@corbado/observe 0.9.1 → 0.10.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 +1 -1
- package/dist/index.d.mts +193 -41
- package/dist/index.d.ts +193 -41
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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-known-identifier" | "password-login-with-identifier" | "password-enrollment" | "email-otp-login" | "email-otp-enrollment" | "email-link-login" | "email-link-enrollment" | "social-google" | "social-apple" | "social-facebook" | "social-other" | "reset-flow";
|
|
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
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";
|
|
8
8
|
type FlowType = "login" | "signup" | "recovery" | "enrollment" | (string & {});
|
|
9
9
|
type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "other";
|
|
@@ -175,9 +175,31 @@ interface TelemetryEntry {
|
|
|
175
175
|
/** Capture time, unix ms. */
|
|
176
176
|
ts: number;
|
|
177
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Why a delivery attempt happened. Each value maps 1:1 to one flush trigger, so server-side
|
|
180
|
+
* analyses can tell which triggers actually carry the traffic and whether the trigger switches and
|
|
181
|
+
* opt-in flush features of the reliability config earn their keep.
|
|
182
|
+
*
|
|
183
|
+
* - `timer`: the flush interval elapsed (the ordinary cadence).
|
|
184
|
+
* - `backoff`: a retry whose backoff delay elapsed — a resend, not new work.
|
|
185
|
+
* - `recovery`: events recovered from the durable outbox at boot (previous load never delivered them).
|
|
186
|
+
* - `flow-finished`: a configured priority flow type completed (`flushOnFlowTypeFinished`).
|
|
187
|
+
* - `telemetry`: a telemetry entry escalated to an immediate flush (`flushOnTelemetry`).
|
|
188
|
+
* - `visibility-change`: the document became hidden (`tvc`).
|
|
189
|
+
* - `pagehide`: the page is going away (`tph`).
|
|
190
|
+
* - `low-event-teardown`: a low-event tracker's unload teardown handed over its batched lows (`tlf`).
|
|
191
|
+
* - `destroy`: the tracker was destroyed (`td`).
|
|
192
|
+
* - `manual`: the host app called `flushKeepalive()` itself.
|
|
193
|
+
*/
|
|
194
|
+
type FlushReason = "timer" | "backoff" | "recovery" | "flow-finished" | "telemetry" | "visibility-change" | "pagehide" | "low-event-teardown" | "destroy" | "manual";
|
|
178
195
|
interface EventBatchMeta {
|
|
179
196
|
sent: number;
|
|
180
197
|
transport: "fetch" | "beacon";
|
|
198
|
+
/**
|
|
199
|
+
* What triggered the flush this batch was sent in. All batches of one flush (a backlog larger
|
|
200
|
+
* than `batchSize` is drained in several requests) carry the same reason.
|
|
201
|
+
*/
|
|
202
|
+
flushReason?: FlushReason;
|
|
181
203
|
/** Number of prior failed delivery attempts for this batch; omitted on the first attempt. */
|
|
182
204
|
retryCount?: number;
|
|
183
205
|
/**
|
|
@@ -219,6 +241,11 @@ interface DeviceInfoDataWeb {
|
|
|
219
241
|
javaScriptHighEntropy?: JavaScriptHighEntropy;
|
|
220
242
|
privateMode?: boolean;
|
|
221
243
|
webdriver?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* `navigator.maxTouchPoints` — maximum simultaneous touch contact points. Reported raw so the
|
|
246
|
+
* backend can separate iPadOS (non-zero, but sends a macOS user agent) from real macOS devices (0).
|
|
247
|
+
*/
|
|
248
|
+
maxTouchPoints?: number;
|
|
222
249
|
}
|
|
223
250
|
type DeviceInfoCollectionError = {
|
|
224
251
|
field: keyof DeviceInfoDataWeb;
|
|
@@ -281,7 +308,14 @@ interface SdkReliabilityConfig {
|
|
|
281
308
|
* relevant when `sessionContinuity` is enabled.
|
|
282
309
|
*/
|
|
283
310
|
sessionInactivityMs: number;
|
|
284
|
-
/**
|
|
311
|
+
/**
|
|
312
|
+
* Maximum time to wait for the cross-tab sequence Web Lock before allocating without it.
|
|
313
|
+
*
|
|
314
|
+
* `0` disables the lock: the counter is then allocated straight away, without ever requesting a
|
|
315
|
+
* lock. That gives up cross-tab atomicity — two tabs sharing a continuity session can allocate the
|
|
316
|
+
* same seq, which is what the unlocked fallback already does on every timeout — in exchange for
|
|
317
|
+
* removing a lock round-trip per tracked event.
|
|
318
|
+
*/
|
|
285
319
|
seqLockTimeoutMs: number;
|
|
286
320
|
/**
|
|
287
321
|
* Flush-trigger switch: flush pending events when the document becomes hidden
|
|
@@ -311,13 +345,31 @@ interface SdkReliabilityConfig {
|
|
|
311
345
|
*/
|
|
312
346
|
flushOnTelemetry: boolean;
|
|
313
347
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* instead of relying on unload delivery.
|
|
317
|
-
*
|
|
318
|
-
*
|
|
348
|
+
* Flow types (e.g. `login`, `enrollment`) whose completion triggers an immediate flush when
|
|
349
|
+
* enqueued, so the highest-value events go out via a normal fetch while the page is still alive
|
|
350
|
+
* instead of relying on unload delivery. Both completion events count — `flow_finished` and
|
|
351
|
+
* `flow_auto_finished` — matched on their `flowName`; no other event name ever flushes early.
|
|
352
|
+
* Empty by default (no priority flows). The whole pending queue is sent, and the immediate flush
|
|
353
|
+
* coexists with the interval timer without double-sending (the in-flight drain absorbs it).
|
|
354
|
+
*/
|
|
355
|
+
flushOnFlowTypeFinished: FlowType[];
|
|
356
|
+
/**
|
|
357
|
+
* Per-field timeout for device info collection, in milliseconds. A field whose browser API does
|
|
358
|
+
* not answer within this budget is recorded as a `TimeoutError` in `collectionErrors` and left
|
|
359
|
+
* undefined; the remaining fields are unaffected. Defaults to 1000ms.
|
|
360
|
+
*
|
|
361
|
+
* Read at collection time, so a config that arrives mid-load applies from the next device info
|
|
362
|
+
* refresh onward. The very first collection of a load booting on the built-in defaults (nothing
|
|
363
|
+
* cached) always runs on the default.
|
|
364
|
+
*/
|
|
365
|
+
deviceInfoCollectorTimeoutMs: number;
|
|
366
|
+
/**
|
|
367
|
+
* When true (and `telemetry` is enabled), every device info collection emits an `info` telemetry
|
|
368
|
+
* entry with the total duration and the per-field durations in milliseconds. Defaults to false:
|
|
369
|
+
* this is a diagnostic stream to switch on while investigating slow collection, not something to
|
|
370
|
+
* run permanently.
|
|
319
371
|
*/
|
|
320
|
-
|
|
372
|
+
deviceInfoTiming: boolean;
|
|
321
373
|
/** Retry configuration for failed event flushes. */
|
|
322
374
|
retry: SdkRetryConfig;
|
|
323
375
|
}
|
|
@@ -449,10 +501,20 @@ type PasskeyLoginCeremonyStart = {
|
|
|
449
501
|
type PasskeyLoginCeremonyFinished = {
|
|
450
502
|
assertionResponse: string;
|
|
451
503
|
};
|
|
504
|
+
type PasskeyLoginPostResponseStart = {
|
|
505
|
+
/**
|
|
506
|
+
* Fallback carrier for the WebAuthn assertion, same JSON shape the ceremony step reports. Set it
|
|
507
|
+
* only when the ceremony itself could not be observed — e.g. an extension holds
|
|
508
|
+
* `navigator.credentials` in a form the integration declines to patch — and the submitted
|
|
509
|
+
* credential is the only remaining copy. Leave it unset whenever a ceremony step carried the
|
|
510
|
+
* assertion, so consumers never see two sources for one login.
|
|
511
|
+
*/
|
|
512
|
+
assertionResponse?: string;
|
|
513
|
+
};
|
|
452
514
|
declare class PasskeyLoginOperationFull extends OperationFull {
|
|
453
515
|
readonly getOptions: StepHelper<PasskeyLoginGetOptionsStart, PasskeyLoginGetOptionsFinished>;
|
|
454
516
|
readonly ceremony: StepHelper<PasskeyLoginCeremonyStart, PasskeyLoginCeremonyFinished>;
|
|
455
|
-
readonly postResponse: StepHelper
|
|
517
|
+
readonly postResponse: StepHelper<PasskeyLoginPostResponseStart>;
|
|
456
518
|
private lowEventTracker;
|
|
457
519
|
constructor(tracker: CorbadoTracker);
|
|
458
520
|
/**
|
|
@@ -470,21 +532,27 @@ type EmailOTPOperationSendOTPStart = {
|
|
|
470
532
|
type EmailOTPOperationPostResponseStart = {
|
|
471
533
|
explicitSpecType?: EmailOTPOperationSpecType;
|
|
472
534
|
};
|
|
535
|
+
type EmailOTPOperationConfig = {
|
|
536
|
+
explicitSpecType?: EmailOTPOperationSpecType;
|
|
537
|
+
};
|
|
473
538
|
declare class EmailOtpOperationFull extends OperationFull {
|
|
474
539
|
readonly send: StepHelper<EmailOTPOperationSendOTPStart>;
|
|
475
540
|
readonly postResponse: StepHelper<EmailOTPOperationPostResponseStart>;
|
|
476
541
|
readonly resend: StepHelper;
|
|
477
|
-
constructor(tracker: CorbadoTracker);
|
|
542
|
+
constructor(tracker: CorbadoTracker, config?: EmailOTPOperationConfig);
|
|
478
543
|
}
|
|
479
544
|
|
|
480
545
|
type SmsOTPOperationSpecType = "sms-otp-login" | "sms-otp-enrollment";
|
|
481
546
|
type SmsOTPOperationPostResponseStart = {
|
|
482
547
|
explicitSpecType?: SmsOTPOperationSpecType;
|
|
483
548
|
};
|
|
549
|
+
type SmsOTPOperationConfig = {
|
|
550
|
+
explicitSpecType?: SmsOTPOperationSpecType;
|
|
551
|
+
};
|
|
484
552
|
declare class SmsOtpOperationFull extends OperationFull {
|
|
485
553
|
readonly postResponse: StepHelper<SmsOTPOperationPostResponseStart>;
|
|
486
554
|
readonly resend: StepHelper;
|
|
487
|
-
constructor(tracker: CorbadoTracker);
|
|
555
|
+
constructor(tracker: CorbadoTracker, config?: SmsOTPOperationConfig);
|
|
488
556
|
}
|
|
489
557
|
|
|
490
558
|
type EmailLinkOperationSpecType = "email-link-login" | "email-link-enrollment";
|
|
@@ -517,12 +585,26 @@ type PasskeyEnrollmentCeremonyStart = {
|
|
|
517
585
|
type PasskeyEnrollmentCeremonyFinished = {
|
|
518
586
|
attestationResponse: string;
|
|
519
587
|
};
|
|
588
|
+
type PasskeyEnrollmentPostResponseStart = {
|
|
589
|
+
/**
|
|
590
|
+
* Fallback carrier for the WebAuthn attestation, mirroring the passkey-login contract. Set it only
|
|
591
|
+
* when the ceremony itself could not be observed — e.g. an extension holds `navigator.credentials`
|
|
592
|
+
* in a form the integration declines to patch — and the submitted credential is the only remaining
|
|
593
|
+
* copy. Leave it unset whenever a ceremony step carried the attestation, so consumers never see two
|
|
594
|
+
* sources for one enrollment. A credential recovered from the submission may carry more members
|
|
595
|
+
* than the ceremony reports; consumers must tolerate unknown keys.
|
|
596
|
+
*/
|
|
597
|
+
attestationResponse?: string;
|
|
598
|
+
};
|
|
599
|
+
type PasskeyEnrollmentOperationConfig = {
|
|
600
|
+
explicitSpecType?: PasskeyOperationEnrollmentExplicitSpecType;
|
|
601
|
+
};
|
|
520
602
|
declare class PasskeyEnrollmentOperationFull extends OperationFull {
|
|
521
603
|
readonly getOptions: StepHelper<PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentGetOptionsFinished>;
|
|
522
604
|
readonly ceremony: StepHelper<PasskeyEnrollmentCeremonyStart, PasskeyEnrollmentCeremonyFinished>;
|
|
523
|
-
readonly postResponse: StepHelper
|
|
605
|
+
readonly postResponse: StepHelper<PasskeyEnrollmentPostResponseStart>;
|
|
524
606
|
private lowEventTracker;
|
|
525
|
-
constructor(tracker: CorbadoTracker);
|
|
607
|
+
constructor(tracker: CorbadoTracker, config?: PasskeyEnrollmentOperationConfig);
|
|
526
608
|
destroy(): void;
|
|
527
609
|
}
|
|
528
610
|
|
|
@@ -609,7 +691,7 @@ type PasskeyLoginCUITypedError = {
|
|
|
609
691
|
code: PasskeyLoginCUITypedErrorCode;
|
|
610
692
|
};
|
|
611
693
|
type PasskeyLoginCUITypedErrorCode = "cancel_detected";
|
|
612
|
-
type ProvideIdentifierSpecType = "email";
|
|
694
|
+
type ProvideIdentifierSpecType = "email" | "phone";
|
|
613
695
|
type ProvideIdentifierPostResponseStart = {
|
|
614
696
|
explicitSpecType?: ProvideIdentifierSpecType;
|
|
615
697
|
};
|
|
@@ -624,6 +706,10 @@ type PasskeyLoginCUIGetOptionsFinished = {
|
|
|
624
706
|
explicitSpecType?: ProvideIdentifierSpecType;
|
|
625
707
|
assertionOptions: string;
|
|
626
708
|
};
|
|
709
|
+
type OperationFullProvideIdentifierWithCUIConfig = {
|
|
710
|
+
inputHtmlField?: HTMLInputElement;
|
|
711
|
+
explicitSpecType?: ProvideIdentifierSpecType;
|
|
712
|
+
};
|
|
627
713
|
declare class OperationFullProvideIdentifierWithCUI {
|
|
628
714
|
private tracker;
|
|
629
715
|
private lowEventTracker?;
|
|
@@ -635,7 +721,7 @@ declare class OperationFullProvideIdentifierWithCUI {
|
|
|
635
721
|
trigger: (data: SubflowTrigger, options?: StepOptions) => void;
|
|
636
722
|
getOptions: StepHelper<PasskeyLoginCUIGetOptionsStart, PasskeyLoginCUIGetOptionsFinished>;
|
|
637
723
|
ceremony: StepHelper<CUICeremonyStart, PasskeyLoginCeremonyFinished, PasskeyLoginCUITypedError>;
|
|
638
|
-
postResponse: StepHelper
|
|
724
|
+
postResponse: StepHelper<PasskeyLoginPostResponseStart>;
|
|
639
725
|
};
|
|
640
726
|
readonly provideIdentifier: {
|
|
641
727
|
/**
|
|
@@ -646,7 +732,7 @@ declare class OperationFullProvideIdentifierWithCUI {
|
|
|
646
732
|
clientValidation: StepHelper;
|
|
647
733
|
postResponse: StepHelper<ProvideIdentifierPostResponseStart>;
|
|
648
734
|
};
|
|
649
|
-
constructor(tracker: CorbadoTracker,
|
|
735
|
+
constructor(tracker: CorbadoTracker, config?: OperationFullProvideIdentifierWithCUIConfig);
|
|
650
736
|
private createStep;
|
|
651
737
|
destroy(): void;
|
|
652
738
|
}
|
|
@@ -715,7 +801,12 @@ interface TrackerOptions {
|
|
|
715
801
|
logger?: Logger;
|
|
716
802
|
/** Minimum time between attaching cached device info to events. */
|
|
717
803
|
deviceInfoDebounceTime?: number;
|
|
718
|
-
/**
|
|
804
|
+
/**
|
|
805
|
+
* @deprecated The device info collection timeout is server-controlled via the SDK reliability
|
|
806
|
+
* config (`deviceInfoCollectorTimeoutMs`). This option only applies as long as no server config
|
|
807
|
+
* has been received (i.e. before the first config response is cached); once a server config is
|
|
808
|
+
* cached it wins. It will be removed in a future release.
|
|
809
|
+
*/
|
|
719
810
|
deviceInfoCollectorTimeout?: number;
|
|
720
811
|
defaultTags?: Record<string, string>;
|
|
721
812
|
/**
|
|
@@ -749,6 +840,12 @@ declare class CorbadoTracker {
|
|
|
749
840
|
private config;
|
|
750
841
|
private deviceInfoManager;
|
|
751
842
|
private seq;
|
|
843
|
+
/**
|
|
844
|
+
* When the continuity record's `lastActiveAt` was last persisted. Throttles that write inside the
|
|
845
|
+
* seq critical section (see {@link SESSION_ACTIVITY_WRITE_INTERVAL_MS}). 0 = not written yet on
|
|
846
|
+
* this load, so the first allocation always persists.
|
|
847
|
+
*/
|
|
848
|
+
private lastActivityWriteAt;
|
|
752
849
|
/** Persistent experiment assignments (experiment key → variant), attached to every produced event. */
|
|
753
850
|
private experiments;
|
|
754
851
|
/** Self-instrumentation state: re-entrancy guard, readiness, per-load dedupe, and pre-queue buffer. */
|
|
@@ -810,19 +907,36 @@ declare class CorbadoTracker {
|
|
|
810
907
|
* Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
|
|
811
908
|
* same browser. Rotates after `config.sessionInactivityMs` of inactivity (server-controlled,
|
|
812
909
|
* boot-snapshot like the rest of the config), resetting the seq counter.
|
|
910
|
+
*
|
|
911
|
+
* This is the ONLY place an inactivity rotation happens. Rotating here is safe because the load
|
|
912
|
+
* that triggers it also re-announces its flow (an integration emits `flow_started` on page load),
|
|
913
|
+
* so the fresh session id gets a classifiable flow. Mid-page there is no such re-announcement:
|
|
914
|
+
* rotating between two tracked events would leave the started flow unfinished in the old session
|
|
915
|
+
* and the remaining events without a flow start in the new one — one gap counted as a drop-off,
|
|
916
|
+
* one completion counted as nothing. `nextSeq` therefore never rotates on inactivity.
|
|
813
917
|
*/
|
|
814
918
|
private getContinuitySessionId;
|
|
919
|
+
/**
|
|
920
|
+
* Persist the continuity record and remember when, so the throttled refresh in the seq critical
|
|
921
|
+
* section measures from the last write that actually happened — whoever made it.
|
|
922
|
+
*/
|
|
923
|
+
private persistContinuitySession;
|
|
815
924
|
/**
|
|
816
925
|
* Return the next sequence number. With session continuity the counter is persisted so ordering
|
|
817
926
|
* survives reloads/redirects; the read-increment-write runs under a cross-tab Web Lock
|
|
818
927
|
* ({@link SEQ_LOCK_NAME}) so two tabs sharing the session cannot allocate the same seq (where Web
|
|
819
928
|
* Locks are unavailable or exceed the configured timeout it degrades to the historical best-effort merge).
|
|
820
|
-
* Lock grants are FIFO, so seq order matches `track()` call order within a tab.
|
|
821
|
-
* continuity session's `lastActiveAt
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
929
|
+
* Lock grants are FIFO, so seq order matches `track()` call order within a tab. Tracking also keeps the
|
|
930
|
+
* continuity session's `lastActiveAt` fresh (throttled, see {@link SESSION_ACTIVITY_WRITE_INTERVAL_MS}),
|
|
931
|
+
* so the window the NEXT boot evaluates measures real user
|
|
932
|
+
* inactivity instead of time-since-page-load (a long-lived active tab must not rotate the session
|
|
933
|
+
* on the next reload). It never rotates the session itself: the inactivity window is evaluated at
|
|
934
|
+
* boot only ({@link getContinuitySessionId} documents why). Consequence: while a page is never
|
|
935
|
+
* reloaded — foreground idle, bfcache restore, long-lived SPA tab — a session can outlive
|
|
936
|
+
* `sessionInactivityMs`. That inflates flow durations but keeps flow counts correct, which is the
|
|
937
|
+
* better half of the trade. An empty store while this load already has a session id means
|
|
938
|
+
* persistence is failing (or was cleared); the in-memory id is reused then — never re-minted — so
|
|
939
|
+
* a broken store degrades to one session per page load instead of one session per event.
|
|
826
940
|
*/
|
|
827
941
|
private nextSeq;
|
|
828
942
|
private resolveTrackingSourcePath;
|
|
@@ -1028,9 +1142,12 @@ declare class CorbadoTracker {
|
|
|
1028
1142
|
* Synchronously flush any pending events and low events via beacon. Use during page-unload
|
|
1029
1143
|
* style teardown where async flushing is unreliable.
|
|
1030
1144
|
*
|
|
1145
|
+
* @param reason What triggered the flush; recorded as `meta.flushReason` on the batch. Defaults
|
|
1146
|
+
* to a direct call by the host app.
|
|
1147
|
+
*
|
|
1031
1148
|
* @internal
|
|
1032
1149
|
*/
|
|
1033
|
-
flushKeepalive(): void;
|
|
1150
|
+
flushKeepalive(reason?: FlushReason): void;
|
|
1034
1151
|
/**
|
|
1035
1152
|
* Keepalive flush requested by a low-event tracker's `pagehide` teardown. Gated by the
|
|
1036
1153
|
* server-controlled trigger switch `tlf` (boot-snapshot, default true = historical behavior):
|
|
@@ -1040,13 +1157,13 @@ declare class CorbadoTracker {
|
|
|
1040
1157
|
*/
|
|
1041
1158
|
lowEventFlushKeepalive(): void;
|
|
1042
1159
|
passkeyLoginFullOperation(): PasskeyLoginOperationFull;
|
|
1043
|
-
passkeyEnrollmentFullOperation(): PasskeyEnrollmentOperationFull;
|
|
1160
|
+
passkeyEnrollmentFullOperation(config?: PasskeyEnrollmentOperationConfig): PasskeyEnrollmentOperationFull;
|
|
1044
1161
|
passwordLoginFullOperation(autoTrackConfig?: PasswordLoginAutoTrackConfig): PasswordLoginOperationFull;
|
|
1045
1162
|
passwordEnrollmentFullOperation(autoTrackConfig?: PasswordEnrollmentAutoTrackConfig): PasswordEnrollmentOperationFull;
|
|
1046
1163
|
emailLinkOperationFull(): EmailLinkOperationFull;
|
|
1047
|
-
emailOtpOperationFull(): EmailOtpOperationFull;
|
|
1048
|
-
smsOtpOperationFull(): SmsOtpOperationFull;
|
|
1049
|
-
provideIdentifierOperationFull(
|
|
1164
|
+
emailOtpOperationFull(config?: EmailOTPOperationConfig): EmailOtpOperationFull;
|
|
1165
|
+
smsOtpOperationFull(config?: SmsOTPOperationConfig): SmsOtpOperationFull;
|
|
1166
|
+
provideIdentifierOperationFull(config?: OperationFullProvideIdentifierWithCUIConfig): OperationFullProvideIdentifierWithCUI;
|
|
1050
1167
|
provideDataOperationFull(config?: ProvideDataOperationConfig): ProvideDataOperationFull;
|
|
1051
1168
|
socialLoginOperationFull(): SocialLoginOperationFull;
|
|
1052
1169
|
appConfirmationOperationFull(explicitSpecType?: AppConfirmationOperationSpecType): AppConfirmationOperationFull;
|
|
@@ -1206,6 +1323,9 @@ interface QueueOptions {
|
|
|
1206
1323
|
*
|
|
1207
1324
|
* Flushing is timer-driven only (the flush interval); `batchSize` caps the events per request, and a
|
|
1208
1325
|
* flush drains all due work in sequential capped batches, stopping at the first failed send.
|
|
1326
|
+
*
|
|
1327
|
+
* Every flush carries a {@link FlushReason} that names its trigger; it is stamped onto the batch as
|
|
1328
|
+
* `meta.flushReason` so the server can see which triggers actually deliver.
|
|
1209
1329
|
*/
|
|
1210
1330
|
declare class RequestQueue {
|
|
1211
1331
|
private readonly logger;
|
|
@@ -1243,8 +1363,11 @@ declare class RequestQueue {
|
|
|
1243
1363
|
* config (see {@link handleConfigResponse}).
|
|
1244
1364
|
*/
|
|
1245
1365
|
private config;
|
|
1246
|
-
/**
|
|
1247
|
-
|
|
1366
|
+
/**
|
|
1367
|
+
* Flow types whose completion triggers an immediate flush at enqueue time
|
|
1368
|
+
* (config.flushOnFlowTypeFinished).
|
|
1369
|
+
*/
|
|
1370
|
+
private priorityFlowTypes;
|
|
1248
1371
|
private store?;
|
|
1249
1372
|
/**
|
|
1250
1373
|
* Once the server has answered the config request with a 2xx (200 = fresh config cached for the
|
|
@@ -1279,20 +1402,35 @@ declare class RequestQueue {
|
|
|
1279
1402
|
*/
|
|
1280
1403
|
enqueueTelemetry(entry: TelemetryEntry): void;
|
|
1281
1404
|
private scheduleAfterEnqueue;
|
|
1405
|
+
/**
|
|
1406
|
+
* Whether this event completes one of the configured priority flow types. Only the two flow
|
|
1407
|
+
* completion events qualify — `flow_finished` and `flow_auto_finished`, both carrying the
|
|
1408
|
+
* finished flow in `data.flowName`. Custom events never match, even when named like one of them.
|
|
1409
|
+
*/
|
|
1410
|
+
private isPriorityEvent;
|
|
1411
|
+
/**
|
|
1412
|
+
* Arm the flush timer. The `reason` travels with the timer into the flush it triggers; an
|
|
1413
|
+
* already-armed timer keeps the reason it was armed with (the flush it fires is that flush, and
|
|
1414
|
+
* it takes whatever accumulated in the meantime with it).
|
|
1415
|
+
*/
|
|
1282
1416
|
private scheduleFlush;
|
|
1283
1417
|
private clearTimer;
|
|
1284
1418
|
/**
|
|
1419
|
+
* @param reason What triggered this flush; stamped onto every batch it sends as
|
|
1420
|
+
* `meta.flushReason`. Defaults to the ordinary interval cadence.
|
|
1421
|
+
*
|
|
1285
1422
|
* Error situations:
|
|
1286
1423
|
* - Queue is empty: return without calling transport.send
|
|
1287
1424
|
* - A flush is already in progress: return without calling transport.send again
|
|
1288
1425
|
* - transport.send rejects or throws, or any other error in the try block: log "Unexpected error in queue flush"
|
|
1289
1426
|
*/
|
|
1290
|
-
flush(): Promise<void>;
|
|
1427
|
+
flush(reason?: FlushReason): Promise<void>;
|
|
1291
1428
|
/**
|
|
1292
|
-
* Stamps delivery metadata onto the batch: the
|
|
1293
|
-
* built-in defaults) and the number of prior failed delivery
|
|
1294
|
-
* only when at least one entry is a retry). `entry.attempts`
|
|
1295
|
-
* so it equals the retry count at send time. The transport
|
|
1429
|
+
* Stamps delivery metadata onto the batch: the trigger that caused this flush, the config version
|
|
1430
|
+
* this load runs under (omitted on built-in defaults) and the number of prior failed delivery
|
|
1431
|
+
* attempts (the max across its entries, only when at least one entry is a retry). `entry.attempts`
|
|
1432
|
+
* is incremented on each failed flush, so it equals the retry count at send time. The transport
|
|
1433
|
+
* later merges in `sent`/`transport`.
|
|
1296
1434
|
*/
|
|
1297
1435
|
private attachBatchMeta;
|
|
1298
1436
|
private getDuePending;
|
|
@@ -1311,7 +1449,7 @@ declare class RequestQueue {
|
|
|
1311
1449
|
/**
|
|
1312
1450
|
* Switch this load from the built-in defaults to the first server config (defaults boot only).
|
|
1313
1451
|
* Most fields are read at use time, so replacing the reference is enough; only the derived state
|
|
1314
|
-
* (priority
|
|
1452
|
+
* (priority flow type set, durable outbox store) needs rebuilding.
|
|
1315
1453
|
*/
|
|
1316
1454
|
private applyConfigLive;
|
|
1317
1455
|
/** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
|
|
@@ -1339,9 +1477,13 @@ declare class RequestQueue {
|
|
|
1339
1477
|
* with the host app). With `config.durableOutbox` enabled, entries are NOT removed (they are
|
|
1340
1478
|
* resent on the next load and deduped server-side); otherwise the sent chunk is removed
|
|
1341
1479
|
* best-effort and a remainder keeps the next lifecycle signal flush-worthy.
|
|
1342
|
-
* Deduplicated: a call with nothing newly enqueued since the last sync flush is a no-op
|
|
1480
|
+
* Deduplicated: a call with nothing newly enqueued since the last sync flush is a no-op — so of
|
|
1481
|
+
* several unload signals in one navigation only the first one that finds something to send is
|
|
1482
|
+
* recorded as the flush reason.
|
|
1483
|
+
*
|
|
1484
|
+
* @param reason What triggered the unload flush; defaults to a direct call by the host app.
|
|
1343
1485
|
*/
|
|
1344
|
-
flushKeepalive(): void;
|
|
1486
|
+
flushKeepalive(reason?: FlushReason): void;
|
|
1345
1487
|
private flushSync;
|
|
1346
1488
|
/**
|
|
1347
1489
|
* Error situations:
|
|
@@ -1361,6 +1503,12 @@ declare const CONFIG_REQUEST_HEADER = "X-Corbado-Observe-Config";
|
|
|
1361
1503
|
/** Built-in flush interval used until the server provides one. Matches the historical default. */
|
|
1362
1504
|
declare const DEFAULT_FLUSH_INTERVAL_MS = 500;
|
|
1363
1505
|
declare const DEFAULT_SEQ_LOCK_TIMEOUT_MS = 50;
|
|
1506
|
+
/**
|
|
1507
|
+
* Built-in per-field device info collection timeout. Also the timeout of the very first collection
|
|
1508
|
+
* of a load that booted without a cached config, since collection starts before the first server
|
|
1509
|
+
* response can arrive — generous enough that a slow-but-working browser API still answers.
|
|
1510
|
+
*/
|
|
1511
|
+
declare const DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS = 1000;
|
|
1364
1512
|
/**
|
|
1365
1513
|
* Clamping bounds for server-provided config values. They protect the client from a dangerous
|
|
1366
1514
|
* server-side config mistake (e.g. a 0ms flush interval would busy-loop); the server clamps with
|
|
@@ -1384,10 +1532,14 @@ declare const CONFIG_BOUNDS: {
|
|
|
1384
1532
|
readonly max: 86400000;
|
|
1385
1533
|
};
|
|
1386
1534
|
readonly seqLockTimeoutMs: {
|
|
1387
|
-
readonly min:
|
|
1535
|
+
readonly min: 0;
|
|
1388
1536
|
readonly max: 250;
|
|
1389
1537
|
};
|
|
1390
|
-
readonly
|
|
1538
|
+
readonly deviceInfoCollectorTimeoutMs: {
|
|
1539
|
+
readonly min: 10;
|
|
1540
|
+
readonly max: 10000;
|
|
1541
|
+
};
|
|
1542
|
+
readonly flushOnFlowTypeFinished: {
|
|
1391
1543
|
readonly maxEntries: 20;
|
|
1392
1544
|
readonly maxNameLength: 100;
|
|
1393
1545
|
};
|
|
@@ -1493,4 +1645,4 @@ declare function logInfo(message: string): void;
|
|
|
1493
1645
|
declare function logError(message: string): void;
|
|
1494
1646
|
declare function destroy(): Promise<void>;
|
|
1495
1647
|
|
|
1496
|
-
export { type AppConfirmationOperationCeremonyTypedError, 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 ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, 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, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, 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 JavaScriptHighEntropy, LocalStorage, type Logger, type LowEvent, type MultiFlowReset, type MultiFlowStarted, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, OperationFull, OperationFullProvideIdentifierWithCUI, type OutboxEntry, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentOperationFull, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, PasskeyLoginOperationFull, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentAutoTrackConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginAutoTrackConfig, type PasswordLoginCUICeremonyStart, type PasswordLoginCUIGetOptionsFinished, type PasswordLoginCUIGetOptionsStart, type PasswordLoginCUISpecType, type PasswordLoginCUITypedError, 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 SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, 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, getTracker, init, loadCachedConfig, logError, logInfo, parseReliabilityConfig, resetSession, setExperiment, setExperiments, telemetry };
|
|
1648
|
+
export { type AppConfirmationOperationCeremonyTypedError, 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 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, 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 MultiFlowReset, type MultiFlowStarted, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, 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, PasskeyLoginOperationFull, type PasskeyLoginPostResponseStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentAutoTrackConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginAutoTrackConfig, type PasswordLoginCUICeremonyStart, type PasswordLoginCUIGetOptionsFinished, type PasswordLoginCUIGetOptionsStart, type PasswordLoginCUISpecType, type PasswordLoginCUITypedError, 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, 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, getTracker, init, loadCachedConfig, logError, logInfo, parseReliabilityConfig, resetSession, setExperiment, setExperiments, telemetry };
|