oc-phone-link 0.0.0-stage → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,92 @@
1
+ # Changelog — server plugin
2
+
3
+ This file records the beacon's server-side changes. APK and app release notes
4
+ live in `../../CHANGELOG.md`; the `version` fields in `whitelist.json` are APK
5
+ release digests, not the server version.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## 2.0.11
10
+
11
+ - A targeted `revoke(id)` fails closed. Keys with no device association,
12
+ including pre-2.0.10 bare hash strings, are dropped with the revoked device;
13
+ a tagged key for another device is kept. Trade-off: revoking one device also
14
+ invalidates pre-2.0.10 keys on other devices, which re-enter the PIN once and
15
+ get a tagged key in return.
16
+ - Rotation never mints an unassociated key. An associated key rotates into a
17
+ replacement that keeps its device tag; a legacy untagged key stays valid but
18
+ is not re-minted.
19
+ - `beacon.test.mjs` adds the legacy-key revoke and rotation regression checks.
20
+ The earlier single-device revoke test now asserts the fail-closed result.
21
+
22
+ Proof: `node --test test/*.mjs plugin/oc-phone-link/beacon.test.mjs` EXIT 0 —
23
+ 41 tests, 41 pass, 0 fail. Local test candidate only; nothing was pushed.
24
+
25
+ ## 2.0.10
26
+
27
+ - Per-device revoke now drops that device's keys as well as its device row.
28
+ Keys record the issuing device id at mint, including on rotation, and
29
+ `revoke(id)` deletes only those keys. Revoke All still drops every key.
30
+ - The key cookie gets a fresh 90-day `Expires` from the server clock on each
31
+ use, so a key used at day 80 still has a live cookie at day 91. `Max-Age`
32
+ stays at 90 days. The phone sends its device id with the PIN so minted keys
33
+ carry the association.
34
+
35
+ ## 2.0.9
36
+
37
+ The canonical app repo now carries the server lens work as well as the app work.
38
+ `beacon.mjs` keeps the app repo's narration purge and gains the harness copy's
39
+ server changes in full:
40
+
41
+ - Device keys are persistent credentials. Cookies carry `Max-Age` (90 days)
42
+ with `Secure`, `HttpOnly` and `SameSite=Strict`, and are renewed on use. A
43
+ stored key keeps working across a fresh browser session. Revoked keys still
44
+ return `401 pin`.
45
+ - Keys record `issued` and `lastUsed`. A key expires after 90 days idle and
46
+ rotates at 45 days of age on next use. Rotation mints a new key into the
47
+ browser cookie and keeps the old key valid, so an app holding the old key is
48
+ not broken. Legacy hash-string keys in `state.json` are upgraded on load.
49
+ - Proxy requests to a killed or hung upstream now return a JSON `502` within
50
+ one second instead of hanging. `GET /health` still answers `200` and reports
51
+ `upstream: "up" | "down"`.
52
+ - The server version has one source: `package.json`. Both `/health` and the
53
+ loopback panel print it.
54
+ - The focused lens tests (`beacon.test.mjs`) and the probe benchmark
55
+ (`probe-bench.mjs`) live beside the beacon, so the plugin and its proof move
56
+ together.
57
+
58
+ No APK change ships with this version from the server side; the phone app keeps
59
+ using the same key and header it already has. See `../../CHANGELOG.md` for the
60
+ 2.0.9 app changes.
61
+
62
+ ## 2.0.8
63
+
64
+ Server-side reliability and credential persistence. No APK change shipped with
65
+ this version; the phone app kept using the same key and header it already had.
66
+
67
+ - Device keys are now persistent credentials. Cookies carry `Max-Age` (90 days)
68
+ with `Secure`, `HttpOnly` and `SameSite=Strict`, and are renewed on use. A
69
+ stored key keeps working across a fresh browser session. Revoked keys still
70
+ return `401 pin`.
71
+ - Keys record `issued` and `lastUsed`. A key expires after 90 days idle and
72
+ rotates at 45 days of age on next use. Rotation mints a new key into the
73
+ browser cookie and keeps the old key valid, so an app holding the old key is
74
+ not broken. Legacy hash-string keys in `state.json` are upgraded on load.
75
+ - Proxy requests to a killed or hung upstream now return a JSON `502` within
76
+ one second instead of hanging. `GET /health` still answers `200` and reports
77
+ `upstream: "up" | "down"`.
78
+ - The `PROBE -> payload` and first proxied response paths were measured on
79
+ loopback before and after the change. They were already far below the 200 ms
80
+ target, so no hot-path work was removed. Measurement stays in `probe-bench.mjs`.
81
+ - The server version now has one source: `package.json`. Both `/health` and the
82
+ loopback panel print it. The `version` fields in `whitelist.json` are APK
83
+ release digests, not the server version, and are unchanged.
84
+
85
+ The APK signing-certificate and digest check remains log-only. A phone that
86
+ pairs from the same Wi-Fi is auto-paired; its digest is recorded in `agent.log`
87
+ as `digest-match` or `digest-unlisted`. Turning that check into a hard gate
88
+ needs the owner's explicit approval.
89
+
90
+ ## 2.0.7
91
+
92
+ Previous release. APK whitelist digests recorded in `whitelist.json`.
package/README.md CHANGED
@@ -1,3 +1,82 @@
1
- # Temporary Holding Version
1
+ <h1 align="center">oc-phone-link</h1>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center"><strong>Drive OpenCode from an Android phone on the same Wi-Fi: in-server beacon, pinned TLS, one PIN, no tray, no QR.</strong></p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/oc-phone-link"><img src="https://img.shields.io/npm/v/oc-phone-link" alt="npm version"></a>
7
+ <img src="https://img.shields.io/badge/platform-windows--linux-2b3137" alt="platform">
8
+ <a href="https://github.com/nathwn12/oc-collections/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="MIT"></a>
9
+ </p>
10
+
11
+ ## Install
12
+
13
+ Add the plugin to `~/.config/opencode/opencode.jsonc` and restart OpenCode:
14
+
15
+ ```json
16
+ { "plugins": ["oc-phone-link"] }
17
+ ```
18
+
19
+ The plugin starts the beacon during setup and stops it when the session disposes. There is no tray app, no separate service and no QR code: the beacon is a keyed reverse proxy in front of the OpenCode server your PC already runs.
20
+
21
+ ## Pair a phone
22
+
23
+ 1. Open `https://localhost:41338` on the PC. That page is the beacon's own control panel.
24
+ 2. Set an 8-digit PIN there. The phone enters it once, and only after the fingerprint check below.
25
+ 3. Open the phone app. It finds the beacon over UDP port 41337 on the local network and shows a short TLS fingerprint.
26
+ 4. Compare that short fingerprint with the Verify line on the PC page, then enter the PIN.
27
+ 5. The phone receives a device key: valid for 90 days, rotated after 45, and one of at most 16 keys the beacon will hold.
28
+
29
+ The PC page also lists paired devices with issue date, last use and last IP, and can revoke one device, revoke all of them, or reset the PIN.
30
+
31
+ ## Use it
32
+
33
+ Once paired, the phone sends its requests to the beacon on port 41340, which checks the device key and forwards to OpenCode on its own port (28894 by default). The beacon also keeps a loopback port on 41339 for the PC itself and an exposed port on 41341 for setup actions, which it refuses when the request did not come from the local machine.
34
+
35
+ The phone drives the same server session the PC does. Nothing is uploaded anywhere: discovery, pairing and proxying all stay on your network.
36
+
37
+ ## Security
38
+
39
+ - **PIN**: exactly 8 digits, stretched with PBKDF2-SHA256 at 600,000 iterations and stored salted and hashed. Only the owner's own networks may claim the first PIN.
40
+ - **TLS**: a self-signed certificate is generated on first start and pinned by the phone on first use. The PC page prints the full fingerprint and a short form for comparison.
41
+ - **Keys**: per-device, tagged with the device that minted them. A targeted revoke fails closed and drops only that device's keys; revoke all drops every key.
42
+ - **Lockout**: five failed PIN attempts from one address in ten minutes locks that address out for ten minutes.
43
+ - **Limits**: ten requests per minute per address, request bodies capped at 4 KB, upstream calls time out after five seconds.
44
+ - **Local only**: no telemetry, no cloud relay, no analytics.
45
+
46
+ ## Configuration
47
+
48
+ The beacon reads these environment variables and nothing else:
49
+
50
+ - `OC_PHONE_LINK_PORT_BASE` - shift the fixed port block (41337 to 41341) by an offset, for when a port is taken.
51
+ - `OC_PHONE_LINK_BIND_HOST` - address to bind, default all interfaces.
52
+ - `OC_PHONE_LINK_DATA_DIR` - where state, TLS material and the agent log live.
53
+ - `OC_PHONE_LINK_NO_UDP` - set to 1 to disable UDP discovery and pair by address instead.
54
+ - `OC_PHONE_LINK_PASSWORD` (or `OPENCODE_SERVER_PASSWORD`) - upstream password the proxy presents when OpenCode asks for one.
55
+ - `OC_PHONE_LINK_UPSTREAM` - upstream port override when OpenCode is not on 28894.
56
+ - `OC_PHONE_LINK_TRANSPORT` - set to `tunnel` to use the tunnel transport instead of the local network.
57
+
58
+ ## Development
59
+
60
+ ```text
61
+ node --test packages/oc-phone-link/beacon.test.mjs
62
+ node packages/oc-phone-link/probe-bench.mjs
63
+ ```
64
+
65
+ The test file covers PIN derivation, key revoke and rotation, discovery and the proxy gate. The bench script measures UDP discovery and the first proxied response on loopback through the public startBeacon seam.
66
+
67
+ ## Requirements
68
+
69
+ - OpenCode V2.
70
+ - Node 22 or newer.
71
+ - An Android phone on the same Wi-Fi, or the tunnel transport.
72
+
73
+ ## Status
74
+
75
+ **Unverified** - as-is, use at your own risk.
76
+
77
+ ## Links
78
+
79
+ - [Issues](https://github.com/nathwn12/oc-collections/issues)
80
+ - [Releases](https://github.com/nathwn12/oc-collections/releases)
81
+ - [Package source](https://github.com/nathwn12/oc-collections/tree/main/packages/oc-phone-link)
82
+ - [MIT licence](https://github.com/nathwn12/oc-collections/blob/main/LICENSE)