node-opcua-transport 2.55.0 → 2.59.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.
Files changed (43) hide show
  1. package/.mocharc.yml +10 -10
  2. package/LICENSE +20 -20
  3. package/dist/source/AcknowledgeMessage.js +5 -5
  4. package/dist/source/AcknowledgeMessage.js.map +1 -1
  5. package/dist/source/TCPErrorMessage.js.map +1 -1
  6. package/dist/source/client_tcp_transport.d.ts +3 -3
  7. package/dist/source/client_tcp_transport.js +2 -2
  8. package/dist/source/client_tcp_transport.js.map +1 -1
  9. package/dist/source/server_tcp_transport.d.ts +3 -0
  10. package/dist/source/server_tcp_transport.js +2 -7
  11. package/dist/source/server_tcp_transport.js.map +1 -1
  12. package/dist/source/tcp_transport.js +2 -2
  13. package/dist/source/tools.d.ts +1 -1
  14. package/dist/source/tools.js +4 -4
  15. package/dist/source/tools.js.map +1 -1
  16. package/dist/source/utils.js +1 -1
  17. package/dist/source/utils.js.map +1 -1
  18. package/dist/test-fixtures/fixture_full_tcp_packets.js +8 -8
  19. package/dist/test-fixtures/fixture_full_tcp_packets.js.map +1 -1
  20. package/dist/test_helpers/direct_transport.d.ts +1 -1
  21. package/dist/test_helpers/direct_transport.js.map +1 -1
  22. package/dist/test_helpers/fake_server.d.ts +2 -2
  23. package/dist/test_helpers/fake_server.js +1 -1
  24. package/dist/test_helpers/fake_server.js.map +1 -1
  25. package/dist/test_helpers/half_com_channel.js +2 -4
  26. package/dist/test_helpers/half_com_channel.js.map +1 -1
  27. package/dist/test_helpers/socket_transport.js +1 -0
  28. package/dist/test_helpers/socket_transport.js.map +1 -1
  29. package/package.json +11 -9
  30. package/source/AcknowledgeMessage.ts +7 -9
  31. package/source/TCPErrorMessage.ts +58 -57
  32. package/source/client_tcp_transport.ts +366 -366
  33. package/source/index.ts +11 -11
  34. package/source/message_builder_base.ts +2 -2
  35. package/source/server_tcp_transport.ts +11 -12
  36. package/source/tcp_transport.ts +455 -455
  37. package/source/tools.ts +4 -4
  38. package/source/utils.ts +1 -1
  39. package/test_helpers/direct_transport.ts +2 -2
  40. package/test_helpers/fake_server.ts +69 -71
  41. package/test_helpers/half_com_channel.ts +2 -5
  42. package/test_helpers/index.ts +4 -4
  43. package/test_helpers/socket_transport.ts +33 -34
package/source/index.ts CHANGED
@@ -1,11 +1,11 @@
1
- /**
2
- * @module node-opcua-transport
3
- */
4
- export * from "./HelloMessage";
5
- export * from "./AcknowledgeMessage";
6
- export * from "./TCPErrorMessage";
7
- export * from "./client_tcp_transport";
8
- export * from "./server_tcp_transport";
9
- export * from "./tcp_transport";
10
- export * from "./tools";
11
- export * from "./message_builder_base";
1
+ /**
2
+ * @module node-opcua-transport
3
+ */
4
+ export * from "./HelloMessage";
5
+ export * from "./AcknowledgeMessage";
6
+ export * from "./TCPErrorMessage";
7
+ export * from "./client_tcp_transport";
8
+ export * from "./server_tcp_transport";
9
+ export * from "./tcp_transport";
10
+ export * from "./tools";
11
+ export * from "./message_builder_base";
@@ -106,7 +106,7 @@ export class MessageBuilderBase extends EventEmitter {
106
106
  this._init_new();
107
107
  }
108
108
 
