Skip to content

refactor(auth)!: migrate to TypeScript and bring auth closer in alignment with firebase-js-sdk API#8991

Draft
russellwheatley wants to merge 7 commits intomainfrom
auth-typescript
Draft

refactor(auth)!: migrate to TypeScript and bring auth closer in alignment with firebase-js-sdk API#8991
russellwheatley wants to merge 7 commits intomainfrom
auth-typescript

Conversation

@russellwheatley
Copy link
Copy Markdown
Member

Description

Related issues

Release Summary

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan


Think react-native-firebase is great? Please consider supporting the project with any of the below:

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-firebase Error Error Apr 21, 2026 1:46pm

Request Review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the modular API for the Auth package and refactors the namespaced API with improved TypeScript support. Key updates include the integration of react-native-builder-bob for builds, a fix for a logic error in TOTP secret handling, and the addition of type comparison configurations. Feedback was provided to improve the clarity of an error message in the password validation logic and to refine the emulator URL parsing to handle missing ports more explicitly.

export function validatePassword(auth: Auth, password: string): Promise<PasswordValidationStatus> {
if (!auth || !('app' in auth)) {
throw new Error(
"firebase.auth().validatePassword(*) 'auth' must be a valid Auth instance with an 'app' property. Received: undefined",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message hardcodes undefined for the received value, which is misleading if the auth parameter is null or an object that simply lacks the app property. It's better to dynamically include the actual value in the error message to aid debugging.

Suggested change
"firebase.auth().validatePassword(*) 'auth' must be a valid Auth instance with an 'app' property. Received: undefined",
`firebase.auth().validatePassword(*) 'auth' must be a valid Auth instance with an 'app' property. Received: ${auth}`

Comment on lines +658 to +660
if (!host || !portString) {
throw new Error('firebase.auth().useEmulator() unable to parse host and port from URL');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic throws an error if the port is missing from the URL. While the Firebase Auth Emulator typically requires a port, the regex match for the port is optional. If the intention is to require a port, the regex should be updated, or the error message should explicitly state that the port is mandatory. If a default port is acceptable, it should be handled here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant