@corbado/observe 1.3.0 → 1.5.0
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/dist/cdn/script.global.js +36 -5
- package/dist/index.d.mts +158 -20
- package/dist/index.d.ts +158 -20
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -50,7 +50,7 @@ type SetFlowTagsOptions = {
|
|
|
50
50
|
expandToFollowing?: boolean;
|
|
51
51
|
};
|
|
52
52
|
type ProvideIdentifierSpecType = "email" | "phone" | "username";
|
|
53
|
-
type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "line" | "kakao" | "singpass" | "other";
|
|
53
|
+
type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "line" | "kakao" | "singpass" | "naver" | "yahoo" | "other";
|
|
54
54
|
declare enum AuthEventName {
|
|
55
55
|
FlowStarted = "flow_started",
|
|
56
56
|
FlowDecided = "flow_decided",
|
|
@@ -307,6 +307,52 @@ interface TelemetryEntry {
|
|
|
307
307
|
/** Capture time, unix ms. */
|
|
308
308
|
ts: number;
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Context stamped on a probe item: the integration's current state / flow type / step (each ≤ 64 chars).
|
|
312
|
+
*
|
|
313
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
314
|
+
*/
|
|
315
|
+
interface ProbeContext {
|
|
316
|
+
state?: string;
|
|
317
|
+
flowType?: string;
|
|
318
|
+
step?: string;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Input of {@link CorbadoTracker.probe}.
|
|
322
|
+
*
|
|
323
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
324
|
+
*/
|
|
325
|
+
interface ProbeInput {
|
|
326
|
+
/** Item kind, `^[a-z][a-z0-9_-]{0,31}$` (e.g. `ui`, `act`, `net`, `page`, `snapshot`). */
|
|
327
|
+
kind: string;
|
|
328
|
+
/** Already redacted JSON object or array; serialized ≤ 16384 bytes, larger items are dropped. */
|
|
329
|
+
payload: Record<string, unknown> | unknown[];
|
|
330
|
+
/** `^[A-Za-z0-9_-]{1,16}$`; defaults to one random id per tracker instance (page). */
|
|
331
|
+
pageId?: string;
|
|
332
|
+
/** Probe config hash, `^[A-Za-z0-9_-]{1,16}$`. */
|
|
333
|
+
cfg?: string;
|
|
334
|
+
ctx?: ProbeContext;
|
|
335
|
+
/** Capture time, unix ms; defaults to now. */
|
|
336
|
+
ts?: number;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A probe item on the wire (`probes` array of the events endpoint payload).
|
|
340
|
+
*
|
|
341
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
342
|
+
*/
|
|
343
|
+
interface ProbeEntry {
|
|
344
|
+
/** Client-generated idempotency id (uuidv7); kept across retries. */
|
|
345
|
+
id: string;
|
|
346
|
+
kind: string;
|
|
347
|
+
/** Capture time, unix ms. */
|
|
348
|
+
ts: number;
|
|
349
|
+
pageId: string;
|
|
350
|
+
/** Per `pageId`, starting at 0; gaps mean loss. */
|
|
351
|
+
seq: number;
|
|
352
|
+
cfg?: string;
|
|
353
|
+
ctx?: ProbeContext;
|
|
354
|
+
payload: Record<string, unknown> | unknown[];
|
|
355
|
+
}
|
|
310
356
|
/**
|
|
311
357
|
* Why a delivery attempt happened. Each value maps 1:1 to one flush trigger, so server-side
|
|
312
358
|
* analyses can tell which triggers actually carry the traffic and whether the trigger switches and
|
|
@@ -370,6 +416,8 @@ interface EventBatch {
|
|
|
370
416
|
sdk: SdkInfo;
|
|
371
417
|
lows?: LowEvent[];
|
|
372
418
|
telemetry?: TelemetryEntry[];
|
|
419
|
+
/** Probe items (internal diagnostics captured by autocapture bundles); a batch may carry probes only. */
|
|
420
|
+
probes?: ProbeEntry[];
|
|
373
421
|
meta?: EventBatchMeta;
|
|
374
422
|
}
|
|
375
423
|
type DeviceType = "web" | "app" | "other";
|
|
@@ -512,20 +560,17 @@ interface SdkReliabilityConfig {
|
|
|
512
560
|
*/
|
|
513
561
|
flushOnFlowTypeFinished: FlowType[];
|
|
514
562
|
/**
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
* Read at collection time, so a config that arrives mid-load applies from the next device info
|
|
520
|
-
* refresh onward. The very first collection of a load booting on the built-in defaults (nothing
|
|
521
|
-
* cached) always runs on the default.
|
|
563
|
+
* @deprecated No effect since device info is collected with built-in deadlines (a fast snapshot
|
|
564
|
+
* within 300 ms, slower fields as a later update within 3000 ms). Still parsed so older server
|
|
565
|
+
* configs keep loading; the backend keeps serving it for older SDK versions.
|
|
522
566
|
*/
|
|
523
567
|
deviceInfoCollectorTimeoutMs: number;
|
|
524
568
|
/**
|
|
525
|
-
* When true (and `telemetry` is enabled),
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
569
|
+
* When true (and `telemetry` is enabled), device info collection emits `info` telemetry entries:
|
|
570
|
+
* the fast snapshot's total and per-field durations in milliseconds, the late fields' outcome, the
|
|
571
|
+
* `privateMode` source (cache age, detection duration or timeout) and how the update was delivered
|
|
572
|
+
* (or that it was left undelivered at pagehide / destroy). Defaults to false: this is a diagnostic
|
|
573
|
+
* stream to switch on while investigating slow collection, not something to run permanently.
|
|
529
574
|
*/
|
|
530
575
|
deviceInfoTiming: boolean;
|
|
531
576
|
/** Serialize explicitly supplied raw error diagnostics. Defaults to true; refreshes apply to subsequent errors. Already queued events are unchanged. */
|
|
@@ -1541,10 +1586,9 @@ interface TrackerOptions {
|
|
|
1541
1586
|
/** Minimum time between attaching cached device info to events. */
|
|
1542
1587
|
deviceInfoDebounceTime?: number;
|
|
1543
1588
|
/**
|
|
1544
|
-
* @deprecated
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1547
|
-
* cached it wins. It will be removed in a future release.
|
|
1589
|
+
* @deprecated No effect: device info is collected with built-in deadlines (a fast snapshot within
|
|
1590
|
+
* 300 ms, slower fields as a later update within 3000 ms). Still accepted so existing integrations
|
|
1591
|
+
* keep compiling. It will be removed in a future release.
|
|
1548
1592
|
*/
|
|
1549
1593
|
deviceInfoCollectorTimeout?: number;
|
|
1550
1594
|
defaultTags?: Record<string, string>;
|
|
@@ -1615,6 +1659,9 @@ declare class CorbadoTracker {
|
|
|
1615
1659
|
private telemetryReady;
|
|
1616
1660
|
private readonly reportedTelemetryKeys;
|
|
1617
1661
|
private pendingSelfTelemetry;
|
|
1662
|
+
/** Default probe page id (one per tracker instance) and the probe seq counter per page id. */
|
|
1663
|
+
private probePageId?;
|
|
1664
|
+
private readonly probeSeqs;
|
|
1618
1665
|
private windowObserver?;
|
|
1619
1666
|
private passwordManagerSampler?;
|
|
1620
1667
|
/** @internal Shared passive page observation and per-operation context registration. */
|
|
@@ -2024,10 +2071,36 @@ declare class CorbadoTracker {
|
|
|
2024
2071
|
* PII — telemetry is for diagnostics only. Like all SDK entry points, this never throws.
|
|
2025
2072
|
*/
|
|
2026
2073
|
telemetry(level: TelemetryLevel, message: string): void;
|
|
2074
|
+
/**
|
|
2075
|
+
* Queue a probe item (diagnostic capture produced by a Corbado autocapture bundle).
|
|
2076
|
+
*
|
|
2077
|
+
* @remarks
|
|
2078
|
+
* The SDK fills `id` (uuidv7), `seq` (per `pageId`), `pageId` (default: one random id per tracker
|
|
2079
|
+
* instance) and `ts` (default: now). Items are held in memory only (never the durable outbox) and
|
|
2080
|
+
* ride the regular batches; they are the lowest priority at page unload. Invalid input is dropped.
|
|
2081
|
+
* The payload must already be redacted. Blocked user agents are skipped. Never throws.
|
|
2082
|
+
*
|
|
2083
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
2084
|
+
* @internal
|
|
2085
|
+
*/
|
|
2086
|
+
probe(input: ProbeInput): void;
|
|
2087
|
+
private defaultProbePageId;
|
|
2088
|
+
private nextProbeSeq;
|
|
2027
2089
|
/** Convenience wrapper for {@link CorbadoTracker.telemetry} at `info` level. */
|
|
2028
2090
|
logInfo(message: string): void;
|
|
2029
2091
|
/** Convenience wrapper for {@link CorbadoTracker.telemetry} at `error` level. */
|
|
2030
2092
|
logError(message: string): void;
|
|
2093
|
+
/**
|
|
2094
|
+
* Queue hook run right before an event batch is sent: a device info snapshot that no event carried
|
|
2095
|
+
* yet (typically the fast snapshot after a burst of events at page load, or the privateMode update)
|
|
2096
|
+
* rides the first event of this page in the batch that has none. Events of other pages (outbox
|
|
2097
|
+
* replays) are never touched, and nothing is sent just for device info. When the page goes away
|
|
2098
|
+
* with a snapshot nothing could carry, that is reported (timing diagnostics only).
|
|
2099
|
+
*
|
|
2100
|
+
* Error situations:
|
|
2101
|
+
* - Any error: log "Failed to attach device info to batch" and send the batch unchanged
|
|
2102
|
+
*/
|
|
2103
|
+
private attachUndeliveredDeviceInfo;
|
|
2031
2104
|
/**
|
|
2032
2105
|
* Escalate an internal SDK diagnostic to the telemetry stream (self-instrumentation). This is the
|
|
2033
2106
|
* sink behind {@link Logger.reportTelemetry}; chosen internal failure sites route here so faults
|
|
@@ -2270,6 +2343,23 @@ interface TransportOptions {
|
|
|
2270
2343
|
headers?: Record<string, string>;
|
|
2271
2344
|
}
|
|
2272
2345
|
|
|
2346
|
+
/** In-memory probe queue caps (oldest items are dropped beyond them). */
|
|
2347
|
+
declare const PROBE_QUEUE_MAX_ITEMS = 500;
|
|
2348
|
+
declare const PROBE_QUEUE_MAX_BYTES: number;
|
|
2349
|
+
/** Per-request probe caps (the server keeps at most 200 probe items per batch). */
|
|
2350
|
+
declare const PROBE_BATCH_MAX_ITEMS = 200;
|
|
2351
|
+
declare const PROBE_BATCH_MAX_BYTES: number;
|
|
2352
|
+
/** Serialized payload cap per probe item (server rule). */
|
|
2353
|
+
declare const PROBE_PAYLOAD_MAX_BYTES: number;
|
|
2354
|
+
/**
|
|
2355
|
+
* Unload request budget shared by the event beacon and the probe beacon that follows it: unload
|
|
2356
|
+
* transports share a ~64 KB in-flight budget per page (same limit as the fetch keepalive cap).
|
|
2357
|
+
*/
|
|
2358
|
+
declare const UNLOAD_BUDGET_BYTES = 60000;
|
|
2359
|
+
/** Absolute cap of the probe request at pagehide / destroy. */
|
|
2360
|
+
declare const UNLOAD_PROBE_MAX_BYTES = 32000;
|
|
2361
|
+
/** UTF-8 byte length of a string (no TextEncoder dependency). */
|
|
2362
|
+
declare function utf8Length(text: string): number;
|
|
2273
2363
|
interface QueueOptions {
|
|
2274
2364
|
/**
|
|
2275
2365
|
* Maximum number of events per request (payload cap). A backlog larger than this is drained in
|
|
@@ -2299,6 +2389,14 @@ interface QueueOptions {
|
|
|
2299
2389
|
* none has ever been set. Read at send time so a change applies to the next batch without a flush.
|
|
2300
2390
|
*/
|
|
2301
2391
|
getDataPolicy?: () => number | undefined;
|
|
2392
|
+
/**
|
|
2393
|
+
* Called with the events of every event batch right before it is sent (async and unload flushes),
|
|
2394
|
+
* before the batch's telemetry is taken. The tracker uses it to attach a device info snapshot that
|
|
2395
|
+
* no event carried yet to an event of the current page. It may mutate the events; the in-memory
|
|
2396
|
+
* pending entries share them, so a retry on this page keeps the change. Never called for batches
|
|
2397
|
+
* without events.
|
|
2398
|
+
*/
|
|
2399
|
+
beforeEventBatchSend?: (events: Event[], reason: FlushReason) => void;
|
|
2302
2400
|
}
|
|
2303
2401
|
/**
|
|
2304
2402
|
* @remarks When `window` is defined, `visibilitychange` (when the document becomes hidden) and `pagehide`
|
|
@@ -2335,6 +2433,16 @@ declare class RequestQueue {
|
|
|
2335
2433
|
* the flush timer (it piggybacks), unless `config.flushOnTelemetry` escalates to an immediate flush.
|
|
2336
2434
|
*/
|
|
2337
2435
|
private telemetryQueue;
|
|
2436
|
+
/**
|
|
2437
|
+
* Probe items (`tracker.probe()`): in memory only — never the durable outbox — capped by
|
|
2438
|
+
* {@link PROBE_QUEUE_MAX_ITEMS} / {@link PROBE_QUEUE_MAX_BYTES}. They arm the flush timer, ride
|
|
2439
|
+
* the regular batches (probe-only batches allowed), retry under `config.retry`, and are the lowest
|
|
2440
|
+
* priority at unload (a separate request after the event request, within the remaining budget).
|
|
2441
|
+
*/
|
|
2442
|
+
private probeQueue;
|
|
2443
|
+
private probeBytes;
|
|
2444
|
+
/** Probe items dropped on this load (caps, permanent rejection, exhausted retries, unload budget). */
|
|
2445
|
+
private probesDropped;
|
|
2338
2446
|
private timer;
|
|
2339
2447
|
private isFlushing;
|
|
2340
2448
|
private flushingDone?;
|
|
@@ -2353,6 +2461,7 @@ declare class RequestQueue {
|
|
|
2353
2461
|
private readonly requestConfig;
|
|
2354
2462
|
private readonly onConfigReceived?;
|
|
2355
2463
|
private readonly getDataPolicy?;
|
|
2464
|
+
private readonly beforeEventBatchSend?;
|
|
2356
2465
|
/** Current delivery policy, including live updates. */
|
|
2357
2466
|
private config;
|
|
2358
2467
|
/**
|
|
@@ -2395,6 +2504,30 @@ declare class RequestQueue {
|
|
|
2395
2504
|
* - Any error while enqueueing or triggering the flush: log "Failed to enqueue telemetry"
|
|
2396
2505
|
*/
|
|
2397
2506
|
enqueueTelemetry(entry: TelemetryEntry): void;
|
|
2507
|
+
/**
|
|
2508
|
+
* Queue a probe item (in memory only). The payload is snapshotted (serialized once) so later host
|
|
2509
|
+
* mutations cannot change it; items over {@link PROBE_PAYLOAD_MAX_BYTES} are dropped, and the
|
|
2510
|
+
* oldest items are dropped beyond the queue caps. Arms the normal flush timer.
|
|
2511
|
+
*
|
|
2512
|
+
* Error situations:
|
|
2513
|
+
* - Any error while enqueueing or scheduling the flush timer: log "Failed to enqueue probe"
|
|
2514
|
+
*/
|
|
2515
|
+
enqueueProbe(entry: ProbeEntry, capturedSessionId?: string): void;
|
|
2516
|
+
/** Number of probe items dropped on this load (diagnostics / tests). */
|
|
2517
|
+
droppedProbeCount(): number;
|
|
2518
|
+
private dueProbes;
|
|
2519
|
+
/** Oldest-first selection for one session, within an item and byte cap (at least one item when any fits the item cap). */
|
|
2520
|
+
private selectProbes;
|
|
2521
|
+
private removeProbes;
|
|
2522
|
+
private dropProbes;
|
|
2523
|
+
/** Same policy as events: 2xx delivered, non-retryable dropped, retryable backed off up to `config.retry.maxAttempts`. */
|
|
2524
|
+
private handleProbeSendResult;
|
|
2525
|
+
/**
|
|
2526
|
+
* Unload / final teardown: one probe-only request for the current session within `budget` bytes,
|
|
2527
|
+
* sent after the event request so the events' delivery is unaffected. Leftovers are dropped when
|
|
2528
|
+
* `dropRest` (pagehide, destroy); otherwise they stay queued.
|
|
2529
|
+
*/
|
|
2530
|
+
private sendUnloadProbes;
|
|
2398
2531
|
private scheduleAfterEnqueue;
|
|
2399
2532
|
/**
|
|
2400
2533
|
* Whether this event completes one of the configured priority flow types. Only the two flow
|
|
@@ -2428,6 +2561,8 @@ declare class RequestQueue {
|
|
|
2428
2561
|
* The transport later merges in `sent`/`transport`.
|
|
2429
2562
|
*/
|
|
2430
2563
|
private attachBatchMeta;
|
|
2564
|
+
/** Run the beforeEventBatchSend hook; a throwing hook must never break a flush. */
|
|
2565
|
+
private prepareEvents;
|
|
2431
2566
|
/** The data policy code from the tracker, or undefined; a throwing getter must never break a flush. */
|
|
2432
2567
|
private readDataPolicy;
|
|
2433
2568
|
private getDuePending;
|
|
@@ -2481,6 +2616,10 @@ declare class RequestQueue {
|
|
|
2481
2616
|
*/
|
|
2482
2617
|
flushKeepalive(reason?: FlushReason): void;
|
|
2483
2618
|
private flushSync;
|
|
2619
|
+
/** The event part of the unload flush; returns the serialized size of what it sent (0 = nothing). */
|
|
2620
|
+
private flushSyncEvents;
|
|
2621
|
+
/** Serialized batch size for the unload budget; on failure assume the whole budget was used. */
|
|
2622
|
+
private approximateSize;
|
|
2484
2623
|
/**
|
|
2485
2624
|
* Error situations:
|
|
2486
2625
|
* - Timer clearance or event listener removal throws: log "Failed to destroy queue lifecycle hooks"
|
|
@@ -2500,9 +2639,8 @@ declare const CONFIG_REQUEST_HEADER = "X-Corbado-Observe-Config";
|
|
|
2500
2639
|
declare const DEFAULT_FLUSH_INTERVAL_MS = 500;
|
|
2501
2640
|
declare const DEFAULT_SEQ_LOCK_TIMEOUT_MS = 50;
|
|
2502
2641
|
/**
|
|
2503
|
-
*
|
|
2504
|
-
*
|
|
2505
|
-
* response can arrive — generous enough that a slow-but-working browser API still answers.
|
|
2642
|
+
* Default of the deprecated `deviceInfoCollectorTimeoutMs` config field. Only parsed for config
|
|
2643
|
+
* compatibility: device info collection uses its own built-in deadlines (see `device.ts`).
|
|
2506
2644
|
*/
|
|
2507
2645
|
declare const DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS = 1000;
|
|
2508
2646
|
/**
|
|
@@ -2741,4 +2879,4 @@ declare function logInfo(message: string): void;
|
|
|
2741
2879
|
declare function logError(message: string): void;
|
|
2742
2880
|
declare function destroy(): Promise<void>;
|
|
2743
2881
|
|
|
2744
|
-
export { type AppConfirmationOperationCeremonyTypedError, type AppConfirmationOperationConfig, AppConfirmationOperationFull, type AppConfirmationOperationRetryReason, type AppConfirmationOperationSpecType, type AppConfirmationOperationStart, type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, CEREMONY_LOW_EVENT_TAIL_MS, CONFIG_BOUNDS, CONFIG_REQUEST_HEADER, CONFIG_STORAGE_KEY, type CaptchaOperationConfig, CaptchaOperationFull, type CaptchaOperationSpecType, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SEQ_LOCK_TIMEOUT_MS, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, type DeviceInfoDataWeb, type DeviceType, type EmailLinkContinuationConfig, EmailLinkContinuationOperation, type EmailLinkOperationConfig, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationConfig, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type ErrorStepOptions, type Event, type EventBatch, type EventBatchMeta, type EventMeta, EventStore, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowHandle, type FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, type KeyOperationConfig, KeyRegistrationOperationFull, KeySigningOperationFull, LocalStorage, type Logger, type LowEvent, type LowEventFieldRole, type LowEventInitiator, type LowEventInputEffect, type LowEventSourceKind, type MultiFlowReset, type MultiFlowStarted, NamespacedStorage, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, type ObserveSdkConfigSnapshot, OperationFull, OperationFullProvideIdentifierWithCUI, type OperationFullProvideIdentifierWithCUIConfig, type OutboxEntry, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, type PasskeyEnrollmentOperationConfig, PasskeyEnrollmentOperationFull, type PasskeyEnrollmentPostResponseStart, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, type PasskeyLoginOperationConfig, PasskeyLoginOperationFull, type PasskeyLoginPostResponseStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginCUICeremonyStart, type PasswordLoginCUIGetOptionsFinished, type PasswordLoginCUIGetOptionsStart, type PasswordLoginCUISpecType, type PasswordLoginCUITypedError, type PasswordLoginConfig, type PasswordLoginExplicitSpecType, PasswordLoginOperationFull, type PasswordLoginTypedError, type PasswordManagerExtension, type PasswordManagerExtensionName, type PredefinedEvent, type ProvideDataOperationConfig, ProvideDataOperationFull, type ProvideDataOperationPostResponseStart, type ProvideDataOperationSpecType, type ProvideDataOperationStart, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RAW_ERROR_BOUNDS, type RawErrorEnvelope, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, type SdkReliabilityConfig, type SdkReliabilityConfigOverrides, type SdkRetryConfig, type SerializeRawErrorOptions, SessionStorage, type SetFlowTagsOptions, type SmsOTPOperationConfig, type SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, type SocialLoginOperationConfig, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type SourcePathQueryMode, type SsoLoginExchangeCodeFinished, type SsoLoginExchangeCodeStart, type SsoLoginGetRedirectUrlFinished, type SsoLoginGetRedirectUrlStart, type SsoLoginOperationConfig, SsoLoginOperationFull, type SsoLoginSpecType, type StepHelper, type StepIdentifier, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TelemetryEntry, type TelemetryLevel, type TelemetrySink, type TotpOperationConfig, TotpOperationFull, type TotpOperationPostResponseStart, type TotpOperationSpecType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type TrustedDeviceBindingMetadata, type TrustedDeviceCheckConfig, TrustedDeviceCheckOperationFull, type TrustedDeviceCheckResult, type TrustedDeviceCheckStepResult, type TrustedDeviceCheckTypedError, TrustedDeviceEnrollmentOperationFull, type TrustedDeviceEnrollmentResult, type TrustedDeviceOperationConfig, type TrustedDevicePurpose, type TrustedDeviceStorage, type UserReference, type WebAuthnIdentifierProjector, type WebAuthnIdentifierProjectors, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, detectPasswordManagerExtensions, getExperiments, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, namespacedKey, parseReliabilityConfig, resetSession, resolveRawErrorLimits, resolveReliabilityConfig, sanitizeAssertionResponse, sanitizeCreationOptions, sanitizeCreationResponse, sanitizeRequestOptions, serializeRawError, setExperiment, setExperiments, setFlowTags, setUser, telemetry };
|
|
2882
|
+
export { type AppConfirmationOperationCeremonyTypedError, type AppConfirmationOperationConfig, AppConfirmationOperationFull, type AppConfirmationOperationRetryReason, type AppConfirmationOperationSpecType, type AppConfirmationOperationStart, type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, CEREMONY_LOW_EVENT_TAIL_MS, CONFIG_BOUNDS, CONFIG_REQUEST_HEADER, CONFIG_STORAGE_KEY, type CaptchaOperationConfig, CaptchaOperationFull, type CaptchaOperationSpecType, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SEQ_LOCK_TIMEOUT_MS, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, type DeviceInfoDataWeb, type DeviceType, type EmailLinkContinuationConfig, EmailLinkContinuationOperation, type EmailLinkOperationConfig, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationConfig, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type ErrorStepOptions, type Event, type EventBatch, type EventBatchMeta, type EventMeta, EventStore, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowHandle, type FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, type KeyOperationConfig, KeyRegistrationOperationFull, KeySigningOperationFull, LocalStorage, type Logger, type LowEvent, type LowEventFieldRole, type LowEventInitiator, type LowEventInputEffect, type LowEventSourceKind, type MultiFlowReset, type MultiFlowStarted, NamespacedStorage, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, type ObserveSdkConfigSnapshot, OperationFull, OperationFullProvideIdentifierWithCUI, type OperationFullProvideIdentifierWithCUIConfig, type OutboxEntry, PROBE_BATCH_MAX_BYTES, PROBE_BATCH_MAX_ITEMS, PROBE_PAYLOAD_MAX_BYTES, PROBE_QUEUE_MAX_BYTES, PROBE_QUEUE_MAX_ITEMS, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, type PasskeyEnrollmentOperationConfig, PasskeyEnrollmentOperationFull, type PasskeyEnrollmentPostResponseStart, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, type PasskeyLoginOperationConfig, PasskeyLoginOperationFull, type PasskeyLoginPostResponseStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginCUICeremonyStart, type PasswordLoginCUIGetOptionsFinished, type PasswordLoginCUIGetOptionsStart, type PasswordLoginCUISpecType, type PasswordLoginCUITypedError, type PasswordLoginConfig, type PasswordLoginExplicitSpecType, PasswordLoginOperationFull, type PasswordLoginTypedError, type PasswordManagerExtension, type PasswordManagerExtensionName, type PredefinedEvent, type ProbeContext, type ProbeEntry, type ProbeInput, type ProvideDataOperationConfig, ProvideDataOperationFull, type ProvideDataOperationPostResponseStart, type ProvideDataOperationSpecType, type ProvideDataOperationStart, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RAW_ERROR_BOUNDS, type RawErrorEnvelope, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, type SdkReliabilityConfig, type SdkReliabilityConfigOverrides, type SdkRetryConfig, type SerializeRawErrorOptions, SessionStorage, type SetFlowTagsOptions, type SmsOTPOperationConfig, type SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, type SocialLoginOperationConfig, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type SourcePathQueryMode, type SsoLoginExchangeCodeFinished, type SsoLoginExchangeCodeStart, type SsoLoginGetRedirectUrlFinished, type SsoLoginGetRedirectUrlStart, type SsoLoginOperationConfig, SsoLoginOperationFull, type SsoLoginSpecType, type StepHelper, type StepIdentifier, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TelemetryEntry, type TelemetryLevel, type TelemetrySink, type TotpOperationConfig, TotpOperationFull, type TotpOperationPostResponseStart, type TotpOperationSpecType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type TrustedDeviceBindingMetadata, type TrustedDeviceCheckConfig, TrustedDeviceCheckOperationFull, type TrustedDeviceCheckResult, type TrustedDeviceCheckStepResult, type TrustedDeviceCheckTypedError, TrustedDeviceEnrollmentOperationFull, type TrustedDeviceEnrollmentResult, type TrustedDeviceOperationConfig, type TrustedDevicePurpose, type TrustedDeviceStorage, UNLOAD_BUDGET_BYTES, UNLOAD_PROBE_MAX_BYTES, type UserReference, type WebAuthnIdentifierProjector, type WebAuthnIdentifierProjectors, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, detectPasswordManagerExtensions, getExperiments, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, namespacedKey, parseReliabilityConfig, resetSession, resolveRawErrorLimits, resolveReliabilityConfig, sanitizeAssertionResponse, sanitizeCreationOptions, sanitizeCreationResponse, sanitizeRequestOptions, serializeRawError, setExperiment, setExperiments, setFlowTags, setUser, telemetry, utf8Length };
|
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ type SetFlowTagsOptions = {
|
|
|
50
50
|
expandToFollowing?: boolean;
|
|
51
51
|
};
|
|
52
52
|
type ProvideIdentifierSpecType = "email" | "phone" | "username";
|
|
53
|
-
type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "line" | "kakao" | "singpass" | "other";
|
|
53
|
+
type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "line" | "kakao" | "singpass" | "naver" | "yahoo" | "other";
|
|
54
54
|
declare enum AuthEventName {
|
|
55
55
|
FlowStarted = "flow_started",
|
|
56
56
|
FlowDecided = "flow_decided",
|
|
@@ -307,6 +307,52 @@ interface TelemetryEntry {
|
|
|
307
307
|
/** Capture time, unix ms. */
|
|
308
308
|
ts: number;
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Context stamped on a probe item: the integration's current state / flow type / step (each ≤ 64 chars).
|
|
312
|
+
*
|
|
313
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
314
|
+
*/
|
|
315
|
+
interface ProbeContext {
|
|
316
|
+
state?: string;
|
|
317
|
+
flowType?: string;
|
|
318
|
+
step?: string;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Input of {@link CorbadoTracker.probe}.
|
|
322
|
+
*
|
|
323
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
324
|
+
*/
|
|
325
|
+
interface ProbeInput {
|
|
326
|
+
/** Item kind, `^[a-z][a-z0-9_-]{0,31}$` (e.g. `ui`, `act`, `net`, `page`, `snapshot`). */
|
|
327
|
+
kind: string;
|
|
328
|
+
/** Already redacted JSON object or array; serialized ≤ 16384 bytes, larger items are dropped. */
|
|
329
|
+
payload: Record<string, unknown> | unknown[];
|
|
330
|
+
/** `^[A-Za-z0-9_-]{1,16}$`; defaults to one random id per tracker instance (page). */
|
|
331
|
+
pageId?: string;
|
|
332
|
+
/** Probe config hash, `^[A-Za-z0-9_-]{1,16}$`. */
|
|
333
|
+
cfg?: string;
|
|
334
|
+
ctx?: ProbeContext;
|
|
335
|
+
/** Capture time, unix ms; defaults to now. */
|
|
336
|
+
ts?: number;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A probe item on the wire (`probes` array of the events endpoint payload).
|
|
340
|
+
*
|
|
341
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
342
|
+
*/
|
|
343
|
+
interface ProbeEntry {
|
|
344
|
+
/** Client-generated idempotency id (uuidv7); kept across retries. */
|
|
345
|
+
id: string;
|
|
346
|
+
kind: string;
|
|
347
|
+
/** Capture time, unix ms. */
|
|
348
|
+
ts: number;
|
|
349
|
+
pageId: string;
|
|
350
|
+
/** Per `pageId`, starting at 0; gaps mean loss. */
|
|
351
|
+
seq: number;
|
|
352
|
+
cfg?: string;
|
|
353
|
+
ctx?: ProbeContext;
|
|
354
|
+
payload: Record<string, unknown> | unknown[];
|
|
355
|
+
}
|
|
310
356
|
/**
|
|
311
357
|
* Why a delivery attempt happened. Each value maps 1:1 to one flush trigger, so server-side
|
|
312
358
|
* analyses can tell which triggers actually carry the traffic and whether the trigger switches and
|
|
@@ -370,6 +416,8 @@ interface EventBatch {
|
|
|
370
416
|
sdk: SdkInfo;
|
|
371
417
|
lows?: LowEvent[];
|
|
372
418
|
telemetry?: TelemetryEntry[];
|
|
419
|
+
/** Probe items (internal diagnostics captured by autocapture bundles); a batch may carry probes only. */
|
|
420
|
+
probes?: ProbeEntry[];
|
|
373
421
|
meta?: EventBatchMeta;
|
|
374
422
|
}
|
|
375
423
|
type DeviceType = "web" | "app" | "other";
|
|
@@ -512,20 +560,17 @@ interface SdkReliabilityConfig {
|
|
|
512
560
|
*/
|
|
513
561
|
flushOnFlowTypeFinished: FlowType[];
|
|
514
562
|
/**
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
* Read at collection time, so a config that arrives mid-load applies from the next device info
|
|
520
|
-
* refresh onward. The very first collection of a load booting on the built-in defaults (nothing
|
|
521
|
-
* cached) always runs on the default.
|
|
563
|
+
* @deprecated No effect since device info is collected with built-in deadlines (a fast snapshot
|
|
564
|
+
* within 300 ms, slower fields as a later update within 3000 ms). Still parsed so older server
|
|
565
|
+
* configs keep loading; the backend keeps serving it for older SDK versions.
|
|
522
566
|
*/
|
|
523
567
|
deviceInfoCollectorTimeoutMs: number;
|
|
524
568
|
/**
|
|
525
|
-
* When true (and `telemetry` is enabled),
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
569
|
+
* When true (and `telemetry` is enabled), device info collection emits `info` telemetry entries:
|
|
570
|
+
* the fast snapshot's total and per-field durations in milliseconds, the late fields' outcome, the
|
|
571
|
+
* `privateMode` source (cache age, detection duration or timeout) and how the update was delivered
|
|
572
|
+
* (or that it was left undelivered at pagehide / destroy). Defaults to false: this is a diagnostic
|
|
573
|
+
* stream to switch on while investigating slow collection, not something to run permanently.
|
|
529
574
|
*/
|
|
530
575
|
deviceInfoTiming: boolean;
|
|
531
576
|
/** Serialize explicitly supplied raw error diagnostics. Defaults to true; refreshes apply to subsequent errors. Already queued events are unchanged. */
|
|
@@ -1541,10 +1586,9 @@ interface TrackerOptions {
|
|
|
1541
1586
|
/** Minimum time between attaching cached device info to events. */
|
|
1542
1587
|
deviceInfoDebounceTime?: number;
|
|
1543
1588
|
/**
|
|
1544
|
-
* @deprecated
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1547
|
-
* cached it wins. It will be removed in a future release.
|
|
1589
|
+
* @deprecated No effect: device info is collected with built-in deadlines (a fast snapshot within
|
|
1590
|
+
* 300 ms, slower fields as a later update within 3000 ms). Still accepted so existing integrations
|
|
1591
|
+
* keep compiling. It will be removed in a future release.
|
|
1548
1592
|
*/
|
|
1549
1593
|
deviceInfoCollectorTimeout?: number;
|
|
1550
1594
|
defaultTags?: Record<string, string>;
|
|
@@ -1615,6 +1659,9 @@ declare class CorbadoTracker {
|
|
|
1615
1659
|
private telemetryReady;
|
|
1616
1660
|
private readonly reportedTelemetryKeys;
|
|
1617
1661
|
private pendingSelfTelemetry;
|
|
1662
|
+
/** Default probe page id (one per tracker instance) and the probe seq counter per page id. */
|
|
1663
|
+
private probePageId?;
|
|
1664
|
+
private readonly probeSeqs;
|
|
1618
1665
|
private windowObserver?;
|
|
1619
1666
|
private passwordManagerSampler?;
|
|
1620
1667
|
/** @internal Shared passive page observation and per-operation context registration. */
|
|
@@ -2024,10 +2071,36 @@ declare class CorbadoTracker {
|
|
|
2024
2071
|
* PII — telemetry is for diagnostics only. Like all SDK entry points, this never throws.
|
|
2025
2072
|
*/
|
|
2026
2073
|
telemetry(level: TelemetryLevel, message: string): void;
|
|
2074
|
+
/**
|
|
2075
|
+
* Queue a probe item (diagnostic capture produced by a Corbado autocapture bundle).
|
|
2076
|
+
*
|
|
2077
|
+
* @remarks
|
|
2078
|
+
* The SDK fills `id` (uuidv7), `seq` (per `pageId`), `pageId` (default: one random id per tracker
|
|
2079
|
+
* instance) and `ts` (default: now). Items are held in memory only (never the durable outbox) and
|
|
2080
|
+
* ride the regular batches; they are the lowest priority at page unload. Invalid input is dropped.
|
|
2081
|
+
* The payload must already be redacted. Blocked user agents are skipped. Never throws.
|
|
2082
|
+
*
|
|
2083
|
+
* @experimental Internal: used by Corbado autocapture bundles. Not part of the documented API.
|
|
2084
|
+
* @internal
|
|
2085
|
+
*/
|
|
2086
|
+
probe(input: ProbeInput): void;
|
|
2087
|
+
private defaultProbePageId;
|
|
2088
|
+
private nextProbeSeq;
|
|
2027
2089
|
/** Convenience wrapper for {@link CorbadoTracker.telemetry} at `info` level. */
|
|
2028
2090
|
logInfo(message: string): void;
|
|
2029
2091
|
/** Convenience wrapper for {@link CorbadoTracker.telemetry} at `error` level. */
|
|
2030
2092
|
logError(message: string): void;
|
|
2093
|
+
/**
|
|
2094
|
+
* Queue hook run right before an event batch is sent: a device info snapshot that no event carried
|
|
2095
|
+
* yet (typically the fast snapshot after a burst of events at page load, or the privateMode update)
|
|
2096
|
+
* rides the first event of this page in the batch that has none. Events of other pages (outbox
|
|
2097
|
+
* replays) are never touched, and nothing is sent just for device info. When the page goes away
|
|
2098
|
+
* with a snapshot nothing could carry, that is reported (timing diagnostics only).
|
|
2099
|
+
*
|
|
2100
|
+
* Error situations:
|
|
2101
|
+
* - Any error: log "Failed to attach device info to batch" and send the batch unchanged
|
|
2102
|
+
*/
|
|
2103
|
+
private attachUndeliveredDeviceInfo;
|
|
2031
2104
|
/**
|
|
2032
2105
|
* Escalate an internal SDK diagnostic to the telemetry stream (self-instrumentation). This is the
|
|
2033
2106
|
* sink behind {@link Logger.reportTelemetry}; chosen internal failure sites route here so faults
|
|
@@ -2270,6 +2343,23 @@ interface TransportOptions {
|
|
|
2270
2343
|
headers?: Record<string, string>;
|
|
2271
2344
|
}
|
|
2272
2345
|
|
|
2346
|
+
/** In-memory probe queue caps (oldest items are dropped beyond them). */
|
|
2347
|
+
declare const PROBE_QUEUE_MAX_ITEMS = 500;
|
|
2348
|
+
declare const PROBE_QUEUE_MAX_BYTES: number;
|
|
2349
|
+
/** Per-request probe caps (the server keeps at most 200 probe items per batch). */
|
|
2350
|
+
declare const PROBE_BATCH_MAX_ITEMS = 200;
|
|
2351
|
+
declare const PROBE_BATCH_MAX_BYTES: number;
|
|
2352
|
+
/** Serialized payload cap per probe item (server rule). */
|
|
2353
|
+
declare const PROBE_PAYLOAD_MAX_BYTES: number;
|
|
2354
|
+
/**
|
|
2355
|
+
* Unload request budget shared by the event beacon and the probe beacon that follows it: unload
|
|
2356
|
+
* transports share a ~64 KB in-flight budget per page (same limit as the fetch keepalive cap).
|
|
2357
|
+
*/
|
|
2358
|
+
declare const UNLOAD_BUDGET_BYTES = 60000;
|
|
2359
|
+
/** Absolute cap of the probe request at pagehide / destroy. */
|
|
2360
|
+
declare const UNLOAD_PROBE_MAX_BYTES = 32000;
|
|
2361
|
+
/** UTF-8 byte length of a string (no TextEncoder dependency). */
|
|
2362
|
+
declare function utf8Length(text: string): number;
|
|
2273
2363
|
interface QueueOptions {
|
|
2274
2364
|
/**
|
|
2275
2365
|
* Maximum number of events per request (payload cap). A backlog larger than this is drained in
|
|
@@ -2299,6 +2389,14 @@ interface QueueOptions {
|
|
|
2299
2389
|
* none has ever been set. Read at send time so a change applies to the next batch without a flush.
|
|
2300
2390
|
*/
|
|
2301
2391
|
getDataPolicy?: () => number | undefined;
|
|
2392
|
+
/**
|
|
2393
|
+
* Called with the events of every event batch right before it is sent (async and unload flushes),
|
|
2394
|
+
* before the batch's telemetry is taken. The tracker uses it to attach a device info snapshot that
|
|
2395
|
+
* no event carried yet to an event of the current page. It may mutate the events; the in-memory
|
|
2396
|
+
* pending entries share them, so a retry on this page keeps the change. Never called for batches
|
|
2397
|
+
* without events.
|
|
2398
|
+
*/
|
|
2399
|
+
beforeEventBatchSend?: (events: Event[], reason: FlushReason) => void;
|
|
2302
2400
|
}
|
|
2303
2401
|
/**
|
|
2304
2402
|
* @remarks When `window` is defined, `visibilitychange` (when the document becomes hidden) and `pagehide`
|
|
@@ -2335,6 +2433,16 @@ declare class RequestQueue {
|
|
|
2335
2433
|
* the flush timer (it piggybacks), unless `config.flushOnTelemetry` escalates to an immediate flush.
|
|
2336
2434
|
*/
|
|
2337
2435
|
private telemetryQueue;
|
|
2436
|
+
/**
|
|
2437
|
+
* Probe items (`tracker.probe()`): in memory only — never the durable outbox — capped by
|
|
2438
|
+
* {@link PROBE_QUEUE_MAX_ITEMS} / {@link PROBE_QUEUE_MAX_BYTES}. They arm the flush timer, ride
|
|
2439
|
+
* the regular batches (probe-only batches allowed), retry under `config.retry`, and are the lowest
|
|
2440
|
+
* priority at unload (a separate request after the event request, within the remaining budget).
|
|
2441
|
+
*/
|
|
2442
|
+
private probeQueue;
|
|
2443
|
+
private probeBytes;
|
|
2444
|
+
/** Probe items dropped on this load (caps, permanent rejection, exhausted retries, unload budget). */
|
|
2445
|
+
private probesDropped;
|
|
2338
2446
|
private timer;
|
|
2339
2447
|
private isFlushing;
|
|
2340
2448
|
private flushingDone?;
|
|
@@ -2353,6 +2461,7 @@ declare class RequestQueue {
|
|
|
2353
2461
|
private readonly requestConfig;
|
|
2354
2462
|
private readonly onConfigReceived?;
|
|
2355
2463
|
private readonly getDataPolicy?;
|
|
2464
|
+
private readonly beforeEventBatchSend?;
|
|
2356
2465
|
/** Current delivery policy, including live updates. */
|
|
2357
2466
|
private config;
|
|
2358
2467
|
/**
|
|
@@ -2395,6 +2504,30 @@ declare class RequestQueue {
|
|
|
2395
2504
|
* - Any error while enqueueing or triggering the flush: log "Failed to enqueue telemetry"
|
|
2396
2505
|
*/
|
|
2397
2506
|
enqueueTelemetry(entry: TelemetryEntry): void;
|
|
2507
|
+
/**
|
|
2508
|
+
* Queue a probe item (in memory only). The payload is snapshotted (serialized once) so later host
|
|
2509
|
+
* mutations cannot change it; items over {@link PROBE_PAYLOAD_MAX_BYTES} are dropped, and the
|
|
2510
|
+
* oldest items are dropped beyond the queue caps. Arms the normal flush timer.
|
|
2511
|
+
*
|
|
2512
|
+
* Error situations:
|
|
2513
|
+
* - Any error while enqueueing or scheduling the flush timer: log "Failed to enqueue probe"
|
|
2514
|
+
*/
|
|
2515
|
+
enqueueProbe(entry: ProbeEntry, capturedSessionId?: string): void;
|
|
2516
|
+
/** Number of probe items dropped on this load (diagnostics / tests). */
|
|
2517
|
+
droppedProbeCount(): number;
|
|
2518
|
+
private dueProbes;
|
|
2519
|
+
/** Oldest-first selection for one session, within an item and byte cap (at least one item when any fits the item cap). */
|
|
2520
|
+
private selectProbes;
|
|
2521
|
+
private removeProbes;
|
|
2522
|
+
private dropProbes;
|
|
2523
|
+
/** Same policy as events: 2xx delivered, non-retryable dropped, retryable backed off up to `config.retry.maxAttempts`. */
|
|
2524
|
+
private handleProbeSendResult;
|
|
2525
|
+
/**
|
|
2526
|
+
* Unload / final teardown: one probe-only request for the current session within `budget` bytes,
|
|
2527
|
+
* sent after the event request so the events' delivery is unaffected. Leftovers are dropped when
|
|
2528
|
+
* `dropRest` (pagehide, destroy); otherwise they stay queued.
|
|
2529
|
+
*/
|
|
2530
|
+
private sendUnloadProbes;
|
|
2398
2531
|
private scheduleAfterEnqueue;
|
|
2399
2532
|
/**
|
|
2400
2533
|
* Whether this event completes one of the configured priority flow types. Only the two flow
|
|
@@ -2428,6 +2561,8 @@ declare class RequestQueue {
|
|
|
2428
2561
|
* The transport later merges in `sent`/`transport`.
|
|
2429
2562
|
*/
|
|
2430
2563
|
private attachBatchMeta;
|
|
2564
|
+
/** Run the beforeEventBatchSend hook; a throwing hook must never break a flush. */
|
|
2565
|
+
private prepareEvents;
|
|
2431
2566
|
/** The data policy code from the tracker, or undefined; a throwing getter must never break a flush. */
|
|
2432
2567
|
private readDataPolicy;
|
|
2433
2568
|
private getDuePending;
|
|
@@ -2481,6 +2616,10 @@ declare class RequestQueue {
|
|
|
2481
2616
|
*/
|
|
2482
2617
|
flushKeepalive(reason?: FlushReason): void;
|
|
2483
2618
|
private flushSync;
|
|
2619
|
+
/** The event part of the unload flush; returns the serialized size of what it sent (0 = nothing). */
|
|
2620
|
+
private flushSyncEvents;
|
|
2621
|
+
/** Serialized batch size for the unload budget; on failure assume the whole budget was used. */
|
|
2622
|
+
private approximateSize;
|
|
2484
2623
|
/**
|
|
2485
2624
|
* Error situations:
|
|
2486
2625
|
* - Timer clearance or event listener removal throws: log "Failed to destroy queue lifecycle hooks"
|
|
@@ -2500,9 +2639,8 @@ declare const CONFIG_REQUEST_HEADER = "X-Corbado-Observe-Config";
|
|
|
2500
2639
|
declare const DEFAULT_FLUSH_INTERVAL_MS = 500;
|
|
2501
2640
|
declare const DEFAULT_SEQ_LOCK_TIMEOUT_MS = 50;
|
|
2502
2641
|
/**
|
|
2503
|
-
*
|
|
2504
|
-
*
|
|
2505
|
-
* response can arrive — generous enough that a slow-but-working browser API still answers.
|
|
2642
|
+
* Default of the deprecated `deviceInfoCollectorTimeoutMs` config field. Only parsed for config
|
|
2643
|
+
* compatibility: device info collection uses its own built-in deadlines (see `device.ts`).
|
|
2506
2644
|
*/
|
|
2507
2645
|
declare const DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS = 1000;
|
|
2508
2646
|
/**
|
|
@@ -2741,4 +2879,4 @@ declare function logInfo(message: string): void;
|
|
|
2741
2879
|
declare function logError(message: string): void;
|
|
2742
2880
|
declare function destroy(): Promise<void>;
|
|
2743
2881
|
|
|
2744
|
-
export { type AppConfirmationOperationCeremonyTypedError, type AppConfirmationOperationConfig, AppConfirmationOperationFull, type AppConfirmationOperationRetryReason, type AppConfirmationOperationSpecType, type AppConfirmationOperationStart, type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, CEREMONY_LOW_EVENT_TAIL_MS, CONFIG_BOUNDS, CONFIG_REQUEST_HEADER, CONFIG_STORAGE_KEY, type CaptchaOperationConfig, CaptchaOperationFull, type CaptchaOperationSpecType, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SEQ_LOCK_TIMEOUT_MS, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, type DeviceInfoDataWeb, type DeviceType, type EmailLinkContinuationConfig, EmailLinkContinuationOperation, type EmailLinkOperationConfig, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationConfig, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type ErrorStepOptions, type Event, type EventBatch, type EventBatchMeta, type EventMeta, EventStore, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowHandle, type FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, type KeyOperationConfig, KeyRegistrationOperationFull, KeySigningOperationFull, LocalStorage, type Logger, type LowEvent, type LowEventFieldRole, type LowEventInitiator, type LowEventInputEffect, type LowEventSourceKind, type MultiFlowReset, type MultiFlowStarted, NamespacedStorage, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, type ObserveSdkConfigSnapshot, OperationFull, OperationFullProvideIdentifierWithCUI, type OperationFullProvideIdentifierWithCUIConfig, type OutboxEntry, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, type PasskeyEnrollmentOperationConfig, PasskeyEnrollmentOperationFull, type PasskeyEnrollmentPostResponseStart, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, type PasskeyLoginOperationConfig, PasskeyLoginOperationFull, type PasskeyLoginPostResponseStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginCUICeremonyStart, type PasswordLoginCUIGetOptionsFinished, type PasswordLoginCUIGetOptionsStart, type PasswordLoginCUISpecType, type PasswordLoginCUITypedError, type PasswordLoginConfig, type PasswordLoginExplicitSpecType, PasswordLoginOperationFull, type PasswordLoginTypedError, type PasswordManagerExtension, type PasswordManagerExtensionName, type PredefinedEvent, type ProvideDataOperationConfig, ProvideDataOperationFull, type ProvideDataOperationPostResponseStart, type ProvideDataOperationSpecType, type ProvideDataOperationStart, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RAW_ERROR_BOUNDS, type RawErrorEnvelope, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, type SdkReliabilityConfig, type SdkReliabilityConfigOverrides, type SdkRetryConfig, type SerializeRawErrorOptions, SessionStorage, type SetFlowTagsOptions, type SmsOTPOperationConfig, type SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, type SocialLoginOperationConfig, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type SourcePathQueryMode, type SsoLoginExchangeCodeFinished, type SsoLoginExchangeCodeStart, type SsoLoginGetRedirectUrlFinished, type SsoLoginGetRedirectUrlStart, type SsoLoginOperationConfig, SsoLoginOperationFull, type SsoLoginSpecType, type StepHelper, type StepIdentifier, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TelemetryEntry, type TelemetryLevel, type TelemetrySink, type TotpOperationConfig, TotpOperationFull, type TotpOperationPostResponseStart, type TotpOperationSpecType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type TrustedDeviceBindingMetadata, type TrustedDeviceCheckConfig, TrustedDeviceCheckOperationFull, type TrustedDeviceCheckResult, type TrustedDeviceCheckStepResult, type TrustedDeviceCheckTypedError, TrustedDeviceEnrollmentOperationFull, type TrustedDeviceEnrollmentResult, type TrustedDeviceOperationConfig, type TrustedDevicePurpose, type TrustedDeviceStorage, type UserReference, type WebAuthnIdentifierProjector, type WebAuthnIdentifierProjectors, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, detectPasswordManagerExtensions, getExperiments, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, namespacedKey, parseReliabilityConfig, resetSession, resolveRawErrorLimits, resolveReliabilityConfig, sanitizeAssertionResponse, sanitizeCreationOptions, sanitizeCreationResponse, sanitizeRequestOptions, serializeRawError, setExperiment, setExperiments, setFlowTags, setUser, telemetry };
|
|
2882
|
+
export { type AppConfirmationOperationCeremonyTypedError, type AppConfirmationOperationConfig, AppConfirmationOperationFull, type AppConfirmationOperationRetryReason, type AppConfirmationOperationSpecType, type AppConfirmationOperationStart, type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, CEREMONY_LOW_EVENT_TAIL_MS, CONFIG_BOUNDS, CONFIG_REQUEST_HEADER, CONFIG_STORAGE_KEY, type CaptchaOperationConfig, CaptchaOperationFull, type CaptchaOperationSpecType, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SEQ_LOCK_TIMEOUT_MS, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, type DeviceInfoDataWeb, type DeviceType, type EmailLinkContinuationConfig, EmailLinkContinuationOperation, type EmailLinkOperationConfig, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationConfig, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type ErrorStepOptions, type Event, type EventBatch, type EventBatchMeta, type EventMeta, EventStore, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowHandle, type FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, type KeyOperationConfig, KeyRegistrationOperationFull, KeySigningOperationFull, LocalStorage, type Logger, type LowEvent, type LowEventFieldRole, type LowEventInitiator, type LowEventInputEffect, type LowEventSourceKind, type MultiFlowReset, type MultiFlowStarted, NamespacedStorage, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, type ObserveSdkConfigSnapshot, OperationFull, OperationFullProvideIdentifierWithCUI, type OperationFullProvideIdentifierWithCUIConfig, type OutboxEntry, PROBE_BATCH_MAX_BYTES, PROBE_BATCH_MAX_ITEMS, PROBE_PAYLOAD_MAX_BYTES, PROBE_QUEUE_MAX_BYTES, PROBE_QUEUE_MAX_ITEMS, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, type PasskeyEnrollmentOperationConfig, PasskeyEnrollmentOperationFull, type PasskeyEnrollmentPostResponseStart, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, type PasskeyLoginOperationConfig, PasskeyLoginOperationFull, type PasskeyLoginPostResponseStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginCUICeremonyStart, type PasswordLoginCUIGetOptionsFinished, type PasswordLoginCUIGetOptionsStart, type PasswordLoginCUISpecType, type PasswordLoginCUITypedError, type PasswordLoginConfig, type PasswordLoginExplicitSpecType, PasswordLoginOperationFull, type PasswordLoginTypedError, type PasswordManagerExtension, type PasswordManagerExtensionName, type PredefinedEvent, type ProbeContext, type ProbeEntry, type ProbeInput, type ProvideDataOperationConfig, ProvideDataOperationFull, type ProvideDataOperationPostResponseStart, type ProvideDataOperationSpecType, type ProvideDataOperationStart, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RAW_ERROR_BOUNDS, type RawErrorEnvelope, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, type SdkReliabilityConfig, type SdkReliabilityConfigOverrides, type SdkRetryConfig, type SerializeRawErrorOptions, SessionStorage, type SetFlowTagsOptions, type SmsOTPOperationConfig, type SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, type SocialLoginOperationConfig, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type SourcePathQueryMode, type SsoLoginExchangeCodeFinished, type SsoLoginExchangeCodeStart, type SsoLoginGetRedirectUrlFinished, type SsoLoginGetRedirectUrlStart, type SsoLoginOperationConfig, SsoLoginOperationFull, type SsoLoginSpecType, type StepHelper, type StepIdentifier, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TelemetryEntry, type TelemetryLevel, type TelemetrySink, type TotpOperationConfig, TotpOperationFull, type TotpOperationPostResponseStart, type TotpOperationSpecType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type TrustedDeviceBindingMetadata, type TrustedDeviceCheckConfig, TrustedDeviceCheckOperationFull, type TrustedDeviceCheckResult, type TrustedDeviceCheckStepResult, type TrustedDeviceCheckTypedError, TrustedDeviceEnrollmentOperationFull, type TrustedDeviceEnrollmentResult, type TrustedDeviceOperationConfig, type TrustedDevicePurpose, type TrustedDeviceStorage, UNLOAD_BUDGET_BYTES, UNLOAD_PROBE_MAX_BYTES, type UserReference, type WebAuthnIdentifierProjector, type WebAuthnIdentifierProjectors, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, detectPasswordManagerExtensions, getExperiments, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, namespacedKey, parseReliabilityConfig, resetSession, resolveRawErrorLimits, resolveReliabilityConfig, sanitizeAssertionResponse, sanitizeCreationOptions, sanitizeCreationResponse, sanitizeRequestOptions, serializeRawError, setExperiment, setExperiments, setFlowTags, setUser, telemetry, utf8Length };
|