@sphereon/ssi-sdk.presentation-exchange 0.18.2-unstable.8 → 0.18.2-unstable.87
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 +25 -24
- package/dist/agent/PresentationExchange.d.ts.map +1 -1
- package/dist/agent/PresentationExchange.js +183 -181
- package/dist/agent/PresentationExchange.js.map +1 -1
- package/dist/functions.d.ts +13 -11
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +127 -40
- package/dist/functions.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +26 -26
- package/dist/types/IPresentationExchange.d.ts +75 -80
- package/dist/types/IPresentationExchange.d.ts.map +1 -1
- package/dist/types/IPresentationExchange.js +2 -2
- package/package.json +8 -8
- package/src/agent/PresentationExchange.ts +4 -1
- package/src/functions.ts +111 -22
- package/src/types/IPresentationExchange.ts +7 -4
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { IDefinitionCredentialFilterArgs, IPEXFilterResult, IPEXFilterResultWithInputDescriptor, IRequiredContext, PEXOpts, VersionDiscoveryResult } from '../index';
|
|
2
|
-
import { IAgentPlugin } from '@veramo/core';
|
|
3
|
-
import { IPresentationExchange } from '../types/IPresentationExchange';
|
|
4
|
-
import { IPresentationDefinition } from '@sphereon/pex';
|
|
5
|
-
export declare class PresentationExchange implements IAgentPlugin {
|
|
6
|
-
private readonly _stores;
|
|
7
|
-
readonly schema: any;
|
|
8
|
-
private readonly defaultStore;
|
|
9
|
-
private readonly defaultNamespace;
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
|
|
1
|
+
import { IDefinitionCredentialFilterArgs, IPEXFilterResult, IPEXFilterResultWithInputDescriptor, IRequiredContext, PEXOpts, VersionDiscoveryResult } from '../index';
|
|
2
|
+
import { IAgentPlugin } from '@veramo/core';
|
|
3
|
+
import { IPresentationExchange } from '../types/IPresentationExchange';
|
|
4
|
+
import { IPresentationDefinition } from '@sphereon/pex';
|
|
5
|
+
export declare class PresentationExchange implements IAgentPlugin {
|
|
6
|
+
private readonly _stores;
|
|
7
|
+
readonly schema: any;
|
|
8
|
+
private readonly defaultStore;
|
|
9
|
+
private readonly defaultNamespace;
|
|
10
|
+
private readonly pex;
|
|
11
|
+
readonly methods: IPresentationExchange;
|
|
12
|
+
constructor(opts?: PEXOpts);
|
|
13
|
+
private pexStoreGetDefinition;
|
|
14
|
+
private pexStoreHasDefinition;
|
|
15
|
+
private pexStorePersistDefinition;
|
|
16
|
+
private pexStoreRemoveDefinition;
|
|
17
|
+
private pexStoreClearDefinitions;
|
|
18
|
+
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
19
|
+
pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult>;
|
|
20
|
+
pexDefinitionFilterCredentialsPerInputDescriptor(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResultWithInputDescriptor[]>;
|
|
21
|
+
private pexFilterCredentials;
|
|
22
|
+
private store;
|
|
23
|
+
private namespace;
|
|
24
|
+
private prefix;
|
|
25
|
+
}
|
|
25
26
|
//# 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,EAM/B,gBAAgB,EAChB,mCAAmC,EACnC,gBAAgB,EAChB,OAAO,EAEP,sBAAsB,EACvB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAuB,YAAY,EAAE,MAAM,cAAc,CAA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GAAG,OAAO,CAAC,gBAAgB,CAAC;IAe3H,gDAAgD,CACpD,IAAI,EAAE,+BAA+B,EACrC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mCAAmC,EAAE,CAAC;YAmCnC,oBAAoB;IAqBlC,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -1,182 +1,184 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PresentationExchange = void 0;
|
|
13
|
-
const index_1 = require("../index");
|
|
14
|
-
const ssi_sdk_kv_store_temp_1 = require("@sphereon/ssi-sdk.kv-store-temp");
|
|
15
|
-
const pex_1 = require("@sphereon/pex");
|
|
16
|
-
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
17
|
-
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
18
|
-
class PresentationExchange {
|
|
19
|
-
constructor(opts) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
this.schema = index_1.schema.IDidAuthSiopOpAuthenticator;
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PresentationExchange = void 0;
|
|
13
|
+
const index_1 = require("../index");
|
|
14
|
+
const ssi_sdk_kv_store_temp_1 = require("@sphereon/ssi-sdk.kv-store-temp");
|
|
15
|
+
const pex_1 = require("@sphereon/pex");
|
|
16
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
17
|
+
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
18
|
+
class PresentationExchange {
|
|
19
|
+
constructor(opts) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
this.schema = index_1.schema.IDidAuthSiopOpAuthenticator;
|
|
22
|
+
this.pex = new pex_1.PEX();
|
|
23
|
+
this.methods = {
|
|
24
|
+
pexStoreGetDefinition: this.pexStoreGetDefinition.bind(this),
|
|
25
|
+
pexStorePersistDefinition: this.pexStorePersistDefinition.bind(this),
|
|
26
|
+
pexStoreHasDefinition: this.pexStoreHasDefinition.bind(this),
|
|
27
|
+
pexStoreRemoveDefinition: this.pexStoreRemoveDefinition.bind(this),
|
|
28
|
+
pexStoreClearDefinitions: this.pexStoreClearDefinitions.bind(this),
|
|
29
|
+
pexDefinitionVersion: this.pexDefinitionVersion.bind(this),
|
|
30
|
+
pexDefinitionFilterCredentials: this.pexDefinitionFilterCredentials.bind(this),
|
|
31
|
+
pexDefinitionFilterCredentialsPerInputDescriptor: this.pexDefinitionFilterCredentialsPerInputDescriptor.bind(this),
|
|
32
|
+
};
|
|
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
|
+
}
|
|
51
|
+
pexStoreGetDefinition({ definitionId, storeId, namespace }) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return this.store({ storeId }).get(this.prefix({ namespace, definitionId }));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
pexStoreHasDefinition({ definitionId, storeId, namespace }) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return this.store({ storeId }).has(this.prefix({ namespace, definitionId }));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
pexStorePersistDefinition(args) {
|
|
62
|
+
var _a;
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const { definition, ttl, storeId, namespace } = args;
|
|
65
|
+
if ((args === null || args === void 0 ? void 0 : args.validation) !== false) {
|
|
66
|
+
let invalids = [];
|
|
67
|
+
try {
|
|
68
|
+
const result = pex_1.PEX.validateDefinition(definition); // throws an error in case the def is not valid
|
|
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
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const definitionId = (_a = args.definitionId) !== null && _a !== void 0 ? _a : definition.id;
|
|
88
|
+
const existing = yield this.store({ storeId }).getAsValueData(this.prefix({ namespace, definitionId }));
|
|
89
|
+
if (!existing.value || (existing.value && args.overwriteExisting !== false)) {
|
|
90
|
+
return yield this.store({ storeId }).set(this.prefix({ namespace, definitionId }), definition, ttl);
|
|
91
|
+
}
|
|
92
|
+
return existing;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
pexStoreRemoveDefinition({ storeId, definitionId, namespace }) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
return this.store({ storeId }).delete(this.prefix({ namespace, definitionId }));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
pexStoreClearDefinitions({ storeId }) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
return yield this.store({ storeId })
|
|
103
|
+
.clear()
|
|
104
|
+
.then(() => true);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
pexDefinitionVersion(presentationDefinition) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
return pex_1.PEX.definitionVersionDiscovery(presentationDefinition);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
pexDefinitionFilterCredentials(args, context) {
|
|
113
|
+
var _a, _b, _c, _d;
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const credentials = yield this.pexFilterCredentials((_a = args.credentialFilterOpts) !== null && _a !== void 0 ? _a : {}, context);
|
|
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());
|
|
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'] }));
|
|
118
|
+
return {
|
|
119
|
+
id: args.presentationDefinition.id,
|
|
120
|
+
selectResults,
|
|
121
|
+
filteredCredentials: (_d = (_c = selectResults.verifiableCredential) === null || _c === void 0 ? void 0 : _c.map((vc) => ssi_types_1.CredentialMapper.storedCredentialToOriginalFormat(vc))) !== null && _d !== void 0 ? _d : [],
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
pexDefinitionFilterCredentialsPerInputDescriptor(args, context) {
|
|
126
|
+
var _a;
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const origDefinition = args.presentationDefinition;
|
|
129
|
+
const credentials = yield this.pexFilterCredentials((_a = args.credentialFilterOpts) !== null && _a !== void 0 ? _a : {}, context);
|
|
130
|
+
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());
|
|
131
|
+
const limitDisclosureSignatureSuites = args.limitDisclosureSignatureSuites;
|
|
132
|
+
const promises = new Map();
|
|
133
|
+
origDefinition.input_descriptors.forEach((inputDescriptor) => {
|
|
134
|
+
const presentationDefinition = {
|
|
135
|
+
id: inputDescriptor.id,
|
|
136
|
+
input_descriptors: [inputDescriptor],
|
|
137
|
+
};
|
|
138
|
+
promises.set(inputDescriptor, this.pexDefinitionFilterCredentials({
|
|
139
|
+
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
presentationDefinition,
|
|
142
|
+
holderDIDs,
|
|
143
|
+
limitDisclosureSignatureSuites,
|
|
144
|
+
}, context));
|
|
145
|
+
});
|
|
146
|
+
yield Promise.all(promises.values());
|
|
147
|
+
const result = [];
|
|
148
|
+
for (const entry of promises.entries()) {
|
|
149
|
+
result.push(Object.assign(Object.assign({}, (yield entry[1])), { inputDescriptor: entry[0] }));
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
pexFilterCredentials(filterOpts, context) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
if ((filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.verifiableCredentials) && filterOpts.verifiableCredentials.length > 0) {
|
|
157
|
+
return filterOpts.verifiableCredentials;
|
|
158
|
+
}
|
|
159
|
+
return (yield context.agent.dataStoreORMGetVerifiableCredentials(filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.filter))
|
|
160
|
+
.map((uniqueVC) => uniqueVC.verifiableCredential)
|
|
161
|
+
.map((vc) => (vc.proof && vc.proof.type === ssi_types_1.JWT_PROOF_TYPE_2020 ? vc.proof.jwt : vc));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
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
|
+
}
|
|
183
|
+
exports.PresentationExchange = PresentationExchange;
|
|
182
184
|
//# sourceMappingURL=PresentationExchange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAaiB;AAIjB,2EAA2F;AAC3F,uCAAqE;AACrE,mDAAoG;AAEpG,2EAAwD;AAExD,MAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAaiB;AAIjB,2EAA2F;AAC3F,uCAAqE;AACrE,mDAAoG;AAEpG,2EAAwD;AAExD,MAAa,oBAAoB;IAkB/B,YAAY,IAAc;;QAhBjB,WAAM,GAAG,cAAM,CAAC,2BAA2B,CAAA;QAGnC,QAAG,GAAG,IAAI,SAAG,EAAE,CAAA;QAEvB,YAAO,GAA0B;YACxC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5D,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5D,wBAAwB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;YAClE,wBAAwB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;YAClE,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1D,8BAA8B,EAAE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9E,gDAAgD,EAAE,IAAI,CAAC,gDAAgD,CAAC,IAAI,CAAC,IAAI,CAAC;SACnH,CAAA;QAGC,IAAI,CAAC,YAAY,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,mCAAI,UAAU,CAAA;QACpD,IAAI,CAAC,gBAAgB,GAAG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E,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;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,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils';
|
|
2
|
+
import { IPEXOptions, IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange';
|
|
3
|
+
import { IPresentationDefinition } from '@sphereon/pex';
|
|
4
|
+
import { ProofFormat } from '@veramo/core';
|
|
5
|
+
import { Format } from '@sphereon/pex-models';
|
|
6
|
+
export declare function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined>;
|
|
7
|
+
export declare function createPEXPresentationSignCallback(args: {
|
|
8
|
+
idOpts: IIdentifierOpts;
|
|
9
|
+
fetchRemoteContexts?: boolean;
|
|
10
|
+
format?: Format | ProofFormat;
|
|
11
|
+
domain?: string;
|
|
12
|
+
challenge?: string;
|
|
13
|
+
}, context: IRequiredContext): Promise<IPEXPresentationSignCallback>;
|
|
12
14
|
//# sourceMappingURL=functions.d.ts.map
|
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
|
@@ -1,41 +1,128 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createPEXPresentationSignCallback = exports.getPresentationDefinition = void 0;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createPEXPresentationSignCallback = exports.getPresentationDefinition = void 0;
|
|
13
|
+
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
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
|
+
function createPEXPresentationSignCallback(args, context) {
|
|
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
|
+
}
|
|
42
|
+
return ({ presentation, domain, presentationDefinition, format, challenge, }) => __awaiter(this, void 0, void 0, function* () {
|
|
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()}`);
|
|
110
|
+
const vp = yield context.agent.createVerifiablePresentation({
|
|
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,
|
|
117
|
+
proofFormat,
|
|
118
|
+
header,
|
|
119
|
+
});
|
|
120
|
+
console.log(`POST CREATE VP AGENT ${new Date().toString()}`);
|
|
121
|
+
console.log(`PRE MAPPER AGENT ${new Date().toString()}`);
|
|
122
|
+
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
123
|
+
return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(vp);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
exports.createPEXPresentationSignCallback = createPEXPresentationSignCallback;
|
|
41
128
|
//# sourceMappingURL=functions.js.map
|
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,CA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BACtC,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
declare const schema: any;
|
|
5
|
-
export { schema };
|
|
6
|
-
export { PresentationExchange } from './agent/PresentationExchange';
|
|
7
|
-
export * from './types/IPresentationExchange';
|
|
8
|
-
export * from './functions';
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
declare const schema: any;
|
|
5
|
+
export { schema };
|
|
6
|
+
export { PresentationExchange } from './agent/PresentationExchange';
|
|
7
|
+
export * from './types/IPresentationExchange';
|
|
8
|
+
export * from './functions';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PresentationExchange = exports.schema = void 0;
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
const schema = require('../plugin.schema.json');
|
|
22
|
-
exports.schema = schema;
|
|
23
|
-
var PresentationExchange_1 = require("./agent/PresentationExchange");
|
|
24
|
-
Object.defineProperty(exports, "PresentationExchange", { enumerable: true, get: function () { return PresentationExchange_1.PresentationExchange; } });
|
|
25
|
-
__exportStar(require("./types/IPresentationExchange"), exports);
|
|
26
|
-
__exportStar(require("./functions"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PresentationExchange = exports.schema = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
const schema = require('../plugin.schema.json');
|
|
22
|
+
exports.schema = schema;
|
|
23
|
+
var PresentationExchange_1 = require("./agent/PresentationExchange");
|
|
24
|
+
Object.defineProperty(exports, "PresentationExchange", { enumerable: true, get: function () { return PresentationExchange_1.PresentationExchange; } });
|
|
25
|
+
__exportStar(require("./types/IPresentationExchange"), exports);
|
|
26
|
+
__exportStar(require("./functions"), exports);
|
|
27
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,81 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
3
|
-
import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
|
|
4
|
-
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex';
|
|
5
|
-
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models';
|
|
6
|
-
export interface IPresentationExchange extends IPluginMethodMap {
|
|
7
|
-
pexStoreGetDefinition(args: IDefinitionGetArgs): Promise<IPresentationDefinition | undefined>;
|
|
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>;
|
|
12
|
-
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
13
|
-
pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult>;
|
|
14
|
-
pexDefinitionFilterCredentialsPerInputDescriptor(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResultWithInputDescriptor[]>;
|
|
15
|
-
}
|
|
16
|
-
export interface IDefinitionGetArgs {
|
|
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 {
|
|
26
|
-
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
|
-
}
|
|
37
|
-
export interface IDefinitionCredentialFilterArgs {
|
|
38
|
-
presentationDefinition: IPresentationDefinition;
|
|
39
|
-
credentialFilterOpts?: {
|
|
40
|
-
verifiableCredentials?: W3CVerifiableCredential[];
|
|
41
|
-
filter?: FindCredentialsArgs;
|
|
42
|
-
};
|
|
43
|
-
holderDIDs?: (string | IIdentifier)[];
|
|
44
|
-
limitDisclosureSignatureSuites?: string[];
|
|
45
|
-
restrictToFormats?: Format;
|
|
46
|
-
restrictToDIDMethods?: string[];
|
|
47
|
-
}
|
|
48
|
-
export interface PEXOpts {
|
|
49
|
-
defaultStore?: string;
|
|
50
|
-
defaultNamespace?: string;
|
|
51
|
-
stores?: Map<string, IKeyValueStore<IPresentationDefinition>> | IKeyValueStore<IPresentationDefinition>;
|
|
52
|
-
importDefinitions?: IDefinitionImportArgs[];
|
|
53
|
-
}
|
|
54
|
-
export interface IPEXOptions {
|
|
55
|
-
definition?: IPresentationDefinition;
|
|
56
|
-
definitionId: string;
|
|
57
|
-
}
|
|
58
|
-
export interface IPEXFilterResultWithInputDescriptor extends IPEXFilterResult {
|
|
59
|
-
inputDescriptor: InputDescriptorV1 | InputDescriptorV2;
|
|
60
|
-
}
|
|
61
|
-
export interface IPEXFilterResult {
|
|
62
|
-
id: string;
|
|
63
|
-
selectResults: SelectResults;
|
|
64
|
-
filteredCredentials: W3CVerifiableCredential[];
|
|
65
|
-
}
|
|
66
|
-
export interface
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export interface
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
export type
|
|
76
|
-
export interface IPEXPresentationSignCallBackParams {
|
|
77
|
-
presentation: PresentationPayload;
|
|
78
|
-
presentationDefinition: IPresentationDefinition;
|
|
79
|
-
}
|
|
80
|
-
export type IRequiredContext = IAgentContext<IDataStoreORM & IDIDManager>;
|
|
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
|
+
import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
|
|
4
|
+
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex';
|
|
5
|
+
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models';
|
|
6
|
+
export interface IPresentationExchange extends IPluginMethodMap {
|
|
7
|
+
pexStoreGetDefinition(args: IDefinitionGetArgs): Promise<IPresentationDefinition | undefined>;
|
|
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>;
|
|
12
|
+
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
13
|
+
pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult>;
|
|
14
|
+
pexDefinitionFilterCredentialsPerInputDescriptor(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResultWithInputDescriptor[]>;
|
|
15
|
+
}
|
|
16
|
+
export interface IDefinitionGetArgs {
|
|
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 {
|
|
26
|
+
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
|
+
}
|
|
37
|
+
export interface IDefinitionCredentialFilterArgs {
|
|
38
|
+
presentationDefinition: IPresentationDefinition;
|
|
39
|
+
credentialFilterOpts?: {
|
|
40
|
+
verifiableCredentials?: W3CVerifiableCredential[];
|
|
41
|
+
filter?: FindCredentialsArgs;
|
|
42
|
+
};
|
|
43
|
+
holderDIDs?: (string | IIdentifier)[];
|
|
44
|
+
limitDisclosureSignatureSuites?: string[];
|
|
45
|
+
restrictToFormats?: Format;
|
|
46
|
+
restrictToDIDMethods?: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface PEXOpts {
|
|
49
|
+
defaultStore?: string;
|
|
50
|
+
defaultNamespace?: string;
|
|
51
|
+
stores?: Map<string, IKeyValueStore<IPresentationDefinition>> | IKeyValueStore<IPresentationDefinition>;
|
|
52
|
+
importDefinitions?: IDefinitionImportArgs[];
|
|
53
|
+
}
|
|
54
|
+
export interface IPEXOptions {
|
|
55
|
+
definition?: IPresentationDefinition;
|
|
56
|
+
definitionId: string;
|
|
57
|
+
}
|
|
58
|
+
export interface IPEXFilterResultWithInputDescriptor extends IPEXFilterResult {
|
|
59
|
+
inputDescriptor: InputDescriptorV1 | InputDescriptorV2;
|
|
60
|
+
}
|
|
61
|
+
export interface IPEXFilterResult {
|
|
62
|
+
id: string;
|
|
63
|
+
selectResults: SelectResults;
|
|
64
|
+
filteredCredentials: W3CVerifiableCredential[];
|
|
65
|
+
}
|
|
66
|
+
export interface VersionDiscoveryResult {
|
|
67
|
+
version?: PEVersion;
|
|
68
|
+
error?: string;
|
|
69
|
+
}
|
|
70
|
+
export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>;
|
|
71
|
+
export interface IPEXPresentationSignCallBackParams {
|
|
72
|
+
presentation: IPresentation | Optional<PresentationPayload, 'holder'>;
|
|
73
|
+
presentationDefinition: IPresentationDefinition;
|
|
74
|
+
}
|
|
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,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AiB,CAAC,EAAE,qBAAqB,EAAE,CAAA;CAC5C;AAED,MAAM,WAAW,WAAW;IAE1B,UAAU,CAAC,EAAE,uBAAuB,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,mCAAoC,SAAQ,gBAAgB;IAC3E,eAAe,EAAE,iBAAiB,GAAG,iBAAiB,CAAA;CACvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,aAAa,CAAA;IAC5B,mBAAmB,EAAE,uBAAuB,EAAE,CAAA;CAC/C;AAUD,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,4BAA4B,GAAG,CAAC,IAAI,EAAE,kCAAkC,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAE3H,MAAM,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"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=IPresentationExchange.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.presentation-exchange",
|
|
3
|
-
"version": "0.18.2-unstable.
|
|
3
|
+
"version": "0.18.2-unstable.87+ecefdcf4",
|
|
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.
|
|
19
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
20
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.18.2-unstable.
|
|
21
|
-
"@sphereon/ssi-types": "0.18.2-unstable.
|
|
17
|
+
"@sphereon/pex": "^3.2.0",
|
|
18
|
+
"@sphereon/pex-models": "^2.2.0",
|
|
19
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
|
|
20
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.18.2-unstable.87+ecefdcf4",
|
|
21
|
+
"@sphereon/ssi-types": "0.18.2-unstable.87+ecefdcf4",
|
|
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-unstable.
|
|
26
|
+
"@sphereon/ssi-sdk.agent-config": "0.18.2-unstable.87+ecefdcf4",
|
|
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": "ecefdcf4eccfa2d78fb9e815efdbe3881aa9e2f8"
|
|
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>
|