@brud/daemon 0.0.0-stage → 0.0.1

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.
Files changed (61) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +67 -2
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.js +88 -0
  5. package/dist/client/DaemonClient.d.ts +55 -0
  6. package/dist/client/DaemonClient.js +383 -0
  7. package/dist/client/connectToDaemon.d.ts +19 -0
  8. package/dist/client/connectToDaemon.js +131 -0
  9. package/dist/client/errors.d.ts +74 -0
  10. package/dist/client/errors.js +104 -0
  11. package/dist/client/identity.d.ts +3 -0
  12. package/dist/client/identity.js +7 -0
  13. package/dist/client/index.d.ts +6 -0
  14. package/dist/client/index.js +23 -0
  15. package/dist/client/socket.d.ts +9 -0
  16. package/dist/client/socket.js +101 -0
  17. package/dist/client/spawn.d.ts +7 -0
  18. package/dist/client/spawn.js +171 -0
  19. package/dist/index.d.ts +12 -0
  20. package/dist/index.js +29 -0
  21. package/dist/instanceRegistry.d.ts +130 -0
  22. package/dist/instanceRegistry.js +332 -0
  23. package/dist/lifecycle/endpoint.d.ts +19 -0
  24. package/dist/lifecycle/endpoint.js +124 -0
  25. package/dist/lifecycle/idle.d.ts +28 -0
  26. package/dist/lifecycle/idle.js +69 -0
  27. package/dist/lifecycle/index.d.ts +4 -0
  28. package/dist/lifecycle/index.js +21 -0
  29. package/dist/lifecycle/lock.d.ts +28 -0
  30. package/dist/lifecycle/lock.js +155 -0
  31. package/dist/lifecycle/shutdown.d.ts +39 -0
  32. package/dist/lifecycle/shutdown.js +115 -0
  33. package/dist/operatorConfig.d.ts +36 -0
  34. package/dist/operatorConfig.js +92 -0
  35. package/dist/security/channel.d.ts +113 -0
  36. package/dist/security/channel.js +448 -0
  37. package/dist/security/noise.d.ts +64 -0
  38. package/dist/security/noise.js +313 -0
  39. package/dist/security/ownership.d.ts +36 -0
  40. package/dist/security/ownership.js +86 -0
  41. package/dist/security/peerCredentials.d.ts +104 -0
  42. package/dist/security/peerCredentials.js +244 -0
  43. package/dist/server/Connection.d.ts +70 -0
  44. package/dist/server/Connection.js +412 -0
  45. package/dist/server/DaemonServer.d.ts +77 -0
  46. package/dist/server/DaemonServer.js +396 -0
  47. package/dist/server/createDaemon.d.ts +52 -0
  48. package/dist/server/createDaemon.js +165 -0
  49. package/dist/server/dispatch.d.ts +52 -0
  50. package/dist/server/dispatch.js +291 -0
  51. package/dist/server/framing.d.ts +63 -0
  52. package/dist/server/framing.js +196 -0
  53. package/dist/server/handshake.d.ts +22 -0
  54. package/dist/server/handshake.js +94 -0
  55. package/dist/server/protocolValidation.d.ts +47 -0
  56. package/dist/server/protocolValidation.js +366 -0
  57. package/dist/server/wireErrors.d.ts +5 -0
  58. package/dist/server/wireErrors.js +190 -0
  59. package/dist/version.d.ts +2 -0
  60. package/dist/version.js +6 -0
  61. package/package.json +55 -4
