refactor(verifiers): share whole-file SHA-256 hashing (#14475)

* refactor(verifiers): share whole-file SHA-256 hashing

* fix(verifiers): type the streamed digest input
This commit is contained in:
Vincent Koc authored and GitHub committed 2026-11-25 10:01:22 +00:00
1 parent a0390ba877
commit 60af9ef6b3
12 files changed
+41 -68

No files matched your search

+2 -3
View File
@@ -1,3 +1,4 @@
import { sha256File } from "../../lib/verifier-file-sha256.mjs";
import assert from "node:assert/strict";
import { constants } from "node:buffer";
import { createHash } from "node:crypto";
@@ -157,9 +158,7 @@ await withVerifierFixture(fixture, async () => {
assert.equal(output.error, undefined);
assert.equal(unexpectedOutputBytes, 0);
const actualHash = createHash("sha256");
for await (const chunk of createReadStream(path)) actualHash.update(chunk);
const digest = actualHash.digest("hex");
const digest = await sha256File(path);
assert.equal(digest, expectedHash.digest("hex"));
assert.equal((await stat(path)).size, expectedBytes);
let verifiedTokenCount;