diff --git a/package.json b/package.json index 414c46916..dc8327778 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "@sphereon/oid4vci-common": "0.15.1-next.9", "@sphereon/oid4vci-client": "0.15.1-next.9", "@sphereon/oid4vci-issuer": "0.15.1-next.9", + "@sphereon/pex": "^4.0.1", "@noble/hashes": "1.2.0", "debug": "^4.3.5", "did-jwt": "6.11.6", diff --git a/packages/oid4vci-holder/src/agent/OID4VCIHolder.ts b/packages/oid4vci-holder/src/agent/OID4VCIHolder.ts index 42e7bc4f5..bdda84319 100644 --- a/packages/oid4vci-holder/src/agent/OID4VCIHolder.ts +++ b/packages/oid4vci-holder/src/agent/OID4VCIHolder.ts @@ -616,8 +616,9 @@ export class OID4VCIHolder implements IAgentPlugin { // FIXME: This type mapping is wrong. It should use credential_identifier in case the access token response has authorization details const types = getTypesFromObject(issuanceOpt) - const credentialTypes = issuanceOpt.credentialConfigurationId ?? issuanceOpt.id ?? types - if (!credentialTypes || (Array.isArray(credentialTypes) && credentialTypes.length === 0)) { + const id: string | undefined = 'id' in issuanceOpt && issuanceOpt.id ? (issuanceOpt.id as string) : undefined + const credentialTypes = asArray(issuanceOpt.credentialConfigurationId ?? id ?? types) + if (!credentialTypes || credentialTypes.length === 0) { return Promise.reject(Error('cannot determine credential id to request')) } const credentialResponse = await client.acquireCredentials({ @@ -632,7 +633,7 @@ export class OID4VCIHolder implements IAgentPlugin { }) const credential = { - id: issuanceOpt.credentialConfigurationId ?? issuanceOpt.id, + id: issuanceOpt.credentialConfigurationId ?? id, types: types ?? asArray(credentialTypes), issuanceOpt, credentialResponse, diff --git a/packages/oid4vci-holder/src/agent/OID4VCIHolderService.ts b/packages/oid4vci-holder/src/agent/OID4VCIHolderService.ts index 03d7d497e..07059b510 100644 --- a/packages/oid4vci-holder/src/agent/OID4VCIHolderService.ts +++ b/packages/oid4vci-holder/src/agent/OID4VCIHolderService.ts @@ -5,6 +5,7 @@ import { CredentialResponse, CredentialsSupportedDisplay, getSupportedCredentials, + getTypesFromCredentialSupported, getTypesFromObject, MetadataDisplay, OpenId4VCIVersion, @@ -27,7 +28,7 @@ import { WrappedVerifiableCredential, } from '@sphereon/ssi-types' import { IIdentifier, IVerifyCredentialArgs, TKeyType, VerifiableCredential } from '@veramo/core' -import { _ExtendedIKey } from '@veramo/utils' +import { _ExtendedIKey, asArray } from '@veramo/utils' import { createJWT, Signer } from 'did-jwt' import { translate } from '../localization/Localization' import { @@ -74,11 +75,8 @@ export const getCredentialBranding = async (args: GetCredentialBrandingArgs): Pr ) const defaultCredentialType = 'VerifiableCredential' - const credentialTypes: Array = ('types' in credentialsConfigSupported // TODO credentialsConfigSupported.types is deprecated - ? (credentialsConfigSupported.types as string[]) - : 'credential_definition' in credentialsConfigSupported - ? credentialsConfigSupported.credential_definition.type - : [defaultCredentialType]) ?? [configId] + const configSupportedTypes = getTypesFromCredentialSupported(credentialsConfigSupported) + const credentialTypes: Array = configSupportedTypes.length === 0 ? asArray(defaultCredentialType) : configSupportedTypes const filteredCredentialTypes = credentialTypes.filter((type: string): boolean => type !== defaultCredentialType) credentialBranding[filteredCredentialTypes[0]] = localeBranding // TODO for now taking the first type @@ -385,7 +383,7 @@ export const getCredentialConfigsSupportedBySingleTypeOrId = async ( allSupported = {} satisfies Record offerSupported.forEach((supported) => { if (supported.id) { - allSupported[supported.id] = supported + allSupported[supported.id as string] = supported return } const id = createIdFromTypes(supported) diff --git a/packages/oid4vci-issuer-rest-api/package.json b/packages/oid4vci-issuer-rest-api/package.json index 2a60e37c2..c0966defd 100644 --- a/packages/oid4vci-issuer-rest-api/package.json +++ b/packages/oid4vci-issuer-rest-api/package.json @@ -34,7 +34,7 @@ "devDependencies": { "@decentralized-identity/ion-sdk": "^0.6.0", "@sphereon/did-uni-client": "^0.6.3", - "@sphereon/pex": "3.3.3", + "@sphereon/pex": "^4.0.1", "@sphereon/pex-models": "^2.2.4", "@sphereon/ssi-sdk-ext.did-provider-jwk": "0.23.1-next.5", "@sphereon/ssi-sdk-ext.key-manager": "0.23.1-next.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1f089322c..d0bff8dee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,7 @@ overrides: '@sphereon/oid4vci-common': 0.15.1-next.9 '@sphereon/oid4vci-client': 0.15.1-next.9 '@sphereon/oid4vci-issuer': 0.15.1-next.9 + '@sphereon/pex': ^4.0.1 '@noble/hashes': 1.2.0 debug: ^4.3.5 did-jwt: 6.11.6 @@ -1033,8 +1034,8 @@ importers: specifier: ^0.6.3 version: 0.6.3 '@sphereon/pex': - specifier: 3.3.3 - version: 3.3.3 + specifier: ^4.0.1 + version: 4.0.1 '@sphereon/pex-models': specifier: ^2.2.4 version: 2.2.4 @@ -7568,7 +7569,7 @@ packages: dependencies: '@astronautlabs/jsonpath': 1.1.2 '@sphereon/did-uni-client': 0.6.3 - '@sphereon/pex': 3.3.3 + '@sphereon/pex': 4.0.1 '@sphereon/pex-models': 2.2.4 '@sphereon/ssi-types': link:packages/ssi-types '@sphereon/wellknown-dids-client': 0.1.3 @@ -7754,24 +7755,6 @@ packages: /@sphereon/pex-models@2.2.4: resolution: {integrity: sha512-pGlp+wplneE1+Lk3U48/2htYKTbONMeG5/x7vhO6AnPUOsnOXeJdftPrBYWVSzz/JH5GJptAc6+pAyYE1zMu4Q==} - /@sphereon/pex@3.3.3: - resolution: {integrity: sha512-CXwdEcMTUh2z/5AriBn3OuShEG06l2tgiIr7qDJthnkez8DQ3sZo2vr4NEQWKKAL+DeAWAI4FryQGO4KuK7yfg==} - engines: {node: '>=18'} - requiresBuild: true - dependencies: - '@astronautlabs/jsonpath': 1.1.2 - '@sd-jwt/decode': 0.6.1 - '@sd-jwt/present': 0.6.1 - '@sd-jwt/types': 0.6.1 - '@sphereon/pex-models': 2.2.4 - '@sphereon/ssi-types': link:packages/ssi-types - ajv: 8.17.1 - ajv-formats: 2.1.1(ajv@8.17.1) - jwt-decode: 3.1.2 - nanoid: 3.3.7 - string.prototype.matchall: 4.0.11 - uint8arrays: 3.1.1 - /@sphereon/pex@4.0.1: resolution: {integrity: sha512-3XnX/YJpxR8ueMO+qZLcn14dYFE4OHqi3i1qMLwPo/7jFFLrTb70uDG1++D+MqS7YTwYQbMtJA9KzzWcKTEg4w==} engines: {node: '>=18'}