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/bin/pki.mjs CHANGED
@@ -1195,6 +1195,7 @@ var init_certificate_manager = __esm({
1195
1195
  return "BadCertificateInvalid" /* BadCertificateInvalid */;
1196
1196
  }
1197
1197
  if (certificates.length > 1) {
1198
+ await this.#scanCertFolder(this.issuersCertFolder, this.#thumbs.issuers.certs);
1198
1199
  for (const issuerCert of certificates.slice(1)) {
1199
1200
  const thumbprint = makeFingerprint(issuerCert);
1200
1201
  if (!await this.hasIssuer(thumbprint)) {
@@ -1545,9 +1546,7 @@ var init_certificate_manager = __esm({
1545
1546
  const h = this.#filenameToHash.get(filename);
1546
1547
  if (h && index.has(h)) {
1547
1548
  index.delete(h);
1548
- if (ready) {
1549
- this.emit("certificateRemoved", { store, fingerprint: h, filename });
1550
- }
1549
+ this.emit("certificateRemoved", { store, fingerprint: h, filename });
1551
1550
  }
1552
1551
  });
1553
1552
  w.on("add", (filename) => {
@@ -1556,6 +1555,7 @@ var init_certificate_manager = __esm({
1556
1555
  const certificate = readCertificate(filename);
1557
1556
  const info = exploreCertificate(certificate);
1558
1557
  const fingerprint2 = makeFingerprint(certificate);
1558
+ const isNew = !index.has(fingerprint2);
1559
1559
  index.set(fingerprint2, { certificate, filename, info });
1560
1560
  this.#filenameToHash.set(filename, fingerprint2);
1561
1561
  debugLog(
@@ -1564,7 +1564,7 @@ var init_certificate_manager = __esm({
1564
1564
  info.tbsCertificate.serialNumber,
1565
1565
  info.tbsCertificate.extensions?.authorityKeyIdentifier?.authorityCertIssuerFingerPrint
1566
1566
  );
1567
- if (ready) {
1567
+ if (ready || isNew) {
1568
1568
  this.emit("certificateAdded", { store, certificate, fingerprint: fingerprint2, filename });
1569
1569
  }
1570
1570
  } catch (err) {
@@ -1583,9 +1583,7 @@ var init_certificate_manager = __esm({
1583
1583
  }
1584
1584
  index.set(newFingerprint, { certificate, filename: changedPath, info: exploreCertificate(certificate) });
1585
1585
  this.#filenameToHash.set(changedPath, newFingerprint);
1586
- if (ready) {
1587
- this.emit("certificateChange", { store, certificate, fingerprint: newFingerprint, filename: changedPath });
1588
- }
1586
+ this.emit("certificateChange", { store, certificate, fingerprint: newFingerprint, filename: changedPath });
1589
1587
  } catch (err) {
1590
1588
  debugLog(`change event: failed to re-read ${changedPath}`, err);
1591
1589
  }