Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zkochan/dint
Generate and verify directory integrity
https://github.com/zkochan/dint
Last synced: 2 months ago
JSON representation
Generate and verify directory integrity
- Host: GitHub
- URL: https://github.com/zkochan/dint
- Owner: zkochan
- License: mit
- Created: 2017-06-11T21:19:33.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-11-01T18:01:38.000Z (about 1 year ago)
- Last Synced: 2024-03-15T14:49:00.628Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 246 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dint
> Generate and verify directory integrity
[![npm version](https://img.shields.io/npm/v/dint.svg)](https://www.npmjs.com/package/dint) [![Build Status](https://img.shields.io/travis/zkochan/dint/master.svg)](https://travis-ci.org/zkochan/dint)
This package is mostly a copy/paste from [@zkat](https://github.com/zkat)'s [cadr](https://github.com/zkat/cadr) excluding the [cacache](https://github.com/zkat/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
```sh
npm i -S dint
```## API
### `from(dirname): Promise`
Returns a mapping of file names to size and [Subresource Integrity](https://w3c.github.io/webappsec-subresource-integrity/) of each file.
Result example:
```js
{
'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`
Verifies directory integrity against a `directoryIntegrity` argument.
E.g.:
```js
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](./LICENSE) © [Zoltan Kochan](http://kochan.io)