@sphereon/ssi-sdk.oid4vci-holder 0.34.1-next.29 → 0.34.1-next.299
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 +426 -420
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +533 -527
- package/dist/index.js.map +1 -1
- package/package.json +25 -24
- package/src/agent/OID4VCIHolder.ts +35 -34
- package/src/machines/firstPartyMachine.ts +1 -1
- package/src/machines/oid4vciMachine.ts +1 -1
- package/src/mappers/OIDC4VCIBrandingMapper.ts +1 -1
- package/src/services/OID4VCIHolderService.ts +46 -45
- package/src/types/FirstPartyMachine.ts +6 -5
- package/src/types/IOID4VCIHolder.ts +4 -2
package/dist/index.js
CHANGED
|
@@ -56,13 +56,16 @@ var require_nl = __commonJS({
|
|
|
56
56
|
|
|
57
57
|
// src/agent/OID4VCIHolder.ts
|
|
58
58
|
import { CredentialOfferClient, MetadataClient, OpenID4VCIClient as OpenID4VCIClient2 } from "@sphereon/oid4vci-client";
|
|
59
|
-
import { DefaultURISchemes,
|
|
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
|
-
import {
|
|
64
|
-
import {
|
|
63
|
+
import { defaultHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
64
|
+
import { ensureRawDocument } from "@sphereon/ssi-sdk.data-store-types";
|
|
65
|
+
import { ConnectionType, CorrelationIdentifierType, CredentialCorrelationType, IdentityOrigin } from "@sphereon/ssi-sdk.data-store-types";
|
|
66
|
+
import { CredentialMapper as CredentialMapper2, CredentialRole, JoseSignatureAlgorithm as JoseSignatureAlgorithm2, Loggers, parseDid } from "@sphereon/ssi-types";
|
|
65
67
|
import { asArray as asArray2, computeEntryHash } from "@veramo/utils";
|
|
68
|
+
import fetch from "cross-fetch";
|
|
66
69
|
import { decodeJWT } from "did-jwt";
|
|
67
70
|
import { v4 as uuidv42 } from "uuid";
|
|
68
71
|
|
|
@@ -75,18 +78,18 @@ import i18n from "i18n-js";
|
|
|
75
78
|
import memoize from "lodash.memoize";
|
|
76
79
|
|
|
77
80
|
// src/types/IOID4VCIHolder.ts
|
|
78
|
-
var OID4VCIHolderEvent = /* @__PURE__ */ function(OID4VCIHolderEvent2) {
|
|
81
|
+
var OID4VCIHolderEvent = /* @__PURE__ */ (function(OID4VCIHolderEvent2) {
|
|
79
82
|
OID4VCIHolderEvent2["CONTACT_IDENTITY_CREATED"] = "contact_identity_created";
|
|
80
83
|
OID4VCIHolderEvent2["CREDENTIAL_STORED"] = "credential_stored";
|
|
81
84
|
OID4VCIHolderEvent2["IDENTIFIER_CREATED"] = "identifier_created";
|
|
82
85
|
return OID4VCIHolderEvent2;
|
|
83
|
-
}({});
|
|
84
|
-
var SupportedLanguage = /* @__PURE__ */ function(SupportedLanguage2) {
|
|
86
|
+
})({});
|
|
87
|
+
var SupportedLanguage = /* @__PURE__ */ (function(SupportedLanguage2) {
|
|
85
88
|
SupportedLanguage2["ENGLISH"] = "en";
|
|
86
89
|
SupportedLanguage2["DUTCH"] = "nl";
|
|
87
90
|
return SupportedLanguage2;
|
|
88
|
-
}({});
|
|
89
|
-
var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
91
|
+
})({});
|
|
92
|
+
var OID4VCIMachineStates = /* @__PURE__ */ (function(OID4VCIMachineStates2) {
|
|
90
93
|
OID4VCIMachineStates2["start"] = "start";
|
|
91
94
|
OID4VCIMachineStates2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
92
95
|
OID4VCIMachineStates2["getContact"] = "getContact";
|
|
@@ -117,18 +120,18 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
117
120
|
OID4VCIMachineStates2["error"] = "error";
|
|
118
121
|
OID4VCIMachineStates2["done"] = "done";
|
|
119
122
|
return OID4VCIMachineStates2;
|
|
120
|
-
}({});
|
|
121
|
-
var OID4VCIMachineAddContactStates = /* @__PURE__ */ function(OID4VCIMachineAddContactStates2) {
|
|
123
|
+
})({});
|
|
124
|
+
var OID4VCIMachineAddContactStates = /* @__PURE__ */ (function(OID4VCIMachineAddContactStates2) {
|
|
122
125
|
OID4VCIMachineAddContactStates2["idle"] = "idle";
|
|
123
126
|
OID4VCIMachineAddContactStates2["next"] = "next";
|
|
124
127
|
return OID4VCIMachineAddContactStates2;
|
|
125
|
-
}({});
|
|
126
|
-
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ function(OID4VCIMachineVerifyPinStates2) {
|
|
128
|
+
})({});
|
|
129
|
+
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ (function(OID4VCIMachineVerifyPinStates2) {
|
|
127
130
|
OID4VCIMachineVerifyPinStates2["idle"] = "idle";
|
|
128
131
|
OID4VCIMachineVerifyPinStates2["next"] = "next";
|
|
129
132
|
return OID4VCIMachineVerifyPinStates2;
|
|
130
|
-
}({});
|
|
131
|
-
var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
133
|
+
})({});
|
|
134
|
+
var OID4VCIMachineEvents = /* @__PURE__ */ (function(OID4VCIMachineEvents2) {
|
|
132
135
|
OID4VCIMachineEvents2["NEXT"] = "NEXT";
|
|
133
136
|
OID4VCIMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
134
137
|
OID4VCIMachineEvents2["DECLINE"] = "DECLINE";
|
|
@@ -141,14 +144,15 @@ var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
|
141
144
|
OID4VCIMachineEvents2["INVOKED_AUTHORIZATION_CODE_REQUEST"] = "INVOKED_AUTHORIZATION_CODE_REQUEST";
|
|
142
145
|
OID4VCIMachineEvents2["PROVIDE_AUTHORIZATION_CODE_RESPONSE"] = "PROVIDE_AUTHORIZATION_CODE_RESPONSE";
|
|
143
146
|
return OID4VCIMachineEvents2;
|
|
144
|
-
}({});
|
|
145
|
-
var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
147
|
+
})({});
|
|
148
|
+
var OID4VCIMachineGuards = /* @__PURE__ */ (function(OID4VCIMachineGuards2) {
|
|
146
149
|
OID4VCIMachineGuards2["hasContactGuard"] = "oid4vciHasContactGuard";
|
|
147
150
|
OID4VCIMachineGuards2["hasNoContactGuard"] = "oid4vciHasNoContactGuard";
|
|
148
151
|
OID4VCIMachineGuards2["credentialsToSelectRequiredGuard"] = "oid4vciCredentialsToSelectRequiredGuard";
|
|
149
152
|
OID4VCIMachineGuards2["requirePinGuard"] = "oid4vciRequirePinGuard";
|
|
150
153
|
OID4VCIMachineGuards2["requireAuthorizationGuard"] = "oid4vciRequireAuthorizationGuard";
|
|
151
154
|
OID4VCIMachineGuards2["noAuthorizationGuard"] = "oid4vciNoAuthorizationGuard";
|
|
155
|
+
OID4VCIMachineGuards2["hasNonceEndpointGuard"] = "oid4vciHasNonceEndpointGuard ";
|
|
152
156
|
OID4VCIMachineGuards2["hasAuthorizationResponse"] = "oid4vciHasAuthorizationResponse";
|
|
153
157
|
OID4VCIMachineGuards2["hasNoContactIdentityGuard"] = "oid4vciHasNoContactIdentityGuard";
|
|
154
158
|
OID4VCIMachineGuards2["verificationCodeGuard"] = "oid4vciVerificationCodeGuard";
|
|
@@ -158,8 +162,8 @@ var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
|
158
162
|
OID4VCIMachineGuards2["contactHasLowTrustGuard"] = "oid4vciContactHasLowTrustGuard";
|
|
159
163
|
OID4VCIMachineGuards2["isFirstPartyApplication"] = "oid4vciIsFirstPartyApplication";
|
|
160
164
|
return OID4VCIMachineGuards2;
|
|
161
|
-
}({});
|
|
162
|
-
var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
165
|
+
})({});
|
|
166
|
+
var OID4VCIMachineServices = /* @__PURE__ */ (function(OID4VCIMachineServices2) {
|
|
163
167
|
OID4VCIMachineServices2["start"] = "start";
|
|
164
168
|
OID4VCIMachineServices2["getContact"] = "getContact";
|
|
165
169
|
OID4VCIMachineServices2["getFederationTrust"] = "getFederationTrust";
|
|
@@ -174,17 +178,17 @@ var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
|
174
178
|
OID4VCIMachineServices2["storeCredentials"] = "storeCredentials";
|
|
175
179
|
OID4VCIMachineServices2["startFirstPartApplicationFlow"] = "startFirstPartApplicationFlow";
|
|
176
180
|
return OID4VCIMachineServices2;
|
|
177
|
-
}({});
|
|
178
|
-
var RequestType = /* @__PURE__ */ function(RequestType2) {
|
|
181
|
+
})({});
|
|
182
|
+
var RequestType = /* @__PURE__ */ (function(RequestType2) {
|
|
179
183
|
RequestType2["OPENID_INITIATE_ISSUANCE"] = "openid-initiate-issuance";
|
|
180
184
|
RequestType2["OPENID_CREDENTIAL_OFFER"] = "openid-credential-offer";
|
|
181
185
|
RequestType2["URL"] = "URL";
|
|
182
186
|
return RequestType2;
|
|
183
|
-
}({});
|
|
184
|
-
var IdentifierAliasEnum = /* @__PURE__ */ function(IdentifierAliasEnum2) {
|
|
187
|
+
})({});
|
|
188
|
+
var IdentifierAliasEnum = /* @__PURE__ */ (function(IdentifierAliasEnum2) {
|
|
185
189
|
IdentifierAliasEnum2["PRIMARY"] = "primary";
|
|
186
190
|
return IdentifierAliasEnum2;
|
|
187
|
-
}({});
|
|
191
|
+
})({});
|
|
188
192
|
|
|
189
193
|
// src/localization/Localization.ts
|
|
190
194
|
var Localization = class Localization2 {
|
|
@@ -226,7 +230,7 @@ var Localization = class Localization2 {
|
|
|
226
230
|
var translate = Localization.translate;
|
|
227
231
|
|
|
228
232
|
// src/types/FirstPartyMachine.ts
|
|
229
|
-
var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStateTypes2) {
|
|
233
|
+
var FirstPartyMachineStateTypes = /* @__PURE__ */ (function(FirstPartyMachineStateTypes2) {
|
|
230
234
|
FirstPartyMachineStateTypes2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
231
235
|
FirstPartyMachineStateTypes2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
232
236
|
FirstPartyMachineStateTypes2["selectCredentials"] = "selectCredentials";
|
|
@@ -237,21 +241,21 @@ var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStat
|
|
|
237
241
|
FirstPartyMachineStateTypes2["aborted"] = "aborted";
|
|
238
242
|
FirstPartyMachineStateTypes2["declined"] = "declined";
|
|
239
243
|
return FirstPartyMachineStateTypes2;
|
|
240
|
-
}({});
|
|
241
|
-
var FirstPartyMachineServices = /* @__PURE__ */ function(FirstPartyMachineServices2) {
|
|
244
|
+
})({});
|
|
245
|
+
var FirstPartyMachineServices = /* @__PURE__ */ (function(FirstPartyMachineServices2) {
|
|
242
246
|
FirstPartyMachineServices2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
243
247
|
FirstPartyMachineServices2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
244
248
|
FirstPartyMachineServices2["createConfig"] = "createConfig";
|
|
245
249
|
FirstPartyMachineServices2["getSiopRequest"] = "getSiopRequest";
|
|
246
250
|
return FirstPartyMachineServices2;
|
|
247
|
-
}({});
|
|
248
|
-
var FirstPartyMachineEvents = /* @__PURE__ */ function(FirstPartyMachineEvents2) {
|
|
251
|
+
})({});
|
|
252
|
+
var FirstPartyMachineEvents = /* @__PURE__ */ (function(FirstPartyMachineEvents2) {
|
|
249
253
|
FirstPartyMachineEvents2["NEXT"] = "NEXT";
|
|
250
254
|
FirstPartyMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
251
255
|
FirstPartyMachineEvents2["DECLINE"] = "DECLINE";
|
|
252
256
|
FirstPartyMachineEvents2["SET_SELECTED_CREDENTIALS"] = "SET_SELECTED_CREDENTIALS";
|
|
253
257
|
return FirstPartyMachineEvents2;
|
|
254
|
-
}({});
|
|
258
|
+
})({});
|
|
255
259
|
|
|
256
260
|
// src/machines/oid4vciMachine.ts
|
|
257
261
|
var oid4vciHasNoContactGuard = /* @__PURE__ */ __name((_ctx, _event) => {
|
|
@@ -976,413 +980,152 @@ var OID4VCIMachine = class {
|
|
|
976
980
|
|
|
977
981
|
// src/services/OID4VCIHolderService.ts
|
|
978
982
|
import { LOG } from "@sphereon/oid4vci-client";
|
|
979
|
-
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject
|
|
983
|
+
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject } from "@sphereon/oid4vci-common";
|
|
980
984
|
import { KeyUse } from "@sphereon/ssi-sdk-ext.did-resolver-jwk";
|
|
981
985
|
import { getOrCreatePrimaryIdentifier, SupportedDidMethodEnum } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
982
986
|
import { isIIdentifier, isManagedIdentifierDidResult, isManagedIdentifierResult, managedIdentifierToJwk } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
983
987
|
import { keyTypeFromCryptographicSuite } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
988
|
+
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
984
989
|
import { CredentialMapper, JoseSignatureAlgorithm, mdocDecodedCredentialToUniformCredential, sdJwtDecodedCredentialToUniformCredential } from "@sphereon/ssi-types";
|
|
985
990
|
import { asArray } from "@veramo/utils";
|
|
986
991
|
|
|
987
|
-
// src/
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
credentialDisplay
|
|
999
|
-
})
|
|
1000
|
-
}
|
|
992
|
+
// src/machines/firstPartyMachine.ts
|
|
993
|
+
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
994
|
+
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
995
|
+
|
|
996
|
+
// src/services/FirstPartyMachineServices.ts
|
|
997
|
+
import { OpenID4VCIClient } from "@sphereon/oid4vci-client";
|
|
998
|
+
import { v4 as uuidv4 } from "uuid";
|
|
999
|
+
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
1000
|
+
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
1001
|
+
const oid4vciClient = await OpenID4VCIClient.fromState({
|
|
1002
|
+
state: openID4VCIClientState
|
|
1001
1003
|
});
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
const localeKey = display.locale || "";
|
|
1007
|
-
localeDisplays.set(localeKey, display);
|
|
1008
|
-
return localeDisplays;
|
|
1009
|
-
}, /* @__PURE__ */ new Map());
|
|
1010
|
-
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1011
|
-
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1012
|
-
const { issuerCredentialSubject } = args;
|
|
1013
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1014
|
-
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1015
|
-
Object.entries(claim).forEach(([key, value]) => {
|
|
1016
|
-
if (key === "mandatory" || key === "value_type") {
|
|
1017
|
-
return;
|
|
1018
|
-
}
|
|
1019
|
-
if (key === "display" && Array.isArray(value)) {
|
|
1020
|
-
value.forEach(({ name, locale = "" }) => {
|
|
1021
|
-
if (!name) {
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
if (!localeClaims.has(locale)) {
|
|
1025
|
-
localeClaims.set(locale, []);
|
|
1026
|
-
}
|
|
1027
|
-
localeClaims.get(locale).push({
|
|
1028
|
-
key: parentKey,
|
|
1029
|
-
name
|
|
1030
|
-
});
|
|
1031
|
-
});
|
|
1032
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1033
|
-
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
1036
|
-
}, "processClaimObject");
|
|
1037
|
-
processClaimObject(issuerCredentialSubject);
|
|
1038
|
-
return localeClaims;
|
|
1039
|
-
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1040
|
-
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1041
|
-
const { credentialDisplay } = args;
|
|
1042
|
-
return {
|
|
1043
|
-
...credentialDisplay.name && {
|
|
1044
|
-
alias: credentialDisplay.name
|
|
1045
|
-
},
|
|
1046
|
-
...credentialDisplay.locale && {
|
|
1047
|
-
locale: credentialDisplay.locale
|
|
1048
|
-
},
|
|
1049
|
-
...credentialDisplay.logo && {
|
|
1050
|
-
logo: {
|
|
1051
|
-
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1052
|
-
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1053
|
-
},
|
|
1054
|
-
...credentialDisplay.logo.alt_text && {
|
|
1055
|
-
alt: credentialDisplay.logo?.alt_text
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1004
|
+
return oid4vciClient.acquireAuthorizationChallengeCode({
|
|
1005
|
+
clientId: oid4vciClient.clientId ?? uuidv4(),
|
|
1006
|
+
...authSession && {
|
|
1007
|
+
authSession
|
|
1058
1008
|
},
|
|
1059
|
-
|
|
1060
|
-
|
|
1009
|
+
...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
|
|
1010
|
+
issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
|
|
1061
1011
|
},
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
color: credentialDisplay.text_color
|
|
1065
|
-
}
|
|
1012
|
+
...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
|
|
1013
|
+
issuerState: openID4VCIClientState.credentialOffer?.issuerState
|
|
1066
1014
|
},
|
|
1067
|
-
...
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1015
|
+
...presentationDuringIssuanceSession && {
|
|
1016
|
+
presentationDuringIssuanceSession
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
}, "sendAuthorizationChallengeRequest");
|
|
1020
|
+
var createConfig = /* @__PURE__ */ __name(async (args, context) => {
|
|
1021
|
+
const { presentationUri } = args;
|
|
1022
|
+
if (!presentationUri) {
|
|
1023
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1024
|
+
}
|
|
1025
|
+
return context.agent.siopCreateConfig({
|
|
1026
|
+
url: presentationUri
|
|
1027
|
+
});
|
|
1028
|
+
}, "createConfig");
|
|
1029
|
+
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1030
|
+
const { didAuthConfig, presentationUri } = args;
|
|
1031
|
+
if (presentationUri === void 0) {
|
|
1032
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1033
|
+
}
|
|
1034
|
+
if (didAuthConfig === void 0) {
|
|
1035
|
+
return Promise.reject(Error("Missing did auth config in context"));
|
|
1036
|
+
}
|
|
1037
|
+
return context.agent.siopGetSiopRequest({
|
|
1038
|
+
didAuthConfig,
|
|
1039
|
+
url: presentationUri
|
|
1040
|
+
});
|
|
1041
|
+
}, "getSiopRequest");
|
|
1042
|
+
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1043
|
+
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1044
|
+
const responseData = await context.agent.siopSendResponse({
|
|
1045
|
+
authorizationRequestData,
|
|
1046
|
+
selectedCredentials,
|
|
1047
|
+
didAuthConfig,
|
|
1048
|
+
isFirstParty: true
|
|
1049
|
+
});
|
|
1050
|
+
return responseData.body.presentation_during_issuance_session;
|
|
1051
|
+
}, "sendAuthorizationResponse");
|
|
1052
|
+
|
|
1053
|
+
// src/machines/firstPartyMachine.ts
|
|
1054
|
+
var firstPartyMachineStates = {
|
|
1055
|
+
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1056
|
+
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1057
|
+
invoke: {
|
|
1058
|
+
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1059
|
+
onDone: {
|
|
1060
|
+
target: FirstPartyMachineStateTypes.done,
|
|
1061
|
+
actions: assign2({
|
|
1062
|
+
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1063
|
+
})
|
|
1064
|
+
},
|
|
1065
|
+
onError: [
|
|
1066
|
+
{
|
|
1067
|
+
target: FirstPartyMachineStateTypes.createConfig,
|
|
1068
|
+
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1069
|
+
actions: assign2({
|
|
1070
|
+
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1071
|
+
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1072
|
+
})
|
|
1078
1073
|
},
|
|
1079
|
-
|
|
1080
|
-
|
|
1074
|
+
{
|
|
1075
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1076
|
+
actions: assign2({
|
|
1077
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1078
|
+
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1079
|
+
message: _event.data.message,
|
|
1080
|
+
stack: _event.data.stack
|
|
1081
|
+
}), "error")
|
|
1082
|
+
})
|
|
1081
1083
|
}
|
|
1084
|
+
]
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1088
|
+
id: FirstPartyMachineStateTypes.createConfig,
|
|
1089
|
+
invoke: {
|
|
1090
|
+
src: FirstPartyMachineServices.createConfig,
|
|
1091
|
+
onDone: {
|
|
1092
|
+
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1093
|
+
actions: assign2({
|
|
1094
|
+
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1095
|
+
})
|
|
1096
|
+
},
|
|
1097
|
+
onError: {
|
|
1098
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1099
|
+
actions: assign2({
|
|
1100
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1101
|
+
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1102
|
+
message: _event.data.message,
|
|
1103
|
+
stack: _event.data.stack
|
|
1104
|
+
}), "error")
|
|
1105
|
+
})
|
|
1082
1106
|
}
|
|
1083
1107
|
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1095
|
-
return {
|
|
1096
|
-
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1097
|
-
credentialDisplay: display
|
|
1098
|
-
}),
|
|
1099
|
-
...locale.length > 0 && {
|
|
1100
|
-
locale
|
|
1108
|
+
},
|
|
1109
|
+
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1110
|
+
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1111
|
+
invoke: {
|
|
1112
|
+
src: FirstPartyMachineServices.getSiopRequest,
|
|
1113
|
+
onDone: {
|
|
1114
|
+
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1115
|
+
actions: assign2({
|
|
1116
|
+
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1117
|
+
})
|
|
1101
1118
|
},
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
})
|
|
1113
|
-
},
|
|
1114
|
-
...credentialDisplay && {
|
|
1115
|
-
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1116
|
-
credentialDisplay
|
|
1117
|
-
})
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
}, "sdJwtGetCredentialBrandingFrom");
|
|
1121
|
-
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1122
|
-
const { credentialDisplay } = args;
|
|
1123
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1124
|
-
const localeKey = display.lang || "";
|
|
1125
|
-
localeDisplays.set(localeKey, display);
|
|
1126
|
-
return localeDisplays;
|
|
1127
|
-
}, /* @__PURE__ */ new Map());
|
|
1128
|
-
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1129
|
-
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1130
|
-
const { claimsMetadata } = args;
|
|
1131
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1132
|
-
claimsMetadata.forEach((claim) => {
|
|
1133
|
-
claim.display?.forEach((display) => {
|
|
1134
|
-
const { lang = "", label } = display;
|
|
1135
|
-
const key = claim.path.map((value) => String(value)).join(".");
|
|
1136
|
-
if (!localeClaims.has(lang)) {
|
|
1137
|
-
localeClaims.set(lang, []);
|
|
1138
|
-
}
|
|
1139
|
-
localeClaims.get(lang).push({
|
|
1140
|
-
key,
|
|
1141
|
-
name: label
|
|
1142
|
-
});
|
|
1143
|
-
});
|
|
1144
|
-
});
|
|
1145
|
-
return localeClaims;
|
|
1146
|
-
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1147
|
-
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1148
|
-
const { credentialDisplay } = args;
|
|
1149
|
-
return {
|
|
1150
|
-
...credentialDisplay.name && {
|
|
1151
|
-
alias: credentialDisplay.name
|
|
1152
|
-
},
|
|
1153
|
-
...credentialDisplay.lang && {
|
|
1154
|
-
locale: credentialDisplay.lang
|
|
1155
|
-
},
|
|
1156
|
-
...credentialDisplay.rendering?.simple?.logo && {
|
|
1157
|
-
logo: {
|
|
1158
|
-
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1159
|
-
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1160
|
-
},
|
|
1161
|
-
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1162
|
-
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
},
|
|
1166
|
-
...credentialDisplay.description && {
|
|
1167
|
-
description: credentialDisplay.description
|
|
1168
|
-
},
|
|
1169
|
-
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1170
|
-
text: {
|
|
1171
|
-
color: credentialDisplay.rendering.simple.text_color
|
|
1172
|
-
}
|
|
1173
|
-
},
|
|
1174
|
-
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1175
|
-
background: {
|
|
1176
|
-
color: credentialDisplay.rendering.simple.background_color
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
};
|
|
1180
|
-
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1181
|
-
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1182
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1183
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1184
|
-
...claimsMetadata.keys(),
|
|
1185
|
-
...credentialDisplayLocales.keys()
|
|
1186
|
-
]));
|
|
1187
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1188
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1189
|
-
const claims = claimsMetadata.get(locale);
|
|
1190
|
-
return {
|
|
1191
|
-
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1192
|
-
credentialDisplay: display
|
|
1193
|
-
}),
|
|
1194
|
-
...locale.length > 0 && {
|
|
1195
|
-
locale
|
|
1196
|
-
},
|
|
1197
|
-
claims
|
|
1198
|
-
};
|
|
1199
|
-
}));
|
|
1200
|
-
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1201
|
-
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1202
|
-
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1203
|
-
return {
|
|
1204
|
-
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1205
|
-
alias: dynamicRegistrationClientMetadata.client_name
|
|
1206
|
-
},
|
|
1207
|
-
...issuerDisplay.name && {
|
|
1208
|
-
alias: issuerDisplay.name
|
|
1209
|
-
},
|
|
1210
|
-
...issuerDisplay.locale && {
|
|
1211
|
-
locale: issuerDisplay.locale
|
|
1212
|
-
},
|
|
1213
|
-
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1214
|
-
logo: {
|
|
1215
|
-
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1216
|
-
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1217
|
-
},
|
|
1218
|
-
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1219
|
-
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1220
|
-
},
|
|
1221
|
-
...issuerDisplay.logo?.alt_text && {
|
|
1222
|
-
alt: issuerDisplay.logo?.alt_text
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
},
|
|
1226
|
-
...issuerDisplay.description && {
|
|
1227
|
-
description: issuerDisplay.description
|
|
1228
|
-
},
|
|
1229
|
-
...issuerDisplay.text_color && {
|
|
1230
|
-
text: {
|
|
1231
|
-
color: issuerDisplay.text_color
|
|
1232
|
-
}
|
|
1233
|
-
},
|
|
1234
|
-
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1235
|
-
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1236
|
-
},
|
|
1237
|
-
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1238
|
-
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1239
|
-
},
|
|
1240
|
-
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1241
|
-
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1242
|
-
},
|
|
1243
|
-
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1244
|
-
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1245
|
-
}
|
|
1246
|
-
};
|
|
1247
|
-
}, "issuerLocaleBrandingFrom");
|
|
1248
|
-
|
|
1249
|
-
// src/machines/firstPartyMachine.ts
|
|
1250
|
-
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
1251
|
-
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
1252
|
-
|
|
1253
|
-
// src/services/FirstPartyMachineServices.ts
|
|
1254
|
-
import { OpenID4VCIClient } from "@sphereon/oid4vci-client";
|
|
1255
|
-
import { v4 as uuidv4 } from "uuid";
|
|
1256
|
-
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
1257
|
-
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
1258
|
-
const oid4vciClient = await OpenID4VCIClient.fromState({
|
|
1259
|
-
state: openID4VCIClientState
|
|
1260
|
-
});
|
|
1261
|
-
return oid4vciClient.acquireAuthorizationChallengeCode({
|
|
1262
|
-
clientId: oid4vciClient.clientId ?? uuidv4(),
|
|
1263
|
-
...authSession && {
|
|
1264
|
-
authSession
|
|
1265
|
-
},
|
|
1266
|
-
...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
|
|
1267
|
-
issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
|
|
1268
|
-
},
|
|
1269
|
-
...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
|
|
1270
|
-
issuerState: openID4VCIClientState.credentialOffer?.issuerState
|
|
1271
|
-
},
|
|
1272
|
-
...presentationDuringIssuanceSession && {
|
|
1273
|
-
presentationDuringIssuanceSession
|
|
1274
|
-
}
|
|
1275
|
-
});
|
|
1276
|
-
}, "sendAuthorizationChallengeRequest");
|
|
1277
|
-
var createConfig = /* @__PURE__ */ __name(async (args, context) => {
|
|
1278
|
-
const { presentationUri } = args;
|
|
1279
|
-
if (!presentationUri) {
|
|
1280
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1281
|
-
}
|
|
1282
|
-
return context.agent.siopCreateConfig({
|
|
1283
|
-
url: presentationUri
|
|
1284
|
-
});
|
|
1285
|
-
}, "createConfig");
|
|
1286
|
-
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1287
|
-
const { didAuthConfig, presentationUri } = args;
|
|
1288
|
-
if (presentationUri === void 0) {
|
|
1289
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1290
|
-
}
|
|
1291
|
-
if (didAuthConfig === void 0) {
|
|
1292
|
-
return Promise.reject(Error("Missing did auth config in context"));
|
|
1293
|
-
}
|
|
1294
|
-
return context.agent.siopGetSiopRequest({
|
|
1295
|
-
didAuthConfig,
|
|
1296
|
-
url: presentationUri
|
|
1297
|
-
});
|
|
1298
|
-
}, "getSiopRequest");
|
|
1299
|
-
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1300
|
-
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1301
|
-
const responseData = await context.agent.siopSendResponse({
|
|
1302
|
-
authorizationRequestData,
|
|
1303
|
-
selectedCredentials,
|
|
1304
|
-
didAuthConfig,
|
|
1305
|
-
isFirstParty: true
|
|
1306
|
-
});
|
|
1307
|
-
return responseData.body.presentation_during_issuance_session;
|
|
1308
|
-
}, "sendAuthorizationResponse");
|
|
1309
|
-
|
|
1310
|
-
// src/machines/firstPartyMachine.ts
|
|
1311
|
-
var firstPartyMachineStates = {
|
|
1312
|
-
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1313
|
-
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1314
|
-
invoke: {
|
|
1315
|
-
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1316
|
-
onDone: {
|
|
1317
|
-
target: FirstPartyMachineStateTypes.done,
|
|
1318
|
-
actions: assign2({
|
|
1319
|
-
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1320
|
-
})
|
|
1321
|
-
},
|
|
1322
|
-
onError: [
|
|
1323
|
-
{
|
|
1324
|
-
target: FirstPartyMachineStateTypes.createConfig,
|
|
1325
|
-
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1326
|
-
actions: assign2({
|
|
1327
|
-
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1328
|
-
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1329
|
-
})
|
|
1330
|
-
},
|
|
1331
|
-
{
|
|
1332
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1333
|
-
actions: assign2({
|
|
1334
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1335
|
-
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1336
|
-
message: _event.data.message,
|
|
1337
|
-
stack: _event.data.stack
|
|
1338
|
-
}), "error")
|
|
1339
|
-
})
|
|
1340
|
-
}
|
|
1341
|
-
]
|
|
1342
|
-
}
|
|
1343
|
-
},
|
|
1344
|
-
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1345
|
-
id: FirstPartyMachineStateTypes.createConfig,
|
|
1346
|
-
invoke: {
|
|
1347
|
-
src: FirstPartyMachineServices.createConfig,
|
|
1348
|
-
onDone: {
|
|
1349
|
-
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1350
|
-
actions: assign2({
|
|
1351
|
-
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1352
|
-
})
|
|
1353
|
-
},
|
|
1354
|
-
onError: {
|
|
1355
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1356
|
-
actions: assign2({
|
|
1357
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1358
|
-
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1359
|
-
message: _event.data.message,
|
|
1360
|
-
stack: _event.data.stack
|
|
1361
|
-
}), "error")
|
|
1362
|
-
})
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
},
|
|
1366
|
-
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1367
|
-
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1368
|
-
invoke: {
|
|
1369
|
-
src: FirstPartyMachineServices.getSiopRequest,
|
|
1370
|
-
onDone: {
|
|
1371
|
-
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1372
|
-
actions: assign2({
|
|
1373
|
-
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1374
|
-
})
|
|
1375
|
-
},
|
|
1376
|
-
onError: {
|
|
1377
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1378
|
-
actions: assign2({
|
|
1379
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1380
|
-
title: translate("siopV2_machine_get_request_error_title"),
|
|
1381
|
-
message: _event.data.message,
|
|
1382
|
-
stack: _event.data.stack
|
|
1383
|
-
}), "error")
|
|
1384
|
-
})
|
|
1385
|
-
}
|
|
1119
|
+
onError: {
|
|
1120
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1121
|
+
actions: assign2({
|
|
1122
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1123
|
+
title: translate("siopV2_machine_get_request_error_title"),
|
|
1124
|
+
message: _event.data.message,
|
|
1125
|
+
stack: _event.data.stack
|
|
1126
|
+
}), "error")
|
|
1127
|
+
})
|
|
1128
|
+
}
|
|
1386
1129
|
}
|
|
1387
1130
|
},
|
|
1388
1131
|
[FirstPartyMachineStateTypes.selectCredentials]: {
|
|
@@ -1449,96 +1192,357 @@ var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
1449
1192
|
contact: opts.contact,
|
|
1450
1193
|
selectedCredentials: []
|
|
1451
1194
|
};
|
|
1452
|
-
return createMachine2({
|
|
1453
|
-
id: opts?.machineId ?? "FirstParty",
|
|
1454
|
-
predictableActionArguments: true,
|
|
1455
|
-
initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1456
|
-
context: initialContext,
|
|
1457
|
-
states: firstPartyMachineStates,
|
|
1458
|
-
schema: {
|
|
1459
|
-
events: {},
|
|
1460
|
-
services: {}
|
|
1195
|
+
return createMachine2({
|
|
1196
|
+
id: opts?.machineId ?? "FirstParty",
|
|
1197
|
+
predictableActionArguments: true,
|
|
1198
|
+
initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1199
|
+
context: initialContext,
|
|
1200
|
+
states: firstPartyMachineStates,
|
|
1201
|
+
schema: {
|
|
1202
|
+
events: {},
|
|
1203
|
+
services: {}
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}, "createFirstPartyActivationMachine");
|
|
1207
|
+
var FirstPartyMachine = class _FirstPartyMachine {
|
|
1208
|
+
static {
|
|
1209
|
+
__name(this, "FirstPartyMachine");
|
|
1210
|
+
}
|
|
1211
|
+
static _instance;
|
|
1212
|
+
static hasInstance() {
|
|
1213
|
+
return _FirstPartyMachine._instance !== void 0;
|
|
1214
|
+
}
|
|
1215
|
+
static get instance() {
|
|
1216
|
+
if (!_FirstPartyMachine._instance) {
|
|
1217
|
+
throw Error("Please initialize ESIMActivation machine first");
|
|
1218
|
+
}
|
|
1219
|
+
return _FirstPartyMachine._instance;
|
|
1220
|
+
}
|
|
1221
|
+
static clearInstance(opts) {
|
|
1222
|
+
const { stop } = opts;
|
|
1223
|
+
if (_FirstPartyMachine.hasInstance()) {
|
|
1224
|
+
if (stop) {
|
|
1225
|
+
_FirstPartyMachine.stopInstance();
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
_FirstPartyMachine._instance = void 0;
|
|
1229
|
+
}
|
|
1230
|
+
static stopInstance() {
|
|
1231
|
+
if (!_FirstPartyMachine.hasInstance()) {
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
_FirstPartyMachine.instance.stop();
|
|
1235
|
+
_FirstPartyMachine._instance = void 0;
|
|
1236
|
+
}
|
|
1237
|
+
static newInstance(opts) {
|
|
1238
|
+
const { agentContext } = opts;
|
|
1239
|
+
const services = {
|
|
1240
|
+
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1241
|
+
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1242
|
+
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1243
|
+
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1244
|
+
};
|
|
1245
|
+
const newInst = interpret2(createFirstPartyActivationMachine(opts).withConfig({
|
|
1246
|
+
services: {
|
|
1247
|
+
...services,
|
|
1248
|
+
...opts?.services
|
|
1249
|
+
},
|
|
1250
|
+
guards: {
|
|
1251
|
+
...opts?.guards
|
|
1252
|
+
}
|
|
1253
|
+
}));
|
|
1254
|
+
if (typeof opts?.subscription === "function") {
|
|
1255
|
+
newInst.onTransition(opts.subscription);
|
|
1256
|
+
}
|
|
1257
|
+
if (opts?.requireCustomNavigationHook !== true) {
|
|
1258
|
+
newInst.onTransition((snapshot) => {
|
|
1259
|
+
if (opts?.stateNavigationListener) {
|
|
1260
|
+
void opts.stateNavigationListener(newInst, snapshot);
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
return newInst;
|
|
1265
|
+
}
|
|
1266
|
+
static getInstance(opts) {
|
|
1267
|
+
if (!_FirstPartyMachine._instance) {
|
|
1268
|
+
if (opts?.requireExisting === true) {
|
|
1269
|
+
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1270
|
+
}
|
|
1271
|
+
_FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
|
|
1272
|
+
}
|
|
1273
|
+
return _FirstPartyMachine._instance;
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
1278
|
+
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1279
|
+
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
1280
|
+
return oid4vciCombineDisplayLocalesFrom({
|
|
1281
|
+
...issuerCredentialSubject && {
|
|
1282
|
+
issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
|
|
1283
|
+
issuerCredentialSubject
|
|
1284
|
+
})
|
|
1285
|
+
},
|
|
1286
|
+
...credentialDisplay && {
|
|
1287
|
+
credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
|
|
1288
|
+
credentialDisplay
|
|
1289
|
+
})
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
}, "oid4vciGetCredentialBrandingFrom");
|
|
1293
|
+
var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1294
|
+
const { credentialDisplay } = args;
|
|
1295
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1296
|
+
const localeKey = display.locale || "";
|
|
1297
|
+
localeDisplays.set(localeKey, display);
|
|
1298
|
+
return localeDisplays;
|
|
1299
|
+
}, /* @__PURE__ */ new Map());
|
|
1300
|
+
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1301
|
+
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1302
|
+
const { issuerCredentialSubject } = args;
|
|
1303
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
1304
|
+
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1305
|
+
Object.entries(claim).forEach(([key, value]) => {
|
|
1306
|
+
if (key === "mandatory" || key === "value_type") {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
if (key === "display" && Array.isArray(value)) {
|
|
1310
|
+
value.forEach(({ name, locale = "" }) => {
|
|
1311
|
+
if (!name) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
if (!localeClaims.has(locale)) {
|
|
1315
|
+
localeClaims.set(locale, []);
|
|
1316
|
+
}
|
|
1317
|
+
localeClaims.get(locale).push({
|
|
1318
|
+
key: parentKey,
|
|
1319
|
+
name
|
|
1320
|
+
});
|
|
1321
|
+
});
|
|
1322
|
+
} else if (typeof value === "object" && value !== null) {
|
|
1323
|
+
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
}, "processClaimObject");
|
|
1327
|
+
processClaimObject(issuerCredentialSubject);
|
|
1328
|
+
return localeClaims;
|
|
1329
|
+
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1330
|
+
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1331
|
+
const { credentialDisplay } = args;
|
|
1332
|
+
return {
|
|
1333
|
+
...credentialDisplay.name && {
|
|
1334
|
+
alias: credentialDisplay.name
|
|
1335
|
+
},
|
|
1336
|
+
...credentialDisplay.locale && {
|
|
1337
|
+
locale: credentialDisplay.locale
|
|
1338
|
+
},
|
|
1339
|
+
...credentialDisplay.logo && {
|
|
1340
|
+
logo: {
|
|
1341
|
+
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1342
|
+
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1343
|
+
},
|
|
1344
|
+
...credentialDisplay.logo.alt_text && {
|
|
1345
|
+
alt: credentialDisplay.logo?.alt_text
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
},
|
|
1349
|
+
...credentialDisplay.description && {
|
|
1350
|
+
description: credentialDisplay.description
|
|
1351
|
+
},
|
|
1352
|
+
...credentialDisplay.text_color && {
|
|
1353
|
+
text: {
|
|
1354
|
+
color: credentialDisplay.text_color
|
|
1355
|
+
}
|
|
1356
|
+
},
|
|
1357
|
+
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1358
|
+
background: {
|
|
1359
|
+
...credentialDisplay.background_image && {
|
|
1360
|
+
image: {
|
|
1361
|
+
...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
|
|
1362
|
+
uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
|
|
1363
|
+
},
|
|
1364
|
+
...credentialDisplay.background_image.alt_text && {
|
|
1365
|
+
alt: credentialDisplay.background_image?.alt_text
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
...credentialDisplay.background_color && {
|
|
1370
|
+
color: credentialDisplay.background_color
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1376
|
+
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1377
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1378
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1379
|
+
...issuerCredentialSubjectLocales.keys(),
|
|
1380
|
+
...credentialDisplayLocales.keys()
|
|
1381
|
+
]));
|
|
1382
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1383
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1384
|
+
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1385
|
+
return {
|
|
1386
|
+
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1387
|
+
credentialDisplay: display
|
|
1388
|
+
}),
|
|
1389
|
+
...locale.length > 0 && {
|
|
1390
|
+
locale
|
|
1391
|
+
},
|
|
1392
|
+
claims
|
|
1393
|
+
};
|
|
1394
|
+
}));
|
|
1395
|
+
}, "oid4vciCombineDisplayLocalesFrom");
|
|
1396
|
+
var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1397
|
+
const { credentialDisplay, claimsMetadata } = args;
|
|
1398
|
+
return sdJwtCombineDisplayLocalesFrom({
|
|
1399
|
+
...claimsMetadata && {
|
|
1400
|
+
claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
|
|
1401
|
+
claimsMetadata
|
|
1402
|
+
})
|
|
1403
|
+
},
|
|
1404
|
+
...credentialDisplay && {
|
|
1405
|
+
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1406
|
+
credentialDisplay
|
|
1407
|
+
})
|
|
1461
1408
|
}
|
|
1462
1409
|
});
|
|
1463
|
-
}, "
|
|
1464
|
-
var
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
if (stop) {
|
|
1482
|
-
_FirstPartyMachine.stopInstance();
|
|
1410
|
+
}, "sdJwtGetCredentialBrandingFrom");
|
|
1411
|
+
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1412
|
+
const { credentialDisplay } = args;
|
|
1413
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1414
|
+
const localeKey = display.lang || "";
|
|
1415
|
+
localeDisplays.set(localeKey, display);
|
|
1416
|
+
return localeDisplays;
|
|
1417
|
+
}, /* @__PURE__ */ new Map());
|
|
1418
|
+
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1419
|
+
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1420
|
+
const { claimsMetadata } = args;
|
|
1421
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
1422
|
+
claimsMetadata.forEach((claim) => {
|
|
1423
|
+
claim.display?.forEach((display) => {
|
|
1424
|
+
const { lang = "", label } = display;
|
|
1425
|
+
const key = claim.path.map((value) => String(value)).join(".");
|
|
1426
|
+
if (!localeClaims.has(lang)) {
|
|
1427
|
+
localeClaims.set(lang, []);
|
|
1483
1428
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1429
|
+
localeClaims.get(lang).push({
|
|
1430
|
+
key,
|
|
1431
|
+
name: label
|
|
1432
|
+
});
|
|
1433
|
+
});
|
|
1434
|
+
});
|
|
1435
|
+
return localeClaims;
|
|
1436
|
+
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1437
|
+
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1438
|
+
const { credentialDisplay } = args;
|
|
1439
|
+
return {
|
|
1440
|
+
...credentialDisplay.name && {
|
|
1441
|
+
alias: credentialDisplay.name
|
|
1442
|
+
},
|
|
1443
|
+
...credentialDisplay.lang && {
|
|
1444
|
+
locale: credentialDisplay.lang
|
|
1445
|
+
},
|
|
1446
|
+
...credentialDisplay.rendering?.simple?.logo && {
|
|
1447
|
+
logo: {
|
|
1448
|
+
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1449
|
+
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1450
|
+
},
|
|
1451
|
+
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1452
|
+
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
},
|
|
1456
|
+
...credentialDisplay.description && {
|
|
1457
|
+
description: credentialDisplay.description
|
|
1458
|
+
},
|
|
1459
|
+
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1460
|
+
text: {
|
|
1461
|
+
color: credentialDisplay.rendering.simple.text_color
|
|
1462
|
+
}
|
|
1463
|
+
},
|
|
1464
|
+
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1465
|
+
background: {
|
|
1466
|
+
color: credentialDisplay.rendering.simple.background_color
|
|
1509
1467
|
}
|
|
1510
|
-
}));
|
|
1511
|
-
if (typeof opts?.subscription === "function") {
|
|
1512
|
-
newInst.onTransition(opts.subscription);
|
|
1513
1468
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1469
|
+
};
|
|
1470
|
+
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1471
|
+
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1472
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1473
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1474
|
+
...claimsMetadata.keys(),
|
|
1475
|
+
...credentialDisplayLocales.keys()
|
|
1476
|
+
]));
|
|
1477
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1478
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1479
|
+
const claims = claimsMetadata.get(locale);
|
|
1480
|
+
return {
|
|
1481
|
+
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1482
|
+
credentialDisplay: display
|
|
1483
|
+
}),
|
|
1484
|
+
...locale.length > 0 && {
|
|
1485
|
+
locale
|
|
1486
|
+
},
|
|
1487
|
+
claims
|
|
1488
|
+
};
|
|
1489
|
+
}));
|
|
1490
|
+
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1491
|
+
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1492
|
+
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1493
|
+
return {
|
|
1494
|
+
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1495
|
+
alias: dynamicRegistrationClientMetadata.client_name
|
|
1496
|
+
},
|
|
1497
|
+
...issuerDisplay.name && {
|
|
1498
|
+
alias: issuerDisplay.name
|
|
1499
|
+
},
|
|
1500
|
+
...issuerDisplay.locale && {
|
|
1501
|
+
locale: issuerDisplay.locale
|
|
1502
|
+
},
|
|
1503
|
+
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1504
|
+
logo: {
|
|
1505
|
+
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1506
|
+
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1507
|
+
},
|
|
1508
|
+
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1509
|
+
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1510
|
+
},
|
|
1511
|
+
...issuerDisplay.logo?.alt_text && {
|
|
1512
|
+
alt: issuerDisplay.logo?.alt_text
|
|
1518
1513
|
}
|
|
1519
|
-
});
|
|
1520
|
-
}
|
|
1521
|
-
return newInst;
|
|
1522
|
-
}
|
|
1523
|
-
static getInstance(opts) {
|
|
1524
|
-
if (!_FirstPartyMachine._instance) {
|
|
1525
|
-
if (opts?.requireExisting === true) {
|
|
1526
|
-
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1527
1514
|
}
|
|
1528
|
-
|
|
1515
|
+
},
|
|
1516
|
+
...issuerDisplay.description && {
|
|
1517
|
+
description: issuerDisplay.description
|
|
1518
|
+
},
|
|
1519
|
+
...issuerDisplay.text_color && {
|
|
1520
|
+
text: {
|
|
1521
|
+
color: issuerDisplay.text_color
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1525
|
+
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1526
|
+
},
|
|
1527
|
+
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1528
|
+
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1529
|
+
},
|
|
1530
|
+
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1531
|
+
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1532
|
+
},
|
|
1533
|
+
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1534
|
+
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1529
1535
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
};
|
|
1536
|
+
};
|
|
1537
|
+
}, "issuerLocaleBrandingFrom");
|
|
1533
1538
|
|
|
1534
1539
|
// src/services/OID4VCIHolderService.ts
|
|
1535
|
-
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
1536
1540
|
var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
|
|
1537
1541
|
const { credentialsSupported, context } = args;
|
|
1538
1542
|
const credentialBranding = {};
|
|
1539
1543
|
await Promise.all(Object.entries(credentialsSupported).map(async ([configId, credentialsConfigSupported]) => {
|
|
1540
1544
|
let sdJwtTypeMetadata;
|
|
1541
|
-
if (credentialsConfigSupported.format === "
|
|
1545
|
+
if (credentialsConfigSupported.format === "dc+sd-jwt") {
|
|
1542
1546
|
const vct = credentialsConfigSupported.vct;
|
|
1543
1547
|
if (vct.startsWith("http")) {
|
|
1544
1548
|
try {
|
|
@@ -1604,10 +1608,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
|
|
|
1604
1608
|
}, "selectCredentialLocaleBranding");
|
|
1605
1609
|
var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1606
1610
|
const { mappedCredential, hasher, onVerifyEBSICredentialIssuer, schemaValidation, context } = args;
|
|
1607
|
-
const credential = mappedCredential.credentialToAccept.credentialResponse
|
|
1608
|
-
if (!credential) {
|
|
1609
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1610
|
-
}
|
|
1611
|
+
const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
|
|
1611
1612
|
const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credential, {
|
|
1612
1613
|
hasher: hasher ?? defaultHasher
|
|
1613
1614
|
});
|
|
@@ -1659,11 +1660,7 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1659
1660
|
}, "verifyCredentialToAccept");
|
|
1660
1661
|
var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1661
1662
|
const { credentialToAccept, hasher } = args;
|
|
1662
|
-
const
|
|
1663
|
-
const verifiableCredential = credentialResponse.credential;
|
|
1664
|
-
if (!verifiableCredential) {
|
|
1665
|
-
return Promise.reject(Error("No credential found in credential response"));
|
|
1666
|
-
}
|
|
1663
|
+
const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
|
|
1667
1664
|
const wrappedVerifiableCredential = CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
|
|
1668
1665
|
hasher
|
|
1669
1666
|
});
|
|
@@ -1683,6 +1680,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1683
1680
|
uniformVerifiableCredential = wrappedVerifiableCredential.credential;
|
|
1684
1681
|
}
|
|
1685
1682
|
const correlationId = typeof uniformVerifiableCredential.issuer === "string" ? uniformVerifiableCredential.issuer : CredentialMapper.isSdJwtDecodedCredential(uniformVerifiableCredential) ? uniformVerifiableCredential.decodedPayload.iss : uniformVerifiableCredential.issuer.id;
|
|
1683
|
+
const credentialResponse = credentialToAccept.credentialResponse;
|
|
1686
1684
|
return {
|
|
1687
1685
|
correlationId,
|
|
1688
1686
|
credentialToAccept,
|
|
@@ -1694,6 +1692,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1694
1692
|
}
|
|
1695
1693
|
};
|
|
1696
1694
|
}, "mapCredentialToAccept");
|
|
1695
|
+
var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse) => {
|
|
1696
|
+
let credential;
|
|
1697
|
+
if ("credential" in credentialResponse) {
|
|
1698
|
+
credential = credentialResponse.credential;
|
|
1699
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1700
|
+
credential = credentialResponse.credentials[0].credential;
|
|
1701
|
+
}
|
|
1702
|
+
if (!credential) {
|
|
1703
|
+
throw new Error("No credential found in credential response");
|
|
1704
|
+
}
|
|
1705
|
+
return credential;
|
|
1706
|
+
}, "extractCredentialFromResponse");
|
|
1697
1707
|
var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
1698
1708
|
const { issuanceOpt, context } = args;
|
|
1699
1709
|
const { identifier: identifierArg } = issuanceOpt;
|
|
@@ -1802,24 +1812,19 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
|
|
|
1802
1812
|
}
|
|
1803
1813
|
__name(createIdFromTypes, "createIdFromTypes");
|
|
1804
1814
|
if (configurationId) {
|
|
1805
|
-
const allSupported2 = client.getCredentialsSupported(
|
|
1815
|
+
const allSupported2 = client.getCredentialsSupported(format);
|
|
1806
1816
|
return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
|
|
1807
1817
|
}
|
|
1808
|
-
if (!
|
|
1809
|
-
return Promise.reject(Error("openID4VCIClient has no credentialOffer
|
|
1818
|
+
if (!client.credentialOffer) {
|
|
1819
|
+
return Promise.reject(Error("openID4VCIClient has no credentialOffer"));
|
|
1810
1820
|
}
|
|
1811
|
-
if (!
|
|
1812
|
-
|
|
1813
|
-
format = client.credentialOffer.credential_offer.credentials.filter((cred) => typeof cred !== "string").map((cred) => cred.format);
|
|
1814
|
-
if (format?.length === 0) {
|
|
1815
|
-
format = void 0;
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1821
|
+
if (!types) {
|
|
1822
|
+
return Promise.reject(Error("openID4VCIClient has no types"));
|
|
1818
1823
|
}
|
|
1819
1824
|
const offerSupported = getSupportedCredentials({
|
|
1820
|
-
types:
|
|
1825
|
+
types: [
|
|
1821
1826
|
types
|
|
1822
|
-
]
|
|
1827
|
+
],
|
|
1823
1828
|
format,
|
|
1824
1829
|
version: client.version(),
|
|
1825
1830
|
issuerMetadata: client.endpointMetadata.credentialIssuerMetadata
|
|
@@ -1994,7 +1999,8 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
|
|
|
1994
1999
|
case "jwt":
|
|
1995
2000
|
case "jwt_vc_json":
|
|
1996
2001
|
case "jwt_vc":
|
|
1997
|
-
case
|
|
2002
|
+
//case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
2003
|
+
case "dc+sd-jwt":
|
|
1998
2004
|
case "mso_mdoc": {
|
|
1999
2005
|
const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
|
|
2000
2006
|
if (supportedPreferences.length > 0) {
|
|
@@ -2062,8 +2068,6 @@ var startFirstPartApplicationMachine = /* @__PURE__ */ __name(async (args, conte
|
|
|
2062
2068
|
}, "startFirstPartApplicationMachine");
|
|
2063
2069
|
|
|
2064
2070
|
// src/agent/OID4VCIHolder.ts
|
|
2065
|
-
import "cross-fetch/polyfill";
|
|
2066
|
-
import { defaultHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
2067
2071
|
var oid4vciHolderContextMethods = [
|
|
2068
2072
|
"cmGetContacts",
|
|
2069
2073
|
"cmGetContact",
|
|
@@ -2079,7 +2083,7 @@ var oid4vciHolderContextMethods = [
|
|
|
2079
2083
|
];
|
|
2080
2084
|
var logger = Loggers.DEFAULT.get("sphereon:oid4vci:holder");
|
|
2081
2085
|
function signCallback(identifier, context, nonce) {
|
|
2082
|
-
return async (jwt, kid) => {
|
|
2086
|
+
return async (jwt, kid, noIssPayloadUpdate) => {
|
|
2083
2087
|
let resolution = await context.agent.identifierManagedGet(identifier);
|
|
2084
2088
|
const jwk = jwt.header.jwk ?? (resolution.method === "jwk" ? resolution.jwk : void 0);
|
|
2085
2089
|
if (!resolution.issuer && !jwt.payload.iss) {
|
|
@@ -2097,7 +2101,7 @@ function signCallback(identifier, context, nonce) {
|
|
|
2097
2101
|
return (await context.agent.jwtCreateJwsCompactSignature({
|
|
2098
2102
|
issuer: {
|
|
2099
2103
|
...resolution,
|
|
2100
|
-
noIssPayloadUpdate: false
|
|
2104
|
+
noIssPayloadUpdate: noIssPayloadUpdate ?? false
|
|
2101
2105
|
},
|
|
2102
2106
|
protectedHeader: header,
|
|
2103
2107
|
payload
|
|
@@ -2132,6 +2136,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2132
2136
|
oid4vciHolderStoreIssuerBranding: this.oid4vciHolderStoreIssuerBranding.bind(this)
|
|
2133
2137
|
};
|
|
2134
2138
|
vcFormatPreferences = [
|
|
2139
|
+
"dc+sd-jwt",
|
|
2135
2140
|
"vc+sd-jwt",
|
|
2136
2141
|
"mso_mdoc",
|
|
2137
2142
|
"jwt_vc_json",
|
|
@@ -2283,7 +2288,6 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2283
2288
|
formats = Array.from(new Set(authFormats));
|
|
2284
2289
|
}
|
|
2285
2290
|
let oid4vciClient;
|
|
2286
|
-
let types = void 0;
|
|
2287
2291
|
let offer;
|
|
2288
2292
|
if (requestData.existingClientState) {
|
|
2289
2293
|
oid4vciClient = await OpenID4VCIClient2.fromState({
|
|
@@ -2319,17 +2323,18 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2319
2323
|
});
|
|
2320
2324
|
}
|
|
2321
2325
|
}
|
|
2326
|
+
let configurationIds = [];
|
|
2322
2327
|
if (offer) {
|
|
2323
|
-
|
|
2328
|
+
configurationIds = offer.original_credential_offer.credential_configuration_ids;
|
|
2324
2329
|
} else {
|
|
2325
|
-
|
|
2330
|
+
configurationIds = asArray2(authorizationRequestOpts.authorizationDetails).filter((authDetails) => typeof authDetails !== "string").map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
|
|
2326
2331
|
}
|
|
2327
|
-
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2328
2332
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
2329
2333
|
client: oid4vciClient,
|
|
2330
2334
|
vcFormatPreferences: formats,
|
|
2331
|
-
|
|
2335
|
+
configurationIds
|
|
2332
2336
|
});
|
|
2337
|
+
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2333
2338
|
const credentialBranding = await getCredentialBranding({
|
|
2334
2339
|
credentialsSupported,
|
|
2335
2340
|
context
|
|
@@ -2718,7 +2723,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2718
2723
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2719
2724
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2720
2725
|
logger.log(`Subject issuance/signing will be used, with event`, event);
|
|
2721
|
-
const issuerVC = mappedCredentialToAccept.credentialToAccept.credentialResponse
|
|
2726
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
|
|
2722
2727
|
const wrappedIssuerVC = CredentialMapper2.toWrappedVerifiableCredential(issuerVC, {
|
|
2723
2728
|
hasher: this.hasher ?? defaultHasher2
|
|
2724
2729
|
});
|
|
@@ -3089,6 +3094,7 @@ export {
|
|
|
3089
3094
|
RequestType,
|
|
3090
3095
|
SupportedLanguage,
|
|
3091
3096
|
createConfig,
|
|
3097
|
+
extractCredentialFromResponse,
|
|
3092
3098
|
getBasicIssuerLocaleBranding,
|
|
3093
3099
|
getCredentialBranding,
|
|
3094
3100
|
getCredentialConfigsBasedOnFormatPref,
|