@eudiplo/sdk-core 4.3.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({
@@ -849,6 +815,14 @@ var appControllerGetFrontendConfig = (options) => (options?.client ?? client).ge
849
815
  url: "/api/frontend-config",
850
816
  ...options
851
817
  });
818
+ var authControllerGetOAuth2Token = (options) => (options.client ?? client).post({
819
+ url: "/api/oauth2/token",
820
+ ...options,
821
+ headers: {
822
+ "Content-Type": "application/json",
823
+ ...options.headers
824
+ }
825
+ });
852
826
  var tenantControllerGetTenants = (options) => (options?.client ?? client).get({
853
827
  security: [{ scheme: "bearer", type: "http" }],
854
828
  url: "/api/tenant",
@@ -882,6 +856,11 @@ var tenantControllerUpdateTenant = (options) => (options.client ?? client).patch
882
856
  ...options.headers
883
857
  }
884
858
  });
859
+ var auditLogControllerGetAuditLogs = (options) => (options?.client ?? client).get({
860
+ security: [{ scheme: "bearer", type: "http" }],
861
+ url: "/api/admin/audit-logs",
862
+ ...options
863
+ });
885
864
  var clientControllerGetClients = (options) => (options?.client ?? client).get({
886
865
  security: [{ scheme: "bearer", type: "http" }],
887
866
  url: "/api/client",
@@ -1106,18 +1085,81 @@ var credentialConfigControllerUpdateCredentialConfiguration = (options) => (opti
1106
1085
  ...options.headers
1107
1086
  }
1108
1087
  });
