@asgardeo/auth-react 1.1.14 → 1.1.17

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 +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,EACjB,iBAAiB,EACjB,SAAS,EAMZ,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,CAkMlF,CAAC;AAEF,QAAA,MAAM,cAAc,QAAO,oBAE1B,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"secure-route.d.ts","sourceRoot":"","sources":["../../src/secure-route.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAc,EAAE,iBAAiB,EAA2B,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAS,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,UAAU,CAyBrE,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"secure-route.d.ts","sourceRoot":"","sources":["../../src/secure-route.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAc,EAAE,iBAAiB,EAAqD,MAAM,OAAO,CAAC;AACpG,OAAO,EAAS,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,UAAU,CAsCrE,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -237,8 +237,8 @@
237
237
  "affectsGlobalScope": false
238
238
  },
239
239
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/data.d.ts": {
240
- "version": "030074650037a6e61cfb86ae3e22845464535b376736976eaca80d214c9d1286",
241
- "signature": "030074650037a6e61cfb86ae3e22845464535b376736976eaca80d214c9d1286",
240
+ "version": "ef558820fc7c6ac5a7f32117ac8a533639e636659f7370ff56a88e4ac362d963",
241
+ "signature": "ef558820fc7c6ac5a7f32117ac8a533639e636659f7370ff56a88e4ac362d963",
242
242
  "affectsGlobalScope": false
243
243
  },
244
244
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/parameters.d.ts": {
@@ -251,19 +251,14 @@
251
251
  "signature": "1408465b7ef31763e5827b443a38d83d125e5d9ccb60ed23c49cbd5e16bb35e4",
252
252
  "affectsGlobalScope": false
253
253
  },
254
- "../../node_modules/@asgardeo/auth-js/dist/src/constants/environments.d.ts": {
255
- "version": "1d5f29a8df2a26f1f2a27aafc55e89708cb5648a57464d2424eafa795694e188",
256
- "signature": "1d5f29a8df2a26f1f2a27aafc55e89708cb5648a57464d2424eafa795694e188",
257
- "affectsGlobalScope": false
258
- },
259
254
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/fetch.d.ts": {
260
255
  "version": "8c590f6cab70aaa58ff3a785019b4065b0ad86aaed35b06f1e608511f0342066",
261
256
  "signature": "8c590f6cab70aaa58ff3a785019b4065b0ad86aaed35b06f1e608511f0342066",
262
257
  "affectsGlobalScope": false
263
258
  },
264
259
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/index.d.ts": {
265
- "version": "37e3dd4b6f6bbfd099d48fd08fe31b000e7a150cf5fa4823e79e6d0eef5038d7",
266
- "signature": "37e3dd4b6f6bbfd099d48fd08fe31b000e7a150cf5fa4823e79e6d0eef5038d7",
260
+ "version": "5a96909505b035b618b7cf507602aa31861a3b4bed2c8316a4ddb93944599a24",
261
+ "signature": "5a96909505b035b618b7cf507602aa31861a3b4bed2c8316a4ddb93944599a24",
267
262
  "affectsGlobalScope": false
268
263
  },
269
264
  "../../node_modules/@asgardeo/auth-js/dist/src/data/data-layer.d.ts": {
@@ -292,8 +287,8 @@
292
287
  "affectsGlobalScope": false
293
288
  },
294
289
  "../../node_modules/@asgardeo/auth-js/dist/src/client.d.ts": {
295
- "version": "ecae5055f45ffb3a76cdbfe29e09fde83422f9b9f61d9a7cb907d051c081284f",
296
- "signature": "ecae5055f45ffb3a76cdbfe29e09fde83422f9b9f61d9a7cb907d051c081284f",
290
+ "version": "879d50966f7660197f183f5a411db9bf949567a056e38606c2ce0471a68b728f",
291
+ "signature": "879d50966f7660197f183f5a411db9bf949567a056e38606c2ce0471a68b728f",
297
292
  "affectsGlobalScope": false
298
293
  },
299
294
  "../../node_modules/@asgardeo/auth-js/dist/src/utils/authentication-utils.d.ts": {
@@ -362,8 +357,8 @@
362
357
  "affectsGlobalScope": false
363
358
  },
364
359
  "../../node_modules/@asgardeo/auth-spa/dist/src/helpers/spa-helper.d.ts": {
365
- "version": "b0d8707daeb8c23e2a5f19775de1d728bb10823325bef53a00cfdbab46b9e949",
366
- "signature": "b0d8707daeb8c23e2a5f19775de1d728bb10823325bef53a00cfdbab46b9e949",
360
+ "version": "c737e3fc34df82139f959eb93b08219bc386c7c88d1abe82cd9c14e46266d5d2",
361
+ "signature": "c737e3fc34df82139f959eb93b08219bc386c7c88d1abe82cd9c14e46266d5d2",
367
362
  "affectsGlobalScope": false
368
363
  },
369
364
  "../../node_modules/@asgardeo/auth-spa/dist/src/http-client/models/axios-http-client.d.ts": {
@@ -601,7 +596,7 @@
601
596
  "affectsGlobalScope": false
602
597
  },
