@walkhi/code-relax 0.1.0-beta.3 → 0.1.0-beta.4
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/README.md
CHANGED
|
@@ -80,4 +80,4 @@ npm uninstall -g @walkhi/code-relax
|
|
|
80
80
|
|
|
81
81
|
## 发布边界
|
|
82
82
|
|
|
83
|
-
registry 当前公开包为 `@walkhi/code-relax@0.1.0-beta.
|
|
83
|
+
registry 当前公开包为 `@walkhi/code-relax@0.1.0-beta.3`,主 CLI 为 `relax`,并保留 `code-relax` 兼容入口。该版将 WMI 后的第二层 PowerShell broker 改为 Node worker,并加入 `%LOCALAPPDATA%\CodexRemote\install.log` 持久安装日志;本机启动交接、npm 打包和公开 registry 已验证,仍需在原故障电脑复核。详细规则见 [npm 分发](../docs/npm-distribution.md)。
|
|
@@ -18,12 +18,16 @@ import { relayAddress, validSecret } from './wire.mjs';
|
|
|
18
18
|
import { saveLanAuthorizations } from './lan-authorizations.mjs';
|
|
19
19
|
import { lanNetworks } from '../platform/windows/network-info.mjs';
|
|
20
20
|
|
|
21
|
-
const exec = promisify(execFile);
|
|
22
|
-
const script = fileURLToPath(import.meta.url);
|
|
23
|
-
const recordPath = root => path.join(root, 'self-relay-session.json');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const exec = promisify(execFile);
|
|
22
|
+
const script = fileURLToPath(import.meta.url);
|
|
23
|
+
const recordPath = root => path.join(root, 'self-relay-session.json');
|
|
24
|
+
const officialConfig = { url: 'wss://api.uulife.site/relay' };
|
|
25
|
+
|
|
26
|
+
async function loadConfig(stateRoot) {
|
|
27
|
+
const configPath = path.join(stateRoot, 'self-relay-config.json');
|
|
28
|
+
const stored = readRecord(configPath) || {};
|
|
29
|
+
const config = { ...officialConfig, ...stored };
|
|
30
|
+
if (!stored.url) writeRecord(configPath, config);
|
|
27
31
|
if (config.p2pIceServers !== undefined && !validProbeIceServers(config.p2pIceServers)) throw new Error('p2pIceServers 只接受最多 4 个 stun:主机:端口地址');
|
|
28
32
|
if (config.p2pWindowsRouteHelper !== undefined && typeof config.p2pWindowsRouteHelper !== 'boolean') throw new Error('p2pWindowsRouteHelper 必须是布尔值');
|
|
29
33
|
if (config.p2pWindowsRouteHelper && !/^[A-Za-z0-9_-]{32,128}$/.test(config.p2pWindowsRouteHelperToken || '')) throw new Error('p2pWindowsRouteHelperToken 无效');
|
|
@@ -37,8 +41,9 @@ async function loadConfig(stateRoot) {
|
|
|
37
41
|
(pairing.protocol === 'http:' && pairing.hostname !== '127.0.0.1')) throw new Error('self-relay-config.json 的 pairingUrl 必须是 HTTPS /pair 地址。');
|
|
38
42
|
return { ...config, url: resolved, pairingUrl: pairing.href };
|
|
39
43
|
}
|
|
40
|
-
async function registrationKey(config) {
|
|
41
|
-
|
|
44
|
+
async function registrationKey(config) {
|
|
45
|
+
if (config.url === officialConfig.url) return undefined;
|
|
46
|
+
const hostKeyFile = process.env.RELAY_HOST_KEY_FILE || config.hostKeyFile;
|
|
42
47
|
let hostKey;
|
|
43
48
|
if (hostKeyFile) hostKey = fs.readFileSync(hostKeyFile, 'utf8').trim();
|
|
44
49
|
else {
|
|
@@ -198,11 +198,13 @@ export async function startSelfRelay({ port = 0, hostKey = secret(), pairingTtlM
|
|
|
198
198
|
hostName = normalizeHostName(message.hostName);
|
|
199
199
|
}
|
|
200
200
|
catch { return fail(1008, 'Invalid LAN candidates'); }
|
|
201
|
-
room = durable ? rooms.get(message.deviceId) : undefined;
|
|
202
|
-
if (room && (room.status !== 'active' || !matches(message.deviceSecret, room.hostHash))) return fail();
|
|
203
|
-
if (!room) {
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
room = durable ? rooms.get(message.deviceId) : undefined;
|
|
202
|
+
if (room && (room.status !== 'active' || !matches(message.deviceSecret, room.hostHash))) return fail();
|
|
203
|
+
if (!room) {
|
|
204
|
+
// Durable computers prove future ownership with their generated device secret.
|
|
205
|
+
// The legacy deployment key remains accepted, but is no longer required for first registration.
|
|
206
|
+
if (!durable && !matches(message.key, hostHash)) return fail();
|
|
207
|
+
if (rooms.size >= 256) return fail(4429, 'Device limit reached');
|
|
206
208
|
const now = new Date().toISOString();
|
|
207
209
|
room = { id: durable ? message.deviceId : randomUUID(), durable,
|
|
208
210
|
revision: 0, status: 'active', clients: [], connections: new Map(), observers: new Map(), createdAt: now, updatedAt: now,
|