@sphereon/ssi-sdk.oid4vci-holder 0.34.1-next.87 → 0.34.1-next.91

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,
@@ -1062,271 +1063,10 @@ var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-resolver-jwk");
1062
1063
  var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.did-utils");
1063
1064
  var import_ssi_sdk_ext3 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
1064
1065
  var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.key-utils");
1066
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
1065
1067
  var import_ssi_types = require("@sphereon/ssi-types");
1066
1068
  var import_utils = require("@veramo/utils");
1067
1069
 
1068
- // src/mappers/OIDC4VCIBrandingMapper.ts
1069
- var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1070
- const { credentialDisplay, issuerCredentialSubject } = args;
1071
- return oid4vciCombineDisplayLocalesFrom({
1072
- ...issuerCredentialSubject && {
1073
- issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
1074
- issuerCredentialSubject
1075
- })
1076
- },
1077
- ...credentialDisplay && {
1078
- credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
1079
- credentialDisplay
1080
- })
1081
- }
1082
- });
1083
- }, "oid4vciGetCredentialBrandingFrom");
1084
- var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1085
- const { credentialDisplay } = args;
1086
- return credentialDisplay.reduce((localeDisplays, display) => {
1087
- const localeKey = display.locale || "";
1088
- localeDisplays.set(localeKey, display);
1089
- return localeDisplays;
1090
- }, /* @__PURE__ */ new Map());
1091
- }, "oid4vciCredentialDisplayLocalesFrom");
1092
- var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1093
- const { issuerCredentialSubject } = args;
1094
- const localeClaims = /* @__PURE__ */ new Map();
1095
- const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
1096
- Object.entries(claim).forEach(([key, value]) => {
1097
- if (key === "mandatory" || key === "value_type") {
1098
- return;
1099
- }
1100
- if (key === "display" && Array.isArray(value)) {
1101
- value.forEach(({ name, locale = "" }) => {
1102
- if (!name) {
1103
- return;
1104
- }
1105
- if (!localeClaims.has(locale)) {
1106
- localeClaims.set(locale, []);
1107
- }
1108
- localeClaims.get(locale).push({
1109
- key: parentKey,
1110
- name
1111
- });
1112
- });
1113
- } else if (typeof value === "object" && value !== null) {
1114
- processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
1115
- }
1116
- });
1117
- }, "processClaimObject");
1118
- processClaimObject(issuerCredentialSubject);
1119
- return localeClaims;
1120
- }, "oid4vciIssuerCredentialSubjectLocalesFrom");
1121
- var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1122
- const { credentialDisplay } = args;
1123
- return {
1124
- ...credentialDisplay.name && {
1125
- alias: credentialDisplay.name
1126
- },
1127
- ...credentialDisplay.locale && {
1128
- locale: credentialDisplay.locale
1129
- },
1130
- ...credentialDisplay.logo && {
1131
- logo: {
1132
- ...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
1133
- uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
1134
- },
1135
- ...credentialDisplay.logo.alt_text && {
1136
- alt: credentialDisplay.logo?.alt_text
1137
- }
1138
- }
1139
- },
1140
- ...credentialDisplay.description && {
1141
- description: credentialDisplay.description
1142
- },
1143
- ...credentialDisplay.text_color && {
1144
- text: {
1145
- color: credentialDisplay.text_color
1146
- }
1147
- },
1148
- ...(credentialDisplay.background_image || credentialDisplay.background_color) && {
1149
- background: {
1150
- ...credentialDisplay.background_image && {
1151
- image: {
1152
- ...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
1153
- uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
1154
- },
1155
- ...credentialDisplay.background_image.alt_text && {
1156
- alt: credentialDisplay.background_image?.alt_text
1157
- }
1158
- }
1159
- },
1160
- ...credentialDisplay.background_color && {
1161
- color: credentialDisplay.background_color
1162
- }
1163
- }
1164
- }
1165
- };
1166
- }, "oid4vciCredentialLocaleBrandingFrom");
1167
- var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1168
- const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
1169
- const locales = Array.from(/* @__PURE__ */ new Set([
1170
- ...issuerCredentialSubjectLocales.keys(),
1171
- ...credentialDisplayLocales.keys()
1172
- ]));
1173
- return Promise.all(locales.map(async (locale) => {
1174
- const display = credentialDisplayLocales.get(locale);
1175
- const claims = issuerCredentialSubjectLocales.get(locale);
1176
- return {
1177
- ...display && await oid4vciCredentialLocaleBrandingFrom({
1178
- credentialDisplay: display
1179
- }),
1180
- ...locale.length > 0 && {
1181
- locale
1182
- },
1183
- claims
1184
- };
1185
- }));
1186
- }, "oid4vciCombineDisplayLocalesFrom");
1187
- var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1188
- const { credentialDisplay, claimsMetadata } = args;
1189
- return sdJwtCombineDisplayLocalesFrom({
1190
- ...claimsMetadata && {
1191
- claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
1192
- claimsMetadata
1193
- })
1194
- },
1195
- ...credentialDisplay && {
1196
- credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
1197
- credentialDisplay
1198
- })
1199
- }
1200
- });
1201
- }, "sdJwtGetCredentialBrandingFrom");
1202
- var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1203
- const { credentialDisplay } = args;
1204
- return credentialDisplay.reduce((localeDisplays, display) => {
1205
- const localeKey = display.lang || "";
1206
- localeDisplays.set(localeKey, display);
1207
- return localeDisplays;
1208
- }, /* @__PURE__ */ new Map());
1209
- }, "sdJwtCredentialDisplayLocalesFrom");
1210
- var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1211
- const { claimsMetadata } = args;
1212
- const localeClaims = /* @__PURE__ */ new Map();
1213
- claimsMetadata.forEach((claim) => {
1214
- claim.display?.forEach((display) => {
1215
- const { lang = "", label } = display;
1216
- const key = claim.path.map((value) => String(value)).join(".");
1217
- if (!localeClaims.has(lang)) {
1218
- localeClaims.set(lang, []);
1219
- }
1220
- localeClaims.get(lang).push({
1221
- key,
1222
- name: label
1223
- });
1224
- });
1225
- });
1226
- return localeClaims;
1227
- }, "sdJwtCredentialClaimLocalesFrom");
1228
- var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1229
- const { credentialDisplay } = args;
1230
- return {
1231
- ...credentialDisplay.name && {
1232
- alias: credentialDisplay.name
1233
- },
1234
- ...credentialDisplay.lang && {
1235
- locale: credentialDisplay.lang
1236
- },
1237
- ...credentialDisplay.rendering?.simple?.logo && {
1238
- logo: {
1239
- ...credentialDisplay.rendering.simple.logo.uri && {
1240
- uri: credentialDisplay.rendering.simple.logo.uri
1241
- },
1242
- ...credentialDisplay.rendering.simple.logo.alt_text && {
1243
- alt: credentialDisplay.rendering.simple.logo.alt_text
1244
- }
1245
- }
1246
- },
1247
- ...credentialDisplay.description && {
1248
- description: credentialDisplay.description
1249
- },
1250
- ...credentialDisplay.rendering?.simple?.text_color && {
1251
- text: {
1252
- color: credentialDisplay.rendering.simple.text_color
1253
- }
1254
- },
1255
- ...credentialDisplay.rendering?.simple?.background_color && {
1256
- background: {
1257
- color: credentialDisplay.rendering.simple.background_color
1258
- }
1259
- }
1260
- };
1261
- }, "sdJwtCredentialLocaleBrandingFrom");
1262
- var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1263
- const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
1264
- const locales = Array.from(/* @__PURE__ */ new Set([
1265
- ...claimsMetadata.keys(),
1266
- ...credentialDisplayLocales.keys()
1267
- ]));
1268
- return Promise.all(locales.map(async (locale) => {
1269
- const display = credentialDisplayLocales.get(locale);
1270
- const claims = claimsMetadata.get(locale);
1271
- return {
1272
- ...display && await sdJwtCredentialLocaleBrandingFrom({
1273
- credentialDisplay: display
1274
- }),
1275
- ...locale.length > 0 && {
1276
- locale
1277
- },
1278
- claims
1279
- };
1280
- }));
1281
- }, "sdJwtCombineDisplayLocalesFrom");
1282
- var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1283
- const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
1284
- return {
1285
- ...dynamicRegistrationClientMetadata?.client_name && {
1286
- alias: dynamicRegistrationClientMetadata.client_name
1287
- },
1288
- ...issuerDisplay.name && {
1289
- alias: issuerDisplay.name
1290
- },
1291
- ...issuerDisplay.locale && {
1292
- locale: issuerDisplay.locale
1293
- },
1294
- ...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
1295
- logo: {
1296
- ...dynamicRegistrationClientMetadata?.logo_uri && {
1297
- uri: dynamicRegistrationClientMetadata?.logo_uri
1298
- },
1299
- ...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
1300
- uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
1301
- },
1302
- ...issuerDisplay.logo?.alt_text && {
1303
- alt: issuerDisplay.logo?.alt_text
1304
- }
1305
- }
1306
- },
1307
- ...issuerDisplay.description && {
1308
- description: issuerDisplay.description
1309
- },
1310
- ...issuerDisplay.text_color && {
1311
- text: {
1312
- color: issuerDisplay.text_color
1313
- }
1314
- },
1315
- ...dynamicRegistrationClientMetadata?.client_uri && {
1316
- clientUri: dynamicRegistrationClientMetadata.client_uri
1317
- },
1318
- ...dynamicRegistrationClientMetadata?.tos_uri && {
1319
- tosUri: dynamicRegistrationClientMetadata.tos_uri
1320
- },
1321
- ...dynamicRegistrationClientMetadata?.policy_uri && {
1322
- policyUri: dynamicRegistrationClientMetadata.policy_uri
1323
- },
1324
- ...dynamicRegistrationClientMetadata?.contacts && {
1325
- contacts: dynamicRegistrationClientMetadata.contacts
1326
- }
1327
- };
1328
- }, "issuerLocaleBrandingFrom");
1329
-
1330
1070
  // src/machines/firstPartyMachine.ts
