@donotdev/firebase 0.0.1

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.
Files changed (51) hide show
  1. package/LICENSE.md +242 -0
  2. package/README.md +386 -0
  3. package/dist/client/firestore.d.ts +147 -0
  4. package/dist/client/firestore.d.ts.map +1 -0
  5. package/dist/client/firestore.js +1 -0
  6. package/dist/client/functions.d.ts +28 -0
  7. package/dist/client/functions.d.ts.map +1 -0
  8. package/dist/client/functions.js +1 -0
  9. package/dist/client/index.d.ts +11 -0
  10. package/dist/client/index.d.ts.map +1 -0
  11. package/dist/client/index.js +1 -0
  12. package/dist/client/sdk.d.ts +968 -0
  13. package/dist/client/sdk.d.ts.map +1 -0
  14. package/dist/client/sdk.js +21 -0
  15. package/dist/index.d.ts +9 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +1 -0
  18. package/dist/server/batch.d.ts +97 -0
  19. package/dist/server/batch.d.ts.map +1 -0
  20. package/dist/server/batch.js +1 -0
  21. package/dist/server/index.d.ts +15 -0
  22. package/dist/server/index.d.ts.map +1 -0
  23. package/dist/server/index.js +1 -0
  24. package/dist/server/init.d.ts +13 -0
  25. package/dist/server/init.d.ts.map +1 -0
  26. package/dist/server/init.js +2 -0
  27. package/dist/server/subscription.d.ts +117 -0
  28. package/dist/server/subscription.d.ts.map +1 -0
  29. package/dist/server/subscription.js +1 -0
  30. package/dist/server/uniqueness.d.ts +69 -0
  31. package/dist/server/uniqueness.d.ts.map +1 -0
  32. package/dist/server/uniqueness.js +1 -0
  33. package/dist/server/utils.d.ts +28 -0
  34. package/dist/server/utils.d.ts.map +1 -0
  35. package/dist/server/utils.js +1 -0
  36. package/dist/server/validation.d.ts +43 -0
  37. package/dist/server/validation.d.ts.map +1 -0
  38. package/dist/server/validation.js +1 -0
  39. package/dist/shared/index.d.ts +11 -0
  40. package/dist/shared/index.d.ts.map +1 -0
  41. package/dist/shared/index.js +1 -0
  42. package/dist/shared/transform.d.ts +96 -0
  43. package/dist/shared/transform.d.ts.map +1 -0
  44. package/dist/shared/transform.js +1 -0
  45. package/dist/shared/types.d.ts +37 -0
  46. package/dist/shared/types.d.ts.map +1 -0
  47. package/dist/shared/types.js +0 -0
  48. package/dist/shared/utils.d.ts +71 -0
  49. package/dist/shared/utils.d.ts.map +1 -0
  50. package/dist/shared/utils.js +1 -0
  51. package/package.json +50 -0
