node-opcua-crypto 5.3.0 → 5.3.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.
- package/dist/{chunk-7GWSCCWS.cjs → chunk-IKQT3ICS.cjs} +96 -22
- package/dist/chunk-IKQT3ICS.cjs.map +1 -0
- package/dist/{chunk-KCVNMSLI.js → chunk-ODR4HUB7.js} +66 -15
- package/dist/chunk-ODR4HUB7.js.map +1 -0
- package/dist/{chunk-ERHE4VFS.cjs → chunk-TSW463FI.cjs} +68 -17
- package/dist/chunk-TSW463FI.cjs.map +1 -0
- package/dist/{chunk-QGNXSXUU.js → chunk-UEEZA3YS.js} +82 -8
- package/dist/chunk-UEEZA3YS.js.map +1 -0
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -5
- package/dist/source/index_web.cjs +6 -2
- package/dist/source/index_web.cjs.map +1 -1
- package/dist/source/index_web.d.cts +10 -1
- package/dist/source/index_web.d.ts +10 -1
- package/dist/source/index_web.js +7 -3
- package/dist/source_nodejs/index.cjs +19 -3
- package/dist/source_nodejs/index.cjs.map +1 -1
- package/dist/source_nodejs/index.d.cts +67 -2
- package/dist/source_nodejs/index.d.ts +67 -2
- package/dist/source_nodejs/index.js +20 -4
- package/package.json +5 -5
- package/dist/chunk-7GWSCCWS.cjs.map +0 -1
- package/dist/chunk-ERHE4VFS.cjs.map +0 -1
- package/dist/chunk-KCVNMSLI.js.map +0 -1
- package/dist/chunk-QGNXSXUU.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
|
|
2
2
|
var __export = (target, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -1168,41 +1168,90 @@ function readTbsCertificate(buffer, block) {
|
|
|
1168
1168
|
extensions
|
|
1169
1169
|
};
|
|
1170
1170
|
}
|
|
1171
|
+
var LRUCache = (_class = class {
|
|
1172
|
+
constructor(maxSize) {;_class.prototype.__init.call(this);
|
|
1173
|
+
this.maxSize = maxSize;
|
|
1174
|
+
}
|
|
1175
|
+
__init() {this.map = /* @__PURE__ */ new Map()}
|
|
1176
|
+
get(key) {
|
|
1177
|
+
if (!this.map.has(key)) {
|
|
1178
|
+
return void 0;
|
|
1179
|
+
}
|
|
1180
|
+
const val = this.map.get(key);
|
|
1181
|
+
if (val !== void 0) {
|
|
1182
|
+
this.map.delete(key);
|
|
1183
|
+
this.map.set(key, val);
|
|
1184
|
+
return val;
|
|
1185
|
+
}
|
|
1186
|
+
return void 0;
|
|
1187
|
+
}
|
|
1188
|
+
set(key, value) {
|
|
1189
|
+
if (this.map.has(key)) {
|
|
1190
|
+
this.map.delete(key);
|
|
1191
|
+
} else if (this.map.size >= this.maxSize) {
|
|
1192
|
+
const oldestKey = this.map.keys().next().value;
|
|
1193
|
+
if (oldestKey !== void 0) {
|
|
1194
|
+
this.map.delete(oldestKey);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
this.map.set(key, value);
|
|
1198
|
+
}
|
|
1199
|
+
clear() {
|
|
1200
|
+
this.map.clear();
|
|
1201
|
+
}
|
|
1202
|
+
}, _class);
|
|
1203
|
+
var exploreCertificateCache = new LRUCache(1e3);
|
|
1204
|
+
function clearExploreCertificateCache() {
|
|
1205
|
+
exploreCertificateCache.clear();
|
|
1206
|
+
}
|
|
1171
1207
|
function exploreCertificate(certificate) {
|
|
1172
1208
|
_assert2.default.call(void 0, Buffer.isBuffer(certificate));
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1209
|
+
const key = certificate.toString("base64");
|
|
1210
|
+
let cached = exploreCertificateCache.get(key);
|
|
1211
|
+
if (!cached) {
|
|
1212
|
+
verify_certificate_der_structure(certificate);
|
|
1175
1213
|
const block_info = readTag(certificate, 0);
|
|
1176
1214
|
const blocks = readStruct(certificate, block_info);
|
|
1177
|
-
|
|
1215
|
+
cached = {
|
|
1178
1216
|
tbsCertificate: readTbsCertificate(certificate, blocks[0]),
|
|
1179
1217
|
signatureAlgorithm: readAlgorithmIdentifier(certificate, blocks[1]),
|
|
1180
1218
|
signatureValue: readSignatureValue(certificate, blocks[2])
|
|
1181
1219
|
};
|
|
1220
|
+
exploreCertificateCache.set(key, cached);
|
|
1182
1221
|
}
|
|
1183
|
-
return
|
|
1222
|
+
return cached;
|
|
1184
1223
|
}
|
|
1185
1224
|
function split_der(certificateChain) {
|
|
1186
1225
|
const certificate_chain = [];
|
|
1187
1226
|
do {
|
|
1188
1227
|
const block_info = readTag(certificateChain, 0);
|
|
1189
1228
|
const length = block_info.position + block_info.length;
|
|
1229
|
+
if (length > certificateChain.length) {
|
|
1230
|
+
throw new Error("Invalid certificate chain: block length exceeds buffer length");
|
|
1231
|
+
}
|
|
1190
1232
|
const der_certificate = certificateChain.subarray(0, length);
|
|
1191
1233
|
certificate_chain.push(der_certificate);
|
|
1192
1234
|
certificateChain = certificateChain.subarray(length);
|
|
1193
1235
|
} while (certificateChain.length > 0);
|
|
1194
1236
|
return certificate_chain;
|
|
1195
1237
|
}
|
|
1238
|
+
function verify_certificate_der_structure(cert) {
|
|
1239
|
+
const blocks = split_der(cert);
|
|
1240
|
+
let sum = 0;
|
|
1241
|
+
for (const block of blocks) {
|
|
1242
|
+
const block_info = readTag(block, 0);
|
|
1243
|
+
if (block_info.position + block_info.length !== block.length) {
|
|
1244
|
+
throw new Error("Invalid certificate buffer: block length doesn't match");
|
|
1245
|
+
}
|
|
1246
|
+
sum += block.length;
|
|
1247
|
+
}
|
|
1248
|
+
if (sum !== cert.length) {
|
|
1249
|
+
throw new Error("Invalid certificate buffer: total block length doesn't match buffer length");
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1196
1252
|
function combine_der(certificates) {
|
|
1197
1253
|
for (const cert of certificates) {
|
|
1198
|
-
|
|
1199
|
-
let sum = 0;
|
|
1200
|
-
b.forEach((block) => {
|
|
1201
|
-
const block_info = readTag(block, 0);
|
|
1202
|
-
_assert2.default.call(void 0, block_info.position + block_info.length === block.length);
|
|
1203
|
-
sum += block.length;
|
|
1204
|
-
});
|
|
1205
|
-
_assert2.default.call(void 0, sum === cert.length);
|
|
1254
|
+
verify_certificate_der_structure(cert);
|
|
1206
1255
|
}
|
|
1207
1256
|
return Buffer.concat(certificates);
|
|
1208
1257
|
}
|
|
@@ -1311,13 +1360,13 @@ async function verifyCertificateChain(certificateChain) {
|
|
|
1311
1360
|
if (!certInfo.tbsCertificate.extensions) {
|
|
1312
1361
|
return {
|
|
1313
1362
|
status: "BadCertificateInvalid",
|
|
1314
|
-
reason: "Cannot find
|
|
1363
|
+
reason: "Cannot find X509 Extension 3 in certificate"
|
|
1315
1364
|
};
|
|
1316
1365
|
}
|
|
1317
1366
|
if (!certParentInfo.tbsCertificate.extensions || !certInfo.tbsCertificate.extensions.authorityKeyIdentifier) {
|
|
1318
1367
|
return {
|
|
1319
1368
|
status: "BadCertificateInvalid",
|
|
1320
|
-
reason: "Cannot find
|
|
1369
|
+
reason: "Cannot find X509 Extension 3 in certificate (parent)"
|
|
1321
1370
|
};
|
|
1322
1371
|
}
|
|
1323
1372
|
if (certParentInfo.tbsCertificate.extensions.subjectKeyIdentifier !== certInfo.tbsCertificate.extensions.authorityKeyIdentifier.keyIdentifier) {
|
|
@@ -6502,7 +6551,9 @@ var asn1 = { readDirectoryName, readTag, readStruct, readAlgorithmIdentifier, re
|
|
|
6502
6551
|
|
|
6503
6552
|
|
|
6504
6553
|
|
|
6505
|
-
|
|
6554
|
+
|
|
6555
|
+
|
|
6556
|
+
exports.createPrivateKeyFromNodeJSCrypto = createPrivateKeyFromNodeJSCrypto; exports.isKeyObject = isKeyObject; exports.CertificatePurpose = CertificatePurpose; exports.identifyPemType = identifyPemType; exports.removeTrailingLF = removeTrailingLF; exports.toPem = toPem; exports.convertPEMtoDER = convertPEMtoDER; exports.hexDump = hexDump; exports.makeMessageChunkSignature = makeMessageChunkSignature; exports.verifyMessageChunkSignature = verifyMessageChunkSignature; exports.makeSHA1Thumbprint = makeSHA1Thumbprint; exports.RSA_PKCS1_OAEP_PADDING = RSA_PKCS1_OAEP_PADDING; exports.RSA_PKCS1_PADDING = RSA_PKCS1_PADDING; exports.PaddingAlgorithm = PaddingAlgorithm; exports.publicEncrypt_native = publicEncrypt_native; exports.privateDecrypt_native = privateDecrypt_native; exports.publicEncrypt = publicEncrypt; exports.privateDecrypt = privateDecrypt; exports.publicEncrypt_long = publicEncrypt_long; exports.privateDecrypt_long = privateDecrypt_long; exports.coerceCertificatePem = coerceCertificatePem; exports.extractPublicKeyFromCertificateSync = extractPublicKeyFromCertificateSync; exports.extractPublicKeyFromCertificate = extractPublicKeyFromCertificate; exports.readExtension = readExtension; exports.readTbsCertificate = readTbsCertificate; exports.clearExploreCertificateCache = clearExploreCertificateCache; exports.exploreCertificate = exploreCertificate; exports.split_der = split_der; exports.verify_certificate_der_structure = verify_certificate_der_structure; exports.combine_der = combine_der; exports.readNameForCrl = readNameForCrl; exports.exploreCertificateRevocationList = exploreCertificateRevocationList; exports.verifyCertificateOrClrSignature = verifyCertificateOrClrSignature; exports.verifyCertificateSignature = verifyCertificateSignature; exports.verifyCertificateRevocationListSignature = verifyCertificateRevocationListSignature; exports.verifyCertificateChain = verifyCertificateChain; exports.isCrlIssuedByCertificate = isCrlIssuedByCertificate; exports.verifyCrlIssuedByCertificate = verifyCrlIssuedByCertificate; exports.exploreAsn1 = exploreAsn1; exports.coerceCertificate = coerceCertificate; exports.exploreCertificateInfo = exploreCertificateInfo; exports.readCertificationRequestInfo = readCertificationRequestInfo; exports.exploreCertificateSigningRequest = exploreCertificateSigningRequest; exports.explorePrivateKey = explorePrivateKey; exports.identifyDERContent = identifyDERContent; exports.Subject = Subject; exports.generateKeyPair = generateKeyPair; exports.generatePrivateKey = generatePrivateKey; exports.privateKeyToPEM = privateKeyToPEM; exports.derToPrivateKey = derToPrivateKey; exports.pemToPrivateKey = pemToPrivateKey; exports.coercePEMorDerToPrivateKey = coercePEMorDerToPrivateKey; exports._coercePrivateKey = _coercePrivateKey; exports.createCertificateSigningRequest = createCertificateSigningRequest; exports.createSelfSignedCertificate = createSelfSignedCertificate; exports.rsaLengthPrivateKey = rsaLengthPrivateKey; exports.toPem2 = toPem2; exports.coercePrivateKeyPem = coercePrivateKeyPem; exports.coercePublicKeyPem = coercePublicKeyPem; exports.coerceRsaPublicKeyPem = coerceRsaPublicKeyPem; exports.rsaLengthPublicKey = rsaLengthPublicKey; exports.rsaLengthRsaPublicKey = rsaLengthRsaPublicKey; exports.makePseudoRandomBuffer = makePseudoRandomBuffer; exports.computeDerivedKeys = computeDerivedKeys; exports.reduceLength = reduceLength; exports.removePadding = removePadding; exports.verifyChunkSignature = verifyChunkSignature; exports.computePaddingFooter = computePaddingFooter; exports.encryptBufferWithDerivedKeys = encryptBufferWithDerivedKeys; exports.decryptBufferWithDerivedKeys = decryptBufferWithDerivedKeys; exports.makeMessageChunkSignatureWithDerivedKeys = makeMessageChunkSignatureWithDerivedKeys; exports.verifyChunkSignatureWithDerivedKeys = verifyChunkSignatureWithDerivedKeys; exports.makePrivateKeyFromPem = makePrivateKeyFromPem; exports.makePrivateKeyThumbPrint = makePrivateKeyThumbPrint; exports.publicKeyAndPrivateKeyMatches = publicKeyAndPrivateKeyMatches; exports.certificateMatchesPrivateKey = certificateMatchesPrivateKey; exports.asn1 = asn1;
|
|
6506
6557
|
/*! Bundled license information:
|
|
6507
6558
|
|
|
6508
6559
|
pvtsutils/build/index.es.js:
|
|
@@ -6571,4 +6622,4 @@ asn1js/build/index.es.js:
|
|
|
6571
6622
|
*
|
|
6572
6623
|
*)
|
|
6573
6624
|
*/
|
|
6574
|
-
//# sourceMappingURL=chunk-
|
|
6625
|
+
//# sourceMappingURL=chunk-TSW463FI.cjs.map
|