@fireproof/vendor 0.0.0-smoke → 1.0.0
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 +150 -7
- package/patched/@ipld/dag-json/.github/dependabot.yml +0 -11
- package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +0 -28
- package/patched/@ipld/dag-json/CHANGELOG.md +0 -202
- package/patched/@ipld/dag-json/LICENSE-APACHE +0 -5
- package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
- package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
- package/patched/@ipld/dag-json/src/index.js +0 -291
- package/patched/@ipld/dag-json/test/test-basics.spec.js +0 -290
- package/patched/@ipld/dag-json/test/ts-use/package.json +0 -11
- package/patched/@ipld/dag-json/test/ts-use/src/main.ts +0 -54
- package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +0 -9
- package/patched/@ipld/dag-json/tsconfig.json +0 -14
- package/patched/cborg/.github/dependabot.yml +0 -16
- package/patched/cborg/.github/workflows/test-and-release.yml +0 -52
- package/patched/cborg/cborg-4.2.7.tgz +0 -0
- package/patched/cborg/example-json.js +0 -6
- package/patched/cborg/example.js +0 -5
- package/patched/cborg/lib/0uint.js +0 -227
- package/patched/cborg/lib/json/decode.js +0 -462
- package/patched/cborg/lib/json/encode.js +0 -299
- package/patched/cborg/package.json +0 -169
- package/patched/cborg/pnpm-lock.yaml +0 -6096
- package/patched/cborg/test/common.js +0 -18
- package/patched/cborg/test/test-cbor-vectors.js +0 -107
- package/patched/cborg/test/test-json.js +0 -219
- package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-json/dag-json/README.md +0 -58
- package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-json/dag-json/package.json +0 -173
- package/src/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
- package/src/cborg/cborg/.github/dependabot.yml +0 -16
- package/src/cborg/cborg/.github/workflows/test-and-release.yml +0 -52
- package/src/cborg/cborg/CHANGELOG.md +0 -513
- package/src/cborg/cborg/LICENSE +0 -13
- package/src/cborg/cborg/README.md +0 -515
- package/src/cborg/cborg/bench/bench.js +0 -117
- package/src/cborg/cborg/bench/json.js +0 -124
- package/src/cborg/cborg/bench/package.json +0 -8
- package/src/cborg/cborg/cborg.js +0 -31
- package/src/cborg/cborg/example-bytestrings.js +0 -180
- package/src/cborg/cborg/interface.ts +0 -56
- package/src/cborg/cborg/lib/1negint.js +0 -111
- package/src/cborg/cborg/lib/2bytes.js +0 -133
- package/src/cborg/cborg/lib/3string.js +0 -90
- package/src/cborg/cborg/lib/4array.js +0 -113
- package/src/cborg/cborg/lib/5map.js +0 -113
- package/src/cborg/cborg/lib/6tag.js +0 -80
- package/src/cborg/cborg/lib/7float.js +0 -308
- package/src/cborg/cborg/lib/bin.js +0 -189
- package/src/cborg/cborg/lib/bl.js +0 -124
- package/src/cborg/cborg/lib/byte-utils.js +0 -417
- package/src/cborg/cborg/lib/common.js +0 -27
- package/src/cborg/cborg/lib/decode.js +0 -209
- package/src/cborg/cborg/lib/diagnostic.js +0 -156
- package/src/cborg/cborg/lib/diagnostic_test.js +0 -117
- package/src/cborg/cborg/lib/encode.js +0 -464
- package/src/cborg/cborg/lib/is.js +0 -106
- package/src/cborg/cborg/lib/json/json.js +0 -4
- package/src/cborg/cborg/lib/jump.js +0 -209
- package/src/cborg/cborg/lib/length.js +0 -61
- package/src/cborg/cborg/lib/token.js +0 -76
- package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
- package/src/cborg/cborg/taglib.js +0 -73
- package/src/cborg/cborg/test/appendix_a.js +0 -647
- package/src/cborg/cborg/test/node-test-bin.js +0 -402
- package/src/cborg/cborg/test/noop-bin-test.js +0 -3
- package/src/cborg/cborg/test/test-0uint.js +0 -103
- package/src/cborg/cborg/test/test-1negint.js +0 -96
- package/src/cborg/cborg/test/test-2bytes.js +0 -198
- package/src/cborg/cborg/test/test-3string.js +0 -136
- package/src/cborg/cborg/test/test-4array.js +0 -93
- package/src/cborg/cborg/test/test-5map.js +0 -284
- package/src/cborg/cborg/test/test-6tag.js +0 -85
- package/src/cborg/cborg/test/test-7float.js +0 -131
- package/src/cborg/cborg/test/test-bl.js +0 -37
- package/src/cborg/cborg/test/test-decode-errors.js +0 -65
- package/src/cborg/cborg/test/test-fuzz.js +0 -42
- package/src/cborg/cborg/test/test-length.js +0 -65
- package/src/cborg/cborg/test/test-partial.js +0 -111
- package/src/cborg/cborg/tsconfig.json +0 -45
- package/src/cborg/cborg/types/cborg.d.ts +0 -28
- package/src/cborg/cborg/types/cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/example.d.ts +0 -2
- package/src/cborg/cborg/types/example.d.ts.map +0 -1
- package/src/cborg/cborg/types/interface.d.ts +0 -47
- package/src/cborg/cborg/types/interface.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/0uint.d.ts +0 -100
- package/src/cborg/cborg/types/lib/0uint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/1negint.d.ts +0 -58
- package/src/cborg/cborg/types/lib/1negint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/2bytes.d.ts +0 -68
- package/src/cborg/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/3string.d.ts +0 -46
- package/src/cborg/cborg/types/lib/3string.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/4array.d.ts +0 -65
- package/src/cborg/cborg/types/lib/4array.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/5map.d.ts +0 -65
- package/src/cborg/cborg/types/lib/5map.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/6tag.d.ts +0 -61
- package/src/cborg/cborg/types/lib/6tag.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/7float.d.ts +0 -60
- package/src/cborg/cborg/types/lib/7float.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bin.d.ts +0 -4
- package/src/cborg/cborg/types/lib/bin.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bl.d.ts +0 -26
- package/src/cborg/cborg/types/lib/bl.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/byte-utils.d.ts +0 -53
- package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/common.d.ts +0 -10
- package/src/cborg/cborg/types/lib/common.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/decode.d.ts +0 -41
- package/src/cborg/cborg/types/lib/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic.d.ts +0 -12
- package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/encode.d.ts +0 -50
- package/src/cborg/cborg/types/lib/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/is.d.ts +0 -6
- package/src/cborg/cborg/types/lib/is.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/decode.d.ts +0 -67
- package/src/cborg/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/encode.d.ts +0 -11
- package/src/cborg/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/json.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/json.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/jump.d.ts +0 -12
- package/src/cborg/cborg/types/lib/jump.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/length.d.ts +0 -27
- package/src/cborg/cborg/types/lib/length.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/token.d.ts +0 -59
- package/src/cborg/cborg/types/lib/token.d.ts.map +0 -1
- package/src/cborg/cborg/types/taglib.d.ts +0 -18
- package/src/cborg/cborg/types/taglib.d.ts.map +0 -1
- package/src/cborg/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +0 -4
- /package/{patched/@ipld/dag-json → src/@ipld/car}/LICENSE +0 -0
- /package/src/@ipld/car/{car/README.md → README.md} +0 -0
- /package/src/@ipld/car/{car/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/package.json → package.json} +0 -0
- /package/src/@ipld/car/{car/src → src}/api.ts +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-decoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-reader.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-writer.js +0 -0
- /package/src/@ipld/car/{car/src → src}/coding.ts +0 -0
- /package/src/@ipld/car/{car/src → src}/decoder-common.js +0 -0
- /package/src/@ipld/car/{car/src → src}/decoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/encoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/header-validator.js +0 -0
- /package/src/@ipld/car/{car/src → src}/header.ipldsch +0 -0
- /package/src/@ipld/car/{car/src → src}/index-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/index.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexed-reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexed-reader.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexer.js +0 -0
- /package/src/@ipld/car/{car/src → src}/iterator-channel.js +0 -0
- /package/src/@ipld/car/{car/src → src}/iterator.js +0 -0
- /package/src/@ipld/car/{car/src → src}/reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/reader.js +0 -0
- /package/src/@ipld/car/{car/src → src}/writer-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/writer.js +0 -0
- /package/src/@ipld/{car/car → dag-cbor}/LICENSE +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/README.md → README.md} +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/package.json → package.json} +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/src → src}/index.js +0 -0
- /package/src/@ipld/{dag-cbor/dag-cbor → dag-json}/LICENSE +0 -0
- /package/{patched → src}/@ipld/dag-json/README.md +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts.map +0 -0
- /package/{patched → src}/@ipld/dag-json/package.json +0 -0
- /package/src/@ipld/dag-json/{dag-json/src → src}/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/LICENSE.md → LICENSE.md} +0 -0
- /package/src/@web3-storage/pail/{pail/README.md → README.md} +0 -0
- /package/src/@web3-storage/pail/{pail/cli.js → cli.js} +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/tsconfig.tsbuildinfo +0 -0
- /package/src/@web3-storage/pail/{pail/package.json → package.json} +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/shard.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/block.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/diff.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/merge.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/shard.js +0 -0
- /package/{patched → src}/cborg/CHANGELOG.md +0 -0
- /package/{patched → src}/cborg/LICENSE +0 -0
- /package/{patched → src}/cborg/README.md +0 -0
- /package/{patched → src}/cborg/bench/bench.js +0 -0
- /package/{patched → src}/cborg/bench/json.js +0 -0
- /package/{patched → src}/cborg/bench/package.json +0 -0
- /package/{patched → src}/cborg/cborg.js +0 -0
- /package/{patched → src}/cborg/example-bytestrings.js +0 -0
- /package/src/cborg/{cborg/example-json.js → example-json.js} +0 -0
- /package/src/cborg/{cborg/example.js → example.js} +0 -0
- /package/{patched → src}/cborg/interface.ts +0 -0
- /package/src/cborg/{cborg/lib → lib}/0uint.js +0 -0
- /package/{patched → src}/cborg/lib/1negint.js +0 -0
- /package/{patched → src}/cborg/lib/2bytes.js +0 -0
- /package/{patched → src}/cborg/lib/3string.js +0 -0
- /package/{patched → src}/cborg/lib/4array.js +0 -0
- /package/{patched → src}/cborg/lib/5map.js +0 -0
- /package/{patched → src}/cborg/lib/6tag.js +0 -0
- /package/{patched → src}/cborg/lib/7float.js +0 -0
- /package/{patched → src}/cborg/lib/bin.js +0 -0
- /package/{patched → src}/cborg/lib/bl.js +0 -0
- /package/{patched → src}/cborg/lib/byte-utils.js +0 -0
- /package/{patched → src}/cborg/lib/common.js +0 -0
- /package/{patched → src}/cborg/lib/decode.js +0 -0
- /package/{patched → src}/cborg/lib/diagnostic.js +0 -0
- /package/{patched → src}/cborg/lib/diagnostic_test.js +0 -0
- /package/{patched → src}/cborg/lib/encode.js +0 -0
- /package/{patched → src}/cborg/lib/is.js +0 -0
- /package/src/cborg/{cborg/lib → lib}/json/decode.js +0 -0
- /package/src/cborg/{cborg/lib → lib}/json/encode.js +0 -0
- /package/{patched → src}/cborg/lib/json/json.js +0 -0
- /package/{patched → src}/cborg/lib/jump.js +0 -0
- /package/{patched → src}/cborg/lib/length.js +0 -0
- /package/{patched → src}/cborg/lib/token.js +0 -0
- /package/src/cborg/{cborg/package.json → package.json} +0 -0
- /package/{patched → src}/cborg/taglib.js +0 -0
- /package/{patched → src}/cborg/test/appendix_a.js +0 -0
- /package/src/cborg/{cborg/test → test}/common.js +0 -0
- /package/{patched → src}/cborg/test/node-test-bin.js +0 -0
- /package/{patched → src}/cborg/test/noop-bin-test.js +0 -0
- /package/{patched → src}/cborg/test/test-0uint.js +0 -0
- /package/{patched → src}/cborg/test/test-1negint.js +0 -0
- /package/{patched → src}/cborg/test/test-2bytes.js +0 -0
- /package/{patched → src}/cborg/test/test-3string.js +0 -0
- /package/{patched → src}/cborg/test/test-4array.js +0 -0
- /package/{patched → src}/cborg/test/test-5map.js +0 -0
- /package/{patched → src}/cborg/test/test-6tag.js +0 -0
- /package/{patched → src}/cborg/test/test-7float.js +0 -0
- /package/{patched → src}/cborg/test/test-bl.js +0 -0
- /package/src/cborg/{cborg/test → test}/test-cbor-vectors.js +0 -0
- /package/{patched → src}/cborg/test/test-decode-errors.js +0 -0
- /package/{patched → src}/cborg/test/test-fuzz.js +0 -0
- /package/src/cborg/{cborg/test → test}/test-json.js +0 -0
- /package/{patched → src}/cborg/test/test-length.js +0 -0
- /package/{patched → src}/cborg/test/test-partial.js +0 -0
- /package/{patched → src}/cborg/tsconfig.json +0 -0
- /package/{patched → src}/cborg/types/cborg.d.ts +0 -0
- /package/{patched → src}/cborg/types/cborg.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/example.d.ts +0 -0
- /package/{patched → src}/cborg/types/example.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/interface.d.ts +0 -0
- /package/{patched → src}/cborg/types/interface.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/0uint.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/0uint.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/1negint.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/1negint.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/2bytes.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/2bytes.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/3string.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/3string.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/4array.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/4array.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/5map.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/5map.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/6tag.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/6tag.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/7float.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/7float.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/bin.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/bin.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/bl.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/bl.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/byte-utils.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/byte-utils.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/common.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/common.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/decode.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/decode.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/diagnostic.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/diagnostic.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/diagnostic_test.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/diagnostic_test.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/encode.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/encode.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/is.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/is.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/json/decode.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/json/decode.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/json/encode.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/json/encode.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/json/forward-cborg.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/json/forward-cborg.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/json/json.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/json/json.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/jump.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/jump.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/length.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/length.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/lib/token.d.ts +0 -0
- /package/{patched → src}/cborg/types/lib/token.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/taglib.d.ts +0 -0
- /package/{patched → src}/cborg/types/taglib.d.ts.map +0 -0
- /package/{patched → src}/cborg/types/tsconfig.tsbuildinfo +0 -0
- /package/src/{@ipld/dag-json/dag-json → ipfs-unixfs-exporter}/LICENSE +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/README.md → README.md} +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/index.min.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/typedoc-urls.json +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/package.json → package.json} +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/errors.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-cbor.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-json.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/identity.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/json.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/raw.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/directory.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/file.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/raw.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/extract-data-from-block.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/find-cid-in-shard.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/resolve-object-path.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/validate-offset-and-length.ts +0 -0
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/* eslint max-depth: ["error", 7] */
|
|
2
|
-
import { Token, Type } from 'cborg'
|
|
3
|
-
import * as cborgJson from 'cborg/json'
|
|
4
|
-
import { CID } from 'multiformats'
|
|
5
|
-
import { base64 } from 'multiformats/bases/base64'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @template T
|
|
9
|
-
* @typedef {import('multiformats/codecs/interface').ByteView<T>} ByteView
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @template T
|
|
13
|
-
* @typedef {import('multiformats/codecs/interface').ArrayBufferView<T>} ArrayBufferView
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @template T
|
|
17
|
-
* @typedef {import('multiformats').ToString<T>} ToString
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {import('cborg/interface').DecodeTokenizer} DecodeTokenizer
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @template T
|
|
25
|
-
* @param {ByteView<T> | ArrayBufferView<T>} buf
|
|
26
|
-
* @returns {ByteView<T>}
|
|
27
|
-
*/
|
|
28
|
-
function toByteView (buf) {
|
|
29
|
-
if (buf instanceof ArrayBuffer) {
|
|
30
|
-
return new Uint8Array(buf, 0, buf.byteLength)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return buf
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* cidEncoder will receive all Objects during encode, it needs to filter out
|
|
38
|
-
* anything that's not a CID and return `null` for that so it's encoded as
|
|
39
|
-
* normal. Encoding a CID means replacing it with a `{"/":"<CidString>}`
|
|
40
|
-
* object as per the DAG-JSON spec.
|
|
41
|
-
*
|
|
42
|
-
* @param {any} obj
|
|
43
|
-
* @returns {Token[]|null}
|
|
44
|
-
*/
|
|
45
|
-
function cidEncoder (obj) {
|
|
46
|
-
if (obj.asCID !== obj && obj['/'] !== obj.bytes) {
|
|
47
|
-
return null // any other kind of object
|
|
48
|
-
}
|
|
49
|
-
const cid = CID.asCID(obj)
|
|
50
|
-
/* c8 ignore next 4 */
|
|
51
|
-
// very unlikely case, and it'll probably throw a recursion error in cborg
|
|
52
|
-
if (!cid) {
|
|
53
|
-
return null
|
|
54
|
-
}
|
|
55
|
-
const cidString = cid.toString()
|
|
56
|
-
|
|
57
|
-
return [
|
|
58
|
-
new Token(Type.map, Infinity, 1),
|
|
59
|
-
new Token(Type.string, '/', 1), // key
|
|
60
|
-
new Token(Type.string, cidString, cidString.length), // value
|
|
61
|
-
new Token(Type.break, undefined, 1)
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* bytesEncoder will receive all Uint8Arrays (and friends) during encode, it
|
|
67
|
-
* needs to replace it with a `{"/":{"bytes":"Base64ByteString"}}` object as
|
|
68
|
-
* per the DAG-JSON spec.
|
|
69
|
-
*
|
|
70
|
-
* @param {Uint8Array} bytes
|
|
71
|
-
* @returns {Token[]|null}
|
|
72
|
-
*/
|
|
73
|
-
function bytesEncoder (bytes) {
|
|
74
|
-
const bytesString = base64.encode(bytes).slice(1) // no mbase prefix
|
|
75
|
-
return [
|
|
76
|
-
new Token(Type.map, Infinity, 1),
|
|
77
|
-
new Token(Type.string, '/', 1), // key
|
|
78
|
-
new Token(Type.map, Infinity, 1), // value
|
|
79
|
-
new Token(Type.string, 'bytes', 5), // inner key
|
|
80
|
-
new Token(Type.string, bytesString, bytesString.length), // inner value
|
|
81
|
-
new Token(Type.break, undefined, 1),
|
|
82
|
-
new Token(Type.break, undefined, 1)
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* taBytesEncoder wraps bytesEncoder() but for the more exotic typed arrays so
|
|
88
|
-
* that we access the underlying ArrayBuffer data
|
|
89
|
-
*
|
|
90
|
-
* @param {Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|Uint8ClampedArray|BigInt64Array|BigUint64Array} obj
|
|
91
|
-
* @returns {Token[]|null}
|
|
92
|
-
*/
|
|
93
|
-
function taBytesEncoder (obj) {
|
|
94
|
-
return bytesEncoder(new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength))
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* abBytesEncoder wraps bytesEncoder() but for plain ArrayBuffers
|
|
99
|
-
*
|
|
100
|
-
* @param {ArrayBuffer} ab
|
|
101
|
-
* @returns {Token[]|null}
|
|
102
|
-
*/
|
|
103
|
-
function abBytesEncoder (ab) {
|
|
104
|
-
return bytesEncoder(new Uint8Array(ab))
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// eslint-disable-next-line jsdoc/require-returns-check
|
|
108
|
-
/**
|
|
109
|
-
* Intercept all `undefined` values from an object walk and reject the entire
|
|
110
|
-
* object if we find one.
|
|
111
|
-
*
|
|
112
|
-
* @returns {null}
|
|
113
|
-
*/
|
|
114
|
-
function undefinedEncoder () {
|
|
115
|
-
throw new Error('`undefined` is not supported by the IPLD Data Model and cannot be encoded')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Intercept all `number` values from an object walk and reject the entire
|
|
120
|
-
* object if we find something that doesn't fit the IPLD data model (NaN &
|
|
121
|
-
* Infinity).
|
|
122
|
-
*
|
|
123
|
-
* @param {number} num
|
|
124
|
-
* @returns {null}
|
|
125
|
-
*/
|
|
126
|
-
function numberEncoder (num) {
|
|
127
|
-
if (Number.isNaN(num)) {
|
|
128
|
-
throw new Error('`NaN` is not supported by the IPLD Data Model and cannot be encoded')
|
|
129
|
-
}
|
|
130
|
-
if (num === Infinity || num === -Infinity) {
|
|
131
|
-
throw new Error('`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded')
|
|
132
|
-
}
|
|
133
|
-
return null // process with standard number encoder
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const encodeOptions = {
|
|
137
|
-
typeEncoders: {
|
|
138
|
-
Object: cidEncoder,
|
|
139
|
-
Buffer: bytesEncoder,
|
|
140
|
-
Uint8Array: bytesEncoder,
|
|
141
|
-
Int8Array: taBytesEncoder,
|
|
142
|
-
Uint16Array: taBytesEncoder,
|
|
143
|
-
Int16Array: taBytesEncoder,
|
|
144
|
-
Uint32Array: taBytesEncoder,
|
|
145
|
-
Int32Array: taBytesEncoder,
|
|
146
|
-
Float32Array: taBytesEncoder,
|
|
147
|
-
Float64Array: taBytesEncoder,
|
|
148
|
-
Uint8ClampedArray: taBytesEncoder,
|
|
149
|
-
BigInt64Array: taBytesEncoder,
|
|
150
|
-
BigUint64Array: taBytesEncoder,
|
|
151
|
-
DataView: taBytesEncoder,
|
|
152
|
-
ArrayBuffer: abBytesEncoder,
|
|
153
|
-
undefined: undefinedEncoder,
|
|
154
|
-
number: numberEncoder
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @implements {DecodeTokenizer}
|
|
160
|
-
*/
|
|
161
|
-
class DagJsonTokenizer extends cborgJson.Tokenizer {
|
|
162
|
-
/**
|
|
163
|
-
* @param {Uint8Array} data
|
|
164
|
-
* @param {object} [options]
|
|
165
|
-
*/
|
|
166
|
-
constructor (data, options) {
|
|
167
|
-
super(data, options)
|
|
168
|
-
/** @type {Token[]} */
|
|
169
|
-
this.tokenBuffer = []
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @returns {boolean}
|
|
174
|
-
*/
|
|
175
|
-
done () {
|
|
176
|
-
return this.tokenBuffer.length === 0 && super.done()
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* @returns {Token}
|
|
181
|
-
*/
|
|
182
|
-
_next () {
|
|
183
|
-
if (this.tokenBuffer.length > 0) {
|
|
184
|
-
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/30406
|
|
185
|
-
return this.tokenBuffer.pop()
|
|
186
|
-
}
|
|
187
|
-
return super.next()
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Implements rules outlined in https://github.com/ipld/specs/pull/356
|
|
192
|
-
*
|
|
193
|
-
* @returns {Token}
|
|
194
|
-
*/
|
|
195
|
-
next () {
|
|
196
|
-
const token = this._next()
|
|
197
|
-
|
|
198
|
-
if (token.type.compare(Type.map) === 0) {
|
|
199
|
-
const keyToken = this._next()
|
|
200
|
-
if (keyToken.type.compare(Type.string) === 0 && keyToken.value === '/') {
|
|
201
|
-
const valueToken = this._next()
|
|
202
|
-
if (valueToken.type.compare(Type.string) === 0) { // *must* be a CID
|
|
203
|
-
const breakToken = this._next() // swallow the end-of-map token
|
|
204
|
-
if (breakToken.type.compare(Type.break)) {
|
|
205
|
-
throw new Error('Invalid encoded CID form')
|
|
206
|
-
}
|
|
207
|
-
this.tokenBuffer.push(valueToken) // CID.parse will pick this up after our tag token
|
|
208
|
-
return new Token(Type.tag, 42, 0)
|
|
209
|
-
}
|
|
210
|
-
if (valueToken.type.compare(Type.map) === 0) {
|
|
211
|
-
const innerKeyToken = this._next()
|
|
212
|
-
if (innerKeyToken.type.compare(Type.string) === 0 && innerKeyToken.value === 'bytes') {
|
|
213
|
-
const innerValueToken = this._next()
|
|
214
|
-
if (innerValueToken.type.compare(Type.string) === 0) { // *must* be Bytes
|
|
215
|
-
for (let i = 0; i < 2; i++) {
|
|
216
|
-
const breakToken = this._next() // swallow two end-of-map tokens
|
|
217
|
-
if (breakToken.type.compare(Type.break)) {
|
|
218
|
-
throw new Error('Invalid encoded Bytes form')
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const bytes = base64.decode(`m${innerValueToken.value}`)
|
|
222
|
-
return new Token(Type.bytes, bytes, innerValueToken.value.length)
|
|
223
|
-
}
|
|
224
|
-
this.tokenBuffer.push(innerValueToken) // bail
|
|
225
|
-
}
|
|
226
|
-
this.tokenBuffer.push(innerKeyToken) // bail
|
|
227
|
-
}
|
|
228
|
-
this.tokenBuffer.push(valueToken) // bail
|
|
229
|
-
}
|
|
230
|
-
this.tokenBuffer.push(keyToken) // bail
|
|
231
|
-
}
|
|
232
|
-
return token
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const decodeOptions = {
|
|
237
|
-
allowIndefinite: false,
|
|
238
|
-
allowUndefined: false,
|
|
239
|
-
allowNaN: false,
|
|
240
|
-
allowInfinity: false,
|
|
241
|
-
allowBigInt: true, // this will lead to BigInt for ints outside of
|
|
242
|
-
// safe-integer range, which may surprise users
|
|
243
|
-
strict: true,
|
|
244
|
-
useMaps: false,
|
|
245
|
-
rejectDuplicateMapKeys: true,
|
|
246
|
-
/** @type {import('cborg').TagDecoder[]} */
|
|
247
|
-
tags: []
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// we're going to get TAG(42)STRING("bafy...") from the tokenizer so we only need
|
|
251
|
-
// to deal with the STRING("bafy...") at this point
|
|
252
|
-
decodeOptions.tags[42] = CID.parse
|
|
253
|
-
|
|
254
|
-
export const name = 'dag-json'
|
|
255
|
-
export const code = 0x0129
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @template T
|
|
259
|
-
* @param {T} node
|
|
260
|
-
* @returns {ByteView<T>}
|
|
261
|
-
*/
|
|
262
|
-
export const encode = (node) => cborgJson.encode(node, encodeOptions)
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* @template T
|
|
266
|
-
* @param {ByteView<T> | ArrayBufferView<T>} data
|
|
267
|
-
* @returns {T}
|
|
268
|
-
*/
|
|
269
|
-
export const decode = (data) => {
|
|
270
|
-
const buf = toByteView(data)
|
|
271
|
-
// the tokenizer is stateful so we need a single instance of it
|
|
272
|
-
const options = Object.assign(decodeOptions, { tokenizer: new DagJsonTokenizer(buf, decodeOptions) })
|
|
273
|
-
return cborgJson.decode(buf, options)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* @template T
|
|
278
|
-
* @param {T} node
|
|
279
|
-
* @returns {ToString<T>}
|
|
280
|
-
*/
|
|
281
|
-
export const format = (node) => utf8Decoder.decode(encode(node))
|
|
282
|
-
export { format as stringify }
|
|
283
|
-
const utf8Decoder = new TextDecoder()
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* @template T
|
|
287
|
-
* @param {ToString<T>} data
|
|
288
|
-
* @returns {T}
|
|
289
|
-
*/
|
|
290
|
-
export const parse = (data) => decode(utf8Encoder.encode(data))
|
|
291
|
-
const utf8Encoder = new TextEncoder()
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { garbage } from '@ipld/garbage'
|
|
3
|
-
import { assert } from 'aegir/chai'
|
|
4
|
-
import { bytes, CID } from 'multiformats'
|
|
5
|
-
import { base64 } from 'multiformats/bases/base64'
|
|
6
|
-
import { encode, decode, stringify, parse } from '../src/index.js'
|
|
7
|
-
|
|
8
|
-
const same = assert.deepStrictEqual
|
|
9
|
-
|
|
10
|
-
const recode = (/** @type {Uint8Array} */ byts) => encode(decode(byts))
|
|
11
|
-
|
|
12
|
-
const link = CID.parse('bafyreifepiu23okq5zuyvyhsoiazv2icw2van3s7ko6d3ixl5jx2yj2yhu')
|
|
13
|
-
|
|
14
|
-
describe('basic dag-json', () => {
|
|
15
|
-
it('encode decode', () => {
|
|
16
|
-
const byts = encode({ hello: 'world' })
|
|
17
|
-
same(JSON.parse(bytes.toString(recode(byts))), { hello: 'world' })
|
|
18
|
-
const o = { link, byts: bytes.fromString('asdf'), n: null, o: {} }
|
|
19
|
-
const byts2 = encode(o)
|
|
20
|
-
same(decode(byts2), o)
|
|
21
|
-
same(bytes.isBinary(decode(byts2).byts), true)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('encode decode 2', () => {
|
|
25
|
-
// mirrors a go-ipld-prime test, but with sorted keys
|
|
26
|
-
const obj = { plain: 'olde string', bytes: utf8Encode('deadbeef') }
|
|
27
|
-
const expected = '{"bytes":{"/":{"bytes":"ZGVhZGJlZWY"}},"plain":"olde string"}'
|
|
28
|
-
const byts = encode(obj)
|
|
29
|
-
same(JSON.parse(bytes.toString(recode(byts))), JSON.parse(expected))
|
|
30
|
-
same(bytes.toString(recode(byts)), expected)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('encode decode with ArrayBuffer', () => {
|
|
34
|
-
const byts = encode({ hello: 'world' })
|
|
35
|
-
same(JSON.parse(bytes.toString(recode(byts))), { hello: 'world' })
|
|
36
|
-
const o = { link, byts: bytes.fromString('asdf'), n: null, o: {} }
|
|
37
|
-
const byts2 = encode(o)
|
|
38
|
-
same(decode(byts2), o)
|
|
39
|
-
same(bytes.isBinary(decode(byts2).byts.buffer), true)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
describe('reserved space', () => {
|
|
43
|
-
it('allow alternative types', () => {
|
|
44
|
-
// wrong types
|
|
45
|
-
for (const obj of [true, false, null, 1, -1, 1.1, { blip: 'bop' }, ['foo']]) {
|
|
46
|
-
same(decode(encode({ '/': obj })), { '/': obj })
|
|
47
|
-
same(decode(encode({ '/': { bytes: obj } })), { '/': { bytes: obj } })
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('allow specials within reserved space', () => {
|
|
52
|
-
// can we put slash-objects within slashes?
|
|
53
|
-
same(decode(encode({ '/': bytes.fromString('asdf') })), { '/': bytes.fromString('asdf') })
|
|
54
|
-
same(new TextDecoder().decode(encode({ '/': bytes.fromString('asdf') })), '{"/":{"/":{"bytes":"YXNkZg"}}}')
|
|
55
|
-
same(decode(encode({ '/': link })), { '/': link })
|
|
56
|
-
same(new TextDecoder().decode(encode({ '/': link })), '{"/":{"/":"bafyreifepiu23okq5zuyvyhsoiazv2icw2van3s7ko6d3ixl5jx2yj2yhu"}}')
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('disallow extraneous tokens', () => {
|
|
60
|
-
// encode() shouldn't allow this but it currently does
|
|
61
|
-
// https://github.com/ipld/js-dag-json/issues/91 should change this test
|
|
62
|
-
// into two parts, encode and decode
|
|
63
|
-
assert.throws(() => decode(encode({ '/': link.toString(), x: 'bip' })))
|
|
64
|
-
assert.throws(() => decode(encode({ '/': { bytes: 'mS7ldeA', x: 'bip' } })))
|
|
65
|
-
assert.throws(() => decode(encode({ '/': { bytes: 'mS7ldeA' }, x: 'bip' })))
|
|
66
|
-
assert.throws(() => decode(encode({ '/': { bytes: 'mS7ldeA', x: 'bip' }, bop: 'bip' })))
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('native types', () => {
|
|
71
|
-
const flip = (/** @type {any} */ obj) => decode(encode(obj))
|
|
72
|
-
same(flip('test'), 'test')
|
|
73
|
-
same(flip(null), null)
|
|
74
|
-
same(flip(12), 12)
|
|
75
|
-
same(flip(-1), -1)
|
|
76
|
-
same(flip(1.2), 1.2)
|
|
77
|
-
same(flip(true), true)
|
|
78
|
-
same(flip(false), false)
|
|
79
|
-
same(flip([]), [])
|
|
80
|
-
same(flip(['asdf']), ['asdf'])
|
|
81
|
-
same(decode(utf8Encode('10.0')), 10)
|
|
82
|
-
same(decode(utf8Encode('[-10.0, 1.0, 0.0, 100.0]')), [-10, 1, 0, 100])
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('stable map key sorting', () => {
|
|
86
|
-
const s1 = bytes.toString(encode({ a: 1, b: 2, bb: 2.2, c: 3, c_: 3.3 }))
|
|
87
|
-
const s2 = bytes.toString(encode({ c_: 3.3, bb: 2.2, b: 2, c: 3, a: 1 }))
|
|
88
|
-
same('{"a":1,"b":2,"bb":2.2,"c":3,"c_":3.3}', s1)
|
|
89
|
-
same('{"a":1,"b":2,"bb":2.2,"c":3,"c_":3.3}', s2)
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('bigints', () => {
|
|
93
|
-
const verify = (/** @type {number | bigint} **/ inp) => {
|
|
94
|
-
assert.strictEqual(decode(utf8Encode(String(inp))), inp)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// plain Number objects
|
|
98
|
-
verify(0)
|
|
99
|
-
verify(1)
|
|
100
|
-
verify(-1)
|
|
101
|
-
verify(Math.pow(2, 50))
|
|
102
|
-
verify(-Math.pow(2, 50))
|
|
103
|
-
verify(Number.MAX_SAFE_INTEGER)
|
|
104
|
-
verify(-Number.MAX_SAFE_INTEGER)
|
|
105
|
-
// should round-trip as BigInts
|
|
106
|
-
verify(BigInt('9007199254740992')) // Number.MAX_SAFE_INTEGER+1
|
|
107
|
-
verify(BigInt('9007199254740993'))
|
|
108
|
-
verify(BigInt('11959030306112471731'))
|
|
109
|
-
verify(BigInt('18446744073709551615')) // max uint64
|
|
110
|
-
verify(BigInt('9223372036854775807')) // max int64
|
|
111
|
-
verify(BigInt('-9007199254740992'))
|
|
112
|
-
verify(BigInt('-9007199254740993'))
|
|
113
|
-
verify(BigInt('-9223372036854776000')) // min int64
|
|
114
|
-
verify(BigInt('-11959030306112471732'))
|
|
115
|
-
verify(BigInt('-18446744073709551616')) // min -uint64
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('error on circular references', () => {
|
|
119
|
-
const circularObj = {}
|
|
120
|
-
circularObj.a = circularObj
|
|
121
|
-
assert.throws(() => encode(circularObj), /object contains circular references/)
|
|
122
|
-
const circularArr = [circularObj]
|
|
123
|
-
circularObj.a = circularArr
|
|
124
|
-
assert.throws(() => encode(circularArr), /object contains circular references/)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it('error on encoding undefined', () => {
|
|
128
|
-
assert.throws(() => encode(undefined), /\Wundefined\W.*not supported/)
|
|
129
|
-
const objWithUndefined = { a: 'a', b: undefined }
|
|
130
|
-
assert.throws(() => encode(objWithUndefined), /\Wundefined\W.*not supported/)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('error on encoding IEEE 754 specials', () => {
|
|
134
|
-
for (const special of [NaN, Infinity, -Infinity]) {
|
|
135
|
-
assert.throws(() => encode(special), new RegExp(`\\W${String(special)}\\W.*not supported`))
|
|
136
|
-
const objWithSpecial = { a: 'a', b: special }
|
|
137
|
-
assert.throws(() => encode(objWithSpecial), new RegExp(`\\W${String(special)}\\W.*not supported`))
|
|
138
|
-
const arrWithSpecial = [1, 1.1, -1, -1.1, Number.MAX_SAFE_INTEGER, special, Number.MIN_SAFE_INTEGER]
|
|
139
|
-
assert.throws(() => encode(arrWithSpecial), new RegExp(`\\W${String(special)}\\W.*not supported`))
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
it('fuzz serialize and deserialize with garbage', function () {
|
|
144
|
-
// filter out fuzz garbage for objects that are disqualified by DAG-JSON rules
|
|
145
|
-
/** @type {(obj: any) => boolean} */
|
|
146
|
-
const checkObj = (obj) => {
|
|
147
|
-
if (Array.isArray(obj)) {
|
|
148
|
-
return obj.every(checkObj)
|
|
149
|
-
}
|
|
150
|
-
if (obj && typeof obj === 'object') {
|
|
151
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
152
|
-
if (key === '/') {
|
|
153
|
-
if (typeof value === 'string') {
|
|
154
|
-
return false
|
|
155
|
-
}
|
|
156
|
-
if (value && typeof value === 'object' && value.bytes !== undefined) {
|
|
157
|
-
return false
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (!checkObj(value)) {
|
|
161
|
-
return false
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return true
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this.timeout(5000)
|
|
169
|
-
for (let ii = 0; ii < 1000; ii++) {
|
|
170
|
-
const original = garbage(300)
|
|
171
|
-
if (!checkObj(original)) {
|
|
172
|
-
continue
|
|
173
|
-
}
|
|
174
|
-
const encoded = encode(original)
|
|
175
|
-
const decoded = decode(encoded)
|
|
176
|
-
same(decoded, original)
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
it('serialize', () => {
|
|
181
|
-
same(stringify({ hello: 'world' }), JSON.stringify({ hello: 'world' }))
|
|
182
|
-
|
|
183
|
-
const input = { link, bytes: bytes.fromString('asdf'), n: null, o: {} }
|
|
184
|
-
same(stringify(input), JSON.stringify({
|
|
185
|
-
bytes: { '/': { bytes: base64.baseEncode(input.bytes) } },
|
|
186
|
-
link: { '/': link.toString() },
|
|
187
|
-
n: null,
|
|
188
|
-
o: {}
|
|
189
|
-
}))
|
|
190
|
-
|
|
191
|
-
const output = parse(stringify(input))
|
|
192
|
-
same(input, output)
|
|
193
|
-
same(bytes.isBinary(output.bytes), true)
|
|
194
|
-
same(CID.asCID(output.link), output.link)
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
describe('typed arrays', () => {
|
|
198
|
-
// This mirrors what ships by default in dag-cbor: https://github.com/rvagg/cborg/blob/968fdac4af22c9b22fe5b40c2a6f9bb855780a4a/test/test-2bytes.js#L121
|
|
199
|
-
// It's an open question whether this should slip by without error or not,
|
|
200
|
-
// for now we silently convert them to plain bytes and they all round trip
|
|
201
|
-
// as Uint8Arrays.
|
|
202
|
-
const cases = /** @type {{obj: ArrayBufferView, expected: string}[]} */([
|
|
203
|
-
{
|
|
204
|
-
obj: Uint8Array.from([1, 2, 3]),
|
|
205
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
obj: Uint8ClampedArray.from([1, 2, 3]),
|
|
209
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
obj: Uint16Array.from([1, 2, 3]),
|
|
213
|
-
expected: '{"/":{"bytes":"AQACAAMA"}}'
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
obj: Uint32Array.from([1, 2, 3]),
|
|
217
|
-
expected: '{"/":{"bytes":"AQAAAAIAAAADAAAA"}}'
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
obj: Int8Array.from([1, 2, -3]),
|
|
221
|
-
expected: '{"/":{"bytes":"AQL9"}}'
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
obj: Int16Array.from([1, 2, -3]),
|
|
225
|
-
expected: '{"/":{"bytes":"AQACAP3/"}}'
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
obj: Int32Array.from([1, 2, -3]),
|
|
229
|
-
expected: '{"/":{"bytes":"AQAAAAIAAAD9////"}}'
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
obj: Float32Array.from([1, 2, -3]),
|
|
233
|
-
expected: '{"/":{"bytes":"AACAPwAAAEAAAEDA"}}'
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
obj: Float64Array.from([1, 2, -3]),
|
|
237
|
-
expected: '{"/":{"bytes":"AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAjA"}}'
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
obj: BigUint64Array.from([BigInt(1), BigInt(2), BigInt(3)]),
|
|
241
|
-
expected: '{"/":{"bytes":"AQAAAAAAAAACAAAAAAAAAAMAAAAAAAAA"}}'
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
obj: BigInt64Array.from([BigInt(1), BigInt(2), BigInt(-3)]),
|
|
245
|
-
expected: '{"/":{"bytes":"AQAAAAAAAAACAAAAAAAAAP3/////////"}}'
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
obj: new DataView(Uint8Array.from([1, 2, 3]).buffer),
|
|
249
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
obj: Uint8Array.from([1, 2, 3]).buffer,
|
|
253
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
254
|
-
}
|
|
255
|
-
])
|
|
256
|
-
|
|
257
|
-
for (const testCase of cases) {
|
|
258
|
-
it(testCase.obj.constructor.name, () => {
|
|
259
|
-
same(utf8Decode(encode(testCase.obj)), testCase.expected)
|
|
260
|
-
const decoded = decode(utf8Encode(testCase.expected))
|
|
261
|
-
assert.instanceOf(decoded, Uint8Array)
|
|
262
|
-
if (testCase.obj instanceof ArrayBuffer) {
|
|
263
|
-
same(decoded, new Uint8Array(testCase.obj))
|
|
264
|
-
} else {
|
|
265
|
-
same(decoded, new Uint8Array(testCase.obj.buffer, testCase.obj.byteOffset, testCase.obj.byteLength))
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
it('reject duplicate map keys', () => {
|
|
272
|
-
assert.throws(() => decode(utf8Encode('{"foo":1,"foo":2,"bar":3}')), /found repeat map key "foo"/)
|
|
273
|
-
})
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* @param {string} s
|
|
278
|
-
* @returns {Uint8Array}
|
|
279
|
-
*/
|
|
280
|
-
function utf8Encode (s) {
|
|
281
|
-
return new TextEncoder().encode(s)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @param {Uint8Array} b
|
|
286
|
-
* @returns {string}
|
|
287
|
-
*/
|
|
288
|
-
function utf8Decode (b) {
|
|
289
|
-
return new TextDecoder().decode(b)
|
|
290
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { deepStrictEqual } from 'assert'
|
|
2
|
-
|
|
3
|
-
import { BlockEncoder, BlockDecoder, BlockCodec } from 'multiformats/codecs/interface'
|
|
4
|
-
import * as dagJson from '@ipld/dag-json'
|
|
5
|
-
|
|
6
|
-
const main = () => {
|
|
7
|
-
// make sure we have a full CodecFeature
|
|
8
|
-
useCodecFeature(dagJson)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function useCodecFeature (codec: BlockCodec<297, any>) {
|
|
12
|
-
// use only as a BlockEncoder
|
|
13
|
-
useEncoder(codec)
|
|
14
|
-
|
|
15
|
-
// use only as a BlockDecoder
|
|
16
|
-
useDecoder(codec)
|
|
17
|
-
|
|
18
|
-
// use with ArrayBuffer input type
|
|
19
|
-
useDecoderWithArrayBuffer(codec)
|
|
20
|
-
|
|
21
|
-
// use as a full BlockCodec which does both BlockEncoder & BlockDecoder
|
|
22
|
-
useBlockCodec(codec)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function useEncoder<Codec extends number> (encoder: BlockEncoder<Codec, string>) {
|
|
26
|
-
deepStrictEqual(encoder.code, 297)
|
|
27
|
-
deepStrictEqual(encoder.name, 'dag-json')
|
|
28
|
-
deepStrictEqual(Array.from(encoder.encode('blip')), [34, 98, 108, 105, 112, 34])
|
|
29
|
-
console.log('[TS] ✓ { encoder: BlockEncoder }')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function useDecoder<Codec extends number> (decoder: BlockDecoder<Codec, Uint8Array>) {
|
|
33
|
-
deepStrictEqual(decoder.code, 297)
|
|
34
|
-
deepStrictEqual(decoder.decode(Uint8Array.from([34, 98, 108, 105, 112, 34 ])), 'blip')
|
|
35
|
-
console.log('[TS] ✓ { decoder: BlockDecoder }')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function useDecoderWithArrayBuffer<Codec extends number> (decoder: BlockDecoder<Codec, Uint8Array>) {
|
|
39
|
-
deepStrictEqual(decoder.code, 297)
|
|
40
|
-
deepStrictEqual(decoder.decode(Uint8Array.from([34, 98, 108, 105, 112, 34 ]).buffer), 'blip')
|
|
41
|
-
console.log('[TS] ✓ { decoder: BlockDecoder }')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function useBlockCodec<Codec extends number> (blockCodec: BlockCodec<Codec, string>) {
|
|
45
|
-
deepStrictEqual(blockCodec.code, 297)
|
|
46
|
-
deepStrictEqual(blockCodec.name, 'dag-json')
|
|
47
|
-
deepStrictEqual(Array.from(blockCodec.encode('blip')), [34, 98, 108, 105, 112, 34])
|
|
48
|
-
deepStrictEqual(blockCodec.decode(Uint8Array.from([34, 98, 108, 105, 112, 34])), 'blip')
|
|
49
|
-
console.log('[TS] ✓ {}:BlockCodec')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
main()
|
|
53
|
-
|
|
54
|
-
export default main
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
updates:
|
|
3
|
-
- package-ecosystem: 'github-actions'
|
|
4
|
-
directory: '/'
|
|
5
|
-
schedule:
|
|
6
|
-
interval: 'daily'
|
|
7
|
-
commit-message:
|
|
8
|
-
prefix: 'chore'
|
|
9
|
-
include: 'scope'
|
|
10
|
-
- package-ecosystem: 'npm'
|
|
11
|
-
directory: '/'
|
|
12
|
-
schedule:
|
|
13
|
-
interval: 'daily'
|
|
14
|
-
commit-message:
|
|
15
|
-
prefix: 'chore'
|
|
16
|
-
include: 'scope'
|