@auth0/auth0-react 1.8.0 → 1.10.1
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/dist/auth0-context.d.ts +9 -3
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts +7 -1
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +63 -42
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +56 -36
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +65 -43
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +13 -13
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/reducer.d.ts +1 -1
- package/dist/reducer.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/with-auth0.d.ts +2 -2
- package/dist/with-auth0.d.ts.map +1 -1
- package/dist/with-authentication-required.d.ts +1 -1
- package/dist/with-authentication-required.d.ts.map +1 -1
- package/package.json +42 -42
- package/src/auth0-context.tsx +13 -4
- package/src/auth0-provider.tsx +51 -22
- package/src/with-auth0.tsx +11 -7
- package/src/with-authentication-required.tsx +2 -2
package/dist/reducer.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ declare type Action = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Handles how that state changes in the `useAuth0` hook.
|
|
16
16
|
*/
|
|
17
|
-
export declare const reducer: (state: AuthState
|
|
17
|
+
export declare const reducer: (state: AuthState, action: Action) => AuthState;
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=reducer.d.ts.map
|
package/dist/reducer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,aAAK,MAAM,GACP;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,GAC/B;IACE,IAAI,EACA,aAAa,GACb,sBAAsB,GACtB,2BAA2B,GAC3B,0BAA0B,CAAC;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,GACD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,aAAK,MAAM,GACP;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,GAC/B;IACE,IAAI,EACA,aAAa,GACb,sBAAsB,GACtB,2BAA2B,GAC3B,0BAA0B,CAAC;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,GACD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,OAAO,UAAW,SAAS,UAAU,MAAM,KAAG,SAuC1D,CAAC"}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,6BAA4C,OAEzC,CAAC;AAc9B,eAAO,MAAM,UAAU;WAXG,MAAM;;mCAC7B,KAUuD,CAAC;AAE3D,eAAO,MAAM,UAAU;WAbG,MAAM;;mCAC7B,KAYkE,CAAC"}
|
package/dist/with-auth0.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
2
|
import { Auth0ContextInterface } from './auth0-context';
|
|
3
3
|
/**
|
|
4
4
|
* Components wrapped in `withAuth0` will have an additional `auth0` prop
|
|
@@ -21,6 +21,6 @@ export interface WithAuth0Props {
|
|
|
21
21
|
*
|
|
22
22
|
* Wrap your class components in this Higher Order Component to give them access to the Auth0Context
|
|
23
23
|
*/
|
|
24
|
-
declare const withAuth0: <P extends WithAuth0Props>(Component: React.ComponentType<P>) => React.ComponentType<
|
|
24
|
+
declare const withAuth0: <P extends WithAuth0Props>(Component: React.ComponentType<P>) => React.ComponentType<Omit<P, "auth0">>;
|
|
25
25
|
export default withAuth0;
|
|
26
26
|
//# sourceMappingURL=with-auth0.d.ts.map
|
package/dist/with-auth0.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-auth0.d.ts","sourceRoot":"","sources":["../src/with-auth0.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-authentication-required.d.ts","sourceRoot":"","sources":["../src/with-authentication-required.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;AAC5D,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAcjE;;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;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,kEAErB,iCAAiC,gBAyC3C,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": "1.
|
|
4
|
+
"version": "1.10.1",
|
|
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": "^
|
|
56
|
-
"@rollup/plugin-replace": "^
|
|
57
|
-
"@testing-library/jest-dom": "^5.
|
|
58
|
-
"@testing-library/react": "^
|
|
59
|
-
"@testing-library/react-hooks": "^
|
|
60
|
-
"@types/jest": "^
|
|
61
|
-
"@types/react": "^
|
|
62
|
-
"@types/react-dom": "^
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
64
|
-
"@typescript-eslint/parser": "^
|
|
65
|
-
"browserstack-cypress-cli": "^1.
|
|
66
|
-
"codecov": "^3.
|
|
67
|
-
"cypress": "^
|
|
68
|
-
"eslint": "^
|
|
69
|
-
"eslint-plugin-react": "^7.
|
|
70
|
-
"eslint-plugin-react-hooks": "^4.
|
|
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": "^
|
|
73
|
-
"jest-junit": "^
|
|
74
|
-
"oidc-provider": "^7.6
|
|
75
|
-
"prettier": "2.
|
|
76
|
-
"pretty-quick": "^
|
|
77
|
-
"react": "^
|
|
78
|
-
"react-dom": "^
|
|
79
|
-
"react-test-renderer": "^
|
|
80
|
-
"rollup": "^2.
|
|
81
|
-
"rollup-plugin-analyzer": "^
|
|
82
|
-
"rollup-plugin-delete": "^
|
|
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.0.0",
|
|
78
|
+
"react-dom": "^18.0.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": "^
|
|
85
|
-
"rollup-plugin-peer-deps-external": "^2.2.
|
|
86
|
-
"rollup-plugin-serve": "^1.0
|
|
87
|
-
"rollup-plugin-terser": "^7.0.
|
|
88
|
-
"rollup-plugin-typescript2": "^0.
|
|
89
|
-
"start-server-and-test": "^1.
|
|
90
|
-
"ts-jest": "^
|
|
91
|
-
"tslib": "^
|
|
92
|
-
"typedoc": "^0.
|
|
93
|
-
"typescript": "^
|
|
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.
|
|
105
|
+
"@auth0/auth0-spa-js": "^1.21.0"
|
|
106
106
|
}
|
|
107
107
|
}
|
package/src/auth0-context.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
RedirectLoginOptions as Auth0RedirectLoginOptions,
|
|
12
12
|
RedirectLoginResult,
|
|
13
13
|
User,
|
|
14
|
+
GetTokenSilentlyVerboseResponse,
|
|
14
15
|
} from '@auth0/auth0-spa-js';
|
|
15
16
|
import { createContext } from 'react';
|
|
16
17
|
import { AuthState, initialAuthState } from './auth-state';
|
|
@@ -64,9 +65,15 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
64
65
|
* Note that in all cases, falling back to an iframe requires access to
|
|
65
66
|
* the `auth0` cookie.
|
|
66
67
|
*/
|
|
67
|
-
getAccessTokenSilently:
|
|
68
|
-
options
|
|
69
|
-
|
|
68
|
+
getAccessTokenSilently: {
|
|
69
|
+
(options: GetTokenSilentlyOptions & { detailedResponse: true }): Promise<
|
|
70
|
+
GetTokenSilentlyVerboseResponse
|
|
71
|
+
>;
|
|
72
|
+
(options?: GetTokenSilentlyOptions): Promise<string>;
|
|
73
|
+
(options: GetTokenSilentlyOptions): Promise<
|
|
74
|
+
GetTokenSilentlyVerboseResponse | string
|
|
75
|
+
>;
|
|
76
|
+
};
|
|
70
77
|
|
|
71
78
|
/**
|
|
72
79
|
* ```js
|
|
@@ -92,7 +99,9 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
92
99
|
*
|
|
93
100
|
* Returns all claims from the id_token if available.
|
|
94
101
|
*/
|
|
95
|
-
getIdTokenClaims: (
|
|
102
|
+
getIdTokenClaims: (
|
|
103
|
+
options?: GetIdTokenClaimsOptions
|
|
104
|
+
) => Promise<IdToken | undefined>;
|
|
96
105
|
|
|
97
106
|
/**
|
|
98
107
|
* ```js
|
package/src/auth0-provider.tsx
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useReducer,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
2
9
|
import {
|
|
3
10
|
Auth0Client,
|
|
4
11
|
Auth0ClientOptions,
|
|
5
12
|
CacheLocation,
|
|
6
|
-
IdToken,
|
|
7
13
|
LogoutOptions,
|
|
8
14
|
LogoutUrlOptions,
|
|
9
15
|
PopupLoginOptions,
|
|
10
16
|
PopupConfigOptions,
|
|
11
17
|
RedirectLoginOptions as Auth0RedirectLoginOptions,
|
|
12
18
|
GetTokenWithPopupOptions,
|
|
13
|
-
GetTokenSilentlyOptions,
|
|
14
|
-
GetIdTokenClaimsOptions,
|
|
15
19
|
RedirectLoginResult,
|
|
16
20
|
ICache,
|
|
21
|
+
GetTokenSilentlyOptions,
|
|
17
22
|
} from '@auth0/auth0-spa-js';
|
|
18
23
|
import Auth0Context, { RedirectLoginOptions } from './auth0-context';
|
|
19
24
|
import { hasAuthParams, loginError, tokenError } from './utils';
|
|
@@ -41,7 +46,7 @@ export interface Auth0ProviderOptions {
|
|
|
41
46
|
* It uses `window.history` but you might want to overwrite this if you are using a custom router, like `react-router-dom`
|
|
42
47
|
* See the EXAMPLES.md for more info.
|
|
43
48
|
*/
|
|
44
|
-
onRedirectCallback?: (appState
|
|
49
|
+
onRedirectCallback?: (appState?: AppState) => void;
|
|
45
50
|
/**
|
|
46
51
|
* By default, if the page url has code/state params, the SDK will treat them as Auth0's and attempt to exchange the
|
|
47
52
|
* code for a token. In some cases the code might be for something else (another OAuth SDK perhaps). In these
|
|
@@ -148,6 +153,12 @@ export interface Auth0ProviderOptions {
|
|
|
148
153
|
* The Id of an invitation to accept. This is available from the user invitation URL that is given when participating in a user invitation flow.
|
|
149
154
|
*/
|
|
150
155
|
invitation?: string;
|
|
156
|
+
/**
|
|
157
|
+
* The name of the connection configured for your application.
|
|
158
|
+
* If null, it will redirect to the Auth0 Login Page and show
|
|
159
|
+
* the Login Widget.
|
|
160
|
+
*/
|
|
161
|
+
connection?: string;
|
|
151
162
|
/**
|
|
152
163
|
* If you need to send custom parameters to the Authorization Server,
|
|
153
164
|
* make sure to use the original parameter name.
|
|
@@ -230,8 +241,13 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
|
|
|
230
241
|
() => new Auth0Client(toAuth0ClientOptions(clientOpts))
|
|
231
242
|
);
|
|
232
243
|
const [state, dispatch] = useReducer(reducer, initialAuthState);
|
|
244
|
+
const didInitialise = useRef(false);
|
|
233
245
|
|
|
234
246
|
useEffect(() => {
|
|
247
|
+
if (didInitialise.current) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
didInitialise.current = true;
|
|
235
251
|
(async (): Promise<void> => {
|
|
236
252
|
try {
|
|
237
253
|
if (hasAuthParams() && !skipRedirectCallback) {
|
|
@@ -298,7 +314,8 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
|
|
|
298
314
|
);
|
|
299
315
|
|
|
300
316
|
const getAccessTokenSilently = useCallback(
|
|
301
|
-
|
|
317
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
318
|
+
async (opts?: GetTokenSilentlyOptions): Promise<any> => {
|
|
302
319
|
let token;
|
|
303
320
|
try {
|
|
304
321
|
token = await client.getTokenSilently(opts);
|
|
@@ -337,8 +354,7 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
|
|
|
337
354
|
);
|
|
338
355
|
|
|
339
356
|
const getIdTokenClaims = useCallback(
|
|
340
|
-
(opts
|
|
341
|
-
client.getIdTokenClaims(opts),
|
|
357
|
+
(opts) => client.getIdTokenClaims(opts),
|
|
342
358
|
[client]
|
|
343
359
|
);
|
|
344
360
|
|
|
@@ -358,21 +374,34 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
|
|
|
358
374
|
[client]
|
|
359
375
|
);
|
|
360
376
|
|
|
377
|
+
const contextValue = useMemo(() => {
|
|
378
|
+
return {
|
|
379
|
+
...state,
|
|
380
|
+
buildAuthorizeUrl,
|
|
381
|
+
buildLogoutUrl,
|
|
382
|
+
getAccessTokenSilently,
|
|
383
|
+
getAccessTokenWithPopup,
|
|
384
|
+
getIdTokenClaims,
|
|
385
|
+
loginWithRedirect,
|
|
386
|
+
loginWithPopup,
|
|
387
|
+
logout,
|
|
388
|
+
handleRedirectCallback,
|
|
389
|
+
};
|
|
390
|
+
}, [
|
|
391
|
+
state,
|
|
392
|
+
buildAuthorizeUrl,
|
|
393
|
+
buildLogoutUrl,
|
|
394
|
+
getAccessTokenSilently,
|
|
395
|
+
getAccessTokenWithPopup,
|
|
396
|
+
getIdTokenClaims,
|
|
397
|
+
loginWithRedirect,
|
|
398
|
+
loginWithPopup,
|
|
399
|
+
logout,
|
|
400
|
+
handleRedirectCallback,
|
|
401
|
+
]);
|
|
402
|
+
|
|
361
403
|
return (
|
|
362
|
-
<Auth0Context.Provider
|
|
363
|
-
value={{
|
|
364
|
-
...state,
|
|
365
|
-
buildAuthorizeUrl,
|
|
366
|
-
buildLogoutUrl,
|
|
367
|
-
getAccessTokenSilently,
|
|
368
|
-
getAccessTokenWithPopup,
|
|
369
|
-
getIdTokenClaims,
|
|
370
|
-
loginWithRedirect,
|
|
371
|
-
loginWithPopup,
|
|
372
|
-
logout,
|
|
373
|
-
handleRedirectCallback,
|
|
374
|
-
}}
|
|
375
|
-
>
|
|
404
|
+
<Auth0Context.Provider value={contextValue}>
|
|
376
405
|
{children}
|
|
377
406
|
</Auth0Context.Provider>
|
|
378
407
|
);
|
package/src/with-auth0.tsx
CHANGED
|
@@ -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>> =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
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;
|
|
@@ -84,8 +84,8 @@ const withAuthenticationRequired = <P extends object>(
|
|
|
84
84
|
const {
|
|
85
85
|
returnTo = defaultReturnTo,
|
|
86
86
|
onRedirecting = defaultOnRedirecting,
|
|
87
|
-
loginOptions = {},
|
|
88
87
|
claimCheck = (): boolean => true,
|
|
88
|
+
loginOptions,
|
|
89
89
|
} = options;
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -101,7 +101,7 @@ const withAuthenticationRequired = <P extends object>(
|
|
|
101
101
|
const opts = {
|
|
102
102
|
...loginOptions,
|
|
103
103
|
appState: {
|
|
104
|
-
...loginOptions.appState,
|
|
104
|
+
...(loginOptions && loginOptions.appState),
|
|
105
105
|
returnTo: typeof returnTo === 'function' ? returnTo() : returnTo,
|
|
106
106
|
},
|
|
107
107
|
};
|