Repository navigation
fix: inline synchronous sha1, drop node crypto import (#643) - #645
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
getDefaultTitleForSchemano longer imports Node'scrypto, so the package runs in browser bundles (Vite etc. don't polyfill it, and Web Crypto has nocreateHash).src/sha1.ts: synchronous SHA-1 over the UTF-8 encoding of the input plus hand-written base64 over the 20 digest bytes. No new dependency, nobtoa, noBuffer— works in browsers and Node alike.src/index.ts:createHash("sha1").update(asString).digest("base64")replaced withsha1Base64(asString); thehashRegexfriendly-hash logic is untouched.src/sha1.test.ts: known-answer vectors (empty, ASCII, 2/3/4-byte UTF-8, lone surrogates, 55/56-byte padding boundaries, long input) pinning the byte-compatibility contract.Byte-compatibility verification
createHash("sha1"): 18/18 inputs byte-identical, including empty string, emoji, mixed multi-byte, lone high/low surrogates, padding-boundary lengths (55/56/57/64/119/120), and 100k-char inputs (throwaway script, not committed).string_doaGddGA,oneOf_number_Ho1clIqD_self_string_doaGddGA_wGyf9nC9) — generated names are unchanged.npm test(28/28, coverage thresholds met),npm run lint, andnpm run build:codeall green. Nocryptoreferences remain insrc/orbuild/.Out of scope
The playground's
shims/crypto.mjsalias can be deleted once a titleizer release with this change ships.