From bf63f615fc1b97d6fb84db55f7639084e3ada5af Mon Sep 17 00:00:00 2001 From: André Alves <71379045+andremralves@users.noreply.github.com> Date: Fri, 26 May 2023 10:02:35 -0300 Subject: Add global crypto to @astrojs/webapi (#6981) * add crypto to be polyfilled * chore: changeset * chore: update deps for node types --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> Co-authored-by: Princesseuh --- packages/webapi/src/polyfill.ts | 3 +++ packages/webapi/src/ponyfill.ts | 2 ++ 2 files changed, 5 insertions(+) (limited to 'packages/webapi/src') diff --git a/packages/webapi/src/polyfill.ts b/packages/webapi/src/polyfill.ts index 4d1531a3f..5fadd5a68 100644 --- a/packages/webapi/src/polyfill.ts +++ b/packages/webapi/src/polyfill.ts @@ -8,6 +8,7 @@ import { clearTimeout, Comment, CountQueuingStrategy, + crypto, CSSStyleSheet, CustomElementRegistry, CustomEvent, @@ -87,6 +88,7 @@ export { clearTimeout, Comment, CountQueuingStrategy, + crypto, CSSStyleSheet, CustomElementRegistry, CustomEvent, @@ -211,6 +213,7 @@ export const polyfill = (target: any, options?: PolyfillOptions) => { cancelAnimationFrame, cancelIdleCallback, clearTimeout, + crypto, fetch, requestAnimationFrame, requestIdleCallback, diff --git a/packages/webapi/src/ponyfill.ts b/packages/webapi/src/ponyfill.ts index 368f7ee5b..9be4377c5 100644 --- a/packages/webapi/src/ponyfill.ts +++ b/packages/webapi/src/ponyfill.ts @@ -14,6 +14,7 @@ import { WritableStreamDefaultController, WritableStreamDefaultWriter, } from 'node:stream/web' // Remove when Node 16 is dropped for Node 18. +import { webcrypto as crypto } from 'node:crypto' // Remove when Node 18 is dropped for Node 20 import { fetch, File, FormData, Headers, Request, Response } from 'undici' // Remove when Node 16 is dropped for Node 18. import { URLPattern } from 'urlpattern-polyfill' import { @@ -133,6 +134,7 @@ export { cancelAnimationFrame, cancelIdleCallback, clearTimeout, + crypto, fetch, requestAnimationFrame, requestIdleCallback, -- cgit v1.2.3