Skip to content

Commit 04dcdbb

Browse files
authored
Fix MFA endpoint names to be mfa provider-agnostic. (#6572)
We will have other MFA providers than phone in the near future.
1 parent ca1b0c8 commit 04dcdbb

File tree

8 files changed

+22
-25
lines changed

8 files changed

+22
-25
lines changed

packages/auth/src/api/account_management/mfa.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('api/account_management/startEnrollPhoneMfa', () => {
5252
afterEach(mockFetch.tearDown);
5353

5454
it('should POST to the correct endpoint', async () => {
55-
const mock = mockEndpoint(Endpoint.START_PHONE_MFA_ENROLLMENT, {
55+
const mock = mockEndpoint(Endpoint.START_MFA_ENROLLMENT, {
5656
phoneSessionInfo: {
5757
sessionInfo: 'session-info'
5858
}
@@ -72,7 +72,7 @@ describe('api/account_management/startEnrollPhoneMfa', () => {
7272

7373
it('should handle errors', async () => {
7474
const mock = mockEndpoint(
75-
Endpoint.START_PHONE_MFA_ENROLLMENT,
75+
Endpoint.START_MFA_ENROLLMENT,
7676
{
7777
error: {
7878
code: 400,
@@ -116,7 +116,7 @@ describe('api/account_management/finalizeEnrollPhoneMfa', () => {
116116
afterEach(mockFetch.tearDown);
117117

118118
it('should POST to the correct endpoint', async () => {
119-
const mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT, {
119+
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_ENROLLMENT, {
120120
idToken: 'id-token',
121121
refreshToken: 'refresh-token'
122122
});
@@ -136,7 +136,7 @@ describe('api/account_management/finalizeEnrollPhoneMfa', () => {
136136

137137
it('should handle errors', async () => {
138138
const mock = mockEndpoint(
139-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
139+
Endpoint.FINALIZE_MFA_ENROLLMENT,
140140
{
141141
error: {
142142
code: 400,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function startEnrollPhoneMfa(
7171
>(
7272
auth,
7373
HttpMethod.POST,
74-
Endpoint.START_PHONE_MFA_ENROLLMENT,
74+
Endpoint.START_MFA_ENROLLMENT,
7575
_addTidIfNecessary(auth, request)
7676
);
7777
}
@@ -96,7 +96,7 @@ export function finalizeEnrollPhoneMfa(
9696
>(
9797
auth,
9898
HttpMethod.POST,
99-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
99+
Endpoint.FINALIZE_MFA_ENROLLMENT,
100100
_addTidIfNecessary(auth, request)
101101
);
102102
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('api/authentication/startSignInPhoneMfa', () => {
4848
afterEach(mockFetch.tearDown);
4949

5050
it('should POST to the correct endpoint', async () => {
51-
const mock = mockEndpoint(Endpoint.START_PHONE_MFA_SIGN_IN, {
51+
const mock = mockEndpoint(Endpoint.START_MFA_SIGN_IN, {
5252
phoneResponseInfo: {
5353
sessionInfo: 'session-info'
5454
}
@@ -68,7 +68,7 @@ describe('api/authentication/startSignInPhoneMfa', () => {
6868

6969
it('should handle errors', async () => {
7070
const mock = mockEndpoint(
71-
Endpoint.START_PHONE_MFA_SIGN_IN,
71+
Endpoint.START_MFA_SIGN_IN,
7272
{
7373
error: {
7474
code: 400,
@@ -112,7 +112,7 @@ describe('api/authentication/finalizeSignInPhoneMfa', () => {
112112
afterEach(mockFetch.tearDown);
113113

114114
it('should POST to the correct endpoint', async () => {
115-
const mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_SIGN_IN, {
115+
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, {
116116
idToken: 'id-token',
117117
refreshToken: 'refresh-token'
118118
});
@@ -132,7 +132,7 @@ describe('api/authentication/finalizeSignInPhoneMfa', () => {
132132

133133
it('should handle errors', async () => {
134134
const mock = mockEndpoint(
135-
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
135+
Endpoint.FINALIZE_MFA_SIGN_IN,
136136
{
137137
error: {
138138
code: 400,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function startSignInPhoneMfa(
6868
>(
6969
auth,
7070
HttpMethod.POST,
71-
Endpoint.START_PHONE_MFA_SIGN_IN,
71+
Endpoint.START_MFA_SIGN_IN,
7272
_addTidIfNecessary(auth, request)
7373
);
7474
}
@@ -91,7 +91,7 @@ export function finalizeSignInPhoneMfa(
9191
>(
9292
auth,
9393
HttpMethod.POST,
94-
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
94+
Endpoint.FINALIZE_MFA_SIGN_IN,
9595
_addTidIfNecessary(auth, request)
9696
);
9797
}

packages/auth/src/api/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ export const enum Endpoint {
6060
SET_ACCOUNT_INFO = '/v1/accounts:update',
6161
GET_ACCOUNT_INFO = '/v1/accounts:lookup',
6262
GET_RECAPTCHA_PARAM = '/v1/recaptchaParams',
63-
START_PHONE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:start',
64-
FINALIZE_PHONE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:finalize',
65-
START_PHONE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:start',
66-
FINALIZE_PHONE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:finalize',
63+
START_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:start',
64+
FINALIZE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:finalize',
65+
START_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:start',
66+
FINALIZE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:finalize',
6767
WITHDRAW_MFA = '/v2/accounts/mfaEnrollment:withdraw',
6868
GET_PROJECT_CONFIG = '/v1/projects'
6969
}

packages/auth/src/mfa/mfa_resolver.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('core/mfa/mfa_resolver/MultiFactorResolver', () => {
114114
};
115115

116116
beforeEach(() => {
117-
mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_SIGN_IN, {
117+
mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, {
118118
idToken: finalIdToken,
119119
refreshToken: 'final-refresh-token'
120120
});

packages/auth/src/platform_browser/mfa/assertions/phone.test.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('platform_browser/mfa/phone', () => {
6363

6464
it('should finalize the MFA enrollment', async () => {
6565
const mock = mockEndpoint(
66-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
66+
Endpoint.FINALIZE_MFA_ENROLLMENT,
6767
serverResponse
6868
);
6969
const response = await assertion._process(auth, session);
@@ -80,7 +80,7 @@ describe('platform_browser/mfa/phone', () => {
8080
context('with display name', () => {
8181
it('should set the display name', async () => {
8282
const mock = mockEndpoint(
83-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
83+
Endpoint.FINALIZE_MFA_ENROLLMENT,
8484
serverResponse
8585
);
8686
const response = await assertion._process(
@@ -109,10 +109,7 @@ describe('platform_browser/mfa/phone', () => {
109109
});
110110

111111
it('should finalize the MFA sign in', async () => {
112-
const mock = mockEndpoint(
113-
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
114-
serverResponse
115-
);
112+
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, serverResponse);
116113
const response = await assertion._process(auth, session);
117114
expect(response).to.eql(serverResponse);
118115
expect(mock.calls[0].request).to.eql({

packages/auth/src/platform_browser/strategies/phone.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe('platform_browser/strategies/phone', () => {
323323
});
324324

325325
it('works with an enrollment flow', async () => {
326-
const endpoint = mockEndpoint(Endpoint.START_PHONE_MFA_ENROLLMENT, {
326+
const endpoint = mockEndpoint(Endpoint.START_MFA_ENROLLMENT, {
327327
phoneSessionInfo: {
328328
sessionInfo: 'session-info'
329329
}
@@ -345,7 +345,7 @@ describe('platform_browser/strategies/phone', () => {
345345
});
346346

347347
it('works when completing the sign in flow', async () => {
348-
const endpoint = mockEndpoint(Endpoint.START_PHONE_MFA_SIGN_IN, {
348+
const endpoint = mockEndpoint(Endpoint.START_MFA_SIGN_IN, {
349349
phoneResponseInfo: {
350350
sessionInfo: 'session-info'
351351
}

0 commit comments

Comments
 (0)