@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.
- package/CHANGELOG.md +8 -0
- package/README.md +25 -0
- package/dist/auth-public.d.ts +135 -4
- package/dist/auth.d.ts +138 -4
- package/dist/browser-cjs/{index-ff477525.js → index-3e63d976.js} +180 -5
- package/dist/browser-cjs/index-3e63d976.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-4dd66477.js} +31 -6
- package/dist/cordova/popup_redirect-4dd66477.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-c8153924.js} +179 -6
- package/dist/esm2017/index-c8153924.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-f3279380.js} +207 -6
- package/dist/esm5/index-f3279380.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-9c98f1ff.js} +243 -6
- package/dist/node/totp-9c98f1ff.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-a3bfc07a.js} +213 -7
- package/dist/node-esm/totp-a3bfc07a.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-588b1f48.js} +37 -5
- package/dist/rn/phone-588b1f48.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
|
@@ -27,7 +27,8 @@ import { Component } from '@firebase/component';
|
|
|
27
27
|
*/
|
|
28
28
|
var FactorId = {
|
|
29
29
|
/** Phone as second factor */
|
|
30
|
-
PHONE: 'phone'
|
|
30
|
+
PHONE: 'phone',
|
|
31
|
+
TOTP: 'totp'
|
|
31
32
|
};
|
|
32
33
|
/**
|
|
33
34
|
* Enumeration of supported providers.
|
|
@@ -212,6 +213,7 @@ function _debugErrorMap() {
|
|
|
212
213
|
_a["missing-or-invalid-nonce" /* AuthErrorCode.MISSING_OR_INVALID_NONCE */] = 'The request does not contain a valid nonce. This can occur if the ' +
|
|
213
214
|
'SHA-256 hash of the provided raw nonce does not match the hashed nonce ' +
|
|
214
215
|
'in the ID token payload.',
|
|
216
|
+
_a["missing-password" /* AuthErrorCode.MISSING_PASSWORD */] = 'A non-empty password must be provided',
|
|
215
217
|
_a["missing-multi-factor-info" /* AuthErrorCode.MISSING_MFA_INFO */] = 'No second factor identifier is provided.',
|
|
216
218
|
_a["missing-multi-factor-session" /* AuthErrorCode.MISSING_MFA_SESSION */] = 'The request is missing proof of first factor successful sign-in.',
|
|
217
219
|
_a["missing-phone-number" /* AuthErrorCode.MISSING_PHONE_NUMBER */] = 'To send verification codes, provide a phone number for the recipient.',
|
|
@@ -866,7 +868,7 @@ var SERVER_ERROR_MAP = (_a$1 = {},
|
|
|
866
868
|
// Sign in with email and password errors (some apply to sign up too).
|
|
867
869
|
_a$1["INVALID_PASSWORD" /* ServerError.INVALID_PASSWORD */] = "wrong-password" /* AuthErrorCode.INVALID_PASSWORD */,
|
|
868
870
|
// This can only happen if the SDK sends a bad request.
|
|
869
|
-
_a$1["MISSING_PASSWORD" /* ServerError.MISSING_PASSWORD */] = "
|
|
871
|
+
_a$1["MISSING_PASSWORD" /* ServerError.MISSING_PASSWORD */] = "missing-password" /* AuthErrorCode.MISSING_PASSWORD */,
|
|
870
872
|
// Sign up with email and password errors.
|
|
871
873
|
_a$1["EMAIL_EXISTS" /* ServerError.EMAIL_EXISTS */] = "email-already-in-use" /* AuthErrorCode.EMAIL_EXISTS */,
|
|
872
874
|
_a$1["PASSWORD_LOGIN_DISABLED" /* ServerError.PASSWORD_LOGIN_DISABLED */] = "operation-not-allowed" /* AuthErrorCode.OPERATION_NOT_ALLOWED */,
|
|
@@ -1035,7 +1037,10 @@ function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
|
|
|
1035
1037
|
if (e_1 instanceof FirebaseError) {
|
|
1036
1038
|
throw e_1;
|
|
1037
1039
|
}
|
|
1038
|
-
|
|
1040
|
+
// Changing this to a different error code will log user out when there is a network error
|
|
1041
|
+
// because we treat any error other than NETWORK_REQUEST_FAILED as token is invalid.
|
|
1042
|
+
// https://github.com/firebase/firebase-js-sdk/blob/4fbc73610d70be4e0852e7de63a39cb7897e8546/packages/auth/src/core/auth/auth_impl.ts#L309-L316
|
|
1043
|
+
_fail(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */, { 'message': String(e_1) });
|
|
1039
1044
|
return [3 /*break*/, 5];
|
|
1040
1045
|
case 5: return [2 /*return*/];
|
|
1041
1046
|
}
|
|
@@ -5698,6 +5703,9 @@ var MultiFactorInfoImpl = /** @class */ (function () {
|
|
|
5698
5703
|
if ('phoneInfo' in enrollment) {
|
|
5699
5704
|
return PhoneMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
5700
5705
|
}
|
|
5706
|
+
else if ('totpInfo' in enrollment) {
|
|
5707
|
+
return TotpMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
5708
|
+
}
|
|
5701
5709
|
return _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
5702
5710
|
};
|
|
5703
5711
|
return MultiFactorInfoImpl;
|
|
@@ -5713,6 +5721,16 @@ var PhoneMultiFactorInfoImpl = /** @class */ (function (_super) {
|
|
|
5713
5721
|
return new PhoneMultiFactorInfoImpl(enrollment);
|
|
5714
5722
|
};
|
|
5715
5723
|
return PhoneMultiFactorInfoImpl;
|
|
5724
|
+
}(MultiFactorInfoImpl));
|
|
5725
|
+
var TotpMultiFactorInfoImpl = /** @class */ (function (_super) {
|
|
5726
|
+
__extends(TotpMultiFactorInfoImpl, _super);
|
|
5727
|
+
function TotpMultiFactorInfoImpl(response) {
|
|
5728
|
+
return _super.call(this, "totp" /* FactorId.TOTP */, response) || this;
|
|
5729
|
+
}
|
|
5730
|
+
TotpMultiFactorInfoImpl._fromServerResponse = function (_auth, enrollment) {
|
|
5731
|
+
return new TotpMultiFactorInfoImpl(enrollment);
|
|
5732
|
+
};
|
|
5733
|
+
return TotpMultiFactorInfoImpl;
|
|
5716
5734
|
}(MultiFactorInfoImpl));
|
|
5717
5735
|
|
|
5718
5736
|
/**
|
|
@@ -6679,6 +6697,7 @@ function setPersistence(auth, persistence) {
|
|
|
6679
6697
|
*
|
|
6680
6698
|
* @remarks
|
|
6681
6699
|
* This includes sign-in, sign-out, and token refresh events.
|
|
6700
|
+
* This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
|
|
6682
6701
|
*
|
|
6683
6702
|
* @param auth - The {@link Auth} instance.
|
|
6684
6703
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -6941,6 +6960,12 @@ function startEnrollPhoneMfa(auth, request) {
|
|
|
6941
6960
|
function finalizeEnrollPhoneMfa(auth, request) {
|
|
6942
6961
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6943
6962
|
}
|
|
6963
|
+
function startEnrollTotpMfa(auth, request) {
|
|
6964
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:start" /* Endpoint.START_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6965
|
+
}
|
|
6966
|
+
function finalizeEnrollTotpMfa(auth, request) {
|
|
6967
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6968
|
+
}
|
|
6944
6969
|
function withdrawMfa(auth, request) {
|
|
6945
6970
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:withdraw" /* Endpoint.WITHDRAW_MFA */, _addTidIfNecessary(auth, request));
|
|
6946
6971
|
}
|
|
@@ -8348,6 +8373,9 @@ function startSignInPhoneMfa(auth, request) {
|
|
|
8348
8373
|
}
|
|
8349
8374
|
function finalizeSignInPhoneMfa(auth, request) {
|
|
8350
8375
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
8376
|
+
}
|
|
8377
|
+
function finalizeSignInTotpMfa(auth, request) {
|
|
8378
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
8351
8379
|
}
|
|
8352
8380
|
|
|
8353
8381
|
/**
|
|
@@ -11101,8 +11129,181 @@ var PhoneMultiFactorGenerator = /** @class */ (function () {
|
|
|
11101
11129
|
return PhoneMultiFactorGenerator;
|
|
11102
11130
|
}());
|
|
11103
11131
|
|
|
11132
|
+
/**
|
|
11133
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
11134
|
+
*
|
|
11135
|
+
* @public
|
|
11136
|
+
*/
|
|
11137
|
+
var TotpMultiFactorGenerator = /** @class */ (function () {
|
|
11138
|
+
function TotpMultiFactorGenerator() {
|
|
11139
|
+
}
|
|
11140
|
+
/**
|
|
11141
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
11142
|
+
* the TOTP (time-based one-time password) second factor.
|
|
11143
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
11144
|
+
*
|
|
11145
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
11146
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
11147
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
11148
|
+
* {@link MultiFactorUser.enroll}.
|
|
11149
|
+
*/
|
|
11150
|
+
TotpMultiFactorGenerator.assertionForEnrollment = function (secret, oneTimePassword) {
|
|
11151
|
+
return TotpMultiFactorAssertionImpl._fromSecret(secret, oneTimePassword);
|
|
11152
|
+
};
|
|
11153
|
+
/**
|
|
11154
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
11155
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
11156
|
+
*
|
|
11157
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
11158
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
11159
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
11160
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
11161
|
+
*/
|
|
11162
|
+
TotpMultiFactorGenerator.assertionForSignIn = function (enrollmentId, oneTimePassword) {
|
|
11163
|
+
return TotpMultiFactorAssertionImpl._fromEnrollmentId(enrollmentId, oneTimePassword);
|
|
11164
|
+
};
|
|
11165
|
+
/**
|
|
11166
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
11167
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
11168
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
11169
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
11170
|
+
*
|
|
11171
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
11172
|
+
* @returns A promise to {@link TotpSecret}.
|
|
11173
|
+
*/
|
|
11174
|
+
TotpMultiFactorGenerator.generateSecret = function (session) {
|
|
11175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11176
|
+
var mfaSession, response;
|
|
11177
|
+
return __generator(this, function (_a) {
|
|
11178
|
+
switch (_a.label) {
|
|
11179
|
+
case 0:
|
|
11180
|
+
mfaSession = session;
|
|
11181
|
+
_assert(typeof mfaSession.auth !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
11182
|
+
return [4 /*yield*/, startEnrollTotpMfa(mfaSession.auth, {
|
|
11183
|
+
idToken: mfaSession.credential,
|
|
11184
|
+
totpEnrollmentInfo: {}
|
|
11185
|
+
})];
|
|
11186
|
+
case 1:
|
|
11187
|
+
response = _a.sent();
|
|
11188
|
+
return [2 /*return*/, TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.auth)];
|
|
11189
|
+
}
|
|
11190
|
+
});
|
|
11191
|
+
});
|
|
11192
|
+
};
|
|
11193
|
+
/**
|
|
11194
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
11195
|
+
*/
|
|
11196
|
+
TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
|
|
11197
|
+
return TotpMultiFactorGenerator;
|
|
11198
|
+
}());
|
|
11199
|
+
var TotpMultiFactorAssertionImpl = /** @class */ (function (_super) {
|
|
11200
|
+
__extends(TotpMultiFactorAssertionImpl, _super);
|
|
11201
|
+
function TotpMultiFactorAssertionImpl(otp, enrollmentId, secret) {
|
|
11202
|
+
var _this = _super.call(this, "totp" /* FactorId.TOTP */) || this;
|
|
11203
|
+
_this.otp = otp;
|
|
11204
|
+
_this.enrollmentId = enrollmentId;
|
|
11205
|
+
_this.secret = secret;
|
|
11206
|
+
return _this;
|
|
11207
|
+
}
|
|
11208
|
+
/** @internal */
|
|
11209
|
+
TotpMultiFactorAssertionImpl._fromSecret = function (secret, otp) {
|
|
11210
|
+
return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
|
|
11211
|
+
};
|
|
11212
|
+
/** @internal */
|
|
11213
|
+
TotpMultiFactorAssertionImpl._fromEnrollmentId = function (enrollmentId, otp) {
|
|
11214
|
+
return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
|
|
11215
|
+
};
|
|
11216
|
+
/** @internal */
|
|
11217
|
+
TotpMultiFactorAssertionImpl.prototype._finalizeEnroll = function (auth, idToken, displayName) {
|
|
11218
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11219
|
+
return __generator(this, function (_a) {
|
|
11220
|
+
_assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
11221
|
+
return [2 /*return*/, finalizeEnrollTotpMfa(auth, {
|
|
11222
|
+
idToken: idToken,
|
|
11223
|
+
displayName: displayName,
|
|
11224
|
+
totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
|
|
11225
|
+
})];
|
|
11226
|
+
});
|
|
11227
|
+
});
|
|
11228
|
+
};
|
|
11229
|
+
/** @internal */
|
|
11230
|
+
TotpMultiFactorAssertionImpl.prototype._finalizeSignIn = function (auth, mfaPendingCredential) {
|
|
11231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11232
|
+
var totpVerificationInfo;
|
|
11233
|
+
return __generator(this, function (_a) {
|
|
11234
|
+
_assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
11235
|
+
totpVerificationInfo = { verificationCode: this.otp };
|
|
11236
|
+
return [2 /*return*/, finalizeSignInTotpMfa(auth, {
|
|
11237
|
+
mfaPendingCredential: mfaPendingCredential,
|
|
11238
|
+
mfaEnrollmentId: this.enrollmentId,
|
|
11239
|
+
totpVerificationInfo: totpVerificationInfo
|
|
11240
|
+
})];
|
|
11241
|
+
});
|
|
11242
|
+
});
|
|
11243
|
+
};
|
|
11244
|
+
return TotpMultiFactorAssertionImpl;
|
|
11245
|
+
}(MultiFactorAssertionImpl));
|
|
11246
|
+
/**
|
|
11247
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
11248
|
+
*
|
|
11249
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
11250
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
11251
|
+
* @public
|
|
11252
|
+
*/
|
|
11253
|
+
var TotpSecret = /** @class */ (function () {
|
|
11254
|
+
// The public members are declared outside the constructor so the docs can be generated.
|
|
11255
|
+
function TotpSecret(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
|
|
11256
|
+
this.sessionInfo = sessionInfo;
|
|
11257
|
+
this.auth = auth;
|
|
11258
|
+
this.secretKey = secretKey;
|
|
11259
|
+
this.hashingAlgorithm = hashingAlgorithm;
|
|
11260
|
+
this.codeLength = codeLength;
|
|
11261
|
+
this.codeIntervalSeconds = codeIntervalSeconds;
|
|
11262
|
+
this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
|
|
11263
|
+
}
|
|
11264
|
+
/** @internal */
|
|
11265
|
+
TotpSecret._fromStartTotpMfaEnrollmentResponse = function (response, auth) {
|
|
11266
|
+
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);
|
|
11267
|
+
};
|
|
11268
|
+
/** @internal */
|
|
11269
|
+
TotpSecret.prototype._makeTotpVerificationInfo = function (otp) {
|
|
11270
|
+
return { sessionInfo: this.sessionInfo, verificationCode: otp };
|
|
11271
|
+
};
|
|
11272
|
+
/**
|
|
11273
|
+
* Returns a QR code URL as described in
|
|
11274
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
11275
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
11276
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
11277
|
+
*
|
|
11278
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
11279
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
11280
|
+
* @returns A QR code URL string.
|
|
11281
|
+
*/
|
|
11282
|
+
TotpSecret.prototype.generateQrCodeUrl = function (accountName, issuer) {
|
|
11283
|
+
var _a;
|
|
11284
|
+
var useDefaults = false;
|
|
11285
|
+
if (_isEmptyString(accountName) || _isEmptyString(issuer)) {
|
|
11286
|
+
useDefaults = true;
|
|
11287
|
+
}
|
|
11288
|
+
if (useDefaults) {
|
|
11289
|
+
if (_isEmptyString(accountName)) {
|
|
11290
|
+
accountName = ((_a = this.auth.currentUser) === null || _a === void 0 ? void 0 : _a.email) || 'unknownuser';
|
|
11291
|
+
}
|
|
11292
|
+
if (_isEmptyString(issuer)) {
|
|
11293
|
+
issuer = this.auth.name;
|
|
11294
|
+
}
|
|
11295
|
+
}
|
|
11296
|
+
return "otpauth://totp/".concat(issuer, ":").concat(accountName, "?secret=").concat(this.secretKey, "&issuer=").concat(issuer, "&algorithm=").concat(this.hashingAlgorithm, "&digits=").concat(this.codeLength);
|
|
11297
|
+
};
|
|
11298
|
+
return TotpSecret;
|
|
11299
|
+
}());
|
|
11300
|
+
/** @internal */
|
|
11301
|
+
function _isEmptyString(input) {
|
|
11302
|
+
return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
|
|
11303
|
+
}
|
|
11304
|
+
|
|
11104
11305
|
var name = "@firebase/auth";
|
|
11105
|
-
var version = "0.21.
|
|
11306
|
+
var version = "0.21.6-canary.45a55330e";
|
|
11106
11307
|
|
|
11107
11308
|
/**
|
|
11108
11309
|
* @license
|
|
@@ -11359,5 +11560,5 @@ function getAuth(app) {
|
|
|
11359
11560
|
}
|
|
11360
11561
|
registerAuth("Browser" /* ClientPlatform.BROWSER */);
|
|
11361
11562
|
|
|
11362
|
-
export {
|
|
11363
|
-
//# sourceMappingURL=index-
|
|
11563
|
+
export { linkWithCredential as $, ActionCodeOperation as A, deleteUser as B, debugErrorMap as C, prodErrorMap as D, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as E, FactorId as F, initializeAuth as G, connectAuthEmulator as H, AuthCredential as I, EmailAuthCredential as J, OAuthCredential as K, PhoneAuthCredential as L, inMemoryPersistence as M, EmailAuthProvider as N, OperationType as O, PhoneAuthProvider as P, FacebookAuthProvider as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, GoogleAuthProvider as U, GithubAuthProvider as V, OAuthProvider as W, SAMLAuthProvider as X, TwitterAuthProvider as Y, signInAnonymously as Z, signInWithCredential as _, browserSessionPersistence as a, reauthenticateWithCredential as a0, signInWithCustomToken as a1, sendPasswordResetEmail as a2, confirmPasswordReset as a3, applyActionCode as a4, checkActionCode as a5, verifyPasswordResetCode as a6, createUserWithEmailAndPassword as a7, signInWithEmailAndPassword as a8, sendSignInLinkToEmail as a9, AuthEventManager as aA, _getInstance as aB, _persistenceKeyName as aC, _clearRedirectOutcomes as aD, _getRedirectResult as aE, _overrideRedirectResult as aF, _castAuth as aG, UserImpl as aH, AuthImpl as aI, _getClientVersion as aJ, _generateEventId as aK, AuthPopup as aL, FetchProvider as aM, SAMLAuthCredential as aN, isSignInWithEmailLink as aa, signInWithEmailLink as ab, fetchSignInMethodsForEmail as ac, sendEmailVerification as ad, verifyBeforeUpdateEmail as ae, ActionCodeURL as af, parseActionCodeURL as ag, updateProfile as ah, updateEmail as ai, updatePassword as aj, getIdToken as ak, getIdTokenResult as al, unlink as am, getAdditionalUserInfo as an, reload as ao, getMultiFactorResolver as ap, multiFactor as aq, _isIOS as ar, _isAndroid as as, _fail as at, _getRedirectUrl as au, debugAssert as av, _getProjectConfig as aw, _isIOS7Or8 as ax, _assert as ay, _createError as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, onIdTokenChanged as t, updatePhoneNumber as u, beforeAuthStateChanged as v, onAuthStateChanged as w, useDeviceLanguage as x, updateCurrentUser as y, signOut as z };
|
|
11564
|
+
//# sourceMappingURL=index-f3279380.js.map
|