- 
                Notifications
    You must be signed in to change notification settings 
- Fork 300
feat: add Buffer support for HMAC generation #7288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
918f1e4    to
    273e6b7      
    Compare
  
    There was a problem hiding this 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 adds Buffer support to the HMAC generation functions to improve performance by eliminating unnecessary toString() conversions when working with binary data from WP.
- Updated type definitions to accept string | Bufferfor text parameters
- Modified calculateHMACSubjectto handle Buffer inputs and return Buffer when appropriate
- Added comprehensive test coverage for Buffer-based HMAC generation and verification
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description | 
|---|---|
| modules/sdk-hmac/src/types.ts | Updated type definitions to support Buffer in addition to string for text parameters across all HMAC-related interfaces | 
| modules/sdk-hmac/src/hmac.ts | Enhanced calculateHMACSubjectfunction to handle Buffer inputs by concatenating prefix with Buffer data instead of string joining | 
| modules/sdk-api/src/bitgoAPI.ts | Updated return type of calculateHMACSubjectmethod to reflect Buffer support | 
| modules/sdk-hmac/test/hmac.ts | Added test cases for Buffer input handling in request/response HMAC generation and verification | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Ticket: ANT-1033
Description
This change enhances the
calculateHMACSubjectfunction to support Buffers in addition to strings. This will allow us to pass buffers directly from WP instead of having to calltoString()which incurs a performance cost. Existing tests pass, and new tests have been added to verify the HMAC generation/verification works with Buffers.This change is part of the V3 auth improvements epic
Issue Number
ANT-1033
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Unit tests
Checklist: