Skip to content

Commit

Permalink
fix(BULL-44449): tweak subtle import
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictobias committed Dec 12, 2024
1 parent 3399e9d commit 4d4944d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/subtle.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
export const subtle = window.crypto?.subtle || (require('crypto').subtle as SubtleCrypto)
// window exists in envs like react-native so we also check for the presense of `subtle`. We can alias the "crypto" module in react-native with react-native-quick-crypto.
export const subtle =
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
(typeof window !== 'undefined' && window.crypto?.subtle) || (require('crypto').subtle as SubtleCrypto)

0 comments on commit 4d4944d

Please sign in to comment.