diff --git a/package-lock.json b/package-lock.json index 0b02744..e39d85b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "readable-web-to-node-stream": "^3.0.2", "remark-gfm": "^3.0.1", "sass": "^1.54.3", - "secure-file-transfer": "^0.0.1", + "secure-file-transfer": "^0.0.2", "streamsaver": "^2.0.6", "trystero": "github:jeremyckahn/trystero#bugfix/29__clean-up-peers", "typeface-public-sans": "^1.1.13", @@ -7503,6 +7503,11 @@ "resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.3.tgz", "integrity": "sha512-D/vrAD4dLVX23NalHwb8dSvsUsxeRPO8Y7ToKA015JQYq69MLDOMkC0uGZYA/MPpltLO8rt8eqFC2j8DxjTZ/w==" }, + "node_modules/bep53-range": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bep53-range/-/bep53-range-1.1.1.tgz", + "integrity": "sha512-ct6s33iiwRCUPp9KXnJ4QMWDgHIgaw36caK/5XEQ9L8dCzSQlJt1Vk6VmHh1VD4AlGCAI4C2zmtfItifBBPrhQ==" + }, "node_modules/bfj": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.0.2.tgz", @@ -9134,6 +9139,44 @@ "sha.js": "^2.4.8" } }, + "node_modules/create-torrent": { + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/create-torrent/-/create-torrent-5.0.9.tgz", + "integrity": "sha512-WQ/bMe+aCBSa5EonIkgw7CTM/1JnJDQuLJhA78omSWvuEbXDwaUy0rG3a+IYt+EiO+rdTLxdsBwrsn/wfWOMQA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "bencode": "^2.0.3", + "block-iterator": "^1.0.1", + "fast-readable-async-iterator": "^1.1.1", + "is-file": "^1.0.0", + "join-async-iterator": "^1.1.1", + "junk": "^3.1.0", + "minimist": "^1.2.7", + "piece-length": "^2.0.1", + "queue-microtask": "^1.2.3", + "run-parallel": "^1.2.0", + "simple-sha1": "^3.1.0" + }, + "bin": { + "create-torrent": "bin/cmd.js" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -12320,6 +12363,17 @@ "node": ">=8.0.0" } }, + "node_modules/get-stdin": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -17767,6 +17821,29 @@ "sourcemap-codec": "^1.4.8" } }, + "node_modules/magnet-uri": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/magnet-uri/-/magnet-uri-6.2.0.tgz", + "integrity": "sha512-O9AgdDwT771fnUj0giPYu/rACpz8173y8UXCSOdLITjOVfBenZ9H9q3FqQmveK+ORUMuD+BkKNSZP8C3+IMAKQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "bep53-range": "^1.1.0", + "thirty-two": "^1.0.2" + } + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -19793,6 +19870,37 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse-torrent": { + "version": "9.1.5", + "resolved": "https://registry.npmjs.org/parse-torrent/-/parse-torrent-9.1.5.tgz", + "integrity": "sha512-K8FXRwTOaZMI0/xuv0dpng1MVHZRtMJ0jRWBJ3qZWVNTrC1MzWUxm9QwaXDz/2qPhV2XC4UIHI92IGHwseAwaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "bencode": "^2.0.2", + "blob-to-buffer": "^1.2.9", + "get-stdin": "^8.0.0", + "magnet-uri": "^6.2.0", + "queue-microtask": "^1.2.3", + "simple-get": "^4.0.1", + "simple-sha1": "^3.1.0" + }, + "bin": { + "parse-torrent": "bin/cmd.js" + } + }, "node_modules/parse5": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", @@ -23174,9 +23282,9 @@ } }, "node_modules/secure-file-transfer": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/secure-file-transfer/-/secure-file-transfer-0.0.1.tgz", - "integrity": "sha512-biTN2faslbvKUMA+vax9z1a/8suJpga1fgXHSTrWaKTKnH/sbFRH+eT3LB1LFywZVl6tUMHM+IacauqTrdnQcg==", + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/secure-file-transfer/-/secure-file-transfer-0.0.2.tgz", + "integrity": "sha512-EsfWSUbHG9EsclMrlJYicC+RHv2sMS9xIBtx2h3MaBuktMXvBlw3u4/X2L6+3mRglenmBwvzuilU/sd2eHDNiA==", "dependencies": { "@types/streamsaver": "^2.0.1", "@types/webtorrent": "^0.109.3", @@ -23187,6 +23295,7 @@ "idb-chunk-store": "^1.0.1", "path": "npm:path-browserify@^1.0.1", "readable-stream-node-to-web": "^1.0.1", + "readable-web-to-node-stream": "^3.0.2", "stream": "npm:stream-browserify@^3.0.0", "streamsaver": "^2.0.6", "webtorrent": "^1.9.7", @@ -26091,83 +26200,6 @@ "utp-native": "^2.5.3" } }, - "node_modules/webtorrent/node_modules/bep53-range": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/bep53-range/-/bep53-range-1.1.1.tgz", - "integrity": "sha512-ct6s33iiwRCUPp9KXnJ4QMWDgHIgaw36caK/5XEQ9L8dCzSQlJt1Vk6VmHh1VD4AlGCAI4C2zmtfItifBBPrhQ==" - }, - "node_modules/webtorrent/node_modules/create-torrent": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/create-torrent/-/create-torrent-5.0.9.tgz", - "integrity": "sha512-WQ/bMe+aCBSa5EonIkgw7CTM/1JnJDQuLJhA78omSWvuEbXDwaUy0rG3a+IYt+EiO+rdTLxdsBwrsn/wfWOMQA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "bencode": "^2.0.3", - "block-iterator": "^1.0.1", - "fast-readable-async-iterator": "^1.1.1", - "is-file": "^1.0.0", - "join-async-iterator": "^1.1.1", - "junk": "^3.1.0", - "minimist": "^1.2.7", - "piece-length": "^2.0.1", - "queue-microtask": "^1.2.3", - "run-parallel": "^1.2.0", - "simple-sha1": "^3.1.0" - }, - "bin": { - "create-torrent": "bin/cmd.js" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/webtorrent/node_modules/get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/webtorrent/node_modules/magnet-uri": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/magnet-uri/-/magnet-uri-6.2.0.tgz", - "integrity": "sha512-O9AgdDwT771fnUj0giPYu/rACpz8173y8UXCSOdLITjOVfBenZ9H9q3FqQmveK+ORUMuD+BkKNSZP8C3+IMAKQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "bep53-range": "^1.1.0", - "thirty-two": "^1.0.2" - } - }, "node_modules/webtorrent/node_modules/mime": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", @@ -26179,37 +26211,6 @@ "node": ">=10.0.0" } }, - "node_modules/webtorrent/node_modules/parse-torrent": { - "version": "9.1.5", - "resolved": "https://registry.npmjs.org/parse-torrent/-/parse-torrent-9.1.5.tgz", - "integrity": "sha512-K8FXRwTOaZMI0/xuv0dpng1MVHZRtMJ0jRWBJ3qZWVNTrC1MzWUxm9QwaXDz/2qPhV2XC4UIHI92IGHwseAwaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "bencode": "^2.0.2", - "blob-to-buffer": "^1.2.9", - "get-stdin": "^8.0.0", - "magnet-uri": "^6.2.0", - "queue-microtask": "^1.2.3", - "simple-get": "^4.0.1", - "simple-sha1": "^3.1.0" - }, - "bin": { - "parse-torrent": "bin/cmd.js" - } - }, "node_modules/whatwg-encoding": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", @@ -32311,6 +32312,11 @@ "resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.3.tgz", "integrity": "sha512-D/vrAD4dLVX23NalHwb8dSvsUsxeRPO8Y7ToKA015JQYq69MLDOMkC0uGZYA/MPpltLO8rt8eqFC2j8DxjTZ/w==" }, + "bep53-range": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bep53-range/-/bep53-range-1.1.1.tgz", + "integrity": "sha512-ct6s33iiwRCUPp9KXnJ4QMWDgHIgaw36caK/5XEQ9L8dCzSQlJt1Vk6VmHh1VD4AlGCAI4C2zmtfItifBBPrhQ==" + }, "bfj": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.0.2.tgz", @@ -33449,6 +33455,24 @@ "sha.js": "^2.4.8" } }, + "create-torrent": { + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/create-torrent/-/create-torrent-5.0.9.tgz", + "integrity": "sha512-WQ/bMe+aCBSa5EonIkgw7CTM/1JnJDQuLJhA78omSWvuEbXDwaUy0rG3a+IYt+EiO+rdTLxdsBwrsn/wfWOMQA==", + "requires": { + "bencode": "^2.0.3", + "block-iterator": "^1.0.1", + "fast-readable-async-iterator": "^1.1.1", + "is-file": "^1.0.0", + "join-async-iterator": "^1.1.1", + "junk": "^3.1.0", + "minimist": "^1.2.7", + "piece-length": "^2.0.1", + "queue-microtask": "^1.2.3", + "run-parallel": "^1.2.0", + "simple-sha1": "^3.1.0" + } + }, "cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -35797,6 +35821,11 @@ "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==" }, + "get-stdin": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==" + }, "get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -40024,6 +40053,15 @@ "sourcemap-codec": "^1.4.8" } }, + "magnet-uri": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/magnet-uri/-/magnet-uri-6.2.0.tgz", + "integrity": "sha512-O9AgdDwT771fnUj0giPYu/rACpz8173y8UXCSOdLITjOVfBenZ9H9q3FqQmveK+ORUMuD+BkKNSZP8C3+IMAKQ==", + "requires": { + "bep53-range": "^1.1.0", + "thirty-two": "^1.0.2" + } + }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -41415,6 +41453,20 @@ "lines-and-columns": "^1.1.6" } }, + "parse-torrent": { + "version": "9.1.5", + "resolved": "https://registry.npmjs.org/parse-torrent/-/parse-torrent-9.1.5.tgz", + "integrity": "sha512-K8FXRwTOaZMI0/xuv0dpng1MVHZRtMJ0jRWBJ3qZWVNTrC1MzWUxm9QwaXDz/2qPhV2XC4UIHI92IGHwseAwaA==", + "requires": { + "bencode": "^2.0.2", + "blob-to-buffer": "^1.2.9", + "get-stdin": "^8.0.0", + "magnet-uri": "^6.2.0", + "queue-microtask": "^1.2.3", + "simple-get": "^4.0.1", + "simple-sha1": "^3.1.0" + } + }, "parse5": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", @@ -43696,9 +43748,9 @@ } }, "secure-file-transfer": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/secure-file-transfer/-/secure-file-transfer-0.0.1.tgz", - "integrity": "sha512-biTN2faslbvKUMA+vax9z1a/8suJpga1fgXHSTrWaKTKnH/sbFRH+eT3LB1LFywZVl6tUMHM+IacauqTrdnQcg==", + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/secure-file-transfer/-/secure-file-transfer-0.0.2.tgz", + "integrity": "sha512-EsfWSUbHG9EsclMrlJYicC+RHv2sMS9xIBtx2h3MaBuktMXvBlw3u4/X2L6+3mRglenmBwvzuilU/sd2eHDNiA==", "requires": { "@types/streamsaver": "^2.0.1", "@types/webtorrent": "^0.109.3", @@ -43709,6 +43761,7 @@ "idb-chunk-store": "^1.0.1", "path": "npm:path-browserify@^1.0.1", "readable-stream-node-to-web": "^1.0.1", + "readable-web-to-node-stream": "^3.0.2", "stream": "npm:stream-browserify@^3.0.0", "streamsaver": "^2.0.6", "webtorrent": "^1.9.7", @@ -45832,61 +45885,10 @@ "utp-native": "^2.5.3" }, "dependencies": { - "bep53-range": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/bep53-range/-/bep53-range-1.1.1.tgz", - "integrity": "sha512-ct6s33iiwRCUPp9KXnJ4QMWDgHIgaw36caK/5XEQ9L8dCzSQlJt1Vk6VmHh1VD4AlGCAI4C2zmtfItifBBPrhQ==" - }, - "create-torrent": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/create-torrent/-/create-torrent-5.0.9.tgz", - "integrity": "sha512-WQ/bMe+aCBSa5EonIkgw7CTM/1JnJDQuLJhA78omSWvuEbXDwaUy0rG3a+IYt+EiO+rdTLxdsBwrsn/wfWOMQA==", - "requires": { - "bencode": "^2.0.3", - "block-iterator": "^1.0.1", - "fast-readable-async-iterator": "^1.1.1", - "is-file": "^1.0.0", - "join-async-iterator": "^1.1.1", - "junk": "^3.1.0", - "minimist": "^1.2.7", - "piece-length": "^2.0.1", - "queue-microtask": "^1.2.3", - "run-parallel": "^1.2.0", - "simple-sha1": "^3.1.0" - } - }, - "get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==" - }, - "magnet-uri": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/magnet-uri/-/magnet-uri-6.2.0.tgz", - "integrity": "sha512-O9AgdDwT771fnUj0giPYu/rACpz8173y8UXCSOdLITjOVfBenZ9H9q3FqQmveK+ORUMuD+BkKNSZP8C3+IMAKQ==", - "requires": { - "bep53-range": "^1.1.0", - "thirty-two": "^1.0.2" - } - }, "mime": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==" - }, - "parse-torrent": { - "version": "9.1.5", - "resolved": "https://registry.npmjs.org/parse-torrent/-/parse-torrent-9.1.5.tgz", - "integrity": "sha512-K8FXRwTOaZMI0/xuv0dpng1MVHZRtMJ0jRWBJ3qZWVNTrC1MzWUxm9QwaXDz/2qPhV2XC4UIHI92IGHwseAwaA==", - "requires": { - "bencode": "^2.0.2", - "blob-to-buffer": "^1.2.9", - "get-stdin": "^8.0.0", - "magnet-uri": "^6.2.0", - "queue-microtask": "^1.2.3", - "simple-get": "^4.0.1", - "simple-sha1": "^3.1.0" - } } } }, diff --git a/package.json b/package.json index cb18e47..c5e260b 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "readable-web-to-node-stream": "^3.0.2", "remark-gfm": "^3.0.1", "sass": "^1.54.3", - "secure-file-transfer": "^0.0.1", + "secure-file-transfer": "^0.0.2", "streamsaver": "^2.0.6", "trystero": "github:jeremyckahn/trystero#bugfix/29__clean-up-peers", "typeface-public-sans": "^1.1.13", diff --git a/src/components/Message/InlineMedia.tsx b/src/components/Message/InlineMedia.tsx index 11cd4a5..a6c865c 100644 --- a/src/components/Message/InlineMedia.tsx +++ b/src/components/Message/InlineMedia.tsx @@ -1,6 +1,5 @@ import { useContext, useEffect, useRef, useState } from 'react' import { TorrentFile } from 'webtorrent' -import { ReadableWebToNodeStream } from 'readable-web-to-node-stream' import CircularProgress from '@mui/material/CircularProgress' import { Typography } from '@mui/material' @@ -14,7 +13,7 @@ interface InlineMediaProps { } interface InlineFileProps { - file: TorrentFiles[0] + file: TorrentFile } export const InlineFile = ({ file }: InlineFileProps) => { @@ -29,28 +28,7 @@ export const InlineFile = ({ file }: InlineFileProps) => { if (!container) return try { - if (typeof shellContext.roomId !== 'string') { - throw new Error('shellContext.roomId is not a string') - } - - const readStream: NodeJS.ReadableStream = new ReadableWebToNodeStream( - await fileTransfer.getDecryptedFileReadStream( - file, - shellContext.roomId - ) - // ReadableWebToNodeStream is the same as NodeJS.ReadableStream. The - // library's typing is wrong. - ) as any - - const decryptedFile: TorrentFile = { - ...file, - createReadStream: () => { - return readStream - }, - } - - Object.setPrototypeOf(decryptedFile, Object.getPrototypeOf(file)) - decryptedFile.appendTo(container) + file.appendTo(container) } catch (e) { console.error(e) setDidRenderingMediaFail(true)