@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.mjs
CHANGED
|
@@ -742,10 +742,14 @@ var createClient = (config = {}) => {
|
|
|
742
742
|
case "arrayBuffer":
|
|
743
743
|
case "blob":
|
|
744
744
|
case "formData":
|
|
745
|
-
case "json":
|
|
746
745
|
case "text":
|
|
747
746
|
data = await response[parseAs]();
|
|
748
747
|
break;
|
|
748
|
+
case "json": {
|
|
749
|
+
const text = await response.text();
|
|
750
|
+
data = text ? JSON.parse(text) : {};
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
749
753
|
case "stream":
|
|
750
754
|
return opts.responseStyle === "data" ? response.body : {
|
|
751
755
|
data: response.body,
|
|
@@ -927,6 +931,11 @@ var clientControllerGetClientSecret = (options) => (options.client ?? client).ge
|
|
|
927
931
|
url: "/client/{id}/secret",
|
|
928
932
|
...options
|
|
929
933
|
});
|
|
934
|
+
var clientControllerRotateClientSecret = (options) => (options.client ?? client).post({
|
|
935
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
936
|
+
url: "/client/{id}/rotate-secret",
|
|
937
|
+
...options
|
|
938
|
+
});
|
|
930
939
|
var keyControllerGetKeys = (options) => (options?.client ?? client).get({
|
|
931
940
|
security: [{ scheme: "bearer", type: "http" }],
|
|
932
941
|
url: "/key",
|
|
@@ -1146,6 +1155,14 @@ var credentialConfigControllerUpdateCredentialConfiguration = (options) => (opti
|
|
|
1146
1155
|
}
|
|
1147
1156
|
});
|
|
1148
1157
|
var oid4VciControllerCredential = (options) => (options.client ?? client).post({ url: "/{tenantId}/vci/credential", ...options });
|
|
1158
|
+
var oid4VciControllerDeferredCredential = (options) => (options.client ?? client).post({
|
|
1159
|
+
url: "/{tenantId}/vci/deferred_credential",
|
|
1160
|
+
...options,
|
|
1161
|
+
headers: {
|
|
1162
|
+
"Content-Type": "application/json",
|
|
1163
|
+
...options.headers
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1149
1166
|
var oid4VciControllerNotifications = (options) => (options.client ?? client).post({
|
|
1150
1167
|
url: "/{tenantId}/vci/notification",
|
|
1151
1168
|
...options,
|
|
@@ -1173,6 +1190,18 @@ var authorizeControllerAuthorizationChallengeEndpoint = (options) => (options.cl
|
|
|
1173
1190
|
...options.headers
|
|
1174
1191
|
}
|
|
1175
1192
|
});
|
|
1193
|
+
var interactiveAuthorizationControllerInteractiveAuthorization = (options) => (options.client ?? client).post({
|
|
1194
|
+
url: "/{tenantId}/authorize/interactive",
|
|
1195
|
+
...options,
|
|
1196
|
+
headers: {
|
|
1197
|
+
"Content-Type": "application/json",
|
|
1198
|
+
...options.headers
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
var interactiveAuthorizationControllerCompleteWebAuth = (options) => (options.client ?? client).post({
|
|
1202
|
+
url: "/{tenantId}/authorize/interactive/complete-web-auth/{authSession}",
|
|
1203
|
+
...options
|
|
1204
|
+
});
|
|
1176
1205
|
var credentialOfferControllerGetOffer = (options) => (options.client ?? client).post({
|
|
1177
1206
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1178
1207
|
url: "/issuer/offer",
|
|
@@ -1182,6 +1211,24 @@ var credentialOfferControllerGetOffer = (options) => (options.client ?? client).
|
|
|
1182
1211
|
...options.headers
|
|
1183
1212
|
}
|
|
1184
1213
|
});
|
|
1214
|
+
var deferredControllerCompleteDeferred = (options) => (options.client ?? client).post({
|
|
1215
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1216
|
+
url: "/issuer/deferred/{transactionId}/complete",
|
|
1217
|
+
...options,
|
|
1218
|
+
headers: {
|
|
1219
|
+
"Content-Type": "application/json",
|
|
1220
|
+
...options.headers
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
var deferredControllerFailDeferred = (options) => (options.client ?? client).post({
|
|
1224
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1225
|
+
url: "/issuer/deferred/{transactionId}/fail",
|
|
1226
|
+
...options,
|
|
1227
|
+
headers: {
|
|
1228
|
+
"Content-Type": "application/json",
|
|
1229
|
+
...options.headers
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1185
1232
|
var oid4VciMetadataControllerVct = (options) => (options.client ?? client).get({ url: "/{tenantId}/credentials-metadata/vct/{id}", ...options });
|
|
1186
1233
|
var wellKnownControllerIssuerMetadata0 = (options) => (options.client ?? client).get({ url: "/.well-known/openid-credential-issuer/{tenantId}", ...options });
|
|
1187
1234
|
var wellKnownControllerIssuerMetadata1 = (options) => (options.client ?? client).get({ url: "/{tenantId}/.well-known/openid-credential-issuer", ...options });
|
|
@@ -1191,6 +1238,7 @@ var wellKnownControllerGetJwks0 = (options) => (options.client ?? client).get({
|
|
|
1191
1238
|
var wellKnownControllerGetJwks1 = (options) => (options.client ?? client).get({ url: "/{tenantId}/.well-known/jwks.json", ...options });
|
|
1192
1239
|
var oid4VpControllerGetRequestWithSession = (options) => (options.client ?? client).get({ url: "/{session}/oid4vp/request", ...options });
|
|
1193
1240
|
var oid4VpControllerGetPostRequestWithSession = (options) => (options.client ?? client).post({ url: "/{session}/oid4vp/request", ...options });
|
|
1241
|
+
var oid4VpControllerGetRequestNoRedirectWithSession = (options) => (options.client ?? client).get({ url: "/{session}/oid4vp/request/no-redirect", ...options });
|
|
1194
1242
|
var oid4VpControllerGetResponse = (options) => (options.client ?? client).post({
|
|
1195
1243
|
url: "/{session}/oid4vp",
|
|
1196
1244
|
...options,
|
|
@@ -1199,6 +1247,43 @@ var oid4VpControllerGetResponse = (options) => (options.client ?? client).post({
|
|
|
1199
1247
|
...options.headers
|
|
1200
1248
|
}
|
|
1201
1249
|
});
|
|
1250
|
+
var registrarControllerDeleteConfig = (options) => (options?.client ?? client).delete({
|
|
1251
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1252
|
+
url: "/registrar/config",
|
|
1253
|
+
...options
|
|
1254
|
+
});
|
|
1255
|
+
var registrarControllerGetConfig = (options) => (options?.client ?? client).get({
|
|
1256
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1257
|
+
url: "/registrar/config",
|
|
1258
|
+
...options
|
|
1259
|
+
});
|
|
1260
|
+
var registrarControllerUpdateConfig = (options) => (options.client ?? client).patch({
|
|
1261
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1262
|
+
url: "/registrar/config",
|
|
1263
|
+
...options,
|
|
1264
|
+
headers: {
|
|
1265
|
+
"Content-Type": "application/json",
|
|
1266
|
+
...options.headers
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
var registrarControllerCreateConfig = (options) => (options.client ?? client).post({
|
|
1270
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1271
|
+
url: "/registrar/config",
|
|
1272
|
+
...options,
|
|
1273
|
+
headers: {
|
|
1274
|
+
"Content-Type": "application/json",
|
|
1275
|
+
...options.headers
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
var registrarControllerCreateAccessCertificate = (options) => (options.client ?? client).post({
|
|
1279
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1280
|
+
url: "/registrar/access-certificate",
|
|
1281
|
+
...options,
|
|
1282
|
+
headers: {
|
|
1283
|
+
"Content-Type": "application/json",
|
|
1284
|
+
...options.headers
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1202
1287
|
var presentationManagementControllerConfiguration = (options) => (options?.client ?? client).get({
|
|
1203
1288
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1204
1289
|
url: "/verifier/config",
|
|
@@ -1232,6 +1317,26 @@ var presentationManagementControllerUpdateConfiguration = (options) => (options.
|
|
|
1232
1317
|
...options.headers
|
|
1233
1318
|
}
|
|
1234
1319
|
});
|
|
1320
|
+
var cacheControllerGetStats = (options) => (options?.client ?? client).get({
|
|
1321
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1322
|
+
url: "/cache/stats",
|
|
1323
|
+
...options
|
|
1324
|
+
});
|
|
1325
|
+
var cacheControllerClearAllCaches = (options) => (options?.client ?? client).delete({
|
|
1326
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1327
|
+
url: "/cache",
|
|
1328
|
+
...options
|
|
1329
|
+
});
|
|
1330
|
+
var cacheControllerClearTrustListCache = (options) => (options?.client ?? client).delete({
|
|
1331
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1332
|
+
url: "/cache/trust-list",
|
|
1333
|
+
...options
|
|
1334
|
+
});
|
|
1335
|
+
var cacheControllerClearStatusListCache = (options) => (options?.client ?? client).delete({
|
|
1336
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1337
|
+
url: "/cache/status-list",
|
|
1338
|
+
...options
|
|
1339
|
+
});
|
|
1235
1340
|
var trustListControllerGetAllTrustLists = (options) => (options?.client ?? client).get({
|
|
1236
1341
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1237
1342
|
url: "/trust-list",
|
|
@@ -1303,6 +1408,19 @@ var storageControllerUpload = (options) => (options.client ?? client).post({
|
|
|
1303
1408
|
var storageControllerDownload = (options) => (options.client ?? client).get({ url: "/storage/{key}", ...options });
|
|
1304
1409
|
|
|
1305
1410
|
// src/client.ts
|
|
1411
|
+
function isDcApiAvailable() {
|
|
1412
|
+
return typeof navigator !== "undefined" && "credentials" in navigator && "get" in navigator.credentials && typeof window !== "undefined" && "DigitalCredential" in window;
|
|
1413
|
+
}
|
|
1414
|
+
function decodeJwtPayload(jwt) {
|
|
1415
|
+
const parts = jwt.split(".");
|
|
1416
|
+
if (parts.length !== 3) {
|
|
1417
|
+
throw new Error("Invalid JWT format");
|
|
1418
|
+
}
|
|
1419
|
+
const payload = parts[1];
|
|
1420
|
+
const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
1421
|
+
const jsonPayload = atob(base64);
|
|
1422
|
+
return JSON.parse(jsonPayload);
|
|
1423
|
+
}
|
|
1306
1424
|
var EudiploClient = class {
|
|
1307
1425
|
config;
|
|
1308
1426
|
accessToken;
|
|
@@ -1415,14 +1533,26 @@ var EudiploClient = class {
|
|
|
1415
1533
|
/**
|
|
1416
1534
|
* Create a presentation request (for verification).
|
|
1417
1535
|
*
|
|
1418
|
-
*
|
|
1536
|
+
* Returns two URIs:
|
|
1537
|
+
* - `uri`: For same-device flow (wallet on same device, redirect after completion)
|
|
1538
|
+
* - `crossDeviceUri`: For cross-device flow (QR code, no redirect, poll for status)
|
|
1539
|
+
*
|
|
1540
|
+
* @example Same-device flow (wallet app on user's device)
|
|
1419
1541
|
* ```typescript
|
|
1420
|
-
* // Age verification
|
|
1421
1542
|
* const { uri, sessionId } = await client.createPresentationRequest({
|
|
1422
|
-
* configId: 'age-over-18'
|
|
1543
|
+
* configId: 'age-over-18',
|
|
1544
|
+
* redirectUri: 'https://example.com/callback'
|
|
1423
1545
|
* });
|
|
1546
|
+
* // Redirect user to uri - wallet will redirect back after completion
|
|
1547
|
+
* window.location.href = uri;
|
|
1548
|
+
* ```
|
|
1424
1549
|
*
|
|
1425
|
-
*
|
|
1550
|
+
* @example Cross-device flow (QR code scanned by separate device)
|
|
1551
|
+
* ```typescript
|
|
1552
|
+
* const { crossDeviceUri, sessionId } = await client.createPresentationRequest({
|
|
1553
|
+
* configId: 'age-over-18'
|
|
1554
|
+
* });
|
|
1555
|
+
* // Display crossDeviceUri as QR code, then poll for completion
|
|
1426
1556
|
* const session = await client.waitForSession(sessionId);
|
|
1427
1557
|
* ```
|
|
1428
1558
|
*/
|
|
@@ -1441,6 +1571,7 @@ var EudiploClient = class {
|
|
|
1441
1571
|
}
|
|
1442
1572
|
return {
|
|
1443
1573
|
uri: response.data.uri,
|
|
1574
|
+
crossDeviceUri: response.data.crossDeviceUri ?? response.data.uri,
|
|
1444
1575
|
sessionId: response.data.session
|
|
1445
1576
|
};
|
|
1446
1577
|
}
|
|
@@ -1523,6 +1654,133 @@ var EudiploClient = class {
|
|
|
1523
1654
|
getBaseUrl() {
|
|
1524
1655
|
return this.config.baseUrl;
|
|
1525
1656
|
}
|
|
1657
|
+
// ==========================================================================
|
|
1658
|
+
// Digital Credentials API Methods
|
|
1659
|
+
// ==========================================================================
|
|
1660
|
+
/**
|
|
1661
|
+
* Create a presentation request configured for DC API usage.
|
|
1662
|
+
* Returns a session with the signed request object needed for DC API.
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```typescript
|
|
1666
|
+
* const session = await client.createDcApiPresentationRequest({
|
|
1667
|
+
* configId: 'age-over-18'
|
|
1668
|
+
* });
|
|
1669
|
+
*
|
|
1670
|
+
* // Use the requestObject with the DC API
|
|
1671
|
+
* const result = await client.submitDcApiPresentation(session);
|
|
1672
|
+
* ```
|
|
1673
|
+
*/
|
|
1674
|
+
async createDcApiPresentationRequest(options) {
|
|
1675
|
+
await this.ensureAuthenticated();
|
|
1676
|
+
const body = {
|
|
1677
|
+
response_type: "dc-api",
|
|
1678
|
+
requestId: options.configId,
|
|
1679
|
+
redirectUri: options.redirectUri
|
|
1680
|
+
};
|
|
1681
|
+
const response = await verifierOfferControllerGetOffer({
|
|
1682
|
+
body
|
|
1683
|
+
});
|
|
1684
|
+
if (!response.data) {
|
|
1685
|
+
throw new Error("Failed to create DC API presentation request");
|
|
1686
|
+
}
|
|
1687
|
+
return this.getSession(response.data.session);
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
* Submit a presentation using the Digital Credentials API.
|
|
1691
|
+
* This method handles the browser DC API call and submits the response to the verifier.
|
|
1692
|
+
*
|
|
1693
|
+
* @example
|
|
1694
|
+
* ```typescript
|
|
1695
|
+
* // Check if DC API is available
|
|
1696
|
+
* if (!isDcApiAvailable()) {
|
|
1697
|
+
* throw new Error('DC API not supported in this browser');
|
|
1698
|
+
* }
|
|
1699
|
+
*
|
|
1700
|
+
* const session = await client.createDcApiPresentationRequest({
|
|
1701
|
+
* configId: 'age-over-18'
|
|
1702
|
+
* });
|
|
1703
|
+
*
|
|
1704
|
+
* const result = await client.submitDcApiPresentation(session);
|
|
1705
|
+
* console.log('Verified credentials:', result.credentials);
|
|
1706
|
+
* ```
|
|
1707
|
+
*/
|
|
1708
|
+
async submitDcApiPresentation(session, options = {}) {
|
|
1709
|
+
if (!isDcApiAvailable()) {
|
|
1710
|
+
throw new Error(
|
|
1711
|
+
"Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
if (!session.requestObject) {
|
|
1715
|
+
throw new Error(
|
|
1716
|
+
'Session does not contain a requestObject. Make sure to create the session with response_type: "dc-api"'
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
const dcResponse = await navigator.credentials.get({
|
|
1720
|
+
mediation: "required",
|
|
1721
|
+
digital: {
|
|
1722
|
+
requests: [
|
|
1723
|
+
{
|
|
1724
|
+
protocol: "openid4vp-v1-signed",
|
|
1725
|
+
data: { request: session.requestObject }
|
|
1726
|
+
}
|
|
1727
|
+
]
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
if (!dcResponse) {
|
|
1731
|
+
throw new Error("No response from Digital Credentials API");
|
|
1732
|
+
}
|
|
1733
|
+
if (dcResponse.data?.error) {
|
|
1734
|
+
throw new Error(
|
|
1735
|
+
`Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
|
|
1736
|
+
);
|
|
1737
|
+
}
|
|
1738
|
+
const requestPayload = decodeJwtPayload(
|
|
1739
|
+
session.requestObject
|
|
1740
|
+
);
|
|
1741
|
+
if (!requestPayload.response_uri) {
|
|
1742
|
+
throw new Error("No response_uri found in request object");
|
|
1743
|
+
}
|
|
1744
|
+
const fetchImpl = this.config.fetch ?? fetch;
|
|
1745
|
+
const submitResponse = await fetchImpl(requestPayload.response_uri, {
|
|
1746
|
+
method: "POST",
|
|
1747
|
+
headers: {
|
|
1748
|
+
"Content-Type": "application/json"
|
|
1749
|
+
},
|
|
1750
|
+
body: JSON.stringify({
|
|
1751
|
+
...dcResponse.data,
|
|
1752
|
+
sendResponse: options.sendResponse ?? true
|
|
1753
|
+
})
|
|
1754
|
+
});
|
|
1755
|
+
if (!submitResponse.ok) {
|
|
1756
|
+
const errorText = await submitResponse.text();
|
|
1757
|
+
throw new Error(
|
|
1758
|
+
`Failed to submit presentation: ${submitResponse.status} ${errorText}`
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
const result = await submitResponse.json();
|
|
1762
|
+
return {
|
|
1763
|
+
credentials: result.credentials ?? result,
|
|
1764
|
+
response: result,
|
|
1765
|
+
redirectUri: result.redirect_uri
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Convenience method to create a presentation request and immediately
|
|
1770
|
+
* submit it using the Digital Credentials API.
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
* ```typescript
|
|
1774
|
+
* const result = await client.verifyWithDcApi({
|
|
1775
|
+
* configId: 'age-over-18'
|
|
1776
|
+
* });
|
|
1777
|
+
* console.log('Verified:', result.credentials);
|
|
1778
|
+
* ```
|
|
1779
|
+
*/
|
|
1780
|
+
async verifyWithDcApi(options, dcOptions = {}) {
|
|
1781
|
+
const session = await this.createDcApiPresentationRequest(options);
|
|
1782
|
+
return this.submitDcApiPresentation(session, dcOptions);
|
|
1783
|
+
}
|
|
1526
1784
|
};
|
|
1527
1785
|
async function verify(options) {
|
|
1528
1786
|
const client2 = new EudiploClient({
|
|
@@ -1569,7 +1827,118 @@ async function issueAndWait(options) {
|
|
|
1569
1827
|
options.onUri(uri);
|
|
1570
1828
|
return waitForCompletion(options.polling);
|
|
1571
1829
|
}
|
|
1830
|
+
async function verifyWithDcApi(options) {
|
|
1831
|
+
const eudiploClient = new EudiploClient({
|
|
1832
|
+
baseUrl: options.baseUrl,
|
|
1833
|
+
clientId: options.clientId,
|
|
1834
|
+
clientSecret: options.clientSecret
|
|
1835
|
+
});
|
|
1836
|
+
return eudiploClient.verifyWithDcApi(
|
|
1837
|
+
{
|
|
1838
|
+
configId: options.configId,
|
|
1839
|
+
redirectUri: options.redirectUri
|
|
1840
|
+
},
|
|
1841
|
+
{
|
|
1842
|
+
sendResponse: options.sendResponse
|
|
1843
|
+
}
|
|
1844
|
+
);
|
|
1845
|
+
}
|
|
1846
|
+
async function createDcApiRequest(options) {
|
|
1847
|
+
const eudiploClient = new EudiploClient({
|
|
1848
|
+
baseUrl: options.baseUrl,
|
|
1849
|
+
clientId: options.clientId,
|
|
1850
|
+
clientSecret: options.clientSecret
|
|
1851
|
+
});
|
|
1852
|
+
const session = await eudiploClient.createDcApiPresentationRequest({
|
|
1853
|
+
configId: options.configId,
|
|
1854
|
+
redirectUri: options.redirectUri
|
|
1855
|
+
});
|
|
1856
|
+
return {
|
|
1857
|
+
session,
|
|
1858
|
+
submit: (dcOptions) => eudiploClient.submitDcApiPresentation(session, {
|
|
1859
|
+
sendResponse: options.sendResponse,
|
|
1860
|
+
...dcOptions
|
|
1861
|
+
})
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
async function createDcApiRequestForBrowser(options) {
|
|
1865
|
+
const eudiploClient = new EudiploClient({
|
|
1866
|
+
baseUrl: options.baseUrl,
|
|
1867
|
+
clientId: options.clientId,
|
|
1868
|
+
clientSecret: options.clientSecret
|
|
1869
|
+
});
|
|
1870
|
+
const session = await eudiploClient.createDcApiPresentationRequest({
|
|
1871
|
+
configId: options.configId,
|
|
1872
|
+
redirectUri: options.redirectUri
|
|
1873
|
+
});
|
|
1874
|
+
if (!session.requestObject) {
|
|
1875
|
+
throw new Error("Session does not contain a requestObject");
|
|
1876
|
+
}
|
|
1877
|
+
const requestPayload = decodeJwtPayload(
|
|
1878
|
+
session.requestObject
|
|
1879
|
+
);
|
|
1880
|
+
if (!requestPayload.response_uri) {
|
|
1881
|
+
throw new Error("No response_uri found in request object");
|
|
1882
|
+
}
|
|
1883
|
+
return {
|
|
1884
|
+
requestObject: session.requestObject,
|
|
1885
|
+
sessionId: session.id,
|
|
1886
|
+
responseUri: requestPayload.response_uri
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
async function callDcApi(requestObject) {
|
|
1890
|
+
if (!isDcApiAvailable()) {
|
|
1891
|
+
throw new Error(
|
|
1892
|
+
"Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
const dcResponse = await navigator.credentials.get({
|
|
1896
|
+
mediation: "required",
|
|
1897
|
+
digital: {
|
|
1898
|
+
requests: [
|
|
1899
|
+
{
|
|
1900
|
+
protocol: "openid4vp-v1-signed",
|
|
1901
|
+
data: { request: requestObject }
|
|
1902
|
+
}
|
|
1903
|
+
]
|
|
1904
|
+
}
|
|
1905
|
+
});
|
|
1906
|
+
if (!dcResponse) {
|
|
1907
|
+
throw new Error("No response from Digital Credentials API");
|
|
1908
|
+
}
|
|
1909
|
+
if (dcResponse.data?.error) {
|
|
1910
|
+
throw new Error(
|
|
1911
|
+
`Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
|
|
1912
|
+
);
|
|
1913
|
+
}
|
|
1914
|
+
return dcResponse.data;
|
|
1915
|
+
}
|
|
1916
|
+
async function submitDcApiWalletResponse(options) {
|
|
1917
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
1918
|
+
const submitResponse = await fetchImpl(options.responseUri, {
|
|
1919
|
+
method: "POST",
|
|
1920
|
+
headers: {
|
|
1921
|
+
"Content-Type": "application/json"
|
|
1922
|
+
},
|
|
1923
|
+
body: JSON.stringify({
|
|
1924
|
+
...options.walletResponse,
|
|
1925
|
+
sendResponse: options.sendResponse ?? true
|
|
1926
|
+
})
|
|
1927
|
+
});
|
|
1928
|
+
if (!submitResponse.ok) {
|
|
1929
|
+
const errorText = await submitResponse.text();
|
|
1930
|
+
throw new Error(
|
|
1931
|
+
`Failed to submit presentation: ${submitResponse.status} ${errorText}`
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
const result = await submitResponse.json();
|
|
1935
|
+
return {
|
|
1936
|
+
credentials: result.credentials ?? result,
|
|
1937
|
+
response: result,
|
|
1938
|
+
redirectUri: result.redirect_uri
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1572
1941
|
|
|
1573
|
-
export { EudiploClient, appControllerMain, authControllerGetGlobalJwks, authControllerGetOAuth2Token, authControllerGetOidcDiscovery, authorizeControllerAuthorizationChallengeEndpoint, authorizeControllerAuthorize, authorizeControllerPar, authorizeControllerToken, certControllerAddCertificate, certControllerDeleteCertificate, certControllerExportConfig, certControllerGetCertificate, certControllerGetCertificates, certControllerUpdateCertificate, client, clientControllerCreateClient, clientControllerDeleteClient, clientControllerGetClient, clientControllerGetClientSecret, clientControllerGetClients, clientControllerUpdateClient, credentialConfigControllerDeleteIssuanceConfiguration, credentialConfigControllerGetConfigById, credentialConfigControllerGetConfigs, credentialConfigControllerStoreCredentialConfiguration, credentialConfigControllerUpdateCredentialConfiguration, credentialOfferControllerGetOffer, healthControllerCheck, issuanceConfigControllerGetIssuanceConfigurations, issuanceConfigControllerStoreIssuanceConfiguration, issue, issueAndWait, keyControllerAddKey, keyControllerDeleteKey, keyControllerGetKey, keyControllerGetKeys, keyControllerUpdateKey, oid4VciControllerCredential, oid4VciControllerNonce, oid4VciControllerNotifications, oid4VciMetadataControllerVct, oid4VpControllerGetPostRequestWithSession, oid4VpControllerGetRequestWithSession, oid4VpControllerGetResponse, presentationManagementControllerConfiguration, presentationManagementControllerDeleteConfiguration, presentationManagementControllerGetConfiguration, presentationManagementControllerStorePresentationConfig, presentationManagementControllerUpdateConfiguration, prometheusControllerIndex, sessionConfigControllerGetConfig, sessionConfigControllerResetConfig, sessionConfigControllerUpdateConfig, sessionControllerDeleteSession, sessionControllerGetAllSessions, sessionControllerGetSession, sessionControllerRevokeAll, statusListConfigControllerGetConfig, statusListConfigControllerResetConfig, statusListConfigControllerUpdateConfig, statusListControllerGetList, statusListControllerGetStatusListAggregation, statusListManagementControllerCreateList, statusListManagementControllerDeleteList, statusListManagementControllerGetList, statusListManagementControllerGetLists, statusListManagementControllerUpdateList, storageControllerDownload, storageControllerUpload, tenantControllerDeleteTenant, tenantControllerGetTenant, tenantControllerGetTenants, tenantControllerInitTenant, tenantControllerUpdateTenant, trustListControllerCreateTrustList, trustListControllerDeleteTrustList, trustListControllerExportTrustList, trustListControllerGetAllTrustLists, trustListControllerGetTrustList, trustListControllerGetTrustListVersion, trustListControllerGetTrustListVersions, trustListControllerUpdateTrustList, trustListPublicControllerGetTrustListJwt, verifierOfferControllerGetOffer, verify, verifyAndWait, wellKnownControllerAuthzMetadata0, wellKnownControllerAuthzMetadata1, wellKnownControllerGetJwks0, wellKnownControllerGetJwks1, wellKnownControllerIssuerMetadata0, wellKnownControllerIssuerMetadata1 };
|
|
1942
|
+
export { EudiploClient, appControllerMain, authControllerGetGlobalJwks, authControllerGetOAuth2Token, authControllerGetOidcDiscovery, authorizeControllerAuthorizationChallengeEndpoint, authorizeControllerAuthorize, authorizeControllerPar, authorizeControllerToken, cacheControllerClearAllCaches, cacheControllerClearStatusListCache, cacheControllerClearTrustListCache, cacheControllerGetStats, callDcApi, certControllerAddCertificate, certControllerDeleteCertificate, certControllerExportConfig, certControllerGetCertificate, certControllerGetCertificates, certControllerUpdateCertificate, client, clientControllerCreateClient, clientControllerDeleteClient, clientControllerGetClient, clientControllerGetClientSecret, clientControllerGetClients, clientControllerRotateClientSecret, clientControllerUpdateClient, createDcApiRequest, createDcApiRequestForBrowser, credentialConfigControllerDeleteIssuanceConfiguration, credentialConfigControllerGetConfigById, credentialConfigControllerGetConfigs, credentialConfigControllerStoreCredentialConfiguration, credentialConfigControllerUpdateCredentialConfiguration, credentialOfferControllerGetOffer, deferredControllerCompleteDeferred, deferredControllerFailDeferred, healthControllerCheck, interactiveAuthorizationControllerCompleteWebAuth, interactiveAuthorizationControllerInteractiveAuthorization, isDcApiAvailable, issuanceConfigControllerGetIssuanceConfigurations, issuanceConfigControllerStoreIssuanceConfiguration, issue, issueAndWait, keyControllerAddKey, keyControllerDeleteKey, keyControllerGetKey, keyControllerGetKeys, keyControllerUpdateKey, oid4VciControllerCredential, oid4VciControllerDeferredCredential, oid4VciControllerNonce, oid4VciControllerNotifications, oid4VciMetadataControllerVct, oid4VpControllerGetPostRequestWithSession, oid4VpControllerGetRequestNoRedirectWithSession, oid4VpControllerGetRequestWithSession, oid4VpControllerGetResponse, presentationManagementControllerConfiguration, presentationManagementControllerDeleteConfiguration, presentationManagementControllerGetConfiguration, presentationManagementControllerStorePresentationConfig, presentationManagementControllerUpdateConfiguration, prometheusControllerIndex, registrarControllerCreateAccessCertificate, registrarControllerCreateConfig, registrarControllerDeleteConfig, registrarControllerGetConfig, registrarControllerUpdateConfig, sessionConfigControllerGetConfig, sessionConfigControllerResetConfig, sessionConfigControllerUpdateConfig, sessionControllerDeleteSession, sessionControllerGetAllSessions, sessionControllerGetSession, sessionControllerRevokeAll, statusListConfigControllerGetConfig, statusListConfigControllerResetConfig, statusListConfigControllerUpdateConfig, statusListControllerGetList, statusListControllerGetStatusListAggregation, statusListManagementControllerCreateList, statusListManagementControllerDeleteList, statusListManagementControllerGetList, statusListManagementControllerGetLists, statusListManagementControllerUpdateList, storageControllerDownload, storageControllerUpload, submitDcApiWalletResponse, tenantControllerDeleteTenant, tenantControllerGetTenant, tenantControllerGetTenants, tenantControllerInitTenant, tenantControllerUpdateTenant, trustListControllerCreateTrustList, trustListControllerDeleteTrustList, trustListControllerExportTrustList, trustListControllerGetAllTrustLists, trustListControllerGetTrustList, trustListControllerGetTrustListVersion, trustListControllerGetTrustListVersions, trustListControllerUpdateTrustList, trustListPublicControllerGetTrustListJwt, verifierOfferControllerGetOffer, verify, verifyAndWait, verifyWithDcApi, wellKnownControllerAuthzMetadata0, wellKnownControllerAuthzMetadata1, wellKnownControllerGetJwks0, wellKnownControllerGetJwks1, wellKnownControllerIssuerMetadata0, wellKnownControllerIssuerMetadata1 };
|
|
1574
1943
|
//# sourceMappingURL=index.mjs.map
|
|
1575
1944
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -325,4 +325,4 @@ interface TDataShape {
|
|
|
325
325
|
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
326
326
|
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = "fields"> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, "body" | "path" | "query" | "url"> & ([TData] extends [never] ? unknown : Omit<TData, "url">);
|
|
327
327
|
|
|
328
|
-
export { type Auth as A, type
|
|
328
|
+
export { type Auth as A, type Client as C, type Options as O, type QuerySerializerOptions as Q, type RequestOptions as R, type TDataShape as T, type ClientOptions as a, type Config as b, type CreateClientConfig as c, type RequestResult as d, type ResolvedRequestOptions as e, type ResponseStyle as f, createConfig as g, formDataBodySerializer as h, jsonBodySerializer as j, mergeHeaders as m, urlSearchParamsBodySerializer as u };
|
|
@@ -325,4 +325,4 @@ interface TDataShape {
|
|
|
325
325
|
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
326
326
|
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = "fields"> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, "body" | "path" | "query" | "url"> & ([TData] extends [never] ? unknown : Omit<TData, "url">);
|
|
327
327
|
|
|
328
|
-
export { type Auth as A, type
|
|
328
|
+
export { type Auth as A, type Client as C, type Options as O, type QuerySerializerOptions as Q, type RequestOptions as R, type TDataShape as T, type ClientOptions as a, type Config as b, type CreateClientConfig as c, type RequestResult as d, type ResolvedRequestOptions as e, type ResponseStyle as f, createConfig as g, formDataBodySerializer as h, jsonBodySerializer as j, mergeHeaders as m, urlSearchParamsBodySerializer as u };
|