OID4VC holder (v0.5.10) is not being able to accept json-ld credential offer
Opened this issue · 0 comments
Issue: Error when accepting JSON-LD offer
I encountered the following error when trying to accept a jsonld
offer:
Error: No @context value present, but it is required
at CredentialRequestClient.<anonymous> (/home/frcs/nordivo/credo-playground/credo-ts/node_modules/.pnpm/@sphereon+oid4vci-client@0.16.1-next.3/node_modules/@sphereon/oid4vci-client/lib/CredentialRequestClient.ts:247:15)
at Generator.next (<anonymous>)
at fulfilled (/home/frcs/nordivo/credo-playground/credo-ts/node_modules/.pnpm/@sphereon+oid4vci-client@0.16.1-next.3/node_modules/@sphereon/oid4vci-client/dist/CredentialRequestClient.js:5:58)
This error is being thrown from the oid4vci-client.
Root Cause:
The error indicates that the @context
value is not being passed when handling jwt_vc_json-ld
or ldp_vc
. Without this value, the credential offer fails validation.
Solution:
I added the following lines to the OpenId4VciHolderService.ts
file to include the @context
value when the credential format is either jwt_vc_json-ld
or ldp_vc
.
This change is located here.
const context = offeredCredentialConfiguration.format === OpenId4VciCredentialFormatProfile.JwtVcJsonLd ||
offeredCredentialConfiguration.format === OpenId4VciCredentialFormatProfile.LdpVc
? (offeredCredentialConfiguration.credential_definition as CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_13)['@context']
: undefined;
const credentialResponse = await credentialRequestClient.acquireCredentialsUsingProof({
proofInput: proofOfPossession,
credentialTypes: getTypesFromCredentialSupported(offeredCredentialConfiguration),
format: offeredCredentialConfiguration.format,
createDPoPOpts: createDpopOpts,
context: context // Include @context for jsonld credentials
});
By adding this logic to include the contex
t when the format is jwt_vc_json-ld or ldp_vc, the holder is now able to successfully accept the JSON-LD credential.
Can anyone please review this solution and confirm if this is the appropriate fix for ensuring the context
is correctly passed when dealing with JSON-LD offers?