Skip to content

Commit

Permalink
refactor: update crypto exports
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Dec 14, 2023
1 parent 4993df5 commit 4b51dd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/crypto/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
/**
* This file is necessary to ensure that the crypto library is available
* in node and the browser
*/

// eslint-disable-next-line no-restricted-syntax
import { webcrypto as nodeCrypto } from 'crypto'

const webcrypto =
typeof globalThis === 'object' && 'crypto' in globalThis
? (globalThis.crypto as nodeCrypto.Crypto)
: undefined

const crypto = webcrypto ?? nodeCrypto

import { webcrypto } from 'crypto'
const crypto = webcrypto
export default crypto
5 changes: 5 additions & 0 deletions src/crypto/crypto.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/***********************************************************************************************
* DO NOT IMPORT THIS FILE DIRECTLY
***********************************************************************************************/
const crypto = window.crypto
export default crypto

0 comments on commit 4b51dd3

Please sign in to comment.