@@ -0,0 +1,968 @@
1
+ import * as firebaseAuth from 'firebase/auth';
2
+ import { GoogleAuthProvider, GithubAuthProvider, FacebookAuthProvider, TwitterAuthProvider, EmailAuthProvider, PhoneAuthProvider } from 'firebase/auth';
3
+ import type { FirebaseApp } from 'firebase/app';
4
+ import type { User, UserCredential, AuthProvider, OAuthProvider, RecaptchaVerifier, Unsubscribe, ActionCodeSettings, AuthCredential, MultiFactorResolver, MultiFactorUser, AdditionalUserInfo, Persistence } from 'firebase/auth';
5
+ export type { User as FirebaseUser, UserInfo, OAuthCredential, AuthCredential, } from 'firebase/auth';
6
+ export { GoogleAuthProvider, GithubAuthProvider, FacebookAuthProvider, TwitterAuthProvider, OAuthProvider, EmailAuthProvider, } from 'firebase/auth';
7
+ /**
8
+ * Firebase SDK Singleton Wrapper
9
+ *
10
+ * Manages Firebase initialization and provides type-safe wrappers around
11
+ * all Firebase Auth methods. Handles auth instance management internally
12
+ * so consumers never need to pass or manage the auth instance.
13
+ *
14
+ * **Key Responsibilities:**
15
+ * - Initialize Firebase app and auth once
16
+ * - Store auth instance for internal reuse
17
+ * - Handle emulator connections in development
18
+ * - Provide clean, typed interface to Firebase Auth
19
+ * - Isolate Firebase API changes from business logic
20
+ *
21
+ * **NOT Responsible For:**
22
+ * - Error conversion (handled by FirebaseAuth)
23
+ * - Business logic (handled by FirebaseAuth)
24
+ * - State management (handled by AuthService)
25
+ *
26
+ * @class FirebaseSDK
27
+ * @example
28
+ * ```typescript
29
+ * const sdk = getFirebaseSDK();
30
+ * await sdk.initialize();
31
+ * const result = await sdk.signInWithPopup(provider);
32
+ * ```
33
+ */
34
+ declare class FirebaseSDK {
35
+ /** Tracks initialization state */
36
+ private initialized;
37
+ /** Firebase app instance */
38
+ private app;
39
+ /** Firebase auth instance - managed internally */
40
+ private auth;
41
+ /** Firebase App Check instance - auto-enabled if RECAPTCHA_SITE_KEY is set */
42
+ private appCheck;
43
+ /** Tracks if auth emulator has been connected (can only connect once) */
44
+ private authEmulatorConnected;
45
+ /**
46
+ * Initialize Firebase app and auth
47
+ *
48
+ * Must be called before any other methods. Safe to call multiple times
49
+ * as initialization only happens once. Loads configuration from environment
50
+ * variables and connects to emulator if in development mode.
51
+ *
52
+ * @returns Promise that resolves when initialization is complete
53
+ * @throws Error if Firebase initialization fails
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const sdk = getFirebaseSDK();
58
+ * await sdk.initialize();
59
+ * ```
60
+ */
61
+ initialize(): Promise<void>;
62
+ /**
63
+ * Ensure auth instance is initialized before use
64
+ *
65
+ * Internal method called by all public methods to guarantee auth
66
+ * instance is available. Throws descriptive error if called before
67
+ * initialization.
68
+ *
69
+ * @returns The initialized auth instance
70
+ * @throws Error if auth not initialized
71
+ * @private
72
+ */
73
+ private ensureInitialized;
74
+ /**
75
+ * Initialize App Check if reCAPTCHA site key is configured
76
+ * Auto-enables abuse protection for all Firebase resources
77
+ *
78
+ * Lazy initialization - only called when App Check is actually needed
79
+ * This defers reCaptcha script loading until Firebase operations require it
80
+ */
81
+ private initializeAppCheck;
82
+ /** Tracks App Check initialization promise to prevent race conditions */
83
+ private appCheckInitPromise;
84
+ /**
85
+ * Ensure App Check is initialized (lazy initialization)
86
+ * Called before Firebase operations that benefit from App Check protection
87
+ * Uses promise caching to prevent duplicate initialization
88
+ */
89
+ private ensureAppCheckInitialized;
90
+ /**
91
+ * Check if App Check is enabled
92
+ */
93
+ isAppCheckEnabled(): boolean;
94
+ /**
95
+ * Get Firebase app instance
96
+ *
97
+ * Ensures Firebase is initialized and returns the app instance.
98
+ * Safe to call from any consumer - handles initialization order automatically.
99
+ *
100
+ * @returns Promise resolving to Firebase app instance
101
+ * @throws Error if initialization fails
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const sdk = getFirebaseSDK();
106
+ * const app = await sdk.getApp();
107
+ * const functions = getFunctions(app, 'europe-west1');
108
+ * ```
109
+ */
110
+ getApp(): Promise<FirebaseApp>;
111
+ /**
112
+ * Subscribe to authentication state changes
113
+ *
114
+ * Registers a callback that fires when auth state changes (sign in,
115
+ * sign out, token refresh, etc.). Returns unsubscribe function.
116
+ *
117
+ * @param nextOrObserver - Callback function receiving user or null
118
+ * @returns Unsubscribe function to stop listening
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const unsubscribe = sdk.onAuthStateChanged((user) => {
123
+ * if (user) {
124
+ * console.log('Signed in:', user.uid);
125
+ * } else {
126
+ * console.log('Signed out');
127
+ * }
128
+ * });
129
+ * // Later: unsubscribe();
130
+ * ```
131
+ */
132
+ onAuthStateChanged(nextOrObserver: (user: User | null) => void): Unsubscribe;
133
+ /**
134
+ * Register callback before authentication state changes
135
+ *
136
+ * Similar to onAuthStateChanged but fires before state change completes.
137
+ * Useful for performing actions before user data is available.
138
+ *
139
+ * @param nextOrObserver - Callback function receiving user or null
140
+ * @returns Unsubscribe function to stop listening
141
+ */
142
+ beforeAuthStateChanged(nextOrObserver: (user: User | null) => void): Unsubscribe;
143
+ /**
144
+ * Get current authenticated user
145
+ *
146
+ * Synchronously returns current user or null if signed out.
147
+ * Does not wait for auth state to initialize.
148
+ *
149
+ * @returns Current user or null if not authenticated
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const user = sdk.getCurrentUser();
154
+ * if (user) {
155
+ * console.log('Current user:', user.email);
156
+ * }
157
+ * ```
158
+ */
159
+ getCurrentUser(): User | null;
160
+ /**
161
+ * Get result of a redirect-based sign-in operation
162
+ *
163
+ * Call this after user returns from OAuth redirect. Returns null if
164
+ * no redirect operation was performed or if called before redirect completes.
165
+ *
166
+ * **React StrictMode Safe:**
167
+ * Uses module-level cache to prevent double-execution from consuming the result.
168
+ * Firebase's getRedirectResult() is destructive (one-time read), so we cache
169
+ * it at module scope to survive component re-mounts.
170
+ *
171
+ * @returns Promise resolving to user credential or null
172
+ * @throws Error if redirect operation failed
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * // After OAuth redirect returns user to your app
177
+ * const result = await sdk.getRedirectResult();
178
+ * if (result?.user) {
179
+ * console.log('Signed in via redirect:', result.user.email);
180
+ * }
181
+ * ```
182
+ */
183
+ getRedirectResult(): Promise<UserCredential | null>;
184
+ /**
185
+ * Sign in using redirect flow
186
+ *
187
+ * Redirects user to provider's sign-in page. User leaves your app and
188
+ * returns after authentication. Use getRedirectResult() to get result.
189
+ *
190
+ * @param provider - Authentication provider instance
191
+ * @returns Promise resolving when redirect is initiated
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * const provider = sdk.createGoogleProvider();
196
+ * await sdk.signInWithRedirect(provider);
197
+ * // User redirects to Google, then returns to your app
198
+ * ```
199
+ */
200
+ signInWithRedirect(provider: AuthProvider): Promise<void>;
201
+ /**
202
+ * Sign in using popup flow
203
+ *
204
+ * Opens provider sign-in in popup window. User stays on your app while
205
+ * authenticating in popup. Returns result when popup closes.
206
+ *
207
+ * @param provider - Authentication provider instance
208
+ * @returns Promise resolving to user credential
209
+ * @throws Error if popup blocked or authentication fails
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const provider = sdk.createGoogleProvider();
214
+ * const result = await sdk.signInWithPopup(provider);
215
+ * console.log('Signed in:', result.user.email);
216
+ * ```
217
+ */
218
+ signInWithPopup(provider: AuthProvider): Promise<UserCredential>;
219
+ /**
220
+ * Sign in with email and password
221
+ *
222
+ * Authenticates user with email/password credentials.
223
+ *
224
+ * @param email - User's email address
225
+ * @param password - User's password
226
+ * @returns Promise resolving to user credential
227
+ * @throws Error if credentials are invalid
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const result = await sdk.signInWithEmailAndPassword(
232
+ * 'user@example.com',
233
+ * 'password123'
234
+ * );
235
+ * ```
236
+ */
237
+ signInWithEmailAndPassword(email: string, password: string): Promise<UserCredential>;
238
+ /**
239
+ * Create new user account with email and password
240
+ *
241
+ * Creates new user account and signs in automatically.
242
+ *
243
+ * @param email - New user's email address
244
+ * @param password - New user's password
245
+ * @returns Promise resolving to user credential
246
+ * @throws Error if account creation fails
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * const result = await sdk.createUserWithEmailAndPassword(
251
+ * 'newuser@example.com',
252
+ * 'password123'
253
+ * );
254
+ * ```
255
+ */
256
+ createUserWithEmailAndPassword(email: string, password: string): Promise<UserCredential>;
257
+ /**
258
+ * Send password reset email
259
+ *
260
+ * Sends email with link to reset password to specified email address.
261
+ *
262
+ * @param email - Email address to send reset link to
263
+ * @param actionCodeSettings - Optional settings for reset link
264
+ * @returns Promise resolving when email is sent
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * await sdk.sendPasswordResetEmail('user@example.com');
269
+ * ```
270
+ */
271
+ sendPasswordResetEmail(email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
272
+ /**
273
+ * Confirm password reset with code
274
+ *
275
+ * Completes password reset flow using code from reset email.
276
+ *
277
+ * @param code - Reset code from email
278
+ * @param newPassword - New password to set
279
+ * @returns Promise resolving when password is reset
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * await sdk.confirmPasswordReset('code-from-email', 'newpassword');
284
+ * ```
285
+ */
286
+ confirmPasswordReset(code: string, newPassword: string): Promise<void>;
287
+ /**
288
+ * Verify password reset code
289
+ *
290
+ * Checks if password reset code is valid and returns associated email.
291
+ *
292
+ * @param code - Reset code from email
293
+ * @returns Promise resolving to email associated with code
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * const email = await sdk.verifyPasswordResetCode('code-from-email');
298
+ * console.log('Resetting password for:', email);
299
+ * ```
300
+ */
301
+ verifyPasswordResetCode(code: string): Promise<string>;
302
+ /**
303
+ * Sign in with email link
304
+ *
305
+ * Completes email link sign-in flow. Call this with email link from email.
306
+ *
307
+ * @param email - User's email address
308
+ * @param emailLink - Optional email link URL (defaults to current URL)
309
+ * @returns Promise resolving to user credential
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * const result = await sdk.signInWithEmailLink(
314
+ * 'user@example.com',
315
+ * window.location.href
316
+ * );
317
+ * ```
318
+ */
319
+ signInWithEmailLink(email: string, emailLink?: string): Promise<UserCredential>;
320
+ /**
321
+ * Send sign-in link to email
322
+ *
323
+ * Sends email with link that signs user in when clicked.
324
+ *
325
+ * @param email - Email address to send link to
326
+ * @param actionCodeSettings - Settings for sign-in link
327
+ * @returns Promise resolving when email is sent
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * await sdk.sendSignInLinkToEmail('user@example.com', {
332
+ * url: 'https://yourapp.com/finishSignIn',
333
+ * handleCodeInApp: true
334
+ * });
335
+ * ```
336
+ */
337
+ sendSignInLinkToEmail(email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;
338
+ /**
339
+ * Check if string is valid email sign-in link
340
+ *
341
+ * Validates whether a URL is a valid email sign-in link.
342
+ *
343
+ * @param emailLink - URL to validate
344
+ * @returns True if valid email sign-in link
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * if (sdk.isSignInWithEmailLink(window.location.href)) {
349
+ * // Complete sign-in
350
+ * }
351
+ * ```
352
+ */
353
+ isSignInWithEmailLink(emailLink: string): boolean;
354
+ /**
355
+ * Sign in with custom token
356
+ *
357
+ * Signs in using custom token generated by your backend.
358
+ *
359
+ * @param token - Custom auth token
360
+ * @returns Promise resolving to user credential
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * const token = await getCustomTokenFromBackend();
365
+ * const result = await sdk.signInWithCustomToken(token);
366
+ * ```
367
+ */
368
+ signInWithCustomToken(token: string): Promise<UserCredential>;
369
+ /**
370
+ * Sign in anonymously
371
+ *
372
+ * Creates temporary anonymous user account.
373
+ *
374
+ * @returns Promise resolving to user credential
375
+ *
376
+ * @example
377
+ * ```typescript
378
+ * const result = await sdk.signInAnonymously();
379
+ * console.log('Anonymous user:', result.user.uid);
380
+ * ```
381
+ */
382
+ signInAnonymously(): Promise<UserCredential>;
383
+ /**
384
+ * Sign in with credential object
385
+ *
386
+ * Signs in using pre-built auth credential.
387
+ *
388
+ * @param credential - Auth credential object
389
+ * @returns Promise resolving to user credential
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * const credential = GoogleAuthProvider.credential(idToken);
394
+ * const result = await sdk.signInWithCredential(credential);
395
+ * ```
396
+ */
397
+ signInWithCredential(credential: AuthCredential): Promise<UserCredential>;
398
+ /**
399
+ * Sign in with phone number
400
+ *
401
+ * Initiates phone number sign-in flow with reCAPTCHA verification.
402
+ *
403
+ * @param phoneNumber - Phone number in E.164 format
404
+ * @param appVerifier - reCAPTCHA verifier instance
405
+ * @returns Promise resolving to confirmation result
406
+ *
407
+ * @example
408
+ * ```typescript
409
+ * const verifier = sdk.createRecaptchaVerifier('recaptcha-container');
410
+ * const result = await sdk.signInWithPhoneNumber('+1234567890', verifier);
411
+ * const code = prompt('Enter verification code:');
412
+ * await result.confirm(code);
413
+ * ```
414
+ */
415
+ signInWithPhoneNumber(phoneNumber: string, appVerifier: RecaptchaVerifier): Promise<firebaseAuth.ConfirmationResult>;
416
+ /**
417
+ * Sign out current user
418
+ *
419
+ * Signs out currently authenticated user.
420
+ *
421
+ * @returns Promise resolving when sign out completes
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * await sdk.signOut();
426
+ * console.log('User signed out');
427
+ * ```
428
+ */
429
+ signOut(): Promise<void>;
430
+ /**
431
+ * Send email verification to user
432
+ *
433
+ * Sends verification email to user's email address.
434
+ *
435
+ * @param user - User to send verification to
436
+ * @param actionCodeSettings - Optional settings for verification link
437
+ * @returns Promise resolving when email is sent
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * const user = sdk.getCurrentUser();
442
+ * await sdk.sendEmailVerification(user);
443
+ * ```
444
+ */
445
+ sendEmailVerification(user: User, actionCodeSettings?: ActionCodeSettings): Promise<void>;
446
+ /**
447
+ * Update user's password
448
+ *
449
+ * Changes password for currently signed-in user.
450
+ *
451
+ * @param user - User to update password for
452
+ * @param newPassword - New password
453
+ * @returns Promise resolving when password is updated
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * const user = sdk.getCurrentUser();
458
+ * await sdk.updatePassword(user, 'newpassword');
459
+ * ```
460
+ */
461
+ updatePassword(user: User, newPassword: string): Promise<void>;
462
+ /**
463
+ * Update user's email address
464
+ *
465
+ * Changes email address for currently signed-in user.
466
+ *
467
+ * @param user - User to update email for
468
+ * @param newEmail - New email address
469
+ * @returns Promise resolving when email is updated
470
+ */
471
+ updateEmail(user: User, newEmail: string): Promise<void>;
472
+ /**
473
+ * Update user's profile information
474
+ *
475
+ * Updates display name and/or photo URL.
476
+ *
477
+ * @param user - User to update profile for
478
+ * @param profile - Profile updates (displayName and/or photoURL)
479
+ * @returns Promise resolving when profile is updated
480
+ *
481
+ * @example
482
+ * ```typescript
483
+ * const user = sdk.getCurrentUser();
484
+ * await sdk.updateProfile(user, {
485
+ * displayName: 'John Doe',
486
+ * photoURL: 'https://example.com/photo.jpg'
487
+ * });
488
+ * ```
489
+ */
490
+ updateProfile(user: User, profile: {
491
+ displayName?: string | null;
492
+ photoURL?: string | null;
493
+ }): Promise<void>;
494
+ /**
495
+ * Reload user data from server
496
+ *
497
+ * Refreshes user's profile data and custom claims.
498
+ *
499
+ * @param user - User to reload
500
+ * @returns Promise resolving when reload completes
501
+ */
502
+ reload(user: User): Promise<void>;
503
+ /**
504
+ * Delete user account
505
+ *
506
+ * Permanently deletes user account. Cannot be undone.
507
+ *
508
+ * @param user - User to delete
509
+ * @returns Promise resolving when account is deleted
510
+ */
511
+ deleteUser(user: User): Promise<void>;
512
+ /**
513
+ * Get user's ID token
514
+ *
515
+ * Gets current ID token, optionally forcing refresh.
516
+ *
517
+ * @param user - User to get token for
518
+ * @param forceRefresh - Force token refresh even if not expired
519
+ * @returns Promise resolving to ID token string
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * const user = sdk.getCurrentUser();
524
+ * const token = await sdk.getIdToken(user, true);
525
+ * ```
526
+ */
527
+ getIdToken(user: User, forceRefresh?: boolean): Promise<string>;
528
+ /**
529
+ * Get user's ID token with claims
530
+ *
531
+ * Gets ID token result including custom claims.
532
+ *
533
+ * @param user - User to get token result for
534
+ * @param forceRefresh - Force token refresh
535
+ * @returns Promise resolving to token result with claims
536
+ *
537
+ * @example
538
+ * ```typescript
539
+ * const user = sdk.getCurrentUser();
540
+ * const result = await sdk.getIdTokenResult(user);
541
+ * console.log('Custom claims:', result.claims);
542
+ * ```
543
+ */
544
+ getIdTokenResult(user: User, forceRefresh?: boolean): Promise<firebaseAuth.IdTokenResult>;
545
+ /**
546
+ * Link credential to existing account
547
+ *
548
+ * Links additional auth provider to current user's account.
549
+ *
550
+ * @param user - User to link credential to
551
+ * @param credential - Credential to link
552
+ * @returns Promise resolving to updated user credential
553
+ *
554
+ * @example
555
+ * ```typescript
556
+ * const credential = GoogleAuthProvider.credential(idToken);
557
+ * await sdk.linkWithCredential(currentUser, credential);
558
+ * ```
559
+ */
560
+ linkWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
561
+ /**
562
+ * Link provider using popup
563
+ *
564
+ * Links additional provider to account using popup flow.
565
+ *
566
+ * @param user - User to link provider to
567
+ * @param provider - Provider to link
568
+ * @returns Promise resolving to updated user credential
569
+ */
570
+ linkWithPopup(user: User, provider: AuthProvider): Promise<UserCredential>;
571
+ /**
572
+ * Link provider using redirect
573
+ *
574
+ * Links additional provider to account using redirect flow.
575
+ *
576
+ * @param user - User to link provider to
577
+ * @param provider - Provider to link
578
+ * @returns Promise resolving when redirect is initiated
579
+ */
580
+ linkWithRedirect(user: User, provider: AuthProvider): Promise<void>;
581
+ /**
582
+ * Link phone number to account
583
+ *
584
+ * Links phone number authentication to existing account.
585
+ *
586
+ * @param user - User to link phone to
587
+ * @param phoneNumber - Phone number in E.164 format
588
+ * @param appVerifier - reCAPTCHA verifier
589
+ * @returns Promise resolving to confirmation result
590
+ */
591
+ linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: RecaptchaVerifier): Promise<firebaseAuth.ConfirmationResult>;
592
+ /**
593
+ * Unlink provider from account
594
+ *
595
+ * Removes linked provider from user's account.
596
+ *
597
+ * @param user - User to unlink provider from
598
+ * @param providerId - Provider ID to unlink
599
+ * @returns Promise resolving to updated user
600
+ */
601
+ unlink(user: User, providerId: string): Promise<User>;
602
+ /**
603
+ * Fetch sign-in methods for email
604
+ *
605
+ * Gets list of sign-in methods available for given email address.
606
+ *
607
+ * @param email - Email address to check
608
+ * @returns Promise resolving to array of provider IDs
609
+ *
610
+ * @example
611
+ * ```typescript
612
+ * const methods = await sdk.fetchSignInMethodsForEmail('user@example.com');
613
+ * console.log('Available methods:', methods); // ['google.com', 'password']
614
+ * ```
615
+ */
616
+ fetchSignInMethodsForEmail(email: string): Promise<string[]>;
617
+ /**
618
+ * Re-authenticate with credential
619
+ *
620
+ * Re-authenticates user before sensitive operations.
621
+ *
622
+ * @param user - User to re-authenticate
623
+ * @param credential - Credential to re-authenticate with
624
+ * @returns Promise resolving to user credential
625
+ */
626
+ reauthenticateWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
627
+ /**
628
+ * Re-authenticate using popup
629
+ *
630
+ * Re-authenticates user using popup flow.
631
+ *
632
+ * @param user - User to re-authenticate
633
+ * @param provider - Provider to use
634
+ * @returns Promise resolving to user credential
635
+ */
636
+ reauthenticateWithPopup(user: User, provider: AuthProvider): Promise<UserCredential>;
637
+ /**
638
+ * Re-authenticate using redirect
639
+ *
640
+ * Re-authenticates user using redirect flow.
641
+ *
642
+ * @param user - User to re-authenticate
643
+ * @param provider - Provider to use
644
+ * @returns Promise resolving when redirect is initiated
645
+ */
646
+ reauthenticateWithRedirect(user: User, provider: AuthProvider): Promise<void>;
647
+ /**
648
+ * Create Google auth provider
649
+ *
650
+ * @returns New Google provider instance
651
+ *
652
+ * @example
653
+ * ```typescript
654
+ * const provider = sdk.createGoogleProvider();
655
+ * provider.addScope('https://www.googleapis.com/auth/drive.readonly');
656
+ * ```
657
+ */
658
+ createGoogleProvider(): GoogleAuthProvider;
659
+ /**
660
+ * Create GitHub auth provider
661
+ *
662
+ * @returns New GitHub provider instance
663
+ */
664
+ createGithubProvider(): GithubAuthProvider;
665
+ /**
666
+ * Create Facebook auth provider
667
+ *
668
+ * @returns New Facebook provider instance
669
+ */
670
+ createFacebookProvider(): FacebookAuthProvider;
671
+ /**
672
+ * Create Twitter auth provider
673
+ *
674
+ * @returns New Twitter provider instance
675
+ */
676
+ createTwitterProvider(): TwitterAuthProvider;
677
+ /**
678
+ * Create Microsoft auth provider
679
+ *
680
+ * @returns New Microsoft OAuth provider instance
681
+ */
682
+ createMicrosoftProvider(): OAuthProvider;
683
+ /**
684
+ * Create Apple auth provider
685
+ *
686
+ * @returns New Apple OAuth provider instance
687
+ */
688
+ createAppleProvider(): OAuthProvider;
689
+ /**
690
+ * Create generic OAuth provider
691
+ *
692
+ * Creates provider for any OAuth-compatible service.
693
+ *
694
+ * @param providerId - Provider ID (e.g., 'discord.com')
695
+ * @returns New OAuth provider instance
696
+ *
697
+ * @example
698
+ * ```typescript
699
+ * const provider = sdk.createOAuthProvider('discord.com');
700
+ * provider.addScope('identify');
701
+ * ```
702
+ */
703
+ createOAuthProvider(providerId: string): OAuthProvider;
704
+ /**
705
+ * Create phone auth provider
706
+ *
707
+ * @returns New phone auth provider instance
708
+ */
709
+ createPhoneAuthProvider(): PhoneAuthProvider;
710
+ /**
711
+ * Create email auth provider
712
+ *
713
+ * @returns New email auth provider instance
714
+ */
715
+ createEmailAuthProvider(): typeof EmailAuthProvider;
716
+ /**
717
+ * Create reCAPTCHA verifier
718
+ *
719
+ * Creates verifier for phone authentication.
720
+ *
721
+ * @param container - Container element ID or element reference
722
+ * @param parameters - Optional reCAPTCHA parameters
723
+ * @returns New reCAPTCHA verifier instance
724
+ *
725
+ * @example
726
+ * ```typescript
727
+ * const verifier = sdk.createRecaptchaVerifier('recaptcha-container', {
728
+ * size: 'invisible'
729
+ * });
730
+ * ```
731
+ */
732
+ createRecaptchaVerifier(container: string | HTMLElement, parameters?: firebaseAuth.RecaptchaParameters): RecaptchaVerifier;
733
+ /**
734
+ * Get multi-factor interface for user
735
+ *
736
+ * @param user - User to get multi-factor for
737
+ * @returns Multi-factor user interface
738
+ */
739
+ multiFactor(user: User): MultiFactorUser;
740
+ /**
741
+ * Get multi-factor resolver from error
742
+ *
743
+ * Creates resolver for handling multi-factor authentication errors.
744
+ *
745
+ * @param error - Multi-factor error from sign-in attempt
746
+ * @returns Multi-factor resolver instance
747
+ */
748
+ getMultiFactorResolver(error: firebaseAuth.MultiFactorError): MultiFactorResolver;
749
+ /**
750
+ * Get additional user info from credential
751
+ *
752
+ * Extracts additional user information from sign-in result.
753
+ *
754
+ * @param result - User credential from sign-in
755
+ * @returns Additional user info or null
756
+ *
757
+ * @example
758
+ * ```typescript
759
+ * const result = await sdk.signInWithPopup(provider);
760
+ * const info = sdk.getAdditionalUserInfo(result);
761
+ * if (info?.isNewUser) {
762
+ * console.log('Welcome new user!');
763
+ * }
764
+ * ```
765
+ */
766
+ getAdditionalUserInfo(result: UserCredential): AdditionalUserInfo | null;
767
+ /**
768
+ * Set authentication state persistence
769
+ *
770
+ * Controls how auth state persists between sessions.
771
+ *
772
+ * @param persistence - Persistence type (local, session, or none)
773
+ * @returns Promise resolving when persistence is set
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * // Persist until browser closes
778
+ * await sdk.setPersistence(firebaseAuth.browserSessionPersistence);
779
+ * ```
780
+ */
781
+ setPersistence(persistence: Persistence): Promise<void>;
782
+ /**
783
+ * Set auth language to device default
784
+ *
785
+ * Sets Firebase Auth UI language to user's device language.
786
+ */
787
+ useDeviceLanguage(): void;
788
+ /**
789
+ * Check action code validity
790
+ *
791
+ * Validates action code from email (password reset, email verification, etc.).
792
+ *
793
+ * @param code - Action code from email
794
+ * @returns Promise resolving to action code info
795
+ */
796
+ checkActionCode(code: string): Promise<firebaseAuth.ActionCodeInfo>;
797
+ /**
798
+ * Apply action code
799
+ *
800
+ * Applies action code from email (email verification, password reset, etc.).
801
+ *
802
+ * @param code - Action code from email
803
+ * @returns Promise resolving when code is applied
804
+ */
805
+ applyActionCode(code: string): Promise<void>;
806
+ /**
807
+ * Sign in with Google using popup
808
+ *
809
+ * @returns Promise resolving to user credential
810
+ */
811
+ signInWithGoogle(): Promise<UserCredential>;
812
+ /**
813
+ * Sign in with Google using redirect
814
+ *
815
+ * @returns Promise resolving when redirect is initiated
816
+ */
817
+ signInWithGoogleRedirect(): Promise<void>;
818
+ /**
819
+ * Sign in with GitHub using popup
820
+ *
821
+ * @returns Promise resolving to user credential
822
+ */
823
+ signInWithGitHub(): Promise<UserCredential>;
824
+ /**
825
+ * Sign in with GitHub using redirect
826
+ *
827
+ * @returns Promise resolving when redirect is initiated
828
+ */
829
+ signInWithGitHubRedirect(): Promise<void>;
830
+ /**
831
+ * Sign in with Facebook using popup
832
+ *
833
+ * @returns Promise resolving to user credential
834
+ */
835
+ signInWithFacebook(): Promise<UserCredential>;
836
+ /**
837
+ * Sign in with Facebook using redirect
838
+ *
839
+ * @returns Promise resolving when redirect is initiated
840
+ */
841
+ signInWithFacebookRedirect(): Promise<void>;
842
+ /**
843
+ * Sign in with Twitter using popup
844
+ *
845
+ * @returns Promise resolving to user credential
846
+ */
847
+ signInWithTwitter(): Promise<UserCredential>;
848
+ /**
849
+ * Sign in with Twitter using redirect
850
+ *
851
+ * @returns Promise resolving when redirect is initiated
852
+ */
853
+ signInWithTwitterRedirect(): Promise<void>;
854
+ /**
855
+ * Sign in with Microsoft using popup
856
+ *
857
+ * @returns Promise resolving to user credential
858
+ */
859
+ signInWithMicrosoft(): Promise<UserCredential>;
860
+ /**
861
+ * Sign in with Microsoft using redirect
862
+ *
863
+ * @returns Promise resolving when redirect is initiated
864
+ */
865
+ signInWithMicrosoftRedirect(): Promise<void>;
866
+ /**
867
+ * Sign in with Apple using popup
868
+ *
869
+ * @returns Promise resolving to user credential
870
+ */
871
+ signInWithApple(): Promise<UserCredential>;
872
+ /**
873
+ * Sign in with Apple using redirect
874
+ *
875
+ * @returns Promise resolving when redirect is initiated
876
+ */
877
+ signInWithAppleRedirect(): Promise<void>;
878
+ /**
879
+ * Sign in with Google credential (for Google One Tap)
880
+ *
881
+ * @param credential - Google ID token
882
+ * @returns Promise resolving to user credential
883
+ */
884
+ signInWithGoogleCredential(credential: string): Promise<UserCredential>;
885
+ /**
886
+ * Sign in with email and password (high-level)
887
+ *
888
+ * @param email - User's email address
889
+ * @param password - User's password
890
+ * @returns Promise resolving to user credential
891
+ */
892
+ signInWithEmail(email: string, password: string): Promise<UserCredential>;
893
+ /**
894
+ * Create user with email and password (high-level)
895
+ *
896
+ * @param email - User's email address
897
+ * @param password - User's password
898
+ * @returns Promise resolving to user credential
899
+ */
900
+ createUserWithEmail(email: string, password: string): Promise<UserCredential>;
901
+ /**
902
+ * Link Google account to current user
903
+ *
904
+ * @param user - Current user
905
+ * @returns Promise resolving to updated user credential
906
+ */
907
+ linkWithGoogle(user: User): Promise<UserCredential>;
908
+ /**
909
+ * Link GitHub account to current user
910
+ *
911
+ * @param user - Current user
912
+ * @returns Promise resolving to updated user credential
913
+ */
914
+ linkWithGitHub(user: User): Promise<UserCredential>;
915
+ /**
916
+ * Link Facebook account to current user
917
+ *
918
+ * @param user - Current user
919
+ * @returns Promise resolving to updated user credential
920
+ */
921
+ linkWithFacebook(user: User): Promise<UserCredential>;
922
+ /**
923
+ * Link Twitter account to current user
924
+ *
925
+ * @param user - Current user
926
+ * @returns Promise resolving to updated user credential
927
+ */
928
+ linkWithTwitter(user: User): Promise<UserCredential>;
929
+ /**
930
+ * Link Microsoft account to current user
931
+ *
932
+ * @param user - Current user
933
+ * @returns Promise resolving to updated user credential
934
+ */
935
+ linkWithMicrosoft(user: User): Promise<UserCredential>;
936
+ /**
937
+ * Link Apple account to current user
938
+ *
939
+ * @param user - Current user
940
+ * @returns Promise resolving to updated user credential
941
+ */
942
+ linkWithApple(user: User): Promise<UserCredential>;
943
+ /**
944
+ * Reset SDK state (HMR support)
945
+ *
946
+ * Called during hot module replacement to reset singleton state.
947
+ * Internal method for development only.
948
+ *
949
+ * @internal
950
+ */
951
+ reset(): void;
952
+ }
953
+ /**
954
+ * Get singleton instance of Firebase SDK wrapper
955
+ *
956
+ * Always returns same instance. Safe to call multiple times.
957
+ *
958
+ * @returns Singleton FirebaseSDK instance
959
+ *
960
+ * @example
961
+ * ```typescript
962
+ * const sdk = getFirebaseSDK();
963
+ * await sdk.initialize();
964
+ * const user = sdk.getCurrentUser();
965
+ * ```
966
+ */
967
+ export declare const getFirebaseSDK: () => FirebaseSDK;
968
+ //# sourceMappingURL=sdk.d.ts.map