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 CHANGED
@@ -9,14 +9,15 @@ NodeOPCUA Crypto is a powerful JavaScript module for handling security and crypt
9
9
  [![Coverage Status](https://coveralls.io/repos/github/node-opcua/node-opcua-crypto/badge.svg?branch=master)](https://coveralls.io/github/node-opcua/node-opcua-crypto?branch=master)
10
10
  [![install size](https://packagephobia.com/badge?p=node-opcua-crypto)](https://packagephobia.com/result?p=node-opcua-crypto)
11
11
  [![FOSSA Status](https://app.fossa.com/api/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto.svg?type=shield)](https://app.fossa.com/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto?ref=badge_shield)
12
+
12
13
  <!-- [![Test Coverage](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/coverage.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto/coverage) -->
13
14
 
14
15
  ## Features
15
16
 
16
- * a comprehensive set of cryptographic functionalities.
17
- * supports both Node.js and browser environments.
18
- * compatible with TypeScript for robust, type-safe coding.
19
- * implements advanced security standards for OPCUA.
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
- ``` bash
28
+ ```bash
28
29
  npm install nodeopcua-crypto
29
30
  ```
30
31
 
31
32
  ### Usage
32
33
 
33
- ``` bash
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
  [![Professional Support](https://img.shields.io/static/v1?style=for-the-badge&label=Professional&message=Support&labelColor=blue&color=green&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDQ5MS41MiA0OTEuNTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ5MS41MiA0OTEuNTI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxnPg0KCQk8cGF0aCBkPSJNNDg3Ljk4OSwzODkuNzU1bC05My4xMDktOTIuOTc2Yy00LjgxMy00LjgwNi0xMi42NDItNC42NzQtMTcuMjczLDAuMzA3Yy03LjE0OCw3LjY4OS0xNC42NCwxNS41NTQtMjEuNzMsMjIuNjM0ICAgIGMtMC4yNzEsMC4yNy0wLjUwMSwwLjQ5My0wLjc2MywwLjc1NUw0NjcuMyw0MzIuNTA0YzguOTEtMTAuNjE0LDE2LjY1Ny0yMC40MSwyMS43My0yNi45NyAgICBDNDkyLjcyLDQwMC43NjIsNDky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jwvZz4NCjxnPg0KPC9nPg0KPC9zdmc+)](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
- * Fork the repository.
92
- * Create a new branch.
93
- * Commit your changes.
94
- * Submit a pull request.
95
- * Sign the CLA (Contributor Licence Agreement) form
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 instanceof Buffer);
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 instanceof Buffer) {
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 instanceof Buffer ? removeTrailingLF(raw_key.toString("utf8")) : removeTrailingLF(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 instanceof Buffer) {
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 instanceof Buffer);
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 instanceof Buffer);
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 instanceof Buffer);
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 instanceof Buffer);
1481
- assert7(derivedKeys.signingKey instanceof Buffer);
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 instanceof Buffer) {
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-LHUQUHQQ.mjs.map
6297
+ //# sourceMappingURL=chunk-F5EAPW2U.mjs.map