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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for the crypto.randomUUID operation #22

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Nov 3, 2022

This PR addresses #20.

It adds an implementation for the crypto.randomUUID operation to the extension.

import { crypto } from "k6/x/webcrypto";

export default function () {
  const myUUID = crypto.randomUUID();

  console.log(myUUID);
}

It implements the function according to the Web Crypto API's specification. Please note that this feature is part of a restricted feature set of the API.

Under the hood, it uses Google's UUID package, version v1.2.2 like in k6, to produce UUID values.

Let me know what you think 馃檱馃徎

@oleiade oleiade added the enhancement New feature or request label Nov 3, 2022
@oleiade oleiade self-assigned this Nov 3, 2022
@oleiade oleiade force-pushed the feature/randomUUID branch 3 times, most recently from ba431ec to 75747b9 Compare November 21, 2022 08:53
@oleiade oleiade requested a review from imiric November 28, 2022 09:46
@oleiade oleiade force-pushed the feature/randomUUID branch 4 times, most recently from 348fecd to 09ceb51 Compare November 28, 2022 13:01
Copy link

@imiric imiric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 馃憤

I would DRY the tests a bit since there's a lot of repetition, but it's not a big deal.

@oleiade
Copy link
Member Author

oleiade commented Dec 8, 2022

@imiric thanks 馃檱馃徎

I believe I mentioned it in the tests, but those are almost verbatim copies of the Web Platform Tests covering the Web Crypto API. Thus the not dryness is not my fact 馃ゥ

@oleiade oleiade merged commit da963cf into main Dec 8, 2022
@oleiade oleiade deleted the feature/randomUUID branch December 8, 2022 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants