@auth0/auth0-react 1.9.0 → 1.10.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 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAChB,KAAK,EAAE,MAAM;IAAS,iBAAiB,CAAC;gBAAxC,KAAK,EAAE,MAAM,EAAS,iBAAiB,CAAC,oBAAQ;CAGpE"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAChB,KAAK,EAAE,MAAM;IAAS,iBAAiB,CAAC;gBAAxC,KAAK,EAAE,MAAM,EAAS,iBAAiB,CAAC,oBAAQ;CAMpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"with-auth0.d.ts","sourceRoot":"","sources":["../src/with-auth0.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,SAAS,wGAQd,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"with-auth0.d.ts","sourceRoot":"","sources":["../src/with-auth0.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,SAAS,wGAYd,CAAC;AAEF,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Auth0",
3
3
  "name": "@auth0/auth0-react",
4
- "version": "1.9.0",
4
+ "version": "1.10.2",
5
5
  "description": "Auth0 SDK for React Single Page Applications (SPA)",
6
6
  "keywords": [
7
7
  "auth0",
@@ -26,7 +26,7 @@
26
26
  "test": "jest --coverage",
27
27
  "prepack": "npm run build",
28
28
  "docs": "typedoc --options typedoc.js src",
29
- "install:examples": "npm i --prefix=examples/cra-react-router --no-package-lock && npm i --prefix=examples/gatsby-app --no-package-lock && npm i --prefix=examples/nextjs-app --no-package-lock && npm ci --prefix=examples/users-api",
29
+ "install:examples": "npm i --prefix=examples/cra-react-router --no-package-lock && npm i --prefix=examples/gatsby-app --no-package-lock --legacy-peer-deps && npm i --prefix=examples/nextjs-app --no-package-lock --legacy-peer-deps && npm ci --prefix=examples/users-api",
30
30
  "start:cra": "npm start --prefix=examples/cra-react-router",
31
31
  "start:gatsby": "npm start --prefix=examples/gatsby-app",
32
32
  "start:nextjs": "npm run dev --prefix=examples/nextjs-app",
@@ -52,49 +52,49 @@
52
52
  },
53
53
  "homepage": "https://github.com/auth0/auth0-react#readme",
54
54
  "devDependencies": {
55
- "@rollup/plugin-node-resolve": "^7.1.3",
56
- "@rollup/plugin-replace": "^2.3.2",
57
- "@testing-library/jest-dom": "^5.5.0",
58
- "@testing-library/react": "^10.0.4",
59
- "@testing-library/react-hooks": "^3.2.1",
60
- "@types/jest": "^27.4.0",
61
- "@types/react": "^16.9.34",
62
- "@types/react-dom": "^16.9.6",
63
- "@typescript-eslint/eslint-plugin": "^2.30.0",
64
- "@typescript-eslint/parser": "^2.30.0",
65
- "browserstack-cypress-cli": "^1.8.1",
66
- "codecov": "^3.7.2",
67
- "cypress": "^7.2.0",
68
- "eslint": "^6.8.0",
69
- "eslint-plugin-react": "^7.19.0",
70
- "eslint-plugin-react-hooks": "^4.0.0",
55
+ "@rollup/plugin-node-resolve": "^13.1.3",
56
+ "@rollup/plugin-replace": "^4.0.0",
57
+ "@testing-library/jest-dom": "^5.16.3",
58
+ "@testing-library/react": "^13.0.0",
59
+ "@testing-library/react-hooks": "^7.0.2",
60
+ "@types/jest": "^27.4.1",
61
+ "@types/react": "^17.0.43",
62
+ "@types/react-dom": "^17.0.14",
63
+ "@typescript-eslint/eslint-plugin": "^5.17.0",
64
+ "@typescript-eslint/parser": "^5.17.0",
65
+ "browserstack-cypress-cli": "^1.1.2",
66
+ "codecov": "^3.8.2",
67
+ "cypress": "^9.5.3",
68
+ "eslint": "^8.12.0",
69
+ "eslint-plugin-react": "^7.29.4",
70
+ "eslint-plugin-react-hooks": "^4.4.0",
71
71
  "husky": "^4.2.5",
72
- "jest": "^27.4.7",
73
- "jest-junit": "^10.0.0",
74
- "oidc-provider": "^7.6.0",
75
- "prettier": "2.0.5",
76
- "pretty-quick": "^2.0.1",
77
- "react": "^16.14.0",
78
- "react-dom": "^16.14.0",
79
- "react-test-renderer": "^16.13.1",
80
- "rollup": "^2.7.2",
81
- "rollup-plugin-analyzer": "^3.3.0",
82
- "rollup-plugin-delete": "^1.2.0",
72
+ "jest": "^27.5.1",
73
+ "jest-junit": "^13.0.0",
74
+ "oidc-provider": "^7.10.6",
75
+ "prettier": "2.6.2",
76
+ "pretty-quick": "^3.1.3",
77
+ "react": "^18.1.0",
78
+ "react-dom": "^18.1.0",
79
+ "react-test-renderer": "^18.0.0",
80
+ "rollup": "^2.70.1",
81
+ "rollup-plugin-analyzer": "^4.0.0",
82
+ "rollup-plugin-delete": "^2.0.0",
83
83
  "rollup-plugin-dev": "^1.1.3",
84
- "rollup-plugin-livereload": "^1.2.0",
85
- "rollup-plugin-peer-deps-external": "^2.2.2",
86
- "rollup-plugin-serve": "^1.0.1",
87
- "rollup-plugin-terser": "^7.0.0",
88
- "rollup-plugin-typescript2": "^0.27.0",
89
- "start-server-and-test": "^1.11.0",
90
- "ts-jest": "^27.1.2",
91
- "tslib": "^1.11.1",
92
- "typedoc": "^0.20.32",
93
- "typescript": "^4.5.4"
84
+ "rollup-plugin-livereload": "^2.0.5",
85
+ "rollup-plugin-peer-deps-external": "^2.2.4",
86
+ "rollup-plugin-serve": "^1.1.0",
87
+ "rollup-plugin-terser": "^7.0.2",
88
+ "rollup-plugin-typescript2": "^0.31.2",
89
+ "start-server-and-test": "^1.14.0",
90
+ "ts-jest": "^27.1.4",
91
+ "tslib": "^2.3.1",
92
+ "typedoc": "^0.22.13",
93
+ "typescript": "^4.6.3"
94
94
  },
95
95
  "peerDependencies": {
96
- "react": "^16.11.0 || ^17",
97
- "react-dom": "^16.11.0 || ^17"
96
+ "react": "^16.11.0 || ^17 || ^18",
97
+ "react-dom": "^16.11.0 || ^17 || ^18"
98
98
  },
99
99
  "husky": {
100
100
  "hooks": {
@@ -102,6 +102,6 @@
102
102
  }
103
103
  },
104
104
  "dependencies": {
105
- "@auth0/auth0-spa-js": "^1.19.3"
105
+ "@auth0/auth0-spa-js": "^1.22.0"
106
106
  }
107
107
  }
