New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[middlewares] globalThis and globalThis.CryptoKey is missing #30475
Comments
Note that CryptoKey's WebIDL defines CryptoKey as exposed via globals. See https://w3c.github.io/webcrypto/#cryptokey-interface |
We're bringing in |
@javivelasco globalThis is just one portion, but a great start nontheless! |
Looks like Does |
It does not come for free ;) |
We are adding it in the next canary |
export async function middleware(req, ev) {
return new Response(JSON.stringify({
globalThisPresent: typeof globalThis !== 'undefined',
CryptoKeyInGlobalThis: typeof globalThis !== 'undefined' && typeof globalThis.CryptoKey !== 'undefined',
CryptoKey: typeof CryptoKey !== 'undefined'
}), { status: 200 });
} State as of
{
"globalThisPresent": true,
"CryptoKeyInGlobalThis": false,
"CryptoKey": false
}
{
"globalThisPresent": false,
"CryptoKeyInGlobalThis": false,
"CryptoKey": false
} |
This is not fixed on Edge Functions still as per my previous comment in this issue. |
@panva right, no problem. A new runtime version should be released paired with the next canary, let me ping you when is done 🙂 |
Right. But the release of 12.0.3 didnt align globalThis on edge functions so i'm wondering how this works... |
Same with the new canary - locally its good now, on vercel.com - not. https://my-next-app-panva.vercel.app |
@panva this has now been rolled to stable on Vercel, please re-deploy and give a try! |
Yup! |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
12.0.1
What version of Node.js are you using?
v14.18.0
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Both Vercel and
next dev
Describe the Bug
Testing a universal JOSE (JWT/JWK/etc) library on Middlewares I've encountered an issue where the CryptoKey constructor is not exposed via globalThis.CryptoKey.
This is the case for all browsers, Deno, and Cloudflare Workers runtimes but not for Middlewares deployed via vercel or running via
next dev
.Not having access to this constructor prohibits my particular library from validating user inputs.
In
next dev
globalThis.CryptoKey is missing, in vercel.com runtimeglobalThis
is missing completely.Expected Behavior
globalThis
,globalThis.CryptoKey
, andCryptoKey
are exposed both running vianext dev
or deployed via vercel.comTo Reproduce
Create a middleware like so, both in development as well as vercel.com, observe the failures are there and also, different.
The text was updated successfully, but these errors were encountered: