Skip to content

Commit

Permalink
global.crypto fix for Node 19.0 (#19)
Browse files Browse the repository at this point in the history
With Node.js 19.0, the Web Crypto API is now accessible directly from the global object. global.crypto is not writable so trying to assign to it crashes the program. This is a simple fix for it.
  • Loading branch information
doge1338 authored Jan 24, 2023
1 parent a685db9 commit b755dac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export function installGlobals() {
global.ReadableStream = NodeReadableStream
global.WritableStream = NodeWritableStream

global.crypto = crypto as Crypto
if (typeof global.crypto === "undefined") {
global.crypto = crypto as Crypto
}
}

/**
Expand Down

0 comments on commit b755dac

Please sign in to comment.