squad-openclaw 2026.2.2004 → 2026.2.2006
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/dist/index.js +28 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1352,10 +1352,10 @@ function registerVersionMethods(api) {
|
|
|
1352
1352
|
|
|
1353
1353
|
// src/relay-client.ts
|
|
1354
1354
|
import { WebSocket as NodeWebSocket } from "ws";
|
|
1355
|
-
import
|
|
1356
|
-
import
|
|
1357
|
-
import
|
|
1358
|
-
import
|
|
1355
|
+
import crypto3 from "crypto";
|
|
1356
|
+
import fs7 from "fs";
|
|
1357
|
+
import path7 from "path";
|
|
1358
|
+
import os2 from "os";
|
|
1359
1359
|
|
|
1360
1360
|
// src/e2e-crypto.ts
|
|
1361
1361
|
import crypto from "crypto";
|
|
@@ -1434,20 +1434,14 @@ var E2ECrypto = class {
|
|
|
1434
1434
|
}
|
|
1435
1435
|
};
|
|
1436
1436
|
|
|
1437
|
-
// src/
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
const raw = fs6.readFileSync(configPath, "utf-8");
|
|
1443
|
-
const config = JSON.parse(raw);
|
|
1444
|
-
return config?.gateway?.auth?.token ?? config?.gateway?.remote?.token ?? config?.gateway?.token ?? null;
|
|
1445
|
-
} catch {
|
|
1446
|
-
return null;
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1437
|
+
// src/device-keys.ts
|
|
1438
|
+
import crypto2 from "crypto";
|
|
1439
|
+
import fs6 from "fs";
|
|
1440
|
+
import path6 from "path";
|
|
1441
|
+
import os from "os";
|
|
1449
1442
|
var RELAY_DATA_DIR = path6.join(os.homedir(), ".openclaw", "squad-ceo-data", "relay");
|
|
1450
1443
|
var RELAY_STATE_PATH = path6.join(RELAY_DATA_DIR, "squad-relay.json");
|
|
1444
|
+
var PENDING_APPROVAL_PATH = path6.join(RELAY_DATA_DIR, "pending-approval.json");
|
|
1451
1445
|
function readRelayState() {
|
|
1452
1446
|
try {
|
|
1453
1447
|
const raw = fs6.readFileSync(RELAY_STATE_PATH, "utf-8");
|
|
@@ -1478,7 +1472,7 @@ function loadOrCreateRelayDeviceKeys() {
|
|
|
1478
1472
|
const privateKeyPem = privateKey.export({ type: "pkcs8", format: "pem" });
|
|
1479
1473
|
const keys = { deviceId, publicKey: publicKeyB64, privateKeyPem };
|
|
1480
1474
|
writeRelayState({ ...state, deviceKeys: keys });
|
|
1481
|
-
console.log(`[
|
|
1475
|
+
console.log(`[device-keys] Generated relay device identity: ${deviceId.substring(0, 12)}...`);
|
|
1482
1476
|
return keys;
|
|
1483
1477
|
}
|
|
1484
1478
|
function writeDeviceInfoFile(keys) {
|
|
@@ -1494,16 +1488,29 @@ function writeDeviceInfoFile(keys) {
|
|
|
1494
1488
|
try {
|
|
1495
1489
|
fs6.writeFileSync(infoPath, JSON.stringify(info, null, 2));
|
|
1496
1490
|
} catch (err2) {
|
|
1497
|
-
console.error("[
|
|
1491
|
+
console.error("[device-keys] Failed to write relay-device-info.json:", err2);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
// src/relay-client.ts
|
|
1496
|
+
function readOperatorToken() {
|
|
1497
|
+
const stateDir = process.env.OPENCLAW_STATE_DIR || path7.join(os2.homedir(), ".openclaw");
|
|
1498
|
+
const configPath = path7.join(stateDir, "openclaw.json");
|
|
1499
|
+
try {
|
|
1500
|
+
const raw = fs7.readFileSync(configPath, "utf-8");
|
|
1501
|
+
const config = JSON.parse(raw);
|
|
1502
|
+
return config?.gateway?.auth?.token ?? config?.gateway?.remote?.token ?? config?.gateway?.token ?? null;
|
|
1503
|
+
} catch {
|
|
1504
|
+
return null;
|
|
1498
1505
|
}
|
|
1499
1506
|
}
|
|
1500
1507
|
function signDeviceIdentity(keys, clientId, clientMode, role, scopes, token, challengeNonce) {
|
|
1501
1508
|
const signedAtMs = Date.now();
|
|
1502
|
-
const nonce = challengeNonce ||
|
|
1509
|
+
const nonce = challengeNonce || crypto3.randomBytes(16).toString("hex");
|
|
1503
1510
|
const scopeStr = scopes.join(",");
|
|
1504
1511
|
const payload = `v2|${keys.deviceId}|${clientId}|${clientMode}|${role}|${scopeStr}|${signedAtMs}|${token ?? ""}|${nonce}`;
|
|
1505
|
-
const privateKey =
|
|
1506
|
-
const signature =
|
|
1512
|
+
const privateKey = crypto3.createPrivateKey(keys.privateKeyPem);
|
|
1513
|
+
const signature = crypto3.sign(null, Buffer.from(payload), privateKey);
|
|
1507
1514
|
return {
|
|
1508
1515
|
id: keys.deviceId,
|
|
1509
1516
|
publicKey: keys.publicKey,
|
package/package.json
CHANGED