✨ Add MetaMask login button via Reown AppKit#59
Open
javaing wants to merge 1 commit into
Open
Conversation
Renders a fixed-position "Login with MetaMask" button at the bottom of the WebView whenever the user is logged out of 3ook.com (detected via absence of the `nuxt-session` cookie). Tapping it opens Reown AppKit's wallet picker, routes to MetaMask Mobile for `personal_sign`, posts the signed payload to 3ook.com/api/login, installs the returned nuxt-session cookie, and forces a fresh server-side render so SSR picks up the new session. Notes: - Uses 3ook.com's own /api/login (not api.like.co/users/login) because the frontend authenticates against the encrypted Nuxt session, not the raw likecoin JWT. Signed message is pretty-printed JSON with the 10-permission list from JWT_PERMISSIONS — must match the web client byte-for-byte. - Requires EXPO_PUBLIC_REOWN_PROJECT_ID at build time (free from cloud.reown.com). - Covers only the "existing wallet-registered user" path. New users see a "register on web first" hint; account-linking for email users is out of scope. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
nuxt-sessioncookie).personal_sign→ posts the signed payload to3ook.com/api/login→ installs the returnednuxt-sessioncookie → forces a fresh server-side render so SSR picks up the new session.Why `/api/login` and not `api.like.co/users/login`
3ook's frontend authenticates against the encrypted Nuxt session cookie (`nuxt-session` on `.3ook.com`), not the raw `likecoin_auth` JWT scoped to `.like.co`. Calling the upstream API directly returns a valid likecoin JWT but the SPA simply ignores it. Going through `3ook.com/api/login` makes the Nuxt server wrap the upstream response in its own sealed session, so the SPA recognizes the login.
The signed message must be a pretty-printed JSON (2-space indent) containing `action: 'authorize'` and the 10-permission list from `stores/account.ts#JWT_PERMISSIONS` byte-for-byte, otherwise the server's signature recovery fails.
Setup
Scope
Covers only the existing wallet-registered user path. New users (or email users who haven't linked an EVM wallet) currently get a "register on the website first" error message — account-linking and on-device registration are deliberately out of scope for v1.
Test plan
🤖 Generated with Claude Code