@firebase/auth 1.7.9-canary.aa6db78eb → 1.7.9-canary.b942e9e6e

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 (148) hide show
  1. package/README.md +32 -1
  2. package/dist/auth-public.d.ts +22 -10
  3. package/dist/auth.d.ts +22 -10
  4. package/dist/browser-cjs/{index-8c4960c5.js → index-c1e3d4f9.js} +392 -175
  5. package/dist/browser-cjs/index-c1e3d4f9.js.map +1 -0
  6. package/dist/browser-cjs/index.js +1 -1
  7. package/dist/browser-cjs/internal.js +1 -1
  8. package/dist/browser-cjs/src/api/account_management/mfa.d.ts +5 -1
  9. package/dist/browser-cjs/src/api/authentication/mfa.d.ts +5 -1
  10. package/dist/browser-cjs/src/api/authentication/sms.d.ts +5 -1
  11. package/dist/browser-cjs/src/api/index.d.ts +7 -3
  12. package/dist/browser-cjs/src/platform_browser/providers/phone.d.ts +7 -5
  13. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  14. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  15. package/dist/browser-cjs/src/platform_browser/strategies/phone.d.ts +10 -6
  16. package/dist/browser-cjs/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  17. package/dist/cordova/auth-cordova-public.d.ts +7 -0
  18. package/dist/cordova/auth-cordova.d.ts +7 -0
  19. package/dist/cordova/index.js +2 -2
  20. package/dist/cordova/internal.js +168 -177
  21. package/dist/cordova/internal.js.map +1 -1
  22. package/dist/cordova/{popup_redirect-1e109c2a.js → popup_redirect-63b3580d.js} +285 -21
  23. package/dist/cordova/popup_redirect-63b3580d.js.map +1 -0
  24. package/dist/cordova/src/api/account_management/mfa.d.ts +5 -1
  25. package/dist/cordova/src/api/authentication/mfa.d.ts +5 -1
  26. package/dist/cordova/src/api/authentication/sms.d.ts +5 -1
  27. package/dist/cordova/src/api/index.d.ts +7 -3
  28. package/dist/cordova/src/platform_browser/providers/phone.d.ts +7 -5
  29. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  30. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  31. package/dist/cordova/src/platform_browser/strategies/phone.d.ts +10 -6
  32. package/dist/cordova/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  33. package/dist/esm2017/{index-6cb7b51a.js → index-c8d513e3.js} +392 -175
  34. package/dist/esm2017/index-c8d513e3.js.map +1 -0
  35. package/dist/esm2017/index.js +1 -1
  36. package/dist/esm2017/internal.js +2 -2
  37. package/dist/esm2017/src/api/account_management/mfa.d.ts +5 -1
  38. package/dist/esm2017/src/api/authentication/mfa.d.ts +5 -1
  39. package/dist/esm2017/src/api/authentication/sms.d.ts +5 -1
  40. package/dist/esm2017/src/api/index.d.ts +7 -3
  41. package/dist/esm2017/src/platform_browser/providers/phone.d.ts +7 -5
  42. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  43. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  44. package/dist/esm2017/src/platform_browser/strategies/phone.d.ts +10 -6
  45. package/dist/esm2017/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  46. package/dist/esm5/{index-262b3f24.js → index-82b3e33f.js} +450 -195
  47. package/dist/esm5/index-82b3e33f.js.map +1 -0
  48. package/dist/esm5/index.js +1 -1
  49. package/dist/esm5/internal.js +2 -2
  50. package/dist/esm5/src/api/account_management/mfa.d.ts +5 -1
  51. package/dist/esm5/src/api/authentication/mfa.d.ts +5 -1
  52. package/dist/esm5/src/api/authentication/sms.d.ts +5 -1
  53. package/dist/esm5/src/api/index.d.ts +7 -3
  54. package/dist/esm5/src/platform_browser/providers/phone.d.ts +7 -5
  55. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  56. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  57. package/dist/esm5/src/platform_browser/strategies/phone.d.ts +10 -6
  58. package/dist/esm5/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  59. package/dist/index.webworker.esm5.js +163 -19
  60. package/dist/index.webworker.esm5.js.map +1 -1
  61. package/dist/node/index.js +1 -1
  62. package/dist/node/internal.js +1 -1
  63. package/dist/node/src/api/account_management/mfa.d.ts +5 -1
  64. package/dist/node/src/api/authentication/mfa.d.ts +5 -1
  65. package/dist/node/src/api/authentication/sms.d.ts +5 -1
  66. package/dist/node/src/api/index.d.ts +7 -3
  67. package/dist/node/src/platform_browser/providers/phone.d.ts +7 -5
  68. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  69. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  70. package/dist/node/src/platform_browser/strategies/phone.d.ts +10 -6
  71. package/dist/node/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  72. package/dist/node/{totp-617e4db6.js → totp-c9a669c7.js} +164 -20
  73. package/dist/node/totp-c9a669c7.js.map +1 -0
  74. package/dist/node-esm/index.js +1 -1
  75. package/dist/node-esm/internal.js +2 -2
  76. package/dist/node-esm/src/api/account_management/mfa.d.ts +5 -1
  77. package/dist/node-esm/src/api/authentication/mfa.d.ts +5 -1
  78. package/dist/node-esm/src/api/authentication/sms.d.ts +5 -1
  79. package/dist/node-esm/src/api/index.d.ts +7 -3
  80. package/dist/node-esm/src/platform_browser/providers/phone.d.ts +7 -5
  81. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  82. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  83. package/dist/node-esm/src/platform_browser/strategies/phone.d.ts +10 -6
  84. package/dist/node-esm/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  85. package/dist/node-esm/{totp-98ba6f1f.js → totp-9698d31a.js} +168 -30
  86. package/dist/node-esm/totp-9698d31a.js.map +1 -0
  87. package/dist/rn/{index-198b1e87.js → index-dd6cc9b0.js} +450 -195
  88. package/dist/rn/index-dd6cc9b0.js.map +1 -0
  89. package/dist/rn/index.js +1 -1
  90. package/dist/rn/internal.js +1 -1
  91. package/dist/rn/src/api/account_management/mfa.d.ts +5 -1
  92. package/dist/rn/src/api/authentication/mfa.d.ts +5 -1
  93. package/dist/rn/src/api/authentication/sms.d.ts +5 -1
  94. package/dist/rn/src/api/index.d.ts +7 -3
  95. package/dist/rn/src/platform_browser/providers/phone.d.ts +7 -5
  96. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  97. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  98. package/dist/rn/src/platform_browser/strategies/phone.d.ts +10 -6
  99. package/dist/rn/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  100. package/dist/src/api/account_management/mfa.d.ts +5 -1
  101. package/dist/src/api/authentication/mfa.d.ts +5 -1
  102. package/dist/src/api/authentication/sms.d.ts +5 -1
  103. package/dist/src/api/index.d.ts +7 -3
  104. package/dist/src/platform_browser/providers/phone.d.ts +7 -5
  105. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  106. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  107. package/dist/src/platform_browser/strategies/phone.d.ts +10 -6
  108. package/dist/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  109. package/dist/web-extension-cjs/index.js +1 -1
  110. package/dist/web-extension-cjs/internal.js +115 -147
  111. package/dist/web-extension-cjs/internal.js.map +1 -1
  112. package/dist/web-extension-cjs/{register-0aa8e295.js → register-1a706c5a.js} +283 -30
  113. package/dist/web-extension-cjs/register-1a706c5a.js.map +1 -0
  114. package/dist/web-extension-cjs/src/api/account_management/mfa.d.ts +5 -1
  115. package/dist/web-extension-cjs/src/api/authentication/mfa.d.ts +5 -1
  116. package/dist/web-extension-cjs/src/api/authentication/sms.d.ts +5 -1
  117. package/dist/web-extension-cjs/src/api/index.d.ts +7 -3
  118. package/dist/web-extension-cjs/src/platform_browser/providers/phone.d.ts +7 -5
  119. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  120. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  121. package/dist/web-extension-cjs/src/platform_browser/strategies/phone.d.ts +10 -6
  122. package/dist/web-extension-cjs/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  123. package/dist/web-extension-esm2017/auth-web-extension-public.d.ts +7 -0
  124. package/dist/web-extension-esm2017/auth-web-extension.d.ts +7 -0
  125. package/dist/web-extension-esm2017/index.js +2 -2
  126. package/dist/web-extension-esm2017/internal.js +115 -147
  127. package/dist/web-extension-esm2017/internal.js.map +1 -1
  128. package/dist/web-extension-esm2017/{register-68ef89ff.js → register-3c017834.js} +280 -31
  129. package/dist/web-extension-esm2017/register-3c017834.js.map +1 -0
  130. package/dist/web-extension-esm2017/src/api/account_management/mfa.d.ts +5 -1
  131. package/dist/web-extension-esm2017/src/api/authentication/mfa.d.ts +5 -1
  132. package/dist/web-extension-esm2017/src/api/authentication/sms.d.ts +5 -1
  133. package/dist/web-extension-esm2017/src/api/index.d.ts +7 -3
  134. package/dist/web-extension-esm2017/src/platform_browser/providers/phone.d.ts +7 -5
  135. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  136. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  137. package/dist/web-extension-esm2017/src/platform_browser/strategies/phone.d.ts +10 -6
  138. package/dist/web-extension-esm2017/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  139. package/package.json +6 -6
  140. package/dist/browser-cjs/index-8c4960c5.js.map +0 -1
  141. package/dist/cordova/popup_redirect-1e109c2a.js.map +0 -1
  142. package/dist/esm2017/index-6cb7b51a.js.map +0 -1
  143. package/dist/esm5/index-262b3f24.js.map +0 -1
  144. package/dist/node/totp-617e4db6.js.map +0 -1
  145. package/dist/node-esm/totp-98ba6f1f.js.map +0 -1
  146. package/dist/rn/index-198b1e87.js.map +0 -1
  147. package/dist/web-extension-cjs/register-0aa8e295.js.map +0 -1
  148. package/dist/web-extension-esm2017/register-68ef89ff.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { ai as _performApiRequest, aj as _addTidIfNecessary, ak as _assert, al as Delay, am as _window, an as isV2, ao as _createError, ap as _recaptchaV2ScriptUrl, aq as _loadJS, ar as _generateCallbackName, as as getRecaptchaParams, at as _isHttpOrHttps, au as _isWorker, av as _castAuth, M as signInWithCredential, aw as _serverAppCurrentUserOperationNotSupportedError, N as linkWithCredential, ax as _assertLinkedStatus, Q as reauthenticateWithCredential, ay as sendPhoneVerificationCode, az as startEnrollPhoneMfa, aA as _link, B as PhoneAuthCredential, aB as debugAssert, aC as _generateEventId, aD as AbstractPopupRedirectOperation, aE as _assertInstanceOf, aF as _withDefaultResolver, aG as FederatedAuthProvider, aH as _fail, aI as _getProjectConfig, aJ as _getCurrentUrl, aK as _gapiScriptUrl, aL as _emulatorUrl, aM as _isChromeIOS, aN as _isFirefox, aO as _isIOSStandalone, aP as _getRedirectUrl, aQ as _setWindowLocation, aR as _isMobileBrowser, aS as _isSafari, aT as _isIOS, f as browserSessionPersistence, aU as _getRedirectResult, aV as _overrideRedirectResult, aW as AuthEventManager, aX as debugFail, aY as finalizeEnrollPhoneMfa, aZ as finalizeEnrollTotpMfa, a_ as startEnrollTotpMfa, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, e as browserLocalPersistence, j as beforeAuthStateChanged, o as onIdTokenChanged, x as connectAuthEmulator, a$ as _setExternalJSProvider } from './popup_redirect-1e109c2a.js';
