@backblaze-labs/b2-sdk 0.2.0 → 0.4.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 (590) hide show
  1. package/CHANGELOG.md +86 -1
  2. package/README.md +38 -7
  3. package/dist/_virtual/_b2-sdk-version-json.cjs +1 -1
  4. package/dist/_virtual/_b2-sdk-version-json.js +1 -1
  5. package/dist/auth/file.cjs.map +1 -1
  6. package/dist/auth/reauth-coalescer.cjs +65 -0
  7. package/dist/auth/reauth-coalescer.cjs.map +1 -0
  8. package/dist/auth/reauth-coalescer.d.cts +34 -0
  9. package/dist/auth/reauth-coalescer.d.cts.map +1 -0
  10. package/dist/auth/reauth-coalescer.d.ts +34 -0
  11. package/dist/auth/reauth-coalescer.d.ts.map +1 -0
  12. package/dist/auth/reauth-coalescer.js +65 -0
  13. package/dist/auth/reauth-coalescer.js.map +1 -0
  14. package/dist/backup/client.cjs +206 -0
  15. package/dist/backup/client.cjs.map +1 -0
  16. package/dist/backup/client.d.cts +238 -0
  17. package/dist/backup/client.d.cts.map +1 -0
  18. package/dist/backup/client.d.ts +238 -0
  19. package/dist/backup/client.d.ts.map +1 -0
  20. package/dist/backup/client.js +206 -0
  21. package/dist/backup/client.js.map +1 -0
  22. package/dist/backup/index.cjs +15 -0
  23. package/dist/backup/index.d.cts +22 -0
  24. package/dist/backup/index.d.cts.map +1 -0
  25. package/dist/backup/index.d.ts +22 -0
  26. package/dist/backup/index.d.ts.map +1 -0
  27. package/dist/backup/index.js +7 -0
  28. package/dist/backup/raw.cjs +168 -0
  29. package/dist/backup/raw.cjs.map +1 -0
  30. package/dist/backup/raw.d.cts +122 -0
  31. package/dist/backup/raw.d.cts.map +1 -0
  32. package/dist/backup/raw.d.ts +122 -0
  33. package/dist/backup/raw.d.ts.map +1 -0
  34. package/dist/backup/raw.js +168 -0
  35. package/dist/backup/raw.js.map +1 -0
  36. package/dist/bucket-validation.cjs +111 -0
  37. package/dist/bucket-validation.cjs.map +1 -0
  38. package/dist/bucket-validation.d.cts +27 -0
  39. package/dist/bucket-validation.d.cts.map +1 -0
  40. package/dist/bucket-validation.d.ts +27 -0
  41. package/dist/bucket-validation.d.ts.map +1 -0
  42. package/dist/bucket-validation.js +109 -0
  43. package/dist/bucket-validation.js.map +1 -0
  44. package/dist/bucket.cjs +125 -74
  45. package/dist/bucket.cjs.map +1 -1
  46. package/dist/bucket.d.cts +156 -61
  47. package/dist/bucket.d.cts.map +1 -1
  48. package/dist/bucket.d.ts +156 -61
  49. package/dist/bucket.d.ts.map +1 -1
  50. package/dist/bucket.js +125 -74
  51. package/dist/bucket.js.map +1 -1
  52. package/dist/client.cjs +29 -8
  53. package/dist/client.cjs.map +1 -1
  54. package/dist/client.d.cts +30 -9
  55. package/dist/client.d.cts.map +1 -1
  56. package/dist/client.d.ts +30 -9
  57. package/dist/client.d.ts.map +1 -1
  58. package/dist/client.js +29 -8
  59. package/dist/client.js.map +1 -1
  60. package/dist/copy/large.cjs +5 -3
  61. package/dist/copy/large.cjs.map +1 -1
  62. package/dist/copy/large.d.cts.map +1 -1
  63. package/dist/copy/large.d.ts.map +1 -1
  64. package/dist/copy/large.js +5 -3
  65. package/dist/copy/large.js.map +1 -1
  66. package/dist/download/checksum.cjs +6 -2
  67. package/dist/download/checksum.cjs.map +1 -1
  68. package/dist/download/checksum.js +6 -2
  69. package/dist/download/checksum.js.map +1 -1
  70. package/dist/download/parallel.cjs +52 -15
  71. package/dist/download/parallel.cjs.map +1 -1
  72. package/dist/download/parallel.d.cts +8 -1
  73. package/dist/download/parallel.d.cts.map +1 -1
  74. package/dist/download/parallel.d.ts +8 -1
  75. package/dist/download/parallel.d.ts.map +1 -1
  76. package/dist/download/parallel.js +52 -15
  77. package/dist/download/parallel.js.map +1 -1
  78. package/dist/download/single.cjs +179 -19
  79. package/dist/download/single.cjs.map +1 -1
  80. package/dist/download/single.d.cts +10 -4
  81. package/dist/download/single.d.cts.map +1 -1
  82. package/dist/download/single.d.ts +10 -4
  83. package/dist/download/single.d.ts.map +1 -1
  84. package/dist/download/single.js +179 -19
  85. package/dist/download/single.js.map +1 -1
  86. package/dist/errors/index.cjs +196 -3
  87. package/dist/errors/index.cjs.map +1 -1
  88. package/dist/errors/index.d.cts +134 -0
  89. package/dist/errors/index.d.cts.map +1 -1
  90. package/dist/errors/index.d.ts +134 -0
  91. package/dist/errors/index.d.ts.map +1 -1
  92. package/dist/errors/index.js +183 -4
  93. package/dist/errors/index.js.map +1 -1
  94. package/dist/http/non-idempotent-mutations.cjs +38 -0
  95. package/dist/http/non-idempotent-mutations.cjs.map +1 -0
  96. package/dist/http/non-idempotent-mutations.d.cts +25 -0
  97. package/dist/http/non-idempotent-mutations.d.cts.map +1 -0
  98. package/dist/http/non-idempotent-mutations.d.ts +25 -0
  99. package/dist/http/non-idempotent-mutations.d.ts.map +1 -0
  100. package/dist/http/non-idempotent-mutations.js +35 -0
  101. package/dist/http/non-idempotent-mutations.js.map +1 -0
  102. package/dist/http/retry.cjs +1 -1
  103. package/dist/http/retry.cjs.map +1 -1
  104. package/dist/http/retry.js +1 -1
  105. package/dist/http/retry.js.map +1 -1
  106. package/dist/http/transport.cjs +62 -23
  107. package/dist/http/transport.cjs.map +1 -1
  108. package/dist/http/transport.d.cts +30 -3
  109. package/dist/http/transport.d.cts.map +1 -1
  110. package/dist/http/transport.d.ts +30 -3
  111. package/dist/http/transport.d.ts.map +1 -1
  112. package/dist/http/transport.js +60 -22
  113. package/dist/http/transport.js.map +1 -1
  114. package/dist/http/user-agent.cjs +12 -1
  115. package/dist/http/user-agent.cjs.map +1 -1
  116. package/dist/http/user-agent.d.cts +8 -0
  117. package/dist/http/user-agent.d.cts.map +1 -1
  118. package/dist/http/user-agent.d.ts +8 -0
  119. package/dist/http/user-agent.d.ts.map +1 -1
  120. package/dist/http/user-agent.js +13 -3
  121. package/dist/http/user-agent.js.map +1 -1
  122. package/dist/index.cjs +50 -2
  123. package/dist/index.d.cts +15 -12
  124. package/dist/index.d.cts.map +1 -1
  125. package/dist/index.d.ts +15 -12
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +13 -10
  128. package/dist/notifications/index.cjs +3 -0
  129. package/dist/notifications/index.d.cts +2 -0
  130. package/dist/notifications/index.d.cts.map +1 -1
  131. package/dist/notifications/index.d.ts +2 -0
  132. package/dist/notifications/index.d.ts.map +1 -1
  133. package/dist/notifications/index.js +2 -1
  134. package/dist/object.cjs +13 -2
  135. package/dist/object.cjs.map +1 -1
  136. package/dist/object.d.cts +11 -3
  137. package/dist/object.d.cts.map +1 -1
  138. package/dist/object.d.ts +11 -3
  139. package/dist/object.d.ts.map +1 -1
  140. package/dist/object.js +13 -2
  141. package/dist/object.js.map +1 -1
  142. package/dist/partner/account-info.d.cts +43 -0
  143. package/dist/partner/account-info.d.cts.map +1 -0
  144. package/dist/partner/account-info.d.ts +43 -0
  145. package/dist/partner/account-info.d.ts.map +1 -0
  146. package/dist/partner/auth-clone.cjs +64 -0
  147. package/dist/partner/auth-clone.cjs.map +1 -0
  148. package/dist/partner/auth-clone.d.cts +27 -0
  149. package/dist/partner/auth-clone.d.cts.map +1 -0
  150. package/dist/partner/auth-clone.d.ts +27 -0
  151. package/dist/partner/auth-clone.d.ts.map +1 -0
  152. package/dist/partner/auth-clone.js +63 -0
  153. package/dist/partner/auth-clone.js.map +1 -0
  154. package/dist/partner/auth-core.cjs +156 -0
  155. package/dist/partner/auth-core.cjs.map +1 -0
  156. package/dist/partner/auth-core.d.cts +111 -0
  157. package/dist/partner/auth-core.d.cts.map +1 -0
  158. package/dist/partner/auth-core.d.ts +111 -0
  159. package/dist/partner/auth-core.d.ts.map +1 -0
  160. package/dist/partner/auth-core.js +156 -0
  161. package/dist/partner/auth-core.js.map +1 -0
  162. package/dist/partner/auth-shape.cjs +36 -0
  163. package/dist/partner/auth-shape.cjs.map +1 -0
  164. package/dist/partner/auth-shape.d.cts +12 -0
  165. package/dist/partner/auth-shape.d.cts.map +1 -0
  166. package/dist/partner/auth-shape.d.ts +12 -0
  167. package/dist/partner/auth-shape.d.ts.map +1 -0
  168. package/dist/partner/auth-shape.js +36 -0
  169. package/dist/partner/auth-shape.js.map +1 -0
  170. package/dist/partner/client.cjs +270 -0
  171. package/dist/partner/client.cjs.map +1 -0
  172. package/dist/partner/client.d.cts +357 -0
  173. package/dist/partner/client.d.cts.map +1 -0
  174. package/dist/partner/client.d.ts +357 -0
  175. package/dist/partner/client.d.ts.map +1 -0
  176. package/dist/partner/client.js +270 -0
  177. package/dist/partner/client.js.map +1 -0
  178. package/dist/partner/endpoint-url.cjs +109 -0
  179. package/dist/partner/endpoint-url.cjs.map +1 -0
  180. package/dist/partner/endpoint-url.d.cts +74 -0
  181. package/dist/partner/endpoint-url.d.cts.map +1 -0
  182. package/dist/partner/endpoint-url.d.ts +74 -0
  183. package/dist/partner/endpoint-url.d.ts.map +1 -0
  184. package/dist/partner/endpoint-url.js +106 -0
  185. package/dist/partner/endpoint-url.js.map +1 -0
  186. package/dist/partner/in-memory.cjs +135 -0
  187. package/dist/partner/in-memory.cjs.map +1 -0
  188. package/dist/partner/in-memory.d.cts +99 -0
  189. package/dist/partner/in-memory.d.cts.map +1 -0
  190. package/dist/partner/in-memory.d.ts +99 -0
  191. package/dist/partner/in-memory.d.ts.map +1 -0
  192. package/dist/partner/in-memory.js +135 -0
  193. package/dist/partner/in-memory.js.map +1 -0
  194. package/dist/partner/index.cjs +27 -0
  195. package/dist/partner/index.d.cts +32 -0
  196. package/dist/partner/index.d.cts.map +1 -0
  197. package/dist/partner/index.d.ts +32 -0
  198. package/dist/partner/index.d.ts.map +1 -0
  199. package/dist/partner/index.js +9 -0
  200. package/dist/partner/raw.cjs +400 -0
  201. package/dist/partner/raw.cjs.map +1 -0
  202. package/dist/partner/raw.d.cts +220 -0
  203. package/dist/partner/raw.d.cts.map +1 -0
  204. package/dist/partner/raw.d.ts +220 -0
  205. package/dist/partner/raw.d.ts.map +1 -0
  206. package/dist/partner/raw.js +398 -0
  207. package/dist/partner/raw.js.map +1 -0
  208. package/dist/partner/redaction-placeholders.cjs +10 -0
  209. package/dist/partner/redaction-placeholders.cjs.map +1 -0
  210. package/dist/partner/redaction-placeholders.d.cts +5 -0
  211. package/dist/partner/redaction-placeholders.d.cts.map +1 -0
  212. package/dist/partner/redaction-placeholders.d.ts +5 -0
  213. package/dist/partner/redaction-placeholders.d.ts.map +1 -0
  214. package/dist/partner/redaction-placeholders.js +9 -0
  215. package/dist/partner/redaction-placeholders.js.map +1 -0
  216. package/dist/partner/redaction.cjs +292 -0
  217. package/dist/partner/redaction.cjs.map +1 -0
  218. package/dist/partner/redaction.d.cts +158 -0
  219. package/dist/partner/redaction.d.cts.map +1 -0
  220. package/dist/partner/redaction.d.ts +158 -0
  221. package/dist/partner/redaction.d.ts.map +1 -0
  222. package/dist/partner/redaction.js +281 -0
  223. package/dist/partner/redaction.js.map +1 -0
  224. package/dist/raw/encoding.cjs +29 -10
  225. package/dist/raw/encoding.cjs.map +1 -1
  226. package/dist/raw/encoding.d.cts +3 -2
  227. package/dist/raw/encoding.d.cts.map +1 -1
  228. package/dist/raw/encoding.d.ts +3 -2
  229. package/dist/raw/encoding.d.ts.map +1 -1
  230. package/dist/raw/encoding.js +29 -10
  231. package/dist/raw/encoding.js.map +1 -1
  232. package/dist/raw/index.cjs +131 -44
  233. package/dist/raw/index.cjs.map +1 -1
  234. package/dist/raw/index.d.cts +21 -15
  235. package/dist/raw/index.d.cts.map +1 -1
  236. package/dist/raw/index.d.ts +21 -15
  237. package/dist/raw/index.d.ts.map +1 -1
  238. package/dist/raw/index.js +114 -45
  239. package/dist/raw/index.js.map +1 -1
  240. package/dist/raw/url.cjs +111 -0
  241. package/dist/raw/url.cjs.map +1 -0
  242. package/dist/raw/url.d.cts +41 -0
  243. package/dist/raw/url.d.cts.map +1 -0
  244. package/dist/raw/url.d.ts +41 -0
  245. package/dist/raw/url.d.ts.map +1 -0
  246. package/dist/raw/url.js +110 -0
  247. package/dist/raw/url.js.map +1 -0
  248. package/dist/s3/sigv4.cjs +15 -10
  249. package/dist/s3/sigv4.cjs.map +1 -1
  250. package/dist/s3/sigv4.js +15 -10
  251. package/dist/s3/sigv4.js.map +1 -1
  252. package/dist/simulator/index.cjs +1579 -257
  253. package/dist/simulator/index.cjs.map +1 -1
  254. package/dist/simulator/index.d.cts +124 -11
  255. package/dist/simulator/index.d.cts.map +1 -1
  256. package/dist/simulator/index.d.ts +124 -11
  257. package/dist/simulator/index.d.ts.map +1 -1
  258. package/dist/simulator/index.js +1568 -262
  259. package/dist/simulator/index.js.map +1 -1
  260. package/dist/simulator/partner-capabilities.cjs +77 -0
  261. package/dist/simulator/partner-capabilities.cjs.map +1 -0
  262. package/dist/simulator/partner-capabilities.d.cts +53 -0
  263. package/dist/simulator/partner-capabilities.d.cts.map +1 -0
  264. package/dist/simulator/partner-capabilities.d.ts +53 -0
  265. package/dist/simulator/partner-capabilities.d.ts.map +1 -0
  266. package/dist/simulator/partner-capabilities.js +73 -0
  267. package/dist/simulator/partner-capabilities.js.map +1 -0
  268. package/dist/simulator/partner.cjs +713 -0
  269. package/dist/simulator/partner.cjs.map +1 -0
  270. package/dist/simulator/partner.d.cts +186 -0
  271. package/dist/simulator/partner.d.cts.map +1 -0
  272. package/dist/simulator/partner.d.ts +186 -0
  273. package/dist/simulator/partner.d.ts.map +1 -0
  274. package/dist/simulator/partner.js +713 -0
  275. package/dist/simulator/partner.js.map +1 -0
  276. package/dist/simulator/validation.cjs +732 -25
  277. package/dist/simulator/validation.cjs.map +1 -1
  278. package/dist/simulator/validation.d.cts +145 -6
  279. package/dist/simulator/validation.d.cts.map +1 -1
  280. package/dist/simulator/validation.d.ts +145 -6
  281. package/dist/simulator/validation.d.ts.map +1 -1
  282. package/dist/simulator/validation.js +705 -26
  283. package/dist/simulator/validation.js.map +1 -1
  284. package/dist/streams/file-source.cjs +2 -2
  285. package/dist/streams/file-source.cjs.map +1 -1
  286. package/dist/streams/file-source.js +2 -2
  287. package/dist/streams/file-source.js.map +1 -1
  288. package/dist/streams/hash.cjs +246 -13
  289. package/dist/streams/hash.cjs.map +1 -1
  290. package/dist/streams/hash.d.cts +37 -12
  291. package/dist/streams/hash.d.cts.map +1 -1
  292. package/dist/streams/hash.d.ts +37 -12
  293. package/dist/streams/hash.d.ts.map +1 -1
  294. package/dist/streams/hash.js +246 -15
  295. package/dist/streams/hash.js.map +1 -1
  296. package/dist/streams/index.cjs +3 -1
  297. package/dist/streams/index.d.cts +1 -1
  298. package/dist/streams/index.d.cts.map +1 -1
  299. package/dist/streams/index.d.ts +1 -1
  300. package/dist/streams/index.d.ts.map +1 -1
  301. package/dist/streams/index.js +3 -3
  302. package/dist/streams/progress.cjs +63 -4
  303. package/dist/streams/progress.cjs.map +1 -1
  304. package/dist/streams/progress.d.cts +28 -2
  305. package/dist/streams/progress.d.cts.map +1 -1
  306. package/dist/streams/progress.d.ts +28 -2
  307. package/dist/streams/progress.d.ts.map +1 -1
  308. package/dist/streams/progress.js +63 -4
  309. package/dist/streams/progress.js.map +1 -1
  310. package/dist/streams/source.cjs +2 -1
  311. package/dist/streams/source.cjs.map +1 -1
  312. package/dist/streams/source.js +2 -1
  313. package/dist/streams/source.js.map +1 -1
  314. package/dist/sync/b2-sha1-reader.cjs +6 -2
  315. package/dist/sync/b2-sha1-reader.cjs.map +1 -1
  316. package/dist/sync/b2-sha1-reader.d.cts.map +1 -1
  317. package/dist/sync/b2-sha1-reader.d.ts.map +1 -1
  318. package/dist/sync/b2-sha1-reader.js +6 -2
  319. package/dist/sync/b2-sha1-reader.js.map +1 -1
  320. package/dist/sync/download-staging.cjs +156 -43
  321. package/dist/sync/download-staging.cjs.map +1 -1
  322. package/dist/sync/download-staging.d.cts +26 -2
  323. package/dist/sync/download-staging.d.cts.map +1 -1
  324. package/dist/sync/download-staging.d.ts +26 -2
  325. package/dist/sync/download-staging.d.ts.map +1 -1
  326. package/dist/sync/download-staging.js +155 -44
  327. package/dist/sync/download-staging.js.map +1 -1
  328. package/dist/sync/filters.cjs.map +1 -1
  329. package/dist/sync/filters.js.map +1 -1
  330. package/dist/sync/index.d.cts +1 -1
  331. package/dist/sync/index.d.cts.map +1 -1
  332. package/dist/sync/index.d.ts +1 -1
  333. package/dist/sync/index.d.ts.map +1 -1
  334. package/dist/sync/local-file-io.cjs +15 -6
  335. package/dist/sync/local-file-io.cjs.map +1 -1
  336. package/dist/sync/local-file-io.d.cts +3 -0
  337. package/dist/sync/local-file-io.d.cts.map +1 -1
  338. package/dist/sync/local-file-io.d.ts +3 -0
  339. package/dist/sync/local-file-io.d.ts.map +1 -1
  340. package/dist/sync/local-file-io.js +15 -6
  341. package/dist/sync/local-file-io.js.map +1 -1
  342. package/dist/sync/local-sha1.cjs +6 -15
  343. package/dist/sync/local-sha1.cjs.map +1 -1
  344. package/dist/sync/local-sha1.d.cts +0 -8
  345. package/dist/sync/local-sha1.d.cts.map +1 -1
  346. package/dist/sync/local-sha1.d.ts +0 -8
  347. package/dist/sync/local-sha1.d.ts.map +1 -1
  348. package/dist/sync/local-sha1.js +7 -15
  349. package/dist/sync/local-sha1.js.map +1 -1
  350. package/dist/sync/pairing.cjs +1 -0
  351. package/dist/sync/pairing.cjs.map +1 -1
  352. package/dist/sync/pairing.js +1 -0
  353. package/dist/sync/pairing.js.map +1 -1
  354. package/dist/sync/policies/compare.cjs +5 -3
  355. package/dist/sync/policies/compare.cjs.map +1 -1
  356. package/dist/sync/policies/compare.d.cts.map +1 -1
  357. package/dist/sync/policies/compare.d.ts.map +1 -1
  358. package/dist/sync/policies/compare.js +6 -4
  359. package/dist/sync/policies/compare.js.map +1 -1
  360. package/dist/sync/policies/index.cjs +4 -10
  361. package/dist/sync/policies/index.cjs.map +1 -1
  362. package/dist/sync/policies/index.js +4 -10
  363. package/dist/sync/policies/index.js.map +1 -1
  364. package/dist/sync/scanners/b2.cjs +4 -2
  365. package/dist/sync/scanners/b2.cjs.map +1 -1
  366. package/dist/sync/scanners/b2.d.cts.map +1 -1
  367. package/dist/sync/scanners/b2.d.ts.map +1 -1
  368. package/dist/sync/scanners/b2.js +4 -2
  369. package/dist/sync/scanners/b2.js.map +1 -1
  370. package/dist/sync/scanners/local.cjs +150 -33
  371. package/dist/sync/scanners/local.cjs.map +1 -1
  372. package/dist/sync/scanners/local.d.cts +6 -0
  373. package/dist/sync/scanners/local.d.cts.map +1 -1
  374. package/dist/sync/scanners/local.d.ts +6 -0
  375. package/dist/sync/scanners/local.d.ts.map +1 -1
  376. package/dist/sync/scanners/local.js +150 -33
  377. package/dist/sync/scanners/local.js.map +1 -1
  378. package/dist/sync/synchronizer.cjs +79 -31
  379. package/dist/sync/synchronizer.cjs.map +1 -1
  380. package/dist/sync/synchronizer.d.cts +1 -0
  381. package/dist/sync/synchronizer.d.cts.map +1 -1
  382. package/dist/sync/synchronizer.d.ts +1 -0
  383. package/dist/sync/synchronizer.d.ts.map +1 -1
  384. package/dist/sync/synchronizer.js +79 -31
  385. package/dist/sync/synchronizer.js.map +1 -1
  386. package/dist/sync/types.d.cts +19 -3
  387. package/dist/sync/types.d.cts.map +1 -1
  388. package/dist/sync/types.d.ts +19 -3
  389. package/dist/sync/types.d.ts.map +1 -1
  390. package/dist/types/auth.cjs +4 -0
  391. package/dist/types/auth.cjs.map +1 -1
  392. package/dist/types/auth.d.cts +4 -0
  393. package/dist/types/auth.d.cts.map +1 -1
  394. package/dist/types/auth.d.ts +4 -0
  395. package/dist/types/auth.d.ts.map +1 -1
  396. package/dist/types/auth.js +4 -0
  397. package/dist/types/auth.js.map +1 -1
  398. package/dist/types/backup.d.cts +85 -0
  399. package/dist/types/backup.d.cts.map +1 -0
  400. package/dist/types/backup.d.ts +85 -0
  401. package/dist/types/backup.d.ts.map +1 -0
  402. package/dist/types/bucket.cjs +81 -11
  403. package/dist/types/bucket.cjs.map +1 -1
  404. package/dist/types/bucket.d.cts +194 -41
  405. package/dist/types/bucket.d.cts.map +1 -1
  406. package/dist/types/bucket.d.ts +194 -41
  407. package/dist/types/bucket.d.ts.map +1 -1
  408. package/dist/types/bucket.js +67 -12
  409. package/dist/types/bucket.js.map +1 -1
  410. package/dist/types/download.cjs +62 -0
  411. package/dist/types/download.cjs.map +1 -0
  412. package/dist/types/download.d.cts +100 -16
  413. package/dist/types/download.d.cts.map +1 -1
  414. package/dist/types/download.d.ts +100 -16
  415. package/dist/types/download.d.ts.map +1 -1
  416. package/dist/types/download.js +61 -0
  417. package/dist/types/download.js.map +1 -0
  418. package/dist/types/encryption.cjs +76 -229
  419. package/dist/types/encryption.cjs.map +1 -1
  420. package/dist/types/encryption.d.cts +48 -6
  421. package/dist/types/encryption.d.cts.map +1 -1
  422. package/dist/types/encryption.d.ts +48 -6
  423. package/dist/types/encryption.d.ts.map +1 -1
  424. package/dist/types/encryption.js +74 -229
  425. package/dist/types/encryption.js.map +1 -1
  426. package/dist/types/errors.cjs +9 -0
  427. package/dist/types/errors.cjs.map +1 -1
  428. package/dist/types/errors.d.cts +1 -1
  429. package/dist/types/errors.d.cts.map +1 -1
  430. package/dist/types/errors.d.ts +1 -1
  431. package/dist/types/errors.d.ts.map +1 -1
  432. package/dist/types/errors.js +9 -0
  433. package/dist/types/errors.js.map +1 -1
  434. package/dist/types/file.cjs +3 -0
  435. package/dist/types/file.cjs.map +1 -1
  436. package/dist/types/file.d.cts +140 -18
  437. package/dist/types/file.d.cts.map +1 -1
  438. package/dist/types/file.d.ts +140 -18
  439. package/dist/types/file.d.ts.map +1 -1
  440. package/dist/types/file.js +3 -1
  441. package/dist/types/file.js.map +1 -1
  442. package/dist/types/ids.cjs +30 -0
  443. package/dist/types/ids.cjs.map +1 -1
  444. package/dist/types/ids.d.cts +32 -0
  445. package/dist/types/ids.d.cts.map +1 -1
  446. package/dist/types/ids.d.ts +32 -0
  447. package/dist/types/ids.d.ts.map +1 -1
  448. package/dist/types/ids.js +28 -1
  449. package/dist/types/ids.js.map +1 -1
  450. package/dist/types/index.d.cts +16 -12
  451. package/dist/types/index.d.cts.map +1 -1
  452. package/dist/types/index.d.ts +16 -12
  453. package/dist/types/index.d.ts.map +1 -1
  454. package/dist/types/key.d.cts +4 -3
  455. package/dist/types/key.d.cts.map +1 -1
  456. package/dist/types/key.d.ts +4 -3
  457. package/dist/types/key.d.ts.map +1 -1
  458. package/dist/types/lock.cjs.map +1 -1
  459. package/dist/types/lock.d.cts +14 -0
  460. package/dist/types/lock.d.cts.map +1 -1
  461. package/dist/types/lock.d.ts +14 -0
  462. package/dist/types/lock.d.ts.map +1 -1
  463. package/dist/types/lock.js.map +1 -1
  464. package/dist/types/notifications.cjs +31 -1
  465. package/dist/types/notifications.cjs.map +1 -1
  466. package/dist/types/notifications.d.cts +31 -4
  467. package/dist/types/notifications.d.cts.map +1 -1
  468. package/dist/types/notifications.d.ts +31 -4
  469. package/dist/types/notifications.d.ts.map +1 -1
  470. package/dist/types/notifications.js +30 -2
  471. package/dist/types/notifications.js.map +1 -1
  472. package/dist/types/partner.cjs +32 -0
  473. package/dist/types/partner.cjs.map +1 -0
  474. package/dist/types/partner.d.cts +386 -0
  475. package/dist/types/partner.d.cts.map +1 -0
  476. package/dist/types/partner.d.ts +386 -0
  477. package/dist/types/partner.d.ts.map +1 -0
  478. package/dist/types/partner.js +29 -0
  479. package/dist/types/partner.js.map +1 -0
  480. package/dist/types/upload.d.cts +35 -18
  481. package/dist/types/upload.d.cts.map +1 -1
  482. package/dist/types/upload.d.ts +35 -18
  483. package/dist/types/upload.d.ts.map +1 -1
  484. package/dist/upload/abort-scope.cjs +0 -45
  485. package/dist/upload/abort-scope.cjs.map +1 -1
  486. package/dist/upload/abort-scope.d.cts +0 -22
  487. package/dist/upload/abort-scope.d.cts.map +1 -1
  488. package/dist/upload/abort-scope.d.ts +0 -22
  489. package/dist/upload/abort-scope.d.ts.map +1 -1
  490. package/dist/upload/abort-scope.js +1 -44
  491. package/dist/upload/abort-scope.js.map +1 -1
  492. package/dist/upload/finish.cjs +3 -8
  493. package/dist/upload/finish.cjs.map +1 -1
  494. package/dist/upload/finish.d.cts.map +1 -1
  495. package/dist/upload/finish.d.ts.map +1 -1
  496. package/dist/upload/finish.js +1 -6
  497. package/dist/upload/finish.js.map +1 -1
  498. package/dist/upload/large.cjs +15 -8
  499. package/dist/upload/large.cjs.map +1 -1
  500. package/dist/upload/large.d.cts +31 -8
  501. package/dist/upload/large.d.cts.map +1 -1
  502. package/dist/upload/large.d.ts +31 -8
  503. package/dist/upload/large.d.ts.map +1 -1
  504. package/dist/upload/large.js +15 -8
  505. package/dist/upload/large.js.map +1 -1
  506. package/dist/upload/options.cjs.map +1 -1
  507. package/dist/upload/options.d.cts +24 -0
  508. package/dist/upload/options.d.cts.map +1 -1
  509. package/dist/upload/options.d.ts +24 -0
  510. package/dist/upload/options.d.ts.map +1 -1
  511. package/dist/upload/options.js.map +1 -1
  512. package/dist/upload/resume.cjs +6 -4
  513. package/dist/upload/resume.cjs.map +1 -1
  514. package/dist/upload/resume.d.cts +9 -5
  515. package/dist/upload/resume.d.cts.map +1 -1
  516. package/dist/upload/resume.d.ts +9 -5
  517. package/dist/upload/resume.d.ts.map +1 -1
  518. package/dist/upload/resume.js +6 -4
  519. package/dist/upload/resume.js.map +1 -1
  520. package/dist/upload/retry.cjs +25 -13
  521. package/dist/upload/retry.cjs.map +1 -1
  522. package/dist/upload/retry.d.cts.map +1 -1
  523. package/dist/upload/retry.d.ts.map +1 -1
  524. package/dist/upload/retry.js +25 -13
  525. package/dist/upload/retry.js.map +1 -1
  526. package/dist/upload/single.cjs +35 -30
  527. package/dist/upload/single.cjs.map +1 -1
  528. package/dist/upload/single.d.cts +12 -0
  529. package/dist/upload/single.d.cts.map +1 -1
  530. package/dist/upload/single.d.ts +12 -0
  531. package/dist/upload/single.d.ts.map +1 -1
  532. package/dist/upload/single.js +35 -30
  533. package/dist/upload/single.js.map +1 -1
  534. package/dist/upload/stream.cjs +18 -5
  535. package/dist/upload/stream.cjs.map +1 -1
  536. package/dist/upload/stream.d.cts +12 -0
  537. package/dist/upload/stream.d.cts.map +1 -1
  538. package/dist/upload/stream.d.ts +12 -0
  539. package/dist/upload/stream.d.ts.map +1 -1
  540. package/dist/upload/stream.js +15 -2
  541. package/dist/upload/stream.js.map +1 -1
  542. package/dist/util/abort.cjs +114 -0
  543. package/dist/util/abort.cjs.map +1 -0
  544. package/dist/util/abort.d.cts +65 -0
  545. package/dist/util/abort.d.cts.map +1 -0
  546. package/dist/util/abort.d.ts +65 -0
  547. package/dist/util/abort.d.ts.map +1 -0
  548. package/dist/util/abort.js +109 -0
  549. package/dist/util/abort.js.map +1 -0
  550. package/dist/util/defaults.cjs +3 -0
  551. package/dist/util/defaults.cjs.map +1 -1
  552. package/dist/util/defaults.d.cts +2 -0
  553. package/dist/util/defaults.d.cts.map +1 -1
  554. package/dist/util/defaults.d.ts +2 -0
  555. package/dist/util/defaults.d.ts.map +1 -1
  556. package/dist/util/defaults.js +3 -1
  557. package/dist/util/defaults.js.map +1 -1
  558. package/dist/util/md5.cjs +211 -0
  559. package/dist/util/md5.cjs.map +1 -0
  560. package/dist/util/md5.d.cts +43 -0
  561. package/dist/util/md5.d.cts.map +1 -0
  562. package/dist/util/md5.d.ts +43 -0
  563. package/dist/util/md5.d.ts.map +1 -0
  564. package/dist/util/md5.js +209 -0
  565. package/dist/util/md5.js.map +1 -0
  566. package/dist/util/normalize.cjs +5 -5
  567. package/dist/util/normalize.cjs.map +1 -1
  568. package/dist/util/normalize.d.cts +7 -7
  569. package/dist/util/normalize.d.cts.map +1 -1
  570. package/dist/util/normalize.d.ts +7 -7
  571. package/dist/util/normalize.d.ts.map +1 -1
  572. package/dist/util/normalize.js +5 -5
  573. package/dist/util/normalize.js.map +1 -1
  574. package/dist/util/paginator.cjs +7 -1
  575. package/dist/util/paginator.cjs.map +1 -1
  576. package/dist/util/paginator.d.cts +3 -1
  577. package/dist/util/paginator.d.cts.map +1 -1
  578. package/dist/util/paginator.d.ts +3 -1
  579. package/dist/util/paginator.d.ts.map +1 -1
  580. package/dist/util/paginator.js +7 -1
  581. package/dist/util/paginator.js.map +1 -1
  582. package/dist/version.cjs +56 -4
  583. package/dist/version.cjs.map +1 -1
  584. package/dist/version.d.cts +53 -4
  585. package/dist/version.d.cts.map +1 -1
  586. package/dist/version.d.ts +53 -4
  587. package/dist/version.d.ts.map +1 -1
  588. package/dist/version.js +52 -5
  589. package/dist/version.js.map +1 -1
  590. package/package.json +47 -18
