@smartbit4all/ng-client 4.5.9 → 4.5.11

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.
@@ -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 { SmartViewContextService } from '../view-context/smart-view-context.service';
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 viewcontext;
8
+ private bootstrap;
9
9
  sessionErrorCodes: SessionError[];
10
- constructor(session: SmartSessionService, viewcontext: SmartViewContextService);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartbit4all/ng-client",
3
- "version": "4.5.9",
3
+ "version": "4.5.11",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
6
6
  "@angular/common": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
Binary file