@eudiplo/sdk-core 8.1.0-main.a83e1b5 → 8.1.0-main.d5dca08

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1667,6 +1667,11 @@ function mapDcApiPresentationResult(result) {
1667
1667
  redirectUri: result?.redirect_uri
1668
1668
  };
1669
1669
  }
1670
+ function withoutTrailingSlashes(url) {
1671
+ let end = url.length;
1672
+ while (end > 0 && url[end - 1] === "/") end--;
1673
+ return url.slice(0, end);
1674
+ }
1670
1675
  var EudiploClient = class {
1671
1676
  config;
1672
1677
  accessToken;
@@ -1675,10 +1680,12 @@ var EudiploClient = class {
1675
1680
  constructor(config) {
1676
1681
  this.config = {
1677
1682
  autoRefresh: true,
1678
- ...config
1683
+ ...config,
1684
+ // Hand-written URLs append paths with a leading slash.
1685
+ baseUrl: withoutTrailingSlashes(config.baseUrl)
1679
1686
  };
1680
1687
  client.setConfig({
1681
- baseUrl: config.baseUrl,
1688
+ baseUrl: this.config.baseUrl,
1682
1689
  fetch: config.fetch
1683
1690
  });
1684
1691
  }
@@ -1941,7 +1948,7 @@ var EudiploClient = class {
1941
1948
  "EventSource is not available in this environment. Use polling with waitForSession() instead, or provide a polyfill."
1942
1949
  );
1943
1950
  }
1944
- const url = `${this.config.baseUrl}/session/${sessionId}/events?token=${encodeURIComponent(token)}`;
1951
+ const url = `${this.config.baseUrl}/api/session/${encodeURIComponent(sessionId)}/events?token=${encodeURIComponent(token)}`;
1945
1952
  const eventSource = new EventSource(url);
1946
1953
  eventSource.onopen = () => {
1947
1954
  options.onOpen?.();
@@ -2049,7 +2056,7 @@ var EudiploClient = class {
2049
2056
  return session;
2050
2057
  }
2051
2058
  const nonceOrId = session.walletNonce ?? session.id;
2052
- const requestObjectUrl = `${this.config.baseUrl}/api/presentations/${encodeURIComponent(nonceOrId)}/oid4vp/request`;
2059
+ const requestObjectUrl = `${this.config.baseUrl}/presentations/${encodeURIComponent(nonceOrId)}/oid4vp/request`;
2053
2060
  const fetchImpl = this.config.fetch ?? fetch;
2054
2061
  const requestObjectResponse = await fetchImpl(requestObjectUrl, {
2055
2062
  method: "GET",
package/dist/index.mjs CHANGED
@@ -1665,6 +1665,11 @@ function mapDcApiPresentationResult(result) {
1665
1665
  redirectUri: result?.redirect_uri
1666
1666
  };
1667
1667
  }
1668
+ function withoutTrailingSlashes(url) {
1669
+ let end = url.length;
1670
+ while (end > 0 && url[end - 1] === "/") end--;
1671
+ return url.slice(0, end);
1672
+ }
1668
1673
  var EudiploClient = class {
1669
1674
  config;
1670
1675
  accessToken;
@@ -1673,10 +1678,12 @@ var EudiploClient = class {
1673
1678
  constructor(config) {
1674
1679
  this.config = {
1675
1680
  autoRefresh: true,
1676
- ...config
1681
+ ...config,
1682
+ // Hand-written URLs append paths with a leading slash.
1683
+ baseUrl: withoutTrailingSlashes(config.baseUrl)
1677
1684
  };
1678
1685
  client.setConfig({
1679
- baseUrl: config.baseUrl,
1686
+ baseUrl: this.config.baseUrl,
1680
1687
  fetch: config.fetch
1681
1688
  });
1682
1689
  }
@@ -1939,7 +1946,7 @@ var EudiploClient = class {
1939
1946
  "EventSource is not available in this environment. Use polling with waitForSession() instead, or provide a polyfill."
1940
1947
  );
1941
1948
  }
1942
- const url = `${this.config.baseUrl}/session/${sessionId}/events?token=${encodeURIComponent(token)}`;
1949
+ const url = `${this.config.baseUrl}/api/session/${encodeURIComponent(sessionId)}/events?token=${encodeURIComponent(token)}`;
1943
1950
  const eventSource = new EventSource(url);
1944
1951
  eventSource.onopen = () => {
1945
1952
  options.onOpen?.();
@@ -2047,7 +2054,7 @@ var EudiploClient = class {
2047
2054
  return session;
2048
2055
  }
2049
2056
  const nonceOrId = session.walletNonce ?? session.id;
2050
- const requestObjectUrl = `${this.config.baseUrl}/api/presentations/${encodeURIComponent(nonceOrId)}/oid4vp/request`;
2057
+ const requestObjectUrl = `${this.config.baseUrl}/presentations/${encodeURIComponent(nonceOrId)}/oid4vp/request`;
2051
2058
  const fetchImpl = this.config.fetch ?? fetch;
2052
2059
  const requestObjectResponse = await fetchImpl(requestObjectUrl, {
2053
2060
  method: "GET",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eudiplo/sdk-core",
3
- "version": "8.1.0-main.a83e1b5",
3
+ "version": "8.1.0-main.d5dca08",
4
4
  "description": "Framework-agnostic EUDIPLO SDK for demos and integrations",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",