Repository navigation
Description
Living record of how this app came together, the architecture, and what's next. Companion to the JSS-side tracking issue JavaScriptSolidServer/JavaScriptSolidServer#522. The commit history has the blow-by-blow; this is the curated why.
What it is
An installable Android app that runs a real Solid Pod natively. A React Native shell embeds a full Node.js runtime (nodejs-mobile) and boots JSS in-process via createServer(). On launch: the pod serves at http://localhost:<port>/, the IdP generates signing keys, a single-user pod is created, a starter app bundle is installed on first run, and OIDC sign-in works end-to-end from a Solid app (pilot).
Architecture
- RN shell (
App.tsx) — single screen: boot status, "Pod running at ", Open-in-browser. Talks to Node overrn-bridge(status / ready / error messages). - Embedded Node (
nodejs-assets/nodejs-project/main.js) — imports JSScreateServerdirectly (no subprocess), applies the nodejs-mobile compat layer, finds a free port, listens, then best-effort seeds apps. scripts/patch-android-assets.js— post-npm installsource surgery for things that can't be fixed at runtime (see "AAPT" and "regex/crypto.hash" below).- specialUse foreground service (
PodForegroundService.kt) — keeps the Node event loop alive when the user switches to a browser. - CI (
.github/workflows/build.yml) — manualworkflow_dispatch, builds a release APK (signed with the debug keystore for sideloading), 3-day artifact retention.
Why in-process JSS (not jspod)
jspod's start() launches JSS with spawn('jss', …). Android can't fork a CLI binary out of the asset bundle, so we bypass jspod and call javascript-solid-server's createServer() in the same process. (Tracked for jspod in #522.)
The fix phases
1. Native / React Native (get the APK to launch)
- Enable the new architecture +
SoLoader.init(this, OpenSourceMergedSoMapping)— RN 0.76 merged thelibhermes_executor/react_*JNIs intolibreactnative.so; the legacy bridge path crashes without this. assembleRelease(not debug) so the JS bundle ships in the APK — a sideloaded debug build expects Metro and red-screens.
2. Assets (AAPT eats files)
- AAPT silently drops directories named
_from packaged assets (oidc-provider'slib/helpers/_/). OverridingignoreAssetsPatterndidn't stick, so the patch script renames_dirs and rewrites references before packaging.
3. nodejs-mobile runtime compat (Node 18, no ICU)
nodejs-mobile bundles an older Node without full ICU. The pod's dep graph (JSS + oidc-provider + jose + @koa/router) assumes Node 20/22. We bridge the gap in main.js (runtime polyfills) and the patch script (source rewrites where a runtime polyfill can't reach):
globalThis.crypto←node:crypto.webcrypto(jose key-gen)URL.parse()(Node 22.1+) polyfillIntl.ListFormatminimal polyfill (no ICU)Array#toReversed/toSorted/with(ES2023) polyfill\p{…}/\P{…}Unicode property-escape regexes → ASCII classes (V8 rejects them) — source rewritecrypto.hash()(Node 21.7+) →createHash().digest()— source rewrite (oidc-provider importscryptoas an immutable namespace, so a runtime shim can't add it)chdirinto the writable extracted project dir so JSS canmkdir ./pod-data
4. Runtime / lifecycle
- Port-shopping from 5444 (Termux pm2 jspod often already holds 5444 on the same device).
- specialUse foreground service (NOT
dataSync, which Android 15 force-kills within seconds) so the pod survives backgrounding. - Browser
<queries>for Android 11+ package visibility, or Open-in-browser silently no-ops.
5. Auth (OIDC sign-in)
- First-run bootstrap fetches solid-apps (pilot/profile/home) from jsDelivr onto the pod, so sign-in happens from a same-origin app (HTTPS web apps hit mixed-content against http://localhost).
idpIssuermust carry a trailing slash: JSS forces one on the discoveryissuerbut emits the RFC 9207issparam raw; the strict client (xlogin → solid-oidc) compares them byte-for-byte. (Server-side bug: JSS#524; client-side fix shipped in xlogin 0.0.13 → solid-oidc 0.0.9.)
Upstream issues filed
- JSS: #520 (
\P{C}regex), #521 (TOKEN_SECREThomedir), #523 (toReversed/crypto.hash— needs Node 20+/22), #524 (RFC 9207issvs issuer slash) — all under tracking #522. - xlogin: Bump pinned solid-oidc 0.0.8 -> 0.0.9 (fixes strict issuer compare that breaks login on trailing-slash mismatch) melvincarvalho/xlogin#22 → PR OS gap: app discovery / store #23 merged → published 0.0.13.
Known gaps
- Pod data lives under the app's extracted project dir; needs a deliberate persistent path that survives app updates.
- Sign-in only from same-origin apps on the pod (no HTTPS/cert story yet).
- localhost-only; no LAN/remote reachability.
- The nodejs-mobile compat layer is a growing per-API shim list — driven by oidc-provider targeting current Node LTS.
Future work
- Native Kotlin + nodejs-mobile-android (drop React Native): leaner APK, none of the Hermes/new-arch/bundle complexity; reuses the same Node-side compat layer.
- iOS via nodejs-mobile (RN iOS target or native Swift).
- Persistent, user-visible pod storage + backup.
Activity