@sphereon/ssi-sdk.presentation-exchange 0.18.1 → 0.18.2-unstable.10
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.js +181 -181
- package/dist/functions.d.ts +11 -11
- package/dist/functions.js +40 -40
- package/dist/index.d.ts +8 -8
- package/dist/index.js +26 -26
- package/dist/types/IPresentationExchange.d.ts +80 -80
- package/dist/types/IPresentationExchange.js +2 -2
- package/package.json +6 -6
|
@@ -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,182 +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
|
-
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;
|
|
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;
|
|
182
182
|
//# sourceMappingURL=PresentationExchange.js.map
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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>;
|
|
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>;
|
|
12
12
|
//# sourceMappingURL=functions.d.ts.map
|
package/dist/functions.js
CHANGED
|
@@ -1,41 +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 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;
|
|
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;
|
|
41
41
|
//# sourceMappingURL=functions.js.map
|
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,81 @@
|
|
|
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>;
|
|
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>;
|
|
81
81
|
//# sourceMappingURL=IPresentationExchange.d.ts.map
|
|
@@ -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.
|
|
3
|
+
"version": "0.18.2-unstable.10+f2428c90",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@sphereon/pex": "2.1.2",
|
|
18
18
|
"@sphereon/pex-models": "^2.1.0",
|
|
19
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
20
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.18.
|
|
21
|
-
"@sphereon/ssi-types": "0.18.
|
|
19
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-unstable.34+2f414ae",
|
|
20
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.18.2-unstable.10+f2428c90",
|
|
21
|
+
"@sphereon/ssi-types": "0.18.2-unstable.10+f2428c90",
|
|
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.
|
|
26
|
+
"@sphereon/ssi-sdk.agent-config": "0.18.2-unstable.10+f2428c90",
|
|
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": "f2428c90a2d35170a6c8e6c732ce74add79a4ffe"
|
|
67
67
|
}
|