@auth0/auth0-react 1.12.1 → 2.0.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/README.md +3 -1
- package/dist/auth0-context.d.ts +9 -43
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts +3 -106
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +34 -58
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +29 -47
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +34 -58
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -15
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/reducer.d.ts +1 -1
- package/dist/reducer.d.ts.map +1 -1
- package/dist/with-authentication-required.d.ts +1 -7
- package/dist/with-authentication-required.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/auth0-context.tsx +14 -54
- package/src/auth0-provider.tsx +9 -155
- package/src/index.tsx +2 -2
- package/src/reducer.tsx +1 -1
- package/src/with-authentication-required.tsx +8 -19
package/README.md
CHANGED
package/dist/auth0-context.d.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { GetTokenSilentlyOptions, GetTokenWithPopupOptions, IdToken, LogoutOptions as SPALogoutOptions, PopupLoginOptions, PopupConfigOptions, RedirectLoginResult, User, GetTokenSilentlyVerboseResponse, RedirectLoginOptions as SPARedirectLoginOptions } from '@auth0/auth0-spa-js';
|
|
3
3
|
import { AuthState } from './auth-state';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* the "Allowed Callback URLs" field in your Auth0 Application's
|
|
9
|
-
* settings.
|
|
10
|
-
*/
|
|
11
|
-
redirectUri?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Used to store state before doing the redirect
|
|
14
|
-
*/
|
|
15
|
-
appState?: any;
|
|
16
|
-
/**
|
|
17
|
-
* Used to add to the URL fragment before redirecting
|
|
18
|
-
*/
|
|
19
|
-
fragment?: string;
|
|
4
|
+
import { AppState } from './auth0-provider';
|
|
5
|
+
export interface LogoutOptions extends Omit<SPALogoutOptions, 'onRedirect'> {
|
|
6
|
+
}
|
|
7
|
+
export interface RedirectLoginOptions<TAppState = AppState> extends Omit<SPARedirectLoginOptions<TAppState>, 'onRedirect'> {
|
|
20
8
|
}
|
|
21
9
|
/**
|
|
22
10
|
* Contains the authenticated state and authentication methods provided by the `useAuth0` hook.
|
|
@@ -65,7 +53,7 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
65
53
|
* parameters will be auto-generated. If the response is successful,
|
|
66
54
|
* results will be valid according to their expiration times.
|
|
67
55
|
*/
|
|
68
|
-
getAccessTokenWithPopup: (options?: GetTokenWithPopupOptions, config?: PopupConfigOptions) => Promise<string>;
|
|
56
|
+
getAccessTokenWithPopup: (options?: GetTokenWithPopupOptions, config?: PopupConfigOptions) => Promise<string | undefined>;
|
|
69
57
|
/**
|
|
70
58
|
* ```js
|
|
71
59
|
* const claims = await getIdTokenClaims();
|
|
@@ -73,7 +61,7 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
73
61
|
*
|
|
74
62
|
* Returns all claims from the id_token if available.
|
|
75
63
|
*/
|
|
76
|
-
getIdTokenClaims: (
|
|
64
|
+
getIdTokenClaims: () => Promise<IdToken | undefined>;
|
|
77
65
|
/**
|
|
78
66
|
* ```js
|
|
79
67
|
* await loginWithRedirect(options);
|
|
@@ -83,7 +71,7 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
83
71
|
* provided as arguments. Random and secure `state` and `nonce`
|
|
84
72
|
* parameters will be auto-generated.
|
|
85
73
|
*/
|
|
86
|
-
loginWithRedirect: (options?: RedirectLoginOptions) => Promise<void>;
|
|
74
|
+
loginWithRedirect: (options?: RedirectLoginOptions<AppState>) => Promise<void>;
|
|
87
75
|
/**
|
|
88
76
|
* ```js
|
|
89
77
|
* await loginWithPopup(options, config);
|
|
@@ -106,32 +94,10 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
106
94
|
*
|
|
107
95
|
* Clears the application session and performs a redirect to `/v2/logout`, using
|
|
108
96
|
* the parameters provided as arguments, to clear the Auth0 session.
|
|
109
|
-
* If the `federated` option is specified, it also clears the Identity Provider session.
|
|
110
|
-
* If the `localOnly` option is specified, it only clears the application session.
|
|
111
|
-
* It is invalid to set both the `federated` and `localOnly` options to `true`,
|
|
112
|
-
* and an error will be thrown if you do.
|
|
97
|
+
* If the `logoutParams.federated` option is specified, it also clears the Identity Provider session.
|
|
113
98
|
* [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
|
|
114
99
|
*/
|
|
115
100
|
logout: (options?: LogoutOptions) => void;
|
|
116
|
-
/**
|
|
117
|
-
* ```js
|
|
118
|
-
* const authUrl = await buildAuthorizeUrl();
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* Builds an `/authorize` URL for loginWithRedirect using the parameters
|
|
122
|
-
* provided as arguments. Random and secure `state` and `nonce`
|
|
123
|
-
* parameters will be auto-generated.
|
|
124
|
-
*/
|
|
125
|
-
buildAuthorizeUrl: (options?: Auth0RedirectLoginOptions) => Promise<string>;
|
|
126
|
-
/**
|
|
127
|
-
* ```js
|
|
128
|
-
* const logoutUrl = buildLogoutUrl();
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* returns a URL to the logout endpoint using the parameters provided as arguments.
|
|
132
|
-
* @param options
|
|
133
|
-
*/
|
|
134
|
-
buildLogoutUrl: (options?: LogoutUrlOptions) => string;
|
|
135
101
|
/**
|
|
136
102
|
* After the browser redirects back to the callback page,
|
|
137
103
|
* call `handleRedirectCallback` to handle success and error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-context.d.ts","sourceRoot":"","sources":["../src/auth0-context.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,
|
|
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;;;;;;;;;;;;;;;;;;;;;;;OAuBG;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,IAAI,CAAC;IAE1C;;;;;;;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,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Auth0ClientOptions, User } from '@auth0/auth0-spa-js';
|
|
3
3
|
import { Auth0ContextInterface } from './auth0-context';
|
|
4
4
|
/**
|
|
5
5
|
* The state of the application before the user was redirected to the login page.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type AppState = {
|
|
8
8
|
returnTo?: string;
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* The main configuration to instantiate the `Auth0Provider`.
|
|
13
13
|
*/
|
|
14
|
-
export interface Auth0ProviderOptions {
|
|
14
|
+
export interface Auth0ProviderOptions extends Auth0ClientOptions {
|
|
15
15
|
/**
|
|
16
16
|
* The child nodes your Provider has wrapped
|
|
17
17
|
*/
|
|
@@ -36,104 +36,6 @@ export interface Auth0ProviderOptions {
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
skipRedirectCallback?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Your Auth0 account domain such as `'example.auth0.com'`,
|
|
41
|
-
* `'example.eu.auth0.com'` or , `'example.mycompany.com'`
|
|
42
|
-
* (when using [custom domains](https://auth0.com/docs/custom-domains))
|
|
43
|
-
*/
|
|
44
|
-
domain: string;
|
|
45
|
-
/**
|
|
46
|
-
* The issuer to be used for validation of JWTs, optionally defaults to the domain above
|
|
47
|
-
*/
|
|
48
|
-
issuer?: string;
|
|
49
|
-
/**
|
|
50
|
-
* The Client ID found on your Application settings page
|
|
51
|
-
*/
|
|
52
|
-
clientId: string;
|
|
53
|
-
/**
|
|
54
|
-
* The default URL where Auth0 will redirect your browser to with
|
|
55
|
-
* the authentication result. It must be whitelisted in
|
|
56
|
-
* the "Allowed Callback URLs" field in your Auth0 Application's
|
|
57
|
-
* settings. If not provided here, it should be provided in the other
|
|
58
|
-
* methods that provide authentication.
|
|
59
|
-
*/
|
|
60
|
-
redirectUri?: string;
|
|
61
|
-
/**
|
|
62
|
-
* The value in seconds used to account for clock skew in JWT expirations.
|
|
63
|
-
* Typically, this value is no more than a minute or two at maximum.
|
|
64
|
-
* Defaults to 60s.
|
|
65
|
-
*/
|
|
66
|
-
leeway?: number;
|
|
67
|
-
/**
|
|
68
|
-
* The location to use when storing cache data. Valid values are `memory` or `localstorage`.
|
|
69
|
-
* The default setting is `memory`.
|
|
70
|
-
*
|
|
71
|
-
* Read more about [changing storage options in the Auth0 docs](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#change-storage-options)
|
|
72
|
-
*/
|
|
73
|
-
cacheLocation?: CacheLocation;
|
|
74
|
-
/**
|
|
75
|
-
* Specify a custom cache implementation to use for token storage and retrieval. This setting takes precedence over `cacheLocation` if they are both specified.
|
|
76
|
-
*
|
|
77
|
-
* Read more about [creating a custom cache](https://github.com/auth0/auth0-spa-js#creating-a-custom-cache)
|
|
78
|
-
*/
|
|
79
|
-
cache?: ICache;
|
|
80
|
-
/**
|
|
81
|
-
* If true, refresh tokens are used to fetch new access tokens from the Auth0 server. If false, the legacy technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` is used.
|
|
82
|
-
* The default setting is `false`.
|
|
83
|
-
*
|
|
84
|
-
* **Note**: Use of refresh tokens must be enabled by an administrator on your Auth0 client application.
|
|
85
|
-
*/
|
|
86
|
-
useRefreshTokens?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* A maximum number of seconds to wait before declaring background calls to /authorize as failed for timeout
|
|
89
|
-
* Defaults to 60s.
|
|
90
|
-
*/
|
|
91
|
-
authorizeTimeoutInSeconds?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Changes to recommended defaults, like defaultScope
|
|
94
|
-
*/
|
|
95
|
-
advancedOptions?: {
|
|
96
|
-
/**
|
|
97
|
-
* The default scope to be included with all requests.
|
|
98
|
-
* If not provided, 'openid profile email' is used. This can be set to `null` in order to effectively remove the default scopes.
|
|
99
|
-
*
|
|
100
|
-
* Note: The `openid` scope is **always applied** regardless of this setting.
|
|
101
|
-
*/
|
|
102
|
-
defaultScope?: string;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Maximum allowable elapsed time (in seconds) since authentication.
|
|
106
|
-
* If the last time the user authenticated is greater than this value,
|
|
107
|
-
* the user must be reauthenticated.
|
|
108
|
-
*/
|
|
109
|
-
maxAge?: string | number;
|
|
110
|
-
/**
|
|
111
|
-
* The default scope to be used on authentication requests.
|
|
112
|
-
* The defaultScope defined in the Auth0Client is included
|
|
113
|
-
* along with this scope
|
|
114
|
-
*/
|
|
115
|
-
scope?: string;
|
|
116
|
-
/**
|
|
117
|
-
* The default audience to be used for requesting API access.
|
|
118
|
-
*/
|
|
119
|
-
audience?: string;
|
|
120
|
-
/**
|
|
121
|
-
* The Id of an organization to log in to.
|
|
122
|
-
*
|
|
123
|
-
* This will specify an `organization` parameter in your user's login request and will add a step to validate
|
|
124
|
-
* the `org_id` claim in your user's ID Token.
|
|
125
|
-
*/
|
|
126
|
-
organization?: string;
|
|
127
|
-
/**
|
|
128
|
-
* 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.
|
|
129
|
-
*/
|
|
130
|
-
invitation?: string;
|
|
131
|
-
/**
|
|
132
|
-
* The name of the connection configured for your application.
|
|
133
|
-
* If null, it will redirect to the Auth0 Login Page and show
|
|
134
|
-
* the Login Widget.
|
|
135
|
-
*/
|
|
136
|
-
connection?: string;
|
|
137
39
|
/**
|
|
138
40
|
* Context to be used when creating the Auth0Provider, defaults to the internally created context.
|
|
139
41
|
*
|
|
@@ -152,11 +54,6 @@ export interface Auth0ProviderOptions {
|
|
|
152
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)
|
|
153
55
|
*/
|
|
154
56
|
context?: React.Context<Auth0ContextInterface>;
|
|
155
|
-
/**
|
|
156
|
-
* If you need to send custom parameters to the Authorization Server,
|
|
157
|
-
* make sure to use the original parameter name.
|
|
158
|
-
*/
|
|
159
|
-
[key: string]: any;
|
|
160
57
|
}
|
|
161
58
|
/**
|
|
162
59
|
* ```jsx
|
|
@@ -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,
|
|
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;AAKzB;;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,oBAAqB,SAAQ,kBAAkB;IAC9D;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IAChE;;;;;;;;;;;;OAYG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChD;AAkCD;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa,SAAU,oBAAoB,KAAG,WA2JnD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|