@sphereon/ssi-sdk.presentation-exchange 0.18.2-unstable.25 → 0.18.2-unstable.7
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 +24 -24
- package/dist/agent/PresentationExchange.d.ts.map +1 -1
- package/dist/agent/PresentationExchange.js +181 -182
- package/dist/agent/PresentationExchange.js.map +1 -1
- package/dist/functions.d.ts +11 -13
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +40 -75
- 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 +80 -75
- 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 +0 -2
- package/src/functions.ts +22 -52
- package/src/types/IPresentationExchange.ts +4 -7
|
@@ -1,25 +1,25 @@
|
|
|
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 methods: IPresentationExchange;
|
|
11
|
-
constructor(opts?: PEXOpts);
|
|
12
|
-
private pexStoreGetDefinition;
|
|
13
|
-
private pexStoreHasDefinition;
|
|
14
|
-
private pexStorePersistDefinition;
|
|
15
|
-
private pexStoreRemoveDefinition;
|
|
16
|
-
private pexStoreClearDefinitions;
|
|
17
|
-
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
18
|
-
pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult>;
|
|
19
|
-
pexDefinitionFilterCredentialsPerInputDescriptor(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResultWithInputDescriptor[]>;
|
|
20
|
-
private pexFilterCredentials;
|
|
21
|
-
private store;
|
|
22
|
-
private namespace;
|
|
23
|
-
private prefix;
|
|
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
|
+
readonly methods: IPresentationExchange;
|
|
11
|
+
constructor(opts?: PEXOpts);
|
|
12
|
+
private pexStoreGetDefinition;
|
|
13
|
+
private pexStoreHasDefinition;
|
|
14
|
+
private pexStorePersistDefinition;
|
|
15
|
+
private pexStoreRemoveDefinition;
|
|
16
|
+
private pexStoreClearDefinitions;
|
|
17
|
+
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
18
|
+
pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult>;
|
|
19
|
+
pexDefinitionFilterCredentialsPerInputDescriptor(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResultWithInputDescriptor[]>;
|
|
20
|
+
private pexFilterCredentials;
|
|
21
|
+
private store;
|
|
22
|
+
private namespace;
|
|
23
|
+
private prefix;
|
|
24
|
+
}
|
|
25
25
|
//# 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,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,CAAC,MAAM,MAAqC;IACpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;IAEzC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAStC;gBAEW,IAAI,CAAC,EAAE,OAAO;YAqBZ,qBAAqB;YAIrB,qBAAqB;YAIrB,yBAAyB;YAiCzB,wBAAwB;YAIxB,wBAAwB;IAMhC,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;
|
|
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,CAAC,MAAM,MAAqC;IACpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;IAEzC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAStC;gBAEW,IAAI,CAAC,EAAE,OAAO;YAqBZ,qBAAqB;YAIrB,qBAAqB;YAIrB,yBAAyB;YAiCzB,wBAAwB;YAIxB,wBAAwB;IAMhC,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;YAiCnC,oBAAoB;IAqBlC,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -1,183 +1,182 @@
|
|
|
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.methods = {
|
|
23
|
-
pexStoreGetDefinition: this.pexStoreGetDefinition.bind(this),
|
|
24
|
-
pexStorePersistDefinition: this.pexStorePersistDefinition.bind(this),
|
|
25
|
-
pexStoreHasDefinition: this.pexStoreHasDefinition.bind(this),
|
|
26
|
-
pexStoreRemoveDefinition: this.pexStoreRemoveDefinition.bind(this),
|
|
27
|
-
pexStoreClearDefinitions: this.pexStoreClearDefinitions.bind(this),
|
|
28
|
-
pexDefinitionVersion: this.pexDefinitionVersion.bind(this),
|
|
29
|
-
pexDefinitionFilterCredentials: this.pexDefinitionFilterCredentials.bind(this),
|
|
30
|
-
pexDefinitionFilterCredentialsPerInputDescriptor: this.pexDefinitionFilterCredentialsPerInputDescriptor.bind(this),
|
|
31
|
-
};
|
|
32
|
-
this.defaultStore = (_a = opts === null || opts === void 0 ? void 0 : opts.defaultStore) !== null && _a !== void 0 ? _a : '_default';
|
|
33
|
-
this.defaultNamespace = (_b = opts === null || opts === void 0 ? void 0 : opts.defaultNamespace) !== null && _b !== void 0 ? _b : 'pex';
|
|
34
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.stores) && opts.stores instanceof Map) {
|
|
35
|
-
this._stores = opts.stores;
|
|
36
|
-
}
|
|
37
|
-
else if (opts === null || opts === void 0 ? void 0 : opts.stores) {
|
|
38
|
-
this._stores = new Map().set(this.defaultStore, opts.stores);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
this._stores = new Map().set(this.defaultStore, new ssi_sdk_kv_store_temp_1.KeyValueStore({
|
|
42
|
-
namespace: this.defaultNamespace,
|
|
43
|
-
store: new Map(),
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
if (opts && Array.isArray(opts === null || opts === void 0 ? void 0 : opts.importDefinitions)) {
|
|
47
|
-
opts.importDefinitions.forEach(this.pexStorePersistDefinition);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
pexStoreGetDefinition({ definitionId, storeId, namespace }) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
return this.store({ storeId }).get(this.prefix({ namespace, definitionId }));
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
pexStoreHasDefinition({ definitionId, storeId, namespace }) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return this.store({ storeId }).has(this.prefix({ namespace, definitionId }));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
pexStorePersistDefinition(args) {
|
|
61
|
-
var _a;
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const { definition, ttl, storeId, namespace } = args;
|
|
64
|
-
if ((args === null || args === void 0 ? void 0 : args.validation) !== false) {
|
|
65
|
-
let invalids = [];
|
|
66
|
-
try {
|
|
67
|
-
const result = pex_1.PEX.validateDefinition(definition); // throws an error in case the def is not valid
|
|
68
|
-
const validations = Array.isArray(result) ? result : [result];
|
|
69
|
-
invalids = validations.filter((v) => v.status === 'error');
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
invalids.push({
|
|
73
|
-
status: 'error',
|
|
74
|
-
message: typeof error === 'string'
|
|
75
|
-
? error
|
|
76
|
-
: typeof error === 'object' && 'message' in error
|
|
77
|
-
? error.message
|
|
78
|
-
: 'unknown error',
|
|
79
|
-
tag: 'validation',
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (invalids.length > 0) {
|
|
83
|
-
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const definitionId = (_a = args.definitionId) !== null && _a !== void 0 ? _a : definition.id;
|
|
87
|
-
const existing = yield this.store({ storeId }).getAsValueData(this.prefix({ namespace, definitionId }));
|
|
88
|
-
if (!existing.value || (existing.value && args.overwriteExisting !== false)) {
|
|
89
|
-
return yield this.store({ storeId }).set(this.prefix({ namespace, definitionId }), definition, ttl);
|
|
90
|
-
}
|
|
91
|
-
return existing;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
pexStoreRemoveDefinition({ storeId, definitionId, namespace }) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
return this.store({ storeId }).delete(this.prefix({ namespace, definitionId }));
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
pexStoreClearDefinitions({ storeId }) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
return yield this.store({ storeId })
|
|
102
|
-
.clear()
|
|
103
|
-
.then(() => true);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
pexDefinitionVersion(presentationDefinition) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
return pex_1.PEX.definitionVersionDiscovery(presentationDefinition);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
pexDefinitionFilterCredentials(args, context) {
|
|
112
|
-
var _a, _b, _c, _d;
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
const credentials = yield this.pexFilterCredentials((_a = args.credentialFilterOpts) !== null && _a !== void 0 ? _a : {}, context);
|
|
115
|
-
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 = new pex_1.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
|
-
return {
|
|
118
|
-
id: args.presentationDefinition.id,
|
|
119
|
-
selectResults,
|
|
120
|
-
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 : [],
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
pexDefinitionFilterCredentialsPerInputDescriptor(args, context) {
|
|
125
|
-
var _a;
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const origDefinition = args.presentationDefinition;
|
|
128
|
-
const credentials = yield this.pexFilterCredentials((_a = args.credentialFilterOpts) !== null && _a !== void 0 ? _a : {}, context);
|
|
129
|
-
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());
|
|
130
|
-
const limitDisclosureSignatureSuites = args.limitDisclosureSignatureSuites;
|
|
131
|
-
const promises = new Map();
|
|
132
|
-
origDefinition.input_descriptors.forEach((inputDescriptor) => {
|
|
133
|
-
const presentationDefinition = {
|
|
134
|
-
id: inputDescriptor.id,
|
|
135
|
-
input_descriptors: [inputDescriptor],
|
|
136
|
-
};
|
|
137
|
-
promises.set(inputDescriptor, this.pexDefinitionFilterCredentials({
|
|
138
|
-
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
.map((
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
exports.PresentationExchange = PresentationExchange;
|
|
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.methods = {
|
|
23
|
+
pexStoreGetDefinition: this.pexStoreGetDefinition.bind(this),
|
|
24
|
+
pexStorePersistDefinition: this.pexStorePersistDefinition.bind(this),
|
|
25
|
+
pexStoreHasDefinition: this.pexStoreHasDefinition.bind(this),
|
|
26
|
+
pexStoreRemoveDefinition: this.pexStoreRemoveDefinition.bind(this),
|
|
27
|
+
pexStoreClearDefinitions: this.pexStoreClearDefinitions.bind(this),
|
|
28
|
+
pexDefinitionVersion: this.pexDefinitionVersion.bind(this),
|
|
29
|
+
pexDefinitionFilterCredentials: this.pexDefinitionFilterCredentials.bind(this),
|
|
30
|
+
pexDefinitionFilterCredentialsPerInputDescriptor: this.pexDefinitionFilterCredentialsPerInputDescriptor.bind(this),
|
|
31
|
+
};
|
|
32
|
+
this.defaultStore = (_a = opts === null || opts === void 0 ? void 0 : opts.defaultStore) !== null && _a !== void 0 ? _a : '_default';
|
|
33
|
+
this.defaultNamespace = (_b = opts === null || opts === void 0 ? void 0 : opts.defaultNamespace) !== null && _b !== void 0 ? _b : 'pex';
|
|
34
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.stores) && opts.stores instanceof Map) {
|
|
35
|
+
this._stores = opts.stores;
|
|
36
|
+
}
|
|
37
|
+
else if (opts === null || opts === void 0 ? void 0 : opts.stores) {
|
|
38
|
+
this._stores = new Map().set(this.defaultStore, opts.stores);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this._stores = new Map().set(this.defaultStore, new ssi_sdk_kv_store_temp_1.KeyValueStore({
|
|
42
|
+
namespace: this.defaultNamespace,
|
|
43
|
+
store: new Map(),
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
if (opts && Array.isArray(opts === null || opts === void 0 ? void 0 : opts.importDefinitions)) {
|
|
47
|
+
opts.importDefinitions.forEach(this.pexStorePersistDefinition);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
pexStoreGetDefinition({ definitionId, storeId, namespace }) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return this.store({ storeId }).get(this.prefix({ namespace, definitionId }));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
pexStoreHasDefinition({ definitionId, storeId, namespace }) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return this.store({ storeId }).has(this.prefix({ namespace, definitionId }));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
pexStorePersistDefinition(args) {
|
|
61
|
+
var _a;
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const { definition, ttl, storeId, namespace } = args;
|
|
64
|
+
if ((args === null || args === void 0 ? void 0 : args.validation) !== false) {
|
|
65
|
+
let invalids = [];
|
|
66
|
+
try {
|
|
67
|
+
const result = pex_1.PEX.validateDefinition(definition); // throws an error in case the def is not valid
|
|
68
|
+
const validations = Array.isArray(result) ? result : [result];
|
|
69
|
+
invalids = validations.filter((v) => v.status === 'error');
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
invalids.push({
|
|
73
|
+
status: 'error',
|
|
74
|
+
message: typeof error === 'string'
|
|
75
|
+
? error
|
|
76
|
+
: typeof error === 'object' && 'message' in error
|
|
77
|
+
? error.message
|
|
78
|
+
: 'unknown error',
|
|
79
|
+
tag: 'validation',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (invalids.length > 0) {
|
|
83
|
+
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const definitionId = (_a = args.definitionId) !== null && _a !== void 0 ? _a : definition.id;
|
|
87
|
+
const existing = yield this.store({ storeId }).getAsValueData(this.prefix({ namespace, definitionId }));
|
|
88
|
+
if (!existing.value || (existing.value && args.overwriteExisting !== false)) {
|
|
89
|
+
return yield this.store({ storeId }).set(this.prefix({ namespace, definitionId }), definition, ttl);
|
|
90
|
+
}
|
|
91
|
+
return existing;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
pexStoreRemoveDefinition({ storeId, definitionId, namespace }) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return this.store({ storeId }).delete(this.prefix({ namespace, definitionId }));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
pexStoreClearDefinitions({ storeId }) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
return yield this.store({ storeId })
|
|
102
|
+
.clear()
|
|
103
|
+
.then(() => true);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
pexDefinitionVersion(presentationDefinition) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
return pex_1.PEX.definitionVersionDiscovery(presentationDefinition);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
pexDefinitionFilterCredentials(args, context) {
|
|
112
|
+
var _a, _b, _c, _d;
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const credentials = yield this.pexFilterCredentials((_a = args.credentialFilterOpts) !== null && _a !== void 0 ? _a : {}, context);
|
|
115
|
+
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 = new pex_1.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
|
+
return {
|
|
118
|
+
id: args.presentationDefinition.id,
|
|
119
|
+
selectResults,
|
|
120
|
+
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 : [],
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
pexDefinitionFilterCredentialsPerInputDescriptor(args, context) {
|
|
125
|
+
var _a;
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const origDefinition = args.presentationDefinition;
|
|
128
|
+
const credentials = yield this.pexFilterCredentials((_a = args.credentialFilterOpts) !== null && _a !== void 0 ? _a : {}, context);
|
|
129
|
+
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());
|
|
130
|
+
const limitDisclosureSignatureSuites = args.limitDisclosureSignatureSuites;
|
|
131
|
+
const promises = new Map();
|
|
132
|
+
origDefinition.input_descriptors.forEach((inputDescriptor) => {
|
|
133
|
+
const presentationDefinition = {
|
|
134
|
+
id: inputDescriptor.id,
|
|
135
|
+
input_descriptors: [inputDescriptor],
|
|
136
|
+
};
|
|
137
|
+
promises.set(inputDescriptor, this.pexDefinitionFilterCredentials({
|
|
138
|
+
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
139
|
+
presentationDefinition,
|
|
140
|
+
holderDIDs,
|
|
141
|
+
limitDisclosureSignatureSuites,
|
|
142
|
+
}, context));
|
|
143
|
+
});
|
|
144
|
+
yield Promise.all(promises.values());
|
|
145
|
+
const result = [];
|
|
146
|
+
for (const entry of promises.entries()) {
|
|
147
|
+
result.push(Object.assign(Object.assign({}, (yield entry[1])), { inputDescriptor: entry[0] }));
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
pexFilterCredentials(filterOpts, context) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
if ((filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.verifiableCredentials) && filterOpts.verifiableCredentials.length > 0) {
|
|
155
|
+
return filterOpts.verifiableCredentials;
|
|
156
|
+
}
|
|
157
|
+
return (yield context.agent.dataStoreORMGetVerifiableCredentials(filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.filter))
|
|
158
|
+
.map((uniqueVC) => uniqueVC.verifiableCredential)
|
|
159
|
+
.map((vc) => (vc.proof && vc.proof.type === ssi_types_1.JWT_PROOF_TYPE_2020 ? vc.proof.jwt : vc));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/*private assertIdentifier(identifier?: IIdentifier): void {
|
|
163
|
+
if (!identifier) {
|
|
164
|
+
throw Error(`OID4VP needs an identifier at this point`)
|
|
165
|
+
}
|
|
166
|
+
}*/
|
|
167
|
+
store({ storeId }) {
|
|
168
|
+
const store = this._stores.get(storeId !== null && storeId !== void 0 ? storeId : this.defaultStore);
|
|
169
|
+
if (!store) {
|
|
170
|
+
throw Error(`Could not get definition store: ${storeId !== null && storeId !== void 0 ? storeId : this.defaultStore}`);
|
|
171
|
+
}
|
|
172
|
+
return store;
|
|
173
|
+
}
|
|
174
|
+
namespace({ namespace }) {
|
|
175
|
+
return namespace !== null && namespace !== void 0 ? namespace : this.defaultStore;
|
|
176
|
+
}
|
|
177
|
+
prefix({ namespace, definitionId }) {
|
|
178
|
+
return `${this.namespace({ namespace })}:${definitionId}`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.PresentationExchange = PresentationExchange;
|
|
183
182
|
//# sourceMappingURL=Presentation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AEK,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;AApLD,oDAoLC"}
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
challenge?: string;
|
|
13
|
-
}, context: IRequiredContext): Promise<IPEXPresentationSignCallback>;
|
|
1
|
+
import { IPEXOptions, IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange';
|
|
2
|
+
import { IPresentationDefinition } from '@sphereon/pex';
|
|
3
|
+
import { Format } from '@sphereon/pex-models';
|
|
4
|
+
export declare function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined>;
|
|
5
|
+
export declare function createPEXPresentationSignCallback({ kid, fetchRemoteContexts, format, domain, challenge, }: {
|
|
6
|
+
kid: string;
|
|
7
|
+
fetchRemoteContexts?: boolean;
|
|
8
|
+
format?: Format;
|
|
9
|
+
domain?: string;
|
|
10
|
+
challenge?: string;
|
|
11
|
+
}, context: IRequiredContext): Promise<IPEXPresentationSignCallback>;
|
|
14
12
|
//# 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,
|
|
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;AAGvD,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,EACE,GAAG,EACH,mBAAmB,EACnB,MAAM,EACN,MAAM,EACN,SAAS,GACV,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,EACD,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,4BAA4B,CAAC,CA4BvC"}
|
package/dist/functions.js
CHANGED
|
@@ -1,76 +1,41 @@
|
|
|
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
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (formatOptions) {
|
|
42
|
-
if (typeof formatOptions === 'object') {
|
|
43
|
-
const formats = Object.keys(formatOptions).map((form) => (form.includes('ldp') ? 'lds' : 'jwt'));
|
|
44
|
-
if (!formats.includes('jwt')) {
|
|
45
|
-
proofFormat = 'lds';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
proofFormat = formatOptions;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
let header;
|
|
53
|
-
if (format === 'jwt') {
|
|
54
|
-
header = {
|
|
55
|
-
kid: vm.id,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
// we ignore the alg / proof_format for now, as we already have the kid anyway at this point
|
|
59
|
-
// todo: look for jwt_vc_json and remove types and @context
|
|
60
|
-
const vp = yield context.agent.createVerifiablePresentation({
|
|
61
|
-
presentation: presentation,
|
|
62
|
-
removeOriginalFields: true,
|
|
63
|
-
keyRef: key.kid,
|
|
64
|
-
domain: domain !== null && domain !== void 0 ? domain : args.domain,
|
|
65
|
-
challenge: challenge !== null && challenge !== void 0 ? challenge : args.challenge,
|
|
66
|
-
fetchRemoteContexts: args.fetchRemoteContexts !== false,
|
|
67
|
-
proofFormat,
|
|
68
|
-
header,
|
|
69
|
-
});
|
|
70
|
-
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
71
|
-
return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(vp);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
exports.createPEXPresentationSignCallback = createPEXPresentationSignCallback;
|
|
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_types_1 = require("@sphereon/ssi-types");
|
|
14
|
+
function getPresentationDefinition(pexOptions) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
return pexOptions === null || pexOptions === void 0 ? void 0 : pexOptions.definition;
|
|
17
|
+
/*const store = await getPresentationDefinitionStore(pexOptions)
|
|
18
|
+
return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.getPresentationDefinition = getPresentationDefinition;
|
|
22
|
+
function createPEXPresentationSignCallback({ kid, fetchRemoteContexts, format, domain, challenge, }, context) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return ({ presentation, domain, presentationDefinition, format, challenge, }) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const formatOptions = format !== null && format !== void 0 ? format : presentationDefinition.format;
|
|
26
|
+
const proofFormat = formatOptions && (!!formatOptions.ldp || !!formatOptions.ldp_vp) ? 'lds' : 'jwt';
|
|
27
|
+
const vp = yield context.agent.createVerifiablePresentation({
|
|
28
|
+
presentation,
|
|
29
|
+
keyRef: kid,
|
|
30
|
+
domain,
|
|
31
|
+
challenge,
|
|
32
|
+
fetchRemoteContexts: fetchRemoteContexts !== undefined ? fetchRemoteContexts : true,
|
|
33
|
+
proofFormat,
|
|
34
|
+
});
|
|
35
|
+
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
36
|
+
return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(vp);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.createPEXPresentationSignCallback = createPEXPresentationSignCallback;
|
|
76
41
|
//# 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":";;;;;;;;;;;;AAGA,mDAAiF;AAGjF,SAAsB,yBAAyB,CAAC,UAAwB;;QACtE,OAAO,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,CAAA;QAC7B;oGAC4F;IAC9F,CAAC;CAAA;AAJD,8DAIC;AAED,SAAsB,iCAAiC,CACrD,EACE,GAAG,EACH,mBAAmB,EACnB,MAAM,EACN,MAAM,EACN,SAAS,GAOV,EACD,OAAyB;;QAEzB,OAAO,CAAO,EACZ,YAAY,EACZ,MAAM,EACN,sBAAsB,EACtB,MAAM,EACN,SAAS,GAOV,EAAsC,EAAE;YACvC,MAAM,aAAa,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,sBAAsB,CAAC,MAAM,CAAA;YAC7D,MAAM,WAAW,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;YAEpG,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC;gBAC1D,YAAY;gBACZ,MAAM,EAAE,GAAG;gBACX,MAAM;gBACN,SAAS;gBACT,mBAAmB,EAAE,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI;gBACnF,WAAW;aACZ,CAAC,CAAA;YACF,2FAA2F;YAC3F,OAAO,4BAAgB,CAAC,kCAAkC,CAAC,EAA+B,CAAC,CAAA;QAC7F,CAAC,CAAA,CAAA;IACH,CAAC;CAAA;AA3CD,8EA2CC"}
|
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,76 +1,81 @@
|
|
|
1
|
-
import { FindCredentialsArgs, IAgentContext,
|
|
2
|
-
import {
|
|
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
|
|
1
|
+
import { DIDDocumentSection, FindCredentialsArgs, IAgentContext, IDataStoreORM, IDIDManager, IIdentifier, IPluginMethodMap, PresentationPayload } from '@veramo/core';
|
|
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 IIdentifierOpts {
|
|
67
|
+
identifier: IIdentifier | string;
|
|
68
|
+
verificationMethodSection?: DIDDocumentSection;
|
|
69
|
+
kid?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface VersionDiscoveryResult {
|
|
72
|
+
version?: PEVersion;
|
|
73
|
+
error?: string;
|
|
74
|
+
}
|
|
75
|
+
export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>;
|
|
76
|
+
export interface IPEXPresentationSignCallBackParams {
|
|
77
|
+
presentation: PresentationPayload;
|
|
78
|
+
presentationDefinition: IPresentationDefinition;
|
|
79
|
+
}
|
|
80
|
+
export type IRequiredContext = IAgentContext<IDataStoreORM & IDIDManager>;
|
|
76
81
|
//# 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,mBAAmB,EACnB,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"IPresentationExchange.d.ts","sourceRoot":"","sources":["../../src/types/IPresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACxF,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,uBAAuB,CAAC,CAAC,CAAA;IAErG,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEvE,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEvE,oBAAoB,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAEtG,8BAA8B,CAAC,IAAI,EAAE,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: 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.7+9cf609bb",
|
|
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": "
|
|
18
|
-
"@sphereon/pex-models": "^2.1.
|
|
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": "2.1.2",
|
|
18
|
+
"@sphereon/pex-models": "^2.1.0",
|
|
19
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-unstable.34+2f414ae",
|
|
20
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.18.2-unstable.7+9cf609bb",
|
|
21
|
+
"@sphereon/ssi-types": "0.18.2-unstable.7+9cf609bb",
|
|
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.7+9cf609bb",
|
|
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": "9cf609bb48c5dd93aa42e0f959fe56c6929fb7a2"
|
|
67
67
|
}
|
|
@@ -144,13 +144,11 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
144
144
|
id: inputDescriptor.id,
|
|
145
145
|
input_descriptors: [inputDescriptor],
|
|
146
146
|
}
|
|
147
|
-
|
|
148
147
|
promises.set(
|
|
149
148
|
inputDescriptor,
|
|
150
149
|
this.pexDefinitionFilterCredentials(
|
|
151
150
|
{
|
|
152
151
|
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
153
|
-
// @ts-ignore
|
|
154
152
|
presentationDefinition,
|
|
155
153
|
holderDIDs,
|
|
156
154
|
limitDisclosureSignatureSuites,
|
package/src/functions.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { dereferenceDidKeysWithJwkSupport, getAgentResolver, getIdentifier, getKey, IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
2
1
|
import { IPEXOptions, IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange'
|
|
3
2
|
import { IPresentationDefinition } from '@sphereon/pex'
|
|
4
|
-
import { PresentationPayload
|
|
5
|
-
import { CredentialMapper,
|
|
3
|
+
import { PresentationPayload } from '@veramo/core'
|
|
4
|
+
import { CredentialMapper, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
6
5
|
import { Format } from '@sphereon/pex-models'
|
|
7
6
|
|
|
8
7
|
export async function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined> {
|
|
9
8
|
return pexOptions?.definition
|
|
10
9
|
/*const store = await getPresentationDefinitionStore(pexOptions)
|
|
11
|
-
|
|
10
|
+
return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export async function createPEXPresentationSignCallback(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
{
|
|
15
|
+
kid,
|
|
16
|
+
fetchRemoteContexts,
|
|
17
|
+
format,
|
|
18
|
+
domain,
|
|
19
|
+
challenge,
|
|
20
|
+
}: {
|
|
21
|
+
kid: string
|
|
17
22
|
fetchRemoteContexts?: boolean
|
|
18
|
-
format?: Format
|
|
23
|
+
format?: Format
|
|
19
24
|
domain?: string
|
|
20
25
|
challenge?: string
|
|
21
26
|
},
|
|
@@ -28,59 +33,24 @@ export async function createPEXPresentationSignCallback(
|
|
|
28
33
|
format,
|
|
29
34
|
challenge,
|
|
30
35
|
}: {
|
|
31
|
-
presentation:
|
|
36
|
+
presentation: PresentationPayload
|
|
32
37
|
presentationDefinition: IPresentationDefinition
|
|
33
|
-
format?: Format
|
|
38
|
+
format?: Format
|
|
34
39
|
domain?: string
|
|
35
40
|
challenge?: string
|
|
36
41
|
}): Promise<W3CVerifiablePresentation> => {
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
if (typeof idOpts.identifier === 'string') {
|
|
40
|
-
idOpts.identifier = id
|
|
41
|
-
}
|
|
42
|
-
const key = await getKey(id, 'authentication', context, idOpts.kid)
|
|
43
|
-
const didResolution = await getAgentResolver(context).resolve(idOpts.identifier.did)
|
|
44
|
-
const vms = await dereferenceDidKeysWithJwkSupport(didResolution.didDocument!, idOpts.verificationMethodSection ?? 'authentication', context)
|
|
45
|
-
const vm = vms.find((vm) => vm.publicKeyHex === key.publicKeyHex)
|
|
46
|
-
if (!vm) {
|
|
47
|
-
throw Error(`Could not resolve DID document or match signing key to did ${idOpts.identifier.did}`)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let proofFormat: ProofFormat = 'jwt'
|
|
51
|
-
const formatOptions = format ?? args.format ?? presentationDefinition.format
|
|
52
|
-
if (formatOptions) {
|
|
53
|
-
if (typeof formatOptions === 'object') {
|
|
54
|
-
const formats = Object.keys(formatOptions).map((form) => (form.includes('ldp') ? 'lds' : 'jwt'))
|
|
55
|
-
if (!formats.includes('jwt')) {
|
|
56
|
-
proofFormat = 'lds'
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
proofFormat = formatOptions
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
let header: undefined | object
|
|
63
|
-
if (format === 'jwt') {
|
|
64
|
-
header = {
|
|
65
|
-
kid: vm.id,
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// we ignore the alg / proof_format for now, as we already have the kid anyway at this point
|
|
70
|
-
|
|
71
|
-
// todo: look for jwt_vc_json and remove types and @context
|
|
42
|
+
const formatOptions = format ?? presentationDefinition.format
|
|
43
|
+
const proofFormat = formatOptions && (!!formatOptions.ldp || !!formatOptions.ldp_vp) ? 'lds' : 'jwt'
|
|
72
44
|
|
|
73
45
|
const vp = await context.agent.createVerifiablePresentation({
|
|
74
|
-
presentation
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
fetchRemoteContexts: args.fetchRemoteContexts !== false,
|
|
46
|
+
presentation,
|
|
47
|
+
keyRef: kid,
|
|
48
|
+
domain,
|
|
49
|
+
challenge,
|
|
50
|
+
fetchRemoteContexts: fetchRemoteContexts !== undefined ? fetchRemoteContexts : true,
|
|
80
51
|
proofFormat,
|
|
81
|
-
header,
|
|
82
52
|
})
|
|
83
53
|
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
84
|
-
return CredentialMapper.storedPresentationToOriginalFormat(vp as
|
|
54
|
+
return CredentialMapper.storedPresentationToOriginalFormat(vp as W3CVerifiablePresentation)
|
|
85
55
|
}
|
|
86
56
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DIDDocumentSection,
|
|
2
3
|
FindCredentialsArgs,
|
|
3
4
|
IAgentContext,
|
|
4
|
-
ICredentialPlugin,
|
|
5
5
|
IDataStoreORM,
|
|
6
6
|
IDIDManager,
|
|
7
7
|
IIdentifier,
|
|
8
8
|
IPluginMethodMap,
|
|
9
|
-
IResolver,
|
|
10
9
|
PresentationPayload,
|
|
11
10
|
} from '@veramo/core'
|
|
12
|
-
import {
|
|
11
|
+
import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
13
12
|
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'
|
|
@@ -94,13 +93,11 @@ export interface IPEXFilterResult {
|
|
|
94
93
|
filteredCredentials: W3CVerifiableCredential[]
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
/*
|
|
98
96
|
export interface IIdentifierOpts {
|
|
99
97
|
identifier: IIdentifier | string
|
|
100
98
|
verificationMethodSection?: DIDDocumentSection
|
|
101
99
|
kid?: string
|
|
102
100
|
}
|
|
103
|
-
*/
|
|
104
101
|
|
|
105
102
|
export interface VersionDiscoveryResult {
|
|
106
103
|
version?: PEVersion
|
|
@@ -110,8 +107,8 @@ export interface VersionDiscoveryResult {
|
|
|
110
107
|
export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>
|
|
111
108
|
|
|
112
109
|
export interface IPEXPresentationSignCallBackParams {
|
|
113
|
-
presentation:
|
|
110
|
+
presentation: PresentationPayload
|
|
114
111
|
presentationDefinition: IPresentationDefinition
|
|
115
112
|
}
|
|
116
113
|
|
|
117
|
-
export type IRequiredContext = IAgentContext<IDataStoreORM &
|
|
114
|
+
export type IRequiredContext = IAgentContext<IDataStoreORM & IDIDManager>
|