[PR #8457] [CLOSED] feat(crypto): native scrypt support for CF Workers #16233

Closed
opened 2026-04-13 10:27:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8457
Author: @bauchdj
Created: 3/6/2026
Status: ❌ Closed

Base: canary ← Head: feat/native-scrypt-cf-workers


📝 Commits (1)

  • dbf2c2e feat(crypto): use native node:crypto scrypt with fallback to @noble/hashes

📊 Changes

2 files changed (+71 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/crypto/password.test.ts (+26 -0)
📝 packages/better-auth/src/crypto/password.ts (+45 -2)

📄 Description

Summary

  • Adds native node:crypto scrypt detection at import time (cached promise)
  • Prefers native scrypt when available (Node.js, Cloudflare Workers), falls back to @noble/hashes/scrypt
  • No change to hash format — fully backwards compatible with existing stored hashes
  • Adds cross-compatibility test (hash with noble, verify through main path) and round-trip test

Motivation

Cloudflare Workers now support node:crypto.scrypt. This change lets CF Workers users benefit from the native (faster) implementation automatically, without any configuration.

Closes #8456

Test plan

  • vitest packages/better-auth/src/crypto/password.test.ts --run — 9/9 pass
  • pnpm typecheck — clean
  • pnpm lint — clean

🤖 Generated with Claude Code


Summary by cubic

Adds native node:crypto scrypt support for Cloudflare Workers and Node, with automatic detection and fallback to @noble/hashes. Hash format remains the same, so existing password hashes keep working.

  • New Features
    • Detects native scrypt at import time (cached promise) and prefers it when available.
    • Falls back to @noble/hashes/scrypt in environments without native support.
    • Adds cross-compatibility and round-trip tests to ensure verification across both paths.

Written for commit dbf2c2e87a. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8457 **Author:** [@bauchdj](https://github.com/bauchdj) **Created:** 3/6/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/native-scrypt-cf-workers` --- ### 📝 Commits (1) - [`dbf2c2e`](https://github.com/better-auth/better-auth/commit/dbf2c2e87a02495518e287d9e3c79215a10ddff2) feat(crypto): use native node:crypto scrypt with fallback to @noble/hashes ### 📊 Changes **2 files changed** (+71 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/crypto/password.test.ts` (+26 -0) 📝 `packages/better-auth/src/crypto/password.ts` (+45 -2) </details> ### 📄 Description ## Summary - Adds native `node:crypto` scrypt detection at import time (cached promise) - Prefers native scrypt when available (Node.js, Cloudflare Workers), falls back to `@noble/hashes/scrypt` - No change to hash format — fully backwards compatible with existing stored hashes - Adds cross-compatibility test (hash with noble, verify through main path) and round-trip test ## Motivation Cloudflare Workers now support `node:crypto.scrypt`. This change lets CF Workers users benefit from the native (faster) implementation automatically, without any configuration. Closes #8456 ## Test plan - [x] `vitest packages/better-auth/src/crypto/password.test.ts --run` — 9/9 pass - [x] `pnpm typecheck` — clean - [x] `pnpm lint` — clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds native node:crypto scrypt support for Cloudflare Workers and Node, with automatic detection and fallback to @noble/hashes. Hash format remains the same, so existing password hashes keep working. - **New Features** - Detects native scrypt at import time (cached promise) and prefers it when available. - Falls back to @noble/hashes/scrypt in environments without native support. - Adds cross-compatibility and round-trip tests to ensure verification across both paths. <sup>Written for commit dbf2c2e87a02495518e287d9e3c79215a10ddff2. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 10:27:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16233