@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feat.SSISDK.35.64 → 0.34.1-feat.SSISDK.55.243
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 +427 -444
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +409 -426
- package/dist/index.js.map +1 -1
- package/package.json +24 -24
- package/src/agent/OID4VCIHolder.ts +17 -30
- package/src/machines/firstPartyMachine.ts +1 -1
- package/src/machines/oid4vciMachine.ts +1 -1
- package/src/mappers/OIDC4VCIBrandingMapper.ts +1 -1
- package/src/services/OID4VCIHolderService.ts +42 -63
- package/src/types/FirstPartyMachine.ts +5 -6
- package/src/types/IOID4VCIHolder.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -56,14 +56,16 @@ var require_nl = __commonJS({
|
|
|
56
56
|
|
|
57
57
|
// src/agent/OID4VCIHolder.ts
|
|
58
58
|
import { CredentialOfferClient, MetadataClient, OpenID4VCIClient as OpenID4VCIClient2 } from "@sphereon/oid4vci-client";
|
|
59
|
-
import { DefaultURISchemes,
|
|
59
|
+
import { DefaultURISchemes, getTypesFromObject as getTypesFromObject2 } from "@sphereon/oid4vci-common";
|
|
60
60
|
import { SupportedDidMethodEnum as SupportedDidMethodEnum2 } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
61
61
|
import { isManagedIdentifierDidOpts, isManagedIdentifierDidResult as isManagedIdentifierDidResult2, isManagedIdentifierJwkResult, isManagedIdentifierKidResult, isManagedIdentifierResult as isManagedIdentifierResult2, isManagedIdentifierX5cOpts, isManagedIdentifierX5cResult } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
62
62
|
import { signatureAlgorithmFromKey } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
63
63
|
import { defaultHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
64
|
+
import { ensureRawDocument } from "@sphereon/ssi-sdk.data-store-types";
|
|
65
|
+
import { ConnectionType, CorrelationIdentifierType, CredentialCorrelationType, IdentityOrigin } from "@sphereon/ssi-sdk.data-store-types";
|
|
66
|
+
import { CredentialMapper as CredentialMapper2, CredentialRole, JoseSignatureAlgorithm as JoseSignatureAlgorithm2, Loggers, parseDid } from "@sphereon/ssi-types";
|
|
66
67
|
import { asArray as asArray2, computeEntryHash } from "@veramo/utils";
|
|
68
|
+
import fetch from "cross-fetch";
|
|
67
69
|
import { decodeJWT } from "did-jwt";
|
|
68
70
|
import { v4 as uuidv42 } from "uuid";
|
|
69
71
|
|
|
@@ -978,14 +980,300 @@ var OID4VCIMachine = class {
|
|
|
978
980
|
|
|
979
981
|
// src/services/OID4VCIHolderService.ts
|
|
980
982
|
import { LOG } from "@sphereon/oid4vci-client";
|
|
981
|
-
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject
|
|
983
|
+
import { getSupportedCredentials, getTypesFromCredentialSupported, getTypesFromObject } from "@sphereon/oid4vci-common";
|
|
982
984
|
import { KeyUse } from "@sphereon/ssi-sdk-ext.did-resolver-jwk";
|
|
983
985
|
import { getOrCreatePrimaryIdentifier, SupportedDidMethodEnum } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
984
986
|
import { isIIdentifier, isManagedIdentifierDidResult, isManagedIdentifierResult, managedIdentifierToJwk } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
985
987
|
import { keyTypeFromCryptographicSuite } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
988
|
+
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
986
989
|
import { CredentialMapper, JoseSignatureAlgorithm, mdocDecodedCredentialToUniformCredential, sdJwtDecodedCredentialToUniformCredential } from "@sphereon/ssi-types";
|
|
987
990
|
import { asArray } from "@veramo/utils";
|
|
988
991
|
|
|
992
|
+
// src/machines/firstPartyMachine.ts
|
|
993
|
+
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
994
|
+
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
995
|
+
|
|
996
|
+
// src/services/FirstPartyMachineServices.ts
|
|
997
|
+
import { OpenID4VCIClient } from "@sphereon/oid4vci-client";
|
|
998
|
+
import { v4 as uuidv4 } from "uuid";
|
|
999
|
+
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
1000
|
+
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
1001
|
+
const oid4vciClient = await OpenID4VCIClient.fromState({
|
|
1002
|
+
state: openID4VCIClientState
|
|
1003
|
+
});
|
|
1004
|
+
return oid4vciClient.acquireAuthorizationChallengeCode({
|
|
1005
|
+
clientId: oid4vciClient.clientId ?? uuidv4(),
|
|
1006
|
+
...authSession && {
|
|
1007
|
+
authSession
|
|
1008
|
+
},
|
|
1009
|
+
...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
|
|
1010
|
+
issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
|
|
1011
|
+
},
|
|
1012
|
+
...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
|
|
1013
|
+
issuerState: openID4VCIClientState.credentialOffer?.issuerState
|
|
1014
|
+
},
|
|
1015
|
+
...presentationDuringIssuanceSession && {
|
|
1016
|
+
presentationDuringIssuanceSession
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
}, "sendAuthorizationChallengeRequest");
|
|
1020
|
+
var createConfig = /* @__PURE__ */ __name(async (args, context) => {
|
|
1021
|
+
const { presentationUri } = args;
|
|
1022
|
+
if (!presentationUri) {
|
|
1023
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1024
|
+
}
|
|
1025
|
+
return context.agent.siopCreateConfig({
|
|
1026
|
+
url: presentationUri
|
|
1027
|
+
});
|
|
1028
|
+
}, "createConfig");
|
|
1029
|
+
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1030
|
+
const { didAuthConfig, presentationUri } = args;
|
|
1031
|
+
if (presentationUri === void 0) {
|
|
1032
|
+
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1033
|
+
}
|
|
1034
|
+
if (didAuthConfig === void 0) {
|
|
1035
|
+
return Promise.reject(Error("Missing did auth config in context"));
|
|
1036
|
+
}
|
|
1037
|
+
return context.agent.siopGetSiopRequest({
|
|
1038
|
+
didAuthConfig,
|
|
1039
|
+
url: presentationUri
|
|
1040
|
+
});
|
|
1041
|
+
}, "getSiopRequest");
|
|
1042
|
+
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1043
|
+
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1044
|
+
const responseData = await context.agent.siopSendResponse({
|
|
1045
|
+
authorizationRequestData,
|
|
1046
|
+
selectedCredentials,
|
|
1047
|
+
didAuthConfig,
|
|
1048
|
+
isFirstParty: true
|
|
1049
|
+
});
|
|
1050
|
+
return responseData.body.presentation_during_issuance_session;
|
|
1051
|
+
}, "sendAuthorizationResponse");
|
|
1052
|
+
|
|
1053
|
+
// src/machines/firstPartyMachine.ts
|
|
1054
|
+
var firstPartyMachineStates = {
|
|
1055
|
+
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1056
|
+
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1057
|
+
invoke: {
|
|
1058
|
+
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1059
|
+
onDone: {
|
|
1060
|
+
target: FirstPartyMachineStateTypes.done,
|
|
1061
|
+
actions: assign2({
|
|
1062
|
+
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1063
|
+
})
|
|
1064
|
+
},
|
|
1065
|
+
onError: [
|
|
1066
|
+
{
|
|
1067
|
+
target: FirstPartyMachineStateTypes.createConfig,
|
|
1068
|
+
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1069
|
+
actions: assign2({
|
|
1070
|
+
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1071
|
+
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1072
|
+
})
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1076
|
+
actions: assign2({
|
|
1077
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1078
|
+
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1079
|
+
message: _event.data.message,
|
|
1080
|
+
stack: _event.data.stack
|
|
1081
|
+
}), "error")
|
|
1082
|
+
})
|
|
1083
|
+
}
|
|
1084
|
+
]
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1088
|
+
id: FirstPartyMachineStateTypes.createConfig,
|
|
1089
|
+
invoke: {
|
|
1090
|
+
src: FirstPartyMachineServices.createConfig,
|
|
1091
|
+
onDone: {
|
|
1092
|
+
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1093
|
+
actions: assign2({
|
|
1094
|
+
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1095
|
+
})
|
|
1096
|
+
},
|
|
1097
|
+
onError: {
|
|
1098
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1099
|
+
actions: assign2({
|
|
1100
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1101
|
+
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1102
|
+
message: _event.data.message,
|
|
1103
|
+
stack: _event.data.stack
|
|
1104
|
+
}), "error")
|
|
1105
|
+
})
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
},
|
|
1109
|
+
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1110
|
+
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1111
|
+
invoke: {
|
|
1112
|
+
src: FirstPartyMachineServices.getSiopRequest,
|
|
1113
|
+
onDone: {
|
|
1114
|
+
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1115
|
+
actions: assign2({
|
|
1116
|
+
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1117
|
+
})
|
|
1118
|
+
},
|
|
1119
|
+
onError: {
|
|
1120
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1121
|
+
actions: assign2({
|
|
1122
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1123
|
+
title: translate("siopV2_machine_get_request_error_title"),
|
|
1124
|
+
message: _event.data.message,
|
|
1125
|
+
stack: _event.data.stack
|
|
1126
|
+
}), "error")
|
|
1127
|
+
})
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
},
|
|
1131
|
+
[FirstPartyMachineStateTypes.selectCredentials]: {
|
|
1132
|
+
id: FirstPartyMachineStateTypes.selectCredentials,
|
|
1133
|
+
on: {
|
|
1134
|
+
[FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS]: {
|
|
1135
|
+
actions: assign2({
|
|
1136
|
+
selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
|
|
1137
|
+
})
|
|
1138
|
+
},
|
|
1139
|
+
[FirstPartyMachineEvents.NEXT]: {
|
|
1140
|
+
target: FirstPartyMachineStateTypes.sendAuthorizationResponse
|
|
1141
|
+
},
|
|
1142
|
+
[FirstPartyMachineEvents.DECLINE]: {
|
|
1143
|
+
target: FirstPartyMachineStateTypes.declined
|
|
1144
|
+
},
|
|
1145
|
+
[FirstPartyMachineEvents.PREVIOUS]: {
|
|
1146
|
+
target: FirstPartyMachineStateTypes.aborted
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
[FirstPartyMachineStateTypes.sendAuthorizationResponse]: {
|
|
1151
|
+
id: FirstPartyMachineStateTypes.sendAuthorizationResponse,
|
|
1152
|
+
invoke: {
|
|
1153
|
+
src: FirstPartyMachineServices.sendAuthorizationResponse,
|
|
1154
|
+
onDone: {
|
|
1155
|
+
target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1156
|
+
actions: assign2({
|
|
1157
|
+
presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
|
|
1158
|
+
})
|
|
1159
|
+
},
|
|
1160
|
+
onError: {
|
|
1161
|
+
target: FirstPartyMachineStateTypes.error,
|
|
1162
|
+
actions: assign2({
|
|
1163
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1164
|
+
title: translate("oid4vci_machine_get_request_error_title"),
|
|
1165
|
+
message: _event.data.message,
|
|
1166
|
+
stack: _event.data.stack
|
|
1167
|
+
}), "error")
|
|
1168
|
+
})
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1172
|
+
[FirstPartyMachineStateTypes.aborted]: {
|
|
1173
|
+
id: FirstPartyMachineStateTypes.aborted,
|
|
1174
|
+
type: "final"
|
|
1175
|
+
},
|
|
1176
|
+
[FirstPartyMachineStateTypes.declined]: {
|
|
1177
|
+
id: FirstPartyMachineStateTypes.declined,
|
|
1178
|
+
type: "final"
|
|
1179
|
+
},
|
|
1180
|
+
[FirstPartyMachineStateTypes.error]: {
|
|
1181
|
+
id: FirstPartyMachineStateTypes.error,
|
|
1182
|
+
type: "final"
|
|
1183
|
+
},
|
|
1184
|
+
[FirstPartyMachineStateTypes.done]: {
|
|
1185
|
+
id: FirstPartyMachineStateTypes.done,
|
|
1186
|
+
type: "final"
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
1190
|
+
const initialContext = {
|
|
1191
|
+
openID4VCIClientState: opts.openID4VCIClientState,
|
|
1192
|
+
contact: opts.contact,
|
|
1193
|
+
selectedCredentials: []
|
|
1194
|
+
};
|
|
1195
|
+
return createMachine2({
|
|
1196
|
+
id: opts?.machineId ?? "FirstParty",
|
|
1197
|
+
predictableActionArguments: true,
|
|
1198
|
+
initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1199
|
+
context: initialContext,
|
|
1200
|
+
states: firstPartyMachineStates,
|
|
1201
|
+
schema: {
|
|
1202
|
+
events: {},
|
|
1203
|
+
services: {}
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}, "createFirstPartyActivationMachine");
|
|
1207
|
+
var FirstPartyMachine = class _FirstPartyMachine {
|
|
1208
|
+
static {
|
|
1209
|
+
__name(this, "FirstPartyMachine");
|
|
1210
|
+
}
|
|
1211
|
+
static _instance;
|
|
1212
|
+
static hasInstance() {
|
|
1213
|
+
return _FirstPartyMachine._instance !== void 0;
|
|
1214
|
+
}
|
|
1215
|
+
static get instance() {
|
|
1216
|
+
if (!_FirstPartyMachine._instance) {
|
|
1217
|
+
throw Error("Please initialize ESIMActivation machine first");
|
|
1218
|
+
}
|
|
1219
|
+
return _FirstPartyMachine._instance;
|
|
1220
|
+
}
|
|
1221
|
+
static clearInstance(opts) {
|
|
1222
|
+
const { stop } = opts;
|
|
1223
|
+
if (_FirstPartyMachine.hasInstance()) {
|
|
1224
|
+
if (stop) {
|
|
1225
|
+
_FirstPartyMachine.stopInstance();
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
_FirstPartyMachine._instance = void 0;
|
|
1229
|
+
}
|
|
1230
|
+
static stopInstance() {
|
|
1231
|
+
if (!_FirstPartyMachine.hasInstance()) {
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
_FirstPartyMachine.instance.stop();
|
|
1235
|
+
_FirstPartyMachine._instance = void 0;
|
|
1236
|
+
}
|
|
1237
|
+
static newInstance(opts) {
|
|
1238
|
+
const { agentContext } = opts;
|
|
1239
|
+
const services = {
|
|
1240
|
+
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1241
|
+
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1242
|
+
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1243
|
+
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1244
|
+
};
|
|
1245
|
+
const newInst = interpret2(createFirstPartyActivationMachine(opts).withConfig({
|
|
1246
|
+
services: {
|
|
1247
|
+
...services,
|
|
1248
|
+
...opts?.services
|
|
1249
|
+
},
|
|
1250
|
+
guards: {
|
|
1251
|
+
...opts?.guards
|
|
1252
|
+
}
|
|
1253
|
+
}));
|
|
1254
|
+
if (typeof opts?.subscription === "function") {
|
|
1255
|
+
newInst.onTransition(opts.subscription);
|
|
1256
|
+
}
|
|
1257
|
+
if (opts?.requireCustomNavigationHook !== true) {
|
|
1258
|
+
newInst.onTransition((snapshot) => {
|
|
1259
|
+
if (opts?.stateNavigationListener) {
|
|
1260
|
+
void opts.stateNavigationListener(newInst, snapshot);
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
return newInst;
|
|
1265
|
+
}
|
|
1266
|
+
static getInstance(opts) {
|
|
1267
|
+
if (!_FirstPartyMachine._instance) {
|
|
1268
|
+
if (opts?.requireExisting === true) {
|
|
1269
|
+
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`);
|
|
1270
|
+
}
|
|
1271
|
+
_FirstPartyMachine._instance = _FirstPartyMachine.newInstance(opts);
|
|
1272
|
+
}
|
|
1273
|
+
return _FirstPartyMachine._instance;
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
|
|
989
1277
|
// src/mappers/OIDC4VCIBrandingMapper.ts
|
|
990
1278
|
var oid4vciGetCredentialBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
991
1279
|
const { credentialDisplay, issuerCredentialSubject } = args;
|
|
@@ -1151,390 +1439,104 @@ var sdJwtCredentialLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
|
1151
1439
|
return {
|
|
1152
1440
|
...credentialDisplay.name && {
|
|
1153
1441
|
alias: credentialDisplay.name
|
|
1154
|
-
},
|
|
1155
|
-
...credentialDisplay.lang && {
|
|
1156
|
-
locale: credentialDisplay.lang
|
|
1157
|
-
},
|
|
1158
|
-
...credentialDisplay.rendering?.simple?.logo && {
|
|
1159
|
-
logo: {
|
|
1160
|
-
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1161
|
-
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1162
|
-
},
|
|
1163
|
-
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1164
|
-
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
...credentialDisplay.description && {
|
|
1169
|
-
description: credentialDisplay.description
|
|
1170
|
-
},
|
|
1171
|
-
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1172
|
-
text: {
|
|
1173
|
-
color: credentialDisplay.rendering.simple.text_color
|
|
1174
|
-
}
|
|
1175
|
-
},
|
|
1176
|
-
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1177
|
-
background: {
|
|
1178
|
-
color: credentialDisplay.rendering.simple.background_color
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
};
|
|
1182
|
-
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1183
|
-
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1184
|
-
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1185
|
-
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1186
|
-
...claimsMetadata.keys(),
|
|
1187
|
-
...credentialDisplayLocales.keys()
|
|
1188
|
-
]));
|
|
1189
|
-
return Promise.all(locales.map(async (locale) => {
|
|
1190
|
-
const display = credentialDisplayLocales.get(locale);
|
|
1191
|
-
const claims = claimsMetadata.get(locale);
|
|
1192
|
-
return {
|
|
1193
|
-
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1194
|
-
credentialDisplay: display
|
|
1195
|
-
}),
|
|
1196
|
-
...locale.length > 0 && {
|
|
1197
|
-
locale
|
|
1198
|
-
},
|
|
1199
|
-
claims
|
|
1200
|
-
};
|
|
1201
|
-
}));
|
|
1202
|
-
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1203
|
-
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1204
|
-
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1205
|
-
return {
|
|
1206
|
-
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1207
|
-
alias: dynamicRegistrationClientMetadata.client_name
|
|
1208
|
-
},
|
|
1209
|
-
...issuerDisplay.name && {
|
|
1210
|
-
alias: issuerDisplay.name
|
|
1211
|
-
},
|
|
1212
|
-
...issuerDisplay.locale && {
|
|
1213
|
-
locale: issuerDisplay.locale
|
|
1214
|
-
},
|
|
1215
|
-
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1216
|
-
logo: {
|
|
1217
|
-
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1218
|
-
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1219
|
-
},
|
|
1220
|
-
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1221
|
-
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1222
|
-
},
|
|
1223
|
-
...issuerDisplay.logo?.alt_text && {
|
|
1224
|
-
alt: issuerDisplay.logo?.alt_text
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
},
|
|
1228
|
-
...issuerDisplay.description && {
|
|
1229
|
-
description: issuerDisplay.description
|
|
1230
|
-
},
|
|
1231
|
-
...issuerDisplay.text_color && {
|
|
1232
|
-
text: {
|
|
1233
|
-
color: issuerDisplay.text_color
|
|
1234
|
-
}
|
|
1235
|
-
},
|
|
1236
|
-
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1237
|
-
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1238
|
-
},
|
|
1239
|
-
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1240
|
-
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1241
|
-
},
|
|
1242
|
-
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1243
|
-
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1244
|
-
},
|
|
1245
|
-
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1246
|
-
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
}, "issuerLocaleBrandingFrom");
|
|
1250
|
-
|
|
1251
|
-
// src/machines/firstPartyMachine.ts
|
|
1252
|
-
import { assign as assign2, createMachine as createMachine2, interpret as interpret2 } from "xstate";
|
|
1253
|
-
import { AuthorizationChallengeError } from "@sphereon/oid4vci-common";
|
|
1254
|
-
|
|
1255
|
-
// src/services/FirstPartyMachineServices.ts
|
|
1256
|
-
import { OpenID4VCIClient } from "@sphereon/oid4vci-client";
|
|
1257
|
-
import { v4 as uuidv4 } from "uuid";
|
|
1258
|
-
var sendAuthorizationChallengeRequest = /* @__PURE__ */ __name(async (args) => {
|
|
1259
|
-
const { openID4VCIClientState, authSession, presentationDuringIssuanceSession } = args;
|
|
1260
|
-
const oid4vciClient = await OpenID4VCIClient.fromState({
|
|
1261
|
-
state: openID4VCIClientState
|
|
1262
|
-
});
|
|
1263
|
-
return oid4vciClient.acquireAuthorizationChallengeCode({
|
|
1264
|
-
clientId: oid4vciClient.clientId ?? uuidv4(),
|
|
1265
|
-
...authSession && {
|
|
1266
|
-
authSession
|
|
1267
|
-
},
|
|
1268
|
-
...!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && {
|
|
1269
|
-
issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode
|
|
1270
|
-
},
|
|
1271
|
-
...!authSession && openID4VCIClientState.credentialOffer?.issuerState && {
|
|
1272
|
-
issuerState: openID4VCIClientState.credentialOffer?.issuerState
|
|
1273
|
-
},
|
|
1274
|
-
...presentationDuringIssuanceSession && {
|
|
1275
|
-
presentationDuringIssuanceSession
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
}, "sendAuthorizationChallengeRequest");
|
|
1279
|
-
var createConfig = /* @__PURE__ */ __name(async (args, context) => {
|
|
1280
|
-
const { presentationUri } = args;
|
|
1281
|
-
if (!presentationUri) {
|
|
1282
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1283
|
-
}
|
|
1284
|
-
return context.agent.siopCreateConfig({
|
|
1285
|
-
url: presentationUri
|
|
1286
|
-
});
|
|
1287
|
-
}, "createConfig");
|
|
1288
|
-
var getSiopRequest = /* @__PURE__ */ __name(async (args, context) => {
|
|
1289
|
-
const { didAuthConfig, presentationUri } = args;
|
|
1290
|
-
if (presentationUri === void 0) {
|
|
1291
|
-
return Promise.reject(Error("Missing presentation uri in context"));
|
|
1292
|
-
}
|
|
1293
|
-
if (didAuthConfig === void 0) {
|
|
1294
|
-
return Promise.reject(Error("Missing did auth config in context"));
|
|
1295
|
-
}
|
|
1296
|
-
return context.agent.siopGetSiopRequest({
|
|
1297
|
-
didAuthConfig,
|
|
1298
|
-
url: presentationUri
|
|
1299
|
-
});
|
|
1300
|
-
}, "getSiopRequest");
|
|
1301
|
-
var sendAuthorizationResponse = /* @__PURE__ */ __name(async (args, context) => {
|
|
1302
|
-
const { didAuthConfig, authorizationRequestData, selectedCredentials } = args;
|
|
1303
|
-
const responseData = await context.agent.siopSendResponse({
|
|
1304
|
-
authorizationRequestData,
|
|
1305
|
-
selectedCredentials,
|
|
1306
|
-
didAuthConfig,
|
|
1307
|
-
isFirstParty: true
|
|
1308
|
-
});
|
|
1309
|
-
return responseData.body.presentation_during_issuance_session;
|
|
1310
|
-
}, "sendAuthorizationResponse");
|
|
1311
|
-
|
|
1312
|
-
// src/machines/firstPartyMachine.ts
|
|
1313
|
-
var firstPartyMachineStates = {
|
|
1314
|
-
[FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest]: {
|
|
1315
|
-
id: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1316
|
-
invoke: {
|
|
1317
|
-
src: FirstPartyMachineServices.sendAuthorizationChallengeRequest,
|
|
1318
|
-
onDone: {
|
|
1319
|
-
target: FirstPartyMachineStateTypes.done,
|
|
1320
|
-
actions: assign2({
|
|
1321
|
-
authorizationCodeResponse: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationCodeResponse")
|
|
1322
|
-
})
|
|
1323
|
-
},
|
|
1324
|
-
onError: [
|
|
1325
|
-
{
|
|
1326
|
-
target: FirstPartyMachineStateTypes.createConfig,
|
|
1327
|
-
cond: /* @__PURE__ */ __name((_ctx, _event) => _event.data.error === AuthorizationChallengeError.insufficient_authorization, "cond"),
|
|
1328
|
-
actions: assign2({
|
|
1329
|
-
authSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data.auth_session, "authSession"),
|
|
1330
|
-
presentationUri: /* @__PURE__ */ __name((_ctx, _event) => _event.data.presentation, "presentationUri")
|
|
1331
|
-
})
|
|
1332
|
-
},
|
|
1333
|
-
{
|
|
1334
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1335
|
-
actions: assign2({
|
|
1336
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1337
|
-
title: translate("oid4vci_machine_send_authorization_challenge_request_error_title"),
|
|
1338
|
-
message: _event.data.message,
|
|
1339
|
-
stack: _event.data.stack
|
|
1340
|
-
}), "error")
|
|
1341
|
-
})
|
|
1342
|
-
}
|
|
1343
|
-
]
|
|
1344
|
-
}
|
|
1345
|
-
},
|
|
1346
|
-
[FirstPartyMachineStateTypes.createConfig]: {
|
|
1347
|
-
id: FirstPartyMachineStateTypes.createConfig,
|
|
1348
|
-
invoke: {
|
|
1349
|
-
src: FirstPartyMachineServices.createConfig,
|
|
1350
|
-
onDone: {
|
|
1351
|
-
target: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1352
|
-
actions: assign2({
|
|
1353
|
-
didAuthConfig: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "didAuthConfig")
|
|
1354
|
-
})
|
|
1355
|
-
},
|
|
1356
|
-
onError: {
|
|
1357
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1358
|
-
actions: assign2({
|
|
1359
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1360
|
-
title: translate("oid4vci_machine_create_config_error_title"),
|
|
1361
|
-
message: _event.data.message,
|
|
1362
|
-
stack: _event.data.stack
|
|
1363
|
-
}), "error")
|
|
1364
|
-
})
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
},
|
|
1368
|
-
[FirstPartyMachineStateTypes.getSiopRequest]: {
|
|
1369
|
-
id: FirstPartyMachineStateTypes.getSiopRequest,
|
|
1370
|
-
invoke: {
|
|
1371
|
-
src: FirstPartyMachineServices.getSiopRequest,
|
|
1372
|
-
onDone: {
|
|
1373
|
-
target: FirstPartyMachineStateTypes.selectCredentials,
|
|
1374
|
-
actions: assign2({
|
|
1375
|
-
authorizationRequestData: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "authorizationRequestData")
|
|
1376
|
-
})
|
|
1377
|
-
},
|
|
1378
|
-
onError: {
|
|
1379
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1380
|
-
actions: assign2({
|
|
1381
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1382
|
-
title: translate("siopV2_machine_get_request_error_title"),
|
|
1383
|
-
message: _event.data.message,
|
|
1384
|
-
stack: _event.data.stack
|
|
1385
|
-
}), "error")
|
|
1386
|
-
})
|
|
1442
|
+
},
|
|
1443
|
+
...credentialDisplay.lang && {
|
|
1444
|
+
locale: credentialDisplay.lang
|
|
1445
|
+
},
|
|
1446
|
+
...credentialDisplay.rendering?.simple?.logo && {
|
|
1447
|
+
logo: {
|
|
1448
|
+
...credentialDisplay.rendering.simple.logo.uri && {
|
|
1449
|
+
uri: credentialDisplay.rendering.simple.logo.uri
|
|
1450
|
+
},
|
|
1451
|
+
...credentialDisplay.rendering.simple.logo.alt_text && {
|
|
1452
|
+
alt: credentialDisplay.rendering.simple.logo.alt_text
|
|
1453
|
+
}
|
|
1387
1454
|
}
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
selectedCredentials: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "selectedCredentials")
|
|
1396
|
-
})
|
|
1397
|
-
},
|
|
1398
|
-
[FirstPartyMachineEvents.NEXT]: {
|
|
1399
|
-
target: FirstPartyMachineStateTypes.sendAuthorizationResponse
|
|
1400
|
-
},
|
|
1401
|
-
[FirstPartyMachineEvents.DECLINE]: {
|
|
1402
|
-
target: FirstPartyMachineStateTypes.declined
|
|
1403
|
-
},
|
|
1404
|
-
[FirstPartyMachineEvents.PREVIOUS]: {
|
|
1405
|
-
target: FirstPartyMachineStateTypes.aborted
|
|
1455
|
+
},
|
|
1456
|
+
...credentialDisplay.description && {
|
|
1457
|
+
description: credentialDisplay.description
|
|
1458
|
+
},
|
|
1459
|
+
...credentialDisplay.rendering?.simple?.text_color && {
|
|
1460
|
+
text: {
|
|
1461
|
+
color: credentialDisplay.rendering.simple.text_color
|
|
1406
1462
|
}
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
invoke: {
|
|
1412
|
-
src: FirstPartyMachineServices.sendAuthorizationResponse,
|
|
1413
|
-
onDone: {
|
|
1414
|
-
target: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
1415
|
-
actions: assign2({
|
|
1416
|
-
presentationDuringIssuanceSession: /* @__PURE__ */ __name((_ctx, _event) => _event.data, "presentationDuringIssuanceSession")
|
|
1417
|
-
})
|
|
1418
|
-
},
|
|
1419
|
-
onError: {
|
|
1420
|
-
target: FirstPartyMachineStateTypes.error,
|
|
1421
|
-
actions: assign2({
|
|
1422
|
-
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
1423
|
-
title: translate("oid4vci_machine_get_request_error_title"),
|
|
1424
|
-
message: _event.data.message,
|
|
1425
|
-
stack: _event.data.stack
|
|
1426
|
-
}), "error")
|
|
1427
|
-
})
|
|
1463
|
+
},
|
|
1464
|
+
...credentialDisplay.rendering?.simple?.background_color && {
|
|
1465
|
+
background: {
|
|
1466
|
+
color: credentialDisplay.rendering.simple.background_color
|
|
1428
1467
|
}
|
|
1429
1468
|
}
|
|
1430
|
-
},
|
|
1431
|
-
[FirstPartyMachineStateTypes.aborted]: {
|
|
1432
|
-
id: FirstPartyMachineStateTypes.aborted,
|
|
1433
|
-
type: "final"
|
|
1434
|
-
},
|
|
1435
|
-
[FirstPartyMachineStateTypes.declined]: {
|
|
1436
|
-
id: FirstPartyMachineStateTypes.declined,
|
|
1437
|
-
type: "final"
|
|
1438
|
-
},
|
|
1439
|
-
[FirstPartyMachineStateTypes.error]: {
|
|
1440
|
-
id: FirstPartyMachineStateTypes.error,
|
|
1441
|
-
type: "final"
|
|
1442
|
-
},
|
|
1443
|
-
[FirstPartyMachineStateTypes.done]: {
|
|
1444
|
-
id: FirstPartyMachineStateTypes.done,
|
|
1445
|
-
type: "final"
|
|
1446
|
-
}
|
|
1447
|
-
};
|
|
1448
|
-
var createFirstPartyActivationMachine = /* @__PURE__ */ __name((opts) => {
|
|
1449
|
-
const initialContext = {
|
|
1450
|
-
openID4VCIClientState: opts.openID4VCIClientState,
|
|
1451
|
-
contact: opts.contact,
|
|
1452
|
-
selectedCredentials: []
|
|
1453
1469
|
};
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
static _instance;
|
|
1471
|
-
static hasInstance() {
|
|
1472
|
-
return _FirstPartyMachine._instance !== void 0;
|
|
1473
|
-
}
|
|
1474
|
-
static get instance() {
|
|
1475
|
-
if (!_FirstPartyMachine._instance) {
|
|
1476
|
-
throw Error("Please initialize ESIMActivation machine first");
|
|
1477
|
-
}
|
|
1478
|
-
return _FirstPartyMachine._instance;
|
|
1479
|
-
}
|
|
1480
|
-
static clearInstance(opts) {
|
|
1481
|
-
const { stop } = opts;
|
|
1482
|
-
if (_FirstPartyMachine.hasInstance()) {
|
|
1483
|
-
if (stop) {
|
|
1484
|
-
_FirstPartyMachine.stopInstance();
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
_FirstPartyMachine._instance = void 0;
|
|
1488
|
-
}
|
|
1489
|
-
static stopInstance() {
|
|
1490
|
-
if (!_FirstPartyMachine.hasInstance()) {
|
|
1491
|
-
return;
|
|
1492
|
-
}
|
|
1493
|
-
_FirstPartyMachine.instance.stop();
|
|
1494
|
-
_FirstPartyMachine._instance = void 0;
|
|
1495
|
-
}
|
|
1496
|
-
static newInstance(opts) {
|
|
1497
|
-
const { agentContext } = opts;
|
|
1498
|
-
const services = {
|
|
1499
|
-
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: sendAuthorizationChallengeRequest,
|
|
1500
|
-
[FirstPartyMachineServices.createConfig]: (args) => createConfig(args, agentContext),
|
|
1501
|
-
[FirstPartyMachineServices.getSiopRequest]: (args) => getSiopRequest(args, agentContext),
|
|
1502
|
-
[FirstPartyMachineServices.sendAuthorizationResponse]: (args) => sendAuthorizationResponse(args, agentContext)
|
|
1503
|
-
};
|
|
1504
|
-
const newInst = interpret2(createFirstPartyActivationMachine(opts).withConfig({
|
|
1505
|
-
services: {
|
|
1506
|
-
...services,
|
|
1507
|
-
...opts?.services
|
|
1470
|
+
}, "sdJwtCredentialLocaleBrandingFrom");
|
|
1471
|
+
var sdJwtCombineDisplayLocalesFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1472
|
+
const { credentialDisplayLocales = /* @__PURE__ */ new Map(), claimsMetadata = /* @__PURE__ */ new Map() } = args;
|
|
1473
|
+
const locales = Array.from(/* @__PURE__ */ new Set([
|
|
1474
|
+
...claimsMetadata.keys(),
|
|
1475
|
+
...credentialDisplayLocales.keys()
|
|
1476
|
+
]));
|
|
1477
|
+
return Promise.all(locales.map(async (locale) => {
|
|
1478
|
+
const display = credentialDisplayLocales.get(locale);
|
|
1479
|
+
const claims = claimsMetadata.get(locale);
|
|
1480
|
+
return {
|
|
1481
|
+
...display && await sdJwtCredentialLocaleBrandingFrom({
|
|
1482
|
+
credentialDisplay: display
|
|
1483
|
+
}),
|
|
1484
|
+
...locale.length > 0 && {
|
|
1485
|
+
locale
|
|
1508
1486
|
},
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1487
|
+
claims
|
|
1488
|
+
};
|
|
1489
|
+
}));
|
|
1490
|
+
}, "sdJwtCombineDisplayLocalesFrom");
|
|
1491
|
+
var issuerLocaleBrandingFrom = /* @__PURE__ */ __name(async (args) => {
|
|
1492
|
+
const { issuerDisplay, dynamicRegistrationClientMetadata } = args;
|
|
1493
|
+
return {
|
|
1494
|
+
...dynamicRegistrationClientMetadata?.client_name && {
|
|
1495
|
+
alias: dynamicRegistrationClientMetadata.client_name
|
|
1496
|
+
},
|
|
1497
|
+
...issuerDisplay.name && {
|
|
1498
|
+
alias: issuerDisplay.name
|
|
1499
|
+
},
|
|
1500
|
+
...issuerDisplay.locale && {
|
|
1501
|
+
locale: issuerDisplay.locale
|
|
1502
|
+
},
|
|
1503
|
+
...(issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
|
|
1504
|
+
logo: {
|
|
1505
|
+
...dynamicRegistrationClientMetadata?.logo_uri && {
|
|
1506
|
+
uri: dynamicRegistrationClientMetadata?.logo_uri
|
|
1507
|
+
},
|
|
1508
|
+
...(issuerDisplay.logo?.url || issuerDisplay.logo?.uri) && {
|
|
1509
|
+
uri: issuerDisplay.logo?.url ?? issuerDisplay.logo?.uri
|
|
1510
|
+
},
|
|
1511
|
+
...issuerDisplay.logo?.alt_text && {
|
|
1512
|
+
alt: issuerDisplay.logo?.alt_text
|
|
1520
1513
|
}
|
|
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
1514
|
}
|
|
1530
|
-
|
|
1515
|
+
},
|
|
1516
|
+
...issuerDisplay.description && {
|
|
1517
|
+
description: issuerDisplay.description
|
|
1518
|
+
},
|
|
1519
|
+
...issuerDisplay.text_color && {
|
|
1520
|
+
text: {
|
|
1521
|
+
color: issuerDisplay.text_color
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
...dynamicRegistrationClientMetadata?.client_uri && {
|
|
1525
|
+
clientUri: dynamicRegistrationClientMetadata.client_uri
|
|
1526
|
+
},
|
|
1527
|
+
...dynamicRegistrationClientMetadata?.tos_uri && {
|
|
1528
|
+
tosUri: dynamicRegistrationClientMetadata.tos_uri
|
|
1529
|
+
},
|
|
1530
|
+
...dynamicRegistrationClientMetadata?.policy_uri && {
|
|
1531
|
+
policyUri: dynamicRegistrationClientMetadata.policy_uri
|
|
1532
|
+
},
|
|
1533
|
+
...dynamicRegistrationClientMetadata?.contacts && {
|
|
1534
|
+
contacts: dynamicRegistrationClientMetadata.contacts
|
|
1531
1535
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
};
|
|
1536
|
+
};
|
|
1537
|
+
}, "issuerLocaleBrandingFrom");
|
|
1535
1538
|
|
|
1536
1539
|
// src/services/OID4VCIHolderService.ts
|
|
1537
|
-
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
1538
1540
|
var getCredentialBranding = /* @__PURE__ */ __name(async (args) => {
|
|
1539
1541
|
const { credentialsSupported, context } = args;
|
|
1540
1542
|
const credentialBranding = {};
|
|
@@ -1606,16 +1608,7 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
|
|
|
1606
1608
|
}, "selectCredentialLocaleBranding");
|
|
1607
1609
|
var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1608
1610
|
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
|
-
}
|
|
1611
|
+
const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse);
|
|
1619
1612
|
const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credential, {
|
|
1620
1613
|
hasher: hasher ?? defaultHasher
|
|
1621
1614
|
});
|
|
@@ -1667,16 +1660,7 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1667
1660
|
}, "verifyCredentialToAccept");
|
|
1668
1661
|
var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1669
1662
|
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
|
-
}
|
|
1663
|
+
const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse);
|
|
1680
1664
|
const wrappedVerifiableCredential = CredentialMapper.toWrappedVerifiableCredential(verifiableCredential, {
|
|
1681
1665
|
hasher
|
|
1682
1666
|
});
|
|
@@ -1696,6 +1680,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1696
1680
|
uniformVerifiableCredential = wrappedVerifiableCredential.credential;
|
|
1697
1681
|
}
|
|
1698
1682
|
const correlationId = typeof uniformVerifiableCredential.issuer === "string" ? uniformVerifiableCredential.issuer : CredentialMapper.isSdJwtDecodedCredential(uniformVerifiableCredential) ? uniformVerifiableCredential.decodedPayload.iss : uniformVerifiableCredential.issuer.id;
|
|
1683
|
+
const credentialResponse = credentialToAccept.credentialResponse;
|
|
1699
1684
|
return {
|
|
1700
1685
|
correlationId,
|
|
1701
1686
|
credentialToAccept,
|
|
@@ -1707,6 +1692,18 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1707
1692
|
}
|
|
1708
1693
|
};
|
|
1709
1694
|
}, "mapCredentialToAccept");
|
|
1695
|
+
var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse) => {
|
|
1696
|
+
let credential;
|
|
1697
|
+
if ("credential" in credentialResponse) {
|
|
1698
|
+
credential = credentialResponse.credential;
|
|
1699
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1700
|
+
credential = credentialResponse.credentials[0].credential;
|
|
1701
|
+
}
|
|
1702
|
+
if (!credential) {
|
|
1703
|
+
throw new Error("No credential found in credential response");
|
|
1704
|
+
}
|
|
1705
|
+
return credential;
|
|
1706
|
+
}, "extractCredentialFromResponse");
|
|
1710
1707
|
var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
1711
1708
|
const { issuanceOpt, context } = args;
|
|
1712
1709
|
const { identifier: identifierArg } = issuanceOpt;
|
|
@@ -1815,24 +1812,19 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
|
|
|
1815
1812
|
}
|
|
1816
1813
|
__name(createIdFromTypes, "createIdFromTypes");
|
|
1817
1814
|
if (configurationId) {
|
|
1818
|
-
const allSupported2 = client.getCredentialsSupported(
|
|
1815
|
+
const allSupported2 = client.getCredentialsSupported(format);
|
|
1819
1816
|
return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
|
|
1820
1817
|
}
|
|
1821
|
-
if (!
|
|
1822
|
-
return Promise.reject(Error("openID4VCIClient has no credentialOffer
|
|
1818
|
+
if (!client.credentialOffer) {
|
|
1819
|
+
return Promise.reject(Error("openID4VCIClient has no credentialOffer"));
|
|
1823
1820
|
}
|
|
1824
|
-
if (!
|
|
1825
|
-
|
|
1826
|
-
format = client.credentialOffer.credential_offer.credentials.filter((cred) => typeof cred !== "string").map((cred) => cred.format);
|
|
1827
|
-
if (format?.length === 0) {
|
|
1828
|
-
format = void 0;
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1821
|
+
if (!types) {
|
|
1822
|
+
return Promise.reject(Error("openID4VCIClient has no types"));
|
|
1831
1823
|
}
|
|
1832
1824
|
const offerSupported = getSupportedCredentials({
|
|
1833
|
-
types:
|
|
1825
|
+
types: [
|
|
1834
1826
|
types
|
|
1835
|
-
]
|
|
1827
|
+
],
|
|
1836
1828
|
format,
|
|
1837
1829
|
version: client.version(),
|
|
1838
1830
|
issuerMetadata: client.endpointMetadata.credentialIssuerMetadata
|
|
@@ -2007,7 +1999,7 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
|
|
|
2007
1999
|
case "jwt":
|
|
2008
2000
|
case "jwt_vc_json":
|
|
2009
2001
|
case "jwt_vc":
|
|
2010
|
-
case
|
|
2002
|
+
//case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
2011
2003
|
case "dc+sd-jwt":
|
|
2012
2004
|
case "mso_mdoc": {
|
|
2013
2005
|
const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
|
|
@@ -2076,7 +2068,6 @@ var startFirstPartApplicationMachine = /* @__PURE__ */ __name(async (args, conte
|
|
|
2076
2068
|
}, "startFirstPartApplicationMachine");
|
|
2077
2069
|
|
|
2078
2070
|
// src/agent/OID4VCIHolder.ts
|
|
2079
|
-
import "cross-fetch/polyfill";
|
|
2080
2071
|
var oid4vciHolderContextMethods = [
|
|
2081
2072
|
"cmGetContacts",
|
|
2082
2073
|
"cmGetContact",
|
|
@@ -2297,7 +2288,6 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2297
2288
|
formats = Array.from(new Set(authFormats));
|
|
2298
2289
|
}
|
|
2299
2290
|
let oid4vciClient;
|
|
2300
|
-
let types = void 0;
|
|
2301
2291
|
let offer;
|
|
2302
2292
|
if (requestData.existingClientState) {
|
|
2303
2293
|
oid4vciClient = await OpenID4VCIClient2.fromState({
|
|
@@ -2333,17 +2323,18 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2333
2323
|
});
|
|
2334
2324
|
}
|
|
2335
2325
|
}
|
|
2326
|
+
let configurationIds = [];
|
|
2336
2327
|
if (offer) {
|
|
2337
|
-
|
|
2328
|
+
configurationIds = offer.original_credential_offer.credential_configuration_ids;
|
|
2338
2329
|
} else {
|
|
2339
|
-
|
|
2330
|
+
configurationIds = asArray2(authorizationRequestOpts.authorizationDetails).filter((authDetails) => typeof authDetails !== "string").map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
|
|
2340
2331
|
}
|
|
2341
|
-
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2342
2332
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
2343
2333
|
client: oid4vciClient,
|
|
2344
2334
|
vcFormatPreferences: formats,
|
|
2345
|
-
|
|
2335
|
+
configurationIds
|
|
2346
2336
|
});
|
|
2337
|
+
const serverMetadata = await oid4vciClient.retrieveServerMetadata();
|
|
2347
2338
|
const credentialBranding = await getCredentialBranding({
|
|
2348
2339
|
credentialsSupported,
|
|
2349
2340
|
context
|
|
@@ -2732,16 +2723,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2732
2723
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2733
2724
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2734
2725
|
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
|
-
}
|
|
2726
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse);
|
|
2745
2727
|
const wrappedIssuerVC = CredentialMapper2.toWrappedVerifiableCredential(issuerVC, {
|
|
2746
2728
|
hasher: this.hasher ?? defaultHasher2
|
|
2747
2729
|
});
|
|
@@ -3112,6 +3094,7 @@ export {
|
|
|
3112
3094
|
RequestType,
|
|
3113
3095
|
SupportedLanguage,
|
|
3114
3096
|
createConfig,
|
|
3097
|
+
extractCredentialFromResponse,
|
|
3115
3098
|
getBasicIssuerLocaleBranding,
|
|
3116
3099
|
getCredentialBranding,
|
|
3117
3100
|
getCredentialConfigsBasedOnFormatPref,
|