Initial Commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { webcrypto } from "node:crypto";
|
||||
|
||||
type WritableGlobal = { crypto?: Crypto; CryptoKey?: typeof CryptoKey };
|
||||
const g = globalThis as WritableGlobal;
|
||||
if (g.crypto === undefined) {
|
||||
g.crypto = webcrypto as unknown as Crypto;
|
||||
}
|
||||
if (g.CryptoKey === undefined) {
|
||||
// Node exposes CryptoKey on the webcrypto object
|
||||
g.CryptoKey = (
|
||||
webcrypto as unknown as { CryptoKey: typeof CryptoKey }
|
||||
).CryptoKey;
|
||||
}
|
||||
Reference in New Issue
Block a user