@edgedev/firebase 1.9.16 → 1.9.17
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/edgeFirebase.ts +16 -6
- package/package.json +1 -1
package/edgeFirebase.ts
CHANGED
|
@@ -246,10 +246,6 @@ export const EdgeFirebase = class {
|
|
|
246
246
|
|
|
247
247
|
private functions = null;
|
|
248
248
|
|
|
249
|
-
public createRecaptchaVerifier = (containerId, parameters = { size: 'invisible' }) => {
|
|
250
|
-
return new RecaptchaVerifier(containerId, parameters, this.auth);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
249
|
public runFunction = async (functionName: string, data: Record<string, unknown>) => {
|
|
254
250
|
data.uid = this.user.uid;
|
|
255
251
|
const callable = httpsCallable(this.functions, functionName);
|
|
@@ -422,6 +418,8 @@ export const EdgeFirebase = class {
|
|
|
422
418
|
|
|
423
419
|
private setOnAuthStateChanged = (): void => {
|
|
424
420
|
onAuthStateChanged(this.auth, (userAuth) => {
|
|
421
|
+
const oldDiv = document.getElementById("recaptcha-container");
|
|
422
|
+
if (oldDiv) oldDiv.remove();
|
|
425
423
|
if (userAuth) {
|
|
426
424
|
this.user.loggingIn = true;
|
|
427
425
|
this.user.email = userAuth.email;
|
|
@@ -444,7 +442,10 @@ export const EdgeFirebase = class {
|
|
|
444
442
|
};
|
|
445
443
|
|
|
446
444
|
public logInWithPhone = async (confirmationResult: ConfirmationResult, phoneCode: string): Promise<void> => {
|
|
445
|
+
const oldDiv = document.getElementById("recaptcha-container");
|
|
446
|
+
if (oldDiv) oldDiv.remove();
|
|
447
447
|
try {
|
|
448
|
+
console.log(confirmationResult)
|
|
448
449
|
const result = await confirmationResult.confirm(phoneCode);
|
|
449
450
|
if (!Object.prototype.hasOwnProperty.call(result, "user")) {
|
|
450
451
|
this.user.logInError = true;
|
|
@@ -459,11 +460,13 @@ export const EdgeFirebase = class {
|
|
|
459
460
|
this.user.logInError = true;
|
|
460
461
|
this.user.logInErrorMessage = "User does not exist";
|
|
461
462
|
this.logOut();
|
|
463
|
+
return;
|
|
462
464
|
}
|
|
463
465
|
} catch (error) {
|
|
464
466
|
this.user.logInError = true;
|
|
465
467
|
this.user.logInErrorMessage = error.message;
|
|
466
468
|
this.logOut();
|
|
469
|
+
return;
|
|
467
470
|
}
|
|
468
471
|
};
|
|
469
472
|
|
|
@@ -533,6 +536,9 @@ export const EdgeFirebase = class {
|
|
|
533
536
|
}
|
|
534
537
|
|
|
535
538
|
public sendPhoneCode = async (phone: string): Promise<any> => {
|
|
539
|
+
const oldDiv = document.getElementById("recaptcha-container");
|
|
540
|
+
if (oldDiv) oldDiv.remove();
|
|
541
|
+
|
|
536
542
|
const newDiv = document.createElement("div");
|
|
537
543
|
newDiv.setAttribute("id", "recaptcha-container");
|
|
538
544
|
document.body.appendChild(newDiv);
|
|
@@ -548,7 +554,10 @@ export const EdgeFirebase = class {
|
|
|
548
554
|
const confirmationResult = await signInWithPhoneNumber(this.auth, phone, recaptchaVerifier);
|
|
549
555
|
return confirmationResult
|
|
550
556
|
} catch (error) {
|
|
551
|
-
|
|
557
|
+
this.user.logInError = true;
|
|
558
|
+
this.user.logInErrorMessage = error.message;
|
|
559
|
+
this.logOut();
|
|
560
|
+
return false;
|
|
552
561
|
}
|
|
553
562
|
}
|
|
554
563
|
|
|
@@ -600,7 +609,8 @@ export const EdgeFirebase = class {
|
|
|
600
609
|
} else if (authProvider === "microsoft") {
|
|
601
610
|
response = await this.registerUserWithMicrosoft(providerScopes);
|
|
602
611
|
} else if (authProvider === "phone") {
|
|
603
|
-
|
|
612
|
+
const oldDiv = document.getElementById("recaptcha-container");
|
|
613
|
+
if (oldDiv) oldDiv.remove();
|
|
604
614
|
try {
|
|
605
615
|
response = await userRegister.confirmationResult.confirm(userRegister.phoneCode);
|
|
606
616
|
} catch (error) {
|