@muze-nl/metro-oidc 0.5.1 → 0.5.2

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/browser.js CHANGED
@@ -1681,9 +1681,18 @@
1681
1681
  client_info: openid_client_metadata
1682
1682
  });
1683
1683
  const defaultOptions = {
1684
- client: everything_default.client().with(throwermw()).with(jsonmw())
1684
+ client: everything_default.client().with(throwermw()).with(jsonmw()),
1685
+ client_info: {
1686
+ redirect_uris: [globalThis.document?.location.href]
1687
+ }
1685
1688
  };
1686
1689
  options = Object.assign({}, defaultOptions, options);
1690
+ if (!options.client_info) {
1691
+ options.client_info = {};
1692
+ }
1693
+ if (!options.client_info.redirect_uris) {
1694
+ options.client_info.redirect_uris = [globalThis.document?.location.href];
1695
+ }
1687
1696
  let response2 = await options.client.post(options.registration_endpoint, {
1688
1697
  body: options.client_info
1689
1698
  });
@@ -1743,7 +1752,7 @@
1743
1752
  if (!options.openid_configuration && options.store.has("openid_configuration")) {
1744
1753
  options.openid_configuration = options.store.get("openid_configuration");
1745
1754
  }
1746
- if (!options.client_info.client_id && options.store.has("client_info")) {
1755
+ if (!options.client_info?.client_id && options.store.has("client_info")) {
1747
1756
  options.client_info = options.store.get("client_info");
1748
1757
  }
1749
1758
  return async (req, next) => {
@@ -1767,7 +1776,6 @@
1767
1776
  options.store.set("openid_configuration", options.openid_configuration);
1768
1777
  }
1769
1778
  if (!options.client_info?.client_id) {
1770
- assert(options.client_info?.client_name, Required());
1771
1779
  if (!options.openid_configuration.registration_endpoint) {
1772
1780
  throw metroError("metro.oidcmw: Error: issuer " + options.issuer + " does not support dynamic client registration, but you haven't specified a client_id");
1773
1781
  }
@@ -1785,8 +1793,8 @@
1785
1793
  force_authorization: true,
1786
1794
  authorize_callback: options.authorize_callback,
1787
1795
  oauth2_configuration: {
1788
- client_id: options.client_info.client_id,
1789
- client_secret: options.client_info.client_secret,
1796
+ client_id: options.client_info?.client_id,
1797
+ client_secret: options.client_info?.client_secret,
1790
1798
  grant_type: "authorization_code",
1791
1799
  response_type: "code",
1792
1800
  response_mode: "query",