@cosyte/mllp 0.1.11 → 0.1.13

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,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.13
4
+ ### Patch Changes
5
+
6
+ - 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()`.
7
+ - 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.
8
+ - 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.
9
+
10
+ ## 0.1.12
11
+ ### Patch Changes
12
+
13
+ - 254176b: **`TlsOptions.pfx`**: a client now takes its mutual-TLS certificate and key as one PKCS#12 file's bytes, unlocked with `passphrase`, the same as a server's `ServerTlsOptions.pfx`. A file the TLS library cannot load (a wrong passphrase, not PKCS#12, or a legacy RC2-40 file that Node.js on OpenSSL 3 refuses) rejects `connect()` with `MllpTlsConfigurationError` and the code `MLLP_TLS_PFX_REJECTED` before a socket is opened, and the client does not retry it; the message names `tls.pfx` and never the file or the passphrase. A caller passing `cert` and `key` changes nothing.
14
+ - bdc3013: The reference now says what `connect()` rejects with when `destroy()` runs while it is still connecting, and how long a TLS server waits for a handshake. Over TCP or TLS, before or during the handshake, `connect()` rejects with an `MllpConnectionError` whose `phase` is `connect`; its `cause` is the reason passed to `destroy(reason)`, or with no reason an `Error` whose message is `closed before connect`, and it carries no `connectionCause`. A reason is the caller's own, so one whose message or `code` reads like a TLS failure (the word `alert`, an `ERR_SSL_` code, `EPROTO`, a certificate verification code) is no longer sorted into `tls-handshake` or `tls-verify`: it is carried as the cause as it is. The first `destroy()` decides: a second call before `connect()` settles, with or without a reason, no longer changes how a TLS `connect()` is classified. A TLS server sets no handshake time limit of its own: on Node.js the runtime's 120 second default applies, after which the socket is closed and `'tlsClientError'` fires with code `ERR_TLS_HANDSHAKE_TIMEOUT`. Until then such a connection holds a `maxConnections` place, and `deadPeerTimeoutMs` does not cover it. On Bun and Deno we have not measured what bounds a handshake. The one change in behaviour: a caller who read a `tls-handshake` or `tls-verify` cause off a `connect()` they ended with their own `destroy(reason)` now sees no `connectionCause`, and tells that case apart by `err.cause === reason`.
15
+ - b7fc91b: The client and the server now turn Nagle's algorithm off (TCP_NODELAY) on every socket they open or accept, plain and TLS, reconnects included. With it on, an ACK or a message written while an earlier one was still unacknowledged at the TCP level waited for the peer's delayed TCP acknowledgment, 40 ms on Linux, so on a link with irregular traffic some acknowledgments took up to about 40 ms longer than they needed to. A new `noDelay` option on `ClientOptions`, `StarterClientOptions` and `ServerOptions`, default `true`, sets it; pass `noDelay: false` to keep the operating system's default. Nothing else changes for a caller.
16
+ - 48a7fff: `send(payload, { ackTimeoutMs })` now bounds that send's wait for its acknowledgment, as its name says. It used to bound only the wait for queue room under `onBackpressure: "wait"`, and the acknowledgment wait always ran on the client's `ackTimeoutMs`, so a send asking for 5 s waited the client's 30 s. A caller who passes a per-send `ackTimeoutMs` gets that bound now, shorter or longer than the client's; one who wanted the old behavior, the client-wide bound on the acknowledgment, drops the per-send option or passes the client's value. Under `onBackpressure: "wait"` it still bounds the wait for room too, and the acknowledgment wait starts afresh once the send is written. A send without the option behaves exactly as before.
17
+ - ae156dc: Two additions an engine in front of this package needs to pass through.
18
+
19
+ - **`ServerTlsOptions.pfx`** takes a PKCS#12 file's bytes in place of `cert` and `key`, unlocked with `passphrase`. A file the TLS library cannot load (a wrong passphrase, not PKCS#12, or a legacy RC2-40 file that Node.js on OpenSSL 3 refuses) rejects `listen()` with `MllpTlsConfigurationError` and the new code `MLLP_TLS_PFX_REJECTED`, before anything is bound; the message names `tls.pfx` and never the file or the passphrase. `ServerTlsOptions.cert` and `key` are now optional in the type, since `pfx` can stand in for them; a server given neither pair nor file now throws a `TypeError` when it is created, where before it was refused by the type and failed every handshake if the type was bypassed. A caller passing `cert` and `key` changes nothing.
20
+ - **`selectAckCode({ msh15, msh16, outcome })`** returns the acknowledgement code to send, by the same table the server's auto-ACK uses: the accept-mode `CA`/`CE`/`CR` where MSH-15 asks for an accept acknowledgement on that outcome, the outcome itself otherwise. It also reports the mode, whether MSH-16 asks for an application acknowledgement, and whether either field held a value outside Table 0155. New types `AckCodeSelection` and `AckCodeSelectionInput`.
21
+ - 1357fe3: The README now matches what ships. Its API section names all four code subpaths, `@cosyte/mllp/arbitraries` among them, where it said three, and its Documentation list links every page of the documentation site in the sidebar's order, where it linked 10 of the 19. Nothing changes for a caller.
22
+ - d1abef3: **`pfx` together with `cert` or `key` is now refused.** A client or server given a PKCS#12 file in `tls.pfx` and also `tls.cert` or `tls.key` used to be accepted, and Node.js loaded the file last, so the file's certificate was presented and the `cert` passed went unused with nothing to say so. Now `createClient`, `createServer` and both constructors throw `MllpTlsConfigurationError` with the new stable code `MLLP_TLS_CREDENTIAL_CONFLICT`; the message names the options and never their values. A caller passing all three must drop either `pfx` or the `cert` and `key` pair. The `MLLP_TLS_PFX_REJECTED` message now ends with "no socket was opened" rather than "nothing was bound", so it reads right when a client raises it.
23
+ - b065e1e: The cipher and Diffie-Hellman options now fail loudly on a runtime that would not enforce them, `maxConnections` holds with its event on every runtime, and `destroy()` during `connect()` settles the promise. Before a cipher list or Diffie-Hellman parameters reach the runtime, probes that carry none of your configuration check that its TLS library enforces that kind of option. Where it does not, `connect()` or `listen()` rejects with an `MllpTlsConfigurationError` carrying one of two new codes, both exported: `MLLP_TLS_CIPHER_LIST_UNENFORCEABLE` (for `ciphers` and a client's `atnaTransportSecurity`) and `MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE` (for `dhParameters` and a server's `atnaTransportSecurity`). Under Deno, whose `node:tls` took these options and applied none of them with no error, all three options are now refused. Under Bun, `atnaTransportSecurity` and `dhParameters` are refused with Bun's own refusal as the `cause`, where before a server with either threw a plain `Error` from `createServer`; `ciphers` still works on Bun. Node.js passes every probe, so nothing changes there. `TlsConfigurationErrorCode` gains the two members, so a caller that switches over every member of that union needs a case for each; both are classified permanent, so a client never retries them. `ServerOptions.maxConnections` is now counted by the server itself instead of by the runtime's listener, so `connectionRejected` fires under Deno too, where before the connection was closed and nothing reported it. `MllpClient.destroy()` called while `connect()` is still connecting now rejects that `connect()` with an `MllpConnectionError` (`phase: 'connect'`); with no reason given it used to leave the promise pending for good.
24
+ - 419c12d: Under Bun, a TLS server with `maxConnections` now gives a connection's place back when that connection closes. Bun hands the server's accept and secure-connection events the same socket object, and the transport that took the socket over removed the listener that counted its close, so every TLS connection that completed a handshake held its place for good: once `maxConnections` had been reached, the server closed every new connection at accept. Node.js and Deno were not affected, and plaintext servers were not affected on any runtime. Nothing changes for a caller.
25
+ - 419c12d: The TLS enforcement probes now run once per process instead of on every connect. A client with `atnaTransportSecurity` built five throwaway TLS contexts on each connect and each reconnect, and one with `ciphers` built one; now only the first connect in a process builds them, and every later connect, reconnect and server reads the result it found. A probe's input is a fixed value and the runtime does not change under a running process, so what is refused and what is accepted is unchanged. Nothing changes for a caller.
26
+
3
27
  ## 0.1.11
4
28
  ### Patch Changes
5
29
 
package/README.md CHANGED
@@ -207,7 +207,7 @@ table, the TLS 1.2 floor (IHE ATNA ITI-19), the typed failure modes (`tls-verify
207
207
 
