Skip to content

Fix/exclusive zod validation issue 36#38

Open
Absy00 wants to merge 7 commits intomainfrom
fix/exclusive-zod-validation-issue-36
Open

Fix/exclusive zod validation issue 36#38
Absy00 wants to merge 7 commits intomainfrom
fix/exclusive-zod-validation-issue-36

Conversation

@Absy00
Copy link
Collaborator

@Absy00 Absy00 commented Jan 24, 2026

Summary

Changes Zod schema validation to use exclusive minimum and maximum checks instead of inclusive ones, aligning with the official Node.js crypto.argon2() API specification.

Closes #36

Problem

The current validation used inclusive bounds (.min(), .max()), which incorrectly accepted boundary values. According to Node.js crypto.argon2 documentation:

  • parallelism must be greater than 1 and less than 2^24-1
  • tagLength must be greater than 4 and less than 2^32-1
  • memory must be greater than 8 * parallelism and less than 2^32-1
  • passes must be greater than 1 and less than 2^32-1

Changes

Parameter Before After
memory .max(MAX_UINT32) .lt(MAX_UINT32)
passes .min(2).max(MAX_UINT32) .gt(1).lt(MAX_UINT32)
parallelism .min(1).max(MAX_UINT24) .gt(1).lt(MAX_UINT24)
tagLength .min(4).max(MAX_UINT32) .gt(4).lt(MAX_UINT32)
memory refine >= 8 * parallelism > 8 * parallelism

Verification

  • All tests pass (pnpm test)
  • Type checking passes (pnpm typecheck)
  • Linting passes (pnpm lint:check)

Zod Numbers validation https://zod.dev/?id=numbers
Node.js crypto.argon2 https://nodejs.org/api/crypto.html#cryptoargon2algorithm-parameters-callback
RFC 9106 Argon2 https://www.rfc-editor.org/rfc/rfc9106.html#section-4-5


Note

Aligns Argon2 parameter validation with RFC 9106 minimums and verifies via new tests.

  • Update optionsSchema to allow passes >= 1 (was >= 2) and clarify memory constraint message (memory >= 8 * parallelism)
  • Add argon2-validation.test.ts covering minima for parallelism, tagLength, passes, and memory relative to parallelism, plus negative-value checks
  • Minor formatting tweak in CHANGELOG.md

Written by Cursor Bugbot for commit 5c71a35. This will update automatically on new commits. Configure here.

@Filipo11021
Copy link
Owner

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on February 12

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change Zod validation from inclusive to exclusive min/max checks

2 participants