@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feature.SSISDK.26.RP.58 → 0.34.1-feature.SSISDK.44.finish.dcql.310
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 +440 -402
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -14
- package/dist/index.d.ts +23 -14
- package/dist/index.js +440 -402
- package/dist/index.js.map +1 -1
- package/package.json +25 -24
- package/src/agent/OID4VCIHolder.ts +65 -42
- 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 +43 -66
- package/src/types/FirstPartyMachine.ts +6 -5
- package/src/types/IOID4VCIHolder.ts +19 -12
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,
|
|
@@ -140,9 +141,10 @@ 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
143
|
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.core");
|
|
143
|
-
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store");
|
|
144
|
+
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store-types");
|
|
144
145
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
145
146
|
var import_utils2 = require("@veramo/utils");
|
|
147
|
+
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
146
148
|
var import_did_jwt = require("did-jwt");
|
|
147
149
|
var import_uuid2 = require("uuid");
|
|
148
150
|
|
|
@@ -155,18 +157,18 @@ var import_i18n_js = __toESM(require("i18n-js"), 1);
|
|
|
155
157
|
var import_lodash = __toESM(require("lodash.memoize"), 1);
|
|
156
158
|
|
|
157
159
|
// src/types/IOID4VCIHolder.ts
|
|
158
|
-
var OID4VCIHolderEvent = /* @__PURE__ */ function(OID4VCIHolderEvent2) {
|
|
160
|
+
var OID4VCIHolderEvent = /* @__PURE__ */ (function(OID4VCIHolderEvent2) {
|
|
159
161
|
OID4VCIHolderEvent2["CONTACT_IDENTITY_CREATED"] = "contact_identity_created";
|
|
160
162
|
OID4VCIHolderEvent2["CREDENTIAL_STORED"] = "credential_stored";
|
|
161
163
|
OID4VCIHolderEvent2["IDENTIFIER_CREATED"] = "identifier_created";
|
|
162
164
|
return OID4VCIHolderEvent2;
|
|
163
|
-
}({});
|
|
164
|
-
var SupportedLanguage = /* @__PURE__ */ function(SupportedLanguage2) {
|
|
165
|
+
})({});
|
|
166
|
+
var SupportedLanguage = /* @__PURE__ */ (function(SupportedLanguage2) {
|
|
165
167
|
SupportedLanguage2["ENGLISH"] = "en";
|
|
166
168
|
SupportedLanguage2["DUTCH"] = "nl";
|
|
167
169
|
return SupportedLanguage2;
|
|
168
|
-
}({});
|
|
169
|
-
var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
170
|
+
})({});
|
|
171
|
+
var OID4VCIMachineStates = /* @__PURE__ */ (function(OID4VCIMachineStates2) {
|
|
170
172
|
OID4VCIMachineStates2["start"] = "start";
|
|
171
173
|
OID4VCIMachineStates2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
172
174
|
OID4VCIMachineStates2["getContact"] = "getContact";
|
|
@@ -182,6 +184,7 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
182
184
|
OID4VCIMachineStates2["selectCredentials"] = "selectCredentials";
|
|
183
185
|
OID4VCIMachineStates2["transitionFromSelectingCredentials"] = "transitionFromSelectingCredentials";
|
|
184
186
|
OID4VCIMachineStates2["verifyPin"] = "verifyPin";
|
|
187
|
+
OID4VCIMachineStates2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
185
188
|
OID4VCIMachineStates2["initiateAuthorizationRequest"] = "initiateAuthorizationRequest";
|
|
186
189
|
OID4VCIMachineStates2["waitForAuthorizationResponse"] = "waitForAuthorizationResponse";
|
|
187
190
|
OID4VCIMachineStates2["getCredentials"] = "getCredentials";
|
|
@@ -197,18 +200,18 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
197
200
|
OID4VCIMachineStates2["error"] = "error";
|
|
198
201
|
OID4VCIMachineStates2["done"] = "done";
|
|
199
202
|
return OID4VCIMachineStates2;
|
|
200
|
-
}({});
|
|
201
|
-
var OID4VCIMachineAddContactStates = /* @__PURE__ */ function(OID4VCIMachineAddContactStates2) {
|
|
203
|
+
})({});
|
|
204
|
+
var OID4VCIMachineAddContactStates = /* @__PURE__ */ (function(OID4VCIMachineAddContactStates2) {
|
|
202
205
|
OID4VCIMachineAddContactStates2["idle"] = "idle";
|
|
203
206
|
OID4VCIMachineAddContactStates2["next"] = "next";
|
|
204
207
|
return OID4VCIMachineAddContactStates2;
|
|
205
|
-
}({});
|
|
206
|
-
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ function(OID4VCIMachineVerifyPinStates2) {
|
|
208
|
+
})({});
|
|
209
|
+
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ (function(OID4VCIMachineVerifyPinStates2) {
|
|
207
210
|
OID4VCIMachineVerifyPinStates2["idle"] = "idle";
|
|
208
211
|
OID4VCIMachineVerifyPinStates2["next"] = "next";
|
|
209
212
|
return OID4VCIMachineVerifyPinStates2;
|
|
210
|
-
}({});
|
|
211
|
-
var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
213
|
+
})({});
|
|
214
|
+
var OID4VCIMachineEvents = /* @__PURE__ */ (function(OID4VCIMachineEvents2) {
|
|
212
215
|
OID4VCIMachineEvents2["NEXT"] = "NEXT";
|
|
213
216
|
OID4VCIMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
214
217
|
OID4VCIMachineEvents2["DECLINE"] = "DECLINE";
|
|
@@ -221,8 +224,8 @@ var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
|
221
224
|
OID4VCIMachineEvents2["INVOKED_AUTHORIZATION_CODE_REQUEST"] = "INVOKED_AUTHORIZATION_CODE_REQUEST";
|
|
222
225
|
OID4VCIMachineEvents2["PROVIDE_AUTHORIZATION_CODE_RESPONSE"] = "PROVIDE_AUTHORIZATION_CODE_RESPONSE";
|
|
223
226
|
return OID4VCIMachineEvents2;
|
|
224
|
-
}({});
|
|
225
|
-
var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
227
|
+
})({});
|
|
228
|
+
var OID4VCIMachineGuards = /* @__PURE__ */ (function(OID4VCIMachineGuards2) {
|
|
226
229
|
OID4VCIMachineGuards2["hasContactGuard"] = "oid4vciHasContactGuard";
|
|
227
230
|
OID4VCIMachineGuards2["hasNoContactGuard"] = "oid4vciHasNoContactGuard";
|
|
228
231
|
OID4VCIMachineGuards2["credentialsToSelectRequiredGuard"] = "oid4vciCredentialsToSelectRequiredGuard";
|
|
@@ -239,13 +242,14 @@ var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
|
239
242
|
OID4VCIMachineGuards2["contactHasLowTrustGuard"] = "oid4vciContactHasLowTrustGuard";
|
|
240
243
|
OID4VCIMachineGuards2["isFirstPartyApplication"] = "oid4vciIsFirstPartyApplication";
|
|
241
244
|
return OID4VCIMachineGuards2;
|
|
242
|
-
}({});
|
|
243
|
-
var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
245
|
+
})({});
|
|
246
|
+
var OID4VCIMachineServices = /* @__PURE__ */ (function(OID4VCIMachineServices2) {
|
|
244
247
|
OID4VCIMachineServices2["start"] = "start";
|
|
245
248
|
OID4VCIMachineServices2["getContact"] = "getContact";
|
|
246
249
|
OID4VCIMachineServices2["getFederationTrust"] = "getFederationTrust";
|
|
247
250
|
OID4VCIMachineServices2["addContactIdentity"] = "addContactIdentity";
|
|
248
251
|
OID4VCIMachineServices2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
252
|
+
OID4VCIMachineServices2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
249
253
|
OID4VCIMachineServices2["getIssuerBranding"] = "getIssuerBranding";
|
|
250
254
|
OID4VCIMachineServices2["storeIssuerBranding"] = "storeIssuerBranding";
|
|
251
255
|
OID4VCIMachineServices2["getCredentials"] = "getCredentials";
|
|
@@ -255,17 +259,17 @@ var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
|
255
259
|
OID4VCIMachineServices2["storeCredentials"] = "storeCredentials";
|
|
256
260
|
OID4VCIMachineServices2["startFirstPartApplicationFlow"] = "startFirstPartApplicationFlow";
|
|
257
261
|
return OID4VCIMachineServices2;
|
|
258
|
-
}({});
|
|
259
|
-
var RequestType = /* @__PURE__ */ function(RequestType2) {
|
|
262
|
+
})({});
|
|
263
|
+
var RequestType = /* @__PURE__ */ (function(RequestType2) {
|
|
260
264
|
RequestType2["OPENID_INITIATE_ISSUANCE"] = "openid-initiate-issuance";
|
|
261
265
|
RequestType2["OPENID_CREDENTIAL_OFFER"] = "openid-credential-offer";
|
|
262
266
|
RequestType2["URL"] = "URL";
|
|
263
267
|
return RequestType2;
|
|
264
|
-
}({});
|
|
265
|
-
var IdentifierAliasEnum = /* @__PURE__ */ function(IdentifierAliasEnum2) {
|
|
268
|
+
})({});
|
|
269
|
+
var IdentifierAliasEnum = /* @__PURE__ */ (function(IdentifierAliasEnum2) {
|
|
266
270
|
IdentifierAliasEnum2["PRIMARY"] = "primary";
|
|
267
271
|
return IdentifierAliasEnum2;
|
|
268
|
-
}({});
|
|
272
|
+
})({});
|
|
269
273
|
|
|
270
274
|
// src/localization/Localization.ts
|
|
271
275
|
var Localization = class Localization2 {
|
|
@@ -307,7 +311,7 @@ var Localization = class Localization2 {
|
|
|
307
311
|
var translate = Localization.translate;
|
|
308
312
|
|
|
309
313
|
// src/types/FirstPartyMachine.ts
|
|
310
|
-
var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStateTypes2) {
|
|
314
|
+
var FirstPartyMachineStateTypes = /* @__PURE__ */ (function(FirstPartyMachineStateTypes2) {
|
|
311
315
|
FirstPartyMachineStateTypes2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
312
316
|
FirstPartyMachineStateTypes2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
313
317
|
FirstPartyMachineStateTypes2["selectCredentials"] = "selectCredentials";
|
|
@@ -318,21 +322,21 @@ var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStat
|
|
|
318
322
|
FirstPartyMachineStateTypes2["aborted"] = "aborted";
|
|
319
323
|
FirstPartyMachineStateTypes2["declined"] = "declined";
|
|
320
324
|
return FirstPartyMachineStateTypes2;
|
|
321
|
-
}({});
|
|
322
|
-
var FirstPartyMachineServices = /* @__PURE__ */ function(FirstPartyMachineServices2) {
|
|
325
|
+
})({});
|
|
326
|
+
var FirstPartyMachineServices = /* @__PURE__ */ (function(FirstPartyMachineServices2) {
|
|
323
327
|
FirstPartyMachineServices2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
324
328
|
FirstPartyMachineServices2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
325
329
|
FirstPartyMachineServices2["createConfig"] = "createConfig";
|
|
326
330
|
FirstPartyMachineServices2["getSiopRequest"] = "getSiopRequest";
|
|
327
331
|
return FirstPartyMachineServices2;
|
|
328
|
-
}({});
|
|
329
|
-
var FirstPartyMachineEvents = /* @__PURE__ */ function(FirstPartyMachineEvents2) {
|
|
332
|
+
})({});
|
|
333
|
+
var FirstPartyMachineEvents = /* @__PURE__ */ (function(FirstPartyMachineEvents2) {
|
|
330
334
|
FirstPartyMachineEvents2["NEXT"] = "NEXT";
|
|
331
335
|
FirstPartyMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
332
336
|
FirstPartyMachineEvents2["DECLINE"] = "DECLINE";
|
|
333
337
|
FirstPartyMachineEvents2["SET_SELECTED_CREDENTIALS"] = "SET_SELECTED_CREDENTIALS";
|
|
334
338
|
return FirstPartyMachineEvents2;
|
|
335
|
-
}({});
|
|
339
|
+
})({});
|
|
336
340
|
|
|
337
341
|
// src/machines/oid4vciMachine.ts
|
|
338
342
|
var oid4vciHasNoContactGuard = /* @__PURE__ */ __name((_ctx, _event) => {
|
|
@@ -387,9 +391,7 @@ var oid4vciRequireAuthorizationGuard = /* @__PURE__ */ __name((ctx, _event) => {
|
|
|
387
391
|
if (!openID4VCIClientState) {
|
|
388
392
|
throw Error("Missing openID4VCI client state in context");
|
|
389
393
|
}
|
|
390
|
-
if (
|
|
391
|
-
return false;
|
|
392
|
-
} else if (openID4VCIClientState.authorizationRequestOpts) {
|
|
394
|
+
if (openID4VCIClientState.authorizationURL && openID4VCIClientState.authorizationRequestOpts) {
|
|
393
395
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
394
396
|
} else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(import_oid4vci_common.AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
|
|
395
397
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
@@ -440,7 +442,6 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
440
442
|
onDone: {
|
|
441
443
|
target: OID4VCIMachineStates.createCredentialsToSelectFrom,
|
|
442
444
|
actions: (0, import_xstate.assign)({
|
|
443
|
-
authorizationCodeURL: /* @__PURE__ */ __name((_ctx, _event) => _event.data.authorizationCodeURL, "authorizationCodeURL"),
|
|
444
445
|
credentialBranding: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialBranding ?? {}, "credentialBranding"),
|
|
445
446
|
credentialsSupported: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialsSupported, "credentialsSupported"),
|
|
446
447
|
serverMetadata: /* @__PURE__ */ __name((_ctx, _event) => _event.data.serverMetadata, "serverMetadata"),
|
|
@@ -677,6 +678,10 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
677
678
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
678
679
|
cond: OID4VCIMachineGuards.isFirstPartyApplication
|
|
679
680
|
},
|
|
681
|
+
{
|
|
682
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
683
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
684
|
+
},
|
|
680
685
|
{
|
|
681
686
|
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
682
687
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
@@ -752,12 +757,16 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
752
757
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
753
758
|
cond: OID4VCIMachineGuards.isFirstPartyApplication
|
|
754
759
|
},
|
|
760
|
+
{
|
|
761
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
762
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
763
|
+
},
|
|
755
764
|
{
|
|
756
765
|
target: OID4VCIMachineStates.verifyPin,
|
|
757
766
|
cond: OID4VCIMachineGuards.requirePinGuard
|
|
758
767
|
},
|
|
759
768
|
{
|
|
760
|
-
target: OID4VCIMachineStates.
|
|
769
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
761
770
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
762
771
|
},
|
|
763
772
|
{
|
|
@@ -765,6 +774,28 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
765
774
|
}
|
|
766
775
|
]
|
|
767
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
|
+
},
|
|
768
799
|
[OID4VCIMachineStates.initiateAuthorizationRequest]: {
|
|
769
800
|
id: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
770
801
|
on: {
|
|
@@ -1062,271 +1093,10 @@ var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-resolver-jwk");
|
|
|
1062
1093
|
var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
1063
1094
|
var import_ssi_sdk_ext3 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
1064
1095
|
var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
1096
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
|
|
1065
1097
|
var import_ssi_types = require("@sphereon/ssi-types");
|
|
1066
1098
|
var import_utils = require("@veramo/utils");
|
|
1067
1099
|
|
|
1068
|
-
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
1069
|
-
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1070
|
-
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
1071
|
-
return oid4vciCombineDisplayLocalesFrom({
|
|
1072
|
-
...issuerCredentialSubject && {
|
|
1073
|
-
issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
|
|
1074
|
-
issuerCredentialSubject
|
|
1075
|
-
})
|
|
1076
|
-
},
|
|
1077
|
-
...credentialDisplay && {
|
|
1078
|
-
credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
|
|
1079
|
-
credentialDisplay
|
|
1080
|
-
})
|
|
1081
|
-
}
|
|
1082
|
-
});
|
|
1083
|
-
}, "oid4vciGetCredentialBrandingFrom");
|
|
1084
|
-
var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1085
|
-
const { credentialDisplay } = args;
|
|
1086
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1087
|
-
const localeKey = display.locale || "";
|
|
1088
|
-
localeDisplays.set(localeKey, display);
|
|
1089
|
-
return localeDisplays;
|
|
1090
|
-
}, /* @__PURE__ */ new Map());
|
|
1091
|
-
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1092
|
-
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1093
|
-
const { issuerCredentialSubject } = args;
|
|
1094
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1095
|
-
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1096
|
-
Object.entries(claim).forEach(([key, value]) => {
|
|
1097
|
-
if (key === "mandatory" || key === "value_type") {
|
|
1098
|
-
return;
|
|
1099
|
-
}
|
|
1100
|
-
if (key === "display" && Array.isArray(value)) {
|
|
1101
|
-
value.forEach(({ name, locale = "" }) => {
|
|
1102
|
-
if (!name) {
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
if (!localeClaims.has(locale)) {
|
|
1106
|
-
localeClaims.set(locale, []);
|
|
1107
|
-
}
|
|
1108
|
-
localeClaims.get(locale).push({
|
|
1109
|
-
key: parentKey,
|
|
1110
|
-
name
|
|
1111
|
-
});
|
|
1112
|
-
});
|
|
1113
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1114
|
-
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1115
|
-
}
|
|
1116
|
-
});
|
|
1117
|
-
}, "processClaimObject");
|
|
1118
|
-
processClaimObject(issuerCredentialSubject);
|
|
1119
|
-
return localeClaims;
|
|
1120
|
-
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1121
|
-
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1122
|
-
const { credentialDisplay } = args;
|
|
1123
|
-
return {
|
|
1124
|
-
...credentialDisplay.name && {
|
|
1125
|
-
alias: credentialDisplay.name
|
|
1126
|
-
},
|
|
1127
|
-
...credentialDisplay.locale && {
|
|
1128
|
-
locale: credentialDisplay.locale
|
|
1129
|
-
},
|
|
1130
|
-
...credentialDisplay.logo && {
|
|
1131
|
-
logo: {
|
|
1132
|
-
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1133
|
-
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1134
|
-
},
|
|
1135
|
-
...credentialDisplay.logo.alt_text && {
|
|
1136
|
-
alt: credentialDisplay.logo?.alt_text
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
},
|
|
1140
|
-
...credentialDisplay.description && {
|
|
1141
|
-
description: credentialDisplay.description
|
|
1142
|
-
},
|
|
1143
|
-
...credentialDisplay.text_color && {
|
|
1144
|
-
text: {
|
|
1145
|
-
color: credentialDisplay.text_color
|
|
1146
|
-
}
|
|
1147
|
-
},
|
|
1148
|
-
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1149
|
-
background: {
|
|
1150
|
-
...credentialDisplay.background_image && {
|
|
1151
|
-
image: {
|
|
1152
|
-
...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
|
|
1153
|
-
uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
|
|
1154
|
-
},
|
|
1155
|
-
...credentialDisplay.background_image.alt_text && {
|
|
1156
|
-
alt: credentialDisplay.background_image?.alt_text
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
},
|
|
1160
|
-
...credentialDisplay.background_color && {
|
|
1161
|
-
color: credentialDisplay.background_color
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
};
|
|
1166
|
-
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1167
|
-
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1168
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1169
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1170
|
-
...issuerCredentialSubjectLocales.keys(),
|
|
1171
|
-
...credentialDisplayLocales.keys()
|
|
1172
|
-
]));
|
|
1173
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1174
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1175
|
-
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1176
|
-
return {
|
|
1177
|
-
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1178
|
-
credentialDisplay: display
|
|
1179
|
-
}),
|
|
1180
|
-
...locale.length > 0 && {
|
|
1181
|
-
locale
|
|
1182
|
-
},
|
|
1183
|
-
claims
|
|
1184
|
-
};
|
|
1185
|
-
}));
|
|
1186
|
-
}, "oid4vciCombineDisplayLocalesFrom");
|
|
1187
|
-
var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1188
|
-
const { credentialDisplay, claimsMetadata } = args;
|
|
1189
|
-
return sdJwtCombineDisplayLocalesFrom({
|
|
1190
|
-
...claimsMetadata && {
|
|
1191
|
-
claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
|
|
1192
|
-
claimsMetadata
|
|
1193
|
-
})
|
|
1194
|
-
},
|
|
1195
|
-
...credentialDisplay && {
|
|
1196
|
-
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1197
|
-
credentialDisplay
|
|
1198
|
-
})
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
}, "sdJwtGetCredentialBrandingFrom");
|
|
1202
|
-
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1203
|
-
const { credentialDisplay } = args;
|
|
1204
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1205
|
-
const localeKey = display.lang || "";
|
|
1206
|
-
localeDisplays.set(localeKey, display);
|
|
1207
|
-
return localeDisplays;
|
|
1208
|
-
}, /* @__PURE__ */ new Map());
|
|
1209
|
-
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1210
|
-
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1211
|
-
const { claimsMetadata } = args;
|
|
1212
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1213
|
-
claimsMetadata.forEach((claim) => {
|
|
1214
|
-
claim.display?.forEach((display) => {
|
|
1215
|
-
const { lang = "", label } = display;
|
|
1216
|
-
const key = claim.path.map((value) => String(value)).join(".");
|
|
1217
|
-
if (!localeClaims.has(lang)) {
|
|
1218
|
-
localeClaims.set(lang, []);
|
|
1219
|
-
}
|
|
1220
|
-
localeClaims.get(lang).push({
|
|
1221
|
-
key,
|
|
1222
|
-
name: label
|
|
1223
|
-
});
|
|
1224
|
-
});
|
|
1225
|
-
});
|
|
1226
|
-
return localeClaims;
|
|
1227
|
-
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1228
|
-
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1229
|
-
const { credentialDisplay } = args;
|
|
1230
|
-
return {
|
|
1231
|
-
...credentialDisplay.name && {
|
|
1232
|
-
alias: credentialDisplay.name
|
|
1233
|
-
},
|
|
1234
|
-
...credentialDisplay.lang && {
|
|
1235
|
-
locale: credentialDisplay.lang
|
|
1236
|
-
},
|
|
1237
|
-
...credentialDisplay.rendering?.simple?.logo && {
|
|
1238
|
-
logo: {
|
|
1239
|
-
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1240
|
-
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1241
|
-
},
|
|
1242
|
-
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1243
|
-
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
},
|
|
1247
|
-
...credentialDisplay.description && {
|
|
1248
|
-
description: credentialDisplay.description
|
|
1249
|
-
},
|
|
1250
|
-
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1251
|
-
text: {
|
|
1252
|
-
color: credentialDisplay.rendering.simple.text_color
|
|
1253
|
-
}
|
|
1254
|
-
},
|
|
1255
|
-
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1256
|
-
background: {
|
|
1257
|
-
color: credentialDisplay.rendering.simple.background_color
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
};
|
|
1261
|
-
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1262
|
-
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1263
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1264
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1265
|
-
...claimsMetadata.keys(),
|
|
1266
|
-
...credentialDisplayLocales.keys()
|
|
1267
|
-
]));
|
|
1268
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1269
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1270
|
-
const claims = claimsMetadata.get(locale);
|
|
1271
|
-
return {
|
|
1272
|
-
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1273
|
-
credentialDisplay: display
|
|
1274
|
-
}),
|
|
1275
|
-
...locale.length > 0 && {
|
|
1276
|
-
locale
|
|
1277
|
-
},
|
|
1278
|
-
claims
|
|
1279
|
-
};
|
|
1280
|
-
}));
|
|
1281
|
-
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1282
|
-
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1283
|
-
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1284
|
-
return {
|
|
1285
|
-
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1286
|
-
alias: dynamicRegistrationClientMetadata.client_name
|
|
1287
|
-
},
|
|
1288
|
-
...issuerDisplay.name && {
|
|
1289
|
-
alias: issuerDisplay.name
|
|
1290
|
-
},
|
|
1291
|
-
...issuerDisplay.locale && {
|
|
1292
|
-
locale: issuerDisplay.locale
|
|
1293
|
-
},
|
|
1294
|
-
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1295
|
-
logo: {
|
|
1296
|
-
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1297
|
-
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1298
|
-
},
|
|
1299
|
-
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1300
|
-
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1301
|
-
},
|
|
1302
|
-
...issuerDisplay.logo?.alt_text && {
|
|
1303
|
-
alt: issuerDisplay.logo?.alt_text
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
},
|
|
1307
|
-
...issuerDisplay.description && {
|
|
1308
|
-
description: issuerDisplay.description
|
|
1309
|
-
},
|
|
1310
|
-
...issuerDisplay.text_color && {
|
|
1311
|
-
text: {
|
|
1312
|
-
color: issuerDisplay.text_color
|
|
1313
|
-
}
|
|
1314
|
-
},
|
|
1315
|
-
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1316
|
-
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1317
|
-
},
|
|
1318
|
-
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1319
|
-
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1320
|
-
},
|
|
1321
|
-
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1322
|
-
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1323
|
-
},
|
|
1324
|
-
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1325
|
-
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1326
|
-
}
|
|
1327
|
-
};
|
|
1328
|
-
}, "issuerLocaleBrandingFrom");
|
|
1329
|
-
|
|
1330
1100
|
// src/machines/firstPartyMachine.ts
|
|
1331
1101
|
var import_xstate2 = require("xstate");
|
|
1332
1102
|
var import_oid4vci_common2 = require("@sphereon/oid4vci-common");
|
|
@@ -1563,57 +1333,318 @@ var FirstPartyMachine = class _FirstPartyMachine {
|
|
|
1563
1333
|
_FirstPartyMachine.stopInstance();
|
|
1564
1334
|
}
|
|
1565
1335
|
}
|
|
1566
|
-
_FirstPartyMachine._instance = void 0;
|
|
1567
|
-
}
|
|
1568
|
-
static stopInstance() {
|
|
1569
|
-
if (!_FirstPartyMachine.hasInstance()) {
|
|
1570
|
-
return;
|
|
1571
|
-
}
|
|
1572
|
-
_FirstPartyMachine.instance.stop();
|
|
1573
|
-
_FirstPartyMachine._instance = void 0;
|
|
1574
|
-
}
|
|
1575
|
-
static newInstance(opts) {
|
|
1576
|
-
const { agentContext } = opts;
|
|
1577
|
-
const services = {
|
|
1578
|
-
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1579
|
-
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1580
|
-
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1581
|
-
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1582
|
-
};
|
|
1583
|
-
const newInst = (0, import_xstate2.interpret)(createFirstPartyActivationMachine(opts).withConfig({
|
|
1584
|
-
services: {
|
|
1585
|
-
...services,
|
|
1586
|
-
...opts?.services
|
|
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) => {
|
|
1402
|
+
const { credentialDisplay } = args;
|
|
1403
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1404
|
+
const localeKey = display.locale || "";
|
|
1405
|
+
localeDisplays.set(localeKey, display);
|
|
1406
|
+
return localeDisplays;
|
|
1407
|
+
}, /* @__PURE__ */ new Map());
|
|
1408
|
+
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1409
|
+
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1410
|
+
const { issuerCredentialSubject } = args;
|
|
1411
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
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);
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
}, "processClaimObject");
|
|
1435
|
+
processClaimObject(issuerCredentialSubject);
|
|
1436
|
+
return localeClaims;
|
|
1437
|
+
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1438
|
+
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1439
|
+
const { credentialDisplay } = args;
|
|
1440
|
+
return {
|
|
1441
|
+
...credentialDisplay.name && {
|
|
1442
|
+
alias: credentialDisplay.name
|
|
1443
|
+
},
|
|
1444
|
+
...credentialDisplay.locale && {
|
|
1445
|
+
locale: credentialDisplay.locale
|
|
1446
|
+
},
|
|
1447
|
+
...credentialDisplay.logo && {
|
|
1448
|
+
logo: {
|
|
1449
|
+
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1450
|
+
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1451
|
+
},
|
|
1452
|
+
...credentialDisplay.logo.alt_text && {
|
|
1453
|
+
alt: credentialDisplay.logo?.alt_text
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
...credentialDisplay.description && {
|
|
1458
|
+
description: credentialDisplay.description
|
|
1459
|
+
},
|
|
1460
|
+
...credentialDisplay.text_color && {
|
|
1461
|
+
text: {
|
|
1462
|
+
color: credentialDisplay.text_color
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1466
|
+
background: {
|
|
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
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1484
|
+
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1485
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1486
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1487
|
+
...issuerCredentialSubjectLocales.keys(),
|
|
1488
|
+
...credentialDisplayLocales.keys()
|
|
1489
|
+
]));
|
|
1490
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1491
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1492
|
+
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1493
|
+
return {
|
|
1494
|
+
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1495
|
+
credentialDisplay: display
|
|
1496
|
+
}),
|
|
1497
|
+
...locale.length > 0 && {
|
|
1498
|
+
locale
|
|
1587
1499
|
},
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1500
|
+
claims
|
|
1501
|
+
};
|
|
1502
|
+
}));
|
|
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
|
+
})
|
|
1511
|
+
},
|
|
1512
|
+
...credentialDisplay && {
|
|
1513
|
+
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1514
|
+
credentialDisplay
|
|
1515
|
+
})
|
|
1594
1516
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1517
|
+
});
|
|
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
|
|
1600
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
|
|
1550
|
+
},
|
|
1551
|
+
...credentialDisplay.lang && {
|
|
1552
|
+
locale: credentialDisplay.lang
|
|
1553
|
+
},
|
|
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
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
},
|
|
1564
|
+
...credentialDisplay.description && {
|
|
1565
|
+
description: credentialDisplay.description
|
|
1566
|
+
},
|
|
1567
|
+
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1568
|
+
text: {
|
|
1569
|
+
color: credentialDisplay.rendering.simple.text_color
|
|
1570
|
+
}
|
|
1571
|
+
},
|
|
1572
|
+
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1573
|
+
background: {
|
|
1574
|
+
color: credentialDisplay.rendering.simple.background_color
|
|
1575
|
+
}
|
|
1601
1576
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1577
|
+
};
|
|
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
|
|
1594
|
+
},
|
|
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
|
|
1621
|
+
}
|
|
1608
1622
|
}
|
|
1609
|
-
|
|
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
|
|
1610
1643
|
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
};
|
|
1644
|
+
};
|
|
1645
|
+
}, "issuerLocaleBrandingFrom");
|
|
1614
1646
|
|
|
1615
1647
|
// src/services/OID4VCIHolderService.ts
|
|
1616
|
-
var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
|
|
1617
1648
|
var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
|
|
1618
1649
|
const { credentialsSupported, context } = args;
|
|
1619
1650
|
const credentialBranding = {};
|
|
@@ -1685,16 +1716,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
|
|
|
1685
1716
|
}, "selectCredentialLocaleBranding");
|
|
1686
1717
|
var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1687
1718
|
const { mappedCredential, hasher, onVerifyEBSICredentialIssuer, schemaValidation, context } = args;
|
|
1688
|
-
const
|
|
1689
|
-
let credential;
|
|
1690
|
-
if ("credential" in credentialResponse) {
|
|
1691
|
-
credential = credentialResponse.credential;
|
|
1692
|
-
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1693
|
-
credential = credentialResponse.credentials[0].credential;
|
|
1694
|
-
}
|
|
1695
|
-
if (!credential) {
|
|
1696
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1697
|
-
}
|
|
1719
|
+
const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
|
|
1698
1720
|
const wrappedVC = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(credential, {
|
|
1699
1721
|
hasher: hasher ?? import_ssi_sdk.defaultHasher
|
|
1700
1722
|
});
|
|
@@ -1746,22 +1768,13 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1746
1768
|
}, "verifyCredentialToAccept");
|
|
1747
1769
|
var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1748
1770
|
const { credentialToAccept, hasher } = args;
|
|
1749
|
-
const
|
|
1750
|
-
let verifiableCredential;
|
|
1751
|
-
if ("credential" in credentialResponse) {
|
|
1752
|
-
verifiableCredential = credentialResponse.credential;
|
|
1753
|
-
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1754
|
-
verifiableCredential = credentialResponse.credentials[0].credential;
|
|
1755
|
-
}
|
|
1756
|
-
if (!verifiableCredential) {
|
|
1757
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1758
|
-
}
|
|
1771
|
+
const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
|
|
1759
1772
|
const wrappedVerifiableCredential = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
|
|
1760
1773
|
hasher
|
|
1761
1774
|
});
|
|
1762
1775
|
let uniformVerifiableCredential;
|
|
1763
1776
|
if (import_ssi_types.CredentialMapper.isSdJwtDecodedCredential(wrappedVerifiableCredential.credential)) {
|
|
1764
|
-
uniformVerifiableCredential =
|
|
1777
|
+
uniformVerifiableCredential = (0, import_ssi_types.sdJwtDecodedCredentialToUniformCredential)(wrappedVerifiableCredential.credential);
|
|
1765
1778
|
} else if (import_ssi_types.CredentialMapper.isSdJwtEncoded(wrappedVerifiableCredential.credential)) {
|
|
1766
1779
|
if (!hasher) {
|
|
1767
1780
|
return Promise.reject("a hasher is required for encoded SD-JWT credentials");
|
|
@@ -1775,6 +1788,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1775
1788
|
uniformVerifiableCredential = wrappedVerifiableCredential.credential;
|
|
1776
1789
|
}
|
|
1777
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;
|
|
1778
1792
|
return {
|
|
1779
1793
|
correlationId,
|
|
1780
1794
|
credentialToAccept,
|
|
@@ -1786,6 +1800,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1786
1800
|
}
|
|
1787
1801
|
};
|
|
1788
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");
|
|
1789
1815
|
var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
1790
1816
|
const { issuanceOpt, context } = args;
|
|
1791
1817
|
const { identifier: identifierArg } = issuanceOpt;
|
|
@@ -1894,24 +1920,19 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
|
|
|
1894
1920
|
}
|
|
1895
1921
|
__name(createIdFromTypes, "createIdFromTypes");
|
|
1896
1922
|
if (configurationId) {
|
|
1897
|
-
const allSupported2 = client.getCredentialsSupported(
|
|
1923
|
+
const allSupported2 = client.getCredentialsSupported(void 0, format);
|
|
1898
1924
|
return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
|
|
1899
1925
|
}
|
|
1900
|
-
if (!
|
|
1901
|
-
return Promise.reject(Error("openID4VCIClient has no credentialOffer
|
|
1926
|
+
if (!client.credentialOffer) {
|
|
1927
|
+
return Promise.reject(Error("openID4VCIClient has no credentialOffer"));
|
|
1902
1928
|
}
|
|
1903
|
-
if (!
|
|
1904
|
-
|
|
1905
|
-
format = client.credentialOffer.credential_offer.credentials.filter((cred) => typeof cred !== "string").map((cred) => cred.format);
|
|
1906
|
-
if (format?.length === 0) {
|
|
1907
|
-
format = void 0;
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1929
|
+
if (!types) {
|
|
1930
|
+
return Promise.reject(Error("openID4VCIClient has no types"));
|
|
1910
1931
|
}
|
|
1911
1932
|
const offerSupported = (0, import_oid4vci_common3.getSupportedCredentials)({
|
|
1912
|
-
types:
|
|
1933
|
+
types: [
|
|
1913
1934
|
types
|
|
1914
|
-
]
|
|
1935
|
+
],
|
|
1915
1936
|
format,
|
|
1916
1937
|
version: client.version(),
|
|
1917
1938
|
issuerMetadata: client.endpointMetadata.credentialIssuerMetadata
|
|
@@ -2086,7 +2107,7 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
|
|
|
2086
2107
|
case "jwt":
|
|
2087
2108
|
case "jwt_vc_json":
|
|
2088
2109
|
case "jwt_vc":
|
|
2089
|
-
case
|
|
2110
|
+
//case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
2090
2111
|
case "dc+sd-jwt":
|
|
2091
2112
|
case "mso_mdoc": {
|
|
2092
2113
|
const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
|
|
@@ -2155,7 +2176,6 @@ var startFirstPartApplicationMachine = /* @__PURE__ */ __name(async (args, conte
|
|
|
2155
2176
|
}, "startFirstPartApplicationMachine");
|
|
2156
2177
|
|
|
2157
2178
|
// src/agent/OID4VCIHolder.ts
|
|
2158
|
-
var import_polyfill = require("cross-fetch/polyfill");
|
|
2159
2179
|
var oid4vciHolderContextMethods = [
|
|
2160
2180
|
"cmGetContacts",
|
|
2161
2181
|
"cmGetContact",
|
|
@@ -2211,6 +2231,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2211
2231
|
oid4vciHolderStart: this.oid4vciHolderStart.bind(this),
|
|
2212
2232
|
oid4vciHolderGetIssuerMetadata: this.oid4vciHolderGetIssuerMetadata.bind(this),
|
|
2213
2233
|
oid4vciHolderGetMachineInterpreter: this.oid4vciHolderGetMachineInterpreter.bind(this),
|
|
2234
|
+
oid4vciHolderPrepareAuthorizationRequest: this.oid4vciHolderPrepareAuthorizationRequest.bind(this),
|
|
2214
2235
|
oid4vciHolderCreateCredentialsToSelectFrom: this.oid4vciHolderCreateCredentialsToSelectFrom.bind(this),
|
|
2215
2236
|
oid4vciHolderGetContact: this.oid4vciHolderGetContact.bind(this),
|
|
2216
2237
|
oid4vciHolderGetCredentials: this.oid4vciHolderGetCredentials.bind(this),
|
|
@@ -2315,6 +2336,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2315
2336
|
stateNavigationListener: opts.firstPartyStateNavigationListener
|
|
2316
2337
|
}, context),
|
|
2317
2338
|
[OID4VCIMachineServices.createCredentialsToSelectFrom]: (args) => this.oid4vciHolderCreateCredentialsToSelectFrom(args, context),
|
|
2339
|
+
[OID4VCIMachineServices.prepareAuthorizationRequest]: (args) => this.oid4vciHolderPrepareAuthorizationRequest(args, context),
|
|
2318
2340
|
[OID4VCIMachineServices.getContact]: (args) => this.oid4vciHolderGetContact(args, context),
|
|
2319
2341
|
[OID4VCIMachineServices.getCredentials]: (args) => this.oid4vciHolderGetCredentials({
|
|
2320
2342
|
accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts,
|
|
@@ -2376,10 +2398,9 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2376
2398
|
formats = Array.from(new Set(authFormats));
|
|
2377
2399
|
}
|
|
2378
2400
|
let oid4vciClient;
|
|
2379
|
-
let types = void 0;
|
|
2380
2401
|
let offer;
|
|
2381
2402
|
if (requestData.existingClientState) {
|
|
2382
|
-
oid4vciClient = await import_oid4vci_client3.
|
|
2403
|
+
oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromState({
|
|
2383
2404
|
state: requestData.existingClientState
|
|
2384
2405
|
});
|
|
2385
2406
|
offer = oid4vciClient.credentialOffer;
|
|
@@ -2396,50 +2417,76 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2396
2417
|
}
|
|
2397
2418
|
if (!offer) {
|
|
2398
2419
|
logger.log(`Issuer url received (no credential offer): ${uri}`);
|
|
2399
|
-
oid4vciClient = await import_oid4vci_client3.
|
|
2420
|
+
oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromCredentialIssuer({
|
|
2400
2421
|
credentialIssuer: uri,
|
|
2401
2422
|
authorizationRequest: authorizationRequestOpts,
|
|
2402
2423
|
clientId: authorizationRequestOpts.clientId,
|
|
2403
|
-
createAuthorizationRequestURL:
|
|
2424
|
+
createAuthorizationRequestURL: false
|
|
2404
2425
|
});
|
|
2405
2426
|
} else {
|
|
2406
2427
|
logger.log(`Credential offer received: ${uri}`);
|
|
2407
|
-
oid4vciClient = await import_oid4vci_client3.
|
|
2428
|
+
oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromURI({
|
|
2408
2429
|
uri,
|
|
2409
2430
|
authorizationRequest: authorizationRequestOpts,
|
|
2410
2431
|
clientId: authorizationRequestOpts.clientId,
|
|
2411
|
-
createAuthorizationRequestURL:
|
|
2432
|
+
createAuthorizationRequestURL: false
|
|
2412
2433
|
});
|
|
2413
2434
|
}
|
|
2414
2435
|
}
|
|
2436
|
+
let configurationIds = [];
|
|
2415
2437
|
if (offer) {
|
|
2416
|
-
|
|
2438
|
+
configurationIds = offer.original_credential_offer.credential_configuration_ids;
|
|
2417
2439
|
} else {
|
|
2418
|
-
|
|
2440
|
+
configurationIds = (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails).filter((authDetails) => typeof authDetails !== "string").map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
|
|
2419
2441
|
}
|
|
2420
|
-
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2421
2442
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
2422
2443
|
client: oid4vciClient,
|
|
2423
2444
|
vcFormatPreferences: formats,
|
|
2424
|
-
|
|
2445
|
+
configurationIds
|
|
2425
2446
|
});
|
|
2447
|
+
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2426
2448
|
const credentialBranding = await getCredentialBranding({
|
|
2427
2449
|
credentialsSupported,
|
|
2428
2450
|
context
|
|
2429
2451
|
});
|
|
2430
|
-
const authorizationCodeURL = oid4vciClient.authorizationURL;
|
|
2431
|
-
if (authorizationCodeURL) {
|
|
2432
|
-
logger.log(`authorization code URL ${authorizationCodeURL}`);
|
|
2433
|
-
}
|
|
2434
2452
|
const oid4vciClientState = JSON.parse(await oid4vciClient.exportState());
|
|
2435
2453
|
return {
|
|
2436
|
-
authorizationCodeURL,
|
|
2437
2454
|
credentialBranding,
|
|
2438
2455
|
credentialsSupported,
|
|
2439
2456
|
serverMetadata,
|
|
2440
2457
|
oid4vciClientState
|
|
2441
2458
|
};
|
|
2442
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
|
+
}
|
|
2443
2490
|
async oid4vciHolderCreateCredentialsToSelectFrom(args, context) {
|
|
2444
2491
|
const { credentialBranding, locale, selectedCredentials, credentialsSupported } = args;
|
|
2445
2492
|
logger.info(`Credentials supported ${Object.keys(credentialsSupported).join(", ")}`);
|
|
@@ -2511,7 +2558,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2511
2558
|
if (!openID4VCIClientState) {
|
|
2512
2559
|
return Promise.reject(Error("Missing openID4VCI client state in context"));
|
|
2513
2560
|
}
|
|
2514
|
-
const client = await import_oid4vci_client3.
|
|
2561
|
+
const client = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromState({
|
|
2515
2562
|
state: openID4VCIClientState
|
|
2516
2563
|
});
|
|
2517
2564
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
@@ -2650,7 +2697,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2650
2697
|
alias: credentialsToAccept[0].correlationId,
|
|
2651
2698
|
origin: import_ssi_sdk3.IdentityOrigin.EXTERNAL,
|
|
2652
2699
|
roles: [
|
|
2653
|
-
|
|
2700
|
+
import_ssi_types2.CredentialRole.ISSUER
|
|
2654
2701
|
],
|
|
2655
2702
|
identifier: {
|
|
2656
2703
|
type: identifierType,
|
|
@@ -2685,7 +2732,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2685
2732
|
}
|
|
2686
2733
|
async oid4vciHolderGetIssuerBranding(args, context) {
|
|
2687
2734
|
const { serverMetadata, contact } = args;
|
|
2688
|
-
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];
|
|
2689
2736
|
if (issuerCorrelationId) {
|
|
2690
2737
|
const branding = await context.agent.ibGetIssuerBranding({
|
|
2691
2738
|
filter: [
|
|
@@ -2715,7 +2762,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2715
2762
|
if (!contact) {
|
|
2716
2763
|
return Promise.reject(Error("Missing contact in context"));
|
|
2717
2764
|
}
|
|
2718
|
-
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];
|
|
2719
2766
|
const branding = await context.agent.ibGetIssuerBranding({
|
|
2720
2767
|
filter: [
|
|
2721
2768
|
{
|
|
@@ -2811,16 +2858,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2811
2858
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2812
2859
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2813
2860
|
logger.log(`Subject issuance/signing will be used, with event`, event);
|
|
2814
|
-
const
|
|
2815
|
-
let issuerVC;
|
|
2816
|
-
if ("credential" in credentialResponse) {
|
|
2817
|
-
issuerVC = credentialResponse.credential;
|
|
2818
|
-
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
2819
|
-
issuerVC = credentialResponse.credentials[0].credential;
|
|
2820
|
-
}
|
|
2821
|
-
if (!issuerVC) {
|
|
2822
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
2823
|
-
}
|
|
2861
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
|
|
2824
2862
|
const wrappedIssuerVC = import_ssi_types2.CredentialMapper.toWrappedVerifiableCredential(issuerVC, {
|
|
2825
2863
|
hasher: this.hasher ?? import_ssi_sdk2.defaultHasher
|
|
2826
2864
|
});
|
|
@@ -2926,7 +2964,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2926
2964
|
rawDocument: (0, import_ssi_sdk3.ensureRawDocument)(persistCredential),
|
|
2927
2965
|
kmsKeyRef,
|
|
2928
2966
|
identifierMethod: method,
|
|
2929
|
-
credentialRole:
|
|
2967
|
+
credentialRole: import_ssi_types2.CredentialRole.HOLDER,
|
|
2930
2968
|
issuerCorrelationType: issuer?.startsWith("did:") ? import_ssi_sdk3.CredentialCorrelationType.DID : import_ssi_sdk3.CredentialCorrelationType.URL,
|
|
2931
2969
|
issuerCorrelationId: issuer,
|
|
2932
2970
|
subjectCorrelationType,
|