diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c90e7da..8e0f3b3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # bedrock-vc-issuer ChangeLog +## 28.3.0 - 2024-12-dd + +### Added +- Add support for multiple language values w/`name` and `description`. + ## 28.2.0 - 2024-12-17 ### Added diff --git a/schemas/bedrock-vc-issuer.js b/schemas/bedrock-vc-issuer.js index 26e83f66..a94a6263 100644 --- a/schemas/bedrock-vc-issuer.js +++ b/schemas/bedrock-vc-issuer.js @@ -305,7 +305,7 @@ const vcdmTypedObjectSet = { }] }; -const languageValue = { +const languageObject = { type: 'object', required: ['@value'], additionalProperties: false, @@ -322,6 +322,17 @@ const languageValue = { } }; +const valueStringOrObject = { + anyOf: [{type: 'string'}, languageObject] +}; + +const languageValue = { + anyOf: [ + valueStringOrObject, + {type: 'array', minItems: 1, items: valueStringOrObject} + ] +}; + export const issueCredentialBody = { title: 'Issue Credential', type: 'object', @@ -352,14 +363,10 @@ export const issueCredentialBody = { credentialSchema: vcdmTypedObjectSet, credentialStatus: vcdmTypedObjectSet, credentialSubject: vcdmObjectOrReferenceSet, - description: { - anyOf: [{type: 'string'}, languageValue] - }, + description: languageValue, evidence: vcdmTypedObjectSet, // `issuer` skipped, handled internally during issuance - name: { - anyOf: [{type: 'string'}, languageValue] - }, + name: languageValue, proof: vcdmTypedObjectSet, refreshService: vcdmTypedObjectSet, relatedResource: vcdmObjectSet, diff --git a/test/mocha/assertions/issueWithoutStatus.js b/test/mocha/assertions/issueWithoutStatus.js index 0000ca1c..7d5ffdb4 100644 --- a/test/mocha/assertions/issueWithoutStatus.js +++ b/test/mocha/assertions/issueWithoutStatus.js @@ -115,6 +115,43 @@ export function testIssueWithoutStatus({ should.not.exist(verifiableCredential.proof.created); } }); + it('issues a valid credential w/multiple "@language"', async () => { + const credential = klona(mockCredentialV2); + credential.name = [{ + '@value': 'Name of credential', + '@language': 'en', + '@direction': 'ltr' + }, { + '@value': 'Name of credential, pip pip', + '@language': 'en-GB', + '@direction': 'ltr' + }]; + credential.description = [{ + '@value': 'Description of credential', + '@language': 'en', + '@direction': 'ltr' + }, { + '@value': 'Description of credential, pip pip', + '@language': 'en-GB', + '@direction': 'ltr' + }]; + const zcapClient = helpers.createZcapClient({capabilityAgent}); + const {verifiableCredential} = await assertions.issueAndAssert({ + configId: noStatusListIssuerId, + credential, + issueOptions, + zcapClient, + capability: noStatusListIssuerRootZcap + }); + should.exist(verifiableCredential.id); + should.not.exist(verifiableCredential.credentialStatus); + // not supported with old `Ed25519Signature2020` + if(suiteName !== 'Ed25519Signature2020') { + // `created` should not be set by default because new issue config + // mechanism was used w/o requesting it + should.not.exist(verifiableCredential.proof.created); + } + }); it('fails to issue an empty credential', async () => { let error;