-
Notifications
You must be signed in to change notification settings - Fork 52
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is exactly correct. We need to keep things |
@alanshaw what is the state of this? |
f62abec
to
89eadc0
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.
LGTM - will need to be released as 0.17 and needs a "BREAKING CHANGE: API refactored to use async/await" message in the squashed commit.
56b4715
to
d2b8d7a
Compare
I've updated the commit message |
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 is looking great! The code is much more readable now!
Just left a comment regarding bundle optimization.
Other than that, can we create an issue for adding err-code to the errors? I don’t want to block this PR from getting merged since its goal is not that, but a second pass to add the codes would be great! I am available to create the issue and add them!
src/keys/rsa-class.js
Outdated
|
||
const crypto = require('./rsa') | ||
const pbm = protobuf(require('./keys.proto')) | ||
require('node-forge/lib/sha512') |
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 believe @hugomrdias added this for reducing the bundle size: 8d8294d#diff-17ddd891dd4a459b2c549aebf399e5edR10
Should we really remove this? If not, we should document why we have this
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.
Good catch, removing this increased the bundle size by 400kb(!)(!!!!!!!). I have put it back in.
d2b8d7a
to
f48f4c4
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.
LGTM! 🎉
if (err) { | ||
return callback(err) | ||
} | ||
if (j + todo > resultLength) { |
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'm not sure if this if block is necessary?
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.
Certainly removing it doesn't make any tests fail, though it's in the callback version too.
BREAKING CHANGE: API refactored to use async/await feat: WIP use async await fix: passing tests chore: update travis node.js versions fix: skip ursa optional tests on windows fix: benchmarks docs: update docs fix: remove broken and intested private key decrypt chore: update deps
f48f4c4
to
7af33a4
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.
This looks good.
@dignifiedquire I am going to merge this in so that we can incorporate #153 as well before the release. If there are any issues you see with this we can do a follow up PR before the release. |
This PR changes this module to remove callbacks and use async/await. The API is unchanged aside from the obvious removal of the
callback
parameter.Notes
async
keywordI've labeled API methods that are asynchronous with the
async
keyword even if they don't actually useawait
. I'm interested to hear views on this but I think it communicates the intention of the function better even if it is not required. A contrived example:publicApiFn
doesn't actually useawait
, soasync
is not strictly required. However theasync
keyword helps communicate the fact that it returns a promise so you can use it without having to track down_privateFn
to see what that returns.The other reason for doing this is if a consumer is using
then/catch
andtype.toLowerCase()
throws, then it'll be caught in the catch block. Without theasync
keyword it'll be an uncaught exception.Mostly synchronous API
There's a lot of functions labelled as async that don't actually do anything async! This is largely because the Node.js crypto API is synchronous. However the webcrypto API is async so I assume this has been done to present a consistent interface to developers in both Node.js and the browser. Maybe someone can verify that for me?
depends on
refs ipfs/js-ipfs#1670
Benchmarks
Before
After