svelte-firekit 0.1.1 → 0.1.2
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/components/auth-guard.svelte +8 -2
- package/dist/firebase.js +15 -3
- package/dist/services/auth.js +19 -9
- package/package.json +2 -2
|
@@ -36,8 +36,14 @@
|
|
|
36
36
|
fallback?: Snippet<[]>;
|
|
37
37
|
} = $props();
|
|
38
38
|
|
|
39
|
-
// Get Firebase Auth instance
|
|
40
|
-
|
|
39
|
+
// Get Firebase Auth instance with error handling
|
|
40
|
+
let auth: Auth | null = null;
|
|
41
|
+
try {
|
|
42
|
+
auth = firebaseService.getAuthInstance();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.warn('Firebase Auth not available:', error);
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
if (!auth) {
|
|
42
48
|
throw new Error('Firebase Auth instance not available');
|
|
43
49
|
}
|
package/dist/firebase.js
CHANGED
|
@@ -129,9 +129,21 @@ class FirebaseService {
|
|
|
129
129
|
*/
|
|
130
130
|
getDbInstance() {
|
|
131
131
|
if (!this.db) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
try {
|
|
133
|
+
this.getFirebaseApp();
|
|
134
|
+
if (!this.db) {
|
|
135
|
+
// If we're not in a browser environment, Firestore won't be available
|
|
136
|
+
if (!this.isBrowser) {
|
|
137
|
+
throw new FirebaseServiceError('Firestore is not available in server environment', 'firestore');
|
|
138
|
+
}
|
|
139
|
+
throw new FirebaseServiceError('Firestore instance not available', 'firestore');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (error instanceof FirebaseServiceError) {
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
throw new FirebaseServiceError('Failed to initialize Firestore', 'firestore');
|
|
135
147
|
}
|
|
136
148
|
}
|
|
137
149
|
return this.db;
|
package/dist/services/auth.js
CHANGED
|
@@ -65,7 +65,14 @@ class FirekitAuth {
|
|
|
65
65
|
return;
|
|
66
66
|
try {
|
|
67
67
|
this.auth = firebaseService.getAuthInstance();
|
|
68
|
-
|
|
68
|
+
// Try to get Firestore instance, but don't fail if it's not available
|
|
69
|
+
try {
|
|
70
|
+
this.firestore = firebaseService.getDbInstance();
|
|
71
|
+
}
|
|
72
|
+
catch (firestoreError) {
|
|
73
|
+
console.warn('Firestore not available, continuing without Firestore integration:', firestoreError);
|
|
74
|
+
this.firestore = null;
|
|
75
|
+
}
|
|
69
76
|
this._servicesInitialized = true;
|
|
70
77
|
this.initializeAuthStateListener();
|
|
71
78
|
}
|
|
@@ -125,7 +132,8 @@ class FirekitAuth {
|
|
|
125
132
|
*/
|
|
126
133
|
async updateUserInFirestore(user) {
|
|
127
134
|
if (!this.firestore) {
|
|
128
|
-
|
|
135
|
+
console.warn('Firestore not available, skipping user update in Firestore');
|
|
136
|
+
return;
|
|
129
137
|
}
|
|
130
138
|
await updateUserInFirestore(this.firestore, user);
|
|
131
139
|
}
|
|
@@ -735,13 +743,15 @@ class FirekitAuth {
|
|
|
735
743
|
if (currentPassword) {
|
|
736
744
|
await this.reauthenticateUser(currentPassword);
|
|
737
745
|
}
|
|
738
|
-
// Delete user data from Firestore first
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
746
|
+
// Delete user data from Firestore first (if available)
|
|
747
|
+
if (this.firestore) {
|
|
748
|
+
try {
|
|
749
|
+
const userRef = doc(this.firestore, 'users', user.uid);
|
|
750
|
+
await setDoc(userRef, { deleted: true, deletedAt: serverTimestamp() }, { merge: true });
|
|
751
|
+
}
|
|
752
|
+
catch (firestoreError) {
|
|
753
|
+
console.warn('Failed to update Firestore before account deletion:', firestoreError);
|
|
754
|
+
}
|
|
745
755
|
}
|
|
746
756
|
// Delete the user account
|
|
747
757
|
await deleteUser(user);
|