node-opcua-samples 2.110.0 → 2.111.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/bin/simple_server.js
CHANGED
|
@@ -9,6 +9,7 @@ const assert = require("assert");
|
|
|
9
9
|
const chalk = require("chalk");
|
|
10
10
|
const yargs = require("yargs/yargs");
|
|
11
11
|
const envPaths = require("env-paths");
|
|
12
|
+
const bcrypt = require("bcrypt");
|
|
12
13
|
|
|
13
14
|
const {
|
|
14
15
|
OPCUAServer,
|
|
@@ -26,13 +27,9 @@ const {
|
|
|
26
27
|
WellKnownRoles
|
|
27
28
|
} = require("node-opcua");
|
|
28
29
|
|
|
29
|
-
const {
|
|
30
|
-
install_optional_cpu_and_memory_usage_node,
|
|
31
|
-
} = require("node-opcua-vendor-diagnostic");
|
|
30
|
+
const { install_optional_cpu_and_memory_usage_node } = require("node-opcua-vendor-diagnostic");
|
|
32
31
|
|
|
33
|
-
const {
|
|
34
|
-
build_address_space_for_conformance_testing,
|
|
35
|
-
}= require("node-opcua-address-space-for-conformance-testing");
|
|
32
|
+
const { build_address_space_for_conformance_testing } = require("node-opcua-address-space-for-conformance-testing");
|
|
36
33
|
|
|
37
34
|
Error.stackTraceLimit = Infinity;
|
|
38
35
|
|
|
@@ -83,10 +80,10 @@ const maxSubscriptionsPerSession = argv.maxSubscriptionsPerSession || 50;
|
|
|
83
80
|
async function getIpAddresses() {
|
|
84
81
|
const ipAddresses = [];
|
|
85
82
|
const interfaces = os.networkInterfaces();
|
|
86
|
-
Object.keys(interfaces).forEach(function
|
|
83
|
+
Object.keys(interfaces).forEach(function(interfaceName) {
|
|
87
84
|
let alias = 0;
|
|
88
85
|
|
|
89
|
-
interfaces[interfaceName].forEach(function
|
|
86
|
+
interfaces[interfaceName].forEach(function(iface) {
|
|
90
87
|
if ("IPv4" !== iface.family || iface.internal !== false) {
|
|
91
88
|
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
|
|
92
89
|
return;
|
|
@@ -106,13 +103,18 @@ async function getIpAddresses() {
|
|
|
106
103
|
return ipAddresses;
|
|
107
104
|
}
|
|
108
105
|
|
|
106
|
+
const salt = bcrypt.genSaltSync(10);
|
|
109
107
|
const users = [
|
|
110
108
|
{
|
|
111
109
|
username: "user1",
|
|
112
|
-
password: "password1",
|
|
110
|
+
password: bcrypt.hashSync((() => "password1")(), salt),
|
|
113
111
|
role: makeRoles([WellKnownRoles.AuthenticatedUser, WellKnownRoles.ConfigureAdmin])
|
|
114
112
|
},
|
|
115
|
-
{
|
|
113
|
+
{
|
|
114
|
+
username: "user2",
|
|
115
|
+
password: bcrypt.hashSync((() => "password2")(), salt),
|
|
116
|
+
role: makeRoles([WellKnownRoles.AuthenticatedUser, WellKnownRoles.Operator])
|
|
117
|
+
}
|
|
116
118
|
];
|
|
117
119
|
|
|
118
120
|
const userManager = {
|
|
@@ -121,10 +123,7 @@ const userManager = {
|
|
|
121
123
|
if (uIndex < 0) {
|
|
122
124
|
return false;
|
|
123
125
|
}
|
|
124
|
-
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return true;
|
|
126
|
+
return bcrypt.compareSync(password, users[uIndex].password);
|
|
128
127
|
},
|
|
129
128
|
getUserRoles(username) {
|
|
130
129
|
const uIndex = users.findIndex((x) => x.username === username);
|
|
@@ -236,7 +235,6 @@ const paths = envPaths(productUri);
|
|
|
236
235
|
server_options.alternateHostname = argv.alternateHostname;
|
|
237
236
|
const server = new OPCUAServer(server_options);
|
|
238
237
|
|
|
239
|
-
|
|
240
238
|
await server.initialize();
|
|
241
239
|
|
|
242
240
|
function post_initialize() {
|
|
@@ -270,7 +268,7 @@ const paths = envPaths(productUri);
|
|
|
270
268
|
value: new Variant({ dataType: DataType.Double, value: 1000.0 })
|
|
271
269
|
});
|
|
272
270
|
|
|
273
|
-
setInterval(function
|
|
271
|
+
setInterval(function() {
|
|
274
272
|
const fluctuation = Math.random() * 100 - 50;
|
|
275
273
|
variable0.setValueFromSource(new Variant({ dataType: DataType.Double, value: 1000.0 + fluctuation }));
|
|
276
274
|
}, 10);
|
|
@@ -296,7 +294,7 @@ const paths = envPaths(productUri);
|
|
|
296
294
|
* @method get
|
|
297
295
|
* @return {Variant}
|
|
298
296
|
*/
|
|
299
|
-
get: function
|
|
297
|
+
get: function() {
|
|
300
298
|
const pump_speed = 200 + 100 * Math.sin(Date.now() / 10000);
|
|
301
299
|
return new Variant({ dataType: DataType.Double, value: pump_speed });
|
|
302
300
|
}
|
|
@@ -309,7 +307,7 @@ const paths = envPaths(productUri);
|
|
|
309
307
|
nodeId: "ns=1;s=SomeDate",
|
|
310
308
|
dataType: "DateTime",
|
|
311
309
|
value: {
|
|
312
|
-
get: function
|
|
310
|
+
get: function() {
|
|
313
311
|
return new Variant({ dataType: DataType.DateTime, value: new Date(Date.UTC(2016, 9, 13, 8, 40, 0)) });
|
|
314
312
|
}
|
|
315
313
|
}
|
|
@@ -328,7 +326,7 @@ const paths = envPaths(productUri);
|
|
|
328
326
|
sourceTimestamp: null,
|
|
329
327
|
sourcePicoseconds: 0
|
|
330
328
|
});
|
|
331
|
-
setInterval(function
|
|
329
|
+
setInterval(function() {
|
|
332
330
|
external_value_with_sourceTimestamp.value.value = Math.random();
|
|
333
331
|
external_value_with_sourceTimestamp.sourceTimestamp = new Date();
|
|
334
332
|
}, 1000);
|
|
@@ -339,7 +337,7 @@ const paths = envPaths(productUri);
|
|
|
339
337
|
nodeId: "ns=1;s=Pressure",
|
|
340
338
|
dataType: "Double",
|
|
341
339
|
value: {
|
|
342
|
-
timestamped_get: function
|
|
340
|
+
timestamped_get: function() {
|
|
343
341
|
return external_value_with_sourceTimestamp;
|
|
344
342
|
}
|
|
345
343
|
}
|
|
@@ -362,13 +360,13 @@ const paths = envPaths(productUri);
|
|
|
362
360
|
dataType: "Double",
|
|
363
361
|
|
|
364
362
|
value: {
|
|
365
|
-
refreshFunc: function
|
|
363
|
+
refreshFunc: function(callback) {
|
|
366
364
|
const temperature = 20 + 10 * Math.sin(Date.now() / 10000);
|
|
367
365
|
const value = new Variant({ dataType: DataType.Double, value: temperature });
|
|
368
366
|
const sourceTimestamp = new Date();
|
|
369
367
|
|
|
370
368
|
// simulate a asynchronous behaviour
|
|
371
|
-
setTimeout(function
|
|
369
|
+
setTimeout(function() {
|
|
372
370
|
callback(null, new DataValue({ value: value, sourceTimestamp: sourceTimestamp }));
|
|
373
371
|
}, 100);
|
|
374
372
|
}
|
|
@@ -389,7 +387,7 @@ const paths = envPaths(productUri);
|
|
|
389
387
|
engineeringUnits: standardUnits.degree_celsius,
|
|
390
388
|
dataType: "Double",
|
|
391
389
|
value: {
|
|
392
|
-
get: function
|
|
390
|
+
get: function() {
|
|
393
391
|
return new Variant({ dataType: DataType.Double, value: Math.random() + 19.0 });
|
|
394
392
|
}
|
|
395
393
|
}
|
|
@@ -403,7 +401,7 @@ const paths = envPaths(productUri);
|
|
|
403
401
|
valueRank: 2,
|
|
404
402
|
arrayDimensions: [3, 3],
|
|
405
403
|
value: {
|
|
406
|
-
get: function
|
|
404
|
+
get: function() {
|
|
407
405
|
return new Variant({
|
|
408
406
|
dataType: DataType.Double,
|
|
409
407
|
arrayType: VariantArrayType.Matrix,
|
|
@@ -422,7 +420,7 @@ const paths = envPaths(productUri);
|
|
|
422
420
|
valueRank: 1,
|
|
423
421
|
arrayDimensions: null,
|
|
424
422
|
value: {
|
|
425
|
-
get: function
|
|
423
|
+
get: function() {
|
|
426
424
|
return new Variant({
|
|
427
425
|
dataType: DataType.Double,
|
|
428
426
|
arrayType: VariantArrayType.Array,
|
|
@@ -485,13 +483,13 @@ const paths = envPaths(productUri);
|
|
|
485
483
|
|
|
486
484
|
if (argv.silent) {
|
|
487
485
|
console.log(" silent");
|
|
488
|
-
console.log = function
|
|
486
|
+
console.log = function() {
|
|
489
487
|
/** */
|
|
490
488
|
};
|
|
491
489
|
}
|
|
492
490
|
// console.log = function(){};
|
|
493
491
|
|
|
494
|
-
server.on("create_session", function
|
|
492
|
+
server.on("create_session", function(session) {
|
|
495
493
|
console.log(" SESSION CREATED");
|
|
496
494
|
console.log(chalk.cyan(" client application URI: "), session.clientDescription.applicationUri);
|
|
497
495
|
console.log(chalk.cyan(" client product URI: "), session.clientDescription.productUri);
|
|
@@ -502,7 +500,7 @@ const paths = envPaths(productUri);
|
|
|
502
500
|
console.log(chalk.cyan(" session id: "), session.sessionId);
|
|
503
501
|
});
|
|
504
502
|
|
|
505
|
-
server.on("session_closed", function
|
|
503
|
+
server.on("session_closed", function(session, reason) {
|
|
506
504
|
console.log(" SESSION CLOSED :", reason);
|
|
507
505
|
console.log(chalk.cyan(" session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
|
|
508
506
|
});
|
|
@@ -517,7 +515,7 @@ const paths = envPaths(productUri);
|
|
|
517
515
|
const spacer = " ".slice(0, nb);
|
|
518
516
|
return str
|
|
519
517
|
.split("\n")
|
|
520
|
-
.map(function
|
|
518
|
+
.map(function(s) {
|
|
521
519
|
return spacer + s;
|
|
522
520
|
})
|
|
523
521
|
.join("\n");
|
|
@@ -531,7 +529,7 @@ const paths = envPaths(productUri);
|
|
|
531
529
|
}
|
|
532
530
|
|
|
533
531
|
const servicesToTrace = ["CreateMonitoredItems", "Publish", "ModifyMonitoredItems"]; // "Publish", "TransferSubscriptions", "Republish", "CreateSubscription", "CreateMonitoredItems"];
|
|
534
|
-
server.on("response", function
|
|
532
|
+
server.on("response", function(response) {
|
|
535
533
|
if (argv.silent) {
|
|
536
534
|
return;
|
|
537
535
|
}
|
|
@@ -547,7 +545,7 @@ const paths = envPaths(productUri);
|
|
|
547
545
|
}
|
|
548
546
|
});
|
|
549
547
|
|
|
550
|
-
server.on("request", function
|
|
548
|
+
server.on("request", function(request, channel) {
|
|
551
549
|
if (argv.silent) {
|
|
552
550
|
return;
|
|
553
551
|
}
|
|
@@ -563,11 +561,11 @@ const paths = envPaths(productUri);
|
|
|
563
561
|
}
|
|
564
562
|
});
|
|
565
563
|
|
|
566
|
-
process.once("SIGINT", function
|
|
564
|
+
process.once("SIGINT", function() {
|
|
567
565
|
// only work on linux apparently
|
|
568
566
|
console.error(chalk.red.bold(" Received server interruption from user "));
|
|
569
567
|
console.error(chalk.red.bold(" shutting down ..."));
|
|
570
|
-
server.shutdown(1000, function
|
|
568
|
+
server.shutdown(1000, function() {
|
|
571
569
|
console.error(chalk.red.bold(" shutting down completed "));
|
|
572
570
|
console.error(chalk.red.bold(" done "));
|
|
573
571
|
console.error("");
|
|
@@ -10,12 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const node_opcua_1 = require("node-opcua");
|
|
13
|
+
const bcrypt_1 = require("bcrypt");
|
|
13
14
|
const port = 2510;
|
|
14
15
|
let server;
|
|
16
|
+
const salt = (0, bcrypt_1.genSaltSync)(10);
|
|
15
17
|
const users = [
|
|
16
18
|
{
|
|
17
19
|
username: "user1",
|
|
18
|
-
password: "
|
|
20
|
+
password: (() => (0, bcrypt_1.hashSync)((() => "password1")(), salt))(),
|
|
19
21
|
roles: (0, node_opcua_1.makeRoles)([node_opcua_1.WellKnownRoles.AuthenticatedUser, node_opcua_1.WellKnownRoles.ConfigureAdmin])
|
|
20
22
|
}
|
|
21
23
|
];
|
|
@@ -27,10 +29,7 @@ const userManager = {
|
|
|
27
29
|
if (uIndex < 0) {
|
|
28
30
|
return false;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
32
|
+
return (0, bcrypt_1.compareSync)(password, users[uIndex].password);
|
|
34
33
|
},
|
|
35
34
|
getUserRoles: (username) => {
|
|
36
35
|
const uIndex = users.findIndex(function (x) {
|
|
@@ -68,7 +67,7 @@ function startServer() {
|
|
|
68
67
|
console.log("server connection refused");
|
|
69
68
|
});
|
|
70
69
|
server.on("session_closed", () => {
|
|
71
|
-
console.log("server
|
|
70
|
+
console.log("server session closed");
|
|
72
71
|
});
|
|
73
72
|
server.on("create_session", () => {
|
|
74
73
|
console.log("server create session");
|
|
@@ -84,9 +83,9 @@ function startServer() {
|
|
|
84
83
|
}
|
|
85
84
|
});
|
|
86
85
|
while (true) {
|
|
87
|
-
users[0].password = `password${counter % 2}
|
|
86
|
+
users[0].password = (0, bcrypt_1.hashSync)(`password${counter % 2}`, salt);
|
|
88
87
|
counter++;
|
|
89
|
-
console.log("user:
|
|
88
|
+
console.log("user:", users[0].username, "(", `password${counter % 2}`, ")");
|
|
90
89
|
const server = yield startServer();
|
|
91
90
|
console.log("server started at", server.getEndpointUrl());
|
|
92
91
|
yield new Promise((resolve) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server_with_changing_password.js","sourceRoot":"","sources":["../bin/server_with_changing_password.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAsF;
|
|
1
|
+
{"version":3,"file":"server_with_changing_password.js","sourceRoot":"","sources":["../bin/server_with_changing_password.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAsF;AACtF,mCAA4D;AAC5D,MAAM,IAAI,GAAG,IAAI,CAAC;AAClB,IAAI,MAAmB,CAAC;AAExB,MAAM,IAAI,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC;AAC7B,MAAM,KAAK,GAAG;IACV;QACI,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,IAAA,iBAAQ,EAAC,CAAC,GAAE,EAAE,CAAA,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE;QACvD,KAAK,EAAE,IAAA,sBAAS,EAAC,CAAC,2BAAc,CAAC,iBAAiB,EAAE,2BAAc,CAAC,cAAc,CAAC,CAAC;KACtF;CACJ,CAAC;AAEF,MAAM,WAAW,GAAG;IAChB,WAAW,EAAE,CAAC,QAAgB,EAAE,QAAgB,EAAW,EAAE;QACzD,MAAM,MAAM,GAAG,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,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;YAC3C,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAEjC,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;KACjD;AACL,CAAC,CAAA,CAAC,EAAE,CAAC"}
|
|
@@ -44,6 +44,7 @@ const node_opcua_1 = require("node-opcua");
|
|
|
44
44
|
const node_opcua_pki_1 = require("node-opcua-pki");
|
|
45
45
|
const node_opcua_server_configuration_1 = require("node-opcua-server-configuration");
|
|
46
46
|
const yargs_1 = __importDefault(require("yargs"));
|
|
47
|
+
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
47
48
|
const rootFolder = path.join(__dirname, "../../..");
|
|
48
49
|
const env_paths_1 = __importDefault(require("env-paths"));
|
|
49
50
|
const config = (0, env_paths_1.default)("node-opcua-default").config;
|
|
@@ -53,13 +54,18 @@ const certificateManager = new node_opcua_1.OPCUACertificateManager({
|
|
|
53
54
|
name: "PKI",
|
|
54
55
|
rootFolder: pkiFolder
|
|
55
56
|
});
|
|
57
|
+
const salt = bcrypt_1.default.genSaltSync(10);
|
|
56
58
|
const users = [
|
|
57
59
|
{
|
|
58
60
|
username: "user1",
|
|
59
|
-
password: "password1",
|
|
61
|
+
password: bcrypt_1.default.hashSync((() => "password1")(), salt),
|
|
60
62
|
role: (0, node_opcua_1.makeRoles)([node_opcua_1.WellKnownRoles.AuthenticatedUser, node_opcua_1.WellKnownRoles.ConfigureAdmin, node_opcua_1.WellKnownRoles.SecurityAdmin])
|
|
61
63
|
},
|
|
62
|
-
{
|
|
64
|
+
{
|
|
65
|
+
username: "user2",
|
|
66
|
+
password: bcrypt_1.default.hashSync((() => "password2")(), salt),
|
|
67
|
+
role: (0, node_opcua_1.makeRoles)([node_opcua_1.WellKnownRoles.AuthenticatedUser, node_opcua_1.WellKnownRoles.Operator])
|
|
68
|
+
}
|
|
63
69
|
];
|
|
64
70
|
const userManager = {
|
|
65
71
|
isValidUser(username, password) {
|
|
@@ -67,7 +73,7 @@ const userManager = {
|
|
|
67
73
|
if (uIndex < 0) {
|
|
68
74
|
return false;
|
|
69
75
|
}
|
|
70
|
-
if (users[uIndex].password
|
|
76
|
+
if (!bcrypt_1.default.compareSync(password, users[uIndex].password)) {
|
|
71
77
|
return false;
|
|
72
78
|
}
|
|
73
79
|
return true;
|
|
@@ -103,7 +109,7 @@ function main() {
|
|
|
103
109
|
});
|
|
104
110
|
yield applicationGroup.initialize();
|
|
105
111
|
const server = new node_opcua_1.OPCUAServer(serverOptions);
|
|
106
|
-
console.log(" Configuration
|
|
112
|
+
console.log(" Configuration root dir = ", server.serverCertificateManager.rootDir);
|
|
107
113
|
console.log(chalk_1.default.yellow(" server PID :"), process.pid);
|
|
108
114
|
yield server.initialize();
|
|
109
115
|
const addressSpace = server.engine.addressSpace;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server_with_push_certificate.js","sourceRoot":"","sources":["../bin/server_with_push_certificate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAA+B;AAC/B,4BAA4B;AAC5B,2CAA6B;AAC7B,kDAA0B;AAE1B,2CAA2H;AAC3H,mDAAoD;AACpD,qFAAmF;AACnF,kDAA0B;
|
|
1
|
+
{"version":3,"file":"server_with_push_certificate.js","sourceRoot":"","sources":["../bin/server_with_push_certificate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAA+B;AAC/B,4BAA4B;AAC5B,2CAA6B;AAC7B,kDAA0B;AAE1B,2CAA2H;AAC3H,mDAAoD;AACpD,qFAAmF;AACnF,kDAA0B;AAC1B,oDAA4B;AAE5B,MAAM,UAAU,G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,CAAC,eAAK,CAAC,MAAM,CAAC,yBAAyB,CAAC,EAAE,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAC9E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,wDAAwD,CAAC,CAAC,CAAC;QAEpF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAS,EAAE;YAC9B,gCAAgC;YAChC,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CAAA,CAAC,CAAC;IACP,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-samples",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.111.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module samples",
|
|
5
5
|
"bin": {
|
|
6
6
|
"simple_client": "./dist/simple_client_ts.js",
|
|
@@ -16,24 +16,26 @@
|
|
|
16
16
|
"clean": "npx rimraf certificates"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@types/
|
|
19
|
+
"@types/bcrypt": "^5.0.0",
|
|
20
|
+
"@types/underscore": "^1.11.9",
|
|
20
21
|
"@types/yargs": "17.0.24",
|
|
22
|
+
"bcrypt": "^5.1.1",
|
|
21
23
|
"chalk": "4.1.2",
|
|
22
24
|
"easy-table": "^1.2.0",
|
|
23
25
|
"env-paths": "2.2.1",
|
|
24
26
|
"exit": "^0.1.2",
|
|
25
|
-
"node-opcua": "2.
|
|
26
|
-
"node-opcua-address-space": "2.
|
|
27
|
-
"node-opcua-address-space-for-conformance-testing": "2.
|
|
27
|
+
"node-opcua": "2.111.0",
|
|
28
|
+
"node-opcua-address-space": "2.111.0",
|
|
29
|
+
"node-opcua-address-space-for-conformance-testing": "2.111.0",
|
|
28
30
|
"node-opcua-assert": "2.105.0",
|
|
29
|
-
"node-opcua-client-crawler": "2.
|
|
30
|
-
"node-opcua-client-proxy": "2.
|
|
31
|
-
"node-opcua-crypto": "4.
|
|
32
|
-
"node-opcua-packet-analyzer": "2.
|
|
33
|
-
"node-opcua-pki": "4.
|
|
34
|
-
"node-opcua-server-configuration": "2.
|
|
31
|
+
"node-opcua-client-crawler": "2.111.0",
|
|
32
|
+
"node-opcua-client-proxy": "2.111.0",
|
|
33
|
+
"node-opcua-crypto": "4.3.1",
|
|
34
|
+
"node-opcua-packet-analyzer": "2.111.0",
|
|
35
|
+
"node-opcua-pki": "4.5.0",
|
|
36
|
+
"node-opcua-server-configuration": "2.111.0",
|
|
35
37
|
"node-opcua-utils": "2.110.0",
|
|
36
|
-
"node-opcua-vendor-diagnostic": "2.
|
|
38
|
+
"node-opcua-vendor-diagnostic": "2.111.0",
|
|
37
39
|
"sprintf-js": "^1.1.2",
|
|
38
40
|
"treeify": "^1.1.0",
|
|
39
41
|
"underscore": "^1.13.6",
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
"internet of things"
|
|
55
57
|
],
|
|
56
58
|
"homepage": "http://node-opcua.github.io/",
|
|
57
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "94a810c732583bdb401e29a5ac92662c7895caeb",
|
|
58
60
|
"files": [
|
|
59
61
|
"dist"
|
|
60
62
|
]
|