@fireproof/vendor 0.0.0-smoke
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +29 -0
- package/patched/@ipld/dag-json/.github/dependabot.yml +11 -0
- package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +28 -0
- package/patched/@ipld/dag-json/CHANGELOG.md +202 -0
- package/patched/@ipld/dag-json/LICENSE +4 -0
- package/patched/@ipld/dag-json/LICENSE-APACHE +5 -0
- package/patched/@ipld/dag-json/LICENSE-MIT +19 -0
- package/patched/@ipld/dag-json/README.md +58 -0
- package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
- package/patched/@ipld/dag-json/package.json +173 -0
- package/patched/@ipld/dag-json/src/index.js +291 -0
- package/patched/@ipld/dag-json/test/test-basics.spec.js +290 -0
- package/patched/@ipld/dag-json/test/ts-use/package.json +11 -0
- package/patched/@ipld/dag-json/test/ts-use/src/main.ts +54 -0
- package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +9 -0
- package/patched/@ipld/dag-json/tsconfig.json +14 -0
- package/patched/cborg/.github/dependabot.yml +16 -0
- package/patched/cborg/.github/workflows/test-and-release.yml +52 -0
- package/patched/cborg/CHANGELOG.md +513 -0
- package/patched/cborg/LICENSE +13 -0
- package/patched/cborg/README.md +515 -0
- package/patched/cborg/bench/bench.js +117 -0
- package/patched/cborg/bench/json.js +124 -0
- package/patched/cborg/bench/package.json +8 -0
- package/patched/cborg/cborg-4.2.7.tgz +0 -0
- package/patched/cborg/cborg.js +31 -0
- package/patched/cborg/example-bytestrings.js +180 -0
- package/patched/cborg/example-json.js +6 -0
- package/patched/cborg/example.js +5 -0
- package/patched/cborg/interface.ts +56 -0
- package/patched/cborg/lib/0uint.js +227 -0
- package/patched/cborg/lib/1negint.js +111 -0
- package/patched/cborg/lib/2bytes.js +133 -0
- package/patched/cborg/lib/3string.js +90 -0
- package/patched/cborg/lib/4array.js +113 -0
- package/patched/cborg/lib/5map.js +113 -0
- package/patched/cborg/lib/6tag.js +80 -0
- package/patched/cborg/lib/7float.js +308 -0
- package/patched/cborg/lib/bin.js +189 -0
- package/patched/cborg/lib/bl.js +124 -0
- package/patched/cborg/lib/byte-utils.js +417 -0
- package/patched/cborg/lib/common.js +27 -0
- package/patched/cborg/lib/decode.js +209 -0
- package/patched/cborg/lib/diagnostic.js +156 -0
- package/patched/cborg/lib/diagnostic_test.js +117 -0
- package/patched/cborg/lib/encode.js +464 -0
- package/patched/cborg/lib/is.js +106 -0
- package/patched/cborg/lib/json/decode.js +462 -0
- package/patched/cborg/lib/json/encode.js +299 -0
- package/patched/cborg/lib/json/json.js +4 -0
- package/patched/cborg/lib/jump.js +209 -0
- package/patched/cborg/lib/length.js +61 -0
- package/patched/cborg/lib/token.js +76 -0
- package/patched/cborg/package.json +169 -0
- package/patched/cborg/pnpm-lock.yaml +6096 -0
- package/patched/cborg/taglib.js +73 -0
- package/patched/cborg/test/appendix_a.js +647 -0
- package/patched/cborg/test/common.js +18 -0
- package/patched/cborg/test/node-test-bin.js +402 -0
- package/patched/cborg/test/noop-bin-test.js +3 -0
- package/patched/cborg/test/test-0uint.js +103 -0
- package/patched/cborg/test/test-1negint.js +96 -0
- package/patched/cborg/test/test-2bytes.js +198 -0
- package/patched/cborg/test/test-3string.js +136 -0
- package/patched/cborg/test/test-4array.js +93 -0
- package/patched/cborg/test/test-5map.js +284 -0
- package/patched/cborg/test/test-6tag.js +85 -0
- package/patched/cborg/test/test-7float.js +131 -0
- package/patched/cborg/test/test-bl.js +37 -0
- package/patched/cborg/test/test-cbor-vectors.js +107 -0
- package/patched/cborg/test/test-decode-errors.js +65 -0
- package/patched/cborg/test/test-fuzz.js +42 -0
- package/patched/cborg/test/test-json.js +219 -0
- package/patched/cborg/test/test-length.js +65 -0
- package/patched/cborg/test/test-partial.js +111 -0
- package/patched/cborg/tsconfig.json +45 -0
- package/patched/cborg/types/cborg.d.ts +28 -0
- package/patched/cborg/types/cborg.d.ts.map +1 -0
- package/patched/cborg/types/example.d.ts +2 -0
- package/patched/cborg/types/example.d.ts.map +1 -0
- package/patched/cborg/types/interface.d.ts +47 -0
- package/patched/cborg/types/interface.d.ts.map +1 -0
- package/patched/cborg/types/lib/0uint.d.ts +100 -0
- package/patched/cborg/types/lib/0uint.d.ts.map +1 -0
- package/patched/cborg/types/lib/1negint.d.ts +58 -0
- package/patched/cborg/types/lib/1negint.d.ts.map +1 -0
- package/patched/cborg/types/lib/2bytes.d.ts +68 -0
- package/patched/cborg/types/lib/2bytes.d.ts.map +1 -0
- package/patched/cborg/types/lib/3string.d.ts +46 -0
- package/patched/cborg/types/lib/3string.d.ts.map +1 -0
- package/patched/cborg/types/lib/4array.d.ts +65 -0
- package/patched/cborg/types/lib/4array.d.ts.map +1 -0
- package/patched/cborg/types/lib/5map.d.ts +65 -0
- package/patched/cborg/types/lib/5map.d.ts.map +1 -0
- package/patched/cborg/types/lib/6tag.d.ts +61 -0
- package/patched/cborg/types/lib/6tag.d.ts.map +1 -0
- package/patched/cborg/types/lib/7float.d.ts +60 -0
- package/patched/cborg/types/lib/7float.d.ts.map +1 -0
- package/patched/cborg/types/lib/bin.d.ts +4 -0
- package/patched/cborg/types/lib/bin.d.ts.map +1 -0
- package/patched/cborg/types/lib/bl.d.ts +26 -0
- package/patched/cborg/types/lib/bl.d.ts.map +1 -0
- package/patched/cborg/types/lib/byte-utils.d.ts +53 -0
- package/patched/cborg/types/lib/byte-utils.d.ts.map +1 -0
- package/patched/cborg/types/lib/common.d.ts +10 -0
- package/patched/cborg/types/lib/common.d.ts.map +1 -0
- package/patched/cborg/types/lib/decode.d.ts +41 -0
- package/patched/cborg/types/lib/decode.d.ts.map +1 -0
- package/patched/cborg/types/lib/diagnostic.d.ts +12 -0
- package/patched/cborg/types/lib/diagnostic.d.ts.map +1 -0
- package/patched/cborg/types/lib/diagnostic_test.d.ts +2 -0
- package/patched/cborg/types/lib/diagnostic_test.d.ts.map +1 -0
- package/patched/cborg/types/lib/encode.d.ts +50 -0
- package/patched/cborg/types/lib/encode.d.ts.map +1 -0
- package/patched/cborg/types/lib/is.d.ts +6 -0
- package/patched/cborg/types/lib/is.d.ts.map +1 -0
- package/patched/cborg/types/lib/json/decode.d.ts +67 -0
- package/patched/cborg/types/lib/json/decode.d.ts.map +1 -0
- package/patched/cborg/types/lib/json/encode.d.ts +11 -0
- package/patched/cborg/types/lib/json/encode.d.ts.map +1 -0
- package/patched/cborg/types/lib/json/forward-cborg.d.ts +6 -0
- package/patched/cborg/types/lib/json/forward-cborg.d.ts.map +1 -0
- package/patched/cborg/types/lib/json/json.d.ts +6 -0
- package/patched/cborg/types/lib/json/json.d.ts.map +1 -0
- package/patched/cborg/types/lib/jump.d.ts +12 -0
- package/patched/cborg/types/lib/jump.d.ts.map +1 -0
- package/patched/cborg/types/lib/length.d.ts +27 -0
- package/patched/cborg/types/lib/length.d.ts.map +1 -0
- package/patched/cborg/types/lib/token.d.ts +59 -0
- package/patched/cborg/types/lib/token.d.ts.map +1 -0
- package/patched/cborg/types/taglib.d.ts +18 -0
- package/patched/cborg/types/taglib.d.ts.map +1 -0
- package/patched/cborg/types/tsconfig.tsbuildinfo +1 -0
- package/src/@ipld/car/car/LICENSE +4 -0
- package/src/@ipld/car/car/README.md +1078 -0
- package/src/@ipld/car/car/dist/index.min.js +5 -0
- package/src/@ipld/car/car/dist/src/api.d.ts +72 -0
- package/src/@ipld/car/car/dist/src/api.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts +67 -0
- package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts +116 -0
- package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/buffer-reader.d.ts +31 -0
- package/src/@ipld/car/car/dist/src/buffer-reader.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/buffer-writer.d.ts +86 -0
- package/src/@ipld/car/car/dist/src/buffer-writer.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/coding.d.ts +49 -0
- package/src/@ipld/car/car/dist/src/coding.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/decoder-common.d.ts +43 -0
- package/src/@ipld/car/car/dist/src/decoder-common.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/decoder.d.ts +87 -0
- package/src/@ipld/car/car/dist/src/decoder.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/encoder.d.ts +17 -0
- package/src/@ipld/car/car/dist/src/encoder.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/header-validator.d.ts +5 -0
- package/src/@ipld/car/car/dist/src/header-validator.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/index-browser.d.ts +10 -0
- package/src/@ipld/car/car/dist/src/index-browser.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/index.d.ts +11 -0
- package/src/@ipld/car/car/dist/src/index.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts +5 -0
- package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/indexed-reader.d.ts +152 -0
- package/src/@ipld/car/car/dist/src/indexed-reader.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/indexer.d.ts +95 -0
- package/src/@ipld/car/car/dist/src/indexer.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/iterator-channel.d.ts +7 -0
- package/src/@ipld/car/car/dist/src/iterator-channel.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/iterator.d.ts +174 -0
- package/src/@ipld/car/car/dist/src/iterator.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/reader-browser.d.ts +151 -0
- package/src/@ipld/car/car/dist/src/reader-browser.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/reader.d.ts +35 -0
- package/src/@ipld/car/car/dist/src/reader.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/writer-browser.d.ts +155 -0
- package/src/@ipld/car/car/dist/src/writer-browser.d.ts.map +1 -0
- package/src/@ipld/car/car/dist/src/writer.d.ts +45 -0
- package/src/@ipld/car/car/dist/src/writer.d.ts.map +1 -0
- package/src/@ipld/car/car/node_modules/.bin/cborg +17 -0
- package/src/@ipld/car/car/package.json +235 -0
- package/src/@ipld/car/car/src/api.ts +90 -0
- package/src/@ipld/car/car/src/buffer-decoder.js +213 -0
- package/src/@ipld/car/car/src/buffer-reader-browser.js +144 -0
- package/src/@ipld/car/car/src/buffer-reader.js +51 -0
- package/src/@ipld/car/car/src/buffer-writer.js +286 -0
- package/src/@ipld/car/car/src/coding.ts +68 -0
- package/src/@ipld/car/car/src/decoder-common.js +82 -0
- package/src/@ipld/car/car/src/decoder.js +347 -0
- package/src/@ipld/car/car/src/encoder.js +76 -0
- package/src/@ipld/car/car/src/header-validator.js +214 -0
- package/src/@ipld/car/car/src/header.ipldsch +18 -0
- package/src/@ipld/car/car/src/index-browser.js +18 -0
- package/src/@ipld/car/car/src/index.js +21 -0
- package/src/@ipld/car/car/src/indexed-reader-browser.js +7 -0
- package/src/@ipld/car/car/src/indexed-reader.js +211 -0
- package/src/@ipld/car/car/src/indexer.js +130 -0
- package/src/@ipld/car/car/src/iterator-channel.js +91 -0
- package/src/@ipld/car/car/src/iterator.js +267 -0
- package/src/@ipld/car/car/src/reader-browser.js +194 -0
- package/src/@ipld/car/car/src/reader.js +56 -0
- package/src/@ipld/car/car/src/writer-browser.js +250 -0
- package/src/@ipld/car/car/src/writer.js +84 -0
- package/src/@ipld/dag-cbor/dag-cbor/LICENSE +4 -0
- package/src/@ipld/dag-cbor/dag-cbor/README.md +80 -0
- package/src/@ipld/dag-cbor/dag-cbor/dist/index.min.js +3 -0
- package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts +67 -0
- package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts.map +1 -0
- package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +17 -0
- package/src/@ipld/dag-cbor/dag-cbor/package.json +171 -0
- package/src/@ipld/dag-cbor/dag-cbor/src/index.js +147 -0
- package/src/@ipld/dag-json/dag-json/LICENSE +4 -0
- package/src/@ipld/dag-json/dag-json/README.md +58 -0
- package/src/@ipld/dag-json/dag-json/dist/index.min.js +3 -0
- package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts +12 -0
- package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts.map +1 -0
- package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +17 -0
- package/src/@ipld/dag-json/dag-json/package.json +173 -0
- package/src/@ipld/dag-json/dag-json/src/index.js +291 -0
- package/src/@web3-storage/pail/pail/LICENSE.md +232 -0
- package/src/@web3-storage/pail/pail/README.md +84 -0
- package/src/@web3-storage/pail/pail/cli.js +218 -0
- package/src/@web3-storage/pail/pail/dist/src/api.d.ts +59 -0
- package/src/@web3-storage/pail/pail/dist/src/api.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts +31 -0
- package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts +75 -0
- package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts +3 -0
- package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/block.d.ts +35 -0
- package/src/@web3-storage/pail/pail/dist/src/block.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts +10 -0
- package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts +48 -0
- package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts +26 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts +11 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts +5 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts +9 -0
- package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/diff.d.ts +13 -0
- package/src/@web3-storage/pail/pail/dist/src/diff.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/index.d.ts +10 -0
- package/src/@web3-storage/pail/pail/dist/src/index.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/merge.d.ts +5 -0
- package/src/@web3-storage/pail/pail/dist/src/merge.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/src/shard.d.ts +43 -0
- package/src/@web3-storage/pail/pail/dist/src/shard.d.ts.map +1 -0
- package/src/@web3-storage/pail/pail/dist/tsconfig.tsbuildinfo +1 -0
- package/src/@web3-storage/pail/pail/node_modules/.bin/pail +17 -0
- package/src/@web3-storage/pail/pail/package.json +173 -0
- package/src/@web3-storage/pail/pail/src/api.js +1 -0
- package/src/@web3-storage/pail/pail/src/api.ts +90 -0
- package/src/@web3-storage/pail/pail/src/batch/api.js +1 -0
- package/src/@web3-storage/pail/pail/src/batch/api.ts +59 -0
- package/src/@web3-storage/pail/pail/src/batch/index.js +258 -0
- package/src/@web3-storage/pail/pail/src/batch/shard.js +13 -0
- package/src/@web3-storage/pail/pail/src/block.js +75 -0
- package/src/@web3-storage/pail/pail/src/clock/api.js +1 -0
- package/src/@web3-storage/pail/pail/src/clock/api.ts +12 -0
- package/src/@web3-storage/pail/pail/src/clock/index.js +182 -0
- package/src/@web3-storage/pail/pail/src/crdt/api.js +1 -0
- package/src/@web3-storage/pail/pail/src/crdt/api.ts +33 -0
- package/src/@web3-storage/pail/pail/src/crdt/batch/api.js +1 -0
- package/src/@web3-storage/pail/pail/src/crdt/batch/api.ts +30 -0
- package/src/@web3-storage/pail/pail/src/crdt/batch/index.js +155 -0
- package/src/@web3-storage/pail/pail/src/crdt/index.js +354 -0
- package/src/@web3-storage/pail/pail/src/diff.js +151 -0
- package/src/@web3-storage/pail/pail/src/index.js +406 -0
- package/src/@web3-storage/pail/pail/src/merge.js +43 -0
- package/src/@web3-storage/pail/pail/src/shard.js +180 -0
- package/src/cborg/cborg/.github/dependabot.yml +16 -0
- package/src/cborg/cborg/.github/workflows/test-and-release.yml +52 -0
- package/src/cborg/cborg/CHANGELOG.md +513 -0
- package/src/cborg/cborg/LICENSE +13 -0
- package/src/cborg/cborg/README.md +515 -0
- package/src/cborg/cborg/bench/bench.js +117 -0
- package/src/cborg/cborg/bench/json.js +124 -0
- package/src/cborg/cborg/bench/package.json +8 -0
- package/src/cborg/cborg/cborg.js +31 -0
- package/src/cborg/cborg/example-bytestrings.js +180 -0
- package/src/cborg/cborg/example-json.js +6 -0
- package/src/cborg/cborg/example.js +5 -0
- package/src/cborg/cborg/interface.ts +56 -0
- package/src/cborg/cborg/lib/0uint.js +227 -0
- package/src/cborg/cborg/lib/1negint.js +111 -0
- package/src/cborg/cborg/lib/2bytes.js +133 -0
- package/src/cborg/cborg/lib/3string.js +90 -0
- package/src/cborg/cborg/lib/4array.js +113 -0
- package/src/cborg/cborg/lib/5map.js +113 -0
- package/src/cborg/cborg/lib/6tag.js +80 -0
- package/src/cborg/cborg/lib/7float.js +308 -0
- package/src/cborg/cborg/lib/bin.js +189 -0
- package/src/cborg/cborg/lib/bl.js +124 -0
- package/src/cborg/cborg/lib/byte-utils.js +417 -0
- package/src/cborg/cborg/lib/common.js +27 -0
- package/src/cborg/cborg/lib/decode.js +209 -0
- package/src/cborg/cborg/lib/diagnostic.js +156 -0
- package/src/cborg/cborg/lib/diagnostic_test.js +117 -0
- package/src/cborg/cborg/lib/encode.js +464 -0
- package/src/cborg/cborg/lib/is.js +106 -0
- package/src/cborg/cborg/lib/json/decode.js +462 -0
- package/src/cborg/cborg/lib/json/encode.js +299 -0
- package/src/cborg/cborg/lib/json/json.js +4 -0
- package/src/cborg/cborg/lib/jump.js +209 -0
- package/src/cborg/cborg/lib/length.js +61 -0
- package/src/cborg/cborg/lib/token.js +76 -0
- package/src/cborg/cborg/node_modules/.bin/cborg +17 -0
- package/src/cborg/cborg/package.json +168 -0
- package/src/cborg/cborg/taglib.js +73 -0
- package/src/cborg/cborg/test/appendix_a.js +647 -0
- package/src/cborg/cborg/test/common.js +18 -0
- package/src/cborg/cborg/test/node-test-bin.js +402 -0
- package/src/cborg/cborg/test/noop-bin-test.js +3 -0
- package/src/cborg/cborg/test/test-0uint.js +103 -0
- package/src/cborg/cborg/test/test-1negint.js +96 -0
- package/src/cborg/cborg/test/test-2bytes.js +198 -0
- package/src/cborg/cborg/test/test-3string.js +136 -0
- package/src/cborg/cborg/test/test-4array.js +93 -0
- package/src/cborg/cborg/test/test-5map.js +284 -0
- package/src/cborg/cborg/test/test-6tag.js +85 -0
- package/src/cborg/cborg/test/test-7float.js +131 -0
- package/src/cborg/cborg/test/test-bl.js +37 -0
- package/src/cborg/cborg/test/test-cbor-vectors.js +107 -0
- package/src/cborg/cborg/test/test-decode-errors.js +65 -0
- package/src/cborg/cborg/test/test-fuzz.js +42 -0
- package/src/cborg/cborg/test/test-json.js +219 -0
- package/src/cborg/cborg/test/test-length.js +65 -0
- package/src/cborg/cborg/test/test-partial.js +111 -0
- package/src/cborg/cborg/tsconfig.json +45 -0
- package/src/cborg/cborg/types/cborg.d.ts +28 -0
- package/src/cborg/cborg/types/cborg.d.ts.map +1 -0
- package/src/cborg/cborg/types/example.d.ts +2 -0
- package/src/cborg/cborg/types/example.d.ts.map +1 -0
- package/src/cborg/cborg/types/interface.d.ts +47 -0
- package/src/cborg/cborg/types/interface.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/0uint.d.ts +100 -0
- package/src/cborg/cborg/types/lib/0uint.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/1negint.d.ts +58 -0
- package/src/cborg/cborg/types/lib/1negint.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/2bytes.d.ts +68 -0
- package/src/cborg/cborg/types/lib/2bytes.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/3string.d.ts +46 -0
- package/src/cborg/cborg/types/lib/3string.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/4array.d.ts +65 -0
- package/src/cborg/cborg/types/lib/4array.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/5map.d.ts +65 -0
- package/src/cborg/cborg/types/lib/5map.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/6tag.d.ts +61 -0
- package/src/cborg/cborg/types/lib/6tag.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/7float.d.ts +60 -0
- package/src/cborg/cborg/types/lib/7float.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/bin.d.ts +4 -0
- package/src/cborg/cborg/types/lib/bin.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/bl.d.ts +26 -0
- package/src/cborg/cborg/types/lib/bl.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/byte-utils.d.ts +53 -0
- package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/common.d.ts +10 -0
- package/src/cborg/cborg/types/lib/common.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/decode.d.ts +41 -0
- package/src/cborg/cborg/types/lib/decode.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/diagnostic.d.ts +12 -0
- package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +2 -0
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/encode.d.ts +50 -0
- package/src/cborg/cborg/types/lib/encode.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/is.d.ts +6 -0
- package/src/cborg/cborg/types/lib/is.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/json/decode.d.ts +67 -0
- package/src/cborg/cborg/types/lib/json/decode.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/json/encode.d.ts +11 -0
- package/src/cborg/cborg/types/lib/json/encode.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +6 -0
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/json/json.d.ts +6 -0
- package/src/cborg/cborg/types/lib/json/json.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/jump.d.ts +12 -0
- package/src/cborg/cborg/types/lib/jump.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/length.d.ts +27 -0
- package/src/cborg/cborg/types/lib/length.d.ts.map +1 -0
- package/src/cborg/cborg/types/lib/token.d.ts +59 -0
- package/src/cborg/cborg/types/lib/token.d.ts.map +1 -0
- package/src/cborg/cborg/types/taglib.d.ts +18 -0
- package/src/cborg/cborg/types/taglib.d.ts.map +1 -0
- package/src/cborg/cborg/types/tsconfig.tsbuildinfo +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/README.md +105 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/index.min.js +3 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts +57 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js +73 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts +355 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js +197 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +9 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +9 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +38 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js +30 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js +9 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +37 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +29 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +153 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +59 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +25 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +104 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +3 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +20 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +6 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +116 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +57 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +6 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +30 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +1 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/typedoc-urls.json +58 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/package.json +180 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/errors.ts +87 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/index.ts +498 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +12 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +12 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/identity.ts +49 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/index.ts +35 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/json.ts +12 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/raw.ts +49 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +39 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +198 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +76 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +37 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +121 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +24 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +149 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +62 -0
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +38 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CID } from 'multiformats/cid'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Literally any `Iterable` (async or regular).
|
|
5
|
+
*/
|
|
6
|
+
export type AwaitIterable<T> = Iterable<T> | AsyncIterable<T>
|
|
7
|
+
|
|
8
|
+
export type { CID }
|
|
9
|
+
/* Generic types for interfacing with block storage */
|
|
10
|
+
|
|
11
|
+
export interface Block {
|
|
12
|
+
cid: CID
|
|
13
|
+
bytes: Uint8Array
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BlockHeader {
|
|
17
|
+
cid: CID
|
|
18
|
+
length: number
|
|
19
|
+
blockLength: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BlockIndex extends BlockHeader {
|
|
23
|
+
offset: number
|
|
24
|
+
blockOffset: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface RootsReader {
|
|
28
|
+
version: number
|
|
29
|
+
getRoots(): Promise<CID[]>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RootsBufferReader {
|
|
33
|
+
version: number
|
|
34
|
+
getRoots(): CID[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface BlockIterator extends AsyncIterable<Block> {}
|
|
38
|
+
|
|
39
|
+
export interface CIDIterator extends AsyncIterable<CID> {}
|
|
40
|
+
|
|
41
|
+
export interface BlockReader {
|
|
42
|
+
has(key: CID): Promise<boolean>
|
|
43
|
+
get(key: CID): Promise<Block | undefined>
|
|
44
|
+
blocks(): BlockIterator
|
|
45
|
+
cids(): CIDIterator
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface BlockBufferReader {
|
|
49
|
+
has(key: CID): boolean
|
|
50
|
+
get(key: CID): Block | undefined
|
|
51
|
+
blocks(): Iterable<Block>
|
|
52
|
+
cids(): Iterable<CID>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface BlockWriter {
|
|
56
|
+
put(block: Block): Promise<void>
|
|
57
|
+
close(): Promise<void>
|
|
58
|
+
version(): number
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface CarBufferWriter {
|
|
62
|
+
addRoot(root: CID, options?: { resize?: boolean }): CarBufferWriter
|
|
63
|
+
write(block: Block): CarBufferWriter
|
|
64
|
+
close(options?: { resize?: boolean }): Uint8Array
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface CarBufferWriterOptions {
|
|
68
|
+
roots?: CID[] // defaults to []
|
|
69
|
+
byteOffset?: number // defaults to 0
|
|
70
|
+
byteLength?: number // defaults to buffer.byteLength
|
|
71
|
+
|
|
72
|
+
headerSize?: number // defaults to size needed for provided roots
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface WriterChannel {
|
|
76
|
+
writer: BlockWriter
|
|
77
|
+
out: AsyncIterable<Uint8Array>
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface CarReader extends BlockReader, RootsReader {}
|
|
81
|
+
export interface CarBufferReader extends BlockBufferReader, RootsBufferReader {}
|
|
82
|
+
|
|
83
|
+
/* Specific implementations for CAR block storage */
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
export interface CarBlockIterator extends BlockIterator, RootsReader {}
|
|
87
|
+
export interface CarCIDIterator extends CIDIterator, RootsReader {}
|
|
88
|
+
export interface CarIndexer extends AsyncIterable<BlockIndex>, RootsReader {}
|
|
89
|
+
export interface CarWriter extends BlockWriter {}
|
|
90
|
+
*/
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { decode as decodeDagCbor } from "@fireproof/vendor/@ipld/dag-cbor"
|
|
2
|
+
import { CID } from 'multiformats/cid'
|
|
3
|
+
import * as Digest from 'multiformats/hashes/digest'
|
|
4
|
+
import { CIDV0_BYTES, decodeV2Header, decodeVarint, getMultihashLength, V2_HEADER_LENGTH } from './decoder-common.js'
|
|
5
|
+
import { CarV1HeaderOrV2Pragma } from './header-validator.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('./api').Block} Block
|
|
9
|
+
* @typedef {import('./api').BlockHeader} BlockHeader
|
|
10
|
+
* @typedef {import('./api').BlockIndex} BlockIndex
|
|
11
|
+
* @typedef {import('./coding').BytesBufferReader} BytesBufferReader
|
|
12
|
+
* @typedef {import('./coding').CarHeader} CarHeader
|
|
13
|
+
* @typedef {import('./coding').CarV2Header} CarV2Header
|
|
14
|
+
* @typedef {import('./coding').CarV2FixedHeader} CarV2FixedHeader
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Reads header data from a `BytesReader`. The header may either be in the form
|
|
19
|
+
* of a `CarHeader` or `CarV2Header` depending on the CAR being read.
|
|
20
|
+
*
|
|
21
|
+
* @name decoder.readHeader(reader)
|
|
22
|
+
* @param {BytesBufferReader} reader
|
|
23
|
+
* @param {number} [strictVersion]
|
|
24
|
+
* @returns {CarHeader | CarV2Header}
|
|
25
|
+
*/
|
|
26
|
+
export function readHeader (reader, strictVersion) {
|
|
27
|
+
const length = decodeVarint(reader.upTo(8), reader)
|
|
28
|
+
if (length === 0) {
|
|
29
|
+
throw new Error('Invalid CAR header (zero length)')
|
|
30
|
+
}
|
|
31
|
+
const header = reader.exactly(length, true)
|
|
32
|
+
const block = decodeDagCbor(header)
|
|
33
|
+
if (CarV1HeaderOrV2Pragma.toTyped(block) === undefined) {
|
|
34
|
+
throw new Error('Invalid CAR header format')
|
|
35
|
+
}
|
|
36
|
+
if ((block.version !== 1 && block.version !== 2) || (strictVersion !== undefined && block.version !== strictVersion)) {
|
|
37
|
+
throw new Error(`Invalid CAR version: ${block.version}${strictVersion !== undefined ? ` (expected ${strictVersion})` : ''}`)
|
|
38
|
+
}
|
|
39
|
+
if (block.version === 1) {
|
|
40
|
+
// CarV1HeaderOrV2Pragma makes roots optional, let's make it mandatory
|
|
41
|
+
if (!Array.isArray(block.roots)) {
|
|
42
|
+
throw new Error('Invalid CAR header format')
|
|
43
|
+
}
|
|
44
|
+
return block
|
|
45
|
+
}
|
|
46
|
+
// version 2
|
|
47
|
+
if (block.roots !== undefined) {
|
|
48
|
+
throw new Error('Invalid CAR header format')
|
|
49
|
+
}
|
|
50
|
+
const v2Header = decodeV2Header(reader.exactly(V2_HEADER_LENGTH, true))
|
|
51
|
+
reader.seek(v2Header.dataOffset - reader.pos)
|
|
52
|
+
const v1Header = readHeader(reader, 1)
|
|
53
|
+
return Object.assign(v1Header, v2Header)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Reads CID sync
|
|
58
|
+
*
|
|
59
|
+
* @param {BytesBufferReader} reader
|
|
60
|
+
* @returns {CID}
|
|
61
|
+
*/
|
|
62
|
+
function readCid (reader) {
|
|
63
|
+
const first = reader.exactly(2, false)
|
|
64
|
+
if (first[0] === CIDV0_BYTES.SHA2_256 && first[1] === CIDV0_BYTES.LENGTH) {
|
|
65
|
+
// cidv0 32-byte sha2-256
|
|
66
|
+
const bytes = reader.exactly(34, true)
|
|
67
|
+
const multihash = Digest.decode(bytes)
|
|
68
|
+
return CID.create(0, CIDV0_BYTES.DAG_PB, multihash)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const version = decodeVarint(reader.upTo(8), reader)
|
|
72
|
+
if (version !== 1) {
|
|
73
|
+
throw new Error(`Unexpected CID version (${version})`)
|
|
74
|
+
}
|
|
75
|
+
const codec = decodeVarint(reader.upTo(8), reader)
|
|
76
|
+
const bytes = reader.exactly(getMultihashLength(reader.upTo(8)), true)
|
|
77
|
+
const multihash = Digest.decode(bytes)
|
|
78
|
+
return CID.create(version, codec, multihash)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Reads the leading data of an individual block from CAR data from a
|
|
83
|
+
* `BytesBufferReader`. Returns a `BlockHeader` object which contains
|
|
84
|
+
* `{ cid, length, blockLength }` which can be used to either index the block
|
|
85
|
+
* or read the block binary data.
|
|
86
|
+
*
|
|
87
|
+
* @name async decoder.readBlockHead(reader)
|
|
88
|
+
* @param {BytesBufferReader} reader
|
|
89
|
+
* @returns {BlockHeader}
|
|
90
|
+
*/
|
|
91
|
+
export function readBlockHead (reader) {
|
|
92
|
+
// length includes a CID + Binary, where CID has a variable length
|
|
93
|
+
// we have to deal with
|
|
94
|
+
const start = reader.pos
|
|
95
|
+
let length = decodeVarint(reader.upTo(8), reader)
|
|
96
|
+
if (length === 0) {
|
|
97
|
+
throw new Error('Invalid CAR section (zero length)')
|
|
98
|
+
}
|
|
99
|
+
length += (reader.pos - start)
|
|
100
|
+
const cid = readCid(reader)
|
|
101
|
+
const blockLength = length - Number(reader.pos - start) // subtract CID length
|
|
102
|
+
|
|
103
|
+
return { cid, length, blockLength }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Returns Car header and blocks from a Uint8Array
|
|
108
|
+
*
|
|
109
|
+
* @param {Uint8Array} bytes
|
|
110
|
+
* @returns {{ header : CarHeader | CarV2Header , blocks: Block[]}}
|
|
111
|
+
*/
|
|
112
|
+
export function fromBytes (bytes) {
|
|
113
|
+
let reader = bytesReader(bytes)
|
|
114
|
+
const header = readHeader(reader)
|
|
115
|
+
if (header.version === 2) {
|
|
116
|
+
const v1length = reader.pos - header.dataOffset
|
|
117
|
+
reader = limitReader(reader, header.dataSize - v1length)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const blocks = []
|
|
121
|
+
while (reader.upTo(8).length > 0) {
|
|
122
|
+
const { cid, blockLength } = readBlockHead(reader)
|
|
123
|
+
|
|
124
|
+
blocks.push({ cid, bytes: reader.exactly(blockLength, true) })
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
header, blocks
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Creates a `BytesBufferReader` from a `Uint8Array`.
|
|
134
|
+
*
|
|
135
|
+
* @name decoder.bytesReader(bytes)
|
|
136
|
+
* @param {Uint8Array} bytes
|
|
137
|
+
* @returns {BytesBufferReader}
|
|
138
|
+
*/
|
|
139
|
+
export function bytesReader (bytes) {
|
|
140
|
+
let pos = 0
|
|
141
|
+
|
|
142
|
+
/** @type {BytesBufferReader} */
|
|
143
|
+
return {
|
|
144
|
+
upTo (length) {
|
|
145
|
+
return bytes.subarray(pos, pos + Math.min(length, bytes.length - pos))
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
exactly (length, seek = false) {
|
|
149
|
+
if (length > bytes.length - pos) {
|
|
150
|
+
throw new Error('Unexpected end of data')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const out = bytes.subarray(pos, pos + length)
|
|
154
|
+
if (seek) {
|
|
155
|
+
pos += length
|
|
156
|
+
}
|
|
157
|
+
return out
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
seek (length) {
|
|
161
|
+
pos += length
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
get pos () {
|
|
165
|
+
return pos
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Wraps a `BytesBufferReader` in a limiting `BytesBufferReader` which limits maximum read
|
|
172
|
+
* to `byteLimit` bytes. It _does not_ update `pos` of the original
|
|
173
|
+
* `BytesBufferReader`.
|
|
174
|
+
*
|
|
175
|
+
* @name decoder.limitReader(reader, byteLimit)
|
|
176
|
+
* @param {BytesBufferReader} reader
|
|
177
|
+
* @param {number} byteLimit
|
|
178
|
+
* @returns {BytesBufferReader}
|
|
179
|
+
*/
|
|
180
|
+
export function limitReader (reader, byteLimit) {
|
|
181
|
+
let bytesRead = 0
|
|
182
|
+
|
|
183
|
+
/** @type {BytesBufferReader} */
|
|
184
|
+
return {
|
|
185
|
+
upTo (length) {
|
|
186
|
+
let bytes = reader.upTo(length)
|
|
187
|
+
if (bytes.length + bytesRead > byteLimit) {
|
|
188
|
+
bytes = bytes.subarray(0, byteLimit - bytesRead)
|
|
189
|
+
}
|
|
190
|
+
return bytes
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
exactly (length, seek = false) {
|
|
194
|
+
const bytes = reader.exactly(length, seek)
|
|
195
|
+
if (bytes.length + bytesRead > byteLimit) {
|
|
196
|
+
throw new Error('Unexpected end of data')
|
|
197
|
+
}
|
|
198
|
+
if (seek) {
|
|
199
|
+
bytesRead += length
|
|
200
|
+
}
|
|
201
|
+
return bytes
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
seek (length) {
|
|
205
|
+
bytesRead += length
|
|
206
|
+
reader.seek(length)
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
get pos () {
|
|
210
|
+
return reader.pos
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as BufferDecoder from './buffer-decoder.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('multiformats').CID} CID
|
|
5
|
+
* @typedef {import('./api').Block} Block
|
|
6
|
+
* @typedef {import('./api').CarBufferReader} ICarBufferReader
|
|
7
|
+
* @typedef {import('./coding').CarHeader} CarHeader
|
|
8
|
+
* @typedef {import('./coding').CarV2Header} CarV2Header
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Provides blockstore-like access to a CAR.
|
|
13
|
+
*
|
|
14
|
+
* Implements the `RootsBufferReader` interface:
|
|
15
|
+
* {@link ICarBufferReader.getRoots `getRoots()`}. And the `BlockBufferReader` interface:
|
|
16
|
+
* {@link ICarBufferReader.get `get()`}, {@link ICarBufferReader.has `has()`},
|
|
17
|
+
* {@link ICarBufferReader.blocks `blocks()`} and
|
|
18
|
+
* {@link ICarBufferReader.cids `cids()`}.
|
|
19
|
+
*
|
|
20
|
+
* Load this class with either `import { CarBufferReader } from '@ipld/car/buffer-reader'`
|
|
21
|
+
* (`const { CarBufferReader } = require('@ipld/car/buffer-reader')`). Or
|
|
22
|
+
* `import { CarBufferReader } from '@ipld/car'` (`const { CarBufferReader } = require('@ipld/car')`).
|
|
23
|
+
* The former will likely result in smaller bundle sizes where this is
|
|
24
|
+
* important.
|
|
25
|
+
*
|
|
26
|
+
* @name CarBufferReader
|
|
27
|
+
* @class
|
|
28
|
+
* @implements {ICarBufferReader}
|
|
29
|
+
* @property {number} version The version number of the CAR referenced by this
|
|
30
|
+
* reader (should be `1` or `2`).
|
|
31
|
+
*/
|
|
32
|
+
export class CarBufferReader {
|
|
33
|
+
/**
|
|
34
|
+
* @constructs CarBufferReader
|
|
35
|
+
* @param {CarHeader|CarV2Header} header
|
|
36
|
+
* @param {Block[]} blocks
|
|
37
|
+
*/
|
|
38
|
+
constructor (header, blocks) {
|
|
39
|
+
this._header = header
|
|
40
|
+
this._blocks = blocks
|
|
41
|
+
this._cids = undefined
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @property version
|
|
46
|
+
* @memberof CarBufferReader
|
|
47
|
+
* @instance
|
|
48
|
+
*/
|
|
49
|
+
get version () {
|
|
50
|
+
return this._header.version
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get the list of roots defined by the CAR referenced by this reader. May be
|
|
55
|
+
* zero or more `CID`s.
|
|
56
|
+
*
|
|
57
|
+
* @function
|
|
58
|
+
* @memberof CarBufferReader
|
|
59
|
+
* @instance
|
|
60
|
+
* @returns {CID[]}
|
|
61
|
+
*/
|
|
62
|
+
getRoots () {
|
|
63
|
+
return this._header.roots
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check whether a given `CID` exists within the CAR referenced by this
|
|
68
|
+
* reader.
|
|
69
|
+
*
|
|
70
|
+
* @function
|
|
71
|
+
* @memberof CarBufferReader
|
|
72
|
+
* @instance
|
|
73
|
+
* @param {CID} key
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
has (key) {
|
|
77
|
+
return this._blocks.some(b => b.cid.equals(key))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR
|
|
82
|
+
* referenced by this reader matching the provided `CID`. In the case where
|
|
83
|
+
* the provided `CID` doesn't exist within the CAR, `undefined` will be
|
|
84
|
+
* returned.
|
|
85
|
+
*
|
|
86
|
+
* @function
|
|
87
|
+
* @memberof CarBufferReader
|
|
88
|
+
* @instance
|
|
89
|
+
* @param {CID} key
|
|
90
|
+
* @returns {Block | undefined}
|
|
91
|
+
*/
|
|
92
|
+
get (key) {
|
|
93
|
+
return this._blocks.find(b => b.cid.equals(key))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns a `Block[]` of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within
|
|
98
|
+
* the CAR referenced by this reader.
|
|
99
|
+
*
|
|
100
|
+
* @function
|
|
101
|
+
* @memberof CarBufferReader
|
|
102
|
+
* @instance
|
|
103
|
+
* @returns {Block[]}
|
|
104
|
+
*/
|
|
105
|
+
blocks () {
|
|
106
|
+
return this._blocks
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns a `CID[]` of the `CID`s contained within the CAR referenced by this reader.
|
|
111
|
+
*
|
|
112
|
+
* @function
|
|
113
|
+
* @memberof CarBufferReader
|
|
114
|
+
* @instance
|
|
115
|
+
* @returns {CID[]}
|
|
116
|
+
*/
|
|
117
|
+
cids () {
|
|
118
|
+
if (!this._cids) {
|
|
119
|
+
this._cids = this._blocks.map(b => b.cid)
|
|
120
|
+
}
|
|
121
|
+
return this._cids
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Instantiate a {@link CarBufferReader} from a `Uint8Array` blob. This performs a
|
|
126
|
+
* decode fully in memory and maintains the decoded state in memory for full
|
|
127
|
+
* access to the data via the `CarReader` API.
|
|
128
|
+
*
|
|
129
|
+
* @static
|
|
130
|
+
* @memberof CarBufferReader
|
|
131
|
+
* @param {Uint8Array} bytes
|
|
132
|
+
* @returns {CarBufferReader}
|
|
133
|
+
*/
|
|
134
|
+
static fromBytes (bytes) {
|
|
135
|
+
if (!(bytes instanceof Uint8Array)) {
|
|
136
|
+
throw new TypeError('fromBytes() requires a Uint8Array')
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const { header, blocks } = BufferDecoder.fromBytes(bytes)
|
|
140
|
+
return new CarBufferReader(header, blocks)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const __browser = true
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { CarBufferReader as BrowserCarBufferReader } from './buffer-reader-browser.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('./api').Block} Block
|
|
6
|
+
* @typedef {import('./api').BlockIndex} BlockIndex
|
|
7
|
+
* @typedef {import('./api').CarBufferReader} ICarBufferReader
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fsread = fs.readSync
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @class
|
|
14
|
+
* @implements {ICarBufferReader}
|
|
15
|
+
*/
|
|
16
|
+
export class CarBufferReader extends BrowserCarBufferReader {
|
|
17
|
+
/**
|
|
18
|
+
* Reads a block directly from a file descriptor for an open CAR file. This
|
|
19
|
+
* function is **only available in Node.js** and not a browser environment.
|
|
20
|
+
*
|
|
21
|
+
* This function can be used in connection with {@link CarIndexer} which emits
|
|
22
|
+
* the `BlockIndex` objects that are required by this function.
|
|
23
|
+
*
|
|
24
|
+
* The user is responsible for opening and closing the file used in this call.
|
|
25
|
+
*
|
|
26
|
+
* @static
|
|
27
|
+
* @memberof CarBufferReader
|
|
28
|
+
* @param {number} fd - A file descriptor from the
|
|
29
|
+
* Node.js `fs` module. An integer, from `fs.open()`.
|
|
30
|
+
* @param {BlockIndex} blockIndex - An index pointing to the location of the
|
|
31
|
+
* Block required. This `BlockIndex` should take the form:
|
|
32
|
+
* `{cid:CID, blockLength:number, blockOffset:number}`.
|
|
33
|
+
* @returns {Block} A `{ cid:CID, bytes:Uint8Array }` pair.
|
|
34
|
+
*/
|
|
35
|
+
static readRaw (fd, blockIndex) {
|
|
36
|
+
const { cid, blockLength, blockOffset } = blockIndex
|
|
37
|
+
const bytes = new Uint8Array(blockLength)
|
|
38
|
+
let read
|
|
39
|
+
if (typeof fd === 'number') {
|
|
40
|
+
read = fsread(fd, bytes, 0, blockLength, blockOffset)
|
|
41
|
+
} else {
|
|
42
|
+
throw new TypeError('Bad fd')
|
|
43
|
+
}
|
|
44
|
+
if (read !== blockLength) {
|
|
45
|
+
throw new Error(`Failed to read entire block (${read} instead of ${blockLength})`)
|
|
46
|
+
}
|
|
47
|
+
return { cid, bytes }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const __browser = false
|