@eudiplo/sdk-core 1.15.2 → 1.18.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/README.md +150 -0
- package/dist/api/client/client.gen.d.mts +1 -1
- package/dist/api/client/client.gen.d.ts +1 -1
- package/dist/api/client/client.gen.js +5 -1
- package/dist/api/client/client.gen.mjs +5 -1
- package/dist/api/client/index.d.mts +1 -1
- package/dist/api/client/index.d.ts +1 -1
- package/dist/api/client/index.js +5 -1
- package/dist/api/client/index.mjs +5 -1
- package/dist/api/client/types.gen.d.mts +1 -1
- package/dist/api/client/types.gen.d.ts +1 -1
- package/dist/api/client.gen.d.mts +15 -2
- package/dist/api/client.gen.d.ts +15 -2
- package/dist/api/client.gen.js +5 -1
- package/dist/api/client.gen.mjs +5 -1
- package/dist/api/index.d.mts +103 -6
- package/dist/api/index.d.ts +103 -6
- package/dist/api/index.js +122 -2
- package/dist/api/index.mjs +107 -2
- package/dist/index.d.mts +291 -16
- package/dist/index.d.ts +291 -16
- package/dist/index.js +396 -5
- package/dist/index.mjs +375 -6
- package/dist/{types.gen-CIiveH8G.d.mts → types.gen-DDunhhsd.d.mts} +1 -1
- package/dist/{types.gen-CIiveH8G.d.ts → types.gen-DDunhhsd.d.ts} +1 -1
- package/dist/{client.gen-CU56lLgT.d.mts → types.gen-M31b0SZB.d.mts} +637 -33
- package/dist/{client.gen-CsfHl8pY.d.ts → types.gen-M31b0SZB.d.ts} +637 -33
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -744,10 +744,14 @@ var createClient = (config = {}) => {
|
|
|
744
744
|
case "arrayBuffer":
|
|
745
745
|
case "blob":
|
|
746
746
|
case "formData":
|
|
747
|
-
case "json":
|
|
748
747
|
case "text":
|
|
749
748
|
data = await response[parseAs]();
|
|
750
749
|
break;
|
|
750
|
+
case "json": {
|
|
751
|
+
const text = await response.text();
|
|
752
|
+
data = text ? JSON.parse(text) : {};
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
751
755
|
case "stream":
|
|
752
756
|
return opts.responseStyle === "data" ? response.body : {
|
|
753
757
|
data: response.body,
|
|
@@ -929,6 +933,11 @@ var clientControllerGetClientSecret = (options) => (options.client ?? client).ge
|
|
|
929
933
|
url: "/client/{id}/secret",
|
|
930
934
|
...options
|
|
931
935
|
});
|
|
936
|
+
var clientControllerRotateClientSecret = (options) => (options.client ?? client).post({
|
|
937
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
938
|
+
url: "/client/{id}/rotate-secret",
|
|
939
|
+
...options
|
|
940
|
+
});
|
|
932
941
|
var keyControllerGetKeys = (options) => (options?.client ?? client).get({
|
|
933
942
|
security: [{ scheme: "bearer", type: "http" }],
|
|
934
943
|
url: "/key",
|
|
@@ -1148,6 +1157,14 @@ var credentialConfigControllerUpdateCredentialConfiguration = (options) => (opti
|
|
|
1148
1157
|
}
|
|
1149
1158
|
});
|
|
1150
1159
|
var oid4VciControllerCredential = (options) => (options.client ?? client).post({ url: "/{tenantId}/vci/credential", ...options });
|
|
1160
|
+
var oid4VciControllerDeferredCredential = (options) => (options.client ?? client).post({
|
|
1161
|
+
url: "/{tenantId}/vci/deferred_credential",
|
|
1162
|
+
...options,
|
|
1163
|
+
headers: {
|
|
1164
|
+
"Content-Type": "application/json",
|
|
1165
|
+
...options.headers
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1151
1168
|
var oid4VciControllerNotifications = (options) => (options.client ?? client).post({
|
|
1152
1169
|
url: "/{tenantId}/vci/notification",
|
|
1153
1170
|
...options,
|
|
@@ -1175,6 +1192,18 @@ var authorizeControllerAuthorizationChallengeEndpoint = (options) => (options.cl
|
|
|
1175
1192
|
...options.headers
|
|
1176
1193
|
}
|
|
1177
1194
|
});
|
|
1195
|
+
var interactiveAuthorizationControllerInteractiveAuthorization = (options) => (options.client ?? client).post({
|
|
1196
|
+
url: "/{tenantId}/authorize/interactive",
|
|
1197
|
+
...options,
|
|
1198
|
+
headers: {
|
|
1199
|
+
"Content-Type": "application/json",
|
|
1200
|
+
...options.headers
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
var interactiveAuthorizationControllerCompleteWebAuth = (options) => (options.client ?? client).post({
|
|
1204
|
+
url: "/{tenantId}/authorize/interactive/complete-web-auth/{authSession}",
|
|
1205
|
+
...options
|
|
1206
|
+
});
|
|
1178
1207
|
var credentialOfferControllerGetOffer = (options) => (options.client ?? client).post({
|
|
1179
1208
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1180
1209
|
url: "/issuer/offer",
|
|
@@ -1184,6 +1213,24 @@ var credentialOfferControllerGetOffer = (options) => (options.client ?? client).
|
|
|
1184
1213
|
...options.headers
|
|
1185
1214
|
}
|
|
1186
1215
|
});
|
|
1216
|
+
var deferredControllerCompleteDeferred = (options) => (options.client ?? client).post({
|
|
1217
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1218
|
+
url: "/issuer/deferred/{transactionId}/complete",
|
|
1219
|
+
...options,
|
|
1220
|
+
headers: {
|
|
1221
|
+
"Content-Type": "application/json",
|
|
1222
|
+
...options.headers
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
var deferredControllerFailDeferred = (options) => (options.client ?? client).post({
|
|
1226
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1227
|
+
url: "/issuer/deferred/{transactionId}/fail",
|
|
1228
|
+
...options,
|
|
1229
|
+
headers: {
|
|
1230
|
+
"Content-Type": "application/json",
|
|
1231
|
+
...options.headers
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1187
1234
|
var oid4VciMetadataControllerVct = (options) => (options.client ?? client).get({ url: "/{tenantId}/credentials-metadata/vct/{id}", ...options });
|
|
1188
1235
|
var wellKnownControllerIssuerMetadata0 = (options) => (options.client ?? client).get({ url: "/.well-known/openid-credential-issuer/{tenantId}", ...options });
|
|
1189
1236
|
var wellKnownControllerIssuerMetadata1 = (options) => (options.client ?? client).get({ url: "/{tenantId}/.well-known/openid-credential-issuer", ...options });
|
|
@@ -1193,6 +1240,7 @@ var wellKnownControllerGetJwks0 = (options) => (options.client ?? client).get({
|
|
|
1193
1240
|
var wellKnownControllerGetJwks1 = (options) => (options.client ?? client).get({ url: "/{tenantId}/.well-known/jwks.json", ...options });
|
|
1194
1241
|
var oid4VpControllerGetRequestWithSession = (options) => (options.client ?? client).get({ url: "/{session}/oid4vp/request", ...options });
|
|
1195
1242
|
var oid4VpControllerGetPostRequestWithSession = (options) => (options.client ?? client).post({ url: "/{session}/oid4vp/request", ...options });
|
|
1243
|
+
var oid4VpControllerGetRequestNoRedirectWithSession = (options) => (options.client ?? client).get({ url: "/{session}/oid4vp/request/no-redirect", ...options });
|
|
1196
1244
|
var oid4VpControllerGetResponse = (options) => (options.client ?? client).post({
|
|
1197
1245
|
url: "/{session}/oid4vp",
|
|
1198
1246
|
...options,
|
|
@@ -1201,6 +1249,43 @@ var oid4VpControllerGetResponse = (options) => (options.client ?? client).post({
|
|
|
1201
1249
|
...options.headers
|
|
1202
1250
|
}
|
|
1203
1251
|
});
|
|
1252
|
+
var registrarControllerDeleteConfig = (options) => (options?.client ?? client).delete({
|
|
1253
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1254
|
+
url: "/registrar/config",
|
|
1255
|
+
...options
|
|
1256
|
+
});
|
|
1257
|
+
var registrarControllerGetConfig = (options) => (options?.client ?? client).get({
|
|
1258
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1259
|
+
url: "/registrar/config",
|
|
1260
|
+
...options
|
|
1261
|
+
});
|
|
1262
|
+
var registrarControllerUpdateConfig = (options) => (options.client ?? client).patch({
|
|
1263
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1264
|
+
url: "/registrar/config",
|
|
1265
|
+
...options,
|
|
1266
|
+
headers: {
|
|
1267
|
+
"Content-Type": "application/json",
|
|
1268
|
+
...options.headers
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
var registrarControllerCreateConfig = (options) => (options.client ?? client).post({
|
|
1272
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1273
|
+
url: "/registrar/config",
|
|
1274
|
+
...options,
|
|
1275
|
+
headers: {
|
|
1276
|
+
"Content-Type": "application/json",
|
|
1277
|
+
...options.headers
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
var registrarControllerCreateAccessCertificate = (options) => (options.client ?? client).post({
|
|
1281
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1282
|
+
url: "/registrar/access-certificate",
|
|
1283
|
+
...options,
|
|
1284
|
+
headers: {
|
|
1285
|
+
"Content-Type": "application/json",
|
|
1286
|
+
...options.headers
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1204
1289
|
var presentationManagementControllerConfiguration = (options) => (options?.client ?? client).get({
|
|
1205
1290
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1206
1291
|
url: "/verifier/config",
|
|
@@ -1234,6 +1319,26 @@ var presentationManagementControllerUpdateConfiguration = (options) => (options.
|
|
|
1234
1319
|
...options.headers
|
|
1235
1320
|
}
|
|
1236
1321
|
});
|
|
1322
|
+
var cacheControllerGetStats = (options) => (options?.client ?? client).get({
|
|
1323
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1324
|
+
url: "/cache/stats",
|
|
1325
|
+
...options
|
|
1326
|
+
});
|
|
1327
|
+
var cacheControllerClearAllCaches = (options) => (options?.client ?? client).delete({
|
|
1328
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1329
|
+
url: "/cache",
|
|
1330
|
+
...options
|
|
1331
|
+
});
|
|
1332
|
+
var cacheControllerClearTrustListCache = (options) => (options?.client ?? client).delete({
|
|
1333
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1334
|
+
url: "/cache/trust-list",
|
|
1335
|
+
...options
|
|
1336
|
+
});
|
|
1337
|
+
var cacheControllerClearStatusListCache = (options) => (options?.client ?? client).delete({
|
|
1338
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1339
|
+
url: "/cache/status-list",
|
|
1340
|
+
...options
|
|
1341
|
+
});
|
|
1237
1342
|
var trustListControllerGetAllTrustLists = (options) => (options?.client ?? client).get({
|
|
1238
1343
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1239
1344
|
url: "/trust-list",
|
|
@@ -1305,6 +1410,19 @@ var storageControllerUpload = (options) => (options.client ?? client).post({
|
|
|
1305
1410
|
var storageControllerDownload = (options) => (options.client ?? client).get({ url: "/storage/{key}", ...options });
|
|
1306
1411
|
|
|
1307
1412
|
// src/client.ts
|
|
1413
|
+
function isDcApiAvailable() {
|
|
1414
|
+
return typeof navigator !== "undefined" && "credentials" in navigator && "get" in navigator.credentials && typeof window !== "undefined" && "DigitalCredential" in window;
|
|
1415
|
+
}
|
|
1416
|
+
function decodeJwtPayload(jwt) {
|
|
1417
|
+
const parts = jwt.split(".");
|
|
1418
|
+
if (parts.length !== 3) {
|
|
1419
|
+
throw new Error("Invalid JWT format");
|
|
1420
|
+
}
|
|
1421
|
+
const payload = parts[1];
|
|
1422
|
+
const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
1423
|
+
const jsonPayload = atob(base64);
|
|
1424
|
+
return JSON.parse(jsonPayload);
|
|
1425
|
+
}
|
|
1308
1426
|
var EudiploClient = class {
|
|
1309
1427
|
config;
|
|
1310
1428
|
accessToken;
|
|
@@ -1417,14 +1535,26 @@ var EudiploClient = class {
|
|
|
1417
1535
|
/**
|
|
1418
1536
|
* Create a presentation request (for verification).
|
|
1419
1537
|
*
|
|
1420
|
-
*
|
|
1538
|
+
* Returns two URIs:
|
|
1539
|
+
* - `uri`: For same-device flow (wallet on same device, redirect after completion)
|
|
1540
|
+
* - `crossDeviceUri`: For cross-device flow (QR code, no redirect, poll for status)
|
|
1541
|
+
*
|
|
1542
|
+
* @example Same-device flow (wallet app on user's device)
|
|
1421
1543
|
* ```typescript
|
|
1422
|
-
* // Age verification
|
|
1423
1544
|
* const { uri, sessionId } = await client.createPresentationRequest({
|
|
1424
|
-
* configId: 'age-over-18'
|
|
1545
|
+
* configId: 'age-over-18',
|
|
1546
|
+
* redirectUri: 'https://example.com/callback'
|
|
1425
1547
|
* });
|
|
1548
|
+
* // Redirect user to uri - wallet will redirect back after completion
|
|
1549
|
+
* window.location.href = uri;
|
|
1550
|
+
* ```
|
|
1426
1551
|
*
|
|
1427
|
-
*
|
|
1552
|
+
* @example Cross-device flow (QR code scanned by separate device)
|
|
1553
|
+
* ```typescript
|
|
1554
|
+
* const { crossDeviceUri, sessionId } = await client.createPresentationRequest({
|
|
1555
|
+
* configId: 'age-over-18'
|
|
1556
|
+
* });
|
|
1557
|
+
* // Display crossDeviceUri as QR code, then poll for completion
|
|
1428
1558
|
* const session = await client.waitForSession(sessionId);
|
|
1429
1559
|
* ```
|
|
1430
1560
|
*/
|
|
@@ -1443,6 +1573,7 @@ var EudiploClient = class {
|
|
|
1443
1573
|
}
|
|
1444
1574
|
return {
|
|
1445
1575
|
uri: response.data.uri,
|
|
1576
|
+
crossDeviceUri: response.data.crossDeviceUri ?? response.data.uri,
|
|
1446
1577
|
sessionId: response.data.session
|
|
1447
1578
|
};
|
|
1448
1579
|
}
|
|
@@ -1525,6 +1656,133 @@ var EudiploClient = class {
|
|
|
1525
1656
|
getBaseUrl() {
|
|
1526
1657
|
return this.config.baseUrl;
|
|
1527
1658
|
}
|
|
1659
|
+
// ==========================================================================
|
|
1660
|
+
// Digital Credentials API Methods
|
|
1661
|
+
// ==========================================================================
|
|
1662
|
+
/**
|
|
1663
|
+
* Create a presentation request configured for DC API usage.
|
|
1664
|
+
* Returns a session with the signed request object needed for DC API.
|
|
1665
|
+
*
|
|
1666
|
+
* @example
|
|
1667
|
+
* ```typescript
|
|
1668
|
+
* const session = await client.createDcApiPresentationRequest({
|
|
1669
|
+
* configId: 'age-over-18'
|
|
1670
|
+
* });
|
|
1671
|
+
*
|
|
1672
|
+
* // Use the requestObject with the DC API
|
|
1673
|
+
* const result = await client.submitDcApiPresentation(session);
|
|
1674
|
+
* ```
|
|
1675
|
+
*/
|
|
1676
|
+
async createDcApiPresentationRequest(options) {
|
|
1677
|
+
await this.ensureAuthenticated();
|
|
1678
|
+
const body = {
|
|
1679
|
+
response_type: "dc-api",
|
|
1680
|
+
requestId: options.configId,
|
|
1681
|
+
redirectUri: options.redirectUri
|
|
1682
|
+
};
|
|
1683
|
+
const response = await verifierOfferControllerGetOffer({
|
|
1684
|
+
body
|
|
1685
|
+
});
|
|
1686
|
+
if (!response.data) {
|
|
1687
|
+
throw new Error("Failed to create DC API presentation request");
|
|
1688
|
+
}
|
|
1689
|
+
return this.getSession(response.data.session);
|
|
1690
|
+
}
|
|
1691
|
+
/**
|
|
1692
|
+
* Submit a presentation using the Digital Credentials API.
|
|
1693
|
+
* This method handles the browser DC API call and submits the response to the verifier.
|
|
1694
|
+
*
|
|
1695
|
+
* @example
|
|
1696
|
+
* ```typescript
|
|
1697
|
+
* // Check if DC API is available
|
|
1698
|
+
* if (!isDcApiAvailable()) {
|
|
1699
|
+
* throw new Error('DC API not supported in this browser');
|
|
1700
|
+
* }
|
|
1701
|
+
*
|
|
1702
|
+
* const session = await client.createDcApiPresentationRequest({
|
|
1703
|
+
* configId: 'age-over-18'
|
|
1704
|
+
* });
|
|
1705
|
+
*
|
|
1706
|
+
* const result = await client.submitDcApiPresentation(session);
|
|
1707
|
+
* console.log('Verified credentials:', result.credentials);
|
|
1708
|
+
* ```
|
|
1709
|
+
*/
|
|
1710
|
+
async submitDcApiPresentation(session, options = {}) {
|
|
1711
|
+
if (!isDcApiAvailable()) {
|
|
1712
|
+
throw new Error(
|
|
1713
|
+
"Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
|
|
1714
|
+
);
|
|
1715
|
+
}
|
|
1716
|
+
if (!session.requestObject) {
|
|
1717
|
+
throw new Error(
|
|
1718
|
+
'Session does not contain a requestObject. Make sure to create the session with response_type: "dc-api"'
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1721
|
+
const dcResponse = await navigator.credentials.get({
|
|
1722
|
+
mediation: "required",
|
|
1723
|
+
digital: {
|
|
1724
|
+
requests: [
|
|
1725
|
+
{
|
|
1726
|
+
protocol: "openid4vp-v1-signed",
|
|
1727
|
+
data: { request: session.requestObject }
|
|
1728
|
+
}
|
|
1729
|
+
]
|
|
1730
|
+
}
|
|
1731
|
+
});
|
|
1732
|
+
if (!dcResponse) {
|
|
1733
|
+
throw new Error("No response from Digital Credentials API");
|
|
1734
|
+
}
|
|
1735
|
+
if (dcResponse.data?.error) {
|
|
1736
|
+
throw new Error(
|
|
1737
|
+
`Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
|
|
1738
|
+
);
|
|
1739
|
+
}
|
|
1740
|
+
const requestPayload = decodeJwtPayload(
|
|
1741
|
+
session.requestObject
|
|
1742
|
+
);
|
|
1743
|
+
if (!requestPayload.response_uri) {
|
|
1744
|
+
throw new Error("No response_uri found in request object");
|
|
1745
|
+
}
|
|
1746
|
+
const fetchImpl = this.config.fetch ?? fetch;
|
|
1747
|
+
const submitResponse = await fetchImpl(requestPayload.response_uri, {
|
|
1748
|
+
method: "POST",
|
|
1749
|
+
headers: {
|
|
1750
|
+
"Content-Type": "application/json"
|
|
1751
|
+
},
|
|
1752
|
+
body: JSON.stringify({
|
|
1753
|
+
...dcResponse.data,
|
|
1754
|
+
sendResponse: options.sendResponse ?? true
|
|
1755
|
+
})
|
|
1756
|
+
});
|
|
1757
|
+
if (!submitResponse.ok) {
|
|
1758
|
+
const errorText = await submitResponse.text();
|
|
1759
|
+
throw new Error(
|
|
1760
|
+
`Failed to submit presentation: ${submitResponse.status} ${errorText}`
|
|
1761
|
+
);
|
|
1762
|
+
}
|
|
1763
|
+
const result = await submitResponse.json();
|
|
1764
|
+
return {
|
|
1765
|
+
credentials: result.credentials ?? result,
|
|
1766
|
+
response: result,
|
|
1767
|
+
redirectUri: result.redirect_uri
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Convenience method to create a presentation request and immediately
|
|
1772
|
+
* submit it using the Digital Credentials API.
|
|
1773
|
+
*
|
|
1774
|
+
* @example
|
|
1775
|
+
* ```typescript
|
|
1776
|
+
* const result = await client.verifyWithDcApi({
|
|
1777
|
+
* configId: 'age-over-18'
|
|
1778
|
+
* });
|
|
1779
|
+
* console.log('Verified:', result.credentials);
|
|
1780
|
+
* ```
|
|
1781
|
+
*/
|
|
1782
|
+
async verifyWithDcApi(options, dcOptions = {}) {
|
|
1783
|
+
const session = await this.createDcApiPresentationRequest(options);
|
|
1784
|
+
return this.submitDcApiPresentation(session, dcOptions);
|
|
1785
|
+
}
|
|
1528
1786
|
};
|
|
1529
1787
|
async function verify(options) {
|
|
1530
1788
|
const client2 = new EudiploClient({
|
|
@@ -1571,6 +1829,117 @@ async function issueAndWait(options) {
|
|
|
1571
1829
|
options.onUri(uri);
|
|
1572
1830
|
return waitForCompletion(options.polling);
|
|
1573
1831
|
}
|
|
1832
|
+
async function verifyWithDcApi(options) {
|
|
1833
|
+
const eudiploClient = new EudiploClient({
|
|
1834
|
+
baseUrl: options.baseUrl,
|
|
1835
|
+
clientId: options.clientId,
|
|
1836
|
+
clientSecret: options.clientSecret
|
|
1837
|
+
});
|
|
1838
|
+
return eudiploClient.verifyWithDcApi(
|
|
1839
|
+
{
|
|
1840
|
+
configId: options.configId,
|
|
1841
|
+
redirectUri: options.redirectUri
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
sendResponse: options.sendResponse
|
|
1845
|
+
}
|
|
1846
|
+
);
|
|
1847
|
+
}
|
|
1848
|
+
async function createDcApiRequest(options) {
|
|
1849
|
+
const eudiploClient = new EudiploClient({
|
|
1850
|
+
baseUrl: options.baseUrl,
|
|
1851
|
+
clientId: options.clientId,
|
|
1852
|
+
clientSecret: options.clientSecret
|
|
1853
|
+
});
|
|
1854
|
+
const session = await eudiploClient.createDcApiPresentationRequest({
|
|
1855
|
+
configId: options.configId,
|
|
1856
|
+
redirectUri: options.redirectUri
|
|
1857
|
+
});
|
|
1858
|
+
return {
|
|
1859
|
+
session,
|
|
1860
|
+
submit: (dcOptions) => eudiploClient.submitDcApiPresentation(session, {
|
|
1861
|
+
sendResponse: options.sendResponse,
|
|
1862
|
+
...dcOptions
|
|
1863
|
+
})
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
async function createDcApiRequestForBrowser(options) {
|
|
1867
|
+
const eudiploClient = new EudiploClient({
|
|
1868
|
+
baseUrl: options.baseUrl,
|
|
1869
|
+
clientId: options.clientId,
|
|
1870
|
+
clientSecret: options.clientSecret
|
|
1871
|
+
});
|
|
1872
|
+
const session = await eudiploClient.createDcApiPresentationRequest({
|
|
1873
|
+
configId: options.configId,
|
|
1874
|
+
redirectUri: options.redirectUri
|
|
1875
|
+
});
|
|
1876
|
+
if (!session.requestObject) {
|
|
1877
|
+
throw new Error("Session does not contain a requestObject");
|
|
1878
|
+
}
|
|
1879
|
+
const requestPayload = decodeJwtPayload(
|
|
1880
|
+
session.requestObject
|
|
1881
|
+
);
|
|
1882
|
+
if (!requestPayload.response_uri) {
|
|
1883
|
+
throw new Error("No response_uri found in request object");
|
|
1884
|
+
}
|
|
1885
|
+
return {
|
|
1886
|
+
requestObject: session.requestObject,
|
|
1887
|
+
sessionId: session.id,
|
|
1888
|
+
responseUri: requestPayload.response_uri
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
async function callDcApi(requestObject) {
|
|
1892
|
+
if (!isDcApiAvailable()) {
|
|
1893
|
+
throw new Error(
|
|
1894
|
+
"Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
|
|
1895
|
+
);
|
|
1896
|
+
}
|
|
1897
|
+
const dcResponse = await navigator.credentials.get({
|
|
1898
|
+
mediation: "required",
|
|
1899
|
+
digital: {
|
|
1900
|
+
requests: [
|
|
1901
|
+
{
|
|
1902
|
+
protocol: "openid4vp-v1-signed",
|
|
1903
|
+
data: { request: requestObject }
|
|
1904
|
+
}
|
|
1905
|
+
]
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
if (!dcResponse) {
|
|
1909
|
+
throw new Error("No response from Digital Credentials API");
|
|
1910
|
+
}
|
|
1911
|
+
if (dcResponse.data?.error) {
|
|
1912
|
+
throw new Error(
|
|
1913
|
+
`Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
return dcResponse.data;
|
|
1917
|
+
}
|
|
1918
|
+
async function submitDcApiWalletResponse(options) {
|
|
1919
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
1920
|
+
const submitResponse = await fetchImpl(options.responseUri, {
|
|
1921
|
+
method: "POST",
|
|
1922
|
+
headers: {
|
|
1923
|
+
"Content-Type": "application/json"
|
|
1924
|
+
},
|
|
1925
|
+
body: JSON.stringify({
|
|
1926
|
+
...options.walletResponse,
|
|
1927
|
+
sendResponse: options.sendResponse ?? true
|
|
1928
|
+
})
|
|
1929
|
+
});
|
|
1930
|
+
if (!submitResponse.ok) {
|
|
1931
|
+
const errorText = await submitResponse.text();
|
|
1932
|
+
throw new Error(
|
|
1933
|
+
`Failed to submit presentation: ${submitResponse.status} ${errorText}`
|
|
1934
|
+
);
|
|
1935
|
+
}
|
|
1936
|
+
const result = await submitResponse.json();
|
|
1937
|
+
return {
|
|
1938
|
+
credentials: result.credentials ?? result,
|
|
1939
|
+
response: result,
|
|
1940
|
+
redirectUri: result.redirect_uri
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1574
1943
|
|
|
1575
1944
|
exports.EudiploClient = EudiploClient;
|
|
1576
1945
|
exports.appControllerMain = appControllerMain;
|
|
@@ -1581,6 +1950,11 @@ exports.authorizeControllerAuthorizationChallengeEndpoint = authorizeControllerA
|
|
|
1581
1950
|
exports.authorizeControllerAuthorize = authorizeControllerAuthorize;
|
|
1582
1951
|
exports.authorizeControllerPar = authorizeControllerPar;
|
|
1583
1952
|
exports.authorizeControllerToken = authorizeControllerToken;
|
|
1953
|
+
exports.cacheControllerClearAllCaches = cacheControllerClearAllCaches;
|
|
1954
|
+
exports.cacheControllerClearStatusListCache = cacheControllerClearStatusListCache;
|
|
1955
|
+
exports.cacheControllerClearTrustListCache = cacheControllerClearTrustListCache;
|
|
1956
|
+
exports.cacheControllerGetStats = cacheControllerGetStats;
|
|
1957
|
+
exports.callDcApi = callDcApi;
|
|
1584
1958
|
exports.certControllerAddCertificate = certControllerAddCertificate;
|
|
1585
1959
|
exports.certControllerDeleteCertificate = certControllerDeleteCertificate;
|
|
1586
1960
|
exports.certControllerExportConfig = certControllerExportConfig;
|
|
@@ -1593,14 +1967,22 @@ exports.clientControllerDeleteClient = clientControllerDeleteClient;
|
|
|
1593
1967
|
exports.clientControllerGetClient = clientControllerGetClient;
|
|
1594
1968
|
exports.clientControllerGetClientSecret = clientControllerGetClientSecret;
|
|
1595
1969
|
exports.clientControllerGetClients = clientControllerGetClients;
|
|
1970
|
+
exports.clientControllerRotateClientSecret = clientControllerRotateClientSecret;
|
|
1596
1971
|
exports.clientControllerUpdateClient = clientControllerUpdateClient;
|
|
1972
|
+
exports.createDcApiRequest = createDcApiRequest;
|
|
1973
|
+
exports.createDcApiRequestForBrowser = createDcApiRequestForBrowser;
|
|
1597
1974
|
exports.credentialConfigControllerDeleteIssuanceConfiguration = credentialConfigControllerDeleteIssuanceConfiguration;
|
|
1598
1975
|
exports.credentialConfigControllerGetConfigById = credentialConfigControllerGetConfigById;
|
|
1599
1976
|
exports.credentialConfigControllerGetConfigs = credentialConfigControllerGetConfigs;
|
|
1600
1977
|
exports.credentialConfigControllerStoreCredentialConfiguration = credentialConfigControllerStoreCredentialConfiguration;
|
|
1601
1978
|
exports.credentialConfigControllerUpdateCredentialConfiguration = credentialConfigControllerUpdateCredentialConfiguration;
|
|
1602
1979
|
exports.credentialOfferControllerGetOffer = credentialOfferControllerGetOffer;
|
|
1980
|
+
exports.deferredControllerCompleteDeferred = deferredControllerCompleteDeferred;
|
|
1981
|
+
exports.deferredControllerFailDeferred = deferredControllerFailDeferred;
|
|
1603
1982
|
exports.healthControllerCheck = healthControllerCheck;
|
|
1983
|
+
exports.interactiveAuthorizationControllerCompleteWebAuth = interactiveAuthorizationControllerCompleteWebAuth;
|
|
1984
|
+
exports.interactiveAuthorizationControllerInteractiveAuthorization = interactiveAuthorizationControllerInteractiveAuthorization;
|
|
1985
|
+
exports.isDcApiAvailable = isDcApiAvailable;
|
|
1604
1986
|
exports.issuanceConfigControllerGetIssuanceConfigurations = issuanceConfigControllerGetIssuanceConfigurations;
|
|
1605
1987
|
exports.issuanceConfigControllerStoreIssuanceConfiguration = issuanceConfigControllerStoreIssuanceConfiguration;
|
|
1606
1988
|
exports.issue = issue;
|
|
@@ -1611,10 +1993,12 @@ exports.keyControllerGetKey = keyControllerGetKey;
|
|
|
1611
1993
|
exports.keyControllerGetKeys = keyControllerGetKeys;
|
|
1612
1994
|
exports.keyControllerUpdateKey = keyControllerUpdateKey;
|
|
1613
1995
|
exports.oid4VciControllerCredential = oid4VciControllerCredential;
|
|
1996
|
+
exports.oid4VciControllerDeferredCredential = oid4VciControllerDeferredCredential;
|
|
1614
1997
|
exports.oid4VciControllerNonce = oid4VciControllerNonce;
|
|
1615
1998
|
exports.oid4VciControllerNotifications = oid4VciControllerNotifications;
|
|
1616
1999
|
exports.oid4VciMetadataControllerVct = oid4VciMetadataControllerVct;
|
|
1617
2000
|
exports.oid4VpControllerGetPostRequestWithSession = oid4VpControllerGetPostRequestWithSession;
|
|
2001
|
+
exports.oid4VpControllerGetRequestNoRedirectWithSession = oid4VpControllerGetRequestNoRedirectWithSession;
|
|
1618
2002
|
exports.oid4VpControllerGetRequestWithSession = oid4VpControllerGetRequestWithSession;
|
|
1619
2003
|
exports.oid4VpControllerGetResponse = oid4VpControllerGetResponse;
|
|
1620
2004
|
exports.presentationManagementControllerConfiguration = presentationManagementControllerConfiguration;
|
|
@@ -1623,6 +2007,11 @@ exports.presentationManagementControllerGetConfiguration = presentationManagemen
|
|
|
1623
2007
|
exports.presentationManagementControllerStorePresentationConfig = presentationManagementControllerStorePresentationConfig;
|
|
1624
2008
|
exports.presentationManagementControllerUpdateConfiguration = presentationManagementControllerUpdateConfiguration;
|
|
1625
2009
|
exports.prometheusControllerIndex = prometheusControllerIndex;
|
|
2010
|
+
exports.registrarControllerCreateAccessCertificate = registrarControllerCreateAccessCertificate;
|
|
2011
|
+
exports.registrarControllerCreateConfig = registrarControllerCreateConfig;
|
|
2012
|
+
exports.registrarControllerDeleteConfig = registrarControllerDeleteConfig;
|
|
2013
|
+
exports.registrarControllerGetConfig = registrarControllerGetConfig;
|
|
2014
|
+
exports.registrarControllerUpdateConfig = registrarControllerUpdateConfig;
|
|
1626
2015
|
exports.sessionConfigControllerGetConfig = sessionConfigControllerGetConfig;
|
|
1627
2016
|
exports.sessionConfigControllerResetConfig = sessionConfigControllerResetConfig;
|
|
1628
2017
|
exports.sessionConfigControllerUpdateConfig = sessionConfigControllerUpdateConfig;
|
|
@@ -1642,6 +2031,7 @@ exports.statusListManagementControllerGetLists = statusListManagementControllerG
|
|
|
1642
2031
|
exports.statusListManagementControllerUpdateList = statusListManagementControllerUpdateList;
|
|
1643
2032
|
exports.storageControllerDownload = storageControllerDownload;
|
|
1644
2033
|
exports.storageControllerUpload = storageControllerUpload;
|
|
2034
|
+
exports.submitDcApiWalletResponse = submitDcApiWalletResponse;
|
|
1645
2035
|
exports.tenantControllerDeleteTenant = tenantControllerDeleteTenant;
|
|
1646
2036
|
exports.tenantControllerGetTenant = tenantControllerGetTenant;
|
|
1647
2037
|
exports.tenantControllerGetTenants = tenantControllerGetTenants;
|
|
@@ -1659,6 +2049,7 @@ exports.trustListPublicControllerGetTrustListJwt = trustListPublicControllerGetT
|
|
|
1659
2049
|
exports.verifierOfferControllerGetOffer = verifierOfferControllerGetOffer;
|
|
1660
2050
|
exports.verify = verify;
|
|
1661
2051
|
exports.verifyAndWait = verifyAndWait;
|
|
2052
|
+
exports.verifyWithDcApi = verifyWithDcApi;
|
|
1662
2053
|
exports.wellKnownControllerAuthzMetadata0 = wellKnownControllerAuthzMetadata0;
|
|
1663
2054
|
exports.wellKnownControllerAuthzMetadata1 = wellKnownControllerAuthzMetadata1;
|
|
1664
2055
|
exports.wellKnownControllerGetJwks0 = wellKnownControllerGetJwks0;
|