@veramo/credential-ld 3.1.6-next.166 → 3.1.6-next.169
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.
- package/build/action-handler.d.ts.map +1 -1
- package/build/action-handler.js +22 -10
- package/build/action-handler.js.map +1 -1
- package/build/ld-credential-module.d.ts +4 -4
- package/build/ld-credential-module.d.ts.map +1 -1
- package/build/ld-credential-module.js +22 -48
- package/build/ld-credential-module.js.map +1 -1
- package/build/types.d.ts +30 -2
- package/build/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/plugin.schema.json +22 -2
- package/src/__tests__/issue-verify-flow.test.ts +8 -8
- package/src/action-handler.ts +31 -8
- package/src/ld-credential-module.ts +21 -16
- package/src/types.ts +37 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-handler.d.ts","sourceRoot":"","sources":["../src/action-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAKZ,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAU,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAG9C,OAAO,EAML,SAAS,EAET,UAAU,EACX,MAAM,eAAe,CAAA;AAItB,OAAO,EACL,UAAU,EACV,iCAAiC,EACjC,mCAAmC,EACnC,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAIhB;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAA;IACrC,QAAQ,CAAC,MAAM,MAA2B;IAE1C,OAAO,CAAC,kBAAkB,CAAoB;gBAElC,OAAO,EAAE;QAAE,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,iBAAiB,EAAE,CAAA;KAAE;IActG,uEAAuE;IAC1D,8BAA8B,CACzC,I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AO,CAAC;YAgBL,oBAAoB;CA+BnC"}
|
package/build/action-handler.js
CHANGED
|
@@ -71,7 +71,11 @@ class CredentialIssuerLD {
|
|
|
71
71
|
}
|
|
72
72
|
try {
|
|
73
73
|
const { signingKey, verificationMethodId } = yield this.findSigningKeyWithId(context, identifier, args.keyRef);
|
|
74
|
-
|
|
74
|
+
let { now } = args;
|
|
75
|
+
if (typeof now === 'number') {
|
|
76
|
+
now = new Date(now * 1000);
|
|
77
|
+
}
|
|
78
|
+
return yield this.ldCredentialModule.signLDVerifiablePresentation(presentation, identifier.did, signingKey, verificationMethodId, args.challenge || '', args.domain || '', Object.assign(Object.assign({}, args), { now }), context);
|
|
75
79
|
}
|
|
76
80
|
catch (error) {
|
|
77
81
|
debug(error);
|
|
@@ -81,15 +85,11 @@ class CredentialIssuerLD {
|
|
|
81
85
|
}
|
|
82
86
|
/** {@inheritdoc ICredentialIssuerLD.createVerifiableCredentialLD} */
|
|
83
87
|
createVerifiableCredentialLD(args, context) {
|
|
84
|
-
var _a, _b
|
|
88
|
+
var _a, _b;
|
|
85
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
90
|
const credentialContext = (0, utils_1.processEntryToArray)((_a = args === null || args === void 0 ? void 0 : args.credential) === null || _a === void 0 ? void 0 : _a['@context'], utils_1.MANDATORY_CREDENTIAL_CONTEXT);
|
|
87
91
|
const credentialType = (0, utils_1.processEntryToArray)((_b = args === null || args === void 0 ? void 0 : args.credential) === null || _b === void 0 ? void 0 : _b.type, 'VerifiableCredential');
|
|
88
|
-
|
|
89
|
-
if (issuanceDate instanceof Date) {
|
|
90
|
-
issuanceDate = issuanceDate.toISOString();
|
|
91
|
-
}
|
|
92
|
-
const credential = Object.assign(Object.assign({}, args === null || args === void 0 ? void 0 : args.credential), { '@context': credentialContext, type: credentialType, issuanceDate });
|
|
92
|
+
const credential = Object.assign(Object.assign({}, args === null || args === void 0 ? void 0 : args.credential), { '@context': credentialContext, type: credentialType });
|
|
93
93
|
const issuer = (0, utils_1.extractIssuer)(credential);
|
|
94
94
|
if (!issuer || typeof issuer === 'undefined') {
|
|
95
95
|
throw new Error('invalid_argument: args.credential.issuer must not be empty');
|
|
@@ -103,7 +103,11 @@ class CredentialIssuerLD {
|
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
105
|
const { signingKey, verificationMethodId } = yield this.findSigningKeyWithId(context, identifier, args.keyRef);
|
|
106
|
-
|
|
106
|
+
let { now } = args;
|
|
107
|
+
if (typeof now === 'number') {
|
|
108
|
+
now = new Date(now * 1000);
|
|
109
|
+
}
|
|
110
|
+
return yield this.ldCredentialModule.issueLDVerifiableCredential(credential, identifier.did, signingKey, verificationMethodId, Object.assign(Object.assign({}, args.options), { now }), context);
|
|
107
111
|
}
|
|
108
112
|
catch (error) {
|
|
109
113
|
debug(error);
|
|
@@ -115,14 +119,22 @@ class CredentialIssuerLD {
|
|
|
115
119
|
verifyCredentialLD(args, context) {
|
|
116
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
121
|
const credential = args.credential;
|
|
118
|
-
|
|
122
|
+
let { now } = args;
|
|
123
|
+
if (typeof now === 'number') {
|
|
124
|
+
now = new Date(now * 1000);
|
|
125
|
+
}
|
|
126
|
+
return this.ldCredentialModule.verifyCredential(credential, args.fetchRemoteContexts || false, Object.assign(Object.assign({}, args.options), { now }), context);
|
|
119
127
|
});
|
|
120
128
|
}
|
|
121
129
|
/** {@inheritdoc ICredentialIssuerLD.verifyPresentationLD} */
|
|
122
130
|
verifyPresentationLD(args, context) {
|
|
123
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
132
|
const presentation = args.presentation;
|
|
125
|
-
|
|
133
|
+
let { now } = args;
|
|
134
|
+
if (typeof now === 'number') {
|
|
135
|
+
now = new Date(now * 1000);
|
|
136
|
+
}
|
|
137
|
+
return this.ldCredentialModule.verifyPresentation(presentation, args.challenge, args.domain, args.fetchRemoteContexts || false, Object.assign(Object.assign({}, args.options), { now }), context);
|
|
126
138
|
});
|
|
127
139
|
}
|
|
128
140
|
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,CAAA;QAEF,IAAI,CAAC,OAAO,GAAG;YACb,8BAA8B,EAAE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9E,4BAA4B,EAAE,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1E,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;YACtD,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;SAC3D,CAAA;IACH,CAAC;IAED,uEAAuE;IAC1D,8BAA8B,CACzC,IAAyC,EACzC,OAAyB;;;YAEzB,MAAM,mBAAmB,GAAG,IAAA,2BAAmB,EAC7C,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAG,UAAU,CAAC,EAChC,oCAA4B,CAC7B,CAAA;YACD,MAAM,gBAA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,IAAI,MAAM,EAAE;oBACV,KAAK,CACH,uHAAuH,CACxH,CAAA;iBACF;gBACD,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAA;aAC/F;YAED,IAAI,CAAC,UAAU;gBAAE,MAAM,KAAK,CAAC,oDAAoD,UAAU,CAAC,GAAG,EAAE,CAAC,CAAA;YAClG,oBAAoB,GAAG,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAA;YAC5D,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAA;QAC7C,CAAC;KAAA;CACF;AArND,gDAqNC"}
|
|
@@ -17,9 +17,9 @@ export declare class LdCredentialModule {
|
|
|
17
17
|
ldSuiteLoader: LdSuiteLoader;
|
|
18
18
|
});
|
|
19
19
|
getDocumentLoader(context: IAgentContext<IResolver>, attemptToFetchContexts?: boolean): any;
|
|
20
|
-
issueLDVerifiableCredential(credential: CredentialPayload, issuerDid: string, key: IKey, verificationMethodId: string, context: IAgentContext<RequiredAgentMethods>): Promise<VerifiableCredential>;
|
|
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, 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>;
|
|
20
|
+
issueLDVerifiableCredential(credential: CredentialPayload, issuerDid: string, key: IKey, verificationMethodId: string, options: any, context: IAgentContext<RequiredAgentMethods>): Promise<VerifiableCredential>;
|
|
21
|
+
signLDVerifiablePresentation(presentation: PresentationPayload, holderDid: string, key: IKey, verificationMethodId: string, challenge: string | undefined, domain: string | undefined, options: any, context: IAgentContext<RequiredAgentMethods>): Promise<VerifiablePresentation>;
|
|
22
|
+
verifyCredential(credential: VerifiableCredential, fetchRemoteContexts: boolean | undefined, options: any, context: IAgentContext<IResolver>): Promise<boolean>;
|
|
23
|
+
verifyPresentation(presentation: VerifiablePresentation, challenge: string | undefined, domain: string | undefined, fetchRemoteContexts: boolean | undefined, options: any, 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;AAKrB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIlD,qBAAa,kBAAkB;IAC7B;;;;;;OAMG;IAEH,OAAO,CAAC,eAAe,CAAiB;IACxC,aAAa,EAAE,aAAa,CAAA;
|
|
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;AAKrB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE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70 +98,44 @@ class LdCredentialModule {
|
|
|
98
98
|
return vc.defaultDocumentLoader(url);
|
|
99
99
|
}));
|
|
100
100
|
}
|
|
101
|
-
issueLDVerifiableCredential(credential, issuerDid, key, verificationMethodId, context) {
|
|
101
|
+
issueLDVerifiableCredential(credential, issuerDid, key, verificationMethodId, options, context) {
|
|
102
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
103
|
const suite = this.ldSuiteLoader.getSignatureSuiteForKeyType(key.type);
|
|
104
|
-
const documentLoader = this.getDocumentLoader(context);
|
|
104
|
+
const documentLoader = this.getDocumentLoader(context, options.fetchRemoteContexts);
|
|
105
105
|
// some suites can modify the incoming credential (e.g. add required contexts)
|
|
106
106
|
suite.preSigningCredModification(credential);
|
|
107
|
-
return yield vc.issue({
|
|
108
|
-
credential,
|
|
109
|
-
suite: suite.getSuiteForSigning(key, issuerDid, verificationMethodId, context),
|
|
110
|
-
documentLoader,
|
|
111
|
-
compactProof: false,
|
|
112
|
-
});
|
|
107
|
+
return yield vc.issue(Object.assign(Object.assign({}, options), { credential, suite: suite.getSuiteForSigning(key, issuerDid, verificationMethodId, context), documentLoader, compactProof: false }));
|
|
113
108
|
});
|
|
114
109
|
}
|
|
115
|
-
signLDVerifiablePresentation(presentation, holderDid, key, verificationMethodId, challenge, domain, context) {
|
|
110
|
+
signLDVerifiablePresentation(presentation, holderDid, key, verificationMethodId, challenge, domain, options, context) {
|
|
116
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
112
|
const suite = this.ldSuiteLoader.getSignatureSuiteForKeyType(key.type);
|
|
118
|
-
const documentLoader = this.getDocumentLoader(context);
|
|
113
|
+
const documentLoader = this.getDocumentLoader(context, options.fetchRemoteContexts);
|
|
119
114
|
suite.preSigningPresModification(presentation);
|
|
120
|
-
return yield vc.signPresentation({
|
|
121
|
-
presentation,
|
|
122
|
-
suite: suite.getSuiteForSigning(key, holderDid, verificationMethodId, context),
|
|
123
|
-
challenge,
|
|
115
|
+
return yield vc.signPresentation(Object.assign(Object.assign({}, options), { presentation, suite: suite.getSuiteForSigning(key, holderDid, verificationMethodId, context), challenge,
|
|
124
116
|
domain,
|
|
125
|
-
documentLoader,
|
|
126
|
-
compactProof: false,
|
|
127
|
-
});
|
|
117
|
+
documentLoader, compactProof: false }));
|
|
128
118
|
});
|
|
129
119
|
}
|
|
130
|
-
verifyCredential(credential, fetchRemoteContexts = false, context) {
|
|
120
|
+
verifyCredential(credential, fetchRemoteContexts = false, options, context) {
|
|
131
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const result = yield vc.verifyCredential({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
if (result.verified)
|
|
140
|
-
return true;
|
|
141
|
-
// NOT verified.
|
|
142
|
-
// result can include raw Error
|
|
143
|
-
debug(`Error verifying LD Verifiable Credential: ${JSON.stringify(result, null, 2)}`);
|
|
144
|
-
// console.log(JSON.stringify(result, null, 2));
|
|
145
|
-
throw Error('Error verifying LD Verifiable Credential');
|
|
122
|
+
const result = yield vc.verifyCredential(Object.assign(Object.assign({}, options), { credential, suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()), documentLoader: this.getDocumentLoader(context, fetchRemoteContexts), compactProof: false, checkStatus: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve({ verified: true }); }) }));
|
|
123
|
+
if (!result.verified) {
|
|
124
|
+
// result can include raw Error
|
|
125
|
+
debug(`Error verifying LD Credential: ${JSON.stringify(result, null, 2)}`);
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
146
128
|
});
|
|
147
129
|
}
|
|
148
|
-
verifyPresentation(presentation, challenge, domain, fetchRemoteContexts = false, context) {
|
|
130
|
+
verifyPresentation(presentation, challenge, domain, fetchRemoteContexts = false, options, context) {
|
|
149
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
const result = yield vc.verify({
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
if (result.verified)
|
|
159
|
-
return true;
|
|
160
|
-
// NOT verified.
|
|
161
|
-
// result can include raw Error
|
|
162
|
-
console.log(`Error verifying LD Verifiable Presentation`);
|
|
163
|
-
console.log(JSON.stringify(result, null, 2));
|
|
164
|
-
throw Error('Error verifying LD Verifiable Presentation');
|
|
132
|
+
const result = yield vc.verify(Object.assign(Object.assign({}, options), { presentation, suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()), documentLoader: this.getDocumentLoader(context, fetchRemoteContexts), challenge,
|
|
133
|
+
domain, compactProof: false }));
|
|
134
|
+
if (!result.verified) {
|
|
135
|
+
// result can include raw Error
|
|
136
|
+
debug(`Error verifying LD Presentation: ${JSON.stringify(result, null, 2)}`);
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
165
139
|
});
|
|
166
140
|
}
|
|
167
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ld-credential-module.js","sourceRoot":"","sources":["../src/ld-credential-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8DAA+B;AAC/B,kDAAyB;AACzB,6EAA2E;AAC3E,2DAA4C;AAK5C,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,iCAAiC,CAAC,CAAA;AAEtD,MAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"ld-credential-module.js","sourceRoot":"","sources":["../src/ld-credential-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8DAA+B;AAC/B,kDAAyB;AACzB,6EAA2E;AAC3E,2DAA4C;AAK5C,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,iCAAiC,CAAC,CAAA;AAEtD,MAAa,kBAAkB;IAY7B,YAAY,OAA2E;QACrF,IAAI,CAAC,eAAe,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7B,MAA0B,EAC1B,sBAA+B,KAAK,EACpC,OAAY,EACZ,OAAiC;;YAEjC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,iCACzB,OAAO,KACV,YAAY,EACZ,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,EACzF,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,CAAC,EACpE,SAAS;gBACT,MAAM,EACN,YAAY,EAAE,KAAK,IACnB,CAAA;YAEF,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACpB,+BAA+B;gBAC/B,KAAK,CAAC,oCAAoC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;aAC7E;YACD,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AA5KD,gDA4KC"}
|
package/build/types.d.ts
CHANGED
|
@@ -95,6 +95,16 @@ export interface ICreateVerifiablePresentationLDArgs {
|
|
|
95
95
|
* Optional. The key handle ({@link @veramo/core#IKey.kid | IKey.kid}) from the internal database.
|
|
96
96
|
*/
|
|
97
97
|
keyRef?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
100
|
+
*
|
|
101
|
+
* Defaults to `false`
|
|
102
|
+
*/
|
|
103
|
+
fetchRemoteContexts?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
106
|
+
*/
|
|
107
|
+
[x: string]: any;
|
|
98
108
|
}
|
|
99
109
|
/**
|
|
100
110
|
* Encapsulates the parameters required to create a
|
|
@@ -117,6 +127,16 @@ export interface ICreateVerifiableCredentialLDArgs {
|
|
|
117
127
|
* Optional. The key handle ({@link @veramo/core#IKey.kid | IKey.kid}) from the internal database.
|
|
118
128
|
*/
|
|
119
129
|
keyRef?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
132
|
+
*
|
|
133
|
+
* Defaults to `false`
|
|
134
|
+
*/
|
|
135
|
+
fetchRemoteContexts?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
138
|
+
*/
|
|
139
|
+
[x: string]: any;
|
|
120
140
|
}
|
|
121
141
|
/**
|
|
122
142
|
* Encapsulates the parameters required to verify a
|
|
@@ -135,11 +155,15 @@ export interface IVerifyCredentialLDArgs {
|
|
|
135
155
|
*/
|
|
136
156
|
credential: VerifiableCredential;
|
|
137
157
|
/**
|
|
138
|
-
* Set this to true if you want the `@context` URLs to be fetched in case they are not
|
|
158
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
139
159
|
*
|
|
140
160
|
* Defaults to `false`
|
|
141
161
|
*/
|
|
142
162
|
fetchRemoteContexts?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
165
|
+
*/
|
|
166
|
+
[x: string]: any;
|
|
143
167
|
}
|
|
144
168
|
/**
|
|
145
169
|
* Encapsulates the parameters required to verify a
|
|
@@ -166,11 +190,15 @@ export interface IVerifyPresentationLDArgs {
|
|
|
166
190
|
*/
|
|
167
191
|
domain?: string;
|
|
168
192
|
/**
|
|
169
|
-
* Set this to true if you want the `@context` URLs to be fetched in case they are not
|
|
193
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
170
194
|
*
|
|
171
195
|
* Defaults to `false`
|
|
172
196
|
*/
|
|
173
197
|
fetchRemoteContexts?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
200
|
+
*/
|
|
201
|
+
[x: string]: any;
|
|
174
202
|
}
|
|
175
203
|
/**
|
|
176
204
|
* Represents the requirements that this plugin has.
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,cAAc,CAAA;AAErB;;;;;;;;GAQG;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,uBAAuB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE9F;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACnG;AAED;;;;;GAKG;AACH,MAAM,WAAW,mCAAmC;IAClD;;;;;;;;OAQG;IACH,YAAY,EAAE,mBAAmB,CAAA;IAEjC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;OAQG;IACH,UAAU,EAAE,iBAAiB,CAAA;IAE7B;;OAEG;IACH,MAAM,CAAC,EAAE,M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|
2
2
|
"name": "@veramo/credential-ld",
|
|
3
3
|
"description": "Veramo plugin for working with W3C JSON-LD Verifiable Credentials & Presentations.",
|
|
4
|
-
"version": "3.1.6-next.
|
|
4
|
+
"version": "3.1.6-next.169+b987fc09",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"@transmute/credentials-context": "^0.7.0-unstable.60",
|
|
21
21
|
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.60",
|
|
22
22
|
"@veramo-community/lds-ecdsa-secp256k1-recovery2020": "uport-project/EcdsaSecp256k1RecoverySignature2020",
|
|
23
|
-
"@veramo/core": "^3.1.6-next.
|
|
24
|
-
"@veramo/did-resolver": "^3.1.6-next.
|
|
25
|
-
"@veramo/utils": "^3.1.6-next.
|
|
23
|
+
"@veramo/core": "^3.1.6-next.169+b987fc09",
|
|
24
|
+
"@veramo/did-resolver": "^3.1.6-next.169+b987fc09",
|
|
25
|
+
"@veramo/utils": "^3.1.6-next.169+b987fc09",
|
|
26
26
|
"debug": "^4.3.3",
|
|
27
27
|
"did-resolver": "^4.0.0",
|
|
28
28
|
"uint8arrays": "^3.0.0"
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"author": "Mircea Nistor <mircea.nistor@mesh.xyz>",
|
|
52
52
|
"license": "Apache-2.0",
|
|
53
53
|
"keywords": [],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b987fc0903a31d3bbffb43fef872be4d6c62c2ad"
|
|
55
55
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -12,11 +12,18 @@
|
|
|
12
12
|
"keyRef": {
|
|
13
13
|
"type": "string",
|
|
14
14
|
"description": "Optional. The key handle ( {@link @veramo/core#IKey.kid | IKey.kid } ) from the internal database."
|
|
15
|
+
},
|
|
16
|
+
"fetchRemoteContexts": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"required": [
|
|
18
22
|
"credential"
|
|
19
23
|
],
|
|
24
|
+
"additionalProperties": {
|
|
25
|
+
"description": "Any other options that can be forwarded to the lower level libraries"
|
|
26
|
+
},
|
|
20
27
|
"description": "Encapsulates the parameters required to create a\n {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential }"
|
|
21
28
|
},
|
|
22
29
|
"CredentialPayload": {
|
|
@@ -193,11 +200,18 @@
|
|
|
193
200
|
"keyRef": {
|
|
194
201
|
"type": "string",
|
|
195
202
|
"description": "Optional. The key handle ( {@link @veramo/core#IKey.kid | IKey.kid } ) from the internal database."
|
|
203
|
+
},
|
|
204
|
+
"fetchRemoteContexts": {
|
|
205
|
+
"type": "boolean",
|
|
206
|
+
"description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
|
|
196
207
|
}
|
|
197
208
|
},
|
|
198
209
|
"required": [
|
|
199
210
|
"presentation"
|
|
200
211
|
],
|
|
212
|
+
"additionalProperties": {
|
|
213
|
+
"description": "Any other options that can be forwarded to the lower level libraries"
|
|
214
|
+
},
|
|
201
215
|
"description": "Encapsulates the parameters required to create a\n {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation }"
|
|
202
216
|
},
|
|
203
217
|
"PresentationPayload": {
|
|
@@ -333,12 +347,15 @@
|
|
|
333
347
|
},
|
|
334
348
|
"fetchRemoteContexts": {
|
|
335
349
|
"type": "boolean",
|
|
336
|
-
"description": "Set this to true if you want the `@context` URLs to be fetched in case they are not
|
|
350
|
+
"description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
|
|
337
351
|
}
|
|
338
352
|
},
|
|
339
353
|
"required": [
|
|
340
354
|
"credential"
|
|
341
355
|
],
|
|
356
|
+
"additionalProperties": {
|
|
357
|
+
"description": "Any other options that can be forwarded to the lower level libraries"
|
|
358
|
+
},
|
|
342
359
|
"description": "Encapsulates the parameters required to verify a\n {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential }"
|
|
343
360
|
},
|
|
344
361
|
"IVerifyPresentationLDArgs": {
|
|
@@ -358,12 +375,15 @@
|
|
|
358
375
|
},
|
|
359
376
|
"fetchRemoteContexts": {
|
|
360
377
|
"type": "boolean",
|
|
361
|
-
"description": "Set this to true if you want the `@context` URLs to be fetched in case they are not
|
|
378
|
+
"description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
|
|
362
379
|
}
|
|
363
380
|
},
|
|
364
381
|
"required": [
|
|
365
382
|
"presentation"
|
|
366
383
|
],
|
|
384
|
+
"additionalProperties": {
|
|
385
|
+
"description": "Any other options that can be forwarded to the lower level libraries"
|
|
386
|
+
},
|
|
367
387
|
"description": "Encapsulates the parameters required to verify a\n {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation }"
|
|
368
388
|
}
|
|
369
389
|
},
|
|
@@ -91,11 +91,11 @@ describe('credential-LD full flow', () => {
|
|
|
91
91
|
|
|
92
92
|
expect(verifiableCredential).toBeDefined()
|
|
93
93
|
|
|
94
|
-
const
|
|
94
|
+
const result = await agent.verifyCredential({
|
|
95
95
|
credential: verifiableCredential,
|
|
96
96
|
})
|
|
97
97
|
|
|
98
|
-
expect(verified).toBe(true)
|
|
98
|
+
expect(result.verified).toBe(true)
|
|
99
99
|
})
|
|
100
100
|
|
|
101
101
|
it('works with EcdsaSecp256k1RecoveryMethod2020 credentials', async () => {
|
|
@@ -113,11 +113,11 @@ describe('credential-LD full flow', () => {
|
|
|
113
113
|
|
|
114
114
|
expect(verifiableCredential).toBeDefined()
|
|
115
115
|
|
|
116
|
-
const
|
|
116
|
+
const result = await agent.verifyCredential({
|
|
117
117
|
credential: verifiableCredential,
|
|
118
118
|
})
|
|
119
119
|
|
|
120
|
-
expect(verified).toBe(true)
|
|
120
|
+
expect(result.verified).toBe(true)
|
|
121
121
|
})
|
|
122
122
|
|
|
123
123
|
it('works with Ed25519Signature2018 credential and presentation', async () => {
|
|
@@ -144,12 +144,12 @@ describe('credential-LD full flow', () => {
|
|
|
144
144
|
|
|
145
145
|
expect(verifiablePresentation).toBeDefined()
|
|
146
146
|
|
|
147
|
-
const
|
|
147
|
+
const result = await agent.verifyPresentation({
|
|
148
148
|
presentation: verifiablePresentation,
|
|
149
149
|
challenge: 'VERAMO',
|
|
150
150
|
})
|
|
151
151
|
|
|
152
|
-
expect(verified).toBe(true)
|
|
152
|
+
expect(result.verified).toBe(true)
|
|
153
153
|
})
|
|
154
154
|
|
|
155
155
|
it('works with EcdsaSecp256k1RecoveryMethod2020 credential and presentation', async () => {
|
|
@@ -179,11 +179,11 @@ describe('credential-LD full flow', () => {
|
|
|
179
179
|
|
|
180
180
|
expect(verifiablePresentation).toBeDefined()
|
|
181
181
|
|
|
182
|
-
const
|
|
182
|
+
const result = await agent.verifyPresentation({
|
|
183
183
|
presentation: verifiablePresentation,
|
|
184
184
|
challenge: 'VERAMO',
|
|
185
185
|
})
|
|
186
186
|
|
|
187
|
-
expect(verified).toBe(true)
|
|
187
|
+
expect(result.verified).toBe(true)
|
|
188
188
|
})
|
|
189
189
|
})
|
package/src/action-handler.ts
CHANGED
|
@@ -110,13 +110,19 @@ export class CredentialIssuerLD implements IAgentPlugin {
|
|
|
110
110
|
args.keyRef,
|
|
111
111
|
)
|
|
112
112
|
|
|
113
|
+
let { now } = args
|
|
114
|
+
if (typeof now === 'number') {
|
|
115
|
+
now = new Date(now * 1000)
|
|
116
|
+
}
|
|
117
|
+
|
|
113
118
|
return await this.ldCredentialModule.signLDVerifiablePresentation(
|
|
114
119
|
presentation,
|
|
115
120
|
identifier.did,
|
|
116
121
|
signingKey,
|
|
117
122
|
verificationMethodId,
|
|
118
|
-
args.challenge,
|
|
119
|
-
args.domain,
|
|
123
|
+
args.challenge || '',
|
|
124
|
+
args.domain || '',
|
|
125
|
+
{ ...args, now },
|
|
120
126
|
context,
|
|
121
127
|
)
|
|
122
128
|
} catch (error) {
|
|
@@ -135,15 +141,10 @@ export class CredentialIssuerLD implements IAgentPlugin {
|
|
|
135
141
|
MANDATORY_CREDENTIAL_CONTEXT,
|
|
136
142
|
)
|
|
137
143
|
const credentialType = processEntryToArray(args?.credential?.type, 'VerifiableCredential')
|
|
138
|
-
let issuanceDate = args?.credential?.issuanceDate || new Date().toISOString()
|
|
139
|
-
if (issuanceDate instanceof Date) {
|
|
140
|
-
issuanceDate = issuanceDate.toISOString()
|
|
141
|
-
}
|
|
142
144
|
const credential: CredentialPayload = {
|
|
143
145
|
...args?.credential,
|
|
144
146
|
'@context': credentialContext,
|
|
145
147
|
type: credentialType,
|
|
146
|
-
issuanceDate,
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
const issuer = extractIssuer(credential)
|
|
@@ -164,11 +165,17 @@ export class CredentialIssuerLD implements IAgentPlugin {
|
|
|
164
165
|
args.keyRef,
|
|
165
166
|
)
|
|
166
167
|
|
|
168
|
+
let { now } = args
|
|
169
|
+
if (typeof now === 'number') {
|
|
170
|
+
now = new Date(now * 1000)
|
|
171
|
+
}
|
|
172
|
+
|
|
167
173
|
return await this.ldCredentialModule.issueLDVerifiableCredential(
|
|
168
174
|
credential,
|
|
169
175
|
identifier.did,
|
|
170
176
|
signingKey,
|
|
171
177
|
verificationMethodId,
|
|
178
|
+
{ ...args.options, now },
|
|
172
179
|
context,
|
|
173
180
|
)
|
|
174
181
|
} catch (error) {
|
|
@@ -183,7 +190,18 @@ export class CredentialIssuerLD implements IAgentPlugin {
|
|
|
183
190
|
context: IRequiredContext,
|
|
184
191
|
): Promise<boolean> {
|
|
185
192
|
const credential = args.credential
|
|
186
|
-
|
|
193
|
+
|
|
194
|
+
let { now } = args
|
|
195
|
+
if (typeof now === 'number') {
|
|
196
|
+
now = new Date(now * 1000)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return this.ldCredentialModule.verifyCredential(
|
|
200
|
+
credential,
|
|
201
|
+
args.fetchRemoteContexts || false,
|
|
202
|
+
{ ...args.options, now },
|
|
203
|
+
context,
|
|
204
|
+
)
|
|
187
205
|
}
|
|
188
206
|
|
|
189
207
|
/** {@inheritdoc ICredentialIssuerLD.verifyPresentationLD} */
|
|
@@ -192,11 +210,16 @@ export class CredentialIssuerLD implements IAgentPlugin {
|
|
|
192
210
|
context: IRequiredContext,
|
|
193
211
|
): Promise<boolean> {
|
|
194
212
|
const presentation = args.presentation
|
|
213
|
+
let { now } = args
|
|
214
|
+
if (typeof now === 'number') {
|
|
215
|
+
now = new Date(now * 1000)
|
|
216
|
+
}
|
|
195
217
|
return this.ldCredentialModule.verifyPresentation(
|
|
196
218
|
presentation,
|
|
197
219
|
args.challenge,
|
|
198
220
|
args.domain,
|
|
199
221
|
args.fetchRemoteContexts || false,
|
|
222
|
+
{ ...args.options, now },
|
|
200
223
|
context,
|
|
201
224
|
)
|
|
202
225
|
}
|
|
@@ -28,6 +28,7 @@ export class LdCredentialModule {
|
|
|
28
28
|
|
|
29
29
|
private ldContextLoader: LdContextLoader
|
|
30
30
|
ldSuiteLoader: LdSuiteLoader
|
|
31
|
+
|
|
31
32
|
constructor(options: { ldContextLoader: LdContextLoader; ldSuiteLoader: LdSuiteLoader }) {
|
|
32
33
|
this.ldContextLoader = options.ldContextLoader
|
|
33
34
|
this.ldSuiteLoader = options.ldSuiteLoader
|
|
@@ -97,15 +98,17 @@ export class LdCredentialModule {
|
|
|
97
98
|
issuerDid: string,
|
|
98
99
|
key: IKey,
|
|
99
100
|
verificationMethodId: string,
|
|
101
|
+
options: any,
|
|
100
102
|
context: IAgentContext<RequiredAgentMethods>,
|
|
101
103
|
): Promise<VerifiableCredential> {
|
|
102
104
|
const suite = this.ldSuiteLoader.getSignatureSuiteForKeyType(key.type)
|
|
103
|
-
const documentLoader = this.getDocumentLoader(context)
|
|
105
|
+
const documentLoader = this.getDocumentLoader(context, options.fetchRemoteContexts)
|
|
104
106
|
|
|
105
107
|
// some suites can modify the incoming credential (e.g. add required contexts)
|
|
106
108
|
suite.preSigningCredModification(credential)
|
|
107
109
|
|
|
108
110
|
return await vc.issue({
|
|
111
|
+
...options,
|
|
109
112
|
credential,
|
|
110
113
|
suite: suite.getSuiteForSigning(key, issuerDid, verificationMethodId, context),
|
|
111
114
|
documentLoader,
|
|
@@ -120,14 +123,16 @@ export class LdCredentialModule {
|
|
|
120
123
|
verificationMethodId: string,
|
|
121
124
|
challenge: string | undefined,
|
|
122
125
|
domain: string | undefined,
|
|
126
|
+
options: any,
|
|
123
127
|
context: IAgentContext<RequiredAgentMethods>,
|
|
124
128
|
): Promise<VerifiablePresentation> {
|
|
125
129
|
const suite = this.ldSuiteLoader.getSignatureSuiteForKeyType(key.type)
|
|
126
|
-
const documentLoader = this.getDocumentLoader(context)
|
|
130
|
+
const documentLoader = this.getDocumentLoader(context, options.fetchRemoteContexts)
|
|
127
131
|
|
|
128
132
|
suite.preSigningPresModification(presentation)
|
|
129
133
|
|
|
130
134
|
return await vc.signPresentation({
|
|
135
|
+
...options,
|
|
131
136
|
presentation,
|
|
132
137
|
suite: suite.getSuiteForSigning(key, holderDid, verificationMethodId, context),
|
|
133
138
|
challenge,
|
|
@@ -140,9 +145,11 @@ export class LdCredentialModule {
|
|
|
140
145
|
async verifyCredential(
|
|
141
146
|
credential: VerifiableCredential,
|
|
142
147
|
fetchRemoteContexts: boolean = false,
|
|
148
|
+
options: any,
|
|
143
149
|
context: IAgentContext<IResolver>,
|
|
144
150
|
): Promise<boolean> {
|
|
145
151
|
const result = await vc.verifyCredential({
|
|
152
|
+
...options,
|
|
146
153
|
credential,
|
|
147
154
|
suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
|
|
148
155
|
documentLoader: this.getDocumentLoader(context, fetchRemoteContexts),
|
|
@@ -150,13 +157,12 @@ export class LdCredentialModule {
|
|
|
150
157
|
checkStatus: async () => Promise.resolve({ verified: true }), // Fake method
|
|
151
158
|
})
|
|
152
159
|
|
|
153
|
-
if (result.verified)
|
|
160
|
+
if (!result.verified) {
|
|
161
|
+
// result can include raw Error
|
|
162
|
+
debug(`Error verifying LD Credential: ${JSON.stringify(result, null, 2)}`)
|
|
163
|
+
}
|
|
154
164
|
|
|
155
|
-
|
|
156
|
-
// result can include raw Error
|
|
157
|
-
debug(`Error verifying LD Verifiable Credential: ${JSON.stringify(result, null, 2)}`)
|
|
158
|
-
// console.log(JSON.stringify(result, null, 2));
|
|
159
|
-
throw Error('Error verifying LD Verifiable Credential')
|
|
165
|
+
return result
|
|
160
166
|
}
|
|
161
167
|
|
|
162
168
|
async verifyPresentation(
|
|
@@ -164,9 +170,11 @@ export class LdCredentialModule {
|
|
|
164
170
|
challenge: string | undefined,
|
|
165
171
|
domain: string | undefined,
|
|
166
172
|
fetchRemoteContexts: boolean = false,
|
|
173
|
+
options: any,
|
|
167
174
|
context: IAgentContext<IResolver>,
|
|
168
175
|
): Promise<boolean> {
|
|
169
176
|
const result = await vc.verify({
|
|
177
|
+
...options,
|
|
170
178
|
presentation,
|
|
171
179
|
suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
|
|
172
180
|
documentLoader: this.getDocumentLoader(context, fetchRemoteContexts),
|
|
@@ -175,13 +183,10 @@ export class LdCredentialModule {
|
|
|
175
183
|
compactProof: false,
|
|
176
184
|
})
|
|
177
185
|
|
|
178
|
-
if (result.verified)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
console.log(`Error verifying LD Verifiable Presentation`)
|
|
184
|
-
console.log(JSON.stringify(result, null, 2))
|
|
185
|
-
throw Error('Error verifying LD Verifiable Presentation')
|
|
186
|
+
if (!result.verified) {
|
|
187
|
+
// result can include raw Error
|
|
188
|
+
debug(`Error verifying LD Presentation: ${JSON.stringify(result, null, 2)}`)
|
|
189
|
+
}
|
|
190
|
+
return result
|
|
186
191
|
}
|
|
187
192
|
}
|
package/src/types.ts
CHANGED
|
@@ -119,6 +119,18 @@ export interface ICreateVerifiablePresentationLDArgs {
|
|
|
119
119
|
* Optional. The key handle ({@link @veramo/core#IKey.kid | IKey.kid}) from the internal database.
|
|
120
120
|
*/
|
|
121
121
|
keyRef?: string
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
125
|
+
*
|
|
126
|
+
* Defaults to `false`
|
|
127
|
+
*/
|
|
128
|
+
fetchRemoteContexts?: boolean
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
132
|
+
*/
|
|
133
|
+
[x:string]: any
|
|
122
134
|
}
|
|
123
135
|
|
|
124
136
|
/**
|
|
@@ -142,7 +154,19 @@ export interface ICreateVerifiableCredentialLDArgs {
|
|
|
142
154
|
/**
|
|
143
155
|
* Optional. The key handle ({@link @veramo/core#IKey.kid | IKey.kid}) from the internal database.
|
|
144
156
|
*/
|
|
145
|
-
keyRef?: string
|
|
157
|
+
keyRef?: string,
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
161
|
+
*
|
|
162
|
+
* Defaults to `false`
|
|
163
|
+
*/
|
|
164
|
+
fetchRemoteContexts?: boolean
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
168
|
+
*/
|
|
169
|
+
[x:string]: any
|
|
146
170
|
}
|
|
147
171
|
|
|
148
172
|
/**
|
|
@@ -163,11 +187,16 @@ export interface IVerifyCredentialLDArgs {
|
|
|
163
187
|
credential: VerifiableCredential
|
|
164
188
|
|
|
165
189
|
/**
|
|
166
|
-
* Set this to true if you want the `@context` URLs to be fetched in case they are not
|
|
190
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
167
191
|
*
|
|
168
192
|
* Defaults to `false`
|
|
169
193
|
*/
|
|
170
194
|
fetchRemoteContexts?: boolean
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
198
|
+
*/
|
|
199
|
+
[x:string]: any
|
|
171
200
|
}
|
|
172
201
|
|
|
173
202
|
/**
|
|
@@ -198,11 +227,16 @@ export interface IVerifyPresentationLDArgs {
|
|
|
198
227
|
domain?: string
|
|
199
228
|
|
|
200
229
|
/**
|
|
201
|
-
* Set this to true if you want the `@context` URLs to be fetched in case they are not
|
|
230
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
202
231
|
*
|
|
203
232
|
* Defaults to `false`
|
|
204
233
|
*/
|
|
205
234
|
fetchRemoteContexts?: boolean
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
238
|
+
*/
|
|
239
|
+
[x:string]: any
|
|
206
240
|
}
|
|
207
241
|
|
|
208
242
|
/**
|