@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feat.SSISDK.35.64 → 0.34.1-feat.SSISDK.55.244

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 CHANGED
@@ -100,6 +100,7 @@ __export(index_exports, {
100
100
  RequestType: () => RequestType,
101
101
  SupportedLanguage: () => SupportedLanguage,
102
102
  createConfig: () => createConfig,
103
+ extractCredentialFromResponse: () => extractCredentialFromResponse,
103
104
  getBasicIssuerLocaleBranding: () => getBasicIssuerLocaleBranding,
104
105
  getCredentialBranding: () => getCredentialBranding,
105
106
  getCredentialConfigsBasedOnFormatPref: () => getCredentialConfigsBasedOnFormatPref,
@@ -140,9 +141,11 @@ var import_ssi_sdk_ext5 = require("@sphereon/ssi-sdk-ext.did-utils");
140
141
  var import_ssi_sdk_ext6 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
141
142
  var import_ssi_sdk_ext7 = require("@sphereon/ssi-sdk-ext.key-utils");
142
143
  var import_ssi_sdk2 = require("@sphereon/ssi-sdk.core");
143
- var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store");
144
+ var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store-types");
145
+ var import_ssi_sdk4 = require("@sphereon/ssi-sdk.data-store-types");
144
146
  var import_ssi_types2 = require("@sphereon/ssi-types");
145
147
  var import_utils2 = require("@veramo/utils");
148
+ var import_cross_fetch = __toESM(require("cross-fetch"), 1);
146
149
  var import_did_jwt = require("did-jwt");
147
150
  var import_uuid2 = require("uuid");
148
151
 
@@ -1062,9 +1065,295 @@ var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-resolver-jwk");
1062
1065
  var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.did-utils");
1063
1066
  var import_ssi_sdk_ext3 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
1064
1067
  var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.key-utils");
1068
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
1065
1069
  var import_ssi_types = require("@sphereon/ssi-types");
1066
1070
  var import_utils = require("@veramo/utils");
1067
1071
 
1072
+ // src/machines/firstPartyMachine.ts
1073
+ var import_xstate2 = require("xstate");
1074
+ var import_oid4vci_common2 = require("@sphereon/oid4vci-common");
1075
+
1076
+ // src/services/FirstPartyMachineServices.ts
1077
+ var import_oid4vci_client = require("@sphereon/oid4vci-client");
1078
+ var import_uuid = require("uuid");
1079
+ var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
1080
+ const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
1081
+ const oid4vciClient = await import_oid4vci_client.OpenID4VCIClient.fromState({
1082
+ state: openID4VCIClientState
1083
+ });
1084
+ return oid4vciClient.acquireAuthorizationChallengeCode({
1085
+ clientId: oid4vciClient.clientId ?? (0, import_uuid.v4)(),
1086
+ ...authSession && {
1087
+ authSession
1088
+ },
1089
+ ...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
1090
+ issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
1091
+ },
1092
+ ...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
1093
+ issuerState: openID4VCIClientState.credentialOffer?.issuerState
1094
+ },
1095
+ ...presentationDuringIssuanceSession && {
1096
+ presentationDuringIssuanceSession
1097
+ }
1098
+ });
1099
+ }, "sendAuthorizationChallengeRequest");
1100
+ var createConfig = /* @__PURE__ */ __name(async (args, context) => {
1101
+ const { presentationUri } = args;
1102
+ if (!presentationUri) {
1103
+ return Promise.reject(Error("Missing presentation uri in context"));
1104
+ }
1105
+ return context.agent.siopCreateConfig({
1106
+ url: presentationUri
1107
+ });
1108
+ }, "createConfig");
1109
+ var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
1110
+ const { didAuthConfig, presentationUri } = args;
1111
+ if (presentationUri === void 0) {
1112
+ return Promise.reject(Error("Missing presentation uri in context"));
1113
+ }
1114
+ if (didAuthConfig === void 0) {
1115
+ return Promise.reject(Error("Missing did auth config in context"));
1116
+ }
1117
+ return context.agent.siopGetSiopRequest({
1118
+ didAuthConfig,
1119
+ url: presentationUri
1120
+ });
1121
+ }, "getSiopRequest");
1122
+ var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
1123
+ const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
1124
+ const responseData = await context.agent.siopSendResponse({
1125
+ authorizationRequestData,
1126
+ selectedCredentials,
1127
+ didAuthConfig,
1128
+ isFirstParty: true
1129
+ });
1130
+ return responseData.body.presentation_during_issuance_session;
1131
+ }, "sendAuthorizationResponse");
1132
+
1133
+ // src/machines/firstPartyMachine.ts
1134
+ var firstPartyMachineStates = {
1135
+ [FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
1136
+ id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
1137
+ invoke: {
1138
+ src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
1139
+ onDone: {
1140
+ target: FirstPartyMachineStateTypes.done,
1141
+ actions: (0, import_xstate2.assign)({
1142
+ authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
1143
+ })
1144
+ },
1145
+ onError: [
1146
+ {
1147
+ target: FirstPartyMachineStateTypes.createConfig,
1148
+ cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === import_oid4vci_common2.AuthorizationChallengeError.insufficient_authorization, "cond"),
1149
+ actions: (0, import_xstate2.assign)({
1150
+ authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
1151
+ presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
1152
+ })
1153
+ },
1154
+ {
1155
+ target: FirstPartyMachineStateTypes.error,
1156
+ actions: (0, import_xstate2.assign)({
1157
+ error: /* @__PURE__ */ __name((_ctx, _event) => ({
1158
+ title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
1159
+ message: _event.data.message,
1160
+ stack: _event.data.stack
1161
+ }), "error")
1162
+ })
1163
+ }
1164
+ ]
1165
+ }
1166
+ },
1167
+ [FirstPartyMachineStateTypes.createConfig]: {
1168
+ id: FirstPartyMachineStateTypes.createConfig,
1169
+ invoke: {
1170
+ src: FirstPartyMachineServices.createConfig,
1171
+ onDone: {
1172
+ target: FirstPartyMachineStateTypes.getSiopRequest,
1173
+ actions: (0, import_xstate2.assign)({
1174
+ didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
1175
+ })
1176
+ },
1177
+ onError: {
1178
+ target: FirstPartyMachineStateTypes.error,
1179
+ actions: (0, import_xstate2.assign)({
1180
+ error: /* @__PURE__ */ __name((_ctx, _event) => ({
1181
+ title: translate("oid4vci_machine_create_config_error_title"),
1182
+ message: _event.data.message,
1183
+ stack: _event.data.stack
1184
+ }), "error")
1185
+ })
1186
+ }
1187
+ }
1188
+ },
1189
+ [FirstPartyMachineStateTypes.getSiopRequest]: {
1190
+ id: FirstPartyMachineStateTypes.getSiopRequest,
1191
+ invoke: {
1192
+ src: FirstPartyMachineServices.getSiopRequest,
1193
+ onDone: {
1194
+ target: FirstPartyMachineStateTypes.selectCredentials,
1195
+ actions: (0, import_xstate2.assign)({
1196
+ authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
1197
+ })
1198
+ },
1199
+ onError: {
1200
+ target: FirstPartyMachineStateTypes.error,
1201
+ actions: (0, import_xstate2.assign)({
1202
+ error: /* @__PURE__ */ __name((_ctx, _event) => ({
1203
+ title: translate("siopV2_machine_get_request_error_title"),
1204
+ message: _event.data.message,
1205
+ stack: _event.data.stack
1206
+ }), "error")
1207
+ })
1208
+ }
1209
+ }
1210
+ },
1211
+ [FirstPartyMachineStateTypes.selectCredentials]: {
1212
+ id: FirstPartyMachineStateTypes.selectCredentials,
1213
+ on: {
1214
+ [FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS]: {
1215
+ actions: (0, import_xstate2.assign)({
1216
+ selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
1217
+ })
1218
+ },
1219
+ [FirstPartyMachineEvents.NEXT]: {
1220
+ target: FirstPartyMachineStateTypes.sendAuthorizationResponse
1221
+ },
1222
+ [FirstPartyMachineEvents.DECLINE]: {
1223
+ target: FirstPartyMachineStateTypes.declined
1224
+ },
1225
+ [FirstPartyMachineEvents.PREVIOUS]: {
1226
+ target: FirstPartyMachineStateTypes.aborted
1227
+ }
1228
+ }
1229
+ },
1230
+ [FirstPartyMachineStateTypes.sendAuthorizationResponse]: {
1231
+ id: FirstPartyMachineStateTypes.sendAuthorizationResponse,
1232
+ invoke: {
1233
+ src: FirstPartyMachineServices.sendAuthorizationResponse,
1234
+ onDone: {
1235
+ target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
1236
+ actions: (0, import_xstate2.assign)({
1237
+ presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
1238
+ })
1239
+ },
1240
+ onError: {
1241
+ target: FirstPartyMachineStateTypes.error,
1242
+ actions: (0, import_xstate2.assign)({
1243
+ error: /* @__PURE__ */ __name((_ctx, _event) => ({
1244
+ title: translate("oid4vci_machine_get_request_error_title"),
1245
+ message: _event.data.message,
1246
+ stack: _event.data.stack
1247
+ }), "error")
1248
+ })
1249
+ }
1250
+ }
1251
+ },
1252
+ [FirstPartyMachineStateTypes.aborted]: {
1253
+ id: FirstPartyMachineStateTypes.aborted,
1254
+ type: "final"
1255
+ },
1256
+ [FirstPartyMachineStateTypes.declined]: {
1257
+ id: FirstPartyMachineStateTypes.declined,
1258
+ type: "final"
1259
+ },
1260
+ [FirstPartyMachineStateTypes.error]: {
1261
+ id: FirstPartyMachineStateTypes.error,
1262
+ type: "final"
1263
+ },
1264
+ [FirstPartyMachineStateTypes.done]: {
1265
+ id: FirstPartyMachineStateTypes.done,
1266
+ type: "final"
1267
+ }
1268
+ };
1269
+ var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
1270
+ const initialContext = {
1271
+ openID4VCIClientState: opts.openID4VCIClientState,
1272
+ contact: opts.contact,
1273
+ selectedCredentials: []
1274
+ };
1275
+ return (0, import_xstate2.createMachine)({
1276
+ id: opts?.machineId ?? "FirstParty",
1277
+ predictableActionArguments: true,
1278
+ initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
1279
+ context: initialContext,
1280
+ states: firstPartyMachineStates,
1281
+ schema: {
1282
+ events: {},
1283
+ services: {}
1284
+ }
1285
+ });
1286
+ }, "createFirstPartyActivationMachine");
1287
+ var FirstPartyMachine = class _FirstPartyMachine {
1288
+ static {
1289
+ __name(this, "FirstPartyMachine");
1290
+ }
1291
+ static _instance;
1292
+ static hasInstance() {
1293
+ return _FirstPartyMachine._instance !== void 0;
1294
+ }
1295
+ static get instance() {
1296
+ if (!_FirstPartyMachine._instance) {
1297
+ throw Error("Please initialize ESIMActivation machine first");
1298
+ }
1299
+ return _FirstPartyMachine._instance;
1300
+ }
1301
+ static clearInstance(opts) {
1302
+ const { stop } = opts;
1303
+ if (_FirstPartyMachine.hasInstance()) {
1304
+ if (stop) {
1305
+ _FirstPartyMachine.stopInstance();
1306
+ }
1307
+ }
1308
+ _FirstPartyMachine._instance = void 0;
1309
+ }
1310
+ static stopInstance() {
1311
+ if (!_FirstPartyMachine.hasInstance()) {
1312
+ return;
1313
+ }
1314
+ _FirstPartyMachine.instance.stop();
1315
+ _FirstPartyMachine._instance = void 0;
1316
+ }
1317
+ static newInstance(opts) {
1318
+ const { agentContext } = opts;
1319
+ const services = {
1320
+ [FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
1321
+ [FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
1322
+ [FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
1323
+ [FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
1324
+ };
1325
+ const newInst = (0, import_xstate2.interpret)(createFirstPartyActivationMachine(opts).withConfig({
1326
+ services: {
1327
+ ...services,
1328
+ ...opts?.services
1329
+ },
1330
+ guards: {
1331
+ ...opts?.guards
1332
+ }
1333
+ }));
1334
+ if (typeof opts?.subscription === "function") {
1335
+ newInst.onTransition(opts.subscription);
1336
+ }
1337
+ if (opts?.requireCustomNavigationHook !== true) {
1338
+ newInst.onTransition((snapshot) => {
1339
+ if (opts?.stateNavigationListener) {
1340
+ void opts.stateNavigationListener(newInst, snapshot);
1341
+ }
1342
+ });
1343
+ }
1344
+ return newInst;
1345
+ }
1346
+ static getInstance(opts) {
1347
+ if (!_FirstPartyMachine._instance) {
1348
+ if (opts?.requireExisting === true) {
1349
+ throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
1350
+ }
1351
+ _FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
1352
+ }
1353
+ return _FirstPartyMachine._instance;
1354
+ }
1355
+ };
1356
+
1068
1357
  // src/mappers/OIDC4VCIBrandingMapper.ts
1069
1358
  var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1070
1359
  const { credentialDisplay, issuerCredentialSubject } = args;
@@ -1230,390 +1519,104 @@ var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1230
1519
  return {
1231
1520
  ...credentialDisplay.name && {
1232
1521
  alias: credentialDisplay.name
1233
- },
1234
- ...credentialDisplay.lang && {
1235
- locale: credentialDisplay.lang
1236
- },
1237
- ...credentialDisplay.rendering?.simple?.logo && {
1238
- logo: {
1239
- ...credentialDisplay.rendering.simple.logo.uri && {
1240
- uri: credentialDisplay.rendering.simple.logo.uri
1241
- },
1242
- ...credentialDisplay.rendering.simple.logo.alt_text && {
1243
- alt: credentialDisplay.rendering.simple.logo.alt_text
1244
- }
1245
- }
1246
- },
1247
- ...credentialDisplay.description && {
1248
- description: credentialDisplay.description
1249
- },
1250
- ...credentialDisplay.rendering?.simple?.text_color && {
1251
- text: {
1252
- color: credentialDisplay.rendering.simple.text_color
1253
- }
1254
- },
1255
- ...credentialDisplay.rendering?.simple?.background_color && {
1256
- background: {
1257
- color: credentialDisplay.rendering.simple.background_color
1258
- }
1259
- }
1260
- };
1261
- }, "sdJwtCredentialLocaleBrandingFrom");
1262
- var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1263
- const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
1264
- const locales = Array.from(/* @__PURE__ */ new Set([
1265
- ...claimsMetadata.keys(),
1266
- ...credentialDisplayLocales.keys()
1267
- ]));
1268
- return Promise.all(locales.map(async (locale) => {
1269
- const display = credentialDisplayLocales.get(locale);
1270
- const claims = claimsMetadata.get(locale);
1271
- return {
1272
- ...display && await sdJwtCredentialLocaleBrandingFrom({
1273
- credentialDisplay: display
1274
- }),
1275
- ...locale.length > 0 && {
1276
- locale
1277
- },
1278
- claims
1279
- };
1280
- }));
1281
- }, "sdJwtCombineDisplayLocalesFrom");
1282
- var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1283
- const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
1284
- return {
1285
- ...dynamicRegistrationClientMetadata?.client_name && {
1286
- alias: dynamicRegistrationClientMetadata.client_name
1287
- },
1288
- ...issuerDisplay.name && {
1289
- alias: issuerDisplay.name
1290
- },
1291
- ...issuerDisplay.locale && {
1292
- locale: issuerDisplay.locale
1293
- },
1294
- ...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
1295
- logo: {
1296
- ...dynamicRegistrationClientMetadata?.logo_uri && {
1297
- uri: dynamicRegistrationClientMetadata?.logo_uri
1298
- },
1299
- ...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
1300
- uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
1301
- },
1302
- ...issuerDisplay.logo?.alt_text && {
1303
- alt: issuerDisplay.logo?.alt_text
1304
- }
1305
- }
1306
- },
1307
- ...issuerDisplay.description && {
1308
- description: issuerDisplay.description
1309
- },
1310
- ...issuerDisplay.text_color && {
1311
- text: {
1312
- color: issuerDisplay.text_color
1313
- }
1314
- },
1315
- ...dynamicRegistrationClientMetadata?.client_uri && {
1316
- clientUri: dynamicRegistrationClientMetadata.client_uri
1317
- },
1318
- ...dynamicRegistrationClientMetadata?.tos_uri && {
1319
- tosUri: dynamicRegistrationClientMetadata.tos_uri
1320
- },
1321
- ...dynamicRegistrationClientMetadata?.policy_uri && {
1322
- policyUri: dynamicRegistrationClientMetadata.policy_uri
1323
- },
1324
- ...dynamicRegistrationClientMetadata?.contacts && {
1325
- contacts: dynamicRegistrationClientMetadata.contacts
1326
- }
1327
- };
1328
- }, "issuerLocaleBrandingFrom");
1329
-
1330
- // src/machines/firstPartyMachine.ts
1331
- var import_xstate2 = require("xstate");
1332
- var import_oid4vci_common2 = require("@sphereon/oid4vci-common");
1333
-
1334
- // src/services/FirstPartyMachineServices.ts
1335
- var import_oid4vci_client = require("@sphereon/oid4vci-client");
1336
- var import_uuid = require("uuid");
1337
- var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
1338
- const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
1339
- const oid4vciClient = await import_oid4vci_client.OpenID4VCIClient.fromState({
1340
- state: openID4VCIClientState
1341
- });
1342
- return oid4vciClient.acquireAuthorizationChallengeCode({
1343
- clientId: oid4vciClient.clientId ?? (0, import_uuid.v4)(),
1344
- ...authSession && {
1345
- authSession
1346
- },
1347
- ...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
1348
- issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
1349
- },
1350
- ...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
1351
- issuerState: openID4VCIClientState.credentialOffer?.issuerState
1352
- },
1353
- ...presentationDuringIssuanceSession && {
1354
- presentationDuringIssuanceSession
1355
- }
1356
- });
1357
- }, "sendAuthorizationChallengeRequest");
1358
- var createConfig = /* @__PURE__ */ __name(async (args, context) => {
1359
- const { presentationUri } = args;
1360
- if (!presentationUri) {
1361
- return Promise.reject(Error("Missing presentation uri in context"));
1362
- }
1363
- return context.agent.siopCreateConfig({
1364
- url: presentationUri
1365
- });
1366
- }, "createConfig");
1367
- var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
1368
- const { didAuthConfig, presentationUri } = args;
1369
- if (presentationUri === void 0) {
1370
- return Promise.reject(Error("Missing presentation uri in context"));
1371
- }
1372
- if (didAuthConfig === void 0) {
1373
- return Promise.reject(Error("Missing did auth config in context"));
1374
- }
1375
- return context.agent.siopGetSiopRequest({
1376
- didAuthConfig,
1377
- url: presentationUri
1378
- });
1379
- }, "getSiopRequest");
1380
- var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
1381
- const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
1382
- const responseData = await context.agent.siopSendResponse({
1383
- authorizationRequestData,
1384
- selectedCredentials,
1385
- didAuthConfig,
1386
- isFirstParty: true
1387
- });
1388
- return responseData.body.presentation_during_issuance_session;
1389
- }, "sendAuthorizationResponse");
1390
-
1391
- // src/machines/firstPartyMachine.ts
1392
- var firstPartyMachineStates = {
1393
- [FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
1394
- id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
1395
- invoke: {
1396
- src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
1397
- onDone: {
1398
- target: FirstPartyMachineStateTypes.done,
1399
- actions: (0, import_xstate2.assign)({
1400
- authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
1401
- })
1402
- },
1403
- onError: [
1404
- {
1405
- target: FirstPartyMachineStateTypes.createConfig,
1406
- cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === import_oid4vci_common2.AuthorizationChallengeError.insufficient_authorization, "cond"),
1407
- actions: (0, import_xstate2.assign)({
1408
- authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
1409
- presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
1410
- })
1411
- },
1412
- {
1413
- target: FirstPartyMachineStateTypes.error,
1414
- actions: (0, import_xstate2.assign)({
1415
- error: /* @__PURE__ */ __name((_ctx, _event) => ({
1416
- title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
1417
- message: _event.data.message,
1418
- stack: _event.data.stack
1419
- }), "error")
1420
- })
1421
- }
1422
- ]
1423
- }
1424
- },
1425
- [FirstPartyMachineStateTypes.createConfig]: {
1426
- id: FirstPartyMachineStateTypes.createConfig,
1427
- invoke: {
1428
- src: FirstPartyMachineServices.createConfig,
1429
- onDone: {
1430
- target: FirstPartyMachineStateTypes.getSiopRequest,
1431
- actions: (0, import_xstate2.assign)({
1432
- didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
1433
- })
1434
- },
1435
- onError: {
1436
- target: FirstPartyMachineStateTypes.error,
1437
- actions: (0, import_xstate2.assign)({
1438
- error: /* @__PURE__ */ __name((_ctx, _event) => ({
1439
- title: translate("oid4vci_machine_create_config_error_title"),
1440
- message: _event.data.message,
1441
- stack: _event.data.stack
1442
- }), "error")
1443
- })
1444
- }
1445
- }
1446
- },
1447
- [FirstPartyMachineStateTypes.getSiopRequest]: {
1448
- id: FirstPartyMachineStateTypes.getSiopRequest,
1449
- invoke: {
1450
- src: FirstPartyMachineServices.getSiopRequest,
1451
- onDone: {
1452
- target: FirstPartyMachineStateTypes.selectCredentials,
1453
- actions: (0, import_xstate2.assign)({
1454
- authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
1455
- })
1456
- },
1457
- onError: {
1458
- target: FirstPartyMachineStateTypes.error,
1459
- actions: (0, import_xstate2.assign)({
1460
- error: /* @__PURE__ */ __name((_ctx, _event) => ({
1461
- title: translate("siopV2_machine_get_request_error_title"),
1462
- message: _event.data.message,
1463
- stack: _event.data.stack
1464
- }), "error")
1465
- })
1522
+ },
1523
+ ...credentialDisplay.lang && {
1524
+ locale: credentialDisplay.lang
1525
+ },
1526
+ ...credentialDisplay.rendering?.simple?.logo && {
1527
+ logo: {
1528
+ ...credentialDisplay.rendering.simple.logo.uri && {
1529
+ uri: credentialDisplay.rendering.simple.logo.uri
1530
+ },
1531
+ ...credentialDisplay.rendering.simple.logo.alt_text && {
1532
+ alt: credentialDisplay.rendering.simple.logo.alt_text
1533
+ }
1466
1534
  }
1467
- }
1468
- },
1469
- [FirstPartyMachineStateTypes.selectCredentials]: {
1470
- id: FirstPartyMachineStateTypes.selectCredentials,
1471
- on: {
1472
- [FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS]: {
1473
- actions: (0, import_xstate2.assign)({
1474
- selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
1475
- })
1476
- },
1477
- [FirstPartyMachineEvents.NEXT]: {
1478
- target: FirstPartyMachineStateTypes.sendAuthorizationResponse
1479
- },
1480
- [FirstPartyMachineEvents.DECLINE]: {
1481
- target: FirstPartyMachineStateTypes.declined
1482
- },
1483
- [FirstPartyMachineEvents.PREVIOUS]: {
1484
- target: FirstPartyMachineStateTypes.aborted
1535
+ },
1536
+ ...credentialDisplay.description && {
1537
+ description: credentialDisplay.description
1538
+ },
1539
+ ...credentialDisplay.rendering?.simple?.text_color && {
1540
+ text: {
1541
+ color: credentialDisplay.rendering.simple.text_color
1485
1542
  }
1486
- }
1487
- },
1488
- [FirstPartyMachineStateTypes.sendAuthorizationResponse]: {
1489
- id: FirstPartyMachineStateTypes.sendAuthorizationResponse,
1490
- invoke: {
1491
- src: FirstPartyMachineServices.sendAuthorizationResponse,
1492
- onDone: {
1493
- target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
1494
- actions: (0, import_xstate2.assign)({
1495
- presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
1496
- })
1497
- },
1498
- onError: {
1499
- target: FirstPartyMachineStateTypes.error,
1500
- actions: (0, import_xstate2.assign)({
1501
- error: /* @__PURE__ */ __name((_ctx, _event) => ({
1502
- title: translate("oid4vci_machine_get_request_error_title"),
1503
- message: _event.data.message,
1504
- stack: _event.data.stack
1505
- }), "error")
1506
- })
1543
+ },
1544
+ ...credentialDisplay.rendering?.simple?.background_color && {
1545
+ background: {
1546
+ color: credentialDisplay.rendering.simple.background_color
1507
1547
  }
1508
1548
  }
1509
- },
1510
- [FirstPartyMachineStateTypes.aborted]: {
1511
- id: FirstPartyMachineStateTypes.aborted,
1512
- type: "final"
1513
- },
1514
- [FirstPartyMachineStateTypes.declined]: {
1515
- id: FirstPartyMachineStateTypes.declined,
1516
- type: "final"
1517
- },
1518
- [FirstPartyMachineStateTypes.error]: {
1519
- id: FirstPartyMachineStateTypes.error,
1520
- type: "final"
1521
- },
1522
- [FirstPartyMachineStateTypes.done]: {
1523
- id: FirstPartyMachineStateTypes.done,
1524
- type: "final"
1525
- }
1526
- };
1527
- var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
1528
- const initialContext = {
1529
- openID4VCIClientState: opts.openID4VCIClientState,
1530
- contact: opts.contact,
1531
- selectedCredentials: []
1532
1549
  };
1533
- return (0, import_xstate2.createMachine)({
1534
- id: opts?.machineId ?? "FirstParty",
1535
- predictableActionArguments: true,
1536
- initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
1537
- context: initialContext,
1538
- states: firstPartyMachineStates,
1539
- schema: {
1540
- events: {},
1541
- services: {}
1542
- }
1543
- });
1544
- }, "createFirstPartyActivationMachine");
1545
- var FirstPartyMachine = class _FirstPartyMachine {
1546
- static {
1547
- __name(this, "FirstPartyMachine");
1548
- }
1549
- static _instance;
1550
- static hasInstance() {
1551
- return _FirstPartyMachine._instance !== void 0;
1552
- }
1553
- static get instance() {
1554
- if (!_FirstPartyMachine._instance) {
1555
- throw Error("Please initialize ESIMActivation machine first");
1556
- }
1557
- return _FirstPartyMachine._instance;
1558
- }
1559
- static clearInstance(opts) {
1560
- const { stop } = opts;
1561
- if (_FirstPartyMachine.hasInstance()) {
1562
- if (stop) {
1563
- _FirstPartyMachine.stopInstance();
1564
- }
1565
- }
1566
- _FirstPartyMachine._instance = void 0;
1567
- }
1568
- static stopInstance() {
1569
- if (!_FirstPartyMachine.hasInstance()) {
1570
- return;
1571
- }
1572
- _FirstPartyMachine.instance.stop();
1573
- _FirstPartyMachine._instance = void 0;
1574
- }
1575
- static newInstance(opts) {
1576
- const { agentContext } = opts;
1577
- const services = {
1578
- [FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
1579
- [FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
1580
- [FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
1581
- [FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
1582
- };
1583
- const newInst = (0, import_xstate2.interpret)(createFirstPartyActivationMachine(opts).withConfig({
1584
- services: {
1585
- ...services,
1586
- ...opts?.services
1550
+ }, "sdJwtCredentialLocaleBrandingFrom");
1551
+ var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1552
+ const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
1553
+ const locales = Array.from(/* @__PURE__ */ new Set([
1554
+ ...claimsMetadata.keys(),
1555
+ ...credentialDisplayLocales.keys()
1556
+ ]));
1557
+ return Promise.all(locales.map(async (locale) => {
1558
+ const display = credentialDisplayLocales.get(locale);
1559
+ const claims = claimsMetadata.get(locale);
1560
+ return {
1561
+ ...display && await sdJwtCredentialLocaleBrandingFrom({
1562
+ credentialDisplay: display
1563
+ }),
1564
+ ...locale.length > 0 && {
1565
+ locale
1587
1566
  },
1588
- guards: {
1589
- ...opts?.guards
1590
- }
1591
- }));
1592
- if (typeof opts?.subscription === "function") {
1593
- newInst.onTransition(opts.subscription);
1594
- }
1595
- if (opts?.requireCustomNavigationHook !== true) {
1596
- newInst.onTransition((snapshot) => {
1597
- if (opts?.stateNavigationListener) {
1598
- void opts.stateNavigationListener(newInst, snapshot);
1567
+ claims
1568
+ };
1569
+ }));
1570
+ }, "sdJwtCombineDisplayLocalesFrom");
1571
+ var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1572
+ const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
1573
+ return {
1574
+ ...dynamicRegistrationClientMetadata?.client_name && {
1575
+ alias: dynamicRegistrationClientMetadata.client_name
1576
+ },
1577
+ ...issuerDisplay.name && {
1578
+ alias: issuerDisplay.name
1579
+ },
1580
+ ...issuerDisplay.locale && {
1581
+ locale: issuerDisplay.locale
1582
+ },
1583
+ ...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
1584
+ logo: {
1585
+ ...dynamicRegistrationClientMetadata?.logo_uri && {
1586
+ uri: dynamicRegistrationClientMetadata?.logo_uri
1587
+ },
1588
+ ...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
1589
+ uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
1590
+ },
1591
+ ...issuerDisplay.logo?.alt_text && {
1592
+ alt: issuerDisplay.logo?.alt_text
1599
1593
  }
1600
- });
1601
- }
1602
- return newInst;
1603
- }
1604
- static getInstance(opts) {
1605
- if (!_FirstPartyMachine._instance) {
1606
- if (opts?.requireExisting === true) {
1607
- throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
1608
1594
  }
1609
- _FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
1595
+ },
1596
+ ...issuerDisplay.description && {
1597
+ description: issuerDisplay.description
1598
+ },
1599
+ ...issuerDisplay.text_color && {
1600
+ text: {
1601
+ color: issuerDisplay.text_color
1602
+ }
1603
+ },
1604
+ ...dynamicRegistrationClientMetadata?.client_uri && {
1605
+ clientUri: dynamicRegistrationClientMetadata.client_uri
1606
+ },
1607
+ ...dynamicRegistrationClientMetadata?.tos_uri && {
1608
+ tosUri: dynamicRegistrationClientMetadata.tos_uri
1609
+ },
1610
+ ...dynamicRegistrationClientMetadata?.policy_uri && {
1611
+ policyUri: dynamicRegistrationClientMetadata.policy_uri
1612
+ },
1613
+ ...dynamicRegistrationClientMetadata?.contacts && {
1614
+ contacts: dynamicRegistrationClientMetadata.contacts
1610
1615
  }
1611
- return _FirstPartyMachine._instance;
1612
- }
1613
- };
1616
+ };
1617
+ }, "issuerLocaleBrandingFrom");
1614
1618
 
