oc-phone-link 0.0.0-stage → 2.3.3
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 +94 -0
- package/README.md +87 -2
- package/beacon.mjs +1444 -0
- package/index.js +37 -0
- package/package.json +27 -4
- package/whitelist.json +33 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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.3.3] - 2026-11-29
|
|
10
|
+
|
|
11
|
+
## 2.0.11
|
|
12
|
+
|
|
13
|
+
- A targeted `revoke(id)` fails closed. Keys with no device association,
|
|
14
|
+
including pre-2.0.10 bare hash strings, are dropped with the revoked device;
|
|
15
|
+
a tagged key for another device is kept. Trade-off: revoking one device also
|
|
16
|
+
invalidates pre-2.0.10 keys on other devices, which re-enter the PIN once and
|
|
17
|
+
get a tagged key in return.
|
|
18
|
+
- Rotation never mints an unassociated key. An associated key rotates into a
|
|
19
|
+
replacement that keeps its device tag; a legacy untagged key stays valid but
|
|
20
|
+
is not re-minted.
|
|
21
|
+
- `beacon.test.mjs` adds the legacy-key revoke and rotation regression checks.
|
|
22
|
+
The earlier single-device revoke test now asserts the fail-closed result.
|
|
23
|
+
|
|
24
|
+
Proof: `node --test test/*.mjs plugin/oc-phone-link/beacon.test.mjs` EXIT 0 —
|
|
25
|
+
41 tests, 41 pass, 0 fail. Local test candidate only; nothing was pushed.
|
|
26
|
+
|
|
27
|
+
## 2.0.10
|
|
28
|
+
|
|
29
|
+
- Per-device revoke now drops that device's keys as well as its device row.
|
|
30
|
+
Keys record the issuing device id at mint, including on rotation, and
|
|
31
|
+
`revoke(id)` deletes only those keys. Revoke All still drops every key.
|
|
32
|
+
- The key cookie gets a fresh 90-day `Expires` from the server clock on each
|
|
33
|
+
use, so a key used at day 80 still has a live cookie at day 91. `Max-Age`
|
|
34
|
+
stays at 90 days. The phone sends its device id with the PIN so minted keys
|
|
35
|
+
carry the association.
|
|
36
|
+
|
|
37
|
+
## 2.0.9
|
|
38
|
+
|
|
39
|
+
The canonical app repo now carries the server lens work as well as the app work.
|
|
40
|
+
`beacon.mjs` keeps the app repo's narration purge and gains the harness copy's
|
|
41
|
+
server changes in full:
|
|
42
|
+
|
|
43
|
+
- Device keys are persistent credentials. Cookies carry `Max-Age` (90 days)
|
|
44
|
+
with `Secure`, `HttpOnly` and `SameSite=Strict`, and are renewed on use. A
|
|
45
|
+
stored key keeps working across a fresh browser session. Revoked keys still
|
|
46
|
+
return `401 pin`.
|
|
47
|
+
- Keys record `issued` and `lastUsed`. A key expires after 90 days idle and
|
|
48
|
+
rotates at 45 days of age on next use. Rotation mints a new key into the
|
|
49
|
+
browser cookie and keeps the old key valid, so an app holding the old key is
|
|
50
|
+
not broken. Legacy hash-string keys in `state.json` are upgraded on load.
|
|
51
|
+
- Proxy requests to a killed or hung upstream now return a JSON `502` within
|
|
52
|
+
one second instead of hanging. `GET /health` still answers `200` and reports
|
|
53
|
+
`upstream: "up" | "down"`.
|
|
54
|
+
- The server version has one source: `package.json`. Both `/health` and the
|
|
55
|
+
loopback panel print it.
|
|
56
|
+
- The focused lens tests (`beacon.test.mjs`) and the probe benchmark
|
|
57
|
+
(`probe-bench.mjs`) live beside the beacon, so the plugin and its proof move
|
|
58
|
+
together.
|
|
59
|
+
|
|
60
|
+
No APK change ships with this version from the server side; the phone app keeps
|
|
61
|
+
using the same key and header it already has. See `../../CHANGELOG.md` for the
|
|
62
|
+
2.0.9 app changes.
|
|
63
|
+
|
|
64
|
+
## 2.0.8
|
|
65
|
+
|
|
66
|
+
Server-side reliability and credential persistence. No APK change shipped with
|
|
67
|
+
this version; the phone app kept using the same key and header it already had.
|
|
68
|
+
|
|
69
|
+
- Device keys are now persistent credentials. Cookies carry `Max-Age` (90 days)
|
|
70
|
+
with `Secure`, `HttpOnly` and `SameSite=Strict`, and are renewed on use. A
|
|
71
|
+
stored key keeps working across a fresh browser session. Revoked keys still
|
|
72
|
+
return `401 pin`.
|
|
73
|
+
- Keys record `issued` and `lastUsed`. A key expires after 90 days idle and
|
|
74
|
+
rotates at 45 days of age on next use. Rotation mints a new key into the
|
|
75
|
+
browser cookie and keeps the old key valid, so an app holding the old key is
|
|
76
|
+
not broken. Legacy hash-string keys in `state.json` are upgraded on load.
|
|
77
|
+
- Proxy requests to a killed or hung upstream now return a JSON `502` within
|
|
78
|
+
one second instead of hanging. `GET /health` still answers `200` and reports
|
|
79
|
+
`upstream: "up" | "down"`.
|
|
80
|
+
- The `PROBE -> payload` and first proxied response paths were measured on
|
|
81
|
+
loopback before and after the change. They were already far below the 200 ms
|
|
82
|
+
target, so no hot-path work was removed. Measurement stays in `probe-bench.mjs`.
|
|
83
|
+
- The server version now has one source: `package.json`. Both `/health` and the
|
|
84
|
+
loopback panel print it. The `version` fields in `whitelist.json` are APK
|
|
85
|
+
release digests, not the server version, and are unchanged.
|
|
86
|
+
|
|
87
|
+
The APK signing-certificate and digest check remains log-only. A phone that
|
|
88
|
+
pairs from the same Wi-Fi is auto-paired; its digest is recorded in `agent.log`
|
|
89
|
+
as `digest-match` or `digest-unlisted`. Turning that check into a hard gate
|
|
90
|
+
needs the owner's explicit approval.
|
|
91
|
+
|
|
92
|
+
## 2.0.7
|
|
93
|
+
|
|
94
|
+
Previous release. APK whitelist digests recorded in `whitelist.json`.
|
package/README.md
CHANGED
|
@@ -1,3 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">oc-phone-link</h1>
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
Use the published [PC plugin 2.3.0](https://www.npmjs.com/package/oc-phone-link/v/2.3.0). Add `oc-phone-link` to `~/.config/opencode/opencode.jsonc` and restart OpenCode:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{ "plugins": ["oc-phone-link"] }
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The PC plugin and Android app use separate version numbers. 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
|
+
## First use
|
|
22
|
+
|
|
23
|
+
1. Connect the PC and Android phone to the same Wi-Fi.
|
|
24
|
+
2. Install the [Android 2.2.0 APK](https://github.com/nathwn12/oc-collections/releases/tag/oc-phone-link%402.3.0) (`oc-phone-link-v2.2.0.apk`) on the phone.
|
|
25
|
+
3. Open `https://localhost:41338` on the PC. That page is the beacon's own control panel. Set an 8-digit PIN there.
|
|
26
|
+
4. Open the phone app. It finds the beacon over UDP port 41337 on the local network and shows a short TLS fingerprint.
|
|
27
|
+
5. Compare that short fingerprint with the Verify line on the PC page. Enter the PIN only after the fingerprints match.
|
|
28
|
+
6. The phone receives a device key: valid for 90 days, rotated after 45, and one of at most 16 keys the beacon will hold.
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
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.
|
|
33
|
+
|
|
34
|
+
The phone drives the same server session the PC does. Nothing is uploaded anywhere: discovery, pairing and proxying all stay on your network.
|
|
35
|
+
|
|
36
|
+
## Troubleshooting
|
|
37
|
+
|
|
38
|
+
- **The phone cannot find the beacon.** Confirm both devices are on the same Wi-Fi and that UDP port 41337 can reach the PC. `OC_PHONE_LINK_NO_UDP=1` disables discovery for pair-by-address setups.
|
|
39
|
+
- **The TLS fingerprints differ.** Do not enter the PIN. Confirm the phone is showing this PC's beacon and compare its short fingerprint with the Verify line on the PC page before trying again.
|
|
40
|
+
- **The Android app cannot pair.** The old Android 1.4.1 APK is not compatible with this PC plugin. Install the 2.2.0 APK linked above.
|
|
41
|
+
- **The control panel does not open.** Confirm the plugin loaded after the OpenCode restart. If a port is taken, set `OC_PHONE_LINK_PORT_BASE` to shift the fixed port block.
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
node --test packages/oc-phone-link/beacon.test.mjs
|
|
47
|
+
node packages/oc-phone-link/probe-bench.mjs
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
## Security
|
|
53
|
+
|
|
54
|
+
- **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.
|
|
55
|
+
- **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.
|
|
56
|
+
- **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.
|
|
57
|
+
- **Lockout**: five failed PIN attempts from one address in ten minutes locks that address out for ten minutes.
|
|
58
|
+
- **Limits**: ten requests per minute per address, request bodies capped at 4 KB, upstream calls time out after five seconds.
|
|
59
|
+
- **Local only**: no telemetry, no cloud relay, no analytics.
|
|
60
|
+
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
The beacon reads these environment variables and nothing else:
|
|
64
|
+
|
|
65
|
+
- `OC_PHONE_LINK_PORT_BASE` - shift the fixed port block (41337 to 41341) by an offset, for when a port is taken.
|
|
66
|
+
- `OC_PHONE_LINK_BIND_HOST` - address to bind, default all interfaces.
|
|
67
|
+
- `OC_PHONE_LINK_DATA_DIR` - where state, TLS material and the agent log live.
|
|
68
|
+
- `OC_PHONE_LINK_NO_UDP` - set to 1 to disable UDP discovery and pair by address instead.
|
|
69
|
+
- `OC_PHONE_LINK_PASSWORD` (or `OPENCODE_SERVER_PASSWORD`) - upstream password the proxy presents when OpenCode asks for one.
|
|
70
|
+
- `OC_PHONE_LINK_UPSTREAM` - upstream port override when OpenCode is not on 28894.
|
|
71
|
+
- `OC_PHONE_LINK_TRANSPORT` - set to `tunnel` to use the tunnel transport instead of the local network.
|
|
72
|
+
|
|
73
|
+
## Requirements
|
|
74
|
+
|
|
75
|
+
- OpenCode V2.
|
|
76
|
+
- Node 22 or newer.
|
|
77
|
+
- An Android phone on the same Wi-Fi, or the tunnel transport.
|
|
78
|
+
|
|
79
|
+
## Status
|
|
80
|
+
|
|
81
|
+
**Unverified** - as-is, use at your own risk.
|
|
82
|
+
|
|
83
|
+
## Links
|
|
84
|
+
|
|
85
|
+
- [Issues](https://github.com/nathwn12/oc-collections/issues)
|
|
86
|
+
- [Releases](https://github.com/nathwn12/oc-collections/releases)
|
|
87
|
+
- [Package source](https://github.com/nathwn12/oc-collections/tree/main/packages/oc-phone-link)
|
|
88
|
+
- [MIT licence](https://github.com/nathwn12/oc-collections/blob/main/LICENSE)
|