1331
1071
  var import_xstate2 = require("xstate");
1332
1072
  var import_oid4vci_common2 = require("@sphereon/oid4vci-common");
@@ -1530,90 +1270,351 @@ var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
1530
1270
  contact: opts.contact,
1531
1271
  selectedCredentials: []
1532
1272
  };
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: {}
1273
+ return (0, import_xstate2.createMachine)({
1274
+ id: opts?.machineId ?? "FirstParty",
1275
+ predictableActionArguments: true,
1276
+ initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
1277
+ context: initialContext,
1278
+ states: firstPartyMachineStates,
1279
+ schema: {
1280
+ events: {},
1281
+ services: {}
1282
+ }
1283
+ });
1284
+ }, "createFirstPartyActivationMachine");
1285
+ var FirstPartyMachine = class _FirstPartyMachine {
1286
+ static {
1287
+ __name(this, "FirstPartyMachine");
1288
+ }
1289
+ static _instance;
1290
+ static hasInstance() {
1291
+ return _FirstPartyMachine._instance !== void 0;
1292
+ }
1293
+ static get instance() {
1294
+ if (!_FirstPartyMachine._instance) {
1295
+ throw Error("Please initialize ESIMActivation machine first");
1296
+ }
1297
+ return _FirstPartyMachine._instance;
1298
+ }
1299
+ static clearInstance(opts) {
1300
+ const { stop } = opts;
1301
+ if (_FirstPartyMachine.hasInstance()) {
1302
+ if (stop) {
1303
+ _FirstPartyMachine.stopInstance();
1304
+ }
1305
+ }
1306
+ _FirstPartyMachine._instance = void 0;
1307
+ }
1308
+ static stopInstance() {
1309
+ if (!_FirstPartyMachine.hasInstance()) {
1310
+ return;
1311
+ }
1312
+ _FirstPartyMachine.instance.stop();
1313
+ _FirstPartyMachine._instance = void 0;
1314
+ }
1315
+ static newInstance(opts) {
1316
+ const { agentContext } = opts;
1317
+ const services = {
1318
+ [FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
1319
+ [FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
1320
+ [FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
1321
+ [FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
1322
+ };
1323
+ const newInst = (0, import_xstate2.interpret)(createFirstPartyActivationMachine(opts).withConfig({
1324
+ services: {
1325
+ ...services,
1326
+ ...opts?.services
1327
+ },
1328
+ guards: {
1329
+ ...opts?.guards
1330
+ }
1331
+ }));
1332
+ if (typeof opts?.subscription === "function") {
1333
+ newInst.onTransition(opts.subscription);
1334
+ }
1335
+ if (opts?.requireCustomNavigationHook !== true) {
1336
+ newInst.onTransition((snapshot) => {
1337
+ if (opts?.stateNavigationListener) {
1338
+ void opts.stateNavigationListener(newInst, snapshot);
1339
+ }
1340
+ });
1341
+ }
1342
+ return newInst;
1343
+ }
1344
+ static getInstance(opts) {
1345
+ if (!_FirstPartyMachine._instance) {
1346
+ if (opts?.requireExisting === true) {
1347
+ throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
1348
+ }
1349
+ _FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
1350
+ }
1351
+ return _FirstPartyMachine._instance;
1352
+ }
1353
+ };
1354
+
1355
+ // src/mappers/OIDC4VCIBrandingMapper.ts
1356
+ var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1357
+ const { credentialDisplay, issuerCredentialSubject } = args;
1358
+ return oid4vciCombineDisplayLocalesFrom({
1359
+ ...issuerCredentialSubject && {
1360
+ issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
1361
+ issuerCredentialSubject
1362
+ })
1363
+ },
1364
+ ...credentialDisplay && {
1365
+ credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
1366
+ credentialDisplay
1367
+ })
1368
+ }
1369
+ });
1370
+ }, "oid4vciGetCredentialBrandingFrom");
1371
+ var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1372
+ const { credentialDisplay } = args;
1373
+ return credentialDisplay.reduce((localeDisplays, display) => {
1374
+ const localeKey = display.locale || "";
1375
+ localeDisplays.set(localeKey, display);
1376
+ return localeDisplays;
1377
+ }, /* @__PURE__ */ new Map());
1378
+ }, "oid4vciCredentialDisplayLocalesFrom");
1379
+ var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1380
+ const { issuerCredentialSubject } = args;
1381
+ const localeClaims = /* @__PURE__ */ new Map();
1382
+ const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
1383
+ Object.entries(claim).forEach(([key, value]) => {
1384
+ if (key === "mandatory" || key === "value_type") {
1385
+ return;
1386
+ }
1387
+ if (key === "display" && Array.isArray(value)) {
1388
+ value.forEach(({ name, locale = "" }) => {
1389
+ if (!name) {
1390
+ return;
1391
+ }
1392
+ if (!localeClaims.has(locale)) {
1393
+ localeClaims.set(locale, []);
1394
+ }
1395
+ localeClaims.get(locale).push({
1396
+ key: parentKey,
1397
+ name
1398
+ });
1399
+ });
1400
+ } else if (typeof value === "object" && value !== null) {
1401
+ processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
1402
+ }
1403
+ });
1404
+ }, "processClaimObject");
1405
+ processClaimObject(issuerCredentialSubject);
1406
+ return localeClaims;
1407
+ }, "oid4vciIssuerCredentialSubjectLocalesFrom");
1408
+ var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1409
+ const { credentialDisplay } = args;
1410
+ return {
1411
+ ...credentialDisplay.name && {
1412
+ alias: credentialDisplay.name
1413
+ },
1414
+ ...credentialDisplay.locale && {
1415
+ locale: credentialDisplay.locale
1416
+ },
1417
+ ...credentialDisplay.logo && {
1418
+ logo: {
1419
+ ...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
1420
+ uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
1421
+ },
1422
+ ...credentialDisplay.logo.alt_text && {
1423
+ alt: credentialDisplay.logo?.alt_text
1424
+ }
1425
+ }
1426
+ },
1427
+ ...credentialDisplay.description && {
1428
+ description: credentialDisplay.description
1429
+ },
1430
+ ...credentialDisplay.text_color && {
1431
+ text: {
1432
+ color: credentialDisplay.text_color
1433
+ }
1434
+ },
1435
+ ...(credentialDisplay.background_image || credentialDisplay.background_color) && {
1436
+ background: {
1437
+ ...credentialDisplay.background_image && {
1438
+ image: {
1439
+ ...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
1440
+ uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
1441
+ },
1442
+ ...credentialDisplay.background_image.alt_text && {
1443
+ alt: credentialDisplay.background_image?.alt_text
1444
+ }
1445
+ }
1446
+ },
1447
+ ...credentialDisplay.background_color && {
1448
+ color: credentialDisplay.background_color
1449
+ }
1450
+ }
1451
+ }
1452
+ };
1453
+ }, "oid4vciCredentialLocaleBrandingFrom");
1454
+ var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1455
+ const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
1456
+ const locales = Array.from(/* @__PURE__ */ new Set([
1457
+ ...issuerCredentialSubjectLocales.keys(),
1458
+ ...credentialDisplayLocales.keys()
1459
+ ]));
1460
+ return Promise.all(locales.map(async (locale) => {
1461
+ const display = credentialDisplayLocales.get(locale);
1462
+ const claims = issuerCredentialSubjectLocales.get(locale);
1463
+ return {
1464
+ ...display && await oid4vciCredentialLocaleBrandingFrom({
1465
+ credentialDisplay: display
1466
+ }),
1467
+ ...locale.length > 0 && {
1468
+ locale
1469
+ },
1470
+ claims
1471
+ };
1472
+ }));
1473
+ }, "oid4vciCombineDisplayLocalesFrom");
1474
+ var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1475
+ const { credentialDisplay, claimsMetadata } = args;
1476
+ return sdJwtCombineDisplayLocalesFrom({
1477
+ ...claimsMetadata && {
1478
+ claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
1479
+ claimsMetadata
1480
+ })
1481
+ },
1482
+ ...credentialDisplay && {
1483
+ credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
1484
+ credentialDisplay
1485
+ })
1542
1486
  }
