@nimbus-dev/client 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/index.cjs +287 -42
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ipc-proof.d.ts +40 -0
- package/dist/ipc-proof.d.ts.map +1 -0
- package/dist/ipc-proof.js +146 -0
- package/dist/ipc-proof.js.map +1 -0
- package/dist/ipc-transport.d.ts +23 -0
- package/dist/ipc-transport.d.ts.map +1 -1
- package/dist/ipc-transport.js +83 -12
- package/dist/ipc-transport.js.map +1 -1
- package/dist/nimbus-client.d.ts +7 -0
- package/dist/nimbus-client.d.ts.map +1 -1
- package/dist/nimbus-client.js +4 -2
- package/dist/nimbus-client.js.map +1 -1
- package/dist/proving-ipc-client.d.ts +38 -0
- package/dist/proving-ipc-client.d.ts.map +1 -0
- package/dist/proving-ipc-client.js +94 -0
- package/dist/proving-ipc-client.js.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -120,6 +120,40 @@ try {
|
|
|
120
120
|
}
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
+
### Proving the gateway before a secret
|
|
124
|
+
|
|
125
|
+
`connectorAuth()` carries a token, so `NimbusClient` first proves that the process on the socket is
|
|
126
|
+
your gateway. The gateway writes a fresh key to an owner-only file at every start; the client and
|
|
127
|
+
the gateway each prove they hold it (an HMAC challenge in both directions) before the token is
|
|
128
|
+
sent. A process that cannot answer gets nothing, and the call rejects with a `GatewayProofError`
|
|
129
|
+
whose `kind` names the cause (`key-missing`, `impostor`, `restarted`, `refused`, `unavailable`,
|
|
130
|
+
`outdated`, `no-answer`, `connection-lost`) and whose message names the fix. Every other method is
|
|
131
|
+
untouched.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { GatewayProofError, NimbusClient } from "@nimbus-dev/client";
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
await client.connectorAuth({ serviceId: "github", token });
|
|
138
|
+
} catch (e) {
|
|
139
|
+
if (e instanceof GatewayProofError && e.kind === "outdated") {
|
|
140
|
+
// A gateway started by a Nimbus older than the proof: restart it (nimbus stop, nimbus start).
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- The key file is found beside the gateway's data (`getNimbusPaths().dataDir`). For a gateway
|
|
146
|
+
whose data dir this package does not derive, pass `keyPath` to `NimbusClient.open`. (A demo
|
|
147
|
+
gateway, `NIMBUS_DEMO=1`, refuses credentials outright.)
|
|
148
|
+
- After `impostor`, `restarted` or `no-answer` the connection is closed, as if it had died:
|
|
149
|
+
pending calls reject and `onClose` handlers (open streams) run. A `NimbusClient` cannot
|
|
150
|
+
reconnect, so open a new one.
|
|
151
|
+
- **Behaviour change in 0.20:** against a gateway older than the proof, `connectorAuth()` now
|
|
152
|
+
rejects with `outdated` or `key-missing` instead of sending the token; restarting the gateway
|
|
153
|
+
fixes it.
|
|
154
|
+
- Talking to the transport directly? Use `ProvingIPCClient` (a drop-in `IPCClient`) and it holds
|
|
155
|
+
every secret-carrying method (`SECRET_IPC_METHODS`) the same way.
|
|
156
|
+
|
|
123
157
|
### Egress ledger (provable locality)
|
|
124
158
|
|
|
125
159
|
Read-only view of the append-only, hash-chained egress ledger — every gated
|
package/dist/index.cjs
CHANGED
|
@@ -18,13 +18,15 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
18
18
|
return cached;
|
|
19
19
|
}
|
|
20
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
28
30
|
if (canCache)
|
|
29
31
|
cache.set(mod, to);
|
|
30
32
|
return to;
|
|
@@ -63,25 +65,33 @@ var __export = (target, all) => {
|
|
|
63
65
|
// src/index.ts
|
|
64
66
|
var exports_src = {};
|
|
65
67
|
__export(exports_src, {
|
|
66
|
-
|
|
67
|
-
jsonRpcErrorData: () => jsonRpcErrorData,
|
|
68
|
-
jsonRpcErrorCode: () => jsonRpcErrorCode,
|
|
69
|
-
isJsonRpcError: () => isJsonRpcError,
|
|
70
|
-
getNimbusPaths: () => getNimbusPaths,
|
|
71
|
-
gatewayStatePath: () => gatewayStatePath,
|
|
72
|
-
discoverSocketPath: () => discoverSocketPath,
|
|
73
|
-
NimbusClient: () => NimbusClient,
|
|
74
|
-
NO_EGRESS_COVERAGE: () => NO_EGRESS_COVERAGE,
|
|
75
|
-
MockClient: () => MockClient,
|
|
76
|
-
JsonRpcError: () => JsonRpcError,
|
|
77
|
-
IpcResponseError: () => IpcResponseError,
|
|
78
|
-
IPCClient: () => IPCClient,
|
|
79
|
-
EGRESS_GRANULARITIES: () => EGRESS_GRANULARITIES,
|
|
80
|
-
EGRESS_COVERAGE_CLASSES: () => EGRESS_COVERAGE_CLASSES,
|
|
81
|
-
DEFAULT_AGENT_TIMEOUT_MS: () => DEFAULT_AGENT_TIMEOUT_MS,
|
|
82
|
-
CONSENT_ANSWER_SOURCES: () => CONSENT_ANSWER_SOURCES,
|
|
68
|
+
AgentBriefError: () => AgentBriefError,
|
|
83
69
|
AgentTimeoutError: () => AgentTimeoutError,
|
|
84
|
-
|
|
70
|
+
CONSENT_ANSWER_SOURCES: () => CONSENT_ANSWER_SOURCES,
|
|
71
|
+
DEFAULT_AGENT_TIMEOUT_MS: () => DEFAULT_AGENT_TIMEOUT_MS,
|
|
72
|
+
EGRESS_COVERAGE_CLASSES: () => EGRESS_COVERAGE_CLASSES,
|
|
73
|
+
EGRESS_GRANULARITIES: () => EGRESS_GRANULARITIES,
|
|
74
|
+
GatewayProofError: () => GatewayProofError,
|
|
75
|
+
IPCClient: () => IPCClient,
|
|
76
|
+
IpcResponseError: () => IpcResponseError,
|
|
77
|
+
JsonRpcError: () => JsonRpcError,
|
|
78
|
+
MockClient: () => MockClient,
|
|
79
|
+
NO_EGRESS_COVERAGE: () => NO_EGRESS_COVERAGE,
|
|
80
|
+
NimbusClient: () => NimbusClient,
|
|
81
|
+
PROOF_LABEL_CLIENT: () => PROOF_LABEL_CLIENT,
|
|
82
|
+
PROOF_LABEL_SERVER: () => PROOF_LABEL_SERVER,
|
|
83
|
+
ProvingIPCClient: () => ProvingIPCClient,
|
|
84
|
+
SECRET_IPC_METHODS: () => SECRET_IPC_METHODS,
|
|
85
|
+
computeProof: () => computeProof,
|
|
86
|
+
discoverSocketPath: () => discoverSocketPath,
|
|
87
|
+
gatewayStatePath: () => gatewayStatePath,
|
|
88
|
+
getNimbusPaths: () => getNimbusPaths,
|
|
89
|
+
isJsonRpcError: () => isJsonRpcError,
|
|
90
|
+
jsonRpcErrorCode: () => jsonRpcErrorCode,
|
|
91
|
+
jsonRpcErrorData: () => jsonRpcErrorData,
|
|
92
|
+
parseHex32: () => parseHex32,
|
|
93
|
+
proofKeyFileName: () => proofKeyFileName,
|
|
94
|
+
readGatewayState: () => readGatewayState
|
|
85
95
|
});
|
|
86
96
|
module.exports = __toCommonJS(exports_src);
|
|
87
97
|
// node_modules/@nimbus-dev/sdk/src/agents/guard-factory.ts
|
|
@@ -703,9 +713,12 @@ async function discoverSocketPath(opts) {
|
|
|
703
713
|
}
|
|
704
714
|
return { socketPath: paths.socketPath, source: "default" };
|
|
705
715
|
}
|
|
716
|
+
// src/ipc-proof.ts
|
|
717
|
+
var import_node_crypto2 = require("node:crypto");
|
|
718
|
+
|
|
706
719
|
// src/ipc-transport.ts
|
|
707
720
|
var import_node_crypto = require("node:crypto");
|
|
708
|
-
var import_node_net = __toESM(require("node:net"));
|
|
721
|
+
var import_node_net = __toESM(require("node:net"), 1);
|
|
709
722
|
var import_node_os2 = require("node:os");
|
|
710
723
|
var HAS_BUN = globalThis.Bun !== undefined;
|
|
711
724
|
var DEFAULT_REQUEST_TIMEOUT_MS = 30000;
|
|
@@ -767,6 +780,9 @@ function tryParseJsonRecord(line) {
|
|
|
767
780
|
return;
|
|
768
781
|
}
|
|
769
782
|
}
|
|
783
|
+
function supersededDial() {
|
|
784
|
+
return new Error("IPC connect superseded by a disconnect or a newer connect");
|
|
785
|
+
}
|
|
770
786
|
|
|
771
787
|
class IPCClient {
|
|
772
788
|
socketPath;
|
|
@@ -778,31 +794,58 @@ class IPCClient {
|
|
|
778
794
|
bunSocket = null;
|
|
779
795
|
netSocket = null;
|
|
780
796
|
connected = false;
|
|
797
|
+
generation = 0;
|
|
781
798
|
requestTimeoutMs;
|
|
782
799
|
constructor(socketPath, opts) {
|
|
783
800
|
this.socketPath = socketPath;
|
|
784
801
|
this.requestTimeoutMs = opts?.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
785
802
|
}
|
|
803
|
+
get transportConnected() {
|
|
804
|
+
return this.connected;
|
|
805
|
+
}
|
|
806
|
+
get transportGeneration() {
|
|
807
|
+
return this.generation;
|
|
808
|
+
}
|
|
809
|
+
abortConnection(err) {
|
|
810
|
+
if (!this.connected)
|
|
811
|
+
return;
|
|
812
|
+
this.connected = false;
|
|
813
|
+
this.generation += 1;
|
|
814
|
+
this.failAll(err);
|
|
815
|
+
this.endWindowsTransport();
|
|
816
|
+
this.endUnixTransport();
|
|
817
|
+
this.notifyClosed(err);
|
|
818
|
+
}
|
|
786
819
|
async connect() {
|
|
787
820
|
if (this.connected) {
|
|
788
821
|
return;
|
|
789
822
|
}
|
|
790
823
|
this.reader = new NdjsonLineReader;
|
|
791
824
|
this.closeNotified = false;
|
|
825
|
+
this.generation += 1;
|
|
826
|
+
const gen = this.generation;
|
|
792
827
|
if (import_node_os2.platform() === "win32") {
|
|
793
|
-
await this.connectWindows();
|
|
828
|
+
await this.connectWindows(gen);
|
|
794
829
|
return;
|
|
795
830
|
}
|
|
796
|
-
await this.connectUnix();
|
|
831
|
+
await this.connectUnix(gen);
|
|
797
832
|
}
|
|
798
|
-
|
|
833
|
+
isCurrent(gen) {
|
|
834
|
+
return gen === this.generation;
|
|
835
|
+
}
|
|
836
|
+
async connectWindows(gen) {
|
|
799
837
|
await new Promise((resolve, reject) => {
|
|
800
838
|
const sock = import_node_net.default.createConnection(this.socketPath);
|
|
801
|
-
this.attachNetSocket(sock, resolve, reject);
|
|
839
|
+
this.attachNetSocket(sock, gen, resolve, reject);
|
|
802
840
|
});
|
|
803
841
|
}
|
|
804
|
-
attachNetSocket(sock, resolve, reject) {
|
|
842
|
+
attachNetSocket(sock, gen, resolve, reject) {
|
|
805
843
|
sock.on("connect", () => {
|
|
844
|
+
if (!this.isCurrent(gen)) {
|
|
845
|
+
sock.destroy();
|
|
846
|
+
reject(supersededDial());
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
806
849
|
this.netSocket = sock;
|
|
807
850
|
this.connected = true;
|
|
808
851
|
resolve();
|
|
@@ -811,40 +854,55 @@ class IPCClient {
|
|
|
811
854
|
reject(err);
|
|
812
855
|
});
|
|
813
856
|
sock.on("data", (buf) => {
|
|
857
|
+
if (!this.isCurrent(gen))
|
|
858
|
+
return;
|
|
814
859
|
this.onTransportData(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));
|
|
815
860
|
});
|
|
816
861
|
sock.on("close", () => {
|
|
862
|
+
if (!this.isCurrent(gen))
|
|
863
|
+
return;
|
|
817
864
|
this.onNetSocketClosed();
|
|
818
865
|
});
|
|
819
866
|
}
|
|
820
|
-
async connectUnix() {
|
|
867
|
+
async connectUnix(gen) {
|
|
821
868
|
if (HAS_BUN) {
|
|
822
|
-
await this.connectUnixBun();
|
|
869
|
+
await this.connectUnixBun(gen);
|
|
823
870
|
return;
|
|
824
871
|
}
|
|
825
|
-
await this.connectUnixNode();
|
|
872
|
+
await this.connectUnixNode(gen);
|
|
826
873
|
}
|
|
827
|
-
async connectUnixBun() {
|
|
828
|
-
|
|
874
|
+
async connectUnixBun(gen) {
|
|
875
|
+
const socket = await Bun.connect({
|
|
829
876
|
unix: this.socketPath,
|
|
830
877
|
socket: {
|
|
831
878
|
data: (_socket, chunk) => {
|
|
879
|
+
if (!this.isCurrent(gen))
|
|
880
|
+
return;
|
|
832
881
|
this.onTransportData(chunk);
|
|
833
882
|
},
|
|
834
883
|
close: () => {
|
|
884
|
+
if (!this.isCurrent(gen))
|
|
885
|
+
return;
|
|
835
886
|
this.onUnixClosed(new Error("IPC connection closed"));
|
|
836
887
|
},
|
|
837
888
|
error: () => {
|
|
889
|
+
if (!this.isCurrent(gen))
|
|
890
|
+
return;
|
|
838
891
|
this.onUnixClosed(new Error("IPC connection error"));
|
|
839
892
|
}
|
|
840
893
|
}
|
|
841
894
|
});
|
|
895
|
+
if (!this.isCurrent(gen)) {
|
|
896
|
+
socket.end();
|
|
897
|
+
throw supersededDial();
|
|
898
|
+
}
|
|
899
|
+
this.bunSocket = socket;
|
|
842
900
|
this.connected = true;
|
|
843
901
|
}
|
|
844
|
-
async connectUnixNode() {
|
|
902
|
+
async connectUnixNode(gen) {
|
|
845
903
|
await new Promise((resolve, reject) => {
|
|
846
904
|
const sock = import_node_net.default.createConnection({ path: this.socketPath });
|
|
847
|
-
this.attachNetSocket(sock, resolve, reject);
|
|
905
|
+
this.attachNetSocket(sock, gen, resolve, reject);
|
|
848
906
|
});
|
|
849
907
|
}
|
|
850
908
|
onTransportData(chunk) {
|
|
@@ -951,6 +1009,7 @@ class IPCClient {
|
|
|
951
1009
|
}
|
|
952
1010
|
disconnect() {
|
|
953
1011
|
this.connected = false;
|
|
1012
|
+
this.generation += 1;
|
|
954
1013
|
this.closeNotified = true;
|
|
955
1014
|
this.failAll(new Error("IPC disconnected"));
|
|
956
1015
|
this.endWindowsTransport();
|
|
@@ -1043,6 +1102,119 @@ class IPCClient {
|
|
|
1043
1102
|
this.pending.clear();
|
|
1044
1103
|
}
|
|
1045
1104
|
}
|
|
1105
|
+
|
|
1106
|
+
// src/ipc-proof.ts
|
|
1107
|
+
var SECRET_IPC_METHODS = new Set([
|
|
1108
|
+
"connector.auth",
|
|
1109
|
+
"vault.set",
|
|
1110
|
+
"vault.get",
|
|
1111
|
+
"extension.credentialSet",
|
|
1112
|
+
"toolgen.credentialSet",
|
|
1113
|
+
"toolgen.create",
|
|
1114
|
+
"scim.setToken",
|
|
1115
|
+
"teamvault.put",
|
|
1116
|
+
"clip.pair",
|
|
1117
|
+
"lan.openPairingWindow"
|
|
1118
|
+
]);
|
|
1119
|
+
var PROOF_LABEL_SERVER = "nimbus-ipc-v1/server";
|
|
1120
|
+
var PROOF_LABEL_CLIENT = "nimbus-ipc-v1/client";
|
|
1121
|
+
var HEX32 = /^[0-9a-f]{64}$/;
|
|
1122
|
+
function parseHex32(value) {
|
|
1123
|
+
if (typeof value !== "string" || !HEX32.test(value))
|
|
1124
|
+
return;
|
|
1125
|
+
return Uint8Array.from(Buffer.from(value, "hex"));
|
|
1126
|
+
}
|
|
1127
|
+
function toHex(bytes) {
|
|
1128
|
+
return Buffer.from(bytes).toString("hex");
|
|
1129
|
+
}
|
|
1130
|
+
function computeProof(key, label, clientNonce, serverNonce) {
|
|
1131
|
+
const mac = import_node_crypto2.createHmac("sha256", key);
|
|
1132
|
+
mac.update(Buffer.from(label, "utf8"));
|
|
1133
|
+
mac.update(Uint8Array.of(0));
|
|
1134
|
+
mac.update(clientNonce);
|
|
1135
|
+
mac.update(serverNonce);
|
|
1136
|
+
return Uint8Array.from(mac.digest());
|
|
1137
|
+
}
|
|
1138
|
+
function proofMatches(expected, received) {
|
|
1139
|
+
return expected.length === received.length && import_node_crypto2.timingSafeEqual(expected, received);
|
|
1140
|
+
}
|
|
1141
|
+
function proofKeyFileName(socketPath, platform) {
|
|
1142
|
+
const canonical = platform === "win32" ? socketPath.toLowerCase() : socketPath;
|
|
1143
|
+
const id = import_node_crypto2.createHash("sha256").update(canonical, "utf8").digest("hex").slice(0, 16);
|
|
1144
|
+
return `ipc-proof-${id}.key`;
|
|
1145
|
+
}
|
|
1146
|
+
var MESSAGES = {
|
|
1147
|
+
"key-missing": "Could not verify the Nimbus gateway: its proof key is missing or unreadable, so the secret was not sent. If the gateway was started by an older Nimbus, restart it (nimbus stop, then nimbus start). If the gateway keeps its data somewhere else, pass the keyPath option.",
|
|
1148
|
+
impostor: "Something other than your Nimbus gateway is answering on the gateway's socket. The secret was not sent and the connection was closed.",
|
|
1149
|
+
restarted: "The Nimbus gateway restarted while connecting. The secret was not sent and the connection was closed; reconnect (open a new client) and try again.",
|
|
1150
|
+
refused: "The Nimbus gateway refused the proof. The secret was not sent.",
|
|
1151
|
+
unavailable: 'The Nimbus gateway could not publish its proof key; its log says why, on a line starting "ipc proof: unavailable". The secret was not sent.',
|
|
1152
|
+
outdated: "The Nimbus gateway running now predates the proof, so the secret was not sent. Restart it (nimbus stop, then nimbus start).",
|
|
1153
|
+
"no-answer": "The process on the gateway's socket did not answer the proof in time. The secret was not sent and the connection was closed.",
|
|
1154
|
+
"connection-lost": "The connection to the Nimbus gateway closed during the proof. The secret was not sent."
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
class GatewayProofError extends Error {
|
|
1158
|
+
kind;
|
|
1159
|
+
constructor(kind) {
|
|
1160
|
+
super(MESSAGES[kind]);
|
|
1161
|
+
this.name = "GatewayProofError";
|
|
1162
|
+
this.kind = kind;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
var TIMED_OUT = Symbol("proof step timed out");
|
|
1166
|
+
async function proofStep(io, method, params, timeoutMs) {
|
|
1167
|
+
let timer;
|
|
1168
|
+
const timedOut = new Promise((resolve) => {
|
|
1169
|
+
timer = setTimeout(() => resolve(TIMED_OUT), timeoutMs);
|
|
1170
|
+
});
|
|
1171
|
+
let r;
|
|
1172
|
+
try {
|
|
1173
|
+
r = await Promise.race([io.call(method, params), timedOut]);
|
|
1174
|
+
} catch (e) {
|
|
1175
|
+
if (io.isTimeout(e))
|
|
1176
|
+
r = TIMED_OUT;
|
|
1177
|
+
else
|
|
1178
|
+
throw failureOf(e);
|
|
1179
|
+
} finally {
|
|
1180
|
+
clearTimeout(timer);
|
|
1181
|
+
}
|
|
1182
|
+
if (r === TIMED_OUT) {
|
|
1183
|
+
await io.disconnect();
|
|
1184
|
+
throw new GatewayProofError("no-answer");
|
|
1185
|
+
}
|
|
1186
|
+
return typeof r === "object" && r !== null ? r : undefined;
|
|
1187
|
+
}
|
|
1188
|
+
function failureOf(e) {
|
|
1189
|
+
if (!isJsonRpcError(e))
|
|
1190
|
+
return new GatewayProofError("connection-lost");
|
|
1191
|
+
if (e.code === -32601)
|
|
1192
|
+
return new GatewayProofError("outdated");
|
|
1193
|
+
if (e.message === "ERR_PROOF_UNAVAILABLE")
|
|
1194
|
+
return new GatewayProofError("unavailable");
|
|
1195
|
+
return new GatewayProofError("refused");
|
|
1196
|
+
}
|
|
1197
|
+
async function proveGateway(io, opts) {
|
|
1198
|
+
const key = io.readKey();
|
|
1199
|
+
if (key === undefined)
|
|
1200
|
+
throw new GatewayProofError("key-missing");
|
|
1201
|
+
const clientNonce = Uint8Array.from(import_node_crypto2.randomBytes(32));
|
|
1202
|
+
const reply = await proofStep(io, "session.prove", { clientNonce: toHex(clientNonce) }, opts.timeoutMs);
|
|
1203
|
+
const serverNonce = parseHex32(reply?.["serverNonce"]);
|
|
1204
|
+
const serverProof = parseHex32(reply?.["serverProof"]);
|
|
1205
|
+
if (serverNonce === undefined || serverProof === undefined || !proofMatches(computeProof(key, PROOF_LABEL_SERVER, clientNonce, serverNonce), serverProof)) {
|
|
1206
|
+
await io.disconnect();
|
|
1207
|
+
const again = io.readKey();
|
|
1208
|
+
if (again !== undefined && !proofMatches(again, key)) {
|
|
1209
|
+
throw new GatewayProofError("restarted");
|
|
1210
|
+
}
|
|
1211
|
+
throw new GatewayProofError("impostor");
|
|
1212
|
+
}
|
|
1213
|
+
const clientProof = toHex(computeProof(key, PROOF_LABEL_CLIENT, clientNonce, serverNonce));
|
|
1214
|
+
const done = await proofStep(io, "session.proveClient", { clientProof }, opts.timeoutMs);
|
|
1215
|
+
if (done?.["proven"] !== true)
|
|
1216
|
+
throw new GatewayProofError("refused");
|
|
1217
|
+
}
|
|
1046
1218
|
// src/event-queue.ts
|
|
1047
1219
|
function createEventQueue() {
|
|
1048
1220
|
const buffer = [];
|
|
@@ -1259,6 +1431,78 @@ function createAskStream(ipc, input, opts = {}) {
|
|
|
1259
1431
|
return handle;
|
|
1260
1432
|
}
|
|
1261
1433
|
|
|
1434
|
+
// src/proving-ipc-client.ts
|
|
1435
|
+
var import_node_fs2 = require("node:fs");
|
|
1436
|
+
var import_node_path3 = require("node:path");
|
|
1437
|
+
var DEFAULT_PROOF_TIMEOUT_MS = 1e4;
|
|
1438
|
+
|
|
1439
|
+
class ProvingIPCClient extends IPCClient {
|
|
1440
|
+
proofSocketPath;
|
|
1441
|
+
keyPathOption;
|
|
1442
|
+
resolveDataDir;
|
|
1443
|
+
proofTimeoutMs;
|
|
1444
|
+
proof;
|
|
1445
|
+
proofGeneration = -1;
|
|
1446
|
+
constructor(socketPath, opts = {}) {
|
|
1447
|
+
const { keyPath, proofTimeoutMs, resolveDataDir, ...base } = opts;
|
|
1448
|
+
super(socketPath, base);
|
|
1449
|
+
this.proofSocketPath = socketPath;
|
|
1450
|
+
this.keyPathOption = keyPath;
|
|
1451
|
+
this.resolveDataDir = resolveDataDir ?? (() => getNimbusPaths().dataDir);
|
|
1452
|
+
this.proofTimeoutMs = proofTimeoutMs ?? DEFAULT_PROOF_TIMEOUT_MS;
|
|
1453
|
+
this.onClose(() => {
|
|
1454
|
+
this.proof = undefined;
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
async call(method, params) {
|
|
1458
|
+
if (SECRET_IPC_METHODS.has(method) && this.transportConnected) {
|
|
1459
|
+
await this.ensureProven();
|
|
1460
|
+
}
|
|
1461
|
+
return super.call(method, params);
|
|
1462
|
+
}
|
|
1463
|
+
async disconnect() {
|
|
1464
|
+
this.proof = undefined;
|
|
1465
|
+
await super.disconnect();
|
|
1466
|
+
}
|
|
1467
|
+
ensureProven() {
|
|
1468
|
+
if (this.proof !== undefined && this.proofGeneration !== this.transportGeneration) {
|
|
1469
|
+
this.proof = undefined;
|
|
1470
|
+
}
|
|
1471
|
+
if (this.proof === undefined) {
|
|
1472
|
+
this.proofGeneration = this.transportGeneration;
|
|
1473
|
+
const attempt = this.runProof();
|
|
1474
|
+
this.proof = attempt;
|
|
1475
|
+
attempt.catch(() => {
|
|
1476
|
+
if (this.proof === attempt)
|
|
1477
|
+
this.proof = undefined;
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
return this.proof;
|
|
1481
|
+
}
|
|
1482
|
+
runProof() {
|
|
1483
|
+
const generation = this.transportGeneration;
|
|
1484
|
+
return proveGateway({
|
|
1485
|
+
call: (method, params) => super.call(method, params),
|
|
1486
|
+
readKey: () => this.readKey(),
|
|
1487
|
+
disconnect: async () => {
|
|
1488
|
+
if (this.transportGeneration !== generation)
|
|
1489
|
+
return;
|
|
1490
|
+
this.proof = undefined;
|
|
1491
|
+
this.abortConnection(new Error("IPC connection closed: the gateway proof failed"));
|
|
1492
|
+
},
|
|
1493
|
+
isTimeout: (e) => e instanceof Error && e.message.startsWith("IPC request timed out")
|
|
1494
|
+
}, { timeoutMs: this.proofTimeoutMs });
|
|
1495
|
+
}
|
|
1496
|
+
readKey() {
|
|
1497
|
+
try {
|
|
1498
|
+
const path = this.keyPathOption ?? import_node_path3.join(this.resolveDataDir(), proofKeyFileName(this.proofSocketPath, process.platform));
|
|
1499
|
+
return parseHex32(import_node_fs2.readFileSync(path, "utf8"));
|
|
1500
|
+
} catch {
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1262
1506
|
// src/validate.ts
|
|
1263
1507
|
class IpcResponseError extends Error {
|
|
1264
1508
|
constructor(method, detail) {
|
|
@@ -2249,7 +2493,7 @@ function validateWhyPeek(method, v) {
|
|
|
2249
2493
|
}
|
|
2250
2494
|
|
|
2251
2495
|
// src/workflow-stream.ts
|
|
2252
|
-
var
|
|
2496
|
+
var import_node_crypto3 = require("node:crypto");
|
|
2253
2497
|
function workflowRunWireParams(params) {
|
|
2254
2498
|
return {
|
|
2255
2499
|
name: params.name,
|
|
@@ -2265,7 +2509,7 @@ function workflowRunWireParams(params) {
|
|
|
2265
2509
|
function createWorkflowRunStream(ipc, params, validate) {
|
|
2266
2510
|
const events = createEventQueue();
|
|
2267
2511
|
let detach;
|
|
2268
|
-
const streamId = params.streamId ??
|
|
2512
|
+
const streamId = params.streamId ?? import_node_crypto3.randomUUID();
|
|
2269
2513
|
const finish = () => {
|
|
2270
2514
|
events.close(() => {
|
|
2271
2515
|
detach?.();
|
|
@@ -2368,8 +2612,9 @@ class NimbusClient {
|
|
|
2368
2612
|
this.ipc = ipc;
|
|
2369
2613
|
}
|
|
2370
2614
|
static async open(opts) {
|
|
2371
|
-
const ipc = new
|
|
2372
|
-
...opts.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: opts.requestTimeoutMs }
|
|
2615
|
+
const ipc = new ProvingIPCClient(opts.socketPath, {
|
|
2616
|
+
...opts.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: opts.requestTimeoutMs },
|
|
2617
|
+
...opts.keyPath === undefined ? {} : { keyPath: opts.keyPath }
|
|
2373
2618
|
});
|
|
2374
2619
|
await ipc.connect();
|
|
2375
2620
|
return new NimbusClient(ipc);
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
export type { AgentBrief, AgentName, BriefFor, CatchupBrief, ConflictBrief, ExpertBrief, GhostBrief, HuddleBrief, ImpactBrief, JanitorBrief, NimbusItem, PreflightBrief, WhyBrief, WhyFinding, WhyLane, WhyPeek, WhySubject, } from "@nimbus-dev/sdk";
|
|
5
5
|
export { AgentBriefError, type AgentBriefEvent, type AgentParamsFor, AgentTimeoutError, type CatchupParams, type ConflictsParams, DEFAULT_AGENT_TIMEOUT_MS, type ExpertParams, type GhostParams, type HuddleParams, type ImpactParams, type JanitorParams, type PreflightParams, type WhyParams, } from "./agents.js";
|
|
6
6
|
export { discoverSocketPath, type GatewayStateFile, gatewayStatePath, readGatewayState, type SocketDiscoveryResult, } from "./discovery.js";
|
|
7
|
+
export { computeProof, GatewayProofError, type GatewayProofErrorKind, PROOF_LABEL_CLIENT, PROOF_LABEL_SERVER, parseHex32, proofKeyFileName, SECRET_IPC_METHODS, } from "./ipc-proof.js";
|
|
7
8
|
export { IPCClient, type IPCClientOptions, isJsonRpcError, JsonRpcError, jsonRpcErrorCode, jsonRpcErrorData, } from "./ipc-transport.js";
|
|
8
9
|
export { MockClient, type MockClientFixtures } from "./mock-client.js";
|
|
9
10
|
export { type AuditStatus, type AuditSummary, type AuditToolCallsParams, type AuditToolCallsResult, type AuditVerifyParams, type AuditVerifyResult, type CiFinding, CONSENT_ANSWER_SOURCES, type ConnectorAddMcpParams, type ConnectorAddMcpResult, type ConnectorAuthParams, type ConnectorAuthResult, type ConnectorConfigChanged, type ConnectorHealthEntry, type ConnectorHealthHistoryEntry, type ConnectorHealthHistoryParams, type ConnectorReindexParams, type ConnectorReindexResult, type ConnectorRemoveParams, type ConnectorRemoveResult, type ConnectorServiceParams, type ConnectorSetConfigParams, type ConnectorSetConfigResult, type ConnectorSetIntervalParams, type ConnectorStatus, type ConnectorStatusParams, type ConnectorStatusResult, type ConnectorSyncParams, type ConnectorSyncStatus, type ConnectorSyncTelemetry, type ConsentAnswerSource, type ConsentRespondParams, type DeployPreflightParams, type DeployPreflightResult, type DiagSnapshot, type DiagVersion, type DoraGap, type DoraMetricsResult, type DoraMetricValue, EGRESS_COVERAGE_CLASSES, EGRESS_GRANULARITIES, type EgressCompleteness, type EgressCoverageClass, type EgressCoverageVector, type EgressGranularity, type EgressHead, type EgressListParams, type EgressListResult, type EgressProveWindowParams, type EgressProveWindowResult, type EgressReceipt, type EgressRow, type EgressVerifyResult, type GatedRejection, type GatewayPingResult, type GatewayStatus, type HitlStatusCounts, type IdentityStatus, type IncidentFinding, type IndexedItem, type IndexMetrics, type MetricsDoraParams, type NamespaceStatus, NimbusClient, type NimbusClientLike, type NimbusClientOptions, NO_EGRESS_COVERAGE, type PeerStatus, type PolicySource, type PolicyState, type PreflightCheck, type PreflightGap, type PrFinding, type RankedSearchItem, type RankedSearchParams, type RankedSearchWithRetrieval, type SandboxDiag, type SearchRetrieval, type SearchRetrievalReason, type SessionAppendParams, type SessionClearParams, type SessionClearResult, type SessionListEntry, type SessionListResult, type SessionMemoryRole, type SessionRecallHit, type SessionRecallParams, type SessionRecallResult, type SessionTranscript, type ToolCallLogEntry, type WatcherSummary, type WorkflowCancelParams, type WorkflowCancelResult, type WorkflowDeleteParams, type WorkflowListResult, type WorkflowListRunsParams, type WorkflowListRunsResult, type WorkflowRow, type WorkflowRunHistoryRow, type WorkflowRunParams, type WorkflowRunResult, type WorkflowSaveParams, type WorkflowStepResult, } from "./nimbus-client.js";
|
|
10
11
|
export { getNimbusPaths, type NimbusPaths } from "./paths.js";
|
|
12
|
+
export { ProvingIPCClient, type ProvingIPCClientOptions } from "./proving-ipc-client.js";
|
|
11
13
|
export type { AskStreamHandle, AskStreamOptions, HitlRequest, StreamEvent, WorkflowRunEvent, WorkflowRunStreamHandle, WorkflowRunStreamParams, } from "./stream-events.js";
|
|
12
14
|
export { IpcResponseError } from "./validate.js";
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,YAAY,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,OAAO,EACP,OAAO,EACP,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B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K,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,YAAY,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,OAAO,EACP,OAAO,EACP,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,wBAAwB,EACxB,KAAK,YAAY,E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,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzF,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { AgentBriefError, AgentTimeoutError, DEFAULT_AGENT_TIMEOUT_MS, } from "./agents.js";
|
|
5
5
|
export { discoverSocketPath, gatewayStatePath, readGatewayState, } from "./discovery.js";
|
|
6
|
+
export { computeProof, GatewayProofError, PROOF_LABEL_CLIENT, PROOF_LABEL_SERVER, parseHex32, proofKeyFileName, SECRET_IPC_METHODS, } from "./ipc-proof.js";
|
|
6
7
|
export { IPCClient, isJsonRpcError, JsonRpcError, jsonRpcErrorCode, jsonRpcErrorData, } from "./ipc-transport.js";
|
|
7
8
|
export { MockClient } from "./mock-client.js";
|
|
8
9
|
export { CONSENT_ANSWER_SOURCES, EGRESS_COVERAGE_CLASSES, EGRESS_GRANULARITIES, NimbusClient, NO_EGRESS_COVERAGE, } from "./nimbus-client.js";
|
|
9
10
|
export { getNimbusPaths } from "./paths.js";
|
|
11
|
+
export { ProvingIPCClient } from "./proving-ipc-client.js";
|
|
10
12
|
export { IpcResponseError } from "./validate.js";
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuBH,OAAO,EACL,eAAe,EAGf,iBAAiB,EAGjB,wBAAwB,GAQzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAElB,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EAET,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAA2B,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAQL,sBAAsB,EAgCtB,uBAAuB,EACvB,oBAAoB,EAuBpB,YAAY,EAGZ,kBAAkB,GAqCnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAoB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuBH,OAAO,EACL,eAAe,EAGf,iBAAiB,EAGjB,wBAAwB,GAQzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAElB,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,iBAAiB,EAEjB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EAET,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAA2B,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAQL,sBAAsB,EAgCtB,uBAAuB,EACvB,oBAAoB,EAuBpB,YAAY,EAGZ,kBAAkB,GAqCnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAoB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAgC,MAAM,yBAAyB,CAAC;AAUzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** IPC methods that carry a secret in their params or their result (the gateway's list). */
|
|
2
|
+
export declare const SECRET_IPC_METHODS: ReadonlySet<string>;
|
|
3
|
+
export declare const PROOF_LABEL_SERVER = "nimbus-ipc-v1/server";
|
|
4
|
+
export declare const PROOF_LABEL_CLIENT = "nimbus-ipc-v1/client";
|
|
5
|
+
/** Exactly 64 lowercase hex characters → 32 bytes; anything else (any type) → `undefined`. */
|
|
6
|
+
export declare function parseHex32(value: unknown): Uint8Array | undefined;
|
|
7
|
+
export declare function computeProof(key: Uint8Array, label: string, clientNonce: Uint8Array, serverNonce: Uint8Array): Uint8Array;
|
|
8
|
+
/** Constant-time equality (`timingSafeEqual`); unequal lengths are simply unequal. */
|
|
9
|
+
export declare function proofMatches(expected: Uint8Array, received: Uint8Array): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The key file's name for one socket: `ipc-proof-<16 hex of SHA-256(socket path)>.key`, the path
|
|
12
|
+
* lower-cased on Windows (pipe names are case-insensitive).
|
|
13
|
+
*/
|
|
14
|
+
export declare function proofKeyFileName(socketPath: string, platform: NodeJS.Platform): string;
|
|
15
|
+
export type GatewayProofErrorKind = "key-missing" | "impostor" | "restarted" | "refused" | "unavailable" | "outdated" | "no-answer" | "connection-lost";
|
|
16
|
+
/** Why a proof failed; `kind` names the cause, the message the fix. */
|
|
17
|
+
export declare class GatewayProofError extends Error {
|
|
18
|
+
readonly kind: GatewayProofErrorKind;
|
|
19
|
+
constructor(kind: GatewayProofErrorKind);
|
|
20
|
+
}
|
|
21
|
+
/** What {@link proveGateway} needs from one connection. */
|
|
22
|
+
export type ProofIo = {
|
|
23
|
+
/** Sends one request on the connection being proven. */
|
|
24
|
+
readonly call: (method: string, params: unknown) => Promise<unknown>;
|
|
25
|
+
/** Reads the key file fresh; `undefined` when it is missing or malformed. */
|
|
26
|
+
readonly readKey: () => Uint8Array | undefined;
|
|
27
|
+
/** Closes the connection being proven (after an impostor, a restart or no answer). */
|
|
28
|
+
readonly disconnect: () => Promise<void>;
|
|
29
|
+
/** Whether a transport error is the caller's own request timeout firing. */
|
|
30
|
+
readonly isTimeout: (e: unknown) => boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Proves the gateway on one connection (S1's two steps), or throws {@link GatewayProofError}.
|
|
34
|
+
* Nothing is sent without a key; a gateway whose server proof does not match is disconnected
|
|
35
|
+
* before anything else happens.
|
|
36
|
+
*/
|
|
37
|
+
export declare function proveGateway(io: ProofIo, opts: {
|
|
38
|
+
timeoutMs: number;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
//# sourceMappingURL=ipc-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipc-proof.d.ts","sourceRoot":"","sources":["../src/ipc-proof.ts"],"names":[],"mappings":"AAgBA,4FAA4F;AAC5F,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAWjD,CAAC;AAEH,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AACzD,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AAIzD,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAGjE;AAMD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,UAAU,EACvB,WAAW,EAAE,UAAU,GACtB,UAAU,CAOZ;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAEhF;AAED;;;GAGG;AACH,wBAAgB,gBAAg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