Skip to content
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

fix: refactor types for rsaFunctionFor to include BufferLike #590

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

JonathanYeeW
Copy link

@JonathanYeeW JonathanYeeW commented Jan 24, 2025

Why

This PR updates the returned function parameter types for rsaFunctionFor() to include BufferLike. The original code already performs checks and assumes that EncodingOptions can be a BinaryLike, but this type wasn’t properly reflected in the definitions.

This omission causes issues during TypeScript compilation (tsc) in cases where passing a private key works as intended but fails the type check. For example:

const symmetricKey = crypto.privateDecrypt(
    privateKey,
    Buffer.from(encryptedSymmetricKey, "base64")
  );

Also noting, this change does the type checking logic inline. Normally, I’d pull these into utility functions to keep the function body cleaner and more focused. However, I’m unsure where this type of utility would belong in the project structure. Additionally, given that this functionality might be deprecated, I’m not certain if it’s worth the effort to refactor at this point.

That said, I’m happy to make changes based on the team’s preferences.

What

  • Added BufferLike to the function’s returned parameter types.

@JonathanYeeW JonathanYeeW marked this pull request as ready for review January 24, 2025 04:59
@boorad boorad merged commit a1c857c into margelo:0.x Jan 24, 2025
2 checks passed
@boorad
Copy link
Collaborator

boorad commented Jan 24, 2025

@JonathanYeeW tyvm ❤️

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.

2 participants