-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor WebCrypto to be tread safe: part 1 #75
Conversation
acca5b4
to
9ad6664
Compare
9ad6664
to
d3fa3aa
Compare
reject(err) | ||
return promise | ||
} | ||
err := func() error { |
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 familiar with this pattern of wrapping erroring code in dedicated anonymous' function scope. Just informally, I'd be keen to hear more about its benefits 🙇🏻
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.
Sure 👍
The key point of this change is to centralize the logic of management promises. Previously, it was easier to miss that we either had to reject or return promises.
See examples:
- JWK Implementation for import/export #61 (comment)
- JWK Implementation for import/export #61 (comment)
Also, it simplifies the operations because at this logical block, we only do operations + with returning almost vanilla errors, but it doesn't do any promise-related operations.
What?
This change centralizes and unifies logic and ensures that runtime (
tr
) isn't used outside the event loop.I also removed references to WebCrypto steps, like (
1.
,2.
, etc.) since the issue is that for different algorithms, they could mean different steps, which could confuse future maintainers.Splitting the PR into the parts to make it smaller. #76
Why?
Updates #71