@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.33.1-next.3 → 0.33.1-next.68
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/index.cjs +2451 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +559 -0
- package/dist/index.d.ts +555 -8
- package/dist/index.js +2420 -31
- package/dist/index.js.map +1 -1
- package/package.json +41 -30
- package/src/agent/DidAuthSiopOpAuthenticator.ts +13 -14
- package/src/session/OpSession.ts +13 -13
- package/dist/agent/DidAuthSiopOpAuthenticator.d.ts +0 -36
- package/dist/agent/DidAuthSiopOpAuthenticator.d.ts.map +0 -1
- package/dist/agent/DidAuthSiopOpAuthenticator.js +0 -392
- package/dist/agent/DidAuthSiopOpAuthenticator.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/link-handler/index.d.ts +0 -22
- package/dist/link-handler/index.d.ts.map +0 -1
- package/dist/link-handler/index.js +0 -57
- package/dist/link-handler/index.js.map +0 -1
- package/dist/localization/Localization.d.ts +0 -9
- package/dist/localization/Localization.d.ts.map +0 -1
- package/dist/localization/Localization.js +0 -46
- package/dist/localization/Localization.js.map +0 -1
- package/dist/localization/translations/en.json +0 -9
- package/dist/localization/translations/nl.json +0 -8
- package/dist/machine/CallbackStateListener.d.ts +0 -3
- package/dist/machine/CallbackStateListener.d.ts.map +0 -1
- package/dist/machine/CallbackStateListener.js +0 -48
- package/dist/machine/CallbackStateListener.js.map +0 -1
- package/dist/machine/Siopv2Machine.d.ts +0 -8
- package/dist/machine/Siopv2Machine.d.ts.map +0 -1
- package/dist/machine/Siopv2Machine.js +0 -364
- package/dist/machine/Siopv2Machine.js.map +0 -1
- package/dist/services/IdentifierService.d.ts +0 -3
- package/dist/services/IdentifierService.d.ts.map +0 -1
- package/dist/services/IdentifierService.js +0 -28
- package/dist/services/IdentifierService.js.map +0 -1
- package/dist/services/Siopv2MachineService.d.ts +0 -18
- package/dist/services/Siopv2MachineService.d.ts.map +0 -1
- package/dist/services/Siopv2MachineService.js +0 -299
- package/dist/services/Siopv2MachineService.js.map +0 -1
- package/dist/session/OID4VP.d.ts +0 -72
- package/dist/session/OID4VP.d.ts.map +0 -1
- package/dist/session/OID4VP.js +0 -224
- package/dist/session/OID4VP.js.map +0 -1
- package/dist/session/OpSession.d.ts +0 -39
- package/dist/session/OpSession.d.ts.map +0 -1
- package/dist/session/OpSession.js +0 -365
- package/dist/session/OpSession.js.map +0 -1
- package/dist/session/functions.d.ts +0 -37
- package/dist/session/functions.d.ts.map +0 -1
- package/dist/session/functions.js +0 -163
- package/dist/session/functions.js.map +0 -1
- package/dist/session/index.d.ts +0 -4
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js +0 -20
- package/dist/session/index.js.map +0 -1
- package/dist/types/IDidAuthSiopOpAuthenticator.d.ts +0 -120
- package/dist/types/IDidAuthSiopOpAuthenticator.d.ts.map +0 -1
- package/dist/types/IDidAuthSiopOpAuthenticator.js +0 -10
- package/dist/types/IDidAuthSiopOpAuthenticator.js.map +0 -1
- package/dist/types/error/index.d.ts +0 -8
- package/dist/types/error/index.d.ts.map +0 -1
- package/dist/types/error/index.js +0 -3
- package/dist/types/error/index.js.map +0 -1
- package/dist/types/identifier/index.d.ts +0 -53
- package/dist/types/identifier/index.d.ts.map +0 -1
- package/dist/types/identifier/index.js +0 -5
- package/dist/types/identifier/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -6
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -22
- package/dist/types/index.js.map +0 -1
- package/dist/types/machine/index.d.ts +0 -124
- package/dist/types/machine/index.d.ts.map +0 -1
- package/dist/types/machine/index.js +0 -57
- package/dist/types/machine/index.js.map +0 -1
- package/dist/types/siop-service/index.d.ts +0 -80
- package/dist/types/siop-service/index.d.ts.map +0 -1
- package/dist/types/siop-service/index.js +0 -14
- package/dist/types/siop-service/index.js.map +0 -1
- package/dist/utils/CredentialUtils.d.ts +0 -23
- package/dist/utils/CredentialUtils.d.ts.map +0 -1
- package/dist/utils/CredentialUtils.js +0 -65
- package/dist/utils/CredentialUtils.js.map +0 -1
- package/dist/utils/dcql.d.ts +0 -5
- package/dist/utils/dcql.d.ts.map +0 -1
- package/dist/utils/dcql.js +0 -37
- package/dist/utils/dcql.js.map +0 -1
|
@@ -1,299 +0,0 @@
|
|
|
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.translateCorrelationIdToName = exports.getSelectableCredentials = exports.siopSendAuthorizationResponse = exports.logger = void 0;
|
|
13
|
-
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
14
|
-
const pex_1 = require("@sphereon/pex");
|
|
15
|
-
const ssi_sdk_ext_identifier_resolution_1 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
16
|
-
const ssi_sdk_credential_store_1 = require("@sphereon/ssi-sdk.credential-store");
|
|
17
|
-
const ssi_sdk_data_store_1 = require("@sphereon/ssi-sdk.data-store");
|
|
18
|
-
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
19
|
-
const types_1 = require("../types");
|
|
20
|
-
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
21
|
-
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
22
|
-
const dcql_1 = require("dcql");
|
|
23
|
-
const dcql_2 = require("../utils/dcql");
|
|
24
|
-
const CredentialUtils_1 = require("../utils/CredentialUtils");
|
|
25
|
-
exports.logger = ssi_types_1.Loggers.DEFAULT.get(types_1.LOGGER_NAMESPACE);
|
|
26
|
-
const createEbsiIdentifier = (agentContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
exports.logger.log(`No EBSI key present yet. Creating a new one...`);
|
|
28
|
-
const { result: newIdentifier, created } = yield (0, ssi_sdk_ext_did_utils_1.getOrCreatePrimaryIdentifier)(agentContext, {
|
|
29
|
-
method: ssi_sdk_ext_did_utils_1.SupportedDidMethodEnum.DID_KEY,
|
|
30
|
-
createOpts: { options: { codecName: 'jwk_jcs-pub', type: 'Secp256r1' } },
|
|
31
|
-
});
|
|
32
|
-
exports.logger.log(`EBSI key created: ${newIdentifier.did}`);
|
|
33
|
-
if (created) {
|
|
34
|
-
yield agentContext.agent.emit(types_1.Siopv2HolderEvent.IDENTIFIER_CREATED, { result: newIdentifier });
|
|
35
|
-
}
|
|
36
|
-
return yield agentContext.agent.identifierManagedGetByDid({ identifier: newIdentifier.did });
|
|
37
|
-
});
|
|
38
|
-
const hasEbsiClient = (authorizationRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
const clientId = yield authorizationRequest.getMergedProperty('client_id');
|
|
40
|
-
const redirectUri = yield authorizationRequest.getMergedProperty('redirect_uri');
|
|
41
|
-
return (clientId === null || clientId === void 0 ? void 0 : clientId.toLowerCase().includes('.ebsi.eu')) || (redirectUri === null || redirectUri === void 0 ? void 0 : redirectUri.toLowerCase().includes('.ebsi.eu'));
|
|
42
|
-
});
|
|
43
|
-
const siopSendAuthorizationResponse = (connectionType, args, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
45
|
-
const { agent } = context;
|
|
46
|
-
const agentContext = Object.assign(Object.assign({}, context), { agent: context.agent });
|
|
47
|
-
let { idOpts, isFirstParty, hasher = ssi_sdk_core_1.defaultHasher } = args;
|
|
48
|
-
if (connectionType !== ssi_sdk_data_store_1.ConnectionType.SIOPv2_OpenID4VP) {
|
|
49
|
-
return Promise.reject(Error(`No supported authentication provider for type: ${connectionType}`));
|
|
50
|
-
}
|
|
51
|
-
const session = yield agent.siopGetOPSession({ sessionId: args.sessionId });
|
|
52
|
-
const request = yield session.getAuthorizationRequest();
|
|
53
|
-
const aud = yield request.authorizationRequest.getMergedProperty('aud');
|
|
54
|
-
exports.logger.debug(`AUD: ${aud}`);
|
|
55
|
-
exports.logger.debug(JSON.stringify(request.authorizationRequest));
|
|
56
|
-
let presentationsAndDefs;
|
|
57
|
-
let presentationSubmission;
|
|
58
|
-
if (yield session.hasPresentationDefinitions()) {
|
|
59
|
-
const oid4vp = yield session.getOID4VP({ hasher });
|
|
60
|
-
const credentialsAndDefinitions = args.verifiableCredentialsWithDefinition
|
|
61
|
-
? args.verifiableCredentialsWithDefinition
|
|
62
|
-
: yield oid4vp.filterCredentialsAgainstAllDefinitions(ssi_sdk_data_store_1.CredentialRole.HOLDER);
|
|
63
|
-
const domain = (_b = (_a = (yield request.authorizationRequest.getMergedProperty('client_id'))) !== null && _a !== void 0 ? _a : request.issuer) !== null && _b !== void 0 ? _b : (request.versions.includes(did_auth_siop_1.SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1)
|
|
64
|
-
? 'https://self-issued.me/v2/openid-vc'
|
|
65
|
-
: 'https://self-issued.me/v2');
|
|
66
|
-
exports.logger.log(`NONCE: ${session.nonce}, domain: ${domain}`);
|
|
67
|
-
const firstUniqueDC = credentialsAndDefinitions[0].credentials[0];
|
|
68
|
-
if (typeof firstUniqueDC !== 'object' || !('digitalCredential' in firstUniqueDC)) {
|
|
69
|
-
return Promise.reject(Error('SiopMachine only supports UniqueDigitalCredentials for now'));
|
|
70
|
-
}
|
|
71
|
-
let identifier;
|
|
72
|
-
const digitalCredential = firstUniqueDC.digitalCredential;
|
|
73
|
-
const firstVC = firstUniqueDC.uniformVerifiableCredential;
|
|
74
|
-
const holder = ssi_types_1.CredentialMapper.isSdJwtDecodedCredential(firstVC)
|
|
75
|
-
? ((_c = firstVC.decodedPayload.cnf) === null || _c === void 0 ? void 0 : _c.jwk)
|
|
76
|
-
? //TODO SDK-19: convert the JWK to hex and search for the appropriate key and associated DID
|
|
77
|
-
//doesn't apply to did:jwk only, as you can represent any DID key as a JWK. So whenever you encounter a JWK it doesn't mean it had to come from a did:jwk in the system. It just can always be represented as a did:jwk
|
|
78
|
-
`did:jwk:${(0, ssi_sdk_core_1.encodeJoseBlob)((_d = firstVC.decodedPayload.cnf) === null || _d === void 0 ? void 0 : _d.jwk)}#0`
|
|
79
|
-
: firstVC.decodedPayload.sub
|
|
80
|
-
: Array.isArray(firstVC.credentialSubject)
|
|
81
|
-
? firstVC.credentialSubject[0].id
|
|
82
|
-
: firstVC.credentialSubject.id;
|
|
83
|
-
if (!digitalCredential.kmsKeyRef) {
|
|
84
|
-
// In case the store does not have the kmsKeyRef lets search for the holder
|
|
85
|
-
if (!holder) {
|
|
86
|
-
return Promise.reject(`No holder found and no kmsKeyRef in DB. Cannot determine identifier to use`);
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
identifier = yield session.context.agent.identifierManagedGet({ identifier: holder });
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
exports.logger.debug(`Holder DID not found: ${holder}`);
|
|
93
|
-
throw e;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else if ((0, ssi_sdk_ext_identifier_resolution_1.isOID4VCIssuerIdentifier)(digitalCredential.kmsKeyRef)) {
|
|
97
|
-
identifier = yield session.context.agent.identifierManagedGetByOID4VCIssuer({
|
|
98
|
-
identifier: firstUniqueDC.digitalCredential.kmsKeyRef,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
switch (digitalCredential.subjectCorrelationType) {
|
|
103
|
-
case 'DID':
|
|
104
|
-
identifier = yield session.context.agent.identifierManagedGetByDid({
|
|
105
|
-
identifier: (_e = digitalCredential.subjectCorrelationId) !== null && _e !== void 0 ? _e : holder,
|
|
106
|
-
kmsKeyRef: digitalCredential.kmsKeyRef,
|
|
107
|
-
});
|
|
108
|
-
break;
|
|
109
|
-
// TODO other implementations?
|
|
110
|
-
default:
|
|
111
|
-
if (((_f = digitalCredential.subjectCorrelationId) === null || _f === void 0 ? void 0 : _f.startsWith('did:')) || (holder === null || holder === void 0 ? void 0 : holder.startsWith('did:'))) {
|
|
112
|
-
identifier = yield session.context.agent.identifierManagedGetByDid({
|
|
113
|
-
identifier: (_g = digitalCredential.subjectCorrelationId) !== null && _g !== void 0 ? _g : holder,
|
|
114
|
-
kmsKeyRef: digitalCredential.kmsKeyRef,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// Since we are using the kmsKeyRef we will find the KID regardless of the identifier. We set it for later access though
|
|
119
|
-
identifier = yield session.context.agent.identifierManagedGetByKid({
|
|
120
|
-
identifier: (_j = (_h = digitalCredential.subjectCorrelationId) !== null && _h !== void 0 ? _h : holder) !== null && _j !== void 0 ? _j : digitalCredential.kmsKeyRef,
|
|
121
|
-
kmsKeyRef: digitalCredential.kmsKeyRef,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (identifier === undefined && idOpts !== undefined && (yield hasEbsiClient(request.authorizationRequest))) {
|
|
127
|
-
identifier = yield createEbsiIdentifier(agentContext);
|
|
128
|
-
}
|
|
129
|
-
exports.logger.debug(`Identifier`, identifier);
|
|
130
|
-
// TODO Add mdoc support
|
|
131
|
-
presentationsAndDefs = yield oid4vp.createVerifiablePresentations(ssi_sdk_data_store_1.CredentialRole.HOLDER, credentialsAndDefinitions, {
|
|
132
|
-
idOpts: identifier,
|
|
133
|
-
proofOpts: {
|
|
134
|
-
nonce: session.nonce,
|
|
135
|
-
domain,
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
if (!presentationsAndDefs || presentationsAndDefs.length === 0) {
|
|
139
|
-
throw Error('No verifiable presentations could be created');
|
|
140
|
-
}
|
|
141
|
-
else if (presentationsAndDefs.length > 1) {
|
|
142
|
-
throw Error(`Only one verifiable presentation supported for now. Got ${presentationsAndDefs.length}`);
|
|
143
|
-
}
|
|
144
|
-
idOpts = presentationsAndDefs[0].idOpts;
|
|
145
|
-
presentationSubmission = presentationsAndDefs[0].presentationSubmission;
|
|
146
|
-
exports.logger.log(`Definitions and locations:`, JSON.stringify((_k = presentationsAndDefs === null || presentationsAndDefs === void 0 ? void 0 : presentationsAndDefs[0]) === null || _k === void 0 ? void 0 : _k.verifiablePresentations, null, 2));
|
|
147
|
-
exports.logger.log(`Presentation Submission:`, JSON.stringify(presentationSubmission, null, 2));
|
|
148
|
-
const mergedVerifiablePresentations = (presentationsAndDefs === null || presentationsAndDefs === void 0 ? void 0 : presentationsAndDefs.flatMap((pd) => pd.verifiablePresentations)) || [];
|
|
149
|
-
return yield session.sendAuthorizationResponse(Object.assign(Object.assign(Object.assign({}, (presentationsAndDefs && { verifiablePresentations: mergedVerifiablePresentations })), (presentationSubmission && { presentationSubmission })), {
|
|
150
|
-
// todo: Change issuer value in case we do not use identifier. Use key.meta.jwkThumbprint then
|
|
151
|
-
responseSignerOpts: idOpts, isFirstParty }));
|
|
152
|
-
}
|
|
153
|
-
else if (request.dcqlQuery) {
|
|
154
|
-
if (args.verifiableCredentialsWithDefinition !== undefined && args.verifiableCredentialsWithDefinition !== null) {
|
|
155
|
-
const vcs = args.verifiableCredentialsWithDefinition.flatMap((vcd) => vcd.credentials);
|
|
156
|
-
const domain = (_m = (_l = (yield request.authorizationRequest.getMergedProperty('client_id'))) !== null && _l !== void 0 ? _l : request.issuer) !== null && _m !== void 0 ? _m : (request.versions.includes(did_auth_siop_1.SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1)
|
|
157
|
-
? 'https://self-issued.me/v2/openid-vc'
|
|
158
|
-
: 'https://self-issued.me/v2');
|
|
159
|
-
exports.logger.debug(`NONCE: ${session.nonce}, domain: ${domain}`);
|
|
160
|
-
const firstUniqueDC = vcs[0];
|
|
161
|
-
if (typeof firstUniqueDC !== 'object' || !('digitalCredential' in firstUniqueDC)) {
|
|
162
|
-
return Promise.reject(Error('SiopMachine only supports UniqueDigitalCredentials for now'));
|
|
163
|
-
}
|
|
164
|
-
let identifier;
|
|
165
|
-
const digitalCredential = firstUniqueDC.digitalCredential;
|
|
166
|
-
const firstVC = firstUniqueDC.uniformVerifiableCredential;
|
|
167
|
-
const holder = ssi_types_1.CredentialMapper.isSdJwtDecodedCredential(firstVC)
|
|
168
|
-
? ((_o = firstVC.decodedPayload.cnf) === null || _o === void 0 ? void 0 : _o.jwk)
|
|
169
|
-
? //TODO SDK-19: convert the JWK to hex and search for the appropriate key and associated DID
|
|
170
|
-
//doesn't apply to did:jwk only, as you can represent any DID key as a JWK. So whenever you encounter a JWK it doesn't mean it had to come from a did:jwk in the system. It just can always be represented as a did:jwk
|
|
171
|
-
`did:jwk:${(0, ssi_sdk_core_1.encodeJoseBlob)((_p = firstVC.decodedPayload.cnf) === null || _p === void 0 ? void 0 : _p.jwk)}#0`
|
|
172
|
-
: firstVC.decodedPayload.sub
|
|
173
|
-
: Array.isArray(firstVC.credentialSubject)
|
|
174
|
-
? firstVC.credentialSubject[0].id
|
|
175
|
-
: firstVC.credentialSubject.id;
|
|
176
|
-
if (!digitalCredential.kmsKeyRef) {
|
|
177
|
-
// In case the store does not have the kmsKeyRef lets search for the holder
|
|
178
|
-
if (!holder) {
|
|
179
|
-
return Promise.reject(`No holder found and no kmsKeyRef in DB. Cannot determine identifier to use`);
|
|
180
|
-
}
|
|
181
|
-
try {
|
|
182
|
-
identifier = yield session.context.agent.identifierManagedGet({ identifier: holder });
|
|
183
|
-
}
|
|
184
|
-
catch (e) {
|
|
185
|
-
exports.logger.debug(`Holder DID not found: ${holder}`);
|
|
186
|
-
throw e;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
else if ((0, ssi_sdk_ext_identifier_resolution_1.isOID4VCIssuerIdentifier)(digitalCredential.kmsKeyRef)) {
|
|
190
|
-
identifier = yield session.context.agent.identifierManagedGetByOID4VCIssuer({
|
|
191
|
-
identifier: firstUniqueDC.digitalCredential.kmsKeyRef,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
switch (digitalCredential.subjectCorrelationType) {
|
|
196
|
-
case 'DID':
|
|
197
|
-
identifier = yield session.context.agent.identifierManagedGetByDid({
|
|
198
|
-
identifier: (_q = digitalCredential.subjectCorrelationId) !== null && _q !== void 0 ? _q : holder,
|
|
199
|
-
kmsKeyRef: digitalCredential.kmsKeyRef,
|
|
200
|
-
});
|
|
201
|
-
break;
|
|
202
|
-
// TODO other implementations?
|
|
203
|
-
default:
|
|
204
|
-
// Since we are using the kmsKeyRef we will find the KID regardless of the identifier. We set it for later access though
|
|
205
|
-
identifier = yield session.context.agent.identifierManagedGetByKid({
|
|
206
|
-
identifier: (_s = (_r = digitalCredential.subjectCorrelationId) !== null && _r !== void 0 ? _r : holder) !== null && _s !== void 0 ? _s : digitalCredential.kmsKeyRef,
|
|
207
|
-
kmsKeyRef: digitalCredential.kmsKeyRef,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
console.log(`Identifier`, identifier);
|
|
212
|
-
const dcqlRepresentations = [];
|
|
213
|
-
vcs.forEach((vc) => {
|
|
214
|
-
const rep = (0, dcql_2.convertToDcqlCredentials)(vc, args.hasher);
|
|
215
|
-
if (rep) {
|
|
216
|
-
dcqlRepresentations.push(rep);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
const queryResult = dcql_1.DcqlQuery.query(request.dcqlQuery, dcqlRepresentations);
|
|
220
|
-
const presentation = {};
|
|
221
|
-
for (const [key, value] of Object.entries(queryResult.credential_matches)) {
|
|
222
|
-
const allMatches = Array.isArray(value) ? value : [value];
|
|
223
|
-
allMatches.forEach((match) => {
|
|
224
|
-
if (match.success) {
|
|
225
|
-
const originalCredential = (0, CredentialUtils_1.getOriginalVerifiableCredential)(vcs[match.input_credential_index]);
|
|
226
|
-
if (!originalCredential) {
|
|
227
|
-
throw new Error(`Index ${match.input_credential_index} out of range in credentials array`);
|
|
228
|
-
}
|
|
229
|
-
presentation[key] =
|
|
230
|
-
originalCredential['compactSdJwtVc'] !== undefined ? originalCredential.compactSdJwtVc : originalCredential;
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
const response = session.sendAuthorizationResponse(Object.assign({ responseSignerOpts: identifier }, { dcqlQuery: { dcqlPresentation: dcql_1.DcqlPresentation.parse(presentation) } }));
|
|
235
|
-
exports.logger.debug(`Response: `, response);
|
|
236
|
-
return response;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
throw Error('Presentation Definition or DCQL is required');
|
|
240
|
-
});
|
|
241
|
-
exports.siopSendAuthorizationResponse = siopSendAuthorizationResponse;
|
|
242
|
-
function buildPartialPD(inputDescriptor, presentationDefinition) {
|
|
243
|
-
return Object.assign(Object.assign({}, presentationDefinition), { input_descriptors: [inputDescriptor] });
|
|
244
|
-
}
|
|
245
|
-
const getSelectableCredentials = (presentationDefinition, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
246
|
-
var _a;
|
|
247
|
-
const agentContext = Object.assign(Object.assign({}, context), { agent: context.agent });
|
|
248
|
-
const { agent } = agentContext;
|
|
249
|
-
const pex = new pex_1.PEX();
|
|
250
|
-
const uniqueVerifiableCredentials = yield agent.crsGetUniqueCredentials({
|
|
251
|
-
filter: (0, ssi_sdk_credential_store_1.verifiableCredentialForRoleFilter)(ssi_sdk_data_store_1.CredentialRole.HOLDER),
|
|
252
|
-
});
|
|
253
|
-
const credentialBranding = yield agent.ibGetCredentialBranding();
|
|
254
|
-
const selectableCredentialsMap = new Map();
|
|
255
|
-
for (const inputDescriptor of presentationDefinition.input_descriptors) {
|
|
256
|
-
const partialPD = buildPartialPD(inputDescriptor, presentationDefinition);
|
|
257
|
-
const originalCredentials = uniqueVerifiableCredentials.map((uniqueVC) => {
|
|
258
|
-
return ssi_types_1.CredentialMapper.storedCredentialToOriginalFormat(uniqueVC.originalVerifiableCredential); // ( ! is valid for verifiableCredentialForRoleFilter )
|
|
259
|
-
});
|
|
260
|
-
const selectionResults = pex.selectFrom(partialPD, originalCredentials);
|
|
261
|
-
const selectableCredentials = [];
|
|
262
|
-
for (const selectedCredential of selectionResults.verifiableCredential || []) {
|
|
263
|
-
const filteredUniqueVC = uniqueVerifiableCredentials.find((uniqueVC) => {
|
|
264
|
-
const proof = uniqueVC.uniformVerifiableCredential.proof;
|
|
265
|
-
return Array.isArray(proof) ? proof.some((proofItem) => proofItem.jwt === selectedCredential) : proof.jwt === selectedCredential;
|
|
266
|
-
});
|
|
267
|
-
if (filteredUniqueVC) {
|
|
268
|
-
const filteredCredentialBrandings = credentialBranding.filter((cb) => cb.vcHash === filteredUniqueVC.hash);
|
|
269
|
-
const issuerPartyIdentity = yield agent.cmGetContacts({
|
|
270
|
-
filter: [{ identities: { identifier: { correlationId: filteredUniqueVC.uniformVerifiableCredential.issuerDid } } }],
|
|
271
|
-
});
|
|
272
|
-
const subjectPartyIdentity = yield agent.cmGetContacts({
|
|
273
|
-
filter: [{ identities: { identifier: { correlationId: filteredUniqueVC.uniformVerifiableCredential.subjectDid } } }],
|
|
274
|
-
});
|
|
275
|
-
selectableCredentials.push({
|
|
276
|
-
credential: filteredUniqueVC,
|
|
277
|
-
credentialBranding: (_a = filteredCredentialBrandings[0]) === null || _a === void 0 ? void 0 : _a.localeBranding,
|
|
278
|
-
issuerParty: issuerPartyIdentity === null || issuerPartyIdentity === void 0 ? void 0 : issuerPartyIdentity[0],
|
|
279
|
-
subjectParty: subjectPartyIdentity === null || subjectPartyIdentity === void 0 ? void 0 : subjectPartyIdentity[0],
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
selectableCredentialsMap.set(inputDescriptor.id, selectableCredentials);
|
|
284
|
-
}
|
|
285
|
-
return selectableCredentialsMap;
|
|
286
|
-
});
|
|
287
|
-
exports.getSelectableCredentials = getSelectableCredentials;
|
|
288
|
-
const translateCorrelationIdToName = (correlationId, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
289
|
-
const { agent } = context;
|
|
290
|
-
const contacts = yield agent.cmGetContacts({
|
|
291
|
-
filter: [{ identities: { identifier: { correlationId } } }],
|
|
292
|
-
});
|
|
293
|
-
if (contacts.length === 0) {
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
296
|
-
return contacts[0].contact.displayName;
|
|
297
|
-
});
|
|
298
|
-
exports.translateCorrelationIdToName = translateCorrelationIdToName;
|
|
299
|
-
//# sourceMappingURL=Siopv2MachineService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Siopv2MachineService.js","sourceRoot":"","sources":["../../src/services/Siopv2MachineService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAgF;AAChF,uCAA4D;AAE5D,mGAAqH;AACrH,iFAA+G;AAC/G,qEAA6E;AAC7E,mDAAiI;AAEjI,oCAUiB;AAEjB,2EAAsG;AACtG,yDAAsE;AACtE,+BAA8F;AAC9F,wCAAwD;AACxD,8DAA0E;AAE7D,QAAA,MAAM,GAAG,mBAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAgB,CAAC,CAAA;AAE3D,MAAM,oBAAoB,GAAG,CAAO,YAAwC,EAA0C,EAAE;IACtH,cAAM,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAA;IAC5D,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,oDAA4B,EAAC,YAAY,EAAE;QAC1F,MAAM,EAAE,8CAAsB,CAAC,OAA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oB,uBAApB,oBAAoB,CAAG,CAAC,CAAC;iBACxC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,wBAAwB,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,wBAAwB,CAAA;AACjC,CAAC,CAAA,CAAA;AAjDY,QAAA,wBAAwB,4BAiDpC;AAEM,MAAM,4BAA4B,GAAG,CAAO,aAAqB,EAAE,OAAwB,EAA+B,EAAE;IACjI,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IAEzB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC;QACzC,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;KAC5D,CAAC,CAAA;IAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAA;AACxC,CAAC,CAAA,CAAA;AAZY,QAAA,4BAA4B,gCAYxC"}
|
package/dist/session/OID4VP.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { PresentationDefinitionWithLocation } from '@sphereon/did-auth-siop';
|
|
2
|
-
import { SelectResults } from '@sphereon/pex';
|
|
3
|
-
import { Format } from '@sphereon/pex-models';
|
|
4
|
-
import { ManagedIdentifierOptsOrResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
5
|
-
import { ProofOptions } from '@sphereon/ssi-sdk.core';
|
|
6
|
-
import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store';
|
|
7
|
-
import { CredentialRole, FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store';
|
|
8
|
-
import { HasherSync, OriginalVerifiableCredential } from '@sphereon/ssi-types';
|
|
9
|
-
import { VerifiableCredentialsWithDefinition, VerifiablePresentationWithDefinition } from '../types';
|
|
10
|
-
import { OpSession } from './OpSession';
|
|
11
|
-
export declare class OID4VP {
|
|
12
|
-
private readonly session;
|
|
13
|
-
private readonly allIdentifiers;
|
|
14
|
-
private readonly hasher?;
|
|
15
|
-
private constructor();
|
|
16
|
-
static init(session: OpSession, allIdentifiers: string[], hasher?: HasherSync): Promise<OID4VP>;
|
|
17
|
-
getPresentationDefinitions(): Promise<PresentationDefinitionWithLocation[] | undefined>;
|
|
18
|
-
private getPresentationExchange;
|
|
19
|
-
createVerifiablePresentations(credentialRole: CredentialRole, credentialsWithDefinitions: VerifiableCredentialsWithDefinition[], opts?: {
|
|
20
|
-
forceNoCredentialsInVP?: boolean;
|
|
21
|
-
restrictToFormats?: Format;
|
|
22
|
-
restrictToDIDMethods?: string[];
|
|
23
|
-
proofOpts?: ProofOptions;
|
|
24
|
-
idOpts?: ManagedIdentifierOptsOrResult;
|
|
25
|
-
skipDidResolution?: boolean;
|
|
26
|
-
holderDID?: string;
|
|
27
|
-
subjectIsHolder?: boolean;
|
|
28
|
-
hasher?: HasherSync;
|
|
29
|
-
applyFilter?: boolean;
|
|
30
|
-
}): Promise<VerifiablePresentationWithDefinition[]>;
|
|
31
|
-
createVerifiablePresentation(credentialRole: CredentialRole, selectedVerifiableCredentials: VerifiableCredentialsWithDefinition, opts?: {
|
|
32
|
-
forceNoCredentialsInVP?: boolean;
|
|
33
|
-
restrictToFormats?: Format;
|
|
34
|
-
restrictToDIDMethods?: string[];
|
|
35
|
-
proofOpts?: ProofOptions;
|
|
36
|
-
idOpts?: ManagedIdentifierOptsOrResult;
|
|
37
|
-
skipDidResolution?: boolean;
|
|
38
|
-
holder?: string;
|
|
39
|
-
subjectIsHolder?: boolean;
|
|
40
|
-
applyFilter?: boolean;
|
|
41
|
-
hasher?: HasherSync;
|
|
42
|
-
}): Promise<VerifiablePresentationWithDefinition>;
|
|
43
|
-
filterCredentialsAgainstAllDefinitions(credentialRole: CredentialRole, opts?: {
|
|
44
|
-
filterOpts?: {
|
|
45
|
-
verifiableCredentials?: UniqueDigitalCredential[];
|
|
46
|
-
filter?: FindDigitalCredentialArgs;
|
|
47
|
-
};
|
|
48
|
-
holderDIDs?: string[];
|
|
49
|
-
restrictToFormats?: Format;
|
|
50
|
-
restrictToDIDMethods?: string[];
|
|
51
|
-
}): Promise<VerifiableCredentialsWithDefinition[]>;
|
|
52
|
-
filterCredentials(credentialRole: CredentialRole, presentationDefinition: PresentationDefinitionWithLocation, opts?: {
|
|
53
|
-
filterOpts?: {
|
|
54
|
-
verifiableCredentials?: (UniqueDigitalCredential | OriginalVerifiableCredential)[];
|
|
55
|
-
filter?: FindDigitalCredentialArgs;
|
|
56
|
-
};
|
|
57
|
-
holderDIDs?: string[];
|
|
58
|
-
restrictToFormats?: Format;
|
|
59
|
-
restrictToDIDMethods?: string[];
|
|
60
|
-
}): Promise<VerifiableCredentialsWithDefinition>;
|
|
61
|
-
filterCredentialsWithSelectionStatus(credentialRole: CredentialRole, presentationDefinition: PresentationDefinitionWithLocation, opts?: {
|
|
62
|
-
filterOpts?: {
|
|
63
|
-
verifiableCredentials?: OriginalVerifiableCredential[];
|
|
64
|
-
filter?: FindDigitalCredentialArgs;
|
|
65
|
-
};
|
|
66
|
-
holderDIDs?: string[];
|
|
67
|
-
restrictToFormats?: Format;
|
|
68
|
-
restrictToDIDMethods?: string[];
|
|
69
|
-
}): Promise<SelectResults>;
|
|
70
|
-
private getCredentials;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=OID4VP.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OID4VP.d.ts","sourceRoot":"","sources":["../../src/session/OID4VP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAwB,MAAM,yBAAyB,CAAA;AAClG,OAAO,EAAE,aAAa,EAAsC,MAAM,eAAe,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAA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AAM,EAAE,CAAA;QACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;QAC1B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAChC,GACA,OAAO,CAAC,mCAAmC,CAAC;IA8BlC,oCAAoC,CAC/C,cAAc,EAAE,cAAc,EAC9B,sBAAsB,EAAE,kCAAkC,EAC1D,IAAI,CAAC,EAAE;QACL,UAAU,CAAC,EAAE;YAAE,qBAAqB,CAAC,EAAE,4BAA4B,EAAE,CAAC;YAAC,MAAM,CAAC,EAAE,yBAAyB,CAAA;SAAE,CAAA;QAC3G,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;QAC1B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAChC,GACA,OAAO,CAAC,aAAa,CAAC;YAiBX,cAAc;CAoB7B"}
|
package/dist/session/OID4VP.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
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.OID4VP = void 0;
|
|
13
|
-
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
14
|
-
const pex_1 = require("@sphereon/pex");
|
|
15
|
-
const ssi_sdk_ext_identifier_resolution_1 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
16
|
-
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
17
|
-
const ssi_sdk_credential_store_1 = require("@sphereon/ssi-sdk.credential-store");
|
|
18
|
-
const types_1 = require("../types");
|
|
19
|
-
const functions_1 = require("./functions");
|
|
20
|
-
class OID4VP {
|
|
21
|
-
constructor(args) {
|
|
22
|
-
const { session, allIdentifiers, hasher = ssi_sdk_core_1.defaultHasher } = args;
|
|
23
|
-
this.session = session;
|
|
24
|
-
this.allIdentifiers = allIdentifiers !== null && allIdentifiers !== void 0 ? allIdentifiers : [];
|
|
25
|
-
this.hasher = hasher;
|
|
26
|
-
}
|
|
27
|
-
static init(session, allIdentifiers, hasher) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return new OID4VP({ session, allIdentifiers: allIdentifiers !== null && allIdentifiers !== void 0 ? allIdentifiers : (yield session.getSupportedDIDs()), hasher });
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
getPresentationDefinitions() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const definitions = yield this.session.getPresentationDefinitions();
|
|
35
|
-
if (definitions) {
|
|
36
|
-
did_auth_siop_1.PresentationExchange.assertValidPresentationDefinitionWithLocations(definitions);
|
|
37
|
-
}
|
|
38
|
-
return definitions;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
getPresentationExchange(args) {
|
|
42
|
-
const { verifiableCredentials, allIdentifiers, hasher } = args;
|
|
43
|
-
return new did_auth_siop_1.PresentationExchange({
|
|
44
|
-
allDIDs: allIdentifiers !== null && allIdentifiers !== void 0 ? allIdentifiers : this.allIdentifiers,
|
|
45
|
-
allVerifiableCredentials: verifiableCredentials,
|
|
46
|
-
hasher: hasher !== null && hasher !== void 0 ? hasher : this.hasher,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
createVerifiablePresentations(credentialRole, credentialsWithDefinitions, opts) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
return yield Promise.all(credentialsWithDefinitions.map((cred) => this.createVerifiablePresentation(credentialRole, cred, opts)));
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
createVerifiablePresentation(credentialRole, selectedVerifiableCredentials, opts) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
57
|
-
const { subjectIsHolder, holder, forceNoCredentialsInVP = false } = Object.assign({}, opts);
|
|
58
|
-
if (subjectIsHolder && holder) {
|
|
59
|
-
throw Error('Cannot both have subject is holder and a holderDID value at the same time (programming error)');
|
|
60
|
-
}
|
|
61
|
-
if (forceNoCredentialsInVP) {
|
|
62
|
-
selectedVerifiableCredentials.credentials = [];
|
|
63
|
-
}
|
|
64
|
-
else if (!(selectedVerifiableCredentials === null || selectedVerifiableCredentials === void 0 ? void 0 : selectedVerifiableCredentials.credentials) || selectedVerifiableCredentials.credentials.length === 0) {
|
|
65
|
-
throw Error('No verifiable verifiableCredentials provided for presentation definition');
|
|
66
|
-
}
|
|
67
|
-
const proofOptions = Object.assign(Object.assign({}, opts === null || opts === void 0 ? void 0 : opts.proofOpts), { challenge: (_d = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.proofOpts) === null || _a === void 0 ? void 0 : _a.nonce) !== null && _b !== void 0 ? _b : (_c = opts === null || opts === void 0 ? void 0 : opts.proofOpts) === null || _c === void 0 ? void 0 : _c.challenge) !== null && _d !== void 0 ? _d : this.session.nonce, domain: (_f = (_e = opts === null || opts === void 0 ? void 0 : opts.proofOpts) === null || _e === void 0 ? void 0 : _e.domain) !== null && _f !== void 0 ? _f : (yield this.session.getRedirectUri()) });
|
|
68
|
-
let idOpts = opts === null || opts === void 0 ? void 0 : opts.idOpts;
|
|
69
|
-
if (!idOpts) {
|
|
70
|
-
if (opts === null || opts === void 0 ? void 0 : opts.subjectIsHolder) {
|
|
71
|
-
if (forceNoCredentialsInVP) {
|
|
72
|
-
return Promise.reject(Error(`Cannot have subject is holder, when force no credentials is being used, as we could never determine the holder then. Please provide holderDID`));
|
|
73
|
-
}
|
|
74
|
-
const firstUniqueDC = selectedVerifiableCredentials.credentials[0];
|
|
75
|
-
// const firstVC = firstUniqueDC.uniformVerifiableCredential!
|
|
76
|
-
if (typeof firstUniqueDC !== 'object' || !('digitalCredential' in firstUniqueDC)) {
|
|
77
|
-
return Promise.reject(Error('If no opts provided, credentials should be of type UniqueDigitalCredential'));
|
|
78
|
-
}
|
|
79
|
-
idOpts = (0, ssi_sdk_ext_identifier_resolution_1.isOID4VCIssuerIdentifier)(firstUniqueDC.digitalCredential.kmsKeyRef)
|
|
80
|
-
? yield this.session.context.agent.identifierManagedGetByIssuer({
|
|
81
|
-
identifier: firstUniqueDC.digitalCredential.kmsKeyRef,
|
|
82
|
-
})
|
|
83
|
-
: yield this.session.context.agent.identifierManagedGetByKid({
|
|
84
|
-
identifier: firstUniqueDC.digitalCredential.kmsKeyRef,
|
|
85
|
-
kmsKeyRef: firstUniqueDC.digitalCredential.kmsKeyRef,
|
|
86
|
-
});
|
|
87
|
-
/*
|
|
88
|
-
const holder = CredentialMapper.isSdJwtDecodedCredential(firstVC)
|
|
89
|
-
? firstVC.decodedPayload.cnf?.jwk
|
|
90
|
-
? //TODO SDK-19: convert the JWK to hex and search for the appropriate key and associated DID
|
|
91
|
-
//doesn't apply to did:jwk only, as you can represent any DID key as a JWK. So whenever you encounter a JWK it doesn't mean it had to come from a did:jwk in the system. It just can always be represented as a did:jwk
|
|
92
|
-
`did:jwk:${encodeJoseBlob(firstVC.decodedPayload.cnf?.jwk)}#0`
|
|
93
|
-
: firstVC.decodedPayload.sub
|
|
94
|
-
: Array.isArray(firstVC.credentialSubject)
|
|
95
|
-
? firstVC.credentialSubject[0].id
|
|
96
|
-
: firstVC.credentialSubject.id
|
|
97
|
-
if (holder) {
|
|
98
|
-
idOpts = { identifier: holder }
|
|
99
|
-
}
|
|
100
|
-
*/
|
|
101
|
-
}
|
|
102
|
-
else if (opts === null || opts === void 0 ? void 0 : opts.holder) {
|
|
103
|
-
idOpts = { identifier: opts.holder };
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// We are making sure to filter, in case the user submitted all verifiableCredentials in the wallet/agent. We also make sure to get original formats back
|
|
107
|
-
const vcs = forceNoCredentialsInVP
|
|
108
|
-
? selectedVerifiableCredentials
|
|
109
|
-
: (opts === null || opts === void 0 ? void 0 : opts.applyFilter)
|
|
110
|
-
? yield this.filterCredentials(credentialRole, selectedVerifiableCredentials.definition, {
|
|
111
|
-
restrictToFormats: opts === null || opts === void 0 ? void 0 : opts.restrictToFormats,
|
|
112
|
-
restrictToDIDMethods: opts === null || opts === void 0 ? void 0 : opts.restrictToDIDMethods,
|
|
113
|
-
filterOpts: {
|
|
114
|
-
verifiableCredentials: selectedVerifiableCredentials.credentials,
|
|
115
|
-
},
|
|
116
|
-
})
|
|
117
|
-
: {
|
|
118
|
-
definition: selectedVerifiableCredentials.definition,
|
|
119
|
-
credentials: selectedVerifiableCredentials.credentials,
|
|
120
|
-
};
|
|
121
|
-
if (!idOpts) {
|
|
122
|
-
return Promise.reject(Error(`No identifier options present at this point`));
|
|
123
|
-
}
|
|
124
|
-
const signCallback = yield (0, functions_1.createOID4VPPresentationSignCallback)({
|
|
125
|
-
presentationSignCallback: this.session.options.presentationSignCallback,
|
|
126
|
-
idOpts,
|
|
127
|
-
context: this.session.context,
|
|
128
|
-
domain: proofOptions.domain,
|
|
129
|
-
challenge: proofOptions.challenge,
|
|
130
|
-
format: (_g = opts === null || opts === void 0 ? void 0 : opts.restrictToFormats) !== null && _g !== void 0 ? _g : selectedVerifiableCredentials.definition.definition.format,
|
|
131
|
-
skipDidResolution: (_h = opts === null || opts === void 0 ? void 0 : opts.skipDidResolution) !== null && _h !== void 0 ? _h : false,
|
|
132
|
-
});
|
|
133
|
-
const identifier = yield this.session.context.agent.identifierManagedGet(idOpts);
|
|
134
|
-
const verifiableCredentials = vcs.credentials.map((credential) => typeof credential === 'object' && 'digitalCredential' in credential ? credential.originalVerifiableCredential : credential);
|
|
135
|
-
const presentationResult = yield this.getPresentationExchange({
|
|
136
|
-
verifiableCredentials: verifiableCredentials,
|
|
137
|
-
allIdentifiers: this.allIdentifiers,
|
|
138
|
-
hasher: opts === null || opts === void 0 ? void 0 : opts.hasher,
|
|
139
|
-
}).createVerifiablePresentation(vcs.definition.definition, verifiableCredentials, signCallback, Object.assign({ proofOptions }, (identifier && (0, ssi_sdk_ext_identifier_resolution_1.isManagedIdentifierDidResult)(identifier) && { holderDID: identifier.did })));
|
|
140
|
-
const verifiablePresentations = presentationResult.verifiablePresentations.map((verifiablePresentation) => typeof verifiablePresentation !== 'string' &&
|
|
141
|
-
'proof' in verifiablePresentation &&
|
|
142
|
-
'jwt' in verifiablePresentation.proof &&
|
|
143
|
-
verifiablePresentation.proof.jwt
|
|
144
|
-
? verifiablePresentation.proof.jwt
|
|
145
|
-
: verifiablePresentation);
|
|
146
|
-
return Object.assign(Object.assign({}, presentationResult), { verifiablePresentations, verifiableCredentials: verifiableCredentials, definition: selectedVerifiableCredentials.definition, idOpts });
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
filterCredentialsAgainstAllDefinitions(credentialRole, opts) {
|
|
150
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
const defs = yield this.getPresentationDefinitions();
|
|
152
|
-
const result = [];
|
|
153
|
-
if (defs) {
|
|
154
|
-
for (const definition of defs) {
|
|
155
|
-
result.push(yield this.filterCredentials(credentialRole, definition, opts));
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return result;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
filterCredentials(credentialRole, presentationDefinition, opts) {
|
|
162
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
var _a, _b, _c, _d, _e;
|
|
164
|
-
const udcMap = new Map();
|
|
165
|
-
(_b = (_a = opts === null || opts === void 0 ? void 0 : opts.filterOpts) === null || _a === void 0 ? void 0 : _a.verifiableCredentials) === null || _b === void 0 ? void 0 : _b.forEach((credential) => {
|
|
166
|
-
if (typeof credential === 'object' && 'digitalCredential' in credential) {
|
|
167
|
-
udcMap.set(credential.originalVerifiableCredential, credential);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
udcMap.set(credential, credential);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
const credentials = (yield this.filterCredentialsWithSelectionStatus(credentialRole, presentationDefinition, Object.assign(Object.assign({}, opts), { filterOpts: {
|
|
174
|
-
verifiableCredentials: (_d = (_c = opts === null || opts === void 0 ? void 0 : opts.filterOpts) === null || _c === void 0 ? void 0 : _c.verifiableCredentials) === null || _d === void 0 ? void 0 : _d.map((credential) => {
|
|
175
|
-
if (typeof credential === 'object' && 'digitalCredential' in credential) {
|
|
176
|
-
return credential.originalVerifiableCredential;
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
return credential;
|
|
180
|
-
}
|
|
181
|
-
}),
|
|
182
|
-
} }))).verifiableCredential;
|
|
183
|
-
return {
|
|
184
|
-
definition: presentationDefinition,
|
|
185
|
-
credentials: (_e = credentials === null || credentials === void 0 ? void 0 : credentials.map((vc) => udcMap.get(vc))) !== null && _e !== void 0 ? _e : [],
|
|
186
|
-
};
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
filterCredentialsWithSelectionStatus(credentialRole, presentationDefinition, opts) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
const selectionResults = yield this.getPresentationExchange({
|
|
192
|
-
verifiableCredentials: yield this.getCredentials(credentialRole, opts === null || opts === void 0 ? void 0 : opts.filterOpts),
|
|
193
|
-
}).selectVerifiableCredentialsForSubmission(presentationDefinition.definition, opts);
|
|
194
|
-
if (selectionResults.errors && selectionResults.errors.length > 0) {
|
|
195
|
-
throw Error(JSON.stringify(selectionResults.errors));
|
|
196
|
-
}
|
|
197
|
-
else if (selectionResults.areRequiredCredentialsPresent === pex_1.Status.ERROR) {
|
|
198
|
-
throw Error(`Not all required credentials are available to satisfy the relying party's request`);
|
|
199
|
-
}
|
|
200
|
-
const matches = selectionResults.matches;
|
|
201
|
-
if (!matches || matches.length === 0 || !selectionResults.verifiableCredential || selectionResults.verifiableCredential.length === 0) {
|
|
202
|
-
throw Error(JSON.stringify(selectionResults.errors));
|
|
203
|
-
}
|
|
204
|
-
return selectionResults;
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
getCredentials(credentialRole, filterOpts) {
|
|
208
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
if ((filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.verifiableCredentials) && filterOpts.verifiableCredentials.length > 0) {
|
|
210
|
-
return filterOpts.verifiableCredentials;
|
|
211
|
-
}
|
|
212
|
-
const filter = (0, ssi_sdk_credential_store_1.verifiableCredentialForRoleFilter)(credentialRole, filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.filter);
|
|
213
|
-
const uniqueCredentials = yield this.session.context.agent.crsGetUniqueCredentials({ filter });
|
|
214
|
-
return uniqueCredentials.map((uniqueVC) => {
|
|
215
|
-
const vc = uniqueVC.uniformVerifiableCredential;
|
|
216
|
-
const proof = Array.isArray(vc.proof) ? vc.proof : [vc.proof];
|
|
217
|
-
const jwtProof = proof.find((p) => (p === null || p === void 0 ? void 0 : p.type) === types_1.DEFAULT_JWT_PROOF_TYPE);
|
|
218
|
-
return jwtProof ? jwtProof.jwt : vc;
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
exports.OID4VP = OID4VP;
|
|
224
|
-
//# sourceMappingURL=OID4VP.js.map
|