1109
- 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({
1110
1117
  security: [{ scheme: "bearer", type: "http" }],
1111
- url: "/api/issuer/credentials/schema-metadata/sign",
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({
1127
+ security: [{ scheme: "bearer", type: "http" }],
1128
+ url: "/api/schema-metadata/{id}/versions/{version}",
1112
1129
  ...options,
1113
1130
  headers: {
1114
1131
  "Content-Type": "application/json",
1115
1132
  ...options.headers
1116
1133
  }
1117
1134
  });
1118
- 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({
1119
1141
  security: [{ scheme: "bearer", type: "http" }],
1120
- url: "/api/issuer/credentials/schema-metadata/sign-version",
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({
1161
+ security: [{ scheme: "bearer", type: "http" }],
1162
+ url: "/api/schema-metadata/{id}/versions/{version}/deprecation",
1121
1163
  ...options,
1122
1164
  headers: {
1123
1165
  "Content-Type": "application/json",
@@ -1238,6 +1280,26 @@ var trustListControllerGetTrustListVersion = (options) => (options.client ?? cli
1238
1280
  url: "/api/trust-list/{id}/versions/{versionId}",
1239
1281
  ...options
1240
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
+ });
1241
1303
  var presentationManagementControllerConfiguration = (options) => (options?.client ?? client).get({
1242
1304
  security: [{ scheme: "bearer", type: "http" }],
1243
1305
  url: "/api/verifier/config",
@@ -1299,26 +1361,6 @@ var presentationManagementControllerReissueRegistrationCertificate = (options) =
1299
1361
  url: "/api/verifier/config/{id}/registration-cert/reissue",
1300
1362
  ...options
1301
1363
  });
1302
- var cacheControllerGetStats = (options) => (options?.client ?? client).get({
1303
- security: [{ scheme: "bearer", type: "http" }],
1304
- url: "/api/cache/stats",
1305
- ...options
1306
- });
1307
- var cacheControllerClearAllCaches = (options) => (options?.client ?? client).delete({
1308
- security: [{ scheme: "bearer", type: "http" }],
1309
- url: "/api/cache",
1310
- ...options
1311
- });
1312
- var cacheControllerClearTrustListCache = (options) => (options?.client ?? client).delete({
1313
- security: [{ scheme: "bearer", type: "http" }],
1314
- url: "/api/cache/trust-list",
1315
- ...options
1316
- });
1317
- var cacheControllerClearStatusListCache = (options) => (options?.client ?? client).delete({
1318
- security: [{ scheme: "bearer", type: "http" }],
1319
- url: "/api/cache/status-list",
1320
- ...options
1321
- });
1322
1364
  var registrarControllerDeleteConfig = (options) => (options?.client ?? client).delete({
1323
1365
  security: [{ scheme: "bearer", type: "http" }],
1324
1366
  url: "/api/registrar/config",
@@ -1356,69 +1398,6 @@ var registrarControllerCreateAccessCertificate = (options) => (options.client ??
1356
1398
  ...options.headers
1357
1399
  }
1358
1400
  });
1359
- var schemaMetadataControllerGetVocabularies = (options) => (options?.client ?? client).get({
1360
- security: [{ scheme: "bearer", type: "http" }],
1361
- url: "/api/schema-metadata/vocabularies",
1362
- ...options
1363
- });
1364
- var schemaMetadataControllerFindAll = (options) => (options?.client ?? client).get({
1365
- security: [{ scheme: "bearer", type: "http" }],
1366
- url: "/api/schema-metadata",
1367
- ...options
1368
- });
1369
- var schemaMetadataControllerFindOne = (options) => (options.client ?? client).get({
1370
- security: [{ scheme: "bearer", type: "http" }],
1371
- url: "/api/schema-metadata/{id}",
1372
- ...options
1373
- });
1374
- var schemaMetadataControllerRemove = (options) => (options.client ?? client).delete({
1375
- security: [{ scheme: "bearer", type: "http" }],
1376
- url: "/api/schema-metadata/{id}/versions/{version}",
1377
- ...options
1378
- });
1379
- var schemaMetadataControllerUpdate = (options) => (options.client ?? client).patch({
1380
- security: [{ scheme: "bearer", type: "http" }],
1381
- url: "/api/schema-metadata/{id}/versions/{version}",
1382
- ...options,
1383
- headers: {
1384
- "Content-Type": "application/json",
1385
- ...options.headers
1386
- }
1387
- });
1388
- var schemaMetadataControllerGetLatest = (options) => (options.client ?? client).get({
1389
- security: [{ scheme: "bearer", type: "http" }],
1390
- url: "/api/schema-metadata/{id}/latest",
1391
- ...options
1392
- });
1393
- var schemaMetadataControllerGetVersions = (options) => (options.client ?? client).get({
1394
- security: [{ scheme: "bearer", type: "http" }],
1395
- url: "/api/schema-metadata/{id}/versions",
1396
- ...options
1397
- });
1398
- var schemaMetadataControllerGetJwt = (options) => (options.client ?? client).get({
1399
- security: [{ scheme: "bearer", type: "http" }],
1400
- url: "/api/schema-metadata/{id}/versions/{version}/jwt",
1401
- ...options
1402
- });
1403
- var schemaMetadataControllerExport = (options) => (options.client ?? client).get({
1404
- security: [{ scheme: "bearer", type: "http" }],
1405
- url: "/api/schema-metadata/{id}/versions/{version}/export",
1406
- ...options
1407
- });
1408
- var schemaMetadataControllerGetSchema = (options) => (options.client ?? client).get({
1409
- security: [{ scheme: "bearer", type: "http" }],
1410
- url: "/api/schema-metadata/{id}/versions/{version}/schemas/{format}",
1411
- ...options
1412
- });
1413
- var schemaMetadataControllerDeprecateVersion = (options) => (options.client ?? client).patch({
1414
- security: [{ scheme: "bearer", type: "http" }],
1415
- url: "/api/schema-metadata/{id}/versions/{version}/deprecation",
1416
- ...options,
1417
- headers: {
1418
- "Content-Type": "application/json",
1419
- ...options.headers
1420
- }
1421
- });
1422
1401
  var credentialOfferControllerGetOffer = (options) => (options.client ?? client).post({
1423
1402
  security: [{ scheme: "bearer", type: "http" }],
1424
1403
  url: "/api/issuer/offer",
@@ -1451,6 +1430,11 @@ var keyChainControllerGetProviders = (options) => (options?.client ?? client).ge
1451
1430
  url: "/api/key-chain/providers",
1452
1431
  ...options
1453
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
+ });
1454
1438
  var keyChainControllerGetAll = (options) => (options?.client ?? client).get({
1455
1439
  security: [{ scheme: "bearer", type: "http" }],
1456
1440
  url: "/api/key-chain",
@@ -1537,6 +1521,26 @@ function decodeJwtPayload(jwt) {
1537
1521
  const jsonPayload = atob(base64);
1538
1522
  return JSON.parse(jsonPayload);
1539
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
+ }
1540
1544
  var EudiploClient = class {
1541
1545
  config;
1542
1546
  accessToken;
@@ -1569,7 +1573,7 @@ var EudiploClient = class {
1569
1573
  }
1570
1574
  async _doAuthenticate() {
1571
1575
  const fetchFn = this.config.fetch ?? globalThis.fetch;
1572
- const res = await fetchFn(`${this.config.baseUrl}/oauth2/token`, {
1576
+ const res = await fetchFn(`${this.config.baseUrl}/api/oauth2/token`, {
1573
1577
  method: "POST",
1574
1578
  headers: { "Content-Type": "application/json" },
1575
1579
  body: JSON.stringify({
@@ -1628,15 +1632,14 @@ var EudiploClient = class {
1628
1632
  tx_code: options.txCode
1629
1633
  };
1630
1634
  if (options.claims) {
1631
- body.credentialClaims = {
1632
- additionalProperties: void 0
1633
- };
1635
+ const credentialClaims = {};
1634
1636
  for (const [configId, claims] of Object.entries(options.claims)) {
1635
- body.credentialClaims[configId] = {
1637
+ credentialClaims[configId] = {
1636
1638
  type: "inline",
1637
1639
  claims
1638
1640
  };
1639
1641
  }
1642
+ body.credentialClaims = credentialClaims;
1640
1643
  }
1641
1644
  const response = await credentialOfferControllerGetOffer({
1642
1645
  body
@@ -1677,10 +1680,12 @@ var EudiploClient = class {
1677
1680
  */
1678
1681
  async createPresentationRequest(options) {
1679
1682
  await this.ensureAuthenticated();
1683
+ const inferredOrigin = options.origin ?? (typeof globalThis.location === "object" ? globalThis.location.origin : void 0);
1680
1684
  const body = {
1681
1685
  response_type: options.responseType ?? "uri",
1682
1686
  requestId: options.configId,
1683
- redirectUri: options.redirectUri
1687
+ redirectUri: options.redirectUri,
1688
+ expected_origin: options.responseType === "dc-api" ? inferredOrigin : void 0
1684
1689
  };
1685
1690
  const response = await verifierOfferControllerGetOffer({
1686
1691
  body
@@ -1898,10 +1903,12 @@ var EudiploClient = class {
1898
1903
  */
1899
1904
  async createDcApiPresentationRequest(options) {
1900
1905
  await this.ensureAuthenticated();
1906
+ const inferredOrigin = options.origin ?? (typeof globalThis.location === "object" ? globalThis.location.origin : void 0);
1901
1907
  const body = {
1902
1908
  response_type: "dc-api",
1903
1909
  requestId: options.configId,
1904
- redirectUri: options.redirectUri
1910
+ redirectUri: options.redirectUri,
1911
+ expected_origin: inferredOrigin
1905
1912
  };
1906
1913
  const response = await verifierOfferControllerGetOffer({
1907
1914
  body
@@ -1909,7 +1916,34 @@ var EudiploClient = class {
1909
1916
  if (!response.data) {
1910
1917
  throw new Error("Failed to create DC API presentation request");
1911
1918
  }
1912
- 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
+ };
1913
1947
  }
1914
1948
  /**
1915
1949
  * Submit a presentation using the Digital Credentials API.
@@ -1941,54 +1975,13 @@ var EudiploClient = class {
1941
1975
  'Session does not contain a requestObject. Make sure to create the session with response_type: "dc-api"'
1942
1976
  );
1943
1977
  }
1944
- const dcResponse = await navigator.credentials.get({
1945
- mediation: "required",
1946
- digital: {
1947
- requests: [
1948
- {
1949
- protocol: "openid4vp-v1-signed",
1950
- data: { request: session.requestObject }
1951
- }
1952
- ]
1953
- }
1954
- });
1955
- if (!dcResponse) {
1956
- throw new Error("No response from Digital Credentials API");
1957
- }
1958
- if (dcResponse.data?.error) {
1959
- throw new Error(
1960
- `Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
1961
- );
1962
- }
1963
- const requestPayload = decodeJwtPayload(
1964
- session.requestObject
1965
- );
1966
- if (!requestPayload.response_uri) {
1967
- throw new Error("No response_uri found in request object");
1968
- }
1969
- const fetchImpl = this.config.fetch ?? fetch;
1970
- const submitResponse = await fetchImpl(requestPayload.response_uri, {
1971
- method: "POST",
1972
- headers: {
1973
- "Content-Type": "application/json"
1974
- },
1975
- body: JSON.stringify({
1976
- ...dcResponse.data,
1977
- sendResponse: options.sendResponse ?? true
1978
- })
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
1979
1984
  });
1980
- if (!submitResponse.ok) {
1981
- const errorText = await submitResponse.text();
1982
- throw new Error(
1983
- `Failed to submit presentation: ${submitResponse.status} ${errorText}`
1984
- );
1985
- }
1986
- const result = await submitResponse.json();
1987
- return {
1988
- credentials: result.credentials ?? result,
1989
- response: result,
1990
- redirectUri: result.redirect_uri
1991
- };
1992
1985
  }
1993
1986
  /**
1994
1987
  * Convenience method to create a presentation request and immediately
@@ -2007,111 +2000,7 @@ var EudiploClient = class {
2007
2000
  return this.submitDcApiPresentation(session, dcOptions);
2008
2001
  }
2009
2002
  };
2010
- async function verify(options) {
2011
- const client2 = new EudiploClient({
2012
- baseUrl: options.baseUrl,
2013
- clientId: options.clientId,
2014
- clientSecret: options.clientSecret
2015
- });
2016
- const { uri, sessionId } = await client2.createPresentationRequest({
2017
- configId: options.configId,
2018
- redirectUri: options.redirectUri
2019
- });
2020
- return {
2021
- uri,
2022
- sessionId,
2023
- waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
2024
- getStatus: () => client2.getSession(sessionId)
2025
- };
2026
- }
2027
- async function issue(options) {
2028
- const client2 = new EudiploClient({
2029
- baseUrl: options.baseUrl,
2030
- clientId: options.clientId,
2031
- clientSecret: options.clientSecret
2032
- });
2033
- const { uri, sessionId } = await client2.createIssuanceOffer({
2034
- credentialConfigurationIds: options.credentialConfigurationIds,
2035
- claims: options.claims,
2036
- txCode: options.txCode
2037
- });
2038
- return {
2039
- uri,
2040
- sessionId,
2041
- waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
2042
- getStatus: () => client2.getSession(sessionId)
2043
- };
2044
- }
2045
- async function verifyAndWait(options) {
2046
- const { uri, waitForCompletion } = await verify(options);
2047
- options.onUri(uri);
2048
- return waitForCompletion(options.polling);
2049
- }
2050
- async function issueAndWait(options) {
2051
- const { uri, waitForCompletion } = await issue(options);
2052
- options.onUri(uri);
2053
- return waitForCompletion(options.polling);
2054
- }
2055
- async function verifyWithDcApi(options) {
2056
- const eudiploClient = new EudiploClient({
2057
- baseUrl: options.baseUrl,
2058
- clientId: options.clientId,
2059
- clientSecret: options.clientSecret
2060
- });
2061
- return eudiploClient.verifyWithDcApi(
2062
- {
2063
- configId: options.configId,
2064
- redirectUri: options.redirectUri
2065
- },
2066
- {
2067
- sendResponse: options.sendResponse
2068
- }
2069
- );
2070
- }
2071
- async function createDcApiRequest(options) {
2072
- const eudiploClient = new EudiploClient({
2073
- baseUrl: options.baseUrl,
2074
- clientId: options.clientId,
2075
- clientSecret: options.clientSecret
2076
- });
2077
- const session = await eudiploClient.createDcApiPresentationRequest({
2078
- configId: options.configId,
2079
- redirectUri: options.redirectUri
2080
- });
2081
- return {
2082
- session,
2083
- submit: (dcOptions) => eudiploClient.submitDcApiPresentation(session, {
2084
- sendResponse: options.sendResponse,
2085
- ...dcOptions
2086
- })
2087
- };
2088
- }
2089
- async function createDcApiRequestForBrowser(options) {
2090
- const eudiploClient = new EudiploClient({
2091
- baseUrl: options.baseUrl,
2092
- clientId: options.clientId,
2093
- clientSecret: options.clientSecret
2094
- });
2095
- const session = await eudiploClient.createDcApiPresentationRequest({
2096
- configId: options.configId,
2097
- redirectUri: options.redirectUri
2098
- });
2099
- if (!session.requestObject) {
2100
- throw new Error("Session does not contain a requestObject");
2101
- }
2102
- const requestPayload = decodeJwtPayload(
2103
- session.requestObject
2104
- );
2105
- if (!requestPayload.response_uri) {
2106
- throw new Error("No response_uri found in request object");
2107
- }
2108
- return {
2109
- requestObject: session.requestObject,
2110
- sessionId: session.id,
2111
- responseUri: requestPayload.response_uri
2112
- };
2113
- }
2114
- async function callDcApi(requestObject) {
2003
+ async function invokeDcApi(requestObject) {
2115
2004
  if (!isDcApiAvailable()) {
2116
2005
  throw new Error(
2117
2006
  "Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
@@ -2138,7 +2027,7 @@ async function callDcApi(requestObject) {
2138
2027
  }
2139
2028
  return dcResponse.data;
2140
2029
  }
2141
- async function submitDcApiWalletResponse(options) {
2030
+ async function submitDcApiResponse(options) {
2142
2031
  const fetchImpl = options.fetch ?? fetch;
2143
2032
  const submitResponse = await fetchImpl(options.responseUri, {
2144
2033
  method: "POST",
@@ -2157,10 +2046,217 @@ async function submitDcApiWalletResponse(options) {
2157
2046
  );
2158
2047
  }
2159
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) {
2160
2254
  return {
2161
- credentials: result.credentials ?? result,
2162
- response: result,
2163
- redirectUri: result.redirect_uri
2255
+ claims: buildClaims(fields),
2256
+ disclosureFrame: buildDisclosureFrame(fields),
2257
+ claimsMetadata: buildClaimsMetadata(fields),
2258
+ schema: buildJsonSchema(fields),
2259
+ claimsByNamespace: buildClaimsByNamespace(fields)
2164
2260
  };
2165
2261
  }
2166
2262
 
@@ -2172,11 +2268,17 @@ exports.attributeProviderControllerDelete = attributeProviderControllerDelete;
2172
2268
  exports.attributeProviderControllerGetAll = attributeProviderControllerGetAll;
2173
2269
  exports.attributeProviderControllerGetById = attributeProviderControllerGetById;
2174
2270
  exports.attributeProviderControllerUpdate = attributeProviderControllerUpdate;
2271
+ exports.auditLogControllerGetAuditLogs = auditLogControllerGetAuditLogs;
2272
+ exports.authControllerGetOAuth2Token = authControllerGetOAuth2Token;
2273
+ exports.buildClaims = buildClaims;
2274
+ exports.buildClaimsByNamespace = buildClaimsByNamespace;
2275
+ exports.buildClaimsMetadata = buildClaimsMetadata;
2276
+ exports.buildDisclosureFrame = buildDisclosureFrame;
2277
+ exports.buildJsonSchema = buildJsonSchema;
2175
2278
  exports.cacheControllerClearAllCaches = cacheControllerClearAllCaches;
2176
2279
  exports.cacheControllerClearStatusListCache = cacheControllerClearStatusListCache;
2177
2280
  exports.cacheControllerClearTrustListCache = cacheControllerClearTrustListCache;
2178
2281
  exports.cacheControllerGetStats = cacheControllerGetStats;
2179
- exports.callDcApi = callDcApi;
2180
2282
  exports.client = client;
2181
2283
  exports.clientControllerCreateClient = clientControllerCreateClient;
2182
2284
  exports.clientControllerDeleteClient = clientControllerDeleteClient;
@@ -2185,29 +2287,25 @@ exports.clientControllerGetClientSecret = clientControllerGetClientSecret;
2185
2287
  exports.clientControllerGetClients = clientControllerGetClients;
2186
2288
  exports.clientControllerRotateClientSecret = clientControllerRotateClientSecret;
2187
2289
  exports.clientControllerUpdateClient = clientControllerUpdateClient;
2188
- exports.createDcApiRequest = createDcApiRequest;
2189
- exports.createDcApiRequestForBrowser = createDcApiRequestForBrowser;
2190
2290
  exports.credentialConfigControllerDeleteIssuanceConfiguration = credentialConfigControllerDeleteIssuanceConfiguration;
2191
2291
  exports.credentialConfigControllerGetConfigById = credentialConfigControllerGetConfigById;
2192
2292
  exports.credentialConfigControllerGetConfigs = credentialConfigControllerGetConfigs;
2193
- exports.credentialConfigControllerSignSchemaMetaConfig = credentialConfigControllerSignSchemaMetaConfig;
2194
- exports.credentialConfigControllerSignVersionSchemaMetaConfig = credentialConfigControllerSignVersionSchemaMetaConfig;
2195
2293
  exports.credentialConfigControllerStoreCredentialConfiguration = credentialConfigControllerStoreCredentialConfiguration;
2196
2294
  exports.credentialConfigControllerUpdateCredentialConfiguration = credentialConfigControllerUpdateCredentialConfiguration;
2197
2295
  exports.credentialOfferControllerGetOffer = credentialOfferControllerGetOffer;
2198
2296
  exports.deferredControllerCompleteDeferred = deferredControllerCompleteDeferred;
2199
2297
  exports.deferredControllerFailDeferred = deferredControllerFailDeferred;
2298
+ exports.deriveRuntimeArtifacts = deriveRuntimeArtifacts;
2200
2299
  exports.isDcApiAvailable = isDcApiAvailable;
2201
2300
  exports.issuanceConfigControllerGetIssuanceConfigurations = issuanceConfigControllerGetIssuanceConfigurations;
2202
2301
  exports.issuanceConfigControllerStoreIssuanceConfiguration = issuanceConfigControllerStoreIssuanceConfiguration;
2203
- exports.issue = issue;
2204
- exports.issueAndWait = issueAndWait;
2205
2302
  exports.keyChainControllerCreate = keyChainControllerCreate;
2206
2303
  exports.keyChainControllerDelete = keyChainControllerDelete;
2207
2304
  exports.keyChainControllerExport = keyChainControllerExport;
2208
2305
  exports.keyChainControllerGetAll = keyChainControllerGetAll;
2209
2306
  exports.keyChainControllerGetById = keyChainControllerGetById;
2210
2307
  exports.keyChainControllerGetProviders = keyChainControllerGetProviders;
2308
+ exports.keyChainControllerGetProvidersHealth = keyChainControllerGetProvidersHealth;
2211
2309
  exports.keyChainControllerImport = keyChainControllerImport;
2212
2310
  exports.keyChainControllerRotate = keyChainControllerRotate;
2213
2311
  exports.keyChainControllerUpdate = keyChainControllerUpdate;
@@ -2235,6 +2333,8 @@ exports.schemaMetadataControllerGetSchema = schemaMetadataControllerGetSchema;
2235
2333
  exports.schemaMetadataControllerGetVersions = schemaMetadataControllerGetVersions;
2236
2334
  exports.schemaMetadataControllerGetVocabularies = schemaMetadataControllerGetVocabularies;
2237
2335
  exports.schemaMetadataControllerRemove = schemaMetadataControllerRemove;
2336
+ exports.schemaMetadataControllerSignSchemaMetaConfig = schemaMetadataControllerSignSchemaMetaConfig;
2337
+ exports.schemaMetadataControllerSignVersionSchemaMetaConfig = schemaMetadataControllerSignVersionSchemaMetaConfig;
2238
2338
  exports.schemaMetadataControllerUpdate = schemaMetadataControllerUpdate;
2239
2339
  exports.sessionConfigControllerGetConfig = sessionConfigControllerGetConfig;
2240
2340
  exports.sessionConfigControllerResetConfig = sessionConfigControllerResetConfig;
@@ -2254,7 +2354,6 @@ exports.statusListManagementControllerGetList = statusListManagementControllerGe
2254
2354
  exports.statusListManagementControllerGetLists = statusListManagementControllerGetLists;
2255
2355
  exports.statusListManagementControllerUpdateList = statusListManagementControllerUpdateList;
2256
2356
  exports.storageControllerUpload = storageControllerUpload;
2257
- exports.submitDcApiWalletResponse = submitDcApiWalletResponse;
2258
2357
  exports.tenantControllerDeleteTenant = tenantControllerDeleteTenant;
2259
2358
  exports.tenantControllerGetTenant = tenantControllerGetTenant;
2260
2359
  exports.tenantControllerGetTenants = tenantControllerGetTenants;
@@ -2274,9 +2373,6 @@ exports.userControllerGetUser = userControllerGetUser;
2274
2373
  exports.userControllerGetUsers = userControllerGetUsers;
2275
2374
  exports.userControllerUpdateUser = userControllerUpdateUser;
2276
2375
  exports.verifierOfferControllerGetOffer = verifierOfferControllerGetOffer;
2277
- exports.verify = verify;
2278
- exports.verifyAndWait = verifyAndWait;
2279
- exports.verifyWithDcApi = verifyWithDcApi;
2280
2376
  exports.webhookEndpointControllerCreate = webhookEndpointControllerCreate;
2281
2377
  exports.webhookEndpointControllerDelete = webhookEndpointControllerDelete;
2282
2378
  exports.webhookEndpointControllerGetAll = webhookEndpointControllerGetAll;