node-opcua-samples 2.64.0 → 2.64.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.
- package/bin/di_server.js +0 -0
- package/bin/interactive_client.js +0 -0
- package/bin/simple_server.js +0 -0
- package/dist/get_endpoints.d.ts +2 -2
- package/dist/get_endpoints.js +141 -141
- package/dist/mini_server.d.ts +1 -1
- package/dist/mini_server.js +88 -88
- package/dist/server_with_push_certificate.d.ts +2 -2
- package/dist/server_with_push_certificate.js +82 -82
- package/dist/simple_client_ts.d.ts +2 -2
- package/dist/simple_client_ts.js +663 -663
- package/dist/simple_findservers.d.ts +2 -2
- package/dist/simple_findservers.js +48 -48
- package/dist/simple_secure_server.d.ts +2 -2
- package/dist/simple_secure_server.js +121 -121
- package/dist/simple_server_with_custom_extension_objects.d.ts +2 -2
- package/dist/simple_server_with_custom_extension_objects.js +81 -81
- package/dist/stressing_client.d.ts +1 -1
- package/dist/stressing_client.js +36 -36
- package/package.json +47 -47
|
@@ -1,83 +1,83 @@
|
|
|
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 chalk = require("chalk");
|
|
16
|
-
const node_opcua_1 = require("node-opcua");
|
|
17
|
-
const node_opcua_pki_1 = require("node-opcua-pki");
|
|
18
|
-
const node_opcua_server_configuration_1 = require("node-opcua-server-configuration");
|
|
19
|
-
const path = require("path");
|
|
20
|
-
const yargs = require("yargs");
|
|
21
|
-
const rootFolder = path.join(__dirname, "../../..");
|
|
22
|
-
const envPaths = require("env-paths");
|
|
23
|
-
const config = envPaths("node-opcua-default").config;
|
|
24
|
-
const pkiFolder = path.join(config, "PKI");
|
|
25
|
-
const certificateManager = new node_opcua_1.OPCUACertificateManager({
|
|
26
|
-
automaticallyAcceptUnknownCertificate: true,
|
|
27
|
-
name: "PKI",
|
|
28
|
-
rootFolder: pkiFolder
|
|
29
|
-
});
|
|
30
|
-
function main() {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const argv = yield yargs.wrap(132).option("port", {
|
|
33
|
-
alias: "p",
|
|
34
|
-
default: "26543",
|
|
35
|
-
describe: "port to listen"
|
|
36
|
-
}).argv;
|
|
37
|
-
const port = parseInt(argv.port, 10) || 26555;
|
|
38
|
-
const server_options = {
|
|
39
|
-
port,
|
|
40
|
-
nodeset_filename: [node_opcua_1.nodesets.standard],
|
|
41
|
-
serverCertificateManager: certificateManager
|
|
42
|
-
};
|
|
43
|
-
process.title = "Node OPCUA Server on port : " + server_options.port;
|
|
44
|
-
const tmpFolder = path.join(__dirname, "../certificates/myApp");
|
|
45
|
-
const applicationGroup = new node_opcua_pki_1.CertificateManager({
|
|
46
|
-
location: tmpFolder
|
|
47
|
-
});
|
|
48
|
-
yield applicationGroup.initialize();
|
|
49
|
-
const server = new node_opcua_1.OPCUAServer(server_options);
|
|
50
|
-
console.log(" Configuration rootdir = ", server.serverCertificateManager.rootDir);
|
|
51
|
-
console.log(chalk.yellow(" server PID :"), process.pid);
|
|
52
|
-
server.on("post_initialize", () => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const addressSpace = server.engine.addressSpace;
|
|
54
|
-
// to do: expose new nodeid here
|
|
55
|
-
const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
|
|
56
|
-
yield (0, node_opcua_server_configuration_1.installPushCertificateManagement)(addressSpace, {
|
|
57
|
-
applicationGroup: server.serverCertificateManager,
|
|
58
|
-
userTokenGroup: server.userCertificateManager,
|
|
59
|
-
applicationUri: server.serverInfo.applicationUri
|
|
60
|
-
});
|
|
61
|
-
console.log("Certificate rejected folder ", server.serverCertificateManager.rejectedFolder);
|
|
62
|
-
}));
|
|
63
|
-
try {
|
|
64
|
-
yield server.start();
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
console.log(" Server failed to start ... exiting");
|
|
68
|
-
process.exit(-3);
|
|
69
|
-
}
|
|
70
|
-
const endpointUrl = server.getEndpointUrl();
|
|
71
|
-
console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
|
|
72
|
-
console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
|
|
73
|
-
console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
|
|
74
|
-
process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
// only work on linux apparently
|
|
76
|
-
yield server.shutdown(1000);
|
|
77
|
-
console.log(chalk.red.bold(" shutting down completed "));
|
|
78
|
-
process.exit(-1);
|
|
79
|
-
}));
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
main();
|
|
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 chalk = require("chalk");
|
|
16
|
+
const node_opcua_1 = require("node-opcua");
|
|
17
|
+
const node_opcua_pki_1 = require("node-opcua-pki");
|
|
18
|
+
const node_opcua_server_configuration_1 = require("node-opcua-server-configuration");
|
|
19
|
+
const path = require("path");
|
|
20
|
+
const yargs = require("yargs");
|
|
21
|
+
const rootFolder = path.join(__dirname, "../../..");
|
|
22
|
+
const envPaths = require("env-paths");
|
|
23
|
+
const config = envPaths("node-opcua-default").config;
|
|
24
|
+
const pkiFolder = path.join(config, "PKI");
|
|
25
|
+
const certificateManager = new node_opcua_1.OPCUACertificateManager({
|
|
26
|
+
automaticallyAcceptUnknownCertificate: true,
|
|
27
|
+
name: "PKI",
|
|
28
|
+
rootFolder: pkiFolder
|
|
29
|
+
});
|
|
30
|
+
function main() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const argv = yield yargs.wrap(132).option("port", {
|
|
33
|
+
alias: "p",
|
|
34
|
+
default: "26543",
|
|
35
|
+
describe: "port to listen"
|
|
36
|
+
}).argv;
|
|
37
|
+
const port = parseInt(argv.port, 10) || 26555;
|
|
38
|
+
const server_options = {
|
|
39
|
+
port,
|
|
40
|
+
nodeset_filename: [node_opcua_1.nodesets.standard],
|
|
41
|
+
serverCertificateManager: certificateManager
|
|
42
|
+
};
|
|
43
|
+
process.title = "Node OPCUA Server on port : " + server_options.port;
|
|
44
|
+
const tmpFolder = path.join(__dirname, "../certificates/myApp");
|
|
45
|
+
const applicationGroup = new node_opcua_pki_1.CertificateManager({
|
|
46
|
+
location: tmpFolder
|
|
47
|
+
});
|
|
48
|
+
yield applicationGroup.initialize();
|
|
49
|
+
const server = new node_opcua_1.OPCUAServer(server_options);
|
|
50
|
+
console.log(" Configuration rootdir = ", server.serverCertificateManager.rootDir);
|
|
51
|
+
console.log(chalk.yellow(" server PID :"), process.pid);
|
|
52
|
+
server.on("post_initialize", () => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const addressSpace = server.engine.addressSpace;
|
|
54
|
+
// to do: expose new nodeid here
|
|
55
|
+
const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
|
|
56
|
+
yield (0, node_opcua_server_configuration_1.installPushCertificateManagement)(addressSpace, {
|
|
57
|
+
applicationGroup: server.serverCertificateManager,
|
|
58
|
+
userTokenGroup: server.userCertificateManager,
|
|
59
|
+
applicationUri: server.serverInfo.applicationUri
|
|
60
|
+
});
|
|
61
|
+
console.log("Certificate rejected folder ", server.serverCertificateManager.rejectedFolder);
|
|
62
|
+
}));
|
|
63
|
+
try {
|
|
64
|
+
yield server.start();
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.log(" Server failed to start ... exiting");
|
|
68
|
+
process.exit(-3);
|
|
69
|
+
}
|
|
70
|
+
const endpointUrl = server.getEndpointUrl();
|
|
71
|
+
console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
|
|
72
|
+
console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
|
|
73
|
+
console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
|
|
74
|
+
process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
// only work on linux apparently
|
|
76
|
+
yield server.shutdown(1000);
|
|
77
|
+
console.log(chalk.red.bold(" shutting down completed "));
|
|
78
|
+
process.exit(-1);
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
main();
|
|
83
83
|
//# sourceMappingURL=server_with_push_certificate.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
export {};
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
export {};
|