@vocollege/app 0.0.76 → 0.0.77
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 +69 -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 +74 -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,25 @@ 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
|
+
console.log("cookieName", cookieName);
|
|
315
|
+
if ([
|
|
316
|
+
"XSRF-TOKEN",
|
|
317
|
+
"voapp_redirectTo",
|
|
318
|
+
"vo_organisation",
|
|
319
|
+
VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN,
|
|
320
|
+
VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN,
|
|
321
|
+
].indexOf(cookieName) === -1) {
|
|
322
|
+
js_cookie_1.default.remove(cookieName, {
|
|
323
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
310
327
|
token = this.getToken();
|
|
311
328
|
if (!token) return [3 /*break*/, 5];
|
|
312
329
|
_a.label = 1;
|
|
@@ -382,18 +399,19 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
382
399
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
383
400
|
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
384
401
|
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) {
|
|
402
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
403
|
+
// // const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
404
|
+
// const tokenType = JsCookies.get(tokenTypeKey);
|
|
405
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
406
|
+
// // const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
407
|
+
// const expiresIn = JsCookies.get(expiresInKey);
|
|
408
|
+
// if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
409
|
+
if (refreshToken && accessToken) {
|
|
392
410
|
return {
|
|
393
411
|
refresh_token: refreshToken,
|
|
394
412
|
access_token: accessToken,
|
|
395
|
-
token_type: tokenType,
|
|
396
|
-
expires_in: expiresIn,
|
|
413
|
+
// token_type: tokenType,
|
|
414
|
+
// expires_in: expiresIn,
|
|
397
415
|
};
|
|
398
416
|
}
|
|
399
417
|
}
|
|
@@ -430,13 +448,20 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
430
448
|
sameSite: "Lax",
|
|
431
449
|
expires: 1,
|
|
432
450
|
});
|
|
433
|
-
var
|
|
434
|
-
Helpers.localStorage.remove(
|
|
435
|
-
js_cookie_1.default.remove(
|
|
451
|
+
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
452
|
+
Helpers.localStorage.remove(refreshTokenKey);
|
|
453
|
+
js_cookie_1.default.remove(refreshTokenKey, {
|
|
436
454
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
437
455
|
sameSite: "Lax",
|
|
438
|
-
expires:
|
|
456
|
+
expires: 1,
|
|
439
457
|
});
|
|
458
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
459
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
460
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
461
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
462
|
+
// sameSite: "Lax",
|
|
463
|
+
// expires: 12,
|
|
464
|
+
// });
|
|
440
465
|
return {
|
|
441
466
|
state: state,
|
|
442
467
|
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,25 @@ 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
|
+
console.log("cookieName", cookieName);
|
|
212
|
+
if (
|
|
213
|
+
[
|
|
214
|
+
"XSRF-TOKEN",
|
|
215
|
+
"voapp_redirectTo",
|
|
216
|
+
"vo_organisation",
|
|
217
|
+
VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN,
|
|
218
|
+
VoConfig.get.AUTH_STORAGE_ACCESS_TOKEN,
|
|
219
|
+
].indexOf(cookieName) === -1
|
|
220
|
+
) {
|
|
221
|
+
JsCookies.remove(cookieName, {
|
|
222
|
+
domain: VoConfig.get.AUTH_DOMAIN,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
206
227
|
const token = this.getToken();
|
|
207
228
|
if (token) {
|
|
208
229
|
try {
|
|
@@ -252,20 +273,21 @@ class VoAuth extends VoBase {
|
|
|
252
273
|
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
253
274
|
const accessToken = JsCookies.get(accessTokenKey);
|
|
254
275
|
|
|
255
|
-
let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
256
|
-
// const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
257
|
-
const tokenType = JsCookies.get(tokenTypeKey);
|
|
276
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
277
|
+
// // const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
278
|
+
// const tokenType = JsCookies.get(tokenTypeKey);
|
|
258
279
|
|
|
259
|
-
let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
260
|
-
// const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
261
|
-
const expiresIn = JsCookies.get(expiresInKey);
|
|
280
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
281
|
+
// // const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
282
|
+
// const expiresIn = JsCookies.get(expiresInKey);
|
|
262
283
|
|
|
263
|
-
if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
284
|
+
// if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
285
|
+
if (refreshToken && accessToken) {
|
|
264
286
|
return {
|
|
265
287
|
refresh_token: refreshToken,
|
|
266
288
|
access_token: accessToken,
|
|
267
|
-
token_type: tokenType,
|
|
268
|
-
expires_in: expiresIn,
|
|
289
|
+
// token_type: tokenType,
|
|
290
|
+
// expires_in: expiresIn,
|
|
269
291
|
};
|
|
270
292
|
}
|
|
271
293
|
} catch (error) {
|
|
@@ -307,14 +329,22 @@ class VoAuth extends VoBase {
|
|
|
307
329
|
expires: 1,
|
|
308
330
|
});
|
|
309
331
|
|
|
310
|
-
let
|
|
311
|
-
Helpers.localStorage.remove(
|
|
312
|
-
JsCookies.remove(
|
|
332
|
+
let refreshTokenKey = VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
333
|
+
Helpers.localStorage.remove(refreshTokenKey);
|
|
334
|
+
JsCookies.remove(refreshTokenKey, {
|
|
313
335
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
314
336
|
sameSite: "Lax",
|
|
315
|
-
expires:
|
|
337
|
+
expires: 1,
|
|
316
338
|
});
|
|
317
339
|
|
|
340
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
341
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
342
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
343
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
344
|
+
// sameSite: "Lax",
|
|
345
|
+
// expires: 12,
|
|
346
|
+
// });
|
|
347
|
+
|
|
318
348
|
return {
|
|
319
349
|
state,
|
|
320
350
|
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",
|