node-opcua-client 2.98.0 → 2.98.1

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 (106) hide show
  1. package/dist/alarms_and_conditions/client_alarm.d.ts +49 -0
  2. package/dist/alarms_and_conditions/client_alarm.js +110 -0
  3. package/dist/alarms_and_conditions/client_alarm.js.map +1 -0
  4. package/dist/alarms_and_conditions/client_alarm_list.d.ts +25 -0
  5. package/dist/alarms_and_conditions/client_alarm_list.js +98 -0
  6. package/dist/alarms_and_conditions/client_alarm_list.js.map +1 -0
  7. package/dist/alarms_and_conditions/client_alarm_tools.d.ts +4 -0
  8. package/dist/alarms_and_conditions/client_alarm_tools.js +157 -0
  9. package/dist/alarms_and_conditions/client_alarm_tools.js.map +1 -0
  10. package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.d.ts +18 -0
  11. package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js +193 -0
  12. package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js.map +1 -0
  13. package/dist/alarms_and_conditions/client_alarm_tools_dump_event.d.ts +9 -0
  14. package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js +73 -0
  15. package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js.map +1 -0
  16. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.d.ts +3 -0
  17. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.js +119 -0
  18. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.js.map +1 -0
  19. package/dist/alarms_and_conditions/client_tools.d.ts +7 -0
  20. package/dist/alarms_and_conditions/client_tools.js +180 -0
  21. package/dist/alarms_and_conditions/client_tools.js.map +1 -0
  22. package/dist/client_base.d.ts +277 -0
  23. package/dist/client_base.js +15 -0
  24. package/dist/client_base.js.map +1 -0
  25. package/dist/client_monitored_item.d.ts +21 -0
  26. package/dist/client_monitored_item.js +12 -0
  27. package/dist/client_monitored_item.js.map +1 -0
  28. package/dist/client_monitored_item_base.d.ts +39 -0
  29. package/dist/client_monitored_item_base.js +3 -0
  30. package/dist/client_monitored_item_base.js.map +1 -0
  31. package/dist/client_monitored_item_group.d.ts +21 -0
  32. package/dist/client_monitored_item_group.js +14 -0
  33. package/dist/client_monitored_item_group.js.map +1 -0
  34. package/dist/client_monitored_item_toolbox.d.ts +15 -0
  35. package/dist/client_monitored_item_toolbox.js +117 -0
  36. package/dist/client_monitored_item_toolbox.js.map +1 -0
  37. package/dist/client_session.d.ts +529 -0
  38. package/dist/client_session.js +11 -0
  39. package/dist/client_session.js.map +1 -0
  40. package/dist/client_session_keepalive_manager.d.ts +34 -0
  41. package/dist/client_session_keepalive_manager.js +150 -0
  42. package/dist/client_session_keepalive_manager.js.map +1 -0
  43. package/dist/client_subscription.d.ts +241 -0
  44. package/dist/client_subscription.js +15 -0
  45. package/dist/client_subscription.js.map +1 -0
  46. package/dist/client_utils.d.ts +22 -0
  47. package/dist/client_utils.js +88 -0
  48. package/dist/client_utils.js.map +1 -0
  49. package/dist/common.d.ts +17 -0
  50. package/dist/common.js +6 -0
  51. package/dist/common.js.map +1 -0
  52. package/dist/index.d.ts +56 -0
  53. package/dist/index.js +95 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/opcua_client.d.ts +118 -0
  56. package/dist/opcua_client.js +34 -0
  57. package/dist/opcua_client.js.map +1 -0
  58. package/dist/private/client_base_impl.d.ts +160 -0
  59. package/dist/private/client_base_impl.js +1349 -0
  60. package/dist/private/client_base_impl.js.map +1 -0
  61. package/dist/private/client_monitored_item_base_impl.d.ts +3 -0
  62. package/dist/private/client_monitored_item_base_impl.js +5 -0
  63. package/dist/private/client_monitored_item_base_impl.js.map +1 -0
  64. package/dist/private/client_monitored_item_group_impl.d.ts +53 -0
  65. package/dist/private/client_monitored_item_group_impl.js +162 -0
  66. package/dist/private/client_monitored_item_group_impl.js.map +1 -0
  67. package/dist/private/client_monitored_item_impl.d.ts +93 -0
  68. package/dist/private/client_monitored_item_impl.js +305 -0
  69. package/dist/private/client_monitored_item_impl.js.map +1 -0
  70. package/dist/private/client_publish_engine.d.ts +62 -0
  71. package/dist/private/client_publish_engine.js +409 -0
  72. package/dist/private/client_publish_engine.js.map +1 -0
  73. package/dist/private/client_session_impl.d.ts +631 -0
  74. package/dist/private/client_session_impl.js +1349 -0
  75. package/dist/private/client_session_impl.js.map +1 -0
  76. package/dist/private/client_subscription_impl.d.ts +93 -0
  77. package/dist/private/client_subscription_impl.js +780 -0
  78. package/dist/private/client_subscription_impl.js.map +1 -0
  79. package/dist/private/i_private_client.d.ts +21 -0
  80. package/dist/private/i_private_client.js +3 -0
  81. package/dist/private/i_private_client.js.map +1 -0
  82. package/dist/private/opcua_client_impl.d.ts +166 -0
  83. package/dist/private/opcua_client_impl.js +1001 -0
  84. package/dist/private/opcua_client_impl.js.map +1 -0
  85. package/dist/private/performance.d.ts +1 -0
  86. package/dist/private/performance.js +19 -0
  87. package/dist/private/performance.js.map +1 -0
  88. package/dist/reconnection.d.ts +9 -0
  89. package/dist/reconnection.js +382 -0
  90. package/dist/reconnection.js.map +1 -0
  91. package/dist/tools/findservers.d.ts +20 -0
  92. package/dist/tools/findservers.js +62 -0
  93. package/dist/tools/findservers.js.map +1 -0
  94. package/dist/tools/read_history_server_capabilities.d.ts +6 -0
  95. package/dist/tools/read_history_server_capabilities.js +99 -0
  96. package/dist/tools/read_history_server_capabilities.js.map +1 -0
  97. package/dist/user_identity_info.d.ts +1 -0
  98. package/dist/user_identity_info.js +3 -0
  99. package/dist/user_identity_info.js.map +1 -0
  100. package/dist/verify.d.ts +5 -0
  101. package/dist/verify.js +135 -0
  102. package/dist/verify.js.map +1 -0
  103. package/package.json +48 -44
  104. package/.nycrc.json +0 -14
  105. package/test_helpers/create_certificates.js +0 -1
  106. package/typedoc.js +0 -20
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readHistoryServerCapabilities = void 0;
4
+ /**
5
+ * @module node-opcua-client
6
+ */
7
+ const node_opcua_assert_1 = require("node-opcua-assert");
8
+ const node_opcua_constants_1 = require("node-opcua-constants");
9
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
10
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
11
+ const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
12
+ const node_opcua_utils_1 = require("node-opcua-utils");
13
+ function readHistoryServerCapabilities(session, callback) {
14
+ if (!callback) {
15
+ throw new Error("Internal error");
16
+ }
17
+ // display HistoryCapabilities of server
18
+ const browsePath = (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(node_opcua_constants_1.ObjectIds.ObjectsFolder, "/Server/ServerCapabilities.HistoryServerCapabilities");
19
+ session.translateBrowsePath(browsePath, (err, result) => {
20
+ if (err) {
21
+ return callback(err);
22
+ }
23
+ /* istanbul ignore next */
24
+ if (!result) {
25
+ return callback(new Error("Internal Error"));
26
+ }
27
+ if (result.statusCode.isNotGood()) {
28
+ return callback(new Error("StatusCode = " + result.statusCode.toString()));
29
+ }
30
+ result.targets = result.targets || [];
31
+ const historyServerCapabilitiesNodeId = result.targets[0].targetId;
32
+ // (should be ns=0;i=11192)
33
+ (0, node_opcua_assert_1.assert)(historyServerCapabilitiesNodeId.toString() === "ns=0;i=11192");
34
+ // -------------------------
35
+ const properties = [
36
+ "AccessHistoryDataCapability",
37
+ "AccessHistoryEventsCapability",
38
+ "DeleteAtTimeCapability",
39
+ "DeleteRawCapability",
40
+ "DeleteEventCapability",
41
+ "InsertAnnotationCapability",
42
+ "InsertDataCapability",
43
+ "InsertEventCapability",
44
+ "ReplaceDataCapability",
45
+ "ReplaceEventCapability",
46
+ "UpdateDataCapability",
47
+ "UpdateEventCapability",
48
+ "MaxReturnDataValues",
49
+ "MaxReturnEventValues",
50
+ "AggregateFunctions/AnnotationCount",
51
+ "AggregateFunctions/Average",
52
+ "AggregateFunctions/Count",
53
+ "AggregateFunctions/Delta",
54
+ "AggregateFunctions/DeltaBounds",
55
+ "AggregateFunctions/DurationBad",
56
+ "AggregateFunctions/DurationGood",
57
+ "AggregateFunctions/DurationStateNonZero"
58
+ // etc....
59
+ ];
60
+ const browsePaths = properties.map((prop) => (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(historyServerCapabilitiesNodeId, "." + prop));
61
+ session.translateBrowsePath(browsePaths, (innerErr, results) => {
62
+ if (innerErr) {
63
+ return callback(innerErr);
64
+ }
65
+ /* istanbul ignore next */
66
+ if (!results) {
67
+ return callback(new Error("Internal Error"));
68
+ }
69
+ const nodeIds = results.map((innerResult) => innerResult.statusCode.isGood() && innerResult.targets
70
+ ? innerResult.targets[0].targetId
71
+ : new node_opcua_nodeid_1.NodeId());
72
+ const nodesToRead = nodeIds.map((nodeId) => ({
73
+ attributeId: node_opcua_data_model_1.AttributeIds.Value,
74
+ nodeId /*: coerceNodeId(nodeId)*/
75
+ }));
76
+ const data = {};
77
+ session.read(nodesToRead, (err2, dataValues) => {
78
+ if (err2) {
79
+ return callback(err2);
80
+ }
81
+ /* istanbul ignore next */
82
+ if (!dataValues) {
83
+ return callback(new Error("Internal Error"));
84
+ }
85
+ for (let i = 0; i < dataValues.length; i++) {
86
+ const propName = (0, node_opcua_utils_1.lowerFirstLetter)(properties[i]);
87
+ data[propName] = dataValues[i].value;
88
+ }
89
+ callback(null, data);
90
+ });
91
+ });
92
+ });
93
+ }
94
+ exports.readHistoryServerCapabilities = readHistoryServerCapabilities;
95
+ // tslint:disable:no-var-requires
96
+ const thenify = require("thenify");
97
+ const opts = { multiArgs: false };
98
+ module.exports.readHistoryServerCapabilities = thenify.withCallback(module.exports.readHistoryServerCapabilities, opts);
99
+ //# sourceMappingURL=read_history_server_capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read_history_server_capabilities.js","sourceRoot":"","sources":["../../source/tools/read_history_server_capabilities.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,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,IAAI,CAAC,UAAU,EAAE;oBACb,OAAO,QAAQ,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;iBAChD;gBAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACxC,MAAM,QAAQ,GAAG,IAAA,mCAAgB,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;oBACjD,IAAI,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,KAAgB,CAAC;iBACnD;gBACD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AA/FD,sEA+FC;AACD,iCAAiC;AACjC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,IAAI,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACjC,MAAc,CAAC,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,YAAY,CACvE,MAAc,CAAC,OAAO,CAAC,6BAA6B,EACrD,IAAI,CACP,CAAC"}
@@ -0,0 +1 @@
1
+ export { UserIdentityInfoUserName, UserIdentityInfoX509, AnonymousIdentity, UserIdentityInfo } from "node-opcua-pseudo-session";
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user_identity_info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user_identity_info.js","sourceRoot":"","sources":["../source/user_identity_info.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { OPCUACertificateManager } from "node-opcua-certificate-manager";
2
+ import { OPCUASecureObject } from "node-opcua-common";
3
+ import { Certificate } from "node-opcua-crypto";
4
+ export declare function verifyIsOPCUAValidCertificate(certificate: Certificate, certificateFile: string, type: "client" | "server", applicationUri: string): void;
5
+ export declare function performCertificateSanityCheck(this: OPCUASecureObject, serverOrClient: "server" | "client", certificateManager: OPCUACertificateManager, applicationUri: string): Promise<void>;
package/dist/verify.js ADDED
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.performCertificateSanityCheck = exports.verifyIsOPCUAValidCertificate = void 0;
13
+ const node_opcua_crypto_1 = require("node-opcua-crypto");
14
+ const node_opcua_debug_1 = require("node-opcua-debug");
15
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
16
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
17
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
18
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
19
+ function verifyIsOPCUAValidCertificate(certificate, certificateFile, type, applicationUri) {
20
+ var _a, _b, _c, _d, _e;
21
+ const certificateInfo = (0, node_opcua_crypto_1.exploreCertificate)(certificate);
22
+ const now = new Date();
23
+ if (certificateInfo.tbsCertificate.validity.notBefore.getTime() > now.getTime()) {
24
+ // check that certificate is active
25
+ // certificate is not active yet
26
+ warningLog(`[NODE-OPCUA-W02] The certificate is not active yet\n` +
27
+ `notBefore ${certificateInfo.tbsCertificate.validity.notBefore.toISOString()}\n` +
28
+ `certificateFile ${certificateFile}`);
29
+ }
30
+ // check that certificate has not expired
31
+ if (certificateInfo.tbsCertificate.validity.notAfter.getTime() <= now.getTime()) {
32
+ // certificate is obsolete
33
+ warningLog(`[NODE-OPCUA-W03] The certificate has expired\n` +
34
+ `Please regenerate a valid certificate\n` +
35
+ `notAfter = ${certificateInfo.tbsCertificate.validity.notAfter.toISOString()}\n` +
36
+ `certificateFile= ${certificateFile}`);
37
+ }
38
+ else {
39
+ const tenDays = 10 * 24 * 60 * 60 * 1000;
40
+ if (certificateInfo.tbsCertificate.validity.notAfter.getTime() <= now.getTime() + tenDays) {
41
+ // certificate is going to expired very soon
42
+ warningLog(`[NODE-OPCUA-W05] The certificate is about to expire in less than 10 days.\n` +
43
+ `Please regenerate a valid certificate as soon as possible\n` +
44
+ `notAfter = ${certificateInfo.tbsCertificate.validity.notAfter.toISOString()}\n` +
45
+ `certificateFile= ${certificateFile}\n`);
46
+ }
47
+ }
48
+ // check that server certificate matches Application URI
49
+ const uniformResourceIdentifier = (_c = (_b = (_a = certificateInfo === null || certificateInfo === void 0 ? void 0 : certificateInfo.tbsCertificate) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.subjectAltName) === null || _c === void 0 ? void 0 : _c.uniformResourceIdentifier;
50
+ if (!uniformResourceIdentifier) {
51
+ warningLog(`[NODE-OPCUA-W14] The certificate subjectAltName uniformResourceIdentifier is missing.\n` +
52
+ `Please regenerate a specific certificate with a uniformResourceIdentifier that matches your ${type} applicationUri\n` +
53
+ `applicationUri = ${applicationUri}\n` +
54
+ `certificateFile = ${certificateFile}\n`);
55
+ return;
56
+ }
57
+ else if (uniformResourceIdentifier[0] !== applicationUri) {
58
+ warningLog(`[NODE-OPCUA-W06] The certificate subjectAltName does not match the ${type} applicationUri\n` +
59
+ `Please regenerate a specific certificate that matches your ${type} applicationUri\n` +
60
+ `certificate subjectAltName = ${uniformResourceIdentifier[0]}\n` +
61
+ `${type} applicationUri = ${applicationUri}\n` +
62
+ `certificateFile = ${certificateFile}\n`);
63
+ }
64
+ const keyUsage = (_d = certificateInfo.tbsCertificate.extensions) === null || _d === void 0 ? void 0 : _d.keyUsage;
65
+ if (!keyUsage) {
66
+ warningLog(`[NODE-OPCUA-W15] The certificate keyUsage is missing\n` + `certificateFile = ${certificateFile}`);
67
+ }
68
+ else {
69
+ // spec says that certificate shall include digitalSignature, nonRepudiation, keyEncipherment and dataEncipherment.
70
+ // Other key uses are allowed.
71
+ if (!keyUsage.digitalSignature || !keyUsage.nonRepudiation || !keyUsage.keyEncipherment || !keyUsage.dataEncipherment) {
72
+ warningLog(`[NODE-OPCUA-W16] The certificate keyUsage must include digitalSignature, nonRepudiation, keyEncipherment and dataEncipherment.\n` +
73
+ `see https://reference.opcfoundation.org/v104/Core/docs/Part6/6.2.2/\n` +
74
+ `certificateFile = ${certificateFile}`);
75
+ }
76
+ }
77
+ const extKeyUsage = (_e = certificateInfo.tbsCertificate.extensions) === null || _e === void 0 ? void 0 : _e.extKeyUsage;
78
+ if (!extKeyUsage) {
79
+ warningLog(`[NODE-OPCUA-W17] The certificate extKeyUsage is missing\n` + `certificateFile = ${certificateFile}`);
80
+ }
81
+ else {
82
+ // spec says that certificate shall include digitalSignature, nonRepudiation, keyEncipherment and dataEncipherment.
83
+ // Other key uses are allowed.
84
+ if (!extKeyUsage.clientAuth && !extKeyUsage.serverAuth) {
85
+ warningLog(`[NODE-OPCUA-W18] The certificate extKeyUsage must include clientAuth and/or serverAuth.\n` +
86
+ `see https://reference.opcfoundation.org/v104/Core/docs/Part6/6.2.2/\n` +
87
+ `certificateFile = ${certificateFile}`);
88
+ }
89
+ }
90
+ const keyLengthInBits = certificateInfo.tbsCertificate.subjectPublicKeyInfo.keyLength * 8;
91
+ if (keyLengthInBits < 1024) {
92
+ errorLog(`[NODE-OPCUA-W19] The public key length shall be greater than or equal to 1024 bits. key length is ${keyLengthInBits}.\n` +
93
+ `see https://reference.opcfoundation.org/v104/GDS/docs/7.6.3/\n` +
94
+ `certificateFile = ${certificateFile}`);
95
+ }
96
+ else if (keyLengthInBits < 2048) {
97
+ warningLog(`[NODE-OPCUA-W23] key lengths less than 2048 are considered insecure. key length is ${keyLengthInBits}\n` +
98
+ `see https://reference.opcfoundation.org/v104/Core/docs/Part2/6.8/\n` +
99
+ `certificateFile = ${certificateFile}`);
100
+ }
101
+ }
102
+ exports.verifyIsOPCUAValidCertificate = verifyIsOPCUAValidCertificate;
103
+ function performCertificateSanityCheck(serverOrClient, certificateManager, applicationUri) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ // verify that certificate is matching private key, and inform the developper if not
106
+ const certificate = this.getCertificate();
107
+ const privateKey = this.getPrivateKey();
108
+ //
109
+ if (!(0, node_opcua_crypto_1.publicKeyAndPrivateKeyMatches)(certificate, privateKey)) {
110
+ errorLog("[NODE-OPCUA-E01] Configuration error : the certificate and the private key do not match !");
111
+ errorLog(" please check the configuration of the OPCUA Server");
112
+ errorLog(" privateKey= ", this.privateKeyFile);
113
+ errorLog(" certificateManager.privateKey= ", certificateManager.privateKey);
114
+ errorLog(" certificateFile= ", this.certificateFile);
115
+ throw new Error("[NODE-OPCUA-E01] Configuration error : the certificate and the private key do not match ! please fix your configuration");
116
+ }
117
+ // verify that the certificate provided has the right key length ( at least 2048)
118
+ const privateKeyInfo = (0, node_opcua_crypto_1.explorePrivateKey)(privateKey);
119
+ const keyLengthInBits = privateKeyInfo.modulus.length * 8;
120
+ if (keyLengthInBits <= 1024) {
121
+ warningLog(`[NODE-OPCUA-W04] The public/private key pair uses a key length which is equal or lower than 1024 bits. ( key length was ${keyLengthInBits} )\n` +
122
+ `OPCUA version 1.04 requires that security key length are greater or equal to 2048 bits.\n` +
123
+ `The ${serverOrClient} is operating at risk. `);
124
+ }
125
+ // verify that the certificate has a valid date and has expected extensions fields such as DNS and IP.
126
+ const status1 = yield certificateManager.trustCertificate(certificate);
127
+ const status = yield certificateManager.verifyCertificateAsync(certificate);
128
+ if (status !== "Good") {
129
+ warningLog("[NODE-OPCUA-W04] Warning: the certificate status is = ", status, " file = ", this.certificateFile);
130
+ }
131
+ verifyIsOPCUAValidCertificate(certificate, this.certificateFile, serverOrClient, applicationUri);
132
+ });
133
+ }
134
+ exports.performCertificateSanityCheck = performCertificateSanityCheck;
135
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../source/verify.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,yDAM2B;AAC3B,uDAAiG;AAEjG,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,UAAU,CAAC,CAAC;AAE/C,SAAgB,6BAA6B,CACzC,WAAwB,EACxB,eAAuB,EACvB,IAAyB,EACzB,cAAsB;;IAEtB,MAAM,eAAe,GAAG,IAAA,sCAAkB,EAAC,WAAW,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,IAAI,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,EAAE;QAC7E,mCAAmC;QACnC,gCAAgC;QAChC,UAAU,CACN,sDAAsD;YAClD,mBAAmB,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI;YACtF,mBAAmB,eAAe,EAAE,CAC3C,CAAC;KACL;IACD,0CAA0C;IAC1C,IAAI,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE;QAC7E,0BAA0B;QAC1B,UAAU,CACN,gDAAgD;YAC5C,yCAAyC;YACzC,oBAAoB,eAAe,CAAC,cAAc,CAAC,QAAQ,CAA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,EAAE;QACF,IAAI,CAAC,IAAA,iDAA6B,EAAC,WAAW,EAAE,UAAU,CAAC,EAAE;YACzD,QAAQ,CAAC,2FAA2F,CAAC,CAAC;YACtG,QAAQ,CAAC,sEAAsE,CAAC,CAAC;YACjF,QAAQ,CAAC,kCAAkC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YAClE,QAAQ,CAAC,kCAAkC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;YAC5E,QAAQ,CAAC,kCAAkC,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;YACnE,MAAM,IAAI,KAAK,CACX,yHAAyH,CAC5H,CAAC;SACL;QACD,iFAAiF;QACjF,MAAM,cAAc,GAAG,IAAA,qCAAiB,EAAC,UAAU,CAAC,CAAC;QACrD,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1D,IAAI,eAAe,IAAI,IAAI,EAAE;YACzB,UAAU,CACN,2HAA2H,eAAe,MAAM;gBAC5I,2FAA2F;gBAC3F,OAAO,cAAc,qEAAqE,CACjG,CAAC;SACL;QACD,sGAAsG;QACtG,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACvE,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;QAE5E,IAAI,MAAM,KAAK,MAAM,EAAE;YACnB,UAAU,CAAC,wDAAwD,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;SAClH;QAED,6BAA6B,CAAC,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IACrG,CAAC;CAAA;AAvCD,sEAuCC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-opcua-client",
3
- "version": "2.98.0",
4
- "description": "pure nodejs OPCUA SDK - module -client",
3
+ "version": "2.98.1",
4
+ "description": "pure nodejs OPCUA SDK - module client",
5
5
  "scripts": {
6
6
  "clean": "npx rimraf node_modules dist *.tsbuildinfo certificates",
7
7
  "test": "mocha",
@@ -19,44 +19,44 @@
19
19
  "async": "^3.2.4",
20
20
  "callbackify": "^1.1.0",
21
21
  "chalk": "4.1.2",
22
- "node-opcua-assert": "2.88.0",
23
- "node-opcua-basic-types": "2.98.0",
24
- "node-opcua-buffer-utils": "2.98.0",
25
- "node-opcua-certificate-manager": "2.98.0",
26
- "node-opcua-client-dynamic-extension-object": "2.98.0",
27
- "node-opcua-common": "2.98.0",
28
- "node-opcua-constants": "2.88.0",
22
+ "node-opcua-assert": "2.98.1",
23
+ "node-opcua-basic-types": "2.98.1",
24
+ "node-opcua-buffer-utils": "2.98.1",
25
+ "node-opcua-certificate-manager": "2.98.1",
26
+ "node-opcua-client-dynamic-extension-object": "2.98.1",
27
+ "node-opcua-common": "2.98.1",
28
+ "node-opcua-constants": "2.98.1",
29
29
  "node-opcua-crypto": "^2.1.2",
30
- "node-opcua-data-model": "2.98.0",
31
- "node-opcua-data-value": "2.98.0",
32
- "node-opcua-date-time": "2.98.0",
33
- "node-opcua-debug": "2.98.0",
34
- "node-opcua-extension-object": "2.98.0",
35
- "node-opcua-hostname": "2.88.0",
36
- "node-opcua-nodeid": "2.98.0",
37
- "node-opcua-object-registry": "2.98.0",
30
+ "node-opcua-data-model": "2.98.1",
31
+ "node-opcua-data-value": "2.98.1",
32
+ "node-opcua-date-time": "2.98.1",
33
+ "node-opcua-debug": "2.98.1",
34
+ "node-opcua-extension-object": "2.98.1",
35
+ "node-opcua-hostname": "2.98.1",
36
+ "node-opcua-nodeid": "2.98.1",
37
+ "node-opcua-object-registry": "2.98.1",
38
38
  "node-opcua-pki": "^3.0.2",
39
- "node-opcua-pseudo-session": "2.98.0",
40
- "node-opcua-schemas": "2.98.0",
41
- "node-opcua-secure-channel": "2.98.0",
42
- "node-opcua-service-browse": "2.98.0",
43
- "node-opcua-service-call": "2.98.0",
44
- "node-opcua-service-discovery": "2.98.0",
45
- "node-opcua-service-endpoints": "2.98.0",
46
- "node-opcua-service-filter": "2.98.0",
47
- "node-opcua-service-history": "2.98.0",
48
- "node-opcua-service-query": "2.98.0",
49
- "node-opcua-service-read": "2.98.0",
50
- "node-opcua-service-register-node": "2.98.0",
51
- "node-opcua-service-secure-channel": "2.98.0",
52
- "node-opcua-service-session": "2.98.0",
53
- "node-opcua-service-subscription": "2.98.0",
54
- "node-opcua-service-translate-browse-path": "2.98.0",
55
- "node-opcua-service-write": "2.98.0",
56
- "node-opcua-status-code": "2.98.0",
57
- "node-opcua-types": "2.98.0",
58
- "node-opcua-utils": "2.98.0",
59
- "node-opcua-variant": "2.98.0",
39
+ "node-opcua-pseudo-session": "2.98.1",
40
+ "node-opcua-schemas": "2.98.1",
41
+ "node-opcua-secure-channel": "2.98.1",
42
+ "node-opcua-service-browse": "2.98.1",
43
+ "node-opcua-service-call": "2.98.1",
44
+ "node-opcua-service-discovery": "2.98.1",
45
+ "node-opcua-service-endpoints": "2.98.1",
46
+ "node-opcua-service-filter": "2.98.1",
47
+ "node-opcua-service-history": "2.98.1",
48
+ "node-opcua-service-query": "2.98.1",
49
+ "node-opcua-service-read": "2.98.1",
50
+ "node-opcua-service-register-node": "2.98.1",
51
+ "node-opcua-service-secure-channel": "2.98.1",
52
+ "node-opcua-service-session": "2.98.1",
53
+ "node-opcua-service-subscription": "2.98.1",
54
+ "node-opcua-service-translate-browse-path": "2.98.1",
55
+ "node-opcua-service-write": "2.98.1",
56
+ "node-opcua-status-code": "2.98.1",
57
+ "node-opcua-types": "2.98.1",
58
+ "node-opcua-utils": "2.98.1",
59
+ "node-opcua-variant": "2.98.1",
60
60
  "once": "^1.4.0",
61
61
  "thenify": "^3.3.1"
62
62
  },
