Skip to content

Commit cfac8e1

Browse files
committed
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.).
1 parent 1440ef8 commit cfac8e1

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/core/services/AuthenticationOrchestrator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@ export class AuthenticationOrchestrator implements IAuthenticationProvider {
369369
headers
370370
);
371371
if (!response.ok) throw AuthError.fromResponse(response, json);
372-
// The response is already camelCased by the API, so we can cast it directly.
373-
return json as MfaChallengeResponse;
372+
return deepCamelCase<MfaChallengeResponse>(json);
374373
}
375374

376375
async revoke(parameters: RevokeOptions): Promise<void> {

src/core/services/__tests__/AuthenticationOrchestrator.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,10 @@ describe('AuthenticationOrchestrator', () => {
626626
);
627627
});
628628

629-
it('multifactorChallenge should send correct payload and return response', async () => {
630-
const challengeResponse = { challengeType: 'oob', oobCode: 'abc' };
629+
it('multifactorChallenge should send correct payload and return camelCased response', async () => {
630+
const apiResponse = { challenge_type: 'oob', oob_code: 'abc' };
631631
mockHttpClientInstance.post.mockResolvedValueOnce({
632-
json: challengeResponse,
632+
json: apiResponse,
633633
response: new Response(null, { status: 200 }),
634634
});
635635
const result = await orchestrator.multifactorChallenge({
@@ -648,7 +648,7 @@ describe('AuthenticationOrchestrator', () => {
648648
},
649649
undefined
650650
);
651-
expect(result).toEqual(challengeResponse);
651+
expect(result).toEqual({ challengeType: 'oob', oobCode: 'abc' });
652652
});
653653
});
654654

0 commit comments

Comments
 (0)