node-opcua-client 2.103.0 → 2.105.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.
- package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js +0 -1
- package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js.map +1 -1
- package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js +8 -4
- package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js.map +1 -1
- package/dist/alarms_and_conditions/client_tools.js +24 -1
- package/dist/alarms_and_conditions/client_tools.js.map +1 -1
- package/dist/client_base.js +1 -1
- package/dist/client_base.js.map +1 -1
- package/dist/client_monitored_item_toolbox.js +5 -2
- package/dist/client_monitored_item_toolbox.js.map +1 -1
- package/dist/client_session_keepalive_manager.js +5 -3
- package/dist/client_session_keepalive_manager.js.map +1 -1
- package/dist/client_subscription.js +1 -1
- package/dist/client_subscription.js.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/private/client_base_impl.js +70 -31
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_publish_engine.js +39 -13
- package/dist/private/client_publish_engine.js.map +1 -1
- package/dist/private/client_session_impl.js +27 -24
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/client_subscription_impl.js +45 -19
- package/dist/private/client_subscription_impl.js.map +1 -1
- package/dist/private/opcua_client_impl.js +60 -24
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/reconnection.js +53 -28
- package/dist/reconnection.js.map +1 -1
- package/dist/tools/findservers.js +24 -1
- package/dist/tools/findservers.js.map +1 -1
- package/dist/tools/read_history_server_capabilities.js.map +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +9 -8
- package/dist/verify.js.map +1 -1
- package/package.json +47 -47
- package/source/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.ts +1 -5
- package/source/alarms_and_conditions/client_alarm_tools_dump_event.ts +7 -4
- package/source/client_monitored_item_toolbox.ts +1 -1
- package/source/client_session_keepalive_manager.ts +1 -2
- package/source/private/client_base_impl.ts +37 -24
- package/source/private/client_publish_engine.ts +1 -1
- package/source/private/client_session_impl.ts +22 -23
- package/source/private/client_subscription_impl.ts +1 -1
- package/source/private/opcua_client_impl.ts +40 -33
- package/source/reconnection.ts +2 -4
- package/source/tools/read_history_server_capabilities.ts +6 -0
- package/source/verify.ts +9 -8
|
@@ -9,19 +9,11 @@ import * as crypto from "crypto";
|
|
|
9
9
|
import { createPublicKey } from "crypto";
|
|
10
10
|
import { callbackify } from "util";
|
|
11
11
|
import * as async from "async";
|
|
12
|
-
import
|
|
12
|
+
import chalk from "chalk";
|
|
13
13
|
|
|
14
14
|
import { assert } from "node-opcua-assert";
|
|
15
15
|
import { createFastUninitializedBuffer } from "node-opcua-buffer-utils";
|
|
16
|
-
import {
|
|
17
|
-
Certificate,
|
|
18
|
-
exploreCertificate,
|
|
19
|
-
extractPublicKeyFromCertificateSync,
|
|
20
|
-
Nonce,
|
|
21
|
-
PrivateKey,
|
|
22
|
-
PrivateKeyPEM,
|
|
23
|
-
toPem
|
|
24
|
-
} from "node-opcua-crypto";
|
|
16
|
+
import { Certificate, exploreCertificate, extractPublicKeyFromCertificateSync, Nonce, PrivateKey, toPem } from "node-opcua-crypto";
|
|
25
17
|
|
|
26
18
|
import { LocalizedText } from "node-opcua-data-model";
|
|
27
19
|
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
@@ -609,7 +601,7 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
609
601
|
innerCallback();
|
|
610
602
|
});
|
|
611
603
|
} catch (err) {
|
|
612
|
-
|
|
604
|
+
errorLog("Exception catch in inner function, check your code ", err);
|
|
613
605
|
errorLog("OPCUAClientImpl#withClientSession", (<Error>err).message);
|
|
614
606
|
the_error = err as Error;
|
|
615
607
|
innerCallback();
|
|
@@ -638,7 +630,7 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
638
630
|
],
|
|
639
631
|
(err1) => {
|
|
640
632
|
if (err1) {
|
|
641
|
-
|
|
633
|
+
errorLog("err", err1.message);
|
|
642
634
|
}
|
|
643
635
|
if (need_disconnect) {
|
|
644
636
|
errorLog("Disconnecting client after failure");
|
|
@@ -729,7 +721,7 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
729
721
|
const result = await func(session, subscription);
|
|
730
722
|
return result;
|
|
731
723
|
} catch (err) {
|
|
732
|
-
|
|
724
|
+
errorLog("withSubscriptionAsync inner function failed ", (<Error>err).message);
|
|
733
725
|
throw err;
|
|
734
726
|
} finally {
|
|
735
727
|
await subscription.terminate();
|
|
@@ -757,9 +749,14 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
757
749
|
if (!this.__resolveEndPoint() || !this.endpoint) {
|
|
758
750
|
return callback!(
|
|
759
751
|
new Error(
|
|
760
|
-
" End point must exist " +
|
|
761
|
-
|
|
762
|
-
|
|
752
|
+
" End point must exist " +
|
|
753
|
+
this._secureChannel!.endpointUrl +
|
|
754
|
+
" securityMode = " +
|
|
755
|
+
MessageSecurityMode[this.securityMode] +
|
|
756
|
+
" securityPolicy = " +
|
|
757
|
+
this.securityPolicy
|
|
758
|
+
)
|
|
759
|
+
);
|
|
763
760
|
}
|
|
764
761
|
|
|
765
762
|
assert(
|
|
@@ -846,7 +843,7 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
846
843
|
this.clientNonce = crypto.randomBytes(32);
|
|
847
844
|
|
|
848
845
|
// recycle session name if already exists
|
|
849
|
-
const sessionName = session.name
|
|
846
|
+
const sessionName = session.name;
|
|
850
847
|
|
|
851
848
|
const request = new CreateSessionRequest({
|
|
852
849
|
clientCertificate: this.getCertificate(),
|
|
@@ -856,7 +853,7 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
856
853
|
maxResponseMessageSize: 800000,
|
|
857
854
|
requestedSessionTimeout: this.requestedSessionTimeout,
|
|
858
855
|
serverUri: this.serverUri,
|
|
859
|
-
sessionName
|
|
856
|
+
sessionName
|
|
860
857
|
});
|
|
861
858
|
|
|
862
859
|
// a client Nonce must be provided if security mode is set
|
|
@@ -865,10 +862,8 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
865
862
|
this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
866
863
|
/* istanbul ignore next */
|
|
867
864
|
if (err) {
|
|
868
|
-
|
|
865
|
+
debugLog("__createSession_step3 has failed", err.message);
|
|
869
866
|
return callback(err);
|
|
870
|
-
|
|
871
|
-
// //xxxxxx qdqsdqsdqsdqsd
|
|
872
867
|
// // we could have an invalid state here or a connection error
|
|
873
868
|
// errorLog("error: ", err.message, " retrying in ... 5 secondes");
|
|
874
869
|
// setTimeout(() => {
|
|
@@ -1156,20 +1151,32 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
1156
1151
|
if (!this.__resolveEndPoint() || !this.endpoint) {
|
|
1157
1152
|
/* istanbul ignore next */
|
|
1158
1153
|
if (this._serverEndpoints) {
|
|
1159
|
-
warningLog(
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1154
|
+
warningLog(
|
|
1155
|
+
"server endpoints =",
|
|
1156
|
+
this._serverEndpoints
|
|
1157
|
+
.map(
|
|
1158
|
+
(endpoint) =>
|
|
1159
|
+
endpoint.endpointUrl +
|
|
1160
|
+
" " +
|
|
1161
|
+
MessageSecurityMode[endpoint.securityMode] +
|
|
1162
|
+
" " +
|
|
1163
|
+
endpoint.securityPolicyUri +
|
|
1164
|
+
" " +
|
|
1165
|
+
endpoint.userIdentityTokens?.map((u) => UserTokenType[u.tokenType]).join(",")
|
|
1166
|
+
)
|
|
1167
|
+
.join("\n")
|
|
1167
1168
|
);
|
|
1168
1169
|
}
|
|
1169
|
-
return callback(
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1170
|
+
return callback(
|
|
1171
|
+
new Error(
|
|
1172
|
+
" End point must exist " +
|
|
1173
|
+
this._secureChannel!.endpointUrl +
|
|
1174
|
+
" securityMode = " +
|
|
1175
|
+
MessageSecurityMode[this.securityMode] +
|
|
1176
|
+
" securityPolicy = " +
|
|
1177
|
+
this.securityPolicy
|
|
1178
|
+
)
|
|
1179
|
+
);
|
|
1173
1180
|
}
|
|
1174
1181
|
this.serverUri = this.endpoint.server.applicationUri || "invalid application uri";
|
|
1175
1182
|
this.endpointUrl = this._secureChannel!.endpointUrl;
|
package/source/reconnection.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// tslint:disable:only-arrow-functions
|
|
6
6
|
import * as async from "async";
|
|
7
|
-
import
|
|
7
|
+
import chalk from "chalk";
|
|
8
8
|
import { assert } from "node-opcua-assert";
|
|
9
9
|
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
10
10
|
import { TransferSubscriptionsRequest, TransferSubscriptionsResponse } from "node-opcua-service-subscription";
|
|
@@ -167,7 +167,6 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
167
167
|
session: ClientSessionImpl,
|
|
168
168
|
callback: (err?: Error) => void
|
|
169
169
|
) {
|
|
170
|
-
|
|
171
170
|
// As we don"t know if server has been rebooted or not,
|
|
172
171
|
// and may be upgraded in between, we have to invalidate the extra data type manager
|
|
173
172
|
invalidateExtraDataTypeManager(session);
|
|
@@ -367,8 +366,7 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
367
366
|
// call Republish
|
|
368
367
|
return _ask_for_subscription_republish(newSession, (err) => {
|
|
369
368
|
if (err) {
|
|
370
|
-
|
|
371
|
-
console.log("warning: Subscription republished has failed ", err.message);
|
|
369
|
+
warningLog("warning: Subscription republished has failed ", err.message);
|
|
372
370
|
}
|
|
373
371
|
innerCallback(err);
|
|
374
372
|
});
|
|
@@ -55,18 +55,24 @@ export function readHistoryServerCapabilities(
|
|
|
55
55
|
const properties = [
|
|
56
56
|
"AccessHistoryDataCapability",
|
|
57
57
|
"AccessHistoryEventsCapability",
|
|
58
|
+
|
|
58
59
|
"DeleteAtTimeCapability",
|
|
59
60
|
"DeleteRawCapability",
|
|
60
61
|
"DeleteEventCapability",
|
|
62
|
+
|
|
61
63
|
"InsertAnnotationCapability",
|
|
62
64
|
"InsertDataCapability",
|
|
63
65
|
"InsertEventCapability",
|
|
66
|
+
|
|
64
67
|
"ReplaceDataCapability",
|
|
65
68
|
"ReplaceEventCapability",
|
|
69
|
+
|
|
66
70
|
"UpdateDataCapability",
|
|
67
71
|
"UpdateEventCapability",
|
|
72
|
+
|
|
68
73
|
"MaxReturnDataValues",
|
|
69
74
|
"MaxReturnEventValues",
|
|
75
|
+
|
|
70
76
|
"AggregateFunctions/AnnotationCount",
|
|
71
77
|
"AggregateFunctions/Average",
|
|
72
78
|
"AggregateFunctions/Count",
|
package/source/verify.ts
CHANGED
|
@@ -86,6 +86,7 @@ export function verifyIsOPCUAValidCertificate(
|
|
|
86
86
|
`see https://reference.opcfoundation.org/v104/Core/docs/Part6/6.2.2/\n` +
|
|
87
87
|
`certificateFile = ${certificateFile}`
|
|
88
88
|
);
|
|
89
|
+
warningLog(`keyUsage = ${JSON.stringify(keyUsage, null, " ")}`);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
const extKeyUsage = certificateInfo.tbsCertificate.extensions?.extKeyUsage;
|
|
@@ -120,21 +121,21 @@ export function verifyIsOPCUAValidCertificate(
|
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
export async function performCertificateSanityCheck(
|
|
123
|
-
|
|
124
|
+
secureObject: OPCUASecureObject,
|
|
124
125
|
serverOrClient: "server" | "client",
|
|
125
126
|
certificateManager: OPCUACertificateManager,
|
|
126
127
|
applicationUri: string
|
|
127
128
|
): Promise<void> {
|
|
128
|
-
// verify that certificate is matching private key, and inform the
|
|
129
|
-
const certificate =
|
|
130
|
-
const privateKey =
|
|
129
|
+
// verify that certificate is matching private key, and inform the developer if not
|
|
130
|
+
const certificate = secureObject.getCertificate();
|
|
131
|
+
const privateKey = secureObject.getPrivateKey();
|
|
131
132
|
//
|
|
132
133
|
if (!publicKeyAndPrivateKeyMatches(certificate, privateKey)) {
|
|
133
134
|
errorLog("[NODE-OPCUA-E01] Configuration error : the certificate and the private key do not match !");
|
|
134
135
|
errorLog(" please check the configuration of the OPCUA Server");
|
|
135
|
-
errorLog(" privateKey= ",
|
|
136
|
+
errorLog(" privateKey= ", secureObject.privateKeyFile);
|
|
136
137
|
errorLog(" certificateManager.privateKey= ", certificateManager.privateKey);
|
|
137
|
-
errorLog(" certificateFile= ",
|
|
138
|
+
errorLog(" certificateFile= ", secureObject.certificateFile);
|
|
138
139
|
throw new Error(
|
|
139
140
|
"[NODE-OPCUA-E01] Configuration error : the certificate and the private key do not match ! please fix your configuration"
|
|
140
141
|
);
|
|
@@ -154,8 +155,8 @@ export async function performCertificateSanityCheck(
|
|
|
154
155
|
const status = await certificateManager.verifyCertificateAsync(certificate);
|
|
155
156
|
|
|
156
157
|
if (status !== "Good") {
|
|
157
|
-
warningLog("[NODE-OPCUA-W04] Warning: the certificate status is = ", status, " file = ",
|
|
158
|
+
warningLog("[NODE-OPCUA-W04] Warning: the certificate status is = ", status, " file = ", secureObject.certificateFile);
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
verifyIsOPCUAValidCertificate(certificate,
|
|
161
|
+
verifyIsOPCUAValidCertificate(certificate, secureObject.certificateFile, serverOrClient, applicationUri);
|
|
161
162
|
}
|