[GH-ISSUE #8456] feat: use native node:crypto scrypt for Cloudflare Workers support #11096

Closed
opened 2026-04-13 07:28:37 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @bauchdj on GitHub (Mar 6, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8456

Problem

The password hashing module currently always uses @noble/hashes/scrypt (pure JS). Cloudflare Workers now support node:crypto.scrypt, so environments like CF Workers could benefit from the faster native implementation.

Proposed Solution

  • Detect native node:crypto.scrypt at import time via dynamic import with try/catch
  • Prefer native scrypt when available (Node.js, CF Workers), fall back to @noble/hashes/scrypt
  • No change to hash format — fully backwards compatible with existing stored hashes
  • Add cross-compatibility tests to verify native and noble produce identical output
Originally created by @bauchdj on GitHub (Mar 6, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8456 ## Problem The password hashing module currently always uses `@noble/hashes/scrypt` (pure JS). Cloudflare Workers now support `node:crypto.scrypt`, so environments like CF Workers could benefit from the faster native implementation. ## Proposed Solution - Detect native `node:crypto.scrypt` at import time via dynamic import with try/catch - Prefer native scrypt when available (Node.js, CF Workers), fall back to `@noble/hashes/scrypt` - No change to hash format — fully backwards compatible with existing stored hashes - Add cross-compatibility tests to verify native and noble produce identical output
GiteaMirror added the enhancementlocked labels 2026-04-13 07:28:37 -05:00
Author
Owner

@bytaesu commented on GitHub (Mar 6, 2026):

We're careful with changes that introduce runtime dependencies 🤔

<!-- gh-comment-id:4013989296 --> @bytaesu commented on GitHub (Mar 6, 2026): We're careful with changes that introduce runtime dependencies 🤔
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#11096