node-opcua-client 2.84.0 → 2.86.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_dump_event.js +1 -2
- package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js.map +1 -1
- package/dist/alarms_and_conditions/client_tools.js +1 -2
- package/dist/alarms_and_conditions/client_tools.js.map +1 -1
- package/dist/client_base.d.ts +4 -4
- package/dist/client_monitored_item_toolbox.js +1 -2
- package/dist/client_monitored_item_toolbox.js.map +1 -1
- package/dist/client_session.d.ts +12 -12
- package/dist/client_session_keepalive_manager.js +1 -2
- package/dist/client_session_keepalive_manager.js.map +1 -1
- package/dist/client_subscription.d.ts +1 -1
- package/dist/client_utils.js +1 -2
- package/dist/client_utils.js.map +1 -1
- package/dist/common.d.ts +2 -2
- package/dist/opcua_client.d.ts +4 -4
- package/dist/private/client_base_impl.d.ts +1 -1
- package/dist/private/client_base_impl.js +59 -51
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_monitored_item_impl.d.ts +1 -1
- package/dist/private/client_monitored_item_impl.js +3 -4
- package/dist/private/client_monitored_item_impl.js.map +1 -1
- package/dist/private/client_session_impl.d.ts +4 -4
- package/dist/private/client_session_impl.js +1 -1
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/client_subscription_impl.js +18 -18
- package/dist/private/client_subscription_impl.js.map +1 -1
- package/dist/private/opcua_client_impl.js +6 -5
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/reconnection.d.ts +1 -1
- package/dist/reconnection.js +1 -1
- package/dist/reconnection.js.map +1 -1
- package/dist/tools/read_history_server_capabilities.js +2 -3
- package/dist/tools/read_history_server_capabilities.js.map +1 -1
- package/dist/verify.js +1 -1
- package/dist/verify.js.map +1 -1
- package/package.json +41 -41
- package/source/alarms_and_conditions/client_alarm_tools_dump_event.ts +1 -2
- package/source/alarms_and_conditions/client_tools.ts +1 -1
- package/source/client_monitored_item_toolbox.ts +1 -1
- package/source/client_session_keepalive_manager.ts +1 -1
- package/source/client_utils.ts +1 -1
- package/source/private/client_base_impl.ts +15 -2
- package/source/private/client_monitored_item_impl.ts +4 -5
- package/source/private/client_session_impl.ts +3 -3
- package/source/private/client_subscription_impl.ts +1 -1
- package/source/private/opcua_client_impl.ts +7 -7
- package/source/reconnection.ts +2 -2
- package/source/tools/read_history_server_capabilities.ts +2 -2
- package/source/verify.ts +2 -1
|
@@ -158,7 +158,7 @@ export class ClientSessionKeepAliveManager extends EventEmitter implements Clien
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
if (dataValue.statusCode
|
|
161
|
+
if (dataValue.statusCode.isGood()) {
|
|
162
162
|
const newState = dataValue.value.value as ServerState;
|
|
163
163
|
// istanbul ignore next
|
|
164
164
|
if (newState !== this.lastKnownState && this.lastKnownState) {
|
package/source/client_utils.ts
CHANGED
|
@@ -83,7 +83,7 @@ export function readUAAnalogItem(session: ClientSession, nodeId: NodeIdLike, ...
|
|
|
83
83
|
const nodesToRead: ReadValueIdOptions[] = [];
|
|
84
84
|
|
|
85
85
|
function processProperty(browsePathResult: BrowsePathResult, propertyName: string) {
|
|
86
|
-
if (browsePathResult.statusCode
|
|
86
|
+
if (browsePathResult.statusCode.isGood()) {
|
|
87
87
|
browsePathResult.targets = browsePathResult.targets || [];
|
|
88
88
|
nodesToRead.push({
|
|
89
89
|
attributeId: AttributeIds.Value,
|
|
@@ -579,9 +579,10 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
579
579
|
"the server certificate has changed, we need to retrieve server certificate again: ",
|
|
580
580
|
err.message
|
|
581
581
|
);
|
|
582
|
+
const oldServerCertificate = this.serverCertificate;
|
|
582
583
|
warningLog(
|
|
583
584
|
"old server certificate ",
|
|
584
|
-
|
|
585
|
+
oldServerCertificate ? makeSHA1Thumbprint(oldServerCertificate!).toString("hex") : "undefined"
|
|
585
586
|
);
|
|
586
587
|
// the server may have shut down the channel because its certificate
|
|
587
588
|
// has changed ....
|
|
@@ -590,7 +591,19 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
590
591
|
if (err1) {
|
|
591
592
|
return _failAndRetry(err1, "Failing to fetch new server certificate", callback);
|
|
592
593
|
}
|
|
593
|
-
|
|
594
|
+
const newServerCertificate = this.serverCertificate!;
|
|
595
|
+
warningLog("new server certificate ", makeSHA1Thumbprint(newServerCertificate).toString("hex"));
|
|
596
|
+
|
|
597
|
+
const sha1Old = makeSHA1Thumbprint(oldServerCertificate!);
|
|
598
|
+
const sha1New = makeSHA1Thumbprint(newServerCertificate);
|
|
599
|
+
if (sha1Old === sha1New) {
|
|
600
|
+
warningLog("server certificate has not changed, but was expected to have changed");
|
|
601
|
+
return _failAndRetry(
|
|
602
|
+
new Error("Server Certificate not changed"),
|
|
603
|
+
"Failing to fetch new server certificate",
|
|
604
|
+
callback
|
|
605
|
+
);
|
|
606
|
+
}
|
|
594
607
|
this._internal_create_secure_channel(infiniteConnectionRetry, (err3?: Error | null) => {
|
|
595
608
|
if (err3) {
|
|
596
609
|
return _failAndRetry(err3, "trying to create new channel with new certificate", callback);
|
|
@@ -310,7 +310,7 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
310
310
|
this.statusCode = monitoredItemResult.statusCode;
|
|
311
311
|
|
|
312
312
|
/* istanbul ignore else */
|
|
313
|
-
if (monitoredItemResult.statusCode
|
|
313
|
+
if (monitoredItemResult.statusCode.isGood()) {
|
|
314
314
|
this.result = monitoredItemResult;
|
|
315
315
|
this.monitoredItemId = monitoredItemResult.monitoredItemId;
|
|
316
316
|
this.monitoringParameters.samplingInterval = monitoredItemResult.revisedSamplingInterval;
|
|
@@ -348,7 +348,7 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
348
348
|
public _after_create(monitoredItemResult: MonitoredItemCreateResult): void {
|
|
349
349
|
this._applyResult(monitoredItemResult);
|
|
350
350
|
|
|
351
|
-
if (this.statusCode
|
|
351
|
+
if (this.statusCode.isGood()) {
|
|
352
352
|
/**
|
|
353
353
|
* Notify the observers that the monitored item is now fully initialized.
|
|
354
354
|
* @event initialized
|
|
@@ -366,7 +366,7 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
public _terminate_and_emit(err?: Error): void {
|
|
369
|
-
if (this
|
|
369
|
+
if ((this as any)._terminated) {
|
|
370
370
|
return; // already terminated
|
|
371
371
|
}
|
|
372
372
|
if (err) {
|
|
@@ -380,8 +380,7 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
380
380
|
*/
|
|
381
381
|
this.emit("terminated", err);
|
|
382
382
|
this.removeAllListeners();
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
|
|
385
384
|
// also remove from subscription
|
|
386
385
|
const clientHandle = this.monitoringParameters.clientHandle;
|
|
387
386
|
delete this.subscription.monitoredItems[clientHandle];
|
|
@@ -520,7 +520,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
520
520
|
* ```javascript
|
|
521
521
|
* session.readVariableValue("ns=2;s=Furnace_1.Temperature",function(err,dataValue) {
|
|
522
522
|
* if(err) { return callback(err); }
|
|
523
|
-
* if (dataValue.
|
|
523
|
+
* if (dataValue.isGood()) {
|
|
524
524
|
* }
|
|
525
525
|
* console.log(dataValue.toString());
|
|
526
526
|
* callback();
|
|
@@ -1091,7 +1091,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
1091
1091
|
*
|
|
1092
1092
|
* ``` javascript
|
|
1093
1093
|
* session.readAllAttributes("ns=2;s=Furnace_1.Temperature",function(err,data) {
|
|
1094
|
-
* if(data.statusCode
|
|
1094
|
+
* if(data.statusCode.isGood()) {
|
|
1095
1095
|
* console.log(" nodeId = ",data.nodeId.toString());
|
|
1096
1096
|
* console.log(" browseName = ",data.browseName.toString());
|
|
1097
1097
|
* console.log(" description = ",data.description.toString());
|
|
@@ -2099,7 +2099,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
2099
2099
|
}
|
|
2100
2100
|
|
|
2101
2101
|
/* istanbul ignore next */
|
|
2102
|
-
if (dataValue.statusCode
|
|
2102
|
+
if (dataValue.statusCode.isNotGood()) {
|
|
2103
2103
|
return callback(new Error("readNamespaceArray : " + dataValue.statusCode.toString()));
|
|
2104
2104
|
}
|
|
2105
2105
|
assert(dataValue.value.value instanceof Array);
|
|
@@ -428,7 +428,7 @@ export class ClientSubscriptionImpl extends EventEmitter implements ClientSubscr
|
|
|
428
428
|
if (!statusCode) {
|
|
429
429
|
return callback(new Error("Internal Error"));
|
|
430
430
|
}
|
|
431
|
-
if (statusCode
|
|
431
|
+
if (statusCode.isNotGood()) {
|
|
432
432
|
return callback(null, statusCode);
|
|
433
433
|
}
|
|
434
434
|
callback(null, StatusCodes.Good);
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// tslint:disable:no-empty
|
|
7
7
|
|
|
8
8
|
import * as crypto from "crypto";
|
|
9
|
+
import { createPublicKey } from "crypto";
|
|
9
10
|
import { callbackify } from "util";
|
|
10
11
|
import * as async from "async";
|
|
11
12
|
import * as chalk from "chalk";
|
|
@@ -17,13 +18,14 @@ import {
|
|
|
17
18
|
exploreCertificate,
|
|
18
19
|
extractPublicKeyFromCertificateSync,
|
|
19
20
|
Nonce,
|
|
21
|
+
PrivateKey,
|
|
20
22
|
PrivateKeyPEM,
|
|
21
23
|
toPem
|
|
22
24
|
} from "node-opcua-crypto";
|
|
23
25
|
|
|
24
26
|
import { LocalizedText } from "node-opcua-data-model";
|
|
25
27
|
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
26
|
-
import { extractFullyQualifiedDomainName
|
|
28
|
+
import { extractFullyQualifiedDomainName } from "node-opcua-hostname";
|
|
27
29
|
import { ClientSecureChannelLayer, computeSignature, fromURI, getCryptoFactory, SecurityPolicy } from "node-opcua-secure-channel";
|
|
28
30
|
import { ApplicationDescriptionOptions, ApplicationType, EndpointDescription, UserTokenType } from "node-opcua-service-endpoints";
|
|
29
31
|
import { MessageSecurityMode, UserTokenPolicy } from "node-opcua-service-secure-channel";
|
|
@@ -31,8 +33,6 @@ import {
|
|
|
31
33
|
ActivateSessionRequest,
|
|
32
34
|
ActivateSessionResponse,
|
|
33
35
|
AnonymousIdentityToken,
|
|
34
|
-
CloseSessionRequest,
|
|
35
|
-
CloseSessionResponse,
|
|
36
36
|
CreateSessionRequest,
|
|
37
37
|
CreateSessionResponse,
|
|
38
38
|
UserNameIdentityToken,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
import { CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
42
42
|
import { ErrorCallback, Callback } from "node-opcua-status-code";
|
|
43
43
|
|
|
44
|
-
import {
|
|
44
|
+
import { SignatureDataOptions, UserIdentityToken } from "node-opcua-types";
|
|
45
45
|
import { isNullOrUndefined, matchUri } from "node-opcua-utils";
|
|
46
46
|
|
|
47
47
|
import { ClientSession } from "../client_session";
|
|
@@ -132,7 +132,7 @@ interface X509TokenAndSignature {
|
|
|
132
132
|
function createX509IdentityToken(
|
|
133
133
|
context: IdentityTokenContext,
|
|
134
134
|
certificate: Certificate,
|
|
135
|
-
privateKey:
|
|
135
|
+
privateKey: PrivateKey
|
|
136
136
|
): X509TokenAndSignature {
|
|
137
137
|
const endpoint = context.endpoint;
|
|
138
138
|
assert(endpoint instanceof EndpointDescription);
|
|
@@ -250,7 +250,7 @@ function createUserNameIdentityToken(
|
|
|
250
250
|
|
|
251
251
|
assert(serverCertificate instanceof Buffer);
|
|
252
252
|
serverCertificate = toPem(serverCertificate, "CERTIFICATE");
|
|
253
|
-
const publicKey = extractPublicKeyFromCertificateSync(serverCertificate);
|
|
253
|
+
const publicKey = createPublicKey(extractPublicKeyFromCertificateSync(serverCertificate));
|
|
254
254
|
|
|
255
255
|
const serverNonce: Nonce = session.serverNonce || Buffer.alloc(0);
|
|
256
256
|
assert(serverNonce instanceof Buffer);
|
|
@@ -1236,7 +1236,7 @@ export class OPCUAClientImpl extends ClientBaseImpl implements OPCUAClient {
|
|
|
1236
1236
|
|
|
1237
1237
|
case UserTokenType.Certificate: {
|
|
1238
1238
|
const certificate = userIdentityInfo.certificateData;
|
|
1239
|
-
const privateKey = userIdentityInfo.privateKey;
|
|
1239
|
+
const privateKey = crypto.createPrivateKey(userIdentityInfo.privateKey);
|
|
1240
1240
|
({ userIdentityToken, userTokenSignature } = createX509IdentityToken(context, certificate, privateKey));
|
|
1241
1241
|
break;
|
|
1242
1242
|
}
|
package/source/reconnection.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as 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";
|
|
11
|
-
import { CallbackT, StatusCodes } from "node-opcua-status-code";
|
|
11
|
+
import { CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
12
12
|
import { ErrorCallback } from "node-opcua-status-code";
|
|
13
13
|
import { CloseSessionRequest } from "node-opcua-types";
|
|
14
14
|
|
|
@@ -320,7 +320,7 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
320
320
|
// those one need to be recreated and repaired ....
|
|
321
321
|
for (let i = 0; i < results.length; i++) {
|
|
322
322
|
const statusCode = results[i].statusCode;
|
|
323
|
-
if (statusCode
|
|
323
|
+
if (statusCode.equals(StatusCodes.BadSubscriptionIdInvalid)) {
|
|
324
324
|
// repair subscription
|
|
325
325
|
debugLog(
|
|
326
326
|
chalk.red(" WARNING SUBSCRIPTION "),
|
|
@@ -41,7 +41,7 @@ export function readHistoryServerCapabilities(
|
|
|
41
41
|
if (!result) {
|
|
42
42
|
return callback(new Error("Internal Error"));
|
|
43
43
|
}
|
|
44
|
-
if (result.statusCode
|
|
44
|
+
if (result.statusCode.isNotGood()) {
|
|
45
45
|
return callback(new Error("StatusCode = " + result.statusCode.toString()));
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -89,7 +89,7 @@ export function readHistoryServerCapabilities(
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const nodeIds = results.map((innerResult: BrowsePathResult) =>
|
|
92
|
-
innerResult.statusCode
|
|
92
|
+
innerResult.statusCode.isGood() && innerResult.targets
|
|
93
93
|
? innerResult.targets[0].targetId
|
|
94
94
|
: new NodeId()
|
|
95
95
|
);
|
package/source/verify.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createPrivateKey } from "crypto";
|
|
1
2
|
import { OPCUACertificateManager } from "node-opcua-certificate-manager";
|
|
2
3
|
import { OPCUASecureObject } from "node-opcua-common";
|
|
3
4
|
|
|
@@ -126,7 +127,7 @@ export async function performCertificateSanityCheck(
|
|
|
126
127
|
): Promise<void> {
|
|
127
128
|
// verify that certificate is matching private key, and inform the developper if not
|
|
128
129
|
const certificate = this.getCertificate();
|
|
129
|
-
const privateKey =
|
|
130
|
+
const privateKey = this.getPrivateKey();
|
|
130
131
|
//
|
|
131
132
|
if (!publicKeyAndPrivateKeyMatches(certificate, privateKey)) {
|
|
132
133
|
errorLog("[NODE-OPCUA-E01] Configuration error : the certificate and the private key do not match !");
|