@arsedizioni/ars-utils 20.2.4 → 20.2.6
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.
|
@@ -198,7 +198,7 @@ interface ClipperLoginInfo {
|
|
|
198
198
|
complianceContext?: any;
|
|
199
199
|
channels?: ClipperChannelSettings[];
|
|
200
200
|
credentials?: string;
|
|
201
|
-
|
|
201
|
+
oauth?: LoginOAuthType;
|
|
202
202
|
}
|
|
203
203
|
declare class ClipperSearchParams {
|
|
204
204
|
version: number;
|
|
@@ -1059,9 +1059,14 @@ declare class ClipperService implements OnDestroy {
|
|
|
1059
1059
|
*/
|
|
1060
1060
|
getMFAToken(): string | null;
|
|
1061
1061
|
/**
|
|
1062
|
-
* Store
|
|
1062
|
+
* Store context
|
|
1063
1063
|
*/
|
|
1064
|
-
|
|
1064
|
+
storeContext(): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Update context
|
|
1067
|
+
* @param newContext: the new context
|
|
1068
|
+
*/
|
|
1069
|
+
updateContext(newContext?: ClipperUserInfo): void;
|
|
1065
1070
|
/**
|
|
1066
1071
|
* Perform auto login using current link data
|
|
1067
1072
|
* @param email: the optional email if using OAuth2
|
package/core/index.d.ts
CHANGED
|
@@ -567,7 +567,7 @@ interface LoginResult<T> extends ApiResult<boolean> {
|
|
|
567
567
|
token: string;
|
|
568
568
|
refreshToken?: string;
|
|
569
569
|
requiresMFA?: boolean;
|
|
570
|
-
|
|
570
|
+
mfaToken?: string;
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
declare class DateIntervalChangeDirective implements OnInit, OnDestroy {
|
|
@@ -2031,7 +2031,7 @@ class ClipperService {
|
|
|
2031
2031
|
}
|
|
2032
2032
|
get loginInfo() {
|
|
2033
2033
|
if (!this._loginInfo) {
|
|
2034
|
-
const loginInfo = localStorage.getItem('
|
|
2034
|
+
const loginInfo = localStorage.getItem('clipper_context');
|
|
2035
2035
|
if (loginInfo) {
|
|
2036
2036
|
try {
|
|
2037
2037
|
this._loginInfo = JSON.parse(loginInfo);
|
|
@@ -2117,7 +2117,6 @@ class ClipperService {
|
|
|
2117
2117
|
if (!tokenExpired || this.loggedIn()) {
|
|
2118
2118
|
// Auto login
|
|
2119
2119
|
this.loggedIn.set(true);
|
|
2120
|
-
this.loggingIn.set(false);
|
|
2121
2120
|
// Should refresh
|
|
2122
2121
|
this.shouldRefreshToken.set(!!tokenExpirationDate);
|
|
2123
2122
|
// Keep alive
|
|
@@ -2183,7 +2182,7 @@ class ClipperService {
|
|
|
2183
2182
|
setToken(value) {
|
|
2184
2183
|
sessionStorage.setItem('clipper_jwt', value.token);
|
|
2185
2184
|
sessionStorage.setItem('clipper_jwt_refresh', value.refreshToken ?? '');
|
|
2186
|
-
localStorage.setItem('clipper_mfa', value.
|
|
2185
|
+
localStorage.setItem('clipper_mfa', value.mfaToken ?? '');
|
|
2187
2186
|
}
|
|
2188
2187
|
/**
|
|
2189
2188
|
* Return current JWT token
|
|
@@ -2203,10 +2202,22 @@ class ClipperService {
|
|
|
2203
2202
|
return localStorage.getItem("clipper_mfa");
|
|
2204
2203
|
}
|
|
2205
2204
|
/**
|
|
2206
|
-
* Store
|
|
2205
|
+
* Store context
|
|
2207
2206
|
*/
|
|
2208
|
-
|
|
2209
|
-
localStorage.setItem('
|
|
2207
|
+
storeContext() {
|
|
2208
|
+
localStorage.setItem('clipper_context', JSON.stringify(this._loginInfo));
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Update context
|
|
2212
|
+
* @param newContext: the new context
|
|
2213
|
+
*/
|
|
2214
|
+
updateContext(newContext) {
|
|
2215
|
+
// Update login info
|
|
2216
|
+
if (!this._loginInfo)
|
|
2217
|
+
this._loginInfo = { context: newContext };
|
|
2218
|
+
else
|
|
2219
|
+
this._loginInfo.context = newContext;
|
|
2220
|
+
this.storeContext();
|
|
2210
2221
|
}
|
|
2211
2222
|
/**
|
|
2212
2223
|
* Perform auto login using current link data
|
|
@@ -2269,7 +2280,6 @@ class ClipperService {
|
|
|
2269
2280
|
* @returns: the login result
|
|
2270
2281
|
*/
|
|
2271
2282
|
login(email, password, remember, oauth, oauthAccessToken = sessionStorage.getItem("clipper_oauth_token")) {
|
|
2272
|
-
this.loggingIn.set(true);
|
|
2273
2283
|
return this.httpClient
|
|
2274
2284
|
.post(this._serviceUri + '/login2', {
|
|
2275
2285
|
user: oauth ? null : email,
|
|
@@ -2285,26 +2295,25 @@ class ClipperService {
|
|
|
2285
2295
|
})
|
|
2286
2296
|
.pipe(catchError(err => {
|
|
2287
2297
|
this.loggingIn.set(false);
|
|
2288
|
-
localStorage.removeItem('
|
|
2298
|
+
localStorage.removeItem('clipper_context');
|
|
2289
2299
|
localStorage.removeItem('clipper_mfa');
|
|
2290
2300
|
return throwError(() => err);
|
|
2291
2301
|
}), map((r) => {
|
|
2292
2302
|
if (r.success) {
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
email: email,
|
|
2303
|
-
password: password,
|
|
2304
|
-
remember: remember,
|
|
2305
|
-
}), loginInfo.context.userId.toString());
|
|
2306
|
-
this.storeLogin();
|
|
2303
|
+
if (!this._loginInfo)
|
|
2304
|
+
this._loginInfo = { context: undefined };
|
|
2305
|
+
this._loginInfo.oauth = oauth;
|
|
2306
|
+
if (!this._loginInfo.oauth) {
|
|
2307
|
+
this._loginInfo.credentials = SystemUtils.cipher(JSON.stringify({
|
|
2308
|
+
email: email,
|
|
2309
|
+
password: password,
|
|
2310
|
+
remember: remember
|
|
2311
|
+
}), r.value.context?.userId?.toString() ?? '');
|
|
2307
2312
|
}
|
|
2313
|
+
else {
|
|
2314
|
+
this._loginInfo.credentials = undefined;
|
|
2315
|
+
}
|
|
2316
|
+
console.log(r.value.requiresMFA ?? "no");
|
|
2308
2317
|
if (!oauth && r.value.requiresMFA) {
|
|
2309
2318
|
// Notify login is pending
|
|
2310
2319
|
this.broadcastService.sendMessage(ClipperMessages.LOGIN_PENDING);
|
|
@@ -2324,6 +2333,7 @@ class ClipperService {
|
|
|
2324
2333
|
completeLogin(result) {
|
|
2325
2334
|
// Update info
|
|
2326
2335
|
this.setToken(result);
|
|
2336
|
+
this.updateContext(result.context);
|
|
2327
2337
|
this.loggedIn.set(true);
|
|
2328
2338
|
this.loggingIn.set(false);
|
|
2329
2339
|
// Keep alive
|
|
@@ -2341,7 +2351,7 @@ class ClipperService {
|
|
|
2341
2351
|
return this.httpClient
|
|
2342
2352
|
.post(this._serviceUri + '/login/confirm/' + code, {})
|
|
2343
2353
|
.pipe(catchError((err) => {
|
|
2344
|
-
localStorage.removeItem('
|
|
2354
|
+
localStorage.removeItem('clipper_context');
|
|
2345
2355
|
localStorage.removeItem('clipper_mfa');
|
|
2346
2356
|
this.loggingIn.set(false);
|
|
2347
2357
|
return throwError(() => err);
|
|
@@ -2361,7 +2371,7 @@ class ClipperService {
|
|
|
2361
2371
|
this.removeKeepAlive();
|
|
2362
2372
|
this.clear(true);
|
|
2363
2373
|
// Remove credentials
|
|
2364
|
-
localStorage.removeItem('
|
|
2374
|
+
localStorage.removeItem('clipper_context');
|
|
2365
2375
|
localStorage.removeItem('clipper_mfa');
|
|
2366
2376
|
}), catchError((_e) => {
|
|
2367
2377
|
return of([]);
|
|
@@ -2375,7 +2385,6 @@ class ClipperService {
|
|
|
2375
2385
|
this._loginInfo = undefined;
|
|
2376
2386
|
// Logged out
|
|
2377
2387
|
this.loggedIn.set(false);
|
|
2378
|
-
this.loggingIn.set(false);
|
|
2379
2388
|
// Reset channels
|
|
2380
2389
|
this.availableChannels.set([]);
|
|
2381
2390
|
// Notify
|
|
@@ -2808,7 +2817,7 @@ class ClipperService {
|
|
|
2808
2817
|
if (params.channels) {
|
|
2809
2818
|
// Update channels
|
|
2810
2819
|
this._loginInfo.channels = params.channels;
|
|
2811
|
-
this.
|
|
2820
|
+
this.storeContext();
|
|
2812
2821
|
this.initializeChannels();
|
|
2813
2822
|
}
|
|
2814
2823
|
}
|
|
@@ -2831,7 +2840,7 @@ class ClipperService {
|
|
|
2831
2840
|
this.dashboard.isTrial = r.value.isTrial;
|
|
2832
2841
|
this.dashboard.items.set(r.value.items ?? []);
|
|
2833
2842
|
this.broadcastService.sendMessage(ClipperMessages.COMMAND_DASHBOARD_UPDATED);
|
|
2834
|
-
this.
|
|
2843
|
+
this.storeContext();
|
|
2835
2844
|
this.initializeChannels();
|
|
2836
2845
|
}
|
|
2837
2846
|
return r;
|