node-opcua-pki 6.6.0 → 6.7.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/dist/index.mjs CHANGED
@@ -2022,6 +2022,7 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
2022
2022
  return "BadCertificateInvalid" /* BadCertificateInvalid */;
2023
2023
  }
2024
2024
  if (certificates.length > 1) {
2025
+ await this.#scanCertFolder(this.issuersCertFolder, this.#thumbs.issuers.certs);
2025
2026
  for (const issuerCert of certificates.slice(1)) {
2026
2027
  const thumbprint = makeFingerprint(issuerCert);
2027
2028
  if (!await this.hasIssuer(thumbprint)) {
@@ -2372,9 +2373,7 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
2372
2373
  const h = this.#filenameToHash.get(filename);
2373
2374
  if (h && index.has(h)) {
2374
2375
  index.delete(h);
2375
- if (ready) {
2376
- this.emit("certificateRemoved", { store, fingerprint: h, filename });
2377
- }
2376
+ this.emit("certificateRemoved", { store, fingerprint: h, filename });
2378
2377
  }
2379
2378
  });
2380
2379
  w.on("add", (filename) => {
@@ -2383,6 +2382,7 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
2383
2382
  const certificate = readCertificate(filename);
2384
2383
  const info = exploreCertificate(certificate);
2385
2384
  const fingerprint = makeFingerprint(certificate);
2385
+ const isNew = !index.has(fingerprint);
2386
2386
  index.set(fingerprint, { certificate, filename, info });
2387
2387
  this.#filenameToHash.set(filename, fingerprint);
2388
2388
  debugLog(
@@ -2391,7 +2391,7 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
2391
2391
  info.tbsCertificate.serialNumber,
2392
2392
  info.tbsCertificate.extensions?.authorityKeyIdentifier?.authorityCertIssuerFingerPrint
2393
2393
  );
2394
- if (ready) {
2394
+ if (ready || isNew) {
2395
2395
  this.emit("certificateAdded", { store, certificate, fingerprint, filename });
2396
2396
  }
2397
2397
  } catch (err) {
@@ -2410,9 +2410,7 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
2410
2410
  }
2411
2411
  index.set(newFingerprint, { certificate, filename: changedPath, info: exploreCertificate(certificate) });
2412
2412
  this.#filenameToHash.set(changedPath, newFingerprint);
2413
- if (ready) {
2414
- this.emit("certificateChange", { store, certificate, fingerprint: newFingerprint, filename: changedPath });
2415
- }
2413
+ this.emit("certificateChange", { store, certificate, fingerprint: newFingerprint, filename: changedPath });
2416
2414
  } catch (err) {
2417
2415
  debugLog(`change event: failed to re-read ${changedPath}`, err);
2418
2416
  }