node-opcua-client 2.189.0 → 2.190.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.d.ts.map +1 -1
- package/dist/alarms_and_conditions/client_alarm_tools.js +2 -1
- package/dist/alarms_and_conditions/client_alarm_tools.js.map +1 -1
- package/dist/client_monitored_item_toolbox.d.ts.map +1 -1
- package/dist/client_monitored_item_toolbox.js +8 -4
- package/dist/client_monitored_item_toolbox.js.map +1 -1
- package/dist/client_session_keepalive_manager.d.ts.map +1 -1
- package/dist/client_session_keepalive_manager.js +18 -12
- package/dist/client_session_keepalive_manager.js.map +1 -1
- package/dist/private/client_base_impl.d.ts +10 -1
- package/dist/private/client_base_impl.d.ts.map +1 -1
- package/dist/private/client_base_impl.js +188 -77
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_monitored_item_impl.d.ts.map +1 -1
- package/dist/private/client_monitored_item_impl.js +2 -1
- package/dist/private/client_monitored_item_impl.js.map +1 -1
- package/dist/private/client_publish_engine.d.ts.map +1 -1
- package/dist/private/client_publish_engine.js +16 -8
- package/dist/private/client_publish_engine.js.map +1 -1
- package/dist/private/client_session_impl.d.ts +21 -0
- package/dist/private/client_session_impl.d.ts.map +1 -1
- package/dist/private/client_session_impl.js +122 -57
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/client_subscription_impl.d.ts.map +1 -1
- package/dist/private/client_subscription_impl.js +27 -17
- package/dist/private/client_subscription_impl.js.map +1 -1
- package/dist/private/opcua_client_impl.d.ts.map +1 -1
- package/dist/private/opcua_client_impl.js +307 -29
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/private/reconnection/client_publish_engine_reconnection.d.ts.map +1 -1
- package/dist/private/reconnection/client_publish_engine_reconnection.js +6 -3
- package/dist/private/reconnection/client_publish_engine_reconnection.js.map +1 -1
- package/dist/private/reconnection/client_subscription_reconnection.d.ts.map +1 -1
- package/dist/private/reconnection/client_subscription_reconnection.js +6 -3
- package/dist/private/reconnection/client_subscription_reconnection.js.map +1 -1
- package/dist/private/reconnection/reconnection.d.ts.map +1 -1
- package/dist/private/reconnection/reconnection.js +6 -4
- package/dist/private/reconnection/reconnection.js.map +1 -1
- package/dist/private/verify_server_signature.d.ts +51 -0
- package/dist/private/verify_server_signature.d.ts.map +1 -0
- package/dist/private/verify_server_signature.js +76 -0
- package/dist/private/verify_server_signature.js.map +1 -0
- package/dist/reverse/client_reverse_connect.js +2 -2
- package/dist/reverse/client_reverse_connect.js.map +1 -1
- package/dist/tools/read_history_server_capabilities.js +6 -3
- package/dist/tools/read_history_server_capabilities.js.map +1 -1
- package/dist/verify.d.ts +6 -0
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +32 -10
- package/dist/verify.js.map +1 -1
- package/package.json +45 -45
- package/source/alarms_and_conditions/client_alarm_tools.ts +2 -1
- package/source/client_monitored_item_toolbox.ts +8 -4
- package/source/client_session_keepalive_manager.ts +18 -12
- package/source/private/client_base_impl.ts +206 -78
- package/source/private/client_monitored_item_impl.ts +2 -1
- package/source/private/client_publish_engine.ts +16 -8
- package/source/private/client_session_impl.ts +122 -57
- package/source/private/client_subscription_impl.ts +27 -17
- package/source/private/opcua_client_impl.ts +383 -29
- package/source/private/reconnection/client_publish_engine_reconnection.ts +6 -3
- package/source/private/reconnection/client_subscription_reconnection.ts +6 -3
- package/source/private/reconnection/reconnection.ts +6 -4
- package/source/private/verify_server_signature.ts +109 -0
- package/source/reverse/client_reverse_connect.ts +2 -2
- package/source/tools/read_history_server_capabilities.ts +6 -3
- package/source/verify.ts +34 -12
|
@@ -235,6 +235,24 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
235
235
|
public userIdentityInfo?: UserIdentityInfo;
|
|
236
236
|
public name = "";
|
|
237
237
|
public serverNonce?: Nonce;
|
|
238
|
+
/**
|
|
239
|
+
* The nonce that the client sent in the CreateSession of this session. The signatures that are
|
|
240
|
+
* bound to the SecureChannel use it again in each ActivateSession.
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
public _clientNonce?: Buffer;
|
|
244
|
+
/**
|
|
245
|
+
* The certificate that the client sent in the CreateSession of this session. The user
|
|
246
|
+
* certificate signature that is bound to the SecureChannel hashes it.
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
public _clientCertificate?: Buffer;
|
|
250
|
+
/**
|
|
251
|
+
* The ephemeral key that the server gave for the secret of the next user identity token of
|
|
252
|
+
* this session, with a SecurityPolicy for a key on an elliptic curve (OPC 10000-6, 6.8.2).
|
|
253
|
+
* @internal
|
|
254
|
+
*/
|
|
255
|
+
public _serverEphemeralKey?: { securityPolicy: string; publicKey: Buffer } | null;
|
|
238
256
|
public serverSignature?: SignatureData; // todo : remove ?
|
|
239
257
|
public serverEndpoints: EndpointDescription[] = [];
|
|
240
258
|
public lastActivateSessionStatusCode: StatusCode = StatusCodes.Good;
|
|
@@ -454,10 +472,11 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
454
472
|
return callback(err);
|
|
455
473
|
}
|
|
456
474
|
|
|
457
|
-
/* c8 ignore
|
|
475
|
+
/* c8 ignore start */
|
|
458
476
|
if (!response || !(response instanceof BrowseResponse)) {
|
|
459
477
|
return callback(new Error("Internal Error"));
|
|
460
478
|
}
|
|
479
|
+
/* c8 ignore stop */
|
|
461
480
|
|
|
462
481
|
const results: BrowseResult[] = response.results ? response.results : [];
|
|
463
482
|
|
|
@@ -465,7 +484,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
465
484
|
for (let i = 0; i < results.length; i++) {
|
|
466
485
|
const r = results[i];
|
|
467
486
|
|
|
468
|
-
/* c8 ignore
|
|
487
|
+
/* c8 ignore start */
|
|
469
488
|
if (r.references && r.references.length > this.requestedMaxReferencesPerNode) {
|
|
470
489
|
warningLog(
|
|
471
490
|
chalk.yellow("warning") +
|
|
@@ -476,6 +495,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
476
495
|
warningLog(` got ${r.references.length}for ${nodesToBrowse[i].nodeId.toString()}`);
|
|
477
496
|
warningLog(" continuationPoint ", r.continuationPoint);
|
|
478
497
|
}
|
|
498
|
+
/* c8 ignore stop */
|
|
479
499
|
}
|
|
480
500
|
}
|
|
481
501
|
for (const r of results) {
|
|
@@ -515,15 +535,17 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
515
535
|
});
|
|
516
536
|
|
|
517
537
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
518
|
-
/* c8 ignore
|
|
538
|
+
/* c8 ignore start */
|
|
519
539
|
if (err) {
|
|
520
540
|
return callback(err);
|
|
521
541
|
}
|
|
542
|
+
/* c8 ignore stop */
|
|
522
543
|
|
|
523
|
-
/* c8 ignore
|
|
544
|
+
/* c8 ignore start */
|
|
524
545
|
if (!response || !(response instanceof BrowseNextResponse)) {
|
|
525
546
|
return callback(new Error("Internal Error"));
|
|
526
547
|
}
|
|
548
|
+
/* c8 ignore stop */
|
|
527
549
|
const results: BrowseResult[] = response.results ? response.results : [];
|
|
528
550
|
|
|
529
551
|
for (const r of results) {
|
|
@@ -590,25 +612,29 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
590
612
|
});
|
|
591
613
|
|
|
592
614
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
593
|
-
/* c8 ignore
|
|
615
|
+
/* c8 ignore start */
|
|
594
616
|
if (err) {
|
|
595
617
|
return callback(err);
|
|
596
618
|
}
|
|
619
|
+
/* c8 ignore stop */
|
|
597
620
|
|
|
598
|
-
/* c8 ignore
|
|
621
|
+
/* c8 ignore start */
|
|
599
622
|
if (!(response instanceof ReadResponse)) {
|
|
600
623
|
return callback(new Error("Internal Error"));
|
|
601
624
|
}
|
|
625
|
+
/* c8 ignore stop */
|
|
602
626
|
|
|
603
|
-
/* c8 ignore
|
|
627
|
+
/* c8 ignore start */
|
|
604
628
|
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
605
629
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
606
630
|
}
|
|
631
|
+
/* c8 ignore stop */
|
|
607
632
|
|
|
608
|
-
/* c8 ignore
|
|
633
|
+
/* c8 ignore start */
|
|
609
634
|
if (!response.results) {
|
|
610
635
|
response.results = [];
|
|
611
636
|
}
|
|
637
|
+
/* c8 ignore stop */
|
|
612
638
|
|
|
613
639
|
assert(nodes.length === response.results.length);
|
|
614
640
|
|
|
@@ -738,14 +764,16 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
738
764
|
|
|
739
765
|
assert(nodes.length === request.nodesToRead.length);
|
|
740
766
|
return this.historyRead(request, (err: Error | null, response?: HistoryReadResponse) => {
|
|
741
|
-
/* c8 ignore
|
|
767
|
+
/* c8 ignore start */
|
|
742
768
|
if (err) {
|
|
743
769
|
return cb(err);
|
|
744
770
|
}
|
|
745
|
-
/* c8 ignore
|
|
771
|
+
/* c8 ignore stop */
|
|
772
|
+
/* c8 ignore start */
|
|
746
773
|
if (!response || !(response instanceof HistoryReadResponse)) {
|
|
747
774
|
return cb(new Error("Internal Error"));
|
|
748
775
|
}
|
|
776
|
+
/* c8 ignore stop */
|
|
749
777
|
response.results = response.results || [];
|
|
750
778
|
assert(nodes.length === response.results.length);
|
|
751
779
|
cb(null, isArray ? response.results : response.results[0]);
|
|
@@ -755,21 +783,24 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
755
783
|
public historyRead(request: HistoryReadRequest, callback: Callback<HistoryReadResponse>): void;
|
|
756
784
|
public historyRead(request: HistoryReadRequest): Promise<HistoryReadResponse>;
|
|
757
785
|
public historyRead(request: HistoryReadRequest, callback?: CallbackT<HistoryReadResponse>): unknown {
|
|
758
|
-
/* c8 ignore
|
|
786
|
+
/* c8 ignore start */
|
|
759
787
|
if (!callback) {
|
|
760
788
|
throw new Error("expecting a callback");
|
|
761
789
|
}
|
|
790
|
+
/* c8 ignore stop */
|
|
762
791
|
|
|
763
792
|
return this.performMessageTransaction(request, (err: Error | null, response) => {
|
|
764
|
-
/* c8 ignore
|
|
793
|
+
/* c8 ignore start */
|
|
765
794
|
if (err) {
|
|
766
795
|
return callback(err);
|
|
767
796
|
}
|
|
797
|
+
/* c8 ignore stop */
|
|
768
798
|
|
|
769
|
-
/* c8 ignore
|
|
799
|
+
/* c8 ignore start */
|
|
770
800
|
if (!response || !(response instanceof HistoryReadResponse)) {
|
|
771
801
|
return callback(new Error("Internal Error"));
|
|
772
802
|
}
|
|
803
|
+
/* c8 ignore stop */
|
|
773
804
|
|
|
774
805
|
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
775
806
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
@@ -908,15 +939,17 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
908
939
|
|
|
909
940
|
assert(nodesToRead.length === request.nodesToRead?.length);
|
|
910
941
|
return this.performMessageTransaction(request, (err: Error | null, response) => {
|
|
911
|
-
/* c8 ignore
|
|
942
|
+
/* c8 ignore start */
|
|
912
943
|
if (err) {
|
|
913
944
|
return callback(err);
|
|
914
945
|
}
|
|
946
|
+
/* c8 ignore stop */
|
|
915
947
|
|
|
916
|
-
/* c8 ignore
|
|
948
|
+
/* c8 ignore start */
|
|
917
949
|
if (!response || !(response instanceof HistoryReadResponse)) {
|
|
918
950
|
return callback(new Error("Internal Error"));
|
|
919
951
|
}
|
|
952
|
+
/* c8 ignore stop */
|
|
920
953
|
|
|
921
954
|
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
922
955
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
@@ -1047,20 +1080,23 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1047
1080
|
const request = new WriteRequest({ nodesToWrite });
|
|
1048
1081
|
|
|
1049
1082
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
1050
|
-
/* c8 ignore
|
|
1083
|
+
/* c8 ignore start */
|
|
1051
1084
|
if (err) {
|
|
1052
1085
|
return callback(err, response);
|
|
1053
1086
|
}
|
|
1087
|
+
/* c8 ignore stop */
|
|
1054
1088
|
|
|
1055
|
-
/* c8 ignore
|
|
1089
|
+
/* c8 ignore start */
|
|
1056
1090
|
if (!response || !(response instanceof WriteResponse)) {
|
|
1057
1091
|
return callback(new Error("Internal Error"));
|
|
1058
1092
|
}
|
|
1093
|
+
/* c8 ignore stop */
|
|
1059
1094
|
|
|
1060
|
-
/* c8 ignore
|
|
1095
|
+
/* c8 ignore start */
|
|
1061
1096
|
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
1062
1097
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
1063
1098
|
}
|
|
1099
|
+
/* c8 ignore stop */
|
|
1064
1100
|
response.results = response.results || /* c8 ignore next */ [];
|
|
1065
1101
|
assert(nodesToWrite.length === response.results.length);
|
|
1066
1102
|
callback(null, isArray ? response.results : response.results[0]);
|
|
@@ -1118,10 +1154,11 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1118
1154
|
});
|
|
1119
1155
|
|
|
1120
1156
|
return this.write(nodeToWrite, (err, statusCode) => {
|
|
1121
|
-
/* c8 ignore
|
|
1157
|
+
/* c8 ignore start */
|
|
1122
1158
|
if (err) {
|
|
1123
1159
|
return callback(err);
|
|
1124
1160
|
}
|
|
1161
|
+
/* c8 ignore stop */
|
|
1125
1162
|
assert(statusCode);
|
|
1126
1163
|
callback(null, statusCode);
|
|
1127
1164
|
});
|
|
@@ -1241,7 +1278,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1241
1278
|
const callback = args[2] as (err: Error | null, results?: DataValue[] | DataValue | Response) => void;
|
|
1242
1279
|
assert(typeof callback === "function");
|
|
1243
1280
|
|
|
1244
|
-
/* c8 ignore
|
|
1281
|
+
/* c8 ignore start */
|
|
1245
1282
|
if (helpAPIChange) {
|
|
1246
1283
|
// the read method deprecation detection and warning
|
|
1247
1284
|
if (
|
|
@@ -1267,6 +1304,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1267
1304
|
throw new Error("ERROR ClientSession#read API has changed !!, please fix the client code");
|
|
1268
1305
|
}
|
|
1269
1306
|
}
|
|
1307
|
+
/* c8 ignore stop */
|
|
1270
1308
|
|
|
1271
1309
|
// coerce nodeIds
|
|
1272
1310
|
for (const node of nodesToRead) {
|
|
@@ -1282,15 +1320,17 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1282
1320
|
});
|
|
1283
1321
|
|
|
1284
1322
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
1285
|
-
/* c8 ignore
|
|
1323
|
+
/* c8 ignore start */
|
|
1286
1324
|
if (err) {
|
|
1287
1325
|
return callback(err, response);
|
|
1288
1326
|
}
|
|
1327
|
+
/* c8 ignore stop */
|
|
1289
1328
|
|
|
1290
|
-
/* c8 ignore
|
|
1329
|
+
/* c8 ignore start */
|
|
1291
1330
|
if (!response || !(response instanceof ReadResponse)) {
|
|
1292
1331
|
return callback(new Error("Internal Error"));
|
|
1293
1332
|
}
|
|
1333
|
+
/* c8 ignore stop */
|
|
1294
1334
|
|
|
1295
1335
|
// perform ExtensionObject resolution
|
|
1296
1336
|
promoteOpaqueStructure(this, response.results || [])
|
|
@@ -1306,7 +1346,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1306
1346
|
|
|
1307
1347
|
public emitCloseEvent(statusCode: StatusCode): void {
|
|
1308
1348
|
if (!this._closeEventHasBeenEmitted) {
|
|
1309
|
-
|
|
1349
|
+
/* c8 ignore next */
|
|
1310
1350
|
doDebug && debugLog("ClientSession#emitCloseEvent");
|
|
1311
1351
|
this._closeEventHasBeenEmitted = true;
|
|
1312
1352
|
this.emit("session_closed", statusCode);
|
|
@@ -1476,14 +1516,16 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1476
1516
|
SetPublishingModeResponse,
|
|
1477
1517
|
options,
|
|
1478
1518
|
(err: Error | null, response?: SetPublishingModeResponse) => {
|
|
1479
|
-
/* c8 ignore
|
|
1519
|
+
/* c8 ignore start */
|
|
1480
1520
|
if (err) {
|
|
1481
1521
|
return callback(err);
|
|
1482
1522
|
}
|
|
1483
|
-
/* c8 ignore
|
|
1523
|
+
/* c8 ignore stop */
|
|
1524
|
+
/* c8 ignore start */
|
|
1484
1525
|
if (!response) {
|
|
1485
1526
|
return callback(new Error("Internal Error"));
|
|
1486
1527
|
}
|
|
1528
|
+
/* c8 ignore stop */
|
|
1487
1529
|
response.results = response.results || /* c8 ignore next */ [];
|
|
1488
1530
|
callback(err, isArray ? response.results : response.results[0]);
|
|
1489
1531
|
}
|
|
@@ -1512,14 +1554,16 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1512
1554
|
const request = new TranslateBrowsePathsToNodeIdsRequest({ browsePaths });
|
|
1513
1555
|
|
|
1514
1556
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
1515
|
-
/* c8 ignore
|
|
1557
|
+
/* c8 ignore start */
|
|
1516
1558
|
if (err) {
|
|
1517
1559
|
return callback(err, response);
|
|
1518
1560
|
}
|
|
1519
|
-
/* c8 ignore
|
|
1561
|
+
/* c8 ignore stop */
|
|
1562
|
+
/* c8 ignore start */
|
|
1520
1563
|
if (!response || !(response instanceof TranslateBrowsePathsToNodeIdsResponse)) {
|
|
1521
1564
|
return callback(new Error("Internal Error"));
|
|
1522
1565
|
}
|
|
1566
|
+
/* c8 ignore stop */
|
|
1523
1567
|
response.results = response.results || /* c8 ignore next */ [];
|
|
1524
1568
|
|
|
1525
1569
|
callback(null, isArray ? response.results : response.results[0]);
|
|
@@ -1531,11 +1575,12 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1531
1575
|
return secureChannel?.isOpened() ? secureChannel.channelId : -1;
|
|
1532
1576
|
}
|
|
1533
1577
|
public isChannelValid(): boolean {
|
|
1534
|
-
/* c8 ignore
|
|
1578
|
+
/* c8 ignore start */
|
|
1535
1579
|
if (!this._client) {
|
|
1536
|
-
|
|
1580
|
+
/* c8 ignore next */
|
|
1537
1581
|
doDebug && debugLog(chalk.red("Warning SessionClient is null ?"));
|
|
1538
1582
|
}
|
|
1583
|
+
/* c8 ignore stop */
|
|
1539
1584
|
|
|
1540
1585
|
return !!this._client?._secureChannel?.isOpened();
|
|
1541
1586
|
}
|
|
@@ -1562,7 +1607,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1562
1607
|
// valid channel and passes straight through. Queueing on "reconnecting" alone would
|
|
1563
1608
|
// park the repair's requests behind the repair that is waiting for them.
|
|
1564
1609
|
if (!this.isChannelValid() && (this._reconnecting.reconnecting || this._client.isReconnecting)) {
|
|
1565
|
-
/* c8 ignore
|
|
1610
|
+
/* c8 ignore start */
|
|
1566
1611
|
if (this._reconnecting.pendingTransactions.length > 10) {
|
|
1567
1612
|
if (!pendingTransactionMessageDisplayed) {
|
|
1568
1613
|
pendingTransactionMessageDisplayed = true;
|
|
@@ -1582,7 +1627,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1582
1627
|
);
|
|
1583
1628
|
}
|
|
1584
1629
|
} else if (this._reconnecting.pendingTransactions.length > 3) {
|
|
1585
|
-
|
|
1630
|
+
/* c8 ignore next */
|
|
1586
1631
|
doDebug &&
|
|
1587
1632
|
debugLog(
|
|
1588
1633
|
chalk.yellow(
|
|
@@ -1591,6 +1636,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1591
1636
|
)
|
|
1592
1637
|
);
|
|
1593
1638
|
}
|
|
1639
|
+
/* c8 ignore stop */
|
|
1594
1640
|
this._reconnecting.pendingTransactions.push({ request, callback });
|
|
1595
1641
|
return;
|
|
1596
1642
|
}
|
|
@@ -1618,7 +1664,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1618
1664
|
// listener - left the caller waiting for an answer that could never come.
|
|
1619
1665
|
// flushPendingTransactions is called on every exit from a repair, so the
|
|
1620
1666
|
// transaction is always resolved one way or the other.
|
|
1621
|
-
|
|
1667
|
+
/* c8 ignore next */
|
|
1622
1668
|
doDebug && debugLog("holding for replay after repair:", request.constructor.name, "attempt", attemptCount);
|
|
1623
1669
|
this._reconnecting.pendingTransactions.push({ request, callback });
|
|
1624
1670
|
} else {
|
|
@@ -1658,7 +1704,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1658
1704
|
if (heldTransactions.length === 0) {
|
|
1659
1705
|
return;
|
|
1660
1706
|
}
|
|
1661
|
-
|
|
1707
|
+
/* c8 ignore next */
|
|
1662
1708
|
doDebug && debugLog("flushPendingTransactions", heldTransactions.length, err ? `failing: ${err.message}` : "replaying");
|
|
1663
1709
|
pendingTransactionMessageDisplayed = false;
|
|
1664
1710
|
for (const pending of heldTransactions) {
|
|
@@ -1679,18 +1725,19 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1679
1725
|
public _performMessageTransaction(request: Request, callback: (err: Error | null, response?: Response) => void): void {
|
|
1680
1726
|
assert(typeof callback === "function");
|
|
1681
1727
|
|
|
1682
|
-
/* c8 ignore
|
|
1728
|
+
/* c8 ignore start */
|
|
1683
1729
|
if (!this._client) {
|
|
1684
1730
|
// session may have been closed by user ... but is still in used !!
|
|
1685
1731
|
callback(new Error("Session has been closed and should not be used to perform a transaction anymore"));
|
|
1686
1732
|
return;
|
|
1687
1733
|
}
|
|
1734
|
+
/* c8 ignore stop */
|
|
1688
1735
|
|
|
1689
1736
|
if (!this.isChannelValid()) {
|
|
1690
1737
|
// the secure channel is broken, may be the server has crashed or the network cable has been disconnected
|
|
1691
1738
|
// for a long time
|
|
1692
1739
|
// we may need to queue this transaction, as a secure token may be being reprocessed
|
|
1693
|
-
|
|
1740
|
+
/* c8 ignore next */
|
|
1694
1741
|
doDebug && debugLog(chalk.bgWhite.red("!!! Performing transaction on invalid channel !!! ", request.constructor.name));
|
|
1695
1742
|
callback(new Error("Invalid Channel BadConnectionClosed"));
|
|
1696
1743
|
return;
|
|
@@ -1713,10 +1760,11 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1713
1760
|
return callback(annotateWithDiagnostics(err, response));
|
|
1714
1761
|
}
|
|
1715
1762
|
|
|
1716
|
-
/* c8 ignore
|
|
1763
|
+
/* c8 ignore start */
|
|
1717
1764
|
if (!response) {
|
|
1718
1765
|
return callback(new Error("internal Error"));
|
|
1719
1766
|
}
|
|
1767
|
+
/* c8 ignore stop */
|
|
1720
1768
|
|
|
1721
1769
|
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
1722
1770
|
const serviceResultError = new Error(
|
|
@@ -1797,17 +1845,18 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1797
1845
|
assert(typeof callback === "function");
|
|
1798
1846
|
assert(typeof deleteSubscription === "boolean");
|
|
1799
1847
|
|
|
1800
|
-
/* c8 ignore
|
|
1848
|
+
/* c8 ignore start */
|
|
1801
1849
|
if (!this._client) {
|
|
1802
|
-
|
|
1850
|
+
/* c8 ignore next */
|
|
1803
1851
|
doDebug && debugLog("ClientSession#close : warning, client is already closed");
|
|
1804
1852
|
return callback(); // already close ?
|
|
1805
1853
|
}
|
|
1854
|
+
/* c8 ignore stop */
|
|
1806
1855
|
assert(this._client);
|
|
1807
1856
|
|
|
1808
1857
|
this._terminatePublishEngine();
|
|
1809
1858
|
this._client.closeSession(this, deleteSubscription as boolean, (err?: Error) => {
|
|
1810
|
-
|
|
1859
|
+
/* c8 ignore next */
|
|
1811
1860
|
doDebug && debugLog("session Close err ", err ? err.message : "null");
|
|
1812
1861
|
callback();
|
|
1813
1862
|
});
|
|
@@ -1848,15 +1897,17 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1848
1897
|
const request = new CallRequest({ methodsToCall });
|
|
1849
1898
|
|
|
1850
1899
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
1851
|
-
/* c8 ignore
|
|
1900
|
+
/* c8 ignore start */
|
|
1852
1901
|
if (err) {
|
|
1853
1902
|
return callback(err);
|
|
1854
1903
|
}
|
|
1904
|
+
/* c8 ignore stop */
|
|
1855
1905
|
|
|
1856
|
-
/* c8 ignore
|
|
1906
|
+
/* c8 ignore start */
|
|
1857
1907
|
if (!response || !(response instanceof CallResponse)) {
|
|
1858
1908
|
return callback(new Error("internal error"));
|
|
1859
1909
|
}
|
|
1910
|
+
/* c8 ignore stop */
|
|
1860
1911
|
const results: CallMethodResult[] = response.results || [];
|
|
1861
1912
|
response.results = results;
|
|
1862
1913
|
|
|
@@ -1880,10 +1931,11 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1880
1931
|
err ? reject(err) : resolve(response)
|
|
1881
1932
|
)
|
|
1882
1933
|
);
|
|
1883
|
-
/* c8 ignore
|
|
1934
|
+
/* c8 ignore start */
|
|
1884
1935
|
if (!response || !(response instanceof CallResponse)) {
|
|
1885
1936
|
throw new Error("internal error");
|
|
1886
1937
|
}
|
|
1938
|
+
/* c8 ignore stop */
|
|
1887
1939
|
const results: CallMethodResult[] = response.results || [];
|
|
1888
1940
|
await promoteOpaqueStructureForCall(this, results);
|
|
1889
1941
|
const diagnosticInfos = (response.diagnosticInfos || []).map((d) => d ?? new DiagnosticInfo());
|
|
@@ -1927,19 +1979,22 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1927
1979
|
});
|
|
1928
1980
|
|
|
1929
1981
|
return this.call(methodsToCall, (err?: Error | null, result?: CallMethodResult) => {
|
|
1930
|
-
/* c8 ignore
|
|
1982
|
+
/* c8 ignore start */
|
|
1931
1983
|
if (err) {
|
|
1932
1984
|
return callback(err);
|
|
1933
1985
|
}
|
|
1986
|
+
/* c8 ignore stop */
|
|
1934
1987
|
|
|
1935
|
-
/* c8 ignore
|
|
1988
|
+
/* c8 ignore start */
|
|
1936
1989
|
if (!result) {
|
|
1937
1990
|
return callback(new Error("internal error"));
|
|
1938
1991
|
}
|
|
1992
|
+
/* c8 ignore stop */
|
|
1939
1993
|
|
|
1940
|
-
/* c8 ignore
|
|
1994
|
+
/* c8 ignore start */
|
|
1941
1995
|
if (result.statusCode.isNot(StatusCodes.Good)) {
|
|
1942
1996
|
callback(new Error(result.statusCode.toString()));
|
|
1997
|
+
/* c8 ignore stop */
|
|
1943
1998
|
} else {
|
|
1944
1999
|
result.outputArguments = result.outputArguments || [];
|
|
1945
2000
|
|
|
@@ -1996,14 +2051,16 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1996
2051
|
});
|
|
1997
2052
|
|
|
1998
2053
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
1999
|
-
/* c8 ignore
|
|
2054
|
+
/* c8 ignore start */
|
|
2000
2055
|
if (err) {
|
|
2001
2056
|
return callback(err);
|
|
2002
2057
|
}
|
|
2003
|
-
/* c8 ignore
|
|
2058
|
+
/* c8 ignore stop */
|
|
2059
|
+
/* c8 ignore start */
|
|
2004
2060
|
if (!response || !(response instanceof RegisterNodesResponse)) {
|
|
2005
2061
|
return callback(new Error("Internal Error"));
|
|
2006
2062
|
}
|
|
2063
|
+
/* c8 ignore stop */
|
|
2007
2064
|
|
|
2008
2065
|
response.registeredNodeIds = response.registeredNodeIds || /* c8 ignore next */ [];
|
|
2009
2066
|
|
|
@@ -2025,14 +2082,16 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
2025
2082
|
});
|
|
2026
2083
|
|
|
2027
2084
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
2028
|
-
/* c8 ignore
|
|
2085
|
+
/* c8 ignore start */
|
|
2029
2086
|
if (err) {
|
|
2030
2087
|
return callback(err);
|
|
2031
2088
|
}
|
|
2032
|
-
/* c8 ignore
|
|
2089
|
+
/* c8 ignore stop */
|
|
2090
|
+
/* c8 ignore start */
|
|
2033
2091
|
if (!response || !(response instanceof UnregisterNodesResponse)) {
|
|
2034
2092
|
return callback(new Error("Internal Error"));
|
|
2035
2093
|
}
|
|
2094
|
+
/* c8 ignore stop */
|
|
2036
2095
|
callback();
|
|
2037
2096
|
});
|
|
2038
2097
|
}
|
|
@@ -2048,14 +2107,16 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
2048
2107
|
const request = new QueryFirstRequest(queryFirstRequest);
|
|
2049
2108
|
|
|
2050
2109
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
2051
|
-
/* c8 ignore
|
|
2110
|
+
/* c8 ignore start */
|
|
2052
2111
|
if (err) {
|
|
2053
2112
|
return callback(err);
|
|
2054
2113
|
}
|
|
2055
|
-
/* c8 ignore
|
|
2114
|
+
/* c8 ignore stop */
|
|
2115
|
+
/* c8 ignore start */
|
|
2056
2116
|
if (!response || !(response instanceof QueryFirstResponse)) {
|
|
2057
2117
|
return callback(new Error("internal error"));
|
|
2058
2118
|
}
|
|
2119
|
+
/* c8 ignore stop */
|
|
2059
2120
|
callback(null, response);
|
|
2060
2121
|
});
|
|
2061
2122
|
}
|
|
@@ -2281,34 +2342,37 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
2281
2342
|
|
|
2282
2343
|
const request: Request = options instanceof requestClass ? options : new requestClass(options);
|
|
2283
2344
|
|
|
2284
|
-
/* c8 ignore
|
|
2345
|
+
/* c8 ignore start */
|
|
2285
2346
|
if (doDebug) {
|
|
2286
2347
|
(request as unknown as { trace?: string }).trace = new Error("").stack;
|
|
2287
2348
|
}
|
|
2349
|
+
/* c8 ignore stop */
|
|
2288
2350
|
|
|
2289
|
-
/* c8 ignore
|
|
2351
|
+
/* c8 ignore start */
|
|
2290
2352
|
if (this._closeEventHasBeenEmitted) {
|
|
2291
|
-
|
|
2353
|
+
/* c8 ignore next */
|
|
2292
2354
|
doDebug && debugLog("ClientSession#_defaultRequest => session has been closed !!", request.toString());
|
|
2293
2355
|
setImmediate(() => {
|
|
2294
2356
|
callback(new Error("ClientSession is closed !"));
|
|
2295
2357
|
});
|
|
2296
2358
|
return undefined;
|
|
2297
2359
|
}
|
|
2360
|
+
/* c8 ignore stop */
|
|
2298
2361
|
|
|
2299
2362
|
return this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
|
|
2300
2363
|
if (this._closeEventHasBeenEmitted) {
|
|
2301
|
-
|
|
2364
|
+
/* c8 ignore start */
|
|
2302
2365
|
doDebug &&
|
|
2303
2366
|
debugLog(
|
|
2304
2367
|
"ClientSession#_defaultRequest ... err =",
|
|
2305
2368
|
err ? err.message : "null",
|
|
2306
2369
|
response ? response.toString() : " null"
|
|
2307
2370
|
);
|
|
2371
|
+
/* c8 ignore stop */
|
|
2308
2372
|
}
|
|
2309
|
-
/* c8 ignore
|
|
2373
|
+
/* c8 ignore start */
|
|
2310
2374
|
if (err) {
|
|
2311
|
-
|
|
2375
|
+
/* c8 ignore next */
|
|
2312
2376
|
doDebug && debugLog("Client session : performMessageTransaction error = ", err.message);
|
|
2313
2377
|
// let intercept interesting error message
|
|
2314
2378
|
if (err.message.match(/BadSessionClosed/)) {
|
|
@@ -2349,6 +2413,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
2349
2413
|
}
|
|
2350
2414
|
return callback(err, response as TResponse | undefined);
|
|
2351
2415
|
}
|
|
2416
|
+
/* c8 ignore stop */
|
|
2352
2417
|
callback(null, response as TResponse | undefined);
|
|
2353
2418
|
});
|
|
2354
2419
|
}
|