summaryrefslogtreecommitdiff
path: root/packages/webapi/src
diff options
context:
space:
mode:
authorGravatar André Alves <71379045+andremralves@users.noreply.github.com> 2023-05-26 10:02:35 -0300
committerGravatar GitHub <noreply@github.com> 2023-05-26 15:02:35 +0200
commitbf63f615fc1b97d6fb84db55f7639084e3ada5af (patch)
tree5e4f488ba3ed6e03d4d0c1c216c52b0c20fc51fd /packages/webapi/src
parent52af9ad18840ffa4e2996386c82cbe34d9fd076a (diff)
downloadastro-bf63f615fc1b97d6fb84db55f7639084e3ada5af.tar.gz
astro-bf63f615fc1b97d6fb84db55f7639084e3ada5af.tar.zst
astro-bf63f615fc1b97d6fb84db55f7639084e3ada5af.zip
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 <princssdev@gmail.com>
Diffstat (limited to 'packages/webapi/src')
-rw-r--r--packages/webapi/src/polyfill.ts3
-rw-r--r--packages/webapi/src/ponyfill.ts2
2 files changed, 5 insertions, 0 deletions
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,