@sphereon/ssi-sdk.oid4vci-holder 0.34.1-next.88 → 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 +353 -366
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +353 -366
- package/dist/index.js.map +1 -1
- package/package.json +24 -24
- package/src/agent/OID4VCIHolder.ts +3 -16
- package/src/services/OID4VCIHolderService.ts +34 -39
package/dist/index.js
CHANGED
|
@@ -983,271 +983,10 @@ 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
|
|
|
989
|
-
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
990
|
-
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
991
|
-
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
992
|
-
return oid4vciCombineDisplayLocalesFrom({
|
|
993
|
-
...issuerCredentialSubject && {
|
|
994
|
-
issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
|
|
995
|
-
issuerCredentialSubject
|
|
996
|
-
})
|
|
997
|
-
},
|
|
998
|
-
...credentialDisplay && {
|
|
999
|
-
credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
|
|
1000
|
-
credentialDisplay
|
|
1001
|
-
})
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
}, "oid4vciGetCredentialBrandingFrom");
|
|
1005
|
-
var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1006
|
-
const { credentialDisplay } = args;
|
|
1007
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1008
|
-
const localeKey = display.locale || "";
|
|
1009
|
-
localeDisplays.set(localeKey, display);
|
|
1010
|
-
return localeDisplays;
|
|
1011
|
-
}, /* @__PURE__ */ new Map());
|
|
1012
|
-
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1013
|
-
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1014
|
-
const { issuerCredentialSubject } = args;
|
|
1015
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1016
|
-
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1017
|
-
Object.entries(claim).forEach(([key, value]) => {
|
|
1018
|
-
if (key === "mandatory" || key === "value_type") {
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
if (key === "display" && Array.isArray(value)) {
|
|
1022
|
-
value.forEach(({ name, locale = "" }) => {
|
|
1023
|
-
if (!name) {
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
if (!localeClaims.has(locale)) {
|
|
1027
|
-
localeClaims.set(locale, []);
|
|
1028
|
-
}
|
|
1029
|
-
localeClaims.get(locale).push({
|
|
1030
|
-
key: parentKey,
|
|
1031
|
-
name
|
|
1032
|
-
});
|
|
1033
|
-
});
|
|
1034
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1035
|
-
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
}, "processClaimObject");
|
|
1039
|
-
processClaimObject(issuerCredentialSubject);
|
|
1040
|
-
return localeClaims;
|
|
1041
|
-
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1042
|
-
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1043
|
-
const { credentialDisplay } = args;
|
|
1044
|
-
return {
|
|
1045
|
-
...credentialDisplay.name && {
|
|
1046
|
-
alias: credentialDisplay.name
|
|
1047
|
-
},
|
|
1048
|
-
...credentialDisplay.locale && {
|
|
1049
|
-
locale: credentialDisplay.locale
|
|
1050
|
-
},
|
|
1051
|
-
...credentialDisplay.logo && {
|
|
1052
|
-
logo: {
|
|
1053
|
-
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1054
|
-
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1055
|
-
},
|
|
1056
|
-
...credentialDisplay.logo.alt_text && {
|
|
1057
|
-
alt: credentialDisplay.logo?.alt_text
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
},
|
|
1061
|
-
...credentialDisplay.description && {
|
|
1062
|
-
description: credentialDisplay.description
|
|
1063
|
-
},
|
|
1064
|
-
...credentialDisplay.text_color && {
|
|
1065
|
-
text: {
|
|
1066
|
-
color: credentialDisplay.text_color
|
|
1067
|
-
}
|
|
1068
|
-
},
|
|
1069
|
-
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1070
|
-
background: {
|
|
1071
|
-
...credentialDisplay.background_image && {
|
|
1072
|
-
image: {
|
|
1073
|
-
...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
|
|
1074
|
-
uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
|
|
1075
|
-
},
|
|
1076
|
-
...credentialDisplay.background_image.alt_text && {
|
|
1077
|
-
alt: credentialDisplay.background_image?.alt_text
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
},
|
|
1081
|
-
...credentialDisplay.background_color && {
|
|
1082
|
-
color: credentialDisplay.background_color
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1088
|
-
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1089
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1090
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1091
|
-
...issuerCredentialSubjectLocales.keys(),
|
|
1092
|
-
...credentialDisplayLocales.keys()
|
|
1093
|
-
]));
|
|
1094
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1095
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1096
|
-
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1097
|
-
return {
|
|
1098
|
-
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1099
|
-
credentialDisplay: display
|
|
1100
|
-
}),
|
|
1101
|
-
...locale.length > 0 && {
|
|
1102
|
-
locale
|
|
1103
|
-
},
|
|
1104
|
-
claims
|
|
1105
|
-
};
|
|
1106
|
-
}));
|
|
1107
|
-
}, "oid4vciCombineDisplayLocalesFrom");
|
|
1108
|
-
var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1109
|
-
const { credentialDisplay, claimsMetadata } = args;
|
|
1110
|
-
return sdJwtCombineDisplayLocalesFrom({
|
|
1111
|
-
...claimsMetadata && {
|
|
1112
|
-
claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
|
|
1113
|
-
claimsMetadata
|
|
1114
|
-
})
|
|
1115
|
-
},
|
|
1116
|
-
...credentialDisplay && {
|
|
1117
|
-
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1118
|
-
credentialDisplay
|
|
1119
|
-
})
|
|
1120
|
-
}
|
|
1121
|
-
});
|
|
1122
|
-
}, "sdJwtGetCredentialBrandingFrom");
|
|
1123
|
-
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1124
|
-
const { credentialDisplay } = args;
|
|
1125
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1126
|
-
const localeKey = display.lang || "";
|
|
1127
|
-
localeDisplays.set(localeKey, display);
|
|
1128
|
-
return localeDisplays;
|
|
1129
|
-
}, /* @__PURE__ */ new Map());
|
|
1130
|
-
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1131
|
-
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1132
|
-
const { claimsMetadata } = args;
|
|
1133
|
-
const localeClaims = /* @__PURE__ */ new Map();
|
|
1134
|
-
claimsMetadata.forEach((claim) => {
|
|
1135
|
-
claim.display?.forEach((display) => {
|
|
1136
|
-
const { lang = "", label } = display;
|
|
1137
|
-
const key = claim.path.map((value) => String(value)).join(".");
|
|
1138
|
-
if (!localeClaims.has(lang)) {
|
|
1139
|
-
localeClaims.set(lang, []);
|
|
1140
|
-
}
|
|
1141
|
-
localeClaims.get(lang).push({
|
|
1142
|
-
key,
|
|
1143
|
-
name: label
|
|
1144
|
-
});
|
|
1145
|
-
});
|
|
1146
|
-
});
|
|
1147
|
-
return localeClaims;
|
|
1148
|
-
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1149
|
-
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1150
|
-
const { credentialDisplay } = args;
|
|
1151
|
-
return {
|
|
1152
|
-
...credentialDisplay.name && {
|
|
1153
|
-
alias: credentialDisplay.name
|
|
1154
|
-
},
|
|
1155
|
-
...credentialDisplay.lang && {
|
|
1156
|
-
locale: credentialDisplay.lang
|
|
1157
|
-
},
|
|
1158
|
-
...credentialDisplay.rendering?.simple?.logo && {
|
|
1159
|
-
logo: {
|
|
1160
|
-
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1161
|
-
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1162
|
-
},
|
|
1163
|
-
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1164
|
-
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
...credentialDisplay.description && {
|
|
1169
|
-
description: credentialDisplay.description
|
|
1170
|
-
},
|
|
1171
|
-
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1172
|
-
text: {
|
|
1173
|
-
color: credentialDisplay.rendering.simple.text_color
|
|
1174
|
-
}
|
|
1175
|
-
},
|
|
1176
|
-
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1177
|
-
background: {
|
|
1178
|
-
color: credentialDisplay.rendering.simple.background_color
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
};
|
|
1182
|
-
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1183
|
-
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1184
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1185
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1186
|
-
...claimsMetadata.keys(),
|
|
1187
|
-
...credentialDisplayLocales.keys()
|
|
1188
|
-
]));
|
|
1189
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1190
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1191
|
-
const claims = claimsMetadata.get(locale);
|
|
1192
|
-
return {
|
|
1193
|
-
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1194
|
-
credentialDisplay: display
|
|
1195
|
-
}),
|
|
1196
|
-
...locale.length > 0 && {
|
|
1197
|
-
locale
|
|
1198
|
-
},
|
|
1199
|
-
claims
|
|
1200
|
-
};
|
|
1201
|
-
}));
|
|
1202
|
-
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1203
|
-
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1204
|
-
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1205
|
-
return {
|
|
1206
|
-
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1207
|
-
alias: dynamicRegistrationClientMetadata.client_name
|
|
1208
|
-
},
|
|
1209
|
-
...issuerDisplay.name && {
|
|
1210
|
-
alias: issuerDisplay.name
|
|
1211
|
-
},
|
|
1212
|
-
...issuerDisplay.locale && {
|
|
1213
|
-
locale: issuerDisplay.locale
|
|
1214
|
-
},
|
|
1215
|
-
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1216
|
-
logo: {
|
|
1217
|
-
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1218
|
-
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1219
|
-
},
|
|
1220
|
-
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1221
|
-
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1222
|
-
},
|
|
1223
|
-
...issuerDisplay.logo?.alt_text && {
|
|
1224
|
-
alt: issuerDisplay.logo?.alt_text
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
},
|
|
1228
|
-
...issuerDisplay.description && {
|
|
1229
|
-
description: issuerDisplay.description
|
|
1230
|
-
},
|
|
1231
|
-
...issuerDisplay.text_color && {
|
|
1232
|
-
text: {
|
|
1233
|
-
color: issuerDisplay.text_color
|
|
1234
|
-
}
|
|
1235
|
-
},
|
|
1236
|
-
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1237
|
-
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1238
|
-
},
|
|
1239
|
-
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1240
|
-
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1241
|
-
},
|
|
1242
|
-
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1243
|
-
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1244
|
-
},
|
|
1245
|
-
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1246
|
-
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
}, "issuerLocaleBrandingFrom");
|
|
1250
|
-
|
|
1251
990
|
// src/machines/firstPartyMachine.ts
|
|
1252
991
|
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
1253
992
|
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
@@ -1451,90 +1190,351 @@ var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
1451
1190
|
contact: opts.contact,
|
|
1452
1191
|
selectedCredentials: []
|
|
1453
1192
|
};
|
|
1454
|
-
return createMachine2({
|
|
1455
|
-
id: opts?.machineId ?? "FirstParty",
|
|
1456
|
-
predictableActionArguments: true,
|
|
1457
|
-
initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1458
|
-
context: initialContext,
|
|
1459
|
-
states: firstPartyMachineStates,
|
|
1460
|
-
schema: {
|
|
1461
|
-
events: {},
|
|
1462
|
-
services: {}
|
|
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
|
+
|
|
1275
|
+
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
1276
|
+
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1277
|
+
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
1278
|
+
return oid4vciCombineDisplayLocalesFrom({
|
|
1279
|
+
...issuerCredentialSubject && {
|
|
1280
|
+
issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({
|
|
1281
|
+
issuerCredentialSubject
|
|
1282
|
+
})
|
|
1283
|
+
},
|
|
1284
|
+
...credentialDisplay && {
|
|
1285
|
+
credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({
|
|
1286
|
+
credentialDisplay
|
|
1287
|
+
})
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
}, "oid4vciGetCredentialBrandingFrom");
|
|
1291
|
+
var oid4vciCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1292
|
+
const { credentialDisplay } = args;
|
|
1293
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1294
|
+
const localeKey = display.locale || "";
|
|
1295
|
+
localeDisplays.set(localeKey, display);
|
|
1296
|
+
return localeDisplays;
|
|
1297
|
+
}, /* @__PURE__ */ new Map());
|
|
1298
|
+
}, "oid4vciCredentialDisplayLocalesFrom");
|
|
1299
|
+
var oid4vciIssuerCredentialSubjectLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1300
|
+
const { issuerCredentialSubject } = args;
|
|
1301
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
1302
|
+
const processClaimObject = /* @__PURE__ */ __name((claim, parentKey = "") => {
|
|
1303
|
+
Object.entries(claim).forEach(([key, value]) => {
|
|
1304
|
+
if (key === "mandatory" || key === "value_type") {
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
if (key === "display" && Array.isArray(value)) {
|
|
1308
|
+
value.forEach(({ name, locale = "" }) => {
|
|
1309
|
+
if (!name) {
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
if (!localeClaims.has(locale)) {
|
|
1313
|
+
localeClaims.set(locale, []);
|
|
1314
|
+
}
|
|
1315
|
+
localeClaims.get(locale).push({
|
|
1316
|
+
key: parentKey,
|
|
1317
|
+
name
|
|
1318
|
+
});
|
|
1319
|
+
});
|
|
1320
|
+
} else if (typeof value === "object" && value !== null) {
|
|
1321
|
+
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key);
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
}, "processClaimObject");
|
|
1325
|
+
processClaimObject(issuerCredentialSubject);
|
|
1326
|
+
return localeClaims;
|
|
1327
|
+
}, "oid4vciIssuerCredentialSubjectLocalesFrom");
|
|
1328
|
+
var oid4vciCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1329
|
+
const { credentialDisplay } = args;
|
|
1330
|
+
return {
|
|
1331
|
+
...credentialDisplay.name && {
|
|
1332
|
+
alias: credentialDisplay.name
|
|
1333
|
+
},
|
|
1334
|
+
...credentialDisplay.locale && {
|
|
1335
|
+
locale: credentialDisplay.locale
|
|
1336
|
+
},
|
|
1337
|
+
...credentialDisplay.logo && {
|
|
1338
|
+
logo: {
|
|
1339
|
+
...(credentialDisplay.logo.url || credentialDisplay.logo.uri) && {
|
|
1340
|
+
uri: credentialDisplay.logo?.url ?? credentialDisplay.logo.uri
|
|
1341
|
+
},
|
|
1342
|
+
...credentialDisplay.logo.alt_text && {
|
|
1343
|
+
alt: credentialDisplay.logo?.alt_text
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
},
|
|
1347
|
+
...credentialDisplay.description && {
|
|
1348
|
+
description: credentialDisplay.description
|
|
1349
|
+
},
|
|
1350
|
+
...credentialDisplay.text_color && {
|
|
1351
|
+
text: {
|
|
1352
|
+
color: credentialDisplay.text_color
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
...(credentialDisplay.background_image || credentialDisplay.background_color) && {
|
|
1356
|
+
background: {
|
|
1357
|
+
...credentialDisplay.background_image && {
|
|
1358
|
+
image: {
|
|
1359
|
+
...(credentialDisplay.background_image.url || credentialDisplay.background_image.uri) && {
|
|
1360
|
+
uri: credentialDisplay.background_image?.url ?? credentialDisplay.background_image.uri
|
|
1361
|
+
},
|
|
1362
|
+
...credentialDisplay.background_image.alt_text && {
|
|
1363
|
+
alt: credentialDisplay.background_image?.alt_text
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
...credentialDisplay.background_color && {
|
|
1368
|
+
color: credentialDisplay.background_color
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
}, "oid4vciCredentialLocaleBrandingFrom");
|
|
1374
|
+
var oid4vciCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1375
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), issuerCredentialSubjectLocales = /* @__PURE__ */ new Map() } = args;
|
|
1376
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1377
|
+
...issuerCredentialSubjectLocales.keys(),
|
|
1378
|
+
...credentialDisplayLocales.keys()
|
|
1379
|
+
]));
|
|
1380
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1381
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1382
|
+
const claims = issuerCredentialSubjectLocales.get(locale);
|
|
1383
|
+
return {
|
|
1384
|
+
...display && await oid4vciCredentialLocaleBrandingFrom({
|
|
1385
|
+
credentialDisplay: display
|
|
1386
|
+
}),
|
|
1387
|
+
...locale.length > 0 && {
|
|
1388
|
+
locale
|
|
1389
|
+
},
|
|
1390
|
+
claims
|
|
1391
|
+
};
|
|
1392
|
+
}));
|
|
1393
|
+
}, "oid4vciCombineDisplayLocalesFrom");
|
|
1394
|
+
var sdJwtGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1395
|
+
const { credentialDisplay, claimsMetadata } = args;
|
|
1396
|
+
return sdJwtCombineDisplayLocalesFrom({
|
|
1397
|
+
...claimsMetadata && {
|
|
1398
|
+
claimsMetadata: await sdJwtCredentialClaimLocalesFrom({
|
|
1399
|
+
claimsMetadata
|
|
1400
|
+
})
|
|
1401
|
+
},
|
|
1402
|
+
...credentialDisplay && {
|
|
1403
|
+
credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({
|
|
1404
|
+
credentialDisplay
|
|
1405
|
+
})
|
|
1463
1406
|
}
|
|
1464
1407
|
});
|
|
1465
|
-
}, "
|
|
1466
|
-
var
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
if (stop) {
|
|
1484
|
-
_FirstPartyMachine.stopInstance();
|
|
1408
|
+
}, "sdJwtGetCredentialBrandingFrom");
|
|
1409
|
+
var sdJwtCredentialDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1410
|
+
const { credentialDisplay } = args;
|
|
1411
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
1412
|
+
const localeKey = display.lang || "";
|
|
1413
|
+
localeDisplays.set(localeKey, display);
|
|
1414
|
+
return localeDisplays;
|
|
1415
|
+
}, /* @__PURE__ */ new Map());
|
|
1416
|
+
}, "sdJwtCredentialDisplayLocalesFrom");
|
|
1417
|
+
var sdJwtCredentialClaimLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1418
|
+
const { claimsMetadata } = args;
|
|
1419
|
+
const localeClaims = /* @__PURE__ */ new Map();
|
|
1420
|
+
claimsMetadata.forEach((claim) => {
|
|
1421
|
+
claim.display?.forEach((display) => {
|
|
1422
|
+
const { lang = "", label } = display;
|
|
1423
|
+
const key = claim.path.map((value) => String(value)).join(".");
|
|
1424
|
+
if (!localeClaims.has(lang)) {
|
|
1425
|
+
localeClaims.set(lang, []);
|
|
1485
1426
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1427
|
+
localeClaims.get(lang).push({
|
|
1428
|
+
key,
|
|
1429
|
+
name: label
|
|
1430
|
+
});
|
|
1431
|
+
});
|
|
1432
|
+
});
|
|
1433
|
+
return localeClaims;
|
|
1434
|
+
}, "sdJwtCredentialClaimLocalesFrom");
|
|
1435
|
+
var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1436
|
+
const { credentialDisplay } = args;
|
|
1437
|
+
return {
|
|
1438
|
+
...credentialDisplay.name && {
|
|
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
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
},
|
|
1454
|
+
...credentialDisplay.description && {
|
|
1455
|
+
description: credentialDisplay.description
|
|
1456
|
+
},
|
|
1457
|
+
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1458
|
+
text: {
|
|
1459
|
+
color: credentialDisplay.rendering.simple.text_color
|
|
1460
|
+
}
|
|
1461
|
+
},
|
|
1462
|
+
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1463
|
+
background: {
|
|
1464
|
+
color: credentialDisplay.rendering.simple.background_color
|
|
1511
1465
|
}
|
|
1512
|
-
}));
|
|
1513
|
-
if (typeof opts?.subscription === "function") {
|
|
1514
|
-
newInst.onTransition(opts.subscription);
|
|
1515
1466
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1467
|
+
};
|
|
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
|
|
1484
|
+
},
|
|
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;
|
|
@@ -2732,16 +2727,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2732
2727
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2733
2728
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2734
2729
|
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
|
-
}
|
|
2730
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
|
|
2745
2731
|
const wrappedIssuerVC = CredentialMapper2.toWrappedVerifiableCredential(issuerVC, {
|
|
2746
2732
|
hasher: this.hasher ?? defaultHasher2
|
|
2747
2733
|
});
|
|
@@ -3112,6 +3098,7 @@ export {
|
|
|
3112
3098
|
RequestType,
|
|
3113
3099
|
SupportedLanguage,
|
|
3114
3100
|
createConfig,
|
|
3101
|
+
extractCredentialFromResponse,
|
|
3115
3102
|
getBasicIssuerLocaleBranding,
|
|
3116
3103
|
getCredentialBranding,
|
|
3117
3104
|
getCredentialConfigsBasedOnFormatPref,
|