svelte-firekit 0.0.25 → 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.
Files changed (95) hide show
  1. package/README.md +445 -213
  2. package/dist/components/Collection.svelte +150 -0
  3. package/dist/components/Collection.svelte.d.ts +27 -0
  4. package/dist/components/Ddoc.svelte +131 -0
  5. package/dist/components/Ddoc.svelte.d.ts +28 -0
  6. package/dist/components/Node.svelte +97 -0
  7. package/dist/components/Node.svelte.d.ts +23 -0
  8. package/dist/components/auth-guard.svelte +89 -0
  9. package/dist/components/auth-guard.svelte.d.ts +26 -0
  10. package/dist/components/custom-guard.svelte +122 -0
  11. package/dist/components/custom-guard.svelte.d.ts +31 -0
  12. package/dist/components/download-url.svelte +92 -0
  13. package/dist/components/download-url.svelte.d.ts +19 -0
  14. package/dist/components/firebase-app.svelte +30 -0
  15. package/dist/components/firebase-app.svelte.d.ts +7 -0
  16. package/dist/components/node-list.svelte +102 -0
  17. package/dist/components/node-list.svelte.d.ts +27 -0
  18. package/dist/components/signed-in.svelte +42 -0
  19. package/dist/components/signed-in.svelte.d.ts +11 -0
  20. package/dist/components/signed-out.svelte +42 -0
  21. package/dist/components/signed-out.svelte.d.ts +11 -0
  22. package/dist/components/storage-list.svelte +97 -0
  23. package/dist/components/storage-list.svelte.d.ts +26 -0
  24. package/dist/components/upload-task.svelte +108 -0
  25. package/dist/components/upload-task.svelte.d.ts +24 -0
  26. package/dist/config.js +17 -39
  27. package/dist/firebase.d.ts +43 -21
  28. package/dist/firebase.js +121 -35
  29. package/dist/index.d.ts +21 -13
  30. package/dist/index.js +27 -15
  31. package/dist/services/auth.d.ts +389 -0
  32. package/dist/services/auth.js +824 -0
  33. package/dist/services/collection.svelte.d.ts +286 -0
  34. package/dist/services/collection.svelte.js +871 -0
  35. package/dist/services/document.svelte.d.ts +288 -0
  36. package/dist/services/document.svelte.js +555 -0
  37. package/dist/services/mutations.d.ts +336 -0
  38. package/dist/services/mutations.js +1079 -0
  39. package/dist/services/presence.svelte.d.ts +141 -0
  40. package/dist/services/presence.svelte.js +727 -0
  41. package/dist/{realtime → services}/realtime.svelte.d.ts +3 -1
  42. package/dist/{realtime → services}/realtime.svelte.js +13 -7
  43. package/dist/services/storage.svelte.d.ts +257 -0
  44. package/dist/services/storage.svelte.js +374 -0
  45. package/dist/services/user.svelte.d.ts +290 -0
  46. package/dist/services/user.svelte.js +533 -0
  47. package/dist/types/auth.d.ts +158 -0
  48. package/dist/types/auth.js +106 -0
  49. package/dist/types/collection.d.ts +360 -0
  50. package/dist/types/collection.js +167 -0
  51. package/dist/types/document.d.ts +342 -0
  52. package/dist/types/document.js +148 -0
  53. package/dist/types/firebase.d.ts +44 -0
  54. package/dist/types/firebase.js +33 -0
  55. package/dist/types/index.d.ts +6 -0
  56. package/dist/types/index.js +4 -0
  57. package/dist/types/mutations.d.ts +387 -0
  58. package/dist/types/mutations.js +205 -0
  59. package/dist/types/presence.d.ts +282 -0
  60. package/dist/types/presence.js +80 -0
  61. package/dist/utils/errors.d.ts +21 -0
  62. package/dist/utils/errors.js +35 -0
  63. package/dist/utils/firestore.d.ts +9 -0
  64. package/dist/utils/firestore.js +33 -0
  65. package/dist/utils/index.d.ts +4 -0
  66. package/dist/utils/index.js +8 -0
  67. package/dist/utils/providers.d.ts +16 -0
  68. package/dist/utils/providers.js +30 -0
  69. package/dist/utils/user.d.ts +8 -0
  70. package/dist/utils/user.js +29 -0
  71. package/package.json +65 -65
  72. package/dist/auth/auth.d.ts +0 -117
  73. package/dist/auth/auth.js +0 -194
  74. package/dist/auth/presence.svelte.d.ts +0 -139
  75. package/dist/auth/presence.svelte.js +0 -373
  76. package/dist/auth/user.svelte.d.ts +0 -112
  77. package/dist/auth/user.svelte.js +0 -155
  78. package/dist/firestore/awaitable-doc.svelte.d.ts +0 -141
  79. package/dist/firestore/awaitable-doc.svelte.js +0 -183
  80. package/dist/firestore/batch-mutations.svelte.d.ts +0 -140
  81. package/dist/firestore/batch-mutations.svelte.js +0 -218
  82. package/dist/firestore/collection-group.svelte.d.ts +0 -78
  83. package/dist/firestore/collection-group.svelte.js +0 -120
  84. package/dist/firestore/collection.svelte.d.ts +0 -96
  85. package/dist/firestore/collection.svelte.js +0 -137
  86. package/dist/firestore/doc.svelte.d.ts +0 -90
  87. package/dist/firestore/doc.svelte.js +0 -131
  88. package/dist/firestore/document-mutations.svelte.d.ts +0 -164
  89. package/dist/firestore/document-mutations.svelte.js +0 -273
  90. package/dist/storage/download-url.svelte.d.ts +0 -83
  91. package/dist/storage/download-url.svelte.js +0 -114
  92. package/dist/storage/storage-list.svelte.d.ts +0 -89
  93. package/dist/storage/storage-list.svelte.js +0 -123
  94. package/dist/storage/upload-task.svelte.d.ts +0 -94
  95. package/dist/storage/upload-task.svelte.js +0 -138
