Repository: mozilla/pdf.js
File: src/core/document.js (JavaScript)

Code before:
      const hasOnlyDocumentSignatures =
        hasSignatures && this.#hasOnlyDocumentSignatures(fields);
      formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
      formInfo.hasSignatures = hasSignatures;
    } catch (ex) {
      if (ex instanceof MissingDataException) {
        throw ex;
      }
      warn(`Cannot fetch form information: "${ex}".`);
    }
    return shadow(this, "formInfo", formInfo);
  }

  get documentInfo() {
    const { catalog, formInfo, xref } = this;

    const docInfo = {
      PDFFormatVersion: this.version,
      Language: catalog.lang,
      EncryptFilterName: xref.encrypt?.filterName ?? null,
      IsLinearized: !!this.linearization,
      IsAcroFormPresent: formInfo.hasAcroForm,
      IsXFAPresent: formInfo.hasXfa,
      IsCollectionPresent: !!catalog.collection,
      IsSignaturesPresent: formInfo.hasSignatures,
      collectedSignatureCertificates:
        formInfo.collectedSignatureCertificates ?? null,
    };

    let infoDict;
    try {
      infoDict = xref.trailer.get("Info");
    } catch (err) {
      if (err instanceof MissingDataException) {
        throw err;
      }
      info("The document information dictionary is invalid.");
    }
    if (!(infoDict instanceof Dict)) {
      return shadow(this, "documentInfo", docInfo);
    }

    for (const [key, value] of infoDict) {
      switch (key) {
        case "Title":
        case "Author":
        case "Subject":
        case "Keywords":
        case "Creator":
        case "Producer":
        case "CreationDate":

Review comment (suggestion):
This field is only for (temporary?) telemetry, but doing it like this makes it visible in the API surface judging by the tests we have e.g. here: https://github.com/mozilla/pdf.js/blob/1ebc896b6f82373eb1b6d296de2d6154dc2993d7/test/unit/api_spec.js#L2216
We probably don't want that in order to be able to delete it again later on once the telemetry is no longer needed. Hence it seems better to limit the entire signature collection to the MOZCENTRAL build target so other builds are not affected by it and it won't be part of the official API.

If that's not feasible, we should probably at least indicate that it's private by prefixing it with an underscore (but preferably we don't expose this in the API surface at all).

Code after:
        }
      }
      const hasOnlyDocumentSignatures =
        hasSignatures && this.#hasOnlyDocumentSignatures(fields);
      formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
      formInfo.hasSignatures = hasSignatures;
    } catch (ex) {
      if (ex instanceof MissingDataException) {
        throw ex;
      }
      warn(`Cannot fetch form information: "${ex}".`);
    }
    return shadow(this, "formInfo", formInfo);
  }

  get documentInfo() {
    const { catalog, formInfo, xref } = this;

    const docInfo = {
      PDFFormatVersion: this.version,
      Language: catalog.lang,
      EncryptFilterName: xref.encrypt?.filterName ?? null,
      IsLinearized: !!this.linearization,
      IsAcroFormPresent: formInfo.hasAcroForm,
      IsXFAPresent: formInfo.hasXfa,
      IsCollectionPresent: !!catalog.collection,
      IsSignaturesPresent: formInfo.hasSignatures,
    };

    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
      docInfo.collectedSignatureCertificates =
        formInfo.collectedSignatureCertificates ?? null;
    }

    let infoDict;
    try {
      infoDict = xref.trailer.get("Info");
    } catch (err) {
      if (err instanceof MissingDataException) {
        throw err;
      }
      info("The document information dictionary is invalid.");
    }
    if (!(infoDict instanceof Dict)) {
      return shadow(this, "documentInfo", docInfo);
    }

    for (const [key, value] of infoDict) {
      switch (key) {
        case "Title":
        case "Author":