@sphereon/ssi-sdk.presentation-exchange 0.17.6-unstable.74 → 0.18.0
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/functions.d.ts +3 -5
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +9 -44
- package/dist/functions.js.map +1 -1
- package/dist/types/IPresentationExchange.d.ts +9 -4
- package/dist/types/IPresentationExchange.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/functions.ts +22 -52
- package/src/types/IPresentationExchange.ts +4 -7
package/dist/functions.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { 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 { ProofFormat } from '@veramo/core';
|
|
5
3
|
import { Format } from '@sphereon/pex-models';
|
|
6
4
|
export declare function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined>;
|
|
7
|
-
export declare function createPEXPresentationSignCallback(
|
|
8
|
-
|
|
5
|
+
export declare function createPEXPresentationSignCallback({ kid, fetchRemoteContexts, format, domain, challenge, }: {
|
|
6
|
+
kid: string;
|
|
9
7
|
fetchRemoteContexts?: boolean;
|
|
10
|
-
format?: Format
|
|
8
|
+
format?: Format;
|
|
11
9
|
domain?: string;
|
|
12
10
|
challenge?: string;
|
|
13
11
|
}, context: IRequiredContext): Promise<IPEXPresentationSignCallback>;
|
package/dist/functions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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
|
@@ -10,62 +10,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createPEXPresentationSignCallback = exports.getPresentationDefinition = void 0;
|
|
13
|
-
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
14
13
|
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
15
14
|
function getPresentationDefinition(pexOptions) {
|
|
16
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
16
|
return pexOptions === null || pexOptions === void 0 ? void 0 : pexOptions.definition;
|
|
18
17
|
/*const store = await getPresentationDefinitionStore(pexOptions)
|
|
19
|
-
|
|
18
|
+
return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
21
|
exports.getPresentationDefinition = getPresentationDefinition;
|
|
23
|
-
function createPEXPresentationSignCallback(
|
|
22
|
+
function createPEXPresentationSignCallback({ kid, fetchRemoteContexts, format, domain, challenge, }, context) {
|
|
24
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
24
|
return ({ presentation, domain, presentationDefinition, format, challenge, }) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const id = yield (0, ssi_sdk_ext_did_utils_1.getIdentifier)(idOpts, context);
|
|
29
|
-
if (typeof idOpts.identifier === 'string') {
|
|
30
|
-
idOpts.identifier = id;
|
|
31
|
-
}
|
|
32
|
-
const key = yield (0, ssi_sdk_ext_did_utils_1.getKey)(id, 'authentication', context, idOpts.kid);
|
|
33
|
-
const didResolution = yield (0, ssi_sdk_ext_did_utils_1.getAgentResolver)(context).resolve(idOpts.identifier.did);
|
|
34
|
-
const vms = yield (0, ssi_sdk_ext_did_utils_1.dereferenceDidKeysWithJwkSupport)(didResolution.didDocument, (_a = idOpts.verificationMethodSection) !== null && _a !== void 0 ? _a : 'authentication', context);
|
|
35
|
-
const vm = vms.find((vm) => vm.publicKeyHex === key.publicKeyHex);
|
|
36
|
-
if (!vm) {
|
|
37
|
-
throw Error(`Could not resolve DID document or match signing key to did ${idOpts.identifier.did}`);
|
|
38
|
-
}
|
|
39
|
-
let proofFormat = 'jwt';
|
|
40
|
-
const formatOptions = (_b = format !== null && format !== void 0 ? format : args.format) !== null && _b !== void 0 ? _b : presentationDefinition.format;
|
|
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
|
|
25
|
+
const formatOptions = format !== null && format !== void 0 ? format : presentationDefinition.format;
|
|
26
|
+
const proofFormat = formatOptions && (!!formatOptions.ldp || !!formatOptions.ldp_vp) ? 'lds' : 'jwt';
|
|
60
27
|
const vp = yield context.agent.createVerifiablePresentation({
|
|
61
|
-
presentation
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
fetchRemoteContexts: args.fetchRemoteContexts !== false,
|
|
28
|
+
presentation,
|
|
29
|
+
keyRef: kid,
|
|
30
|
+
domain,
|
|
31
|
+
challenge,
|
|
32
|
+
fetchRemoteContexts: fetchRemoteContexts !== undefined ? fetchRemoteContexts : true,
|
|
67
33
|
proofFormat,
|
|
68
|
-
header,
|
|
69
34
|
});
|
|
70
35
|
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
71
36
|
return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(vp);
|
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FindCredentialsArgs, IAgentContext,
|
|
2
|
-
import {
|
|
1
|
+
import { DIDDocumentSection, FindCredentialsArgs, IAgentContext, IDataStoreORM, IDIDManager, IIdentifier, IPluginMethodMap, PresentationPayload } from '@veramo/core';
|
|
2
|
+
import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
3
3
|
import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
|
|
4
4
|
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex';
|
|
5
5
|
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models';
|
|
@@ -63,14 +63,19 @@ export interface IPEXFilterResult {
|
|
|
63
63
|
selectResults: SelectResults;
|
|
64
64
|
filteredCredentials: W3CVerifiableCredential[];
|
|
65
65
|
}
|
|
66
|
+
export interface IIdentifierOpts {
|
|
67
|
+
identifier: IIdentifier | string;
|
|
68
|
+
verificationMethodSection?: DIDDocumentSection;
|
|
69
|
+
kid?: string;
|
|
70
|
+
}
|
|
66
71
|
export interface VersionDiscoveryResult {
|
|
67
72
|
version?: PEVersion;
|
|
68
73
|
error?: string;
|
|
69
74
|
}
|
|
70
75
|
export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>;
|
|
71
76
|
export interface IPEXPresentationSignCallBackParams {
|
|
72
|
-
presentation:
|
|
77
|
+
presentation: PresentationPayload;
|
|
73
78
|
presentationDefinition: IPresentationDefinition;
|
|
74
79
|
}
|
|
75
|
-
export type IRequiredContext = IAgentContext<IDataStoreORM &
|
|
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,E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B,mBAAmB,EAAE,uBAAuB,EAAE,CAAA;CAC/C;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,WAAW,GAAG,MAAM,CAAA;IAChC,yBAAyB,CAAC,EAAE,kBAAkB,CAAA;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,4BAA4B,GAAG,CAAC,IAAI,EAAE,kCAAkC,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAE3H,MAAM,WAAW,kCAAkC;IACjD,YAAY,EAAE,mBAAmB,CAAA;IACjC,sBAAsB,EAAE,uBAAuB,CAAA;CAChD;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,aAAa,GAAG,WAAW,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.presentation-exchange",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sphereon/pex": "2.
|
|
18
|
-
"@sphereon/pex-models": "^2.1.
|
|
17
|
+
"@sphereon/pex": "2.1.2",
|
|
18
|
+
"@sphereon/pex-models": "^2.1.0",
|
|
19
19
|
"@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
|
|
20
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.
|
|
21
|
-
"@sphereon/ssi-types": "0.
|
|
20
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.18.0",
|
|
21
|
+
"@sphereon/ssi-types": "0.18.0",
|
|
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.
|
|
26
|
+
"@sphereon/ssi-sdk.agent-config": "0.18.0",
|
|
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": "afad00bef1e0ce6ac1637169b2e8a3b46f287255"
|
|
67
67
|
}
|
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>
|