@corbado/observe 0.10.0 → 0.11.0-next.90-2fe1389
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 +92 -4
- package/dist/index.d.ts +92 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ interface SdkInfo {
|
|
|
4
4
|
}
|
|
5
5
|
type EventType = "predefined" | "custom" | "error" | "identify";
|
|
6
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";
|
|
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";
|
|
8
8
|
type FlowType = "login" | "signup" | "recovery" | "enrollment" | (string & {});
|
|
9
9
|
type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "other";
|
|
10
10
|
declare enum AuthEventName {
|
|
@@ -59,7 +59,8 @@ type UserReference = {
|
|
|
59
59
|
*/
|
|
60
60
|
type NormalizedError = {
|
|
61
61
|
name?: string;
|
|
62
|
-
|
|
62
|
+
code?: string;
|
|
63
|
+
message?: string;
|
|
63
64
|
};
|
|
64
65
|
type FlowStarted = {
|
|
65
66
|
flowName: FlowType;
|
|
@@ -211,6 +212,12 @@ interface EventBatchMeta {
|
|
|
211
212
|
}
|
|
212
213
|
interface EventMeta {
|
|
213
214
|
trackingSourcePath: string;
|
|
215
|
+
/**
|
|
216
|
+
* Per-tab id (uuidv7, `sessionStorage`-scoped) of the tab that CREATED this event, stamped at
|
|
217
|
+
* `track()` time. Late-flushed events keep the tab they originated in regardless of which page
|
|
218
|
+
* delivers them; the backend uses this to split interleaved multi-tab streams per session.
|
|
219
|
+
*/
|
|
220
|
+
tabId?: string;
|
|
214
221
|
}
|
|
215
222
|
interface EventBatch {
|
|
216
223
|
sessionId: string;
|
|
@@ -481,6 +488,13 @@ declare abstract class OperationFull {
|
|
|
481
488
|
}
|
|
482
489
|
|
|
483
490
|
type PasskeyOperationLoginExplicitSpecType = "passkey-cui" | "passkey-known-identifier" | "passkey-no-identifier"
|
|
491
|
+
/**
|
|
492
|
+
* The `-auto` variants are the same two ceremonies started by the integration rather than by a
|
|
493
|
+
* user gesture — `navigator.credentials.get()` called without user activation, so the passkey
|
|
494
|
+
* prompt appears on its own. Unlike `passkey-immediate` they still run after the auth-method
|
|
495
|
+
* decision is rendered and attribute to the same decision option as their manual counterpart.
|
|
496
|
+
*/
|
|
497
|
+
| "passkey-known-identifier-auto" | "passkey-no-identifier-auto"
|
|
484
498
|
/**
|
|
485
499
|
* WebAuthn immediate mediation (`navigator.credentials.get({ uiMode: "immediate" })`, Chrome 149+):
|
|
486
500
|
* button-triggered, discoverable credentials only (empty allowList). Shows the account picker when
|
|
@@ -598,6 +612,11 @@ type PasskeyEnrollmentPostResponseStart = {
|
|
|
598
612
|
};
|
|
599
613
|
type PasskeyEnrollmentOperationConfig = {
|
|
600
614
|
explicitSpecType?: PasskeyOperationEnrollmentExplicitSpecType;
|
|
615
|
+
/**
|
|
616
|
+
* Timestamp (epoch ms) for the subflow-started event. Set it when the enrollment began before the
|
|
617
|
+
* operation could be constructed.
|
|
618
|
+
*/
|
|
619
|
+
explicitTimestamp?: number;
|
|
601
620
|
};
|
|
602
621
|
declare class PasskeyEnrollmentOperationFull extends OperationFull {
|
|
603
622
|
readonly getOptions: StepHelper<PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentGetOptionsFinished>;
|
|
@@ -769,6 +788,23 @@ declare class AppConfirmationOperationFull extends OperationFull {
|
|
|
769
788
|
constructor(tracker: CorbadoTracker, explicitSpecType?: AppConfirmationOperationSpecType);
|
|
770
789
|
}
|
|
771
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Which captcha widget the integration observed.
|
|
793
|
+
* - `visible`: a widget presenting UI to the user. Can require interaction.
|
|
794
|
+
* - `invisible`: a widget that never presents UI and always solves itself.
|
|
795
|
+
*/
|
|
796
|
+
type CaptchaOperationSpecType = "visible" | "invisible";
|
|
797
|
+
type CaptchaOperationConfig = {
|
|
798
|
+
explicitSpecType?: CaptchaOperationSpecType;
|
|
799
|
+
};
|
|
800
|
+
declare class CaptchaOperationFull extends OperationFull {
|
|
801
|
+
/** Step representing the captcha challenge ceremony. */
|
|
802
|
+
readonly ceremony: StepHelper;
|
|
803
|
+
/** Submission of the captcha token and the server's verdict on it. */
|
|
804
|
+
readonly postResponse: StepHelper;
|
|
805
|
+
constructor(tracker: CorbadoTracker, config?: CaptchaOperationConfig);
|
|
806
|
+
}
|
|
807
|
+
|
|
772
808
|
type ProvideDataOperationSpecType = "signup" | "login" | "recovery" | "enrollment";
|
|
773
809
|
type ProvideDataOperationStart = {
|
|
774
810
|
/** Stable name of the data field collected by this subflow, when known. */
|
|
@@ -822,6 +858,8 @@ interface TrackerOptions {
|
|
|
822
858
|
* It will be removed in a future release.
|
|
823
859
|
*/
|
|
824
860
|
flushInterval?: number;
|
|
861
|
+
/** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
|
|
862
|
+
sessionIdGenerator?: () => string;
|
|
825
863
|
}
|
|
826
864
|
declare class CorbadoTracker {
|
|
827
865
|
private options;
|
|
@@ -839,6 +877,12 @@ declare class CorbadoTracker {
|
|
|
839
877
|
*/
|
|
840
878
|
private config;
|
|
841
879
|
private deviceInfoManager;
|
|
880
|
+
private deviceCollector;
|
|
881
|
+
/**
|
|
882
|
+
* Cached per-tab id stamped onto every event's meta (see {@link EventMeta.tabId}). Resolved
|
|
883
|
+
* lazily from the collector's sessionStorage-backed id; stable for the whole page lifetime.
|
|
884
|
+
*/
|
|
885
|
+
private eventTabId?;
|
|
842
886
|
private seq;
|
|
843
887
|
/**
|
|
844
888
|
* When the continuity record's `lastActiveAt` was last persisted. Throttles that write inside the
|
|
@@ -902,7 +946,8 @@ declare class CorbadoTracker {
|
|
|
902
946
|
*/
|
|
903
947
|
private resolveExperiments;
|
|
904
948
|
private isTrackingBlocked;
|
|
905
|
-
private
|
|
949
|
+
private createSessionId;
|
|
950
|
+
private resolveSessionId;
|
|
906
951
|
/**
|
|
907
952
|
* Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
|
|
908
953
|
* same browser. Rotates after `config.sessionInactivityMs` of inactivity (server-controlled,
|
|
@@ -940,6 +985,11 @@ declare class CorbadoTracker {
|
|
|
940
985
|
*/
|
|
941
986
|
private nextSeq;
|
|
942
987
|
private resolveTrackingSourcePath;
|
|
988
|
+
/**
|
|
989
|
+
* Per-tab id for event meta, cached after the first successful resolution: the id is
|
|
990
|
+
* sessionStorage-backed and stable for the whole page lifetime.
|
|
991
|
+
*/
|
|
992
|
+
private resolveEventTabId;
|
|
943
993
|
trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
|
|
944
994
|
trackSubflowTrigger(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
|
|
945
995
|
trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions, ignoreAsInteraction?: boolean): void;
|
|
@@ -1167,6 +1217,7 @@ declare class CorbadoTracker {
|
|
|
1167
1217
|
provideDataOperationFull(config?: ProvideDataOperationConfig): ProvideDataOperationFull;
|
|
1168
1218
|
socialLoginOperationFull(): SocialLoginOperationFull;
|
|
1169
1219
|
appConfirmationOperationFull(explicitSpecType?: AppConfirmationOperationSpecType): AppConfirmationOperationFull;
|
|
1220
|
+
captchaOperationFull(config?: CaptchaOperationConfig): CaptchaOperationFull;
|
|
1170
1221
|
/**
|
|
1171
1222
|
* Flush any pending events and release all resources (timers, event listeners).
|
|
1172
1223
|
*
|
|
@@ -1178,6 +1229,38 @@ declare class CorbadoTracker {
|
|
|
1178
1229
|
* resources are released either way.
|
|
1179
1230
|
*/
|
|
1180
1231
|
destroy(): Promise<void>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Return the Observe session id this tracker is currently reporting under.
|
|
1234
|
+
*
|
|
1235
|
+
* @remarks
|
|
1236
|
+
* Use this to route a server-side event into the same session the browser reports to: read the id,
|
|
1237
|
+
* pass it to your own backend, and let the backend use it as the `sessionID` of its ingest call.
|
|
1238
|
+
* Reading it here is the supported path — the storage layout behind it is an implementation detail
|
|
1239
|
+
* that has already changed once (per-tab `sessionStorage` to the cross-tab continuity record).
|
|
1240
|
+
*
|
|
1241
|
+
* The value is **not stable for the lifetime of the page**. It changes on
|
|
1242
|
+
* {@link CorbadoTracker.resetSession}, when this tab adopts a continuity session another tab
|
|
1243
|
+
* rotated to, and when a failed bootstrap recovers. Read it at the moment you need it; never cache
|
|
1244
|
+
* it across a request.
|
|
1245
|
+
*
|
|
1246
|
+
* `undefined` means no session id could be established at all — an environment without Web Crypto,
|
|
1247
|
+
* where tracking is not working either. Skip the server-side event instead of sending an empty id:
|
|
1248
|
+
* the ingest API requires a UUID and would reject the batch.
|
|
1249
|
+
*
|
|
1250
|
+
* @returns The current session id, or `undefined` if none could be established.
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```typescript
|
|
1254
|
+
* const sessionId = tracker.getSessionId();
|
|
1255
|
+
* if (sessionId) {
|
|
1256
|
+
* await fetch("/api/checkout", {
|
|
1257
|
+
* method: "POST",
|
|
1258
|
+
* body: JSON.stringify({ ...payload, observeSessionId: sessionId }),
|
|
1259
|
+
* });
|
|
1260
|
+
* }
|
|
1261
|
+
* ```
|
|
1262
|
+
*/
|
|
1263
|
+
getSessionId(): string | undefined;
|
|
1181
1264
|
/** @internal */
|
|
1182
1265
|
resetSession(): string;
|
|
1183
1266
|
}
|
|
@@ -1635,6 +1718,11 @@ declare class EventStore {
|
|
|
1635
1718
|
declare function init(options: TrackerOptions): CorbadoTracker;
|
|
1636
1719
|
declare function getTracker(): CorbadoTracker | undefined;
|
|
1637
1720
|
declare function resetSession(): string | undefined;
|
|
1721
|
+
/**
|
|
1722
|
+
* Session id of the global tracker, or `undefined` when no tracker was initialized or no session
|
|
1723
|
+
* could be established. See {@link CorbadoTracker.getSessionId}.
|
|
1724
|
+
*/
|
|
1725
|
+
declare function getSessionId(): string | undefined;
|
|
1638
1726
|
declare function setExperiment(key: string, variant: string): void;
|
|
1639
1727
|
declare function setExperiments(assignments: Record<string, string>): void;
|
|
1640
1728
|
declare function clearExperiment(key: string): void;
|
|
@@ -1645,4 +1733,4 @@ declare function logInfo(message: string): void;
|
|
|
1645
1733
|
declare function logError(message: string): void;
|
|
1646
1734
|
declare function destroy(): Promise<void>;
|
|
1647
1735
|
|
|
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 };
|
|
1736
|
+
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 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, 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, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, parseReliabilityConfig, resetSession, setExperiment, setExperiments, telemetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ interface SdkInfo {
|
|
|
4
4
|
}
|
|
5
5
|
type EventType = "predefined" | "custom" | "error" | "identify";
|
|
6
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";
|
|
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";
|
|
8
8
|
type FlowType = "login" | "signup" | "recovery" | "enrollment" | (string & {});
|
|
9
9
|
type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "other";
|
|
10
10
|
declare enum AuthEventName {
|
|
@@ -59,7 +59,8 @@ type UserReference = {
|
|
|
59
59
|
*/
|
|
60
60
|
type NormalizedError = {
|
|
61
61
|
name?: string;
|
|
62
|
-
|
|
62
|
+
code?: string;
|
|
63
|
+
message?: string;
|
|
63
64
|
};
|
|
64
65
|
type FlowStarted = {
|
|
65
66
|
flowName: FlowType;
|
|
@@ -211,6 +212,12 @@ interface EventBatchMeta {
|
|
|
211
212
|
}
|
|
212
213
|
interface EventMeta {
|
|
213
214
|
trackingSourcePath: string;
|
|
215
|
+
/**
|
|
216
|
+
* Per-tab id (uuidv7, `sessionStorage`-scoped) of the tab that CREATED this event, stamped at
|
|
217
|
+
* `track()` time. Late-flushed events keep the tab they originated in regardless of which page
|
|
218
|
+
* delivers them; the backend uses this to split interleaved multi-tab streams per session.
|
|
219
|
+
*/
|
|
220
|
+
tabId?: string;
|
|
214
221
|
}
|
|
215
222
|
interface EventBatch {
|
|
216
223
|
sessionId: string;
|
|
@@ -481,6 +488,13 @@ declare abstract class OperationFull {
|
|
|
481
488
|
}
|
|
482
489
|
|
|
483
490
|
type PasskeyOperationLoginExplicitSpecType = "passkey-cui" | "passkey-known-identifier" | "passkey-no-identifier"
|
|
491
|
+
/**
|
|
492
|
+
* The `-auto` variants are the same two ceremonies started by the integration rather than by a
|
|
493
|
+
* user gesture — `navigator.credentials.get()` called without user activation, so the passkey
|
|
494
|
+
* prompt appears on its own. Unlike `passkey-immediate` they still run after the auth-method
|
|
495
|
+
* decision is rendered and attribute to the same decision option as their manual counterpart.
|
|
496
|
+
*/
|
|
497
|
+
| "passkey-known-identifier-auto" | "passkey-no-identifier-auto"
|
|
484
498
|
/**
|
|
485
499
|
* WebAuthn immediate mediation (`navigator.credentials.get({ uiMode: "immediate" })`, Chrome 149+):
|
|
486
500
|
* button-triggered, discoverable credentials only (empty allowList). Shows the account picker when
|
|
@@ -598,6 +612,11 @@ type PasskeyEnrollmentPostResponseStart = {
|
|
|
598
612
|
};
|
|
599
613
|
type PasskeyEnrollmentOperationConfig = {
|
|
600
614
|
explicitSpecType?: PasskeyOperationEnrollmentExplicitSpecType;
|
|
615
|
+
/**
|
|
616
|
+
* Timestamp (epoch ms) for the subflow-started event. Set it when the enrollment began before the
|
|
617
|
+
* operation could be constructed.
|
|
618
|
+
*/
|
|
619
|
+
explicitTimestamp?: number;
|
|
601
620
|
};
|
|
602
621
|
declare class PasskeyEnrollmentOperationFull extends OperationFull {
|
|
603
622
|
readonly getOptions: StepHelper<PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentGetOptionsFinished>;
|
|
@@ -769,6 +788,23 @@ declare class AppConfirmationOperationFull extends OperationFull {
|
|
|
769
788
|
constructor(tracker: CorbadoTracker, explicitSpecType?: AppConfirmationOperationSpecType);
|
|
770
789
|
}
|
|
771
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Which captcha widget the integration observed.
|
|
793
|
+
* - `visible`: a widget presenting UI to the user. Can require interaction.
|
|
794
|
+
* - `invisible`: a widget that never presents UI and always solves itself.
|
|
795
|
+
*/
|
|
796
|
+
type CaptchaOperationSpecType = "visible" | "invisible";
|
|
797
|
+
type CaptchaOperationConfig = {
|
|
798
|
+
explicitSpecType?: CaptchaOperationSpecType;
|
|
799
|
+
};
|
|
800
|
+
declare class CaptchaOperationFull extends OperationFull {
|
|
801
|
+
/** Step representing the captcha challenge ceremony. */
|
|
802
|
+
readonly ceremony: StepHelper;
|
|
803
|
+
/** Submission of the captcha token and the server's verdict on it. */
|
|
804
|
+
readonly postResponse: StepHelper;
|
|
805
|
+
constructor(tracker: CorbadoTracker, config?: CaptchaOperationConfig);
|
|
806
|
+
}
|
|
807
|
+
|
|
772
808
|
type ProvideDataOperationSpecType = "signup" | "login" | "recovery" | "enrollment";
|
|
773
809
|
type ProvideDataOperationStart = {
|
|
774
810
|
/** Stable name of the data field collected by this subflow, when known. */
|
|
@@ -822,6 +858,8 @@ interface TrackerOptions {
|
|
|
822
858
|
* It will be removed in a future release.
|
|
823
859
|
*/
|
|
824
860
|
flushInterval?: number;
|
|
861
|
+
/** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
|
|
862
|
+
sessionIdGenerator?: () => string;
|
|
825
863
|
}
|
|
826
864
|
declare class CorbadoTracker {
|
|
827
865
|
private options;
|
|
@@ -839,6 +877,12 @@ declare class CorbadoTracker {
|
|
|
839
877
|
*/
|
|
840
878
|
private config;
|
|
841
879
|
private deviceInfoManager;
|
|
880
|
+
private deviceCollector;
|
|
881
|
+
/**
|
|
882
|
+
* Cached per-tab id stamped onto every event's meta (see {@link EventMeta.tabId}). Resolved
|
|
883
|
+
* lazily from the collector's sessionStorage-backed id; stable for the whole page lifetime.
|
|
884
|
+
*/
|
|
885
|
+
private eventTabId?;
|
|
842
886
|
private seq;
|
|
843
887
|
/**
|
|
844
888
|
* When the continuity record's `lastActiveAt` was last persisted. Throttles that write inside the
|
|
@@ -902,7 +946,8 @@ declare class CorbadoTracker {
|
|
|
902
946
|
*/
|
|
903
947
|
private resolveExperiments;
|
|
904
948
|
private isTrackingBlocked;
|
|
905
|
-
private
|
|
949
|
+
private createSessionId;
|
|
950
|
+
private resolveSessionId;
|
|
906
951
|
/**
|
|
907
952
|
* Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
|
|
908
953
|
* same browser. Rotates after `config.sessionInactivityMs` of inactivity (server-controlled,
|
|
@@ -940,6 +985,11 @@ declare class CorbadoTracker {
|
|
|
940
985
|
*/
|
|
941
986
|
private nextSeq;
|
|
942
987
|
private resolveTrackingSourcePath;
|
|
988
|
+
/**
|
|
989
|
+
* Per-tab id for event meta, cached after the first successful resolution: the id is
|
|
990
|
+
* sessionStorage-backed and stable for the whole page lifetime.
|
|
991
|
+
*/
|
|
992
|
+
private resolveEventTabId;
|
|
943
993
|
trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
|
|
944
994
|
trackSubflowTrigger(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
|
|
945
995
|
trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions, ignoreAsInteraction?: boolean): void;
|
|
@@ -1167,6 +1217,7 @@ declare class CorbadoTracker {
|
|
|
1167
1217
|
provideDataOperationFull(config?: ProvideDataOperationConfig): ProvideDataOperationFull;
|
|
1168
1218
|
socialLoginOperationFull(): SocialLoginOperationFull;
|
|
1169
1219
|
appConfirmationOperationFull(explicitSpecType?: AppConfirmationOperationSpecType): AppConfirmationOperationFull;
|
|
1220
|
+
captchaOperationFull(config?: CaptchaOperationConfig): CaptchaOperationFull;
|
|
1170
1221
|
/**
|
|
1171
1222
|
* Flush any pending events and release all resources (timers, event listeners).
|
|
1172
1223
|
*
|
|
@@ -1178,6 +1229,38 @@ declare class CorbadoTracker {
|
|
|
1178
1229
|
* resources are released either way.
|
|
1179
1230
|
*/
|
|
1180
1231
|
destroy(): Promise<void>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Return the Observe session id this tracker is currently reporting under.
|
|
1234
|
+
*
|
|
1235
|
+
* @remarks
|
|
1236
|
+
* Use this to route a server-side event into the same session the browser reports to: read the id,
|
|
1237
|
+
* pass it to your own backend, and let the backend use it as the `sessionID` of its ingest call.
|
|
1238
|
+
* Reading it here is the supported path — the storage layout behind it is an implementation detail
|
|
1239
|
+
* that has already changed once (per-tab `sessionStorage` to the cross-tab continuity record).
|
|
1240
|
+
*
|
|
1241
|
+
* The value is **not stable for the lifetime of the page**. It changes on
|
|
1242
|
+
* {@link CorbadoTracker.resetSession}, when this tab adopts a continuity session another tab
|
|
1243
|
+
* rotated to, and when a failed bootstrap recovers. Read it at the moment you need it; never cache
|
|
1244
|
+
* it across a request.
|
|
1245
|
+
*
|
|
1246
|
+
* `undefined` means no session id could be established at all — an environment without Web Crypto,
|
|
1247
|
+
* where tracking is not working either. Skip the server-side event instead of sending an empty id:
|
|
1248
|
+
* the ingest API requires a UUID and would reject the batch.
|
|
1249
|
+
*
|
|
1250
|
+
* @returns The current session id, or `undefined` if none could be established.
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```typescript
|
|
1254
|
+
* const sessionId = tracker.getSessionId();
|
|
1255
|
+
* if (sessionId) {
|
|
1256
|
+
* await fetch("/api/checkout", {
|
|
1257
|
+
* method: "POST",
|
|
1258
|
+
* body: JSON.stringify({ ...payload, observeSessionId: sessionId }),
|
|
1259
|
+
* });
|
|
1260
|
+
* }
|
|
1261
|
+
* ```
|
|
1262
|
+
*/
|
|
1263
|
+
getSessionId(): string | undefined;
|
|
1181
1264
|
/** @internal */
|
|
1182
1265
|
resetSession(): string;
|
|
1183
1266
|
}
|
|
@@ -1635,6 +1718,11 @@ declare class EventStore {
|
|
|
1635
1718
|
declare function init(options: TrackerOptions): CorbadoTracker;
|
|
1636
1719
|
declare function getTracker(): CorbadoTracker | undefined;
|
|
1637
1720
|
declare function resetSession(): string | undefined;
|
|
1721
|
+
/**
|
|
1722
|
+
* Session id of the global tracker, or `undefined` when no tracker was initialized or no session
|
|
1723
|
+
* could be established. See {@link CorbadoTracker.getSessionId}.
|
|
1724
|
+
*/
|
|
1725
|
+
declare function getSessionId(): string | undefined;
|
|
1638
1726
|
declare function setExperiment(key: string, variant: string): void;
|
|
1639
1727
|
declare function setExperiments(assignments: Record<string, string>): void;
|
|
1640
1728
|
declare function clearExperiment(key: string): void;
|
|
@@ -1645,4 +1733,4 @@ declare function logInfo(message: string): void;
|
|
|
1645
1733
|
declare function logError(message: string): void;
|
|
1646
1734
|
declare function destroy(): Promise<void>;
|
|
1647
1735
|
|
|
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 };
|
|
1736
|
+
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 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, 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, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, parseReliabilityConfig, resetSession, setExperiment, setExperiments, telemetry };
|