fix(convert): avoid bundling node crypto
Some checks failed
Tests / test-deno (push) Successful in 1m52s
Tests / test-bun (push) Successful in 2m0s
Tests / test-node (node22) (push) Successful in 2m4s
Tests / test-node (node20) (push) Successful in 2m8s
Tests / test-node (node18) (push) Successful in 2m12s
Tests / test-web (chromium) (push) Successful in 2m6s
Tests / test-web (firefox) (push) Successful in 1m23s
Docs / build (push) Successful in 6m28s
Tests / lint (push) Failing after 6m59s
Tests / e2e (push) Has been skipped
Tests / e2e-deno (push) Has been skipped

This commit is contained in:
alina 🌸 2025-01-15 10:47:09 +03:00
parent 2c0b89089d
commit 5ba65769f8
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
2 changed files with 12 additions and 2 deletions

View file

@ -14,6 +14,14 @@
"@fuman/net": "0.0.9",
"@fuman/io": "0.0.8"
},
"peerDependencies": {
"@mtcute/node": "workspace:^"
},
"peerDependenciesMeta": {
"@mtcute/node": {
"optional": true
}
},
"devDependencies": {
"@mtcute/test": "workspace:^",
"@mtcute/node": "workspace:^"

View file

@ -10,9 +10,11 @@ export interface IExtendedCryptoProvider extends ICryptoProvider {
export async function getDefaultCryptoProvider(): Promise<IExtendedCryptoProvider> {
const crypto = /* @vite-ignore */ await import('node:crypto')
const { NodeCryptoProvider } = /* @vite-ignore */ await import('@mtcute/node/utils.js')
const nodeModule = '@mtcute/node/utils.js'
const { NodeCryptoProvider } = await import(/* @vite-ignore */ nodeModule) as typeof import('@mtcute/node/utils.js')
// <deno-tsignore>
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore typescript complains because of the dynamic import
return new (class extends NodeCryptoProvider implements IExtendedCryptoProvider {
createHash(algorithm: 'md5' | 'sha512') {
const hasher = crypto.createHash(algorithm)