@metamask-previews/wallet-cli 0.0.0-preview-8bfa290fb → 0.0.0-preview-e8a256c39
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 +8 -4
- package/dist/commands/daemon/{call.d.mts → call.d.ts} +2 -2
- package/dist/commands/daemon/call.d.ts.map +1 -0
- package/dist/commands/daemon/{call.mjs → call.js} +30 -31
- package/dist/commands/daemon/call.js.map +1 -0
- package/dist/commands/daemon/{list.d.cts → list.d.ts} +2 -2
- package/dist/commands/daemon/list.d.ts.map +1 -0
- package/dist/commands/daemon/{list.mjs → list.js} +9 -10
- package/dist/commands/daemon/list.js.map +1 -0
- package/dist/commands/daemon/{purge.d.cts → purge.d.ts} +2 -2
- package/dist/commands/daemon/purge.d.ts.map +1 -0
- package/dist/commands/daemon/{purge.mjs → purge.js} +19 -20
- package/dist/commands/daemon/purge.js.map +1 -0
- package/dist/commands/daemon/{start.d.cts → start.d.ts} +2 -2
- package/dist/commands/daemon/start.d.ts.map +1 -0
- package/dist/commands/daemon/start.js +49 -0
- package/dist/commands/daemon/{start.cjs.map → start.js.map} +1 -1
- package/dist/commands/daemon/{status.d.cts → status.d.ts} +2 -2
- package/dist/commands/daemon/status.d.ts.map +1 -0
- package/dist/commands/daemon/{status.mjs → status.js} +10 -11
- package/dist/commands/daemon/status.js.map +1 -0
- package/dist/commands/daemon/{stop.d.cts → stop.d.ts} +2 -2
- package/dist/commands/daemon/stop.d.ts.map +1 -0
- package/dist/commands/daemon/{stop.mjs → stop.js} +9 -10
- package/dist/commands/daemon/stop.js.map +1 -0
- package/dist/commands/wallet/{send.d.cts → send.d.ts} +3 -3
- package/dist/commands/wallet/send.d.ts.map +1 -0
- package/dist/commands/wallet/{send.mjs → send.js} +111 -123
- package/dist/commands/wallet/send.js.map +1 -0
- package/dist/commands/wallet/{unlock.d.cts → unlock.d.ts} +2 -2
- package/dist/commands/wallet/unlock.d.ts.map +1 -0
- package/dist/commands/wallet/{unlock.mjs → unlock.js} +29 -30
- package/dist/commands/wallet/unlock.js.map +1 -0
- package/dist/daemon/{auto-approval.d.mts → auto-approval.d.ts} +3 -3
- package/dist/daemon/auto-approval.d.ts.map +1 -0
- package/dist/daemon/{auto-approval.mjs → auto-approval.js} +1 -1
- package/dist/daemon/auto-approval.js.map +1 -0
- package/dist/daemon/{daemon-client.d.mts → daemon-client.d.ts} +2 -2
- package/dist/daemon/daemon-client.d.ts.map +1 -0
- package/dist/daemon/{daemon-client.mjs → daemon-client.js} +8 -8
- package/dist/daemon/daemon-client.js.map +1 -0
- package/dist/daemon/daemon-entry.d.ts +2 -0
- package/dist/daemon/daemon-entry.d.ts.map +1 -0
- package/dist/daemon/{daemon-entry.mjs → daemon-entry.js} +12 -12
- package/dist/daemon/daemon-entry.js.map +1 -0
- package/dist/daemon/{daemon-spawn.d.mts → daemon-spawn.d.ts} +2 -2
- package/dist/daemon/daemon-spawn.d.ts.map +1 -0
- package/dist/daemon/{daemon-spawn.mjs → daemon-spawn.js} +7 -7
- package/dist/daemon/daemon-spawn.js.map +1 -0
- package/dist/daemon/{data-dir.d.cts → data-dir.d.ts} +1 -1
- package/dist/daemon/data-dir.d.ts.map +1 -0
- package/dist/daemon/{data-dir.mjs → data-dir.js} +3 -3
- package/dist/daemon/data-dir.js.map +1 -0
- package/dist/daemon/{paths.d.mts → paths.d.ts} +2 -2
- package/dist/daemon/paths.d.ts.map +1 -0
- package/dist/daemon/{paths.mjs → paths.js} +2 -2
- package/dist/daemon/paths.js.map +1 -0
- package/dist/daemon/{prompts.d.cts → prompts.d.ts} +1 -1
- package/dist/daemon/prompts.d.ts.map +1 -0
- package/dist/daemon/{prompts.mjs → prompts.js} +4 -4
- package/dist/daemon/prompts.js.map +1 -0
- package/dist/daemon/{rpc-socket-server.d.cts → rpc-socket-server.d.ts} +2 -2
- package/dist/daemon/rpc-socket-server.d.ts.map +1 -0
- package/dist/daemon/{rpc-socket-server.mjs → rpc-socket-server.js} +8 -8
- package/dist/daemon/rpc-socket-server.js.map +1 -0
- package/dist/daemon/{secrets.d.cts → secrets.d.ts} +1 -1
- package/dist/daemon/secrets.d.ts.map +1 -0
- package/dist/daemon/{secrets.mjs → secrets.js} +11 -23
- package/dist/daemon/secrets.js.map +1 -0
- package/dist/daemon/{send-transaction.d.cts → send-transaction.d.ts} +9 -9
- package/dist/daemon/send-transaction.d.ts.map +1 -0
- package/dist/daemon/{send-transaction.mjs → send-transaction.js} +3 -3
- package/dist/daemon/send-transaction.js.map +1 -0
- package/dist/daemon/{socket-line.d.cts → socket-line.d.ts} +2 -5
- package/dist/daemon/socket-line.d.ts.map +1 -0
- package/dist/daemon/{socket-line.mjs → socket-line.js} +1 -1
- package/dist/daemon/socket-line.js.map +1 -0
- package/dist/daemon/{stop-daemon.d.cts → stop-daemon.d.ts} +1 -1
- package/dist/daemon/stop-daemon.d.ts.map +1 -0
- package/dist/daemon/{stop-daemon.mjs → stop-daemon.js} +7 -7
- package/dist/daemon/stop-daemon.js.map +1 -0
- package/dist/daemon/{types.d.cts → types.d.ts} +4 -4
- package/dist/daemon/types.d.ts.map +1 -0
- package/dist/daemon/{types.mjs → types.js} +1 -1
- package/dist/daemon/types.js.map +1 -0
- package/dist/daemon/{utils.d.cts → utils.d.ts} +2 -3
- package/dist/daemon/utils.d.ts.map +1 -0
- package/dist/daemon/{utils.mjs → utils.js} +3 -3
- package/dist/daemon/utils.js.map +1 -0
- package/dist/daemon/{wallet-factory.d.cts → wallet-factory.d.ts} +4 -4
- package/dist/daemon/wallet-factory.d.ts.map +1 -0
- package/dist/daemon/{wallet-factory.mjs → wallet-factory.js} +12 -12
- package/dist/daemon/wallet-factory.js.map +1 -0
- package/dist/persistence/{KeyValueStore.d.cts → KeyValueStore.d.ts} +2 -2
- package/dist/persistence/KeyValueStore.d.ts.map +1 -0
- package/dist/persistence/KeyValueStore.js +59 -0
- package/dist/persistence/KeyValueStore.js.map +1 -0
- package/dist/persistence/{persistence.d.cts → persistence.d.ts} +5 -5
- package/dist/persistence/persistence.d.ts.map +1 -0
- package/dist/persistence/{persistence.mjs → persistence.js} +2 -2
- package/dist/persistence/persistence.js.map +1 -0
- package/dist/test/{run-command.d.cts → run-command.d.ts} +4 -4
- package/dist/test/run-command.d.ts.map +1 -0
- package/dist/test/{run-command.mjs → run-command.js} +3 -3
- package/dist/test/run-command.js.map +1 -0
- package/package.json +19 -15
- package/dist/commands/daemon/call.cjs +0 -79
- package/dist/commands/daemon/call.cjs.map +0 -1
- package/dist/commands/daemon/call.d.cts +0 -14
- package/dist/commands/daemon/call.d.cts.map +0 -1
- package/dist/commands/daemon/call.d.mts.map +0 -1
- package/dist/commands/daemon/call.mjs.map +0 -1
- package/dist/commands/daemon/list.cjs +0 -48
- package/dist/commands/daemon/list.cjs.map +0 -1
- package/dist/commands/daemon/list.d.cts.map +0 -1
- package/dist/commands/daemon/list.d.mts +0 -7
- package/dist/commands/daemon/list.d.mts.map +0 -1
- package/dist/commands/daemon/list.mjs.map +0 -1
- package/dist/commands/daemon/purge.cjs +0 -58
- package/dist/commands/daemon/purge.cjs.map +0 -1
- package/dist/commands/daemon/purge.d.cts.map +0 -1
- package/dist/commands/daemon/purge.d.mts +0 -10
- package/dist/commands/daemon/purge.d.mts.map +0 -1
- package/dist/commands/daemon/purge.mjs.map +0 -1
- package/dist/commands/daemon/start.cjs +0 -52
- package/dist/commands/daemon/start.d.cts.map +0 -1
- package/dist/commands/daemon/start.d.mts +0 -12
- package/dist/commands/daemon/start.d.mts.map +0 -1
- package/dist/commands/daemon/start.mjs +0 -50
- package/dist/commands/daemon/start.mjs.map +0 -1
- package/dist/commands/daemon/status.cjs +0 -59
- package/dist/commands/daemon/status.cjs.map +0 -1
- package/dist/commands/daemon/status.d.cts.map +0 -1
- package/dist/commands/daemon/status.d.mts +0 -7
- package/dist/commands/daemon/status.d.mts.map +0 -1
- package/dist/commands/daemon/status.mjs.map +0 -1
- package/dist/commands/daemon/stop.cjs +0 -26
- package/dist/commands/daemon/stop.cjs.map +0 -1
- package/dist/commands/daemon/stop.d.cts.map +0 -1
- package/dist/commands/daemon/stop.d.mts +0 -7
- package/dist/commands/daemon/stop.d.mts.map +0 -1
- package/dist/commands/daemon/stop.mjs.map +0 -1
- package/dist/commands/wallet/send.cjs +0 -332
- package/dist/commands/wallet/send.cjs.map +0 -1
- package/dist/commands/wallet/send.d.cts.map +0 -1
- package/dist/commands/wallet/send.d.mts +0 -42
- package/dist/commands/wallet/send.d.mts.map +0 -1
- package/dist/commands/wallet/send.mjs.map +0 -1
- package/dist/commands/wallet/unlock.cjs +0 -75
- package/dist/commands/wallet/unlock.cjs.map +0 -1
- package/dist/commands/wallet/unlock.d.cts.map +0 -1
- package/dist/commands/wallet/unlock.d.mts +0 -11
- package/dist/commands/wallet/unlock.d.mts.map +0 -1
- package/dist/commands/wallet/unlock.mjs.map +0 -1
- package/dist/daemon/auto-approval.cjs +0 -86
- package/dist/daemon/auto-approval.cjs.map +0 -1
- package/dist/daemon/auto-approval.d.cts +0 -22
- package/dist/daemon/auto-approval.d.cts.map +0 -1
- package/dist/daemon/auto-approval.d.mts.map +0 -1
- package/dist/daemon/auto-approval.mjs.map +0 -1
- package/dist/daemon/daemon-client.cjs +0 -149
- package/dist/daemon/daemon-client.cjs.map +0 -1
- package/dist/daemon/daemon-client.d.cts +0 -84
- package/dist/daemon/daemon-client.d.cts.map +0 -1
- package/dist/daemon/daemon-client.d.mts.map +0 -1
- package/dist/daemon/daemon-client.mjs.map +0 -1
- package/dist/daemon/daemon-entry.cjs +0 -278
- package/dist/daemon/daemon-entry.cjs.map +0 -1
- package/dist/daemon/daemon-entry.d.cts +0 -2
- package/dist/daemon/daemon-entry.d.cts.map +0 -1
- package/dist/daemon/daemon-entry.d.mts +0 -2
- package/dist/daemon/daemon-entry.d.mts.map +0 -1
- package/dist/daemon/daemon-entry.mjs.map +0 -1
- package/dist/daemon/daemon-spawn.cjs +0 -138
- package/dist/daemon/daemon-spawn.cjs.map +0 -1
- package/dist/daemon/daemon-spawn.d.cts +0 -28
- package/dist/daemon/daemon-spawn.d.cts.map +0 -1
- package/dist/daemon/daemon-spawn.d.mts.map +0 -1
- package/dist/daemon/daemon-spawn.mjs.map +0 -1
- package/dist/daemon/data-dir.cjs +0 -23
- package/dist/daemon/data-dir.cjs.map +0 -1
- package/dist/daemon/data-dir.d.cts.map +0 -1
- package/dist/daemon/data-dir.d.mts +0 -14
- package/dist/daemon/data-dir.d.mts.map +0 -1
- package/dist/daemon/data-dir.mjs.map +0 -1
- package/dist/daemon/paths.cjs +0 -20
- package/dist/daemon/paths.cjs.map +0 -1
- package/dist/daemon/paths.d.cts +0 -9
- package/dist/daemon/paths.d.cts.map +0 -1
- package/dist/daemon/paths.d.mts.map +0 -1
- package/dist/daemon/paths.mjs.map +0 -1
- package/dist/daemon/prompts.cjs +0 -55
- package/dist/daemon/prompts.cjs.map +0 -1
- package/dist/daemon/prompts.d.cts.map +0 -1
- package/dist/daemon/prompts.d.mts +0 -31
- package/dist/daemon/prompts.d.mts.map +0 -1
- package/dist/daemon/prompts.mjs.map +0 -1
- package/dist/daemon/rpc-socket-server.cjs +0 -284
- package/dist/daemon/rpc-socket-server.cjs.map +0 -1
- package/dist/daemon/rpc-socket-server.d.cts.map +0 -1
- package/dist/daemon/rpc-socket-server.d.mts +0 -44
- package/dist/daemon/rpc-socket-server.d.mts.map +0 -1
- package/dist/daemon/rpc-socket-server.mjs.map +0 -1
- package/dist/daemon/secrets.cjs +0 -137
- package/dist/daemon/secrets.cjs.map +0 -1
- package/dist/daemon/secrets.d.cts.map +0 -1
- package/dist/daemon/secrets.d.mts +0 -72
- package/dist/daemon/secrets.d.mts.map +0 -1
- package/dist/daemon/secrets.mjs.map +0 -1
- package/dist/daemon/send-transaction.cjs +0 -147
- package/dist/daemon/send-transaction.cjs.map +0 -1
- package/dist/daemon/send-transaction.d.cts.map +0 -1
- package/dist/daemon/send-transaction.d.mts +0 -102
- package/dist/daemon/send-transaction.d.mts.map +0 -1
- package/dist/daemon/send-transaction.mjs.map +0 -1
- package/dist/daemon/socket-line.cjs +0 -93
- package/dist/daemon/socket-line.cjs.map +0 -1
- package/dist/daemon/socket-line.d.cts.map +0 -1
- package/dist/daemon/socket-line.d.mts +0 -21
- package/dist/daemon/socket-line.d.mts.map +0 -1
- package/dist/daemon/socket-line.mjs.map +0 -1
- package/dist/daemon/stop-daemon.cjs +0 -117
- package/dist/daemon/stop-daemon.cjs.map +0 -1
- package/dist/daemon/stop-daemon.d.cts.map +0 -1
- package/dist/daemon/stop-daemon.d.mts +0 -28
- package/dist/daemon/stop-daemon.d.mts.map +0 -1
- package/dist/daemon/stop-daemon.mjs.map +0 -1
- package/dist/daemon/types.cjs +0 -20
- package/dist/daemon/types.cjs.map +0 -1
- package/dist/daemon/types.d.cts.map +0 -1
- package/dist/daemon/types.d.mts +0 -94
- package/dist/daemon/types.d.mts.map +0 -1
- package/dist/daemon/types.mjs.map +0 -1
- package/dist/daemon/utils.cjs +0 -172
- package/dist/daemon/utils.cjs.map +0 -1
- package/dist/daemon/utils.d.cts.map +0 -1
- package/dist/daemon/utils.d.mts +0 -87
- package/dist/daemon/utils.d.mts.map +0 -1
- package/dist/daemon/utils.mjs.map +0 -1
- package/dist/daemon/wallet-factory.cjs +0 -341
- package/dist/daemon/wallet-factory.cjs.map +0 -1
- package/dist/daemon/wallet-factory.d.cts.map +0 -1
- package/dist/daemon/wallet-factory.d.mts +0 -64
- package/dist/daemon/wallet-factory.d.mts.map +0 -1
- package/dist/daemon/wallet-factory.mjs.map +0 -1
- package/dist/persistence/KeyValueStore.cjs +0 -79
- package/dist/persistence/KeyValueStore.cjs.map +0 -1
- package/dist/persistence/KeyValueStore.d.cts.map +0 -1
- package/dist/persistence/KeyValueStore.d.mts +0 -18
- package/dist/persistence/KeyValueStore.d.mts.map +0 -1
- package/dist/persistence/KeyValueStore.mjs +0 -79
- package/dist/persistence/KeyValueStore.mjs.map +0 -1
- package/dist/persistence/persistence.cjs +0 -204
- package/dist/persistence/persistence.cjs.map +0 -1
- package/dist/persistence/persistence.d.cts.map +0 -1
- package/dist/persistence/persistence.d.mts +0 -45
- package/dist/persistence/persistence.d.mts.map +0 -1
- package/dist/persistence/persistence.mjs.map +0 -1
- package/dist/test/run-command.cjs +0 -73
- package/dist/test/run-command.cjs.map +0 -1
- package/dist/test/run-command.d.cts.map +0 -1
- package/dist/test/run-command.d.mts +0 -27
- package/dist/test/run-command.d.mts.map +0 -1
- package/dist/test/run-command.mjs.map +0 -1
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readLine = exports.writeLine = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Write a newline-delimited line to a socket.
|
|
6
|
-
*
|
|
7
|
-
* @param socket - The socket to write to.
|
|
8
|
-
* @param line - The line to write (without trailing newline).
|
|
9
|
-
*/
|
|
10
|
-
async function writeLine(socket, line) {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
// A socket 'error' can fire while the write is in flight without ever
|
|
13
|
-
// reaching the write callback; without this listener Node would treat it
|
|
14
|
-
// as an unhandled 'error' event and crash the process.
|
|
15
|
-
const onError = (error) => {
|
|
16
|
-
socket.removeListener('error', onError);
|
|
17
|
-
reject(error);
|
|
18
|
-
};
|
|
19
|
-
socket.once('error', onError);
|
|
20
|
-
socket.write(`${line}\n`, (error) => {
|
|
21
|
-
if (error) {
|
|
22
|
-
// A failed write (e.g. EPIPE) is delivered BOTH here AND as a later
|
|
23
|
-
// 'error' event. Leave `onError` attached to handle that event —
|
|
24
|
-
// detaching here would let Node treat it as unhandled and crash the
|
|
25
|
-
// process. This reject settles the promise; `onError` detaches itself
|
|
26
|
-
// when/if the event arrives.
|
|
27
|
-
reject(error);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
socket.removeListener('error', onError);
|
|
31
|
-
resolve();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
exports.writeLine = writeLine;
|
|
36
|
-
/**
|
|
37
|
-
* Read a single newline-delimited line from a socket.
|
|
38
|
-
*
|
|
39
|
-
* @param socket - The socket to read from.
|
|
40
|
-
* @param timeoutMs - Optional timeout in milliseconds. Rejects with a timeout
|
|
41
|
-
* error if no complete line is received within the limit.
|
|
42
|
-
* @returns The line read (without trailing newline).
|
|
43
|
-
*/
|
|
44
|
-
async function readLine(socket, timeoutMs) {
|
|
45
|
-
return new Promise((resolve, reject) => {
|
|
46
|
-
let buffer = '';
|
|
47
|
-
let timer;
|
|
48
|
-
if (timeoutMs !== undefined) {
|
|
49
|
-
timer = setTimeout(() => {
|
|
50
|
-
cleanup();
|
|
51
|
-
reject(new Error('Socket read timed out'));
|
|
52
|
-
}, timeoutMs);
|
|
53
|
-
}
|
|
54
|
-
const onData = (data) => {
|
|
55
|
-
buffer += data.toString();
|
|
56
|
-
const idx = buffer.indexOf('\n');
|
|
57
|
-
if (idx !== -1) {
|
|
58
|
-
cleanup();
|
|
59
|
-
resolve(buffer.slice(0, idx));
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const onError = (error) => {
|
|
63
|
-
cleanup();
|
|
64
|
-
reject(error);
|
|
65
|
-
};
|
|
66
|
-
const onEnd = () => {
|
|
67
|
-
cleanup();
|
|
68
|
-
reject(new Error('Socket closed before response received'));
|
|
69
|
-
};
|
|
70
|
-
const onClose = () => {
|
|
71
|
-
cleanup();
|
|
72
|
-
reject(new Error('Socket closed before response received'));
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Remove listeners registered by this call and clear the timeout.
|
|
76
|
-
*/
|
|
77
|
-
function cleanup() {
|
|
78
|
-
if (timer !== undefined) {
|
|
79
|
-
clearTimeout(timer);
|
|
80
|
-
}
|
|
81
|
-
socket.removeListener('data', onData);
|
|
82
|
-
socket.removeListener('error', onError);
|
|
83
|
-
socket.removeListener('end', onEnd);
|
|
84
|
-
socket.removeListener('close', onClose);
|
|
85
|
-
}
|
|
86
|
-
socket.on('data', onData);
|
|
87
|
-
socket.once('error', onError);
|
|
88
|
-
socket.once('end', onEnd);
|
|
89
|
-
socket.once('close', onClose);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
exports.readLine = readLine;
|
|
93
|
-
//# sourceMappingURL=socket-line.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"socket-line.cjs","sourceRoot":"","sources":["../../src/daemon/socket-line.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,IAAY;IAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,sEAAsE;QACtE,yEAAyE;QACzE,uDAAuD;QACvD,MAAM,OAAO,GAAG,CAAC,KAAY,EAAQ,EAAE;YACrC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAE9B,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YAClC,IAAI,KAAK,EAAE,CAAC;gBACV,oEAAoE;gBACpE,iEAAiE;gBACjE,oEAAoE;gBACpE,sEAAsE;gBACtE,6BAA6B;gBAC7B,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;YACT,CAAC;YACD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxC,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAzBD,8BAyBC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,QAAQ,CAC5B,MAAc,EACd,SAAkB;IAElB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO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C,CAAC;YACtC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACpC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAzDD,4BAyDC","sourcesContent":["import type { Socket } from 'node:net';\n\n/**\n * Write a newline-delimited line to a socket.\n *\n * @param socket - The socket to write to.\n * @param line - The line to write (without trailing newline).\n */\nexport async function writeLine(socket: Socket, line: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // A socket 'error' can fire while the write is in flight without ever\n // reaching the write callback; without this listener Node would treat it\n // as an unhandled 'error' event and crash the process.\n const onError = (error: Error): void => {\n socket.removeListener('error', onError);\n reject(error);\n };\n socket.once('error', onError);\n\n socket.write(`${line}\\n`, (error) => {\n if (error) {\n // A failed write (e.g. EPIPE) is delivered BOTH here AND as a later\n // 'error' event. Leave `onError` attached to handle that event —\n // detaching here would let Node treat it as unhandled and crash the\n // process. This reject settles the promise; `onError` detaches itself\n // when/if the event arrives.\n reject(error);\n return;\n }\n socket.removeListener('error', onError);\n resolve();\n });\n });\n}\n\n/**\n * Read a single newline-delimited line from a socket.\n *\n * @param socket - The socket to read from.\n * @param timeoutMs - Optional timeout in milliseconds. Rejects with a timeout\n * error if no complete line is received within the limit.\n * @returns The line read (without trailing newline).\n */\nexport async function readLine(\n socket: Socket,\n timeoutMs?: number,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n let buffer = '';\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n if (timeoutMs !== undefined) {\n timer = setTimeout(() => {\n cleanup();\n reject(new Error('Socket read timed out'));\n }, timeoutMs);\n }\n\n const onData = (data: Buffer): void => {\n buffer += data.toString();\n const idx = buffer.indexOf('\\n');\n if (idx !== -1) {\n cleanup();\n resolve(buffer.slice(0, idx));\n }\n };\n\n const onError = (error: Error): void => {\n cleanup();\n reject(error);\n };\n\n const onEnd = (): void => {\n cleanup();\n reject(new Error('Socket closed before response received'));\n };\n\n const onClose = (): void => {\n cleanup();\n reject(new Error('Socket closed before response received'));\n };\n\n /**\n * Remove listeners registered by this call and clear the timeout.\n */\n function cleanup(): void {\n if (timer !== undefined) {\n clearTimeout(timer);\n }\n socket.removeListener('data', onData);\n socket.removeListener('error', onError);\n socket.removeListener('end', onEnd);\n socket.removeListener('close', onClose);\n }\n\n socket.on('data', onData);\n socket.once('error', onError);\n socket.once('end', onEnd);\n socket.once('close', onClose);\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"socket-line.d.cts","sourceRoot":"","sources":["../../src/daemon/socket-line.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB;AAEvC;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB3E;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAsDjB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node/net" />
|
|
3
|
-
/// <reference types="npm-which/node_modules/@types/node/net" />
|
|
4
|
-
import type { Socket } from "node:net";
|
|
5
|
-
/**
|
|
6
|
-
* Write a newline-delimited line to a socket.
|
|
7
|
-
*
|
|
8
|
-
* @param socket - The socket to write to.
|
|
9
|
-
* @param line - The line to write (without trailing newline).
|
|
10
|
-
*/
|
|
11
|
-
export declare function writeLine(socket: Socket, line: string): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Read a single newline-delimited line from a socket.
|
|
14
|
-
*
|
|
15
|
-
* @param socket - The socket to read from.
|
|
16
|
-
* @param timeoutMs - Optional timeout in milliseconds. Rejects with a timeout
|
|
17
|
-
* error if no complete line is received within the limit.
|
|
18
|
-
* @returns The line read (without trailing newline).
|
|
19
|
-
*/
|
|
20
|
-
export declare function readLine(socket: Socket, timeoutMs?: number): Promise<string>;
|
|
21
|
-
//# sourceMappingURL=socket-line.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"socket-line.d.mts","sourceRoot":"","sources":["../../src/daemon/socket-line.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB;AAEvC;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB3E;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAsDjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"socket-line.mjs","sourceRoot":"","sources":["../../src/daemon/socket-line.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,IAAY;IAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,sEAAsE;QACtE,yEAAyE;QACzE,uDAAuD;QACvD,MAAM,OAAO,GAAG,CAAC,KAAY,EAAQ,EAAE;YACrC,MAAM,CAAC,cA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CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,KAAY,EAAQ,EAAE;YACrC,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC;QAEF,MAAM,KAAK,GAAG,GAAS,EAAE;YACvB,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC;QAEF;;WAEG;QACH,SAAS,OAAO;YACd,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YACD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACtC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACpC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Socket } from 'node:net';\n\n/**\n * Write a newline-delimited line to a socket.\n *\n * @param socket - The socket to write to.\n * @param line - The line to write (without trailing newline).\n */\nexport async function writeLine(socket: Socket, line: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // A socket 'error' can fire while the write is in flight without ever\n // reaching the write callback; without this listener Node would treat it\n // as an unhandled 'error' event and crash the process.\n const onError = (error: Error): void => {\n socket.removeListener('error', onError);\n reject(error);\n };\n socket.once('error', onError);\n\n socket.write(`${line}\\n`, (error) => {\n if (error) {\n // A failed write (e.g. EPIPE) is delivered BOTH here AND as a later\n // 'error' event. Leave `onError` attached to handle that event —\n // detaching here would let Node treat it as unhandled and crash the\n // process. This reject settles the promise; `onError` detaches itself\n // when/if the event arrives.\n reject(error);\n return;\n }\n socket.removeListener('error', onError);\n resolve();\n });\n });\n}\n\n/**\n * Read a single newline-delimited line from a socket.\n *\n * @param socket - The socket to read from.\n * @param timeoutMs - Optional timeout in milliseconds. Rejects with a timeout\n * error if no complete line is received within the limit.\n * @returns The line read (without trailing newline).\n */\nexport async function readLine(\n socket: Socket,\n timeoutMs?: number,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n let buffer = '';\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n if (timeoutMs !== undefined) {\n timer = setTimeout(() => {\n cleanup();\n reject(new Error('Socket read timed out'));\n }, timeoutMs);\n }\n\n const onData = (data: Buffer): void => {\n buffer += data.toString();\n const idx = buffer.indexOf('\\n');\n if (idx !== -1) {\n cleanup();\n resolve(buffer.slice(0, idx));\n }\n };\n\n const onError = (error: Error): void => {\n cleanup();\n reject(error);\n };\n\n const onEnd = (): void => {\n cleanup();\n reject(new Error('Socket closed before response received'));\n };\n\n const onClose = (): void => {\n cleanup();\n reject(new Error('Socket closed before response received'));\n };\n\n /**\n * Remove listeners registered by this call and clear the timeout.\n */\n function cleanup(): void {\n if (timer !== undefined) {\n clearTimeout(timer);\n }\n socket.removeListener('data', onData);\n socket.removeListener('error', onError);\n socket.removeListener('end', onEnd);\n socket.removeListener('close', onClose);\n }\n\n socket.on('data', onData);\n socket.once('error', onError);\n socket.once('end', onEnd);\n socket.once('close', onClose);\n });\n}\n"]}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stopDaemon = void 0;
|
|
4
|
-
const promises_1 = require("node:fs/promises");
|
|
5
|
-
const daemon_client_js_1 = require("./daemon-client.cjs");
|
|
6
|
-
const utils_js_1 = require("./utils.cjs");
|
|
7
|
-
/**
|
|
8
|
-
* Stop the daemon, preferring a graceful shutdown.
|
|
9
|
-
*
|
|
10
|
-
* Resolution order when a live daemon is present:
|
|
11
|
-
* 1. If the socket is responsive, request a graceful `shutdown` over it.
|
|
12
|
-
* 2. If the recorded PID is still alive, escalate to SIGTERM.
|
|
13
|
-
* 3. ...then SIGKILL.
|
|
14
|
-
*
|
|
15
|
-
* Signals (steps 2-3) are only ever sent against a PID that is observed alive.
|
|
16
|
-
* The socket-absent + alive-PID branch trades a small risk of signalling a
|
|
17
|
-
* recycled PID for the larger risk of leaving an orphan daemon holding the
|
|
18
|
-
* SQLite database — which `daemon purge` would otherwise wipe out from under
|
|
19
|
-
* it.
|
|
20
|
-
*
|
|
21
|
-
* When the socket is NOT responsive AND the recorded PID is dead (or there is
|
|
22
|
-
* no PID file), there is no live daemon: a lingering socket or PID file is
|
|
23
|
-
* stale leftovers from a daemon that already exited — typically one that
|
|
24
|
-
* crashed without running its own cleanup. Those files are removed and the
|
|
25
|
-
* stop is reported as successful, rather than failing on a daemon that is
|
|
26
|
-
* already gone.
|
|
27
|
-
*
|
|
28
|
-
* @param socketPath - The daemon socket path.
|
|
29
|
-
* @param pidPath - The daemon PID file path.
|
|
30
|
-
* @param log - Optional logging function for status messages.
|
|
31
|
-
* @returns True if the daemon was stopped (or was not running).
|
|
32
|
-
*/
|
|
33
|
-
async function stopDaemon(socketPath, pidPath, log) {
|
|
34
|
-
const pid = await (0, utils_js_1.readPidFile)(pidPath);
|
|
35
|
-
const ping = await (0, daemon_client_js_1.pingDaemon)(socketPath);
|
|
36
|
-
const socketObserved = ping.status === 'responsive' || ping.status === 'unreachable';
|
|
37
|
-
const processAlive = pid !== undefined && (0, utils_js_1.isProcessAlive)(pid);
|
|
38
|
-
// Only `absent` and `refused` prove no live daemon; `permission`/`timeout`/
|
|
39
|
-
// `protocol` may be a wedged or foreign daemon, so those fall through.
|
|
40
|
-
const socketProvenGone = ping.status === 'absent' ||
|
|
41
|
-
(ping.status === 'unreachable' && ping.reason === 'refused');
|
|
42
|
-
if (socketProvenGone && !processAlive) {
|
|
43
|
-
await cleanupFile(pidPath, 'PID file', log);
|
|
44
|
-
await cleanupFile(socketPath, 'socket file', log);
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
log?.('Stopping daemon...');
|
|
48
|
-
let stopped = false;
|
|
49
|
-
// Strategy 1: Graceful socket-based shutdown.
|
|
50
|
-
if (ping.status === 'responsive') {
|
|
51
|
-
try {
|
|
52
|
-
await (0, daemon_client_js_1.sendCommand)({ socketPath, method: 'shutdown' });
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
log?.(`Graceful shutdown request failed: ${String(error)}`);
|
|
56
|
-
}
|
|
57
|
-
// A quiet socket does not prove the process exited; require the recorded
|
|
58
|
-
// pid to be gone too, so a daemon that outlived its socket falls through to
|
|
59
|
-
// SIGTERM/SIGKILL rather than being orphaned.
|
|
60
|
-
stopped = await (0, utils_js_1.waitFor)(async () => (await (0, daemon_client_js_1.pingDaemon)(socketPath)).status !== 'responsive' &&
|
|
61
|
-
(pid === undefined || !(0, utils_js_1.isProcessAlive)(pid)), 5000);
|
|
62
|
-
}
|
|
63
|
-
// Strategy 2: SIGTERM. Signal when either the socket was observed or the
|
|
64
|
-
// recorded PID is alive; the absent+alive case typically means someone
|
|
65
|
-
// removed the socket from under a live daemon.
|
|
66
|
-
if (!stopped && processAlive && pid !== undefined) {
|
|
67
|
-
if (!socketObserved) {
|
|
68
|
-
log?.(`Socket at ${socketPath} is absent but recorded pid ${pid} is alive; signalling anyway.`);
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
if ((0, utils_js_1.sendSignal)(pid, 'SIGTERM')) {
|
|
72
|
-
stopped = await (0, utils_js_1.waitFor)(() => !(0, utils_js_1.isProcessAlive)(pid), 5000);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
stopped = true; // Process already gone (ESRCH).
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
log?.(`SIGTERM failed: ${String(error)}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Strategy 3: SIGKILL.
|
|
83
|
-
if (!stopped && processAlive && pid !== undefined) {
|
|
84
|
-
try {
|
|
85
|
-
if ((0, utils_js_1.sendSignal)(pid, 'SIGKILL')) {
|
|
86
|
-
stopped = await (0, utils_js_1.waitFor)(() => !(0, utils_js_1.isProcessAlive)(pid), 2000);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
stopped = true; // Process already gone (ESRCH).
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
log?.(`SIGKILL failed: ${String(error)}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (stopped) {
|
|
97
|
-
await cleanupFile(pidPath, 'PID file', log);
|
|
98
|
-
await cleanupFile(socketPath, 'socket file', log);
|
|
99
|
-
log?.('Daemon stopped.');
|
|
100
|
-
}
|
|
101
|
-
return stopped;
|
|
102
|
-
}
|
|
103
|
-
exports.stopDaemon = stopDaemon;
|
|
104
|
-
/**
|
|
105
|
-
* Remove a file best-effort, logging any failure rather than letting it
|
|
106
|
-
* propagate. ENOENT is silently ignored via `force: true`.
|
|
107
|
-
*
|
|
108
|
-
* @param path - The file path to remove.
|
|
109
|
-
* @param label - Human-readable label for log messages.
|
|
110
|
-
* @param log - Optional log sink.
|
|
111
|
-
*/
|
|
112
|
-
async function cleanupFile(path, label, log) {
|
|
113
|
-
await (0, promises_1.rm)(path, { force: true }).catch((error) => {
|
|
114
|
-
log?.(`Failed to remove ${label}: ${String(error)}`);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=stop-daemon.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop-daemon.cjs","sourceRoot":"","sources":["../../src/daemon/stop-daemon.ts"],"names":[],"mappings":";;;AAAA,+CAAsC;AAEtC,0DAA6D;AAC7D,0CAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,OAAe,EACf,GAA+B;IAE/B,MAAM,GAAG,GAAG,MAAM,IAAA,sBAAW,EAAC,OAAO,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAU,EAAC,UAAU,CAAC,CAAC;IAC1C,MAAM,cAAc,GAClB,IAAI,CAAC,MAAM,KAAK,YAAY,IAAI,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC;IAChE,MAAM,YAAY,GAAG,GAAG,KAAK,SAAS,IAAI,IAAA,yBAAc,EAAC,GAAG,CAAC,CAAC;IAE9D,4EAA4E;IAC5E,uEAAuE;IACvE,MAAM,gBAAgB,GACpB,IAAI,CAAC,MAAM,KAAK,QAAQ;QACxB,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;IAE/D,IAAI,gBAAgB,IAAI,CAAC,YAAY,EAAE,CAAC;QACtC,MAAM,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QAC5C,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;IAE5B,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,8CAA8C;IAC9C,IAA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CAAC;IAED,uBAAuB;IACvB,IAAI,CAAC,OAAO,IAAI,YAAY,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QAClD,IAAI,CAAC;YACH,IAAI,IAAA,qBAAU,EAAC,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC;gBAC/B,OAAO,GAAG,MAAM,IAAA,kBAAO,EAAC,GAAG,EAAE,CAAC,CAAC,IAAA,yBAAc,EAAC,GAAG,CAAC,EAAE,IAAK,CAAC,CAAC;YAC7D,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,IAAI,CAAC,CAAC,gCAAgC;YAClD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,EAAE,CAAC,mBAAmB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QAC5C,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QAClD,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AArFD,gCAqFC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,WAAW,CACxB,IAAY,EACZ,KAAa,EACb,GAA4C;IAE5C,MAAM,IAAA,aAAE,EAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACvD,GAAG,EAAE,CAAC,oBAAoB,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { rm } from 'node:fs/promises';\n\nimport { pingDaemon, sendCommand } from './daemon-client.js';\nimport { isProcessAlive, readPidFile, sendSignal, waitFor } from './utils.js';\n\n/**\n * Stop the daemon, preferring a graceful shutdown.\n *\n * Resolution order when a live daemon is present:\n * 1. If the socket is responsive, request a graceful `shutdown` over it.\n * 2. If the recorded PID is still alive, escalate to SIGTERM.\n * 3. ...then SIGKILL.\n *\n * Signals (steps 2-3) are only ever sent against a PID that is observed alive.\n * The socket-absent + alive-PID branch trades a small risk of signalling a\n * recycled PID for the larger risk of leaving an orphan daemon holding the\n * SQLite database — which `daemon purge` would otherwise wipe out from under\n * it.\n *\n * When the socket is NOT responsive AND the recorded PID is dead (or there is\n * no PID file), there is no live daemon: a lingering socket or PID file is\n * stale leftovers from a daemon that already exited — typically one that\n * crashed without running its own cleanup. Those files are removed and the\n * stop is reported as successful, rather than failing on a daemon that is\n * already gone.\n *\n * @param socketPath - The daemon socket path.\n * @param pidPath - The daemon PID file path.\n * @param log - Optional logging function for status messages.\n * @returns True if the daemon was stopped (or was not running).\n */\nexport async function stopDaemon(\n socketPath: string,\n pidPath: string,\n log?: (message: string) => void,\n): Promise<boolean> {\n const pid = await readPidFile(pidPath);\n const ping = await pingDaemon(socketPath);\n const socketObserved =\n ping.status === 'responsive' || ping.status === 'unreachable';\n const processAlive = pid !== undefined && isProcessAlive(pid);\n\n // Only `absent` and `refused` prove no live daemon; `permission`/`timeout`/\n // `protocol` may be a wedged or foreign daemon, so those fall through.\n const socketProvenGone =\n ping.status === 'absent' ||\n (ping.status === 'unreachable' && ping.reason === 'refused');\n\n if (socketProvenGone && !processAlive) {\n await cleanupFile(pidPath, 'PID file', log);\n await cleanupFile(socketPath, 'socket file', log);\n return true;\n }\n\n log?.('Stopping daemon...');\n\n let stopped = false;\n\n // Strategy 1: Graceful socket-based shutdown.\n if (ping.status === 'responsive') {\n try {\n await sendCommand({ socketPath, method: 'shutdown' });\n } catch (error) {\n log?.(`Graceful shutdown request failed: ${String(error)}`);\n }\n // A quiet socket does not prove the process exited; require the recorded\n // pid to be gone too, so a daemon that outlived its socket falls through to\n // SIGTERM/SIGKILL rather than being orphaned.\n stopped = await waitFor(\n async () =>\n (await pingDaemon(socketPath)).status !== 'responsive' &&\n (pid === undefined || !isProcessAlive(pid)),\n 5_000,\n );\n }\n\n // Strategy 2: SIGTERM. Signal when either the socket was observed or the\n // recorded PID is alive; the absent+alive case typically means someone\n // removed the socket from under a live daemon.\n if (!stopped && processAlive && pid !== undefined) {\n if (!socketObserved) {\n log?.(\n `Socket at ${socketPath} is absent but recorded pid ${pid} is alive; signalling anyway.`,\n );\n }\n try {\n if (sendSignal(pid, 'SIGTERM')) {\n stopped = await waitFor(() => !isProcessAlive(pid), 5_000);\n } else {\n stopped = true; // Process already gone (ESRCH).\n }\n } catch (error) {\n log?.(`SIGTERM failed: ${String(error)}`);\n }\n }\n\n // Strategy 3: SIGKILL.\n if (!stopped && processAlive && pid !== undefined) {\n try {\n if (sendSignal(pid, 'SIGKILL')) {\n stopped = await waitFor(() => !isProcessAlive(pid), 2_000);\n } else {\n stopped = true; // Process already gone (ESRCH).\n }\n } catch (error) {\n log?.(`SIGKILL failed: ${String(error)}`);\n }\n }\n\n if (stopped) {\n await cleanupFile(pidPath, 'PID file', log);\n await cleanupFile(socketPath, 'socket file', log);\n log?.('Daemon stopped.');\n }\n\n return stopped;\n}\n\n/**\n * Remove a file best-effort, logging any failure rather than letting it\n * propagate. ENOENT is silently ignored via `force: true`.\n *\n * @param path - The file path to remove.\n * @param label - Human-readable label for log messages.\n * @param log - Optional log sink.\n */\nasync function cleanupFile(\n path: string,\n label: string,\n log: ((message: string) => void) | undefined,\n): Promise<void> {\n await rm(path, { force: true }).catch((error: unknown) => {\n log?.(`Failed to remove ${label}: ${String(error)}`);\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop-daemon.d.cts","sourceRoot":"","sources":["../../src/daemon/stop-daemon.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAC9B,OAAO,CAAC,OAAO,CAAC,CAiFlB"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stop the daemon, preferring a graceful shutdown.
|
|
3
|
-
*
|
|
4
|
-
* Resolution order when a live daemon is present:
|
|
5
|
-
* 1. If the socket is responsive, request a graceful `shutdown` over it.
|
|
6
|
-
* 2. If the recorded PID is still alive, escalate to SIGTERM.
|
|
7
|
-
* 3. ...then SIGKILL.
|
|
8
|
-
*
|
|
9
|
-
* Signals (steps 2-3) are only ever sent against a PID that is observed alive.
|
|
10
|
-
* The socket-absent + alive-PID branch trades a small risk of signalling a
|
|
11
|
-
* recycled PID for the larger risk of leaving an orphan daemon holding the
|
|
12
|
-
* SQLite database — which `daemon purge` would otherwise wipe out from under
|
|
13
|
-
* it.
|
|
14
|
-
*
|
|
15
|
-
* When the socket is NOT responsive AND the recorded PID is dead (or there is
|
|
16
|
-
* no PID file), there is no live daemon: a lingering socket or PID file is
|
|
17
|
-
* stale leftovers from a daemon that already exited — typically one that
|
|
18
|
-
* crashed without running its own cleanup. Those files are removed and the
|
|
19
|
-
* stop is reported as successful, rather than failing on a daemon that is
|
|
20
|
-
* already gone.
|
|
21
|
-
*
|
|
22
|
-
* @param socketPath - The daemon socket path.
|
|
23
|
-
* @param pidPath - The daemon PID file path.
|
|
24
|
-
* @param log - Optional logging function for status messages.
|
|
25
|
-
* @returns True if the daemon was stopped (or was not running).
|
|
26
|
-
*/
|
|
27
|
-
export declare function stopDaemon(socketPath: string, pidPath: string, log?: (message: string) => void): Promise<boolean>;
|
|
28
|
-
//# sourceMappingURL=stop-daemon.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop-daemon.d.mts","sourceRoot":"","sources":["../../src/daemon/stop-daemon.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;GA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isProcessAlive, readPidFile, sendSignal, waitFor } from './utils.js';\n\n/**\n * Stop the daemon, preferring a graceful shutdown.\n *\n * Resolution order when a live daemon is present:\n * 1. If the socket is responsive, request a graceful `shutdown` over it.\n * 2. If the recorded PID is still alive, escalate to SIGTERM.\n * 3. ...then SIGKILL.\n *\n * Signals (steps 2-3) are only ever sent against a PID that is observed alive.\n * The socket-absent + alive-PID branch trades a small risk of signalling a\n * recycled PID for the larger risk of leaving an orphan daemon holding the\n * SQLite database — which `daemon purge` would otherwise wipe out from under\n * it.\n *\n * When the socket is NOT responsive AND the recorded PID is dead (or there is\n * no PID file), there is no live daemon: a lingering socket or PID file is\n * stale leftovers from a daemon that already exited — typically one that\n * crashed without running its own cleanup. Those files are removed and the\n * stop is reported as successful, rather than failing on a daemon that is\n * already gone.\n *\n * @param socketPath - The daemon socket path.\n * @param pidPath - The daemon PID file path.\n * @param log - Optional logging function for status messages.\n * @returns True if the daemon was stopped (or was not running).\n */\nexport async function stopDaemon(\n socketPath: string,\n pidPath: string,\n log?: (message: string) => void,\n): Promise<boolean> {\n const pid = await readPidFile(pidPath);\n const ping = await pingDaemon(socketPath);\n const socketObserved =\n ping.status === 'responsive' || ping.status === 'unreachable';\n const processAlive = pid !== undefined && isProcessAlive(pid);\n\n // Only `absent` and `refused` prove no live daemon; `permission`/`timeout`/\n // `protocol` may be a wedged or foreign daemon, so those fall through.\n const socketProvenGone =\n ping.status === 'absent' ||\n (ping.status === 'unreachable' && ping.reason === 'refused');\n\n if (socketProvenGone && !processAlive) {\n await cleanupFile(pidPath, 'PID file', log);\n await cleanupFile(socketPath, 'socket file', log);\n return true;\n }\n\n log?.('Stopping daemon...');\n\n let stopped = false;\n\n // Strategy 1: Graceful socket-based shutdown.\n if (ping.status === 'responsive') {\n try {\n await sendCommand({ socketPath, method: 'shutdown' });\n } catch (error) {\n log?.(`Graceful shutdown request failed: ${String(error)}`);\n }\n // A quiet socket does not prove the process exited; require the recorded\n // pid to be gone too, so a daemon that outlived its socket falls through to\n // SIGTERM/SIGKILL rather than being orphaned.\n stopped = await waitFor(\n async () =>\n (await pingDaemon(socketPath)).status !== 'responsive' &&\n (pid === undefined || !isProcessAlive(pid)),\n 5_000,\n );\n }\n\n // Strategy 2: SIGTERM. Signal when either the socket was observed or the\n // recorded PID is alive; the absent+alive case typically means someone\n // removed the socket from under a live daemon.\n if (!stopped && processAlive && pid !== undefined) {\n if (!socketObserved) {\n log?.(\n `Socket at ${socketPath} is absent but recorded pid ${pid} is alive; signalling anyway.`,\n );\n }\n try {\n if (sendSignal(pid, 'SIGTERM')) {\n stopped = await waitFor(() => !isProcessAlive(pid), 5_000);\n } else {\n stopped = true; // Process already gone (ESRCH).\n }\n } catch (error) {\n log?.(`SIGTERM failed: ${String(error)}`);\n }\n }\n\n // Strategy 3: SIGKILL.\n if (!stopped && processAlive && pid !== undefined) {\n try {\n if (sendSignal(pid, 'SIGKILL')) {\n stopped = await waitFor(() => !isProcessAlive(pid), 2_000);\n } else {\n stopped = true; // Process already gone (ESRCH).\n }\n } catch (error) {\n log?.(`SIGKILL failed: ${String(error)}`);\n }\n }\n\n if (stopped) {\n await cleanupFile(pidPath, 'PID file', log);\n await cleanupFile(socketPath, 'socket file', log);\n log?.('Daemon stopped.');\n }\n\n return stopped;\n}\n\n/**\n * Remove a file best-effort, logging any failure rather than letting it\n * propagate. ENOENT is silently ignored via `force: true`.\n *\n * @param path - The file path to remove.\n * @param label - Human-readable label for log messages.\n * @param log - Optional log sink.\n */\nasync function cleanupFile(\n path: string,\n label: string,\n log: ((message: string) => void) | undefined,\n): Promise<void> {\n await rm(path, { force: true }).catch((error: unknown) => {\n log?.(`Failed to remove ${label}: ${String(error)}`);\n });\n}\n"]}
|
package/dist/daemon/types.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineHandler = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Bundle a params struct with the handler that runs once `params` is
|
|
6
|
-
* validated. The server invokes `run` only after `paramsStruct` accepts the
|
|
7
|
-
* value, so `run` can trust the type of its argument.
|
|
8
|
-
*
|
|
9
|
-
* The returned definition erases `TParams` to `unknown` so heterogeneous
|
|
10
|
-
* handlers can share an {@link RpcHandlerMap}.
|
|
11
|
-
*
|
|
12
|
-
* @param paramsStruct - Struct that validates `params` for this method.
|
|
13
|
-
* @param run - Handler invoked with the validated params.
|
|
14
|
-
* @returns An {@link RpcHandlerDefinition} suitable for an {@link RpcHandlerMap}.
|
|
15
|
-
*/
|
|
16
|
-
function defineHandler(paramsStruct, run) {
|
|
17
|
-
return { paramsStruct, run };
|
|
18
|
-
}
|
|
19
|
-
exports.defineHandler = defineHandler;
|
|
20
|
-
//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/daemon/types.ts"],"names":[],"mappings":";;;AAiDA;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAC3B,YAA6B,EAC7B,GAAiC;IAEjC,OAAO,EAAE,YAAY,EAAE,GAAG,EAGzB,CAAC;AACJ,CAAC;AARD,sCAQC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\n\nimport type { Password, Srp } from './secrets.js';\n\n/**\n * Sink for daemon diagnostic messages. A backgrounded daemon's stdio may be\n * discarded, so hosts supply a logger that writes somewhere durable.\n */\nexport type Logger = (message: string) => void;\n\n/**\n * A function that handles a JSON-RPC method call after its params have been\n * validated by the corresponding {@link RpcHandlerDefinition.paramsStruct}.\n */\nexport type RpcHandler<TParams, TResult> = (\n params: TParams,\n) => Promise<TResult>;\n\n/**\n * Definition for a single JSON-RPC method: the struct that validates\n * incoming `params` plus the handler that runs once `params` is known to\n * match.\n *\n * The server (see `rpc-socket-server.ts`) validates the raw `params` against\n * `paramsStruct` before invoking `run`, so each handler body can trust the\n * shape of its input without re-checking.\n */\nexport type RpcHandlerDefinition<TParams, TResult extends Json | void> = {\n paramsStruct: Struct<TParams>;\n run: RpcHandler<TParams, TResult>;\n};\n\n/**\n * A map of RPC method names to their handler definitions.\n *\n * `TParams` is erased to `unknown` here so definitions with different narrow\n * params types (e.g. `null` vs. a tuple) can coexist in the same map. Consumers\n * therefore see each `run` as accepting `unknown` and must validate `params`\n * against the paired `paramsStruct` before invoking it — which is exactly what\n * the server (see `rpc-socket-server.ts`) does. The concrete `TParams` is\n * captured inside {@link defineHandler}, where the struct and handler are bound\n * together.\n */\nexport type RpcHandlerMap = Record<\n string,\n RpcHandlerDefinition<unknown, Json | void>\n>;\n\n/**\n * Bundle a params struct with the handler that runs once `params` is\n * validated. The server invokes `run` only after `paramsStruct` accepts the\n * value, so `run` can trust the type of its argument.\n *\n * The returned definition erases `TParams` to `unknown` so heterogeneous\n * handlers can share an {@link RpcHandlerMap}.\n *\n * @param paramsStruct - Struct that validates `params` for this method.\n * @param run - Handler invoked with the validated params.\n * @returns An {@link RpcHandlerDefinition} suitable for an {@link RpcHandlerMap}.\n */\nexport function defineHandler<TParams, TResult extends Json | void>(\n paramsStruct: Struct<TParams>,\n run: RpcHandler<TParams, TResult>,\n): RpcHandlerDefinition<unknown, TResult> {\n return { paramsStruct, run } as unknown as RpcHandlerDefinition<\n unknown,\n TResult\n >;\n}\n\n/**\n * Typed wrapper around `wallet.messenger.call` used by the `call` RPC.\n *\n * The messenger is strongly typed by action name; the daemon exposes the full\n * messenger surface over the socket and dispatches by string, so we consolidate\n * the unsafe cast into a single, documented escape hatch instead of repeating\n * it at each call site.\n */\nexport type RpcDispatcher = (action: string, ...args: Json[]) => Promise<Json>;\n\n/**\n * Resolved paths for daemon state files.\n */\nexport type DaemonPaths = {\n socketPath: string;\n pidPath: string;\n logPath: string;\n dbPath: string;\n};\n\n/**\n * Status information returned by the daemon's `getStatus` RPC method.\n */\nexport type DaemonStatusInfo = {\n pid: number;\n uptime: number;\n};\n\n/**\n * Configuration passed to the daemon spawner.\n *\n * `password` is optional: when omitted, the daemon starts without unlocking\n * the keyring, and the caller is expected to use `mm wallet unlock` before\n * any keyring-bound operation. First-run startup still requires both\n * `password` and `srp`; without `password`, the daemon will exit during\n * startup with a clear error. `srp` is always required by the type and\n * forwarded to the daemon; it is only consumed on first run.\n */\nexport type DaemonSpawnConfig = {\n dataDir: string;\n infuraProjectId: string;\n password?: Password;\n srp: Srp;\n packageRoot: string;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/daemon/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,sBAAqB;AAElD;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,IAAI,CACzC,MAAM,EAAE,OAAO,KACZ,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,CAAC,OAAO,EAAE,OAAO,SAAS,IAAI,GAAG,IAAI,IAAI;IACvE,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,GAAG,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAChC,MAAM,EACN,oBAAoB,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC,CAC3C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,SAAS,IAAI,GAAG,IAAI,EAChE,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,EAC7B,GAAG,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAChC,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAKxC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
package/dist/daemon/types.d.mts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { Struct } from "@metamask/superstruct";
|
|
2
|
-
import type { Json } from "@metamask/utils";
|
|
3
|
-
import type { Password, Srp } from "./secrets.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* Sink for daemon diagnostic messages. A backgrounded daemon's stdio may be
|
|
6
|
-
* discarded, so hosts supply a logger that writes somewhere durable.
|
|
7
|
-
*/
|
|
8
|
-
export type Logger = (message: string) => void;
|
|
9
|
-
/**
|
|
10
|
-
* A function that handles a JSON-RPC method call after its params have been
|
|
11
|
-
* validated by the corresponding {@link RpcHandlerDefinition.paramsStruct}.
|
|
12
|
-
*/
|
|
13
|
-
export type RpcHandler<TParams, TResult> = (params: TParams) => Promise<TResult>;
|
|
14
|
-
/**
|
|
15
|
-
* Definition for a single JSON-RPC method: the struct that validates
|
|
16
|
-
* incoming `params` plus the handler that runs once `params` is known to
|
|
17
|
-
* match.
|
|
18
|
-
*
|
|
19
|
-
* The server (see `rpc-socket-server.ts`) validates the raw `params` against
|
|
20
|
-
* `paramsStruct` before invoking `run`, so each handler body can trust the
|
|
21
|
-
* shape of its input without re-checking.
|
|
22
|
-
*/
|
|
23
|
-
export type RpcHandlerDefinition<TParams, TResult extends Json | void> = {
|
|
24
|
-
paramsStruct: Struct<TParams>;
|
|
25
|
-
run: RpcHandler<TParams, TResult>;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* A map of RPC method names to their handler definitions.
|
|
29
|
-
*
|
|
30
|
-
* `TParams` is erased to `unknown` here so definitions with different narrow
|
|
31
|
-
* params types (e.g. `null` vs. a tuple) can coexist in the same map. Consumers
|
|
32
|
-
* therefore see each `run` as accepting `unknown` and must validate `params`
|
|
33
|
-
* against the paired `paramsStruct` before invoking it — which is exactly what
|
|
34
|
-
* the server (see `rpc-socket-server.ts`) does. The concrete `TParams` is
|
|
35
|
-
* captured inside {@link defineHandler}, where the struct and handler are bound
|
|
36
|
-
* together.
|
|
37
|
-
*/
|
|
38
|
-
export type RpcHandlerMap = Record<string, RpcHandlerDefinition<unknown, Json | void>>;
|
|
39
|
-
/**
|
|
40
|
-
* Bundle a params struct with the handler that runs once `params` is
|
|
41
|
-
* validated. The server invokes `run` only after `paramsStruct` accepts the
|
|
42
|
-
* value, so `run` can trust the type of its argument.
|
|
43
|
-
*
|
|
44
|
-
* The returned definition erases `TParams` to `unknown` so heterogeneous
|
|
45
|
-
* handlers can share an {@link RpcHandlerMap}.
|
|
46
|
-
*
|
|
47
|
-
* @param paramsStruct - Struct that validates `params` for this method.
|
|
48
|
-
* @param run - Handler invoked with the validated params.
|
|
49
|
-
* @returns An {@link RpcHandlerDefinition} suitable for an {@link RpcHandlerMap}.
|
|
50
|
-
*/
|
|
51
|
-
export declare function defineHandler<TParams, TResult extends Json | void>(paramsStruct: Struct<TParams>, run: RpcHandler<TParams, TResult>): RpcHandlerDefinition<unknown, TResult>;
|
|
52
|
-
/**
|
|
53
|
-
* Typed wrapper around `wallet.messenger.call` used by the `call` RPC.
|
|
54
|
-
*
|
|
55
|
-
* The messenger is strongly typed by action name; the daemon exposes the full
|
|
56
|
-
* messenger surface over the socket and dispatches by string, so we consolidate
|
|
57
|
-
* the unsafe cast into a single, documented escape hatch instead of repeating
|
|
58
|
-
* it at each call site.
|
|
59
|
-
*/
|
|
60
|
-
export type RpcDispatcher = (action: string, ...args: Json[]) => Promise<Json>;
|
|
61
|
-
/**
|
|
62
|
-
* Resolved paths for daemon state files.
|
|
63
|
-
*/
|
|
64
|
-
export type DaemonPaths = {
|
|
65
|
-
socketPath: string;
|
|
66
|
-
pidPath: string;
|
|
67
|
-
logPath: string;
|
|
68
|
-
dbPath: string;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Status information returned by the daemon's `getStatus` RPC method.
|
|
72
|
-
*/
|
|
73
|
-
export type DaemonStatusInfo = {
|
|
74
|
-
pid: number;
|
|
75
|
-
uptime: number;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Configuration passed to the daemon spawner.
|
|
79
|
-
*
|
|
80
|
-
* `password` is optional: when omitted, the daemon starts without unlocking
|
|
81
|
-
* the keyring, and the caller is expected to use `mm wallet unlock` before
|
|
82
|
-
* any keyring-bound operation. First-run startup still requires both
|
|
83
|
-
* `password` and `srp`; without `password`, the daemon will exit during
|
|
84
|
-
* startup with a clear error. `srp` is always required by the type and
|
|
85
|
-
* forwarded to the daemon; it is only consumed on first run.
|
|
86
|
-
*/
|
|
87
|
-
export type DaemonSpawnConfig = {
|
|
88
|
-
dataDir: string;
|
|
89
|
-
infuraProjectId: string;
|
|
90
|
-
password?: Password;
|
|
91
|
-
srp: Srp;
|
|
92
|
-
packageRo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AK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/daemon/types.ts"],"names":[],"mappings":"AAiDA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAC3B,YAA6B,EAC7B,GAAiC;IAEjC,OAAO,EAAE,YAAY,EAAE,GAAG,EAGzB,CAAC;AACJ,CAAC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\n\nimport type { Password, Srp } from './secrets.js';\n\n/**\n * Sink for daemon diagnostic messages. A backgrounded daemon's stdio may be\n * discarded, so hosts supply a logger that writes somewhere durable.\n */\nexport type Logger = (message: string) => void;\n\n/**\n * A function that handles a JSON-RPC method call after its params have been\n * validated by the corresponding {@link RpcHandlerDefinition.paramsStruct}.\n */\nexport type RpcHandler<TParams, TResult> = (\n params: TParams,\n) => Promise<TResult>;\n\n/**\n * Definition for a single JSON-RPC method: the struct that validates\n * incoming `params` plus the handler that runs once `params` is known to\n * match.\n *\n * The server (see `rpc-socket-server.ts`) validates the raw `params` against\n * `paramsStruct` before invoking `run`, so each handler body can trust the\n * shape of its input without re-checking.\n */\nexport type RpcHandlerDefinition<TParams, TResult extends Json | void> = {\n paramsStruct: Struct<TParams>;\n run: RpcHandler<TParams, TResult>;\n};\n\n/**\n * A map of RPC method names to their handler definitions.\n *\n * `TParams` is erased to `unknown` here so definitions with different narrow\n * params types (e.g. `null` vs. a tuple) can coexist in the same map. Consumers\n * therefore see each `run` as accepting `unknown` and must validate `params`\n * against the paired `paramsStruct` before invoking it — which is exactly what\n * the server (see `rpc-socket-server.ts`) does. The concrete `TParams` is\n * captured inside {@link defineHandler}, where the struct and handler are bound\n * together.\n */\nexport type RpcHandlerMap = Record<\n string,\n RpcHandlerDefinition<unknown, Json | void>\n>;\n\n/**\n * Bundle a params struct with the handler that runs once `params` is\n * validated. The server invokes `run` only after `paramsStruct` accepts the\n * value, so `run` can trust the type of its argument.\n *\n * The returned definition erases `TParams` to `unknown` so heterogeneous\n * handlers can share an {@link RpcHandlerMap}.\n *\n * @param paramsStruct - Struct that validates `params` for this method.\n * @param run - Handler invoked with the validated params.\n * @returns An {@link RpcHandlerDefinition} suitable for an {@link RpcHandlerMap}.\n */\nexport function defineHandler<TParams, TResult extends Json | void>(\n paramsStruct: Struct<TParams>,\n run: RpcHandler<TParams, TResult>,\n): RpcHandlerDefinition<unknown, TResult> {\n return { paramsStruct, run } as unknown as RpcHandlerDefinition<\n unknown,\n TResult\n >;\n}\n\n/**\n * Typed wrapper around `wallet.messenger.call` used by the `call` RPC.\n *\n * The messenger is strongly typed by action name; the daemon exposes the full\n * messenger surface over the socket and dispatches by string, so we consolidate\n * the unsafe cast into a single, documented escape hatch instead of repeating\n * it at each call site.\n */\nexport type RpcDispatcher = (action: string, ...args: Json[]) => Promise<Json>;\n\n/**\n * Resolved paths for daemon state files.\n */\nexport type DaemonPaths = {\n socketPath: string;\n pidPath: string;\n logPath: string;\n dbPath: string;\n};\n\n/**\n * Status information returned by the daemon's `getStatus` RPC method.\n */\nexport type DaemonStatusInfo = {\n pid: number;\n uptime: number;\n};\n\n/**\n * Configuration passed to the daemon spawner.\n *\n * `password` is optional: when omitted, the daemon starts without unlocking\n * the keyring, and the caller is expected to use `mm wallet unlock` before\n * any keyring-bound operation. First-run startup still requires both\n * `password` and `srp`; without `password`, the daemon will exit during\n * startup with a clear error. `srp` is always required by the type and\n * forwarded to the daemon; it is only consumed on first run.\n */\nexport type DaemonSpawnConfig = {\n dataDir: string;\n infuraProjectId: string;\n password?: Password;\n srp: Srp;\n packageRoot: string;\n};\n"]}
|