2
- export { A as ActionCodeOperation, a6 as ActionCodeURL, y as AuthCredential, w as AuthErrorCodes, b3 as AuthImpl, E as EmailAuthCredential, D as EmailAuthProvider, G as FacebookAuthProvider, F as FactorId, b5 as FetchProvider, I as GithubAuthProvider, H as GoogleAuthProvider, z as OAuthCredential, J as OAuthProvider, O as OperationType, B as PhoneAuthCredential, P as ProviderId, b6 as SAMLAuthCredential, K as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, b1 as UserImpl, ak as _assert, av as _castAuth, aH as _fail, aC as _generateEventId, b4 as _getClientVersion, b2 as _getInstance, aU as _getRedirectResult, aV as _overrideRedirectResult, b0 as _persistenceKeyName, W as applyActionCode, j as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, X as checkActionCode, V as confirmPasswordReset, x as connectAuthEmulator, d as cordovaPopupRedirectResolver, Z as createUserWithEmailAndPassword, q as debugErrorMap, p as deleteUser, a3 as fetchSignInMethodsForEmail, ae as getAdditionalUserInfo, ab as getIdToken, ac as getIdTokenResult, ag as getMultiFactorResolver, g as getRedirectResult, C as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, h as initializeRecaptchaConfig, a1 as isSignInWithEmailLink, N as linkWithCredential, b8 as linkWithRedirect, ah as multiFactor, k as onAuthStateChanged, o as onIdTokenChanged, a7 as parseActionCodeURL, t as prodErrorMap, Q as reauthenticateWithCredential, b9 as reauthenticateWithRedirect, af as reload, n as revokeAccessToken, a4 as sendEmailVerification, U as sendPasswordResetEmail, a0 as sendSignInLinkToEmail, s as setPersistence, L as signInAnonymously, M as signInWithCredential, R as signInWithCustomToken, $ as signInWithEmailAndPassword, a2 as signInWithEmailLink, b7 as signInWithRedirect, m as signOut, ad as unlink, l as updateCurrentUser, a9 as updateEmail, aa as updatePassword, a8 as updateProfile, u as useDeviceLanguage, v as validatePassword, a5 as verifyBeforeUpdateEmail, Y as verifyPasswordResetCode } from './popup_redirect-1e109c2a.js';
1
+ import { ai as _performApiRequest, aj as _addTidIfNecessary, ak as Delay, al as _window, am as _assert, an as isV2, ao as _createError, ap as _recaptchaV2ScriptUrl, aq as _loadJS, ar as MockReCaptcha, as as _generateCallbackName, at as getRecaptchaParams, au as _isHttpOrHttps, av as _isWorker, aw as _castAuth, M as signInWithCredential, ax as _serverAppCurrentUserOperationNotSupportedError, N as linkWithCredential, ay as _assertLinkedStatus, Q as reauthenticateWithCredential, az as handleRecaptchaFlow, aA as _initializeRecaptchaConfig, aB as _link, aC as sendPhoneVerificationCode, aD as FAKE_TOKEN, aE as startEnrollPhoneMfa, B as PhoneAuthCredential, aF as debugAssert, aG as _generateEventId, aH as AbstractPopupRedirectOperation, aI as _assertInstanceOf, aJ as _withDefaultResolver, aK as FederatedAuthProvider, aL as _fail, aM as _getProjectConfig, aN as _getCurrentUrl, aO as _gapiScriptUrl, aP as _emulatorUrl, aQ as _isChromeIOS, aR as _isFirefox, aS as _isIOSStandalone, aT as _getRedirectUrl, aU as _setWindowLocation, aV as _isMobileBrowser, aW as _isSafari, aX as _isIOS, f as browserSessionPersistence, aY as _getRedirectResult, aZ as _overrideRedirectResult, a_ as AuthEventManager, a$ as debugFail, b0 as finalizeEnrollPhoneMfa, b1 as finalizeEnrollTotpMfa, b2 as startEnrollTotpMfa, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, e as browserLocalPersistence, j as beforeAuthStateChanged, o as onIdTokenChanged, x as connectAuthEmulator, b3 as _setExternalJSProvider } from './popup_redirect-63b3580d.js';
2
+ export { A as ActionCodeOperation, a6 as ActionCodeURL, y as AuthCredential, w as AuthErrorCodes, b7 as AuthImpl, E as EmailAuthCredential, D as EmailAuthProvider, G as FacebookAuthProvider, F as FactorId, b9 as FetchProvider, I as GithubAuthProvider, H as GoogleAuthProvider, z as OAuthCredential, J as OAuthProvider, O as OperationType, B as PhoneAuthCredential, P as ProviderId, ba as SAMLAuthCredential, K as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, b5 as UserImpl, am as _assert, aw as _castAuth, aL as _fail, aG as _generateEventId, b8 as _getClientVersion, b6 as _getInstance, aY as _getRedirectResult, aZ as _overrideRedirectResult, b4 as _persistenceKeyName, W as applyActionCode, j as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, X as checkActionCode, V as confirmPasswordReset, x as connectAuthEmulator, d as cordovaPopupRedirectResolver, Z as createUserWithEmailAndPassword, q as debugErrorMap, p as deleteUser, a3 as fetchSignInMethodsForEmail, ae as getAdditionalUserInfo, ab as getIdToken, ac as getIdTokenResult, ag as getMultiFactorResolver, g as getRedirectResult, C as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, h as initializeRecaptchaConfig, a1 as isSignInWithEmailLink, N as linkWithCredential, bc as linkWithRedirect, ah as multiFactor, k as onAuthStateChanged, o as onIdTokenChanged, a7 as parseActionCodeURL, t as prodErrorMap, Q as reauthenticateWithCredential, bd as reauthenticateWithRedirect, af as reload, n as revokeAccessToken, a4 as sendEmailVerification, U as sendPasswordResetEmail, a0 as sendSignInLinkToEmail, s as setPersistence, L as signInAnonymously, M as signInWithCredential, R as signInWithCustomToken, $ as signInWithEmailAndPassword, a2 as signInWithEmailLink, bb as signInWithRedirect, m as signOut, ad as unlink, l as updateCurrentUser, a9 as updateEmail, aa as updatePassword, a8 as updateProfile, u as useDeviceLanguage, v as validatePassword, a5 as verifyBeforeUpdateEmail, Y as verifyPasswordResetCode } from './popup_redirect-63b3580d.js';
3
3
  import { __awaiter, __generator, __assign, __extends, __spreadArray } from 'tslib';
