Skip to content

Commit 8b44f59

Browse files
committed
chore: fixes for oid4vc 1.0
1 parent 304a4f8 commit 8b44f59

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

packages/client/lib/CredentialRequestClient.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,21 @@ export class CredentialRequestClient {
362362
? [credentialIdentifier]
363363
: undefined)
364364

365+
// OID4VCI 1.0 uses 'proofs' (plural) instead of 'proof' (singular)
366+
// See https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
367+
let proofsBody: Record<string, unknown> = {}
368+
if (proof) {
369+
const proofJwt = proof.jwt
370+
proofsBody = { proofs: { jwt: [proofJwt] } }
371+
}
372+
365373
const request: CredentialRequestV1_0 = {
366374
credential_configuration_id: configId,
367375
...(identifiers && identifiers.length > 0 && { credential_identifiers: identifiers }),
368-
...commonBody,
369-
}
376+
...(issuer_state && { issuer_state }),
377+
...proofsBody,
378+
...opts.subjectIssuance,
379+
} as CredentialRequestV1_0
370380
return request
371381
}
372382

packages/client/lib/OpenID4VCIClient.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,13 @@ export class OpenID4VCIClient {
541541
this._state.dpopResponseParams = response.params
542542
if (response.errorBody) {
543543
logger.debug(`Credential request error:\r\n${JSON.stringify(response.errorBody)}`)
544+
const errDesc = response.errorBody.error_description
545+
? `: ${response.errorBody.error_description}`
546+
: response.errorBody.error
547+
? `: ${response.errorBody.error}`
548+
: ''
544549
throw Error(
545-
`Retrieving a credential from ${this._state.endpointMetadata?.credential_endpoint} for issuer ${this.getIssuer()} failed with status: ${response.origResponse.status}`,
550+
`Retrieving a credential from ${this._state.endpointMetadata?.credential_endpoint} for issuer ${this.getIssuer()} failed with status: ${response.origResponse.status}${errDesc}`,
546551
)
547552
} else if (!response.successBody) {
548553
logger.debug(`Credential request error. No success body`)
@@ -603,9 +608,14 @@ export class OpenID4VCIClient {
603608
this._state.dpopResponseParams = response2.params
604609
if (response2.errorBody) {
605610
logger.debug(`Credential request error (after retry):\r\n${JSON.stringify(response2.errorBody)}`)
611+
const errDesc2 = response2.errorBody.error_description
612+
? `: ${response2.errorBody.error_description}`
613+
: response2.errorBody.error
614+
? `: ${response2.errorBody.error}`
615+
: ''
606616
return Promise.reject(
607617
Error(
608-
`Retrieving a credential from ${this._state.endpointMetadata?.credential_endpoint} for issuer ${this.getIssuer()} failed after retry with status: ${response2.origResponse.status}`,
618+
`Retrieving a credential from ${this._state.endpointMetadata?.credential_endpoint} for issuer ${this.getIssuer()} failed after retry with status: ${response2.origResponse.status}${errDesc2}`,
609619
),
610620
)
611621
} else if (!response2.successBody) {

0 commit comments

Comments
 (0)