node-opcua-common 2.97.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.
- 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 +33 -33
- package/dist/opcua_secure_object.js +60 -60
- package/package.json +10 -6
- package/crypto_explore_certificate.js +0 -2
- package/fragments.yml +0 -46
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,33 +1,33 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from "events";
|
|
3
|
-
import { Certificate, PrivateKey } from "node-opcua-crypto";
|
|
4
|
-
export interface ICertificateKeyPairProvider {
|
|
5
|
-
getCertificate(): Certificate;
|
|
6
|
-
getCertificateChain(): Certificate;
|
|
7
|
-
getPrivateKey(): PrivateKey;
|
|
8
|
-
}
|
|
9
|
-
export interface ICertificateKeyPairProviderPriv extends ICertificateKeyPairProvider {
|
|
10
|
-
$$certificate: null | Certificate;
|
|
11
|
-
$$certificateChain: null | Certificate;
|
|
12
|
-
$$privateKey: null | PrivateKey;
|
|
13
|
-
}
|
|
14
|
-
export interface IOPCUASecureObjectOptions {
|
|
15
|
-
certificateFile?: string;
|
|
16
|
-
privateKeyFile?: string;
|
|
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
|
-
export declare class OPCUASecureObject extends EventEmitter implements ICertificateKeyPairProvider {
|
|
27
|
-
readonly certificateFile: string;
|
|
28
|
-
readonly privateKeyFile: string;
|
|
29
|
-
constructor(options: IOPCUASecureObjectOptions);
|
|
30
|
-
getCertificate(): Certificate;
|
|
31
|
-
getCertificateChain(): Certificate;
|
|
32
|
-
getPrivateKey(): PrivateKey;
|
|
33
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import { Certificate, PrivateKey } from "node-opcua-crypto";
|
|
4
|
+
export interface ICertificateKeyPairProvider {
|
|
5
|
+
getCertificate(): Certificate;
|
|
6
|
+
getCertificateChain(): Certificate;
|
|
7
|
+
getPrivateKey(): PrivateKey;
|
|
8
|
+
}
|
|
9
|
+
export interface ICertificateKeyPairProviderPriv extends ICertificateKeyPairProvider {
|
|
10
|
+
$$certificate: null | Certificate;
|
|
11
|
+
$$certificateChain: null | Certificate;
|
|
12
|
+
$$privateKey: null | PrivateKey;
|
|
13
|
+
}
|
|
14
|
+
export interface IOPCUASecureObjectOptions {
|
|
15
|
+
certificateFile?: string;
|
|
16
|
+
privateKeyFile?: string;
|
|
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
|
+
export declare class OPCUASecureObject extends EventEmitter implements ICertificateKeyPairProvider {
|
|
27
|
+
readonly certificateFile: string;
|
|
28
|
+
readonly privateKeyFile: string;
|
|
29
|
+
constructor(options: IOPCUASecureObjectOptions);
|
|
30
|
+
getCertificate(): Certificate;
|
|
31
|
+
getCertificateChain(): Certificate;
|
|
32
|
+
getPrivateKey(): PrivateKey;
|
|
33
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OPCUASecureObject = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
7
|
-
const node_opcua_crypto_1 = require("node-opcua-crypto");
|
|
8
|
-
function _load_certificate(certificateFilename) {
|
|
9
|
-
const der = (0, node_opcua_crypto_1.readCertificate)(certificateFilename);
|
|
10
|
-
return der;
|
|
11
|
-
}
|
|
12
|
-
function _load_private_key(privateKeyFilename) {
|
|
13
|
-
return (0, node_opcua_crypto_1.readPrivateKey)(privateKeyFilename);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* an object that provides a certificate and a privateKey
|
|
17
|
-
* @class OPCUASecureObject
|
|
18
|
-
* @param options
|
|
19
|
-
* @param options.certificateFile {string}
|
|
20
|
-
* @param options.privateKeyFile {string}
|
|
21
|
-
* @constructor
|
|
22
|
-
*/
|
|
23
|
-
class OPCUASecureObject extends events_1.EventEmitter {
|
|
24
|
-
constructor(options) {
|
|
25
|
-
super();
|
|
26
|
-
(0, node_opcua_assert_1.assert)(typeof options.certificateFile === "string");
|
|
27
|
-
(0, node_opcua_assert_1.assert)(typeof options.privateKeyFile === "string");
|
|
28
|
-
this.certificateFile = options.certificateFile || "invalid certificate file";
|
|
29
|
-
this.privateKeyFile = options.privateKeyFile || "invalid private key file";
|
|
30
|
-
}
|
|
31
|
-
getCertificate() {
|
|
32
|
-
const priv = this;
|
|
33
|
-
if (!priv.$$certificate) {
|
|
34
|
-
const certChain = this.getCertificateChain();
|
|
35
|
-
priv.$$certificate = (0, node_opcua_crypto_1.split_der)(certChain)[0];
|
|
36
|
-
}
|
|
37
|
-
return priv.$$certificate;
|
|
38
|
-
}
|
|
39
|
-
getCertificateChain() {
|
|
40
|
-
const priv = this;
|
|
41
|
-
if (!priv.$$certificateChain) {
|
|
42
|
-
(0, node_opcua_assert_1.assert)(fs.existsSync(this.certificateFile), "Certificate file must exist :" + this.certificateFile);
|
|
43
|
-
priv.$$certificateChain = _load_certificate(this.certificateFile);
|
|
44
|
-
if (priv.$$certificateChain && priv.$$certificateChain.length === 0) {
|
|
45
|
-
priv.$$certificateChain = _load_certificate(this.certificateFile);
|
|
46
|
-
throw new Error("Invalid certificate length = 0 " + this.certificateFile);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return priv.$$certificateChain;
|
|
50
|
-
}
|
|
51
|
-
getPrivateKey() {
|
|
52
|
-
const priv = this;
|
|
53
|
-
if (!priv.$$privateKey) {
|
|
54
|
-
(0, node_opcua_assert_1.assert)(fs.existsSync(this.privateKeyFile), "private file must exist :" + this.privateKeyFile);
|
|
55
|
-
priv.$$privateKey = _load_private_key(this.privateKeyFile);
|
|
56
|
-
}
|
|
57
|
-
return priv.$$privateKey;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.OPCUASecureObject = OPCUASecureObject;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OPCUASecureObject = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
7
|
+
const node_opcua_crypto_1 = require("node-opcua-crypto");
|
|
8
|
+
function _load_certificate(certificateFilename) {
|
|
9
|
+
const der = (0, node_opcua_crypto_1.readCertificate)(certificateFilename);
|
|
10
|
+
return der;
|
|
11
|
+
}
|
|
12
|
+
function _load_private_key(privateKeyFilename) {
|
|
13
|
+
return (0, node_opcua_crypto_1.readPrivateKey)(privateKeyFilename);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* an object that provides a certificate and a privateKey
|
|
17
|
+
* @class OPCUASecureObject
|
|
18
|
+
* @param options
|
|
19
|
+
* @param options.certificateFile {string}
|
|
20
|
+
* @param options.privateKeyFile {string}
|
|
21
|
+
* @constructor
|
|
22
|
+
*/
|
|
23
|
+
class OPCUASecureObject extends events_1.EventEmitter {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
super();
|
|
26
|
+
(0, node_opcua_assert_1.assert)(typeof options.certificateFile === "string");
|
|
27
|
+
(0, node_opcua_assert_1.assert)(typeof options.privateKeyFile === "string");
|
|
28
|
+
this.certificateFile = options.certificateFile || "invalid certificate file";
|
|
29
|
+
this.privateKeyFile = options.privateKeyFile || "invalid private key file";
|
|
30
|
+
}
|
|
31
|
+
getCertificate() {
|
|
32
|
+
const priv = this;
|
|
33
|
+
if (!priv.$$certificate) {
|
|
34
|
+
const certChain = this.getCertificateChain();
|
|
35
|
+
priv.$$certificate = (0, node_opcua_crypto_1.split_der)(certChain)[0];
|
|
36
|
+
}
|
|
37
|
+
return priv.$$certificate;
|
|
38
|
+
}
|
|
39
|
+
getCertificateChain() {
|
|
40
|
+
const priv = this;
|
|
41
|
+
if (!priv.$$certificateChain) {
|
|
42
|
+
(0, node_opcua_assert_1.assert)(fs.existsSync(this.certificateFile), "Certificate file must exist :" + this.certificateFile);
|
|
43
|
+
priv.$$certificateChain = _load_certificate(this.certificateFile);
|
|
44
|
+
if (priv.$$certificateChain && priv.$$certificateChain.length === 0) {
|
|
45
|
+
priv.$$certificateChain = _load_certificate(this.certificateFile);
|
|
46
|
+
throw new Error("Invalid certificate length = 0 " + this.certificateFile);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return priv.$$certificateChain;
|
|
50
|
+
}
|
|
51
|
+
getPrivateKey() {
|
|
52
|
+
const priv = this;
|
|
53
|
+
if (!priv.$$privateKey) {
|
|
54
|
+
(0, node_opcua_assert_1.assert)(fs.existsSync(this.privateKeyFile), "private file must exist :" + this.privateKeyFile);
|
|
55
|
+
priv.$$privateKey = _load_private_key(this.privateKeyFile);
|
|
56
|
+
}
|
|
57
|
+
return priv.$$privateKey;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.OPCUASecureObject = OPCUASecureObject;
|
|
61
61
|
//# sourceMappingURL=opcua_secure_object.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-common",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "pure nodejs OPCUA SDK - module
|
|
3
|
+
"version": "2.98.1",
|
|
4
|
+
"description": "pure nodejs OPCUA SDK - module common",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "mocha",
|
|
7
7
|
"clean": "npx rimraf node_modules dist *.tsbuildinfo",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"main": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"node-opcua-assert": "2.
|
|
14
|
+
"node-opcua-assert": "2.98.1",
|
|
15
15
|
"node-opcua-crypto": "^2.1.2",
|
|
16
|
-
"node-opcua-types": "2.
|
|
16
|
+
"node-opcua-types": "2.98.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/node": "18.15.
|
|
19
|
+
"@types/node": "18.15.11",
|
|
20
20
|
"should": "^13.2.3"
|
|
21
21
|
},
|
|
22
22
|
"author": "Etienne Rossignon",
|
|
@@ -34,5 +34,9 @@
|
|
|
34
34
|
"internet of things"
|
|
35
35
|
],
|
|
36
36
|
"homepage": "http://node-opcua.github.io/",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"source"
|
|
41
|
+
]
|
|
38
42
|
}
|
package/fragments.yml
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
ApplicationInstanceCertificate:
|
|
3
|
-
reference: OPC Unified Architecture, Part 4 page 106
|
|
4
|
-
documentation: ApplicationInstanceCertificate with signature created by a Certificate Authority
|
|
5
|
-
fields:
|
|
6
|
-
version: An identifier for the version of the Certificate encoding.
|
|
7
|
-
serialNumber: A unique identifier for the Certificate assigned by the Issuer.
|
|
8
|
-
signatureAlgorithm: >
|
|
9
|
-
The algorithm used to sign the Certificate.
|
|
10
|
-
The syntax of this field depends on the Certificate encoding.
|
|
11
|
-
signature: The signature created by the Issuer.
|
|
12
|
-
issuer: A name that identifies the Issuer Certificate used to create the signature.
|
|
13
|
-
validFrom: When the Certificate becomes valid.
|
|
14
|
-
validTo: When the Certificate expires.
|
|
15
|
-
subject: >
|
|
16
|
-
A name that identifies the application instance that the Certificate describes.
|
|
17
|
-
This field shall contain the productName and the name of the organization
|
|
18
|
-
responsible for the application instance.
|
|
19
|
-
applicationUri: >
|
|
20
|
-
The applicationUri specified in the ApplicationDescription .
|
|
21
|
-
The ApplicationDescription is described in 7.1.
|
|
22
|
-
hostnames: >
|
|
23
|
-
The name of the machine where the application instance runs.
|
|
24
|
-
A machine may have multiple names if is accessible via multiple networks.
|
|
25
|
-
The hostname may be a numeric network address or a descriptive name.
|
|
26
|
-
Server Certificates shall have at least one hostname defined.
|
|
27
|
-
publicKey: The public key associated with the Certificate .
|
|
28
|
-
keyUsage: >
|
|
29
|
-
Specifies how the Certificate key may be used.
|
|
30
|
-
ApplicationInstanceCertificates shall support Digital Signature, Non-Repudiation Key Encryption,
|
|
31
|
-
Data Encryption and Client/Server Authorization.
|
|
32
|
-
The contents of this field depend on the Certificate encoding
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#
|
|
36
|
-
BuildInfo:
|
|
37
|
-
documentation: Server build Info,
|
|
38
|
-
fields:
|
|
39
|
-
productUri: A description for the ProductUri Variable.
|
|
40
|
-
manufacturerName: the name of the manufacturer
|
|
41
|
-
productName: the product name"
|
|
42
|
-
softwareVersion: the software version
|
|
43
|
-
buildNumber: the software build number
|
|
44
|
-
buildDate: the software build date
|
|
45
|
-
|
|
46
|
-
|