@asgardeo/auth-react 1.1.20 → 2.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgardeo/auth-react",
3
- "version": "1.1.20",
3
+ "version": "2.0.1",
4
4
  "description": "Asgardeo Auth React SDK for React Applications.",
5
5
  "keywords": [
6
6
  "WSO2",
@@ -20,11 +20,11 @@
20
20
  "scripts": {
21
21
  "lint": "eslint --ext .js,.ts .",
22
22
  "fix-lint": "eslint --ext .js,.ts . --fix",
23
- "build": "rimraf dist && npm run type-check && cross-env NODE_OPTIONS=--openssl-legacy-provider webpack -p --env.NODE_ENV=production",
24
- "build:dev": "rimraf dist && npm run type-check && webpack -p --env.NODE_ENV=development",
25
- "build:watch": "npm run build:dev -- --watch",
23
+ "build": "rimraf dist && yarn run type-check && webpack --env NODE_ENV=production",
24
+ "build:dev": "rimraf dist && yarn run type-check && webpack --env NODE_ENV=development",
25
+ "build:watch": "yarn run build:dev -- --watch",
26
26
  "type-check": "tsc --emitDeclarationOnly",
27
- "type-check:watch": "npm run type-check -- --watch"
27
+ "type-check:watch": "yarn run type-check -- --watch"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
@@ -37,41 +37,42 @@
37
37
  "author": "WSO2",
38
38
  "license": "Apache-2.0",
39
39
  "dependencies": {
40
- "@asgardeo/auth-spa": "^0.4.10"
40
+ "@asgardeo/auth-spa": "^1.0.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@babel/cli": "^7.10.5",
44
- "@babel/core": "^7.11.4",
45
- "@babel/plugin-proposal-class-properties": "^7.10.4",
46
- "@babel/plugin-proposal-decorators": "^7.10.5",
47
- "@babel/plugin-transform-modules-commonjs": "^7.6.0",
48
- "@babel/preset-env": "^7.11.0",
49
- "@babel/preset-react": "^7.6.3",
50
- "@babel/preset-typescript": "^7.10.4",
51
- "@babel/runtime-corejs3": "^7.11.2",
52
- "@types/node": "^13.9.2",
53
- "@typescript-eslint/eslint-plugin": "^2.19.2",
54
- "@typescript-eslint/parser": "^3.10.1",
55
- "babel-loader": "^8.1.0",
56
- "core-js": "^3.8.3",
57
- "cross-env": "^7.0.3",
58
- "eslint": "^7.20.0",
59
- "eslint-plugin-import": "^2.20.2",
60
- "eslint-plugin-react": "^7.18.3",
61
- "eslint-plugin-react-hooks": "^4.0.0",
62
- "react": "^16.14.0",
63
- "react-dom": "16.14.0",
64
- "react-router-dom": "^5.2.0",
43
+ "@babel/cli": "^7.19.3",
44
+ "@babel/core": "^7.20.5",
45
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
46
+ "@babel/plugin-proposal-decorators": "^7.20.5",
47
+ "@babel/plugin-transform-modules-commonjs": "^7.19.6",
48
+ "@babel/preset-env": "^7.20.2",
49
+ "@babel/preset-react": "^7.18.6",
50
+ "@babel/preset-typescript": "^7.18.6",
51
+ "@babel/runtime-corejs3": "^7.20.6",
52
+ "@types/node": "^18.11.17",
53
+ "@types/react-router-dom": "^5.3.3",
54
+ "@typescript-eslint/eslint-plugin": "^5.47.0",
55
+ "@typescript-eslint/parser": "^5.47.0",
56
+ "babel-loader": "^9.1.0",
57
+ "core-js": "^3.26.1",
58
+ "eslint": "^8.30.0",
59
+ "eslint-plugin-import": "^2.26.0",
60
+ "eslint-plugin-react": "^7.31.11",
61
+ "eslint-plugin-react-hooks": "^4.6.0",
62
+ "eslint-webpack-plugin": "^3.2.0",
63
+ "react": "^18.2.0",
64
+ "react-dom": "^18.2.0",
65
+ "react-router-dom": "^6.3.0",
65
66
  "rimraf": "^3.0.2",
66
- "typescript": "^3.9.7",
67
- "webpack": "^4.41.5",
68
- "webpack-cli": "^3.3.7",
69
- "worker-loader": "^2.0.0"
67
+ "typescript": "^4.9.4",
68
+ "webpack": "^5.75.0",
69
+ "webpack-cli": "^5.0.1",
70
+ "worker-loader": "^3.0.8"
70
71
  },
71
72
  "peerDependencies": {
72
73
  "@babel/runtime-corejs3": "^7.11.2",
73
74
  "react": ">=16.8",
74
75
  "react-dom": ">=16.8",
75
- "react-router-dom": "^5.2.0"
76
+ "react-router-dom": "^6.3.0"
76
77
  }
77
78
  }
package/src/api.ts CHANGED
@@ -337,6 +337,15 @@ class AuthAPI {
337
337
  return this._client.isAuthenticated();
338
338
  }
339
339
 
340
+ /**
341
+ * This method specifies if the session is active or not.
342
+ *
343
+ * @return {Promise<boolean>} - A Promise that resolves with `true` if there is an active session.
344
+ */
345
+ public async isSessionActive(): Promise<boolean> {
346
+ return this._client.isSessionActive();
347
+ }
348
+
340
349
  /**
341
350
  * This method enables callback functions attached to the http client.
342
351
  *
@@ -48,7 +48,8 @@ import { AuthContextInterface, AuthReactConfig, AuthStateInterface } from "./mod
48
48
  * Default `AuthReactConfig` config.
49
49
  */
50
50
  const defaultConfig: Partial<ReactConfig> = {
51
- disableTrySignInSilently: true
51
+ disableTrySignInSilently: true,
52
+ checkActiveSession: false
52
53
  };
53
54
 
54
55
  /**
@@ -214,6 +215,10 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
214
215
  return;
215
216
  }
216
217
 
218
+ if (config.checkActiveSession && await AuthClient.isSessionActive()) {
219
+ signIn();
220
+ }
221
+
217
222
  if (config.disableTrySignInSilently || isSignedOut) {
218
223
  dispatch({ ...state, isLoading: false });
219
224
 
@@ -265,6 +270,9 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
265
270
 
266
271
  return;
267
272
  }
273
+
274
+ AuthClient.updateState({ ...state, isAuthenticated: isAuthenticatedState, isLoading: false });
275
+ dispatch({ ...state, isAuthenticated: isAuthenticatedState, isLoading: false });
268
276
  }
269
277
  };
270
278
 
package/src/models.ts CHANGED
@@ -45,6 +45,7 @@ export interface ReactConfig {
45
45
  * with the latest session information from the server. This option could be used to disable that behaviour.
46
46
  */
47
47
  disableTrySignInSilently?: boolean;
48
+ checkActiveSession?: boolean;
48
49
  }
