@bedrock/zcap-storage

中文文档
9.7.0发布于 2026/05/08ES Module近 30 天下载 1797

Bedrock Authorization Capability Storage

原始使用文档
文档目录3 节
  1. Zcap Expiration Logging
  2. Configuration
  3. Log Events

bedrock-zcap-storage

Backend storage of Authorization Capabilities for Bedrock apps

Zcap Expiration Logging

Proactive logging for zcap expiration events, designed for observability alerting.

Configuration

// bedrock config
config['zcap-storage'].logging.zcapExpiration = {
  // Key for metric filters: { $.logName = "zcap-expiration" }
  logName: 'zcap-expiration',

  // Warn when zcaps expire within threshold (default: 7 days)
  // Set to `false` to disable
  logNearExpiration: {
    threshold: 7 * 24 * 60 * 60 * 1000,

    // Suppress warnings for short-lived/ephemeral zcaps whose original TTL
    // (delegation lifetime, computed from `proof.created` to `expires`) is
    // at or below this value in ms. Such zcaps are intentionally
    // short-lived and would always trip the threshold by design.
    // Defaults to `null`, which uses the value of `threshold`. Set to `0`
    // (or a negative number) to disable the filter and warn on all zcaps
    // near expiration. Zcaps without a `proof.created` timestamp are never
    // suppressed.
    minTtl: null
  },

  // Log when expired zcaps are presented (default: true)
  // Set to `false` to disable
  logExpired: true
};

Log Events

Near-expiration (warning level):

{
  "logName": "zcap-expiration",
  "event": "zcap-near-expiration",
  "capabilityId": "urn:zcap:...",
  "invocationTarget": "https://...",
  "timeUntilExpirationMs": 432000000
}

Expired (error level):

{
  "logName": "zcap-expiration",
  "event": "zcap-expired",
  "capabilityId": "urn:zcap:...",
  "invocationTarget": "https://...",
  "expiredAgoMs": 3600000
}

版本与发布记录

@bedrock/zcap-storage 共发布 15 个版本,首次发布于 2022/04/02;过去 12 个月发布了 5 个版本。

版本发布日期距今
9.7.0latest2026/05/086 个月前
9.6.02026/02/069 个月前
9.5.02026/01/229 个月前
9.4.22025/11/1711 个月前
9.4.12025/11/1611 个月前
9.4.02025/10/181.1 年前

关于 @bedrock/zcap-storage 的常见问题

@bedrock/zcap-storage 是什么?

Bedrock Authorization Capability Storage

如何安装 @bedrock/zcap-storage?

在项目目录运行 npm install @bedrock/zcap-storage,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@bedrock/core(^6.3.0)、@bedrock/mongodb(^11.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bedrock/zcap-storage 支持 TypeScript 吗?

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

@bedrock/zcap-storage 支持 ESM 还是 CommonJS?

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

@bedrock/zcap-storage 需要什么版本的 Node.js?

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

@bedrock/zcap-storage 可以商用吗?

@bedrock/zcap-storage 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@bedrock/zcap-storage 的下载量有多少?

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

@bedrock/zcap-storage 还在维护吗?

最新版本 9.7.0 发布于 2026/05/08(6 个月前);至今共发布 15 个版本,其中过去 12 个月发布了 5 个;首次发布于 2022/04/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。