-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't rely on figuring out isNode in dynamic.cjs. Instead, we can just check global.crypto, since we're doing a dynamic check anyway. Also, we're absolutely making sure we've got access to a global object thorugh either globalThis, window or self.
- Loading branch information
Showing
3 changed files
with
9 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const webcrypto = globalThis.crypto | ||
const global = globalThis || window || self | ||
|
||
export const webcrypto = global.crypto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// check the environment dynamically | ||
const global = globalThis || window || self | ||
|
||
const isNode = typeof process === 'object' | ||
const webcrypto = isNode ? require('crypto').webcrypto : globalThis.crypto | ||
|
||
module.exports = { webcrypto } | ||
module.exports = { | ||
// check the environment dynamically | ||
webcrypto: global.crypto != null ? global.crypto : require('crypto').webcrypto | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters