// The Postiz API key at rest: sealed in _sc_plugins.configuration (Saltcorn // stores plugin configuration plaintext, so a DB dump, a backup or a dev-deploy // sync would otherwise expose it), opened only at the point of use. The key is // derived from the session secret (env / config file, NOT the database), see // lib/common/aesGcm.js + sessionKey.js. The configuration workflow seals a newly // typed key before Saltcorn saves it (lib/config.js); onLoad seals a plaintext // key left by plugin versions before 0.0.3. Rotating the session secret means // re-entering the key. const { createSealer, isSealedString, STRING_PREFIX } = require("./common/aesGcm"); const { getSessionSecret } = require("./common/sessionKey"); const { PLUGIN_NAME } = require("./constants"); // Domain label that ties the sealed apiKey to this plugin + field (key // derivation). Changing it would orphan already-sealed keys. const API_KEY_INFO = `${PLUGIN_NAME}:apiKey`; // What the stored apiKey is: not set, sealed (and it opens), sealed but it does // not open (session secret missing or rotated), or plaintext (legacy, or no // session secret to seal under). const API_KEY_STATES = { UNSET: "unset", SEALED: "sealed", SEALED_UNOPENABLE: "sealed_unopenable", PLAINTEXT: "plaintext" }; // The sealer of one configuration field, keyed by its domain label: HKDF salt // "scs1: