Cloudflare Workers (nodejs_compat): SignedDataVerifier passes with online checks; two non-crypto blockers remain
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 32/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js, typescript
- 领域
- backend, networking
调研方向
Start from the OCSP request path — follow where node-fetch is imported and where fetch(url, { timeout }) and response.buffer() are used — and replace them with the global fetch plus AbortSignal.timeout(30000) and Buffer.from(await response.arrayBuffer()). For the import-time randomness, find where jsrsasign is statically imported and move it to a lazy dynamic import inside the async verification methods. The existing test should validate a real chain with OCSP is the check: done means it still passes on Node and a Worker with nodejs_compat boots without a global-scope error.
由索引模型根据 Issue 内容生成。
描述
In #255 you asked to be told if a runtime such as Cloudflare Workers now has the crypto needed to verify signed data. We tested it, and it does. Only two small issues block it, and neither involves the crypto.
What we measured
2026-10-23, @apple/app-store-server-library 3.1.0, wrangler 4.149.0 (workerd 1.20261006.1), compatibility_date = "2026-10-01", compatibility_flags = ["nodejs_compat"]. Node v24 was the control.
| Check | Cloudflare edge (NRT), 3 runs | Node v24 |
|---|---|---|
Real Apple chain with OCSP (enableOnlineChecks = true). We used the certificates and date from this repo's test should validate a real chain with OCSP |
passes (116–146 ms) | passes (199–216 ms) |
verifyAndDecodeTransaction on a JWS signed by a test chain (online checks off) |
passes | passes |
| Same JWS with its payload tampered | rejected | rejected |
The library's use of node:crypto (X509Certificate, signature verification, hashing) worked as-is under nodejs_compat.
What blocked it
- jsrsasign generates random values at import time. When the module loads, it calls
crypto.getRandomValues. Workers do not allow random generation in global scope (Disallowed operation called within global scope), so a staticimportstops the Worker from starting. Our workaround is a dynamicimport()inside the request handler. - The OCSP request relies on node-fetch v2-only APIs:
fetch(url, { timeout })andresponse.buffer(). On Workers, the bundler replacesnode-fetchwith a polyfill that forwards to the platformfetch. That polyfill has neither API, and the call fails with(0 , node_fetch_1.default) is not a function. Our workaround is to aliasnode-fetchto a wrapper of about 30 lines.
Suggestion
For (2), the OCSP request could use the global fetch (Node 18+) with signal: AbortSignal.timeout(30000), and read the body with Buffer.from(await response.arrayBuffer()). Because the abort signal also covers reading the body, I think this would also fix #455.
For (1), #472 is one approach (it replaces jsrsasign). A smaller change would be to load jsrsasign lazily in the verification path, since those methods are already async.
Note for local testing
wrangler dev --local sends CF-Worker: example.com on outgoing requests, and Apple's OCSP responder answers 403 to that value. Requests with no header, or with other values (foo.com, workers.dev), get 200. A deployed Worker gets 200 too. This only matters when testing OCSP locally. --local-upstream <your-domain> avoids it.
- 主要语言
- TypeScript
- 星标
- 388
- 派生
- 88
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apple/app-store-server-library-node 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
NotificationHistoryResponseValidator uses the response validator for history items and accepts malformed item fields可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 3/5 1-2 天 新手友好度 54/100
-
Abort OCSP requests when the response times out可能已有人在做 @TorinAsakura 于 71 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
-
Subscription status response validators omit validation of data and nested lastTransactions可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 84/100
查看 apple/app-store-server-library-node 的全部 Issue
相似的 Issue
-
bug priority: low role: BE stage: now
难度 2/5 1-3 小时 新手友好度 86/100
ahmadrosid/nakama#2594 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
milind-soni/OpenMausBot#6495 ·
维护者通常 1 天内回复
-
Navigating the session tree adds the branch's prompts to Up-arrow history again可能已有人在做 @acmerfight 今天认领。 未关闭untriaged
难度 2/5 1-3 小时 新手友好度 68/100
earendil-works/pi#12279 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
approved documentation
难度 1/5 1 小时以内 新手友好度 89/100
vitest-dev/vitest#12015 · 4 条评论 ·
维护者通常 1 天内回复