node-opcua-common 2.70.3 → 2.71.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/dist/applicationurn.d.ts +1 -1
- package/dist/applicationurn.js +25 -25
- package/dist/index.d.ts +12 -12
- package/dist/index.js +38 -38
- package/dist/opcua_secure_object.d.ts +34 -34
- package/dist/opcua_secure_object.js +63 -63
- package/package.json +11 -11
package/dist/applicationurn.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function makeApplicationUrn(hostname: string, suffix: string): string;
|
|
1
|
+
export declare function makeApplicationUrn(hostname: string, suffix: string): string;
|
package/dist/applicationurn.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeApplicationUrn = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opcua-common
|
|
6
|
-
*/
|
|
7
|
-
const crypto = require("crypto");
|
|
8
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
-
function makeApplicationUrn(hostname, suffix) {
|
|
10
|
-
(0, node_opcua_assert_1.assert)(!suffix.match(/urn:/), "already a application URN ?");
|
|
11
|
-
// beware : Openssl doesn't support urn with length greater than 64 !!
|
|
12
|
-
// sometimes hostname length could be too long ...
|
|
13
|
-
// application urn length must not exceed 64 car. to comply with openssl
|
|
14
|
-
// see cryptoCA
|
|
15
|
-
let hostnameHash = hostname;
|
|
16
|
-
if (hostnameHash.length + 7 + suffix.length >= 64) {
|
|
17
|
-
// we need to reduce the applicationUrn side => let's take
|
|
18
|
-
// a portion of the hostname hash.
|
|
19
|
-
hostnameHash = crypto.createHash("md5").update(hostname).digest("hex").substring(0, 16);
|
|
20
|
-
}
|
|
21
|
-
const applicationUrn = "urn:" + hostnameHash + ":" + suffix;
|
|
22
|
-
(0, node_opcua_assert_1.assert)(applicationUrn.length <= 64);
|
|
23
|
-
return applicationUrn;
|
|
24
|
-
}
|
|
25
|
-
exports.makeApplicationUrn = makeApplicationUrn;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeApplicationUrn = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-common
|
|
6
|
+
*/
|
|
7
|
+
const crypto = require("crypto");
|
|
8
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
+
function makeApplicationUrn(hostname, suffix) {
|
|
10
|
+
(0, node_opcua_assert_1.assert)(!suffix.match(/urn:/), "already a application URN ?");
|
|
11
|
+
// beware : Openssl doesn't support urn with length greater than 64 !!
|
|
12
|
+
// sometimes hostname length could be too long ...
|
|
13
|
+
// application urn length must not exceed 64 car. to comply with openssl
|
|
14
|
+
// see cryptoCA
|
|
15
|
+
let hostnameHash = hostname;
|
|
16
|
+
if (hostnameHash.length + 7 + suffix.length >= 64) {
|
|
17
|
+
// we need to reduce the applicationUrn side => let's take
|
|
18
|
+
// a portion of the hostname hash.
|
|
19
|
+
hostnameHash = crypto.createHash("md5").update(hostname).digest("hex").substring(0, 16);
|
|
20
|
+
}
|
|
21
|
+
const applicationUrn = "urn:" + hostnameHash + ":" + suffix;
|
|
22
|
+
(0, node_opcua_assert_1.assert)(applicationUrn.length <= 64);
|
|
23
|
+
return applicationUrn;
|
|
24
|
+
}
|
|
25
|
+
exports.makeApplicationUrn = makeApplicationUrn;
|
|
26
26
|
//# sourceMappingURL=applicationurn.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opcua-common
|
|
3
|
-
*/
|
|
4
|
-
export { ServerState, ServerStatusDataType, // ServerStatus
|
|
5
|
-
RedundantServerDataType, // RedundantServer
|
|
6
|
-
ModelChangeStructureDataType, // ModelChangeStructure
|
|
7
|
-
SubscriptionDiagnosticsDataType, // SubscriptionDiagnostics
|
|
8
|
-
SamplingIntervalDiagnosticsDataType, // SamplingIntervalDiagnostics
|
|
9
|
-
SemanticChangeStructureDataType, // SemanticChangeStructure
|
|
10
|
-
ServerDiagnosticsSummaryDataType, SessionSecurityDiagnosticsDataType, ServiceCounterDataType, SessionDiagnosticsDataType, BuildInfo, DataTypeDefinition, EnumValueType, TimeZoneDataType, } from "node-opcua-types";
|
|
11
|
-
export * from "./applicationurn";
|
|
12
|
-
export * from "./opcua_secure_object";
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-common
|
|
3
|
+
*/
|
|
4
|
+
export { ServerState, ServerStatusDataType, // ServerStatus
|
|
5
|
+
RedundantServerDataType, // RedundantServer
|
|
6
|
+
ModelChangeStructureDataType, // ModelChangeStructure
|
|
7
|
+
SubscriptionDiagnosticsDataType, // SubscriptionDiagnostics
|
|
8
|
+
SamplingIntervalDiagnosticsDataType, // SamplingIntervalDiagnostics
|
|
9
|
+
SemanticChangeStructureDataType, // SemanticChangeStructure
|
|
10
|
+
ServerDiagnosticsSummaryDataType, SessionSecurityDiagnosticsDataType, ServiceCounterDataType, SessionDiagnosticsDataType, BuildInfo, DataTypeDefinition, EnumValueType, TimeZoneDataType, } from "node-opcua-types";
|
|
11
|
+
export * from "./applicationurn";
|
|
12
|
+
export * from "./opcua_secure_object";
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.TimeZoneDataType = exports.EnumValueType = exports.DataTypeDefinition = exports.BuildInfo = exports.SessionDiagnosticsDataType = exports.ServiceCounterDataType = exports.SessionSecurityDiagnosticsDataType = exports.ServerDiagnosticsSummaryDataType = exports.SemanticChangeStructureDataType = exports.SamplingIntervalDiagnosticsDataType = exports.SubscriptionDiagnosticsDataType = exports.ModelChangeStructureDataType = exports.RedundantServerDataType = exports.ServerStatusDataType = exports.ServerState = void 0;
|
|
18
|
-
/**
|
|
19
|
-
* @module node-opcua-common
|
|
20
|
-
*/
|
|
21
|
-
var node_opcua_types_1 = require("node-opcua-types");
|
|
22
|
-
Object.defineProperty(exports, "ServerState", { enumerable: true, get: function () { return node_opcua_types_1.ServerState; } });
|
|
23
|
-
Object.defineProperty(exports, "ServerStatusDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerStatusDataType; } });
|
|
24
|
-
Object.defineProperty(exports, "RedundantServerDataType", { enumerable: true, get: function () { return node_opcua_types_1.RedundantServerDataType; } });
|
|
25
|
-
Object.defineProperty(exports, "ModelChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.ModelChangeStructureDataType; } });
|
|
26
|
-
Object.defineProperty(exports, "SubscriptionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SubscriptionDiagnosticsDataType; } });
|
|
27
|
-
Object.defineProperty(exports, "SamplingIntervalDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SamplingIntervalDiagnosticsDataType; } });
|
|
28
|
-
Object.defineProperty(exports, "SemanticChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.SemanticChangeStructureDataType; } });
|
|
29
|
-
Object.defineProperty(exports, "ServerDiagnosticsSummaryDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerDiagnosticsSummaryDataType; } });
|
|
30
|
-
Object.defineProperty(exports, "SessionSecurityDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionSecurityDiagnosticsDataType; } });
|
|
31
|
-
Object.defineProperty(exports, "ServiceCounterDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServiceCounterDataType; } });
|
|
32
|
-
Object.defineProperty(exports, "SessionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionDiagnosticsDataType; } });
|
|
33
|
-
Object.defineProperty(exports, "BuildInfo", { enumerable: true, get: function () { return node_opcua_types_1.BuildInfo; } });
|
|
34
|
-
Object.defineProperty(exports, "DataTypeDefinition", { enumerable: true, get: function () { return node_opcua_types_1.DataTypeDefinition; } });
|
|
35
|
-
Object.defineProperty(exports, "EnumValueType", { enumerable: true, get: function () { return node_opcua_types_1.EnumValueType; } });
|
|
36
|
-
Object.defineProperty(exports, "TimeZoneDataType", { enumerable: true, get: function () { return node_opcua_types_1.TimeZoneDataType; } });
|
|
37
|
-
__exportStar(require("./applicationurn"), exports);
|
|
38
|
-
__exportStar(require("./opcua_secure_object"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TimeZoneDataType = exports.EnumValueType = exports.DataTypeDefinition = exports.BuildInfo = exports.SessionDiagnosticsDataType = exports.ServiceCounterDataType = exports.SessionSecurityDiagnosticsDataType = exports.ServerDiagnosticsSummaryDataType = exports.SemanticChangeStructureDataType = exports.SamplingIntervalDiagnosticsDataType = exports.SubscriptionDiagnosticsDataType = exports.ModelChangeStructureDataType = exports.RedundantServerDataType = exports.ServerStatusDataType = exports.ServerState = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* @module node-opcua-common
|
|
20
|
+
*/
|
|
21
|
+
var node_opcua_types_1 = require("node-opcua-types");
|
|
22
|
+
Object.defineProperty(exports, "ServerState", { enumerable: true, get: function () { return node_opcua_types_1.ServerState; } });
|
|
23
|
+
Object.defineProperty(exports, "ServerStatusDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerStatusDataType; } });
|
|
24
|
+
Object.defineProperty(exports, "RedundantServerDataType", { enumerable: true, get: function () { return node_opcua_types_1.RedundantServerDataType; } });
|
|
25
|
+
Object.defineProperty(exports, "ModelChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.ModelChangeStructureDataType; } });
|
|
26
|
+
Object.defineProperty(exports, "SubscriptionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SubscriptionDiagnosticsDataType; } });
|
|
27
|
+
Object.defineProperty(exports, "SamplingIntervalDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SamplingIntervalDiagnosticsDataType; } });
|
|
28
|
+
Object.defineProperty(exports, "SemanticChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.SemanticChangeStructureDataType; } });
|
|
29
|
+
Object.defineProperty(exports, "ServerDiagnosticsSummaryDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerDiagnosticsSummaryDataType; } });
|
|
30
|
+
Object.defineProperty(exports, "SessionSecurityDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionSecurityDiagnosticsDataType; } });
|
|
31
|
+
Object.defineProperty(exports, "ServiceCounterDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServiceCounterDataType; } });
|
|
32
|
+
Object.defineProperty(exports, "SessionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionDiagnosticsDataType; } });
|
|
33
|
+
Object.defineProperty(exports, "BuildInfo", { enumerable: true, get: function () { return node_opcua_types_1.BuildInfo; } });
|
|
34
|
+
Object.defineProperty(exports, "DataTypeDefinition", { enumerable: true, get: function () { return node_opcua_types_1.DataTypeDefinition; } });
|
|
35
|
+
Object.defineProperty(exports, "EnumValueType", { enumerable: true, get: function () { return node_opcua_types_1.EnumValueType; } });
|
|
36
|
+
Object.defineProperty(exports, "TimeZoneDataType", { enumerable: true, get: function () { return node_opcua_types_1.TimeZoneDataType; } });
|
|
37
|
+
__exportStar(require("./applicationurn"), exports);
|
|
38
|
+
__exportStar(require("./opcua_secure_object"), exports);
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* @module node-opcua-common
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from "events";
|
|
6
|
-
import { Certificate, PrivateKeyPEM } from "node-opcua-crypto";
|
|
7
|
-
export interface ICertificateKeyPairProvider {
|
|
8
|
-
getCertificate(): Certificate;
|
|
9
|
-
getCertificateChain(): Certificate;
|
|
10
|
-
getPrivateKey(): PrivateKeyPEM;
|
|
11
|
-
}
|
|
12
|
-
export interface IOPCUASecureObjectOptions {
|
|
13
|
-
certificateFile?: string;
|
|
14
|
-
privateKeyFile?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* an object that provides a certificate and a privateKey
|
|
18
|
-
* @class OPCUASecureObject
|
|
19
|
-
* @param options
|
|
20
|
-
* @param options.certificateFile {string}
|
|
21
|
-
* @param options.privateKeyFile {string}
|
|
22
|
-
* @constructor
|
|
23
|
-
*/
|
|
24
|
-
export declare class OPCUASecureObject extends EventEmitter implements ICertificateKeyPairProvider {
|
|
25
|
-
readonly certificateFile: string;
|
|
26
|
-
readonly privateKeyFile: string;
|
|
27
|
-
private certificate;
|
|
28
|
-
private certificateChain;
|
|
29
|
-
private privateKeyPEM;
|
|
30
|
-
constructor(options: IOPCUASecureObjectOptions);
|
|
31
|
-
getCertificate(): Certificate;
|
|
32
|
-
getCertificateChain(): Certificate;
|
|
33
|
-
getPrivateKey(): PrivateKeyPEM;
|
|
34
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @module node-opcua-common
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
import { Certificate, PrivateKeyPEM } from "node-opcua-crypto";
|
|
7
|
+
export interface ICertificateKeyPairProvider {
|
|
8
|
+
getCertificate(): Certificate;
|
|
9
|
+
getCertificateChain(): Certificate;
|
|
10
|
+
getPrivateKey(): PrivateKeyPEM;
|
|
11
|
+
}
|
|
12
|
+
export interface IOPCUASecureObjectOptions {
|
|
13
|
+
certificateFile?: string;
|
|
14
|
+
privateKeyFile?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* an object that provides a certificate and a privateKey
|
|
18
|
+
* @class OPCUASecureObject
|
|
19
|
+
* @param options
|
|
20
|
+
* @param options.certificateFile {string}
|
|
21
|
+
* @param options.privateKeyFile {string}
|
|
22
|
+
* @constructor
|
|
23
|
+
*/
|
|
24
|
+
export declare class OPCUASecureObject extends EventEmitter implements ICertificateKeyPairProvider {
|
|
25
|
+
readonly certificateFile: string;
|
|
26
|
+
readonly privateKeyFile: string;
|
|
27
|
+
private certificate;
|
|
28
|
+
private certificateChain;
|
|
29
|
+
private privateKeyPEM;
|
|
30
|
+
constructor(options: IOPCUASecureObjectOptions);
|
|
31
|
+
getCertificate(): Certificate;
|
|
32
|
+
getCertificateChain(): Certificate;
|
|
33
|
+
getPrivateKey(): PrivateKeyPEM;
|
|
34
|
+
}
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OPCUASecureObject = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opcua-common
|
|
6
|
-
*/
|
|
7
|
-
const events_1 = require("events");
|
|
8
|
-
const fs = require("fs");
|
|
9
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
10
|
-
const node_opcua_crypto_1 = require("node-opcua-crypto");
|
|
11
|
-
function _load_certificate(certificateFilename) {
|
|
12
|
-
const der = (0, node_opcua_crypto_1.readCertificate)(certificateFilename);
|
|
13
|
-
return der;
|
|
14
|
-
}
|
|
15
|
-
function _load_private_key_pem(privateKeyFilename) {
|
|
16
|
-
return (0, node_opcua_crypto_1.readKeyPem)(privateKeyFilename);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* an object that provides a certificate and a privateKey
|
|
20
|
-
* @class OPCUASecureObject
|
|
21
|
-
* @param options
|
|
22
|
-
* @param options.certificateFile {string}
|
|
23
|
-
* @param options.privateKeyFile {string}
|
|
24
|
-
* @constructor
|
|
25
|
-
*/
|
|
26
|
-
class OPCUASecureObject extends events_1.EventEmitter {
|
|
27
|
-
constructor(options) {
|
|
28
|
-
super();
|
|
29
|
-
this.certificate = null;
|
|
30
|
-
this.certificateChain = null;
|
|
31
|
-
this.privateKeyPEM = null;
|
|
32
|
-
(0, node_opcua_assert_1.assert)(typeof options.certificateFile === "string");
|
|
33
|
-
(0, node_opcua_assert_1.assert)(typeof options.privateKeyFile === "string");
|
|
34
|
-
this.certificateFile = options.certificateFile || "invalid certificate file";
|
|
35
|
-
this.privateKeyFile = options.privateKeyFile || "invalid private key file";
|
|
36
|
-
}
|
|
37
|
-
getCertificate() {
|
|
38
|
-
if (!this.certificate) {
|
|
39
|
-
const certChain = this.getCertificateChain();
|
|
40
|
-
this.certificate = (0, node_opcua_crypto_1.split_der)(certChain)[0];
|
|
41
|
-
}
|
|
42
|
-
return this.certificate;
|
|
43
|
-
}
|
|
44
|
-
getCertificateChain() {
|
|
45
|
-
if (!this.certificateChain) {
|
|
46
|
-
(0, node_opcua_assert_1.assert)(fs.existsSync(this.certificateFile), "Certificate file must exist :" + this.certificateFile);
|
|
47
|
-
this.certificateChain = _load_certificate(this.certificateFile);
|
|
48
|
-
if (this.certificateChain && this.certificateChain.length === 0) {
|
|
49
|
-
this.certificateChain = _load_certificate(this.certificateFile);
|
|
50
|
-
throw new Error("Invalid certificate length = 0 " + this.certificateFile);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return this.certificateChain;
|
|
54
|
-
}
|
|
55
|
-
getPrivateKey() {
|
|
56
|
-
if (!this.privateKeyPEM) {
|
|
57
|
-
(0, node_opcua_assert_1.assert)(fs.existsSync(this.privateKeyFile), "private file must exist :" + this.privateKeyFile);
|
|
58
|
-
this.privateKeyPEM = _load_private_key_pem(this.privateKeyFile);
|
|
59
|
-
}
|
|
60
|
-
return this.privateKeyPEM;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.OPCUASecureObject = OPCUASecureObject;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OPCUASecureObject = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-common
|
|
6
|
+
*/
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
10
|
+
const node_opcua_crypto_1 = require("node-opcua-crypto");
|
|
11
|
+
function _load_certificate(certificateFilename) {
|
|
12
|
+
const der = (0, node_opcua_crypto_1.readCertificate)(certificateFilename);
|
|
13
|
+
return der;
|
|
14
|
+
}
|
|
15
|
+
function _load_private_key_pem(privateKeyFilename) {
|
|
16
|
+
return (0, node_opcua_crypto_1.readKeyPem)(privateKeyFilename);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* an object that provides a certificate and a privateKey
|
|
20
|
+
* @class OPCUASecureObject
|
|
21
|
+
* @param options
|
|
22
|
+
* @param options.certificateFile {string}
|
|
23
|
+
* @param options.privateKeyFile {string}
|
|
24
|
+
* @constructor
|
|
25
|
+
*/
|
|
26
|
+
class OPCUASecureObject extends events_1.EventEmitter {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
super();
|
|
29
|
+
this.certificate = null;
|
|
30
|
+
this.certificateChain = null;
|
|
31
|
+
this.privateKeyPEM = null;
|
|
32
|
+
(0, node_opcua_assert_1.assert)(typeof options.certificateFile === "string");
|
|
33
|
+
(0, node_opcua_assert_1.assert)(typeof options.privateKeyFile === "string");
|
|
34
|
+
this.certificateFile = options.certificateFile || "invalid certificate file";
|
|
35
|
+
this.privateKeyFile = options.privateKeyFile || "invalid private key file";
|
|
36
|
+
}
|
|
37
|
+
getCertificate() {
|
|
38
|
+
if (!this.certificate) {
|
|
39
|
+
const certChain = this.getCertificateChain();
|
|
40
|
+
this.certificate = (0, node_opcua_crypto_1.split_der)(certChain)[0];
|
|
41
|
+
}
|
|
42
|
+
return this.certificate;
|
|
43
|
+
}
|
|
44
|
+
getCertificateChain() {
|
|
45
|
+
if (!this.certificateChain) {
|
|
46
|
+
(0, node_opcua_assert_1.assert)(fs.existsSync(this.certificateFile), "Certificate file must exist :" + this.certificateFile);
|
|
47
|
+
this.certificateChain = _load_certificate(this.certificateFile);
|
|
48
|
+
if (this.certificateChain && this.certificateChain.length === 0) {
|
|
49
|
+
this.certificateChain = _load_certificate(this.certificateFile);
|
|
50
|
+
throw new Error("Invalid certificate length = 0 " + this.certificateFile);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return this.certificateChain;
|
|
54
|
+
}
|
|
55
|
+
getPrivateKey() {
|
|
56
|
+
if (!this.privateKeyPEM) {
|
|
57
|
+
(0, node_opcua_assert_1.assert)(fs.existsSync(this.privateKeyFile), "private file must exist :" + this.privateKeyFile);
|
|
58
|
+
this.privateKeyPEM = _load_private_key_pem(this.privateKeyFile);
|
|
59
|
+
}
|
|
60
|
+
return this.privateKeyPEM;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.OPCUASecureObject = OPCUASecureObject;
|
|
64
64
|
//# sourceMappingURL=opcua_secure_object.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.71.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module -common",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "mocha",
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"node-opcua-assert": "2.66.0",
|
|
15
|
-
"node-opcua-basic-types": "2.
|
|
16
|
-
"node-opcua-crypto": "^1.
|
|
17
|
-
"node-opcua-data-model": "2.
|
|
18
|
-
"node-opcua-factory": "2.
|
|
19
|
-
"node-opcua-nodeid": "2.
|
|
20
|
-
"node-opcua-service-endpoints": "2.
|
|
21
|
-
"node-opcua-service-secure-channel": "2.
|
|
22
|
-
"node-opcua-types": "2.
|
|
15
|
+
"node-opcua-basic-types": "2.71.0",
|
|
16
|
+
"node-opcua-crypto": "^1.11.0",
|
|
17
|
+
"node-opcua-data-model": "2.71.0",
|
|
18
|
+
"node-opcua-factory": "2.71.0",
|
|
19
|
+
"node-opcua-nodeid": "2.71.0",
|
|
20
|
+
"node-opcua-service-endpoints": "2.71.0",
|
|
21
|
+
"node-opcua-service-secure-channel": "2.71.0",
|
|
22
|
+
"node-opcua-types": "2.71.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "
|
|
25
|
+
"@types/node": "18.0.0",
|
|
26
26
|
"should": "^13.2.3"
|
|
27
27
|
},
|
|
28
28
|
"author": "Etienne Rossignon",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"internet of things"
|
|
41
41
|
],
|
|
42
42
|
"homepage": "http://node-opcua.github.io/",
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "10f7cc1e1cd30dfef75adad9cb709a78401fabf3"
|
|
44
44
|
}
|