node-opcua-common 2.64.1 → 2.65.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.
@@ -1 +1 @@
1
- export declare function makeApplicationUrn(hostname: string, suffix: string): string;
1
+ export declare function makeApplicationUrn(hostname: string, suffix: string): string;
@@ -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").substr(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").substr(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,35 +1,35 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- 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;
14
- /**
15
- * @module node-opcua-common
16
- */
17
- var node_opcua_types_1 = require("node-opcua-types");
18
- Object.defineProperty(exports, "ServerState", { enumerable: true, get: function () { return node_opcua_types_1.ServerState; } });
19
- Object.defineProperty(exports, "ServerStatusDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerStatusDataType; } });
20
- Object.defineProperty(exports, "RedundantServerDataType", { enumerable: true, get: function () { return node_opcua_types_1.RedundantServerDataType; } });
21
- Object.defineProperty(exports, "ModelChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.ModelChangeStructureDataType; } });
22
- Object.defineProperty(exports, "SubscriptionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SubscriptionDiagnosticsDataType; } });
23
- Object.defineProperty(exports, "SamplingIntervalDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SamplingIntervalDiagnosticsDataType; } });
24
- Object.defineProperty(exports, "SemanticChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.SemanticChangeStructureDataType; } });
25
- Object.defineProperty(exports, "ServerDiagnosticsSummaryDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerDiagnosticsSummaryDataType; } });
26
- Object.defineProperty(exports, "SessionSecurityDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionSecurityDiagnosticsDataType; } });
27
- Object.defineProperty(exports, "ServiceCounterDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServiceCounterDataType; } });
28
- Object.defineProperty(exports, "SessionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionDiagnosticsDataType; } });
29
- Object.defineProperty(exports, "BuildInfo", { enumerable: true, get: function () { return node_opcua_types_1.BuildInfo; } });
30
- Object.defineProperty(exports, "DataTypeDefinition", { enumerable: true, get: function () { return node_opcua_types_1.DataTypeDefinition; } });
31
- Object.defineProperty(exports, "EnumValueType", { enumerable: true, get: function () { return node_opcua_types_1.EnumValueType; } });
32
- Object.defineProperty(exports, "TimeZoneDataType", { enumerable: true, get: function () { return node_opcua_types_1.TimeZoneDataType; } });
33
- __exportStar(require("./applicationurn"), exports);
34
- __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
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ 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;
14
+ /**
15
+ * @module node-opcua-common
16
+ */
17
+ var node_opcua_types_1 = require("node-opcua-types");
18
+ Object.defineProperty(exports, "ServerState", { enumerable: true, get: function () { return node_opcua_types_1.ServerState; } });
19
+ Object.defineProperty(exports, "ServerStatusDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerStatusDataType; } });
20
+ Object.defineProperty(exports, "RedundantServerDataType", { enumerable: true, get: function () { return node_opcua_types_1.RedundantServerDataType; } });
21
+ Object.defineProperty(exports, "ModelChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.ModelChangeStructureDataType; } });
22
+ Object.defineProperty(exports, "SubscriptionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SubscriptionDiagnosticsDataType; } });
23
+ Object.defineProperty(exports, "SamplingIntervalDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SamplingIntervalDiagnosticsDataType; } });
24
+ Object.defineProperty(exports, "SemanticChangeStructureDataType", { enumerable: true, get: function () { return node_opcua_types_1.SemanticChangeStructureDataType; } });
25
+ Object.defineProperty(exports, "ServerDiagnosticsSummaryDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServerDiagnosticsSummaryDataType; } });
26
+ Object.defineProperty(exports, "SessionSecurityDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionSecurityDiagnosticsDataType; } });
27
+ Object.defineProperty(exports, "ServiceCounterDataType", { enumerable: true, get: function () { return node_opcua_types_1.ServiceCounterDataType; } });
28
+ Object.defineProperty(exports, "SessionDiagnosticsDataType", { enumerable: true, get: function () { return node_opcua_types_1.SessionDiagnosticsDataType; } });
29
+ Object.defineProperty(exports, "BuildInfo", { enumerable: true, get: function () { return node_opcua_types_1.BuildInfo; } });
30
+ Object.defineProperty(exports, "DataTypeDefinition", { enumerable: true, get: function () { return node_opcua_types_1.DataTypeDefinition; } });
31
+ Object.defineProperty(exports, "EnumValueType", { enumerable: true, get: function () { return node_opcua_types_1.EnumValueType; } });
32
+ Object.defineProperty(exports, "TimeZoneDataType", { enumerable: true, get: function () { return node_opcua_types_1.TimeZoneDataType; } });
33
+ __exportStar(require("./applicationurn"), exports);
34
+ __exportStar(require("./opcua_secure_object"), exports);
35
35
  //# 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.64.1",
3
+ "version": "2.65.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -common",
5
5
  "scripts": {
6
6
  "test": "mocha",
@@ -17,9 +17,9 @@
17
17
  "node-opcua-data-model": "2.64.1",
18
18
  "node-opcua-factory": "2.64.1",
19
19
  "node-opcua-nodeid": "2.64.1",
20
- "node-opcua-service-endpoints": "2.64.1",
21
- "node-opcua-service-secure-channel": "2.64.1",
22
- "node-opcua-types": "2.64.1"
20
+ "node-opcua-service-endpoints": "2.65.0",
21
+ "node-opcua-service-secure-channel": "2.65.0",
22
+ "node-opcua-types": "2.65.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "17.0.21",
@@ -40,5 +40,5 @@
40
40
  "internet of things"
41
41
  ],
42
42
  "homepage": "http://node-opcua.github.io/",
43
- "gitHead": "b65b8738603cd475d7d99a2b20b0ae9d32b4110c"
43
+ "gitHead": "59b9cae30fb45633ad501f9cf3b74fb9d05e8960"
44
44
  }