-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add crypto utility function and use in BearerDid #430
Conversation
Signed-off-by: Frank Hinek <[email protected]>
TBDocs Report 🛑 Errors: 0 @web5/api
@web5/crypto
@web5/crypto-aws-kms
@web5/dids
@web5/credentials
TBDocs Report Updated at 2024-02-27T01:11:17Z |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #430 +/- ##
=======================================
Coverage 93.34% 93.35%
=======================================
Files 80 80
Lines 23804 23827 +23
Branches 1890 1891 +1
=======================================
+ Hits 22220 22243 +23
Misses 1544 1544
Partials 40 40
|
packages/crypto/src/utils.ts
Outdated
return curveToJoseAlgorithm[publicKey.crv]; | ||
} | ||
|
||
throw new Error(`Unable to determine algorithm based on provided input: alg=${publicKey.alg}, crv=${publicKey.crv}`); |
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.
Maybe we should include the curves we support here and/or in the docs?
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.
Thanks @KendallWeihe. Added the list of supported algorithm identifiers and curve names to the error in 0aa36d1.
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.
seems right to me 👍
Only nitpicky feedback item, so take it or leave it, would've been to do this one #418 is a separate PR. Reasoning being, it's a disparate matter to the other two items in this PR so caused a slight disruption when reviewing, but also it may just be because of my naivete to this code base. |
|
||
// If the key contains an `alg` property that matches a JOSE registered algorithm identifier, | ||
// return its value. | ||
if (publicKey.alg && Object.values(curveToJoseAlgorithm).includes(publicKey.alg)) { |
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.
Nit clarification: Previously, we didn't check that the alg is in curveToJoseAlgorithm
values. This seems correct to me, but also took me a second to notice while reviewing. Did we previously want to return "unsupported" algorithms or was that just an oversight that we're not correcting?
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.
I may be missing the question. Unsupported algorithms won't be returned and an error will be thrown.
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.
This change seems pretty innocuous since we're just moving the location of existing functionality. I added a question, but feel free to merge as-is.
Signed-off-by: Frank Hinek <[email protected]>
* Add crypto utility function and use in BearerDid * Improve error message --------- Signed-off-by: Frank Hinek <[email protected]>
* Add crypto utility function and use in BearerDid * Improve error message --------- Signed-off-by: Frank Hinek <[email protected]>
* Add crypto utility function and use in BearerDid * Improve error message --------- Signed-off-by: Frank Hinek <[email protected]>
This PR will:
BearerDid
to the@web5/crypto
package.BearerDid
to use the utility function.BearerDid
to close CorrectBearerDid
documentation #418.Note
The package versions for
@web5/crypto
and@web5/dids
are not incremented in this PR as this change is rather minimal, has no immediate impact on external API consumers, and consequently, isn't worth publishing a new release.A future PR will bump the versions and publish new releases as the utility function added to
@web5/crypto
is consumed in other packages in this monorepo (which is already the case for a branch that is still a WIP.