Skip to content

Commit

Permalink
Merge pull request #121 from auer-martin/small-fix
Browse files Browse the repository at this point in the history
fix: sdjwtvc decode hasher dependency
  • Loading branch information
nklomp authored Jul 5, 2024
2 parents 0709859 + 7888a14 commit b1d0422
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/issuer/lib/VcIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,24 @@ export class VcIssuer<DIDDoc extends object> {
credential.credentialSubject = Array.isArray(credential.credentialSubject) ? credentialSubjects : credentialSubjects[0]
}

let issuer: string | undefined = undefined
if (credential.iss) {
issuer = credential.iss
} else if (credential.issuer) {
if (typeof credential.issuer === 'string') {
issuer = credential.issuer
} else if (typeof credential.issuer === 'object' && 'id' in credential.issuer && typeof credential.issuer.id === 'string') {
issuer = credential.issuer.id
}
}

const verifiableCredential = await this.issueCredentialImpl(
{
credentialRequest: opts.credentialRequest,
format,
credential,
jwtVerifyResult,
issuer,
},
signerCallback,
)
Expand Down Expand Up @@ -597,23 +609,22 @@ export class VcIssuer<DIDDoc extends object> {
credential: CredentialIssuanceInput
jwtVerifyResult: JwtVerifyResult<DIDDoc>
format?: OID4VCICredentialFormat
issuer?: string
},
issuerCallback?: CredentialSignerCallback<DIDDoc>,
): Promise<W3CVerifiableCredential | CompactSdJwtVc> {
if ((!opts.credential && !opts.credentialRequest) || !this._credentialSignerCallback) {
throw new Error(ISSUER_CONFIG_ERROR)
}
const credential = issuerCallback ? await issuerCallback(opts) : await this._credentialSignerCallback(opts)
const uniform = CredentialMapper.toUniformCredential(credential)
const issuer = uniform.issuer ? (typeof uniform.issuer === 'string' ? uniform.issuer : uniform.issuer.id) : '<unknown>'

// TODO: Create builder
EVENTS.emit(CredentialEventNames.OID4VCI_CREDENTIAL_ISSUED, {
eventName: CredentialEventNames.OID4VCI_CREDENTIAL_ISSUED,
id: v4(),
data: credential,
// TODO: Format, request etc
initiator: issuer ?? '<unknown>',
initiator: opts.issuer ?? '<unknown>',
initiatorType: InitiatorType.EXTERNAL,
system: System.OID4VCI,
subsystem: SubSystem.VC_ISSUER,
Expand Down

0 comments on commit b1d0422

Please sign in to comment.