funuicss 3.6.19 → 3.7.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/css/fun.css +138 -127
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +1 -2
- package/ui/carousel/Carousel.d.ts +2 -0
- package/ui/carousel/Carousel.js +11 -11
- package/ui/chart/Line.d.ts +68 -11
- package/ui/chart/Line.js +227 -26
- package/ui/sidebar/SideBar.js +1 -1
- package/ui/text/Text.js +73 -33
- package/ui/theme/theme.d.ts +12 -0
- package/ui/theme/theme.js +104 -52
- package/js/firebase/Auth.d.ts +0 -191
- package/js/firebase/Auth.js +0 -746
- package/js/firebase/FireStore.d.ts +0 -54
- package/js/firebase/FireStore.js +0 -285
package/js/firebase/Auth.js
DELETED
|
@@ -1,746 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.AuthErrorCodes = exports.FunFireAuth = void 0;
|
|
49
|
-
var auth_1 = require("firebase/auth");
|
|
50
|
-
/**
|
|
51
|
-
* Firebase Authentication Operations
|
|
52
|
-
* Users must pass their Auth instance to each method
|
|
53
|
-
*/
|
|
54
|
-
exports.FunFireAuth = {
|
|
55
|
-
/**
|
|
56
|
-
* 📧 Sign in with email and password
|
|
57
|
-
* @param auth - Firebase Auth instance
|
|
58
|
-
* @param email - User email
|
|
59
|
-
* @param password - User password
|
|
60
|
-
*/
|
|
61
|
-
signInWithEmail: function (auth, email, password) { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var credential, err_1, error;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
_a.trys.push([0, 2, , 3]);
|
|
67
|
-
return [4 /*yield*/, (0, auth_1.signInWithEmailAndPassword)(auth, email, password)];
|
|
68
|
-
case 1:
|
|
69
|
-
credential = _a.sent();
|
|
70
|
-
return [2 /*return*/, {
|
|
71
|
-
user: credential.user,
|
|
72
|
-
credential: credential
|
|
73
|
-
}];
|
|
74
|
-
case 2:
|
|
75
|
-
err_1 = _a.sent();
|
|
76
|
-
error = err_1;
|
|
77
|
-
throw new Error("Sign in failed: ".concat(error.message));
|
|
78
|
-
case 3: return [2 /*return*/];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}); },
|
|
82
|
-
/**
|
|
83
|
-
* ✍️ Create account with email and password
|
|
84
|
-
* @param auth - Firebase Auth instance
|
|
85
|
-
* @param email - User email
|
|
86
|
-
* @param password - User password
|
|
87
|
-
* @param displayName - Optional display name
|
|
88
|
-
* @param photoURL - Optional photo URL
|
|
89
|
-
*/
|
|
90
|
-
createAccount: function (auth, email, password, displayName, photoURL) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
-
var credential, err_2, error;
|
|
92
|
-
return __generator(this, function (_a) {
|
|
93
|
-
switch (_a.label) {
|
|
94
|
-
case 0:
|
|
95
|
-
_a.trys.push([0, 4, , 5]);
|
|
96
|
-
return [4 /*yield*/, (0, auth_1.createUserWithEmailAndPassword)(auth, email, password)];
|
|
97
|
-
case 1:
|
|
98
|
-
credential = _a.sent();
|
|
99
|
-
if (!(displayName || photoURL)) return [3 /*break*/, 3];
|
|
100
|
-
return [4 /*yield*/, (0, auth_1.updateProfile)(credential.user, {
|
|
101
|
-
displayName: displayName || null,
|
|
102
|
-
photoURL: photoURL || null
|
|
103
|
-
})];
|
|
104
|
-
case 2:
|
|
105
|
-
_a.sent();
|
|
106
|
-
_a.label = 3;
|
|
107
|
-
case 3: return [2 /*return*/, {
|
|
108
|
-
user: credential.user,
|
|
109
|
-
credential: credential,
|
|
110
|
-
isNewUser: true
|
|
111
|
-
}];
|
|
112
|
-
case 4:
|
|
113
|
-
err_2 = _a.sent();
|
|
114
|
-
error = err_2;
|
|
115
|
-
throw new Error("Account creation failed: ".concat(error.message));
|
|
116
|
-
case 5: return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}); },
|
|
120
|
-
/**
|
|
121
|
-
* 🔐 Sign in with Google (Popup)
|
|
122
|
-
* @param auth - Firebase Auth instance
|
|
123
|
-
*/
|
|
124
|
-
signInWithGoogle: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
-
var provider, credential, additionalInfo, err_3, error;
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
switch (_a.label) {
|
|
128
|
-
case 0:
|
|
129
|
-
_a.trys.push([0, 2, , 3]);
|
|
130
|
-
provider = new auth_1.GoogleAuthProvider();
|
|
131
|
-
provider.addScope('profile');
|
|
132
|
-
provider.addScope('email');
|
|
133
|
-
return [4 /*yield*/, (0, auth_1.signInWithPopup)(auth, provider)];
|
|
134
|
-
case 1:
|
|
135
|
-
credential = _a.sent();
|
|
136
|
-
additionalInfo = (0, auth_1.getAdditionalUserInfo)(credential);
|
|
137
|
-
return [2 /*return*/, {
|
|
138
|
-
user: credential.user,
|
|
139
|
-
credential: credential,
|
|
140
|
-
isNewUser: additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.isNewUser
|
|
141
|
-
}];
|
|
142
|
-
case 2:
|
|
143
|
-
err_3 = _a.sent();
|
|
144
|
-
error = err_3;
|
|
145
|
-
throw new Error("Google sign in failed: ".concat(error.message));
|
|
146
|
-
case 3: return [2 /*return*/];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}); },
|
|
150
|
-
/**
|
|
151
|
-
* 🔐 Sign in with Facebook (Popup)
|
|
152
|
-
* @param auth - Firebase Auth instance
|
|
153
|
-
*/
|
|
154
|
-
signInWithFacebook: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
155
|
-
var provider, credential, additionalInfo, err_4, error;
|
|
156
|
-
return __generator(this, function (_a) {
|
|
157
|
-
switch (_a.label) {
|
|
158
|
-
case 0:
|
|
159
|
-
_a.trys.push([0, 2, , 3]);
|
|
160
|
-
provider = new auth_1.FacebookAuthProvider();
|
|
161
|
-
provider.addScope('email');
|
|
162
|
-
provider.addScope('public_profile');
|
|
163
|
-
return [4 /*yield*/, (0, auth_1.signInWithPopup)(auth, provider)];
|
|
164
|
-
case 1:
|
|
165
|
-
credential = _a.sent();
|
|
166
|
-
additionalInfo = (0, auth_1.getAdditionalUserInfo)(credential);
|
|
167
|
-
return [2 /*return*/, {
|
|
168
|
-
user: credential.user,
|
|
169
|
-
credential: credential,
|
|
170
|
-
isNewUser: additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.isNewUser
|
|
171
|
-
}];
|
|
172
|
-
case 2:
|
|
173
|
-
err_4 = _a.sent();
|
|
174
|
-
error = err_4;
|
|
175
|
-
throw new Error("Facebook sign in failed: ".concat(error.message));
|
|
176
|
-
case 3: return [2 /*return*/];
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}); },
|
|
180
|
-
/**
|
|
181
|
-
* 🔐 Sign in with GitHub (Popup)
|
|
182
|
-
* @param auth - Firebase Auth instance
|
|
183
|
-
*/
|
|
184
|
-
signInWithGithub: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
185
|
-
var provider, credential, additionalInfo, err_5, error;
|
|
186
|
-
return __generator(this, function (_a) {
|
|
187
|
-
switch (_a.label) {
|
|
188
|
-
case 0:
|
|
189
|
-
_a.trys.push([0, 2, , 3]);
|
|
190
|
-
provider = new auth_1.GithubAuthProvider();
|
|
191
|
-
provider.addScope('user:email');
|
|
192
|
-
return [4 /*yield*/, (0, auth_1.signInWithPopup)(auth, provider)];
|
|
193
|
-
case 1:
|
|
194
|
-
credential = _a.sent();
|
|
195
|
-
additionalInfo = (0, auth_1.getAdditionalUserInfo)(credential);
|
|
196
|
-
return [2 /*return*/, {
|
|
197
|
-
user: credential.user,
|
|
198
|
-
credential: credential,
|
|
199
|
-
isNewUser: additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.isNewUser
|
|
200
|
-
}];
|
|
201
|
-
case 2:
|
|
202
|
-
err_5 = _a.sent();
|
|
203
|
-
error = err_5;
|
|
204
|
-
throw new Error("GitHub sign in failed: ".concat(error.message));
|
|
205
|
-
case 3: return [2 /*return*/];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}); },
|
|
209
|
-
/**
|
|
210
|
-
* 🔐 Sign in with Twitter (Popup)
|
|
211
|
-
* @param auth - Firebase Auth instance
|
|
212
|
-
*/
|
|
213
|
-
signInWithTwitter: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
-
var provider, credential, additionalInfo, err_6, error;
|
|
215
|
-
return __generator(this, function (_a) {
|
|
216
|
-
switch (_a.label) {
|
|
217
|
-
case 0:
|
|
218
|
-
_a.trys.push([0, 2, , 3]);
|
|
219
|
-
provider = new auth_1.TwitterAuthProvider();
|
|
220
|
-
return [4 /*yield*/, (0, auth_1.signInWithPopup)(auth, provider)];
|
|
221
|
-
case 1:
|
|
222
|
-
credential = _a.sent();
|
|
223
|
-
additionalInfo = (0, auth_1.getAdditionalUserInfo)(credential);
|
|
224
|
-
return [2 /*return*/, {
|
|
225
|
-
user: credential.user,
|
|
226
|
-
credential: credential,
|
|
227
|
-
isNewUser: additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.isNewUser
|
|
228
|
-
}];
|
|
229
|
-
case 2:
|
|
230
|
-
err_6 = _a.sent();
|
|
231
|
-
error = err_6;
|
|
232
|
-
throw new Error("Twitter sign in failed: ".concat(error.message));
|
|
233
|
-
case 3: return [2 /*return*/];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}); },
|
|
237
|
-
/**
|
|
238
|
-
* 🔐 Sign in with Microsoft (Popup)
|
|
239
|
-
* @param auth - Firebase Auth instance
|
|
240
|
-
*/
|
|
241
|
-
signInWithMicrosoft: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
242
|
-
var provider, credential, additionalInfo, err_7, error;
|
|
243
|
-
return __generator(this, function (_a) {
|
|
244
|
-
switch (_a.label) {
|
|
245
|
-
case 0:
|
|
246
|
-
_a.trys.push([0, 2, , 3]);
|
|
247
|
-
provider = new auth_1.OAuthProvider('microsoft.com');
|
|
248
|
-
provider.addScope('email');
|
|
249
|
-
provider.addScope('profile');
|
|
250
|
-
return [4 /*yield*/, (0, auth_1.signInWithPopup)(auth, provider)];
|
|
251
|
-
case 1:
|
|
252
|
-
credential = _a.sent();
|
|
253
|
-
additionalInfo = (0, auth_1.getAdditionalUserInfo)(credential);
|
|
254
|
-
return [2 /*return*/, {
|
|
255
|
-
user: credential.user,
|
|
256
|
-
credential: credential,
|
|
257
|
-
isNewUser: additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.isNewUser
|
|
258
|
-
}];
|
|
259
|
-
case 2:
|
|
260
|
-
err_7 = _a.sent();
|
|
261
|
-
error = err_7;
|
|
262
|
-
throw new Error("Microsoft sign in failed: ".concat(error.message));
|
|
263
|
-
case 3: return [2 /*return*/];
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}); },
|
|
267
|
-
/**
|
|
268
|
-
* 🔐 Sign in with Apple (Popup)
|
|
269
|
-
* @param auth - Firebase Auth instance
|
|
270
|
-
*/
|
|
271
|
-
signInWithApple: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
272
|
-
var provider, credential, additionalInfo, err_8, error;
|
|
273
|
-
return __generator(this, function (_a) {
|
|
274
|
-
switch (_a.label) {
|
|
275
|
-
case 0:
|
|
276
|
-
_a.trys.push([0, 2, , 3]);
|
|
277
|
-
provider = new auth_1.OAuthProvider('apple.com');
|
|
278
|
-
provider.addScope('email');
|
|
279
|
-
provider.addScope('name');
|
|
280
|
-
return [4 /*yield*/, (0, auth_1.signInWithPopup)(auth, provider)];
|
|
281
|
-
case 1:
|
|
282
|
-
credential = _a.sent();
|
|
283
|
-
additionalInfo = (0, auth_1.getAdditionalUserInfo)(credential);
|
|
284
|
-
return [2 /*return*/, {
|
|
285
|
-
user: credential.user,
|
|
286
|
-
credential: credential,
|
|
287
|
-
isNewUser: additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.isNewUser
|
|
288
|
-
}];
|
|
289
|
-
case 2:
|
|
290
|
-
err_8 = _a.sent();
|
|
291
|
-
error = err_8;
|
|
292
|
-
throw new Error("Apple sign in failed: ".concat(error.message));
|
|
293
|
-
case 3: return [2 /*return*/];
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}); },
|
|
297
|
-
/**
|
|
298
|
-
* 🔐 Generic provider sign in with redirect (better for mobile)
|
|
299
|
-
* @param auth - Firebase Auth instance
|
|
300
|
-
* @param providerType - Provider type
|
|
301
|
-
*/
|
|
302
|
-
signInWithRedirect: function (auth, providerType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
303
|
-
var provider, err_9, error;
|
|
304
|
-
return __generator(this, function (_a) {
|
|
305
|
-
switch (_a.label) {
|
|
306
|
-
case 0:
|
|
307
|
-
_a.trys.push([0, 2, , 3]);
|
|
308
|
-
provider = void 0;
|
|
309
|
-
switch (providerType) {
|
|
310
|
-
case 'google':
|
|
311
|
-
provider = new auth_1.GoogleAuthProvider();
|
|
312
|
-
break;
|
|
313
|
-
case 'facebook':
|
|
314
|
-
provider = new auth_1.FacebookAuthProvider();
|
|
315
|
-
break;
|
|
316
|
-
case 'github':
|
|
317
|
-
provider = new auth_1.GithubAuthProvider();
|
|
318
|
-
break;
|
|
319
|
-
case 'twitter':
|
|
320
|
-
provider = new auth_1.TwitterAuthProvider();
|
|
321
|
-
break;
|
|
322
|
-
case 'microsoft':
|
|
323
|
-
provider = new auth_1.OAuthProvider('microsoft.com');
|
|
324
|
-
break;
|
|
325
|
-
case 'apple':
|
|
326
|
-
provider = new auth_1.OAuthProvider('apple.com');
|
|
327
|
-
break;
|
|
328
|
-
default:
|
|
329
|
-
throw new Error('Invalid provider type');
|
|
330
|
-
}
|
|
331
|
-
return [4 /*yield*/, (0, auth_1.signInWithRedirect)(auth, provider)];
|
|
332
|
-
case 1:
|
|
333
|
-
_a.sent();
|
|
334
|
-
return [3 /*break*/, 3];
|
|
335
|
-
case 2:
|
|
336
|
-
err_9 = _a.sent();
|
|
337
|
-
error = err_9;
|
|
338
|
-
throw new Error("Redirect sign in failed: ".concat(error.message));
|
|
339
|
-
case 3: return [2 /*return*/];
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
}); },
|
|
343
|
-
/**
|
|
344
|
-
* 🚪 Sign out
|
|
345
|
-
* @param auth - Firebase Auth instance
|
|
346
|
-
*/
|
|
347
|
-
signOut: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
348
|
-
var err_10, error;
|
|
349
|
-
return __generator(this, function (_a) {
|
|
350
|
-
switch (_a.label) {
|
|
351
|
-
case 0:
|
|
352
|
-
_a.trys.push([0, 2, , 3]);
|
|
353
|
-
return [4 /*yield*/, (0, auth_1.signOut)(auth)];
|
|
354
|
-
case 1:
|
|
355
|
-
_a.sent();
|
|
356
|
-
return [3 /*break*/, 3];
|
|
357
|
-
case 2:
|
|
358
|
-
err_10 = _a.sent();
|
|
359
|
-
error = err_10;
|
|
360
|
-
throw new Error("Sign out failed: ".concat(error.message));
|
|
361
|
-
case 3: return [2 /*return*/];
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}); },
|
|
365
|
-
/**
|
|
366
|
-
* 🔄 Send password reset email
|
|
367
|
-
* @param auth - Firebase Auth instance
|
|
368
|
-
* @param email - User email
|
|
369
|
-
* @param actionCodeSettings - Optional action code settings for custom redirect
|
|
370
|
-
*/
|
|
371
|
-
resetPassword: function (auth, email, actionCodeSettings) { return __awaiter(void 0, void 0, void 0, function () {
|
|
372
|
-
var err_11, error;
|
|
373
|
-
return __generator(this, function (_a) {
|
|
374
|
-
switch (_a.label) {
|
|
375
|
-
case 0:
|
|
376
|
-
_a.trys.push([0, 2, , 3]);
|
|
377
|
-
return [4 /*yield*/, (0, auth_1.sendPasswordResetEmail)(auth, email, actionCodeSettings)];
|
|
378
|
-
case 1:
|
|
379
|
-
_a.sent();
|
|
380
|
-
return [3 /*break*/, 3];
|
|
381
|
-
case 2:
|
|
382
|
-
err_11 = _a.sent();
|
|
383
|
-
error = err_11;
|
|
384
|
-
throw new Error("Password reset failed: ".concat(error.message));
|
|
385
|
-
case 3: return [2 /*return*/];
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
}); },
|
|
389
|
-
/**
|
|
390
|
-
* ✉️ Send email verification
|
|
391
|
-
* @param auth - Firebase Auth instance
|
|
392
|
-
* @param actionCodeSettings - Optional action code settings for custom redirect
|
|
393
|
-
*/
|
|
394
|
-
sendVerificationEmail: function (auth, actionCodeSettings) { return __awaiter(void 0, void 0, void 0, function () {
|
|
395
|
-
var user, err_12, error;
|
|
396
|
-
return __generator(this, function (_a) {
|
|
397
|
-
switch (_a.label) {
|
|
398
|
-
case 0:
|
|
399
|
-
_a.trys.push([0, 2, , 3]);
|
|
400
|
-
user = auth.currentUser;
|
|
401
|
-
if (!user)
|
|
402
|
-
throw new Error('No user logged in');
|
|
403
|
-
return [4 /*yield*/, (0, auth_1.sendEmailVerification)(user, actionCodeSettings)];
|
|
404
|
-
case 1:
|
|
405
|
-
_a.sent();
|
|
406
|
-
return [3 /*break*/, 3];
|
|
407
|
-
case 2:
|
|
408
|
-
err_12 = _a.sent();
|
|
409
|
-
error = err_12;
|
|
410
|
-
throw new Error("Send verification email failed: ".concat(error.message));
|
|
411
|
-
case 3: return [2 /*return*/];
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
}); },
|
|
415
|
-
/**
|
|
416
|
-
* 🔑 Update user password
|
|
417
|
-
* @param auth - Firebase Auth instance
|
|
418
|
-
* @param newPassword - New password
|
|
419
|
-
*/
|
|
420
|
-
updatePassword: function (auth, newPassword) { return __awaiter(void 0, void 0, void 0, function () {
|
|
421
|
-
var user, err_13, error;
|
|
422
|
-
return __generator(this, function (_a) {
|
|
423
|
-
switch (_a.label) {
|
|
424
|
-
case 0:
|
|
425
|
-
_a.trys.push([0, 2, , 3]);
|
|
426
|
-
user = auth.currentUser;
|
|
427
|
-
if (!user)
|
|
428
|
-
throw new Error('No user logged in');
|
|
429
|
-
return [4 /*yield*/, (0, auth_1.updatePassword)(user, newPassword)];
|
|
430
|
-
case 1:
|
|
431
|
-
_a.sent();
|
|
432
|
-
return [3 /*break*/, 3];
|
|
433
|
-
case 2:
|
|
434
|
-
err_13 = _a.sent();
|
|
435
|
-
error = err_13;
|
|
436
|
-
throw new Error("Password update failed: ".concat(error.message));
|
|
437
|
-
case 3: return [2 /*return*/];
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}); },
|
|
441
|
-
/**
|
|
442
|
-
* 📧 Update user email
|
|
443
|
-
* @param auth - Firebase Auth instance
|
|
444
|
-
* @param newEmail - New email
|
|
445
|
-
*/
|
|
446
|
-
updateEmail: function (auth, newEmail) { return __awaiter(void 0, void 0, void 0, function () {
|
|
447
|
-
var user, err_14, error;
|
|
448
|
-
return __generator(this, function (_a) {
|
|
449
|
-
switch (_a.label) {
|
|
450
|
-
case 0:
|
|
451
|
-
_a.trys.push([0, 2, , 3]);
|
|
452
|
-
user = auth.currentUser;
|
|
453
|
-
if (!user)
|
|
454
|
-
throw new Error('No user logged in');
|
|
455
|
-
return [4 /*yield*/, (0, auth_1.updateEmail)(user, newEmail)];
|
|
456
|
-
case 1:
|
|
457
|
-
_a.sent();
|
|
458
|
-
return [3 /*break*/, 3];
|
|
459
|
-
case 2:
|
|
460
|
-
err_14 = _a.sent();
|
|
461
|
-
error = err_14;
|
|
462
|
-
throw new Error("Email update failed: ".concat(error.message));
|
|
463
|
-
case 3: return [2 /*return*/];
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}); },
|
|
467
|
-
/**
|
|
468
|
-
* 👤 Update user profile
|
|
469
|
-
* @param auth - Firebase Auth instance
|
|
470
|
-
* @param displayName - Display name
|
|
471
|
-
* @param photoURL - Photo URL
|
|
472
|
-
*/
|
|
473
|
-
updateProfile: function (auth, displayName, photoURL) { return __awaiter(void 0, void 0, void 0, function () {
|
|
474
|
-
var user, err_15, error;
|
|
475
|
-
return __generator(this, function (_a) {
|
|
476
|
-
switch (_a.label) {
|
|
477
|
-
case 0:
|
|
478
|
-
_a.trys.push([0, 2, , 3]);
|
|
479
|
-
user = auth.currentUser;
|
|
480
|
-
if (!user)
|
|
481
|
-
throw new Error('No user logged in');
|
|
482
|
-
return [4 /*yield*/, (0, auth_1.updateProfile)(user, {
|
|
483
|
-
displayName: displayName || null,
|
|
484
|
-
photoURL: photoURL || null
|
|
485
|
-
})];
|
|
486
|
-
case 1:
|
|
487
|
-
_a.sent();
|
|
488
|
-
return [3 /*break*/, 3];
|
|
489
|
-
case 2:
|
|
490
|
-
err_15 = _a.sent();
|
|
491
|
-
error = err_15;
|
|
492
|
-
throw new Error("Profile update failed: ".concat(error.message));
|
|
493
|
-
case 3: return [2 /*return*/];
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
}); },
|
|
497
|
-
/**
|
|
498
|
-
* 🔐 Reauthenticate user (required before sensitive operations)
|
|
499
|
-
* @param auth - Firebase Auth instance
|
|
500
|
-
* @param password - Current password
|
|
501
|
-
*/
|
|
502
|
-
reauthenticate: function (auth, password) { return __awaiter(void 0, void 0, void 0, function () {
|
|
503
|
-
var user, credential, err_16, error;
|
|
504
|
-
return __generator(this, function (_a) {
|
|
505
|
-
switch (_a.label) {
|
|
506
|
-
case 0:
|
|
507
|
-
_a.trys.push([0, 2, , 3]);
|
|
508
|
-
user = auth.currentUser;
|
|
509
|
-
if (!user || !user.email)
|
|
510
|
-
throw new Error('No user logged in');
|
|
511
|
-
credential = auth_1.EmailAuthProvider.credential(user.email, password);
|
|
512
|
-
return [4 /*yield*/, (0, auth_1.reauthenticateWithCredential)(user, credential)];
|
|
513
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
514
|
-
case 2:
|
|
515
|
-
err_16 = _a.sent();
|
|
516
|
-
error = err_16;
|
|
517
|
-
throw new Error("Reauthentication failed: ".concat(error.message));
|
|
518
|
-
case 3: return [2 /*return*/];
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
}); },
|
|
522
|
-
/**
|
|
523
|
-
* ❌ Delete user account
|
|
524
|
-
* @param auth - Firebase Auth instance
|
|
525
|
-
*/
|
|
526
|
-
deleteAccount: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
527
|
-
var user, err_17, error;
|
|
528
|
-
return __generator(this, function (_a) {
|
|
529
|
-
switch (_a.label) {
|
|
530
|
-
case 0:
|
|
531
|
-
_a.trys.push([0, 2, , 3]);
|
|
532
|
-
user = auth.currentUser;
|
|
533
|
-
if (!user)
|
|
534
|
-
throw new Error('No user logged in');
|
|
535
|
-
return [4 /*yield*/, (0, auth_1.deleteUser)(user)];
|
|
536
|
-
case 1:
|
|
537
|
-
_a.sent();
|
|
538
|
-
return [3 /*break*/, 3];
|
|
539
|
-
case 2:
|
|
540
|
-
err_17 = _a.sent();
|
|
541
|
-
error = err_17;
|
|
542
|
-
throw new Error("Account deletion failed: ".concat(error.message));
|
|
543
|
-
case 3: return [2 /*return*/];
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
}); },
|
|
547
|
-
/**
|
|
548
|
-
* 👁️ Listen to auth state changes
|
|
549
|
-
* @param auth - Firebase Auth instance
|
|
550
|
-
* @param callback - Callback function that receives user or null
|
|
551
|
-
* @returns Unsubscribe function
|
|
552
|
-
*/
|
|
553
|
-
onAuthStateChanged: function (auth, callback) {
|
|
554
|
-
return (0, auth_1.onAuthStateChanged)(auth, callback);
|
|
555
|
-
},
|
|
556
|
-
/**
|
|
557
|
-
* 🔍 Get current user
|
|
558
|
-
* @param auth - Firebase Auth instance
|
|
559
|
-
* @returns Current user or null
|
|
560
|
-
*/
|
|
561
|
-
getCurrentUser: function (auth) {
|
|
562
|
-
return auth.currentUser;
|
|
563
|
-
},
|
|
564
|
-
/**
|
|
565
|
-
* 🔍 Check if email exists
|
|
566
|
-
* @param auth - Firebase Auth instance
|
|
567
|
-
* @param email - Email to check
|
|
568
|
-
* @returns Array of sign-in methods for the email
|
|
569
|
-
*/
|
|
570
|
-
checkEmailExists: function (auth, email) { return __awaiter(void 0, void 0, void 0, function () {
|
|
571
|
-
var err_18, error;
|
|
572
|
-
return __generator(this, function (_a) {
|
|
573
|
-
switch (_a.label) {
|
|
574
|
-
case 0:
|
|
575
|
-
_a.trys.push([0, 2, , 3]);
|
|
576
|
-
return [4 /*yield*/, (0, auth_1.fetchSignInMethodsForEmail)(auth, email)];
|
|
577
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
578
|
-
case 2:
|
|
579
|
-
err_18 = _a.sent();
|
|
580
|
-
error = err_18;
|
|
581
|
-
throw new Error("Email check failed: ".concat(error.message));
|
|
582
|
-
case 3: return [2 /*return*/];
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
}); },
|
|
586
|
-
/**
|
|
587
|
-
* ✅ Apply action code (email verification, password reset)
|
|
588
|
-
* @param auth - Firebase Auth instance
|
|
589
|
-
* @param code - Action code from email link
|
|
590
|
-
*/
|
|
591
|
-
applyActionCode: function (auth, code) { return __awaiter(void 0, void 0, void 0, function () {
|
|
592
|
-
var err_19, error;
|
|
593
|
-
return __generator(this, function (_a) {
|
|
594
|
-
switch (_a.label) {
|
|
595
|
-
case 0:
|
|
596
|
-
_a.trys.push([0, 2, , 3]);
|
|
597
|
-
return [4 /*yield*/, (0, auth_1.applyActionCode)(auth, code)];
|
|
598
|
-
case 1:
|
|
599
|
-
_a.sent();
|
|
600
|
-
return [3 /*break*/, 3];
|
|
601
|
-
case 2:
|
|
602
|
-
err_19 = _a.sent();
|
|
603
|
-
error = err_19;
|
|
604
|
-
throw new Error("Apply action code failed: ".concat(error.message));
|
|
605
|
-
case 3: return [2 /*return*/];
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
}); },
|
|
609
|
-
/**
|
|
610
|
-
* 🔍 Verify password reset code
|
|
611
|
-
* @param auth - Firebase Auth instance
|
|
612
|
-
* @param code - Password reset code
|
|
613
|
-
* @returns Email associated with the code
|
|
614
|
-
*/
|
|
615
|
-
verifyPasswordResetCode: function (auth, code) { return __awaiter(void 0, void 0, void 0, function () {
|
|
616
|
-
var err_20, error;
|
|
617
|
-
return __generator(this, function (_a) {
|
|
618
|
-
switch (_a.label) {
|
|
619
|
-
case 0:
|
|
620
|
-
_a.trys.push([0, 2, , 3]);
|
|
621
|
-
return [4 /*yield*/, (0, auth_1.verifyPasswordResetCode)(auth, code)];
|
|
622
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
623
|
-
case 2:
|
|
624
|
-
err_20 = _a.sent();
|
|
625
|
-
error = err_20;
|
|
626
|
-
throw new Error("Verify reset code failed: ".concat(error.message));
|
|
627
|
-
case 3: return [2 /*return*/];
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
}); },
|
|
631
|
-
/**
|
|
632
|
-
* ✅ Confirm password reset
|
|
633
|
-
* @param auth - Firebase Auth instance
|
|
634
|
-
* @param code - Password reset code
|
|
635
|
-
* @param newPassword - New password
|
|
636
|
-
*/
|
|
637
|
-
confirmPasswordReset: function (auth, code, newPassword) { return __awaiter(void 0, void 0, void 0, function () {
|
|
638
|
-
var err_21, error;
|
|
639
|
-
return __generator(this, function (_a) {
|
|
640
|
-
switch (_a.label) {
|
|
641
|
-
case 0:
|
|
642
|
-
_a.trys.push([0, 2, , 3]);
|
|
643
|
-
return [4 /*yield*/, (0, auth_1.confirmPasswordReset)(auth, code, newPassword)];
|
|
644
|
-
case 1:
|
|
645
|
-
_a.sent();
|
|
646
|
-
return [3 /*break*/, 3];
|
|
647
|
-
case 2:
|
|
648
|
-
err_21 = _a.sent();
|
|
649
|
-
error = err_21;
|
|
650
|
-
throw new Error("Confirm password reset failed: ".concat(error.message));
|
|
651
|
-
case 3: return [2 /*return*/];
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
}); },
|
|
655
|
-
/**
|
|
656
|
-
* 🔗 Link account with Google
|
|
657
|
-
* @param auth - Firebase Auth instance
|
|
658
|
-
*/
|
|
659
|
-
linkWithGoogle: function (auth) { return __awaiter(void 0, void 0, void 0, function () {
|
|
660
|
-
var user, provider, err_22, error;
|
|
661
|
-
return __generator(this, function (_a) {
|
|
662
|
-
switch (_a.label) {
|
|
663
|
-
case 0:
|
|
664
|
-
_a.trys.push([0, 2, , 3]);
|
|
665
|
-
user = auth.currentUser;
|
|
666
|
-
if (!user)
|
|
667
|
-
throw new Error('No user logged in');
|
|
668
|
-
provider = new auth_1.GoogleAuthProvider();
|
|
669
|
-
return [4 /*yield*/, (0, auth_1.linkWithPopup)(user, provider)];
|
|
670
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
671
|
-
case 2:
|
|
672
|
-
err_22 = _a.sent();
|
|
673
|
-
error = err_22;
|
|
674
|
-
throw new Error("Link with Google failed: ".concat(error.message));
|
|
675
|
-
case 3: return [2 /*return*/];
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
}); },
|
|
679
|
-
/**
|
|
680
|
-
* 🔓 Unlink provider from account
|
|
681
|
-
* @param auth - Firebase Auth instance
|
|
682
|
-
* @param providerId - Provider ID to unlink (e.g., 'google.com', 'password')
|
|
683
|
-
*/
|
|
684
|
-
unlinkProvider: function (auth, providerId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
685
|
-
var user, err_23, error;
|
|
686
|
-
return __generator(this, function (_a) {
|
|
687
|
-
switch (_a.label) {
|
|
688
|
-
case 0:
|
|
689
|
-
_a.trys.push([0, 2, , 3]);
|
|
690
|
-
user = auth.currentUser;
|
|
691
|
-
if (!user)
|
|
692
|
-
throw new Error('No user logged in');
|
|
693
|
-
return [4 /*yield*/, (0, auth_1.unlink)(user, providerId)];
|
|
694
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
695
|
-
case 2:
|
|
696
|
-
err_23 = _a.sent();
|
|
697
|
-
error = err_23;
|
|
698
|
-
throw new Error("Unlink provider failed: ".concat(error.message));
|
|
699
|
-
case 3: return [2 /*return*/];
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
}); },
|
|
703
|
-
/**
|
|
704
|
-
* 📱 Get ID token (for backend verification)
|
|
705
|
-
* @param auth - Firebase Auth instance
|
|
706
|
-
* @param forceRefresh - Force token refresh
|
|
707
|
-
*/
|
|
708
|
-
getIdToken: function (auth_2) {
|
|
709
|
-
var args_1 = [];
|
|
710
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
711
|
-
args_1[_i - 1] = arguments[_i];
|
|
712
|
-
}
|
|
713
|
-
return __awaiter(void 0, __spreadArray([auth_2], args_1, true), void 0, function (auth, forceRefresh) {
|
|
714
|
-
var user, err_24, error;
|
|
715
|
-
if (forceRefresh === void 0) { forceRefresh = false; }
|
|
716
|
-
return __generator(this, function (_a) {
|
|
717
|
-
switch (_a.label) {
|
|
718
|
-
case 0:
|
|
719
|
-
_a.trys.push([0, 2, , 3]);
|
|
720
|
-
user = auth.currentUser;
|
|
721
|
-
if (!user)
|
|
722
|
-
throw new Error('No user logged in');
|
|
723
|
-
return [4 /*yield*/, user.getIdToken(forceRefresh)];
|
|
724
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
725
|
-
case 2:
|
|
726
|
-
err_24 = _a.sent();
|
|
727
|
-
error = err_24;
|
|
728
|
-
throw new Error("Get ID token failed: ".concat(error.message));
|
|
729
|
-
case 3: return [2 /*return*/];
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
// Export common error codes for error handling
|
|
736
|
-
exports.AuthErrorCodes = {
|
|
737
|
-
EMAIL_EXISTS: 'auth/email-already-in-use',
|
|
738
|
-
INVALID_EMAIL: 'auth/invalid-email',
|
|
739
|
-
WEAK_PASSWORD: 'auth/weak-password',
|
|
740
|
-
USER_NOT_FOUND: 'auth/user-not-found',
|
|
741
|
-
WRONG_PASSWORD: 'auth/wrong-password',
|
|
742
|
-
TOO_MANY_REQUESTS: 'auth/too-many-requests',
|
|
743
|
-
NETWORK_ERROR: 'auth/network-request-failed',
|
|
744
|
-
POPUP_CLOSED: 'auth/popup-closed-by-user',
|
|
745
|
-
REQUIRES_RECENT_LOGIN: 'auth/requires-recent-login'
|
|
746
|
-
};
|