@trudb/tru-common-lib 0.2.460 → 0.2.462
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/fesm2022/trudb-tru-common-lib.mjs +753 -47
- package/fesm2022/trudb-tru-common-lib.mjs.map +1 -1
- package/lib/components/login/services/tru-auth.d.ts +5 -1
- package/lib/components/login/services/tru-server-touch-interceptor.d.ts +14 -0
- package/lib/components/login/services/tru-server-touch-tracker.d.ts +31 -0
- package/lib/components/login/services/tru-session-expiry-monitor.d.ts +37 -0
- package/lib/components/login/services/tru-session-keepalive.d.ts +44 -0
- package/lib/components/login/services/tru-user-activity-tracker.d.ts +14 -0
- package/lib/services/tru-app-environment.d.ts +3 -0
- package/lib/services/tru-ui-notification.d.ts +5 -0
- package/package.json +1 -1
|
@@ -6,6 +6,8 @@ import { TruAuthCache } from "./tru-auth-cache";
|
|
|
6
6
|
import { TruAuthStrategy } from "../classes/tru-auth-config";
|
|
7
7
|
import { TruUser } from "../../../services/tru-user";
|
|
8
8
|
import { TruAppEnvironment } from "../../../services/tru-app-environment";
|
|
9
|
+
import { TruSessionKeepalive } from "./tru-session-keepalive";
|
|
10
|
+
import { TruSessionExpiryMonitor } from "./tru-session-expiry-monitor";
|
|
9
11
|
import * as i0 from "@angular/core";
|
|
10
12
|
export declare class TruAuth {
|
|
11
13
|
private router;
|
|
@@ -13,10 +15,12 @@ export declare class TruAuth {
|
|
|
13
15
|
private cache;
|
|
14
16
|
private user;
|
|
15
17
|
private appEnvironment;
|
|
18
|
+
private sessionKeepalive;
|
|
19
|
+
private sessionExpiryMonitor;
|
|
16
20
|
private auth;
|
|
17
21
|
private loggedIn;
|
|
18
22
|
private baseUrl;
|
|
19
|
-
constructor(router: Router, http: HttpClient, cache: TruAuthCache, user: TruUser, appEnvironment: TruAppEnvironment, auth: TruAuthStrategy<any>);
|
|
23
|
+
constructor(router: Router, http: HttpClient, cache: TruAuthCache, user: TruUser, appEnvironment: TruAppEnvironment, sessionKeepalive: TruSessionKeepalive, sessionExpiryMonitor: TruSessionExpiryMonitor, auth: TruAuthStrategy<any>);
|
|
20
24
|
login(loginRequest: TruAuthLoginRequest): Observable<any>;
|
|
21
25
|
setUser(): void;
|
|
22
26
|
logout(): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { TruAppEnvironment } from '../../../services/tru-app-environment';
|
|
4
|
+
import { TruServerTouchTracker } from './tru-server-touch-tracker';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class TruServerTouchInterceptor implements HttpInterceptor {
|
|
7
|
+
private appEnvironment;
|
|
8
|
+
private tracker;
|
|
9
|
+
constructor(appEnvironment: TruAppEnvironment, tracker: TruServerTouchTracker);
|
|
10
|
+
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
|
|
11
|
+
private isApiRequest;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TruServerTouchInterceptor, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TruServerTouchInterceptor>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { TruAppEnvironment } from '../../../services/tru-app-environment';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class TruServerTouchTracker {
|
|
5
|
+
private appEnvironment;
|
|
6
|
+
private static readonly STORAGE_PREFIX;
|
|
7
|
+
private lastServerTouchAtMs;
|
|
8
|
+
private lastSessionRenewedAtMs;
|
|
9
|
+
private readonly serverTouchSubject;
|
|
10
|
+
private readonly sessionRenewedSubject;
|
|
11
|
+
constructor(appEnvironment: TruAppEnvironment);
|
|
12
|
+
get serverTouch$(): Observable<number>;
|
|
13
|
+
get sessionRenewed$(): Observable<number>;
|
|
14
|
+
getLastServerTouchAtMs(): number;
|
|
15
|
+
getLastSessionRenewedAtMs(): number;
|
|
16
|
+
recordServerTouch(atMs?: number): void;
|
|
17
|
+
tryAcquireKeepaliveLock(ownerId: string, ttlMs: number, nowMs?: number): boolean;
|
|
18
|
+
releaseKeepaliveLock(ownerId: string): void;
|
|
19
|
+
private maybeRecordSessionRenewal;
|
|
20
|
+
private recordSessionRenewed;
|
|
21
|
+
private getStorageKey;
|
|
22
|
+
private getStorageKeyPrefix;
|
|
23
|
+
private readLock;
|
|
24
|
+
private getAppScope;
|
|
25
|
+
private getTimeoutMs;
|
|
26
|
+
private setupCrossTabStorageSync;
|
|
27
|
+
private readNumber;
|
|
28
|
+
private writeNumber;
|
|
29
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TruServerTouchTracker, never>;
|
|
30
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TruServerTouchTracker>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { NgZone } from '@angular/core';
|
|
2
|
+
import { TruAppEnvironment } from '../../../services/tru-app-environment';
|
|
3
|
+
import { TruUiNotification } from '../../../services/tru-ui-notification';
|
|
4
|
+
import { TruServerTouchTracker } from './tru-server-touch-tracker';
|
|
5
|
+
import { TruUserActivityTracker } from './tru-user-activity-tracker';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export declare class TruSessionExpiryMonitor {
|
|
8
|
+
private appEnvironment;
|
|
9
|
+
private serverTouchTracker;
|
|
10
|
+
private activityTracker;
|
|
11
|
+
private uiNotification;
|
|
12
|
+
private ngZone;
|
|
13
|
+
private static readonly MIN_WARNING_MS;
|
|
14
|
+
private static readonly MAX_WARNING_MS;
|
|
15
|
+
private static readonly WARN_ONLY_IF_IDLE_MS;
|
|
16
|
+
private isRunning;
|
|
17
|
+
private onExpired;
|
|
18
|
+
private subscriptions;
|
|
19
|
+
private warnTimeoutId;
|
|
20
|
+
private logoutTimeoutId;
|
|
21
|
+
private currentExpiresAtMs;
|
|
22
|
+
private warnedForExpiresAtMs;
|
|
23
|
+
private warningToastId;
|
|
24
|
+
private expiredToastId;
|
|
25
|
+
constructor(appEnvironment: TruAppEnvironment, serverTouchTracker: TruServerTouchTracker, activityTracker: TruUserActivityTracker, uiNotification: TruUiNotification, ngZone: NgZone);
|
|
26
|
+
start(onExpired: () => void): void;
|
|
27
|
+
stop(): void;
|
|
28
|
+
private scheduleFromRenewedAt;
|
|
29
|
+
private handleWarning;
|
|
30
|
+
private handleExpired;
|
|
31
|
+
private clearWarningToast;
|
|
32
|
+
private clearTimers;
|
|
33
|
+
private getTimeoutMs;
|
|
34
|
+
private getWarningLeadMs;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TruSessionExpiryMonitor, never>;
|
|
36
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TruSessionExpiryMonitor>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { NgZone } from '@angular/core';
|
|
3
|
+
import { TruAppEnvironment } from '../../../services/tru-app-environment';
|
|
4
|
+
import { TruServerTouchTracker } from './tru-server-touch-tracker';
|
|
5
|
+
import { TruUserActivityTracker } from './tru-user-activity-tracker';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export declare class TruSessionKeepalive {
|
|
8
|
+
private http;
|
|
9
|
+
private appEnvironment;
|
|
10
|
+
private serverTouchTracker;
|
|
11
|
+
private activityTracker;
|
|
12
|
+
private ngZone;
|
|
13
|
+
private static readonly ACTIVITY_WINDOW_CAP_MS;
|
|
14
|
+
private static readonly TICK_MS;
|
|
15
|
+
private static readonly KEEPALIVE_AFTER_FRACTION;
|
|
16
|
+
private static readonly MAX_JITTER_MS;
|
|
17
|
+
private static readonly KEEPALIVE_LOCK_TTL_MS;
|
|
18
|
+
private static readonly INITIAL_RETRY_DELAY_MS;
|
|
19
|
+
private static readonly MAX_RETRY_DELAY_MS;
|
|
20
|
+
private isRunning;
|
|
21
|
+
private stop$;
|
|
22
|
+
private subscriptions;
|
|
23
|
+
private readonly tabId;
|
|
24
|
+
private keepaliveLockHeld;
|
|
25
|
+
private lastSessionRenewedAtMs;
|
|
26
|
+
private nextAttemptAtMs;
|
|
27
|
+
private consecutiveFailures;
|
|
28
|
+
private requestInFlight;
|
|
29
|
+
constructor(http: HttpClient, appEnvironment: TruAppEnvironment, serverTouchTracker: TruServerTouchTracker, activityTracker: TruUserActivityTracker, ngZone: NgZone);
|
|
30
|
+
start(): void;
|
|
31
|
+
stop(): void;
|
|
32
|
+
private scheduleTicks;
|
|
33
|
+
private ping;
|
|
34
|
+
private tryAcquireKeepaliveLock;
|
|
35
|
+
private releaseKeepaliveLock;
|
|
36
|
+
private generateTabId;
|
|
37
|
+
private syncSessionRenewal;
|
|
38
|
+
private getKeepaliveAfterMs;
|
|
39
|
+
private getActivityWindowMs;
|
|
40
|
+
private getTimeoutMs;
|
|
41
|
+
private getRetryDelayMs;
|
|
42
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TruSessionKeepalive, never>;
|
|
43
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TruSessionKeepalive>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NgZone } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class TruUserActivityTracker {
|
|
5
|
+
private ngZone;
|
|
6
|
+
private static readonly THROTTLE_MS;
|
|
7
|
+
private lastActivityAtMs;
|
|
8
|
+
private readonly activitySubject;
|
|
9
|
+
constructor(ngZone: NgZone);
|
|
10
|
+
get lastActivity$(): Observable<number>;
|
|
11
|
+
getLastActivityAtMs(): number;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TruUserActivityTracker, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TruUserActivityTracker>;
|
|
14
|
+
}
|
|
@@ -15,6 +15,7 @@ export declare class TruAppEnvironment {
|
|
|
15
15
|
private _environmentWarning;
|
|
16
16
|
private _loginFormTitle;
|
|
17
17
|
private _authType;
|
|
18
|
+
private _authenticationTimeoutMinutes;
|
|
18
19
|
private _maxRecordCount;
|
|
19
20
|
private _isSaving;
|
|
20
21
|
private _saveComplete;
|
|
@@ -58,6 +59,8 @@ export declare class TruAppEnvironment {
|
|
|
58
59
|
set appUri(uri: string);
|
|
59
60
|
get authType(): 'session' | 'jwt';
|
|
60
61
|
set authType(type: 'session' | 'jwt');
|
|
62
|
+
get authenticationTimeoutMinutes(): number;
|
|
63
|
+
set authenticationTimeoutMinutes(minutes: number);
|
|
61
64
|
get isSaving(): boolean;
|
|
62
65
|
set isSaving(isSaving: boolean);
|
|
63
66
|
get maxRecordCount(): number;
|
|
@@ -4,6 +4,7 @@ import * as i0 from "@angular/core";
|
|
|
4
4
|
export declare class TruUiNotification {
|
|
5
5
|
private toastr;
|
|
6
6
|
private dialog;
|
|
7
|
+
private static readonly STICKY_TOAST_CONFIG;
|
|
7
8
|
private _toastr;
|
|
8
9
|
private _dialog;
|
|
9
10
|
constructor(toastr: ToastrService, dialog: MatDialog);
|
|
@@ -26,12 +27,16 @@ export declare class TruUiNotification {
|
|
|
26
27
|
* Same as error() but for warning message.
|
|
27
28
|
*/
|
|
28
29
|
warning: (message: string, detail?: Array<string> | null) => void;
|
|
30
|
+
warningSticky: (message: string, detail?: Array<string> | null) => number | null;
|
|
31
|
+
infoSticky: (message: string, detail?: Array<string> | null) => number | null;
|
|
32
|
+
clearToast: (toastId: number | null) => void;
|
|
29
33
|
log: (message: string) => void;
|
|
30
34
|
showErrorDialog: (title: string, message: string) => void;
|
|
31
35
|
showExportDialog: () => Promise<boolean>;
|
|
32
36
|
confirm: (title: string, message: string, displayCancelButton?: boolean, displayConfirmButton?: boolean, cancelButtonName?: string, confirmButtonName?: string) => Promise<boolean>;
|
|
33
37
|
changePassword: (userRef: number, username: string, admin?: boolean, entity?: any) => Promise<boolean>;
|
|
34
38
|
about: () => Promise<boolean>;
|
|
39
|
+
private showStickyMessage;
|
|
35
40
|
static ɵfac: i0.ɵɵFactoryDeclaration<TruUiNotification, never>;
|
|
36
41
|
static ɵprov: i0.ɵɵInjectableDeclaration<TruUiNotification>;
|
|
37
42
|
}
|