@backblaze-labs/b2-sdk 0.1.0 → 0.3.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 (885) hide show
  1. package/CHANGELOG.md +151 -5
  2. package/README.md +163 -34
  3. package/dist/_virtual/_b2-sdk-version-json.cjs +4 -0
  4. package/dist/_virtual/_b2-sdk-version-json.js +4 -0
  5. package/dist/auth/account-info.d.cts +32 -0
  6. package/dist/auth/account-info.d.cts.map +1 -1
  7. package/dist/auth/account-info.d.ts +32 -0
  8. package/dist/auth/account-info.d.ts.map +1 -1
  9. package/dist/auth/file.cjs +408 -207
  10. package/dist/auth/file.cjs.map +1 -1
  11. package/dist/auth/file.d.cts +77 -3
  12. package/dist/auth/file.d.cts.map +1 -1
  13. package/dist/auth/file.d.ts +77 -3
  14. package/dist/auth/file.d.ts.map +1 -1
  15. package/dist/auth/file.js +407 -207
  16. package/dist/auth/file.js.map +1 -1
  17. package/dist/auth/in-memory.cjs +212 -183
  18. package/dist/auth/in-memory.cjs.map +1 -1
  19. package/dist/auth/in-memory.d.cts +8 -0
  20. package/dist/auth/in-memory.d.cts.map +1 -1
  21. package/dist/auth/in-memory.d.ts +8 -0
  22. package/dist/auth/in-memory.d.ts.map +1 -1
  23. package/dist/auth/in-memory.js +211 -182
  24. package/dist/auth/in-memory.js.map +1 -1
  25. package/dist/auth/index.cjs +7 -9
  26. package/dist/auth/index.d.cts +3 -2
  27. package/dist/auth/index.d.cts.map +1 -1
  28. package/dist/auth/index.d.ts +3 -2
  29. package/dist/auth/index.d.ts.map +1 -1
  30. package/dist/auth/index.js +2 -8
  31. package/dist/auth/realms.cjs +80 -7
  32. package/dist/auth/realms.cjs.map +1 -1
  33. package/dist/auth/realms.d.cts +27 -4
  34. package/dist/auth/realms.d.cts.map +1 -1
  35. package/dist/auth/realms.d.ts +27 -4
  36. package/dist/auth/realms.d.ts.map +1 -1
  37. package/dist/auth/realms.js +80 -9
  38. package/dist/auth/realms.js.map +1 -1
  39. package/dist/auth/upload-url-pool.cjs +55 -51
  40. package/dist/auth/upload-url-pool.cjs.map +1 -1
  41. package/dist/auth/upload-url-pool.js +55 -51
  42. package/dist/auth/upload-url-pool.js.map +1 -1
  43. package/dist/backup/client.cjs +206 -0
  44. package/dist/backup/client.cjs.map +1 -0
  45. package/dist/backup/client.d.cts +238 -0
  46. package/dist/backup/client.d.cts.map +1 -0
  47. package/dist/backup/client.d.ts +238 -0
  48. package/dist/backup/client.d.ts.map +1 -0
  49. package/dist/backup/client.js +206 -0
  50. package/dist/backup/client.js.map +1 -0
  51. package/dist/backup/index.cjs +15 -0
  52. package/dist/backup/index.d.cts +22 -0
  53. package/dist/backup/index.d.cts.map +1 -0
  54. package/dist/backup/index.d.ts +22 -0
  55. package/dist/backup/index.d.ts.map +1 -0
  56. package/dist/backup/index.js +7 -0
  57. package/dist/backup/raw.cjs +146 -0
  58. package/dist/backup/raw.cjs.map +1 -0
  59. package/dist/backup/raw.d.cts +122 -0
  60. package/dist/backup/raw.d.cts.map +1 -0
  61. package/dist/backup/raw.d.ts +122 -0
  62. package/dist/backup/raw.d.ts.map +1 -0
  63. package/dist/backup/raw.js +146 -0
  64. package/dist/backup/raw.js.map +1 -0
  65. package/dist/bucket.cjs +786 -787
  66. package/dist/bucket.cjs.map +1 -1
  67. package/dist/bucket.d.cts +35 -47
  68. package/dist/bucket.d.cts.map +1 -1
  69. package/dist/bucket.d.ts +35 -47
  70. package/dist/bucket.d.ts.map +1 -1
  71. package/dist/bucket.js +781 -782
  72. package/dist/bucket.js.map +1 -1
  73. package/dist/client.cjs +246 -228
  74. package/dist/client.cjs.map +1 -1
  75. package/dist/client.d.cts +25 -17
  76. package/dist/client.d.cts.map +1 -1
  77. package/dist/client.d.ts +25 -17
  78. package/dist/client.d.ts.map +1 -1
  79. package/dist/client.js +243 -225
  80. package/dist/client.js.map +1 -1
  81. package/dist/copy/large.cjs +116 -71
  82. package/dist/copy/large.cjs.map +1 -1
  83. package/dist/copy/large.d.cts +6 -0
  84. package/dist/copy/large.d.cts.map +1 -1
  85. package/dist/copy/large.d.ts +6 -0
  86. package/dist/copy/large.d.ts.map +1 -1
  87. package/dist/copy/large.js +114 -69
  88. package/dist/copy/large.js.map +1 -1
  89. package/dist/download/checksum.cjs +93 -0
  90. package/dist/download/checksum.cjs.map +1 -0
  91. package/dist/download/checksum.d.cts +40 -0
  92. package/dist/download/checksum.d.cts.map +1 -0
  93. package/dist/download/checksum.d.ts +40 -0
  94. package/dist/download/checksum.d.ts.map +1 -0
  95. package/dist/download/checksum.js +91 -0
  96. package/dist/download/checksum.js.map +1 -0
  97. package/dist/download/parallel.cjs +251 -118
  98. package/dist/download/parallel.cjs.map +1 -1
  99. package/dist/download/parallel.d.cts +13 -2
  100. package/dist/download/parallel.d.cts.map +1 -1
  101. package/dist/download/parallel.d.ts +13 -2
  102. package/dist/download/parallel.d.ts.map +1 -1
  103. package/dist/download/parallel.js +249 -116
  104. package/dist/download/parallel.js.map +1 -1
  105. package/dist/download/single.cjs +323 -97
  106. package/dist/download/single.cjs.map +1 -1
  107. package/dist/download/single.d.cts +6 -1
  108. package/dist/download/single.d.cts.map +1 -1
  109. package/dist/download/single.d.ts +6 -1
  110. package/dist/download/single.d.ts.map +1 -1
  111. package/dist/download/single.js +322 -99
  112. package/dist/download/single.js.map +1 -1
  113. package/dist/errors/index.cjs +869 -243
  114. package/dist/errors/index.cjs.map +1 -1
  115. package/dist/errors/index.d.cts +404 -82
  116. package/dist/errors/index.d.cts.map +1 -1
  117. package/dist/errors/index.d.ts +404 -82
  118. package/dist/errors/index.d.ts.map +1 -1
  119. package/dist/errors/index.js +835 -261
  120. package/dist/errors/index.js.map +1 -1
  121. package/dist/http/retry.cjs +45 -28
  122. package/dist/http/retry.cjs.map +1 -1
  123. package/dist/http/retry.d.cts +15 -2
  124. package/dist/http/retry.d.cts.map +1 -1
  125. package/dist/http/retry.d.ts +15 -2
  126. package/dist/http/retry.d.ts.map +1 -1
  127. package/dist/http/retry.js +46 -31
  128. package/dist/http/retry.js.map +1 -1
  129. package/dist/http/transport.cjs +476 -140
  130. package/dist/http/transport.cjs.map +1 -1
  131. package/dist/http/transport.d.cts +46 -5
  132. package/dist/http/transport.d.cts.map +1 -1
  133. package/dist/http/transport.d.ts +46 -5
  134. package/dist/http/transport.d.ts.map +1 -1
  135. package/dist/http/transport.js +474 -140
  136. package/dist/http/transport.js.map +1 -1
  137. package/dist/http/url-guard.cjs +154 -89
  138. package/dist/http/url-guard.cjs.map +1 -1
  139. package/dist/http/url-guard.d.cts +25 -3
  140. package/dist/http/url-guard.d.cts.map +1 -1
  141. package/dist/http/url-guard.d.ts +25 -3
  142. package/dist/http/url-guard.d.ts.map +1 -1
  143. package/dist/http/url-guard.js +152 -90
  144. package/dist/http/url-guard.js.map +1 -1
  145. package/dist/http/user-agent.cjs +84 -44
  146. package/dist/http/user-agent.cjs.map +1 -1
  147. package/dist/http/user-agent.js +84 -46
  148. package/dist/http/user-agent.js.map +1 -1
  149. package/dist/index.cjs +124 -77
  150. package/dist/index.d.cts +29 -21
  151. package/dist/index.d.cts.map +1 -1
  152. package/dist/index.d.ts +29 -21
  153. package/dist/index.d.ts.map +1 -1
  154. package/dist/index.js +18 -72
  155. package/dist/internal/b2-naming.cjs +66 -0
  156. package/dist/internal/b2-naming.cjs.map +1 -0
  157. package/dist/internal/b2-naming.d.cts +43 -0
  158. package/dist/internal/b2-naming.d.cts.map +1 -0
  159. package/dist/internal/b2-naming.d.ts +43 -0
  160. package/dist/internal/b2-naming.d.ts.map +1 -0
  161. package/dist/internal/b2-naming.js +60 -0
  162. package/dist/internal/b2-naming.js.map +1 -0
  163. package/dist/internal/upload-retry-options.cjs +21 -0
  164. package/dist/internal/upload-retry-options.cjs.map +1 -0
  165. package/dist/internal/upload-retry-options.d.cts +12 -0
  166. package/dist/internal/upload-retry-options.d.cts.map +1 -0
  167. package/dist/internal/upload-retry-options.d.ts +12 -0
  168. package/dist/internal/upload-retry-options.d.ts.map +1 -0
  169. package/dist/internal/upload-retry-options.js +21 -0
  170. package/dist/internal/upload-retry-options.js.map +1 -0
  171. package/dist/internal/url-redaction.cjs +31 -0
  172. package/dist/internal/url-redaction.cjs.map +1 -0
  173. package/dist/internal/url-redaction.d.cts +17 -0
  174. package/dist/internal/url-redaction.d.cts.map +1 -0
  175. package/dist/internal/url-redaction.d.ts +17 -0
  176. package/dist/internal/url-redaction.d.ts.map +1 -0
  177. package/dist/internal/url-redaction.js +31 -0
  178. package/dist/internal/url-redaction.js.map +1 -0
  179. package/dist/notifications/index.cjs +4 -6
  180. package/dist/notifications/index.d.cts +1 -1
  181. package/dist/notifications/index.d.cts.map +1 -1
  182. package/dist/notifications/index.d.ts +1 -1
  183. package/dist/notifications/index.d.ts.map +1 -1
  184. package/dist/notifications/index.js +1 -6
  185. package/dist/notifications/webhook.cjs +195 -85
  186. package/dist/notifications/webhook.cjs.map +1 -1
  187. package/dist/notifications/webhook.d.cts.map +1 -1
  188. package/dist/notifications/webhook.d.ts.map +1 -1
  189. package/dist/notifications/webhook.js +195 -87
  190. package/dist/notifications/webhook.js.map +1 -1
  191. package/dist/object.cjs +253 -210
  192. package/dist/object.cjs.map +1 -1
  193. package/dist/object.d.cts +13 -57
  194. package/dist/object.d.cts.map +1 -1
  195. package/dist/object.d.ts +13 -57
  196. package/dist/object.d.ts.map +1 -1
  197. package/dist/object.js +249 -206
  198. package/dist/object.js.map +1 -1
  199. package/dist/partner/account-info.d.cts +43 -0
  200. package/dist/partner/account-info.d.cts.map +1 -0
  201. package/dist/partner/account-info.d.ts +43 -0
  202. package/dist/partner/account-info.d.ts.map +1 -0
  203. package/dist/partner/auth-clone.cjs +64 -0
  204. package/dist/partner/auth-clone.cjs.map +1 -0
  205. package/dist/partner/auth-clone.d.cts +27 -0
  206. package/dist/partner/auth-clone.d.cts.map +1 -0
  207. package/dist/partner/auth-clone.d.ts +27 -0
  208. package/dist/partner/auth-clone.d.ts.map +1 -0
  209. package/dist/partner/auth-clone.js +63 -0
  210. package/dist/partner/auth-clone.js.map +1 -0
  211. package/dist/partner/auth-core.cjs +175 -0
  212. package/dist/partner/auth-core.cjs.map +1 -0
  213. package/dist/partner/auth-core.d.cts +111 -0
  214. package/dist/partner/auth-core.d.cts.map +1 -0
  215. package/dist/partner/auth-core.d.ts +111 -0
  216. package/dist/partner/auth-core.d.ts.map +1 -0
  217. package/dist/partner/auth-core.js +175 -0
  218. package/dist/partner/auth-core.js.map +1 -0
  219. package/dist/partner/auth-shape.cjs +36 -0
  220. package/dist/partner/auth-shape.cjs.map +1 -0
  221. package/dist/partner/auth-shape.d.cts +12 -0
  222. package/dist/partner/auth-shape.d.cts.map +1 -0
  223. package/dist/partner/auth-shape.d.ts +12 -0
  224. package/dist/partner/auth-shape.d.ts.map +1 -0
  225. package/dist/partner/auth-shape.js +36 -0
  226. package/dist/partner/auth-shape.js.map +1 -0
  227. package/dist/partner/client.cjs +255 -0
  228. package/dist/partner/client.cjs.map +1 -0
  229. package/dist/partner/client.d.cts +335 -0
  230. package/dist/partner/client.d.cts.map +1 -0
  231. package/dist/partner/client.d.ts +335 -0
  232. package/dist/partner/client.d.ts.map +1 -0
  233. package/dist/partner/client.js +255 -0
  234. package/dist/partner/client.js.map +1 -0
  235. package/dist/partner/endpoint-url.cjs +108 -0
  236. package/dist/partner/endpoint-url.cjs.map +1 -0
  237. package/dist/partner/endpoint-url.d.cts +72 -0
  238. package/dist/partner/endpoint-url.d.cts.map +1 -0
  239. package/dist/partner/endpoint-url.d.ts +72 -0
  240. package/dist/partner/endpoint-url.d.ts.map +1 -0
  241. package/dist/partner/endpoint-url.js +105 -0
  242. package/dist/partner/endpoint-url.js.map +1 -0
  243. package/dist/partner/in-memory.cjs +135 -0
  244. package/dist/partner/in-memory.cjs.map +1 -0
  245. package/dist/partner/in-memory.d.cts +99 -0
  246. package/dist/partner/in-memory.d.cts.map +1 -0
  247. package/dist/partner/in-memory.d.ts +99 -0
  248. package/dist/partner/in-memory.d.ts.map +1 -0
  249. package/dist/partner/in-memory.js +135 -0
  250. package/dist/partner/in-memory.js.map +1 -0
  251. package/dist/partner/index.cjs +18 -0
  252. package/dist/partner/index.d.cts +23 -0
  253. package/dist/partner/index.d.cts.map +1 -0
  254. package/dist/partner/index.d.ts +23 -0
  255. package/dist/partner/index.d.ts.map +1 -0
  256. package/dist/partner/index.js +7 -0
  257. package/dist/partner/raw.cjs +392 -0
  258. package/dist/partner/raw.cjs.map +1 -0
  259. package/dist/partner/raw.d.cts +223 -0
  260. package/dist/partner/raw.d.cts.map +1 -0
  261. package/dist/partner/raw.d.ts +223 -0
  262. package/dist/partner/raw.d.ts.map +1 -0
  263. package/dist/partner/raw.js +390 -0
  264. package/dist/partner/raw.js.map +1 -0
  265. package/dist/partner/redaction-placeholders.cjs +10 -0
  266. package/dist/partner/redaction-placeholders.cjs.map +1 -0
  267. package/dist/partner/redaction-placeholders.d.cts +5 -0
  268. package/dist/partner/redaction-placeholders.d.cts.map +1 -0
  269. package/dist/partner/redaction-placeholders.d.ts +5 -0
  270. package/dist/partner/redaction-placeholders.d.ts.map +1 -0
  271. package/dist/partner/redaction-placeholders.js +9 -0
  272. package/dist/partner/redaction-placeholders.js.map +1 -0
  273. package/dist/partner/redaction.cjs +267 -0
  274. package/dist/partner/redaction.cjs.map +1 -0
  275. package/dist/partner/redaction.d.cts +124 -0
  276. package/dist/partner/redaction.d.cts.map +1 -0
  277. package/dist/partner/redaction.d.ts +124 -0
  278. package/dist/partner/redaction.d.ts.map +1 -0
  279. package/dist/partner/redaction.js +257 -0
  280. package/dist/partner/redaction.js.map +1 -0
  281. package/dist/raw/encoding.cjs +74 -35
  282. package/dist/raw/encoding.cjs.map +1 -1
  283. package/dist/raw/encoding.js +74 -38
  284. package/dist/raw/encoding.js.map +1 -1
  285. package/dist/raw/index.cjs +740 -587
  286. package/dist/raw/index.cjs.map +1 -1
  287. package/dist/raw/index.d.cts +126 -19
  288. package/dist/raw/index.d.cts.map +1 -1
  289. package/dist/raw/index.d.ts +126 -19
  290. package/dist/raw/index.d.ts.map +1 -1
  291. package/dist/raw/index.js +736 -589
  292. package/dist/raw/index.js.map +1 -1
  293. package/dist/raw/url.cjs +111 -0
  294. package/dist/raw/url.cjs.map +1 -0
  295. package/dist/raw/url.d.cts +41 -0
  296. package/dist/raw/url.d.cts.map +1 -0
  297. package/dist/raw/url.d.ts +41 -0
  298. package/dist/raw/url.d.ts.map +1 -0
  299. package/dist/raw/url.js +110 -0
  300. package/dist/raw/url.js.map +1 -0
  301. package/dist/s3/index.cjs +355 -18
  302. package/dist/s3/index.cjs.map +1 -1
  303. package/dist/s3/index.d.cts +233 -5
  304. package/dist/s3/index.d.cts.map +1 -1
  305. package/dist/s3/index.d.ts +233 -5
  306. package/dist/s3/index.d.ts.map +1 -1
  307. package/dist/s3/index.js +351 -22
  308. package/dist/s3/index.js.map +1 -1
  309. package/dist/s3/sigv4.cjs +154 -0
  310. package/dist/s3/sigv4.cjs.map +1 -0
  311. package/dist/s3/sigv4.d.cts +43 -0
  312. package/dist/s3/sigv4.d.cts.map +1 -0
  313. package/dist/s3/sigv4.d.ts +43 -0
  314. package/dist/s3/sigv4.d.ts.map +1 -0
  315. package/dist/s3/sigv4.js +153 -0
  316. package/dist/s3/sigv4.js.map +1 -0
  317. package/dist/s3/validation.cjs +69 -0
  318. package/dist/s3/validation.cjs.map +1 -0
  319. package/dist/s3/validation.d.cts +43 -0
  320. package/dist/s3/validation.d.cts.map +1 -0
  321. package/dist/s3/validation.d.ts +43 -0
  322. package/dist/s3/validation.d.ts.map +1 -0
  323. package/dist/s3/validation.js +66 -0
  324. package/dist/s3/validation.js.map +1 -0
  325. package/dist/simulator/capabilities.cjs +63 -48
  326. package/dist/simulator/capabilities.cjs.map +1 -1
  327. package/dist/simulator/capabilities.js +63 -49
  328. package/dist/simulator/capabilities.js.map +1 -1
  329. package/dist/simulator/index.cjs +3114 -1547
  330. package/dist/simulator/index.cjs.map +1 -1
  331. package/dist/simulator/index.d.cts +186 -20
  332. package/dist/simulator/index.d.cts.map +1 -1
  333. package/dist/simulator/index.d.ts +186 -20
  334. package/dist/simulator/index.d.ts.map +1 -1
  335. package/dist/simulator/index.js +3098 -1545
  336. package/dist/simulator/index.js.map +1 -1
  337. package/dist/simulator/partner.cjs +719 -0
  338. package/dist/simulator/partner.cjs.map +1 -0
  339. package/dist/simulator/partner.d.cts +183 -0
  340. package/dist/simulator/partner.d.cts.map +1 -0
  341. package/dist/simulator/partner.d.ts +183 -0
  342. package/dist/simulator/partner.d.ts.map +1 -0
  343. package/dist/simulator/partner.js +718 -0
  344. package/dist/simulator/partner.js.map +1 -0
  345. package/dist/simulator/validation.cjs +772 -157
  346. package/dist/simulator/validation.cjs.map +1 -1
  347. package/dist/simulator/validation.d.cts +120 -21
  348. package/dist/simulator/validation.d.cts.map +1 -1
  349. package/dist/simulator/validation.d.ts +120 -21
  350. package/dist/simulator/validation.d.ts.map +1 -1
  351. package/dist/simulator/validation.js +755 -167
  352. package/dist/simulator/validation.js.map +1 -1
  353. package/dist/streams/collect.cjs +74 -24
  354. package/dist/streams/collect.cjs.map +1 -1
  355. package/dist/streams/collect.d.cts +14 -1
  356. package/dist/streams/collect.d.cts.map +1 -1
  357. package/dist/streams/collect.d.ts +14 -1
  358. package/dist/streams/collect.d.ts.map +1 -1
  359. package/dist/streams/collect.js +74 -25
  360. package/dist/streams/collect.js.map +1 -1
  361. package/dist/streams/file-source.cjs +287 -0
  362. package/dist/streams/file-source.cjs.map +1 -0
  363. package/dist/streams/file-source.d.cts +96 -0
  364. package/dist/streams/file-source.d.cts.map +1 -0
  365. package/dist/streams/file-source.d.ts +96 -0
  366. package/dist/streams/file-source.d.ts.map +1 -0
  367. package/dist/streams/file-source.js +286 -0
  368. package/dist/streams/file-source.js.map +1 -0
  369. package/dist/streams/hash.cjs +207 -115
  370. package/dist/streams/hash.cjs.map +1 -1
  371. package/dist/streams/hash.d.cts +5 -4
  372. package/dist/streams/hash.d.cts.map +1 -1
  373. package/dist/streams/hash.d.ts +5 -4
  374. package/dist/streams/hash.d.ts.map +1 -1
  375. package/dist/streams/hash.js +208 -95
  376. package/dist/streams/hash.js.map +1 -1
  377. package/dist/streams/index.cjs +12 -12
  378. package/dist/streams/index.d.cts +3 -3
  379. package/dist/streams/index.d.cts.map +1 -1
  380. package/dist/streams/index.d.ts +3 -3
  381. package/dist/streams/index.d.ts.map +1 -1
  382. package/dist/streams/index.js +3 -11
  383. package/dist/streams/progress.cjs +60 -46
  384. package/dist/streams/progress.cjs.map +1 -1
  385. package/dist/streams/progress.js +60 -46
  386. package/dist/streams/progress.js.map +1 -1
  387. package/dist/streams/source.cjs +317 -146
  388. package/dist/streams/source.cjs.map +1 -1
  389. package/dist/streams/source.d.cts +56 -18
  390. package/dist/streams/source.d.cts.map +1 -1
  391. package/dist/streams/source.d.ts +56 -18
  392. package/dist/streams/source.d.ts.map +1 -1
  393. package/dist/streams/source.js +313 -149
  394. package/dist/streams/source.js.map +1 -1
  395. package/dist/sync/actions/index.cjs +236 -184
  396. package/dist/sync/actions/index.cjs.map +1 -1
  397. package/dist/sync/actions/index.d.cts +29 -21
  398. package/dist/sync/actions/index.d.cts.map +1 -1
  399. package/dist/sync/actions/index.d.ts +29 -21
  400. package/dist/sync/actions/index.d.ts.map +1 -1
  401. package/dist/sync/actions/index.js +236 -190
  402. package/dist/sync/actions/index.js.map +1 -1
  403. package/dist/sync/b2-sha1-reader.cjs +152 -0
  404. package/dist/sync/b2-sha1-reader.cjs.map +1 -0
  405. package/dist/sync/b2-sha1-reader.d.cts +58 -0
  406. package/dist/sync/b2-sha1-reader.d.cts.map +1 -0
  407. package/dist/sync/b2-sha1-reader.d.ts +58 -0
  408. package/dist/sync/b2-sha1-reader.d.ts.map +1 -0
  409. package/dist/sync/b2-sha1-reader.js +149 -0
  410. package/dist/sync/b2-sha1-reader.js.map +1 -0
  411. package/dist/sync/download-staging.cjs +266 -0
  412. package/dist/sync/download-staging.cjs.map +1 -0
  413. package/dist/sync/download-staging.d.cts +55 -0
  414. package/dist/sync/download-staging.d.cts.map +1 -0
  415. package/dist/sync/download-staging.d.ts +55 -0
  416. package/dist/sync/download-staging.d.ts.map +1 -0
  417. package/dist/sync/download-staging.js +260 -0
  418. package/dist/sync/download-staging.js.map +1 -0
  419. package/dist/sync/filesystem-errors.cjs +32 -0
  420. package/dist/sync/filesystem-errors.cjs.map +1 -0
  421. package/dist/sync/filesystem-errors.d.cts +8 -0
  422. package/dist/sync/filesystem-errors.d.cts.map +1 -0
  423. package/dist/sync/filesystem-errors.d.ts +8 -0
  424. package/dist/sync/filesystem-errors.d.ts.map +1 -0
  425. package/dist/sync/filesystem-errors.js +32 -0
  426. package/dist/sync/filesystem-errors.js.map +1 -0
  427. package/dist/sync/filters.cjs +217 -0
  428. package/dist/sync/filters.cjs.map +1 -0
  429. package/dist/sync/filters.d.cts +51 -0
  430. package/dist/sync/filters.d.cts.map +1 -0
  431. package/dist/sync/filters.d.ts +51 -0
  432. package/dist/sync/filters.d.ts.map +1 -0
  433. package/dist/sync/filters.js +213 -0
  434. package/dist/sync/filters.js.map +1 -0
  435. package/dist/sync/index.cjs +39 -22
  436. package/dist/sync/index.d.cts +14 -9
  437. package/dist/sync/index.d.cts.map +1 -1
  438. package/dist/sync/index.d.ts +14 -9
  439. package/dist/sync/index.d.ts.map +1 -1
  440. package/dist/sync/index.js +9 -20
  441. package/dist/sync/local-file-identity.cjs +61 -0
  442. package/dist/sync/local-file-identity.cjs.map +1 -0
  443. package/dist/sync/local-file-identity.d.cts +37 -0
  444. package/dist/sync/local-file-identity.d.cts.map +1 -0
  445. package/dist/sync/local-file-identity.d.ts +37 -0
  446. package/dist/sync/local-file-identity.d.ts.map +1 -0
  447. package/dist/sync/local-file-identity.js +60 -0
  448. package/dist/sync/local-file-identity.js.map +1 -0
  449. package/dist/sync/local-file-io.cjs +369 -0
  450. package/dist/sync/local-file-io.cjs.map +1 -0
  451. package/dist/sync/local-file-io.d.cts +76 -0
  452. package/dist/sync/local-file-io.d.cts.map +1 -0
  453. package/dist/sync/local-file-io.d.ts +76 -0
  454. package/dist/sync/local-file-io.d.ts.map +1 -0
  455. package/dist/sync/local-file-io.js +365 -0
  456. package/dist/sync/local-file-io.js.map +1 -0
  457. package/dist/sync/local-filesystem-root.cjs +27 -0
  458. package/dist/sync/local-filesystem-root.cjs.map +1 -0
  459. package/dist/sync/local-filesystem-root.d.cts +18 -0
  460. package/dist/sync/local-filesystem-root.d.cts.map +1 -0
  461. package/dist/sync/local-filesystem-root.d.ts +18 -0
  462. package/dist/sync/local-filesystem-root.d.ts.map +1 -0
  463. package/dist/sync/local-filesystem-root.js +26 -0
  464. package/dist/sync/local-filesystem-root.js.map +1 -0
  465. package/dist/sync/local-sha1.cjs +110 -0
  466. package/dist/sync/local-sha1.cjs.map +1 -0
  467. package/dist/sync/local-sha1.d.cts +31 -0
  468. package/dist/sync/local-sha1.d.cts.map +1 -0
  469. package/dist/sync/local-sha1.d.ts +31 -0
  470. package/dist/sync/local-sha1.d.ts.map +1 -0
  471. package/dist/sync/local-sha1.js +109 -0
  472. package/dist/sync/local-sha1.js.map +1 -0
  473. package/dist/sync/pairing.cjs +118 -29
  474. package/dist/sync/pairing.cjs.map +1 -1
  475. package/dist/sync/pairing.d.cts +7 -2
  476. package/dist/sync/pairing.d.cts.map +1 -1
  477. package/dist/sync/pairing.d.ts +7 -2
  478. package/dist/sync/pairing.d.ts.map +1 -1
  479. package/dist/sync/pairing.js +120 -31
  480. package/dist/sync/pairing.js.map +1 -1
  481. package/dist/sync/path-order.cjs +30 -0
  482. package/dist/sync/path-order.cjs.map +1 -0
  483. package/dist/sync/path-order.d.cts +28 -0
  484. package/dist/sync/path-order.d.cts.map +1 -0
  485. package/dist/sync/path-order.d.ts +28 -0
  486. package/dist/sync/path-order.d.ts.map +1 -0
  487. package/dist/sync/path-order.js +29 -0
  488. package/dist/sync/path-order.js.map +1 -0
  489. package/dist/sync/path-safety.cjs +111 -0
  490. package/dist/sync/path-safety.cjs.map +1 -0
  491. package/dist/sync/path-safety.d.cts +78 -0
  492. package/dist/sync/path-safety.d.cts.map +1 -0
  493. package/dist/sync/path-safety.d.ts +78 -0
  494. package/dist/sync/path-safety.d.ts.map +1 -0
  495. package/dist/sync/path-safety.js +105 -0
  496. package/dist/sync/path-safety.js.map +1 -0
  497. package/dist/sync/paths.d.cts +19 -0
  498. package/dist/sync/paths.d.cts.map +1 -0
  499. package/dist/sync/paths.d.ts +19 -0
  500. package/dist/sync/paths.d.ts.map +1 -0
  501. package/dist/sync/policies/compare.cjs +391 -11
  502. package/dist/sync/policies/compare.cjs.map +1 -1
  503. package/dist/sync/policies/compare.d.cts +100 -2
  504. package/dist/sync/policies/compare.d.cts.map +1 -1
  505. package/dist/sync/policies/compare.d.ts +100 -2
  506. package/dist/sync/policies/compare.d.ts.map +1 -1
  507. package/dist/sync/policies/compare.js +389 -13
  508. package/dist/sync/policies/compare.js.map +1 -1
  509. package/dist/sync/policies/index.cjs +70 -65
  510. package/dist/sync/policies/index.cjs.map +1 -1
  511. package/dist/sync/policies/index.d.cts +35 -6
  512. package/dist/sync/policies/index.d.cts.map +1 -1
  513. package/dist/sync/policies/index.d.ts +35 -6
  514. package/dist/sync/policies/index.d.ts.map +1 -1
  515. package/dist/sync/policies/index.js +70 -65
  516. package/dist/sync/policies/index.js.map +1 -1
  517. package/dist/sync/prefix.cjs +96 -0
  518. package/dist/sync/prefix.cjs.map +1 -0
  519. package/dist/sync/prefix.d.cts +55 -0
  520. package/dist/sync/prefix.d.cts.map +1 -0
  521. package/dist/sync/prefix.d.ts +55 -0
  522. package/dist/sync/prefix.d.ts.map +1 -0
  523. package/dist/sync/prefix.js +92 -0
  524. package/dist/sync/prefix.js.map +1 -0
  525. package/dist/sync/regexp-safety.cjs +192 -0
  526. package/dist/sync/regexp-safety.cjs.map +1 -0
  527. package/dist/sync/regexp-safety.d.cts +29 -0
  528. package/dist/sync/regexp-safety.d.cts.map +1 -0
  529. package/dist/sync/regexp-safety.d.ts +29 -0
  530. package/dist/sync/regexp-safety.d.ts.map +1 -0
  531. package/dist/sync/regexp-safety.js +190 -0
  532. package/dist/sync/regexp-safety.js.map +1 -0
  533. package/dist/sync/scan-events.cjs +33 -0
  534. package/dist/sync/scan-events.cjs.map +1 -0
  535. package/dist/sync/scan-events.d.cts +17 -0
  536. package/dist/sync/scan-events.d.cts.map +1 -0
  537. package/dist/sync/scan-events.d.ts +17 -0
  538. package/dist/sync/scan-events.d.ts.map +1 -0
  539. package/dist/sync/scan-events.js +32 -0
  540. package/dist/sync/scan-events.js.map +1 -0
  541. package/dist/sync/scan-limit.cjs +33 -0
  542. package/dist/sync/scan-limit.cjs.map +1 -0
  543. package/dist/sync/scan-limit.d.cts +21 -0
  544. package/dist/sync/scan-limit.d.cts.map +1 -0
  545. package/dist/sync/scan-limit.d.ts +21 -0
  546. package/dist/sync/scan-limit.d.ts.map +1 -0
  547. package/dist/sync/scan-limit.js +31 -0
  548. package/dist/sync/scan-limit.js.map +1 -0
  549. package/dist/sync/scanners/b2.cjs +239 -55
  550. package/dist/sync/scanners/b2.cjs.map +1 -1
  551. package/dist/sync/scanners/b2.d.cts +26 -7
  552. package/dist/sync/scanners/b2.d.cts.map +1 -1
  553. package/dist/sync/scanners/b2.d.ts +26 -7
  554. package/dist/sync/scanners/b2.d.ts.map +1 -1
  555. package/dist/sync/scanners/b2.js +239 -55
  556. package/dist/sync/scanners/b2.js.map +1 -1
  557. package/dist/sync/scanners/local.cjs +215 -56
  558. package/dist/sync/scanners/local.cjs.map +1 -1
  559. package/dist/sync/scanners/local.d.cts +22 -7
  560. package/dist/sync/scanners/local.d.cts.map +1 -1
  561. package/dist/sync/scanners/local.d.ts +22 -7
  562. package/dist/sync/scanners/local.d.ts.map +1 -1
  563. package/dist/sync/scanners/local.js +216 -57
  564. package/dist/sync/scanners/local.js.map +1 -1
  565. package/dist/sync/sha1-metadata.cjs +94 -0
  566. package/dist/sync/sha1-metadata.cjs.map +1 -0
  567. package/dist/sync/sha1-metadata.d.cts +82 -0
  568. package/dist/sync/sha1-metadata.d.cts.map +1 -0
  569. package/dist/sync/sha1-metadata.d.ts +82 -0
  570. package/dist/sync/sha1-metadata.d.ts.map +1 -0
  571. package/dist/sync/sha1-metadata.js +89 -0
  572. package/dist/sync/sha1-metadata.js.map +1 -0
  573. package/dist/sync/sha1-options.cjs +23 -0
  574. package/dist/sync/sha1-options.cjs.map +1 -0
  575. package/dist/sync/sha1-options.d.cts +14 -0
  576. package/dist/sync/sha1-options.d.cts.map +1 -0
  577. package/dist/sync/sha1-options.d.ts +14 -0
  578. package/dist/sync/sha1-options.d.ts.map +1 -0
  579. package/dist/sync/sha1-options.js +21 -0
  580. package/dist/sync/sha1-options.js.map +1 -0
  581. package/dist/sync/synchronizer.cjs +783 -197
  582. package/dist/sync/synchronizer.cjs.map +1 -1
  583. package/dist/sync/synchronizer.d.cts +47 -1
  584. package/dist/sync/synchronizer.d.cts.map +1 -1
  585. package/dist/sync/synchronizer.d.ts +47 -1
  586. package/dist/sync/synchronizer.d.ts.map +1 -1
  587. package/dist/sync/synchronizer.js +780 -173
  588. package/dist/sync/synchronizer.js.map +1 -1
  589. package/dist/sync/types.d.cts +208 -16
  590. package/dist/sync/types.d.cts.map +1 -1
  591. package/dist/sync/types.d.ts +208 -16
  592. package/dist/sync/types.d.ts.map +1 -1
  593. package/dist/types/auth.cjs +80 -56
  594. package/dist/types/auth.cjs.map +1 -1
  595. package/dist/types/auth.d.cts +71 -9
  596. package/dist/types/auth.d.cts.map +1 -1
  597. package/dist/types/auth.d.ts +71 -9
  598. package/dist/types/auth.d.ts.map +1 -1
  599. package/dist/types/auth.js +81 -57
  600. package/dist/types/auth.js.map +1 -1
  601. package/dist/types/backup.d.cts +80 -0
  602. package/dist/types/backup.d.cts.map +1 -0
  603. package/dist/types/backup.d.ts +80 -0
  604. package/dist/types/backup.d.ts.map +1 -0
  605. package/dist/types/bucket.cjs +74 -38
  606. package/dist/types/bucket.cjs.map +1 -1
  607. package/dist/types/bucket.d.cts +4 -2
  608. package/dist/types/bucket.d.cts.map +1 -1
  609. package/dist/types/bucket.d.ts +4 -2
  610. package/dist/types/bucket.d.ts.map +1 -1
  611. package/dist/types/bucket.js +75 -41
  612. package/dist/types/bucket.js.map +1 -1
  613. package/dist/types/download.cjs +62 -0
  614. package/dist/types/download.cjs.map +1 -0
  615. package/dist/types/download.d.cts +98 -0
  616. package/dist/types/download.d.cts.map +1 -1
  617. package/dist/types/download.d.ts +98 -0
  618. package/dist/types/download.d.ts.map +1 -1
  619. package/dist/types/download.js +61 -0
  620. package/dist/types/download.js.map +1 -0
  621. package/dist/types/encryption.cjs +194 -328
  622. package/dist/types/encryption.cjs.map +1 -1
  623. package/dist/types/encryption.d.cts +48 -0
  624. package/dist/types/encryption.d.cts.map +1 -1
  625. package/dist/types/encryption.d.ts +48 -0
  626. package/dist/types/encryption.d.ts.map +1 -1
  627. package/dist/types/encryption.js +192 -311
  628. package/dist/types/encryption.js.map +1 -1
  629. package/dist/types/errors.cjs +56 -0
  630. package/dist/types/errors.cjs.map +1 -0
  631. package/dist/types/errors.d.cts +13 -4
  632. package/dist/types/errors.d.cts.map +1 -1
  633. package/dist/types/errors.d.ts +13 -4
  634. package/dist/types/errors.d.ts.map +1 -1
  635. package/dist/types/errors.js +56 -0
  636. package/dist/types/errors.js.map +1 -0
  637. package/dist/types/file.cjs +36 -19
  638. package/dist/types/file.cjs.map +1 -1
  639. package/dist/types/file.d.cts +17 -4
  640. package/dist/types/file.d.cts.map +1 -1
  641. package/dist/types/file.d.ts +17 -4
  642. package/dist/types/file.d.ts.map +1 -1
  643. package/dist/types/file.js +37 -21
  644. package/dist/types/file.js.map +1 -1
  645. package/dist/types/ids.cjs +83 -9
  646. package/dist/types/ids.cjs.map +1 -1
  647. package/dist/types/ids.d.cts +32 -0
  648. package/dist/types/ids.d.cts.map +1 -1
  649. package/dist/types/ids.d.ts +32 -0
  650. package/dist/types/ids.d.ts.map +1 -1
  651. package/dist/types/ids.js +82 -16
  652. package/dist/types/ids.js.map +1 -1
  653. package/dist/types/index.d.cts +18 -13
  654. package/dist/types/index.d.cts.map +1 -1
  655. package/dist/types/index.d.ts +18 -13
  656. package/dist/types/index.d.ts.map +1 -1
  657. package/dist/types/key.d.cts +44 -8
  658. package/dist/types/key.d.cts.map +1 -1
  659. package/dist/types/key.d.ts +44 -8
  660. package/dist/types/key.d.ts.map +1 -1
  661. package/dist/types/lock.cjs +33 -13
  662. package/dist/types/lock.cjs.map +1 -1
  663. package/dist/types/lock.d.cts +14 -0
  664. package/dist/types/lock.d.cts.map +1 -1
  665. package/dist/types/lock.d.ts +14 -0
  666. package/dist/types/lock.d.ts.map +1 -1
  667. package/dist/types/lock.js +34 -15
  668. package/dist/types/lock.js.map +1 -1
  669. package/dist/types/notifications.cjs +44 -22
  670. package/dist/types/notifications.cjs.map +1 -1
  671. package/dist/types/notifications.d.cts +5 -3
  672. package/dist/types/notifications.d.cts.map +1 -1
  673. package/dist/types/notifications.d.ts +5 -3
  674. package/dist/types/notifications.d.ts.map +1 -1
  675. package/dist/types/notifications.js +45 -23
  676. package/dist/types/notifications.js.map +1 -1
  677. package/dist/types/partner.cjs +32 -0
  678. package/dist/types/partner.cjs.map +1 -0
  679. package/dist/types/partner.d.cts +394 -0
  680. package/dist/types/partner.d.cts.map +1 -0
  681. package/dist/types/partner.d.ts +394 -0
  682. package/dist/types/partner.d.ts.map +1 -0
  683. package/dist/types/partner.js +29 -0
  684. package/dist/types/partner.js.map +1 -0
  685. package/dist/types/upload.d.cts +53 -6
  686. package/dist/types/upload.d.cts.map +1 -1
  687. package/dist/types/upload.d.ts +53 -6
  688. package/dist/types/upload.d.ts.map +1 -1
  689. package/dist/upload/abort-scope.cjs +46 -0
  690. package/dist/upload/abort-scope.cjs.map +1 -0
  691. package/dist/upload/abort-scope.d.cts +26 -0
  692. package/dist/upload/abort-scope.d.cts.map +1 -0
  693. package/dist/upload/abort-scope.d.ts +26 -0
  694. package/dist/upload/abort-scope.d.ts.map +1 -0
  695. package/dist/upload/abort-scope.js +45 -0
  696. package/dist/upload/abort-scope.js.map +1 -0
  697. package/dist/upload/cancel.cjs +183 -8
  698. package/dist/upload/cancel.cjs.map +1 -1
  699. package/dist/upload/cancel.d.cts +110 -2
  700. package/dist/upload/cancel.d.cts.map +1 -1
  701. package/dist/upload/cancel.d.ts +110 -2
  702. package/dist/upload/cancel.d.ts.map +1 -1
  703. package/dist/upload/cancel.js +178 -9
  704. package/dist/upload/cancel.js.map +1 -1
  705. package/dist/upload/concurrency.cjs +79 -52
  706. package/dist/upload/concurrency.cjs.map +1 -1
  707. package/dist/upload/concurrency.js +79 -53
  708. package/dist/upload/concurrency.js.map +1 -1
  709. package/dist/upload/finish.cjs +54 -0
  710. package/dist/upload/finish.cjs.map +1 -0
  711. package/dist/upload/finish.d.cts +26 -0
  712. package/dist/upload/finish.d.cts.map +1 -0
  713. package/dist/upload/finish.d.ts +26 -0
  714. package/dist/upload/finish.d.ts.map +1 -0
  715. package/dist/upload/finish.js +54 -0
  716. package/dist/upload/finish.js.map +1 -0
  717. package/dist/upload/large.cjs +305 -218
  718. package/dist/upload/large.cjs.map +1 -1
  719. package/dist/upload/large.d.cts +90 -9
  720. package/dist/upload/large.d.cts.map +1 -1
  721. package/dist/upload/large.d.ts +90 -9
  722. package/dist/upload/large.d.ts.map +1 -1
  723. package/dist/upload/large.js +305 -218
  724. package/dist/upload/large.js.map +1 -1
  725. package/dist/upload/options.cjs +28 -0
  726. package/dist/upload/options.cjs.map +1 -0
  727. package/dist/upload/options.d.cts +116 -0
  728. package/dist/upload/options.d.cts.map +1 -0
  729. package/dist/upload/options.d.ts +116 -0
  730. package/dist/upload/options.d.ts.map +1 -0
  731. package/dist/upload/options.js +27 -0
  732. package/dist/upload/options.js.map +1 -0
  733. package/dist/upload/resume.cjs +334 -33
  734. package/dist/upload/resume.cjs.map +1 -1
  735. package/dist/upload/resume.d.cts +84 -12
  736. package/dist/upload/resume.d.cts.map +1 -1
  737. package/dist/upload/resume.d.ts +84 -12
  738. package/dist/upload/resume.d.ts.map +1 -1
  739. package/dist/upload/resume.js +331 -33
  740. package/dist/upload/resume.js.map +1 -1
  741. package/dist/upload/retry.cjs +191 -0
  742. package/dist/upload/retry.cjs.map +1 -0
  743. package/dist/upload/retry.d.cts +127 -0
  744. package/dist/upload/retry.d.cts.map +1 -0
  745. package/dist/upload/retry.d.ts +127 -0
  746. package/dist/upload/retry.d.ts.map +1 -0
  747. package/dist/upload/retry.js +187 -0
  748. package/dist/upload/retry.js.map +1 -0
  749. package/dist/upload/single.cjs +69 -44
  750. package/dist/upload/single.cjs.map +1 -1
  751. package/dist/upload/single.d.cts +8 -1
  752. package/dist/upload/single.d.cts.map +1 -1
  753. package/dist/upload/single.d.ts +8 -1
  754. package/dist/upload/single.d.ts.map +1 -1
  755. package/dist/upload/single.js +69 -44
  756. package/dist/upload/single.js.map +1 -1
  757. package/dist/upload/stream.cjs +319 -193
  758. package/dist/upload/stream.cjs.map +1 -1
  759. package/dist/upload/stream.d.cts +9 -1
  760. package/dist/upload/stream.d.cts.map +1 -1
  761. package/dist/upload/stream.d.ts +9 -1
  762. package/dist/upload/stream.d.ts.map +1 -1
  763. package/dist/upload/stream.js +318 -192
  764. package/dist/upload/stream.js.map +1 -1
  765. package/dist/util/abort.cjs +114 -0
  766. package/dist/util/abort.cjs.map +1 -0
  767. package/dist/util/abort.d.cts +65 -0
  768. package/dist/util/abort.d.cts.map +1 -0
  769. package/dist/util/abort.d.ts +65 -0
  770. package/dist/util/abort.d.ts.map +1 -0
  771. package/dist/util/abort.js +109 -0
  772. package/dist/util/abort.js.map +1 -0
  773. package/dist/util/best-effort.cjs +42 -8
  774. package/dist/util/best-effort.cjs.map +1 -1
  775. package/dist/util/best-effort.d.cts +2 -1
  776. package/dist/util/best-effort.d.cts.map +1 -1
  777. package/dist/util/best-effort.d.ts +2 -1
  778. package/dist/util/best-effort.d.ts.map +1 -1
  779. package/dist/util/best-effort.js +43 -9
  780. package/dist/util/best-effort.js.map +1 -1
  781. package/dist/util/bytes.cjs +23 -0
  782. package/dist/util/bytes.cjs.map +1 -0
  783. package/dist/util/bytes.d.cts +15 -0
  784. package/dist/util/bytes.d.cts.map +1 -0
  785. package/dist/util/bytes.d.ts +15 -0
  786. package/dist/util/bytes.d.ts.map +1 -0
  787. package/dist/util/bytes.js +23 -0
  788. package/dist/util/bytes.js.map +1 -0
  789. package/dist/util/crypto.cjs +68 -0
  790. package/dist/util/crypto.cjs.map +1 -0
  791. package/dist/util/crypto.d.cts +26 -0
  792. package/dist/util/crypto.d.cts.map +1 -0
  793. package/dist/util/crypto.d.ts +26 -0
  794. package/dist/util/crypto.d.ts.map +1 -0
  795. package/dist/util/crypto.js +66 -0
  796. package/dist/util/crypto.js.map +1 -0
  797. package/dist/util/defaults.cjs +28 -9
  798. package/dist/util/defaults.cjs.map +1 -1
  799. package/dist/util/defaults.d.cts +2 -0
  800. package/dist/util/defaults.d.cts.map +1 -1
  801. package/dist/util/defaults.d.ts +2 -0
  802. package/dist/util/defaults.d.ts.map +1 -1
  803. package/dist/util/defaults.js +28 -11
  804. package/dist/util/defaults.js.map +1 -1
  805. package/dist/util/error-reason.cjs +41 -0
  806. package/dist/util/error-reason.cjs.map +1 -0
  807. package/dist/util/error-reason.d.cts +9 -0
  808. package/dist/util/error-reason.d.cts.map +1 -0
  809. package/dist/util/error-reason.d.ts +9 -0
  810. package/dist/util/error-reason.d.ts.map +1 -0
  811. package/dist/util/error-reason.js +41 -0
  812. package/dist/util/error-reason.js.map +1 -0
  813. package/dist/util/http.cjs +23 -0
  814. package/dist/util/http.cjs.map +1 -0
  815. package/dist/util/http.d.cts +13 -0
  816. package/dist/util/http.d.cts.map +1 -0
  817. package/dist/util/http.d.ts +13 -0
  818. package/dist/util/http.d.ts.map +1 -0
  819. package/dist/util/http.js +23 -0
  820. package/dist/util/http.js.map +1 -0
  821. package/dist/util/md5.cjs +211 -0
  822. package/dist/util/md5.cjs.map +1 -0
  823. package/dist/util/md5.d.cts +43 -0
  824. package/dist/util/md5.d.cts.map +1 -0
  825. package/dist/util/md5.d.ts +43 -0
  826. package/dist/util/md5.d.ts.map +1 -0
  827. package/dist/util/md5.js +209 -0
  828. package/dist/util/md5.js.map +1 -0
  829. package/dist/util/normalize.cjs +66 -7
  830. package/dist/util/normalize.cjs.map +1 -1
  831. package/dist/util/normalize.d.cts +7 -7
  832. package/dist/util/normalize.d.cts.map +1 -1
  833. package/dist/util/normalize.d.ts +7 -7
  834. package/dist/util/normalize.d.ts.map +1 -1
  835. package/dist/util/normalize.js +67 -10
  836. package/dist/util/normalize.js.map +1 -1
  837. package/dist/util/paginator.cjs +69 -14
  838. package/dist/util/paginator.cjs.map +1 -1
  839. package/dist/util/paginator.d.cts +3 -1
  840. package/dist/util/paginator.d.cts.map +1 -1
  841. package/dist/util/paginator.d.ts +3 -1
  842. package/dist/util/paginator.d.ts.map +1 -1
  843. package/dist/util/paginator.js +70 -16
  844. package/dist/util/paginator.js.map +1 -1
  845. package/dist/util/plan-ranges.cjs +47 -22
  846. package/dist/util/plan-ranges.cjs.map +1 -1
  847. package/dist/util/plan-ranges.js +48 -24
  848. package/dist/util/plan-ranges.js.map +1 -1
  849. package/dist/util/sha1.cjs +27 -0
  850. package/dist/util/sha1.cjs.map +1 -0
  851. package/dist/util/sha1.d.cts +17 -0
  852. package/dist/util/sha1.d.cts.map +1 -0
  853. package/dist/util/sha1.d.ts +17 -0
  854. package/dist/util/sha1.d.ts.map +1 -0
  855. package/dist/util/sha1.js +26 -0
  856. package/dist/util/sha1.js.map +1 -0
  857. package/dist/util/text-codec.cjs +29 -5
  858. package/dist/util/text-codec.cjs.map +1 -1
  859. package/dist/util/text-codec.js +30 -7
  860. package/dist/util/text-codec.js.map +1 -1
  861. package/dist/util/to-error.cjs +18 -4
  862. package/dist/util/to-error.cjs.map +1 -1
  863. package/dist/util/to-error.js +19 -5
  864. package/dist/util/to-error.js.map +1 -1
  865. package/dist/version.cjs +17 -5
  866. package/dist/version.cjs.map +1 -1
  867. package/dist/version.d.cts +3 -3
  868. package/dist/version.d.ts +3 -3
  869. package/dist/version.js +19 -6
  870. package/dist/version.js.map +1 -1
  871. package/package.json +45 -20
  872. package/dist/auth/index.cjs.map +0 -1
  873. package/dist/auth/index.js.map +0 -1
  874. package/dist/index.cjs.map +0 -1
  875. package/dist/index.js.map +0 -1
  876. package/dist/notifications/index.cjs.map +0 -1
  877. package/dist/notifications/index.js.map +0 -1
  878. package/dist/package.json.cjs +0 -9
  879. package/dist/package.json.cjs.map +0 -1
  880. package/dist/package.json.js +0 -9
  881. package/dist/package.json.js.map +0 -1
  882. package/dist/streams/index.cjs.map +0 -1
  883. package/dist/streams/index.js.map +0 -1
  884. package/dist/sync/index.cjs.map +0 -1
  885. package/dist/sync/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sources":["../src/object.ts"],"sourcesContent":["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport { type DownloadResult, downloadByName } from './download/single.ts'\nimport { type HeadResult, downloadById, headById, headByName } from './download/single.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { ContentSource } from './streams/source.ts'\nimport type { EncryptionSetting } from './types/encryption.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId, LargeFileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { type UploadWriteHandle, createWriteStream } from './upload/stream.ts'\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n *\n * @internal\n */\n constructor(client: B2Client, bucket: Bucket, fileName: string) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: {\n /** Data source to upload. */\n source: ContentSource\n /** MIME type. Defaults to auto-detection by B2. */\n contentType?: string\n /** Custom key-value metadata stored with the file. */\n fileInfo?: Record<string, string>\n /** Server-side encryption settings. */\n serverSideEncryption?: EncryptionSetting\n /** File retention policy (requires file lock). */\n fileRetention?: FileRetentionValue\n /** Legal hold status. */\n legalHold?: LegalHoldValue\n /** Last-modified timestamp in milliseconds since epoch. */\n lastModifiedMillis?: number\n /** Part size override for multipart uploads, in bytes. */\n partSize?: number\n /** Number of concurrent part uploads for large files. */\n concurrency?: number\n /** Callback invoked with upload progress events. */\n onProgress?: ProgressListener\n /** Abort signal for cancelling the upload. */\n signal?: AbortSignal\n /**\n * Resume an unfinished multipart upload for this file name when one\n * exists. Only meaningful on the large-file path. Ignored on the\n * small-file path.\n */\n resume?: boolean\n /**\n * Resume into a specific large-file ID, bypassing discovery.\n * Overrides the `resume` discovery path.\n */\n resumeFileId?: LargeFileId\n }): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n\n if (isLarge) {\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n bucketId: this.bucket.id,\n fileName: this.fileName,\n ...options,\n })\n }\n\n // Small-file path doesn't accept resume options.\n const { resume: _resume, resumeFileId: _resumeFileId, ...smallOptions } = options\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n bucketId: this.bucket.id,\n fileName: this.fileName,\n ...smallOptions,\n })\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 8 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: {\n /** MIME type. Defaults to `b2/x-auto`. */\n contentType?: string\n /** Custom key-value metadata stored with the file. */\n fileInfo?: Record<string, string>\n /** Server-side encryption applied to each part. */\n serverSideEncryption?: EncryptionSetting\n /** Target part size in bytes. Defaults to the account's recommended part size. */\n partSize?: number\n /** Maximum number of parts uploaded in parallel. Defaults to 4. */\n concurrency?: number\n /** Callback invoked with upload progress events. */\n onProgress?: ProgressListener\n /** Abort signal that cancels the upload and the unfinished large file. */\n signal?: AbortSignal\n }): UploadWriteHandle {\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n bucketId: this.bucket.id,\n fileName: this.fileName,\n ...(options ?? {}),\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"names":[],"mappings":";;;;;AA4EO,MAAM,SAAS;AAAA;AAAA,EAEX;AAAA,EACQ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjB,YAAY,QAAkB,QAAgB,UAAkB;AAC9D,SAAK,SAAS;AACd,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,SAkCY;AACvB,UAAM,sBAAsB,KAAK,OAAO,YAAY,uBAAA;AACpD,UAAM,UAAU,QAAQ,OAAO,OAAO;AAEtC,QAAI,SAAS;AACX,aAAO,gBAAgB,KAAK,OAAO,KAAK,KAAK,OAAO,aAAa;AAAA,QAC/D,UAAU,KAAK,OAAO;AAAA,QACtB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,oBAAoB,KAAK,UAAU,QAAQ,SAAS;AAAA,EACzE;AACF;"}