49
50
 
50
51
  export type AuthReactConfig = AuthSPAClientConfig & ReactConfig;
@@ -61,8 +61,7 @@ const SecureRoute: FunctionComponent<SecureRouteInterface & RouteProps> = (props
61
61
  return (
62
62
  <Route
63
63
  { ...rest }
64
- render={ (props) =>
65
- <Component { ...props } />
64
+ element={ <Component />
66
65
  }
67
66
  />
68
67
  );
package/webpack.config.js CHANGED
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  const path = require("path");
20
+ const ESLintPlugin = require("eslint-webpack-plugin");
20
21
 
21
22
  // Name of the UMD bundle.
22
23
  const LIBRARY_NAME = "AsgardeoAuth";
@@ -40,21 +41,21 @@ module.exports = (env) => {
40
41
  externals: [
41
42
  {
42
43
  "react": {
43
- root: "React",
44
- commonjs2: "react",
45
44
  commonjs: "react",
45
+ commonjs2: "react",
46
+ root: "React",
46
47
  umd: "react"
47
48
  },
48
49
  "react-dom": {
49
- root: "ReactDOM",
50
- commonjs2: "react-dom",
51
50
  commonjs: "react-dom",
51
+ commonjs2: "react-dom",
52
+ root: "ReactDOM",
52
53
  umd: "react-dom"
53
54
  },
54
55
  "react-router-dom": {
55
- root: "ReactRouter",
56
- commonjs2: "react-router-dom",
57
56
  commonjs: "react-router-dom",
57
+ commonjs2: "react-router-dom",
58
+ root: "ReactRouter",
58
59
  umd: "react-router-dom"
59
60
  }
60
61
  }
@@ -75,19 +76,6 @@ module.exports = (env) => {
75
76
  exclude: /(node_modules|dist)/,
76
77
  test: /\.(tsx|jsx|ts|js)?$/,
77
78
  use: "babel-loader"
78
- },
79
- {
80
- exclude: /(node_modules|dist)/,
81
- test: /\.(tsx|jsx|ts?|js)$/,
82
- use: [
83
- {
84
- loader: "eslint-loader",
85
- options: {
86
- happyPackMode: true,
87
- transpileOnly: true
88
- }
89
- }
90
- ]
91
79
  }
92
80
  ]
93
81
  },
@@ -98,6 +86,7 @@ module.exports = (env) => {
98
86
  libraryTarget: "umd",
99
87
  path: path.resolve(__dirname, "dist")
100
88
  },
89
+ plugins: [ new ESLintPlugin()],
101
90
  resolve: {
102
91
  extensions: [".tsx", ".ts", ".js"]
103
92
  }