@fireproof/vendor 1.1.1 → 1.2.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 (302) hide show
  1. package/package.json +109 -19
  2. package/src/@ipld/car/LICENSE +4 -0
  3. package/src/@ipld/car/README.md +1132 -0
  4. package/src/@ipld/car/dist/index.min.js +5 -0
  5. package/src/@ipld/car/dist/src/api.d.ts +72 -0
  6. package/src/@ipld/car/dist/src/api.d.ts.map +1 -0
  7. package/src/@ipld/car/dist/src/buffer-decoder.d.ts +67 -0
  8. package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +1 -0
  9. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +116 -0
  10. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +1 -0
  11. package/src/@ipld/car/dist/src/buffer-reader.d.ts +31 -0
  12. package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +1 -0
  13. package/src/@ipld/car/dist/src/buffer-writer.d.ts +86 -0
  14. package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +1 -0
  15. package/src/@ipld/car/dist/src/coding.d.ts +49 -0
  16. package/src/@ipld/car/dist/src/coding.d.ts.map +1 -0
  17. package/src/@ipld/car/dist/src/decoder-common.d.ts +43 -0
  18. package/src/@ipld/car/dist/src/decoder-common.d.ts.map +1 -0
  19. package/src/@ipld/car/dist/src/decoder.d.ts +87 -0
  20. package/src/@ipld/car/dist/src/decoder.d.ts.map +1 -0
  21. package/src/@ipld/car/dist/src/encoder.d.ts +17 -0
  22. package/src/@ipld/car/dist/src/encoder.d.ts.map +1 -0
  23. package/src/@ipld/car/dist/src/header-validator.d.ts +5 -0
  24. package/src/@ipld/car/dist/src/header-validator.d.ts.map +1 -0
  25. package/src/@ipld/car/dist/src/index-browser.d.ts +10 -0
  26. package/src/@ipld/car/dist/src/index-browser.d.ts.map +1 -0
  27. package/src/@ipld/car/dist/src/index.d.ts +11 -0
  28. package/src/@ipld/car/dist/src/index.d.ts.map +1 -0
  29. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +5 -0
  30. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +1 -0
  31. package/src/@ipld/car/dist/src/indexed-reader.d.ts +152 -0
  32. package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +1 -0
  33. package/src/@ipld/car/dist/src/indexer.d.ts +95 -0
  34. package/src/@ipld/car/dist/src/indexer.d.ts.map +1 -0
  35. package/src/@ipld/car/dist/src/iterator-channel.d.ts +7 -0
  36. package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +1 -0
  37. package/src/@ipld/car/dist/src/iterator.d.ts +174 -0
  38. package/src/@ipld/car/dist/src/iterator.d.ts.map +1 -0
  39. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +28 -0
  40. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +1 -0
  41. package/src/@ipld/car/dist/src/reader-browser.d.ts +151 -0
  42. package/src/@ipld/car/dist/src/reader-browser.d.ts.map +1 -0
  43. package/src/@ipld/car/dist/src/reader.d.ts +40 -0
  44. package/src/@ipld/car/dist/src/reader.d.ts.map +1 -0
  45. package/src/@ipld/car/dist/src/writer-browser.d.ts +155 -0
  46. package/src/@ipld/car/dist/src/writer-browser.d.ts.map +1 -0
  47. package/src/@ipld/car/dist/src/writer.d.ts +45 -0
  48. package/src/@ipld/car/dist/src/writer.d.ts.map +1 -0
  49. package/src/@ipld/car/src/api.ts +90 -0
  50. package/src/@ipld/car/src/buffer-decoder.js +213 -0
  51. package/src/@ipld/car/src/buffer-reader-browser.js +144 -0
  52. package/src/@ipld/car/src/buffer-reader.js +51 -0
  53. package/src/@ipld/car/src/buffer-writer.js +286 -0
  54. package/src/@ipld/car/src/coding.ts +68 -0
  55. package/src/@ipld/car/src/decoder-common.js +82 -0
  56. package/src/@ipld/car/src/decoder.js +347 -0
  57. package/src/@ipld/car/src/encoder.js +76 -0
  58. package/src/@ipld/car/src/header-validator.js +214 -0
  59. package/src/@ipld/car/src/header.ipldsch +18 -0
  60. package/src/@ipld/car/src/index-browser.js +18 -0
  61. package/src/@ipld/car/src/index.js +21 -0
  62. package/src/@ipld/car/src/indexed-reader-browser.js +7 -0
  63. package/src/@ipld/car/src/indexed-reader.js +211 -0
  64. package/src/@ipld/car/src/indexer.js +130 -0
  65. package/src/@ipld/car/src/iterator-channel.js +91 -0
  66. package/src/@ipld/car/src/iterator.js +267 -0
  67. package/src/@ipld/car/src/promise-fs-opts.js +46 -0
  68. package/src/@ipld/car/src/reader-browser.js +194 -0
  69. package/src/@ipld/car/src/reader.js +54 -0
  70. package/src/@ipld/car/src/writer-browser.js +250 -0
  71. package/src/@ipld/car/src/writer.js +81 -0
  72. package/src/@ipld/dag-cbor/LICENSE +4 -0
  73. package/src/@ipld/dag-cbor/README.md +80 -0
  74. package/src/@ipld/dag-cbor/dist/index.min.js +3 -0
  75. package/src/@ipld/dag-cbor/dist/src/index.d.ts +67 -0
  76. package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +1 -0
  77. package/src/@ipld/dag-cbor/src/index.js +147 -0
  78. package/src/@ipld/dag-json/LICENSE +4 -0
  79. package/src/@ipld/dag-json/README.md +58 -0
  80. package/src/@ipld/dag-json/dist/index.min.js +3 -0
  81. package/src/@ipld/dag-json/dist/src/index.d.ts +12 -0
  82. package/src/@ipld/dag-json/dist/src/index.d.ts.map +1 -0
  83. package/src/@ipld/dag-json/src/index.js +291 -0
  84. package/src/@web3-storage/pail/dist/src/batch/index.d.ts +53 -1
  85. package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
  86. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
  87. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
  88. package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
  89. package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
  90. package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
  91. package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
  92. package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
  93. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
  94. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
  95. package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
  96. package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
  97. package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
  98. package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
  99. package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
  100. package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
  101. package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
  102. package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
  103. package/src/@web3-storage/pail/src/api.ts +1 -1
  104. package/src/@web3-storage/pail/src/clock/index.js +1 -1
  105. package/src/@web3-storage/pail/src/shard.js +1 -1
  106. package/src/cborg/.github/dependabot.yml +16 -0
  107. package/src/cborg/.github/workflows/test-and-release.yml +52 -0
  108. package/src/cborg/CHANGELOG.md +513 -0
  109. package/src/cborg/LICENSE +13 -0
  110. package/src/cborg/README.md +515 -0
  111. package/src/cborg/bench/bench.js +117 -0
  112. package/src/cborg/bench/json.js +124 -0
  113. package/src/cborg/bench/package.json +8 -0
  114. package/src/cborg/cborg/bin.js +189 -0
  115. package/src/cborg/cborg/common.js +28 -0
  116. package/src/cborg/cborg/decode.js +211 -0
  117. package/src/cborg/cborg/diagnostic.js +158 -0
  118. package/src/cborg/cborg/diagnostic_test.js +117 -0
  119. package/src/cborg/cborg/encode.js +466 -0
  120. package/src/cborg/cborg/index.js +33 -0
  121. package/src/cborg/cborg/is.js +106 -0
  122. package/src/cborg/cborg/length.js +62 -0
  123. package/src/cborg/example-bytestrings.js +180 -0
  124. package/src/cborg/example-json.js +6 -0
  125. package/src/cborg/example.js +5 -0
  126. package/src/cborg/interface.ts +59 -0
  127. package/src/cborg/json/decode.js +462 -0
  128. package/src/cborg/json/encode.js +302 -0
  129. package/src/cborg/json/json.js +4 -0
  130. package/src/cborg/taglib.js +75 -0
  131. package/src/cborg/test/appendix_a.js +647 -0
  132. package/src/cborg/test/common.js +18 -0
  133. package/src/cborg/test/node-test-bin.js +402 -0
  134. package/src/cborg/test/noop-bin-test.js +3 -0
  135. package/src/cborg/test/test-0uint.js +103 -0
  136. package/src/cborg/test/test-1negint.js +96 -0
  137. package/src/cborg/test/test-2bytes.js +198 -0
  138. package/src/cborg/test/test-3string.js +136 -0
  139. package/src/cborg/test/test-4array.js +93 -0
  140. package/src/cborg/test/test-5map.js +284 -0
  141. package/src/cborg/test/test-6tag.js +84 -0
  142. package/src/cborg/test/test-7float.js +131 -0
  143. package/src/cborg/test/test-bl.js +37 -0
  144. package/src/cborg/test/test-cbor-vectors.js +107 -0
  145. package/src/cborg/test/test-decode-errors.js +65 -0
  146. package/src/cborg/test/test-fuzz.js +42 -0
  147. package/src/cborg/test/test-json.js +219 -0
  148. package/src/cborg/test/test-length.js +65 -0
  149. package/src/cborg/test/test-partial.js +111 -0
  150. package/src/cborg/tsconfig.json +48 -0
  151. package/src/cborg/types/cborg/decode.d.ts +43 -0
  152. package/src/cborg/types/cborg/decode.d.ts.map +1 -0
  153. package/src/cborg/types/cborg/encode.d.ts +51 -0
  154. package/src/cborg/types/cborg/encode.d.ts.map +1 -0
  155. package/src/cborg/types/cborg/index.d.ts +26 -0
  156. package/src/cborg/types/cborg/index.d.ts.map +1 -0
  157. package/src/cborg/types/cborg/is.d.ts +6 -0
  158. package/src/cborg/types/cborg/is.d.ts.map +1 -0
  159. package/src/cborg/types/example.d.ts +2 -0
  160. package/src/cborg/types/example.d.ts.map +1 -0
  161. package/src/cborg/types/interface.d.ts +49 -0
  162. package/src/cborg/types/interface.d.ts.map +1 -0
  163. package/src/cborg/types/json/decode.d.ts +67 -0
  164. package/src/cborg/types/json/decode.d.ts.map +1 -0
  165. package/src/cborg/types/json/encode.d.ts +11 -0
  166. package/src/cborg/types/json/encode.d.ts.map +1 -0
  167. package/src/cborg/types/json/json.d.ts +6 -0
  168. package/src/cborg/types/json/json.d.ts.map +1 -0
  169. package/src/cborg/types/taglib.d.ts +18 -0
  170. package/src/cborg/types/taglib.d.ts.map +1 -0
  171. package/src/cborg/types/tsconfig.tsbuildinfo +1 -0
  172. package/src/cborg/types/utils/0uint.d.ts +102 -0
  173. package/src/cborg/types/utils/0uint.d.ts.map +1 -0
  174. package/src/cborg/types/utils/1negint.d.ts +59 -0
  175. package/src/cborg/types/utils/1negint.d.ts.map +1 -0
  176. package/src/cborg/types/utils/2bytes.d.ts +69 -0
  177. package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
  178. package/src/cborg/types/utils/3string.d.ts +46 -0
  179. package/src/cborg/types/utils/3string.d.ts.map +1 -0
  180. package/src/cborg/types/utils/4array.d.ts +66 -0
  181. package/src/cborg/types/utils/4array.d.ts.map +1 -0
  182. package/src/cborg/types/utils/5map.d.ts +66 -0
  183. package/src/cborg/types/utils/5map.d.ts.map +1 -0
  184. package/src/cborg/types/utils/6tag.d.ts +62 -0
  185. package/src/cborg/types/utils/6tag.d.ts.map +1 -0
  186. package/src/cborg/types/utils/7float.d.ts +60 -0
  187. package/src/cborg/types/utils/7float.d.ts.map +1 -0
  188. package/src/cborg/types/utils/bl.d.ts +26 -0
  189. package/src/cborg/types/utils/bl.d.ts.map +1 -0
  190. package/src/cborg/types/utils/byte-utils.d.ts +53 -0
  191. package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
  192. package/src/cborg/types/utils/common.d.ts +8 -0
  193. package/src/cborg/types/utils/common.d.ts.map +1 -0
  194. package/src/cborg/types/utils/index.d.ts +13 -0
  195. package/src/cborg/types/utils/index.d.ts.map +1 -0
  196. package/src/cborg/types/utils/jump.d.ts +16 -0
  197. package/src/cborg/types/utils/jump.d.ts.map +1 -0
  198. package/src/cborg/types/utils/token.d.ts +59 -0
  199. package/src/cborg/types/utils/token.d.ts.map +1 -0
  200. package/src/cborg/utils/0uint.js +229 -0
  201. package/src/cborg/utils/1negint.js +111 -0
  202. package/src/cborg/utils/2bytes.js +135 -0
  203. package/src/cborg/utils/3string.js +90 -0
  204. package/src/cborg/utils/4array.js +114 -0
  205. package/src/cborg/utils/5map.js +113 -0
  206. package/src/cborg/utils/6tag.js +81 -0
  207. package/src/cborg/utils/7float.js +310 -0
  208. package/src/cborg/utils/bl.js +124 -0
  209. package/src/cborg/utils/byte-utils.js +417 -0
  210. package/src/cborg/utils/common.js +11 -0
  211. package/src/cborg/utils/index.js +12 -0
  212. package/src/cborg/utils/jump.js +222 -0
  213. package/src/cborg/utils/token.js +76 -0
  214. package/src/ipfs-unixfs-exporter/LICENSE +4 -0
  215. package/src/ipfs-unixfs-exporter/README.md +105 -0
  216. package/src/ipfs-unixfs-exporter/dist/index.min.js +3 -0
  217. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +57 -0
  218. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +1 -0
  219. package/src/ipfs-unixfs-exporter/dist/src/errors.js +73 -0
  220. package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +1 -0
  221. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +355 -0
  222. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +1 -0
  223. package/src/ipfs-unixfs-exporter/dist/src/index.js +197 -0
  224. package/src/ipfs-unixfs-exporter/dist/src/index.js.map +1 -0
  225. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +4 -0
  226. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +1 -0
  227. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +9 -0
  228. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +1 -0
  229. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +4 -0
  230. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +1 -0
  231. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +9 -0
  232. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +1 -0
  233. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +4 -0
  234. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +1 -0
  235. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +38 -0
  236. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +1 -0
  237. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +4 -0
  238. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +1 -0
  239. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +30 -0
  240. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +1 -0
  241. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +4 -0
  242. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +1 -0
  243. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +9 -0
  244. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +1 -0
  245. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +4 -0
  246. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +1 -0
  247. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +37 -0
  248. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +1 -0
  249. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +4 -0
  250. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +1 -0
  251. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +29 -0
  252. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +1 -0
  253. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +4 -0
  254. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +1 -0
  255. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +153 -0
  256. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +1 -0
  257. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +4 -0
  258. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +1 -0
  259. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +59 -0
  260. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +1 -0
  261. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +4 -0
  262. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +1 -0
  263. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +25 -0
  264. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +1 -0
  265. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +4 -0
  266. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +1 -0
  267. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +104 -0
  268. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +1 -0
  269. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +3 -0
  270. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +1 -0
  271. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +20 -0
  272. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +1 -0
  273. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +6 -0
  274. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +1 -0
  275. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +116 -0
  276. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +1 -0
  277. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +4 -0
  278. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +1 -0
  279. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +57 -0
  280. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +1 -0
  281. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +6 -0
  282. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +1 -0
  283. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +30 -0
  284. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +1 -0
  285. package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +58 -0
  286. package/src/ipfs-unixfs-exporter/src/errors.ts +87 -0
  287. package/src/ipfs-unixfs-exporter/src/index.ts +498 -0
  288. package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +12 -0
  289. package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +12 -0
  290. package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +49 -0
  291. package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +35 -0
  292. package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +12 -0
  293. package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +49 -0
  294. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +39 -0
  295. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +198 -0
  296. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +76 -0
  297. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +37 -0
  298. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +121 -0
  299. package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +24 -0
  300. package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +149 -0
  301. package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +62 -0
  302. package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +38 -0
