From 05e800042a284d6c1115e81fce52ed217959c92f Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Wed, 11 Dec 2024 08:52:49 -0600 Subject: [PATCH] fix: use same dependencies as mapeo-mobile (#10) --- package-lock.json | 742 +++++------------- package.json | 6 +- patches/simple-hypercore-protocol+2.1.2.patch | 11 - src/lib/hypercoreUtil.js | 18 +- src/lib/readableStreamToAsyncIterable.js | 11 + src/writer.js | 13 +- test/lib/readableStreamToAsyncIterable.js | 47 ++ types/hypercore.d.ts | 12 +- types/multifeed.d.ts | 6 +- 9 files changed, 306 insertions(+), 560 deletions(-) delete mode 100644 patches/simple-hypercore-protocol+2.1.2.patch create mode 100644 src/lib/readableStreamToAsyncIterable.js create mode 100644 test/lib/readableStreamToAsyncIterable.js diff --git a/package-lock.json b/package-lock.json index 6541979..ffd3e2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,14 +7,13 @@ "": { "name": "@mapeo/legacy-export-format", "version": "0.1.0", - "hasInstallScript": true, "license": "MIT", "dependencies": { "archiver": "^7.0.1", + "hypercore": "^7.7.1", "hypercore-crypto": "^3.4.2", - "multifeed": "^6.0.0", + "multifeed": "^4.3.0", "p-event": "^6.0.1", - "patch-package": "^8.0.0", "valibot": "^1.0.0-beta.9", "yauzl-promise": "^4.0.0" }, @@ -910,11 +909,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@yarnpkg/lockfile": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", - "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==" - }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -927,14 +921,6 @@ "node": ">=6.5" } }, - "node_modules/abstract-extension": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/abstract-extension/-/abstract-extension-3.1.1.tgz", - "integrity": "sha512-qmUIqQEh6ZZBKN6JfysKgCEBqI4qVexE6/N/MUJjqtQhhuGR8a16GKnK6SGFKv/n1cAlbYxLDXbtyhkxSnVYRQ==", - "dependencies": { - "codecs": "^2.0.0" - } - }, "node_modules/acorn": { "version": "8.14.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", @@ -1207,6 +1193,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/array-lru": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-lru/-/array-lru-1.1.1.tgz", + "integrity": "sha512-DgyrnKyaWLX2YfWtjGcLXJU2/MAf2iYL8kgszqkfgnZvTW3iXfSohkP/ExAVgHRVWDwzdblCF/7Mpl51jUcyxQ==", + "license": "MIT" + }, "node_modules/arraybuffer.prototype.slice": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.3.tgz", @@ -1236,14 +1228,6 @@ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "license": "MIT" }, - "node_modules/at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/atomic-batcher": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/atomic-batcher/-/atomic-batcher-1.0.2.tgz", @@ -1332,6 +1316,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1341,6 +1326,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, "dependencies": { "fill-range": "^7.1.1" }, @@ -1400,10 +1386,28 @@ "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==" }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, + "node_modules/bulk-write-stream": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/bulk-write-stream/-/bulk-write-stream-1.1.4.tgz", + "integrity": "sha512-GtKwd/4etuk1hNeprXoESBO1RSeRYJMXKf+O0qHmWdUomLT8ysNEfX/4bZFXr3BK6eukpHiEnhY2uMtEHDM2ng==", + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.1.4" + } + }, "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dev": true, "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", @@ -1432,6 +1436,8 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/chacha20-universal/-/chacha20-universal-1.0.4.tgz", "integrity": "sha512-/IOxdWWNa7nRabfe7+oF+jVkGjlr2xUL4J8l/OvzZhj+c9RpMqoo3Dq+5nU1j/BflRV4BKnaQ4+4oH1yBpQG1Q==", + "optional": true, + "peer": true, "dependencies": { "nanoassert": "^2.0.0" } @@ -1440,6 +1446,7 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -1451,28 +1458,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/ci-info": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", - "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "engines": { - "node": ">=8" - } - }, - "node_modules/clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/codecs": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/codecs/-/codecs-2.2.0.tgz", @@ -1578,7 +1563,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "node_modules/core-util-is": { "version": "1.0.3", @@ -2219,6 +2205,18 @@ "reusify": "^1.0.4" } }, + "node_modules/fd-lock": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fd-lock/-/fd-lock-1.2.0.tgz", + "integrity": "sha512-Lk/pKH2DldLpG4Yh/sOOY84k5VqNzxHPffGwf1+yYI+/qMXzTPp9KJMX+Wh6n4xqGSA1Mu7JPmaDArfJGw2O/A==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "dependencies": { + "napi-macros": "^2.0.0", + "node-gyp-build": "^4.2.2" + } + }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -2236,6 +2234,7 @@ "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, @@ -2260,14 +2259,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/find-yarn-workspace-root": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", - "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", - "dependencies": { - "micromatch": "^4.0.2" - } - }, "node_modules/flat-cache": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", @@ -2283,9 +2274,10 @@ } }, "node_modules/flat-tree": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/flat-tree/-/flat-tree-1.11.0.tgz", - "integrity": "sha512-dO6oawiYBpTROI9RZQ1seCFyNTr5UGnIdk5Ep+h7MbluB8ijnpA+tufJG5AA1hb6HSjhYI8qRo+negHnkBPqVA==" + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/flat-tree/-/flat-tree-1.12.1.tgz", + "integrity": "sha512-GchQ+onbnw5QaqsGbpcV6c8etAd396X/EVdDxutQMkGapB0lRvV9heIXS6ZffQVCse0hm2hBpK7GJz2Zp7qiMg==", + "license": "MIT" }, "node_modules/flatted": { "version": "3.3.2", @@ -2320,34 +2312,14 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" - }, - "node_modules/fsctl": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fsctl/-/fsctl-1.0.0.tgz", - "integrity": "sha512-uNHlfhyUJiVO2kHA6ZBnDkBhG1wM8fII+xGfCi5aBoWR7DLh9Q3nOAWe4fEETQzkptahITI1xbe5r23HuA5ECA==", - "hasInstallScript": true, - "optional": true, + "node_modules/from2": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", + "integrity": "sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==", + "license": "MIT", "dependencies": { - "napi-macros": "^2.0.0", - "node-gyp-build": "^4.2.3" + "inherits": "^2.0.1", + "readable-stream": "^2.0.0" } }, "node_modules/function-bind": { @@ -2423,26 +2395,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -2522,6 +2474,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, "engines": { "node": ">=8" } @@ -2586,15 +2539,6 @@ "node": ">= 0.4" } }, - "node_modules/hmac-blake2b": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hmac-blake2b/-/hmac-blake2b-2.0.2.tgz", - "integrity": "sha512-1XnS1OeKvuPIzf5MI5xw0pgB8MUlvcGGX3TH5LNz9Ew6dRMI6b2wHZoUpbj+WjbRqb9hkIW7Oo00rrvPJuQX1g==", - "dependencies": { - "nanoassert": "^2.0.0", - "sodium-universal": "^4.0.0" - } - }, "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -2603,41 +2547,40 @@ "license": "ISC" }, "node_modules/hypercore": { - "version": "9.12.0", - "resolved": "https://registry.npmjs.org/hypercore/-/hypercore-9.12.0.tgz", - "integrity": "sha512-wIlM4Iwl618NcmsY+1O/X08Cx/bY6ti3LXmQhRnPZFGQPqAeX0x53hASckW082IIAVWzXD3zcmREw5yEINzb4w==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/hypercore/-/hypercore-7.7.1.tgz", + "integrity": "sha512-boEiPCK848pNGACW1j111tJApu530e/UPpwbHytJZlrVf3YdgUIP1KL3aSi5xJFLUnuO8GLGl4lIsSeH8TaQQA==", + "license": "MIT", "dependencies": { - "abstract-extension": "^3.0.1", + "array-lru": "^1.1.0", "atomic-batcher": "^1.0.2", "bitfield-rle": "^2.2.1", + "bulk-write-stream": "^1.1.3", "codecs": "^2.0.0", "fast-bitfield": "^1.2.2", "flat-tree": "^1.6.0", - "hypercore-cache": "^1.0.1", - "hypercore-crypto": "^2.0.0", - "hypercore-default-storage": "^1.1.1", - "hypercore-protocol": "^8.0.5", - "hypercore-streams": "^1.0.1", + "from2": "^2.3.0", + "hypercore-crypto": "^1.0.0", + "hypercore-protocol": "^6.5.0", "inherits": "^2.0.3", "inspect-custom-symbol": "^1.1.0", "last-one-wins": "^1.0.4", "memory-pager": "^1.0.2", - "merkle-tree-stream": "^4.0.0", + "merkle-tree-stream": "^3.0.3", "nanoguard": "^1.2.0", - "nanoresource": "^1.3.0", "pretty-hash": "^1.0.1", + "random-access-file": "^2.1.0", + "sodium-universal": "^2.0.0", "sparse-bitfield": "^3.0.0", - "timeout-refresh": "^1.0.3", + "thunky": "^1.0.1", "uint64be": "^2.0.1", "unordered-array-remove": "^1.0.2", "unordered-set": "^2.0.0" + }, + "optionalDependencies": { + "fd-lock": "^1.0.2" } }, - "node_modules/hypercore-cache": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/hypercore-cache/-/hypercore-cache-1.0.2.tgz", - "integrity": "sha512-AJ/q7y6EOrXnOH/4+DVcfDygsh1ZXMRGvNc67GBNqwCt22oSCOWhRI6EJ+3HEJciM9M2oSm1WX3qg6kgRhT/Gw==" - }, "node_modules/hypercore-crypto": { "version": "3.4.2", "resolved": "https://registry.npmjs.org/hypercore-crypto/-/hypercore-crypto-3.4.2.tgz", @@ -2648,103 +2591,100 @@ "sodium-universal": "^4.0.1" } }, - "node_modules/hypercore-default-storage": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/hypercore-default-storage/-/hypercore-default-storage-1.1.1.tgz", - "integrity": "sha512-y7dSX3VUT4I/X5Cj0h6hcKN2R+/QQIi1HnElnCqY3tQYbVaWYljdbVe3aBQIvkRCfOgWMfe2RbCLX4N78D5syg==", - "dependencies": { - "random-access-file": "^2.1.5" - }, - "optionalDependencies": { - "fsctl": "^1.0.0" - } - }, "node_modules/hypercore-protocol": { - "version": "8.0.7", - "resolved": "https://registry.npmjs.org/hypercore-protocol/-/hypercore-protocol-8.0.7.tgz", - "integrity": "sha512-b5TXhqXUZ+Z7M/5/PlCTgElfufDRa3EzACd7y7BA7owLkxQreaUQ58wUO7nzJppDP1bnC2Hz6Hg7nlRPc75bKw==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/hypercore-protocol/-/hypercore-protocol-6.12.0.tgz", + "integrity": "sha512-T3oy9/7QFejqJX2RGcCUU1944e5/eKbLlSz9JPTNN1QbYFJgat/r7eTyOO8SMSLUimUmQx6YBMKhgYbdKzp7Bw==", + "license": "MIT", "dependencies": { - "abstract-extension": "^3.0.1", - "debug": "^4.1.1", - "hypercore-crypto": "^2.0.0", - "inspect-custom-symbol": "^1.1.0", - "nanoguard": "^1.2.1", - "pretty-hash": "^1.0.1", - "simple-hypercore-protocol": "^2.0.0", - "streamx": "^2.1.0", - "timeout-refresh": "^1.0.0" + "buffer-alloc-unsafe": "^1.0.0", + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "protocol-buffers-encodings": "^1.1.0", + "readable-stream": "^2.2.6", + "sodium-universal": "^2.0.0", + "sorted-indexof": "^1.0.0", + "varint": "^5.0.0" } }, - "node_modules/hypercore-protocol/node_modules/hypercore-crypto": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/hypercore-crypto/-/hypercore-crypto-2.3.2.tgz", - "integrity": "sha512-GzHgVOfr5utdiJG5QNcQZ0oo+/YQNbekpg429x00YpUobBraX2qEL3E+iH/EFEIdCQSiGHfToWyYw+OpznSjww==", - "dependencies": { - "sodium-universal": "^3.0.0", - "uint64be": "^3.0.0" - } + "node_modules/hypercore-protocol/node_modules/nanoassert": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/nanoassert/-/nanoassert-1.1.0.tgz", + "integrity": "sha512-C40jQ3NzfkP53NsO8kEOFd79p4b9kDXQMwgiY1z8ZwrDZgUyom0AHwGegF4Dm99L+YoYhuaB0ceerUcXmqr1rQ==", + "license": "ISC" }, - "node_modules/hypercore-protocol/node_modules/sodium-universal": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/sodium-universal/-/sodium-universal-3.1.0.tgz", - "integrity": "sha512-N2gxk68Kg2qZLSJ4h0NffEhp4BjgWHCHXVlDi1aG1hA3y+ZeWEmHqnpml8Hy47QzfL1xLy5nwr9LcsWAg2Ep0A==", + "node_modules/hypercore-protocol/node_modules/sodium-javascript": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/sodium-javascript/-/sodium-javascript-0.5.6.tgz", + "integrity": "sha512-Uk+JpqHEbzsEmiMxwL7TB/ndhMEpc52KdReYXXSIX2oRFPaI7ZDlDImF8KbkFWbYl9BJRtc82AZ/kNf4/0n9KA==", + "license": "MIT", "dependencies": { "blake2b": "^2.1.1", - "chacha20-universal": "^1.0.4", - "nanoassert": "^2.0.0", - "resolve": "^1.17.0", - "sha256-universal": "^1.1.0", - "sha512-universal": "^1.1.0", + "nanoassert": "^1.0.0", "siphash24": "^1.0.1", - "sodium-javascript": "~0.8.0", - "sodium-native": "^3.2.0", "xsalsa20": "^1.0.0" } }, - "node_modules/hypercore-protocol/node_modules/uint64be": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/uint64be/-/uint64be-3.0.0.tgz", - "integrity": "sha512-mliiCSrsE29aNBI7O9W5gGv6WmA9kBR8PtTt6Apaxns076IRdYrrtFhXHEWMj5CSum3U7cv7/pi4xmi4XsIOqg==" - }, - "node_modules/hypercore-streams": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hypercore-streams/-/hypercore-streams-1.0.1.tgz", - "integrity": "sha512-OcN2zq9DEoArC84q9VCSrf9Hx1QUkR6ineCOwyOwhE4v/8aUTOx87mAk1nyjMOf76DQmF+tl2vnS2FssLx5N+Q==", + "node_modules/hypercore-protocol/node_modules/sodium-universal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sodium-universal/-/sodium-universal-2.0.0.tgz", + "integrity": "sha512-csdVyakzHJRyCevY4aZC2Eacda8paf+4nmRGF2N7KxCLKY2Ajn72JsExaQlJQ2BiXJncp44p3T+b80cU+2TTsg==", + "license": "MIT", "dependencies": { - "streamx": "^2.6.0" + "sodium-javascript": "~0.5.0" + }, + "optionalDependencies": { + "sodium-native": "^2.0.0" } }, + "node_modules/hypercore-protocol/node_modules/varint": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==", + "license": "MIT" + }, "node_modules/hypercore/node_modules/hypercore-crypto": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/hypercore-crypto/-/hypercore-crypto-2.3.2.tgz", - "integrity": "sha512-GzHgVOfr5utdiJG5QNcQZ0oo+/YQNbekpg429x00YpUobBraX2qEL3E+iH/EFEIdCQSiGHfToWyYw+OpznSjww==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hypercore-crypto/-/hypercore-crypto-1.0.0.tgz", + "integrity": "sha512-xFwOnNlOt8L+SovC7dTNchKaNYJb5l8rKZZwpWQnCme1r7CU4Hlhp1RDqPES6b0OpS7DkTo9iU0GltQGkpsjMw==", + "license": "MIT", "dependencies": { - "sodium-universal": "^3.0.0", - "uint64be": "^3.0.0" + "buffer-alloc-unsafe": "^1.1.0", + "buffer-from": "^1.1.0", + "sodium-universal": "^2.0.0", + "uint64be": "^2.0.2" } }, - "node_modules/hypercore/node_modules/hypercore-crypto/node_modules/uint64be": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/uint64be/-/uint64be-3.0.0.tgz", - "integrity": "sha512-mliiCSrsE29aNBI7O9W5gGv6WmA9kBR8PtTt6Apaxns076IRdYrrtFhXHEWMj5CSum3U7cv7/pi4xmi4XsIOqg==" + "node_modules/hypercore/node_modules/nanoassert": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/nanoassert/-/nanoassert-1.1.0.tgz", + "integrity": "sha512-C40jQ3NzfkP53NsO8kEOFd79p4b9kDXQMwgiY1z8ZwrDZgUyom0AHwGegF4Dm99L+YoYhuaB0ceerUcXmqr1rQ==", + "license": "ISC" }, - "node_modules/hypercore/node_modules/sodium-universal": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/sodium-universal/-/sodium-universal-3.1.0.tgz", - "integrity": "sha512-N2gxk68Kg2qZLSJ4h0NffEhp4BjgWHCHXVlDi1aG1hA3y+ZeWEmHqnpml8Hy47QzfL1xLy5nwr9LcsWAg2Ep0A==", + "node_modules/hypercore/node_modules/sodium-javascript": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/sodium-javascript/-/sodium-javascript-0.5.6.tgz", + "integrity": "sha512-Uk+JpqHEbzsEmiMxwL7TB/ndhMEpc52KdReYXXSIX2oRFPaI7ZDlDImF8KbkFWbYl9BJRtc82AZ/kNf4/0n9KA==", + "license": "MIT", "dependencies": { "blake2b": "^2.1.1", - "chacha20-universal": "^1.0.4", - "nanoassert": "^2.0.0", - "resolve": "^1.17.0", - "sha256-universal": "^1.1.0", - "sha512-universal": "^1.1.0", + "nanoassert": "^1.0.0", "siphash24": "^1.0.1", - "sodium-javascript": "~0.8.0", - "sodium-native": "^3.2.0", "xsalsa20": "^1.0.0" } }, + "node_modules/hypercore/node_modules/sodium-universal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sodium-universal/-/sodium-universal-2.0.0.tgz", + "integrity": "sha512-csdVyakzHJRyCevY4aZC2Eacda8paf+4nmRGF2N7KxCLKY2Ajn72JsExaQlJQ2BiXJncp44p3T+b80cU+2TTsg==", + "license": "MIT", + "dependencies": { + "sodium-javascript": "~0.5.0" + }, + "optionalDependencies": { + "sodium-native": "^2.0.0" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -2802,21 +2742,18 @@ "node": ">=0.8.19" } }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "license": "ISC", + "optional": true + }, "node_modules/inspect-custom-symbol": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/inspect-custom-symbol/-/inspect-custom-symbol-1.1.1.tgz", @@ -2908,6 +2845,7 @@ "version": "2.15.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "dev": true, "dependencies": { "hasown": "^2.0.2" }, @@ -2950,20 +2888,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -3026,6 +2950,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, "engines": { "node": ">=0.12.0" } @@ -3161,17 +3086,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dependencies": { - "is-docker": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -3231,23 +3145,6 @@ "dev": true, "license": "MIT" }, - "node_modules/json-stable-stringify": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.1.1.tgz", - "integrity": "sha512-SU/971Kt5qVQfJpyDveVhQ/vya+5hvrjClFOcr8c0Fq5aODJjMwutrOfCU+eCnVD5gpx1Q3fEqkyom77zH1iIg==", - "dependencies": { - "call-bind": "^1.0.5", - "isarray": "^2.0.5", - "jsonify": "^0.0.1", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -3255,30 +3152,6 @@ "dev": true, "license": "MIT" }, - "node_modules/json-stable-stringify/node_modules/isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" - }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/jsonify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", - "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -3289,14 +3162,6 @@ "json-buffer": "3.0.1" } }, - "node_modules/klaw-sync": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", - "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", - "dependencies": { - "graceful-fs": "^4.1.11" - } - }, "node_modules/last-one-wins": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/last-one-wins/-/last-one-wins-1.0.4.tgz", @@ -3404,18 +3269,20 @@ } }, "node_modules/merkle-tree-stream": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/merkle-tree-stream/-/merkle-tree-stream-4.0.0.tgz", - "integrity": "sha512-TIurLf/ustQNMXi5foClGTcEsRvH6DCvxeAKu68OrwHMOSM/M1pgPXb7qe52Svk1ClvmZuAVpLtP5FWKzPr/sw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/merkle-tree-stream/-/merkle-tree-stream-3.0.3.tgz", + "integrity": "sha512-cylD/HcPXjeSVEPj4menLP0mndi6gvqmTlDq3QF4Vptn1tgc6ilgK7rdcAUA4X3RTkymXRwLuZpNncIfq1q1AA==", + "license": "MIT", "dependencies": { "flat-tree": "^1.3.0", - "streamx": "^2.7.1" + "readable-stream": "^2.0.5" } }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" @@ -3428,6 +3295,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -3435,14 +3303,6 @@ "node": "*" } }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/minipass": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", @@ -3463,13 +3323,13 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/multifeed": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/multifeed/-/multifeed-6.0.0.tgz", - "integrity": "sha512-PuK9zBYr7lu0WwkDE9kq1523ECi1vOFzS20CHG+2d1ZaGPARNrsGBzYPUvwTueAWpBJPxbpfmR5FORgYQemcOw==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/multifeed/-/multifeed-4.3.0.tgz", + "integrity": "sha512-7RLBHilfBA9FTdTw98YbFv/UEg/44dIEefLRn/ALDnB1MMjB7gxGcgXqE01AH63oW8/uS30mndoFCBx/GyC7fg==", + "license": "ISC", "dependencies": { "debug": "^4.1.0", - "hypercore": "^9.6.0", - "hypercore-protocol": "^8.0.7", + "hypercore-protocol": "^6.8.0", "inherits": "^2.0.3", "mutexify": "^1.2.0", "once": "^1.4.0", @@ -3496,6 +3356,13 @@ "queue-tick": "^1.0.0" } }, + "node_modules/nan": { + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz", + "integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==", + "license": "MIT", + "optional": true + }, "node_modules/nanoassert": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/nanoassert/-/nanoassert-2.0.0.tgz", @@ -3506,18 +3373,11 @@ "resolved": "https://registry.npmjs.org/nanoguard/-/nanoguard-1.3.0.tgz", "integrity": "sha512-K/ON5wyflyPyZskdeT3m7Y2gJVkm3QLdKykMCquAbK8A2erstyMpZUc3NG8Nz5jKdfatiYndONrlmLF8+pGl+A==" }, - "node_modules/nanoresource": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/nanoresource/-/nanoresource-1.3.0.tgz", - "integrity": "sha512-OI5dswqipmlYfyL3k/YMm7mbERlh4Bd1KuKdMHpeoVD1iVxqxaTMKleB4qaA2mbQZ6/zMNSxCXv9M9P/YbqTuQ==", - "dependencies": { - "inherits": "^2.0.4" - } - }, "node_modules/napi-macros": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.2.2.tgz", "integrity": "sha512-hmEVtAGYzVQpCKdbQea4skABsdXW4RUh5t5mJ2zzqowJS2OyXZTU1KhDVFhx+NlWZ4ap9mqR9TcDO3LTTttd+g==", + "license": "MIT", "optional": true }, "node_modules/natural-compare": { @@ -3544,17 +3404,6 @@ "node-gyp-build-test": "build-test.js" } }, - "node_modules/noise-protocol": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/noise-protocol/-/noise-protocol-3.0.2.tgz", - "integrity": "sha512-1jwktH8KYmVwgfLeiCPRmFFsfSQ2i4/R09tL2VRD5bsrfh0tjepAM5hf7Xlp4VZAFJgOlz9j4sPyIbbHM26RAA==", - "dependencies": { - "clone": "^2.1.2", - "hmac-blake2b": "^2.0.2", - "nanoassert": "^2.0.0", - "sodium-universal": "^4.0.0" - } - }, "node_modules/normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -3812,21 +3661,6 @@ "wrappy": "1" } }, - "node_modules/open": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", - "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", - "dependencies": { - "is-docker": "^2.0.0", - "is-wsl": "^2.1.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -3845,14 +3679,6 @@ "node": ">= 0.8.0" } }, - "node_modules/os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/p-event": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/p-event/-/p-event-6.0.1.tgz", @@ -3945,36 +3771,6 @@ "node": ">=4" } }, - "node_modules/patch-package": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.0.tgz", - "integrity": "sha512-da8BVIhzjtgScwDJ2TtKsfT5JFWz1hYoBl9rUQ1f38MC2HwnEIkK8VN3dKMKcP7P7bvvgzNDbfNHtx3MsQb5vA==", - "license": "MIT", - "dependencies": { - "@yarnpkg/lockfile": "^1.1.0", - "chalk": "^4.1.2", - "ci-info": "^3.7.0", - "cross-spawn": "^7.0.3", - "find-yarn-workspace-root": "^2.0.0", - "fs-extra": "^9.0.0", - "json-stable-stringify": "^1.0.2", - "klaw-sync": "^6.0.0", - "minimist": "^1.2.6", - "open": "^7.4.2", - "rimraf": "^2.6.3", - "semver": "^7.5.3", - "slash": "^2.0.0", - "tmp": "^0.0.33", - "yaml": "^2.2.2" - }, - "bin": { - "patch-package": "index.js" - }, - "engines": { - "node": ">=14", - "npm": ">5" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -3985,14 +3781,6 @@ "node": ">=8" } }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -4004,7 +3792,8 @@ "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true }, "node_modules/path-scurry": { "version": "1.11.1", @@ -4039,6 +3828,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, "engines": { "node": ">=8.6" }, @@ -4128,6 +3918,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/protocol-buffers-encodings/-/protocol-buffers-encodings-1.2.0.tgz", "integrity": "sha512-daeNPuKh1NlLD1uDfbLpD+xyUTc07nEtfHwmBZmt/vH0B7VOM+JOCOpDcx9ZRpqHjAiIkGqyTDi+wfGSl17R9w==", + "license": "MIT", "dependencies": { "b4a": "^1.6.0", "signed-varint": "^2.0.1", @@ -4137,7 +3928,8 @@ "node_modules/protocol-buffers-encodings/node_modules/varint": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.0.tgz", - "integrity": "sha512-gC13b/bWrqQoKY2EmROCZ+AR0jitc6DnDGaQ6Ls9QpKmuSgJB1eQ7H3KETtQm7qSdMWMKCmsshyCmUwMLh3OAA==" + "integrity": "sha512-gC13b/bWrqQoKY2EmROCZ+AR0jitc6DnDGaQ6Ls9QpKmuSgJB1eQ7H3KETtQm7qSdMWMKCmsshyCmUwMLh3OAA==", + "license": "MIT" }, "node_modules/punycode": { "version": "2.3.1", @@ -4282,6 +4074,7 @@ "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, "dependencies": { "is-core-module": "^2.13.0", "path-parse": "^1.0.7", @@ -4315,18 +4108,6 @@ "node": ">=0.10.0" } }, - "node_modules/rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -4404,6 +4185,7 @@ "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, "bin": { "semver": "bin/semver.js" }, @@ -4415,6 +4197,7 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", @@ -4447,6 +4230,8 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/sha256-universal/-/sha256-universal-1.2.1.tgz", "integrity": "sha512-ghn3muhdn1ailCQqqceNxRgkOeZSVfSE13RQWEg6njB+itsFzGVSJv+O//2hvNXZuxVIRyNzrgsZ37SPDdGJJw==", + "optional": true, + "peer": true, "dependencies": { "b4a": "^1.0.1", "sha256-wasm": "^2.2.1" @@ -4456,6 +4241,8 @@ "version": "2.2.2", "resolved": "https://registry.npmjs.org/sha256-wasm/-/sha256-wasm-2.2.2.tgz", "integrity": "sha512-qKSGARvao+JQlFiA+sjJZhJ/61gmW/3aNLblB2rsgIxDlDxsJPHo8a1seXj12oKtuHVgJSJJ7QEGBUYQN741lQ==", + "optional": true, + "peer": true, "dependencies": { "b4a": "^1.0.1", "nanoassert": "^2.0.0" @@ -4465,6 +4252,8 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/sha512-universal/-/sha512-universal-1.2.1.tgz", "integrity": "sha512-kehYuigMoRkIngCv7rhgruLJNNHDnitGTBdkcYbCbooL8Cidj/bS78MDxByIjcc69M915WxcQTgZetZ1JbeQTQ==", + "optional": true, + "peer": true, "dependencies": { "b4a": "^1.0.1", "sha512-wasm": "^2.3.1" @@ -4474,6 +4263,8 @@ "version": "2.3.4", "resolved": "https://registry.npmjs.org/sha512-wasm/-/sha512-wasm-2.3.4.tgz", "integrity": "sha512-akWoxJPGCB3aZCrZ+fm6VIFhJ/p8idBv7AWGFng/CZIrQo51oQNsvDbTSRXWAzIiZJvpy16oIDiCCPqTe21sKg==", + "optional": true, + "peer": true, "dependencies": { "b4a": "^1.0.1", "nanoassert": "^2.0.0" @@ -4543,6 +4334,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/signed-varint/-/signed-varint-2.0.1.tgz", "integrity": "sha512-abgDPg1106vuZZOvw7cFwdCABddfJRz5akcCcchzTbhyhYnsG31y4AlZEgp315T7W3nQq5P4xeOm186ZiPVFzw==", + "license": "MIT", "dependencies": { "varint": "~5.0.0" } @@ -4550,66 +4342,8 @@ "node_modules/signed-varint/node_modules/varint": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", - "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" - }, - "node_modules/simple-handshake": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/simple-handshake/-/simple-handshake-3.0.0.tgz", - "integrity": "sha512-8Te0vlxvhpNCMgwnWFTbRR6Re2l8hq8wyXQc3lY9dPYXFxYwVkh79LhDQHFCOWRavmbiOdfqq1l5HT/73Rn2/w==", - "dependencies": { - "nanoassert": "^2.0.0", - "noise-protocol": "^3.0.0" - } - }, - "node_modules/simple-hypercore-protocol": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/simple-hypercore-protocol/-/simple-hypercore-protocol-2.1.2.tgz", - "integrity": "sha512-zCwEMw/Evd5iDPkVEjO+1T3OJqbuDukJSuZtMZ7A7Wfn0RxmaJFbwngfUnDNyQFbPMxiINNxGBMD85fFJF8ghA==", - "dependencies": { - "hypercore-crypto": "^2.1.0", - "noise-protocol": "^3.0.1", - "protocol-buffers-encodings": "^1.1.0", - "simple-handshake": "^3.0.0", - "simple-message-channels": "^1.2.1", - "varint": "^5.0.0", - "xsalsa20-universal": "^1.0.0" - } - }, - "node_modules/simple-hypercore-protocol/node_modules/hypercore-crypto": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/hypercore-crypto/-/hypercore-crypto-2.3.2.tgz", - "integrity": "sha512-GzHgVOfr5utdiJG5QNcQZ0oo+/YQNbekpg429x00YpUobBraX2qEL3E+iH/EFEIdCQSiGHfToWyYw+OpznSjww==", - "dependencies": { - "sodium-universal": "^3.0.0", - "uint64be": "^3.0.0" - } - }, - "node_modules/simple-hypercore-protocol/node_modules/sodium-universal": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/sodium-universal/-/sodium-universal-3.1.0.tgz", - "integrity": "sha512-N2gxk68Kg2qZLSJ4h0NffEhp4BjgWHCHXVlDi1aG1hA3y+ZeWEmHqnpml8Hy47QzfL1xLy5nwr9LcsWAg2Ep0A==", - "dependencies": { - "blake2b": "^2.1.1", - "chacha20-universal": "^1.0.4", - "nanoassert": "^2.0.0", - "resolve": "^1.17.0", - "sha256-universal": "^1.1.0", - "sha512-universal": "^1.1.0", - "siphash24": "^1.0.1", - "sodium-javascript": "~0.8.0", - "sodium-native": "^3.2.0", - "xsalsa20": "^1.0.0" - } - }, - "node_modules/simple-hypercore-protocol/node_modules/uint64be": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/uint64be/-/uint64be-3.0.0.tgz", - "integrity": "sha512-mliiCSrsE29aNBI7O9W5gGv6WmA9kBR8PtTt6Apaxns076IRdYrrtFhXHEWMj5CSum3U7cv7/pi4xmi4XsIOqg==" - }, - "node_modules/simple-hypercore-protocol/node_modules/varint": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", - "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==", + "license": "MIT" }, "node_modules/simple-invariant": { "version": "2.0.1", @@ -4620,19 +4354,6 @@ "node": ">=10" } }, - "node_modules/simple-message-channels": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/simple-message-channels/-/simple-message-channels-1.2.1.tgz", - "integrity": "sha512-knSr69GKW9sCjzpoy817xQelpOASUQ53TXCBcSLDKLE7GTGpUAhZzOZYrdbX2Ig//m+8AIrNp7sM7HDNHBRzXw==", - "dependencies": { - "varint": "^5.0.0" - } - }, - "node_modules/simple-message-channels/node_modules/varint": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", - "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" - }, "node_modules/siphash24": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/siphash24/-/siphash24-1.3.1.tgz", @@ -4641,18 +4362,12 @@ "nanoassert": "^2.0.0" } }, - "node_modules/slash": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", - "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", - "engines": { - "node": ">=6" - } - }, "node_modules/sodium-javascript": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/sodium-javascript/-/sodium-javascript-0.8.0.tgz", "integrity": "sha512-rEBzR5mPxPES+UjyMDvKPIXy9ImF17KOJ32nJNi9uIquWpS/nfj+h6m05J5yLJaGXjgM72LmQoUbWZVxh/rmGg==", + "optional": true, + "peer": true, "dependencies": { "blake2b": "^2.1.1", "chacha20-universal": "^1.0.4", @@ -4664,12 +4379,16 @@ } }, "node_modules/sodium-native": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-3.4.1.tgz", - "integrity": "sha512-PaNN/roiFWzVVTL6OqjzYct38NSXewdl2wz8SRB51Br/MLIJPrbM3XexhVWkq7D3UWMysfrhKVf1v1phZq6MeQ==", + "version": "2.4.9", + "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-2.4.9.tgz", + "integrity": "sha512-mbkiyA2clyfwAyOFIzMvsV6ny2KrKEIhFVASJxWfsmgfUEymgLIS2MLHHcGIQMkrcKhPErRaMR5Dzv0EEn+BWg==", "hasInstallScript": true, + "license": "MIT", + "optional": true, "dependencies": { - "node-gyp-build": "^4.3.0" + "ini": "^1.3.5", + "nan": "^2.14.0", + "node-gyp-build": "^4.1.0" } }, "node_modules/sodium-universal": { @@ -4697,6 +4416,12 @@ "node-gyp-build": "^4.8.0" } }, + "node_modules/sorted-indexof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/sorted-indexof/-/sorted-indexof-1.0.0.tgz", + "integrity": "sha512-N9bptDwgg6V4b9DexkX1Zmj2raV4jRPdVfE3Tri8DvtocNhdl52z+eekD/8mlFDMe9G0uqd95U5YFjHQuA1tGA==", + "license": "MIT" + }, "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", @@ -4956,6 +4681,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4967,6 +4693,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, "engines": { "node": ">= 0.4" }, @@ -5044,26 +4771,17 @@ "readable-stream": "2 || 3" } }, - "node_modules/timeout-refresh": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/timeout-refresh/-/timeout-refresh-1.0.3.tgz", - "integrity": "sha512-Mz0CX4vBGM5lj8ttbIFt7o4ZMxk/9rgudJRh76EvB7xXZMur7T/cjRiH2w4Fmkq0zxf2QpM8IFvOSRn8FEu3gA==" - }, - "node_modules/tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dependencies": { - "os-tmpdir": "~1.0.2" - }, - "engines": { - "node": ">=0.6.0" - } + "node_modules/thunky": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", + "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", + "license": "MIT" }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, "dependencies": { "is-number": "^7.0.0" }, @@ -5269,14 +4987,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/unordered-array-remove": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unordered-array-remove/-/unordered-array-remove-1.0.2.tgz", @@ -5491,26 +5201,6 @@ "resolved": "https://registry.npmjs.org/xsalsa20/-/xsalsa20-1.2.0.tgz", "integrity": "sha512-FIr/DEeoHfj7ftfylnoFt3rAIRoWXpx2AoDfrT2qD2wtp7Dp+COajvs/Icb7uHqRW9m60f5iXZwdsJJO3kvb7w==" }, - "node_modules/xsalsa20-universal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/xsalsa20-universal/-/xsalsa20-universal-1.0.0.tgz", - "integrity": "sha512-0M/X61wiKKAGAMqsxEyJ0kY6NtjpcMiKinYSSsl4K7ypgvqXDTMwQK6hxnYE1s1Jm7h6YKcN8obDUg2CC+jVGA==", - "dependencies": { - "sodium-native": "^3.0.1", - "xsalsa20": "^1.1.0" - } - }, - "node_modules/yaml": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", - "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/yauzl-promise": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yauzl-promise/-/yauzl-promise-4.0.0.tgz", diff --git a/package.json b/package.json index fbc228b..d500f85 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,10 @@ "files": [ "README.md", "LICENSE.md", - "patches", "src", "dist/src" ], "scripts": { - "postinstall": "patch-package", "prepack": "npm run build", "format": "prettier --write .", "build": "tsc", @@ -34,10 +32,10 @@ "license": "MIT", "dependencies": { "archiver": "^7.0.1", + "hypercore": "^7.7.1", "hypercore-crypto": "^3.4.2", - "multifeed": "^6.0.0", + "multifeed": "^4.3.0", "p-event": "^6.0.1", - "patch-package": "^8.0.0", "valibot": "^1.0.0-beta.9", "yauzl-promise": "^4.0.0" }, diff --git a/patches/simple-hypercore-protocol+2.1.2.patch b/patches/simple-hypercore-protocol+2.1.2.patch deleted file mode 100644 index acee703..0000000 --- a/patches/simple-hypercore-protocol+2.1.2.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/node_modules/simple-hypercore-protocol/lib/handshake.js b/node_modules/simple-hypercore-protocol/lib/handshake.js -index efc583d..c7a35e8 100644 ---- a/node_modules/simple-hypercore-protocol/lib/handshake.js -+++ b/node_modules/simple-hypercore-protocol/lib/handshake.js -@@ -1,5 +1,5 @@ - const SH = require('simple-handshake') --const DH = require('noise-protocol/dh') -+const DH = require('noise-protocol/dh')() - const crypto = require('hypercore-crypto') - const varint = require('varint') - diff --git a/src/lib/hypercoreUtil.js b/src/lib/hypercoreUtil.js index ced78b6..d10a167 100644 --- a/src/lib/hypercoreUtil.js +++ b/src/lib/hypercoreUtil.js @@ -1,21 +1,17 @@ +import { pEvent } from 'p-event' /** @import { Hypercore } from 'hypercore' */ /** - * Wraps `Hypercore.prototype.ready` in a promise. + * Waits for a Hypercore to be ready. * * @param {Hypercore} hypercore * @returns {Promise} */ -export const ready = (hypercore) => - new Promise((resolve, reject) => { - hypercore.ready((err) => { - if (err) { - reject(err) - } else { - resolve() - } - }) - }) +export const ready = async (hypercore) => { + const isReady = Boolean(hypercore.key) + if (isReady) return + await pEvent(hypercore, 'ready') +} /** * Wraps `Hypercore.prototype.rootHashes` in a promise. diff --git a/src/lib/readableStreamToAsyncIterable.js b/src/lib/readableStreamToAsyncIterable.js new file mode 100644 index 0000000..10b094d --- /dev/null +++ b/src/lib/readableStreamToAsyncIterable.js @@ -0,0 +1,11 @@ +import { pEventIterator } from 'p-event' + +/** + * This is needed because the stream returned by + * `Hypercore.prototype.createReadStream` is not iterable with `for await`. + * Normally, Node streams don't need this wrapper. + * @param {NodeJS.ReadableStream} readable + * @returns {AsyncIterable} + */ +export const readableStreamToAsyncIterable = (readable) => + pEventIterator(readable, 'data', { resolutionEvents: ['end'] }) diff --git a/src/writer.js b/src/writer.js index 8e65b45..adebbb3 100644 --- a/src/writer.js +++ b/src/writer.js @@ -1,5 +1,6 @@ import archiver from 'archiver' import * as hypercoreCrypto from 'hypercore-crypto' +import hypercore from 'hypercore' import multifeed from 'multifeed' import fs from 'node:fs' import { readdir } from 'node:fs/promises' @@ -7,6 +8,7 @@ import * as path from 'node:path' import { pEvent } from 'p-event' import * as hypercoreUtil from './lib/hypercoreUtil.js' import * as multifeedUtil from './lib/multifeedUtil.js' +import { readableStreamToAsyncIterable } from './lib/readableStreamToAsyncIterable.js' import { noop } from './lib/noop.js' /** @import { Hypercore } from 'hypercore' */ /** @import { HypercoreMetadata, DocumentVersion } from './types.js' */ @@ -65,7 +67,7 @@ export async function write(inputPath, outputPath) { * @returns {AsyncGenerator} */ async function* getInputDocuments(inputPath) { - const multi = multifeed(inputPath, { + const multi = multifeed(hypercore, inputPath, { createIfMissing: false, valueEncoding: 'json', stats: false, @@ -80,7 +82,7 @@ async function* getInputDocuments(inputPath) { const hypercoreMetadata = await getHypercoreMetadata(hypercore) - for await (const document of stream) { + for await (const document of readableStreamToAsyncIterable(stream)) { const { id, version } = parseDocument(document) yield { id, version, document, hypercoreMetadata } } @@ -92,11 +94,18 @@ async function* getInputDocuments(inputPath) { * @returns {Promise} */ async function getHypercoreMetadata(hypercore) { + await hypercoreUtil.ready(hypercore) + + if (!hypercore.key) { + throw new Error("Hypercore is missing a key even though it's ready") + } + const rootHashesPromise = hypercoreUtil.rootHashes(hypercore, 0) const signaturePromise = hypercoreUtil.signature( hypercore, Math.max(0, hypercore.length - 1) ) + return { rootHashChecksum: hypercoreCrypto .tree(await rootHashesPromise) diff --git a/test/lib/readableStreamToAsyncIterable.js b/test/lib/readableStreamToAsyncIterable.js new file mode 100644 index 0000000..01309d5 --- /dev/null +++ b/test/lib/readableStreamToAsyncIterable.js @@ -0,0 +1,47 @@ +import assert from 'node:assert/strict' +import test from 'node:test' +import { Readable } from 'node:stream' +import { readableStreamToAsyncIterable } from '../../src/lib/readableStreamToAsyncIterable.js' + +class TestStream extends Readable { + #count = 0 + + /** + * @param {undefined | string} value + * @returns {void} + */ + #push(value) { + this.push(value ? Buffer.from(value) : null) + this.#count++ + } + + /** + * @override + */ + _read() { + this.#push(['foo', 'bar', 'baz'][this.#count]) + } + + /** + * @override + */ + [Symbol.asyncIterator]() { + // This is a hack to satisfy TypeScript, which will otherwise complain that + // this method returns the wrong type. + if (Date.now()) { + assert.fail('Wrapper should not call this method') + } + return super[Symbol.asyncIterator]() + } +} + +test('returns an async iterable', async () => { + const result = readableStreamToAsyncIterable(new TestStream()) + + const chunks = [] + for await (const chunk of result) chunks.push(chunk) + assert.deepEqual( + chunks, + ['foo', 'bar', 'baz'].map((str) => Buffer.from(str)) + ) +}) diff --git a/types/hypercore.d.ts b/types/hypercore.d.ts index aabf440..4bdc729 100644 --- a/types/hypercore.d.ts +++ b/types/hypercore.d.ts @@ -2,13 +2,13 @@ * This is a subset of the types we actually use, so lots of things are missing. */ declare module 'hypercore' { - export class Hypercore { - get key(): Buffer - get length(): number + import { EventEmitter } from 'node:events' - ready(cb: (err: null | Error) => unknown): void + export class Hypercore extends EventEmitter { + get key(): null | Buffer + get length(): number - createReadStream(): AsyncIterable + createReadStream(): NodeJS.ReadableStream signature( index: number, @@ -26,4 +26,6 @@ declare module 'hypercore' { ) => unknown ): void } + + export default function hypercore(...args: unknown[]): Hypercore } diff --git a/types/multifeed.d.ts b/types/multifeed.d.ts index 2c9d4a9..8ce3a70 100644 --- a/types/multifeed.d.ts +++ b/types/multifeed.d.ts @@ -11,5 +11,9 @@ declare module 'multifeed' { feeds(): Hypercore[] } - export default function multifeed(storage: string, opts?: unknown): Multifeed + export default function multifeed( + hypercore: () => Hypercore, + storage: string, + opts?: unknown + ): Multifeed }