Skip to content

Commit 0b0921f

Browse files
scripts/bundle-jss.sh + doc fixes from spike
Verified the JSS launch args end-to-end on this dev box: - Boot args: --single-user --port <p> --host 127.0.0.1 --root <path> --idp - JSS_SINGLE_USER_PASSWORD env var seeds the IDP account on first run - All four sentinel endpoints return 200: /, /idp, /.well-known/openid-configuration, /profile/card.jsonld - Loopback bind confirmed (127.0.0.1 only) - Pod tree (profile/, public/, private/, inbox/, settings/, .idp/) is created under --root and nothing leaks elsewhere Doc fix-ups: the CLI flag is `--root`, not `--data-root` as initially drafted; --host 127.0.0.1 is now part of the canonical mobile launch line; ARCHITECTURE.md notes the spike-verified args and adds a first-run-UX open question for the IDP password. scripts/bundle-jss.sh produces assets/nodejs-project/ from the published npm tarball (or `--source <dir>` for a local checkout). Aborts loudly if any *.node or binding.gyp turn up. Bundle for v0.0.169: ~62 MB, 5444 files. Smoke-tested by booting JSS from the bundled tree before committing.
1 parent 89b7b32 commit 0b0921f

3 files changed

Lines changed: 108 additions & 7 deletions

File tree

ARCHITECTURE.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@ Ship a single-tap Android install that runs a personal Solid pod on the phone. T
4141
1. App `main()` → run Flutter app
4242
2. Flutter `initState` → call `NodejsMobile.startNodeProject()` with:
4343
- script: `bin/jss.js`
44-
- args: `['start', '--single-user', '--port', '4443', '--data-root', <android-files-dir>/data]`
44+
- args: `['start', '--single-user', '--port', '4443', '--host', '127.0.0.1', '--root', '<android-files-dir>/data', '--idp']`
45+
- env: `JSS_SINGLE_USER_PASSWORD=<derived-or-prompted>` (only on first launch, to seed the IDP account)
4546
3. Node thread starts; JSS imports its modules; Fastify binds to `127.0.0.1:4443`
4647
4. Flutter listens for the "ready" message on the channel (or polls `GET /` until 200) and shows the WebView
4748

4849
## Data layout on device
4950

50-
- `<android-files-dir>/data/` — JSS pod data (passed via `--data-root` and `DATA_ROOT` env)
51-
- `<android-files-dir>/data/.idp/` — IDP credentials, keys
52-
- `<android-files-dir>/.well-known/` — token store, etc.
51+
- `<android-files-dir>/data/` — JSS pod data (passed via `--root <path>` or `DATA_ROOT` env)
52+
- `<android-files-dir>/data/.idp/` — IDP credentials, keys (verified by spike: created on first boot)
53+
- `<android-files-dir>/data/.well-known/` — token store, etc. (when `--idp` is on)
5354
- `<cache-dir>/` — JSS notification queues, ephemeral state
5455

55-
The pod's filesystem layout is unchanged from desktop JSS — we just point `--data-root` at app-private storage.
56+
The pod's filesystem layout is unchanged from desktop JSS — we just point `--root` at app-private storage. Verified by booting `jss start --single-user --port 4444 --root /tmp/foo --idp`: full pod tree (profile/, public/, private/, inbox/, settings/, .idp/) is created at the supplied path with nothing leaking to `~/.jss/` or the cwd.
57+
58+
> **Spike note (2026-05-08):** the CLI flag is `-r, --root <path>`, not `--data-root` as initially drafted. The architecture docs and any future Dart launcher should use `--root`.
5659
5760
## Auth model on a single-user phone pod
5861

@@ -78,10 +81,11 @@ The pod's filesystem layout is unchanged from desktop JSS — we just point `--d
7881

7982
## Open questions
8083

81-
- Does `nodejs-mobile`'s most recent release ship Node ≥ 18? (verify before scaffold, but `engines.node: ">=18.0.0"` is JSS's floor)
84+
- Does `nodejs-mobile`'s most recent release ship Node ≥ 18? (`engines.node: ">=18.0.0"` is JSS's floor; spike on dev box ran Node 24 with one `oidc-provider` warning about preferring v22 LTS — runtime is *forgiving*, but we should pin the mobile target to whatever Node `nodejs-mobile` ships)
8285
- Memory ceiling on cheap Android devices (1 GB RAM)? `oidc-provider` is the heaviest dep; might need `--idp` off in a "lite" mode
8386
- How do we surface the WebID/pod URL outside the app? (Deep link? Share sheet? A "copy URL" button?)
8487
- Does the foreground-service notification need a stop action wired to a graceful Fastify shutdown? (yes — need to expose this via the plugin channel)
88+
- First-run UX: where do we surface the IDP password? Options: (a) auto-generate, store in Android Keystore, never show; (b) prompt user; (c) skip IDP entirely on phone (signed-in via did:nostr only)
8589

