@objekt/checksum-report
NodeJS utility library to generate checksums for files and directories.
[Introduction] [Configuration] [Usage] [API Reference] [Contributors] [License]
This utility libary assists you to generate a checksum report for a directory and its descendants.
This is useful to include in the root of distribution bundle, e.g. a static website, as a client application could use this report to validate it has downloaded the complete bundle.
Each file in the directory structure is read and its content hashed using the sha1 algorithm with hex encoding by default.
The report is generated as a JSON string in the below format, where:
e.g.
{
"id":"9d307fdcafb3f6f2fbcd47899df78652936cea00",
"timestamp":"2022-04-10T15:21:08.406Z",
"files":[
{
"path":"index.html",
"hash":"064c47308009992f133a44e368cf1dcfdaa9d85e"
},
{
"path":"app.39b812d9.js",
"hash":"1bd6e3344fbc3363b1faa00d1115378135aac5ce"
},
{
"path":"vendors.70682963.js",
"hash":"5b055ca612c8e6883decd76258261d85da3de644"
},
{
"path":"assets/logo.png",
"hash":"ed73e59a43d571044f457e62d385a6ea025f651c"
}
]
}
npm install @objekt/checksum-report
No configuration needed. This libary targets NodeJS 16 and above.
Generate a checksum report for the dist directory.
import { ChecksumReport } from '@objekt/checksum-report';
const report = await ChecksumReport.get('./dist');
console.log(report);
Generate and save a checksum for the dist directory as checksum.json to disk.
import { ChecksumReport } from '@objekt/checksum-report';
const report = await ChecksumReport.save('./dist', './dist/checksum.json');
console.log(report);
Full API documentation here.
This project follows the all-contributors specification. Contributions of any kind welcome! (emoji key)
jn42lm1 💻 📖 |
Generated using TypeDoc