@firebase/auth 0.21.5 → 0.21.6-canary.a8d6499b1
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/CHANGELOG.md +8 -0
- package/README.md +25 -0
- package/dist/auth-public.d.ts +137 -4
- package/dist/auth.d.ts +149 -4
- package/dist/browser-cjs/{index-ff477525.js → index-a031a7c0.js} +180 -5
- package/dist/browser-cjs/index-a031a7c0.js.map +1 -0
- package/dist/browser-cjs/index.d.ts +2 -1
- package/dist/browser-cjs/index.js +3 -1
- package/dist/browser-cjs/index.js.map +1 -1
- package/dist/browser-cjs/internal.js +3 -1
- package/dist/browser-cjs/internal.js.map +1 -1
- package/dist/browser-cjs/src/api/account_management/mfa.d.ts +38 -4
- package/dist/browser-cjs/src/api/authentication/mfa.d.ts +11 -0
- package/dist/browser-cjs/src/core/errors.d.ts +1 -0
- package/dist/browser-cjs/src/core/index.d.ts +1 -0
- package/dist/browser-cjs/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/browser-cjs/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/browser-cjs/src/mfa/mfa_info.d.ts +5 -1
- package/dist/browser-cjs/src/model/enum_maps.d.ts +1 -0
- package/dist/browser-cjs/src/model/public_types.d.ts +18 -1
- package/dist/browser-cjs/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/browser-cjs/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/cordova/index.d.ts +2 -1
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal.js +179 -3
- package/dist/cordova/internal.js.map +1 -1
- package/dist/cordova/{popup_redirect-a4d3c436.js → popup_redirect-69cff576.js} +31 -6
- package/dist/cordova/popup_redirect-69cff576.js.map +1 -0
- package/dist/cordova/src/api/account_management/mfa.d.ts +38 -4
- package/dist/cordova/src/api/authentication/mfa.d.ts +11 -0
- package/dist/cordova/src/core/errors.d.ts +1 -0
- package/dist/cordova/src/core/index.d.ts +1 -0
- package/dist/cordova/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/cordova/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/cordova/src/mfa/mfa_info.d.ts +5 -1
- package/dist/cordova/src/model/enum_maps.d.ts +1 -0
- package/dist/cordova/src/model/public_types.d.ts +18 -1
- package/dist/cordova/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/cordova/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/esm2017/{index-3363a72a.js → index-33f309f3.js} +179 -6
- package/dist/esm2017/index-33f309f3.js.map +1 -0
- package/dist/esm2017/index.d.ts +2 -1
- package/dist/esm2017/index.js +1 -1
- package/dist/esm2017/internal.js +2 -2
- package/dist/esm2017/src/api/account_management/mfa.d.ts +38 -4
- package/dist/esm2017/src/api/authentication/mfa.d.ts +11 -0
- package/dist/esm2017/src/core/errors.d.ts +1 -0
- package/dist/esm2017/src/core/index.d.ts +1 -0
- package/dist/esm2017/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/esm2017/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/esm2017/src/mfa/mfa_info.d.ts +5 -1
- package/dist/esm2017/src/model/enum_maps.d.ts +1 -0
- package/dist/esm2017/src/model/public_types.d.ts +18 -1
- package/dist/esm2017/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/esm2017/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/esm5/{index-3f05dc7b.js → index-588c4d42.js} +207 -6
- package/dist/esm5/index-588c4d42.js.map +1 -0
- package/dist/esm5/index.d.ts +2 -1
- package/dist/esm5/index.js +1 -1
- package/dist/esm5/internal.js +2 -2
- package/dist/esm5/src/api/account_management/mfa.d.ts +38 -4
- package/dist/esm5/src/api/authentication/mfa.d.ts +11 -0
- package/dist/esm5/src/core/errors.d.ts +1 -0
- package/dist/esm5/src/core/index.d.ts +1 -0
- package/dist/esm5/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/esm5/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/esm5/src/mfa/mfa_info.d.ts +5 -1
- package/dist/esm5/src/model/enum_maps.d.ts +1 -0
- package/dist/esm5/src/model/public_types.d.ts +18 -1
- package/dist/esm5/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/esm5/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.webworker.esm5.js +23 -4
- package/dist/index.webworker.esm5.js.map +1 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.js +83 -81
- package/dist/node/index.js.map +1 -1
- package/dist/node/internal.js +144 -142
- package/dist/node/internal.js.map +1 -1
- package/dist/node/src/api/account_management/mfa.d.ts +38 -4
- package/dist/node/src/api/authentication/mfa.d.ts +11 -0
- package/dist/node/src/core/errors.d.ts +1 -0
- package/dist/node/src/core/index.d.ts +1 -0
- package/dist/node/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/node/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/node/src/mfa/mfa_info.d.ts +5 -1
- package/dist/node/src/model/enum_maps.d.ts +1 -0
- package/dist/node/src/model/public_types.d.ts +18 -1
- package/dist/node/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/node/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/node/{index-45468d80.js → totp-4f539e73.js} +243 -6
- package/dist/node/totp-4f539e73.js.map +1 -0
- package/dist/node-esm/index.d.ts +2 -1
- package/dist/node-esm/index.js +2 -2
- package/dist/node-esm/internal.js +3 -3
- package/dist/node-esm/src/api/account_management/mfa.d.ts +38 -4
- package/dist/node-esm/src/api/authentication/mfa.d.ts +11 -0
- package/dist/node-esm/src/core/errors.d.ts +1 -0
- package/dist/node-esm/src/core/index.d.ts +1 -0
- package/dist/node-esm/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/node-esm/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/node-esm/src/mfa/mfa_info.d.ts +5 -1
- package/dist/node-esm/src/model/enum_maps.d.ts +1 -0
- package/dist/node-esm/src/model/public_types.d.ts +18 -1
- package/dist/node-esm/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/node-esm/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/node-esm/{index-1f9492de.js → totp-aec70fa2.js} +213 -7
- package/dist/node-esm/totp-aec70fa2.js.map +1 -0
- package/dist/rn/index.d.ts +2 -1
- package/dist/rn/index.js +1 -1
- package/dist/rn/internal.js +176 -1
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/{phone-e7bf48a1.js → phone-a38a417c.js} +37 -5
- package/dist/rn/phone-a38a417c.js.map +1 -0
- package/dist/rn/src/api/account_management/mfa.d.ts +38 -4
- package/dist/rn/src/api/authentication/mfa.d.ts +11 -0
- package/dist/rn/src/core/errors.d.ts +1 -0
- package/dist/rn/src/core/index.d.ts +1 -0
- package/dist/rn/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/rn/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/rn/src/mfa/mfa_info.d.ts +5 -1
- package/dist/rn/src/model/enum_maps.d.ts +1 -0
- package/dist/rn/src/model/public_types.d.ts +18 -1
- package/dist/rn/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/rn/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/src/api/account_management/mfa.d.ts +38 -4
- package/dist/src/api/authentication/mfa.d.ts +11 -0
- package/dist/src/core/errors.d.ts +1 -0
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/src/mfa/mfa_info.d.ts +5 -1
- package/dist/src/model/enum_maps.d.ts +1 -0
- package/dist/src/model/public_types.d.ts +18 -1
- package/dist/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/test/integration/flows/totp.test.d.ts +17 -0
- package/package.json +10 -8
- package/dist/browser-cjs/index-ff477525.js.map +0 -1
- package/dist/cordova/popup_redirect-a4d3c436.js.map +0 -1
- package/dist/esm2017/index-3363a72a.js.map +0 -1
- package/dist/esm5/index-3f05dc7b.js.map +0 -1
- package/dist/node/index-45468d80.js.map +0 -1
- package/dist/node-esm/index-1f9492de.js.map +0 -1
- package/dist/rn/phone-e7bf48a1.js.map +0 -1
|
@@ -29,7 +29,8 @@ var component = require('@firebase/component');
|
|
|
29
29
|
*/
|
|
30
30
|
const FactorId = {
|
|
31
31
|
/** Phone as second factor */
|
|
32
|
-
PHONE: 'phone'
|
|
32
|
+
PHONE: 'phone',
|
|
33
|
+
TOTP: 'totp'
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
36
|
* Enumeration of supported providers.
|
|
@@ -213,6 +214,7 @@ function _debugErrorMap() {
|
|
|
213
214
|
["missing-or-invalid-nonce" /* AuthErrorCode.MISSING_OR_INVALID_NONCE */]: 'The request does not contain a valid nonce. This can occur if the ' +
|
|
214
215
|
'SHA-256 hash of the provided raw nonce does not match the hashed nonce ' +
|
|
215
216
|
'in the ID token payload.',
|
|
217
|
+
["missing-password" /* AuthErrorCode.MISSING_PASSWORD */]: 'A non-empty password must be provided',
|
|
216
218
|
["missing-multi-factor-info" /* AuthErrorCode.MISSING_MFA_INFO */]: 'No second factor identifier is provided.',
|
|
217
219
|
["missing-multi-factor-session" /* AuthErrorCode.MISSING_MFA_SESSION */]: 'The request is missing proof of first factor successful sign-in.',
|
|
218
220
|
["missing-phone-number" /* AuthErrorCode.MISSING_PHONE_NUMBER */]: 'To send verification codes, provide a phone number for the recipient.',
|
|
@@ -839,7 +841,7 @@ const SERVER_ERROR_MAP = {
|
|
|
839
841
|
// Sign in with email and password errors (some apply to sign up too).
|
|
840
842
|
["INVALID_PASSWORD" /* ServerError.INVALID_PASSWORD */]: "wrong-password" /* AuthErrorCode.INVALID_PASSWORD */,
|
|
841
843
|
// This can only happen if the SDK sends a bad request.
|
|
842
|
-
["MISSING_PASSWORD" /* ServerError.MISSING_PASSWORD */]: "
|
|
844
|
+
["MISSING_PASSWORD" /* ServerError.MISSING_PASSWORD */]: "missing-password" /* AuthErrorCode.MISSING_PASSWORD */,
|
|
843
845
|
// Sign up with email and password errors.
|
|
844
846
|
["EMAIL_EXISTS" /* ServerError.EMAIL_EXISTS */]: "email-already-in-use" /* AuthErrorCode.EMAIL_EXISTS */,
|
|
845
847
|
["PASSWORD_LOGIN_DISABLED" /* ServerError.PASSWORD_LOGIN_DISABLED */]: "operation-not-allowed" /* AuthErrorCode.OPERATION_NOT_ALLOWED */,
|
|
@@ -983,7 +985,10 @@ async function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
|
|
|
983
985
|
if (e instanceof util.FirebaseError) {
|
|
984
986
|
throw e;
|
|
985
987
|
}
|
|
986
|
-
|
|
988
|
+
// Changing this to a different error code will log user out when there is a network error
|
|
989
|
+
// because we treat any error other than NETWORK_REQUEST_FAILED as token is invalid.
|
|
990
|
+
// https://github.com/firebase/firebase-js-sdk/blob/4fbc73610d70be4e0852e7de63a39cb7897e8546/packages/auth/src/core/auth/auth_impl.ts#L309-L316
|
|
991
|
+
_fail(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */, { 'message': String(e) });
|
|
987
992
|
}
|
|
988
993
|
}
|
|
989
994
|
async function _performSignInRequest(auth, method, path, request, customErrorMap = {}) {
|
|
@@ -4861,6 +4866,9 @@ class MultiFactorInfoImpl {
|
|
|
4861
4866
|
if ('phoneInfo' in enrollment) {
|
|
4862
4867
|
return PhoneMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
4863
4868
|
}
|
|
4869
|
+
else if ('totpInfo' in enrollment) {
|
|
4870
|
+
return TotpMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
4871
|
+
}
|
|
4864
4872
|
return _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
4865
4873
|
}
|
|
4866
4874
|
}
|
|
@@ -4872,6 +4880,14 @@ class PhoneMultiFactorInfoImpl extends MultiFactorInfoImpl {
|
|
|
4872
4880
|
static _fromServerResponse(_auth, enrollment) {
|
|
4873
4881
|
return new PhoneMultiFactorInfoImpl(enrollment);
|
|
4874
4882
|
}
|
|
4883
|
+
}
|
|
4884
|
+
class TotpMultiFactorInfoImpl extends MultiFactorInfoImpl {
|
|
4885
|
+
constructor(response) {
|
|
4886
|
+
super("totp" /* FactorId.TOTP */, response);
|
|
4887
|
+
}
|
|
4888
|
+
static _fromServerResponse(_auth, enrollment) {
|
|
4889
|
+
return new TotpMultiFactorInfoImpl(enrollment);
|
|
4890
|
+
}
|
|
4875
4891
|
}
|
|
4876
4892
|
|
|
4877
4893
|
/**
|
|
@@ -5675,6 +5691,7 @@ function setPersistence(auth, persistence) {
|
|
|
5675
5691
|
*
|
|
5676
5692
|
* @remarks
|
|
5677
5693
|
* This includes sign-in, sign-out, and token refresh events.
|
|
5694
|
+
* This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
|
|
5678
5695
|
*
|
|
5679
5696
|
* @param auth - The {@link Auth} instance.
|
|
5680
5697
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -5908,6 +5925,12 @@ function startEnrollPhoneMfa(auth, request) {
|
|
|
5908
5925
|
function finalizeEnrollPhoneMfa(auth, request) {
|
|
5909
5926
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
5910
5927
|
}
|
|
5928
|
+
function startEnrollTotpMfa(auth, request) {
|
|
5929
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:start" /* Endpoint.START_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
5930
|
+
}
|
|
5931
|
+
function finalizeEnrollTotpMfa(auth, request) {
|
|
5932
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
5933
|
+
}
|
|
5911
5934
|
function withdrawMfa(auth, request) {
|
|
5912
5935
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:withdraw" /* Endpoint.WITHDRAW_MFA */, _addTidIfNecessary(auth, request));
|
|
5913
5936
|
}
|
|
@@ -7003,6 +7026,9 @@ function startSignInPhoneMfa(auth, request) {
|
|
|
7003
7026
|
}
|
|
7004
7027
|
function finalizeSignInPhoneMfa(auth, request) {
|
|
7005
7028
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
7029
|
+
}
|
|
7030
|
+
function finalizeSignInTotpMfa(auth, request) {
|
|
7031
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
7006
7032
|
}
|
|
7007
7033
|
|
|
7008
7034
|
/**
|
|
@@ -9313,8 +9339,155 @@ class PhoneMultiFactorGenerator {
|
|
|
9313
9339
|
*/
|
|
9314
9340
|
PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
|
|
9315
9341
|
|
|
9342
|
+
/**
|
|
9343
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
9344
|
+
*
|
|
9345
|
+
* @public
|
|
9346
|
+
*/
|
|
9347
|
+
class TotpMultiFactorGenerator {
|
|
9348
|
+
/**
|
|
9349
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
9350
|
+
* the TOTP (time-based one-time password) second factor.
|
|
9351
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
9352
|
+
*
|
|
9353
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
9354
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
9355
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
9356
|
+
* {@link MultiFactorUser.enroll}.
|
|
9357
|
+
*/
|
|
9358
|
+
static assertionForEnrollment(secret, oneTimePassword) {
|
|
9359
|
+
return TotpMultiFactorAssertionImpl._fromSecret(secret, oneTimePassword);
|
|
9360
|
+
}
|
|
9361
|
+
/**
|
|
9362
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
9363
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
9364
|
+
*
|
|
9365
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
9366
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
9367
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
9368
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
9369
|
+
*/
|
|
9370
|
+
static assertionForSignIn(enrollmentId, oneTimePassword) {
|
|
9371
|
+
return TotpMultiFactorAssertionImpl._fromEnrollmentId(enrollmentId, oneTimePassword);
|
|
9372
|
+
}
|
|
9373
|
+
/**
|
|
9374
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
9375
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
9376
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
9377
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
9378
|
+
*
|
|
9379
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
9380
|
+
* @returns A promise to {@link TotpSecret}.
|
|
9381
|
+
*/
|
|
9382
|
+
static async generateSecret(session) {
|
|
9383
|
+
const mfaSession = session;
|
|
9384
|
+
_assert(typeof mfaSession.auth !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
9385
|
+
const response = await startEnrollTotpMfa(mfaSession.auth, {
|
|
9386
|
+
idToken: mfaSession.credential,
|
|
9387
|
+
totpEnrollmentInfo: {}
|
|
9388
|
+
});
|
|
9389
|
+
return TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.auth);
|
|
9390
|
+
}
|
|
9391
|
+
}
|
|
9392
|
+
/**
|
|
9393
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
9394
|
+
*/
|
|
9395
|
+
TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
|
|
9396
|
+
class TotpMultiFactorAssertionImpl extends MultiFactorAssertionImpl {
|
|
9397
|
+
constructor(otp, enrollmentId, secret) {
|
|
9398
|
+
super("totp" /* FactorId.TOTP */);
|
|
9399
|
+
this.otp = otp;
|
|
9400
|
+
this.enrollmentId = enrollmentId;
|
|
9401
|
+
this.secret = secret;
|
|
9402
|
+
}
|
|
9403
|
+
/** @internal */
|
|
9404
|
+
static _fromSecret(secret, otp) {
|
|
9405
|
+
return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
|
|
9406
|
+
}
|
|
9407
|
+
/** @internal */
|
|
9408
|
+
static _fromEnrollmentId(enrollmentId, otp) {
|
|
9409
|
+
return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
|
|
9410
|
+
}
|
|
9411
|
+
/** @internal */
|
|
9412
|
+
async _finalizeEnroll(auth, idToken, displayName) {
|
|
9413
|
+
_assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
9414
|
+
return finalizeEnrollTotpMfa(auth, {
|
|
9415
|
+
idToken,
|
|
9416
|
+
displayName,
|
|
9417
|
+
totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
|
|
9418
|
+
});
|
|
9419
|
+
}
|
|
9420
|
+
/** @internal */
|
|
9421
|
+
async _finalizeSignIn(auth, mfaPendingCredential) {
|
|
9422
|
+
_assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
9423
|
+
const totpVerificationInfo = { verificationCode: this.otp };
|
|
9424
|
+
return finalizeSignInTotpMfa(auth, {
|
|
9425
|
+
mfaPendingCredential,
|
|
9426
|
+
mfaEnrollmentId: this.enrollmentId,
|
|
9427
|
+
totpVerificationInfo
|
|
9428
|
+
});
|
|
9429
|
+
}
|
|
9430
|
+
}
|
|
9431
|
+
/**
|
|
9432
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
9433
|
+
*
|
|
9434
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
9435
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
9436
|
+
* @public
|
|
9437
|
+
*/
|
|
9438
|
+
class TotpSecret {
|
|
9439
|
+
// The public members are declared outside the constructor so the docs can be generated.
|
|
9440
|
+
constructor(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
|
|
9441
|
+
this.sessionInfo = sessionInfo;
|
|
9442
|
+
this.auth = auth;
|
|
9443
|
+
this.secretKey = secretKey;
|
|
9444
|
+
this.hashingAlgorithm = hashingAlgorithm;
|
|
9445
|
+
this.codeLength = codeLength;
|
|
9446
|
+
this.codeIntervalSeconds = codeIntervalSeconds;
|
|
9447
|
+
this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
|
|
9448
|
+
}
|
|
9449
|
+
/** @internal */
|
|
9450
|
+
static _fromStartTotpMfaEnrollmentResponse(response, auth) {
|
|
9451
|
+
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);
|
|
9452
|
+
}
|
|
9453
|
+
/** @internal */
|
|
9454
|
+
_makeTotpVerificationInfo(otp) {
|
|
9455
|
+
return { sessionInfo: this.sessionInfo, verificationCode: otp };
|
|
9456
|
+
}
|
|
9457
|
+
/**
|
|
9458
|
+
* Returns a QR code URL as described in
|
|
9459
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
9460
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
9461
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
9462
|
+
*
|
|
9463
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
9464
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
9465
|
+
* @returns A QR code URL string.
|
|
9466
|
+
*/
|
|
9467
|
+
generateQrCodeUrl(accountName, issuer) {
|
|
9468
|
+
var _a;
|
|
9469
|
+
let useDefaults = false;
|
|
9470
|
+
if (_isEmptyString(accountName) || _isEmptyString(issuer)) {
|
|
9471
|
+
useDefaults = true;
|
|
9472
|
+
}
|
|
9473
|
+
if (useDefaults) {
|
|
9474
|
+
if (_isEmptyString(accountName)) {
|
|
9475
|
+
accountName = ((_a = this.auth.currentUser) === null || _a === void 0 ? void 0 : _a.email) || 'unknownuser';
|
|
9476
|
+
}
|
|
9477
|
+
if (_isEmptyString(issuer)) {
|
|
9478
|
+
issuer = this.auth.name;
|
|
9479
|
+
}
|
|
9480
|
+
}
|
|
9481
|
+
return `otpauth://totp/${issuer}:${accountName}?secret=${this.secretKey}&issuer=${issuer}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`;
|
|
9482
|
+
}
|
|
9483
|
+
}
|
|
9484
|
+
/** @internal */
|
|
9485
|
+
function _isEmptyString(input) {
|
|
9486
|
+
return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
|
|
9487
|
+
}
|
|
9488
|
+
|
|
9316
9489
|
var name = "@firebase/auth";
|
|
9317
|
-
var version = "0.21.
|
|
9490
|
+
var version = "0.21.6-canary.a8d6499b1";
|
|
9318
9491
|
|
|
9319
9492
|
/**
|
|
9320
9493
|
* @license
|
|
@@ -9564,6 +9737,8 @@ exports.RecaptchaVerifier = RecaptchaVerifier;
|
|
|
9564
9737
|
exports.SAMLAuthCredential = SAMLAuthCredential;
|
|
9565
9738
|
exports.SAMLAuthProvider = SAMLAuthProvider;
|
|
9566
9739
|
exports.SignInMethod = SignInMethod;
|
|
9740
|
+
exports.TotpMultiFactorGenerator = TotpMultiFactorGenerator;
|
|
9741
|
+
exports.TotpSecret = TotpSecret;
|
|
9567
9742
|
exports.TwitterAuthProvider = TwitterAuthProvider;
|
|
9568
9743
|
exports.UserImpl = UserImpl;
|
|
9569
9744
|
exports._assert = _assert;
|
|
@@ -9641,4 +9816,4 @@ exports.updateProfile = updateProfile;
|
|
|
9641
9816
|
exports.useDeviceLanguage = useDeviceLanguage;
|
|
9642
9817
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
9643
9818
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
9644
|
-
//# sourceMappingURL=index-
|
|
9819
|
+
//# sourceMappingURL=index-a031a7c0.js.map
|