@rdlabo/ionic-angular-kit 21.4.5 → 21.4.7
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/README.md +142 -18
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +152 -16
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +389 -43
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +1 -1
- package/types/rdlabo-ionic-angular-kit-offline.d.ts +73 -24
- package/types/rdlabo-ionic-angular-kit.d.ts +159 -18
package/package.json
CHANGED
|
@@ -397,6 +397,9 @@ interface OfflineSyncSession {
|
|
|
397
397
|
}
|
|
398
398
|
/** Product adapter that exposes the currently authenticated synchronization session. */
|
|
399
399
|
interface OfflineSyncContext {
|
|
400
|
+
/** Session allowed to read/write the local replica and append durable outbox commands. */
|
|
401
|
+
getLocalSession?(): Promise<OfflineSyncSession | null>;
|
|
402
|
+
/** Remotely authenticated session allowed to pull and replay commands. */
|
|
400
403
|
getSession(): Promise<OfflineSyncSession | null>;
|
|
401
404
|
}
|
|
402
405
|
/** DI token for authenticated synchronization context. */
|
|
@@ -411,6 +414,65 @@ declare const DEFAULT_OFFLINE_COMMAND_HOOKS: OfflineCommandHooks;
|
|
|
411
414
|
/** DI token for optional product-specific synchronization hooks. */
|
|
412
415
|
declare const OFFLINE_COMMAND_HOOKS: InjectionToken<OfflineCommandHooks>;
|
|
413
416
|
|
|
417
|
+
/** Persisted identity and group boundary for one authenticated local replica. */
|
|
418
|
+
interface OfflineSessionManifest {
|
|
419
|
+
userId: number;
|
|
420
|
+
scopeIds: number[];
|
|
421
|
+
/** Authentication-provider subject used to distinguish users on a shared device. */
|
|
422
|
+
authSubject: string | null;
|
|
423
|
+
updatedAt: number;
|
|
424
|
+
}
|
|
425
|
+
/** Structural lease used to reject stale asynchronous session commits. */
|
|
426
|
+
interface OfflineSessionTransitionLease {
|
|
427
|
+
isCurrent(): boolean;
|
|
428
|
+
}
|
|
429
|
+
/** Owns activation and cleanup of the authenticated local-replica boundary. */
|
|
430
|
+
declare class OfflineSessionService {
|
|
431
|
+
#private;
|
|
432
|
+
readonly activeManifest: i0.Signal<OfflineSessionManifest | null>;
|
|
433
|
+
initialize(): Promise<void>;
|
|
434
|
+
activateSession(userId: number, scopeIds: readonly number[], authSubject: string | null): Promise<void>;
|
|
435
|
+
activateSession(userId: number, scopeIds: readonly number[], authSubject: string | null, lease: OfflineSessionTransitionLease): Promise<boolean>;
|
|
436
|
+
clearActiveSession(): Promise<void>;
|
|
437
|
+
/** Disable remote pull/replay eligibility while retaining the verified local manifest. */
|
|
438
|
+
suspendRemoteSession(): Promise<void>;
|
|
439
|
+
/**
|
|
440
|
+
* Returns the persisted identity boundary for local-only route access.
|
|
441
|
+
*
|
|
442
|
+
* @remarks
|
|
443
|
+
* This does not activate the sync context. Call it only after the authentication authority has
|
|
444
|
+
* been classified as unavailable, never after explicit sign-out or HTTP 401/403. Legacy
|
|
445
|
+
* manifests without an authentication-provider subject are rejected.
|
|
446
|
+
*
|
|
447
|
+
* @param authSubject - A currently known provider subject. When supplied, it must match the
|
|
448
|
+
* persisted subject.
|
|
449
|
+
*/
|
|
450
|
+
getOfflineAccessManifest(authSubject?: string | null): Promise<OfflineSessionManifest | null>;
|
|
451
|
+
/**
|
|
452
|
+
* Activates a previously verified manifest for local replica and outbox access only.
|
|
453
|
+
*
|
|
454
|
+
* @remarks
|
|
455
|
+
* This never enables pull or command replay. A later successful remote authentication must call
|
|
456
|
+
* {@link activateSession} before synchronization can use transport.
|
|
457
|
+
*
|
|
458
|
+
* @param authSubject - A currently known provider subject. When supplied, it must match the
|
|
459
|
+
* persisted subject.
|
|
460
|
+
*/
|
|
461
|
+
activateOfflineSession(authSubject?: string | null, lease?: OfflineSessionTransitionLease): Promise<OfflineSessionManifest | null>;
|
|
462
|
+
/** Returns the session allowed to use the local replica and append outbox commands. */
|
|
463
|
+
getLocalSession(): Promise<{
|
|
464
|
+
userId: number;
|
|
465
|
+
scopes: OfflineScope[];
|
|
466
|
+
} | null>;
|
|
467
|
+
/** Returns the remotely authenticated session eligible for pull and command replay. */
|
|
468
|
+
getSession(): Promise<{
|
|
469
|
+
userId: number;
|
|
470
|
+
scopes: OfflineScope[];
|
|
471
|
+
} | null>;
|
|
472
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OfflineSessionService, never>;
|
|
473
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<OfflineSessionService>;
|
|
474
|
+
}
|
|
475
|
+
|
|
414
476
|
/** User choice when logout encounters unconfirmed local mutations. */
|
|
415
477
|
type OfflineLogoutAction = 'sync' | 'discard' | 'cancel';
|
|
416
478
|
/** Coordinates local persistence, session boundaries, network state, and outbox synchronization. */
|
|
@@ -422,6 +484,14 @@ declare class OfflineCoordinatorService {
|
|
|
422
484
|
readonly conflicts: i0.Signal<_rdlabo_ionic_angular_kit_offline.OfflineCommand<unknown>[]>;
|
|
423
485
|
initialize(): Promise<void>;
|
|
424
486
|
activateSession(userId: number, scopeIds: readonly number[], authSubject: string | null): Promise<void>;
|
|
487
|
+
/** Installs a remotely verified identity without starting pull or outbox replay. */
|
|
488
|
+
prepareRemoteSession(userId: number, scopeIds: readonly number[], authSubject: string | null, authLease?: OfflineSessionTransitionLease): Promise<boolean>;
|
|
489
|
+
/** Starts pull and outbox replay after the caller has published remote access. */
|
|
490
|
+
resumeRemoteSession(): Promise<void>;
|
|
491
|
+
/**
|
|
492
|
+
* Activates a restored identity for local replica/outbox use without enabling transport sync.
|
|
493
|
+
*/
|
|
494
|
+
activateOfflineSession(authSubject?: string | null, authLease?: OfflineSessionTransitionLease): Promise<OfflineSessionManifest | null>;
|
|
425
495
|
clearActiveSession(): Promise<void>;
|
|
426
496
|
prepareLogout(action: OfflineLogoutAction): Promise<boolean>;
|
|
427
497
|
flush(): Promise<void>;
|
|
@@ -589,29 +659,6 @@ interface ProvideOfflineOptions extends OfflineKitOptions {
|
|
|
589
659
|
*/
|
|
590
660
|
declare function provideOffline(options: ProvideOfflineOptions): EnvironmentProviders;
|
|
591
661
|
|
|
592
|
-
/** Persisted identity and group boundary for one authenticated local replica. */
|
|
593
|
-
interface OfflineSessionManifest {
|
|
594
|
-
userId: number;
|
|
595
|
-
scopeIds: number[];
|
|
596
|
-
/** Authentication-provider subject used to distinguish users on a shared device. */
|
|
597
|
-
authSubject: string | null;
|
|
598
|
-
updatedAt: number;
|
|
599
|
-
}
|
|
600
|
-
/** Owns activation and cleanup of the authenticated local-replica boundary. */
|
|
601
|
-
declare class OfflineSessionService {
|
|
602
|
-
#private;
|
|
603
|
-
readonly activeManifest: i0.Signal<OfflineSessionManifest | null>;
|
|
604
|
-
initialize(): Promise<void>;
|
|
605
|
-
activateSession(userId: number, scopeIds: readonly number[], authSubject: string | null): Promise<void>;
|
|
606
|
-
clearActiveSession(): Promise<void>;
|
|
607
|
-
getSession(): Promise<{
|
|
608
|
-
userId: number;
|
|
609
|
-
scopes: OfflineScope[];
|
|
610
|
-
} | null>;
|
|
611
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<OfflineSessionService, never>;
|
|
612
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<OfflineSessionService>;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
662
|
/** Aggregate synchronization state exposed to application UI. */
|
|
616
663
|
type OfflineSyncState = 'idle' | 'pending' | 'syncing' | 'attention';
|
|
617
664
|
/** Mutation and optimistic entity materialization appended atomically to the outbox. */
|
|
@@ -644,6 +691,8 @@ declare class OfflineSyncService {
|
|
|
644
691
|
noteScope(scope: OfflineScope): void;
|
|
645
692
|
reloadPendingCommands(): Promise<void>;
|
|
646
693
|
refreshSession(): Promise<void>;
|
|
694
|
+
/** Restores local outbox visibility without enabling pull or replay transport. */
|
|
695
|
+
refreshLocalSession(): Promise<void>;
|
|
647
696
|
resetSession(): Promise<void>;
|
|
648
697
|
enqueue<T>(request: EnqueueOfflineCommand<T>, options?: {
|
|
649
698
|
flush?: boolean;
|
|
@@ -668,4 +717,4 @@ declare class OfflineRequestFallbackService {
|
|
|
668
717
|
}
|
|
669
718
|
|
|
670
719
|
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_KIT_OPTIONS, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_HEADER, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCoordinatorService, OfflineNetworkService, OfflinePayloadValidationError, OfflineReplicaPullService, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineSyncService, SqliteOfflineRepository, assertOfflineReplicaServerId, booleanColumn, createCommunitySqliteDriver, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, ignored, integer, isOfflineFallbackError, json, nullable, offlineInterceptor, projectOfflineReplicaValues, provideOffline, provideOfflineRequestPolicy, real, selectOfflineRepository, serverId, sha256OfflineReplicaSchema, text };
|
|
671
|
-
export type { CommunitySqliteConnection, CommunitySqliteDatabase, CommunitySqliteDriver, EnqueueOfflineCommand, OfflineCommand, OfflineCommandExecutor, OfflineCommandHooks, OfflineCommandResult, OfflineCommandState, OfflineCommandTarget, OfflineKitOptions, OfflineLogoutAction, OfflineNetworkState, OfflineReadRequestPlan, OfflineReplicaChange, OfflineReplicaColumnDef, OfflineReplicaCursor, OfflineReplicaEntityDefinition, OfflineReplicaEntitySchema, OfflineReplicaEntityScope, OfflineReplicaFieldDescriptor, OfflineReplicaFieldPolicy, OfflineReplicaIgnoredDef, OfflineReplicaMigration, OfflineReplicaPullPage, OfflineReplicaPullRequest, OfflineReplicaPuller, OfflineReplicaRow, OfflineReplicaRowKey, OfflineReplicaSchemaBundle, OfflineReplicaSchemaDefinition, OfflineReplicaServerIdDef, OfflineReplicaSqliteAffinity, OfflineReplicaStorageKind, OfflineReplicaSyncState, OfflineReplicaTransaction, OfflineReplicaWebMigrationCallback, OfflineReplicaWebMigrationResult, OfflineReplicaWebMigrationRow, OfflineRepository, OfflineRequestPlan, OfflineRequestPolicy, OfflineResponseSource, OfflineScope, OfflineSessionManifest, OfflineSyncContext, OfflineSyncSession, OfflineSyncState, ProvideOfflineOptions };
|
|
720
|
+
export type { CommunitySqliteConnection, CommunitySqliteDatabase, CommunitySqliteDriver, EnqueueOfflineCommand, OfflineCommand, OfflineCommandExecutor, OfflineCommandHooks, OfflineCommandResult, OfflineCommandState, OfflineCommandTarget, OfflineKitOptions, OfflineLogoutAction, OfflineNetworkState, OfflineReadRequestPlan, OfflineReplicaChange, OfflineReplicaColumnDef, OfflineReplicaCursor, OfflineReplicaEntityDefinition, OfflineReplicaEntitySchema, OfflineReplicaEntityScope, OfflineReplicaFieldDescriptor, OfflineReplicaFieldPolicy, OfflineReplicaIgnoredDef, OfflineReplicaMigration, OfflineReplicaPullPage, OfflineReplicaPullRequest, OfflineReplicaPuller, OfflineReplicaRow, OfflineReplicaRowKey, OfflineReplicaSchemaBundle, OfflineReplicaSchemaDefinition, OfflineReplicaServerIdDef, OfflineReplicaSqliteAffinity, OfflineReplicaStorageKind, OfflineReplicaSyncState, OfflineReplicaTransaction, OfflineReplicaWebMigrationCallback, OfflineReplicaWebMigrationResult, OfflineReplicaWebMigrationRow, OfflineRepository, OfflineRequestPlan, OfflineRequestPolicy, OfflineResponseSource, OfflineScope, OfflineSessionManifest, OfflineSessionTransitionLease, OfflineSyncContext, OfflineSyncSession, OfflineSyncState, ProvideOfflineOptions };
|
|
@@ -2,9 +2,9 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, EnvironmentProviders, InputSignalWithTransform, OnInit, ElementRef, WritableSignal, InputSignal, Signal, OutputEmitterRef } from '@angular/core';
|
|
3
3
|
import { ModalOptions, PopoverOptions, ToastOptions, LoadingOptions, AlertController, ActionSheetController } from '@ionic/angular/standalone';
|
|
4
4
|
import { PluginListenerHandle } from '@capacitor/core';
|
|
5
|
-
import { RouterStateSnapshot, UrlTree, CanActivateFn } from '@angular/router';
|
|
6
5
|
import { Observable } from 'rxjs';
|
|
7
|
-
import {
|
|
6
|
+
import { RouterStateSnapshot, UrlTree, CanActivateFn } from '@angular/router';
|
|
7
|
+
import { HttpContextToken, HttpRequest, HttpResponse, HttpErrorResponse, HttpEvent, HttpInterceptorFn } from '@angular/common/http';
|
|
8
8
|
import { ImpactStyle } from '@capacitor/haptics';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -877,6 +877,88 @@ type KitKeyboardAdjust = 'transform' | 'offset' | 'keyboard-offset';
|
|
|
877
877
|
*/
|
|
878
878
|
declare const kitKeyboardInit: (elementRef: ElementRef, type: KitKeyboardAdjust) => Promise<PluginListenerHandle[]>;
|
|
879
879
|
|
|
880
|
+
/** Access level currently granted to the application runtime. */
|
|
881
|
+
type KitAuthAccessMode = 'none' | 'local' | 'remote';
|
|
882
|
+
/** Generation lease that becomes stale as soon as a newer access transition starts. */
|
|
883
|
+
interface KitAuthAccessLease {
|
|
884
|
+
/** Whether work owned by this transition may still publish or persist access. */
|
|
885
|
+
isCurrent(): boolean;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Result of remote reauthentication, split into ordered activation and resume phases.
|
|
889
|
+
*
|
|
890
|
+
* @remarks
|
|
891
|
+
* `activate` installs the remotely authenticated identity without starting transport. The kit then
|
|
892
|
+
* publishes `remote` access and invokes `resume`, which may start pull, outbox replay, and realtime
|
|
893
|
+
* work.
|
|
894
|
+
*/
|
|
895
|
+
interface KitRemoteAccessRecovery {
|
|
896
|
+
/**
|
|
897
|
+
* Install the remotely verified identity, checking the lease again immediately before commit.
|
|
898
|
+
*
|
|
899
|
+
* @returns `false` when a newer logout or identity transition superseded this activation.
|
|
900
|
+
*/
|
|
901
|
+
activate(lease: KitAuthAccessLease): Promise<boolean>;
|
|
902
|
+
resume(): Promise<void>;
|
|
903
|
+
}
|
|
904
|
+
/** Recovery-specific authentication configuration consumed by {@link KitAuthRecoveryService}. */
|
|
905
|
+
interface KitAuthRecoveryConfig {
|
|
906
|
+
/** Classifies transport unavailability; HTTP 401/403 are always denied before this callback. */
|
|
907
|
+
isUnavailableError?(error: unknown): boolean;
|
|
908
|
+
/** Optional online-recovery lifecycle used after local-only route access. */
|
|
909
|
+
remoteRecovery?: {
|
|
910
|
+
availability(): Observable<boolean>;
|
|
911
|
+
reauthenticate(lease: KitAuthAccessLease): Promise<KitRemoteAccessRecovery | false>;
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
/** Internal alias of the application auth config used without a module cycle. */
|
|
915
|
+
declare const KIT_AUTH_RECOVERY_CONFIG: InjectionToken<KitAuthRecoveryConfig>;
|
|
916
|
+
/** Shared runtime access state consumed by guards, UI, HTTP, and realtime connections. */
|
|
917
|
+
declare class KitAuthAccessService {
|
|
918
|
+
#private;
|
|
919
|
+
/** Emits the current access mode and every later transition. */
|
|
920
|
+
readonly mode$: Observable<KitAuthAccessMode>;
|
|
921
|
+
/** Current synchronous access mode. */
|
|
922
|
+
get mode(): KitAuthAccessMode;
|
|
923
|
+
/**
|
|
924
|
+
* Monotonic runtime revision used to invalidate an in-flight access transition.
|
|
925
|
+
*
|
|
926
|
+
* @internal
|
|
927
|
+
*/
|
|
928
|
+
get revision(): number;
|
|
929
|
+
/**
|
|
930
|
+
* Start a transition and invalidate every older asynchronous access decision.
|
|
931
|
+
*
|
|
932
|
+
* @param options - Set `suspendRemote` when the new decision must revoke published remote
|
|
933
|
+
* capabilities immediately while keeping this new lease valid.
|
|
934
|
+
*/
|
|
935
|
+
beginTransition(options?: {
|
|
936
|
+
suspendRemote?: boolean;
|
|
937
|
+
}): KitAuthAccessLease;
|
|
938
|
+
/** Revoke published capabilities without invalidating the transition that owns `lease`. */
|
|
939
|
+
suspend(lease: KitAuthAccessLease): boolean;
|
|
940
|
+
/** Publish a verified local-replica-only session. */
|
|
941
|
+
grantLocal(): void;
|
|
942
|
+
/** Publish a remotely authenticated session. */
|
|
943
|
+
grantRemote(): void;
|
|
944
|
+
/** Revoke both local and remote access. */
|
|
945
|
+
clear(): void;
|
|
946
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KitAuthAccessService, never>;
|
|
947
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<KitAuthAccessService>;
|
|
948
|
+
}
|
|
949
|
+
/** Coordinates single-flight recovery from local-only mode to remote access. */
|
|
950
|
+
declare class KitAuthRecoveryService {
|
|
951
|
+
#private;
|
|
952
|
+
/** Subscribe to the configured remote-availability stream once. */
|
|
953
|
+
initialize(): void;
|
|
954
|
+
/** Run one ordered remote recovery attempt, coalescing concurrent triggers. */
|
|
955
|
+
recover(): Promise<void>;
|
|
956
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KitAuthRecoveryService, never>;
|
|
957
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<KitAuthRecoveryService>;
|
|
958
|
+
}
|
|
959
|
+
/** Returns true for authoritative authentication denials that must never use local fallback. */
|
|
960
|
+
declare function isExplicitAuthDenial(error: unknown): boolean;
|
|
961
|
+
|
|
880
962
|
/**
|
|
881
963
|
* Discriminated set of authentication states the guards react to.
|
|
882
964
|
*
|
|
@@ -890,6 +972,15 @@ declare const kitKeyboardInit: (elementRef: ElementRef, type: KitKeyboardAdjust)
|
|
|
890
972
|
* - `anonymous` — signed in anonymously; the user can still be guided toward full registration.
|
|
891
973
|
*/
|
|
892
974
|
type KitAuthState = 'user' | 'confirm' | 'required' | 'anonymous';
|
|
975
|
+
/**
|
|
976
|
+
* Authentication states accepted by route guards.
|
|
977
|
+
*
|
|
978
|
+
* @remarks
|
|
979
|
+
* `unavailable` means the authentication authority cannot currently be reached; this is distinct
|
|
980
|
+
* from an explicit signed-out result. {@link KitAuthState} remains the original four-state union
|
|
981
|
+
* so existing exhaustive consumers remain source-compatible.
|
|
982
|
+
*/
|
|
983
|
+
type KitAuthGuardState = KitAuthState | 'unavailable';
|
|
893
984
|
/**
|
|
894
985
|
* Redirect targets (route paths) used by the guards when access is denied.
|
|
895
986
|
*
|
|
@@ -911,11 +1002,11 @@ interface KitAuthRedirects {
|
|
|
911
1002
|
* Configuration consumed by the authentication guards, injected through {@link provideKitAuth}.
|
|
912
1003
|
*
|
|
913
1004
|
* @remarks
|
|
914
|
-
* `authState` and `redirects` are required. The `onAuthorized
|
|
915
|
-
*
|
|
916
|
-
*
|
|
1005
|
+
* `authState` and `redirects` are required. The `onAuthorized`, `onUnauthenticated`, and
|
|
1006
|
+
* `onUnavailable` hooks are optional. Without them the guard allows an authenticated user and
|
|
1007
|
+
* redirects unauthenticated or unavailable states, so an app only supplies hooks with real logic.
|
|
917
1008
|
*/
|
|
918
|
-
interface KitAuthConfig {
|
|
1009
|
+
interface KitAuthConfig extends KitAuthRecoveryConfig {
|
|
919
1010
|
/**
|
|
920
1011
|
* Source of the current authentication state.
|
|
921
1012
|
*
|
|
@@ -924,7 +1015,7 @@ interface KitAuthConfig {
|
|
|
924
1015
|
*
|
|
925
1016
|
* @returns A stream of {@link KitAuthState} values.
|
|
926
1017
|
*/
|
|
927
|
-
authState(): Observable<
|
|
1018
|
+
authState(): Observable<KitAuthGuardState>;
|
|
928
1019
|
/**
|
|
929
1020
|
* Application-specific work that runs in {@link kitRequireAuthorizedGuard} after the state is confirmed to be `user`.
|
|
930
1021
|
*
|
|
@@ -933,9 +1024,11 @@ interface KitAuthConfig {
|
|
|
933
1024
|
* or restoring a previously requested redirect. Optional; defaults to `true` (allow activation).
|
|
934
1025
|
*
|
|
935
1026
|
* @param state - The router state snapshot of the route being activated.
|
|
936
|
-
* @
|
|
1027
|
+
* @param lease - Transition lease that product persistence must verify immediately before commit.
|
|
1028
|
+
* @returns `true` to allow activation, a `UrlTree` to perform a custom redirect, or a phased
|
|
1029
|
+
* remote activation that installs the session before transport work resumes.
|
|
937
1030
|
*/
|
|
938
|
-
onAuthorized?(state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
1031
|
+
onAuthorized?(state: RouterStateSnapshot, lease: KitAuthAccessLease): Promise<boolean | UrlTree | KitRemoteAccessRecovery>;
|
|
939
1032
|
/**
|
|
940
1033
|
* Fallback that runs in {@link kitRequireAuthorizedGuard} when the state is `required` (not authenticated).
|
|
941
1034
|
*
|
|
@@ -944,9 +1037,28 @@ interface KitAuthConfig {
|
|
|
944
1037
|
* (fall through to the default `whenUnauthorized` redirect).
|
|
945
1038
|
*
|
|
946
1039
|
* @param state - The router state snapshot of the route being activated.
|
|
947
|
-
* @
|
|
1040
|
+
* @param lease - Transition lease that product persistence must verify immediately before commit.
|
|
1041
|
+
* @returns `true` to allow activation, a `UrlTree` for a custom redirect, a phased remote
|
|
1042
|
+
* activation, or `false` to use the default redirect.
|
|
948
1043
|
*/
|
|
949
|
-
onUnauthenticated?(state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
1044
|
+
onUnauthenticated?(state: RouterStateSnapshot, lease: KitAuthAccessLease): Promise<boolean | UrlTree | KitRemoteAccessRecovery>;
|
|
1045
|
+
/**
|
|
1046
|
+
* Fallback that runs only when authentication is unavailable, never for an explicit
|
|
1047
|
+
* unauthenticated result.
|
|
1048
|
+
*
|
|
1049
|
+
* @remarks
|
|
1050
|
+
* This hook may authorize read/write access to a previously verified local replica. It must not
|
|
1051
|
+
* provide credentials to HTTP or realtime transports. Explicit sign-out and HTTP 401/403 must
|
|
1052
|
+
* remain unauthorized.
|
|
1053
|
+
*
|
|
1054
|
+
* @param state - The router state snapshot of the route being activated.
|
|
1055
|
+
* @param error - The classified transport error, or `undefined` when `authState` emitted
|
|
1056
|
+
* `unavailable`.
|
|
1057
|
+
* @param lease - Transition lease that local-session activation must verify before commit.
|
|
1058
|
+
* @returns `true` to allow local route activation, a `UrlTree` for a custom redirect, or `false`
|
|
1059
|
+
* to use the default redirect.
|
|
1060
|
+
*/
|
|
1061
|
+
onUnavailable?(state: RouterStateSnapshot, error: unknown | undefined, lease: KitAuthAccessLease): Promise<boolean | UrlTree>;
|
|
950
1062
|
/** Redirect targets used by the guards. */
|
|
951
1063
|
redirects: KitAuthRedirects;
|
|
952
1064
|
}
|
|
@@ -986,9 +1098,9 @@ declare const provideKitAuth: (configFactory: () => KitAuthConfig) => Environmen
|
|
|
986
1098
|
* Guard that requires the user to be unauthenticated (for example sign-in or sign-up pages).
|
|
987
1099
|
*
|
|
988
1100
|
* @remarks
|
|
989
|
-
* Allows the `required` and `
|
|
990
|
-
* registration page). An authenticated user (`user`) is sent to `whenAuthorized`, and
|
|
991
|
-
* awaiting confirmation (`confirm`) is sent to `whenConfirming`.
|
|
1101
|
+
* Allows the `required`, `anonymous`, and `unavailable` states (an anonymous user is permitted to
|
|
1102
|
+
* proceed to a registration page). An authenticated user (`user`) is sent to `whenAuthorized`, and
|
|
1103
|
+
* a user awaiting confirmation (`confirm`) is sent to `whenConfirming`.
|
|
992
1104
|
*
|
|
993
1105
|
* @returns A stream emitting `true` to allow activation, or `false` after triggering a redirect.
|
|
994
1106
|
*
|
|
@@ -1019,6 +1131,8 @@ declare const kitRequireConfirmingGuard: CanActivateFn;
|
|
|
1019
1131
|
* @remarks
|
|
1020
1132
|
* - `user` — runs {@link KitAuthConfig.onAuthorized} (token login, permission checks, and so on).
|
|
1021
1133
|
* - `anonymous` — allowed as-is, for applications that permit anonymous browsing.
|
|
1134
|
+
* - `unavailable` — runs {@link KitAuthConfig.onUnavailable}; this is the only state intended for
|
|
1135
|
+
* restored local-replica access.
|
|
1022
1136
|
* - `required` / `confirm` — runs {@link KitAuthConfig.onUnauthenticated}; if it resolves to `false`,
|
|
1023
1137
|
* the user is redirected to `whenUnauthorized`.
|
|
1024
1138
|
*
|
|
@@ -1033,6 +1147,17 @@ declare const kitRequireConfirmingGuard: CanActivateFn;
|
|
|
1033
1147
|
*/
|
|
1034
1148
|
declare const kitRequireAuthorizedGuard: CanActivateFn;
|
|
1035
1149
|
|
|
1150
|
+
/**
|
|
1151
|
+
* Marks the narrowly scoped credential-exchange request that establishes remote access.
|
|
1152
|
+
*
|
|
1153
|
+
* @remarks
|
|
1154
|
+
* When shared auth access enforcement is enabled, the application starts in `none` (or may be
|
|
1155
|
+
* recovering from `local`) and therefore cannot make ordinary authenticated requests. The one
|
|
1156
|
+
* server request that verifies the current provider credential must set this context token. It
|
|
1157
|
+
* still runs the complete header, retry, denial, and error pipeline; only the pre-existing
|
|
1158
|
+
* `remote` access requirement is deferred until that exchange succeeds.
|
|
1159
|
+
*/
|
|
1160
|
+
declare const KIT_AUTH_BOOTSTRAP_REQUEST: HttpContextToken<boolean>;
|
|
1036
1161
|
/**
|
|
1037
1162
|
* True when the error is the fleet maintenance short-circuit (`503` + body `code: 'MAINTENANCE'`).
|
|
1038
1163
|
*
|
|
@@ -1062,6 +1187,16 @@ declare const isMaintenanceError: (error: HttpErrorResponse) => boolean;
|
|
|
1062
1187
|
* only the behavior that actually differs from the canonical baseline.
|
|
1063
1188
|
*/
|
|
1064
1189
|
interface KitHttpConfig {
|
|
1190
|
+
/**
|
|
1191
|
+
* Enforce the shared auth access mode before generating headers or using transport.
|
|
1192
|
+
*
|
|
1193
|
+
* @remarks
|
|
1194
|
+
* Optional and `false` by default for backward compatibility. In `local` mode the interceptor
|
|
1195
|
+
* consults `offlineFallback` without calling `getAuthHeaders` or transport. In `none` mode it
|
|
1196
|
+
* rejects without exposing local data. Real HTTP/auth-header 401/403 responses revoke access and
|
|
1197
|
+
* bypass `offlineFallback`.
|
|
1198
|
+
*/
|
|
1199
|
+
enforceAuthAccessMode?: boolean;
|
|
1065
1200
|
/**
|
|
1066
1201
|
* Produce authentication and metadata headers for the outgoing request.
|
|
1067
1202
|
*
|
|
@@ -1119,6 +1254,7 @@ interface KitHttpConfig {
|
|
|
1119
1254
|
* @remarks
|
|
1120
1255
|
* Returning a non-null observable replaces the error with that response (for example a queued
|
|
1121
1256
|
* offline result). Optional; defaults to `null` (no fallback, normal error handling proceeds).
|
|
1257
|
+
* With shared access enforcement enabled, explicit 401/403 denials are never passed here.
|
|
1122
1258
|
*
|
|
1123
1259
|
* @param request - The request that failed (after headers were applied).
|
|
1124
1260
|
* @param error - The error response that triggered the fallback.
|
|
@@ -1263,7 +1399,8 @@ declare const provideKitHttp: (configFactory: () => KitHttpConfig) => Environmen
|
|
|
1263
1399
|
* `Idempotency-Key`), and the status is a {@link RETRYABLE_STATUSES | transient status}. The
|
|
1264
1400
|
* backoff is `retryCount * 500ms` plus up to 250ms of jitter, or the server's `Retry-After`.
|
|
1265
1401
|
* When the device is offline it stops retrying immediately.
|
|
1266
|
-
* 5. On the final error,
|
|
1402
|
+
* 5. On the final error, enforced 401/403 revokes shared access and is rejected before fallback.
|
|
1403
|
+
* For every other error, `offlineFallback` is consulted first; otherwise the error is classified by
|
|
1267
1404
|
* status (see {@link dispatchError}): `401`→`onUnauthorized`, `403`→`onForbidden`, `0`→
|
|
1268
1405
|
* `onNetworkError` (when connected), `429`→`onRateLimited`, maintenance `503`→`onMaintenance`,
|
|
1269
1406
|
* other `502`/`503`/`504`→`onServerBusy`, and `400`/`422`/`500` with a body message→`onServerError`.
|
|
@@ -1301,6 +1438,8 @@ interface KitRealtimeConnectionOptions {
|
|
|
1301
1438
|
openTimeoutMs?: number;
|
|
1302
1439
|
pingIntervalMs?: number;
|
|
1303
1440
|
livenessTimeoutMs?: number;
|
|
1441
|
+
/** Require shared `remote` auth access before opening or retaining sockets. */
|
|
1442
|
+
requireRemoteAccess?: boolean;
|
|
1304
1443
|
}
|
|
1305
1444
|
/** Stable per-tab/application-run ID shared by realtime connections and write headers. */
|
|
1306
1445
|
declare const KIT_REALTIME_CLIENT_ID: `${string}-${string}-${string}-${string}-${string}`;
|
|
@@ -1333,8 +1472,10 @@ declare class KitRealtimeLivenessWatchdog {
|
|
|
1333
1472
|
*/
|
|
1334
1473
|
declare abstract class KitRealtimeConnection<TEvent extends KitRealtimeEvent> {
|
|
1335
1474
|
#private;
|
|
1475
|
+
private readonly authAccess;
|
|
1336
1476
|
/** Client ID used to classify self echoes. */
|
|
1337
1477
|
protected readonly listeners: PluginListenerHandle[];
|
|
1478
|
+
constructor(authAccess?: KitAuthAccessService | null);
|
|
1338
1479
|
/** All parsed events received by this connection. */
|
|
1339
1480
|
readonly events$: Observable<KitClientRealtimeEvent<TEvent>>;
|
|
1340
1481
|
/** Emits after every fully established connection cycle, including the first, prompting a REST resync. */
|
|
@@ -1379,7 +1520,7 @@ declare abstract class KitRealtimeConnection<TEvent extends KitRealtimeEvent> {
|
|
|
1379
1520
|
protected refreshConnectionTargets(): Promise<void>;
|
|
1380
1521
|
/** Open missing targets, preserving healthy sockets when another target fails. */
|
|
1381
1522
|
protected open(): Promise<void>;
|
|
1382
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<KitRealtimeConnection<any>,
|
|
1523
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KitRealtimeConnection<any>, [{ optional: true; }]>;
|
|
1383
1524
|
static ɵprov: i0.ɵɵInjectableDeclaration<KitRealtimeConnection<any>>;
|
|
1384
1525
|
}
|
|
1385
1526
|
|
|
@@ -1581,5 +1722,5 @@ type ComponentPropsType<T> = {
|
|
|
1581
1722
|
[K in keyof T]: InputSignal<T[K]> | InputSignalWithTransform<T[K], any>;
|
|
1582
1723
|
};
|
|
1583
1724
|
|
|
1584
|
-
export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_REALTIME_CLIENT_ID, KIT_THEME_STORAGE_KEY, KitAuthInputDirective, KitLoadingController, KitMaintenanceController, KitOverlayController, KitRealtimeConnection, KitRealtimeLivenessWatchdog, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRealtimeProtocols, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
|
|
1585
|
-
export type { ComponentPropsType, KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitClearableStore, KitClientRealtimeEvent, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitRealtimeConnectionOptions, KitRealtimeEvent, KitRealtimeSocketTarget, KitReloadAlertOptions, ModalMetadata, ReactiveHost, ViewModelHost };
|
|
1725
|
+
export { KIT_AUTH_BOOTSTRAP_REQUEST, KIT_AUTH_CONFIG, KIT_AUTH_RECOVERY_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_REALTIME_CLIENT_ID, KIT_THEME_STORAGE_KEY, KitAuthAccessService, KitAuthInputDirective, KitAuthRecoveryService, KitLoadingController, KitMaintenanceController, KitOverlayController, KitRealtimeConnection, KitRealtimeLivenessWatchdog, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, isExplicitAuthDenial, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRealtimeProtocols, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
|
|
1726
|
+
export type { ComponentPropsType, KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthAccessLease, KitAuthAccessMode, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthGuardState, KitAuthInputMode, KitAuthRecoveryConfig, KitAuthRedirects, KitAuthState, KitClearableStore, KitClientRealtimeEvent, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitRealtimeConnectionOptions, KitRealtimeEvent, KitRealtimeSocketTarget, KitReloadAlertOptions, KitRemoteAccessRecovery, ModalMetadata, ReactiveHost, ViewModelHost };
|