httpbis-digest-headers
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

HTTP Digest Headers

Node.js CI

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

The library currently only supports sha-256 and sha-512 algorithms

Examples

Creating a digest header

import { createContentDigestHeader } from 'httpbis-digest-headers';
request.setHeader('Content-Digest', createContentDigestHeader(messageBody, ['sha-256']))

Verify a digest header

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'))
});```

Dependents (1)

Package Sidebar

Install

npm i httpbis-digest-headers

Weekly Downloads

803

Version

1.0.0

License

MIT

Unpacked Size

16.4 kB

Total Files

12

Last publish

Collaborators

  • interledger