@eudiplo/sdk-core 8.0.2 → 8.1.0-main.1c091cc
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 +7 -2
- package/dist/api/client.gen.d.mts +1 -1
- package/dist/api/client.gen.d.ts +1 -1
- package/dist/api/index.d.mts +18 -6
- package/dist/api/index.d.ts +18 -6
- package/dist/api/index.js +25 -3
- package/dist/api/index.mjs +23 -4
- package/dist/index.d.mts +20 -9
- package/dist/index.d.ts +20 -9
- package/dist/index.js +92 -55
- package/dist/index.mjs +90 -56
- package/dist/{types.gen-Cnavg2yI.d.mts → types.gen-lZIdbe_8.d.mts} +163 -24
- package/dist/{types.gen-Cnavg2yI.d.ts → types.gen-lZIdbe_8.d.ts} +163 -24
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1155,7 +1155,11 @@ var sessionConfigControllerUpdateConfig = (options) => (options.client ?? client
|
|
|
1155
1155
|
...options.headers
|
|
1156
1156
|
}
|
|
1157
1157
|
});
|
|
1158
|
-
var sessionEventsControllerSubscribeToSessionEvents = (options) => (options.client ?? client).sse.get({
|
|
1158
|
+
var sessionEventsControllerSubscribeToSessionEvents = (options) => (options.client ?? client).sse.get({
|
|
1159
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1160
|
+
url: "/api/session/{id}/events",
|
|
1161
|
+
...options
|
|
1162
|
+
});
|
|
1159
1163
|
var statusListConfigControllerResetConfig = (options) => (options?.client ?? client).delete({
|
|
1160
1164
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1161
1165
|
url: "/api/status-list-config",
|
|
@@ -1592,16 +1596,31 @@ var configPortabilityControllerPlanArchive = (options) => (options?.client ?? cl
|
|
|
1592
1596
|
url: "/api/config-bundles/plan/archive",
|
|
1593
1597
|
...options
|
|
1594
1598
|
});
|
|
1595
|
-
var configPortabilityControllerImport = (options) => (options
|
|
1599
|
+
var configPortabilityControllerImport = (options) => (options.client ?? client).post({
|
|
1596
1600
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1597
1601
|
url: "/api/config-bundles/import",
|
|
1598
1602
|
...options
|
|
1599
1603
|
});
|
|
1600
|
-
var configPortabilityControllerImportArchive = (options) => (options
|
|
1604
|
+
var configPortabilityControllerImportArchive = (options) => (options.client ?? client).post({
|
|
1601
1605
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1602
1606
|
url: "/api/config-bundles/import/archive",
|
|
1603
1607
|
...options
|
|
1604
1608
|
});
|
|
1609
|
+
var configPortabilityControllerOperations = (options) => (options?.client ?? client).get({
|
|
1610
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1611
|
+
url: "/api/config-bundles/operations",
|
|
1612
|
+
...options
|
|
1613
|
+
});
|
|
1614
|
+
var configPortabilityControllerOperation = (options) => (options.client ?? client).get({
|
|
1615
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1616
|
+
url: "/api/config-bundles/operations/{id}",
|
|
1617
|
+
...options
|
|
1618
|
+
});
|
|
1619
|
+
var configPortabilityControllerAcknowledgeInterruption = (options) => (options.client ?? client).post({
|
|
1620
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1621
|
+
url: "/api/config-bundles/operations/{id}/acknowledge-interruption",
|
|
1622
|
+
...options
|
|
1623
|
+
});
|
|
1605
1624
|
var configPortabilityControllerUpgrade = (options) => (options?.client ?? client).post({
|
|
1606
1625
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1607
1626
|
url: "/api/config-bundles/documents/upgrade",
|
|
@@ -1652,6 +1671,14 @@ function mapDcApiPresentationResult(result) {
|
|
|
1652
1671
|
redirectUri: result?.redirect_uri
|
|
1653
1672
|
};
|
|
1654
1673
|
}
|
|
1674
|
+
function isTerminalStatus(status) {
|
|
1675
|
+
return status === "completed" || status === "expired" || status === "failed";
|
|
1676
|
+
}
|
|
1677
|
+
function withoutTrailingSlashes(url) {
|
|
1678
|
+
let end = url.length;
|
|
1679
|
+
while (end > 0 && url[end - 1] === "/") end--;
|
|
1680
|
+
return url.slice(0, end);
|
|
1681
|
+
}
|
|
1655
1682
|
var EudiploClient = class {
|
|
1656
1683
|
config;
|
|
1657
1684
|
accessToken;
|
|
@@ -1660,10 +1687,12 @@ var EudiploClient = class {
|
|
|
1660
1687
|
constructor(config) {
|
|
1661
1688
|
this.config = {
|
|
1662
1689
|
autoRefresh: true,
|
|
1663
|
-
...config
|
|
1690
|
+
...config,
|
|
1691
|
+
// Hand-written URLs append paths with a leading slash.
|
|
1692
|
+
baseUrl: withoutTrailingSlashes(config.baseUrl)
|
|
1664
1693
|
};
|
|
1665
1694
|
client.setConfig({
|
|
1666
|
-
baseUrl: config.baseUrl,
|
|
1695
|
+
baseUrl: this.config.baseUrl,
|
|
1667
1696
|
fetch: config.fetch
|
|
1668
1697
|
});
|
|
1669
1698
|
}
|
|
@@ -1741,7 +1770,8 @@ var EudiploClient = class {
|
|
|
1741
1770
|
credentialConfigurationIds: options.credentialConfigurationIds,
|
|
1742
1771
|
flow: options.flow ?? "pre_authorized_code",
|
|
1743
1772
|
tx_code: options.txCode,
|
|
1744
|
-
authorization_server: options.authorizationServer
|
|
1773
|
+
authorization_server: options.authorizationServer,
|
|
1774
|
+
reference: options.reference
|
|
1745
1775
|
};
|
|
1746
1776
|
if (options.claims) {
|
|
1747
1777
|
const credentialClaims = {};
|
|
@@ -1798,6 +1828,7 @@ var EudiploClient = class {
|
|
|
1798
1828
|
requestId: options.configId,
|
|
1799
1829
|
redirectUri: options.redirectUri,
|
|
1800
1830
|
skewSeconds: options.skewSeconds,
|
|
1831
|
+
reference: options.reference,
|
|
1801
1832
|
expected_origin: options.responseType === "dc-api" ? inferredOrigin : void 0
|
|
1802
1833
|
};
|
|
1803
1834
|
const response = await verifierOfferControllerGetOffer({
|
|
@@ -1896,17 +1927,16 @@ var EudiploClient = class {
|
|
|
1896
1927
|
/**
|
|
1897
1928
|
* Subscribe to real-time session status updates via Server-Sent Events.
|
|
1898
1929
|
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1930
|
+
* The stream is read with `fetch` and the client's access token in the
|
|
1931
|
+
* `Authorization` header, so it works in browsers and in Node.js 18+. The
|
|
1932
|
+
* first event carries the current status; the stream ends after a terminal
|
|
1933
|
+
* status. Failed connections are retried up to three times in total.
|
|
1901
1934
|
*
|
|
1902
1935
|
* @example
|
|
1903
1936
|
* ```typescript
|
|
1904
1937
|
* const subscription = await client.subscribeToSession(sessionId, {
|
|
1905
1938
|
* onStatusChange: (event) => {
|
|
1906
1939
|
* console.log(`Status: ${event.status}`);
|
|
1907
|
-
* if (['completed', 'expired', 'failed'].includes(event.status)) {
|
|
1908
|
-
* subscription.close();
|
|
1909
|
-
* }
|
|
1910
1940
|
* },
|
|
1911
1941
|
* onError: (error) => console.error('SSE error:', error)
|
|
1912
1942
|
* });
|
|
@@ -1916,41 +1946,38 @@ var EudiploClient = class {
|
|
|
1916
1946
|
* ```
|
|
1917
1947
|
*/
|
|
1918
1948
|
async subscribeToSession(sessionId, options = {}) {
|
|
1919
|
-
|
|
1920
|
-
const
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
if (typeof EventSource === "undefined") {
|
|
1925
|
-
throw new Error(
|
|
1926
|
-
"EventSource is not available in this environment. Use polling with waitForSession() instead, or provide a polyfill."
|
|
1927
|
-
);
|
|
1928
|
-
}
|
|
1929
|
-
const url = `${this.config.baseUrl}/session/${sessionId}/events?token=${encodeURIComponent(token)}`;
|
|
1930
|
-
const eventSource = new EventSource(url);
|
|
1931
|
-
eventSource.onopen = () => {
|
|
1932
|
-
options.onOpen?.();
|
|
1949
|
+
const abort = new AbortController();
|
|
1950
|
+
const report = (error) => {
|
|
1951
|
+
if (!abort.signal.aborted) {
|
|
1952
|
+
options.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
1953
|
+
}
|
|
1933
1954
|
};
|
|
1934
|
-
|
|
1955
|
+
const stream = await this.sessionEvents(sessionId, abort.signal, report);
|
|
1956
|
+
void (async () => {
|
|
1957
|
+
let opened = false;
|
|
1935
1958
|
try {
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1959
|
+
for await (const event of stream) {
|
|
1960
|
+
if (!opened) {
|
|
1961
|
+
opened = true;
|
|
1962
|
+
options.onOpen?.();
|
|
1963
|
+
}
|
|
1964
|
+
options.onStatusChange?.(event);
|
|
1965
|
+
if (isTerminalStatus(event.status)) return;
|
|
1966
|
+
}
|
|
1967
|
+
report(new Error(`Session event stream for ${sessionId} ended before a final status`));
|
|
1938
1968
|
} catch (error) {
|
|
1939
|
-
|
|
1969
|
+
report(error);
|
|
1940
1970
|
}
|
|
1941
|
-
};
|
|
1942
|
-
eventSource.onerror = () => {
|
|
1943
|
-
options.onError?.(new Error("SSE connection error"));
|
|
1944
|
-
};
|
|
1971
|
+
})();
|
|
1945
1972
|
return {
|
|
1946
|
-
close: () =>
|
|
1973
|
+
close: () => abort.abort()
|
|
1947
1974
|
};
|
|
1948
1975
|
}
|
|
1949
1976
|
/**
|
|
1950
1977
|
* Subscribe to session and wait for completion via SSE.
|
|
1951
1978
|
*
|
|
1952
1979
|
* Returns a Promise that resolves when the session completes,
|
|
1953
|
-
* or rejects if it fails/expires.
|
|
1980
|
+
* or rejects if it fails/expires or the stream cannot be read.
|
|
1954
1981
|
*
|
|
1955
1982
|
* @example
|
|
1956
1983
|
* ```typescript
|
|
@@ -1963,27 +1990,33 @@ var EudiploClient = class {
|
|
|
1963
1990
|
* ```
|
|
1964
1991
|
*/
|
|
1965
1992
|
async waitForSessionWithSse(sessionId, options = {}) {
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
subscription.close();
|
|
1976
|
-
reject(new Error(`Session ${event.status}: ${sessionId}`));
|
|
1977
|
-
}
|
|
1978
|
-
},
|
|
1979
|
-
onError: (error) => {
|
|
1980
|
-
console.warn("SSE connection error, reconnecting...", error);
|
|
1981
|
-
}
|
|
1982
|
-
});
|
|
1983
|
-
} catch (error) {
|
|
1984
|
-
reject(error);
|
|
1993
|
+
let lastError;
|
|
1994
|
+
const stream = await this.sessionEvents(sessionId, void 0, (error) => {
|
|
1995
|
+
lastError = error;
|
|
1996
|
+
});
|
|
1997
|
+
for await (const event of stream) {
|
|
1998
|
+
options.onStatusChange?.(event);
|
|
1999
|
+
if (event.status === "completed") return event;
|
|
2000
|
+
if (isTerminalStatus(event.status)) {
|
|
2001
|
+
throw new Error(`Session ${event.status}: ${sessionId}`);
|
|
1985
2002
|
}
|
|
2003
|
+
}
|
|
2004
|
+
throw new Error(
|
|
2005
|
+
`Session event stream for ${sessionId} ended before a final status` + (lastError ? `: ${lastError instanceof Error ? lastError.message : String(lastError)}` : "")
|
|
2006
|
+
);
|
|
2007
|
+
}
|
|
2008
|
+
/** Opens the event stream of a session with the current access token. */
|
|
2009
|
+
async sessionEvents(sessionId, signal, onError) {
|
|
2010
|
+
await this.ensureAuthenticated();
|
|
2011
|
+
const { stream } = await sessionEventsControllerSubscribeToSessionEvents({
|
|
2012
|
+
path: { id: sessionId },
|
|
2013
|
+
signal,
|
|
2014
|
+
// The stream starts with the current status, so a reconnect misses
|
|
2015
|
+
// nothing. 401, 403 and 404 do not go away, so stop retrying soon.
|
|
2016
|
+
sseMaxRetryAttempts: 3,
|
|
2017
|
+
onSseError: onError
|
|
1986
2018
|
});
|
|
2019
|
+
return stream;
|
|
1987
2020
|
}
|
|
1988
2021
|
/**
|
|
1989
2022
|
* Get the current access token (for advanced usage)
|
|
@@ -2021,6 +2054,7 @@ var EudiploClient = class {
|
|
|
2021
2054
|
response_type: "dc-api",
|
|
2022
2055
|
requestId: options.configId,
|
|
2023
2056
|
redirectUri: options.redirectUri,
|
|
2057
|
+
reference: options.reference,
|
|
2024
2058
|
expected_origin: inferredOrigin
|
|
2025
2059
|
};
|
|
2026
2060
|
const response = await verifierOfferControllerGetOffer({
|
|
@@ -2034,7 +2068,7 @@ var EudiploClient = class {
|
|
|
2034
2068
|
return session;
|
|
2035
2069
|
}
|
|
2036
2070
|
const nonceOrId = session.walletNonce ?? session.id;
|
|
2037
|
-
const requestObjectUrl = `${this.config.baseUrl}/
|
|
2071
|
+
const requestObjectUrl = `${this.config.baseUrl}/presentations/${encodeURIComponent(nonceOrId)}/oid4vp/request`;
|
|
2038
2072
|
const fetchImpl = this.config.fetch ?? fetch;
|
|
2039
2073
|
const requestObjectResponse = await fetchImpl(requestObjectUrl, {
|
|
2040
2074
|
method: "GET",
|
|
@@ -2459,10 +2493,13 @@ exports.clientControllerGetClient = clientControllerGetClient;
|
|
|
2459
2493
|
exports.clientControllerGetClients = clientControllerGetClients;
|
|
2460
2494
|
exports.clientControllerRotateClientSecret = clientControllerRotateClientSecret;
|
|
2461
2495
|
exports.clientControllerUpdateClient = clientControllerUpdateClient;
|
|
2496
|
+
exports.configPortabilityControllerAcknowledgeInterruption = configPortabilityControllerAcknowledgeInterruption;
|
|
2462
2497
|
exports.configPortabilityControllerDetach = configPortabilityControllerDetach;
|
|
2463
2498
|
exports.configPortabilityControllerExport = configPortabilityControllerExport;
|
|
2464
2499
|
exports.configPortabilityControllerImport = configPortabilityControllerImport;
|
|
2465
2500
|
exports.configPortabilityControllerImportArchive = configPortabilityControllerImportArchive;
|
|
2501
|
+
exports.configPortabilityControllerOperation = configPortabilityControllerOperation;
|
|
2502
|
+
exports.configPortabilityControllerOperations = configPortabilityControllerOperations;
|
|
2466
2503
|
exports.configPortabilityControllerPlan = configPortabilityControllerPlan;
|
|
2467
2504
|
exports.configPortabilityControllerPlanArchive = configPortabilityControllerPlanArchive;
|
|
2468
2505
|
exports.configPortabilityControllerResources = configPortabilityControllerResources;
|
package/dist/index.mjs
CHANGED
|
@@ -1153,7 +1153,11 @@ var sessionConfigControllerUpdateConfig = (options) => (options.client ?? client
|
|
|
1153
1153
|
...options.headers
|
|
1154
1154
|
}
|
|
1155
1155
|
});
|
|
1156
|
-
var sessionEventsControllerSubscribeToSessionEvents = (options) => (options.client ?? client).sse.get({
|
|
1156
|
+
var sessionEventsControllerSubscribeToSessionEvents = (options) => (options.client ?? client).sse.get({
|
|
1157
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1158
|
+
url: "/api/session/{id}/events",
|
|
1159
|
+
...options
|
|
1160
|
+
});
|
|
1157
1161
|
var statusListConfigControllerResetConfig = (options) => (options?.client ?? client).delete({
|
|
1158
1162
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1159
1163
|
url: "/api/status-list-config",
|
|
@@ -1590,16 +1594,31 @@ var configPortabilityControllerPlanArchive = (options) => (options?.client ?? cl
|
|
|
1590
1594
|
url: "/api/config-bundles/plan/archive",
|
|
1591
1595
|
...options
|
|
1592
1596
|
});
|
|
1593
|
-
var configPortabilityControllerImport = (options) => (options
|
|
1597
|
+
var configPortabilityControllerImport = (options) => (options.client ?? client).post({
|
|
1594
1598
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1595
1599
|
url: "/api/config-bundles/import",
|
|
1596
1600
|
...options
|
|
1597
1601
|
});
|
|
1598
|
-
var configPortabilityControllerImportArchive = (options) => (options
|
|
1602
|
+
var configPortabilityControllerImportArchive = (options) => (options.client ?? client).post({
|
|
1599
1603
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1600
1604
|
url: "/api/config-bundles/import/archive",
|
|
1601
1605
|
...options
|
|
1602
1606
|
});
|
|
1607
|
+
var configPortabilityControllerOperations = (options) => (options?.client ?? client).get({
|
|
1608
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1609
|
+
url: "/api/config-bundles/operations",
|
|
1610
|
+
...options
|
|
1611
|
+
});
|
|
1612
|
+
var configPortabilityControllerOperation = (options) => (options.client ?? client).get({
|
|
1613
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1614
|
+
url: "/api/config-bundles/operations/{id}",
|
|
1615
|
+
...options
|
|
1616
|
+
});
|
|
1617
|
+
var configPortabilityControllerAcknowledgeInterruption = (options) => (options.client ?? client).post({
|
|
1618
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1619
|
+
url: "/api/config-bundles/operations/{id}/acknowledge-interruption",
|
|
1620
|
+
...options
|
|
1621
|
+
});
|
|
1603
1622
|
var configPortabilityControllerUpgrade = (options) => (options?.client ?? client).post({
|
|
1604
1623
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1605
1624
|
url: "/api/config-bundles/documents/upgrade",
|
|
@@ -1650,6 +1669,14 @@ function mapDcApiPresentationResult(result) {
|
|
|
1650
1669
|
redirectUri: result?.redirect_uri
|
|
1651
1670
|
};
|
|
1652
1671
|
}
|
|
1672
|
+
function isTerminalStatus(status) {
|
|
1673
|
+
return status === "completed" || status === "expired" || status === "failed";
|
|
1674
|
+
}
|
|
1675
|
+
function withoutTrailingSlashes(url) {
|
|
1676
|
+
let end = url.length;
|
|
1677
|
+
while (end > 0 && url[end - 1] === "/") end--;
|
|
1678
|
+
return url.slice(0, end);
|
|
1679
|
+
}
|
|
1653
1680
|
var EudiploClient = class {
|
|
1654
1681
|
config;
|
|
1655
1682
|
accessToken;
|
|
@@ -1658,10 +1685,12 @@ var EudiploClient = class {
|
|
|
1658
1685
|
constructor(config) {
|
|
1659
1686
|
this.config = {
|
|
1660
1687
|
autoRefresh: true,
|
|
1661
|
-
...config
|
|
1688
|
+
...config,
|
|
1689
|
+
// Hand-written URLs append paths with a leading slash.
|
|
1690
|
+
baseUrl: withoutTrailingSlashes(config.baseUrl)
|
|
1662
1691
|
};
|
|
1663
1692
|
client.setConfig({
|
|
1664
|
-
baseUrl: config.baseUrl,
|
|
1693
|
+
baseUrl: this.config.baseUrl,
|
|
1665
1694
|
fetch: config.fetch
|
|
1666
1695
|
});
|
|
1667
1696
|
}
|
|
@@ -1739,7 +1768,8 @@ var EudiploClient = class {
|
|
|
1739
1768
|
credentialConfigurationIds: options.credentialConfigurationIds,
|
|
1740
1769
|
flow: options.flow ?? "pre_authorized_code",
|
|
1741
1770
|
tx_code: options.txCode,
|
|
1742
|
-
authorization_server: options.authorizationServer
|
|
1771
|
+
authorization_server: options.authorizationServer,
|
|
1772
|
+
reference: options.reference
|
|
1743
1773
|
};
|
|
1744
1774
|
if (options.claims) {
|
|
1745
1775
|
const credentialClaims = {};
|
|
@@ -1796,6 +1826,7 @@ var EudiploClient = class {
|
|
|
1796
1826
|
requestId: options.configId,
|
|
1797
1827
|
redirectUri: options.redirectUri,
|
|
1798
1828
|
skewSeconds: options.skewSeconds,
|
|
1829
|
+
reference: options.reference,
|
|
1799
1830
|
expected_origin: options.responseType === "dc-api" ? inferredOrigin : void 0
|
|
1800
1831
|
};
|
|
1801
1832
|
const response = await verifierOfferControllerGetOffer({
|
|
@@ -1894,17 +1925,16 @@ var EudiploClient = class {
|
|
|
1894
1925
|
/**
|
|
1895
1926
|
* Subscribe to real-time session status updates via Server-Sent Events.
|
|
1896
1927
|
*
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1928
|
+
* The stream is read with `fetch` and the client's access token in the
|
|
1929
|
+
* `Authorization` header, so it works in browsers and in Node.js 18+. The
|
|
1930
|
+
* first event carries the current status; the stream ends after a terminal
|
|
1931
|
+
* status. Failed connections are retried up to three times in total.
|
|
1899
1932
|
*
|
|
1900
1933
|
* @example
|
|
1901
1934
|
* ```typescript
|
|
1902
1935
|
* const subscription = await client.subscribeToSession(sessionId, {
|
|
1903
1936
|
* onStatusChange: (event) => {
|
|
1904
1937
|
* console.log(`Status: ${event.status}`);
|
|
1905
|
-
* if (['completed', 'expired', 'failed'].includes(event.status)) {
|
|
1906
|
-
* subscription.close();
|
|
1907
|
-
* }
|
|
1908
1938
|
* },
|
|
1909
1939
|
* onError: (error) => console.error('SSE error:', error)
|
|
1910
1940
|
* });
|
|
@@ -1914,41 +1944,38 @@ var EudiploClient = class {
|
|
|
1914
1944
|
* ```
|
|
1915
1945
|
*/
|
|
1916
1946
|
async subscribeToSession(sessionId, options = {}) {
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
if (typeof EventSource === "undefined") {
|
|
1923
|
-
throw new Error(
|
|
1924
|
-
"EventSource is not available in this environment. Use polling with waitForSession() instead, or provide a polyfill."
|
|
1925
|
-
);
|
|
1926
|
-
}
|
|
1927
|
-
const url = `${this.config.baseUrl}/session/${sessionId}/events?token=${encodeURIComponent(token)}`;
|
|
1928
|
-
const eventSource = new EventSource(url);
|
|
1929
|
-
eventSource.onopen = () => {
|
|
1930
|
-
options.onOpen?.();
|
|
1947
|
+
const abort = new AbortController();
|
|
1948
|
+
const report = (error) => {
|
|
1949
|
+
if (!abort.signal.aborted) {
|
|
1950
|
+
options.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
1951
|
+
}
|
|
1931
1952
|
};
|
|
1932
|
-
|
|
1953
|
+
const stream = await this.sessionEvents(sessionId, abort.signal, report);
|
|
1954
|
+
void (async () => {
|
|
1955
|
+
let opened = false;
|
|
1933
1956
|
try {
|
|
1934
|
-
const
|
|
1935
|
-
|
|
1957
|
+
for await (const event of stream) {
|
|
1958
|
+
if (!opened) {
|
|
1959
|
+
opened = true;
|
|
1960
|
+
options.onOpen?.();
|
|
1961
|
+
}
|
|
1962
|
+
options.onStatusChange?.(event);
|
|
1963
|
+
if (isTerminalStatus(event.status)) return;
|
|
1964
|
+
}
|
|
1965
|
+
report(new Error(`Session event stream for ${sessionId} ended before a final status`));
|
|
1936
1966
|
} catch (error) {
|
|
1937
|
-
|
|
1967
|
+
report(error);
|
|
1938
1968
|
}
|
|
1939
|
-
};
|
|
1940
|
-
eventSource.onerror = () => {
|
|
1941
|
-
options.onError?.(new Error("SSE connection error"));
|
|
1942
|
-
};
|
|
1969
|
+
})();
|
|
1943
1970
|
return {
|
|
1944
|
-
close: () =>
|
|
1971
|
+
close: () => abort.abort()
|
|
1945
1972
|
};
|
|
1946
1973
|
}
|
|
1947
1974
|
/**
|
|
1948
1975
|
* Subscribe to session and wait for completion via SSE.
|
|
1949
1976
|
*
|
|
1950
1977
|
* Returns a Promise that resolves when the session completes,
|
|
1951
|
-
* or rejects if it fails/expires.
|
|
1978
|
+
* or rejects if it fails/expires or the stream cannot be read.
|
|
1952
1979
|
*
|
|
1953
1980
|
* @example
|
|
1954
1981
|
* ```typescript
|
|
@@ -1961,27 +1988,33 @@ var EudiploClient = class {
|
|
|
1961
1988
|
* ```
|
|
1962
1989
|
*/
|
|
1963
1990
|
async waitForSessionWithSse(sessionId, options = {}) {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
subscription.close();
|
|
1974
|
-
reject(new Error(`Session ${event.status}: ${sessionId}`));
|
|
1975
|
-
}
|
|
1976
|
-
},
|
|
1977
|
-
onError: (error) => {
|
|
1978
|
-
console.warn("SSE connection error, reconnecting...", error);
|
|
1979
|
-
}
|
|
1980
|
-
});
|
|
1981
|
-
} catch (error) {
|
|
1982
|
-
reject(error);
|
|
1991
|
+
let lastError;
|
|
1992
|
+
const stream = await this.sessionEvents(sessionId, void 0, (error) => {
|
|
1993
|
+
lastError = error;
|
|
1994
|
+
});
|
|
1995
|
+
for await (const event of stream) {
|
|
1996
|
+
options.onStatusChange?.(event);
|
|
1997
|
+
if (event.status === "completed") return event;
|
|
1998
|
+
if (isTerminalStatus(event.status)) {
|
|
1999
|
+
throw new Error(`Session ${event.status}: ${sessionId}`);
|
|
1983
2000
|
}
|
|
2001
|
+
}
|
|
2002
|
+
throw new Error(
|
|
2003
|
+
`Session event stream for ${sessionId} ended before a final status` + (lastError ? `: ${lastError instanceof Error ? lastError.message : String(lastError)}` : "")
|
|
2004
|
+
);
|
|
2005
|
+
}
|
|
2006
|
+
/** Opens the event stream of a session with the current access token. */
|
|
2007
|
+
async sessionEvents(sessionId, signal, onError) {
|
|
2008
|
+
await this.ensureAuthenticated();
|
|
2009
|
+
const { stream } = await sessionEventsControllerSubscribeToSessionEvents({
|
|
2010
|
+
path: { id: sessionId },
|
|
2011
|
+
signal,
|
|
2012
|
+
// The stream starts with the current status, so a reconnect misses
|
|
2013
|
+
// nothing. 401, 403 and 404 do not go away, so stop retrying soon.
|
|
2014
|
+
sseMaxRetryAttempts: 3,
|
|
2015
|
+
onSseError: onError
|
|
1984
2016
|
});
|
|
2017
|
+
return stream;
|
|
1985
2018
|
}
|
|
1986
2019
|
/**
|
|
1987
2020
|
* Get the current access token (for advanced usage)
|
|
@@ -2019,6 +2052,7 @@ var EudiploClient = class {
|
|
|
2019
2052
|
response_type: "dc-api",
|
|
2020
2053
|
requestId: options.configId,
|
|
2021
2054
|
redirectUri: options.redirectUri,
|
|
2055
|
+
reference: options.reference,
|
|
2022
2056
|
expected_origin: inferredOrigin
|
|
2023
2057
|
};
|
|
2024
2058
|
const response = await verifierOfferControllerGetOffer({
|
|
@@ -2032,7 +2066,7 @@ var EudiploClient = class {
|
|
|
2032
2066
|
return session;
|
|
2033
2067
|
}
|
|
2034
2068
|
const nonceOrId = session.walletNonce ?? session.id;
|
|
2035
|
-
const requestObjectUrl = `${this.config.baseUrl}/
|
|
2069
|
+
const requestObjectUrl = `${this.config.baseUrl}/presentations/${encodeURIComponent(nonceOrId)}/oid4vp/request`;
|
|
2036
2070
|
const fetchImpl = this.config.fetch ?? fetch;
|
|
2037
2071
|
const requestObjectResponse = await fetchImpl(requestObjectUrl, {
|
|
2038
2072
|
method: "GET",
|
|
@@ -2427,6 +2461,6 @@ function deriveRuntimeArtifacts(fields) {
|
|
|
2427
2461
|
};
|
|
2428
2462
|
}
|
|
2429
2463
|
|
|
2430
|
-
export { EudiploClient, appControllerGetFrontendConfig, appControllerGetVersion, attributeProviderControllerCreate, attributeProviderControllerDelete, attributeProviderControllerGetAll, attributeProviderControllerGetById, attributeProviderControllerUpdate, auditLogControllerGetAuditLogs, authControllerGetOAuth2Token, buildClaims, buildClaimsByNamespace, buildClaimsMetadata, buildDisclosureFrame, buildJsonSchema, cacheControllerClearAllCaches, cacheControllerClearStatusListCache, cacheControllerClearTrustListCache, cacheControllerGetStats, chainedAsVpControllerAuthorize, chainedAsVpControllerPar, chainedAsVpControllerToken, chainedAsVpControllerVpCallback, client, clientControllerCreateClient, clientControllerDeleteClient, clientControllerGetClient, clientControllerGetClients, clientControllerRotateClientSecret, clientControllerUpdateClient, configPortabilityControllerDetach, configPortabilityControllerExport, configPortabilityControllerImport, configPortabilityControllerImportArchive, configPortabilityControllerPlan, configPortabilityControllerPlanArchive, configPortabilityControllerResources, configPortabilityControllerUpgrade, credentialConfigControllerDeleteIssuanceConfiguration, credentialConfigControllerGetConfigById, credentialConfigControllerGetConfigs, credentialConfigControllerStoreCredentialConfiguration, credentialConfigControllerUpdateCredentialConfiguration, credentialOfferControllerGetOffer, deferredControllerCompleteDeferred, deferredControllerFailDeferred, deriveRuntimeArtifacts, flattenFields, isDcApiAvailable, issuanceConfigControllerGetIssuanceConfigurations, issuanceConfigControllerReissueRegistrationCertificate, issuanceConfigControllerStoreIssuanceConfiguration, keyChainControllerCreate, keyChainControllerDelete, keyChainControllerDeleteTenantKmsConfig, keyChainControllerExport, keyChainControllerGetAll, keyChainControllerGetById, keyChainControllerGetProviders, keyChainControllerGetProvidersHealth, keyChainControllerGetTenantKmsConfig, keyChainControllerImport, keyChainControllerRotate, keyChainControllerUpdate, keyChainControllerUpdateTenantKmsConfig, presentationManagementControllerConfiguration, presentationManagementControllerDeleteConfiguration, presentationManagementControllerGetConfiguration, presentationManagementControllerListSchemaMetadataCatalog, presentationManagementControllerReissueRegistrationCertificate, presentationManagementControllerResolveIssuerMetadata, presentationManagementControllerResolveSchemaMetadata, presentationManagementControllerResolveSchemaMetadataJwt, presentationManagementControllerStorePresentationConfig, presentationManagementControllerUpdateConfiguration, registrarControllerCreateAccessCertificate, registrarControllerCreateConfig, registrarControllerDeleteConfig, registrarControllerGetConfig, registrarControllerUpdateConfig, schemaMetadataControllerDeprecateVersion, schemaMetadataControllerFindAll, schemaMetadataControllerFindOne, schemaMetadataControllerGetJwt, schemaMetadataControllerGetLatest, schemaMetadataControllerGetMine, schemaMetadataControllerGetSchema, schemaMetadataControllerGetVersions, schemaMetadataControllerGetVocabularies, schemaMetadataControllerPublishSchemaMetadata, schemaMetadataControllerPublishSchemaMetadataVersion, schemaMetadataControllerRemove, schemaMetadataControllerUpdate, sessionConfigControllerGetConfig, sessionConfigControllerResetConfig, sessionConfigControllerUpdateConfig, sessionControllerDeleteSession, sessionControllerGetAllSessions, sessionControllerGetSession, sessionControllerGetSessionLogs, sessionControllerRevokeAll, sessionEventsControllerSubscribeToSessionEvents, statusListConfigControllerGetConfig, statusListConfigControllerResetConfig, statusListConfigControllerUpdateConfig, statusListManagementControllerCreateList, statusListManagementControllerDeleteList, statusListManagementControllerGetList, statusListManagementControllerGetLists, statusListManagementControllerUpdateList, storageControllerUpload, tenantControllerDeleteTenant, tenantControllerGetTenant, tenantControllerGetTenants, tenantControllerInitTenant, tenantControllerUpdateTenant, trustListControllerCreateTrustList, trustListControllerDeleteTrustList, trustListControllerExportTrustList, trustListControllerGetAllTrustLists, trustListControllerGetTrustList, trustListControllerGetTrustListVersion, trustListControllerGetTrustListVersions, trustListControllerUpdateTrustList, userControllerCreateUser, userControllerDeleteUser, userControllerGetUser, userControllerGetUsers, userControllerUpdateUser, verifierOfferControllerGetOffer, webhookEndpointControllerCreate, webhookEndpointControllerDelete, webhookEndpointControllerGetAll, webhookEndpointControllerGetById, webhookEndpointControllerUpdate };
|
|
2464
|
+
export { EudiploClient, appControllerGetFrontendConfig, appControllerGetVersion, attributeProviderControllerCreate, attributeProviderControllerDelete, attributeProviderControllerGetAll, attributeProviderControllerGetById, attributeProviderControllerUpdate, auditLogControllerGetAuditLogs, authControllerGetOAuth2Token, buildClaims, buildClaimsByNamespace, buildClaimsMetadata, buildDisclosureFrame, buildJsonSchema, cacheControllerClearAllCaches, cacheControllerClearStatusListCache, cacheControllerClearTrustListCache, cacheControllerGetStats, chainedAsVpControllerAuthorize, chainedAsVpControllerPar, chainedAsVpControllerToken, chainedAsVpControllerVpCallback, client, clientControllerCreateClient, clientControllerDeleteClient, clientControllerGetClient, clientControllerGetClients, clientControllerRotateClientSecret, clientControllerUpdateClient, configPortabilityControllerAcknowledgeInterruption, configPortabilityControllerDetach, configPortabilityControllerExport, configPortabilityControllerImport, configPortabilityControllerImportArchive, configPortabilityControllerOperation, configPortabilityControllerOperations, configPortabilityControllerPlan, configPortabilityControllerPlanArchive, configPortabilityControllerResources, configPortabilityControllerUpgrade, credentialConfigControllerDeleteIssuanceConfiguration, credentialConfigControllerGetConfigById, credentialConfigControllerGetConfigs, credentialConfigControllerStoreCredentialConfiguration, credentialConfigControllerUpdateCredentialConfiguration, credentialOfferControllerGetOffer, deferredControllerCompleteDeferred, deferredControllerFailDeferred, deriveRuntimeArtifacts, flattenFields, isDcApiAvailable, issuanceConfigControllerGetIssuanceConfigurations, issuanceConfigControllerReissueRegistrationCertificate, issuanceConfigControllerStoreIssuanceConfiguration, keyChainControllerCreate, keyChainControllerDelete, keyChainControllerDeleteTenantKmsConfig, keyChainControllerExport, keyChainControllerGetAll, keyChainControllerGetById, keyChainControllerGetProviders, keyChainControllerGetProvidersHealth, keyChainControllerGetTenantKmsConfig, keyChainControllerImport, keyChainControllerRotate, keyChainControllerUpdate, keyChainControllerUpdateTenantKmsConfig, presentationManagementControllerConfiguration, presentationManagementControllerDeleteConfiguration, presentationManagementControllerGetConfiguration, presentationManagementControllerListSchemaMetadataCatalog, presentationManagementControllerReissueRegistrationCertificate, presentationManagementControllerResolveIssuerMetadata, presentationManagementControllerResolveSchemaMetadata, presentationManagementControllerResolveSchemaMetadataJwt, presentationManagementControllerStorePresentationConfig, presentationManagementControllerUpdateConfiguration, registrarControllerCreateAccessCertificate, registrarControllerCreateConfig, registrarControllerDeleteConfig, registrarControllerGetConfig, registrarControllerUpdateConfig, schemaMetadataControllerDeprecateVersion, schemaMetadataControllerFindAll, schemaMetadataControllerFindOne, schemaMetadataControllerGetJwt, schemaMetadataControllerGetLatest, schemaMetadataControllerGetMine, schemaMetadataControllerGetSchema, schemaMetadataControllerGetVersions, schemaMetadataControllerGetVocabularies, schemaMetadataControllerPublishSchemaMetadata, schemaMetadataControllerPublishSchemaMetadataVersion, schemaMetadataControllerRemove, schemaMetadataControllerUpdate, sessionConfigControllerGetConfig, sessionConfigControllerResetConfig, sessionConfigControllerUpdateConfig, sessionControllerDeleteSession, sessionControllerGetAllSessions, sessionControllerGetSession, sessionControllerGetSessionLogs, sessionControllerRevokeAll, sessionEventsControllerSubscribeToSessionEvents, statusListConfigControllerGetConfig, statusListConfigControllerResetConfig, statusListConfigControllerUpdateConfig, statusListManagementControllerCreateList, statusListManagementControllerDeleteList, statusListManagementControllerGetList, statusListManagementControllerGetLists, statusListManagementControllerUpdateList, storageControllerUpload, tenantControllerDeleteTenant, tenantControllerGetTenant, tenantControllerGetTenants, tenantControllerInitTenant, tenantControllerUpdateTenant, trustListControllerCreateTrustList, trustListControllerDeleteTrustList, trustListControllerExportTrustList, trustListControllerGetAllTrustLists, trustListControllerGetTrustList, trustListControllerGetTrustListVersion, trustListControllerGetTrustListVersions, trustListControllerUpdateTrustList, userControllerCreateUser, userControllerDeleteUser, userControllerGetUser, userControllerGetUsers, userControllerUpdateUser, verifierOfferControllerGetOffer, webhookEndpointControllerCreate, webhookEndpointControllerDelete, webhookEndpointControllerGetAll, webhookEndpointControllerGetById, webhookEndpointControllerUpdate };
|
|
2431
2465
|
//# sourceMappingURL=index.mjs.map
|
|
2432
2466
|
//# sourceMappingURL=index.mjs.map
|