@auth0/auth0-react 2.2.3 → 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.
@@ -31,7 +31,7 @@ export interface WithAuthenticationRequiredOptions {
31
31
  *
32
32
  * Render a message to show that the user is being redirected to the login.
33
33
  */
34
- onRedirecting?: () => JSX.Element;
34
+ onRedirecting?: () => React.JSX.Element;
35
35
  /**
36
36
  * ```js
37
37
  * withAuthenticationRequired(Profile, {
@@ -1 +1 @@
1
- {"version":3,"file":"with-authentication-required.d.ts","sourceRoot":"","sources":["../src/with-authentication-required.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,EAAE,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAqB,EACnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAkBzB;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACnC;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IAClC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChD;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,kEAErB,iCAAiC,gBAwC3C,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"with-authentication-required.d.ts","sourceRoot":"","sources":["../src/with-authentication-required.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,EAAE,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAqB,EACnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAkBzB;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACnC;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;IACxC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChD;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,kEAErB,iCAAiC,gBAwC3C,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Auth0",
3
3
  "name": "@auth0/auth0-react",
4
- "version": "2.2.3",
4
+ "version": "2.3.0",
5
5
  "description": "Auth0 SDK for React Single Page Applications (SPA)",
6
6
  "keywords": [
7
7
  "auth0",
@@ -54,12 +54,12 @@
54
54
  "@rollup/plugin-node-resolve": "^15.0.1",
55
55
  "@rollup/plugin-replace": "^5.0.1",
56
56
  "@rollup/plugin-terser": "^0.4.3",
57
- "@testing-library/jest-dom": "^5.16.5",
58
- "@testing-library/react": "^14.0.0",
59
- "@testing-library/react-hooks": "^7.0.2",
57
+ "@testing-library/jest-dom": "6.6.3",
58
+ "@testing-library/react": "16.1.0",
59
+ "@testing-library/dom": "^10.4.0",
60
60
  "@types/jest": "^29.2.3",
61
- "@types/react": "^18.2.27",
62
- "@types/react-dom": "^18.2.12",
61
+ "@types/react": "19.0.7",
62
+ "@types/react-dom": "19.0.3",
63
63
  "@typescript-eslint/eslint-plugin": "^5.45.0",
64
64
  "@typescript-eslint/parser": "^5.45.0",
65
65
  "browserstack-cypress-cli": "^1.19.1",
@@ -74,9 +74,8 @@
74
74
  "oidc-provider": "^8.0.0",
75
75
  "prettier": "^2.8.1",
76
76
  "pretty-quick": "^3.1.3",
77
- "react": "^18.2.0",
78
- "react-dom": "^18.2.0",
79
- "react-test-renderer": "^18.2.0",
77
+ "react": "^19.0.0",
78
+ "react-dom": "19.0.0",
80
79
  "rollup": "^3.7.0",
81
80
  "rollup-plugin-analyzer": "^4.0.0",
82
81
  "rollup-plugin-delete": "^2.0.0",
@@ -92,10 +91,10 @@
92
91
  "typescript": "^4.9.4"
93
92
  },
94
93
  "peerDependencies": {
95
- "react": "^16.11.0 || ^17 || ^18",
96
- "react-dom": "^16.11.0 || ^17 || ^18"
94
+ "react": "^16.11.0 || ^17 || ^18 || ^19",
95
+ "react-dom": "^16.11.0 || ^17 || ^18 || ^19"
97
96
  },
98
97
  "dependencies": {
99
- "@auth0/auth0-spa-js": "^2.1.2"
98
+ "@auth0/auth0-spa-js": "^2.1.3"
100
99
  }
101
100
  }
@@ -38,7 +38,9 @@ export interface Auth0ContextInterface<TUser extends User = User>
38
38
  *
39
39
  * If refresh tokens are used, the token endpoint is called directly with the
40
40
  * 'refresh_token' grant. If no refresh token is available to make this call,
41
- * the SDK falls back to using an iframe to the '/authorize' URL.
41
+ * the SDK will only fall back to using an iframe to the '/authorize' URL if
42
+ * the `useRefreshTokensFallback` setting has been set to `true`. By default this
43
+ * setting is `false`.
42
44
  *
43
45
  * This method may use a web worker to perform the token call if the in-memory
44
46
  * cache is used.
@@ -125,14 +125,14 @@ const defaultOnRedirectCallback = (appState?: AppState): void => {
125
125
  * <Auth0Provider
126
126
  * domain={domain}
127
127
  * clientId={clientId}
128
- * authorizationParams={{ redirect_uri: window.location.origin }}}>
128
+ * authorizationParams={{ redirect_uri: window.location.origin }}>
129
129
  * <MyApp />
130
130
  * </Auth0Provider>
131
131
  * ```
132
132
  *
133
133
  * Provides the Auth0Context to its child components.
134
134
  */
135
- const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
135
+ const Auth0Provider = (opts: Auth0ProviderOptions) => {
136
136
  const {
137
137
  children,
138
138
  skipRedirectCallback,
@@ -146,6 +146,11 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
146
146
  const [state, dispatch] = useReducer(reducer, initialAuthState);
147
147
  const didInitialise = useRef(false);
148
148
 
149
+ const handleError = useCallback((error: Error) => {
150
+ dispatch({ type: 'ERROR', error });
151
+ return error;
152
+ }, []);
153
+
149
154
  useEffect(() => {
150
155
  if (didInitialise.current) {
151
156
  return;
@@ -164,10 +169,10 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
164
169
  }
165
170
  dispatch({ type: 'INITIALISED', user });
166
171
  } catch (error) {
167
- dispatch({ type: 'ERROR', error: loginError(error) });
172
+ handleError(loginError(error));
168
173
  }
169
174
  })();
170
- }, [client, onRedirectCallback, skipRedirectCallback]);
175
+ }, [client, onRedirectCallback, skipRedirectCallback, handleError]);
171
176
 
