Skip to content

Commit e183833

Browse files
mikehardyjoehan
andauthored
fix(emulator, auth): allow SMS MFA finalization with obfuscated number (#9062)
* fix(emulator, auth): allow SMS MFA finalization with obfuscated number This works in practice against cloud auth but fails on the emulator. The emulator should succeed if cloud auth succeeds * Update src/emulator/auth/operations.ts Co-authored-by: Mike Hardy <[email protected]> * Fix buggy merge * Changelog * format --------- Co-authored-by: Joe Hanley <[email protected]>
1 parent f0f157a commit e183833

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
- Support auth token JSON in `dataconnect_execute` MPC tool. (#9046)
1+
- Added support for auth token JSON in `dataconnect_execute` MPC tool. (#9046)
2+
- Fixed issue where `firebase-ios-sdk` could not finalize MFA with auth emulator. (#9062)
23
- Fixed the bugs when MCP tools cannot connect to emulator due to CLI version mis-matched. (#9068)
3-
- Fix bug when `firebase dataconnect:sdk:generate --watch` swallow all logs. (#9055)
4-
- Add GA4 agent user property to tag CLI usage by coding agents. (#9070)
4+
- Fixed a bug where `firebase dataconnect:sdk:generate --watch` swallowed all logs. (#9055)
5+
- Added GA4 agent user property to tag CLI usage by coding agents. (#9070)

src/emulator/auth/operations.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,9 +2220,23 @@ async function mfaSignInFinalize(
22202220
const phoneNumber = verifyPhoneNumber(state, sessionInfo, code);
22212221

22222222
let { user, signInProvider } = parsePendingCredential(state, reqBody.mfaPendingCredential);
2223-
const enrollment = user.mfaInfo?.find(
2224-
(enrollment) => enrollment.unobfuscatedPhoneInfo === phoneNumber,
2225-
);
2223+
const enrollment = user.mfaInfo?.find((enrollment) => {
2224+
// All but firebase-ios-sdk finalize with unobfuscated phone number.
2225+
if (enrollment.unobfuscatedPhoneInfo === phoneNumber) {
2226+
return true;
2227+
}
2228+
2229+
// But firebase-ios-sdk finalizes with an obfuscated number. This works against
2230+
// cloud auth, so emulator should attempt to find enrollment obfuscated as well.
2231+
if (
2232+
!!enrollment.unobfuscatedPhoneInfo &&
2233+
obfuscatePhoneNumber(enrollment.unobfuscatedPhoneInfo) === phoneNumber
2234+
) {
2235+
return true;
2236+
}
2237+
2238+
return false;
2239+
});
22262240

22272241
const { updates, extraClaims } = await fetchBlockingFunction(
22282242
state,

0 commit comments

Comments
 (0)