@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.
Files changed (480) hide show
  1. package/package.json +150 -7
  2. package/patched/@ipld/dag-json/.github/dependabot.yml +0 -11
  3. package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +0 -28
  4. package/patched/@ipld/dag-json/CHANGELOG.md +0 -202
  5. package/patched/@ipld/dag-json/LICENSE-APACHE +0 -5
  6. package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
  7. package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
  8. package/patched/@ipld/dag-json/src/index.js +0 -291
  9. package/patched/@ipld/dag-json/test/test-basics.spec.js +0 -290
  10. package/patched/@ipld/dag-json/test/ts-use/package.json +0 -11
  11. package/patched/@ipld/dag-json/test/ts-use/src/main.ts +0 -54
  12. package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +0 -9
  13. package/patched/@ipld/dag-json/tsconfig.json +0 -14
  14. package/patched/cborg/.github/dependabot.yml +0 -16
  15. package/patched/cborg/.github/workflows/test-and-release.yml +0 -52
  16. package/patched/cborg/cborg-4.2.7.tgz +0 -0
  17. package/patched/cborg/example-json.js +0 -6
  18. package/patched/cborg/example.js +0 -5
  19. package/patched/cborg/lib/0uint.js +0 -227
  20. package/patched/cborg/lib/json/decode.js +0 -462
  21. package/patched/cborg/lib/json/encode.js +0 -299
  22. package/patched/cborg/package.json +0 -169
  23. package/patched/cborg/pnpm-lock.yaml +0 -6096
  24. package/patched/cborg/test/common.js +0 -18
  25. package/patched/cborg/test/test-cbor-vectors.js +0 -107
  26. package/patched/cborg/test/test-json.js +0 -219
  27. package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
  28. package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
  29. package/src/@ipld/dag-json/dag-json/README.md +0 -58
  30. package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +0 -17
  31. package/src/@ipld/dag-json/dag-json/package.json +0 -173
  32. package/src/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
  33. package/src/cborg/cborg/.github/dependabot.yml +0 -16
  34. package/src/cborg/cborg/.github/workflows/test-and-release.yml +0 -52
  35. package/src/cborg/cborg/CHANGELOG.md +0 -513
  36. package/src/cborg/cborg/LICENSE +0 -13
  37. package/src/cborg/cborg/README.md +0 -515
  38. package/src/cborg/cborg/bench/bench.js +0 -117
  39. package/src/cborg/cborg/bench/json.js +0 -124
  40. package/src/cborg/cborg/bench/package.json +0 -8
  41. package/src/cborg/cborg/cborg.js +0 -31
  42. package/src/cborg/cborg/example-bytestrings.js +0 -180
  43. package/src/cborg/cborg/interface.ts +0 -56
  44. package/src/cborg/cborg/lib/1negint.js +0 -111
  45. package/src/cborg/cborg/lib/2bytes.js +0 -133
  46. package/src/cborg/cborg/lib/3string.js +0 -90
  47. package/src/cborg/cborg/lib/4array.js +0 -113
  48. package/src/cborg/cborg/lib/5map.js +0 -113
  49. package/src/cborg/cborg/lib/6tag.js +0 -80
  50. package/src/cborg/cborg/lib/7float.js +0 -308
  51. package/src/cborg/cborg/lib/bin.js +0 -189
  52. package/src/cborg/cborg/lib/bl.js +0 -124
  53. package/src/cborg/cborg/lib/byte-utils.js +0 -417
  54. package/src/cborg/cborg/lib/common.js +0 -27
  55. package/src/cborg/cborg/lib/decode.js +0 -209
  56. package/src/cborg/cborg/lib/diagnostic.js +0 -156
  57. package/src/cborg/cborg/lib/diagnostic_test.js +0 -117
  58. package/src/cborg/cborg/lib/encode.js +0 -464
  59. package/src/cborg/cborg/lib/is.js +0 -106
  60. package/src/cborg/cborg/lib/json/json.js +0 -4
  61. package/src/cborg/cborg/lib/jump.js +0 -209
  62. package/src/cborg/cborg/lib/length.js +0 -61
  63. package/src/cborg/cborg/lib/token.js +0 -76
  64. package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
  65. package/src/cborg/cborg/taglib.js +0 -73
  66. package/src/cborg/cborg/test/appendix_a.js +0 -647
  67. package/src/cborg/cborg/test/node-test-bin.js +0 -402
  68. package/src/cborg/cborg/test/noop-bin-test.js +0 -3
  69. package/src/cborg/cborg/test/test-0uint.js +0 -103
  70. package/src/cborg/cborg/test/test-1negint.js +0 -96
  71. package/src/cborg/cborg/test/test-2bytes.js +0 -198
  72. package/src/cborg/cborg/test/test-3string.js +0 -136
  73. package/src/cborg/cborg/test/test-4array.js +0 -93
  74. package/src/cborg/cborg/test/test-5map.js +0 -284
  75. package/src/cborg/cborg/test/test-6tag.js +0 -85
  76. package/src/cborg/cborg/test/test-7float.js +0 -131
  77. package/src/cborg/cborg/test/test-bl.js +0 -37
  78. package/src/cborg/cborg/test/test-decode-errors.js +0 -65
  79. package/src/cborg/cborg/test/test-fuzz.js +0 -42
  80. package/src/cborg/cborg/test/test-length.js +0 -65
  81. package/src/cborg/cborg/test/test-partial.js +0 -111
  82. package/src/cborg/cborg/tsconfig.json +0 -45
  83. package/src/cborg/cborg/types/cborg.d.ts +0 -28
  84. package/src/cborg/cborg/types/cborg.d.ts.map +0 -1
  85. package/src/cborg/cborg/types/example.d.ts +0 -2
  86. package/src/cborg/cborg/types/example.d.ts.map +0 -1
  87. package/src/cborg/cborg/types/interface.d.ts +0 -47
  88. package/src/cborg/cborg/types/interface.d.ts.map +0 -1
  89. package/src/cborg/cborg/types/lib/0uint.d.ts +0 -100
  90. package/src/cborg/cborg/types/lib/0uint.d.ts.map +0 -1
  91. package/src/cborg/cborg/types/lib/1negint.d.ts +0 -58
  92. package/src/cborg/cborg/types/lib/1negint.d.ts.map +0 -1
  93. package/src/cborg/cborg/types/lib/2bytes.d.ts +0 -68
  94. package/src/cborg/cborg/types/lib/2bytes.d.ts.map +0 -1
  95. package/src/cborg/cborg/types/lib/3string.d.ts +0 -46
  96. package/src/cborg/cborg/types/lib/3string.d.ts.map +0 -1
  97. package/src/cborg/cborg/types/lib/4array.d.ts +0 -65
  98. package/src/cborg/cborg/types/lib/4array.d.ts.map +0 -1
  99. package/src/cborg/cborg/types/lib/5map.d.ts +0 -65
  100. package/src/cborg/cborg/types/lib/5map.d.ts.map +0 -1
  101. package/src/cborg/cborg/types/lib/6tag.d.ts +0 -61
  102. package/src/cborg/cborg/types/lib/6tag.d.ts.map +0 -1
  103. package/src/cborg/cborg/types/lib/7float.d.ts +0 -60
  104. package/src/cborg/cborg/types/lib/7float.d.ts.map +0 -1
  105. package/src/cborg/cborg/types/lib/bin.d.ts +0 -4
  106. package/src/cborg/cborg/types/lib/bin.d.ts.map +0 -1
  107. package/src/cborg/cborg/types/lib/bl.d.ts +0 -26
  108. package/src/cborg/cborg/types/lib/bl.d.ts.map +0 -1
  109. package/src/cborg/cborg/types/lib/byte-utils.d.ts +0 -53
  110. package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +0 -1
  111. package/src/cborg/cborg/types/lib/common.d.ts +0 -10
  112. package/src/cborg/cborg/types/lib/common.d.ts.map +0 -1
  113. package/src/cborg/cborg/types/lib/decode.d.ts +0 -41
  114. package/src/cborg/cborg/types/lib/decode.d.ts.map +0 -1
  115. package/src/cborg/cborg/types/lib/diagnostic.d.ts +0 -12
  116. package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +0 -1
  117. package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +0 -2
  118. package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
  119. package/src/cborg/cborg/types/lib/encode.d.ts +0 -50
  120. package/src/cborg/cborg/types/lib/encode.d.ts.map +0 -1
  121. package/src/cborg/cborg/types/lib/is.d.ts +0 -6
  122. package/src/cborg/cborg/types/lib/is.d.ts.map +0 -1
  123. package/src/cborg/cborg/types/lib/json/decode.d.ts +0 -67
  124. package/src/cborg/cborg/types/lib/json/decode.d.ts.map +0 -1
  125. package/src/cborg/cborg/types/lib/json/encode.d.ts +0 -11
  126. package/src/cborg/cborg/types/lib/json/encode.d.ts.map +0 -1
  127. package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +0 -6
  128. package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
  129. package/src/cborg/cborg/types/lib/json/json.d.ts +0 -6
  130. package/src/cborg/cborg/types/lib/json/json.d.ts.map +0 -1
  131. package/src/cborg/cborg/types/lib/jump.d.ts +0 -12
  132. package/src/cborg/cborg/types/lib/jump.d.ts.map +0 -1
  133. package/src/cborg/cborg/types/lib/length.d.ts +0 -27
  134. package/src/cborg/cborg/types/lib/length.d.ts.map +0 -1
  135. package/src/cborg/cborg/types/lib/token.d.ts +0 -59
  136. package/src/cborg/cborg/types/lib/token.d.ts.map +0 -1
  137. package/src/cborg/cborg/types/taglib.d.ts +0 -18
  138. package/src/cborg/cborg/types/taglib.d.ts.map +0 -1
  139. package/src/cborg/cborg/types/tsconfig.tsbuildinfo +0 -1
  140. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +0 -4
  141. /package/{patched/@ipld/dag-json → src/@ipld/car}/LICENSE +0 -0
  142. /package/src/@ipld/car/{car/README.md → README.md} +0 -0
  143. /package/src/@ipld/car/{car/dist → dist}/index.min.js +0 -0
  144. /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts +0 -0
  145. /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts.map +0 -0
  146. /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts +0 -0
  147. /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts.map +0 -0
  148. /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts +0 -0
  149. /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts.map +0 -0
  150. /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts +0 -0
  151. /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts.map +0 -0
  152. /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts +0 -0
  153. /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts.map +0 -0
  154. /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts +0 -0
  155. /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts.map +0 -0
  156. /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts +0 -0
  157. /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts.map +0 -0
  158. /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts +0 -0
  159. /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts.map +0 -0
  160. /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts +0 -0
  161. /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts.map +0 -0
  162. /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts +0 -0
  163. /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts.map +0 -0
  164. /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts +0 -0
  165. /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts.map +0 -0
  166. /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts +0 -0
  167. /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts.map +0 -0
  168. /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts +0 -0
  169. /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts.map +0 -0
  170. /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts +0 -0
  171. /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts.map +0 -0
  172. /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts +0 -0
  173. /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts.map +0 -0
  174. /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts +0 -0
  175. /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts.map +0 -0
  176. /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts +0 -0
  177. /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts.map +0 -0
  178. /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts +0 -0
  179. /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts.map +0 -0
  180. /package/src/@ipld/car/{car/dist → dist}/src/reader.d.ts +0 -0
  181. /package/src/@ipld/car/{car/dist → dist}/src/reader.d.ts.map +0 -0
  182. /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts +0 -0
  183. /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts.map +0 -0
  184. /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts +0 -0
  185. /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts.map +0 -0
  186. /package/src/@ipld/car/{car/package.json → package.json} +0 -0
  187. /package/src/@ipld/car/{car/src → src}/api.ts +0 -0
  188. /package/src/@ipld/car/{car/src → src}/buffer-decoder.js +0 -0
  189. /package/src/@ipld/car/{car/src → src}/buffer-reader-browser.js +0 -0
  190. /package/src/@ipld/car/{car/src → src}/buffer-reader.js +0 -0
  191. /package/src/@ipld/car/{car/src → src}/buffer-writer.js +0 -0
  192. /package/src/@ipld/car/{car/src → src}/coding.ts +0 -0
  193. /package/src/@ipld/car/{car/src → src}/decoder-common.js +0 -0
  194. /package/src/@ipld/car/{car/src → src}/decoder.js +0 -0
  195. /package/src/@ipld/car/{car/src → src}/encoder.js +0 -0
  196. /package/src/@ipld/car/{car/src → src}/header-validator.js +0 -0
  197. /package/src/@ipld/car/{car/src → src}/header.ipldsch +0 -0
  198. /package/src/@ipld/car/{car/src → src}/index-browser.js +0 -0
  199. /package/src/@ipld/car/{car/src → src}/index.js +0 -0
  200. /package/src/@ipld/car/{car/src → src}/indexed-reader-browser.js +0 -0
  201. /package/src/@ipld/car/{car/src → src}/indexed-reader.js +0 -0
  202. /package/src/@ipld/car/{car/src → src}/indexer.js +0 -0
  203. /package/src/@ipld/car/{car/src → src}/iterator-channel.js +0 -0
  204. /package/src/@ipld/car/{car/src → src}/iterator.js +0 -0
  205. /package/src/@ipld/car/{car/src → src}/reader-browser.js +0 -0
  206. /package/src/@ipld/car/{car/src → src}/reader.js +0 -0
  207. /package/src/@ipld/car/{car/src → src}/writer-browser.js +0 -0
  208. /package/src/@ipld/car/{car/src → src}/writer.js +0 -0
  209. /package/src/@ipld/{car/car → dag-cbor}/LICENSE +0 -0
  210. /package/src/@ipld/dag-cbor/{dag-cbor/README.md → README.md} +0 -0
  211. /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/index.min.js +0 -0
  212. /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts +0 -0
  213. /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts.map +0 -0
  214. /package/src/@ipld/dag-cbor/{dag-cbor/package.json → package.json} +0 -0
  215. /package/src/@ipld/dag-cbor/{dag-cbor/src → src}/index.js +0 -0
  216. /package/src/@ipld/{dag-cbor/dag-cbor → dag-json}/LICENSE +0 -0
  217. /package/{patched → src}/@ipld/dag-json/README.md +0 -0
  218. /package/src/@ipld/dag-json/{dag-json/dist → dist}/index.min.js +0 -0
  219. /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts +0 -0
  220. /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts.map +0 -0
  221. /package/{patched → src}/@ipld/dag-json/package.json +0 -0
  222. /package/src/@ipld/dag-json/{dag-json/src → src}/index.js +0 -0
  223. /package/src/@web3-storage/pail/{pail/LICENSE.md → LICENSE.md} +0 -0
  224. /package/src/@web3-storage/pail/{pail/README.md → README.md} +0 -0
  225. /package/src/@web3-storage/pail/{pail/cli.js → cli.js} +0 -0
  226. /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts +0 -0
  227. /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts.map +0 -0
  228. /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts +0 -0
  229. /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts.map +0 -0
  230. /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts +0 -0
  231. /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts.map +0 -0
  232. /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts +0 -0
  233. /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts.map +0 -0
  234. /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts +0 -0
  235. /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts.map +0 -0
  236. /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts +0 -0
  237. /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts.map +0 -0
  238. /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts +0 -0
  239. /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts.map +0 -0
  240. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts +0 -0
  241. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts.map +0 -0
  242. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts +0 -0
  243. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts.map +0 -0
  244. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts +0 -0
  245. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts.map +0 -0
  246. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts +0 -0
  247. /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts.map +0 -0
  248. /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts +0 -0
  249. /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts.map +0 -0
  250. /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts +0 -0
  251. /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts.map +0 -0
  252. /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts +0 -0
  253. /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts.map +0 -0
  254. /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts +0 -0
  255. /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts.map +0 -0
  256. /package/src/@web3-storage/pail/{pail/dist → dist}/tsconfig.tsbuildinfo +0 -0
  257. /package/src/@web3-storage/pail/{pail/package.json → package.json} +0 -0
  258. /package/src/@web3-storage/pail/{pail/src → src}/api.js +0 -0
  259. /package/src/@web3-storage/pail/{pail/src → src}/api.ts +0 -0
  260. /package/src/@web3-storage/pail/{pail/src → src}/batch/api.js +0 -0
  261. /package/src/@web3-storage/pail/{pail/src → src}/batch/api.ts +0 -0
  262. /package/src/@web3-storage/pail/{pail/src → src}/batch/index.js +0 -0
  263. /package/src/@web3-storage/pail/{pail/src → src}/batch/shard.js +0 -0
  264. /package/src/@web3-storage/pail/{pail/src → src}/block.js +0 -0
  265. /package/src/@web3-storage/pail/{pail/src → src}/clock/api.js +0 -0
  266. /package/src/@web3-storage/pail/{pail/src → src}/clock/api.ts +0 -0
  267. /package/src/@web3-storage/pail/{pail/src → src}/clock/index.js +0 -0
  268. /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.js +0 -0
  269. /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.ts +0 -0
  270. /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.js +0 -0
  271. /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.ts +0 -0
  272. /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/index.js +0 -0
  273. /package/src/@web3-storage/pail/{pail/src → src}/crdt/index.js +0 -0
  274. /package/src/@web3-storage/pail/{pail/src → src}/diff.js +0 -0
  275. /package/src/@web3-storage/pail/{pail/src → src}/index.js +0 -0
  276. /package/src/@web3-storage/pail/{pail/src → src}/merge.js +0 -0
  277. /package/src/@web3-storage/pail/{pail/src → src}/shard.js +0 -0
  278. /package/{patched → src}/cborg/CHANGELOG.md +0 -0
  279. /package/{patched → src}/cborg/LICENSE +0 -0
  280. /package/{patched → src}/cborg/README.md +0 -0
  281. /package/{patched → src}/cborg/bench/bench.js +0 -0
  282. /package/{patched → src}/cborg/bench/json.js +0 -0
  283. /package/{patched → src}/cborg/bench/package.json +0 -0
  284. /package/{patched → src}/cborg/cborg.js +0 -0
  285. /package/{patched → src}/cborg/example-bytestrings.js +0 -0
  286. /package/src/cborg/{cborg/example-json.js → example-json.js} +0 -0
  287. /package/src/cborg/{cborg/example.js → example.js} +0 -0
  288. /package/{patched → src}/cborg/interface.ts +0 -0
  289. /package/src/cborg/{cborg/lib → lib}/0uint.js +0 -0
  290. /package/{patched → src}/cborg/lib/1negint.js +0 -0
  291. /package/{patched → src}/cborg/lib/2bytes.js +0 -0
  292. /package/{patched → src}/cborg/lib/3string.js +0 -0
  293. /package/{patched → src}/cborg/lib/4array.js +0 -0
  294. /package/{patched → src}/cborg/lib/5map.js +0 -0
  295. /package/{patched → src}/cborg/lib/6tag.js +0 -0
  296. /package/{patched → src}/cborg/lib/7float.js +0 -0
  297. /package/{patched → src}/cborg/lib/bin.js +0 -0
  298. /package/{patched → src}/cborg/lib/bl.js +0 -0
  299. /package/{patched → src}/cborg/lib/byte-utils.js +0 -0
  300. /package/{patched → src}/cborg/lib/common.js +0 -0
  301. /package/{patched → src}/cborg/lib/decode.js +0 -0
  302. /package/{patched → src}/cborg/lib/diagnostic.js +0 -0
  303. /package/{patched → src}/cborg/lib/diagnostic_test.js +0 -0
  304. /package/{patched → src}/cborg/lib/encode.js +0 -0
  305. /package/{patched → src}/cborg/lib/is.js +0 -0
  306. /package/src/cborg/{cborg/lib → lib}/json/decode.js +0 -0
  307. /package/src/cborg/{cborg/lib → lib}/json/encode.js +0 -0
  308. /package/{patched → src}/cborg/lib/json/json.js +0 -0
  309. /package/{patched → src}/cborg/lib/jump.js +0 -0
  310. /package/{patched → src}/cborg/lib/length.js +0 -0
  311. /package/{patched → src}/cborg/lib/token.js +0 -0
  312. /package/src/cborg/{cborg/package.json → package.json} +0 -0
  313. /package/{patched → src}/cborg/taglib.js +0 -0
  314. /package/{patched → src}/cborg/test/appendix_a.js +0 -0
  315. /package/src/cborg/{cborg/test → test}/common.js +0 -0
  316. /package/{patched → src}/cborg/test/node-test-bin.js +0 -0
  317. /package/{patched → src}/cborg/test/noop-bin-test.js +0 -0
  318. /package/{patched → src}/cborg/test/test-0uint.js +0 -0
  319. /package/{patched → src}/cborg/test/test-1negint.js +0 -0
  320. /package/{patched → src}/cborg/test/test-2bytes.js +0 -0
  321. /package/{patched → src}/cborg/test/test-3string.js +0 -0
  322. /package/{patched → src}/cborg/test/test-4array.js +0 -0
  323. /package/{patched → src}/cborg/test/test-5map.js +0 -0
  324. /package/{patched → src}/cborg/test/test-6tag.js +0 -0
  325. /package/{patched → src}/cborg/test/test-7float.js +0 -0
  326. /package/{patched → src}/cborg/test/test-bl.js +0 -0
  327. /package/src/cborg/{cborg/test → test}/test-cbor-vectors.js +0 -0
  328. /package/{patched → src}/cborg/test/test-decode-errors.js +0 -0
  329. /package/{patched → src}/cborg/test/test-fuzz.js +0 -0
  330. /package/src/cborg/{cborg/test → test}/test-json.js +0 -0
  331. /package/{patched → src}/cborg/test/test-length.js +0 -0
  332. /package/{patched → src}/cborg/test/test-partial.js +0 -0
  333. /package/{patched → src}/cborg/tsconfig.json +0 -0
  334. /package/{patched → src}/cborg/types/cborg.d.ts +0 -0
  335. /package/{patched → src}/cborg/types/cborg.d.ts.map +0 -0
  336. /package/{patched → src}/cborg/types/example.d.ts +0 -0
  337. /package/{patched → src}/cborg/types/example.d.ts.map +0 -0
  338. /package/{patched → src}/cborg/types/interface.d.ts +0 -0
  339. /package/{patched → src}/cborg/types/interface.d.ts.map +0 -0
  340. /package/{patched → src}/cborg/types/lib/0uint.d.ts +0 -0
  341. /package/{patched → src}/cborg/types/lib/0uint.d.ts.map +0 -0
  342. /package/{patched → src}/cborg/types/lib/1negint.d.ts +0 -0
  343. /package/{patched → src}/cborg/types/lib/1negint.d.ts.map +0 -0
  344. /package/{patched → src}/cborg/types/lib/2bytes.d.ts +0 -0
  345. /package/{patched → src}/cborg/types/lib/2bytes.d.ts.map +0 -0
  346. /package/{patched → src}/cborg/types/lib/3string.d.ts +0 -0
  347. /package/{patched → src}/cborg/types/lib/3string.d.ts.map +0 -0
  348. /package/{patched → src}/cborg/types/lib/4array.d.ts +0 -0
  349. /package/{patched → src}/cborg/types/lib/4array.d.ts.map +0 -0
  350. /package/{patched → src}/cborg/types/lib/5map.d.ts +0 -0
  351. /package/{patched → src}/cborg/types/lib/5map.d.ts.map +0 -0
  352. /package/{patched → src}/cborg/types/lib/6tag.d.ts +0 -0
  353. /package/{patched → src}/cborg/types/lib/6tag.d.ts.map +0 -0
  354. /package/{patched → src}/cborg/types/lib/7float.d.ts +0 -0
  355. /package/{patched → src}/cborg/types/lib/7float.d.ts.map +0 -0
  356. /package/{patched → src}/cborg/types/lib/bin.d.ts +0 -0
  357. /package/{patched → src}/cborg/types/lib/bin.d.ts.map +0 -0
  358. /package/{patched → src}/cborg/types/lib/bl.d.ts +0 -0
  359. /package/{patched → src}/cborg/types/lib/bl.d.ts.map +0 -0
  360. /package/{patched → src}/cborg/types/lib/byte-utils.d.ts +0 -0
  361. /package/{patched → src}/cborg/types/lib/byte-utils.d.ts.map +0 -0
  362. /package/{patched → src}/cborg/types/lib/common.d.ts +0 -0
  363. /package/{patched → src}/cborg/types/lib/common.d.ts.map +0 -0
  364. /package/{patched → src}/cborg/types/lib/decode.d.ts +0 -0
  365. /package/{patched → src}/cborg/types/lib/decode.d.ts.map +0 -0
  366. /package/{patched → src}/cborg/types/lib/diagnostic.d.ts +0 -0
  367. /package/{patched → src}/cborg/types/lib/diagnostic.d.ts.map +0 -0
  368. /package/{patched → src}/cborg/types/lib/diagnostic_test.d.ts +0 -0
  369. /package/{patched → src}/cborg/types/lib/diagnostic_test.d.ts.map +0 -0
  370. /package/{patched → src}/cborg/types/lib/encode.d.ts +0 -0
  371. /package/{patched → src}/cborg/types/lib/encode.d.ts.map +0 -0
  372. /package/{patched → src}/cborg/types/lib/is.d.ts +0 -0
  373. /package/{patched → src}/cborg/types/lib/is.d.ts.map +0 -0
  374. /package/{patched → src}/cborg/types/lib/json/decode.d.ts +0 -0
  375. /package/{patched → src}/cborg/types/lib/json/decode.d.ts.map +0 -0
  376. /package/{patched → src}/cborg/types/lib/json/encode.d.ts +0 -0
  377. /package/{patched → src}/cborg/types/lib/json/encode.d.ts.map +0 -0
  378. /package/{patched → src}/cborg/types/lib/json/forward-cborg.d.ts +0 -0
  379. /package/{patched → src}/cborg/types/lib/json/forward-cborg.d.ts.map +0 -0
  380. /package/{patched → src}/cborg/types/lib/json/json.d.ts +0 -0
  381. /package/{patched → src}/cborg/types/lib/json/json.d.ts.map +0 -0
  382. /package/{patched → src}/cborg/types/lib/jump.d.ts +0 -0
  383. /package/{patched → src}/cborg/types/lib/jump.d.ts.map +0 -0
  384. /package/{patched → src}/cborg/types/lib/length.d.ts +0 -0
  385. /package/{patched → src}/cborg/types/lib/length.d.ts.map +0 -0
  386. /package/{patched → src}/cborg/types/lib/token.d.ts +0 -0
  387. /package/{patched → src}/cborg/types/lib/token.d.ts.map +0 -0
  388. /package/{patched → src}/cborg/types/taglib.d.ts +0 -0
  389. /package/{patched → src}/cborg/types/taglib.d.ts.map +0 -0
  390. /package/{patched → src}/cborg/types/tsconfig.tsbuildinfo +0 -0
  391. /package/src/{@ipld/dag-json/dag-json → ipfs-unixfs-exporter}/LICENSE +0 -0
  392. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/README.md → README.md} +0 -0
  393. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/index.min.js +0 -0
  394. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts +0 -0
  395. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts.map +0 -0
  396. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js +0 -0
  397. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js.map +0 -0
  398. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts +0 -0
  399. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts.map +0 -0
  400. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js +0 -0
  401. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js.map +0 -0
  402. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts +0 -0
  403. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts.map +0 -0
  404. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js +0 -0
  405. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js.map +0 -0
  406. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts +0 -0
  407. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts.map +0 -0
  408. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js +0 -0
  409. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js.map +0 -0
  410. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts +0 -0
  411. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts.map +0 -0
  412. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js +0 -0
  413. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js.map +0 -0
  414. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts +0 -0
  415. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts.map +0 -0
  416. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js +0 -0
  417. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js.map +0 -0
  418. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts +0 -0
  419. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts.map +0 -0
  420. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js +0 -0
  421. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js.map +0 -0
  422. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts +0 -0
  423. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts.map +0 -0
  424. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js +0 -0
  425. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js.map +0 -0
  426. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts +0 -0
  427. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -0
  428. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js +0 -0
  429. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js.map +0 -0
  430. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts +0 -0
  431. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -0
  432. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js +0 -0
  433. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js.map +0 -0
  434. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -0
  435. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -0
  436. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -0
  437. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -0
  438. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts +0 -0
  439. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -0
  440. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js +0 -0
  441. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js.map +0 -0
  442. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts +0 -0
  443. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts.map +0 -0
  444. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js +0 -0
  445. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js.map +0 -0
  446. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts +0 -0
  447. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts.map +0 -0
  448. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js +0 -0
  449. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js.map +0 -0
  450. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts +0 -0
  451. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts.map +0 -0
  452. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js +0 -0
  453. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js.map +0 -0
  454. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts +0 -0
  455. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts.map +0 -0
  456. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js +0 -0
  457. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js.map +0 -0
  458. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts +0 -0
  459. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts.map +0 -0
  460. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js +0 -0
  461. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js.map +0 -0
  462. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/typedoc-urls.json +0 -0
  463. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/package.json → package.json} +0 -0
  464. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/errors.ts +0 -0
  465. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/index.ts +0 -0
  466. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-cbor.ts +0 -0
  467. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-json.ts +0 -0
  468. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/identity.ts +0 -0
  469. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/index.ts +0 -0
  470. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/json.ts +0 -0
  471. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/raw.ts +0 -0
  472. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/directory.ts +0 -0
  473. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/file.ts +0 -0
  474. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -0
  475. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/raw.ts +0 -0
  476. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/index.ts +0 -0
  477. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/extract-data-from-block.ts +0 -0
  478. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/find-cid-in-shard.ts +0 -0
  479. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/resolve-object-path.ts +0 -0
  480. /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/validate-offset-and-length.ts +0 -0
