HMAC Integrity
An HMAC is a message authentication code computed from data and a shared secret. Staxis uses HMAC-SHA256 to compare covered pack code against local integrity records. A matching record establishes consistency with that baseline and key. Reviewing and approving the baseline remains part of the development and deployment process.
What Enters the Check
The snapshot starts in the directory containing the manifest's entry point, walks subdirectories in sorted order, and concatenates the contents of non-empty .js files. The Core hashes those bytes, then calculates an HMAC over the pack label, typology, version, and content hash. Records are stored by pack label in .hmac.
- manifest.json is excluded as a file. Its label, typology, and version enter the HMAC payload, while fields such as permits, require, and method are not included directly.
- Other file extensions, empty JavaScript files, npm dependencies outside that directory, and files elsewhere in the project are outside this snapshot's input.
- File names and separators between file contents are absent from the concatenated input. Renaming a file without changing the concatenated byte sequence can preserve the snapshot. The check therefore covers those bytes and selected metadata, with limited coverage of layout changes.
When Verification Runs
With HMAC active, the Core checks a pack before importing its entry point. It checks a runtime layer again when its instance or lifecycle API is requested through layers.require. Library lookup through libraries.require has no equivalent repeat check.
The loaded registry is cached. A later verification compares .hmac's modification time with the value captured when the registry was loaded. A changed timestamp produces an integrity failure. These are checks at defined operations. File changes between those operations are not continuously monitored.
A mismatch rejects the checked pack or request. Whether a load-time error also terminates the process depends on the configured error behaviour. Keep the Core, key material, registry, and deployment files protected.
Prepare the Baseline
In development, startup normally regenerates the records before loading packs. This accepts the code currently on disk as the new baseline. The development combination of fastload and a non-empty watching array skips HMAC checks. A selected security profile alone does not establish that an earlier approved baseline is being enforced during local development.
For a reviewed release, prepare the files and environment keys, generate matching records, and start in production mode. The explicit command is:
node project updateHMAC
This command updates records for the configured stack. Run it after reviewing the intended changes. Investigate an unexpected mismatch before accepting a new baseline. Changing a key used for pack integrity requires regenerating the records with that key.
node project resetHMAC
resetHMAC removes the configured stack entries from the registry. Generate fresh records before starting a production process that needs them. See Security Profiles for production detection.