1615
1619
  // src/services/OID4VCIHolderService.ts
1616
- var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
1617
1620
  var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
1618
1621
  const { credentialsSupported, context } = args;
1619
1622
  const credentialBranding = {};
@@ -1685,16 +1688,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
1685
1688
  }, "selectCredentialLocaleBranding");
1686
1689
  var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1687
1690
  const { mappedCredential, hasher, onVerifyEBSICredentialIssuer, schemaValidation, context } = args;
1688
- const credentialResponse = mappedCredential.credentialToAccept.credentialResponse;
1689
- let credential;
1690
- if ("credential" in credentialResponse) {
1691
- credential = credentialResponse.credential;
1692
- } else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
1693
- credential = credentialResponse.credentials[0].credential;
1694
- }
1695
- if (!credential) {
1696
- return Promise.reject(Error("No credential found in credential response"));
1697
- }
1691
+ const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
1698
1692
  const wrappedVC = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(credential, {
1699
1693
  hasher: hasher ?? import_ssi_sdk.defaultHasher
1700
1694
  });
@@ -1746,16 +1740,7 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1746
1740
  }, "verifyCredentialToAccept");
1747
1741
  var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1748
1742
  const { credentialToAccept, hasher } = args;
1749
- const credentialResponse = credentialToAccept.credentialResponse;
1750
- let verifiableCredential;
1751
- if ("credential" in credentialResponse) {
1752
- verifiableCredential = credentialResponse.credential;
1753
- } else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
1754
- verifiableCredential = credentialResponse.credentials[0].credential;
1755
- }
1756
- if (!verifiableCredential) {
1757
- return Promise.reject(Error("No credential found in credential response"));
1758
- }
1743
+ const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
1759
1744
  const wrappedVerifiableCredential = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
