oc-phone-link 2.4.0 → 2.4.1
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 +79 -4
- package/LICENSE +21 -0
- package/README.md +20 -14
- package/beacon.mjs +26 -5
- package/package.json +18 -1
- package/whitelist.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
This file records the beacon's server-side changes. APK and app release notes
|
|
4
4
|
live in `../../CHANGELOG.md`; the `version` fields in `whitelist.json` are APK
|
|
5
|
-
release digests, not the server version.
|
|
5
|
+
release digests, not the server version. The app-side facts in the entries below
|
|
6
|
+
are attributed to the app repository's own changelog
|
|
7
|
+
(`nathwn12/my-opencode-app`, CHANGELOG.md), with the APK digest in
|
|
8
|
+
`whitelist.json` as the in-repo anchor.
|
|
6
9
|
|
|
7
10
|
## [Unreleased]
|
|
8
11
|
|
|
9
|
-
## [2.4.
|
|
12
|
+
## [2.4.1] - 2026-11-29
|
|
10
13
|
|
|
11
14
|
Ships with the 2.4.0 app. The app and beacon must be upgraded together.
|
|
12
15
|
|
|
16
|
+
- Upgrading a state written by 2.2.0/2.3.x: a v5 PIN record with no recorded
|
|
17
|
+
digit length is cleared on load, along with its claim. Every device key and
|
|
18
|
+
the owner token survive byte-identically and `v` stays 5, so paired
|
|
19
|
+
devices stay paired. A four-digit PIN must be set again on the PC before a
|
|
20
|
+
new device can pair. The migration logs one line saying so and runs once;
|
|
21
|
+
new PIN records store `len` and the panel echoes it.
|
|
13
22
|
- The shared code is exactly four digits: `pinPattern` is `^\d{4}$` in
|
|
14
23
|
`beacon.mjs` and is used by `setPin`, `/setup` and `/auth`. The panel
|
|
15
24
|
input and its client-side check were updated to match. PBKDF2-SHA256 at
|
|
@@ -40,11 +49,77 @@ Ships with the 2.4.0 app. The app and beacon must be upgraded together.
|
|
|
40
49
|
revoke-fails-closed, both `/info` shapes and the once-per-source discovery
|
|
41
50
|
log.
|
|
42
51
|
|
|
43
|
-
Proof: `node --test beacon.test.mjs` EXIT 0 —
|
|
44
|
-
(baseline
|
|
52
|
+
Proof: `node --test beacon.test.mjs` EXIT 0 — 42 tests, 42 pass, 0 fail
|
|
53
|
+
(baseline 37/37 before this migration; all 37 still pass). `bun run check` was already EXIT 1 at baseline on the
|
|
45
54
|
unrelated `packages/janua` MCP conformance timeout; the `oc-phone-link`
|
|
46
55
|
workspace portion passes 37/37.
|
|
47
56
|
|
|
57
|
+
## 2.3.3
|
|
58
|
+
|
|
59
|
+
- Tagged as `oc-phone-link@2.3.3` (commit `680ff40`) and published as npm
|
|
60
|
+
latest. The only package change restored `repository`, `homepage` and
|
|
61
|
+
`bugs` in `package.json` so provenance publishing passes; no beacon, APK
|
|
62
|
+
or wire change shipped.
|
|
63
|
+
- Scope: **server-only** packaging metadata. A 2.2.0 APK user does not need to
|
|
64
|
+
update; the PIN and key flow are unchanged.
|
|
65
|
+
|
|
66
|
+
## 2.3.2
|
|
67
|
+
|
|
68
|
+
- Tagged as `oc-phone-link@2.3.2` (commit `9f2938c`, the lint sweep).
|
|
69
|
+
`json()` spreads `extra` directly and two test helpers drop redundant
|
|
70
|
+
`|| {}` defaults; no runtime behaviour, endpoint or APK changed. The npm
|
|
71
|
+
registry has no 2.3.2 tarball, so this entry records the tagged server tree.
|
|
72
|
+
- Scope: **server-only**, cosmetic. No APK update.
|
|
73
|
+
|
|
74
|
+
## 2.3.1
|
|
75
|
+
|
|
76
|
+
- Tagged as `oc-phone-link@2.3.1` (commit `87bd029`). `beacon.test.mjs`
|
|
77
|
+
gained socket-close guards so the suite stops hanging after socket failures;
|
|
78
|
+
no beacon source changed. The npm registry has no 2.3.1 tarball.
|
|
79
|
+
- Scope: **server-only** test hygiene. No APK update.
|
|
80
|
+
|
|
81
|
+
## 2.3.0
|
|
82
|
+
|
|
83
|
+
- Tagged as `oc-phone-link@2.3.0` (merge `5d4c748`) and published to npm.
|
|
84
|
+
The server tree entered this monorepo in `bc0a0c4` with the front-door
|
|
85
|
+
README added in `44cb104`: eight-digit PIN, 90-day idle keys rotating at
|
|
86
|
+
45 days, UDP 41337 discovery, the HTTPS panel on 41338 and proxy on 41340,
|
|
87
|
+
and the loopback-only 41341 tunnel listener preview. The import itself made
|
|
88
|
+
no wire change.
|
|
89
|
+
- The release ships Android APK 2.2.0 (digest in `whitelist.json`, release
|
|
90
|
+
notes in `nathwn12/my-opencode-app`). The APK sets the first PIN from the
|
|
91
|
+
phone in one `/setup` request, with a private-network guard and claim
|
|
92
|
+
attribution; the tunnel client and APK tunnel mode were deferred from 2.2.0
|
|
93
|
+
to 2.3.0.
|
|
94
|
+
- Scope: **app-affecting**. A 2.2.0 APK already has the app side; an older APK
|
|
95
|
+
must update to pair with this beacon's eight-digit flow.
|
|
96
|
+
|
|
97
|
+
## 2.2.0
|
|
98
|
+
|
|
99
|
+
- App release 2.2.0 (APK digest in `whitelist.json`). The first PIN may be set
|
|
100
|
+
from the phone once via `POST /setup {pin, device, name}`, which also mints
|
|
101
|
+
that phone's key: private peers only, 409 `pin-exists` afterwards, 404 on
|
|
102
|
+
the tunnel listener. The claim is attributed in the panel and `agent.log`.
|
|
103
|
+
Eight-digit/600k PIN rules, owner token, 90-day idle / 45-day rotation keys
|
|
104
|
+
and the panel are unchanged.
|
|
105
|
+
- Server 2.2.0 was staged in `bc0a0c4` and is the source of the 2.3.0 npm
|
|
106
|
+
release; its beacon carries the 41341 listener preview. App notes:
|
|
107
|
+
`nathwn12/my-opencode-app` CHANGELOG 2.2.0.
|
|
108
|
+
- Scope: **app-affecting** for first-PIN-from-phone. A 2.2.0 APK user already
|
|
109
|
+
has it; only the 2.4.0 pairing rewrite needs a new APK.
|
|
110
|
+
|
|
111
|
+
## 2.1.0
|
|
112
|
+
|
|
113
|
+
- App release 2.1.0 (APK digest in `whitelist.json`, notes in
|
|
114
|
+
`nathwn12/my-opencode-app` CHANGELOG 2.1.0). No loopback auth bypass; no
|
|
115
|
+
password or token sent to the phone (upstream Basic auth is injected
|
|
116
|
+
in-process); auth-bound Android vault, re-lock and FLAG_SECURE; eight-digit
|
|
117
|
+
600k PIN with capped async derivation; per-device keys with 90-day idle /
|
|
118
|
+
45-day rotation; streaming and WebSocket proxy; cert SAN for active LAN IPs;
|
|
119
|
+
upstream port from the plugin context; minSdk 29.
|
|
120
|
+
- Scope: **app-affecting** (APK and beacon together). A 2.2.0 APK already
|
|
121
|
+
carries all of it; an older APK must update.
|
|
122
|
+
|
|
48
123
|
## 2.0.11
|
|
49
124
|
|
|
50
125
|
- A targeted `revoke(id)` fails closed. Keys with no device association,
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nathan <137482711+nathwn12@users.noreply.github.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,32 +10,38 @@
|
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Install the published [oc-phone-link plugin](https://www.npmjs.com/package/oc-phone-link) from npm, add `oc-phone-link` to `~/.config/opencode/opencode.jsonc` and restart OpenCode:
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{ "plugins": ["oc-phone-link"] }
|
|
17
17
|
```
|
|
18
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.
|
|
19
|
+
There is no version pin here on purpose: npm's published version changes on every release of this package, so the install line stays true after the next publish. 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
|
+
## Upgrading from 2.2.0 or 2.3.x
|
|
22
|
+
|
|
23
|
+
An eight-digit PIN stored by an older beacon cannot work with the four-digit rule. On first start the beacon clears that PIN and its claim and logs one line in `agent.log`: set a four-digit PIN again on the PC. Device keys, paired phones and the owner token are kept, so paired devices stay paired and keep using their existing keys while the new PIN is set. The migration runs once; a state that already stores the PIN length is left untouched, including across restarts.
|
|
20
24
|
|
|
21
25
|
## First use — one entry, then automatic
|
|
22
26
|
|
|
23
|
-
1. Connect the PC and Android phone to the same Wi-Fi (or use the tunnel transport).
|
|
27
|
+
1. Connect the PC and Android phone to the same Wi-Fi (or use the tunnel transport with an app that supports it).
|
|
24
28
|
2. Install the Android app that ships with this beacon. From 2.4.0 the app and beacon share the four-digit flow; a 2.2.0 app still expects eight digits and cannot pair with this build.
|
|
25
|
-
3. Open `https://localhost:41338` on the PC. That page is the beacon's own control panel. Set a **four-digit** PIN there.
|
|
26
|
-
4. Open the phone app
|
|
27
|
-
5. The app shows a short TLS fingerprint. Compare it with the Verify line on the PC page. Enter the four digits **once** after the fingerprints match: the
|
|
28
|
-
6. Every later launch reuses that device key and asks for nothing. The key idle-expires after 180 days and rotates after 45; each use refreshes the idle clock, so weekly use never re-pairs. At most 16 keys are held.
|
|
29
|
+
3. Open `https://localhost:41338` on the PC. That page is the beacon's own control panel. Set a **four-digit** PIN there (or let the phone set the first one in step 5).
|
|
30
|
+
4. Open the phone app. You can let discovery find the PC, or enter the beacon address once and call `GET /info?pair=1` on the HTTPS port (41338) instead. That endpoint returns the beacon's LAN `urls` and `agentUrls`, `httpsPort`, `proxyPort`, `hosts`, `fingerprint` and `pinRequired` (`true` when no code has been set yet). It returns no code, key, owner token or password; a plain `GET /info` still needs a device key or the owner cookie. This is the pairing-without-discovery path.
|
|
31
|
+
5. The app shows a short TLS fingerprint. Compare it with the Verify line on the PC page. Enter the four digits **once** after the fingerprints match: the first code can be set from the phone through `/setup`, and a later device uses `/auth`. A successful call mints a device key. Five wrong codes from one source IP in five minutes arm a 15-minute lockout for that source; only a wrong code counts, and a correct one clears the record.
|
|
32
|
+
6. Every later launch reuses that device key and asks for nothing. The key idle-expires after 180 days and rotates after 45 days of age on use; each use refreshes the idle clock, so weekly use never re-pairs. At most 16 keys are held.
|
|
33
|
+
|
|
34
|
+
Discovery order on the phone is: last proven address first, then a UDP broadcast probe on 41337, then a parallel HTTPS scan of the local /24 on 41338. Entering the address and using `/info?pair=1` skips all three probes.
|
|
29
35
|
|
|
30
36
|
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. A revoked key fails closed on its next request.
|
|
31
37
|
|
|
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
|
|
38
|
+
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 keeps a loopback-only, plain-HTTP owner panel on 41339. When `OC_PHONE_LINK_TRANSPORT=tunnel` is set it also starts a plain-HTTP listener bound to `127.0.0.1:41341` for a tunnel client you provision. That listener serves the proxy plus `/health`, `/auth` and `/info` (plain `/info` still needs a device key or owner cookie, while `/info?pair=1` stays available for pairing) and answers 404 for `/setup`, `/reset` and `/revoke`. It does not exist in the default local-network mode.
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
By default nothing is uploaded anywhere: discovery, pairing and proxying all stay on your local network. Under `OC_PHONE_LINK_TRANSPORT=tunnel`, traffic through the 41341 listener is carried out of your network by the tunnel you provision, so that default claim no longer holds for those requests. The package itself ships no cloud relay, account or telemetry.
|
|
35
41
|
|
|
36
42
|
## Troubleshooting
|
|
37
43
|
|
|
38
|
-
- **The phone cannot find the beacon.**
|
|
44
|
+
- **The phone cannot find the beacon.** The app tries the last proven address, then UDP broadcast on 41337, then a parallel HTTPS /24 sweep on 41338; a blocked UDP port still leaves the sweep. `OC_PHONE_LINK_NO_UDP=1` disables the beacon's UDP listener for pair-by-address setups; enter the beacon address and use `GET /info?pair=1` instead. The log writes a `discovery addresses` line at startup and a `discovery request ... answer on` line for each probe, naming the addresses the beacon answers on; a probe from any other source is logged once per source as `discovery unexpected source`. Check `agent.log` before assuming the Wi-Fi is at fault.
|
|
39
45
|
- **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
46
|
- **The Android app cannot pair.** The old Android 1.4.1 and 2.2.0 apps expect eight digits and cannot pair with this beacon. Install the 2.4.0 app that ships with it.
|
|
41
47
|
- **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.
|
|
@@ -54,22 +60,22 @@ The test file covers PIN derivation, key revoke and rotation, discovery and the
|
|
|
54
60
|
- **PIN**: exactly four digits (`^\d{4}$` in the panel, `/setup` and `/auth`), stretched with the same PBKDF2-SHA256 at 600,000 iterations and stored salted and hashed. Only the owner's own networks may claim the first PIN.
|
|
55
61
|
- **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
62
|
- **Keys**: per-device, tagged with the device that minted them. A key idle-expires after 180 days (`KEY_TTL`) and rotates after 45 days of age on use; presenting it refreshes the idle clock, so wall-clock age alone never expires a key in use. The cookie carries a matching 180-day `Max-Age`. A targeted revoke fails closed and drops only that device's keys; revoke all drops every key.
|
|
57
|
-
- **Lockout**: at most five wrong
|
|
63
|
+
- **Lockout**: at most five wrong codes from one source IP in five minutes; the fifth arms a 15-minute lockout that is logged once. Constants in `beacon.mjs`: `AUTH_FAIL_MAX = 5`, `AUTH_WINDOW_MS = 5 * 60 * 1000`, `AUTH_LOCKOUT_MS = 15 * 60 * 1000`.
|
|
58
64
|
- **Pre-pair info**: `GET /info?pair=1` exposes only endpoint discovery (LAN URLs, HTTPS port, `pinRequired`); no code, key, owner token or password. Plain `/info` stays gated.
|
|
59
65
|
- **Limits**: ten requests per minute per address, request bodies capped at 4 KB, upstream calls time out after five seconds.
|
|
60
66
|
- **Local only**: no telemetry, no cloud relay, no analytics.
|
|
61
67
|
|
|
62
68
|
## Configuration
|
|
63
69
|
|
|
64
|
-
The beacon reads
|
|
70
|
+
The beacon reads the environment variables below, plus `LOCALAPPDATA` (or the process working directory when that is unset) as the parent of its default data directory; it reads nothing else from the environment.
|
|
65
71
|
|
|
66
72
|
- `OC_PHONE_LINK_PORT_BASE` - shift the fixed port block (41337 to 41341) by an offset, for when a port is taken.
|
|
67
73
|
- `OC_PHONE_LINK_BIND_HOST` - address to bind, default all interfaces.
|
|
68
|
-
- `OC_PHONE_LINK_DATA_DIR` - where state, TLS material and the agent log live.
|
|
74
|
+
- `OC_PHONE_LINK_DATA_DIR` - where state, TLS material and the agent log live; overrides the `LOCALAPPDATA`-based default.
|
|
69
75
|
- `OC_PHONE_LINK_NO_UDP` - set to 1 to disable UDP discovery and pair by address instead.
|
|
70
76
|
- `OC_PHONE_LINK_PASSWORD` (or `OPENCODE_SERVER_PASSWORD`) - upstream password the proxy presents when OpenCode asks for one.
|
|
71
77
|
- `OC_PHONE_LINK_UPSTREAM` - upstream port override when OpenCode is not on 28894.
|
|
72
|
-
- `OC_PHONE_LINK_TRANSPORT` - set to `tunnel` to
|
|
78
|
+
- `OC_PHONE_LINK_TRANSPORT` - set to `tunnel` to start the plain-HTTP, loopback-bound listener on 41341 for a tunnel you provision.
|
|
73
79
|
|
|
74
80
|
## Requirements
|
|
75
81
|
|
package/beacon.mjs
CHANGED
|
@@ -252,9 +252,22 @@ function loadState() {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
let changed = false;
|
|
255
|
+
let pinMigrationLog = null;
|
|
255
256
|
const pinPresent = s.pin !== undefined && s.pin !== null;
|
|
256
257
|
if (s.pin === undefined) { s.pin = null; changed = true; }
|
|
257
258
|
else if (s.pin !== null && !validPin(s.pin)) return { ok: false, error: "state pin is invalid" };
|
|
259
|
+
// A v5 PIN record with no `len` was written before the four-digit rule: its
|
|
260
|
+
// hash belongs to a longer code that /auth now rejects, so the PIN is dead.
|
|
261
|
+
// Clear only the PIN and its claim. Keys and the owner stay: paired phones
|
|
262
|
+
// keep working. The marker lets this PIN-less state load again instead of
|
|
263
|
+
// tripping the "keys have no PIN" guard below.
|
|
264
|
+
if (pinPresent && !Number.isInteger(s.pin.len)) {
|
|
265
|
+
s.pin = null;
|
|
266
|
+
s.pinClaim = null;
|
|
267
|
+
s.pinResetNeeded = true;
|
|
268
|
+
pinMigrationLog = "state migrated: legacy PIN cleared; set a 4-digit PIN on the PC, paired devices stay paired";
|
|
269
|
+
changed = true;
|
|
270
|
+
}
|
|
258
271
|
if (s.keys === undefined) {
|
|
259
272
|
if (pinPresent) return { ok: false, error: "state keys are missing" };
|
|
260
273
|
s.keys = [];
|
|
@@ -265,7 +278,7 @@ function loadState() {
|
|
|
265
278
|
s.keys = s.keys.map(normalizeKey);
|
|
266
279
|
changed = true;
|
|
267
280
|
}
|
|
268
|
-
if (!pinPresent && s.keys.length > 0) return { ok: false, error: "state keys have no PIN" };
|
|
281
|
+
if (!pinPresent && s.keys.length > 0 && !s.pinResetNeeded) return { ok: false, error: "state keys have no PIN" };
|
|
269
282
|
|
|
270
283
|
const pruned = s.keys.filter((k) => now() - (k.lastUsed || 0) > KEY_TTL).length;
|
|
271
284
|
if (pruned) {
|
|
@@ -293,7 +306,9 @@ function loadState() {
|
|
|
293
306
|
if (changed) {
|
|
294
307
|
if (pruned) log("state keys pruned", pruned);
|
|
295
308
|
s.v = STATE_VERSION;
|
|
296
|
-
if (
|
|
309
|
+
if (saveState(s)) {
|
|
310
|
+
if (pinMigrationLog) log(pinMigrationLog);
|
|
311
|
+
} else log("state normalize not persisted");
|
|
297
312
|
}
|
|
298
313
|
return { ok: true, state: s };
|
|
299
314
|
}
|
|
@@ -363,7 +378,7 @@ async function setPin(pin, opts) {
|
|
|
363
378
|
// Another request may have claimed the PIN while this derivation was queued.
|
|
364
379
|
if (state.pin !== before) return "pin-exists";
|
|
365
380
|
const t = Date.now();
|
|
366
|
-
state.pin = { salt: salt, hash: hash, at: t };
|
|
381
|
+
state.pin = { salt: salt, hash: hash, at: t, len: p.length };
|
|
367
382
|
if (opts && opts.claim) state.pinClaim = { ip: opts.claim.ip, name: opts.claim.name, at: t };
|
|
368
383
|
if (opts && opts.keyRecord) {
|
|
369
384
|
if (!Array.isArray(state.keys)) state.keys = [];
|
|
@@ -377,6 +392,7 @@ async function setPin(pin, opts) {
|
|
|
377
392
|
log("pin set not persisted: rolled back");
|
|
378
393
|
return "save-failed";
|
|
379
394
|
}
|
|
395
|
+
delete state.pinResetNeeded;
|
|
380
396
|
log("pin set");
|
|
381
397
|
if (opts && opts.claim) log("pin set by phone", opts.claim.ip, opts.claim.name || "unknown");
|
|
382
398
|
return null;
|
|
@@ -478,8 +494,11 @@ function ownerToken(req) {
|
|
|
478
494
|
|
|
479
495
|
// Gate: loopback is a source address, never an identity. No isLocal() here.
|
|
480
496
|
function gate(req, opts) {
|
|
481
|
-
|
|
497
|
+
// A device key stays usable while the PIN is absent after the legacy-PIN
|
|
498
|
+
// migration: paired phones keep working until a new four-digit PIN is set.
|
|
499
|
+
// With no key and no PIN the state is still a first-time setup.
|
|
482
500
|
if (keyOk(req)) return null;
|
|
501
|
+
if (!state.pin || !state.pin.hash) return "setup";
|
|
483
502
|
if (opts && opts.owner && ownerToken(req)) return null;
|
|
484
503
|
return "pin";
|
|
485
504
|
}
|
|
@@ -754,7 +773,7 @@ function loopPage() {
|
|
|
754
773
|
const ready = password() !== "";
|
|
755
774
|
const hasPin = !!(state.pin && state.pin.hash);
|
|
756
775
|
const pinBlock = hasPin
|
|
757
|
-
? '<p class="dim">PIN set. Enter it once on the phone.</p>'
|
|
776
|
+
? '<p class="dim">PIN set (' + (Number.isInteger(state.pin.len) ? state.pin.len : 4) + ' digits). Enter it once on the phone.</p>'
|
|
758
777
|
: '<p class="dim">No PIN yet. Set one here, then enter the same PIN on the phone.</p>\n' +
|
|
759
778
|
'<p><input id="pin" type="password" inputmode="numeric" autocomplete="new-password" placeholder="4 digits" size="18">' +
|
|
760
779
|
'<button data-set-pin="1">Set PIN</button></p>';
|
|
@@ -1081,6 +1100,7 @@ async function handleAgent(req, res, opts) {
|
|
|
1081
1100
|
state.keys = beforeKeys;
|
|
1082
1101
|
return json(req, res, 500, { ok: false, error: "save-failed" });
|
|
1083
1102
|
}
|
|
1103
|
+
delete state.pinResetNeeded;
|
|
1084
1104
|
authFails.clear();
|
|
1085
1105
|
setupRefused.clear();
|
|
1086
1106
|
log("pin and device keys reset; owner kept");
|
|
@@ -1246,6 +1266,7 @@ async function handleLoopback(req, res) {
|
|
|
1246
1266
|
res.end('{"ok":false,"error":"save-failed"}');
|
|
1247
1267
|
return;
|
|
1248
1268
|
}
|
|
1269
|
+
delete state.pinResetNeeded;
|
|
1249
1270
|
authFails.clear();
|
|
1250
1271
|
setupRefused.clear();
|
|
1251
1272
|
log("pin and device keys reset; owner kept");
|
package/package.json
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-phone-link",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Drive OpenCode from an Android phone on the same Wi-Fi: in-server beacon, pinned TLS, one PIN, no tray, no QR.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "nathwn12",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"opencode",
|
|
9
|
+
"opencode-plugin",
|
|
10
|
+
"plugin",
|
|
11
|
+
"android",
|
|
12
|
+
"phone",
|
|
13
|
+
"remote",
|
|
14
|
+
"beacon",
|
|
15
|
+
"tls"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22"
|
|
19
|
+
},
|
|
5
20
|
"type": "module",
|
|
6
21
|
"main": "./index.js",
|
|
7
22
|
"exports": {
|
|
@@ -18,6 +33,8 @@
|
|
|
18
33
|
"index.js",
|
|
19
34
|
"beacon.mjs",
|
|
20
35
|
"whitelist.json",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE",
|
|
21
38
|
"CHANGELOG.md"
|
|
22
39
|
],
|
|
23
40
|
"scripts": {
|
package/whitelist.json
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
"md5": "c5db10035ac6a3d99302b64fa01232bf"
|
|
5
5
|
},
|
|
6
6
|
"releases": [
|
|
7
|
+
{
|
|
8
|
+
"version": "2.4.0",
|
|
9
|
+
"sha256": "2550d7bea6b10966f52d9fa2b271a98cf2735c7f018e88b9a2c1c5120d3009ed",
|
|
10
|
+
"md5": "a0701e39e1546c8b772f4f826492511c"
|
|
11
|
+
},
|
|
7
12
|
{
|
|
8
13
|
"version": "2.2.0",
|
|
9
14
|
"sha256": "65210da2853ada04b3f03dcd7833a316fa5ac8b7545aa8502e6ca416652daa6e",
|
|
@@ -23,11 +28,6 @@
|
|
|
23
28
|
"version": "2.0.10",
|
|
24
29
|
"sha256": "9c1b36b1c4b93dc2d3e8a424ab33ae4a71d2fe9baa33bee44d32fc06ec18da6d",
|
|
25
30
|
"md5": "ee141e91dcd3617cb7dea53422ccc569"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"version": "2.0.9",
|
|
29
|
-
"sha256": "1fbc2a55540496633222417c992ffa89a0b5599a51f9a643be43f14b8f25f73b",
|
|
30
|
-
"md5": "4590715bafb8c67caf8922463c3c224a"
|
|
31
31
|
}
|
|
32
32
|
]
|
|
33
33
|
}
|