@@ -3,6 +3,7 @@ import React, {
3
3
  useEffect,
4
4
  useMemo,
5
5
  useReducer,
6
+ useRef,
6
7
  useState,
7
8
  } from 'react';
8
9
  import {
@@ -45,7 +46,7 @@ export interface Auth0ProviderOptions {
45
46
  * It uses `window.history` but you might want to overwrite this if you are using a custom router, like `react-router-dom`
46
47
  * See the EXAMPLES.md for more info.
47
48
  */
48
- onRedirectCallback?: (appState: AppState) => void;
49
+ onRedirectCallback?: (appState?: AppState) => void;
49
50
  /**
50
51
  * By default, if the page url has code/state params, the SDK will treat them as Auth0's and attempt to exchange the
51
52
  * code for a token. In some cases the code might be for something else (another OAuth SDK perhaps). In these
@@ -240,8 +241,13 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
240
241
  () => new Auth0Client(toAuth0ClientOptions(clientOpts))
241
242
  );
242
243
  const [state, dispatch] = useReducer(reducer, initialAuthState);
244
+ const didInitialise = useRef(false);
243
245
 
244
246
  useEffect(() => {
247
+ if (didInitialise.current) {
248
+ return;
249
+ }
250
+ didInitialise.current = true;
245
251
  (async (): Promise<void> => {
246
252
  try {
247
253
  if (hasAuthParams() && !skipRedirectCallback) {
package/src/errors.tsx CHANGED
@@ -7,5 +7,8 @@
7
7
  export class OAuthError extends Error {
8
8
  constructor(public error: string, public error_description?: string) {
9
9
  super(error_description || error);
10
+
11
+ // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
12
+ Object.setPrototypeOf(this, OAuthError.prototype);
10
13
  }
11
14
  }
@@ -25,12 +25,16 @@ export interface WithAuth0Props {
25
25
  */
26
26
  const withAuth0 = <P extends WithAuth0Props>(
27
27
  Component: ComponentType<P>
28
- ): ComponentType<Omit<P, keyof WithAuth0Props>> => (props): JSX.Element => (
29
- <Auth0Context.Consumer>
30
- {(auth: Auth0ContextInterface): JSX.Element => (
31
- <Component {...(props as P)} auth0={auth} />
32
- )}
33
- </Auth0Context.Consumer>
34
- );
28
+ ): ComponentType<Omit<P, keyof WithAuth0Props>> => {
29
+ return function WithAuth(props): JSX.Element {
30
+ return (
31
+ <Auth0Context.Consumer>
32
+ {(auth: Auth0ContextInterface): JSX.Element => (
33
+ <Component {...(props as P)} auth0={auth} />
34
+ )}
35
+ </Auth0Context.Consumer>
36
+ );
37
+ };
38
+ };
35
39
 
36
40
  export default withAuth0;