1760
1745
  hasher
1761
1746
  });
@@ -1775,6 +1760,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1775
1760
  uniformVerifiableCredential = wrappedVerifiableCredential.credential;
1776
1761
  }
1777
1762
  const correlationId = typeof uniformVerifiableCredential.issuer === "string" ? uniformVerifiableCredential.issuer : import_ssi_types.CredentialMapper.isSdJwtDecodedCredential(uniformVerifiableCredential) ? uniformVerifiableCredential.decodedPayload.iss : uniformVerifiableCredential.issuer.id;
1763
+ const credentialResponse = credentialToAccept.credentialResponse;
1778
1764
  return {
1779
1765
  correlationId,
1780
1766
  credentialToAccept,
@@ -1786,6 +1772,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1786
1772
  }
1787
1773
  };
1788
1774
  }, "mapCredentialToAccept");
1775
+ var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse) => {
1776
+ let credential;
1777
+ if ("credential" in credentialResponse) {
1778
+ credential = credentialResponse.credential;
1779
+ } else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
1780
+ credential = credentialResponse.credentials[0].credential;
1781
+ }
1782
+ if (!credential) {
1783
+ throw new Error("No credential found in credential response");
1784
+ }
1785
+ return credential;
1786
+ }, "extractCredentialFromResponse");
1789
1787
  var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
