@veramo/credential-ld 3.1.1-next.9 → 3.1.2-next.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -115,14 +115,14 @@ class CredentialIssuerLD {
115
115
  verifyCredentialLD(args, context) {
116
116
  return __awaiter(this, void 0, void 0, function* () {
117
117
  const credential = args.credential;
118
- return this.ldCredentialModule.verifyCredential(credential, context);
118
+ return this.ldCredentialModule.verifyCredential(credential, args.fetchRemoteContexts || false, context);
119
119
  });
120
120
  }
121
121
  /** {@inheritdoc ICredentialIssuerLD.verifyPresentationLD} */
122
122
  verifyPresentationLD(args, context) {
123
123
  return __awaiter(this, void 0, void 0, function* () {
124
124
  const presentation = args.presentation;
125
- return this.ldCredentialModule.verifyPresentation(presentation, args.challenge, args.domain, context);
125
+ return this.ldCredentialModule.verifyPresentation(presentation, args.challenge, args.domain, args.fetchRemoteContexts || false, context);
126
126
  });
127
127
  }
128
128
  findSigningKeyWithId(context, identifier, keyRef) {
@@ -1 +1 @@
1
- {"version":3,"file":"action-handler.js","sourceRoot":"","sources":["../src/action-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAWA,yBAA8C;AAC9C,kDAAyB;AACzB,2DAAqD;AACrD,yCASsB;AAEtB,iEAA2D;AAC3D,uDAAiD;AAWjD,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,2BAA2B,CAAC,CAAA;AAEhD;;;;GAIG;AACH,MAAa,kBAAkB;IAM7B,YAAY,OAA0F;QAJ7F,WAAM,GAAG,SAAM,CAAC,iBAAiB,CAAA;QAKxC,IAAI,CAAC,kBAAkB,GAAG,IAAI,yCAAkB,CAAC;YAC/C,eAAe,EAAE,IAAI,mCAAe,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5E,aAAa,EAAE,IAAI,+BAAa,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;SACzE,CAAC,CAA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AE,CAAA;YAC5D,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAA;QAC7C,CAAC;KAAA;CACF;AAxLD,gDAwLC"}
@@ -1,12 +1,12 @@
1
1
  /**
2
- * The LdContextLoader is initialized with a List of Map<string, ContextDoc>
2
+ * The LdContextLoader is initialized with a List of Map<string, ContextDoc | Promise<ContextDoc>>
3
3
  * that it unifies into a single Map to provide to the documentLoader within
4
4
  * the w3c credential module.
5
5
  */
6
6
  import { OrPromise, RecordLike } from '@veramo/utils';
7
7
  import { ContextDoc } from './types';
8
8
  export declare class LdContextLoader {
9
- private contexts;
9
+ private readonly contexts;
10
10
  constructor(options: {
11
11
  contextsPaths: RecordLike<OrPromise<ContextDoc>>[];
12
12
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ld-context-loader.d.ts","sourceRoot":"","sources":["../src/ld-context-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAuC;gBAE3C,OAAO,EAAE;QAAE,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAA;KAAE;IAU3E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAInB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAG5C"}
1
+ {"version":3,"file":"ld-context-loader.d.ts","sourceRoot":"","sources":["../src/ld-context-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAc,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuC;gBAEpD,OAAO,EAAE;QAAE,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAA;KAAE;IAW3E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAInB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAG5C"}
@@ -10,12 +10,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.LdContextLoader = void 0;
13
+ /**
14
+ * The LdContextLoader is initialized with a List of Map<string, ContextDoc | Promise<ContextDoc>>
15
+ * that it unifies into a single Map to provide to the documentLoader within
16
+ * the w3c credential module.
17
+ */
18
+ const utils_1 = require("@veramo/utils");
13
19
  class LdContextLoader {
14
20
  constructor(options) {
15
21
  this.contexts = {};
16
- // generate-plugin-schema is failing unless we use the cast to `any[]`
17
22
  Array.from(options.contextsPaths, (mapItem) => {
18
- for (const [key, value] of mapItem) {
23
+ const map = (0, utils_1.isIterable)(mapItem) ? mapItem : Object.entries(mapItem);
24
+ // generate-plugin-schema is failing unless we use the cast to `any[]`
25
+ for (const [key, value] of map) {
19
26
  this.contexts[key] = value;
20
27
  }
21
28
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ld-context-loader.js","sourceRoot":"","sources":["../src/ld-context-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,MAAa,eAAe;IAG1B,YAAY,OAA+D;QACzE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,sEAAsE;QACtE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAsB,EAAE,CAAC,OAAO,EAAE,EAAE;YACrD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE;gBAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;aAC3B;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,WAAW,CAAA;IACjF,CAAC;IAEK,GAAG,CAAC,GAAW;;YACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QAC3B,CAAC;KAAA;CACF;AApBD,0CAoBC"}
1
+ {"version":3,"file":"ld-context-loader.js","sourceRoot":"","sources":["../src/ld-context-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;GAIG;AACH,yCAAiE;AAGjE,MAAa,eAAe;IAG1B,YAAY,OAA+D;QACzE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE;YAC5C,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YACnE,sEAAsE;YACtE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAY,EAAE;gBACvC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;aAC3B;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,WAAW,CAAA;IACjF,CAAC;IAEK,GAAG,CAAC,GAAW;;YACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QAC3B,CAAC;KAAA;CACF;AArBD,0CAqBC"}
@@ -16,10 +16,10 @@ export declare class LdCredentialModule {
16
16
  ldContextLoader: LdContextLoader;
17
17
  ldSuiteLoader: LdSuiteLoader;
18
18
  });
19
- getDocumentLoader(context: IAgentContext<IResolver>): any;
19
+ getDocumentLoader(context: IAgentContext<IResolver>, attemptToFetchContexts?: boolean): any;
20
20
  issueLDVerifiableCredential(credential: CredentialPayload, issuerDid: string, key: IKey, verificationMethodId: string, context: IAgentContext<RequiredAgentMethods>): Promise<VerifiableCredential>;
21
21
  signLDVerifiablePresentation(presentation: PresentationPayload, holderDid: string, key: IKey, verificationMethodId: string, challenge: string | undefined, domain: string | undefined, context: IAgentContext<RequiredAgentMethods>): Promise<VerifiablePresentation>;
22
- verifyCredential(credential: VerifiableCredential, context: IAgentContext<IResolver>): Promise<boolean>;
23
- verifyPresentation(presentation: VerifiablePresentation, challenge: string | undefined, domain: string | undefined, context: IAgentContext<IResolver>): Promise<boolean>;
22
+ verifyCredential(credential: VerifiableCredential, fetchRemoteContexts: boolean | undefined, context: IAgentContext<IResolver>): Promise<boolean>;
23
+ verifyPresentation(presentation: VerifiablePresentation, challenge: string | undefined, domain: string | undefined, fetchRemoteContexts: boolean | undefined, context: IAgentContext<IResolver>): Promise<boolean>;
24
24
  }
25
25
  //# sourceMappingURL=ld-credential-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ld-credential-module.d.ts","sourceRoot":"","sources":["../src/ld-credential-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,cAAc,CAAA;AAIrB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMlD,qBAAa,kBAAkB;IAC7B;;;;;;OAMG;IAEH,OAAO,CAAC,eAAe,CAAiB;IACxC,aAAa,EAAE,aAAa,CAAA;gBAChB,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ule", { value: true });
34
34
  exports.LdCredentialModule = void 0;
35
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
35
36
  const debug_1 = __importDefault(require("debug"));
36
37
  const jsonld_signatures_1 = require("jsonld-signatures");
37
38
  const vc = __importStar(require("vc-js"));
@@ -42,7 +43,7 @@ class LdCredentialModule {
42
43
  this.ldContextLoader = options.ldContextLoader;
43
44
  this.ldSuiteLoader = options.ldSuiteLoader;
44
45
  }
45
- getDocumentLoader(context) {
46
+ getDocumentLoader(context, attemptToFetchContexts = false) {
46
47
  return (0, jsonld_signatures_1.extendContextLoader)((url) => __awaiter(this, void 0, void 0, function* () {
47
48
  // console.log(`resolving context for: ${url}`)
48
49
  // did resolution
@@ -70,8 +71,27 @@ class LdCredentialModule {
70
71
  document: contextDoc,
71
72
  };
72
73
  }
73
- debug('WARNING: Possible unknown context/identifier for', url);
74
- console.log(`WARNING: Possible unknown context/identifier for: ${url}`);
74
+ else {
75
+ if (attemptToFetchContexts) {
76
+ // attempt to fetch the remote context!!!! MEGA FAIL for JSON-LD.
77
+ debug("WARNING: attempting to fetch the doc directly for ", url);
78
+ try {
79
+ const response = yield (0, cross_fetch_1.default)(url);
80
+ if (response.status === 200) {
81
+ const document = yield response.json();
82
+ return {
83
+ contextUrl: null,
84
+ documentUrl: url,
85
+ document
86
+ };
87
+ }
88
+ }
89
+ catch (e) {
90
+ debug("WARNING: unable to fetch the doc or interpret it as JSON", e);
91
+ }
92
+ }
93
+ }
94
+ debug(`WARNING: Possible unknown context/identifier for ${url} \n falling back to default documentLoader`);
75
95
  return vc.defaultDocumentLoader(url);
76
96
  }));
77
97
  }
@@ -105,12 +125,12 @@ class LdCredentialModule {
105
125
  });
106
126
  });
107
127
  }
108
- verifyCredential(credential, context) {
128
+ verifyCredential(credential, fetchRemoteContexts = false, context) {
109
129
  return __awaiter(this, void 0, void 0, function* () {
110
130
  const result = yield vc.verifyCredential({
111
131
  credential,
112
132
  suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
113
- documentLoader: this.getDocumentLoader(context),
133
+ documentLoader: this.getDocumentLoader(context, fetchRemoteContexts),
114
134
  purpose: new AssertionProofPurpose(),
115
135
  compactProof: false,
116
136
  });
@@ -123,12 +143,12 @@ class LdCredentialModule {
123
143
  throw Error('Error verifying LD Verifiable Credential');
124
144
  });
125
145
  }
126
- verifyPresentation(presentation, challenge, domain, context) {
146
+ verifyPresentation(presentation, challenge, domain, fetchRemoteContexts = false, context) {
127
147
  return __awaiter(this, void 0, void 0, function* () {
128
148
  const result = yield vc.verify({
129
149
  presentation,
130
150
  suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
131
- documentLoader: this.getDocumentLoader(context),
151
+ documentLoader: this.getDocumentLoader(context, fetchRemoteContexts),
132
152
  challenge,
133
153
  domain,
134
154
  purpose: new AssertionProofPurpose(),
@@ -1 +1 @@
1
- {"version":3,"file":"ld-credential-module.js","sourceRoot":"","sources":["../src/ld-credential-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,kDAAyB;AACzB,yDAAiE;AACjE,0CAA2B;AAK3B,MAAM,qBAAqB,GAAG,4BAAQ,CAAC,qBAAqB,CAAA;AAE5D,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,iCAAiC,CAAC,CAAA;AAEtD,MAAa,kBAAkB;IAW7B,YAAY,OAA2E;QACrF,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAA;QAC9C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;IAC5C,CAAC;IAED,iBAAiB,CAAC,OAAiC;QACjD,OAAO,IAAA,uCAAmB,EAAC,CAAO,GAAW,EAAE,EAAE;YAC/C,+CAA+C;YAE/C,iBAAiB;YACjB,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;gBACxC,MAAM,gBAAgB,GAAG,MAAM,OAAO,CA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EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;YACrF,gDAAgD;YAChD,MAAM,KAAK,CAAC,0CAA0C,CAAC,CAAA;QACzD,CAAC;KAAA;IAEK,kBAAkB,CACtB,YAAoC,EACpC,SAA6B,EAC7B,MAA0B,EAC1B,sBAA+B,KAAK,EACpC,OAAiC;;YAEjC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC;gBAC7B,YAAY;gBACZ,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC;gBACzF,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,CAAC;gBACpE,SAAS;gBACT,MAAM;gBACN,OAAO,EAAE,IAAI,qBAAqB,EAAE;gBACpC,YAAY,EAAE,KAAK;aACpB,CAAC,CAAA;YAEF,IAAI,MAAM,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAA;YAEhC,gBAAgB;YAEhB,+BAA+B;YAC/B,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAA;YACzD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;YAC5C,MAAM,KAAK,CAAC,4CAA4C,CAAC,CAAA;QAC3D,CAAC;KAAA;CACF;AAxKD,gDAwKC"}
@@ -1,2 +1,6 @@
1
- export declare const LdDefaultContexts: Map<string, any>;
1
+ import { ContextDoc } from './types';
2
+ /**
3
+ * Provides a hardcoded map of common context definitions
4
+ */
5
+ export declare const LdDefaultContexts: Map<string, Promise<ContextDoc>>;
2
6
  //# sourceMappingURL=ld-default-contexts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ld-default-contexts.d.ts","sourceRoot":"","sources":["../src/ld-default-contexts.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,kBAa5B,CAAA"}
1
+ {"version":3,"file":"ld-default-contexts.d.ts","sourceRoot":"","sources":["../src/ld-default-contexts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AASpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,kCAe5B,CAAA"}
@@ -18,19 +18,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
21
30
  Object.defineProperty(exports, "__esModule", { value: true });
22
31
  exports.LdDefaultContexts = void 0;
23
32
  const fs = __importStar(require("fs"));
24
33
  const path = __importStar(require("path"));
25
34
  function _read(_path) {
26
- return JSON.parse(fs.readFileSync(path.join(__dirname, '../contexts', _path), { encoding: 'utf8' }));
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const contextDefinition = yield fs.promises.readFile(path.join(__dirname, '../contexts', _path), {
37
+ encoding: 'utf8',
38
+ });
39
+ return JSON.parse(contextDefinition);
40
+ });
27
41
  }
42
+ /**
43
+ * Provides a hardcoded map of common context definitions
44
+ */
28
45
  exports.LdDefaultContexts = new Map([
46
+ ['https://www.w3.org/2018/credentials/v1', _read('w3_2018_credentials_v1.jsonld')],
47
+ ['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
48
+ ['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],
29
49
  ['https://veramo.io/contexts/socialmedia/v1', _read('socialmedia-v1.jsonld')],
30
50
  ['https://veramo.io/contexts/kyc/v1', _read('kyc-v1.jsonld')],
31
51
  ['https://veramo.io/contexts/profile/v1', _read('profile-v1.jsonld')],
32
- ['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
33
- ['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],
34
52
  ['https://ns.did.ai/transmute/v1', _read('transmute_v1.jsonld')],
35
53
  [
36
54
  'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
@@ -1 +1 @@
1
- {"version":3,"file":"ld-default-contexts.js","sourceRoot":"","sources":["../src/ld-default-contexts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAE5B,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AACtG,CAAC;AAEY,QAAA,iBAAiB,GAAG,IAAI,GAAG,CAAC;IACvC,CAAC,2CAA2C,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC7E,CAAC,mCAAmC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC7D,CAAC,uCAAuC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACrE,CAAC,8BAA8B,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACrE,CAAC,4BAA4B,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACzD,CAAC,gCAAgC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAChE;QACE,6GAA6G;QAC7G,KAAK,CAAC,6CAA6C,CAAC;KACrD;IACD,CAAC,kDAAkD,EAAE,KAAK,CAAC,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ages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.19"
8
+ "packageVersion": "7.19.4"
9
9
  }
10
10
  ]
11
11
  }
package/build/types.d.ts CHANGED
@@ -133,6 +133,12 @@ export interface IVerifyCredentialLDArgs {
133
133
  *
134
134
  */
135
135
  credential: VerifiableCredential;
136
+ /**
137
+ * Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
138
+ *
139
+ * @default false
140
+ */
141
+ fetchRemoteContexts?: boolean;
136
142
  }
137
143
  /**
138
144
  * Encapsulates the parameters required to verify a
@@ -158,6 +164,12 @@ export interface IVerifyPresentationLDArgs {
158
164
  * Optional (only for JWT) string domain parameter to verify the verifiable presentation against
159
165
  */
160
166
  domain?: string;
167
+ /**
168
+ * Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
169
+ *
170
+ * @default false
171
+ */
172
+ fetchRemoteContexts?: boolean;
161
173
  }
162
174
  /**
163
175
  * Represents the requirements that this plugin has.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EAEX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,cAAc,CAAA;AAErB;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D;;;;;;;;;;;;;OAaG;IACH,8BAA8B,CAC5B,IAAI,EAAE,mCAAmC,EACzC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAElC;;;;;;;;;;;;;OAaG;IACH,4BAA4B,CAC1B,IAAI,EAAE,iCAAiC,EACvC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAEhC;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,IAAI,EAAE,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G;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;;OAOG;IACH,YAAY,EAAE,sBAAsB,CAAA;IAEpC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;OAIG;IACF,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED;;;;;;;GAOG;AACH,oBAAY,gBAAgB,GAAG,aAAa,CAC1C,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,gBAAgB,CAAC,CACvG,CAAA;AAED,oBAAY,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA"}
@@ -0,0 +1,237 @@
1
+ {
2
+ "@context": {
3
+ "@version": 1.1,
4
+ "@protected": true,
5
+
6
+ "id": "@id",
7
+ "type": "@type",
8
+
9
+ "VerifiableCredential": {
10
+ "@id": "https://www.w3.org/2018/credentials#VerifiableCredential",
11
+ "@context": {
12
+ "@version": 1.1,
13
+ "@protected": true,
14
+
15
+ "id": "@id",
16
+ "type": "@type",
17
+
18
+ "cred": "https://www.w3.org/2018/credentials#",
19
+ "sec": "https://w3id.org/security#",
20
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
21
+
22
+ "credentialSchema": {
23
+ "@id": "cred:credentialSchema",
24
+ "@type": "@id",
25
+ "@context": {
26
+ "@version": 1.1,
27
+ "@protected": true,
28
+
29
+ "id": "@id",
30
+ "type": "@type",
31
+
32
+ "cred": "https://www.w3.org/2018/credentials#",
33
+
34
+ "JsonSchemaValidator2018": "cred:JsonSchemaValidator2018"
35
+ }
36
+ },
37
+ "credentialStatus": {"@id": "cred:credentialStatus", "@type": "@id"},
38
+ "credentialSubject": {"@id": "cred:credentialSubject", "@type": "@id"},
39
+ "evidence": {"@id": "cred:evidence", "@type": "@id"},
40
+ "expirationDate": {"@id": "cred:expirationDate", "@type": "xsd:dateTime"},
41
+ "holder": {"@id": "cred:holder", "@type": "@id"},
42
+ "issued": {"@id": "cred:issued", "@type": "xsd:dateTime"},
43
+ "issuer": {"@id": "cred:issuer", "@type": "@id"},
44
+ "issuanceDate": {"@id": "cred:issuanceDate", "@type": "xsd:dateTime"},
45
+ "proof": {"@id": "sec:proof", "@type": "@id", "@container": "@graph"},
46
+ "refreshService": {
47
+ "@id": "cred:refreshService",
48
+ "@type": "@id",
49
+ "@context": {
50
+ "@version": 1.1,
51
+ "@protected": true,
52
+
53
+ "id": "@id",
54
+ "type": "@type",
55
+
56
+ "cred": "https://www.w3.org/2018/credentials#",
57
+
58
+ "ManualRefreshService2018": "cred:ManualRefreshService2018"
59
+ }
60
+ },
61
+ "termsOfUse": {"@id": "cred:termsOfUse", "@type": "@id"},
62
+ "validFrom": {"@id": "cred:validFrom", "@type": "xsd:dateTime"},
63
+ "validUntil": {"@id": "cred:validUntil", "@type": "xsd:dateTime"}
64
+ }
65
+ },
66
+
67
+ "VerifiablePresentation": {
68
+ "@id": "https://www.w3.org/2018/credentials#VerifiablePresentation",
69
+ "@context": {
70
+ "@version": 1.1,
71
+ "@protected": true,
72
+
73
+ "id": "@id",
74
+ "type": "@type",
75
+
76
+ "cred": "https://www.w3.org/2018/credentials#",
77
+ "sec": "https://w3id.org/security#",
78
+
79
+ "holder": {"@id": "cred:holder", "@type": "@id"},
80
+ "proof": {"@id": "sec:proof", "@type": "@id", "@container": "@graph"},
81
+ "verifiableCredential": {"@id": "cred:verifiableCredential", "@type": "@id", "@container": "@graph"}
82
+ }
83
+ },
84
+
85
+ "EcdsaSecp256k1Signature2019": {
86
+ "@id": "https://w3id.org/security#EcdsaSecp256k1Signature2019",
87
+ "@context": {
88
+ "@version": 1.1,
89
+ "@protected": true,
90
+
91
+ "id": "@id",
92
+ "type": "@type",
93
+
94
+ "sec": "https://w3id.org/security#",
95
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
96
+
97
+ "challenge": "sec:challenge",
98
+ "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"},
99
+ "domain": "sec:domain",
100
+ "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
101
+ "jws": "sec:jws",
102
+ "nonce": "sec:nonce",
103
+ "proofPurpose": {
104
+ "@id": "sec:proofPurpose",
105
+ "@type": "@vocab",
106
+ "@context": {
107
+ "@version": 1.1,
108
+ "@protected": true,
109
+
110
+ "id": "@id",
111
+ "type": "@type",
112
+
113
+ "sec": "https://w3id.org/security#",
114
+
115
+ "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"},
116
+ "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"}
117
+ }
118
+ },
119
+ "proofValue": "sec:proofValue",
120
+ "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"}
121
+ }
122
+ },
123
+
124
+ "EcdsaSecp256r1Signature2019": {
125
+ "@id": "https://w3id.org/security#EcdsaSecp256r1Signature2019",
126
+ "@context": {
127
+ "@version": 1.1,
128
+ "@protected": true,
129
+
130
+ "id": "@id",
131
+ "type": "@type",
132
+
133
+ "sec": "https://w3id.org/security#",
134
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
135
+
136
+ "challenge": "sec:challenge",
137
+ "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"},
138
+ "domain": "sec:domain",
139
+ "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
140
+ "jws": "sec:jws",
141
+ "nonce": "sec:nonce",
142
+ "proofPurpose": {
143
+ "@id": "sec:proofPurpose",
144
+ "@type": "@vocab",
145
+ "@context": {
146
+ "@version": 1.1,
147
+ "@protected": true,
148
+
149
+ "id": "@id",
150
+ "type": "@type",
151
+
152
+ "sec": "https://w3id.org/security#",
153
+
154
+ "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"},
155
+ "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"}
156
+ }
157
+ },
158
+ "proofValue": "sec:proofValue",
159
+ "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"}
160
+ }
161
+ },
162
+
163
+ "Ed25519Signature2018": {
164
+ "@id": "https://w3id.org/security#Ed25519Signature2018",
165
+ "@context": {
166
+ "@version": 1.1,
167
+ "@protected": true,
168
+
169
+ "id": "@id",
170
+ "type": "@type",
171
+
172
+ "sec": "https://w3id.org/security#",
173
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
174
+
175
+ "challenge": "sec:challenge",
176
+ "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"},
177
+ "domain": "sec:domain",
178
+ "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
179
+ "jws": "sec:jws",
180
+ "nonce": "sec:nonce",
181
+ "proofPurpose": {
182
+ "@id": "sec:proofPurpose",
183
+ "@type": "@vocab",
184
+ "@context": {
185
+ "@version": 1.1,
186
+ "@protected": true,
187
+
188
+ "id": "@id",
189
+ "type": "@type",
190
+
191
+ "sec": "https://w3id.org/security#",
192
+
193
+ "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"},
194
+ "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"}
195
+ }
196
+ },
197
+ "proofValue": "sec:proofValue",
198
+ "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"}
199
+ }
200
+ },
201
+
202
+ "RsaSignature2018": {
203
+ "@id": "https://w3id.org/security#RsaSignature2018",
204
+ "@context": {
205
+ "@version": 1.1,
206
+ "@protected": true,
207
+
208
+ "challenge": "sec:challenge",
209
+ "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"},
210
+ "domain": "sec:domain",
211
+ "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
212
+ "jws": "sec:jws",
213
+ "nonce": "sec:nonce",
214
+ "proofPurpose": {
215
+ "@id": "sec:proofPurpose",
216
+ "@type": "@vocab",
217
+ "@context": {
218
+ "@version": 1.1,
219
+ "@protected": true,
220
+
221
+ "id": "@id",
222
+ "type": "@type",
223
+
224
+ "sec": "https://w3id.org/security#",
225
+
226
+ "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"},
227
+ "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"}
228
+ }
229
+ },
230
+ "proofValue": "sec:proofValue",
231
+ "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"}
232
+ }
233
+ },
234
+
235
+ "proof": {"@id": "https://w3id.org/security#proof", "@type": "@id", "@container": "@graph"}
236
+ }
237
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@veramo/credential-ld",
3
3
  "description": "Veramo plugin for working with W3C JSON-LD Verifiable Credentials & Presentations.",
4
- "version": "3.1.1-next.9+3e2cf29e",
4
+ "version": "3.1.2-next.31+faebd001",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
7
7
  "scripts": {
@@ -14,23 +14,23 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@transmute/credentials-context": "^0.7.0-unstable.26",
18
- "@transmute/ed25519-signature-2018": "^0.7.0-unstable.27",
17
+ "@transmute/credentials-context": "^0.7.0-unstable.34",
18
+ "@transmute/ed25519-signature-2018": "^0.7.0-unstable.34",
19
19
  "@transmute/lds-ecdsa-secp256k1-recovery2020": "^0.0.7",
20
- "@veramo/core": "^3.1.1-next.9+3e2cf29e",
21
- "@veramo/did-resolver": "^3.1.1-next.9+3e2cf29e",
22
- "@veramo/utils": "^3.1.1-next.9+3e2cf29e",
23
- "debug": "^4.1.1",
24
- "did-resolver": "3.1.3",
20
+ "@veramo/core": "^3.1.2-next.31+faebd001",
21
+ "@veramo/did-resolver": "^3.1.2-next.31+faebd001",
22
+ "@veramo/utils": "^3.1.2-next.31+faebd001",
23
+ "debug": "^4.3.3",
24
+ "did-resolver": "^3.1.5",
25
25
  "jsonld": "^5.2.0",
26
- "jsonld-signatures": "^9.0.2",
27
- "uint8arrays": "^2.1.3",
26
+ "jsonld-signatures": "^9.3.1",
27
+ "uint8arrays": "^3.0.0",
28
28
  "vc-js": "^0.6.4"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/debug": "4.1.7",
32
- "borc": "^3.0.0",
33
- "typescript": "4.4.4"
32
+ "borc": "3.0.0",
33
+ "typescript": "4.5.4"
34
34
  },
35
35
  "files": [
36
36
  "build/**/*",
@@ -47,5 +47,5 @@
47
47
  "author": "Mircea Nistor <mircea.nistor@mesh.xyz>",
48
48
  "license": "Apache-2.0",
49
49
  "keywords": [],
50
- "gitHead": "3e2cf29ecc7aecf0a3750beec7490306ceb79dab"
50
+ "gitHead": "faebd0015883e2be7d85da2896ea7628cf567dc9"
51
51
  }
@@ -326,6 +326,11 @@
326
326
  "credential": {
327
327
  "$ref": "#/components/schemas/VerifiableCredential",
328
328
  "description": "The json payload of the Credential according to the\n {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model } \n\nThe signer of the Credential is chosen based on the `issuer.id` property of the `credential`"
329
+ },
330
+ "fetchRemoteContexts": {
331
+ "type": "boolean",
332
+ "description": "Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.",
333
+ "default": false
329
334
  }
330
335
  },
331
336
  "required": [
@@ -347,6 +352,11 @@
347
352
  "domain": {
348
353
  "type": "string",
349
354
  "description": "Optional (only for JWT) string domain parameter to verify the verifiable presentation against"
355
+ },
356
+ "fetchRemoteContexts": {
357
+ "type": "boolean",
358
+ "description": "Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.",
359
+ "default": false
350
360
  }
351
361
  },
352
362
  "required": [
@@ -0,0 +1,39 @@
1
+ import { ContextDoc } from '../types'
2
+ import { LdContextLoader } from '../ld-context-loader'
3
+ import { LdDefaultContexts } from '../ld-default-contexts'
4
+
5
+ describe('credential-ld context loader', () => {
6
+ const customContext: Record<string, ContextDoc> = {
7
+ 'https://example.com/custom/context': {
8
+ '@context': {
9
+ '@version': 1.1,
10
+ id: '@id',
11
+ type: '@type',
12
+ nothing: 'https://example.com/nothing',
13
+ },
14
+ },
15
+ }
16
+
17
+ it('loads custom context from record', async () => {
18
+ expect.assertions(2)
19
+ const loader = new LdContextLoader({ contextsPaths: [customContext] })
20
+ expect(loader.has('https://example.com/custom/context')).toBe(true)
21
+ await expect(loader.get('https://example.com/custom/context')).resolves.toEqual({
22
+ '@context': {
23
+ '@version': 1.1,
24
+ id: '@id',
25
+ type: '@type',
26
+ nothing: 'https://example.com/nothing',
27
+ },
28
+ })
29
+ })
30
+
31
+ it('loads context from default map', async () => {
32
+ expect.assertions(2)
33
+ const loader = new LdContextLoader({ contextsPaths: [LdDefaultContexts] })
34
+ expect(loader.has('https://www.w3.org/2018/credentials/v1')).toBe(true)
35
+
36
+ const credsContext = await loader.get('https://www.w3.org/2018/credentials/v1')
37
+ expect(credsContext['@context']).toBeDefined()
38
+ })
39
+ })
@@ -0,0 +1,84 @@
1
+ import {
2
+ createAgent,
3
+ CredentialPayload,
4
+ IDIDManager,
5
+ IIdentifier,
6
+ IKeyManager,
7
+ IResolver,
8
+ TAgent,
9
+ } from '../../../core/src'
10
+ import { CredentialIssuer, ICredentialIssuer } from '../../../credential-w3c/src'
11
+ import { DIDManager, MemoryDIDStore } from '../../../did-manager/src'
12
+ import { KeyManager, MemoryKeyStore, MemoryPrivateKeyStore } from '../../../key-manager/src'
13
+ import { KeyManagementSystem } from '../../../kms-local/src'
14
+ import { getDidKeyResolver, KeyDIDProvider } from '../../../did-provider-key/src'
15
+ import { DIDResolverPlugin } from '../../../did-resolver/src'
16
+ import { ContextDoc } from '../types'
17
+ import { CredentialIssuerLD } from '../action-handler'
18
+ import { LdDefaultContexts } from '../ld-default-contexts'
19
+ import { VeramoEd25519Signature2018 } from '../suites/Ed25519Signature2018'
20
+ import { Resolver } from 'did-resolver'
21
+
22
+ const customContext: Record<string, ContextDoc> = {
23
+ 'custom:example.context': {
24
+ '@context': {
25
+ nothing: 'custom:example.context#blank',
26
+ },
27
+ },
28
+ }
29
+
30
+ describe('credential-LD full flow', () => {
31
+ let didKeyIdentifier: IIdentifier
32
+ let agent: TAgent<IResolver & IKeyManager & IDIDManager & ICredentialIssuer>
33
+
34
+ beforeAll(async () => {
35
+ agent = createAgent({
36
+ plugins: [
37
+ new KeyManager({
38
+ store: new MemoryKeyStore(),
39
+ kms: {
40
+ local: new KeyManagementSystem(new MemoryPrivateKeyStore()),
41
+ },
42
+ }),
43
+ new DIDManager({
44
+ providers: {
45
+ 'did:key': new KeyDIDProvider({ defaultKms: 'local' }),
46
+ },
47
+ store: new MemoryDIDStore(),
48
+ defaultProvider: 'did:key',
49
+ }),
50
+ new DIDResolverPlugin({
51
+ resolver: new Resolver({ ...getDidKeyResolver() }),
52
+ }),
53
+ new CredentialIssuer(),
54
+ new CredentialIssuerLD({
55
+ contextMaps: [LdDefaultContexts, customContext],
56
+ suites: [new VeramoEd25519Signature2018()],
57
+ }),
58
+ ],
59
+ })
60
+ didKeyIdentifier = await agent.didManagerCreate()
61
+ })
62
+
63
+ it('works with Ed25519Signature2018', async () => {
64
+ const credential: CredentialPayload = {
65
+ issuer: didKeyIdentifier.did,
66
+ '@context': ['custom:example.context'],
67
+ credentialSubject: {
68
+ nothing: 'else matters',
69
+ },
70
+ }
71
+ const verifiableCredential = await agent.createVerifiableCredential({
72
+ credential,
73
+ proofFormat: 'lds',
74
+ })
75
+
76
+ expect(verifiableCredential).toBeDefined()
77
+
78
+ const verified = await agent.verifyCredential({
79
+ credential: verifiableCredential,
80
+ })
81
+
82
+ expect(verified).toBe(true)
83
+ })
84
+ })
@@ -183,7 +183,7 @@ export class CredentialIssuerLD implements IAgentPlugin {
183
183
  context: IRequiredContext,
184
184
  ): Promise<boolean> {
185
185
  const credential = args.credential
186
- return this.ldCredentialModule.verifyCredential(credential, context)
186
+ return this.ldCredentialModule.verifyCredential(credential, args.fetchRemoteContexts || false, context)
187
187
  }
188
188
 
189
189
  /** {@inheritdoc ICredentialIssuerLD.verifyPresentationLD} */
@@ -192,7 +192,7 @@ export class CredentialIssuerLD implements IAgentPlugin {
192
192
  context: IRequiredContext,
193
193
  ): Promise<boolean> {
194
194
  const presentation = args.presentation
195
- return this.ldCredentialModule.verifyPresentation(presentation, args.challenge, args.domain, context)
195
+ return this.ldCredentialModule.verifyPresentation(presentation, args.challenge, args.domain, args.fetchRemoteContexts || false, context)
196
196
  }
197
197
 
198
198
  private async findSigningKeyWithId(
@@ -1,19 +1,20 @@
1
1
  /**
2
- * The LdContextLoader is initialized with a List of Map<string, ContextDoc>
2
+ * The LdContextLoader is initialized with a List of Map<string, ContextDoc | Promise<ContextDoc>>
3
3
  * that it unifies into a single Map to provide to the documentLoader within
4
4
  * the w3c credential module.
5
5
  */
6
- import { OrPromise, RecordLike } from '@veramo/utils'
6
+ import { isIterable, OrPromise, RecordLike } from '@veramo/utils'
7
7
  import { ContextDoc } from './types'
8
8
 
9
9
  export class LdContextLoader {
10
- private contexts: Record<string, OrPromise<ContextDoc>>
10
+ private readonly contexts: Record<string, OrPromise<ContextDoc>>
11
11
 
12
12
  constructor(options: { contextsPaths: RecordLike<OrPromise<ContextDoc>>[] }) {
13
13
  this.contexts = {}
14
- // generate-plugin-schema is failing unless we use the cast to `any[]`
15
- Array.from(options.contextsPaths as any[], (mapItem) => {
16
- for (const [key, value] of mapItem) {
14
+ Array.from(options.contextsPaths, (mapItem) => {
15
+ const map = isIterable(mapItem) ? mapItem : Object.entries(mapItem)
16
+ // generate-plugin-schema is failing unless we use the cast to `any[]`
17
+ for (const [key, value] of map as any[]) {
17
18
  this.contexts[key] = value
18
19
  }
19
20
  })
@@ -7,6 +7,7 @@ import {
7
7
  VerifiableCredential,
8
8
  VerifiablePresentation,
9
9
  } from '@veramo/core'
10
+ import fetch from 'cross-fetch'
10
11
  import Debug from 'debug'
11
12
  import { extendContextLoader, purposes } from 'jsonld-signatures'
12
13
  import * as vc from 'vc-js'
@@ -34,7 +35,7 @@ export class LdCredentialModule {
34
35
  this.ldSuiteLoader = options.ldSuiteLoader
35
36
  }
36
37
 
37
- getDocumentLoader(context: IAgentContext<IResolver>) {
38
+ getDocumentLoader(context: IAgentContext<IResolver>, attemptToFetchContexts: boolean = false) {
38
39
  return extendContextLoader(async (url: string) => {
39
40
  // console.log(`resolving context for: ${url}`)
40
41
 
@@ -65,10 +66,27 @@ export class LdCredentialModule {
65
66
  documentUrl: url,
66
67
  document: contextDoc,
67
68
  }
69
+ } else {
70
+ if (attemptToFetchContexts) {
71
+ // attempt to fetch the remote context!!!! MEGA FAIL for JSON-LD.
72
+ debug("WARNING: attempting to fetch the doc directly for ", url)
73
+ try {
74
+ const response = await fetch(url)
75
+ if (response.status === 200) {
76
+ const document = await response.json()
77
+ return {
78
+ contextUrl: null,
79
+ documentUrl: url,
80
+ document
81
+ }
82
+ }
83
+ } catch (e) {
84
+ debug("WARNING: unable to fetch the doc or interpret it as JSON", e)
85
+ }
86
+ }
68
87
  }
69
88
 
70
- debug('WARNING: Possible unknown context/identifier for', url)
71
- console.log(`WARNING: Possible unknown context/identifier for: ${url}`)
89
+ debug(`WARNING: Possible unknown context/identifier for ${url} \n falling back to default documentLoader`)
72
90
 
73
91
  return vc.defaultDocumentLoader(url)
74
92
  })
@@ -122,12 +140,13 @@ export class LdCredentialModule {
122
140
 
123
141
  async verifyCredential(
124
142
  credential: VerifiableCredential,
143
+ fetchRemoteContexts: boolean = false,
125
144
  context: IAgentContext<IResolver>,
126
145
  ): Promise<boolean> {
127
146
  const result = await vc.verifyCredential({
128
147
  credential,
129
148
  suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
130
- documentLoader: this.getDocumentLoader(context),
149
+ documentLoader: this.getDocumentLoader(context, fetchRemoteContexts),
131
150
  purpose: new AssertionProofPurpose(),
132
151
  compactProof: false,
133
152
  })
@@ -146,12 +165,13 @@ export class LdCredentialModule {
146
165
  presentation: VerifiablePresentation,
147
166
  challenge: string | undefined,
148
167
  domain: string | undefined,
168
+ fetchRemoteContexts: boolean = false,
149
169
  context: IAgentContext<IResolver>,
150
170
  ): Promise<boolean> {
151
171
  const result = await vc.verify({
152
172
  presentation,
153
173
  suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
154
- documentLoader: this.getDocumentLoader(context),
174
+ documentLoader: this.getDocumentLoader(context, fetchRemoteContexts),
155
175
  challenge,
156
176
  domain,
157
177
  purpose: new AssertionProofPurpose(),
@@ -1,16 +1,25 @@
1
1
  import * as fs from 'fs'
2
2
  import * as path from 'path'
3
+ import { ContextDoc } from './types'
3
4
 
4
- function _read(_path: string) {
5
- return JSON.parse(fs.readFileSync(path.join(__dirname, '../contexts', _path), { encoding: 'utf8' }))
5
+ async function _read(_path: string): Promise<ContextDoc> {
6
+ const contextDefinition = await fs.promises.readFile(path.join(__dirname, '../contexts', _path), {
7
+ encoding: 'utf8',
8
+ })
9
+ return JSON.parse(contextDefinition)
6
10
  }
7
11
 
12
+ /**
13
+ * Provides a hardcoded map of common context definitions
14
+ */
8
15
  export const LdDefaultContexts = new Map([
16
+ ['https://www.w3.org/2018/credentials/v1', _read('w3_2018_credentials_v1.jsonld')],
17
+ ['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
18
+ ['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],
19
+
9
20
  ['https://veramo.io/contexts/socialmedia/v1', _read('socialmedia-v1.jsonld')],
10
21
  ['https://veramo.io/contexts/kyc/v1', _read('kyc-v1.jsonld')],
11
22
  ['https://veramo.io/contexts/profile/v1', _read('profile-v1.jsonld')],
12
- ['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
13
- ['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],
14
23
  ['https://ns.did.ai/transmute/v1', _read('transmute_v1.jsonld')],
15
24
  [
16
25
  'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
package/src/types.ts CHANGED
@@ -160,7 +160,14 @@ export interface IVerifyCredentialLDArgs {
160
160
  * of the `credential`
161
161
  *
162
162
  */
163
- credential: VerifiableCredential
163
+ credential: VerifiableCredential,
164
+
165
+ /**
166
+ * Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
167
+ *
168
+ * @default false
169
+ */
170
+ fetchRemoteContexts?: boolean
164
171
  }
165
172
 
166
173
  /**
@@ -189,6 +196,13 @@ export interface IVerifyPresentationLDArgs {
189
196
  * Optional (only for JWT) string domain parameter to verify the verifiable presentation against
190
197
  */
191
198
  domain?: string
199
+
200
+ /**
201
+ * Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
202
+ *
203
+ * @default false
204
+ */
205
+ fetchRemoteContexts?: boolean
192
206
  }
193
207
 
194
208
  /**