@corbado/observe 0.15.0 → 0.15.2

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/index.d.mts CHANGED
@@ -3,8 +3,10 @@ interface SdkInfo {
3
3
  version: string;
4
4
  }
5
5
  type EventType = "predefined" | "custom" | "error" | "identify";
6
- type AuthMethodType = "identifier-email" | "passkey-login-known-identifier" | "passkey-login-no-identifier" | "passkey-login-cui" | "passkey-login-immediate" | "passkey-enrollment" | "password-login" | "password-login-known-identifier" | "password-login-with-identifier" | "password-enrollment" | "email-otp" | "email-otp-login" | "email-otp-enrollment" | "email-link" | "email-link-login" | "email-link-enrollment" | "sms-otp" | "sms-otp-login" | "sms-otp-enrollment" | "social-google" | "social-apple" | "social-facebook" | "social-other" | "reset-flow" | "provide-data";
7
- type SubflowType = "passkey-enrollment" | "passkey-login" | "email-otp" | "email-link" | "social-login" | "sms-otp" | "provide-identifier" | "provide-data" | "password-login" | "password-enrollment" | "totp" | "app-confirmation" | "captcha";
6
+ type AuthMethodType = "identifier-email"
7
+ /** Neutral "enter an identifier" choice; the identifier kind is the provide-identifier spec type. */
8
+ | "identifier" | "passkey-login-known-identifier" | "passkey-login-no-identifier" | "passkey-login-cui" | "passkey-login-immediate" | "passkey-enrollment" | "password-login" | "password-login-known-identifier" | "password-login-with-identifier" | "password-enrollment" | "email-otp" | "email-otp-login" | "email-otp-enrollment" | "email-link" | "email-link-login" | "email-link-enrollment" | "sms-otp" | "sms-otp-login" | "sms-otp-enrollment" | "social-google" | "social-apple" | "social-facebook" | "social-other" | "reset-flow" | "provide-data";
9
+ type SubflowType = "trusted-device-check" | "trusted-device-enrollment" | "passkey-enrollment" | "passkey-login" | "email-otp" | "email-link" | "social-login" | "sms-otp" | "provide-identifier" | "provide-data" | "password-login" | "password-enrollment" | "totp" | "app-confirmation" | "captcha";
8
10
  type FlowType = "login" | "signup" | "recovery" | "enrollment" | (string & {});
9
11
  type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "other";