208
208
  ## API
209
209
 
210
- Three code subpaths ship, plus `@cosyte/mllp/package.json`:
210
+ Four code subpaths ship, plus `@cosyte/mllp/package.json`:
211
211
 
212
212
  - **`@cosyte/mllp`** is the whole transport: `createServer` and `createStarterServer`, `createClient`
213
213
  and `createStarterClient`, `encodeFrame` and `FrameReader`, `Connection`, `buildRawAck`, the typed
@@ -216,6 +216,11 @@ Three code subpaths ship, plus `@cosyte/mllp/package.json`:
216
216
  test that can run over it should.
217
217
  - **`@cosyte/mllp/ack-from-hl7`** builds acknowledgments from a parsed message, or from raw bytes it
218
218
  parses through the peer, and is the one place the optional `@cosyte/hl7` peer is needed.
219
+ - **`@cosyte/mllp/arbitraries`** is fast-check generators for property-testing code you build on
220
+ the transport: `payload`, `frame`, `chunked` and `stream` for canonical bytes, `messyStream` for
221
+ the framing quirks a lenient reader accepts, and `hostileInput` for streams a reader may refuse
222
+ but must never hang or crash on. It needs the optional `fast-check` peer, and imports nothing
223
+ from the library at run time.
219
224
 
220
225
  What comes with them:
