@securitydept/client 0.3.0-beta.3 → 0.3.0-beta.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 +6 -0
- package/dist/create-99Ksgl_O.mjs +952 -0
- package/dist/create-99Ksgl_O.mjs.map +1 -0
- package/dist/handle-TnxwtQ4T.mjs +634 -0
- package/dist/handle-TnxwtQ4T.mjs.map +1 -0
- package/dist/index-Cg_iY2yY.d.mts +608 -0
- package/dist/index-DmIapvr-.d.mts +1669 -0
- package/dist/index-O1A3CdBV.d.mts +119 -0
- package/dist/index.d.mts +3 -353
- package/dist/index.mjs +1127 -364
- package/dist/index.mjs.map +1 -1
- package/dist/router-DUh3bhLy.mjs +245 -0
- package/dist/router-DUh3bhLy.mjs.map +1 -0
- package/dist/rx/index.d.mts +68 -0
- package/dist/rx/index.mjs +2 -0
- package/dist/rx-B3OU17wu.mjs +1105 -0
- package/dist/rx-B3OU17wu.mjs.map +1 -0
- package/dist/server/index.d.mts +20 -0
- package/dist/server/index.mjs +29 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/test/index.d.mts +101 -0
- package/dist/test/index.mjs +270 -0
- package/dist/test/index.mjs.map +1 -0
- package/dist/uri-string-BPNbIMgv.mjs +300 -0
- package/dist/uri-string-BPNbIMgv.mjs.map +1 -0
- package/dist/web/index.d.mts +93 -363
- package/dist/web/index.mjs +335 -428
- package/dist/web/index.mjs.map +1 -1
- package/dist/webext/index.d.mts +73 -0
- package/dist/webext/index.mjs +231 -0
- package/dist/webext/index.mjs.map +1 -0
- package/package.json +28 -21
- package/dist/auth-coordination/index.d.mts +0 -198
- package/dist/auth-coordination/index.mjs +0 -107
- package/dist/auth-coordination/index.mjs.map +0 -1
- package/dist/client-environment-CaumNmir.mjs +0 -812
- package/dist/client-environment-CaumNmir.mjs.map +0 -1
- package/dist/client-environment-CdHtVxKW.d.mts +0 -401
- package/dist/events/index.d.mts +0 -2
- package/dist/events/index.mjs +0 -2
- package/dist/events-BUlfsRfl.mjs +0 -127
- package/dist/events-BUlfsRfl.mjs.map +0 -1
- package/dist/index-C4xlKhG7.d.mts +0 -102
- package/dist/index-COUt5x9Z.d.mts +0 -39
- package/dist/persistence/index.d.mts +0 -3
- package/dist/persistence/index.mjs +0 -2
- package/dist/persistence/web/index.d.mts +0 -16
- package/dist/persistence/web/index.mjs +0 -2
- package/dist/persistence-CSB8770k.mjs +0 -108
- package/dist/persistence-CSB8770k.mjs.map +0 -1
- package/dist/planner-host-BTWie0lo.mjs +0 -197
- package/dist/planner-host-BTWie0lo.mjs.map +0 -1
- package/dist/planner-host-DN9dRsQx.d.mts +0 -190
- package/dist/types-BJqUdH2e.d.mts +0 -32
- package/dist/types-BwcnUGNl.d.mts +0 -52
- package/dist/web-DQmMqZnR.mjs +0 -51
- package/dist/web-DQmMqZnR.mjs.map +0 -1
- package/dist/web-router/index.d.mts +0 -259
- package/dist/web-router/index.mjs +0 -395
- package/dist/web-router/index.mjs.map +0 -1
package/dist/web/index.d.mts
CHANGED
|
@@ -1,52 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { T as TimeTrait, qt as WithTraitDeps, st as EventStreamTrait } from "../index-Cg_iY2yY.mjs";
|
|
2
|
+
import { Er as PopupTrait, Ft as CreateFoundationEnvironmentOptions, Hn as RouterTrait, On as WithTraitInputValidator, Rt as EnvironmentValidators, sn as SyncStorageTrait, zt as FoundationEnvironment } from "../index-DmIapvr-.mjs";
|
|
3
|
+
import { _ as createPageResumeSource, a as NativeWebWindowLike, c as WebNavigationRouter, d as createPageLifecycleForNativeWeb, f as CreatePageResumeSourceOptions, g as PageResumeWindowTarget, h as PageResumeTriggerKind, i as NativeWebRouter, l as createRouterForNativeWeb, m as PageResumeEvent, n as NativeWebLocationLike, o as RouterForNativeWebCreateOptions, p as PageResumeDocumentTarget, r as NativeWebNavigationLike, s as WebLegacyRouter, t as NativeWebHistoryLike, u as PageLifecycleForNativeWebCreateOptions } from "../index-O1A3CdBV.mjs";
|
|
4
|
+
//#region src/web/events/from-storage.d.ts
|
|
5
|
+
interface StorageEventTarget {
|
|
6
|
+
addEventListener(type: "storage", listener: EventListener): void;
|
|
7
|
+
removeEventListener(type: "storage", listener: EventListener): void;
|
|
8
|
+
}
|
|
9
|
+
interface FromStorageEventOptions {
|
|
10
|
+
storageEventTarget: StorageEventTarget;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* This is the canonical consumer-side path for browser hosts that receive an
|
|
12
|
-
* `AbortSignal` from framework/runtime APIs (for example React Query queryFns)
|
|
13
|
-
* but need to call SDK surfaces that accept `CancellationTokenTrait`.
|
|
14
|
-
*/
|
|
15
|
-
declare function createCancellationTokenFromAbortSignal(signal?: AbortSignal): CancellationTokenTrait | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Bridge foundation cancellation to web `AbortSignal` without exposing
|
|
18
|
-
* `AbortSignal` in core contracts.
|
|
13
|
+
* Adapt browser `storage` events into an event stream.
|
|
19
14
|
*/
|
|
20
|
-
declare function
|
|
21
|
-
|
|
15
|
+
declare function fromStorageEvent(options: FromStorageEventOptions): EventStreamTrait<StorageEvent>;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/web/popup.d.ts
|
|
18
|
+
interface PopupForNativeWebCreateOptions {
|
|
19
|
+
window?: unknown;
|
|
20
|
+
}
|
|
21
|
+
interface PopupFeaturesOptions {
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
}
|
|
25
|
+
interface NativeWebPopupWindowLike {
|
|
26
|
+
closed: boolean;
|
|
27
|
+
close(): void;
|
|
28
|
+
postMessage(message: unknown, targetOrigin: string): void;
|
|
29
|
+
}
|
|
30
|
+
interface NativeWebWindowLike$1 {
|
|
31
|
+
open(url: string, target?: string, features?: string): NativeWebPopupWindowLike | null;
|
|
32
|
+
addEventListener(type: "message", handler: (event: MessageEvent) => void): void;
|
|
33
|
+
removeEventListener(type: "message", handler: (event: MessageEvent) => void): void;
|
|
34
|
+
location?: {
|
|
35
|
+
href?: string;
|
|
36
|
+
origin?: string;
|
|
37
|
+
};
|
|
38
|
+
screenX?: number;
|
|
39
|
+
screenY?: number;
|
|
40
|
+
innerWidth?: number;
|
|
41
|
+
innerHeight?: number;
|
|
42
|
+
close?(): void;
|
|
43
|
+
opener?: {
|
|
44
|
+
postMessage(message: unknown, targetOrigin: string): void;
|
|
45
|
+
} | null;
|
|
46
|
+
}
|
|
47
|
+
declare function createPopupForNativeWeb(options: PopupForNativeWebCreateOptions & WithTraitInputValidator<Pick<EnvironmentValidators, "popup">> & WithTraitDeps<{
|
|
48
|
+
time: TimeTrait;
|
|
49
|
+
}>): PopupTrait | null;
|
|
50
|
+
declare function computePopupFeatures(options?: PopupFeaturesOptions, windowLike?: Pick<NativeWebWindowLike$1, "screenX" | "screenY" | "innerWidth" | "innerHeight">): string;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/web/storage.d.ts
|
|
53
|
+
interface NativeWebStorageLike {
|
|
54
|
+
getItem(key: string): string | null;
|
|
55
|
+
setItem(key: string, value: string): void;
|
|
56
|
+
removeItem(key: string): void;
|
|
57
|
+
}
|
|
58
|
+
interface StorageForNativeWebCreateOptions {
|
|
59
|
+
storage?: NativeWebStorageLike | null;
|
|
60
|
+
storageEventTarget?: StorageEventTarget | null;
|
|
61
|
+
prefix?: string;
|
|
62
|
+
validatorKey: "persistentStorage" | "sessionStorage";
|
|
63
|
+
}
|
|
64
|
+
declare function createStorageForNativeWeb(options: StorageForNativeWebCreateOptions & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
|
|
65
|
+
declare function createPersistentStorageForNativeWeb(options: Omit<StorageForNativeWebCreateOptions, "validatorKey"> & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
|
|
66
|
+
declare function createSessionStorageForNativeWeb(options: Omit<StorageForNativeWebCreateOptions, "validatorKey"> & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
|
|
22
67
|
//#endregion
|
|
23
|
-
//#region src/web/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
68
|
+
//#region src/web/environment.d.ts
|
|
69
|
+
interface NativeWebEnvironment extends FoundationEnvironment {
|
|
70
|
+
router: RouterTrait;
|
|
71
|
+
}
|
|
72
|
+
interface CreateEnvironmentForNativeWebOptions extends CreateFoundationEnvironmentOptions {
|
|
73
|
+
routerForNativeWebCreateOptions?: RouterForNativeWebCreateOptions;
|
|
74
|
+
pageLifecycleForNativeWebCreateOptions?: PageLifecycleForNativeWebCreateOptions;
|
|
75
|
+
popupForNativeWebCreateOptions?: PopupForNativeWebCreateOptions;
|
|
76
|
+
persistentStorageForNativeWebCreateOptions?: Omit<StorageForNativeWebCreateOptions, "validatorKey">;
|
|
77
|
+
sessionStorageForNativeWebCreateOptions?: Omit<StorageForNativeWebCreateOptions, "validatorKey">;
|
|
78
|
+
}
|
|
79
|
+
declare function createEnvironmentForNativeWeb(options: CreateEnvironmentForNativeWebOptions): NativeWebEnvironment;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/web/sync/cross-tab-sync.d.ts
|
|
82
|
+
/** Event emitted when a cross-tab storage change is detected for the watched key. */
|
|
83
|
+
interface CrossTabSyncEvent {
|
|
84
|
+
/** The new value written by the other tab, or null if the key was removed. */
|
|
85
|
+
newValue: string | null;
|
|
86
|
+
/** The old value before the other tab's write. */
|
|
27
87
|
oldValue: string | null;
|
|
28
|
-
}
|
|
88
|
+
}
|
|
29
89
|
/** Options for {@link createCrossTabSync}. */
|
|
30
90
|
interface CreateCrossTabSyncOptions {
|
|
31
91
|
/** The localStorage key to watch for cross-tab changes. */
|
|
32
92
|
key: string;
|
|
33
|
-
|
|
34
|
-
onSync: CrossTabSyncCallback;
|
|
35
|
-
/**
|
|
36
|
-
* Override the window target (primarily for testing).
|
|
37
|
-
* Defaults to `globalThis`.
|
|
38
|
-
*/
|
|
39
|
-
target?: {
|
|
40
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
41
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/** Handle returned by {@link createCrossTabSync}. */
|
|
45
|
-
interface CrossTabSync {
|
|
46
|
-
/** Stop listening for cross-tab storage events. */
|
|
47
|
-
dispose(): void;
|
|
48
|
-
/** Number of times a sync event has been received. */
|
|
49
|
-
readonly syncCount: number;
|
|
93
|
+
storageEventTarget: StorageEventTarget;
|
|
50
94
|
}
|
|
51
95
|
/**
|
|
52
96
|
* Create a cross-tab sync listener for a specific localStorage key.
|
|
@@ -56,339 +100,25 @@ interface CrossTabSync {
|
|
|
56
100
|
*
|
|
57
101
|
* @example
|
|
58
102
|
* ```ts
|
|
59
|
-
* const
|
|
103
|
+
* const subscription = createCrossTabSync({
|
|
60
104
|
* key: "auth:v1",
|
|
61
|
-
*
|
|
105
|
+
* storageEventTarget: window,
|
|
106
|
+
* }).subscribe({
|
|
107
|
+
* next: ({ newValue }) => {
|
|
62
108
|
* if (newValue) {
|
|
63
109
|
* // Another tab updated auth state — reconcile
|
|
64
|
-
*
|
|
110
|
+
* client.restorePersistedState();
|
|
65
111
|
* } else {
|
|
66
112
|
* // Another tab cleared auth state — log out
|
|
67
|
-
* controller.clearState({
|
|
68
|
-
* }
|
|
69
|
-
* },
|
|
70
|
-
* });
|
|
71
|
-
* // Later:
|
|
72
|
-
* sync.dispose();
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
declare function createCrossTabSync(options: CreateCrossTabSyncOptions): CrossTabSync;
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/web/environment-service.d.ts
|
|
78
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
79
|
-
interface ClientEnvironmentServiceOptions<TClientEnvironment extends ClientEnvironment = ClientEnvironment, TWebEnvironment extends WebClientEnvironment = WebClientEnvironment, TPageEnvironment extends PageClientEnvironment = PageClientEnvironment> {
|
|
80
|
-
createClientEnvironment?: () => MaybePromise<TClientEnvironment>;
|
|
81
|
-
createWebEnvironment?: (clientEnvironment: TClientEnvironment) => MaybePromise<TWebEnvironment>;
|
|
82
|
-
createPageEnvironment?: (webEnvironment: TWebEnvironment) => MaybePromise<TPageEnvironment>;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Framework-neutral environment resolver with layered lazy materialization.
|
|
86
|
-
*
|
|
87
|
-
* `resolve*()` coalesces concurrent work into a single pending promise.
|
|
88
|
-
* `read*()` is Suspense-compatible: pending resolutions throw the same promise,
|
|
89
|
-
* rejections throw the cached error, and fulfilled layers return the value.
|
|
90
|
-
*
|
|
91
|
-
* `reset()` invalidates all cached layers. In-flight promises may still settle
|
|
92
|
-
* for existing awaiters, but their results are discarded and never repopulate
|
|
93
|
-
* the service cache after a reset.
|
|
94
|
-
*/
|
|
95
|
-
declare class ClientEnvironmentService<TClientEnvironment extends ClientEnvironment = ClientEnvironment, TWebEnvironment extends WebClientEnvironment = WebClientEnvironment, TPageEnvironment extends PageClientEnvironment = PageClientEnvironment> {
|
|
96
|
-
private readonly createClientEnvironmentImpl;
|
|
97
|
-
private readonly createWebEnvironmentImpl;
|
|
98
|
-
private readonly createPageEnvironmentImpl;
|
|
99
|
-
private readonly clientState;
|
|
100
|
-
private readonly webState;
|
|
101
|
-
private readonly pageState;
|
|
102
|
-
constructor(options?: ClientEnvironmentServiceOptions<TClientEnvironment, TWebEnvironment, TPageEnvironment>);
|
|
103
|
-
resolveClientEnvironment(): Promise<TClientEnvironment>;
|
|
104
|
-
resolveWebEnvironment(): Promise<TWebEnvironment>;
|
|
105
|
-
resolvePageEnvironment(): Promise<TPageEnvironment>;
|
|
106
|
-
readClientEnvironment(): TClientEnvironment;
|
|
107
|
-
readWebEnvironment(): TWebEnvironment;
|
|
108
|
-
readPageEnvironment(): TPageEnvironment;
|
|
109
|
-
reset(): void;
|
|
110
|
-
private resolveState;
|
|
111
|
-
private readState;
|
|
112
|
-
private resetState;
|
|
113
|
-
}
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/web/input-sources.d.ts
|
|
116
|
-
interface AbortSignalSource {
|
|
117
|
-
aborted: boolean;
|
|
118
|
-
reason: unknown;
|
|
119
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
120
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
121
|
-
}
|
|
122
|
-
interface FromAbortSignalOptions {
|
|
123
|
-
/** AbortSignal to observe. */
|
|
124
|
-
signal?: AbortSignalSource;
|
|
125
|
-
/** Callback invoked when the signal aborts. */
|
|
126
|
-
callback: (reason: unknown) => void;
|
|
127
|
-
/**
|
|
128
|
-
* Emit immediately when the signal is already aborted at subscribe time.
|
|
129
|
-
* Defaults to `false`.
|
|
130
|
-
*/
|
|
131
|
-
emitIfAborted?: boolean;
|
|
132
|
-
}
|
|
133
|
-
interface StorageEventTarget {
|
|
134
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
135
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
136
|
-
}
|
|
137
|
-
interface FromStorageEventOptions {
|
|
138
|
-
/**
|
|
139
|
-
* Storage-event target. Defaults to `globalThis`, which is appropriate for
|
|
140
|
-
* browser hosts and jsdom-based tests.
|
|
141
|
-
*/
|
|
142
|
-
target?: StorageEventTarget;
|
|
143
|
-
/** Callback invoked for each browser `storage` event. */
|
|
144
|
-
callback: (event: StorageEvent) => void;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Adapt a browser AbortSignal into the shared Subscription model.
|
|
148
|
-
*/
|
|
149
|
-
declare function fromAbortSignal(options: FromAbortSignalOptions): Subscription;
|
|
150
|
-
/**
|
|
151
|
-
* Adapt browser `storage` events into the shared Subscription model.
|
|
152
|
-
*/
|
|
153
|
-
declare function fromStorageEvent(options: FromStorageEventOptions): Subscription;
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/web/page-resume-reconciler.d.ts
|
|
156
|
-
declare const PageResumeTriggerKind: {
|
|
157
|
-
readonly Visibility: "visibility";
|
|
158
|
-
readonly PageShow: "pageshow";
|
|
159
|
-
readonly Focus: "focus";
|
|
160
|
-
readonly Online: "online";
|
|
161
|
-
};
|
|
162
|
-
type PageResumeTriggerKind = (typeof PageResumeTriggerKind)[keyof typeof PageResumeTriggerKind];
|
|
163
|
-
interface PageResumeEvent {
|
|
164
|
-
trigger: PageResumeTriggerKind;
|
|
165
|
-
persisted?: boolean;
|
|
166
|
-
}
|
|
167
|
-
type PageResumeCallback = (event: PageResumeEvent) => void | Promise<void>;
|
|
168
|
-
interface PageResumeDocumentTarget {
|
|
169
|
-
addEventListener(type: "visibilitychange", handler: EventListener): void;
|
|
170
|
-
removeEventListener(type: "visibilitychange", handler: EventListener): void;
|
|
171
|
-
visibilityState: DocumentVisibilityState;
|
|
172
|
-
}
|
|
173
|
-
interface PageResumeWindowTarget {
|
|
174
|
-
addEventListener(type: "pageshow" | "focus" | "online", handler: EventListener): void;
|
|
175
|
-
removeEventListener(type: "pageshow" | "focus" | "online", handler: EventListener): void;
|
|
176
|
-
}
|
|
177
|
-
interface CreatePageResumeReconcilerOptions {
|
|
178
|
-
onReconcile: PageResumeCallback;
|
|
179
|
-
/** Defaults to 5000ms. Use 0 in deterministic tests. */
|
|
180
|
-
throttleMs?: number;
|
|
181
|
-
document?: PageResumeDocumentTarget | null;
|
|
182
|
-
window?: PageResumeWindowTarget | null;
|
|
183
|
-
now?: () => number;
|
|
184
|
-
onError?: (error: unknown, event: PageResumeEvent) => void;
|
|
185
|
-
}
|
|
186
|
-
interface PageResumeReconciler {
|
|
187
|
-
dispose(): void;
|
|
188
|
-
readonly reconcileCount: number;
|
|
189
|
-
}
|
|
190
|
-
declare function createPageResumeReconciler(options: CreatePageResumeReconcilerOptions): PageResumeReconciler;
|
|
191
|
-
//#endregion
|
|
192
|
-
//#region src/web/popup.d.ts
|
|
193
|
-
/** Stable error codes for popup-related failures. */
|
|
194
|
-
declare const PopupErrorCode: {
|
|
195
|
-
/** The browser blocked the popup window from opening. */readonly Blocked: "popup.blocked"; /** The popup was closed by the user before completing the flow. */
|
|
196
|
-
readonly Closed: "popup.closed_by_user"; /** The relay message was not received within the timeout. */
|
|
197
|
-
readonly Timeout: "popup.relay_timeout"; /** The relay message contained an error from the callback page. */
|
|
198
|
-
readonly RelayError: "popup.relay_error"; /** An unexpected error occurred during popup lifecycle. */
|
|
199
|
-
readonly Internal: "popup.internal";
|
|
200
|
-
};
|
|
201
|
-
type PopupErrorCode = (typeof PopupErrorCode)[keyof typeof PopupErrorCode];
|
|
202
|
-
/**
|
|
203
|
-
* Options for computing the popup window features string.
|
|
204
|
-
*/
|
|
205
|
-
interface PopupFeaturesOptions {
|
|
206
|
-
/** Width in pixels (default: 500). */
|
|
207
|
-
width?: number;
|
|
208
|
-
/** Height in pixels (default: 600). */
|
|
209
|
-
height?: number;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Compute the `features` string for `window.open()`, centered on screen.
|
|
213
|
-
*/
|
|
214
|
-
declare function computePopupFeatures(options?: PopupFeaturesOptions): string;
|
|
215
|
-
/**
|
|
216
|
-
* Result of opening a popup window.
|
|
217
|
-
*/
|
|
218
|
-
interface PopupWindowHandle {
|
|
219
|
-
/** The opened window reference. */
|
|
220
|
-
window: Window;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Open a popup window to the given URL.
|
|
224
|
-
*
|
|
225
|
-
* Throws a `ClientError` with code `popup.blocked` if the browser
|
|
226
|
-
* blocks the popup.
|
|
227
|
-
*/
|
|
228
|
-
declare function openPopupWindow(url: string, options?: PopupFeaturesOptions & {
|
|
229
|
-
target?: string;
|
|
230
|
-
}): PopupWindowHandle;
|
|
231
|
-
/**
|
|
232
|
-
* Expected shape of a relay message from the popup callback page.
|
|
233
|
-
*/
|
|
234
|
-
interface PopupRelayMessage {
|
|
235
|
-
/** Discriminator for the message type. */
|
|
236
|
-
type: "securitydept:popup_callback";
|
|
237
|
-
/** The callback URL or fragment received by the popup. */
|
|
238
|
-
payload: string;
|
|
239
|
-
/** Optional error from the callback page. */
|
|
240
|
-
error?: string;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Options for waiting for a popup relay message.
|
|
244
|
-
*/
|
|
245
|
-
interface WaitForPopupRelayOptions {
|
|
246
|
-
/** The popup window handle to monitor. */
|
|
247
|
-
popup: PopupWindowHandle;
|
|
248
|
-
/** Maximum time to wait in milliseconds (default: 120000 = 2 minutes). */
|
|
249
|
-
timeoutMs?: number;
|
|
250
|
-
/** Expected origin for the relay message (default: current origin). */
|
|
251
|
-
expectedOrigin?: string;
|
|
252
|
-
/** Poll interval for checking if the popup is closed (default: 500ms). */
|
|
253
|
-
pollIntervalMs?: number;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Wait for a relay message from a popup callback page.
|
|
257
|
-
*
|
|
258
|
-
* The popup callback page should call `relayPopupCallback()` to post
|
|
259
|
-
* the callback URL back to the opener.
|
|
260
|
-
*
|
|
261
|
-
* Resolves with the callback payload (URL or fragment string).
|
|
262
|
-
* Rejects with a `ClientError` if:
|
|
263
|
-
* - the popup is closed without relaying (popup.closed_by_user)
|
|
264
|
-
* - the timeout expires (popup.relay_timeout)
|
|
265
|
-
* - the relay message contains an error (popup.relay_error)
|
|
266
|
-
*/
|
|
267
|
-
declare function waitForPopupRelay(options: WaitForPopupRelayOptions): Promise<string>;
|
|
268
|
-
/**
|
|
269
|
-
* Options for relaying the callback from the popup window back to the opener.
|
|
270
|
-
*/
|
|
271
|
-
interface RelayPopupCallbackOptions {
|
|
272
|
-
/** The callback payload (URL or fragment) to relay. */
|
|
273
|
-
payload?: string;
|
|
274
|
-
/** An error message to relay instead of a successful payload. */
|
|
275
|
-
error?: string;
|
|
276
|
-
/** Whether to close the popup after relaying (default: true). */
|
|
277
|
-
closeAfterRelay?: boolean;
|
|
278
|
-
/** Target origin for the postMessage (default: current origin). */
|
|
279
|
-
targetOrigin?: string;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Relay the popup callback result back to the opener window.
|
|
283
|
-
*
|
|
284
|
-
* Call this function from the popup callback page to send the callback
|
|
285
|
-
* URL/fragment back to the parent window that initiated the popup login.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* ```html
|
|
289
|
-
* <script type="module">
|
|
290
|
-
* import { relayPopupCallback } from "@securitydept/client/web";
|
|
291
|
-
* relayPopupCallback({ payload: window.location.href });
|
|
292
|
-
* </script>
|
|
293
|
-
* ```
|
|
294
|
-
*/
|
|
295
|
-
declare function relayPopupCallback(options?: RelayPopupCallbackOptions): void;
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/web/visibility.d.ts
|
|
298
|
-
/** Visibility state snapshot passed to the callback. */
|
|
299
|
-
declare const VisibilityState: {
|
|
300
|
-
readonly Visible: "visible";
|
|
301
|
-
readonly Hidden: "hidden";
|
|
302
|
-
};
|
|
303
|
-
type VisibilityState = (typeof VisibilityState)[keyof typeof VisibilityState];
|
|
304
|
-
/** Options for {@link fromVisibilityChange}. */
|
|
305
|
-
interface FromVisibilityChangeOptions {
|
|
306
|
-
/**
|
|
307
|
-
* Callback invoked when the document visibility state changes.
|
|
308
|
-
*
|
|
309
|
-
* The callback receives the new visibility state ("visible" or "hidden").
|
|
310
|
-
*/
|
|
311
|
-
callback: (state: VisibilityState) => void;
|
|
312
|
-
/**
|
|
313
|
-
* Override the document target (primarily for testing).
|
|
314
|
-
* Defaults to `globalThis.document`.
|
|
315
|
-
*/
|
|
316
|
-
document?: Pick<Document, "addEventListener" | "removeEventListener" | "visibilityState">;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Subscribe to browser document visibility changes.
|
|
320
|
-
*
|
|
321
|
-
* Built on {@link fromEventPattern} so it follows the same Subscription
|
|
322
|
-
* contract. Returns a {@link Subscription} handle for cleanup.
|
|
323
|
-
*
|
|
324
|
-
* @example
|
|
325
|
-
* ```ts
|
|
326
|
-
* const sub = fromVisibilityChange({
|
|
327
|
-
* callback: (state) => {
|
|
328
|
-
* if (state === VisibilityState.Visible) {
|
|
329
|
-
* scheduleRefresh();
|
|
330
|
-
* }
|
|
331
|
-
* },
|
|
332
|
-
* });
|
|
333
|
-
* // Cleanup:
|
|
334
|
-
* sub.unsubscribe();
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
declare function fromVisibilityChange(options: FromVisibilityChangeOptions): Subscription;
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/web/visibility-reconciler.d.ts
|
|
340
|
-
/** Callback invoked when the page becomes visible and reconciliation is needed. */
|
|
341
|
-
type ReconcileCallback = () => void | Promise<void>;
|
|
342
|
-
/** Options for {@link createVisibilityReconciler}. */
|
|
343
|
-
interface CreateVisibilityReconcilerOptions {
|
|
344
|
-
/**
|
|
345
|
-
* Called when the document transitions from hidden → visible.
|
|
346
|
-
* The reconciler only fires on the hidden→visible edge; repeated
|
|
347
|
-
* visible→visible events are suppressed.
|
|
348
|
-
*/
|
|
349
|
-
onReconcile: ReconcileCallback;
|
|
350
|
-
/**
|
|
351
|
-
* Minimum interval (ms) between reconciliation triggers.
|
|
352
|
-
* Prevents rapid-fire reconciliation when the user toggles tabs quickly.
|
|
353
|
-
* Defaults to 5000ms (5 seconds).
|
|
354
|
-
*/
|
|
355
|
-
throttleMs?: number;
|
|
356
|
-
/**
|
|
357
|
-
* Override the document target (primarily for testing).
|
|
358
|
-
* Defaults to `globalThis.document`.
|
|
359
|
-
*/
|
|
360
|
-
document?: FromVisibilityChangeOptions["document"];
|
|
361
|
-
/**
|
|
362
|
-
* Clock override for testing.
|
|
363
|
-
*/
|
|
364
|
-
now?: () => number;
|
|
365
|
-
}
|
|
366
|
-
/** Handle returned by {@link createVisibilityReconciler}. */
|
|
367
|
-
interface VisibilityReconciler {
|
|
368
|
-
/** Stop listening for visibility changes. */
|
|
369
|
-
dispose(): void;
|
|
370
|
-
/** Number of times reconciliation has been triggered. */
|
|
371
|
-
readonly reconcileCount: number;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Create a visibility reconciler that triggers a callback when the page
|
|
375
|
-
* transitions from hidden → visible.
|
|
376
|
-
*
|
|
377
|
-
* @example
|
|
378
|
-
* ```ts
|
|
379
|
-
* const reconciler = createVisibilityReconciler({
|
|
380
|
-
* onReconcile: () => {
|
|
381
|
-
* // Re-check token freshness or sync cross-tab state
|
|
382
|
-
* if (controller.snapshot?.tokens.accessTokenExpiresAt) {
|
|
383
|
-
* scheduleRefreshIfExpired();
|
|
113
|
+
* controller.clearState({ persistPolicy: "skip" });
|
|
384
114
|
* }
|
|
385
115
|
* },
|
|
386
116
|
* });
|
|
387
117
|
* // Later:
|
|
388
|
-
*
|
|
118
|
+
* subscription.unsubscribe();
|
|
389
119
|
* ```
|
|
390
120
|
*/
|
|
391
|
-
declare function
|
|
121
|
+
declare function createCrossTabSync(options: CreateCrossTabSyncOptions): EventStreamTrait<CrossTabSyncEvent>;
|
|
392
122
|
//#endregion
|
|
393
|
-
export { type
|
|
123
|
+
export { type CreateCrossTabSyncOptions, type CreateEnvironmentForNativeWebOptions, type CreatePageResumeSourceOptions, type CrossTabSyncEvent, type FoundationEnvironment, type FromStorageEventOptions, type NativeWebEnvironment, type NativeWebHistoryLike, type NativeWebLocationLike, type NativeWebNavigationLike, NativeWebRouter, type NativeWebStorageLike, type NativeWebWindowLike, type PageLifecycleForNativeWebCreateOptions, type PageResumeDocumentTarget, type PageResumeEvent, PageResumeTriggerKind, type PageResumeWindowTarget, type PopupFeaturesOptions, type PopupForNativeWebCreateOptions, type RouterForNativeWebCreateOptions, type StorageEventTarget, type StorageForNativeWebCreateOptions, WebLegacyRouter, WebNavigationRouter, computePopupFeatures, createCrossTabSync, createEnvironmentForNativeWeb, createPageLifecycleForNativeWeb, createPageResumeSource, createPersistentStorageForNativeWeb, createPopupForNativeWeb, createRouterForNativeWeb, createSessionStorageForNativeWeb, createStorageForNativeWeb, fromStorageEvent };
|
|
394
124
|
//# sourceMappingURL=index.d.mts.map
|