refactor(auth)!: migrate to TypeScript and bring auth closer in alignment with firebase-js-sdk API#8991
refactor(auth)!: migrate to TypeScript and bring auth closer in alignment with firebase-js-sdk API#8991russellwheatley wants to merge 75 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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.
|
Hello 👋, this PR has been opened for more than 14 days with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
…o auth-typescript
Updated to main and re-pushed to verify things still work since we're not using a merge queue here
release notes will come from the commit, so here's the draft of the commit message pulled from the description:
BREAKING CHANGE: auth types now match firebase-js-sdk as closely as possible
Please see https://rnfirebase.io/migrating-to-v25 for help migrating if needed.
react-native-firebase has a goal to be a drop-in replacement for firebase-js-sdk, with native extensions and performance. It has always worked that way at the javascript level but the typescript types have been divergent.
We are fixing that as we refactor to typescript. Please bear with us as we get closer to our goal of react-native-firebase matching firebase-js-sdk both in functionality where possible, but also in exact typescript typing.
Specifics for Auth:
Auth,User,UserCredential,ActionCodeInfo,MultiFactorResolver, andMultiFactorUserno longer use the deprecatedFirebaseAuthTypesnamespace types in their public signatures; TypeScript consumers should import the modular types directly from@react-native-firebase/auth.initializeRecaptchaConfigexport from@react-native-firebase/auth; RN Firebase uses native SDK phone-auth verification rather than the browser reCAPTCHA bootstrap flow.sendSignInLinkToEmail(auth, email, actionCodeSettings)soactionCodeSettingsis required, matching the firebase-js-sdk modular signature.signInWithPhoneNumber(auth, phoneNumber, appVerifier?)so the old RNFBforceResendfourth argument is no longer part of the modular signature; use the RNFB-specificverifyPhoneNumber(...)helper for the native listener / force-resend flow.signInWithRedirect(...)andlinkWithRedirect(...)now returnPromise<UserCredential>because RN Firebase native provider flows resolve immediately with credentials instead of following the browser redirect contract.FirebaseAuthTypesAPI for backwards compatibility, but marked it deprecated and separated it from the modular public types; consumers should prefer direct exported modular types going forward.FirebaseAuthTypes.UserInfonullable profile fields andfirebase.auth().confignow typed asRecord<string, never>rather thanMap<any, any>.auth.authStateReady(),auth.beforeAuthStateChanged(...),auth.emulatorConfig, andauth.updateCurrentUser(user)on the Auth instance; modularbeforeAuthStateChangedandupdateCurrentUsernow delegate to the instance instead of throwing.auth.tenantIdsetter (delegates tosetTenantId) for firebase-js-sdk parity.auth.configis typed for parity but returns{}at runtime because native iOS/Android Firebase Auth SDKs do not expose the web config object.signInWithEmailLink(auth, email, emailLink?)third argument optional to match firebase-js-sdk.sendSignInLinkToEmail(email, settings?)default of{}when settings are omitted; modular API keeps requiredactionCodeSettingsper firebase-js-sdk.AuthCredential,EmailAuthCredential,OAuthCredential,PhoneAuthCredential) now mirror firebase-js-sdk withtoJSON()andstatic fromJSON()where applicable, while retaining RNFBtoken/secretbridge fields.OAuthProvider.credentialFromResult/credentialFromErrorandPhoneAuthProvider.credentialFromResult/credentialFromErrornull-returning stubs for API parity.User.reauthenticateWithRedirectto call_setUserCredentialagain socurrentUserupdates after native provider reauthentication.multiFactor(user)uses the user's auth instance instead ofgetAuth()for secondary-app correctness.multiFactor(user)now enforcesuser.uid === currentUser.uid.UserCredential,checkActionCode,getAdditionalUserInfo, andsignInWithPhoneNumberconfirmation results.TotpSecret.generateQrCodeUrl()documented as async because it uses the React Native native bridge.Related issues
No open issue specifically tracks modular
multiFactor(user)usinggetAuth(); related historical discussion: #7339 (closed, native MFA with secondary Firebase apps).Release Summary
Checklist
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/**\e2ejesttests added or updated inpackages/**\__tests__Test Plan
Think
react-native-firebaseis great? Please consider supporting the project with any of the below:React Native FirebaseandInvertaseon Twitter