@firebase/auth 0.21.5 → 0.21.6-20230329040242
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 +20 -0
- package/dist/auth-public.d.ts +136 -4
- package/dist/auth.d.ts +147 -4
- package/dist/browser-cjs/{index-ff477525.js → index-f0c95b47.js} +177 -4
- package/dist/browser-cjs/index-f0c95b47.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/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-ea399a63.js} +28 -5
- package/dist/cordova/popup_redirect-ea399a63.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/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-998a92c6.js} +176 -5
- package/dist/esm2017/index-998a92c6.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/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-14d0c8cb.js} +204 -5
- package/dist/esm5/index-14d0c8cb.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/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 +20 -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/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-06ccbed7.js} +240 -5
- package/dist/node/totp-06ccbed7.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/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-412ade8c.js} +210 -6
- package/dist/node-esm/totp-412ade8c.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-e85f18b7.js} +34 -4
- package/dist/rn/phone-e85f18b7.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/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/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 +5 -3
- 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
package/dist/esm2017/index.d.ts
CHANGED
|
@@ -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/esm2017/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ActionCodeOperation,
|
|
1
|
+
export { A as ActionCodeOperation, af as ActionCodeURL, I as AuthCredential, E as AuthErrorCodes, J as EmailAuthCredential, N as EmailAuthProvider, Q as FacebookAuthProvider, F as FactorId, V as GithubAuthProvider, U as GoogleAuthProvider, K as OAuthCredential, W as OAuthProvider, O as OperationType, L as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, X as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, Y as TwitterAuthProvider, a4 as applyActionCode, v as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a5 as checkActionCode, a3 as confirmPasswordReset, H as connectAuthEmulator, a7 as createUserWithEmailAndPassword, C as debugErrorMap, B as deleteUser, ac as fetchSignInMethodsForEmail, an as getAdditionalUserInfo, o as getAuth, ak as getIdToken, al as getIdTokenResult, ap as getMultiFactorResolver, j as getRedirectResult, M as inMemoryPersistence, i as indexedDBLocalPersistence, G as initializeAuth, aa as isSignInWithEmailLink, $ as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, aq as multiFactor, w as onAuthStateChanged, t as onIdTokenChanged, ag as parseActionCodeURL, D as prodErrorMap, a0 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, ao as reload, ad as sendEmailVerification, a2 as sendPasswordResetEmail, a9 as sendSignInLinkToEmail, q as setPersistence, Z as signInAnonymously, _ as signInWithCredential, a1 as signInWithCustomToken, a8 as signInWithEmailAndPassword, ab as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, z as signOut, am as unlink, y as updateCurrentUser, ai as updateEmail, aj as updatePassword, u as updatePhoneNumber, ah as updateProfile, x as useDeviceLanguage, ae as verifyBeforeUpdateEmail, a6 as verifyPasswordResetCode } from './index-998a92c6.js';
|
|
2
2
|
import '@firebase/util';
|
|
3
3
|
import '@firebase/app';
|
|
4
4
|
import '@firebase/logger';
|
package/dist/esm2017/internal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as ActionCodeOperation,
|
|
1
|
+
import { ar as debugAssert, as as _isIOS, at as _isAndroid, au as _fail, av as _getRedirectUrl, aw as _getProjectConfig, ax as _isIOS7Or8, ay as _createError, az as _assert, aA as AuthEventManager, aB as _getInstance, b as browserLocalPersistence, aC as _persistenceKeyName, a as browserSessionPersistence, aD as _getRedirectResult, aE as _overrideRedirectResult, aF as _clearRedirectOutcomes, aG as _castAuth } from './index-998a92c6.js';
|
|
2
|
+
export { A as ActionCodeOperation, af as ActionCodeURL, I as AuthCredential, E as AuthErrorCodes, aI as AuthImpl, aL as AuthPopup, J as EmailAuthCredential, N as EmailAuthProvider, Q as FacebookAuthProvider, F as FactorId, aM as FetchProvider, V as GithubAuthProvider, U as GoogleAuthProvider, K as OAuthCredential, W as OAuthProvider, O as OperationType, L as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, aN as SAMLAuthCredential, X as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, Y as TwitterAuthProvider, aH as UserImpl, az as _assert, aG as _castAuth, au as _fail, aK as _generateEventId, aJ as _getClientVersion, aB as _getInstance, aD as _getRedirectResult, aE as _overrideRedirectResult, aC as _persistenceKeyName, a4 as applyActionCode, v as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a5 as checkActionCode, a3 as confirmPasswordReset, H as connectAuthEmulator, a7 as createUserWithEmailAndPassword, C as debugErrorMap, B as deleteUser, ac as fetchSignInMethodsForEmail, an as getAdditionalUserInfo, o as getAuth, ak as getIdToken, al as getIdTokenResult, ap as getMultiFactorResolver, j as getRedirectResult, M as inMemoryPersistence, i as indexedDBLocalPersistence, G as initializeAuth, aa as isSignInWithEmailLink, $ as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, aq as multiFactor, w as onAuthStateChanged, t as onIdTokenChanged, ag as parseActionCodeURL, D as prodErrorMap, a0 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, ao as reload, ad as sendEmailVerification, a2 as sendPasswordResetEmail, a9 as sendSignInLinkToEmail, q as setPersistence, Z as signInAnonymously, _ as signInWithCredential, a1 as signInWithCustomToken, a8 as signInWithEmailAndPassword, ab as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, z as signOut, am as unlink, y as updateCurrentUser, ai as updateEmail, aj as updatePassword, u as updatePhoneNumber, ah as updateProfile, x as useDeviceLanguage, ae as verifyBeforeUpdateEmail, a6 as verifyPasswordResetCode } from './index-998a92c6.js';
|
|
3
3
|
import { querystringDecode } from '@firebase/util';
|
|
4
4
|
import '@firebase/app';
|
|
5
5
|
import '@firebase/logger';
|
|
@@ -18,7 +18,7 @@ import { SignInWithPhoneNumberRequest } from '../authentication/sms';
|
|
|
18
18
|
import { FinalizeMfaResponse } from '../authentication/mfa';
|
|
19
19
|
import { AuthInternal } from '../../model/auth';
|
|
20
20
|
/**
|
|
21
|
-
* MFA Info as returned by the API
|
|
21
|
+
* MFA Info as returned by the API.
|
|
22
22
|
*/
|
|
23
23
|
interface BaseMfaEnrollment {
|
|
24
24
|
mfaEnrollmentId: string;
|
|
@@ -26,15 +26,20 @@ interface BaseMfaEnrollment {
|
|
|
26
26
|
displayName?: string;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* An MFA provided by SMS verification
|
|
29
|
+
* An MFA provided by SMS verification.
|
|
30
30
|
*/
|
|
31
31
|
export interface PhoneMfaEnrollment extends BaseMfaEnrollment {
|
|
32
32
|
phoneInfo: string;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* An MFA provided by TOTP (Time-based One Time Password).
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export interface TotpMfaEnrollment extends BaseMfaEnrollment {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment and TotpMfaEnrollment are supported.
|
|
41
|
+
*/
|
|
42
|
+
export declare type MfaEnrollment = PhoneMfaEnrollment | TotpMfaEnrollment;
|
|
38
43
|
export interface StartPhoneMfaEnrollmentRequest {
|
|
39
44
|
idToken: string;
|
|
40
45
|
phoneEnrollmentInfo: {
|
|
@@ -58,6 +63,35 @@ export interface FinalizePhoneMfaEnrollmentRequest {
|
|
|
58
63
|
export interface FinalizePhoneMfaEnrollmentResponse extends FinalizeMfaResponse {
|
|
59
64
|
}
|
|
60
65
|
export declare function finalizeEnrollPhoneMfa(auth: AuthInternal, request: FinalizePhoneMfaEnrollmentRequest): Promise<FinalizePhoneMfaEnrollmentResponse>;
|
|
66
|
+
export interface StartTotpMfaEnrollmentRequest {
|
|
67
|
+
idToken: string;
|
|
68
|
+
totpEnrollmentInfo: {};
|
|
69
|
+
tenantId?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface StartTotpMfaEnrollmentResponse {
|
|
72
|
+
totpSessionInfo: {
|
|
73
|
+
sharedSecretKey: string;
|
|
74
|
+
verificationCodeLength: number;
|
|
75
|
+
hashingAlgorithm: string;
|
|
76
|
+
periodSec: number;
|
|
77
|
+
sessionInfo: string;
|
|
78
|
+
finalizeEnrollmentTime: number;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export declare function startEnrollTotpMfa(auth: AuthInternal, request: StartTotpMfaEnrollmentRequest): Promise<StartTotpMfaEnrollmentResponse>;
|
|
82
|
+
export interface TotpVerificationInfo {
|
|
83
|
+
sessionInfo: string;
|
|
84
|
+
verificationCode: string;
|
|
85
|
+
}
|
|
86
|
+
export interface FinalizeTotpMfaEnrollmentRequest {
|
|
87
|
+
idToken: string;
|
|
88
|
+
totpVerificationInfo: TotpVerificationInfo;
|
|
89
|
+
displayName?: string | null;
|
|
90
|
+
tenantId?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface FinalizeTotpMfaEnrollmentResponse extends FinalizeMfaResponse {
|
|
93
|
+
}
|
|
94
|
+
export declare function finalizeEnrollTotpMfa(auth: AuthInternal, request: FinalizeTotpMfaEnrollmentRequest): Promise<FinalizeTotpMfaEnrollmentResponse>;
|
|
61
95
|
export interface WithdrawMfaRequest {
|
|
62
96
|
idToken: string;
|
|
63
97
|
mfaEnrollmentId: string;
|
|
@@ -49,9 +49,20 @@ export interface FinalizePhoneMfaSignInRequest {
|
|
|
49
49
|
phoneVerificationInfo: SignInWithPhoneNumberRequest;
|
|
50
50
|
tenantId?: string;
|
|
51
51
|
}
|
|
52
|
+
export interface FinalizeTotpMfaSignInRequest {
|
|
53
|
+
mfaPendingCredential: string;
|
|
54
|
+
totpVerificationInfo: {
|
|
55
|
+
verificationCode: string;
|
|
56
|
+
};
|
|
57
|
+
tenantId?: string;
|
|
58
|
+
mfaEnrollmentId: string;
|
|
59
|
+
}
|
|
52
60
|
export interface FinalizePhoneMfaSignInResponse extends FinalizeMfaResponse {
|
|
53
61
|
}
|
|
62
|
+
export interface FinalizeTotpMfaSignInResponse extends FinalizeMfaResponse {
|
|
63
|
+
}
|
|
54
64
|
export declare function finalizeSignInPhoneMfa(auth: Auth, request: FinalizePhoneMfaSignInRequest): Promise<FinalizePhoneMfaSignInResponse>;
|
|
65
|
+
export declare function finalizeSignInTotpMfa(auth: Auth, request: FinalizeTotpMfaSignInRequest): Promise<FinalizeTotpMfaSignInResponse>;
|
|
55
66
|
/**
|
|
56
67
|
* @internal
|
|
57
68
|
*/
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { TotpMultiFactorAssertion, MultiFactorSession, FactorId } from '../../model/public_types';
|
|
18
|
+
import { AuthInternal } from '../../model/auth';
|
|
19
|
+
import { StartTotpMfaEnrollmentResponse, TotpVerificationInfo } from '../../api/account_management/mfa';
|
|
20
|
+
import { FinalizeMfaResponse } from '../../api/authentication/mfa';
|
|
21
|
+
import { MultiFactorAssertionImpl } from '../../mfa/mfa_assertion';
|
|
22
|
+
/**
|
|
23
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare class TotpMultiFactorGenerator {
|
|
28
|
+
/**
|
|
29
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
30
|
+
* the TOTP (time-based one-time password) second factor.
|
|
31
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
32
|
+
*
|
|
33
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
34
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
35
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
36
|
+
* {@link MultiFactorUser.enroll}.
|
|
37
|
+
*/
|
|
38
|
+
static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
39
|
+
/**
|
|
40
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
41
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
42
|
+
*
|
|
43
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
44
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
45
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
46
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
47
|
+
*/
|
|
48
|
+
static assertionForSignIn(enrollmentId: string, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
49
|
+
/**
|
|
50
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
51
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
52
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
53
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
54
|
+
*
|
|
55
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
56
|
+
* @returns A promise to {@link TotpSecret}.
|
|
57
|
+
*/
|
|
58
|
+
static generateSecret(session: MultiFactorSession): Promise<TotpSecret>;
|
|
59
|
+
/**
|
|
60
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
61
|
+
*/
|
|
62
|
+
static FACTOR_ID: FactorId;
|
|
63
|
+
}
|
|
64
|
+
export declare class TotpMultiFactorAssertionImpl extends MultiFactorAssertionImpl implements TotpMultiFactorAssertion {
|
|
65
|
+
readonly otp: string;
|
|
66
|
+
readonly enrollmentId?: string | undefined;
|
|
67
|
+
readonly secret?: TotpSecret | undefined;
|
|
68
|
+
constructor(otp: string, enrollmentId?: string | undefined, secret?: TotpSecret | undefined);
|
|
69
|
+
/** @internal */
|
|
70
|
+
static _fromSecret(secret: TotpSecret, otp: string): TotpMultiFactorAssertionImpl;
|
|
71
|
+
/** @internal */
|
|
72
|
+
static _fromEnrollmentId(enrollmentId: string, otp: string): TotpMultiFactorAssertionImpl;
|
|
73
|
+
/** @internal */
|
|
74
|
+
_finalizeEnroll(auth: AuthInternal, idToken: string, displayName?: string | null): Promise<FinalizeMfaResponse>;
|
|
75
|
+
/** @internal */
|
|
76
|
+
_finalizeSignIn(auth: AuthInternal, mfaPendingCredential: string): Promise<FinalizeMfaResponse>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
80
|
+
*
|
|
81
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
82
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export declare class TotpSecret {
|
|
86
|
+
private readonly sessionInfo;
|
|
87
|
+
private readonly auth;
|
|
88
|
+
/**
|
|
89
|
+
* Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
|
|
90
|
+
*/
|
|
91
|
+
readonly secretKey: string;
|
|
92
|
+
/**
|
|
93
|
+
* Hashing algorithm used.
|
|
94
|
+
*/
|
|
95
|
+
readonly hashingAlgorithm: string;
|
|
96
|
+
/**
|
|
97
|
+
* Length of the one-time passwords to be generated.
|
|
98
|
+
*/
|
|
99
|
+
readonly codeLength: number;
|
|
100
|
+
/**
|
|
101
|
+
* The interval (in seconds) when the OTP codes should change.
|
|
102
|
+
*/
|
|
103
|
+
readonly codeIntervalSeconds: number;
|
|
104
|
+
/**
|
|
105
|
+
* The timestamp (UTC string) by which TOTP enrollment should be completed.
|
|
106
|
+
*/
|
|
107
|
+
readonly enrollmentCompletionDeadline: string;
|
|
108
|
+
private constructor();
|
|
109
|
+
/** @internal */
|
|
110
|
+
static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret;
|
|
111
|
+
/** @internal */
|
|
112
|
+
_makeTotpVerificationInfo(otp: string): TotpVerificationInfo;
|
|
113
|
+
/**
|
|
114
|
+
* Returns a QR code URL as described in
|
|
115
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
116
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
117
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
118
|
+
*
|
|
119
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
120
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
121
|
+
* @returns A QR code URL string.
|
|
122
|
+
*/
|
|
123
|
+
generateQrCodeUrl(accountName?: string, issuer?: string): string;
|
|
124
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { FactorId, MultiFactorInfo, PhoneMultiFactorInfo } from '../model/public_types';
|
|
17
|
+
import { FactorId, MultiFactorInfo, PhoneMultiFactorInfo, TotpMultiFactorInfo } from '../model/public_types';
|
|
18
18
|
import { MfaEnrollment } from '../api/account_management/mfa';
|
|
19
19
|
import { AuthInternal } from '../model/auth';
|
|
20
20
|
export declare abstract class MultiFactorInfoImpl implements MultiFactorInfo {
|
|
@@ -30,3 +30,7 @@ export declare class PhoneMultiFactorInfoImpl extends MultiFactorInfoImpl implem
|
|
|
30
30
|
private constructor();
|
|
31
31
|
static _fromServerResponse(_auth: AuthInternal, enrollment: MfaEnrollment): PhoneMultiFactorInfoImpl;
|
|
32
32
|
}
|
|
33
|
+
export declare class TotpMultiFactorInfoImpl extends MultiFactorInfoImpl implements TotpMultiFactorInfo {
|
|
34
|
+
private constructor();
|
|
35
|
+
static _fromServerResponse(_auth: AuthInternal, enrollment: MfaEnrollment): TotpMultiFactorInfoImpl;
|
|
36
|
+
}
|
|
@@ -502,7 +502,8 @@ export interface AuthProvider {
|
|
|
502
502
|
*/
|
|
503
503
|
export declare const enum FactorId {
|
|
504
504
|
/** Phone as second factor */
|
|
505
|
-
PHONE = "phone"
|
|
505
|
+
PHONE = "phone",
|
|
506
|
+
TOTP = "totp"
|
|
506
507
|
}
|
|
507
508
|
/**
|
|
508
509
|
* A result from a phone number sign-in, link, or reauthenticate call.
|
|
@@ -609,6 +610,13 @@ export interface PhoneMultiFactorInfo extends MultiFactorInfo {
|
|
|
609
610
|
/** The phone number associated with the current second factor. */
|
|
610
611
|
readonly phoneNumber: string;
|
|
611
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* The subclass of the {@link MultiFactorInfo} interface for TOTP
|
|
615
|
+
* second factors. The `factorId` of this second factor is {@link FactorId}.TOTP.
|
|
616
|
+
* @public
|
|
617
|
+
*/
|
|
618
|
+
export interface TotpMultiFactorInfo extends MultiFactorInfo {
|
|
619
|
+
}
|
|
612
620
|
/**
|
|
613
621
|
* The class used to facilitate recovery from {@link MultiFactorError} when a user needs to
|
|
614
622
|
* provide a second factor to sign in.
|
|
@@ -1160,3 +1168,12 @@ export interface Dependencies {
|
|
|
1160
1168
|
*/
|
|
1161
1169
|
errorMap?: AuthErrorMap;
|
|
1162
1170
|
}
|
|
1171
|
+
/**
|
|
1172
|
+
* The class for asserting ownership of a TOTP second factor. Provided by
|
|
1173
|
+
* {@link TotpMultiFactorGenerator.assertionForEnrollment} and
|
|
1174
|
+
* {@link TotpMultiFactorGenerator.assertionForSignIn}.
|
|
1175
|
+
*
|
|
1176
|
+
* @public
|
|
1177
|
+
*/
|
|
1178
|
+
export interface TotpMultiFactorAssertion extends MultiFactorAssertion {
|
|
1179
|
+
}
|
|
@@ -18,3 +18,6 @@ import { Auth } from '../../../src/model/public_types';
|
|
|
18
18
|
export declare function randomEmail(): string;
|
|
19
19
|
export declare function getTestInstance(requireEmulator?: boolean): Auth;
|
|
20
20
|
export declare function cleanUpTestInstance(auth: Auth): Promise<void>;
|
|
21
|
+
export declare function getTotpCode(sharedSecretKey: string, periodSec: number, verificationCodeLength: number, timestamp: Date): string;
|
|
22
|
+
export declare const email = "totpuser-donotdelete@test.com";
|
|
23
|
+
export declare const incorrectTotpCode = "1000000";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
@@ -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.
|
|
@@ -1035,7 +1036,10 @@ function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
|
|
|
1035
1036
|
if (e_1 instanceof FirebaseError) {
|
|
1036
1037
|
throw e_1;
|
|
1037
1038
|
}
|
|
1038
|
-
|
|
1039
|
+
// Changing this to a different error code will log user out when there is a network error
|
|
1040
|
+
// because we treat any error other than NETWORK_REQUEST_FAILED as token is invalid.
|
|
1041
|
+
// https://github.com/firebase/firebase-js-sdk/blob/4fbc73610d70be4e0852e7de63a39cb7897e8546/packages/auth/src/core/auth/auth_impl.ts#L309-L316
|
|
1042
|
+
_fail(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */, { 'message': String(e_1) });
|
|
1039
1043
|
return [3 /*break*/, 5];
|
|
1040
1044
|
case 5: return [2 /*return*/];
|
|
1041
1045
|
}
|
|
@@ -5698,6 +5702,9 @@ var MultiFactorInfoImpl = /** @class */ (function () {
|
|
|
5698
5702
|
if ('phoneInfo' in enrollment) {
|
|
5699
5703
|
return PhoneMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
5700
5704
|
}
|
|
5705
|
+
else if ('totpInfo' in enrollment) {
|
|
5706
|
+
return TotpMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
5707
|
+
}
|
|
5701
5708
|
return _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
5702
5709
|
};
|
|
5703
5710
|
return MultiFactorInfoImpl;
|
|
@@ -5713,6 +5720,16 @@ var PhoneMultiFactorInfoImpl = /** @class */ (function (_super) {
|
|
|
5713
5720
|
return new PhoneMultiFactorInfoImpl(enrollment);
|
|
5714
5721
|
};
|
|
5715
5722
|
return PhoneMultiFactorInfoImpl;
|
|
5723
|
+
}(MultiFactorInfoImpl));
|
|
5724
|
+
var TotpMultiFactorInfoImpl = /** @class */ (function (_super) {
|
|
5725
|
+
__extends(TotpMultiFactorInfoImpl, _super);
|
|
5726
|
+
function TotpMultiFactorInfoImpl(response) {
|
|
5727
|
+
return _super.call(this, "totp" /* FactorId.TOTP */, response) || this;
|
|
5728
|
+
}
|
|
5729
|
+
TotpMultiFactorInfoImpl._fromServerResponse = function (_auth, enrollment) {
|
|
5730
|
+
return new TotpMultiFactorInfoImpl(enrollment);
|
|
5731
|
+
};
|
|
5732
|
+
return TotpMultiFactorInfoImpl;
|
|
5716
5733
|
}(MultiFactorInfoImpl));
|
|
5717
5734
|
|
|
5718
5735
|
/**
|
|
@@ -6941,6 +6958,12 @@ function startEnrollPhoneMfa(auth, request) {
|
|
|
6941
6958
|
function finalizeEnrollPhoneMfa(auth, request) {
|
|
6942
6959
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6943
6960
|
}
|
|
6961
|
+
function startEnrollTotpMfa(auth, request) {
|
|
6962
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:start" /* Endpoint.START_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6963
|
+
}
|
|
6964
|
+
function finalizeEnrollTotpMfa(auth, request) {
|
|
6965
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6966
|
+
}
|
|
6944
6967
|
function withdrawMfa(auth, request) {
|
|
6945
6968
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:withdraw" /* Endpoint.WITHDRAW_MFA */, _addTidIfNecessary(auth, request));
|
|
6946
6969
|
}
|
|
@@ -8348,6 +8371,9 @@ function startSignInPhoneMfa(auth, request) {
|
|
|
8348
8371
|
}
|
|
8349
8372
|
function finalizeSignInPhoneMfa(auth, request) {
|
|
8350
8373
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
8374
|
+
}
|
|
8375
|
+
function finalizeSignInTotpMfa(auth, request) {
|
|
8376
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
8351
8377
|
}
|
|
8352
8378
|
|
|
8353
8379
|
/**
|
|
@@ -11101,8 +11127,181 @@ var PhoneMultiFactorGenerator = /** @class */ (function () {
|
|
|
11101
11127
|
return PhoneMultiFactorGenerator;
|
|
11102
11128
|
}());
|
|
11103
11129
|
|
|
11130
|
+
/**
|
|
11131
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
11132
|
+
*
|
|
11133
|
+
* @public
|
|
11134
|
+
*/
|
|
11135
|
+
var TotpMultiFactorGenerator = /** @class */ (function () {
|
|
11136
|
+
function TotpMultiFactorGenerator() {
|
|
11137
|
+
}
|
|
11138
|
+
/**
|
|
11139
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
11140
|
+
* the TOTP (time-based one-time password) second factor.
|
|
11141
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
11142
|
+
*
|
|
11143
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
11144
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
11145
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
11146
|
+
* {@link MultiFactorUser.enroll}.
|
|
11147
|
+
*/
|
|
11148
|
+
TotpMultiFactorGenerator.assertionForEnrollment = function (secret, oneTimePassword) {
|
|
11149
|
+
return TotpMultiFactorAssertionImpl._fromSecret(secret, oneTimePassword);
|
|
11150
|
+
};
|
|
11151
|
+
/**
|
|
11152
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
11153
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
11154
|
+
*
|
|
11155
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
11156
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
11157
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
11158
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
11159
|
+
*/
|
|
11160
|
+
TotpMultiFactorGenerator.assertionForSignIn = function (enrollmentId, oneTimePassword) {
|
|
11161
|
+
return TotpMultiFactorAssertionImpl._fromEnrollmentId(enrollmentId, oneTimePassword);
|
|
11162
|
+
};
|
|
11163
|
+
/**
|
|
11164
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
11165
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
11166
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
11167
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
11168
|
+
*
|
|
11169
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
11170
|
+
* @returns A promise to {@link TotpSecret}.
|
|
11171
|
+
*/
|
|
11172
|
+
TotpMultiFactorGenerator.generateSecret = function (session) {
|
|
11173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11174
|
+
var mfaSession, response;
|
|
11175
|
+
return __generator(this, function (_a) {
|
|
11176
|
+
switch (_a.label) {
|
|
11177
|
+
case 0:
|
|
11178
|
+
mfaSession = session;
|
|
11179
|
+
_assert(typeof mfaSession.auth !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
11180
|
+
return [4 /*yield*/, startEnrollTotpMfa(mfaSession.auth, {
|
|
11181
|
+
idToken: mfaSession.credential,
|
|
11182
|
+
totpEnrollmentInfo: {}
|
|
11183
|
+
})];
|
|
11184
|
+
case 1:
|
|
11185
|
+
response = _a.sent();
|
|
11186
|
+
return [2 /*return*/, TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.auth)];
|
|
11187
|
+
}
|
|
11188
|
+
});
|
|
11189
|
+
});
|
|
11190
|
+
};
|
|
11191
|
+
/**
|
|
11192
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
11193
|
+
*/
|
|
11194
|
+
TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
|
|
11195
|
+
return TotpMultiFactorGenerator;
|
|
11196
|
+
}());
|
|
11197
|
+
var TotpMultiFactorAssertionImpl = /** @class */ (function (_super) {
|
|
11198
|
+
__extends(TotpMultiFactorAssertionImpl, _super);
|
|
11199
|
+
function TotpMultiFactorAssertionImpl(otp, enrollmentId, secret) {
|
|
11200
|
+
var _this = _super.call(this, "totp" /* FactorId.TOTP */) || this;
|
|
11201
|
+
_this.otp = otp;
|
|
11202
|
+
_this.enrollmentId = enrollmentId;
|
|
11203
|
+
_this.secret = secret;
|
|
11204
|
+
return _this;
|
|
11205
|
+
}
|
|
11206
|
+
/** @internal */
|
|
11207
|
+
TotpMultiFactorAssertionImpl._fromSecret = function (secret, otp) {
|
|
11208
|
+
return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
|
|
11209
|
+
};
|
|
11210
|
+
/** @internal */
|
|
11211
|
+
TotpMultiFactorAssertionImpl._fromEnrollmentId = function (enrollmentId, otp) {
|
|
11212
|
+
return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
|
|
11213
|
+
};
|
|
11214
|
+
/** @internal */
|
|
11215
|
+
TotpMultiFactorAssertionImpl.prototype._finalizeEnroll = function (auth, idToken, displayName) {
|
|
11216
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11217
|
+
return __generator(this, function (_a) {
|
|
11218
|
+
_assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
11219
|
+
return [2 /*return*/, finalizeEnrollTotpMfa(auth, {
|
|
11220
|
+
idToken: idToken,
|
|
11221
|
+
displayName: displayName,
|
|
11222
|
+
totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
|
|
11223
|
+
})];
|
|
11224
|
+
});
|
|
11225
|
+
});
|
|
11226
|
+
};
|
|
11227
|
+
/** @internal */
|
|
11228
|
+
TotpMultiFactorAssertionImpl.prototype._finalizeSignIn = function (auth, mfaPendingCredential) {
|
|
11229
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11230
|
+
var totpVerificationInfo;
|
|
11231
|
+
return __generator(this, function (_a) {
|
|
11232
|
+
_assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
11233
|
+
totpVerificationInfo = { verificationCode: this.otp };
|
|
11234
|
+
return [2 /*return*/, finalizeSignInTotpMfa(auth, {
|
|
11235
|
+
mfaPendingCredential: mfaPendingCredential,
|
|
11236
|
+
mfaEnrollmentId: this.enrollmentId,
|
|
11237
|
+
totpVerificationInfo: totpVerificationInfo
|
|
11238
|
+
})];
|
|
11239
|
+
});
|
|
11240
|
+
});
|
|
11241
|
+
};
|
|
11242
|
+
return TotpMultiFactorAssertionImpl;
|
|
11243
|
+
}(MultiFactorAssertionImpl));
|
|
11244
|
+
/**
|
|
11245
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
11246
|
+
*
|
|
11247
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
11248
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
11249
|
+
* @public
|
|
11250
|
+
*/
|
|
11251
|
+
var TotpSecret = /** @class */ (function () {
|
|
11252
|
+
// The public members are declared outside the constructor so the docs can be generated.
|
|
11253
|
+
function TotpSecret(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
|
|
11254
|
+
this.sessionInfo = sessionInfo;
|
|
11255
|
+
this.auth = auth;
|
|
11256
|
+
this.secretKey = secretKey;
|
|
11257
|
+
this.hashingAlgorithm = hashingAlgorithm;
|
|
11258
|
+
this.codeLength = codeLength;
|
|
11259
|
+
this.codeIntervalSeconds = codeIntervalSeconds;
|
|
11260
|
+
this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
|
|
11261
|
+
}
|
|
11262
|
+
/** @internal */
|
|
11263
|
+
TotpSecret._fromStartTotpMfaEnrollmentResponse = function (response, auth) {
|
|
11264
|
+
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);
|
|
11265
|
+
};
|
|
11266
|
+
/** @internal */
|
|
11267
|
+
TotpSecret.prototype._makeTotpVerificationInfo = function (otp) {
|
|
11268
|
+
return { sessionInfo: this.sessionInfo, verificationCode: otp };
|
|
11269
|
+
};
|
|
11270
|
+
/**
|
|
11271
|
+
* Returns a QR code URL as described in
|
|
11272
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
11273
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
11274
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
11275
|
+
*
|
|
11276
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
11277
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
11278
|
+
* @returns A QR code URL string.
|
|
11279
|
+
*/
|
|
11280
|
+
TotpSecret.prototype.generateQrCodeUrl = function (accountName, issuer) {
|
|
11281
|
+
var _a;
|
|
11282
|
+
var useDefaults = false;
|
|
11283
|
+
if (_isEmptyString(accountName) || _isEmptyString(issuer)) {
|
|
11284
|
+
useDefaults = true;
|
|
11285
|
+
}
|
|
11286
|
+
if (useDefaults) {
|
|
11287
|
+
if (_isEmptyString(accountName)) {
|
|
11288
|
+
accountName = ((_a = this.auth.currentUser) === null || _a === void 0 ? void 0 : _a.email) || 'unknownuser';
|
|
11289
|
+
}
|
|
11290
|
+
if (_isEmptyString(issuer)) {
|
|
11291
|
+
issuer = this.auth.name;
|
|
11292
|
+
}
|
|
11293
|
+
}
|
|
11294
|
+
return "otpauth://totp/".concat(issuer, ":").concat(accountName, "?secret=").concat(this.secretKey, "&issuer=").concat(issuer, "&algorithm=").concat(this.hashingAlgorithm, "&digits=").concat(this.codeLength);
|
|
11295
|
+
};
|
|
11296
|
+
return TotpSecret;
|
|
11297
|
+
}());
|
|
11298
|
+
/** @internal */
|
|
11299
|
+
function _isEmptyString(input) {
|
|
11300
|
+
return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
|
|
11301
|
+
}
|
|
11302
|
+
|
|
11104
11303
|
var name = "@firebase/auth";
|
|
11105
|
-
var version = "0.21.
|
|
11304
|
+
var version = "0.21.6-20230329040242";
|
|
11106
11305
|
|
|
11107
11306
|
/**
|
|
11108
11307
|
* @license
|
|
@@ -11359,5 +11558,5 @@ function getAuth(app) {
|
|
|
11359
11558
|
}
|
|
11360
11559
|
registerAuth("Browser" /* ClientPlatform.BROWSER */);
|
|
11361
11560
|
|
|
11362
|
-
export {
|
|
11363
|
-
//# sourceMappingURL=index-
|
|
11561
|
+
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 };
|
|
11562
|
+
//# sourceMappingURL=index-14d0c8cb.js.map
|