@sphereon/ssi-sdk.oid4vci-holder 0.34.1-next.3 → 0.34.1-next.322
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 +650 -579
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -17
- package/dist/index.d.ts +27 -17
- package/dist/index.js +628 -557
- package/dist/index.js.map +1 -1
- package/package.json +25 -24
- package/src/agent/OID4VCIHolder.ts +109 -54
- package/src/machines/firstPartyMachine.ts +1 -1
- package/src/machines/oid4vciMachine.ts +38 -6
- package/src/mappers/OIDC4VCIBrandingMapper.ts +1 -1
- package/src/services/OID4VCIHolderService.ts +47 -48
- package/src/types/FirstPartyMachine.ts +6 -5
- package/src/types/IOID4VCIHolder.ts +22 -13
package/dist/index.cjs
CHANGED
|
@@ -100,6 +100,7 @@ __export(index_exports, {
|
|
|
100
100
|
RequestType: () => RequestType,
|
|
101
101
|
SupportedLanguage: () => SupportedLanguage,
|
|
102
102
|
createConfig: () => createConfig,
|
|
103
|
+
extractCredentialFromResponse: () => extractCredentialFromResponse,
|
|
103
104
|
getBasicIssuerLocaleBranding: () => getBasicIssuerLocaleBranding,
|
|
104
105
|
getCredentialBranding: () => getCredentialBranding,
|
|
105
106
|
getCredentialConfigsBasedOnFormatPref: () => getCredentialConfigsBasedOnFormatPref,
|
|
@@ -139,9 +140,11 @@ var import_oid4vci_common4 = require("@sphereon/oid4vci-common");
|
|
|
139
140
|
var import_ssi_sdk_ext5 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
140
141
|
var import_ssi_sdk_ext6 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
141
142
|
var import_ssi_sdk_ext7 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
142
|
-
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.
|
|
143
|
+
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.core");
|
|
144
|
+
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store-types");
|
|
143
145
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
144
146
|
var import_utils2 = require("@veramo/utils");
|
|
147
|
+
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
145
148
|
var import_did_jwt = require("did-jwt");
|
|
146
149
|
var import_uuid2 = require("uuid");
|
|
147
150
|
|
|
@@ -154,18 +157,18 @@ var import_i18n_js = __toESM(require("i18n-js"), 1);
|
|
|
154
157
|
var import_lodash = __toESM(require("lodash.memoize"), 1);
|
|
155
158
|
|
|
156
159
|
// src/types/IOID4VCIHolder.ts
|
|
157
|
-
var OID4VCIHolderEvent = /* @__PURE__ */ function(OID4VCIHolderEvent2) {
|
|
160
|
+
var OID4VCIHolderEvent = /* @__PURE__ */ (function(OID4VCIHolderEvent2) {
|
|
158
161
|
OID4VCIHolderEvent2["CONTACT_IDENTITY_CREATED"] = "contact_identity_created";
|
|
159
162
|
OID4VCIHolderEvent2["CREDENTIAL_STORED"] = "credential_stored";
|
|
160
163
|
OID4VCIHolderEvent2["IDENTIFIER_CREATED"] = "identifier_created";
|
|
161
164
|
return OID4VCIHolderEvent2;
|
|
162
|
-
}({});
|
|
163
|
-
var SupportedLanguage = /* @__PURE__ */ function(SupportedLanguage2) {
|
|
165
|
+
})({});
|
|
166
|
+
var SupportedLanguage = /* @__PURE__ */ (function(SupportedLanguage2) {
|
|
164
167
|
SupportedLanguage2["ENGLISH"] = "en";
|
|
165
168
|
SupportedLanguage2["DUTCH"] = "nl";
|
|
166
169
|
return SupportedLanguage2;
|
|
167
|
-
}({});
|
|
168
|
-
var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
170
|
+
})({});
|
|
171
|
+
var OID4VCIMachineStates = /* @__PURE__ */ (function(OID4VCIMachineStates2) {
|
|
169
172
|
OID4VCIMachineStates2["start"] = "start";
|
|
170
173
|
OID4VCIMachineStates2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
171
174
|
OID4VCIMachineStates2["getContact"] = "getContact";
|
|
@@ -181,6 +184,7 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
181
184
|
OID4VCIMachineStates2["selectCredentials"] = "selectCredentials";
|
|
182
185
|
OID4VCIMachineStates2["transitionFromSelectingCredentials"] = "transitionFromSelectingCredentials";
|
|
183
186
|
OID4VCIMachineStates2["verifyPin"] = "verifyPin";
|
|
187
|
+
OID4VCIMachineStates2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
184
188
|
OID4VCIMachineStates2["initiateAuthorizationRequest"] = "initiateAuthorizationRequest";
|
|
185
189
|
OID4VCIMachineStates2["waitForAuthorizationResponse"] = "waitForAuthorizationResponse";
|
|
186
190
|
OID4VCIMachineStates2["getCredentials"] = "getCredentials";
|
|
@@ -196,18 +200,18 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
196
200
|
OID4VCIMachineStates2["error"] = "error";
|
|
197
201
|
OID4VCIMachineStates2["done"] = "done";
|
|
198
202
|
return OID4VCIMachineStates2;
|
|
199
|
-
}({});
|
|
200
|
-
var OID4VCIMachineAddContactStates = /* @__PURE__ */ function(OID4VCIMachineAddContactStates2) {
|
|
203
|
+
})({});
|
|
204
|
+
var OID4VCIMachineAddContactStates = /* @__PURE__ */ (function(OID4VCIMachineAddContactStates2) {
|
|
201
205
|
OID4VCIMachineAddContactStates2["idle"] = "idle";
|
|
202
206
|
OID4VCIMachineAddContactStates2["next"] = "next";
|
|
203
207
|
return OID4VCIMachineAddContactStates2;
|
|
204
|
-
}({});
|
|
205
|
-
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ function(OID4VCIMachineVerifyPinStates2) {
|
|
208
|
+
})({});
|
|
209
|
+
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ (function(OID4VCIMachineVerifyPinStates2) {
|
|
206
210
|
OID4VCIMachineVerifyPinStates2["idle"] = "idle";
|
|
207
211
|
OID4VCIMachineVerifyPinStates2["next"] = "next";
|
|
208
212
|
return OID4VCIMachineVerifyPinStates2;
|
|
209
|
-
}({});
|
|
210
|
-
var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
213
|
+
})({});
|
|
214
|
+
var OID4VCIMachineEvents = /* @__PURE__ */ (function(OID4VCIMachineEvents2) {
|
|
211
215
|
OID4VCIMachineEvents2["NEXT"] = "NEXT";
|
|
212
216
|
OID4VCIMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
213
217
|
OID4VCIMachineEvents2["DECLINE"] = "DECLINE";
|
|
@@ -220,14 +224,15 @@ var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
|
220
224
|
OID4VCIMachineEvents2["INVOKED_AUTHORIZATION_CODE_REQUEST"] = "INVOKED_AUTHORIZATION_CODE_REQUEST";
|
|
221
225
|
OID4VCIMachineEvents2["PROVIDE_AUTHORIZATION_CODE_RESPONSE"] = "PROVIDE_AUTHORIZATION_CODE_RESPONSE";
|
|
222
226
|
return OID4VCIMachineEvents2;
|
|
223
|
-
}({});
|
|
224
|
-
var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
227
|
+
})({});
|
|
228
|
+
var OID4VCIMachineGuards = /* @__PURE__ */ (function(OID4VCIMachineGuards2) {
|
|
225
229
|
OID4VCIMachineGuards2["hasContactGuard"] = "oid4vciHasContactGuard";
|
|
226
230
|
OID4VCIMachineGuards2["hasNoContactGuard"] = "oid4vciHasNoContactGuard";
|
|
227
231
|
OID4VCIMachineGuards2["credentialsToSelectRequiredGuard"] = "oid4vciCredentialsToSelectRequiredGuard";
|
|
228
232
|
OID4VCIMachineGuards2["requirePinGuard"] = "oid4vciRequirePinGuard";
|
|
229
233
|
OID4VCIMachineGuards2["requireAuthorizationGuard"] = "oid4vciRequireAuthorizationGuard";
|
|
230
234
|
OID4VCIMachineGuards2["noAuthorizationGuard"] = "oid4vciNoAuthorizationGuard";
|
|
235
|
+
OID4VCIMachineGuards2["hasNonceEndpointGuard"] = "oid4vciHasNonceEndpointGuard ";
|
|
231
236
|
OID4VCIMachineGuards2["hasAuthorizationResponse"] = "oid4vciHasAuthorizationResponse";
|
|
232
237
|
OID4VCIMachineGuards2["hasNoContactIdentityGuard"] = "oid4vciHasNoContactIdentityGuard";
|
|
233
238
|
OID4VCIMachineGuards2["verificationCodeGuard"] = "oid4vciVerificationCodeGuard";
|
|
@@ -237,13 +242,14 @@ var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
|
237
242
|
OID4VCIMachineGuards2["contactHasLowTrustGuard"] = "oid4vciContactHasLowTrustGuard";
|
|
238
243
|
OID4VCIMachineGuards2["isFirstPartyApplication"] = "oid4vciIsFirstPartyApplication";
|
|
239
244
|
return OID4VCIMachineGuards2;
|
|
240
|
-
}({});
|
|
241
|
-
var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
245
|
+
})({});
|
|
246
|
+
var OID4VCIMachineServices = /* @__PURE__ */ (function(OID4VCIMachineServices2) {
|
|
242
247
|
OID4VCIMachineServices2["start"] = "start";
|
|
243
248
|
OID4VCIMachineServices2["getContact"] = "getContact";
|
|
244
249
|
OID4VCIMachineServices2["getFederationTrust"] = "getFederationTrust";
|
|
245
250
|
OID4VCIMachineServices2["addContactIdentity"] = "addContactIdentity";
|
|
246
251
|
OID4VCIMachineServices2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
252
|
+
OID4VCIMachineServices2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
247
253
|
OID4VCIMachineServices2["getIssuerBranding"] = "getIssuerBranding";
|
|
248
254
|
OID4VCIMachineServices2["storeIssuerBranding"] = "storeIssuerBranding";
|
|
249
255
|
OID4VCIMachineServices2["getCredentials"] = "getCredentials";
|
|
@@ -253,17 +259,17 @@ var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
|
253
259
|
OID4VCIMachineServices2["storeCredentials"] = "storeCredentials";
|
|
254
260
|
OID4VCIMachineServices2["startFirstPartApplicationFlow"] = "startFirstPartApplicationFlow";
|
|
255
261
|
return OID4VCIMachineServices2;
|
|
256
|
-
}({});
|
|
257
|
-
var RequestType = /* @__PURE__ */ function(RequestType2) {
|
|
262
|
+
})({});
|
|
263
|
+
var RequestType = /* @__PURE__ */ (function(RequestType2) {
|
|
258
264
|
RequestType2["OPENID_INITIATE_ISSUANCE"] = "openid-initiate-issuance";
|
|
259
265
|
RequestType2["OPENID_CREDENTIAL_OFFER"] = "openid-credential-offer";
|
|
260
266
|
RequestType2["URL"] = "URL";
|
|
261
267
|
return RequestType2;
|
|
262
|
-
}({});
|
|
263
|
-
var IdentifierAliasEnum = /* @__PURE__ */ function(IdentifierAliasEnum2) {
|
|
268
|
+
})({});
|
|
269
|
+
var IdentifierAliasEnum = /* @__PURE__ */ (function(IdentifierAliasEnum2) {
|
|
264
270
|
IdentifierAliasEnum2["PRIMARY"] = "primary";
|
|
265
271
|
return IdentifierAliasEnum2;
|
|
266
|
-
}({});
|
|
272
|
+
})({});
|
|
267
273
|
|
|
268
274
|
// src/localization/Localization.ts
|
|
269
275
|
var Localization = class Localization2 {
|
|
@@ -305,7 +311,7 @@ var Localization = class Localization2 {
|
|
|
305
311
|
var translate = Localization.translate;
|
|
306
312
|
|
|
307
313
|
// src/types/FirstPartyMachine.ts
|
|
308
|
-
var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStateTypes2) {
|
|
314
|
+
var FirstPartyMachineStateTypes = /* @__PURE__ */ (function(FirstPartyMachineStateTypes2) {
|
|
309
315
|
FirstPartyMachineStateTypes2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
310
316
|
FirstPartyMachineStateTypes2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
311
317
|
FirstPartyMachineStateTypes2["selectCredentials"] = "selectCredentials";
|
|
@@ -316,21 +322,21 @@ var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStat
|
|
|
316
322
|
FirstPartyMachineStateTypes2["aborted"] = "aborted";
|
|
317
323
|
FirstPartyMachineStateTypes2["declined"] = "declined";
|
|
318
324
|
return FirstPartyMachineStateTypes2;
|
|
319
|
-
}({});
|
|
320
|
-
var FirstPartyMachineServices = /* @__PURE__ */ function(FirstPartyMachineServices2) {
|
|
325
|
+
})({});
|
|
326
|
+
var FirstPartyMachineServices = /* @__PURE__ */ (function(FirstPartyMachineServices2) {
|
|
321
327
|
FirstPartyMachineServices2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
322
328
|
FirstPartyMachineServices2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
323
329
|
FirstPartyMachineServices2["createConfig"] = "createConfig";
|
|
324
330
|
FirstPartyMachineServices2["getSiopRequest"] = "getSiopRequest";
|
|
325
331
|
return FirstPartyMachineServices2;
|
|
326
|
-
}({});
|
|
327
|
-
var FirstPartyMachineEvents = /* @__PURE__ */ function(FirstPartyMachineEvents2) {
|
|
332
|
+
})({});
|
|
333
|
+
var FirstPartyMachineEvents = /* @__PURE__ */ (function(FirstPartyMachineEvents2) {
|
|
328
334
|
FirstPartyMachineEvents2["NEXT"] = "NEXT";
|
|
329
335
|
FirstPartyMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
330
336
|
FirstPartyMachineEvents2["DECLINE"] = "DECLINE";
|
|
331
337
|
FirstPartyMachineEvents2["SET_SELECTED_CREDENTIALS"] = "SET_SELECTED_CREDENTIALS";
|
|
332
338
|
return FirstPartyMachineEvents2;
|
|
333
|
-
}({});
|
|
339
|
+
})({});
|
|
334
340
|
|
|
335
341
|
// src/machines/oid4vciMachine.ts
|
|
336
342
|
var oid4vciHasNoContactGuard = /* @__PURE__ */ __name((_ctx, _event) => {
|
|
@@ -385,9 +391,7 @@ var oid4vciRequireAuthorizationGuard = /* @__PURE__ */ __name((ctx, _event) => {
|
|
|
385
391
|
if (!openID4VCIClientState) {
|
|
386
392
|
throw Error("Missing openID4VCI client state in context");
|
|
387
393
|
}
|
|
388
|
-
if (
|
|
389
|
-
return false;
|
|
390
|
-
} else if (openID4VCIClientState.authorizationRequestOpts) {
|
|
394
|
+
if (openID4VCIClientState.authorizationURL && openID4VCIClientState.authorizationRequestOpts) {
|
|
391
395
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
392
396
|
} else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(import_oid4vci_common.AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
|
|
393
397
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
@@ -438,7 +442,6 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
438
442
|
onDone: {
|
|
439
443
|
target: OID4VCIMachineStates.createCredentialsToSelectFrom,
|
|
440
444
|
actions: (0, import_xstate.assign)({
|
|
441
|
-
authorizationCodeURL: /* @__PURE__ */ __name((_ctx, _event) => _event.data.authorizationCodeURL, "authorizationCodeURL"),
|
|
442
445
|
credentialBranding: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialBranding ?? {}, "credentialBranding"),
|
|
443
446
|
credentialsSupported: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialsSupported, "credentialsSupported"),
|
|
444
447
|
serverMetadata: /* @__PURE__ */ __name((_ctx, _event) => _event.data.serverMetadata, "serverMetadata"),
|
|
@@ -675,6 +678,10 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
675
678
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
676
679
|
cond: OID4VCIMachineGuards.isFirstPartyApplication
|
|
677
680
|
},
|
|
681
|
+
{
|
|
682
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
683
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
684
|
+
},
|
|
678
685
|
{
|
|
679
686
|
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
680
687
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
@@ -750,12 +757,16 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
750
757
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
751
758
|
cond: OID4VCIMachineGuards.isFirstPartyApplication
|
|
752
759
|
},
|
|
760
|
+
{
|
|
761
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
762
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
763
|
+
},
|
|
753
764
|
{
|
|
754
765
|
target: OID4VCIMachineStates.verifyPin,
|
|
755
766
|
cond: OID4VCIMachineGuards.requirePinGuard
|
|
756
767
|
},
|
|
757
768
|
{
|
|
758
|
-
target: OID4VCIMachineStates.
|
|
769
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
759
770
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
760
771
|
},
|
|
761
772
|
{
|
|
@@ -763,6 +774,28 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
763
774
|
}
|
|
764
775
|
]
|
|
765
776
|
},
|
|
777
|
+
[OID4VCIMachineStates.prepareAuthorizationRequest]: {
|
|
778
|
+
id: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
779
|
+
invoke: {
|
|
780
|
+
src: OID4VCIMachineServices.prepareAuthorizationRequest,
|
|
781
|
+
onDone: {
|
|
782
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
783
|
+
actions: (0, import_xstate.assign)({
|
|
784
|
+
authorizationCodeURL: /* @__PURE__ */ __name((_ctx, _event) => _event.data.authorizationCodeURL, "authorizationCodeURL")
|
|
785
|
+
})
|
|
786
|
+
},
|
|
787
|
+
onError: {
|
|
788
|
+
target: OID4VCIMachineStates.handleError,
|
|
789
|
+
actions: (0, import_xstate.assign)({
|
|
790
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
791
|
+
title: translate("oid4vci_machine_prepare_authorization_error_title"),
|
|
792
|
+
message: _event.data.message,
|
|
793
|
+
stack: _event.data.stack
|
|
794
|
+
}), "error")
|
|
795
|
+
})
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
},
|
|
766
799
|
[OID4VCIMachineStates.initiateAuthorizationRequest]: {
|
|
767
800
|
id: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
768
801
|
on: {
|
|
@@ -1060,214 +1093,405 @@ var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-resolver-jwk");
|
|
|
1060
1093
|
var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
1061
1094
|
var import_ssi_sdk_ext3 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
1062
1095
|
var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
1096
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
|
|
1063
1097
|
var import_ssi_types = require("@sphereon/ssi-types");
|
|
1064
1098
|
var import_utils = require("@veramo/utils");
|
|
1065
1099
|
|
|
1066
|
-
// src/
|
|
1067
|
-
var
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
credentialDisplay
|
|
1078
|
-
})
|
|
1079
|
-
}
|
|
1100
|
+
// src/machines/firstPartyMachine.ts
|
|
1101
|
+
var import_xstate2 = require("xstate");
|
|
1102
|
+
var import_oid4vci_common2 = require("@sphereon/oid4vci-common");
|
|
1103
|
+
|
|
1104
|
+
// src/services/FirstPartyMachineServices.ts
|
|
1105
|
+
var import_oid4vci_client = require("@sphereon/oid4vci-client");
|
|
1106
|
+
var import_uuid = require("uuid");
|
|
1107
|
+
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
1108
|
+
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
1109
|
+
const oid4vciClient = await import_oid4vci_client.OpenID4VCIClient.fromState({
|
|
1110
|
+
state: openID4VCIClientState
|
|
1080
1111
|
});
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
const localeKey = display.locale || "";
|
|
1086
|
-
localeDisplays.set(localeKey, display);
|
|
1087
|
-
return localeDisplays;
|
|
1088
|
-
}, /* @__PURE__ */ new Map());
|
|
1089
|
-
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1090
|
-
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1091
|
-
const { issuerCredentialSubject } = args;
|
|
1092
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1093
|
-
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1094
|
-
Object.entries(claim).forEach(([key, value]) => {
|
|
1095
|
-
if (key === "mandatory" || key === "value_type") {
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
if (key === "display" && Array.isArray(value)) {
|
|
1099
|
-
value.forEach(({ name, locale = "" }) => {
|
|
1100
|
-
if (!name) {
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
|
-
if (!localeClaims.has(locale)) {
|
|
1104
|
-
localeClaims.set(locale, []);
|
|
1105
|
-
}
|
|
1106
|
-
localeClaims.get(locale).push({
|
|
1107
|
-
key: parentKey,
|
|
1108
|
-
name
|
|
1109
|
-
});
|
|
1110
|
-
});
|
|
1111
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1112
|
-
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1113
|
-
}
|
|
1114
|
-
});
|
|
1115
|
-
}, "processClaimObject");
|
|
1116
|
-
processClaimObject(issuerCredentialSubject);
|
|
1117
|
-
return localeClaims;
|
|
1118
|
-
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1119
|
-
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1120
|
-
const { credentialDisplay } = args;
|
|
1121
|
-
return {
|
|
1122
|
-
...credentialDisplay.name && {
|
|
1123
|
-
alias: credentialDisplay.name
|
|
1124
|
-
},
|
|
1125
|
-
...credentialDisplay.locale && {
|
|
1126
|
-
locale: credentialDisplay.locale
|
|
1127
|
-
},
|
|
1128
|
-
...credentialDisplay.logo && {
|
|
1129
|
-
logo: {
|
|
1130
|
-
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1131
|
-
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1132
|
-
},
|
|
1133
|
-
...credentialDisplay.logo.alt_text && {
|
|
1134
|
-
alt: credentialDisplay.logo?.alt_text
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1112
|
+
return oid4vciClient.acquireAuthorizationChallengeCode({
|
|
1113
|
+
clientId: oid4vciClient.clientId ?? (0, import_uuid.v4)(),
|
|
1114
|
+
...authSession && {
|
|
1115
|
+
authSession
|
|
1137
1116
|
},
|
|
1138
|
-
|
|
1139
|
-
|
|
1117
|
+
...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
|
|
1118
|
+
issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
|
|
1140
1119
|
},
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
color: credentialDisplay.text_color
|
|
1144
|
-
}
|
|
1120
|
+
...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
|
|
1121
|
+
issuerState: openID4VCIClientState.credentialOffer?.issuerState
|
|
1145
1122
|
},
|
|
1146
|
-
...
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1123
|
+
...presentationDuringIssuanceSession && {
|
|
1124
|
+
presentationDuringIssuanceSession
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
}, "sendAuthorizationChallengeRequest");
|
|
1128
|
+
var createConfig = /* @__PURE__ */ __name(async (args, context) => {
|
|
1129
|
+
const { presentationUri } = args;
|
|
1130
|
+
if (!presentationUri) {
|
|
1131
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1132
|
+
}
|
|
1133
|
+
return context.agent.siopCreateConfig({
|
|
1134
|
+
url: presentationUri
|
|
1135
|
+
});
|
|
1136
|
+
}, "createConfig");
|
|
1137
|
+
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1138
|
+
const { didAuthConfig, presentationUri } = args;
|
|
1139
|
+
if (presentationUri === void 0) {
|
|
1140
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1141
|
+
}
|
|
1142
|
+
if (didAuthConfig === void 0) {
|
|
1143
|
+
return Promise.reject(Error("Missing did auth config in context"));
|
|
1144
|
+
}
|
|
1145
|
+
return context.agent.siopGetSiopRequest({
|
|
1146
|
+
didAuthConfig,
|
|
1147
|
+
url: presentationUri
|
|
1148
|
+
});
|
|
1149
|
+
}, "getSiopRequest");
|
|
1150
|
+
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1151
|
+
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1152
|
+
const responseData = await context.agent.siopSendResponse({
|
|
1153
|
+
authorizationRequestData,
|
|
1154
|
+
selectedCredentials,
|
|
1155
|
+
didAuthConfig,
|
|
1156
|
+
isFirstParty: true
|
|
1157
|
+
});
|
|
1158
|
+
return responseData.body.presentation_during_issuance_session;
|
|
1159
|
+
}, "sendAuthorizationResponse");
|
|
1160
|
+
|
|
1161
|
+
// src/machines/firstPartyMachine.ts
|
|
1162
|
+
var firstPartyMachineStates = {
|
|
1163
|
+
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1164
|
+
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1165
|
+
invoke: {
|
|
1166
|
+
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1167
|
+
onDone: {
|
|
1168
|
+
target: FirstPartyMachineStateTypes.done,
|
|
1169
|
+
actions: (0, import_xstate2.assign)({
|
|
1170
|
+
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1171
|
+
})
|
|
1172
|
+
},
|
|
1173
|
+
onError: [
|
|
1174
|
+
{
|
|
1175
|
+
target: FirstPartyMachineStateTypes.createConfig,
|
|
1176
|
+
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === import_oid4vci_common2.AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1177
|
+
actions: (0, import_xstate2.assign)({
|
|
1178
|
+
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1179
|
+
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1180
|
+
})
|
|
1157
1181
|
},
|
|
1158
|
-
|
|
1159
|
-
|
|
1182
|
+
{
|
|
1183
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1184
|
+
actions: (0, import_xstate2.assign)({
|
|
1185
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1186
|
+
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1187
|
+
message: _event.data.message,
|
|
1188
|
+
stack: _event.data.stack
|
|
1189
|
+
}), "error")
|
|
1190
|
+
})
|
|
1160
1191
|
}
|
|
1161
|
-
|
|
1192
|
+
]
|
|
1162
1193
|
}
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1174
|
-
return {
|
|
1175
|
-
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1176
|
-
credentialDisplay: display
|
|
1177
|
-
}),
|
|
1178
|
-
...locale.length > 0 && {
|
|
1179
|
-
locale
|
|
1194
|
+
},
|
|
1195
|
+
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1196
|
+
id: FirstPartyMachineStateTypes.createConfig,
|
|
1197
|
+
invoke: {
|
|
1198
|
+
src: FirstPartyMachineServices.createConfig,
|
|
1199
|
+
onDone: {
|
|
1200
|
+
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1201
|
+
actions: (0, import_xstate2.assign)({
|
|
1202
|
+
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1203
|
+
})
|
|
1180
1204
|
},
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1205
|
+
onError: {
|
|
1206
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1207
|
+
actions: (0, import_xstate2.assign)({
|
|
1208
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1209
|
+
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1210
|
+
message: _event.data.message,
|
|
1211
|
+
stack: _event.data.stack
|
|
1212
|
+
}), "error")
|
|
1213
|
+
})
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
},
|
|
1217
|
+
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1218
|
+
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1219
|
+
invoke: {
|
|
1220
|
+
src: FirstPartyMachineServices.getSiopRequest,
|
|
1221
|
+
onDone: {
|
|
1222
|
+
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1223
|
+
actions: (0, import_xstate2.assign)({
|
|
1224
|
+
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1225
|
+
})
|
|
1226
|
+
},
|
|
1227
|
+
onError: {
|
|
1228
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1229
|
+
actions: (0, import_xstate2.assign)({
|
|
1230
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1231
|
+
title: translate("siopV2_machine_get_request_error_title"),
|
|
1232
|
+
message: _event.data.message,
|
|
1233
|
+
stack: _event.data.stack
|
|
1234
|
+
}), "error")
|
|
1235
|
+
})
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
},
|
|
1239
|
+
[FirstPartyMachineStateTypes.selectCredentials]: {
|
|
1240
|
+
id: FirstPartyMachineStateTypes.selectCredentials,
|
|
1241
|
+
on: {
|
|
1242
|
+
[FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS]: {
|
|
1243
|
+
actions: (0, import_xstate2.assign)({
|
|
1244
|
+
selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
|
|
1245
|
+
})
|
|
1246
|
+
},
|
|
1247
|
+
[FirstPartyMachineEvents.NEXT]: {
|
|
1248
|
+
target: FirstPartyMachineStateTypes.sendAuthorizationResponse
|
|
1249
|
+
},
|
|
1250
|
+
[FirstPartyMachineEvents.DECLINE]: {
|
|
1251
|
+
target: FirstPartyMachineStateTypes.declined
|
|
1252
|
+
},
|
|
1253
|
+
[FirstPartyMachineEvents.PREVIOUS]: {
|
|
1254
|
+
target: FirstPartyMachineStateTypes.aborted
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
},
|
|
1258
|
+
[FirstPartyMachineStateTypes.sendAuthorizationResponse]: {
|
|
1259
|
+
id: FirstPartyMachineStateTypes.sendAuthorizationResponse,
|
|
1260
|
+
invoke: {
|
|
1261
|
+
src: FirstPartyMachineServices.sendAuthorizationResponse,
|
|
1262
|
+
onDone: {
|
|
1263
|
+
target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1264
|
+
actions: (0, import_xstate2.assign)({
|
|
1265
|
+
presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
|
|
1266
|
+
})
|
|
1267
|
+
},
|
|
1268
|
+
onError: {
|
|
1269
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1270
|
+
actions: (0, import_xstate2.assign)({
|
|
1271
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1272
|
+
title: translate("oid4vci_machine_get_request_error_title"),
|
|
1273
|
+
message: _event.data.message,
|
|
1274
|
+
stack: _event.data.stack
|
|
1275
|
+
}), "error")
|
|
1276
|
+
})
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
[FirstPartyMachineStateTypes.aborted]: {
|
|
1281
|
+
id: FirstPartyMachineStateTypes.aborted,
|
|
1282
|
+
type: "final"
|
|
1283
|
+
},
|
|
1284
|
+
[FirstPartyMachineStateTypes.declined]: {
|
|
1285
|
+
id: FirstPartyMachineStateTypes.declined,
|
|
1286
|
+
type: "final"
|
|
1287
|
+
},
|
|
1288
|
+
[FirstPartyMachineStateTypes.error]: {
|
|
1289
|
+
id: FirstPartyMachineStateTypes.error,
|
|
1290
|
+
type: "final"
|
|
1291
|
+
},
|
|
1292
|
+
[FirstPartyMachineStateTypes.done]: {
|
|
1293
|
+
id: FirstPartyMachineStateTypes.done,
|
|
1294
|
+
type: "final"
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
1298
|
+
const initialContext = {
|
|
1299
|
+
openID4VCIClientState: opts.openID4VCIClientState,
|
|
1300
|
+
contact: opts.contact,
|
|
1301
|
+
selectedCredentials: []
|
|
1302
|
+
};
|
|
1303
|
+
return (0, import_xstate2.createMachine)({
|
|
1304
|
+
id: opts?.machineId ?? "FirstParty",
|
|
1305
|
+
predictableActionArguments: true,
|
|
1306
|
+
initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1307
|
+
context: initialContext,
|
|
1308
|
+
states: firstPartyMachineStates,
|
|
1309
|
+
schema: {
|
|
1310
|
+
events: {},
|
|
1311
|
+
services: {}
|
|
1197
1312
|
}
|
|
1198
1313
|
});
|
|
1199
|
-
}, "
|
|
1200
|
-
var
|
|
1314
|
+
}, "createFirstPartyActivationMachine");
|
|
1315
|
+
var FirstPartyMachine = class _FirstPartyMachine {
|
|
1316
|
+
static {
|
|
1317
|
+
__name(this, "FirstPartyMachine");
|
|
1318
|
+
}
|
|
1319
|
+
static _instance;
|
|
1320
|
+
static hasInstance() {
|
|
1321
|
+
return _FirstPartyMachine._instance !== void 0;
|
|
1322
|
+
}
|
|
1323
|
+
static get instance() {
|
|
1324
|
+
if (!_FirstPartyMachine._instance) {
|
|
1325
|
+
throw Error("Please initialize ESIMActivation machine first");
|
|
1326
|
+
}
|
|
1327
|
+
return _FirstPartyMachine._instance;
|
|
1328
|
+
}
|
|
1329
|
+
static clearInstance(opts) {
|
|
1330
|
+
const { stop } = opts;
|
|
1331
|
+
if (_FirstPartyMachine.hasInstance()) {
|
|
1332
|
+
if (stop) {
|
|
1333
|
+
_FirstPartyMachine.stopInstance();
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
_FirstPartyMachine._instance = void 0;
|
|
1337
|
+
}
|
|
1338
|
+
static stopInstance() {
|
|
1339
|
+
if (!_FirstPartyMachine.hasInstance()) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
_FirstPartyMachine.instance.stop();
|
|
1343
|
+
_FirstPartyMachine._instance = void 0;
|
|
1344
|
+
}
|
|
1345
|
+
static newInstance(opts) {
|
|
1346
|
+
const { agentContext } = opts;
|
|
1347
|
+
const services = {
|
|
1348
|
+
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1349
|
+
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1350
|
+
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1351
|
+
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1352
|
+
};
|
|
1353
|
+
const newInst = (0, import_xstate2.interpret)(createFirstPartyActivationMachine(opts).withConfig({
|
|
1354
|
+
services: {
|
|
1355
|
+
...services,
|
|
1356
|
+
...opts?.services
|
|
1357
|
+
},
|
|
1358
|
+
guards: {
|
|
1359
|
+
...opts?.guards
|
|
1360
|
+
}
|
|
1361
|
+
}));
|
|
1362
|
+
if (typeof opts?.subscription === "function") {
|
|
1363
|
+
newInst.onTransition(opts.subscription);
|
|
1364
|
+
}
|
|
1365
|
+
if (opts?.requireCustomNavigationHook !== true) {
|
|
1366
|
+
newInst.onTransition((snapshot) => {
|
|
1367
|
+
if (opts?.stateNavigationListener) {
|
|
1368
|
+
void opts.stateNavigationListener(newInst, snapshot);
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
return newInst;
|
|
1373
|
+
}
|
|
1374
|
+
static getInstance(opts) {
|
|
1375
|
+
if (!_FirstPartyMachine._instance) {
|
|
1376
|
+
if (opts?.requireExisting === true) {
|
|
1377
|
+
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1378
|
+
}
|
|
1379
|
+
_FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
|
|
1380
|
+
}
|
|
1381
|
+
return _FirstPartyMachine._instance;
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
1386
|
+
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1387
|
+
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
1388
|
+
return oid4vciCombineDisplayLocalesFrom({
|
|
1389
|
+
...issuerCredentialSubject && {
|
|
1390
|
+
issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
|
|
1391
|
+
issuerCredentialSubject
|
|
1392
|
+
})
|
|
1393
|
+
},
|
|
1394
|
+
...credentialDisplay && {
|
|
1395
|
+
credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
|
|
1396
|
+
credentialDisplay
|
|
1397
|
+
})
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
}, "oid4vciGetCredentialBrandingFrom");
|
|
1401
|
+
var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1201
1402
|
const { credentialDisplay } = args;
|
|
1202
1403
|
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1203
|
-
const localeKey = display.
|
|
1404
|
+
const localeKey = display.locale || "";
|
|
1204
1405
|
localeDisplays.set(localeKey, display);
|
|
1205
1406
|
return localeDisplays;
|
|
1206
1407
|
}, /* @__PURE__ */ new Map());
|
|
1207
|
-
}, "
|
|
1208
|
-
var
|
|
1209
|
-
const {
|
|
1408
|
+
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1409
|
+
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1410
|
+
const { issuerCredentialSubject } = args;
|
|
1210
1411
|
const localeClaims = /* @__PURE__ */ new Map();
|
|
1211
|
-
|
|
1212
|
-
claim.
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1412
|
+
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1413
|
+
Object.entries(claim).forEach(([key, value]) => {
|
|
1414
|
+
if (key === "mandatory" || key === "value_type") {
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (key === "display" && Array.isArray(value)) {
|
|
1418
|
+
value.forEach(({ name, locale = "" }) => {
|
|
1419
|
+
if (!name) {
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
if (!localeClaims.has(locale)) {
|
|
1423
|
+
localeClaims.set(locale, []);
|
|
1424
|
+
}
|
|
1425
|
+
localeClaims.get(locale).push({
|
|
1426
|
+
key: parentKey,
|
|
1427
|
+
name
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
1430
|
+
} else if (typeof value === "object" && value !== null) {
|
|
1431
|
+
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1217
1432
|
}
|
|
1218
|
-
localeClaims.get(lang).push({
|
|
1219
|
-
key,
|
|
1220
|
-
name: label
|
|
1221
|
-
});
|
|
1222
1433
|
});
|
|
1223
|
-
});
|
|
1434
|
+
}, "processClaimObject");
|
|
1435
|
+
processClaimObject(issuerCredentialSubject);
|
|
1224
1436
|
return localeClaims;
|
|
1225
|
-
}, "
|
|
1226
|
-
var
|
|
1437
|
+
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1438
|
+
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1227
1439
|
const { credentialDisplay } = args;
|
|
1228
1440
|
return {
|
|
1229
1441
|
...credentialDisplay.name && {
|
|
1230
1442
|
alias: credentialDisplay.name
|
|
1231
1443
|
},
|
|
1232
|
-
...credentialDisplay.
|
|
1233
|
-
locale: credentialDisplay.
|
|
1444
|
+
...credentialDisplay.locale && {
|
|
1445
|
+
locale: credentialDisplay.locale
|
|
1234
1446
|
},
|
|
1235
|
-
...credentialDisplay.
|
|
1447
|
+
...credentialDisplay.logo && {
|
|
1236
1448
|
logo: {
|
|
1237
|
-
...credentialDisplay.
|
|
1238
|
-
uri: credentialDisplay.
|
|
1449
|
+
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1450
|
+
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1239
1451
|
},
|
|
1240
|
-
...credentialDisplay.
|
|
1241
|
-
alt: credentialDisplay.
|
|
1452
|
+
...credentialDisplay.logo.alt_text && {
|
|
1453
|
+
alt: credentialDisplay.logo?.alt_text
|
|
1242
1454
|
}
|
|
1243
1455
|
}
|
|
1244
1456
|
},
|
|
1245
1457
|
...credentialDisplay.description && {
|
|
1246
1458
|
description: credentialDisplay.description
|
|
1247
1459
|
},
|
|
1248
|
-
...credentialDisplay.
|
|
1460
|
+
...credentialDisplay.text_color && {
|
|
1249
1461
|
text: {
|
|
1250
|
-
color: credentialDisplay.
|
|
1462
|
+
color: credentialDisplay.text_color
|
|
1251
1463
|
}
|
|
1252
1464
|
},
|
|
1253
|
-
...credentialDisplay.
|
|
1465
|
+
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1254
1466
|
background: {
|
|
1255
|
-
|
|
1467
|
+
...credentialDisplay.background_image && {
|
|
1468
|
+
image: {
|
|
1469
|
+
...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
|
|
1470
|
+
uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
|
|
1471
|
+
},
|
|
1472
|
+
...credentialDisplay.background_image.alt_text && {
|
|
1473
|
+
alt: credentialDisplay.background_image?.alt_text
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
},
|
|
1477
|
+
...credentialDisplay.background_color && {
|
|
1478
|
+
color: credentialDisplay.background_color
|
|
1479
|
+
}
|
|
1256
1480
|
}
|
|
1257
1481
|
}
|
|
1258
1482
|
};
|
|
1259
|
-
}, "
|
|
1260
|
-
var
|
|
1261
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(),
|
|
1483
|
+
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1484
|
+
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1485
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1262
1486
|
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1263
|
-
...
|
|
1487
|
+
...issuerCredentialSubjectLocales.keys(),
|
|
1264
1488
|
...credentialDisplayLocales.keys()
|
|
1265
1489
|
]));
|
|
1266
1490
|
return Promise.all(locales.map(async (locale) => {
|
|
1267
1491
|
const display = credentialDisplayLocales.get(locale);
|
|
1268
|
-
const claims =
|
|
1492
|
+
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1269
1493
|
return {
|
|
1270
|
-
...display && await
|
|
1494
|
+
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1271
1495
|
credentialDisplay: display
|
|
1272
1496
|
}),
|
|
1273
1497
|
...locale.length > 0 && {
|
|
@@ -1276,348 +1500,157 @@ var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
|
1276
1500
|
claims
|
|
1277
1501
|
};
|
|
1278
1502
|
}));
|
|
1279
|
-
}, "
|
|
1280
|
-
var
|
|
1281
|
-
const {
|
|
1282
|
-
return {
|
|
1283
|
-
...
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
alias: issuerDisplay.name
|
|
1288
|
-
},
|
|
1289
|
-
...issuerDisplay.locale && {
|
|
1290
|
-
locale: issuerDisplay.locale
|
|
1291
|
-
},
|
|
1292
|
-
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1293
|
-
logo: {
|
|
1294
|
-
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1295
|
-
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1296
|
-
},
|
|
1297
|
-
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1298
|
-
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1299
|
-
},
|
|
1300
|
-
...issuerDisplay.logo?.alt_text && {
|
|
1301
|
-
alt: issuerDisplay.logo?.alt_text
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
},
|
|
1305
|
-
...issuerDisplay.description && {
|
|
1306
|
-
description: issuerDisplay.description
|
|
1307
|
-
},
|
|
1308
|
-
...issuerDisplay.text_color && {
|
|
1309
|
-
text: {
|
|
1310
|
-
color: issuerDisplay.text_color
|
|
1311
|
-
}
|
|
1312
|
-
},
|
|
1313
|
-
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1314
|
-
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1315
|
-
},
|
|
1316
|
-
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1317
|
-
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1318
|
-
},
|
|
1319
|
-
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1320
|
-
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1503
|
+
}, "oid4vciCombineDisplayLocalesFrom");
|
|
1504
|
+
var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1505
|
+
const { credentialDisplay, claimsMetadata } = args;
|
|
1506
|
+
return sdJwtCombineDisplayLocalesFrom({
|
|
1507
|
+
...claimsMetadata && {
|
|
1508
|
+
claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
|
|
1509
|
+
claimsMetadata
|
|
1510
|
+
})
|
|
1321
1511
|
},
|
|
1322
|
-
...
|
|
1323
|
-
|
|
1512
|
+
...credentialDisplay && {
|
|
1513
|
+
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1514
|
+
credentialDisplay
|
|
1515
|
+
})
|
|
1324
1516
|
}
|
|
1325
|
-
};
|
|
1326
|
-
}, "issuerLocaleBrandingFrom");
|
|
1327
|
-
|
|
1328
|
-
// src/machines/firstPartyMachine.ts
|
|
1329
|
-
var import_xstate2 = require("xstate");
|
|
1330
|
-
var import_oid4vci_common2 = require("@sphereon/oid4vci-common");
|
|
1331
|
-
|
|
1332
|
-
// src/services/FirstPartyMachineServices.ts
|
|
1333
|
-
var import_oid4vci_client = require("@sphereon/oid4vci-client");
|
|
1334
|
-
var import_uuid = require("uuid");
|
|
1335
|
-
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
1336
|
-
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
1337
|
-
const oid4vciClient = await import_oid4vci_client.OpenID4VCIClient.fromState({
|
|
1338
|
-
state: openID4VCIClientState
|
|
1339
1517
|
});
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1518
|
+
}, "sdJwtGetCredentialBrandingFrom");
|
|
1519
|
+
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1520
|
+
const { credentialDisplay } = args;
|
|
1521
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1522
|
+
const localeKey = display.lang || "";
|
|
1523
|
+
localeDisplays.set(localeKey, display);
|
|
1524
|
+
return localeDisplays;
|
|
1525
|
+
}, /* @__PURE__ */ new Map());
|
|
1526
|
+
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1527
|
+
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1528
|
+
const { claimsMetadata } = args;
|
|
1529
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
1530
|
+
claimsMetadata.forEach((claim) => {
|
|
1531
|
+
claim.display?.forEach((display) => {
|
|
1532
|
+
const { lang = "", label } = display;
|
|
1533
|
+
const key = claim.path.map((value) => String(value)).join(".");
|
|
1534
|
+
if (!localeClaims.has(lang)) {
|
|
1535
|
+
localeClaims.set(lang, []);
|
|
1536
|
+
}
|
|
1537
|
+
localeClaims.get(lang).push({
|
|
1538
|
+
key,
|
|
1539
|
+
name: label
|
|
1540
|
+
});
|
|
1541
|
+
});
|
|
1542
|
+
});
|
|
1543
|
+
return localeClaims;
|
|
1544
|
+
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1545
|
+
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1546
|
+
const { credentialDisplay } = args;
|
|
1547
|
+
return {
|
|
1548
|
+
...credentialDisplay.name && {
|
|
1549
|
+
alias: credentialDisplay.name
|
|
1347
1550
|
},
|
|
1348
|
-
|
|
1349
|
-
|
|
1551
|
+
...credentialDisplay.lang && {
|
|
1552
|
+
locale: credentialDisplay.lang
|
|
1350
1553
|
},
|
|
1351
|
-
...
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
},
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1360
|
-
}
|
|
1361
|
-
return context.agent.siopCreateConfig({
|
|
1362
|
-
url: presentationUri
|
|
1363
|
-
});
|
|
1364
|
-
}, "createConfig");
|
|
1365
|
-
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1366
|
-
const { didAuthConfig, presentationUri } = args;
|
|
1367
|
-
if (presentationUri === void 0) {
|
|
1368
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1369
|
-
}
|
|
1370
|
-
if (didAuthConfig === void 0) {
|
|
1371
|
-
return Promise.reject(Error("Missing did auth config in context"));
|
|
1372
|
-
}
|
|
1373
|
-
return context.agent.siopGetSiopRequest({
|
|
1374
|
-
didAuthConfig,
|
|
1375
|
-
url: presentationUri
|
|
1376
|
-
});
|
|
1377
|
-
}, "getSiopRequest");
|
|
1378
|
-
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1379
|
-
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1380
|
-
const responseData = await context.agent.siopSendResponse({
|
|
1381
|
-
authorizationRequestData,
|
|
1382
|
-
selectedCredentials,
|
|
1383
|
-
didAuthConfig,
|
|
1384
|
-
isFirstParty: true
|
|
1385
|
-
});
|
|
1386
|
-
return responseData.body.presentation_during_issuance_session;
|
|
1387
|
-
}, "sendAuthorizationResponse");
|
|
1388
|
-
|
|
1389
|
-
// src/machines/firstPartyMachine.ts
|
|
1390
|
-
var firstPartyMachineStates = {
|
|
1391
|
-
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1392
|
-
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1393
|
-
invoke: {
|
|
1394
|
-
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1395
|
-
onDone: {
|
|
1396
|
-
target: FirstPartyMachineStateTypes.done,
|
|
1397
|
-
actions: (0, import_xstate2.assign)({
|
|
1398
|
-
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1399
|
-
})
|
|
1400
|
-
},
|
|
1401
|
-
onError: [
|
|
1402
|
-
{
|
|
1403
|
-
target: FirstPartyMachineStateTypes.createConfig,
|
|
1404
|
-
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === import_oid4vci_common2.AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1405
|
-
actions: (0, import_xstate2.assign)({
|
|
1406
|
-
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1407
|
-
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1408
|
-
})
|
|
1409
|
-
},
|
|
1410
|
-
{
|
|
1411
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1412
|
-
actions: (0, import_xstate2.assign)({
|
|
1413
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1414
|
-
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1415
|
-
message: _event.data.message,
|
|
1416
|
-
stack: _event.data.stack
|
|
1417
|
-
}), "error")
|
|
1418
|
-
})
|
|
1419
|
-
}
|
|
1420
|
-
]
|
|
1421
|
-
}
|
|
1422
|
-
},
|
|
1423
|
-
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1424
|
-
id: FirstPartyMachineStateTypes.createConfig,
|
|
1425
|
-
invoke: {
|
|
1426
|
-
src: FirstPartyMachineServices.createConfig,
|
|
1427
|
-
onDone: {
|
|
1428
|
-
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1429
|
-
actions: (0, import_xstate2.assign)({
|
|
1430
|
-
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1431
|
-
})
|
|
1432
|
-
},
|
|
1433
|
-
onError: {
|
|
1434
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1435
|
-
actions: (0, import_xstate2.assign)({
|
|
1436
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1437
|
-
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1438
|
-
message: _event.data.message,
|
|
1439
|
-
stack: _event.data.stack
|
|
1440
|
-
}), "error")
|
|
1441
|
-
})
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
},
|
|
1445
|
-
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1446
|
-
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1447
|
-
invoke: {
|
|
1448
|
-
src: FirstPartyMachineServices.getSiopRequest,
|
|
1449
|
-
onDone: {
|
|
1450
|
-
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1451
|
-
actions: (0, import_xstate2.assign)({
|
|
1452
|
-
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1453
|
-
})
|
|
1454
|
-
},
|
|
1455
|
-
onError: {
|
|
1456
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1457
|
-
actions: (0, import_xstate2.assign)({
|
|
1458
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1459
|
-
title: translate("siopV2_machine_get_request_error_title"),
|
|
1460
|
-
message: _event.data.message,
|
|
1461
|
-
stack: _event.data.stack
|
|
1462
|
-
}), "error")
|
|
1463
|
-
})
|
|
1554
|
+
...credentialDisplay.rendering?.simple?.logo && {
|
|
1555
|
+
logo: {
|
|
1556
|
+
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1557
|
+
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1558
|
+
},
|
|
1559
|
+
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1560
|
+
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1561
|
+
}
|
|
1464
1562
|
}
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
|
|
1473
|
-
})
|
|
1474
|
-
},
|
|
1475
|
-
[FirstPartyMachineEvents.NEXT]: {
|
|
1476
|
-
target: FirstPartyMachineStateTypes.sendAuthorizationResponse
|
|
1477
|
-
},
|
|
1478
|
-
[FirstPartyMachineEvents.DECLINE]: {
|
|
1479
|
-
target: FirstPartyMachineStateTypes.declined
|
|
1480
|
-
},
|
|
1481
|
-
[FirstPartyMachineEvents.PREVIOUS]: {
|
|
1482
|
-
target: FirstPartyMachineStateTypes.aborted
|
|
1563
|
+
},
|
|
1564
|
+
...credentialDisplay.description && {
|
|
1565
|
+
description: credentialDisplay.description
|
|
1566
|
+
},
|
|
1567
|
+
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1568
|
+
text: {
|
|
1569
|
+
color: credentialDisplay.rendering.simple.text_color
|
|
1483
1570
|
}
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
invoke: {
|
|
1489
|
-
src: FirstPartyMachineServices.sendAuthorizationResponse,
|
|
1490
|
-
onDone: {
|
|
1491
|
-
target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1492
|
-
actions: (0, import_xstate2.assign)({
|
|
1493
|
-
presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
|
|
1494
|
-
})
|
|
1495
|
-
},
|
|
1496
|
-
onError: {
|
|
1497
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1498
|
-
actions: (0, import_xstate2.assign)({
|
|
1499
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1500
|
-
title: translate("oid4vci_machine_get_request_error_title"),
|
|
1501
|
-
message: _event.data.message,
|
|
1502
|
-
stack: _event.data.stack
|
|
1503
|
-
}), "error")
|
|
1504
|
-
})
|
|
1571
|
+
},
|
|
1572
|
+
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1573
|
+
background: {
|
|
1574
|
+
color: credentialDisplay.rendering.simple.background_color
|
|
1505
1575
|
}
|
|
1506
1576
|
}
|
|
1507
|
-
},
|
|
1508
|
-
[FirstPartyMachineStateTypes.aborted]: {
|
|
1509
|
-
id: FirstPartyMachineStateTypes.aborted,
|
|
1510
|
-
type: "final"
|
|
1511
|
-
},
|
|
1512
|
-
[FirstPartyMachineStateTypes.declined]: {
|
|
1513
|
-
id: FirstPartyMachineStateTypes.declined,
|
|
1514
|
-
type: "final"
|
|
1515
|
-
},
|
|
1516
|
-
[FirstPartyMachineStateTypes.error]: {
|
|
1517
|
-
id: FirstPartyMachineStateTypes.error,
|
|
1518
|
-
type: "final"
|
|
1519
|
-
},
|
|
1520
|
-
[FirstPartyMachineStateTypes.done]: {
|
|
1521
|
-
id: FirstPartyMachineStateTypes.done,
|
|
1522
|
-
type: "final"
|
|
1523
|
-
}
|
|
1524
|
-
};
|
|
1525
|
-
var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
1526
|
-
const initialContext = {
|
|
1527
|
-
openID4VCIClientState: opts.openID4VCIClientState,
|
|
1528
|
-
contact: opts.contact,
|
|
1529
|
-
selectedCredentials: []
|
|
1530
1577
|
};
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
static _instance;
|
|
1548
|
-
static hasInstance() {
|
|
1549
|
-
return _FirstPartyMachine._instance !== void 0;
|
|
1550
|
-
}
|
|
1551
|
-
static get instance() {
|
|
1552
|
-
if (!_FirstPartyMachine._instance) {
|
|
1553
|
-
throw Error("Please initialize ESIMActivation machine first");
|
|
1554
|
-
}
|
|
1555
|
-
return _FirstPartyMachine._instance;
|
|
1556
|
-
}
|
|
1557
|
-
static clearInstance(opts) {
|
|
1558
|
-
const { stop } = opts;
|
|
1559
|
-
if (_FirstPartyMachine.hasInstance()) {
|
|
1560
|
-
if (stop) {
|
|
1561
|
-
_FirstPartyMachine.stopInstance();
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
_FirstPartyMachine._instance = void 0;
|
|
1565
|
-
}
|
|
1566
|
-
static stopInstance() {
|
|
1567
|
-
if (!_FirstPartyMachine.hasInstance()) {
|
|
1568
|
-
return;
|
|
1569
|
-
}
|
|
1570
|
-
_FirstPartyMachine.instance.stop();
|
|
1571
|
-
_FirstPartyMachine._instance = void 0;
|
|
1572
|
-
}
|
|
1573
|
-
static newInstance(opts) {
|
|
1574
|
-
const { agentContext } = opts;
|
|
1575
|
-
const services = {
|
|
1576
|
-
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1577
|
-
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1578
|
-
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1579
|
-
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1580
|
-
};
|
|
1581
|
-
const newInst = (0, import_xstate2.interpret)(createFirstPartyActivationMachine(opts).withConfig({
|
|
1582
|
-
services: {
|
|
1583
|
-
...services,
|
|
1584
|
-
...opts?.services
|
|
1578
|
+
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1579
|
+
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1580
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1581
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1582
|
+
...claimsMetadata.keys(),
|
|
1583
|
+
...credentialDisplayLocales.keys()
|
|
1584
|
+
]));
|
|
1585
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1586
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1587
|
+
const claims = claimsMetadata.get(locale);
|
|
1588
|
+
return {
|
|
1589
|
+
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1590
|
+
credentialDisplay: display
|
|
1591
|
+
}),
|
|
1592
|
+
...locale.length > 0 && {
|
|
1593
|
+
locale
|
|
1585
1594
|
},
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1595
|
+
claims
|
|
1596
|
+
};
|
|
1597
|
+
}));
|
|
1598
|
+
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1599
|
+
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1600
|
+
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1601
|
+
return {
|
|
1602
|
+
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1603
|
+
alias: dynamicRegistrationClientMetadata.client_name
|
|
1604
|
+
},
|
|
1605
|
+
...issuerDisplay.name && {
|
|
1606
|
+
alias: issuerDisplay.name
|
|
1607
|
+
},
|
|
1608
|
+
...issuerDisplay.locale && {
|
|
1609
|
+
locale: issuerDisplay.locale
|
|
1610
|
+
},
|
|
1611
|
+
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1612
|
+
logo: {
|
|
1613
|
+
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1614
|
+
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1615
|
+
},
|
|
1616
|
+
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1617
|
+
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1618
|
+
},
|
|
1619
|
+
...issuerDisplay.logo?.alt_text && {
|
|
1620
|
+
alt: issuerDisplay.logo?.alt_text
|
|
1597
1621
|
}
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
return newInst;
|
|
1601
|
-
}
|
|
1602
|
-
static getInstance(opts) {
|
|
1603
|
-
if (!_FirstPartyMachine._instance) {
|
|
1604
|
-
if (opts?.requireExisting === true) {
|
|
1605
|
-
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1606
1622
|
}
|
|
1607
|
-
|
|
1623
|
+
},
|
|
1624
|
+
...issuerDisplay.description && {
|
|
1625
|
+
description: issuerDisplay.description
|
|
1626
|
+
},
|
|
1627
|
+
...issuerDisplay.text_color && {
|
|
1628
|
+
text: {
|
|
1629
|
+
color: issuerDisplay.text_color
|
|
1630
|
+
}
|
|
1631
|
+
},
|
|
1632
|
+
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1633
|
+
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1634
|
+
},
|
|
1635
|
+
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1636
|
+
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1637
|
+
},
|
|
1638
|
+
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1639
|
+
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1640
|
+
},
|
|
1641
|
+
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1642
|
+
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1608
1643
|
}
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
};
|
|
1644
|
+
};
|
|
1645
|
+
}, "issuerLocaleBrandingFrom");
|
|
1612
1646
|
|
|
1613
1647
|
// src/services/OID4VCIHolderService.ts
|
|
1614
|
-
var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
|
|
1615
1648
|
var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
|
|
1616
1649
|
const { credentialsSupported, context } = args;
|
|
1617
1650
|
const credentialBranding = {};
|
|
1618
1651
|
await Promise.all(Object.entries(credentialsSupported).map(async ([configId, credentialsConfigSupported]) => {
|
|
1619
1652
|
let sdJwtTypeMetadata;
|
|
1620
|
-
if (credentialsConfigSupported.format === "
|
|
1653
|
+
if (credentialsConfigSupported.format === "dc+sd-jwt") {
|
|
1621
1654
|
const vct = credentialsConfigSupported.vct;
|
|
1622
1655
|
if (vct.startsWith("http")) {
|
|
1623
1656
|
try {
|
|
@@ -1683,10 +1716,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
|
|
|
1683
1716
|
}, "selectCredentialLocaleBranding");
|
|
1684
1717
|
var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1685
1718
|
const { mappedCredential, hasher, onVerifyEBSICredentialIssuer, schemaValidation, context } = args;
|
|
1686
|
-
const credential = mappedCredential.credentialToAccept.credentialResponse
|
|
1687
|
-
if (!credential) {
|
|
1688
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1689
|
-
}
|
|
1719
|
+
const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
|
|
1690
1720
|
const wrappedVC = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(credential, {
|
|
1691
1721
|
hasher: hasher ?? import_ssi_sdk.defaultHasher
|
|
1692
1722
|
});
|
|
@@ -1738,17 +1768,13 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1738
1768
|
}, "verifyCredentialToAccept");
|
|
1739
1769
|
var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1740
1770
|
const { credentialToAccept, hasher } = args;
|
|
1741
|
-
const
|
|
1742
|
-
const verifiableCredential = credentialResponse.credential;
|
|
1743
|
-
if (!verifiableCredential) {
|
|
1744
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1745
|
-
}
|
|
1771
|
+
const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
|
|
1746
1772
|
const wrappedVerifiableCredential = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
|
|
1747
1773
|
hasher
|
|
1748
1774
|
});
|
|
1749
1775
|
let uniformVerifiableCredential;
|
|
1750
1776
|
if (import_ssi_types.CredentialMapper.isSdJwtDecodedCredential(wrappedVerifiableCredential.credential)) {
|
|
1751
|
-
uniformVerifiableCredential =
|
|
1777
|
+
uniformVerifiableCredential = (0, import_ssi_types.sdJwtDecodedCredentialToUniformCredential)(wrappedVerifiableCredential.credential);
|
|
1752
1778
|
} else if (import_ssi_types.CredentialMapper.isSdJwtEncoded(wrappedVerifiableCredential.credential)) {
|
|
1753
1779
|
if (!hasher) {
|
|
1754
1780
|
return Promise.reject("a hasher is required for encoded SD-JWT credentials");
|
|
@@ -1762,6 +1788,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1762
1788
|
uniformVerifiableCredential = wrappedVerifiableCredential.credential;
|
|
1763
1789
|
}
|
|
1764
1790
|
const correlationId = typeof uniformVerifiableCredential.issuer === "string" ? uniformVerifiableCredential.issuer : import_ssi_types.CredentialMapper.isSdJwtDecodedCredential(uniformVerifiableCredential) ? uniformVerifiableCredential.decodedPayload.iss : uniformVerifiableCredential.issuer.id;
|
|
1791
|
+
const credentialResponse = credentialToAccept.credentialResponse;
|
|
1765
1792
|
return {
|
|
1766
1793
|
correlationId,
|
|
1767
1794
|
credentialToAccept,
|
|
@@ -1773,6 +1800,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1773
1800
|
}
|
|
1774
1801
|
};
|
|
1775
1802
|
}, "mapCredentialToAccept");
|
|
1803
|
+
var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse) => {
|
|
1804
|
+
let credential;
|
|
1805
|
+
if ("credential" in credentialResponse) {
|
|
1806
|
+
credential = credentialResponse.credential;
|
|
1807
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1808
|
+
credential = credentialResponse.credentials[0].credential;
|
|
1809
|
+
}
|
|
1810
|
+
if (!credential) {
|
|
1811
|
+
throw new Error("No credential found in credential response");
|
|
1812
|
+
}
|
|
1813
|
+
return credential;
|
|
1814
|
+
}, "extractCredentialFromResponse");
|
|
1776
1815
|
var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
1777
1816
|
const { issuanceOpt, context } = args;
|
|
1778
1817
|
const { identifier: identifierArg } = issuanceOpt;
|
|
@@ -1881,24 +1920,19 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
|
|
|
1881
1920
|
}
|
|
1882
1921
|
__name(createIdFromTypes, "createIdFromTypes");
|
|
1883
1922
|
if (configurationId) {
|
|
1884
|
-
const allSupported2 = client.getCredentialsSupported(
|
|
1923
|
+
const allSupported2 = client.getCredentialsSupported(void 0, format);
|
|
1885
1924
|
return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
|
|
1886
1925
|
}
|
|
1887
|
-
if (!
|
|
1888
|
-
return Promise.reject(Error("openID4VCIClient has no credentialOffer
|
|
1926
|
+
if (!client.credentialOffer) {
|
|
1927
|
+
return Promise.reject(Error("openID4VCIClient has no credentialOffer"));
|
|
1889
1928
|
}
|
|
1890
|
-
if (!
|
|
1891
|
-
|
|
1892
|
-
format = client.credentialOffer.credential_offer.credentials.filter((cred) => typeof cred !== "string").map((cred) => cred.format);
|
|
1893
|
-
if (format?.length === 0) {
|
|
1894
|
-
format = void 0;
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1929
|
+
if (!types) {
|
|
1930
|
+
return Promise.reject(Error("openID4VCIClient has no types"));
|
|
1897
1931
|
}
|
|
1898
1932
|
const offerSupported = (0, import_oid4vci_common3.getSupportedCredentials)({
|
|
1899
|
-
types:
|
|
1933
|
+
types: [
|
|
1900
1934
|
types
|
|
1901
|
-
]
|
|
1935
|
+
],
|
|
1902
1936
|
format,
|
|
1903
1937
|
version: client.version(),
|
|
1904
1938
|
issuerMetadata: client.endpointMetadata.credentialIssuerMetadata
|
|
@@ -2073,7 +2107,8 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
|
|
|
2073
2107
|
case "jwt":
|
|
2074
2108
|
case "jwt_vc_json":
|
|
2075
2109
|
case "jwt_vc":
|
|
2076
|
-
case
|
|
2110
|
+
//case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
2111
|
+
case "dc+sd-jwt":
|
|
2077
2112
|
case "mso_mdoc": {
|
|
2078
2113
|
const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
|
|
2079
2114
|
if (supportedPreferences.length > 0) {
|
|
@@ -2141,8 +2176,6 @@ var startFirstPartApplicationMachine = /* @__PURE__ */ __name(async (args, conte
|
|
|
2141
2176
|
}, "startFirstPartApplicationMachine");
|
|
2142
2177
|
|
|
2143
2178
|
// src/agent/OID4VCIHolder.ts
|
|
2144
|
-
var import_polyfill = require("cross-fetch/polyfill");
|
|
2145
|
-
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.core");
|
|
2146
2179
|
var oid4vciHolderContextMethods = [
|
|
2147
2180
|
"cmGetContacts",
|
|
2148
2181
|
"cmGetContact",
|
|
@@ -2158,7 +2191,7 @@ var oid4vciHolderContextMethods = [
|
|
|
2158
2191
|
];
|
|
2159
2192
|
var logger = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vci:holder");
|
|
2160
2193
|
function signCallback(identifier, context, nonce) {
|
|
2161
|
-
return async (jwt, kid) => {
|
|
2194
|
+
return async (jwt, kid, noIssPayloadUpdate) => {
|
|
2162
2195
|
let resolution = await context.agent.identifierManagedGet(identifier);
|
|
2163
2196
|
const jwk = jwt.header.jwk ?? (resolution.method === "jwk" ? resolution.jwk : void 0);
|
|
2164
2197
|
if (!resolution.issuer && !jwt.payload.iss) {
|
|
@@ -2176,7 +2209,7 @@ function signCallback(identifier, context, nonce) {
|
|
|
2176
2209
|
return (await context.agent.jwtCreateJwsCompactSignature({
|
|
2177
2210
|
issuer: {
|
|
2178
2211
|
...resolution,
|
|
2179
|
-
noIssPayloadUpdate: false
|
|
2212
|
+
noIssPayloadUpdate: noIssPayloadUpdate ?? false
|
|
2180
2213
|
},
|
|
2181
2214
|
protectedHeader: header,
|
|
2182
2215
|
payload
|
|
@@ -2198,6 +2231,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2198
2231
|
oid4vciHolderStart: this.oid4vciHolderStart.bind(this),
|
|
2199
2232
|
oid4vciHolderGetIssuerMetadata: this.oid4vciHolderGetIssuerMetadata.bind(this),
|
|
2200
2233
|
oid4vciHolderGetMachineInterpreter: this.oid4vciHolderGetMachineInterpreter.bind(this),
|
|
2234
|
+
oid4vciHolderPrepareAuthorizationRequest: this.oid4vciHolderPrepareAuthorizationRequest.bind(this),
|
|
2201
2235
|
oid4vciHolderCreateCredentialsToSelectFrom: this.oid4vciHolderCreateCredentialsToSelectFrom.bind(this),
|
|
2202
2236
|
oid4vciHolderGetContact: this.oid4vciHolderGetContact.bind(this),
|
|
2203
2237
|
oid4vciHolderGetCredentials: this.oid4vciHolderGetCredentials.bind(this),
|
|
@@ -2211,6 +2245,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2211
2245
|
oid4vciHolderStoreIssuerBranding: this.oid4vciHolderStoreIssuerBranding.bind(this)
|
|
2212
2246
|
};
|
|
2213
2247
|
vcFormatPreferences = [
|
|
2248
|
+
"dc+sd-jwt",
|
|
2214
2249
|
"vc+sd-jwt",
|
|
2215
2250
|
"mso_mdoc",
|
|
2216
2251
|
"jwt_vc_json",
|
|
@@ -2244,7 +2279,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2244
2279
|
onIdentifierCreated;
|
|
2245
2280
|
onVerifyEBSICredentialIssuer;
|
|
2246
2281
|
constructor(options) {
|
|
2247
|
-
const { onContactIdentityCreated, onCredentialStored, onIdentifierCreated, onVerifyEBSICredentialIssuer, vcFormatPreferences, jsonldCryptographicSuitePreferences, didMethodPreferences, jwtCryptographicSuitePreferences, defaultAuthorizationRequestOptions, hasher =
|
|
2282
|
+
const { onContactIdentityCreated, onCredentialStored, onIdentifierCreated, onVerifyEBSICredentialIssuer, vcFormatPreferences, jsonldCryptographicSuitePreferences, didMethodPreferences, jwtCryptographicSuitePreferences, defaultAuthorizationRequestOptions, hasher = import_ssi_sdk2.defaultHasher } = {
|
|
2248
2283
|
...options
|
|
2249
2284
|
};
|
|
2250
2285
|
this.hasher = hasher;
|
|
@@ -2301,6 +2336,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2301
2336
|
stateNavigationListener: opts.firstPartyStateNavigationListener
|
|
2302
2337
|
}, context),
|
|
2303
2338
|
[OID4VCIMachineServices.createCredentialsToSelectFrom]: (args) => this.oid4vciHolderCreateCredentialsToSelectFrom(args, context),
|
|
2339
|
+
[OID4VCIMachineServices.prepareAuthorizationRequest]: (args) => this.oid4vciHolderPrepareAuthorizationRequest(args, context),
|
|
2304
2340
|
[OID4VCIMachineServices.getContact]: (args) => this.oid4vciHolderGetContact(args, context),
|
|
2305
2341
|
[OID4VCIMachineServices.getCredentials]: (args) => this.oid4vciHolderGetCredentials({
|
|
2306
2342
|
accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts,
|
|
@@ -2349,7 +2385,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2349
2385
|
...this.defaultAuthorizationRequestOpts,
|
|
2350
2386
|
...args.authorizationRequestOpts
|
|
2351
2387
|
};
|
|
2352
|
-
authorizationRequestOpts.authorizationDetails = authorizationRequestOpts?.authorizationDetails ? (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails)
|
|
2388
|
+
authorizationRequestOpts.authorizationDetails = authorizationRequestOpts?.authorizationDetails ? (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails) : void 0;
|
|
2353
2389
|
if (!authorizationRequestOpts.redirectUri) {
|
|
2354
2390
|
authorizationRequestOpts.redirectUri = _OID4VCIHolder.DEFAULT_MOBILE_REDIRECT_URI;
|
|
2355
2391
|
}
|
|
@@ -2362,10 +2398,9 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2362
2398
|
formats = Array.from(new Set(authFormats));
|
|
2363
2399
|
}
|
|
2364
2400
|
let oid4vciClient;
|
|
2365
|
-
let types = void 0;
|
|
2366
2401
|
let offer;
|
|
2367
2402
|
if (requestData.existingClientState) {
|
|
2368
|
-
oid4vciClient = await import_oid4vci_client3.
|
|
2403
|
+
oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromState({
|
|
2369
2404
|
state: requestData.existingClientState
|
|
2370
2405
|
});
|
|
2371
2406
|
offer = oid4vciClient.credentialOffer;
|
|
@@ -2382,50 +2417,76 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2382
2417
|
}
|
|
2383
2418
|
if (!offer) {
|
|
2384
2419
|
logger.log(`Issuer url received (no credential offer): ${uri}`);
|
|
2385
|
-
oid4vciClient = await import_oid4vci_client3.
|
|
2420
|
+
oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromCredentialIssuer({
|
|
2386
2421
|
credentialIssuer: uri,
|
|
2387
2422
|
authorizationRequest: authorizationRequestOpts,
|
|
2388
2423
|
clientId: authorizationRequestOpts.clientId,
|
|
2389
|
-
createAuthorizationRequestURL:
|
|
2424
|
+
createAuthorizationRequestURL: false
|
|
2390
2425
|
});
|
|
2391
2426
|
} else {
|
|
2392
2427
|
logger.log(`Credential offer received: ${uri}`);
|
|
2393
|
-
oid4vciClient = await import_oid4vci_client3.
|
|
2428
|
+
oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromURI({
|
|
2394
2429
|
uri,
|
|
2395
2430
|
authorizationRequest: authorizationRequestOpts,
|
|
2396
2431
|
clientId: authorizationRequestOpts.clientId,
|
|
2397
|
-
createAuthorizationRequestURL:
|
|
2432
|
+
createAuthorizationRequestURL: false
|
|
2398
2433
|
});
|
|
2399
2434
|
}
|
|
2400
2435
|
}
|
|
2436
|
+
let configurationIds = [];
|
|
2401
2437
|
if (offer) {
|
|
2402
|
-
|
|
2438
|
+
configurationIds = offer.original_credential_offer.credential_configuration_ids;
|
|
2403
2439
|
} else {
|
|
2404
|
-
|
|
2440
|
+
configurationIds = (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails).map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
|
|
2405
2441
|
}
|
|
2406
|
-
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2407
2442
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
2408
2443
|
client: oid4vciClient,
|
|
2409
2444
|
vcFormatPreferences: formats,
|
|
2410
|
-
|
|
2445
|
+
configurationIds
|
|
2411
2446
|
});
|
|
2447
|
+
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2412
2448
|
const credentialBranding = await getCredentialBranding({
|
|
2413
2449
|
credentialsSupported,
|
|
2414
2450
|
context
|
|
2415
2451
|
});
|
|
2416
|
-
const authorizationCodeURL = oid4vciClient.authorizationURL;
|
|
2417
|
-
if (authorizationCodeURL) {
|
|
2418
|
-
logger.log(`authorization code URL ${authorizationCodeURL}`);
|
|
2419
|
-
}
|
|
2420
2452
|
const oid4vciClientState = JSON.parse(await oid4vciClient.exportState());
|
|
2421
2453
|
return {
|
|
2422
|
-
authorizationCodeURL,
|
|
2423
2454
|
credentialBranding,
|
|
2424
2455
|
credentialsSupported,
|
|
2425
2456
|
serverMetadata,
|
|
2426
2457
|
oid4vciClientState
|
|
2427
2458
|
};
|
|
2428
2459
|
}
|
|
2460
|
+
async oid4vciHolderPrepareAuthorizationRequest(args, context) {
|
|
2461
|
+
const { openID4VCIClientState, contact } = args;
|
|
2462
|
+
if (!openID4VCIClientState) {
|
|
2463
|
+
return Promise.reject(Error("Missing openID4VCI client state in context"));
|
|
2464
|
+
}
|
|
2465
|
+
const clientId = contact?.identities.map((identity) => {
|
|
2466
|
+
const connectionConfig = identity.connection?.config;
|
|
2467
|
+
if (connectionConfig && "clientId" in connectionConfig) {
|
|
2468
|
+
return connectionConfig.clientId;
|
|
2469
|
+
}
|
|
2470
|
+
return void 0;
|
|
2471
|
+
}).find((clientId2) => clientId2);
|
|
2472
|
+
if (!clientId) {
|
|
2473
|
+
return Promise.reject(Error(`Missing client id in contact's connectionConfig`));
|
|
2474
|
+
}
|
|
2475
|
+
const client = await import_oid4vci_client3.OpenID4VCIClient.fromState({
|
|
2476
|
+
state: openID4VCIClientState
|
|
2477
|
+
});
|
|
2478
|
+
const authorizationCodeURL = await client.createAuthorizationRequestUrl({
|
|
2479
|
+
authorizationRequest: {
|
|
2480
|
+
clientId
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2483
|
+
if (authorizationCodeURL) {
|
|
2484
|
+
logger.log(`authorization code URL ${authorizationCodeURL}`);
|
|
2485
|
+
}
|
|
2486
|
+
return {
|
|
2487
|
+
authorizationCodeURL
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2429
2490
|
async oid4vciHolderCreateCredentialsToSelectFrom(args, context) {
|
|
2430
2491
|
const { credentialBranding, locale, selectedCredentials, credentialsSupported } = args;
|
|
2431
2492
|
logger.info(`Credentials supported ${Object.keys(credentialsSupported).join(", ")}`);
|
|
@@ -2497,7 +2558,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2497
2558
|
if (!openID4VCIClientState) {
|
|
2498
2559
|
return Promise.reject(Error("Missing openID4VCI client state in context"));
|
|
2499
2560
|
}
|
|
2500
|
-
const client = await import_oid4vci_client3.
|
|
2561
|
+
const client = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromState({
|
|
2501
2562
|
state: openID4VCIClientState
|
|
2502
2563
|
});
|
|
2503
2564
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
@@ -2625,26 +2686,26 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2625
2686
|
return Promise.reject(Error("Missing credential offers in context"));
|
|
2626
2687
|
}
|
|
2627
2688
|
let correlationId = credentialsToAccept[0].correlationId;
|
|
2628
|
-
let identifierType =
|
|
2689
|
+
let identifierType = import_ssi_sdk3.CorrelationIdentifierType.DID;
|
|
2629
2690
|
if (!correlationId.toLowerCase().startsWith("did:")) {
|
|
2630
|
-
identifierType =
|
|
2691
|
+
identifierType = import_ssi_sdk3.CorrelationIdentifierType.URL;
|
|
2631
2692
|
if (correlationId.startsWith("http")) {
|
|
2632
2693
|
correlationId = new URL(correlationId).hostname;
|
|
2633
2694
|
}
|
|
2634
2695
|
}
|
|
2635
2696
|
const identity = {
|
|
2636
2697
|
alias: credentialsToAccept[0].correlationId,
|
|
2637
|
-
origin:
|
|
2698
|
+
origin: import_ssi_sdk3.IdentityOrigin.EXTERNAL,
|
|
2638
2699
|
roles: [
|
|
2639
|
-
|
|
2700
|
+
import_ssi_types2.CredentialRole.ISSUER
|
|
2640
2701
|
],
|
|
2641
2702
|
identifier: {
|
|
2642
2703
|
type: identifierType,
|
|
2643
2704
|
correlationId
|
|
2644
2705
|
},
|
|
2645
|
-
...identifierType ===
|
|
2706
|
+
...identifierType === import_ssi_sdk3.CorrelationIdentifierType.URL && {
|
|
2646
2707
|
connection: {
|
|
2647
|
-
type:
|
|
2708
|
+
type: import_ssi_sdk3.ConnectionType.OPENID_CONNECT,
|
|
2648
2709
|
config: {
|
|
2649
2710
|
clientId: "138d7bf8-c930-4c6e-b928-97d3a4928b01",
|
|
2650
2711
|
clientSecret: "03b3955f-d020-4f2a-8a27-4e452d4e27a0",
|
|
@@ -2671,7 +2732,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2671
2732
|
}
|
|
2672
2733
|
async oid4vciHolderGetIssuerBranding(args, context) {
|
|
2673
2734
|
const { serverMetadata, contact } = args;
|
|
2674
|
-
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(
|
|
2735
|
+
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_types2.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
|
|
2675
2736
|
if (issuerCorrelationId) {
|
|
2676
2737
|
const branding = await context.agent.ibGetIssuerBranding({
|
|
2677
2738
|
filter: [
|
|
@@ -2701,7 +2762,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2701
2762
|
if (!contact) {
|
|
2702
2763
|
return Promise.reject(Error("Missing contact in context"));
|
|
2703
2764
|
}
|
|
2704
|
-
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(
|
|
2765
|
+
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_types2.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
|
|
2705
2766
|
const branding = await context.agent.ibGetIssuerBranding({
|
|
2706
2767
|
filter: [
|
|
2707
2768
|
{
|
|
@@ -2737,9 +2798,19 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2737
2798
|
}
|
|
2738
2799
|
let counter = 0;
|
|
2739
2800
|
for (const credentialId of selectedCredentials) {
|
|
2740
|
-
const
|
|
2801
|
+
const configId = credentialId;
|
|
2802
|
+
const types = credentialsToAccept.find((ac) => ac.correlationId === configId || ac.credentialToAccept.id === configId || ac.types.includes(configId))?.types?.filter((type) => type != "VerifiableCredential") ?? [];
|
|
2803
|
+
const localeBranding = credentialBranding?.[configId] ?? [];
|
|
2804
|
+
if (localeBranding.length === 0) {
|
|
2805
|
+
for (const type of types) {
|
|
2806
|
+
const branding = credentialBranding?.[type] ?? [];
|
|
2807
|
+
if (branding.length > 0) {
|
|
2808
|
+
localeBranding.push(...branding);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2741
2812
|
if (localeBranding && localeBranding.length > 0) {
|
|
2742
|
-
const credential = credentialsToAccept.find((credAccept) => credAccept.credentialToAccept.id === credentialId || JSON.stringify(credAccept.types) === credentialId || credentialsToAccept[counter]);
|
|
2813
|
+
const credential = credentialsToAccept.find((credAccept) => credAccept.credentialToAccept.id === credentialId || JSON.stringify(credAccept.types) === credentialId || JSON.stringify(credAccept.types.filter((cred) => cred !== "VerifiableCredential")) === JSON.stringify(types) || credentialsToAccept[counter]);
|
|
2743
2814
|
counter++;
|
|
2744
2815
|
await context.agent.ibAddCredentialBranding({
|
|
2745
2816
|
vcHash: (0, import_utils2.computeEntryHash)(credential.rawVerifiableCredential),
|
|
@@ -2787,9 +2858,9 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2787
2858
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2788
2859
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2789
2860
|
logger.log(`Subject issuance/signing will be used, with event`, event);
|
|
2790
|
-
const issuerVC = mappedCredentialToAccept.credentialToAccept.credentialResponse
|
|
2861
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
|
|
2791
2862
|
const wrappedIssuerVC = import_ssi_types2.CredentialMapper.toWrappedVerifiableCredential(issuerVC, {
|
|
2792
|
-
hasher: this.hasher ??
|
|
2863
|
+
hasher: this.hasher ?? import_ssi_sdk2.defaultHasher
|
|
2793
2864
|
});
|
|
2794
2865
|
console.log(`Wrapped VC: ${wrappedIssuerVC.type}, ${wrappedIssuerVC.format}`);
|
|
2795
2866
|
let issuer;
|
|
@@ -2890,11 +2961,11 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2890
2961
|
const [subjectCorrelationType, subjectCorrelationId] = this.determineSubjectCorrelation(issuanceOpt.identifier, issuer);
|
|
2891
2962
|
const persistedCredential = await context.agent.crsAddCredential({
|
|
2892
2963
|
credential: {
|
|
2893
|
-
rawDocument: (0,
|
|
2964
|
+
rawDocument: (0, import_ssi_sdk3.ensureRawDocument)(persistCredential),
|
|
2894
2965
|
kmsKeyRef,
|
|
2895
2966
|
identifierMethod: method,
|
|
2896
|
-
credentialRole:
|
|
2897
|
-
issuerCorrelationType: issuer?.startsWith("did:") ?
|
|
2967
|
+
credentialRole: import_ssi_types2.CredentialRole.HOLDER,
|
|
2968
|
+
issuerCorrelationType: issuer?.startsWith("did:") ? import_ssi_sdk3.CredentialCorrelationType.DID : import_ssi_sdk3.CredentialCorrelationType.URL,
|
|
2898
2969
|
issuerCorrelationId: issuer,
|
|
2899
2970
|
subjectCorrelationType,
|
|
2900
2971
|
subjectCorrelationId
|
|
@@ -2962,12 +3033,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2962
3033
|
case "did":
|
|
2963
3034
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierDidResult)(identifier)) {
|
|
2964
3035
|
return [
|
|
2965
|
-
|
|
3036
|
+
import_ssi_sdk3.CredentialCorrelationType.DID,
|
|
2966
3037
|
identifier.did
|
|
2967
3038
|
];
|
|
2968
3039
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
|
|
2969
3040
|
return [
|
|
2970
|
-
|
|
3041
|
+
import_ssi_sdk3.CredentialCorrelationType.DID,
|
|
2971
3042
|
typeof identifier.identifier === "string" ? identifier.identifier : identifier.identifier.did
|
|
2972
3043
|
];
|
|
2973
3044
|
}
|
|
@@ -2975,12 +3046,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2975
3046
|
case "kid":
|
|
2976
3047
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierKidResult)(identifier)) {
|
|
2977
3048
|
return [
|
|
2978
|
-
|
|
3049
|
+
import_ssi_sdk3.CredentialCorrelationType.KID,
|
|
2979
3050
|
identifier.kid
|
|
2980
3051
|
];
|
|
2981
3052
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
|
|
2982
3053
|
return [
|
|
2983
|
-
|
|
3054
|
+
import_ssi_sdk3.CredentialCorrelationType.KID,
|
|
2984
3055
|
identifier.identifier
|
|
2985
3056
|
];
|
|
2986
3057
|
}
|
|
@@ -2988,19 +3059,19 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2988
3059
|
case "x5c":
|
|
2989
3060
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierX5cResult)(identifier)) {
|
|
2990
3061
|
return [
|
|
2991
|
-
|
|
3062
|
+
import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
|
|
2992
3063
|
identifier.x5c.join("\r\n")
|
|
2993
3064
|
];
|
|
2994
3065
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierX5cOpts)(identifier)) {
|
|
2995
3066
|
return [
|
|
2996
|
-
|
|
3067
|
+
import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
|
|
2997
3068
|
identifier.identifier.join("\r\n")
|
|
2998
3069
|
];
|
|
2999
3070
|
}
|
|
3000
3071
|
break;
|
|
3001
3072
|
}
|
|
3002
3073
|
return [
|
|
3003
|
-
|
|
3074
|
+
import_ssi_sdk3.CredentialCorrelationType.URL,
|
|
3004
3075
|
issuer
|
|
3005
3076
|
];
|
|
3006
3077
|
}
|