@fireproof/vendor 1.0.3 → 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 (299) 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/reader-browser.d.ts +0 -151
  62. package/src/@ipld/car/dist/src/reader-browser.d.ts.map +0 -1
  63. package/src/@ipld/car/dist/src/reader.d.ts +0 -35
  64. package/src/@ipld/car/dist/src/reader.d.ts.map +0 -1
  65. package/src/@ipld/car/dist/src/writer-browser.d.ts +0 -155
  66. package/src/@ipld/car/dist/src/writer-browser.d.ts.map +0 -1
  67. package/src/@ipld/car/dist/src/writer.d.ts +0 -45
  68. package/src/@ipld/car/dist/src/writer.d.ts.map +0 -1
  69. package/src/@ipld/car/src/api.ts +0 -90
  70. package/src/@ipld/car/src/buffer-decoder.js +0 -213
  71. package/src/@ipld/car/src/buffer-reader-browser.js +0 -144
  72. package/src/@ipld/car/src/buffer-reader.js +0 -51
  73. package/src/@ipld/car/src/buffer-writer.js +0 -286
  74. package/src/@ipld/car/src/coding.ts +0 -68
  75. package/src/@ipld/car/src/decoder-common.js +0 -82
  76. package/src/@ipld/car/src/decoder.js +0 -347
  77. package/src/@ipld/car/src/encoder.js +0 -76
  78. package/src/@ipld/car/src/header-validator.js +0 -214
  79. package/src/@ipld/car/src/header.ipldsch +0 -18
  80. package/src/@ipld/car/src/index-browser.js +0 -18
  81. package/src/@ipld/car/src/index.js +0 -21
  82. package/src/@ipld/car/src/indexed-reader-browser.js +0 -7
  83. package/src/@ipld/car/src/indexed-reader.js +0 -211
  84. package/src/@ipld/car/src/indexer.js +0 -130
  85. package/src/@ipld/car/src/iterator-channel.js +0 -91
  86. package/src/@ipld/car/src/iterator.js +0 -267
  87. package/src/@ipld/car/src/reader-browser.js +0 -194
  88. package/src/@ipld/car/src/reader.js +0 -73
  89. package/src/@ipld/car/src/writer-browser.js +0 -250
  90. package/src/@ipld/car/src/writer.js +0 -84
  91. package/src/@ipld/dag-cbor/LICENSE +0 -4
  92. package/src/@ipld/dag-cbor/README.md +0 -80
  93. package/src/@ipld/dag-cbor/dist/index.min.js +0 -3
  94. package/src/@ipld/dag-cbor/dist/src/index.d.ts +0 -67
  95. package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +0 -1
  96. package/src/@ipld/dag-cbor/src/index.js +0 -147
  97. package/src/@ipld/dag-json/LICENSE +0 -4
  98. package/src/@ipld/dag-json/README.md +0 -58
  99. package/src/@ipld/dag-json/dist/index.min.js +0 -3
  100. package/src/@ipld/dag-json/dist/src/index.d.ts +0 -12
  101. package/src/@ipld/dag-json/dist/src/index.d.ts.map +0 -1
  102. package/src/@ipld/dag-json/src/index.js +0 -291
  103. package/src/cborg/.github/dependabot.yml +0 -16
  104. package/src/cborg/.github/workflows/test-and-release.yml +0 -52
  105. package/src/cborg/CHANGELOG.md +0 -513
  106. package/src/cborg/LICENSE +0 -13
  107. package/src/cborg/README.md +0 -515
  108. package/src/cborg/bench/bench.js +0 -117
  109. package/src/cborg/bench/json.js +0 -124
  110. package/src/cborg/bench/package.json +0 -8
  111. package/src/cborg/cborg/bin.js +0 -189
  112. package/src/cborg/cborg/common.js +0 -28
  113. package/src/cborg/cborg/decode.js +0 -211
  114. package/src/cborg/cborg/diagnostic.js +0 -158
  115. package/src/cborg/cborg/diagnostic_test.js +0 -117
  116. package/src/cborg/cborg/encode.js +0 -466
  117. package/src/cborg/cborg/index.js +0 -33
  118. package/src/cborg/cborg/is.js +0 -106
  119. package/src/cborg/cborg/length.js +0 -62
  120. package/src/cborg/example-bytestrings.js +0 -180
  121. package/src/cborg/example-json.js +0 -6
  122. package/src/cborg/example.js +0 -5
  123. package/src/cborg/interface.ts +0 -59
  124. package/src/cborg/json/decode.js +0 -462
  125. package/src/cborg/json/encode.js +0 -302
  126. package/src/cborg/json/json.js +0 -4
  127. package/src/cborg/taglib.js +0 -75
  128. package/src/cborg/test/appendix_a.js +0 -647
  129. package/src/cborg/test/common.js +0 -18
  130. package/src/cborg/test/node-test-bin.js +0 -402
  131. package/src/cborg/test/noop-bin-test.js +0 -3
  132. package/src/cborg/test/test-0uint.js +0 -103
  133. package/src/cborg/test/test-1negint.js +0 -96
  134. package/src/cborg/test/test-2bytes.js +0 -198
  135. package/src/cborg/test/test-3string.js +0 -136
  136. package/src/cborg/test/test-4array.js +0 -93
  137. package/src/cborg/test/test-5map.js +0 -284
  138. package/src/cborg/test/test-6tag.js +0 -84
  139. package/src/cborg/test/test-7float.js +0 -131
  140. package/src/cborg/test/test-bl.js +0 -37
  141. package/src/cborg/test/test-cbor-vectors.js +0 -107
  142. package/src/cborg/test/test-decode-errors.js +0 -65
  143. package/src/cborg/test/test-fuzz.js +0 -42
  144. package/src/cborg/test/test-json.js +0 -219
  145. package/src/cborg/test/test-length.js +0 -65
  146. package/src/cborg/test/test-partial.js +0 -111
  147. package/src/cborg/tsconfig.json +0 -48
  148. package/src/cborg/types/cborg/decode.d.ts +0 -43
  149. package/src/cborg/types/cborg/decode.d.ts.map +0 -1
  150. package/src/cborg/types/cborg/encode.d.ts +0 -51
  151. package/src/cborg/types/cborg/encode.d.ts.map +0 -1
  152. package/src/cborg/types/cborg/index.d.ts +0 -26
  153. package/src/cborg/types/cborg/index.d.ts.map +0 -1
  154. package/src/cborg/types/cborg/is.d.ts +0 -6
  155. package/src/cborg/types/cborg/is.d.ts.map +0 -1
  156. package/src/cborg/types/example.d.ts +0 -2
  157. package/src/cborg/types/example.d.ts.map +0 -1
  158. package/src/cborg/types/interface.d.ts +0 -49
  159. package/src/cborg/types/interface.d.ts.map +0 -1
  160. package/src/cborg/types/json/decode.d.ts +0 -67
  161. package/src/cborg/types/json/decode.d.ts.map +0 -1
  162. package/src/cborg/types/json/encode.d.ts +0 -11
  163. package/src/cborg/types/json/encode.d.ts.map +0 -1
  164. package/src/cborg/types/json/json.d.ts +0 -6
  165. package/src/cborg/types/json/json.d.ts.map +0 -1
  166. package/src/cborg/types/taglib.d.ts +0 -18
  167. package/src/cborg/types/taglib.d.ts.map +0 -1
  168. package/src/cborg/types/tsconfig.tsbuildinfo +0 -1
  169. package/src/cborg/types/utils/0uint.d.ts +0 -102
  170. package/src/cborg/types/utils/0uint.d.ts.map +0 -1
  171. package/src/cborg/types/utils/1negint.d.ts +0 -59
  172. package/src/cborg/types/utils/1negint.d.ts.map +0 -1
  173. package/src/cborg/types/utils/2bytes.d.ts +0 -69
  174. package/src/cborg/types/utils/2bytes.d.ts.map +0 -1
  175. package/src/cborg/types/utils/3string.d.ts +0 -46
  176. package/src/cborg/types/utils/3string.d.ts.map +0 -1
  177. package/src/cborg/types/utils/4array.d.ts +0 -66
  178. package/src/cborg/types/utils/4array.d.ts.map +0 -1
  179. package/src/cborg/types/utils/5map.d.ts +0 -66
  180. package/src/cborg/types/utils/5map.d.ts.map +0 -1
  181. package/src/cborg/types/utils/6tag.d.ts +0 -62
  182. package/src/cborg/types/utils/6tag.d.ts.map +0 -1
  183. package/src/cborg/types/utils/7float.d.ts +0 -60
  184. package/src/cborg/types/utils/7float.d.ts.map +0 -1
  185. package/src/cborg/types/utils/bl.d.ts +0 -26
  186. package/src/cborg/types/utils/bl.d.ts.map +0 -1
  187. package/src/cborg/types/utils/byte-utils.d.ts +0 -53
  188. package/src/cborg/types/utils/byte-utils.d.ts.map +0 -1
  189. package/src/cborg/types/utils/common.d.ts +0 -8
  190. package/src/cborg/types/utils/common.d.ts.map +0 -1
  191. package/src/cborg/types/utils/index.d.ts +0 -13
  192. package/src/cborg/types/utils/index.d.ts.map +0 -1
  193. package/src/cborg/types/utils/jump.d.ts +0 -16
  194. package/src/cborg/types/utils/jump.d.ts.map +0 -1
  195. package/src/cborg/types/utils/token.d.ts +0 -59
  196. package/src/cborg/types/utils/token.d.ts.map +0 -1
  197. package/src/cborg/utils/0uint.js +0 -229
  198. package/src/cborg/utils/1negint.js +0 -111
  199. package/src/cborg/utils/2bytes.js +0 -135
  200. package/src/cborg/utils/3string.js +0 -90
  201. package/src/cborg/utils/4array.js +0 -114
  202. package/src/cborg/utils/5map.js +0 -113
  203. package/src/cborg/utils/6tag.js +0 -81
  204. package/src/cborg/utils/7float.js +0 -310
  205. package/src/cborg/utils/bl.js +0 -124
  206. package/src/cborg/utils/byte-utils.js +0 -417
  207. package/src/cborg/utils/common.js +0 -11
  208. package/src/cborg/utils/index.js +0 -12
  209. package/src/cborg/utils/jump.js +0 -222
  210. package/src/cborg/utils/token.js +0 -76
  211. package/src/ipfs-unixfs-exporter/LICENSE +0 -4
  212. package/src/ipfs-unixfs-exporter/README.md +0 -105
  213. package/src/ipfs-unixfs-exporter/dist/index.min.js +0 -3
  214. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
  215. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
  216. package/src/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
  217. package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
  218. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
  219. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
  220. package/src/ipfs-unixfs-exporter/dist/src/index.js +0 -197
  221. package/src/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
  222. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
  223. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
  224. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
  225. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
  226. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
  227. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
  228. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
  229. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
  230. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
  231. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
  232. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
  233. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
  234. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
  235. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
  236. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
  237. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
  238. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
  239. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
  240. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
  241. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
  242. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
  243. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
  244. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
  245. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
  246. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
  247. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
  248. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
  249. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
  250. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
  251. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
  252. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
  253. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
  254. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
  255. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
  256. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
  257. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
  258. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
  259. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
  260. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
  261. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
  262. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
  263. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
  264. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
  265. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
  266. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
  267. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
  268. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
  269. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
  270. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
  271. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
  272. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
  273. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
  274. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
  275. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
  276. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
  277. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
  278. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
  279. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
  280. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
  281. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
  282. package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
  283. package/src/ipfs-unixfs-exporter/src/errors.ts +0 -87
  284. package/src/ipfs-unixfs-exporter/src/index.ts +0 -498
  285. package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
  286. package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
  287. package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
  288. package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
  289. package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
  290. package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
  291. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
  292. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
  293. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
  294. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
  295. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
  296. package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
  297. package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
  298. package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
  299. package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
