@sphereon/ssi-sdk.presentation-exchange 0.28.1-next.13 → 0.28.1-next.40
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.map +1 -1
- package/dist/agent/PresentationExchange.js +16 -9
- package/dist/agent/PresentationExchange.js.map +1 -1
- package/dist/types/IPresentationExchange.d.ts +7 -4
- package/dist/types/IPresentationExchange.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/agent/PresentationExchange.ts +21 -9
- package/src/types/IPresentationExchange.ts +8 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.d.ts","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAE/B,gBAAgB,EAChB,mCAAmC,EACnC,gBAAgB,EAChB,OAAO,EAEP,sBAAsB,EACvB,MAAM,UAAU,CAAA;AACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"PresentationExchange.d.ts","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAE/B,gBAAgB,EAChB,mCAAmC,EACnC,gBAAgB,EAChB,OAAO,EAEP,sBAAsB,EACvB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAW,uBAAuB,EAAO,MAAM,eAAe,CAAA;AAOrE,qBAAa,oBAAqB,YAAW,YAAY;IACvD,QAAQ,CAAC,MAAM,MAAqC;IACpD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAEhC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAKtC;gBAEW,IAAI,CAAC,EAAE,OAAO;YAEZ,qBAAqB;IA2B7B,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;YAqCnC,oBAAoB;CAsBnC"}
|
|
@@ -14,6 +14,7 @@ const index_1 = require("../index");
|
|
|
14
14
|
const pex_1 = require("@sphereon/pex");
|
|
15
15
|
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
16
16
|
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
17
|
+
const ssi_sdk_credential_store_1 = require("@sphereon/ssi-sdk.credential-store");
|
|
17
18
|
class PresentationExchange {
|
|
18
19
|
constructor(opts) {
|
|
19
20
|
this.schema = index_1.schema.IDidAuthSiopOpAuthenticator;
|
|
@@ -58,14 +59,14 @@ class PresentationExchange {
|
|
|
58
59
|
}
|
|
59
60
|
pexDefinitionFilterCredentials(args, context) {
|
|
60
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
var _a, _b, _c
|
|
62
|
-
const credentials = yield this.pexFilterCredentials(
|
|
62
|
+
var _a, _b, _c;
|
|
63
|
+
const credentials = yield this.pexFilterCredentials(args.credentialFilterOpts, context);
|
|
63
64
|
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());
|
|
64
|
-
const selectResults = this.pex.selectFrom(args.presentationDefinition, credentials !== null && credentials !== void 0 ? credentials : [], Object.assign(Object.assign({}, args), { holderDIDs, limitDisclosureSignatureSuites: (
|
|
65
|
+
const selectResults = this.pex.selectFrom(args.presentationDefinition, credentials !== null && credentials !== void 0 ? credentials : [], Object.assign(Object.assign({}, args), { holderDIDs, limitDisclosureSignatureSuites: (_a = args.limitDisclosureSignatureSuites) !== null && _a !== void 0 ? _a : ['BbsBlsSignature2020'] }));
|
|
65
66
|
return {
|
|
66
67
|
id: args.presentationDefinition.id,
|
|
67
68
|
selectResults,
|
|
68
|
-
filteredCredentials: (
|
|
69
|
+
filteredCredentials: (_c = (_b = selectResults.verifiableCredential) === null || _b === void 0 ? void 0 : _b.map((vc) => ssi_types_1.CredentialMapper.storedCredentialToOriginalFormat(vc))) !== null && _c !== void 0 ? _c : [],
|
|
69
70
|
};
|
|
70
71
|
});
|
|
71
72
|
}
|
|
@@ -82,8 +83,9 @@ class PresentationExchange {
|
|
|
82
83
|
id: inputDescriptor.id,
|
|
83
84
|
input_descriptors: [inputDescriptor],
|
|
84
85
|
};
|
|
86
|
+
const credentialRole = args.credentialFilterOpts.credentialRole;
|
|
85
87
|
promises.set(inputDescriptor, this.pexDefinitionFilterCredentials({
|
|
86
|
-
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
88
|
+
credentialFilterOpts: { credentialRole, verifiableCredentials: credentials },
|
|
87
89
|
// @ts-ignore
|
|
88
90
|
presentationDefinition,
|
|
89
91
|
holderDIDs,
|
|
@@ -100,12 +102,17 @@ class PresentationExchange {
|
|
|
100
102
|
}
|
|
101
103
|
pexFilterCredentials(filterOpts, context) {
|
|
102
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
if (
|
|
105
|
+
if (filterOpts.verifiableCredentials && filterOpts.verifiableCredentials.length > 0) {
|
|
104
106
|
return filterOpts.verifiableCredentials;
|
|
105
107
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
const filter = (0, ssi_sdk_credential_store_1.verifiableCredentialForRoleFilter)(filterOpts.credentialRole, filterOpts.filter);
|
|
109
|
+
const uniqueCredentials = yield context.agent.crsGetUniqueCredentials({ filter });
|
|
110
|
+
return uniqueCredentials.map((uniqueVC) => {
|
|
111
|
+
const vc = uniqueVC.uniformVerifiableCredential;
|
|
112
|
+
const proof = Array.isArray(vc.proof) ? vc.proof : [vc.proof];
|
|
113
|
+
const jwtProof = proof.find((p) => (p === null || p === void 0 ? void 0 : p.type) === ssi_types_1.JWT_PROOF_TYPE_2020);
|
|
114
|
+
return jwtProof ? jwtProof.jwt : vc;
|
|
115
|
+
});
|
|
109
116
|
});
|
|
110
117
|
}
|
|
111
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCASiB;AAIjB,uCAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCASiB;AAIjB,uCAAqE;AACrE,mDAAgH;AAEhH,2EAAwD;AACxD,iFAA+H;AAG/H,MAAa,oBAAoB;IAW/B,YAAY,IAAc;QAVjB,WAAM,GAAG,cAAM,CAAC,2BAA2B,CAAA;QACnC,QAAG,GAAG,IAAI,SAAG,EAAE,CAAA;QAEvB,YAAO,GAA0B;YACxC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5D,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1D,8BAA8B,EAAE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9E,gDAAgD,EAAE,IAAI,CAAC,gDAAgD,CAAC,IAAI,CAAC,IAAI,CAAC;SACnH,CAAA;IAE4B,CAAC;IAEhB,qBAAqB,CAAC,IAA6B;;YAC/D,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;YAC3B,MAAM,QAAQ,GAAc,EAAE,CAAA;YAE9B,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,SAAG,CAAC,kBAAkB,CAAC,UAAU,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gBACjE,MAAM,EAAE,GAAG,QAAQ,CAAC,2BAA4B,CAAA;gBAChD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;gBAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,+BAAmB,CAAC,CAAA;gBACnE,OAAO,QAAQ,CAAC,CAAC,CAAE,QAAQ,CAAC,GAAkB,CAAC,CAAC,CAAC,EAAE,CAAA;YACrD,CAAC,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AAzHD,oDAyHC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAgentContext, ICredentialPlugin, IDataStoreORM, IDIDManager, IIdentifier, IPluginMethodMap, IResolver, PresentationPayload } from '@veramo/core';
|
|
2
2
|
import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
3
3
|
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex';
|
|
4
4
|
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models';
|
|
5
|
+
import { ICredentialStore } from '@sphereon/ssi-sdk.credential-store';
|
|
6
|
+
import { CredentialRole, FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store';
|
|
5
7
|
export interface IPresentationExchange extends IPluginMethodMap {
|
|
6
8
|
pexValidateDefinition(args: IDefinitionValidateArgs): Promise<boolean>;
|
|
7
9
|
pexDefinitionVersion(presentationDefinition: IPresentationDefinition): Promise<VersionDiscoveryResult>;
|
|
@@ -13,9 +15,10 @@ export interface IDefinitionValidateArgs {
|
|
|
13
15
|
}
|
|
14
16
|
export interface IDefinitionCredentialFilterArgs {
|
|
15
17
|
presentationDefinition: IPresentationDefinition;
|
|
16
|
-
credentialFilterOpts
|
|
18
|
+
credentialFilterOpts: {
|
|
19
|
+
credentialRole: CredentialRole;
|
|
17
20
|
verifiableCredentials?: W3CVerifiableCredential[];
|
|
18
|
-
filter?:
|
|
21
|
+
filter?: FindDigitalCredentialArgs;
|
|
19
22
|
};
|
|
20
23
|
holderDIDs?: (string | IIdentifier)[];
|
|
21
24
|
limitDisclosureSignatureSuites?: string[];
|
|
@@ -47,5 +50,5 @@ export interface IPEXPresentationSignCallBackParams {
|
|
|
47
50
|
presentation: IPresentation | Optional<PresentationPayload, 'holder'>;
|
|
48
51
|
presentationDefinition: IPresentationDefinition;
|
|
49
52
|
}
|
|
50
|
-
export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin>;
|
|
53
|
+
export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin & ICredentialStore>;
|
|
51
54
|
//# sourceMappingURL=IPresentationExchange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPresentationExchange.d.ts","sourceRoot":"","sources":["../../src/types/IPresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"IPresentationExchange.d.ts","sourceRoot":"","sources":["../../src/types/IPresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EA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,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,mCAAoC,SAAQ,gBAAgB;IAC3E,eAAe,EAAE,iBAAiB,GAAG,iBAAiB,CAAA;CACvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,aAAa,CAAA;IAC5B,mBAAmB,EAAE,uBAAuB,EAAE,CAAA;CAC/C;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,aAAa,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAA;IACrE,sBAAsB,EAAE,uBAAuB,CAAA;CAChD;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,iBAAiB,GAAG,gBAAgB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.presentation-exchange",
|
|
3
|
-
"version": "0.28.1-next.
|
|
3
|
+
"version": "0.28.1-next.40+2397942b",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
"@sphereon/pex": "^4.0.1",
|
|
18
18
|
"@sphereon/pex-models": "^2.2.4",
|
|
19
19
|
"@sphereon/ssi-sdk-ext.did-utils": "0.23.1-next.5",
|
|
20
|
-
"@sphereon/ssi-sdk.
|
|
21
|
-
"@sphereon/ssi-
|
|
20
|
+
"@sphereon/ssi-sdk.credential-store": "0.28.1-next.40+2397942b",
|
|
21
|
+
"@sphereon/ssi-sdk.data-store": "0.28.1-next.40+2397942b",
|
|
22
|
+
"@sphereon/ssi-types": "0.28.1-next.40+2397942b",
|
|
22
23
|
"@veramo/core": "4.2.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
26
|
-
"@sphereon/ssi-sdk.agent-config": "0.28.1-next.
|
|
27
|
+
"@sphereon/ssi-sdk.agent-config": "0.28.1-next.40+2397942b",
|
|
27
28
|
"@types/json-buffer": "^3.0.2",
|
|
28
29
|
"@veramo/did-provider-key": "4.2.0",
|
|
29
30
|
"@veramo/did-resolver": "4.2.0",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"OpenID Connect",
|
|
61
62
|
"Authenticator"
|
|
62
63
|
],
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "2397942bc970efd3250bc6ee28e681f35e8342c4"
|
|
64
65
|
}
|
|
@@ -8,13 +8,15 @@ import {
|
|
|
8
8
|
schema,
|
|
9
9
|
VersionDiscoveryResult,
|
|
10
10
|
} from '../index'
|
|
11
|
-
import {
|
|
11
|
+
import { IAgentPlugin } from '@veramo/core'
|
|
12
12
|
|
|
13
13
|
import { IPresentationExchange } from '../types/IPresentationExchange'
|
|
14
14
|
import { Checked, IPresentationDefinition, PEX } from '@sphereon/pex'
|
|
15
|
-
import { CredentialMapper, JWT_PROOF_TYPE_2020, W3CVerifiableCredential } from '@sphereon/ssi-types'
|
|
15
|
+
import { CompactJWT, CredentialMapper, JWT_PROOF_TYPE_2020, W3CVerifiableCredential } from '@sphereon/ssi-types'
|
|
16
16
|
import { InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models'
|
|
17
17
|
import { toDIDs } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
18
|
+
import { CredentialRole, UniqueDigitalCredential, verifiableCredentialForRoleFilter } from '@sphereon/ssi-sdk.credential-store'
|
|
19
|
+
import { FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store'
|
|
18
20
|
|
|
19
21
|
export class PresentationExchange implements IAgentPlugin {
|
|
20
22
|
readonly schema = schema.IDidAuthSiopOpAuthenticator
|
|
@@ -61,7 +63,7 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
async pexDefinitionFilterCredentials(args: IDefinitionCredentialFilterArgs, context: IRequiredContext): Promise<IPEXFilterResult> {
|
|
64
|
-
const credentials = await this.pexFilterCredentials(args.credentialFilterOpts
|
|
66
|
+
const credentials = await this.pexFilterCredentials(args.credentialFilterOpts, context)
|
|
65
67
|
const holderDIDs = args.holderDIDs ? toDIDs(args.holderDIDs) : toDIDs(await context.agent.dataStoreORMGetIdentifiers())
|
|
66
68
|
const selectResults = this.pex.selectFrom(args.presentationDefinition, credentials ?? [], {
|
|
67
69
|
...args,
|
|
@@ -91,11 +93,13 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
91
93
|
input_descriptors: [inputDescriptor],
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
const credentialRole = args.credentialFilterOpts.credentialRole
|
|
97
|
+
|
|
94
98
|
promises.set(
|
|
95
99
|
inputDescriptor,
|
|
96
100
|
this.pexDefinitionFilterCredentials(
|
|
97
101
|
{
|
|
98
|
-
credentialFilterOpts: { verifiableCredentials: credentials },
|
|
102
|
+
credentialFilterOpts: { credentialRole, verifiableCredentials: credentials },
|
|
99
103
|
// @ts-ignore
|
|
100
104
|
presentationDefinition,
|
|
101
105
|
holderDIDs,
|
|
@@ -115,16 +119,24 @@ export class PresentationExchange implements IAgentPlugin {
|
|
|
115
119
|
|
|
116
120
|
private async pexFilterCredentials(
|
|
117
121
|
filterOpts: {
|
|
122
|
+
credentialRole: CredentialRole
|
|
118
123
|
verifiableCredentials?: W3CVerifiableCredential[]
|
|
119
|
-
filter?:
|
|
124
|
+
filter?: FindDigitalCredentialArgs
|
|
120
125
|
},
|
|
121
126
|
context: IRequiredContext,
|
|
122
127
|
): Promise<W3CVerifiableCredential[]> {
|
|
123
|
-
if (filterOpts
|
|
128
|
+
if (filterOpts.verifiableCredentials && filterOpts.verifiableCredentials.length > 0) {
|
|
124
129
|
return filterOpts.verifiableCredentials as W3CVerifiableCredential[]
|
|
125
130
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
|
|
132
|
+
const filter = verifiableCredentialForRoleFilter(filterOpts.credentialRole, filterOpts.filter)
|
|
133
|
+
const uniqueCredentials = await context.agent.crsGetUniqueCredentials({ filter })
|
|
134
|
+
|
|
135
|
+
return uniqueCredentials.map((uniqueVC: UniqueDigitalCredential) => {
|
|
136
|
+
const vc = uniqueVC.uniformVerifiableCredential!
|
|
137
|
+
const proof = Array.isArray(vc.proof) ? vc.proof : [vc.proof]
|
|
138
|
+
const jwtProof = proof.find((p) => p?.type === JWT_PROOF_TYPE_2020)
|
|
139
|
+
return jwtProof ? (jwtProof.jwt as CompactJWT) : vc
|
|
140
|
+
})
|
|
129
141
|
}
|
|
130
142
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
FindCredentialsArgs,
|
|
3
2
|
IAgentContext,
|
|
4
3
|
ICredentialPlugin,
|
|
5
4
|
IDataStoreORM,
|
|
@@ -12,6 +11,8 @@ import {
|
|
|
12
11
|
import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types'
|
|
13
12
|
import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex'
|
|
14
13
|
import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models'
|
|
14
|
+
import { ICredentialStore } from '@sphereon/ssi-sdk.credential-store'
|
|
15
|
+
import { CredentialRole, FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store'
|
|
15
16
|
|
|
16
17
|
export interface IPresentationExchange extends IPluginMethodMap {
|
|
17
18
|
pexValidateDefinition(args: IDefinitionValidateArgs): Promise<boolean>
|
|
@@ -32,7 +33,11 @@ export interface IDefinitionValidateArgs {
|
|
|
32
33
|
|
|
33
34
|
export interface IDefinitionCredentialFilterArgs {
|
|
34
35
|
presentationDefinition: IPresentationDefinition
|
|
35
|
-
credentialFilterOpts
|
|
36
|
+
credentialFilterOpts: {
|
|
37
|
+
credentialRole: CredentialRole
|
|
38
|
+
verifiableCredentials?: W3CVerifiableCredential[]
|
|
39
|
+
filter?: FindDigitalCredentialArgs
|
|
40
|
+
}
|
|
36
41
|
holderDIDs?: (string | IIdentifier)[]
|
|
37
42
|
limitDisclosureSignatureSuites?: string[]
|
|
38
43
|
restrictToFormats?: Format
|
|
@@ -72,4 +77,4 @@ export interface IPEXPresentationSignCallBackParams {
|
|
|
72
77
|
presentationDefinition: IPresentationDefinition
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin>
|
|
80
|
+
export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin & ICredentialStore>
|