@@ -0,0 +1,448 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SecureChannel = exports.RECORD_ERROR = exports.RECORD_SUCCESS = exports.RECORD_NOTIFICATION = exports.RECORD_REQUEST = exports.CHANNEL_PROLOGUE_PREFIX = exports.DEFAULT_HANDSHAKE_TIMEOUT_MS = exports.MAX_RECORD_PLAINTEXT_BYTES = exports.MAX_HANDSHAKE_BYTES = void 0;
4
+ exports.channelPrologue = channelPrologue;
5
+ const node_buffer_1 = require("node:buffer");
6
+ const noise_js_1 = require("./noise.js");
7
+ /** Hard ceiling for one Noise handshake message. */
8
+ exports.MAX_HANDSHAKE_BYTES = 8 * 1024;
9
+ /** Hard ceiling for one encrypted transport record's plaintext. */
10
+ exports.MAX_RECORD_PLAINTEXT_BYTES = 8 * 1024 * 1024;
11
+ /** Default deadline for completing the Noise handshake. */
12
+ exports.DEFAULT_HANDSHAKE_TIMEOUT_MS = 10_000;
13
+ const TAGLEN = 16;
14
+ const MAX_RECORD_BYTES = 1 + exports.MAX_RECORD_PLAINTEXT_BYTES + TAGLEN;
15
+ /** Constant channel-binding prefix mixed into every Noise prologue. */
16
+ exports.CHANNEL_PROLOGUE_PREFIX = 'brud-daemon-channel-v1';
17
+ /** Binds a handshake to the endpoint both parties believe they are using. */
18
+ function channelPrologue(socketPath) {
19
+ return node_buffer_1.Buffer.from(`${exports.CHANNEL_PROLOGUE_PREFIX}\0${socketPath}`, 'utf8');
20
+ }
21
+ /**
22
+ * Record type, authenticated as the AEAD associated data.
23
+ *
24
+ * Direction separation comes from the two Noise cipher states; type
25
+ * separation comes from this byte. A record reflected with a different type
26
+ * fails authentication.
27
+ */
28
+ exports.RECORD_REQUEST = 1;
29
+ exports.RECORD_NOTIFICATION = 2;
30
+ exports.RECORD_SUCCESS = 3;
31
+ exports.RECORD_ERROR = 4;
32
+ const RECORD_TYPES = new Set([
33
+ exports.RECORD_REQUEST,
34
+ exports.RECORD_NOTIFICATION,
35
+ exports.RECORD_SUCCESS,
36
+ exports.RECORD_ERROR,
37
+ ]);
38
+ function isRecord(value) {
39
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
40
+ }
41
+ function parseHandshakePayload(text) {
42
+ const value = JSON.parse(text);
43
+ if (!isRecord(value) || value.v !== 1) {
44
+ throw new Error('Invalid handshake payload version');
45
+ }
46
+ const principal = value.principal;
47
+ const home = value.home;
48
+ if (principal !== 'ui' && principal !== 'ai') {
49
+ throw new Error('Invalid handshake principal');
50
+ }
51
+ if (typeof home !== 'string' || home.length === 0) {
52
+ throw new Error('Invalid handshake daemon home');
53
+ }
54
+ const clientInfo = parseIdentity(value.clientInfo);
55
+ const capabilities = Array.isArray(value.capabilities)
56
+ ? value.capabilities.filter((entry) => typeof entry === 'string')
57
+ : undefined;
58
+ return {
59
+ v: 1,
60
+ principal,
61
+ home,
62
+ ...(clientInfo === undefined ? {} : { clientInfo }),
63
+ ...(capabilities === undefined ? {} : { capabilities }),
64
+ };
65
+ }
66
+ function parseServerPayload(text) {
67
+ const value = JSON.parse(text);
68
+ if (!isRecord(value) || value.v !== 1) {
69
+ throw new Error('Invalid server handshake payload');
70
+ }
71
+ const server = value.server;
72
+ if (!isRecord(server)
73
+ || typeof server.name !== 'string'
74
+ || typeof server.version !== 'string'
75
+ || typeof server.pid !== 'number'
76
+ || !Number.isInteger(server.pid)) {
77
+ throw new Error('Invalid server identity payload');
78
+ }
79
+ return {
80
+ v: 1,
81
+ server: { name: server.name, version: server.version, pid: server.pid },
82
+ };
83
+ }
84
+ function parseIdentity(value) {
85
+ if (!isRecord(value) || typeof value.name !== 'string' || typeof value.version !== 'string') {
86
+ return undefined;
87
+ }
88
+ return { name: value.name, version: value.version };
89
+ }
90
+ function encodeHandshakeFrame(message) {
91
+ if (message.length > exports.MAX_HANDSHAKE_BYTES) {
92
+ throw new Error('Noise handshake message exceeds the size limit');
93
+ }
94
+ const frame = node_buffer_1.Buffer.allocUnsafe(4 + message.length);
95
+ frame.writeUInt32BE(message.length, 0);
96
+ message.copy(frame, 4);
97
+ return frame;
98
+ }
99
+ function classifyMessage(message) {
100
+ if (isRecord(message) && typeof message.method === 'string') {
101
+ return 'id' in message ? exports.RECORD_REQUEST : exports.RECORD_NOTIFICATION;
102
+ }
103
+ if (isRecord(message) && 'error' in message) {
104
+ return exports.RECORD_ERROR;
105
+ }
106
+ return exports.RECORD_SUCCESS;
107
+ }
108
+ /**
109
+ * Authenticated, AEAD-protected record channel over one local socket.
110
+ *
111
+ * The handshake is two Noise NNpsk0 messages; every message after it is a
112
+ * length-prefixed record whose type is bound into the AEAD associated data.
113
+ * Authentication failure, nonce reuse, a replayed record, or an invalid
114
+ * record shape destroys the connection: there is no fallback to plaintext.
115
+ */
116
+ class SecureChannel {
117
+ socket;
118
+ options;
119
+ maxRecordBytes;
120
+ sendState;
121
+ receiveState;
122
+ handshakeHash;
123
+ buffer = node_buffer_1.Buffer.alloc(0);
124
+ phase = 'handshaking';
125
+ messageListener;
126
+ closeListener;
127
+ handshakeTimer;
128
+ resolveHandshake;
129
+ rejectHandshake;
130
+ handshakeDone;
131
+ handshakeResolved = false;
132
+ constructor(socket, options) {
133
+ this.socket = socket;
134
+ this.options = options;
135
+ this.maxRecordBytes = Math.min(options.maxRecordBytes ?? MAX_RECORD_BYTES, MAX_RECORD_BYTES);
136
+ this.handshakeDone = new Promise((resolve, reject) => {
137
+ this.resolveHandshake = resolve;
138
+ this.rejectHandshake = reject;
139
+ });
140
+ this.handshakeDone.catch(() => undefined);
141
+ socket.setNoDelay(true);
142
+ socket.on('data', (chunk) => {
143
+ this.onData(chunk);
144
+ });
145
+ socket.on('error', () => {
146
+ this.fail(new Error('Secure channel socket error'));
147
+ });
148
+ socket.on('close', () => {
149
+ this.fail(new Error('Secure channel closed'));
150
+ });
151
+ }
152
+ static async connect(socket, options) {
153
+ const channel = new SecureChannel(socket, options);
154
+ const handshake = new noise_js_1.NoiseHandshake({
155
+ role: 'initiator',
156
+ psk: options.psk,
157
+ prologue: options.prologue,
158
+ });
159
+ const payload = node_buffer_1.Buffer.from(JSON.stringify({
160
+ v: 1,
161
+ principal: options.context.principal,
162
+ home: options.context.home,
163
+ ...(options.context.clientInfo === undefined
164
+ ? {}
165
+ : { clientInfo: options.context.clientInfo }),
166
+ ...(options.context.capabilities === undefined
167
+ ? {}
168
+ : { capabilities: options.context.capabilities }),
169
+ }), 'utf8');
170
+ channel.beginHandshakeTimeout();
171
+ channel.writeRaw(encodeHandshakeFrame(handshake.writeMessage(payload)));
172
+ try {
173
+ const result = await channel.handshakeDone;
174
+ timerClear(channel.handshakeTimer);
175
+ channel.handshakeTimer = undefined;
176
+ if (channel.isClosed) {
177
+ throw new Error('Secure channel closed during the handshake');
178
+ }
179
+ const serverPayload = handshake.readMessage(result.serverPayload);
180
+ channel.installTransport(result, handshake);
181
+ return {
182
+ channel,
183
+ server: parseServerPayload(serverPayload.toString('utf8')).server,
184
+ };
185
+ }
186
+ catch (error) {
187
+ channel.destroy();
188
+ throw error instanceof Error ? error : new Error(String(error));
189
+ }
190
+ }
191
+ static async accept(socket, options) {
192
+ const channel = new SecureChannel(socket, options);
193
+ const serverPayload = node_buffer_1.Buffer.from(JSON.stringify({
194
+ v: 1,
195
+ server: options.server,
196
+ }), 'utf8');
197
+ channel.beginHandshakeTimeout();
198
+ try {
199
+ const result = await channel.handshakeDone;
200
+ const first = result.firstHandshakeMessage;
201
+ if (channel.isClosed || first === undefined) {
202
+ throw new Error('Noise initiator message is missing');
203
+ }
204
+ let accepted;
205
+ for (const candidate of options.psks) {
206
+ try {
207
+ const handshake = new noise_js_1.NoiseHandshake({
208
+ role: 'responder',
209
+ psk: candidate.psk,
210
+ prologue: options.prologue,
211
+ });
212
+ const plaintext = handshake.readMessage(first);
213
+ const payload = parseHandshakePayload(plaintext.toString('utf8'));
214
+ if (payload.principal !== candidate.principal) {
215
+ continue;
216
+ }
217
+ options.validateHome(payload.home);
218
+ accepted = { handshake, context: payload };
219
+ break;
220
+ }
221
+ catch {
222
+ continue;
223
+ }
224
+ }
225
+ if (accepted === undefined) {
226
+ throw new Error('Noise handshake authentication failed');
227
+ }
228
+ channel.writeRaw(encodeHandshakeFrame(accepted.handshake.writeMessage(serverPayload)));
229
+ timerClear(channel.handshakeTimer);
230
+ channel.handshakeTimer = undefined;
231
+ channel.installTransport({ firstHandshakeMessage: undefined, serverPayload: node_buffer_1.Buffer.alloc(0) }, accepted.handshake);
232
+ return { channel, context: accepted.context };
233
+ }
234
+ catch (error) {
235
+ channel.destroy();
236
+ throw error instanceof Error ? error : new Error(String(error));
237
+ }
238
+ }
239
+ onMessage(listener) {
240
+ this.messageListener = listener;
241
+ }
242
+ onClose(listener) {
243
+ this.closeListener = listener;
244
+ }
245
+ get isClosed() {
246
+ return this.phase === 'closed';
247
+ }
248
+ get binding() {
249
+ return this.handshakeHash === undefined ? undefined : node_buffer_1.Buffer.from(this.handshakeHash);
250
+ }
251
+ send(message) {
252
+ this.sendTyped(classifyMessage(message), JSON.stringify(message));
253
+ }
254
+ /**
255
+ * Sends raw JSON text of a chosen type through the real encryption path.
256
+ *
257
+ * Test clients use this to inject malformed or hostile plaintext after the
258
+ * handshake; the daemon's post-decryption validation is still the real path.
259
+ */
260
+ sendRaw(text, type = exports.RECORD_REQUEST) {
261
+ this.sendTyped(type, text);
262
+ }
263
+ end() {
264
+ if (this.phase === 'closed') {
265
+ return;
266
+ }
267
+ this.phase = 'closed';
268
+ timerClear(this.handshakeTimer);
269
+ this.handshakeTimer = undefined;
270
+ this.socket.end();
271
+ this.socket.destroy();
272
+ this.notifyClose();
273
+ }
274
+ destroy() {
275
+ if (this.phase === 'closed') {
276
+ return;
277
+ }
278
+ this.phase = 'closed';
279
+ timerClear(this.handshakeTimer);
280
+ this.handshakeTimer = undefined;
281
+ this.socket.destroy();
282
+ this.notifyClose();
283
+ }
284
+ sendTyped(type, text) {
285
+ if (this.phase !== 'open' || this.sendState === undefined) {
286
+ throw new Error('Secure channel is not open');
287
+ }
288
+ const plaintext = node_buffer_1.Buffer.from(text, 'utf8');
289
+ if (plaintext.length > exports.MAX_RECORD_PLAINTEXT_BYTES) {
290
+ throw new Error('Record plaintext exceeds the size limit');
291
+ }
292
+ const ciphertext = this.sendState.encrypt(node_buffer_1.Buffer.from([type]), plaintext);
293
+ const frame = node_buffer_1.Buffer.allocUnsafe(4 + 1 + ciphertext.length);
294
+ frame.writeUInt32BE(1 + ciphertext.length, 0);
295
+ frame.writeUInt8(type, 4);
296
+ ciphertext.copy(frame, 5);
297
+ this.writeRaw(frame);
298
+ }
299
+ beginHandshakeTimeout() {
300
+ const timeoutMs = this.options.handshakeTimeoutMs ?? exports.DEFAULT_HANDSHAKE_TIMEOUT_MS;
301
+ this.handshakeTimer = setTimeout(() => {
302
+ this.fail(new Error(`Noise handshake timed out after ${timeoutMs} ms`));
303
+ }, timeoutMs);
304
+ this.handshakeTimer.unref?.();
305
+ }
306
+ installTransport(result, handshake) {
307
+ if (this.phase === 'closed') {
308
+ throw new Error('Secure channel closed during the handshake');
309
+ }
310
+ const transport = handshake.split();
311
+ this.sendState = transport.send;
312
+ this.receiveState = transport.receive;
313
+ this.handshakeHash = transport.handshakeHash;
314
+ this.phase = 'open';
315
+ this.handshakeResolved = false;
316
+ this.resolveHandshake?.(result);
317
+ this.resolveHandshake = undefined;
318
+ this.rejectHandshake = undefined;
319
+ // A peer may have pipelined a transport record into the same chunk as the
320
+ // final handshake message. Pump it now that the keys are installed.
321
+ this.pump();
322
+ }
323
+ onData(chunk) {
324
+ if (this.phase === 'closed') {
325
+ return;
326
+ }
327
+ if (this.buffer.length + chunk.length > this.maxBufferBytes()) {
328
+ this.fail(new Error('Secure channel buffer limit exceeded'));
329
+ return;
330
+ }
331
+ this.buffer = this.buffer.length === 0 ? chunk : node_buffer_1.Buffer.concat([this.buffer, chunk]);
332
+ this.pump();
333
+ }
334
+ maxBufferBytes() {
335
+ const frameLimit = this.phase === 'handshaking'
336
+ ? exports.MAX_HANDSHAKE_BYTES
337
+ : this.maxRecordBytes;
338
+ return frameLimit + 4;
339
+ }
340
+ pump() {
341
+ for (;;) {
342
+ if (this.phase === 'closed' || this.handshakeResolved) {
343
+ return;
344
+ }
345
+ if (this.buffer.length < 4) {
346
+ return;
347
+ }
348
+ const length = this.buffer.readUInt32BE(0);
349
+ if (this.phase === 'handshaking') {
350
+ if (length === 0 || length > exports.MAX_HANDSHAKE_BYTES) {
351
+ this.fail(new Error('Invalid Noise handshake frame length'));
352
+ return;
353
+ }
354
+ if (this.buffer.length < 4 + length) {
355
+ return;
356
+ }
357
+ const message = node_buffer_1.Buffer.from(this.buffer.subarray(4, 4 + length));
358
+ this.buffer = this.buffer.subarray(4 + length);
359
+ this.deliverHandshakeMessage(message);
360
+ continue;
361
+ }
362
+ if (length < 1 + TAGLEN || length > this.maxRecordBytes) {
363
+ this.fail(new Error('Invalid encrypted record length'));
364
+ return;
365
+ }
366
+ if (this.buffer.length < 4 + length) {
367
+ return;
368
+ }
369
+ const type = this.buffer.readUInt8(4);
370
+ const ciphertext = node_buffer_1.Buffer.from(this.buffer.subarray(5, 4 + length));
371
+ this.buffer = this.buffer.subarray(4 + length);
372
+ if (!RECORD_TYPES.has(type)) {
373
+ this.fail(new Error(`Unknown record type ${String(type)}`));
374
+ return;
375
+ }
376
+ if (this.receiveState === undefined) {
377
+ this.fail(new Error('Encrypted record received before the handshake completed'));
378
+ return;
379
+ }
380
+ let plaintext;
381
+ try {
382
+ plaintext = this.receiveState.decrypt(node_buffer_1.Buffer.from([type]), ciphertext);
383
+ }
384
+ catch {
385
+ this.fail(new Error('Record authentication failed'));
386
+ return;
387
+ }
388
+ const listener = this.messageListener;
389
+ if (listener !== undefined) {
390
+ listener(type, plaintext.toString('utf8'));
391
+ }
392
+ }
393
+ }
394
+ deliverHandshakeMessage(message) {
395
+ if (this.phase !== 'handshaking' || this.handshakeResolved) {
396
+ this.fail(new Error('Unexpected handshake message'));
397
+ return;
398
+ }
399
+ // The first handshake frame is either the initiator's message (server
400
+ // side) or the responder's reply (client side). The role is not stored on
401
+ // the channel, so stash it and let the static factory interpret it.
402
+ this.handshakeResolved = true;
403
+ this.resolveHandshake?.({
404
+ firstHandshakeMessage: message,
405
+ serverPayload: message,
406
+ });
407
+ this.resolveHandshake = undefined;
408
+ this.rejectHandshake = undefined;
409
+ }
410
+ writeRaw(frame) {
411
+ if (this.phase === 'closed' || this.socket.destroyed) {
412
+ return;
413
+ }
414
+ try {
415
+ this.socket.write(frame);
416
+ }
417
+ catch {
418
+ this.destroy();
419
+ }
420
+ }
421
+ fail(error) {
422
+ if (this.phase === 'closed') {
423
+ return;
424
+ }
425
+ this.phase = 'closed';
426
+ timerClear(this.handshakeTimer);
427
+ this.handshakeTimer = undefined;
428
+ this.rejectHandshake?.(error);
429
+ this.resolveHandshake = undefined;
430
+ this.rejectHandshake = undefined;
431
+ if (!this.socket.destroyed) {
432
+ this.socket.destroy();
433
+ }
434
+ this.notifyClose();
435
+ }
436
+ notifyClose() {
437
+ const listener = this.closeListener;
438
+ this.closeListener = undefined;
439
+ listener?.();
440
+ }
441
+ }
442
+ exports.SecureChannel = SecureChannel;
443
+ function timerClear(timer) {
444
+ if (timer !== undefined) {
445
+ clearTimeout(timer);
446
+ }
447
+ }
448
+ //# sourceMappingURL=channel.js.map
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Noise Protocol Framework revision 34, pattern NNpsk0, instantiated with
3
+ * X25519 / ChaCha20-Poly1305 / SHA-256.
4
+ *
5
+ * The pattern is:
6
+ *
7
+ * -> psk, e
8
+ * <- e, ee
9
+ *
10
+ * The pre-shared key is the daemon's 256-bit token. Both endpoints prove
11
+ * possession of it; the ephemeral X25519 exchange gives each session fresh
12
+ * key material and forward secrecy. The handshake hash is available as a
13
+ * channel binding after `split()`.
14
+ */
15
+ export declare const NOISE_PROTOCOL_NAME = "Noise_NNpsk0_25519_ChaChaPoly_SHA256";
16
+ /**
17
+ * Derives the fixed-size Noise PSK from the on-disk token.
18
+ *
19
+ * Token files stay human-readable 256-bit hex strings; Noise requires exactly
20
+ * 32 key bytes, so the secret is hashed once on both ends.
21
+ */
22
+ export declare function derivePsk(secret: string): Buffer;
23
+ export type NoiseRole = 'initiator' | 'responder';
24
+ export interface NoiseHandshakeOptions {
25
+ readonly role: NoiseRole;
26
+ readonly psk: Buffer;
27
+ readonly prologue?: Buffer;
28
+ }
29
+ export interface NoiseCipherState {
30
+ encrypt(ad: Buffer, plaintext: Buffer): Buffer;
31
+ decrypt(ad: Buffer, ciphertext: Buffer): Buffer;
32
+ readonly nonce: bigint;
33
+ }
34
+ export interface NoiseTransport {
35
+ readonly send: NoiseCipherState;
36
+ readonly receive: NoiseCipherState;
37
+ readonly handshakeHash: Buffer;
38
+ }
39
+ /**
40
+ * One side of an NNpsk0 handshake.
41
+ *
42
+ * Usage is strictly alternating: the initiator writes message 1 and reads
43
+ * message 2; the responder reads message 1 and writes message 2. A call in the
44
+ * wrong order, a malformed payload, or a failed AEAD tag throws and the caller
45
+ * must abandon the connection.
46
+ */
47
+ export declare class NoiseHandshake {
48
+ private readonly role;
49
+ private readonly psk;
50
+ private readonly symmetric;
51
+ private ephemeral;
52
+ private remoteEphemeral;
53
+ private messageIndex;
54
+ private splitResult;
55
+ constructor(options: NoiseHandshakeOptions);
56
+ writeMessage(payload?: Buffer): Buffer;
57
+ readMessage(message: Buffer): Buffer;
58
+ split(): NoiseTransport;
59
+ get handshakeHash(): Buffer;
60
+ private generateEphemeral;
61
+ private requireEphemeral;
62
+ private requireRemoteEphemeral;
63
+ private diffieHellman;
64
+ }