From 9684994bb2c544910282c330ac9dc0e346672383 Mon Sep 17 00:00:00 2001 From: Akhtar Zaman Date: Sat, 11 Apr 2026 21:50:28 -0400 Subject: [PATCH 1/2] fix: apply deepCamelCase to MFA challenge response for correct oob_code mapping The /mfa/challenge endpoint returns snake_case keys (oob_code, challenge_type, binding_method) but multifactorChallenge() was casting the raw response directly to MfaChallengeResponse without conversion. This caused oobCode to be undefined while the actual data was on the oob_code key. Apply deepCamelCase() to the response, consistent with all other API methods in the orchestrator (userInfo, createUser, etc.). --- src/core/services/AuthenticationOrchestrator.ts | 3 +-- .../services/__tests__/AuthenticationOrchestrator.spec.ts | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/services/AuthenticationOrchestrator.ts b/src/core/services/AuthenticationOrchestrator.ts index e8f38883..2376142f 100644 --- a/src/core/services/AuthenticationOrchestrator.ts +++ b/src/core/services/AuthenticationOrchestrator.ts @@ -369,8 +369,7 @@ export class AuthenticationOrchestrator implements IAuthenticationProvider { headers ); if (!response.ok) throw AuthError.fromResponse(response, json); - // The response is already camelCased by the API, so we can cast it directly. - return json as MfaChallengeResponse; + return deepCamelCase(json); } async revoke(parameters: RevokeOptions): Promise { diff --git a/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts b/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts index 12be2f23..43065e30 100644 --- a/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts +++ b/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts @@ -626,10 +626,10 @@ describe('AuthenticationOrchestrator', () => { ); }); - it('multifactorChallenge should send correct payload and return response', async () => { - const challengeResponse = { challengeType: 'oob', oobCode: 'abc' }; + it('multifactorChallenge should send correct payload and return camelCased response', async () => { + const apiResponse = { challenge_type: 'oob', oob_code: 'abc' }; mockHttpClientInstance.post.mockResolvedValueOnce({ - json: challengeResponse, + json: apiResponse, response: new Response(null, { status: 200 }), }); const result = await orchestrator.multifactorChallenge({ @@ -648,7 +648,7 @@ describe('AuthenticationOrchestrator', () => { }, undefined ); - expect(result).toEqual(challengeResponse); + expect(result).toEqual({ challengeType: 'oob', oobCode: 'abc' }); }); }); From 10809519aee0c571d705337db51827579ae45736 Mon Sep 17 00:00:00 2001 From: Akhtar Zaman Date: Sat, 11 Apr 2026 21:58:37 -0400 Subject: [PATCH 2/2] revert test mock to original camelCase format --- .../services/__tests__/AuthenticationOrchestrator.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts b/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts index 43065e30..12be2f23 100644 --- a/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts +++ b/src/core/services/__tests__/AuthenticationOrchestrator.spec.ts @@ -626,10 +626,10 @@ describe('AuthenticationOrchestrator', () => { ); }); - it('multifactorChallenge should send correct payload and return camelCased response', async () => { - const apiResponse = { challenge_type: 'oob', oob_code: 'abc' }; + it('multifactorChallenge should send correct payload and return response', async () => { + const challengeResponse = { challengeType: 'oob', oobCode: 'abc' }; mockHttpClientInstance.post.mockResolvedValueOnce({ - json: apiResponse, + json: challengeResponse, response: new Response(null, { status: 200 }), }); const result = await orchestrator.multifactorChallenge({ @@ -648,7 +648,7 @@ describe('AuthenticationOrchestrator', () => { }, undefined ); - expect(result).toEqual({ challengeType: 'oob', oobCode: 'abc' }); + expect(result).toEqual(challengeResponse); }); });