node-opcua-crypto 4.6.1 → 4.6.2

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.
@@ -19,8 +19,8 @@ var getDirname = () => path.dirname(getFilename());
19
19
  var __dirname = /* @__PURE__ */ getDirname();
20
20
 
21
21
  // source/common.ts
22
- import { KeyObject as KeyObjectOrig } from "crypto";
23
22
  import __crypto from "crypto";
23
+ var KeyObjectOrig = __crypto.KeyObject;
24
24
  var { createPrivateKey: createPrivateKeyFromNodeJSCrypto } = __crypto;
25
25
  function isKeyObject(mayBeKeyObject) {
26
26
  if (KeyObjectOrig) {
@@ -6253,4 +6253,4 @@ asn1js/build/index.es.js:
6253
6253
  *
6254
6254
  *)
6255
6255
  */
6256
- //# sourceMappingURL=chunk-D3SBIIXU.mjs.map
6256
+ //# sourceMappingURL=chunk-KDZI3R4E.mjs.map
@@ -6,7 +6,7 @@ import {
6
6
  privateKeyToPEM,
7
7
  removeTrailingLF,
8
8
  toPem
9
- } from "./chunk-D3SBIIXU.mjs";
9
+ } from "./chunk-KDZI3R4E.mjs";
10
10
 
11
11
  // source_nodejs/read.ts
12
12
  import assert from "assert";
@@ -170,4 +170,4 @@ export {
170
170
  generatePrivateKeyFile,
171
171
  generatePrivateKeyFileAlternate
172
172
  };