1543
1487
  });
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();
1488
+ }, "sdJwtGetCredentialBrandingFrom");
1489
+ var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1490
+ const { credentialDisplay } = args;
1491
+ return credentialDisplay.reduce((localeDisplays, display) => {
1492
+ const localeKey = display.lang || "";
1493
+ localeDisplays.set(localeKey, display);
1494
+ return localeDisplays;
1495
+ }, /* @__PURE__ */ new Map());
1496
+ }, "sdJwtCredentialDisplayLocalesFrom");
1497
+ var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1498
+ const { claimsMetadata } = args;
1499
+ const localeClaims = /* @__PURE__ */ new Map();
1500
+ claimsMetadata.forEach((claim) => {
1501
+ claim.display?.forEach((display) => {
1502
+ const { lang = "", label } = display;
1503
+ const key = claim.path.map((value) => String(value)).join(".");
1504
+ if (!localeClaims.has(lang)) {
1505
+ localeClaims.set(lang, []);
1564
1506
  }
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
1587
- },
1588
- guards: {
1589
- ...opts?.guards
1507
+ localeClaims.get(lang).push({
1508
+ key,
1509
+ name: label
1510
+ });
1511
+ });
1512
+ });
1513
+ return localeClaims;
1514
+ }, "sdJwtCredentialClaimLocalesFrom");
1515
+ var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1516
+ const { credentialDisplay } = args;
1517
+ return {
1518
+ ...credentialDisplay.name && {
1519
+ alias: credentialDisplay.name
1520
+ },
1521
+ ...credentialDisplay.lang && {
1522
+ locale: credentialDisplay.lang
1523
+ },
1524
+ ...credentialDisplay.rendering?.simple?.logo && {
1525
+ logo: {
1526
+ ...credentialDisplay.rendering.simple.logo.uri && {
1527
+ uri: credentialDisplay.rendering.simple.logo.uri
1528
+ },
1529
+ ...credentialDisplay.rendering.simple.logo.alt_text && {
1530
+ alt: credentialDisplay.rendering.simple.logo.alt_text
1531
+ }
1532
+ }
1533
+ },
1534
+ ...credentialDisplay.description && {
1535
+ description: credentialDisplay.description
1536
+ },
1537
+ ...credentialDisplay.rendering?.simple?.text_color && {
1538
+ text: {
1539
+ color: credentialDisplay.rendering.simple.text_color
1540
+ }
1541
+ },
1542
+ ...credentialDisplay.rendering?.simple?.background_color && {
1543
+ background: {
1544
+ color: credentialDisplay.rendering.simple.background_color
1590
1545
  }
1591
- }));
1592
- if (typeof opts?.subscription === "function") {
1593
- newInst.onTransition(opts.subscription);
1594
1546
  }
