@cosyte/mllp 0.1.12 → 0.1.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.14
4
+ ### Patch Changes
5
+
6
+ - 660fcf7: **An acknowledgment or message that starts with a UTF-8 byte order mark is now read.** Some engines write `EF BB BF` before the `MSH` when they encode a message as UTF-8. Before this, the mark hid the `MSH`, so a healthy acknowledgment behind one could not be matched by control ID under `correlateByControlId: true`, and in FIFO mode it drew the `MLLP_ACK_FIFO_MSA1_UNREADABLE` warning (or rejected the send under `fifoUnreadableAck: "reject"`); on the server, a positive auto-ACK for an inbound message behind one was downgraded to `AE` with an empty MSA-2, and `buildRawAck` and `rawAckUncorrelatable` did the same. Now a whole mark at byte 0 is skipped for reading the `MSH`, MSA-1 and MSA-2 in both client modes and on the server, so those acknowledgments settle their sends with no warning and those messages get an `AA` that echoes MSH-10. The bytes handed to the caller stay exactly as received, mark included. A mark anywhere else (after a leading `CR`, a second mark, or part of one) still hides the `MSH`, as before. Nothing for a caller to change: a handler that counted on the `AE` downgrade for such a message now sees `AA`.
7
+ - d3ebc5d: **A client correlating in order no longer settles a send on a frame that is not an acknowledgment without saying so.** In FIFO mode, the default, the oldest pending send is settled by whatever frame arrives next, and before this a lone `0x06` or `0x15` byte, an `MSH` with no `MSA`, or an MSA-1 outside HL7 Table 0008 resolved `send()` with no signal at all. Now the client emits the `'warning'` `MLLP_ACK_FIFO_MSA1_UNREADABLE` (an `AckModeWarning` carrying `msa1Bytes` and `byteOffset`, never field content) whenever the frame that settles a send has no readable MSA-1. What a caller sees by default: `send()` still resolves with the frame, exactly as before, plus that one warning; a `'warning'` handler that checks for an exhaustive set of codes has to allow the new one. What a caller may change: the new client option `fifoUnreadableAck: "reject"` (also on `createStarterClient`) makes such a send reject with the new `MllpUnreadableAckError` instead, whose `msa1Bytes`, `byteOffset` and `elapsedMs` are numbers only; the frame still takes that send's turn, so the next send settles on the next frame. `fifoUnreadableAck` takes `"warn"` (the default) or `"reject"`, and any other value throws a `TypeError` at construction. With `correlateByControlId: true` nothing changes: such a frame matches no send and settles nothing, and correlating by control ID remains what we recommend whenever the peer echoes MSH-10 in MSA-2.
8
+
9
+ ## 0.1.13
10
+ ### Patch Changes
11
+
12
+ - c81ac75: **The `tls` options are copied when a client or server is created.** Both kept the caller's `tls` object, and a client read it again on every connect and reconnect, so a `pfx` added to that object after construction reached the socket without the `MLLP_TLS_CREDENTIAL_CONFLICT` check and its certificate was presented in place of `cert`. Now `createClient`, `createServer` and both constructors take a copy, check it, and use only it. The copy reads each TLS option by name, so options a class instance supplies through getters, or an object inherits from its prototype, are kept (a server given `clientAuth: "MUST"` that way still requires a client certificate); it takes new arrays and new bytes for every `Buffer`, so bytes overwritten in place after construction no longer change the identity a client presents on reconnect. A caller who changed their `tls` object, its `Buffer` bytes, or put a new one in the options, to have a running client pick up new TLS settings must create a new client instead. A `tls` that is `null` or not an object now throws `MllpTlsConfigurationError` with the new exported code `MLLP_TLS_OPTIONS_NOT_AN_OBJECT` at creation, where it threw a bare `TypeError` (or, for a value such as `false` on a client, was taken as TLS with default options). The opening of the TLS section in the warning and error codes page now says which codes are thrown at creation rather than rejecting `connect()` or `listen()`.
13
+ - 697f397: **The `'tlsNegotiated'` record now names the key-exchange group, so a post-quantum link can be seen in your logs.** `NegotiatedTlsParameters` gains an optional `keyExchangeGroup`, the group the handshake's key exchange used as the TLS library names it: `'X25519'`, `'prime256v1'`, or a post-quantum hybrid such as `'X25519MLKEM768'`. The key is on the record only where Node.js reports the group, and missing everywhere else: Node.js reports it on a client socket alone, so a server record never carries it; a classic elliptic-curve group is reported on every supported Node.js line, while a group with no classic key, such as a post-quantum hybrid, is reported from Node.js 24.19.0 and 26.5.0 and is missing on Node.js 22; and a TLS 1.2 `DHE` suite has no group name to report. Like the other fields it is a name out of a closed registry, never caller data. Nothing changes for code that reads the record; code that checks its exact set of keys has to allow `keyExchangeGroup` on a client record.
14
+ - 1f8661d: **Every byte array in the `tls` options is copied, and a `tls` that is an array or another kind of object is refused.** The copy taken at creation gave new bytes only to a `Buffer`, so a `cert`, `key`, `ca` or `pfx` passed as a plain `Uint8Array` (outside the declared type, but Node.js accepts it) stayed the caller's: bytes overwritten in it after creation changed what a client presented on reconnect. Now every `ArrayBuffer` view (a `Buffer`, a `Uint8Array`, any other typed array, a `DataView`) is copied the same way, as a `Buffer` of the bytes it covers. A `tls` that is an array, a byte array (a `Buffer`, any other typed array, a `DataView`, an `ArrayBuffer` or a `SharedArrayBuffer`), a `Map`, a `Set`, a `Date`, a `Promise` or a boxed primitive now throws `MllpTlsConfigurationError` with `MLLP_TLS_OPTIONS_NOT_AN_OBJECT` from `createClient`, `createServer` and both constructors; before, a client given an array connected with TLS defaults and a server threw a `TypeError` asking for `cert` and `key`. Only those kinds are refused, each recognised by what it is rather than by its `Symbol.toStringTag`: a literal, a class instance (one that sets its own `Symbol.toStringTag` included), an `Object.create` object and a module namespace object are still accepted and read by name, as before. A caller who passed one of the refused kinds must pass an object of options instead. A client now loads its `pfx` once, when it is created, rather than on every connect and reconnect: a file that cannot be loaded still rejects every `connect()` with `MLLP_TLS_PFX_REJECTED` before a socket is opened, and a reconnect no longer spends the time to load the same bytes again.
15
+
3
16
  ## 0.1.12
