@firebase/auth 0.21.5 → 0.21.6-canary.45a55330e

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 (144) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +25 -0
  3. package/dist/auth-public.d.ts +135 -4
  4. package/dist/auth.d.ts +138 -4
  5. package/dist/browser-cjs/{index-ff477525.js → index-3e63d976.js} +180 -5
  6. package/dist/browser-cjs/index-3e63d976.js.map +1 -0
  7. package/dist/browser-cjs/index.d.ts +2 -1
  8. package/dist/browser-cjs/index.js +3 -1
  9. package/dist/browser-cjs/index.js.map +1 -1
  10. package/dist/browser-cjs/internal.js +3 -1
  11. package/dist/browser-cjs/internal.js.map +1 -1
  12. package/dist/browser-cjs/src/api/account_management/mfa.d.ts +38 -4
  13. package/dist/browser-cjs/src/api/authentication/mfa.d.ts +11 -0
  14. package/dist/browser-cjs/src/core/errors.d.ts +1 -0
  15. package/dist/browser-cjs/src/core/index.d.ts +1 -0
  16. package/dist/browser-cjs/src/mfa/assertions/totp.d.ts +124 -0
  17. package/dist/browser-cjs/src/mfa/assertions/totp.test.d.ts +17 -0
  18. package/dist/browser-cjs/src/mfa/mfa_info.d.ts +5 -1
  19. package/dist/browser-cjs/src/model/enum_maps.d.ts +1 -0
  20. package/dist/browser-cjs/src/model/public_types.d.ts +18 -1
  21. package/dist/browser-cjs/test/helpers/integration/helpers.d.ts +3 -0
  22. package/dist/browser-cjs/test/integration/flows/totp.test.d.ts +17 -0
  23. package/dist/cordova/index.d.ts +2 -1
  24. package/dist/cordova/index.js +2 -2
  25. package/dist/cordova/internal.js +179 -3
  26. package/dist/cordova/internal.js.map +1 -1
  27. package/dist/cordova/{popup_redirect-a4d3c436.js → popup_redirect-4dd66477.js} +31 -6
  28. package/dist/cordova/popup_redirect-4dd66477.js.map +1 -0
  29. package/dist/cordova/src/api/account_management/mfa.d.ts +38 -4
  30. package/dist/cordova/src/api/authentication/mfa.d.ts +11 -0
  31. package/dist/cordova/src/core/errors.d.ts +1 -0
  32. package/dist/cordova/src/core/index.d.ts +1 -0
  33. package/dist/cordova/src/mfa/assertions/totp.d.ts +124 -0
  34. package/dist/cordova/src/mfa/assertions/totp.test.d.ts +17 -0
  35. package/dist/cordova/src/mfa/mfa_info.d.ts +5 -1
  36. package/dist/cordova/src/model/enum_maps.d.ts +1 -0
  37. package/dist/cordova/src/model/public_types.d.ts +18 -1
  38. package/dist/cordova/test/helpers/integration/helpers.d.ts +3 -0
  39. package/dist/cordova/test/integration/flows/totp.test.d.ts +17 -0
  40. package/dist/esm2017/{index-3363a72a.js → index-c8153924.js} +179 -6
  41. package/dist/esm2017/index-c8153924.js.map +1 -0
  42. package/dist/esm2017/index.d.ts +2 -1
  43. package/dist/esm2017/index.js +1 -1
  44. package/dist/esm2017/internal.js +2 -2
  45. package/dist/esm2017/src/api/account_management/mfa.d.ts +38 -4
  46. package/dist/esm2017/src/api/authentication/mfa.d.ts +11 -0
  47. package/dist/esm2017/src/core/errors.d.ts +1 -0
  48. package/dist/esm2017/src/core/index.d.ts +1 -0
  49. package/dist/esm2017/src/mfa/assertions/totp.d.ts +124 -0
  50. package/dist/esm2017/src/mfa/assertions/totp.test.d.ts +17 -0
  51. package/dist/esm2017/src/mfa/mfa_info.d.ts +5 -1
  52. package/dist/esm2017/src/model/enum_maps.d.ts +1 -0
  53. package/dist/esm2017/src/model/public_types.d.ts +18 -1
  54. package/dist/esm2017/test/helpers/integration/helpers.d.ts +3 -0
  55. package/dist/esm2017/test/integration/flows/totp.test.d.ts +17 -0
  56. package/dist/esm5/{index-3f05dc7b.js → index-f3279380.js} +207 -6
  57. package/dist/esm5/index-f3279380.js.map +1 -0
  58. package/dist/esm5/index.d.ts +2 -1
  59. package/dist/esm5/index.js +1 -1
  60. package/dist/esm5/internal.js +2 -2
  61. package/dist/esm5/src/api/account_management/mfa.d.ts +38 -4
  62. package/dist/esm5/src/api/authentication/mfa.d.ts +11 -0
  63. package/dist/esm5/src/core/errors.d.ts +1 -0
  64. package/dist/esm5/src/core/index.d.ts +1 -0
  65. package/dist/esm5/src/mfa/assertions/totp.d.ts +124 -0
  66. package/dist/esm5/src/mfa/assertions/totp.test.d.ts +17 -0
  67. package/dist/esm5/src/mfa/mfa_info.d.ts +5 -1
  68. package/dist/esm5/src/model/enum_maps.d.ts +1 -0
  69. package/dist/esm5/src/model/public_types.d.ts +18 -1
  70. package/dist/esm5/test/helpers/integration/helpers.d.ts +3 -0
  71. package/dist/esm5/test/integration/flows/totp.test.d.ts +17 -0
  72. package/dist/index.d.ts +2 -1
  73. package/dist/index.webworker.esm5.js +23 -4
  74. package/dist/index.webworker.esm5.js.map +1 -1
  75. package/dist/node/index.d.ts +2 -1
  76. package/dist/node/index.js +83 -81
  77. package/dist/node/index.js.map +1 -1
  78. package/dist/node/internal.js +144 -142
  79. package/dist/node/internal.js.map +1 -1
  80. package/dist/node/src/api/account_management/mfa.d.ts +38 -4
  81. package/dist/node/src/api/authentication/mfa.d.ts +11 -0
  82. package/dist/node/src/core/errors.d.ts +1 -0
  83. package/dist/node/src/core/index.d.ts +1 -0
  84. package/dist/node/src/mfa/assertions/totp.d.ts +124 -0
  85. package/dist/node/src/mfa/assertions/totp.test.d.ts +17 -0
  86. package/dist/node/src/mfa/mfa_info.d.ts +5 -1
  87. package/dist/node/src/model/enum_maps.d.ts +1 -0
  88. package/dist/node/src/model/public_types.d.ts +18 -1
  89. package/dist/node/test/helpers/integration/helpers.d.ts +3 -0
  90. package/dist/node/test/integration/flows/totp.test.d.ts +17 -0
  91. package/dist/node/{index-45468d80.js → totp-9c98f1ff.js} +243 -6
  92. package/dist/node/totp-9c98f1ff.js.map +1 -0
  93. package/dist/node-esm/index.d.ts +2 -1
  94. package/dist/node-esm/index.js +2 -2
  95. package/dist/node-esm/internal.js +3 -3
  96. package/dist/node-esm/src/api/account_management/mfa.d.ts +38 -4
  97. package/dist/node-esm/src/api/authentication/mfa.d.ts +11 -0
  98. package/dist/node-esm/src/core/errors.d.ts +1 -0
  99. package/dist/node-esm/src/core/index.d.ts +1 -0
  100. package/dist/node-esm/src/mfa/assertions/totp.d.ts +124 -0
  101. package/dist/node-esm/src/mfa/assertions/totp.test.d.ts +17 -0
  102. package/dist/node-esm/src/mfa/mfa_info.d.ts +5 -1
  103. package/dist/node-esm/src/model/enum_maps.d.ts +1 -0
  104. package/dist/node-esm/src/model/public_types.d.ts +18 -1
  105. package/dist/node-esm/test/helpers/integration/helpers.d.ts +3 -0
  106. package/dist/node-esm/test/integration/flows/totp.test.d.ts +17 -0
  107. package/dist/node-esm/{index-1f9492de.js → totp-a3bfc07a.js} +213 -7
  108. package/dist/node-esm/totp-a3bfc07a.js.map +1 -0
  109. package/dist/rn/index.d.ts +2 -1
  110. package/dist/rn/index.js +1 -1
  111. package/dist/rn/internal.js +176 -1
  112. package/dist/rn/internal.js.map +1 -1
  113. package/dist/rn/{phone-e7bf48a1.js → phone-588b1f48.js} +37 -5
  114. package/dist/rn/phone-588b1f48.js.map +1 -0
  115. package/dist/rn/src/api/account_management/mfa.d.ts +38 -4
  116. package/dist/rn/src/api/authentication/mfa.d.ts +11 -0
  117. package/dist/rn/src/core/errors.d.ts +1 -0
  118. package/dist/rn/src/core/index.d.ts +1 -0
  119. package/dist/rn/src/mfa/assertions/totp.d.ts +124 -0
  120. package/dist/rn/src/mfa/assertions/totp.test.d.ts +17 -0
  121. package/dist/rn/src/mfa/mfa_info.d.ts +5 -1
  122. package/dist/rn/src/model/enum_maps.d.ts +1 -0
  123. package/dist/rn/src/model/public_types.d.ts +18 -1
  124. package/dist/rn/test/helpers/integration/helpers.d.ts +3 -0
  125. package/dist/rn/test/integration/flows/totp.test.d.ts +17 -0
  126. package/dist/src/api/account_management/mfa.d.ts +38 -4
  127. package/dist/src/api/authentication/mfa.d.ts +11 -0
  128. package/dist/src/core/errors.d.ts +1 -0
  129. package/dist/src/core/index.d.ts +1 -0
  130. package/dist/src/mfa/assertions/totp.d.ts +124 -0
  131. package/dist/src/mfa/assertions/totp.test.d.ts +17 -0
  132. package/dist/src/mfa/mfa_info.d.ts +5 -1
  133. package/dist/src/model/enum_maps.d.ts +1 -0
  134. package/dist/src/model/public_types.d.ts +18 -1
  135. package/dist/test/helpers/integration/helpers.d.ts +3 -0
  136. package/dist/test/integration/flows/totp.test.d.ts +17 -0
  137. package/package.json +10 -8
  138. package/dist/browser-cjs/index-ff477525.js.map +0 -1
  139. package/dist/cordova/popup_redirect-a4d3c436.js.map +0 -1
  140. package/dist/esm2017/index-3363a72a.js.map +0 -1
  141. package/dist/esm5/index-3f05dc7b.js.map +0 -1
  142. package/dist/node/index-45468d80.js.map +0 -1
  143. package/dist/node-esm/index-1f9492de.js.map +0 -1
  144. package/dist/rn/phone-e7bf48a1.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { getApp, _getProvider } from '@firebase/app';