1595
- if (opts?.requireCustomNavigationHook !== true) {
1596
- newInst.onTransition((snapshot) => {
1597
- if (opts?.stateNavigationListener) {
1598
- void opts.stateNavigationListener(newInst, snapshot);
1547
+ };
1548
+ }, "sdJwtCredentialLocaleBrandingFrom");
1549
+ var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
1550
+ const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
1551
+ const locales = Array.from(/* @__PURE__ */ new Set([
1552
+ ...claimsMetadata.keys(),
1553
+ ...credentialDisplayLocales.keys()
1554
+ ]));
1555
+ return Promise.all(locales.map(async (locale) => {
1556
+ const display = credentialDisplayLocales.get(locale);
1557
+ const claims = claimsMetadata.get(locale);
1558
+ return {
1559
+ ...display && await sdJwtCredentialLocaleBrandingFrom({
1560
+ credentialDisplay: display
1561
+ }),
1562
+ ...locale.length > 0 && {
1563
+ locale
1564
+ },
1565
+ claims
1566
+ };
1567
+ }));
1568
+ }, "sdJwtCombineDisplayLocalesFrom");
1569
+ var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
1570
+ const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
1571
+ return {
1572
+ ...dynamicRegistrationClientMetadata?.client_name && {
1573
+ alias: dynamicRegistrationClientMetadata.client_name
1574
+ },
1575
+ ...issuerDisplay.name && {
1576
+ alias: issuerDisplay.name
1577
+ },
1578
+ ...issuerDisplay.locale && {
1579
+ locale: issuerDisplay.locale
1580
+ },
1581
+ ...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
1582
+ logo: {
1583
+ ...dynamicRegistrationClientMetadata?.logo_uri && {
1584
+ uri: dynamicRegistrationClientMetadata?.logo_uri
1585
+ },
1586
+ ...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
1587
+ uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
1588
+ },
1589
+ ...issuerDisplay.logo?.alt_text && {
1590
+ alt: issuerDisplay.logo?.alt_text
1599
1591
  }
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
1592
  }
