@eudiplo/sdk-core 4.4.0 → 4.5.0

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.js CHANGED
@@ -27,10 +27,7 @@ var formDataBodySerializer = {
27
27
  }
28
28
  };
29
29
  var jsonBodySerializer = {
30
- bodySerializer: (body) => JSON.stringify(
31
- body,
32
- (_key, value) => typeof value === "bigint" ? value.toString() : value
33
- )
30
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
34
31
  };
35
32
 
36
33
  // src/api/core/serverSentEvents.gen.ts
@@ -74,10 +71,7 @@ function createSseClient({
74
71
  }
75
72
  const _fetch = options.fetch ?? globalThis.fetch;
76
73
  const response = await _fetch(request);
77
- if (!response.ok)
78
- throw new Error(
79
- `SSE failed: ${response.status} ${response.statusText}`
80
- );
74
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
81
75
  if (!response.body) throw new Error("No body in SSE response");
82
76
  const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
83
77
  let buffer = "";
@@ -108,10 +102,7 @@ function createSseClient({
108
102
  } else if (line.startsWith("id:")) {
109
103
  lastEventId = line.replace(/^id:\s*/, "");
110
104
  } else if (line.startsWith("retry:")) {
111
- const parsed = Number.parseInt(
112
- line.replace(/^retry:\s*/, ""),
113
- 10
114
- );
105
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
115
106
  if (!Number.isNaN(parsed)) {
116
107
  retryDelay = parsed;
117
108
  }
@@ -157,10 +148,7 @@ function createSseClient({
157
148
  if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
158
149
  break;
159
150
  }
160
- const backoff = Math.min(
161
- retryDelay * 2 ** (attempt - 1),
162
- sseMaxRetryDelay ?? 3e4
163
- );
151
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
164
152
  await sleep(backoff);
165
153
  }
166
154
  }
@@ -268,11 +256,7 @@ var serializeObjectParam = ({
268
256
  if (style !== "deepObject" && !explode) {
269
257
  let values = [];
270
258
  Object.entries(value).forEach(([key, v]) => {
271
- values = [
272
- ...values,
273
- key,
274
- allowReserved ? v : encodeURIComponent(v)
275
- ];
259
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
276
260
  });
277
261
  const joinedValues2 = values.join(",");
278
262
  switch (style) {
@@ -323,10 +307,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
323
307
  continue;
324
308
  }
325
309
  if (Array.isArray(value)) {
326
- url = url.replace(
327
- match,
328
- serializeArrayParam({ explode, name, style, value })
329
- );
310
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
330
311
  continue;
331
312
  }
332
313
  if (typeof value === "object") {
@@ -474,9 +455,7 @@ var getParseAs = (contentType) => {
474
455
  if (cleanContent === "multipart/form-data") {
475
456
  return "formData";
476
457
  }
477
- if (["application/", "audio/", "image/", "video/"].some(
478
- (type) => cleanContent.startsWith(type)
479
- )) {
458
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
480
459
  return "blob";
481
460
  }
482
461
  if (cleanContent.startsWith("text/")) {
@@ -493,11 +472,8 @@ var checkForExistence = (options, name) => {
493
472
  }
494
473
  return false;
495
474
  };
496
- var setAuthParams = async ({
497
- security,
498
- ...options
499
- }) => {
500
- for (const auth of security) {
475
+ async function setAuthParams(options) {
476
+ for (const auth of options.security ?? []) {
501
477
  if (checkForExistence(options, auth.name)) {
502
478
  continue;
503
479
  }
@@ -522,7 +498,7 @@ var setAuthParams = async ({
522
498
  break;
523
499
  }
524
500
  }
525
- };
501
+ }
526
502
  var buildUrl = (options) => getUrl({
527
503
  baseUrl: options.baseUrl,
528
504
  path: options.path,
@@ -648,10 +624,7 @@ var createClient = (config = {}) => {
648
624
  serializedBody: void 0
649
625
  };
650
626
  if (opts.security) {
651
- await setAuthParams({
652
- ...opts,
653
- security: opts.security
654
- });
627
+ await setAuthParams(opts);
655
628
  }
656
629
  if (opts.requestValidator) {
657
630
  await opts.requestValidator(opts);
@@ -764,12 +737,7 @@ var createClient = (config = {}) => {
764
737
  let finalError = error;
765
738
  for (const fn of interceptors.error.fns) {
766
739
  if (fn) {
767
- finalError = await fn(
768
- finalError,
769
- response,
770
- request2,
771
- options
772
- );
740
+ finalError = await fn(finalError, response, request2, options);
773
741
  }
774
742
  }
775
743
  finalError = finalError || {};
@@ -834,9 +802,7 @@ var createClient = (config = {}) => {
834
802
  };
835
803
 
836
804
  // src/api/client.gen.ts
837
- var client = createClient(
838
- createConfig({ throwOnError: true })
839
- );
805
+ var client = createClient(createConfig({ throwOnError: true }));
840
806
 
841
807
  // src/api/sdk.gen.ts
842
808
  var appControllerGetVersion = (options) => (options?.client ?? client).get({
@@ -1119,18 +1085,81 @@ var credentialConfigControllerUpdateCredentialConfiguration = (options) => (opti
1119
1085
  ...options.headers
1120
1086
  }
1121
1087
  });
1122
- var credentialConfigControllerSignSchemaMetaConfig = (options) => (options.client ?? client).post({
1088
+ var schemaMetadataControllerSignSchemaMetaConfig = (options) => (options.client ?? client).post({
1089
+ security: [{ scheme: "bearer", type: "http" }],
1090
+ url: "/api/schema-metadata/sign",
1091
+ ...options,
1092
+ headers: {
1093
+ "Content-Type": "application/json",
1094
+ ...options.headers
1095
+ }
1096
+ });
1097
+ var schemaMetadataControllerSignVersionSchemaMetaConfig = (options) => (options.client ?? client).post({
1098
+ security: [{ scheme: "bearer", type: "http" }],
1099
+ url: "/api/schema-metadata/sign-version",
1100
+ ...options,
1101
+ headers: {
1102
+ "Content-Type": "application/json",
1103
+ ...options.headers
1104
+ }
1105
+ });
1106
+ var schemaMetadataControllerGetVocabularies = (options) => (options?.client ?? client).get({
1107
+ security: [{ scheme: "bearer", type: "http" }],
1108
+ url: "/api/schema-metadata/vocabularies",
1109
+ ...options
1110
+ });
1111
+ var schemaMetadataControllerFindAll = (options) => (options?.client ?? client).get({
1112
+ security: [{ scheme: "bearer", type: "http" }],
1113
+ url: "/api/schema-metadata",
1114
+ ...options
1115
+ });
1116
+ var schemaMetadataControllerFindOne = (options) => (options.client ?? client).get({
1117
+ security: [{ scheme: "bearer", type: "http" }],
1118
+ url: "/api/schema-metadata/{id}",
1119
+ ...options
1120
+ });
1121
+ var schemaMetadataControllerRemove = (options) => (options.client ?? client).delete({
1122
+ security: [{ scheme: "bearer", type: "http" }],
1123
+ url: "/api/schema-metadata/{id}/versions/{version}",
1124
+ ...options
1125
+ });
1126
+ var schemaMetadataControllerUpdate = (options) => (options.client ?? client).patch({
1123
1127
  security: [{ scheme: "bearer", type: "http" }],
1124
- url: "/api/issuer/credentials/schema-metadata/sign",
1128
+ url: "/api/schema-metadata/{id}/versions/{version}",
1125
1129
  ...options,
1126
1130
  headers: {
1127
1131
  "Content-Type": "application/json",
1128
1132
  ...options.headers
1129
1133
  }
1130
1134
  });
1131
- var credentialConfigControllerSignVersionSchemaMetaConfig = (options) => (options.client ?? client).post({
1135
+ var schemaMetadataControllerGetLatest = (options) => (options.client ?? client).get({
1136
+ security: [{ scheme: "bearer", type: "http" }],
1137
+ url: "/api/schema-metadata/{id}/latest",
1138
+ ...options
1139
+ });
1140
+ var schemaMetadataControllerGetVersions = (options) => (options.client ?? client).get({
1141
+ security: [{ scheme: "bearer", type: "http" }],
1142
+ url: "/api/schema-metadata/{id}/versions",
1143
+ ...options
1144
+ });
1145
+ var schemaMetadataControllerGetJwt = (options) => (options.client ?? client).get({
1146
+ security: [{ scheme: "bearer", type: "http" }],
1147
+ url: "/api/schema-metadata/{id}/versions/{version}/jwt",
1148
+ ...options
1149
+ });
1150
+ var schemaMetadataControllerExport = (options) => (options.client ?? client).get({
1151
+ security: [{ scheme: "bearer", type: "http" }],
1152
+ url: "/api/schema-metadata/{id}/versions/{version}/export",
1153
+ ...options
1154
+ });
1155
+ var schemaMetadataControllerGetSchema = (options) => (options.client ?? client).get({
1156
+ security: [{ scheme: "bearer", type: "http" }],
1157
+ url: "/api/schema-metadata/{id}/versions/{version}/schemas/{format}",
1158
+ ...options
1159
+ });
1160
+ var schemaMetadataControllerDeprecateVersion = (options) => (options.client ?? client).patch({
1132
1161
  security: [{ scheme: "bearer", type: "http" }],
1133
- url: "/api/issuer/credentials/schema-metadata/sign-version",
1162
+ url: "/api/schema-metadata/{id}/versions/{version}/deprecation",
1134
1163
  ...options,
1135
1164
  headers: {
1136
1165
  "Content-Type": "application/json",
@@ -1251,6 +1280,26 @@ var trustListControllerGetTrustListVersion = (options) => (options.client ?? cli
1251
1280
  url: "/api/trust-list/{id}/versions/{versionId}",
1252
1281
  ...options
1253
1282
  });
1283
+ var cacheControllerGetStats = (options) => (options?.client ?? client).get({
1284
+ security: [{ scheme: "bearer", type: "http" }],
1285
+ url: "/api/cache/stats",
1286
+ ...options
1287
+ });
1288
+ var cacheControllerClearAllCaches = (options) => (options?.client ?? client).delete({
1289
+ security: [{ scheme: "bearer", type: "http" }],
1290
+ url: "/api/cache",
1291
+ ...options
1292
+ });
1293
+ var cacheControllerClearTrustListCache = (options) => (options?.client ?? client).delete({
1294
+ security: [{ scheme: "bearer", type: "http" }],
1295
+ url: "/api/cache/trust-list",
1296
+ ...options
1297
+ });
1298
+ var cacheControllerClearStatusListCache = (options) => (options?.client ?? client).delete({
1299
+ security: [{ scheme: "bearer", type: "http" }],
1300
+ url: "/api/cache/status-list",
1301
+ ...options
1302
+ });
1254
1303
  var presentationManagementControllerConfiguration = (options) => (options?.client ?? client).get({
1255
1304
  security: [{ scheme: "bearer", type: "http" }],
1256
1305
  url: "/api/verifier/config",
@@ -1312,26 +1361,6 @@ var presentationManagementControllerReissueRegistrationCertificate = (options) =
1312
1361
  url: "/api/verifier/config/{id}/registration-cert/reissue",
1313
1362
  ...options
1314
1363
  });
1315
- var cacheControllerGetStats = (options) => (options?.client ?? client).get({
1316
- security: [{ scheme: "bearer", type: "http" }],
1317
- url: "/api/cache/stats",
1318
- ...options
1319
- });
1320
- var cacheControllerClearAllCaches = (options) => (options?.client ?? client).delete({
1321
- security: [{ scheme: "bearer", type: "http" }],
1322
- url: "/api/cache",
1323
- ...options
1324
- });
1325
- var cacheControllerClearTrustListCache = (options) => (options?.client ?? client).delete({
1326
- security: [{ scheme: "bearer", type: "http" }],
1327
- url: "/api/cache/trust-list",
1328
- ...options
1329
- });
1330
- var cacheControllerClearStatusListCache = (options) => (options?.client ?? client).delete({
1331
- security: [{ scheme: "bearer", type: "http" }],
1332
- url: "/api/cache/status-list",
1333
- ...options
1334
- });
1335
1364
  var registrarControllerDeleteConfig = (options) => (options?.client ?? client).delete({
1336
1365
  security: [{ scheme: "bearer", type: "http" }],
1337
1366
  url: "/api/registrar/config",
@@ -1369,69 +1398,6 @@ var registrarControllerCreateAccessCertificate = (options) => (options.client ??
1369
1398
  ...options.headers
1370
1399
  }
1371
1400
  });
1372
- var schemaMetadataControllerGetVocabularies = (options) => (options?.client ?? client).get({
1373
- security: [{ scheme: "bearer", type: "http" }],
1374
- url: "/api/schema-metadata/vocabularies",
1375
- ...options
1376
- });
1377
- var schemaMetadataControllerFindAll = (options) => (options?.client ?? client).get({
1378
- security: [{ scheme: "bearer", type: "http" }],
1379
- url: "/api/schema-metadata",
1380
- ...options
1381
- });
1382
- var schemaMetadataControllerFindOne = (options) => (options.client ?? client).get({
1383
- security: [{ scheme: "bearer", type: "http" }],
1384
- url: "/api/schema-metadata/{id}",
1385
- ...options
1386
- });
1387
- var schemaMetadataControllerRemove = (options) => (options.client ?? client).delete({
1388
- security: [{ scheme: "bearer", type: "http" }],
1389
- url: "/api/schema-metadata/{id}/versions/{version}",
1390
- ...options
1391
- });
1392
- var schemaMetadataControllerUpdate = (options) => (options.client ?? client).patch({
1393
- security: [{ scheme: "bearer", type: "http" }],
1394
- url: "/api/schema-metadata/{id}/versions/{version}",
1395
- ...options,
1396
- headers: {
1397
- "Content-Type": "application/json",
1398
- ...options.headers
1399
- }
1400
- });
1401
- var schemaMetadataControllerGetLatest = (options) => (options.client ?? client).get({
1402
- security: [{ scheme: "bearer", type: "http" }],
1403
- url: "/api/schema-metadata/{id}/latest",
1404
- ...options
1405
- });
1406
- var schemaMetadataControllerGetVersions = (options) => (options.client ?? client).get({
1407
- security: [{ scheme: "bearer", type: "http" }],
1408
- url: "/api/schema-metadata/{id}/versions",
1409
- ...options
1410
- });
1411
- var schemaMetadataControllerGetJwt = (options) => (options.client ?? client).get({
1412
- security: [{ scheme: "bearer", type: "http" }],
1413
- url: "/api/schema-metadata/{id}/versions/{version}/jwt",
1414
- ...options
1415
- });
1416
- var schemaMetadataControllerExport = (options) => (options.client ?? client).get({
1417
- security: [{ scheme: "bearer", type: "http" }],
1418
- url: "/api/schema-metadata/{id}/versions/{version}/export",
1419
- ...options
1420
- });
1421
- var schemaMetadataControllerGetSchema = (options) => (options.client ?? client).get({
1422
- security: [{ scheme: "bearer", type: "http" }],
1423
- url: "/api/schema-metadata/{id}/versions/{version}/schemas/{format}",
1424
- ...options
1425
- });
1426
- var schemaMetadataControllerDeprecateVersion = (options) => (options.client ?? client).patch({
1427
- security: [{ scheme: "bearer", type: "http" }],
1428
- url: "/api/schema-metadata/{id}/versions/{version}/deprecation",
1429
- ...options,
1430
- headers: {
1431
- "Content-Type": "application/json",
1432
- ...options.headers
1433
- }
1434
- });
1435
1401
  var credentialOfferControllerGetOffer = (options) => (options.client ?? client).post({
1436
1402
  security: [{ scheme: "bearer", type: "http" }],
1437
1403
  url: "/api/issuer/offer",
@@ -1464,6 +1430,11 @@ var keyChainControllerGetProviders = (options) => (options?.client ?? client).ge
1464
1430
  url: "/api/key-chain/providers",
1465
1431
  ...options
1466
1432
  });
1433
+ var keyChainControllerGetProvidersHealth = (options) => (options?.client ?? client).get({
1434
+ security: [{ scheme: "bearer", type: "http" }],
1435
+ url: "/api/key-chain/providers/health",
1436
+ ...options
1437
+ });
1467
1438
  var keyChainControllerGetAll = (options) => (options?.client ?? client).get({
1468
1439
  security: [{ scheme: "bearer", type: "http" }],
1469
1440
  url: "/api/key-chain",
@@ -1550,6 +1521,26 @@ function decodeJwtPayload(jwt) {
1550
1521
  const jsonPayload = atob(base64);
1551
1522
  return JSON.parse(jsonPayload);
1552
1523
  }
1524
+ function extractResponseUriFromRequestObject(requestObject) {
1525
+ const requestPayload = decodeJwtPayload(requestObject);
1526
+ if (!requestPayload.response_uri) {
1527
+ throw new Error("No response_uri found in request object");
1528
+ }
1529
+ return requestPayload.response_uri;
1530
+ }
1531
+ function mapDcApiPresentationResult(result) {
1532
+ let resolvedCredentials;
1533
+ if (Array.isArray(result)) {
1534
+ resolvedCredentials = result;
1535
+ } else if (Array.isArray(result?.credentials)) {
1536
+ resolvedCredentials = result.credentials;
1537
+ }
1538
+ return {
1539
+ credentials: resolvedCredentials,
1540
+ response: result,
1541
+ redirectUri: result?.redirect_uri
1542
+ };
1543
+ }
1553
1544
  var EudiploClient = class {
1554
1545
  config;
1555
1546
  accessToken;
@@ -1641,15 +1632,14 @@ var EudiploClient = class {
1641
1632
  tx_code: options.txCode
1642
1633
  };
1643
1634
  if (options.claims) {
1644
- body.credentialClaims = {
1645
- additionalProperties: void 0
1646
- };
1635
+ const credentialClaims = {};
1647
1636
  for (const [configId, claims] of Object.entries(options.claims)) {
1648
- body.credentialClaims[configId] = {
1637
+ credentialClaims[configId] = {
1649
1638
  type: "inline",
1650
1639
  claims
1651
1640
  };
1652
1641
  }
1642
+ body.credentialClaims = credentialClaims;
1653
1643
  }
1654
1644
  const response = await credentialOfferControllerGetOffer({
1655
1645
  body
@@ -1690,10 +1680,12 @@ var EudiploClient = class {
1690
1680
  */
1691
1681
  async createPresentationRequest(options) {
1692
1682
  await this.ensureAuthenticated();
1683
+ const inferredOrigin = options.origin ?? (typeof globalThis.location === "object" ? globalThis.location.origin : void 0);
1693
1684
  const body = {
1694
1685
  response_type: options.responseType ?? "uri",
1695
1686
  requestId: options.configId,
1696
- redirectUri: options.redirectUri
1687
+ redirectUri: options.redirectUri,
1688
+ expected_origin: options.responseType === "dc-api" ? inferredOrigin : void 0
1697
1689
  };
1698
1690
  const response = await verifierOfferControllerGetOffer({
1699
1691
  body
@@ -1911,10 +1903,12 @@ var EudiploClient = class {
1911
1903
  */
1912
1904
  async createDcApiPresentationRequest(options) {
1913
1905
  await this.ensureAuthenticated();
1906
+ const inferredOrigin = options.origin ?? (typeof globalThis.location === "object" ? globalThis.location.origin : void 0);
1914
1907
  const body = {
1915
1908
  response_type: "dc-api",
1916
1909
  requestId: options.configId,
1917
- redirectUri: options.redirectUri
1910
+ redirectUri: options.redirectUri,
1911
+ expected_origin: inferredOrigin
1918
1912
  };
1919
1913
  const response = await verifierOfferControllerGetOffer({
1920
1914
  body
@@ -1922,7 +1916,34 @@ var EudiploClient = class {
1922
1916
  if (!response.data) {
1923
1917
  throw new Error("Failed to create DC API presentation request");
1924
1918
  }
1925
- return this.getSession(response.data.session);
1919
+ const session = await this.getSession(response.data.session);
1920
+ if (session.requestObject) {
1921
+ return session;
1922
+ }
1923
+ const nonceOrId = session.walletNonce ?? session.id;
1924
+ const requestObjectUrl = `${this.config.baseUrl}/api/presentations/${encodeURIComponent(nonceOrId)}/oid4vp/request`;
1925
+ const fetchImpl = this.config.fetch ?? fetch;
1926
+ const requestObjectResponse = await fetchImpl(requestObjectUrl, {
1927
+ method: "GET",
1928
+ headers: {
1929
+ Accept: "application/oauth-authz-req+jwt",
1930
+ ...inferredOrigin ? { Origin: inferredOrigin } : {}
1931
+ }
1932
+ });
1933
+ if (!requestObjectResponse.ok) {
1934
+ const errorText = await requestObjectResponse.text();
1935
+ throw new Error(
1936
+ `Failed to fetch DC API request object: ${requestObjectResponse.status} ${errorText}`
1937
+ );
1938
+ }
1939
+ const requestObject = (await requestObjectResponse.text()).trim();
1940
+ if (!requestObject) {
1941
+ throw new Error("DC API request endpoint returned an empty requestObject");
1942
+ }
1943
+ return {
1944
+ ...session,
1945
+ requestObject
1946
+ };
1926
1947
  }
1927
1948
  /**
1928
1949
  * Submit a presentation using the Digital Credentials API.
@@ -1954,54 +1975,13 @@ var EudiploClient = class {
1954
1975
  'Session does not contain a requestObject. Make sure to create the session with response_type: "dc-api"'
1955
1976
  );
1956
1977
  }
1957
- const dcResponse = await navigator.credentials.get({
1958
- mediation: "required",
1959
- digital: {
1960
- requests: [
1961
- {
1962
- protocol: "openid4vp-v1-signed",
1963
- data: { request: session.requestObject }
1964
- }
1965
- ]
1966
- }
1967
- });
1968
- if (!dcResponse) {
1969
- throw new Error("No response from Digital Credentials API");
1970
- }
1971
- if (dcResponse.data?.error) {
1972
- throw new Error(
1973
- `Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
1974
- );
1975
- }
1976
- const requestPayload = decodeJwtPayload(
1977
- session.requestObject
1978
- );
1979
- if (!requestPayload.response_uri) {
1980
- throw new Error("No response_uri found in request object");
1981
- }
1982
- const fetchImpl = this.config.fetch ?? fetch;
1983
- const submitResponse = await fetchImpl(requestPayload.response_uri, {
1984
- method: "POST",
1985
- headers: {
1986
- "Content-Type": "application/json"
1987
- },
1988
- body: JSON.stringify({
1989
- ...dcResponse.data,
1990
- sendResponse: options.sendResponse ?? true
1991
- })
1978
+ const walletResponse = await invokeDcApi(session.requestObject);
1979
+ return submitDcApiResponse({
1980
+ responseUri: extractResponseUriFromRequestObject(session.requestObject),
1981
+ walletResponse,
1982
+ sendResponse: options.sendResponse,
1983
+ fetch: this.config.fetch
1992
1984
  });
1993
- if (!submitResponse.ok) {
1994
- const errorText = await submitResponse.text();
1995
- throw new Error(
1996
- `Failed to submit presentation: ${submitResponse.status} ${errorText}`
1997
- );
1998
- }
1999
- const result = await submitResponse.json();
2000
- return {
2001
- credentials: result.credentials ?? result,
2002
- response: result,
2003
- redirectUri: result.redirect_uri
2004
- };
2005
1985
  }
2006
1986
  /**
2007
1987
  * Convenience method to create a presentation request and immediately
@@ -2020,111 +2000,7 @@ var EudiploClient = class {
2020
2000
  return this.submitDcApiPresentation(session, dcOptions);
2021
2001
  }
2022
2002
  };
2023
- async function verify(options) {
2024
- const client2 = new EudiploClient({
2025
- baseUrl: options.baseUrl,
2026
- clientId: options.clientId,
2027
- clientSecret: options.clientSecret
2028
- });
2029
- const { uri, sessionId } = await client2.createPresentationRequest({
2030
- configId: options.configId,
2031
- redirectUri: options.redirectUri
2032
- });
2033
- return {
2034
- uri,
2035
- sessionId,
2036
- waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
2037
- getStatus: () => client2.getSession(sessionId)
2038
- };
2039
- }
2040
- async function issue(options) {
2041
- const client2 = new EudiploClient({
2042
- baseUrl: options.baseUrl,
2043
- clientId: options.clientId,
2044
- clientSecret: options.clientSecret
2045
- });
2046
- const { uri, sessionId } = await client2.createIssuanceOffer({
2047
- credentialConfigurationIds: options.credentialConfigurationIds,
2048
- claims: options.claims,
2049
- txCode: options.txCode
2050
- });
2051
- return {
2052
- uri,
2053
- sessionId,
2054
- waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
2055
- getStatus: () => client2.getSession(sessionId)
2056
- };
2057
- }
2058
- async function verifyAndWait(options) {
2059
- const { uri, waitForCompletion } = await verify(options);
2060
- options.onUri(uri);
2061
- return waitForCompletion(options.polling);
2062
- }
2063
- async function issueAndWait(options) {
2064
- const { uri, waitForCompletion } = await issue(options);
2065
- options.onUri(uri);
2066
- return waitForCompletion(options.polling);
2067
- }
2068
- async function verifyWithDcApi(options) {
2069
- const eudiploClient = new EudiploClient({
2070
- baseUrl: options.baseUrl,
2071
- clientId: options.clientId,
2072
- clientSecret: options.clientSecret
2073
- });
2074
- return eudiploClient.verifyWithDcApi(
2075
- {
2076
- configId: options.configId,
2077
- redirectUri: options.redirectUri
2078
- },
2079
- {
2080
- sendResponse: options.sendResponse
2081
- }
2082
- );
2083
- }
2084
- async function createDcApiRequest(options) {
2085
- const eudiploClient = new EudiploClient({
2086
- baseUrl: options.baseUrl,
2087
- clientId: options.clientId,
2088
- clientSecret: options.clientSecret
2089
- });
2090
- const session = await eudiploClient.createDcApiPresentationRequest({
2091
- configId: options.configId,
2092
- redirectUri: options.redirectUri
2093
- });
2094
- return {
2095
- session,
2096
- submit: (dcOptions) => eudiploClient.submitDcApiPresentation(session, {
2097
- sendResponse: options.sendResponse,
2098
- ...dcOptions
2099
- })
2100
- };
2101
- }
2102
- async function createDcApiRequestForBrowser(options) {
2103
- const eudiploClient = new EudiploClient({
2104
- baseUrl: options.baseUrl,
2105
- clientId: options.clientId,
2106
- clientSecret: options.clientSecret
2107
- });
2108
- const session = await eudiploClient.createDcApiPresentationRequest({
2109
- configId: options.configId,
2110
- redirectUri: options.redirectUri
2111
- });
2112
- if (!session.requestObject) {
2113
- throw new Error("Session does not contain a requestObject");
2114
- }
2115
- const requestPayload = decodeJwtPayload(
2116
- session.requestObject
2117
- );
2118
- if (!requestPayload.response_uri) {
2119
- throw new Error("No response_uri found in request object");
2120
- }
2121
- return {
2122
- requestObject: session.requestObject,
2123
- sessionId: session.id,
2124
- responseUri: requestPayload.response_uri
2125
- };
2126
- }
2127
- async function callDcApi(requestObject) {
2003
+ async function invokeDcApi(requestObject) {
2128
2004
  if (!isDcApiAvailable()) {
2129
2005
  throw new Error(
2130
2006
  "Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
@@ -2151,7 +2027,7 @@ async function callDcApi(requestObject) {
2151
2027
  }
2152
2028
  return dcResponse.data;
2153
2029
  }
2154
- async function submitDcApiWalletResponse(options) {
2030
+ async function submitDcApiResponse(options) {
2155
2031
  const fetchImpl = options.fetch ?? fetch;
2156
2032
  const submitResponse = await fetchImpl(options.responseUri, {
2157
2033
  method: "POST",
@@ -2170,10 +2046,217 @@ async function submitDcApiWalletResponse(options) {
2170
2046
  );
2171
2047
  }
2172
2048
  const result = await submitResponse.json();
2049
+ return mapDcApiPresentationResult(result);
2050
+ }
2051
+
2052
+ // src/config/derive.ts
2053
+ var JSON_SCHEMA_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
2054
+ function segmentToKey(segment) {
2055
+ if (segment === null) {
2056
+ return "*";
2057
+ }
2058
+ return String(segment);
2059
+ }
2060
+ function getOrCreateChild(target, key, nextIsArray) {
2061
+ const current = target[key];
2062
+ if (current !== void 0) {
2063
+ if (Array.isArray(current)) {
2064
+ return current;
2065
+ }
2066
+ if (typeof current === "object" && current !== null) {
2067
+ return current;
2068
+ }
2069
+ }
2070
+ const created = nextIsArray ? [] : {};
2071
+ target[key] = created;
2072
+ return created;
2073
+ }
2074
+ function setValueAtPath(target, path, value) {
2075
+ if (path.length === 0) {
2076
+ return;
2077
+ }
2078
+ let cursor = target;
2079
+ for (let index = 0; index < path.length; index += 1) {
2080
+ const segment = path[index];
2081
+ const isLast = index === path.length - 1;
2082
+ const next = path[index + 1];
2083
+ if (Array.isArray(cursor)) {
2084
+ const arrayIndex = typeof segment === "number" ? segment : Number(segmentToKey(segment));
2085
+ if (!Number.isFinite(arrayIndex) || arrayIndex < 0) {
2086
+ return;
2087
+ }
2088
+ if (isLast) {
2089
+ cursor[arrayIndex] = value;
2090
+ return;
2091
+ }
2092
+ const current = cursor[arrayIndex];
2093
+ if (typeof current !== "object" || current === null) {
2094
+ cursor[arrayIndex] = typeof next === "number" ? [] : {};
2095
+ }
2096
+ cursor = cursor[arrayIndex];
2097
+ continue;
2098
+ }
2099
+ const key = segmentToKey(segment);
2100
+ if (isLast) {
2101
+ cursor[key] = value;
2102
+ return;
2103
+ }
2104
+ cursor = getOrCreateChild(cursor, key, typeof next === "number");
2105
+ }
2106
+ }
2107
+ function getDisplayTitle(display) {
2108
+ if (!display || display.length === 0) {
2109
+ return void 0;
2110
+ }
2111
+ const en = display.find((entry) => entry.locale.toLowerCase().startsWith("en"));
2112
+ return en?.name ?? display[0]?.name;
2113
+ }
2114
+ function mergeLeafSchema(existing, next) {
2115
+ const merged = { ...next };
2116
+ if (existing.properties && Object.keys(existing.properties).length > 0) {
2117
+ merged.properties = existing.properties;
2118
+ }
2119
+ if (Array.isArray(existing.required) && existing.required.length > 0) {
2120
+ merged.required = existing.required;
2121
+ }
2122
+ return merged;
2123
+ }
2124
+ function ensureSchemaNode(root, path) {
2125
+ let cursor = root;
2126
+ for (const segment of path) {
2127
+ const key = segmentToKey(segment);
2128
+ cursor.properties ??= {};
2129
+ if (!cursor.properties[key]) {
2130
+ cursor.properties[key] = {
2131
+ type: "object",
2132
+ properties: {}
2133
+ };
2134
+ }
2135
+ cursor = cursor.properties[key];
2136
+ }
2137
+ return cursor;
2138
+ }
2139
+ function ensureFrameNode(root, path) {
2140
+ let cursor = root;
2141
+ for (const segment of path) {
2142
+ const key = segmentToKey(segment);
2143
+ const current = cursor[key];
2144
+ if (!current || typeof current !== "object" || Array.isArray(current)) {
2145
+ cursor[key] = {};
2146
+ }
2147
+ cursor = cursor[key];
2148
+ }
2149
+ return cursor;
2150
+ }
2151
+ function buildClaims(fields) {
2152
+ const claims = {};
2153
+ for (const field of fields) {
2154
+ if (!Object.prototype.hasOwnProperty.call(field, "defaultValue")) {
2155
+ continue;
2156
+ }
2157
+ setValueAtPath(claims, field.path, field.defaultValue);
2158
+ }
2159
+ return claims;
2160
+ }
2161
+ function buildDisclosureFrame(fields) {
2162
+ const frame = {};
2163
+ let hasDisclosure = false;
2164
+ for (const field of fields) {
2165
+ if (!field.disclosable || field.path.length === 0) {
2166
+ continue;
2167
+ }
2168
+ const parentPath = field.path.slice(0, -1);
2169
+ const leaf = segmentToKey(field.path.at(-1) ?? "");
2170
+ const node = ensureFrameNode(frame, parentPath);
2171
+ const existing = Array.isArray(node._sd) ? node._sd : [];
2172
+ if (!existing.includes(leaf)) {
2173
+ existing.push(leaf);
2174
+ node._sd = existing;
2175
+ }
2176
+ hasDisclosure = true;
2177
+ }
2178
+ return hasDisclosure ? frame : void 0;
2179
+ }
2180
+ function buildClaimsMetadata(fields) {
2181
+ return fields.filter((field) => field.path.length > 0).map((field) => {
2182
+ const metadata = {
2183
+ path: field.path
2184
+ };
2185
+ if (typeof field.mandatory === "boolean") {
2186
+ metadata.mandatory = field.mandatory;
2187
+ }
2188
+ if (field.display && field.display.length > 0) {
2189
+ metadata.display = field.display;
2190
+ }
2191
+ return metadata;
2192
+ });
2193
+ }
2194
+ function buildLeafSchema(field) {
2195
+ const schema = {
2196
+ ...field.constraints,
2197
+ type: field.type === "date" ? "string" : field.type
2198
+ };
2199
+ if (field.type === "date" && !schema.format) {
2200
+ schema.format = "date";
2201
+ }
2202
+ const title = getDisplayTitle(field.display);
2203
+ if (title) {
2204
+ schema.title = title;
2205
+ }
2206
+ return schema;
2207
+ }
2208
+ function addRequired(parent, key) {
2209
+ if (!Array.isArray(parent.required)) {
2210
+ parent.required = [];
2211
+ }
2212
+ if (!parent.required.includes(key)) {
2213
+ parent.required.push(key);
2214
+ }
2215
+ }
2216
+ function buildJsonSchema(fields) {
2217
+ const root = {
2218
+ $schema: JSON_SCHEMA_DRAFT_2020_12,
2219
+ type: "object",
2220
+ properties: {}
2221
+ };
2222
+ for (const field of fields) {
2223
+ if (field.path.length === 0) {
2224
+ continue;
2225
+ }
2226
+ const parent = ensureSchemaNode(root, field.path.slice(0, -1));
2227
+ const leafKey = segmentToKey(field.path.at(-1) ?? "");
2228
+ parent.properties ??= {};
2229
+ const leafSchema = buildLeafSchema(field);
2230
+ const existing = parent.properties[leafKey];
2231
+ parent.properties[leafKey] = existing && typeof existing === "object" && !Array.isArray(existing) ? mergeLeafSchema(existing, leafSchema) : leafSchema;
2232
+ if (field.mandatory) {
2233
+ addRequired(parent, leafKey);
2234
+ }
2235
+ }
2236
+ return root;
2237
+ }
2238
+ function buildClaimsByNamespace(fields) {
2239
+ const byNamespace = {};
2240
+ for (const field of fields) {
2241
+ if (!field.namespace || !Object.prototype.hasOwnProperty.call(field, "defaultValue")) {
2242
+ continue;
2243
+ }
2244
+ if (!byNamespace[field.namespace]) {
2245
+ byNamespace[field.namespace] = {};
2246
+ }
2247
+ const namespaceTarget = byNamespace[field.namespace];
2248
+ const normalizedPath = field.path.length > 0 && segmentToKey(field.path[0] ?? "") === field.namespace ? field.path.slice(1) : field.path;
2249
+ setValueAtPath(namespaceTarget, normalizedPath, field.defaultValue);
2250
+ }
2251
+ return byNamespace;
2252
+ }
2253
+ function deriveRuntimeArtifacts(fields) {
2173
2254
  return {
2174
- credentials: result.credentials ?? result,
2175
- response: result,
2176
- redirectUri: result.redirect_uri
2255
+ claims: buildClaims(fields),
2256
+ disclosureFrame: buildDisclosureFrame(fields),
2257
+ claimsMetadata: buildClaimsMetadata(fields),
2258
+ schema: buildJsonSchema(fields),
2259
+ claimsByNamespace: buildClaimsByNamespace(fields)
2177
2260
  };
2178
2261
  }
2179
2262
 
@@ -2187,11 +2270,15 @@ exports.attributeProviderControllerGetById = attributeProviderControllerGetById;
2187
2270
  exports.attributeProviderControllerUpdate = attributeProviderControllerUpdate;
2188
2271
  exports.auditLogControllerGetAuditLogs = auditLogControllerGetAuditLogs;
2189
2272
  exports.authControllerGetOAuth2Token = authControllerGetOAuth2Token;
2273
+ exports.buildClaims = buildClaims;
2274
+ exports.buildClaimsByNamespace = buildClaimsByNamespace;
2275
+ exports.buildClaimsMetadata = buildClaimsMetadata;
2276
+ exports.buildDisclosureFrame = buildDisclosureFrame;
2277
+ exports.buildJsonSchema = buildJsonSchema;
2190
2278
  exports.cacheControllerClearAllCaches = cacheControllerClearAllCaches;
2191
2279
  exports.cacheControllerClearStatusListCache = cacheControllerClearStatusListCache;
2192
2280
  exports.cacheControllerClearTrustListCache = cacheControllerClearTrustListCache;
2193
2281
  exports.cacheControllerGetStats = cacheControllerGetStats;
2194
- exports.callDcApi = callDcApi;
2195
2282
  exports.client = client;
2196
2283
  exports.clientControllerCreateClient = clientControllerCreateClient;
2197
2284
  exports.clientControllerDeleteClient = clientControllerDeleteClient;
@@ -2200,29 +2287,25 @@ exports.clientControllerGetClientSecret = clientControllerGetClientSecret;
2200
2287
  exports.clientControllerGetClients = clientControllerGetClients;
2201
2288
  exports.clientControllerRotateClientSecret = clientControllerRotateClientSecret;
2202
2289
  exports.clientControllerUpdateClient = clientControllerUpdateClient;
2203
- exports.createDcApiRequest = createDcApiRequest;
2204
- exports.createDcApiRequestForBrowser = createDcApiRequestForBrowser;
2205
2290
  exports.credentialConfigControllerDeleteIssuanceConfiguration = credentialConfigControllerDeleteIssuanceConfiguration;
2206
2291
  exports.credentialConfigControllerGetConfigById = credentialConfigControllerGetConfigById;
2207
2292
  exports.credentialConfigControllerGetConfigs = credentialConfigControllerGetConfigs;
2208
- exports.credentialConfigControllerSignSchemaMetaConfig = credentialConfigControllerSignSchemaMetaConfig;
2209
- exports.credentialConfigControllerSignVersionSchemaMetaConfig = credentialConfigControllerSignVersionSchemaMetaConfig;
2210
2293
  exports.credentialConfigControllerStoreCredentialConfiguration = credentialConfigControllerStoreCredentialConfiguration;
2211
2294
  exports.credentialConfigControllerUpdateCredentialConfiguration = credentialConfigControllerUpdateCredentialConfiguration;
2212
2295
  exports.credentialOfferControllerGetOffer = credentialOfferControllerGetOffer;
2213
2296
  exports.deferredControllerCompleteDeferred = deferredControllerCompleteDeferred;
2214
2297
  exports.deferredControllerFailDeferred = deferredControllerFailDeferred;
2298
+ exports.deriveRuntimeArtifacts = deriveRuntimeArtifacts;
2215
2299
  exports.isDcApiAvailable = isDcApiAvailable;
2216
2300
  exports.issuanceConfigControllerGetIssuanceConfigurations = issuanceConfigControllerGetIssuanceConfigurations;
2217
2301
  exports.issuanceConfigControllerStoreIssuanceConfiguration = issuanceConfigControllerStoreIssuanceConfiguration;
2218
- exports.issue = issue;
2219
- exports.issueAndWait = issueAndWait;
2220
2302
  exports.keyChainControllerCreate = keyChainControllerCreate;
2221
2303
  exports.keyChainControllerDelete = keyChainControllerDelete;
2222
2304
  exports.keyChainControllerExport = keyChainControllerExport;
2223
2305
  exports.keyChainControllerGetAll = keyChainControllerGetAll;
2224
2306
  exports.keyChainControllerGetById = keyChainControllerGetById;
2225
2307
  exports.keyChainControllerGetProviders = keyChainControllerGetProviders;
2308
+ exports.keyChainControllerGetProvidersHealth = keyChainControllerGetProvidersHealth;
2226
2309
  exports.keyChainControllerImport = keyChainControllerImport;
2227
2310
  exports.keyChainControllerRotate = keyChainControllerRotate;
2228
2311
  exports.keyChainControllerUpdate = keyChainControllerUpdate;
@@ -2250,6 +2333,8 @@ exports.schemaMetadataControllerGetSchema = schemaMetadataControllerGetSchema;
2250
2333
  exports.schemaMetadataControllerGetVersions = schemaMetadataControllerGetVersions;
2251
2334
  exports.schemaMetadataControllerGetVocabularies = schemaMetadataControllerGetVocabularies;
2252
2335
  exports.schemaMetadataControllerRemove = schemaMetadataControllerRemove;
2336
+ exports.schemaMetadataControllerSignSchemaMetaConfig = schemaMetadataControllerSignSchemaMetaConfig;
2337
+ exports.schemaMetadataControllerSignVersionSchemaMetaConfig = schemaMetadataControllerSignVersionSchemaMetaConfig;
2253
2338
  exports.schemaMetadataControllerUpdate = schemaMetadataControllerUpdate;
2254
2339
  exports.sessionConfigControllerGetConfig = sessionConfigControllerGetConfig;
2255
2340
  exports.sessionConfigControllerResetConfig = sessionConfigControllerResetConfig;
@@ -2269,7 +2354,6 @@ exports.statusListManagementControllerGetList = statusListManagementControllerGe
2269
2354
  exports.statusListManagementControllerGetLists = statusListManagementControllerGetLists;
2270
2355
  exports.statusListManagementControllerUpdateList = statusListManagementControllerUpdateList;
2271
2356
  exports.storageControllerUpload = storageControllerUpload;
2272
- exports.submitDcApiWalletResponse = submitDcApiWalletResponse;
2273
2357
  exports.tenantControllerDeleteTenant = tenantControllerDeleteTenant;
2274
2358
  exports.tenantControllerGetTenant = tenantControllerGetTenant;
2275
2359
  exports.tenantControllerGetTenants = tenantControllerGetTenants;
@@ -2289,9 +2373,6 @@ exports.userControllerGetUser = userControllerGetUser;
2289
2373
  exports.userControllerGetUsers = userControllerGetUsers;
2290
2374
  exports.userControllerUpdateUser = userControllerUpdateUser;
2291
2375
  exports.verifierOfferControllerGetOffer = verifierOfferControllerGetOffer;
2292
- exports.verify = verify;
2293
- exports.verifyAndWait = verifyAndWait;
2294
- exports.verifyWithDcApi = verifyWithDcApi;
2295
2376
  exports.webhookEndpointControllerCreate = webhookEndpointControllerCreate;
2296
2377
  exports.webhookEndpointControllerDelete = webhookEndpointControllerDelete;
2297
2378
  exports.webhookEndpointControllerGetAll = webhookEndpointControllerGetAll;