Repository navigation
Conversation
Password hashing used a hard-coded cost of 12 with bcryptjs (pure JS),
so every createUser({ password }) and login in tests paid ~200ms.
The cost now reads PASSWORD_BCRYPT_COST, defaulting to 12, and
vitest.config.js sets it to 4 for the test run.
API ChangesNo changes. |
andrewplummer
approved these changes
Oct 5, 2026
andrewplummer
left a comment
Collaborator
There was a problem hiding this comment.
This is totally fine - approved, however I was thinking to myself maybe mocking bcrypt is the more "correct" way ... either way it's fine
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
services/api/.env: addsBCRYPT_SALT_PASSES=12.services/api/src/utils/auth/password.js: the bcrypt cost readsBCRYPT_SALT_PASSESviaconfig.getinstead of the literal 12.services/api/vitest.config.js: setsBCRYPT_SALT_PASSES ||= '4'(the minimum; bcryptjs clamps anything lower up to 4, so 1 would behave the same) alongside the existing test-only env vars.Why
setPasswordhashed at a hard-coded cost of 12 with bcryptjs (pure JS). EverycreateUser({ password })and every password login in tests paid for a cost-12 hash or compare, which dominated the auth test files.Measurements (local, warm runs)
pnpm test src/routes/auth/password.test.js(20 tests)pnpm test src/routes/auth src/utils/auth(90 tests)Reviewer notes
.envdefault, a generated hash still starts with$2b$12$.vitest.config.js, so nothing outside the test run gets a weaker cost.