2
- import { _ as _signInWithRedirect, a as _reauthenticateWithRedirect, b as _linkWithRedirect, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, d as cordovaPopupRedirectResolver } from './popup_redirect-a4d3c436.js';
3
- export { A as ActionCodeOperation, a3 as ActionCodeURL, v as AuthCredential, q as AuthErrorCodes, E as EmailAuthCredential, z as EmailAuthProvider, B as FacebookAuthProvider, F as FactorId, C as GithubAuthProvider, G as GoogleAuthProvider, w as OAuthCredential, D as OAuthProvider, O as OperationType, x as PhoneAuthCredential, P as ProviderId, H as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, R as applyActionCode, h as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, U as checkActionCode, Q as confirmPasswordReset, t as connectAuthEmulator, d as cordovaPopupRedirectResolver, W as createUserWithEmailAndPassword, n as debugErrorMap, m as deleteUser, a0 as fetchSignInMethodsForEmail, ab as getAdditionalUserInfo, a8 as getIdToken, a9 as getIdTokenResult, ad as getMultiFactorResolver, g as getRedirectResult, y as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, Z as isSignInWithEmailLink, K as linkWithCredential, ae as multiFactor, j as onAuthStateChanged, o as onIdTokenChanged, a4 as parseActionCodeURL, p as prodErrorMap, L as reauthenticateWithCredential, ac as reload, a1 as sendEmailVerification, N as sendPasswordResetEmail, Y as sendSignInLinkToEmail, s as setPersistence, I as signInAnonymously, J as signInWithCredential, M as signInWithCustomToken, X as signInWithEmailAndPassword, $ as signInWithEmailLink, l as signOut, aa as unlink, k as updateCurrentUser, a6 as updateEmail, a7 as updatePassword, a5 as updateProfile, u as useDeviceLanguage, a2 as verifyBeforeUpdateEmail, V as verifyPasswordResetCode } from './popup_redirect-a4d3c436.js';
2
+ import { _ as _signInWithRedirect, a as _reauthenticateWithRedirect, b as _linkWithRedirect, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, d as cordovaPopupRedirectResolver } from './popup_redirect-4dd66477.js';
3
+ export { A as ActionCodeOperation, a3 as ActionCodeURL, v as AuthCredential, q as AuthErrorCodes, E as EmailAuthCredential, z as EmailAuthProvider, B as FacebookAuthProvider, F as FactorId, C as GithubAuthProvider, G as GoogleAuthProvider, w as OAuthCredential, D as OAuthProvider, O as OperationType, x as PhoneAuthCredential, P as ProviderId, H as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, R as applyActionCode, h as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, U as checkActionCode, Q as confirmPasswordReset, t as connectAuthEmulator, d as cordovaPopupRedirectResolver, W as createUserWithEmailAndPassword, n as debugErrorMap, m as deleteUser, a0 as fetchSignInMethodsForEmail, ab as getAdditionalUserInfo, a8 as getIdToken, a9 as getIdTokenResult, ad as getMultiFactorResolver, g as getRedirectResult, y as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, Z as isSignInWithEmailLink, K as linkWithCredential, ae as multiFactor, j as onAuthStateChanged, o as onIdTokenChanged, a4 as parseActionCodeURL, p as prodErrorMap, L as reauthenticateWithCredential, ac as reload, a1 as sendEmailVerification, N as sendPasswordResetEmail, Y as sendSignInLinkToEmail, s as setPersistence, I as signInAnonymously, J as signInWithCredential, M as signInWithCustomToken, X as signInWithEmailAndPassword, $ as signInWithEmailLink, l as signOut, aa as unlink, k as updateCurrentUser, a6 as updateEmail, a7 as updatePassword, a5 as updateProfile, u as useDeviceLanguage, a2 as verifyBeforeUpdateEmail, V as verifyPasswordResetCode } from './popup_redirect-4dd66477.js';
4
4
  import 'tslib';
