node-opcua-client 2.167.0 → 2.169.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 (41) hide show
  1. package/dist/client_monitored_item.d.ts +4 -4
  2. package/dist/client_monitored_item.js +6 -5
  3. package/dist/client_monitored_item.js.map +1 -1
  4. package/dist/client_monitored_item_base.d.ts +7 -7
  5. package/dist/client_monitored_item_toolbox.d.ts +5 -5
  6. package/dist/client_monitored_item_toolbox.js +26 -19
  7. package/dist/client_monitored_item_toolbox.js.map +1 -1
  8. package/dist/private/client_base_impl.js +116 -85
  9. package/dist/private/client_base_impl.js.map +1 -1
  10. package/dist/private/client_monitored_item_group_impl.d.ts +7 -6
  11. package/dist/private/client_monitored_item_group_impl.js +6 -8
  12. package/dist/private/client_monitored_item_group_impl.js.map +1 -1
  13. package/dist/private/client_monitored_item_impl.d.ts +10 -9
  14. package/dist/private/client_monitored_item_impl.js +40 -26
  15. package/dist/private/client_monitored_item_impl.js.map +1 -1
  16. package/dist/private/client_session_impl.d.ts +1 -0
  17. package/dist/private/client_session_impl.js +12 -0
  18. package/dist/private/client_session_impl.js.map +1 -1
  19. package/dist/private/client_subscription_impl.d.ts +7 -4
  20. package/dist/private/client_subscription_impl.js +101 -77
  21. package/dist/private/client_subscription_impl.js.map +1 -1
  22. package/dist/private/opcua_client_impl.d.ts +1 -0
  23. package/dist/private/opcua_client_impl.js +11 -0
  24. package/dist/private/opcua_client_impl.js.map +1 -1
  25. package/dist/private/reconnection/client_publish_engine_reconnection.js +54 -45
  26. package/dist/private/reconnection/client_publish_engine_reconnection.js.map +1 -1
  27. package/dist/private/reconnection/reconnection.d.ts +1 -1
  28. package/dist/private/reconnection/reconnection.js +199 -280
  29. package/dist/private/reconnection/reconnection.js.map +1 -1
  30. package/package.json +43 -44
  31. package/source/client_monitored_item.ts +5 -4
  32. package/source/client_monitored_item_base.ts +13 -8
  33. package/source/client_monitored_item_toolbox.ts +24 -20
  34. package/source/private/client_base_impl.ts +169 -199
  35. package/source/private/client_monitored_item_group_impl.ts +15 -16
  36. package/source/private/client_monitored_item_impl.ts +56 -38
  37. package/source/private/client_session_impl.ts +29 -14
  38. package/source/private/client_subscription_impl.ts +151 -91
  39. package/source/private/opcua_client_impl.ts +13 -0
  40. package/source/private/reconnection/client_publish_engine_reconnection.ts +67 -60
  41. package/source/private/reconnection/reconnection.ts +253 -344
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @module node-opcua-client
3
3
  */
4
- import type { EventEmitter } from "events";
4
+ import type { EventEmitter } from "node:events";
5
5
  import { type DataValue, TimestampsToReturn } from "node-opcua-data-value";
6
6
  import type { ReadValueIdOptions } from "node-opcua-service-read";
7
- import { type MonitoringParametersOptions } from "node-opcua-types";
7
+ import type { MonitoringParametersOptions } from "node-opcua-types";
8
8
  import type { Variant } from "node-opcua-variant";
9
9
  import type { ClientMonitoredItemBase, ClientMonitoredItemOrGroupAction } from "./client_monitored_item_base";
10
10
  import type { ClientSubscription } from "./client_subscription";
@@ -15,6 +15,6 @@ export interface ClientMonitoredItem extends ClientMonitoredItemBase, ClientMoni
15
15
  on(event: "initialized", eventHandler: () => void): this;
16
16
  on(event: "err", eventHandler: (message: string) => void): this;
17
17
  }
