@vocollege/app 0.0.76 → 0.0.79
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/dist/global.d.ts +0 -3
- package/dist/interceptor.js +6 -4
- package/dist/modules/VoApi/GraphClient.js +2 -1
- package/dist/modules/VoAuth.js +68 -44
- package/dist/modules/VoConfig.js +6 -6
- package/package.json +1 -1
- package/src/global.ts +3 -3
- package/src/interceptor.ts +6 -4
- package/src/modules/VoApi/GraphClient.ts +2 -1
- package/src/modules/VoAuth.ts +73 -44
- package/src/modules/VoConfig.ts +6 -6
package/dist/global.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare type AuthStorageConfigType = {
|
|
|
4
4
|
REFRESH_TOKEN: string;
|
|
5
5
|
ACCESS_TOKEN: string;
|
|
6
6
|
TOKEN_TYPE: string;
|
|
7
|
-
EXPIRES_IN: string;
|
|
8
7
|
};
|
|
9
8
|
export declare type AuthConfigType = {
|
|
10
9
|
BASE_URL: string;
|
|
@@ -31,10 +30,8 @@ export declare type VoAppType = {
|
|
|
31
30
|
api: any;
|
|
32
31
|
};
|
|
33
32
|
export declare type VoTokenType = {
|
|
34
|
-
token_type: string;
|
|
35
33
|
access_token: string;
|
|
36
34
|
refresh_token: string;
|
|
37
|
-
expires_in: string;
|
|
38
35
|
};
|
|
39
36
|
export interface GeneralObject {
|
|
40
37
|
[key: string]: any;
|
package/dist/interceptor.js
CHANGED
|
@@ -103,7 +103,8 @@ var I18n_1 = __importDefault(require("./modules/Services/I18n"));
|
|
|
103
103
|
if (token) {
|
|
104
104
|
retry = 0;
|
|
105
105
|
error.config.headers["Authorization"] =
|
|
106
|
-
token.token_type + " " + token.access_token;
|
|
106
|
+
// token.token_type + " " + token.access_token;
|
|
107
|
+
"Bearer " + token.access_token;
|
|
107
108
|
}
|
|
108
109
|
return [2 /*return*/, axios_1.default.request(error.config)];
|
|
109
110
|
case 3:
|
|
@@ -116,9 +117,10 @@ var I18n_1 = __importDefault(require("./modules/Services/I18n"));
|
|
|
116
117
|
switch (status) {
|
|
117
118
|
case 419:
|
|
118
119
|
react_toastify_1.toast.error(I18n_1.default.get.messages.sessionExpired);
|
|
119
|
-
setTimeout(
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
// setTimeout(() => {
|
|
121
|
+
redirect();
|
|
122
|
+
reject(error);
|
|
123
|
+
// }, 5000);
|
|
122
124
|
break;
|
|
123
125
|
default:
|
|
124
126
|
reject(error);
|
|
@@ -175,7 +175,8 @@ var GraphClient = /** @class */ (function () {
|
|
|
175
175
|
}
|
|
176
176
|
operation.setContext(function () { return (__assign(__assign({}, currentHeaders), { headers: {
|
|
177
177
|
Authorization: token
|
|
178
|
-
?
|
|
178
|
+
? // ? `${token.token_type} ${token.access_token}`
|
|
179
|
+
"Bearer ".concat(token.access_token)
|
|
179
180
|
: "",
|
|
180
181
|
VoGroup: groupId,
|
|
181
182
|
} })); });
|
package/dist/modules/VoAuth.js
CHANGED
|
@@ -197,37 +197,39 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
197
197
|
}); });
|
|
198
198
|
};
|
|
199
199
|
VoAuth.prototype.setSession = function (token) {
|
|
200
|
-
|
|
200
|
+
// const { token_type, access_token, refresh_token, expires_in } = token;
|
|
201
|
+
var access_token = token.access_token, refresh_token = token.refresh_token;
|
|
201
202
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
202
203
|
// Helpers.localStorage.set(refreshTokenKey, refresh_token);
|
|
203
204
|
js_cookie_1.default.set(refreshTokenKey, refresh_token, {
|
|
204
|
-
expires:
|
|
205
|
+
expires: 11,
|
|
205
206
|
sameSite: "Lax",
|
|
206
207
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
207
208
|
});
|
|
208
209
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
209
210
|
// Helpers.localStorage.set(accessTokenKey, access_token);
|
|
210
211
|
js_cookie_1.default.set(accessTokenKey, access_token, {
|
|
211
|
-
expires:
|
|
212
|
-
sameSite: "Lax",
|
|
213
|
-
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
214
|
-
});
|
|
215
|
-
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
216
|
-
// Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
217
|
-
js_cookie_1.default.set(tokenTypeKey, token_type, {
|
|
218
|
-
expires: 20,
|
|
219
|
-
sameSite: "Lax",
|
|
220
|
-
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
221
|
-
});
|
|
222
|
-
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
223
|
-
// Helpers.localStorage.set(expiresInKey, expires_in);
|
|
224
|
-
js_cookie_1.default.set(expiresInKey, expires_in, {
|
|
225
|
-
expires: 20,
|
|
212
|
+
expires: 1,
|
|
226
213
|
sameSite: "Lax",
|
|
227
214
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
228
215
|
});
|
|
216
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
217
|
+
// // Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
218
|
+
// JsCookies.set(tokenTypeKey, token_type, {
|
|
219
|
+
// expires: 11,
|
|
220
|
+
// sameSite: "Lax",
|
|
221
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
222
|
+
// });
|
|
223
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
224
|
+
// // Helpers.localStorage.set(expiresInKey, expires_in);
|
|
225
|
+
// JsCookies.set(expiresInKey, expires_in, {
|
|
226
|
+
// expires: 11,
|
|
227
|
+
// sameSite: "Lax",
|
|
228
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
229
|
+
// });
|
|
229
230
|
axios_1.default.defaults.headers.common["Authorization"] =
|
|
230
|
-
token_type + " " + access_token;
|
|
231
|
+
// token_type + " " + access_token;
|
|
232
|
+
"Bearer " + access_token;
|
|
231
233
|
var currentGroup = VoGroups_1.default.getCurrent(true);
|
|
232
234
|
axios_1.default.defaults.headers.common["VoGroup"] = currentGroup
|
|
233
235
|
? currentGroup.id
|
|
@@ -246,18 +248,18 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
246
248
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
247
249
|
sameSite: "Lax",
|
|
248
250
|
});
|
|
249
|
-
|
|
250
|
-
Helpers.localStorage.remove(tokenTypeKey);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
Helpers.localStorage.remove(expiresInKey);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
251
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
252
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
253
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
254
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
255
|
+
// sameSite: "Lax",
|
|
256
|
+
// });
|
|
257
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
258
|
+
// Helpers.localStorage.remove(expiresInKey);
|
|
259
|
+
// JsCookies.remove(expiresInKey, {
|
|
260
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
261
|
+
// sameSite: "Lax",
|
|
262
|
+
// });
|
|
261
263
|
Helpers.localStorage.remove(VoConfig_1.default.get.CURRENT_GROUP || "");
|
|
262
264
|
Helpers.localStorage.remove(VoConfig_1.default.get.MASQUERADE_USER || "");
|
|
263
265
|
delete axios_1.default.defaults.headers.common["Authorization"];
|
|
@@ -303,10 +305,24 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
303
305
|
if (forceLoad === void 0) { forceLoad = false; }
|
|
304
306
|
this.checkConfig();
|
|
305
307
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
306
|
-
var token, error_3;
|
|
308
|
+
var currentCookies, cookieName, token, error_3;
|
|
307
309
|
return __generator(this, function (_a) {
|
|
308
310
|
switch (_a.label) {
|
|
309
311
|
case 0:
|
|
312
|
+
currentCookies = js_cookie_1.default.get();
|
|
313
|
+
for (cookieName in currentCookies) {
|
|
314
|
+
if ([
|
|
315
|
+
"XSRF-TOKEN",
|
|
316
|
+
"voapp_redirectTo",
|
|
317
|
+
"vo_organisation",
|
|
318
|
+
VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN,
|
|
319
|
+
VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN,
|
|
320
|
+
].indexOf(cookieName) === -1) {
|
|
321
|
+
js_cookie_1.default.remove(cookieName, {
|
|
322
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
310
326
|
token = this.getToken();
|
|
311
327
|
if (!token) return [3 /*break*/, 5];
|
|
312
328
|
_a.label = 1;
|
|
@@ -382,18 +398,19 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
382
398
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
383
399
|
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
384
400
|
var accessToken = js_cookie_1.default.get(accessTokenKey);
|
|
385
|
-
|
|
386
|
-
// const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
// const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
390
|
-
|
|
391
|
-
if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
401
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
402
|
+
// // const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
403
|
+
// const tokenType = JsCookies.get(tokenTypeKey);
|
|
404
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
405
|
+
// // const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
406
|
+
// const expiresIn = JsCookies.get(expiresInKey);
|
|
407
|
+
// if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
408
|
+
if (refreshToken && accessToken) {
|
|
392
409
|
return {
|
|
393
410
|
refresh_token: refreshToken,
|
|
394
411
|
access_token: accessToken,
|
|
395
|
-
token_type: tokenType,
|
|
396
|
-
expires_in: expiresIn,
|
|
412
|
+
// token_type: tokenType,
|
|
413
|
+
// expires_in: expiresIn,
|
|
397
414
|
};
|
|
398
415
|
}
|
|
399
416
|
}
|
|
@@ -430,13 +447,20 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
430
447
|
sameSite: "Lax",
|
|
431
448
|
expires: 1,
|
|
432
449
|
});
|
|
433
|
-
var
|
|
434
|
-
Helpers.localStorage.remove(
|
|
435
|
-
js_cookie_1.default.remove(
|
|
450
|
+
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
451
|
+
Helpers.localStorage.remove(refreshTokenKey);
|
|
452
|
+
js_cookie_1.default.remove(refreshTokenKey, {
|
|
436
453
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
437
454
|
sameSite: "Lax",
|
|
438
|
-
expires:
|
|
455
|
+
expires: 1,
|
|
439
456
|
});
|
|
457
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
458
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
459
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
460
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
461
|
+
// sameSite: "Lax",
|
|
462
|
+
// expires: 12,
|
|
463
|
+
// });
|
|
440
464
|
return {
|
|
441
465
|
state: state,
|
|
442
466
|
challenge: challenge,
|
package/dist/modules/VoConfig.js
CHANGED
|
@@ -43,12 +43,12 @@ var VoConfig = /** @class */ (function () {
|
|
|
43
43
|
LOGIN: "",
|
|
44
44
|
HOME: "",
|
|
45
45
|
HOME_AUTHENTICATED: "",
|
|
46
|
-
AUTH_STORAGE_STATE: "
|
|
47
|
-
AUTH_STORAGE_VERIFIER: "
|
|
48
|
-
AUTH_STORAGE_REFRESH_TOKEN: "
|
|
49
|
-
AUTH_STORAGE_ACCESS_TOKEN: "
|
|
50
|
-
AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
-
AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
46
|
+
AUTH_STORAGE_STATE: "vo_state",
|
|
47
|
+
AUTH_STORAGE_VERIFIER: "vo_verifier",
|
|
48
|
+
AUTH_STORAGE_REFRESH_TOKEN: "vo_rtoken",
|
|
49
|
+
AUTH_STORAGE_ACCESS_TOKEN: "vo_atoken",
|
|
50
|
+
// AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
+
// AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
52
52
|
AUTH_DOMAIN: ".vo-college.se",
|
|
53
53
|
CURRENT_GROUP: "vo_group",
|
|
54
54
|
MASQUERADE_USER: "vo_masquerade",
|
package/package.json
CHANGED
package/src/global.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type AuthStorageConfigType = {
|
|
|
4
4
|
REFRESH_TOKEN: string;
|
|
5
5
|
ACCESS_TOKEN: string;
|
|
6
6
|
TOKEN_TYPE: string;
|
|
7
|
-
EXPIRES_IN: string;
|
|
7
|
+
// EXPIRES_IN: string;
|
|
8
8
|
};
|
|
9
9
|
export type AuthConfigType = {
|
|
10
10
|
BASE_URL: string;
|
|
@@ -31,10 +31,10 @@ export type VoAppType = {
|
|
|
31
31
|
api: any;
|
|
32
32
|
};
|
|
33
33
|
export type VoTokenType = {
|
|
34
|
-
token_type: string;
|
|
34
|
+
// token_type: string;
|
|
35
35
|
access_token: string;
|
|
36
36
|
refresh_token: string;
|
|
37
|
-
expires_in: string;
|
|
37
|
+
// expires_in: string;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export interface GeneralObject {
|
package/src/interceptor.ts
CHANGED
|
@@ -48,7 +48,8 @@ import I18n from "./modules/Services/I18n";
|
|
|
48
48
|
if (token) {
|
|
49
49
|
retry = 0;
|
|
50
50
|
error.config.headers["Authorization"] =
|
|
51
|
-
token.token_type + " " + token.access_token;
|
|
51
|
+
// token.token_type + " " + token.access_token;
|
|
52
|
+
"Bearer " + token.access_token;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
return axios.request(error.config);
|
|
@@ -64,9 +65,10 @@ import I18n from "./modules/Services/I18n";
|
|
|
64
65
|
switch (status) {
|
|
65
66
|
case 419:
|
|
66
67
|
toast.error(I18n.get.messages.sessionExpired);
|
|
67
|
-
setTimeout(() => {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
// setTimeout(() => {
|
|
69
|
+
redirect();
|
|
70
|
+
reject(error);
|
|
71
|
+
// }, 5000);
|
|
70
72
|
break;
|
|
71
73
|
default:
|
|
72
74
|
reject(error);
|
|
@@ -137,7 +137,8 @@ class GraphClient {
|
|
|
137
137
|
...currentHeaders,
|
|
138
138
|
headers: {
|
|
139
139
|
Authorization: token
|
|
140
|
-
? `${token.token_type} ${token.access_token}`
|
|
140
|
+
? // ? `${token.token_type} ${token.access_token}`
|
|
141
|
+
`Bearer ${token.access_token}`
|
|
141
142
|
: "",
|
|
142
143
|
VoGroup: groupId,
|
|
143
144
|
},
|
package/src/modules/VoAuth.ts
CHANGED
|
@@ -99,12 +99,13 @@ class VoAuth extends VoBase {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
setSession(token: any) {
|
|
102
|
-
const { token_type, access_token, refresh_token, expires_in } = token;
|
|
102
|
+
// const { token_type, access_token, refresh_token, expires_in } = token;
|
|
103
|
+
const { access_token, refresh_token } = token;
|
|
103
104
|
|
|
104
105
|
let refreshTokenKey = VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
105
106
|
// Helpers.localStorage.set(refreshTokenKey, refresh_token);
|
|
106
107
|
JsCookies.set(refreshTokenKey, refresh_token, {
|
|
107
|
-
expires:
|
|
108
|
+
expires: 11,
|
|
108
109
|
sameSite: "Lax",
|
|
109
110
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
110
111
|
});
|
|
@@ -112,29 +113,30 @@ class VoAuth extends VoBase {
|
|
|
112
113
|
let accessTokenKey = VoConfig.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
113
114
|
// Helpers.localStorage.set(accessTokenKey, access_token);
|
|
114
115
|
JsCookies.set(accessTokenKey, access_token, {
|
|
115
|
-
expires:
|
|
116
|
+
expires: 1,
|
|
116
117
|
sameSite: "Lax",
|
|
117
118
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
118
119
|
});
|
|
119
120
|
|
|
120
|
-
let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
121
|
-
// Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
122
|
-
JsCookies.set(tokenTypeKey, token_type, {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
129
|
-
// Helpers.localStorage.set(expiresInKey, expires_in);
|
|
130
|
-
JsCookies.set(expiresInKey, expires_in, {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
121
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
122
|
+
// // Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
123
|
+
// JsCookies.set(tokenTypeKey, token_type, {
|
|
124
|
+
// expires: 11,
|
|
125
|
+
// sameSite: "Lax",
|
|
126
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
127
|
+
// });
|
|
128
|
+
|
|
129
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
130
|
+
// // Helpers.localStorage.set(expiresInKey, expires_in);
|
|
131
|
+
// JsCookies.set(expiresInKey, expires_in, {
|
|
132
|
+
// expires: 11,
|
|
133
|
+
// sameSite: "Lax",
|
|
134
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
135
|
+
// });
|
|
135
136
|
|
|
136
137
|
axios.defaults.headers.common["Authorization"] =
|
|
137
|
-
token_type + " " + access_token;
|
|
138
|
+
// token_type + " " + access_token;
|
|
139
|
+
"Bearer " + access_token;
|
|
138
140
|
let currentGroup = VoGroups.getCurrent(true);
|
|
139
141
|
axios.defaults.headers.common["VoGroup"] = currentGroup
|
|
140
142
|
? currentGroup.id
|
|
@@ -155,19 +157,19 @@ class VoAuth extends VoBase {
|
|
|
155
157
|
sameSite: "Lax",
|
|
156
158
|
});
|
|
157
159
|
|
|
158
|
-
let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
159
|
-
Helpers.localStorage.remove(tokenTypeKey);
|
|
160
|
-
JsCookies.remove(tokenTypeKey, {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
160
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
161
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
162
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
163
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
164
|
+
// sameSite: "Lax",
|
|
165
|
+
// });
|
|
164
166
|
|
|
165
|
-
let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
166
|
-
Helpers.localStorage.remove(expiresInKey);
|
|
167
|
-
JsCookies.remove(expiresInKey, {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
167
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
168
|
+
// Helpers.localStorage.remove(expiresInKey);
|
|
169
|
+
// JsCookies.remove(expiresInKey, {
|
|
170
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
171
|
+
// sameSite: "Lax",
|
|
172
|
+
// });
|
|
171
173
|
|
|
172
174
|
Helpers.localStorage.remove(VoConfig.get.CURRENT_GROUP || "");
|
|
173
175
|
Helpers.localStorage.remove(VoConfig.get.MASQUERADE_USER || "");
|
|
@@ -203,6 +205,24 @@ class VoAuth extends VoBase {
|
|
|
203
205
|
check(forceRedirect = false, forceLoad = false): Promise<any> {
|
|
204
206
|
this.checkConfig();
|
|
205
207
|
return new Promise(async (resolve, reject) => {
|
|
208
|
+
// VC-231 | Clear up unnecessary cookies.
|
|
209
|
+
let currentCookies = JsCookies.get();
|
|
210
|
+
for (const cookieName in currentCookies) {
|
|
211
|
+
if (
|
|
212
|
+
[
|
|
213
|
+
"XSRF-TOKEN",
|
|
214
|
+
"voapp_redirectTo",
|
|
215
|
+
"vo_organisation",
|
|
216
|
+
VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN,
|
|
217
|
+
VoConfig.get.AUTH_STORAGE_ACCESS_TOKEN,
|
|
218
|
+
].indexOf(cookieName) === -1
|
|
219
|
+
) {
|
|
220
|
+
JsCookies.remove(cookieName, {
|
|
221
|
+
domain: VoConfig.get.AUTH_DOMAIN,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
206
226
|
const token = this.getToken();
|
|
207
227
|
if (token) {
|
|
208
228
|
try {
|
|
@@ -252,20 +272,21 @@ class VoAuth extends VoBase {
|
|
|
252
272
|
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
253
273
|
const accessToken = JsCookies.get(accessTokenKey);
|
|
254
274
|
|
|
255
|
-
let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
256
|
-
// const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
257
|
-
const tokenType = JsCookies.get(tokenTypeKey);
|
|
275
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
276
|
+
// // const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
277
|
+
// const tokenType = JsCookies.get(tokenTypeKey);
|
|
258
278
|
|
|
259
|
-
let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
260
|
-
// const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
261
|
-
const expiresIn = JsCookies.get(expiresInKey);
|
|
279
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
280
|
+
// // const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
281
|
+
// const expiresIn = JsCookies.get(expiresInKey);
|
|
262
282
|
|
|
263
|
-
if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
283
|
+
// if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
284
|
+
if (refreshToken && accessToken) {
|
|
264
285
|
return {
|
|
265
286
|
refresh_token: refreshToken,
|
|
266
287
|
access_token: accessToken,
|
|
267
|
-
token_type: tokenType,
|
|
268
|
-
expires_in: expiresIn,
|
|
288
|
+
// token_type: tokenType,
|
|
289
|
+
// expires_in: expiresIn,
|
|
269
290
|
};
|
|
270
291
|
}
|
|
271
292
|
} catch (error) {
|
|
@@ -307,14 +328,22 @@ class VoAuth extends VoBase {
|
|
|
307
328
|
expires: 1,
|
|
308
329
|
});
|
|
309
330
|
|
|
310
|
-
let
|
|
311
|
-
Helpers.localStorage.remove(
|
|
312
|
-
JsCookies.remove(
|
|
331
|
+
let refreshTokenKey = VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
332
|
+
Helpers.localStorage.remove(refreshTokenKey);
|
|
333
|
+
JsCookies.remove(refreshTokenKey, {
|
|
313
334
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
314
335
|
sameSite: "Lax",
|
|
315
|
-
expires:
|
|
336
|
+
expires: 1,
|
|
316
337
|
});
|
|
317
338
|
|
|
339
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
340
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
341
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
342
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
343
|
+
// sameSite: "Lax",
|
|
344
|
+
// expires: 12,
|
|
345
|
+
// });
|
|
346
|
+
|
|
318
347
|
return {
|
|
319
348
|
state,
|
|
320
349
|
challenge,
|
package/src/modules/VoConfig.ts
CHANGED
|
@@ -43,12 +43,12 @@ class VoConfig {
|
|
|
43
43
|
HOME: "",
|
|
44
44
|
HOME_AUTHENTICATED: "",
|
|
45
45
|
|
|
46
|
-
AUTH_STORAGE_STATE: "
|
|
47
|
-
AUTH_STORAGE_VERIFIER: "
|
|
48
|
-
AUTH_STORAGE_REFRESH_TOKEN: "
|
|
49
|
-
AUTH_STORAGE_ACCESS_TOKEN: "
|
|
50
|
-
AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
-
AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
46
|
+
AUTH_STORAGE_STATE: "vo_state",
|
|
47
|
+
AUTH_STORAGE_VERIFIER: "vo_verifier",
|
|
48
|
+
AUTH_STORAGE_REFRESH_TOKEN: "vo_rtoken",
|
|
49
|
+
AUTH_STORAGE_ACCESS_TOKEN: "vo_atoken",
|
|
50
|
+
// AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
+
// AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
52
52
|
AUTH_DOMAIN: ".vo-college.se",
|
|
53
53
|
|
|
54
54
|
CURRENT_GROUP: "vo_group",
|