dint
Generate and verify directory integrity
This package is mostly a copy/paste from @zkat's cadr excluding the cacache usages.
Important! A directory is not considered modified if a file was added.
A directory is considered modified if a file was modified or removed.
Installation
npm i -S dint
API
from(dirname): Promise<DirectoryIntegrity>
Returns a mapping of file names to size and Subresource Integrity of each file.
Result example:
{
'test/fixtures/4/lib/bar.js':
{ generatingIntegrity: Promise<'sha512-1B0QjibzjRrYeSf79Hcy9T1t8KNt4cFpz//88geXTN6lDnUzMo+4o/MJDESUs884XdZ5EX4RLdzsJA8qeEV3lg=='>,
size: 198 },
'test/index.js':
{ generatingIntegrity: Promise<'sha512-X6ypBcefaTDbDHHcR0J57E2dvDv6vAVi7tHAhfDImmDU8LBaYwdkdX+hVlqFdWNevJjRqsgZbXb/c+Ewq5t3tQ=='>,
size: 939 } }
check(dirname, directoryIntegrity): Promise<Boolean>
Verifies directory integrity against a directoryIntegrity
argument.
E.g.:
check('dirname', {
'test/fixtures/4/lib/bar.js':
{ integrity: 'sha512-1B0QjibzjRrYeSf79Hcy9T1t8KNt4cFpz//88geXTN6lDnUzMo+4o/MJDESUs884XdZ5EX4RLdzsJA8qeEV3lg==',
size: 198 },
'test/index.js':
{ integrity: 'sha512-X6ypBcefaTDbDHHcR0J57E2dvDv6vAVi7tHAhfDImmDU8LBaYwdkdX+hVlqFdWNevJjRqsgZbXb/c+Ewq5t3tQ==',
size: 939 } })
License
MIT © Zoltan Kochan