Skip to content

Commit 7ef34a5

Browse files
committed
docs(integrity): clarify sha512 is the canonical OUR-side algorithm
checksumToIntegrity keeps its sha256 default deliberately — it relabels upstream SHA256SUMS hex (its only caller parses GitHub checksum files) and does not re-hash, so a sha512 label on 256-bit bytes would be incorrect. OUR-side integrity is sha512 via computeHashes; sha256 stays for upstream-SHASUMS interop and content addressing. Set version to 6.0.8.
1 parent 26c82ec commit 7ef34a5

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/integrity.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,16 @@ const CHECKSUM_RE = /^[a-f0-9]{64}$/i
9292
* Idempotent on integrity input — call this on user-supplied data without first
9393
* sniffing the format.
9494
*
95-
* The default algorithm is `'sha256'` because that's the fleet's checksum
96-
* convention; pass an explicit algorithm if you have a hex digest from `sha384`
97-
* or `sha512` (the function does not verify hex length against the algorithm —
98-
* caller's responsibility).
95+
* The default algorithm is `'sha256'` because this converts a _checksum_, and
96+
* checksums are sha256 by fleet convention (the GitHub-SHA256SUMS interop shape
97+
* its only caller, `checksum-file.ts`, parses). Do NOT flip this default to
98+
* sha512: this function only relabels the hex bytes, it does not re-hash, so a
99+
* sha512 label on a 256-bit digest would be a lie. The canonical algorithm for
100+
* OUR-side integrity values is sha512 — emitted by `computeHashes` as the
101+
* `integrity` (`sha512-<base64>`) field; sha256 is reserved for
102+
* upstream-SHASUMS interop and content addressing. Pass an explicit algorithm
103+
* if you have a hex digest from `sha384` or `sha512` (the function does not
104+
* verify hex length against the algorithm — caller's responsibility).
99105
*
100106
* @example
101107
* ;```typescript

0 commit comments

Comments
 (0)