@fetchproxy/protocol

中文文档
3.8.0发布于 2026/11/09MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 1.3万

WebSocket frame types + runtime validators for fetchproxy.

原始使用文档
文档目录4 节
  1. Install
  2. What's in here
  3. Stability
  4. License

@fetchproxy/protocol

Wire-protocol types, runtime validators, and crypto wrappers for the fetchproxy WebSocket protocol.

Internal-ish: most users want @fetchproxy/server instead. @fetchproxy/server re-exports the few protocol types MCP authors typically need (Capability, FetchInit); pull this package in directly only if you're building your own bridge endpoint (alternate server, test harness, custom extension).

See:

Install

npm install @fetchproxy/protocol

What's in here

ModuleExportsPurpose
framesPROTOCOL_VERSION, Capability, KNOWN_CAPABILITIES, all …Frame types, FetchInit, ReadCookiesInit, InnerFrame union, StoragePointerDecl, IndexedDbScopeDecl, CaptureHeaderDeclStatic + runtime descriptions of every frame on the wire.
validatevalidateFrame, validateInnerFrame, ProtocolError, HOSTNAME_REDefensive JSON validators with no third-party dependencies. Reject prototype-pollution attempts, malformed base64, unknown ops/capabilities, bad hostnames.
cryptoRawKeyPair, generateX25519, generateEd25519, ecdhX25519, hkdfSha256, ed25519Sign, ed25519Verify, aesGcmSeal, aesGcmOpen, sha256Thin async wrappers around WebCrypto subtle. Used by both server and extension.
mcp-idgenerateMcpId, parseMcpId, isValidMcpId, McpIdPartsPer-process <serverName>:<version>:<rand> ids.
pair-codepairTranscriptDeterministic 8-digit SAS code over the pair transcript — both identity pubs, both hello nonces and the MCP's session ephemeral (SHA256('fetchproxy/4/pair' | NUL | …)[0..7] as a big-endian BigInt mod 100_000_000, formatted XXXX-XXXX). 3.0.0+; the v3 pair of functions over the two long-term identity pubs alone is gone, so a code cannot be ground offline once and reused against that MCP forever.
sealsealInnerFrame, openEncryptedFrameAES-256-GCM encrypt/decrypt of inner JSON payloads keyed by sessionKey.
encodingtoB64, fromB64, toHex, concatBytesShared base64/hex helpers.
json-pointerevalJsonPointer, isValidJsonPointer, matchesDeclaredKey, undeclaredKeysJSON-pointer evaluation + glob matching for storage-pointer extraction.

Stability

All exports are part of the published surface and follow semver:

  • Major bumps signal wire-incompatible changes (new required fields, removed fields, semantic shifts).
  • Minor bumps add fields or accepted values additively.
  • Patch bumps are pure fixes.

0.2.0 was a wire-incompatible jump from 0.1.x (singular domain: string → domains: string[]; added capabilities; added op discriminator on inner request/response).

License

MIT.

版本与发布记录

@fetchproxy/protocol 共发布 88 个版本,首次发布于 2026/05/21;过去 12 个月发布了 88 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.8.0latest2026/11/095 天前
3.7.02026/11/077 天前
3.6.32026/10/2124 天前
3.6.22026/10/1629 天前
3.6.12026/10/091 个月前
3.6.02026/10/061 个月前

关于 @fetchproxy/protocol 的常见问题

@fetchproxy/protocol 是什么?

WebSocket frame types + runtime validators for fetchproxy.

如何安装 @fetchproxy/protocol?

在项目目录运行 npm install @fetchproxy/protocol,或使用 pnpm add / yarn add / bun add。

@fetchproxy/protocol 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fetchproxy/protocol 支持 ESM 还是 CommonJS?

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

@fetchproxy/protocol 可以商用吗?

@fetchproxy/protocol 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fetchproxy/protocol 的下载量有多少?

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

@fetchproxy/protocol 还在维护吗?

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