172
177
  const loginWithRedirect = useCallback(
173
178
  (opts?: RedirectLoginOptions): Promise<void> => {
@@ -187,7 +192,7 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
187
192
  try {
188
193
  await client.loginWithPopup(options, config);
189
194
  } catch (error) {
190
- dispatch({ type: 'ERROR', error: loginError(error) });
195
+ handleError(loginError(error));
191
196
  return;
192
197
  }
193
198
  const user = await client.getUser();
@@ -30,10 +30,10 @@ const withAuth0 = <P extends WithAuth0Props>(
30
30
  Component: ComponentType<P>,
31
31
  context = Auth0Context
32
32
  ): ComponentType<Omit<P, keyof WithAuth0Props>> => {
33
- return function WithAuth(props): JSX.Element {
33
+ return function WithAuth(props): React.JSX.Element {
34
34
  return (
35
35
  <context.Consumer>
36
- {(auth: Auth0ContextInterface): JSX.Element => (
36
+ {(auth: Auth0ContextInterface): React.JSX.Element => (
37
37
  <Component {...(props as P)} auth0={auth} />
38
38
  )}
39
39
  </context.Consumer>
@@ -8,12 +8,12 @@ import Auth0Context, {
8
8
  /**
9
9
  * @ignore
10
10
  */
11
- const defaultOnRedirecting = (): JSX.Element => <></>;
11
+ const defaultOnRedirecting = (): React.JSX.Element => <></>;
12
12
 
13
13
  /**
14
14
  * @ignore
15
15
  */
16
- const defaultOnBeforeAuthentication = async (): Promise<void> => {/* noop */};
16
+ const defaultOnBeforeAuthentication = async (): Promise<void> => {/* noop */ };
17
17
 
18
18
  /**
19
19
  * @ignore
@@ -52,7 +52,7 @@ export interface WithAuthenticationRequiredOptions {
52
52
  *
53
53
  * Render a message to show that the user is being redirected to the login.
54
54
  */
55
- onRedirecting?: () => JSX.Element;
55
+ onRedirecting?: () => React.JSX.Element;
56
56
  /**
57
57
  * ```js
58
58
  * withAuthenticationRequired(Profile, {
@@ -98,7 +98,7 @@ const withAuthenticationRequired = <P extends object>(
98
98
  Component: ComponentType<P>,
99
99
  options: WithAuthenticationRequiredOptions = {}
100
100
  ): FC<P> => {
101
- return function WithAuthenticationRequired(props: P): JSX.Element {
101
+ return function WithAuthenticationRequired(props: P): React.JSX.Element {
102
102
  const {
103
103
  returnTo = defaultReturnTo,
104
104
  onRedirecting = defaultOnRedirecting,