@auth0/auth0-react 2.3.0 → 2.4.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.
- package/dist/auth-state.d.ts +14 -14
- package/dist/auth-state.d.ts.map +1 -1
- package/dist/auth0-context.d.ts +134 -135
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts +71 -71
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +453 -436
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +451 -434
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +453 -436
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -1
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/errors.d.ts +11 -11
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/reducer.d.ts +18 -18
- package/dist/reducer.d.ts.map +1 -1
- package/dist/use-auth0.d.ts +26 -27
- package/dist/use-auth0.d.ts.map +1 -1
- package/dist/utils.d.ts +9 -9
- package/dist/utils.d.ts.map +1 -1
- package/dist/with-auth0.d.ts +28 -28
- package/dist/with-auth0.d.ts.map +1 -1
- package/dist/with-authentication-required.d.ts +76 -76
- package/dist/with-authentication-required.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/auth-state.tsx +4 -2
- package/src/auth0-context.tsx +2 -2
- package/src/auth0-provider.tsx +10 -10
- package/src/errors.tsx +1 -1
- package/src/reducer.tsx +4 -4
- package/src/utils.tsx +1 -1
- package/src/with-authentication-required.tsx +2 -2
package/dist/auth-state.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { User } from '@auth0/auth0-spa-js';
|
|
2
|
-
/**
|
|
3
|
-
* The auth state which, when combined with the auth methods, make up the return object of the `useAuth0` hook.
|
|
4
|
-
*/
|
|
5
|
-
export interface AuthState<TUser extends User = User> {
|
|
6
|
-
error
|
|
7
|
-
isAuthenticated: boolean;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
user
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* The initial auth state.
|
|
13
|
-
*/
|
|
14
|
-
export declare const initialAuthState: AuthState;
|
|
1
|
+
import { User } from '@auth0/auth0-spa-js';
|
|
2
|
+
/**
|
|
3
|
+
* The auth state which, when combined with the auth methods, make up the return object of the `useAuth0` hook.
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthState<TUser extends User = User> {
|
|
6
|
+
error: Error | undefined;
|
|
7
|
+
isAuthenticated: boolean;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
user: TUser | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The initial auth state.
|
|
13
|
+
*/
|
|
14
|
+
export declare const initialAuthState: AuthState;
|
|
15
15
|
//# sourceMappingURL=auth-state.d.ts.map
|
package/dist/auth-state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-state.d.ts","sourceRoot":"","sources":["../src/auth-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI;IAClD,KAAK,
|
|
1
|
+
{"version":3,"file":"auth-state.d.ts","sourceRoot":"","sources":["../src/auth-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI;IAClD,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAK9B,CAAC"}
|
package/dist/auth0-context.d.ts
CHANGED
|
@@ -1,136 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* will be
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* the
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(options
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* the
|
|
99
|
-
*
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
export default Auth0Context;
|
|
1
|
+
import { GetTokenSilentlyOptions, GetTokenWithPopupOptions, IdToken, LogoutOptions as SPALogoutOptions, PopupLoginOptions, PopupConfigOptions, RedirectLoginResult, User, GetTokenSilentlyVerboseResponse, RedirectLoginOptions as SPARedirectLoginOptions } from '@auth0/auth0-spa-js';
|
|
2
|
+
import { AuthState } from './auth-state';
|
|
3
|
+
import { AppState } from './auth0-provider';
|
|
4
|
+
export interface LogoutOptions extends Omit<SPALogoutOptions, 'onRedirect'> {
|
|
5
|
+
}
|
|
6
|
+
export interface RedirectLoginOptions<TAppState = AppState> extends Omit<SPARedirectLoginOptions<TAppState>, 'onRedirect'> {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Contains the authenticated state and authentication methods provided by the `useAuth0` hook.
|
|
10
|
+
*/
|
|
11
|
+
export interface Auth0ContextInterface<TUser extends User = User> extends AuthState<TUser> {
|
|
12
|
+
/**
|
|
13
|
+
* ```js
|
|
14
|
+
* const token = await getAccessTokenSilently(options);
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* If there's a valid token stored, return it. Otherwise, opens an
|
|
18
|
+
* iframe with the `/authorize` URL using the parameters provided
|
|
19
|
+
* as arguments. Random and secure `state` and `nonce` parameters
|
|
20
|
+
* will be auto-generated. If the response is successful, results
|
|
21
|
+
* will be valid according to their expiration times.
|
|
22
|
+
*
|
|
23
|
+
* If refresh tokens are used, the token endpoint is called directly with the
|
|
24
|
+
* 'refresh_token' grant. If no refresh token is available to make this call,
|
|
25
|
+
* the SDK will only fall back to using an iframe to the '/authorize' URL if
|
|
26
|
+
* the `useRefreshTokensFallback` setting has been set to `true`. By default this
|
|
27
|
+
* setting is `false`.
|
|
28
|
+
*
|
|
29
|
+
* This method may use a web worker to perform the token call if the in-memory
|
|
30
|
+
* cache is used.
|
|
31
|
+
*
|
|
32
|
+
* If an `audience` value is given to this function, the SDK always falls
|
|
33
|
+
* back to using an iframe to make the token exchange.
|
|
34
|
+
*
|
|
35
|
+
* Note that in all cases, falling back to an iframe requires access to
|
|
36
|
+
* the `auth0` cookie.
|
|
37
|
+
*/
|
|
38
|
+
getAccessTokenSilently: {
|
|
39
|
+
(options: GetTokenSilentlyOptions & {
|
|
40
|
+
detailedResponse: true;
|
|
41
|
+
}): Promise<GetTokenSilentlyVerboseResponse>;
|
|
42
|
+
(options?: GetTokenSilentlyOptions): Promise<string>;
|
|
43
|
+
(options: GetTokenSilentlyOptions): Promise<GetTokenSilentlyVerboseResponse | string>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* ```js
|
|
47
|
+
* const token = await getTokenWithPopup(options, config);
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* Get an access token interactively.
|
|
51
|
+
*
|
|
52
|
+
* Opens a popup with the `/authorize` URL using the parameters
|
|
53
|
+
* provided as arguments. Random and secure `state` and `nonce`
|
|
54
|
+
* parameters will be auto-generated. If the response is successful,
|
|
55
|
+
* results will be valid according to their expiration times.
|
|
56
|
+
*/
|
|
57
|
+
getAccessTokenWithPopup: (options?: GetTokenWithPopupOptions, config?: PopupConfigOptions) => Promise<string | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* ```js
|
|
60
|
+
* const claims = await getIdTokenClaims();
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Returns all claims from the id_token if available.
|
|
64
|
+
*/
|
|
65
|
+
getIdTokenClaims: () => Promise<IdToken | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* ```js
|
|
68
|
+
* await loginWithRedirect(options);
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* Performs a redirect to `/authorize` using the parameters
|
|
72
|
+
* provided as arguments. Random and secure `state` and `nonce`
|
|
73
|
+
* parameters will be auto-generated.
|
|
74
|
+
*/
|
|
75
|
+
loginWithRedirect: (options?: RedirectLoginOptions<AppState>) => Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* ```js
|
|
78
|
+
* await loginWithPopup(options, config);
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* Opens a popup with the `/authorize` URL using the parameters
|
|
82
|
+
* provided as arguments. Random and secure `state` and `nonce`
|
|
83
|
+
* parameters will be auto-generated. If the response is successful,
|
|
84
|
+
* results will be valid according to their expiration times.
|
|
85
|
+
*
|
|
86
|
+
* IMPORTANT: This method has to be called from an event handler
|
|
87
|
+
* that was started by the user like a button click, for example,
|
|
88
|
+
* otherwise the popup will be blocked in most browsers.
|
|
89
|
+
*/
|
|
90
|
+
loginWithPopup: (options?: PopupLoginOptions, config?: PopupConfigOptions) => Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* ```js
|
|
93
|
+
* auth0.logout({ logoutParams: { returnTo: window.location.origin } });
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* Clears the application session and performs a redirect to `/v2/logout`, using
|
|
97
|
+
* the parameters provided as arguments, to clear the Auth0 session.
|
|
98
|
+
* If the `logoutParams.federated` option is specified, it also clears the Identity Provider session.
|
|
99
|
+
* [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
|
|
100
|
+
*/
|
|
101
|
+
logout: (options?: LogoutOptions) => Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* After the browser redirects back to the callback page,
|
|
104
|
+
* call `handleRedirectCallback` to handle success and error
|
|
105
|
+
* responses from Auth0. If the response is successful, results
|
|
106
|
+
* will be valid according to their expiration times.
|
|
107
|
+
*
|
|
108
|
+
* @param url The URL to that should be used to retrieve the `state` and `code` values. Defaults to `window.location.href` if not given.
|
|
109
|
+
*/
|
|
110
|
+
handleRedirectCallback: (url?: string) => Promise<RedirectLoginResult>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @ignore
|
|
114
|
+
*/
|
|
115
|
+
export declare const initialContext: {
|
|
116
|
+
buildAuthorizeUrl: () => never;
|
|
117
|
+
buildLogoutUrl: () => never;
|
|
118
|
+
getAccessTokenSilently: () => never;
|
|
119
|
+
getAccessTokenWithPopup: () => never;
|
|
120
|
+
getIdTokenClaims: () => never;
|
|
121
|
+
loginWithRedirect: () => never;
|
|
122
|
+
loginWithPopup: () => never;
|
|
123
|
+
logout: () => never;
|
|
124
|
+
handleRedirectCallback: () => never;
|
|
125
|
+
error: Error | undefined;
|
|
126
|
+
isAuthenticated: boolean;
|
|
127
|
+
isLoading: boolean;
|
|
128
|
+
user: User | undefined;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The Auth0 Context
|
|
132
|
+
*/
|
|
133
|
+
declare const Auth0Context: import("react").Context<Auth0ContextInterface<User>>;
|
|
134
|
+
export default Auth0Context;
|
|
136
135
|
//# sourceMappingURL=auth0-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-context.d.ts","sourceRoot":"","sources":["../src/auth0-context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth0-context.d.ts","sourceRoot":"","sources":["../src/auth0-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,OAAO,EACP,aAAa,IAAI,gBAAgB,EACjC,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,IAAI,EACJ,+BAA+B,EAC/B,oBAAoB,IAAI,uBAAuB,EAChD,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC;CAAG;AAE9E,MAAM,WAAW,oBAAoB,CAAC,SAAS,GAAG,QAAQ,CACxD,SAAQ,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;CAAG;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,CAC9D,SAAQ,SAAS,CAAC,KAAK,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,sBAAsB,EAAE;QACtB,CACE,OAAO,EAAE,uBAAuB,GAAG;YAAE,gBAAgB,EAAE,IAAI,CAAA;SAAE,GAC5D,OAAO,CAAC,+BAA+B,CAAC,CAAC;QAC5C,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CACzC,+BAA+B,GAAG,MAAM,CACzC,CAAC;KACH,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,uBAAuB,EAAE,CACvB,OAAO,CAAC,EAAE,wBAAwB,EAClC,MAAM,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IAErD;;;;;;;;OAQG;IACH,iBAAiB,EAAE,CACjB,OAAO,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KACrC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;;;;;;;OAaG;IACH,cAAc,EAAE,CACd,OAAO,CAAC,EAAE,iBAAiB,EAC3B,MAAM,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;;;OASG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;;;;;;OAOG;IACH,sBAAsB,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACxE;AASD;;GAEG;AACH,eAAO,MAAM,cAAc;6BAPV,KAAK;0BAAL,KAAK;kCAAL,KAAK;mCAAL,KAAK;4BAAL,KAAK;6BAAL,KAAK;0BAAL,KAAK;kBAAL,KAAK;kCAAL,KAAK;;;;;CAkBrB,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,YAAY,sDAAuD,CAAC;AAE1E,eAAe,YAAY,CAAC"}
|
package/dist/auth0-provider.d.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Auth0ClientOptions, User } from '@auth0/auth0-spa-js';
|
|
3
|
-
import { Auth0ContextInterface } from './auth0-context';
|
|
4
|
-
/**
|
|
5
|
-
* The state of the application before the user was redirected to the login page.
|
|
6
|
-
*/
|
|
7
|
-
export type AppState = {
|
|
8
|
-
returnTo?: string;
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* The main configuration to instantiate the `Auth0Provider`.
|
|
13
|
-
*/
|
|
14
|
-
export interface Auth0ProviderOptions extends Auth0ClientOptions {
|
|
15
|
-
/**
|
|
16
|
-
* The child nodes your Provider has wrapped
|
|
17
|
-
*/
|
|
18
|
-
children?: React.ReactNode;
|
|
19
|
-
/**
|
|
20
|
-
* By default this removes the code and state parameters from the url when you are redirected from the authorize page.
|
|
21
|
-
* It uses `window.history` but you might want to overwrite this if you are using a custom router, like `react-router-dom`
|
|
22
|
-
* See the EXAMPLES.md for more info.
|
|
23
|
-
*/
|
|
24
|
-
onRedirectCallback?: (appState?: AppState, user?:
|
|
25
|
-
/**
|
|
26
|
-
* By default, if the page url has code/state params, the SDK will treat them as Auth0's and attempt to exchange the
|
|
27
|
-
* code for a token. In some cases the code might be for something else (another OAuth SDK perhaps). In these
|
|
28
|
-
* instances you can instruct the client to ignore them eg
|
|
29
|
-
*
|
|
30
|
-
* ```jsx
|
|
31
|
-
* <Auth0Provider
|
|
32
|
-
* clientId={clientId}
|
|
33
|
-
* domain={domain}
|
|
34
|
-
* skipRedirectCallback={window.location.pathname === '/stripe-oauth-callback'}
|
|
35
|
-
* >
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
skipRedirectCallback?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Context to be used when creating the Auth0Provider, defaults to the internally created context.
|
|
41
|
-
*
|
|
42
|
-
* This allows multiple Auth0Providers to be nested within the same application, the context value can then be
|
|
43
|
-
* passed to useAuth0, withAuth0, or withAuthenticationRequired to use that specific Auth0Provider to access
|
|
44
|
-
* auth state and methods specifically tied to the provider that the context belongs to.
|
|
45
|
-
*
|
|
46
|
-
* When using multiple Auth0Providers in a single application you should do the following to ensure sessions are not
|
|
47
|
-
* overwritten:
|
|
48
|
-
*
|
|
49
|
-
* * Configure a different redirect_uri for each Auth0Provider, and set skipRedirectCallback for each provider to ignore
|
|
50
|
-
* the others redirect_uri
|
|
51
|
-
* * If using localstorage for both Auth0Providers, ensure that the audience and scope are different for so that the key
|
|
52
|
-
* used to store data is different
|
|
53
|
-
*
|
|
54
|
-
* For a sample on using multiple Auth0Providers review the [React Account Linking Sample](https://github.com/auth0-samples/auth0-link-accounts-sample/tree/react-variant)
|
|
55
|
-
*/
|
|
56
|
-
context?: React.Context<Auth0ContextInterface
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* ```jsx
|
|
60
|
-
* <Auth0Provider
|
|
61
|
-
* domain={domain}
|
|
62
|
-
* clientId={clientId}
|
|
63
|
-
* authorizationParams={{ redirect_uri: window.location.origin }}>
|
|
64
|
-
* <MyApp />
|
|
65
|
-
* </Auth0Provider>
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* Provides the Auth0Context to its child components.
|
|
69
|
-
*/
|
|
70
|
-
declare const Auth0Provider: (opts: Auth0ProviderOptions) => React.JSX.Element;
|
|
71
|
-
export default Auth0Provider;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Auth0ClientOptions, User } from '@auth0/auth0-spa-js';
|
|
3
|
+
import { Auth0ContextInterface } from './auth0-context';
|
|
4
|
+
/**
|
|
5
|
+
* The state of the application before the user was redirected to the login page.
|
|
6
|
+
*/
|
|
7
|
+
export type AppState = {
|
|
8
|
+
returnTo?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The main configuration to instantiate the `Auth0Provider`.
|
|
13
|
+
*/
|
|
14
|
+
export interface Auth0ProviderOptions<TUser extends User = User> extends Auth0ClientOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The child nodes your Provider has wrapped
|
|
17
|
+
*/
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* By default this removes the code and state parameters from the url when you are redirected from the authorize page.
|
|
21
|
+
* It uses `window.history` but you might want to overwrite this if you are using a custom router, like `react-router-dom`
|
|
22
|
+
* See the EXAMPLES.md for more info.
|
|
23
|
+
*/
|
|
24
|
+
onRedirectCallback?: (appState?: AppState, user?: TUser) => void;
|
|
25
|
+
/**
|
|
26
|
+
* By default, if the page url has code/state params, the SDK will treat them as Auth0's and attempt to exchange the
|
|
27
|
+
* code for a token. In some cases the code might be for something else (another OAuth SDK perhaps). In these
|
|
28
|
+
* instances you can instruct the client to ignore them eg
|
|
29
|
+
*
|
|
30
|
+
* ```jsx
|
|
31
|
+
* <Auth0Provider
|
|
32
|
+
* clientId={clientId}
|
|
33
|
+
* domain={domain}
|
|
34
|
+
* skipRedirectCallback={window.location.pathname === '/stripe-oauth-callback'}
|
|
35
|
+
* >
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
skipRedirectCallback?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Context to be used when creating the Auth0Provider, defaults to the internally created context.
|
|
41
|
+
*
|
|
42
|
+
* This allows multiple Auth0Providers to be nested within the same application, the context value can then be
|
|
43
|
+
* passed to useAuth0, withAuth0, or withAuthenticationRequired to use that specific Auth0Provider to access
|
|
44
|
+
* auth state and methods specifically tied to the provider that the context belongs to.
|
|
45
|
+
*
|
|
46
|
+
* When using multiple Auth0Providers in a single application you should do the following to ensure sessions are not
|
|
47
|
+
* overwritten:
|
|
48
|
+
*
|
|
49
|
+
* * Configure a different redirect_uri for each Auth0Provider, and set skipRedirectCallback for each provider to ignore
|
|
50
|
+
* the others redirect_uri
|
|
51
|
+
* * If using localstorage for both Auth0Providers, ensure that the audience and scope are different for so that the key
|
|
52
|
+
* used to store data is different
|
|
53
|
+
*
|
|
54
|
+
* For a sample on using multiple Auth0Providers review the [React Account Linking Sample](https://github.com/auth0-samples/auth0-link-accounts-sample/tree/react-variant)
|
|
55
|
+
*/
|
|
56
|
+
context?: React.Context<Auth0ContextInterface<TUser>>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* ```jsx
|
|
60
|
+
* <Auth0Provider
|
|
61
|
+
* domain={domain}
|
|
62
|
+
* clientId={clientId}
|
|
63
|
+
* authorizationParams={{ redirect_uri: window.location.origin }}>
|
|
64
|
+
* <MyApp />
|
|
65
|
+
* </Auth0Provider>
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* Provides the Auth0Context to its child components.
|
|
69
|
+
*/
|
|
70
|
+
declare const Auth0Provider: <TUser extends User = User>(opts: Auth0ProviderOptions<TUser>) => React.JSX.Element;
|
|
71
|
+
export default Auth0Provider;
|
|
72
72
|
//# sourceMappingURL=auth0-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-provider.d.ts","sourceRoot":"","sources":["../src/auth0-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,kBAAkB,EAMlB,IAAI,EACL,MAAM,qBAAqB,CAAC;AAC7B,OAAqB,EACnB,qBAAqB,EAGtB,MAAM,iBAAiB,CAAC;AAUzB;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"auth0-provider.d.ts","sourceRoot":"","sources":["../src/auth0-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,kBAAkB,EAMlB,IAAI,EACL,MAAM,qBAAqB,CAAC;AAC7B,OAAqB,EACnB,qBAAqB,EAGtB,MAAM,iBAAiB,CAAC;AAUzB;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,CAAE,SAAQ,kBAAkB;IACzF;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IACjE;;;;;;;;;;;;OAYG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;CACvD;AAoCD;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa,GAAI,KAAK,SAAS,IAAI,GAAG,IAAI,EAAE,MAAM,oBAAoB,CAAC,KAAK,CAAC,sBAmKlF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|