221
226
 
@@ -256,25 +261,31 @@ The full reference is on [docs.cosyte.com/mllp](https://docs.cosyte.com/mllp); s
256
261
  ## Documentation
257
262
 
258
263
  The full reference lives at [docs.cosyte.com/mllp](https://docs.cosyte.com/mllp), built from this
259
- repository's [`docs-content/`](https://github.com/cosyte/mllp/tree/main/docs-content). Start with
260
- these pages:
261
-
262
- - [Send messages](https://github.com/cosyte/mllp/blob/main/docs-content/send-messages.md) and
263
- [Receive and acknowledge messages](https://github.com/cosyte/mllp/blob/main/docs-content/receive-messages.md): the two everyday tasks.
264
- - [ACKs and the commit contract](https://github.com/cosyte/mllp/blob/main/docs-content/acks.md):
265
- the code auto-ACK selects, correlation on the client, enhanced mode, and the ack-from-hl7 builder.
266
- - [Framing and tolerance](https://github.com/cosyte/mllp/blob/main/docs-content/framing.md): the
267
- wire format, the opt-in tolerance flags, the stable warning codes, and what throws.
268
- - [Connection, reconnect and backpressure](https://github.com/cosyte/mllp/blob/main/docs-content/reliability.md):
269
- the six-state connection machine, backoff, dead-peer detection, and what `close()` does.
270
- - [Secure a link with TLS](https://github.com/cosyte/mllp/blob/main/docs-content/tls.md): mutual TLS,
271
- verification, bind safety, the TLS 1.2 floor, and the typed failure modes.
272
- - [Test your code and verify an engine](https://github.com/cosyte/mllp/blob/main/docs-content/testing.md):
273
- the in-memory transport, and the differential harness for the engine you integrate with.
274
- - [Warning and error codes](https://github.com/cosyte/mllp/blob/main/docs-content/warning-and-error-codes.md)
275
- and [Troubleshooting](https://github.com/cosyte/mllp/blob/main/docs-content/troubleshooting.md): every stable code, and what to do when a link fails.
276
- - [Known limitations and non-goals](https://github.com/cosyte/mllp/blob/main/docs-content/limitations.md):
277
- what not to trust this transport to do.
264
+ repository's [`docs-content/`](https://github.com/cosyte/mllp/tree/main/docs-content). Every page
265
+ is listed here, in the order and the groups of the site's sidebar:
266
+
267
+ - [Overview](https://github.com/cosyte/mllp/blob/main/docs-content/intro.md): what the package is and what it leaves to you.
268
+ - [Installation](https://github.com/cosyte/mllp/blob/main/docs-content/installation.md) and [Quickstart](https://github.com/cosyte/mllp/blob/main/docs-content/quickstart.md): install it, then
269
+ start a server, send it a message and read the acknowledgment.
270
+ - How-to guides:
271
+ - [Send messages](https://github.com/cosyte/mllp/blob/main/docs-content/send-messages.md)
272
+ - [Receive and acknowledge messages](https://github.com/cosyte/mllp/blob/main/docs-content/receive-messages.md)
273
+ - [Tolerate a sender's framing quirks](https://github.com/cosyte/mllp/blob/main/docs-content/tolerate-sender-quirks.md)
274
+ - [Secure a link with TLS](https://github.com/cosyte/mllp/blob/main/docs-content/tls.md)
275
+ - [Build ACKs with @cosyte/hl7](https://github.com/cosyte/mllp/blob/main/docs-content/build-acks-from-hl7.md)
276
+ - [Test your code and verify an engine](https://github.com/cosyte/mllp/blob/main/docs-content/testing.md)
277
+ - [Property-test your own code with generated MLLP streams](https://github.com/cosyte/mllp/blob/main/docs-content/property-test-your-code.md)
278
+ - Explanation:
279
+ - [ACKs and the commit contract](https://github.com/cosyte/mllp/blob/main/docs-content/acks.md)
280
+ - [Framing and tolerance](https://github.com/cosyte/mllp/blob/main/docs-content/framing.md)
281
+ - [Connection, reconnect and backpressure](https://github.com/cosyte/mllp/blob/main/docs-content/reliability.md)
282
+ - [Known limitations and non-goals](https://github.com/cosyte/mllp/blob/main/docs-content/limitations.md): what not to trust this transport to do.
283
+ - Reference:
284
+ - [Warning and error codes](https://github.com/cosyte/mllp/blob/main/docs-content/warning-and-error-codes.md)
285
+ - [Conformance statement](https://github.com/cosyte/mllp/blob/main/docs-content/conformance.md)
286
+ - [Troubleshooting](https://github.com/cosyte/mllp/blob/main/docs-content/troubleshooting.md): what to do when a link fails, symptom by symptom.
287
+ - [Testing and quality](https://github.com/cosyte/mllp/blob/main/docs-content/testing-and-quality.md) and [Performance](https://github.com/cosyte/mllp/blob/main/docs-content/performance.md): how we
288
+ test the package, and what we measure.
278
289
 
279
290
  ## Support
280
291
 
package/TRADEMARKS.md CHANGED
@@ -5,8 +5,10 @@ or sponsored by** any company named in this repository or its documentation.
5
5
 
6
6
  ## Why these names appear
7
7
 
8
- This package names other systems in two places: to identify the engines its differential test
9
- harness runs against, and to state plainly which engines it has **not** been verified against.
8
+ This package names other systems in three places: to identify the engines its differential test
9
+ harness runs against, to state plainly which engines it has **not** been verified against, and to
10
+ point a reader moving an interface from another product or library to the setting that does the same
11
+ job here.
10
12
 
11
13
  Every reference is **descriptive**: it identifies whose engine was tested against, or whose behaviour is explicitly not covered. Naming a system is the only way to say
12
14
  whether a library works with it.
@@ -24,6 +26,7 @@ including an explicit statement that Epic and Cerner are **not** part of the har
24
26
  | Mirth Connect, NextGen | Named as an engine in the differential test harness. |
25
27
  | Google Cloud Healthcare | Named as an engine in the differential test harness (the MLLP adapter). |
26
28
  | Epic, Cerner | Named in `docs-content/limitations.md` to record that this package is **not** differentially verified against them. |
29
+ | HAPI, python-hl7, simple-hl7 | Named in `docs-content/coming-from-an-engine.md`, in the table that maps their listener and acknowledgment settings to ours. |
27
30
 
28
31
  All product names, logos, and brands are the property of their respective owners. Use of a name here
29
32
  does not imply any affiliation with, or endorsement by, its owner. If you own one of these marks and
@@ -2,7 +2,7 @@
2
2
 
3
3
  var module$1 = require('module');
4
4
 
5
- // node_modules/.pnpm/tsup@9.0.0_postcss@8.5.32_tsx@4.23.15_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
5
+ // node_modules/.pnpm/tsup@9.0.0_postcss@8.5.32_tsx@4.23.15_typescript@5.9.3_yaml@2.9.1/node_modules/tsup/assets/cjs_shims.js
6
6
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
7
7
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
8
8