Skip to content

Commit f17e779

Browse files
authored
Merge 188c2cd into 57c32b9
2 parents 57c32b9 + 188c2cd commit f17e779

File tree

3 files changed

+8
-57
lines changed

3 files changed

+8
-57
lines changed

packages/auth/src/api/authentication/mfa.ts

+3-29
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,13 @@ export interface StartPhoneMfaSignInRequest {
5151
};
5252
tenantId?: string;
5353
}
54-
export interface StartTotpMfaSignInRequest {
55-
mfaPendingCredential: string;
56-
mfaEnrollmentId: string;
57-
totpSignInInfo: {
58-
verificationCode: string;
59-
};
60-
tenantId?: string;
61-
}
6254

6355
export interface StartPhoneMfaSignInResponse {
6456
phoneResponseInfo: {
6557
sessionInfo: string;
6658
};
6759
}
6860

69-
export interface StartTotpMfaSignInResponse {
70-
totpSignInInfo: {
71-
verificationCode: string;
72-
};
73-
}
74-
7561
export function startSignInPhoneMfa(
7662
auth: Auth,
7763
request: StartPhoneMfaSignInRequest
@@ -87,27 +73,15 @@ export function startSignInPhoneMfa(
8773
);
8874
}
8975

90-
export function startSignInTotpMfa(
91-
auth: Auth,
92-
request: StartTotpMfaSignInRequest
93-
): Promise<StartTotpMfaSignInResponse> {
94-
return _performApiRequest<
95-
StartTotpMfaSignInRequest,
96-
StartTotpMfaSignInResponse
97-
>(
98-
auth,
99-
HttpMethod.POST,
100-
Endpoint.START_MFA_SIGN_IN,
101-
_addTidIfNecessary(auth, request)
102-
);
103-
}
104-
10576
export interface FinalizePhoneMfaSignInRequest {
10677
mfaPendingCredential: string;
10778
phoneVerificationInfo: SignInWithPhoneNumberRequest;
10879
tenantId?: string;
10980
}
11081

82+
// TOTP MFA Sign in only has a finalize phase. Phone MFA has a start phase to initiate sending an
83+
// SMS and a finalize phase to complete sign in. With TOTP, the user already has the OTP in the
84+
// TOTP/Authenticator app.
11185
export interface FinalizeTotpMfaSignInRequest {
11286
mfaPendingCredential: string;
11387
totpVerificationInfo: { verificationCode: string };

packages/auth/src/mfa/assertions/totp.test.ts

+5-27
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ import * as mockFetch from '../../../test/helpers/mock_fetch';
2424
import { Endpoint } from '../../api';
2525
import { MultiFactorSessionImpl } from '../../mfa/mfa_session';
2626
import { StartTotpMfaEnrollmentResponse } from '../../api/account_management/mfa';
27-
import {
28-
FinalizeMfaResponse,
29-
StartTotpMfaSignInResponse
30-
} from '../../api/authentication/mfa';
27+
import { FinalizeMfaResponse } from '../../api/authentication/mfa';
3128
import {
3229
TotpMultiFactorAssertionImpl,
3330
TotpMultiFactorGenerator,
@@ -215,7 +212,6 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
215212
describe('Testing signin Flow', () => {
216213
let auth: TestAuth;
217214
let assertion: MultiFactorAssertionImpl;
218-
let totpSignInResponse: StartTotpMfaSignInResponse;
219215
let session: MultiFactorSessionImpl;
220216
beforeEach(async () => {
221217
mockFetch.setUp();
@@ -227,24 +223,18 @@ describe('Testing signin Flow', () => {
227223
afterEach(mockFetch.tearDown);
228224

229225
it('should finalize mfa signin for totp', async () => {
230-
totpSignInResponse = {
231-
verificationCode: '123456',
226+
const mockResponse: FinalizeMfaResponse = {
232227
idToken: 'final-id-token',
233228
refreshToken: 'refresh-token'
234-
} as any;
229+
};
230+
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, mockResponse);
235231
assertion = TotpMultiFactorGenerator.assertionForSignIn(
236232
'enrollment-id',
237233
'123456'
238234
) as any;
239-
240-
const mock = mockEndpoint(
241-
Endpoint.FINALIZE_MFA_SIGN_IN,
242-
totpSignInResponse
243-
);
244-
245235
const response = await assertion._process(auth, session);
246236

247-
expect(response).to.eql(totpSignInResponse);
237+
expect(response).to.eql(mockResponse);
248238

249239
expect(mock.calls[0].request).to.eql({
250240
mfaPendingCredential: 'mfa-pending-credential',
@@ -256,12 +246,6 @@ describe('Testing signin Flow', () => {
256246
});
257247

258248
it('should throw Firebase Error if enrollment-id is undefined', async () => {
259-
let _response: FinalizeMfaResponse;
260-
totpSignInResponse = {
261-
verificationCode: '123456',
262-
idToken: 'final-id-token',
263-
refreshToken: 'refresh-token'
264-
} as any;
265249
assertion = TotpMultiFactorGenerator.assertionForSignIn(
266250
undefined as any,
267251
'123456'
@@ -273,12 +257,6 @@ describe('Testing signin Flow', () => {
273257
});
274258

275259
it('should throw Firebase Error if otp is undefined', async () => {
276-
let _response: FinalizeMfaResponse;
277-
totpSignInResponse = {
278-
verificationCode: '123456',
279-
idToken: 'final-id-token',
280-
refreshToken: 'refresh-token'
281-
} as any;
282260
assertion = TotpMultiFactorGenerator.assertionForSignIn(
283261
'enrollment-id',
284262
undefined as any

packages/auth/src/mfa/mfa_info.ts

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export abstract class MultiFactorInfoImpl implements MultiFactorInfo {
4848
if ('phoneInfo' in enrollment) {
4949
return PhoneMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
5050
} else if ('totpInfo' in enrollment) {
51-
// TODO(prameshj) ensure that this field is set by the backend once the tracking bug is fixed.
5251
return TotpMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
5352
}
5453
return _fail(auth, AuthErrorCode.INTERNAL_ERROR);

0 commit comments

Comments
 (0)