Skip to content

Commit

Permalink
fix: resolve undefined credential_definition.type in credentialRequest
Browse files Browse the repository at this point in the history
Signed-off-by: Paramet Kongjaroen <parametprame2@gmail.com>
  • Loading branch information
Paramet Kongjaroen authored and parametprame committed Aug 14, 2024
1 parent 3ef3f10 commit 8bb8694
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,17 @@ export class OpenId4VcIssuerService {
credentialRequest.format === OpenId4VciCredentialFormatProfile.JwtVcJson &&
offeredCredential.format === credentialRequest.format
) {
/*
Issue: https://github.com/openwallet-foundation/credo-ts/issues/1963
Handling `credentialRequest.types` by checking if `credentialRequest.credential_definition` is not `undefined`.
`credentialRequest.credential_definition` requires a `type` attribute which does not currently exist.
Therefore, adding the `type` attribute at line 41 in `packages/openid4vc/src/shared/models/index.ts`.
*/

credentialRequest.types = credentialRequest.credential_definition
? credentialRequest.credential_definition.type
: credentialRequest.types

return equalsIgnoreOrder(offeredCredential.credential_definition.type ?? [], credentialRequest.types)
} else if (
credentialRequest.format === OpenId4VciCredentialFormatProfile.JwtVcJsonLd &&
Expand Down
2 changes: 1 addition & 1 deletion packages/openid4vc/src/shared/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type OpenId4VciIssuerMetadata = OpenId4VciIssuerMetadataV1Draft11 | OpenI
export type OpenId4VciIssuerMetadataDisplay = MetadataDisplay

export type OpenId4VciCredentialRequest =
| CredentialRequestJwtVcJson
| (CredentialRequestJwtVcJson & { credential_definition: { type: string[] } })
| CredentialRequestJwtVcJsonLdAndLdpVc
| CredentialRequestSdJwtVc

Expand Down

0 comments on commit 8bb8694

Please sign in to comment.