109
- public dispose() {
109
+ public dispose(): void {
110
110
  this.removeAllListeners();
111
111
  }
112
112
 
@@ -115,7 +115,7 @@ export class MessageBuilderBase extends EventEmitter {
115
115
  * @method feed
116
116
  * @param data
117
117
  */
118
- public feed(data: Buffer) {
118
+ public feed(data: Buffer): void {
119
119
  if (!this._securityDefeated && !this._hasReceivedError) {
120
120
  this._packetAssembler.feed(data);
121
121
  }
@@ -3,11 +3,12 @@
3
3
  */
4
4
  // tslint:disable:class-name
5
5
  // system
6
- import * as chalk from "chalk";
7
6
  import { Socket } from "net";
7
+ import * as chalk from "chalk";
8
8
  import { assert } from "node-opcua-assert";
9
9
 
10
10
  // opcua requires
11
+ import * as debug from "node-opcua-debug";
11
12
  import { BinaryStream } from "node-opcua-binary-stream";
12
13
  import { verify_message_chunk } from "node-opcua-chunkmanager";
13
14
  import { StatusCode, StatusCodes } from "node-opcua-status-code";
@@ -19,8 +20,6 @@ import { HelloMessage } from "./HelloMessage";
19
20
  import { TCP_transport } from "./tcp_transport";
20
21
  import { TCPErrorMessage } from "./TCPErrorMessage";
21
22
  import { decodeMessage, packTcpMessage } from "./tools";
22
-
23
- import * as debug from "node-opcua-debug";
24
23
  import { doTraceHelloAck } from "./utils";
25
24
 
26
25
  const hexDump = debug.hexDump;
@@ -54,7 +53,7 @@ const minimumBufferSize = 8192;
54
53
  *
55
54
  */
56
55
  export class ServerTCP_transport extends TCP_transport {
57
- public static throttleTime: number = 1000;
56
+ public static throttleTime = 1000;
58
57
 
59
58
  public receiveBufferSize: number;
60
59
  public sendBufferSize: number;
@@ -103,7 +102,7 @@ export class ServerTCP_transport extends TCP_transport {
103
102
  *
104
103
  *
105
104
  */
106
- public init(socket: Socket, callback: ErrorCallback) {
105
+ public init(socket: Socket, callback: ErrorCallback): void {
107
106
  if (debugLog) {
108
107
  debugLog(chalk.cyan("init socket"));
109
108
  }
@@ -113,10 +112,10 @@ export class ServerTCP_transport extends TCP_transport {
113
112
  this._install_HEL_message_receiver(callback);
114
113
  }
115
114
 
116
- public abortWithError(statusCode: StatusCode, extraErrorDescription: string, callback: ErrorCallback) {
115
+ public abortWithError(statusCode: StatusCode, extraErrorDescription: string, callback: ErrorCallback): void {
117
116
  return this._abortWithError(statusCode, extraErrorDescription, callback);
118
117
  }
119
- private _abortWithError(statusCode: StatusCode, extraErrorDescription: string, callback: ErrorCallback) {
118
+ private _abortWithError(statusCode: StatusCode, extraErrorDescription: string, callback: ErrorCallback): void {
120
119
  if (debugLog) {
121
120
  debugLog(chalk.cyan("_abortWithError"));
122
121
  }
@@ -128,7 +127,7 @@ export class ServerTCP_transport extends TCP_transport {
128
127
  this._aborted = 1;
129
128
  setTimeout(() => {
130
129
  // send the error message and close the connection
131
- assert(StatusCodes.hasOwnProperty(statusCode.name));
130
+ assert(Object.prototype.hasOwnProperty.call(StatusCodes, statusCode.name));
132
131
 
133
132
  /* istanbul ignore next*/
134
133
  if (doDebug) {
@@ -155,7 +154,7 @@ export class ServerTCP_transport extends TCP_transport {
155
154
  }
156
155
  }
157
156
 
158
- private _send_ACK_response(helloMessage: HelloMessage) {
157
+ private _send_ACK_response(helloMessage: HelloMessage): void {
159
158
  assert(helloMessage.receiveBufferSize >= minimumBufferSize);
160
159
  assert(helloMessage.sendBufferSize >= minimumBufferSize);
161
160
 
@@ -198,7 +197,7 @@ export class ServerTCP_transport extends TCP_transport {
198
197
  this.write(messageChunk);
199
198
  }
200
199
 
201
- private _install_HEL_message_receiver(callback: ErrorCallback) {
200
+ private _install_HEL_message_receiver(callback: ErrorCallback): void {
202
201
  if (debugLog) {
203
202
  debugLog(chalk.cyan("_install_HEL_message_receiver "));
204
203
  }
@@ -212,7 +211,7 @@ export class ServerTCP_transport extends TCP_transport {
212
211
  });
213
212
  }
214
213
 
215
- private _on_HEL_message(data: Buffer, callback: ErrorCallback) {
214
+ private _on_HEL_message(data: Buffer, callback: ErrorCallback): void {
216
215
  if (debugLog) {
217
216
  debugLog(chalk.cyan("_on_HEL_message"));
218
217
  }
@@ -269,7 +268,7 @@ export class ServerTCP_transport extends TCP_transport {
269
268
  this._send_ACK_response(helloMessage);
270
269
  } catch (err) {
271
270
  // connection rejected because of malformed message
272
- return this._abortWithError(StatusCodes.BadConnectionRejected, err instanceof Error ? err.message: "", callback);
271
+ return this._abortWithError(StatusCodes.BadConnectionRejected, err instanceof Error ? err.message : "", callback);
273
272
  }
274
273
  callback(); // no Error
275
274
  } else {