node-opcua-common 2.132.0 → 2.134.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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module node-opcua-common
|
|
3
3
|
*/
|
|
4
4
|
import { EventEmitter } from "events";
|
|
5
|
-
import { Certificate, PrivateKey } from "node-opcua-crypto";
|
|
5
|
+
import { Certificate, PrivateKey } from "node-opcua-crypto/web";
|
|
6
6
|
export interface ICertificateKeyPairProvider {
|
|
7
7
|
getCertificate(): Certificate;
|
|
8
8
|
getCertificateChain(): Certificate;
|
|
@@ -21,11 +21,6 @@ export interface IOPCUASecureObjectOptions {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* an object that provides a certificate and a privateKey
|
|
24
|
-
* @class OPCUASecureObject
|
|
25
|
-
* @param options
|
|
26
|
-
* @param options.certificateFile {string}
|
|
27
|
-
* @param options.privateKeyFile {string}
|
|
28
|
-
* @constructor
|
|
29
24
|
*/
|
|
30
25
|
export declare class OPCUASecureObject extends EventEmitter implements ICertificateKeyPairProvider {
|
|
31
26
|
readonly certificateFile: string;
|
|
@@ -12,6 +12,7 @@ exports.getPartialCertificateChain = getPartialCertificateChain;
|
|
|
12
12
|
const events_1 = require("events");
|
|
13
13
|
const fs_1 = __importDefault(require("fs"));
|
|
14
14
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
15
|
+
const web_1 = require("node-opcua-crypto/web");
|
|
15
16
|
const node_opcua_crypto_1 = require("node-opcua-crypto");
|
|
16
17
|
function _load_certificate(certificateFilename) {
|
|
17
18
|
const der = (0, node_opcua_crypto_1.readCertificate)(certificateFilename);
|
|
@@ -30,7 +31,7 @@ function getPartialCertificateChain(certificateChain, maxSize) {
|
|
|
30
31
|
if (maxSize === undefined) {
|
|
31
32
|
return certificateChain;
|
|
32
33
|
}
|
|
33
|
-
const certificates = (0,
|
|
34
|
+
const certificates = (0, web_1.split_der)(certificateChain);
|
|
34
35
|
// at least include first certificate
|
|
35
36
|
let buffer = certificates.length == 1 ? certificateChain : Buffer.from(certificates[0]);
|
|
36
37
|
// Throw if first certificate already exceed maxSize
|
|
@@ -46,11 +47,6 @@ function getPartialCertificateChain(certificateChain, maxSize) {
|
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* an object that provides a certificate and a privateKey
|
|
49
|
-
* @class OPCUASecureObject
|
|
50
|
-
* @param options
|
|
51
|
-
* @param options.certificateFile {string}
|
|
52
|
-
* @param options.privateKeyFile {string}
|
|
53
|
-
* @constructor
|
|
54
50
|
*/
|
|
55
51
|
class OPCUASecureObject extends events_1.EventEmitter {
|
|
56
52
|
constructor(options) {
|
|
@@ -64,7 +60,7 @@ class OPCUASecureObject extends events_1.EventEmitter {
|
|
|
64
60
|
const priv = this;
|
|
65
61
|
if (!priv.$$certificate) {
|
|
66
62
|
const certChain = this.getCertificateChain();
|
|
67
|
-
priv.$$certificate = (0,
|
|
63
|
+
priv.$$certificate = (0, web_1.split_der)(certChain)[0];
|
|
68
64
|
}
|
|
69
65
|
return priv.$$certificate;
|
|
70
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opcua_secure_object.js","sourceRoot":"","sources":["../source/opcua_secure_object.ts"],"names":[],"mappings":";;;;;;AA4BA,kEAGC;AACD,gEAsBC;AAtDD;;GAEG;AACH,mCAAsC;AACtC,4CAAoB;AAEpB,yDAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"opcua_secure_object.js","sourceRoot":"","sources":["../source/opcua_secure_object.ts"],"names":[],"mappings":";;;;;;AA4BA,kEAGC;AACD,gEAsBC;AAtDD;;GAEG;AACH,mCAAsC;AACtC,4CAAoB;AAEpB,yDAA2C;AAC3C,+CAA2E;AAC3E,yDAAoE;AAWpE,SAAS,iBAAiB,CAAC,mBAA2B;IAClD,MAAM,GAAG,GAAG,IAAA,mCAAe,EAAC,mBAAmB,CAAC,CAAC;IACjD,OAAO,GA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AC;YAC9E,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAEM,aAAa;QAChB,MAAM,IAAI,GAAG,IAAkD,CAAC;QAChE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACrB,IAAA,0BAAM,EAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,2BAA2B,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9F,IAAI,CAAC,YAAY,GAAG,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/D,CAAC;QACD,IAAA,0BAAM,EAAC,CAAC,CAAC,IAAI,CAAC,YAAY,YAAY,MAAM,CAAC,EAAE,wBAAwB,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;CACJ;AA7CD,8CA6CC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.134.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module common",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "mocha",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"node-opcua-assert": "2.120.0",
|
|
15
|
-
"node-opcua-crypto": "4.
|
|
16
|
-
"node-opcua-types": "2.
|
|
15
|
+
"node-opcua-crypto": "4.12.0",
|
|
16
|
+
"node-opcua-types": "2.134.0"
|
|
17
17
|
},
|
|
18
18
|
"author": "Etienne Rossignon",
|
|
19
19
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"internet of things"
|
|
31
31
|
],
|
|
32
32
|
"homepage": "http://node-opcua.github.io/",
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "ccb34926a3c195f6a7e66fca58a2f101858e78be",
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|
|
36
36
|
"source"
|
|
@@ -5,8 +5,8 @@ import { EventEmitter } from "events";
|
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
|
|
7
7
|
import { assert } from "node-opcua-assert";
|
|
8
|
-
import { Certificate, PrivateKey,
|
|
9
|
-
|
|
8
|
+
import { Certificate, PrivateKey, split_der } from "node-opcua-crypto/web";
|
|
9
|
+
import { readCertificate, readPrivateKey } from "node-opcua-crypto";
|
|
10
10
|
export interface ICertificateKeyPairProvider {
|
|
11
11
|
getCertificate(): Certificate;
|
|
12
12
|
getCertificateChain(): Certificate;
|
|
@@ -61,11 +61,6 @@ export interface IOPCUASecureObjectOptions {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* an object that provides a certificate and a privateKey
|
|
64
|
-
* @class OPCUASecureObject
|
|
65
|
-
* @param options
|
|
66
|
-
* @param options.certificateFile {string}
|
|
67
|
-
* @param options.privateKeyFile {string}
|
|
68
|
-
* @constructor
|
|
69
64
|
*/
|
|
70
65
|
export class OPCUASecureObject extends EventEmitter implements ICertificateKeyPairProvider {
|
|
71
66
|
public readonly certificateFile: string;
|