@arsedizioni/ars-utils 19.0.21 → 19.0.23
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/clipper.common/common/services/clipper.service.d.ts +8 -0
- package/evolution.common/common/services/evolution.service.d.ts +8 -0
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs +20 -5
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs +20 -6
- package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-support.common.mjs +20 -5
- package/fesm2022/arsedizioni-ars-utils-support.common.mjs.map +1 -1
- package/package.json +5 -5
- package/support.common/common/services/support.service.d.ts +8 -0
|
@@ -39,6 +39,14 @@ export declare class ClipperService implements OnDestroy {
|
|
|
39
39
|
*/
|
|
40
40
|
initialize(serviceUri: string, flags?: ClipperServiceFlags): void;
|
|
41
41
|
/**
|
|
42
|
+
* Get access token expiration date
|
|
43
|
+
*/
|
|
44
|
+
private getTokenExpirationDate;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if access token in expired
|
|
47
|
+
*/
|
|
48
|
+
private isTokenExpired;
|
|
49
|
+
/**
|
|
42
50
|
* Set keep alive
|
|
43
51
|
*/
|
|
44
52
|
private setKeepAlive;
|
|
@@ -24,6 +24,14 @@ export declare class EvolutionService implements OnDestroy {
|
|
|
24
24
|
* @param flags: the service flags. Default is none.
|
|
25
25
|
*/
|
|
26
26
|
initialize(serviceUri: string, flags?: EvolutionServiceFlags): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get access token expiration date
|
|
29
|
+
*/
|
|
30
|
+
private getTokenExpirationDate;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if access token in expired
|
|
33
|
+
*/
|
|
34
|
+
private isTokenExpired;
|
|
27
35
|
/**
|
|
28
36
|
* Set keep alive
|
|
29
37
|
*/
|
|
@@ -2197,7 +2197,7 @@ class ClipperService {
|
|
|
2197
2197
|
});
|
|
2198
2198
|
}
|
|
2199
2199
|
// Eveluate current session storage in case of page refresh (F5)
|
|
2200
|
-
if (!this.loggedIn() && this.
|
|
2200
|
+
if (!this.loggedIn() && !this.isTokenExpired()) {
|
|
2201
2201
|
// Auto login
|
|
2202
2202
|
this.loggedIn.set(true);
|
|
2203
2203
|
// Notify
|
|
@@ -2207,6 +2207,25 @@ class ClipperService {
|
|
|
2207
2207
|
}
|
|
2208
2208
|
}
|
|
2209
2209
|
/**
|
|
2210
|
+
* Get access token expiration date
|
|
2211
|
+
*/
|
|
2212
|
+
getTokenExpirationDate() {
|
|
2213
|
+
const token = this.getToken();
|
|
2214
|
+
if (!token)
|
|
2215
|
+
return null;
|
|
2216
|
+
// Parse json object from base64 encoded jwt token
|
|
2217
|
+
const jwtToken = JSON.parse(atob(token.split('.')[1]));
|
|
2218
|
+
// Set a timeout to refresh the token a minute before it expires
|
|
2219
|
+
return new Date(jwtToken.exp * 1000);
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Checks if access token in expired
|
|
2223
|
+
*/
|
|
2224
|
+
isTokenExpired() {
|
|
2225
|
+
const expires = this.getTokenExpirationDate();
|
|
2226
|
+
return !expires || expires.getTime() < Date.now();
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2210
2229
|
* Set keep alive
|
|
2211
2230
|
*/
|
|
2212
2231
|
setKeepAlive() {
|
|
@@ -2374,11 +2393,7 @@ class ClipperService {
|
|
|
2374
2393
|
return this.httpClient.post(this._serviceUri + '/logout', {}).pipe(finalize(() => {
|
|
2375
2394
|
this.removeKeepAlive();
|
|
2376
2395
|
this.clear(true);
|
|
2377
|
-
}), map(r => {
|
|
2378
|
-
this.clear(true);
|
|
2379
|
-
return r;
|
|
2380
2396
|
}), catchError((_e) => {
|
|
2381
|
-
this.clear(true);
|
|
2382
2397
|
return of([]);
|
|
2383
2398
|
}));
|
|
2384
2399
|
}
|