10
12
  declare enum AuthEventName {
@@ -148,7 +150,7 @@ type AuthDecisionFinished = {
148
150
  explicitDecisionValue?: string;
149
151
  };
150
152
  type StepOptions = {
151
- /** Semantic control that explicitly initiated this step; omitted when unknown. */
153
+ /** Optional initiator override. Passkey ceremonies infer it from the operation/step spec when omitted. */
152
154
  initiator?: LowEventInitiator;
153
155
  /** @internal Session captured with the operation start; never sent as event metadata. */
154
156
  captureSessionId?: string;
@@ -343,32 +345,24 @@ type ObserveSdkConfigSnapshot = {
343
345
  readonly aap: string;
344
346
  };
345
347
  /**
346
- * SDK reliability configuration returned by the events endpoint (opt-in via the
347
- * `X-Corbado-Observe-Config` header). Mirrors the server `observeEventCreateRes` schema.
348
- * All delivery-reliability features default OFF until the server returns config.
349
- *
350
- * @remarks
351
- * Boot-snapshot model: the config resolved at construction (from the localStorage cache) is the
352
- * config for the entire page load. A config received from the server during the load is only
353
- * cached for the NEXT load, never applied live — this keeps session identity, seq source and
354
- * outbox mode coherent within one load.
348
+ * Resolved browser SDK reliability policy. Init overrides take precedence over server policy and defaults.
349
+ * Session continuity and durable outbox can activate on any refresh and stay enabled for the rest of the document.
355
350
  */
356
351
  interface SdkReliabilityConfig {
357
352
  /**
358
- * Content-derived version (hash) assigned by the server. Echoed in the config request header so
359
- * the server can answer 204 when nothing changed, and stamped into every batch's
360
- * `meta.configVersion`. Empty string for the built-in defaults (nothing cached yet).
353
+ * Content-derived version assigned by the server, or a non-empty identifier for injected config.
354
+ * Stamped into every batch's meta.configVersion. Empty when neither the server nor init overrides supply a version.
361
355
  */
362
356
  version: string;
363
357
  /** How often the SDK flushes its event queue, in milliseconds. */
364
358
  flushIntervalMs: number;
365
- /** Persist queued events to a durable outbox so they survive reloads, redirects and context switches. */
359
+ /** Persist queued events across reloads, redirects and context switches. Can activate on any refresh; deactivation takes effect on the next initialization. */
366
360
  durableOutbox: boolean;
367
361
  /** Persist lows in a separate bounded outbox; defaults to disabled for older configs. */
368
362
  durableLowOutbox?: boolean;
369
363
  /** Use keepalive/sendBeacon transport for flushes triggered during page unload. */
370
364
  beaconKeepalive: boolean;
371
- /** Maintain session continuity across reloads/tabs by persisting the session id in localStorage. */
365
+ /** Maintain session continuity across reloads/tabs. Can activate on any refresh; deactivation takes effect on the next initialization. */
372
366
  sessionContinuity: boolean;
373
367
  /**
374
368
  * Inactivity threshold for continuity sessions, in milliseconds. When more time than this has
@@ -402,8 +396,8 @@ interface SdkReliabilityConfig {
402
396
  tlf: boolean;
403
397
  /**
404
398
  * Master switch for the diagnostic telemetry stream. When true the SDK sends buffered telemetry
405
- * entries piggybacked on normal event requests; when false it collects and sends nothing. Defaults
406
- * to true (telemetry is on out of the box) and can be turned off server-side without a redeploy.
399
+ * entries piggybacked on normal event requests. When false it stops collection, but already buffered
400
+ * entries can still be sent. Defaults to true and can be turned off server-side without a redeploy.
407
401
  */
408
402
  telemetry: boolean;
409
403
  /**
@@ -446,6 +440,10 @@ interface SdkReliabilityConfig {
446
440
  /** Retry configuration for failed event flushes. */
447
441
  retry: SdkRetryConfig;
448
442
  }
443
+ /** Optional init overrides; omitted fields (including nested retry fields) inherit server policy or defaults. */
444
+ type SdkReliabilityConfigOverrides = Partial<Omit<SdkReliabilityConfig, "retry">> & {
445
+ retry?: Partial<SdkRetryConfig>;
446
+ };
449
447
 
450
448
  /** Sink that escalates a diagnostic message to the telemetry stream. */
451
449
  type TelemetrySink = (level: TelemetryLevel, message: string) => void;
@@ -521,6 +519,98 @@ interface LowEventSink {
521
519
  };
522
520
  }
523
521
 
522
+ /**
523
+ * Limits for optional raw-error serialization. Modeled on Sentry's client options
524
+ * (`normalizeDepth`, `normalizeMaxBreadth`, `maxValueLength`, `normalizeToSize`, the
525
+ * stack-frame limit and the linked-errors limit) with defaults tuned for an authentication
526
+ * event stream rather than an error monitor. Every value is clamped to {@link RAW_ERROR_BOUNDS};
527
+ * invalid values fall back to the default.
528
+ */
529
+ type SerializeRawErrorOptions = {
530
+ /** Include `stack` strings. Default false. */
531
+ stack?: boolean;
532
+ /** Stack lines kept after the header line when `stack` is on. Default 50 (Sentry: 50). */
533
+ maxStackFrames?: number;
534
+ /** Object nesting depth below the envelope. Default 3 (Sentry `normalizeDepth`: 3). */
535
+ depth?: number;
536
+ /** Keys per object and items per array, Map or Set. Default 30 (Sentry `normalizeMaxBreadth`: 1000). */
537
+ maxBreadth?: number;
538
+ /** Characters kept per string. Default 1024 (Sentry `maxValueLength`: 250). */
539
+ maxValueLength?: number;
540
+ /** `cause` hops followed. Default 3 (Sentry linked errors: 5, Datadog: 10). */
541
+ maxCauseDepth?: number;
542
+ /** Maximum UTF-8 JSON size in bytes. Depth is reduced until the output fits; omit diagnostics that cannot fit. Default 32768 (Sentry `normalizeToSize`: 100 KiB). */
543
+ maxBytes?: number;
544
+ };
545
+ /** Envelope produced by {@link serializeRawError}. */
546
+ type RawErrorEnvelope = {
547
+ /** Class tag of the original value: `DOMException`, `Error`, `Object`, `Response`, `number`, `null`, `unserializable`, … */
548
+ type: string;
549
+ /** Bounded plain-JSON copy of the value; absent when it could not be serialized within the limits. */
550
+ value?: unknown;
551
+ /** Set when even the shallowest serialization exceeded `maxBytes`. */
552
+ truncated?: true;
553
+ };
554
+ type Limits = Required<Omit<SerializeRawErrorOptions, "stack">> & {
555
+ stack: boolean;
556
+ };
557
+ /** Inclusive bounds for every numeric limit; defaults sit inside them. */
558
+ declare const RAW_ERROR_BOUNDS: {
559
+ readonly maxStackFrames: {
560
+ readonly min: 1;
561
+ readonly max: 100;
562
+ readonly default: 50;
563
+ };
564
+ readonly depth: {
565
+ readonly min: 0;
566
+ readonly max: 10;
567
+ readonly default: 3;
568
+ };
569
+ readonly maxBreadth: {
570
+ readonly min: 1;
571
+ readonly max: 1000;
572
+ readonly default: 30;
573
+ };
574
+ readonly maxValueLength: {
575
+ readonly min: 1;
576
+ readonly max: 10000;
577
+ readonly default: 1024;
578
+ };
579
+ readonly maxCauseDepth: {
580
+ readonly min: 0;
581
+ readonly max: 10;
582
+ readonly default: 3;
583
+ };
584
+ readonly maxBytes: {
585
+ readonly min: 0;
586
+ readonly max: 65536;
587
+ readonly default: 32768;
588
+ };
589
+ };
590
+ /** Resolve caller options into clamped limits. Exported for tests and integrations that want to inspect the effective values. */
591
+ declare function resolveRawErrorLimits(options?: SerializeRawErrorOptions): Limits;
592
+ /**
593
+ * Serialize an arbitrary thrown value for the `rawError` diagnostic field.
594
+ *
595
+ * Copies standard error fields and serializable own properties within the configured limits.
596
+ * Standard fields are read through the prototype chain so DOMException and cross-realm errors
597
+ * serialize. Output is plain JSON, bounded in depth, breadth, string length, cause chain and
598
+ * UTF-8 size, and never throws.
599
+ *
600
+ * The result is an envelope `{ type, value }`: `type` is the value's class tag (`DOMException`,
601
+ * `Error`, `Object`, `number`, …) and `value` is a bounded diagnostic copy. Keeping the class tag
602
+ * outside value preserves the library's own `type` field. When the value cannot be serialized
603
+ * within the limits the envelope carries `truncated: true` or the type `unserializable` and no
604
+ * `value`.
605
+ *
606
+ * Stacks are omitted unless `stack: true`; they carry page URLs and add the most bytes.
607
+ * Binary data (ArrayBuffer, typed arrays) is reported by type and length only, never by content.
608
+ *
609
+ * @param value - Original thrown value or an explicit diagnostic projection.
610
+ * @param options - Limits; see {@link SerializeRawErrorOptions} for defaults and {@link RAW_ERROR_BOUNDS} for clamping.
611
+ */
612
+ declare function serializeRawError(value: unknown, options?: SerializeRawErrorOptions): RawErrorEnvelope | undefined;
613
+
524
614
  /** Ceremony context lease on the shared observer. Never installs its own window listeners. */
525
615
  declare class LowEventWindowTracker {
526
616
  private logger;
@@ -539,12 +629,56 @@ declare class LowEventWindowTracker {
539
629
  * picker dismiss animations land shortly after the WebAuthn promise resolves/rejects.
540
630
  */
541
631
  declare const CEREMONY_LOW_EVENT_TAIL_MS = 1500;
632
+ /**
633
+ * Optional diagnostic context for both normal and typed step errors.
634
+ *
635
+ * Use `rawError` when a library error contains useful context beyond its classified name,
636
+ * code and message, such as a nested cause, an error array or a response status.
637
+ * It is emitted as a bounded `{ type, value }` envelope in `stepData.rawError` for raw-event
638
+ * inspection. The envelope type describes the JavaScript value; the library's own fields
639
+ * stay inside value. See {@link serializeRawError} for serialization limits.
640
+ *
641
+ * @remarks
642
+ * The first argument to `.error()` or `.errorTyped()` supplies the classified diagnostic.
643
+ * `rawError` does not fill missing classified fields or affect outcomes, error-group assignment
644
+ * or severity: a code-only typed error remains code-only even if its raw diagnostic has a name
645
+ * and message. Existing StepOptions such as userReference and explicitTimestamp can accompany
646
+ * rawError; calls without it behave as before.
647
+ *
648
+ * Supply a deliberate diagnostic object without credentials, cookies or personal data.
649
+ * Arrays retain their structure in rawError; arrays passed directly to `.error()` become a
650
+ * string message. Keep the original error for application handling; serialization makes a copy.
651
+ *
652
+ * @example
653
+ * ```ts
654
+ * // Normal error with additional provider context.
655
+ * passkey.ceremony.error(originalError, { rawError: providerDiagnostic });
656
+ *
657
+ * // Typed error with the original error available for inspection.
658
+ * password.postResponse.errorTyped(
659
+ * { code: "invalid_password" },
660
+ * { rawError: originalError },
661
+ * );
662
+ *
663
+ * // A classified code and message plus additional raw context.
664
+ * password.postResponse.error(
665
+ * { code: "invalid_password", name: "AuthenticationError", message: "The password was rejected" },
666
+ * { rawError: providerDiagnostic },
667
+ * );
668
+ * ```
669
+ */
670
+ type ErrorStepOptions = StepOptions & {
671
+ /** Explicit opt-in. Serialized with bounded depth and UTF-8 size; stacks are omitted by default and binary contents are summarized. */
672
+ rawError?: unknown;
673
+ /** Per-call limits for `rawError` serialization (depth, breadth, string length, cause chain, bytes, stack). See {@link SerializeRawErrorOptions}. */
674
+ rawErrorLimits?: SerializeRawErrorOptions;
675
+ };
542
676
  type StepHelper<TStart = {}, TFinished = {}, TTypedError = never> = {
543
677
  start: (data: TStart, options?: StepOptions) => void;
544
678
  finished: (data: TFinished, options?: StepOptions) => void;
545
- error: (error: unknown, options?: StepOptions) => void;
679
+ error: (error: unknown, options?: ErrorStepOptions) => void;
546
680
  } & ([TTypedError] extends [never] ? {} : {
547
- errorTyped: (error: TTypedError, options?: StepOptions) => void;
681
+ errorTyped: (error: TTypedError, options?: ErrorStepOptions) => void;
548
682
  });
549
683
  declare abstract class OperationFull {
550
684
  private tracker;
@@ -581,7 +715,7 @@ declare abstract class OperationFull {
581
715
  customStep<TStart = {}, TFinished = {}>(stepName: string): StepHelper<TStart, TFinished>;
582
716
  protected subflowStepStarted(stepName: string, data: any, options?: StepOptions, ignoreAsInteraction?: boolean): void;
583
717
  protected subflowStepFinished(stepName: string, data: any, options?: StepOptions): void;
584
- protected subflowStepError(stepName: string, data: any, options?: StepOptions): void;
718
+ protected subflowStepError(stepName: string, data: any, options?: ErrorStepOptions): void;
585
719
  /**
586
720
  * Decorate a (ceremony) step so window low-event collection follows its lifecycle: `start` arms
587
721
  * the tracker, `finished`/`error`/`errorTyped` schedule disarming after
@@ -773,7 +907,7 @@ declare class PasskeyEnrollmentOperationFull extends OperationFull {
773
907
  type PasswordLoginTypedError = {
774
908
  code: PasswordLoginTypedErrorCode;
775
909
  };
776
- type PasswordLoginTypedErrorCode = "invalid_password" | "user_not_found" | "account_locked";
910
+ type PasswordLoginTypedErrorCode = "invalid_identifier_or_password" | "invalid_password" | "user_not_found" | "account_locked";
777
911
  /**
778
912
  * Conditional-UI (CUI) passkey login hosted on the password-login subflow. Mirrors the CUI step
779
913
  * family of `OperationFullProvideIdentifierWithCUI`, but the steps are emitted under
@@ -852,7 +986,7 @@ type PasskeyLoginCUITypedError = {
852
986
  code: PasskeyLoginCUITypedErrorCode;
853
987
  };
854
988
  type PasskeyLoginCUITypedErrorCode = "cancel_detected";
855
- type ProvideIdentifierSpecType = "email" | "phone";
989
+ type ProvideIdentifierSpecType = "email" | "phone" | "username";
856
990
  type ProvideIdentifierPostResponseStart = {
857
991
  explicitSpecType?: ProvideIdentifierSpecType;
858
992
  };
@@ -951,6 +1085,60 @@ declare class CaptchaOperationFull extends OperationFull {
951
1085
  constructor(tracker: CorbadoTracker, config?: CaptchaOperationConfig);
952
1086
  }
953
1087
 
1088
+ type TrustedDevicePurpose = "additional-verification" | "mfa-exemption";
1089
+ type TrustedDeviceStorage = "cookie" | "indexeddb" | "localstore" | "sessionstore";
1090
+ /** Metadata about the accepted binding. Never report cookie values, proofs or key material. */
1091
+ type TrustedDeviceBindingMetadata = {
1092
+ storage?: TrustedDeviceStorage;
1093
+ /** Stable pseudonymous reference to the binding, max 255 characters. */
1094
+ bindingReference?: string;
1095
+ /** Optional name for the trust mechanism, max 128 characters. */
1096
+ trustName?: string;
1097
+ };
1098
+ /**
1099
+ * Identity of the operation. Only `explicitSpecType` is sent on subflow_started, as for every other
1100
+ * subflow; `purpose`, `storage` and `trustName` are repeated by the helper on every step start
1101
+ * and on finished results, so they survive early completion, errors or abandonment.
1102
+ */
1103
+ type TrustedDeviceOperationConfig = {
1104
+ explicitSpecType: "token" | "key";
1105
+ purpose: TrustedDevicePurpose;
1106
+ storage: TrustedDeviceStorage;
1107
+ trustName?: string;
1108
+ };
1109
+ type TrustedDeviceCheckConfig = TrustedDeviceOperationConfig;
1110
+ type TrustedDeviceNegativeResult = "not-trusted" | "no-eligible-local-key" | "server-key-no-local-match";
1111
+ type TrustedDeviceCheckResult = TrustedDeviceBindingMetadata & {
1112
+ result: "trusted" | TrustedDeviceNegativeResult;
1113
+ };
1114
+ /** Expected negative results can settle discovery without a server verification step. */
1115
+ type TrustedDeviceCheckStepResult = {
1116
+ result?: TrustedDeviceNegativeResult;
1117
+ };
1118
+ /** Keeps the original diagnostic while reporting a typed negative check code. */
1119
+ type TrustedDeviceCheckTypedError = {
1120
+ code: "not_trusted" | "no_eligible_local_key" | "server_key_no_local_match";
1121
+ error?: unknown;
1122
+ };
1123
+ type TrustedDeviceEnrollmentResult = TrustedDeviceBindingMetadata & {
1124
+ result: "created" | "renewed" | "unchanged" | "skipped";
1125
+ };
1126
+ /** Records a host trust verdict. Discovery or signing alone is not a successful check. */
1127
+ declare class TrustedDeviceCheckOperationFull extends OperationFull {
1128
+ readonly getOptions: StepHelper<{}, TrustedDeviceCheckStepResult, TrustedDeviceCheckTypedError>;
1129
+ readonly ceremony: StepHelper<{}, TrustedDeviceCheckStepResult, TrustedDeviceCheckTypedError>;
1130
+ readonly postResponse: StepHelper<{}, TrustedDeviceCheckResult, TrustedDeviceCheckTypedError>;
1131
+ constructor(tracker: CorbadoTracker, config: TrustedDeviceCheckConfig);
1132
+ private checkStep;
1133
+ }
1134
+ /** Finish registration/renewal after host acceptance. Explicit user opt-out reports skipped without creating a binding. */
1135
+ declare class TrustedDeviceEnrollmentOperationFull extends OperationFull {
1136
+ readonly getOptions: StepHelper<{}, {}>;
1137
+ readonly ceremony: StepHelper<{}, {}>;
1138
+ readonly postResponse: StepHelper<{}, TrustedDeviceEnrollmentResult>;
1139
+ constructor(tracker: CorbadoTracker, config: TrustedDeviceOperationConfig);
1140
+ }
1141
+
954
1142
  type ProvideDataOperationSpecType = "signup" | "login" | "recovery" | "enrollment";
955
1143
  type ProvideDataOperationStart = {
956
1144
  /** Stable name of the data field collected by this subflow, when known. */
@@ -979,6 +1167,10 @@ interface TrackerOptions {
979
1167
  projectId: string;
980
1168
  apiBaseUrl: string;
981
1169
  apiEventPath?: string;
1170
+ /** Per-field overrides over server config and defaults. A complete policy disables remote fetching. */
1171
+ sdkConfig?: SdkReliabilityConfigOverrides;
1172
+ /** Config endpoint override for integrations that proxy Observe under a different path. */
1173
+ apiConfigPath?: string;
982
1174
  storage?: "cookie" | "local";
983
1175
  cookieDomain?: string;
984
1176
  debug?: boolean;
@@ -1018,12 +1210,10 @@ declare class CorbadoTracker {
1018
1210
  private persistentStorage;
1019
1211
  /** Seq/continuity Web Lock name; project-scoped together with the storage keys it guards. */
1020
1212
  private readonly seqLockName;
1021
- /**
1022
- * Reliability config for this load. A boot with a cached server config is a snapshot (immutable
1023
- * mid-load); a boot on the built-in defaults upgrades once to the first server-returned config
1024
- * (see {@link handleConfig}).
1025
- */
1213
+ /** Current resolved policy. Continuity and persistence stay enabled once activated within a document. */
1026
1214
  private config;
1215
+ private readonly configManager?;
1216
+ private readonly configOverrides;
1027
1217
  private deviceInfoManager;
1028
1218
  private deviceCollector;
1029
1219
  /**
@@ -1049,16 +1239,11 @@ declare class CorbadoTracker {
1049
1239
  /** @internal Shared passive page observation and per-operation context registration. */
1050
1240
  getWindowObserver(): SharedWindowObserver;
1051
1241
  constructor(options: TrackerOptions);
1052
- /**
1053
- * Cache fresh server config as last-known so the next page load boots with it. When this load
1054
- * booted on the built-in defaults (no cached config), the config is additionally applied live:
1055
- * every field is read at use time, and a mid-load `sessionContinuity` flip is safe because
1056
- * `nextSeq` adopts the in-memory session id into the empty continuity store instead of minting
1057
- * (no session split). A load that booted on a cached config keeps its snapshot untouched.
1058
- */
1242
+ /** Apply init overrides on every refresh; continuity and persistence only activate within a document. */
1059
1243
  private handleConfig;
1060
1244
  /**
1061
1245
  * Returns the logger used by this tracker.
1246
+ * @internal
1062
1247
  */
1063
1248
  getLogger(): Logger;
1064
1249
  private applicationTag;
@@ -1088,7 +1273,7 @@ declare class CorbadoTracker {
1088
1273
  /** Returns a copy of the currently active experiment assignments. */
1089
1274
  getExperiments(): Record<string, string>;
1090
1275
  /**
1091
- * Returns the public SDK configuration for this page load.
1276
+ * Returns the currently active public SDK configuration, including live updates.
1092
1277
  *
1093
1278
  * @returns A frozen snapshot, created fresh on every call.
1094
1279
  */
@@ -1107,7 +1292,7 @@ declare class CorbadoTracker {
1107
1292
  /**
1108
1293
  * Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
1109
1294
  * same browser. Rotates after `config.sessionInactivityMs` of inactivity (server-controlled,
1110
- * boot-snapshot like the rest of the config), resetting the seq counter.
1295
+ * evaluated at boot), resetting the seq counter.
1111
1296
  *
1112
1297
  * Inactivity rotation happens at boot only, here and on the per-tab path {@link resolveSessionId}
1113
1298
  * takes without continuity. Boot is chosen on an assumption, not a guarantee: that a load
@@ -1136,12 +1321,11 @@ declare class CorbadoTracker {
1136
1321
  * Persist the per-tab record and remember when, sharing the throttle bookkeeping with the
1137
1322
  * continuity record — a load resolves its session on one path or the other, never both.
1138
1323
  *
1139
- * Only a load that received a server config stamps the window; any other carries forward what the
1140
- * tab already knows. So a defaults boot never downgrades a tab that has already learned the
1141
- * project's threshold to the built-in one, and the window survives a rotation within the tab.
1324
+ * An explicit timeout override or server config stamps the window. Otherwise carry forward what
1325
+ * the tab already knows, so a defaults boot does not replace a previously configured threshold.
1142
1326
  */
1143
1327
  private persistPerTabSession;
1144
- /** The window this tab measures against: what a configured load recorded, else this load's own. */
1328
+ /** Explicit init timeout wins; otherwise retain the window a prior configured load recorded. */
1145
1329
  private perTabInactivityMs;
1146
1330
  /**
1147
1331
  * Return the next sequence number. With session continuity the counter is persisted so ordering
@@ -1167,13 +1351,19 @@ declare class CorbadoTracker {
1167
1351
  * sessionStorage-backed and stable for the whole page lifetime.
1168
1352
  */
1169
1353
  private resolveEventTabId;
1354
+ /** @internal */
1170
1355
  trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions, eventId?: string): void;
1356
+ /** @internal */
1171
1357
  trackSubflowTrigger(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
1358
+ /** @internal */
1172
1359
  trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions, ignoreAsInteraction?: boolean): void;
1360
+ /** @internal */
1173
1361
  trackSubflowStepFinished(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
1362
+ /** @internal */
1174
1363
  trackSubflowStepError(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
1175
1364
  /**
1176
1365
  * @remarks
1366
+ * @internal
1177
1367
  * Records an additional error occurrence against the subflow. Carries no outcome semantics —
1178
1368
  * step errors are the intended channel; not part of a normal integration.
1179
1369
  */
@@ -1440,6 +1630,47 @@ declare class CorbadoTracker {
1440
1630
  socialLoginOperationFull(config?: SocialLoginOperationConfig): SocialLoginOperationFull;
1441
1631
  appConfirmationOperationFull(config?: AppConfirmationOperationConfig): AppConfirmationOperationFull;
1442
1632
  captchaOperationFull(config?: CaptchaOperationConfig): CaptchaOperationFull;
1633
+ /**
1634
+ * Track a device-trust check through getOptions, ceremony and postResponse.
1635
+ *
1636
+ * @param config - Mechanism, purpose, storage and optional trust name.
1637
+ * @remarks
1638
+ * Only `trusted` completes the check. Negative results (`not-trusted`, `no-eligible-local-key`,
1639
+ * `server-key-no-local-match`) remain incomplete and may settle an early step. Key-specific
1640
+ * results require a key mechanism; the server-specific result requires explicit evidence.
1641
+ * Use `errorTyped({ code, error })` to retain an original diagnostic with a negative result,
1642
+ * or `error(error)` for an unexpected failure. An accepted result may include a stable
1643
+ * pseudonymous `bindingReference`; never send cookie values, proofs or key material.
1644
+ * @example
1645
+ * ```ts
1646
+ * const check = tracker.trustedDeviceCheckOperationFull({
1647
+ * explicitSpecType: "key", storage: "indexeddb", purpose: "additional-verification",
1648
+ * });
1649
+ * check.ceremony.start({});
1650
+ * // On a recognized local-key failure:
1651
+ * check.ceremony.errorTyped({ code: "no_eligible_local_key", error: originalError });
1652
+ * ```
1653
+ */
1654
+ trustedDeviceCheckOperationFull(config: TrustedDeviceCheckConfig): TrustedDeviceCheckOperationFull;
1655
+ /**
1656
+ * Track device-trust enrollment through getOptions, ceremony and postResponse.
1657
+ *
1658
+ * @param config - Mechanism, purpose, storage and optional trust name.
1659
+ * @remarks
1660
+ * Report `created`, `renewed` or `unchanged` after host acceptance. Explicit opt-out is `skipped`;
1661
+ * an unanswered operation remains incomplete. User identity uses the existing `setUser` API.
1662
+ * Missing or unsupported purpose/storage logs a warning and is omitted; the operation remains usable.
1663
+ * @example
1664
+ * ```ts
1665
+ * const enrollment = tracker.trustedDeviceEnrollmentOperationFull({
1666
+ * explicitSpecType: "token", storage: "cookie", purpose: "mfa-exemption",
1667
+ * });
1668
+ * enrollment.postResponse.start({});
1669
+ * // After the host grants browser trust:
1670
+ * enrollment.postResponse.finished({ result: "created", bindingReference });
1671
+ * ```
1672
+ */
1673
+ trustedDeviceEnrollmentOperationFull(config: TrustedDeviceOperationConfig): TrustedDeviceEnrollmentOperationFull;
1443
1674
  /**
1444
1675
  * Flush any pending events and release all resources (timers, event listeners).
1445
1676
  *
@@ -1623,16 +1854,11 @@ interface QueueOptions {
1623
1854
  */
1624
1855
  flushInterval?: number;
1625
1856
  debug?: boolean;
1626
- /**
1627
- * Reliability config for this page load; defaults to all-features-OFF. Boot-snapshot model: with
1628
- * a cached config the queue never changes its behavior mid-load — a fresh config returned by the
1629
- * server is only handed to {@link QueueOptions.onConfigReceived} for caching and applies on the
1630
- * next load. Only a defaults boot (no cached config) applies the first server config live.
1631
- */
1857
+ /** Initial delivery policy. The tracker applies later updates with updateConfig(). */
1632
1858
  config?: SdkReliabilityConfig;
1633
1859
  /** Called when the server returns a fresh config, so the client can cache it for the next load. */
1634
1860
  onConfigReceived?: (config: SdkReliabilityConfig) => void;
1635
- /** Whether to send the opt-in config header on the first flush of this load. Defaults to true. */
1861
+ /** Legacy standalone queue handshake. Trackers set false and use the independent config manager. */
1636
1862
  requestConfig?: boolean;
1637
1863
  /**
1638
1864
  * Web Lock name for the durable outbox, scoped alongside the storage engine's keys (see
@@ -1692,11 +1918,7 @@ declare class RequestQueue {
1692
1918
  private readonly debug;
1693
1919
  private readonly requestConfig;
1694
1920
  private readonly onConfigReceived?;
1695
- /**
1696
- * Reliability config for this load. A boot with a cached server config is a snapshot that never
1697
- * changes mid-load; a boot on the built-in defaults upgrades once to the first server-returned
1698
- * config (see {@link handleConfigResponse}).
1699
- */
1921
+ /** Current delivery policy, including live updates. */
1700
1922
  private config;
1701
1923
  /**
1702
1924
  * Flow types whose completion triggers an immediate flush at enqueue time
@@ -1729,7 +1951,7 @@ declare class RequestQueue {
1729
1951
  * Buffer a diagnostic telemetry entry for delivery with the next event batch.
1730
1952
  *
1731
1953
  * @remarks
1732
- * The master switch `config.telemetry` gates collection: when off, nothing is buffered or sent.
1954
+ * The switch `config.telemetry` gates collection. Entries buffered while on remain eligible for delivery.
1733
1955
  * By default a telemetry entry does NOT arm the flush timer — it piggybacks the next flush caused
1734
1956
  * by events or a lifecycle signal (it is marked dirty so the unload flush picks it up). When
1735
1957
  * `config.flushOnTelemetry` is on it escalates to an immediate flush.
@@ -1787,13 +2009,8 @@ declare class RequestQueue {
1787
2009
  * reliability features.
1788
2010
  */
1789
2011
  private handleConfigResponse;
1790
- /**
1791
- * Switch this load from the built-in defaults to the first server config (defaults boot only).
1792
- * Most fields are read at use time, so replacing the reference is enough; only the derived state
1793
- * (priority flow type set, durable outbox store) needs rebuilding.
1794
- */
1795
- private applyConfigLive;
1796
- /** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
2012
+ /** Applies live delivery policy, retaining pending events, retry deadlines, and activated persistence. */
2013
+ updateConfig(config: SdkReliabilityConfig): void;
1797
2014
  private handleSendResult;
1798
2015
  private isRetryable;
1799
2016
  /**
@@ -1833,7 +2050,7 @@ declare class RequestQueue {
1833
2050
  destroy(): void;
1834
2051
  }
1835
2052
 
1836
- /** localStorage key under which the last-known server config is cached. */
2053
+ /** Last-known server config shared by batch-based and independently fetching SDK versions. */
1837
2054
  declare const CONFIG_STORAGE_KEY = "cbo_sdk_config";
1838
2055
  /**
1839
2056
  * Opt-in request header that asks the events endpoint to return the SDK reliability config. Its value
@@ -1888,11 +2105,9 @@ declare const CONFIG_BOUNDS: {
1888
2105
  /** Built-in continuity-session inactivity threshold (30 minutes); matches the historical default. */
1889
2106
  declare const DEFAULT_SESSION_INACTIVITY_MS: number;
1890
2107
  /**
1891
- * Default config: every delivery-reliability feature is OFF. The SDK behaves like a plain async
1892
- * fetch-keepalive flusher until the server returns config, which is cached as last-known for the
1893
- * next load AND applied live to the current load (a defaults boot has no prior config to stay
1894
- * coherent with; loads booting on a cached config keep their snapshot — boot-snapshot model). The
1895
- * empty version means "nothing cached"; the config request header sends "1" in that case.
2108
+ * Defaults used until a valid injected, cached, or fetched config is available.
2109
+ * Delivery-reliability features start OFF. Last-known remote config never expires.
2110
+ * Init overrides win per field; a complete override bypasses remote fetching and caching.
1896
2111
  */
1897
2112
  declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1898
2113
  /**
@@ -1905,6 +2120,8 @@ declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1905
2120
  * server value cannot harm the client.
1906
2121
  */
1907
2122
  declare function parseReliabilityConfig(raw: unknown): SdkReliabilityConfig | null;
2123
+ /** Resolve init overrides over validated server policy, then defaults, including individual retry fields. */
2124
+ declare function resolveReliabilityConfig(serverConfig: SdkReliabilityConfig | undefined, overrides?: SdkReliabilityConfigOverrides): SdkReliabilityConfig;
1908
2125
  /** Read the cached config from storage, or `null` if absent/invalid. */
1909
2126
  declare function loadCachedConfig(storage: StorageEngine): SdkReliabilityConfig | null;
1910
2127
  /** Persist the config as last-known so the next page load starts with these features enabled. */
@@ -2016,4 +2233,4 @@ declare function logInfo(message: string): void;
2016
2233
  declare function logError(message: string): void;
2017
2234
  declare function destroy(): Promise<void>;
2018
2235
 
2019
- 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 EmailLinkOperationConfig, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationConfig, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventBatchMeta, type EventMeta, EventStore, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, 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 PredefinedEvent, type ProvideDataOperationConfig, ProvideDataOperationFull, type ProvideDataOperationPostResponseStart, type ProvideDataOperationSpecType, type ProvideDataOperationStart, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, type SdkReliabilityConfig, type SdkRetryConfig, SessionStorage, type SmsOTPOperationConfig, type SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, type SocialLoginOperationConfig, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TelemetryEntry, type TelemetryLevel, type TelemetrySink, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type UserReference, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, getExperiments, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, namespacedKey, parseReliabilityConfig, resetSession, setExperiment, setExperiments, setUser, telemetry };
2236
+ 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 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 FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, 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 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 SmsOTPOperationConfig, type SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, type SocialLoginOperationConfig, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TelemetryEntry, type TelemetryLevel, type TelemetrySink, 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, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, getExperiments, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, namespacedKey, parseReliabilityConfig, resetSession, resolveRawErrorLimits, resolveReliabilityConfig, serializeRawError, setExperiment, setExperiments, setUser, telemetry };