node-opcua-samples 2.180.0 → 2.181.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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// A server whose private key is OPAQUE: held by a key-operations provider
|
|
7
|
+
// (stand-in for an HSM / cloud KMS / TPM), never readable by node-opcua.
|
|
8
|
+
//
|
|
9
|
+
// ts-node simple_server_with_hsm_style_key.ts
|
|
10
|
+
//
|
|
11
|
+
// The provider below wraps an in-memory key so the sample is self-contained;
|
|
12
|
+
// a real deployment implements the same four methods against its KMS SDK.
|
|
13
|
+
// See documentation/using_hsm_kms_keys.md for the full guide.
|
|
14
|
+
const node_crypto_1 = require("node:crypto");
|
|
15
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
const node_opcua_1 = require("node-opcua");
|
|
18
|
+
const node_opcua_crypto_1 = require("node-opcua-crypto");
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// the "KMS": asynchronous-only, the key never leaves it
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
function makeKmsStyleKeyOperations() {
|
|
23
|
+
const { privateKey } = (0, node_crypto_1.generateKeyPairSync)("rsa", { modulusLength: 2048 });
|
|
24
|
+
const vault = (0, node_opcua_crypto_1.keyOperationsFromPrivateKey)({ hidden: privateKey.export({ type: "pkcs8", format: "pem" }).toString() });
|
|
25
|
+
return {
|
|
26
|
+
// a real implementation calls its KMS here — note: NO *Sync methods,
|
|
27
|
+
// node-opcua drives everything through the asynchronous interface
|
|
28
|
+
sign: (data, params) => vault.sign(data, params),
|
|
29
|
+
decryptBlock: (block, params) => vault.decryptBlock(block, params),
|
|
30
|
+
getKeyMetadata: () => vault.getKeyMetadata(),
|
|
31
|
+
getPublicKey: () => vault.getPublicKey()
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
(async () => {
|
|
35
|
+
const keyOperations = makeKmsStyleKeyOperations();
|
|
36
|
+
const serverCertificateManager = new node_opcua_1.OPCUACertificateManager({
|
|
37
|
+
rootFolder: node_path_1.default.join(node_os_1.default.tmpdir(), "opaque-sample-pki"),
|
|
38
|
+
keyOperations,
|
|
39
|
+
automaticallyAcceptUnknownCertificate: true
|
|
40
|
+
});
|
|
41
|
+
await serverCertificateManager.initialize();
|
|
42
|
+
// bootstrap the certificate over the vault-held key (idempotent enough for a sample)
|
|
43
|
+
const certificateFile = node_path_1.default.join(serverCertificateManager.rootDir, "own/certs/self_signed_certificate.pem");
|
|
44
|
+
await serverCertificateManager.createSelfSignedCertificate({
|
|
45
|
+
applicationUri: "urn:sample:opaque-key-server",
|
|
46
|
+
subject: "/CN=OpaqueKeySampleServer",
|
|
47
|
+
dns: [node_os_1.default.hostname()],
|
|
48
|
+
startDate: new Date(),
|
|
49
|
+
validity: 365
|
|
50
|
+
});
|
|
51
|
+
const server = new node_opcua_1.OPCUAServer({
|
|
52
|
+
port: 26545,
|
|
53
|
+
serverInfo: { applicationUri: "urn:sample:opaque-key-server" },
|
|
54
|
+
serverCertificateManager,
|
|
55
|
+
certificateFile,
|
|
56
|
+
privateKeyFile: serverCertificateManager.privateKey, // path is unused: the key is in the vault
|
|
57
|
+
securityModes: [node_opcua_1.MessageSecurityMode.None, node_opcua_1.MessageSecurityMode.SignAndEncrypt]
|
|
58
|
+
});
|
|
59
|
+
await server.start();
|
|
60
|
+
console.log("server started at", server.getEndpointUrl());
|
|
61
|
+
console.log("the private key lives in the provider: server.getPrivateKey() would throw PrivateKeyUnavailableError");
|
|
62
|
+
process.once("SIGINT", async () => {
|
|
63
|
+
await server.shutdown(1000);
|
|
64
|
+
process.exit(0);
|
|
65
|
+
});
|
|
66
|
+
})();
|
|
67
|
+
//# sourceMappingURL=simple_server_with_hsm_style_key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple_server_with_hsm_style_key.js","sourceRoot":"","sources":["../bin/simple_server_with_hsm_style_key.ts"],"names":[],"mappings":";;;;;AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,8DAA8D;AAC9D,6CAAkD;AAClD,sDAAyB;AACzB,0DAA6B;AAC7B,2CAAuF;AACvF,yDAAqF;AAErF,8EAA8E;AAC9E,wDAAwD;AACxD,8EAA8E;AAC9E,SAAS,yBAAyB;IAC9B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iCAAmB,EAAC,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,MAAM,KAAK,GAAG,IAAA,+CAA2B,EAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACtH,OAAO;QACH,qEAAqE;QACrE,kEAAkE;QAClE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;QAChD,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC;QAClE,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE;QAC5C,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE;KAC3C,CAAC;AACN,CAAC;AAED,CAAC,KAAK,IAAI,EAAE;IACR,MAA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,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-samples",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.181.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module samples",
|
|
5
5
|
"bin": {
|
|
6
6
|
"simple_client": "./dist/simple_client_ts.js",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"chalk": "4.1.2",
|
|
23
23
|
"easy-table": "^1.2.0",
|
|
24
24
|
"env-paths": "2.2.1",
|
|
25
|
-
"node-opcua": "2.
|
|
26
|
-
"node-opcua-address-space": "2.
|
|
27
|
-
"node-opcua-address-space-for-conformance-testing": "2.
|
|
25
|
+
"node-opcua": "2.181.0",
|
|
26
|
+
"node-opcua-address-space": "2.181.0",
|
|
27
|
+
"node-opcua-address-space-for-conformance-testing": "2.181.0",
|
|
28
28
|
"node-opcua-assert": "2.179.0",
|
|
29
|
-
"node-opcua-client-proxy": "2.
|
|
30
|
-
"node-opcua-crypto": "5.
|
|
31
|
-
"node-opcua-packet-analyzer": "2.
|
|
32
|
-
"node-opcua-pki": "6.
|
|
33
|
-
"node-opcua-server-configuration": "2.
|
|
34
|
-
"node-opcua-utils": "2.
|
|
35
|
-
"node-opcua-vendor-diagnostic": "2.
|
|
29
|
+
"node-opcua-client-proxy": "2.181.0",
|
|
30
|
+
"node-opcua-crypto": "5.10.1",
|
|
31
|
+
"node-opcua-packet-analyzer": "2.181.0",
|
|
32
|
+
"node-opcua-pki": "6.22.0",
|
|
33
|
+
"node-opcua-server-configuration": "2.181.0",
|
|
34
|
+
"node-opcua-utils": "2.181.0",
|
|
35
|
+
"node-opcua-vendor-diagnostic": "2.181.0",
|
|
36
36
|
"sprintf-js": "^1.1.3",
|
|
37
37
|
"treeify": "^1.1.0",
|
|
38
38
|
"yargs": "15.4.1"
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"internet of things"
|
|
53
53
|
],
|
|
54
54
|
"homepage": "http://node-opcua.github.io/",
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "f8f472c59e681b2aa18ae1533c3d1e5f17614c5c",
|
|
56
56
|
"files": [
|
|
57
57
|
"dist"
|
|
58
58
|
]
|