@cosyte/mllp 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -685,6 +685,8 @@ interface TlsOptions {
685
685
  /**
686
686
  * SNI hostname and the identity-check target (matched against the server
687
687
  * certificate's Subject/SAN). Defaults to `ClientOptions.host` when unset.
688
+ * An IP address, set here or as the host, is checked against the
689
+ * certificate but never sent as SNI, which RFC 6066 reserves for host names.
688
690
  */
689
691
  readonly servername?: string;
690
692
  /**
@@ -3370,7 +3372,9 @@ declare class MllpClient extends EventEmitter {
3370
3372
  * `TlsTransport`, verification defaults **on**
3371
3373
  * (`rejectUnauthorized: !allowUnverified`), floor `minVersion: 'TLSv1.2'`
3372
3374
  * (the IHE ATNA ITI-19 BCP195 floor), `servername` defaulting to
3373
- * `ClientOptions.host`.
3375
+ * `ClientOptions.host`. An IP address is never sent as the SNI server
3376
+ * name (see `identityOptions`); the certificate is still checked
3377
+ * against it.
3374
3378
  */
3375
3379
  private _createSocketAndTransport;
3376
3380
  /**
@@ -4947,7 +4951,7 @@ interface DifferentialRunOptions {
4947
4951
  declare function runDifferential(options?: DifferentialRunOptions): Promise<DifferentialReport>;
4948
4952
 
4949
4953
  /**
4950
- * `@cosyte/mllp`, Production-grade MLLP client and server for Node.js.
4954
+ * `@cosyte/mllp`: an MLLP client and server for Node.js.
4951
4955
  *
4952
4956
  * Transport-only sibling to `@cosyte/hl7`. Handles framing, ACKs, reconnects,
4953
4957
  * backpressure, and TLS without requiring knowledge of the MLLP spec.
package/dist/index.d.ts CHANGED
@@ -685,6 +685,8 @@ interface TlsOptions {
685
685
  /**
686
686
  * SNI hostname and the identity-check target (matched against the server
687
687
  * certificate's Subject/SAN). Defaults to `ClientOptions.host` when unset.
688
+ * An IP address, set here or as the host, is checked against the
689
+ * certificate but never sent as SNI, which RFC 6066 reserves for host names.
688
690
  */
689
691
  readonly servername?: string;
690
692
  /**
@@ -3370,7 +3372,9 @@ declare class MllpClient extends EventEmitter {
3370
3372
  * `TlsTransport`, verification defaults **on**
3371
3373
  * (`rejectUnauthorized: !allowUnverified`), floor `minVersion: 'TLSv1.2'`
3372
3374
  * (the IHE ATNA ITI-19 BCP195 floor), `servername` defaulting to
3373
- * `ClientOptions.host`.
3375
+ * `ClientOptions.host`. An IP address is never sent as the SNI server
3376
+ * name (see `identityOptions`); the certificate is still checked
3377
+ * against it.
3374
3378
  */
3375
3379
  private _createSocketAndTransport;
3376
3380
  /**
@@ -4947,7 +4951,7 @@ interface DifferentialRunOptions {
4947
4951
  declare function runDifferential(options?: DifferentialRunOptions): Promise<DifferentialReport>;
4948
4952
 
4949
4953
  /**
4950
- * `@cosyte/mllp`, Production-grade MLLP client and server for Node.js.
4954
+ * `@cosyte/mllp`: an MLLP client and server for Node.js.
4951
4955
  *
4952
4956
  * Transport-only sibling to `@cosyte/hl7`. Handles framing, ACKs, reconnects,
4953
4957
  * backpressure, and TLS without requiring knowledge of the MLLP spec.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createSecureContext, createServer as createServer$2, connect } from 'tls';
1
+ import { createSecureContext, createServer as createServer$2, connect, checkServerIdentity } from 'tls';
2
2
  import { EventEmitter } from 'events';
3
3
  import { randomUUID } from 'crypto';
4
4
  import { createServer as createServer$1, createConnection, isIP, SocketAddress } from 'net';
@@ -3020,6 +3020,14 @@ var OUTBOUND_WARNING_CONTEXT = Object.freeze({
3020
3020
  byteOffset: 0,
3021
3021
  elapsedSinceSendMs: 0
3022
3022
  });
3023
+ function identityOptions(host, servername) {
3024
+ const target = servername ?? host;
3025
+ if (isIP(target) === 0) return { servername: target };
3026
+ if (target === host) return {};
3027
+ return {
3028
+ checkServerIdentity: (_hostname, cert) => checkServerIdentity(target, cert)
3029
+ };
3030
+ }
3023
3031
  var MllpClient = class extends EventEmitter {
3024
3032
  _opts;
3025
3033
  _connection = null;
@@ -3290,7 +3298,9 @@ var MllpClient = class extends EventEmitter {
3290
3298
  * `TlsTransport`, verification defaults **on**
3291
3299
  * (`rejectUnauthorized: !allowUnverified`), floor `minVersion: 'TLSv1.2'`
3292
3300
  * (the IHE ATNA ITI-19 BCP195 floor), `servername` defaulting to
3293
- * `ClientOptions.host`.
3301
+ * `ClientOptions.host`. An IP address is never sent as the SNI server
3302
+ * name (see `identityOptions`); the certificate is still checked
3303
+ * against it.
3294
3304
  */
3295
3305
  _createSocketAndTransport() {
3296
3306
  const tlsOpt = this._opts.tls;
@@ -3303,7 +3313,7 @@ var MllpClient = class extends EventEmitter {
3303
3313
  const socket = connect({
3304
3314
  host: this._opts.host,
3305
3315
  port: this._opts.port,
3306
- servername: tlsOpts.servername ?? this._opts.host,
3316
+ ...identityOptions(this._opts.host, tlsOpts.servername),
3307
3317
  ...tlsOpts.ca !== void 0 ? { ca: tlsOpts.ca } : {},
3308
3318
  ...tlsOpts.cert !== void 0 ? { cert: tlsOpts.cert } : {},
3309
3319
  ...tlsOpts.key !== void 0 ? { key: tlsOpts.key } : {},
@@ -4945,7 +4955,7 @@ async function runDifferential(options = {}) {
4945
4955
  }
4946
4956
 
4947
4957
  // src/index.ts
4948
- var VERSION = "0.1.0";
4958
+ var VERSION = "0.1.2";
4949
4959
 
4950
4960
  export { ATNA_CIPHER_LIST, ATNA_CIPHER_SUITES, Connection, FrameReader, MLLP_BIND_ALL_INTERFACES, 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, 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, tlsConfigurationMessage };
4951
4961
  //# sourceMappingURL=index.mjs.map