5
5
  import '@firebase/util';
6
6
  import '@firebase/component';
@@ -1,5 +1,5 @@
1
- import { af as _performApiRequest, ag as _addTidIfNecessary, ah as _createError, ai as _assert, aj as Delay, ak as _window, al as _isHttpOrHttps, am as _isWorker, an as _castAuth, J as signInWithCredential, K as linkWithCredential, ao as _assertLinkedStatus, L as reauthenticateWithCredential, ap as sendPhoneVerificationCode, aq as startEnrollPhoneMfa, ar as _link, x as PhoneAuthCredential, as as debugAssert, at as _generateEventId, au as AbstractPopupRedirectOperation, av as _assertInstanceOf, aw as _withDefaultResolver, ax as FederatedAuthProvider, ay as _fail, az as _getProjectConfig, aA as _getCurrentUrl, aB as _emulatorUrl, aC as _isChromeIOS, aD as _isFirefox, aE as _isIOSStandalone, aF as _getRedirectUrl, aG as _setWindowLocation, aH as _isMobileBrowser, aI as _isSafari, aJ as _isIOS, f as browserSessionPersistence, aK as _getRedirectResult, aL as _overrideRedirectResult, aM as AuthEventManager, aN as debugFail, aO as finalizeEnrollPhoneMfa, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, e as browserLocalPersistence, h as beforeAuthStateChanged, o as onIdTokenChanged, t as connectAuthEmulator } from './popup_redirect-a4d3c436.js';
2
- export { A as ActionCodeOperation, a3 as ActionCodeURL, v as AuthCredential, q as AuthErrorCodes, aS as AuthImpl, E as EmailAuthCredential, z as EmailAuthProvider, B as FacebookAuthProvider, F as FactorId, aU as FetchProvider, C as GithubAuthProvider, G as GoogleAuthProvider, w as OAuthCredential, D as OAuthProvider, O as OperationType, x as PhoneAuthCredential, P as ProviderId, aV as SAMLAuthCredential, H as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, aQ as UserImpl, ai as _assert, an as _castAuth, ay as _fail, at as _generateEventId, aT as _getClientVersion, aR as _getInstance, aK as _getRedirectResult, aL as _overrideRedirectResult, aP as _persistenceKeyName, R as applyActionCode, h as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, U as checkActionCode, Q as confirmPasswordReset, t as connectAuthEmulator, d as cordovaPopupRedirectResolver, W as createUserWithEmailAndPassword, n as debugErrorMap, m as deleteUser, a0 as fetchSignInMethodsForEmail, ab as getAdditionalUserInfo, a8 as getIdToken, a9 as getIdTokenResult, ad as getMultiFactorResolver, g as getRedirectResult, y as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, Z as isSignInWithEmailLink, K as linkWithCredential, aX as linkWithRedirect, ae as multiFactor, j as onAuthStateChanged, o as onIdTokenChanged, a4 as parseActionCodeURL, p as prodErrorMap, L as reauthenticateWithCredential, aY as reauthenticateWithRedirect, ac as reload, a1 as sendEmailVerification, N as sendPasswordResetEmail, Y as sendSignInLinkToEmail, s as setPersistence, I as signInAnonymously, J as signInWithCredential, M as signInWithCustomToken, X as signInWithEmailAndPassword, $ as signInWithEmailLink, aW as signInWithRedirect, l as signOut, aa as unlink, k as updateCurrentUser, a6 as updateEmail, a7 as updatePassword, a5 as updateProfile, u as useDeviceLanguage, a2 as verifyBeforeUpdateEmail, V as verifyPasswordResetCode } from './popup_redirect-a4d3c436.js';
1
+ import { af as _performApiRequest, ag as _addTidIfNecessary, ah as _createError, ai as _assert, aj as Delay, ak as _window, al as _isHttpOrHttps, am as _isWorker, an as _castAuth, J as signInWithCredential, K as linkWithCredential, ao as _assertLinkedStatus, L as reauthenticateWithCredential, ap as sendPhoneVerificationCode, aq as startEnrollPhoneMfa, ar as _link, x as PhoneAuthCredential, as as debugAssert, at as _generateEventId, au as AbstractPopupRedirectOperation, av as _assertInstanceOf, aw as _withDefaultResolver, ax as FederatedAuthProvider, ay as _fail, az as _getProjectConfig, aA as _getCurrentUrl, aB as _emulatorUrl, aC as _isChromeIOS, aD as _isFirefox, aE as _isIOSStandalone, aF as _getRedirectUrl, aG as _setWindowLocation, aH as _isMobileBrowser, aI as _isSafari, aJ as _isIOS, f as browserSessionPersistence, aK as _getRedirectResult, aL as _overrideRedirectResult, aM as AuthEventManager, aN as debugFail, aO as finalizeEnrollPhoneMfa, aP as finalizeEnrollTotpMfa, aQ as startEnrollTotpMfa, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, e as browserLocalPersistence, h as beforeAuthStateChanged, o as onIdTokenChanged, t as connectAuthEmulator } from './popup_redirect-4dd66477.js';
2
+ export { A as ActionCodeOperation, a3 as ActionCodeURL, v as AuthCredential, q as AuthErrorCodes, aU as AuthImpl, E as EmailAuthCredential, z as EmailAuthProvider, B as FacebookAuthProvider, F as FactorId, aW as FetchProvider, C as GithubAuthProvider, G as GoogleAuthProvider, w as OAuthCredential, D as OAuthProvider, O as OperationType, x as PhoneAuthCredential, P as ProviderId, aX as SAMLAuthCredential, H as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, aS as UserImpl, ai as _assert, an as _castAuth, ay as _fail, at as _generateEventId, aV as _getClientVersion, aT as _getInstance, aK as _getRedirectResult, aL as _overrideRedirectResult, aR as _persistenceKeyName, R as applyActionCode, h as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, U as checkActionCode, Q as confirmPasswordReset, t as connectAuthEmulator, d as cordovaPopupRedirectResolver, W as createUserWithEmailAndPassword, n as debugErrorMap, m as deleteUser, a0 as fetchSignInMethodsForEmail, ab as getAdditionalUserInfo, a8 as getIdToken, a9 as getIdTokenResult, ad as getMultiFactorResolver, g as getRedirectResult, y as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, Z as isSignInWithEmailLink, K as linkWithCredential, aZ as linkWithRedirect, ae as multiFactor, j as onAuthStateChanged, o as onIdTokenChanged, a4 as parseActionCodeURL, p as prodErrorMap, L as reauthenticateWithCredential, a_ as reauthenticateWithRedirect, ac as reload, a1 as sendEmailVerification, N as sendPasswordResetEmail, Y as sendSignInLinkToEmail, s as setPersistence, I as signInAnonymously, J as signInWithCredential, M as signInWithCustomToken, X as signInWithEmailAndPassword, $ as signInWithEmailLink, aY as signInWithRedirect, l as signOut, aa as unlink, k as updateCurrentUser, a6 as updateEmail, a7 as updatePassword, a5 as updateProfile, u as useDeviceLanguage, a2 as verifyBeforeUpdateEmail, V as verifyPasswordResetCode } from './popup_redirect-4dd66477.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 { SDK_VERSION, getApp, _getProvider } from '@firebase/app';
@@ -27,6 +27,9 @@ function startSignInPhoneMfa(auth, request) {
27
27
  }
