@auth0/auth0-react 1.5.0 → 1.9.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 -3
- package/dist/auth0-context.d.ts +9 -3
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts +13 -1
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +40 -25
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +39 -26
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +40 -25
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +2 -2
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- 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/utils.d.ts.map +1 -1
- package/dist/with-auth0.d.ts +2 -2
- package/dist/with-auth0.d.ts.map +1 -1
- package/dist/with-authentication-required.d.ts +1 -1
- package/dist/with-authentication-required.d.ts.map +1 -1
- package/package.json +14 -11
- package/src/auth0-context.tsx +13 -4
- package/src/auth0-provider.tsx +57 -23
- package/src/index.tsx +4 -0
- package/src/use-auth0.tsx +1 -1
- package/src/with-auth0.tsx +1 -1
- package/src/with-authentication-required.tsx +2 -2
- package/CHANGELOG.md +0 -116
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { default as useAuth0 } from './use-auth0';
|
|
|
3
3
|
export { default as withAuth0, WithAuth0Props } from './with-auth0';
|
|
4
4
|
export { default as withAuthenticationRequired, WithAuthenticationRequiredOptions, } from './with-authentication-required';
|
|
5
5
|
export { default as Auth0Context, Auth0ContextInterface, RedirectLoginOptions, } from './auth0-context';
|
|
6
|
-
export { PopupLoginOptions, PopupConfigOptions, GetIdTokenClaimsOptions, GetTokenWithPopupOptions, LogoutOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, } from '@auth0/auth0-spa-js';
|
|
6
|
+
export { PopupLoginOptions, PopupConfigOptions, GetIdTokenClaimsOptions, GetTokenWithPopupOptions, LogoutOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, ICache, InMemoryCache, LocalStorageCache, Cacheable, } from '@auth0/auth0-spa-js';
|
|
7
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,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,OAAO,EACP,IAAI,
|
|
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,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,OAAO,EACP,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/reducer.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ declare type Action = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Handles how that state changes in the `useAuth0` hook.
|
|
16
16
|
*/
|
|
17
|
-
export declare const reducer: (state: AuthState
|
|
17
|
+
export declare const reducer: (state: AuthState, action: Action) => AuthState;
|
|
18
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,aAAK,MAAM,GACP;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,GAC/B;IACE,IAAI,EACA,aAAa,GACb,sBAAsB,GACtB,2BAA2B,GAC3B,0BAA0B,CAAC;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,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,
|
|
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,aAAK,MAAM,GACP;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,GAC/B;IACE,IAAI,EACA,aAAa,GACb,sBAAsB,GACtB,2BAA2B,GAC3B,0BAA0B,CAAC;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,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,UAAW,SAAS,UAAU,MAAM,KAAG,SAuC1D,CAAC"}
|
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,6BAA4C,OAEzC,CAAC;AAc9B,eAAO,MAAM,UAAU;WAXG,MAAM;;mCAC7B,KAUuD,CAAC;AAE3D,eAAO,MAAM,UAAU;WAbG,MAAM;;mCAC7B,KAYkE,CAAC"}
|
package/dist/with-auth0.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
2
|
import { Auth0ContextInterface } from './auth0-context';
|
|
3
3
|
/**
|
|
4
4
|
* Components wrapped in `withAuth0` will have an additional `auth0` prop
|
|
@@ -21,6 +21,6 @@ export interface WithAuth0Props {
|
|
|
21
21
|
*
|
|
22
22
|
* Wrap your class components in this Higher Order Component to give them access to the Auth0Context
|
|
23
23
|
*/
|
|
24
|
-
declare const withAuth0: <P extends WithAuth0Props>(Component: React.ComponentType<P>) => React.ComponentType<
|
|
24
|
+
declare const withAuth0: <P extends WithAuth0Props>(Component: React.ComponentType<P>) => React.ComponentType<Omit<P, "auth0">>;
|
|
25
25
|
export default withAuth0;
|
|
26
26
|
//# 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,
|
|
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;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,SAAS,wGAQd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-authentication-required.d.ts","sourceRoot":"","sources":["../src/with-authentication-required.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;AAC5D,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAcjE;;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,GAAG,CAAC,OAAO,CAAC;IAClC;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,kEAErB,iCAAiC,gBAyC3C,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": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"description": "Auth0 SDK for React Single Page Applications (SPA)",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"auth0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint": "eslint --ext=tsx ./src ./__tests__",
|
|
25
25
|
"start": "rollup -cw",
|
|
26
26
|
"test": "jest --coverage",
|
|
27
|
-
"prepack": "npm run
|
|
27
|
+
"prepack": "npm run build",
|
|
28
28
|
"docs": "typedoc --options typedoc.js src",
|
|
29
29
|
"install:examples": "npm i --prefix=examples/cra-react-router --no-package-lock && npm i --prefix=examples/gatsby-app --no-package-lock && npm i --prefix=examples/nextjs-app --no-package-lock && npm ci --prefix=examples/users-api",
|
|
30
30
|
"start:cra": "npm start --prefix=examples/cra-react-router",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"test:nextjs": "start-server-and-test start:api 3001 start:nextjs 3000 cypress:run",
|
|
39
39
|
"test:nextjs:watch": "start-server-and-test start:api 3001 start:nextjs 3000 cypress:open",
|
|
40
40
|
"test:integration": "npm run test:cra && npm run test:gatsby && npm run test:nextjs",
|
|
41
|
-
"cypress:run": "cypress run",
|
|
41
|
+
"cypress:run": "cypress run --spec 'cypress/integration/smoke.test.ts'",
|
|
42
42
|
"cypress:open": "cypress open",
|
|
43
43
|
"codecov": "codecov"
|
|
44
44
|
},
|
|
@@ -57,37 +57,40 @@
|
|
|
57
57
|
"@testing-library/jest-dom": "^5.5.0",
|
|
58
58
|
"@testing-library/react": "^10.0.4",
|
|
59
59
|
"@testing-library/react-hooks": "^3.2.1",
|
|
60
|
-
"@types/jest": "^
|
|
60
|
+
"@types/jest": "^27.4.0",
|
|
61
61
|
"@types/react": "^16.9.34",
|
|
62
62
|
"@types/react-dom": "^16.9.6",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^2.30.0",
|
|
64
64
|
"@typescript-eslint/parser": "^2.30.0",
|
|
65
|
+
"browserstack-cypress-cli": "^1.8.1",
|
|
65
66
|
"codecov": "^3.7.2",
|
|
66
|
-
"cypress": "^
|
|
67
|
+
"cypress": "^7.2.0",
|
|
67
68
|
"eslint": "^6.8.0",
|
|
68
69
|
"eslint-plugin-react": "^7.19.0",
|
|
69
70
|
"eslint-plugin-react-hooks": "^4.0.0",
|
|
70
71
|
"husky": "^4.2.5",
|
|
71
|
-
"jest": "^
|
|
72
|
+
"jest": "^27.4.7",
|
|
72
73
|
"jest-junit": "^10.0.0",
|
|
74
|
+
"oidc-provider": "^7.6.0",
|
|
73
75
|
"prettier": "2.0.5",
|
|
74
76
|
"pretty-quick": "^2.0.1",
|
|
75
|
-
"react": "^16.
|
|
76
|
-
"react-dom": "^16.
|
|
77
|
+
"react": "^16.14.0",
|
|
78
|
+
"react-dom": "^16.14.0",
|
|
77
79
|
"react-test-renderer": "^16.13.1",
|
|
78
80
|
"rollup": "^2.7.2",
|
|
79
81
|
"rollup-plugin-analyzer": "^3.3.0",
|
|
80
82
|
"rollup-plugin-delete": "^1.2.0",
|
|
83
|
+
"rollup-plugin-dev": "^1.1.3",
|
|
81
84
|
"rollup-plugin-livereload": "^1.2.0",
|
|
82
85
|
"rollup-plugin-peer-deps-external": "^2.2.2",
|
|
83
86
|
"rollup-plugin-serve": "^1.0.1",
|
|
84
87
|
"rollup-plugin-terser": "^7.0.0",
|
|
85
88
|
"rollup-plugin-typescript2": "^0.27.0",
|
|
86
89
|
"start-server-and-test": "^1.11.0",
|
|
87
|
-
"ts-jest": "^
|
|
90
|
+
"ts-jest": "^27.1.2",
|
|
88
91
|
"tslib": "^1.11.1",
|
|
89
92
|
"typedoc": "^0.20.32",
|
|
90
|
-
"typescript": "^
|
|
93
|
+
"typescript": "^4.5.4"
|
|
91
94
|
},
|
|
92
95
|
"peerDependencies": {
|
|
93
96
|
"react": "^16.11.0 || ^17",
|
|
@@ -99,6 +102,6 @@
|
|
|
99
102
|
}
|
|
100
103
|
},
|
|
101
104
|
"dependencies": {
|
|
102
|
-
"@auth0/auth0-spa-js": "^1.
|
|
105
|
+
"@auth0/auth0-spa-js": "^1.19.3"
|
|
103
106
|
}
|
|
104
107
|
}
|
package/src/auth0-context.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
RedirectLoginOptions as Auth0RedirectLoginOptions,
|
|
12
12
|
RedirectLoginResult,
|
|
13
13
|
User,
|
|
14
|
+
GetTokenSilentlyVerboseResponse,
|
|
14
15
|
} from '@auth0/auth0-spa-js';
|
|
15
16
|
import { createContext } from 'react';
|
|
16
17
|
import { AuthState, initialAuthState } from './auth-state';
|
|
@@ -64,9 +65,15 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
64
65
|
* Note that in all cases, falling back to an iframe requires access to
|
|
65
66
|
* the `auth0` cookie.
|
|
66
67
|
*/
|
|
67
|
-
getAccessTokenSilently:
|
|
68
|
-
options
|
|
69
|
-
|
|
68
|
+
getAccessTokenSilently: {
|
|
69
|
+
(options: GetTokenSilentlyOptions & { detailedResponse: true }): Promise<
|
|
70
|
+
GetTokenSilentlyVerboseResponse
|
|
71
|
+
>;
|
|
72
|
+
(options?: GetTokenSilentlyOptions): Promise<string>;
|
|
73
|
+
(options: GetTokenSilentlyOptions): Promise<
|
|
74
|
+
GetTokenSilentlyVerboseResponse | string
|
|
75
|
+
>;
|
|
76
|
+
};
|
|
70
77
|
|
|
71
78
|
/**
|
|
72
79
|
* ```js
|
|
@@ -92,7 +99,9 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
92
99
|
*
|
|
93
100
|
* Returns all claims from the id_token if available.
|
|
94
101
|
*/
|
|
95
|
-
getIdTokenClaims: (
|
|
102
|
+
getIdTokenClaims: (
|
|
103
|
+
options?: GetIdTokenClaimsOptions
|
|
104
|
+
) => Promise<IdToken | undefined>;
|
|
96
105
|
|
|
97
106
|
/**
|
|
98
107
|
* ```js
|
package/src/auth0-provider.tsx
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useReducer,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import {
|
|
3
9
|
Auth0Client,
|
|
4
10
|
Auth0ClientOptions,
|
|
5
11
|
CacheLocation,
|
|
6
|
-
IdToken,
|
|
7
12
|
LogoutOptions,
|
|
8
13
|
LogoutUrlOptions,
|
|
9
14
|
PopupLoginOptions,
|
|
10
15
|
PopupConfigOptions,
|
|
11
16
|
RedirectLoginOptions as Auth0RedirectLoginOptions,
|
|
12
17
|
GetTokenWithPopupOptions,
|
|
13
|
-
GetTokenSilentlyOptions,
|
|
14
|
-
GetIdTokenClaimsOptions,
|
|
15
18
|
RedirectLoginResult,
|
|
19
|
+
ICache,
|
|
20
|
+
GetTokenSilentlyOptions,
|
|
16
21
|
} from '@auth0/auth0-spa-js';
|
|
17
22
|
import Auth0Context, { RedirectLoginOptions } from './auth0-context';
|
|
18
23
|
import { hasAuthParams, loginError, tokenError } from './utils';
|
|
@@ -90,6 +95,12 @@ export interface Auth0ProviderOptions {
|
|
|
90
95
|
* Read more about [changing storage options in the Auth0 docs](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#change-storage-options)
|
|
91
96
|
*/
|
|
92
97
|
cacheLocation?: CacheLocation;
|
|
98
|
+
/**
|
|
99
|
+
* Specify a custom cache implementation to use for token storage and retrieval. This setting takes precedence over `cacheLocation` if they are both specified.
|
|
100
|
+
*
|
|
101
|
+
* Read more about [creating a custom cache](https://github.com/auth0/auth0-spa-js#creating-a-custom-cache)
|
|
102
|
+
*/
|
|
103
|
+
cache?: ICache;
|
|
93
104
|
/**
|
|
94
105
|
* 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.
|
|
95
106
|
* The default setting is `false`.
|
|
@@ -141,6 +152,12 @@ export interface Auth0ProviderOptions {
|
|
|
141
152
|
* 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.
|
|
142
153
|
*/
|
|
143
154
|
invitation?: string;
|
|
155
|
+
/**
|
|
156
|
+
* The name of the connection configured for your application.
|
|
157
|
+
* If null, it will redirect to the Auth0 Login Page and show
|
|
158
|
+
* the Login Widget.
|
|
159
|
+
*/
|
|
160
|
+
connection?: string;
|
|
144
161
|
/**
|
|
145
162
|
* If you need to send custom parameters to the Authorization Server,
|
|
146
163
|
* make sure to use the original parameter name.
|
|
@@ -277,17 +294,22 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
|
|
|
277
294
|
);
|
|
278
295
|
|
|
279
296
|
const logout = useCallback(
|
|
280
|
-
(opts: LogoutOptions = {}): void => {
|
|
281
|
-
client.logout(opts);
|
|
297
|
+
(opts: LogoutOptions = {}): Promise<void> | void => {
|
|
298
|
+
const maybePromise = client.logout(opts);
|
|
282
299
|
if (opts.localOnly) {
|
|
300
|
+
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
301
|
+
return maybePromise.then(() => dispatch({ type: 'LOGOUT' }));
|
|
302
|
+
}
|
|
283
303
|
dispatch({ type: 'LOGOUT' });
|
|
284
304
|
}
|
|
305
|
+
return maybePromise;
|
|
285
306
|
},
|
|
286
307
|
[client]
|
|
287
308
|
);
|
|
288
309
|
|
|
289
310
|
const getAccessTokenSilently = useCallback(
|
|
290
|
-
|
|
311
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
312
|
+
async (opts?: GetTokenSilentlyOptions): Promise<any> => {
|
|
291
313
|
let token;
|
|
292
314
|
try {
|
|
293
315
|
token = await client.getTokenSilently(opts);
|
|
@@ -326,8 +348,7 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
|
|
|
326
348
|
);
|
|
327
349
|
|
|
328
350
|
const getIdTokenClaims = useCallback(
|
|
329
|
-
(opts
|
|
330
|
-
client.getIdTokenClaims(opts),
|
|
351
|
+
(opts) => client.getIdTokenClaims(opts),
|
|
331
352
|
[client]
|
|
332
353
|
);
|
|
333
354
|
|
|
@@ -347,21 +368,34 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
|
|
|
347
368
|
[client]
|
|
348
369
|
);
|
|
349
370
|
|
|
371
|
+
const contextValue = useMemo(() => {
|
|
372
|
+
return {
|
|
373
|
+
...state,
|
|
374
|
+
buildAuthorizeUrl,
|
|
375
|
+
buildLogoutUrl,
|
|
376
|
+
getAccessTokenSilently,
|
|
377
|
+
getAccessTokenWithPopup,
|
|
378
|
+
getIdTokenClaims,
|
|
379
|
+
loginWithRedirect,
|
|
380
|
+
loginWithPopup,
|
|
381
|
+
logout,
|
|
382
|
+
handleRedirectCallback,
|
|
383
|
+
};
|
|
384
|
+
}, [
|
|
385
|
+
state,
|
|
386
|
+
buildAuthorizeUrl,
|
|
387
|
+
buildLogoutUrl,
|
|
388
|
+
getAccessTokenSilently,
|
|
389
|
+
getAccessTokenWithPopup,
|
|
390
|
+
getIdTokenClaims,
|
|
391
|
+
loginWithRedirect,
|
|
392
|
+
loginWithPopup,
|
|
393
|
+
logout,
|
|
394
|
+
handleRedirectCallback,
|
|
395
|
+
]);
|
|
396
|
+
|
|
350
397
|
return (
|
|
351
|
-
<Auth0Context.Provider
|
|
352
|
-
value={{
|
|
353
|
-
...state,
|
|
354
|
-
buildAuthorizeUrl,
|
|
355
|
-
buildLogoutUrl,
|
|
356
|
-
getAccessTokenSilently,
|
|
357
|
-
getAccessTokenWithPopup,
|
|
358
|
-
getIdTokenClaims,
|
|
359
|
-
loginWithRedirect,
|
|
360
|
-
loginWithPopup,
|
|
361
|
-
logout,
|
|
362
|
-
handleRedirectCallback,
|
|
363
|
-
}}
|
|
364
|
-
>
|
|
398
|
+
<Auth0Context.Provider value={contextValue}>
|
|
365
399
|
{children}
|
|
366
400
|
</Auth0Context.Provider>
|
|
367
401
|
);
|
package/src/index.tsx
CHANGED
package/src/use-auth0.tsx
CHANGED
|
@@ -27,4 +27,4 @@ import Auth0Context, { Auth0ContextInterface } from './auth0-context';
|
|
|
27
27
|
const useAuth0 = <TUser extends User = User>(): Auth0ContextInterface<TUser> =>
|
|
28
28
|
useContext(Auth0Context) as Auth0ContextInterface<TUser>;
|
|
29
29
|
|
|
30
|
-
export default useAuth0;
|
|
30
|
+
export default useAuth0;
|
package/src/with-auth0.tsx
CHANGED
|
@@ -28,7 +28,7 @@ const withAuth0 = <P extends WithAuth0Props>(
|
|
|
28
28
|
): ComponentType<Omit<P, keyof WithAuth0Props>> => (props): JSX.Element => (
|
|
29
29
|
<Auth0Context.Consumer>
|
|
30
30
|
{(auth: Auth0ContextInterface): JSX.Element => (
|
|
31
|
-
<Component
|
|
31
|
+
<Component {...(props as P)} auth0={auth} />
|
|
32
32
|
)}
|
|
33
33
|
</Auth0Context.Consumer>
|
|
34
34
|
);
|
|
@@ -84,8 +84,8 @@ const withAuthenticationRequired = <P extends object>(
|
|
|
84
84
|
const {
|
|
85
85
|
returnTo = defaultReturnTo,
|
|
86
86
|
onRedirecting = defaultOnRedirecting,
|
|
87
|
-
loginOptions = {},
|
|
88
87
|
claimCheck = (): boolean => true,
|
|
88
|
+
loginOptions,
|
|
89
89
|
} = options;
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -101,7 +101,7 @@ const withAuthenticationRequired = <P extends object>(
|
|
|
101
101
|
const opts = {
|
|
102
102
|
...loginOptions,
|
|
103
103
|
appState: {
|
|
104
|
-
...loginOptions.appState,
|
|
104
|
+
...(loginOptions && loginOptions.appState),
|
|
105
105
|
returnTo: typeof returnTo === 'function' ? returnTo() : returnTo,
|
|
106
106
|
},
|
|
107
107
|
};
|
package/CHANGELOG.md
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
## [v1.5.0](https://github.com/auth0/auth0-react/tree/v1.5.0) (2021-05-05)
|
|
4
|
-
|
|
5
|
-
**Added**
|
|
6
|
-
|
|
7
|
-
- Expose `handleRedirectCallback` [\#233](https://github.com/auth0/auth0-react/pull/233) ([stevehobbsdev](https://github.com/stevehobbsdev))
|
|
8
|
-
- Add TUser type param to useAuth0 hook [\#230](https://github.com/auth0/auth0-react/pull/230) ([Jameskmonger](https://github.com/Jameskmonger))
|
|
9
|
-
|
|
10
|
-
**Changed**
|
|
11
|
-
|
|
12
|
-
- Update User type [\#236](https://github.com/auth0/auth0-react/pull/236) ([tkiryu](https://github.com/tkiryu))
|
|
13
|
-
|
|
14
|
-
**Fixed**
|
|
15
|
-
|
|
16
|
-
- Check for state along with error param [\#231](https://github.com/auth0/auth0-react/pull/231) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
17
|
-
|
|
18
|
-
## [v1.4.0](https://github.com/auth0/auth0-react/tree/v1.4.0) (2021-03-26)
|
|
19
|
-
|
|
20
|
-
**Added**
|
|
21
|
-
|
|
22
|
-
- Update SPA JS, add organizations docs and example [\#211](https://github.com/auth0/auth0-react/pull/211) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
23
|
-
|
|
24
|
-
**Fixed**
|
|
25
|
-
|
|
26
|
-
- Update auth state on access token fail [\#219](https://github.com/auth0/auth0-react/pull/219) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
27
|
-
- Updates to user should not update memoized getAccessToken* methods [\#213](https://github.com/auth0/auth0-react/pull/213) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
28
|
-
|
|
29
|
-
## [v1.3.0](https://github.com/auth0/auth0-react/tree/v1.3.0) (2021-02-16)
|
|
30
|
-
|
|
31
|
-
**Added**
|
|
32
|
-
|
|
33
|
-
- Added `buildAuthorizeUrl` and `buildLogoutUrl` [\#190](https://github.com/auth0/auth0-react/pull/190) ([THISS](https://github.com/THISS))
|
|
34
|
-
|
|
35
|
-
**Changed**
|
|
36
|
-
|
|
37
|
-
- `isLoading` should default to `true` even when doing SSR [\#193](https://github.com/auth0/auth0-react/pull/193) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
38
|
-
|
|
39
|
-
## [v1.2.0](https://github.com/auth0/auth0-react/tree/v1.2.0) (2020-11-04)
|
|
40
|
-
|
|
41
|
-
**Added**
|
|
42
|
-
|
|
43
|
-
- [SDK-2106] Memoize auth methods [\#150](https://github.com/auth0/auth0-react/pull/150) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
44
|
-
- Add react fast refresh support [\#151](https://github.com/auth0/auth0-react/pull/151) ([Idered](https://github.com/Idered))
|
|
45
|
-
- [SDK-2105] Skip redirect callback option [\#148](https://github.com/auth0/auth0-react/pull/148) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
46
|
-
- [SDK-2104] Update peerDeps to account for react 17 [\#147](https://github.com/auth0/auth0-react/pull/147) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
47
|
-
- [SDK-1938] Update the user/isAuthenticated state after getting a token [\#146](https://github.com/auth0/auth0-react/pull/146) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
48
|
-
- Add config argument to getAccessTokenWithPopup [\#141](https://github.com/auth0/auth0-react/pull/141) ([ygist](https://github.com/ygist))
|
|
49
|
-
- Export AppState type for custom onRedirectCallback's [\#120](https://github.com/auth0/auth0-react/pull/120) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
50
|
-
|
|
51
|
-
## [v1.1.0](https://github.com/auth0/auth0-react/tree/v1.1.0) (2020-09-17)
|
|
52
|
-
|
|
53
|
-
**Added**
|
|
54
|
-
|
|
55
|
-
- [SDK-1927] Check for state param in callback url [\#107](https://github.com/auth0/auth0-react/pull/107) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
56
|
-
- Support react v16.11 [\#99](https://github.com/auth0/auth0-react/pull/99) ([tiagob](https://github.com/tiagob))
|
|
57
|
-
|
|
58
|
-
**Fixed**
|
|
59
|
-
|
|
60
|
-
- [SDK-1836] Update state for local logouts [\#81](https://github.com/auth0/auth0-react/pull/81) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
61
|
-
- Add config argument to loginWithPopup [\#77](https://github.com/auth0/auth0-react/pull/77) ([Aulos](https://github.com/Aulos))
|
|
62
|
-
|
|
63
|
-
## [v1.0.0](https://github.com/auth0/auth0-react/tree/v1.0.0) (2020-06-19)
|
|
64
|
-
|
|
65
|
-
**Breaking Change**
|
|
66
|
-
|
|
67
|
-
- Allow custom `returnTo` in `withAuthenticationRequired` [\#41](https://github.com/auth0/auth0-react/pull/41) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
68
|
-
|
|
69
|
-
## [v0.4.0](https://github.com/auth0/auth0-react/tree/v0.4.0) (2020-06-05)
|
|
70
|
-
|
|
71
|
-
**Added**
|
|
72
|
-
|
|
73
|
-
- [SDK-1697] Add custom user agent to spa js [\#28](https://github.com/auth0/auth0-react/pull/28) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
74
|
-
- Use `checkSession` to start login [\#27](https://github.com/auth0/auth0-react/pull/27) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
75
|
-
- [SDK-1690] Add generated API docs [\#25](https://github.com/auth0/auth0-react/pull/25) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
76
|
-
|
|
77
|
-
## [v0.3.1](https://github.com/auth0/auth0-react/tree/v0.3.1) (2020-06-01)
|
|
78
|
-
|
|
79
|
-
**Fixed**
|
|
80
|
-
|
|
81
|
-
- getToken methods were being called in the wrong scope [\#24](https://github.com/auth0/auth0-react/pull/24) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
82
|
-
|
|
83
|
-
## [v0.3.0](https://github.com/auth0/auth0-react/tree/v0.3.0) (2020-05-29)
|
|
84
|
-
|
|
85
|
-
**Added**
|
|
86
|
-
|
|
87
|
-
- [SDK-1641] Add SSR support [\#17](https://github.com/auth0/auth0-react/pull/17) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
88
|
-
|
|
89
|
-
**Breaking Changes**
|
|
90
|
-
|
|
91
|
-
- [SDK-1694] Camel case props [\#22](https://github.com/auth0/auth0-react/pull/22) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
92
|
-
- [SDK-1693] Renames some init props [\#21](https://github.com/auth0/auth0-react/pull/21) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
93
|
-
|
|
94
|
-
## [v0.2.0](https://github.com/auth0/auth0-react/tree/v0.2.0) (2020-05-20)
|
|
95
|
-
|
|
96
|
-
**Added**
|
|
97
|
-
|
|
98
|
-
- [SDK-1642] Add missing methods from SPA JS [\#11](https://github.com/auth0/auth0-react/pull/11) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
99
|
-
- [SDK-1582] Normalize the auth0 error and add error handling to the basic example [\#10](https://github.com/auth0/auth0-react/pull/10) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
100
|
-
|
|
101
|
-
**Changed**
|
|
102
|
-
|
|
103
|
-
- Rename auth prop to prevent clashes and align with public api [\#14](https://github.com/auth0/auth0-react/pull/14) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
104
|
-
- Bundle SPA JS with the SDK for easier install [\#13](https://github.com/auth0/auth0-react/pull/13) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
105
|
-
|
|
106
|
-
## [v0.1.0](https://github.com/auth0/auth0-react/tree/v0.1.0) (2020-05-08)
|
|
107
|
-
|
|
108
|
-
**Added**
|
|
109
|
-
|
|
110
|
-
- [SDK-1580][SDK-1581] Add withAuth and withLoginRequired [\#7](https://github.com/auth0/auth0-react/pull/7) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
111
|
-
- [SDK-1583] Setup basic README for Early Access [\#6](https://github.com/auth0/auth0-react/pull/6) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
112
|
-
- [SDK-1577][SDK-1578] Add login functionality [\#5](https://github.com/auth0/auth0-react/pull/5) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
113
|
-
- [SDK-1576] Linting [\#4](https://github.com/auth0/auth0-react/pull/4) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
114
|
-
- [SDK-1572] Added CircleCI config [\#3](https://github.com/auth0/auth0-react/pull/3) ([Widcket](https://github.com/Widcket))
|
|
115
|
-
- [SDK-1568] Set up unit tests [\#2](https://github.com/auth0/auth0-react/pull/2) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
116
|
-
- [SDK-1570][SDK-1571] Setup dev environment and build targets [\#1](https://github.com/auth0/auth0-react/pull/1) ([adamjmcgrath](https://github.com/adamjmcgrath))
|