Skip to content

Commit 0232c0e

Browse files
committed
remove startMfaSignIn step for TOTP.
TOTP only needs a finalize step.
1 parent 57c32b9 commit 0232c0e

File tree

3 files changed

+10
-54
lines changed

3 files changed

+10
-54
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

+7-24
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { MultiFactorSessionImpl } from '../../mfa/mfa_session';
2626
import { StartTotpMfaEnrollmentResponse } from '../../api/account_management/mfa';
2727
import {
2828
FinalizeMfaResponse,
29-
StartTotpMfaSignInResponse
3029
} from '../../api/authentication/mfa';
3130
import {
3231
TotpMultiFactorAssertionImpl,
@@ -215,7 +214,6 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
215214
describe('Testing signin Flow', () => {
216215
let auth: TestAuth;
217216
let assertion: MultiFactorAssertionImpl;
218-
let totpSignInResponse: StartTotpMfaSignInResponse;
219217
let session: MultiFactorSessionImpl;
220218
beforeEach(async () => {
221219
mockFetch.setUp();
@@ -227,24 +225,21 @@ describe('Testing signin Flow', () => {
227225
afterEach(mockFetch.tearDown);
228226

229227
it('should finalize mfa signin for totp', async () => {
230-
totpSignInResponse = {
231-
verificationCode: '123456',
228+
const mockResponse: FinalizeMfaResponse = {
232229
idToken: 'final-id-token',
233230
refreshToken: 'refresh-token'
234-
} as any;
231+
};
232+
const mock = mockEndpoint(
233+
Endpoint.FINALIZE_MFA_SIGN_IN,
234+
mockResponse
235+
);
235236
assertion = TotpMultiFactorGenerator.assertionForSignIn(
236237
'enrollment-id',
237238
'123456'
238239
) as any;
239-
240-
const mock = mockEndpoint(
241-
Endpoint.FINALIZE_MFA_SIGN_IN,
242-
totpSignInResponse
243-
);
244-
245240
const response = await assertion._process(auth, session);
246241

247-
expect(response).to.eql(totpSignInResponse);
242+
expect(response).to.eql(mockResponse);
248243

249244
expect(mock.calls[0].request).to.eql({
250245
mfaPendingCredential: 'mfa-pending-credential',
@@ -256,12 +251,6 @@ describe('Testing signin Flow', () => {
256251
});
257252

258253
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;
265254
assertion = TotpMultiFactorGenerator.assertionForSignIn(
266255
undefined as any,
267256
'123456'
@@ -273,12 +262,6 @@ describe('Testing signin Flow', () => {
273262
});
274263

275264
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;
282265
assertion = TotpMultiFactorGenerator.assertionForSignIn(
283266
'enrollment-id',
284267
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)