28
28
  function finalizeSignInPhoneMfa(auth, request) {
29
29
  return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
30
+ }
31
+ function finalizeSignInTotpMfa(auth, request) {
32
+ return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
30
33
  }
31
34
 
32
35
  /**
@@ -1852,6 +1855,179 @@ var PhoneMultiFactorGenerator = /** @class */ (function () {
1852
1855
  return PhoneMultiFactorGenerator;
1853
1856
  }());
1854
1857
 
1858
+ /**
1859
+ * Provider for generating a {@link TotpMultiFactorAssertion}.
1860
+ *
1861
+ * @public
1862
+ */
1863
+ var TotpMultiFactorGenerator = /** @class */ (function () {
1864
+ function TotpMultiFactorGenerator() {
1865
+ }
1866
+ /**
1867
+ * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
1868
+ * the TOTP (time-based one-time password) second factor.
1869
+ * This assertion is used to complete enrollment in TOTP second factor.
1870
+ *
1871
+ * @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
1872
+ * @param oneTimePassword One-time password from TOTP App.
1873
+ * @returns A {@link TotpMultiFactorAssertion} which can be used with
1874
+ * {@link MultiFactorUser.enroll}.
1875
+ */
1876
+ TotpMultiFactorGenerator.assertionForEnrollment = function (secret, oneTimePassword) {
1877
+ return TotpMultiFactorAssertionImpl._fromSecret(secret, oneTimePassword);
1878
+ };
1879
+ /**
1880
+ * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
1881
+ * This assertion is used to complete signIn with TOTP as the second factor.
1882
+ *
1883
+ * @param enrollmentId identifies the enrolled TOTP second factor.
1884
+ * @param oneTimePassword One-time password from TOTP App.
1885
+ * @returns A {@link TotpMultiFactorAssertion} which can be used with
1886
+ * {@link MultiFactorResolver.resolveSignIn}.
1887
+ */
1888
+ TotpMultiFactorGenerator.assertionForSignIn = function (enrollmentId, oneTimePassword) {
1889
+ return TotpMultiFactorAssertionImpl._fromEnrollmentId(enrollmentId, oneTimePassword);
1890
+ };
1891
+ /**
1892
+ * Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
1893
+ * Creates a TOTP secret as part of enrolling a TOTP second factor.
1894
+ * Used for generating a QR code URL or inputting into a TOTP app.
1895
+ * This method uses the auth instance corresponding to the user in the multiFactorSession.
1896
+ *
1897
+ * @param session The {@link MultiFactorSession} that the user is part of.
1898
+ * @returns A promise to {@link TotpSecret}.
1899
+ */
1900
+ TotpMultiFactorGenerator.generateSecret = function (session) {
1901
+ return __awaiter(this, void 0, void 0, function () {
1902
+ var mfaSession, response;
1903
+ return __generator(this, function (_a) {
1904
+ switch (_a.label) {
1905
+ case 0:
1906
+ mfaSession = session;
1907
+ _assert(typeof mfaSession.auth !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1908
+ return [4 /*yield*/, startEnrollTotpMfa(mfaSession.auth, {
1909
+ idToken: mfaSession.credential,
1910
+ totpEnrollmentInfo: {}
1911
+ })];
1912
+ case 1:
1913
+ response = _a.sent();
1914
+ return [2 /*return*/, TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.auth)];
1915
+ }
1916
+ });
1917
+ });
1918
+ };
1919
+ /**
1920
+ * The identifier of the TOTP second factor: `totp`.
1921
+ */
1922
+ TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
1923
+ return TotpMultiFactorGenerator;
1924
+ }());
1925
+ var TotpMultiFactorAssertionImpl = /** @class */ (function (_super) {
1926
+ __extends(TotpMultiFactorAssertionImpl, _super);
1927
+ function TotpMultiFactorAssertionImpl(otp, enrollmentId, secret) {
1928
+ var _this = _super.call(this, "totp" /* FactorId.TOTP */) || this;
1929
+ _this.otp = otp;
1930
+ _this.enrollmentId = enrollmentId;
1931
+ _this.secret = secret;
1932
+ return _this;
1933
+ }
1934
+ /** @internal */
1935
+ TotpMultiFactorAssertionImpl._fromSecret = function (secret, otp) {
1936
+ return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
1937
+ };
1938
+ /** @internal */
1939
+ TotpMultiFactorAssertionImpl._fromEnrollmentId = function (enrollmentId, otp) {
1940
+ return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
1941
+ };
1942
+ /** @internal */
1943
+ TotpMultiFactorAssertionImpl.prototype._finalizeEnroll = function (auth, idToken, displayName) {
1944
+ return __awaiter(this, void 0, void 0, function () {
1945
+ return __generator(this, function (_a) {
1946
+ _assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
1947
+ return [2 /*return*/, finalizeEnrollTotpMfa(auth, {
1948
+ idToken: idToken,
1949
+ displayName: displayName,
1950
+ totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
1951
+ })];
1952
+ });
1953
+ });
1954
+ };
1955
+ /** @internal */
1956
+ TotpMultiFactorAssertionImpl.prototype._finalizeSignIn = function (auth, mfaPendingCredential) {
1957
+ return __awaiter(this, void 0, void 0, function () {
1958
+ var totpVerificationInfo;
1959
+ return __generator(this, function (_a) {
1960
+ _assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
1961
+ totpVerificationInfo = { verificationCode: this.otp };
1962
+ return [2 /*return*/, finalizeSignInTotpMfa(auth, {
1963
+ mfaPendingCredential: mfaPendingCredential,
1964
+ mfaEnrollmentId: this.enrollmentId,
1965
+ totpVerificationInfo: totpVerificationInfo
1966
+ })];
1967
+ });
1968
+ });
1969
+ };
1970
+ return TotpMultiFactorAssertionImpl;
1971
+ }(MultiFactorAssertionImpl));
1972
+ /**
1973
+ * Provider for generating a {@link TotpMultiFactorAssertion}.
1974
+ *
1975
+ * Stores the shared secret key and other parameters to generate time-based OTPs.
1976
+ * Implements methods to retrieve the shared secret key and generate a QR code URL.
1977
+ * @public
1978
+ */
1979
+ var TotpSecret = /** @class */ (function () {
1980
+ // The public members are declared outside the constructor so the docs can be generated.
1981
+ function TotpSecret(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
1982
+ this.sessionInfo = sessionInfo;
1983
+ this.auth = auth;
1984
+ this.secretKey = secretKey;
1985
+ this.hashingAlgorithm = hashingAlgorithm;
1986
+ this.codeLength = codeLength;
1987
+ this.codeIntervalSeconds = codeIntervalSeconds;
1988
+ this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
1989
+ }
1990
+ /** @internal */
1991
+ TotpSecret._fromStartTotpMfaEnrollmentResponse = function (response, auth) {
1992
+ return new TotpSecret(response.totpSessionInfo.sharedSecretKey, response.totpSessionInfo.hashingAlgorithm, response.totpSessionInfo.verificationCodeLength, response.totpSessionInfo.periodSec, new Date(response.totpSessionInfo.finalizeEnrollmentTime).toUTCString(), response.totpSessionInfo.sessionInfo, auth);
1993
+ };
1994
+ /** @internal */
1995
+ TotpSecret.prototype._makeTotpVerificationInfo = function (otp) {
1996
+ return { sessionInfo: this.sessionInfo, verificationCode: otp };
1997
+ };
1998
+ /**
1999
+ * Returns a QR code URL as described in
2000
+ * https://github.com/google/google-authenticator/wiki/Key-Uri-Format
2001
+ * This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
2002
+ * If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
2003
+ *
2004
+ * @param accountName the name of the account/app along with a user identifier.
2005
+ * @param issuer issuer of the TOTP (likely the app name).
2006
+ * @returns A QR code URL string.
2007
+ */
2008
+ TotpSecret.prototype.generateQrCodeUrl = function (accountName, issuer) {
2009
+ var _a;
2010
+ var useDefaults = false;
2011
+ if (_isEmptyString(accountName) || _isEmptyString(issuer)) {
2012
+ useDefaults = true;
2013
+ }
2014
+ if (useDefaults) {
2015
+ if (_isEmptyString(accountName)) {
2016
+ accountName = ((_a = this.auth.currentUser) === null || _a === void 0 ? void 0 : _a.email) || 'unknownuser';
2017
+ }
2018
+ if (_isEmptyString(issuer)) {
2019
+ issuer = this.auth.name;
2020
+ }
2021
+ }
2022
+ return "otpauth://totp/".concat(issuer, ":").concat(accountName, "?secret=").concat(this.secretKey, "&issuer=").concat(issuer, "&algorithm=").concat(this.hashingAlgorithm, "&digits=").concat(this.codeLength);
2023
+ };
2024
+ return TotpSecret;
2025
+ }());
2026
+ /** @internal */
2027
+ function _isEmptyString(input) {
2028
+ return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
2029
+ }
2030
+
1855
2031
  /**
1856
2032
  * @license
1857
2033
  * Copyright 2021 Google LLC
@@ -1969,5 +2145,5 @@ function addFrameworkForLogging(auth, framework) {
1969
2145
  _castAuth(auth)._logFramework(framework);
1970
2146
  }
1971
2147
 
1972
- export { AuthPopup, PhoneAuthProvider, PhoneMultiFactorGenerator, RecaptchaVerifier, addFrameworkForLogging, browserPopupRedirectResolver, getAuth, linkWithPhoneNumber, linkWithPopup, reauthenticateWithPhoneNumber, reauthenticateWithPopup, signInWithPhoneNumber, signInWithPopup, updatePhoneNumber };
2148
+ export { AuthPopup, PhoneAuthProvider, PhoneMultiFactorGenerator, RecaptchaVerifier, TotpMultiFactorGenerator, TotpSecret, addFrameworkForLogging, browserPopupRedirectResolver, getAuth, linkWithPhoneNumber, linkWithPopup, reauthenticateWithPhoneNumber, reauthenticateWithPopup, signInWithPhoneNumber, signInWithPopup, updatePhoneNumber };
1973
2149
  //# sourceMappingURL=internal.js.map