88a033fa1f
### What? Exposing `globalThis.crypto`, based on [Node.js' WebCrypto API](https://nodejs.org/api/globals.html#crypto_1) ### Why? Similar to `fetch`, `crypto` is a popular API that is currently not available on `globalThis` in all active Node.js versions yet. This can help library authors to create runtime-agnostic packages. ### How? Node.js already has the WebCrypto API that can be imported, we just expose it on `globalThis` in Node.js versions where this is not available. Closes NEXT-1063 [Slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1681821510191059)
11 lines
214 B
TypeScript
11 lines
214 B
TypeScript
export default function Page() {
|
|
return (
|
|
<p>
|
|
{typeof globalThis.crypto === 'object'
|
|
? 'crypto is available'
|
|
: 'crypto is not available'}
|
|
</p>
|
|
)
|
|
}
|
|
|
|
export const runtime = 'nodejs'
|