Skip to content

Commit 479deb6

Browse files
node 18
1 parent 7a5886d commit 479deb6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
// TODO - remove this and use global `crypto` when we drop Node 18
2+
// @ts-ignore - we don't install node types in the prod build
3+
import { webcrypto } from 'node:crypto';
4+
15
let text_encoder;
26

37
/** @param {string} data */
48
export async function sha256(data) {
59
text_encoder ??= new TextEncoder();
6-
const hash_buffer = await crypto.subtle.digest('SHA-256', text_encoder.encode(data));
10+
// @ts-ignore - we don't install node types in the prod build
11+
const hash_buffer = await webcrypto.subtle.digest('SHA-256', text_encoder.encode(data));
712
// @ts-ignore - we don't install node types in the prod build
813
return Buffer.from(hash_buffer).toString('base64');
914
}

0 commit comments

Comments
 (0)