/** * passkey-flags.ts — single switch for the Firefox passkey content-script proxy. * * FIREFOX_USE_CONTENT_SCRIPT_PROXY * * true — Use the content script monkey-patch (current workaround). * Required until Mozilla ships webAuthenticationProxy in stable Firefox. * * false — Use the native webAuthenticationProxy path (Chrome today; future * Firefox once the API ships). * * The value is computed at runtime from feature presence, not a hard-coded * boolean. The day Firefox exposes `chrome.webAuthenticationProxy`, this flag * flips to false on updated browsers without any code change. Cleanup at that * point is purely subtractive — see the removal checklist below. * * TO REMOVE THE MONKEY-PATCH: * 1. Confirm `webAuthenticationProxy` is in stable Firefox (not Nightly) * and the minimum supported Firefox version for Peach covers it. * 2. Verify this flag evaluates to `false` automatically on the new build. * 3. Delete src/content/passkeys-firefox.ts * 4. Delete src/content/passkeys-firefox-relay.ts * 5. Delete src/shared/passkey-flags.ts * 6. Remove the PASSKEY_HAS_CREDENTIALS handler in src/background/messages.ts * and the Firefox branches in PASSKEY_CREATE / PASSKEY_GET handlers. * 7. Remove the two Firefox content_scripts entries from manifest.firefox.json * and add `"webAuthenticationProxy"` to its permissions list. * 8. The Chrome webAuthenticationProxy path already handles everything. * * Track removal readiness: * https://github.com/w3c/webextensions/issues/ (WECG passkey API issue) */ export const FIREFOX_USE_CONTENT_SCRIPT_PROXY: boolean = (() => { // chrome.webAuthenticationProxy presence wins over everything — that path // is preferred when available, regardless of how we got here. const c = (typeof chrome !== "undefined" ? chrome : undefined) as | { webAuthenticationProxy?: unknown; runtime?: { getURL?: (path: string) => string } } | undefined; if (c?.webAuthenticationProxy) return false; try { const url = c?.runtime?.getURL?.("") ?? ""; return url.startsWith("moz-extension://"); } catch { return false; } })();