4
17
  ### Patch Changes
5
18
 
@@ -144,9 +144,12 @@ function segmentEnds(buf) {
144
144
  return atCr < atLf ? atCr : atLf;
145
145
  };
146
146
  }
147
+ function firstSegmentStart(buf) {
148
+ return buf[0] === 239 && buf[1] === 187 && buf[2] === 191 ? 3 : 0;
149
+ }
147
150
  function findMshSegment(buf) {
148
151
  const segmentEnd = segmentEnds(buf);
149
- let segStart = 0;
152
+ let segStart = firstSegmentStart(buf);
150
153
  while (segStart < buf.length) {
151
154
  const end = segmentEnd(segStart);
152
155
  if (isMshSegmentAt(buf, segStart)) return { start: segStart, end };
@@ -192,7 +195,7 @@ function readMsaSegment(buf) {
192
195
  if (msh === null) return null;
193
196
  const fieldSep = msh.fieldSep.charCodeAt(0);
194
197
  const end = buf.length;
195
- let segStart = 0;
198
+ let segStart = firstSegmentStart(buf);
196
199
  while (segStart < end) {
197
200
  let segEnd = segStart;
198
201
  while (segEnd < end && buf[segEnd] !== SEGMENT_SEPARATOR_CR && buf[segEnd] !== SEGMENT_SEPARATOR_LF) {