8690
## Build & release
8791

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ See the [feasibility spike](https://github.com/JavaScriptSolidServer/JavaScriptS
4040
- [ ] Flutter project scaffold (`flutter create .`)
4141
- [ ] `nodejs-mobile-flutter` plugin wired in
4242
- [ ] JSS source bundled as `assets/nodejs-project/`
43-
- [ ] Boot `bin/jss.js start --single-user --port 4443` on app launch
43+
- [ ] Boot `bin/jss.js start --single-user --port 4443 --host 127.0.0.1 --root <files-dir>/data --idp` on app launch (CLI surface verified by [spike](https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/366#issuecomment-4401585143))
4444
- [ ] WebView at `http://localhost:4443/`
4545
- [ ] Foreground service + persistent notification
4646
- [ ] APK build target (debug + release)

scripts/bundle-jss.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env bash
2+
#
3+
# bundle-jss.sh — populate assets/nodejs-project/ with a JSS bundle
4+
#
5+
# Pulls the published `javascript-solid-server` tarball from npm, installs
6+
# its production dependencies, and copies the result to assets/nodejs-project/.
7+
# That directory is then bundled into the APK as nodejs-mobile's project root.
8+
#
9+
# Usage:
10+
# ./scripts/bundle-jss.sh # latest published version
11+
# ./scripts/bundle-jss.sh 0.0.169 # a specific version
12+
# ./scripts/bundle-jss.sh --source ../JavaScriptSolidServer
13+
# # bundle from a local checkout (dev)
14+
#
15+
# Aborts if any *.node binaries or binding.gyp files turn up in the tree —
16+
# nodejs-mobile can't load native addons unless they're cross-compiled for
17+
# Android, and we explicitly want to keep the bundle pure-JS.
18+
19+
set -euo pipefail
20+
21+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
22+
DEST="$REPO_ROOT/assets/nodejs-project"
23+
24+
SOURCE_DIR=""
25+
VERSION="latest"
26+
27+
while [[ $# -gt 0 ]]; do
28+
case "$1" in
29+
--source)
30+
SOURCE_DIR="$2"
31+
shift 2
32+
;;
33+
-h|--help)
34+
sed -n '2,15p' "$0"
35+
exit 0
36+
;;
37+
*)
38+
VERSION="$1"
39+
shift
40+
;;
41+
esac
42+
done
43+
44+
TMPDIR="$(mktemp -d)"
45+
trap 'rm -rf "$TMPDIR"' EXIT
46+
47+
if [[ -n "$SOURCE_DIR" ]]; then
48+
if [[ ! -f "$SOURCE_DIR/package.json" ]]; then
49+
echo "ERROR: --source path '$SOURCE_DIR' has no package.json" >&2
50+
exit 1
51+
fi
52+
echo "==> Packing local source: $SOURCE_DIR"
53+
( cd "$SOURCE_DIR" && npm pack --pack-destination "$TMPDIR" >/dev/null )
54+
else
55+
echo "==> Pulling javascript-solid-server@$VERSION from npm"
56+
( cd "$TMPDIR" && npm pack "javascript-solid-server@$VERSION" >/dev/null )
57+
fi
58+
59+
cd "$TMPDIR"
60+
TARBALL="$(ls javascript-solid-server-*.tgz | head -1)"
61+
tar -xzf "$TARBALL"
62+
cd package
63+
64+
echo "==> Installing production dependencies"
65+
npm install --omit=dev --no-package-lock --no-audit --no-fund >/dev/null
66+
67+
echo "==> Sanity check: no native modules"
68+
NATIVE_HITS="$(find . \( -name "*.node" -o -name "binding.gyp" \) 2>/dev/null || true)"
69+
if [[ -n "$NATIVE_HITS" ]]; then
70+
echo "ERROR: native modules detected — nodejs-mobile won't load these" >&2
71+
echo "$NATIVE_HITS" >&2
72+
exit 1
73+
fi
74+
75+
PKG_VERSION="$(node -p "require('./package.json').version")"
76+
FILE_COUNT="$(find . -type f | wc -l | tr -d ' ')"
77+
SIZE="$(du -sh . | cut -f1)"
78+
79+
echo "==> Copying to $DEST"
80+
mkdir -p "$DEST"
81+
rm -rf "${DEST:?}"/*
82+
cp -r bin src package.json node_modules "$DEST/"
83+
84+
cat > "$DEST/.bundle-info" <<EOF
85+
javascript-solid-server@$PKG_VERSION
86+
bundled at $(date -u +%Y-%m-%dT%H:%M:%SZ)
87+
files: $FILE_COUNT
88+
size: $SIZE
89+
source: ${SOURCE_DIR:-npm:$VERSION}
90+
EOF
91+
92+
echo
93+
echo "Done."
94+
echo " Version: $PKG_VERSION"
95+
echo " Files: $FILE_COUNT"
96+
echo " Size: $SIZE"
97+
echo " Path: $DEST"

0 commit comments

Comments
 (0)