@@ -1,402 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import * as chai from 'chai'
4
- import { exec } from 'child_process'
5
- import process from 'process'
6
- import path from 'path'
7
- import { platform } from 'os'
8
- import { fileURLToPath } from 'url'
9
-
10
- const { assert } = chai
11
-
12
- const fixture1JsonString = '{"a":1,"b":[2,3],"smile":"😀"}'
13
- const fixture1JsonPrettyString =
14
- `{
15
- "a": 1,
16
- "b": [
17
- 2,
18
- 3
19
- ],
20
- "smile": "😀"
21
- }
22
- `
23
- const fixture1HexString = 'a3616101616282020365736d696c6564f09f9880'
24
- const fixture1Bin = fromHex(fixture1HexString)
25
- const fixture1BinString = new TextDecoder().decode(fixture1Bin)
26
- const fixture1DiagnosticString =
27
- `a3 # map(3)
28
- 61 # string(1)
29
- 61 # "a"
30
- 01 # uint(1)
31
- 61 # string(1)
32
- 62 # "b"
33
- 82 # array(2)
34
- 02 # uint(2)
35
- 03 # uint(3)
36
- 65 # string(5)
37
- 736d696c65 # "smile"
38
- 64 # string(2)
39
- f09f9880 # "😀"
40
- `
41
- const fixture2HexString = 'a4616101616282020363627566440102036165736d696c6564f09f9880'
42
- const fixture2DiagnosticString =
43
- `a4 # map(4)
44
- 61 # string(1)
45
- 61 # "a"
46
- 01 # uint(1)
47
- 61 # string(1)
48
- 62 # "b"
49
- 82 # array(2)
50
- 02 # uint(2)
51
- 03 # uint(3)
52
- 63 # string(3)
53
- 627566 # "buf"
54
- 44 # bytes(4)
55
- 01020361 # "\\x01\\x02\\x03a"
56
- 65 # string(5)
57
- 736d696c65 # "smile"
58
- 64 # string(2)
59
- f09f9880 # "😀"
60
- `
61
-
62
- const binPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../lib/bin.js')
63
-
64
- function fromHex (hex) {
65
- return new Uint8Array(hex.split('')
66
- .map((/** @type {string} */ c, /** @type {number} */ i, /** @type {string[]} */ d) => i % 2 === 0 ? `0x${c}${d[i + 1]}` : '')
67
- .filter(Boolean)
68
- .map((/** @type {string} */ e) => parseInt(e, 16)))
69
- }
70
-
71
- async function execBin (cmd, stdin) {
72
- return new Promise((resolve, reject) => {
73
- const cp = exec(`"${process.execPath}" "${binPath}" ${cmd}`, (err, stdout, stderr) => {
74
- if (err) {
75
- err.stdout = stdout
76
- err.stderr = stderr
77
- return reject(err)
78
- }
79
- resolve({ stdout, stderr })
80
- })
81
- if (stdin != null) {
82
- cp.on('spawn', () => {
83
- cp.stdin.write(stdin)
84
- cp.stdin.end()
85
- })
86
- }
87
- })
88
- }
89
-
90
- describe('Bin', () => {
91
- it('usage', async () => {
92
- try {
93
- await execBin('')
94
- assert.fail('should have errored')
95
- } catch (e) {
96
- assert.strictEqual(e.stdout, '')
97
- assert.strictEqual(e.stderr,
98
- `Usage: cborg <command> <args>
99
- Valid commands:
100
- \tbin2diag [binary input]
101
- \tbin2hex [binary input]
102
- \tbin2json [--pretty] [binary input]
103
- \tdiag2bin [diagnostic input]
104
- \tdiag2hex [diagnostic input]
105
- \tdiag2json [--pretty] [diagnostic input]
106
- \thex2bin [hex input]
107
- \thex2diag [hex input]
108
- \thex2json [--pretty] [hex input]
109
- \tjson2bin '[json input]'
110
- \tjson2diag '[json input]'
111
- \tjson2hex '[json input]'
112
- Input may either be supplied as an argument or piped via stdin
113
- `)
114
- }
115
- })
116
-
117
- it('bad cmd', async () => {
118
- try {
119
- await execBin('blip')
120
- assert.fail('should have errored')
121
- } catch (e) {
122
- assert.strictEqual(e.stdout, '')
123
- assert.strictEqual(e.stderr,
124
- `Unknown command: 'blip'
125
- Usage: cborg <command> <args>
126
- Valid commands:
127
- \tbin2diag [binary input]
128
- \tbin2hex [binary input]
129
- \tbin2json [--pretty] [binary input]
130
- \tdiag2bin [diagnostic input]
131
- \tdiag2hex [diagnostic input]
132
- \tdiag2json [--pretty] [diagnostic input]
133
- \thex2bin [hex input]
134
- \thex2diag [hex input]
135
- \thex2json [--pretty] [hex input]
136
- \tjson2bin '[json input]'
137
- \tjson2diag '[json input]'
138
- \tjson2hex '[json input]'
139
- Input may either be supplied as an argument or piped via stdin
140
- `)
141
- }
142
- })
143
-
144
- it('help', async () => {
145
- const { stdout, stderr } = await execBin('help')
146
- assert.strictEqual(stdout, '')
147
- assert.strictEqual(stderr,
148
- `Usage: cborg <command> <args>
149
- Valid commands:
150
- \tbin2diag [binary input]
151
- \tbin2hex [binary input]
152
- \tbin2json [--pretty] [binary input]
153
- \tdiag2bin [diagnostic input]
154
- \tdiag2hex [diagnostic input]
155
- \tdiag2json [--pretty] [diagnostic input]
156
- \thex2bin [hex input]
157
- \thex2diag [hex input]
158
- \thex2json [--pretty] [hex input]
159
- \tjson2bin '[json input]'
160
- \tjson2diag '[json input]'
161
- \tjson2hex '[json input]'
162
- Input may either be supplied as an argument or piped via stdin
163
- `)
164
- })
165
-
166
- it('bin2diag (stdin)', async () => {
167
- const { stdout, stderr } = await execBin('bin2diag', fixture1Bin)
168
- assert.strictEqual(stderr, '')
169
- assert.strictEqual(stdout, fixture1DiagnosticString)
170
- })
171
-
172
- it('bin2hex (stdin)', async () => {
173
- const { stdout, stderr } = await execBin('bin2hex', fixture1Bin)
174
- assert.strictEqual(stderr, '')
175
- assert.strictEqual(stdout, `${fixture1HexString}\n`)
176
- })
177
-
178
- it('bin2json (stdin)', async () => {
179
- const { stdout, stderr } = await execBin('bin2json', fixture1Bin)
180
- assert.strictEqual(stderr, '')
181
- assert.strictEqual(stdout, `${fixture1JsonString}\n`)
182
- })
183
-
184
- it('bin2json pretty (stdin)', async () => {
185
- const { stdout, stderr } = await execBin('bin2json --pretty', fixture1Bin)
186
- assert.strictEqual(stderr, '')
187
- assert.strictEqual(stdout, fixture1JsonPrettyString)
188
- })
189
-
190
- for (const stdin of [true, false]) {
191
- if (platform() !== 'win32' || stdin) { // multiline CLI input is hard (impossible?) on Windows
192
- it(`diag2bin${stdin ? ' (stdin)' : ''}`, async () => {
193
- const { stdout, stderr } = !stdin
194
- ? await execBin(`diag2bin '${fixture1DiagnosticString}'`)
195
- : await execBin('diag2bin', fixture1DiagnosticString)
196
- assert.strictEqual(stderr, '')
197
- assert.strictEqual(stdout, fixture1BinString)
198
- })
199
-
200
- it(`diag2hex${stdin ? ' (stdin)' : ''}`, async () => {
201
- const { stdout, stderr } = !stdin
202
- ? await execBin(`diag2hex '${fixture1DiagnosticString}'`)
203
- : await execBin('diag2hex', fixture1DiagnosticString)
204
- assert.strictEqual(stderr, '')
205
- assert.strictEqual(stdout, `${fixture1HexString}\n`)
206
- })
207
-
208
- it(`diag2json${stdin ? ' (stdin)' : ''}`, async () => {
209
- const { stdout, stderr } = !stdin
210
- ? await execBin(`diag2json '${fixture1DiagnosticString}'`)
211
- : await execBin('diag2json', fixture1DiagnosticString)
212
- assert.strictEqual(stderr, '')
213
- assert.strictEqual(stdout, `${fixture1JsonString}\n`)
214
- })
215
-
216
- it(`diag2json pretty${stdin ? ' (stdin)' : ''}`, async () => {
217
- const { stdout, stderr } = !stdin
218
- ? await execBin(`diag2json --pretty '${fixture1DiagnosticString}'`)
219
- : await execBin('diag2json --pretty', fixture1DiagnosticString)
220
- assert.strictEqual(stderr, '')
221
- assert.strictEqual(stdout, fixture1JsonPrettyString)
222
- })
223
- }
224
-
225
- it(`hex2bin${stdin ? ' (stdin)' : ''}`, async () => {
226
- const { stdout, stderr } = !stdin
227
- ? await execBin(`hex2bin ${fixture1HexString}`)
228
- : await execBin('hex2bin', fixture1HexString)
229
- assert.strictEqual(stderr, '')
230
- assert.strictEqual(stdout, fixture1BinString)
231
- })
232
-
233
- it(`hex2diag${stdin ? ' (stdin)' : ''}`, async () => {
234
- const { stdout, stderr } = !stdin
235
- ? await execBin(`hex2diag ${fixture2HexString}`)
236
- : await execBin('hex2diag', fixture2HexString)
237
- assert.strictEqual(stderr, '')
238
- assert.strictEqual(stdout, fixture2DiagnosticString)
239
- })
240
-
241
- it(`hex2json${stdin ? ' (stdin)' : ''}`, async () => {
242
- const { stdout, stderr } = !stdin
243
- ? await execBin(`hex2json ${fixture1HexString}`)
244
- : await execBin('hex2json', fixture1HexString)
245
- assert.strictEqual(stderr, '')
246
- assert.strictEqual(stdout, `${fixture1JsonString}\n`)
247
- })
248
-
249
- it(`hex2json pretty${stdin ? ' (stdin)' : ''}`, async () => {
250
- const { stdout, stderr } = !stdin
251
- ? await execBin(`hex2json --pretty ${fixture1HexString}`)
252
- : await execBin('hex2json --pretty', fixture1HexString)
253
- assert.strictEqual(stderr, '')
254
- assert.strictEqual(stdout, fixture1JsonPrettyString)
255
- })
256
-
257
- it(`json2bin${stdin ? ' (stdin)' : ''}`, async () => {
258
- const { stdout, stderr } = !stdin
259
- ? await execBin('json2bin "{\\"a\\":1,\\"b\\":[2,3],\\"smile\\":\\"😀\\"}"')
260
- : await execBin('json2bin', fixture1JsonString)
261
- assert.strictEqual(stderr, '')
262
- assert.strictEqual(stdout, fixture1BinString)
263
- })
264
-
265
- it(`json2diag${stdin ? ' (stdin)' : ''}`, async () => {
266
- const { stdout, stderr } = !stdin
267
- ? await execBin('json2diag "{\\"a\\":1,\\"b\\":[2,3],\\"smile\\":\\"😀\\"}"')
268
- : await execBin('json2diag', fixture1JsonString)
269
- assert.strictEqual(stderr, '')
270
- assert.strictEqual(stdout, fixture1DiagnosticString)
271
- })
272
-
273
- it(`json2hex${stdin ? ' (stdin)' : ''}`, async () => {
274
- const { stdout, stderr } = !stdin
275
- ? await execBin(`json2hex "${fixture1JsonString.replace(/"/g, '\\"')}"`)
276
- : await execBin('json2hex', fixture1JsonString)
277
- assert.strictEqual(stderr, '')
278
- assert.strictEqual(stdout, `${fixture1HexString}\n`)
279
- })
280
- }
281
-
282
- // complicated nesting to test indenting algorithm
283
- it('diag indenting', async () => {
284
- const { stdout, stderr } = await execBin('json2diag', '{"a":[],"b":{},"c":{"a":1,"b":{"a":{"a":{}}}},"d":{"a":{"a":{"a":1},"b":2,"c":[]}},"e":[[[[{"a":{}}]]]],"f":1}')
285
- assert.strictEqual(stderr, '')
286
- assert.strictEqual(stdout,
287
- `a6 # map(6)
288
- 61 # string(1)
289
- 61 # "a"
290
- 80 # array(0)
291
- 61 # string(1)
292
- 62 # "b"
293
- a0 # map(0)
294
- 61 # string(1)
295
- 63 # "c"
296
- a2 # map(2)
297
- 61 # string(1)
298
- 61 # "a"
299
- 01 # uint(1)
300
- 61 # string(1)
301
- 62 # "b"
302
- a1 # map(1)
303
- 61 # string(1)
304
- 61 # "a"
305
- a1 # map(1)
306
- 61 # string(1)
307
- 61 # "a"
308
- a0 # map(0)
309
- 61 # string(1)
310
- 64 # "d"
311
- a1 # map(1)
312
- 61 # string(1)
313
- 61 # "a"
314
- a3 # map(3)
315
- 61 # string(1)
316
- 61 # "a"
317
- a1 # map(1)
318
- 61 # string(1)
319
- 61 # "a"
320
- 01 # uint(1)
321
- 61 # string(1)
322
- 62 # "b"
323
- 02 # uint(2)
324
- 61 # string(1)
325
- 63 # "c"
326
- 80 # array(0)
327
- 61 # string(1)
328
- 65 # "e"
329
- 81 # array(1)
330
- 81 # array(1)
331
- 81 # array(1)
332
- 81 # array(1)
333
- a1 # map(1)
334
- 61 # string(1)
335
- 61 # "a"
336
- a0 # map(0)
337
- 61 # string(1)
338
- 66 # "f"
339
- 01 # uint(1)
340
- `)
341
- })
342
-
343
- describe('diag length bytes', () => {
344
- it('compact', async () => {
345
- const { stdout, stderr } = await execBin('json2diag', '"aaaaaaaaaaaaaaaaaaaaaaa"')
346
- assert.strictEqual(stderr, '')
347
- assert.strictEqual(stdout,
348
- `77 # string(23)
349
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
350
- `)
351
- })
352
-
353
- it('1-byte', async () => {
354
- const { stdout, stderr } = await execBin('json2diag', '"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"')
355
- assert.strictEqual(stderr, '')
356
- assert.strictEqual(stdout,
357
- `78 23 # string(35)
358
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
359
- 616161616161616161616161 # "aaaaaaaaaaaa"
360
- `)
361
- })
362
-
363
- it('2-byte', async () => {
364
- const { stdout, stderr } = await execBin('json2diag', '"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"')
365
- assert.strictEqual(stderr, '')
366
- assert.strictEqual(stdout,
367
- `79 0100 # string(256)
368
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
369
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
370
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
371
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
372
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
373
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
374
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
375
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
376
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
377
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
378
- 6161616161616161616161616161616161616161616161 # "aaaaaaaaaaaaaaaaaaaaaaa"
379
- 616161 # "aaa"
380
- `)
381
- })
382
- })
383
-
384
- it('diag non-utf8 and non-printable ascii', async () => {
385
- const input = '7864f55ff8f12508b63ef2bfeca7557ae90df6311a5ec1631b4a1fa843310bd9c3a710eaace5a1bdd72ad0bfe049771c11e756338bd93865e645f1adec9b9c99ef407fbd4fc6859e7904c5ad7dc9bd10a5cc16973d5b28ec1a6dd43d9f82f9f18c3d03418e35'
386
- let { stdout, stderr } = await execBin(`hex2diag ${input}`)
387
- assert.strictEqual(stderr, '')
388
- assert.strictEqual(stdout,
389
- `78 64 # string(86)
390
- f55ff8f12508b63ef2bfeca7557ae90df6311a5ec1631b # "õ_øñ%\\x08¶>ò¿ì§Uzé\\x0dö1\\x1a^Ác\\x1b"
391
- 4a1fa843310bd9c3a710eaace5a1bdd72ad0bfe049771c # "J\\x1f¨C1\\x0bÙç\\x10ê¬å¡½×*пàIw\\x1c"
392
- 11e756338bd93865e645f1adec9b9c99ef407fbd4fc685 # "\\x11çV3\\x8bÙ8eæEñ\\xadì\\x9b\\x9c\\x99ï@\\x7f½OÆ\\x85"
393
- 9e7904c5ad7dc9bd10a5cc16973d5b28ec1a6dd43d9f82 # "\\x9ey\\x04Å\\xad}ɽ\\x10¥Ì\\x16\\x97=[(ì\\x1amÔ=\\x9f\\x82"
394
- f9f18c3d03418e35 # "ùñ\\x8c=\\x03A\\x8e5"
395
- `)
396
-
397
- // round-trip
398
- ;({ stdout, stderr } = await execBin('diag2hex', stdout))
399
- assert.strictEqual(stderr, '')
400
- assert.strictEqual(stdout, `${input}\n`)
401
- })
402
- })
@@ -1,3 +0,0 @@
1
- // file included so ipjs will compile ../lib/bin.js
2
- // this test file is not intended to be run or loaded
3
- import bin from '../lib/bin.js' // eslint-disable-line
@@ -1,103 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import * as chai from 'chai'
4
-
5
- import { decode, encode } from '../cborg.js'
6
- import { fromHex, toHex } from '../lib/byte-utils.js'
7
-
8
- const { assert } = chai
9
-
10
- // some from https://github.com/PJK/libcbor
11
-
12
- const fixtures = [
13
- { data: '00', expected: 0, type: 'uint8' },
14
- { data: '02', expected: 2, type: 'uint8' },
15
- { data: '18ff', expected: 255, type: 'uint8' },
16
- { data: '1901f4', expected: 500, type: 'uint16' },
17
- { data: '1900ff', expected: 255, type: 'uint16', strict: false },
18
- { data: '19ffff', expected: 65535, type: 'uint16' },
19
- { data: '1a000000ff', expected: 255, type: 'uint32', strict: false },
20
- { data: '1a00010000', expected: 65536, type: 'uint32' },
21
- { data: '1a000f4240', expected: 1000000, type: 'uint32' },
22
- { data: '1aa5f702b3', expected: 2784428723, type: 'uint32' },
23
- { data: '1b00000000000000ff', expected: 255, type: 'uint64', strict: false },
24
- { data: '1b0016db6db6db6db7', expected: Number.MAX_SAFE_INTEGER / 1.4, type: 'uint64' },
25
- { data: '1b001fffffffffffff', expected: Number.MAX_SAFE_INTEGER, type: 'uint64' },
26
- { data: '1ba5f702b3a5f702b3', expected: BigInt('11959030306112471731'), type: 'uint64' },
27
- { data: '1bffffffffffffffff', expected: BigInt('18446744073709551615'), type: 'uint64' }
28
- ]
29
-
30
- describe('uint', () => {
31
- describe('decode', () => {
32
- for (const fixture of fixtures) {
33
- const data = fromHex(fixture.data)
34
- it(`should decode ${fixture.type}=${fixture.expected}`, () => {
35
- assert.ok(decode(data) === fixture.expected, `decode ${fixture.type} ${decode(data)} != ${fixture.expected}`)
36
- if (fixture.strict === false) {
37
- assert.throws(() => decode(data, { strict: true }), Error, 'CBOR decode error: integer encoded in more bytes than necessary (strict decode)')
38
- } else {
39
- assert.ok(decode(data, { strict: true }) === fixture.expected, `decode ${fixture.type}`)
40
- }
41
- })
42
- }
43
- })
44
-
45
- it('should throw error', () => {
46
- // minor number 28, too high for uint
47
- assert.throws(() => decode(fromHex('1ca5f702b3a5f702b3')), Error, 'CBOR decode error: encountered invalid minor (28) for major 0')
48
- assert.throws(() => decode(fromHex('1ba5f702b3a5f702')), Error, 'CBOR decode error: not enough data for type')
49
- })
50
-
51
- describe('encode', () => {
52
- for (const fixture of fixtures) {
53
- it(`should encode ${fixture.type}=${fixture.expected}`, () => {
54
- if (fixture.strict === false) {
55
- assert.notStrictEqual(toHex(encode(fixture.expected)), fixture.data, `encode ${fixture.type} !strict`)
56
- } else {
57
- assert.strictEqual(toHex(encode(fixture.expected)), fixture.data, `encode ${fixture.type}`)
58
- }
59
- })
60
- }
61
- })
62
-
63
- // mostly unnecessary, but feels good
64
- describe('roundtrip', () => {
65
- for (const fixture of fixtures) {
66
- if (fixture.strict !== false) {
67
- it(`should roundtrip ${fixture.type}=${fixture.expected}`, () => {
68
- assert.ok(decode(encode(fixture.expected)) === fixture.expected, `roundtrip ${fixture.type}`)
69
- })
70
- }
71
- }
72
- })
73
-
74
- describe('toobig', () => {
75
- it('bigger than 64-bit', () => {
76
- // boundary condition is right on 64-bit int
77
- assert.doesNotThrow(() => encode(BigInt('18446744073709551615') /* BigInt(2) ** BigInt(64) - BigInt(1) */))
78
- assert.throws(() => encode(BigInt('18446744073709551616') /* BigInt(2) ** BigInt(64) */), /BigInt larger than allowable range/)
79
- })
80
-
81
- it('disallow BigInt', () => {
82
- for (const fixture of fixtures) {
83
- const data = fromHex(fixture.data)
84
- if (!Number.isSafeInteger(fixture.expected)) {
85
- assert.throws(() => decode(data, { allowBigInt: false }), /safe integer range/)
86
- } else {
87
- assert.ok(decode(data, { allowBigInt: false }) === fixture.expected, `decode ${fixture.type}`)
88
- }
89
- }
90
- })
91
- })
92
-
93
- describe('toosmall', () => {
94
- for (const fixture of fixtures) {
95
- if (fixture.strict !== false && typeof fixture.expected === 'number') {
96
- const small = BigInt(fixture.expected)
97
- it(`should encode ${small}n`, () => {
98
- assert.strictEqual(toHex(encode(BigInt(small))), fixture.data, `encode ${small}`)
99
- })
100
- }
101
- }
102
- })
103
- })
@@ -1,96 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import * as chai from 'chai'
4
-
5
- import { decode, encode } from '../cborg.js'
6
- import { fromHex, toHex } from '../lib/byte-utils.js'
7
-
8
- const { assert } = chai
9
-
10
- // some from https://github.com/PJK/libcbor
11
-
12
- const fixtures = [
13
- { data: '20', expected: -1, type: 'negint8' },
14
- { data: '22', expected: -3, type: 'negint8' },
15
- { data: '3863', expected: -100, type: 'negint8' },
16
- { data: '38ff', expected: -256, type: 'negint8' },
17
- { data: '3900ff', expected: -256, type: 'negint16', strict: false },
18
- { data: '3901f4', expected: -501, type: 'negint16' },
19
- { data: '3a000000ff', expected: -256, type: 'negint32', strict: false },
20
- { data: '3aa5f702b3', expected: -2784428724, type: 'negint32' },
21
- { data: '3b00000000000000ff', expected: -256, type: 'negint32', strict: false },
22
- { data: '3b0016db6db6db6db7', expected: Number.MIN_SAFE_INTEGER / 1.4 - 1, type: 'negint64' },
23
- { data: '3b001ffffffffffffe', expected: Number.MIN_SAFE_INTEGER, type: 'negint64' },
24
- // kind of hard to assert on these (TODO: improve bignum handling)
25
- { data: '3b001fffffffffffff', expected: BigInt('-9007199254740992') /* Number.MIN_SAFE_INTEGER - 1 */, type: 'negint64' },
26
- { data: '3b0020000000000000', expected: BigInt('-9007199254740993') /* Number.MIN_SAFE_INTEGER - 2 */, type: 'negint64' },
27
- { data: '3ba5f702b3a5f702b3', expected: BigInt('-11959030306112471732'), type: 'negint64' },
28
- { data: '3bffffffffffffffff', expected: BigInt('-18446744073709551616'), type: 'negint64' }
29
- ]
30
-
31
- describe('negint', () => {
32
- describe('decode', () => {
33
- for (const fixture of fixtures) {
34
- const data = fromHex(fixture.data)
35
- it(`should decode ${fixture.type}=${fixture.expected}`, () => {
36
- assert.ok(decode(data) === fixture.expected, `decode ${fixture.type} (${decode(data)} != ${fixture.expected})`)
37
- if (fixture.strict === false) {
38
- assert.throws(() => decode(data, { strict: true }), Error, 'CBOR decode error: integer encoded in more bytes than necessary (strict decode)')
39
- } else {
40
- assert.strictEqual(decode(data, { strict: true }), fixture.expected, `decode ${fixture.type}`)
41
- }
42
- })
43
- }
44
- })
45
-
46
- describe('encode', () => {
47
- for (const fixture of fixtures) {
48
- it(`should encode ${fixture.type}=${fixture.expected}`, () => {
49
- if (fixture.strict === false) {
50
- assert.notStrictEqual(toHex(encode(fixture.expected)), fixture.data, `encode ${fixture.type} !strict`)
51
- } else {
52
- assert.strictEqual(toHex(encode(fixture.expected)), fixture.data, `encode ${fixture.type}`)
53
- }
54
- })
55
- }
56
- })
57
-
58
- // mostly unnecessary, but feels good
59
- describe('roundtrip', () => {
60
- for (const fixture of fixtures) {
61
- it(`should roundtrip ${fixture.type}=${fixture.expected}`, () => {
62
- assert.ok(decode(encode(fixture.expected)) === fixture.expected, `roundtrip ${fixture.type}`)
63
- })
64
- }
65
- })
66
-
67
- describe('toobig', () => {
68
- it('bigger than 64-bit', () => {
69
- // boundary condition is right below 64-bit negint
70
- assert.doesNotThrow(() => encode(BigInt('-18446744073709551616') /* BigInt(-1) * BigInt(2) ** BigInt(64) */))
71
- assert.throws(() => encode(BigInt('-18446744073709551617') /* BigInt(-1) * BigInt(2) ** BigInt(64) - BigInt(1) */), /BigInt larger than allowable range/)
72
- })
73
-
74
- it('disallow BigInt', () => {
75
- for (const fixture of fixtures) {
76
- const data = fromHex(fixture.data)
77
- if (!Number.isSafeInteger(fixture.expected)) {
78
- assert.throws(() => decode(data, { allowBigInt: false }), /safe integer range/)
79
- } else {
80
- assert.ok(decode(data, { allowBigInt: false }) === fixture.expected, `decode ${fixture.type}`)
81
- }
82
- }
83
- })
84
- })
85
-
86
- describe('toosmall', () => {
87
- for (const fixture of fixtures) {
88
- if (fixture.strict !== false && typeof fixture.expected === 'number') {
89
- const small = BigInt(fixture.expected)
90
- it(`should encode ${small}n`, () => {
91
- assert.strictEqual(toHex(encode(BigInt(small))), fixture.data, `encode ${small}`)
92
- })
93
- }
94
- }
95
- })
96
- })