@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/CHANGELOG.md +21 -0
- package/README.md +3 -0
- package/TRADEMARKS.md +5 -5
- package/dist/ack-from-hl7/index.cjs +13 -14
- package/dist/ack-from-hl7/index.cjs.map +1 -1
- package/dist/ack-from-hl7/index.d.cts +1 -0
- package/dist/ack-from-hl7/index.d.ts +1 -0
- package/dist/ack-from-hl7/index.mjs +6 -5
- package/dist/ack-from-hl7/index.mjs.map +1 -1
- package/dist/arbitraries/index.cjs +17 -16
- package/dist/arbitraries/index.cjs.map +1 -1
- package/dist/arbitraries/index.d.cts +1 -0
- package/dist/arbitraries/index.d.ts +1 -0
- package/dist/arbitraries/index.mjs +1 -0
- package/dist/arbitraries/index.mjs.map +1 -1
- package/dist/index.cjs +73 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -56
- package/dist/index.d.ts +61 -56
- package/dist/index.mjs +42 -49
- package/dist/index.mjs.map +1 -1
- package/dist/{registry-CyGU_l8N.d.cts → registry-BPOSRmcX.d.cts} +2 -2
- package/dist/{registry-CyGU_l8N.d.ts → registry-BPOSRmcX.d.ts} +2 -2
- package/dist/testing/index.cjs +3 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.mjs +2 -0
- package/dist/testing/index.mjs.map +1 -1
- package/dist/{index-CD8V2Mtk.d.cts → transport-2Zo_VBmG.d.cts} +3 -16
- package/dist/{index-CD8V2Mtk.d.ts → transport-2Zo_VBmG.d.ts} +3 -16
- package/package.json +18 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { W as WarningCode, M as MllpWarning } from './registry-
|
|
2
|
-
export { c as createWarning } from './registry-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { W as WarningCode, M as MllpWarning } from './registry-BPOSRmcX.js';
|
|
2
|
+
export { c as createWarning } from './registry-BPOSRmcX.js';
|
|
3
|
+
import { Buffer } from 'node:buffer';
|
|
4
|
+
import { T as Transport } from './transport-2Zo_VBmG.js';
|
|
5
5
|
import { Socket } from 'node:net';
|
|
6
6
|
import { TLSSocket } from 'node:tls';
|
|
7
|
+
import { EventEmitter } from 'node:events';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Typed framing error class for unrecoverable MLLP wire-format violations.
|
|
@@ -109,7 +110,7 @@ interface EncoderOptions {
|
|
|
109
110
|
*
|
|
110
111
|
* Default: `false` (strict, throws on delimiter bytes).
|
|
111
112
|
*/
|
|
112
|
-
allowDelimiterBytesInPayload?: boolean;
|
|
113
|
+
readonly allowDelimiterBytesInPayload?: boolean;
|
|
113
114
|
/**
|
|
114
115
|
* Called for each offending delimiter byte when `allowDelimiterBytesInPayload` is `true`.
|
|
115
116
|
* Invocation is wrapped in try/catch, a throwing handler does not interrupt encoding.
|
|
@@ -122,7 +123,7 @@ interface EncoderOptions {
|
|
|
122
123
|
* });
|
|
123
124
|
* ```
|
|
124
125
|
*/
|
|
125
|
-
onWarning?: (w: MllpWarning) => void;
|
|
126
|
+
readonly onWarning?: (w: MllpWarning) => void;
|
|
126
127
|
}
|
|
127
128
|
/**
|
|
128
129
|
* Encode `payload` in canonical MLLP framing: `VT (0x0B) + payload + FS (0x1C) + CR (0x0D)`.
|
|
@@ -154,7 +155,7 @@ interface EncoderOptions {
|
|
|
154
155
|
* });
|
|
155
156
|
* ```
|
|
156
157
|
*/
|
|
157
|
-
declare function encodeFrame(payload: Buffer,
|
|
158
|
+
declare function encodeFrame(payload: Buffer, options?: EncoderOptions): Buffer;
|
|
158
159
|
|
|
159
160
|
/**
|
|
160
161
|
* MLLP frame decoder, stateful 3-state FSM for chunked byte-stream parsing.
|
|
@@ -214,29 +215,29 @@ interface FrameReaderOptions {
|
|
|
214
215
|
* @param warnings - Framing warnings emitted during decoding of this specific frame.
|
|
215
216
|
* Empty array when no tolerance deviations were detected.
|
|
216
217
|
*/
|
|
217
|
-
onFrame: (payload: Buffer, byteOffset: number, warnings: readonly MllpWarning[]) => void;
|
|
218
|
+
readonly onFrame: (payload: Buffer, byteOffset: number, warnings: readonly MllpWarning[]) => void;
|
|
218
219
|
/**
|
|
219
220
|
* Called for each tolerated framing deviation. Wrapped in try/catch.
|
|
220
221
|
* A throwing handler will not corrupt FSM state.
|
|
221
222
|
*/
|
|
222
|
-
onWarning?: (w: MllpWarning) => void;
|
|
223
|
+
readonly onWarning?: (w: MllpWarning) => void;
|
|
223
224
|
/**
|
|
224
225
|
* Maximum accumulated payload bytes before `MllpFramingError('MLLP_FRAME_TOO_LARGE')`.
|
|
225
226
|
* Default: 16 MiB (DoS prevention).
|
|
226
227
|
*/
|
|
227
|
-
maxFrameSizeBytes?: number;
|
|
228
|
+
readonly maxFrameSizeBytes?: number;
|
|
228
229
|
/**
|
|
229
230
|
* Tolerate FS without trailing CR when the next frame's VT follows it; emits
|
|
230
231
|
* `MLLP_FS_WITHOUT_CR`. Any other byte after the FS means the FS sat inside the frame, and the
|
|
231
232
|
* frame is refused whole with `MLLP_PAYLOAD_CONTAINS_FS`.
|
|
232
233
|
*/
|
|
233
|
-
allowFsOnly?: boolean;
|
|
234
|
+
readonly allowFsOnly?: boolean;
|
|
234
235
|
/** Tolerate FS+LF instead of FS+CR; emits `MLLP_LF_AFTER_FS`. */
|
|
235
|
-
allowLfAfterFs?: boolean;
|
|
236
|
+
readonly allowLfAfterFs?: boolean;
|
|
236
237
|
/** Tolerate missing leading VT; emits `MLLP_MISSING_LEADING_VT`. */
|
|
237
|
-
allowMissingLeadingVt?: boolean;
|
|
238
|
+
readonly allowMissingLeadingVt?: boolean;
|
|
238
239
|
/** Tolerate SP/TAB/LF/CR before VT; emits `MLLP_LEADING_WHITESPACE`. */
|
|
239
|
-
allowLeadingWhitespace?: boolean;
|
|
240
|
+
readonly allowLeadingWhitespace?: boolean;
|
|
240
241
|
/**
|
|
241
242
|
* When `true`, escalates the following tolerances to thrown `MllpFramingError`
|
|
242
243
|
* even if individual opt-ins (`allowFsOnly`, `allowLfAfterFs`, `allowMissingLeadingVt`,
|
|
@@ -254,7 +255,7 @@ interface FrameReaderOptions {
|
|
|
254
255
|
* const reader = new FrameReader({ onFrame: fn, strict: true });
|
|
255
256
|
* ```
|
|
256
257
|
*/
|
|
257
|
-
strict?: boolean;
|
|
258
|
+
readonly strict?: boolean;
|
|
258
259
|
}
|
|
259
260
|
/**
|
|
260
261
|
* Stateful MLLP frame decoder. Feed raw TCP byte chunks via `push(chunk)`.
|
|
@@ -615,6 +616,7 @@ interface SecurityWarning {
|
|
|
615
616
|
*
|
|
616
617
|
* @packageDocumentation
|
|
617
618
|
*/
|
|
619
|
+
|
|
618
620
|
/**
|
|
619
621
|
* A PEM-encoded credential (certificate, key, or CA), matching Node's
|
|
620
622
|
* `tls.connect`/`tls.createServer` input shape, a single PEM string/Buffer,
|
|
@@ -1163,9 +1165,9 @@ declare class MllpTlsConfigurationError extends Error {
|
|
|
1163
1165
|
* Construct a TLS configuration error.
|
|
1164
1166
|
*
|
|
1165
1167
|
* @param code - The stable configuration-error code; also selects the message.
|
|
1166
|
-
* @param
|
|
1168
|
+
* @param options - Optional underlying `cause` from the TLS library.
|
|
1167
1169
|
*/
|
|
1168
|
-
constructor(code: TlsConfigurationErrorCode,
|
|
1170
|
+
constructor(code: TlsConfigurationErrorCode, options?: {
|
|
1169
1171
|
cause?: Error;
|
|
1170
1172
|
});
|
|
1171
1173
|
}
|
|
@@ -1199,6 +1201,7 @@ declare class MllpTlsConfigurationError extends Error {
|
|
|
1199
1201
|
*
|
|
1200
1202
|
* @packageDocumentation
|
|
1201
1203
|
*/
|
|
1204
|
+
|
|
1202
1205
|
/**
|
|
1203
1206
|
* The four TLS 1.2 cipher suites ITI TF-2 §3.19.6.2.3 names, in the OpenSSL
|
|
1204
1207
|
* spelling a cipher-list string is written in. Their IANA spellings, which are
|
|
@@ -1535,15 +1538,15 @@ interface ConnectionStats {
|
|
|
1535
1538
|
*/
|
|
1536
1539
|
interface ConnectionOptions {
|
|
1537
1540
|
/** The transport this Connection will drive. */
|
|
1538
|
-
transport: Transport;
|
|
1541
|
+
readonly transport: Transport;
|
|
1539
1542
|
/** Called for each decoded MLLP frame (raw payload bytes, framing stripped). */
|
|
1540
|
-
onMessage?: (payload: Buffer) => void;
|
|
1543
|
+
readonly onMessage?: (payload: Buffer) => void;
|
|
1541
1544
|
/** Per-connection warning subscriber. Replaces previous subscription. */
|
|
1542
|
-
onWarning?: (w: MllpWarning) => void;
|
|
1545
|
+
readonly onWarning?: (w: MllpWarning) => void;
|
|
1543
1546
|
/** Drain timeout used by close() (default: 30_000 ms). */
|
|
1544
|
-
drainTimeoutMs?: number;
|
|
1547
|
+
readonly drainTimeoutMs?: number;
|
|
1545
1548
|
/** FrameReader options (tolerance, maxFrameSizeBytes). onFrame/onWarning are managed internally. */
|
|
1546
|
-
framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
|
|
1549
|
+
readonly framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
|
|
1547
1550
|
}
|
|
1548
1551
|
/**
|
|
1549
1552
|
* A single MLLP connection wrapping a {@link Transport} with a 6-state FSM,
|
|
@@ -1696,14 +1699,14 @@ declare class Connection extends EventEmitter {
|
|
|
1696
1699
|
* `destroy()` during a long drain therefore ends the wait at once, not at the drain timeout.
|
|
1697
1700
|
* - If `CLOSED` or `DISCONNECTED`: no-op.
|
|
1698
1701
|
*
|
|
1699
|
-
* @param
|
|
1702
|
+
* @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
|
|
1700
1703
|
*
|
|
1701
1704
|
* @example
|
|
1702
1705
|
* ```typescript
|
|
1703
1706
|
* await conn.close({ drainTimeoutMs: 5_000 });
|
|
1704
1707
|
* ```
|
|
1705
1708
|
*/
|
|
1706
|
-
close(
|
|
1709
|
+
close(options?: {
|
|
1707
1710
|
drainTimeoutMs?: number;
|
|
1708
1711
|
}): Promise<void>;
|
|
1709
1712
|
/**
|
|
@@ -2320,17 +2323,17 @@ interface ServerOptions {
|
|
|
2320
2323
|
*
|
|
2321
2324
|
* May be sync or async; an async handler is awaited in commit-gated mode.
|
|
2322
2325
|
*/
|
|
2323
|
-
onMessage?: (payload: Buffer, meta: MessageMeta, conn: Connection) => void | Promise<void>;
|
|
2326
|
+
readonly onMessage?: (payload: Buffer, meta: MessageMeta, conn: Connection) => void | Promise<void>;
|
|
2324
2327
|
/**
|
|
2325
2328
|
* FrameReader tolerance options applied to every accepted connection.
|
|
2326
2329
|
* Merged with SERVER_DEFAULT_FRAMING, caller-supplied values override defaults.
|
|
2327
2330
|
* `onFrame` and `onWarning` are managed internally and must not be supplied here.
|
|
2328
2331
|
*/
|
|
2329
|
-
framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
|
|
2332
|
+
readonly framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
|
|
2330
2333
|
/**
|
|
2331
2334
|
* Per-connection warning subscriber. Called for every framing warning on every connection.
|
|
2332
2335
|
*/
|
|
2333
|
-
onWarning?: (w: MllpWarning) => void;
|
|
2336
|
+
readonly onWarning?: (w: MllpWarning) => void;
|
|
2334
2337
|
/**
|
|
2335
2338
|
* Auto-ACK mode. When set, the server builds and sends the ACK for each message.
|
|
2336
2339
|
*
|
|
@@ -2350,14 +2353,14 @@ interface ServerOptions {
|
|
|
2350
2353
|
* The `'message'` event always fires BEFORE the ACK is sent. Do NOT call
|
|
2351
2354
|
* `conn.send()` in `onMessage` when `autoAck` is set, this results in two ACKs.
|
|
2352
2355
|
*/
|
|
2353
|
-
autoAck?: "AA" | ((payload: Buffer, meta: MessageMeta, conn: Connection) => Buffer | Promise<Buffer>);
|
|
2356
|
+
readonly autoAck?: "AA" | ((payload: Buffer, meta: MessageMeta, conn: Connection) => Buffer | Promise<Buffer>);
|
|
2354
2357
|
/**
|
|
2355
2358
|
* TCP keepalive probe interval in ms.
|
|
2356
2359
|
* Calls `socket.setKeepAlive(true, ms)` on each accepted socket.
|
|
2357
2360
|
* Uses OS TCP stack to detect dead peers (half-open, network partitions).
|
|
2358
2361
|
* Distinct from `deadPeerTimeoutMs` (application-level idle close).
|
|
2359
2362
|
*/
|
|
2360
|
-
keepaliveIntervalMs?: number;
|
|
2363
|
+
readonly keepaliveIntervalMs?: number;
|
|
2361
2364
|
/**
|
|
2362
2365
|
* Whether to turn off Nagle's algorithm (`socket.setNoDelay(noDelay)`) on each accepted
|
|
2363
2366
|
* socket. With it on (`false` here), an ACK written while an earlier one is still
|
|
@@ -2366,14 +2369,14 @@ interface ServerOptions {
|
|
|
2366
2369
|
*
|
|
2367
2370
|
* @default true
|
|
2368
2371
|
*/
|
|
2369
|
-
noDelay?: boolean;
|
|
2372
|
+
readonly noDelay?: boolean;
|
|
2370
2373
|
/**
|
|
2371
2374
|
* Application-level idle close timeout in ms.
|
|
2372
2375
|
* If no HL7 messages are received on a connection for this interval, the connection
|
|
2373
2376
|
* is destroyed via `conn.destroy(new Error('idle timeout'))`.
|
|
2374
2377
|
* Resets on every `'message'` event. Distinct from `keepaliveIntervalMs` (OS TCP probe).
|
|
2375
2378
|
*/
|
|
2376
|
-
deadPeerTimeoutMs?: number;
|
|
2379
|
+
readonly deadPeerTimeoutMs?: number;
|
|
2377
2380
|
/**
|
|
2378
2381
|
* Graceful drain timeout passed to `conn.close()` during `server.close()`: the longest
|
|
2379
2382
|
* `close()` waits for the handlers still running and their acknowledgements. A handler still
|
|
@@ -2386,7 +2389,7 @@ interface ServerOptions {
|
|
|
2386
2389
|
* are still answered, and a connection waits at most this long for their handlers before it is
|
|
2387
2390
|
* destroyed.
|
|
2388
2391
|
*/
|
|
2389
|
-
drainTimeoutMs?: number;
|
|
2392
|
+
readonly drainTimeoutMs?: number;
|
|
2390
2393
|
/**
|
|
2391
2394
|
* Enable TLS (MLLPS) for this server. When set, the server binds a
|
|
2392
2395
|
* `tls.Server` instead of a plain `net.Server`, consumes `'secureConnection'`
|
|
@@ -2405,7 +2408,7 @@ interface ServerOptions {
|
|
|
2405
2408
|
*
|
|
2406
2409
|
* @default undefined (plaintext TCP)
|
|
2407
2410
|
*/
|
|
2408
|
-
tls?: ServerTlsOptions;
|
|
2411
|
+
readonly tls?: ServerTlsOptions;
|
|
2409
2412
|
/**
|
|
2410
2413
|
* Opt-in required to bind a wildcard host, a bind-safety guardrail.
|
|
2411
2414
|
* Without this flag, `listen()` rejects a wildcard host in
|
|
@@ -2422,7 +2425,7 @@ interface ServerOptions {
|
|
|
2422
2425
|
*
|
|
2423
2426
|
* @default false
|
|
2424
2427
|
*/
|
|
2425
|
-
allowWildcardBind?: boolean;
|
|
2428
|
+
readonly allowWildcardBind?: boolean;
|
|
2426
2429
|
/**
|
|
2427
2430
|
* The most connections this server holds at once. A connection that arrives while the server
|
|
2428
2431
|
* already holds this many is closed at accept: it never reaches `onMessage` or the
|
|
@@ -2443,7 +2446,7 @@ interface ServerOptions {
|
|
|
2443
2446
|
*
|
|
2444
2447
|
* @default undefined (no cap)
|
|
2445
2448
|
*/
|
|
2446
|
-
maxConnections?: number;
|
|
2449
|
+
readonly maxConnections?: number;
|
|
2447
2450
|
}
|
|
2448
2451
|
/**
|
|
2449
2452
|
* Options for `createStarterServer()`, the "three lines of code" factory.
|
|
@@ -2467,13 +2470,13 @@ interface ServerOptions {
|
|
|
2467
2470
|
*/
|
|
2468
2471
|
interface StarterServerOptions extends ServerOptions {
|
|
2469
2472
|
/** Port to listen on. */
|
|
2470
|
-
port: number;
|
|
2473
|
+
readonly port: number;
|
|
2471
2474
|
/**
|
|
2472
2475
|
* Host to bind to. Default `'127.0.0.1'` (bind-safety hardening,
|
|
2473
2476
|
* was `'0.0.0.0'`; binding all interfaces now requires
|
|
2474
2477
|
* `ServerOptions.allowWildcardBind: true`).
|
|
2475
2478
|
*/
|
|
2476
|
-
host?: string;
|
|
2479
|
+
readonly host?: string;
|
|
2477
2480
|
/**
|
|
2478
2481
|
* Register `process.once('SIGTERM')` and `process.once('SIGINT')` handlers that
|
|
2479
2482
|
* call `server.close()` then `process.exit(0)`. Default: `false`.
|
|
@@ -2482,7 +2485,7 @@ interface StarterServerOptions extends ServerOptions {
|
|
|
2482
2485
|
* `process.listenerCount('SIGTERM') === 0` after close() completes, preventing
|
|
2483
2486
|
* handler accumulation across test instances or multiple server restarts.
|
|
2484
2487
|
*/
|
|
2485
|
-
handleSignals?: boolean;
|
|
2488
|
+
readonly handleSignals?: boolean;
|
|
2486
2489
|
}
|
|
2487
2490
|
/**
|
|
2488
2491
|
* MLLP TCP server, wraps `net.Server` without extending it.
|
|
@@ -2696,8 +2699,8 @@ declare class MllpServer extends EventEmitter {
|
|
|
2696
2699
|
* the server and does NOT settle the in-flight `listen()`, which simply
|
|
2697
2700
|
* continues and settles on its own bind outcome.
|
|
2698
2701
|
*
|
|
2699
|
-
* @param
|
|
2700
|
-
* @param
|
|
2702
|
+
* @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
|
|
2703
|
+
* @param options.signal - AbortSignal to cancel the close operation. On abort, all
|
|
2701
2704
|
* active connections are destroyed and the promise rejects with AbortError.
|
|
2702
2705
|
*
|
|
2703
2706
|
* @example
|
|
@@ -2705,7 +2708,7 @@ declare class MllpServer extends EventEmitter {
|
|
|
2705
2708
|
* await server.close({ drainTimeoutMs: 5_000 });
|
|
2706
2709
|
* ```
|
|
2707
2710
|
*/
|
|
2708
|
-
close(
|
|
2711
|
+
close(options?: {
|
|
2709
2712
|
drainTimeoutMs?: number;
|
|
2710
2713
|
signal?: AbortSignal;
|
|
2711
2714
|
}): Promise<void>;
|
|
@@ -2992,10 +2995,10 @@ declare class MllpAckError extends Error {
|
|
|
2992
2995
|
readonly ackCode: NegativeAckCode;
|
|
2993
2996
|
/**
|
|
2994
2997
|
* @param message - Diagnostic text for the thrower. Never placed on the wire (may carry PHI).
|
|
2995
|
-
* @param
|
|
2996
|
-
* @param
|
|
2998
|
+
* @param options.ackCode - Negative code to return. Default `'AE'`.
|
|
2999
|
+
* @param options.cause - Underlying error, preserved on `.cause`.
|
|
2997
3000
|
*/
|
|
2998
|
-
constructor(message: string,
|
|
3001
|
+
constructor(message: string, options?: {
|
|
2999
3002
|
ackCode?: NegativeAckCode;
|
|
3000
3003
|
cause?: unknown;
|
|
3001
3004
|
});
|
|
@@ -3105,7 +3108,7 @@ declare function rawAckUncorrelatable(payload: Buffer): boolean;
|
|
|
3105
3108
|
* degrading the side that had been **right**: `buildRawAck` began emitting a positive `AA`
|
|
3106
3109
|
* with an empty MSA-2, silently, for a message whose MSH-10 was plainly present. Agreement
|
|
3107
3110
|
* is not the goal; agreeing on the *correct*, *tolerant* answer is. A lenient reader may
|
|
3108
|
-
* never drop data that is there (Postel's Law
|
|
3111
|
+
* never drop data that is there (Postel's Law).
|
|
3109
3112
|
*
|
|
3110
3113
|
* **The fail-safe downgrade: never a positive `AA`/`CA` it cannot correlate**
|
|
3111
3114
|
*
|
|
@@ -3746,8 +3749,9 @@ interface ClientOptions {
|
|
|
3746
3749
|
* friendly.
|
|
3747
3750
|
*
|
|
3748
3751
|
* `warningsByCode` keys are constrained to the public {@link WarningCode}
|
|
3749
|
-
* union,
|
|
3750
|
-
*
|
|
3752
|
+
* union, held at the type boundary. The set may grow in any release, so
|
|
3753
|
+
* keep a default branch; removing or renaming a code is a change a caller
|
|
3754
|
+
* must act on.
|
|
3751
3755
|
*
|
|
3752
3756
|
* @example
|
|
3753
3757
|
* ```typescript
|
|
@@ -4022,7 +4026,7 @@ declare class MllpClient extends EventEmitter {
|
|
|
4022
4026
|
* await client.connect({ signal: ac.signal });
|
|
4023
4027
|
* ```
|
|
4024
4028
|
*/
|
|
4025
|
-
connect(
|
|
4029
|
+
connect(options?: {
|
|
4026
4030
|
signal?: AbortSignal;
|
|
4027
4031
|
}): Promise<void>;
|
|
4028
4032
|
/**
|
|
@@ -4281,16 +4285,16 @@ declare class MllpClient extends EventEmitter {
|
|
|
4281
4285
|
* ```
|
|
4282
4286
|
*
|
|
4283
4287
|
* @param payload Raw bytes; MLLP framing is added internally via `encodeFrame`.
|
|
4284
|
-
* @param
|
|
4285
|
-
* @param
|
|
4288
|
+
* @param options.signal AbortSignal, aborting cancels the ACK wait.
|
|
4289
|
+
* @param options.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
|
|
4286
4290
|
* moment its bytes are flushed, in place of the client's `ackTimeoutMs`. Under
|
|
4287
4291
|
* `onBackpressure: "wait"` it also bounds the wait for queue room, and the
|
|
4288
4292
|
* acknowledgement wait then starts afresh once the send is written.
|
|
4289
|
-
* @param
|
|
4290
|
-
* @param
|
|
4293
|
+
* @param options.applicationAckTimeoutMs Per-send override of the second wait's bound.
|
|
4294
|
+
* @param options.onCommitAck Called with the commit disposition when the peer commits the
|
|
4291
4295
|
* message ahead of its application acknowledgement. See {@link CommitAckReport}.
|
|
4292
4296
|
*/
|
|
4293
|
-
send(payload: Buffer,
|
|
4297
|
+
send(payload: Buffer, options?: {
|
|
4294
4298
|
signal?: AbortSignal;
|
|
4295
4299
|
ackTimeoutMs?: number;
|
|
4296
4300
|
applicationAckTimeoutMs?: number;
|
|
@@ -4483,7 +4487,7 @@ declare class MllpClient extends EventEmitter {
|
|
|
4483
4487
|
* await client.close({ drainTimeoutMs: 5_000 });
|
|
4484
4488
|
* ```
|
|
4485
4489
|
*/
|
|
4486
|
-
close(
|
|
4490
|
+
close(options?: {
|
|
4487
4491
|
drainTimeoutMs?: number;
|
|
4488
4492
|
signal?: AbortSignal;
|
|
4489
4493
|
}): Promise<void>;
|
|
@@ -5178,6 +5182,7 @@ declare class MllpBackpressureError extends Error {
|
|
|
5178
5182
|
*
|
|
5179
5183
|
* @packageDocumentation
|
|
5180
5184
|
*/
|
|
5185
|
+
|
|
5181
5186
|
/**
|
|
5182
5187
|
* One send-and-await-response pair the harness runs against a peer.
|
|
5183
5188
|
*
|
|
@@ -5712,8 +5717,8 @@ declare function runDifferential(options?: DifferentialRunOptions): Promise<Diff
|
|
|
5712
5717
|
/**
|
|
5713
5718
|
* Package version marker exported from the `@cosyte/mllp` root.
|
|
5714
5719
|
*
|
|
5715
|
-
* Kept in lockstep with `package.json` by `
|
|
5716
|
-
* runs immediately after `changeset version`. The `: string` annotation is deliberate, without it
|
|
5720
|
+
* Kept in lockstep with `package.json` by `cosyte-process sync-version`, which the `version`
|
|
5721
|
+
* script runs immediately after `changeset version`. The `: string` annotation is deliberate, without it
|
|
5717
5722
|
* TypeScript infers the *literal* type (`declare const VERSION = "0.0.0"`), which leaks the current
|
|
5718
5723
|
* release into consumers' types and makes an equality check against any other version a compile
|
|
5719
5724
|
* error.
|
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,
|
|
69
|
-
const allow =
|
|
70
|
-
const 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 {
|
|
@@ -687,19 +684,17 @@ var MllpTlsConfigurationError = class _MllpTlsConfigurationError extends Error {
|
|
|
687
684
|
* Construct a TLS configuration error.
|
|
688
685
|
*
|
|
689
686
|
* @param code - The stable configuration-error code; also selects the message.
|
|
690
|
-
* @param
|
|
687
|
+
* @param options - Optional underlying `cause` from the TLS library.
|
|
691
688
|
*/
|
|
692
|
-
constructor(code,
|
|
689
|
+
constructor(code, options = {}) {
|
|
693
690
|
super(tlsConfigurationMessage(code));
|
|
694
691
|
this.code = code;
|
|
695
|
-
this.cause =
|
|
692
|
+
this.cause = options.cause;
|
|
696
693
|
if (Error.captureStackTrace) {
|
|
697
694
|
Error.captureStackTrace(this, _MllpTlsConfigurationError);
|
|
698
695
|
}
|
|
699
696
|
}
|
|
700
697
|
};
|
|
701
|
-
|
|
702
|
-
// src/transport/dh-parameters.ts
|
|
703
698
|
var BEGIN_BOUNDARY = "-----BEGIN DH PARAMETERS-----";
|
|
704
699
|
var END_BOUNDARY = "-----END DH PARAMETERS-----";
|
|
705
700
|
var BOM_SPELLINGS = [
|
|
@@ -1183,15 +1178,15 @@ var Connection = class extends EventEmitter {
|
|
|
1183
1178
|
* `destroy()` during a long drain therefore ends the wait at once, not at the drain timeout.
|
|
1184
1179
|
* - If `CLOSED` or `DISCONNECTED`: no-op.
|
|
1185
1180
|
*
|
|
1186
|
-
* @param
|
|
1181
|
+
* @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
|
|
1187
1182
|
*
|
|
1188
1183
|
* @example
|
|
1189
1184
|
* ```typescript
|
|
1190
1185
|
* await conn.close({ drainTimeoutMs: 5_000 });
|
|
1191
1186
|
* ```
|
|
1192
1187
|
*/
|
|
1193
|
-
async close(
|
|
1194
|
-
const timeout =
|
|
1188
|
+
async close(options = {}) {
|
|
1189
|
+
const timeout = options.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
|
|
1195
1190
|
if (this._state === "CLOSED" || this._state === "DISCONNECTED") return;
|
|
1196
1191
|
if (this._state === "CONNECTING" || this._state === "RECONNECTING") {
|
|
1197
1192
|
this._transition("CLOSED", "close() during " + this._state);
|
|
@@ -1810,13 +1805,13 @@ var MllpAckError = class extends Error {
|
|
|
1810
1805
|
ackCode;
|
|
1811
1806
|
/**
|
|
1812
1807
|
* @param message - Diagnostic text for the thrower. Never placed on the wire (may carry PHI).
|
|
1813
|
-
* @param
|
|
1814
|
-
* @param
|
|
1808
|
+
* @param options.ackCode - Negative code to return. Default `'AE'`.
|
|
1809
|
+
* @param options.cause - Underlying error, preserved on `.cause`.
|
|
1815
1810
|
*/
|
|
1816
|
-
constructor(message,
|
|
1817
|
-
super(message,
|
|
1811
|
+
constructor(message, options = {}) {
|
|
1812
|
+
super(message, options.cause !== void 0 ? { cause: options.cause } : void 0);
|
|
1818
1813
|
this.name = "MllpAckError";
|
|
1819
|
-
this.ackCode =
|
|
1814
|
+
this.ackCode = options.ackCode ?? "AE";
|
|
1820
1815
|
}
|
|
1821
1816
|
};
|
|
1822
1817
|
function resolveNackCode(err) {
|
|
@@ -1944,8 +1939,8 @@ var ORIGINAL_MODE = Object.freeze({
|
|
|
1944
1939
|
acceptCondition: "NE",
|
|
1945
1940
|
applicationCondition: "AL",
|
|
1946
1941
|
awaitsApplicationAck: false,
|
|
1947
|
-
|
|
1948
|
-
|
|
1942
|
+
acceptFieldUnrecognized: false,
|
|
1943
|
+
applicationFieldUnrecognized: false
|
|
1949
1944
|
});
|
|
1950
1945
|
function classifyOutboundAckMode(msh) {
|
|
1951
1946
|
if (msh === null) return ORIGINAL_MODE;
|
|
@@ -1959,8 +1954,8 @@ function classifyOutboundAckMode(msh) {
|
|
|
1959
1954
|
acceptCondition: accept.kind === "code" ? accept.code : "NE",
|
|
1960
1955
|
applicationCondition,
|
|
1961
1956
|
awaitsApplicationAck: applicationCondition !== "NE",
|
|
1962
|
-
|
|
1963
|
-
|
|
1957
|
+
acceptFieldUnrecognized: accept.kind === "unrecognised",
|
|
1958
|
+
applicationFieldUnrecognized: application.kind === "unrecognised"
|
|
1964
1959
|
});
|
|
1965
1960
|
}
|
|
1966
1961
|
function readAcceptCondition(msh) {
|
|
@@ -2488,8 +2483,8 @@ var MllpServer = class extends EventEmitter {
|
|
|
2488
2483
|
* the server and does NOT settle the in-flight `listen()`, which simply
|
|
2489
2484
|
* continues and settles on its own bind outcome.
|
|
2490
2485
|
*
|
|
2491
|
-
* @param
|
|
2492
|
-
* @param
|
|
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
|
|
2493
2488
|
* active connections are destroyed and the promise rejects with AbortError.
|
|
2494
2489
|
*
|
|
2495
2490
|
* @example
|
|
@@ -2497,8 +2492,8 @@ var MllpServer = class extends EventEmitter {
|
|
|
2497
2492
|
* await server.close({ drainTimeoutMs: 5_000 });
|
|
2498
2493
|
* ```
|
|
2499
2494
|
*/
|
|
2500
|
-
async close(
|
|
2501
|
-
const signal =
|
|
2495
|
+
async close(options = {}) {
|
|
2496
|
+
const signal = options.signal;
|
|
2502
2497
|
if (signal?.aborted) {
|
|
2503
2498
|
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
2504
2499
|
}
|
|
@@ -2521,7 +2516,7 @@ var MllpServer = class extends EventEmitter {
|
|
|
2521
2516
|
signal.addEventListener("abort", abortHandler, { once: true });
|
|
2522
2517
|
}) : null;
|
|
2523
2518
|
try {
|
|
2524
|
-
const drainTimeoutMs =
|
|
2519
|
+
const drainTimeoutMs = options.drainTimeoutMs ?? this._opts.drainTimeoutMs ?? 3e4;
|
|
2525
2520
|
if (abortPromise !== null) {
|
|
2526
2521
|
await Promise.race([this._drainAll(drainTimeoutMs), abortPromise]);
|
|
2527
2522
|
} else {
|
|
@@ -3973,8 +3968,8 @@ var MllpClient = class extends EventEmitter {
|
|
|
3973
3968
|
* await client.connect({ signal: ac.signal });
|
|
3974
3969
|
* ```
|
|
3975
3970
|
*/
|
|
3976
|
-
connect(
|
|
3977
|
-
const signal =
|
|
3971
|
+
connect(options = {}) {
|
|
3972
|
+
const signal = options.signal;
|
|
3978
3973
|
if (signal?.aborted) {
|
|
3979
3974
|
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
3980
3975
|
}
|
|
@@ -4858,17 +4853,17 @@ var MllpClient = class extends EventEmitter {
|
|
|
4858
4853
|
* ```
|
|
4859
4854
|
*
|
|
4860
4855
|
* @param payload Raw bytes; MLLP framing is added internally via `encodeFrame`.
|
|
4861
|
-
* @param
|
|
4862
|
-
* @param
|
|
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
|
|
4863
4858
|
* moment its bytes are flushed, in place of the client's `ackTimeoutMs`. Under
|
|
4864
4859
|
* `onBackpressure: "wait"` it also bounds the wait for queue room, and the
|
|
4865
4860
|
* acknowledgement wait then starts afresh once the send is written.
|
|
4866
|
-
* @param
|
|
4867
|
-
* @param
|
|
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
|
|
4868
4863
|
* message ahead of its application acknowledgement. See {@link CommitAckReport}.
|
|
4869
4864
|
*/
|
|
4870
|
-
send(payload,
|
|
4871
|
-
const signal =
|
|
4865
|
+
send(payload, options = {}) {
|
|
4866
|
+
const signal = options.signal;
|
|
4872
4867
|
if (signal?.aborted === true) {
|
|
4873
4868
|
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
4874
4869
|
}
|
|
@@ -4883,7 +4878,7 @@ var MllpClient = class extends EventEmitter {
|
|
|
4883
4878
|
const msh = readMshSegment(payload);
|
|
4884
4879
|
const controlId = this._correlateByControlId ? controlIdFromMsh(msh) : null;
|
|
4885
4880
|
const ackMode = classifyOutboundAckMode(msh);
|
|
4886
|
-
const twoPhase = this._twoPhaseStateFor(ackMode,
|
|
4881
|
+
const twoPhase = this._twoPhaseStateFor(ackMode, options);
|
|
4887
4882
|
const correlator = this._correlator;
|
|
4888
4883
|
const conn = this._connection;
|
|
4889
4884
|
const frame = encodeFrame(payload);
|
|
@@ -4914,10 +4909,10 @@ var MllpClient = class extends EventEmitter {
|
|
|
4914
4909
|
return this._waitThenSend(
|
|
4915
4910
|
payload,
|
|
4916
4911
|
{ byteCount: frame.length, messageControlIdBytes: controlId?.length },
|
|
4917
|
-
|
|
4912
|
+
options
|
|
4918
4913
|
);
|
|
4919
4914
|
}
|
|
4920
|
-
const sendAckTimeoutMs =
|
|
4915
|
+
const sendAckTimeoutMs = options.ackTimeoutMs;
|
|
4921
4916
|
return new Promise((resolve, reject) => {
|
|
4922
4917
|
let abortListener = null;
|
|
4923
4918
|
let ackDeadline;
|
|
@@ -4958,7 +4953,7 @@ var MllpClient = class extends EventEmitter {
|
|
|
4958
4953
|
wrappedReject(neverDelivered());
|
|
4959
4954
|
return;
|
|
4960
4955
|
}
|
|
4961
|
-
this.send(payload,
|
|
4956
|
+
this.send(payload, options).then(wrappedResolve, wrappedReject);
|
|
4962
4957
|
};
|
|
4963
4958
|
parked.cancel = () => {
|
|
4964
4959
|
this.off("drain", onDrain);
|
|
@@ -5018,10 +5013,10 @@ var MllpClient = class extends EventEmitter {
|
|
|
5018
5013
|
*/
|
|
5019
5014
|
_twoPhaseStateFor(ackMode, opts) {
|
|
5020
5015
|
if (!ackMode.enhanced) return null;
|
|
5021
|
-
if (ackMode.
|
|
5016
|
+
if (ackMode.acceptFieldUnrecognized) {
|
|
5022
5017
|
this._emitAckModeWarning("MLLP_ACK_ACCEPT_TYPE_UNRECOGNISED", OUTBOUND_WARNING_CONTEXT);
|
|
5023
5018
|
}
|
|
5024
|
-
if (ackMode.
|
|
5019
|
+
if (ackMode.applicationFieldUnrecognized) {
|
|
5025
5020
|
this._emitAckModeWarning("MLLP_ACK_APPLICATION_TYPE_UNRECOGNISED", OUTBOUND_WARNING_CONTEXT);
|
|
5026
5021
|
}
|
|
5027
5022
|
if (!this._correlateByControlId) {
|
|
@@ -5335,8 +5330,8 @@ var MllpClient = class extends EventEmitter {
|
|
|
5335
5330
|
* await client.close({ drainTimeoutMs: 5_000 });
|
|
5336
5331
|
* ```
|
|
5337
5332
|
*/
|
|
5338
|
-
async close(
|
|
5339
|
-
const signal =
|
|
5333
|
+
async close(options = {}) {
|
|
5334
|
+
const signal = options.signal;
|
|
5340
5335
|
if (signal?.aborted) {
|
|
5341
5336
|
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
5342
5337
|
}
|
|
@@ -5351,7 +5346,7 @@ var MllpClient = class extends EventEmitter {
|
|
|
5351
5346
|
return;
|
|
5352
5347
|
}
|
|
5353
5348
|
this._installDrainHook(conn);
|
|
5354
|
-
const closeOpts =
|
|
5349
|
+
const closeOpts = options.drainTimeoutMs !== void 0 ? { drainTimeoutMs: options.drainTimeoutMs } : void 0;
|
|
5355
5350
|
if (signal === void 0) {
|
|
5356
5351
|
try {
|
|
5357
5352
|
await conn.close(closeOpts);
|
|
@@ -5521,8 +5516,6 @@ async function createStarterClient(opts) {
|
|
|
5521
5516
|
await client.connect();
|
|
5522
5517
|
return client;
|
|
5523
5518
|
}
|
|
5524
|
-
|
|
5525
|
-
// src/differential/corpus.ts
|
|
5526
5519
|
var SEGMENT_SEPARATOR = "\r";
|
|
5527
5520
|
var ADT_A01_SEGMENTS = [
|
|
5528
5521
|
"MSH|^~\\&|SENDING_APP|SENDING_FAC|RECV_APP|RECV_FAC|20260709120000||ADT^A01|MSG00001|P|2.5",
|
|
@@ -5818,7 +5811,7 @@ async function runDifferential(options = {}) {
|
|
|
5818
5811
|
}
|
|
5819
5812
|
|
|
5820
5813
|
// src/index.ts
|
|
5821
|
-
var VERSION = "0.1.
|
|
5814
|
+
var VERSION = "0.1.16";
|
|
5822
5815
|
|
|
5823
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 };
|
|
5824
5817
|
//# sourceMappingURL=index.mjs.map
|