node-opcua-samples 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 (50) hide show
  1. package/dist/get_endpoints.d.ts +2 -0
  2. package/dist/get_endpoints.js +142 -0
  3. package/dist/get_endpoints.js.map +1 -0
  4. package/dist/mini_server.d.ts +1 -0
  5. package/dist/mini_server.js +89 -0
  6. package/dist/mini_server.js.map +1 -0
  7. package/dist/server_with_changing_password.d.ts +1 -0
  8. package/dist/server_with_changing_password.js +101 -0
  9. package/dist/server_with_changing_password.js.map +1 -0
  10. package/dist/server_with_push_certificate.d.ts +2 -0
  11. package/dist/server_with_push_certificate.js +112 -0
  12. package/dist/server_with_push_certificate.js.map +1 -0
  13. package/dist/simple_client_ts.d.ts +2 -0
  14. package/dist/simple_client_ts.js.map +1 -0
  15. package/dist/simple_findservers.d.ts +2 -0
  16. package/dist/simple_findservers.js +49 -0
  17. package/dist/simple_findservers.js.map +1 -0
  18. package/dist/simple_secure_server.d.ts +2 -0
  19. package/dist/simple_secure_server.js +126 -0
  20. package/dist/simple_secure_server.js.map +1 -0
  21. package/dist/simple_server_with_custom_extension_objects.d.ts +2 -0
  22. package/dist/simple_server_with_custom_extension_objects.js +82 -0
  23. package/dist/simple_server_with_custom_extension_objects.js.map +1 -0
  24. package/dist/stressing_client.d.ts +1 -0
  25. package/dist/stressing_client.js +37 -0
  26. package/dist/stressing_client.js.map +1 -0
  27. package/dist/tiny_client.d.ts +1 -0
  28. package/dist/tiny_client.js +33 -0
  29. package/dist/tiny_client.js.map +1 -0
  30. package/package.json +14 -11
  31. package/bin/createOPCUACertificate.cmd +0 -6
  32. package/bin/create_certificates.js +0 -2
  33. package/bin/crypto_create_CA.js +0 -2
  34. package/bin/demo_server_with_alarm.js +0 -51
  35. package/bin/findServersOnNetwork.js +0 -32
  36. package/bin/get_endpoints.ts +0 -166
  37. package/bin/machineryServer.js +0 -83
  38. package/bin/mini_server.ts +0 -106
  39. package/bin/more.js +0 -40
  40. package/bin/node-opcua.js +0 -2
  41. package/bin/opcua_interceptor.js +0 -122
  42. package/bin/server_with_changing_password.ts +0 -97
  43. package/bin/server_with_push_certificate.ts +0 -122
  44. package/bin/simple_client.js +0 -830
  45. package/bin/simple_client_ts.ts +0 -847
  46. package/bin/simple_findservers.ts +0 -45
  47. package/bin/simple_secure_server.ts +0 -152
  48. package/bin/simple_server_with_custom_extension_objects.ts +0 -89
  49. package/bin/stressing_client.ts +0 -28
  50. package/bin/tiny_client.ts +0 -24
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env ts-node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ /* eslint no-process-exit: 0 */
14
+ // tslint:disable:no-console
15
+ const path = require("path");
16
+ const os = require("os");
17
+ const chalk = require("chalk");
18
+ const yargs = require("yargs");
19
+ const node_opcua_1 = require("node-opcua");
20
+ Error.stackTraceLimit = Infinity;
21
+ function constructFilename(filename) {
22
+ return path.join(__dirname, "../", filename);
23
+ }
24
+ const userManager = {
25
+ isValidUser: (userName, password) => {
26
+ if (userName === "user1" && password === "password1") {
27
+ return true;
28
+ }
29
+ if (userName === "user2" && password === "password2") {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ };
35
+ function main() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const argv = yield yargs(process.argv)
38
+ .wrap(132)
39
+ .option("alternateHostname", {
40
+ alias: "a",
41
+ describe: "alternateHostname"
42
+ })
43
+ .option("port", {
44
+ alias: "p",
45
+ default: 26543
46
+ })
47
+ .option("silent", {
48
+ alias: "s",
49
+ default: false,
50
+ describe: "silent - no trace"
51
+ })
52
+ .option("maxSessions", {
53
+ alias: "m",
54
+ default: 10
55
+ })
56
+ .help(true).argv;
57
+ const port = argv.port || 26543;
58
+ // server_options.alternateHostname = argv.alternateHostname;
59
+ const server_options = {
60
+ securityPolicies: [node_opcua_1.SecurityPolicy.Basic128Rsa15, node_opcua_1.SecurityPolicy.Basic256],
61
+ securityModes: [node_opcua_1.MessageSecurityMode.Sign, node_opcua_1.MessageSecurityMode.SignAndEncrypt],
62
+ port,
63
+ nodeset_filename: [node_opcua_1.nodesets.standard, node_opcua_1.nodesets.di],
64
+ serverInfo: {
65
+ applicationName: { text: "NodeOPCUA", locale: "en" },
66
+ applicationUri: (0, node_opcua_1.makeApplicationUrn)(os.hostname(), "NodeOPCUA-SecureServer"),
67
+ productUri: "NodeOPCUA-SecureServer",
68
+ discoveryProfileUri: null,
69
+ discoveryUrls: [],
70
+ gatewayServerUri: null
71
+ },
72
+ buildInfo: {
73
+ buildDate: new Date(),
74
+ buildNumber: "1234"
75
+ },
76
+ serverCapabilities: {
77
+ maxSessions: argv.maxSessions
78
+ },
79
+ maxConnectionsPerEndpoint: argv.maxSessions,
80
+ userManager,
81
+ isAuditing: false
82
+ };
83
+ process.title = "Node OPCUA Server on port : " + server_options.port;
84
+ const server = new node_opcua_1.OPCUAServer(server_options);
85
+ server.on("post_initialize", () => {
86
+ /* empty */
87
+ });
88
+ console.log(chalk.yellow(" server PID :"), process.pid);
89
+ console.log(chalk.yellow(" silent :"), argv.silent);
90
+ yield server.start();
91
+ const endpointUrl = server.getEndpointUrl();
92
+ console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
93
+ console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
94
+ console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
95
+ if (argv.silent) {
96
+ console.log("silent");
97
+ console.log = (...args) => {
98
+ /* silent */
99
+ };
100
+ }
101
+ server.on("create_session", (session) => {
102
+ console.log(" SESSION CREATED");
103
+ console.log(chalk.cyan(" client application URI: "), session.clientDescription.applicationUri);
104
+ console.log(chalk.cyan(" client product URI: "), session.clientDescription.productUri);
105
+ console.log(chalk.cyan(" client application name: "), session.clientDescription.applicationName.toString());
106
+ console.log(chalk.cyan(" client application type: "), session.clientDescription.applicationType.toString());
107
+ console.log(chalk.cyan(" session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
108
+ console.log(chalk.cyan(" session timeout: "), session.sessionTimeout);
109
+ console.log(chalk.cyan(" session id: "), session.nodeId);
110
+ });
111
+ server.on("session_closed", (session, reason) => {
112
+ console.log(" SESSION CLOSED :", reason);
113
+ console.log(chalk.cyan(" session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
114
+ });
115
+ process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
116
+ // only work on linux apparently
117
+ console.error(chalk.red.bold(" Received server interruption from user "));
118
+ console.error(chalk.red.bold(" shutting down ..."));
119
+ yield server.shutdown(1000);
120
+ console.error(chalk.red.bold(" shot down ..."));
121
+ process.exit(1);
122
+ }));
123
+ });
124
+ }
125
+ main();
126
+ //# sourceMappingURL=simple_secure_server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple_secure_server.js","sourceRoot":"","sources":["../bin/simple_secure_server.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+BAA+B;AAC/B,4BAA4B;AAC5B,6BAA6B;AAC7B,yBAAyB;AAEzB,+BAA+B;AAC/B,+BAA+B;AAE/B,2CAQoB;AAEpB,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;AAEjC,SAAS,iBAAiB,CAAC,QAAgB;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACjD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, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ /* eslint no-process-exit: 0 */
14
+ // tslint:disable:no-console
15
+ const path = require("path");
16
+ const chalk = require("chalk");
17
+ const node_opcua_1 = require("node-opcua");
18
+ const yargs = require("yargs");
19
+ Error.stackTraceLimit = Infinity;
20
+ function constructFilename(filename) {
21
+ return path.join(__dirname, "../", filename);
22
+ }
23
+ const rootFolder = path.join(__dirname, "../../..");
24
+ function main() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const argv = yield yargs.wrap(132).option("port", {
27
+ alias: "p",
28
+ default: "26543",
29
+ describe: "port to listen"
30
+ }).argv;
31
+ const port = parseInt(argv.port, 10) || 26555;
32
+ const server_certificate_file = constructFilename("certificates/server_cert_2048.pem");
33
+ const server_certificate_privatekey_file = constructFilename("certificates/server_key_2048.pem");
34
+ const server_options = {
35
+ certificateFile: server_certificate_file,
36
+ privateKeyFile: server_certificate_privatekey_file,
37
+ port,
38
+ nodeset_filename: [node_opcua_1.nodesets.standard, path.join(rootFolder, "modeling/my_data_type.xml")]
39
+ };
40
+ process.title = "Node OPCUA Server on port : " + server_options.port;
41
+ const server = new node_opcua_1.OPCUAServer(server_options);
42
+ console.log(chalk.yellow(" server PID :"), process.pid);
43
+ server.on("post_initialize", () => {
44
+ const addressSpace = server.engine.addressSpace;
45
+ // to do: expose new nodeid here
46
+ const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
47
+ const myStructureType = addressSpace.findVariableType("MyStructureType", ns);
48
+ if (!myStructureType) {
49
+ console.log(" ns = ", ns, "cannot find MyStructureDataType ");
50
+ return;
51
+ }
52
+ const namespace = addressSpace.getOwnNamespace();
53
+ const someObject = namespace.addObject({
54
+ browseName: "SomeObject",
55
+ organizedBy: addressSpace.rootFolder.objects
56
+ });
57
+ myStructureType.instantiate({
58
+ browseName: "MyVar",
59
+ componentOf: someObject
60
+ });
61
+ });
62
+ try {
63
+ yield server.start();
64
+ }
65
+ catch (err) {
66
+ console.log(" Server failed to start ... exiting");
67
+ process.exit(-3);
68
+ }
69
+ const endpointUrl = server.getEndpointUrl();
70
+ console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
71
+ console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
72
+ console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
73
+ process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
74
+ // only work on linux apparently
75
+ yield server.shutdown(1000);
76
+ console.log(chalk.red.bold(" shutting down completed "));
77
+ process.exit(-1);
78
+ }));
79
+ });
80
+ }
81
+ main();
82
+ //# sourceMappingURL=simple_server_with_custom_extension_objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple_server_with_custom_extension_objects.js","sourceRoot":"","sources":["../bin/simple_server_with_custom_extension_objects.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+BAA+B;AAC/B,4BAA4B;AAC5B,6BAA6B;AAC7B,+BAA+B;AAC/B,2CAAmD;AACnD,+BAA+B;AAG/B,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;AAGjC,SAAS,iBAAiB,CAAC,QAAgB;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAEpD,SAAe,IAAI;;QAEf,MAAM,IAAI,G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CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CAAA,CAAC,CAAC;IACP,CAAC;CAAA;AACD,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
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
+ // tslint:disable:no-console
13
+ const node_opcua_1 = require("node-opcua");
14
+ const endpointUrl = "opc.tcp://localhost:26543";
15
+ function main() {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ let counter = 1;
18
+ while (true) {
19
+ const client = node_opcua_1.OPCUAClient.create({ endpointMustExist: false });
20
+ client.on("backoff", (retryCount, delay) => console.log(" backoff", retryCount, delay));
21
+ try {
22
+ yield client.connect(endpointUrl);
23
+ const session = yield client.createSession();
24
+ yield session.close();
25
+ yield client.disconnect();
26
+ }
27
+ catch (err) {
28
+ if (err instanceof Error) {
29
+ console.log("err", err.message);
30
+ }
31
+ }
32
+ console.log(" Connected = ", counter++);
33
+ }
34
+ });
35
+ }
36
+ main();
37
+ //# sourceMappingURL=stressing_client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stressing_client.js","sourceRoot":"","sources":["../bin/stressing_client.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAA4B;AAC5B,2CAAyC;AAEzC,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAEhD,SAAe,IAAI;;QACf,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,OAAO,IAAI,EAAE;YACT,MAAM,MAAM,GAAG,wBAAW,CAAC,MAAM,CAAC,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;YAChE,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,UAAkB,EAAE,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;YAE3G,IAAI;gBACA,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAClC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;gBAC7C,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtB,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;aAC7B;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,GAAG,YAAY,KAAK,EAAE;oBACtB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;iBACnC;aACJ;YAED,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC;SAC3C;IACL,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
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
+ process.env.NODEOPCUADEBUG = "CLIENT{TRACE};TRANSPORT{CHUNK-HELACK}";
13
+ const node_opcua_1 = require("node-opcua");
14
+ (() => __awaiter(void 0, void 0, void 0, function* () {
15
+ const client = node_opcua_1.OPCUAClient.create({
16
+ requestedSessionTimeout: 1000,
17
+ transportSettings: {
18
+ maxChunkCount: 1,
19
+ maxMessageSize: 1 * 8192,
20
+ receiveBufferSize: 8 * 1024,
21
+ sendBufferSize: 8 * 1024
22
+ },
23
+ connectionStrategy: {
24
+ initialDelay: 10,
25
+ maxDelay: 100,
26
+ maxRetry: 2
27
+ }
28
+ });
29
+ yield client.connect("opc.tcp://localhost:48010");
30
+ // await client.connect("opc.tcp://localhost:53530");
31
+ yield client.disconnect();
32
+ }))();
33
+ //# sourceMappingURL=tiny_client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiny_client.js","sourceRoot":"","sources":["../bin/tiny_client.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,uCAAuC,CAAC;AACrE,2CAAyC;AAEzC,CAAC,GAAS,EAAE;IACR,MAAM,MAAM,GAAG,wBAAW,CAAC,MAAM,CAAC;QAC9B,uBAAuB,EAAE,IAAI;QAC7B,iBAAiB,EAAE;YACf,aAAa,EAAE,CAAC;YAChB,cAAc,EAAE,CAAC,GAAG,IAAI;YACxB,iBAAiB,EAAE,CAAC,GAAG,IAAI;YAC3B,cAAc,EAAE,CAAC,GAAG,IAAI;SAC3B;QACD,kBAAkB,EAAE;YAChB,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,GAAG;YACb,QAAQ,EAAE,CAAC;SACd;KACJ,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAClD,qDAAqD;IAErD,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;AAC9B,CAAC,CAAA,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-opcua-samples",
3
- "version": "2.98.0",
4
- "description": "pure nodejs OPCUA SDK - module -samples",
3
+ "version": "2.98.1",
4
+ "description": "pure nodejs OPCUA SDK - module samples",
5
5
  "bin": {
6
6
  "simple_client": "./dist/simple_client_ts.js",
7
7
  "interactive_client": "./bin/interactive_client.js",
@@ -22,16 +22,16 @@
22
22
  "easy-table": "^1.2.0",
23
23
  "env-paths": "2.2.1",
24
24
  "exit": "^0.1.2",
25
- "node-opcua": "2.98.0",
26
- "node-opcua-address-space": "2.98.0",
27
- "node-opcua-address-space-for-conformance-testing": "2.98.0",
28
- "node-opcua-assert": "2.88.0",
29
- "node-opcua-client-crawler": "2.98.0",
25
+ "node-opcua": "2.98.1",
26
+ "node-opcua-address-space": "2.98.1",
27
+ "node-opcua-address-space-for-conformance-testing": "2.98.1",
28
+ "node-opcua-assert": "2.98.1",
29
+ "node-opcua-client-crawler": "2.98.1",
30
30
  "node-opcua-crypto": "^2.1.2",
31
31
  "node-opcua-pki": "^3.0.2",
32
- "node-opcua-server-configuration": "2.98.0",
33
- "node-opcua-utils": "2.98.0",
34
- "node-opcua-vendor-diagnostic": "2.98.0",
32
+ "node-opcua-server-configuration": "2.98.1",
33
+ "node-opcua-utils": "2.98.1",
34
+ "node-opcua-vendor-diagnostic": "2.98.1",
35
35
  "sprintf-js": "^1.1.2",
36
36
  "treeify": "^1.1.0",
37
37
  "underscore": "^1.13.6",
@@ -52,5 +52,8 @@
52
52
  "internet of things"
53
53
  ],
