@cosyte/mllp 0.1.14 → 0.1.16

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/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { Buffer } from 'buffer';
1
2
  import { createSecureContext, createServer as createServer$2, connect, checkServerIdentity } from 'tls';
2
3
  import { EventEmitter } from 'events';
3
4
  import { randomUUID } from 'crypto';
@@ -14,8 +15,6 @@ function createWarning(code, byteOffset, message) {
14
15
  timestamp: /* @__PURE__ */ new Date()
15
16
  });
16
17
  }
17
-
18
- // src/framing/error.ts
19
18
  var MAX_SNIPPET_BYTES = 64;
20
19
  var MllpFramingError = class _MllpFramingError extends Error {
21
20
  name = "MllpFramingError";
@@ -65,9 +64,9 @@ var LF = 10;
65
64
  var DEFAULT_MAX_FRAME_SIZE = 16 * 1024 * 1024;
66
65
 
67
66
  // src/framing/encoder.ts
68
- function encodeFrame(payload, opts) {
69
- const allow = opts?.allowDelimiterBytesInPayload === true;
70
- const onWarning = opts?.onWarning;
67
+ function encodeFrame(payload, options = {}) {
68
+ const allow = options.allowDelimiterBytesInPayload === true;
69
+ const onWarning = options.onWarning;
71
70
  if (!(payload instanceof Uint8Array)) {
72
71
  scanEachByte(payload, allow, onWarning);
73
72
  } else if (!allow || onWarning !== void 0) {
@@ -113,8 +112,6 @@ function delimiterAt(byte, i, allow, onWarning) {
113
112
  }
114
113
  }
115
114
  }
116
-
117
- // src/framing/decoder.ts
118
115
  var BLOCK_SIZE = 4096;
119
116
  var EMPTY_SNIPPET = Buffer.alloc(0);
120
117
  var FrameReader = class {
@@ -396,14 +393,12 @@ var FrameReader = class {
396
393
  return;
397
394
  }
398
395
  if (byte === VT) {
399
- this._emitWarning(
400
- "MLLP_TRAILING_BYTES",
396
+ this._refuse(
397
+ "MLLP_PAYLOAD_CONTAINS_VT",
401
398
  this._byteOffset,
402
- `Unexpected VT (0x0B) mid-payload at offset ${this._byteOffset}; discarding ${this._writePos} accumulated bytes`
399
+ VT,
400
+ `VT (0x0B) inside a frame at offset ${this._byteOffset}; the frame is refused whole`
403
401
  );
404
- this._discard();
405
- this._state = "READING_PAYLOAD";
406
- return;
407
402
  }
408
403
  if (this._writePos >= this._maxFrameSize) this._throwTooLarge();
409
404
  this._appendByte(byte);
@@ -480,14 +475,12 @@ var FrameReader = class {
480
475
  `Strict mode: FS without CR at offset ${this._byteOffset}`
481
476
  );
482
477
  }
483
- this._emitWarning(
484
- "MLLP_FS_WITHOUT_CR",
485
- this._byteOffset,
486
- `FS not followed by CR at offset ${this._byteOffset}; got 0x${byte.toString(16).padStart(2, "0")} (dropped)`
478
+ this._refuse(
479
+ "MLLP_PAYLOAD_CONTAINS_FS",
480
+ this._byteOffset - 1,
481
+ FS,
482
+ `FS (0x1C) inside a frame at offset ${this._byteOffset - 1}; the frame is refused whole`
487
483
  );
488
- this._deliverFrame();
489
- this._state = "SCANNING_FOR_VT";
490
- return;
491
484
  }
492
485
  const snippet = Buffer.from([byte]);
493
486
  throw new MllpFramingError(
@@ -531,6 +524,17 @@ var FrameReader = class {
531
524
  this._frameWarnings = [];
532
525
  this._opts.onFrame(payload, frameStart, frameWarnings);
533
526
  }
527
+ /**
528
+ * Refuse the current frame whole: forget its bytes and its warnings, go back to scanning for a
529
+ * VT, and throw. The error names the framing byte (`delimiter`) and its offset, never a byte of
530
+ * the frame's content, and nothing of the frame is delivered.
531
+ */
532
+ _refuse(code, byteOffset, delimiter, message) {
533
+ this._discard();
534
+ this._frameWarnings = [];
535
+ this._state = "SCANNING_FOR_VT";
536
+ throw new MllpFramingError(code, byteOffset, Buffer.from([delimiter]), message);
537
+ }
534
538
  /** Emit a warning via the `onWarning` callback, swallowing any handler exceptions. */
535
539
  _emitWarning(code, byteOffset, message) {
536
540
  const warning = createWarning(code, byteOffset, message);
@@ -680,19 +684,17 @@ var MllpTlsConfigurationError = class _MllpTlsConfigurationError extends Error {
680
684
  * Construct a TLS configuration error.
681
685
  *
682
686
  * @param code - The stable configuration-error code; also selects the message.
683
- * @param opts - Optional underlying `cause` from the TLS library.
687
+ * @param options - Optional underlying `cause` from the TLS library.
684
688
  */
685
- constructor(code, opts) {
689
+ constructor(code, options = {}) {
686
690
  super(tlsConfigurationMessage(code));
687
691
  this.code = code;
688
- this.cause = opts?.cause;
692
+ this.cause = options.cause;
689
693
  if (Error.captureStackTrace) {
690
694
  Error.captureStackTrace(this, _MllpTlsConfigurationError);
691
695
  }
692
696
  }
693
697
  };
694
-
695
- // src/transport/dh-parameters.ts
696
698
  var BEGIN_BOUNDARY = "-----BEGIN DH PARAMETERS-----";
697
699
  var END_BOUNDARY = "-----END DH PARAMETERS-----";
698
700
  var BOM_SPELLINGS = [
@@ -1021,6 +1023,20 @@ var Connection = class extends EventEmitter {
1021
1023
  _leftDraining = new Promise((resolve) => {
1022
1024
  this._leaveDraining = resolve;
1023
1025
  });
1026
+ /**
1027
+ * Work answering a frame this connection delivered, still running, with what it owes the peer.
1028
+ * See {@link Connection.holdOpenFor}.
1029
+ */
1030
+ _answering = /* @__PURE__ */ new Map();
1031
+ /**
1032
+ * Set once a fatal framing error has been met, or {@link Connection.stopReading} called: from
1033
+ * then on no byte the peer sends is read.
1034
+ */
1035
+ _refusing = false;
1036
+ /** When the `close()` drain began (`Date.now()`), or `undefined` when no `close()` is draining. */
1037
+ _closeBegan;
1038
+ /** Ends the wait after a fatal framing error: destroys the transport once the bound passes. */
1039
+ _refusalBound;
1024
1040
  /**
1025
1041
  * beforeClose hook, no-op default that resolves immediately.
1026
1042
  *
@@ -1052,6 +1068,7 @@ var Connection = class extends EventEmitter {
1052
1068
  }
1053
1069
  });
1054
1070
  this._transport.onData((chunk) => {
1071
+ if (this._refusing) return;
1055
1072
  this._bytesIn += chunk.length;
1056
1073
  this._lastByteInAt = /* @__PURE__ */ new Date();
1057
1074
  try {
@@ -1147,9 +1164,13 @@ var Connection = class extends EventEmitter {
1147
1164
  *
1148
1165
  * - If `CONNECTING` or `RECONNECTING`: cancels the pending attempt, transitions
1149
1166
  * directly to `CLOSED`, and calls `transport.destroy()`.
1150
- * - If `CONNECTED`: transitions to `DRAINING`, calls `beforeClose(drainTimeoutMs)`,
1151
- * then `DRAINING → DISCONNECTED` once the hook resolves, or `DRAINING → CLOSED`
1152
- * if the drain timeout elapses first.
1167
+ * - If `CONNECTED`: transitions to `DRAINING`, calls `beforeClose(drainTimeoutMs)` and
1168
+ * waits for it and for every piece of work passed to {@link Connection.holdOpenFor} that is
1169
+ * still running, then `DRAINING → DISCONNECTED` and ends the transport gracefully, so what
1170
+ * that work wrote reaches the peer. If the drain timeout elapses first: `DRAINING → CLOSED`
1171
+ * and the transport is destroyed. Work still running when the drain ends that way (the
1172
+ * timeout or a `destroy()`) is abandoned, and an `MllpConnectionError` with `phase: 'close'`
1173
+ * on `'error'` says how many were left and that what they would write is not sent.
1153
1174
  * - If `DRAINING`: waits for the existing drain to complete (idempotent).
1154
1175
  *
1155
1176
  * Every pending `close()` resolves as soon as the connection leaves `DRAINING`, by whatever
@@ -1157,15 +1178,15 @@ var Connection = class extends EventEmitter {
1157
1178
  * `destroy()` during a long drain therefore ends the wait at once, not at the drain timeout.
1158
1179
  * - If `CLOSED` or `DISCONNECTED`: no-op.
1159
1180
  *
1160
- * @param opts.drainTimeoutMs - Override drain timeout (default: `opts.drainTimeoutMs ?? 30_000`).
1181
+ * @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
1161
1182
  *
1162
1183
  * @example
1163
1184
  * ```typescript
1164
1185
  * await conn.close({ drainTimeoutMs: 5_000 });
1165
1186
  * ```
1166
1187
  */
1167
- async close(opts) {
1168
- const timeout = opts?.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
1188
+ async close(options = {}) {
1189
+ const timeout = options.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
1169
1190
  if (this._state === "CLOSED" || this._state === "DISCONNECTED") return;
1170
1191
  if (this._state === "CONNECTING" || this._state === "RECONNECTING") {
1171
1192
  this._transition("CLOSED", "close() during " + this._state);
@@ -1175,6 +1196,7 @@ var Connection = class extends EventEmitter {
1175
1196
  if (this._state === "DRAINING") {
1176
1197
  return this._drainPromise ?? Promise.resolve();
1177
1198
  }
1199
+ this._closeBegan = Date.now();
1178
1200
  this._transition("DRAINING");
1179
1201
  this._drainPromise = this._drainWithTimeout(timeout).finally(() => {
1180
1202
  this._drainPromise = null;
@@ -1182,13 +1204,13 @@ var Connection = class extends EventEmitter {
1182
1204
  return this._drainPromise;
1183
1205
  }
1184
1206
  /**
1185
- * Race `beforeClose()` against the drain timeout.
1207
+ * Race `beforeClose()` and the held work against the drain timeout.
1186
1208
  *
1187
1209
  * On normal completion: `DRAINING → DISCONNECTED` + `transport.close()`.
1188
1210
  * On timeout: `DRAINING → CLOSED` + `transport.destroy()`.
1189
1211
  */
1190
1212
  async _drainWithTimeout(timeoutMs) {
1191
- const drainPromise = this.beforeClose(timeoutMs);
1213
+ const drainPromise = Promise.all([this.beforeClose(timeoutMs), this._heldWorkSettled()]);
1192
1214
  let handle;
1193
1215
  const timeoutPromise = new Promise((resolve) => {
1194
1216
  handle = setTimeout(() => {
@@ -1204,6 +1226,7 @@ var Connection = class extends EventEmitter {
1204
1226
  ]);
1205
1227
  if (this._state !== "DRAINING") return;
1206
1228
  if (result === "timeout") {
1229
+ this._reportAbandonedAfter("drain timeout");
1207
1230
  this._transition("CLOSED", "drain timeout");
1208
1231
  this._transport.destroy();
1209
1232
  } else {
@@ -1230,9 +1253,75 @@ var Connection = class extends EventEmitter {
1230
1253
  */
1231
1254
  destroy(reason) {
1232
1255
  if (this._state === "CLOSED") return;
1256
+ if (this._state === "DRAINING") {
1257
+ this._reportAbandonedAfter(reason?.message ?? "destroy()");
1258
+ }
1233
1259
  this._transition("CLOSED", reason?.message ?? "destroy()");
1234
1260
  this._transport.destroy(reason);
1235
1261
  }
1262
+ /**
1263
+ * Hold the connection open, on `close()` or a fatal framing error, until `work` settles.
1264
+ *
1265
+ * Pass the work that answers a frame this connection delivered: the handler and the write of
1266
+ * its acknowledgement. A `close()` waits for every piece of work passed here to settle before
1267
+ * it ends the transport, so an acknowledgement written by that work still goes out. When a
1268
+ * later frame on the same connection has a fatal framing error, the connection reads nothing
1269
+ * more, waits the same way, and only then closes, so the acknowledgement of a frame delivered
1270
+ * before the refused one still goes out. Either wait is bounded by `drainTimeoutMs` (default 30
1271
+ * seconds): work that has not settled by then is abandoned and the connection is destroyed.
1272
+ * `MllpServer` passes every message's work here itself; a caller driving a bare `Connection`
1273
+ * may do the same.
1274
+ *
1275
+ * `options.kind` says what the work owes the peer, which decides whether `close()` waits for it
1276
+ * and how an abandoned piece is reported:
1277
+ *
1278
+ * - `'ack'` (the default): the work writes the frame's acknowledgement as its last step, so
1279
+ * while it runs the acknowledgement has not been sent. `close()` waits for it; abandoned, it is
1280
+ * counted as a message delivered whose acknowledgement was not sent.
1281
+ * - `'manual'`: the work writes the acknowledgement itself at a point of its own choosing (a
1282
+ * manual-mode handler). `close()` waits for it until it settles; abandoned, it is counted as a
1283
+ * handler whose acknowledgement may not have been sent.
1284
+ * - `'observer'`: the work writes no acknowledgement (an `onMessage` observer in custom-ACK
1285
+ * mode). `close()` does not wait for it; still running when a `close()` is abandoned, it is
1286
+ * named separately as an observer still running. A fatal framing error still waits for it.
1287
+ *
1288
+ * A rejection of `work` is not reported here; it only ends the wait for it.
1289
+ *
1290
+ * @param work - The work answering one delivered frame.
1291
+ * @param options - `kind`: what the work owes the peer (default `'ack'`).
1292
+ *
1293
+ * @example
1294
+ * ```typescript
1295
+ * conn.on('message', ({ payload }) => {
1296
+ * conn.holdOpenFor(commit(payload).then(() => conn.send(encodeFrame(ackFor(payload)))));
1297
+ * });
1298
+ * ```
1299
+ */
1300
+ holdOpenFor(work, options) {
1301
+ const done = () => {
1302
+ this._answering.delete(work);
1303
+ };
1304
+ this._answering.set(work, options?.kind ?? "ack");
1305
+ work.then(done, done);
1306
+ }
1307
+ /**
1308
+ * Read nothing more from the peer: every byte that arrives from now on is dropped unread, and
1309
+ * no further frame is delivered. It cannot be undone.
1310
+ *
1311
+ * `MllpServer.close()` calls this on each connection before closing it, so no new message
1312
+ * reaches a handler while the ones already running finish and their acknowledgements are
1313
+ * written. A client must not call it before a `close()` that waits for acknowledgements, since
1314
+ * it would then never read them.
1315
+ *
1316
+ * @example
1317
+ * ```typescript
1318
+ * conn.stopReading();
1319
+ * await conn.close();
1320
+ * ```
1321
+ */
1322
+ stopReading() {
1323
+ this._refusing = true;
1324
+ }
1236
1325
  /**
1237
1326
  * Return a JSON-serializable observability snapshot.
1238
1327
  *
@@ -1270,6 +1359,61 @@ var Connection = class extends EventEmitter {
1270
1359
  // ---------------------------------------------------------------------------
1271
1360
  // Private FSM helpers
1272
1361
  // ---------------------------------------------------------------------------
1362
+ /**
1363
+ * Settle once no work passed to {@link Connection.holdOpenFor} that owes an acknowledgement is
1364
+ * running; an `'observer'` is not waited for. Work registered while waiting (a frame decoded
1365
+ * from bytes already read) is waited for too.
1366
+ */
1367
+ async _heldWorkSettled() {
1368
+ for (; ; ) {
1369
+ const owing = [...this._answering].filter(([, kind]) => kind !== "observer");
1370
+ if (owing.length === 0) return;
1371
+ await Promise.allSettled(owing.map(([work]) => work));
1372
+ }
1373
+ }
1374
+ /**
1375
+ * Report, on `'error'`, the held work a `close()` drain abandons because the drain ended before
1376
+ * that work settled. It counts per delivered message: work that would have written an
1377
+ * acknowledgement (not sent), a manual-mode handler (its acknowledgement may not have been
1378
+ * sent), and, separately, observers that owe none. Nothing is reported when no `close()` is
1379
+ * draining or nothing is still running.
1380
+ *
1381
+ * @param how - How the drain ended, as it reads after "close() ended ".
1382
+ * @param reason - What ended it, the message of the report's `cause`.
1383
+ */
1384
+ _reportAbandonedWork(how, reason) {
1385
+ if (this._closeBegan === void 0) return;
1386
+ const count = { ack: 0, manual: 0, observer: 0 };
1387
+ for (const kind of this._answering.values()) count[kind] += 1;
1388
+ const parts = [];
1389
+ if (count.ack > 0) {
1390
+ parts.push(
1391
+ count.ack === 1 ? "1 message was delivered and its acknowledgement was not sent" : `${String(count.ack)} messages were delivered and their acknowledgements were not sent`
1392
+ );
1393
+ }
1394
+ if (count.manual > 0) {
1395
+ parts.push(
1396
+ count.manual === 1 ? "1 manual-mode handler was still running, so its acknowledgement may not have been sent" : `${String(count.manual)} manual-mode handlers were still running, so their acknowledgements may not have been sent`
1397
+ );
1398
+ }
1399
+ if (count.observer > 0) {
1400
+ parts.push(
1401
+ count.observer === 1 ? "1 observer that owes no acknowledgement was still running" : `${String(count.observer)} observers that owe no acknowledgement were still running`
1402
+ );
1403
+ }
1404
+ if (count.ack + count.manual === 0) return;
1405
+ this._emitErrorIfListened(
1406
+ new MllpConnectionError(`close() ended ${how}: ${parts.join("; ")}`, {
1407
+ cause: new Error(reason),
1408
+ phase: "close"
1409
+ })
1410
+ );
1411
+ }
1412
+ /** Report the work a `close()` drain abandons at the bound or on a `destroy()`. */
1413
+ _reportAbandonedAfter(reason) {
1414
+ const elapsedMs = Date.now() - (this._closeBegan ?? Date.now());
1415
+ this._reportAbandonedWork(`after ${String(elapsedMs)} ms (${reason})`, reason);
1416
+ }
1273
1417
  _transition(to, reason) {
1274
1418
  const from = this._state;
1275
1419
  const legal = LEGAL_TRANSITIONS.get(from);
@@ -1301,7 +1445,9 @@ var Connection = class extends EventEmitter {
1301
1445
  }
1302
1446
  }
1303
1447
  _onTransportClose() {
1448
+ clearTimeout(this._refusalBound);
1304
1449
  if (this._state === "DRAINING") {
1450
+ this._reportAbandonedWork("when the sender closed the connection", "peer closed");
1305
1451
  this._transition("DISCONNECTED");
1306
1452
  return;
1307
1453
  }
@@ -1336,7 +1482,7 @@ var Connection = class extends EventEmitter {
1336
1482
  }
1337
1483
  }
1338
1484
  /**
1339
- * Handle a fatal framing error thrown out of `FrameReader.push` (FRAME-FATAL).
1485
+ * Handle a fatal framing error thrown out of `FrameReader.push`.
1340
1486
  *
1341
1487
  * Contract: surface it as a connection `'error'` (frozen payload, `phase: 'receive'`,
1342
1488
  * `connectionCause: 'framing-fatal'`, the original `MllpFramingError` preserved as `cause` so
@@ -1354,8 +1500,21 @@ var Connection = class extends EventEmitter {
1354
1500
  * forever, and the backoff would become an unbounded reconnect storm against an interface
1355
1501
  * engine that is already unwell. A compatibility failure is not a network blip.
1356
1502
  *
1357
- * If a peer's quirk is *expected* (trailing junk, keepalive bytes, a missing leading VT), the
1358
- * decoder's tolerance opt-ins are the supported answer, they turn the throw into a warning.
1503
+ * Frames delivered before the refused one are still answered. Their handlers may still be
1504
+ * running (an acknowledgement is written after its handler settles, so even a synchronous
1505
+ * handler's is not out yet), and closing at once dropped every one of those acknowledgements:
1506
+ * the sender resent a message already committed, and it was processed twice. So when work
1507
+ * passed to {@link Connection.holdOpenFor} is still running, the connection reads nothing
1508
+ * more, moves to `DRAINING`, waits for that work to settle, then closes gracefully (`CLOSED`,
1509
+ * the transport ended so the acknowledgements written are flushed). The wait is bounded by
1510
+ * `drainTimeoutMs`: past it the connection is destroyed, settled or not, so a handler that never
1511
+ * settles cannot hold the socket open. With nothing running it is destroyed at once.
1512
+ *
1513
+ * If a peer's quirk is *expected*, the decoder's tolerance opt-ins are the supported answer:
1514
+ * `allowLeadingWhitespace` (padding or keepalive bytes before a frame), `allowMissingLeadingVt`,
1515
+ * `allowFsOnly` (a bare FS that the next frame's VT follows) and `allowLfAfterFs` turn their
1516
+ * throw into a warning. No opt-in accepts other bytes between frames, or a stray FS or VT inside
1517
+ * one: those are always refused.
1359
1518
  */
1360
1519
  _onFatalFramingError(err) {
1361
1520
  if (this._state === "CLOSED") return;
@@ -1366,7 +1525,24 @@ var Connection = class extends EventEmitter {
1366
1525
  connectionCause: "framing-fatal"
1367
1526
  })
1368
1527
  );
1369
- this.destroy(err);
1528
+ if (this._answering.size === 0 || this._state !== "CONNECTED") {
1529
+ this.destroy(err);
1530
+ return;
1531
+ }
1532
+ this._refusing = true;
1533
+ const boundMs = this._opts.drainTimeoutMs ?? 3e4;
1534
+ this._transition("DRAINING", err.message);
1535
+ this._drainPromise = this._leftDraining.then(() => void 0);
1536
+ this._refusalBound = setTimeout(() => {
1537
+ this._transition("CLOSED", err.message);
1538
+ this._transport.destroy(err);
1539
+ }, boundMs);
1540
+ this._refusalBound.unref();
1541
+ void Promise.allSettled([...this._answering.keys()]).then(() => {
1542
+ if (this._state !== "DRAINING") return;
1543
+ this._transition("CLOSED", err.message);
1544
+ this._transport.close();
1545
+ });
1370
1546
  }
1371
1547
  /**
1372
1548
  * Backstop for a NON-framing throw escaping `FrameReader.push`, i.e. our own bug, or a
@@ -1389,6 +1565,7 @@ var Connection = class extends EventEmitter {
1389
1565
  const phase = this._state === "CONNECTING" ? "connect" : this._state === "RECONNECTING" ? "reconnect" : this._state === "DRAINING" ? "close" : "receive";
1390
1566
  if (this._state === "CLOSED" || this._state === "DISCONNECTED") return;
1391
1567
  this._emitErrorIfListened(new MllpConnectionError(err.message, { cause: err, phase }));
1568
+ this._reportAbandonedWork(`when the connection failed (${err.message})`, err.message);
1392
1569
  const target = this._state === "CONNECTING" || this._state === "RECONNECTING" ? "CLOSED" : "DISCONNECTED";
1393
1570
  this._transition(target, `error: ${err.message}`);
1394
1571
  }
@@ -1628,13 +1805,13 @@ var MllpAckError = class extends Error {
1628
1805
  ackCode;
1629
1806
  /**
1630
1807
  * @param message - Diagnostic text for the thrower. Never placed on the wire (may carry PHI).
1631
- * @param opts.ackCode - Negative code to return. Default `'AE'`.
1632
- * @param opts.cause - Underlying error, preserved on `.cause`.
1808
+ * @param options.ackCode - Negative code to return. Default `'AE'`.
1809
+ * @param options.cause - Underlying error, preserved on `.cause`.
1633
1810
  */
1634
- constructor(message, opts) {
1635
- super(message, opts?.cause !== void 0 ? { cause: opts.cause } : void 0);
1811
+ constructor(message, options = {}) {
1812
+ super(message, options.cause !== void 0 ? { cause: options.cause } : void 0);
1636
1813
  this.name = "MllpAckError";
1637
- this.ackCode = opts?.ackCode ?? "AE";
1814
+ this.ackCode = options.ackCode ?? "AE";
1638
1815
  }
1639
1816
  };
1640
1817
  function resolveNackCode(err) {
@@ -1762,8 +1939,8 @@ var ORIGINAL_MODE = Object.freeze({
1762
1939
  acceptCondition: "NE",
1763
1940
  applicationCondition: "AL",
1764
1941
  awaitsApplicationAck: false,
1765
- acceptFieldUnrecognised: false,
1766
- applicationFieldUnrecognised: false
1942
+ acceptFieldUnrecognized: false,
1943
+ applicationFieldUnrecognized: false
1767
1944
  });
1768
1945
  function classifyOutboundAckMode(msh) {
1769
1946
  if (msh === null) return ORIGINAL_MODE;
@@ -1777,8 +1954,8 @@ function classifyOutboundAckMode(msh) {
1777
1954
  acceptCondition: accept.kind === "code" ? accept.code : "NE",
1778
1955
  applicationCondition,
1779
1956
  awaitsApplicationAck: applicationCondition !== "NE",
1780
- acceptFieldUnrecognised: accept.kind === "unrecognised",
1781
- applicationFieldUnrecognised: application.kind === "unrecognised"
1957
+ acceptFieldUnrecognized: accept.kind === "unrecognised",
1958
+ applicationFieldUnrecognized: application.kind === "unrecognised"
1782
1959
  });
1783
1960
  }
1784
1961
  function readAcceptCondition(msh) {
@@ -1891,6 +2068,11 @@ var MllpServer = class extends EventEmitter {
1891
2068
  /** `true` when `ServerOptions.tls` is set, `_netServer` is actually a `tls.Server`. */
1892
2069
  _isTls;
1893
2070
  _listening = false;
2071
+ /**
2072
+ * `true` from a `close()` until the next `listen()`: a socket accepted meanwhile (a TLS
2073
+ * handshake that began before the close and finished during it) is closed at once, never served.
2074
+ */
2075
+ _closing = false;
1894
2076
  /** Single-flight guard: `true` while a `listen()` call is settling. */
1895
2077
  _listenInFlight = false;
1896
2078
  /**
@@ -2146,6 +2328,7 @@ var MllpServer = class extends EventEmitter {
2146
2328
  );
2147
2329
  }
2148
2330
  this._listenInFlight = true;
2331
+ this._closing = false;
2149
2332
  return new Promise((resolve, reject) => {
2150
2333
  let settled = false;
2151
2334
  const settle = (outcome, opts) => {
@@ -2272,10 +2455,23 @@ var MllpServer = class extends EventEmitter {
2272
2455
  * Stop accepting new connections and gracefully close all active connections.
2273
2456
  *
2274
2457
  * Sequence:
2275
- * 1. `net.Server.close()`, stops accepting new connections immediately
2458
+ * 1. `net.Server.close()`, stops accepting new connections immediately. A socket the listener
2459
+ * still hands over (a TLS handshake that began before `close()` and ends during it) is
2460
+ * destroyed at once, before any byte of it is read.
2276
2461
  * 2. If `_connections` is empty: resolves immediately (no drain needed)
2277
- * 3. Calls `_drainAll(drainTimeoutMs)`, Promise.all + side-effect setTimeout
2278
- * that force-destroys stragglers after the drain window
2462
+ * 3. Every connection stops reading: bytes the peer sends from now on are dropped unread, so no
2463
+ * new message reaches a handler.
2464
+ * 4. Every connection waits for its handlers still running and the acknowledgements they write
2465
+ * (`AA`, a negative ACK for a handler that rejects, a custom builder's bytes), then ends its
2466
+ * socket gracefully so those acknowledgements reach the sender. In manual mode the wait lasts
2467
+ * until the handler's promise settles: a `conn.send()` made after that is not waited for. In
2468
+ * custom-ACK mode the `onMessage` observer is not waited for: it writes no acknowledgement.
2469
+ * 5. The wait is bounded by `drainTimeoutMs`. A connection still waiting then is destroyed, and
2470
+ * the server's `'error'` event carries an `MllpConnectionError` with `phase: 'close'` saying
2471
+ * how many messages were delivered without their acknowledgement being sent, how many
2472
+ * manual-mode handlers may not have sent theirs, and how many observers were still running.
2473
+ * The same report is made when the sender closes the connection, or half-closes it (the
2474
+ * server's sockets are not half-open, so our side ends with it), before that work settles.
2279
2475
  *
2280
2476
  * Calling `close()` while a `listen()` is still in flight proactively
2281
2477
  * settles that `listen()` with a typed `MllpConnectionError` rejection
@@ -2287,8 +2483,8 @@ var MllpServer = class extends EventEmitter {
2287
2483
  * the server and does NOT settle the in-flight `listen()`, which simply
2288
2484
  * continues and settles on its own bind outcome.
2289
2485
  *
2290
- * @param opts.drainTimeoutMs - Override drain timeout (default: `opts.drainTimeoutMs ?? 30_000`).
2291
- * @param opts.signal - AbortSignal to cancel the close operation. On abort, all
2486
+ * @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
2487
+ * @param options.signal - AbortSignal to cancel the close operation. On abort, all
2292
2488
  * active connections are destroyed and the promise rejects with AbortError.
2293
2489
  *
2294
2490
  * @example
@@ -2296,12 +2492,13 @@ var MllpServer = class extends EventEmitter {
2296
2492
  * await server.close({ drainTimeoutMs: 5_000 });
2297
2493
  * ```
2298
2494
  */
2299
- async close(opts) {
2300
- const signal = opts?.signal;
2495
+ async close(options = {}) {
2496
+ const signal = options.signal;
2301
2497
  if (signal?.aborted) {
2302
2498
  return Promise.reject(new DOMException("Aborted", "AbortError"));
2303
2499
  }
2304
2500
  this._pendingListenSettle?.();
2501
+ this._closing = true;
2305
2502
  this._netServer.close();
2306
2503
  this._listening = false;
2307
2504
  if (this._connections.size === 0) {
@@ -2319,7 +2516,7 @@ var MllpServer = class extends EventEmitter {
2319
2516
  signal.addEventListener("abort", abortHandler, { once: true });
2320
2517
  }) : null;
2321
2518
  try {
2322
- const drainTimeoutMs = opts?.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
2519
+ const drainTimeoutMs = options.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
2323
2520
  if (abortPromise !== null) {
2324
2521
  await Promise.race([this._drainAll(drainTimeoutMs), abortPromise]);
2325
2522
  } else {
@@ -2344,10 +2541,13 @@ var MllpServer = class extends EventEmitter {
2344
2541
  */
2345
2542
  async _drainAll(drainTimeoutMs) {
2346
2543
  const snapshot = [...this._connections];
2347
- const closePromises = snapshot.map((conn) => conn.close({ drainTimeoutMs }));
2544
+ const closePromises = snapshot.map((conn) => {
2545
+ conn.stopReading();
2546
+ return conn.close({ drainTimeoutMs });
2547
+ });
2348
2548
  const timeoutHandle = setTimeout(() => {
2349
2549
  for (const conn of this._connections) {
2350
- conn.destroy();
2550
+ conn.destroy(new Error("drain timeout"));
2351
2551
  }
2352
2552
  }, drainTimeoutMs);
2353
2553
  timeoutHandle.unref();
@@ -2434,6 +2634,10 @@ var MllpServer = class extends EventEmitter {
2434
2634
  // Private: per-socket setup
2435
2635
  // ---------------------------------------------------------------------------
2436
2636
  _onSocketAccepted(socket) {
2637
+ if (this._closing) {
2638
+ socket.destroy();
2639
+ return;
2640
+ }
2437
2641
  if (this._opts.keepaliveIntervalMs !== void 0) {
2438
2642
  socket.setKeepAlive(true, this._opts.keepaliveIntervalMs);
2439
2643
  }
@@ -2444,10 +2648,12 @@ var MllpServer = class extends EventEmitter {
2444
2648
  ...this._opts.framing ?? {}
2445
2649
  };
2446
2650
  const connOpts = this._opts.onWarning !== void 0 ? { transport, framing: mergedFraming, onWarning: this._opts.onWarning } : { transport, framing: mergedFraming };
2447
- const conn = new Connection(connOpts);
2651
+ const conn = new Connection({
2652
+ ...connOpts,
2653
+ drainTimeoutMs: this._opts.drainTimeoutMs ?? 3e4
2654
+ });
2448
2655
  const release = this._capRelease.get(socket);
2449
2656
  if (release !== void 0) socket.once("close", release);
2450
- conn.beforeClose = () => Promise.resolve();
2451
2657
  conn.on("error", (errEvent) => {
2452
2658
  this._emitErrorIfListened(errEvent);
2453
2659
  });
@@ -2501,12 +2707,12 @@ var MllpServer = class extends EventEmitter {
2501
2707
  }
2502
2708
  const autoAck = this._opts.autoAck;
2503
2709
  if (autoAck === "AA") {
2504
- void this._sendCommitAck(payload, meta, conn);
2710
+ conn.holdOpenFor(this._sendCommitAck(payload, meta, conn));
2505
2711
  } else if (autoAck !== void 0) {
2506
- this._observeMessage(payload, meta, conn);
2507
- void this._sendCustomAck(autoAck, payload, meta, conn);
2712
+ this._observeMessage(payload, meta, conn, "observer");
2713
+ conn.holdOpenFor(this._sendCustomAck(autoAck, payload, meta, conn));
2508
2714
  } else {
2509
- this._observeMessage(payload, meta, conn);
2715
+ this._observeMessage(payload, meta, conn, "manual");
2510
2716
  }
2511
2717
  }
2512
2718
  );
@@ -2573,7 +2779,7 @@ var MllpServer = class extends EventEmitter {
2573
2779
  if (handler === void 0) {
2574
2780
  this._dispatchAck(
2575
2781
  conn,
2576
- buildRawAckFrom(inbound, this._resolveAutoAckPositive(inbound, meta, conn, selectCode))
2782
+ buildRawAckFrom(inbound, this._resolveAutoAckPositive(inbound, conn, selectCode))
2577
2783
  );
2578
2784
  return;
2579
2785
  }
@@ -2582,7 +2788,7 @@ var MllpServer = class extends EventEmitter {
2582
2788
  try {
2583
2789
  await handler(payload, meta, conn);
2584
2790
  settled = readInbound(payload);
2585
- code = this._resolveAutoAckPositive(settled, meta, conn, selectCode);
2791
+ code = this._resolveAutoAckPositive(settled, conn, selectCode);
2586
2792
  } catch (err) {
2587
2793
  const nack = resolveNackCode(err);
2588
2794
  code = selectCode(nack);
@@ -2605,30 +2811,18 @@ var MllpServer = class extends EventEmitter {
2605
2811
  * cannot carry a correlatable positive ACK, so `AA` never names a control ID the sender
2606
2812
  * cannot match (→ timeout → resend → **duplicate clinical message**).
2607
2813
  *
2608
- * Two independent disqualifiers, one from the bytes and one from the frame:
2609
- *
2610
- * - **`rawAckUncorrelatable(payload)`**, no readable `MSH`, an empty MSH-10, or a
2611
- * batch/concatenated-message shape. This is the SAME predicate `buildRawAck` enforces
2612
- * on the wire; it is re-checked here so the downgrade is **observable** (a `'nack'`
2613
- * event) rather than a silent code change inside the builder.
2614
- * - **`MLLP_TRAILING_BYTES`** in the frame's warnings, a mid-payload `VT` made the
2615
- * decoder discard accumulated bytes and deliver only the fragment after it. The
2616
- * clinical message was destroyed in transit, so even a fragment that happens to carry
2617
- * a readable MSH must not be positively acknowledged. This condition is invisible to
2618
- * `buildRawAck` (it sees only the fragment), which is why it lives here. The code is
2619
- * **reserved** for that discard (see the decoder's `_readPayload`) and is emitted while
2620
- * accumulating the delivered frame, so it is frame-scoped: it names *this* payload's own
2621
- * discard, never a neighbouring frame's trailing junk.
2622
- *
2623
- * `'discarded-bytes'` takes precedence in the reason when both hold, it is the root cause.
2814
+ * The disqualifier is **`rawAckUncorrelatable(payload)`**: no readable `MSH`, an empty
2815
+ * MSH-10, or a batch/concatenated-message shape. This is the SAME predicate `buildRawAck`
2816
+ * enforces on the wire; it is re-checked here so the downgrade is **observable** (a `'nack'`
2817
+ * event) rather than a silent code change inside the builder. A frame with a `VT` or a stray
2818
+ * `FS` inside it never gets here: the decoder refuses it whole and the connection closes.
2624
2819
  *
2625
2820
  * `selectCode` puts the resolved disposition in the half of HL7 Table 0008 the inbound
2626
2821
  * asked for; it is the identity for a message that asked for nothing.
2627
2822
  */
2628
- _resolveAutoAckPositive(inbound, meta, conn, selectCode) {
2629
- const discarded = meta.warnings.some((w) => w.code === "MLLP_TRAILING_BYTES");
2630
- if (!discarded && !uncorrelatable(inbound)) return selectCode("AA");
2631
- const reason = discarded ? "discarded-bytes" : "uncorrelatable-inbound";
2823
+ _resolveAutoAckPositive(inbound, conn, selectCode) {
2824
+ if (!uncorrelatable(inbound)) return selectCode("AA");
2825
+ const reason = "uncorrelatable-inbound";
2632
2826
  const code = selectCode("AE");
2633
2827
  this._emitContained(
2634
2828
  "nack",
@@ -2704,13 +2898,14 @@ var MllpServer = class extends EventEmitter {
2704
2898
  * connection (a handler error never crashes the server) rather than escaping as
2705
2899
  * an unhandled rejection. The error text is never placed on the wire.
2706
2900
  */
2707
- _observeMessage(payload, meta, conn) {
2901
+ _observeMessage(payload, meta, conn, kind) {
2708
2902
  const handler = this._opts.onMessage;
2709
2903
  if (handler === void 0) return;
2710
- void Promise.resolve().then(() => handler(payload, meta, conn)).catch((err) => {
2904
+ const work = Promise.resolve().then(() => handler(payload, meta, conn)).catch((err) => {
2711
2905
  const connErr = err instanceof Error ? err : new Error(String(err));
2712
2906
  safeEmitError(conn, Object.freeze({ connectionId: conn.connectionId, error: connErr }));
2713
2907
  });
2908
+ conn.holdOpenFor(work, { kind });
2714
2909
  }
2715
2910
  /**
2716
2911
  * The custom-builder path for `autoAck: fn`. Awaits the builder and dispatches its
@@ -2727,10 +2922,12 @@ var MllpServer = class extends EventEmitter {
2727
2922
  }
2728
2923
  }
2729
2924
  /**
2730
- * Frame an ACK payload and write it to the connection. `Connection.send()` returns
2731
- * `false` under backpressure (socket write buffer full); that drops the ACK and emits
2732
- * a `MllpConnectionError({ phase: 'send' })` on the connection, the peer will
2733
- * time out waiting and may retry. The server never crashes.
2925
+ * Frame an ACK payload and write it to the connection. When the connection has already
2926
+ * closed (a handler that settled after `server.close()` gave up on it, or after the peer
2927
+ * left), the ACK is not sent and a `MllpConnectionError({ phase: 'send' })` saying so is
2928
+ * emitted on the connection. `Connection.send()` returns `false` under backpressure (socket
2929
+ * write buffer full); that is reported the same way, as backpressure. Either way the peer
2930
+ * will time out waiting and may retry. The server never crashes.
2734
2931
  */
2735
2932
  _dispatchAck(conn, ackPayload) {
2736
2933
  let framed;
@@ -2747,6 +2944,19 @@ var MllpServer = class extends EventEmitter {
2747
2944
  );
2748
2945
  return;
2749
2946
  }
2947
+ if (conn.state === "CLOSED" || conn.state === "DISCONNECTED") {
2948
+ safeEmitError(
2949
+ conn,
2950
+ Object.freeze({
2951
+ connectionId: conn.connectionId,
2952
+ error: new MllpConnectionError(
2953
+ "ACK not sent: the connection closed before the handler settled",
2954
+ { cause: new Error("connection closed"), phase: "send" }
2955
+ )
2956
+ })
2957
+ );
2958
+ return;
2959
+ }
2750
2960
  const sent = conn.send(framed);
2751
2961
  if (!sent) {
2752
2962
  safeEmitError(
@@ -3758,8 +3968,8 @@ var MllpClient = class extends EventEmitter {
3758
3968
  * await client.connect({ signal: ac.signal });
3759
3969
  * ```
3760
3970
  */
3761
- connect(opts) {
3762
- const signal = opts?.signal;
3971
+ connect(options = {}) {
3972
+ const signal = options.signal;
3763
3973
  if (signal?.aborted) {
3764
3974
  return Promise.reject(new DOMException("Aborted", "AbortError"));
3765
3975
  }
@@ -4638,21 +4848,22 @@ var MllpClient = class extends EventEmitter {
4638
4848
  * @example
4639
4849
  * ```typescript
4640
4850
  * const ack = await client.send(payloadBuffer);
4641
- * logger.info({ ack: ack.toString('utf8') });
4851
+ * // Log the acknowledgement's size, never its bytes: they echo your MSH-10.
4852
+ * logger.info({ ackBytes: ack.length });
4642
4853
  * ```
4643
4854
  *
4644
4855
  * @param payload Raw bytes; MLLP framing is added internally via `encodeFrame`.
4645
- * @param opts.signal AbortSignal, aborting cancels the ACK wait.
4646
- * @param opts.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
4856
+ * @param options.signal AbortSignal, aborting cancels the ACK wait.
4857
+ * @param options.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
4647
4858
  * moment its bytes are flushed, in place of the client's `ackTimeoutMs`. Under
4648
4859
  * `onBackpressure: "wait"` it also bounds the wait for queue room, and the
4649
4860
  * acknowledgement wait then starts afresh once the send is written.
4650
- * @param opts.applicationAckTimeoutMs Per-send override of the second wait's bound.
4651
- * @param opts.onCommitAck Called with the commit disposition when the peer commits the
4861
+ * @param options.applicationAckTimeoutMs Per-send override of the second wait's bound.
4862
+ * @param options.onCommitAck Called with the commit disposition when the peer commits the
4652
4863
  * message ahead of its application acknowledgement. See {@link CommitAckReport}.
4653
4864
  */
4654
- send(payload, opts) {
4655
- const signal = opts?.signal;
4865
+ send(payload, options = {}) {
4866
+ const signal = options.signal;
4656
4867
  if (signal?.aborted === true) {
4657
4868
  return Promise.reject(new DOMException("Aborted", "AbortError"));
4658
4869
  }
@@ -4667,7 +4878,7 @@ var MllpClient = class extends EventEmitter {
4667
4878
  const msh = readMshSegment(payload);
4668
4879
  const controlId = this._correlateByControlId ? controlIdFromMsh(msh) : null;
4669
4880
  const ackMode = classifyOutboundAckMode(msh);
4670
- const twoPhase = this._twoPhaseStateFor(ackMode, opts);
4881
+ const twoPhase = this._twoPhaseStateFor(ackMode, options);
4671
4882
  const correlator = this._correlator;
4672
4883
  const conn = this._connection;
4673
4884
  const frame = encodeFrame(payload);
@@ -4698,10 +4909,10 @@ var MllpClient = class extends EventEmitter {
4698
4909
  return this._waitThenSend(
4699
4910
  payload,
4700
4911
  { byteCount: frame.length, messageControlIdBytes: controlId?.length },
4701
- opts
4912
+ options
4702
4913
  );
4703
4914
  }
4704
- const sendAckTimeoutMs = opts?.ackTimeoutMs;
4915
+ const sendAckTimeoutMs = options.ackTimeoutMs;
4705
4916
  return new Promise((resolve, reject) => {
4706
4917
  let abortListener = null;
4707
4918
  let ackDeadline;
@@ -4742,7 +4953,7 @@ var MllpClient = class extends EventEmitter {
4742
4953
  wrappedReject(neverDelivered());
4743
4954
  return;
4744
4955
  }
4745
- this.send(payload, opts).then(wrappedResolve, wrappedReject);
4956
+ this.send(payload, options).then(wrappedResolve, wrappedReject);
4746
4957
  };
4747
4958
  parked.cancel = () => {
4748
4959
  this.off("drain", onDrain);
@@ -4802,10 +5013,10 @@ var MllpClient = class extends EventEmitter {
4802
5013
  */
4803
5014
  _twoPhaseStateFor(ackMode, opts) {
4804
5015
  if (!ackMode.enhanced) return null;
4805
- if (ackMode.acceptFieldUnrecognised) {
5016
+ if (ackMode.acceptFieldUnrecognized) {
4806
5017
  this._emitAckModeWarning("MLLP_ACK_ACCEPT_TYPE_UNRECOGNISED", OUTBOUND_WARNING_CONTEXT);
4807
5018
  }
4808
- if (ackMode.applicationFieldUnrecognised) {
5019
+ if (ackMode.applicationFieldUnrecognized) {
4809
5020
  this._emitAckModeWarning("MLLP_ACK_APPLICATION_TYPE_UNRECOGNISED", OUTBOUND_WARNING_CONTEXT);
4810
5021
  }
4811
5022
  if (!this._correlateByControlId) {
@@ -5119,8 +5330,8 @@ var MllpClient = class extends EventEmitter {
5119
5330
  * await client.close({ drainTimeoutMs: 5_000 });
5120
5331
  * ```
5121
5332
  */
5122
- async close(opts) {
5123
- const signal = opts?.signal;
5333
+ async close(options = {}) {
5334
+ const signal = options.signal;
5124
5335
  if (signal?.aborted) {
5125
5336
  return Promise.reject(new DOMException("Aborted", "AbortError"));
5126
5337
  }
@@ -5135,7 +5346,7 @@ var MllpClient = class extends EventEmitter {
5135
5346
  return;
5136
5347
  }
5137
5348
  this._installDrainHook(conn);
5138
- const closeOpts = opts?.drainTimeoutMs !== void 0 ? { drainTimeoutMs: opts.drainTimeoutMs } : void 0;
5349
+ const closeOpts = options.drainTimeoutMs !== void 0 ? { drainTimeoutMs: options.drainTimeoutMs } : void 0;
5139
5350
  if (signal === void 0) {
5140
5351
  try {
5141
5352
  await conn.close(closeOpts);
@@ -5305,8 +5516,6 @@ async function createStarterClient(opts) {
5305
5516
  await client.connect();
5306
5517
  return client;
5307
5518
  }
5308
-
5309
- // src/differential/corpus.ts
5310
5519
  var SEGMENT_SEPARATOR = "\r";
5311
5520
  var ADT_A01_SEGMENTS = [
5312
5521
  "MSH|^~\\&|SENDING_APP|SENDING_FAC|RECV_APP|RECV_FAC|20260709120000||ADT^A01|MSG00001|P|2.5",
@@ -5602,7 +5811,7 @@ async function runDifferential(options = {}) {
5602
5811
  }
5603
5812
 
5604
5813
  // src/index.ts
5605
- var VERSION = "0.1.14";
5814
+ var VERSION = "0.1.16";
5606
5815
 
5607
5816
  export { ATNA_CIPHER_LIST, ATNA_CIPHER_SUITES, Connection, FrameReader, MLLP_BIND_ALL_INTERFACES, MLLP_CONNECTION_LIMIT_REACHED, MLLP_DIFF_PEER_UNPARSEABLE, MLLP_TLS_CIPHER_LIST_REJECTED, MLLP_TLS_CIPHER_LIST_UNENFORCEABLE, MLLP_TLS_CIPHER_OPTION_CONFLICT, MLLP_TLS_CREDENTIAL_CONFLICT, MLLP_TLS_DH_PARAMETERS_REJECTED, MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE, MLLP_TLS_OPTIONS_NOT_AN_OBJECT, MLLP_TLS_PFX_REJECTED, MLLP_TLS_VERIFY_DISABLED, MllpAckError, MllpApplicationAckError, MllpBackpressureError, MllpClient, MllpCommitRejectedError, MllpConnectionError, MllpDifferentialConfigurationError, MllpFramingError, MllpNeverDeliveredError, MllpServer, MllpTimeoutError, MllpTlsConfigurationError, MllpUnknownFateError, MllpUnreadableAckError, NetTransport, TLS13_DEFAULT_CIPHER_SUITES, TlsTransport, VERSION, ackDiagnosticMessage, ackModeDiagnosticMessage, buildRawAck, canonicalAcknowledgement, canonicalExchanges, createClient, createServer, createStarterClient, createStarterServer, createWarning, differentialConfigurationMessage, encodeFrame, isTlsProtocolError, isTlsVerificationErrorCode, isTransientConnectionError, rawAckUncorrelatable, readNegotiatedTlsParameters, resolveDifferentialPeer, resolveNackCode, resolveTlsCipherPolicy, runDifferential, selectAckCode, tlsConfigurationMessage };
5608
5817
  //# sourceMappingURL=index.mjs.map