@auth0/auth0-react 2.3.0 → 2.5.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 +179 -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 +466 -440
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +459 -434
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +466 -440
- 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/index.d.ts.map +1 -1
- 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 +17 -17
- package/src/auth-state.tsx +4 -2
- package/src/auth0-context.tsx +52 -2
- package/src/auth0-provider.tsx +38 -10
- package/src/errors.tsx +1 -1
- package/src/index.tsx +3 -1
- package/src/reducer.tsx +4 -4
- package/src/utils.tsx +1 -1
- package/src/with-authentication-required.tsx +2 -2
package/dist/errors.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An OAuth2 error will come from the authorization server and will have at least an `error` property which will
|
|
3
|
-
* be the error code. And possibly an `error_description` property
|
|
4
|
-
*
|
|
5
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.6
|
|
6
|
-
*/
|
|
7
|
-
export declare class OAuthError extends Error {
|
|
8
|
-
error: string;
|
|
9
|
-
error_description?: string | undefined;
|
|
10
|
-
constructor(error: string, error_description?: string | undefined);
|
|
11
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* An OAuth2 error will come from the authorization server and will have at least an `error` property which will
|
|
3
|
+
* be the error code. And possibly an `error_description` property
|
|
4
|
+
*
|
|
5
|
+
* See: https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.6
|
|
6
|
+
*/
|
|
7
|
+
export declare class OAuthError extends Error {
|
|
8
|
+
error: string;
|
|
9
|
+
error_description?: string | undefined;
|
|
10
|
+
constructor(error: string, error_description?: string | undefined);
|
|
11
|
+
}
|
|
12
12
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -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;
|
|
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,EAAE,MAAM;gBAAhD,KAAK,EAAE,MAAM,EAAS,iBAAiB,CAAC,EAAE,MAAM,YAAA;CAMpE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { default as Auth0Provider, Auth0ProviderOptions, AppState, } from './auth0-provider';
|
|
2
|
-
export { default as useAuth0 } from './use-auth0';
|
|
3
|
-
export { default as withAuth0, WithAuth0Props } from './with-auth0';
|
|
4
|
-
export { default as withAuthenticationRequired, WithAuthenticationRequiredOptions, } from './with-authentication-required';
|
|
5
|
-
export { default as Auth0Context, Auth0ContextInterface, initialContext, LogoutOptions, RedirectLoginOptions, } from './auth0-context';
|
|
6
|
-
export { AuthorizationParams, PopupLoginOptions, PopupConfigOptions, GetTokenWithPopupOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, ICache, InMemoryCache, LocalStorageCache, Cacheable, TimeoutError, MfaRequiredError, PopupCancelledError, PopupTimeoutError, AuthenticationError, MissingRefreshTokenError, GenericError } from '@auth0/auth0-spa-js';
|
|
7
|
-
export { OAuthError } from './errors';
|
|
1
|
+
export { default as Auth0Provider, Auth0ProviderOptions, AppState, } from './auth0-provider';
|
|
2
|
+
export { default as useAuth0 } from './use-auth0';
|
|
3
|
+
export { default as withAuth0, WithAuth0Props } from './with-auth0';
|
|
4
|
+
export { default as withAuthenticationRequired, WithAuthenticationRequiredOptions, } from './with-authentication-required';
|
|
5
|
+
export { default as Auth0Context, Auth0ContextInterface, initialContext, LogoutOptions, RedirectLoginOptions, } from './auth0-context';
|
|
6
|
+
export { AuthorizationParams, PopupLoginOptions, PopupConfigOptions, GetTokenWithPopupOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, ICache, InMemoryCache, LocalStorageCache, Cacheable, TimeoutError, MfaRequiredError, PopupCancelledError, PopupTimeoutError, AuthenticationError, MissingRefreshTokenError, GenericError, UseDpopNonceError, type FetcherConfig } from '@auth0/auth0-spa-js';
|
|
7
|
+
export { OAuthError } from './errors';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,oBAAoB,EACpB,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,OAAO,IAAI,0BAA0B,EACrC,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,OAAO,EACP,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,oBAAoB,EACpB,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,OAAO,IAAI,0BAA0B,EACrC,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,OAAO,EACP,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/reducer.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { User } from '@auth0/auth0-spa-js';
|
|
2
|
-
import { AuthState } from './auth-state';
|
|
3
|
-
type Action = {
|
|
4
|
-
type: 'LOGIN_POPUP_STARTED';
|
|
5
|
-
} | {
|
|
6
|
-
type: 'INITIALISED' | 'LOGIN_POPUP_COMPLETE' | 'GET_ACCESS_TOKEN_COMPLETE' | 'HANDLE_REDIRECT_COMPLETE';
|
|
7
|
-
user
|
|
8
|
-
} | {
|
|
9
|
-
type: 'LOGOUT';
|
|
10
|
-
} | {
|
|
11
|
-
type: 'ERROR';
|
|
12
|
-
error: Error;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Handles how that state changes in the `useAuth0` hook.
|
|
16
|
-
*/
|
|
17
|
-
export declare const reducer: (state: AuthState
|
|
18
|
-
export {};
|
|
1
|
+
import { User } from '@auth0/auth0-spa-js';
|
|
2
|
+
import { AuthState } from './auth-state';
|
|
3
|
+
type Action = {
|
|
4
|
+
type: 'LOGIN_POPUP_STARTED';
|
|
5
|
+
} | {
|
|
6
|
+
type: 'INITIALISED' | 'LOGIN_POPUP_COMPLETE' | 'GET_ACCESS_TOKEN_COMPLETE' | 'HANDLE_REDIRECT_COMPLETE';
|
|
7
|
+
user: User | undefined;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'LOGOUT';
|
|
10
|
+
} | {
|
|
11
|
+
type: 'ERROR';
|
|
12
|
+
error: Error;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Handles how that state changes in the `useAuth0` hook.
|
|
16
|
+
*/
|
|
17
|
+
export declare const reducer: <TUser extends User = User>(state: AuthState<TUser>, action: Action) => AuthState<TUser>;
|
|
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,KAAK,MAAM,GACP;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,GAC/B;IACE,IAAI,EACA,aAAa,GACb,sBAAsB,GACtB,2BAA2B,GAC3B,0BAA0B,CAAC;IAC/B,IAAI,
|
|
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,KAAK,MAAM,GACP;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,GAC/B;IACE,IAAI,EACA,aAAa,GACb,sBAAsB,GACtB,2BAA2B,GAC3B,0BAA0B,CAAC;IAC/B,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACxB,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,GAAI,KAAK,SAAS,IAAI,GAAG,IAAI,EAAE,OAAO,SAAS,CAAC,KAAK,CAAC,EAAE,QAAQ,MAAM,KAAG,SAAS,CAAC,KAAK,CAuC3G,CAAC"}
|
package/dist/use-auth0.d.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export default useAuth0;
|
|
1
|
+
import { User } from '@auth0/auth0-spa-js';
|
|
2
|
+
import { Auth0ContextInterface } from './auth0-context';
|
|
3
|
+
/**
|
|
4
|
+
* ```js
|
|
5
|
+
* const {
|
|
6
|
+
* // Auth state:
|
|
7
|
+
* error,
|
|
8
|
+
* isAuthenticated,
|
|
9
|
+
* isLoading,
|
|
10
|
+
* user,
|
|
11
|
+
* // Auth methods:
|
|
12
|
+
* getAccessTokenSilently,
|
|
13
|
+
* getAccessTokenWithPopup,
|
|
14
|
+
* getIdTokenClaims,
|
|
15
|
+
* loginWithRedirect,
|
|
16
|
+
* loginWithPopup,
|
|
17
|
+
* logout,
|
|
18
|
+
* } = useAuth0<TUser>();
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Use the `useAuth0` hook in your components to access the auth state and methods.
|
|
22
|
+
*
|
|
23
|
+
* TUser is an optional type param to provide a type to the `user` field.
|
|
24
|
+
*/
|
|
25
|
+
declare const useAuth0: <TUser extends User = User>(context?: import("react").Context<Auth0ContextInterface<User>>) => Auth0ContextInterface<TUser>;
|
|
26
|
+
export default useAuth0;
|
|
28
27
|
//# sourceMappingURL=use-auth0.d.ts.map
|
package/dist/use-auth0.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-auth0.d.ts","sourceRoot":"","sources":["../src/use-auth0.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-auth0.d.ts","sourceRoot":"","sources":["../src/use-auth0.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,QAAQ,GAAI,KAAK,SAAS,IAAI,GAAG,IAAI,EACzC,8DAAsB,KACrB,qBAAqB,CAAC,KAAK,CACuB,CAAC;AAEtD,eAAe,QAAQ,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const hasAuthParams: (searchParams?: string) => boolean;
|
|
2
|
-
export declare const loginError: (error: unknown) => Error;
|
|
3
|
-
export declare const tokenError: (error: unknown) => Error;
|
|
4
|
-
/**
|
|
5
|
-
* @ignore
|
|
6
|
-
* Helper function to map the v1 `redirectUri` option to the v2 `authorizationParams.redirect_uri`
|
|
7
|
-
* and log a warning.
|
|
8
|
-
*/
|
|
9
|
-
export declare const deprecateRedirectUri: (options?: any) => void;
|
|
1
|
+
export declare const hasAuthParams: (searchParams?: string) => boolean;
|
|
2
|
+
export declare const loginError: (error: unknown) => Error;
|
|
3
|
+
export declare const tokenError: (error: unknown) => Error;
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
* Helper function to map the v1 `redirectUri` option to the v2 `authorizationParams.redirect_uri`
|
|
7
|
+
* and log a warning.
|
|
8
|
+
*/
|
|
9
|
+
export declare const deprecateRedirectUri: (options?: any) => void;
|
|
10
10
|
//# sourceMappingURL=utils.d.ts.map
|
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,GAAI,qBAAqC,KAAG,OAEzC,CAAC;AA0B9B,eAAO,MAAM,UAAU,UAtBb,OAAO,KAAG,KAsBsC,CAAC;AAE3D,eAAO,MAAM,UAAU,UAxBb,OAAO,KAAG,KAwBiD,CAAC;AAEtE;;;;GAIG;AAEH,eAAO,MAAM,oBAAoB,GAAI,UAAU,GAAG,SAkBjD,CAAC"}
|
package/dist/with-auth0.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import React, { ComponentType } from 'react';
|
|
2
|
-
import { Auth0ContextInterface } from './auth0-context';
|
|
3
|
-
/**
|
|
4
|
-
* Components wrapped in `withAuth0` will have an additional `auth0` prop
|
|
5
|
-
*/
|
|
6
|
-
export interface WithAuth0Props {
|
|
7
|
-
auth0: Auth0ContextInterface;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* ```jsx
|
|
11
|
-
* class MyComponent extends Component {
|
|
12
|
-
* render() {
|
|
13
|
-
* // Access the auth context from the `auth0` prop
|
|
14
|
-
* const { user } = this.props.auth0;
|
|
15
|
-
* return <div>Hello {user.name}!</div>
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
* // Wrap your class component in withAuth0
|
|
19
|
-
* export default withAuth0(MyComponent);
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* Wrap your class components in this Higher Order Component to give them access to the Auth0Context.
|
|
23
|
-
*
|
|
24
|
-
* Providing a context as the second argument allows you to configure the Auth0Provider the Auth0Context
|
|
25
|
-
* should come from f you have multiple within your application.
|
|
26
|
-
*/
|
|
27
|
-
declare const withAuth0: <P extends WithAuth0Props>(Component:
|
|
28
|
-
export default withAuth0;
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
import { Auth0ContextInterface } from './auth0-context';
|
|
3
|
+
/**
|
|
4
|
+
* Components wrapped in `withAuth0` will have an additional `auth0` prop
|
|
5
|
+
*/
|
|
6
|
+
export interface WithAuth0Props {
|
|
7
|
+
auth0: Auth0ContextInterface;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ```jsx
|
|
11
|
+
* class MyComponent extends Component {
|
|
12
|
+
* render() {
|
|
13
|
+
* // Access the auth context from the `auth0` prop
|
|
14
|
+
* const { user } = this.props.auth0;
|
|
15
|
+
* return <div>Hello {user.name}!</div>
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* // Wrap your class component in withAuth0
|
|
19
|
+
* export default withAuth0(MyComponent);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Wrap your class components in this Higher Order Component to give them access to the Auth0Context.
|
|
23
|
+
*
|
|
24
|
+
* Providing a context as the second argument allows you to configure the Auth0Provider the Auth0Context
|
|
25
|
+
* should come from f you have multiple within your application.
|
|
26
|
+
*/
|
|
27
|
+
declare const withAuth0: <P extends WithAuth0Props>(Component: ComponentType<P>, context?: React.Context<Auth0ContextInterface<import("@auth0/auth0-spa-js").User>>) => ComponentType<Omit<P, keyof WithAuth0Props>>;
|
|
28
|
+
export default withAuth0;
|
|
29
29
|
//# 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,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;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,SAAS,
|
|
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;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,SAAS,GAAI,CAAC,SAAS,cAAc,EACzC,WAAW,aAAa,CAAC,CAAC,CAAC,EAC3B,kFAAsB,KACrB,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,cAAc,CAAC,CAU7C,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import React, { ComponentType, FC } from 'react';
|
|
2
|
-
import { Auth0ContextInterface, RedirectLoginOptions } from './auth0-context';
|
|
3
|
-
/**
|
|
4
|
-
* Options for the withAuthenticationRequired Higher Order Component
|
|
5
|
-
*/
|
|
6
|
-
export interface WithAuthenticationRequiredOptions {
|
|
7
|
-
/**
|
|
8
|
-
* ```js
|
|
9
|
-
* withAuthenticationRequired(Profile, {
|
|
10
|
-
* returnTo: '/profile'
|
|
11
|
-
* })
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* or
|
|
15
|
-
*
|
|
16
|
-
* ```js
|
|
17
|
-
* withAuthenticationRequired(Profile, {
|
|
18
|
-
* returnTo: () => window.location.hash.substr(1)
|
|
19
|
-
* })
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* Add a path for the `onRedirectCallback` handler to return the user to after login.
|
|
23
|
-
*/
|
|
24
|
-
returnTo?: string | (() => string);
|
|
25
|
-
/**
|
|
26
|
-
* ```js
|
|
27
|
-
* withAuthenticationRequired(Profile, {
|
|
28
|
-
* onRedirecting: () => <div>Redirecting you to the login...</div>
|
|
29
|
-
* })
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* Render a message to show that the user is being redirected to the login.
|
|
33
|
-
*/
|
|
34
|
-
onRedirecting?: () => React.JSX.Element;
|
|
35
|
-
/**
|
|
36
|
-
* ```js
|
|
37
|
-
* withAuthenticationRequired(Profile, {
|
|
38
|
-
* onBeforeAuthentication: () => { analyticsLibrary.track('login_triggered'); }
|
|
39
|
-
* })
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* Allows executing logic before the user is redirected to the login page.
|
|
43
|
-
*/
|
|
44
|
-
onBeforeAuthentication?: () => Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* ```js
|
|
47
|
-
* withAuthenticationRequired(Profile, {
|
|
48
|
-
* loginOptions: {
|
|
49
|
-
* appState: {
|
|
50
|
-
* customProp: 'foo'
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
* })
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* Pass additional login options, like extra `appState` to the login page.
|
|
57
|
-
* This will be merged with the `returnTo` option used by the `onRedirectCallback` handler.
|
|
58
|
-
*/
|
|
59
|
-
loginOptions?: RedirectLoginOptions;
|
|
60
|
-
/**
|
|
61
|
-
* The context to be used when calling useAuth0, this should only be provided if you are using multiple Auth0Providers
|
|
62
|
-
* within your application and you wish to tie a specific component to a Auth0Provider other than the Auth0Provider
|
|
63
|
-
* associated with the default Auth0Context.
|
|
64
|
-
*/
|
|
65
|
-
context?: React.Context<Auth0ContextInterface>;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* ```js
|
|
69
|
-
* const MyProtectedComponent = withAuthenticationRequired(MyComponent);
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* When you wrap your components in this Higher Order Component and an anonymous user visits your component
|
|
73
|
-
* they will be redirected to the login page; after login they will be returned to the page they were redirected from.
|
|
74
|
-
*/
|
|
75
|
-
declare const withAuthenticationRequired: <P extends object>(Component:
|
|
76
|
-
export default withAuthenticationRequired;
|
|
1
|
+
import React, { ComponentType, FC } from 'react';
|
|
2
|
+
import { Auth0ContextInterface, RedirectLoginOptions } from './auth0-context';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the withAuthenticationRequired Higher Order Component
|
|
5
|
+
*/
|
|
6
|
+
export interface WithAuthenticationRequiredOptions {
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* withAuthenticationRequired(Profile, {
|
|
10
|
+
* returnTo: '/profile'
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* or
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* withAuthenticationRequired(Profile, {
|
|
18
|
+
* returnTo: () => window.location.hash.substr(1)
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Add a path for the `onRedirectCallback` handler to return the user to after login.
|
|
23
|
+
*/
|
|
24
|
+
returnTo?: string | (() => string);
|
|
25
|
+
/**
|
|
26
|
+
* ```js
|
|
27
|
+
* withAuthenticationRequired(Profile, {
|
|
28
|
+
* onRedirecting: () => <div>Redirecting you to the login...</div>
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Render a message to show that the user is being redirected to the login.
|
|
33
|
+
*/
|
|
34
|
+
onRedirecting?: () => React.JSX.Element;
|
|
35
|
+
/**
|
|
36
|
+
* ```js
|
|
37
|
+
* withAuthenticationRequired(Profile, {
|
|
38
|
+
* onBeforeAuthentication: () => { analyticsLibrary.track('login_triggered'); }
|
|
39
|
+
* })
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* Allows executing logic before the user is redirected to the login page.
|
|
43
|
+
*/
|
|
44
|
+
onBeforeAuthentication?: () => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* ```js
|
|
47
|
+
* withAuthenticationRequired(Profile, {
|
|
48
|
+
* loginOptions: {
|
|
49
|
+
* appState: {
|
|
50
|
+
* customProp: 'foo'
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* })
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Pass additional login options, like extra `appState` to the login page.
|
|
57
|
+
* This will be merged with the `returnTo` option used by the `onRedirectCallback` handler.
|
|
58
|
+
*/
|
|
59
|
+
loginOptions?: RedirectLoginOptions;
|
|
60
|
+
/**
|
|
61
|
+
* The context to be used when calling useAuth0, this should only be provided if you are using multiple Auth0Providers
|
|
62
|
+
* within your application and you wish to tie a specific component to a Auth0Provider other than the Auth0Provider
|
|
63
|
+
* associated with the default Auth0Context.
|
|
64
|
+
*/
|
|
65
|
+
context?: React.Context<Auth0ContextInterface>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* ```js
|
|
69
|
+
* const MyProtectedComponent = withAuthenticationRequired(MyComponent);
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* When you wrap your components in this Higher Order Component and an anonymous user visits your component
|
|
73
|
+
* they will be redirected to the login page; after login they will be returned to the page they were redirected from.
|
|
74
|
+
*/
|
|
75
|
+
declare const withAuthenticationRequired: <P extends object>(Component: ComponentType<P>, options?: WithAuthenticationRequiredOptions) => FC<P>;
|
|
76
|
+
export default withAuthenticationRequired;
|
|
77
77
|
//# sourceMappingURL=with-authentication-required.d.ts.map
|
|
@@ -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,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,
|
|
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,GAAI,CAAC,SAAS,MAAM,EAClD,WAAW,aAAa,CAAC,CAAC,CAAC,EAC3B,UAAS,iCAAsC,KAC9C,EAAE,CAAC,CAAC,CAuCN,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.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"description": "Auth0 SDK for React Single Page Applications (SPA)",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"auth0",
|
|
@@ -54,28 +54,28 @@
|
|
|
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": "6.6.3",
|
|
58
|
-
"@testing-library/react": "16.1.0",
|
|
59
57
|
"@testing-library/dom": "^10.4.0",
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@types/
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
58
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
59
|
+
"@testing-library/react": "16.3.0",
|
|
60
|
+
"@types/jest": "^29.5.14",
|
|
61
|
+
"@types/react": "19.1.8",
|
|
62
|
+
"@types/react-dom": "19.1.6",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
64
|
+
"@typescript-eslint/parser": "^8.36.0",
|
|
65
65
|
"browserstack-cypress-cli": "^1.19.1",
|
|
66
66
|
"cypress": "^13.1.0",
|
|
67
67
|
"eslint": "^8.28.0",
|
|
68
68
|
"eslint-plugin-react": "^7.31.11",
|
|
69
69
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
70
70
|
"husky": "^8.0.3",
|
|
71
|
-
"jest": "^29.
|
|
71
|
+
"jest": "^29.7.0",
|
|
72
72
|
"jest-environment-jsdom": "^29.3.1",
|
|
73
73
|
"jest-junit": "^15.0.0",
|
|
74
|
-
"oidc-provider": "^8.
|
|
74
|
+
"oidc-provider": "^8.8.1",
|
|
75
75
|
"prettier": "^2.8.1",
|
|
76
76
|
"pretty-quick": "^3.1.3",
|
|
77
|
-
"react": "
|
|
78
|
-
"react-dom": "19.
|
|
77
|
+
"react": "19.1.0",
|
|
78
|
+
"react-dom": "19.1.0",
|
|
79
79
|
"rollup": "^3.7.0",
|
|
80
80
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
81
81
|
"rollup-plugin-delete": "^2.0.0",
|
|
@@ -85,16 +85,16 @@
|
|
|
85
85
|
"rollup-plugin-serve": "^2.0.2",
|
|
86
86
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
87
87
|
"start-server-and-test": "^2.0",
|
|
88
|
-
"ts-jest": "^29.0
|
|
89
|
-
"tslib": "^2.
|
|
90
|
-
"typedoc": "^0.
|
|
91
|
-
"typescript": "^
|
|
88
|
+
"ts-jest": "^29.4.0",
|
|
89
|
+
"tslib": "^2.8.1",
|
|
90
|
+
"typedoc": "^0.28.7",
|
|
91
|
+
"typescript": "^5.8.3"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"react": "^16.11.0 || ^17 || ^18 || ^19",
|
|
95
95
|
"react-dom": "^16.11.0 || ^17 || ^18 || ^19"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@auth0/auth0-spa-js": "^2.1
|
|
98
|
+
"@auth0/auth0-spa-js": "^2.4.1"
|
|
99
99
|
}
|
|
100
100
|
}
|
package/src/auth-state.tsx
CHANGED
|
@@ -4,10 +4,10 @@ import { User } from '@auth0/auth0-spa-js';
|
|
|
4
4
|
* The auth state which, when combined with the auth methods, make up the return object of the `useAuth0` hook.
|
|
5
5
|
*/
|
|
6
6
|
export interface AuthState<TUser extends User = User> {
|
|
7
|
-
error
|
|
7
|
+
error: Error | undefined;
|
|
8
8
|
isAuthenticated: boolean;
|
|
9
9
|
isLoading: boolean;
|
|
10
|
-
user
|
|
10
|
+
user: TUser | undefined;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -16,4 +16,6 @@ export interface AuthState<TUser extends User = User> {
|
|
|
16
16
|
export const initialAuthState: AuthState = {
|
|
17
17
|
isAuthenticated: false,
|
|
18
18
|
isLoading: true,
|
|
19
|
+
error: undefined,
|
|
20
|
+
user: undefined,
|
|
19
21
|
};
|
package/src/auth0-context.tsx
CHANGED
|
@@ -9,14 +9,15 @@ import {
|
|
|
9
9
|
User,
|
|
10
10
|
GetTokenSilentlyVerboseResponse,
|
|
11
11
|
RedirectLoginOptions as SPARedirectLoginOptions,
|
|
12
|
+
type Auth0Client,
|
|
12
13
|
} from '@auth0/auth0-spa-js';
|
|
13
14
|
import { createContext } from 'react';
|
|
14
15
|
import { AuthState, initialAuthState } from './auth-state';
|
|
15
16
|
import { AppState } from './auth0-provider';
|
|
16
17
|
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
18
19
|
export interface LogoutOptions extends Omit<SPALogoutOptions, 'onRedirect'> {}
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
20
21
|
export interface RedirectLoginOptions<TAppState = AppState>
|
|
21
22
|
extends Omit<SPARedirectLoginOptions<TAppState>, 'onRedirect'> {}
|
|
22
23
|
|
|
@@ -140,6 +141,51 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
140
141
|
* @param url The URL to that should be used to retrieve the `state` and `code` values. Defaults to `window.location.href` if not given.
|
|
141
142
|
*/
|
|
142
143
|
handleRedirectCallback: (url?: string) => Promise<RedirectLoginResult>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Returns the current DPoP nonce used for making requests to Auth0.
|
|
147
|
+
*
|
|
148
|
+
* It can return `undefined` because when starting fresh it will not
|
|
149
|
+
* be populated until after the first response from the server.
|
|
150
|
+
*
|
|
151
|
+
* It requires enabling the {@link Auth0ClientOptions.useDpop} option.
|
|
152
|
+
*
|
|
153
|
+
* @param nonce The nonce value.
|
|
154
|
+
* @param id The identifier of a nonce: if absent, it will get the nonce
|
|
155
|
+
* used for requests to Auth0. Otherwise, it will be used to
|
|
156
|
+
* select a specific non-Auth0 nonce.
|
|
157
|
+
*/
|
|
158
|
+
getDpopNonce: Auth0Client['getDpopNonce'];
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Sets the current DPoP nonce used for making requests to Auth0.
|
|
162
|
+
*
|
|
163
|
+
* It requires enabling the {@link Auth0ClientOptions.useDpop} option.
|
|
164
|
+
*
|
|
165
|
+
* @param nonce The nonce value.
|
|
166
|
+
* @param id The identifier of a nonce: if absent, it will set the nonce
|
|
167
|
+
* used for requests to Auth0. Otherwise, it will be used to
|
|
168
|
+
* select a specific non-Auth0 nonce.
|
|
169
|
+
*/
|
|
170
|
+
setDpopNonce: Auth0Client['setDpopNonce'];
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns a string to be used to demonstrate possession of the private
|
|
174
|
+
* key used to cryptographically bind access tokens with DPoP.
|
|
175
|
+
*
|
|
176
|
+
* It requires enabling the {@link Auth0ClientOptions.useDpop} option.
|
|
177
|
+
*/
|
|
178
|
+
generateDpopProof: Auth0Client['generateDpopProof'];
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Returns a new `Fetcher` class that will contain a `fetchWithAuth()` method.
|
|
182
|
+
* This is a drop-in replacement for the Fetch API's `fetch()` method, but will
|
|
183
|
+
* handle certain authentication logic for you, like building the proper auth
|
|
184
|
+
* headers or managing DPoP nonces and retries automatically.
|
|
185
|
+
*
|
|
186
|
+
* Check the `EXAMPLES.md` file for a deeper look into this method.
|
|
187
|
+
*/
|
|
188
|
+
createFetcher: Auth0Client['createFetcher'];
|
|
143
189
|
}
|
|
144
190
|
|
|
145
191
|
/**
|
|
@@ -163,6 +209,10 @@ export const initialContext = {
|
|
|
163
209
|
loginWithPopup: stub,
|
|
164
210
|
logout: stub,
|
|
165
211
|
handleRedirectCallback: stub,
|
|
212
|
+
getDpopNonce: stub,
|
|
213
|
+
setDpopNonce: stub,
|
|
214
|
+
generateDpopProof: stub,
|
|
215
|
+
createFetcher: stub,
|
|
166
216
|
};
|
|
167
217
|
|
|
168
218
|
/**
|