18
- export declare class ClientMonitoredItem {
19
- static create(subscription: ClientSubscription, itemToMonitor: ReadValueIdOptions, monitoringParameters: MonitoringParametersOptions, timestampsToReturn?: TimestampsToReturn): ClientMonitoredItem;
18
+ export declare namespace ClientMonitoredItem {
19
+ let create: (subscription: ClientSubscription, itemToMonitor: ReadValueIdOptions, monitoringParameters: MonitoringParametersOptions, timestampsToReturn?: TimestampsToReturn) => ClientMonitoredItem;
20
20
  }
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClientMonitoredItem = void 0;
4
4
  const node_opcua_data_value_1 = require("node-opcua-data-value");
5
- class ClientMonitoredItem {
6
- static create(subscription, itemToMonitor, monitoringParameters, timestampsToReturn = node_opcua_data_value_1.TimestampsToReturn.Neither) {
5
+ // eslint-disable-next-line @typescript-eslint/no-namespace
6
+ var ClientMonitoredItem;
7
+ (function (ClientMonitoredItem) {
8
+ ClientMonitoredItem.create = function (subscription, itemToMonitor, monitoringParameters, timestampsToReturn = node_opcua_data_value_1.TimestampsToReturn.Neither) {
7
9
  /* c8 ignore next*/
8
10
  throw new Error("unimplemented");
9
- }
10
- }
11
- exports.ClientMonitoredItem = ClientMonitoredItem;
11
+ };
12
+ })(ClientMonitoredItem || (exports.ClientMonitoredItem = ClientMonitoredItem = {}));
12
13
  //# sourceMappingURL=client_monitored_item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client_monitored_item.js","sourceRoot":"","sources":["../source/client_monitored_item.ts"],"names":[],"mappings":";;;AAKA,iEAA2E;AAmB3E,MAAa,mBAAmB;IACrB,MAAM,CAAC,MAAM,CAChB,YAAgC,EAChC,aAAiC,EACjC,oBAAiD,EACjD,qBAAyC,0CAAkB,CAAC,OAAO;QAEnE,mBAAmB;QACnB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;CACJ;AAVD,kDAUC"}
1
+ {"version":3,"file":"client_monitored_item.js","sourceRoot":"","sources":["../source/client_monitored_item.ts"],"names":[],"mappings":";;;AAKA,iEAA2E;AAmB3E,2DAA2D;AAC3D,IAAiB,mBAAmB,CAUnC;AAVD,WAAiB,mBAAmB;IACrB,0BAAM,GAAG,UAChB,YAAgC,EAChC,aAAiC,EACjC,oBAAiD,EACjD,qBAAyC,0CAAkB,CAAC,OAAO;QAEnE,mBAAmB;QACnB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC,CAAA;AACL,CAAC,EAVgB,mBAAmB,mCAAnB,mBAAmB,QAUnC"}
@@ -1,22 +1,22 @@
1
1
  /**
2
2
  * @module node-opcua-client
3
3
  */
4
- import type { EventEmitter } from "events";
5
- import { type AttributeIds } from "node-opcua-basic-types";
4
+ import type { EventEmitter } from "node:events";
5
+ import type { AttributeIds } from "node-opcua-basic-types";
6
6
  import type { QualifiedNameLike } from "node-opcua-data-model";
7
7
  import type { DataValue } from "node-opcua-data-value";
8
8
  import type { ExtensionObject } from "node-opcua-extension-object";
9
9
  import type { NodeId } from "node-opcua-nodeid";
10
10
  import type { NumericRange } from "node-opcua-numeric-range";
11
11
  import type { TimestampsToReturn } from "node-opcua-service-read";
12
- import type { MonitoredItemCreateResult, MonitoringMode, MonitoringParameters, MonitoringParametersOptions } from "node-opcua-service-subscription";
12
+ import type { MonitoredItemCreateResult, MonitoredItemModifyResult, MonitoringMode, MonitoringParameters, MonitoringParametersOptions } from "node-opcua-service-subscription";
13
13
  import type { Callback, ErrorCallback, StatusCode } from "node-opcua-status-code";
14
14
  import type { Variant } from "node-opcua-variant";
15
15
  import type { ClientSubscription } from "./client_subscription";
16
16
  export interface ClientMonitoredItemOrGroupAction {
17
- modify(parameters: MonitoringParametersOptions, timestampsToReturn?: TimestampsToReturn): Promise<StatusCode>;
18
- modify(parameters: MonitoringParametersOptions, callback: Callback<StatusCode>): void;
19
- modify(parameters: MonitoringParametersOptions, timestampsToReturn: TimestampsToReturn | null, callback: Callback<StatusCode>): void;
17
+ modify(parameters: MonitoringParametersOptions, timestampsToReturn?: TimestampsToReturn): Promise<MonitoredItemModifyResult>;
18
+ modify(parameters: MonitoringParametersOptions, callback: Callback<MonitoredItemModifyResult>): void;
19
+ modify(parameters: MonitoringParametersOptions, timestampsToReturn: TimestampsToReturn | null, callback: Callback<MonitoredItemModifyResult>): void;
20
20
  setMonitoringMode(monitoringMode: MonitoringMode): Promise<StatusCode>;
21
21
  setMonitoringMode(monitoringMode: MonitoringMode, callback: Callback<StatusCode>): void;
22
22
  terminate(): Promise<void>;
@@ -40,7 +40,7 @@ export interface ClientMonitoredItemBase {
40
40
  readonly subscription: ClientSubscription;
41
41
  readonly monitoringMode: MonitoringMode;
42
42
  readonly statusCode: StatusCode;
43
- readonly monitoredItemId?: any;
43
+ readonly monitoredItemId?: number;
44
44
  readonly result?: MonitoredItemCreateResult;
45
45
  readonly filterResult?: ExtensionObject;
46
46
  }
@@ -1,6 +1,6 @@
1
1
  import type { TimestampsToReturn } from "node-opcua-data-value";
2
2
  import { type MonitoredItemModifyResult, type MonitoringMode } from "node-opcua-service-subscription";
3
- import { type Callback, type ErrorCallback, type StatusCode } from "node-opcua-status-code";
3
+ import type { Callback, ErrorCallback, StatusCode } from "node-opcua-status-code";
4
4
  import type { MonitoringParametersOptions } from "node-opcua-types";
5
5
  import type { ClientMonitoredItemBase } from "./client_monitored_item_base";
6
6
  import type { ClientSubscription } from "./client_subscription";
@@ -10,8 +10,8 @@ export interface ClientMonitoredItemBaseEx extends ClientMonitoredItemBase {
10
10
  /**
11
11
  * @internal
12
12
  */
13
- export declare class ClientMonitoredItemToolbox {
14
- static _toolbox_monitor(subscription: ClientSubscription, timestampsToReturn: TimestampsToReturn, monitoredItems: ClientMonitoredItemBase[], done: ErrorCallback): void;
15
- static _toolbox_modify(subscription: ClientSubscription, monitoredItems: ClientMonitoredItemBase[], parameters: MonitoringParametersOptions, timestampsToReturn: TimestampsToReturn, callback: Callback<MonitoredItemModifyResult[]>): void;
16
- static _toolbox_setMonitoringMode(subscription: ClientSubscription, monitoredItems: ClientMonitoredItemBaseEx[], monitoringMode: MonitoringMode, callback: Callback<StatusCode[]>): void;
13
+ export declare namespace ClientMonitoredItemToolbox {
14
+ function _toolbox_monitor(subscription: ClientSubscription, timestampsToReturn: TimestampsToReturn, monitoredItems: ClientMonitoredItemBase[], done: ErrorCallback): void;
15
+ function _toolbox_modify(subscription: ClientSubscription, monitoredItems: ClientMonitoredItemBase[], parameters: MonitoringParametersOptions, timestampsToReturn: TimestampsToReturn, callback: Callback<MonitoredItemModifyResult[]>): void;
16
+ function _toolbox_setMonitoringMode(subscription: ClientSubscription, monitoredItems: ClientMonitoredItemBaseEx[], monitoringMode: MonitoringMode, callback: Callback<StatusCode[]>): void;
17
17
  }
@@ -12,27 +12,24 @@ const node_opcua_assert_1 = require("node-opcua-assert");
12
12
  const node_opcua_debug_1 = require("node-opcua-debug");
13
13
  const node_opcua_service_subscription_1 = require("node-opcua-service-subscription");
14
14
  const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
15
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
15
+ const _doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
16
16
  /**
17
17
  * @internal
18
18
  */
19
- class ClientMonitoredItemToolbox {
20
- static _toolbox_monitor(subscription, timestampsToReturn, monitoredItems, done) {
19
+ var ClientMonitoredItemToolbox;
20
+ (function (ClientMonitoredItemToolbox) {
21
+ function _toolbox_monitor(subscription, timestampsToReturn, monitoredItems, done) {
21
22
  (0, node_opcua_assert_1.assert)(typeof done === "function");
22
23
  // we expect subscription to be valid and have a valid session
23
24
  if (!subscription.hasSession) {
24
25
  const err0 = new Error("Invalid subscription");
25
- if (done) {
26
- return done(err0);
27
- }
26
+ done(err0);
28
27
  return;
29
28
  }
30
29
  // may be the subscription has been terminated or is not fully initialize, in the meantime
31
30
  if (!subscription.isActive) {
32
31
  const err1 = new Error("Subscription has been terminated or is not fully initialized");
33
- if (done) {
34
- return done(err1);
35
- }
32
+ done(err1);
36
33
  return;
37
34
  }
38
35
  const itemsToCreate = [];
@@ -40,7 +37,8 @@ class ClientMonitoredItemToolbox {
40
37
  const monitoredItemI = monitoredItem;
41
38
  const itemToCreate = monitoredItemI._prepare_for_monitoring();
42
39
  if (typeof itemToCreate.error === "string") {
43
- return done(new Error(itemToCreate.error));
40
+ done(new Error(itemToCreate.error));
41
+ return;
44
42
  }
45
43
  itemsToCreate.push(itemToCreate);
46
44
  }
@@ -75,7 +73,8 @@ class ClientMonitoredItemToolbox {
75
73
  done(err ? err : undefined);
76
74
  });
77
75
  }
78
- static _toolbox_modify(subscription, monitoredItems, parameters, timestampsToReturn, callback) {
76
+ ClientMonitoredItemToolbox._toolbox_monitor = _toolbox_monitor;
77
+ function _toolbox_modify(subscription, monitoredItems, parameters, timestampsToReturn, callback) {
79
78
  (0, node_opcua_assert_1.assert)(callback === undefined || typeof callback === "function");
80
79
  const itemsToModify = monitoredItems.map((monitoredItem) => {
81
80
  const clientHandle = monitoredItem.monitoringParameters.clientHandle;
@@ -98,22 +97,26 @@ class ClientMonitoredItemToolbox {
98
97
  session.modifyMonitoredItems(modifyMonitoredItemsRequest, (err, response) => {
99
98
  /* c8 ignore next */
100
99
  if (err) {
101
- return callback(err);
100
+ callback(err);
101
+ return;
102
102
  }
103
103
  if (!response || !(response instanceof node_opcua_service_subscription_1.ModifyMonitoredItemsResponse)) {
104
- return callback(new Error("internal error"));
104
+ callback(new Error("internal error"));
105
+ return;
105
106
  }
106
107
  response.results = response.results || [];
107
108
  (0, node_opcua_assert_1.assert)(response.results.length === monitoredItems.length);
108
109
  const res = response.results[0];
109
110
  /* c8 ignore next */
110
111
  if (response.results.length === 1 && res.statusCode.isNotGood()) {
111
- return callback(new Error("Error" + res.statusCode.toString()));
112
+ callback(new Error(`Error${res.statusCode.toString()}`));
113
+ return;
112
114
  }
113
115
  callback(null, response.results);
114
116
  });
115
117
  }
116
- static _toolbox_setMonitoringMode(subscription, monitoredItems, monitoringMode, callback) {
118
+ ClientMonitoredItemToolbox._toolbox_modify = _toolbox_modify;
119
+ function _toolbox_setMonitoringMode(subscription, monitoredItems, monitoringMode, callback) {
117
120
  const monitoredItemIds = monitoredItems.map((monitoredItem) => monitoredItem.monitoredItemId);
118
121
  const setMonitoringModeRequest = {
119
122
  monitoredItemIds,
@@ -124,16 +127,20 @@ class ClientMonitoredItemToolbox {
124
127
  (0, node_opcua_assert_1.assert)(session, "expecting a valid session attached to the subscription ");
125
128
  session.setMonitoringMode(setMonitoringModeRequest, (err, response) => {
126
129
  if (err) {
127
- return callback(err);
130
+ callback(err);
131
+ return;
132
+ }
133
+ if (!response) {
134
+ callback(new Error("internal error"));
135
+ return;
128
136
  }
129
137
  monitoredItems.forEach((monitoredItem) => {
130
138
  monitoredItem.internalSetMonitoringMode(monitoringMode);
131
139
  });
132
- response = response;
133
140
  response.results = response.results || [];
134
141
  callback(null, response.results);
135
142
  });
136
143
  }
137
- }
138
- exports.ClientMonitoredItemToolbox = ClientMonitoredItemToolbox;
144
+ ClientMonitoredItemToolbox._toolbox_setMonitoringMode = _toolbox_setMonitoringMode;
145
+ })(ClientMonitoredItemToolbox || (exports.ClientMonitoredItemToolbox = ClientMonitoredItemToolbox = {}));
139
146
  //# sourceMappingURL=client_monitored_item_toolbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client_monitored_item_toolbox.js","sourceRoot":"","sources":["../source/client_monitored_item_toolbox.ts"],"names":[],"mappings":";;;;;;AAAA;;GAEG;AACH,kDAA0B;AAE1B,yDAA2C;AAE3C,uDAAiE;AACjE,qFASyC;AAUzC,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAK3C;;GAEG;AACH,MAAa,0BAA0B;IAC5B,MAAM,CAAC,gBAAgB,CAC1B,YAAgC,EAChC,kBAAsC,EACtC,cAAyC,EACzC,IAAmB;QAEnB,IAAA,0BAAM,EAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC;QAEnC,8DAA8D;QAC9D,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;YAC/C,IAAI,IAAI,EAAE,CAAC;gBACP,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,OAAO;QACX,CAAC;QAED,0FAA0F;QAC1F,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;YACvF,IAAI,IAAI,EAAE,CAAC;gBACP,OAAO,IAAI,CAAC,IA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gB,0BAA0B,0CAA1B,0BAA0B,QA8J1C"}
@@ -11,7 +11,6 @@ exports.ClientBaseImpl = void 0;
11
11
  const node_fs_1 = __importDefault(require("node:fs"));
12
12
  const node_path_1 = __importDefault(require("node:path"));
13
13
  const global_mutex_1 = require("@ster5/global-mutex");
14
- const async_1 = __importDefault(require("async"));
15
14
  const chalk_1 = __importDefault(require("chalk"));
16
15
  const node_opcua_assert_1 = require("node-opcua-assert");
17
16
  const node_opcua_certificate_manager_1 = require("node-opcua-certificate-manager");
@@ -78,8 +77,8 @@ function __findEndpoint(endpointUrl, params, _callback) {
78
77
  masterClient._tmpClient = client;
79
78
  let selectedEndpoint;
80
79
  const allEndpoints = [];
81
- const tasks = [
82
- (innerCallback) => {
80
+ const step1_connect = () => {
81
+ return new Promise((resolve, reject) => {
83
82
  // rebind backoff handler
84
83
  masterClient.listeners("backoff").forEach((handler) => {
85
84
  client.on("backoff", handler);
@@ -92,7 +91,6 @@ function __findEndpoint(endpointUrl, params, _callback) {
92
91
  }
93
92
  client.connect(endpointUrl, (err) => {
94
93
  if (err) {
95
- // let's improve the error message with meaningful info
96
94
  err.message =
97
95
  "Fail to connect to server at " +
98
96
  endpointUrl +
@@ -101,19 +99,22 @@ function __findEndpoint(endpointUrl, params, _callback) {
101
99
  err.message +
102
100
  ")";
103
101
  warningLog(err.message);
102
+ return reject(err);
104
103
  }
105
- return innerCallback(err);
104
+ resolve();
106
105
  });
107
- },
108
- (innerCallback) => {
106
+ });
107
+ };
108
+ const step2_getEndpoints = () => {
109
+ return new Promise((resolve, reject) => {
109
110
  client.getEndpoints((err, endpoints) => {
110
111
  if (err) {
111
112
  err.message = `error in getEndpoints \n${err.message}`;
112
- return innerCallback(err);
113
+ return reject(err);
113
114
  }
114
115
  // c8 ignore next
115
116
  if (!endpoints) {
116
- return innerCallback(new Error("Internal Error"));
117
+ return reject(new Error("Internal Error"));
117
118
  }
118
119
  for (const endpoint of endpoints) {
119
120
  if (endpoint.securityMode === securityMode && endpoint.securityPolicyUri === securityPolicy) {
@@ -123,20 +124,19 @@ function __findEndpoint(endpointUrl, params, _callback) {
123
124
  selectedEndpoint = endpoint; // found it
124
125
  }
125
126
  }
126
- innerCallback();
127
- });
128
- },
129
- (innerCallback) => {
130
- client.disconnect(innerCallback);
131
- }
132
- ];
133
- async_1.default.series(tasks, (err) => {
134
- if (err) {
135
- client.disconnect(() => {
136
- callback(err);
127
+ resolve();
137
128
  });
138
- return;
139
- }
129
+ });
130
+ };
131
+ const step3_disconnect = () => {
132
+ return new Promise((resolve) => {
133
+ client.disconnect(() => resolve());
134
+ });
135
+ };
136
+ step1_connect()
137
+ .then(() => step2_getEndpoints())
138
+ .then(() => step3_disconnect())
139
+ .then(() => {
140
140
  if (!selectedEndpoint) {
141
141
  return callback(new Error("Cannot find an Endpoint matching " +
142
142
  " security mode: " +
@@ -148,11 +148,12 @@ function __findEndpoint(endpointUrl, params, _callback) {
148
148
  if (doDebug) {
149
149
  debugLog(chalk_1.default.bgWhite.red("xxxxxxxxxxxxxxxxxxxxx => selected EndPoint = "), selectedEndpoint.toString());
150
150
  }
151
- const result = {
152
- endpoints: allEndpoints,
153
- selectedEndpoint
154
- };
155
- callback(null, result);
151
+ callback(null, { endpoints: allEndpoints, selectedEndpoint });
152
+ })
153
+ .catch((err) => {
154
+ client.disconnect(() => {
155
+ callback(err);
156
+ });
156
157
  });
157
158
  }
158
159
  /**
@@ -160,7 +161,7 @@ function __findEndpoint(endpointUrl, params, _callback) {
160
161
  */
161
162
  async function _verify_serverCertificate(certificateManager, serverCertificate) {
162
163
  const status = await certificateManager.checkCertificate(serverCertificate);
163
- if (status !== node_opcua_status_code_1.StatusCodes.Good) {
164
+ if (!status.isGood()) {
164
165
  // c8 ignore next
165
166
  if (doDebug) {
166
167
  // do it again for debug purposes
@@ -520,56 +521,61 @@ class ClientBaseImpl extends node_opcua_common_1.OPCUASecureObject {
520
521
  secureChannel.protocolVersion = this.protocolVersion;
521
522
  this._secureChannel = secureChannel;
522
523
  this.emit("secure_channel_created", secureChannel);
523
- async_1.default.series([
524
- // ------------------------------------------------- STEP 2 : OpenSecureChannel
525
- (innerCallback) => {
524
+ const step2_openSecureChannel = () => {
525
+ return new Promise((resolve, reject) => {
526
526
  debugLog("_internal_create_secure_channel before secureChannel.create");
527
527
  secureChannel.create(this.endpointUrl, (err) => {
528
528
  debugLog("_internal_create_secure_channel after secureChannel.create");
529
529
  if (!this._secureChannel) {
530
530
  debugLog("_secureChannel has been closed during the transaction !");
531
- return innerCallback(new Error("Secure Channel Closed"));
531
+ return reject(new Error("Secure Channel Closed"));
532
532
  }
533
- if (!err) {
534
- this._install_secure_channel_event_handlers(secureChannel);
533
+ if (err) {
534
+ return reject(err);
535
535
  }
536
- innerCallback(err);
536
+ this._install_secure_channel_event_handlers(secureChannel);
537
+ resolve();
537
538
  });
538
- },
539
- // ------------------------------------------------- STEP 3 : GetEndpointsRequest
540
- (innerCallback) => {
539
+ });
540
+ };
541
+ const step3_getEndpoints = () => {
542
+ return new Promise((resolve, reject) => {
541
543
  (0, node_opcua_assert_1.assert)(this._secureChannel !== null);
542
544
  if (!this.knowsServerEndpoint) {
543
545
  this._setInternalState("connecting");
544
546
  this.getEndpoints((err /*, endpoints?: EndpointDescription[]*/) => {
545
547
  if (!this._secureChannel) {
546
548
  debugLog("_secureChannel has been closed during the transaction ! (while getEndpoints)");
547
- return innerCallback(new Error("Secure Channel Closed"));
549
+ return reject(new Error("Secure Channel Closed"));
548
550
  }
549
- innerCallback(err ? err : undefined);
551
+ if (err) {
552
+ return reject(err);
553
+ }
554
+ resolve();
550
555
  });
551
556
  }
552
557
  else {
553
558
  // end points are already known
554
- innerCallback();
555
- }
556
- }
557
- ], (err) => {
558
- if (err) {
559
- doDebug && debugLog(this.clientName, " : Inner create secure channel has failed", err.message);
560
- if (this._secureChannel) {
561
- this._secureChannel.abortConnection(() => {
562
- this._destroy_secure_channel();
563
- callback(err);
564
- });
559
+ resolve();
565
560
  }
566
- else {
561
+ });
562
+ };
563
+ step2_openSecureChannel()
564
+ .then(() => step3_getEndpoints())
565
+ .then(() => {
566
+ (0, node_opcua_assert_1.assert)(this._secureChannel !== null);
567
+ callback(null, secureChannel);
568
+ })
569
+ .catch((err) => {
570
+ doDebug && debugLog(this.clientName, " : Inner create secure channel has failed", err.message);
571
+ if (this._secureChannel) {
572
+ this._secureChannel.abortConnection(() => {
573
+ this._destroy_secure_channel();
567
574
  callback(err);
568
- }
575
+ });
569
576
  }
570
577
  else {
571
- (0, node_opcua_assert_1.assert)(this._secureChannel !== null);
572
- callback(null, secureChannel);
578
+ callback(err);
573
579
  }
574
580
  });
575
581
  }
@@ -863,11 +869,9 @@ class ClientBaseImpl extends node_opcua_common_1.OPCUASecureObject {
863
869
  if (args.length === 1) {
864
870
  if (typeof args[0] === "function") {
865
871
  this.findServers({}, args[0]);
866
- return void 0;
867
- }
868
- else {
869
- throw new Error("Invalid arguments");
872
+ return;
870
873
  }
874
+ throw new Error("Invalid arguments");
871
875
  }
872
876
  const options = args[0];
873
877
  const callback = args[1];
@@ -889,11 +893,12 @@ class ClientBaseImpl extends node_opcua_common_1.OPCUASecureObject {
889
893
  response.servers = response.servers || [];
890
894
  callback(null, response.servers);
891
895
  });
896
+ return undefined;
892
897
  }
893
898
  findServersOnNetwork(...args) {
894
899
  if (args.length === 1) {
895
900
  this.findServersOnNetwork({}, args[0]);
896
- return;
901
+ return undefined;
897
902
  }
898
903
  const options = args[0];
899
904
  const callback = args[1];
@@ -911,7 +916,7 @@ class ClientBaseImpl extends node_opcua_common_1.OPCUASecureObject {
911
916
  response.servers = response.servers || [];
912
917
  callback(null, response.servers);
913
918
  });
914
- return;
919
+ return undefined;
915
920
  }
916
921
  _removeSession(session) {
917
922
  const index = this._sessions.indexOf(session);
@@ -1161,12 +1166,36 @@ class ClientBaseImpl extends node_opcua_common_1.OPCUASecureObject {
1161
1166
  .catch((err1) => {
1162
1167
  warningLog("[NODE-OPCUA-W25] client's server certificate verification has failed ", err1.message);
1163
1168
  warningLog(" clientCertificateManager.rootDir = ", this.clientCertificateManager.rootDir);
1164
- const f = (b) => ` ${b.toString("base64").replace(/(.{80})/g, "$1\n ")}`;
1165
1169
  const chain = (0, web_1.split_der)(endpoint.serverCertificate);
1166
- warningLog(` server certificate contains ${chain.length} elements`);
1170
+ warningLog(` server certificate chain contains ${chain.length} element(s)`);
1167
1171
  for (let i = 0; i < chain.length; i++) {
1168
1172
  const c = chain[i];
1169
- warningLog("certificate", i, `\n${f(c)}`);
1173
+ const thumbprint = (0, web_1.makeSHA1Thumbprint)(c).toString("hex");
1174
+ try {
1175
+ const { exploreCertificate } = require("node-opcua-crypto");
1176
+ const info = exploreCertificate(c);
1177
+ const tbs = info.tbsCertificate;
1178
+ const cn = tbs.subject?.commonName ?? "unknown";
1179
+ const issuerCN = tbs.issuer?.commonName ?? "unknown";
1180
+ const isCA = tbs.extensions?.basicConstraints?.cA === true;
1181
+ const isSelfSigned = JSON.stringify(tbs.subject) === JSON.stringify(tbs.issuer);
1182
+ const certType = isCA
1183
+ ? (isSelfSigned ? "Root CA" : "Intermediate CA")
1184
+ : (isSelfSigned ? "Application (self-signed)" : "Application (CA-signed)");
1185
+ const ski = tbs.extensions?.subjectKeyIdentifier ?? "-";
1186
+ const aki = tbs.extensions?.authorityKeyIdentifier?.keyIdentifier ?? "-";
1187
+ const notBefore = tbs.validity.notBefore.toISOString();
1188
+ const notAfter = tbs.validity.notAfter.toISOString();
1189
+ warningLog(` [${i + 1}/${chain.length}] "${cn}" (${certType})`);
1190
+ warningLog(` thumbprint: ${thumbprint}`);
1191
+ warningLog(` issuer: "${issuerCN}"`);
1192
+ warningLog(` SKI: ${ski}`);
1193
+ warningLog(` AKI: ${aki}`);
1194
+ warningLog(` validity: ${notBefore} → ${notAfter}`);
1195
+ }
1196
+ catch {
1197
+ warningLog(` [${i + 1}/${chain.length}] thumbprint: ${thumbprint} (details unavailable)`);
1198
+ }
1170
1199
  }
1171
1200
  if (chain.length > 1) {
1172
1201
  warningLog(" verify also that the issuer certificate is trusted and the issuer's certificate is present in the issuer.cert folder\n" +
@@ -1211,25 +1240,26 @@ class ClientBaseImpl extends node_opcua_common_1.OPCUASecureObject {
1211
1240
  }
1212
1241
  _close_pending_sessions(callback) {
1213
1242
  const sessions = [...this._sessions];
1214
- async_1.default.map(sessions, (session, next) => {
1215
- (0, node_opcua_assert_1.assert)(session._client === this);
1216
- // note: to prevent next to be call twice
1217
- let _next_already_call = false;
1218
- session.close((err) => {
1219
- if (_next_already_call) {
1220
- return;
1221
- }
1222
- _next_already_call = true;
1223
- // We should not bother if we have an error here
1224
- // Session may fail to close , if they haven't been activate and forcefully closed by server
1225
- // in a attempt to preserve resources in the case of a DDOS attack for instance.
1226
- if (err) {
1227
- const msg = session.authenticationToken ? session.authenticationToken.toString() : "";
1228
- debugLog(` failing to close session ${msg}`);
1229
- }
1230
- next();
1231
- });
1232
- }, (err) => {
1243
+ const closeAll = async () => {
1244
+ for (const session of sessions) {
1245
+ (0, node_opcua_assert_1.assert)(session._client === this);
1246
+ await new Promise((resolve) => {
1247
+ let resolved = false;
1248
+ session.close((err) => {
1249
+ if (resolved)
1250
+ return;
1251
+ resolved = true;
1252
+ if (err) {
1253
+ const msg = session.authenticationToken ? session.authenticationToken.toString() : "";
1254
+ debugLog(` failing to close session ${msg}`);
1255
+ }
1256
+ resolve();
1257
+ });
1258
+ });
1259
+ }
1260
+ };
1261
+ closeAll()
1262
+ .then(() => {
1233
1263
  // c8 ignore next
1234
1264
  if (this._sessions.length > 0) {
1235
1265
  debugLog(this._sessions
@@ -1237,8 +1267,9 @@ class ClientBaseImpl extends node_opcua_common_1.OPCUASecureObject {
1237
1267
  .join(" "));
1238
1268
  }
1239
1269
  (0, node_opcua_assert_1.assert)(this._sessions.length === 0, " failed to disconnect exiting sessions ");
1240
- callback(err || undefined);
1241
- });
1270
+ callback();
1271
+ })
1272
+ .catch((err) => callback(err));
1242
1273
  }
1243
1274
  _install_secure_channel_event_handlers(secureChannel) {
1244
1275
  (0, node_opcua_assert_1.assert)(this instanceof ClientBaseImpl);