node-opcua-crypto 4.12.0 → 4.16.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/README.md +15 -20
- package/dist/{chunk-LHUQUHQQ.mjs → chunk-F5EAPW2U.mjs} +11 -11
- package/dist/chunk-F5EAPW2U.mjs.map +1 -0
- package/dist/{chunk-AXAFLVME.mjs → chunk-XPM4YIBT.mjs} +4 -4
- package/dist/chunk-XPM4YIBT.mjs.map +1 -0
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/source/index.js +10 -10
- package/dist/source/index.js.map +1 -1
- package/dist/source/index.mjs +1 -1
- package/dist/source/index_web.js +10 -10
- package/dist/source/index_web.js.map +1 -1
- package/dist/source/index_web.mjs +1 -1
- package/dist/source_nodejs/index.js +4 -4
- package/dist/source_nodejs/index.js.map +1 -1
- package/dist/source_nodejs/index.mjs +2 -2
- package/package.json +4 -4
- package/dist/chunk-AXAFLVME.mjs.map +0 -1
- package/dist/chunk-LHUQUHQQ.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -9,14 +9,15 @@ NodeOPCUA Crypto is a powerful JavaScript module for handling security and crypt
|
|
|
9
9
|
[](https://coveralls.io/github/node-opcua/node-opcua-crypto?branch=master)
|
|
10
10
|
[](https://packagephobia.com/result?p=node-opcua-crypto)
|
|
11
11
|
[](https://app.fossa.com/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto?ref=badge_shield)
|
|
12
|
+
|
|
12
13
|
<!-- [](https://codeclimate.com/github/node-opcua/node-opcua-crypto/coverage) -->
|
|
13
14
|
|
|
14
15
|
## Features
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
- a comprehensive set of cryptographic functionalities.
|
|
18
|
+
- supports both Node.js and browser environments.
|
|
19
|
+
- compatible with TypeScript for robust, type-safe coding.
|
|
20
|
+
- implements advanced security standards for OPCUA.
|
|
20
21
|
|
|
21
22
|
## Getting Started
|
|
22
23
|
|
|
@@ -24,13 +25,13 @@ To use NodeOPCUA Crypto in your project, follow these steps:
|
|
|
24
25
|
|
|
25
26
|
#### Installation
|
|
26
27
|
|
|
27
|
-
```
|
|
28
|
+
```bash
|
|
28
29
|
npm install nodeopcua-crypto
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
### Usage
|
|
32
33
|
|
|
33
|
-
```
|
|
34
|
+
```bash
|
|
34
35
|
|
|
35
36
|
import { generatePrivateKey, privateKeyToPEM, CertificatePurpose, createSelfSignedCertificate } from "./node-opcua-crypto.js";
|
|
36
37
|
|
|
@@ -64,20 +65,16 @@ demonstratePrivateKeyAndSelfSignedCertificateCreation();
|
|
|
64
65
|
|
|
65
66
|
Please refer to the examples directory for more specific use cases and comprehensive samples.
|
|
66
67
|
|
|
67
|
-
|
|
68
68
|
## Support
|
|
69
69
|
|
|
70
70
|
Sterfive provides this module free of charge, "as is," with the hope that it will be useful to you. However, any support requests, bug fixes, or enhancements are handled exclusively through our paid services. We believe strongly that independent open-source companies should be fairly compensated for their contributions to the community.
|
|
71
71
|
|
|
72
72
|
We highly recommend subscribing to our support program to ensure your requests are addressed and resolved. Please note that we only consider requests from members of our support program or sponsors.
|
|
73
73
|
|
|
74
|
-
|
|
75
74
|
### Getting professional support
|
|
76
75
|
|
|
77
|
-
|
|
78
76
|
NodeOPCUA Crypto is developed and maintained by sterfive.com.
|
|
79
77
|
|
|
80
|
-
|
|
81
78
|
To get professional support, consider subscribing to the node-opcua membership community:
|
|
82
79
|
|
|
83
80
|
[](https://support.sterfive.com)
|
|
@@ -88,17 +85,17 @@ or contact [sterfive](https://www.sterfive.com) for dedicated consulting and mor
|
|
|
88
85
|
|
|
89
86
|
We appreciate contributions from the community. To contribute:
|
|
90
87
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
- Fork the repository.
|
|
89
|
+
- Create a new branch.
|
|
90
|
+
- Commit your changes.
|
|
91
|
+
- Submit a pull request.
|
|
92
|
+
- Sign the CLA (Contributor Licence Agreement) form
|
|
93
|
+
|
|
97
94
|
For more detailed instructions, refer to the CONTRIBUTING.md file.
|
|
98
95
|
|
|
99
96
|
## License
|
|
100
97
|
|
|
101
|
-
NodeOPCUA Crypto is MIT licensed. See the LICENSE file for full license details.
|
|
98
|
+
NodeOPCUA Crypto is MIT licensed. See the LICENSE file for full license details.
|
|
102
99
|
|
|
103
100
|
Copyright © 2023-2024 Sterfive.com.
|
|
104
101
|
|
|
@@ -110,9 +107,7 @@ Please report any issues or vulnerabilities you find via the issue tracker.
|
|
|
110
107
|
|
|
111
108
|
Thank you for considering NodeOPCUA Crypto for your OPCUA cryptography needs. We look forward to seeing what you build with i
|
|
112
109
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
## Supporting the development effort - Sponsors & Backers
|
|
110
|
+
## Supporting the development effort - Sponsors & Backers
|
|
116
111
|
|
|
117
112
|
If you like `node-opcua-crypto` and if you are relying on it in one of your projects, please consider becoming a backer and [sponsoring us](https://opencollective.com/node-opcua), this will help us to maintain a high-quality stack and constant evolution of this module.
|
|
118
113
|
|
|
@@ -955,7 +955,7 @@ function readTbsCertificate(buffer, block) {
|
|
|
955
955
|
};
|
|
956
956
|
}
|
|
957
957
|
function exploreCertificate(certificate) {
|
|
958
|
-
assert3(certificate
|
|
958
|
+
assert3(Buffer.isBuffer(certificate));
|
|
959
959
|
if (!certificate._exploreCertificate_cache) {
|
|
960
960
|
const block_info = readTag(certificate, 0);
|
|
961
961
|
const blocks = readStruct(certificate, block_info);
|
|
@@ -998,7 +998,7 @@ var { hexy } = pkg_hexy;
|
|
|
998
998
|
var PEM_REGEX = /^(-----BEGIN (.*)-----\r?\n([/+=a-zA-Z0-9\r\n]*)\r?\n-----END \2-----\r?\n?)/gm;
|
|
999
999
|
var PEM_TYPE_REGEX = /^(-----BEGIN (.*)-----)/m;
|
|
1000
1000
|
function identifyPemType(rawKey) {
|
|
1001
|
-
if (rawKey
|
|
1001
|
+
if (Buffer.isBuffer(rawKey)) {
|
|
1002
1002
|
rawKey = rawKey.toString("utf8");
|
|
1003
1003
|
}
|
|
1004
1004
|
const match = PEM_TYPE_REGEX.exec(rawKey);
|
|
@@ -1013,7 +1013,7 @@ function toPem(raw_key, pem) {
|
|
|
1013
1013
|
assert4(typeof pem === "string");
|
|
1014
1014
|
let pemType = identifyPemType(raw_key);
|
|
1015
1015
|
if (pemType) {
|
|
1016
|
-
return raw_key
|
|
1016
|
+
return Buffer.isBuffer(raw_key) ? removeTrailingLF(raw_key.toString("utf8")) : removeTrailingLF(raw_key);
|
|
1017
1017
|
} else {
|
|
1018
1018
|
pemType = pem;
|
|
1019
1019
|
assert4(["CERTIFICATE REQUEST", "CERTIFICATE", "RSA PRIVATE KEY", "PUBLIC KEY", "X509 CRL"].indexOf(pemType) >= 0);
|
|
@@ -1149,7 +1149,7 @@ function privateDecrypt_long(buffer, privateKey, blockSize, paddingAlgorithm) {
|
|
|
1149
1149
|
return outputBuffer.subarray(0, total_length);
|
|
1150
1150
|
}
|
|
1151
1151
|
function coerceCertificatePem(certificate) {
|
|
1152
|
-
if (certificate
|
|
1152
|
+
if (Buffer.isBuffer(certificate)) {
|
|
1153
1153
|
certificate = toPem(certificate, "CERTIFICATE");
|
|
1154
1154
|
}
|
|
1155
1155
|
assert4(typeof certificate === "string");
|
|
@@ -1360,7 +1360,7 @@ function coerceCertificate(certificate) {
|
|
|
1360
1360
|
if (typeof certificate === "string") {
|
|
1361
1361
|
certificate = convertPEMtoDER(certificate);
|
|
1362
1362
|
}
|
|
1363
|
-
assert6(certificate
|
|
1363
|
+
assert6(Buffer.isBuffer(certificate));
|
|
1364
1364
|
return certificate;
|
|
1365
1365
|
}
|
|
1366
1366
|
function exploreCertificateInfo(certificate) {
|
|
@@ -1387,7 +1387,7 @@ function plus(buf1, buf2) {
|
|
|
1387
1387
|
return Buffer.concat([buf1, buf2]);
|
|
1388
1388
|
}
|
|
1389
1389
|
function makePseudoRandomBuffer(secret, seed, minLength, sha1or256) {
|
|
1390
|
-
assert7(seed
|
|
1390
|
+
assert7(Buffer.isBuffer(seed));
|
|
1391
1391
|
assert7(sha1or256 === "SHA1" || sha1or256 === "SHA256");
|
|
1392
1392
|
const a = [];
|
|
1393
1393
|
a[0] = seed;
|
|
@@ -1431,7 +1431,7 @@ function removePadding(buffer) {
|
|
|
1431
1431
|
return reduceLength(buffer, nbPaddingBytes);
|
|
1432
1432
|
}
|
|
1433
1433
|
function verifyChunkSignature(chunk, options) {
|
|
1434
|
-
assert7(chunk
|
|
1434
|
+
assert7(Buffer.isBuffer(chunk));
|
|
1435
1435
|
let signatureLength = options.signatureLength || 0;
|
|
1436
1436
|
if (signatureLength === 0) {
|
|
1437
1437
|
const cert = exploreCertificateInfo(options.publicKey);
|
|
@@ -1477,8 +1477,8 @@ function decryptBufferWithDerivedKeys(buffer, derivedKeys) {
|
|
|
1477
1477
|
return Buffer.concat(decrypted_chunks);
|
|
1478
1478
|
}
|
|
1479
1479
|
function makeMessageChunkSignatureWithDerivedKeys(message, derivedKeys) {
|
|
1480
|
-
assert7(message
|
|
1481
|
-
assert7(derivedKeys.signingKey
|
|
1480
|
+
assert7(Buffer.isBuffer(message));
|
|
1481
|
+
assert7(Buffer.isBuffer(derivedKeys.signingKey));
|
|
1482
1482
|
assert7(typeof derivedKeys.sha1or256 === "string");
|
|
1483
1483
|
assert7(derivedKeys.sha1or256 === "SHA1" || derivedKeys.sha1or256 === "SHA256");
|
|
1484
1484
|
const signature = createHmac(derivedKeys.sha1or256, derivedKeys.signingKey).update(message).digest();
|
|
@@ -1866,7 +1866,7 @@ function coercePEMorDerToPrivateKey(privateKeyInDerOrPem) {
|
|
|
1866
1866
|
}
|
|
1867
1867
|
async function _coercePrivateKey(privateKey) {
|
|
1868
1868
|
const KeyObject4 = crypto2.KeyObject;
|
|
1869
|
-
if (privateKey
|
|
1869
|
+
if (Buffer.isBuffer(privateKey)) {
|
|
1870
1870
|
const privateKey1 = await derToPrivateKey(privateKey);
|
|
1871
1871
|
return KeyObject4.from(privateKey1);
|
|
1872
1872
|
} else if (typeof privateKey === "string") {
|
|
@@ -6294,4 +6294,4 @@ asn1js/build/index.es.js:
|
|
|
6294
6294
|
*
|
|
6295
6295
|
*)
|
|
6296
6296
|
*/
|
|
6297
|
-
//# sourceMappingURL=chunk-
|
|
6297
|
+
//# sourceMappingURL=chunk-F5EAPW2U.mjs.map
|