Refs #7, #8, #9. A small follow-up to #15, touching only src/auth/session.ts, server/account/README.md and a new tests/account-native.test.ts.
Why:#15 found the Capacitor Browser plugin through Capacitor.Plugins.Browser. I can't confirm Capacitor 7 populates that for npm-imported plugins. If it doesn't, native login would have fallen back to navigating the WebView to Dex, which RFC 8252 forbids and which may never hand back the custom-scheme redirect.
Change:
New setNativeBrowser(Browser) hook. The app passes in the imported @capacitor/browser.
On native, login() uses that plugin (falling back to Capacitor.Plugins.Browser if present). If neither exists, it throws instead of navigating the WebView.
Refs #7, #8, #9. A small follow-up to #15, touching only `src/auth/session.ts`, `server/account/README.md` and a new `tests/account-native.test.ts`.
**Why:** #15 found the Capacitor Browser plugin through `Capacitor.Plugins.Browser`. I can't confirm Capacitor 7 populates that for npm-imported plugins. If it doesn't, native login would have fallen back to navigating the **WebView** to Dex, which RFC 8252 forbids and which may never hand back the custom-scheme redirect.
**Change:**
- New `setNativeBrowser(Browser)` hook. The app passes in the imported `@capacitor/browser`.
- On native, `login()` uses that plugin (falling back to `Capacitor.Plugins.Browser` if present). If neither exists, it **throws instead of navigating the WebView**.
- The web flow is unchanged.
**For mobile-android (PR #35, `src/native.ts`):**
```ts
import { Browser } from '@capacitor/browser';
import { completeLogin, isCallback, setNativeBrowser } from './auth/session.ts';
setNativeBrowser(Browser);
onDeepLink(u => { if (isCallback(u.href)) void completeLogin(u.href); });
```
**Tests (Node 24):** `npm test` gives 186 tests, 185 pass, 0 fail, 1 skipped. `npm run build` passes. The new test covers:
- native login with no plugin rejects and never touches `location`
- with the hook, it opens `https://dex.eom.dev/auth` with `redirect_uri=dev.eom.wikideck:/oauth/callback`, S256 and the stored `state`
- `isCallback` accepts the custom-scheme URL
🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude
added this to the Night 1: Playable game, accounts and mobile milestone 2026-11-17 05:03:01 +00:00
Native login now opens only the plugin the app passes in (Custom Tab /
SFSafariViewController) and refuses rather than navigating the WebView.
Test covers PKCE params and the dev.eom.wikideck redirect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gate, exact head cbcccf3 (inspiron, Node 24 container): 186 tests, 185 pass, 0 fail; build passes. No consensus files. It's mergeable, and it touches only src/auth/session.ts, server/account/README.md and tests/account-native.test.ts.
It fails closed, which is the right behaviour:
On native, login() opens Dex through the injected @capacitor/browser (or falls back to Capacitor.Plugins.Browser).
If neither exists it throws instead of navigating the WebView to Dex, as RFC 8252 requires; that also avoids a broken custom-scheme return.
The web flow is unchanged.
The test checks that native login with no plugin rejects and never touches location, and that with the hook it opens https://dex.eom.dev/auth with S256, the stored state and redirect_uri=dev.eom.wikideck:/oauth/callback.
mobile-android:#35 is merged, so wire setNativeBrowser(Browser) and onDeepLink(u => isCallback(u.href) && completeLogin(u.href)) in src/native.ts in a small follow-up, as the PR body shows. Until then, native login throws a clear error rather than doing something unsafe.
[night-review] **VERDICT: APPROVED** at **cbcccf3**.
**Gate, exact head cbcccf3** (inspiron, Node 24 container): **186 tests, 185 pass, 0 fail; build passes.** No consensus files. It's mergeable, and it touches only `src/auth/session.ts`, `server/account/README.md` and `tests/account-native.test.ts`.
**It fails closed, which is the right behaviour:**
- On native, `login()` opens Dex through the injected `@capacitor/browser` (or falls back to `Capacitor.Plugins.Browser`).
- If neither exists it **throws** instead of navigating the WebView to Dex, as RFC 8252 requires; that also avoids a broken custom-scheme return.
- The web flow is unchanged.
- The test checks that native login with no plugin rejects and never touches `location`, and that with the hook it opens `https://dex.eom.dev/auth` with S256, the stored `state` and `redirect_uri=dev.eom.wikideck:/oauth/callback`.
**mobile-android:** #35 is merged, so wire `setNativeBrowser(Browser)` and `onDeepLink(u => isCallback(u.href) && completeLogin(u.href))` in `src/native.ts` in a small follow-up, as the PR body shows. Until then, native login throws a clear error rather than doing something unsafe.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Refs #7, #8, #9. A small follow-up to #15, touching only
src/auth/session.ts,server/account/README.mdand a newtests/account-native.test.ts.Why: #15 found the Capacitor Browser plugin through
Capacitor.Plugins.Browser. I can't confirm Capacitor 7 populates that for npm-imported plugins. If it doesn't, native login would have fallen back to navigating the WebView to Dex, which RFC 8252 forbids and which may never hand back the custom-scheme redirect.Change:
setNativeBrowser(Browser)hook. The app passes in the imported@capacitor/browser.login()uses that plugin (falling back toCapacitor.Plugins.Browserif present). If neither exists, it throws instead of navigating the WebView.For mobile-android (PR #35,
src/native.ts):Tests (Node 24):
npm testgives 186 tests, 185 pass, 0 fail, 1 skipped.npm run buildpasses. The new test covers:locationhttps://dex.eom.dev/authwithredirect_uri=dev.eom.wikideck:/oauth/callback, S256 and the storedstateisCallbackaccepts the custom-scheme URL🤖 Generated with Claude Code
[night-review] VERDICT: APPROVED at
cbcccf3.Gate, exact head
cbcccf3(inspiron, Node 24 container): 186 tests, 185 pass, 0 fail; build passes. No consensus files. It's mergeable, and it touches onlysrc/auth/session.ts,server/account/README.mdandtests/account-native.test.ts.It fails closed, which is the right behaviour:
login()opens Dex through the injected@capacitor/browser(or falls back toCapacitor.Plugins.Browser).location, and that with the hook it openshttps://dex.eom.dev/authwith S256, the storedstateandredirect_uri=dev.eom.wikideck:/oauth/callback.mobile-android: #35 is merged, so wire
setNativeBrowser(Browser)andonDeepLink(u => isCallback(u.href) && completeLogin(u.href))insrc/native.tsin a small follow-up, as the PR body shows. Until then, native login throws a clear error rather than doing something unsafe.