Skip to content

Add TypeScript types for key generation functions#860

Open
mahmoud-moursy wants to merge 2 commits intopanva:mainfrom
mahmoud-moursy:main
Open

Add TypeScript types for key generation functions#860
mahmoud-moursy wants to merge 2 commits intopanva:mainfrom
mahmoud-moursy:main

Conversation

@mahmoud-moursy
Copy link
Copy Markdown

Sorry for not creating a discussion first -- alas, I read the CONTRIBUTING.md just after finishing up the code for this contribution.

Benefits

  • It's simply more convenient (for us puny humans, at least) to have autocomplete for the accepted algorithms.
  • Protects against potential typos, which may cause runtime crashes, by providing a type error.
  • I expect that this change is NOT breaking, because using an invalid algorithm causes a runtime crash anyway.

Costs

The weakest link in any cybersecurity system is humans; there is a danger that, by introducing automatic type hints, users may potentially do less pre-reading before using Jose and accidentally introduce security vulnerabilities into their own code-bases by using inappropriate algorithms. I have tried to link to the relevant documentation in the JSDoc comments of these types to reduce the incidence rate of this.

Tests(?)

I made sure to run npm format and npm test before contributing this. Nothing seems broken from what I can glean.

AI Disclosure

All the code was written by hand. I submitted it to Claude to review, where it did catch a typo that I'd made in the identifier for the type SecretKeyAlgorithm.

@mahmoud-moursy
Copy link
Copy Markdown
Author

@panva sorry for pinging you about this -- not sure if you have notifications for pull requests turned on or not.

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.

1 participant