Skip to content

fix(firefox): claims fail because cookies are never attached · plus silent-failure guard for ungranted host permissions - #4

Open
justerlex wants to merge 1 commit into
Axyss:mainfrom
justerlex:fix/firefox-login
Open

fix(firefox): claims fail because cookies are never attached · plus silent-failure guard for ungranted host permissions#4
justerlex wants to merge 1 commit into
Axyss:mainfrom
justerlex:fix/firefox-login

Conversation

@justerlex

Copy link
Copy Markdown

The bug

On Firefox (tested on Zen, a Firefox fork), every claim fails with "Log in to Hoyolab first" (retcode -100) even while the user is demonstrably logged into hoyolab.com. Relogging any number of times does not help. The README lists Firefox/Zen as supported, so this affects every Firefox user.

Two root causes, both Firefox-only

1 · fetch() never attaches cookies. All HoYoLAB calls in claimable.ts use the default credentials mode (same-origin). Chrome attaches cookies implicitly to host-permitted extension requests, which is why the Chrome build works. Firefox follows the fetch spec strictly: a cross-origin request from a moz-extension:// context sends no cookies without credentials: "include", host permission or not. The request reaches the API anonymously → -100.

2 · Firefox ships MV3 host_permissions OFF by default. Unlike Chrome, Firefox treats them as optional and does not grant them at install. In that state the fetches are CORS-blocked and throw, and the extension fails completely silently, no error in the popup, no notification (the rejection escapes the MANUAL_CLAIM listener). The user has no way to discover the fix (about:addons → Permissions → enable hoyolab.com access).

The fix

  • credentials: "include" on all ten HoYoLAB fetches in claimable.ts. No-op on Chrome (it already attached cookies), required on Firefox.
  • A small warning banner in the popup, shown only when the host permission is not granted, with a Grant button wired to permissions.request(). On Chrome the check always passes and the banner never renders.

How it was isolated

Tested on Zen with a real logged-in HoYoLAB session, temporary add-on loads of stock vs patched builds with the same extension id (so permission grants and storage carry over between them):

  • stock build + host permission granted + logged in → -100 on every claim
  • patched build, same conditions → claims succeed
  • stock build + permission NOT granted → silent failure, nothing rendered anywhere
  • patched build, same conditions → banner appears, Grant → claims succeed

Happy to adjust style/wording to match the codebase conventions.

🤖 Generated with Claude Code

…ssion

Firefox never attaches cookies to cross-origin fetches from extension
contexts (default credentials mode is same-origin), while Chrome attaches
them implicitly for host-permitted requests, so every claim on Firefox
reached the API anonymously and returned retcode -100. All HoYoLAB fetches
now pass credentials: 'include' (a no-op on Chrome).

Firefox also treats MV3 host_permissions as optional and ships them OFF by
default; without the grant the fetches are CORS-blocked and the extension
fails silently. The popup now checks the grant on mount and shows a
warning banner with a Grant button (never visible on Chrome, where install
grants host permissions).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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