1609
- _FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
1593
+ },
1594
+ ...issuerDisplay.description && {
1595
+ description: issuerDisplay.description
1596
+ },
1597
+ ...issuerDisplay.text_color && {
1598
+ text: {
1599
+ color: issuerDisplay.text_color
1600
+ }
1601
+ },
1602
+ ...dynamicRegistrationClientMetadata?.client_uri && {
1603
+ clientUri: dynamicRegistrationClientMetadata.client_uri
1604
+ },
1605
+ ...dynamicRegistrationClientMetadata?.tos_uri && {
1606
+ tosUri: dynamicRegistrationClientMetadata.tos_uri
1607
+ },
1608
+ ...dynamicRegistrationClientMetadata?.policy_uri && {
1609
+ policyUri: dynamicRegistrationClientMetadata.policy_uri
1610
+ },
1611
+ ...dynamicRegistrationClientMetadata?.contacts && {
1612
+ contacts: dynamicRegistrationClientMetadata.contacts
1610
1613
  }
1611
- return _FirstPartyMachine._instance;
1612
- }
1613
- };
1614
+ };
1615
+ }, "issuerLocaleBrandingFrom");
1614
1616
 
1615
1617
  // src/services/OID4VCIHolderService.ts
1616
- var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
1617
1618
  var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
