@auth0/auth0-react 2.2.4 → 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.
@@ -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?: Error;
7
- isAuthenticated: boolean;
8
- isLoading: boolean;
9
- user?: TUser;
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
@@ -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,CAAC,EAAE,KAAK,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAG9B,CAAC"}
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"}
@@ -1,134 +1,135 @@
1
- /// <reference types="react" />
2
- import { GetTokenSilentlyOptions, GetTokenWithPopupOptions, IdToken, LogoutOptions as SPALogoutOptions, PopupLoginOptions, PopupConfigOptions, RedirectLoginResult, User, GetTokenSilentlyVerboseResponse, RedirectLoginOptions as SPARedirectLoginOptions } from '@auth0/auth0-spa-js';
3
- import { AuthState } from './auth-state';
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'> {
8
- }
9
- /**
10
- * Contains the authenticated state and authentication methods provided by the `useAuth0` hook.
11
- */
12
- export interface Auth0ContextInterface<TUser extends User = User> extends AuthState<TUser> {
13
- /**
14
- * ```js
15
- * const token = await getAccessTokenSilently(options);
16
- * ```
17
- *
18
- * If there's a valid token stored, return it. Otherwise, opens an
19
- * iframe with the `/authorize` URL using the parameters provided
20
- * as arguments. Random and secure `state` and `nonce` parameters
21
- * will be auto-generated. If the response is successful, results
22
- * will be valid according to their expiration times.
23
- *
24
- * If refresh tokens are used, the token endpoint is called directly with the
25
- * 'refresh_token' grant. If no refresh token is available to make this call,
26
- * the SDK falls back to using an iframe to the '/authorize' URL.
27
- *
28
- * This method may use a web worker to perform the token call if the in-memory
29
- * cache is used.
30
- *
31
- * If an `audience` value is given to this function, the SDK always falls
32
- * back to using an iframe to make the token exchange.
33
- *
34
- * Note that in all cases, falling back to an iframe requires access to
35
- * the `auth0` cookie.
36
- */
37
- getAccessTokenSilently: {
38
- (options: GetTokenSilentlyOptions & {
39
- detailedResponse: true;
40
- }): Promise<GetTokenSilentlyVerboseResponse>;
41
- (options?: GetTokenSilentlyOptions): Promise<string>;
42
- (options: GetTokenSilentlyOptions): Promise<GetTokenSilentlyVerboseResponse | string>;
43
- };
44
- /**
45
- * ```js
46
- * const token = await getTokenWithPopup(options, config);
47
- * ```
48
- *
49
- * Get an access token interactively.
50
- *
51
- * Opens a popup with the `/authorize` URL using the parameters
52
- * provided as arguments. Random and secure `state` and `nonce`
53
- * parameters will be auto-generated. If the response is successful,
54
- * results will be valid according to their expiration times.
55
- */
56
- getAccessTokenWithPopup: (options?: GetTokenWithPopupOptions, config?: PopupConfigOptions) => Promise<string | undefined>;
57
- /**
58
- * ```js
59
- * const claims = await getIdTokenClaims();
60
- * ```
61
- *
62
- * Returns all claims from the id_token if available.
63
- */
64
- getIdTokenClaims: () => Promise<IdToken | undefined>;
65
- /**
66
- * ```js
67
- * await loginWithRedirect(options);
68
- * ```
69
- *
70
- * Performs a redirect to `/authorize` using the parameters
71
- * provided as arguments. Random and secure `state` and `nonce`
72
- * parameters will be auto-generated.
73
- */
74
- loginWithRedirect: (options?: RedirectLoginOptions<AppState>) => Promise<void>;
75
- /**
76
- * ```js
77
- * await loginWithPopup(options, config);
78
- * ```
79
- *
80
- * Opens a popup with the `/authorize` URL using the parameters
81
- * provided as arguments. Random and secure `state` and `nonce`
82
- * parameters will be auto-generated. If the response is successful,
83
- * results will be valid according to their expiration times.
84
- *
85
- * IMPORTANT: This method has to be called from an event handler
86
- * that was started by the user like a button click, for example,
87
- * otherwise the popup will be blocked in most browsers.
88
- */
89
- loginWithPopup: (options?: PopupLoginOptions, config?: PopupConfigOptions) => Promise<void>;
90
- /**
91
- * ```js
92
- * auth0.logout({ logoutParams: { returnTo: window.location.origin } });
93
- * ```
94
- *
95
- * Clears the application session and performs a redirect to `/v2/logout`, using
96
- * the parameters provided as arguments, to clear the Auth0 session.
97
- * If the `logoutParams.federated` option is specified, it also clears the Identity Provider session.
98
- * [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
99
- */
100
- logout: (options?: LogoutOptions) => Promise<void>;
101
- /**
102
- * After the browser redirects back to the callback page,
103
- * call `handleRedirectCallback` to handle success and error
104
- * responses from Auth0. If the response is successful, results
105
- * will be valid according to their expiration times.
106
- *
107
- * @param url The URL to that should be used to retrieve the `state` and `code` values. Defaults to `window.location.href` if not given.
108
- */
109
- handleRedirectCallback: (url?: string) => Promise<RedirectLoginResult>;
110
- }
111
- /**
112
- * @ignore
113
- */
114
- export declare const initialContext: {
115
- buildAuthorizeUrl: () => never;
116
- buildLogoutUrl: () => never;
117
- getAccessTokenSilently: () => never;
118
- getAccessTokenWithPopup: () => never;
119
- getIdTokenClaims: () => never;
120
- loginWithRedirect: () => never;
121
- loginWithPopup: () => never;
122
- logout: () => never;
123
- handleRedirectCallback: () => never;
124
- error?: Error | undefined;
125
- isAuthenticated: boolean;
126
- isLoading: boolean;
127
- user?: User | undefined;
128
- };
129
- /**
130
- * The Auth0 Context
131
- */
132
- declare const Auth0Context: import("react").Context<Auth0ContextInterface<User>>;
133
- 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;
134
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":";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,u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,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"}
@@ -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?: User) => 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>;
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) => 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,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;AAoCD;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa,SAAU,oBAAoB,KAAG,WA8JnD,CAAC;AAEF,eAAe,aAAa,CAAC"}
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,C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