@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.js
CHANGED
|
@@ -55,15 +55,16 @@ var require_nl = __commonJS({
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
// src/agent/OID4VCIHolder.ts
|
|
58
|
-
import { CredentialOfferClient, MetadataClient, OpenID4VCIClient as OpenID4VCIClient2 } from "@sphereon/oid4vci-client";
|
|
59
|
-
import { DefaultURISchemes,
|
|
58
|
+
import { CredentialOfferClient, MetadataClient, OpenID4VCIClient as OpenID4VCIClient2, OpenID4VCIClientV1_0_15 } from "@sphereon/oid4vci-client";
|
|
59
|
+
import { DefaultURISchemes, getTypesFromObject as getTypesFromObject2 } from "@sphereon/oid4vci-common";
|
|
60
60
|
import { SupportedDidMethodEnum as SupportedDidMethodEnum2 } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
61
61
|
import { isManagedIdentifierDidOpts, isManagedIdentifierDidResult as isManagedIdentifierDidResult2, isManagedIdentifierJwkResult, isManagedIdentifierKidResult, isManagedIdentifierResult as isManagedIdentifierResult2, isManagedIdentifierX5cOpts, isManagedIdentifierX5cResult } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
62
62
|
import { signatureAlgorithmFromKey } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
63
63
|
import { defaultHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
64
|
-
import { ConnectionType, CorrelationIdentifierType, CredentialCorrelationType,
|
|
65
|
-
import { CredentialMapper as CredentialMapper2, JoseSignatureAlgorithm as JoseSignatureAlgorithm2, Loggers, parseDid } from "@sphereon/ssi-types";
|
|
64
|
+
import { ConnectionType, CorrelationIdentifierType, CredentialCorrelationType, ensureRawDocument, IdentityOrigin } from "@sphereon/ssi-sdk.data-store-types";
|
|
65
|
+
import { CredentialMapper as CredentialMapper2, CredentialRole, JoseSignatureAlgorithm as JoseSignatureAlgorithm2, Loggers, parseDid } from "@sphereon/ssi-types";
|
|
66
66
|
import { asArray as asArray2, computeEntryHash } from "@veramo/utils";
|
|
67
|
+
import fetch from "cross-fetch";
|
|
67
68
|
import { decodeJWT } from "did-jwt";
|
|
68
69
|
import { v4 as uuidv42 } from "uuid";
|
|
69
70
|
|
|
@@ -76,18 +77,18 @@ import i18n from "i18n-js";
|
|
|
76
77
|
import memoize from "lodash.memoize";
|
|
77
78
|
|
|
78
79
|
// src/types/IOID4VCIHolder.ts
|
|
79
|
-
var OID4VCIHolderEvent = /* @__PURE__ */ function(OID4VCIHolderEvent2) {
|
|
80
|
+
var OID4VCIHolderEvent = /* @__PURE__ */ (function(OID4VCIHolderEvent2) {
|
|
80
81
|
OID4VCIHolderEvent2["CONTACT_IDENTITY_CREATED"] = "contact_identity_created";
|
|
81
82
|
OID4VCIHolderEvent2["CREDENTIAL_STORED"] = "credential_stored";
|
|
82
83
|
OID4VCIHolderEvent2["IDENTIFIER_CREATED"] = "identifier_created";
|
|
83
84
|
return OID4VCIHolderEvent2;
|
|
84
|
-
}({});
|
|
85
|
-
var SupportedLanguage = /* @__PURE__ */ function(SupportedLanguage2) {
|
|
85
|
+
})({});
|
|
86
|
+
var SupportedLanguage = /* @__PURE__ */ (function(SupportedLanguage2) {
|
|
86
87
|
SupportedLanguage2["ENGLISH"] = "en";
|
|
87
88
|
SupportedLanguage2["DUTCH"] = "nl";
|
|
88
89
|
return SupportedLanguage2;
|
|
89
|
-
}({});
|
|
90
|
-
var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
90
|
+
})({});
|
|
91
|
+
var OID4VCIMachineStates = /* @__PURE__ */ (function(OID4VCIMachineStates2) {
|
|
91
92
|
OID4VCIMachineStates2["start"] = "start";
|
|
92
93
|
OID4VCIMachineStates2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
93
94
|
OID4VCIMachineStates2["getContact"] = "getContact";
|
|
@@ -103,6 +104,7 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
103
104
|
OID4VCIMachineStates2["selectCredentials"] = "selectCredentials";
|
|
104
105
|
OID4VCIMachineStates2["transitionFromSelectingCredentials"] = "transitionFromSelectingCredentials";
|
|
105
106
|
OID4VCIMachineStates2["verifyPin"] = "verifyPin";
|
|
107
|
+
OID4VCIMachineStates2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
106
108
|
OID4VCIMachineStates2["initiateAuthorizationRequest"] = "initiateAuthorizationRequest";
|
|
107
109
|
OID4VCIMachineStates2["waitForAuthorizationResponse"] = "waitForAuthorizationResponse";
|
|
108
110
|
OID4VCIMachineStates2["getCredentials"] = "getCredentials";
|
|
@@ -118,18 +120,18 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
118
120
|
OID4VCIMachineStates2["error"] = "error";
|
|
119
121
|
OID4VCIMachineStates2["done"] = "done";
|
|
120
122
|
return OID4VCIMachineStates2;
|
|
121
|
-
}({});
|
|
122
|
-
var OID4VCIMachineAddContactStates = /* @__PURE__ */ function(OID4VCIMachineAddContactStates2) {
|
|
123
|
+
})({});
|
|
124
|
+
var OID4VCIMachineAddContactStates = /* @__PURE__ */ (function(OID4VCIMachineAddContactStates2) {
|
|
123
125
|
OID4VCIMachineAddContactStates2["idle"] = "idle";
|
|
124
126
|
OID4VCIMachineAddContactStates2["next"] = "next";
|
|
125
127
|
return OID4VCIMachineAddContactStates2;
|
|
126
|
-
}({});
|
|
127
|
-
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ function(OID4VCIMachineVerifyPinStates2) {
|
|
128
|
+
})({});
|
|
129
|
+
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ (function(OID4VCIMachineVerifyPinStates2) {
|
|
128
130
|
OID4VCIMachineVerifyPinStates2["idle"] = "idle";
|
|
129
131
|
OID4VCIMachineVerifyPinStates2["next"] = "next";
|
|
130
132
|
return OID4VCIMachineVerifyPinStates2;
|
|
131
|
-
}({});
|
|
132
|
-
var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
133
|
+
})({});
|
|
134
|
+
var OID4VCIMachineEvents = /* @__PURE__ */ (function(OID4VCIMachineEvents2) {
|
|
133
135
|
OID4VCIMachineEvents2["NEXT"] = "NEXT";
|
|
134
136
|
OID4VCIMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
135
137
|
OID4VCIMachineEvents2["DECLINE"] = "DECLINE";
|
|
@@ -142,8 +144,8 @@ var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
|
142
144
|
OID4VCIMachineEvents2["INVOKED_AUTHORIZATION_CODE_REQUEST"] = "INVOKED_AUTHORIZATION_CODE_REQUEST";
|
|
143
145
|
OID4VCIMachineEvents2["PROVIDE_AUTHORIZATION_CODE_RESPONSE"] = "PROVIDE_AUTHORIZATION_CODE_RESPONSE";
|
|
144
146
|
return OID4VCIMachineEvents2;
|
|
145
|
-
}({});
|
|
146
|
-
var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
147
|
+
})({});
|
|
148
|
+
var OID4VCIMachineGuards = /* @__PURE__ */ (function(OID4VCIMachineGuards2) {
|
|
147
149
|
OID4VCIMachineGuards2["hasContactGuard"] = "oid4vciHasContactGuard";
|
|
148
150
|
OID4VCIMachineGuards2["hasNoContactGuard"] = "oid4vciHasNoContactGuard";
|
|
149
151
|
OID4VCIMachineGuards2["credentialsToSelectRequiredGuard"] = "oid4vciCredentialsToSelectRequiredGuard";
|
|
@@ -160,13 +162,14 @@ var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
|
160
162
|
OID4VCIMachineGuards2["contactHasLowTrustGuard"] = "oid4vciContactHasLowTrustGuard";
|
|
161
163
|
OID4VCIMachineGuards2["isFirstPartyApplication"] = "oid4vciIsFirstPartyApplication";
|
|
162
164
|
return OID4VCIMachineGuards2;
|
|
163
|
-
}({});
|
|
164
|
-
var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
165
|
+
})({});
|
|
166
|
+
var OID4VCIMachineServices = /* @__PURE__ */ (function(OID4VCIMachineServices2) {
|
|
165
167
|
OID4VCIMachineServices2["start"] = "start";
|
|
166
168
|
OID4VCIMachineServices2["getContact"] = "getContact";
|
|
167
169
|
OID4VCIMachineServices2["getFederationTrust"] = "getFederationTrust";
|
|
168
170
|
OID4VCIMachineServices2["addContactIdentity"] = "addContactIdentity";
|
|
169
171
|
OID4VCIMachineServices2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
172
|
+
OID4VCIMachineServices2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
170
173
|
OID4VCIMachineServices2["getIssuerBranding"] = "getIssuerBranding";
|
|
171
174
|
OID4VCIMachineServices2["storeIssuerBranding"] = "storeIssuerBranding";
|
|
172
175
|
OID4VCIMachineServices2["getCredentials"] = "getCredentials";
|
|
@@ -176,17 +179,17 @@ var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
|
176
179
|
OID4VCIMachineServices2["storeCredentials"] = "storeCredentials";
|
|
177
180
|
OID4VCIMachineServices2["startFirstPartApplicationFlow"] = "startFirstPartApplicationFlow";
|
|
178
181
|
return OID4VCIMachineServices2;
|
|
179
|
-
}({});
|
|
180
|
-
var RequestType = /* @__PURE__ */ function(RequestType2) {
|
|
182
|
+
})({});
|
|
183
|
+
var RequestType = /* @__PURE__ */ (function(RequestType2) {
|
|
181
184
|
RequestType2["OPENID_INITIATE_ISSUANCE"] = "openid-initiate-issuance";
|
|
182
185
|
RequestType2["OPENID_CREDENTIAL_OFFER"] = "openid-credential-offer";
|
|
183
186
|
RequestType2["URL"] = "URL";
|
|
184
187
|
return RequestType2;
|
|
185
|
-
}({});
|
|
186
|
-
var IdentifierAliasEnum = /* @__PURE__ */ function(IdentifierAliasEnum2) {
|
|
188
|
+
})({});
|
|
189
|
+
var IdentifierAliasEnum = /* @__PURE__ */ (function(IdentifierAliasEnum2) {
|
|
187
190
|
IdentifierAliasEnum2["PRIMARY"] = "primary";
|
|
188
191
|
return IdentifierAliasEnum2;
|
|
189
|
-
}({});
|
|
192
|
+
})({});
|
|
190
193
|
|
|
191
194
|
// src/localization/Localization.ts
|
|
192
195
|
var Localization = class Localization2 {
|
|
@@ -228,7 +231,7 @@ var Localization = class Localization2 {
|
|
|
228
231
|
var translate = Localization.translate;
|
|
229
232
|
|
|
230
233
|
// src/types/FirstPartyMachine.ts
|
|
231
|
-
var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStateTypes2) {
|
|
234
|
+
var FirstPartyMachineStateTypes = /* @__PURE__ */ (function(FirstPartyMachineStateTypes2) {
|
|
232
235
|
FirstPartyMachineStateTypes2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
233
236
|
FirstPartyMachineStateTypes2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
234
237
|
FirstPartyMachineStateTypes2["selectCredentials"] = "selectCredentials";
|
|
@@ -239,21 +242,21 @@ var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStat
|
|
|
239
242
|
FirstPartyMachineStateTypes2["aborted"] = "aborted";
|
|
240
243
|
FirstPartyMachineStateTypes2["declined"] = "declined";
|
|
241
244
|
return FirstPartyMachineStateTypes2;
|
|
242
|
-
}({});
|
|
243
|
-
var FirstPartyMachineServices = /* @__PURE__ */ function(FirstPartyMachineServices2) {
|
|
245
|
+
})({});
|
|
246
|
+
var FirstPartyMachineServices = /* @__PURE__ */ (function(FirstPartyMachineServices2) {
|
|
244
247
|
FirstPartyMachineServices2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
245
248
|
FirstPartyMachineServices2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
246
249
|
FirstPartyMachineServices2["createConfig"] = "createConfig";
|
|
247
250
|
FirstPartyMachineServices2["getSiopRequest"] = "getSiopRequest";
|
|
248
251
|
return FirstPartyMachineServices2;
|
|
249
|
-
}({});
|
|
250
|
-
var FirstPartyMachineEvents = /* @__PURE__ */ function(FirstPartyMachineEvents2) {
|
|
252
|
+
})({});
|
|
253
|
+
var FirstPartyMachineEvents = /* @__PURE__ */ (function(FirstPartyMachineEvents2) {
|
|
251
254
|
FirstPartyMachineEvents2["NEXT"] = "NEXT";
|
|
252
255
|
FirstPartyMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
253
256
|
FirstPartyMachineEvents2["DECLINE"] = "DECLINE";
|
|
254
257
|
FirstPartyMachineEvents2["SET_SELECTED_CREDENTIALS"] = "SET_SELECTED_CREDENTIALS";
|
|
255
258
|
return FirstPartyMachineEvents2;
|
|
256
|
-
}({});
|
|
259
|
+
})({});
|
|
257
260
|
|
|
258
261
|
// src/machines/oid4vciMachine.ts
|
|
259
262
|
var oid4vciHasNoContactGuard = /* @__PURE__ */ __name((_ctx, _event) => {
|
|
@@ -308,9 +311,7 @@ var oid4vciRequireAuthorizationGuard = /* @__PURE__ */ __name((ctx, _event) => {
|
|
|
308
311
|
if (!openID4VCIClientState) {
|
|
309
312
|
throw Error("Missing openID4VCI client state in context");
|
|
310
313
|
}
|
|
311
|
-
if (
|
|
312
|
-
return false;
|
|
313
|
-
} else if (openID4VCIClientState.authorizationRequestOpts) {
|
|
314
|
+
if (openID4VCIClientState.authorizationURL && openID4VCIClientState.authorizationRequestOpts) {
|
|
314
315
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
315
316
|
} else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
|
|
316
317
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
@@ -361,7 +362,6 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
361
362
|
onDone: {
|
|
362
363
|
target: OID4VCIMachineStates.createCredentialsToSelectFrom,
|
|
363
364
|
actions: assign({
|
|
364
|
-
authorizationCodeURL: /* @__PURE__ */ __name((_ctx, _event) => _event.data.authorizationCodeURL, "authorizationCodeURL"),
|
|
365
365
|
credentialBranding: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialBranding ?? {}, "credentialBranding"),
|
|
366
366
|
credentialsSupported: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialsSupported, "credentialsSupported"),
|
|
367
367
|
serverMetadata: /* @__PURE__ */ __name((_ctx, _event) => _event.data.serverMetadata, "serverMetadata"),
|
|
@@ -598,6 +598,10 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
598
598
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
599
599
|
cond: OID4VCIMachineGuards.isFirstPartyApplication
|
|
600
600
|
},
|
|
601
|
+
{
|
|
602
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
603
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
604
|
+
},
|
|
601
605
|
{
|
|
602
606
|
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
603
607
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
@@ -673,12 +677,16 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
673
677
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
674
678
|
cond: OID4VCIMachineGuards.isFirstPartyApplication
|
|
675
679
|
},
|
|
680
|
+
{
|
|
681
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
682
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
683
|
+
},
|
|
676
684
|
{
|
|
677
685
|
target: OID4VCIMachineStates.verifyPin,
|
|
678
686
|
cond: OID4VCIMachineGuards.requirePinGuard
|
|
679
687
|
},
|
|
680
688
|
{
|
|
681
|
-
target: OID4VCIMachineStates.
|
|
689
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
682
690
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
683
691
|
},
|
|
684
692
|
{
|
|
@@ -686,6 +694,28 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
686
694
|
}
|
|
687
695
|
]
|
|
688
696
|
},
|
|
697
|
+
[OID4VCIMachineStates.prepareAuthorizationRequest]: {
|
|
698
|
+
id: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
699
|
+
invoke: {
|
|
700
|
+
src: OID4VCIMachineServices.prepareAuthorizationRequest,
|
|
701
|
+
onDone: {
|
|
702
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
703
|
+
actions: assign({
|
|
704
|
+
authorizationCodeURL: /* @__PURE__ */ __name((_ctx, _event) => _event.data.authorizationCodeURL, "authorizationCodeURL")
|
|
705
|
+
})
|
|
706
|
+
},
|
|
707
|
+
onError: {
|
|
708
|
+
target: OID4VCIMachineStates.handleError,
|
|
709
|
+
actions: assign({
|
|
710
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
711
|
+
title: translate("oid4vci_machine_prepare_authorization_error_title"),
|
|
712
|
+
message: _event.data.message,
|
|
713
|
+
stack: _event.data.stack
|
|
714
|
+
}), "error")
|
|
715
|
+
})
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
},
|
|
689
719
|
[OID4VCIMachineStates.initiateAuthorizationRequest]: {
|
|
690
720
|
id: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
691
721
|
on: {
|
|
@@ -978,276 +1008,15 @@ var OID4VCIMachine = class {
|
|
|
978
1008
|
|
|
979
1009
|
// src/services/OID4VCIHolderService.ts
|
|
980
1010
|
import { LOG } from "@sphereon/oid4vci-client";
|
|
981
|
-
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject
|
|
1011
|
+
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject } from "@sphereon/oid4vci-common";
|
|
982
1012
|
import { KeyUse } from "@sphereon/ssi-sdk-ext.did-resolver-jwk";
|
|
983
1013
|
import { getOrCreatePrimaryIdentifier, SupportedDidMethodEnum } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
984
1014
|
import { isIIdentifier, isManagedIdentifierDidResult, isManagedIdentifierResult, managedIdentifierToJwk } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
985
1015
|
import { keyTypeFromCryptographicSuite } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
1016
|
+
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
986
1017
|
import { CredentialMapper, JoseSignatureAlgorithm, mdocDecodedCredentialToUniformCredential, sdJwtDecodedCredentialToUniformCredential } from "@sphereon/ssi-types";
|
|
987
1018
|
import { asArray } from "@veramo/utils";
|
|
988
1019
|
|
|
989
|
-
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
990
|
-
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
991
|
-
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
992
|
-
return oid4vciCombineDisplayLocalesFrom({
|
|
993
|
-
...issuerCredentialSubject && {
|
|
994
|
-
issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
|
|
995
|
-
issuerCredentialSubject
|
|
996
|
-
})
|
|
997
|
-
},
|
|
998
|
-
...credentialDisplay && {
|
|
999
|
-
credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
|
|
1000
|
-
credentialDisplay
|
|
1001
|
-
})
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
}, "oid4vciGetCredentialBrandingFrom");
|
|
1005
|
-
var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1006
|
-
const { credentialDisplay } = args;
|
|
1007
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1008
|
-
const localeKey = display.locale || "";
|
|
1009
|
-
localeDisplays.set(localeKey, display);
|
|
1010
|
-
return localeDisplays;
|
|
1011
|
-
}, /* @__PURE__ */ new Map());
|
|
1012
|
-
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1013
|
-
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1014
|
-
const { issuerCredentialSubject } = args;
|
|
1015
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1016
|
-
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1017
|
-
Object.entries(claim).forEach(([key, value]) => {
|
|
1018
|
-
if (key === "mandatory" || key === "value_type") {
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
if (key === "display" && Array.isArray(value)) {
|
|
1022
|
-
value.forEach(({ name, locale = "" }) => {
|
|
1023
|
-
if (!name) {
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
if (!localeClaims.has(locale)) {
|
|
1027
|
-
localeClaims.set(locale, []);
|
|
1028
|
-
}
|
|
1029
|
-
localeClaims.get(locale).push({
|
|
1030
|
-
key: parentKey,
|
|
1031
|
-
name
|
|
1032
|
-
});
|
|
1033
|
-
});
|
|
1034
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1035
|
-
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
}, "processClaimObject");
|
|
1039
|
-
processClaimObject(issuerCredentialSubject);
|
|
1040
|
-
return localeClaims;
|
|
1041
|
-
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1042
|
-
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1043
|
-
const { credentialDisplay } = args;
|
|
1044
|
-
return {
|
|
1045
|
-
...credentialDisplay.name && {
|
|
1046
|
-
alias: credentialDisplay.name
|
|
1047
|
-
},
|
|
1048
|
-
...credentialDisplay.locale && {
|
|
1049
|
-
locale: credentialDisplay.locale
|
|
1050
|
-
},
|
|
1051
|
-
...credentialDisplay.logo && {
|
|
1052
|
-
logo: {
|
|
1053
|
-
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1054
|
-
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1055
|
-
},
|
|
1056
|
-
...credentialDisplay.logo.alt_text && {
|
|
1057
|
-
alt: credentialDisplay.logo?.alt_text
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
},
|
|
1061
|
-
...credentialDisplay.description && {
|
|
1062
|
-
description: credentialDisplay.description
|
|
1063
|
-
},
|
|
1064
|
-
...credentialDisplay.text_color && {
|
|
1065
|
-
text: {
|
|
1066
|
-
color: credentialDisplay.text_color
|
|
1067
|
-
}
|
|
1068
|
-
},
|
|
1069
|
-
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1070
|
-
background: {
|
|
1071
|
-
...credentialDisplay.background_image && {
|
|
1072
|
-
image: {
|
|
1073
|
-
...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
|
|
1074
|
-
uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
|
|
1075
|
-
},
|
|
1076
|
-
...credentialDisplay.background_image.alt_text && {
|
|
1077
|
-
alt: credentialDisplay.background_image?.alt_text
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
},
|
|
1081
|
-
...credentialDisplay.background_color && {
|
|
1082
|
-
color: credentialDisplay.background_color
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1088
|
-
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1089
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1090
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1091
|
-
...issuerCredentialSubjectLocales.keys(),
|
|
1092
|
-
...credentialDisplayLocales.keys()
|
|
1093
|
-
]));
|
|
1094
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1095
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1096
|
-
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1097
|
-
return {
|
|
1098
|
-
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1099
|
-
credentialDisplay: display
|
|
1100
|
-
}),
|
|
1101
|
-
...locale.length > 0 && {
|
|
1102
|
-
locale
|
|
1103
|
-
},
|
|
1104
|
-
claims
|
|
1105
|
-
};
|
|
1106
|
-
}));
|
|
1107
|
-
}, "oid4vciCombineDisplayLocalesFrom");
|
|
1108
|
-
var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1109
|
-
const { credentialDisplay, claimsMetadata } = args;
|
|
1110
|
-
return sdJwtCombineDisplayLocalesFrom({
|
|
1111
|
-
...claimsMetadata && {
|
|
1112
|
-
claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
|
|
1113
|
-
claimsMetadata
|
|
1114
|
-
})
|
|
1115
|
-
},
|
|
1116
|
-
...credentialDisplay && {
|
|
1117
|
-
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1118
|
-
credentialDisplay
|
|
1119
|
-
})
|
|
1120
|
-
}
|
|
1121
|
-
});
|
|
1122
|
-
}, "sdJwtGetCredentialBrandingFrom");
|
|
1123
|
-
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1124
|
-
const { credentialDisplay } = args;
|
|
1125
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1126
|
-
const localeKey = display.lang || "";
|
|
1127
|
-
localeDisplays.set(localeKey, display);
|
|
1128
|
-
return localeDisplays;
|
|
1129
|
-
}, /* @__PURE__ */ new Map());
|
|
1130
|
-
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1131
|
-
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1132
|
-
const { claimsMetadata } = args;
|
|
1133
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1134
|
-
claimsMetadata.forEach((claim) => {
|
|
1135
|
-
claim.display?.forEach((display) => {
|
|
1136
|
-
const { lang = "", label } = display;
|
|
1137
|
-
const key = claim.path.map((value) => String(value)).join(".");
|
|
1138
|
-
if (!localeClaims.has(lang)) {
|
|
1139
|
-
localeClaims.set(lang, []);
|
|
1140
|
-
}
|
|
1141
|
-
localeClaims.get(lang).push({
|
|
1142
|
-
key,
|
|
1143
|
-
name: label
|
|
1144
|
-
});
|
|
1145
|
-
});
|
|
1146
|
-
});
|
|
1147
|
-
return localeClaims;
|
|
1148
|
-
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1149
|
-
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1150
|
-
const { credentialDisplay } = args;
|
|
1151
|
-
return {
|
|
1152
|
-
...credentialDisplay.name && {
|
|
1153
|
-
alias: credentialDisplay.name
|
|
1154
|
-
},
|
|
1155
|
-
...credentialDisplay.lang && {
|
|
1156
|
-
locale: credentialDisplay.lang
|
|
1157
|
-
},
|
|
1158
|
-
...credentialDisplay.rendering?.simple?.logo && {
|
|
1159
|
-
logo: {
|
|
1160
|
-
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1161
|
-
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1162
|
-
},
|
|
1163
|
-
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1164
|
-
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
...credentialDisplay.description && {
|
|
1169
|
-
description: credentialDisplay.description
|
|
1170
|
-
},
|
|
1171
|
-
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1172
|
-
text: {
|
|
1173
|
-
color: credentialDisplay.rendering.simple.text_color
|
|
1174
|
-
}
|
|
1175
|
-
},
|
|
1176
|
-
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1177
|
-
background: {
|
|
1178
|
-
color: credentialDisplay.rendering.simple.background_color
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
};
|
|
1182
|
-
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1183
|
-
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1184
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1185
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1186
|
-
...claimsMetadata.keys(),
|
|
1187
|
-
...credentialDisplayLocales.keys()
|
|
1188
|
-
]));
|
|
1189
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1190
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1191
|
-
const claims = claimsMetadata.get(locale);
|
|
1192
|
-
return {
|
|
1193
|
-
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1194
|
-
credentialDisplay: display
|
|
1195
|
-
}),
|
|
1196
|
-
...locale.length > 0 && {
|
|
1197
|
-
locale
|
|
1198
|
-
},
|
|
1199
|
-
claims
|
|
1200
|
-
};
|
|
1201
|
-
}));
|
|
1202
|
-
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1203
|
-
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1204
|
-
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1205
|
-
return {
|
|
1206
|
-
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1207
|
-
alias: dynamicRegistrationClientMetadata.client_name
|
|
1208
|
-
},
|
|
1209
|
-
...issuerDisplay.name && {
|
|
1210
|
-
alias: issuerDisplay.name
|
|
1211
|
-
},
|
|
1212
|
-
...issuerDisplay.locale && {
|
|
1213
|
-
locale: issuerDisplay.locale
|
|
1214
|
-
},
|
|
1215
|
-
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1216
|
-
logo: {
|
|
1217
|
-
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1218
|
-
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1219
|
-
},
|
|
1220
|
-
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1221
|
-
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1222
|
-
},
|
|
1223
|
-
...issuerDisplay.logo?.alt_text && {
|
|
1224
|
-
alt: issuerDisplay.logo?.alt_text
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
},
|
|
1228
|
-
...issuerDisplay.description && {
|
|
1229
|
-
description: issuerDisplay.description
|
|
1230
|
-
},
|
|
1231
|
-
...issuerDisplay.text_color && {
|
|
1232
|
-
text: {
|
|
1233
|
-
color: issuerDisplay.text_color
|
|
1234
|
-
}
|
|
1235
|
-
},
|
|
1236
|
-
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1237
|
-
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1238
|
-
},
|
|
1239
|
-
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1240
|
-
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1241
|
-
},
|
|
1242
|
-
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1243
|
-
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1244
|
-
},
|
|
1245
|
-
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1246
|
-
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
}, "issuerLocaleBrandingFrom");
|
|
1250
|
-
|
|
1251
1020
|
// src/machines/firstPartyMachine.ts
|
|
1252
1021
|
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
1253
1022
|
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
@@ -1484,57 +1253,318 @@ var FirstPartyMachine = class _FirstPartyMachine {
|
|
|
1484
1253
|
_FirstPartyMachine.stopInstance();
|
|
1485
1254
|
}
|
|
1486
1255
|
}
|
|
1487
|
-
_FirstPartyMachine._instance = void 0;
|
|
1488
|
-
}
|
|
1489
|
-
static stopInstance() {
|
|
1490
|
-
if (!_FirstPartyMachine.hasInstance()) {
|
|
1491
|
-
return;
|
|
1492
|
-
}
|
|
1493
|
-
_FirstPartyMachine.instance.stop();
|
|
1494
|
-
_FirstPartyMachine._instance = void 0;
|
|
1495
|
-
}
|
|
1496
|
-
static newInstance(opts) {
|
|
1497
|
-
const { agentContext } = opts;
|
|
1498
|
-
const services = {
|
|
1499
|
-
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1500
|
-
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1501
|
-
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1502
|
-
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1503
|
-
};
|
|
1504
|
-
const newInst = interpret2(createFirstPartyActivationMachine(opts).withConfig({
|
|
1505
|
-
services: {
|
|
1506
|
-
...services,
|
|
1507
|
-
...opts?.services
|
|
1256
|
+
_FirstPartyMachine._instance = void 0;
|
|
1257
|
+
}
|
|
1258
|
+
static stopInstance() {
|
|
1259
|
+
if (!_FirstPartyMachine.hasInstance()) {
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
_FirstPartyMachine.instance.stop();
|
|
1263
|
+
_FirstPartyMachine._instance = void 0;
|
|
1264
|
+
}
|
|
1265
|
+
static newInstance(opts) {
|
|
1266
|
+
const { agentContext } = opts;
|
|
1267
|
+
const services = {
|
|
1268
|
+
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1269
|
+
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1270
|
+
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1271
|
+
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1272
|
+
};
|
|
1273
|
+
const newInst = interpret2(createFirstPartyActivationMachine(opts).withConfig({
|
|
1274
|
+
services: {
|
|
1275
|
+
...services,
|
|
1276
|
+
...opts?.services
|
|
1277
|
+
},
|
|
1278
|
+
guards: {
|
|
1279
|
+
...opts?.guards
|
|
1280
|
+
}
|
|
1281
|
+
}));
|
|
1282
|
+
if (typeof opts?.subscription === "function") {
|
|
1283
|
+
newInst.onTransition(opts.subscription);
|
|
1284
|
+
}
|
|
1285
|
+
if (opts?.requireCustomNavigationHook !== true) {
|
|
1286
|
+
newInst.onTransition((snapshot) => {
|
|
1287
|
+
if (opts?.stateNavigationListener) {
|
|
1288
|
+
void opts.stateNavigationListener(newInst, snapshot);
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
return newInst;
|
|
1293
|
+
}
|
|
1294
|
+
static getInstance(opts) {
|
|
1295
|
+
if (!_FirstPartyMachine._instance) {
|
|
1296
|
+
if (opts?.requireExisting === true) {
|
|
1297
|
+
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1298
|
+
}
|
|
1299
|
+
_FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
|
|
1300
|
+
}
|
|
1301
|
+
return _FirstPartyMachine._instance;
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
1306
|
+
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1307
|
+
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
1308
|
+
return oid4vciCombineDisplayLocalesFrom({
|
|
1309
|
+
...issuerCredentialSubject && {
|
|
1310
|
+
issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
|
|
1311
|
+
issuerCredentialSubject
|
|
1312
|
+
})
|
|
1313
|
+
},
|
|
1314
|
+
...credentialDisplay && {
|
|
1315
|
+
credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
|
|
1316
|
+
credentialDisplay
|
|
1317
|
+
})
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
}, "oid4vciGetCredentialBrandingFrom");
|
|
1321
|
+
var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1322
|
+
const { credentialDisplay } = args;
|
|
1323
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1324
|
+
const localeKey = display.locale || "";
|
|
1325
|
+
localeDisplays.set(localeKey, display);
|
|
1326
|
+
return localeDisplays;
|
|
1327
|
+
}, /* @__PURE__ */ new Map());
|
|
1328
|
+
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1329
|
+
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1330
|
+
const { issuerCredentialSubject } = args;
|
|
1331
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
1332
|
+
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1333
|
+
Object.entries(claim).forEach(([key, value]) => {
|
|
1334
|
+
if (key === "mandatory" || key === "value_type") {
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
if (key === "display" && Array.isArray(value)) {
|
|
1338
|
+
value.forEach(({ name, locale = "" }) => {
|
|
1339
|
+
if (!name) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
if (!localeClaims.has(locale)) {
|
|
1343
|
+
localeClaims.set(locale, []);
|
|
1344
|
+
}
|
|
1345
|
+
localeClaims.get(locale).push({
|
|
1346
|
+
key: parentKey,
|
|
1347
|
+
name
|
|
1348
|
+
});
|
|
1349
|
+
});
|
|
1350
|
+
} else if (typeof value === "object" && value !== null) {
|
|
1351
|
+
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1352
|
+
}
|
|
1353
|
+
});
|
|
1354
|
+
}, "processClaimObject");
|
|
1355
|
+
processClaimObject(issuerCredentialSubject);
|
|
1356
|
+
return localeClaims;
|
|
1357
|
+
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1358
|
+
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1359
|
+
const { credentialDisplay } = args;
|
|
1360
|
+
return {
|
|
1361
|
+
...credentialDisplay.name && {
|
|
1362
|
+
alias: credentialDisplay.name
|
|
1363
|
+
},
|
|
1364
|
+
...credentialDisplay.locale && {
|
|
1365
|
+
locale: credentialDisplay.locale
|
|
1366
|
+
},
|
|
1367
|
+
...credentialDisplay.logo && {
|
|
1368
|
+
logo: {
|
|
1369
|
+
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1370
|
+
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1371
|
+
},
|
|
1372
|
+
...credentialDisplay.logo.alt_text && {
|
|
1373
|
+
alt: credentialDisplay.logo?.alt_text
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
...credentialDisplay.description && {
|
|
1378
|
+
description: credentialDisplay.description
|
|
1379
|
+
},
|
|
1380
|
+
...credentialDisplay.text_color && {
|
|
1381
|
+
text: {
|
|
1382
|
+
color: credentialDisplay.text_color
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1386
|
+
background: {
|
|
1387
|
+
...credentialDisplay.background_image && {
|
|
1388
|
+
image: {
|
|
1389
|
+
...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
|
|
1390
|
+
uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
|
|
1391
|
+
},
|
|
1392
|
+
...credentialDisplay.background_image.alt_text && {
|
|
1393
|
+
alt: credentialDisplay.background_image?.alt_text
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
...credentialDisplay.background_color && {
|
|
1398
|
+
color: credentialDisplay.background_color
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1404
|
+
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1405
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1406
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1407
|
+
...issuerCredentialSubjectLocales.keys(),
|
|
1408
|
+
...credentialDisplayLocales.keys()
|
|
1409
|
+
]));
|
|
1410
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1411
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1412
|
+
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1413
|
+
return {
|
|
1414
|
+
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1415
|
+
credentialDisplay: display
|
|
1416
|
+
}),
|
|
1417
|
+
...locale.length > 0 && {
|
|
1418
|
+
locale
|
|
1508
1419
|
},
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1420
|
+
claims
|
|
1421
|
+
};
|
|
1422
|
+
}));
|
|
1423
|
+
}, "oid4vciCombineDisplayLocalesFrom");
|
|
1424
|
+
var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1425
|
+
const { credentialDisplay, claimsMetadata } = args;
|
|
1426
|
+
return sdJwtCombineDisplayLocalesFrom({
|
|
1427
|
+
...claimsMetadata && {
|
|
1428
|
+
claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
|
|
1429
|
+
claimsMetadata
|
|
1430
|
+
})
|
|
1431
|
+
},
|
|
1432
|
+
...credentialDisplay && {
|
|
1433
|
+
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1434
|
+
credentialDisplay
|
|
1435
|
+
})
|
|
1515
1436
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1437
|
+
});
|
|
1438
|
+
}, "sdJwtGetCredentialBrandingFrom");
|
|
1439
|
+
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1440
|
+
const { credentialDisplay } = args;
|
|
1441
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1442
|
+
const localeKey = display.lang || "";
|
|
1443
|
+
localeDisplays.set(localeKey, display);
|
|
1444
|
+
return localeDisplays;
|
|
1445
|
+
}, /* @__PURE__ */ new Map());
|
|
1446
|
+
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1447
|
+
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1448
|
+
const { claimsMetadata } = args;
|
|
1449
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
1450
|
+
claimsMetadata.forEach((claim) => {
|
|
1451
|
+
claim.display?.forEach((display) => {
|
|
1452
|
+
const { lang = "", label } = display;
|
|
1453
|
+
const key = claim.path.map((value) => String(value)).join(".");
|
|
1454
|
+
if (!localeClaims.has(lang)) {
|
|
1455
|
+
localeClaims.set(lang, []);
|
|
1456
|
+
}
|
|
1457
|
+
localeClaims.get(lang).push({
|
|
1458
|
+
key,
|
|
1459
|
+
name: label
|
|
1521
1460
|
});
|
|
1461
|
+
});
|
|
1462
|
+
});
|
|
1463
|
+
return localeClaims;
|
|
1464
|
+
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1465
|
+
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1466
|
+
const { credentialDisplay } = args;
|
|
1467
|
+
return {
|
|
1468
|
+
...credentialDisplay.name && {
|
|
1469
|
+
alias: credentialDisplay.name
|
|
1470
|
+
},
|
|
1471
|
+
...credentialDisplay.lang && {
|
|
1472
|
+
locale: credentialDisplay.lang
|
|
1473
|
+
},
|
|
1474
|
+
...credentialDisplay.rendering?.simple?.logo && {
|
|
1475
|
+
logo: {
|
|
1476
|
+
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1477
|
+
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1478
|
+
},
|
|
1479
|
+
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1480
|
+
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1484
|
+
...credentialDisplay.description && {
|
|
1485
|
+
description: credentialDisplay.description
|
|
1486
|
+
},
|
|
1487
|
+
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1488
|
+
text: {
|
|
1489
|
+
color: credentialDisplay.rendering.simple.text_color
|
|
1490
|
+
}
|
|
1491
|
+
},
|
|
1492
|
+
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1493
|
+
background: {
|
|
1494
|
+
color: credentialDisplay.rendering.simple.background_color
|
|
1495
|
+
}
|
|
1522
1496
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1497
|
+
};
|
|
1498
|
+
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1499
|
+
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1500
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1501
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1502
|
+
...claimsMetadata.keys(),
|
|
1503
|
+
...credentialDisplayLocales.keys()
|
|
1504
|
+
]));
|
|
1505
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1506
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1507
|
+
const claims = claimsMetadata.get(locale);
|
|
1508
|
+
return {
|
|
1509
|
+
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1510
|
+
credentialDisplay: display
|
|
1511
|
+
}),
|
|
1512
|
+
...locale.length > 0 && {
|
|
1513
|
+
locale
|
|
1514
|
+
},
|
|
1515
|
+
claims
|
|
1516
|
+
};
|
|
1517
|
+
}));
|
|
1518
|
+
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1519
|
+
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1520
|
+
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1521
|
+
return {
|
|
1522
|
+
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1523
|
+
alias: dynamicRegistrationClientMetadata.client_name
|
|
1524
|
+
},
|
|
1525
|
+
...issuerDisplay.name && {
|
|
1526
|
+
alias: issuerDisplay.name
|
|
1527
|
+
},
|
|
1528
|
+
...issuerDisplay.locale && {
|
|
1529
|
+
locale: issuerDisplay.locale
|
|
1530
|
+
},
|
|
1531
|
+
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1532
|
+
logo: {
|
|
1533
|
+
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1534
|
+
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1535
|
+
},
|
|
1536
|
+
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1537
|
+
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1538
|
+
},
|
|
1539
|
+
...issuerDisplay.logo?.alt_text && {
|
|
1540
|
+
alt: issuerDisplay.logo?.alt_text
|
|
1541
|
+
}
|
|
1529
1542
|
}
|
|
1530
|
-
|
|
1543
|
+
},
|
|
1544
|
+
...issuerDisplay.description && {
|
|
1545
|
+
description: issuerDisplay.description
|
|
1546
|
+
},
|
|
1547
|
+
...issuerDisplay.text_color && {
|
|
1548
|
+
text: {
|
|
1549
|
+
color: issuerDisplay.text_color
|
|
1550
|
+
}
|
|
1551
|
+
},
|
|
1552
|
+
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1553
|
+
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1554
|
+
},
|
|
1555
|
+
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1556
|
+
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1557
|
+
},
|
|
1558
|
+
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1559
|
+
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1560
|
+
},
|
|
1561
|
+
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1562
|
+
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1531
1563
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
};
|
|
1564
|
+
};
|
|
1565
|
+
}, "issuerLocaleBrandingFrom");
|
|
1535
1566
|
|
|
1536
1567
|
// src/services/OID4VCIHolderService.ts
|
|
1537
|
-
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
1538
1568
|
var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
|
|
1539
1569
|
const { credentialsSupported, context } = args;
|
|
1540
1570
|
const credentialBranding = {};
|
|
@@ -1606,16 +1636,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
|
|
|
1606
1636
|
}, "selectCredentialLocaleBranding");
|
|
1607
1637
|
var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1608
1638
|
const { mappedCredential, hasher, onVerifyEBSICredentialIssuer, schemaValidation, context } = args;
|
|
1609
|
-
const
|
|
1610
|
-
let credential;
|
|
1611
|
-
if ("credential" in credentialResponse) {
|
|
1612
|
-
credential = credentialResponse.credential;
|
|
1613
|
-
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1614
|
-
credential = credentialResponse.credentials[0].credential;
|
|
1615
|
-
}
|
|
1616
|
-
if (!credential) {
|
|
1617
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1618
|
-
}
|
|
1639
|
+
const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
|
|
1619
1640
|
const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credential, {
|
|
1620
1641
|
hasher: hasher ?? defaultHasher
|
|
1621
1642
|
});
|
|
@@ -1667,22 +1688,13 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1667
1688
|
}, "verifyCredentialToAccept");
|
|
1668
1689
|
var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1669
1690
|
const { credentialToAccept, hasher } = args;
|
|
1670
|
-
const
|
|
1671
|
-
let verifiableCredential;
|
|
1672
|
-
if ("credential" in credentialResponse) {
|
|
1673
|
-
verifiableCredential = credentialResponse.credential;
|
|
1674
|
-
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1675
|
-
verifiableCredential = credentialResponse.credentials[0].credential;
|
|
1676
|
-
}
|
|
1677
|
-
if (!verifiableCredential) {
|
|
1678
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1679
|
-
}
|
|
1691
|
+
const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
|
|
1680
1692
|
const wrappedVerifiableCredential = CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
|
|
1681
1693
|
hasher
|
|
1682
1694
|
});
|
|
1683
1695
|
let uniformVerifiableCredential;
|
|
1684
1696
|
if (CredentialMapper.isSdJwtDecodedCredential(wrappedVerifiableCredential.credential)) {
|
|
1685
|
-
uniformVerifiableCredential =
|
|
1697
|
+
uniformVerifiableCredential = sdJwtDecodedCredentialToUniformCredential(wrappedVerifiableCredential.credential);
|
|
1686
1698
|
} else if (CredentialMapper.isSdJwtEncoded(wrappedVerifiableCredential.credential)) {
|
|
1687
1699
|
if (!hasher) {
|
|
1688
1700
|
return Promise.reject("a hasher is required for encoded SD-JWT credentials");
|
|
@@ -1696,6 +1708,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1696
1708
|
uniformVerifiableCredential = wrappedVerifiableCredential.credential;
|
|
1697
1709
|
}
|
|
1698
1710
|
const correlationId = typeof uniformVerifiableCredential.issuer === "string" ? uniformVerifiableCredential.issuer : CredentialMapper.isSdJwtDecodedCredential(uniformVerifiableCredential) ? uniformVerifiableCredential.decodedPayload.iss : uniformVerifiableCredential.issuer.id;
|
|
1711
|
+
const credentialResponse = credentialToAccept.credentialResponse;
|
|
1699
1712
|
return {
|
|
1700
1713
|
correlationId,
|
|
1701
1714
|
credentialToAccept,
|
|
@@ -1707,6 +1720,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1707
1720
|
}
|
|
1708
1721
|
};
|
|
1709
1722
|
}, "mapCredentialToAccept");
|
|
1723
|
+
var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse) => {
|
|
1724
|
+
let credential;
|
|
1725
|
+
if ("credential" in credentialResponse) {
|
|
1726
|
+
credential = credentialResponse.credential;
|
|
1727
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1728
|
+
credential = credentialResponse.credentials[0].credential;
|
|
1729
|
+
}
|
|
1730
|
+
if (!credential) {
|
|
1731
|
+
throw new Error("No credential found in credential response");
|
|
1732
|
+
}
|
|
1733
|
+
return credential;
|
|
1734
|
+
}, "extractCredentialFromResponse");
|
|
1710
1735
|
var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
1711
1736
|
const { issuanceOpt, context } = args;
|
|
1712
1737
|
const { identifier: identifierArg } = issuanceOpt;
|
|
@@ -1815,24 +1840,19 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
|
|
|
1815
1840
|
}
|
|
1816
1841
|
__name(createIdFromTypes, "createIdFromTypes");
|
|
1817
1842
|
if (configurationId) {
|
|
1818
|
-
const allSupported2 = client.getCredentialsSupported(
|
|
1843
|
+
const allSupported2 = client.getCredentialsSupported(void 0, format);
|
|
1819
1844
|
return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
|
|
1820
1845
|
}
|
|
1821
|
-
if (!
|
|
1822
|
-
return Promise.reject(Error("openID4VCIClient has no credentialOffer
|
|
1846
|
+
if (!client.credentialOffer) {
|
|
1847
|
+
return Promise.reject(Error("openID4VCIClient has no credentialOffer"));
|
|
1823
1848
|
}
|
|
1824
|
-
if (!
|
|
1825
|
-
|
|
1826
|
-
format = client.credentialOffer.credential_offer.credentials.filter((cred) => typeof cred !== "string").map((cred) => cred.format);
|
|
1827
|
-
if (format?.length === 0) {
|
|
1828
|
-
format = void 0;
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1849
|
+
if (!types) {
|
|
1850
|
+
return Promise.reject(Error("openID4VCIClient has no types"));
|
|
1831
1851
|
}
|
|
1832
1852
|
const offerSupported = getSupportedCredentials({
|
|
1833
|
-
types:
|
|
1853
|
+
types: [
|
|
1834
1854
|
types
|
|
1835
|
-
]
|
|
1855
|
+
],
|
|
1836
1856
|
format,
|
|
1837
1857
|
version: client.version(),
|
|
1838
1858
|
issuerMetadata: client.endpointMetadata.credentialIssuerMetadata
|
|
@@ -2007,7 +2027,7 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
|
|
|
2007
2027
|
case "jwt":
|
|
2008
2028
|
case "jwt_vc_json":
|
|
2009
2029
|
case "jwt_vc":
|
|
2010
|
-
case
|
|
2030
|
+
//case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
2011
2031
|
case "dc+sd-jwt":
|
|
2012
2032
|
case "mso_mdoc": {
|
|
2013
2033
|
const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
|
|
@@ -2076,7 +2096,6 @@ var startFirstPartApplicationMachine = /* @__PURE__ */ __name(async (args, conte
|
|
|
2076
2096
|
}, "startFirstPartApplicationMachine");
|
|
2077
2097
|
|
|
2078
2098
|
// src/agent/OID4VCIHolder.ts
|
|
2079
|
-
import "cross-fetch/polyfill";
|
|
2080
2099
|
var oid4vciHolderContextMethods = [
|
|
2081
2100
|
"cmGetContacts",
|
|
2082
2101
|
"cmGetContact",
|
|
@@ -2132,6 +2151,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2132
2151
|
oid4vciHolderStart: this.oid4vciHolderStart.bind(this),
|
|
2133
2152
|
oid4vciHolderGetIssuerMetadata: this.oid4vciHolderGetIssuerMetadata.bind(this),
|
|
2134
2153
|
oid4vciHolderGetMachineInterpreter: this.oid4vciHolderGetMachineInterpreter.bind(this),
|
|
2154
|
+
oid4vciHolderPrepareAuthorizationRequest: this.oid4vciHolderPrepareAuthorizationRequest.bind(this),
|
|
2135
2155
|
oid4vciHolderCreateCredentialsToSelectFrom: this.oid4vciHolderCreateCredentialsToSelectFrom.bind(this),
|
|
2136
2156
|
oid4vciHolderGetContact: this.oid4vciHolderGetContact.bind(this),
|
|
2137
2157
|
oid4vciHolderGetCredentials: this.oid4vciHolderGetCredentials.bind(this),
|
|
@@ -2236,6 +2256,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2236
2256
|
stateNavigationListener: opts.firstPartyStateNavigationListener
|
|
2237
2257
|
}, context),
|
|
2238
2258
|
[OID4VCIMachineServices.createCredentialsToSelectFrom]: (args) => this.oid4vciHolderCreateCredentialsToSelectFrom(args, context),
|
|
2259
|
+
[OID4VCIMachineServices.prepareAuthorizationRequest]: (args) => this.oid4vciHolderPrepareAuthorizationRequest(args, context),
|
|
2239
2260
|
[OID4VCIMachineServices.getContact]: (args) => this.oid4vciHolderGetContact(args, context),
|
|
2240
2261
|
[OID4VCIMachineServices.getCredentials]: (args) => this.oid4vciHolderGetCredentials({
|
|
2241
2262
|
accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts,
|
|
@@ -2297,10 +2318,9 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2297
2318
|
formats = Array.from(new Set(authFormats));
|
|
2298
2319
|
}
|
|
2299
2320
|
let oid4vciClient;
|
|
2300
|
-
let types = void 0;
|
|
2301
2321
|
let offer;
|
|
2302
2322
|
if (requestData.existingClientState) {
|
|
2303
|
-
oid4vciClient = await
|
|
2323
|
+
oid4vciClient = await OpenID4VCIClientV1_0_15.fromState({
|
|
2304
2324
|
state: requestData.existingClientState
|
|
2305
2325
|
});
|
|
2306
2326
|
offer = oid4vciClient.credentialOffer;
|
|
@@ -2317,50 +2337,76 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2317
2337
|
}
|
|
2318
2338
|
if (!offer) {
|
|
2319
2339
|
logger.log(`Issuer url received (no credential offer): ${uri}`);
|
|
2320
|
-
oid4vciClient = await
|
|
2340
|
+
oid4vciClient = await OpenID4VCIClientV1_0_15.fromCredentialIssuer({
|
|
2321
2341
|
credentialIssuer: uri,
|
|
2322
2342
|
authorizationRequest: authorizationRequestOpts,
|
|
2323
2343
|
clientId: authorizationRequestOpts.clientId,
|
|
2324
|
-
createAuthorizationRequestURL:
|
|
2344
|
+
createAuthorizationRequestURL: false
|
|
2325
2345
|
});
|
|
2326
2346
|
} else {
|
|
2327
2347
|
logger.log(`Credential offer received: ${uri}`);
|
|
2328
|
-
oid4vciClient = await
|
|
2348
|
+
oid4vciClient = await OpenID4VCIClientV1_0_15.fromURI({
|
|
2329
2349
|
uri,
|
|
2330
2350
|
authorizationRequest: authorizationRequestOpts,
|
|
2331
2351
|
clientId: authorizationRequestOpts.clientId,
|
|
2332
|
-
createAuthorizationRequestURL:
|
|
2352
|
+
createAuthorizationRequestURL: false
|
|
2333
2353
|
});
|
|
2334
2354
|
}
|
|
2335
2355
|
}
|
|
2356
|
+
let configurationIds = [];
|
|
2336
2357
|
if (offer) {
|
|
2337
|
-
|
|
2358
|
+
configurationIds = offer.original_credential_offer.credential_configuration_ids;
|
|
2338
2359
|
} else {
|
|
2339
|
-
|
|
2360
|
+
configurationIds = asArray2(authorizationRequestOpts.authorizationDetails).filter((authDetails) => typeof authDetails !== "string").map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
|
|
2340
2361
|
}
|
|
2341
|
-
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2342
2362
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
2343
2363
|
client: oid4vciClient,
|
|
2344
2364
|
vcFormatPreferences: formats,
|
|
2345
|
-
|
|
2365
|
+
configurationIds
|
|
2346
2366
|
});
|
|
2367
|
+
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2347
2368
|
const credentialBranding = await getCredentialBranding({
|
|
2348
2369
|
credentialsSupported,
|
|
2349
2370
|
context
|
|
2350
2371
|
});
|
|
2351
|
-
const authorizationCodeURL = oid4vciClient.authorizationURL;
|
|
2352
|
-
if (authorizationCodeURL) {
|
|
2353
|
-
logger.log(`authorization code URL ${authorizationCodeURL}`);
|
|
2354
|
-
}
|
|
2355
2372
|
const oid4vciClientState = JSON.parse(await oid4vciClient.exportState());
|
|
2356
2373
|
return {
|
|
2357
|
-
authorizationCodeURL,
|
|
2358
2374
|
credentialBranding,
|
|
2359
2375
|
credentialsSupported,
|
|
2360
2376
|
serverMetadata,
|
|
2361
2377
|
oid4vciClientState
|
|
2362
2378
|
};
|
|
2363
2379
|
}
|
|
2380
|
+
async oid4vciHolderPrepareAuthorizationRequest(args, context) {
|
|
2381
|
+
const { openID4VCIClientState, contact } = args;
|
|
2382
|
+
if (!openID4VCIClientState) {
|
|
2383
|
+
return Promise.reject(Error("Missing openID4VCI client state in context"));
|
|
2384
|
+
}
|
|
2385
|
+
const clientId = contact?.identities.map((identity) => {
|
|
2386
|
+
const connectionConfig = identity.connection?.config;
|
|
2387
|
+
if (connectionConfig && "clientId" in connectionConfig) {
|
|
2388
|
+
return connectionConfig.clientId;
|
|
2389
|
+
}
|
|
2390
|
+
return void 0;
|
|
2391
|
+
}).find((clientId2) => clientId2);
|
|
2392
|
+
if (!clientId) {
|
|
2393
|
+
return Promise.reject(Error(`Missing client id in contact's connectionConfig`));
|
|
2394
|
+
}
|
|
2395
|
+
const client = await OpenID4VCIClient2.fromState({
|
|
2396
|
+
state: openID4VCIClientState
|
|
2397
|
+
});
|
|
2398
|
+
const authorizationCodeURL = await client.createAuthorizationRequestUrl({
|
|
2399
|
+
authorizationRequest: {
|
|
2400
|
+
clientId
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
if (authorizationCodeURL) {
|
|
2404
|
+
logger.log(`authorization code URL ${authorizationCodeURL}`);
|
|
2405
|
+
}
|
|
2406
|
+
return {
|
|
2407
|
+
authorizationCodeURL
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2364
2410
|
async oid4vciHolderCreateCredentialsToSelectFrom(args, context) {
|
|
2365
2411
|
const { credentialBranding, locale, selectedCredentials, credentialsSupported } = args;
|
|
2366
2412
|
logger.info(`Credentials supported ${Object.keys(credentialsSupported).join(", ")}`);
|
|
@@ -2432,7 +2478,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2432
2478
|
if (!openID4VCIClientState) {
|
|
2433
2479
|
return Promise.reject(Error("Missing openID4VCI client state in context"));
|
|
2434
2480
|
}
|
|
2435
|
-
const client = await
|
|
2481
|
+
const client = await OpenID4VCIClientV1_0_15.fromState({
|
|
2436
2482
|
state: openID4VCIClientState
|
|
2437
2483
|
});
|
|
2438
2484
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
@@ -2732,16 +2778,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2732
2778
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2733
2779
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2734
2780
|
logger.log(`Subject issuance/signing will be used, with event`, event);
|
|
2735
|
-
const
|
|
2736
|
-
let issuerVC;
|
|
2737
|
-
if ("credential" in credentialResponse) {
|
|
2738
|
-
issuerVC = credentialResponse.credential;
|
|
2739
|
-
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
2740
|
-
issuerVC = credentialResponse.credentials[0].credential;
|
|
2741
|
-
}
|
|
2742
|
-
if (!issuerVC) {
|
|
2743
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
2744
|
-
}
|
|
2781
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
|
|
2745
2782
|
const wrappedIssuerVC = CredentialMapper2.toWrappedVerifiableCredential(issuerVC, {
|
|
2746
2783
|
hasher: this.hasher ?? defaultHasher2
|
|
2747
2784
|
});
|
|
@@ -3112,6 +3149,7 @@ export {
|
|
|
3112
3149
|
RequestType,
|
|
3113
3150
|
SupportedLanguage,
|
|
3114
3151
|
createConfig,
|
|
3152
|
+
extractCredentialFromResponse,
|
|
3115
3153
|
getBasicIssuerLocaleBranding,
|
|
3116
3154
|
getCredentialBranding,
|
|
3117
3155
|
getCredentialConfigsBasedOnFormatPref,
|