@@ -0,0 +1,211 @@
1
+ //#region src/util/md5.ts
2
+ /**
3
+ * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).
4
+ *
5
+ * @param bytes - The raw bytes to encode.
6
+ *
7
+ * @returns The base64-encoded string.
8
+ */
9
+ function bytesToBase64(bytes) {
10
+ const g = globalThis;
11
+ if (g.Buffer) return g.Buffer.from(bytes).toString("base64");
12
+ let binary = "";
13
+ for (const byte of bytes) binary += String.fromCharCode(byte);
14
+ return btoa(binary);
15
+ }
16
+ var loadNodeCrypto = () => import("node:crypto");
17
+ function syncNodeCreateHash() {
18
+ const crypto = globalThis.process?.getBuiltinModule?.("node:crypto");
19
+ if (!crypto || typeof crypto !== "object") return null;
20
+ const { createHash } = crypto;
21
+ return typeof createHash === "function" ? createHash : null;
22
+ }
23
+ /**
24
+ * Computes the MD5 digest of the given bytes as a base64 string. Prefers
25
+ * `node:crypto` for native speed when available; falls back to a pure-JS
26
+ * implementation in browser / edge runtimes because WebCrypto's
27
+ * `crypto.subtle.digest` deliberately does not support MD5.
28
+ *
29
+ * MD5 is used only for wire-protocol integrity checks, not as a security
30
+ * boundary.
31
+ *
32
+ * @param bytes - The bytes to digest.
33
+ *
34
+ * @returns The base64-encoded MD5 digest.
35
+ *
36
+ * @internal
37
+ */
38
+ async function md5Base64(bytes) {
39
+ return md5Base64WithCryptoLoader(bytes, loadNodeCrypto);
40
+ }
41
+ /**
42
+ * Computes the MD5 digest with an injected async crypto loader.
43
+ *
44
+ * @param bytes - The bytes to digest.
45
+ * @param loadCrypto - Crypto module loader used by runtime fallback tests.
46
+ *
47
+ * @returns The base64-encoded MD5 digest.
48
+ *
49
+ * @internal
50
+ */
51
+ async function md5Base64WithCryptoLoader(bytes, loadCrypto) {
52
+ try {
53
+ const { createHash } = await loadCrypto();
54
+ if (typeof createHash !== "function") throw new Error("createHash unavailable");
55
+ return createHash("md5").update(bytes).digest("base64");
56
+ } catch {
57
+ return md5Base64Sync(bytes);
58
+ }
59
+ }
60
+ /**
61
+ * Computes the MD5 digest of the given bytes as a base64 string without
62
+ * dynamic imports.
63
+ *
64
+ * @param bytes - The bytes to digest.
65
+ *
66
+ * @returns The base64-encoded MD5 digest.
67
+ *
68
+ * @internal
69
+ */
70
+ function md5Base64Sync(bytes) {
71
+ const createHash = syncNodeCreateHash();
72
+ if (createHash) return createHash("md5").update(bytes).digest("base64");
73
+ return bytesToBase64(md5Bytes(bytes));
74
+ }
75
+ /**
76
+ * Pure-JS MD5 implementation per RFC 1321. Returns the 16-byte digest of the
77
+ * input. Used as a browser fallback for SSE-C key MD5 computation; not
78
+ * intended for security-sensitive purposes (MD5 is broken cryptographically).
79
+ *
80
+ * @param data - The bytes to hash.
81
+ *
82
+ * @returns The 16-byte MD5 digest.
83
+ */
84
+ function md5Bytes(data) {
85
+ const originalBitLength = data.length * 8;
86
+ const paddedLength = data.length + 1 + 8 + 63 & -64;
87
+ const msg = new Uint8Array(paddedLength);
88
+ msg.set(data);
89
+ msg[data.length] = 128;
90
+ const view = new DataView(msg.buffer);
91
+ view.setUint32(paddedLength - 8, originalBitLength >>> 0, true);
92
+ view.setUint32(paddedLength - 4, Math.floor(originalBitLength / 4294967296), true);
93
+ let a0 = 1732584193;
94
+ let b0 = 4023233417;
95
+ let c0 = 2562383102;
96
+ let d0 = 271733878;
97
+ const s = [
98
+ 7,
99
+ 12,
100
+ 17,
101
+ 22,
102
+ 7,
103
+ 12,
104
+ 17,
105
+ 22,
106
+ 7,
107
+ 12,
108
+ 17,
109
+ 22,
110
+ 7,
111
+ 12,
112
+ 17,
113
+ 22,
114
+ 5,
115
+ 9,
116
+ 14,
117
+ 20,
118
+ 5,
119
+ 9,
120
+ 14,
121
+ 20,
122
+ 5,
123
+ 9,
124
+ 14,
125
+ 20,
126
+ 5,
127
+ 9,
128
+ 14,
129
+ 20,
130
+ 4,
131
+ 11,
132
+ 16,
133
+ 23,
134
+ 4,
135
+ 11,
136
+ 16,
137
+ 23,
138
+ 4,
139
+ 11,
140
+ 16,
141
+ 23,
142
+ 4,
143
+ 11,
144
+ 16,
145
+ 23,
146
+ 6,
147
+ 10,
148
+ 15,
149
+ 21,
150
+ 6,
151
+ 10,
152
+ 15,
153
+ 21,
154
+ 6,
155
+ 10,
156
+ 15,
157
+ 21,
158
+ 6,
159
+ 10,
160
+ 15,
161
+ 21
162
+ ];
163
+ const k = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296));
164
+ const leftRotate = (x, c) => x << c | x >>> 32 - c;
165
+ for (let offset = 0; offset < paddedLength; offset += 64) {
166
+ let a = a0;
167
+ let b = b0;
168
+ let c = c0;
169
+ let d = d0;
170
+ const m = Array.from({ length: 16 }, (_, i) => view.getUint32(offset + i * 4, true));
171
+ for (let i = 0; i < 64; i++) {
172
+ let f;
173
+ let g;
174
+ if (i < 16) {
175
+ f = b & c | ~b & d;
176
+ g = i;
177
+ } else if (i < 32) {
178
+ f = d & b | ~d & c;
179
+ g = (5 * i + 1) % 16;
180
+ } else if (i < 48) {
181
+ f = b ^ c ^ d;
182
+ g = (3 * i + 5) % 16;
183
+ } else {
184
+ f = c ^ (b | ~d);
185
+ g = 7 * i % 16;
186
+ }
187
+ const temp = d;
188
+ d = c;
189
+ c = b;
190
+ b = b + leftRotate(a + f + k[i] + m[g] >>> 0, s[i]) >>> 0;
191
+ a = temp;
192
+ }
193
+ a0 = a0 + a >>> 0;
194
+ b0 = b0 + b >>> 0;
195
+ c0 = c0 + c >>> 0;
196
+ d0 = d0 + d >>> 0;
197
+ }
198
+ const out = /* @__PURE__ */ new Uint8Array(16);
199
+ const outView = new DataView(out.buffer);
200
+ outView.setUint32(0, a0, true);
201
+ outView.setUint32(4, b0, true);
202
+ outView.setUint32(8, c0, true);
203
+ outView.setUint32(12, d0, true);
204
+ return out;
205
+ }
206
+ //#endregion
207
+ exports.md5Base64 = md5Base64;
208
+ exports.md5Base64Sync = md5Base64Sync;
209
+ exports.md5Base64WithCryptoLoader = md5Base64WithCryptoLoader;
210
+
211
+ //# sourceMappingURL=md5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5.cjs","names":[],"sources":["../../src/util/md5.ts"],"sourcesContent":["/**\n * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).\n *\n * @param bytes - The raw bytes to encode.\n *\n * @returns The base64-encoded string.\n */\nfunction bytesToBase64(bytes: Uint8Array): string {\n const g = globalThis as {\n Buffer?: { from(b: Uint8Array): { toString(encoding: string): string } }\n }\n if (g.Buffer) return g.Buffer.from(bytes).toString('base64')\n\n let binary = ''\n for (const byte of bytes) binary += String.fromCharCode(byte)\n return btoa(binary)\n}\n\ntype SyncNodeHash = {\n update(bytes: Uint8Array): SyncNodeHash\n digest(encoding: 'base64'): string\n}\n\ntype AsyncNodeCryptoLoader = () => Promise<{ createHash?: unknown }>\n\nconst loadNodeCrypto: AsyncNodeCryptoLoader = () => import('node:crypto')\n\nfunction syncNodeCreateHash(): ((algorithm: string) => SyncNodeHash) | null {\n const g = globalThis as {\n process?: {\n getBuiltinModule?: (name: string) => unknown\n }\n }\n const crypto = g.process?.getBuiltinModule?.('node:crypto')\n if (!crypto || typeof crypto !== 'object') return null\n const { createHash } = crypto as { createHash?: unknown }\n return typeof createHash === 'function'\n ? (createHash as (algorithm: string) => SyncNodeHash)\n : null\n}\n\n/**\n * Computes the MD5 digest of the given bytes as a base64 string. Prefers\n * `node:crypto` for native speed when available; falls back to a pure-JS\n * implementation in browser / edge runtimes because WebCrypto's\n * `crypto.subtle.digest` deliberately does not support MD5.\n *\n * MD5 is used only for wire-protocol integrity checks, not as a security\n * boundary.\n *\n * @param bytes - The bytes to digest.\n *\n * @returns The base64-encoded MD5 digest.\n *\n * @internal\n */\nexport async function md5Base64(bytes: Uint8Array): Promise<string> {\n return md5Base64WithCryptoLoader(bytes, loadNodeCrypto)\n}\n\n/**\n * Computes the MD5 digest with an injected async crypto loader.\n *\n * @param bytes - The bytes to digest.\n * @param loadCrypto - Crypto module loader used by runtime fallback tests.\n *\n * @returns The base64-encoded MD5 digest.\n *\n * @internal\n */\nexport async function md5Base64WithCryptoLoader(\n bytes: Uint8Array,\n loadCrypto: AsyncNodeCryptoLoader,\n): Promise<string> {\n try {\n const { createHash } = await loadCrypto()\n // Vite's browser shim resolves the import but does not implement\n // `createHash`. Probe explicitly so we fall through to the pure-JS path.\n if (typeof createHash !== 'function') throw new Error('createHash unavailable')\n return createHash('md5').update(bytes).digest('base64')\n } catch {\n return md5Base64Sync(bytes)\n }\n}\n\n/**\n * Computes the MD5 digest of the given bytes as a base64 string without\n * dynamic imports.\n *\n * @param bytes - The bytes to digest.\n *\n * @returns The base64-encoded MD5 digest.\n *\n * @internal\n */\nexport function md5Base64Sync(bytes: Uint8Array): string {\n const createHash = syncNodeCreateHash()\n if (createHash) return createHash('md5').update(bytes).digest('base64')\n\n return bytesToBase64(md5Bytes(bytes))\n}\n\n/**\n * Pure-JS MD5 implementation per RFC 1321. Returns the 16-byte digest of the\n * input. Used as a browser fallback for SSE-C key MD5 computation; not\n * intended for security-sensitive purposes (MD5 is broken cryptographically).\n *\n * @param data - The bytes to hash.\n *\n * @returns The 16-byte MD5 digest.\n */\nfunction md5Bytes(data: Uint8Array): Uint8Array {\n const originalBitLength = data.length * 8\n const withOne = data.length + 1\n const paddedLength = (withOne + 8 + 63) & ~63\n const msg = new Uint8Array(paddedLength)\n msg.set(data)\n msg[data.length] = 0x80\n const view = new DataView(msg.buffer)\n view.setUint32(paddedLength - 8, originalBitLength >>> 0, true)\n view.setUint32(paddedLength - 4, Math.floor(originalBitLength / 0x1_0000_0000), true)\n\n let a0 = 0x67452301\n let b0 = 0xefcdab89\n let c0 = 0x98badcfe\n let d0 = 0x10325476\n\n const s = [\n 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9,\n 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21,\n 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,\n ]\n const k = Array.from({ length: 64 }, (_, i) =>\n Math.floor(Math.abs(Math.sin(i + 1)) * 0x1_0000_0000),\n )\n\n const leftRotate = (x: number, c: number) => (x << c) | (x >>> (32 - c))\n\n for (let offset = 0; offset < paddedLength; offset += 64) {\n let a = a0\n let b = b0\n let c = c0\n let d = d0\n\n const m = Array.from({ length: 16 }, (_, i) => view.getUint32(offset + i * 4, true))\n\n for (let i = 0; i < 64; i++) {\n let f: number\n let g: number\n if (i < 16) {\n f = (b & c) | (~b & d)\n g = i\n } else if (i < 32) {\n f = (d & b) | (~d & c)\n g = (5 * i + 1) % 16\n } else if (i < 48) {\n f = b ^ c ^ d\n g = (3 * i + 5) % 16\n } else {\n f = c ^ (b | ~d)\n g = (7 * i) % 16\n }\n\n const temp = d\n d = c\n c = b\n b =\n (b + leftRotate((a + f + (k[i] as number) + (m[g] as number)) >>> 0, s[i] as number)) >>> 0\n a = temp\n }\n\n a0 = (a0 + a) >>> 0\n b0 = (b0 + b) >>> 0\n c0 = (c0 + c) >>> 0\n d0 = (d0 + d) >>> 0\n }\n\n const out = new Uint8Array(16)\n const outView = new DataView(out.buffer)\n outView.setUint32(0, a0, true)\n outView.setUint32(4, b0, true)\n outView.setUint32(8, c0, true)\n outView.setUint32(12, d0, true)\n return out\n}\n"],"mappings":";;;;;;;;AAOA,SAAS,cAAc,OAA2B;CAChD,MAAM,IAAI;CAGV,IAAI,EAAE,QAAQ,OAAO,EAAE,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;CAE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IAAI,KAAK,IAAI,CAAC;IACd,IAAK,IAAI,IAAK;GAChB;GAEA,MAAM,OAAO;GACb,IAAI;GACJ,IAAI;GACJ,IACG,IAAI,WAAY,IAAI,IAAK,EAAE,KAAiB,EAAE,OAAmB,GAAG,EAAE,EAAY,MAAO;GAC5F,IAAI;EACN;EAEA,KAAM,KAAK,MAAO;EAClB,KAAM,KAAK,MAAO;EAClB,KAAM,KAAK,MAAO;EAClB,KAAM,KAAK,MAAO;CACpB;CAEA,MAAM,sBAAM,IAAI,WAAW,EAAE;CAC7B,MAAM,UAAU,IAAI,SAAS,IAAI,MAAM;CACvC,QAAQ,UAAU,GAAG,IAAI,IAAI;CAC7B,QAAQ,UAAU,GAAG,IAAI,IAAI;CAC7B,QAAQ,UAAU,GAAG,IAAI,IAAI;CAC7B,QAAQ,UAAU,IAAI,IAAI,IAAI;CAC9B,OAAO;AACT"}
@@ -0,0 +1,43 @@
1
+ type AsyncNodeCryptoLoader = () => Promise<{
2
+ createHash?: unknown;
3
+ }>;
4
+ /**
5
+ * Computes the MD5 digest of the given bytes as a base64 string. Prefers
6
+ * `node:crypto` for native speed when available; falls back to a pure-JS
7
+ * implementation in browser / edge runtimes because WebCrypto's
8
+ * `crypto.subtle.digest` deliberately does not support MD5.
9
+ *
10
+ * MD5 is used only for wire-protocol integrity checks, not as a security
11
+ * boundary.
12
+ *
13
+ * @param bytes - The bytes to digest.
14
+ *
15
+ * @returns The base64-encoded MD5 digest.
16
+ *
17
+ * @internal
18
+ */
19
+ export declare function md5Base64(bytes: Uint8Array): Promise<string>;
20
+ /**
21
+ * Computes the MD5 digest with an injected async crypto loader.
22
+ *
23
+ * @param bytes - The bytes to digest.
24
+ * @param loadCrypto - Crypto module loader used by runtime fallback tests.
25
+ *
26
+ * @returns The base64-encoded MD5 digest.
27
+ *
28
+ * @internal
29
+ */
30
+ export declare function md5Base64WithCryptoLoader(bytes: Uint8Array, loadCrypto: AsyncNodeCryptoLoader): Promise<string>;
31
+ /**
32
+ * Computes the MD5 digest of the given bytes as a base64 string without
33
+ * dynamic imports.
34
+ *
35
+ * @param bytes - The bytes to digest.
36
+ *
37
+ * @returns The base64-encoded MD5 digest.
38
+ *
39
+ * @internal
40
+ */
41
+ export declare function md5Base64Sync(bytes: Uint8Array): string;
42
+ export {};
43
+ //# sourceMappingURL=md5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5.d.ts","sourceRoot":"","sources":["../../src/util/md5.js"],"names":[],"mappings":"AAuBA,KAAK,qBAAqB,GAAG,MAAM,OAAO,CAAC;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAkBpE;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAElE;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAKvD"}
@@ -0,0 +1,43 @@
1
+ type AsyncNodeCryptoLoader = () => Promise<{
2
+ createHash?: unknown;
3
+ }>;
4
+ /**
5
+ * Computes the MD5 digest of the given bytes as a base64 string. Prefers
6
+ * `node:crypto` for native speed when available; falls back to a pure-JS
7
+ * implementation in browser / edge runtimes because WebCrypto's
8
+ * `crypto.subtle.digest` deliberately does not support MD5.
9
+ *
10
+ * MD5 is used only for wire-protocol integrity checks, not as a security
11
+ * boundary.
12
+ *
13
+ * @param bytes - The bytes to digest.
14
+ *
15
+ * @returns The base64-encoded MD5 digest.
16
+ *
17
+ * @internal
18
+ */
19
+ export declare function md5Base64(bytes: Uint8Array): Promise<string>;
20
+ /**
21
+ * Computes the MD5 digest with an injected async crypto loader.
22
+ *
23
+ * @param bytes - The bytes to digest.
24
+ * @param loadCrypto - Crypto module loader used by runtime fallback tests.
25
+ *
26
+ * @returns The base64-encoded MD5 digest.
27
+ *
28
+ * @internal
29
+ */
30
+ export declare function md5Base64WithCryptoLoader(bytes: Uint8Array, loadCrypto: AsyncNodeCryptoLoader): Promise<string>;
31
+ /**
32
+ * Computes the MD5 digest of the given bytes as a base64 string without
33
+ * dynamic imports.
34
+ *
35
+ * @param bytes - The bytes to digest.
36
+ *
37
+ * @returns The base64-encoded MD5 digest.
38
+ *
39
+ * @internal
40
+ */
41
+ export declare function md5Base64Sync(bytes: Uint8Array): string;
42
+ export {};
43
+ //# sourceMappingURL=md5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5.d.ts","sourceRoot":"","sources":["../../src/util/md5.js"],"names":[],"mappings":"AAuBA,KAAK,qBAAqB,GAAG,MAAM,OAAO,CAAC;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAkBpE;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAElE;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAKvD"}
@@ -0,0 +1,209 @@
1
+ //#region src/util/md5.ts
2
+ /**
3
+ * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).
4
+ *
5
+ * @param bytes - The raw bytes to encode.
6
+ *
7
+ * @returns The base64-encoded string.
8
+ */
9
+ function bytesToBase64(bytes) {
10
+ const g = globalThis;
11
+ if (g.Buffer) return g.Buffer.from(bytes).toString("base64");
12
+ let binary = "";
13
+ for (const byte of bytes) binary += String.fromCharCode(byte);
14
+ return btoa(binary);
15
+ }
16
+ var loadNodeCrypto = () => import("node:crypto");
17
+ function syncNodeCreateHash() {
18
+ const crypto = globalThis.process?.getBuiltinModule?.("node:crypto");
19
+ if (!crypto || typeof crypto !== "object") return null;
20
+ const { createHash } = crypto;
21
+ return typeof createHash === "function" ? createHash : null;
22
+ }
23
+ /**
24
+ * Computes the MD5 digest of the given bytes as a base64 string. Prefers
25
+ * `node:crypto` for native speed when available; falls back to a pure-JS
26
+ * implementation in browser / edge runtimes because WebCrypto's
27
+ * `crypto.subtle.digest` deliberately does not support MD5.
28
+ *
29
+ * MD5 is used only for wire-protocol integrity checks, not as a security
30
+ * boundary.
31
+ *
32
+ * @param bytes - The bytes to digest.
33
+ *
34
+ * @returns The base64-encoded MD5 digest.
35
+ *
36
+ * @internal
37
+ */
38
+ async function md5Base64(bytes) {
39
+ return md5Base64WithCryptoLoader(bytes, loadNodeCrypto);
40
+ }
41
+ /**
42
+ * Computes the MD5 digest with an injected async crypto loader.
43
+ *
44
+ * @param bytes - The bytes to digest.
45
+ * @param loadCrypto - Crypto module loader used by runtime fallback tests.
46
+ *
47
+ * @returns The base64-encoded MD5 digest.
48
+ *
49
+ * @internal
50
+ */
51
+ async function md5Base64WithCryptoLoader(bytes, loadCrypto) {
52
+ try {
53
+ const { createHash } = await loadCrypto();
54
+ if (typeof createHash !== "function") throw new Error("createHash unavailable");
55
+ return createHash("md5").update(bytes).digest("base64");
56
+ } catch {
57
+ return md5Base64Sync(bytes);
58
+ }
59
+ }
60
+ /**
61
+ * Computes the MD5 digest of the given bytes as a base64 string without
62
+ * dynamic imports.
63
+ *
64
+ * @param bytes - The bytes to digest.
65
+ *
66
+ * @returns The base64-encoded MD5 digest.
67
+ *
68
+ * @internal
69
+ */
70
+ function md5Base64Sync(bytes) {
71
+ const createHash = syncNodeCreateHash();
72
+ if (createHash) return createHash("md5").update(bytes).digest("base64");
73
+ return bytesToBase64(md5Bytes(bytes));
74
+ }
75
+ /**
76
+ * Pure-JS MD5 implementation per RFC 1321. Returns the 16-byte digest of the
77
+ * input. Used as a browser fallback for SSE-C key MD5 computation; not
78
+ * intended for security-sensitive purposes (MD5 is broken cryptographically).
79
+ *
80
+ * @param data - The bytes to hash.
81
+ *
82
+ * @returns The 16-byte MD5 digest.
83
+ */
84
+ function md5Bytes(data) {
85
+ const originalBitLength = data.length * 8;
86
+ const paddedLength = data.length + 1 + 8 + 63 & -64;
87
+ const msg = new Uint8Array(paddedLength);
88
+ msg.set(data);
89
+ msg[data.length] = 128;
90
+ const view = new DataView(msg.buffer);
91
+ view.setUint32(paddedLength - 8, originalBitLength >>> 0, true);
92
+ view.setUint32(paddedLength - 4, Math.floor(originalBitLength / 4294967296), true);
93
+ let a0 = 1732584193;
94
+ let b0 = 4023233417;
95
+ let c0 = 2562383102;
96
+ let d0 = 271733878;
97
+ const s = [
98
+ 7,
99
+ 12,
100
+ 17,
101
+ 22,
102
+ 7,
103
+ 12,
104
+ 17,
105
+ 22,
106
+ 7,
107
+ 12,
108
+ 17,
109
+ 22,
110
+ 7,
111
+ 12,
112
+ 17,
113
+ 22,
114
+ 5,
115
+ 9,
116
+ 14,
117
+ 20,
118
+ 5,
119
+ 9,
120
+ 14,
121
+ 20,
122
+ 5,
123
+ 9,
124
+ 14,
125
+ 20,
126
+ 5,
127
+ 9,
128
+ 14,
129
+ 20,
130
+ 4,
131
+ 11,
132
+ 16,
133
+ 23,
134
+ 4,
135
+ 11,
136
+ 16,
137
+ 23,
138
+ 4,
139
+ 11,
140
+ 16,
141
+ 23,
142
+ 4,
143
+ 11,
144
+ 16,
145
+ 23,
146
+ 6,
147
+ 10,
148
+ 15,
149
+ 21,
150
+ 6,
151
+ 10,
152
+ 15,
153
+ 21,
154
+ 6,
155
+ 10,
156
+ 15,
157
+ 21,
158
+ 6,
159
+ 10,
160
+ 15,
161
+ 21
162
+ ];
163
+ const k = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296));
164
+ const leftRotate = (x, c) => x << c | x >>> 32 - c;
165
+ for (let offset = 0; offset < paddedLength; offset += 64) {
166
+ let a = a0;
167
+ let b = b0;
168
+ let c = c0;
169
+ let d = d0;
170
+ const m = Array.from({ length: 16 }, (_, i) => view.getUint32(offset + i * 4, true));
171
+ for (let i = 0; i < 64; i++) {
172
+ let f;
173
+ let g;
174
+ if (i < 16) {
175
+ f = b & c | ~b & d;
176
+ g = i;
177
+ } else if (i < 32) {
178
+ f = d & b | ~d & c;
179
+ g = (5 * i + 1) % 16;
180
+ } else if (i < 48) {
181
+ f = b ^ c ^ d;
182
+ g = (3 * i + 5) % 16;
183
+ } else {
184
+ f = c ^ (b | ~d);
185
+ g = 7 * i % 16;
186
+ }
187
+ const temp = d;
188
+ d = c;
189
+ c = b;
190
+ b = b + leftRotate(a + f + k[i] + m[g] >>> 0, s[i]) >>> 0;
191
+ a = temp;
192
+ }
193
+ a0 = a0 + a >>> 0;
194
+ b0 = b0 + b >>> 0;
195
+ c0 = c0 + c >>> 0;
196
+ d0 = d0 + d >>> 0;
197
+ }
198
+ const out = /* @__PURE__ */ new Uint8Array(16);
199
+ const outView = new DataView(out.buffer);
200
+ outView.setUint32(0, a0, true);
201
+ outView.setUint32(4, b0, true);
202
+ outView.setUint32(8, c0, true);
203
+ outView.setUint32(12, d0, true);
204
+ return out;
205
+ }
206
+ //#endregion
207
+ export { md5Base64, md5Base64Sync, md5Base64WithCryptoLoader };
208
+
209
+ //# sourceMappingURL=md5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5.js","names":[],"sources":["../../src/util/md5.ts"],"sourcesContent":["/**\n * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).\n *\n * @param bytes - The raw bytes to encode.\n *\n * @returns The base64-encoded string.\n */\nfunction bytesToBase64(bytes: Uint8Array): string {\n const g = globalThis as {\n Buffer?: { from(b: Uint8Array): { toString(encoding: string): string } }\n }\n if (g.Buffer) return g.Buffer.from(bytes).toString('base64')\n\n let binary = ''\n for (const byte of bytes) binary += String.fromCharCode(byte)\n return btoa(binary)\n}\n\ntype SyncNodeHash = {\n update(bytes: Uint8Array): SyncNodeHash\n digest(encoding: 'base64'): string\n}\n\ntype AsyncNodeCryptoLoader = () => Promise<{ createHash?: unknown }>\n\nconst loadNodeCrypto: AsyncNodeCryptoLoader = () => import('node:crypto')\n\nfunction syncNodeCreateHash(): ((algorithm: string) => SyncNodeHash) | null {\n const g = globalThis as {\n process?: {\n getBuiltinModule?: (name: string) => unknown\n }\n }\n const crypto = g.process?.getBuiltinModule?.('node:crypto')\n if (!crypto || typeof crypto !== 'object') return null\n const { createHash } = crypto as { createHash?: unknown }\n return typeof createHash === 'function'\n ? (createHash as (algorithm: string) => SyncNodeHash)\n : null\n}\n\n/**\n * Computes the MD5 digest of the given bytes as a base64 string. Prefers\n * `node:crypto` for native speed when available; falls back to a pure-JS\n * implementation in browser / edge runtimes because WebCrypto's\n * `crypto.subtle.digest` deliberately does not support MD5.\n *\n * MD5 is used only for wire-protocol integrity checks, not as a security\n * boundary.\n *\n * @param bytes - The bytes to digest.\n *\n * @returns The base64-encoded MD5 digest.\n *\n * @internal\n */\nexport async function md5Base64(bytes: Uint8Array): Promise<string> {\n return md5Base64WithCryptoLoader(bytes, loadNodeCrypto)\n}\n\n/**\n * Computes the MD5 digest with an injected async crypto loader.\n *\n * @param bytes - The bytes to digest.\n * @param loadCrypto - Crypto module loader used by runtime fallback tests.\n *\n * @returns The base64-encoded MD5 digest.\n *\n * @internal\n */\nexport async function md5Base64WithCryptoLoader(\n bytes: Uint8Array,\n loadCrypto: AsyncNodeCryptoLoader,\n): Promise<string> {\n try {\n const { createHash } = await loadCrypto()\n // Vite's browser shim resolves the import but does not implement\n // `createHash`. Probe explicitly so we fall through to the pure-JS path.\n if (typeof createHash !== 'function') throw new Error('createHash unavailable')\n return createHash('md5').update(bytes).digest('base64')\n } catch {\n return md5Base64Sync(bytes)\n }\n}\n\n/**\n * Computes the MD5 digest of the given bytes as a base64 string without\n * dynamic imports.\n *\n * @param bytes - The bytes to digest.\n *\n * @returns The base64-encoded MD5 digest.\n *\n * @internal\n */\nexport function md5Base64Sync(bytes: Uint8Array): string {\n const createHash = syncNodeCreateHash()\n if (createHash) return createHash('md5').update(bytes).digest('base64')\n\n return bytesToBase64(md5Bytes(bytes))\n}\n\n/**\n * Pure-JS MD5 implementation per RFC 1321. Returns the 16-byte digest of the\n * input. Used as a browser fallback for SSE-C key MD5 computation; not\n * intended for security-sensitive purposes (MD5 is broken cryptographically).\n *\n * @param data - The bytes to hash.\n *\n * @returns The 16-byte MD5 digest.\n */\nfunction md5Bytes(data: Uint8Array): Uint8Array {\n const originalBitLength = data.length * 8\n const withOne = data.length + 1\n const paddedLength = (withOne + 8 + 63) & ~63\n const msg = new Uint8Array(paddedLength)\n msg.set(data)\n msg[data.length] = 0x80\n const view = new DataView(msg.buffer)\n view.setUint32(paddedLength - 8, originalBitLength >>> 0, true)\n view.setUint32(paddedLength - 4, Math.floor(originalBitLength / 0x1_0000_0000), true)\n\n let a0 = 0x67452301\n let b0 = 0xefcdab89\n let c0 = 0x98badcfe\n let d0 = 0x10325476\n\n const s = [\n 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9,\n 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21,\n 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,\n ]\n const k = Array.from({ length: 64 }, (_, i) =>\n Math.floor(Math.abs(Math.sin(i + 1)) * 0x1_0000_0000),\n )\n\n const leftRotate = (x: number, c: number) => (x << c) | (x >>> (32 - c))\n\n for (let offset = 0; offset < paddedLength; offset += 64) {\n let a = a0\n let b = b0\n let c = c0\n let d = d0\n\n const m = Array.from({ length: 16 }, (_, i) => view.getUint32(offset + i * 4, true))\n\n for (let i = 0; i < 64; i++) {\n let f: number\n let g: number\n if (i < 16) {\n f = (b & c) | (~b & d)\n g = i\n } else if (i < 32) {\n f = (d & b) | (~d & c)\n g = (5 * i + 1) % 16\n } else if (i < 48) {\n f = b ^ c ^ d\n g = (3 * i + 5) % 16\n } else {\n f = c ^ (b | ~d)\n g = (7 * i) % 16\n }\n\n const temp = d\n d = c\n c = b\n b =\n (b + leftRotate((a + f + (k[i] as number) + (m[g] as number)) >>> 0, s[i] as number)) >>> 0\n a = temp\n }\n\n a0 = (a0 + a) >>> 0\n b0 = (b0 + b) >>> 0\n c0 = (c0 + c) >>> 0\n d0 = (d0 + d) >>> 0\n }\n\n const out = new Uint8Array(16)\n const outView = new DataView(out.buffer)\n outView.setUint32(0, a0, true)\n outView.setUint32(4, b0, true)\n outView.setUint32(8, c0, true)\n outView.setUint32(12, d0, true)\n return out\n}\n"],"mappings":";;;;;;;;AAOA,SAAS,cAAc,OAA2B;CAChD,MAAM,IAAI;CAGV,IAAI,EAAE,QAAQ,OAAO,EAAE,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;CAE3D,IAAI,SAAS;CACb,KAAK,MAAM,QAAQ,OAAO,UAAU,OAAO,aAAa,IAAI;CAC5D,OAAO,KAAK,MAAM;AACpB;AASA,IAAM,uBAA8C,OAAO;AAE3D,SAAS,qBAAmE;CAM1E,MAAM,SAAS,WAAE,SAAS,mBAAmB,aAAa;CAC1D,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAO;CAClD,MAAM,EAAE,eAAe;CACvB,OAAO,OAAO,eAAe,aACxB,aACD;AACN;;;;;;;;;;;;;;;;AAiBA,eAAsB,UAAU,OAAoC;CAClE,OAAO,0BAA0B,OAAO,cAAc;AACxD;;;;;;;;;;;AAYA,eAAsB,0BACpB,OACA,YACiB;CACjB,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,WAAW;EAGxC,IAAI,OAAO,eAAe,YAAY,MAAM,IAAI,MAAM,wBAAwB;EAC9E,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,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callers paying for change detection
37
37
  * (e.g. React memo) see referential stability.
