@fireproof/vendor 1.0.4 → 1.1.0-dev

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 (302) hide show
  1. package/package.json +4 -97
  2. package/src/@web3-storage/pail/dist/src/batch/index.d.ts +1 -53
  3. package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
  4. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
  5. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
  6. package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
  7. package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
  8. package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
  9. package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
  10. package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
  11. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
  12. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
  13. package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
  14. package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
  15. package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
  16. package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
  17. package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
  18. package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
  19. package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
  20. package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
  21. package/src/@web3-storage/pail/src/api.ts +1 -1
  22. package/src/@web3-storage/pail/src/clock/index.js +1 -1
  23. package/src/@web3-storage/pail/src/shard.js +1 -1
  24. package/src/@ipld/car/LICENSE +0 -4
  25. package/src/@ipld/car/README.md +0 -1132
  26. package/src/@ipld/car/dist/index.min.js +0 -5
  27. package/src/@ipld/car/dist/src/api.d.ts +0 -72
  28. package/src/@ipld/car/dist/src/api.d.ts.map +0 -1
  29. package/src/@ipld/car/dist/src/buffer-decoder.d.ts +0 -67
  30. package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +0 -1
  31. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +0 -116
  32. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
  33. package/src/@ipld/car/dist/src/buffer-reader.d.ts +0 -31
  34. package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +0 -1
  35. package/src/@ipld/car/dist/src/buffer-writer.d.ts +0 -86
  36. package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +0 -1
  37. package/src/@ipld/car/dist/src/coding.d.ts +0 -49
  38. package/src/@ipld/car/dist/src/coding.d.ts.map +0 -1
  39. package/src/@ipld/car/dist/src/decoder-common.d.ts +0 -43
  40. package/src/@ipld/car/dist/src/decoder-common.d.ts.map +0 -1
  41. package/src/@ipld/car/dist/src/decoder.d.ts +0 -87
  42. package/src/@ipld/car/dist/src/decoder.d.ts.map +0 -1
  43. package/src/@ipld/car/dist/src/encoder.d.ts +0 -17
  44. package/src/@ipld/car/dist/src/encoder.d.ts.map +0 -1
  45. package/src/@ipld/car/dist/src/header-validator.d.ts +0 -5
  46. package/src/@ipld/car/dist/src/header-validator.d.ts.map +0 -1
  47. package/src/@ipld/car/dist/src/index-browser.d.ts +0 -10
  48. package/src/@ipld/car/dist/src/index-browser.d.ts.map +0 -1
  49. package/src/@ipld/car/dist/src/index.d.ts +0 -11
  50. package/src/@ipld/car/dist/src/index.d.ts.map +0 -1
  51. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +0 -5
  52. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
  53. package/src/@ipld/car/dist/src/indexed-reader.d.ts +0 -152
  54. package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +0 -1
  55. package/src/@ipld/car/dist/src/indexer.d.ts +0 -95
  56. package/src/@ipld/car/dist/src/indexer.d.ts.map +0 -1
  57. package/src/@ipld/car/dist/src/iterator-channel.d.ts +0 -7
  58. package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +0 -1
  59. package/src/@ipld/car/dist/src/iterator.d.ts +0 -174
  60. package/src/@ipld/car/dist/src/iterator.d.ts.map +0 -1
  61. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +0 -30
  62. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +0 -1
  63. package/src/@ipld/car/dist/src/reader-browser.d.ts +0 -151
  64. package/src/@ipld/car/dist/src/reader-browser.d.ts.map +0 -1
  65. package/src/@ipld/car/dist/src/reader.d.ts +0 -39
  66. package/src/@ipld/car/dist/src/reader.d.ts.map +0 -1
  67. package/src/@ipld/car/dist/src/writer-browser.d.ts +0 -155
  68. package/src/@ipld/car/dist/src/writer-browser.d.ts.map +0 -1
  69. package/src/@ipld/car/dist/src/writer.d.ts +0 -44
  70. package/src/@ipld/car/dist/src/writer.d.ts.map +0 -1
  71. package/src/@ipld/car/src/api.ts +0 -90
  72. package/src/@ipld/car/src/buffer-decoder.js +0 -213
  73. package/src/@ipld/car/src/buffer-reader-browser.js +0 -144
  74. package/src/@ipld/car/src/buffer-reader.js +0 -51
  75. package/src/@ipld/car/src/buffer-writer.js +0 -286
  76. package/src/@ipld/car/src/coding.ts +0 -68
  77. package/src/@ipld/car/src/decoder-common.js +0 -82
  78. package/src/@ipld/car/src/decoder.js +0 -347
  79. package/src/@ipld/car/src/encoder.js +0 -76
  80. package/src/@ipld/car/src/header-validator.js +0 -214
  81. package/src/@ipld/car/src/header.ipldsch +0 -18
  82. package/src/@ipld/car/src/index-browser.js +0 -18
  83. package/src/@ipld/car/src/index.js +0 -21
  84. package/src/@ipld/car/src/indexed-reader-browser.js +0 -7
  85. package/src/@ipld/car/src/indexed-reader.js +0 -211
  86. package/src/@ipld/car/src/indexer.js +0 -130
  87. package/src/@ipld/car/src/iterator-channel.js +0 -91
  88. package/src/@ipld/car/src/iterator.js +0 -267
  89. package/src/@ipld/car/src/promise-fs-opts.js +0 -42
  90. package/src/@ipld/car/src/reader-browser.js +0 -194
  91. package/src/@ipld/car/src/reader.js +0 -53
  92. package/src/@ipld/car/src/writer-browser.js +0 -250
  93. package/src/@ipld/car/src/writer.js +0 -80
  94. package/src/@ipld/dag-cbor/LICENSE +0 -4
  95. package/src/@ipld/dag-cbor/README.md +0 -80
  96. package/src/@ipld/dag-cbor/dist/index.min.js +0 -3
  97. package/src/@ipld/dag-cbor/dist/src/index.d.ts +0 -67
  98. package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +0 -1
  99. package/src/@ipld/dag-cbor/src/index.js +0 -147
  100. package/src/@ipld/dag-json/LICENSE +0 -4
  101. package/src/@ipld/dag-json/README.md +0 -58
  102. package/src/@ipld/dag-json/dist/index.min.js +0 -3
  103. package/src/@ipld/dag-json/dist/src/index.d.ts +0 -12
  104. package/src/@ipld/dag-json/dist/src/index.d.ts.map +0 -1
  105. package/src/@ipld/dag-json/src/index.js +0 -291
  106. package/src/cborg/.github/dependabot.yml +0 -16
  107. package/src/cborg/.github/workflows/test-and-release.yml +0 -52
  108. package/src/cborg/CHANGELOG.md +0 -513
  109. package/src/cborg/LICENSE +0 -13
  110. package/src/cborg/README.md +0 -515
  111. package/src/cborg/bench/bench.js +0 -117
  112. package/src/cborg/bench/json.js +0 -124
  113. package/src/cborg/bench/package.json +0 -8
  114. package/src/cborg/cborg/bin.js +0 -189
  115. package/src/cborg/cborg/common.js +0 -28
  116. package/src/cborg/cborg/decode.js +0 -211
  117. package/src/cborg/cborg/diagnostic.js +0 -158
  118. package/src/cborg/cborg/diagnostic_test.js +0 -117
  119. package/src/cborg/cborg/encode.js +0 -466
  120. package/src/cborg/cborg/index.js +0 -33
  121. package/src/cborg/cborg/is.js +0 -106
  122. package/src/cborg/cborg/length.js +0 -62
  123. package/src/cborg/example-bytestrings.js +0 -180
  124. package/src/cborg/example-json.js +0 -6
  125. package/src/cborg/example.js +0 -5
  126. package/src/cborg/interface.ts +0 -59
  127. package/src/cborg/json/decode.js +0 -462
  128. package/src/cborg/json/encode.js +0 -302
  129. package/src/cborg/json/json.js +0 -4
  130. package/src/cborg/taglib.js +0 -75
  131. package/src/cborg/test/appendix_a.js +0 -647
  132. package/src/cborg/test/common.js +0 -18
  133. package/src/cborg/test/node-test-bin.js +0 -402
  134. package/src/cborg/test/noop-bin-test.js +0 -3
  135. package/src/cborg/test/test-0uint.js +0 -103
  136. package/src/cborg/test/test-1negint.js +0 -96
  137. package/src/cborg/test/test-2bytes.js +0 -198
  138. package/src/cborg/test/test-3string.js +0 -136
  139. package/src/cborg/test/test-4array.js +0 -93
  140. package/src/cborg/test/test-5map.js +0 -284
  141. package/src/cborg/test/test-6tag.js +0 -84
  142. package/src/cborg/test/test-7float.js +0 -131
  143. package/src/cborg/test/test-bl.js +0 -37
  144. package/src/cborg/test/test-cbor-vectors.js +0 -107
  145. package/src/cborg/test/test-decode-errors.js +0 -65
  146. package/src/cborg/test/test-fuzz.js +0 -42
  147. package/src/cborg/test/test-json.js +0 -219
  148. package/src/cborg/test/test-length.js +0 -65
  149. package/src/cborg/test/test-partial.js +0 -111
  150. package/src/cborg/tsconfig.json +0 -48
  151. package/src/cborg/types/cborg/decode.d.ts +0 -43
  152. package/src/cborg/types/cborg/decode.d.ts.map +0 -1
  153. package/src/cborg/types/cborg/encode.d.ts +0 -51
  154. package/src/cborg/types/cborg/encode.d.ts.map +0 -1
  155. package/src/cborg/types/cborg/index.d.ts +0 -26
  156. package/src/cborg/types/cborg/index.d.ts.map +0 -1
  157. package/src/cborg/types/cborg/is.d.ts +0 -6
  158. package/src/cborg/types/cborg/is.d.ts.map +0 -1
  159. package/src/cborg/types/example.d.ts +0 -2
  160. package/src/cborg/types/example.d.ts.map +0 -1
  161. package/src/cborg/types/interface.d.ts +0 -49
  162. package/src/cborg/types/interface.d.ts.map +0 -1
  163. package/src/cborg/types/json/decode.d.ts +0 -67
  164. package/src/cborg/types/json/decode.d.ts.map +0 -1
  165. package/src/cborg/types/json/encode.d.ts +0 -11
  166. package/src/cborg/types/json/encode.d.ts.map +0 -1
  167. package/src/cborg/types/json/json.d.ts +0 -6
  168. package/src/cborg/types/json/json.d.ts.map +0 -1
  169. package/src/cborg/types/taglib.d.ts +0 -18
  170. package/src/cborg/types/taglib.d.ts.map +0 -1
  171. package/src/cborg/types/tsconfig.tsbuildinfo +0 -1
  172. package/src/cborg/types/utils/0uint.d.ts +0 -102
  173. package/src/cborg/types/utils/0uint.d.ts.map +0 -1
  174. package/src/cborg/types/utils/1negint.d.ts +0 -59
  175. package/src/cborg/types/utils/1negint.d.ts.map +0 -1
  176. package/src/cborg/types/utils/2bytes.d.ts +0 -69
  177. package/src/cborg/types/utils/2bytes.d.ts.map +0 -1
  178. package/src/cborg/types/utils/3string.d.ts +0 -46
  179. package/src/cborg/types/utils/3string.d.ts.map +0 -1
  180. package/src/cborg/types/utils/4array.d.ts +0 -66
  181. package/src/cborg/types/utils/4array.d.ts.map +0 -1
  182. package/src/cborg/types/utils/5map.d.ts +0 -66
  183. package/src/cborg/types/utils/5map.d.ts.map +0 -1
  184. package/src/cborg/types/utils/6tag.d.ts +0 -62
  185. package/src/cborg/types/utils/6tag.d.ts.map +0 -1
  186. package/src/cborg/types/utils/7float.d.ts +0 -60
  187. package/src/cborg/types/utils/7float.d.ts.map +0 -1
  188. package/src/cborg/types/utils/bl.d.ts +0 -26
  189. package/src/cborg/types/utils/bl.d.ts.map +0 -1
  190. package/src/cborg/types/utils/byte-utils.d.ts +0 -53
  191. package/src/cborg/types/utils/byte-utils.d.ts.map +0 -1
  192. package/src/cborg/types/utils/common.d.ts +0 -8
  193. package/src/cborg/types/utils/common.d.ts.map +0 -1
  194. package/src/cborg/types/utils/index.d.ts +0 -13
  195. package/src/cborg/types/utils/index.d.ts.map +0 -1
  196. package/src/cborg/types/utils/jump.d.ts +0 -16
  197. package/src/cborg/types/utils/jump.d.ts.map +0 -1
  198. package/src/cborg/types/utils/token.d.ts +0 -59
  199. package/src/cborg/types/utils/token.d.ts.map +0 -1
  200. package/src/cborg/utils/0uint.js +0 -229
  201. package/src/cborg/utils/1negint.js +0 -111
  202. package/src/cborg/utils/2bytes.js +0 -135
  203. package/src/cborg/utils/3string.js +0 -90
  204. package/src/cborg/utils/4array.js +0 -114
  205. package/src/cborg/utils/5map.js +0 -113
  206. package/src/cborg/utils/6tag.js +0 -81
  207. package/src/cborg/utils/7float.js +0 -310
  208. package/src/cborg/utils/bl.js +0 -124
  209. package/src/cborg/utils/byte-utils.js +0 -417
  210. package/src/cborg/utils/common.js +0 -11
  211. package/src/cborg/utils/index.js +0 -12
  212. package/src/cborg/utils/jump.js +0 -222
  213. package/src/cborg/utils/token.js +0 -76
  214. package/src/ipfs-unixfs-exporter/LICENSE +0 -4
  215. package/src/ipfs-unixfs-exporter/README.md +0 -105
  216. package/src/ipfs-unixfs-exporter/dist/index.min.js +0 -3
  217. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
  218. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
  219. package/src/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
  220. package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
  221. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
  222. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
  223. package/src/ipfs-unixfs-exporter/dist/src/index.js +0 -197
  224. package/src/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
  225. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
  226. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
  227. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
  228. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
  229. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
  230. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
  231. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
  232. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
  233. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
  234. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
  235. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
  236. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
  237. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
  238. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
  239. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
  240. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
  241. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
  242. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
  243. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
  244. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
  245. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
  246. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
  247. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
  248. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
  249. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
  250. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
  251. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
  252. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
  253. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
  254. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
  255. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
  256. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
  257. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
  258. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
  259. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
  260. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
  261. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
  262. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
  263. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
  264. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
  265. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
  266. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
  267. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
  268. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
  269. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
  270. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
  271. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
  272. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
  273. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
  274. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
  275. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
  276. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
  277. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
  278. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
  279. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
  280. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
  281. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
  282. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
  283. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
  284. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
  285. package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
  286. package/src/ipfs-unixfs-exporter/src/errors.ts +0 -87
  287. package/src/ipfs-unixfs-exporter/src/index.ts +0 -498
  288. package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
  289. package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
  290. package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
  291. package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
  292. package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
  293. package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
  294. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
  295. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
  296. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
  297. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
  298. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
  299. package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
  300. package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
  301. package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
  302. package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
