feat(firebase): FirebaseDisabledError for dynamicLinks helpers - #306
Merged
Conversation
The two Firebase Dynamic Links helpers (createInviteLink and createJumpstartLink) previously called dynamicLinks() unconditionally. With FIREBASE_ENABLED=false (the current state per .env.mainnet), those calls throw a Firebase native error that is hard for callers to distinguish from other Firebase issues. Now both helpers early-return with a dedicated FirebaseDisabledError so callers can catch specifically and either: - fall back to a plain web URL, - disable the 'share via link' affordance, - surface a friendly 'feature unavailable' message. createInviteLink was already gated at its call site (src/invite/hooks.tsx:22 checks FIREBASE_ENABLED before calling). createJumpstartLink was NOT (src/jumpstart/JumpstartEnterAmount.tsx:77 called it directly); this change makes both safe from the helper's side. Does not touch Sentry TUCOPWALLET-8 native-level crash (that fires from ReactNativeFirebaseDynamicLinksModule.onNewIntent in the Android auto-linked native module, before any JS runs). Separate product decision tracked in PENDING.md (options A/B/C).
… test + add disabled-path test The existing jumpstart-link test broke on PR #306 because it did not mock FIREBASE_ENABLED, and the actual config value is false, so the new guard in createJumpstartLink threw FirebaseDisabledError before reaching the mocked buildLink. Fixes: - beforeEach sets FIREBASE_ENABLED=true and clears mocks so the happy- path test can hit buildLink as before. - New test covers the disabled path: FIREBASE_ENABLED=false throws FirebaseDisabledError AND buildLink is never called (private key never reaches the native module, matching the existing security comment in createJumpstartLink).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Small harm-reduction fix. The two Firebase Dynamic Links helpers now throw a dedicated
FirebaseDisabledErrorinstead of a raw Firebase native error whenFIREBASE_ENABLED=false(current state per.env.mainnet:9). Callers can catch specifically and degrade gracefully.This is NOT the fix for Sentry TUCOPWALLET-8 (Firebase not initialized). That crash fires from
ReactNativeFirebaseDynamicLinksModule.onNewIntenton the Android native side, before any JS runs. That one requires a product-level decision (activate Firebase / remove Firebase modules / stub google-services.json). Options captured inPENDING.mdas a separate entry.Changes
src/firebase/dynamicLinks.ts(+15 lines):FirebaseDisabledErrorclass (exported).createInviteLinkandcreateJumpstartLinkguard onFIREBASE_ENABLEDbefore callingdynamicLinks().Why this specifically
createInviteLinkwas already gated at the call site (src/invite/hooks.tsx:22checksFIREBASE_ENABLED). Adding a helper-side guard is defensive redundancy.createJumpstartLinkwas not gated (src/jumpstart/JumpstartEnterAmount.tsx:77calls it directly). Before this PR, tapping "Enviar por link" in the jumpstart flow with Firebase disabled would throw an opaque Firebase native error the caller has no way to recognize. Now it throwsFirebaseDisabledErrorwhich the caller can identify byerr.name === 'FirebaseDisabledError'orinstanceof.Test plan
yarn build:ts(0 errors)JumpstartEnterAmount.tsxshould catchFirebaseDisabledErrorand either disable the "Enviar por link" affordance or surface "Feature no disponible" toast. Not in scope for this PR (needs product input on the UX copy).