https://github.com/uphold/koa-instance-digest
A middleware to verify HTTP digest headers as described in RFC-3230
https://github.com/uphold/koa-instance-digest
digest headers http koajs rfc-3230
Last synced: 2 months ago
JSON representation
A middleware to verify HTTP digest headers as described in RFC-3230
- Host: GitHub
- URL: https://github.com/uphold/koa-instance-digest
- Owner: uphold
- License: mit
- Created: 2017-09-14T15:17:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-19T03:59:19.000Z (about 2 years ago)
- Last Synced: 2025-01-29T07:30:44.316Z (4 months ago)
- Topics: digest, headers, http, koajs, rfc-3230
- Language: JavaScript
- Homepage:
- Size: 332 KB
- Stars: 0
- Watchers: 18
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# koa-instance-digest
A middleware to handle verification of HTTP digest headers as described in [RFC-3230](https://tools.ietf.org/html/rfc3230) "Instance Digests in HTTP".Note that, as per the _RFC_, this module provides:
- Digest coverage for entire instances communicated via HTTP.
- Support for multiple digest algorithms.
- Negotiation of the use of digests.However, it does _NOT_ provide:
- header integrity
- authentication
- privacy
- authorization## Status
[![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url]
## Installation
Install the package via `yarn`:
```sh
❯ yarn add koa-instance-digest
```or via `npm`:
```sh
❯ npm install koa-instance-digest --save
```### Available algorithms
The following algorithms are available: `md5`, `sha`, `sha-256`, `sha-512`.
### Configuration
The middleware can be configured with the following parameters:
- `algorithms`: List of supported algorithms (all by default).
- `required`: Whether to set a digest header as mandatory (`false` by default).You can change the defaults by doing:
```javascript
middleware({
algorithms: ['sha-256'],
required: true
});
```## Usage
```javascript
const { middleware } = require('koa-instance-digest');
const Koa = require('koa');const app = new Koa();
app.post('/', middleware(), async ctx => {
// Your code here ...
});app.listen(3000);
```### Request
The `Digest` header can be provided as follows:
```javascript
'Digest: ='
```### Response
If the header is missing the following header will be added to the response:
```javascript
'Want-Digest: '
```## Tests
```sh
❯ yarn test
```## Release
```sh
❯ npm version [ | major | minor | patch] -m "Release %s"
```[npm-image]: https://img.shields.io/npm/v/koa-instance-digest.svg?style=flat-square
[npm-url]: https://npmjs.org/package/koa-instance-digest
[travis-image]: https://img.shields.io/travis/uphold/koa-instance-digest.svg?style=flat-square
[travis-url]: https://travis-ci.org/uphold/koa-instance-digest