@firebase/auth 0.21.5-canary.ce79f7fe2 → 0.21.5-canary.f8a2c5865
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/README.md +25 -0
- package/dist/auth-public.d.ts +137 -4
- package/dist/auth.d.ts +149 -4
- package/dist/browser-cjs/{index-da3cf52f.js → index-aeaeb040.js} +176 -4
- package/dist/browser-cjs/index-aeaeb040.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-5b6894c2.js → popup_redirect-5d90c99d.js} +27 -5
- package/dist/cordova/popup_redirect-5d90c99d.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-c0585610.js → index-9467e58b.js} +175 -5
- package/dist/esm2017/index-9467e58b.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-281afa15.js → index-de7cac5b.js} +203 -5
- package/dist/esm5/index-de7cac5b.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 +19 -3
- 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-37042dd3.js → totp-bee43d8c.js} +239 -5
- package/dist/node/totp-bee43d8c.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-1cab2ca1.js → totp-9075bbc1.js} +209 -6
- package/dist/node-esm/totp-9075bbc1.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-2c66b31d.js → phone-4275321a.js} +33 -4
- package/dist/rn/phone-4275321a.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-da3cf52f.js.map +0 -1
- package/dist/cordova/popup_redirect-5b6894c2.js.map +0 -1
- package/dist/esm2017/index-c0585610.js.map +0 -1
- package/dist/esm5/index-281afa15.js.map +0 -1
- package/dist/node/index-37042dd3.js.map +0 -1
- package/dist/node-esm/index-1cab2ca1.js.map +0 -1
- package/dist/rn/phone-2c66b31d.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 */,
|
|
@@ -4864,6 +4866,9 @@ class MultiFactorInfoImpl {
|
|
|
4864
4866
|
if ('phoneInfo' in enrollment) {
|
|
4865
4867
|
return PhoneMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
4866
4868
|
}
|
|
4869
|
+
else if ('totpInfo' in enrollment) {
|
|
4870
|
+
return TotpMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
4871
|
+
}
|
|
4867
4872
|
return _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
4868
4873
|
}
|
|
4869
4874
|
}
|
|
@@ -4875,6 +4880,14 @@ class PhoneMultiFactorInfoImpl extends MultiFactorInfoImpl {
|
|
|
4875
4880
|
static _fromServerResponse(_auth, enrollment) {
|
|
4876
4881
|
return new PhoneMultiFactorInfoImpl(enrollment);
|
|
4877
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
|
+
}
|
|
4878
4891
|
}
|
|
4879
4892
|
|
|
4880
4893
|
/**
|
|
@@ -5678,6 +5691,7 @@ function setPersistence(auth, persistence) {
|
|
|
5678
5691
|
*
|
|
5679
5692
|
* @remarks
|
|
5680
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.
|
|
5681
5695
|
*
|
|
5682
5696
|
* @param auth - The {@link Auth} instance.
|
|
5683
5697
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -5911,6 +5925,12 @@ function startEnrollPhoneMfa(auth, request) {
|
|
|
5911
5925
|
function finalizeEnrollPhoneMfa(auth, request) {
|
|
5912
5926
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
5913
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
|
+
}
|
|
5914
5934
|
function withdrawMfa(auth, request) {
|
|
5915
5935
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:withdraw" /* Endpoint.WITHDRAW_MFA */, _addTidIfNecessary(auth, request));
|
|
5916
5936
|
}
|
|
@@ -7006,6 +7026,9 @@ function startSignInPhoneMfa(auth, request) {
|
|
|
7006
7026
|
}
|
|
7007
7027
|
function finalizeSignInPhoneMfa(auth, request) {
|
|
7008
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));
|
|
7009
7032
|
}
|
|
7010
7033
|
|
|
7011
7034
|
/**
|
|
@@ -9316,8 +9339,155 @@ class PhoneMultiFactorGenerator {
|
|
|
9316
9339
|
*/
|
|
9317
9340
|
PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
|
|
9318
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
|
+
|
|
9319
9489
|
var name = "@firebase/auth";
|
|
9320
|
-
var version = "0.21.5-canary.
|
|
9490
|
+
var version = "0.21.5-canary.f8a2c5865";
|
|
9321
9491
|
|
|
9322
9492
|
/**
|
|
9323
9493
|
* @license
|
|
@@ -9567,6 +9737,8 @@ exports.RecaptchaVerifier = RecaptchaVerifier;
|
|
|
9567
9737
|
exports.SAMLAuthCredential = SAMLAuthCredential;
|
|
9568
9738
|
exports.SAMLAuthProvider = SAMLAuthProvider;
|
|
9569
9739
|
exports.SignInMethod = SignInMethod;
|
|
9740
|
+
exports.TotpMultiFactorGenerator = TotpMultiFactorGenerator;
|
|
9741
|
+
exports.TotpSecret = TotpSecret;
|
|
9570
9742
|
exports.TwitterAuthProvider = TwitterAuthProvider;
|
|
9571
9743
|
exports.UserImpl = UserImpl;
|
|
9572
9744
|
exports._assert = _assert;
|
|
@@ -9644,4 +9816,4 @@ exports.updateProfile = updateProfile;
|
|
|
9644
9816
|
exports.useDeviceLanguage = useDeviceLanguage;
|
|
9645
9817
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
9646
9818
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
9647
|
-
//# sourceMappingURL=index-
|
|
9819
|
+
//# sourceMappingURL=index-aeaeb040.js.map
|