@smartbit4all/ng-client 4.5.9 → 4.5.10
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/esm2022/lib/session/smart-backend-bootstrap.config.mjs +1 -1
- package/esm2022/lib/session/smart-backend-bootstrap.service.mjs +26 -2
- package/esm2022/lib/session/smart-error-catching.interceptor.mjs +7 -7
- package/esm2022/lib/session/smart-session.service.mjs +15 -2
- package/fesm2022/smartbit4all-ng-client.mjs +44 -7
- package/fesm2022/smartbit4all-ng-client.mjs.map +1 -1
- package/lib/session/smart-backend-bootstrap.config.d.ts +21 -0
- package/lib/session/smart-backend-bootstrap.service.d.ts +9 -0
- package/lib/session/smart-error-catching.interceptor.d.ts +3 -3
- package/lib/session/smart-session.service.d.ts +7 -1
- package/package.json +1 -1
- package/smartbit4all-ng-client-4.5.10.tgz +0 -0
- package/smartbit4all-ng-client-4.5.9.tgz +0 -0
|
@@ -12,6 +12,13 @@ export interface SmartBackendBootstrapCredentials {
|
|
|
12
12
|
sessionToken: string;
|
|
13
13
|
/** UUID of an already-existing viewContext on the backend. */
|
|
14
14
|
viewContextUuid: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional long-lived refresh token paired with the SID. If provided, it is
|
|
17
|
+
* persisted to localStorage so the autonomous `SmartErrorCatchingInterceptor`
|
|
18
|
+
* REFRESH flow can recover from `session.expired` errors without dropping
|
|
19
|
+
* the user back to a fresh anonymous session.
|
|
20
|
+
*/
|
|
21
|
+
refreshToken?: string;
|
|
15
22
|
}
|
|
16
23
|
export interface SmartBackendBootstrapConfig {
|
|
17
24
|
url: string;
|
|
@@ -25,4 +32,18 @@ export interface SmartBackendBootstrapConfig {
|
|
|
25
32
|
onSmartLink?: (channel: string) => Promise<void> | void;
|
|
26
33
|
/** Hook for host UX when `start()` rejects (snackbar + retry). */
|
|
27
34
|
onStartError?: (err: unknown) => Promise<void> | void;
|
|
35
|
+
/**
|
|
36
|
+
* Hook called when the backend reports the current viewContext is gone
|
|
37
|
+
* (logout, session expiry, backend restart) — i.e. when the
|
|
38
|
+
* `SmartErrorCatchingInterceptor` would historically auto-trigger
|
|
39
|
+
* `RESTART_VIEWCONTEXT`.
|
|
40
|
+
*
|
|
41
|
+
* Default: rebuilds a fresh anonymous viewContext via
|
|
42
|
+
* `viewContext.initNewViewContext()` (the historical web flow).
|
|
43
|
+
*
|
|
44
|
+
* Mobile/embedded hosts override this to fully delegate to the shell —
|
|
45
|
+
* typically by calling a JS bridge that signals the native side to
|
|
46
|
+
* tear down the webview and return to the native login page.
|
|
47
|
+
*/
|
|
48
|
+
onViewContextLost?: (err: SessionError) => Promise<void> | void;
|
|
28
49
|
}
|
|
@@ -10,6 +10,7 @@ export declare class SmartBackendBootstrapService implements SmartSessionHandler
|
|
|
10
10
|
private runningInit?;
|
|
11
11
|
private lastInitFailed;
|
|
12
12
|
private mode?;
|
|
13
|
+
private runningViewContextLost?;
|
|
13
14
|
constructor(session: SmartSessionService, viewContext: SmartViewContextService);
|
|
14
15
|
configure(config: SmartBackendBootstrapConfig): void;
|
|
15
16
|
private handleSmartLink;
|
|
@@ -17,6 +18,14 @@ export declare class SmartBackendBootstrapService implements SmartSessionHandler
|
|
|
17
18
|
bootstrapWith(creds: SmartBackendBootstrapCredentials): Promise<void>;
|
|
18
19
|
whenReady(): Promise<void>;
|
|
19
20
|
reset(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Called by `SmartErrorCatchingInterceptor` when the backend reports
|
|
23
|
+
* `session.viewcontext.missing`. Idempotent across concurrent and
|
|
24
|
+
* sequential calls until the next `reset()` — multiple racing BFF
|
|
25
|
+
* failures collapse into a single recovery attempt.
|
|
26
|
+
*/
|
|
27
|
+
handleViewContextLost(err: SessionError): Promise<void>;
|
|
28
|
+
private runViewContextLost;
|
|
20
29
|
private runInit;
|
|
21
30
|
private runBootstrapWith;
|
|
22
31
|
private handleInitFailure;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { SessionError, SmartSessionService } from './projects';
|
|
4
|
-
import {
|
|
4
|
+
import { SmartBackendBootstrapService } from './smart-backend-bootstrap.service';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
export declare class SmartErrorCatchingInterceptor implements HttpInterceptor {
|
|
7
7
|
private session;
|
|
8
|
-
private
|
|
8
|
+
private bootstrap;
|
|
9
9
|
sessionErrorCodes: SessionError[];
|
|
10
|
-
constructor(session: SmartSessionService,
|
|
10
|
+
constructor(session: SmartSessionService, bootstrap: SmartBackendBootstrapService);
|
|
11
11
|
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
|
|
12
12
|
private handleError;
|
|
13
13
|
private isSessionError;
|
|
@@ -38,8 +38,14 @@ export declare class SmartSessionService implements OnDestroy {
|
|
|
38
38
|
* `initialize()`'s backend round-trip. Used by the
|
|
39
39
|
* `SmartBackendBootstrapService.bootstrapWith()` flow when a host
|
|
40
40
|
* (e.g. native mobile shell) hands over an already-authenticated session.
|
|
41
|
+
*
|
|
42
|
+
* Persists the SID to localStorage + cookie so that a page reload can
|
|
43
|
+
* rehydrate the session through `initialize()`'s regular
|
|
44
|
+
* `tokenFromLocalStorage === tokenFromCookies` path. The optional
|
|
45
|
+
* refreshToken is persisted to enable autonomous refresh via
|
|
46
|
+
* `refreshSession()` when the SID expires.
|
|
41
47
|
*/
|
|
42
|
-
setSessionToken(token: string): void;
|
|
48
|
+
setSessionToken(token: string, refreshToken?: string): void;
|
|
43
49
|
setUrl(url: string): void;
|
|
44
50
|
getBasePath(): string;
|
|
45
51
|
setCookieName(name: string): void;
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|