1618
1619
  const { credentialsSupported, context } = args;
1619
1620
  const credentialBranding = {};
@@ -1685,16 +1686,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
1685
1686
  }, "selectCredentialLocaleBranding");
1686
1687
  var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1687
1688
  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
- }
1689
+ const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
1698
1690
  const wrappedVC = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(credential, {
1699
1691
  hasher: hasher ?? import_ssi_sdk.defaultHasher
1700
1692
  });
@@ -1746,16 +1738,7 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1746
1738
  }, "verifyCredentialToAccept");
1747
1739
  var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1748
1740
  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
- }
1741
+ const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
1759
1742
  const wrappedVerifiableCredential = import_ssi_types.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
1760
1743
  hasher
1761
1744
  });
@@ -1775,6 +1758,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1775
1758
  uniformVerifiableCredential = wrappedVerifiableCredential.credential;
1776
1759
  }
1777
1760
  const correlationId = typeof uniformVerifiableCredential.issuer === "string" ? uniformVerifiableCredential.issuer : import_ssi_types.CredentialMapper.isSdJwtDecodedCredential(uniformVerifiableCredential) ? uniformVerifiableCredential.decodedPayload.iss : uniformVerifiableCredential.issuer.id;
1761
+ const credentialResponse = credentialToAccept.credentialResponse;
1778
1762
  return {
1779
1763
  correlationId,
1780
1764
  credentialToAccept,
@@ -1786,6 +1770,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1786
1770
  }
