@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,65 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import * as chai from 'chai'
|
|
4
|
+
|
|
5
|
+
import { decode } from '../cborg.js'
|
|
6
|
+
import { fromHex } from '../lib/byte-utils.js'
|
|
7
|
+
|
|
8
|
+
const { assert } = chai
|
|
9
|
+
|
|
10
|
+
describe('decode errors', () => {
|
|
11
|
+
it('not Uint8Array', () => {
|
|
12
|
+
for (const arg of [true, false, null, undefined, 'string', { obj: 'ect' }, {}, ['array'], [], [1, 2, 3], 0, 100, 1.1, -1, Symbol.for('nope')]) {
|
|
13
|
+
assert.throws(() => decode(arg), /CBOR decode error.*must be a Uint8Array/)
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('no data', () => {
|
|
18
|
+
assert.throws(() => decode(new Uint8Array('')), /CBOR decode error.*content/)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('break only', () => {
|
|
22
|
+
assert.throws(() => decode(new Uint8Array([255])), /CBOR decode error.*break/)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('not enough map entries (value)', () => {
|
|
26
|
+
// last value missing
|
|
27
|
+
assert.throws(() => decode(fromHex('a2616f016174')), /map.*not enough entries.*value/)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('not enough map entries (key)', () => {
|
|
31
|
+
// last key & value missing
|
|
32
|
+
assert.throws(() => decode(fromHex('a2616f01')), /map.*not enough entries.*key/)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('break in lengthed map', () => {
|
|
36
|
+
// 0xff (break) in the middle
|
|
37
|
+
assert.throws(() => decode(fromHex('a2616f01ff740f')), /unexpected break to lengthed map/)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('not enough array entries', () => {
|
|
41
|
+
// last value missing
|
|
42
|
+
assert.throws(() => decode(fromHex('82616f')), /array.*not enough entries/)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('break in lengthed array', () => {
|
|
46
|
+
// last value missing
|
|
47
|
+
assert.throws(() => decode(fromHex('82ff')), /unexpected break to lengthed array/)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('no such decoder', () => {
|
|
51
|
+
// last value missing
|
|
52
|
+
assert.throws(() => decode(fromHex('82ff')), /unexpected break to lengthed array/)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('too many terminals', () => {
|
|
56
|
+
// two '1's
|
|
57
|
+
assert.throws(() => decode(fromHex('0101')), /too many terminals/)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('rejectDuplicateMapKeys enabled on duplicate keys', () => {
|
|
61
|
+
assert.deepStrictEqual(decode(fromHex('a3636261720363666f6f0163666f6f02')), { foo: 2, bar: 3 })
|
|
62
|
+
assert.throws(() => decode(fromHex('a3636261720363666f6f0163666f6f02'), { rejectDuplicateMapKeys: true }), /CBOR decode error: found repeat map key "foo"/)
|
|
63
|
+
assert.throws(() => decode(fromHex('a3636261720363666f6f0163666f6f02'), { useMaps: true, rejectDuplicateMapKeys: true }), /CBOR decode error: found repeat map key "foo"/)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import { garbage } from 'ipld-garbage'
|
|
4
|
+
import { decode, encode } from '../cborg.js'
|
|
5
|
+
import * as chai from 'chai'
|
|
6
|
+
|
|
7
|
+
const { assert } = chai
|
|
8
|
+
|
|
9
|
+
describe('Fuzz round-trip', () => {
|
|
10
|
+
it('random objects', function () {
|
|
11
|
+
this.timeout(5000)
|
|
12
|
+
for (let i = 0; i < 1000; i++) {
|
|
13
|
+
const obj = garbage(300, { weights: { CID: 0 } })
|
|
14
|
+
const byts = encode(obj)
|
|
15
|
+
const decoded = decode(byts)
|
|
16
|
+
assert.deepEqual(decoded, obj)
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('circular references error', () => {
|
|
21
|
+
let obj = {}
|
|
22
|
+
obj.obj = obj
|
|
23
|
+
assert.throws(() => encode(obj), /circular references/)
|
|
24
|
+
|
|
25
|
+
obj = { blip: [1, 2, { blop: {} }] }
|
|
26
|
+
obj.blip[2].blop.boop = obj
|
|
27
|
+
assert.throws(() => encode(obj), /circular references/)
|
|
28
|
+
|
|
29
|
+
obj = { blip: [1, 2, { blop: {} }] }
|
|
30
|
+
obj.blip[2].blop.boop = obj.blip
|
|
31
|
+
assert.throws(() => encode(obj), /circular references/)
|
|
32
|
+
|
|
33
|
+
// not circular but a naive check might decide it is
|
|
34
|
+
obj = { blip: {}, bloop: {} }
|
|
35
|
+
obj.bloop = obj.blip
|
|
36
|
+
assert.doesNotThrow(() => encode(obj))
|
|
37
|
+
|
|
38
|
+
const arr = []
|
|
39
|
+
arr[0] = arr
|
|
40
|
+
assert.throws(() => encode(arr), /circular references/)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/* eslint-env mocha,es2020 */
|
|
2
|
+
|
|
3
|
+
import { assert } from 'chai'
|
|
4
|
+
import { decode, decodeFirst, encode } from "@fireproof/vendor/cborg/json"
|
|
5
|
+
|
|
6
|
+
const toBytes = (str) => new TextEncoder().encode(str)
|
|
7
|
+
|
|
8
|
+
function verifyRoundTrip (obj, sorting) {
|
|
9
|
+
const encoded = new TextDecoder().decode(encode(obj, sorting === false ? { mapSorter: null } : undefined))
|
|
10
|
+
const json = JSON.stringify(obj)
|
|
11
|
+
assert.strictEqual(encoded, json)
|
|
12
|
+
const decoded = decode(toBytes(JSON.stringify(obj)))
|
|
13
|
+
assert.deepStrictEqual(decoded, obj)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function verifyEncodedForm (testCase) {
|
|
17
|
+
// round trip the original object
|
|
18
|
+
const obj = JSON.parse(testCase)
|
|
19
|
+
const encoded = encode(obj)
|
|
20
|
+
assert.strictEqual(new TextDecoder().decode(encoded), JSON.stringify(obj))
|
|
21
|
+
const decoded = decode(encoded)
|
|
22
|
+
assert.deepStrictEqual(decoded, obj)
|
|
23
|
+
// now look at the original form
|
|
24
|
+
const decoded2 = decode(toBytes(testCase))
|
|
25
|
+
assert.deepStrictEqual(decoded2, obj)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('json basics', () => {
|
|
29
|
+
it('can round-trip basic literals', () => {
|
|
30
|
+
const testCases = [
|
|
31
|
+
'null',
|
|
32
|
+
'true',
|
|
33
|
+
'false',
|
|
34
|
+
'0',
|
|
35
|
+
'9007199254740991',
|
|
36
|
+
'-9007199254740991',
|
|
37
|
+
JSON.stringify(Number.MAX_VALUE),
|
|
38
|
+
JSON.stringify(Number.MIN_VALUE)
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
for (const testCase of testCases) {
|
|
42
|
+
verifyEncodedForm(testCase)
|
|
43
|
+
}
|
|
44
|
+
assert.strictEqual(decode(toBytes('1E1')), 10)
|
|
45
|
+
assert.strictEqual(decode(toBytes('0.1e1')), 1)
|
|
46
|
+
assert.strictEqual(decode(toBytes('1e-1')), 0.1)
|
|
47
|
+
assert.strictEqual(decode(toBytes('1e+00')), 1)
|
|
48
|
+
assert.strictEqual(decode(toBytes('10.0')), 10)
|
|
49
|
+
assert.deepStrictEqual(decode(toBytes('[-10.0,1.0,0.0,100.0]')), [-10, 1, 0, 100])
|
|
50
|
+
verifyRoundTrip(true)
|
|
51
|
+
verifyRoundTrip(false)
|
|
52
|
+
verifyRoundTrip(null)
|
|
53
|
+
verifyRoundTrip(100)
|
|
54
|
+
verifyRoundTrip(-100)
|
|
55
|
+
verifyRoundTrip(1.11)
|
|
56
|
+
verifyRoundTrip(-100.11111)
|
|
57
|
+
verifyRoundTrip(1.11e10)
|
|
58
|
+
verifyRoundTrip(1.0011111e-18)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('handles large integers as BigInt', () => {
|
|
62
|
+
const verify = (inp, str) => {
|
|
63
|
+
if (str === undefined) {
|
|
64
|
+
str = String(inp)
|
|
65
|
+
}
|
|
66
|
+
assert.strictEqual(decode(toBytes(str), { allowBigInt: true }), inp)
|
|
67
|
+
assert.strictEqual(decode(toBytes(str)), parseFloat(str)) // no BigInt for you
|
|
68
|
+
}
|
|
69
|
+
verify(Number.MAX_SAFE_INTEGER)
|
|
70
|
+
verify(-Number.MAX_SAFE_INTEGER)
|
|
71
|
+
verify(BigInt('9007199254740992')) // Number.MAX_SAFE_INTEGER+1
|
|
72
|
+
verify(BigInt('9007199254740993'))
|
|
73
|
+
verify(BigInt('11959030306112471731'))
|
|
74
|
+
verify(BigInt('18446744073709551615')) // max uint64
|
|
75
|
+
verify(BigInt('9223372036854775807')) // max int64
|
|
76
|
+
verify(BigInt('-9007199254740992'))
|
|
77
|
+
verify(BigInt('-9007199254740993'))
|
|
78
|
+
verify(BigInt('-9223372036854776000')) // min int64
|
|
79
|
+
verify(BigInt('-11959030306112471732'))
|
|
80
|
+
verify(BigInt('-18446744073709551616')) // min -uint64
|
|
81
|
+
|
|
82
|
+
// these are "floats", distinct from "ints" which wouldn't have the `.` in them
|
|
83
|
+
verify(-9007199254740992, '-9007199254740992.0')
|
|
84
|
+
verify(-9223372036854776000, '-9223372036854776000.0')
|
|
85
|
+
verify(-18446744073709551616, '-18446744073709551616.0')
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('can round-trip string literals', () => {
|
|
89
|
+
const testCases = [
|
|
90
|
+
JSON.stringify(''),
|
|
91
|
+
JSON.stringify(' '),
|
|
92
|
+
JSON.stringify('"'),
|
|
93
|
+
JSON.stringify('\\'),
|
|
94
|
+
JSON.stringify('\b\f\n\r\t'),
|
|
95
|
+
JSON.stringify('\u0022'),
|
|
96
|
+
JSON.stringify('" %22 0x22 034 "'),
|
|
97
|
+
'"😀"'
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
for (const testCase of testCases) {
|
|
101
|
+
verifyEncodedForm(testCase)
|
|
102
|
+
}
|
|
103
|
+
assert.strictEqual(decode(toBytes('"/ & \\/"')), '/ & /')
|
|
104
|
+
verifyRoundTrip('this is a string')
|
|
105
|
+
verifyRoundTrip('this 𝄞 is a ☺☺ ♣ string ̐ ̀\n\r') // accents like ̀ and ̐ use two-byte utf8
|
|
106
|
+
verifyRoundTrip('')
|
|
107
|
+
verifyRoundTrip('foo\\bar\nbaz\tbop\rbing"bip\'bang')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('can round-trip array literals', () => {
|
|
111
|
+
const testCases = [
|
|
112
|
+
'[]',
|
|
113
|
+
'[null]',
|
|
114
|
+
'[true, false]',
|
|
115
|
+
'[ \n 0,1, 2\n , 3,\n4] \n ',
|
|
116
|
+
'[-10.0, 1.0, 0.0, 100.0]',
|
|
117
|
+
'[["2 deep"]]'
|
|
118
|
+
]
|
|
119
|
+
for (const testCase of testCases) {
|
|
120
|
+
verifyEncodedForm(testCase)
|
|
121
|
+
}
|
|
122
|
+
verifyRoundTrip([1, 2, 3, 'string', true, 4])
|
|
123
|
+
verifyRoundTrip([1, 2, 3, 'string', true, ['and', 'a', 'nested', 'array', true], 4])
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('can round-trip object literals', () => {
|
|
127
|
+
const testCases = [
|
|
128
|
+
'{}',
|
|
129
|
+
'\n {\n "\\b"\n :\n""\n }\n ',
|
|
130
|
+
'{"":""}',
|
|
131
|
+
'{"1":{"2":0,"3":"deep"}}'
|
|
132
|
+
]
|
|
133
|
+
for (const testCase of testCases) {
|
|
134
|
+
verifyEncodedForm(testCase)
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it('will sort map keys', () => {
|
|
139
|
+
const unsorted = { one: 1, two: 2, three: 3.1, str: 'string', bool: true, four: 4 }
|
|
140
|
+
verifyRoundTrip(unsorted, false)
|
|
141
|
+
assert.strictEqual(
|
|
142
|
+
new TextDecoder().decode(encode(unsorted)),
|
|
143
|
+
'{"bool":true,"four":4,"one":1,"str":"string","three":3.1,"two":2}')
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('can handle novel cases', () => {
|
|
147
|
+
assert.strictEqual(decode(toBytes('"this \\uD834\\uDD1E is a \\u263a\\u263a string"')), 'this 𝄞 is a ☺☺ string')
|
|
148
|
+
verifyRoundTrip({ one: 1, two: 2, three: 3.1, str: 'string', arr: ['and', 'a', 'nested', [], 'array', [true, 1], false], bool: true, obj: { nested: 'object', a: [], o: {} }, four: 4 }, false)
|
|
149
|
+
verifyRoundTrip([false, [{ '#nFzU': {}, '\\w>': -0.9441451951197325, "\t'": "'JB+2Wg\tw\"IrM*#e^L/d&4rrzUuwq(1mH6aVRredB&Bfs]S\"KqK(Tz1Q\"URBAfw", '\n@FrfM': 'M[D]q&' }, "J4>'Xdc+u2$%", 4227406737130333]], false)
|
|
150
|
+
verifyRoundTrip([0.12995619865708727, -4973404279772543, { drG2: [true], ';#K^Qf>V': null, '`2=': 'ecc<e/$+-.;U>Gr5RdZDJ\n5+:{=QHNN.tVVN~dX$FWFwu`6>"&=tW!*1*^☺)JFM1p|}&X.B|${*\\f@!w2☺+' }], false)
|
|
151
|
+
assert.strictEqual(`${decode(encode(9007199254740991))}`, '9007199254740991')
|
|
152
|
+
assert.strictEqual(`${decode(encode(9007199254740992))}`, '9007199254740992')
|
|
153
|
+
assert.strictEqual(`${decode(encode(900719925474099100n))}`, '900719925474099100')
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('should throw on bad types', () => {
|
|
157
|
+
assert.throws(() => encode(new Uint8Array([1, 2])), /CBOR encode error: unsupported type: Uint8Array/)
|
|
158
|
+
assert.throws(() => encode({ boop: new Uint8Array([1, 2]) }), /CBOR encode error: unsupported type: Uint8Array/)
|
|
159
|
+
assert.throws(() => encode(undefined), /CBOR encode error: unsupported type: undefined/)
|
|
160
|
+
assert.throws(() => encode(new Map([[1, 2], [2, 3]])), /CBOR encode error: non-string map keys are not supported/)
|
|
161
|
+
assert.throws(() => encode(new Map([[['foo', 'bar'], 2], [['bar', 'foo'], 3]])), /CBOR encode error: complex map keys are not supported/)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should throw on bad decode failure modes', () => {
|
|
165
|
+
assert.throws(() => decode(toBytes('{"a":1 & "b":2}')), 'CBOR decode error: unexpected character at position 7, was expecting object delimiter but found \'&\'')
|
|
166
|
+
assert.throws(() => decode(toBytes('{"a":1,"b"!2}')), 'CBOR decode error: unexpected character at position 10, was expecting key/value delimiter \':\' but found \'!\'')
|
|
167
|
+
assert.throws(() => decode(toBytes('[1,2&3]')), 'CBOR decode error: unexpected character at position 4, was expecting array delimiter but found \'&\'')
|
|
168
|
+
assert.throws(() => decode(toBytes('{"a":!}')), 'CBOR decode error: unexpected character at position 5')
|
|
169
|
+
assert.throws(() => decode(toBytes('"abc')), 'CBOR decode error: unexpected end of string at position 4')
|
|
170
|
+
assert.throws(() => decode(toBytes('"ab\\xc"')), 'CBOR decode error: unexpected string escape character at position 5')
|
|
171
|
+
assert.throws(() => decode(toBytes('"ab\x1Ec"')), 'CBOR decode error: invalid control character at position 3')
|
|
172
|
+
assert.throws(() => decode(toBytes('"ab\\')), 'CBOR decode error: unexpected string termination at position 4')
|
|
173
|
+
// begining of a quoted string with 3-byte unicode sequence with the last one truncated
|
|
174
|
+
assert.throws(() => decode(toBytes('"☺').subarray(0, 3)), 'CBOR decode error: unexpected unicode sequence at position 1')
|
|
175
|
+
assert.throws(() => decode(toBytes('"\\uxyza"')), 'CBOR decode error: unexpected unicode escape character at position 3')
|
|
176
|
+
assert.throws(() => decode(toBytes('"\\u11"')), 'CBOR decode error: unexpected end of unicode escape sequence at position 3')
|
|
177
|
+
assert.throws(() => decode(toBytes('-boop')), 'CBOR decode error: unexpected token at position 1')
|
|
178
|
+
assert.throws(() => decode(toBytes('{"v":nope}')), 'CBOR decode error: unexpected token at position 7, expected to find \'null\'')
|
|
179
|
+
assert.throws(() => decode(toBytes('[n]')), 'CBOR decode error: unexpected end of input at position 1')
|
|
180
|
+
assert.throws(() => decode(toBytes('{"v":truu}')), 'CBOR decode error: unexpected token at position 9, expected to find \'true\'')
|
|
181
|
+
assert.throws(() => decode(toBytes('[tr]')), 'CBOR decode error: unexpected end of input at position 1')
|
|
182
|
+
assert.throws(() => decode(toBytes('{"v":flase}')), 'CBOR decode error: unexpected token at position 7, expected to find \'false\'')
|
|
183
|
+
assert.throws(() => decode(toBytes('[fa]')), 'CBOR decode error: unexpected end of input at position 1')
|
|
184
|
+
assert.throws(() => decode(toBytes('-0..1')), 'CBOR decode error: unexpected token at position 3')
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('should throw when rejectDuplicateMapKeys enabled on duplicate keys', () => {
|
|
188
|
+
assert.deepStrictEqual(decode(toBytes('{"foo":1,"foo":2}')), { foo: 2 })
|
|
189
|
+
assert.throws(() => decode(toBytes('{"foo":1,"foo":2}'), { rejectDuplicateMapKeys: true }), /CBOR decode error: found repeat map key "foo"/)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('decodeFirst', () => {
|
|
193
|
+
/*
|
|
194
|
+
const encoded = new TextDecoder().decode(encode(obj, sorting === false ? { mapSorter: null } : undefined))
|
|
195
|
+
const json = JSON.stringify(obj)
|
|
196
|
+
assert.strictEqual(encoded, json)
|
|
197
|
+
const decoded = decode(toBytes(JSON.stringify(obj)))
|
|
198
|
+
assert.deepStrictEqual(decoded, obj)
|
|
199
|
+
*/
|
|
200
|
+
let buf = new TextEncoder().encode('{"foo":1,"bar":2}1"ping"2null3[1,2,3]""[[],[],{"boop":true}]')
|
|
201
|
+
const expected = [
|
|
202
|
+
{ foo: 1, bar: 2 },
|
|
203
|
+
1,
|
|
204
|
+
'ping',
|
|
205
|
+
2,
|
|
206
|
+
null,
|
|
207
|
+
3,
|
|
208
|
+
[1, 2, 3],
|
|
209
|
+
'',
|
|
210
|
+
[[], [], { boop: true }]
|
|
211
|
+
]
|
|
212
|
+
for (const exp of expected) {
|
|
213
|
+
const [obj, rest] = decodeFirst(buf)
|
|
214
|
+
assert.deepStrictEqual(exp, obj)
|
|
215
|
+
buf = rest
|
|
216
|
+
}
|
|
217
|
+
assert.strictEqual(buf.length, 0)
|
|
218
|
+
})
|
|
219
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import * as chai from 'chai'
|
|
4
|
+
import { garbage } from 'ipld-garbage'
|
|
5
|
+
import { uintBoundaries } from '../lib/0uint.js'
|
|
6
|
+
import { encode } from '../cborg.js'
|
|
7
|
+
import { encodedLength } from '../lib/length.js'
|
|
8
|
+
import { dateEncoder } from './common.js'
|
|
9
|
+
|
|
10
|
+
const { assert } = chai
|
|
11
|
+
|
|
12
|
+
function verifyLength (object, options) {
|
|
13
|
+
const len = encodedLength(object, options)
|
|
14
|
+
const encoded = encode(object, options)
|
|
15
|
+
const actual = encoded.length
|
|
16
|
+
assert.strictEqual(actual, len, JSON.stringify(object))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('encodedLength', () => {
|
|
20
|
+
it('int boundaries', () => {
|
|
21
|
+
for (let ii = 0; ii < 4; ii++) {
|
|
22
|
+
verifyLength(uintBoundaries[ii])
|
|
23
|
+
verifyLength(uintBoundaries[ii] - 1)
|
|
24
|
+
verifyLength(uintBoundaries[ii] + 1)
|
|
25
|
+
verifyLength(-1 * uintBoundaries[ii])
|
|
26
|
+
verifyLength(-1 * uintBoundaries[ii] - 1)
|
|
27
|
+
verifyLength(-1 * uintBoundaries[ii] + 1)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('tags', () => {
|
|
32
|
+
verifyLength({ date: new Date('2013-03-21T20:04:00Z') }, { typeEncoders: { Date: dateEncoder } })
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('floats', () => {
|
|
36
|
+
verifyLength(0.5)
|
|
37
|
+
verifyLength(0.5, { float64: true })
|
|
38
|
+
verifyLength(8.940696716308594e-08)
|
|
39
|
+
verifyLength(8.940696716308594e-08, { float64: true })
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('small garbage', function () {
|
|
43
|
+
this.timeout(10000)
|
|
44
|
+
for (let ii = 0; ii < 1000; ii++) {
|
|
45
|
+
const gbg = garbage(1 << 6, { weights: { CID: 0 } })
|
|
46
|
+
verifyLength(gbg)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('medium garbage', function () {
|
|
51
|
+
this.timeout(10000)
|
|
52
|
+
for (let ii = 0; ii < 100; ii++) {
|
|
53
|
+
const gbg = garbage(1 << 16, { weights: { CID: 0 } })
|
|
54
|
+
verifyLength(gbg)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('large garbage', function () {
|
|
59
|
+
this.timeout(10000)
|
|
60
|
+
for (let ii = 0; ii < 10; ii++) {
|
|
61
|
+
const gbg = garbage(1 << 20, { weights: { CID: 0 } })
|
|
62
|
+
verifyLength(gbg)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import * as chai from 'chai'
|
|
4
|
+
import { garbage } from 'ipld-garbage'
|
|
5
|
+
import { uintBoundaries } from '../lib/0uint.js'
|
|
6
|
+
import { encode, decodeFirst } from '../cborg.js'
|
|
7
|
+
import { dateDecoder, dateEncoder } from './common.js'
|
|
8
|
+
|
|
9
|
+
const { assert } = chai
|
|
10
|
+
|
|
11
|
+
function verifyPartial (objects, options) {
|
|
12
|
+
const encoded = []
|
|
13
|
+
const lengths = []
|
|
14
|
+
let length = 0
|
|
15
|
+
for (const object of Array.isArray(objects) ? objects : [objects]) {
|
|
16
|
+
encoded.push(encode(object, options))
|
|
17
|
+
const l = encoded[encoded.length - 1].length
|
|
18
|
+
length += l
|
|
19
|
+
lengths.push(l)
|
|
20
|
+
}
|
|
21
|
+
const buf = new Uint8Array(length)
|
|
22
|
+
let offset = 0
|
|
23
|
+
for (const enc of encoded) {
|
|
24
|
+
buf.set(enc, offset)
|
|
25
|
+
offset += enc.length
|
|
26
|
+
}
|
|
27
|
+
let partial = buf
|
|
28
|
+
for (let ii = 0; ii < encoded.length; ii++) {
|
|
29
|
+
const [decoded, remainder] = decodeFirst(partial, options)
|
|
30
|
+
assert.deepEqual(decoded, objects[ii])
|
|
31
|
+
assert.equal(remainder.length, partial.length - lengths[ii])
|
|
32
|
+
partial = remainder
|
|
33
|
+
}
|
|
34
|
+
assert.equal(partial.length, 0) // just to be sure
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('decodePartial', () => {
|
|
38
|
+
describe('multiple', () => {
|
|
39
|
+
it('simple', () => {
|
|
40
|
+
verifyPartial([1, 2, 3])
|
|
41
|
+
verifyPartial([8.940696716308594e-08, 1])
|
|
42
|
+
verifyPartial([
|
|
43
|
+
[],
|
|
44
|
+
[1, 2, { obj: 1.5 }, null, new Uint8Array([1, 2, 3])],
|
|
45
|
+
{ boop: true, bop: 1 },
|
|
46
|
+
'nope',
|
|
47
|
+
{ o: 'nope' },
|
|
48
|
+
new Uint8Array([1, 2, 3]),
|
|
49
|
+
true,
|
|
50
|
+
null
|
|
51
|
+
])
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('options', () => {
|
|
55
|
+
const m = new Map()
|
|
56
|
+
m.set('a', 1)
|
|
57
|
+
m.set('b', null)
|
|
58
|
+
m.set('c', 'grok')
|
|
59
|
+
m.set('date', new Date('2013-03-21T20:04:00Z'))
|
|
60
|
+
verifyPartial(
|
|
61
|
+
[8.940696716308594e-08, 1, null, 'grok', new Date('2013-03-21T20:04:00Z'),
|
|
62
|
+
[8.940696716308594e-08, 1, null, 'grok', new Date('2013-03-21T20:04:00Z')],
|
|
63
|
+
m
|
|
64
|
+
],
|
|
65
|
+
{ typeEncoders: { Date: dateEncoder }, useMaps: true, tags: { 0: dateDecoder } })
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('garbage', function () {
|
|
69
|
+
this.timeout(10000)
|
|
70
|
+
for (let ii = 0; ii < 10; ii++) {
|
|
71
|
+
const gbg = []
|
|
72
|
+
for (let ii = 0; ii < 100; ii++) {
|
|
73
|
+
gbg.push(garbage(1 << 6, { weights: { CID: 0 } }))
|
|
74
|
+
}
|
|
75
|
+
verifyPartial(gbg)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('singular', () => {
|
|
81
|
+
it('int boundaries', () => {
|
|
82
|
+
for (let ii = 0; ii < 4; ii++) {
|
|
83
|
+
verifyPartial(uintBoundaries[ii])
|
|
84
|
+
verifyPartial(uintBoundaries[ii] - 1)
|
|
85
|
+
verifyPartial(uintBoundaries[ii] + 1)
|
|
86
|
+
verifyPartial(-1 * uintBoundaries[ii])
|
|
87
|
+
verifyPartial(-1 * uintBoundaries[ii] - 1)
|
|
88
|
+
verifyPartial(-1 * uintBoundaries[ii] + 1)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('tags', () => {
|
|
93
|
+
verifyPartial({ date: new Date('2013-03-21T20:04:00Z') }, { typeEncoders: { Date: dateEncoder } })
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('floats', () => {
|
|
97
|
+
verifyPartial(0.5)
|
|
98
|
+
verifyPartial(0.5, { float64: true })
|
|
99
|
+
verifyPartial(8.940696716308594e-08)
|
|
100
|
+
verifyPartial(8.940696716308594e-08, { float64: true })
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('small garbage', function () {
|
|
104
|
+
this.timeout(10000)
|
|
105
|
+
for (let ii = 0; ii < 1000; ii++) {
|
|
106
|
+
const gbg = garbage(1 << 6, { weights: { CID: 0 } })
|
|
107
|
+
verifyPartial(gbg)
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"checkJs": true,
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"noImplicitReturns": false,
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
"noImplicitThis": true,
|
|
9
|
+
"noFallthroughCasesInSwitch": true,
|
|
10
|
+
"noUnusedLocals": true,
|
|
11
|
+
"noUnusedParameters": true,
|
|
12
|
+
"strictFunctionTypes": false,
|
|
13
|
+
"strictNullChecks": true,
|
|
14
|
+
"strictPropertyInitialization": true,
|
|
15
|
+
"strictBindCallApply": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"alwaysStrict": true,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"target": "ES2018",
|
|
20
|
+
"moduleResolution": "node",
|
|
21
|
+
"declaration": true,
|
|
22
|
+
"declarationMap": true,
|
|
23
|
+
"outDir": "types",
|
|
24
|
+
"skipLibCheck": true,
|
|
25
|
+
"stripInternal": true,
|
|
26
|
+
"resolveJsonModule": true,
|
|
27
|
+
"baseUrl": ".",
|
|
28
|
+
"emitDeclarationOnly": true,
|
|
29
|
+
"paths": {
|
|
30
|
+
"cborg": [
|
|
31
|
+
"cborg.js"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"include": [
|
|
36
|
+
"cborg.js",
|
|
37
|
+
"example.js",
|
|
38
|
+
"taglib.js",
|
|
39
|
+
"lib/"
|
|
40
|
+
],
|
|
41
|
+
"exclude": [
|
|
42
|
+
"node_modules"
|
|
43
|
+
],
|
|
44
|
+
"compileOnSave": false
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { encodeCustom } from "./lib/encode.js";
|
|
2
|
+
/**
|
|
3
|
+
* There was originally just `TypeEncoder` so don't break types by renaming or not exporting
|
|
4
|
+
*/
|
|
5
|
+
export type TagDecoder = import("./interface").TagDecoder;
|
|
6
|
+
/**
|
|
7
|
+
* Export the types that were present in the original manual cborg.d.ts
|
|
8
|
+
*/
|
|
9
|
+
export type TypeEncoder = import("./interface").OptionalTypeEncoder;
|
|
10
|
+
/**
|
|
11
|
+
* Export the types that were present in the original manual cborg.d.ts
|
|
12
|
+
*/
|
|
13
|
+
export type DecodeOptions = import("./interface").DecodeOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Export the types that were present in the original manual cborg.d.ts
|
|
16
|
+
*/
|
|
17
|
+
export type EncodeOptions = import("./interface").EncodeOptions;
|
|
18
|
+
import { decode } from './lib/decode.js';
|
|
19
|
+
import { decodeFirst } from './lib/decode.js';
|
|
20
|
+
import { Tokeniser } from './lib/decode.js';
|
|
21
|
+
import { tokensToObject } from './lib/decode.js';
|
|
22
|
+
import { encode } from './lib/encode.js';
|
|
23
|
+
import { Token } from './lib/token.js';
|
|
24
|
+
import { Type } from './lib/token.js';
|
|
25
|
+
export { decode, decodeFirst, Tokeniser as Tokenizer, tokensToObject, encode, Token, Type };
|
|
26
|
+
export { encodeErrPrefix, decodeErrPrefix } from "./lib/common.js";
|
|
27
|
+
export { asU8A, fromString, decodeCodePointsArray } from "./lib/byte-utils.js";
|
|
28
|
+
//# sourceMappingURL=cborg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cborg.d.ts","sourceRoot":"","sources":["../cborg.js"],"names":[],"mappings":";;;;yBAWa,OAAO,aAAa,EAAE,UAAU;;;;0BAEhC,OAAO,aAAa,EAAE,mBAAmB;;;;4BACzC,OAAO,aAAa,EAAE,aAAa;;;;4BACnC,OAAO,aAAa,EAAE,aAAa;uBAde,iBAAiB;4BAAjB,iBAAiB;0BAAjB,iBAAiB;+BAAjB,iBAAiB;uBADzD,iBAAiB;sBAEZ,gBAAgB;qBAAhB,gBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../example.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Token } from './lib/token';
|
|
2
|
+
import { Bl } from './lib/bl';
|
|
3
|
+
export type TokenOrNestedTokens = Token | Token[] | TokenOrNestedTokens[];
|
|
4
|
+
export interface Reference {
|
|
5
|
+
parent: Reference | undefined;
|
|
6
|
+
obj: object | any[];
|
|
7
|
+
includes(obj: object | any[]): boolean;
|
|
8
|
+
}
|
|
9
|
+
export type OptionalTypeEncoder = (data: any, typ: string, options: EncodeOptions, refStack?: Reference) => TokenOrNestedTokens | null;
|
|
10
|
+
export type StrictTypeEncoder = (data: any, typ: string, options: EncodeOptions, refStack?: Reference) => TokenOrNestedTokens;
|
|
11
|
+
export type TokenTypeEncoder = {
|
|
12
|
+
(buf: Bl, token: Token, options?: EncodeOptions): void;
|
|
13
|
+
compareTokens(t1: Token, t2: Token): number;
|
|
14
|
+
encodedSize?(token: Token, options?: EncodeOptions): number;
|
|
15
|
+
};
|
|
16
|
+
export type MapSorter = (e1: (Token | Token[])[], e2: (Token | Token[])[]) => number;
|
|
17
|
+
export type QuickEncodeToken = (token: Token) => Uint8Array | undefined;
|
|
18
|
+
export interface DecodeTokenizer {
|
|
19
|
+
done(): boolean;
|
|
20
|
+
next(): Token;
|
|
21
|
+
pos(): number;
|
|
22
|
+
}
|
|
23
|
+
export type TagDecoder = (inner: any) => any;
|
|
24
|
+
export interface DecodeOptions {
|
|
25
|
+
allowIndefinite?: boolean;
|
|
26
|
+
allowUndefined?: boolean;
|
|
27
|
+
coerceUndefinedToNull?: boolean;
|
|
28
|
+
allowInfinity?: boolean;
|
|
29
|
+
allowNaN?: boolean;
|
|
30
|
+
allowBigInt?: boolean;
|
|
31
|
+
strict?: boolean;
|
|
32
|
+
useMaps?: boolean;
|
|
33
|
+
rejectDuplicateMapKeys?: boolean;
|
|
34
|
+
retainStringBytes?: boolean;
|
|
35
|
+
tags?: TagDecoder[];
|
|
36
|
+
tokenizer?: DecodeTokenizer;
|
|
37
|
+
}
|
|
38
|
+
export interface EncodeOptions {
|
|
39
|
+
float64?: boolean;
|
|
40
|
+
addBreakTokens?: boolean;
|
|
41
|
+
mapSorter?: MapSorter;
|
|
42
|
+
quickEncodeToken?: QuickEncodeToken;
|
|
43
|
+
typeEncoders?: {
|
|
44
|
+
[typeName: string]: OptionalTypeEncoder;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAE7B,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,KAAK,EAAE,GAAG,mBAAmB,EAAE,CAAA;AAEzE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;IAC7B,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAA;CACvC;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,SAAS,KAAK,mBAAmB,GAAG,IAAI,CAAA;AAEtI,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,SAAS,KAAK,mBAAmB,CAAA;AAE7H,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACvD,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAAC;IAE5C,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;CAC7D,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,EAAE,CAAC,EAAE,KAAK,MAAM,CAAA;AAEpF,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,UAAU,GAAG,SAAS,CAAA;AAEvE,MAAM,WAAW,eAAe;IAC9B,IAAI,IAAI,OAAO,CAAC;IAChB,IAAI,IAAI,KAAK,CAAC;IACd,GAAG,IAAI,MAAM,CAAC;CACf;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;AAE5C,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,YAAY,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAAA;KAAE,CAAA;CAC3D"}
|