1
+ {"version":3,"file":"object.js","names":[],"sources":["../src/object.ts"],"sourcesContent":["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport {\n type DownloadResult,\n downloadById,\n downloadByName,\n type HeadResult,\n headById,\n headByName,\n} from './download/single.ts'\nimport type { RetryOptions } from './http/retry.ts'\nimport { mergeUploadRetryOptions } from './internal/upload-retry-options.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { BucketRetentionPolicy } from './types/bucket.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport {\n type B2ObjectUploadOptions,\n type B2ObjectWriteStreamOptions,\n rejectSmallResumeFileId,\n stripResumeOnlyOptions,\n} from './upload/options.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { createWriteStream, type UploadWriteHandle } from './upload/stream.ts'\n\ninterface BucketDefaultRetentionSnapshot {\n readonly retention?: BucketRetentionPolicy\n readonly unreadable: boolean\n}\n\nfunction bucketDefaultRetentionSnapshot(info: Bucket['info']): BucketDefaultRetentionSnapshot {\n const fileLock = info.fileLockConfiguration\n if (!fileLock.isClientAuthorizedToRead) return { unreadable: true }\n if (fileLock.value === null) return { unreadable: false }\n return { retention: fileLock.value.defaultRetention, unreadable: false }\n}\n\nfunction resumeNeedsFreshBucketDefaults(options: B2ObjectUploadOptions): boolean {\n const resumeRequested = options.resume === true || options.resumeFileId !== undefined\n return (\n resumeRequested &&\n (options.serverSideEncryption === undefined || options.fileRetention === undefined)\n )\n}\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n private readonly uploadRetryOptions: RetryOptions\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n * @param uploadRetryOptions - Resolved client upload retry defaults.\n *\n * @internal\n */\n constructor(\n client: B2Client,\n bucket: Bucket,\n fileName: string,\n uploadRetryOptions: RetryOptions,\n ) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n this.uploadRetryOptions = uploadRetryOptions\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: B2ObjectUploadOptions): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options.retry)\n\n if (isLarge) {\n const bucketInfo = resumeNeedsFreshBucketDefaults(options)\n ? await this.fetchFreshBucketInfo()\n : this.bucket.info\n const bucketDefaultRetention = bucketDefaultRetentionSnapshot(bucketInfo)\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n ...options,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n bucketDefaultServerSideEncryption: bucketInfo.defaultServerSideEncryption,\n ...(bucketDefaultRetention.retention !== undefined\n ? { bucketDefaultRetention: bucketDefaultRetention.retention }\n : {}),\n ...(bucketDefaultRetention.unreadable ? { bucketDefaultRetentionUnreadable: true } : {}),\n })\n }\n rejectSmallResumeFileId(options, 'B2Object.upload')\n const smallOptions = stripResumeOnlyOptions(options)\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n ...smallOptions,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n private async fetchFreshBucketInfo(): Promise<Bucket['info']> {\n const fresh = await this.client.listBuckets({ bucketId: this.bucket.id })\n const found = fresh[0]\n if (!found) throw new Error(`Bucket ${this.bucket.id} not found`)\n return found.info\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, SSE-C decryption, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 10 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n serverSideEncryption?: SseCDownloadKey\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: B2ObjectWriteStreamOptions): UploadWriteHandle {\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options?.retry)\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n ...(options ?? {}),\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"mappings":";;;;;;;;AAkCA,SAAS,+BAA+B,MAAsD;CAC5F,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,SAAS,0BAA0B,OAAO,EAAE,YAAY,KAAK;CAClE,IAAI,SAAS,UAAU,MAAM,OAAO,EAAE,YAAY,MAAM;CACxD,OAAO;EAAE,WAAW,SAAS,MAAM;EAAkB,YAAY;CAAM;AACzE;AAEA,SAAS,+BAA+B,SAAyC;CAE/E,QADwB,QAAQ,WAAW,QAAQ,QAAQ,iBAAiB,KAAA,OAGzE,QAAQ,yBAAyB,KAAA,KAAa,QAAQ,kBAAkB,KAAA;AAE7E;;;;;;;;;;;;;;AA8DA,IAAa,WAAb,MAAsB;;CAEpB;CACA;CACA;CACA;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KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,WAAW,OAAO;CAClF;;;;;;;;;;;;;;CAeA,MAAM,aAAa,QAAgB,WAA2B;EAC5D,OAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,SAAS;CACzE;AACF"}
@@ -0,0 +1,43 @@
1
+ import { AccountId, PartnerToken } from '../types/ids.js';
2
+ import { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.js';
3
+ /**
4
+ * Stores Partner API and Computer Backup authorization state between requests.
5
+ *
6
+ * Reauthorization follows the storage client's `RetryTransport.onReauth`
7
+ * contract: re-run `PartnerRawClient.authorizePartner` with the same Master
8
+ * Application Key credentials, store the fresh response with `setAuth`, then
9
+ * return `authorizationToken` to the retry transport.
10
+ *
11
+ * Partner authorize responses redact `authorizationToken` when passed to
12
+ * `JSON.stringify`, so do not persist `getAuth()` with direct JSON serialization.
13
+ * For trusted durable caches, serialize the output of
14
+ * `partnerAuthorizeResponseForPersistence(getAuth())` into encrypted or
15
+ * otherwise credential-grade storage, or store `authorizationToken` directly in
16
+ * secure storage with the rest of the authorize response metadata.
17
+ */
18
+ export interface PartnerAccountInfo {
19
+ /** Store a fresh Partner authorization response, replacing any previous state. */
20
+ setAuth(auth: PartnerAuthorizeResponse): void;
21
+ /**
22
+ * Return the current Partner authorization response, or null if not authorized.
23
+ *
24
+ * The returned object remains directly reusable with `setAuth()`, but
25
+ * `JSON.stringify` redacts its token and is not a persistence format.
26
+ */
27
+ getAuth(): PartnerAuthorizeResponse | null;
28
+ /** Discard all cached Partner authorization state. */
29
+ clear(): void;
30
+ /** Current Partner/Backup authorization token. */
31
+ getPartnerToken(): PartnerToken;
32
+ /** Base URL for Partner API calls, or null when the suite is unavailable. */
33
+ getGroupsApiUrl(): string | null;
34
+ /** Base URL for Computer Backup API calls, or null when the suite is unavailable. */
35
+ getBackupApiUrl(): string | null;
36
+ /** The authorized partner administrator account ID. */
37
+ getAccountId(): AccountId;
38
+ /** Capabilities granted for Partner API calls, or null when the suite is unavailable. */
39
+ getGroupsCapabilities(): readonly PartnerCapability[] | null;
40
+ /** Capabilities granted for Computer Backup API calls, or null when the suite is unavailable. */
41
+ getBackupCapabilities(): readonly PartnerCapability[] | null;
42
+ }
43
+ //# sourceMappingURL=account-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-info.d.ts","sourceRoot":"","sources":["../../src/partner/account-info.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,kBAAkB;IACjC,kFAAkF;IAClF,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IAC7C;;;;;OAKG;IACH,OAAO,IAAI,wBAAwB,GAAG,IAAI,CAAA;IAC1C,sDAAsD;IACtD,KAAK,IAAI,IAAI,CAAA;IAEb,kDAAkD;IAClD,eAAe,IAAI,YAAY,CAAA;IAC/B,6EAA6E;IAC7E,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,qFAAqF;IACrF,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,uDAAuD;IACvD,YAAY,IAAI,SAAS,CAAA;IACzB,yFAAyF;IACzF,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;IAC5D,iGAAiG;IACjG,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;CAC7D"}
@@ -0,0 +1,43 @@
1
+ import { AccountId, PartnerToken } from '../types/ids.js';
2
+ import { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.js';
3
+ /**
4
+ * Stores Partner API and Computer Backup authorization state between requests.
5
+ *
6
+ * Reauthorization follows the storage client's `RetryTransport.onReauth`
7
+ * contract: re-run `PartnerRawClient.authorizePartner` with the same Master
8
+ * Application Key credentials, store the fresh response with `setAuth`, then
9
+ * return `authorizationToken` to the retry transport.
10
+ *
11
+ * Partner authorize responses redact `authorizationToken` when passed to
12
+ * `JSON.stringify`, so do not persist `getAuth()` with direct JSON serialization.
13
+ * For trusted durable caches, serialize the output of
14
+ * `partnerAuthorizeResponseForPersistence(getAuth())` into encrypted or
15
+ * otherwise credential-grade storage, or store `authorizationToken` directly in
16
+ * secure storage with the rest of the authorize response metadata.
17
+ */
18
+ export interface PartnerAccountInfo {
19
+ /** Store a fresh Partner authorization response, replacing any previous state. */
20
+ setAuth(auth: PartnerAuthorizeResponse): void;
21
+ /**
22
+ * Return the current Partner authorization response, or null if not authorized.
23
+ *
24
+ * The returned object remains directly reusable with `setAuth()`, but
25
+ * `JSON.stringify` redacts its token and is not a persistence format.
26
+ */
27
+ getAuth(): PartnerAuthorizeResponse | null;
28
+ /** Discard all cached Partner authorization state. */
29
+ clear(): void;
30
+ /** Current Partner/Backup authorization token. */
31
+ getPartnerToken(): PartnerToken;
32
+ /** Base URL for Partner API calls, or null when the suite is unavailable. */
33
+ getGroupsApiUrl(): string | null;
34
+ /** Base URL for Computer Backup API calls, or null when the suite is unavailable. */
35
+ getBackupApiUrl(): string | null;
36
+ /** The authorized partner administrator account ID. */
37
+ getAccountId(): AccountId;
38
+ /** Capabilities granted for Partner API calls, or null when the suite is unavailable. */
39
+ getGroupsCapabilities(): readonly PartnerCapability[] | null;
40
+ /** Capabilities granted for Computer Backup API calls, or null when the suite is unavailable. */
41
+ getBackupCapabilities(): readonly PartnerCapability[] | null;
42
+ }
43
+ //# sourceMappingURL=account-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-info.d.ts","sourceRoot":"","sources":["../../src/partner/account-info.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,kBAAkB;IACjC,kFAAkF;IAClF,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IAC7C;;;;;OAKG;IACH,OAAO,IAAI,wBAAwB,GAAG,IAAI,CAAA;IAC1C,sDAAsD;IACtD,KAAK,IAAI,IAAI,CAAA;IAEb,kDAAkD;IAClD,eAAe,IAAI,YAAY,CAAA;IAC/B,6EAA6E;IAC7E,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,qFAAqF;IACrF,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,uDAAuD;IACvD,YAAY,IAAI,SAAS,CAAA;IACzB,yFAAyF;IACzF,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;IAC5D,iGAAiG;IACjG,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;CAC7D"}
@@ -0,0 +1,64 @@
1
+ const require_auth_shape = require("./auth-shape.cjs");
2
+ //#region src/partner/auth-clone.ts
3
+ /**
4
+ * Returns a hook-free Partner authorize response copy.
5
+ *
6
+ * @param auth - Partner authorization response to clone.
7
+ *
8
+ * @returns A plain object preserving the live Partner token.
9
+ *
10
+ * @internal
11
+ */
12
+ function clonePartnerAuthorizeResponse(auth) {
13
+ require_auth_shape.validatePartnerAuthorizeResponseShape(auth);
14
+ const storageApi = auth.apiInfo.storageApi;
15
+ const groupsApi = auth.apiInfo.groupsApi;
16
+ const backupApi = auth.apiInfo.backupApi;
17
+ return {
18
+ accountId: auth.accountId,
19
+ authorizationToken: auth.authorizationToken,
20
+ apiInfo: {
21
+ ...storageApi !== void 0 ? { storageApi: {
22
+ ...storageApi,
23
+ capabilities: [...storageApi.capabilities]
24
+ } } : {},
25
+ ...groupsApi !== void 0 ? { groupsApi: {
26
+ ...groupsApi,
27
+ capabilities: [...groupsApi.capabilities],
28
+ infoType: "groupsApi"
29
+ } } : {},
30
+ ...backupApi !== void 0 ? { backupApi: {
31
+ ...backupApi,
32
+ capabilities: [...backupApi.capabilities],
33
+ infoType: "backupApi"
34
+ } } : {}
35
+ },
36
+ ...groupsApi !== void 0 ? { groupsApiUrl: groupsApi.groupsApiUrl } : {},
37
+ ...backupApi !== void 0 ? { backupApiUrl: backupApi.backupApiUrl } : {},
38
+ ...groupsApi !== void 0 ? { groupsCapabilities: [...groupsApi.capabilities] } : {},
39
+ ...backupApi !== void 0 ? { backupCapabilities: [...backupApi.capabilities] } : {},
40
+ applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp
41
+ };
42
+ }
43
+ /**
44
+ * Returns a plain Partner authorize response copy for trusted auth-cache persistence.
45
+ *
46
+ * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
47
+ * result can be serialized, parsed, and passed back to
48
+ * `PartnerAccountInfo.setAuth()`.
49
+ *
50
+ * The returned value is raw bearer-token material. Store it only in encrypted
51
+ * or otherwise credential-grade durable storage, and never log it.
52
+ *
53
+ * @param auth - Partner authorization response to persist.
54
+ *
55
+ * @returns A plain object with the live Partner token preserved.
56
+ */
57
+ function partnerAuthorizeResponseForPersistence(auth) {
58
+ return clonePartnerAuthorizeResponse(auth);
59
+ }
60
+ //#endregion
61
+ exports.clonePartnerAuthorizeResponse = clonePartnerAuthorizeResponse;
62
+ exports.partnerAuthorizeResponseForPersistence = partnerAuthorizeResponseForPersistence;
63
+
64
+ //# sourceMappingURL=auth-clone.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-clone.cjs","names":[],"sources":["../../src/partner/auth-clone.ts"],"sourcesContent":["import type { PartnerAuthorizeResponse } from '../types/partner.ts'\nimport { validatePartnerAuthorizeResponseShape } from './auth-shape.ts'\n\n/**\n * Returns a hook-free Partner authorize response copy.\n *\n * @param auth - Partner authorization response to clone.\n *\n * @returns A plain object preserving the live Partner token.\n *\n * @internal\n */\nexport function clonePartnerAuthorizeResponse(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n validatePartnerAuthorizeResponseShape(auth)\n\n const storageApi = auth.apiInfo.storageApi\n const groupsApi = auth.apiInfo.groupsApi\n const backupApi = auth.apiInfo.backupApi\n\n return {\n accountId: auth.accountId,\n authorizationToken: auth.authorizationToken,\n apiInfo: {\n ...(storageApi !== undefined\n ? {\n storageApi: {\n ...storageApi,\n capabilities: [...storageApi.capabilities],\n },\n }\n : {}),\n ...(groupsApi !== undefined\n ? {\n groupsApi: {\n ...groupsApi,\n capabilities: [...groupsApi.capabilities],\n infoType: 'groupsApi' as const,\n },\n }\n : {}),\n ...(backupApi !== undefined\n ? {\n backupApi: {\n ...backupApi,\n capabilities: [...backupApi.capabilities],\n infoType: 'backupApi' as const,\n },\n }\n : {}),\n },\n ...(groupsApi !== undefined ? { groupsApiUrl: groupsApi.groupsApiUrl } : {}),\n ...(backupApi !== undefined ? { backupApiUrl: backupApi.backupApiUrl } : {}),\n ...(groupsApi !== undefined ? { groupsCapabilities: [...groupsApi.capabilities] } : {}),\n ...(backupApi !== undefined ? { backupCapabilities: [...backupApi.capabilities] } : {}),\n applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp,\n }\n}\n\n/**\n * Returns a plain Partner authorize response copy for trusted auth-cache persistence.\n *\n * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the\n * result can be serialized, parsed, and passed back to\n * `PartnerAccountInfo.setAuth()`.\n *\n * The returned value is raw bearer-token material. Store it only in encrypted\n * or otherwise credential-grade durable storage, and never log it.\n *\n * @param auth - Partner authorization response to persist.\n *\n * @returns A plain object with the live Partner token preserved.\n */\nexport function partnerAuthorizeResponseForPersistence(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n return clonePartnerAuthorizeResponse(auth)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,8BACd,MAC0B;CAC1B,mBAAA,sCAAsC,IAAI;CAE1C,MAAM,aAAa,KAAK,QAAQ;CAChC,MAAM,YAAY,KAAK,QAAQ;CAC/B,MAAM,YAAY,KAAK,QAAQ;CAE/B,OAAO;EACL,WAAW,KAAK;EAChB,oBAAoB,KAAK;EACzB,SAAS;GACP,GAAI,eAAe,KAAA,IACf,EACE,YAAY;IACV,GAAG;IACH,cAAc,CAAC,GAAG,WAAW,YAAY;GAC3C,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;EACP;EACA,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,mCAAmC,KAAK;CAC1C;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,uCACd,MAC0B;CAC1B,OAAO,8BAA8B,IAAI;AAC3C"}
@@ -0,0 +1,27 @@
1
+ import { PartnerAuthorizeResponse } from '../types/partner.js';
2
+ /**
3
+ * Returns a hook-free Partner authorize response copy.
4
+ *
5
+ * @param auth - Partner authorization response to clone.
6
+ *
7
+ * @returns A plain object preserving the live Partner token.
8
+ *
9
+ * @internal
10
+ */
11
+ export declare function clonePartnerAuthorizeResponse(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
12
+ /**
13
+ * Returns a plain Partner authorize response copy for trusted auth-cache persistence.
14
+ *
15
+ * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
16
+ * result can be serialized, parsed, and passed back to
17
+ * `PartnerAccountInfo.setAuth()`.
18
+ *
19
+ * The returned value is raw bearer-token material. Store it only in encrypted
20
+ * or otherwise credential-grade durable storage, and never log it.
21
+ *
22
+ * @param auth - Partner authorization response to persist.
23
+ *
24
+ * @returns A plain object with the live Partner token preserved.
25
+ */
26
+ export declare function partnerAuthorizeResponseForPersistence(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
27
+ //# sourceMappingURL=auth-clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-clone.d.ts","sourceRoot":"","sources":["../../src/partner/auth-clone.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAGnE;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CA4C1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CAE1B"}
@@ -0,0 +1,27 @@
1
+ import { PartnerAuthorizeResponse } from '../types/partner.js';
2
+ /**
3
+ * Returns a hook-free Partner authorize response copy.
4
+ *
5
+ * @param auth - Partner authorization response to clone.
6
+ *
7
+ * @returns A plain object preserving the live Partner token.
8
+ *
9
+ * @internal
10
+ */
11
+ export declare function clonePartnerAuthorizeResponse(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
12
+ /**
13
+ * Returns a plain Partner authorize response copy for trusted auth-cache persistence.
14
+ *
15
+ * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
16
+ * result can be serialized, parsed, and passed back to
17
+ * `PartnerAccountInfo.setAuth()`.
18
+ *
19
+ * The returned value is raw bearer-token material. Store it only in encrypted
20
+ * or otherwise credential-grade durable storage, and never log it.
21
+ *
22
+ * @param auth - Partner authorization response to persist.
23
+ *
24
+ * @returns A plain object with the live Partner token preserved.
25
+ */
26
+ export declare function partnerAuthorizeResponseForPersistence(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
27
+ //# sourceMappingURL=auth-clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-clone.d.ts","sourceRoot":"","sources":["../../src/partner/auth-clone.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAGnE;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CA4C1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CAE1B"}
@@ -0,0 +1,63 @@
1
+ import { validatePartnerAuthorizeResponseShape } from "./auth-shape.js";
2
+ //#region src/partner/auth-clone.ts
3
+ /**
4
+ * Returns a hook-free Partner authorize response copy.
5
+ *
6
+ * @param auth - Partner authorization response to clone.
7
+ *
8
+ * @returns A plain object preserving the live Partner token.
9
+ *
10
+ * @internal
11
+ */
12
+ function clonePartnerAuthorizeResponse(auth) {
13
+ validatePartnerAuthorizeResponseShape(auth);
14
+ const storageApi = auth.apiInfo.storageApi;
15
+ const groupsApi = auth.apiInfo.groupsApi;
16
+ const backupApi = auth.apiInfo.backupApi;
17
+ return {
18
+ accountId: auth.accountId,
19
+ authorizationToken: auth.authorizationToken,
20
+ apiInfo: {
21
+ ...storageApi !== void 0 ? { storageApi: {
22
+ ...storageApi,
23
+ capabilities: [...storageApi.capabilities]
24
+ } } : {},
25
+ ...groupsApi !== void 0 ? { groupsApi: {
26
+ ...groupsApi,
27
+ capabilities: [...groupsApi.capabilities],
28
+ infoType: "groupsApi"
29
+ } } : {},
30
+ ...backupApi !== void 0 ? { backupApi: {
31
+ ...backupApi,
32
+ capabilities: [...backupApi.capabilities],
33
+ infoType: "backupApi"
34
+ } } : {}
35
+ },
36
+ ...groupsApi !== void 0 ? { groupsApiUrl: groupsApi.groupsApiUrl } : {},
37
+ ...backupApi !== void 0 ? { backupApiUrl: backupApi.backupApiUrl } : {},
38
+ ...groupsApi !== void 0 ? { groupsCapabilities: [...groupsApi.capabilities] } : {},
39
+ ...backupApi !== void 0 ? { backupCapabilities: [...backupApi.capabilities] } : {},
40
+ applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp
41
+ };
42
+ }
43
+ /**
44
+ * Returns a plain Partner authorize response copy for trusted auth-cache persistence.
45
+ *
46
+ * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
47
+ * result can be serialized, parsed, and passed back to
48
+ * `PartnerAccountInfo.setAuth()`.
49
+ *
50
+ * The returned value is raw bearer-token material. Store it only in encrypted
51
+ * or otherwise credential-grade durable storage, and never log it.
52
+ *
53
+ * @param auth - Partner authorization response to persist.
54
+ *
55
+ * @returns A plain object with the live Partner token preserved.
56
+ */
57
+ function partnerAuthorizeResponseForPersistence(auth) {
58
+ return clonePartnerAuthorizeResponse(auth);
59
+ }
60
+ //#endregion
61
+ export { clonePartnerAuthorizeResponse, partnerAuthorizeResponseForPersistence };
62
+
63
+ //# sourceMappingURL=auth-clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-clone.js","names":[],"sources":["../../src/partner/auth-clone.ts"],"sourcesContent":["import type { PartnerAuthorizeResponse } from '../types/partner.ts'\nimport { validatePartnerAuthorizeResponseShape } from './auth-shape.ts'\n\n/**\n * Returns a hook-free Partner authorize response copy.\n *\n * @param auth - Partner authorization response to clone.\n *\n * @returns A plain object preserving the live Partner token.\n *\n * @internal\n */\nexport function clonePartnerAuthorizeResponse(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n validatePartnerAuthorizeResponseShape(auth)\n\n const storageApi = auth.apiInfo.storageApi\n const groupsApi = auth.apiInfo.groupsApi\n const backupApi = auth.apiInfo.backupApi\n\n return {\n accountId: auth.accountId,\n authorizationToken: auth.authorizationToken,\n apiInfo: {\n ...(storageApi !== undefined\n ? {\n storageApi: {\n ...storageApi,\n capabilities: [...storageApi.capabilities],\n },\n }\n : {}),\n ...(groupsApi !== undefined\n ? {\n groupsApi: {\n ...groupsApi,\n capabilities: [...groupsApi.capabilities],\n infoType: 'groupsApi' as const,\n },\n }\n : {}),\n ...(backupApi !== undefined\n ? {\n backupApi: {\n ...backupApi,\n capabilities: [...backupApi.capabilities],\n infoType: 'backupApi' as const,\n },\n }\n : {}),\n },\n ...(groupsApi !== undefined ? { groupsApiUrl: groupsApi.groupsApiUrl } : {}),\n ...(backupApi !== undefined ? { backupApiUrl: backupApi.backupApiUrl } : {}),\n ...(groupsApi !== undefined ? { groupsCapabilities: [...groupsApi.capabilities] } : {}),\n ...(backupApi !== undefined ? { backupCapabilities: [...backupApi.capabilities] } : {}),\n applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp,\n }\n}\n\n/**\n * Returns a plain Partner authorize response copy for trusted auth-cache persistence.\n *\n * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the\n * result can be serialized, parsed, and passed back to\n * `PartnerAccountInfo.setAuth()`.\n *\n * The returned value is raw bearer-token material. Store it only in encrypted\n * or otherwise credential-grade durable storage, and never log it.\n *\n * @param auth - Partner authorization response to persist.\n *\n * @returns A plain object with the live Partner token preserved.\n */\nexport function partnerAuthorizeResponseForPersistence(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n return clonePartnerAuthorizeResponse(auth)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,8BACd,MAC0B;CAC1B,sCAAsC,IAAI;CAE1C,MAAM,aAAa,KAAK,QAAQ;CAChC,MAAM,YAAY,KAAK,QAAQ;CAC/B,MAAM,YAAY,KAAK,QAAQ;CAE/B,OAAO;EACL,WAAW,KAAK;EAChB,oBAAoB,KAAK;EACzB,SAAS;GACP,GAAI,eAAe,KAAA,IACf,EACE,YAAY;IACV,GAAG;IACH,cAAc,CAAC,GAAG,WAAW,YAAY;GAC3C,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;EACP;EACA,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,mCAAmC,KAAK;CAC1C;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,uCACd,MAC0B;CAC1B,OAAO,8BAA8B,IAAI;AAC3C"}
@@ -0,0 +1,175 @@
1
+ const require_abort = require("../util/abort.cjs");
2
+ const require_retry = require("../http/retry.cjs");
3
+ const require_realms = require("../auth/realms.cjs");
4
+ const require_url_guard = require("../http/url-guard.cjs");
5
+ const require_transport = require("../http/transport.cjs");
6
+ const require_in_memory = require("./in-memory.cjs");
7
+ const require_raw = require("./raw.cjs");
8
+ //#region src/partner/auth-core.ts
9
+ /**
10
+ * Internal Partner authorization state machine shared by public facades.
11
+ *
12
+ * @internal
13
+ */
14
+ var PartnerAuthCore = class {
15
+ /** Low-level Partner raw client used for authorization and Partner endpoints. */
16
+ raw;
17
+ /** Partner authorization state storage. */
18
+ partnerAccountInfo;
19
+ /** Default transport URL guard, or null when a custom transport owns guarding. */
20
+ urlGuard;
21
+ /** Retry-wrapped transport shared by facade-specific raw clients. */
22
+ transport;
23
+ /** Endpoint suffixes validated from cached authorization during construction. */
24
+ cachedEndpointSuffixes;
25
+ /** Resolved Partner authorize realm URL. */
26
+ realmUrl;
27
+ /** Whether custom authorize realms are trusted. */
28
+ allowCustomAuthorizeRealm;
29
+ #masterKeyId;
30
+ #masterKey;
31
+ additionalAllowedSuffixes;
32
+ disableSsrfGuard;
33
+ #inflightReauth = null;
34
+ /**
35
+ * Creates a shared Partner authorization core.
36
+ *
37
+ * @param options - Credentials, state storage, transport, retry, and guard settings.
38
+ */
39
+ constructor(options) {
40
+ this.#masterKeyId = options.masterKeyId;
41
+ this.#masterKey = options.masterKey;
42
+ this.realmUrl = require_realms.getRealmUrl(options.realm ?? "production");
43
+ this.partnerAccountInfo = options.partnerAccountInfo ?? new require_in_memory.InMemoryPartnerAccountInfo();
44
+ this.additionalAllowedSuffixes = options.additionalAllowedHostSuffixes;
45
+ this.disableSsrfGuard = options.disableSsrfGuard ?? false;
46
+ this.allowCustomAuthorizeRealm = options.allowCustomAuthorizeRealm ?? false;
47
+ let baseTransport;
48
+ if (options.transport !== void 0) {
49
+ baseTransport = options.transport;
50
+ this.urlGuard = null;
51
+ } else {
52
+ const urlGuard = new require_url_guard.UrlGuard();
53
+ baseTransport = new require_transport.FetchTransport({
54
+ urlGuard,
55
+ ...options.userAgent !== void 0 ? { userAgent: options.userAgent } : {},
56
+ ...options.followSameOriginRedirects !== void 0 ? { followSameOriginRedirects: options.followSameOriginRedirects } : {}
57
+ });
58
+ this.urlGuard = urlGuard;
59
+ }
60
+ this.transport = new require_transport.RetryTransport({
61
+ transport: baseTransport,
62
+ retry: {
63
+ ...require_retry.DEFAULT_RETRY_OPTIONS,
64
+ ...options.retry
65
+ },
66
+ onReauth: (signal) => this.reauthorize(signal)
67
+ });
68
+ this.cachedEndpointSuffixes = this.validateCachedAuth();
69
+ if (this.cachedEndpointSuffixes !== void 0) this.lockUrlGuardFromSuffixes(this.cachedEndpointSuffixes);
70
+ this.raw = new require_raw.PartnerRawClient({
71
+ transport: this.transport,
72
+ ...this.cachedEndpointSuffixes !== void 0 ? { authorizedPartnerEndpointSuffixes: this.cachedEndpointSuffixes } : {},
73
+ ...options.allowCustomAuthorizeRealm !== void 0 ? { allowCustomAuthorizeRealm: options.allowCustomAuthorizeRealm } : {}
74
+ });
75
+ }
76
+ /**
77
+ * Authenticates with B2 Partner authorization and stores the authorization state.
78
+ *
79
+ * @param options - Optional abort signal.
80
+ *
81
+ * @returns The normalized Partner authorization response.
82
+ */
83
+ async authorize(options) {
84
+ require_abort.throwIfSignalAborted(options?.signal);
85
+ const auth = await this.raw.authorizePartner(this.#masterKeyId, this.#masterKey, this.realmUrl, options?.signal !== void 0 ? { signal: options.signal } : void 0);
86
+ require_abort.throwIfSignalAborted(options?.signal);
87
+ this.partnerAccountInfo.setAuth(auth);
88
+ this.lockUrlGuard(auth);
89
+ return auth;
90
+ }
91
+ /**
92
+ * Locks the default transport URL guard to suffixes from a validated auth response.
93
+ *
94
+ * @param auth - Partner authorization response to derive suffixes from.
95
+ */
96
+ lockUrlGuard(auth) {
97
+ this.lockUrlGuardFromSuffixes(require_raw.derivePartnerAllowedSuffixes(auth, this.realmUrl));
98
+ }
99
+ /**
100
+ * Locks the default transport URL guard to previously validated endpoint suffixes.
101
+ *
102
+ * @param derived - Validated endpoint suffixes.
103
+ */
104
+ lockUrlGuardFromSuffixes(derived) {
105
+ if (this.urlGuard === null) return;
106
+ const merged = this.disableSsrfGuard === true ? [] : this.additionalAllowedSuffixes !== void 0 ? Array.from(/* @__PURE__ */ new Set([...derived, ...this.additionalAllowedSuffixes])) : derived;
107
+ this.urlGuard.setAllowedSuffixes(merged);
108
+ }
109
+ /**
110
+ * Validates a Partner authorization snapshot and returns endpoint suffixes.
111
+ *
112
+ * @param auth - Partner authorization response to validate.
113
+ *
114
+ * @returns Host suffixes safe for Partner-token endpoint requests.
115
+ *
116
+ * @internal
117
+ */
118
+ validateEndpointSuffixes(auth) {
119
+ return require_raw.validatePartnerAuthorizeResponseEndpoints(auth, this.realmUrl, this.allowCustomAuthorizeRealm);
120
+ }
121
+ /**
122
+ * Validates an auth snapshot, locks the default URL guard, and returns endpoint suffixes.
123
+ *
124
+ * @param auth - Partner authorization response to validate and activate.
125
+ *
126
+ * @returns Host suffixes safe for Partner-token endpoint requests.
127
+ *
128
+ * @internal
129
+ */
130
+ activateEndpointSuffixes(auth) {
131
+ const suffixes = this.validateEndpointSuffixes(auth);
132
+ this.lockUrlGuardFromSuffixes(suffixes);
133
+ return suffixes;
134
+ }
135
+ validateCachedAuth() {
136
+ const cachedAuth = this.partnerAccountInfo.getAuth();
137
+ if (cachedAuth === null) return void 0;
138
+ try {
139
+ return this.validateEndpointSuffixes(cachedAuth);
140
+ } catch {
141
+ return;
142
+ }
143
+ }
144
+ reauthorize(signal) {
145
+ require_abort.throwIfSignalAborted(signal);
146
+ const inflight = this.#inflightReauth ?? this.startReauthorize();
147
+ inflight.waiters += 1;
148
+ return require_abort.raceWithAbort(inflight.promise, signal).finally(() => {
149
+ inflight.waiters -= 1;
150
+ if (inflight.waiters === 0 && !inflight.settled && !inflight.controller.signal.aborted) inflight.controller.abort(signal?.aborted === true ? require_abort.abortReason(signal) : void 0);
151
+ });
152
+ }
153
+ startReauthorize() {
154
+ const controller = new AbortController();
155
+ const inflight = {
156
+ controller,
157
+ promise: require_abort.raceWithAbort(this.doReauthorize(controller.signal), controller.signal).finally(() => {
158
+ if (this.#inflightReauth?.controller !== controller) return;
159
+ this.#inflightReauth.settled = true;
160
+ this.#inflightReauth = null;
161
+ }),
162
+ waiters: 0,
163
+ settled: false
164
+ };
165
+ this.#inflightReauth = inflight;
166
+ return inflight;
167
+ }
168
+ async doReauthorize(signal) {
169
+ return (await this.authorize({ signal })).authorizationToken;
170
+ }
171
+ };
172
+ //#endregion
173
+ exports.PartnerAuthCore = PartnerAuthCore;
174
+
175
+ //# sourceMappingURL=auth-core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-core.cjs","names":["#masterKeyId","#masterKey","#inflightReauth"],"sources":["../../src/partner/auth-core.ts"],"sourcesContent":["import { getRealmUrl } from '../auth/realms.ts'\nimport { DEFAULT_RETRY_OPTIONS, type RetryOptions } from '../http/retry.ts'\nimport type { HttpTransport } from '../http/transport.ts'\nimport { FetchTransport, RetryTransport } from '../http/transport.ts'\nimport { UrlGuard } from '../http/url-guard.ts'\nimport type { PartnerAuthorizeResponse } from '../types/partner.ts'\nimport { abortReason, raceWithAbort, throwIfSignalAborted } from '../util/abort.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { InMemoryPartnerAccountInfo } from './in-memory.ts'\nimport {\n derivePartnerAllowedSuffixes,\n PartnerRawClient,\n validatePartnerAuthorizeResponseEndpoints,\n} from './raw.ts'\n\n/** Shared Partner authorization options used by Partner and Backup facades. */\nexport interface PartnerAuthCoreOptions {\n /** The Master Application Key ID for the partner administrator account. */\n readonly masterKeyId: string\n /** The Master Application Key secret. */\n readonly masterKey: string\n /** B2 realm alias or direct trusted realm URL. Defaults to `\"production\"`. */\n readonly realm?: string\n /** Storage backend for Partner authorization state. */\n readonly partnerAccountInfo?: PartnerAccountInfo\n /** Custom HTTP transport. Defaults to {@link FetchTransport}. */\n readonly transport?: HttpTransport\n /** Override retry behavior for retryable requests. */\n readonly retry?: Partial<RetryOptions>\n /** Custom user-agent string prepended to the SDK default. */\n readonly userAgent?: string\n /** Extra trusted host suffixes to merge into the default SSRF guard. */\n readonly additionalAllowedHostSuffixes?: readonly string[]\n /** Explicitly disable default SSRF guard suffix locking. */\n readonly disableSsrfGuard?: boolean\n /** Whether the default fetch transport may follow same-origin GET/HEAD redirects. */\n readonly followSameOriginRedirects?: boolean\n /** Allow direct custom authorize realms for tests or private proxies. */\n readonly allowCustomAuthorizeRealm?: boolean\n}\n\n/** Options for Partner authorization through {@link PartnerAuthCore}. */\nexport interface PartnerAuthCoreAuthorizeOptions {\n /** Abort signal for cancelling the authorize request. */\n readonly signal?: AbortSignal\n}\n\ninterface InflightPartnerReauth {\n readonly controller: AbortController\n readonly promise: Promise<string>\n waiters: number\n settled: boolean\n}\n\n/**\n * Internal Partner authorization state machine shared by public facades.\n *\n * @internal\n */\nexport class PartnerAuthCore {\n /** Low-level Partner raw client used for authorization and Partner endpoints. */\n readonly raw: PartnerRawClient\n /** Partner authorization state storage. */\n readonly partnerAccountInfo: PartnerAccountInfo\n /** Default transport URL guard, or null when a custom transport owns guarding. */\n readonly urlGuard: UrlGuard | null\n /** Retry-wrapped transport shared by facade-specific raw clients. */\n readonly transport: HttpTransport\n /** Endpoint suffixes validated from cached authorization during construction. */\n readonly cachedEndpointSuffixes: readonly string[] | undefined\n /** Resolved Partner authorize realm URL. */\n private readonly realmUrl: string\n /** Whether custom authorize realms are trusted. */\n private readonly allowCustomAuthorizeRealm: boolean\n readonly #masterKeyId: string\n readonly #masterKey: string\n private readonly additionalAllowedSuffixes: readonly string[] | undefined\n private readonly disableSsrfGuard: boolean\n #inflightReauth: InflightPartnerReauth | null = null\n\n /**\n * Creates a shared Partner authorization core.\n *\n * @param options - Credentials, state storage, transport, retry, and guard settings.\n */\n constructor(options: PartnerAuthCoreOptions) {\n this.#masterKeyId = options.masterKeyId\n this.#masterKey = options.masterKey\n this.realmUrl = getRealmUrl(options.realm ?? 'production')\n this.partnerAccountInfo = options.partnerAccountInfo ?? new InMemoryPartnerAccountInfo()\n this.additionalAllowedSuffixes = options.additionalAllowedHostSuffixes\n this.disableSsrfGuard = options.disableSsrfGuard ?? false\n this.allowCustomAuthorizeRealm = options.allowCustomAuthorizeRealm ?? false\n\n let baseTransport: HttpTransport\n if (options.transport !== undefined) {\n baseTransport = options.transport\n this.urlGuard = null\n } else {\n const urlGuard = new UrlGuard()\n baseTransport = new FetchTransport({\n urlGuard,\n ...(options.userAgent !== undefined ? { userAgent: options.userAgent } : {}),\n ...(options.followSameOriginRedirects !== undefined\n ? { followSameOriginRedirects: options.followSameOriginRedirects }\n : {}),\n })\n this.urlGuard = urlGuard\n }\n\n this.transport = new RetryTransport({\n transport: baseTransport,\n retry: { ...DEFAULT_RETRY_OPTIONS, ...options.retry },\n onReauth: (signal) => this.reauthorize(signal),\n })\n\n this.cachedEndpointSuffixes = this.validateCachedAuth()\n if (this.cachedEndpointSuffixes !== undefined) {\n this.lockUrlGuardFromSuffixes(this.cachedEndpointSuffixes)\n }\n\n this.raw = new PartnerRawClient({\n transport: this.transport,\n ...(this.cachedEndpointSuffixes !== undefined\n ? { authorizedPartnerEndpointSuffixes: this.cachedEndpointSuffixes }\n : {}),\n ...(options.allowCustomAuthorizeRealm !== undefined\n ? { allowCustomAuthorizeRealm: options.allowCustomAuthorizeRealm }\n : {}),\n })\n }\n\n /**\n * Authenticates with B2 Partner authorization and stores the authorization state.\n *\n * @param options - Optional abort signal.\n *\n * @returns The normalized Partner authorization response.\n */\n async authorize(options?: PartnerAuthCoreAuthorizeOptions): Promise<PartnerAuthorizeResponse> {\n throwIfSignalAborted(options?.signal)\n const auth = await this.raw.authorizePartner(\n this.#masterKeyId,\n this.#masterKey,\n this.realmUrl,\n options?.signal !== undefined ? { signal: options.signal } : undefined,\n )\n throwIfSignalAborted(options?.signal)\n this.partnerAccountInfo.setAuth(auth)\n this.lockUrlGuard(auth)\n return auth\n }\n\n /**\n * Locks the default transport URL guard to suffixes from a validated auth response.\n *\n * @param auth - Partner authorization response to derive suffixes from.\n */\n lockUrlGuard(auth: PartnerAuthorizeResponse): void {\n this.lockUrlGuardFromSuffixes(derivePartnerAllowedSuffixes(auth, this.realmUrl))\n }\n\n /**\n * Locks the default transport URL guard to previously validated endpoint suffixes.\n *\n * @param derived - Validated endpoint suffixes.\n */\n private lockUrlGuardFromSuffixes(derived: readonly string[]): void {\n if (this.urlGuard === null) return\n const merged =\n this.disableSsrfGuard === true\n ? []\n : this.additionalAllowedSuffixes !== undefined\n ? Array.from(new Set([...derived, ...this.additionalAllowedSuffixes]))\n : derived\n this.urlGuard.setAllowedSuffixes(merged)\n }\n\n /**\n * Validates a Partner authorization snapshot and returns endpoint suffixes.\n *\n * @param auth - Partner authorization response to validate.\n *\n * @returns Host suffixes safe for Partner-token endpoint requests.\n *\n * @internal\n */\n private validateEndpointSuffixes(auth: PartnerAuthorizeResponse): readonly string[] {\n return validatePartnerAuthorizeResponseEndpoints(\n auth,\n this.realmUrl,\n this.allowCustomAuthorizeRealm,\n )\n }\n\n /**\n * Validates an auth snapshot, locks the default URL guard, and returns endpoint suffixes.\n *\n * @param auth - Partner authorization response to validate and activate.\n *\n * @returns Host suffixes safe for Partner-token endpoint requests.\n *\n * @internal\n */\n activateEndpointSuffixes(auth: PartnerAuthorizeResponse): readonly string[] {\n const suffixes = this.validateEndpointSuffixes(auth)\n this.lockUrlGuardFromSuffixes(suffixes)\n return suffixes\n }\n\n private validateCachedAuth(): readonly string[] | undefined {\n const cachedAuth = this.partnerAccountInfo.getAuth()\n if (cachedAuth === null) return undefined\n try {\n return this.validateEndpointSuffixes(cachedAuth)\n } catch {\n // Do not mutate a shared PartnerAccountInfo during construction. The\n // facade will ignore this auth locally until authorize() replaces it.\n return undefined\n }\n }\n\n private reauthorize(signal: AbortSignal | undefined): Promise<string> {\n throwIfSignalAborted(signal)\n const inflight = this.#inflightReauth ?? this.startReauthorize()\n inflight.waiters += 1\n return raceWithAbort(inflight.promise, signal).finally(() => {\n inflight.waiters -= 1\n if (inflight.waiters === 0 && !inflight.settled && !inflight.controller.signal.aborted) {\n inflight.controller.abort(signal?.aborted === true ? abortReason(signal) : undefined)\n }\n })\n }\n\n private startReauthorize(): InflightPartnerReauth {\n const controller = new AbortController()\n const promise = raceWithAbort(this.doReauthorize(controller.signal), controller.signal).finally(\n () => {\n if (this.#inflightReauth?.controller !== controller) return\n this.#inflightReauth.settled = true\n this.#inflightReauth = null\n },\n )\n const inflight: InflightPartnerReauth = {\n controller,\n promise,\n waiters: 0,\n settled: false,\n }\n this.#inflightReauth = inflight\n return inflight\n }\n\n private async doReauthorize(signal: AbortSignal): Promise<string> {\n const auth = await this.authorize({ signal })\n return auth.authorizationToken\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA2DA,IAA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