@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.
@@ -1,5 +1,5 @@
1
1
  import { AuthenticationResult, PopupConfigOptions } from './global';
2
- export declare const parseQueryResult: (queryString: string) => AuthenticationResult;
2
+ export declare const parseAuthenticationResult: (queryString: string) => AuthenticationResult;
3
3
  export declare const runIframe: (authorizeUrl: string, eventOrigin: string, timeoutInSeconds?: number) => Promise<AuthenticationResult>;
4
4
  export declare const openPopup: (url: string) => Window | null;
5
5
  export declare const runPopup: (config: PopupConfigOptions) => Promise<AuthenticationResult>;
@@ -1,2 +1,2 @@
1
- declare const _default: "2.0.1";
1
+ declare const _default: "2.0.2";
2
2
  export default _default;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "@auth0/auth0-spa-js",
4
4
  "description": "Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE",
5
5
  "license": "MIT",
6
- "version": "2.0.1",
6
+ "version": "2.0.2",
7
7
  "main": "dist/lib/auth0-spa-js.cjs.js",
8
8
  "types": "dist/typings/index.d.ts",
9
9
  "module": "dist/auth0-spa-js.production.esm.js",
@@ -58,7 +58,7 @@
58
58
  "jest-fetch-mock": "^3.0.3",
59
59
  "jest-junit": "^14.0.0",
60
60
  "jest-localstorage-mock": "^2.4.22",
61
- "jsonwebtoken": "^8.5.1",
61
+ "jsonwebtoken": "^9.0.0",
62
62
  "node-fetch": "^3.2.10",
63
63
  "oidc-provider": "^7.14.0",
64
64
  "prettier": "^2.7.1",
@@ -3,7 +3,7 @@ import Lock from 'browser-tabs-lock';
3
3
  import {
4
4
  createQueryParams,
5
5
  runPopup,
6
- parseQueryResult,
6
+ parseAuthenticationResult,
7
7
  encode,
8
8
  createRandomString,
9
9
  runIframe,
@@ -486,7 +486,7 @@ export class Auth0Client {
486
486
  throw new Error('There are no query params available for parsing.');
487
487
  }
488
488
 
489
- const { state, code, error, error_description } = parseQueryResult(
489
+ const { state, code, error, error_description } = parseAuthenticationResult(
490
490
  queryStringFragments.join('')
491
491
  );
492
492
 
package/src/utils.ts CHANGED
@@ -12,24 +12,21 @@ import {
12
12
  PopupCancelledError
13
13
  } from './errors';
14
14
 
15
- export const parseQueryResult = (queryString: string): AuthenticationResult => {
15
+ export const parseAuthenticationResult = (
16
+ queryString: string
17
+ ): AuthenticationResult => {
16
18
  if (queryString.indexOf('#') > -1) {
17
- queryString = queryString.substr(0, queryString.indexOf('#'));
19
+ queryString = queryString.substring(0, queryString.indexOf('#'));
18
20
  }
19
21
 
20
- const queryParams = queryString.split('&');
21
- const parsedQuery: Record<string, any> = {};
22
+ const searchParams = new URLSearchParams(queryString);
22
23
 
23
- queryParams.forEach(qp => {
24
- const [key, val] = qp.split('=');
25
- parsedQuery[key] = decodeURIComponent(val);
26
- });
27
-
28
- if (parsedQuery.expires_in) {
29
- parsedQuery.expires_in = parseInt(parsedQuery.expires_in);
30
- }
31
-
32
- return parsedQuery as AuthenticationResult;
24
+ return {
25
+ state: searchParams.get('state')!,
26
+ code: searchParams.get('code') || undefined,
27
+ error: searchParams.get('error') || undefined,
28
+ error_description: searchParams.get('error_description') || undefined
29
+ };
33
30
  };
34
31
 
35
32
  export const runIframe = (
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '2.0.1';
1
+ export default '2.0.2';