@rdlabo/ionic-angular-kit 21.4.4 → 21.4.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.
- package/README.md +132 -18
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +167 -21
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +371 -39
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +1 -1
- package/types/rdlabo-ionic-angular-kit-offline.d.ts +78 -26
- package/types/rdlabo-ionic-angular-kit.d.ts +147 -17
package/package.json
CHANGED
|
@@ -108,7 +108,8 @@ interface OfflineReplicaEntityDefinition<TSelect extends Record<string, unknown>
|
|
|
108
108
|
* Begins a type-safe replica entity schema definition for the given select shape.
|
|
109
109
|
*
|
|
110
110
|
* Every key in `TSelect` must appear exactly once in `fields`, and column nullability
|
|
111
|
-
* must match the select property nullability.
|
|
111
|
+
* must match the select property nullability. An entity may map at most one field with
|
|
112
|
+
* {@link serverId}; omit it for local-only projections that have no remote row identity.
|
|
112
113
|
*/
|
|
113
114
|
declare function defineReplicaEntity<TSelect extends Record<string, unknown>>(): <const TFields extends { readonly [K in keyof TSelect]: OfflineReplicaFieldDefForKey<TSelect, K>; }>(definition: OfflineReplicaEntityDefinition<TSelect, TFields>) => OfflineReplicaEntitySchema<TSelect>;
|
|
114
115
|
/** Maps a non-null string source property to a TEXT column. */
|
|
@@ -131,6 +132,8 @@ declare function nullable<TValue>(column: OfflineReplicaColumnDef<TValue, {
|
|
|
131
132
|
}>;
|
|
132
133
|
/** Maps a source property to the shared nullable `server_id` column. */
|
|
133
134
|
declare function serverId(): OfflineReplicaServerIdDef;
|
|
135
|
+
/** Rejects a remote identity on a local-only projection before it reaches platform storage. */
|
|
136
|
+
declare function assertOfflineReplicaServerId(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, value: number | null): void;
|
|
134
137
|
/** Excludes a source property from SQLite while retaining it in the select shape. */
|
|
135
138
|
declare function ignored(reason: string): OfflineReplicaIgnoredDef;
|
|
136
139
|
/**
|
|
@@ -394,6 +397,9 @@ interface OfflineSyncSession {
|
|
|
394
397
|
}
|
|
395
398
|
/** Product adapter that exposes the currently authenticated synchronization session. */
|
|
396
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. */
|
|
397
403
|
getSession(): Promise<OfflineSyncSession | null>;
|
|
398
404
|
}
|
|
399
405
|
/** DI token for authenticated synchronization context. */
|
|
@@ -408,6 +414,65 @@ declare const DEFAULT_OFFLINE_COMMAND_HOOKS: OfflineCommandHooks;
|
|
|
408
414
|
/** DI token for optional product-specific synchronization hooks. */
|
|
409
415
|
declare const OFFLINE_COMMAND_HOOKS: InjectionToken<OfflineCommandHooks>;
|
|
410
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
|
+
|
|
411
476
|
/** User choice when logout encounters unconfirmed local mutations. */
|
|
412
477
|
type OfflineLogoutAction = 'sync' | 'discard' | 'cancel';
|
|
413
478
|
/** Coordinates local persistence, session boundaries, network state, and outbox synchronization. */
|
|
@@ -419,6 +484,14 @@ declare class OfflineCoordinatorService {
|
|
|
419
484
|
readonly conflicts: i0.Signal<_rdlabo_ionic_angular_kit_offline.OfflineCommand<unknown>[]>;
|
|
420
485
|
initialize(): Promise<void>;
|
|
421
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>;
|
|
422
495
|
clearActiveSession(): Promise<void>;
|
|
423
496
|
prepareLogout(action: OfflineLogoutAction): Promise<boolean>;
|
|
424
497
|
flush(): Promise<void>;
|
|
@@ -586,29 +659,6 @@ interface ProvideOfflineOptions extends OfflineKitOptions {
|
|
|
586
659
|
*/
|
|
587
660
|
declare function provideOffline(options: ProvideOfflineOptions): EnvironmentProviders;
|
|
588
661
|
|
|
589
|
-
/** Persisted identity and group boundary for one authenticated local replica. */
|
|
590
|
-
interface OfflineSessionManifest {
|
|
591
|
-
userId: number;
|
|
592
|
-
scopeIds: number[];
|
|
593
|
-
/** Authentication-provider subject used to distinguish users on a shared device. */
|
|
594
|
-
authSubject: string | null;
|
|
595
|
-
updatedAt: number;
|
|
596
|
-
}
|
|
597
|
-
/** Owns activation and cleanup of the authenticated local-replica boundary. */
|
|
598
|
-
declare class OfflineSessionService {
|
|
599
|
-
#private;
|
|
600
|
-
readonly activeManifest: i0.Signal<OfflineSessionManifest | null>;
|
|
601
|
-
initialize(): Promise<void>;
|
|
602
|
-
activateSession(userId: number, scopeIds: readonly number[], authSubject: string | null): Promise<void>;
|
|
603
|
-
clearActiveSession(): Promise<void>;
|
|
604
|
-
getSession(): Promise<{
|
|
605
|
-
userId: number;
|
|
606
|
-
scopes: OfflineScope[];
|
|
607
|
-
} | null>;
|
|
608
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<OfflineSessionService, never>;
|
|
609
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<OfflineSessionService>;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
662
|
/** Aggregate synchronization state exposed to application UI. */
|
|
613
663
|
type OfflineSyncState = 'idle' | 'pending' | 'syncing' | 'attention';
|
|
614
664
|
/** Mutation and optimistic entity materialization appended atomically to the outbox. */
|
|
@@ -641,6 +691,8 @@ declare class OfflineSyncService {
|
|
|
641
691
|
noteScope(scope: OfflineScope): void;
|
|
642
692
|
reloadPendingCommands(): Promise<void>;
|
|
643
693
|
refreshSession(): Promise<void>;
|
|
694
|
+
/** Restores local outbox visibility without enabling pull or replay transport. */
|
|
695
|
+
refreshLocalSession(): Promise<void>;
|
|
644
696
|
resetSession(): Promise<void>;
|
|
645
697
|
enqueue<T>(request: EnqueueOfflineCommand<T>, options?: {
|
|
646
698
|
flush?: boolean;
|
|
@@ -664,5 +716,5 @@ declare class OfflineRequestFallbackService {
|
|
|
664
716
|
static ɵprov: i0.ɵɵInjectableDeclaration<OfflineRequestFallbackService>;
|
|
665
717
|
}
|
|
666
718
|
|
|
667
|
-
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, booleanColumn, createCommunitySqliteDriver, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, ignored, integer, isOfflineFallbackError, json, nullable, offlineInterceptor, projectOfflineReplicaValues, provideOffline, provideOfflineRequestPolicy, real, selectOfflineRepository, serverId, sha256OfflineReplicaSchema, text };
|
|
668
|
-
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 };
|
|
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 };
|
|
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,8 +2,8 @@ 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';
|
|
6
|
+
import { RouterStateSnapshot, UrlTree, CanActivateFn } from '@angular/router';
|
|
7
7
|
import { HttpRequest, HttpResponse, HttpErrorResponse, HttpEvent, HttpInterceptorFn } from '@angular/common/http';
|
|
8
8
|
import { ImpactStyle } from '@capacitor/haptics';
|
|
9
9
|
|
|
@@ -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
|
*
|
|
@@ -1062,6 +1176,16 @@ declare const isMaintenanceError: (error: HttpErrorResponse) => boolean;
|
|
|
1062
1176
|
* only the behavior that actually differs from the canonical baseline.
|
|
1063
1177
|
*/
|
|
1064
1178
|
interface KitHttpConfig {
|
|
1179
|
+
/**
|
|
1180
|
+
* Enforce the shared auth access mode before generating headers or using transport.
|
|
1181
|
+
*
|
|
1182
|
+
* @remarks
|
|
1183
|
+
* Optional and `false` by default for backward compatibility. In `local` mode the interceptor
|
|
1184
|
+
* consults `offlineFallback` without calling `getAuthHeaders` or transport. In `none` mode it
|
|
1185
|
+
* rejects without exposing local data. Real HTTP/auth-header 401/403 responses revoke access and
|
|
1186
|
+
* bypass `offlineFallback`.
|
|
1187
|
+
*/
|
|
1188
|
+
enforceAuthAccessMode?: boolean;
|
|
1065
1189
|
/**
|
|
1066
1190
|
* Produce authentication and metadata headers for the outgoing request.
|
|
1067
1191
|
*
|
|
@@ -1119,6 +1243,7 @@ interface KitHttpConfig {
|
|
|
1119
1243
|
* @remarks
|
|
1120
1244
|
* Returning a non-null observable replaces the error with that response (for example a queued
|
|
1121
1245
|
* offline result). Optional; defaults to `null` (no fallback, normal error handling proceeds).
|
|
1246
|
+
* With shared access enforcement enabled, explicit 401/403 denials are never passed here.
|
|
1122
1247
|
*
|
|
1123
1248
|
* @param request - The request that failed (after headers were applied).
|
|
1124
1249
|
* @param error - The error response that triggered the fallback.
|
|
@@ -1263,7 +1388,8 @@ declare const provideKitHttp: (configFactory: () => KitHttpConfig) => Environmen
|
|
|
1263
1388
|
* `Idempotency-Key`), and the status is a {@link RETRYABLE_STATUSES | transient status}. The
|
|
1264
1389
|
* backoff is `retryCount * 500ms` plus up to 250ms of jitter, or the server's `Retry-After`.
|
|
1265
1390
|
* When the device is offline it stops retrying immediately.
|
|
1266
|
-
* 5. On the final error,
|
|
1391
|
+
* 5. On the final error, enforced 401/403 revokes shared access and is rejected before fallback.
|
|
1392
|
+
* For every other error, `offlineFallback` is consulted first; otherwise the error is classified by
|
|
1267
1393
|
* status (see {@link dispatchError}): `401`→`onUnauthorized`, `403`→`onForbidden`, `0`→
|
|
1268
1394
|
* `onNetworkError` (when connected), `429`→`onRateLimited`, maintenance `503`→`onMaintenance`,
|
|
1269
1395
|
* other `502`/`503`/`504`→`onServerBusy`, and `400`/`422`/`500` with a body message→`onServerError`.
|
|
@@ -1301,6 +1427,8 @@ interface KitRealtimeConnectionOptions {
|
|
|
1301
1427
|
openTimeoutMs?: number;
|
|
1302
1428
|
pingIntervalMs?: number;
|
|
1303
1429
|
livenessTimeoutMs?: number;
|
|
1430
|
+
/** Require shared `remote` auth access before opening or retaining sockets. */
|
|
1431
|
+
requireRemoteAccess?: boolean;
|
|
1304
1432
|
}
|
|
1305
1433
|
/** Stable per-tab/application-run ID shared by realtime connections and write headers. */
|
|
1306
1434
|
declare const KIT_REALTIME_CLIENT_ID: `${string}-${string}-${string}-${string}-${string}`;
|
|
@@ -1333,8 +1461,10 @@ declare class KitRealtimeLivenessWatchdog {
|
|
|
1333
1461
|
*/
|
|
1334
1462
|
declare abstract class KitRealtimeConnection<TEvent extends KitRealtimeEvent> {
|
|
1335
1463
|
#private;
|
|
1464
|
+
private readonly authAccess;
|
|
1336
1465
|
/** Client ID used to classify self echoes. */
|
|
1337
1466
|
protected readonly listeners: PluginListenerHandle[];
|
|
1467
|
+
constructor(authAccess?: KitAuthAccessService | null);
|
|
1338
1468
|
/** All parsed events received by this connection. */
|
|
1339
1469
|
readonly events$: Observable<KitClientRealtimeEvent<TEvent>>;
|
|
1340
1470
|
/** Emits after every fully established connection cycle, including the first, prompting a REST resync. */
|
|
@@ -1379,7 +1509,7 @@ declare abstract class KitRealtimeConnection<TEvent extends KitRealtimeEvent> {
|
|
|
1379
1509
|
protected refreshConnectionTargets(): Promise<void>;
|
|
1380
1510
|
/** Open missing targets, preserving healthy sockets when another target fails. */
|
|
1381
1511
|
protected open(): Promise<void>;
|
|
1382
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<KitRealtimeConnection<any>,
|
|
1512
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KitRealtimeConnection<any>, [{ optional: true; }]>;
|
|
1383
1513
|
static ɵprov: i0.ɵɵInjectableDeclaration<KitRealtimeConnection<any>>;
|
|
1384
1514
|
}
|
|
1385
1515
|
|
|
@@ -1581,5 +1711,5 @@ type ComponentPropsType<T> = {
|
|
|
1581
1711
|
[K in keyof T]: InputSignal<T[K]> | InputSignalWithTransform<T[K], any>;
|
|
1582
1712
|
};
|
|
1583
1713
|
|
|
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 };
|
|
1714
|
+
export { 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 };
|
|
1715
|
+
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 };
|