@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 +24 -0
- package/README.md +31 -20
- package/TRADEMARKS.md +5 -2
- package/dist/ack-from-hl7/index.cjs +1 -1
- package/dist/ack-from-hl7/index.cjs.map +1 -1
- package/dist/index.cjs +355 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +465 -33
- package/dist/index.d.ts +465 -33
- package/dist/index.mjs +350 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -8
package/dist/index.d.cts
CHANGED
|
@@ -635,8 +635,32 @@ interface TlsOptions {
|
|
|
635
635
|
readonly cert?: PemInput;
|
|
636
636
|
/** Private key matching {@link TlsOptions.cert}. */
|
|
637
637
|
readonly key?: PemInput;
|
|
638
|
-
/**
|
|
638
|
+
/**
|
|
639
|
+
* Passphrase for an encrypted {@link TlsOptions.key}, or for the PKCS#12 file in
|
|
640
|
+
* {@link TlsOptions.pfx}.
|
|
641
|
+
*/
|
|
639
642
|
readonly passphrase?: string;
|
|
643
|
+
/**
|
|
644
|
+
* The client certificate and its private key as one PKCS#12 file (`.pfx` / `.p12`), for mutual
|
|
645
|
+
* TLS, in place of {@link TlsOptions.cert} and {@link TlsOptions.key}, unlocked with
|
|
646
|
+
* {@link TlsOptions.passphrase}. The file's bytes, as `readFileSync` returns them; this package
|
|
647
|
+
* reads no file itself.
|
|
648
|
+
*
|
|
649
|
+
* The file is loaded once, when the client is created, from the copy of the options it takes
|
|
650
|
+
* then. One the TLS library cannot load rejects every `connect()`, before a socket is opened,
|
|
651
|
+
* with a typed `MllpTlsConfigurationError` carrying `MLLP_TLS_PFX_REJECTED`, whose message
|
|
652
|
+
* names this option and never its value: a wrong passphrase, bytes that are not
|
|
653
|
+
* PKCS#12, or a legacy encryption (RC2-40, as `openssl pkcs12 -export -legacy`, OpenSSL 1.x and
|
|
654
|
+
* older Windows exports write it) that Node.js, on OpenSSL 3, does not load. Re-export such a
|
|
655
|
+
* file with AES-256. The refusal is permanent: a client does not retry it.
|
|
656
|
+
*
|
|
657
|
+
* Set it instead of `cert` and `key`, never with either: a client given both throws
|
|
658
|
+
* `MllpTlsConfigurationError` with `MLLP_TLS_CREDENTIAL_CONFLICT` at construction, since Node.js
|
|
659
|
+
* would load the file last and present its certificate in place of `cert`.
|
|
660
|
+
*
|
|
661
|
+
* @default undefined (no PKCS#12 file)
|
|
662
|
+
*/
|
|
663
|
+
readonly pfx?: Buffer;
|
|
640
664
|
/**
|
|
641
665
|
* SNI hostname and the identity-check target (matched against the server
|
|
642
666
|
* certificate's Subject/SAN). Defaults to `ClientOptions.host` when unset.
|
|
@@ -676,6 +700,13 @@ interface TlsOptions {
|
|
|
676
700
|
* offered list, so setting both rejects `connect()` with a typed
|
|
677
701
|
* `MllpTlsConfigurationError`.
|
|
678
702
|
*
|
|
703
|
+
* **On a runtime that cannot offer the list it rejects `connect()`** with a
|
|
704
|
+
* typed `MllpTlsConfigurationError` carrying
|
|
705
|
+
* `MLLP_TLS_CIPHER_LIST_UNENFORCEABLE`, before any socket exists: under Deno,
|
|
706
|
+
* whose `node:tls` takes a cipher list without applying it, and under Bun,
|
|
707
|
+
* whose TLS library has none of the DHE suites the option names. Node.js
|
|
708
|
+
* offers it.
|
|
709
|
+
*
|
|
679
710
|
* @default false
|
|
680
711
|
*/
|
|
681
712
|
readonly atnaTransportSecurity?: boolean;
|
|
@@ -689,7 +720,10 @@ interface TlsOptions {
|
|
|
689
720
|
*
|
|
690
721
|
* A list the runtime rejects rejects `connect()` with a typed
|
|
691
722
|
* `MllpTlsConfigurationError`; it never silently falls back to the default
|
|
692
|
-
* list.
|
|
723
|
+
* list. **So does any list on a runtime that does not enforce cipher lists**
|
|
724
|
+
* (Deno, whose `node:tls` takes a list without applying it), with
|
|
725
|
+
* `MLLP_TLS_CIPHER_LIST_UNENFORCEABLE`, before any socket exists. Node.js and
|
|
726
|
+
* Bun enforce a list.
|
|
693
727
|
*
|
|
694
728
|
* @default undefined (Node defaults)
|
|
695
729
|
*/
|
|
@@ -741,14 +775,41 @@ type ClientAuth = "NONE" | "WANT" | "MUST";
|
|
|
741
775
|
* ```
|
|
742
776
|
*/
|
|
743
777
|
interface ServerTlsOptions {
|
|
744
|
-
/**
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
778
|
+
/**
|
|
779
|
+
* Server certificate (PEM). Required with {@link ServerTlsOptions.key} unless
|
|
780
|
+
* {@link ServerTlsOptions.pfx} is set: a server given neither pair nor file throws a
|
|
781
|
+
* `TypeError` at construction.
|
|
782
|
+
*/
|
|
783
|
+
readonly cert?: PemInput;
|
|
784
|
+
/** Private key matching {@link ServerTlsOptions.cert}. Required with it unless `pfx` is set. */
|
|
785
|
+
readonly key?: PemInput;
|
|
748
786
|
/** Trust anchor(s) for verifying client certificates under `WANT`/`MUST`. */
|
|
749
787
|
readonly ca?: PemInput;
|
|
750
|
-
/**
|
|
788
|
+
/**
|
|
789
|
+
* Passphrase for an encrypted {@link ServerTlsOptions.key}, or for the PKCS#12 file in
|
|
790
|
+
* {@link ServerTlsOptions.pfx}.
|
|
791
|
+
*/
|
|
751
792
|
readonly passphrase?: string;
|
|
793
|
+
/**
|
|
794
|
+
* The server certificate and its private key as one PKCS#12 file (`.pfx` / `.p12`), in place of
|
|
795
|
+
* {@link ServerTlsOptions.cert} and {@link ServerTlsOptions.key}, unlocked with
|
|
796
|
+
* {@link ServerTlsOptions.passphrase}. The file's bytes, as `readFileSync` returns them; this
|
|
797
|
+
* package reads no file itself.
|
|
798
|
+
*
|
|
799
|
+
* The file is loaded before anything is bound. One the TLS library cannot load rejects
|
|
800
|
+
* `listen()` with a typed `MllpTlsConfigurationError` carrying `MLLP_TLS_PFX_REJECTED`, whose
|
|
801
|
+
* message names this option and never its value: a wrong passphrase, bytes that are not
|
|
802
|
+
* PKCS#12, or a legacy encryption (RC2-40, as `openssl pkcs12 -export -legacy`, OpenSSL 1.x and
|
|
803
|
+
* older Windows exports write it) that Node.js, on OpenSSL 3, does not load. Re-export such a
|
|
804
|
+
* file with AES-256. Construction never throws for a file that cannot be loaded.
|
|
805
|
+
*
|
|
806
|
+
* Set it instead of `cert` and `key`, never with either: a server given both throws
|
|
807
|
+
* `MllpTlsConfigurationError` with `MLLP_TLS_CREDENTIAL_CONFLICT` at construction, since Node.js
|
|
808
|
+
* would load the file last and present its certificate in place of `cert`.
|
|
809
|
+
*
|
|
810
|
+
* @default undefined (no PKCS#12 file)
|
|
811
|
+
*/
|
|
812
|
+
readonly pfx?: Buffer;
|
|
752
813
|
/**
|
|
753
814
|
* ATNA ITI-19 mutual-authentication mode. `'WANT'` requests a client
|
|
754
815
|
* certificate without rejecting unauthorized/absent ones (surfaced, not
|
|
@@ -784,6 +845,13 @@ interface ServerTlsOptions {
|
|
|
784
845
|
* Mutually exclusive with {@link ServerTlsOptions.ciphers}: setting both
|
|
785
846
|
* rejects `listen()` with a typed `MllpTlsConfigurationError`.
|
|
786
847
|
*
|
|
848
|
+
* **On a runtime that cannot honour it, `listen()` rejects** with a typed
|
|
849
|
+
* `MllpTlsConfigurationError` carrying `MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE`,
|
|
850
|
+
* before anything is bound: under Bun, whose TLS library refuses the automatic
|
|
851
|
+
* Diffie-Hellman selection (its own error is the `cause`), and under Deno,
|
|
852
|
+
* whose `node:tls` takes parameters and a cipher list without applying them.
|
|
853
|
+
* Construction never throws for it. Node.js honours it.
|
|
854
|
+
*
|
|
787
855
|
* @default false
|
|
788
856
|
*/
|
|
789
857
|
readonly atnaTransportSecurity?: boolean;
|
|
@@ -794,7 +862,9 @@ interface ServerTlsOptions {
|
|
|
794
862
|
*
|
|
795
863
|
* A list the runtime rejects rejects `listen()` with a typed
|
|
796
864
|
* `MllpTlsConfigurationError`; it never silently falls back to the default
|
|
797
|
-
* list.
|
|
865
|
+
* list. **So does any list on a runtime that does not enforce cipher lists**
|
|
866
|
+
* (Deno), with `MLLP_TLS_CIPHER_LIST_UNENFORCEABLE`, before anything is bound.
|
|
867
|
+
* Node.js and Bun enforce a list.
|
|
798
868
|
*
|
|
799
869
|
* @default undefined (Node defaults)
|
|
800
870
|
*/
|
|
@@ -826,6 +896,13 @@ interface ServerTlsOptions {
|
|
|
826
896
|
* silence. `'auto'` is not accepted here; that selection is what
|
|
827
897
|
* `atnaTransportSecurity` already makes.
|
|
828
898
|
*
|
|
899
|
+
* **On a runtime that does not enforce Diffie-Hellman parameters, `listen()`
|
|
900
|
+
* rejects** with `MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE`, before anything is
|
|
901
|
+
* bound, rather than serving without them: under Deno, whose `node:tls` takes
|
|
902
|
+
* parameters without using them, and under Bun, whose TLS library has no
|
|
903
|
+
* finite-field Diffie-Hellman (its own refusal is the `cause`). Node.js
|
|
904
|
+
* enforces them.
|
|
905
|
+
*
|
|
829
906
|
* There is no counterpart on {@link TlsOptions}: the side that answers the
|
|
830
907
|
* key exchange supplies the parameters.
|
|
831
908
|
*
|
|
@@ -841,7 +918,9 @@ interface ServerTlsOptions {
|
|
|
841
918
|
* was asked to offer cannot be honoured, so the connection is refused rather
|
|
842
919
|
* than opened on some other configuration. Two things can be asked for, and
|
|
843
920
|
* they carry separate codes: the offered cipher-suite list, and the server's
|
|
844
|
-
* ephemeral Diffie-Hellman parameters.
|
|
921
|
+
* ephemeral Diffie-Hellman parameters. Each can fail in two ways, also with
|
|
922
|
+
* separate codes: the runtime refused this input, or the runtime does not
|
|
923
|
+
* enforce that kind of input at all. It rejects the `connect()` / `listen()`
|
|
845
924
|
* call that asked for it, never a live connection.
|
|
846
925
|
*
|
|
847
926
|
* These codes are a **public API**. They appear in caller `catch` blocks, log
|
|
@@ -904,6 +983,106 @@ declare const MLLP_TLS_CIPHER_OPTION_CONFLICT = "MLLP_TLS_CIPHER_OPTION_CONFLICT
|
|
|
904
983
|
* ```
|
|
905
984
|
*/
|
|
906
985
|
declare const MLLP_TLS_DH_PARAMETERS_REJECTED = "MLLP_TLS_DH_PARAMETERS_REJECTED";
|
|
986
|
+
/**
|
|
987
|
+
* The runtime's TLS library does not enforce a cipher-suite list: it accepts a list and then
|
|
988
|
+
* offers its own, or it cannot offer a suite the configuration names. Raised for `ciphers` and for
|
|
989
|
+
* `atnaTransportSecurity`, before any socket exists.
|
|
990
|
+
*
|
|
991
|
+
* This is a property of the runtime, not of the list: Node.js enforces both options, and the same
|
|
992
|
+
* configuration fails here on a runtime whose `node:tls` takes a `ciphers` list without applying
|
|
993
|
+
* it, or whose TLS library has no finite-field Diffie-Hellman suite for the ATNA option to offer.
|
|
994
|
+
* It is proved with a probe rather than read off a runtime name: a list that names a suite and then
|
|
995
|
+
* removes it, so selects none, must be refused, and each suite the ATNA option names must be
|
|
996
|
+
* accepted on its own.
|
|
997
|
+
*
|
|
998
|
+
* Distinct from {@link MLLP_TLS_CIPHER_LIST_REJECTED}, where the runtime does enforce lists and
|
|
999
|
+
* refused this one: the remedy here is a different runtime, or no cipher option at all.
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* import { MLLP_TLS_CIPHER_LIST_UNENFORCEABLE } from '@cosyte/mllp';
|
|
1004
|
+
* if (err.code === MLLP_TLS_CIPHER_LIST_UNENFORCEABLE) logger.error('run this link on Node.js');
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
declare const MLLP_TLS_CIPHER_LIST_UNENFORCEABLE = "MLLP_TLS_CIPHER_LIST_UNENFORCEABLE";
|
|
1008
|
+
/**
|
|
1009
|
+
* The runtime's TLS library does not enforce server-side ephemeral Diffie-Hellman parameters: it
|
|
1010
|
+
* accepts parameters and then runs without them, or it refuses the automatic selection the ATNA
|
|
1011
|
+
* option makes. Raised for `ServerTlsOptions.dhParameters` and for a server's
|
|
1012
|
+
* `atnaTransportSecurity`, before anything is bound.
|
|
1013
|
+
*
|
|
1014
|
+
* Proved with a probe rather than read off a runtime name: the automatic selection must be
|
|
1015
|
+
* accepted, and a group far too small to use must be refused. A runtime that takes the small group
|
|
1016
|
+
* in silence would take the caller's group in silence too, and nothing would say it went unused.
|
|
1017
|
+
* When the runtime refused the probe itself, its own error is the `cause`.
|
|
1018
|
+
*
|
|
1019
|
+
* Distinct from {@link MLLP_TLS_DH_PARAMETERS_REJECTED}, where the runtime does enforce parameters
|
|
1020
|
+
* and refused these: the remedy here is a different runtime, or no Diffie-Hellman option at all.
|
|
1021
|
+
*
|
|
1022
|
+
* @example
|
|
1023
|
+
* ```typescript
|
|
1024
|
+
* import { MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE } from '@cosyte/mllp';
|
|
1025
|
+
* if (err.code === MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE) logger.error('run this server on Node.js');
|
|
1026
|
+
* ```
|
|
1027
|
+
*/
|
|
1028
|
+
declare const MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE = "MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE";
|
|
1029
|
+
/**
|
|
1030
|
+
* The TLS library could not load `tls.pfx`, the PKCS#12 file, with `tls.passphrase`. Raised for
|
|
1031
|
+
* `ServerTlsOptions.pfx` by `listen()`, before anything is bound, and for `TlsOptions.pfx` by a
|
|
1032
|
+
* client's `connect()`, before a socket is opened.
|
|
1033
|
+
*
|
|
1034
|
+
* Three causes share it: the passphrase is wrong, the bytes are not a PKCS#12 file, or the file
|
|
1035
|
+
* uses a legacy encryption the library does not load. The last is the one that surprises: a file
|
|
1036
|
+
* written by `openssl pkcs12 -export -legacy`, by OpenSSL 1.x, or by an older Windows export
|
|
1037
|
+
* protects its certificates with RC2-40, and Node.js runs OpenSSL 3 without the legacy provider
|
|
1038
|
+
* that holds RC2, so it refuses the file. Re-export it with AES-256
|
|
1039
|
+
* (`openssl pkcs12 -export` on OpenSSL 3 does by default). The TLS library's own error is the
|
|
1040
|
+
* `cause`; it names the failure and carries neither the passphrase nor any of the file.
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* ```typescript
|
|
1044
|
+
* import { MLLP_TLS_PFX_REJECTED } from '@cosyte/mllp';
|
|
1045
|
+
* if (err.code === MLLP_TLS_PFX_REJECTED) logger.error('re-export the PKCS#12 file with AES-256');
|
|
1046
|
+
* ```
|
|
1047
|
+
*/
|
|
1048
|
+
declare const MLLP_TLS_PFX_REJECTED = "MLLP_TLS_PFX_REJECTED";
|
|
1049
|
+
/**
|
|
1050
|
+
* `tls.pfx` was set together with `tls.cert` or `tls.key`. The PKCS#12 file carries its own
|
|
1051
|
+
* certificate and key, and Node.js loads it after the PEM pair, so the file's certificate would
|
|
1052
|
+
* silently win over the one passed as `cert`. Both declarations are refused instead.
|
|
1053
|
+
*
|
|
1054
|
+
* Unlike the other codes, this one is thrown by the constructor (`createClient`, `createServer`,
|
|
1055
|
+
* `new MllpClient`, `new MllpServer`), not by `connect()` or `listen()`: it is a contradiction in
|
|
1056
|
+
* the options themselves, the same kind of mistake as a server given no certificate at all. The
|
|
1057
|
+
* message names the options and never their values, and there is no `cause`.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```typescript
|
|
1061
|
+
* import { MLLP_TLS_CREDENTIAL_CONFLICT } from '@cosyte/mllp';
|
|
1062
|
+
* if (err.code === MLLP_TLS_CREDENTIAL_CONFLICT) logger.error('pass cert and key, or pfx');
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1065
|
+
declare const MLLP_TLS_CREDENTIAL_CONFLICT = "MLLP_TLS_CREDENTIAL_CONFLICT";
|
|
1066
|
+
/**
|
|
1067
|
+
* `tls` was `null`, an array, a byte array (a `Buffer`, any other typed array, a `DataView`, an
|
|
1068
|
+
* `ArrayBuffer` or a `SharedArrayBuffer`), a `Map`, a `Set`, a `Date`, a `Promise`, a boxed
|
|
1069
|
+
* primitive or a value that is no object, rather than an object of TLS options (for a client,
|
|
1070
|
+
* `true` also asks for the defaults). Any other object is an object of options: a literal, a class
|
|
1071
|
+
* instance, an `Object.create` object or a module namespace object, whatever its
|
|
1072
|
+
* `Symbol.toStringTag`. Without this check such a value reached the options' property reads and
|
|
1073
|
+
* failed there with a bare `TypeError`, or was taken as TLS with no options at all.
|
|
1074
|
+
*
|
|
1075
|
+
* Like {@link MLLP_TLS_CREDENTIAL_CONFLICT}, this one is thrown by the constructor
|
|
1076
|
+
* (`createClient`, `createServer`, `new MllpClient`, `new MllpServer`). The message never carries
|
|
1077
|
+
* the value that was passed, and there is no `cause`.
|
|
1078
|
+
*
|
|
1079
|
+
* @example
|
|
1080
|
+
* ```typescript
|
|
1081
|
+
* import { MLLP_TLS_OPTIONS_NOT_AN_OBJECT } from '@cosyte/mllp';
|
|
1082
|
+
* if (err.code === MLLP_TLS_OPTIONS_NOT_AN_OBJECT) logger.error('tls must be an options object');
|
|
1083
|
+
* ```
|
|
1084
|
+
*/
|
|
1085
|
+
declare const MLLP_TLS_OPTIONS_NOT_AN_OBJECT = "MLLP_TLS_OPTIONS_NOT_AN_OBJECT";
|
|
907
1086
|
/**
|
|
908
1087
|
* Union of the stable TLS-configuration error codes.
|
|
909
1088
|
*
|
|
@@ -912,14 +1091,14 @@ declare const MLLP_TLS_DH_PARAMETERS_REJECTED = "MLLP_TLS_DH_PARAMETERS_REJECTED
|
|
|
912
1091
|
* const code: TlsConfigurationErrorCode = 'MLLP_TLS_CIPHER_LIST_REJECTED';
|
|
913
1092
|
* ```
|
|
914
1093
|
*/
|
|
915
|
-
type TlsConfigurationErrorCode = typeof MLLP_TLS_CIPHER_LIST_REJECTED | typeof MLLP_TLS_CIPHER_OPTION_CONFLICT | typeof MLLP_TLS_DH_PARAMETERS_REJECTED;
|
|
1094
|
+
type TlsConfigurationErrorCode = typeof MLLP_TLS_CIPHER_LIST_REJECTED | typeof MLLP_TLS_CIPHER_OPTION_CONFLICT | typeof MLLP_TLS_DH_PARAMETERS_REJECTED | typeof MLLP_TLS_CIPHER_LIST_UNENFORCEABLE | typeof MLLP_TLS_DH_PARAMETERS_UNENFORCEABLE | typeof MLLP_TLS_PFX_REJECTED | typeof MLLP_TLS_CREDENTIAL_CONFLICT | typeof MLLP_TLS_OPTIONS_NOT_AN_OBJECT;
|
|
916
1095
|
/**
|
|
917
1096
|
* Fixed, human-readable description for a TLS-configuration code.
|
|
918
1097
|
*
|
|
919
1098
|
* Byte-for-byte identical for a given code, whatever the configuration was.
|
|
920
1099
|
*
|
|
921
1100
|
* @param code - The stable configuration-error code.
|
|
922
|
-
* @returns The
|
|
1101
|
+
* @returns The fixed registry text for `code`.
|
|
923
1102
|
*
|
|
924
1103
|
* @example
|
|
925
1104
|
* ```typescript
|
|
@@ -931,13 +1110,16 @@ declare function tlsConfigurationMessage(code: TlsConfigurationErrorCode): strin
|
|
|
931
1110
|
/**
|
|
932
1111
|
* Thrown for a TLS configuration this package will not open a connection on.
|
|
933
1112
|
* Rejects the originating `MllpClient.connect()` or `MllpServer.listen()`; no
|
|
934
|
-
* socket is opened and no listener is left bound.
|
|
1113
|
+
* socket is opened and no listener is left bound. One code,
|
|
1114
|
+
* {@link MLLP_TLS_CREDENTIAL_CONFLICT}, is thrown by the constructor instead.
|
|
935
1115
|
*
|
|
936
1116
|
* Identify it by `instanceof` **and** by the stable {@link MllpTlsConfigurationError.code},
|
|
937
|
-
* never by matching on the message text. `message` is a
|
|
1117
|
+
* never by matching on the message text. `message` is a fixed registry entry
|
|
938
1118
|
* and carries no key material and no passphrase; `cause`, when present, is the
|
|
939
1119
|
* TLS library's own error for one input on its own (the suite list and the
|
|
940
|
-
* Diffie-Hellman parameters are each validated with no credential in scope
|
|
1120
|
+
* Diffie-Hellman parameters are each validated with no credential in scope; a
|
|
1121
|
+
* PKCS#12 file is validated with its passphrase, and the library's error for it
|
|
1122
|
+
* names the failure without repeating either).
|
|
941
1123
|
*
|
|
942
1124
|
* @example
|
|
943
1125
|
* ```typescript
|
|
@@ -957,7 +1139,8 @@ declare class MllpTlsConfigurationError extends Error {
|
|
|
957
1139
|
*/
|
|
958
1140
|
readonly code: TlsConfigurationErrorCode;
|
|
959
1141
|
/**
|
|
960
|
-
* The TLS library's own error, when the runtime is what refused the
|
|
1142
|
+
* The TLS library's own error, when the runtime is what refused the input
|
|
1143
|
+
* (or, for an `_UNENFORCEABLE` code, refused one of the probes).
|
|
961
1144
|
* `undefined` when this package refused the configuration itself.
|
|
962
1145
|
*/
|
|
963
1146
|
readonly cause: Error | undefined;
|
|
@@ -1114,10 +1297,17 @@ interface ResolvedTlsCipherPolicy {
|
|
|
1114
1297
|
* @param opts - The cipher-suite half of the caller's TLS options.
|
|
1115
1298
|
* @param side - Which end of the connection is being configured.
|
|
1116
1299
|
* @returns The TLS-context fields to spread into `tls.connect` / `tls.createServer`.
|
|
1300
|
+
* **A runtime that would not enforce what was asked for is refused too.** Before
|
|
1301
|
+
* a list or parameters are handed over, probes with no caller input in scope
|
|
1302
|
+
* prove that this runtime's TLS library enforces that kind of input at all; one
|
|
1303
|
+
* that would accept it and then run without it (a `node:tls` that takes a list
|
|
1304
|
+
* and offers its own) gets an `_UNENFORCEABLE` code instead of a link that is
|
|
1305
|
+
* not what it says. Node.js passes every probe.
|
|
1306
|
+
*
|
|
1117
1307
|
* @throws {MllpTlsConfigurationError} On a conflicting declaration, a list the
|
|
1118
|
-
* runtime rejects,
|
|
1119
|
-
*
|
|
1120
|
-
* parameters.
|
|
1308
|
+
* runtime rejects, Diffie-Hellman parameters it cannot use, or a list or
|
|
1309
|
+
* parameters this runtime does not enforce. Never falls back to the runtime
|
|
1310
|
+
* default list, and never to a server with no Diffie-Hellman parameters.
|
|
1121
1311
|
*
|
|
1122
1312
|
* @example
|
|
1123
1313
|
* ```typescript
|
|
@@ -1137,15 +1327,15 @@ declare function resolveTlsCipherPolicy(opts: TlsCipherPolicyInput, side: "clien
|
|
|
1137
1327
|
* version and which cipher suite that link negotiated. This is that record,
|
|
1138
1328
|
* emitted once per completed handshake on both the client and the server.
|
|
1139
1329
|
*
|
|
1140
|
-
* It is a **log line**, so it carries no field content:
|
|
1141
|
-
* from the TLS session and
|
|
1330
|
+
* It is a **log line**, so it carries no field content: every value is read
|
|
1331
|
+
* from the TLS session and is a name out of a closed registry, never anything
|
|
1142
1332
|
* derived from the payload, the certificate, or the key.
|
|
1143
1333
|
*
|
|
1144
1334
|
* @example
|
|
1145
1335
|
* ```typescript
|
|
1146
1336
|
* import type { NegotiatedTlsParameters } from '@cosyte/mllp';
|
|
1147
1337
|
* client.on('tlsNegotiated', (p: NegotiatedTlsParameters) => {
|
|
1148
|
-
* logger.info({ tls: p.protocolVersion, suite: p.cipherSuite });
|
|
1338
|
+
* logger.info({ tls: p.protocolVersion, suite: p.cipherSuite, group: p.keyExchangeGroup });
|
|
1149
1339
|
* });
|
|
1150
1340
|
* ```
|
|
1151
1341
|
*
|
|
@@ -1158,7 +1348,7 @@ declare function resolveTlsCipherPolicy(opts: TlsCipherPolicyInput, side: "clien
|
|
|
1158
1348
|
* including every reconnect. Never emitted on a plaintext connection.
|
|
1159
1349
|
*
|
|
1160
1350
|
* Carries no HL7 payload content and no certificate or key material: only the
|
|
1161
|
-
*
|
|
1351
|
+
* negotiated names and the same routing metadata a `SecurityWarning`
|
|
1162
1352
|
* carries. It is emitted at handshake-completion time, before any HL7 byte has
|
|
1163
1353
|
* crossed the link.
|
|
1164
1354
|
*
|
|
@@ -1183,6 +1373,25 @@ interface NegotiatedTlsParameters {
|
|
|
1183
1373
|
* in, is a different rendering of the same suite.
|
|
1184
1374
|
*/
|
|
1185
1375
|
readonly cipherSuite: string;
|
|
1376
|
+
/**
|
|
1377
|
+
* The key-exchange group the handshake used, as the TLS library names it,
|
|
1378
|
+
* e.g. `'X25519'`, `'prime256v1'`, or a post-quantum hybrid such as
|
|
1379
|
+
* `'X25519MLKEM768'`. Standardized group names are the ones the IANA TLS
|
|
1380
|
+
* Supported Groups registry lists.
|
|
1381
|
+
*
|
|
1382
|
+
* Present only where the runtime reports the group, and **absent** (the key
|
|
1383
|
+
* is not on the object) everywhere else:
|
|
1384
|
+
*
|
|
1385
|
+
* - only on a **client** record: Node.js reports the group on a client socket
|
|
1386
|
+
* alone, so a server record never carries it;
|
|
1387
|
+
* - a classic elliptic-curve group (`'X25519'`, `'prime256v1'` and the like)
|
|
1388
|
+
* is reported on every supported Node.js line;
|
|
1389
|
+
* - a group with no classic key, such as a post-quantum hybrid, is reported
|
|
1390
|
+
* from Node.js 24.19.0 and 26.5.0; on Node.js 22 it is absent;
|
|
1391
|
+
* - a TLS 1.2 finite-field Diffie-Hellman exchange (a `DHE` suite) has no
|
|
1392
|
+
* group name to report, so it is absent there too.
|
|
1393
|
+
*/
|
|
1394
|
+
readonly keyExchangeGroup?: string;
|
|
1186
1395
|
/** Host associated with the link (the target host for clients; the bind host for servers). */
|
|
1187
1396
|
readonly host: string;
|
|
1188
1397
|
/** Port associated with the link. */
|
|
@@ -2027,6 +2236,15 @@ interface ServerOptions {
|
|
|
2027
2236
|
* Distinct from `deadPeerTimeoutMs` (application-level idle close).
|
|
2028
2237
|
*/
|
|
2029
2238
|
keepaliveIntervalMs?: number;
|
|
2239
|
+
/**
|
|
2240
|
+
* Whether to turn off Nagle's algorithm (`socket.setNoDelay(noDelay)`) on each accepted
|
|
2241
|
+
* socket. With it on (`false` here), an ACK written while an earlier one is still
|
|
2242
|
+
* unacknowledged at the TCP level waits for that acknowledgment, which Linux delays by up to
|
|
2243
|
+
* about 40 ms. Set `false` only to restore the operating system's default.
|
|
2244
|
+
*
|
|
2245
|
+
* @default true
|
|
2246
|
+
*/
|
|
2247
|
+
noDelay?: boolean;
|
|
2030
2248
|
/**
|
|
2031
2249
|
* Application-level idle close timeout in ms.
|
|
2032
2250
|
* If no HL7 messages are received on a connection for this interval, the connection
|
|
@@ -2045,6 +2263,14 @@ interface ServerOptions {
|
|
|
2045
2263
|
* (post-handshake sockets) instead of `'connection'`, and surfaces failed
|
|
2046
2264
|
* handshakes via the `'tlsClientError'` event rather than crashing.
|
|
2047
2265
|
*
|
|
2266
|
+
* We set no handshake time limit of our own: the runtime's applies. On Node.js that is its
|
|
2267
|
+
* `handshakeTimeout` default of 120 seconds, after which the socket is closed and
|
|
2268
|
+
* `'tlsClientError'` fires with code `ERR_TLS_HANDSHAKE_TIMEOUT`. Until then a peer that
|
|
2269
|
+
* connects and never completes the handshake holds a {@link ServerOptions.maxConnections}
|
|
2270
|
+
* place, and `deadPeerTimeoutMs` does not apply, because it starts only once the connection is
|
|
2271
|
+
* accepted after its handshake. We have not measured what bounds a handshake on Bun or Deno,
|
|
2272
|
+
* which may set no limit at all.
|
|
2273
|
+
*
|
|
2048
2274
|
* Spec anchor: IHE ATNA ITI-19 (https://profiles.ihe.net/ITI/TF/Volume2/ITI-19.html).
|
|
2049
2275
|
*
|
|
2050
2276
|
* @default undefined (plaintext TCP)
|
|
@@ -2078,6 +2304,10 @@ interface ServerOptions {
|
|
|
2078
2304
|
* over-cap TLS connection is closed before its handshake, so it costs no handshake work and is
|
|
2079
2305
|
* not a `'tlsClientError'`.
|
|
2080
2306
|
*
|
|
2307
|
+
* The server counts its connections itself rather than handing the cap to the runtime's
|
|
2308
|
+
* listener, so the cap and `'connectionRejected'` hold the same on Node.js, Bun and Deno (Deno's
|
|
2309
|
+
* own listener cap closed the connection and reported nothing).
|
|
2310
|
+
*
|
|
2081
2311
|
* Must be a positive integer; anything else throws a `RangeError` at construction. Unset means
|
|
2082
2312
|
* no cap.
|
|
2083
2313
|
*
|
|
@@ -2178,6 +2408,8 @@ declare class MllpServer extends EventEmitter {
|
|
|
2178
2408
|
private readonly _netServer;
|
|
2179
2409
|
private readonly _connections;
|
|
2180
2410
|
private readonly _opts;
|
|
2411
|
+
/** The TLS options as they were at construction; never read `_opts.tls`, which the caller owns. */
|
|
2412
|
+
private readonly _tls;
|
|
2181
2413
|
/** `true` when `ServerOptions.tls` is set, `_netServer` is actually a `tls.Server`. */
|
|
2182
2414
|
private readonly _isTls;
|
|
2183
2415
|
private _listening;
|
|
@@ -2194,6 +2426,18 @@ declare class MllpServer extends EventEmitter {
|
|
|
2194
2426
|
private _host;
|
|
2195
2427
|
private _acceptedTotal;
|
|
2196
2428
|
private _closedTotal;
|
|
2429
|
+
/**
|
|
2430
|
+
* Sockets accepted and not yet closed, counted only when {@link ServerOptions.maxConnections} is
|
|
2431
|
+
* set: the number the cap is compared against.
|
|
2432
|
+
*/
|
|
2433
|
+
private _openSockets;
|
|
2434
|
+
/** Sockets the connection cap closed at accept, so a runtime's report of them is recognised. */
|
|
2435
|
+
private readonly _closedAtAccept;
|
|
2436
|
+
/**
|
|
2437
|
+
* For each socket the connection cap counted, what gives its place back. Released once, however
|
|
2438
|
+
* many times it is called.
|
|
2439
|
+
*/
|
|
2440
|
+
private readonly _capRelease;
|
|
2197
2441
|
/** Count of `'tlsClientError'` events since listen(). */
|
|
2198
2442
|
private _tlsClientErrorsTotal;
|
|
2199
2443
|
/**
|
|
@@ -2214,10 +2458,29 @@ declare class MllpServer extends EventEmitter {
|
|
|
2214
2458
|
*/
|
|
2215
2459
|
constructor(opts: ServerOptions);
|
|
2216
2460
|
/**
|
|
2217
|
-
*
|
|
2461
|
+
* Enforce {@link ServerOptions.maxConnections} by counting sockets here, at accept.
|
|
2462
|
+
*
|
|
2463
|
+
* WHY NOT THE LISTENER'S OWN `maxConnections`. Node's `net.Server` enforces a cap of its own and
|
|
2464
|
+
* reports each refusal on `'drop'`, but that report is the runtime's to make, and Deno's
|
|
2465
|
+
* `node:net` closes the socket without emitting `'drop'` (measured: Deno 2.9.8), so the cap held
|
|
2466
|
+
* and `'connectionRejected'` never fired. Counting here makes the cap and its event a property of
|
|
2467
|
+
* this package on every runtime.
|
|
2468
|
+
*
|
|
2469
|
+
* The gate sits IN FRONT of every `'connection'` listener the server already has, and replaces
|
|
2470
|
+
* them: for a plaintext server that is this class's own accept handler, and for a TLS server it
|
|
2471
|
+
* is the runtime's, which wraps the raw socket and starts the handshake. An over-cap socket is
|
|
2472
|
+
* destroyed before either runs, so it never becomes a `Connection`, costs no handshake, and is
|
|
2473
|
+
* not a `'tlsClientError'`. The count is of open sockets, the number that bounds file
|
|
2474
|
+
* descriptors: a socket counts from accept until its `'close'`, handshake in flight included.
|
|
2218
2475
|
*
|
|
2219
|
-
*
|
|
2220
|
-
|
|
2476
|
+
* @param maxConnections - The validated cap.
|
|
2477
|
+
*/
|
|
2478
|
+
private _gateConnections;
|
|
2479
|
+
/**
|
|
2480
|
+
* Report a connection closed at accept because the cap was full.
|
|
2481
|
+
*
|
|
2482
|
+
* Contained: this runs inside the listener's own 'connection' callback, so a throwing subscriber
|
|
2483
|
+
* would otherwise unwind into the accept path. The throw is surfaced on 'error' instead.
|
|
2221
2484
|
*/
|
|
2222
2485
|
private _onConnectionOverCap;
|
|
2223
2486
|
/**
|
|
@@ -2736,6 +2999,127 @@ declare function rawAckUncorrelatable(payload: Buffer): boolean;
|
|
|
2736
2999
|
*/
|
|
2737
3000
|
declare function buildRawAck(payload: Buffer, code: AckCode): Buffer;
|
|
2738
3001
|
|
|
3002
|
+
/**
|
|
3003
|
+
* The acknowledgement-condition table as a public function: from MSH-15, MSH-16 and an outcome to
|
|
3004
|
+
* the HL7 Table 0008 code to send.
|
|
3005
|
+
*
|
|
3006
|
+
* The server's auto-ACK path selects its code by the same rules, read from the same internal
|
|
3007
|
+
* functions, so a caller that builds its own acknowledgement (an `autoAck` function, manual mode,
|
|
3008
|
+
* or another engine) answers exactly as the server would.
|
|
3009
|
+
*
|
|
3010
|
+
* @packageDocumentation
|
|
3011
|
+
*/
|
|
3012
|
+
|
|
3013
|
+
/**
|
|
3014
|
+
* Input to {@link selectAckCode}.
|
|
3015
|
+
*
|
|
3016
|
+
* @example
|
|
3017
|
+
* ```typescript
|
|
3018
|
+
* import type { AckCodeSelectionInput } from '@cosyte/mllp';
|
|
3019
|
+
* const input: AckCodeSelectionInput = { msh15: 'AL', msh16: 'NE', outcome: 'AA' };
|
|
3020
|
+
* ```
|
|
3021
|
+
*/
|
|
3022
|
+
interface AckCodeSelectionInput {
|
|
3023
|
+
/**
|
|
3024
|
+
* MSH-15, accept acknowledgment type (HL7 Table 0155), as the field's text: `AL`, `NE`, `ER`,
|
|
3025
|
+
* `SU`, or anything else the sender put there. Read the way the server reads it: the text before
|
|
3026
|
+
* the first repetition separator, then before the first component separator, with leading and
|
|
3027
|
+
* trailing spaces dropped, compared case-sensitively. Unset, empty, or the HL7 explicit null
|
|
3028
|
+
* `""` is a NULL field.
|
|
3029
|
+
*/
|
|
3030
|
+
readonly msh15?: string | undefined;
|
|
3031
|
+
/** MSH-16, application acknowledgment type (HL7 Table 0155), read the same way as `msh15`. */
|
|
3032
|
+
readonly msh16?: string | undefined;
|
|
3033
|
+
/**
|
|
3034
|
+
* The message's MSH-2 encoding characters, which name its component (first byte) and repetition
|
|
3035
|
+
* (second byte) separators. Unset means the standard `^~\&`.
|
|
3036
|
+
*
|
|
3037
|
+
* @default '^~\\&'
|
|
3038
|
+
*/
|
|
3039
|
+
readonly encodingCharacters?: string | undefined;
|
|
3040
|
+
/**
|
|
3041
|
+
* What the receiving application did with the message, as an application-mode code: `AA` it was
|
|
3042
|
+
* accepted, `AE` it failed, `AR` it was rejected. Any other value throws a `RangeError`.
|
|
3043
|
+
*/
|
|
3044
|
+
readonly outcome: "AA" | "AE" | "AR";
|
|
3045
|
+
}
|
|
3046
|
+
/**
|
|
3047
|
+
* What {@link selectAckCode} decided. A frozen object; it carries no field text.
|
|
3048
|
+
*
|
|
3049
|
+
* @example
|
|
3050
|
+
* ```typescript
|
|
3051
|
+
* import { selectAckCode, type AckCodeSelection } from '@cosyte/mllp';
|
|
3052
|
+
* const selection: AckCodeSelection = selectAckCode({ msh15: 'AL', outcome: 'AA' });
|
|
3053
|
+
* selection.code; // 'CA'
|
|
3054
|
+
* ```
|
|
3055
|
+
*/
|
|
3056
|
+
interface AckCodeSelection {
|
|
3057
|
+
/**
|
|
3058
|
+
* The one code to send now. The accept-mode counterpart of `outcome` (`CA`, `CE` or `CR`) when
|
|
3059
|
+
* MSH-15 asks for an accept acknowledgement on that outcome, and `outcome` itself otherwise. This
|
|
3060
|
+
* is the code the server's auto-ACK sends for the same fields and outcome.
|
|
3061
|
+
*/
|
|
3062
|
+
readonly code: AckCode;
|
|
3063
|
+
/**
|
|
3064
|
+
* `'enhanced'` when MSH-15 or MSH-16 is non-NULL (the standard's own test for the enhanced
|
|
3065
|
+
* protocol), `'original'` when both are NULL.
|
|
3066
|
+
*/
|
|
3067
|
+
readonly mode: "original" | "enhanced";
|
|
3068
|
+
/**
|
|
3069
|
+
* Whether MSH-16 asks for an application acknowledgement carrying this outcome: `AL` always, `NE`
|
|
3070
|
+
* never, `ER` on `AE` or `AR` only, `SU` on `AA` only. A NULL or unrecognised MSH-16 reads as
|
|
3071
|
+
* `AL`, which is the original protocol. Where `code` is an accept-mode code and this is `true`,
|
|
3072
|
+
* the application acknowledgement is a second message, and sending it is the caller's; where
|
|
3073
|
+
* `code` is an application-mode code, `code` is that acknowledgement.
|
|
3074
|
+
*/
|
|
3075
|
+
readonly applicationAckRequested: boolean;
|
|
3076
|
+
/**
|
|
3077
|
+
* MSH-15 held a value outside Table 0155. It was read as NULL: `code` is `outcome`, unchanged,
|
|
3078
|
+
* as the server answers (and reports with `MLLP_ACK_ACCEPT_TYPE_UNRECOGNISED`).
|
|
3079
|
+
*/
|
|
3080
|
+
readonly acceptTypeUnrecognised: boolean;
|
|
3081
|
+
/** MSH-16 held a value outside Table 0155. It was read as NULL, so as `AL`. */
|
|
3082
|
+
readonly applicationTypeUnrecognised: boolean;
|
|
3083
|
+
}
|
|
3084
|
+
/**
|
|
3085
|
+
* Select the acknowledgement code for a message from its MSH-15, MSH-16 and what the application
|
|
3086
|
+
* did with it, by the table the server's auto-ACK uses.
|
|
3087
|
+
*
|
|
3088
|
+
* Rows are MSH-15, columns the outcome:
|
|
3089
|
+
*
|
|
3090
|
+
* | MSH-15 | `AA` | `AE` | `AR` |
|
|
3091
|
+
* | ------------------ | ----- | ----- | ----- |
|
|
3092
|
+
* | NULL | `AA` | `AE` | `AR` |
|
|
3093
|
+
* | `NE` | `AA` | `AE` | `AR` |
|
|
3094
|
+
* | `AL` | `CA` | `CE` | `CR` |
|
|
3095
|
+
* | `ER` | `AA` | `CE` | `CR` |
|
|
3096
|
+
* | `SU` | `CA` | `AE` | `AR` |
|
|
3097
|
+
* | outside Table 0155 | `AA` | `AE` | `AR` |
|
|
3098
|
+
*
|
|
3099
|
+
* MSH-16 never changes the code; it decides {@link AckCodeSelection.applicationAckRequested}.
|
|
3100
|
+
*
|
|
3101
|
+
* Two things the server does are not in this function, because they are about the whole message
|
|
3102
|
+
* rather than its fields: a batch or concatenated frame keeps its warned non-positive answer, and
|
|
3103
|
+
* a message with no usable MSH-10 is never answered positively. A caller building its own
|
|
3104
|
+
* acknowledgement for such a message applies those rules itself.
|
|
3105
|
+
*
|
|
3106
|
+
* @param input - MSH-15, MSH-16, the message's MSH-2 and the outcome.
|
|
3107
|
+
* @returns The code to send, the mode, whether an application acknowledgement is asked for, and
|
|
3108
|
+
* whether either field held a value outside Table 0155.
|
|
3109
|
+
* @throws {RangeError} when `outcome` is not `AA`, `AE` or `AR`. The message does not repeat the
|
|
3110
|
+
* value.
|
|
3111
|
+
*
|
|
3112
|
+
* @example
|
|
3113
|
+
* ```typescript
|
|
3114
|
+
* import { selectAckCode } from '@cosyte/mllp';
|
|
3115
|
+
* selectAckCode({ msh15: 'AL', msh16: 'AL', outcome: 'AA' }).code; // 'CA'
|
|
3116
|
+
* selectAckCode({ msh15: 'ER', outcome: 'AA' }).code; // 'AA'
|
|
3117
|
+
* selectAckCode({ msh15: 'ER', outcome: 'AE' }).code; // 'CE'
|
|
3118
|
+
* selectAckCode({ outcome: 'AR' }).code; // 'AR'
|
|
3119
|
+
* ```
|
|
3120
|
+
*/
|
|
3121
|
+
declare function selectAckCode(input: AckCodeSelectionInput): AckCodeSelection;
|
|
3122
|
+
|
|
2739
3123
|
/**
|
|
2740
3124
|
* The frozen diagnostic registry for ACK correlation.
|
|
2741
3125
|
*
|
|
@@ -3042,6 +3426,9 @@ interface ClientOptions {
|
|
|
3042
3426
|
* Per-message ACK timeout in milliseconds. The clock starts at
|
|
3043
3427
|
* the underlying `write()` flush callback, NOT at the `send()` call,
|
|
3044
3428
|
* pre-flush queue time is not charged to the peer. Default: `30_000`.
|
|
3429
|
+
*
|
|
3430
|
+
* A send can set its own with `send(payload, { ackTimeoutMs })`, which replaces this value
|
|
3431
|
+
* for that send's acknowledgement wait.
|
|
3045
3432
|
*/
|
|
3046
3433
|
readonly ackTimeoutMs?: number;
|
|
3047
3434
|
/**
|
|
@@ -3141,6 +3528,15 @@ interface ClientOptions {
|
|
|
3141
3528
|
* @default undefined (off)
|
|
3142
3529
|
*/
|
|
3143
3530
|
readonly keepaliveIntervalMs?: number;
|
|
3531
|
+
/**
|
|
3532
|
+
* Whether to turn off Nagle's algorithm (`socket.setNoDelay(noDelay)`) on each connection,
|
|
3533
|
+
* the first and every reconnect. With it on (`false` here), a frame written while an earlier
|
|
3534
|
+
* one is still unacknowledged at the TCP level waits for that acknowledgment, which Linux
|
|
3535
|
+
* delays by up to about 40 ms. Set `false` only to restore the operating system's default.
|
|
3536
|
+
*
|
|
3537
|
+
* @default true
|
|
3538
|
+
*/
|
|
3539
|
+
readonly noDelay?: boolean;
|
|
3144
3540
|
/**
|
|
3145
3541
|
* Application-idle timeout (ms) keyed on last inbound bytes / ACK / warning.
|
|
3146
3542
|
* On trip, calls `connection.destroy(new Error('dead
|
|
@@ -3274,6 +3670,10 @@ interface ClientStats {
|
|
|
3274
3670
|
*/
|
|
3275
3671
|
declare class MllpClient extends EventEmitter {
|
|
3276
3672
|
private readonly _opts;
|
|
3673
|
+
/** The TLS options as they were at construction; never read `_opts.tls`, which the caller owns. */
|
|
3674
|
+
private readonly _tls;
|
|
3675
|
+
/** Why `tls.pfx` cannot be loaded, found once at construction; `undefined` when it loads or is unset. */
|
|
3676
|
+
private readonly _pfxRefusal;
|
|
3277
3677
|
private _connection;
|
|
3278
3678
|
private _socket;
|
|
3279
3679
|
/**
|
|
@@ -3336,6 +3736,15 @@ declare class MllpClient extends EventEmitter {
|
|
|
3336
3736
|
private _connectSignal;
|
|
3337
3737
|
/** Set when close()/destroy()/abort fires; reconnect handler short-circuits. */
|
|
3338
3738
|
private _userClosed;
|
|
3739
|
+
/**
|
|
3740
|
+
* The reason passed to the `destroy(reason)` that closed a connection still connecting, `null`
|
|
3741
|
+
* otherwise. The socket hands it back on `'error'`, and `connect()` compares by identity so the
|
|
3742
|
+
* caller's own reason is carried as the cause and never sorted into a TLS `connectionCause`.
|
|
3743
|
+
* Only the call that reaches the socket records it: a later `destroy()` finds the connection
|
|
3744
|
+
* already CLOSED and leaves it alone. Cleared once matched and at the start of `connect()`, so
|
|
3745
|
+
* the client does not keep the caller's object alive.
|
|
3746
|
+
*/
|
|
3747
|
+
private _destroyReason;
|
|
3339
3748
|
/**
|
|
3340
3749
|
* Sends parked inside the client with nothing written for them. See {@link ParkedSend}.
|
|
3341
3750
|
* Every entry removes itself the moment its own wait ends, however it ends.
|
|
@@ -3413,10 +3822,22 @@ declare class MllpClient extends EventEmitter {
|
|
|
3413
3822
|
* - `MllpConnectionError({ phase: 'connect', connectionCause: 'connect-timeout' })` if
|
|
3414
3823
|
* {@link ClientOptions.connectTimeoutMs} is set and the TCP connect, or the TLS handshake
|
|
3415
3824
|
* after it, did not complete in time. The socket is destroyed; nothing was written.
|
|
3825
|
+
* - `MllpConnectionError({ phase: 'connect' })` if {@link MllpClient.destroy} is called while
|
|
3826
|
+
* `connect()` is still connecting, over TCP or TLS, before or during the handshake. Its
|
|
3827
|
+
* `cause` is the reason passed to `destroy(reason)`, as it is, and its message is that
|
|
3828
|
+
* reason's; with no reason the cause is an `Error` whose message is `closed before connect`,
|
|
3829
|
+
* the same as for any socket that closes before connecting with no error. It carries no
|
|
3830
|
+
* `connectionCause` either way: a reason is the caller's own, so one whose message or `code`
|
|
3831
|
+
* reads like a TLS failure (`alert`, `ERR_SSL_*`, `EPROTO`, a certificate code) is never
|
|
3832
|
+
* sorted into `'tls-handshake'` or `'tls-verify'`. The first `destroy()` decides: a second
|
|
3833
|
+
* call before `connect()` settles, with a reason or without one, changes nothing.
|
|
3416
3834
|
* - `MllpTlsConfigurationError` if the configured cipher-suite list cannot be
|
|
3417
|
-
* honoured (the runtime rejects it,
|
|
3418
|
-
* both declare one). Raised
|
|
3419
|
-
* connected; identify it by
|
|
3835
|
+
* honoured (the runtime rejects it, the runtime does not enforce cipher lists
|
|
3836
|
+
* at all, or `atnaTransportSecurity` and `ciphers` both declare one). Raised
|
|
3837
|
+
* **before** a socket is opened, so nothing is left connected; identify it by
|
|
3838
|
+
* `instanceof` plus its stable `code`.
|
|
3839
|
+
* - `MllpTlsConfigurationError` with `MLLP_TLS_PFX_REJECTED` if `tls.pfx` cannot be loaded
|
|
3840
|
+
* with `tls.passphrase` (see {@link TlsOptions.pfx}), also before a socket is opened.
|
|
3420
3841
|
*
|
|
3421
3842
|
* **Dual failure signal on initial connect:** the Connection's transport
|
|
3422
3843
|
* error handler is attached before this promise's own error listener, so a
|
|
@@ -3664,8 +4085,8 @@ declare class MllpClient extends EventEmitter {
|
|
|
3664
4085
|
*
|
|
3665
4086
|
* Resolves with the ACK Buffer (framing stripped). Rejects with:
|
|
3666
4087
|
* - `DOMException('Aborted', 'AbortError')` if `signal` aborts before the ACK.
|
|
3667
|
-
* - `MllpTimeoutError` if no ACK arrives within `ackTimeoutMs
|
|
3668
|
-
* The clock starts at the underlying `write()` flush callback, NOT at
|
|
4088
|
+
* - `MllpTimeoutError` if no ACK arrives within `ackTimeoutMs` (this send's own, else the
|
|
4089
|
+
* client's). The clock starts at the underlying `write()` flush callback, NOT at
|
|
3669
4090
|
* the `send()` call.
|
|
3670
4091
|
* - `MllpConnectionError({ phase: 'send' })` if the client is not connected.
|
|
3671
4092
|
*
|
|
@@ -3694,7 +4115,10 @@ declare class MllpClient extends EventEmitter {
|
|
|
3694
4115
|
*
|
|
3695
4116
|
* @param payload Raw bytes; MLLP framing is added internally via `encodeFrame`.
|
|
3696
4117
|
* @param opts.signal AbortSignal, aborting cancels the ACK wait.
|
|
3697
|
-
* @param opts.ackTimeoutMs
|
|
4118
|
+
* @param opts.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
|
|
4119
|
+
* moment its bytes are flushed, in place of the client's `ackTimeoutMs`. Under
|
|
4120
|
+
* `onBackpressure: "wait"` it also bounds the wait for queue room, and the
|
|
4121
|
+
* acknowledgement wait then starts afresh once the send is written.
|
|
3698
4122
|
* @param opts.applicationAckTimeoutMs Per-send override of the second wait's bound.
|
|
3699
4123
|
* @param opts.onCommitAck Called with the commit disposition when the peer commits the
|
|
3700
4124
|
* message ahead of its application acknowledgement. See {@link CommitAckReport}.
|
|
@@ -3907,6 +4331,12 @@ declare class MllpClient extends EventEmitter {
|
|
|
3907
4331
|
* ever written for it; that is a statement about the bytes, not about how the client was
|
|
3908
4332
|
* shut down, so it holds on this path too.
|
|
3909
4333
|
*
|
|
4334
|
+
* A {@link MllpClient.connect} still connecting rejects with an `MllpConnectionError` whose
|
|
4335
|
+
* `phase` is `'connect'` and no `connectionCause`. Its `cause` is `reason` when one is given,
|
|
4336
|
+
* never classified as a TLS failure whatever its message or `code`, and otherwise an `Error`
|
|
4337
|
+
* whose message is `closed before connect`. Only the first call reaches the socket, so a
|
|
4338
|
+
* second `destroy()` before `connect()` settles, with or without a reason, changes nothing.
|
|
4339
|
+
*
|
|
3910
4340
|
* @example
|
|
3911
4341
|
* ```typescript
|
|
3912
4342
|
* client.destroy(new Error('shutting down'));
|
|
@@ -4004,6 +4434,8 @@ interface StarterClientOptions {
|
|
|
4004
4434
|
readonly framing?: ClientOptions["framing"];
|
|
4005
4435
|
/** TCP keepalive interval ms. */
|
|
4006
4436
|
readonly keepaliveIntervalMs?: number;
|
|
4437
|
+
/** Turn off Nagle's algorithm. Passthrough to `ClientOptions.noDelay`, default `true`. */
|
|
4438
|
+
readonly noDelay?: boolean;
|
|
4007
4439
|
/** Application-idle dead-peer timeout ms. */
|
|
4008
4440
|
readonly deadPeerTimeoutMs?: number;
|
|
4009
4441
|
/**
|
|
@@ -5080,5 +5512,5 @@ declare function runDifferential(options?: DifferentialRunOptions): Promise<Diff
|
|
|
5080
5512
|
*/
|
|
5081
5513
|
declare const VERSION: string;
|
|
5082
5514
|
|
|
5083
|
-
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_OPTION_CONFLICT, MLLP_TLS_DH_PARAMETERS_REJECTED, MLLP_TLS_VERIFY_DISABLED, MllpAckError, MllpApplicationAckError, MllpBackpressureError, MllpClient, MllpCommitRejectedError, MllpConnectionError, MllpDifferentialConfigurationError, MllpFramingError, MllpNeverDeliveredError, MllpServer, MllpTimeoutError, MllpTlsConfigurationError, MllpUnknownFateError, MllpWarning, NetTransport, TLS13_DEFAULT_CIPHER_SUITES, TlsTransport, Transport, VERSION, WarningCode, ackDiagnosticMessage, ackModeDiagnosticMessage, buildRawAck, canonicalAcknowledgement, canonicalExchanges, createClient, createServer, createStarterClient, createStarterServer, differentialConfigurationMessage, encodeFrame, isTlsProtocolError, isTlsVerificationErrorCode, isTransientConnectionError, rawAckUncorrelatable, readNegotiatedTlsParameters, resolveDifferentialPeer, resolveNackCode, resolveTlsCipherPolicy, runDifferential, tlsConfigurationMessage };
|
|
5084
|
-
export type { AckCode, AckCorrelationCode, AckCorrelationWarning, AckModeCode, AckModeWarning, AckModeWarningEvent, ApplicationAckFailure, CanonicalExchange, ClientAuth, ClientOptions, ClientStats, CommitAckReport, ConnectionErrorCause, ConnectionErrorPhase, ConnectionOptions, ConnectionRejectedEvent, ConnectionState, ConnectionStats, DifferentialConfigurationErrorCode, DifferentialConnect, DifferentialCorrelationOutcome, DifferentialDeviation, DifferentialExchangeOutcome, DifferentialExchangeReport, DifferentialParityOutcome, DifferentialPeer, DifferentialReport, DifferentialReportPeer, DifferentialRunOptions, DifferentialRunResult, DifferentialSkipReason, EncoderOptions, FrameReaderOptions, MessageMeta, NackAckCode, NackEvent, NackReason, NegativeAckCode, NegotiatedTlsParameters, PemInput, ReconnectingEvent, ResolvedTlsCipherPolicy, RetryContext, RetryStrategy, SecurityWarning, SecurityWarningCode, ServerOptions, ServerStats, ServerTlsOptions, StarterClientOptions, StarterServerOptions, StateChangeEvent, TlsCipherPolicyInput, TlsConfigurationErrorCode, TlsOptions };
|
|
5515
|
+
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, MllpWarning, NetTransport, TLS13_DEFAULT_CIPHER_SUITES, TlsTransport, Transport, VERSION, WarningCode, ackDiagnosticMessage, ackModeDiagnosticMessage, buildRawAck, canonicalAcknowledgement, canonicalExchanges, createClient, createServer, createStarterClient, createStarterServer, differentialConfigurationMessage, encodeFrame, isTlsProtocolError, isTlsVerificationErrorCode, isTransientConnectionError, rawAckUncorrelatable, readNegotiatedTlsParameters, resolveDifferentialPeer, resolveNackCode, resolveTlsCipherPolicy, runDifferential, selectAckCode, tlsConfigurationMessage };
|
|
5516
|
+
export type { AckCode, AckCodeSelection, AckCodeSelectionInput, AckCorrelationCode, AckCorrelationWarning, AckModeCode, AckModeWarning, AckModeWarningEvent, ApplicationAckFailure, CanonicalExchange, ClientAuth, ClientOptions, ClientStats, CommitAckReport, ConnectionErrorCause, ConnectionErrorPhase, ConnectionOptions, ConnectionRejectedEvent, ConnectionState, ConnectionStats, DifferentialConfigurationErrorCode, DifferentialConnect, DifferentialCorrelationOutcome, DifferentialDeviation, DifferentialExchangeOutcome, DifferentialExchangeReport, DifferentialParityOutcome, DifferentialPeer, DifferentialReport, DifferentialReportPeer, DifferentialRunOptions, DifferentialRunResult, DifferentialSkipReason, EncoderOptions, FrameReaderOptions, MessageMeta, NackAckCode, NackEvent, NackReason, NegativeAckCode, NegotiatedTlsParameters, PemInput, ReconnectingEvent, ResolvedTlsCipherPolicy, RetryContext, RetryStrategy, SecurityWarning, SecurityWarningCode, ServerOptions, ServerStats, ServerTlsOptions, StarterClientOptions, StarterServerOptions, StateChangeEvent, TlsCipherPolicyInput, TlsConfigurationErrorCode, TlsOptions };
|