Skip to content

Commit

Permalink
Add multiple language support for name and description.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Dec 17, 2024
1 parent 211877a commit a93aea8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 14 additions & 7 deletions schemas/bedrock-vc-issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ const vcdmTypedObjectSet = {
}]
};

const languageValue = {
const languageObject = {
type: 'object',
required: ['@value'],
additionalProperties: false,
Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
37 changes: 37 additions & 0 deletions test/mocha/assertions/issueWithoutStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a93aea8

Please sign in to comment.