node-opcua-crypto 5.3.1 → 5.3.3
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-ISWOJ526.js → chunk-DC5KIPR2.js} +2 -2
- package/dist/{chunk-Z4PNMXBN.js → chunk-MFGOTDMX.js} +65 -13
- package/dist/chunk-MFGOTDMX.js.map +1 -0
- package/dist/{chunk-3KSBDOQT.cjs → chunk-R6I4NJSZ.cjs} +67 -15
- package/dist/chunk-R6I4NJSZ.cjs.map +1 -0
- package/dist/{chunk-MUTGGDEL.cjs → chunk-XJHDKGLH.cjs} +22 -22
- package/dist/{chunk-MUTGGDEL.cjs.map → chunk-XJHDKGLH.cjs.map} +1 -1
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- 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 +3 -3
- package/dist/source_nodejs/index.js +2 -2
- package/package.json +6 -5
- package/dist/chunk-3KSBDOQT.cjs.map +0 -1
- package/dist/chunk-Z4PNMXBN.js.map +0 -1
- /package/dist/{chunk-ISWOJ526.js.map → chunk-DC5KIPR2.js.map} +0 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
removeTrailingLF,
|
|
9
9
|
split_der,
|
|
10
10
|
toPem
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MFGOTDMX.js";
|
|
12
12
|
|
|
13
13
|
// source_nodejs/generate_private_key_filename.ts
|
|
14
14
|
import { generateKeyPairSync } from "crypto";
|
|
@@ -280,4 +280,4 @@ export {
|
|
|
280
280
|
writeCertificateChainDer,
|
|
281
281
|
writeCertificateChainDerAsync
|
|
282
282
|
};
|
|
283
|
-
//# sourceMappingURL=chunk-
|
|
283
|
+
//# sourceMappingURL=chunk-DC5KIPR2.js.map
|
|
@@ -1175,41 +1175,90 @@ function readTbsCertificate(buffer, block) {
|
|
|
1175
1175
|
extensions
|
|
1176
1176
|
};
|
|
1177
1177
|
}
|
|
1178
|
+
var LRUCache = class {
|
|
1179
|
+
constructor(maxSize) {
|
|
1180
|
+
this.maxSize = maxSize;
|
|
1181
|
+
}
|
|
1182
|
+
map = /* @__PURE__ */ new Map();
|
|
1183
|
+
get(key) {
|
|
1184
|
+
if (!this.map.has(key)) {
|
|
1185
|
+
return void 0;
|
|
1186
|
+
}
|
|
1187
|
+
const val = this.map.get(key);
|
|
1188
|
+
if (val !== void 0) {
|
|
1189
|
+
this.map.delete(key);
|
|
1190
|
+
this.map.set(key, val);
|
|
1191
|
+
return val;
|
|
1192
|
+
}
|
|
1193
|
+
return void 0;
|
|
1194
|
+
}
|
|
1195
|
+
set(key, value) {
|
|
1196
|
+
if (this.map.has(key)) {
|
|
1197
|
+
this.map.delete(key);
|
|
1198
|
+
} else if (this.map.size >= this.maxSize) {
|
|
1199
|
+
const oldestKey = this.map.keys().next().value;
|
|
1200
|
+
if (oldestKey !== void 0) {
|
|
1201
|
+
this.map.delete(oldestKey);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
this.map.set(key, value);
|
|
1205
|
+
}
|
|
1206
|
+
clear() {
|
|
1207
|
+
this.map.clear();
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
var exploreCertificateCache = new LRUCache(1e3);
|
|
1211
|
+
function clearExploreCertificateCache() {
|
|
1212
|
+
exploreCertificateCache.clear();
|
|
1213
|
+
}
|
|
1178
1214
|
function exploreCertificate(certificate) {
|
|
1179
1215
|
assert4(Buffer.isBuffer(certificate));
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1216
|
+
const key = certificate.toString("base64");
|
|
1217
|
+
let cached = exploreCertificateCache.get(key);
|
|
1218
|
+
if (!cached) {
|
|
1219
|
+
verify_certificate_der_structure(certificate);
|
|
1182
1220
|
const block_info = readTag(certificate, 0);
|
|
1183
1221
|
const blocks = readStruct(certificate, block_info);
|
|
1184
|
-
|
|
1222
|
+
cached = {
|
|
1185
1223
|
tbsCertificate: readTbsCertificate(certificate, blocks[0]),
|
|
1186
1224
|
signatureAlgorithm: readAlgorithmIdentifier(certificate, blocks[1]),
|
|
1187
1225
|
signatureValue: readSignatureValue(certificate, blocks[2])
|
|
1188
1226
|
};
|
|
1227
|
+
exploreCertificateCache.set(key, cached);
|
|
1189
1228
|
}
|
|
1190
|
-
return
|
|
1229
|
+
return cached;
|
|
1191
1230
|
}
|
|
1192
1231
|
function split_der(certificateChain) {
|
|
1193
1232
|
const certificate_chain = [];
|
|
1194
1233
|
do {
|
|
1195
1234
|
const block_info = readTag(certificateChain, 0);
|
|
1196
1235
|
const length = block_info.position + block_info.length;
|
|
1236
|
+
if (length > certificateChain.length) {
|
|
1237
|
+
throw new Error("Invalid certificate chain: block length exceeds buffer length");
|
|
1238
|
+
}
|
|
1197
1239
|
const der_certificate = certificateChain.subarray(0, length);
|
|
1198
1240
|
certificate_chain.push(der_certificate);
|
|
1199
1241
|
certificateChain = certificateChain.subarray(length);
|
|
1200
1242
|
} while (certificateChain.length > 0);
|
|
1201
1243
|
return certificate_chain;
|
|
1202
1244
|
}
|
|
1245
|
+
function verify_certificate_der_structure(cert) {
|
|
1246
|
+
const blocks = split_der(cert);
|
|
1247
|
+
let sum = 0;
|
|
1248
|
+
for (const block of blocks) {
|
|
1249
|
+
const block_info = readTag(block, 0);
|
|
1250
|
+
if (block_info.position + block_info.length !== block.length) {
|
|
1251
|
+
throw new Error("Invalid certificate buffer: block length doesn't match");
|
|
1252
|
+
}
|
|
1253
|
+
sum += block.length;
|
|
1254
|
+
}
|
|
1255
|
+
if (sum !== cert.length) {
|
|
1256
|
+
throw new Error("Invalid certificate buffer: total block length doesn't match buffer length");
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1203
1259
|
function combine_der(certificates) {
|
|
1204
1260
|
for (const cert of certificates) {
|
|
1205
|
-
|
|
1206
|
-
let sum = 0;
|
|
1207
|
-
b.forEach((block) => {
|
|
1208
|
-
const block_info = readTag(block, 0);
|
|
1209
|
-
assert4(block_info.position + block_info.length === block.length);
|
|
1210
|
-
sum += block.length;
|
|
1211
|
-
});
|
|
1212
|
-
assert4(sum === cert.length);
|
|
1261
|
+
verify_certificate_der_structure(cert);
|
|
1213
1262
|
}
|
|
1214
1263
|
return Buffer.concat(certificates);
|
|
1215
1264
|
}
|
|
@@ -1699,6 +1748,7 @@ var Subject = class _Subject {
|
|
|
1699
1748
|
// source/x509/_crypto.ts
|
|
1700
1749
|
import nativeCrypto from "crypto";
|
|
1701
1750
|
import { Crypto as PeculiarWebCrypto } from "@peculiar/webcrypto";
|
|
1751
|
+
import "reflect-metadata";
|
|
1702
1752
|
import * as x509 from "@peculiar/x509";
|
|
1703
1753
|
import * as x5092 from "@peculiar/x509";
|
|
1704
1754
|
var doDebug3 = false;
|
|
@@ -6460,8 +6510,10 @@ export {
|
|
|
6460
6510
|
extractPublicKeyFromCertificate,
|
|
6461
6511
|
readExtension,
|
|
6462
6512
|
readTbsCertificate,
|
|
6513
|
+
clearExploreCertificateCache,
|
|
6463
6514
|
exploreCertificate,
|
|
6464
6515
|
split_der,
|
|
6516
|
+
verify_certificate_der_structure,
|
|
6465
6517
|
combine_der,
|
|
6466
6518
|
readNameForCrl,
|
|
6467
6519
|
exploreCertificateRevocationList,
|
|
@@ -6579,4 +6631,4 @@ asn1js/build/index.es.js:
|
|
|
6579
6631
|
*
|
|
6580
6632
|
*)
|
|
6581
6633
|
*/
|
|
6582
|
-
//# sourceMappingURL=chunk-
|
|
6634
|
+
//# sourceMappingURL=chunk-MFGOTDMX.js.map
|