refactor: type readable-stream-node-to-web

This commit is contained in:
Jeremy Kahn 2023-02-18 13:45:52 -06:00
parent a9f7919460
commit 67ee15c40e
2 changed files with 10 additions and 4 deletions

View File

@ -206,3 +206,11 @@ declare module 'idb-chunk-store' {
TorrentOptions.store TorrentOptions.store
): ChunkStore ): ChunkStore
} }
declare module 'readable-stream-node-to-web' {
export const WEBSTREAM_SUPPORT: boolean
export default function nodeToWeb(
readableStream: NodeJS.ReadableStream
): ReadableStream
}

View File

@ -3,13 +3,11 @@ import streamSaver from 'streamsaver'
import { Keychain, plaintextSize, encryptedSize } from 'wormhole-crypto' import { Keychain, plaintextSize, encryptedSize } from 'wormhole-crypto'
import idbChunkStore from 'idb-chunk-store' import idbChunkStore from 'idb-chunk-store'
import { detectIncognito } from 'detectincognitojs' import { detectIncognito } from 'detectincognitojs'
import nodeToWebStream from 'readable-stream-node-to-web'
import { trackerUrls } from 'config/trackerUrls' import { trackerUrls } from 'config/trackerUrls'
import { streamSaverUrl } from 'config/streamSaverUrl' import { streamSaverUrl } from 'config/streamSaverUrl'
// @ts-ignore
import nodeToWebStream from 'readable-stream-node-to-web'
streamSaver.mitm = streamSaverUrl streamSaver.mitm = streamSaverUrl
const getKeychain = (password: string) => { const getKeychain = (password: string) => {
@ -59,7 +57,7 @@ export class FileTransfer {
const keychain = getKeychain(password) const keychain = getKeychain(password)
const decryptedStream: ReadableStream = await keychain.decryptStream( const decryptedStream: ReadableStream = await keychain.decryptStream(
new nodeToWebStream(file.createReadStream()) nodeToWebStream(file.createReadStream())
) )
return decryptedStream return decryptedStream