k6
k6 copied to clipboard
Extend/rewrite `k6/crypto`
Feature Description
A long time ago we got a pretty big PR extending k6/crypto
in https://github.com/grafana/k6/pull/1025 at the time one of the biggest problems was that ArrayBuffer was not supported. This meant that the returned data was pretty hard to work with and was very not js like.
Additionally (and likely even more importantly) having a custom crypto API that is absolutely nothing like anything else in the js ecosystem adds two problems:
- we need to design an API and hopefully do a good job at it
- users now have to learn it and if they use some other API for some code they want to reuse, they now need to either rewrite their code or make a proxy between the API they use and ours :(
At the time the major possible things to implement were webcrypto and node.js' crypto with the webcrypto being more of standard winning slightly. This though also leads to the fact that up to recently there was also no support for Promises in k6.
The combinations of all of those things and lack of actual resources to work on this either way lead to it being dropped and the PR was finally closed when an extension implementing some parts of this was created by a third party, thanks @szkiba.
Suggested Solution (optional)
While promises and event loops aren't yet (fully) functional in k6, it's now being worked on meaning that it's probably a good idea to start discussing and gathering info on what the API will look like and whether we will be copying just some other already existing API.
I am very much of the opinion that webcrypto is the way, but input from actual js developers who have had some interactions with crypto(graphy not currency) APIs will a lot more valuable. I know that some higher-level APIs just wrap around either webcrypto or nodejs' crypto and if that is the case for the most popular one, I guess we can just go with one of the lower levels once and call it a day.
After we have some more idea on what API we would like to implement, this will likely happen in a separate extension. The development will likely reveal problems that we haven't found so far and is unlikely to take less than 1 cycle.
Lists of things blocked on it(to be edited):
For later reference: SubtleCrypto
Seems like we could close this since we already have a k6/experimental/webcrypto
and https://github.com/grafana/k6/issues/3154, WDYT?
Close it in favor of #3154