nervepay 1.3.9 → 1.4.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.
- package/bin/nervepay-cli.js +26 -30
- package/package.json +1 -1
package/bin/nervepay-cli.js
CHANGED
|
@@ -80,6 +80,9 @@ function findOpenClawConfigPath() {
|
|
|
80
80
|
join(homedir(), '.config', 'openclaw', 'openclaw.json'),
|
|
81
81
|
join(homedir(), '.moltbot', 'openclaw.json'),
|
|
82
82
|
join(homedir(), '.clawdbot', 'openclaw.json'),
|
|
83
|
+
// Common system-level locations (e.g. running as root on a server)
|
|
84
|
+
'/home/openclaw/.openclaw/openclaw.json',
|
|
85
|
+
'/opt/openclaw/openclaw.json',
|
|
83
86
|
];
|
|
84
87
|
for (const p of candidates) {
|
|
85
88
|
if (existsSync(p)) return p;
|
|
@@ -107,7 +110,9 @@ function extractGatewayConfig(config) {
|
|
|
107
110
|
token = config.gateway.auth.token;
|
|
108
111
|
}
|
|
109
112
|
|
|
113
|
+
// Environment variable overrides
|
|
110
114
|
if (process.env.OPENCLAW_GATEWAY_TOKEN) token = token || process.env.OPENCLAW_GATEWAY_TOKEN;
|
|
115
|
+
if (process.env.OPENCLAW_GATEWAY_URL) url = url || process.env.OPENCLAW_GATEWAY_URL;
|
|
111
116
|
if (process.env.OPENCLAW_GATEWAY_PORT && !url) url = `http://127.0.0.1:${process.env.OPENCLAW_GATEWAY_PORT}`;
|
|
112
117
|
|
|
113
118
|
return { url, token };
|
|
@@ -518,10 +523,8 @@ async function deviceNodePairing(options) {
|
|
|
518
523
|
const timeoutMs = parseInt(options.timeout, 10) * 1000;
|
|
519
524
|
|
|
520
525
|
// First attempt
|
|
521
|
-
let deviceToken = '';
|
|
522
526
|
try {
|
|
523
|
-
|
|
524
|
-
deviceToken = result.token;
|
|
527
|
+
await attemptConnect(WebSocket, wsUrl, ctx);
|
|
525
528
|
logOk('Connected (device already paired)');
|
|
526
529
|
} catch (e) {
|
|
527
530
|
if (e.message !== 'NOT_PAIRED') throw e;
|
|
@@ -543,8 +546,7 @@ async function deviceNodePairing(options) {
|
|
|
543
546
|
process.stdout.write(dim('.'));
|
|
544
547
|
|
|
545
548
|
try {
|
|
546
|
-
|
|
547
|
-
deviceToken = result.token;
|
|
549
|
+
await attemptConnect(WebSocket, wsUrl, ctx);
|
|
548
550
|
approved = true;
|
|
549
551
|
console.log();
|
|
550
552
|
break;
|
|
@@ -561,33 +563,27 @@ async function deviceNodePairing(options) {
|
|
|
561
563
|
logOk(bold('Paired!'));
|
|
562
564
|
console.log();
|
|
563
565
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
566
|
+
// Store the master gateway token (used for REST API calls by the backend).
|
|
567
|
+
// The device token from hello-ok is WS-only; the backend uses HTTP Bearer auth.
|
|
568
|
+
logInfo('Saving to NervePay...');
|
|
569
|
+
const client = new NervePayClient({
|
|
570
|
+
apiUrl: options.apiUrl || apiUrl,
|
|
571
|
+
agentDid,
|
|
572
|
+
privateKey,
|
|
573
|
+
});
|
|
571
574
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
575
|
+
const apiResult = await gateway.completeDevicePairing(client, {
|
|
576
|
+
device_token: gatewayToken,
|
|
577
|
+
device_id: deviceId,
|
|
578
|
+
gateway_url: gatewayUrl,
|
|
579
|
+
gateway_name: options.name,
|
|
580
|
+
});
|
|
578
581
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
} else {
|
|
585
|
-
divider();
|
|
586
|
-
logOk(bold('Device approved by gateway'));
|
|
587
|
-
field(' Device ID', deviceId.slice(0, 16) + '...');
|
|
588
|
-
field(' Agent DID', agentDid);
|
|
589
|
-
log(warn(' No device token received — gateway may not issue tokens for this role'));
|
|
590
|
-
}
|
|
582
|
+
divider();
|
|
583
|
+
logOk(bold('Gateway paired'));
|
|
584
|
+
field(' Gateway ID', apiResult.gateway_id);
|
|
585
|
+
field(' Device ID', deviceId.slice(0, 16) + '...');
|
|
586
|
+
field(' Agent DID', agentDid);
|
|
591
587
|
console.log();
|
|
592
588
|
log(dim('View in dashboard:'), info('Mission Control > Task Board'));
|
|
593
589
|
console.log();
|