@versini/auth0-react-thin 2.19.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/LICENSE +21 -0
- package/README.md +185 -0
- package/dist/auth-state.d.ts +15 -0
- package/dist/auth-state.d.ts.map +1 -0
- package/dist/auth0-context.d.ts +423 -0
- package/dist/auth0-context.d.ts.map +1 -0
- package/dist/auth0-provider.d.ts +96 -0
- package/dist/auth0-provider.d.ts.map +1 -0
- package/dist/auth0-react.cjs.js +830 -0
- package/dist/auth0-react.cjs.js.map +1 -0
- package/dist/auth0-react.esm.js +723 -0
- package/dist/auth0-react.esm.js.map +1 -0
- package/dist/auth0-react.js +759 -0
- package/dist/auth0-react.js.map +1 -0
- package/dist/auth0-react.min.js +2 -0
- package/dist/auth0-react.min.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/reducer.d.ts +19 -0
- package/dist/reducer.d.ts.map +1 -0
- package/dist/use-auth0.d.ts +29 -0
- package/dist/use-auth0.d.ts.map +1 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/with-auth0.d.ts +29 -0
- package/dist/with-auth0.d.ts.map +1 -0
- package/dist/with-authentication-required.d.ts +77 -0
- package/dist/with-authentication-required.d.ts.map +1 -0
- package/package.json +43 -0
- package/src/auth-state.tsx +21 -0
- package/src/auth0-context.tsx +506 -0
- package/src/auth0-provider.tsx +488 -0
- package/src/errors.tsx +14 -0
- package/src/index.tsx +100 -0
- package/src/reducer.tsx +59 -0
- package/src/use-auth0.tsx +34 -0
- package/src/utils.tsx +74 -0
- package/src/with-auth0.tsx +44 -0
- package/src/with-authentication-required.tsx +141 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Auth0Client, Auth0ClientOptions, User, ConnectAccountRedirectResult, ResponseType } from '@auth0/auth0-spa-js';
|
|
3
|
+
import { Auth0ContextInterface } from './auth0-context';
|
|
4
|
+
/**
|
|
5
|
+
* The account that has been connected during the connect flow.
|
|
6
|
+
*/
|
|
7
|
+
export type ConnectedAccount = Omit<ConnectAccountRedirectResult, 'appState' | 'response_type'>;
|
|
8
|
+
/**
|
|
9
|
+
* The state of the application before the user was redirected to the login page
|
|
10
|
+
* and any account that the user may have connected to.
|
|
11
|
+
*/
|
|
12
|
+
export type AppState = {
|
|
13
|
+
returnTo?: string;
|
|
14
|
+
connectedAccount?: ConnectedAccount;
|
|
15
|
+
response_type?: ResponseType;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
type Auth0ProviderBaseOptions<TUser extends User = User> = {
|
|
19
|
+
/**
|
|
20
|
+
* The child nodes your Provider has wrapped
|
|
21
|
+
*/
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* By default this removes the code and state parameters from the url when you are redirected from the authorize page.
|
|
25
|
+
* It uses `window.history` but you might want to overwrite this if you are using a custom router, like `react-router-dom`
|
|
26
|
+
* See the EXAMPLES.md for more info.
|
|
27
|
+
*/
|
|
28
|
+
onRedirectCallback?: (appState?: AppState, user?: TUser) => void;
|
|
29
|
+
/**
|
|
30
|
+
* By default, if the page url has code/state params, the SDK will treat them as Auth0's and attempt to exchange the
|
|
31
|
+
* code for a token. In some cases the code might be for something else (another OAuth SDK perhaps). In these
|
|
32
|
+
* instances you can instruct the client to ignore them eg
|
|
33
|
+
*
|
|
34
|
+
* ```jsx
|
|
35
|
+
* <Auth0Provider
|
|
36
|
+
* clientId={clientId}
|
|
37
|
+
* domain={domain}
|
|
38
|
+
* skipRedirectCallback={window.location.pathname === '/stripe-oauth-callback'}
|
|
39
|
+
* >
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
skipRedirectCallback?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Context to be used when creating the Auth0Provider, defaults to the internally created context.
|
|
45
|
+
*
|
|
46
|
+
* This allows multiple Auth0Providers to be nested within the same application, the context value can then be
|
|
47
|
+
* passed to useAuth0, withAuth0, or withAuthenticationRequired to use that specific Auth0Provider to access
|
|
48
|
+
* auth state and methods specifically tied to the provider that the context belongs to.
|
|
49
|
+
*
|
|
50
|
+
* When using multiple Auth0Providers in a single application you should do the following to ensure sessions are not
|
|
51
|
+
* overwritten:
|
|
52
|
+
*
|
|
53
|
+
* * Configure a different redirect_uri for each Auth0Provider, and set skipRedirectCallback for each provider to ignore
|
|
54
|
+
* the others redirect_uri
|
|
55
|
+
* * If using localstorage for both Auth0Providers, ensure that the audience and scope are different for so that the key
|
|
56
|
+
* used to store data is different
|
|
57
|
+
*
|
|
58
|
+
* 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)
|
|
59
|
+
*/
|
|
60
|
+
context?: React.Context<Auth0ContextInterface<TUser>>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Options for `Auth0Provider` when configuring Auth0 via `domain` and `clientId`.
|
|
64
|
+
* Use this type when building wrapper components around `Auth0Provider`.
|
|
65
|
+
*/
|
|
66
|
+
export type Auth0ProviderWithConfigOptions<TUser extends User = User> = Auth0ProviderBaseOptions<TUser> & Auth0ClientOptions & {
|
|
67
|
+
client?: never;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Options for `Auth0Provider` when supplying a pre-configured `Auth0Client` instance.
|
|
71
|
+
*/
|
|
72
|
+
export type Auth0ProviderWithClientOptions<TUser extends User = User> = Auth0ProviderBaseOptions<TUser> & {
|
|
73
|
+
client: Auth0Client;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The main configuration to instantiate the `Auth0Provider`.
|
|
77
|
+
*
|
|
78
|
+
* Either provide `domain` and `clientId` (`Auth0ProviderWithConfigOptions`)
|
|
79
|
+
* or a pre-configured `client` instance (`Auth0ProviderWithClientOptions`).
|
|
80
|
+
*/
|
|
81
|
+
export type Auth0ProviderOptions<TUser extends User = User> = Auth0ProviderWithConfigOptions<TUser> | Auth0ProviderWithClientOptions<TUser>;
|
|
82
|
+
/**
|
|
83
|
+
* ```jsx
|
|
84
|
+
* <Auth0Provider
|
|
85
|
+
* domain={domain}
|
|
86
|
+
* clientId={clientId}
|
|
87
|
+
* authorizationParams={{ redirect_uri: window.location.origin }}>
|
|
88
|
+
* <MyApp />
|
|
89
|
+
* </Auth0Provider>
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* Provides the Auth0Context to its child components.
|
|
93
|
+
*/
|
|
94
|
+
declare const Auth0Provider: <TUser extends User = User>(opts: Auth0ProviderOptions<TUser>) => React.JSX.Element;
|
|
95
|
+
export default Auth0Provider;
|
|
96
|
+
//# sourceMappingURL=auth0-provider.d.ts.map
|
|
@@ -0,0 +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,EACL,WAAW,EACX,kBAAkB,EAMlB,IAAI,EAEJ,4BAA4B,EAC5B,YAAY,EAMb,MAAM,qBAAqB,CAAC;AAC7B,OAAqB,EACnB,qBAAqB,EAGtB,MAAM,iBAAiB,CAAC;AAUzB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,eAAe,CAAC,CAAC;AAEhG;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,KAAK,wBAAwB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,IAAI;IACzD;;OAEG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