@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,464 @@
|
|
|
1
|
+
import { is } from './is.js'
|
|
2
|
+
import { Token, Type } from './token.js'
|
|
3
|
+
import { Bl } from './bl.js'
|
|
4
|
+
import { encodeErrPrefix } from './common.js'
|
|
5
|
+
import { quickEncodeToken } from './jump.js'
|
|
6
|
+
import { asU8A } from './byte-utils.js'
|
|
7
|
+
|
|
8
|
+
import { encodeUint } from './0uint.js'
|
|
9
|
+
import { encodeNegint } from './1negint.js'
|
|
10
|
+
import { encodeBytes } from './2bytes.js'
|
|
11
|
+
import { encodeString } from './3string.js'
|
|
12
|
+
import { encodeArray } from './4array.js'
|
|
13
|
+
import { encodeMap } from './5map.js'
|
|
14
|
+
import { encodeTag } from './6tag.js'
|
|
15
|
+
import { encodeFloat } from './7float.js'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {import('../interface').EncodeOptions} EncodeOptions
|
|
19
|
+
* @typedef {import('../interface').OptionalTypeEncoder} OptionalTypeEncoder
|
|
20
|
+
* @typedef {import('../interface').Reference} Reference
|
|
21
|
+
* @typedef {import('../interface').StrictTypeEncoder} StrictTypeEncoder
|
|
22
|
+
* @typedef {import('../interface').TokenTypeEncoder} TokenTypeEncoder
|
|
23
|
+
* @typedef {import('../interface').TokenOrNestedTokens} TokenOrNestedTokens
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** @type {EncodeOptions} */
|
|
27
|
+
const defaultEncodeOptions = {
|
|
28
|
+
float64: false,
|
|
29
|
+
mapSorter,
|
|
30
|
+
quickEncodeToken
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @returns {TokenTypeEncoder[]} */
|
|
34
|
+
export function makeCborEncoders () {
|
|
35
|
+
const encoders = []
|
|
36
|
+
encoders[Type.uint.major] = encodeUint
|
|
37
|
+
encoders[Type.negint.major] = encodeNegint
|
|
38
|
+
encoders[Type.bytes.major] = encodeBytes
|
|
39
|
+
encoders[Type.string.major] = encodeString
|
|
40
|
+
encoders[Type.array.major] = encodeArray
|
|
41
|
+
encoders[Type.map.major] = encodeMap
|
|
42
|
+
encoders[Type.tag.major] = encodeTag
|
|
43
|
+
encoders[Type.float.major] = encodeFloat
|
|
44
|
+
return encoders
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const cborEncoders = makeCborEncoders()
|
|
48
|
+
|
|
49
|
+
const buf = new Bl()
|
|
50
|
+
|
|
51
|
+
/** @implements {Reference} */
|
|
52
|
+
class Ref {
|
|
53
|
+
/**
|
|
54
|
+
* @param {object|any[]} obj
|
|
55
|
+
* @param {Reference|undefined} parent
|
|
56
|
+
*/
|
|
57
|
+
constructor (obj, parent) {
|
|
58
|
+
this.obj = obj
|
|
59
|
+
this.parent = parent
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {object|any[]} obj
|
|
64
|
+
* @returns {boolean}
|
|
65
|
+
*/
|
|
66
|
+
includes (obj) {
|
|
67
|
+
/** @type {Reference|undefined} */
|
|
68
|
+
let p = this
|
|
69
|
+
do {
|
|
70
|
+
if (p.obj === obj) {
|
|
71
|
+
return true
|
|
72
|
+
}
|
|
73
|
+
} while (p = p.parent) // eslint-disable-line
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {Reference|undefined} stack
|
|
79
|
+
* @param {object|any[]} obj
|
|
80
|
+
* @returns {Reference}
|
|
81
|
+
*/
|
|
82
|
+
static createCheck (stack, obj) {
|
|
83
|
+
if (stack && stack.includes(obj)) {
|
|
84
|
+
throw new Error(`${encodeErrPrefix} object contains circular references`)
|
|
85
|
+
}
|
|
86
|
+
return new Ref(obj, stack)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const simpleTokens = {
|
|
91
|
+
null: new Token(Type.null, null),
|
|
92
|
+
undefined: new Token(Type.undefined, undefined),
|
|
93
|
+
true: new Token(Type.true, true),
|
|
94
|
+
false: new Token(Type.false, false),
|
|
95
|
+
emptyArray: new Token(Type.array, 0),
|
|
96
|
+
emptyMap: new Token(Type.map, 0)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @type {{[typeName: string]: StrictTypeEncoder}} */
|
|
100
|
+
const typeEncoders = {
|
|
101
|
+
/**
|
|
102
|
+
* @param {any} obj
|
|
103
|
+
* @param {string} _typ
|
|
104
|
+
* @param {EncodeOptions} _options
|
|
105
|
+
* @param {Reference} [_refStack]
|
|
106
|
+
* @returns {TokenOrNestedTokens}
|
|
107
|
+
*/
|
|
108
|
+
number (obj, _typ, _options, _refStack) {
|
|
109
|
+
if (!Number.isInteger(obj) || !Number.isSafeInteger(obj)) {
|
|
110
|
+
return new Token(Type.float, obj)
|
|
111
|
+
} else if (obj >= 0) {
|
|
112
|
+
return new Token(Type.uint, obj)
|
|
113
|
+
} else {
|
|
114
|
+
return new Token(Type.negint, obj)
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param {any} obj
|
|
120
|
+
* @param {string} _typ
|
|
121
|
+
* @param {EncodeOptions} _options
|
|
122
|
+
* @param {Reference} [_refStack]
|
|
123
|
+
* @returns {TokenOrNestedTokens}
|
|
124
|
+
*/
|
|
125
|
+
bigint (obj, _typ, _options, _refStack) {
|
|
126
|
+
if (obj >= BigInt(0)) {
|
|
127
|
+
return new Token(Type.uint, obj)
|
|
128
|
+
} else {
|
|
129
|
+
return new Token(Type.negint, obj)
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {any} obj
|
|
135
|
+
* @param {string} _typ
|
|
136
|
+
* @param {EncodeOptions} _options
|
|
137
|
+
* @param {Reference} [_refStack]
|
|
138
|
+
* @returns {TokenOrNestedTokens}
|
|
139
|
+
*/
|
|
140
|
+
Uint8Array (obj, _typ, _options, _refStack) {
|
|
141
|
+
return new Token(Type.bytes, obj)
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {any} obj
|
|
146
|
+
* @param {string} _typ
|
|
147
|
+
* @param {EncodeOptions} _options
|
|
148
|
+
* @param {Reference} [_refStack]
|
|
149
|
+
* @returns {TokenOrNestedTokens}
|
|
150
|
+
*/
|
|
151
|
+
string (obj, _typ, _options, _refStack) {
|
|
152
|
+
return new Token(Type.string, obj)
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @param {any} obj
|
|
157
|
+
* @param {string} _typ
|
|
158
|
+
* @param {EncodeOptions} _options
|
|
159
|
+
* @param {Reference} [_refStack]
|
|
160
|
+
* @returns {TokenOrNestedTokens}
|
|
161
|
+
*/
|
|
162
|
+
boolean (obj, _typ, _options, _refStack) {
|
|
163
|
+
return obj ? simpleTokens.true : simpleTokens.false
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param {any} _obj
|
|
168
|
+
* @param {string} _typ
|
|
169
|
+
* @param {EncodeOptions} _options
|
|
170
|
+
* @param {Reference} [_refStack]
|
|
171
|
+
* @returns {TokenOrNestedTokens}
|
|
172
|
+
*/
|
|
173
|
+
null (_obj, _typ, _options, _refStack) {
|
|
174
|
+
return simpleTokens.null
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {any} _obj
|
|
179
|
+
* @param {string} _typ
|
|
180
|
+
* @param {EncodeOptions} _options
|
|
181
|
+
* @param {Reference} [_refStack]
|
|
182
|
+
* @returns {TokenOrNestedTokens}
|
|
183
|
+
*/
|
|
184
|
+
undefined (_obj, _typ, _options, _refStack) {
|
|
185
|
+
return simpleTokens.undefined
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @param {any} obj
|
|
190
|
+
* @param {string} _typ
|
|
191
|
+
* @param {EncodeOptions} _options
|
|
192
|
+
* @param {Reference} [_refStack]
|
|
193
|
+
* @returns {TokenOrNestedTokens}
|
|
194
|
+
*/
|
|
195
|
+
ArrayBuffer (obj, _typ, _options, _refStack) {
|
|
196
|
+
return new Token(Type.bytes, new Uint8Array(obj))
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param {any} obj
|
|
201
|
+
* @param {string} _typ
|
|
202
|
+
* @param {EncodeOptions} _options
|
|
203
|
+
* @param {Reference} [_refStack]
|
|
204
|
+
* @returns {TokenOrNestedTokens}
|
|
205
|
+
*/
|
|
206
|
+
DataView (obj, _typ, _options, _refStack) {
|
|
207
|
+
return new Token(Type.bytes, new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength))
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @param {any} obj
|
|
212
|
+
* @param {string} _typ
|
|
213
|
+
* @param {EncodeOptions} options
|
|
214
|
+
* @param {Reference} [refStack]
|
|
215
|
+
* @returns {TokenOrNestedTokens}
|
|
216
|
+
*/
|
|
217
|
+
Array (obj, _typ, options, refStack) {
|
|
218
|
+
if (!obj.length) {
|
|
219
|
+
if (options.addBreakTokens === true) {
|
|
220
|
+
return [simpleTokens.emptyArray, new Token(Type.break)]
|
|
221
|
+
}
|
|
222
|
+
return simpleTokens.emptyArray
|
|
223
|
+
}
|
|
224
|
+
refStack = Ref.createCheck(refStack, obj)
|
|
225
|
+
const entries = []
|
|
226
|
+
let i = 0
|
|
227
|
+
for (const e of obj) {
|
|
228
|
+
entries[i++] = objectToTokens(e, options, refStack)
|
|
229
|
+
}
|
|
230
|
+
if (options.addBreakTokens) {
|
|
231
|
+
return [new Token(Type.array, obj.length), entries, new Token(Type.break)]
|
|
232
|
+
}
|
|
233
|
+
return [new Token(Type.array, obj.length), entries]
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @param {any} obj
|
|
238
|
+
* @param {string} typ
|
|
239
|
+
* @param {EncodeOptions} options
|
|
240
|
+
* @param {Reference} [refStack]
|
|
241
|
+
* @returns {TokenOrNestedTokens}
|
|
242
|
+
*/
|
|
243
|
+
Object (obj, typ, options, refStack) {
|
|
244
|
+
// could be an Object or a Map
|
|
245
|
+
const isMap = typ !== 'Object'
|
|
246
|
+
// it's slightly quicker to use Object.keys() than Object.entries()
|
|
247
|
+
const keys = isMap ? obj.keys() : Object.keys(obj)
|
|
248
|
+
const length = isMap ? obj.size : keys.length
|
|
249
|
+
if (!length) {
|
|
250
|
+
if (options.addBreakTokens === true) {
|
|
251
|
+
return [simpleTokens.emptyMap, new Token(Type.break)]
|
|
252
|
+
}
|
|
253
|
+
return simpleTokens.emptyMap
|
|
254
|
+
}
|
|
255
|
+
refStack = Ref.createCheck(refStack, obj)
|
|
256
|
+
/** @type {TokenOrNestedTokens[]} */
|
|
257
|
+
const entries = []
|
|
258
|
+
let i = 0
|
|
259
|
+
for (const key of keys) {
|
|
260
|
+
entries[i++] = [
|
|
261
|
+
objectToTokens(key, options, refStack),
|
|
262
|
+
objectToTokens(isMap ? obj.get(key) : obj[key], options, refStack)
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
sortMapEntries(entries, options)
|
|
266
|
+
if (options.addBreakTokens) {
|
|
267
|
+
return [new Token(Type.map, length), entries, new Token(Type.break)]
|
|
268
|
+
}
|
|
269
|
+
return [new Token(Type.map, length), entries]
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
typeEncoders.Map = typeEncoders.Object
|
|
274
|
+
typeEncoders.Buffer = typeEncoders.Uint8Array
|
|
275
|
+
for (const typ of 'Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64'.split(' ')) {
|
|
276
|
+
typeEncoders[`${typ}Array`] = typeEncoders.DataView
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @param {any} obj
|
|
281
|
+
* @param {EncodeOptions} [options]
|
|
282
|
+
* @param {Reference} [refStack]
|
|
283
|
+
* @returns {TokenOrNestedTokens}
|
|
284
|
+
*/
|
|
285
|
+
function objectToTokens (obj, options = {}, refStack) {
|
|
286
|
+
const typ = is(obj)
|
|
287
|
+
const customTypeEncoder = (options && options.typeEncoders && /** @type {OptionalTypeEncoder} */ options.typeEncoders[typ]) || typeEncoders[typ]
|
|
288
|
+
if (typeof customTypeEncoder === 'function') {
|
|
289
|
+
const tokens = customTypeEncoder(obj, typ, options, refStack)
|
|
290
|
+
if (tokens != null) {
|
|
291
|
+
return tokens
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const typeEncoder = typeEncoders[typ]
|
|
295
|
+
if (!typeEncoder) {
|
|
296
|
+
throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`)
|
|
297
|
+
}
|
|
298
|
+
return typeEncoder(obj, typ, options, refStack)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
CBOR key sorting is a mess.
|
|
303
|
+
|
|
304
|
+
The canonicalisation recommendation from https://tools.ietf.org/html/rfc7049#section-3.9
|
|
305
|
+
includes the wording:
|
|
306
|
+
|
|
307
|
+
> The keys in every map must be sorted lowest value to highest.
|
|
308
|
+
> Sorting is performed on the bytes of the representation of the key
|
|
309
|
+
> data items without paying attention to the 3/5 bit splitting for
|
|
310
|
+
> major types.
|
|
311
|
+
> ...
|
|
312
|
+
> * If two keys have different lengths, the shorter one sorts
|
|
313
|
+
earlier;
|
|
314
|
+
> * If two keys have the same length, the one with the lower value
|
|
315
|
+
in (byte-wise) lexical order sorts earlier.
|
|
316
|
+
|
|
317
|
+
1. It is not clear what "bytes of the representation of the key" means: is it
|
|
318
|
+
the CBOR representation, or the binary representation of the object itself?
|
|
319
|
+
Consider the int and uint difference here.
|
|
320
|
+
2. It is not clear what "without paying attention to" means: do we include it
|
|
321
|
+
and compare on that? Or do we omit the special prefix byte, (mostly) treating
|
|
322
|
+
the key in its plain binary representation form.
|
|
323
|
+
|
|
324
|
+
The FIDO 2.0: Client To Authenticator Protocol spec takes the original CBOR
|
|
325
|
+
wording and clarifies it according to their understanding.
|
|
326
|
+
https://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#message-encoding
|
|
327
|
+
|
|
328
|
+
> The keys in every map must be sorted lowest value to highest. Sorting is
|
|
329
|
+
> performed on the bytes of the representation of the key data items without
|
|
330
|
+
> paying attention to the 3/5 bit splitting for major types. The sorting rules
|
|
331
|
+
> are:
|
|
332
|
+
> * If the major types are different, the one with the lower value in numerical
|
|
333
|
+
> order sorts earlier.
|
|
334
|
+
> * If two keys have different lengths, the shorter one sorts earlier;
|
|
335
|
+
> * If two keys have the same length, the one with the lower value in
|
|
336
|
+
> (byte-wise) lexical order sorts earlier.
|
|
337
|
+
|
|
338
|
+
Some other implementations, such as borc, do a full encode then do a
|
|
339
|
+
length-first, byte-wise-second comparison:
|
|
340
|
+
https://github.com/dignifiedquire/borc/blob/b6bae8b0bcde7c3976b0f0f0957208095c392a36/src/encoder.js#L358
|
|
341
|
+
https://github.com/dignifiedquire/borc/blob/b6bae8b0bcde7c3976b0f0f0957208095c392a36/src/utils.js#L143-L151
|
|
342
|
+
|
|
343
|
+
This has the benefit of being able to easily handle arbitrary keys, including
|
|
344
|
+
complex types (maps and arrays).
|
|
345
|
+
|
|
346
|
+
We'll opt for the FIDO approach, since it affords some efficies since we don't
|
|
347
|
+
need a full encode of each key to determine order and can defer to the types
|
|
348
|
+
to determine how to most efficiently order their values (i.e. int and uint
|
|
349
|
+
ordering can be done on the numbers, no need for byte-wise, for example).
|
|
350
|
+
|
|
351
|
+
Recommendation: stick to single key types or you'll get into trouble, and prefer
|
|
352
|
+
string keys because it's much simpler that way.
|
|
353
|
+
*/
|
|
354
|
+
|
|
355
|
+
/*
|
|
356
|
+
(UPDATE, Dec 2020)
|
|
357
|
+
https://tools.ietf.org/html/rfc8949 is the updated CBOR spec and clarifies some
|
|
358
|
+
of the questions above with a new recommendation for sorting order being much
|
|
359
|
+
closer to what would be expected in other environments (i.e. no length-first
|
|
360
|
+
weirdness).
|
|
361
|
+
This new sorting order is not yet implemented here but could be added as an
|
|
362
|
+
option. "Determinism" (canonicity) is system dependent and it's difficult to
|
|
363
|
+
change existing systems that are built with existing expectations. So if a new
|
|
364
|
+
ordering is introduced here, the old needs to be kept as well with the user
|
|
365
|
+
having the option.
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @param {TokenOrNestedTokens[]} entries
|
|
370
|
+
* @param {EncodeOptions} options
|
|
371
|
+
*/
|
|
372
|
+
function sortMapEntries (entries, options) {
|
|
373
|
+
if (options.mapSorter) {
|
|
374
|
+
entries.sort(options.mapSorter)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @param {(Token|Token[])[]} e1
|
|
380
|
+
* @param {(Token|Token[])[]} e2
|
|
381
|
+
* @returns {number}
|
|
382
|
+
*/
|
|
383
|
+
function mapSorter (e1, e2) {
|
|
384
|
+
// the key position ([0]) could have a single token or an array
|
|
385
|
+
// almost always it'll be a single token but complex key might get involved
|
|
386
|
+
/* c8 ignore next 2 */
|
|
387
|
+
const keyToken1 = Array.isArray(e1[0]) ? e1[0][0] : e1[0]
|
|
388
|
+
const keyToken2 = Array.isArray(e2[0]) ? e2[0][0] : e2[0]
|
|
389
|
+
|
|
390
|
+
// different key types
|
|
391
|
+
if (keyToken1.type !== keyToken2.type) {
|
|
392
|
+
return keyToken1.type.compare(keyToken2.type)
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const major = keyToken1.type.major
|
|
396
|
+
// TODO: handle case where cmp === 0 but there are more keyToken e. complex type)
|
|
397
|
+
const tcmp = cborEncoders[major].compareTokens(keyToken1, keyToken2)
|
|
398
|
+
/* c8 ignore next 5 */
|
|
399
|
+
if (tcmp === 0) {
|
|
400
|
+
// duplicate key or complex type where the first token matched,
|
|
401
|
+
// i.e. a map or array and we're only comparing the opening token
|
|
402
|
+
console.warn('WARNING: complex key types used, CBOR key sorting guarantees are gone')
|
|
403
|
+
}
|
|
404
|
+
return tcmp
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @param {Bl} buf
|
|
409
|
+
* @param {TokenOrNestedTokens} tokens
|
|
410
|
+
* @param {TokenTypeEncoder[]} encoders
|
|
411
|
+
* @param {EncodeOptions} options
|
|
412
|
+
*/
|
|
413
|
+
function tokensToEncoded (buf, tokens, encoders, options) {
|
|
414
|
+
if (Array.isArray(tokens)) {
|
|
415
|
+
for (const token of tokens) {
|
|
416
|
+
tokensToEncoded(buf, token, encoders, options)
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
419
|
+
encoders[tokens.type.major](buf, tokens, options)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @param {any} data
|
|
425
|
+
* @param {TokenTypeEncoder[]} encoders
|
|
426
|
+
* @param {EncodeOptions} options
|
|
427
|
+
* @returns {Uint8Array}
|
|
428
|
+
*/
|
|
429
|
+
function encodeCustom (data, encoders, options) {
|
|
430
|
+
const tokens = objectToTokens(data, options)
|
|
431
|
+
if (!Array.isArray(tokens) && options.quickEncodeToken) {
|
|
432
|
+
const quickBytes = options.quickEncodeToken(tokens)
|
|
433
|
+
if (quickBytes) {
|
|
434
|
+
return quickBytes
|
|
435
|
+
}
|
|
436
|
+
const encoder = encoders[tokens.type.major]
|
|
437
|
+
if (encoder.encodedSize) {
|
|
438
|
+
const size = encoder.encodedSize(tokens, options)
|
|
439
|
+
const buf = new Bl(size)
|
|
440
|
+
encoder(buf, tokens, options)
|
|
441
|
+
/* c8 ignore next 4 */
|
|
442
|
+
// this would be a problem with encodedSize() functions
|
|
443
|
+
if (buf.chunks.length !== 1) {
|
|
444
|
+
throw new Error(`Unexpected error: pre-calculated length for ${tokens} was wrong`)
|
|
445
|
+
}
|
|
446
|
+
return asU8A(buf.chunks[0])
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
buf.reset()
|
|
450
|
+
tokensToEncoded(buf, tokens, encoders, options)
|
|
451
|
+
return buf.toBytes(true)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* @param {any} data
|
|
456
|
+
* @param {EncodeOptions} [options]
|
|
457
|
+
* @returns {Uint8Array}
|
|
458
|
+
*/
|
|
459
|
+
function encode (data, options) {
|
|
460
|
+
options = Object.assign({}, defaultEncodeOptions, options)
|
|
461
|
+
return encodeCustom(data, cborEncoders, options)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export { objectToTokens, encode, encodeCustom, Ref }
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// This is an unfortunate replacement for @sindresorhus/is that we need to
|
|
2
|
+
// re-implement for performance purposes. In particular the is.observable()
|
|
3
|
+
// check is expensive, and unnecessary for our purposes. The values returned
|
|
4
|
+
// are compatible with @sindresorhus/is, however.
|
|
5
|
+
|
|
6
|
+
const typeofs = [
|
|
7
|
+
'string',
|
|
8
|
+
'number',
|
|
9
|
+
'bigint',
|
|
10
|
+
'symbol'
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
const objectTypeNames = [
|
|
14
|
+
'Function',
|
|
15
|
+
'Generator',
|
|
16
|
+
'AsyncGenerator',
|
|
17
|
+
'GeneratorFunction',
|
|
18
|
+
'AsyncGeneratorFunction',
|
|
19
|
+
'AsyncFunction',
|
|
20
|
+
'Observable',
|
|
21
|
+
'Array',
|
|
22
|
+
'Buffer',
|
|
23
|
+
'Object',
|
|
24
|
+
'RegExp',
|
|
25
|
+
'Date',
|
|
26
|
+
'Error',
|
|
27
|
+
'Map',
|
|
28
|
+
'Set',
|
|
29
|
+
'WeakMap',
|
|
30
|
+
'WeakSet',
|
|
31
|
+
'ArrayBuffer',
|
|
32
|
+
'SharedArrayBuffer',
|
|
33
|
+
'DataView',
|
|
34
|
+
'Promise',
|
|
35
|
+
'URL',
|
|
36
|
+
'HTMLElement',
|
|
37
|
+
'Int8Array',
|
|
38
|
+
'Uint8Array',
|
|
39
|
+
'Uint8ClampedArray',
|
|
40
|
+
'Int16Array',
|
|
41
|
+
'Uint16Array',
|
|
42
|
+
'Int32Array',
|
|
43
|
+
'Uint32Array',
|
|
44
|
+
'Float32Array',
|
|
45
|
+
'Float64Array',
|
|
46
|
+
'BigInt64Array',
|
|
47
|
+
'BigUint64Array'
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {any} value
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export function is (value) {
|
|
55
|
+
if (value === null) {
|
|
56
|
+
return 'null'
|
|
57
|
+
}
|
|
58
|
+
if (value === undefined) {
|
|
59
|
+
return 'undefined'
|
|
60
|
+
}
|
|
61
|
+
if (value === true || value === false) {
|
|
62
|
+
return 'boolean'
|
|
63
|
+
}
|
|
64
|
+
const typeOf = typeof value
|
|
65
|
+
if (typeofs.includes(typeOf)) {
|
|
66
|
+
return typeOf
|
|
67
|
+
}
|
|
68
|
+
/* c8 ignore next 4 */
|
|
69
|
+
// not going to bother testing this, it's not going to be valid anyway
|
|
70
|
+
if (typeOf === 'function') {
|
|
71
|
+
return 'Function'
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(value)) {
|
|
74
|
+
return 'Array'
|
|
75
|
+
}
|
|
76
|
+
if (isBuffer(value)) {
|
|
77
|
+
return 'Buffer'
|
|
78
|
+
}
|
|
79
|
+
const objectType = getObjectType(value)
|
|
80
|
+
if (objectType) {
|
|
81
|
+
return objectType
|
|
82
|
+
}
|
|
83
|
+
/* c8 ignore next */
|
|
84
|
+
return 'Object'
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {any} value
|
|
89
|
+
* @returns {boolean}
|
|
90
|
+
*/
|
|
91
|
+
function isBuffer (value) {
|
|
92
|
+
return value && value.constructor && value.constructor.isBuffer && value.constructor.isBuffer.call(null, value)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param {any} value
|
|
97
|
+
* @returns {string|undefined}
|
|
98
|
+
*/
|
|
99
|
+
function getObjectType (value) {
|
|
100
|
+
const objectTypeName = Object.prototype.toString.call(value).slice(8, -1)
|
|
101
|
+
if (objectTypeNames.includes(objectTypeName)) {
|
|
102
|
+
return objectTypeName
|
|
103
|
+
}
|
|
104
|
+
/* c8 ignore next */
|
|
105
|
+
return undefined
|
|
106
|
+
}
|