workerd / digest
AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub
An informal specification of the Cloudflare-specific DigestStream (a WritableStream subclass computing a hash digest) as implemented in workerd, derived from — and kept in lockstep with — the test suite in this directory. The tests are the normative artifact. Both the C++ implementation (src/workerd/api/crypto/crypto.{h,c++}) and the TypeScript implementation (src/per_isolate/crypto/digest-stream.ts, behind typescript_implemented_streams) are covered. Both drive the SAME native digest context (utils.createDigestContext → CRC/OpenSSL contexts and the WTF-8/toWellFormed string encoder), so hashing, string encoding, and byte counting are parity by construction;…
Trending
Quiet since August.thin dataabout the whole repository
Who's talking about cloudflare/workerd
- A Hacker News story“OS Workerd, Cloudflare's JavaScript/WASM Runtime”Hacker News · Sep 27, 2022 · 27 points
- withastro/astro“Cloudflare adapter returning [object Object]”GitHub · Oct 10, 2025 · 18 reactions
- supabase/supabase-js“The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers”GitHub · Mar 28, 2024 · 16 reactions
- nodejs/node“src: improve buffer.transcode performance”GitHub · Aug 1, 2024 · 13 reactions
- NixOS/nixpkgs“Package request: workerd”GitHub · Nov 12, 2024 · 12 reactions
The biggest 5 of 12 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 12
Talked about on GitHub, Bluesky and Hacker News (12 times).
On GitHub · 6
- Oct 10, 2025Cloudflare adapter returning [object Object] — withastro/astro18 reactions · 15 comments
- Mar 28, 2024The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers — supabase/supabase-js16 reactions · 24 comments
- Aug 1, 2024src: improve buffer.transcode performance — nodejs/node13 reactions · 26 comments
- Nov 12, 2024Package request: workerd — NixOS/nixpkgs12 reactions · 8 comments
- Feb 19, 2024Add Curve25519 — w3c/webcrypto9 reactions · 16 comments
1 more on GitHub
- Nov 3, 2025Optimize TextEncoder::encode — nodejs/performance7 reactions · 33 comments
On Bluesky · 4
- Mar 24, 2026workerd : le runtime JavaScript/Wasm open source de Cloudflare Workers — @news.humancoders.com4 likes and reposts
- Aug 22, 2026Current status: trying to build github.com/cloudflare/w... on various sandbox providers — @jeremymorrell.dev1 likes and repost
- Mar 24, 2026workerd : le runtime JavaScript/Wasm qui propulse Cloudflare Workers est maintenant open source. Basé sur les standards web, il permet… — @humancoders.com1 likes and repost
- Nov 5, 2024Technically workers are open source github.com/cloudflare/w... — @userops.bsky.social1 likes and repost
On Hacker News · 2
- Sep 27, 2022OS Workerd, Cloudflare's JavaScript/WASM Runtime27 points · 2 comments
- Oct 5, 2023Cloudflare workers is adopting Ada URL parser2 points
In this repository61 other files it gives its agents.
- AGENTS.mdAGENTS.md
- build/AGENTS.mdAGENTS.md
- src/cloudflare/AGENTS.mdAGENTS.md
- src/node/AGENTS.mdAGENTS.md
- src/per_isolate/AGENTS.mdAGENTS.md
- src/per_isolate/crypto/AGENTS.mdAGENTS.md
- src/per_isolate/webfs/AGENTS.mdAGENTS.md
- src/per_isolate/webstreams/AGENTS.mdAGENTS.md
- src/pyodide/AGENTS.mdAGENTS.md
- src/rust/AGENTS.mdAGENTS.md
- src/rust/cxx/AGENTS.mdAGENTS.md
- src/tests/node/AGENTS.mdAGENTS.md
- src/tests/node/http-client/AGENTS.mdAGENTS.md
- src/tests/node/http-server/AGENTS.mdAGENTS.md
- src/tests/node/net/AGENTS.mdAGENTS.md
- src/tests/node/stream/AGENTS.mdAGENTS.md
- src/tests/streams/AGENTS.mdAGENTS.md
- src/tests/streams/cache/AGENTS.mdAGENTS.md
- src/tests/streams/compression/AGENTS.mdAGENTS.md
- src/tests/streams/encoding/AGENTS.mdAGENTS.md
- src/tests/streams/formdata/AGENTS.mdAGENTS.md
- src/tests/streams/htmlrewriter/AGENTS.mdAGENTS.md
- src/tests/streams/identity/AGENTS.mdAGENTS.md
- src/tests/streams/inspect/AGENTS.mdAGENTS.md
- src/tests/streams/iocontext/AGENTS.mdAGENTS.md
- src/tests/streams/piping/AGENTS.mdAGENTS.md
- src/tests/streams/r2-patterns/AGENTS.mdAGENTS.md
- src/tests/streams/readable/AGENTS.mdAGENTS.md
- src/tests/streams/readable-byte/AGENTS.mdAGENTS.md
- src/tests/streams/scaling/AGENTS.mdAGENTS.md
- src/tests/streams/sockets/AGENTS.mdAGENTS.md
- src/tests/streams/strategies/AGENTS.mdAGENTS.md
- src/tests/streams/transform/AGENTS.mdAGENTS.md
- src/tests/streams/writable/AGENTS.mdAGENTS.md
- src/workerd/api/AGENTS.mdAGENTS.md
- src/workerd/api/crypto/AGENTS.mdAGENTS.md
- src/workerd/api/node/AGENTS.mdAGENTS.md
- src/workerd/api/streams/AGENTS.mdAGENTS.md
- src/workerd/io/AGENTS.mdAGENTS.md
- src/workerd/jsg/AGENTS.mdAGENTS.md
- src/workerd/server/AGENTS.mdAGENTS.md
- src/workerd/util/AGENTS.mdAGENTS.md
- types/AGENTS.mdAGENTS.md
- bazel-test-hygieneSkill
- commit-categoriesSkill
- dad-jokesSkill
- find-and-run-testsSkill
- identify-reviewerSkill
- investigation-notesSkill
- kj-styleSkill
- markdown-draftsSkill
- parent-project-skillsSkill
- pr-review-guideSkill
- receiving-code-reviewSkill
- rust-reviewSkill
- ts-styleSkill
- update-v8Skill
- wd-test-formatSkill
- workerd-api-reviewSkill
- workerd-safety-reviewSkill
- The first 60 shown.
The file
Files
crypto.DigestStream
An informal specification of the Cloudflare-specific DigestStream (a
WritableStream subclass computing a hash digest) as implemented in workerd,
derived from — and kept in lockstep with — the test suite in this
directory. The tests are the normative artifact. Both the C++
implementation (src/workerd/api/crypto/crypto.{h,c++}) and the TypeScript
implementation (src/per_isolate/crypto/digest-stream.ts, behind
typescript_implemented_streams) are covered. Both drive the SAME native
digest context (utils.createDigestContext → CRC/OpenSSL contexts and the
WTF-8/toWellFormed string encoder), so hashing, string encoding, and byte
counting are parity by construction; divergences live in the stream
wrapper and promise plumbing. DigestStream is non-standard: no WPT exists.
Interface
[Exposed=Worker]
interface DigestStream : WritableStream {
constructor((DOMString or HashAlgorithm) algorithm,
optional DigestStreamOptions options = {});
readonly attribute Promise<ArrayBuffer> digest; // memoized identity
readonly attribute bigint bytesWritten;
};
dictionary DigestStreamOptions { boolean toWellFormed = false; };- Algorithms (case-insensitive over the whole name, string or
{name}object):md5,SHA-1,SHA-256,SHA-384,SHA-512,crc32,crc32c,crc64nvme. Unknown names throwNotSupportedErrorsynchronously; the options bag is type-checked BEFORE the algorithm lookup (primitive bags → TypeError "constructor parameter 2 is not of type 'Options'.");toWellFormedis ToBoolean-coerced. - Inheritance divergence (ledger #1): instances are
instanceof WritableStreamand the instance prototype chain is wired in both, but only TypeScript's genuineclass extendslinks the CONSTRUCTOR's prototype to the WritableStream function; the C++ jsg static chain does not. Subclassing viaclass X extends crypto.DigestStreamworks in both. digestandbytesWrittenare brand-checked prototype accessors (digestmoves to a per-instance own property in the unflagged legacy era);Symbol.disposeis brand-checked;[object DigestStream]branding underset_tostring_tag.
Core semantics
- Write settlement: the hash update runs inside write() (chunks are consumed before the write settles — post-write mutation or detach cannot change the digest; metadata comes from internal slots). Chunks: ArrayBuffer, any view (offsets honored), strings; bare SharedArrayBuffers reject (views onto them are accepted); everything else rejects TypeError "DigestStream is a byte stream but received an object of non-ArrayBuffer/ArrayBufferView/string type on its writable side." Zero-length writes are no-ops.
- String encoding: WTF-8 per chunk by default (lone surrogate = ED A0
80 — deliberately NOT TextEncoder's substitution; pinned for existing
digests).
toWellFormed: truesubstitutes U+FFFD with TextEncoderStream-style stateful pairing across chunks and a close-time flush of a dangling lead.bytesWrittencounts UTF-8 bytes (bigint in every era). - Digest promise: memoized identity (same object every access, before and after settling); resolves on close() with the digest ArrayBuffer; rejects on abort(reason) with the reason; never settled by abandonment or GC. close() is single-use (second close rejects, digest unaffected); writes after close reject without disturbing the digest.
Symbol.dispose: errors the digest ("The DigestStream was disposed.") without touching stream state — the stream stays unlocked, zero-length writes still resolve, non-empty writes reject; idempotent; a no-op after close. Rejection reporting diverges (ledger #2): the TypeScript implementation marks the digest promise handled, so an abandoned rejected digest produces NO unhandledrejection report; C++ reports it. A derived promise (.then()with no catch) still reports in both.- Pipes: a valid pipeTo destination from user streams, transforms, and Response bodies (brand checks pass in both implementations).
- Writer accounting: desiredSize counts the in-flight chunk against the default HWM of 1 and recovers on settlement in BOTH implementations (contrast the compression suite's inert C++ desiredSize); ready stays settled. Write resolutions carry undefined (no thenable check); the digest ArrayBuffer gets exactly one thenable check per ledger #3. The constructor's options-bag getter may re-enter the API safely.
Compatibility flags
| Flag (enable date) | Selects | Unflagged behavior tested by |
workers_api_getters_setters_on_prototype (2022-01-31) | digest as prototype accessor | legacyDigestIsOwnInstanceProperty |
set_tostring_tag (2024-09-26) | [object DigestStream] branding | legacyToStringTag |
streams_enable_constructors + transformstream_enable_standard_constructor (2022-11-30) | pipe tests build standard sources | — |
Unlike identity/compression, DigestStream's sink converts exceptions to
rejected promises directly, so capture_async_api_throws has no effect and
is not pinned.
digest-cpp-pedantic.wd-test runs the full module set with the dateless
opt-in pedantic_wpt added, pinning the ABSENCE of pedantic effects
(the implementation consults the flag nowhere; the reachable
standard-streams machinery changes nothing the suite pins).
Divergence ledger (C++ vs TypeScript)
| # | Area | C++ | TypeScript | Pinned in |
| 1 | Constructor static inheritance | getPrototypeOf(crypto.DigestStream) !== WritableStream | === WritableStream | isRealWritableStreamSubclass |
| 2 | Abandoned digest rejection reporting | reported | marked handled, not reported | abandonedDigestReporting |
| 3 | Thenable-check stage for the digest ArrayBuffer (fires exactly once in both) | when the digest promise is awaited | inside close(), as the deferred resolves | thenInterceptionDuringDigestResolution |
Assertion catalogue
| Module | Asserts |
api-surface.js | WritableStream subclassing incl. ledger #1; branding; brand-checked accessors + dispose; subclassable |
construction.js | case-insensitive algorithm matching (digest-compared); CRC exact spelling; unknown/missing algorithms throw synchronously; {name} object form; all 8 algorithms with sizes; option-bag Web IDL rules with exact TypeError; type-check-before-lookup ordering |
digest-vectors.js | pinned md5/SHA-256/crc32 outputs for bytes, strings, non-Uint8 views, offset subarrays; AWS SDK checksum vectors; mixed-type write accumulation with bytesWritten; shared digestOf helper |
string-encoding.js | WTF-8-not-TextEncoder default; toWellFormed matches TextEncoder for every lone-surrogate shape; inert for valid input and byte chunks; identical bytesWritten; every falsy spelling defaults off; ToBoolean coercion; stateful pair-joining across chunks; dangling-lead flush; per-chunk default encoding |
chunk-types.js | non-byte chunk rejection with exact message; bare-SAB rejection + SAB-view acceptance; DataView offset honored |
digest-promise.js | promise identity stability across settling; bytesWritten bigint semantics incl. zero-length and UTF-8 counting |
lifecycle.js | close resolves; abort rejects (incl. after writes); write-after-close rejects without disturbing the digest; double close safe; abandoned stream/writer safe; unused stream safe |
dispose.js | dispose errors digest + non-empty writes while stream state untouched; zero-length writes still resolve; idempotent; no-op after close |
unhandled-rejection.js | ledger #2 reporting matrix + derived-promise reporting |
buffer-lifecycle.js | consume-at-write: post-write mutation/detach invisible; detached/out-of-bounds typed-array and DataView views hash as empty; lying metadata getters never consulted |
pipe-integration.js | pipeTo from user streams; TransformStream chain; Response body |
large-payload.js | 1MB+ chunk digesting |
gc-interplay.js | GC never settles an abandoned digest; writer remains operable across GC |
reentrancy.js | staged thenable-check matrix (ledger #3); write issued from a write continuation preserves accumulation order; options-bag getter re-entering the constructor is safe and its value is honored |
backpressure.js | desiredSize counts and recovers (parity); ready settled |
legacy-shape.js | unflagged era: [object Object]; digest as own instance property (no prototype accessor); bytesWritten stays a bigint prototype accessor; flow unchanged |
which-impl.js | implementation detection |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

