[PM-42047] fix(desktop): install the Firefox native messaging manifest on macOS - #22452
Conversation
|
Thank you for your contribution! We've added this to our internal tracking system for review. Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process. |
|
@fabriziobagala Just FYI, I think someone else proposed a fix for this issue a few days ago: #22409 (also @Donnerbart) |
@pamperer562580892423 Thanks for the info, but I hadn't realized anyone was already working on it. I created this PR because the bug had become too annoying, so I tried to fix it. On my MacBook, I applied the workaround I described in the issue. I hope this PR is helpful; if not, feel free to close it. |
🎟️ Tracking
Fixes #22027
📔 Objective
On macOS the Firefox native messaging manifest is never installed, so biometric unlock never works in Firefox while it works in Chrome on the same machine.
getDarwinNMHS()returns one path per browser, used both to detect that the browser is installed and as the directory to install into. That holds for every browser except Firefox: its profiles live inApplication Support/Firefox/, but its manifests belong inApplication Support/Mozilla/, which Firefox itself does not create - Bitwarden or another native messaging host does. Gating installation onexistsSync()ofMozilla/therefore makes the manifest its own precondition, and Firefox is skipped forever withFirefox not found, skipping.It is also why the Firefox/Zenmkdirfrom #21784 never runs on an affected machine: it sits inside the branch that is never taken.The fix is limited to detection. A new
getDarwinDetectPaths()returns the paths that prove a browser is installed - for Firefox,Application Support/Firefox/plus the existingMozilla/as a fallback; for every other browser, the current path unchanged.getDarwinNMHS()andwriteManifest()are untouched, so #21568 is not reintroduced. Installing each browser's manifest is now wrapped in a try/catch: Firefox is the first entry in the map, and at startupmain.tscallsgenerateManifests()andlisten()inside onetry, so a failure there would stop the native messaging server from starting at all.This does mean
Mozilla/can be created when it is missing, which the note on #21784 rules out ("We do not want to create the browser directory"). Nothing is created for a browser that is not installed -Mozilla/only appears onceApplication Support/Firefox/has been observed, and only on macOS - but the letter of that rule is not preserved, and it deserves an explicit decision. Linux, Snap and Flatpak are unchanged.Both MAS entitlements gain one entry -
/Library/Application Support/Mozilla, without a trailing slash - alongside the existingNativeMessagingHosts/subpath, which is left untouched: a subpath exception rooted atMozilla/NativeMessagingHostscannot authorize creating its own parent. Widening the leaf entry toMozilla/instead would have made it the only non-leaf grant of the thirteen, and would have reachedMozilla/ManagedStorage/andMozilla/Certificates/. This is the one part I cannot exercise - an unsandboxed local build permits the write regardless - so it is worth confirming on a signed MAS build.Also adds
native-messaging.main.spec.ts, which the module did not have.