@@ -1,198 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import * as chai from 'chai'
4
-
5
- import { decode, encode } from "@fireproof/vendor/cborg"
6
- import { useBuffer, fromHex, toHex } from "@fireproof/vendor/cborg/utils"
7
-
8
- const { assert } = chai
9
-
10
- // some from https://github.com/PJK/libcbor
11
-
12
- const fixtures = [
13
- { data: '40', expected: '', type: 'bytes' },
14
- { data: '41a1', expected: 'a1', type: 'bytes' },
15
- { data: '5801a1', expected: 'a1', type: 'bytes', strict: false },
16
- {
17
- data: '58ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
18
- expected: '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
19
- type: 'bytes',
20
- label: 'long bytes, 8-bit length'
21
- },
22
- {
23
- data: '5900ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
24
- expected: '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
25
- type: 'bytes',
26
- label: 'long bytes, 16-bit length',
27
- strict: false
28
- },
29
- {
30
- data: '5a000000ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
31
- expected: '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
32
- type: 'bytes',
33
- label: 'long bytes, 32-bit length',
34
- strict: false
35
- },
36
- {
37
- data: '5b00000000000000ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
38
- expected: '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe',
39
- type: 'bytes',
40
- label: 'long bytes, 64-bit length',
41
- strict: false
42
- }
43
- ]
44
-
45
- // fill up byte arrays we can validate in strict mode, the minimal size for each
46
- // excluding 64-bit because 4G is just too big
47
- ;(() => {
48
- function rnd (length) {
49
- return new Uint8Array(Array.from({ length }, () => Math.floor(Math.random() * 255)))
50
- }
51
-
52
- const expected16 = rnd(256)
53
- fixtures.push({
54
- data: new Uint8Array([...fromHex('590100'), ...expected16]),
55
- expected: expected16,
56
- type: 'bytes',
57
- label: 'long bytes, 16-bit length strict-compat'
58
- })
59
-
60
- const expected32 = rnd(65536)
61
- fixtures.push({
62
- data: new Uint8Array([...fromHex('5a00010000'), ...expected32]),
63
- expected: expected32,
64
- type: 'bytes',
65
- label: 'long bytes, 32-bit length strict-compat'
66
- })
67
- })()
68
-
69
- describe('bytes', () => {
70
- describe('decode', () => {
71
- for (const fixture of fixtures) {
72
- const data = fromHex(fixture.data)
73
- it(`should decode ${fixture.type}=${fixture.label || fixture.expected}`, () => {
74
- let actual = decode(data)
75
- assert.strictEqual(
76
- toHex(actual),
77
- toHex(fromHex(fixture.expected)),
78
- `decode ${fixture.type}`)
79
-
80
- if (fixture.strict === false) {
81
- assert.throws(() => decode(data, { strict: true }), Error, 'CBOR decode error: integer encoded in more bytes than necessary (strict decode)')
82
- } else {
83
- actual = decode(data, { strict: true })
84
- assert.strictEqual(
85
- toHex(actual),
86
- toHex(fromHex(fixture.expected)),
87
- `decode ${fixture.type} strict`)
88
- }
89
- })
90
-
91
- it('should fail to decode very large length', () => {
92
- assert.throws(
93
- () => decode(fromHex('5ba5f702b3a5f702b3000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe')),
94
- /CBOR decode error: 64-bit integer bytes lengths not supported/)
95
- })
96
- }
97
- })
98
-
99
- describe('encode', () => {
100
- for (const fixture of fixtures) {
101
- if (fixture.data.length >= 100000000) {
102
- it.skip(`(TODO) skipping encode of very large bytes ${fixture.type}=${fixture.label || fixture.expected}`, () => {})
103
- continue
104
- }
105
-
106
- const data = fromHex(fixture.expected)
107
- const expectedHex = toHex(fixture.data)
108
-
109
- it(`should encode ${fixture.type}=${fixture.label || fixture.expected}`, () => {
110
- if (fixture.unsafe) {
111
- assert.throws(() => encode(data), Error, /^CBOR encode error: number too large to encode \(-\d+\)$/)
112
- } else if (fixture.strict === false) {
113
- assert.notStrictEqual(toHex(encode(data)), expectedHex, `encode ${fixture.type} !strict`)
114
- } else {
115
- assert.strictEqual(toHex(encode(data)), expectedHex, `encode ${fixture.type}`)
116
- }
117
- })
118
- }
119
- })
120
-
121
- describe('typedarrays', () => {
122
- const cases = [
123
- {
124
- obj: Uint8Array.from([1, 2, 3]),
125
- hex: '43010203'
126
- },
127
- {
128
- obj: Uint8ClampedArray.from([1, 2, 3]),
129
- hex: '43010203'
130
- },
131
- {
132
- obj: Uint16Array.from([1, 2, 3]),
133
- hex: '46010002000300'
134
- },
135
- {
136
- obj: Uint32Array.from([1, 2, 3]),
137
- hex: '4c010000000200000003000000'
138
- },
139
- {
140
- obj: Int8Array.from([1, 2, -3]),
141
- hex: '430102fd'
142
- },
143
- {
144
- obj: Int16Array.from([1, 2, -3]),
145
- hex: '4601000200fdff'
146
- },
147
- {
148
- obj: Int32Array.from([1, 2, -3]),
149
- hex: '4c0100000002000000fdffffff'
150
- },
151
- {
152
- obj: Float32Array.from([1, 2, -3]),
153
- hex: '4c0000803f00000040000040c0'
154
- },
155
- {
156
- obj: Float64Array.from([1, 2, -3]),
157
- hex: '5818000000000000f03f000000000000004000000000000008c0'
158
- },
159
- {
160
- obj: BigUint64Array.from([BigInt(1), BigInt(2), BigInt(3)]),
161
- hex: '5818010000000000000002000000000000000300000000000000'
162
- },
163
- {
164
- obj: BigInt64Array.from([BigInt(1), BigInt(2), BigInt(-3)]),
165
- hex: '581801000000000000000200000000000000fdffffffffffffff'
166
- },
167
- {
168
- obj: new DataView(Uint8Array.from([1, 2, 3]).buffer),
169
- hex: '43010203'
170
- },
171
- {
172
- obj: Uint8Array.from([1, 2, 3]).buffer,
173
- hex: '43010203'
174
- }
175
- ]
176
-
177
- for (const testCase of cases) {
178
- it(testCase.obj.constructor.name, () => {
179
- assert.equal(toHex(encode(testCase.obj)), testCase.hex)
180
- const decoded = decode(fromHex(testCase.hex))
181
- assert.instanceOf(decoded, Uint8Array)
182
- assert.equal(toHex(decoded), toHex(testCase.obj))
183
- })
184
- }
185
- })
186
-
187
- if (useBuffer) {
188
- describe('buffer', () => {
189
- it('can encode Node.js Buffers', () => {
190
- const obj = global.Buffer.from([1, 2, 3])
191
- assert.equal(toHex(encode(obj)), '43010203')
192
- const decoded = decode(fromHex('43010203'))
193
- assert.instanceOf(decoded, Uint8Array)
194
- assert.equal(toHex(decoded), toHex(obj))
195
- })
196
- })
197
- }
198
- })
@@ -1,136 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import * as chai from 'chai'
4
-
5
- import { decode, encode } from "@fireproof/vendor/cborg"
6
- import { fromHex, toHex } from "@fireproof/vendor/cborg/utils"
7
-
8
- const { assert } = chai
9
-
10
- // some from https://github.com/PJK/libcbor
11
-
12
- const fixtures = [
13
- { data: '60', expected: '', type: 'string' },
14
- { data: '6161', expected: 'a', type: 'string' },
15
- { data: '780161', expected: 'a', type: 'string', strict: false },
16
- {
17
- data: '6c48656c6c6f20776f726c6421',
18
- expected: 'Hello world!',
19
- type: 'string'
20
- },
21
- {
22
- data: '6fc48c6175657320c39f76c49b746521',
23
- expected: 'Čaues ßvěte!',
24
- type: 'string'
25
- },
26
- {
27
- data: '78964c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20446f6e6563206d692074656c6c75732c20696163756c6973206e656320766573746962756c756d20717569732c206665726d656e74756d206e6f6e2066656c69732e204d616563656e6173207574206a7573746f20706f73756572652e',
28
- expected: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec mi tellus, iaculis nec vestibulum quis, fermentum non felis. Maecenas ut justo posuere.',
29
- type: 'string',
30
- label: 'long string, 8-bit length'
31
- },
32
- {
33
- data: '7900964c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20446f6e6563206d692074656c6c75732c20696163756c6973206e656320766573746962756c756d20717569732c206665726d656e74756d206e6f6e2066656c69732e204d616563656e6173207574206a7573746f20706f73756572652e',
34
- expected: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec mi tellus, iaculis nec vestibulum quis, fermentum non felis. Maecenas ut justo posuere.',
35
- type: 'string',
36
- label: 'long string, 16-bit length',
37
- strict: false
38
- },
39
- {
40
- data: '7a000000964c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20446f6e6563206d692074656c6c75732c20696163756c6973206e656320766573746962756c756d20717569732c206665726d656e74756d206e6f6e2066656c69732e204d616563656e6173207574206a7573746f20706f73756572652e',
41
- expected: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec mi tellus, iaculis nec vestibulum quis, fermentum non felis. Maecenas ut justo posuere.',
42
- type: 'string',
43
- label: 'long string, 32-bit length',
44
- strict: false
45
- },
46
- {
47
- data: '7b00000000000000964c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20446f6e6563206d692074656c6c75732c20696163756c6973206e656320766573746962756c756d20717569732c206665726d656e74756d206e6f6e2066656c69732e204d616563656e6173207574206a7573746f20706f73756572652e',
48
- expected: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec mi tellus, iaculis nec vestibulum quis, fermentum non felis. Maecenas ut justo posuere.',
49
- type: 'string',
50
- label: 'long string, 64-bit length',
51
- strict: false
52
- }
53
- ]
54
-
55
- // fill up byte arrays converted to strings so we can validate in strict mode,
56
- // the minimal size for each excluding 64-bit because 4G is just too big
57
- ;(() => {
58
- function rnd (length) {
59
- const sa = []
60
- let l = 0
61
- while (l < length) {
62
- // some unicode character, unless we're near the end and want to fill up exactly so
63
- // we need to pad with ascii
64
- const ascii = (length - l) < 3
65
- const base = ascii ? 32 : 0x1f000
66
- const max = ascii ? 126 : 0x1ff00
67
- const cc = Math.floor(Math.random() * (max - base)) + base
68
- const s = String.fromCharCode(cc)
69
- l += (new TextEncoder().encode(s)).length
70
- sa.push(s)
71
- }
72
- return sa.join('')
73
- }
74
-
75
- const expected16 = rnd(256)
76
- fixtures.push({
77
- data: new Uint8Array([...fromHex('790100'), ...(new TextEncoder().encode(expected16))]),
78
- expected: expected16,
79
- type: 'string',
80
- label: 'long string, 16-bit length strict-compat'
81
- })
82
-
83
- const expected32 = rnd(65536)
84
- fixtures.push({
85
- data: new Uint8Array([...fromHex('7a00010000'), ...(new TextEncoder().encode(expected32))]),
86
- expected: expected32,
87
- type: 'string',
88
- label: 'long string, 32-bit length strict-compat'
89
- })
90
- })()
91
-
92
- describe('string', () => {
93
- describe('decode', () => {
94
- for (const fixture of fixtures) {
95
- const data = fromHex(fixture.data)
96
- it(`should decode ${fixture.type}=${fixture.label || fixture.expected}`, () => {
97
- let actual = decode(data)
98
- assert.strictEqual(actual, fixture.expected, `decode ${fixture.type}`)
99
- if (fixture.strict === false) {
100
- assert.throws(() => decode(data, { strict: true }), Error, 'CBOR decode error: integer encoded in more bytes than necessary (strict decode)')
101
- } else {
102
- actual = decode(data, { strict: true })
103
- assert.strictEqual(actual, fixture.expected, `decode ${fixture.type} strict`)
104
- }
105
- })
106
-
107
- it('should fail to decode very large length', () => {
108
- assert.throws(
109
- () => decode(fromHex('7ba5f702b3a5f702b34c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20446f6e6563206d692074656c6c75732c20696163756c6973206e656320766573746962756c756d20717569732c206665726d656e74756d206e6f6e2066656c69732e204d616563656e6173207574206a7573746f20706f73756572652e')),
110
- /CBOR decode error: 64-bit integer string lengths not supported/)
111
- })
112
- }
113
- })
114
-
115
- describe('encode', () => {
116
- for (const fixture of fixtures) {
117
- if (fixture.data.length >= 100000000) {
118
- it.skip(`(TODO) skipping encode of very large string ${fixture.type}=${fixture.label || fixture.expected}`, () => {})
119
- continue
120
- }
121
-
122
- const data = fixture.expected
123
- const expectedHex = toHex(fixture.data)
124
-
125
- it(`should encode ${fixture.type}=${fixture.label || fixture.expected}`, () => {
126
- if (fixture.unsafe) {
127
- assert.throws(() => encode(data), Error, /^CBOR encode error: number too large to encode \(-\d+\)$/)
128
- } else if (fixture.strict === false) {
129
- assert.notStrictEqual(toHex(encode(data)), expectedHex, `encode ${fixture.type} !strict`)
130
- } else {
131
- assert.strictEqual(toHex(encode(data)), expectedHex, `encode ${fixture.type}`)
132
- }
133
- })
134
- }
135
- })
136
- })
@@ -1,93 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import * as chai from 'chai'
4
-
5
- import { decode, encode } from "@fireproof/vendor/cborg"
6
- import { fromHex, toHex } from "@fireproof/vendor/cborg/utils"
7
-
8
- const { assert } = chai
9
-
10
- const fixtures = [
11
- { data: '80', expected: [], type: 'array empty' },
12
- { data: '8102', expected: [2], type: 'array 1 compact uint' },
13
- { data: '8118ff', expected: [255], type: 'array 1 uint8' },
14
- { data: '811901f4', expected: [500], type: 'array 1 uint16' },
15
- { data: '811a00010000', expected: [65536], type: 'array 1 uint32' },
16
- { data: '811b00000000000000ff', expected: [255], type: 'array 1 uint64', strict: false },
17
- { data: '811b0016db6db6db6db7', expected: [Number.MAX_SAFE_INTEGER / 1.4], type: 'array 1 uint64' },
18
- { data: '811b001fffffffffffff', expected: [Number.MAX_SAFE_INTEGER], type: 'array 1 uint64' },
19
- { data: '8403040506', expected: [3, 4, 5, 6], type: 'array 4 ints' },
20
- {
21
- data: '8c1b0016db6db6db6db71a000100001901f40200202238ff3aa5f702b33b0016db6db6db6db74261316fc48c6175657320c39f76c49b746521',
22
- expected: [Number.MAX_SAFE_INTEGER / 1.4, 65536, 500, 2, 0, -1, -3, -256, -2784428724, Number.MIN_SAFE_INTEGER / 1.4 - 1, new TextEncoder().encode('a1'), 'Čaues ßvěte!'],
23
- type: 'array mixed terminals',
24
- label: '[]'
25
- },
26
- {
27
- data: '8265617272617982626f66820582666e657374656482666172726179736121',
28
- expected: ['array', ['of', [5, ['nested', ['arrays', '!']]]]],
29
- type: 'array nested'
30
- },
31
- // testing lengths encoded as too-large ints
32
- { data: '980403040506', expected: [3, 4, 5, 6], type: 'array 4 ints, length8', strict: false },
33
- { data: '99000403040506', expected: [3, 4, 5, 6], type: 'array 4 ints, length16', strict: false },
34
- { data: '9a0000000403040506', expected: [3, 4, 5, 6], type: 'array 4 ints, length32', strict: false },
35
- { data: '9b000000000000000403040506', expected: [3, 4, 5, 6], type: 'array 4 ints, length64', strict: false }
36
- ]
37
-
38
- describe('array', () => {
39
- describe('decode', () => {
40
- for (const fixture of fixtures) {
41
- const data = fromHex(fixture.data)
42
- it(`should decode ${fixture.type}=${fixture.label || fixture.expected}`, () => {
43
- assert.deepStrictEqual(decode(data), fixture.expected, `decode ${fixture.type}`)
44
- if (fixture.strict === false) {
45
- assert.throws(() => decode(data, { strict: true }), Error, 'CBOR decode error: integer encoded in more bytes than necessary (strict decode)')
46
- } else {
47
- assert.deepStrictEqual(decode(data, { strict: true }), fixture.expected, `decode ${fixture.type}`)
48
- }
49
- })
50
-
51
- it('should fail to decode very large length', () => {
52
- assert.throws(
53
- () => decode(fromHex('9ba5f702b3a5f7020403040506')),
54
- /CBOR decode error: 64-bit integer array lengths not supported/)
55
- })
56
- }
57
- })
58
-
59
- describe('encode', () => {
60
- for (const fixture of fixtures) {
61
- it(`should encode ${fixture.type}=${fixture.label || fixture.expected}`, () => {
62
- if (fixture.unsafe) {
63
- assert.throws(encode.bind(null, fixture.expected), Error, /^CBOR encode error: number too large to encode \(\d+\)$/)
64
- } else if (fixture.strict === false) {
65
- assert.notDeepEqual(toHex(encode(fixture.expected)), fixture.data, `encode ${fixture.type} !strict`)
66
- } else {
67
- assert.strictEqual(toHex(encode(fixture.expected)), fixture.data, `encode ${fixture.type}`)
68
- }
69
- })
70
- }
71
- })
72
-
73
- // mostly unnecessary, but feels good
74
- describe('roundtrip', () => {
75
- for (const fixture of fixtures) {
76
- if (!fixture.unsafe && fixture.strict !== false) {
77
- it(`should roundtrip ${fixture.type}=${fixture.label || fixture.expected}`, () => {
78
- assert.deepStrictEqual(decode(encode(fixture.expected)), fixture.expected, `roundtrip ${fixture.type}`)
79
- })
80
- }
81
- }
82
- })
83
-
84
- describe('specials', () => {
85
- it('can decode indefinite length items', () => {
86
- assert.deepStrictEqual(decode(fromHex('9f616f6174ff')), ['o', 't'])
87
- })
88
-
89
- it('can switch off indefinite length support', () => {
90
- assert.throws(() => decode(fromHex('9f616f6174ff'), { allowIndefinite: false }), /indefinite/)
91
- })
92
- })
93
- })