@cosyte/mllp 0.1.15 → 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.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var buffer = require('buffer');
3
4
  var tls = require('tls');
4
5
  var events = require('events');
5
6
  var crypto = require('crypto');
@@ -16,8 +17,6 @@ function createWarning(code, byteOffset, message) {
16
17
  timestamp: /* @__PURE__ */ new Date()
17
18
  });
18
19
  }
19
-
20
- // src/framing/error.ts
21
20
  var MAX_SNIPPET_BYTES = 64;
22
21
  var MllpFramingError = class _MllpFramingError extends Error {
23
22
  name = "MllpFramingError";
@@ -52,7 +51,7 @@ var MllpFramingError = class _MllpFramingError extends Error {
52
51
  super(message ?? `MLLP framing error: ${code} at byte offset ${byteOffset}`);
53
52
  this.code = code;
54
53
  this.byteOffset = byteOffset;
55
- this.snippet = Buffer.from(snippet.subarray(0, MAX_SNIPPET_BYTES));
54
+ this.snippet = buffer.Buffer.from(snippet.subarray(0, MAX_SNIPPET_BYTES));
56
55
  if (Error.captureStackTrace) {
57
56
  Error.captureStackTrace(this, _MllpFramingError);
58
57
  }
@@ -67,9 +66,9 @@ var LF = 10;
67
66
  var DEFAULT_MAX_FRAME_SIZE = 16 * 1024 * 1024;
68
67
 
69
68
  // src/framing/encoder.ts
70
- function encodeFrame(payload, opts) {
71
- const allow = opts?.allowDelimiterBytesInPayload === true;
72
- const onWarning = opts?.onWarning;
69
+ function encodeFrame(payload, options = {}) {
70
+ const allow = options.allowDelimiterBytesInPayload === true;
71
+ const onWarning = options.onWarning;
73
72
  if (!(payload instanceof Uint8Array)) {
74
73
  scanEachByte(payload, allow, onWarning);
75
74
  } else if (!allow || onWarning !== void 0) {
@@ -83,7 +82,7 @@ function encodeFrame(payload, opts) {
83
82
  else fs = payload.indexOf(FS, i + 1);
84
83
  }
85
84
  }
86
- const frame = Buffer.allocUnsafe(payload.length + 3);
85
+ const frame = buffer.Buffer.allocUnsafe(payload.length + 3);
87
86
  frame[0] = VT;
88
87
  payload.copy(frame, 1);
89
88
  frame[payload.length + 1] = FS;
@@ -100,7 +99,7 @@ function scanEachByte(payload, allow, onWarning) {
100
99
  function delimiterAt(byte, i, allow, onWarning) {
101
100
  const code = byte === VT ? "MLLP_PAYLOAD_CONTAINS_VT" : "MLLP_PAYLOAD_CONTAINS_FS";
102
101
  if (!allow) {
103
- throw new MllpFramingError(code, i, Buffer.from([byte]));
102
+ throw new MllpFramingError(code, i, buffer.Buffer.from([byte]));
104
103
  }
105
104
  if (onWarning !== void 0) {
106
105
  const byteHex = byte === VT ? "0x0B" : "0x1C";
@@ -115,16 +114,14 @@ function delimiterAt(byte, i, allow, onWarning) {
115
114
  }
116
115
  }
117
116
  }
118
-
119
- // src/framing/decoder.ts
120
117
  var BLOCK_SIZE = 4096;
121
- var EMPTY_SNIPPET = Buffer.alloc(0);
118
+ var EMPTY_SNIPPET = buffer.Buffer.alloc(0);
122
119
  var FrameReader = class {
123
120
  _opts;
124
121
  _maxFrameSize;
125
122
  _state = "SCANNING_FOR_VT";
126
123
  /** Reusable 4 KiB block the current frame's latest bytes are gathered in. */
127
- _accumulator = Buffer.allocUnsafe(BLOCK_SIZE);
124
+ _accumulator = buffer.Buffer.allocUnsafe(BLOCK_SIZE);
128
125
  /** Number of the current frame's bytes in `_accumulator`. */
129
126
  _blockUsed = 0;
130
127
  /**
@@ -181,7 +178,7 @@ var FrameReader = class {
181
178
  if (nextVt !== -1 && nextVt < stop) stop = nextVt;
182
179
  if (stop > i) {
183
180
  if (this._writePos === 0 && stop === nextFs && stop + 1 < end && chunk[stop + 1] === CR && stop - i <= this._room()) {
184
- const payload = Buffer.from(chunk.subarray(i, stop));
181
+ const payload = buffer.Buffer.from(chunk.subarray(i, stop));
185
182
  this._byteOffset += stop - i + 1;
186
183
  this._state = "EXPECTING_CR";
187
184
  this._deliver(payload);
@@ -256,10 +253,10 @@ var FrameReader = class {
256
253
  }
257
254
  if (at < end) {
258
255
  this._parts.push(this._accumulator);
259
- this._accumulator = Buffer.allocUnsafe(BLOCK_SIZE);
256
+ this._accumulator = buffer.Buffer.allocUnsafe(BLOCK_SIZE);
260
257
  const rest = end - at;
261
258
  if (rest >= BLOCK_SIZE) {
262
- this._parts.push(Buffer.from(src.subarray(at, end)));
259
+ this._parts.push(buffer.Buffer.from(src.subarray(at, end)));
263
260
  this._blockUsed = 0;
264
261
  } else {
265
262
  this._accumulator.set(src.subarray(at, end), 0);
@@ -326,7 +323,7 @@ var FrameReader = class {
326
323
  if (isWhitespace) {
327
324
  if (this._opts.allowLeadingWhitespace === true) {
328
325
  if (this._opts.strict === true) {
329
- const snippet3 = Buffer.from([byte]);
326
+ const snippet3 = buffer.Buffer.from([byte]);
330
327
  throw new MllpFramingError(
331
328
  "MLLP_MISSING_LEADING_VT",
332
329
  this._byteOffset,
@@ -340,7 +337,7 @@ var FrameReader = class {
340
337
  this._wsCount++;
341
338
  return;
342
339
  }
343
- const snippet2 = Buffer.from([byte]);
340
+ const snippet2 = buffer.Buffer.from([byte]);
344
341
  throw new MllpFramingError(
345
342
  "MLLP_MISSING_LEADING_VT",
346
343
  this._byteOffset,
@@ -359,7 +356,7 @@ var FrameReader = class {
359
356
  }
360
357
  if (this._opts.allowMissingLeadingVt === true) {
361
358
  if (this._opts.strict === true) {
362
- const snippet2 = Buffer.from([byte]);
359
+ const snippet2 = buffer.Buffer.from([byte]);
363
360
  throw new MllpFramingError(
364
361
  "MLLP_MISSING_LEADING_VT",
365
362
  this._byteOffset,
@@ -377,7 +374,7 @@ var FrameReader = class {
377
374
  this._readPayload(byte);
378
375
  return;
379
376
  }
380
- const snippet = Buffer.from([byte]);
377
+ const snippet = buffer.Buffer.from([byte]);
381
378
  throw new MllpFramingError(
382
379
  "MLLP_MISSING_LEADING_VT",
383
380
  this._byteOffset,
@@ -417,7 +414,7 @@ var FrameReader = class {
417
414
  if (byte === LF) {
418
415
  if (this._opts.allowLfAfterFs === true) {
419
416
  if (this._opts.strict === true) {
420
- const snippet3 = Buffer.from([byte]);
417
+ const snippet3 = buffer.Buffer.from([byte]);
421
418
  throw new MllpFramingError(
422
419
  "MLLP_LF_AFTER_FS",
423
420
  this._byteOffset,
@@ -434,7 +431,7 @@ var FrameReader = class {
434
431
  this._state = "SCANNING_FOR_VT";
435
432
  return;
436
433
  }
437
- const snippet2 = Buffer.from([byte]);
434
+ const snippet2 = buffer.Buffer.from([byte]);
438
435
  throw new MllpFramingError(
439
436
  "MLLP_LF_AFTER_FS",
440
437
  this._byteOffset,
@@ -445,7 +442,7 @@ var FrameReader = class {
445
442
  if (byte === VT) {
446
443
  if (this._opts.allowFsOnly === true) {
447
444
  if (this._opts.strict === true) {
448
- const snippet3 = Buffer.from([byte]);
445
+ const snippet3 = buffer.Buffer.from([byte]);
449
446
  throw new MllpFramingError(
450
447
  "MLLP_FS_WITHOUT_CR",
451
448
  this._byteOffset,
@@ -462,7 +459,7 @@ var FrameReader = class {
462
459
  this._state = "READING_PAYLOAD";
463
460
  return;
464
461
  }
465
- const snippet2 = Buffer.from([byte]);
462
+ const snippet2 = buffer.Buffer.from([byte]);
466
463
  throw new MllpFramingError(
467
464
  "MLLP_FS_WITHOUT_CR",
468
465
  this._byteOffset,
@@ -472,7 +469,7 @@ var FrameReader = class {
472
469
  }
473
470
  if (this._opts.allowFsOnly === true) {
474
471
  if (this._opts.strict === true) {
475
- const snippet2 = Buffer.from([byte]);
472
+ const snippet2 = buffer.Buffer.from([byte]);
476
473
  throw new MllpFramingError(
477
474
  "MLLP_FS_WITHOUT_CR",
478
475
  this._byteOffset,
@@ -487,7 +484,7 @@ var FrameReader = class {
487
484
  `FS (0x1C) inside a frame at offset ${this._byteOffset - 1}; the frame is refused whole`
488
485
  );
489
486
  }
490
- const snippet = Buffer.from([byte]);
487
+ const snippet = buffer.Buffer.from([byte]);
491
488
  throw new MllpFramingError(
492
489
  "MLLP_FS_WITHOUT_CR",
493
490
  this._byteOffset,
@@ -499,7 +496,7 @@ var FrameReader = class {
499
496
  _appendByte(byte) {
500
497
  if (this._blockUsed === BLOCK_SIZE) {
501
498
  this._parts.push(this._accumulator);
502
- this._accumulator = Buffer.allocUnsafe(BLOCK_SIZE);
499
+ this._accumulator = buffer.Buffer.allocUnsafe(BLOCK_SIZE);
503
500
  this._blockUsed = 0;
504
501
  }
505
502
  this._accumulator[this._blockUsed++] = byte;
@@ -512,11 +509,11 @@ var FrameReader = class {
512
509
  _deliverFrame() {
513
510
  const block = this._accumulator.subarray(0, this._blockUsed);
514
511
  if (this._parts.length === 0) {
515
- this._deliver(Buffer.from(block));
512
+ this._deliver(buffer.Buffer.from(block));
516
513
  return;
517
514
  }
518
515
  this._parts.push(block);
519
- this._deliver(Buffer.concat(this._parts, this._writePos));
516
+ this._deliver(buffer.Buffer.concat(this._parts, this._writePos));
520
517
  }
521
518
  /**
522
519
  * Deliver `payload` via `onFrame` with this frame's start offset and warnings, the frame's
@@ -538,7 +535,7 @@ var FrameReader = class {
538
535
  this._discard();
539
536
  this._frameWarnings = [];
540
537
  this._state = "SCANNING_FOR_VT";
541
- throw new MllpFramingError(code, byteOffset, Buffer.from([delimiter]), message);
538
+ throw new MllpFramingError(code, byteOffset, buffer.Buffer.from([delimiter]), message);
542
539
  }
543
540
  /** Emit a warning via the `onWarning` callback, swallowing any handler exceptions. */
544
541
  _emitWarning(code, byteOffset, message) {
@@ -689,19 +686,17 @@ var MllpTlsConfigurationError = class _MllpTlsConfigurationError extends Error {
689
686
  * Construct a TLS configuration error.
690
687
  *
691
688
  * @param code - The stable configuration-error code; also selects the message.
692
- * @param opts - Optional underlying `cause` from the TLS library.
689
+ * @param options - Optional underlying `cause` from the TLS library.
693
690
  */
694
- constructor(code, opts) {
691
+ constructor(code, options = {}) {
695
692
  super(tlsConfigurationMessage(code));
696
693
  this.code = code;
697
- this.cause = opts?.cause;
694
+ this.cause = options.cause;
698
695
  if (Error.captureStackTrace) {
699
696
  Error.captureStackTrace(this, _MllpTlsConfigurationError);
700
697
  }
701
698
  }
702
699
  };
703
-
704
- // src/transport/dh-parameters.ts
705
700
  var BEGIN_BOUNDARY = "-----BEGIN DH PARAMETERS-----";
706
701
  var END_BOUNDARY = "-----END DH PARAMETERS-----";
707
702
  var BOM_SPELLINGS = [
@@ -757,7 +752,7 @@ function magnitudeOf(der, element) {
757
752
  }
758
753
  function compareMagnitudes(left, right) {
759
754
  if (left.length !== right.length) return left.length < right.length ? -1 : 1;
760
- return Buffer.compare(left, right);
755
+ return buffer.Buffer.compare(left, right);
761
756
  }
762
757
  function isOneBelow(value, oddPrime) {
763
758
  if (value.length !== oddPrime.length) return false;
@@ -811,7 +806,7 @@ function isDhParametersPem(input) {
811
806
  const body = readArmouredBody(text);
812
807
  if (body === null) return false;
813
808
  if (body.length % 4 !== 0 || !BASE64_BODY.test(body)) return false;
814
- const der = Buffer.from(body, "base64");
809
+ const der = buffer.Buffer.from(body, "base64");
815
810
  const sequence = readDerElement(der, 0);
816
811
  if (sequence === null || sequence.tag !== DER_SEQUENCE) return false;
817
812
  if (sequence.contentEnd !== der.length) return false;
@@ -1185,15 +1180,15 @@ var Connection = class extends events.EventEmitter {
1185
1180
  * `destroy()` during a long drain therefore ends the wait at once, not at the drain timeout.
1186
1181
  * - If `CLOSED` or `DISCONNECTED`: no-op.
1187
1182
  *
1188
- * @param opts.drainTimeoutMs - Override drain timeout (default: `opts.drainTimeoutMs ?? 30_000`).
1183
+ * @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
1189
1184
  *
1190
1185
  * @example
1191
1186
  * ```typescript
1192
1187
  * await conn.close({ drainTimeoutMs: 5_000 });
1193
1188
  * ```
1194
1189
  */
1195
- async close(opts) {
1196
- const timeout = opts?.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
1190
+ async close(options = {}) {
1191
+ const timeout = options.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
1197
1192
  if (this._state === "CLOSED" || this._state === "DISCONNECTED") return;
1198
1193
  if (this._state === "CONNECTING" || this._state === "RECONNECTING") {
1199
1194
  this._transition("CLOSED", "close() during " + this._state);
@@ -1657,7 +1652,7 @@ function tlsOptionNames() {
1657
1652
  return Object.values(names);
1658
1653
  }
1659
1654
  function copyValue(value) {
1660
- return ArrayBuffer.isView(value) ? Buffer.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength)) : value;
1655
+ return ArrayBuffer.isView(value) ? buffer.Buffer.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength)) : value;
1661
1656
  }
1662
1657
  function isOptionsObject(value) {
1663
1658
  if (typeof value !== "object" || value === null) return false;
@@ -1812,13 +1807,13 @@ var MllpAckError = class extends Error {
1812
1807
  ackCode;
1813
1808
  /**
1814
1809
  * @param message - Diagnostic text for the thrower. Never placed on the wire (may carry PHI).
1815
- * @param opts.ackCode - Negative code to return. Default `'AE'`.
1816
- * @param opts.cause - Underlying error, preserved on `.cause`.
1810
+ * @param options.ackCode - Negative code to return. Default `'AE'`.
1811
+ * @param options.cause - Underlying error, preserved on `.cause`.
1817
1812
  */
1818
- constructor(message, opts) {
1819
- super(message, opts?.cause !== void 0 ? { cause: opts.cause } : void 0);
1813
+ constructor(message, options = {}) {
1814
+ super(message, options.cause !== void 0 ? { cause: options.cause } : void 0);
1820
1815
  this.name = "MllpAckError";
1821
- this.ackCode = opts?.ackCode ?? "AE";
1816
+ this.ackCode = options.ackCode ?? "AE";
1822
1817
  }
1823
1818
  };
1824
1819
  function resolveNackCode(err) {
@@ -1872,7 +1867,7 @@ function buildRawAckFrom(inbound, code) {
1872
1867
  const s2 = DEFAULT_FIELD_SEPARATOR;
1873
1868
  const e = DEFAULT_ENCODING_CHARACTERS;
1874
1869
  const tail = code === "AE" || code === "AR" ? `${s2}${NACK_TEXT[code]}` : "";
1875
- return Buffer.from(
1870
+ return buffer.Buffer.from(
1876
1871
  `MSH${s2}${e}${s2}${s2}${s2}${s2}${s2}${now}${s2}${s2}ACK${s2}${newControlId}${s2}P${s2}2.3\rMSA${s2}${code}${s2}${tail}\r`,
1877
1872
  "latin1"
1878
1873
  );
@@ -1891,7 +1886,7 @@ function buildRawAckFrom(inbound, code) {
1891
1886
  const version = fields[11] ?? "2.3";
1892
1887
  const msaTail = code === "AE" || code === "AR" ? `${s}${NACK_TEXT[code]}` : "";
1893
1888
  const ackStr = `MSH${s}${encodingChars}${s}${receivingApp}${s}${receivingFacility}${s}${sendingApp}${s}${sendingFacility}${s}${now}${s}${s}ACK${s}${newControlId}${s}${processingId}${s}${version}\rMSA${s}${code}${s}${inboundControlId}${msaTail}\r`;
1894
- return Buffer.from(ackStr, "latin1");
1889
+ return buffer.Buffer.from(ackStr, "latin1");
1895
1890
  }
1896
1891
  function timestamp14() {
1897
1892
  const d = /* @__PURE__ */ new Date();
@@ -1946,8 +1941,8 @@ var ORIGINAL_MODE = Object.freeze({
1946
1941
  acceptCondition: "NE",
1947
1942
  applicationCondition: "AL",
1948
1943
  awaitsApplicationAck: false,
1949
- acceptFieldUnrecognised: false,
1950
- applicationFieldUnrecognised: false
1944
+ acceptFieldUnrecognized: false,
1945
+ applicationFieldUnrecognized: false
1951
1946
  });
1952
1947
  function classifyOutboundAckMode(msh) {
1953
1948
  if (msh === null) return ORIGINAL_MODE;
@@ -1961,8 +1956,8 @@ function classifyOutboundAckMode(msh) {
1961
1956
  acceptCondition: accept.kind === "code" ? accept.code : "NE",
1962
1957
  applicationCondition,
1963
1958
  awaitsApplicationAck: applicationCondition !== "NE",
1964
- acceptFieldUnrecognised: accept.kind === "unrecognised",
1965
- applicationFieldUnrecognised: application.kind === "unrecognised"
1959
+ acceptFieldUnrecognized: accept.kind === "unrecognised",
1960
+ applicationFieldUnrecognized: application.kind === "unrecognised"
1966
1961
  });
1967
1962
  }
1968
1963
  function readAcceptCondition(msh) {
@@ -2490,8 +2485,8 @@ var MllpServer = class extends events.EventEmitter {
2490
2485
  * the server and does NOT settle the in-flight `listen()`, which simply
2491
2486
  * continues and settles on its own bind outcome.
2492
2487
  *
2493
- * @param opts.drainTimeoutMs - Override drain timeout (default: `opts.drainTimeoutMs ?? 30_000`).
2494
- * @param opts.signal - AbortSignal to cancel the close operation. On abort, all
2488
+ * @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
2489
+ * @param options.signal - AbortSignal to cancel the close operation. On abort, all
2495
2490
  * active connections are destroyed and the promise rejects with AbortError.
2496
2491
  *
2497
2492
  * @example
@@ -2499,8 +2494,8 @@ var MllpServer = class extends events.EventEmitter {
2499
2494
  * await server.close({ drainTimeoutMs: 5_000 });
2500
2495
  * ```
2501
2496
  */
2502
- async close(opts) {
2503
- const signal = opts?.signal;
2497
+ async close(options = {}) {
2498
+ const signal = options.signal;
2504
2499
  if (signal?.aborted) {
2505
2500
  return Promise.reject(new DOMException("Aborted", "AbortError"));
2506
2501
  }
@@ -2523,7 +2518,7 @@ var MllpServer = class extends events.EventEmitter {
2523
2518
  signal.addEventListener("abort", abortHandler, { once: true });
2524
2519
  }) : null;
2525
2520
  try {
2526
- const drainTimeoutMs = opts?.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
2521
+ const drainTimeoutMs = options.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
2527
2522
  if (abortPromise !== null) {
2528
2523
  await Promise.race([this._drainAll(drainTimeoutMs), abortPromise]);
2529
2524
  } else {
@@ -3975,8 +3970,8 @@ var MllpClient = class extends events.EventEmitter {
3975
3970
  * await client.connect({ signal: ac.signal });
3976
3971
  * ```
3977
3972
  */
3978
- connect(opts) {
3979
- const signal = opts?.signal;
3973
+ connect(options = {}) {
3974
+ const signal = options.signal;
3980
3975
  if (signal?.aborted) {
3981
3976
  return Promise.reject(new DOMException("Aborted", "AbortError"));
3982
3977
  }
@@ -4321,7 +4316,7 @@ var MllpClient = class extends events.EventEmitter {
4321
4316
  const err = new MllpFramingError(
4322
4317
  "MLLP_ACK_UNMATCHED_CONTROL_ID",
4323
4318
  0,
4324
- Buffer.alloc(0),
4319
+ buffer.Buffer.alloc(0),
4325
4320
  ackDiagnosticMessage("MLLP_ACK_UNMATCHED_CONTROL_ID")
4326
4321
  );
4327
4322
  safeEmitError(
@@ -4860,17 +4855,17 @@ var MllpClient = class extends events.EventEmitter {
4860
4855
  * ```
4861
4856
  *
4862
4857
  * @param payload Raw bytes; MLLP framing is added internally via `encodeFrame`.
4863
- * @param opts.signal AbortSignal, aborting cancels the ACK wait.
4864
- * @param opts.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
4858
+ * @param options.signal AbortSignal, aborting cancels the ACK wait.
4859
+ * @param options.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
4865
4860
  * moment its bytes are flushed, in place of the client's `ackTimeoutMs`. Under
4866
4861
  * `onBackpressure: "wait"` it also bounds the wait for queue room, and the
4867
4862
  * acknowledgement wait then starts afresh once the send is written.
4868
- * @param opts.applicationAckTimeoutMs Per-send override of the second wait's bound.
4869
- * @param opts.onCommitAck Called with the commit disposition when the peer commits the
4863
+ * @param options.applicationAckTimeoutMs Per-send override of the second wait's bound.
4864
+ * @param options.onCommitAck Called with the commit disposition when the peer commits the
4870
4865
  * message ahead of its application acknowledgement. See {@link CommitAckReport}.
4871
4866
  */
4872
- send(payload, opts) {
4873
- const signal = opts?.signal;
4867
+ send(payload, options = {}) {
4868
+ const signal = options.signal;
4874
4869
  if (signal?.aborted === true) {
4875
4870
  return Promise.reject(new DOMException("Aborted", "AbortError"));
4876
4871
  }
@@ -4885,7 +4880,7 @@ var MllpClient = class extends events.EventEmitter {
4885
4880
  const msh = readMshSegment(payload);
4886
4881
  const controlId = this._correlateByControlId ? controlIdFromMsh(msh) : null;
4887
4882
  const ackMode = classifyOutboundAckMode(msh);
4888
- const twoPhase = this._twoPhaseStateFor(ackMode, opts);
4883
+ const twoPhase = this._twoPhaseStateFor(ackMode, options);
4889
4884
  const correlator = this._correlator;
4890
4885
  const conn = this._connection;
4891
4886
  const frame = encodeFrame(payload);
@@ -4916,10 +4911,10 @@ var MllpClient = class extends events.EventEmitter {
4916
4911
  return this._waitThenSend(
4917
4912
  payload,
4918
4913
  { byteCount: frame.length, messageControlIdBytes: controlId?.length },
4919
- opts
4914
+ options
4920
4915
  );
4921
4916
  }
4922
- const sendAckTimeoutMs = opts?.ackTimeoutMs;
4917
+ const sendAckTimeoutMs = options.ackTimeoutMs;
4923
4918
  return new Promise((resolve, reject) => {
4924
4919
  let abortListener = null;
4925
4920
  let ackDeadline;
@@ -4960,7 +4955,7 @@ var MllpClient = class extends events.EventEmitter {
4960
4955
  wrappedReject(neverDelivered());
4961
4956
  return;
4962
4957
  }
4963
- this.send(payload, opts).then(wrappedResolve, wrappedReject);
4958
+ this.send(payload, options).then(wrappedResolve, wrappedReject);
4964
4959
  };
4965
4960
  parked.cancel = () => {
4966
4961
  this.off("drain", onDrain);
@@ -5020,10 +5015,10 @@ var MllpClient = class extends events.EventEmitter {
5020
5015
  */
5021
5016
  _twoPhaseStateFor(ackMode, opts) {
5022
5017
  if (!ackMode.enhanced) return null;
5023
- if (ackMode.acceptFieldUnrecognised) {
5018
+ if (ackMode.acceptFieldUnrecognized) {
5024
5019
  this._emitAckModeWarning("MLLP_ACK_ACCEPT_TYPE_UNRECOGNISED", OUTBOUND_WARNING_CONTEXT);
5025
5020
  }
5026
- if (ackMode.applicationFieldUnrecognised) {
5021
+ if (ackMode.applicationFieldUnrecognized) {
5027
5022
  this._emitAckModeWarning("MLLP_ACK_APPLICATION_TYPE_UNRECOGNISED", OUTBOUND_WARNING_CONTEXT);
5028
5023
  }
5029
5024
  if (!this._correlateByControlId) {
@@ -5337,8 +5332,8 @@ var MllpClient = class extends events.EventEmitter {
5337
5332
  * await client.close({ drainTimeoutMs: 5_000 });
5338
5333
  * ```
5339
5334
  */
5340
- async close(opts) {
5341
- const signal = opts?.signal;
5335
+ async close(options = {}) {
5336
+ const signal = options.signal;
5342
5337
  if (signal?.aborted) {
5343
5338
  return Promise.reject(new DOMException("Aborted", "AbortError"));
5344
5339
  }
@@ -5353,7 +5348,7 @@ var MllpClient = class extends events.EventEmitter {
5353
5348
  return;
5354
5349
  }
5355
5350
  this._installDrainHook(conn);
5356
- const closeOpts = opts?.drainTimeoutMs !== void 0 ? { drainTimeoutMs: opts.drainTimeoutMs } : void 0;
5351
+ const closeOpts = options.drainTimeoutMs !== void 0 ? { drainTimeoutMs: options.drainTimeoutMs } : void 0;
5357
5352
  if (signal === void 0) {
5358
5353
  try {
5359
5354
  await conn.close(closeOpts);
@@ -5523,8 +5518,6 @@ async function createStarterClient(opts) {
5523
5518
  await client.connect();
5524
5519
  return client;
5525
5520
  }
5526
-
5527
- // src/differential/corpus.ts
5528
5521
  var SEGMENT_SEPARATOR = "\r";
5529
5522
  var ADT_A01_SEGMENTS = [
5530
5523
  "MSH|^~\\&|SENDING_APP|SENDING_FAC|RECV_APP|RECV_FAC|20260709120000||ADT^A01|MSG00001|P|2.5",
@@ -5543,7 +5536,7 @@ var ACK_AA_SEGMENTS = [
5543
5536
  "MSA|AA|MSG00001"
5544
5537
  ];
5545
5538
  function messageBytes(segments) {
5546
- return Buffer.from(segments.join(SEGMENT_SEPARATOR), CONTROL_ID_ENCODING);
5539
+ return buffer.Buffer.from(segments.join(SEGMENT_SEPARATOR), CONTROL_ID_ENCODING);
5547
5540
  }
5548
5541
  function canonicalExchanges() {
5549
5542
  return Object.freeze([
@@ -5691,7 +5684,7 @@ async function runExchange(exchange, settings) {
5691
5684
  transport.onData((chunk) => {
5692
5685
  if (settled) return;
5693
5686
  responseByteCount += chunk.length;
5694
- chunks.push(Buffer.from(chunk));
5687
+ chunks.push(buffer.Buffer.from(chunk));
5695
5688
  try {
5696
5689
  reader.push(chunk);
5697
5690
  } catch (err) {
@@ -5753,7 +5746,7 @@ function classifyFrame(exchange, payload, frameStart, chunks, deviations, finish
5753
5746
  recordWarning(deviations, w, frameStart + 1);
5754
5747
  }
5755
5748
  });
5756
- const received = Buffer.concat([...chunks]);
5749
+ const received = buffer.Buffer.concat([...chunks]);
5757
5750
  const parityMatch = deviations.length === 0 && frameStart === 0 && received.length >= canonical.length && received.subarray(0, canonical.length).equals(canonical);
5758
5751
  const acknowledged = extractMsaControlId(payload);
5759
5752
  let correlation;
@@ -5820,7 +5813,7 @@ async function runDifferential(options = {}) {
5820
5813
  }
5821
5814
 
5822
5815
  // src/index.ts
5823
- var VERSION = "0.1.15";
5816
+ var VERSION = "0.1.16";
5824
5817
 
5825
5818
  exports.ATNA_CIPHER_LIST = ATNA_CIPHER_LIST;
5826
5819
  exports.ATNA_CIPHER_SUITES = ATNA_CIPHER_SUITES;