@@ -1,250 +0,0 @@
1
- import { CID } from 'multiformats/cid'
2
- import { bytesReader, readHeader } from './decoder.js'
3
- import { createEncoder, createHeader } from './encoder.js'
4
- import { create as iteratorChannel } from './iterator-channel.js'
5
-
6
- /**
7
- * @typedef {import('./api').Block} Block
8
- * @typedef {import('./api').BlockWriter} BlockWriter
9
- * @typedef {import('./api').WriterChannel} WriterChannel
10
- * @typedef {import('./coding').CarEncoder} CarEncoder
11
- * @typedef {import('./coding').IteratorChannel<Uint8Array>} IteratorChannel
12
- */
13
-
14
- /**
15
- * Provides a writer interface for the creation of CAR files.
16
- *
17
- * Creation of a `CarWriter` involves the instatiation of an input / output pair
18
- * in the form of a `WriterChannel`, which is a
19
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair. These two
20
- * components form what can be thought of as a stream-like interface. The
21
- * `writer` component (an instantiated `CarWriter`), has methods to
22
- * {@link CarWriter.put `put()`} new blocks and {@link CarWriter.put `close()`}
23
- * the writing operation (finalising the CAR archive). The `out` component is
24
- * an `AsyncIterable` that yields the bytes of the archive. This can be
25
- * redirected to a file or other sink. In Node.js, you can use the
26
- * [`Readable.from()`](https://nodejs.org/api/stream.html#stream_stream_readable_from_iterable_options)
27
- * API to convert this to a standard Node.js stream, or it can be directly fed
28
- * to a
29
- * [`stream.pipeline()`](https://nodejs.org/api/stream.html#stream_stream_pipeline_source_transforms_destination_callback).
30
- *
31
- * The channel will provide a form of backpressure. The `Promise` from a
32
- * `write()` won't resolve until the resulting data is drained from the `out`
33
- * iterable.
34
- *
35
- * It is also possible to ignore the `Promise` from `write()` calls and allow
36
- * the generated data to queue in memory. This should be avoided for large CAR
37
- * archives of course due to the memory costs and potential for memory overflow.
38
- *
39
- * Load this class with either
40
- * `import { CarWriter } from '@ipld/car/writer'`
41
- * (`const { CarWriter } = require('@ipld/car/writer')`). Or
42
- * `import { CarWriter } from '@ipld/car'`
43
- * (`const { CarWriter } = require('@ipld/car')`). The former will likely
44
- * result in smaller bundle sizes where this is important.
45
- *
46
- * @name CarWriter
47
- * @class
48
- * @implements {BlockWriter}
49
- */
50
- export class CarWriter {
51
- /**
52
- * @param {CID[]} roots
53
- * @param {CarEncoder} encoder
54
- */
55
- constructor (roots, encoder) {
56
- this._encoder = encoder
57
- /** @type {Promise<void>} */
58
- this._mutex = encoder.setRoots(roots)
59
- this._ended = false
60
- }
61
-
62
- /**
63
- * Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
64
- *
65
- * @function
66
- * @memberof CarWriter
67
- * @instance
68
- * @async
69
- * @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair.
70
- * @returns {Promise<void>} The returned promise will only resolve once the
71
- * bytes this block generates are written to the `out` iterable.
72
- */
73
- async put (block) {
74
- if (!(block.bytes instanceof Uint8Array) || !block.cid) {
75
- throw new TypeError('Can only write {cid, bytes} objects')
76
- }
77
- if (this._ended) {
78
- throw new Error('Already closed')
79
- }
80
- const cid = CID.asCID(block.cid)
81
- if (!cid) {
82
- throw new TypeError('Can only write {cid, bytes} objects')
83
- }
84
- this._mutex = this._mutex.then(() => this._encoder.writeBlock({ cid, bytes: block.bytes }))
85
- return this._mutex
86
- }
87
-
88
- /**
89
- * Finalise the CAR archive and signal that the `out` iterable should end once
90
- * any remaining bytes are written.
91
- *
92
- * @function
93
- * @memberof CarWriter
94
- * @instance
95
- * @async
96
- * @returns {Promise<void>}
97
- */
98
- async close () {
99
- if (this._ended) {
100
- throw new Error('Already closed')
101
- }
102
- await this._mutex
103
- this._ended = true
104
- return this._encoder.close()
105
- }
106
-
107
- /**
108
- * Returns the version number of the CAR file being written
109
- *
110
- * @returns {number}
111
- */
112
- version () {
113
- return this._encoder.version()
114
- }
115
-
116
- /**
117
- * Create a new CAR writer "channel" which consists of a
118
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
119
- *
120
- * @async
121
- * @static
122
- * @memberof CarWriter
123
- * @param {CID[] | CID | void} roots
124
- * @returns {WriterChannel} The channel takes the form of
125
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
126
- */
127
- static create (roots) {
128
- roots = toRoots(roots)
129
- const { encoder, iterator } = encodeWriter()
130
- const writer = new CarWriter(roots, encoder)
131
- const out = new CarWriterOut(iterator)
132
- return { writer, out }
133
- }
134
-
135
- /**
136
- * Create a new CAR appender "channel" which consists of a
137
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
138
- * This appender does not consider roots and does not produce a CAR header.
139
- * It is designed to append blocks to an _existing_ CAR archive. It is
140
- * expected that `out` will be concatenated onto the end of an existing
141
- * archive that already has a properly formatted header.
142
- *
143
- * @async
144
- * @static
145
- * @memberof CarWriter
146
- * @returns {WriterChannel} The channel takes the form of
147
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
148
- */
149
- static createAppender () {
150
- const { encoder, iterator } = encodeWriter()
151
- encoder.setRoots = () => Promise.resolve()
152
- const writer = new CarWriter([], encoder)
153
- const out = new CarWriterOut(iterator)
154
- return { writer, out }
155
- }
156
-
157
- /**
158
- * Update the list of roots in the header of an existing CAR as represented
159
- * in a Uint8Array.
160
- *
161
- * This operation is an _overwrite_, the total length of the CAR will not be
162
- * modified. A rejection will occur if the new header will not be the same
163
- * length as the existing header, in which case the CAR will not be modified.
164
- * It is the responsibility of the user to ensure that the roots being
165
- * replaced encode as the same length as the new roots.
166
- *
167
- * The byte array passed in an argument will be modified and also returned
168
- * upon successful modification.
169
- *
170
- * @async
171
- * @static
172
- * @memberof CarWriter
173
- * @param {Uint8Array} bytes
174
- * @param {CID[]} roots - A new list of roots to replace the existing list in
175
- * the CAR header. The new header must take up the same number of bytes as the
176
- * existing header, so the roots should collectively be the same byte length
177
- * as the existing roots.
178
- * @returns {Promise<Uint8Array>}
179
- */
180
- static async updateRootsInBytes (bytes, roots) {
181
- const reader = bytesReader(bytes)
182
- await readHeader(reader)
183
- const newHeader = createHeader(roots)
184
- if (Number(reader.pos) !== newHeader.length) {
185
- throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${reader.pos} bytes, new header is ${newHeader.length} bytes)`)
186
- }
187
- bytes.set(newHeader, 0)
188
- return bytes
189
- }
190
- }
191
-
192
- /**
193
- * @class
194
- * @implements {AsyncIterable<Uint8Array>}
195
- */
196
- export class CarWriterOut {
197
- /**
198
- * @param {AsyncIterator<Uint8Array>} iterator
199
- */
200
- constructor (iterator) {
201
- this._iterator = iterator
202
- }
203
-
204
- [Symbol.asyncIterator] () {
205
- if (this._iterating) {
206
- throw new Error('Multiple iterator not supported')
207
- }
208
- this._iterating = true
209
- return this._iterator
210
- }
211
- }
212
-
213
- function encodeWriter () {
214
- /** @type {IteratorChannel} */
215
- const iw = iteratorChannel()
216
- const { writer, iterator } = iw
217
- const encoder = createEncoder(writer)
218
- return { encoder, iterator }
219
- }
220
-
221
- /**
222
- * @private
223
- * @param {CID[] | CID | void} roots
224
- * @returns {CID[]}
225
- */
226
- function toRoots (roots) {
227
- if (roots === undefined) {
228
- return []
229
- }
230
-
231
- if (!Array.isArray(roots)) {
232
- const cid = CID.asCID(roots)
233
- if (!cid) {
234
- throw new TypeError('roots must be a single CID or an array of CIDs')
235
- }
236
- return [cid]
237
- }
238
-
239
- const _roots = []
240
- for (const root of roots) {
241
- const _root = CID.asCID(root)
242
- if (!_root) {
243
- throw new TypeError('roots must be a single CID or an array of CIDs')
244
- }
245
- _roots.push(_root)
246
- }
247
- return _roots
248
- }
249
-
250
- export const __browser = true
@@ -1,84 +0,0 @@
1
- import fs from 'fs'
2
- import { promisify } from 'util'
3
- import { readHeader, chunkReader } from './decoder.js'
4
- import { createHeader } from './encoder.js'
5
- import { CarWriter as BrowserCarWriter } from './writer-browser.js'
6
-
7
- const fsread = promisify(fs.read)
8
- const fswrite = promisify(fs.write)
9
-
10
- /**
11
- * @typedef {import('multiformats/cid').CID} CID
12
- * @typedef {import('./api').BlockWriter} BlockWriter
13
- */
14
-
15
- /**
16
- * @class
17
- * @implements {BlockWriter}
18
- */
19
- export class CarWriter extends BrowserCarWriter {
20
- /**
21
- * Update the list of roots in the header of an existing CAR file. The first
22
- * argument must be a file descriptor for CAR file that is open in read and
23
- * write mode (not append), e.g. `fs.open` or `fs.promises.open` with `'r+'`
24
- * mode.
25
- *
26
- * This operation is an _overwrite_, the total length of the CAR will not be
27
- * modified. A rejection will occur if the new header will not be the same
28
- * length as the existing header, in which case the CAR will not be modified.
29
- * It is the responsibility of the user to ensure that the roots being
30
- * replaced encode as the same length as the new roots.
31
- *
32
- * This function is **only available in Node.js** and not a browser
33
- * environment.
34
- *
35
- * @async
36
- * @static
37
- * @memberof CarWriter
38
- * @param {fs.promises.FileHandle | number} fd - A file descriptor from the
39
- * Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
40
- * from `fs.promises.open()`.
41
- * @param {CID[]} roots - A new list of roots to replace the existing list in
42
- * the CAR header. The new header must take up the same number of bytes as the
43
- * existing header, so the roots should collectively be the same byte length
44
- * as the existing roots.
45
- * @returns {Promise<void>}
46
- */
47
- static async updateRootsInFile (fd, roots) {
48
- const chunkSize = 256
49
- /** @type {Uint8Array} */
50
- let bytes
51
- let offset = 0
52
-
53
- /** @type {() => Promise<number>} */
54
- let readChunk
55
- if (typeof fd === 'number') {
56
- readChunk = async () => (await fsread(fd, bytes, 0, chunkSize, offset)).bytesRead
57
- } else if (typeof fd === 'object' && typeof fd.read === 'function') { // FileDescriptor
58
- readChunk = async () => (await fd.read(bytes, 0, chunkSize, offset)).bytesRead
59
- } else {
60
- throw new TypeError('Bad fd')
61
- }
62
- const fdReader = chunkReader(async () => {
63
- bytes = new Uint8Array(chunkSize) // need a new chunk each time, can't reuse old
64
- const read = await readChunk()
65
- offset += read
66
- /* eslint no-warning-comments: 0 */
67
- // TODO: test header > 256 bytes
68
- return read < chunkSize ? bytes.subarray(0, read) : bytes
69
- })
70
-
71
- await readHeader(fdReader)
72
- const newHeader = createHeader(roots)
73
- if (fdReader.pos !== newHeader.length) {
74
- throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${fdReader.pos} bytes, new header is ${newHeader.length} bytes)`)
75
- }
76
- if (typeof fd === 'number') {
77
- await fswrite(fd, newHeader, 0, newHeader.length, 0)
78
- } else if (typeof fd === 'object' && typeof fd.read === 'function') { // FileDescriptor
79
- await fd.write(newHeader, 0, newHeader.length, 0)
80
- }
81
- }
82
- }
83
-
84
- export const __browser = false
@@ -1,4 +0,0 @@
1
- This project is dual licensed under MIT and Apache-2.0.
2
-
3
- MIT: https://www.opensource.org/licenses/mit
4
- Apache-2.0: https://www.apache.org/licenses/license-2.0
@@ -1,80 +0,0 @@
1
- # @ipld/dag-cbor <!-- omit in toc -->
2
-
3
- [![codecov](https://img.shields.io/codecov/c/github/ipld/js-dag-cbor.svg?style=flat-square)](https://codecov.io/gh/ipld/js-dag-cbor)
4
- [![CI](https://img.shields.io/github/workflow/status/ipld/js-dag-cbor/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipld/js-dag-cbor/actions/workflows/js-test-and-release.yml)
5
-
6
- > JS implementation of DAG-CBOR
7
-
8
- ## Table of contents <!-- omit in toc -->
9
-
10
- - [Install](#install)
11
- - [Spec](#spec)
12
- - [License](#license)
13
- - [Contribute](#contribute)
14
-
15
- ## Install
16
-
17
- ```console
18
- $ npm i @ipld/dag-cbor
19
- ```
20
-
21
- This is the *new* interface meant for use by itself or with `multiformats` and
22
- `@ipld/block`. It is not used by `js-ipld-format` which is currently
23
- used in IPFS. That library is [here](https://github.com/ipld/js-ipld-dag-cbor).
24
-
25
- Usage:
26
-
27
- ```javascript
28
- import { encode, decode } from '@ipld/dag-cbor'
29
- import { CID } from 'multiformats'
30
-
31
- const obj = {
32
- x: 1,
33
- /* CID instances are encoded as links */
34
- y: [2, 3, CID.parse('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4')],
35
- z: {
36
- a: CID.parse('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4'),
37
- b: null,
38
- c: 'string'
39
- }
40
- }
41
-
42
- let data = encode(obj)
43
- let decoded = decode(data)
44
- decoded.y[0] // 2
45
- CID.asCID(decoded.z.a) // cid instance
46
-
47
- // encode/decode options are exported for use with cborg's encodedLength and decodeFirst
48
- import { encodeOptions, decodeOptions } from '@ipld/dag-cbor'
49
- import { encodedLength } from 'cborg/length'
50
- import { decodeFirst } from 'cborg'
51
-
52
- // dag-cbor encoded length of obj in bytes
53
- const byteLength = encodedLength(obj, encodeOptions)
54
- byteLength // 104
55
-
56
- // concatenate two dag-cbor encoded obj
57
- const concatenatedData = new Uint8Array(data.length * 2)
58
- concatenatedData.set(data)
59
- concatenatedData.set(data, data.length)
60
-
61
- // returns dag-cbor decoded obj at the beginning of the buffer as well as the remaining bytes
62
- const [first, remainder] = decodeFirst(concatenatedData, decodeOptions)
63
- assert.deepStrictEqual(first, obj)
64
- assert.deepStrictEqual(remainder, data)
65
- ```
66
-
67
- ## Spec
68
-
69
- The [`dag-cbor` specification is in the IPLD specs repo](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-cbor.md).
70
-
71
- ## License
72
-
73
- Licensed under either of
74
-
75
- - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
76
- - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
77
-
78
- ## Contribute
79
-
80
- Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
@@ -1,3 +0,0 @@
1
- (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpldDagCbor = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var IpldDagCbor=(()=>{var Be=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var xr=Object.prototype.hasOwnProperty;var mr=(e,t)=>{for(var r in t)Be(e,r,{get:t[r],enumerable:!0})},yr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of hr(t))!xr.call(e,o)&&o!==r&&Be(e,o,{get:()=>t[o],enumerable:!(n=pr(t,o))||n.enumerable});return e};var gr=e=>yr(Be({},"__esModule",{value:!0}),e);var Dn={};mr(Dn,{code:()=>Nn,decode:()=>Mn,decodeOptions:()=>In,encode:()=>$n,encodeOptions:()=>Bn,name:()=>_n,toByteView:()=>dr});var wr=["string","number","bigint","symbol"],br=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Ge(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(wr.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Er(e))return"Buffer";let r=Ur(e);return r||"Object"}function Er(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Ur(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(br.includes(t))return t}var i=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};i.uint=new i(0,"uint",!0);i.negint=new i(1,"negint",!0);i.bytes=new i(2,"bytes",!0);i.string=new i(3,"string",!0);i.array=new i(4,"array",!1);i.map=new i(5,"map",!1);i.tag=new i(6,"tag",!1);i.float=new i(7,"float",!0);i.false=new i(7,"false",!0);i.true=new i(7,"true",!0);i.null=new i(7,"null",!0);i.undefined=new i(7,"undefined",!0);i.break=new i(7,"break",!0);var a=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var G=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",vr=new TextDecoder,Ar=new TextEncoder;function he(e){return G&&globalThis.Buffer.isBuffer(e)}function Ce(e){return e instanceof Uint8Array?he(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var He=G?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Ke(e,t,r):(e,t,r)=>r-t>64?vr.decode(e.subarray(t,r)):Ke(e,t,r),Qe=G?e=>e.length>64?globalThis.Buffer.from(e):Je(e):e=>e.length>64?Ar.encode(e):Je(e),M=e=>Uint8Array.from(e),J=G?(e,t,r)=>he(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),We=G?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ce(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Ze=G?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Ye(e,t){if(he(e)&&he(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Je(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Ke(e,t,r){let n=[];for(;t<r;){let o=e[t],s=null,u=o>239?4:o>223?3:o>191?2:1;if(t+u<=r){let f,p,g,h;switch(u){case 1:o<128&&(s=o);break;case 2:f=e[t+1],(f&192)===128&&(h=(o&31)<<6|f&63,h>127&&(s=h));break;case 3:f=e[t+1],p=e[t+2],(f&192)===128&&(p&192)===128&&(h=(o&15)<<12|(f&63)<<6|p&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:f=e[t+1],p=e[t+2],g=e[t+3],(f&192)===128&&(p&192)===128&&(g&192)===128&&(h=(o&15)<<18|(f&63)<<12|(p&63)<<6|g&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),t+=u}return Tr(n)}var Xe=4096;function Tr(e){let t=e.length;if(t<=Xe)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Xe));return r}var kr=256,re=class{constructor(t=kr){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Ze(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=J(n,0,this.cursor)}else r=We(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",Ie="CBOR encode error:",ne=[];ne[23]=1;ne[24]=2;ne[25]=3;ne[26]=5;ne[27]=9;function O(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var m=[24,256,65536,4294967296,BigInt("18446744073709551616")];function b(e,t,r){O(e,t,1);let n=e[t];if(r.strict===!0&&n<m[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function E(e,t,r){O(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<m[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function U(e,t,r){O(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<m[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){O(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<m[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function et(e,t,r,n){return new a(i.uint,b(e,t+1,n),2)}function tt(e,t,r,n){return new a(i.uint,E(e,t+1,n),3)}function rt(e,t,r,n){return new a(i.uint,U(e,t+1,n),5)}function nt(e,t,r,n){return new a(i.uint,v(e,t+1,n),9)}function T(e,t){return y(e,0,t.value)}function y(e,t,r){if(r<m[0]){let n=Number(r);e.push([t|n])}else if(r<m[1]){let n=Number(r);e.push([t|24,n])}else if(r<m[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<m[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<m[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),u=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=u&255,u=u>>8,o[3]=u&255,u=u>>8,o[2]=u&255,u=u>>8,o[1]=u&255,e.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}T.encodedSize=function(t){return y.encodedSize(t.value)};y.encodedSize=function(t){return t<m[0]?1:t<m[1]?2:t<m[2]?3:t<m[3]?5:9};T.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function ot(e,t,r,n){return new a(i.negint,-1-b(e,t+1,n),2)}function it(e,t,r,n){return new a(i.negint,-1-E(e,t+1,n),3)}function st(e,t,r,n){return new a(i.negint,-1-U(e,t+1,n),5)}var _e=BigInt(-1),ct=BigInt(1);function at(e,t,r,n){let o=v(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new a(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new a(i.negint,_e-BigInt(o),9)}function xe(e,t){let r=t.value,n=typeof r=="bigint"?r*_e-ct:r*-1-1;y(e,t.type.majorEncoded,n)}xe.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*_e-ct:r*-1-1;return n<m[0]?1:n<m[1]?2:n<m[2]?3:n<m[3]?5:9};xe.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function oe(e,t,r,n){O(e,t,r+n);let o=J(e,t+r,t+r+n);return new a(i.bytes,o,r+n)}function ut(e,t,r,n){return oe(e,t,1,r)}function ft(e,t,r,n){return oe(e,t,2,b(e,t+1,n))}function dt(e,t,r,n){return oe(e,t,3,E(e,t+1,n))}function lt(e,t,r,n){return oe(e,t,5,U(e,t+1,n))}function pt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return oe(e,t,9,o)}function me(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===i.string?Qe(e.value):e.value),e.encodedBytes}function K(e,t){let r=me(t);y(e,t.type.majorEncoded,r.length),e.push(r)}K.encodedSize=function(t){let r=me(t);return y.encodedSize(r.length)+r.length};K.compareTokens=function(t,r){return Br(me(t),me(r))};function Br(e,t){return e.length<t.length?-1:e.length>t.length?1:Ye(e,t)}function ie(e,t,r,n,o){let s=r+n;O(e,t,s);let u=new a(i.string,He(e,t+r,t+s),s);return o.retainStringBytes===!0&&(u.byteValue=J(e,t+r,t+s)),u}function ht(e,t,r,n){return ie(e,t,1,r,n)}function xt(e,t,r,n){return ie(e,t,2,b(e,t+1,n),n)}function mt(e,t,r,n){return ie(e,t,3,E(e,t+1,n),n)}function yt(e,t,r,n){return ie(e,t,5,U(e,t+1,n),n)}function gt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return ie(e,t,9,o,n)}var wt=K;function X(e,t,r,n){return new a(i.array,n,r)}function bt(e,t,r,n){return X(e,t,1,r)}function Et(e,t,r,n){return X(e,t,2,b(e,t+1,n))}function Ut(e,t,r,n){return X(e,t,3,E(e,t+1,n))}function vt(e,t,r,n){return X(e,t,5,U(e,t+1,n))}function At(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return X(e,t,9,o)}function Tt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return X(e,t,1,1/0)}function ye(e,t){y(e,i.array.majorEncoded,t.value)}ye.compareTokens=T.compareTokens;ye.encodedSize=function(t){return y.encodedSize(t.value)};function H(e,t,r,n){return new a(i.map,n,r)}function kt(e,t,r,n){return H(e,t,1,r)}function St(e,t,r,n){return H(e,t,2,b(e,t+1,n))}function Bt(e,t,r,n){return H(e,t,3,E(e,t+1,n))}function Ct(e,t,r,n){return H(e,t,5,U(e,t+1,n))}function It(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return H(e,t,9,o)}function _t(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return H(e,t,1,1/0)}function ge(e,t){y(e,i.map.majorEncoded,t.value)}ge.compareTokens=T.compareTokens;ge.encodedSize=function(t){return y.encodedSize(t.value)};function Nt(e,t,r,n){return new a(i.tag,r,1)}function $t(e,t,r,n){return new a(i.tag,b(e,t+1,n),2)}function Mt(e,t,r,n){return new a(i.tag,E(e,t+1,n),3)}function Dt(e,t,r,n){return new a(i.tag,U(e,t+1,n),5)}function zt(e,t,r,n){return new a(i.tag,v(e,t+1,n),9)}function we(e,t){y(e,i.tag.majorEncoded,t.value)}we.compareTokens=T.compareTokens;we.encodedSize=function(t){return y.encodedSize(t.value)};var Mr=20,Dr=21,zr=22,Or=23;function Ot(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new a(i.null,null,1):new a(i.undefined,void 0,1)}function Ft(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new a(i.break,void 0,1)}function Ne(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new a(i.float,e,t)}function Vt(e,t,r,n){return Ne($e(e,t+1),3,n)}function Lt(e,t,r,n){return Ne(Me(e,t+1),5,n)}function Rt(e,t,r,n){return Ne(Gt(e,t+1),9,n)}function be(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Mr]);else if(n===!0)e.push([i.float.majorEncoded|Dr]);else if(n===null)e.push([i.float.majorEncoded|zr]);else if(n===void 0)e.push([i.float.majorEncoded|Or]);else{let o,s=!1;(!r||r.float64!==!0)&&(jt(n),o=$e(C,1),n===o||Number.isNaN(n)?(C[0]=249,e.push(C.slice(0,3)),s=!0):(qt(n),o=Me(C,1),n===o&&(C[0]=250,e.push(C.slice(0,5)),s=!0))),s||(Fr(n),o=Gt(C,1),C[0]=251,e.push(C.slice(0,9)))}}be.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){jt(n);let o=$e(C,1);if(n===o||Number.isNaN(n))return 3;if(qt(n),o=Me(C,1),n===o)return 5}return 9};var Pt=new ArrayBuffer(9),k=new DataView(Pt,1),C=new Uint8Array(Pt,0);function jt(e){if(e===1/0)k.setUint16(0,31744,!1);else if(e===-1/0)k.setUint16(0,64512,!1);else if(Number.isNaN(e))k.setUint16(0,32256,!1);else{k.setFloat32(0,e);let t=k.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)k.setUint16(0,31744,!1);else if(r===0)k.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?k.setUint16(0,0):o<-14?k.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):k.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function $e(e,t){if(e.length-t<2)throw new Error(`${d} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function qt(e){k.setFloat32(0,e,!1)}function Me(e,t){if(e.length-t<4)throw new Error(`${d} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Fr(e){k.setFloat64(0,e,!1)}function Gt(e,t){if(e.length-t<8)throw new Error(`${d} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}be.compareTokens=T.compareTokens;function l(e,t,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ee(e){return()=>{throw new Error(`${d} ${e}`)}}var c=[];for(let e=0;e<=23;e++)c[e]=l;c[24]=et;c[25]=tt;c[26]=rt;c[27]=nt;c[28]=l;c[29]=l;c[30]=l;c[31]=l;for(let e=32;e<=55;e++)c[e]=l;c[56]=ot;c[57]=it;c[58]=st;c[59]=at;c[60]=l;c[61]=l;c[62]=l;c[63]=l;for(let e=64;e<=87;e++)c[e]=ut;c[88]=ft;c[89]=dt;c[90]=lt;c[91]=pt;c[92]=l;c[93]=l;c[94]=l;c[95]=Ee("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)c[e]=ht;c[120]=xt;c[121]=mt;c[122]=yt;c[123]=gt;c[124]=l;c[125]=l;c[126]=l;c[127]=Ee("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)c[e]=bt;c[152]=Et;c[153]=Ut;c[154]=vt;c[155]=At;c[156]=l;c[157]=l;c[158]=l;c[159]=Tt;for(let e=160;e<=183;e++)c[e]=kt;c[184]=St;c[185]=Bt;c[186]=Ct;c[187]=It;c[188]=l;c[189]=l;c[190]=l;c[191]=_t;for(let e=192;e<=215;e++)c[e]=Nt;c[216]=$t;c[217]=Mt;c[218]=Dt;c[219]=zt;c[220]=l;c[221]=l;c[222]=l;c[223]=l;for(let e=224;e<=243;e++)c[e]=Ee("simple values are not supported");c[244]=l;c[245]=l;c[246]=l;c[247]=Ot;c[248]=Ee("simple values are not supported");c[249]=Vt;c[250]=Lt;c[251]=Rt;c[252]=l;c[253]=l;c[254]=l;c[255]=Ft;var I=[];for(let e=0;e<24;e++)I[e]=new a(i.uint,e,1);for(let e=-1;e>=-24;e--)I[31-e]=new a(i.negint,e,1);I[64]=new a(i.bytes,new Uint8Array(0),1);I[96]=new a(i.string,"",1);I[128]=new a(i.array,0,1);I[160]=new a(i.map,0,1);I[244]=new a(i.false,!1,1);I[245]=new a(i.true,!0,1);I[246]=new a(i.null,null,1);function Jt(e){switch(e.type){case i.false:return M([244]);case i.true:return M([245]);case i.null:return M([246]);case i.bytes:return e.value.length?void 0:M([64]);case i.string:return e.value===""?M([96]):void 0;case i.array:return e.value===0?M([128]):void 0;case i.map:return e.value===0?M([160]):void 0;case i.uint:return e.value<24?M([Number(e.value)]):void 0;case i.negint:if(e.value>=-24)return M([31-Number(e.value)])}}var Lr={float64:!1,mapSorter:jr,quickEncodeToken:Jt};function Rr(){let e=[];return e[i.uint.major]=T,e[i.negint.major]=xe,e[i.bytes.major]=K,e[i.string.major]=wt,e[i.array.major]=ye,e[i.map.major]=ge,e[i.tag.major]=we,e[i.float.major]=be,e}var Kt=Rr(),De=new re,ve=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Ie} object contains circular references`);return new e(r,t)}},L={null:new a(i.null,null),undefined:new a(i.undefined,void 0),true:new a(i.true,!0),false:new a(i.false,!1),emptyArray:new a(i.array,0),emptyMap:new a(i.map,0)},R={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new a(i.float,e):e>=0?new a(i.uint,e):new a(i.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new a(i.uint,e):new a(i.negint,e)},Uint8Array(e,t,r,n){return new a(i.bytes,e)},string(e,t,r,n){return new a(i.string,e)},boolean(e,t,r,n){return e?L.true:L.false},null(e,t,r,n){return L.null},undefined(e,t,r,n){return L.undefined},ArrayBuffer(e,t,r,n){return new a(i.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new a(i.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[L.emptyArray,new a(i.break)]:L.emptyArray;n=ve.createCheck(n,e);let o=[],s=0;for(let u of e)o[s++]=Ue(u,r,n);return r.addBreakTokens?[new a(i.array,e.length),o,new a(i.break)]:[new a(i.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),u=o?e.size:s.length;if(!u)return r.addBreakTokens===!0?[L.emptyMap,new a(i.break)]:L.emptyMap;n=ve.createCheck(n,e);let f=[],p=0;for(let g of s)f[p++]=[Ue(g,r,n),Ue(o?e.get(g):e[g],r,n)];return Pr(f,r),r.addBreakTokens?[new a(i.map,u),f,new a(i.break)]:[new a(i.map,u),f]}};R.Map=R.Object;R.Buffer=R.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))R[`${e}Array`]=R.DataView;function Ue(e,t={},r){let n=Ge(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||R[n];if(typeof o=="function"){let u=o(e,n,t,r);if(u!=null)return u}let s=R[n];if(!s)throw new Error(`${Ie} unsupported type: ${n}`);return s(e,n,t,r)}function Pr(e,t){t.mapSorter&&e.sort(t.mapSorter)}function jr(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,s=Kt[o].compareTokens(r,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Xt(e,t,r,n){if(Array.isArray(t))for(let o of t)Xt(e,o,r,n);else r[t.type.major](e,t,n)}function qr(e,t,r){let n=Ue(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=t[n.type.major];if(s.encodedSize){let u=s.encodedSize(n,r),f=new re(u);if(s(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ce(f.chunks[0])}}return De.reset(),Xt(De,n,t,r),De.toBytes(!0)}function ze(e,t){return t=Object.assign({},Lr,t),qr(e,Kt,t)}var Gr={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ae=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=I[t];if(r===void 0){let n=c[t];if(!n)throw new Error(`${d} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},se=Symbol.for("DONE"),Te=Symbol.for("BREAK");function Jr(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=Q(t,r);if(s===Te){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(s===se)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function Kr(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let u=0;u<e.value;u++){let f=Q(t,r);if(f===Te){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===se)throw new Error(`${d} found map but not enough entries (got ${u} [no key], expected ${e.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&s.has(f)||!n&&f in o))throw new Error(`${d} found repeat map key "${f}"`);let p=Q(t,r);if(p===se)throw new Error(`${d} found map but not enough entries (got ${u} [no value], expected ${e.value})`);n?s.set(f,p):o[f]=p}return n?s:o}function Q(e,t){if(e.done())return se;let r=e.next();if(r.type===i.break)return Te;if(r.type.terminal)return r.value;if(r.type===i.array)return Jr(r,e,t);if(r.type===i.map)return Kr(r,e,t);if(r.type===i.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Q(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ht(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},Gr,t);let r=t.tokenizer||new Ae(e,t),n=Q(r,t);if(n===se)throw new Error(`${d} did not find any content to decode`);if(n===Te)throw new Error(`${d} got unexpected break`);return[n,e.subarray(r.pos())]}function Oe(e,t){let[r,n]=Ht(e,t);if(n.length>0)throw new Error(`${d} too many terminals, data makes no sense`);return r}var Do=new Uint8Array(0);function Qt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function W(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Hr(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),u=s.charCodeAt(0);if(r[u]!==255)throw new TypeError(s+" is ambiguous");r[u]=o}var f=e.length,p=e.charAt(0),g=Math.log(f)/Math.log(256),h=Math.log(256)/Math.log(f);function q(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var w=0,P=0,S=0,_=x.length;S!==_&&x[S]===0;)S++,w++;for(var N=(_-S)*h+1>>>0,A=new Uint8Array(N);S!==_;){for(var $=x[S],V=0,B=N-1;($!==0||V<P)&&B!==-1;B--,V++)$+=256*A[B]>>>0,A[B]=$%f>>>0,$=$/f>>>0;if($!==0)throw new Error("Non-zero carry");P=V,S++}for(var z=N-P;z!==N&&A[z]===0;)z++;for(var pe=p.repeat(w);z<N;++z)pe+=e.charAt(A[z]);return pe}function le(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var w=0;if(x[w]!==" "){for(var P=0,S=0;x[w]===p;)P++,w++;for(var _=(x.length-w)*g+1>>>0,N=new Uint8Array(_);x[w];){var A=r[x.charCodeAt(w)];if(A===255)return;for(var $=0,V=_-1;(A!==0||$<S)&&V!==-1;V--,$++)A+=f*N[V]>>>0,N[V]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");S=$,w++}if(x[w]!==" "){for(var B=_-S;B!==_&&N[B]===0;)B++;for(var z=new Uint8Array(P+(_-B)),pe=P;B!==_;)z[pe++]=N[B++];return z}}}function lr(x){var w=le(x);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:q,decodeUnsafe:le,decode:lr}}var Qr=Hr,Wr=Qr,Wt=Wr;var Fe=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ve=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Zt(this,t)}},Le=class{decoders;constructor(t){this.decoders=t}or(t){return Zt(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Zt(e,t){return new Le({...(e.decoders ?? {[e.prefix]:e}),...(t.decoders ?? {[t.prefix]:t})});}var Re=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Fe(t,r,n),this.decoder=new Ve(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Yt({name:e,prefix:t,encode:r,decode:n}){return new Re(e,t,r,n)}function Z({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Wt(r,e);return Yt({prefix:t,name:e,encode:n,decode:s=>W(o(s))})}function Zr(e,t,r,n){let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let s=e.length;for(;e[s-1]==="=";)--s;let u=new Uint8Array(s*r/8|0),f=0,p=0,g=0;for(let h=0;h<s;++h){let q=o[e[h]];if(q===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|q,f+=r,f>=8&&(f-=8,u[g++]=255&p>>f)}if(f>=r||255&p<<8-f)throw new SyntaxError("Unexpected end of data");return u}function Yr(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",u=0,f=0;for(let p=0;p<e.length;++p)for(f=f<<8|e[p],u+=8;u>r;)u-=r,s+=t[o&f>>u];if(u!==0&&(s+=t[o&f<<r-u]),n)for(;s.length*r&7;)s+="=";return s}function D({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Yt({prefix:t,name:e,encode(o){return Yr(o,n,r)},decode(o){return Zr(o,n,r,e)}})}var ce=D({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Po=D({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),jo=D({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qo=D({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Go=D({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jo=D({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ko=D({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xo=D({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ho=D({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ke=Z({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zo=Z({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var F=Z({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ti=Z({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var en=rr,er=128,tn=127,rn=~tn,nn=Math.pow(2,31);function rr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=nn;)t[r++]=e&255|er,e/=128;for(;e&rn;)t[r++]=e&255|er,e>>>=7;return t[r]=e|0,rr.bytes=r-n+1,t}var on=Pe,sn=128,tr=127;function Pe(e,n){var r=0,n=n||0,o=0,s=n,u,f=e.length;do{if(s>=f)throw (Pe.bytes=0, new RangeError("Could not decode varint"));u=e[s++],r+=o<28?(u&tr)<<o:(u&tr)*Math.pow(2,o),o+=7}while(u>=sn);return Pe.bytes=s-n,r}var cn=Math.pow(2,7),an=Math.pow(2,14),un=Math.pow(2,21),fn=Math.pow(2,28),dn=Math.pow(2,35),ln=Math.pow(2,42),pn=Math.pow(2,49),hn=Math.pow(2,56),xn=Math.pow(2,63),mn=function(e){return e<cn?1:e<an?2:e<un?3:e<fn?4:e<dn?5:e<ln?6:e<pn?7:e<hn?8:e<xn?9:10},yn={encode:en,decode:on,encodingLength:mn},gn=yn,ae=gn;function ue(e,t=0){return[ae.decode(e,t),ae.decode.bytes]}function Y(e,t,r=0){return ae.encode(e,t,r),t}function ee(e){return ae.encodingLength(e)}function or(e,t){let r=t.byteLength,n=ee(e),o=n+ee(r),s=new Uint8Array(o+r);return Y(e,s,0),Y(r,s,n),s.set(t,o),new te(e,r,t,s)}function ir(e){let t=W(e),[r,n]=ue(t),[o,s]=ue(t.subarray(n)),u=t.subarray(n+s);if(u.byteLength!==o)throw new Error("Incorrect length");return new te(r,o,u,t)}function sr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Qt(e.bytes,r.bytes)}}var te=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function cr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return En(r,je(e),t??F.encoder);default:return Un(r,je(e),t??ce.encoder)}}var ar=new WeakMap;function je(e){let t=ar.get(e);if(t==null){let r=new Map;return ar.set(e,r),r}return t}var de=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==fe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==vn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=or(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&sr(t.multihash,n.multihash)}toString(t){return cr(this,t)}toJSON(){return{"/":cr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:u}=r;return new e(n,o,s,u??ur(n,o,s.bytes))}else if(r[An]===!0){let{version:n,multihash:o,code:s}=r,u=ir(o);return e.create(n,s,u)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==fe)throw new Error(`Version 0 CID must use dag-pb (code: ${fe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ur(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,fe,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=W(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),u=new te(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(u):e.createV1(r.codec,u),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[q,le]=ue(t.subarray(r));return r+=le,q},o=n(),s=fe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let u=r,f=n(),p=n(),g=r+p,h=g-u;return{version:o,codec:s,multihashCode:f,digestSize:p,multihashSize:h,size:g}}static parse(t,r){let[n,o]=bn(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return je(s).set(n,t),s}};function bn(e,t){switch(e[0]){case"Q":{let r=t??F;return[F.prefix,r.decode(`${F.prefix}${e}`)]}case F.prefix:{let r=t??F;return[F.prefix,r.decode(e)]}case ce.prefix:{let r=t??ce;return[ce.prefix,r.decode(e)]}case ke.prefix:{let r=t??ke;return[ke.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function En(e,t,r){let{prefix:n}=r;if(n!==F.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Un(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var fe=112,vn=18;function ur(e,t,r){let n=ee(e),o=n+ee(t),s=new Uint8Array(o+r.byteLength);return Y(e,s,0),Y(t,s,n),s.set(r,o),s}var An=Symbol.for("@ipld/js-cid/CID");var fr=42;function dr(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Tn(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=de.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new a(i.tag,fr),new a(i.bytes,r)]}function kn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Sn(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var qe={float64:!0,typeEncoders:{Object:Tn,undefined:kn,number:Sn}},Bn={...qe,typeEncoders:{...qe.typeEncoders}};function Cn(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return de.decode(e.subarray(1))}var Se={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Se.tags[fr]=Cn;var In={...Se,tags:Se.tags.slice()},_n="dag-cbor",Nn=113,$n=e=>ze(e,qe),Mn=e=>Oe(dr(e),Se);return gr(Dn);})();
3
- return IpldDagCbor}));
@@ -1,67 +0,0 @@
1
- /**
2
- * @template T
3
- * @typedef {import('multiformats/codecs/interface').ByteView<T>} ByteView
4
- */
5
- /**
6
- * @template T
7
- * @typedef {import('multiformats/codecs/interface').ArrayBufferView<T>} ArrayBufferView
8
- */
9
- /**
10
- * @template T
11
- * @param {ByteView<T> | ArrayBufferView<T>} buf
12
- * @returns {ByteView<T>}
13
- */
14
- export function toByteView<T>(buf: import("multiformats/cid").ByteView<T> | import("multiformats/codecs/interface").ArrayBufferView<T>): import("multiformats/cid").ByteView<T>;
15
- export namespace encodeOptions {
16
- namespace typeEncoders {
17
- export { cidEncoder as Object };
18
- export { undefinedEncoder as undefined };
19
- export { numberEncoder as number };
20
- }
21
- let float64: boolean;
22
- }
23
- export namespace decodeOptions {
24
- let tags: import("cborg/interface").TagDecoder[];
25
- let allowIndefinite: boolean;
26
- let coerceUndefinedToNull: boolean;
27
- let allowNaN: boolean;
28
- let allowInfinity: boolean;
29
- let allowBigInt: boolean;
30
- let strict: boolean;
31
- let useMaps: boolean;
32
- let rejectDuplicateMapKeys: boolean;
33
- }
34
- export const name: "dag-cbor";
35
- export const code: 113;
36
- export function encode<T>(node: T): import("multiformats/cid").ByteView<T>;
37
- export function decode<T>(data: import("multiformats/cid").ByteView<T> | import("multiformats/codecs/interface").ArrayBufferView<T>): T;
38
- export type ByteView<T> = import('multiformats/codecs/interface').ByteView<T>;
39
- export type ArrayBufferView<T> = import('multiformats/codecs/interface').ArrayBufferView<T>;
40
- /**
41
- * cidEncoder will receive all Objects during encode, it needs to filter out
42
- * anything that's not a CID and return `null` for that so it's encoded as
43
- * normal.
44
- *
45
- * @param {any} obj
46
- * @returns {cborg.Token[]|null}
47
- */
48
- declare function cidEncoder(obj: any): cborg.Token[] | null;
49
- /**
50
- * Intercept all `undefined` values from an object walk and reject the entire
51
- * object if we find one.
52
- *
53
- * @returns {null}
54
- */
55
- declare function undefinedEncoder(): null;
56
- /**
57
- * Intercept all `number` values from an object walk and reject the entire
58
- * object if we find something that doesn't fit the IPLD data model (NaN &
59
- * Infinity).
60
- *
61
- * @param {number} num
62
- * @returns {null}
63
- */
64
- declare function numberEncoder(num: number): null;
65
- import * as cborg from 'cborg';
66
- export {};
67
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":"AAMA;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AACH,gLAMC;;;;;;;;;;;;;;;;;;;;AAwGD,8BAA8B;AAC9B,uBAAwB;AAOjB,2EAA2D;AAO3D,wIAAuE;0BA1IjE,OAAO,+BAA+B,EAAE,QAAQ,CAAC,CAAC,CAAC;iCAKnD,OAAO,+BAA+B,EAAE,eAAe,CAAC,CAAC,CAAC;AAgBvE;;;;;;;GAOG;AACH,iCAHW,GAAG,GACD,MAAM,KAAK,EAAE,GAAC,IAAI,CAkB9B;AAGD;;;;;GAKG;AACH,qCAFa,IAAI,CAIhB;AAED;;;;;;;GAOG;AACH,oCAHW,MAAM,GACJ,IAAI,CAUhB;uBAlFsB,OAAO"}