173
- //# sourceMappingURL=chunk-R33OLRZV.mjs.map
173
+ //# sourceMappingURL=chunk-QFXQNKGH.mjs.map
@@ -142,12 +142,12 @@ __export(node_opcua_crypto_exports, {
142
142
  module.exports = __toCommonJS(node_opcua_crypto_exports);
143
143
 
144
144
  // source/common.ts
145
- var import_crypto = require("crypto");
146
- var import_crypto2 = __toESM(require("crypto"));
147
- var { createPrivateKey: createPrivateKeyFromNodeJSCrypto } = import_crypto2.default;
145
+ var import_crypto = __toESM(require("crypto"));
146
+ var KeyObjectOrig = import_crypto.default.KeyObject;
147
+ var { createPrivateKey: createPrivateKeyFromNodeJSCrypto } = import_crypto.default;
148
148
  function isKeyObject(mayBeKeyObject) {
149
- if (import_crypto.KeyObject) {
150
- return mayBeKeyObject instanceof import_crypto.KeyObject;
149
+ if (KeyObjectOrig) {
150
+ return mayBeKeyObject instanceof KeyObjectOrig;
151
151
  }
152
152
  return typeof mayBeKeyObject === "object" && typeof mayBeKeyObject.type === "string";
153
153
  }
@@ -161,7 +161,7 @@ var CertificatePurpose = /* @__PURE__ */ ((CertificatePurpose2) => {
161
161
 
162
162
  // source/derived_keys.ts
163
163
  var import_assert5 = __toESM(require("assert"));
164
- var import_crypto4 = require("crypto");
164
+ var import_crypto3 = require("crypto");
165
165
 
166
166
  // source/buffer_utils.ts
167
167
  var createFastUninitializedBuffer = Buffer.allocUnsafe ? Buffer.allocUnsafe : (size) => {
@@ -171,7 +171,7 @@ var createFastUninitializedBuffer = Buffer.allocUnsafe ? Buffer.allocUnsafe : (s
171
171
  // source/crypto_utils.ts
172
172
  var import_constants = __toESM(require("constants"));
173
173
  var import_assert3 = __toESM(require("assert"));
174
- var import_crypto3 = require("crypto");
174
+ var import_crypto2 = require("crypto");
175
175
  var import_hexy = __toESM(require("hexy"));
176
176
 
177
177
  // source/crypto_explore_certificate.ts
@@ -1173,19 +1173,19 @@ function hexDump(buffer, width) {
1173
1173
  }
1174
1174
  }
1175
1175
  function makeMessageChunkSignature(chunk, options) {
1176
- const signer = (0, import_crypto3.createSign)(options.algorithm);
1176
+ const signer = (0, import_crypto2.createSign)(options.algorithm);
1177
1177
  signer.update(chunk);
1178
1178
  const signature = signer.sign(options.privateKey.hidden);
1179
1179
  (0, import_assert3.default)(!options.signatureLength || signature.length === options.signatureLength);
1180
1180
  return signature;
1181
1181
  }
1182
1182
  function verifyMessageChunkSignature(blockToVerify, signature, options) {
1183
- const verify = (0, import_crypto3.createVerify)(options.algorithm);
1183
+ const verify = (0, import_crypto2.createVerify)(options.algorithm);
1184
1184
  verify.update(blockToVerify);
1185
1185
  return verify.verify(options.publicKey, signature);
1186
1186
  }
1187
1187
  function makeSHA1Thumbprint(buffer) {
1188
- return (0, import_crypto3.createHash)("sha1").update(buffer).digest();
1188
+ return (0, import_crypto2.createHash)("sha1").update(buffer).digest();
1189
1189
  }
1190
1190
  var RSA_PKCS1_OAEP_PADDING = import_constants.default.RSA_PKCS1_OAEP_PADDING;
1191
1191
  var RSA_PKCS1_PADDING = import_constants.default.RSA_PKCS1_PADDING;
@@ -1200,7 +1200,7 @@ function publicEncrypt_native(buffer, publicKey, algorithm) {
1200
1200
  if (algorithm === void 0) {
1201
1201
  algorithm = 1 /* RSA_PKCS1_PADDING */;
1202
1202
  }
1203
- return (0, import_crypto3.publicEncrypt)(
1203
+ return (0, import_crypto2.publicEncrypt)(
1204
1204
  {
1205
1205
  key: publicKey,
1206
1206
  padding: algorithm
@@ -1213,7 +1213,7 @@ function privateDecrypt_native(buffer, privateKey, algorithm) {
1213
1213
  algorithm = 1 /* RSA_PKCS1_PADDING */;
1214
1214
  }
1215
1215
  try {
1216
- return (0, import_crypto3.privateDecrypt)(
1216
+ return (0, import_crypto2.privateDecrypt)(
1217
1217
  {
1218
1218
  key: privateKey.hidden,
1219
1219
  padding: algorithm
@@ -1316,7 +1316,7 @@ function exploreCertificateInfo(certificate) {
1316
1316
 
1317
1317
  // source/derived_keys.ts
1318
1318
  function HMAC_HASH(sha1or256, secret, message) {
1319
- return (0, import_crypto4.createHmac)(sha1or256, secret).update(message).digest();
1319
+ return (0, import_crypto3.createHmac)(sha1or256, secret).update(message).digest();
1320
1320
  }
1321
1321
  function plus(buf1, buf2) {
1322
1322
  return Buffer.concat([buf1, buf2]);
@@ -1393,7 +1393,7 @@ function encryptBufferWithDerivedKeys(buffer, derivedKeys) {
1393
1393
  const algorithm = derivedKeys_algorithm(derivedKeys);
1394
1394
  const key = derivedKeys.encryptingKey;
1395
1395
  const initVector = derivedKeys.initializationVector;
1396
- const cipher = (0, import_crypto4.createCipheriv)(algorithm, key, initVector);
1396
+ const cipher = (0, import_crypto3.createCipheriv)(algorithm, key, initVector);
1397
1397
  cipher.setAutoPadding(false);
1398
1398
  const encrypted_chunks = [];
1399
1399
  encrypted_chunks.push(cipher.update(buffer));
@@ -1404,7 +1404,7 @@ function decryptBufferWithDerivedKeys(buffer, derivedKeys) {
1404
1404
  const algorithm = derivedKeys_algorithm(derivedKeys);
1405
1405
  const key = derivedKeys.encryptingKey;
1406
1406
  const initVector = derivedKeys.initializationVector;
1407
- const cipher = (0, import_crypto4.createDecipheriv)(algorithm, key, initVector);
1407
+ const cipher = (0, import_crypto3.createDecipheriv)(algorithm, key, initVector);
1408
1408
  cipher.setAutoPadding(false);
1409
1409
  const decrypted_chunks = [];
1410
1410
  decrypted_chunks.push(cipher.update(buffer));
@@ -1416,7 +1416,7 @@ function makeMessageChunkSignatureWithDerivedKeys(message, derivedKeys) {
1416
1416
  (0, import_assert5.default)(derivedKeys.signingKey instanceof Buffer);
1417
1417
  (0, import_assert5.default)(typeof derivedKeys.sha1or256 === "string");
1418
1418
  (0, import_assert5.default)(derivedKeys.sha1or256 === "SHA1" || derivedKeys.sha1or256 === "SHA256");
1419
- const signature = (0, import_crypto4.createHmac)(derivedKeys.sha1or256, derivedKeys.signingKey).update(message).digest();
1419
+ const signature = (0, import_crypto3.createHmac)(derivedKeys.sha1or256, derivedKeys.signingKey).update(message).digest();
1420
1420
  (0, import_assert5.default)(signature.length === derivedKeys.signatureLength);
1421
1421
  return signature;
1422
1422
  }
@@ -1484,7 +1484,7 @@ function rsaLengthRsaPublicKey(key) {
1484
1484
  }
1485
1485
 
1486
1486
  // source/verify_certificate_signature.ts
1487
- var import_crypto5 = require("crypto");
1487
+ var import_crypto4 = require("crypto");
1488
1488
  function verifyCertificateOrClrSignature(certificateOrCrl, parentCertificate) {
1489
1489
  const block_info = readTag(certificateOrCrl, 0);
1490
1490
  const blocks = _readStruct(certificateOrCrl, block_info);
@@ -1493,7 +1493,7 @@ function verifyCertificateOrClrSignature(certificateOrCrl, parentCertificate) {
1493
1493
  const signatureValue = _readSignatureValueBin(certificateOrCrl, blocks[2]);
1494
1494
  const p = split_der(parentCertificate)[0];
1495
1495
  const certPem = toPem(p, "CERTIFICATE");
1496
- const verify = (0, import_crypto5.createVerify)(signatureAlgorithm.identifier);
1496
+ const verify = (0, import_crypto4.createVerify)(signatureAlgorithm.identifier);
1497
1497
  verify.update(bufferToBeSigned);
1498
1498
  verify.end();
1499
1499
  return verify.verify(certPem, signatureValue);
@@ -1751,12 +1751,12 @@ function certificateMatchesPrivateKey(certificate, privateKey) {
1751
1751
  // source/x509/_crypto.ts
1752
1752
  var x509 = __toESM(require("@peculiar/x509"));
1753
1753
  var import_webcrypto = require("@peculiar/webcrypto");
1754
- var import_crypto6 = __toESM(require("crypto"));
1754
+ var import_crypto5 = __toESM(require("crypto"));
1755
1755
  var x5092 = __toESM(require("@peculiar/x509"));
1756
1756
  var _crypto;
1757
1757
  var ignoreCrypto = process.env.IGNORE_SUBTLE_FROM_CRYPTO;
1758
1758
  if (typeof window === "undefined") {
1759
- _crypto = import_crypto6.default;
1759
+ _crypto = import_crypto5.default;
1760
1760
  if (!_crypto?.subtle || ignoreCrypto) {
1761
1761
  _crypto = new import_webcrypto.Crypto();
1762
1762
  console.warn("using @peculiar/webcrypto");
@@ -6212,7 +6212,7 @@ function makePrivateKeyFromPem(privateKeyInPem) {
6212
6212
  var import_assert7 = __toESM(require("assert"));
6213
6213
  var import_fs = __toESM(require("fs"));
6214
6214
  var import_path = __toESM(require("path"));
6215
- var import_crypto14 = require("crypto");
6215
+ var import_crypto13 = require("crypto");
6216
6216
  var import_sshpk = __toESM(require("sshpk"));
6217
6217
  function _readPemFile(filename) {
6218
6218
  (0, import_assert7.default)(typeof filename === "string");
@@ -6231,14 +6231,14 @@ function readCertificate(filename) {
6231
6231
  function readPublicKey(filename) {
6232
6232
  if (filename.match(/.*\.der/)) {
6233
6233
  const der = import_fs.default.readFileSync(filename);
6234
- return (0, import_crypto14.createPublicKey)(der);
6234
+ return (0, import_crypto13.createPublicKey)(der);
6235
6235
  } else {
6236
6236
  const raw_key = _readPemFile(filename);
6237
- return (0, import_crypto14.createPublicKey)(raw_key);
6237
+ return (0, import_crypto13.createPublicKey)(raw_key);
6238
6238
  }
6239
6239
  }
6240
6240
  function myCreatePrivateKey(rawKey) {
6241
- if (!import_crypto14.createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {
6241
+ if (!import_crypto13.createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {
6242
6242
  if (rawKey instanceof Buffer) {
6243
6243
  const pemKey = toPem(rawKey, "PRIVATE KEY");
6244
6244
  (0, import_assert7.default)(["RSA PRIVATE KEY", "PRIVATE KEY"].indexOf(identifyPemType(pemKey)) >= 0);
@@ -6248,7 +6248,7 @@ function myCreatePrivateKey(rawKey) {
6248
6248
  }
6249
6249
  const backup = process.env.OPENSSL_CONF;
6250
6250
  process.env.OPENSSL_CONF = "/dev/null";
6251
- const retValue = (0, import_crypto14.createPrivateKey)(rawKey);
6251
+ const retValue = (0, import_crypto13.createPrivateKey)(rawKey);
6252
6252
  process.env.OPENSSL_CONF = backup;
6253
6253
  return { hidden: retValue };
6254
6254
  }
@@ -6289,7 +6289,7 @@ function getCertificateStore() {
6289
6289
  return _g_certificate_store;
6290
6290
  }
6291
6291
  function readPrivateRsaKey(filename) {
6292
- if (!import_crypto14.createPrivateKey) {
6292
+ if (!import_crypto13.createPrivateKey) {
6293
6293
  throw new Error("createPrivateKey is not supported in this environment");
6294
6294
  }
6295
6295
  if (filename.substring(0, 1) !== "." && !import_fs.default.existsSync(filename)) {
@@ -6298,7 +6298,7 @@ function readPrivateRsaKey(filename) {
6298
6298
  const content = import_fs.default.readFileSync(filename, "utf8");
6299
6299
  const sshKey = import_sshpk.default.parsePrivateKey(content, "auto");
6300
6300
  const key = sshKey.toString("pkcs1");
6301
- const hidden = (0, import_crypto14.createPrivateKey)({ format: "pem", type: "pkcs1", key });
6301
+ const hidden = (0, import_crypto13.createPrivateKey)({ format: "pem", type: "pkcs1", key });
6302
6302
  return { hidden };
6303
6303
  }
6304
6304
  function readPublicRsaKey(filename) {
@@ -6308,7 +6308,7 @@ function readPublicRsaKey(filename) {
6308
6308
  const content = import_fs.default.readFileSync(filename, "utf-8");
6309
6309
  const sshKey = import_sshpk.default.parseKey(content, "ssh");
6310
6310
  const key = sshKey.toString("pkcs1");
6311
- return (0, import_crypto14.createPublicKey)({ format: "pem", type: "pkcs1", key });
6311
+ return (0, import_crypto13.createPublicKey)({ format: "pem", type: "pkcs1", key });
6312
6312
  }
6313
6313
 
6314
6314
  // source_nodejs/read_certificate_revocation_list.ts
@@ -14,7 +14,7 @@ import {
14
14
  readPublicKeyPEM,
15
15
  readPublicRsaKey,
16
16
  setCertificateStore
17
- } from "./chunk-R33OLRZV.mjs";
17
+ } from "./chunk-QFXQNKGH.mjs";
18
18
  import "./chunk-5NV4OKIV.mjs";
19
19
  import {
20
20
  CertificatePurpose,
@@ -110,7 +110,7 @@ import {
110
110
  verifyChunkSignature,
111
111
  verifyChunkSignatureWithDerivedKeys,
112
112
  verifyMessageChunkSignature
113
- } from "./chunk-D3SBIIXU.mjs";
113
+ } from "./chunk-KDZI3R4E.mjs";
114
114
  export {
115
115
  CertificatePurpose,
116
116
  PaddingAlgorithm,
@@ -0,0 +1,4 @@
1
+ export { C as Certificate, d as CertificatePEM, h as CertificatePurpose, g as CertificateRevocationList, D as DER, K as KeyObject, N as Nonce, b as PEM, P as PrivateKey, e as PrivateKeyPEM, a as PublicKey, f as PublicKeyPEM, S as Signature, c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from './common-0xc4gZF8.js';
2
+ export { AlgorithmIdentifier, AttributeTypeAndValue, AuthorityKeyIdentifier, BasicConstraints, BitString, BlockInfo, CertificateExtension, CertificateInfo, CertificateInternals, CertificateRevocationListInfo, CertificateSerialNumber, CertificateSigningRequestInfo, ComputeDerivedKeysOptions, CreateSelfSignCertificateOptions, DerivedKeys, DirectoryName, ExtensionRequest, Extensions, Name, PaddingAlgorithm, PrivateKeyInternals, PublicKeyLength, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, RevokedCertificate, SignatureValue, Subject, SubjectOptions, SubjectPublicKey, SubjectPublicKeyInfo, TBSCertList, TagType, TbsCertificate, Validity, VerifyChunkSignatureOptions, VerifyMessageChunkSignatureOptions, Version, X509ExtKeyUsage, X509KeyUsage, _VerifyStatus, _coercePrivateKey, _findBlockAtIndex, _getBlock, _readAlgorithmIdentifier, _readBitString, _readBooleanValue, _readDirectoryName, _readECCAlgorithmIdentifier, _readExtension, _readIntegerAsByteString, _readIntegerValue, _readListOfInteger, _readLongIntegerValue, _readObjectIdentifier, _readOctetString, _readSignatureValue, _readSignatureValueBin, _readStruct, _readTime, _readValue, _readVersionValue, certificateMatchesPrivateKey, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, compactDirectoryName, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, formatBuffer2DigitHexWithColum, generateKeyPair, generatePrivateKey, hexDump, identifyPemType, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePseudoRandomBuffer, makeSHA1Thumbprint, parseBitString, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readNameForCrl, readTag, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyMessageChunkSignature } from './source/index.mjs';
3
+ import 'crypto';
4
+ import '@peculiar/x509';
@@ -0,0 +1,4 @@
1
+ export { C as Certificate, d as CertificatePEM, h as CertificatePurpose, g as CertificateRevocationList, D as DER, K as KeyObject, N as Nonce, b as PEM, P as PrivateKey, e as PrivateKeyPEM, a as PublicKey, f as PublicKeyPEM, S as Signature, c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from './common-0xc4gZF8.js';
2
+ export { AlgorithmIdentifier, AttributeTypeAndValue, AuthorityKeyIdentifier, BasicConstraints, BitString, BlockInfo, CertificateExtension, CertificateInfo, CertificateInternals, CertificateRevocationListInfo, CertificateSerialNumber, CertificateSigningRequestInfo, ComputeDerivedKeysOptions, CreateSelfSignCertificateOptions, DerivedKeys, DirectoryName, ExtensionRequest, Extensions, Name, PaddingAlgorithm, PrivateKeyInternals, PublicKeyLength, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, RevokedCertificate, SignatureValue, Subject, SubjectOptions, SubjectPublicKey, SubjectPublicKeyInfo, TBSCertList, TagType, TbsCertificate, Validity, VerifyChunkSignatureOptions, VerifyMessageChunkSignatureOptions, Version, X509ExtKeyUsage, X509KeyUsage, _VerifyStatus, _coercePrivateKey, _findBlockAtIndex, _getBlock, _readAlgorithmIdentifier, _readBitString, _readBooleanValue, _readDirectoryName, _readECCAlgorithmIdentifier, _readExtension, _readIntegerAsByteString, _readIntegerValue, _readListOfInteger, _readLongIntegerValue, _readObjectIdentifier, _readOctetString, _readSignatureValue, _readSignatureValueBin, _readStruct, _readTime, _readValue, _readVersionValue, certificateMatchesPrivateKey, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, compactDirectoryName, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, formatBuffer2DigitHexWithColum, generateKeyPair, generatePrivateKey, hexDump, identifyPemType, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePseudoRandomBuffer, makeSHA1Thumbprint, parseBitString, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readNameForCrl, readTag, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyMessageChunkSignature } from './source/index.js';
3
+ import 'crypto';
4
+ import '@peculiar/x509';