1787
1771
  };
1788
1772
  }, "mapCredentialToAccept");
1773
+ var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse) => {
1774
+ let credential;
1775
+ if ("credential" in credentialResponse) {
1776
+ credential = credentialResponse.credential;
1777
+ } else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
1778
+ credential = credentialResponse.credentials[0].credential;
1779
+ }
1780
+ if (!credential) {
1781
+ throw new Error("No credential found in credential response");
1782
+ }
1783
+ return credential;
1784
+ }, "extractCredentialFromResponse");
1789
1785
  var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
1790
1786
  const { issuanceOpt, context } = args;
1791
1787
  const { identifier: identifierArg } = issuanceOpt;
@@ -2086,7 +2082,7 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
2086
2082
  case "jwt":
2087
2083
  case "jwt_vc_json":
2088
2084
  case "jwt_vc":
2089
- case "dc+sd-jwt":
2085
+ case "vc+sd-jwt":
2090
2086
  case "dc+sd-jwt":
2091
2087
  case "mso_mdoc": {
2092
2088
  const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
@@ -2811,16 +2807,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2811
2807
  if (Array.isArray(subjectIssuance?.notification_events_supported)) {
2812
2808
  event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
2813
2809
  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
- }
2810
+ const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
2824
2811
  const wrappedIssuerVC = import_ssi_types2.CredentialMapper.toWrappedVerifiableCredential(issuerVC, {
2825
2812
  hasher: this.hasher ?? import_ssi_sdk2.defaultHasher
2826
2813
  });