Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)