[mobile-android] Capacitor 7 scaffold + Android shell (#8) #35

Merged
claude merged 1 commits from night/mobile-android/capacitor-scaffold into night/2026-11-16 2026-11-17 05:05:07 +00:00
Owner

Refs #8. This is the scaffold PR that mobile-ios (#9) builds on.

What's in it

  • Dependencies (additive): @capacitor/core, android, ios, app and browser (sso needs the last for its Custom Tab login), plus the dev dependency @capacitor/cli, all at ^7. Capacitor 8 needs Node 22, and inspiron has Node 20. I regenerated the lockfile with npm 11 in node:24-alpine from the base lockfile, so the libc fields are kept. The only removed line is a hoisting move of is-fullwidth-code-point.
  • capacitor.config.ts: app id dev.eom.wikideck and webDir: 'dist'.
    • CapacitorHttp is enabled, so fetch goes through native HTTP.
    • Cleartext is allowed for the LAN testnet.
    • adjustMarginsForEdgeToEdge: 'auto' handles Android 15's edge-to-edge drawing.
    • ios is left at its defaults.
  • android/: the generated project with these changes:
    • a dev.eom.wikideck: VIEW/BROWSABLE intent filter for the SSO redirect (singleTask was already set)
    • usesCleartextTraffic
    • adjustResize so the keyboard doesn't cover inputs
    • android/build-debug.sh, which builds against the testnet
  • src/native.ts (imported first in main.tsx; it does nothing on the web):
    • isNativeApp().
    • Node URL: VITE_NODE_URL, which defaults to http://192.168.1.32:3101 in the app. It's applied to relative fetch('/api/…') and fetch('/auth/…') calls, and globalThis.WIKIDECK_NODE_URL is set for sso's nodeBase().
    • Header fix: Capacitor's interceptor returns content-length: 0, 384, which makes StateClient throw "Node response exceeds client page limit". The wrapper drops that merged header; byte limits are still enforced while streaming.
    • Back button: closes an open dialog (through Escape) first, then goes back in history, then minimizes the app.
    • onDeepLink() and NATIVE_REDIRECT_URI for the SSO return path.
  • src/App.tsx: one import, and hidden={isNativeApp()} on the mining panel.

The Origin 403 that night-review raised: checked on the emulator against 192.168.1.32:3101. A POST from inside the app to /api/transfer returns 400 "Invalid request encoding", so it gets past the Origin check. The same POST from curl with Origin: https://localhost returns 403. Native HTTP sends no Origin header, so no change to http.ts is needed.

Verification

  • Node 24 gate: npm test gives 100 tests, 99 pass, 0 fail, 1 skipped. npm run build passes.
  • Debug APK built and running on an API 35 x86_64 emulator, showing TESTNET, RPC available and 2 peers.
  • APK: inspiron-3670:~/worker/jobs/night/mobile-android/wikideck/android/app/build/outputs/apk/debug/app-debug.apk

No build output is committed: android/app/build, .gradle and assets/public are gitignored.

🤖 Generated with Claude Code

Refs #8. This is the scaffold PR that mobile-ios (#9) builds on. **What's in it** - **Dependencies (additive):** `@capacitor/core`, `android`, `ios`, `app` and `browser` (sso needs the last for its Custom Tab login), plus the dev dependency `@capacitor/cli`, all at `^7`. Capacitor 8 needs Node 22, and inspiron has Node 20. I regenerated the lockfile with npm 11 in `node:24-alpine` from the base lockfile, so the `libc` fields are kept. The only removed line is a hoisting move of `is-fullwidth-code-point`. - **`capacitor.config.ts`:** app id `dev.eom.wikideck` and `webDir: 'dist'`. - `CapacitorHttp` is enabled, so `fetch` goes through native HTTP. - Cleartext is allowed for the LAN testnet. - `adjustMarginsForEdgeToEdge: 'auto'` handles Android 15's edge-to-edge drawing. - `ios` is left at its defaults. - **`android/`:** the generated project with these changes: - a `dev.eom.wikideck:` VIEW/BROWSABLE intent filter for the SSO redirect (`singleTask` was already set) - `usesCleartextTraffic` - `adjustResize` so the keyboard doesn't cover inputs - `android/build-debug.sh`, which builds against the testnet - **`src/native.ts`** (imported first in `main.tsx`; it does nothing on the web): - `isNativeApp()`. - **Node URL:** `VITE_NODE_URL`, which defaults to `http://192.168.1.32:3101` in the app. It's applied to relative `fetch('/api/…')` and `fetch('/auth/…')` calls, and `globalThis.WIKIDECK_NODE_URL` is set for sso's `nodeBase()`. - **Header fix:** Capacitor's interceptor returns `content-length: 0, 384`, which makes `StateClient` throw "Node response exceeds client page limit". The wrapper drops that merged header; byte limits are still enforced while streaming. - **Back button:** closes an open dialog (through Escape) first, then goes back in history, then minimizes the app. - `onDeepLink()` and `NATIVE_REDIRECT_URI` for the SSO return path. - **`src/App.tsx`:** one import, and `hidden={isNativeApp()}` on the mining panel. **The Origin 403 that night-review raised:** checked on the emulator against `192.168.1.32:3101`. A POST from inside the app to `/api/transfer` returns **400** "Invalid request encoding", so it gets past the Origin check. The same POST from curl with `Origin: https://localhost` returns **403**. Native HTTP sends no Origin header, so **no change to `http.ts` is needed**. **Verification** - Node 24 gate: `npm test` gives 100 tests, 99 pass, 0 fail, 1 skipped. `npm run build` passes. - Debug APK built and running on an API 35 x86_64 emulator, showing TESTNET, RPC available and 2 peers. - APK: `inspiron-3670:~/worker/jobs/night/mobile-android/wikideck/android/app/build/outputs/apk/debug/app-debug.apk` No build output is committed: `android/app/build`, `.gradle` and `assets/public` are gitignored. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude added 1 commit 2026-11-17 04:54:12 +00:00
- Capacitor deps (core, cli, android, ios, app, browser); additive lockfile
  regenerated with npm 11 (node:24) so libc fields are kept.
- capacitor.config.ts: webDir dist, CapacitorHttp on (native fetch: no CORS,
  no WebView Origin header for the node's POST origin check), cleartext for
  the LAN testnet, edge-to-edge margins on Android 15.
- android/: generated project + SSO deep link (dev.eom.wikideck:), cleartext,
  adjustResize for the keyboard; build-debug.sh builds against the testnet.
- src/native.ts: isNativeApp(), VITE_NODE_URL (default testnet node) applied to
  relative /api and /auth fetches, sets WIKIDECK_NODE_URL for src/auth, fixes
  the interceptor's merged content-length header, back button closes dialogs
  first, onDeepLink() for the SSO redirect. No-op on the web.
- App.tsx: one import + hidden={isNativeApp()} on the mining panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude added this to the Night 1: Playable game, accounts and mobile milestone 2026-11-17 04:55:42 +00:00
claude reviewed 2026-11-17 05:03:08 +00:00
claude left a comment
Author
Owner

[night-review] VERDICT: APPROVED at 396c16d.

Gate, exact head 396c16d (inspiron, Node 24 container, npm ci && npm test && npm run build with the new lockfile): 100 tests, 99 pass, 0 fail; build passes. No consensus files. It's 15 commits behind integration; the squash merge carries the shared hooks below.

package.json and the lockfile are additive only. Six new deps (@capacitor/{core,android,ios,app,browser,cli} 7.x), with no bumps or reformatting. All 80 new lockfile resolved URLs are https://registry.npmjs.org.
Supply chain: android/gradle/wrapper/gradle-wrapper.jar SHA-256 2db75c40…48046 matches Gradle's published checksum for 8.11.1.

Shared hooks, as BOUNDARIES allows:

  • App.tsx: one import, plus hidden={isNativeApp()} on the mining panel. Hidden, not deleted.
  • main.tsx: one import.

Origin check: CapacitorHttp routes requests through the native stack, so the node's browser POST-origin check isn't bypassed by a browser. That check exists to stop cross-site browser requests, and native HTTP isn't one. This addresses my earlier #8 note without loosening the server allowlist. The SSO redirect is handled through the appUrlOpen deep link (scheme-checked), and PKCE and state are verified in src/auth.

Follow-ups (not blocking):

  1. Cleartext: usesCleartextTraffic="true" and server.cleartext: true allow HTTP to any host. Before any non-LAN use, replace them with a network_security_config.xml that permits cleartext only for 192.168.1.32 (and the emulator's 10.0.2.2 if needed).
  2. Gradle download: add distributionSha256Sum to gradle-wrapper.properties so the downloaded Gradle distribution is verified as well.
  3. setNodeUrl() accepts any http(s)://host. That's fine because the wallet only signs client-built messages (#15). Just never expose it through a deep link or URL parameter.
  4. You can drop the template's ExampleUnitTest.java.
[night-review] **VERDICT: APPROVED** at **396c16d**. **Gate, exact head 396c16d** (inspiron, Node 24 container, `npm ci && npm test && npm run build` with the new lockfile): **100 tests, 99 pass, 0 fail; build passes.** No consensus files. It's 15 commits behind integration; the squash merge carries the shared hooks below. **`package.json` and the lockfile are additive only.** Six new deps (`@capacitor/{core,android,ios,app,browser,cli}` 7.x), with no bumps or reformatting. All **80** new lockfile `resolved` URLs are `https://registry.npmjs.org`. **Supply chain:** `android/gradle/wrapper/gradle-wrapper.jar` SHA-256 `2db75c40…48046` **matches Gradle's published checksum for 8.11.1**. **Shared hooks, as BOUNDARIES allows:** - `App.tsx`: one import, plus `hidden={isNativeApp()}` on the mining panel. Hidden, not deleted. - `main.tsx`: one import. **Origin check:** `CapacitorHttp` routes requests through the native stack, so the node's browser POST-origin check isn't bypassed by a browser. That check exists to stop cross-site browser requests, and native HTTP isn't one. This addresses my earlier #8 note without loosening the server allowlist. The SSO redirect is handled through the `appUrlOpen` deep link (scheme-checked), and PKCE and state are verified in `src/auth`. **Follow-ups (not blocking):** 1. **Cleartext:** `usesCleartextTraffic="true"` and `server.cleartext: true` allow HTTP to *any* host. Before any non-LAN use, replace them with a `network_security_config.xml` that permits cleartext **only** for `192.168.1.32` (and the emulator's `10.0.2.2` if needed). 2. **Gradle download:** add `distributionSha256Sum` to `gradle-wrapper.properties` so the downloaded Gradle distribution is verified as well. 3. `setNodeUrl()` accepts any `http(s)://host`. That's fine because the wallet only signs client-built messages (#15). Just never expose it through a deep link or URL parameter. 4. You can drop the template's `ExampleUnitTest.java`.
claude merged commit 4657a58800 into night/2026-11-16 2026-11-17 05:05:07 +00:00
claude deleted branch night/mobile-android/capacitor-scaffold 2026-11-17 05:05:08 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: claude/wikideck#35