@truedat/auth 4.28.1 → 4.28.5
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 +4 -4
- package/src/sessions/components/PrivateRoute.js +2 -0
- package/src/sessions/sagas/__tests__/login.spec.js +9 -9
- package/src/sessions/sagas/__tests__/logout.spec.js +1 -3
- package/src/sessions/sagas/__tests__/token.spec.js +3 -9
- package/src/sessions/sagas/token.js +4 -10
- package/src/users/components/User.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/auth",
|
|
3
|
-
"version": "4.28.
|
|
3
|
+
"version": "4.28.5",
|
|
4
4
|
"description": "Truedat Web Auth",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.14.1",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "4.28.
|
|
37
|
+
"@truedat/test": "4.28.5",
|
|
38
38
|
"babel-jest": "^27.0.6",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@truedat/core": "4.28.
|
|
85
|
+
"@truedat/core": "4.28.5",
|
|
86
86
|
"auth0-js": "^9.12.2",
|
|
87
87
|
"immutable": "^4.0.0-rc.12",
|
|
88
88
|
"jwt-decode": "^2.2.0",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"react-dom": ">= 16.8.6 < 17",
|
|
105
105
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "e004c6a673d6824a4807e4378b6e5c83e947c992"
|
|
108
108
|
}
|
|
@@ -4,7 +4,7 @@ import { testSaga } from "redux-saga-test-plan";
|
|
|
4
4
|
import {
|
|
5
5
|
apiJsonPost,
|
|
6
6
|
authJsonOpts,
|
|
7
|
-
JSON_OPTS
|
|
7
|
+
JSON_OPTS,
|
|
8
8
|
} from "@truedat/core/services/api";
|
|
9
9
|
import { saveToken } from "@truedat/core/services/storage";
|
|
10
10
|
import { login, auth0Login, openIdLogin, nonceLogin } from "../../routines";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
openIdLoginSaga,
|
|
14
14
|
postLoginSaga,
|
|
15
15
|
loginRequestSaga,
|
|
16
|
-
nonceLoginSaga
|
|
16
|
+
nonceLoginSaga,
|
|
17
17
|
} from "../login";
|
|
18
18
|
import { API_SESSIONS } from "../../api";
|
|
19
19
|
|
|
@@ -26,7 +26,7 @@ describe("sagas: login request", () => {
|
|
|
26
26
|
takeLatest(login.TRIGGER, postLoginSaga),
|
|
27
27
|
takeLatest(auth0Login.TRIGGER, auth0LoginSaga),
|
|
28
28
|
takeLatest(openIdLogin.TRIGGER, openIdLoginSaga),
|
|
29
|
-
takeLatest(nonceLogin.TRIGGER, nonceLoginSaga)
|
|
29
|
+
takeLatest(nonceLogin.TRIGGER, nonceLoginSaga),
|
|
30
30
|
])
|
|
31
31
|
.finish()
|
|
32
32
|
.isDone();
|
|
@@ -67,7 +67,7 @@ describe("sagas: post login", () => {
|
|
|
67
67
|
access_method,
|
|
68
68
|
type,
|
|
69
69
|
exp,
|
|
70
|
-
groups
|
|
70
|
+
groups,
|
|
71
71
|
})
|
|
72
72
|
.put(
|
|
73
73
|
login.success({
|
|
@@ -78,7 +78,7 @@ describe("sagas: post login", () => {
|
|
|
78
78
|
access_method,
|
|
79
79
|
type,
|
|
80
80
|
exp,
|
|
81
|
-
groups
|
|
81
|
+
groups,
|
|
82
82
|
})
|
|
83
83
|
)
|
|
84
84
|
.next()
|
|
@@ -145,7 +145,7 @@ describe("sagas: openIdLogin", () => {
|
|
|
145
145
|
has_permissions,
|
|
146
146
|
type,
|
|
147
147
|
exp,
|
|
148
|
-
groups
|
|
148
|
+
groups,
|
|
149
149
|
})
|
|
150
150
|
.put(
|
|
151
151
|
openIdLogin.success({
|
|
@@ -155,7 +155,7 @@ describe("sagas: openIdLogin", () => {
|
|
|
155
155
|
has_permissions,
|
|
156
156
|
type,
|
|
157
157
|
exp,
|
|
158
|
-
groups
|
|
158
|
+
groups,
|
|
159
159
|
})
|
|
160
160
|
)
|
|
161
161
|
.next()
|
|
@@ -201,7 +201,7 @@ describe("sagas: openIdLogin", () => {
|
|
|
201
201
|
has_permissions,
|
|
202
202
|
type,
|
|
203
203
|
exp,
|
|
204
|
-
groups
|
|
204
|
+
groups,
|
|
205
205
|
})
|
|
206
206
|
.put(
|
|
207
207
|
openIdLogin.success({
|
|
@@ -211,7 +211,7 @@ describe("sagas: openIdLogin", () => {
|
|
|
211
211
|
has_permissions,
|
|
212
212
|
type,
|
|
213
213
|
exp,
|
|
214
|
-
groups
|
|
214
|
+
groups,
|
|
215
215
|
})
|
|
216
216
|
)
|
|
217
217
|
.next()
|
|
@@ -16,9 +16,7 @@ describe("sagas: logout request", () => {
|
|
|
16
16
|
|
|
17
17
|
it("should fail handling logoutRequestSaga if wrong pattern", () => {
|
|
18
18
|
expect(() => {
|
|
19
|
-
testSaga(logoutRequestSaga)
|
|
20
|
-
.next()
|
|
21
|
-
.takeLatest("WTF_PATTERN", logoutSaga);
|
|
19
|
+
testSaga(logoutRequestSaga).next().takeLatest("WTF_PATTERN", logoutSaga);
|
|
22
20
|
}).toThrow();
|
|
23
21
|
});
|
|
24
22
|
});
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import jwt_decode from "jwt-decode";
|
|
2
2
|
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
-
import {
|
|
4
|
-
tokenRequestSaga,
|
|
5
|
-
checkExpired,
|
|
6
|
-
readToken
|
|
7
|
-
} from "../token";
|
|
8
3
|
import { readToken as readTokenFromStorage } from "@truedat/core/services/storage";
|
|
4
|
+
import { tokenRequestSaga, checkExpired, readToken } from "../token";
|
|
9
5
|
import { REQUEST_TOKEN, RECEIVE_TOKEN } from "../../actions";
|
|
10
6
|
|
|
11
7
|
describe("sagas: check expired", () => {
|
|
@@ -56,7 +52,7 @@ describe("sagas: read token", () => {
|
|
|
56
52
|
role,
|
|
57
53
|
has_permissions,
|
|
58
54
|
access_method,
|
|
59
|
-
groups
|
|
55
|
+
groups,
|
|
60
56
|
})
|
|
61
57
|
.next()
|
|
62
58
|
.isDone();
|
|
@@ -101,9 +97,7 @@ describe("sagas: token request", () => {
|
|
|
101
97
|
|
|
102
98
|
it("should fail handling tokenRequestSaga if wrong pattern", () => {
|
|
103
99
|
expect(() => {
|
|
104
|
-
testSaga(tokenRequestSaga)
|
|
105
|
-
.next()
|
|
106
|
-
.takeLatest("WTF_PATTERN", readToken);
|
|
100
|
+
testSaga(tokenRequestSaga).next().takeLatest("WTF_PATTERN", readToken);
|
|
107
101
|
}).toThrow();
|
|
108
102
|
});
|
|
109
103
|
});
|
|
@@ -3,7 +3,7 @@ import { call, put, takeLatest } from "redux-saga/effects";
|
|
|
3
3
|
import { readToken as readTokenFromStorage } from "@truedat/core/services/storage";
|
|
4
4
|
import { REQUEST_TOKEN, RECEIVE_TOKEN } from "../actions";
|
|
5
5
|
|
|
6
|
-
export const checkExpired = exp => {
|
|
6
|
+
export const checkExpired = (exp) => {
|
|
7
7
|
if (exp) {
|
|
8
8
|
const now = Date.now().valueOf() / 1000;
|
|
9
9
|
return exp < now;
|
|
@@ -15,14 +15,8 @@ export const checkExpired = exp => {
|
|
|
15
15
|
export function* readToken() {
|
|
16
16
|
const token = yield call(readTokenFromStorage);
|
|
17
17
|
if (token) {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
exp,
|
|
21
|
-
role,
|
|
22
|
-
has_permissions,
|
|
23
|
-
access_method,
|
|
24
|
-
groups
|
|
25
|
-
} = yield call(jwt_decode, token);
|
|
18
|
+
const { user_name, exp, role, has_permissions, access_method, groups } =
|
|
19
|
+
yield call(jwt_decode, token);
|
|
26
20
|
const isExpired = yield call(checkExpired, exp);
|
|
27
21
|
if (!isExpired) {
|
|
28
22
|
yield put({
|
|
@@ -32,7 +26,7 @@ export function* readToken() {
|
|
|
32
26
|
token,
|
|
33
27
|
role,
|
|
34
28
|
access_method,
|
|
35
|
-
groups
|
|
29
|
+
groups,
|
|
36
30
|
});
|
|
37
31
|
}
|
|
38
32
|
}
|