Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve undefined credential_definition.type in credentialRequest #1989

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,23 +468,32 @@ export class OpenId4VcIssuerService {
credentialRequest.format === OpenId4VciCredentialFormatProfile.JwtVcJson &&
offeredCredential.format === credentialRequest.format
) {
return equalsIgnoreOrder(offeredCredential.credential_definition.type ?? [], credentialRequest.types)
const types =
'credential_definition' in credentialRequest
? credentialRequest.credential_definition.type
: credentialRequest.types

return equalsIgnoreOrder(offeredCredential.credential_definition.type ?? [], types)
} else if (
credentialRequest.format === OpenId4VciCredentialFormatProfile.JwtVcJsonLd &&
offeredCredential.format === credentialRequest.format
) {
return equalsIgnoreOrder(
offeredCredential.credential_definition.type ?? [],
credentialRequest.credential_definition.types
)
const types =
'type' in credentialRequest.credential_definition
? credentialRequest.credential_definition.type
: credentialRequest.credential_definition.types

return equalsIgnoreOrder(offeredCredential.credential_definition.type ?? [], types)
} else if (
credentialRequest.format === OpenId4VciCredentialFormatProfile.LdpVc &&
offeredCredential.format === credentialRequest.format
) {
return equalsIgnoreOrder(
offeredCredential.credential_definition.type ?? [],
credentialRequest.credential_definition.types
)
const types =
'type' in credentialRequest.credential_definition
? credentialRequest.credential_definition.type
: credentialRequest.credential_definition.types

return equalsIgnoreOrder(offeredCredential.credential_definition.type ?? [], types)
} else if (
credentialRequest.format === OpenId4VciCredentialFormatProfile.SdJwtVc &&
offeredCredential.format === credentialRequest.format
Expand Down
14 changes: 9 additions & 5 deletions packages/openid4vc/src/shared/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import type {
CredentialOfferPayloadV1_0_13,
CredentialRequestJwtVcJson,
CredentialRequestJwtVcJsonLdAndLdpVc,
CredentialRequestJwtVcJsonLdAndLdpVcV1_0_13,
CredentialRequestJwtVcJsonV1_0_13,
CredentialRequestSdJwtVc,
CredentialsSupportedLegacy,
MetadataDisplay,
TxCode,
UniformCredentialRequest,
} from '@sphereon/oid4vci-common'

export type OpenId4VciCredentialSupportedWithId = OpenId4VciCredentialSupported & { id: string }
Expand All @@ -31,13 +34,14 @@ export type OpenId4VciIssuerMetadata = OpenId4VciIssuerMetadataV1Draft11 | OpenI

export type OpenId4VciIssuerMetadataDisplay = MetadataDisplay

export type OpenId4VciCredentialRequest =
| CredentialRequestJwtVcJson
export type OpenId4VciCredentialRequest = UniformCredentialRequest

export type OpenId4VciCredentialRequestJwtVcJson = CredentialRequestJwtVcJson | CredentialRequestJwtVcJsonV1_0_13

export type OpenId4VciCredentialRequestJwtVcJsonLdAndLdpVc =
| CredentialRequestJwtVcJsonLdAndLdpVc
| CredentialRequestSdJwtVc
| CredentialRequestJwtVcJsonLdAndLdpVcV1_0_13

export type OpenId4VciCredentialRequestJwtVcJson = CredentialRequestJwtVcJson
export type OpenId4VciCredentialRequestJwtVcJsonLdAndLdpVc = CredentialRequestJwtVcJsonLdAndLdpVc
export type OpenId4VciCredentialRequestSdJwtVc = CredentialRequestSdJwtVc
export type OpenId4VciCredentialOffer = AssertedUniformCredentialOffer
export type OpenId4VciCredentialOfferPayload = CredentialOfferPayloadV1_0_11 | CredentialOfferPayloadV1_0_13
Expand Down
Loading