@sphereon/ssi-sdk.presentation-exchange 0.24.0 → 0.24.1-next.98
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/LICENSE +1 -1
- package/dist/agent/PresentationExchange.d.ts +1 -11
- package/dist/agent/PresentationExchange.d.ts.map +1 -1
- package/dist/agent/PresentationExchange.js +22 -93
- package/dist/agent/PresentationExchange.js.map +1 -1
- package/dist/functions.d.ts +1 -3
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +1 -9
- package/dist/functions.js.map +1 -1
- package/dist/types/IPresentationExchange.d.ts +2 -27
- package/dist/types/IPresentationExchange.d.ts.map +1 -1
- package/package.json +5 -8
- package/src/agent/PresentationExchange.ts +29 -106
- package/src/functions.ts +1 -7
- package/src/types/IPresentationExchange.ts +3 -45
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright [
|
|
189
|
+
Copyright [2024] [Sphereon International B.V.]
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -3,24 +3,14 @@ import { IAgentPlugin } from '@veramo/core';
|
|
|
3
3
|
import { IPresentationExchange } from '../types/IPresentationExchange';
|
|
4
4
|
import { IPresentationDefinition } from '@sphereon/pex';
|
|
5
5
|
export declare class PresentationExchange implements IAgentPlugin {
|
|
6
|
-
private readonly _stores;
|
|
7
6
|
readonly schema: any;
|
|
8
|
-
private readonly defaultStore;
|
|
9
|
-
private readonly defaultNamespace;
|
|
10
7
|
private readonly pex;
|
|
11
8
|
readonly methods: IPresentationExchange;
|
|
12
9
|
constructor(opts?: PEXOpts);
|
|
13
|
-
private
|
|
14
|
-
private pexStoreHasDefinition;
|
|
15
|
-
private pexStorePersistDefinition;
|
|
16
|
-
private pexStoreRemoveDefinition;
|
|
17
|
-
private pexStoreClearDefinitions;
|
|
10
|
+
private pexValidateDefinition;
|
|
18
11
|
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
19
12
|
pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult>;
|
|
20
13
|
pexDefinitionFilterCredentialsPerInputDescriptor(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResultWithInputDescriptor[]>;
|
|
21
14
|
private pexFilterCredentials;
|
|
22
|
-
private store;
|
|
23
|
-
private namespace;
|
|
24
|
-
private prefix;
|
|
25
15
|
}
|
|
26
16
|
//# sourceMappingURL=PresentationExchange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.d.ts","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,
|
|
1
|
+
{"version":3,"file":"PresentationExchange.d.ts","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAE/B,gBAAgB,EAChB,mCAAmC,EACnC,gBAAgB,EAChB,OAAO,EAEP,sBAAsB,EACvB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAuB,YAAY,EAA6D,MAAM,cAAc,CAAA;AAE3H,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAW,uBAAuB,EAAO,MAAM,eAAe,CAAA;AAKrE,qBAAa,oBAAqB,YAAW,YAAY;IACvD,QAAQ,CAAC,MAAM,MAAqC;IACpD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAEhC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAKtC;gBAEW,IAAI,CAAC,EAAE,OAAO;YAEZ,qBAAqB;IA2B7B,oBAAoB,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAItG,8BAA8B,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAe3H,gDAAgD,CACpD,IAAI,EAAE,+BAA+B,EACrC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mCAAmC,EAAE,CAAC;YAmCnC,oBAAoB;CAcnC"}
|
|
@@ -11,97 +11,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PresentationExchange = void 0;
|
|
13
13
|
const index_1 = require("../index");
|
|
14
|
-
const ssi_sdk_kv_store_temp_1 = require("@sphereon/ssi-sdk.kv-store-temp");
|
|
15
14
|
const pex_1 = require("@sphereon/pex");
|
|
16
15
|
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
17
16
|
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
18
17
|
class PresentationExchange {
|
|
19
18
|
constructor(opts) {
|
|
20
|
-
var _a, _b;
|
|
21
19
|
this.schema = index_1.schema.IDidAuthSiopOpAuthenticator;
|
|
22
20
|
this.pex = new pex_1.PEX();
|
|
23
21
|
this.methods = {
|
|
24
|
-
|
|
25
|
-
pexStorePersistDefinition: this.pexStorePersistDefinition.bind(this),
|
|
26
|
-
pexStoreHasDefinition: this.pexStoreHasDefinition.bind(this),
|
|
27
|
-
pexStoreRemoveDefinition: this.pexStoreRemoveDefinition.bind(this),
|
|
28
|
-
pexStoreClearDefinitions: this.pexStoreClearDefinitions.bind(this),
|
|
22
|
+
pexValidateDefinition: this.pexValidateDefinition.bind(this),
|
|
29
23
|
pexDefinitionVersion: this.pexDefinitionVersion.bind(this),
|
|
30
24
|
pexDefinitionFilterCredentials: this.pexDefinitionFilterCredentials.bind(this),
|
|
31
25
|
pexDefinitionFilterCredentialsPerInputDescriptor: this.pexDefinitionFilterCredentialsPerInputDescriptor.bind(this),
|
|
32
26
|
};
|
|
33
|
-
this.defaultStore = (_a = opts === null || opts === void 0 ? void 0 : opts.defaultStore) !== null && _a !== void 0 ? _a : '_default';
|
|
34
|
-
this.defaultNamespace = (_b = opts === null || opts === void 0 ? void 0 : opts.defaultNamespace) !== null && _b !== void 0 ? _b : 'pex';
|
|
35
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.stores) && opts.stores instanceof Map) {
|
|
36
|
-
this._stores = opts.stores;
|
|
37
|
-
}
|
|
38
|
-
else if (opts === null || opts === void 0 ? void 0 : opts.stores) {
|
|
39
|
-
this._stores = new Map().set(this.defaultStore, opts.stores);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
this._stores = new Map().set(this.defaultStore, new ssi_sdk_kv_store_temp_1.KeyValueStore({
|
|
43
|
-
namespace: this.defaultNamespace,
|
|
44
|
-
store: new Map(),
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
if (opts && Array.isArray(opts === null || opts === void 0 ? void 0 : opts.importDefinitions)) {
|
|
48
|
-
opts.importDefinitions.forEach(this.pexStorePersistDefinition);
|
|
49
|
-
}
|
|
50
27
|
}
|
|
51
|
-
|
|
52
|
-
return __awaiter(this, arguments, void 0, function* ({ definitionId, storeId, namespace }) {
|
|
53
|
-
return this.store({ storeId }).get(this.prefix({ namespace, definitionId }));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
pexStoreHasDefinition(_a) {
|
|
57
|
-
return __awaiter(this, arguments, void 0, function* ({ definitionId, storeId, namespace }) {
|
|
58
|
-
return this.store({ storeId }).has(this.prefix({ namespace, definitionId }));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
pexStorePersistDefinition(args) {
|
|
28
|
+
pexValidateDefinition(args) {
|
|
62
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const validations = Array.isArray(result) ? result : [result];
|
|
70
|
-
invalids = validations.filter((v) => v.status === 'error');
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
invalids.push({
|
|
74
|
-
status: 'error',
|
|
75
|
-
message: typeof error === 'string'
|
|
76
|
-
? error
|
|
77
|
-
: typeof error === 'object' && 'message' in error
|
|
78
|
-
? error.message
|
|
79
|
-
: 'unknown error',
|
|
80
|
-
tag: 'validation',
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (invalids.length > 0) {
|
|
84
|
-
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`);
|
|
85
|
-
}
|
|
30
|
+
const { definition } = args;
|
|
31
|
+
const invalids = [];
|
|
32
|
+
try {
|
|
33
|
+
const result = pex_1.PEX.validateDefinition(definition);
|
|
34
|
+
const validations = Array.isArray(result) ? result : [result];
|
|
35
|
+
invalids.push(...validations.filter((v) => v.status === 'error'));
|
|
86
36
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
37
|
+
catch (error) {
|
|
38
|
+
invalids.push({
|
|
39
|
+
status: 'error',
|
|
40
|
+
message: typeof error === 'string'
|
|
41
|
+
? error
|
|
42
|
+
: typeof error === 'object' && 'message' in error
|
|
43
|
+
? error.message
|
|
44
|
+
: 'unknown error',
|
|
45
|
+
tag: 'validation',
|
|
46
|
+
});
|
|
91
47
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return __awaiter(this, arguments, void 0, function* ({ storeId, definitionId, namespace }) {
|
|
97
|
-
return this.store({ storeId }).delete(this.prefix({ namespace, definitionId }));
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
pexStoreClearDefinitions(_a) {
|
|
101
|
-
return __awaiter(this, arguments, void 0, function* ({ storeId }) {
|
|
102
|
-
return yield this.store({ storeId })
|
|
103
|
-
.clear()
|
|
104
|
-
.then(() => true);
|
|
48
|
+
if (invalids.length > 0) {
|
|
49
|
+
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`);
|
|
50
|
+
}
|
|
51
|
+
return true; // Never returns false, but REST API does not allow Promise<void>
|
|
105
52
|
});
|
|
106
53
|
}
|
|
107
54
|
pexDefinitionVersion(presentationDefinition) {
|
|
@@ -161,24 +108,6 @@ class PresentationExchange {
|
|
|
161
108
|
.map((vc) => (vc.proof && vc.proof.type === ssi_types_1.JWT_PROOF_TYPE_2020 ? vc.proof.jwt : vc));
|
|
162
109
|
});
|
|
163
110
|
}
|
|
164
|
-
/*private assertIdentifier(identifier?: IIdentifier): void {
|
|
165
|
-
if (!identifier) {
|
|
166
|
-
throw Error(`OID4VP needs an identifier at this point`)
|
|
167
|
-
}
|
|
168
|
-
}*/
|
|
169
|
-
store({ storeId }) {
|
|
170
|
-
const store = this._stores.get(storeId !== null && storeId !== void 0 ? storeId : this.defaultStore);
|
|
171
|
-
if (!store) {
|
|
172
|
-
throw Error(`Could not get definition store: ${storeId !== null && storeId !== void 0 ? storeId : this.defaultStore}`);
|
|
173
|
-
}
|
|
174
|
-
return store;
|
|
175
|
-
}
|
|
176
|
-
namespace({ namespace }) {
|
|
177
|
-
return namespace !== null && namespace !== void 0 ? namespace : this.defaultStore;
|
|
178
|
-
}
|
|
179
|
-
prefix({ namespace, definitionId }) {
|
|
180
|
-
return `${this.namespace({ namespace })}:${definitionId}`;
|
|
181
|
-
}
|
|
182
111
|
}
|
|
183
112
|
exports.PresentationExchange = PresentationExchange;
|
|
184
113
|
//# sourceMappingURL=PresentationExchange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCASiB;AAIjB,uCAAqE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vC,MAAM,CAAC,IAAI,iCAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAE,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,IAAG,CAAA;YACjE,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;IAEa,oBAAoB,CAChC,UAGC,EACD,OAAyB;;YAEzB,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,qBAAqB,KAAI,UAAU,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrF,OAAO,UAAU,CAAC,qBAAkD,CAAA;YACtE,CAAC;YACD,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAC,CAAC;iBAClF,GAAG,CAAC,CAAC,QAAoC,EAAE,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;iBAC5E,GAAG,CAAC,CAAC,EAA6C,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,+BAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACpI,CAAC;KAAA;CACF;AA/GD,oDA+GC"}
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils';
|
|
2
|
-
import {
|
|
3
|
-
import { IPresentationDefinition } from '@sphereon/pex';
|
|
2
|
+
import { IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange';
|
|
4
3
|
import { ProofFormat } from '@veramo/core';
|
|
5
4
|
import { Format } from '@sphereon/pex-models';
|
|
6
|
-
export declare function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined>;
|
|
7
5
|
export declare function createPEXPresentationSignCallback(args: {
|
|
8
6
|
idOpts: IIdentifierOpts;
|
|
9
7
|
fetchRemoteContexts?: boolean;
|
package/dist/functions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAC5I,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAC5I,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAE9F,OAAO,EAAuB,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,wBAAsB,iCAAiC,CACrD,IAAI,EAAE;IACJ,MAAM,EAAE,eAAe,CAAA;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,EACD,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,4BAA4B,CAAC,CA0HvC"}
|
package/dist/functions.js
CHANGED
|
@@ -9,17 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createPEXPresentationSignCallback =
|
|
12
|
+
exports.createPEXPresentationSignCallback = void 0;
|
|
13
13
|
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
14
14
|
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
15
|
-
function getPresentationDefinition(pexOptions) {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
return pexOptions === null || pexOptions === void 0 ? void 0 : pexOptions.definition;
|
|
18
|
-
/*const store = await getPresentationDefinitionStore(pexOptions)
|
|
19
|
-
return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
exports.getPresentationDefinition = getPresentationDefinition;
|
|
23
15
|
function createPEXPresentationSignCallback(args, context) {
|
|
24
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
17
|
function determineProofFormat({ format, presentationDefinition, }) {
|
package/dist/functions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAA4I;AAI5I,mDAA2H;AAG3H,SAAsB,
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAA4I;AAI5I,mDAA2H;AAG3H,SAAsB,iCAAiC,CACrD,IAMC,EACD,OAAyB;;QAEzB,SAAS,oBAAoB,CAAC,EAC5B,MAAM,EACN,sBAAsB,GAIvB;;YACC,IAAI,WAAW,GAAgB,KAAK,CAAA;YACpC,MAAM,aAAa,GAAG,MAAA,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,IAAI,CAAC,MAAM,mCAAI,sBAAsB,CAAC,MAAM,CAAA;YAC5E,IAAI,aAAa,EAAE,CAAC;gBAClB,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;oBACtC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,K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C3B,MAAM,EAAE,GAAG,CAAC,GAAG;gBACf,oGAAoG;gBACpG,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,SAAS;gBACtC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,KAAK,KAAK;gBACvD,WAAW;gBACX,MAAM;aACP,CAAC,CAAA;YACF,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YAC5D,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YACxD,2FAA2F;YAC3F,OAAO,4BAAgB,CAAC,kCAAkC,CAAC,EAAoC,CAAC,CAAA;QAClG,CAAC,CAAA,CAAA;IACH,CAAC;CAAA;AAnID,8EAmIC"}
|
|
@@ -1,38 +1,15 @@
|
|
|
1
1
|
import { FindCredentialsArgs, IAgentContext, ICredentialPlugin, IDataStoreORM, IDIDManager, IIdentifier, IPluginMethodMap, IResolver, PresentationPayload } from '@veramo/core';
|
|
2
2
|
import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
3
|
-
import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
|
|
4
3
|
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex';
|
|
5
4
|
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models';
|
|
6
5
|
export interface IPresentationExchange extends IPluginMethodMap {
|
|
7
|
-
|
|
8
|
-
pexStoreHasDefinition(args: IDefinitionExistsArgs): Promise<boolean>;
|
|
9
|
-
pexStorePersistDefinition(args: IDefinitionPersistArgs): Promise<IValueData<IPresentationDefinition>>;
|
|
10
|
-
pexStoreRemoveDefinition(args: IDefinitionRemoveArgs): Promise<boolean>;
|
|
11
|
-
pexStoreClearDefinitions(args: IDefinitionsClearArgs): Promise<boolean>;
|
|
6
|
+
pexValidateDefinition(args: IDefinitionValidateArgs): Promise<boolean>;
|
|
12
7
|
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
13
8
|
pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult>;
|
|
14
9
|
pexDefinitionFilterCredentialsPerInputDescriptor(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResultWithInputDescriptor[]>;
|
|
15
10
|
}
|
|
16
|
-
export interface
|
|
17
|
-
definitionId: string;
|
|
18
|
-
storeId?: string;
|
|
19
|
-
namespace?: string;
|
|
20
|
-
}
|
|
21
|
-
export type IDefinitionExistsArgs = IDefinitionGetArgs;
|
|
22
|
-
export type IDefinitionClearArgs = IDefinitionGetArgs;
|
|
23
|
-
export type IDefinitionRemoveArgs = IDefinitionGetArgs;
|
|
24
|
-
export type IDefinitionImportArgs = IDefinitionPersistArgs;
|
|
25
|
-
export interface IDefinitionPersistArgs {
|
|
11
|
+
export interface IDefinitionValidateArgs {
|
|
26
12
|
definition: IPresentationDefinition;
|
|
27
|
-
definitionId?: string;
|
|
28
|
-
overwriteExisting?: boolean;
|
|
29
|
-
validation?: boolean;
|
|
30
|
-
ttl?: number;
|
|
31
|
-
storeId?: string;
|
|
32
|
-
namespace?: string;
|
|
33
|
-
}
|
|
34
|
-
export interface IDefinitionsClearArgs {
|
|
35
|
-
storeId?: string;
|
|
36
13
|
}
|
|
37
14
|
export interface IDefinitionCredentialFilterArgs {
|
|
38
15
|
presentationDefinition: IPresentationDefinition;
|
|
@@ -48,8 +25,6 @@ export interface IDefinitionCredentialFilterArgs {
|
|
|
48
25
|
export interface PEXOpts {
|
|
49
26
|
defaultStore?: string;
|
|
50
27
|
defaultNamespace?: string;
|
|
51
|
-
stores?: Map<string, IKeyValueStore<IPresentationDefinition>> | IKeyValueStore<IPresentationDefinition>;
|
|
52
|
-
importDefinitions?: IDefinitionImportArgs[];
|
|
53
28
|
}
|
|
54
29
|
export interface IPEXOptions {
|
|
55
30
|
definition?: IPresentationDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPresentationExchange.d.ts","sourceRoot":"","sources":["../../src/types/IPresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IPresentationExchange.d.ts","sourceRoot":"","sources":["../../src/types/IPresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAEnF,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEtE,oBAAoB,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAEtG,8BAA8B,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAA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,WAAW,kCAAkC;IACjD,YAAY,EAAE,aAAa,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAA;IACrE,sBAAsB,EAAE,uBAAuB,CAAA;CAChD;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,iBAAiB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.presentation-exchange",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.1-next.98+c62d8ca9",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"@sphereon/pex": "^3.3.3",
|
|
18
18
|
"@sphereon/pex-models": "^2.2.4",
|
|
19
19
|
"@sphereon/ssi-sdk-ext.did-utils": "0.19.0",
|
|
20
|
-
"@sphereon/ssi-sdk.
|
|
21
|
-
"@sphereon/ssi-types": "0.24.
|
|
20
|
+
"@sphereon/ssi-sdk.data-store": "0.24.1-next.98+c62d8ca9",
|
|
21
|
+
"@sphereon/ssi-types": "0.24.1-next.98+c62d8ca9",
|
|
22
22
|
"@veramo/core": "4.2.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
26
|
-
"@sphereon/ssi-sdk.agent-config": "0.24.
|
|
26
|
+
"@sphereon/ssi-sdk.agent-config": "0.24.1-next.98+c62d8ca9",
|
|
27
27
|
"@types/json-buffer": "^3.0.0",
|
|
28
28
|
"@veramo/did-provider-key": "4.2.0",
|
|
29
29
|
"@veramo/did-resolver": "4.2.0",
|
|
@@ -33,9 +33,6 @@
|
|
|
33
33
|
"did-resolver": "^4.1.0",
|
|
34
34
|
"nock": "^13.2.1"
|
|
35
35
|
},
|
|
36
|
-
"resolutions": {
|
|
37
|
-
"@veramo/utils": "4.2.0"
|
|
38
|
-
},
|
|
39
36
|
"files": [
|
|
40
37
|
".yalc/**/*",
|
|
41
38
|
"dist/**/*",
|
|
@@ -63,5 +60,5 @@
|
|
|
63
60
|
"OpenID Connect",
|
|
64
61
|
"Authenticator"
|
|
65
62
|
],
|
|
66
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "c62d8ca97210e599cb1a91446ae652d1c832710f"
|
|
67
64
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IDefinitionCredentialFilterArgs,
|
|
3
|
-
|
|
4
|
-
IDefinitionGetArgs,
|
|
5
|
-
IDefinitionPersistArgs,
|
|
6
|
-
IDefinitionRemoveArgs,
|
|
7
|
-
IDefinitionsClearArgs,
|
|
3
|
+
IDefinitionValidateArgs,
|
|
8
4
|
IPEXFilterResult,
|
|
9
5
|
IPEXFilterResultWithInputDescriptor,
|
|
10
6
|
IRequiredContext,
|
|
@@ -12,103 +8,52 @@ import {
|
|
|
12
8
|
schema,
|
|
13
9
|
VersionDiscoveryResult,
|
|
14
10
|
} from '../index'
|
|
15
|
-
import { FindCredentialsArgs, IAgentPlugin } from '@veramo/core'
|
|
11
|
+
import { FindCredentialsArgs, IAgentPlugin, ProofType, UniqueVerifiableCredential, UnsignedCredential } from '@veramo/core'
|
|
16
12
|
|
|
17
13
|
import { IPresentationExchange } from '../types/IPresentationExchange'
|
|
18
|
-
import { IKeyValueStore, IValueData, KeyValueStore } from '@sphereon/ssi-sdk.kv-store-temp'
|
|
19
14
|
import { Checked, IPresentationDefinition, PEX } from '@sphereon/pex'
|
|
20
15
|
import { CredentialMapper, JWT_PROOF_TYPE_2020, W3CVerifiableCredential } from '@sphereon/ssi-types'
|
|
21
16
|
import { InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models'
|
|
22
17
|
import { toDIDs } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
23
18
|
|
|
24
19
|
export class PresentationExchange implements IAgentPlugin {
|
|
25
|
-
private readonly _stores: Map<string, IKeyValueStore<IPresentationDefinition>>
|
|
26
20
|
readonly schema = schema.IDidAuthSiopOpAuthenticator
|
|
27
|
-
private readonly defaultStore: string
|
|
28
|
-
private readonly defaultNamespace: string
|
|
29
21
|
private readonly pex = new PEX()
|
|
30
22
|
|
|
31
23
|
readonly methods: IPresentationExchange = {
|
|
32
|
-
|
|
33
|
-
pexStorePersistDefinition: this.pexStorePersistDefinition.bind(this),
|
|
34
|
-
pexStoreHasDefinition: this.pexStoreHasDefinition.bind(this),
|
|
35
|
-
pexStoreRemoveDefinition: this.pexStoreRemoveDefinition.bind(this),
|
|
36
|
-
pexStoreClearDefinitions: this.pexStoreClearDefinitions.bind(this),
|
|
24
|
+
pexValidateDefinition: this.pexValidateDefinition.bind(this),
|
|
37
25
|
pexDefinitionVersion: this.pexDefinitionVersion.bind(this),
|
|
38
26
|
pexDefinitionFilterCredentials: this.pexDefinitionFilterCredentials.bind(this),
|
|
39
27
|
pexDefinitionFilterCredentialsPerInputDescriptor: this.pexDefinitionFilterCredentialsPerInputDescriptor.bind(this),
|
|
40
28
|
}
|
|
41
29
|
|
|
42
|
-
constructor(opts?: PEXOpts) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
constructor(opts?: PEXOpts) {}
|
|
31
|
+
|
|
32
|
+
private async pexValidateDefinition(args: IDefinitionValidateArgs): Promise<boolean> {
|
|
33
|
+
const { definition } = args
|
|
34
|
+
const invalids: Checked[] = []
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const result = PEX.validateDefinition(definition)
|
|
38
|
+
const validations = Array.isArray(result) ? result : [result]
|
|
39
|
+
invalids.push(...validations.filter((v) => v.status === 'error'))
|
|
40
|
+
} catch (error) {
|
|
41
|
+
invalids.push({
|
|
42
|
+
status: 'error',
|
|
43
|
+
message:
|
|
44
|
+
typeof error === 'string'
|
|
45
|
+
? error
|
|
46
|
+
: typeof error === 'object' && 'message' in (error as object)
|
|
47
|
+
? (error as Error).message
|
|
48
|
+
: 'unknown error',
|
|
49
|
+
tag: 'validation',
|
|
50
|
+
})
|
|
60
51
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private async pexStoreGetDefinition({ definitionId, storeId, namespace }: IDefinitionGetArgs): Promise<IPresentationDefinition | undefined> {
|
|
64
|
-
return this.store({ storeId }).get(this.prefix({ namespace, definitionId }))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private async pexStoreHasDefinition({ definitionId, storeId, namespace }: IDefinitionExistsArgs): Promise<boolean> {
|
|
68
|
-
return this.store({ storeId }).has(this.prefix({ namespace, definitionId }))
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private async pexStorePersistDefinition(args: IDefinitionPersistArgs): Promise<IValueData<IPresentationDefinition>> {
|
|
72
|
-
const { definition, ttl, storeId, namespace } = args
|
|
73
|
-
if (args?.validation !== false) {
|
|
74
|
-
let invalids: Checked[] = []
|
|
75
52
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const validations = Array.isArray(result) ? result : [result]
|
|
79
|
-
invalids = validations.filter((v) => v.status === 'error')
|
|
80
|
-
} catch (error) {
|
|
81
|
-
invalids.push({
|
|
82
|
-
status: 'error',
|
|
83
|
-
message:
|
|
84
|
-
typeof error === 'string'
|
|
85
|
-
? error
|
|
86
|
-
: typeof error === 'object' && 'message' in (error as object)
|
|
87
|
-
? (error as Error).message
|
|
88
|
-
: 'unknown error',
|
|
89
|
-
tag: 'validation',
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
if (invalids.length > 0) {
|
|
93
|
-
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const definitionId = args.definitionId ?? definition.id
|
|
97
|
-
const existing = await this.store({ storeId }).getAsValueData(this.prefix({ namespace, definitionId }))
|
|
98
|
-
if (!existing.value || (existing.value && args.overwriteExisting !== false)) {
|
|
99
|
-
return await this.store({ storeId }).set(this.prefix({ namespace, definitionId }), definition, ttl)
|
|
53
|
+
if (invalids.length > 0) {
|
|
54
|
+
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`)
|
|
100
55
|
}
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private async pexStoreRemoveDefinition({ storeId, definitionId, namespace }: IDefinitionRemoveArgs): Promise<boolean> {
|
|
105
|
-
return this.store({ storeId }).delete(this.prefix({ namespace, definitionId }))
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private async pexStoreClearDefinitions({ storeId }: IDefinitionsClearArgs): Promise<boolean> {
|
|
109
|
-
return await this.store({ storeId })
|
|
110
|
-
.clear()
|
|
111
|
-
.then(() => true)
|
|
56
|
+
return true // Never returns false, but REST API does not allow Promise<void>
|
|
112
57
|
}
|
|
113
58
|
|
|
114
59
|
async pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult> {
|
|
@@ -179,29 +124,7 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
179
124
|
return filterOpts.verifiableCredentials as W3CVerifiableCredential[]
|
|
180
125
|
}
|
|
181
126
|
return (await context.agent.dataStoreORMGetVerifiableCredentials(filterOpts?.filter))
|
|
182
|
-
.map((uniqueVC) => uniqueVC.verifiableCredential)
|
|
183
|
-
.map((vc) => (vc.proof && vc.proof.type === JWT_PROOF_TYPE_2020 ? vc.proof.jwt : vc))
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/*private assertIdentifier(identifier?: IIdentifier): void {
|
|
187
|
-
if (!identifier) {
|
|
188
|
-
throw Error(`OID4VP needs an identifier at this point`)
|
|
189
|
-
}
|
|
190
|
-
}*/
|
|
191
|
-
|
|
192
|
-
private store({ storeId }: { storeId?: string }): IKeyValueStore<IPresentationDefinition> {
|
|
193
|
-
const store = this._stores.get(storeId ?? this.defaultStore)
|
|
194
|
-
if (!store) {
|
|
195
|
-
throw Error(`Could not get definition store: ${storeId ?? this.defaultStore}`)
|
|
196
|
-
}
|
|
197
|
-
return store
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private namespace({ namespace }: { namespace?: string }): string {
|
|
201
|
-
return namespace ?? this.defaultStore
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
private prefix({ namespace, definitionId }: { namespace?: string; definitionId: string }) {
|
|
205
|
-
return `${this.namespace({ namespace })}:${definitionId}`
|
|
127
|
+
.map((uniqueVC: UniqueVerifiableCredential) => uniqueVC.verifiableCredential)
|
|
128
|
+
.map((vc: UnsignedCredential & { proof: ProofType }) => (vc.proof && vc.proof.type === JWT_PROOF_TYPE_2020 ? vc.proof.jwt : vc))
|
|
206
129
|
}
|
|
207
130
|
}
|
package/src/functions.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { dereferenceDidKeysWithJwkSupport, getAgentResolver, getIdentifier, getKey, IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
2
|
-
import {
|
|
2
|
+
import { IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange'
|
|
3
3
|
import { IPresentationDefinition } from '@sphereon/pex'
|
|
4
4
|
import { PresentationPayload, ProofFormat } from '@veramo/core'
|
|
5
5
|
import { CredentialMapper, Optional, OriginalVerifiablePresentation, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
6
6
|
import { Format } from '@sphereon/pex-models'
|
|
7
7
|
|
|
8
|
-
export async function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined> {
|
|
9
|
-
return pexOptions?.definition
|
|
10
|
-
/*const store = await getPresentationDefinitionStore(pexOptions)
|
|
11
|
-
return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
|
|
12
|
-
}
|
|
13
|
-
|
|
14
8
|
export async function createPEXPresentationSignCallback(
|
|
15
9
|
args: {
|
|
16
10
|
idOpts: IIdentifierOpts
|
|
@@ -10,20 +10,11 @@ import {
|
|
|
10
10
|
PresentationPayload,
|
|
11
11
|
} from '@veramo/core'
|
|
12
12
|
import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
13
|
-
import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp'
|
|
14
13
|
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex'
|
|
15
14
|
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models'
|
|
16
15
|
|
|
17
16
|
export interface IPresentationExchange extends IPluginMethodMap {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
pexStoreHasDefinition(args: IDefinitionExistsArgs): Promise<boolean>
|
|
21
|
-
|
|
22
|
-
pexStorePersistDefinition(args: IDefinitionPersistArgs): Promise<IValueData<IPresentationDefinition>>
|
|
23
|
-
|
|
24
|
-
pexStoreRemoveDefinition(args: IDefinitionRemoveArgs): Promise<boolean>
|
|
25
|
-
|
|
26
|
-
pexStoreClearDefinitions(args: IDefinitionsClearArgs): Promise<boolean>
|
|
17
|
+
pexValidateDefinition(args: IDefinitionValidateArgs): Promise<boolean>
|
|
27
18
|
|
|
28
19
|
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>
|
|
29
20
|
|
|
@@ -35,31 +26,8 @@ export interface IPresentationExchange extends IPluginMethodMap {
|
|
|
35
26
|
): Promise<IPEXFilterResultWithInputDescriptor[]>
|
|
36
27
|
}
|
|
37
28
|
|
|
38
|
-
export interface
|
|
39
|
-
|
|
40
|
-
storeId?: string
|
|
41
|
-
namespace?: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type IDefinitionExistsArgs = IDefinitionGetArgs
|
|
45
|
-
export type IDefinitionClearArgs = IDefinitionGetArgs
|
|
46
|
-
export type IDefinitionRemoveArgs = IDefinitionGetArgs
|
|
47
|
-
|
|
48
|
-
export type IDefinitionImportArgs = IDefinitionPersistArgs
|
|
49
|
-
|
|
50
|
-
export interface IDefinitionPersistArgs {
|
|
51
|
-
definition: IPresentationDefinition // The actual Presentation definition to be stored/
|
|
52
|
-
definitionId?: string // Allows to define a custom key for storage. By default, the id of the definition will be used
|
|
53
|
-
overwriteExisting?: boolean // Whether to overwrite any existing definition by id. Defaults to true
|
|
54
|
-
validation?: boolean // Whether to check the definition. Defaults to true
|
|
55
|
-
ttl?: number // How long should the definition be stored in seconds. By default, it will be indefinite
|
|
56
|
-
storeId?: string // The store id to use. Allows you to use multiple different stores next to each-other
|
|
57
|
-
namespace?: string // The namespace (prefix) to use whilst storing the definition. Allows you to partition definitions
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface IDefinitionsClearArgs {
|
|
61
|
-
storeId?: string
|
|
62
|
-
// namespace?: string
|
|
29
|
+
export interface IDefinitionValidateArgs {
|
|
30
|
+
definition: IPresentationDefinition // The Presentation definition/
|
|
63
31
|
}
|
|
64
32
|
|
|
65
33
|
export interface IDefinitionCredentialFilterArgs {
|
|
@@ -74,8 +42,6 @@ export interface IDefinitionCredentialFilterArgs {
|
|
|
74
42
|
export interface PEXOpts {
|
|
75
43
|
defaultStore?: string
|
|
76
44
|
defaultNamespace?: string
|
|
77
|
-
stores?: Map<string, IKeyValueStore<IPresentationDefinition>> | IKeyValueStore<IPresentationDefinition>
|
|
78
|
-
importDefinitions?: IDefinitionImportArgs[]
|
|
79
45
|
}
|
|
80
46
|
|
|
81
47
|
export interface IPEXOptions {
|
|
@@ -94,14 +60,6 @@ export interface IPEXFilterResult {
|
|
|
94
60
|
filteredCredentials: W3CVerifiableCredential[]
|
|
95
61
|
}
|
|
96
62
|
|
|
97
|
-
/*
|
|
98
|
-
export interface IIdentifierOpts {
|
|
99
|
-
identifier: IIdentifier | string
|
|
100
|
-
verificationMethodSection?: DIDDocumentSection
|
|
101
|
-
kid?: string
|
|
102
|
-
}
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
63
|
export interface VersionDiscoveryResult {
|
|
106
64
|
version?: PEVersion
|
|
107
65
|
error?: string
|