sigild 0.0.7 → 0.0.9
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 +80 -27
- package/THREAT_MODEL.md +6 -4
- package/dist/src/audit/log.d.ts +1 -1
- package/dist/src/audit/log.js +1 -1
- package/dist/src/bin/sigil-mcp.js +60 -16
- package/dist/src/bin/sigil-mcp.js.map +1 -1
- package/dist/src/cli/index.d.ts +2 -2
- package/dist/src/cli/index.d.ts.map +1 -1
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/main.d.ts.map +1 -1
- package/dist/src/cli/main.js +35 -9
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/cli/paths.d.ts +15 -5
- package/dist/src/cli/paths.d.ts.map +1 -1
- package/dist/src/cli/paths.js +11 -1
- package/dist/src/cli/paths.js.map +1 -1
- package/dist/src/cli/portal.d.ts +14 -1
- package/dist/src/cli/portal.d.ts.map +1 -1
- package/dist/src/cli/portal.js +31 -1
- package/dist/src/cli/portal.js.map +1 -1
- package/dist/src/cli/status.d.ts +15 -12
- package/dist/src/cli/status.d.ts.map +1 -1
- package/dist/src/cli/status.js +17 -30
- package/dist/src/cli/status.js.map +1 -1
- package/dist/src/cli/unlock.d.ts +15 -15
- package/dist/src/cli/unlock.d.ts.map +1 -1
- package/dist/src/cli/unlock.js +83 -60
- package/dist/src/cli/unlock.js.map +1 -1
- package/dist/src/confirm/ack-server.d.ts +53 -0
- package/dist/src/confirm/ack-server.d.ts.map +1 -0
- package/dist/src/confirm/ack-server.js +87 -0
- package/dist/src/confirm/ack-server.js.map +1 -0
- package/dist/src/confirm/config.d.ts +54 -0
- package/dist/src/confirm/config.d.ts.map +1 -0
- package/dist/src/confirm/config.js +139 -0
- package/dist/src/confirm/config.js.map +1 -0
- package/dist/src/confirm/gate.d.ts +38 -0
- package/dist/src/confirm/gate.d.ts.map +1 -0
- package/dist/src/confirm/gate.js +66 -0
- package/dist/src/confirm/gate.js.map +1 -0
- package/dist/src/confirm/index.d.ts +6 -0
- package/dist/src/confirm/index.d.ts.map +1 -0
- package/dist/src/confirm/index.js +5 -0
- package/dist/src/confirm/index.js.map +1 -0
- package/dist/src/confirm/ntfy.d.ts +38 -0
- package/dist/src/confirm/ntfy.d.ts.map +1 -0
- package/dist/src/confirm/ntfy.js +47 -0
- package/dist/src/confirm/ntfy.js.map +1 -0
- package/dist/src/confirm/types.d.ts +66 -0
- package/dist/src/confirm/types.d.ts.map +1 -0
- package/dist/src/confirm/types.js +12 -0
- package/dist/src/confirm/types.js.map +1 -0
- package/dist/src/control/broadcast.d.ts +29 -0
- package/dist/src/control/broadcast.d.ts.map +1 -0
- package/dist/src/control/broadcast.js +88 -0
- package/dist/src/control/broadcast.js.map +1 -0
- package/dist/src/control/client.d.ts.map +1 -1
- package/dist/src/control/client.js +4 -1
- package/dist/src/control/client.js.map +1 -1
- package/dist/src/control/index.d.ts +1 -0
- package/dist/src/control/index.d.ts.map +1 -1
- package/dist/src/control/index.js +1 -0
- package/dist/src/control/index.js.map +1 -1
- package/dist/src/control/protocol.d.ts +6 -2
- package/dist/src/control/protocol.d.ts.map +1 -1
- package/dist/src/control/protocol.js +2 -1
- package/dist/src/control/protocol.js.map +1 -1
- package/dist/src/control/server.d.ts +10 -0
- package/dist/src/control/server.d.ts.map +1 -1
- package/dist/src/control/server.js +60 -7
- package/dist/src/control/server.js.map +1 -1
- package/dist/src/daemon/handles.d.ts +5 -2
- package/dist/src/daemon/handles.d.ts.map +1 -1
- package/dist/src/daemon/handles.js +11 -3
- package/dist/src/daemon/handles.js.map +1 -1
- package/dist/src/daemon/methods.d.ts +13 -3
- package/dist/src/daemon/methods.d.ts.map +1 -1
- package/dist/src/daemon/methods.js +121 -16
- package/dist/src/daemon/methods.js.map +1 -1
- package/dist/src/eth/secp.d.ts.map +1 -1
- package/dist/src/eth/secp.js +6 -2
- package/dist/src/eth/secp.js.map +1 -1
- package/dist/src/hooks/command-scanner.d.ts.map +1 -1
- package/dist/src/hooks/command-scanner.js +57 -13
- package/dist/src/hooks/command-scanner.js.map +1 -1
- package/dist/src/hooks/glob.js +1 -1
- package/dist/src/hooks/glob.js.map +1 -1
- package/dist/src/hooks/path-blocker.d.ts.map +1 -1
- package/dist/src/hooks/path-blocker.js +1 -8
- package/dist/src/hooks/path-blocker.js.map +1 -1
- package/dist/src/mcp/server.d.ts +14 -2
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +28 -14
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools.d.ts +1 -1
- package/dist/src/mcp/tools.d.ts.map +1 -1
- package/dist/src/mcp/tools.js +38 -4
- package/dist/src/mcp/tools.js.map +1 -1
- package/dist/src/policy/evaluate.d.ts +10 -4
- package/dist/src/policy/evaluate.d.ts.map +1 -1
- package/dist/src/policy/evaluate.js +161 -20
- package/dist/src/policy/evaluate.js.map +1 -1
- package/dist/src/policy/loader.d.ts.map +1 -1
- package/dist/src/policy/loader.js +70 -0
- package/dist/src/policy/loader.js.map +1 -1
- package/dist/src/policy/template.d.ts +1 -1
- package/dist/src/policy/template.d.ts.map +1 -1
- package/dist/src/policy/template.js +30 -0
- package/dist/src/policy/template.js.map +1 -1
- package/dist/src/policy/types.d.ts +53 -3
- package/dist/src/policy/types.d.ts.map +1 -1
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/qr/encode.d.ts +36 -0
- package/dist/src/qr/encode.d.ts.map +1 -0
- package/dist/src/qr/encode.js +44 -0
- package/dist/src/qr/encode.js.map +1 -0
- package/dist/src/qr/index.d.ts +3 -0
- package/dist/src/qr/index.d.ts.map +1 -0
- package/dist/src/qr/index.js +3 -0
- package/dist/src/qr/index.js.map +1 -0
- package/dist/src/qr/render.d.ts +34 -0
- package/dist/src/qr/render.d.ts.map +1 -0
- package/dist/src/qr/render.js +43 -0
- package/dist/src/qr/render.js.map +1 -0
- package/dist/src/svm/address.d.ts +14 -0
- package/dist/src/svm/address.d.ts.map +1 -0
- package/dist/src/svm/address.js +18 -0
- package/dist/src/svm/address.js.map +1 -0
- package/dist/src/svm/base58.d.ts +15 -0
- package/dist/src/svm/base58.d.ts.map +1 -0
- package/dist/src/svm/base58.js +60 -0
- package/dist/src/svm/base58.js.map +1 -0
- package/dist/src/svm/ed25519.d.ts +19 -0
- package/dist/src/svm/ed25519.d.ts.map +1 -0
- package/dist/src/svm/ed25519.js +32 -0
- package/dist/src/svm/ed25519.js.map +1 -0
- package/dist/src/svm/index.d.ts +5 -0
- package/dist/src/svm/index.d.ts.map +1 -0
- package/dist/src/svm/index.js +5 -0
- package/dist/src/svm/index.js.map +1 -0
- package/dist/src/svm/transaction.d.ts +56 -0
- package/dist/src/svm/transaction.d.ts.map +1 -0
- package/dist/src/svm/transaction.js +182 -0
- package/dist/src/svm/transaction.js.map +1 -0
- package/package.json +4 -2
package/dist/src/cli/paths.js
CHANGED
|
@@ -6,8 +6,18 @@ export function resolvePaths(env = process.env) {
|
|
|
6
6
|
home,
|
|
7
7
|
keysDir: join(home, 'keys'),
|
|
8
8
|
policyDir: join(home, 'policy'),
|
|
9
|
-
|
|
9
|
+
controlDir: env['SIGIL_CONTROL_DIR'] ?? join(home, 'control'),
|
|
10
10
|
auditLog: join(home, 'audit.log'),
|
|
11
|
+
configFile: join(home, 'config.toml'),
|
|
11
12
|
};
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The control socket path for a single sigil-mcp instance, named for its PID.
|
|
16
|
+
* Unique per live process, so two sessions never contend for the same path
|
|
17
|
+
* (a same-PID collision only happens after PID reuse, which the server's
|
|
18
|
+
* stale-socket recovery handles on bind).
|
|
19
|
+
*/
|
|
20
|
+
export function sessionSocketPath(controlDir, pid) {
|
|
21
|
+
return join(controlDir, `${pid}.sock`);
|
|
22
|
+
}
|
|
13
23
|
//# sourceMappingURL=paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/cli/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/cli/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAsBjC,MAAM,UAAU,YAAY,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC/D,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5D,OAAO;QACL,IAAI;QACJ,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;QAC3B,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;QAC/B,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;QAC7D,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC;QACjC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC;KACtC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB,EAAE,GAAW;IAC/D,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/src/cli/portal.d.ts
CHANGED
|
@@ -60,8 +60,11 @@ export declare function portalNew(paths: SigilPaths, opts: PortalNewOpts): {
|
|
|
60
60
|
};
|
|
61
61
|
export interface PortalInfo {
|
|
62
62
|
handle: string;
|
|
63
|
-
kind: '
|
|
63
|
+
kind: 'evm';
|
|
64
|
+
/** EVM address (secp256k1). */
|
|
64
65
|
address: string;
|
|
66
|
+
/** Solana address (ed25519) derived from the same secret. */
|
|
67
|
+
svmAddress: string;
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
70
|
* Lists portals by reading the keys directory and decrypting each keyfile
|
|
@@ -69,6 +72,16 @@ export interface PortalInfo {
|
|
|
69
72
|
* Returns an empty list if the directory doesn't exist.
|
|
70
73
|
*/
|
|
71
74
|
export declare function portalListFromDisk(paths: SigilPaths, passphrase: Buffer): PortalInfo[];
|
|
75
|
+
/**
|
|
76
|
+
* Resolve a single portal's address by decrypting its keyfile, deriving
|
|
77
|
+
* the address, then disposing the secret. Throws if the handle is malformed
|
|
78
|
+
* or the keyfile is missing / can't be decrypted with this passphrase.
|
|
79
|
+
*
|
|
80
|
+
* Used by `sigil portal qr` — same trust model as `portal list`, just
|
|
81
|
+
* scoped to one handle so we don't decrypt the whole keychain to render
|
|
82
|
+
* a single QR.
|
|
83
|
+
*/
|
|
84
|
+
export declare function portalAddress(paths: SigilPaths, handle: string, passphrase: Buffer): string;
|
|
72
85
|
export interface PortalRemoveResult {
|
|
73
86
|
removed: boolean;
|
|
74
87
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../src/cli/portal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAW,YAAY,EAAa,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../src/cli/portal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAW,YAAY,EAAa,MAAM,oBAAoB,CAAC;AAItF,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC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G;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GACf;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAa1C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAalF;AAqBD,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/src/cli/portal.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, unlinkSync, writeFile
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { sealKey, SecretBuffer, unsealKey } from '../crypto/index.js';
|
|
4
4
|
import { addressFromPrivateKey, randomSecretKey } from '../eth/index.js';
|
|
5
|
+
import { svmAddressFromSecret } from '../svm/index.js';
|
|
5
6
|
import { HandleTable } from '../daemon/handles.js';
|
|
6
7
|
import { policyTemplate } from '../policy/index.js';
|
|
7
8
|
/**
|
|
@@ -93,7 +94,12 @@ export function portalListFromDisk(paths, passphrase) {
|
|
|
93
94
|
const blob = readFileSync(join(paths.keysDir, filename));
|
|
94
95
|
const sb = unsealKey(blob, passphrase);
|
|
95
96
|
try {
|
|
96
|
-
out.push({
|
|
97
|
+
out.push({
|
|
98
|
+
handle,
|
|
99
|
+
kind: 'evm',
|
|
100
|
+
address: addressFromPrivateKey(sb.bytes()),
|
|
101
|
+
svmAddress: svmAddressFromSecret(sb.bytes()),
|
|
102
|
+
});
|
|
97
103
|
}
|
|
98
104
|
finally {
|
|
99
105
|
sb.dispose();
|
|
@@ -101,6 +107,30 @@ export function portalListFromDisk(paths, passphrase) {
|
|
|
101
107
|
}
|
|
102
108
|
return out;
|
|
103
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Resolve a single portal's address by decrypting its keyfile, deriving
|
|
112
|
+
* the address, then disposing the secret. Throws if the handle is malformed
|
|
113
|
+
* or the keyfile is missing / can't be decrypted with this passphrase.
|
|
114
|
+
*
|
|
115
|
+
* Used by `sigil portal qr` — same trust model as `portal list`, just
|
|
116
|
+
* scoped to one handle so we don't decrypt the whole keychain to render
|
|
117
|
+
* a single QR.
|
|
118
|
+
*/
|
|
119
|
+
export function portalAddress(paths, handle, passphrase) {
|
|
120
|
+
HandleTable.parseHandle(handle);
|
|
121
|
+
const keyfilePath = join(paths.keysDir, `${handle}.sigil`);
|
|
122
|
+
if (!existsSync(keyfilePath)) {
|
|
123
|
+
throw new Error(`portal "${handle}" not found at ${keyfilePath}`);
|
|
124
|
+
}
|
|
125
|
+
const blob = readFileSync(keyfilePath);
|
|
126
|
+
const sb = unsealKey(blob, passphrase);
|
|
127
|
+
try {
|
|
128
|
+
return addressFromPrivateKey(sb.bytes());
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
sb.dispose();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
104
134
|
/**
|
|
105
135
|
* Provision a policy file for an existing portal whose keyfile is on disk
|
|
106
136
|
* but whose policy got lost (older sigil versions, manual deletion, etc).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","sourceRoot":"","sources":["../../../src/cli/portal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAY,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAkB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAmB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AA4BrE;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAC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AC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,2EAA2E;AAC3E,4CAA4C;AAC5C,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/src/cli/status.d.ts
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import { type PortalSummary } from '../control/index.js';
|
|
2
2
|
import type { SigilPaths } from './paths.js';
|
|
3
|
+
export interface SessionStatus {
|
|
4
|
+
/** Process ID of the running sigil-mcp. */
|
|
5
|
+
pid: number;
|
|
6
|
+
/** Whether this session's HandleTable is unlocked. */
|
|
7
|
+
unlocked: boolean;
|
|
8
|
+
/** Portals loaded in this session (empty when locked). */
|
|
9
|
+
portals: PortalSummary[];
|
|
10
|
+
}
|
|
3
11
|
export interface StatusReport {
|
|
4
12
|
/** Number of *.sigil files in the keys directory. */
|
|
5
13
|
keyfilesOnDisk: number;
|
|
6
14
|
/** Path the audit log lives at. Useful for `tail`-ing during incidents. */
|
|
7
15
|
auditLog: string;
|
|
8
|
-
/** True if
|
|
16
|
+
/** True if at least one sigil-mcp session answered the control socket. */
|
|
9
17
|
mcpRunning: boolean;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/** True if the HandleTable has been unlocked. False when mcp is down or locked. */
|
|
13
|
-
unlocked: boolean;
|
|
14
|
-
/** Portals currently loaded in the running sigil-mcp. Empty when locked or down. */
|
|
15
|
-
portals: PortalSummary[];
|
|
18
|
+
/** Per-session live state, one entry per reachable sigil-mcp. */
|
|
19
|
+
sessions: SessionStatus[];
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* Reports the on-disk + live state of sigil. Does NOT require the passphrase.
|
|
19
23
|
*
|
|
20
24
|
* Disk side: counts encrypted keyfiles.
|
|
21
|
-
* Live side:
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* detailed diagnosis.
|
|
25
|
+
* Live side: fans a status probe out across every per-session control socket.
|
|
26
|
+
* Each reachable sigil-mcp contributes a SessionStatus; stale sockets (from
|
|
27
|
+
* hard-killed sessions) are reaped during the broadcast. When no Claude Code
|
|
28
|
+
* session is open, `sessions` is empty and `mcpRunning` is false.
|
|
26
29
|
*/
|
|
27
30
|
export declare function status(paths: SigilPaths): Promise<StatusReport>;
|
|
28
31
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/cli/status.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/cli/status.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,UAAU,EAAE,OAAO,CAAC;IACpB,iEAAiE;IACjE,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBrE"}
|
package/dist/src/cli/status.js
CHANGED
|
@@ -1,46 +1,33 @@
|
|
|
1
1
|
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
-
import {
|
|
2
|
+
import { broadcast, isControlError, } from '../control/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Reports the on-disk + live state of sigil. Does NOT require the passphrase.
|
|
5
5
|
*
|
|
6
6
|
* Disk side: counts encrypted keyfiles.
|
|
7
|
-
* Live side:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* detailed diagnosis.
|
|
7
|
+
* Live side: fans a status probe out across every per-session control socket.
|
|
8
|
+
* Each reachable sigil-mcp contributes a SessionStatus; stale sockets (from
|
|
9
|
+
* hard-killed sessions) are reaped during the broadcast. When no Claude Code
|
|
10
|
+
* session is open, `sessions` is empty and `mcpRunning` is false.
|
|
12
11
|
*/
|
|
13
12
|
export async function status(paths) {
|
|
14
13
|
const keyfilesOnDisk = countKeyfiles(paths.keysDir);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
if (!isControlError(resp)) {
|
|
26
|
-
mcpRunning = true;
|
|
27
|
-
mcpPid = resp.pid;
|
|
28
|
-
unlocked = resp.unlocked;
|
|
29
|
-
portals = resp.portals;
|
|
14
|
+
const results = await broadcast(paths.controlDir, { method: 'status' }, 1_000);
|
|
15
|
+
const sessions = [];
|
|
16
|
+
for (const r of results) {
|
|
17
|
+
if (r.response && !isControlError(r.response)) {
|
|
18
|
+
sessions.push({
|
|
19
|
+
pid: r.response.pid,
|
|
20
|
+
unlocked: r.response.unlocked,
|
|
21
|
+
portals: r.response.portals,
|
|
22
|
+
});
|
|
30
23
|
}
|
|
31
24
|
}
|
|
32
|
-
|
|
33
|
-
if (!(err instanceof ControlClientError))
|
|
34
|
-
throw err;
|
|
35
|
-
// SERVER_DOWN / CONNECT_FAILED / TIMEOUT all → mcpRunning=false.
|
|
36
|
-
}
|
|
25
|
+
sessions.sort((a, b) => a.pid - b.pid);
|
|
37
26
|
return {
|
|
38
27
|
keyfilesOnDisk,
|
|
39
28
|
auditLog: paths.auditLog,
|
|
40
|
-
mcpRunning,
|
|
41
|
-
|
|
42
|
-
unlocked,
|
|
43
|
-
portals,
|
|
29
|
+
mcpRunning: sessions.length > 0,
|
|
30
|
+
sessions,
|
|
44
31
|
};
|
|
45
32
|
}
|
|
46
33
|
function countKeyfiles(dir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/cli/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/cli/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,cAAc,GAEf,MAAM,qBAAqB,CAAC;AAuB7B;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAiB;IAC5C,MAAM,cAAc,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9C,QAAQ,CAAC,IAAI,CAAC;gBACZ,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG;gBACnB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ;gBAC7B,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO;aAC5B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO;QACL,cAAc;QACd,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,UAAU,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC/B,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;AACrE,CAAC"}
|
package/dist/src/cli/unlock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type SessionResult } from '../control/index.js';
|
|
2
2
|
import type { SigilPaths } from './paths.js';
|
|
3
3
|
export interface UnlockOpts {
|
|
4
4
|
paths: SigilPaths;
|
|
@@ -7,29 +7,29 @@ export interface UnlockOpts {
|
|
|
7
7
|
/** Optional connect timeout in ms (default 5000). */
|
|
8
8
|
timeoutMs?: number;
|
|
9
9
|
}
|
|
10
|
-
export interface UnlockResult {
|
|
11
|
-
/** Server-side response, or null if the server is unreachable. */
|
|
12
|
-
response: ControlResponse | null;
|
|
13
|
-
/** Set when the control socket couldn't be reached. */
|
|
14
|
-
clientError?: ControlClientError;
|
|
15
|
-
}
|
|
16
10
|
/**
|
|
17
|
-
*
|
|
11
|
+
* Push an unlock to every running sigil-mcp session. Encodes the passphrase as
|
|
18
12
|
* base64 for transport; does NOT clear the caller's buffer (the caller owns
|
|
19
|
-
* lifetime). Returns the
|
|
20
|
-
*
|
|
13
|
+
* lifetime). Returns the per-session outcomes — aggregate them with
|
|
14
|
+
* {@link formatResult}.
|
|
21
15
|
*/
|
|
22
|
-
export declare function unlock(opts: UnlockOpts): Promise<
|
|
16
|
+
export declare function unlock(opts: UnlockOpts): Promise<SessionResult[]>;
|
|
23
17
|
export interface LockOpts {
|
|
24
18
|
paths: SigilPaths;
|
|
25
19
|
timeoutMs?: number;
|
|
26
20
|
}
|
|
27
|
-
export declare function lock(opts: LockOpts): Promise<
|
|
21
|
+
export declare function lock(opts: LockOpts): Promise<SessionResult[]>;
|
|
28
22
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
23
|
+
* Aggregate per-session outcomes into a single human-readable line + exit code.
|
|
24
|
+
*
|
|
25
|
+
* Sessions that were reaped (stale sockets from dead processes) are ignored —
|
|
26
|
+
* they don't count as reachable. If nothing was reachable, that's "not
|
|
27
|
+
* running". A wrong passphrase fails uniformly (all sessions share the same
|
|
28
|
+
* keyfiles), so any WRONG_PASSPHRASE short-circuits to exit 2. Otherwise we
|
|
29
|
+
* report how many sessions ended up in the desired state, treating
|
|
30
|
+
* ALREADY_UNLOCKED as a successful unlock.
|
|
31
31
|
*/
|
|
32
|
-
export declare function formatResult(action: 'unlock' | 'lock',
|
|
32
|
+
export declare function formatResult(action: 'unlock' | 'lock', sessions: SessionResult[]): {
|
|
33
33
|
message: string;
|
|
34
34
|
code: number;
|
|
35
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../src/cli/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../src/cli/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAGvE;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAEnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAgEA"}
|
package/dist/src/cli/unlock.js
CHANGED
|
@@ -1,77 +1,100 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { broadcast, isControlError, } from '../control/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Push an unlock to every running sigil-mcp session. Encodes the passphrase as
|
|
4
4
|
* base64 for transport; does NOT clear the caller's buffer (the caller owns
|
|
5
|
-
* lifetime). Returns the
|
|
6
|
-
*
|
|
5
|
+
* lifetime). Returns the per-session outcomes — aggregate them with
|
|
6
|
+
* {@link formatResult}.
|
|
7
7
|
*/
|
|
8
8
|
export async function unlock(opts) {
|
|
9
9
|
const passphraseB64 = opts.passphrase.toString('base64');
|
|
10
|
-
|
|
11
|
-
const response = await controlRequest({
|
|
12
|
-
socketPath: opts.paths.controlSocket,
|
|
13
|
-
request: { method: 'unlock', passphraseB64 },
|
|
14
|
-
...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),
|
|
15
|
-
});
|
|
16
|
-
return { response };
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
if (err instanceof ControlClientError)
|
|
20
|
-
return { response: null, clientError: err };
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
10
|
+
return broadcast(opts.paths.controlDir, { method: 'unlock', passphraseB64 }, opts.timeoutMs);
|
|
23
11
|
}
|
|
24
12
|
export async function lock(opts) {
|
|
25
|
-
|
|
26
|
-
const response = await controlRequest({
|
|
27
|
-
socketPath: opts.paths.controlSocket,
|
|
28
|
-
request: { method: 'lock' },
|
|
29
|
-
...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),
|
|
30
|
-
});
|
|
31
|
-
return { response };
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
if (err instanceof ControlClientError)
|
|
35
|
-
return { response: null, clientError: err };
|
|
36
|
-
throw err;
|
|
37
|
-
}
|
|
13
|
+
return broadcast(opts.paths.controlDir, { method: 'lock' }, opts.timeoutMs);
|
|
38
14
|
}
|
|
39
15
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
16
|
+
* Aggregate per-session outcomes into a single human-readable line + exit code.
|
|
17
|
+
*
|
|
18
|
+
* Sessions that were reaped (stale sockets from dead processes) are ignored —
|
|
19
|
+
* they don't count as reachable. If nothing was reachable, that's "not
|
|
20
|
+
* running". A wrong passphrase fails uniformly (all sessions share the same
|
|
21
|
+
* keyfiles), so any WRONG_PASSPHRASE short-circuits to exit 2. Otherwise we
|
|
22
|
+
* report how many sessions ended up in the desired state, treating
|
|
23
|
+
* ALREADY_UNLOCKED as a successful unlock.
|
|
42
24
|
*/
|
|
43
|
-
export function formatResult(action,
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return {
|
|
25
|
+
export function formatResult(action, sessions) {
|
|
26
|
+
// A session is "reachable" if it answered at all (success or server-side
|
|
27
|
+
// error). Reaped / unreachable sockets don't count.
|
|
28
|
+
const answered = sessions.filter((s) => s.response !== null);
|
|
29
|
+
if (answered.length === 0) {
|
|
30
|
+
// Nothing live answered. Whether the directory was empty or every socket
|
|
31
|
+
// in it was stale (reaped this run), the actionable advice is the same:
|
|
32
|
+
// there's no running sigil-mcp to talk to.
|
|
33
|
+
return {
|
|
34
|
+
message: `sigil-mcp is not running. Start a Claude Code session (which spawns it via your MCP config) and try again.`,
|
|
35
|
+
code: 1,
|
|
36
|
+
};
|
|
52
37
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
return { message: `sigil
|
|
38
|
+
if (action === 'unlock') {
|
|
39
|
+
const wrong = answered.find((s) => s.response && isControlError(s.response) && s.response.code === 'WRONG_PASSPHRASE');
|
|
40
|
+
if (wrong)
|
|
41
|
+
return { message: `sigil unlock: wrong passphrase`, code: 2 };
|
|
42
|
+
// Unlocked = freshly unlocked (ok: true, carries authoritative portals) OR
|
|
43
|
+
// already unlocked. A current sigil-mcp reports already-unlocked sessions
|
|
44
|
+
// as ok: true too; the legacy ALREADY_UNLOCKED error is still accepted here
|
|
45
|
+
// for forward-compat with an older server process. Anything else is a
|
|
46
|
+
// per-session failure we surface without sinking the sessions that worked.
|
|
47
|
+
const portalBearing = []; // ok: true — knows its portals
|
|
48
|
+
const unlockedNoInfo = []; // legacy ALREADY_UNLOCKED — portals unknown
|
|
49
|
+
const failed = [];
|
|
50
|
+
for (const s of answered) {
|
|
51
|
+
const r = s.response;
|
|
52
|
+
if (!isControlError(r))
|
|
53
|
+
portalBearing.push(s);
|
|
54
|
+
else if (r.code === 'ALREADY_UNLOCKED')
|
|
55
|
+
unlockedNoInfo.push(s);
|
|
56
|
+
else
|
|
57
|
+
failed.push(s);
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
59
|
+
const unlockedCount = portalBearing.length + unlockedNoInfo.length;
|
|
60
|
+
if (unlockedCount === 0) {
|
|
61
|
+
const first = failed[0]?.response;
|
|
62
|
+
const detail = first && isControlError(first) ? `${first.error} (${first.code})` : 'unknown error';
|
|
63
|
+
return { message: `sigil unlock: ${detail}`, code: 1 };
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
const portals = portalsOf(portalBearing);
|
|
66
|
+
const sessionWord = unlockedCount === 1 ? 'session' : 'sessions';
|
|
67
|
+
let portalPart;
|
|
68
|
+
if (portals.length > 0) {
|
|
69
|
+
portalPart = `: ${portals.join(', ')}`;
|
|
70
|
+
}
|
|
71
|
+
else if (portalBearing.length > 0) {
|
|
72
|
+
// At least one session authoritatively reported its (empty) portal set.
|
|
73
|
+
portalPart = ' (no portals on disk yet — add one with "sigil portal add")';
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Only legacy already-unlocked responses, which don't echo portals.
|
|
77
|
+
portalPart = '';
|
|
78
|
+
}
|
|
79
|
+
let message = `unlocked ${unlockedCount} ${sessionWord}${portalPart}`;
|
|
80
|
+
if (failed.length > 0)
|
|
81
|
+
message += ` — ${failed.length} session(s) failed to unlock`;
|
|
82
|
+
return { message, code: 0 };
|
|
65
83
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
// lock: every answered session is now locked.
|
|
85
|
+
const n = answered.length;
|
|
86
|
+
return { message: `locked ${n} session${n === 1 ? '' : 's'}`, code: 0 };
|
|
87
|
+
}
|
|
88
|
+
/** Distinct portal handles across the given sessions, in first-seen order. */
|
|
89
|
+
function portalsOf(sessions) {
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
for (const s of sessions) {
|
|
92
|
+
const r = s.response;
|
|
93
|
+
if (r && !isControlError(r)) {
|
|
94
|
+
for (const p of r.portals)
|
|
95
|
+
seen.add(p.handle);
|
|
96
|
+
}
|
|
74
97
|
}
|
|
75
|
-
return
|
|
98
|
+
return [...seen];
|
|
76
99
|
}
|
|
77
100
|
//# sourceMappingURL=unlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlock.js","sourceRoot":"","sources":["../../../src/cli/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"unlock.js","sourceRoot":"","sources":["../../../src/cli/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,cAAc,GAEf,MAAM,qBAAqB,CAAC;AAW7B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAgB;IAC3C,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAC/F,CAAC;AAOD,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAc;IACvC,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyB,EAAE,QAAyB;IAI/E,yEAAyE;IACzE,oDAAoD;IACpD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC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AE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,8EAA8E;AAC9E,SAAS,SAAS,CAAC,QAAyB;IAC1C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5B,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO;gBAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local HTTP listener that resolves OOB-confirm clicks. One per sigil-mcp
|
|
3
|
+
* process, bound to 127.0.0.1 on a random port assigned by the kernel.
|
|
4
|
+
*
|
|
5
|
+
* Wire shape (intentionally trivial — every transport hands the human these
|
|
6
|
+
* two URLs, and tapping either resolves the gate):
|
|
7
|
+
*
|
|
8
|
+
* POST /approve?t=<token> → 200 if token matches a pending request
|
|
9
|
+
* POST /deny?t=<token> → 200 if token matches a pending request
|
|
10
|
+
* GET variants are accepted too, so a stock email/SMS link that's
|
|
11
|
+
* followed by a phone browser also works (some clients refuse to POST
|
|
12
|
+
* from a tap).
|
|
13
|
+
*
|
|
14
|
+
* Token semantics:
|
|
15
|
+
* - 32-byte cryptographically random, base64url-encoded, kept in process
|
|
16
|
+
* memory only.
|
|
17
|
+
* - Bound to one pending request — a token issued for sign-request A
|
|
18
|
+
* cannot approve sign-request B.
|
|
19
|
+
* - Single-use: cleared the moment we resolve. A replayed approval click
|
|
20
|
+
* after timeout gets a 410 Gone, not a silent re-approve.
|
|
21
|
+
*
|
|
22
|
+
* No TLS: the listener is on 127.0.0.1. A local attacker who can already
|
|
23
|
+
* make HTTP requests from this machine could also read the process's
|
|
24
|
+
* memory, so TLS here would be theatre.
|
|
25
|
+
*/
|
|
26
|
+
/** Outcome the ack server hands back to the gate. */
|
|
27
|
+
export type AckOutcome = 'approve' | 'deny';
|
|
28
|
+
export interface AckServer {
|
|
29
|
+
/** Hostname-and-port base, e.g. "http://127.0.0.1:42424". No trailing slash. */
|
|
30
|
+
readonly baseUrl: string;
|
|
31
|
+
/**
|
|
32
|
+
* Mint a single-use token bound to a pending request, and return the
|
|
33
|
+
* approve/deny URLs the human will click. The returned Promise resolves
|
|
34
|
+
* when the human clicks (or the caller calls `cancel(token)` — e.g. on
|
|
35
|
+
* timeout).
|
|
36
|
+
*/
|
|
37
|
+
pending(): {
|
|
38
|
+
token: string;
|
|
39
|
+
approveUrl: string;
|
|
40
|
+
denyUrl: string;
|
|
41
|
+
settled: Promise<AckOutcome>;
|
|
42
|
+
};
|
|
43
|
+
/** Drop a pending token without resolving (e.g. the gate timed out).
|
|
44
|
+
* Subsequent clicks for that token get 410 Gone. */
|
|
45
|
+
cancel(token: string): void;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Start a local ack server on 127.0.0.1 and resolve when it's listening.
|
|
50
|
+
* The chosen port is observable via `baseUrl`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function startAckServer(): Promise<AckServer>;
|
|
53
|
+
//# sourceMappingURL=ack-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ack-server.d.ts","sourceRoot":"","sources":["../../../src/confirm/ack-server.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qDAAqD;AACrD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAS5C,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,OAAO,IAAI;QACT,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;KAC9B,CAAC;IACF;yDACqD;IACrD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAAC,SAAS,CAAC,CAgDnD"}
|