@auth0/auth0-spa-js 2.2.0 → 2.3.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 CHANGED
@@ -29,7 +29,7 @@ npm install @auth0/auth0-spa-js
29
29
  From the CDN:
30
30
 
31
31
  ```html
32
- <script src="https://cdn.auth0.com/js/auth0-spa-js/2.2/auth0-spa-js.production.js"></script>
32
+ <script src="https://cdn.auth0.com/js/auth0-spa-js/2.3/auth0-spa-js.production.js"></script>
33
33
  ```
34
34
 
35
35
  ### Configure Auth0
@@ -540,7 +540,7 @@
540
540
  exports.default = SuperTokensLock;
541
541
  }));
542
542
  var Lock = unwrapExports(browserTabsLock);
543
- var version = "2.2.0";
543
+ var version = "2.3.0";
544
544
  const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
545
545
  const DEFAULT_POPUP_CONFIG_OPTIONS = {
546
546
  timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
@@ -840,7 +840,13 @@
840
840
  }
841
841
  async function oauthToken(_a, worker) {
842
842
  var {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData} = _a, options = __rest(_a, [ "baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData" ]);
843
- const body = useFormData ? createQueryParams(options) : JSON.stringify(options);
843
+ const isTokenExchange = options.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange";
844
+ const allParams = Object.assign(Object.assign(Object.assign({}, options), isTokenExchange && audience && {
845
+ audience: audience
846
+ }), isTokenExchange && scope && {
847
+ scope: scope
848
+ });
849
+ const body = useFormData ? createQueryParams(allParams) : JSON.stringify(allParams);
844
850
  return await getJSON(`${baseUrl}/oauth/token`, timeout, audience || "default", scope, {
845
851
  method: "POST",
846
852
  body: body,
@@ -1819,7 +1825,13 @@
1819
1825
  throw new GenericError("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
1820
1826
  }
1821
1827
  const authorizeTimeout = options.timeoutInSeconds || this.options.authorizeTimeoutInSeconds;
1822
- const codeResult = await runIframe(url, this.domainUrl, authorizeTimeout);
1828
+ let eventOrigin;
1829
+ try {
1830
+ eventOrigin = new URL(this.domainUrl).origin;
1831
+ } catch (_a) {
1832
+ eventOrigin = this.domainUrl;
1833
+ }
1834
+ const codeResult = await runIframe(url, eventOrigin, authorizeTimeout);
1823
1835
  if (stateIn !== codeResult.state) {
1824
1836
  throw new GenericError("state_mismatch", "Invalid state");
1825
1837
  }
@@ -1957,7 +1969,7 @@
1957
1969
  subject_token: options.subject_token,
1958
1970
  subject_token_type: options.subject_token_type,
1959
1971
  scope: getUniqueScopes(options.scope, this.scope),
1960
- audience: this.options.authorizationParams.audience
1972
+ audience: options.audience || this.options.authorizationParams.audience
1961
1973
  });
1962
1974
  }
1963
1975
  }