1790
1788
  const { issuanceOpt, context } = args;
1791
1789
  const { identifier: identifierArg } = issuanceOpt;
@@ -1894,24 +1892,19 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
1894
1892
  }
1895
1893
  __name(createIdFromTypes, "createIdFromTypes");
1896
1894
  if (configurationId) {
1897
- const allSupported2 = client.getCredentialsSupported(false);
1895
+ const allSupported2 = client.getCredentialsSupported(format);
1898
1896
  return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
1899
1897
  }
1900
- if (!types && !client.credentialOffer) {
1901
- return Promise.reject(Error("openID4VCIClient has no credentialOffer and no types where provided"));
1898
+ if (!client.credentialOffer) {
1899
+ return Promise.reject(Error("openID4VCIClient has no credentialOffer"));
1902
1900
  }
1903
- if (!Array.isArray(format) && client.credentialOffer) {
1904
- if (client.version() > import_oid4vci_common3.OpenId4VCIVersion.VER_1_0_09 && typeof client.credentialOffer.credential_offer === "object" && "credentials" in client.credentialOffer.credential_offer) {
1905
- format = client.credentialOffer.credential_offer.credentials.filter((cred) => typeof cred !== "string").map((cred) => cred.format);
1906
- if (format?.length === 0) {
1907
- format = void 0;
1908
- }
1909
- }
1901
+ if (!types) {
1902
+ return Promise.reject(Error("openID4VCIClient has no types"));
1910
1903
  }
1911
1904
  const offerSupported = (0, import_oid4vci_common3.getSupportedCredentials)({
1912
- types: types ? [
1905
+ types: [
1913
1906
  types
1914
- ] : client.getCredentialOfferTypes(),
1907
+ ],
1915
1908
  format,
1916
1909
  version: client.version(),
1917
1910
  issuerMetadata: client.endpointMetadata.credentialIssuerMetadata
@@ -2086,7 +2079,7 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
2086
2079
  case "jwt":
2087
2080
  case "jwt_vc_json":
2088
2081
  case "jwt_vc":
2089
- case "vc+sd-jwt":
2082
+ //case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
2090
2083
  case "dc+sd-jwt":
2091
2084
  case "mso_mdoc": {
2092
2085
  const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
@@ -2155,7 +2148,6 @@ var startFirstPartApplicationMachine = /* @__PURE__ */ __name(async (args, conte
2155
2148
  }, "startFirstPartApplicationMachine");
2156
2149
 
2157
2150
  // src/agent/OID4VCIHolder.ts
2158
- var import_polyfill = require("cross-fetch/polyfill");
2159
2151
  var oid4vciHolderContextMethods = [
2160
2152
  "cmGetContacts",
2161
2153
  "cmGetContact",
@@ -2376,7 +2368,6 @@ var OID4VCIHolder = class _OID4VCIHolder {
2376
2368
  formats = Array.from(new Set(authFormats));
2377
2369
  }
2378
2370
  let oid4vciClient;
2379
- let types = void 0;
2380
2371
  let offer;
2381
2372
  if (requestData.existingClientState) {
2382
2373
  oid4vciClient = await import_oid4vci_client3.OpenID4VCIClient.fromState({
@@ -2412,17 +2403,18 @@ var OID4VCIHolder = class _OID4VCIHolder {
2412
2403
  });
2413
2404
  }
2414
2405
  }
2406
+ let configurationIds = [];
2415
2407
  if (offer) {
2416
- types = (0, import_oid4vci_common4.getTypesFromCredentialOffer)(offer.original_credential_offer);
2408
+ configurationIds = offer.original_credential_offer.credential_configuration_ids;
2417
2409
  } else {
2418
- types = (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails).map((authReqOpts) => (0, import_oid4vci_common4.getTypesFromAuthorizationDetails)(authReqOpts) ?? []).filter((inner) => inner.length > 0);
2410
+ configurationIds = (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails).filter((authDetails) => typeof authDetails !== "string").map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
2419
2411
  }
2420
- const serverMetadata = await oid4vciClient.retrieveServerMetadata();
2421
2412
  const credentialsSupported = await getCredentialConfigsSupportedMerged({
2422
2413
  client: oid4vciClient,
2423
2414
  vcFormatPreferences: formats,
2424
- types
2415
+ configurationIds
2425
2416
  });
2417
+ const serverMetadata = await oid4vciClient.retrieveServerMetadata();
2426
2418
  const credentialBranding = await getCredentialBranding({
2427
2419
  credentialsSupported,
2428
2420
  context
@@ -2639,26 +2631,26 @@ var OID4VCIHolder = class _OID4VCIHolder {
2639
2631
  return Promise.reject(Error("Missing credential offers in context"));
2640
2632
  }
2641
2633
  let correlationId = credentialsToAccept[0].correlationId;
2642
- let identifierType = import_ssi_sdk3.CorrelationIdentifierType.DID;
2634
+ let identifierType = import_ssi_sdk4.CorrelationIdentifierType.DID;
2643
2635
  if (!correlationId.toLowerCase().startsWith("did:")) {
2644
- identifierType = import_ssi_sdk3.CorrelationIdentifierType.URL;
2636
+ identifierType = import_ssi_sdk4.CorrelationIdentifierType.URL;
2645
2637
  if (correlationId.startsWith("http")) {
2646
2638
  correlationId = new URL(correlationId).hostname;
2647
2639
  }
2648
2640
  }
2649
2641
  const identity = {
2650
2642
  alias: credentialsToAccept[0].correlationId,
2651
- origin: import_ssi_sdk3.IdentityOrigin.EXTERNAL,
2643
+ origin: import_ssi_sdk4.IdentityOrigin.EXTERNAL,
2652
2644
  roles: [
2653
- import_ssi_sdk3.CredentialRole.ISSUER
2645
+ import_ssi_types2.CredentialRole.ISSUER
2654
2646
  ],
2655
2647
  identifier: {
2656
2648
  type: identifierType,
2657
2649
  correlationId
2658
2650
  },
2659
- ...identifierType === import_ssi_sdk3.CorrelationIdentifierType.URL && {
2651
+ ...identifierType === import_ssi_sdk4.CorrelationIdentifierType.URL && {
2660
2652
  connection: {
2661
- type: import_ssi_sdk3.ConnectionType.OPENID_CONNECT,
2653
+ type: import_ssi_sdk4.ConnectionType.OPENID_CONNECT,
2662
2654
  config: {
2663
2655
  clientId: "138d7bf8-c930-4c6e-b928-97d3a4928b01",
2664
2656
  clientSecret: "03b3955f-d020-4f2a-8a27-4e452d4e27a0",
@@ -2685,7 +2677,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2685
2677
  }
2686
2678
  async oid4vciHolderGetIssuerBranding(args, context) {
2687
2679
  const { serverMetadata, contact } = args;
2688
- const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_sdk3.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
2680
+ const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_types2.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
2689
2681
  if (issuerCorrelationId) {
2690
2682
  const branding = await context.agent.ibGetIssuerBranding({
2691
2683
  filter: [
@@ -2715,7 +2707,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2715
2707
  if (!contact) {
2716
2708
  return Promise.reject(Error("Missing contact in context"));
2717
2709
  }
2718
- const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_sdk3.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
2710
+ const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_types2.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
2719
2711
  const branding = await context.agent.ibGetIssuerBranding({
2720
2712
  filter: [
2721
2713
  {
@@ -2811,16 +2803,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2811
2803
  if (Array.isArray(subjectIssuance?.notification_events_supported)) {
2812
2804
  event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
2813
2805
  logger.log(`Subject issuance/signing will be used, with event`, event);
2814
- const credentialResponse = mappedCredentialToAccept.credentialToAccept.credentialResponse;
2815
- let issuerVC;
2816
- if ("credential" in credentialResponse) {
2817
- issuerVC = credentialResponse.credential;
2818
- } else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
2819
- issuerVC = credentialResponse.credentials[0].credential;
2820
- }
2821
- if (!issuerVC) {
2822
- return Promise.reject(Error("No credential found in credential response"));
2823
- }
2806
+ const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
2824
2807
  const wrappedIssuerVC = import_ssi_types2.CredentialMapper.toWrappedVerifiableCredential(issuerVC, {
2825
2808
  hasher: this.hasher ?? import_ssi_sdk2.defaultHasher
2826
2809
  });
@@ -2926,8 +2909,8 @@ var OID4VCIHolder = class _OID4VCIHolder {
2926
2909
  rawDocument: (0, import_ssi_sdk3.ensureRawDocument)(persistCredential),
2927
2910
  kmsKeyRef,
2928
2911
  identifierMethod: method,
2929
- credentialRole: import_ssi_sdk3.CredentialRole.HOLDER,
2930
- issuerCorrelationType: issuer?.startsWith("did:") ? import_ssi_sdk3.CredentialCorrelationType.DID : import_ssi_sdk3.CredentialCorrelationType.URL,
2912
+ credentialRole: import_ssi_types2.CredentialRole.HOLDER,
2913
+ issuerCorrelationType: issuer?.startsWith("did:") ? import_ssi_sdk4.CredentialCorrelationType.DID : import_ssi_sdk4.CredentialCorrelationType.URL,
2931
2914
  issuerCorrelationId: issuer,
2932
2915
  subjectCorrelationType,
2933
2916
  subjectCorrelationId
@@ -2995,12 +2978,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
2995
2978
  case "did":
2996
2979
  if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierDidResult)(identifier)) {
2997
2980
  return [
2998
- import_ssi_sdk3.CredentialCorrelationType.DID,
2981
+ import_ssi_sdk4.CredentialCorrelationType.DID,
2999
2982
  identifier.did
3000
2983
  ];
3001
2984
  } else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
3002
2985
  return [
3003
- import_ssi_sdk3.CredentialCorrelationType.DID,
2986
+ import_ssi_sdk4.CredentialCorrelationType.DID,
3004
2987
  typeof identifier.identifier === "string" ? identifier.identifier : identifier.identifier.did
3005
2988
  ];
3006
2989
  }
@@ -3008,12 +2991,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
3008
2991
  case "kid":
3009
2992
  if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierKidResult)(identifier)) {
3010
2993
  return [
3011
- import_ssi_sdk3.CredentialCorrelationType.KID,
2994
+ import_ssi_sdk4.CredentialCorrelationType.KID,
3012
2995
  identifier.kid
3013
2996
  ];
3014
2997
  } else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
3015
2998
  return [
3016
- import_ssi_sdk3.CredentialCorrelationType.KID,
2999
+ import_ssi_sdk4.CredentialCorrelationType.KID,
3017
3000
  identifier.identifier
3018
3001
  ];
3019
3002
  }
@@ -3021,19 +3004,19 @@ var OID4VCIHolder = class _OID4VCIHolder {
3021
3004
  case "x5c":
3022
3005
  if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierX5cResult)(identifier)) {
3023
3006
  return [
3024
- import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
3007
+ import_ssi_sdk4.CredentialCorrelationType.X509_SAN,
3025
3008
  identifier.x5c.join("\r\n")
3026
3009
  ];
3027
3010
  } else if ((0, import_ssi_sdk_ext6.isManagedIdentifierX5cOpts)(identifier)) {
3028
3011
  return [
3029
- import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
3012
+ import_ssi_sdk4.CredentialCorrelationType.X509_SAN,
3030
3013
  identifier.identifier.join("\r\n")
3031
3014
  ];
3032
3015
  }
3033
3016
  break;
3034
3017
  }
3035
3018
  return [
3036
- import_ssi_sdk3.CredentialCorrelationType.URL,
3019
+ import_ssi_sdk4.CredentialCorrelationType.URL,
3037
3020
  issuer
3038
3021
  ];
3039
3022
  }
@@ -3092,9 +3075,9 @@ var OID4VCICallbackStateListener = /* @__PURE__ */ __name((callbacks) => {
3092
3075
  // src/link-handler/index.ts
3093
3076
  var import_oid4vci_client4 = require("@sphereon/oid4vci-client");
3094
3077
  var import_oid4vci_common5 = require("@sphereon/oid4vci-common");
3095
- var import_ssi_sdk4 = require("@sphereon/ssi-sdk.core");
3096
- var import_ssi_sdk5 = require("@sphereon/ssi-sdk.xstate-machine-persistence");
3097
- var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter {
3078
+ var import_ssi_sdk5 = require("@sphereon/ssi-sdk.core");
3079
+ var import_ssi_sdk6 = require("@sphereon/ssi-sdk.xstate-machine-persistence");
3080
+ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk5.LinkHandlerAdapter {
3098
3081
  static {
3099
3082
  __name(this, "OID4VCIHolderLinkHandler");
3100
3083
  }
@@ -3154,7 +3137,7 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter
3154
3137
  const interpreter = oid4vciMachine.interpreter;
3155
3138
  if (!opts?.machineState && this.context.agent.availableMethods().includes("machineStatesFindActive")) {
3156
3139
  const stateType = hasCode ? "existing" : "new";
3157
- await (0, import_ssi_sdk5.interpreterStartOrResume)({
3140
+ await (0, import_ssi_sdk6.interpreterStartOrResume)({
3158
3141
  stateType,
3159
3142
  interpreter,
3160
3143
  context: this.context,