@asgardeo/auth-react 1.1.18 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgardeo/auth-react",
3
- "version": "1.1.18",
3
+ "version": "2.0.0",
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 && 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,40 +37,42 @@
37
37
  "author": "WSO2",
38
38
  "license": "Apache-2.0",
39
39
  "dependencies": {
40
- "@asgardeo/auth-spa": "^0.4.8"
40
+ "@asgardeo/auth-spa": "^1.0.0"
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
- "eslint": "^7.20.0",
58
- "eslint-plugin-import": "^2.20.2",
59
- "eslint-plugin-react": "^7.18.3",
60
- "eslint-plugin-react-hooks": "^4.0.0",
61
- "react": "^16.14.0",
62
- "react-dom": "16.14.0",
63
- "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",
64
66
  "rimraf": "^3.0.2",
65
- "typescript": "^3.9.7",
66
- "webpack": "^4.41.5",
67
- "webpack-cli": "^3.3.7",
68
- "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"
69
71
  },
70
72
  "peerDependencies": {
71
73
  "@babel/runtime-corejs3": "^7.11.2",
72
74
  "react": ">=16.8",
73
75
  "react-dom": ">=16.8",
74
- "react-router-dom": "^5.2.0"
76
+ "react-router-dom": "^6.3.0"
75
77
  }
76
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
  /**
@@ -213,6 +214,10 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
213
214
  return;
214
215
  }
215
216
 
217
+ if (config.checkActiveSession && await AuthClient.isSessionActive()) {
218
+ signIn();
219
+ }
220
+
216
221
  if (config.disableTrySignInSilently || isSignedOut) {
217
222
  dispatch({ ...state, isLoading: false });
218
223
 
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";
@@ -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
  }