@digitalbazaar/http-digest-header

中文文档
2.3.0发布于 2025/10/10BSD-3-ClauseES Module零依赖近 30 天下载 7829

Minimal isomorphic library (Node.js and browser) for creating and verifying Digest headers for HTTP Signatures

原始使用文档
文档目录7 节
  1. Table of Contents
  2. Background
  3. Install
  4. Usage
  5. Contribute
  6. Commercial Support
  7. License

HTTP Digest Header Library (@digitalbazaar/http-digest-header)

Build status

JavaScript library (Node.js and browser) for creating and verifying Digest headers for HTTP Signatures

Table of Contents

Background

Originally, this library was implemented based on the Digest header as mentioned in HTTP Signatures IETF draft.

Since then, the Digest header got its own standards-track spec, at https://tools.ietf.org/html/draft-ietf-httpbis-digest-headers.

TODO: Update library in accordance with the new digest spec.

This is a library specifically for creating and verifying the Digest: header, for use with HTTP Signatures and similar mechanisms.

This is a standalone separate library from http-digest-header so as not to introduce dependencies on cryptographic libraries to that lib.

It's intended to be isomorphic (for use both in the browser and server-side, with Node.js).

Install

  • Browsers and Node.js 22+ supported.
  • Web Crypto API required. Older browsers and Node.js 14 must use a polyfill.

To install from npm:

npm install @digitalbazaar/http-digest-header

To install locally (for development):

git clone https://github.com/digitalbazaar/http-digest-header.git
cd http-digest-header
npm install

Usage

import * as httpDigest from '@digitalbazaar/http-digest-header';

const data = `{"hello": "world"}`;

const headerValue = await httpDigest.
    createHeaderValue({data, algorithm: 'sha256', useMultihash: false});
// -> SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

const dataToVerify1 = `{"hello": "world"}`;
const dataToVerify2 = `{"hello": "planet earth"}`;

const verifyResult = await httpDigest.verifyHeaderValue({data: dataToVerify1, headerValue});
// -> { verified: true }
const verifyResult = await httpDigest.verifyHeaderValue({data: dataToVerify2, headerValue});
// -> { verified: false }

Contribute

Please follow the existing code style.

PRs accepted.

If editing the Readme, please conform to the standard-readme specification.

Commercial Support

Commercial support for this library is available upon request from Digital Bazaar: [email protected]

License

BSD-3-Clause © 2019-2022 Digital Bazaar

版本与发布记录

@digitalbazaar/http-digest-header 共发布 7 个版本,首次发布于 2020/12/05;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.3.0latest2025/10/101.1 年前
2.2.12025/10/091.1 年前
2.2.02025/10/091.1 年前
2.1.02025/10/081.1 年前
2.0.02022/06/074 年前
1.0.12021/06/025 年前

关于 @digitalbazaar/http-digest-header 的常见问题

@digitalbazaar/http-digest-header 是什么?

Minimal isomorphic library (Node.js and browser) for creating and verifying Digest headers for HTTP Signatures

如何安装 @digitalbazaar/http-digest-header?

在项目目录运行 npm install @digitalbazaar/http-digest-header,或使用 pnpm add / yarn add / bun add。

@digitalbazaar/http-digest-header 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/digitalbazaar__http-digest-header 是否存在。

@digitalbazaar/http-digest-header 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@digitalbazaar/http-digest-header 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@digitalbazaar/http-digest-header 可以商用吗?

@digitalbazaar/http-digest-header 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@digitalbazaar/http-digest-header 的下载量有多少?

根据 npm 官方下载统计,@digitalbazaar/http-digest-header 在 2026/10/12 – 2026/11/10 这 30 天内被下载 7,829 次,日均约 261 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@digitalbazaar/http-digest-header 还在维护吗?

最新版本 2.3.0 发布于 2025/10/10(1.1 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/12/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。