Skip to content

Commit

Permalink
fix(middleware): expose CryptoKey and globalThis.CryptoKey (#31193)
Browse files Browse the repository at this point in the history
closes #30475
  • Loading branch information
Kikobeats committed Nov 9, 2021
1 parent eb7b401 commit 0bcb714
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next/server/web/sandbox/polyfills.ts
@@ -1,4 +1,7 @@
import { Crypto as WebCrypto } from 'next/dist/compiled/@peculiar/webcrypto'
import {
Crypto as WebCrypto,
CryptoKey,
} from 'next/dist/compiled/@peculiar/webcrypto'
import { TransformStream } from 'next/dist/compiled/web-streams-polyfill'
import { v4 as uuid } from 'next/dist/compiled/uuid'
import crypto from 'crypto'
Expand Down Expand Up @@ -53,6 +56,7 @@ class TextDecoderRuntime {

export { TextDecoderRuntime as TextDecoder }
export { TextEncoderRuntime as TextEncoder }
export { CryptoKey }

export class Crypto extends WebCrypto {
// @ts-ignore Remove once types are updated and we deprecate node 12
Expand Down
1 change: 1 addition & 0 deletions packages/next/server/web/sandbox/sandbox.ts
Expand Up @@ -59,6 +59,7 @@ export async function run(params: {
timeLog: console.timeLog.bind(console),
warn: console.warn.bind(console),
},
CryptoKey: polyfills.CryptoKey,
Crypto: polyfills.Crypto,
crypto: new polyfills.Crypto(),
fetch: (input: RequestInfo, init: RequestInit = {}) => {
Expand Down

0 comments on commit 0bcb714

Please sign in to comment.