Skip to content

Commit

Permalink
fix(node): add webcrypto export for node:crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 11, 2023
1 parent 731eb76 commit fb2b280
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/runtime/node/crypto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
// https://github.com/unjs/uncrypto
import type nodeCrypto from "node:crypto";

const webCrypto = globalThis.crypto;
const webcrypto = globalThis.crypto;

export const subtle: typeof nodeCrypto.subtle = webCrypto.subtle;
export const subtle: typeof nodeCrypto.subtle = webcrypto.subtle;

export const randomUUID: typeof nodeCrypto.randomUUID = () => {
return webCrypto.randomUUID();
return webcrypto.randomUUID();
};

export const getRandomValues: typeof nodeCrypto.getRandomValues = (
array: any
) => {
return webCrypto.getRandomValues(array);
return webcrypto.getRandomValues(array);
};

// TODO: Add missing exports (typecheck is not working!)
export default <typeof nodeCrypto>{
randomUUID,
getRandomValues,
subtle,
webcrypto,
};

0 comments on commit fb2b280

Please sign in to comment.