@fireproof/vendor 0.0.0-smoke → 1.0.1
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 +155 -8
- package/src/@ipld/car/{car/README.md → README.md} +229 -175
- package/src/@ipld/car/dist/src/reader.d.ts.map +1 -0
- package/src/@ipld/car/{car/src → src}/reader.js +19 -2
- package/src/cborg/cborg/{lib/bin.js → bin.js} +2 -2
- package/src/cborg/cborg/common.js +28 -0
- package/{patched/cborg/lib → src/cborg/cborg}/decode.js +24 -22
- package/src/cborg/cborg/{lib/diagnostic.js → diagnostic.js} +6 -4
- package/{patched/cborg/lib → src/cborg/cborg}/diagnostic_test.js +1 -1
- package/src/cborg/cborg/{lib/encode.js → encode.js} +23 -21
- package/{patched/cborg/cborg.js → src/cborg/cborg/index.js} +12 -10
- package/src/cborg/cborg/{lib/length.js → length.js} +3 -2
- package/{patched → src}/cborg/interface.ts +7 -4
- package/src/cborg/{cborg/lib/json → json}/decode.js +25 -25
- package/src/cborg/{cborg/lib/json → json}/encode.js +19 -16
- package/src/cborg/{cborg/package.json → package.json} +15 -11
- package/src/cborg/{cborg/taglib.js → taglib.js} +3 -1
- package/src/cborg/{cborg/test → test}/common.js +1 -1
- package/{patched → src}/cborg/test/noop-bin-test.js +1 -1
- package/{patched → src}/cborg/test/test-0uint.js +2 -2
- package/src/cborg/{cborg/test → test}/test-1negint.js +2 -2
- package/src/cborg/{cborg/test → test}/test-2bytes.js +2 -2
- package/src/cborg/{cborg/test → test}/test-3string.js +2 -2
- package/{patched → src}/cborg/test/test-4array.js +2 -2
- package/{patched → src}/cborg/test/test-5map.js +2 -2
- package/src/cborg/{cborg/test → test}/test-6tag.js +2 -3
- package/{patched → src}/cborg/test/test-7float.js +2 -2
- package/{patched → src}/cborg/test/test-bl.js +1 -1
- package/src/cborg/{cborg/test → test}/test-cbor-vectors.js +2 -2
- package/src/cborg/{cborg/test → test}/test-decode-errors.js +2 -2
- package/{patched → src}/cborg/test/test-fuzz.js +1 -1
- package/src/cborg/{cborg/test → test}/test-json.js +25 -25
- package/{patched → src}/cborg/test/test-length.js +3 -3
- package/src/cborg/{cborg/test → test}/test-partial.js +2 -2
- package/src/cborg/{cborg/tsconfig.json → tsconfig.json} +5 -2
- package/{patched/cborg/types/lib → src/cborg/types/cborg}/decode.d.ts +5 -3
- package/src/cborg/types/cborg/decode.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/cborg}/encode.d.ts +4 -3
- package/src/cborg/types/cborg/encode.d.ts.map +1 -0
- package/src/cborg/types/cborg/index.d.ts +26 -0
- package/src/cborg/types/cborg/index.d.ts.map +1 -0
- package/src/cborg/types/cborg/is.d.ts.map +1 -0
- package/src/cborg/{cborg/types → types}/interface.d.ts +6 -4
- package/src/cborg/types/interface.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types}/json/decode.d.ts +7 -7
- package/src/cborg/types/json/decode.d.ts.map +1 -0
- package/src/cborg/types/json/encode.d.ts +11 -0
- package/src/cborg/types/json/encode.d.ts.map +1 -0
- package/src/cborg/types/json/json.d.ts.map +1 -0
- package/{patched → src}/cborg/types/taglib.d.ts +1 -1
- package/{patched → src}/cborg/types/taglib.d.ts.map +1 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/0uint.d.ts +6 -4
- package/src/cborg/types/utils/0uint.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/1negint.d.ts +4 -3
- package/src/cborg/types/utils/1negint.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/2bytes.d.ts +5 -4
- package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/3string.d.ts +1 -1
- package/src/cborg/types/utils/3string.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/4array.d.ts +3 -2
- package/src/cborg/types/utils/4array.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/5map.d.ts +3 -2
- package/src/cborg/types/utils/5map.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/6tag.d.ts +4 -3
- package/src/cborg/types/utils/6tag.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/7float.d.ts +2 -2
- package/src/cborg/types/utils/7float.d.ts.map +1 -0
- package/src/cborg/types/utils/bl.d.ts.map +1 -0
- package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
- package/src/cborg/types/utils/common.d.ts +8 -0
- package/src/cborg/types/utils/common.d.ts.map +1 -0
- package/src/cborg/types/utils/index.d.ts +13 -0
- package/src/cborg/types/utils/index.d.ts.map +1 -0
- package/src/cborg/types/utils/jump.d.ts +16 -0
- package/src/cborg/types/utils/jump.d.ts.map +1 -0
- package/src/cborg/types/utils/token.d.ts.map +1 -0
- package/src/cborg/{cborg/lib → utils}/0uint.js +16 -14
- package/src/cborg/{cborg/lib → utils}/1negint.js +5 -5
- package/src/cborg/{cborg/lib → utils}/2bytes.js +16 -14
- package/src/cborg/{cborg/lib → utils}/3string.js +4 -4
- package/src/cborg/{cborg/lib → utils}/4array.js +7 -6
- package/{patched/cborg/lib → src/cborg/utils}/5map.js +6 -6
- package/{patched/cborg/lib → src/cborg/utils}/6tag.js +4 -3
- package/src/cborg/{cborg/lib → utils}/7float.js +23 -21
- package/{patched/cborg/lib → src/cborg/utils}/bl.js +1 -1
- package/src/cborg/utils/common.js +11 -0
- package/src/cborg/utils/index.js +12 -0
- package/src/cborg/utils/jump.js +222 -0
- 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/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/1negint.js +0 -111
- package/patched/cborg/lib/2bytes.js +0 -133
- package/patched/cborg/lib/3string.js +0 -90
- package/patched/cborg/lib/4array.js +0 -113
- package/patched/cborg/lib/7float.js +0 -308
- package/patched/cborg/lib/bin.js +0 -189
- package/patched/cborg/lib/common.js +0 -27
- package/patched/cborg/lib/diagnostic.js +0 -156
- package/patched/cborg/lib/encode.js +0 -464
- package/patched/cborg/lib/json/decode.js +0 -462
- package/patched/cborg/lib/json/encode.js +0 -299
- package/patched/cborg/lib/jump.js +0 -209
- package/patched/cborg/lib/length.js +0 -61
- package/patched/cborg/package.json +0 -169
- package/patched/cborg/pnpm-lock.yaml +0 -6096
- package/patched/cborg/taglib.js +0 -73
- package/patched/cborg/test/common.js +0 -18
- package/patched/cborg/test/test-1negint.js +0 -96
- package/patched/cborg/test/test-2bytes.js +0 -198
- package/patched/cborg/test/test-3string.js +0 -136
- package/patched/cborg/test/test-6tag.js +0 -85
- package/patched/cborg/test/test-cbor-vectors.js +0 -107
- package/patched/cborg/test/test-decode-errors.js +0 -65
- package/patched/cborg/test/test-json.js +0 -219
- package/patched/cborg/test/test-partial.js +0 -111
- package/patched/cborg/tsconfig.json +0 -45
- package/patched/cborg/types/cborg.d.ts +0 -28
- package/patched/cborg/types/cborg.d.ts.map +0 -1
- package/patched/cborg/types/interface.d.ts +0 -47
- package/patched/cborg/types/interface.d.ts.map +0 -1
- package/patched/cborg/types/lib/0uint.d.ts.map +0 -1
- package/patched/cborg/types/lib/1negint.d.ts.map +0 -1
- package/patched/cborg/types/lib/2bytes.d.ts +0 -68
- package/patched/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/patched/cborg/types/lib/3string.d.ts +0 -46
- package/patched/cborg/types/lib/3string.d.ts.map +0 -1
- package/patched/cborg/types/lib/4array.d.ts.map +0 -1
- package/patched/cborg/types/lib/5map.d.ts +0 -65
- package/patched/cborg/types/lib/5map.d.ts.map +0 -1
- package/patched/cborg/types/lib/6tag.d.ts.map +0 -1
- package/patched/cborg/types/lib/7float.d.ts +0 -60
- package/patched/cborg/types/lib/7float.d.ts.map +0 -1
- package/patched/cborg/types/lib/bin.d.ts +0 -4
- package/patched/cborg/types/lib/bin.d.ts.map +0 -1
- package/patched/cborg/types/lib/bl.d.ts.map +0 -1
- package/patched/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/patched/cborg/types/lib/common.d.ts +0 -10
- package/patched/cborg/types/lib/common.d.ts.map +0 -1
- package/patched/cborg/types/lib/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic.d.ts +0 -12
- package/patched/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/patched/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/patched/cborg/types/lib/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/is.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/encode.d.ts +0 -11
- package/patched/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/patched/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/json.d.ts.map +0 -1
- package/patched/cborg/types/lib/jump.d.ts +0 -12
- package/patched/cborg/types/lib/jump.d.ts.map +0 -1
- package/patched/cborg/types/lib/length.d.ts +0 -27
- package/patched/cborg/types/lib/length.d.ts.map +0 -1
- package/patched/cborg/types/lib/token.d.ts.map +0 -1
- package/patched/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/@ipld/car/car/dist/src/reader.d.ts.map +0 -1
- 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/5map.js +0 -113
- package/src/cborg/cborg/lib/6tag.js +0 -80
- 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_test.js +0 -117
- 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/token.js +0 -76
- package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
- 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-4array.js +0 -93
- package/src/cborg/cborg/test/test-5map.js +0 -284
- 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-fuzz.js +0 -42
- package/src/cborg/cborg/test/test-length.js +0 -65
- 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.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.map +0 -1
- 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.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.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/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/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}/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/.github/dependabot.yml +0 -0
- /package/{patched → src}/cborg/.github/workflows/test-and-release.yml +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/cborg/lib → src/cborg/cborg}/is.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/cborg/lib → src/cborg}/json/json.js +0 -0
- /package/{patched → src}/cborg/test/appendix_a.js +0 -0
- /package/{patched → src}/cborg/test/node-test-bin.js +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/cborg}/is.d.ts +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/cborg/types/lib → src/cborg/types}/json/json.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/bl.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/byte-utils.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/token.d.ts +0 -0
- /package/{patched/cborg/lib → src/cborg/utils}/byte-utils.js +0 -0
- /package/{patched/cborg/lib → src/cborg/utils}/token.js +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,308 +0,0 @@
|
|
|
1
|
-
// TODO: shift some of the bytes logic to bytes-utils so we can use Buffer
|
|
2
|
-
// where possible
|
|
3
|
-
|
|
4
|
-
import { Token, Type } from './token.js'
|
|
5
|
-
import { decodeErrPrefix } from './common.js'
|
|
6
|
-
import { encodeUint } from './0uint.js'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {import('./bl.js').Bl} Bl
|
|
10
|
-
* @typedef {import('../interface').DecodeOptions} DecodeOptions
|
|
11
|
-
* @typedef {import('../interface').EncodeOptions} EncodeOptions
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const MINOR_FALSE = 20
|
|
15
|
-
const MINOR_TRUE = 21
|
|
16
|
-
const MINOR_NULL = 22
|
|
17
|
-
const MINOR_UNDEFINED = 23
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {Uint8Array} _data
|
|
21
|
-
* @param {number} _pos
|
|
22
|
-
* @param {number} _minor
|
|
23
|
-
* @param {DecodeOptions} options
|
|
24
|
-
* @returns {Token}
|
|
25
|
-
*/
|
|
26
|
-
export function decodeUndefined (_data, _pos, _minor, options) {
|
|
27
|
-
if (options.allowUndefined === false) {
|
|
28
|
-
throw new Error(`${decodeErrPrefix} undefined values are not supported`)
|
|
29
|
-
} else if (options.coerceUndefinedToNull === true) {
|
|
30
|
-
return new Token(Type.null, null, 1)
|
|
31
|
-
}
|
|
32
|
-
return new Token(Type.undefined, undefined, 1)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param {Uint8Array} _data
|
|
37
|
-
* @param {number} _pos
|
|
38
|
-
* @param {number} _minor
|
|
39
|
-
* @param {DecodeOptions} options
|
|
40
|
-
* @returns {Token}
|
|
41
|
-
*/
|
|
42
|
-
export function decodeBreak (_data, _pos, _minor, options) {
|
|
43
|
-
if (options.allowIndefinite === false) {
|
|
44
|
-
throw new Error(`${decodeErrPrefix} indefinite length items not allowed`)
|
|
45
|
-
}
|
|
46
|
-
return new Token(Type.break, undefined, 1)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @param {number} value
|
|
51
|
-
* @param {number} bytes
|
|
52
|
-
* @param {DecodeOptions} options
|
|
53
|
-
* @returns {Token}
|
|
54
|
-
*/
|
|
55
|
-
function createToken (value, bytes, options) {
|
|
56
|
-
if (options) {
|
|
57
|
-
if (options.allowNaN === false && Number.isNaN(value)) {
|
|
58
|
-
throw new Error(`${decodeErrPrefix} NaN values are not supported`)
|
|
59
|
-
}
|
|
60
|
-
if (options.allowInfinity === false && (value === Infinity || value === -Infinity)) {
|
|
61
|
-
throw new Error(`${decodeErrPrefix} Infinity values are not supported`)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return new Token(Type.float, value, bytes)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @param {Uint8Array} data
|
|
69
|
-
* @param {number} pos
|
|
70
|
-
* @param {number} _minor
|
|
71
|
-
* @param {DecodeOptions} options
|
|
72
|
-
* @returns {Token}
|
|
73
|
-
*/
|
|
74
|
-
export function decodeFloat16 (data, pos, _minor, options) {
|
|
75
|
-
return createToken(readFloat16(data, pos + 1), 3, options)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @param {Uint8Array} data
|
|
80
|
-
* @param {number} pos
|
|
81
|
-
* @param {number} _minor
|
|
82
|
-
* @param {DecodeOptions} options
|
|
83
|
-
* @returns {Token}
|
|
84
|
-
*/
|
|
85
|
-
export function decodeFloat32 (data, pos, _minor, options) {
|
|
86
|
-
return createToken(readFloat32(data, pos + 1), 5, options)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @param {Uint8Array} data
|
|
91
|
-
* @param {number} pos
|
|
92
|
-
* @param {number} _minor
|
|
93
|
-
* @param {DecodeOptions} options
|
|
94
|
-
* @returns {Token}
|
|
95
|
-
*/
|
|
96
|
-
export function decodeFloat64 (data, pos, _minor, options) {
|
|
97
|
-
return createToken(readFloat64(data, pos + 1), 9, options)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @param {Bl} buf
|
|
102
|
-
* @param {Token} token
|
|
103
|
-
* @param {EncodeOptions} options
|
|
104
|
-
*/
|
|
105
|
-
export function encodeFloat (buf, token, options) {
|
|
106
|
-
const float = token.value
|
|
107
|
-
|
|
108
|
-
if (float === false) {
|
|
109
|
-
buf.push([Type.float.majorEncoded | MINOR_FALSE])
|
|
110
|
-
} else if (float === true) {
|
|
111
|
-
buf.push([Type.float.majorEncoded | MINOR_TRUE])
|
|
112
|
-
} else if (float === null) {
|
|
113
|
-
buf.push([Type.float.majorEncoded | MINOR_NULL])
|
|
114
|
-
} else if (float === undefined) {
|
|
115
|
-
buf.push([Type.float.majorEncoded | MINOR_UNDEFINED])
|
|
116
|
-
} else {
|
|
117
|
-
let decoded
|
|
118
|
-
let success = false
|
|
119
|
-
if (!options || options.float64 !== true) {
|
|
120
|
-
encodeFloat16(float)
|
|
121
|
-
decoded = readFloat16(ui8a, 1)
|
|
122
|
-
if (float === decoded || Number.isNaN(float)) {
|
|
123
|
-
ui8a[0] = 0xf9
|
|
124
|
-
buf.push(ui8a.slice(0, 3))
|
|
125
|
-
success = true
|
|
126
|
-
} else {
|
|
127
|
-
encodeFloat32(float)
|
|
128
|
-
decoded = readFloat32(ui8a, 1)
|
|
129
|
-
if (float === decoded) {
|
|
130
|
-
ui8a[0] = 0xfa
|
|
131
|
-
buf.push(ui8a.slice(0, 5))
|
|
132
|
-
success = true
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (!success) {
|
|
137
|
-
encodeFloat64(float)
|
|
138
|
-
decoded = readFloat64(ui8a, 1)
|
|
139
|
-
ui8a[0] = 0xfb
|
|
140
|
-
buf.push(ui8a.slice(0, 9))
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @param {Token} token
|
|
147
|
-
* @param {EncodeOptions} options
|
|
148
|
-
* @returns {number}
|
|
149
|
-
*/
|
|
150
|
-
encodeFloat.encodedSize = function encodedSize (token, options) {
|
|
151
|
-
const float = token.value
|
|
152
|
-
|
|
153
|
-
if (float === false || float === true || float === null || float === undefined) {
|
|
154
|
-
return 1
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (!options || options.float64 !== true) {
|
|
158
|
-
encodeFloat16(float)
|
|
159
|
-
let decoded = readFloat16(ui8a, 1)
|
|
160
|
-
if (float === decoded || Number.isNaN(float)) {
|
|
161
|
-
return 3
|
|
162
|
-
}
|
|
163
|
-
encodeFloat32(float)
|
|
164
|
-
decoded = readFloat32(ui8a, 1)
|
|
165
|
-
if (float === decoded) {
|
|
166
|
-
return 5
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return 9
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const buffer = new ArrayBuffer(9)
|
|
173
|
-
const dataView = new DataView(buffer, 1)
|
|
174
|
-
const ui8a = new Uint8Array(buffer, 0)
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* @param {number} inp
|
|
178
|
-
*/
|
|
179
|
-
function encodeFloat16 (inp) {
|
|
180
|
-
if (inp === Infinity) {
|
|
181
|
-
dataView.setUint16(0, 0x7c00, false)
|
|
182
|
-
} else if (inp === -Infinity) {
|
|
183
|
-
dataView.setUint16(0, 0xfc00, false)
|
|
184
|
-
} else if (Number.isNaN(inp)) {
|
|
185
|
-
dataView.setUint16(0, 0x7e00, false)
|
|
186
|
-
} else {
|
|
187
|
-
dataView.setFloat32(0, inp)
|
|
188
|
-
const valu32 = dataView.getUint32(0)
|
|
189
|
-
const exponent = (valu32 & 0x7f800000) >> 23
|
|
190
|
-
const mantissa = valu32 & 0x7fffff
|
|
191
|
-
|
|
192
|
-
/* c8 ignore next 6 */
|
|
193
|
-
if (exponent === 0xff) {
|
|
194
|
-
// too big, Infinity, but this should be hard (impossible?) to trigger
|
|
195
|
-
dataView.setUint16(0, 0x7c00, false)
|
|
196
|
-
} else if (exponent === 0x00) {
|
|
197
|
-
// 0.0, -0.0 and subnormals, shouldn't be possible to get here because 0.0 should be counted as an int
|
|
198
|
-
dataView.setUint16(0, ((inp & 0x80000000) >> 16) | (mantissa >> 13), false)
|
|
199
|
-
} else { // standard numbers
|
|
200
|
-
// chunks of logic here borrowed from https://github.com/PJK/libcbor/blob/c78f437182533e3efa8d963ff4b945bb635c2284/src/cbor/encoding.c#L127
|
|
201
|
-
const logicalExponent = exponent - 127
|
|
202
|
-
// Now we know that 2^exponent <= 0 logically
|
|
203
|
-
/* c8 ignore next 6 */
|
|
204
|
-
if (logicalExponent < -24) {
|
|
205
|
-
/* No unambiguous representation exists, this float is not a half float
|
|
206
|
-
and is too small to be represented using a half, round off to zero.
|
|
207
|
-
Consistent with the reference implementation. */
|
|
208
|
-
// should be difficult (impossible?) to get here in JS
|
|
209
|
-
dataView.setUint16(0, 0)
|
|
210
|
-
} else if (logicalExponent < -14) {
|
|
211
|
-
/* Offset the remaining decimal places by shifting the significand, the
|
|
212
|
-
value is lost. This is an implementation decision that works around the
|
|
213
|
-
absence of standard half-float in the language. */
|
|
214
|
-
dataView.setUint16(0, ((valu32 & 0x80000000) >> 16) | /* sign bit */ (1 << (24 + logicalExponent)), false)
|
|
215
|
-
} else {
|
|
216
|
-
dataView.setUint16(0, ((valu32 & 0x80000000) >> 16) | ((logicalExponent + 15) << 10) | (mantissa >> 13), false)
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @param {Uint8Array} ui8a
|
|
224
|
-
* @param {number} pos
|
|
225
|
-
* @returns {number}
|
|
226
|
-
*/
|
|
227
|
-
function readFloat16 (ui8a, pos) {
|
|
228
|
-
if (ui8a.length - pos < 2) {
|
|
229
|
-
throw new Error(`${decodeErrPrefix} not enough data for float16`)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const half = (ui8a[pos] << 8) + ui8a[pos + 1]
|
|
233
|
-
if (half === 0x7c00) {
|
|
234
|
-
return Infinity
|
|
235
|
-
}
|
|
236
|
-
if (half === 0xfc00) {
|
|
237
|
-
return -Infinity
|
|
238
|
-
}
|
|
239
|
-
if (half === 0x7e00) {
|
|
240
|
-
return NaN
|
|
241
|
-
}
|
|
242
|
-
const exp = (half >> 10) & 0x1f
|
|
243
|
-
const mant = half & 0x3ff
|
|
244
|
-
let val
|
|
245
|
-
if (exp === 0) {
|
|
246
|
-
val = mant * (2 ** -24)
|
|
247
|
-
} else if (exp !== 31) {
|
|
248
|
-
val = (mant + 1024) * (2 ** (exp - 25))
|
|
249
|
-
/* c8 ignore next 4 */
|
|
250
|
-
} else {
|
|
251
|
-
// may not be possible to get here
|
|
252
|
-
val = mant === 0 ? Infinity : NaN
|
|
253
|
-
}
|
|
254
|
-
return (half & 0x8000) ? -val : val
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @param {number} inp
|
|
259
|
-
*/
|
|
260
|
-
function encodeFloat32 (inp) {
|
|
261
|
-
dataView.setFloat32(0, inp, false)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* @param {Uint8Array} ui8a
|
|
266
|
-
* @param {number} pos
|
|
267
|
-
* @returns {number}
|
|
268
|
-
*/
|
|
269
|
-
function readFloat32 (ui8a, pos) {
|
|
270
|
-
if (ui8a.length - pos < 4) {
|
|
271
|
-
throw new Error(`${decodeErrPrefix} not enough data for float32`)
|
|
272
|
-
}
|
|
273
|
-
const offset = (ui8a.byteOffset || 0) + pos
|
|
274
|
-
return new DataView(ui8a.buffer, offset, 4).getFloat32(0, false)
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* @param {number} inp
|
|
279
|
-
*/
|
|
280
|
-
function encodeFloat64 (inp) {
|
|
281
|
-
dataView.setFloat64(0, inp, false)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @param {Uint8Array} ui8a
|
|
286
|
-
* @param {number} pos
|
|
287
|
-
* @returns {number}
|
|
288
|
-
*/
|
|
289
|
-
function readFloat64 (ui8a, pos) {
|
|
290
|
-
if (ui8a.length - pos < 8) {
|
|
291
|
-
throw new Error(`${decodeErrPrefix} not enough data for float64`)
|
|
292
|
-
}
|
|
293
|
-
const offset = (ui8a.byteOffset || 0) + pos
|
|
294
|
-
return new DataView(ui8a.buffer, offset, 8).getFloat64(0, false)
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* @param {Token} _tok1
|
|
299
|
-
* @param {Token} _tok2
|
|
300
|
-
* @returns {number}
|
|
301
|
-
*/
|
|
302
|
-
encodeFloat.compareTokens = encodeUint.compareTokens
|
|
303
|
-
/*
|
|
304
|
-
encodeFloat.compareTokens = function compareTokens (_tok1, _tok2) {
|
|
305
|
-
return _tok1
|
|
306
|
-
throw new Error(`${encodeErrPrefix} cannot use floats as map keys`)
|
|
307
|
-
}
|
|
308
|
-
*/
|
package/patched/cborg/lib/bin.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import process from 'process'
|
|
4
|
-
import { decode, encode } from '../cborg.js'
|
|
5
|
-
import { tokensToDiagnostic, fromDiag } from './diagnostic.js'
|
|
6
|
-
import { fromHex as _fromHex, toHex } from './byte-utils.js'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {number} code
|
|
10
|
-
*/
|
|
11
|
-
function usage (code) {
|
|
12
|
-
console.error('Usage: cborg <command> <args>')
|
|
13
|
-
console.error('Valid commands:')
|
|
14
|
-
console.error('\tbin2diag [--width <width>] [binary input]')
|
|
15
|
-
console.error('\tbin2hex [binary input]')
|
|
16
|
-
console.error('\tbin2json [--pretty] [binary input]')
|
|
17
|
-
console.error('\tdiag2bin [diagnostic input]')
|
|
18
|
-
console.error('\tdiag2hex [diagnostic input]')
|
|
19
|
-
console.error('\tdiag2json [--pretty] [diagnostic input]')
|
|
20
|
-
console.error('\thex2bin [hex input]')
|
|
21
|
-
console.error('\thex2diag [--width <width>] [hex input]')
|
|
22
|
-
console.error('\thex2json [--pretty] [hex input]')
|
|
23
|
-
console.error('\tjson2bin \'[json input]\'')
|
|
24
|
-
console.error('\tjson2diag [--width <width>] \'[json input]\'')
|
|
25
|
-
console.error('\tjson2hex \'[json input]\'')
|
|
26
|
-
console.error('Input may either be supplied as an argument or piped via stdin')
|
|
27
|
-
process.exit(code || 0)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function fromStdin () {
|
|
31
|
-
const chunks = []
|
|
32
|
-
for await (const chunk of process.stdin) {
|
|
33
|
-
chunks.push(chunk)
|
|
34
|
-
}
|
|
35
|
-
return Buffer.concat(chunks)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @param {string} str
|
|
40
|
-
* @returns {Uint8Array}
|
|
41
|
-
*/
|
|
42
|
-
function fromHex (str) {
|
|
43
|
-
str = str.replace(/\r?\n/g, '') // let's be charitable
|
|
44
|
-
/* c8 ignore next 3 */
|
|
45
|
-
if (!(/^([0-9a-f]{2})*$/i).test(str)) {
|
|
46
|
-
throw new Error('Input string is not hexadecimal format')
|
|
47
|
-
}
|
|
48
|
-
return _fromHex(str)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function argvPretty () {
|
|
52
|
-
const argv = process.argv.filter((s) => s !== '--pretty')
|
|
53
|
-
const pretty = argv.length !== process.argv.length
|
|
54
|
-
return { argv, pretty }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function argvWidth () {
|
|
58
|
-
const widthIndex = process.argv.findIndex((s) => s === '--width')
|
|
59
|
-
if (widthIndex <= 0 || widthIndex + 1 >= process.argv.length) {
|
|
60
|
-
return { argv: process.argv.filter((s) => s !== '--width'), width: undefined }
|
|
61
|
-
}
|
|
62
|
-
const width = parseInt(process.argv[widthIndex + 1], 10)
|
|
63
|
-
if (!width || width < 20) {
|
|
64
|
-
return { argv: process.argv.filter((s) => s !== '--width'), width: undefined }
|
|
65
|
-
}
|
|
66
|
-
const argv = process.argv
|
|
67
|
-
argv.splice(widthIndex, 2)
|
|
68
|
-
return { argv, width }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async function run () {
|
|
72
|
-
const cmd = process.argv[2]
|
|
73
|
-
|
|
74
|
-
switch (cmd) {
|
|
75
|
-
case 'help': {
|
|
76
|
-
return usage(0)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
case 'bin2diag': {
|
|
80
|
-
/* c8 ignore next 1 */
|
|
81
|
-
const { argv, width } = argvWidth()
|
|
82
|
-
const bin = argv.length < 4 ? (await fromStdin()) : new TextEncoder().encode(argv[3])
|
|
83
|
-
for (const line of tokensToDiagnostic(bin, width)) {
|
|
84
|
-
console.log(line)
|
|
85
|
-
}
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
case 'bin2hex': {
|
|
90
|
-
// this is really nothing to do with cbor.. just handy
|
|
91
|
-
/* c8 ignore next 1 */
|
|
92
|
-
const bin = process.argv.length < 4 ? (await fromStdin()) : new TextEncoder().encode(process.argv[3])
|
|
93
|
-
return console.log(toHex(bin))
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
case 'bin2json': {
|
|
97
|
-
const { argv, pretty } = argvPretty()
|
|
98
|
-
/* c8 ignore next 1 */
|
|
99
|
-
const bin = argv.length < 4 ? (await fromStdin()) : new TextEncoder().encode(argv[3])
|
|
100
|
-
return console.log(JSON.stringify(decode(bin), undefined, pretty ? 2 : undefined))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
case 'diag2bin': {
|
|
104
|
-
// no coverage on windows for non-stdin input
|
|
105
|
-
/* c8 ignore next 1 */
|
|
106
|
-
const bin = fromDiag(process.argv.length < 4 ? (await fromStdin()).toString() : process.argv[3])
|
|
107
|
-
return process.stdout.write(bin)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
case 'diag2hex': {
|
|
111
|
-
// no coverage on windows for non-stdin input
|
|
112
|
-
/* c8 ignore next 1 */
|
|
113
|
-
const bin = fromDiag(process.argv.length < 4 ? (await fromStdin()).toString() : process.argv[3])
|
|
114
|
-
return console.log(toHex(bin))
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
case 'diag2json': {
|
|
118
|
-
const { argv, pretty } = argvPretty()
|
|
119
|
-
// no coverage on windows for non-stdin input
|
|
120
|
-
/* c8 ignore next 1 */
|
|
121
|
-
const bin = fromDiag(argv.length < 4 ? (await fromStdin()).toString() : argv[3])
|
|
122
|
-
return console.log(JSON.stringify(decode(bin), undefined, pretty ? 2 : undefined))
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
case 'hex2bin': {
|
|
126
|
-
// this is really nothing to do with cbor.. just handy
|
|
127
|
-
const bin = fromHex(process.argv.length < 4 ? (await fromStdin()).toString() : process.argv[3])
|
|
128
|
-
return process.stdout.write(bin)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
case 'hex2diag': {
|
|
132
|
-
const { argv, width } = argvWidth()
|
|
133
|
-
const bin = fromHex(argv.length < 4 ? (await fromStdin()).toString() : argv[3])
|
|
134
|
-
for (const line of tokensToDiagnostic(bin, width)) {
|
|
135
|
-
console.log(line)
|
|
136
|
-
}
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
case 'hex2json': {
|
|
141
|
-
const { argv, pretty } = argvPretty()
|
|
142
|
-
const bin = fromHex(argv.length < 4 ? (await fromStdin()).toString() : argv[3])
|
|
143
|
-
return console.log(JSON.stringify(decode(bin), undefined, pretty ? 2 : undefined))
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
case 'json2bin': {
|
|
147
|
-
const inp = process.argv.length < 4 ? (await fromStdin()).toString() : process.argv[3]
|
|
148
|
-
const obj = JSON.parse(inp)
|
|
149
|
-
return process.stdout.write(encode(obj))
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
case 'json2diag': {
|
|
153
|
-
const { argv, width } = argvWidth()
|
|
154
|
-
const inp = argv.length < 4 ? (await fromStdin()).toString() : argv[3]
|
|
155
|
-
const obj = JSON.parse(inp)
|
|
156
|
-
for (const line of tokensToDiagnostic(encode(obj), width)) {
|
|
157
|
-
console.log(line)
|
|
158
|
-
}
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
case 'json2hex': {
|
|
163
|
-
const inp = process.argv.length < 4 ? (await fromStdin()).toString() : process.argv[3]
|
|
164
|
-
const obj = JSON.parse(inp)
|
|
165
|
-
return console.log(toHex(encode(obj)))
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
default: { // no, or unknown cmd
|
|
169
|
-
// this is a dirty hack to allow import of this package by the tests
|
|
170
|
-
// for inclusion in ipjs bundling, but to silently ignore it so we don't
|
|
171
|
-
// print usage and exit(1).
|
|
172
|
-
if (process.argv.findIndex((a) => a.endsWith('mocha')) === -1) {
|
|
173
|
-
if (cmd) {
|
|
174
|
-
console.error(`Unknown command: '${cmd}'`)
|
|
175
|
-
}
|
|
176
|
-
usage(1)
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
run().catch((err) => {
|
|
183
|
-
/* c8 ignore next 2 */
|
|
184
|
-
console.error(err)
|
|
185
|
-
process.exit(1)
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
// for ipjs, to get it to compile
|
|
189
|
-
export default true
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const decodeErrPrefix = 'CBOR decode error:'
|
|
2
|
-
const encodeErrPrefix = 'CBOR encode error:'
|
|
3
|
-
|
|
4
|
-
const uintMinorPrefixBytes = []
|
|
5
|
-
uintMinorPrefixBytes[23] = 1
|
|
6
|
-
uintMinorPrefixBytes[24] = 2
|
|
7
|
-
uintMinorPrefixBytes[25] = 3
|
|
8
|
-
uintMinorPrefixBytes[26] = 5
|
|
9
|
-
uintMinorPrefixBytes[27] = 9
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {Uint8Array} data
|
|
13
|
-
* @param {number} pos
|
|
14
|
-
* @param {number} need
|
|
15
|
-
*/
|
|
16
|
-
function assertEnoughData (data, pos, need) {
|
|
17
|
-
if (data.length - pos < need) {
|
|
18
|
-
throw new Error(`${decodeErrPrefix} not enough data for type`)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
decodeErrPrefix,
|
|
24
|
-
encodeErrPrefix,
|
|
25
|
-
uintMinorPrefixBytes,
|
|
26
|
-
assertEnoughData
|
|
27
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { Tokeniser } from './decode.js'
|
|
2
|
-
import { Type } from './token.js'
|
|
3
|
-
import { toHex, fromHex } from './byte-utils.js'
|
|
4
|
-
import { uintBoundaries } from './0uint.js'
|
|
5
|
-
|
|
6
|
-
const utf8Encoder = new TextEncoder()
|
|
7
|
-
const utf8Decoder = new TextDecoder()
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @param {Uint8Array} inp
|
|
11
|
-
* @param {number} [width]
|
|
12
|
-
*/
|
|
13
|
-
function * tokensToDiagnostic (inp, width = 100) {
|
|
14
|
-
const tokeniser = new Tokeniser(inp, { retainStringBytes: true, allowBigInt: true })
|
|
15
|
-
let pos = 0
|
|
16
|
-
const indent = []
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {number} start
|
|
20
|
-
* @param {number} length
|
|
21
|
-
* @returns {string}
|
|
22
|
-
*/
|
|
23
|
-
const slc = (start, length) => {
|
|
24
|
-
return toHex(inp.slice(pos + start, pos + start + length))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
while (!tokeniser.done()) {
|
|
28
|
-
const token = tokeniser.next()
|
|
29
|
-
let margin = ''.padStart(indent.length * 2, ' ')
|
|
30
|
-
// @ts-ignore should be safe for decode
|
|
31
|
-
let vLength = token.encodedLength - 1
|
|
32
|
-
/** @type {string|number} */
|
|
33
|
-
let v = String(token.value)
|
|
34
|
-
let outp = `${margin}${slc(0, 1)}`
|
|
35
|
-
const str = token.type.equals(Type.bytes) || token.type.equals(Type.string)
|
|
36
|
-
if (token.type.equals(Type.string)) {
|
|
37
|
-
v = v.length
|
|
38
|
-
vLength -= v
|
|
39
|
-
} else if (token.type.equals(Type.bytes)) {
|
|
40
|
-
v = token.value.length
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
vLength -= v
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let multilen
|
|
46
|
-
switch (token.type.name) {
|
|
47
|
-
case Type.string.name:
|
|
48
|
-
case Type.bytes.name:
|
|
49
|
-
case Type.map.name:
|
|
50
|
-
case Type.array.name:
|
|
51
|
-
// for bytes and string, we want to print out the length part of the value prefix if it
|
|
52
|
-
// exists - it exists for short lengths (<24) but does for longer lengths
|
|
53
|
-
multilen = token.type.equals(Type.string) ? utf8Encoder.encode(token.value).length : token.value.length
|
|
54
|
-
if (multilen >= uintBoundaries[0]) {
|
|
55
|
-
if (multilen < uintBoundaries[1]) {
|
|
56
|
-
outp += ` ${slc(1, 1)}`
|
|
57
|
-
} else if (multilen < uintBoundaries[2]) {
|
|
58
|
-
outp += ` ${slc(1, 2)}`
|
|
59
|
-
/* c8 ignore next 5 */
|
|
60
|
-
} else if (multilen < uintBoundaries[3]) { // sus
|
|
61
|
-
outp += ` ${slc(1, 4)}`
|
|
62
|
-
} else if (multilen < uintBoundaries[4]) { // orly?
|
|
63
|
-
outp += ` ${slc(1, 8)}`
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
break
|
|
67
|
-
default:
|
|
68
|
-
// print the value if it's not compacted into the first byte
|
|
69
|
-
outp += ` ${slc(1, vLength)}`
|
|
70
|
-
break
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
outp = outp.padEnd(width / 2, ' ')
|
|
74
|
-
outp += `# ${margin}${token.type.name}`
|
|
75
|
-
// there should be a method to get a Type from a String
|
|
76
|
-
if (token.type.name !== v) {
|
|
77
|
-
outp += `(${v})`
|
|
78
|
-
}
|
|
79
|
-
yield outp
|
|
80
|
-
|
|
81
|
-
if (str) {
|
|
82
|
-
let asString = token.type.equals(Type.string)
|
|
83
|
-
margin += ' '
|
|
84
|
-
let repr = asString ? utf8Encoder.encode(token.value) : token.value
|
|
85
|
-
if (asString && token.byteValue !== undefined) {
|
|
86
|
-
if (repr.length !== token.byteValue.length) {
|
|
87
|
-
// bail on printing this as a string, it's probably not utf8, so treat it as bytes
|
|
88
|
-
// (you can probably blame a Go programmer for this)
|
|
89
|
-
repr = token.byteValue
|
|
90
|
-
asString = false
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const wh = ((width / 2) - margin.length - 1) / 2
|
|
94
|
-
let snip = 0
|
|
95
|
-
while (repr.length - snip > 0) {
|
|
96
|
-
const piece = repr.slice(snip, snip + wh)
|
|
97
|
-
snip += piece.length
|
|
98
|
-
const st = asString
|
|
99
|
-
? utf8Decoder.decode(piece)
|
|
100
|
-
: piece.reduce((/** @type {string} */ p, /** @type {number} */ c) => {
|
|
101
|
-
if (c < 0x20 || (c >= 0x7f && c < 0xa1) || c === 0xad) {
|
|
102
|
-
return `${p}\\x${c.toString(16).padStart(2, '0')}`
|
|
103
|
-
}
|
|
104
|
-
return `${p}${String.fromCharCode(c)}`
|
|
105
|
-
}, '')
|
|
106
|
-
yield `${margin}${toHex(piece)}`.padEnd(width / 2, ' ') + `# ${margin}"${st}"`
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (indent.length) {
|
|
111
|
-
indent[indent.length - 1]--
|
|
112
|
-
}
|
|
113
|
-
if (!token.type.terminal) {
|
|
114
|
-
switch (token.type.name) {
|
|
115
|
-
case Type.map.name:
|
|
116
|
-
indent.push(token.value * 2)
|
|
117
|
-
break
|
|
118
|
-
case Type.array.name:
|
|
119
|
-
indent.push(token.value)
|
|
120
|
-
break
|
|
121
|
-
// TODO: test tags .. somehow
|
|
122
|
-
/* c8 ignore next 5 */
|
|
123
|
-
case Type.tag.name:
|
|
124
|
-
indent.push(1)
|
|
125
|
-
break
|
|
126
|
-
default:
|
|
127
|
-
throw new Error(`Unknown token type '${token.type.name}'`)
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
while (indent.length && indent[indent.length - 1] <= 0) {
|
|
131
|
-
indent.pop()
|
|
132
|
-
}
|
|
133
|
-
// @ts-ignore it should be set on a decode operation
|
|
134
|
-
pos += token.encodedLength
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Convert an input string formatted as CBOR diagnostic output into binary CBOR form.
|
|
140
|
-
* @param {string} input
|
|
141
|
-
* @returns {Uint8Array}
|
|
142
|
-
*/
|
|
143
|
-
function fromDiag (input) {
|
|
144
|
-
/* c8 ignore next 3 */
|
|
145
|
-
if (typeof input !== 'string') {
|
|
146
|
-
throw new TypeError('Expected string input')
|
|
147
|
-
}
|
|
148
|
-
input = input.replace(/#.*?$/mg, '').replace(/[\s\r\n]+/mg, '')
|
|
149
|
-
/* c8 ignore next 3 */
|
|
150
|
-
if (/[^a-f0-9]/i.test(input)) {
|
|
151
|
-
throw new TypeError('Input string was not CBOR diagnostic format')
|
|
152
|
-
}
|
|
153
|
-
return fromHex(input)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export { tokensToDiagnostic, fromDiag }
|