()
| 19 | |
| 20 | // Async initialization for Node.js crypto |
| 21 | async function initCryptoProvider(): Promise<Crypto> { |
| 22 | // Web |
| 23 | if (typeof window === 'object') { |
| 24 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 25 | return (window as any).crypto; |
| 26 | } |
| 27 | // Web worker |
| 28 | else if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { |
| 29 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 30 | return self.crypto; |
| 31 | } |
| 32 | // Node |
| 33 | else { |
| 34 | // eslint-disable-next-line local-rules/node-imports |
| 35 | const nodeCrypto = await import('node:crypto'); |
| 36 | return nodeCrypto.webcrypto as Crypto; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // Initialize crypto provider (will be set on first use) |
| 41 | let cryptoProviderPromise: Promise<Crypto> | undefined; |
no outgoing calls
no test coverage detected