@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
@@ -32,5 +32,6 @@ import { signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect, getRe
32
32
  import { RecaptchaVerifier } from './src/platform_browser/recaptcha/recaptcha_verifier';
33
33
  import { browserPopupRedirectResolver } from './src/platform_browser/popup_redirect';
34
34
  import { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
35
+ import { TotpMultiFactorGenerator, TotpSecret } from './src/mfa/assertions/totp';
35
36
  import { getAuth } from './src/platform_browser';
36
- export { browserLocalPersistence, browserSessionPersistence, indexedDBLocalPersistence, PhoneAuthProvider, signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber, signInWithPopup, linkWithPopup, reauthenticateWithPopup, signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect, getRedirectResult, RecaptchaVerifier, browserPopupRedirectResolver, PhoneMultiFactorGenerator, getAuth };
37
+ export { browserLocalPersistence, browserSessionPersistence, indexedDBLocalPersistence, PhoneAuthProvider, signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber, signInWithPopup, linkWithPopup, reauthenticateWithPopup, signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect, getRedirectResult, RecaptchaVerifier, browserPopupRedirectResolver, PhoneMultiFactorGenerator, TotpMultiFactorGenerator, TotpSecret, getAuth };
package/dist/rn/index.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ReactNative = require('react-native');
6
6
  var app = require('@firebase/app');
7
- var phone = require('./phone-e7bf48a1.js');
7
+ var phone = require('./phone-588b1f48.js');
8
8
  var tslib = require('tslib');
9
9
  require('@firebase/util');
10
10
  require('@firebase/component');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var phone = require('./phone-e7bf48a1.js');
5
+ var phone = require('./phone-588b1f48.js');
6
6
  var tslib = require('tslib');
7
7
  var util = require('@firebase/util');
8
8
  var app = require('@firebase/app');
@@ -2885,6 +2885,179 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
2885
2885
  */
2886
2886
  var browserPopupRedirectResolver = BrowserPopupRedirectResolver;
2887
2887
 
2888
+ /**
2889
+ * Provider for generating a {@link TotpMultiFactorAssertion}.
2890
+ *
2891
+ * @public
2892
+ */
2893
+ var TotpMultiFactorGenerator = /** @class */ (function () {
2894
+ function TotpMultiFactorGenerator() {
2895
+ }
2896
+ /**
2897
+ * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
2898
+ * the TOTP (time-based one-time password) second factor.
2899
+ * This assertion is used to complete enrollment in TOTP second factor.
2900
+ *
2901
+ * @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
2902
+ * @param oneTimePassword One-time password from TOTP App.
2903
+ * @returns A {@link TotpMultiFactorAssertion} which can be used with
2904
+ * {@link MultiFactorUser.enroll}.
2905
+ */
2906
+ TotpMultiFactorGenerator.assertionForEnrollment = function (secret, oneTimePassword) {
2907
+ return TotpMultiFactorAssertionImpl._fromSecret(secret, oneTimePassword);
2908
+ };
2909
+ /**
2910
+ * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
2911
+ * This assertion is used to complete signIn with TOTP as the second factor.
2912
+ *
2913
+ * @param enrollmentId identifies the enrolled TOTP second factor.
2914
+ * @param oneTimePassword One-time password from TOTP App.
2915
+ * @returns A {@link TotpMultiFactorAssertion} which can be used with
2916
+ * {@link MultiFactorResolver.resolveSignIn}.
2917
+ */
2918
+ TotpMultiFactorGenerator.assertionForSignIn = function (enrollmentId, oneTimePassword) {
2919
+ return TotpMultiFactorAssertionImpl._fromEnrollmentId(enrollmentId, oneTimePassword);
2920
+ };
2921
+ /**
2922
+ * Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
2923
+ * Creates a TOTP secret as part of enrolling a TOTP second factor.
2924
+ * Used for generating a QR code URL or inputting into a TOTP app.
2925
+ * This method uses the auth instance corresponding to the user in the multiFactorSession.
2926
+ *
2927
+ * @param session The {@link MultiFactorSession} that the user is part of.
2928
+ * @returns A promise to {@link TotpSecret}.
2929
+ */
2930
+ TotpMultiFactorGenerator.generateSecret = function (session) {
2931
+ return tslib.__awaiter(this, void 0, void 0, function () {
2932
+ var mfaSession, response;
2933
+ return tslib.__generator(this, function (_a) {
2934
+ switch (_a.label) {
2935
+ case 0:
2936
+ mfaSession = session;
2937
+ phone._assert(typeof mfaSession.auth !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2938
+ return [4 /*yield*/, phone.startEnrollTotpMfa(mfaSession.auth, {
2939
+ idToken: mfaSession.credential,
2940
+ totpEnrollmentInfo: {}
2941
+ })];
2942
+ case 1:
2943
+ response = _a.sent();
2944
+ return [2 /*return*/, TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.auth)];
2945
+ }
2946
+ });
2947
+ });
2948
+ };
2949
+ /**
2950
+ * The identifier of the TOTP second factor: `totp`.
2951
+ */
2952
+ TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
2953
+ return TotpMultiFactorGenerator;
2954
+ }());
2955
+ var TotpMultiFactorAssertionImpl = /** @class */ (function (_super) {
2956
+ tslib.__extends(TotpMultiFactorAssertionImpl, _super);
2957
+ function TotpMultiFactorAssertionImpl(otp, enrollmentId, secret) {
2958
+ var _this = _super.call(this, "totp" /* FactorId.TOTP */) || this;
2959
+ _this.otp = otp;
2960
+ _this.enrollmentId = enrollmentId;
2961
+ _this.secret = secret;
2962
+ return _this;
2963
+ }
2964
+ /** @internal */
2965
+ TotpMultiFactorAssertionImpl._fromSecret = function (secret, otp) {
2966
+ return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
2967
+ };
2968
+ /** @internal */
2969
+ TotpMultiFactorAssertionImpl._fromEnrollmentId = function (enrollmentId, otp) {
2970
+ return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
2971
+ };
2972
+ /** @internal */
2973
+ TotpMultiFactorAssertionImpl.prototype._finalizeEnroll = function (auth, idToken, displayName) {
2974
+ return tslib.__awaiter(this, void 0, void 0, function () {
2975
+ return tslib.__generator(this, function (_a) {
2976
+ phone._assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
2977
+ return [2 /*return*/, phone.finalizeEnrollTotpMfa(auth, {
2978
+ idToken: idToken,
2979
+ displayName: displayName,
2980
+ totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
2981
+ })];
2982
+ });
2983
+ });
2984
+ };
2985
+ /** @internal */
2986
+ TotpMultiFactorAssertionImpl.prototype._finalizeSignIn = function (auth, mfaPendingCredential) {
2987
+ return tslib.__awaiter(this, void 0, void 0, function () {
2988
+ var totpVerificationInfo;
2989
+ return tslib.__generator(this, function (_a) {
2990
+ phone._assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
2991
+ totpVerificationInfo = { verificationCode: this.otp };
2992
+ return [2 /*return*/, phone.finalizeSignInTotpMfa(auth, {
2993
+ mfaPendingCredential: mfaPendingCredential,
2994
+ mfaEnrollmentId: this.enrollmentId,
2995
+ totpVerificationInfo: totpVerificationInfo
2996
+ })];
2997
+ });
2998
+ });
2999
+ };
3000
+ return TotpMultiFactorAssertionImpl;
3001
+ }(phone.MultiFactorAssertionImpl));
3002
+ /**
3003
+ * Provider for generating a {@link TotpMultiFactorAssertion}.
3004
+ *
3005
+ * Stores the shared secret key and other parameters to generate time-based OTPs.
3006
+ * Implements methods to retrieve the shared secret key and generate a QR code URL.
3007
+ * @public
3008
+ */
3009
+ var TotpSecret = /** @class */ (function () {
3010
+ // The public members are declared outside the constructor so the docs can be generated.
3011
+ function TotpSecret(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
3012
+ this.sessionInfo = sessionInfo;
3013
+ this.auth = auth;
3014
+ this.secretKey = secretKey;
3015
+ this.hashingAlgorithm = hashingAlgorithm;
3016
+ this.codeLength = codeLength;
3017
+ this.codeIntervalSeconds = codeIntervalSeconds;
3018
+ this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
3019
+ }
3020
+ /** @internal */
3021
+ TotpSecret._fromStartTotpMfaEnrollmentResponse = function (response, auth) {
3022
+ 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);
3023
+ };
3024
+ /** @internal */
3025
+ TotpSecret.prototype._makeTotpVerificationInfo = function (otp) {
3026
+ return { sessionInfo: this.sessionInfo, verificationCode: otp };
3027
+ };
3028
+ /**
3029
+ * Returns a QR code URL as described in
3030
+ * https://github.com/google/google-authenticator/wiki/Key-Uri-Format
3031
+ * This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
3032
+ * If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
3033
+ *
3034
+ * @param accountName the name of the account/app along with a user identifier.
3035
+ * @param issuer issuer of the TOTP (likely the app name).
3036
+ * @returns A QR code URL string.
3037
+ */
3038
+ TotpSecret.prototype.generateQrCodeUrl = function (accountName, issuer) {
3039
+ var _a;
3040
+ var useDefaults = false;
3041
+ if (_isEmptyString(accountName) || _isEmptyString(issuer)) {
3042
+ useDefaults = true;
3043
+ }
3044
+ if (useDefaults) {
3045
+ if (_isEmptyString(accountName)) {
3046
+ accountName = ((_a = this.auth.currentUser) === null || _a === void 0 ? void 0 : _a.email) || 'unknownuser';
3047
+ }
3048
+ if (_isEmptyString(issuer)) {
3049
+ issuer = this.auth.name;
3050
+ }
3051
+ }
3052
+ return "otpauth://totp/".concat(issuer, ":").concat(accountName, "?secret=").concat(this.secretKey, "&issuer=").concat(issuer, "&algorithm=").concat(this.hashingAlgorithm, "&digits=").concat(this.codeLength);
3053
+ };
3054
+ return TotpSecret;
3055
+ }());
3056
+ /** @internal */
3057
+ function _isEmptyString(input) {
3058
+ return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
3059
+ }
3060
+
2888
3061
  /**
2889
3062
  * @license
2890
3063
  * Copyright 2021 Google LLC
@@ -3729,6 +3902,8 @@ exports.useDeviceLanguage = phone.useDeviceLanguage;
3729
3902
  exports.verifyBeforeUpdateEmail = phone.verifyBeforeUpdateEmail;
3730
3903
  exports.verifyPasswordResetCode = phone.verifyPasswordResetCode;
3731
3904
  exports.AuthPopup = AuthPopup;
3905
+ exports.TotpMultiFactorGenerator = TotpMultiFactorGenerator;
3906
+ exports.TotpSecret = TotpSecret;
3732
3907
  exports._generateEventId = _generateEventId;
3733
3908
  exports._getRedirectResult = _getRedirectResult;
3734
3909
  exports._overrideRedirectResult = _overrideRedirectResult;