overlord-cli 0.2606081356.0 → 0.2606090710.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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const CANONICAL_DEVICE_FILE: string;
|
|
2
|
+
|
|
3
|
+
export function getLegacyDesktopDeviceFilePath(userDataPath: string): string;
|
|
4
|
+
|
|
5
|
+
export function readOrCreateCanonicalDeviceFingerprintSync(input?: {
|
|
6
|
+
explicitFingerprint?: string | null | undefined;
|
|
7
|
+
legacyDesktopUserDataPath?: string | null | undefined;
|
|
8
|
+
}): string;
|
|
9
|
+
|
|
10
|
+
export function readOrCreateCanonicalDeviceFingerprint(input?: {
|
|
11
|
+
legacyDesktopUserDataPath?: string | null | undefined;
|
|
12
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import fsp from 'node:fs/promises';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
export const CANONICAL_DEVICE_FILE = path.join(os.homedir(), '.ovld', 'device.json');
|
|
8
|
+
|
|
9
|
+
export function getLegacyDesktopDeviceFilePath(userDataPath) {
|
|
10
|
+
return path.join(userDataPath, 'overlord-device.json');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function parseDeviceFingerprint(raw) {
|
|
14
|
+
const parsed = JSON.parse(raw);
|
|
15
|
+
return typeof parsed.deviceFingerprint === 'string' ? parsed.deviceFingerprint.trim() : '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function serializeDeviceFingerprint(deviceFingerprint) {
|
|
19
|
+
return `${JSON.stringify({ deviceFingerprint }, null, 2)}\n`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function readDeviceFingerprintSync(filePath) {
|
|
23
|
+
try {
|
|
24
|
+
const fingerprint = parseDeviceFingerprint(fs.readFileSync(filePath, 'utf8'));
|
|
25
|
+
return fingerprint || null;
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function readDeviceFingerprint(filePath) {
|
|
32
|
+
try {
|
|
33
|
+
const fingerprint = parseDeviceFingerprint(await fsp.readFile(filePath, 'utf8'));
|
|
34
|
+
return fingerprint || null;
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function writeCanonicalDeviceFingerprintSync(deviceFingerprint) {
|
|
41
|
+
fs.mkdirSync(path.dirname(CANONICAL_DEVICE_FILE), { recursive: true });
|
|
42
|
+
fs.writeFileSync(CANONICAL_DEVICE_FILE, serializeDeviceFingerprint(deviceFingerprint), 'utf8');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function writeCanonicalDeviceFingerprint(deviceFingerprint) {
|
|
46
|
+
await fsp.mkdir(path.dirname(CANONICAL_DEVICE_FILE), { recursive: true });
|
|
47
|
+
await fsp.writeFile(CANONICAL_DEVICE_FILE, serializeDeviceFingerprint(deviceFingerprint), 'utf8');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function readOrCreateCanonicalDeviceFingerprintSync({
|
|
51
|
+
explicitFingerprint,
|
|
52
|
+
legacyDesktopUserDataPath
|
|
53
|
+
} = {}) {
|
|
54
|
+
const explicit = typeof explicitFingerprint === 'string' ? explicitFingerprint.trim() : '';
|
|
55
|
+
if (explicit) return explicit;
|
|
56
|
+
|
|
57
|
+
const canonical = readDeviceFingerprintSync(CANONICAL_DEVICE_FILE);
|
|
58
|
+
if (canonical) return canonical;
|
|
59
|
+
|
|
60
|
+
if (legacyDesktopUserDataPath) {
|
|
61
|
+
const legacy = readDeviceFingerprintSync(getLegacyDesktopDeviceFilePath(legacyDesktopUserDataPath));
|
|
62
|
+
if (legacy) {
|
|
63
|
+
writeCanonicalDeviceFingerprintSync(legacy);
|
|
64
|
+
return legacy;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const deviceFingerprint = randomUUID();
|
|
69
|
+
writeCanonicalDeviceFingerprintSync(deviceFingerprint);
|
|
70
|
+
return deviceFingerprint;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function readOrCreateCanonicalDeviceFingerprint({
|
|
74
|
+
legacyDesktopUserDataPath
|
|
75
|
+
} = {}) {
|
|
76
|
+
const canonical = await readDeviceFingerprint(CANONICAL_DEVICE_FILE);
|
|
77
|
+
if (canonical) return canonical;
|
|
78
|
+
|
|
79
|
+
if (legacyDesktopUserDataPath) {
|
|
80
|
+
const legacy = await readDeviceFingerprint(
|
|
81
|
+
getLegacyDesktopDeviceFilePath(legacyDesktopUserDataPath)
|
|
82
|
+
);
|
|
83
|
+
if (legacy) {
|
|
84
|
+
await writeCanonicalDeviceFingerprint(legacy);
|
|
85
|
+
return legacy;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const deviceFingerprint = randomUUID();
|
|
90
|
+
await writeCanonicalDeviceFingerprint(deviceFingerprint);
|
|
91
|
+
return deviceFingerprint;
|
|
92
|
+
}
|
package/bin/_cli/runner.mjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { execFileSync, spawn } from 'node:child_process';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
|
-
import fs from 'node:fs';
|
|
6
4
|
import os from 'node:os';
|
|
7
|
-
|
|
5
|
+
|
|
6
|
+
import { readOrCreateCanonicalDeviceFingerprintSync } from './device-identity.mjs';
|
|
8
7
|
|
|
9
8
|
const OVLD_ENTRY = process.argv[1];
|
|
10
|
-
const DEVICE_FILE = path.join(os.homedir(), '.ovld', 'device.json');
|
|
11
9
|
const DEFAULT_TMUX_COMMAND = 'tmux new-session bash {script}';
|
|
12
10
|
|
|
13
11
|
/** @internal Test-only overrides for protocol/launch subprocess calls. */
|
|
@@ -65,22 +63,7 @@ export function readOrCreateDeviceFingerprint(flags) {
|
|
|
65
63
|
typeof flags['device-fingerprint'] === 'string'
|
|
66
64
|
? flags['device-fingerprint'].trim()
|
|
67
65
|
: process.env.OVERLORD_DEVICE_FINGERPRINT?.trim();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const raw = fs.readFileSync(DEVICE_FILE, 'utf8');
|
|
72
|
-
const parsed = JSON.parse(raw);
|
|
73
|
-
if (typeof parsed.deviceFingerprint === 'string' && parsed.deviceFingerprint.trim()) {
|
|
74
|
-
return parsed.deviceFingerprint.trim();
|
|
75
|
-
}
|
|
76
|
-
} catch {
|
|
77
|
-
// Create below.
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const deviceFingerprint = crypto.randomUUID();
|
|
81
|
-
fs.mkdirSync(path.dirname(DEVICE_FILE), { recursive: true });
|
|
82
|
-
fs.writeFileSync(DEVICE_FILE, `${JSON.stringify({ deviceFingerprint }, null, 2)}\n`, 'utf8');
|
|
83
|
-
return deviceFingerprint;
|
|
66
|
+
return readOrCreateCanonicalDeviceFingerprintSync({ explicitFingerprint: explicit });
|
|
84
67
|
}
|
|
85
68
|
|
|
86
69
|
function runOvld(args, env = {}) {
|