38
38
  *
39
- * @typeParam T - Any object with a `contentSha1: string | null` field.
39
+ * @typeParam T - Any object with a `contentSha1?: string | null` field.
40
40
  *
41
41
  * @param fv - The wire-shape file-version object.
42
42
  *
@@ -50,11 +50,11 @@ function normalizeFileVersionSha1(fv) {
50
50
  }
51
51
  /**
52
52
  * Returns a new list-response object with `normalizeFileVersionSha1`
53
- * applied to every entry in `files`. Used at the `b2_list_file_names` /
54
- * `b2_list_file_versions` boundary so list output shares the same
55
- * SHA-1 semantics as the singular endpoints.
53
+ * applied to every entry in `files`. Used at file-version and unfinished
54
+ * large-file list boundaries so list output shares the same SHA-1 semantics
55
+ * as the singular endpoints.
56
56
  *
57
- * @typeParam F - Any object with a `contentSha1: string | null` field.
57
+ * @typeParam F - Any object with a `contentSha1?: string | null` field.
58
58
  * @typeParam R - The list-response shape (must have a `files` array of `F`).
59
59
  *
60
60
  * @param resp - The wire-shape list response.
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.cjs","names":[],"sources":["../../src/util/normalize.ts"],"sourcesContent":["/**\n * Wire-shape → SDK-shape normalization helpers.\n *\n * B2 occasionally uses sentinel strings on the wire where a missing\n * value would be more idiomatic in TypeScript. The biggest offender is\n * `contentSha1: 'none'` on files completed via `b2_finish_large_file`\n * (multipart-finished files don't have a whole-file SHA-1; B2 sends the\n * literal three-letter string). The SDK's `FileVersion.contentSha1` is\n * typed `string | null` to signal that absence — this module collapses\n * the wire sentinel to `null` so callers can write\n * `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.\n *\n * Normalization happens at the RawClient boundary so every SDK consumer\n * (RawClient direct users, the high-level facade, the simulator-driven\n * tests, generated docs) sees the same `null` value.\n *\n * @packageDocumentation\n */\n\n/**\n * Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for\n * SHA-1-shaped fields. Any other string passes through unchanged.\n *\n * @param raw - SHA-1 string from the wire, or `null`/`undefined`.\n *\n * @returns A hex SHA-1 string, or `null` when the wire said \"no hash\".\n */\nexport function normalizeSha1(raw: string | null | undefined): string | null {\n if (raw === null || raw === undefined || raw === 'none') return null\n return raw\n}\n\n/**\n * Returns a new file-version-shaped object with the `contentSha1: 'none'`\n * sentinel collapsed to `null`. Pass-through when the value is already\n * `null` or a real hash. The object reference is preserved if no\n * substitution was needed, so callers paying for change detection\n * (e.g. React memo) see referential stability.\n *\n * @typeParam T - Any object with a `contentSha1: string | null` field.\n *\n * @param fv - The wire-shape file-version object.\n *\n * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.\n */\nexport function normalizeFileVersionSha1<T extends { readonly contentSha1: string | null }>(\n fv: T,\n): T {\n return fv.contentSha1 === 'none' ? { ...fv, contentSha1: null } : fv\n}\n\n/**\n * Returns a new list-response object with `normalizeFileVersionSha1`\n * applied to every entry in `files`. Used at the `b2_list_file_names` /\n * `b2_list_file_versions` boundary so list output shares the same\n * SHA-1 semantics as the singular endpoints.\n *\n * @typeParam F - Any object with a `contentSha1: string | null` field.\n * @typeParam R - The list-response shape (must have a `files` array of `F`).\n *\n * @param resp - The wire-shape list response.\n *\n * @returns A response with normalized `files`. `resp.files` is a new array.\n */\nexport function normalizeFileVersionListSha1<\n F extends { readonly contentSha1: string | null },\n R extends { readonly files: readonly F[] },\n>(resp: R): R {\n return { ...resp, files: resp.files.map(normalizeFileVersionSha1) }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,cAAc,KAA+C;CAC3E,IAAI,QAAQ,QAAQ,QAAQ,KAAA,KAAa,QAAQ,QAAQ,OAAO;CAChE,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,yBACd,IACG;CACH,OAAO,GAAG,gBAAgB,SAAS;EAAE,GAAG;EAAI,aAAa;CAAK,IAAI;AACpE;;;;;;;;;;;;;;AAeA,SAAgB,6BAGd,MAAY;CACZ,OAAO;EAAE,GAAG;EAAM,OAAO,KAAK,MAAM,IAAI,wBAAwB;CAAE;AACpE"}
1
+ {"version":3,"file":"normalize.cjs","names":[],"sources":["../../src/util/normalize.ts"],"sourcesContent":["/**\n * Wire-shape → SDK-shape normalization helpers.\n *\n * B2 occasionally uses sentinel strings on the wire where a missing\n * value would be more idiomatic in TypeScript. The biggest offender is\n * `contentSha1: 'none'` on files completed via `b2_finish_large_file`\n * (multipart-finished files don't have a whole-file SHA-1; B2 sends the\n * literal three-letter string). The SDK's `FileVersion.contentSha1` is\n * typed `string | null` to signal that absence — this module collapses\n * the wire sentinel to `null` so callers can write\n * `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.\n *\n * Normalization happens at the RawClient boundary so every SDK consumer\n * (RawClient direct users, the high-level facade, the simulator-driven\n * tests, generated docs) sees the same `null` value.\n *\n * @packageDocumentation\n */\n\n/**\n * Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for\n * SHA-1-shaped fields. Any other string passes through unchanged.\n *\n * @param raw - SHA-1 string from the wire, or `null`/`undefined`.\n *\n * @returns A hex SHA-1 string, or `null` when the wire said \"no hash\".\n */\nexport function normalizeSha1(raw: string | null | undefined): string | null {\n if (raw === null || raw === undefined || raw === 'none') return null\n return raw\n}\n\n/**\n * Returns a new file-version-shaped object with the `contentSha1: 'none'`\n * sentinel collapsed to `null`. Pass-through when the value is already\n * `null` or a real hash. The object reference is preserved if no\n * substitution was needed, so callers paying for change detection\n * (e.g. React memo) see referential stability.\n *\n * @typeParam T - Any object with a `contentSha1?: string | null` field.\n *\n * @param fv - The wire-shape file-version object.\n *\n * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.\n */\nexport function normalizeFileVersionSha1<T extends { readonly contentSha1?: string | null }>(\n fv: T,\n): T {\n return fv.contentSha1 === 'none' ? { ...fv, contentSha1: null } : fv\n}\n\n/**\n * Returns a new list-response object with `normalizeFileVersionSha1`\n * applied to every entry in `files`. Used at file-version and unfinished\n * large-file list boundaries so list output shares the same SHA-1 semantics\n * as the singular endpoints.\n *\n * @typeParam F - Any object with a `contentSha1?: string | null` field.\n * @typeParam R - The list-response shape (must have a `files` array of `F`).\n *\n * @param resp - The wire-shape list response.\n *\n * @returns A response with normalized `files`. `resp.files` is a new array.\n */\nexport function normalizeFileVersionListSha1<\n F extends { readonly contentSha1?: string | null },\n R extends { readonly files: readonly F[] },\n>(resp: R): R {\n return { ...resp, files: resp.files.map(normalizeFileVersionSha1) }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,cAAc,KAA+C;CAC3E,IAAI,QAAQ,QAAQ,QAAQ,KAAA,KAAa,QAAQ,QAAQ,OAAO;CAChE,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,yBACd,IACG;CACH,OAAO,GAAG,gBAAgB,SAAS;EAAE,GAAG;EAAI,aAAa;CAAK,IAAI;AACpE;;;;;;;;;;;;;;AAeA,SAAgB,6BAGd,MAAY;CACZ,OAAO;EAAE,GAAG;EAAM,OAAO,KAAK,MAAM,IAAI,wBAAwB;CAAE;AACpE"}
@@ -32,22 +32,22 @@ export declare function normalizeSha1(raw: string | null | undefined): string |
32
32
  * substitution was needed, so callers paying for change detection
33
33
  * (e.g. React memo) see referential stability.
34
34
  *
35
- * @typeParam T - Any object with a `contentSha1: string | null` field.
35
+ * @typeParam T - Any object with a `contentSha1?: string | null` field.
36
36
  *
37
37
  * @param fv - The wire-shape file-version object.
38
38
  *
39
39
  * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.
40
40
  */
41
41
  export declare function normalizeFileVersionSha1<T extends {
42
- readonly contentSha1: string | null;
42
+ readonly contentSha1?: string | null;
43
43
  }>(fv: T): T;
44
44
  /**
45
45
  * Returns a new list-response object with `normalizeFileVersionSha1`
46
- * applied to every entry in `files`. Used at the `b2_list_file_names` /
47
- * `b2_list_file_versions` boundary so list output shares the same
48
- * SHA-1 semantics as the singular endpoints.
46
+ * applied to every entry in `files`. Used at file-version and unfinished
47
+ * large-file list boundaries so list output shares the same SHA-1 semantics
48
+ * as the singular endpoints.
49
49
  *
50
- * @typeParam F - Any object with a `contentSha1: string | null` field.
50
+ * @typeParam F - Any object with a `contentSha1?: string | null` field.
51
51
  * @typeParam R - The list-response shape (must have a `files` array of `F`).
52
52
  *
53
53
  * @param resp - The wire-shape list response.
@@ -55,7 +55,7 @@ export declare function normalizeFileVersionSha1<T extends {
55
55
  * @returns A response with normalized `files`. `resp.files` is a new array.
56
56
  */
57
57
  export declare function normalizeFileVersionListSha1<F extends {
58
- readonly contentSha1: string | null;
58
+ readonly contentSha1?: string | null;
59
59
  }, R extends {
60
60
  readonly files: readonly F[];
61
61
  }>(resp: R): R;
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/util/normalize.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACxF,EAAE,EAAE,CAAC,GACJ,CAAC,CAEH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACjD,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAA;CAAE,EAC1C,IAAI,EAAE,CAAC,GAAG,CAAC,CAEZ"}
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/util/normalize.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACzF,EAAE,EAAE,CAAC,GACJ,CAAC,CAEH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAClD,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAA;CAAE,EAC1C,IAAI,EAAE,CAAC,GAAG,CAAC,CAEZ"}
@@ -32,22 +32,22 @@ export declare function normalizeSha1(raw: string | null | undefined): string |
32
32
  * substitution was needed, so callers paying for change detection
33
33
  * (e.g. React memo) see referential stability.
34
34
  *
35
- * @typeParam T - Any object with a `contentSha1: string | null` field.
35
+ * @typeParam T - Any object with a `contentSha1?: string | null` field.
36
36
  *
37
37
  * @param fv - The wire-shape file-version object.
38
38
  *
39
39
  * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.
40
40
  */
41
41
  export declare function normalizeFileVersionSha1<T extends {
42
- readonly contentSha1: string | null;
42
+ readonly contentSha1?: string | null;
43
43
  }>(fv: T): T;
44
44
  /**
45
45
  * Returns a new list-response object with `normalizeFileVersionSha1`
46
- * applied to every entry in `files`. Used at the `b2_list_file_names` /
47
- * `b2_list_file_versions` boundary so list output shares the same
48
- * SHA-1 semantics as the singular endpoints.
46
+ * applied to every entry in `files`. Used at file-version and unfinished
47
+ * large-file list boundaries so list output shares the same SHA-1 semantics
48
+ * as the singular endpoints.
49
49
  *
50
- * @typeParam F - Any object with a `contentSha1: string | null` field.
50
+ * @typeParam F - Any object with a `contentSha1?: string | null` field.
51
51
  * @typeParam R - The list-response shape (must have a `files` array of `F`).
52
52
  *
53
53
  * @param resp - The wire-shape list response.
@@ -55,7 +55,7 @@ export declare function normalizeFileVersionSha1<T extends {
55
55
  * @returns A response with normalized `files`. `resp.files` is a new array.
56
56
  */
57
57
  export declare function normalizeFileVersionListSha1<F extends {
58
- readonly contentSha1: string | null;
58
+ readonly contentSha1?: string | null;
59
59
  }, R extends {
60
60
  readonly files: readonly F[];
61
61
  }>(resp: R): R;