@auth0/auth0-spa-js 2.0.1 → 2.0.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.
@@ -472,7 +472,7 @@
472
472
  exports.default = SuperTokensLock;
473
473
  }));
474
474
  var Lock = unwrapExports(browserTabsLock);
475
- var version = "2.0.1";
475
+ var version = "2.0.2";
476
476
  const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
477
477
  const DEFAULT_POPUP_CONFIG_OPTIONS = {
478
478
  timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
@@ -547,20 +547,17 @@
547
547
  function valueOrEmptyString(value, exclude = []) {
548
548
  return value && !exclude.includes(value) ? value : "";
549
549
  }
550
- const parseQueryResult = queryString => {
550
+ const parseAuthenticationResult = queryString => {
551
551
  if (queryString.indexOf("#") > -1) {
552
- queryString = queryString.substr(0, queryString.indexOf("#"));
552
+ queryString = queryString.substring(0, queryString.indexOf("#"));
553
553
  }
554
- const queryParams = queryString.split("&");
555
- const parsedQuery = {};
556
- queryParams.forEach((qp => {
557
- const [key, val] = qp.split("=");
558
- parsedQuery[key] = decodeURIComponent(val);
559
- }));
560
- if (parsedQuery.expires_in) {
561
- parsedQuery.expires_in = parseInt(parsedQuery.expires_in);
562
- }
563
- return parsedQuery;
554
+ const searchParams = new URLSearchParams(queryString);
555
+ return {
556
+ state: searchParams.get("state"),
557
+ code: searchParams.get("code") || undefined,
558
+ error: searchParams.get("error") || undefined,
559
+ error_description: searchParams.get("error_description") || undefined
560
+ };
564
561
  };
565
562
  const runIframe = (authorizeUrl, eventOrigin, timeoutInSeconds = DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) => new Promise(((res, rej) => {
566
563
  const iframe = window.document.createElement("iframe");
@@ -1557,7 +1554,7 @@
1557
1554
  if (queryStringFragments.length === 0) {
1558
1555
  throw new Error("There are no query params available for parsing.");
1559
1556
  }
1560
- const {state: state, code: code, error: error, error_description: error_description} = parseQueryResult(queryStringFragments.join(""));
1557
+ const {state: state, code: code, error: error, error_description: error_description} = parseAuthenticationResult(queryStringFragments.join(""));
1561
1558
  const transaction = this.transactionManager.get();
1562
1559
  if (!transaction) {
1563
1560
  throw new Error("Invalid state");