Skip to content

Conversation

@jankapunkt
Copy link
Member

Refactor createHash function to include output parameter and update documentation.

Summary

The createHash method was mistakenly using encoding as argument for digest instead of update which could have lead to wrong outputs.

Linked issue(s)

Involved parts of the project

utils, pkce

Added tests?

yes

OAuth2 standard

Reproduction

Refactor createHash function to include output parameter and update documentation.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the createHash utility function where the encoding parameter was incorrectly being passed to digest() instead of update(). The fix introduces a new output parameter for the digest encoding and correctly passes the encoding parameter to the update() method. This ensures proper hash generation according to Node.js crypto API standards.

Key Changes:

  • Corrected parameter usage in createHash: encoding now passed to update(), new output parameter passed to digest()
  • Updated JSDoc documentation to reflect the corrected API design
  • Updated test to use the new output parameter name

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/utils/crypto-util.js Fixed parameter passing in createHash function (encoding→update, output→digest), improved documentation with correct parameter descriptions
test/unit/utils/crypto-util_test.js Updated test to use new output parameter instead of encoding for digest output format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@dhensby dhensby left a comment

Choose a reason for hiding this comment

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

I assume this is a "private" utility and doesn't form part of the public API surface?

@jankapunkt
Copy link
Member Author

Correct, this was internally used in pkce and fortunately in a way that this change will not be breaking.

@jankapunkt jankapunkt merged commit d4dc7c7 into master Jan 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug resolved 😃 Bug has been resolved and fixed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants