@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/README.md +127 -934
- package/dist/main.js +2 -914
- package/dist/main.js.LICENSE.txt +946 -0
- package/dist/src/api.d.ts +6 -0
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/authenticate.d.ts.map +1 -1
- package/dist/src/models.d.ts +2 -1
- package/dist/src/models.d.ts.map +1 -1
- package/dist/src/secure-route.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -2358
- package/package.json +34 -32
- package/src/api.ts +9 -0
- package/src/authenticate.tsx +6 -1
- package/src/models.ts +1 -0
- package/src/secure-route.tsx +1 -2
- package/webpack.config.js +2 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/auth-react",
|
|
3
|
-
"version": "
|
|
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 &&
|
|
24
|
-
"build:dev": "rimraf dist &&
|
|
25
|
-
"build: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": "
|
|
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.
|
|
40
|
+
"@asgardeo/auth-spa": "^1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@babel/cli": "^7.
|
|
44
|
-
"@babel/core": "^7.
|
|
45
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
46
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
47
|
-
"@babel/plugin-transform-modules-commonjs": "^7.6
|
|
48
|
-
"@babel/preset-env": "^7.
|
|
49
|
-
"@babel/preset-react": "^7.6
|
|
50
|
-
"@babel/preset-typescript": "^7.
|
|
51
|
-
"@babel/runtime-corejs3": "^7.
|
|
52
|
-
"@types/node": "^
|
|
53
|
-
"@
|
|
54
|
-
"@typescript-eslint/
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"eslint
|
|
59
|
-
"eslint-plugin-
|
|
60
|
-
"eslint-plugin-react
|
|
61
|
-
"react": "^
|
|
62
|
-
"
|
|
63
|
-
"react
|
|
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": "^
|
|
66
|
-
"webpack": "^
|
|
67
|
-
"webpack-cli": "^
|
|
68
|
-
"worker-loader": "^
|
|
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": "^
|
|
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
|
*
|
package/src/authenticate.tsx
CHANGED
|
@@ -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;
|
package/src/secure-route.tsx
CHANGED
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
|
}
|