@asgardeo/auth-react 1.1.15 → 1.1.16
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/main.js +2 -2
- package/dist/src/authenticate.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/authenticate.tsx +15 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authenticate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEH,iBAAiB,EAQpB,MAAM,oBAAoB,CAAC;AAE5B,OAAc,EACV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authenticate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEH,iBAAiB,EAQpB,MAAM,oBAAoB,CAAC;AAE5B,OAAc,EACV,iBAAiB,EAEjB,iBAAiB,EACjB,SAAS,EAOZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAe,MAAM,GAAG,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAcrF,UAAU,0BAA0B;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CA+MlF,CAAC;AAEF,QAAA,MAAM,cAAc,QAAO,oBAE1B,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -621,7 +621,7 @@
|
|
|
621
621
|
"affectsGlobalScope": false
|
|
622
622
|
},
|
|
623
623
|
"../src/authenticate.tsx": {
|
|
624
|
-
"version": "
|
|
624
|
+
"version": "7b80cd0e2b843d12ad19d3c473efa3d95c4ce9854e6ff71dc71e7d131a3824b1",
|
|
625
625
|
"signature": "150d2de23192873482689c0b27ce8d8aa18d83441455f5402821f15f64b59133",
|
|
626
626
|
"affectsGlobalScope": false
|
|
627
627
|
},
|
package/package.json
CHANGED
package/src/authenticate.tsx
CHANGED
|
@@ -30,12 +30,14 @@ import {
|
|
|
30
30
|
import { SPACustomGrantConfig } from "@asgardeo/auth-spa/src/models/request-custom-grant";
|
|
31
31
|
import React, {
|
|
32
32
|
FunctionComponent,
|
|
33
|
+
MutableRefObject,
|
|
33
34
|
PropsWithChildren,
|
|
34
35
|
ReactNode,
|
|
35
36
|
createContext,
|
|
36
37
|
useContext,
|
|
37
38
|
useEffect,
|
|
38
39
|
useMemo,
|
|
40
|
+
useRef,
|
|
39
41
|
useState
|
|
40
42
|
} from "react";
|
|
41
43
|
import { AuthParams, ReactConfig } from ".";
|
|
@@ -131,6 +133,7 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
|
|
|
131
133
|
const trySignInSilently = () => AuthClient.trySignInSilently(state, dispatch);
|
|
132
134
|
|
|
133
135
|
const [ error, setError ] = useState<AsgardeoAuthException>();
|
|
136
|
+
const reRenderCheckRef: MutableRefObject<boolean> = useRef(false);
|
|
134
137
|
|
|
135
138
|
useEffect(() => {
|
|
136
139
|
if (state.isAuthenticated) {
|
|
@@ -146,6 +149,18 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
|
|
|
146
149
|
* Try signing in when the component is mounted.
|
|
147
150
|
*/
|
|
148
151
|
useEffect(() => {
|
|
152
|
+
// React 18.x Strict.Mode has a new check for `Ensuring reusable state` to facilitate an upcoming react feature.
|
|
153
|
+
// https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state
|
|
154
|
+
// This will remount all the useEffects to ensure that there are no unexpected side effects.
|
|
155
|
+
// When react remounts the signIn hook of the AuthProvider, it will cause a race condition. Hence, we have to
|
|
156
|
+
// prevent the re-render of this hook as suggested in the following discussion.
|
|
157
|
+
// https://github.com/reactwg/react-18/discussions/18#discussioncomment-795623
|
|
158
|
+
if (reRenderCheckRef.current) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
reRenderCheckRef.current = true;
|
|
163
|
+
|
|
149
164
|
(async () => {
|
|
150
165
|
let isSignedOut: boolean = false;
|
|
151
166
|
// If the component was mounted after the user was redirected to the application upon a successful logout,
|