@@ -0,0 +1,498 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * The UnixFS Exporter provides a means to read DAGs from a blockstore given a CID.
5
+ *
6
+ * @example
7
+ *
8
+ * ```js
9
+ * // import a file and export it again
10
+ * import { importer } from 'ipfs-unixfs-importer'
11
+ * import { exporter } from 'ipfs-unixfs-exporter'
12
+ * import { MemoryBlockstore } from 'blockstore-core/memory'
13
+ *
14
+ * // Should contain the blocks we are trying to export
15
+ * const blockstore = new MemoryBlockstore()
16
+ * const files = []
17
+ *
18
+ * for await (const file of importer([{
19
+ * path: '/foo/bar.txt',
20
+ * content: new Uint8Array([0, 1, 2, 3])
21
+ * }], blockstore)) {
22
+ * files.push(file)
23
+ * }
24
+ *
25
+ * console.info(files[0].cid) // Qmbaz
26
+ *
27
+ * const entry = await exporter(files[0].cid, blockstore)
28
+ *
29
+ * console.info(entry.cid) // Qmqux
30
+ * console.info(entry.path) // Qmbaz/foo/bar.txt
31
+ * console.info(entry.name) // bar.txt
32
+ * console.info(entry.unixfs.fileSize()) // 4
33
+ *
34
+ * // stream content from unixfs node
35
+ * const size = entry.unixfs.fileSize()
36
+ * const bytes = new Uint8Array(size)
37
+ * let offset = 0
38
+ *
39
+ * for await (const buf of entry.content()) {
40
+ * bytes.set(buf, offset)
41
+ * offset += chunk.length
42
+ * }
43
+ *
44
+ * console.info(bytes) // 0, 1, 2, 3
45
+ * ```
46
+ */
47
+
48
+ import last from 'it-last'
49
+ import { CID } from 'multiformats/cid'
50
+ import { BadPathError, NotFoundError } from './errors.js'
51
+ import resolve from './resolvers/index.js'
52
+ import type { PBNode } from '@ipld/dag-pb'
53
+ import type { Bucket } from 'hamt-sharding'
54
+ import type { Blockstore } from 'interface-blockstore'
55
+ import type { UnixFS } from 'ipfs-unixfs'
56
+ import type { ProgressOptions, ProgressEvent } from 'progress-events'
57
+
58
+ export * from './errors.js'
59
+
60
+ export interface ExportProgress {
61
+ /**
62
+ * How many bytes of the file have been read
63
+ */
64
+ bytesRead: bigint
65
+
66
+ /**
67
+ * How many bytes of the file will be read - n.b. this may be
68
+ * smaller than `fileSize` if `offset`/`length` have been
69
+ * specified
70
+ */
71
+ totalBytes: bigint
72
+
73
+ /**
74
+ * The size of the file being read - n.b. this may be
75
+ * larger than `total` if `offset`/`length` has been
76
+ * specified
77
+ */
78
+ fileSize: bigint
79
+ }
80
+
81
+ export interface ExportWalk {
82
+ cid: CID
83
+ }
84
+
85
+ /**
86
+ * Progress events emitted by the exporter
87
+ */
88
+ export type ExporterProgressEvents =
89
+ ProgressEvent<'unixfs:exporter:progress:unixfs:file', ExportProgress> |
90
+ ProgressEvent<'unixfs:exporter:progress:unixfs:raw', ExportProgress> |
91
+ ProgressEvent<'unixfs:exporter:progress:raw', ExportProgress> |
92
+ ProgressEvent<'unixfs:exporter:progress:identity', ExportProgress> |
93
+ ProgressEvent<'unixfs:exporter:walk:file', ExportWalk> |
94
+ ProgressEvent<'unixfs:exporter:walk:directory', ExportWalk> |
95
+ ProgressEvent<'unixfs:exporter:walk:hamt-sharded-directory', ExportWalk> |
96
+ ProgressEvent<'unixfs:exporter:walk:raw', ExportWalk>
97
+
98
+ export interface ExporterOptions extends ProgressOptions<ExporterProgressEvents> {
99
+ /**
100
+ * An optional offset to start reading at.
101
+ *
102
+ * If the CID resolves to a file this will be a byte offset within that file,
103
+ * otherwise if it's a directory it will be a directory entry offset within
104
+ * the directory listing. (default: undefined)
105
+ */
106
+ offset?: number
107
+
108
+ /**
109
+ * An optional length to read.
110
+ *
111
+ * If the CID resolves to a file this will be the number of bytes read from
112
+ * the file, otherwise if it's a directory it will be the number of directory
113
+ * entries read from the directory listing. (default: undefined)
114
+ */
115
+ length?: number
116
+
117
+ /**
118
+ * This signal can be used to abort any long-lived operations such as fetching
119
+ * blocks from the network. (default: undefined)
120
+ */
121
+ signal?: AbortSignal
122
+
123
+ /**
124
+ * When a DAG layer is encountered, all child nodes are loaded in parallel but
125
+ * processed as they arrive. This allows us to load sibling nodes in advance
126
+ * of yielding their bytes. Pass a value here to control the number of blocks
127
+ * loaded in parallel. If a strict depth-first traversal is required, this
128
+ * value should be set to `1`, otherwise the traversal order will tend to
129
+ * resemble a breadth-first fan-out and yield a have stable ordering.
130
+ * (default: undefined)
131
+ */
132
+ blockReadConcurrency?: number
133
+ }
134
+
135
+ export interface Exportable<T> {
136
+ /**
137
+ * A disambiguator to allow TypeScript to work out the type of the entry.
138
+ *
139
+ * @example
140
+ *
141
+ * ```TypeScript
142
+ * if (entry.type === 'file') {
143
+ * // access UnixFSFile properties safely
144
+ * }
145
+ *
146
+ * if (entry.type === 'directory') {
147
+ * // access UnixFSDirectory properties safely
148
+ * }
149
+ * ```
150
+ */
151
+ type: 'file' | 'directory' | 'object' | 'raw' | 'identity'
152
+
153
+ /**
154
+ * The name of the entry
155
+ */
156
+ name: string
157
+
158
+ /**
159
+ * The path of the entry within the DAG in which it was encountered
160
+ */
161
+ path: string
162
+
163
+ /**
164
+ * The CID of the entry
165
+ */
166
+ cid: CID
167
+
168
+ /**
169
+ * How far down the DAG the entry is
170
+ */
171
+ depth: number
172
+
173
+ /**
174
+ * The size of the entry
175
+ */
176
+ size: bigint
177
+
178
+ /**
179
+ * @example File content
180
+ *
181
+ * When `entry` is a file or a `raw` node, `offset` and/or `length` arguments can be passed to `entry.content()` to return slices of data:
182
+ *
183
+ * ```javascript
184
+ * const length = 5
185
+ * const data = new Uint8Array(length)
186
+ * let offset = 0
187
+ *
188
+ * for await (const chunk of entry.content({
189
+ * offset: 0,
190
+ * length
191
+ * })) {
192
+ * data.set(chunk, offset)
193
+ * offset += chunk.length
194
+ * }
195
+ *
196
+ * // `data` contains the first 5 bytes of the file
197
+ * return data
198
+ * ```
199
+ *
200
+ * @example Directory content
201
+ *
202
+ * If `entry` is a directory, passing `offset` and/or `length` to `entry.content()` will limit the number of files returned from the directory.
203
+ *
204
+ * ```javascript
205
+ * const entries = []
206
+ *
207
+ * for await (const entry of dir.content({
208
+ * offset: 0,
209
+ * length: 5
210
+ * })) {
211
+ * entries.push(entry)
212
+ * }
213
+ *
214
+ * // `entries` contains the first 5 files/directories in the directory
215
+ * ```
216
+ */
217
+ content(options?: ExporterOptions): AsyncGenerator<T, void, unknown>
218
+ }
219
+
220
+ /**
221
+ * If the entry is a file, `entry.content()` returns an async iterator that yields one or more Uint8Arrays containing the file content:
222
+ *
223
+ * ```javascript
224
+ * if (entry.type === 'file') {
225
+ * for await (const chunk of entry.content()) {
226
+ * // chunk is a Buffer
227
+ * }
228
+ * }
229
+ * ```
230
+ */
231
+ export interface UnixFSFile extends Exportable<Uint8Array> {
232
+ type: 'file'
233
+ unixfs: UnixFS
234
+ node: PBNode
235
+ }
236
+
237
+ /**
238
+ * If the entry is a directory, `entry.content()` returns further `entry` objects:
239
+ *
240
+ * ```javascript
241
+ * if (entry.type === 'directory') {
242
+ * for await (const entry of dir.content()) {
243
+ * console.info(entry.name)
244
+ * }
245
+ * }
246
+ * ```
247
+ */
248
+ export interface UnixFSDirectory extends Exportable<UnixFSEntry> {
249
+ type: 'directory'
250
+ unixfs: UnixFS
251
+ node: PBNode
252
+ }
253
+
254
+ /**
255
+ * Entries with a `dag-cbor` or `dag-json` codec {@link CID} return JavaScript object entries
256
+ */
257
+ export interface ObjectNode extends Exportable<any> {
258
+ type: 'object'
259
+ node: Uint8Array
260
+ }
261
+
262
+ /**
263
+ * Entries with a `raw` codec {@link CID} return raw entries.
264
+ *
265
+ * `entry.content()` returns an async iterator that yields a buffer containing the node content:
266
+ *
267
+ * ```javascript
268
+ * for await (const chunk of entry.content()) {
269
+ * // chunk is a Buffer
270
+ * }
271
+ * ```
272
+ *
273
+ * Unless you an options object containing `offset` and `length` keys as an argument to `entry.content()`, `chunk` will be equal to `entry.node`.
274
+ */
275
+ export interface RawNode extends Exportable<Uint8Array> {
276
+ type: 'raw'
277
+ node: Uint8Array
278
+ }
279
+
280
+ /**
281
+ * Entries with a `identity` codec {@link CID} return identity entries.
282
+ *
283
+ * These are entries where the data payload is stored in the CID itself,
284
+ * otherwise they are identical to {@link RawNode}s.
285
+ */
286
+ export interface IdentityNode extends Exportable<Uint8Array> {
287
+ type: 'identity'
288
+ node: Uint8Array
289
+ }
290
+
291
+ /**
292
+ * A UnixFSEntry is a representation of the types of node that can be
293
+ * encountered in a DAG.
294
+ */
295
+ export type UnixFSEntry = UnixFSFile | UnixFSDirectory | ObjectNode | RawNode | IdentityNode
296
+
297
+ export interface NextResult {
298
+ cid: CID
299
+ name: string
300
+ path: string
301
+ toResolve: string[]
302
+ }
303
+
304
+ export interface ResolveResult {
305
+ entry: UnixFSEntry
306
+ next?: NextResult
307
+ }
308
+
309
+ export interface Resolve { (cid: CID, name: string, path: string, toResolve: string[], depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult> }
310
+ export interface Resolver { (cid: CID, name: string, path: string, toResolve: string[], resolve: Resolve, depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult> }
311
+
312
+ export type UnixfsV1FileContent = AsyncIterable<Uint8Array> | Iterable<Uint8Array>
313
+ export type UnixfsV1DirectoryContent = AsyncIterable<UnixFSEntry> | Iterable<UnixFSEntry>
314
+ export type UnixfsV1Content = UnixfsV1FileContent | UnixfsV1DirectoryContent
315
+ export interface UnixfsV1Resolver { (cid: CID, node: PBNode, unixfs: UnixFS, path: string, resolve: Resolve, depth: number, blockstore: ReadableStorage): (options: ExporterOptions) => UnixfsV1Content }
316
+
317
+ export interface ShardTraversalContext {
318
+ hamtDepth: number
319
+ rootBucket: Bucket<boolean>
320
+ lastBucket: Bucket<boolean>
321
+ }
322
+
323
+ /**
324
+ * A subset of the {@link Blockstore} interface that just contains the get
325
+ * method.
326
+ */
327
+ export type ReadableStorage = Pick<Blockstore, 'get'>
328
+
329
+ const toPathComponents = (path: string = ''): string[] => {
330
+ // split on / unless escaped with \
331
+ return (path
332
+ .trim()
333
+ .match(/([^\\^/]|\\\/)+/g) ?? [])
334
+ .filter(Boolean);
335
+ }
336
+
337
+ const cidAndRest = (path: string | Uint8Array | CID): { cid: CID, toResolve: string[] } => {
338
+ if (path instanceof Uint8Array) {
339
+ return {
340
+ cid: CID.decode(path),
341
+ toResolve: []
342
+ }
343
+ }
344
+
345
+ const cid = CID.asCID(path)
346
+ if (cid != null) {
347
+ return {
348
+ cid,
349
+ toResolve: []
350
+ }
351
+ }
352
+
353
+ if (typeof path === 'string') {
354
+ if (path.indexOf('/ipfs/') === 0) {
355
+ path = path.substring(6)
356
+ }
357
+
358
+ const output = toPathComponents(path)
359
+
360
+ return {
361
+ cid: CID.parse(output[0]),
362
+ toResolve: output.slice(1)
363
+ }
364
+ }
365
+
366
+ throw new BadPathError(`Unknown path type ${path}`)
367
+ }
368
+
369
+ /**
370
+ * Returns an async iterator that yields entries for all segments in a path
371
+ *
372
+ * @example
373
+ *
374
+ * ```javascript
375
+ * import { walkPath } from 'ipfs-unixfs-exporter'
376
+ *
377
+ * const entries = []
378
+ *
379
+ * for await (const entry of walkPath('Qmfoo/foo/bar/baz.txt', blockstore)) {
380
+ * entries.push(entry)
381
+ * }
382
+ *
383
+ * // entries contains 4x `entry` objects
384
+ * ```
385
+ */
386
+ export async function * walkPath (path: string | CID, blockstore: ReadableStorage, options: ExporterOptions = {}): AsyncGenerator<UnixFSEntry, void, any> {
387
+ let {
388
+ cid,
389
+ toResolve
390
+ } = cidAndRest(path)
391
+ let name = cid.toString()
392
+ let entryPath = name
393
+ const startingDepth = toResolve.length
394
+
395
+ while (true) {
396
+ const result = await resolve(cid, name, entryPath, toResolve, startingDepth, blockstore, options)
397
+
398
+ if (result.entry == null && result.next == null) {
399
+ throw new NotFoundError(`Could not resolve ${path}`)
400
+ }
401
+
402
+ if (result.entry != null) {
403
+ yield result.entry
404
+ }
405
+
406
+ if (result.next == null) {
407
+ return
408
+ }
409
+
410
+ // resolve further parts
411
+ toResolve = result.next.toResolve
412
+ cid = result.next.cid
413
+ name = result.next.name
414
+ entryPath = result.next.path
415
+ }
416
+ }
417
+
418
+ /**
419
+ * Uses the given blockstore instance to fetch an IPFS node by a CID or path.
420
+ *
421
+ * Returns a {@link Promise} which resolves to a {@link UnixFSEntry}.
422
+ *
423
+ * @example
424
+ *
425
+ * ```typescript
426
+ * import { exporter } from 'ipfs-unixfs-exporter'
427
+ * import { CID } from 'multiformats/cid'
428
+ *
429
+ * const cid = CID.parse('QmFoo')
430
+ *
431
+ * const entry = await exporter(cid, blockstore, {
432
+ * signal: AbortSignal.timeout(50000)
433
+ * })
434
+ *
435
+ * if (entry.type === 'file') {
436
+ * for await (const chunk of entry.content()) {
437
+ * // chunk is a Uint8Array
438
+ * }
439
+ * }
440
+ * ```
441
+ */
442
+ export async function exporter (path: string | CID, blockstore: ReadableStorage, options: ExporterOptions = {}): Promise<UnixFSEntry> {
443
+ const result = await last(walkPath(path, blockstore, options))
444
+
445
+ if (result == null) {
446
+ throw new NotFoundError(`Could not resolve ${path}`)
447
+ }
448
+
449
+ return result
450
+ }
451
+
452
+ /**
453
+ * Returns an async iterator that yields all entries beneath a given CID or IPFS
454
+ * path, as well as the containing directory.
455
+ *
456
+ * @example
457
+ *
458
+ * ```typescript
459
+ * import { recursive } from 'ipfs-unixfs-exporter'
460
+ *
461
+ * const entries = []
462
+ *
463
+ * for await (const child of recursive('Qmfoo/foo/bar', blockstore)) {
464
+ * entries.push(entry)
465
+ * }
466
+ *
467
+ * // entries contains all children of the `Qmfoo/foo/bar` directory and it's children
468
+ * ```
469
+ */
470
+ export async function * recursive (path: string | CID, blockstore: ReadableStorage, options: ExporterOptions = {}): AsyncGenerator<UnixFSEntry, void, any> {
471
+ const node = await exporter(path, blockstore, options)
472
+
473
+ if (node == null) {
474
+ return
475
+ }
476
+
477
+ yield node
478
+
479
+ if (node.type === 'directory') {
480
+ for await (const child of recurse(node, options)) {
481
+ yield child
482
+ }
483
+ }
484
+
485
+ async function * recurse (node: UnixFSDirectory, options: ExporterOptions): AsyncGenerator<UnixFSEntry, void, any> {
486
+ for await (const file of node.content(options)) {
487
+ yield file
488
+
489
+ if (file instanceof Uint8Array) {
490
+ continue
491
+ }
492
+
493
+ if (file.type === 'directory') {
494
+ yield * recurse(file, options)
495
+ }
496
+ }
497
+ }
498
+ }
@@ -0,0 +1,12 @@
1
+ import * as dagCbor from "@fireproof/vendor/@ipld/dag-cbor"
2
+ import { resolveObjectPath } from '../utils/resolve-object-path.js'
3
+ import type { Resolver } from '../index.js'
4
+
5
+ const resolve: Resolver = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
6
+ const block = await blockstore.get(cid, options)
7
+ const object = dagCbor.decode<any>(block)
8
+
9
+ return resolveObjectPath(object, block, cid, name, path, toResolve, depth)
10
+ }
11
+
12
+ export default resolve
@@ -0,0 +1,12 @@
1
+ import * as dagJson from "@fireproof/vendor/@ipld/dag-json"
2
+ import { resolveObjectPath } from '../utils/resolve-object-path.js'
3
+ import type { Resolver } from '../index.js'
4
+
5
+ const resolve: Resolver = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
6
+ const block = await blockstore.get(cid, options)
7
+ const object = dagJson.decode<any>(block)
8
+
9
+ return resolveObjectPath(object, block, cid, name, path, toResolve, depth)
10
+ }
11
+
12
+ export default resolve
@@ -0,0 +1,49 @@
1
+ import * as mh from 'multiformats/hashes/digest'
2
+ import { CustomProgressEvent } from 'progress-events'
3
+ import { NotFoundError } from '../errors.js'
4
+ import extractDataFromBlock from '../utils/extract-data-from-block.js'
5
+ import validateOffsetAndLength from '../utils/validate-offset-and-length.js'
6
+ import type { ExporterOptions, Resolver, ExportProgress } from '../index.js'
7
+
8
+ const rawContent = (node: Uint8Array): ((options?: ExporterOptions) => AsyncGenerator<Uint8Array, void, undefined>) => {
9
+ async function * contentGenerator (options: ExporterOptions = {}): AsyncGenerator<Uint8Array, void, undefined> {
10
+ const {
11
+ start,
12
+ end
13
+ } = validateOffsetAndLength(node.length, options.offset, options.length)
14
+
15
+ const buf = extractDataFromBlock(node, 0n, start, end)
16
+
17
+ options.onProgress?.(new CustomProgressEvent<ExportProgress>('unixfs:exporter:progress:identity', {
18
+ bytesRead: BigInt(buf.byteLength),
19
+ totalBytes: end - start,
20
+ fileSize: BigInt(node.byteLength)
21
+ }))
22
+
23
+ yield buf
24
+ }
25
+
26
+ return contentGenerator
27
+ }
28
+
29
+ const resolve: Resolver = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
30
+ if (toResolve.length > 0) {
31
+ throw new NotFoundError(`No link named ${path} found in raw node ${cid}`)
32
+ }
33
+ const buf = mh.decode(cid.multihash.bytes)
34
+
35
+ return {
36
+ entry: {
37
+ type: 'identity',
38
+ name,
39
+ path,
40
+ cid,
41
+ content: rawContent(buf.digest),
42
+ depth,
43
+ size: BigInt(buf.digest.length),
44
+ node: buf.digest
45
+ }
46
+ }
47
+ }
48
+
49
+ export default resolve
@@ -0,0 +1,35 @@
1
+ import * as dagCbor from "@fireproof/vendor/@ipld/dag-cbor"
2
+ import * as dagJson from "@fireproof/vendor/@ipld/dag-json"
3
+ import * as dagPb from '@ipld/dag-pb'
4
+ import * as json from 'multiformats/codecs/json'
5
+ import * as raw from 'multiformats/codecs/raw'
6
+ import { identity } from 'multiformats/hashes/identity'
7
+ import { NoResolverError } from '../errors.js'
8
+ import dagCborResolver from './dag-cbor.js'
9
+ import dagJsonResolver from './dag-json.js'
10
+ import identifyResolver from './identity.js'
11
+ import jsonResolver from './json.js'
12
+ import rawResolver from './raw.js'
13
+ import dagPbResolver from './unixfs-v1/index.js'
14
+ import type { Resolve, Resolver } from '../index.js'
15
+
16
+ const resolvers: Record<number, Resolver> = {
17
+ [dagPb.code]: dagPbResolver,
18
+ [raw.code]: rawResolver,
19
+ [dagCbor.code]: dagCborResolver,
20
+ [dagJson.code]: dagJsonResolver,
21
+ [identity.code]: identifyResolver,
22
+ [json.code]: jsonResolver
23
+ }
24
+
25
+ const resolve: Resolve = async (cid, name, path, toResolve, depth, blockstore, options) => {
26
+ const resolver = resolvers[cid.code]
27
+
28
+ if (resolver == null) {
29
+ throw new NoResolverError(`No resolver for code ${cid.code}`)
30
+ }
31
+
32
+ return resolver(cid, name, path, toResolve, resolve, depth, blockstore, options)
33
+ }
34
+
35
+ export default resolve
@@ -0,0 +1,12 @@
1
+ import * as json from 'multiformats/codecs/json'
2
+ import { resolveObjectPath } from '../utils/resolve-object-path.js'
3
+ import type { Resolver } from '../index.js'
4
+
5
+ const resolve: Resolver = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
6
+ const block = await blockstore.get(cid, options)
7
+ const object = json.decode<any>(block)
8
+
9
+ return resolveObjectPath(object, block, cid, name, path, toResolve, depth)
10
+ }
11
+
12
+ export default resolve
@@ -0,0 +1,49 @@
1
+ import { CustomProgressEvent } from 'progress-events'
2
+ import { NotFoundError } from '../errors.js'
3
+ import extractDataFromBlock from '../utils/extract-data-from-block.js'
4
+ import validateOffsetAndLength from '../utils/validate-offset-and-length.js'
5
+ import type { ExporterOptions, Resolver, ExportProgress } from '../index.js'
6
+
7
+ const rawContent = (node: Uint8Array): ((options?: ExporterOptions) => AsyncGenerator<Uint8Array, void, undefined>) => {
8
+ async function * contentGenerator (options: ExporterOptions = {}): AsyncGenerator<Uint8Array, void, undefined> {
9
+ const {
10
+ start,
11
+ end
12
+ } = validateOffsetAndLength(node.length, options.offset, options.length)
13
+
14
+ const buf = extractDataFromBlock(node, 0n, start, end)
15
+
16
+ options.onProgress?.(new CustomProgressEvent<ExportProgress>('unixfs:exporter:progress:raw', {
17
+ bytesRead: BigInt(buf.byteLength),
18
+ totalBytes: end - start,
19
+ fileSize: BigInt(node.byteLength)
20
+ }))
21
+
22
+ yield buf
23
+ }
24
+
25
+ return contentGenerator
26
+ }
27
+
28
+ const resolve: Resolver = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
29
+ if (toResolve.length > 0) {
30
+ throw new NotFoundError(`No link named ${path} found in raw node ${cid}`)
31
+ }
32
+
33
+ const block = await blockstore.get(cid, options)
34
+
35
+ return {
36
+ entry: {
37
+ type: 'raw',
38
+ name,
39
+ path,
40
+ cid,
41
+ content: rawContent(block),
42
+ depth,
43
+ size: BigInt(block.length),
44
+ node: block
45
+ }
46
+ }
47
+ }
48
+
49
+ export default resolve