@sphereon/ssi-sdk.presentation-exchange 0.18.2-next.3 → 0.18.2-next.57
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/dist/agent/PresentationExchange.d.ts +1 -0
- package/dist/agent/PresentationExchange.d.ts.map +1 -1
- package/dist/agent/PresentationExchange.js +3 -1
- package/dist/agent/PresentationExchange.js.map +1 -1
- package/dist/functions.d.ts +5 -3
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +96 -9
- package/dist/functions.js.map +1 -1
- package/dist/types/IPresentationExchange.d.ts +4 -9
- package/dist/types/IPresentationExchange.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/agent/PresentationExchange.ts +4 -1
- package/src/functions.ts +111 -22
- package/src/types/IPresentationExchange.ts +7 -4
|
@@ -7,6 +7,7 @@ export declare class PresentationExchange implements IAgentPlugin {
|
|
|
7
7
|
readonly schema: any;
|
|
8
8
|
private readonly defaultStore;
|
|
9
9
|
private readonly defaultNamespace;
|
|
10
|
+
private readonly pex;
|
|
10
11
|
readonly methods: IPresentationExchange;
|
|
11
12
|
constructor(opts?: PEXOpts);
|
|
12
13
|
private pexStoreGetDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.d.ts","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAM/B,gBAAgB,EAChB,mCAAmC,EACnC,gBAAgB,EAChB,OAAO,EAEP,sBAAsB,EACvB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAuB,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,EAAW,uBAAuB,EAAO,MAAM,eAAe,CAAA;AAKrE,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsD;IAC9E,QAAQ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,SAAS;IAIjB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -19,6 +19,7 @@ class PresentationExchange {
|
|
|
19
19
|
constructor(opts) {
|
|
20
20
|
var _a, _b;
|
|
21
21
|
this.schema = index_1.schema.IDidAuthSiopOpAuthenticator;
|
|
22
|
+
this.pex = new pex_1.PEX();
|
|
22
23
|
this.methods = {
|
|
23
24
|
pexStoreGetDefinition: this.pexStoreGetDefinition.bind(this),
|
|
24
25
|
pexStorePersistDefinition: this.pexStorePersistDefinition.bind(this),
|
|
@@ -113,7 +114,7 @@ class PresentationExchange {
|
|
|
113
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
115
|
const credentials = yield this.pexFilterCredentials((_a = args.credentialFilterOpts) !== null && _a !== void 0 ? _a : {}, context);
|
|
115
116
|
const holderDIDs = args.holderDIDs ? (0, ssi_sdk_ext_did_utils_1.toDIDs)(args.holderDIDs) : (0, ssi_sdk_ext_did_utils_1.toDIDs)(yield context.agent.dataStoreORMGetIdentifiers());
|
|
116
|
-
const selectResults =
|
|
117
|
+
const selectResults = this.pex.selectFrom(args.presentationDefinition, credentials !== null && credentials !== void 0 ? credentials : [], Object.assign(Object.assign({}, args), { holderDIDs, limitDisclosureSignatureSuites: (_b = args.limitDisclosureSignatureSuites) !== null && _b !== void 0 ? _b : ['BbsBlsSignature2020'] }));
|
|
117
118
|
return {
|
|
118
119
|
id: args.presentationDefinition.id,
|
|
119
120
|
selectResults,
|
|
@@ -136,6 +137,7 @@ class PresentationExchange {
|
|
|
136
137
|
};
|
|
137
138
|
promises.set(inputDescriptor, this.pexDefinitionFilterCredentials({
|
|
138
139
|
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
140
|
+
// @ts-ignore
|
|
139
141
|
presentationDefinition,
|
|
140
142
|
holderDIDs,
|
|
141
143
|
limitDisclosureSignatureSuites,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange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,KAAK,CAAC,IAAI,KAAK,+BAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACzF,CAAC;KAAA;IAED;;;;OAIG;IAEK,KAAK,CAAC,EAAE,OAAO,EAAwB;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,YAAY,CAAC,CAAA;QAC5D,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,KAAK,CAAC,mCAAmC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,YAAY,EAAE,CAAC,CAAA;SAC/E;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,SAAS,CAAC,EAAE,SAAS,EAA0B;QACrD,OAAO,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,YAAY,CAAA;IACvC,CAAC;IAEO,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,EAAgD;QACtF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,YAAY,EAAE,CAAA;IAC3D,CAAC;CACF;AAvLD,oDAuLC"}
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils';
|
|
1
2
|
import { IPEXOptions, IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange';
|
|
2
3
|
import { IPresentationDefinition } from '@sphereon/pex';
|
|
4
|
+
import { ProofFormat } from '@veramo/core';
|
|
3
5
|
import { Format } from '@sphereon/pex-models';
|
|
4
6
|
export declare function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined>;
|
|
5
|
-
export declare function createPEXPresentationSignCallback(
|
|
6
|
-
|
|
7
|
+
export declare function createPEXPresentationSignCallback(args: {
|
|
8
|
+
idOpts: IIdentifierOpts;
|
|
7
9
|
fetchRemoteContexts?: boolean;
|
|
8
|
-
format?: Format;
|
|
10
|
+
format?: Format | ProofFormat;
|
|
9
11
|
domain?: string;
|
|
10
12
|
challenge?: string;
|
|
11
13
|
}, context: IRequiredContext): Promise<IPEXPresentationSignCallback>;
|
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,EAAE,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAC3G,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;
|
|
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,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAC3G,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAuB,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,wBAAsB,yBAAyB,CAAC,UAAU,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAItH;AAED,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
|
@@ -10,28 +10,115 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createPEXPresentationSignCallback = exports.getPresentationDefinition = void 0;
|
|
13
|
+
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
13
14
|
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
14
15
|
function getPresentationDefinition(pexOptions) {
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
return pexOptions === null || pexOptions === void 0 ? void 0 : pexOptions.definition;
|
|
17
18
|
/*const store = await getPresentationDefinitionStore(pexOptions)
|
|
18
|
-
|
|
19
|
+
return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
exports.getPresentationDefinition = getPresentationDefinition;
|
|
22
|
-
function createPEXPresentationSignCallback(
|
|
23
|
+
function createPEXPresentationSignCallback(args, context) {
|
|
23
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
function determineProofFormat({ format, presentationDefinition, }) {
|
|
26
|
+
var _a;
|
|
27
|
+
let proofFormat = 'jwt';
|
|
28
|
+
const formatOptions = (_a = format !== null && format !== void 0 ? format : args.format) !== null && _a !== void 0 ? _a : presentationDefinition.format;
|
|
29
|
+
if (formatOptions) {
|
|
30
|
+
if (typeof formatOptions === 'object') {
|
|
31
|
+
const formats = Object.keys(formatOptions).map((form) => (form.includes('ldp') ? 'lds' : 'jwt'));
|
|
32
|
+
if (!formats.includes('jwt')) {
|
|
33
|
+
proofFormat = 'lds';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
proofFormat = formatOptions;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return proofFormat;
|
|
41
|
+
}
|
|
24
42
|
return ({ presentation, domain, presentationDefinition, format, challenge, }) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
|
|
26
|
-
const
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
const idOpts = args.idOpts;
|
|
45
|
+
const id = yield (0, ssi_sdk_ext_did_utils_1.getIdentifier)(idOpts, context);
|
|
46
|
+
if (typeof idOpts.identifier === 'string') {
|
|
47
|
+
idOpts.identifier = id;
|
|
48
|
+
}
|
|
49
|
+
if (!presentation.holder) {
|
|
50
|
+
presentation.holder = id.did;
|
|
51
|
+
}
|
|
52
|
+
const key = yield (0, ssi_sdk_ext_did_utils_1.getKey)(id, 'authentication', context, idOpts.kid);
|
|
53
|
+
const didResolution = yield (0, ssi_sdk_ext_did_utils_1.getAgentResolver)(context).resolve(idOpts.identifier.did);
|
|
54
|
+
const vms = yield (0, ssi_sdk_ext_did_utils_1.dereferenceDidKeysWithJwkSupport)(didResolution.didDocument, (_a = idOpts.verificationMethodSection) !== null && _a !== void 0 ? _a : 'authentication', context);
|
|
55
|
+
const vm = vms.find((vm) => vm.publicKeyHex === key.publicKeyHex);
|
|
56
|
+
if (!vm) {
|
|
57
|
+
throw Error(`Could not resolve DID document or match signing key to did ${idOpts.identifier.did}`);
|
|
58
|
+
}
|
|
59
|
+
const proofFormat = determineProofFormat({ format, presentationDefinition });
|
|
60
|
+
let header;
|
|
61
|
+
if (!presentation.holder) {
|
|
62
|
+
presentation.holder = id.did;
|
|
63
|
+
}
|
|
64
|
+
if (proofFormat === 'jwt') {
|
|
65
|
+
header = {
|
|
66
|
+
kid: vm.id,
|
|
67
|
+
};
|
|
68
|
+
if (presentation.verifier || !presentation.aud) {
|
|
69
|
+
presentation.aud = Array.isArray(presentation.verifier) ? presentation.verifier : (_c = (_b = presentation.verifier) !== null && _b !== void 0 ? _b : domain) !== null && _c !== void 0 ? _c : args.domain;
|
|
70
|
+
delete presentation.verifier;
|
|
71
|
+
}
|
|
72
|
+
if (!presentation.nbf) {
|
|
73
|
+
if (presentation.issuanceDate) {
|
|
74
|
+
const converted = Date.parse(presentation.issuanceDate);
|
|
75
|
+
if (!isNaN(converted)) {
|
|
76
|
+
presentation.nbf = Math.floor(converted / 1000);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
presentation.nbf = Math.floor(Date.now() / 1000);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!presentation.iat) {
|
|
84
|
+
presentation.iat = presentation.nbf;
|
|
85
|
+
}
|
|
86
|
+
if (!presentation.exp) {
|
|
87
|
+
if (presentation.expirationDate) {
|
|
88
|
+
const converted = Date.parse(presentation.expirationDate);
|
|
89
|
+
if (!isNaN(converted)) {
|
|
90
|
+
presentation.exp = Math.floor(converted / 1000);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
presentation.exp = presentation.nbf + 600;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!presentation.vp) {
|
|
98
|
+
presentation.vp = {};
|
|
99
|
+
}
|
|
100
|
+
if (!presentation.sub) {
|
|
101
|
+
presentation.sub = id.did;
|
|
102
|
+
}
|
|
103
|
+
if (!presentation.vp.holder) {
|
|
104
|
+
presentation.vp.holder = id.did;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// we ignore the alg / proof_format for now, as we already have the kid anyway at this point
|
|
108
|
+
// todo: look for jwt_vc_json and remove types and @context
|
|
109
|
+
console.log(`PRE CREATE VP AGENT ${new Date().toString()}`);
|
|
27
110
|
const vp = yield context.agent.createVerifiablePresentation({
|
|
28
|
-
presentation,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
111
|
+
presentation: presentation,
|
|
112
|
+
removeOriginalFields: false,
|
|
113
|
+
keyRef: key.kid,
|
|
114
|
+
// domain: domain ?? args.domain, // handled above, and did-jwt-vc creates an array even for 1 entry
|
|
115
|
+
challenge: challenge !== null && challenge !== void 0 ? challenge : args.challenge,
|
|
116
|
+
fetchRemoteContexts: args.fetchRemoteContexts !== false,
|
|
33
117
|
proofFormat,
|
|
118
|
+
header,
|
|
34
119
|
});
|
|
120
|
+
console.log(`POST CREATE VP AGENT ${new Date().toString()}`);
|
|
121
|
+
console.log(`PRE MAPPER AGENT ${new Date().toString()}`);
|
|
35
122
|
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
36
123
|
return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(vp);
|
|
37
124
|
});
|
package/dist/functions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAA4I;AAI5I,mDAA2H;AAG3H,SAAsB,yBAAyB,CAAC,UAAwB;;QACtE,OAAO,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,CAAA;QAC7B;sGAC8F;IAChG,CAAC;CAAA;AAJD,8DAIC;AAED,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;gBACjB,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;oBACrC,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,KAAK,CAAC,CAA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AE,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,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
1
|
+
import { FindCredentialsArgs, IAgentContext, ICredentialPlugin, IDataStoreORM, IDIDManager, IIdentifier, IPluginMethodMap, IResolver, PresentationPayload } from '@veramo/core';
|
|
2
|
+
import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
3
3
|
import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
|
|
4
4
|
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex';
|
|
5
5
|
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models';
|
|
@@ -63,19 +63,14 @@ export interface IPEXFilterResult {
|
|
|
63
63
|
selectResults: SelectResults;
|
|
64
64
|
filteredCredentials: W3CVerifiableCredential[];
|
|
65
65
|
}
|
|
66
|
-
export interface IIdentifierOpts {
|
|
67
|
-
identifier: IIdentifier | string;
|
|
68
|
-
verificationMethodSection?: DIDDocumentSection;
|
|
69
|
-
kid?: string;
|
|
70
|
-
}
|
|
71
66
|
export interface VersionDiscoveryResult {
|
|
72
67
|
version?: PEVersion;
|
|
73
68
|
error?: string;
|
|
74
69
|
}
|
|
75
70
|
export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>;
|
|
76
71
|
export interface IPEXPresentationSignCallBackParams {
|
|
77
|
-
presentation: PresentationPayload
|
|
72
|
+
presentation: IPresentation | Optional<PresentationPayload, 'holder'>;
|
|
78
73
|
presentationDefinition: IPresentationDefinition;
|
|
79
74
|
}
|
|
80
|
-
export type IRequiredContext = IAgentContext<IDataStoreORM & IDIDManager>;
|
|
75
|
+
export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin>;
|
|
81
76
|
//# sourceMappingURL=IPresentationExchange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPresentationExchange.d.ts","sourceRoot":"","sources":["../../src/types/IPresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
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,cAAc,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAC5E,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,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAA;IAE7F,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEpE,yBAAyB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,u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,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.18.2-next.
|
|
3
|
+
"version": "0.18.2-next.57+5cb8b6b0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sphereon/pex": "2.
|
|
18
|
-
"@sphereon/pex-models": "^2.
|
|
17
|
+
"@sphereon/pex": "^3.2.0",
|
|
18
|
+
"@sphereon/pex-models": "^2.2.0",
|
|
19
19
|
"@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
|
|
20
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.18.2-next.
|
|
21
|
-
"@sphereon/ssi-types": "0.18.2-next.
|
|
20
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.18.2-next.57+5cb8b6b0",
|
|
21
|
+
"@sphereon/ssi-types": "0.18.2-next.57+5cb8b6b0",
|
|
22
22
|
"@veramo/core": "4.2.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@sphereon/did-uni-client": "^0.6.0",
|
|
26
|
-
"@sphereon/ssi-sdk.agent-config": "0.18.2-next.
|
|
26
|
+
"@sphereon/ssi-sdk.agent-config": "0.18.2-next.57+5cb8b6b0",
|
|
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",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"OpenID Connect",
|
|
64
64
|
"Authenticator"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "5cb8b6b035fa13248f517a0e306e359d80efb113"
|
|
67
67
|
}
|
|
@@ -26,6 +26,7 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
26
26
|
readonly schema = schema.IDidAuthSiopOpAuthenticator
|
|
27
27
|
private readonly defaultStore: string
|
|
28
28
|
private readonly defaultNamespace: string
|
|
29
|
+
private readonly pex = new PEX()
|
|
29
30
|
|
|
30
31
|
readonly methods: IPresentationExchange = {
|
|
31
32
|
pexStoreGetDefinition: this.pexStoreGetDefinition.bind(this),
|
|
@@ -117,7 +118,7 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
117
118
|
async pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult> {
|
|
118
119
|
const credentials = await this.pexFilterCredentials(args.credentialFilterOpts ?? {}, context)
|
|
119
120
|
const holderDIDs = args.holderDIDs ? toDIDs(args.holderDIDs) : toDIDs(await context.agent.dataStoreORMGetIdentifiers())
|
|
120
|
-
const selectResults =
|
|
121
|
+
const selectResults = this.pex.selectFrom(args.presentationDefinition, credentials ?? [], {
|
|
121
122
|
...args,
|
|
122
123
|
holderDIDs,
|
|
123
124
|
limitDisclosureSignatureSuites: args.limitDisclosureSignatureSuites ?? ['BbsBlsSignature2020'],
|
|
@@ -144,11 +145,13 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
144
145
|
id: inputDescriptor.id,
|
|
145
146
|
input_descriptors: [inputDescriptor],
|
|
146
147
|
}
|
|
148
|
+
|
|
147
149
|
promises.set(
|
|
148
150
|
inputDescriptor,
|
|
149
151
|
this.pexDefinitionFilterCredentials(
|
|
150
152
|
{
|
|
151
153
|
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
154
|
+
// @ts-ignore
|
|
152
155
|
presentationDefinition,
|
|
153
156
|
holderDIDs,
|
|
154
157
|
limitDisclosureSignatureSuites,
|
package/src/functions.ts
CHANGED
|
@@ -1,31 +1,48 @@
|
|
|
1
|
+
import { dereferenceDidKeysWithJwkSupport, getAgentResolver, getIdentifier, getKey, IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
1
2
|
import { IPEXOptions, IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange'
|
|
2
3
|
import { IPresentationDefinition } from '@sphereon/pex'
|
|
3
|
-
import { PresentationPayload } from '@veramo/core'
|
|
4
|
-
import { CredentialMapper, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
4
|
+
import { PresentationPayload, ProofFormat } from '@veramo/core'
|
|
5
|
+
import { CredentialMapper, Optional, OriginalVerifiablePresentation, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
5
6
|
import { Format } from '@sphereon/pex-models'
|
|
6
7
|
|
|
7
8
|
export async function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined> {
|
|
8
9
|
return pexOptions?.definition
|
|
9
10
|
/*const store = await getPresentationDefinitionStore(pexOptions)
|
|
10
|
-
|
|
11
|
+
return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export async function createPEXPresentationSignCallback(
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
fetchRemoteContexts,
|
|
17
|
-
format,
|
|
18
|
-
domain,
|
|
19
|
-
challenge,
|
|
20
|
-
}: {
|
|
21
|
-
kid: string
|
|
15
|
+
args: {
|
|
16
|
+
idOpts: IIdentifierOpts
|
|
22
17
|
fetchRemoteContexts?: boolean
|
|
23
|
-
format?: Format
|
|
18
|
+
format?: Format | ProofFormat
|
|
24
19
|
domain?: string
|
|
25
20
|
challenge?: string
|
|
26
21
|
},
|
|
27
22
|
context: IRequiredContext
|
|
28
23
|
): Promise<IPEXPresentationSignCallback> {
|
|
24
|
+
function determineProofFormat({
|
|
25
|
+
format,
|
|
26
|
+
presentationDefinition,
|
|
27
|
+
}: {
|
|
28
|
+
format?: Format | 'jwt' | 'lds' | 'EthereumEip712Signature2021'
|
|
29
|
+
presentationDefinition: IPresentationDefinition
|
|
30
|
+
}) {
|
|
31
|
+
let proofFormat: ProofFormat = 'jwt'
|
|
32
|
+
const formatOptions = format ?? args.format ?? presentationDefinition.format
|
|
33
|
+
if (formatOptions) {
|
|
34
|
+
if (typeof formatOptions === 'object') {
|
|
35
|
+
const formats = Object.keys(formatOptions).map((form) => (form.includes('ldp') ? 'lds' : 'jwt'))
|
|
36
|
+
if (!formats.includes('jwt')) {
|
|
37
|
+
proofFormat = 'lds'
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
proofFormat = formatOptions
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return proofFormat
|
|
44
|
+
}
|
|
45
|
+
|
|
29
46
|
return async ({
|
|
30
47
|
presentation,
|
|
31
48
|
domain,
|
|
@@ -33,24 +50,96 @@ export async function createPEXPresentationSignCallback(
|
|
|
33
50
|
format,
|
|
34
51
|
challenge,
|
|
35
52
|
}: {
|
|
36
|
-
presentation: PresentationPayload
|
|
53
|
+
presentation: Optional<PresentationPayload, 'holder'>
|
|
37
54
|
presentationDefinition: IPresentationDefinition
|
|
38
|
-
format?: Format
|
|
55
|
+
format?: Format | ProofFormat
|
|
39
56
|
domain?: string
|
|
40
57
|
challenge?: string
|
|
41
58
|
}): Promise<W3CVerifiablePresentation> => {
|
|
42
|
-
const
|
|
43
|
-
const
|
|
59
|
+
const idOpts = args.idOpts
|
|
60
|
+
const id = await getIdentifier(idOpts, context)
|
|
61
|
+
if (typeof idOpts.identifier === 'string') {
|
|
62
|
+
idOpts.identifier = id
|
|
63
|
+
}
|
|
64
|
+
if (!presentation.holder) {
|
|
65
|
+
presentation.holder = id.did
|
|
66
|
+
}
|
|
67
|
+
const key = await getKey(id, 'authentication', context, idOpts.kid)
|
|
68
|
+
const didResolution = await getAgentResolver(context).resolve(idOpts.identifier.did)
|
|
69
|
+
const vms = await dereferenceDidKeysWithJwkSupport(didResolution.didDocument!, idOpts.verificationMethodSection ?? 'authentication', context)
|
|
70
|
+
const vm = vms.find((vm) => vm.publicKeyHex === key.publicKeyHex)
|
|
71
|
+
if (!vm) {
|
|
72
|
+
throw Error(`Could not resolve DID document or match signing key to did ${idOpts.identifier.did}`)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const proofFormat = determineProofFormat({ format, presentationDefinition })
|
|
76
|
+
let header
|
|
77
|
+
if (!presentation.holder) {
|
|
78
|
+
presentation.holder = id.did
|
|
79
|
+
}
|
|
80
|
+
if (proofFormat === 'jwt') {
|
|
81
|
+
header = {
|
|
82
|
+
kid: vm.id,
|
|
83
|
+
}
|
|
84
|
+
if (presentation.verifier || !presentation.aud) {
|
|
85
|
+
presentation.aud = Array.isArray(presentation.verifier) ? presentation.verifier : presentation.verifier ?? domain ?? args.domain
|
|
86
|
+
delete presentation.verifier
|
|
87
|
+
}
|
|
88
|
+
if (!presentation.nbf) {
|
|
89
|
+
if (presentation.issuanceDate) {
|
|
90
|
+
const converted = Date.parse(presentation.issuanceDate)
|
|
91
|
+
if (!isNaN(converted)) {
|
|
92
|
+
presentation.nbf = Math.floor(converted / 1000)
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
presentation.nbf = Math.floor(Date.now() / 1000)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!presentation.iat) {
|
|
100
|
+
presentation.iat = presentation.nbf
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!presentation.exp) {
|
|
104
|
+
if (presentation.expirationDate) {
|
|
105
|
+
const converted = Date.parse(presentation.expirationDate)
|
|
106
|
+
if (!isNaN(converted)) {
|
|
107
|
+
presentation.exp = Math.floor(converted / 1000)
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
presentation.exp = presentation.nbf + 600
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!presentation.vp) {
|
|
115
|
+
presentation.vp = {}
|
|
116
|
+
}
|
|
117
|
+
if (!presentation.sub) {
|
|
118
|
+
presentation.sub = id.did
|
|
119
|
+
}
|
|
120
|
+
if (!presentation.vp.holder) {
|
|
121
|
+
presentation.vp.holder = id.did
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// we ignore the alg / proof_format for now, as we already have the kid anyway at this point
|
|
126
|
+
|
|
127
|
+
// todo: look for jwt_vc_json and remove types and @context
|
|
44
128
|
|
|
129
|
+
console.log(`PRE CREATE VP AGENT ${new Date().toString()}`)
|
|
45
130
|
const vp = await context.agent.createVerifiablePresentation({
|
|
46
|
-
presentation,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
131
|
+
presentation: presentation as PresentationPayload,
|
|
132
|
+
removeOriginalFields: false,
|
|
133
|
+
keyRef: key.kid,
|
|
134
|
+
// domain: domain ?? args.domain, // handled above, and did-jwt-vc creates an array even for 1 entry
|
|
135
|
+
challenge: challenge ?? args.challenge,
|
|
136
|
+
fetchRemoteContexts: args.fetchRemoteContexts !== false,
|
|
51
137
|
proofFormat,
|
|
138
|
+
header,
|
|
52
139
|
})
|
|
140
|
+
console.log(`POST CREATE VP AGENT ${new Date().toString()}`)
|
|
141
|
+
console.log(`PRE MAPPER AGENT ${new Date().toString()}`)
|
|
53
142
|
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
54
|
-
return CredentialMapper.storedPresentationToOriginalFormat(vp as
|
|
143
|
+
return CredentialMapper.storedPresentationToOriginalFormat(vp as OriginalVerifiablePresentation)
|
|
55
144
|
}
|
|
56
145
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DIDDocumentSection,
|
|
3
2
|
FindCredentialsArgs,
|
|
4
3
|
IAgentContext,
|
|
4
|
+
ICredentialPlugin,
|
|
5
5
|
IDataStoreORM,
|
|
6
6
|
IDIDManager,
|
|
7
7
|
IIdentifier,
|
|
8
8
|
IPluginMethodMap,
|
|
9
|
+
IResolver,
|
|
9
10
|
PresentationPayload,
|
|
10
11
|
} from '@veramo/core'
|
|
11
|
-
import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
12
|
+
import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
12
13
|
import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp'
|
|
13
14
|
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex'
|
|
14
15
|
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models'
|
|
@@ -93,11 +94,13 @@ export interface IPEXFilterResult {
|
|
|
93
94
|
filteredCredentials: W3CVerifiableCredential[]
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
/*
|
|
96
98
|
export interface IIdentifierOpts {
|
|
97
99
|
identifier: IIdentifier | string
|
|
98
100
|
verificationMethodSection?: DIDDocumentSection
|
|
99
101
|
kid?: string
|
|
100
102
|
}
|
|
103
|
+
*/
|
|
101
104
|
|
|
102
105
|
export interface VersionDiscoveryResult {
|
|
103
106
|
version?: PEVersion
|
|
@@ -107,8 +110,8 @@ export interface VersionDiscoveryResult {
|
|
|
107
110
|
export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>
|
|
108
111
|
|
|
109
112
|
export interface IPEXPresentationSignCallBackParams {
|
|
110
|
-
presentation: PresentationPayload
|
|
113
|
+
presentation: IPresentation | Optional<PresentationPayload, 'holder'>
|
|
111
114
|
presentationDefinition: IPresentationDefinition
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
export type IRequiredContext = IAgentContext<IDataStoreORM & IDIDManager>
|
|
117
|
+
export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin>
|