node-opcua-common 2.70.2 → 2.72.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.
@@ -9,6 +9,11 @@ export interface ICertificateKeyPairProvider {
9
9
  getCertificateChain(): Certificate;
10
10
  getPrivateKey(): PrivateKeyPEM;
11
11
  }
12
+ export interface ICertificateKeyPairProviderPriv extends ICertificateKeyPairProvider {
13
+ $$certificate: null | Certificate;
14
+ $$certificateChain: null | Certificate;
15
+ $$privateKeyPEM: null | PrivateKeyPEM;
16
+ }
12
17
  export interface IOPCUASecureObjectOptions {
13
18
  certificateFile?: string;
14
19
  privateKeyFile?: string;
@@ -24,9 +29,6 @@ export interface IOPCUASecureObjectOptions {
24
29
  export declare class OPCUASecureObject extends EventEmitter implements ICertificateKeyPairProvider {
25
30
  readonly certificateFile: string;
26
31
  readonly privateKeyFile: string;
27
- private certificate;
28
- private certificateChain;
29
- private privateKeyPEM;
30
32
  constructor(options: IOPCUASecureObjectOptions);
31
33
  getCertificate(): Certificate;
32
34
  getCertificateChain(): Certificate;
@@ -26,38 +26,38 @@ function _load_private_key_pem(privateKeyFilename) {
26
26
  class OPCUASecureObject extends events_1.EventEmitter {
27
27
  constructor(options) {
28
28
  super();
29
- this.certificate = null;
30
- this.certificateChain = null;
31
- this.privateKeyPEM = null;
32
29
  (0, node_opcua_assert_1.assert)(typeof options.certificateFile === "string");
33
30
  (0, node_opcua_assert_1.assert)(typeof options.privateKeyFile === "string");
34
31
  this.certificateFile = options.certificateFile || "invalid certificate file";
35
32
  this.privateKeyFile = options.privateKeyFile || "invalid private key file";
36
33
  }
37
34
  getCertificate() {
38
- if (!this.certificate) {
35
+ const priv = this;
36
+ if (!priv.$$certificate) {
39
37
  const certChain = this.getCertificateChain();
40
- this.certificate = (0, node_opcua_crypto_1.split_der)(certChain)[0];
38
+ priv.$$certificate = (0, node_opcua_crypto_1.split_der)(certChain)[0];
41
39
  }
42
- return this.certificate;
40
+ return priv.$$certificate;
43
41
  }
44
42
  getCertificateChain() {
45
- if (!this.certificateChain) {
43
+ const priv = this;
44
+ if (!priv.$$certificateChain) {
46
45
  (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);
46
+ priv.$$certificateChain = _load_certificate(this.certificateFile);
47
+ if (priv.$$certificateChain && priv.$$certificateChain.length === 0) {
48
+ priv.$$certificateChain = _load_certificate(this.certificateFile);
50
49
  throw new Error("Invalid certificate length = 0 " + this.certificateFile);
51
50
  }
52
51
  }
53
- return this.certificateChain;
52
+ return priv.$$certificateChain;
54
53
  }
55
54
  getPrivateKey() {
56
- if (!this.privateKeyPEM) {
55
+ const priv = this;
56
+ if (!priv.$$privateKeyPEM) {
57
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);
58
+ priv.$$privateKeyPEM = _load_private_key_pem(this.privateKeyFile);
59
59
  }
60
- return this.privateKeyPEM;
60
+ return priv.$$privateKeyPEM;
61
61
  }
62
62
  }
63
63
  exports.OPCUASecureObject = OPCUASecureObject;
@@ -1 +1 @@
1
- {"version":3,"file":"opcua_secure_object.js","sourceRoot":"","sources":["../source/opcua_secure_object.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mCAAsC;AACtC,yBAAyB;AAEzB,yDAA2C;AAC3C,yDAAuG;AAQvG,SAAS,iBAAiB,CAAC,mBAA2B;IAClD,MAAM,GAAG,GAAG,IAAA,mCAAe,EAAC,mBAAmB,CAAC,CAAC;IACjD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,qBAAqB,CAAC,kBAA0B;IACrD,OAAO,IAAA,8BAAU,EAAC,kBAAkB,CAAC,CAAC;AAC1C,CAAC;AAOD;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,CAAC;CACJ;AA3CD,8CA2CC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-common",
3
- "version": "2.70.2",
3
+ "version": "2.72.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.70.0",
16
- "node-opcua-crypto": "^1.10.0",
17
- "node-opcua-data-model": "2.70.0",
18
- "node-opcua-factory": "2.70.0",
19
- "node-opcua-nodeid": "2.70.0",
20
- "node-opcua-service-endpoints": "2.70.2",
21
- "node-opcua-service-secure-channel": "2.70.2",
22
- "node-opcua-types": "2.70.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.72.0",
21
+ "node-opcua-service-secure-channel": "2.72.0",
22
+ "node-opcua-types": "2.72.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "17.0.36",
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": "3d63db79d14539ee61bc82998b19320202f35392"
43
+ "gitHead": "3c5f00e20bf5bef91a1ca3663af149b903760e5c"
44
44
  }
@@ -12,7 +12,11 @@ export interface ICertificateKeyPairProvider {
12
12
  getCertificateChain(): Certificate;
13
13
  getPrivateKey(): PrivateKeyPEM;
14
14
  }
15
-
15
+ export interface ICertificateKeyPairProviderPriv extends ICertificateKeyPairProvider {
16
+ $$certificate: null | Certificate;
17
+ $$certificateChain: null | Certificate;
18
+ $$privateKeyPEM: null | PrivateKeyPEM;
19
+ }
16
20
  function _load_certificate(certificateFilename: string): Certificate {
17
21
  const der = readCertificate(certificateFilename);
18
22
  return der;
@@ -39,16 +43,8 @@ export class OPCUASecureObject extends EventEmitter implements ICertificateKeyPa
39
43
  public readonly certificateFile: string;
40
44
  public readonly privateKeyFile: string;
41
45
 
42
- private certificate: null | Certificate;
43
- private certificateChain: null | Certificate;
44
- private privateKeyPEM: null | PrivateKeyPEM;
45
-
46
46
  constructor(options: IOPCUASecureObjectOptions) {
47
47
  super();
48
- this.certificate = null;
49
- this.certificateChain = null;
50
- this.privateKeyPEM = null;
51
-
52
48
  assert(typeof options.certificateFile === "string");
53
49
  assert(typeof options.privateKeyFile === "string");
54
50
 
@@ -57,30 +53,33 @@ export class OPCUASecureObject extends EventEmitter implements ICertificateKeyPa
57
53
  }
58
54
 
59
55
  public getCertificate(): Certificate {
60
- if (!this.certificate) {
56
+ const priv = this as unknown as ICertificateKeyPairProviderPriv;
57
+ if (!priv.$$certificate) {
61
58
  const certChain = this.getCertificateChain();
62
- this.certificate = split_der(certChain)[0] as Certificate;
59
+ priv.$$certificate = split_der(certChain)[0] as Certificate;
63
60
  }
64
- return this.certificate;
61
+ return priv.$$certificate;
65
62
  }
66
63
 
67
64
  public getCertificateChain(): Certificate {
68
- if (!this.certificateChain) {
65
+ const priv = this as unknown as ICertificateKeyPairProviderPriv;
66
+ if (!priv.$$certificateChain) {
69
67
  assert(fs.existsSync(this.certificateFile), "Certificate file must exist :" + this.certificateFile);
70
- this.certificateChain = _load_certificate(this.certificateFile);
71
- if (this.certificateChain && this.certificateChain.length === 0) {
72
- this.certificateChain = _load_certificate(this.certificateFile);
68
+ priv.$$certificateChain = _load_certificate(this.certificateFile);
69
+ if (priv.$$certificateChain && priv.$$certificateChain.length === 0) {
70
+ priv.$$certificateChain = _load_certificate(this.certificateFile);
73
71
  throw new Error("Invalid certificate length = 0 " + this.certificateFile);
74
72
  }
75
73
  }
76
- return this.certificateChain;
74
+ return priv.$$certificateChain;
77
75
  }
78
76
 
79
77
  public getPrivateKey(): PrivateKeyPEM {
80
- if (!this.privateKeyPEM) {
78
+ const priv = this as unknown as ICertificateKeyPairProviderPriv;
79
+ if (!priv.$$privateKeyPEM) {
81
80
  assert(fs.existsSync(this.privateKeyFile), "private file must exist :" + this.privateKeyFile);
82
- this.privateKeyPEM = _load_private_key_pem(this.privateKeyFile);
81
+ priv.$$privateKeyPEM = _load_private_key_pem(this.privateKeyFile);
83
82
  }
84
- return this.privateKeyPEM;
83
+ return priv.$$privateKeyPEM;
85
84
  }
86
85
  }