@corbado/observe 0.0.1-next.9 → 0.1.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/index.d.mts CHANGED
@@ -1,16 +1,10 @@
1
- interface User {
2
- id?: string;
3
- email?: string;
4
- username?: string;
5
- name?: string;
6
- [key: string]: unknown;
7
- }
8
1
  interface SdkInfo {
9
2
  name: string;
10
3
  version: string;
11
4
  }
12
5
  type EventType = "predefined" | "custom" | "error" | "identify";
13
- type LoginMethodType = "identifier-email" | "passkey" | "passkey-conditional-ui" | "password" | "email-otp" | "email-link" | "phone-otp" | "switch-method" | "reset-flow" | "social-google" | "social-apple" | "social-facebook" | "social-other";
6
+ type AuthMethodType = "identifier-email" | "passkey-login-known-identifier" | "passkey-login-no-identifier" | "passkey-login-cui" | "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";
7
+ type SubflowType = "passkey-enrollment" | "passkey-login" | "email-otp" | "email-link" | "social-login" | "sms-otp" | "provide-identifier" | "provide-data" | "password-login" | "password-enrollment" | "totp";
14
8
  type FlowType = "login" | "signup" | "recovery" | "enrollment";
15
9
  type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "other";
16
10
  declare enum AuthEventName {
@@ -19,53 +13,17 @@ declare enum AuthEventName {
19
13
  FlowFinished = "flow_finished",
20
14
  FlowReset = "flow_reset",
21
15
  AuthMethodDecisionStarted = "auth_method_decision_started",
16
+ AuthMethodDecisionFinished = "auth_method_decision_finished",
22
17
  FlowAutoFinished = "flow_auto_finished",
23
18
  AuthDecisionStarted = "auth_decision_started",
24
19
  AuthDecisionFinished = "auth_decision_finished",
25
- ProvideIdentifierStarted = "provide_identifier_started",
26
- ProvideIdentifierSubmitted = "provide_identifier_submitted",
27
- ProvideIdentifierFinished = "provide_identifier_finished",
28
- ProvideIdentifierError = "provide_identifier_error",
29
- PasswordLoginStartable = "password_login_startable",
30
- PasswordLoginStarted = "password_login_started",
31
- PasswordLoginSubmitted = "password_login_submitted",
32
- PasswordLoginFinished = "password_login_finished",
33
- PasswordLoginError = "password_login_error",
34
- PasswordLoginForgotPasswordClicked = "password_login_forgot_password_clicked",
35
- PasskeyLoginStartable = "passkey_login_startable",
36
- PasskeyLoginStarted = "passkey_login_started",
37
- PasskeyLoginSubmitted = "passkey_login_submitted",
38
- PasskeyLoginFinished = "passkey_login_finished",
39
- PasskeyLoginError = "passkey_login_error",
40
- CUILoginStartable = "cui_login_startable",
41
- CUILoginStarted = "cui_login_started",
42
- CUILoginSubmitted = "cui_login_submitted",
43
- CUILoginFinished = "cui_login_finished",
44
- CUILoginError = "cui_login_error",
45
- SocialLoginStarted = "social_login_started",
46
- SocialLoginFinished = "social_login_finished",
47
- SocialLoginError = "social_login_error",
48
- PasskeyEnrollmentStartable = "passkey_enrollment_startable",
49
- PasskeyEnrollmentStarted = "passkey_enrollment_started",
50
- PasskeyEnrollmentSubmitted = "passkey_enrollment_submitted",
51
- PasskeyEnrollmentFinished = "passkey_enrollment_finished",
52
- PasskeyEnrollmentSkipped = "passkey_enrollment_skipped",
53
- PasskeyEnrollmentError = "passkey_enrollment_error",
54
- EmailLinkStartable = "email_link_startable",
55
- EmailLinkSubmitted = "email_link_submitted",
56
- EmailLinkFinished = "email_link_finished",
57
- EmailLinkError = "email_link_error",
58
- EmailOTPStartable = "email_otp_startable",
59
- EmailOTPStarted = "email_otp_started",
60
- EmailOTPSubmitted = "email_otp_submitted",
61
- EmailOTPFinished = "email_otp_finished",
62
- EmailOTPError = "email_otp_error",
63
- EmailOTPResent = "email_otp_resent",
64
- SetPasswordStartable = "set_password_startable",
65
- SetPasswordStarted = "set_password_started",
66
- SetPasswordSubmitted = "set_password_submitted",
67
- SetPasswordFinished = "set_password_finished",
68
- SetPasswordError = "set_password_error"
20
+ SubflowStepStarted = "subflow_step_started",
21
+ SubflowStepFinished = "subflow_step_finished",
22
+ SubflowStepError = "subflow_step_error",
23
+ SubflowTrigger = "subflow_trigger",
24
+ SubflowError = "subflow_error",
25
+ SubflowStarted = "subflow_started",
26
+ SubflowFinished = "subflow_finished"
69
27
  }
70
28
  interface BaseEvent {
71
29
  timestamp: number;
@@ -103,6 +61,7 @@ type FlowDecided = {
103
61
  };
104
62
  type FlowFinished = {
105
63
  flowName: FlowType;
64
+ explicitOutcome?: "skipped" | "invisible";
106
65
  } & UserReference;
107
66
  type FlowReset = {
108
67
  flowName: FlowType;
@@ -113,7 +72,12 @@ type FlowAutoFinished = {
113
72
  } & UserReference;
114
73
  type AuthMethodDecisionStarted = {
115
74
  decisionName: string;
116
- options: LoginMethodType[];
75
+ options: (AuthMethodType | (string & {}))[];
76
+ explicitDecisionValue?: string;
77
+ };
78
+ type AuthMethodDecisionFinished = {
79
+ decisionName: string;
80
+ options: (AuthMethodType | (string & {}))[];
117
81
  explicitDecisionValue?: string;
118
82
  };
119
83
  type ProvideIdentifierStart = {};
@@ -124,24 +88,9 @@ type ProvideIdentifierError = UserReference & {
124
88
  type ProvideIdentifierFinish = UserReference & {
125
89
  identifierPrefillingCreated?: boolean;
126
90
  };
127
- interface PasswordLoginStartable {
128
- explicitSpecType?: "pre-identifier" | "post-identifier";
129
- }
130
- interface PasswordLoginStarted {
131
- explicitSpecType?: "pre-identifier" | "post-identifier";
132
- }
133
- type PasswordLoginFinish = {};
134
- type LoginStepPasswordErrorCode = 'invalid_password' | 'unknown';
135
- type PasswordLoginError = {
136
- errorCode?: LoginStepPasswordErrorCode;
137
- error?: any;
138
- };
139
91
  type PasskeyLoginClientError = {
140
92
  error: any;
141
93
  };
142
- type PasskeyLoginStart = {
143
- explicitSpecType: "passkey-cui" | "passkey-identifier" | "passkey-button";
144
- } & PasskeyLoginStartable;
145
94
  type PasskeyLoginStartable = {
146
95
  assertionOptions: string;
147
96
  };
@@ -149,16 +98,6 @@ type PasskeyLoginSubmitted = {
149
98
  assertionResponse: string;
150
99
  };
151
100
  type PasskeyLoginFinish = UserReference & {};
152
- type SocialLoginStart = {
153
- explicitSpecType: "pre-identifier" | "post-identifier";
154
- provider: SocialLoginProviderType;
155
- };
156
- type SocialLoginFinish = UserReference & {
157
- provider: SocialLoginProviderType;
158
- };
159
- type SocialLoginError = UserReference & {
160
- errorCode: string;
161
- };
162
101
  type AuthDecisionStarted = {
163
102
  decisionName: string;
164
103
  options: string[];
@@ -168,21 +107,13 @@ type AuthDecisionFinished = {
168
107
  options: string[];
169
108
  explicitDecisionValue?: string;
170
109
  };
171
- type PasskeyEnrollmentStartable = {};
172
- type PasskeyEnrollmentStarted = {
173
- conditional: boolean;
174
- auto: boolean;
175
- attestationOptions: string;
176
- };
177
- type PasskeyEnrollmentSubmitted = {
178
- conditional: boolean;
179
- auto: boolean;
180
- attestationResponse: string;
110
+ type StepOptions = {
111
+ userReference?: UserReference;
112
+ explicitTimestamp?: number;
181
113
  };
182
- type PasskeyEnrollmentFinished = {};
183
- type PasskeyEnrollmentError = {
184
- errorCode?: string;
185
- error?: unknown;
114
+ type SubflowTrigger = {
115
+ actor: "system" | "user";
116
+ explicitSpecType?: string;
186
117
  };
187
118
  interface PredefinedEvent extends BaseEvent {
188
119
  type: "predefined";
@@ -227,152 +158,222 @@ type ClientEnvHandleMeta = {
227
158
  source: ClientEnvHandleMetaSource;
228
159
  };
229
160
  type ClientEnvHandleMetaSource = "localstorage" | "cookie" | "native";
230
- type EmailOTPStartable = {};
231
- type EmailOTPStarted = {};
232
- type EmailOTPSubmitted = {};
233
- type EmailOTPFinished = {};
234
- type EmailOTPError = {
235
- errorCode: string;
236
- };
237
- type EmailOTPResent = {};
238
- type EmailLinkStartable = {
239
- crossEnvironmentTransactionID?: string;
240
- } & UserReference;
241
- type EmailLinkSubmitted = {
242
- crossEnvironmentTransactionID?: string;
243
- };
244
- type EmailLinkFinished = {} & UserReference;
245
- type EmailLinkError = {
246
- errorCode: string;
247
- };
248
- type SetPasswordStartable = {};
249
- type SetPasswordStarted = {};
250
- type SetPasswordSubmitted = {};
251
- type SetPasswordFinished = {};
252
- type SetPasswordError = {
253
- errorCode: string;
254
- origin: "client" | "server";
255
- };
256
161
 
257
- declare class PasskeyOperationLogin {
162
+ type StepHelper<TStart = {}, TFinished = {}, TTypedError = never> = {
163
+ start: (data: TStart, options?: StepOptions) => void;
164
+ finished: (data: TFinished, options?: StepOptions) => void;
165
+ error: (error: unknown, options?: StepOptions) => void;
166
+ } & ([TTypedError] extends [never] ? {} : {
167
+ errorTyped: (error: TTypedError, options?: StepOptions) => void;
168
+ });
169
+ declare abstract class OperationFull {
258
170
  private tracker;
259
- constructor(tracker: CorbadoTracker, data: PasskeyLoginStart, tags?: Record<string, string>, contexts?: Record<string, any>);
260
- started(data: PasskeyLoginStart, tags?: Record<string, string>, contexts?: Record<string, any>): void;
261
- submitted(data: PasskeyLoginSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
262
- finished(data: PasskeyLoginFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
263
- clientError(data: PasskeyLoginClientError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
264
- serverErrorUnknown(error?: any, tags?: Record<string, string>, contexts?: Record<string, any>): void;
171
+ private operationName;
172
+ constructor(tracker: CorbadoTracker, operationName: SubflowType);
173
+ subflowStart(data: any, options?: StepOptions): void;
174
+ trigger(data: SubflowTrigger, options?: StepOptions): void;
175
+ customStep<TStart = {}, TFinished = {}>(stepName: string): StepHelper<TStart, TFinished>;
176
+ protected subflowStepStarted(stepName: string, data: any, options?: StepOptions): void;
177
+ protected subflowStepFinished(stepName: string, data: any, options?: StepOptions): void;
178
+ protected subflowStepError(stepName: string, data: any, options?: StepOptions): void;
179
+ protected defineStep<TStart = {}, TFinished = {}, TTypedError = never>(stepName: string): StepHelper<TStart, TFinished, TTypedError>;
265
180
  }
266
181
 
267
- declare class PasskeyOperationEnrollment {
268
- private tracker;
269
- constructor(tracker: CorbadoTracker, data: PasskeyEnrollmentStartable, tags?: Record<string, string>, contexts?: Record<string, any>);
270
- startable(data: PasskeyEnrollmentStartable, tags?: Record<string, string>, contexts?: Record<string, any>): void;
271
- started(data: PasskeyEnrollmentStarted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
272
- submitted(data: PasskeyEnrollmentSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
273
- finished(data: PasskeyEnrollmentFinished, tags?: Record<string, string>, contexts?: Record<string, any>): void;
274
- skipped(data: {}, tags?: Record<string, string>, contexts?: Record<string, any>): void;
275
- clientError(data: PasskeyEnrollmentError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
276
- serverErrorUnknown(error?: any, tags?: Record<string, string>, contexts?: Record<string, any>): void;
182
+ type PasskeyOperationLoginExplicitSpecType = "passkey-cui" | "passkey-known-identifier" | "passkey-no-identifier";
183
+ type PasskeyLoginGetOptionsStart = {
184
+ explicitSpecType?: PasskeyOperationLoginExplicitSpecType;
185
+ };
186
+ type PasskeyLoginGetOptionsFinished = {
187
+ explicitSpecType?: PasskeyOperationLoginExplicitSpecType;
188
+ assertionOptions: string;
189
+ };
190
+ type PasskeyLoginCeremonyStart = {
191
+ explicitSpecType?: PasskeyOperationLoginExplicitSpecType;
192
+ assertionOptions?: string;
193
+ };
194
+ type PasskeyLoginCeremonyFinished = {
195
+ assertionResponse: string;
196
+ };
197
+ declare class PasskeyLoginOperationFull extends OperationFull {
198
+ readonly getOptions: StepHelper<PasskeyLoginGetOptionsStart, PasskeyLoginGetOptionsFinished>;
199
+ readonly ceremony: StepHelper<PasskeyLoginCeremonyStart, PasskeyLoginCeremonyFinished>;
200
+ readonly postResponse: StepHelper;
201
+ constructor(tracker: CorbadoTracker);
277
202
  }
278
203
 
279
- declare class ProvideIdentifierOperation {
280
- private tracker;
281
- private patternDetector?;
282
- constructor(tracker: CorbadoTracker, inputHtmlField?: HTMLInputElement);
283
- destroy(): void;
284
- identifierStarted(data: ProvideIdentifierStart, tags?: Record<string, string>, contexts?: Record<string, any>): void;
285
- identifierSubmitted(data: {}, tags?: Record<string, string>, contexts?: Record<string, any>): void;
286
- identifierFinished(data: ProvideIdentifierFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
287
- identifierError(data: ProvideIdentifierError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
288
- conditionalUIStartable(data: PasskeyLoginStartable, tags?: Record<string, string>, contexts?: Record<string, any>): void;
289
- conditionalUISubmitted(data: PasskeyLoginSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
290
- conditionalUIFinished(data: PasskeyLoginFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
291
- conditionalUIClientError(data: PasskeyLoginClientError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
292
- conditionalUIServerErrorConditionalUICredentialDeleted(tags?: Record<string, string>, contexts?: Record<string, any>): void;
293
- conditionalUIServerErrorUnknown(error?: any, tags?: Record<string, string>, contexts?: Record<string, any>): void;
204
+ type EmailOTPOperationSpecType = "email-otp-login" | "email-otp-enrollment";
205
+ type EmailOTPOperationSendOTPStart = {
206
+ explicitSpecType?: EmailOTPOperationSpecType;
207
+ };
208
+ type EmailOTPOperationPostResponseStart = {
209
+ explicitSpecType?: EmailOTPOperationSpecType;
210
+ };
211
+ declare class EmailOtpOperationFull extends OperationFull {
212
+ readonly send: StepHelper<EmailOTPOperationSendOTPStart>;
213
+ readonly postResponse: StepHelper<EmailOTPOperationPostResponseStart>;
214
+ readonly resend: StepHelper;
215
+ constructor(tracker: CorbadoTracker);
294
216
  }
295
217
 
296
- declare class PasswordOperationLogin {
297
- private tracker;
298
- private patternDetector?;
299
- constructor(tracker: CorbadoTracker, inputHtmlField?: HTMLInputElement);
300
- startable(data: PasswordLoginStartable, tags?: Record<string, string>, contexts?: Record<string, any>): void;
301
- started(data: PasswordLoginStarted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
302
- submitted(data: {}, tags?: Record<string, string>, contexts?: Record<string, any>): void;
303
- finished(data: PasswordLoginFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
304
- error(data: PasswordLoginError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
305
- /**
306
- * Fire when the user clicks on the "Forgot password" link during the password login flow.
307
- */
308
- forgotPasswordClicked(data: {}, tags?: Record<string, string>, contexts?: Record<string, any>): void;
309
- destroy(): void;
218
+ type EmailLinkOperationSpecType = "email-link-login" | "email-link-enrollment";
219
+ type EmailLinkOperationSendStart = {
220
+ explicitSpecType?: EmailLinkOperationSpecType;
221
+ };
222
+ type EmailLinkOperationPostResponseStart = {
223
+ explicitSpecType?: EmailLinkOperationSpecType;
224
+ };
225
+ declare class EmailLinkOperationFull extends OperationFull {
226
+ readonly send: StepHelper<EmailLinkOperationSendStart>;
227
+ readonly postResponse: StepHelper<EmailLinkOperationPostResponseStart>;
228
+ readonly resend: StepHelper;
229
+ constructor(tracker: CorbadoTracker);
310
230
  }
311
231
 
312
- declare class SocialOperationLogin {
313
- private tracker;
232
+ type PasskeyOperationEnrollmentExplicitSpecType = "conditional-auto-manual" | "auto-manual" | "manual";
233
+ type PasskeyEnrollmentGetOptionsStart = {
234
+ explicitSpecType?: PasskeyOperationEnrollmentExplicitSpecType;
235
+ };
236
+ type PasskeyEnrollmentGetOptionsFinished = {
237
+ explicitSpecType?: PasskeyOperationEnrollmentExplicitSpecType;
238
+ attestationOptions: string;
239
+ };
240
+ type PasskeyEnrollmentCeremonyStart = {
241
+ explicitSpecType?: PasskeyOperationEnrollmentExplicitSpecType;
242
+ attestationOptions?: string;
243
+ mediation: "conditional" | "optional" | "required";
244
+ };
245
+ type PasskeyEnrollmentCeremonyFinished = {
246
+ attestationResponse: string;
247
+ };
248
+ declare class PasskeyEnrollmentOperationFull extends OperationFull {
249
+ readonly getOptions: StepHelper<PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentGetOptionsFinished>;
250
+ readonly ceremony: StepHelper<PasskeyEnrollmentCeremonyStart, PasskeyEnrollmentCeremonyFinished>;
251
+ readonly postResponse: StepHelper;
314
252
  constructor(tracker: CorbadoTracker);
315
- started(data: SocialLoginStart, tags?: Record<string, string>, contexts?: Record<string, any>): void;
316
- finished(data: SocialLoginFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
317
- error(data: SocialLoginError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
318
253
  }
319
254
 
320
- declare class EmailOTPOperation {
321
- private tracker;
322
- constructor(tracker: CorbadoTracker);
323
- startable(data?: EmailOTPStartable, tags?: Record<string, string>, contexts?: Record<string, any>): void;
324
- started(data?: EmailOTPStarted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
325
- submitted(data?: EmailOTPSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
326
- finished(data?: EmailOTPFinished, tags?: Record<string, string>, contexts?: Record<string, any>): void;
327
- error(data: EmailOTPError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
328
- resent(data?: EmailOTPResent, tags?: Record<string, string>, contexts?: Record<string, any>): void;
255
+ interface Logger {
256
+ debug(message: string, ...args: unknown[]): void;
257
+ info(message: string, ...args: unknown[]): void;
258
+ warn(message: string, ...args: unknown[]): void;
259
+ error(message: string, ...args: unknown[]): void;
260
+ critical(message: string, ...args: unknown[]): void;
261
+ }
262
+ interface CreateLoggerOptions {
263
+ debug: boolean;
329
264
  }
265
+ declare function createLogger(options: CreateLoggerOptions): Logger;
330
266
 
331
- declare class EmailLinkOperation {
332
- private tracker;
333
- constructor(tracker: CorbadoTracker);
334
- /**
335
- * Fire when the email containing the link has been sent to the user.
336
- */
337
- startable(data?: EmailLinkStartable, tags?: Record<string, string>, contexts?: Record<string, any>): void;
338
- /**
339
- * Fire when the link has been opened and right before the verification process starts.
340
- */
341
- submitted(data?: EmailLinkSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
342
- /**
343
- * Fire when the verification process has been completed successfully.
344
- */
345
- finished(data?: EmailLinkFinished, tags?: Record<string, string>, contexts?: Record<string, any>): void;
346
- /**
347
- * Fire when an error occurs during the verification process.
348
- */
349
- error(data: EmailLinkError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
267
+ type PasswordLoginTypedError = {
268
+ code: PasswordLoginTypedErrorCode;
269
+ };
270
+ type PasswordLoginTypedErrorCode = "invalid_password" | "user_not_found" | "account_locked";
271
+ type PasswordLoginExplicitSpecType = "password-known-identifier" | "password-with-identifier";
272
+ type PasswordLoginAutoTrackConfig = {
273
+ explicitSpecType: PasswordLoginExplicitSpecType;
274
+ inputHtmlField: HTMLInputElement;
275
+ };
276
+ declare class PasswordLoginOperationFull extends OperationFull {
277
+ readonly postResponse: StepHelper<{}, {}, PasswordLoginTypedError>;
278
+ private patternDetector?;
279
+ constructor(tracker: CorbadoTracker, autoTrackConfig?: PasswordLoginAutoTrackConfig);
280
+ destroy(): void;
350
281
  }
351
282
 
352
- declare class SetPasswordOperation {
283
+ type PasswordEnrollmentTypedError = {
284
+ code: PasswordEnrollmentTypedErrorCode;
285
+ };
286
+ type PasswordEnrollmentTypedErrorCode = "requirements_not_fulfilled";
287
+ type PasswordEnrollmentExplicitSpecType = "password-set" | "password-reset";
288
+ type PasswordEnrollmentAutoTrackConfig = {
289
+ explicitSpecType: PasswordEnrollmentExplicitSpecType;
290
+ inputHtmlField: HTMLInputElement;
291
+ };
292
+ declare class PasswordEnrollmentOperationFull extends OperationFull {
293
+ readonly postResponse: StepHelper<{}, {}, PasswordEnrollmentTypedError>;
294
+ private patternDetector?;
295
+ constructor(tracker: CorbadoTracker, autoTrackConfig?: PasswordEnrollmentAutoTrackConfig);
296
+ destroy(): void;
297
+ }
298
+
299
+ type PasskeyLoginCUITypedError = {
300
+ code: PasskeyLoginCUITypedErrorCode;
301
+ };
302
+ type PasskeyLoginCUITypedErrorCode = "cancel_detected";
303
+ type ProvideIdentifierSpecType = "email";
304
+ type ProvideIdentifierPostResponseStart = {
305
+ explicitSpecType?: ProvideIdentifierSpecType;
306
+ };
307
+ type PasskeyLoginCUISpecType = "passkey-cui";
308
+ type CUICeremonyStart = {
309
+ explicitSpecType?: PasskeyLoginCUISpecType;
310
+ };
311
+ type PasskeyLoginCUIGetOptionsStart = {
312
+ explicitSpecType?: PasskeyLoginCUISpecType;
313
+ };
314
+ type PasskeyLoginCUIGetOptionsFinished = {
315
+ explicitSpecType?: ProvideIdentifierSpecType;
316
+ assertionOptions: string;
317
+ };
318
+ declare class OperationFullProvideIdentifierWithCUI {
353
319
  private tracker;
354
320
  private patternDetector?;
321
+ readonly cui: {
322
+ trigger: (data: SubflowTrigger, options?: StepOptions) => void;
323
+ getOptions: StepHelper<PasskeyLoginCUIGetOptionsStart, PasskeyLoginCUIGetOptionsFinished>;
324
+ ceremony: StepHelper<CUICeremonyStart, PasskeyLoginCeremonyFinished, PasskeyLoginCUITypedError>;
325
+ postResponse: StepHelper;
326
+ };
327
+ readonly provideIdentifier: {
328
+ trigger: (data: SubflowTrigger, options?: StepOptions) => void;
329
+ postResponse: StepHelper<ProvideIdentifierPostResponseStart>;
330
+ };
355
331
  constructor(tracker: CorbadoTracker, inputHtmlField?: HTMLInputElement);
356
- startable(data?: SetPasswordStartable, tags?: Record<string, string>, contexts?: Record<string, any>): void;
357
- started(data?: SetPasswordStarted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
358
- submitted(data?: SetPasswordSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
359
- finished(data?: SetPasswordFinished, tags?: Record<string, string>, contexts?: Record<string, any>): void;
360
- error(data: SetPasswordError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
332
+ private createStep;
361
333
  destroy(): void;
362
334
  }
363
335
 
336
+ type SocialLoginSpecType = "pre-identifier" | "post-identifier";
337
+ type SocialLoginGetRedirectUrlStart = {
338
+ provider?: SocialLoginProviderType;
339
+ explicitSpecType: SocialLoginSpecType;
340
+ };
341
+ type SocialLoginGetRedirectUrlFinished = {};
342
+ type SocialLoginExchangeCodeStart = {
343
+ provider?: SocialLoginProviderType;
344
+ };
345
+ type SocialLoginExchangeCodeFinished = {};
346
+ declare class SocialLoginOperationFull extends OperationFull {
347
+ readonly getRedirectUrl: StepHelper<SocialLoginGetRedirectUrlStart, SocialLoginGetRedirectUrlFinished>;
348
+ readonly exchangeCode: StepHelper<SocialLoginExchangeCodeStart, SocialLoginExchangeCodeFinished>;
349
+ constructor(tracker: CorbadoTracker);
350
+ }
351
+
364
352
  interface TrackerOptions {
365
353
  projectId: string;
366
354
  apiBaseUrl: string;
367
355
  apiEventPath?: string;
368
356
  storage?: "cookie" | "local";
357
+ cookieDomain?: string;
369
358
  debug?: boolean;
359
+ logger?: Logger;
370
360
  deviceInfoDebounceTime?: number;
371
361
  defaultTags?: Record<string, string>;
372
362
  applicationId?: string;
373
363
  }
364
+ /**
365
+ * @remarks
366
+ * **Constructor**
367
+ * - If `apiBaseUrl` is non-empty and missing `http://` or `https://`: logs via `logger.critical` (does not throw).
368
+ * - If `apiBaseUrl` is non-empty and ends with `/`: logs via `logger.critical` (does not throw).
369
+ * - Session bootstrap (`getSessionId`): on failure logs `Failed to get session id` and continues with an empty session id (does not throw).
370
+ *
371
+ * **Typed tracking helpers** (`flowStarted`, `flowDecided`, and the other public methods that call `track`)
372
+ * - Error handling for queued events is defined on {@link CorbadoTracker.track}.
373
+ */
374
374
  declare class CorbadoTracker {
375
375
  private options;
376
+ private logger;
376
377
  private queue;
377
378
  private sessionId;
378
379
  private storage;
@@ -382,12 +383,28 @@ declare class CorbadoTracker {
382
383
  private deviceInfoTransmittedLastTime;
383
384
  private seq;
384
385
  constructor(options: TrackerOptions);
386
+ /**
387
+ * Returns the logger used by this tracker.
388
+ */
389
+ getLogger(): Logger;
385
390
  private applicationTag;
386
- private debugMessage;
387
391
  private isTrackingBlocked;
388
392
  private getSessionId;
389
393
  private updateDeviceDebounced;
390
- /** @internal */
394
+ trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
395
+ trackSubflowTrigger(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
396
+ trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
397
+ trackSubflowStepFinished(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
398
+ trackSubflowStepError(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
399
+ trackSubflowFinished(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
400
+ trackSubflowError(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
401
+ /**
402
+ * Error situations:
403
+ * - Blocked user agent (see `isBlockedUserAgent`): skip with a debug log and return
404
+ * - Any error before the event is enqueued (e.g. device info update, `JSON.stringify` in debug logging, `queue.enqueue`): log `Failed to process event "<name>" before enqueue`
405
+ *
406
+ * @internal
407
+ */
391
408
  track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number): Promise<void>;
392
409
  /**
393
410
  * Track when an authentication flow (or flow selection screen) becomes visible.
@@ -505,424 +522,26 @@ declare class CorbadoTracker {
505
522
  * ```
506
523
  */
507
524
  authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>): void;
508
- /**
509
- * Create a trackable identifier-provision operation without immediately firing an event.
510
- *
511
- * @remarks
512
- * Returns a {@link ProvideIdentifierOperation} that you can drive through
513
- * `identifierStarted` → `identifierSubmitted` → `identifierFinished` / `identifierError`.
514
- * Pass an `inputHtmlField` to auto-instrument keystroke and paste detection on the identifier input.
515
- *
516
- * @param inputHtmlField - Optional HTML input element to instrument for interaction detection.
517
- * @returns A {@link ProvideIdentifierOperation} instance.
518
- *
519
- * @example
520
- * ```typescript
521
- * const op = tracker.provideIdentifierStartable(document.getElementById("email") as HTMLInputElement);
522
- * op.identifierStarted();
523
- * ```
524
- */
525
- provideIdentifierStartable(inputHtmlField?: HTMLInputElement): ProvideIdentifierOperation;
526
- /**
527
- * Track the start of the identifier-provision step and return the operation handle.
528
- *
529
- * @remarks
530
- * Call this when the user begins entering their identifier (email, phone, username).
531
- * The returned {@link ProvideIdentifierOperation} lets you continue tracking through
532
- * submission, completion, or error.
533
- *
534
- * @param data - Event payload (currently empty, reserved for future fields).
535
- * @param inputHtmlField - Optional HTML input element to instrument for interaction detection.
536
- * @param tags - Optional key-value tags for filtering and segmentation.
537
- * @param contexts - Optional contextual metadata attached to the event.
538
- * @returns A {@link ProvideIdentifierOperation} instance.
539
- *
540
- * @example
541
- * ```typescript
542
- * const op = tracker.provideIdentifierStarted({}, emailInput);
543
- * ```
544
- */
545
- provideIdentifierStarted(data?: ProvideIdentifierStart, inputHtmlField?: HTMLInputElement, tags?: Record<string, string>, contexts?: Record<string, any>): ProvideIdentifierOperation;
546
- /**
547
- * Track when the user submits their identifier.
548
- *
549
- * @remarks
550
- * Fire this event after the user confirms their identifier (e.g. clicks "Continue"
551
- * or presses Enter). This sits between the started and finished/error events.
552
- *
553
- * @param data - Event payload (currently empty, reserved for future fields).
554
- * @param tags - Optional key-value tags for filtering and segmentation.
555
- * @param contexts - Optional contextual metadata attached to the event.
556
- *
557
- * @example
558
- * ```typescript
559
- * tracker.provideIdentifierSubmitted({});
560
- * ```
561
- */
562
- provideIdentifierSubmitted(data: {}, tags?: Record<string, string>, contexts?: Record<string, any>): void;
563
- /**
564
- * Track when identifier provision completes successfully.
565
- *
566
- * @remarks
567
- * Fire this after the backend has validated the identifier and returned
568
- * the available authentication methods. Include `availableMethods` and
569
- * `preferredMethod` so downstream analytics can evaluate method selection.
570
- *
571
- * @param data - Event payload containing the user reference and available methods.
572
- * @param tags - Optional key-value tags for filtering and segmentation.
573
- * @param contexts - Optional contextual metadata attached to the event.
574
- *
575
- * @example
576
- * ```typescript
577
- * tracker.provideIdentifierFinished({
578
- * identifier: "user@example.com",
579
- * availableMethods: ["passkey", "password"],
580
- * preferredMethod: "passkey",
581
- * });
582
- * ```
583
- */
584
- provideIdentifierFinished(data: ProvideIdentifierFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
585
- /**
586
- * Track when identifier provision fails.
587
- *
588
- * @remarks
589
- * Fire this when the identifier lookup or validation returns an error
590
- * (e.g. unknown user, rate limit, network failure).
591
- *
592
- * @param data - Event payload containing the user reference and error details.
593
- * @param tags - Optional key-value tags for filtering and segmentation.
594
- * @param contexts - Optional contextual metadata attached to the event.
595
- *
596
- * @example
597
- * ```typescript
598
- * tracker.provideIdentifierError({
599
- * identifier: "user@example.com",
600
- * error: "user_not_found",
601
- * });
602
- * ```
603
- */
604
- provideIdentifierError(data: ProvideIdentifierError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
605
- /**
606
- * Create a trackable password-login operation and mark it as startable.
607
- *
608
- * @remarks
609
- * Returns a {@link PasswordOperationLogin} that you can drive through the
610
- * `started` → `submitted` → `finished` / `error` lifecycle.
611
- * Pass an `inputHtmlField` to auto-instrument the password input for
612
- * interaction detection (e.g. paste, password-manager usage).
613
- *
614
- * @param inputHtmlField - Optional HTML input element to instrument.
615
- * @param data - Optional password-login startable metadata.
616
- * @param tags - Optional key-value tags for filtering and segmentation.
617
- * @param contexts - Optional contextual metadata attached to the event.
618
- * @returns A {@link PasswordOperationLogin} instance.
619
- *
620
- * @example
621
- * ```typescript
622
- * const op = tracker.passwordLoginStartable(document.getElementById("password") as HTMLInputElement);
623
- * ```
624
- */
625
- passwordLoginStartable(inputHtmlField?: HTMLInputElement, data?: PasswordLoginStartable, tags?: Record<string, string>, contexts?: Record<string, any>): PasswordOperationLogin;
626
- /**
627
- * Track the start of a password login attempt.
628
- *
629
- * @remarks
630
- * Fire this when the user begins entering their password.
631
- * Use the payload fields to record whether a password manager
632
- * was detected or the keyboard was used for input.
633
- *
634
- * @param data - Event payload with optional interaction metadata.
635
- * @param tags - Optional key-value tags for filtering and segmentation.
636
- * @param contexts - Optional contextual metadata attached to the event.
637
- * @returns A {@link PasswordOperationLogin} instance.
638
- *
639
- * @example
640
- * ```typescript
641
- * const op = tracker.passwordLoginStarted({ passwordManagerUsed: true });
642
- * ```
643
- */
644
- passwordLoginStarted(data?: PasswordLoginStarted, tags?: Record<string, string>, contexts?: Record<string, any>): PasswordOperationLogin;
645
- /**
646
- * Track when the user submits their password.
647
- *
648
- * @remarks
649
- * Fire this after the user confirms their password entry (e.g. clicks
650
- * "Sign in" or presses Enter). This sits between the started and
651
- * finished/error events.
652
- *
653
- * @param data - Event payload (currently empty, reserved for future fields).
654
- * @param tags - Optional key-value tags for filtering and segmentation.
655
- * @param contexts - Optional contextual metadata attached to the event.
656
- *
657
- * @example
658
- * ```typescript
659
- * tracker.passwordLoginSubmitted({});
660
- * ```
661
- */
662
- passwordLoginSubmitted(data: {}, tags?: Record<string, string>, contexts?: Record<string, any>): void;
663
- /**
664
- * Track when a password login completes successfully.
665
- *
666
- * @remarks
667
- * Fire this after the backend has verified the password and the user
668
- * is authenticated.
669
- *
670
- * @param data - Event payload (currently empty, reserved for future fields).
671
- * @param tags - Optional key-value tags for filtering and segmentation.
672
- * @param contexts - Optional contextual metadata attached to the event.
673
- *
674
- * @example
675
- * ```typescript
676
- * tracker.passwordLoginFinished({});
677
- * ```
678
- */
679
- passwordLoginFinished(data: PasswordLoginFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
680
- /**
681
- * Track when a password login attempt fails.
682
- *
683
- * @remarks
684
- * Fire this when password verification fails (e.g. invalid password,
685
- * account locked, server error).
686
- *
687
- * @param data - Event payload (currently empty, reserved for future fields).
688
- * @param tags - Optional key-value tags for filtering and segmentation.
689
- * @param contexts - Optional contextual metadata attached to the event.
690
- *
691
- * @example
692
- * ```typescript
693
- * tracker.passwordLoginError({});
694
- * ```
695
- */
696
- passwordLoginError(data: PasswordLoginError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
697
- /**
698
- * Track the start of a passkey (WebAuthn) login and return the operation handle.
699
- *
700
- * @remarks
701
- * Fire this when a passkey authentication ceremony begins.
702
- * Set `conditional` to `true` for Conditional UI (autofill) flows, or `false`
703
- * for an explicit "Sign in with passkey" button click.
704
- * The returned {@link PasskeyOperationLogin} manages the remaining lifecycle events
705
- * (submitted, finished, error) automatically.
706
- *
707
- * @param data - Event payload including the `conditional` flag.
708
- * @param tags - Optional key-value tags for filtering and segmentation.
709
- * @param contexts - Optional contextual metadata attached to the event.
710
- * @returns A {@link PasskeyOperationLogin} instance.
711
- *
712
- * @example
713
- * ```typescript
714
- * const op = tracker.passkeyLoginStart({ conditional: false });
715
- * ```
716
- */
717
- passkeyLoginStart(data: PasskeyLoginStart, tags?: Record<string, string>, contexts?: Record<string, any>): PasskeyOperationLogin;
718
- /**
719
- * Track the start of a social login (OAuth / OpenID Connect) flow.
720
- *
721
- * @remarks
722
- * Fire this when the user initiates a social login (e.g. clicks "Sign in with Google").
723
- * Specify the `provider` (e.g. `"google"`, `"apple"`) so analytics can break down
724
- * conversion by provider.
725
- *
726
- * @param data - Event payload containing the social `provider` name.
727
- * @param tags - Optional key-value tags for filtering and segmentation.
728
- * @param contexts - Optional contextual metadata attached to the event.
729
- * @returns A {@link SocialOperationLogin} instance.
730
- *
731
- * @example
732
- * ```typescript
733
- * const op = tracker.socialLoginStart({ provider: "google" });
734
- * ```
735
- */
736
- socialLoginStart(data: SocialLoginStart, tags?: Record<string, string>, contexts?: Record<string, any>): SocialOperationLogin;
737
- /**
738
- * Track when a social login attempt fails.
739
- *
740
- * @remarks
741
- * Fire this when the OAuth callback returns an error or when token
742
- * exchange with the social provider fails.
743
- *
744
- * @param data - Event payload containing the user reference and `errorCode`.
745
- * @param tags - Optional key-value tags for filtering and segmentation.
746
- * @param contexts - Optional contextual metadata attached to the event.
747
- *
748
- * @example
749
- * ```typescript
750
- * tracker.socialLoginError({ errorCode: "OAuthAccountNotLinked" });
751
- * ```
752
- */
753
- socialLoginError(data: SocialLoginError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
754
- /**
755
- * Track when a social login completes successfully.
756
- *
757
- * @remarks
758
- * Fire this after the social provider callback succeeds and the user
759
- * is authenticated. Include the `provider` and user reference.
760
- *
761
- * @param data - Event payload containing the `provider` and user reference.
762
- * @param tags - Optional key-value tags for filtering and segmentation.
763
- * @param contexts - Optional contextual metadata attached to the event.
764
- *
765
- * @example
766
- * ```typescript
767
- * tracker.socialLoginFinish({ provider: "google" });
768
- * ```
769
- */
770
- socialLoginFinish(data: SocialLoginFinish, tags?: Record<string, string>, contexts?: Record<string, any>): void;
525
+ authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>): void;
771
526
  authDecisionStarted(data: AuthDecisionStarted): void;
772
527
  authDecisionFinished(data: AuthDecisionFinished): void;
528
+ passkeyLoginFullOperation(): PasskeyLoginOperationFull;
529
+ passkeyEnrollmentFullOperation(): PasskeyEnrollmentOperationFull;
530
+ passwordLoginFullOperation(autoTrackConfig?: PasswordLoginAutoTrackConfig): PasswordLoginOperationFull;
531
+ passwordEnrollmentFullOperation(autoTrackConfig?: PasswordEnrollmentAutoTrackConfig): PasswordEnrollmentOperationFull;
532
+ emailLinkOperationFull(): EmailLinkOperationFull;
533
+ emailOtpOperationFull(): EmailOtpOperationFull;
534
+ provideIdentifierOperationFull(inputHtmlField?: HTMLInputElement): OperationFullProvideIdentifierWithCUI;
535
+ socialLoginOperationFull(): SocialLoginOperationFull;
773
536
  /**
774
- * Create a trackable passkey enrollment operation and mark it as startable.
537
+ * Flush any pending events and release all resources (timers, event listeners).
775
538
  *
776
539
  * @remarks
777
- * Returns a {@link PasskeyOperationEnrollment} that manages the full
778
- * enrollment lifecycle: `started` `submitted` `finished` / `error` / `skipped`.
779
- * Call this when the user reaches a point where passkey enrollment can be offered.
780
- *
781
- * @param data - Event payload (currently empty, reserved for future fields).
782
- * @param tags - Optional key-value tags for filtering and segmentation.
783
- * @param contexts - Optional contextual metadata attached to the event.
784
- * @returns A {@link PasskeyOperationEnrollment} instance.
785
- *
786
- * @example
787
- * ```typescript
788
- * const op = tracker.passkeyEnrollmentStartable({});
789
- * ```
540
+ * After calling destroy, the tracker must not be used. Operation objects
541
+ * returned by factory methods (e.g. `passwordLoginFullOperation`) that hold
542
+ * DOM references must be destroyed separately by the caller.
790
543
  */
791
- passkeyEnrollmentStartable(data: PasskeyEnrollmentStartable, tags?: Record<string, string>, contexts?: Record<string, any>): PasskeyOperationEnrollment;
792
- /**
793
- * Track when an email link flow starts.
794
- *
795
- * @remarks
796
- * Fire this when the email has been sent out to the user and the verification process begins.
797
- * If fired from an un-authenticated context, we recommend to include a `crossEnvironmentTransactionID` in `data`.
798
- * This can be any idea that you have again available when the email link flow submits (after the user clicks the link in the email).
799
- *
800
- * @param data - Event payload containing the user reference.
801
- * @param tags - Optional key-value tags for filtering and segmentation.
802
- * @param contexts - Optional contextual metadata attached to the event.
803
- *
804
- * @example
805
- * ```typescript
806
- * tracker.emailLinkStarted({ userId: "usr_123" });
807
- * ```
808
- */
809
- emailLinkStartable(data: EmailLinkStartable, tags?: Record<string, string>, contexts?: Record<string, any>): EmailLinkOperation;
810
- emailLinkSubmitted(data: EmailLinkSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): EmailLinkOperation;
811
- emailLinkFinished(data: EmailLinkFinished, tags?: Record<string, string>, contexts?: Record<string, any>): void;
812
- emailLinkError(data: EmailLinkError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
813
- /**
814
- * Create a trackable email OTP operation and mark it as startable.
815
- *
816
- * @remarks
817
- * Returns an {@link EmailOTPOperation} that manages the full email OTP
818
- * lifecycle: `started` → `submitted` → `finished` / `error`, plus `resent`.
819
- * Call this when the user reaches a point where email OTP authentication
820
- * can be offered (e.g. after identifier provision returns email OTP as
821
- * an available method).
822
- *
823
- * @param data - Event payload (currently empty, reserved for future fields).
824
- * @param tags - Optional key-value tags for filtering and segmentation.
825
- * @param contexts - Optional contextual metadata attached to the event.
826
- * @returns An {@link EmailOTPOperation} instance.
827
- *
828
- * @example
829
- * ```typescript
830
- * const op = tracker.emailOTPStartable({});
831
- * ```
832
- */
833
- emailOTPStartable(data?: EmailOTPStartable, tags?: Record<string, string>, contexts?: Record<string, any>): EmailOTPOperation;
834
- /**
835
- * Track the start of an email OTP authentication flow.
836
- *
837
- * @remarks
838
- * Fire this when the email OTP flow begins — typically when the OTP email
839
- * is sent to the user. The returned {@link EmailOTPOperation} lets you
840
- * continue tracking through submission, completion, error, or resend.
841
- *
842
- * @param data - Event payload (currently empty, reserved for future fields).
843
- * @param tags - Optional key-value tags for filtering and segmentation.
844
- * @param contexts - Optional contextual metadata attached to the event.
845
- * @returns An {@link EmailOTPOperation} instance.
846
- *
847
- * @example
848
- * ```typescript
849
- * const op = tracker.emailOTPStarted({});
850
- * ```
851
- */
852
- emailOTPStarted(data?: EmailOTPStarted, tags?: Record<string, string>, contexts?: Record<string, any>): EmailOTPOperation;
853
- /**
854
- * Track when the user submits an email OTP code.
855
- *
856
- * @remarks
857
- * Fire this after the user enters and submits the OTP code for verification.
858
- * This sits between the started and finished/error events.
859
- *
860
- * @param data - Event payload (currently empty, reserved for future fields).
861
- * @param tags - Optional key-value tags for filtering and segmentation.
862
- * @param contexts - Optional contextual metadata attached to the event.
863
- *
864
- * @example
865
- * ```typescript
866
- * tracker.emailOTPSubmitted({});
867
- * ```
868
- */
869
- emailOTPSubmitted(data?: EmailOTPSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
870
- /**
871
- * Track when email OTP verification completes successfully.
872
- *
873
- * @remarks
874
- * Fire this after the backend has verified the OTP code and the user
875
- * is authenticated.
876
- *
877
- * @param data - Event payload (currently empty, reserved for future fields).
878
- * @param tags - Optional key-value tags for filtering and segmentation.
879
- * @param contexts - Optional contextual metadata attached to the event.
880
- *
881
- * @example
882
- * ```typescript
883
- * tracker.emailOTPFinished({});
884
- * ```
885
- */
886
- emailOTPFinished(data?: EmailOTPFinished, tags?: Record<string, string>, contexts?: Record<string, any>): void;
887
- /**
888
- * Track when email OTP verification fails.
889
- *
890
- * @remarks
891
- * Fire this when OTP code verification fails (e.g. invalid code, expired code,
892
- * rate limit exceeded).
893
- *
894
- * @param data - Event payload containing the `errorCode`.
895
- * @param tags - Optional key-value tags for filtering and segmentation.
896
- * @param contexts - Optional contextual metadata attached to the event.
897
- *
898
- * @example
899
- * ```typescript
900
- * tracker.emailOTPError({ errorCode: "invalid_code" });
901
- * ```
902
- */
903
- emailOTPError(data: EmailOTPError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
904
- /**
905
- * Track when an email OTP code is resent.
906
- *
907
- * @remarks
908
- * Fire this when the user requests a new OTP code (e.g. clicks "Resend code").
909
- * This helps measure how often users need to request a new code.
910
- *
911
- * @param data - Event payload (currently empty, reserved for future fields).
912
- * @param tags - Optional key-value tags for filtering and segmentation.
913
- * @param contexts - Optional contextual metadata attached to the event.
914
- *
915
- * @example
916
- * ```typescript
917
- * tracker.emailOTPResent({});
918
- * ```
919
- */
920
- emailOTPResent(data?: EmailOTPResent, tags?: Record<string, string>, contexts?: Record<string, any>): void;
921
- setPasswordStartable(inputHtmlField?: HTMLInputElement, tags?: Record<string, string>, contexts?: Record<string, any>): SetPasswordOperation;
922
- setPasswordStarted(data?: SetPasswordStarted, tags?: Record<string, string>, contexts?: Record<string, any>): SetPasswordOperation;
923
- setPasswordSubmitted(data?: SetPasswordSubmitted, tags?: Record<string, string>, contexts?: Record<string, any>): void;
924
- setPasswordFinished(data?: SetPasswordFinished, tags?: Record<string, string>, contexts?: Record<string, any>): void;
925
- setPasswordError(data: SetPasswordError, tags?: Record<string, string>, contexts?: Record<string, any>): void;
544
+ destroy(): Promise<void>;
926
545
  /** @internal */
927
546
  resetSession(): string;
928
547
  }
@@ -940,6 +559,7 @@ interface Transport {
940
559
  flush(timeout?: number): Promise<boolean>;
941
560
  }
942
561
  interface TransportOptions {
562
+ logger: Logger;
943
563
  url: string;
944
564
  headers?: Record<string, string>;
945
565
  }
@@ -948,9 +568,12 @@ interface QueueOptions {
948
568
  batchSize?: number;
949
569
  flushInterval?: number;
950
570
  }
571
+ /**
572
+ * @remarks When `window` is defined, `visibilitychange` (when the document becomes hidden) and `pagehide` trigger a synchronous beacon flush (`flushSync`). Any thrown error in that path is logged as "Unexpected error in queue flushSync".
573
+ */
951
574
  declare class RequestQueue {
575
+ private readonly logger;
952
576
  private transport;
953
- private readonly projectId;
954
577
  private sessionId;
955
578
  private readonly sdk;
956
579
  private options;
@@ -959,12 +582,26 @@ declare class RequestQueue {
959
582
  private isFlushing;
960
583
  private onVisibilityChange;
961
584
  private onPageHide;
962
- constructor(transport: Transport, projectId: string, sessionId: string, sdk: SdkInfo, options?: QueueOptions);
585
+ constructor(logger: Logger, transport: Transport, sessionId: string, sdk: SdkInfo, options?: QueueOptions);
963
586
  setSessionId(sessionId: string): void;
587
+ /**
588
+ * Error situations:
589
+ * - Any error while enqueueing or scheduling flush (including a synchronous throw from `flush`): log "Failed to enqueue event"
590
+ */
964
591
  enqueue(event: Event): void;
592
+ /**
593
+ * Error situations:
594
+ * - Queue is empty: return without calling transport.send
595
+ * - A flush is already in progress: return without calling transport.send again
596
+ * - transport.send rejects or throws, or any other error in the try block: log "Unexpected error in queue flush"
597
+ */
965
598
  flush(): Promise<void>;
966
599
  private setupLifecycleHooks;
967
600
  private flushSync;
601
+ /**
602
+ * Error situations:
603
+ * - Timer clearance or event listener removal throws: log "Failed to destroy queue lifecycle hooks"
604
+ */
968
605
  destroy(): void;
969
606
  }
970
607
 
@@ -974,25 +611,83 @@ interface StorageEngine {
974
611
  removeItem(key: string): void;
975
612
  }
976
613
  declare class LocalStorage implements StorageEngine {
614
+ private logger;
615
+ constructor(logger: Logger);
616
+ /**
617
+ * Error situations:
618
+ * - localStorage is not available: return null
619
+ * - localStorage.getItem throws: catch exception, log error and return null
620
+ * - JSON.parse throws: catch exception, log error and return null
621
+ */
977
622
  getItem<T>(key: string): T | null;
623
+ /**
624
+ * Error situations:
625
+ * - localStorage is not available: return without writing
626
+ * - localStorage.setItem throws: catch exception and log error
627
+ * - JSON.stringify throws: catch exception and log error
628
+ */
978
629
  setItem<T>(key: string, value: T): void;
630
+ /**
631
+ * Error situations:
632
+ * - localStorage is not available: return without writing
633
+ * - localStorage.removeItem throws: catch exception and log error
634
+ */
979
635
  removeItem(key: string): void;
980
636
  }
981
637
  declare class CookieStorage implements StorageEngine {
638
+ private logger;
982
639
  private domain?;
983
- constructor(domain?: string | undefined);
640
+ constructor(logger: Logger, domain?: string | undefined);
641
+ /**
642
+ * Error situations:
643
+ * - document is not available: return null
644
+ * - document.cookie read throws: catch exception, log error and return null
645
+ * - decodeURIComponent throws: catch exception, log error and return null
646
+ * - JSON.parse throws: catch exception, log error and return null
647
+ */
984
648
  getItem<T>(key: string): T | null;
649
+ /**
650
+ * Error situations:
651
+ * - document is not available: return without writing
652
+ * - document.cookie write throws: catch exception and log error
653
+ * - JSON.stringify throws: catch exception and log error
654
+ */
985
655
  setItem<T>(key: string, value: T): void;
656
+ /**
657
+ * Error situations:
658
+ * - document is not available: return without writing
659
+ * - document.cookie write throws: catch exception and log error
660
+ */
986
661
  removeItem(key: string): void;
987
662
  }
988
663
  declare class SessionStorage implements StorageEngine {
664
+ private logger;
665
+ constructor(logger: Logger);
666
+ /**
667
+ * Error situations:
668
+ * - sessionStorage is not available: return null
669
+ * - sessionStorage.getItem throws: catch exception, log error and return null
670
+ * - JSON.parse throws: catch exception, log error and return null
671
+ */
989
672
  getItem<T>(key: string): T | null;
673
+ /**
674
+ * Error situations:
675
+ * - sessionStorage is not available: return without writing
676
+ * - sessionStorage.setItem throws: catch exception and log error
677
+ * - JSON.stringify throws: catch exception and log error
678
+ */
990
679
  setItem<T>(key: string, value: T): void;
680
+ /**
681
+ * Error situations:
682
+ * - sessionStorage is not available: return without writing
683
+ * - sessionStorage.removeItem throws: catch exception and log error
684
+ */
991
685
  removeItem(key: string): void;
992
686
  }
993
687
 
994
688
  declare function init(options: TrackerOptions): CorbadoTracker;
995
689
  declare function getTracker(): CorbadoTracker | undefined;
996
690
  declare function resetSession(): string | undefined;
691
+ declare function destroy(): Promise<void>;
997
692
 
998
- export { type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionStarted, type BaseEvent, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, CookieStorage, CorbadoTracker, type CustomEvent, type DeviceInfo, type DeviceInfoDataWeb, type DeviceType, type EmailLinkError, type EmailLinkFinished, EmailLinkOperation, type EmailLinkStartable, type EmailLinkSubmitted, type EmailOTPError, type EmailOTPFinished, EmailOTPOperation, type EmailOTPResent, type EmailOTPStartable, type EmailOTPStarted, type EmailOTPSubmitted, type Event, type EventBatch, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type JavaScriptHighEntropy, LocalStorage, type LoginMethodType, type LoginStepPasswordErrorCode, type MultiFlowStarted, type NormalizedError, type PasskeyEnrollmentError, type PasskeyEnrollmentFinished, type PasskeyEnrollmentStartable, type PasskeyEnrollmentStarted, type PasskeyEnrollmentSubmitted, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, PasskeyOperationEnrollment, PasskeyOperationLogin, type PasswordLoginError, type PasswordLoginFinish, type PasswordLoginStartable, type PasswordLoginStarted, PasswordOperationLogin, type PredefinedEvent, type ProvideIdentifierError, type ProvideIdentifierFinish, ProvideIdentifierOperation, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, SessionStorage, type SetPasswordError, type SetPasswordFinished, SetPasswordOperation, type SetPasswordStartable, type SetPasswordStarted, type SetPasswordSubmitted, type SocialLoginError, type SocialLoginFinish, type SocialLoginProviderType, type SocialLoginStart, SocialOperationLogin, type StorageEngine, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type User, type UserReference, getTracker, init, resetSession };
693
+ export { type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, type DeviceInfo, type DeviceInfoDataWeb, type DeviceType, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type JavaScriptHighEntropy, LocalStorage, type Logger, type MultiFlowStarted, type NormalizedError, OperationFull, OperationFullProvideIdentifierWithCUI, 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, PasswordLoginOperationFull, type PasswordLoginTypedError, type PredefinedEvent, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, SessionStorage, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type UserReference, createLogger, destroy, getTracker, init, resetSession };