https://github.com/interledger/httpbis-digest-headers
TS Library to create and verify a Content-Digest header.
https://github.com/interledger/httpbis-digest-headers
Last synced: 8 months ago
JSON representation
TS Library to create and verify a Content-Digest header.
- Host: GitHub
- URL: https://github.com/interledger/httpbis-digest-headers
- Owner: interledger
- License: mit
- Created: 2022-09-23T14:42:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-06T05:35:49.000Z (almost 3 years ago)
- Last Synced: 2025-09-28T12:41:29.710Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 384 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HTTP Digest Headers
[](https://github.com/interledger/httpbis-digest-headers/actions/workflows/nodejs.yml)
Based on the draft specification for HTTP Digest Headers, this library facilitates the creation and verification of a Content-Digest header.
This is useful when verifying the content of a message body as part of signature verification.
## Specifications
- [HTTPBIS-DIGEST-HEADERS](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-digest-headers)
The library currently only supports sha-256 and sha-512 algorithms
## Examples
### Creating a digest header
```js
import { createContentDigestHeader } from 'httpbis-digest-headers';
request.setHeader('Content-Digest', createContentDigestHeader(messageBody, ['sha-256']))
```
### Verify a digest header
```js
import { verifyContentDigest } from 'httpbis-digest-headers';
const server = http.createServer(async (req, res) => {
const buffers = [];
for await (const chunk of req) {
buffers.push(chunk);
}
const verified = verifyContentDigest(Buffer.concat(buffers), req.getHeader('Content-Digest'))
});
```