Skip to content

Commit 43c403a

Browse files
Use local document loader with vdlCtx
Signed-off-by: ashushukla0412 <[email protected]>
1 parent 75546c2 commit 43c403a

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

tests/15-di-bbs-verify.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as bbs2023Cryptosuite from '@digitalbazaar/bbs-2023-cryptosuite';
77
import {
88
checkDataIntegrityProofVerifyErrors
99
} from 'data-integrity-test-suite-assertion';
10+
import {documentLoader} from './vc-generator/documentLoader.js';
1011
import {endpoints} from 'vc-test-suite-implementations';
1112
import {filterVerifiers} from './helpers.js';
1213
import {getMultiKey} from './vc-generator/key-gen.js';
@@ -30,6 +31,7 @@ for(const vcVersion of vectors.vcTypes) {
3031
authentication: true
3132
},
3233
testDataOptions: {
34+
documentLoader,
3335
suiteName: 'bbs-2023',
3436
key,
3537
cryptosuite: bbs2023Cryptosuite,

tests/vc-generator/contexts.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,42 @@ import dataIntegrityCtx from '@digitalbazaar/data-integrity-context';
1414
import didCtx from '@digitalcredentials/did-context';
1515
import multikeyCtx from '@digitalbazaar/multikey-context';
1616

17-
const contextMap = new Map(credentialsContexts);
17+
const contextMap = new Map();
1818
const setContexts = contexts => {
1919
for(const [key, value] of contexts) {
2020
contextMap.set(key, structuredClone(value));
2121
}
2222
};
23+
const invalidPurpose = {
24+
'@id': 'https://w3id.org/security#invalidPurpose',
25+
'@type': '@id',
26+
'@container': '@set'
27+
};
2328

24-
const {context: vc2Context} = namedCredentialsContexts.get('v2');
25-
const v2Ctx = vc2Context['@context'];
29+
// adding terms manually
30+
const {
31+
id: v2ContextUrl,
32+
context: v2Context
33+
} = structuredClone(namedCredentialsContexts.get('v2'));
34+
const v2Ctx = v2Context['@context'];
2635
v2Ctx.UnknownProofType = structuredClone(v2Ctx.DataIntegrityProof);
36+
v2Ctx.DataIntegrityProof['@context'].proofPurpose['@context'].invalidPurpose =
37+
invalidPurpose;
38+
v2Ctx.undefinedTerm = 'urn:example:undefinedTerm';
39+
2740
const _dataIntegrityCtx = structuredClone(dataIntegrityCtx.CONTEXT);
2841
const diCtx = _dataIntegrityCtx['@context'];
2942
diCtx.UnknownProofType = structuredClone(diCtx.DataIntegrityProof);
30-
contextMap.set(
31-
dataIntegrityCtx.constants.CONTEXT_URL,
32-
_dataIntegrityCtx
33-
);
34-
// add contexts for the documentLoader
43+
diCtx.DataIntegrityProof['@context'].proofPurpose['@context'].invalidPurpose =
44+
invalidPurpose;
45+
diCtx.undefinedTerm = 'urn:example:undefinedTerm';
46+
47+
// adding to contextMap
48+
setContexts(didCtx.contexts);
49+
setContexts(credentialsContexts);
3550
contextMap.set(multikeyCtx.constants.CONTEXT_URL, multikeyCtx.CONTEXT);
3651
contextMap.set(vdlCtxUrl, vdlCtx);
37-
// add the dids contexts
38-
setContexts(didCtx.contexts);
52+
contextMap.set(dataIntegrityCtx.constants.CONTEXT_URL, _dataIntegrityCtx);
53+
contextMap.set(v2ContextUrl, v2Context);
3954

4055
export {contextMap};

0 commit comments

Comments
 (0)