4
4
  import { querystring, getModularInstance, getUA, getExperimentalSetting, getDefaultEmulatorHost } from '@firebase/util';
5
5
  import { _isFirebaseServerApp, SDK_VERSION, getApp, _getProvider } from '@firebase/app';
@@ -32,143 +32,6 @@ function finalizeSignInTotpMfa(auth, request) {
32
32
  return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
33
33
  }
34
34
 
35
- /**
36
- * @license
37
- * Copyright 2020 Google LLC
38
- *
39
- * Licensed under the Apache License, Version 2.0 (the "License");
40
- * you may not use this file except in compliance with the License.
41
- * You may obtain a copy of the License at
42
- *
43
- * http://www.apache.org/licenses/LICENSE-2.0
44
- *
45
- * Unless required by applicable law or agreed to in writing, software
46
- * distributed under the License is distributed on an "AS IS" BASIS,
47
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
- * See the License for the specific language governing permissions and
49
- * limitations under the License.
50
- */
51
- var _SOLVE_TIME_MS = 500;
52
- var _EXPIRATION_TIME_MS = 60000;
53
- var _WIDGET_ID_START = 1000000000000;
54
- var MockReCaptcha = /** @class */ (function () {
55
- function MockReCaptcha(auth) {
56
- this.auth = auth;
57
- this.counter = _WIDGET_ID_START;
58
- this._widgets = new Map();
59
- }
60
- MockReCaptcha.prototype.render = function (container, parameters) {
61
- var id = this.counter;
62
- this._widgets.set(id, new MockWidget(container, this.auth.name, parameters || {}));
63
- this.counter++;
64
- return id;
65
- };
66
- MockReCaptcha.prototype.reset = function (optWidgetId) {
67
- var _a;
68
- var id = optWidgetId || _WIDGET_ID_START;
69
- void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.delete());
70
- this._widgets.delete(id);
71
- };
72
- MockReCaptcha.prototype.getResponse = function (optWidgetId) {
73
- var _a;
74
- var id = optWidgetId || _WIDGET_ID_START;
75
- return ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.getResponse()) || '';
76
- };
77
- MockReCaptcha.prototype.execute = function (optWidgetId) {
78
- var _a;
79
- return __awaiter(this, void 0, void 0, function () {
80
- var id;
81
- return __generator(this, function (_b) {
82
- id = optWidgetId || _WIDGET_ID_START;
83
- void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.execute());
84
- return [2 /*return*/, ''];
85
- });
86
- });
87
- };
88
- return MockReCaptcha;
89
- }());
90
- var MockWidget = /** @class */ (function () {
91
- function MockWidget(containerOrId, appName, params) {
92
- var _this = this;
93
- this.params = params;
94
- this.timerId = null;
95
- this.deleted = false;
96
- this.responseToken = null;
97
- this.clickHandler = function () {
98
- _this.execute();
99
- };
100
- var container = typeof containerOrId === 'string'
101
- ? document.getElementById(containerOrId)
102
- : containerOrId;
103
- _assert(container, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, { appName: appName });
104
- this.container = container;
105
- this.isVisible = this.params.size !== 'invisible';
106
- if (this.isVisible) {
107
- this.execute();
108
- }
109
- else {
110
- this.container.addEventListener('click', this.clickHandler);
111
- }
112
- }
113
- MockWidget.prototype.getResponse = function () {
114
- this.checkIfDeleted();
115
- return this.responseToken;
116
- };
117
- MockWidget.prototype.delete = function () {
118
- this.checkIfDeleted();
119
- this.deleted = true;
120
- if (this.timerId) {
121
- clearTimeout(this.timerId);
122
- this.timerId = null;
123
- }
124
- this.container.removeEventListener('click', this.clickHandler);
125
- };
126
- MockWidget.prototype.execute = function () {
127
- var _this = this;
128
- this.checkIfDeleted();
129
- if (this.timerId) {
130
- return;
131
- }
132
- this.timerId = window.setTimeout(function () {
133
- _this.responseToken = generateRandomAlphaNumericString(50);
134
- var _a = _this.params, callback = _a.callback, expiredCallback = _a["expired-callback"];
135
- if (callback) {
136
- try {
137
- callback(_this.responseToken);
138
- }
139
- catch (e) { }
140
- }
141
- _this.timerId = window.setTimeout(function () {
142
- _this.timerId = null;
143
- _this.responseToken = null;
144
- if (expiredCallback) {
145
- try {
146
- expiredCallback();
147
- }
148
- catch (e) { }
149
- }
150
- if (_this.isVisible) {
151
- _this.execute();
152
- }
153
- }, _EXPIRATION_TIME_MS);
154
- }, _SOLVE_TIME_MS);
155
- };
156
- MockWidget.prototype.checkIfDeleted = function () {
157
- if (this.deleted) {
158
- throw new Error('reCAPTCHA mock was already deleted!');
159
- }
160
- };
161
- return MockWidget;
162
- }());
163
- function generateRandomAlphaNumericString(len) {
164
- var chars = [];
165
- var allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
166
- for (var i = 0; i < len; i++) {
167
- chars.push(allowedChars.charAt(Math.floor(Math.random() * allowedChars.length)));
168
- }
169
- return chars.join('');
170
- }
171
-
172
35
  /**
173
36
  * @license
174
37
  * Copyright 2020 Google LLC
@@ -575,12 +438,15 @@ var ConfirmationResultImpl = /** @class */ (function () {
575
438
  * provides the code sent to their phone, call {@link ConfirmationResult.confirm}
576
439
  * with the code to sign the user in.
577
440
  *
578
- * For abuse prevention, this method also requires a {@link ApplicationVerifier}.
579
- * This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
441
+ * For abuse prevention, this method requires a {@link ApplicationVerifier}.
442
+ * This SDK includes an implementation based on reCAPTCHA v2, {@link RecaptchaVerifier}.
580
443
  * This function can work on other platforms that do not support the
581
444
  * {@link RecaptchaVerifier} (like React Native), but you need to use a
582
445
  * third-party {@link ApplicationVerifier} implementation.
583
446
  *
447
+ * If you've enabled project-level reCAPTCHA Enterprise bot protection in
448
+ * Enforce mode, you can omit the {@link ApplicationVerifier}.
449
+ *
584
450
  * This method does not work in a Node.js environment or with {@link Auth} instances created with a
585
451
  * {@link @firebase/app#FirebaseServerApp}.
586
452
  *
@@ -693,17 +559,29 @@ function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
693
559
  function _verifyPhoneNumber(auth, options, verifier) {
694
560
  var _a;
695
561
  return __awaiter(this, void 0, void 0, function () {
696
- var recaptchaToken, phoneInfoOptions, session, response, mfaEnrollmentId, response, sessionInfo;
562
+ var phoneInfoOptions, session, startPhoneMfaEnrollmentRequest, startEnrollPhoneMfaActionCallback, startPhoneMfaEnrollmentResponse, response, mfaEnrollmentId, startPhoneMfaSignInRequest, startSignInPhoneMfaActionCallback, startPhoneMfaSignInResponse, response, sendPhoneVerificationCodeRequest, sendPhoneVerificationCodeActionCallback, sendPhoneVerificationCodeResponse, response;
563
+ var _this = this;
697
564
  return __generator(this, function (_b) {
698
565
  switch (_b.label) {
699
- case 0: return [4 /*yield*/, verifier.verify()];
566
+ case 0:
567
+ if (!!auth._getRecaptchaConfig()) return [3 /*break*/, 4];
568
+ _b.label = 1;
700
569
  case 1:
701
- recaptchaToken = _b.sent();
702
- _b.label = 2;
570
+ _b.trys.push([1, 3, , 4]);
571
+ return [4 /*yield*/, _initializeRecaptchaConfig(auth)];
703
572
  case 2:
704
- _b.trys.push([2, , 10, 11]);
705
- _assert(typeof recaptchaToken === 'string', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
706
- _assert(verifier.type === RECAPTCHA_VERIFIER_TYPE, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
573
+ _b.sent();
574
+ return [3 /*break*/, 4];
575
+ case 3:
576
+ _b.sent();
577
+ // If an error occurs while fetching the config, there is no way to know the enablement state
578
+ // of Phone provider, so we proceed with recaptcha V2 verification.
579
+ // The error is likely "recaptchaKey undefined", as reCAPTCHA Enterprise is not
580
+ // enabled for any provider.
581
+ console.log('Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.');
582
+ return [3 /*break*/, 4];
583
+ case 4:
584
+ _b.trys.push([4, , 12, 13]);
707
585
  phoneInfoOptions = void 0;
708
586
  if (typeof options === 'string') {
709
587
  phoneInfoOptions = {
@@ -713,48 +591,106 @@ function _verifyPhoneNumber(auth, options, verifier) {
713
591
  else {
714
592
  phoneInfoOptions = options;
715
593
  }
716
- if (!('session' in phoneInfoOptions)) return [3 /*break*/, 7];
594
+ if (!('session' in phoneInfoOptions)) return [3 /*break*/, 9];
717
595
  session = phoneInfoOptions.session;
718
- if (!('phoneNumber' in phoneInfoOptions)) return [3 /*break*/, 4];
596
+ if (!('phoneNumber' in phoneInfoOptions)) return [3 /*break*/, 6];
719
597
  _assert(session.type === "enroll" /* MultiFactorSessionType.ENROLL */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
720
- return [4 /*yield*/, startEnrollPhoneMfa(auth, {
721
- idToken: session.credential,
722
- phoneEnrollmentInfo: {
723
- phoneNumber: phoneInfoOptions.phoneNumber,
724
- recaptchaToken: recaptchaToken
598
+ startPhoneMfaEnrollmentRequest = {
599
+ idToken: session.credential,
600
+ phoneEnrollmentInfo: {
601
+ phoneNumber: phoneInfoOptions.phoneNumber,
602
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
603
+ }
604
+ };
605
+ startEnrollPhoneMfaActionCallback = function (authInstance, request) { return __awaiter(_this, void 0, void 0, function () {
606
+ var requestWithRecaptchaV2;
607
+ return __generator(this, function (_a) {
608
+ switch (_a.label) {
609
+ case 0:
610
+ if (!(request.phoneEnrollmentInfo.captchaResponse === FAKE_TOKEN)) return [3 /*break*/, 2];
611
+ _assert((verifier === null || verifier === void 0 ? void 0 : verifier.type) === RECAPTCHA_VERIFIER_TYPE, authInstance, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
612
+ return [4 /*yield*/, injectRecaptchaV2Token(authInstance, request, verifier)];
613
+ case 1:
614
+ requestWithRecaptchaV2 = _a.sent();
615
+ return [2 /*return*/, startEnrollPhoneMfa(authInstance, requestWithRecaptchaV2)];
616
+ case 2: return [2 /*return*/, startEnrollPhoneMfa(authInstance, request)];
725
617
  }
618
+ });
619
+ }); };
620
+ startPhoneMfaEnrollmentResponse = handleRecaptchaFlow(auth, startPhoneMfaEnrollmentRequest, "mfaSmsEnrollment" /* RecaptchaActionName.MFA_SMS_ENROLLMENT */, startEnrollPhoneMfaActionCallback, "PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */);
621
+ return [4 /*yield*/, startPhoneMfaEnrollmentResponse.catch(function (error) {
622
+ return Promise.reject(error);
726
623
  })];
727
- case 3:
624
+ case 5:
728
625
  response = _b.sent();
729
626
  return [2 /*return*/, response.phoneSessionInfo.sessionInfo];
730
- case 4:
627
+ case 6:
731
628
  _assert(session.type === "signin" /* MultiFactorSessionType.SIGN_IN */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
732
629
  mfaEnrollmentId = ((_a = phoneInfoOptions.multiFactorHint) === null || _a === void 0 ? void 0 : _a.uid) ||
733
630
  phoneInfoOptions.multiFactorUid;
734
631
  _assert(mfaEnrollmentId, auth, "missing-multi-factor-info" /* AuthErrorCode.MISSING_MFA_INFO */);
735
- return [4 /*yield*/, startSignInPhoneMfa(auth, {
736
- mfaPendingCredential: session.credential,
737
- mfaEnrollmentId: mfaEnrollmentId,
738
- phoneSignInInfo: {
739
- recaptchaToken: recaptchaToken
632
+ startPhoneMfaSignInRequest = {
633
+ mfaPendingCredential: session.credential,
634
+ mfaEnrollmentId: mfaEnrollmentId,
635
+ phoneSignInInfo: {
636
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
637
+ }
638
+ };
639
+ startSignInPhoneMfaActionCallback = function (authInstance, request) { return __awaiter(_this, void 0, void 0, function () {
640
+ var requestWithRecaptchaV2;
641
+ return __generator(this, function (_a) {
642
+ switch (_a.label) {
643
+ case 0:
644
+ if (!(request.phoneSignInInfo.captchaResponse === FAKE_TOKEN)) return [3 /*break*/, 2];
645
+ _assert((verifier === null || verifier === void 0 ? void 0 : verifier.type) === RECAPTCHA_VERIFIER_TYPE, authInstance, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
646
+ return [4 /*yield*/, injectRecaptchaV2Token(authInstance, request, verifier)];
647
+ case 1:
648
+ requestWithRecaptchaV2 = _a.sent();
649
+ return [2 /*return*/, startSignInPhoneMfa(authInstance, requestWithRecaptchaV2)];
650
+ case 2: return [2 /*return*/, startSignInPhoneMfa(authInstance, request)];
740
651
  }
652
+ });
653
+ }); };
654
+ startPhoneMfaSignInResponse = handleRecaptchaFlow(auth, startPhoneMfaSignInRequest, "mfaSmsSignIn" /* RecaptchaActionName.MFA_SMS_SIGNIN */, startSignInPhoneMfaActionCallback, "PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */);
655
+ return [4 /*yield*/, startPhoneMfaSignInResponse.catch(function (error) {
656
+ return Promise.reject(error);
741
657
  })];
742
- case 5:
658
+ case 7:
743
659
  response = _b.sent();
744
660
  return [2 /*return*/, response.phoneResponseInfo.sessionInfo];
745
- case 6: return [3 /*break*/, 9];
746
- case 7: return [4 /*yield*/, sendPhoneVerificationCode(auth, {
661
+ case 8: return [3 /*break*/, 11];
662
+ case 9:
663
+ sendPhoneVerificationCodeRequest = {
747
664
  phoneNumber: phoneInfoOptions.phoneNumber,
748
- recaptchaToken: recaptchaToken
749
- })];
750
- case 8:
751
- sessionInfo = (_b.sent()).sessionInfo;
752
- return [2 /*return*/, sessionInfo];
753
- case 9: return [3 /*break*/, 11];
665
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
666
+ };
667
+ sendPhoneVerificationCodeActionCallback = function (authInstance, request) { return __awaiter(_this, void 0, void 0, function () {
668
+ var requestWithRecaptchaV2;
669
+ return __generator(this, function (_a) {
670
+ switch (_a.label) {
671
+ case 0:
672
+ if (!(request.captchaResponse === FAKE_TOKEN)) return [3 /*break*/, 2];
673
+ _assert((verifier === null || verifier === void 0 ? void 0 : verifier.type) === RECAPTCHA_VERIFIER_TYPE, authInstance, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
674
+ return [4 /*yield*/, injectRecaptchaV2Token(authInstance, request, verifier)];
675
+ case 1:
676
+ requestWithRecaptchaV2 = _a.sent();
677
+ return [2 /*return*/, sendPhoneVerificationCode(authInstance, requestWithRecaptchaV2)];
678
+ case 2: return [2 /*return*/, sendPhoneVerificationCode(authInstance, request)];
679
+ }
680
+ });
681
+ }); };
682
+ sendPhoneVerificationCodeResponse = handleRecaptchaFlow(auth, sendPhoneVerificationCodeRequest, "sendVerificationCode" /* RecaptchaActionName.SEND_VERIFICATION_CODE */, sendPhoneVerificationCodeActionCallback, "PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */);
683
+ return [4 /*yield*/, sendPhoneVerificationCodeResponse.catch(function (error) {
684
+ return Promise.reject(error);
685
+ })];
754
686
  case 10:
755
- verifier._reset();
687
+ response = _b.sent();
688
+ return [2 /*return*/, response.sessionInfo];
689
+ case 11: return [3 /*break*/, 13];
690
+ case 12:
691
+ verifier === null || verifier === void 0 ? void 0 : verifier._reset();
756
692
  return [7 /*endfinally*/];
757
- case 11: return [2 /*return*/];
693
+ case 13: return [2 /*return*/];
758
694
  }
759
695
  });
760
696
  });
@@ -799,6 +735,59 @@ function updatePhoneNumber(user, credential) {
799
735
  }
800
736
  });
801
737
  });
738
+ }
739
+ // Helper function that fetches and injects a reCAPTCHA v2 token into the request.
740
+ function injectRecaptchaV2Token(auth, request, recaptchaV2Verifier) {
741
+ return __awaiter(this, void 0, void 0, function () {
742
+ var recaptchaV2Token, newRequest, phoneNumber, captchaResponse, clientType, recaptchaVersion, captchaResponse, clientType, recaptchaVersion;
743
+ return __generator(this, function (_a) {
744
+ switch (_a.label) {
745
+ case 0:
746
+ _assert(recaptchaV2Verifier.type === RECAPTCHA_VERIFIER_TYPE, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
747
+ return [4 /*yield*/, recaptchaV2Verifier.verify()];
748
+ case 1:
749
+ recaptchaV2Token = _a.sent();
750
+ _assert(typeof recaptchaV2Token === 'string', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
751
+ newRequest = __assign({}, request);
752
+ if ('phoneEnrollmentInfo' in newRequest) {
753
+ phoneNumber = newRequest.phoneEnrollmentInfo.phoneNumber;
754
+ captchaResponse = newRequest.phoneEnrollmentInfo.captchaResponse;
755
+ clientType = newRequest
756
+ .phoneEnrollmentInfo.clientType;
757
+ recaptchaVersion = newRequest.phoneEnrollmentInfo.recaptchaVersion;
758
+ Object.assign(newRequest, {
759
+ 'phoneEnrollmentInfo': {
760
+ phoneNumber: phoneNumber,
761
+ recaptchaToken: recaptchaV2Token,
762
+ captchaResponse: captchaResponse,
763
+ clientType: clientType,
764
+ recaptchaVersion: recaptchaVersion
765
+ }
766
+ });
767
+ return [2 /*return*/, newRequest];
768
+ }
769
+ else if ('phoneSignInInfo' in newRequest) {
770
+ captchaResponse = newRequest.phoneSignInInfo.captchaResponse;
771
+ clientType = newRequest
772
+ .phoneSignInInfo.clientType;
773
+ recaptchaVersion = newRequest.phoneSignInInfo.recaptchaVersion;
774
+ Object.assign(newRequest, {
775
+ 'phoneSignInInfo': {
776
+ recaptchaToken: recaptchaV2Token,
777
+ captchaResponse: captchaResponse,
778
+ clientType: clientType,
779
+ recaptchaVersion: recaptchaVersion
780
+ }
781
+ });
782
+ return [2 /*return*/, newRequest];
783
+ }
784
+ else {
785
+ Object.assign(newRequest, { 'recaptchaToken': recaptchaV2Token });
786
+ return [2 /*return*/, newRequest];
787
+ }
788
+ }
789
+ });
790
+ });
802
791
  }
803
792
 
804
793
  /**
@@ -870,12 +859,14 @@ var PhoneAuthProvider = /** @class */ (function () {
870
859
  *
871
860
  * @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
872
861
  * E.164 format (e.g. +16505550101).
873
- * @param applicationVerifier - For abuse prevention, this method also requires a
874
- * {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
875
- * {@link RecaptchaVerifier}.
862
+ * @param applicationVerifier - An {@link ApplicationVerifier}, which prevents
863
+ * requests from unauthorized clients. This SDK includes an implementation
864
+ * based on reCAPTCHA v2, {@link RecaptchaVerifier}. If you've enabled
865
+ * reCAPTCHA Enterprise bot protection in Enforce mode, this parameter is
866
+ * optional; in all other configurations, the parameter is required.
876
867
  *
877
868
  * @returns A Promise for a verification ID that can be passed to
878
- * {@link PhoneAuthProvider.credential} to identify this flow..
869
+ * {@link PhoneAuthProvider.credential} to identify this flow.
879
870
  */
880
871
  PhoneAuthProvider.prototype.verifyPhoneNumber = function (phoneOptions, applicationVerifier) {
881
872
  return _verifyPhoneNumber(this.auth, phoneOptions, getModularInstance(applicationVerifier));