node-opcua-transport 2.170.0 → 2.173.0

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.
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @module node-opcua-transport
3
+ */
4
+ import type { AcknowledgeMessage } from "./AcknowledgeMessage";
5
+ /**
6
+ * Options used to construct a client transport. Passed through {@link IClientTransportFactory.create}
7
+ * and applied to the UACP HEL message during the handshake.
8
+ */
9
+ export interface TransportSettingsOptions {
10
+ maxChunkCount?: number;
11
+ maxMessageSize?: number;
12
+ receiveBufferSize?: number;
13
+ sendBufferSize?: number;
14
+ }
15
+ /**
16
+ * The minimal surface that {@link ClientSecureChannelLayer} (and anything else acting as
17
+ * a secure-channel client) uses from a transport. {@link ClientTCP_transport} already
18
+ * satisfies this interface; browser transports (e.g. a WebSocket-based one) must also
19
+ * satisfy it to be pluggable via {@link IClientTransportFactory}.
20
+ *
21
+ * This interface is intentionally the smallest superset of what the existing
22
+ * `ClientTCP_transport` exposes and that the secure-channel layer actually consumes,
23
+ * so adding new transports does not require replicating Node-specific machinery.
24
+ */
25
+ export interface IClientTransport {
26
+ /** diagnostic name, useful in debug logs */
27
+ readonly name: string;
28
+ /** OPC UA UACP protocol version advertised in HEL */
29
+ protocolVersion: number;
30
+ /** overall timeout applied to the underlying socket / connection lifecycle */
31
+ timeout: number;
32
+ /** number of times the owning channel has retried. Advisory; bumped by callers. */
33
+ numberOfRetry: number;
34
+ /** endpoint URL the transport was connected to (set by `connect`) */
35
+ endpointUrl: string;
36
+ /** URI reported by the local application to the peer */
37
+ serverUri: string;
38
+ readonly parameters?: AcknowledgeMessage;
39
+ readonly receiveBufferSize: number;
40
+ readonly sendBufferSize: number;
41
+ readonly maxChunkCount: number;
42
+ readonly maxMessageSize: number;
43
+ readonly bytesRead: number;
44
+ readonly bytesWritten: number;
45
+ readonly chunkReadCount: number;
46
+ readonly chunkWrittenCount: number;
47
+ /** connect to `endpointUrl` and perform the UACP HEL/ACK handshake */
48
+ connect(endpointUrl: string, callback: (err?: Error | null) => void): void;
49
+ /** gracefully disconnect; invokes `callback` when the underlying connection is closed */
50
+ disconnect(callback: (err?: Error | null) => void): void;
51
+ /** forcibly release resources (close the connection if still open) */
52
+ dispose(): void;
53
+ /** write a single UACP chunk to the transport */
54
+ write(chunk: Buffer, callback?: (err?: Error | null) => undefined): void;
55
+ /** emit an ERR back to the peer and destroy the underlying connection */
56
+ prematureTerminate(err: Error, statusCode: import("node-opcua-status-code").StatusCode): void;
57
+ /** simulate a connection break (used by reconnection logic in tests) */
58
+ forceConnectionBreak(): void;
59
+ /** `true` when the underlying connection is open and usable */
60
+ isValid(): boolean;
61
+ /** `true` when `disconnect()` has started or the connection is gone */
62
+ isDisconnecting(): boolean;
63
+ /** return the effective transport settings (`maxChunkCount` etc.) */
64
+ getTransportSettings(): TransportSettingsOptions;
65
+ on(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
66
+ on(eventName: "close", eventHandler: (err: Error | null) => void): this;
67
+ on(eventName: "connection_break", eventHandler: (err: Error | null) => void): this;
68
+ on(eventName: "connect", eventHandler: () => void): this;
69
+ once(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
70
+ once(eventName: "close", eventHandler: (err: Error | null) => void): this;
71
+ once(eventName: "connection_break", eventHandler: (err: Error | null) => void): this;
72
+ once(eventName: "connect", eventHandler: () => void): this;
73
+ removeListener(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
74
+ removeListener(eventName: "close", eventHandler: (err: Error | null) => void): this;
75
+ removeListener(eventName: "connection_break", eventHandler: (err: Error | null) => void): this;
76
+ removeListener(eventName: "connect", eventHandler: () => void): this;
77
+ }
78
+ /**
79
+ * A factory that produces an {@link IClientTransport}. Injected into
80
+ * {@link ClientSecureChannelLayerOptions.transportFactory} to swap the default Node TCP
81
+ * transport for an alternative (for example, a browser WebSocket transport or a tracing
82
+ * proxy wrapped around the default).
83
+ */
84
+ export interface IClientTransportFactory {
85
+ /**
86
+ * Create a new transport. Called once per secure-channel open; the factory must not
87
+ * return the same instance twice.
88
+ */
89
+ create(settings?: TransportSettingsOptions): IClientTransport;
90
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * @module node-opcua-transport
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=i_client_transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i_client_transport.js","sourceRoot":"","sources":["../../source/i_client_transport.ts"],"names":[],"mappings":";AAAA;;GAEG"}
@@ -0,0 +1,62 @@
1
+ /*!
2
+ * The MIT License (MIT)
3
+ * Copyright (c) 2022-2025 Sterfive SAS - 833264583 RCS ORLEANS - France (https://www.sterfive.com)
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ * this software and associated documentation files (the "Software"), to deal in
7
+ * the Software without restriction, including without limitation the rights to
8
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ * the Software, and to permit persons to whom the Software is furnished to do so,
10
+ * subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ */
15
+ /**
16
+ * @module node-opcua-transport/browser
17
+ *
18
+ * Browser-safe subset of `node-opcua-transport`. Selected automatically by
19
+ * bundlers (esbuild, webpack, vite, rollup) via the `"browser"` condition in
20
+ * this package's `exports` map.
21
+ *
22
+ * Excludes Node-only modules whose top-level `import "node:net" | "node:os"`
23
+ * statements would otherwise crash a `platform: "browser"` bundle even though
24
+ * the runtime never reaches them:
25
+ * - `client_tcp_transport` — opens a `net.Socket`
26
+ * - `default_client_transport_factory` — instantiates `ClientTCP_transport`
27
+ * - `server_tcp_transport` — Node-side server endpoint
28
+ *
29
+ * Browser-side OPC UA transports (e.g. `ClientWS_transport` from
30
+ * `node-opcua-client-browser`) extend `ClientTransportBase` from this entry,
31
+ * implement their own `connect()`, and inherit the inherited HEL/ACK,
32
+ * packet-assembly, and lifecycle machinery.
33
+ *
34
+ * ## Bundler configuration required
35
+ *
36
+ * Several files still re-exported here import `node:events` (e.g.
37
+ * `tcp_transport.ts`, `message_builder_base.ts`). Browser bundlers do not
38
+ * auto-polyfill `node:`-prefixed built-ins; consumers must alias them to
39
+ * polyfill packages. Example (esbuild):
40
+ *
41
+ * alias: {
42
+ * "node:events": "events",
43
+ * "node:util": "util",
44
+ * "node:buffer": "buffer"
45
+ * }
46
+ *
47
+ * Transitively, `node-opcua-debug` and `node-opcua-utils` also need these
48
+ * aliases. We deliberately do not declare the polyfills as dependencies of
49
+ * the transport package — Node consumers would pay the install cost for no
50
+ * benefit, and Node would prefer the npm port over its own built-in.
51
+ */
52
+ export * from "./AcknowledgeMessage";
53
+ export * from "./client_transport_base";
54
+ export * from "./HelloMessage";
55
+ export * from "./i_client_transport";
56
+ export * from "./i_hello_ack_limits";
57
+ export * from "./message_builder_base";
58
+ export * from "./status_codes";
59
+ export * from "./TCPErrorMessage";
60
+ export * from "./tcp_transport";
61
+ export * from "./tools";
62
+ export * from "./utils";
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /*!
18
+ * The MIT License (MIT)
19
+ * Copyright (c) 2022-2025 Sterfive SAS - 833264583 RCS ORLEANS - France (https://www.sterfive.com)
20
+ *
21
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
22
+ * this software and associated documentation files (the "Software"), to deal in
23
+ * the Software without restriction, including without limitation the rights to
24
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
25
+ * the Software, and to permit persons to whom the Software is furnished to do so,
26
+ * subject to the following conditions:
27
+ *
28
+ * The above copyright notice and this permission notice shall be included in all
29
+ * copies or substantial portions of the Software.
30
+ */
31
+ /**
32
+ * @module node-opcua-transport/browser
33
+ *
34
+ * Browser-safe subset of `node-opcua-transport`. Selected automatically by
35
+ * bundlers (esbuild, webpack, vite, rollup) via the `"browser"` condition in
36
+ * this package's `exports` map.
37
+ *
38
+ * Excludes Node-only modules whose top-level `import "node:net" | "node:os"`
39
+ * statements would otherwise crash a `platform: "browser"` bundle even though
40
+ * the runtime never reaches them:
41
+ * - `client_tcp_transport` — opens a `net.Socket`
42
+ * - `default_client_transport_factory` — instantiates `ClientTCP_transport`
43
+ * - `server_tcp_transport` — Node-side server endpoint
44
+ *
45
+ * Browser-side OPC UA transports (e.g. `ClientWS_transport` from
46
+ * `node-opcua-client-browser`) extend `ClientTransportBase` from this entry,
47
+ * implement their own `connect()`, and inherit the inherited HEL/ACK,
48
+ * packet-assembly, and lifecycle machinery.
49
+ *
50
+ * ## Bundler configuration required
51
+ *
52
+ * Several files still re-exported here import `node:events` (e.g.
53
+ * `tcp_transport.ts`, `message_builder_base.ts`). Browser bundlers do not
54
+ * auto-polyfill `node:`-prefixed built-ins; consumers must alias them to
55
+ * polyfill packages. Example (esbuild):
56
+ *
57
+ * alias: {
58
+ * "node:events": "events",
59
+ * "node:util": "util",
60
+ * "node:buffer": "buffer"
61
+ * }
62
+ *
63
+ * Transitively, `node-opcua-debug` and `node-opcua-utils` also need these
64
+ * aliases. We deliberately do not declare the polyfills as dependencies of
65
+ * the transport package — Node consumers would pay the install cost for no
66
+ * benefit, and Node would prefer the npm port over its own built-in.
67
+ */
68
+ __exportStar(require("./AcknowledgeMessage"), exports);
69
+ __exportStar(require("./client_transport_base"), exports);
70
+ __exportStar(require("./HelloMessage"), exports);
71
+ __exportStar(require("./i_client_transport"), exports);
72
+ __exportStar(require("./i_hello_ack_limits"), exports);
73
+ __exportStar(require("./message_builder_base"), exports);
74
+ __exportStar(require("./status_codes"), exports);
75
+ __exportStar(require("./TCPErrorMessage"), exports);
76
+ __exportStar(require("./tcp_transport"), exports);
77
+ __exportStar(require("./tools"), exports);
78
+ __exportStar(require("./utils"), exports);
79
+ //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../source/index.browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;GAaG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,uDAAqC;AACrC,0DAAwC;AACxC,iDAA+B;AAC/B,uDAAqC;AACrC,uDAAqC;AACrC,yDAAuC;AACvC,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC;AAChC,0CAAwB;AACxB,0CAAwB"}
@@ -25,7 +25,10 @@
25
25
  */
26
26
  export * from "./AcknowledgeMessage";
27
27
  export * from "./client_tcp_transport";
28
+ export * from "./client_transport_base";
29
+ export * from "./default_client_transport_factory";
28
30
  export * from "./HelloMessage";
31
+ export * from "./i_client_transport";
29
32
  export * from "./i_hello_ack_limits";
30
33
  export * from "./message_builder_base";
31
34
  export * from "./server_tcp_transport";
@@ -41,7 +41,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
41
41
  */
42
42
  __exportStar(require("./AcknowledgeMessage"), exports);
43
43
  __exportStar(require("./client_tcp_transport"), exports);
44
+ __exportStar(require("./client_transport_base"), exports);
45
+ __exportStar(require("./default_client_transport_factory"), exports);
44
46
  __exportStar(require("./HelloMessage"), exports);
47
+ __exportStar(require("./i_client_transport"), exports);
45
48
  __exportStar(require("./i_hello_ack_limits"), exports);
46
49
  __exportStar(require("./message_builder_base"), exports);
47
50
  __exportStar(require("./server_tcp_transport"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;AACH,uDAAqC;AACrC,yDAAuC;AACvC,iDAA+B;AAC/B,uDAAqC;AACrC,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC;AAChC,0CAAwB;AACxB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;AACH,uDAAqC;AACrC,yDAAuC;AACvC,0DAAwC;AACxC,qEAAmD;AACnD,iDAA+B;AAC/B,uDAAqC;AACrC,uDAAqC;AACrC,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC;AAChC,0CAAwB;AACxB,0CAAwB"}