@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feature.SSISDK.26.RP.58 → 0.34.1-feature.SSISDK.45.189
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 +439 -448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +439 -448
- package/dist/index.js.map +1 -1
- package/package.json +25 -24
- package/src/agent/OID4VCIHolder.ts +14 -20
- package/src/services/OID4VCIHolderService.ts +44 -62
- package/src/types/FirstPartyMachine.ts +6 -5
package/dist/index.js
CHANGED
|
@@ -56,13 +56,13 @@ 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, getTypesFromAuthorizationDetails,
|
|
59
|
+
import { DefaultURISchemes, getTypesFromAuthorizationDetails, getTypesFromCredentialSupported as getTypesFromCredentialSupported2, 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";
|
|
65
|
+
import { CredentialMapper as CredentialMapper2, JoseSignatureAlgorithm as JoseSignatureAlgorithm2, Loggers, parseDid, CredentialRole } from "@sphereon/ssi-types";
|
|
66
66
|
import { asArray as asArray2, computeEntryHash } from "@veramo/utils";
|
|
67
67
|
import { decodeJWT } from "did-jwt";
|
|
68
68
|
import { v4 as uuidv42 } from "uuid";
|
|
@@ -76,18 +76,18 @@ import i18n from "i18n-js";
|
|
|
76
76
|
import memoize from "lodash.memoize";
|
|
77
77
|
|
|
78
78
|
// src/types/IOID4VCIHolder.ts
|
|
79
|
-
var OID4VCIHolderEvent = /* @__PURE__ */ function(OID4VCIHolderEvent2) {
|
|
79
|
+
var OID4VCIHolderEvent = /* @__PURE__ */ (function(OID4VCIHolderEvent2) {
|
|
80
80
|
OID4VCIHolderEvent2["CONTACT_IDENTITY_CREATED"] = "contact_identity_created";
|
|
81
81
|
OID4VCIHolderEvent2["CREDENTIAL_STORED"] = "credential_stored";
|
|
82
82
|
OID4VCIHolderEvent2["IDENTIFIER_CREATED"] = "identifier_created";
|
|
83
83
|
return OID4VCIHolderEvent2;
|
|
84
|
-
}({});
|
|
85
|
-
var SupportedLanguage = /* @__PURE__ */ function(SupportedLanguage2) {
|
|
84
|
+
})({});
|
|
85
|
+
var SupportedLanguage = /* @__PURE__ */ (function(SupportedLanguage2) {
|
|
86
86
|
SupportedLanguage2["ENGLISH"] = "en";
|
|
87
87
|
SupportedLanguage2["DUTCH"] = "nl";
|
|
88
88
|
return SupportedLanguage2;
|
|
89
|
-
}({});
|
|
90
|
-
var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
89
|
+
})({});
|
|
90
|
+
var OID4VCIMachineStates = /* @__PURE__ */ (function(OID4VCIMachineStates2) {
|
|
91
91
|
OID4VCIMachineStates2["start"] = "start";
|
|
92
92
|
OID4VCIMachineStates2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
93
93
|
OID4VCIMachineStates2["getContact"] = "getContact";
|
|
@@ -118,18 +118,18 @@ var OID4VCIMachineStates = /* @__PURE__ */ function(OID4VCIMachineStates2) {
|
|
|
118
118
|
OID4VCIMachineStates2["error"] = "error";
|
|
119
119
|
OID4VCIMachineStates2["done"] = "done";
|
|
120
120
|
return OID4VCIMachineStates2;
|
|
121
|
-
}({});
|
|
122
|
-
var OID4VCIMachineAddContactStates = /* @__PURE__ */ function(OID4VCIMachineAddContactStates2) {
|
|
121
|
+
})({});
|
|
122
|
+
var OID4VCIMachineAddContactStates = /* @__PURE__ */ (function(OID4VCIMachineAddContactStates2) {
|
|
123
123
|
OID4VCIMachineAddContactStates2["idle"] = "idle";
|
|
124
124
|
OID4VCIMachineAddContactStates2["next"] = "next";
|
|
125
125
|
return OID4VCIMachineAddContactStates2;
|
|
126
|
-
}({});
|
|
127
|
-
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ function(OID4VCIMachineVerifyPinStates2) {
|
|
126
|
+
})({});
|
|
127
|
+
var OID4VCIMachineVerifyPinStates = /* @__PURE__ */ (function(OID4VCIMachineVerifyPinStates2) {
|
|
128
128
|
OID4VCIMachineVerifyPinStates2["idle"] = "idle";
|
|
129
129
|
OID4VCIMachineVerifyPinStates2["next"] = "next";
|
|
130
130
|
return OID4VCIMachineVerifyPinStates2;
|
|
131
|
-
}({});
|
|
132
|
-
var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
131
|
+
})({});
|
|
132
|
+
var OID4VCIMachineEvents = /* @__PURE__ */ (function(OID4VCIMachineEvents2) {
|
|
133
133
|
OID4VCIMachineEvents2["NEXT"] = "NEXT";
|
|
134
134
|
OID4VCIMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
135
135
|
OID4VCIMachineEvents2["DECLINE"] = "DECLINE";
|
|
@@ -142,8 +142,8 @@ var OID4VCIMachineEvents = /* @__PURE__ */ function(OID4VCIMachineEvents2) {
|
|
|
142
142
|
OID4VCIMachineEvents2["INVOKED_AUTHORIZATION_CODE_REQUEST"] = "INVOKED_AUTHORIZATION_CODE_REQUEST";
|
|
143
143
|
OID4VCIMachineEvents2["PROVIDE_AUTHORIZATION_CODE_RESPONSE"] = "PROVIDE_AUTHORIZATION_CODE_RESPONSE";
|
|
144
144
|
return OID4VCIMachineEvents2;
|
|
145
|
-
}({});
|
|
146
|
-
var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
145
|
+
})({});
|
|
146
|
+
var OID4VCIMachineGuards = /* @__PURE__ */ (function(OID4VCIMachineGuards2) {
|
|
147
147
|
OID4VCIMachineGuards2["hasContactGuard"] = "oid4vciHasContactGuard";
|
|
148
148
|
OID4VCIMachineGuards2["hasNoContactGuard"] = "oid4vciHasNoContactGuard";
|
|
149
149
|
OID4VCIMachineGuards2["credentialsToSelectRequiredGuard"] = "oid4vciCredentialsToSelectRequiredGuard";
|
|
@@ -160,8 +160,8 @@ var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
|
160
160
|
OID4VCIMachineGuards2["contactHasLowTrustGuard"] = "oid4vciContactHasLowTrustGuard";
|
|
161
161
|
OID4VCIMachineGuards2["isFirstPartyApplication"] = "oid4vciIsFirstPartyApplication";
|
|
162
162
|
return OID4VCIMachineGuards2;
|
|
163
|
-
}({});
|
|
164
|
-
var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
163
|
+
})({});
|
|
164
|
+
var OID4VCIMachineServices = /* @__PURE__ */ (function(OID4VCIMachineServices2) {
|
|
165
165
|
OID4VCIMachineServices2["start"] = "start";
|
|
166
166
|
OID4VCIMachineServices2["getContact"] = "getContact";
|
|
167
167
|
OID4VCIMachineServices2["getFederationTrust"] = "getFederationTrust";
|
|
@@ -176,17 +176,17 @@ var OID4VCIMachineServices = /* @__PURE__ */ function(OID4VCIMachineServices2) {
|
|
|
176
176
|
OID4VCIMachineServices2["storeCredentials"] = "storeCredentials";
|
|
177
177
|
OID4VCIMachineServices2["startFirstPartApplicationFlow"] = "startFirstPartApplicationFlow";
|
|
178
178
|
return OID4VCIMachineServices2;
|
|
179
|
-
}({});
|
|
180
|
-
var RequestType = /* @__PURE__ */ function(RequestType2) {
|
|
179
|
+
})({});
|
|
180
|
+
var RequestType = /* @__PURE__ */ (function(RequestType2) {
|
|
181
181
|
RequestType2["OPENID_INITIATE_ISSUANCE"] = "openid-initiate-issuance";
|
|
182
182
|
RequestType2["OPENID_CREDENTIAL_OFFER"] = "openid-credential-offer";
|
|
183
183
|
RequestType2["URL"] = "URL";
|
|
184
184
|
return RequestType2;
|
|
185
|
-
}({});
|
|
186
|
-
var IdentifierAliasEnum = /* @__PURE__ */ function(IdentifierAliasEnum2) {
|
|
185
|
+
})({});
|
|
186
|
+
var IdentifierAliasEnum = /* @__PURE__ */ (function(IdentifierAliasEnum2) {
|
|
187
187
|
IdentifierAliasEnum2["PRIMARY"] = "primary";
|
|
188
188
|
return IdentifierAliasEnum2;
|
|
189
|
-
}({});
|
|
189
|
+
})({});
|
|
190
190
|
|
|
191
191
|
// src/localization/Localization.ts
|
|
192
192
|
var Localization = class Localization2 {
|
|
@@ -228,7 +228,7 @@ var Localization = class Localization2 {
|
|
|
228
228
|
var translate = Localization.translate;
|
|
229
229
|
|
|
230
230
|
// src/types/FirstPartyMachine.ts
|
|
231
|
-
var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStateTypes2) {
|
|
231
|
+
var FirstPartyMachineStateTypes = /* @__PURE__ */ (function(FirstPartyMachineStateTypes2) {
|
|
232
232
|
FirstPartyMachineStateTypes2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
233
233
|
FirstPartyMachineStateTypes2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
234
234
|
FirstPartyMachineStateTypes2["selectCredentials"] = "selectCredentials";
|
|
@@ -239,21 +239,21 @@ var FirstPartyMachineStateTypes = /* @__PURE__ */ function(FirstPartyMachineStat
|
|
|
239
239
|
FirstPartyMachineStateTypes2["aborted"] = "aborted";
|
|
240
240
|
FirstPartyMachineStateTypes2["declined"] = "declined";
|
|
241
241
|
return FirstPartyMachineStateTypes2;
|
|
242
|
-
}({});
|
|
243
|
-
var FirstPartyMachineServices = /* @__PURE__ */ function(FirstPartyMachineServices2) {
|
|
242
|
+
})({});
|
|
243
|
+
var FirstPartyMachineServices = /* @__PURE__ */ (function(FirstPartyMachineServices2) {
|
|
244
244
|
FirstPartyMachineServices2["sendAuthorizationChallengeRequest"] = "sendAuthorizationChallengeRequest";
|
|
245
245
|
FirstPartyMachineServices2["sendAuthorizationResponse"] = "sendAuthorizationResponse";
|
|
246
246
|
FirstPartyMachineServices2["createConfig"] = "createConfig";
|
|
247
247
|
FirstPartyMachineServices2["getSiopRequest"] = "getSiopRequest";
|
|
248
248
|
return FirstPartyMachineServices2;
|
|
249
|
-
}({});
|
|
250
|
-
var FirstPartyMachineEvents = /* @__PURE__ */ function(FirstPartyMachineEvents2) {
|
|
249
|
+
})({});
|
|
250
|
+
var FirstPartyMachineEvents = /* @__PURE__ */ (function(FirstPartyMachineEvents2) {
|
|
251
251
|
FirstPartyMachineEvents2["NEXT"] = "NEXT";
|
|
252
252
|
FirstPartyMachineEvents2["PREVIOUS"] = "PREVIOUS";
|
|
253
253
|
FirstPartyMachineEvents2["DECLINE"] = "DECLINE";
|
|
254
254
|
FirstPartyMachineEvents2["SET_SELECTED_CREDENTIALS"] = "SET_SELECTED_CREDENTIALS";
|
|
255
255
|
return FirstPartyMachineEvents2;
|
|
256
|
-
}({});
|
|
256
|
+
})({});
|
|
257
257
|
|
|
258
258
|
// src/machines/oid4vciMachine.ts
|
|
259
259
|
var oid4vciHasNoContactGuard = /* @__PURE__ */ __name((_ctx, _event) => {
|
|
@@ -978,14 +978,300 @@ var OID4VCIMachine = class {
|
|
|
978
978
|
|
|
979
979
|
// src/services/OID4VCIHolderService.ts
|
|
980
980
|
import { LOG } from "@sphereon/oid4vci-client";
|
|
981
|
-
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject
|
|
981
|
+
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject } from "@sphereon/oid4vci-common";
|
|
982
982
|
import { KeyUse } from "@sphereon/ssi-sdk-ext.did-resolver-jwk";
|
|
983
983
|
import { getOrCreatePrimaryIdentifier, SupportedDidMethodEnum } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
984
984
|
import { isIIdentifier, isManagedIdentifierDidResult, isManagedIdentifierResult, managedIdentifierToJwk } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
985
985
|
import { keyTypeFromCryptographicSuite } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
986
|
+
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
986
987
|
import { CredentialMapper, JoseSignatureAlgorithm, mdocDecodedCredentialToUniformCredential, sdJwtDecodedCredentialToUniformCredential } from "@sphereon/ssi-types";
|
|
987
988
|
import { asArray } from "@veramo/utils";
|
|
988
989
|
|
|
990
|
+
// src/machines/firstPartyMachine.ts
|
|
991
|
+
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
992
|
+
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
993
|
+
|
|
994
|
+
// src/services/FirstPartyMachineServices.ts
|
|
995
|
+
import { OpenID4VCIClient } from "@sphereon/oid4vci-client";
|
|
996
|
+
import { v4 as uuidv4 } from "uuid";
|
|
997
|
+
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
998
|
+
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
999
|
+
const oid4vciClient = await OpenID4VCIClient.fromState({
|
|
1000
|
+
state: openID4VCIClientState
|
|
1001
|
+
});
|
|
1002
|
+
return oid4vciClient.acquireAuthorizationChallengeCode({
|
|
1003
|
+
clientId: oid4vciClient.clientId ?? uuidv4(),
|
|
1004
|
+
...authSession && {
|
|
1005
|
+
authSession
|
|
1006
|
+
},
|
|
1007
|
+
...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
|
|
1008
|
+
issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
|
|
1009
|
+
},
|
|
1010
|
+
...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
|
|
1011
|
+
issuerState: openID4VCIClientState.credentialOffer?.issuerState
|
|
1012
|
+
},
|
|
1013
|
+
...presentationDuringIssuanceSession && {
|
|
1014
|
+
presentationDuringIssuanceSession
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
}, "sendAuthorizationChallengeRequest");
|
|
1018
|
+
var createConfig = /* @__PURE__ */ __name(async (args, context) => {
|
|
1019
|
+
const { presentationUri } = args;
|
|
1020
|
+
if (!presentationUri) {
|
|
1021
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1022
|
+
}
|
|
1023
|
+
return context.agent.siopCreateConfig({
|
|
1024
|
+
url: presentationUri
|
|
1025
|
+
});
|
|
1026
|
+
}, "createConfig");
|
|
1027
|
+
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1028
|
+
const { didAuthConfig, presentationUri } = args;
|
|
1029
|
+
if (presentationUri === void 0) {
|
|
1030
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1031
|
+
}
|
|
1032
|
+
if (didAuthConfig === void 0) {
|
|
1033
|
+
return Promise.reject(Error("Missing did auth config in context"));
|
|
1034
|
+
}
|
|
1035
|
+
return context.agent.siopGetSiopRequest({
|
|
1036
|
+
didAuthConfig,
|
|
1037
|
+
url: presentationUri
|
|
1038
|
+
});
|
|
1039
|
+
}, "getSiopRequest");
|
|
1040
|
+
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1041
|
+
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1042
|
+
const responseData = await context.agent.siopSendResponse({
|
|
1043
|
+
authorizationRequestData,
|
|
1044
|
+
selectedCredentials,
|
|
1045
|
+
didAuthConfig,
|
|
1046
|
+
isFirstParty: true
|
|
1047
|
+
});
|
|
1048
|
+
return responseData.body.presentation_during_issuance_session;
|
|
1049
|
+
}, "sendAuthorizationResponse");
|
|
1050
|
+
|
|
1051
|
+
// src/machines/firstPartyMachine.ts
|
|
1052
|
+
var firstPartyMachineStates = {
|
|
1053
|
+
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1054
|
+
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1055
|
+
invoke: {
|
|
1056
|
+
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1057
|
+
onDone: {
|
|
1058
|
+
target: FirstPartyMachineStateTypes.done,
|
|
1059
|
+
actions: assign2({
|
|
1060
|
+
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1061
|
+
})
|
|
1062
|
+
},
|
|
1063
|
+
onError: [
|
|
1064
|
+
{
|
|
1065
|
+
target: FirstPartyMachineStateTypes.createConfig,
|
|
1066
|
+
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1067
|
+
actions: assign2({
|
|
1068
|
+
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1069
|
+
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1070
|
+
})
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1074
|
+
actions: assign2({
|
|
1075
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1076
|
+
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1077
|
+
message: _event.data.message,
|
|
1078
|
+
stack: _event.data.stack
|
|
1079
|
+
}), "error")
|
|
1080
|
+
})
|
|
1081
|
+
}
|
|
1082
|
+
]
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1086
|
+
id: FirstPartyMachineStateTypes.createConfig,
|
|
1087
|
+
invoke: {
|
|
1088
|
+
src: FirstPartyMachineServices.createConfig,
|
|
1089
|
+
onDone: {
|
|
1090
|
+
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1091
|
+
actions: assign2({
|
|
1092
|
+
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1093
|
+
})
|
|
1094
|
+
},
|
|
1095
|
+
onError: {
|
|
1096
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1097
|
+
actions: assign2({
|
|
1098
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1099
|
+
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1100
|
+
message: _event.data.message,
|
|
1101
|
+
stack: _event.data.stack
|
|
1102
|
+
}), "error")
|
|
1103
|
+
})
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
},
|
|
1107
|
+
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1108
|
+
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1109
|
+
invoke: {
|
|
1110
|
+
src: FirstPartyMachineServices.getSiopRequest,
|
|
1111
|
+
onDone: {
|
|
1112
|
+
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1113
|
+
actions: assign2({
|
|
1114
|
+
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1115
|
+
})
|
|
1116
|
+
},
|
|
1117
|
+
onError: {
|
|
1118
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1119
|
+
actions: assign2({
|
|
1120
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1121
|
+
title: translate("siopV2_machine_get_request_error_title"),
|
|
1122
|
+
message: _event.data.message,
|
|
1123
|
+
stack: _event.data.stack
|
|
1124
|
+
}), "error")
|
|
1125
|
+
})
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
},
|
|
1129
|
+
[FirstPartyMachineStateTypes.selectCredentials]: {
|
|
1130
|
+
id: FirstPartyMachineStateTypes.selectCredentials,
|
|
1131
|
+
on: {
|
|
1132
|
+
[FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS]: {
|
|
1133
|
+
actions: assign2({
|
|
1134
|
+
selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
|
|
1135
|
+
})
|
|
1136
|
+
},
|
|
1137
|
+
[FirstPartyMachineEvents.NEXT]: {
|
|
1138
|
+
target: FirstPartyMachineStateTypes.sendAuthorizationResponse
|
|
1139
|
+
},
|
|
1140
|
+
[FirstPartyMachineEvents.DECLINE]: {
|
|
1141
|
+
target: FirstPartyMachineStateTypes.declined
|
|
1142
|
+
},
|
|
1143
|
+
[FirstPartyMachineEvents.PREVIOUS]: {
|
|
1144
|
+
target: FirstPartyMachineStateTypes.aborted
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1148
|
+
[FirstPartyMachineStateTypes.sendAuthorizationResponse]: {
|
|
1149
|
+
id: FirstPartyMachineStateTypes.sendAuthorizationResponse,
|
|
1150
|
+
invoke: {
|
|
1151
|
+
src: FirstPartyMachineServices.sendAuthorizationResponse,
|
|
1152
|
+
onDone: {
|
|
1153
|
+
target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1154
|
+
actions: assign2({
|
|
1155
|
+
presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
|
|
1156
|
+
})
|
|
1157
|
+
},
|
|
1158
|
+
onError: {
|
|
1159
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1160
|
+
actions: assign2({
|
|
1161
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1162
|
+
title: translate("oid4vci_machine_get_request_error_title"),
|
|
1163
|
+
message: _event.data.message,
|
|
1164
|
+
stack: _event.data.stack
|
|
1165
|
+
}), "error")
|
|
1166
|
+
})
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
[FirstPartyMachineStateTypes.aborted]: {
|
|
1171
|
+
id: FirstPartyMachineStateTypes.aborted,
|
|
1172
|
+
type: "final"
|
|
1173
|
+
},
|
|
1174
|
+
[FirstPartyMachineStateTypes.declined]: {
|
|
1175
|
+
id: FirstPartyMachineStateTypes.declined,
|
|
1176
|
+
type: "final"
|
|
1177
|
+
},
|
|
1178
|
+
[FirstPartyMachineStateTypes.error]: {
|
|
1179
|
+
id: FirstPartyMachineStateTypes.error,
|
|
1180
|
+
type: "final"
|
|
1181
|
+
},
|
|
1182
|
+
[FirstPartyMachineStateTypes.done]: {
|
|
1183
|
+
id: FirstPartyMachineStateTypes.done,
|
|
1184
|
+
type: "final"
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
1188
|
+
const initialContext = {
|
|
1189
|
+
openID4VCIClientState: opts.openID4VCIClientState,
|
|
1190
|
+
contact: opts.contact,
|
|
1191
|
+
selectedCredentials: []
|
|
1192
|
+
};
|
|
1193
|
+
return createMachine2({
|
|
1194
|
+
id: opts?.machineId ?? "FirstParty",
|
|
1195
|
+
predictableActionArguments: true,
|
|
1196
|
+
initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1197
|
+
context: initialContext,
|
|
1198
|
+
states: firstPartyMachineStates,
|
|
1199
|
+
schema: {
|
|
1200
|
+
events: {},
|
|
1201
|
+
services: {}
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
}, "createFirstPartyActivationMachine");
|
|
1205
|
+
var FirstPartyMachine = class _FirstPartyMachine {
|
|
1206
|
+
static {
|
|
1207
|
+
__name(this, "FirstPartyMachine");
|
|
1208
|
+
}
|
|
1209
|
+
static _instance;
|
|
1210
|
+
static hasInstance() {
|
|
1211
|
+
return _FirstPartyMachine._instance !== void 0;
|
|
1212
|
+
}
|
|
1213
|
+
static get instance() {
|
|
1214
|
+
if (!_FirstPartyMachine._instance) {
|
|
1215
|
+
throw Error("Please initialize ESIMActivation machine first");
|
|
1216
|
+
}
|
|
1217
|
+
return _FirstPartyMachine._instance;
|
|
1218
|
+
}
|
|
1219
|
+
static clearInstance(opts) {
|
|
1220
|
+
const { stop } = opts;
|
|
1221
|
+
if (_FirstPartyMachine.hasInstance()) {
|
|
1222
|
+
if (stop) {
|
|
1223
|
+
_FirstPartyMachine.stopInstance();
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
_FirstPartyMachine._instance = void 0;
|
|
1227
|
+
}
|
|
1228
|
+
static stopInstance() {
|
|
1229
|
+
if (!_FirstPartyMachine.hasInstance()) {
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
_FirstPartyMachine.instance.stop();
|
|
1233
|
+
_FirstPartyMachine._instance = void 0;
|
|
1234
|
+
}
|
|
1235
|
+
static newInstance(opts) {
|
|
1236
|
+
const { agentContext } = opts;
|
|
1237
|
+
const services = {
|
|
1238
|
+
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1239
|
+
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1240
|
+
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1241
|
+
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1242
|
+
};
|
|
1243
|
+
const newInst = interpret2(createFirstPartyActivationMachine(opts).withConfig({
|
|
1244
|
+
services: {
|
|
1245
|
+
...services,
|
|
1246
|
+
...opts?.services
|
|
1247
|
+
},
|
|
1248
|
+
guards: {
|
|
1249
|
+
...opts?.guards
|
|
1250
|
+
}
|
|
1251
|
+
}));
|
|
1252
|
+
if (typeof opts?.subscription === "function") {
|
|
1253
|
+
newInst.onTransition(opts.subscription);
|
|
1254
|
+
}
|
|
1255
|
+
if (opts?.requireCustomNavigationHook !== true) {
|
|
1256
|
+
newInst.onTransition((snapshot) => {
|
|
1257
|
+
if (opts?.stateNavigationListener) {
|
|
1258
|
+
void opts.stateNavigationListener(newInst, snapshot);
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
return newInst;
|
|
1263
|
+
}
|
|
1264
|
+
static getInstance(opts) {
|
|
1265
|
+
if (!_FirstPartyMachine._instance) {
|
|
1266
|
+
if (opts?.requireExisting === true) {
|
|
1267
|
+
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1268
|
+
}
|
|
1269
|
+
_FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
|
|
1270
|
+
}
|
|
1271
|
+
return _FirstPartyMachine._instance;
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
|
|
989
1275
|
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
990
1276
|
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
991
1277
|
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
@@ -1150,391 +1436,105 @@ var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
|
1150
1436
|
const { credentialDisplay } = args;
|
|
1151
1437
|
return {
|
|
1152
1438
|
...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
|
-
// src/machines/firstPartyMachine.ts
|
|
1252
|
-
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
1253
|
-
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
1254
|
-
|
|
1255
|
-
// src/services/FirstPartyMachineServices.ts
|
|
1256
|
-
import { OpenID4VCIClient } from "@sphereon/oid4vci-client";
|
|
1257
|
-
import { v4 as uuidv4 } from "uuid";
|
|
1258
|
-
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
1259
|
-
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
1260
|
-
const oid4vciClient = await OpenID4VCIClient.fromState({
|
|
1261
|
-
state: openID4VCIClientState
|
|
1262
|
-
});
|
|
1263
|
-
return oid4vciClient.acquireAuthorizationChallengeCode({
|
|
1264
|
-
clientId: oid4vciClient.clientId ?? uuidv4(),
|
|
1265
|
-
...authSession && {
|
|
1266
|
-
authSession
|
|
1267
|
-
},
|
|
1268
|
-
...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
|
|
1269
|
-
issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
|
|
1270
|
-
},
|
|
1271
|
-
...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
|
|
1272
|
-
issuerState: openID4VCIClientState.credentialOffer?.issuerState
|
|
1273
|
-
},
|
|
1274
|
-
...presentationDuringIssuanceSession && {
|
|
1275
|
-
presentationDuringIssuanceSession
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
}, "sendAuthorizationChallengeRequest");
|
|
1279
|
-
var createConfig = /* @__PURE__ */ __name(async (args, context) => {
|
|
1280
|
-
const { presentationUri } = args;
|
|
1281
|
-
if (!presentationUri) {
|
|
1282
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1283
|
-
}
|
|
1284
|
-
return context.agent.siopCreateConfig({
|
|
1285
|
-
url: presentationUri
|
|
1286
|
-
});
|
|
1287
|
-
}, "createConfig");
|
|
1288
|
-
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1289
|
-
const { didAuthConfig, presentationUri } = args;
|
|
1290
|
-
if (presentationUri === void 0) {
|
|
1291
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1292
|
-
}
|
|
1293
|
-
if (didAuthConfig === void 0) {
|
|
1294
|
-
return Promise.reject(Error("Missing did auth config in context"));
|
|
1295
|
-
}
|
|
1296
|
-
return context.agent.siopGetSiopRequest({
|
|
1297
|
-
didAuthConfig,
|
|
1298
|
-
url: presentationUri
|
|
1299
|
-
});
|
|
1300
|
-
}, "getSiopRequest");
|
|
1301
|
-
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1302
|
-
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1303
|
-
const responseData = await context.agent.siopSendResponse({
|
|
1304
|
-
authorizationRequestData,
|
|
1305
|
-
selectedCredentials,
|
|
1306
|
-
didAuthConfig,
|
|
1307
|
-
isFirstParty: true
|
|
1308
|
-
});
|
|
1309
|
-
return responseData.body.presentation_during_issuance_session;
|
|
1310
|
-
}, "sendAuthorizationResponse");
|
|
1311
|
-
|
|
1312
|
-
// src/machines/firstPartyMachine.ts
|
|
1313
|
-
var firstPartyMachineStates = {
|
|
1314
|
-
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1315
|
-
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1316
|
-
invoke: {
|
|
1317
|
-
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1318
|
-
onDone: {
|
|
1319
|
-
target: FirstPartyMachineStateTypes.done,
|
|
1320
|
-
actions: assign2({
|
|
1321
|
-
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1322
|
-
})
|
|
1323
|
-
},
|
|
1324
|
-
onError: [
|
|
1325
|
-
{
|
|
1326
|
-
target: FirstPartyMachineStateTypes.createConfig,
|
|
1327
|
-
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1328
|
-
actions: assign2({
|
|
1329
|
-
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1330
|
-
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1331
|
-
})
|
|
1332
|
-
},
|
|
1333
|
-
{
|
|
1334
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1335
|
-
actions: assign2({
|
|
1336
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1337
|
-
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1338
|
-
message: _event.data.message,
|
|
1339
|
-
stack: _event.data.stack
|
|
1340
|
-
}), "error")
|
|
1341
|
-
})
|
|
1342
|
-
}
|
|
1343
|
-
]
|
|
1344
|
-
}
|
|
1345
|
-
},
|
|
1346
|
-
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1347
|
-
id: FirstPartyMachineStateTypes.createConfig,
|
|
1348
|
-
invoke: {
|
|
1349
|
-
src: FirstPartyMachineServices.createConfig,
|
|
1350
|
-
onDone: {
|
|
1351
|
-
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1352
|
-
actions: assign2({
|
|
1353
|
-
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1354
|
-
})
|
|
1355
|
-
},
|
|
1356
|
-
onError: {
|
|
1357
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1358
|
-
actions: assign2({
|
|
1359
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1360
|
-
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1361
|
-
message: _event.data.message,
|
|
1362
|
-
stack: _event.data.stack
|
|
1363
|
-
}), "error")
|
|
1364
|
-
})
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
},
|
|
1368
|
-
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1369
|
-
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1370
|
-
invoke: {
|
|
1371
|
-
src: FirstPartyMachineServices.getSiopRequest,
|
|
1372
|
-
onDone: {
|
|
1373
|
-
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1374
|
-
actions: assign2({
|
|
1375
|
-
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1376
|
-
})
|
|
1377
|
-
},
|
|
1378
|
-
onError: {
|
|
1379
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1380
|
-
actions: assign2({
|
|
1381
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1382
|
-
title: translate("siopV2_machine_get_request_error_title"),
|
|
1383
|
-
message: _event.data.message,
|
|
1384
|
-
stack: _event.data.stack
|
|
1385
|
-
}), "error")
|
|
1386
|
-
})
|
|
1439
|
+
alias: credentialDisplay.name
|
|
1440
|
+
},
|
|
1441
|
+
...credentialDisplay.lang && {
|
|
1442
|
+
locale: credentialDisplay.lang
|
|
1443
|
+
},
|
|
1444
|
+
...credentialDisplay.rendering?.simple?.logo && {
|
|
1445
|
+
logo: {
|
|
1446
|
+
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1447
|
+
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1448
|
+
},
|
|
1449
|
+
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1450
|
+
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1451
|
+
}
|
|
1387
1452
|
}
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
|
|
1396
|
-
})
|
|
1397
|
-
},
|
|
1398
|
-
[FirstPartyMachineEvents.NEXT]: {
|
|
1399
|
-
target: FirstPartyMachineStateTypes.sendAuthorizationResponse
|
|
1400
|
-
},
|
|
1401
|
-
[FirstPartyMachineEvents.DECLINE]: {
|
|
1402
|
-
target: FirstPartyMachineStateTypes.declined
|
|
1403
|
-
},
|
|
1404
|
-
[FirstPartyMachineEvents.PREVIOUS]: {
|
|
1405
|
-
target: FirstPartyMachineStateTypes.aborted
|
|
1453
|
+
},
|
|
1454
|
+
...credentialDisplay.description && {
|
|
1455
|
+
description: credentialDisplay.description
|
|
1456
|
+
},
|
|
1457
|
+
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1458
|
+
text: {
|
|
1459
|
+
color: credentialDisplay.rendering.simple.text_color
|
|
1406
1460
|
}
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
invoke: {
|
|
1412
|
-
src: FirstPartyMachineServices.sendAuthorizationResponse,
|
|
1413
|
-
onDone: {
|
|
1414
|
-
target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1415
|
-
actions: assign2({
|
|
1416
|
-
presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
|
|
1417
|
-
})
|
|
1418
|
-
},
|
|
1419
|
-
onError: {
|
|
1420
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1421
|
-
actions: assign2({
|
|
1422
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1423
|
-
title: translate("oid4vci_machine_get_request_error_title"),
|
|
1424
|
-
message: _event.data.message,
|
|
1425
|
-
stack: _event.data.stack
|
|
1426
|
-
}), "error")
|
|
1427
|
-
})
|
|
1461
|
+
},
|
|
1462
|
+
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1463
|
+
background: {
|
|
1464
|
+
color: credentialDisplay.rendering.simple.background_color
|
|
1428
1465
|
}
|
|
1429
1466
|
}
|
|
1430
|
-
},
|
|
1431
|
-
[FirstPartyMachineStateTypes.aborted]: {
|
|
1432
|
-
id: FirstPartyMachineStateTypes.aborted,
|
|
1433
|
-
type: "final"
|
|
1434
|
-
},
|
|
1435
|
-
[FirstPartyMachineStateTypes.declined]: {
|
|
1436
|
-
id: FirstPartyMachineStateTypes.declined,
|
|
1437
|
-
type: "final"
|
|
1438
|
-
},
|
|
1439
|
-
[FirstPartyMachineStateTypes.error]: {
|
|
1440
|
-
id: FirstPartyMachineStateTypes.error,
|
|
1441
|
-
type: "final"
|
|
1442
|
-
},
|
|
1443
|
-
[FirstPartyMachineStateTypes.done]: {
|
|
1444
|
-
id: FirstPartyMachineStateTypes.done,
|
|
1445
|
-
type: "final"
|
|
1446
|
-
}
|
|
1447
|
-
};
|
|
1448
|
-
var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
1449
|
-
const initialContext = {
|
|
1450
|
-
openID4VCIClientState: opts.openID4VCIClientState,
|
|
1451
|
-
contact: opts.contact,
|
|
1452
|
-
selectedCredentials: []
|
|
1453
1467
|
};
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
static _instance;
|
|
1471
|
-
static hasInstance() {
|
|
1472
|
-
return _FirstPartyMachine._instance !== void 0;
|
|
1473
|
-
}
|
|
1474
|
-
static get instance() {
|
|
1475
|
-
if (!_FirstPartyMachine._instance) {
|
|
1476
|
-
throw Error("Please initialize ESIMActivation machine first");
|
|
1477
|
-
}
|
|
1478
|
-
return _FirstPartyMachine._instance;
|
|
1479
|
-
}
|
|
1480
|
-
static clearInstance(opts) {
|
|
1481
|
-
const { stop } = opts;
|
|
1482
|
-
if (_FirstPartyMachine.hasInstance()) {
|
|
1483
|
-
if (stop) {
|
|
1484
|
-
_FirstPartyMachine.stopInstance();
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
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
|
|
1468
|
+
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1469
|
+
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1470
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1471
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1472
|
+
...claimsMetadata.keys(),
|
|
1473
|
+
...credentialDisplayLocales.keys()
|
|
1474
|
+
]));
|
|
1475
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1476
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1477
|
+
const claims = claimsMetadata.get(locale);
|
|
1478
|
+
return {
|
|
1479
|
+
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1480
|
+
credentialDisplay: display
|
|
1481
|
+
}),
|
|
1482
|
+
...locale.length > 0 && {
|
|
1483
|
+
locale
|
|
1508
1484
|
},
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1485
|
+
claims
|
|
1486
|
+
};
|
|
1487
|
+
}));
|
|
1488
|
+
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1489
|
+
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1490
|
+
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1491
|
+
return {
|
|
1492
|
+
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1493
|
+
alias: dynamicRegistrationClientMetadata.client_name
|
|
1494
|
+
},
|
|
1495
|
+
...issuerDisplay.name && {
|
|
1496
|
+
alias: issuerDisplay.name
|
|
1497
|
+
},
|
|
1498
|
+
...issuerDisplay.locale && {
|
|
1499
|
+
locale: issuerDisplay.locale
|
|
1500
|
+
},
|
|
1501
|
+
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1502
|
+
logo: {
|
|
1503
|
+
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1504
|
+
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1505
|
+
},
|
|
1506
|
+
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1507
|
+
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1508
|
+
},
|
|
1509
|
+
...issuerDisplay.logo?.alt_text && {
|
|
1510
|
+
alt: issuerDisplay.logo?.alt_text
|
|
1520
1511
|
}
|
|
1521
|
-
});
|
|
1522
|
-
}
|
|
1523
|
-
return newInst;
|
|
1524
|
-
}
|
|
1525
|
-
static getInstance(opts) {
|
|
1526
|
-
if (!_FirstPartyMachine._instance) {
|
|
1527
|
-
if (opts?.requireExisting === true) {
|
|
1528
|
-
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1529
1512
|
}
|
|
1530
|
-
|
|
1513
|
+
},
|
|
1514
|
+
...issuerDisplay.description && {
|
|
1515
|
+
description: issuerDisplay.description
|
|
1516
|
+
},
|
|
1517
|
+
...issuerDisplay.text_color && {
|
|
1518
|
+
text: {
|
|
1519
|
+
color: issuerDisplay.text_color
|
|
1520
|
+
}
|
|
1521
|
+
},
|
|
1522
|
+
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1523
|
+
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1524
|
+
},
|
|
1525
|
+
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1526
|
+
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1527
|
+
},
|
|
1528
|
+
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1529
|
+
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1530
|
+
},
|
|
1531
|
+
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1532
|
+
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1531
1533
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
};
|
|
1534
|
+
};
|
|
1535
|
+
}, "issuerLocaleBrandingFrom");
|
|
1535
1536
|
|
|
1536
1537
|
// src/services/OID4VCIHolderService.ts
|
|
1537
|
-
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
1538
1538
|
var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
|
|
1539
1539
|
const { credentialsSupported, context } = args;
|
|
1540
1540
|
const credentialBranding = {};
|
|
@@ -1606,16 +1606,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
|
|
|
1606
1606
|
}, "selectCredentialLocaleBranding");
|
|
1607
1607
|
var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1608
1608
|
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
|
-
}
|
|
1609
|
+
const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
|
|
1619
1610
|
const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credential, {
|
|
1620
1611
|
hasher: hasher ?? defaultHasher
|
|
1621
1612
|
});
|
|
@@ -1667,16 +1658,7 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1667
1658
|
}, "verifyCredentialToAccept");
|
|
1668
1659
|
var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1669
1660
|
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
|
-
}
|
|
1661
|
+
const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
|
|
1680
1662
|
const wrappedVerifiableCredential = CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
|
|
1681
1663
|
hasher
|
|
1682
1664
|
});
|
|
@@ -1696,6 +1678,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1696
1678
|
uniformVerifiableCredential = wrappedVerifiableCredential.credential;
|
|
1697
1679
|
}
|
|
1698
1680
|
const correlationId = typeof uniformVerifiableCredential.issuer === "string" ? uniformVerifiableCredential.issuer : CredentialMapper.isSdJwtDecodedCredential(uniformVerifiableCredential) ? uniformVerifiableCredential.decodedPayload.iss : uniformVerifiableCredential.issuer.id;
|
|
1681
|
+
const credentialResponse = credentialToAccept.credentialResponse;
|
|
1699
1682
|
return {
|
|
1700
1683
|
correlationId,
|
|
1701
1684
|
credentialToAccept,
|
|
@@ -1707,6 +1690,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1707
1690
|
}
|
|
1708
1691
|
};
|
|
1709
1692
|
}, "mapCredentialToAccept");
|
|
1693
|
+
var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse) => {
|
|
1694
|
+
let credential;
|
|
1695
|
+
if ("credential" in credentialResponse) {
|
|
1696
|
+
credential = credentialResponse.credential;
|
|
1697
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1698
|
+
credential = credentialResponse.credentials[0].credential;
|
|
1699
|
+
}
|
|
1700
|
+
if (!credential) {
|
|
1701
|
+
throw new Error("No credential found in credential response");
|
|
1702
|
+
}
|
|
1703
|
+
return credential;
|
|
1704
|
+
}, "extractCredentialFromResponse");
|
|
1710
1705
|
var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
1711
1706
|
const { issuanceOpt, context } = args;
|
|
1712
1707
|
const { identifier: identifierArg } = issuanceOpt;
|
|
@@ -1815,24 +1810,22 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
|
|
|
1815
1810
|
}
|
|
1816
1811
|
__name(createIdFromTypes, "createIdFromTypes");
|
|
1817
1812
|
if (configurationId) {
|
|
1818
|
-
|
|
1813
|
+
if (!format) {
|
|
1814
|
+
return Promise.reject(Error("format parameter missing from input"));
|
|
1815
|
+
}
|
|
1816
|
+
const allSupported2 = client.getCredentialsSupported(format);
|
|
1819
1817
|
return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
|
|
1820
1818
|
}
|
|
1821
|
-
if (!
|
|
1822
|
-
return Promise.reject(Error("openID4VCIClient has no credentialOffer
|
|
1819
|
+
if (!client.credentialOffer) {
|
|
1820
|
+
return Promise.reject(Error("openID4VCIClient has no credentialOffer"));
|
|
1823
1821
|
}
|
|
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
|
-
}
|
|
1822
|
+
if (!types) {
|
|
1823
|
+
return Promise.reject(Error("openID4VCIClient has no types"));
|
|
1831
1824
|
}
|
|
1832
1825
|
const offerSupported = getSupportedCredentials({
|
|
1833
|
-
types:
|
|
1826
|
+
types: [
|
|
1834
1827
|
types
|
|
1835
|
-
]
|
|
1828
|
+
],
|
|
1836
1829
|
format,
|
|
1837
1830
|
version: client.version(),
|
|
1838
1831
|
issuerMetadata: client.endpointMetadata.credentialIssuerMetadata
|
|
@@ -2007,7 +2000,7 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
|
|
|
2007
2000
|
case "jwt":
|
|
2008
2001
|
case "jwt_vc_json":
|
|
2009
2002
|
case "jwt_vc":
|
|
2010
|
-
case
|
|
2003
|
+
//case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
2011
2004
|
case "dc+sd-jwt":
|
|
2012
2005
|
case "mso_mdoc": {
|
|
2013
2006
|
const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
|
|
@@ -2334,7 +2327,13 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2334
2327
|
}
|
|
2335
2328
|
}
|
|
2336
2329
|
if (offer) {
|
|
2337
|
-
|
|
2330
|
+
const credentialsSupported2 = offer.original_credential_offer.credential_configuration_ids.flatMap((configId) => {
|
|
2331
|
+
const config = oid4vciClient.endpointMetadata.credentialIssuerMetadata?.credential_configurations_supported[configId];
|
|
2332
|
+
return config ? [
|
|
2333
|
+
config
|
|
2334
|
+
] : [];
|
|
2335
|
+
});
|
|
2336
|
+
types = credentialsSupported2.map((credentialSupported) => getTypesFromCredentialSupported2(credentialSupported));
|
|
2338
2337
|
} else {
|
|
2339
2338
|
types = asArray2(authorizationRequestOpts.authorizationDetails).map((authReqOpts) => getTypesFromAuthorizationDetails(authReqOpts) ?? []).filter((inner) => inner.length > 0);
|
|
2340
2339
|
}
|
|
@@ -2732,16 +2731,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2732
2731
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2733
2732
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2734
2733
|
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
|
-
}
|
|
2734
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
|
|
2745
2735
|
const wrappedIssuerVC = CredentialMapper2.toWrappedVerifiableCredential(issuerVC, {
|
|
2746
2736
|
hasher: this.hasher ?? defaultHasher2
|
|
2747
2737
|
});
|
|
@@ -3112,6 +3102,7 @@ export {
|
|
|
3112
3102
|
RequestType,
|
|
3113
3103
|
SupportedLanguage,
|
|
3114
3104
|
createConfig,
|
|
3105
|
+
extractCredentialFromResponse,
|
|
3115
3106
|
getBasicIssuerLocaleBranding,
|
|
3116
3107
|
getCredentialBranding,
|
|
3117
3108
|
getCredentialConfigsBasedOnFormatPref,
|