@@ -0,0 +1,533 @@
1
+ /**
2
+ * @fileoverview FirekitUser Store - Reactive user state management using Svelte 5 runes
3
+ * @module FirekitUserStore
4
+ * @version 1.0.0
5
+ */
6
+ import { onAuthStateChanged, updateProfile, updateEmail, updatePassword, reload, sendEmailVerification, getIdToken } from 'firebase/auth';
7
+ import { doc, setDoc, getDoc, serverTimestamp } from 'firebase/firestore';
8
+ import { firebaseService } from '../firebase.js';
9
+ import { FirekitAuthError, AuthErrorCode } from '../types/auth.js';
10
+ import { mapFirebaseUserToProfile, updateUserInFirestore, createAuthError, validateCurrentUser } from '../utils/index.js';
11
+ /**
12
+ * Reactive user store using Svelte 5 runes for state management.
13
+ * Provides real-time authentication state and user profile management.
14
+ *
15
+ * @class FirekitUserStore
16
+ * @example
17
+ * ```typescript
18
+ * import { firekitUser } from 'svelte-firekit';
19
+ *
20
+ * // Access reactive state
21
+ * $: if (firekitUser.isAuthenticated) {
22
+ * console.log("User:", firekitUser.user);
23
+ * }
24
+ *
25
+ * // Update profile
26
+ * await firekitUser.updateDisplayName("John Doe");
27
+ *
28
+ * // Get extended user data
29
+ * const userData = await firekitUser.getExtendedUserData();
30
+ * ```
31
+ */
32
+ class FirekitUserStore {
33
+ static instance;
34
+ auth = firebaseService.getAuthInstance();
35
+ firestore = firebaseService.getDbInstance();
36
+ // ========================================
37
+ // REACTIVE STATE (Svelte 5 Runes)
38
+ // ========================================
39
+ /** Current user profile state */
40
+ _user = $state(null);
41
+ /** Loading state indicator */
42
+ _loading = $state(true);
43
+ /** Authentication initialization state */
44
+ _initialized = $state(false);
45
+ /** Current error state */
46
+ _error = $state(null);
47
+ // ========================================
48
+ // DERIVED STATE
49
+ // ========================================
50
+ /** Derived: Whether user is authenticated (not anonymous) */
51
+ _isAuthenticated = $derived(this._user !== null && !this._user.isAnonymous);
52
+ /** Derived: Whether user is anonymous */
53
+ _isAnonymous = $derived(this._user?.isAnonymous ?? false);
54
+ /** Derived: Whether user's email is verified */
55
+ _isEmailVerified = $derived(this._user?.emailVerified ?? false);
56
+ /** Derived: User's primary email address */
57
+ _userEmail = $derived(this._user?.email ?? null);
58
+ /** Derived: User's display name */
59
+ _userDisplayName = $derived(this._user?.displayName ?? null);
60
+ /** Derived: User's photo URL */
61
+ _userPhotoURL = $derived(this._user?.photoURL ?? null);
62
+ /** Derived: User's unique ID */
63
+ _userId = $derived(this._user?.uid ?? null);
64
+ /** Derived: User's phone number */
65
+ _userPhoneNumber = $derived(this._user?.phoneNumber ?? null);
66
+ constructor() {
67
+ if (!this.auth) {
68
+ throw new Error('Firebase Auth instance not available');
69
+ }
70
+ if (!this.firestore) {
71
+ throw new Error('Firestore instance not available');
72
+ }
73
+ this.initializeAuthStateListener();
74
+ }
75
+ /**
76
+ * Gets singleton instance of FirekitUserStore
77
+ * @returns {FirekitUserStore} The FirekitUserStore instance
78
+ */
79
+ static getInstance() {
80
+ if (!FirekitUserStore.instance) {
81
+ FirekitUserStore.instance = new FirekitUserStore();
82
+ }
83
+ return FirekitUserStore.instance;
84
+ }
85
+ /**
86
+ * Initializes the authentication state listener
87
+ * @private
88
+ */
89
+ initializeAuthStateListener() {
90
+ onAuthStateChanged(this.auth, (firebaseUser) => {
91
+ this._user = firebaseUser ? this.mapFirebaseUserToProfile(firebaseUser) : null;
92
+ this._loading = false;
93
+ this._initialized = true;
94
+ this._error = null;
95
+ }, (error) => {
96
+ console.error('Auth state change error:', error);
97
+ this._error = error;
98
+ this._loading = false;
99
+ this._initialized = true;
100
+ });
101
+ }
102
+ /**
103
+ * Maps Firebase User to UserProfile interface
104
+ * @private
105
+ */
106
+ mapFirebaseUserToProfile(user) {
107
+ return mapFirebaseUserToProfile(user);
108
+ }
109
+ /**
110
+ * Updates user data in Firestore
111
+ * @private
112
+ */
113
+ async updateUserInFirestore(user) {
114
+ await updateUserInFirestore(this.firestore, user);
115
+ }
116
+ // ========================================
117
+ // PUBLIC GETTERS (Reactive State)
118
+ // ========================================
119
+ /** Current user profile */
120
+ get user() {
121
+ return this._user;
122
+ }
123
+ /** Current loading state */
124
+ get loading() {
125
+ return this._loading;
126
+ }
127
+ /** Whether auth has been initialized */
128
+ get initialized() {
129
+ return this._initialized;
130
+ }
131
+ /** Current error state */
132
+ get error() {
133
+ return this._error;
134
+ }
135
+ /** Whether user is authenticated (not anonymous) */
136
+ get isAuthenticated() {
137
+ return this._isAuthenticated;
138
+ }
139
+ /** Whether user is anonymous */
140
+ get isAnonymous() {
141
+ return this._isAnonymous;
142
+ }
143
+ /** Whether user's email is verified */
144
+ get isEmailVerified() {
145
+ return this._isEmailVerified;
146
+ }
147
+ /** User's email address */
148
+ get email() {
149
+ return this._userEmail;
150
+ }
151
+ /** User's display name */
152
+ get displayName() {
153
+ return this._userDisplayName;
154
+ }
155
+ /** User's photo URL */
156
+ get photoURL() {
157
+ return this._userPhotoURL;
158
+ }
159
+ /** User's unique ID */
160
+ get uid() {
161
+ return this._userId;
162
+ }
163
+ /** User's phone number */
164
+ get phoneNumber() {
165
+ return this._userPhoneNumber;
166
+ }
167
+ // ========================================
168
+ // PROFILE UPDATE METHODS
169
+ // ========================================
170
+ /**
171
+ * Updates user's display name
172
+ * @param {string} displayName New display name
173
+ * @returns {Promise<void>} Promise that resolves when update completes
174
+ * @throws {FirekitAuthError} If update fails
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * await firekitUser.updateDisplayName("John Doe");
179
+ * ```
180
+ */
181
+ async updateDisplayName(displayName) {
182
+ const currentUser = validateCurrentUser(this.auth);
183
+ try {
184
+ this._loading = true;
185
+ await updateProfile(currentUser, { displayName });
186
+ await this.updateUserInFirestore(currentUser);
187
+ // Update local state
188
+ if (this._user) {
189
+ this._user = { ...this._user, displayName };
190
+ }
191
+ }
192
+ catch (error) {
193
+ this._error = error;
194
+ throw createAuthError(error, 'update display name');
195
+ }
196
+ finally {
197
+ this._loading = false;
198
+ }
199
+ }
200
+ /**
201
+ * Updates user's photo URL
202
+ * @param {string} photoURL New photo URL
203
+ * @returns {Promise<void>} Promise that resolves when update completes
204
+ * @throws {FirekitAuthError} If update fails
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * await firekitUser.updatePhotoURL("https://example.com/photo.jpg");
209
+ * ```
210
+ */
211
+ async updatePhotoURL(photoURL) {
212
+ const currentUser = validateCurrentUser(this.auth);
213
+ try {
214
+ this._loading = true;
215
+ await updateProfile(currentUser, { photoURL });
216
+ await this.updateUserInFirestore(currentUser);
217
+ // Update local state
218
+ if (this._user) {
219
+ this._user = { ...this._user, photoURL };
220
+ }
221
+ }
222
+ catch (error) {
223
+ this._error = error;
224
+ throw createAuthError(error, 'update photo URL');
225
+ }
226
+ finally {
227
+ this._loading = false;
228
+ }
229
+ }
230
+ /**
231
+ * Updates user's profile data
232
+ * @param {UserProfileUpdateData} profileData Profile data to update
233
+ * @returns {Promise<void>} Promise that resolves when update completes
234
+ * @throws {FirekitAuthError} If update fails
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * await firekitUser.updateProfile({
239
+ * displayName: "John Smith",
240
+ * photoURL: "https://example.com/new-photo.jpg"
241
+ * });
242
+ * ```
243
+ */
244
+ async updateProfile(profileData) {
245
+ const currentUser = validateCurrentUser(this.auth);
246
+ try {
247
+ this._loading = true;
248
+ await updateProfile(currentUser, profileData);
249
+ await this.updateUserInFirestore(currentUser);
250
+ // Update local state
251
+ if (this._user) {
252
+ this._user = {
253
+ ...this._user,
254
+ displayName: profileData.displayName ?? this._user.displayName,
255
+ photoURL: profileData.photoURL ?? this._user.photoURL
256
+ };
257
+ }
258
+ }
259
+ catch (error) {
260
+ this._error = error;
261
+ throw createAuthError(error, 'update profile');
262
+ }
263
+ finally {
264
+ this._loading = false;
265
+ }
266
+ }
267
+ /**
268
+ * Updates user's email address
269
+ * @param {string} newEmail New email address
270
+ * @returns {Promise<void>} Promise that resolves when update completes
271
+ * @throws {FirekitAuthError} If update fails
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * await firekitUser.updateEmail("newemail@example.com");
276
+ * ```
277
+ */
278
+ async updateEmail(newEmail) {
279
+ const currentUser = validateCurrentUser(this.auth);
280
+ try {
281
+ this._loading = true;
282
+ await updateEmail(currentUser, newEmail);
283
+ await this.updateUserInFirestore(currentUser);
284
+ // Update local state
285
+ if (this._user) {
286
+ this._user = { ...this._user, email: newEmail, emailVerified: false };
287
+ }
288
+ }
289
+ catch (error) {
290
+ this._error = error;
291
+ throw createAuthError(error, 'update email');
292
+ }
293
+ finally {
294
+ this._loading = false;
295
+ }
296
+ }
297
+ /**
298
+ * Updates user's password
299
+ * @param {string} newPassword New password
300
+ * @returns {Promise<void>} Promise that resolves when update completes
301
+ * @throws {FirekitAuthError} If update fails
302
+ *
303
+ * @example
304
+ * ```typescript
305
+ * await firekitUser.updatePassword("newSecurePassword123");
306
+ * ```
307
+ */
308
+ async updatePassword(newPassword) {
309
+ const currentUser = validateCurrentUser(this.auth);
310
+ try {
311
+ this._loading = true;
312
+ await updatePassword(currentUser, newPassword);
313
+ }
314
+ catch (error) {
315
+ this._error = error;
316
+ throw createAuthError(error, 'update password');
317
+ }
318
+ finally {
319
+ this._loading = false;
320
+ }
321
+ }
322
+ // ========================================
323
+ // EMAIL VERIFICATION METHODS
324
+ // ========================================
325
+ /**
326
+ * Sends email verification to current user
327
+ * @returns {Promise<void>} Promise that resolves when verification email is sent
328
+ * @throws {FirekitAuthError} If sending fails
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * await firekitUser.sendEmailVerification();
333
+ * ```
334
+ */
335
+ async sendEmailVerification() {
336
+ const currentUser = validateCurrentUser(this.auth);
337
+ try {
338
+ await sendEmailVerification(currentUser);
339
+ }
340
+ catch (error) {
341
+ this._error = error;
342
+ throw createAuthError(error, 'send email verification');
343
+ }
344
+ }
345
+ /**
346
+ * Reloads user to get updated email verification status
347
+ * @returns {Promise<void>} Promise that resolves when user is reloaded
348
+ * @throws {FirekitAuthError} If reload fails
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * await firekitUser.reloadUser();
353
+ * ```
354
+ */
355
+ async reloadUser() {
356
+ const currentUser = validateCurrentUser(this.auth);
357
+ try {
358
+ this._loading = true;
359
+ await reload(currentUser);
360
+ await this.updateUserInFirestore(currentUser);
361
+ // Update local state with reloaded data
362
+ this._user = this.mapFirebaseUserToProfile(currentUser);
363
+ }
364
+ catch (error) {
365
+ this._error = error;
366
+ throw createAuthError(error, 'reload user');
367
+ }
368
+ finally {
369
+ this._loading = false;
370
+ }
371
+ }
372
+ // ========================================
373
+ // TOKEN METHODS
374
+ // ========================================
375
+ /**
376
+ * Gets the current user's ID token
377
+ * @param {boolean} [forceRefresh=false] Whether to force token refresh
378
+ * @returns {Promise<string>} Promise resolving to ID token
379
+ * @throws {FirekitAuthError} If getting token fails
380
+ *
381
+ * @example
382
+ * ```typescript
383
+ * const token = await firekitUser.getIdToken();
384
+ * ```
385
+ */
386
+ async getIdToken(forceRefresh = false) {
387
+ const currentUser = validateCurrentUser(this.auth);
388
+ try {
389
+ return await getIdToken(currentUser, forceRefresh);
390
+ }
391
+ catch (error) {
392
+ this._error = error;
393
+ throw createAuthError(error, 'get ID token');
394
+ }
395
+ }
396
+ // ========================================
397
+ // FIRESTORE EXTENDED DATA METHODS
398
+ // ========================================
399
+ /**
400
+ * Gets extended user data from Firestore
401
+ * @returns {Promise<ExtendedUserData | null>} Promise resolving to extended user data
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * const userData = await firekitUser.getExtendedUserData();
406
+ * console.log(userData?.preferences);
407
+ * ```
408
+ */
409
+ async getExtendedUserData() {
410
+ if (!this._user?.uid) {
411
+ return null;
412
+ }
413
+ try {
414
+ const userRef = doc(this.firestore, 'users', this._user.uid);
415
+ const userDoc = await getDoc(userRef);
416
+ if (userDoc.exists()) {
417
+ return userDoc.data();
418
+ }
419
+ return null;
420
+ }
421
+ catch (error) {
422
+ console.error('Failed to get extended user data:', error);
423
+ this._error = error;
424
+ return null;
425
+ }
426
+ }
427
+ /**
428
+ * Updates extended user data in Firestore
429
+ * @param {Partial<ExtendedUserData>} data Data to update
430
+ * @returns {Promise<void>} Promise that resolves when update completes
431
+ *
432
+ * @example
433
+ * ```typescript
434
+ * await firekitUser.updateExtendedUserData({
435
+ * preferences: { theme: 'dark', language: 'en' },
436
+ * settings: { notifications: true }
437
+ * });
438
+ * ```
439
+ */
440
+ async updateExtendedUserData(data) {
441
+ if (!this._user?.uid) {
442
+ throw new FirekitAuthError(AuthErrorCode.USER_NOT_FOUND, 'No authenticated user found.');
443
+ }
444
+ try {
445
+ const userRef = doc(this.firestore, 'users', this._user.uid);
446
+ await setDoc(userRef, {
447
+ ...data,
448
+ updatedAt: serverTimestamp()
449
+ }, { merge: true });
450
+ }
451
+ catch (error) {
452
+ this._error = error;
453
+ throw createAuthError(error, 'update user data');
454
+ }
455
+ }
456
+ // ========================================
457
+ // UTILITY METHODS
458
+ // ========================================
459
+ /**
460
+ * Waits for authentication to initialize
461
+ * @returns {Promise<UserProfile | null>} Promise that resolves when auth is initialized
462
+ *
463
+ * @example
464
+ * ```typescript
465
+ * const user = await firekitUser.waitForAuth();
466
+ * if (user) {
467
+ * console.log("User is authenticated");
468
+ * }
469
+ * ```
470
+ */
471
+ async waitForAuth() {
472
+ return new Promise((resolve) => {
473
+ if (this._initialized) {
474
+ resolve(this._user);
475
+ return;
476
+ }
477
+ // Create a one-time watcher
478
+ const checkInitialized = () => {
479
+ if (this._initialized) {
480
+ resolve(this._user);
481
+ }
482
+ else {
483
+ // Check again in next tick
484
+ setTimeout(checkInitialized, 10);
485
+ }
486
+ };
487
+ checkInitialized();
488
+ });
489
+ }
490
+ /**
491
+ * Clears any error state
492
+ */
493
+ clearError() {
494
+ this._error = null;
495
+ }
496
+ /**
497
+ * Manually sets loading state (use with caution)
498
+ * @param {boolean} loading Loading state
499
+ */
500
+ setLoading(loading) {
501
+ this._loading = loading;
502
+ }
503
+ /**
504
+ * Resets the store to initial state
505
+ */
506
+ reset() {
507
+ this._user = null;
508
+ this._loading = true;
509
+ this._initialized = false;
510
+ this._error = null;
511
+ }
512
+ }
513
+ /**
514
+ * Pre-initialized singleton instance of FirekitUserStore.
515
+ * Provides reactive user state management for Svelte applications.
516
+ *
517
+ * @example
518
+ * ```typescript
519
+ * import { firekitUser } from 'svelte-firekit';
520
+ *
521
+ * // In a Svelte component
522
+ * $: if (firekitUser.isAuthenticated) {
523
+ * console.log("Welcome:", firekitUser.displayName);
524
+ * }
525
+ *
526
+ * // Update profile
527
+ * await firekitUser.updateDisplayName("John Doe");
528
+ *
529
+ * // Get extended data
530
+ * const userData = await firekitUser.getExtendedUserData();
531
+ * ```
532
+ */
533
+ export const firekitUser = FirekitUserStore.getInstance();
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @fileoverview Authentication types and interfaces for FirekitAuth
3
+ * @module AuthTypes
4
+ * @version 1.0.0
5
+ */
6
+ /**
7
+ * User profile interface with all Firebase user properties
8
+ */
9
+ export interface UserProfile {
10
+ uid: string;
11
+ email: string | null;
12
+ displayName: string | null;
13
+ photoURL: string | null;
14
+ phoneNumber: string | null;
15
+ emailVerified: boolean;
16
+ isAnonymous: boolean;
17
+ providerId: string;
18
+ metadata: {
19
+ creationTime?: string;
20
+ lastSignInTime?: string;
21
+ };
22
+ providerData: Array<{
23
+ providerId: string;
24
+ uid: string;
25
+ displayName: string | null;
26
+ email: string | null;
27
+ phoneNumber: string | null;
28
+ photoURL: string | null;
29
+ }>;
30
+ customClaims?: Record<string, any>;
31
+ }
32
+ /**
33
+ * Authentication state interface
34
+ */
35
+ export interface AuthState {
36
+ user: UserProfile | null;
37
+ loading: boolean;
38
+ initialized: boolean;
39
+ }
40
+ /**
41
+ * Password update result interface
42
+ */
43
+ export interface PasswordUpdateResult {
44
+ success: boolean;
45
+ message: string;
46
+ code?: string;
47
+ }
48
+ /**
49
+ * Account deletion result interface
50
+ */
51
+ export interface AccountDeletionResult {
52
+ success: boolean;
53
+ message: string;
54
+ }
55
+ /**
56
+ * Phone verification result interface
57
+ */
58
+ export interface PhoneVerificationResult {
59
+ verificationId: string;
60
+ confirm: (code: string) => Promise<UserProfile>;
61
+ }
62
+ /**
63
+ * User registration data interface
64
+ */
65
+ export interface UserRegistrationData {
66
+ email: string;
67
+ password: string;
68
+ displayName?: string;
69
+ photoURL?: string;
70
+ }
71
+ /**
72
+ * User profile update data interface
73
+ */
74
+ export interface UserProfileUpdateData {
75
+ displayName?: string;
76
+ photoURL?: string;
77
+ }
78
+ /**
79
+ * OAuth provider types
80
+ */
81
+ export type OAuthProviderType = 'google' | 'facebook' | 'apple' | 'microsoft' | 'github' | 'twitter';
82
+ /**
83
+ * Authentication method types
84
+ */
85
+ export type AuthMethodType = 'email' | 'phone' | 'google' | 'facebook' | 'apple' | 'microsoft' | 'github' | 'twitter' | 'anonymous';
86
+ /**
87
+ * Authentication event types
88
+ */
89
+ export type AuthEventType = 'signIn' | 'signOut' | 'signUp' | 'passwordReset' | 'emailVerification' | 'profileUpdate' | 'accountDeletion' | 'error';
90
+ /**
91
+ * Authentication event data interface
92
+ */
93
+ export interface AuthEventData {
94
+ type: AuthEventType;
95
+ user?: UserProfile | null;
96
+ method?: AuthMethodType;
97
+ error?: FirekitAuthError;
98
+ timestamp: Date;
99
+ }
100
+ /**
101
+ * Authentication configuration interface
102
+ */
103
+ export interface AuthConfig {
104
+ /** Enable automatic Firestore user data sync */
105
+ enableFirestoreSync?: boolean;
106
+ /** Custom Firestore collection path for users */
107
+ usersCollectionPath?: string;
108
+ /** Enable email verification on registration */
109
+ requireEmailVerification?: boolean;
110
+ /** Custom error message overrides */
111
+ errorMessages?: Partial<Record<AuthErrorCode, string>>;
112
+ /** Enable analytics tracking */
113
+ enableAnalytics?: boolean;
114
+ }
115
+ /**
116
+ * Authentication error codes enum
117
+ */
118
+ export declare enum AuthErrorCode {
119
+ EMAIL_ALREADY_IN_USE = "auth/email-already-in-use",
120
+ INVALID_EMAIL = "auth/invalid-email",
121
+ USER_NOT_FOUND = "auth/user-not-found",
122
+ WRONG_PASSWORD = "auth/wrong-password",
123
+ WEAK_PASSWORD = "auth/weak-password",
124
+ TOO_MANY_REQUESTS = "auth/too-many-requests",
125
+ POPUP_CLOSED = "auth/popup-closed-by-user",
126
+ NETWORK_REQUEST_FAILED = "auth/network-request-failed",
127
+ USER_DISABLED = "auth/user-disabled",
128
+ OPERATION_NOT_ALLOWED = "auth/operation-not-allowed",
129
+ INVALID_VERIFICATION_CODE = "auth/invalid-verification-code",
130
+ INVALID_VERIFICATION_ID = "auth/invalid-verification-id",
131
+ REQUIRES_RECENT_LOGIN = "auth/requires-recent-login",
132
+ EXPIRED_ACTION_CODE = "auth/expired-action-code",
133
+ INVALID_ACTION_CODE = "auth/invalid-action-code",
134
+ MISSING_EMAIL = "auth/missing-email",
135
+ MISSING_PASSWORD = "auth/missing-password",
136
+ INVALID_PHONE_NUMBER = "auth/invalid-phone-number",
137
+ MISSING_PHONE_NUMBER = "auth/missing-phone-number",
138
+ QUOTA_EXCEEDED = "auth/quota-exceeded",
139
+ APP_NOT_AUTHORIZED = "auth/app-not-authorized",
140
+ KEYBOARD_NOT_SUPPORTED = "auth/keychain-error",
141
+ INTERNAL_ERROR = "auth/internal-error"
142
+ }
143
+ /**
144
+ * Custom authentication error class
145
+ */
146
+ export declare class FirekitAuthError extends Error {
147
+ code: AuthErrorCode | string;
148
+ originalError?: any | undefined;
149
+ constructor(code: AuthErrorCode | string, message: string, originalError?: any | undefined);
150
+ /**
151
+ * Get user-friendly error message
152
+ */
153
+ getFriendlyMessage(): string;
154
+ /**
155
+ * Check if error is retryable
156
+ */
157
+ isRetryable(): boolean;
158
+ }