603
598
  "../src/secure-route.tsx": {
604
- "version": "92d15d49363702e09541828e6f79125a560e4ab94eebb6b7abeb1e085375ddd2",
599
+ "version": "1adc1b9bb0a3c981da175e3584852e714f2acc9ab987f9158a700e12342eca55",
605
600
  "signature": "a7444f6cda6b9d661a122ba8530dc1941173ae0ab22e75d7adca56b6b99bd40c",
606
601
  "affectsGlobalScope": false
607
602
  },
@@ -626,7 +621,7 @@
626
621
  "affectsGlobalScope": false
627
622
  },
628
623
  "../src/authenticate.tsx": {
629
- "version": "3cea96c50c5f0cb0a4f110fe9556aabcf7604b07978cac9e25c9a0d39588941f",
624
+ "version": "7b80cd0e2b843d12ad19d3c473efa3d95c4ce9854e6ff71dc71e7d131a3824b1",
630
625
  "signature": "150d2de23192873482689c0b27ce8d8aa18d83441455f5402821f15f64b59133",
631
626
  "affectsGlobalScope": false
632
627
  },
@@ -1246,7 +1241,6 @@
1246
1241
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/client-config.d.ts",
1247
1242
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/custom-grant-template-tags.d.ts",
1248
1243
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/data.d.ts",
1249
- "../../node_modules/@asgardeo/auth-js/dist/src/constants/environments.d.ts",
1250
1244
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/fetch.d.ts",
1251
1245
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/oidc-endpoints.d.ts",
1252
1246
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/parameters.d.ts",
@@ -1807,7 +1801,6 @@
1807
1801
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/client-config.d.ts",
1808
1802
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/custom-grant-template-tags.d.ts",
1809
1803
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/data.d.ts",
1810
- "../../node_modules/@asgardeo/auth-js/dist/src/constants/environments.d.ts",
1811
1804
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/fetch.d.ts",
1812
1805
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/oidc-endpoints.d.ts",
1813
1806
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/parameters.d.ts",
@@ -2250,7 +2243,6 @@
2250
2243
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/client-config.d.ts",
2251
2244
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/custom-grant-template-tags.d.ts",
2252
2245
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/data.d.ts",
2253
- "../../node_modules/@asgardeo/auth-js/dist/src/constants/environments.d.ts",
2254
2246
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/fetch.d.ts",
2255
2247
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/index.d.ts",
2256
2248
  "../../node_modules/@asgardeo/auth-js/dist/src/constants/oidc-endpoints.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgardeo/auth-react",
3
- "version": "1.1.14",
3
+ "version": "1.1.17",
4
4
  "description": "Asgardeo Auth React SDK for React Applications.",
5
5
  "keywords": [
6
6
  "WSO2",
@@ -22,6 +22,7 @@
22
22
  "fix-lint": "eslint --ext .js,.ts . --fix",
23
23
  "build": "rimraf dist && npm run type-check && webpack -p --env.NODE_ENV=production",
24
24
  "build:dev": "rimraf dist && npm run type-check && webpack -p --env.NODE_ENV=development",
25
+ "build:watch": "npm run build:dev -- --watch",
25
26
  "type-check": "tsc --emitDeclarationOnly",
26
27
  "type-check:watch": "npm run type-check -- --watch"
27
28
  },
@@ -36,7 +37,7 @@
36
37
  "author": "WSO2",
37
38
  "license": "Apache-2.0",
38
39
  "dependencies": {
39
- "@asgardeo/auth-spa": "^0.4.5"
40
+ "@asgardeo/auth-spa": "^0.4.7"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@babel/cli": "^7.10.5",
@@ -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,
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
 
19
- import React, { FunctionComponent, ReactElement, useEffect } from "react";
19
+ import React, { FunctionComponent, MutableRefObject, ReactElement, useEffect, useRef } from "react";
20
20
  import { Route, RouteProps } from "react-router-dom";
21
21
  import { useAuthContext } from "./authenticate";
22
22
  import { SecureRouteInterface } from "./models";
@@ -31,15 +31,28 @@ import { SecureRouteInterface } from "./models";
31
31
  const SecureRoute: FunctionComponent<SecureRouteInterface & RouteProps> = (props: SecureRouteInterface & RouteProps
32
32
  ): ReactElement => {
33
33
  const { state } = useAuthContext();
34
+ const reRenderCheckRef: MutableRefObject<boolean> = useRef(false);
34
35
 
35
36
  const { component: Component, callback, ...rest } = props;
36
37
 
37
38
  useEffect(() => {
38
- if (!state.isAuthenticated) {
39
- callback && callback();
39
+ if (state.isAuthenticated || state.isLoading) {
40
+ return;
40
41
  }
41
42
 
42
- }, [ state.isAuthenticated ]);
43
+ // React 18.x Strict.Mode has a new check for `Ensuring reusable state` to facilitate an upcoming react feature.
44
+ // https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state
45
+ // This will remount all the useEffects to ensure that there are no unexpected side effects.
46
+ // When react remounts the signIn hook of the AuthProvider, it will cause a race condition. Hence, we have to
47
+ // prevent the re-render of this hook as suggested in the following discussion.
48
+ // https://github.com/reactwg/react-18/discussions/18#discussioncomment-795623
49
+ if (reRenderCheckRef.current) {
50
+ return;
51
+ }
52
+
53
+ reRenderCheckRef.current = true;
54
+ callback && callback();
55
+ }, [ state.isAuthenticated, state.isLoading ]);
43
56
 
44
57
  if (!state.isAuthenticated) {
45
58
  return null;