We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7a5886d commit 479deb6Copy full SHA for 479deb6
packages/svelte/src/internal/server/crypto.js
@@ -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
+
5
let text_encoder;
6
7
/** @param {string} data */
8
export async function sha256(data) {
9
text_encoder ??= new TextEncoder();
- 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));
12
// @ts-ignore - we don't install node types in the prod build
13
return Buffer.from(hash_buffer).toString('base64');
14
}
0 commit comments