const crypto = require("crypto"); const fs = require("fs"); const path = require("path"); const keyPath = process.env.NODE_ENV === "development" ? path.resolve(__dirname, `../../storage/comkey`) : path.resolve(process.env.STORAGE_DIR, `comkey`); // What does this class do? // This class generates a hashed version of some text (typically a JSON payload) using a rolling RSA key // that can then be appended as a header value to do integrity checking on a payload. Given the // nature of this class and that keys are rolled constantly, this protects the request // integrity of requests sent to the collector as only the server can sign these requests. // This keeps accidental misconfigurations of AnythingLLM that leaving port 8888 open from // being abused or SSRF'd by users scraping malicious sites who have a loopback embedded in a