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

Refactor WebCrypto to be tread safe: part 1 #75

Merged
merged 6 commits into from
Apr 17, 2024
Merged

Conversation

olegbespalov
Copy link
Contributor

@olegbespalov olegbespalov commented Apr 17, 2024

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

@olegbespalov olegbespalov mentioned this pull request Apr 17, 2024
@olegbespalov olegbespalov changed the title Refactor WebCrypto to be tread safe Refactor WebCrypto to be tread safe: part 1 Apr 17, 2024
@olegbespalov olegbespalov marked this pull request as ready for review April 17, 2024 14:04
@olegbespalov olegbespalov requested a review from a team as a code owner April 17, 2024 14:04
@olegbespalov olegbespalov requested review from mstoykov and oleiade and removed request for a team April 17, 2024 14:04
@olegbespalov olegbespalov self-assigned this Apr 17, 2024
Base automatically changed from feat/ecdsa to main April 17, 2024 14:20
reject(err)
return promise
}
err := func() error {
Copy link
Member

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 🙇🏻

Copy link
Contributor Author

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:

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.

@olegbespalov olegbespalov merged commit d62fbcf into main Apr 17, 2024
10 checks passed
@olegbespalov olegbespalov deleted the refactor/tread-safe branch April 17, 2024 15:45
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.

3 participants