54
54
  "homepage": "http://node-opcua.github.io/",
55
- "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c"
55
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
56
+ "files": [
57
+ "dist"
58
+ ]
56
59
  }
@@ -1,6 +0,0 @@
1
-
2
- SET BASE=%~dp0%
3
- echo applicationUri %1
4
- echo output %2
5
-
6
- node %BASE%\crypto_create_CA.js certificate --selfSigned --applicationUri %1 -o %2
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require("node-opcua-pki/bin/crypto_create_CA");
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require("node-opcua-pki/bin/crypto_create_CA");
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- const path = require("path");
4
- const { OPCUAServer, nodesets } = require("node-opcua");
5
- const { construct_demo_alarm_in_address_space } = require("node-opcua-address-space/testHelpers");
6
-
7
-
8
- const nodeset_filenames = [nodesets.standard];
9
-
10
- const port = 4334;
11
-
12
- const server = new OPCUAServer({
13
- port, // the port of the listening socket of the server
14
- resourcePath: "/UA/MyLittleServer", // this path will be added to the endpoint resource name
15
- buildInfo: {
16
- productName: "urn:DemoAlarmServer",
17
- buildNumber: "1",
18
- buildDate: new Date(2016, 9, 27)
19
- },
20
- nodeset_filename: nodeset_filenames
21
- });
22
-
23
- function post_initialize() {
24
- function construct_my_address_space(server) {
25
- const addressSpace = server.engine.addressSpace;
26
-
27
- const data = {};
28
- construct_demo_alarm_in_address_space(data, addressSpace);
29
-
30
- let time = 1;
31
- function simulate_variation() {
32
- const value = (1.0 + Math.sin((time / 360) * 3)) / 2.0;
33
- data.tankLevel.setValueFromSource({ dataType: "Double", value: value });
34
-
35
- data.tankLevel2.setValueFromSource({ dataType: "Double", value: value });
36
-
37
- time += 1;
38
- }
39
- setInterval(simulate_variation, 200);
40
- simulate_variation();
41
- }
42
- construct_my_address_space(server);
43
-
44
- server.start(function () {
45
- console.log("Server is now listening ... ( press CTRL+C to stop)");
46
- console.log("port ", server.endpoints[0].port);
47
- const endpointUrl = server.getEndpointUrl();
48
- console.log(" the primary server endpoint url is ", endpointUrl);
49
- });
50
- }
51
- server.initialize(post_initialize);
@@ -1,32 +0,0 @@
1
- const opcua = require("node-opcua");
2
-
3
-
4
- const yargs = require("yargs/yargs");
5
-
6
- const argv = yargs(process.argv)
7
- .wrap(132)
8
- .string("capabilities")
9
- .default("capabilities","DA")
10
- .alias("c","capabilities")
11
-
12
- .string("discoveryServerURI")
13
- .default("discoveryServerURI","opc.tcp://localhost:4840")
14
- .alias("d","discoveryServerURI")
15
-
16
- .help(true)
17
- .argv;
18
-
19
- const capabilities = argv.capabilities || "LDS";
20
-
21
- const discovery_server_endpointUrl = argv.discoveryServerURI || "opc.tcp://localhost:4840";
22
-
23
- opcua.findServersOnNetwork(discovery_server_endpointUrl, function (err, servers) {
24
- if(err) {
25
- console.log("Error : ", err.message);
26
- return;
27
- }
28
-
29
- for (const s of servers) {
30
- console.log(s.toString());
31
- }
32
- });
@@ -1,166 +0,0 @@
1
- #!/usr/bin/env ts-node
2
- // tslint:disable:no-console
3
- import * as chalk from "chalk";
4
- import * as fs from "fs";
5
- import * as path from "path";
6
- import * as yargs from "yargs";
7
-
8
- import {
9
- ApplicationType,
10
- coerceMessageSecurityMode,
11
- coerceSecurityPolicy,
12
- MessageSecurityMode,
13
- OPCUAClient,
14
- OPCUAClientOptions,
15
- SecurityPolicy,
16
- UserTokenType
17
- } from "node-opcua";
18
- import { Certificate, toPem } from "node-opcua-crypto";
19
-
20
- // tslint:disable:no-var-requires
21
- const Table = require("easy-table");
22
- const treeify = require("treeify");
23
-
24
- // eslint-disable-next-line max-statements
25
- async function main() {
26
- // ts-node bin/simple_client.ts --endpoint opc.tcp://localhost:53530/OPCUA/SimulationServer --node "ns=5;s=Sinusoid1"
27
- const argv = await yargs(process.argv)
28
- .wrap(132)
29
-
30
- .option("endpoint", {
31
- alias: "e",
32
- demandOption: true,
33
- describe: "the end point to connect to "
34
- })
35
- .option("securityMode", {
36
- alias: "s",
37
- default: "None",
38
- describe: "the security mode ( None Sign SignAndEncrypt )"
39
- })
40
- .option("securityPolicy", {
41
- alias: "P",
42
- default: "None",
43
- describe: "the policy mode : (" + Object.keys(SecurityPolicy).join(" - ") + ")"
44
- })
45
- .option("discovery", {
46
- alias: "D",
47
- describe: "specify the endpoint uri of discovery server (by default same as server endpoint uri)"
48
- })
49
- .example("get_endpoints --endpoint opc.tcp://localhost:49230", "").argv;
50
-
51
- const securityMode = coerceMessageSecurityMode(argv.securityMode!);
52
- if (securityMode === MessageSecurityMode.Invalid) {
53
- throw new Error("Invalid Security mode");
54
- }
55
-
56
- const securityPolicy = coerceSecurityPolicy(argv.securityPolicy!);
57
- if (securityPolicy === SecurityPolicy.Invalid) {
58
- throw new Error("Invalid securityPolicy");
59
- }
60
-
61
- console.log(chalk.cyan("securityMode = "), securityMode.toString());
62
- console.log(chalk.cyan("securityPolicy = "), securityPolicy.toString());
63
-
64
- const endpointUrl = argv.endpoint as string;
65
-
66
- if (!endpointUrl) {
67
- yargs.showHelp();
68
- process.exit(0);
69
- }
70
- const discoveryUrl = argv.discovery ? (argv.discovery as string) : endpointUrl;
71
- const optionsInitial: OPCUAClientOptions = {
72
- securityMode,
73
- securityPolicy,
74
-
75
- endpointMustExist: false,
76
-
77
- connectionStrategy: {
78
- initialDelay: 2000,
79
- maxDelay: 10 * 1000,
80
- maxRetry: 10
81
- },
82
-
83
- discoveryUrl
84
- };
85
-
86
- const client = OPCUAClient.create(optionsInitial);
87
-
88
- client.on("backoff", (retry: number, delay: number) => {
89
- console.log(chalk.bgWhite.yellow("backoff attempt #"), retry, " retrying in ", delay / 1000.0, " seconds");
90
- });
91
-
92
- console.log(" connecting to ", chalk.cyan.bold(endpointUrl));
93
- console.log(" strategy", client.connectionStrategy);
94
-
95
- try {
96
- await client.connect(endpointUrl);
97
- } catch (err) {
98
- console.log(chalk.red(" Cannot connect to ") + endpointUrl);
99
- if (err instanceof Error) {
100
- console.log(" Error = ", err.message);
101
- }
102
- return;
103
- }
104
-
105
- const endpoints = await client.getEndpoints();
106
-
107
- if (argv.debug) {
108
- fs.writeFileSync("tmp/endpoints.log", JSON.stringify(endpoints, null, " "));
109
- console.log(treeify.asTree(endpoints, true));
110
- }
111
-
112
- const table = new Table();
113
-
114
- let serverCertificate: Certificate | undefined;
115
-
116
- let i = 0;
117
- for (const endpoint of endpoints) {
118
- table.cell("endpoint", endpoint.endpointUrl + "");
119
- table.cell("Application URI", endpoint.server.applicationUri);
120
- table.cell("Product URI", endpoint.server.productUri);
121
- table.cell("Application Name", endpoint.server.applicationName.text);
122
- table.cell("securityLevel", endpoint.securityLevel);
123
- table.cell("Security Mode", chalk.cyan(MessageSecurityMode[endpoint.securityMode].toString()));
124
- table.cell("securityPolicyUri", chalk.cyan(endpoint.securityPolicyUri));
125
- table.cell("Type", ApplicationType[endpoint.server.applicationType]);
126
- table.cell("certificate", "..." /*endpoint.serverCertificate*/);
127
- endpoint.server.discoveryUrls = endpoint.server.discoveryUrls || [];
128
- table.cell("discoveryUrls", endpoint.server.discoveryUrls.join(" - "));
129
-
130
- serverCertificate = endpoint.serverCertificate;
131
-
132
- const certificate_filename = path.join(__dirname, "../certificates/PKI/server_certificate" + i + ".pem");
133
-
134
- if (serverCertificate) {
135
- fs.writeFile(certificate_filename, toPem(serverCertificate, "CERTIFICATE"), () => {
136
- /**/
137
- });
138
- }
139
- table.newRow();
140
- i++;
141
- }
142
- console.log(table.toString());
143
-
144
- for (const endpoint of endpoints) {
145
- console.log(
146
- "Identify Token for : Security Mode=",
147
- chalk.cyan(MessageSecurityMode[endpoint.securityMode].toString()),
148
- " Policy=",
149
- chalk.cyan(endpoint.securityPolicyUri)
150
- );
151
- const table2 = new Table();
152
- for (const token of endpoint.userIdentityTokens!) {
153
- table2.cell("policyId", token.policyId);
154
- table2.cell("tokenType", UserTokenType[token.tokenType]);
155
- table2.cell("issuedTokenType", token.issuedTokenType);
156
- table2.cell("issuerEndpointUrl", token.issuerEndpointUrl);
157
- table2.cell("securityPolicyUri", token.securityPolicyUri);
158
- table2.newRow();
159
- }
160
- console.log(table2.toString());
161
- }
162
- await client.disconnect();
163
- console.log("success !! ");
164
- process.exit(0);
165
- }
166
- main();