@@ -64,11 +64,11 @@
64
64
  "@types/underscore": "^1.11.4",
65
65
  "dequeue": "^1.0.5",
66
66
  "mocha": "^10.2.0",
67
- "node-opcua-address-space": "2.98.0",
68
- "node-opcua-binary-stream": "2.98.0",
69
- "node-opcua-factory": "2.98.0",
70
- "node-opcua-leak-detector": "2.98.0",
71
- "node-opcua-nodesets": "2.98.0",
67
+ "node-opcua-address-space": "2.98.1",
68
+ "node-opcua-binary-stream": "2.98.1",
69
+ "node-opcua-factory": "2.98.1",
70
+ "node-opcua-leak-detector": "2.98.1",
71
+ "node-opcua-nodesets": "2.98.1",
72
72
  "should": "^13.2.3",
73
73
  "sinon": "^15.0.3",
74
74
  "underscore": "^1.13.6"
@@ -93,5 +93,9 @@
93
93
  "internet of things"
94
94
  ],
95
95
  "homepage": "http://node-opcua.github.io/",
96
- "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c"
96
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
97
+ "files": [
98
+ "dist",
99
+ "source"
100
+ ]
97
101
  }
package/.nycrc.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "@istanbuljs/nyc-config-typescript",
3
- "all": true,
4
- "__check-coverage": true,
5
- "excludeNodeModules": false,
6
- "include": [
7
- "dist/**/*.js",
8
- "source/**/*.ts"
9
- ],
10
- "reporter": [
11
- "text",
12
- "lcov"
13
- ]
14
- }
@@ -1 +0,0 @@
1
- require("node-opcua-pki/bin/crypto_create_CA");
package/typedoc.js DELETED
@@ -1,20 +0,0 @@
1
- // (e.g. typedoc --options ./typedoc.js ./src), then you can set an array of exclude paths in the configuration:
2
- // typedoc.js:
3
-
4
- module.exports = {
5
- src: [ "./source/index.ts" ],
6
- out: "./out1/",
7
-
8
- readme: "./documentation/readme.md",
9
- includes: "./documentation",
10
- exclude: ["*/@types/**"],
11
- mode: "file",
12
- //xx excludeExternals: true,
13
- excludeNotExported: true,
14
- excludePrivate: true,
15
- includeDeclarations: true,
16
- moduleResolution: "node",
17
- theme: "default",
18
- logger: "console"
19
- };
20
-