@backblaze-labs/b2-sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (701) hide show
  1. package/CHANGELOG.md +110 -5
  2. package/README.md +144 -33
  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/bucket.cjs +785 -787
  44. package/dist/bucket.cjs.map +1 -1
  45. package/dist/bucket.d.cts +35 -47
  46. package/dist/bucket.d.cts.map +1 -1
  47. package/dist/bucket.d.ts +35 -47
  48. package/dist/bucket.d.ts.map +1 -1
  49. package/dist/bucket.js +780 -782
  50. package/dist/bucket.js.map +1 -1
  51. package/dist/client.cjs +246 -228
  52. package/dist/client.cjs.map +1 -1
  53. package/dist/client.d.cts +25 -17
  54. package/dist/client.d.cts.map +1 -1
  55. package/dist/client.d.ts +25 -17
  56. package/dist/client.d.ts.map +1 -1
  57. package/dist/client.js +243 -225
  58. package/dist/client.js.map +1 -1
  59. package/dist/copy/large.cjs +114 -71
  60. package/dist/copy/large.cjs.map +1 -1
  61. package/dist/copy/large.d.cts +6 -0
  62. package/dist/copy/large.d.cts.map +1 -1
  63. package/dist/copy/large.d.ts +6 -0
  64. package/dist/copy/large.d.ts.map +1 -1
  65. package/dist/copy/large.js +112 -69
  66. package/dist/copy/large.js.map +1 -1
  67. package/dist/download/checksum.cjs +89 -0
  68. package/dist/download/checksum.cjs.map +1 -0
  69. package/dist/download/checksum.d.cts +40 -0
  70. package/dist/download/checksum.d.cts.map +1 -0
  71. package/dist/download/checksum.d.ts +40 -0
  72. package/dist/download/checksum.d.ts.map +1 -0
  73. package/dist/download/checksum.js +87 -0
  74. package/dist/download/checksum.js.map +1 -0
  75. package/dist/download/parallel.cjs +214 -118
  76. package/dist/download/parallel.cjs.map +1 -1
  77. package/dist/download/parallel.d.cts +5 -1
  78. package/dist/download/parallel.d.cts.map +1 -1
  79. package/dist/download/parallel.d.ts +5 -1
  80. package/dist/download/parallel.d.ts.map +1 -1
  81. package/dist/download/parallel.js +212 -116
  82. package/dist/download/parallel.js.map +1 -1
  83. package/dist/download/single.cjs +188 -97
  84. package/dist/download/single.cjs.map +1 -1
  85. package/dist/download/single.d.cts +6 -1
  86. package/dist/download/single.d.cts.map +1 -1
  87. package/dist/download/single.d.ts +6 -1
  88. package/dist/download/single.d.ts.map +1 -1
  89. package/dist/download/single.js +186 -98
  90. package/dist/download/single.js.map +1 -1
  91. package/dist/errors/index.cjs +699 -243
  92. package/dist/errors/index.cjs.map +1 -1
  93. package/dist/errors/index.d.cts +285 -82
  94. package/dist/errors/index.d.cts.map +1 -1
  95. package/dist/errors/index.d.ts +285 -82
  96. package/dist/errors/index.d.ts.map +1 -1
  97. package/dist/errors/index.js +678 -261
  98. package/dist/errors/index.js.map +1 -1
  99. package/dist/http/retry.cjs +45 -28
  100. package/dist/http/retry.cjs.map +1 -1
  101. package/dist/http/retry.d.cts +15 -2
  102. package/dist/http/retry.d.cts.map +1 -1
  103. package/dist/http/retry.d.ts +15 -2
  104. package/dist/http/retry.d.ts.map +1 -1
  105. package/dist/http/retry.js +46 -31
  106. package/dist/http/retry.js.map +1 -1
  107. package/dist/http/transport.cjs +438 -140
  108. package/dist/http/transport.cjs.map +1 -1
  109. package/dist/http/transport.d.cts +21 -2
  110. package/dist/http/transport.d.cts.map +1 -1
  111. package/dist/http/transport.d.ts +21 -2
  112. package/dist/http/transport.d.ts.map +1 -1
  113. package/dist/http/transport.js +437 -140
  114. package/dist/http/transport.js.map +1 -1
  115. package/dist/http/url-guard.cjs +154 -89
  116. package/dist/http/url-guard.cjs.map +1 -1
  117. package/dist/http/url-guard.d.cts +25 -3
  118. package/dist/http/url-guard.d.cts.map +1 -1
  119. package/dist/http/url-guard.d.ts +25 -3
  120. package/dist/http/url-guard.d.ts.map +1 -1
  121. package/dist/http/url-guard.js +152 -90
  122. package/dist/http/url-guard.js.map +1 -1
  123. package/dist/http/user-agent.cjs +84 -44
  124. package/dist/http/user-agent.cjs.map +1 -1
  125. package/dist/http/user-agent.js +84 -46
  126. package/dist/http/user-agent.js.map +1 -1
  127. package/dist/index.cjs +101 -77
  128. package/dist/index.d.cts +27 -21
  129. package/dist/index.d.cts.map +1 -1
  130. package/dist/index.d.ts +27 -21
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/index.js +15 -71
  133. package/dist/internal/b2-naming.cjs +66 -0
  134. package/dist/internal/b2-naming.cjs.map +1 -0
  135. package/dist/internal/b2-naming.d.cts +43 -0
  136. package/dist/internal/b2-naming.d.cts.map +1 -0
  137. package/dist/internal/b2-naming.d.ts +43 -0
  138. package/dist/internal/b2-naming.d.ts.map +1 -0
  139. package/dist/internal/b2-naming.js +60 -0
  140. package/dist/internal/b2-naming.js.map +1 -0
  141. package/dist/internal/upload-retry-options.cjs +21 -0
  142. package/dist/internal/upload-retry-options.cjs.map +1 -0
  143. package/dist/internal/upload-retry-options.d.cts +12 -0
  144. package/dist/internal/upload-retry-options.d.cts.map +1 -0
  145. package/dist/internal/upload-retry-options.d.ts +12 -0
  146. package/dist/internal/upload-retry-options.d.ts.map +1 -0
  147. package/dist/internal/upload-retry-options.js +21 -0
  148. package/dist/internal/upload-retry-options.js.map +1 -0
  149. package/dist/internal/url-redaction.cjs +31 -0
  150. package/dist/internal/url-redaction.cjs.map +1 -0
  151. package/dist/internal/url-redaction.d.cts +17 -0
  152. package/dist/internal/url-redaction.d.cts.map +1 -0
  153. package/dist/internal/url-redaction.d.ts +17 -0
  154. package/dist/internal/url-redaction.d.ts.map +1 -0
  155. package/dist/internal/url-redaction.js +31 -0
  156. package/dist/internal/url-redaction.js.map +1 -0
  157. package/dist/notifications/index.cjs +4 -6
  158. package/dist/notifications/index.d.cts +1 -1
  159. package/dist/notifications/index.d.cts.map +1 -1
  160. package/dist/notifications/index.d.ts +1 -1
  161. package/dist/notifications/index.d.ts.map +1 -1
  162. package/dist/notifications/index.js +1 -6
  163. package/dist/notifications/webhook.cjs +195 -85
  164. package/dist/notifications/webhook.cjs.map +1 -1
  165. package/dist/notifications/webhook.d.cts.map +1 -1
  166. package/dist/notifications/webhook.d.ts.map +1 -1
  167. package/dist/notifications/webhook.js +195 -87
  168. package/dist/notifications/webhook.js.map +1 -1
  169. package/dist/object.cjs +253 -210
  170. package/dist/object.cjs.map +1 -1
  171. package/dist/object.d.cts +9 -55
  172. package/dist/object.d.cts.map +1 -1
  173. package/dist/object.d.ts +9 -55
  174. package/dist/object.d.ts.map +1 -1
  175. package/dist/object.js +249 -206
  176. package/dist/object.js.map +1 -1
  177. package/dist/raw/encoding.cjs +74 -35
  178. package/dist/raw/encoding.cjs.map +1 -1
  179. package/dist/raw/encoding.js +74 -38
  180. package/dist/raw/encoding.js.map +1 -1
  181. package/dist/raw/index.cjs +678 -587
  182. package/dist/raw/index.cjs.map +1 -1
  183. package/dist/raw/index.d.cts +121 -18
  184. package/dist/raw/index.d.cts.map +1 -1
  185. package/dist/raw/index.d.ts +121 -18
  186. package/dist/raw/index.d.ts.map +1 -1
  187. package/dist/raw/index.js +674 -589
  188. package/dist/raw/index.js.map +1 -1
  189. package/dist/s3/index.cjs +355 -18
  190. package/dist/s3/index.cjs.map +1 -1
  191. package/dist/s3/index.d.cts +233 -5
  192. package/dist/s3/index.d.cts.map +1 -1
  193. package/dist/s3/index.d.ts +233 -5
  194. package/dist/s3/index.d.ts.map +1 -1
  195. package/dist/s3/index.js +351 -22
  196. package/dist/s3/index.js.map +1 -1
  197. package/dist/s3/sigv4.cjs +149 -0
  198. package/dist/s3/sigv4.cjs.map +1 -0
  199. package/dist/s3/sigv4.d.cts +43 -0
  200. package/dist/s3/sigv4.d.cts.map +1 -0
  201. package/dist/s3/sigv4.d.ts +43 -0
  202. package/dist/s3/sigv4.d.ts.map +1 -0
  203. package/dist/s3/sigv4.js +148 -0
  204. package/dist/s3/sigv4.js.map +1 -0
  205. package/dist/s3/validation.cjs +69 -0
  206. package/dist/s3/validation.cjs.map +1 -0
  207. package/dist/s3/validation.d.cts +43 -0
  208. package/dist/s3/validation.d.cts.map +1 -0
  209. package/dist/s3/validation.d.ts +43 -0
  210. package/dist/s3/validation.d.ts.map +1 -0
  211. package/dist/s3/validation.js +66 -0
  212. package/dist/s3/validation.js.map +1 -0
  213. package/dist/simulator/capabilities.cjs +63 -48
  214. package/dist/simulator/capabilities.cjs.map +1 -1
  215. package/dist/simulator/capabilities.js +63 -49
  216. package/dist/simulator/capabilities.js.map +1 -1
  217. package/dist/simulator/index.cjs +2124 -1548
  218. package/dist/simulator/index.cjs.map +1 -1
  219. package/dist/simulator/index.d.cts +79 -11
  220. package/dist/simulator/index.d.cts.map +1 -1
  221. package/dist/simulator/index.d.ts +79 -11
  222. package/dist/simulator/index.d.ts.map +1 -1
  223. package/dist/simulator/index.js +2112 -1546
  224. package/dist/simulator/index.js.map +1 -1
  225. package/dist/simulator/validation.cjs +191 -153
  226. package/dist/simulator/validation.cjs.map +1 -1
  227. package/dist/simulator/validation.d.cts +3 -21
  228. package/dist/simulator/validation.d.cts.map +1 -1
  229. package/dist/simulator/validation.d.ts +3 -21
  230. package/dist/simulator/validation.d.ts.map +1 -1
  231. package/dist/simulator/validation.js +188 -162
  232. package/dist/simulator/validation.js.map +1 -1
  233. package/dist/streams/collect.cjs +74 -24
  234. package/dist/streams/collect.cjs.map +1 -1
  235. package/dist/streams/collect.d.cts +14 -1
  236. package/dist/streams/collect.d.cts.map +1 -1
  237. package/dist/streams/collect.d.ts +14 -1
  238. package/dist/streams/collect.d.ts.map +1 -1
  239. package/dist/streams/collect.js +74 -25
  240. package/dist/streams/collect.js.map +1 -1
  241. package/dist/streams/file-source.cjs +287 -0
  242. package/dist/streams/file-source.cjs.map +1 -0
  243. package/dist/streams/file-source.d.cts +96 -0
  244. package/dist/streams/file-source.d.cts.map +1 -0
  245. package/dist/streams/file-source.d.ts +96 -0
  246. package/dist/streams/file-source.d.ts.map +1 -0
  247. package/dist/streams/file-source.js +286 -0
  248. package/dist/streams/file-source.js.map +1 -0
  249. package/dist/streams/hash.cjs +207 -115
  250. package/dist/streams/hash.cjs.map +1 -1
  251. package/dist/streams/hash.d.cts +5 -4
  252. package/dist/streams/hash.d.cts.map +1 -1
  253. package/dist/streams/hash.d.ts +5 -4
  254. package/dist/streams/hash.d.ts.map +1 -1
  255. package/dist/streams/hash.js +208 -95
  256. package/dist/streams/hash.js.map +1 -1
  257. package/dist/streams/index.cjs +12 -12
  258. package/dist/streams/index.d.cts +3 -3
  259. package/dist/streams/index.d.cts.map +1 -1
  260. package/dist/streams/index.d.ts +3 -3
  261. package/dist/streams/index.d.ts.map +1 -1
  262. package/dist/streams/index.js +2 -10
  263. package/dist/streams/progress.cjs +60 -46
  264. package/dist/streams/progress.cjs.map +1 -1
  265. package/dist/streams/progress.js +60 -46
  266. package/dist/streams/progress.js.map +1 -1
  267. package/dist/streams/source.cjs +316 -146
  268. package/dist/streams/source.cjs.map +1 -1
  269. package/dist/streams/source.d.cts +56 -18
  270. package/dist/streams/source.d.cts.map +1 -1
  271. package/dist/streams/source.d.ts +56 -18
  272. package/dist/streams/source.d.ts.map +1 -1
  273. package/dist/streams/source.js +312 -149
  274. package/dist/streams/source.js.map +1 -1
  275. package/dist/sync/actions/index.cjs +236 -184
  276. package/dist/sync/actions/index.cjs.map +1 -1
  277. package/dist/sync/actions/index.d.cts +29 -21
  278. package/dist/sync/actions/index.d.cts.map +1 -1
  279. package/dist/sync/actions/index.d.ts +29 -21
  280. package/dist/sync/actions/index.d.ts.map +1 -1
  281. package/dist/sync/actions/index.js +236 -190
  282. package/dist/sync/actions/index.js.map +1 -1
  283. package/dist/sync/b2-sha1-reader.cjs +148 -0
  284. package/dist/sync/b2-sha1-reader.cjs.map +1 -0
  285. package/dist/sync/b2-sha1-reader.d.cts +58 -0
  286. package/dist/sync/b2-sha1-reader.d.cts.map +1 -0
  287. package/dist/sync/b2-sha1-reader.d.ts +58 -0
  288. package/dist/sync/b2-sha1-reader.d.ts.map +1 -0
  289. package/dist/sync/b2-sha1-reader.js +145 -0
  290. package/dist/sync/b2-sha1-reader.js.map +1 -0
  291. package/dist/sync/download-staging.cjs +265 -0
  292. package/dist/sync/download-staging.cjs.map +1 -0
  293. package/dist/sync/download-staging.d.cts +54 -0
  294. package/dist/sync/download-staging.d.cts.map +1 -0
  295. package/dist/sync/download-staging.d.ts +54 -0
  296. package/dist/sync/download-staging.d.ts.map +1 -0
  297. package/dist/sync/download-staging.js +259 -0
  298. package/dist/sync/download-staging.js.map +1 -0
  299. package/dist/sync/filesystem-errors.cjs +32 -0
  300. package/dist/sync/filesystem-errors.cjs.map +1 -0
  301. package/dist/sync/filesystem-errors.d.cts +8 -0
  302. package/dist/sync/filesystem-errors.d.cts.map +1 -0
  303. package/dist/sync/filesystem-errors.d.ts +8 -0
  304. package/dist/sync/filesystem-errors.d.ts.map +1 -0
  305. package/dist/sync/filesystem-errors.js +32 -0
  306. package/dist/sync/filesystem-errors.js.map +1 -0
  307. package/dist/sync/filters.cjs +217 -0
  308. package/dist/sync/filters.cjs.map +1 -0
  309. package/dist/sync/filters.d.cts +51 -0
  310. package/dist/sync/filters.d.cts.map +1 -0
  311. package/dist/sync/filters.d.ts +51 -0
  312. package/dist/sync/filters.d.ts.map +1 -0
  313. package/dist/sync/filters.js +213 -0
  314. package/dist/sync/filters.js.map +1 -0
  315. package/dist/sync/index.cjs +39 -22
  316. package/dist/sync/index.d.cts +14 -9
  317. package/dist/sync/index.d.cts.map +1 -1
  318. package/dist/sync/index.d.ts +14 -9
  319. package/dist/sync/index.d.ts.map +1 -1
  320. package/dist/sync/index.js +9 -20
  321. package/dist/sync/local-file-identity.cjs +61 -0
  322. package/dist/sync/local-file-identity.cjs.map +1 -0
  323. package/dist/sync/local-file-identity.d.cts +37 -0
  324. package/dist/sync/local-file-identity.d.cts.map +1 -0
  325. package/dist/sync/local-file-identity.d.ts +37 -0
  326. package/dist/sync/local-file-identity.d.ts.map +1 -0
  327. package/dist/sync/local-file-identity.js +60 -0
  328. package/dist/sync/local-file-identity.js.map +1 -0
  329. package/dist/sync/local-file-io.cjs +364 -0
  330. package/dist/sync/local-file-io.cjs.map +1 -0
  331. package/dist/sync/local-file-io.d.cts +75 -0
  332. package/dist/sync/local-file-io.d.cts.map +1 -0
  333. package/dist/sync/local-file-io.d.ts +75 -0
  334. package/dist/sync/local-file-io.d.ts.map +1 -0
  335. package/dist/sync/local-file-io.js +360 -0
  336. package/dist/sync/local-file-io.js.map +1 -0
  337. package/dist/sync/local-filesystem-root.cjs +27 -0
  338. package/dist/sync/local-filesystem-root.cjs.map +1 -0
  339. package/dist/sync/local-filesystem-root.d.cts +18 -0
  340. package/dist/sync/local-filesystem-root.d.cts.map +1 -0
  341. package/dist/sync/local-filesystem-root.d.ts +18 -0
  342. package/dist/sync/local-filesystem-root.d.ts.map +1 -0
  343. package/dist/sync/local-filesystem-root.js +26 -0
  344. package/dist/sync/local-filesystem-root.js.map +1 -0
  345. package/dist/sync/local-sha1.cjs +119 -0
  346. package/dist/sync/local-sha1.cjs.map +1 -0
  347. package/dist/sync/local-sha1.d.cts +39 -0
  348. package/dist/sync/local-sha1.d.cts.map +1 -0
  349. package/dist/sync/local-sha1.d.ts +39 -0
  350. package/dist/sync/local-sha1.d.ts.map +1 -0
  351. package/dist/sync/local-sha1.js +117 -0
  352. package/dist/sync/local-sha1.js.map +1 -0
  353. package/dist/sync/pairing.cjs +118 -29
  354. package/dist/sync/pairing.cjs.map +1 -1
  355. package/dist/sync/pairing.d.cts +7 -2
  356. package/dist/sync/pairing.d.cts.map +1 -1
  357. package/dist/sync/pairing.d.ts +7 -2
  358. package/dist/sync/pairing.d.ts.map +1 -1
  359. package/dist/sync/pairing.js +120 -31
  360. package/dist/sync/pairing.js.map +1 -1
  361. package/dist/sync/path-order.cjs +30 -0
  362. package/dist/sync/path-order.cjs.map +1 -0
  363. package/dist/sync/path-order.d.cts +28 -0
  364. package/dist/sync/path-order.d.cts.map +1 -0
  365. package/dist/sync/path-order.d.ts +28 -0
  366. package/dist/sync/path-order.d.ts.map +1 -0
  367. package/dist/sync/path-order.js +29 -0
  368. package/dist/sync/path-order.js.map +1 -0
  369. package/dist/sync/path-safety.cjs +111 -0
  370. package/dist/sync/path-safety.cjs.map +1 -0
  371. package/dist/sync/path-safety.d.cts +78 -0
  372. package/dist/sync/path-safety.d.cts.map +1 -0
  373. package/dist/sync/path-safety.d.ts +78 -0
  374. package/dist/sync/path-safety.d.ts.map +1 -0
  375. package/dist/sync/path-safety.js +105 -0
  376. package/dist/sync/path-safety.js.map +1 -0
  377. package/dist/sync/paths.d.cts +19 -0
  378. package/dist/sync/paths.d.cts.map +1 -0
  379. package/dist/sync/paths.d.ts +19 -0
  380. package/dist/sync/paths.d.ts.map +1 -0
  381. package/dist/sync/policies/compare.cjs +389 -11
  382. package/dist/sync/policies/compare.cjs.map +1 -1
  383. package/dist/sync/policies/compare.d.cts +100 -2
  384. package/dist/sync/policies/compare.d.cts.map +1 -1
  385. package/dist/sync/policies/compare.d.ts +100 -2
  386. package/dist/sync/policies/compare.d.ts.map +1 -1
  387. package/dist/sync/policies/compare.js +387 -13
  388. package/dist/sync/policies/compare.js.map +1 -1
  389. package/dist/sync/policies/index.cjs +76 -65
  390. package/dist/sync/policies/index.cjs.map +1 -1
  391. package/dist/sync/policies/index.d.cts +35 -6
  392. package/dist/sync/policies/index.d.cts.map +1 -1
  393. package/dist/sync/policies/index.d.ts +35 -6
  394. package/dist/sync/policies/index.d.ts.map +1 -1
  395. package/dist/sync/policies/index.js +76 -65
  396. package/dist/sync/policies/index.js.map +1 -1
  397. package/dist/sync/prefix.cjs +96 -0
  398. package/dist/sync/prefix.cjs.map +1 -0
  399. package/dist/sync/prefix.d.cts +55 -0
  400. package/dist/sync/prefix.d.cts.map +1 -0
  401. package/dist/sync/prefix.d.ts +55 -0
  402. package/dist/sync/prefix.d.ts.map +1 -0
  403. package/dist/sync/prefix.js +92 -0
  404. package/dist/sync/prefix.js.map +1 -0
  405. package/dist/sync/regexp-safety.cjs +192 -0
  406. package/dist/sync/regexp-safety.cjs.map +1 -0
  407. package/dist/sync/regexp-safety.d.cts +29 -0
  408. package/dist/sync/regexp-safety.d.cts.map +1 -0
  409. package/dist/sync/regexp-safety.d.ts +29 -0
  410. package/dist/sync/regexp-safety.d.ts.map +1 -0
  411. package/dist/sync/regexp-safety.js +190 -0
  412. package/dist/sync/regexp-safety.js.map +1 -0
  413. package/dist/sync/scan-events.cjs +33 -0
  414. package/dist/sync/scan-events.cjs.map +1 -0
  415. package/dist/sync/scan-events.d.cts +17 -0
  416. package/dist/sync/scan-events.d.cts.map +1 -0
  417. package/dist/sync/scan-events.d.ts +17 -0
  418. package/dist/sync/scan-events.d.ts.map +1 -0
  419. package/dist/sync/scan-events.js +32 -0
  420. package/dist/sync/scan-events.js.map +1 -0
  421. package/dist/sync/scan-limit.cjs +33 -0
  422. package/dist/sync/scan-limit.cjs.map +1 -0
  423. package/dist/sync/scan-limit.d.cts +21 -0
  424. package/dist/sync/scan-limit.d.cts.map +1 -0
  425. package/dist/sync/scan-limit.d.ts +21 -0
  426. package/dist/sync/scan-limit.d.ts.map +1 -0
  427. package/dist/sync/scan-limit.js +31 -0
  428. package/dist/sync/scan-limit.js.map +1 -0
  429. package/dist/sync/scanners/b2.cjs +239 -55
  430. package/dist/sync/scanners/b2.cjs.map +1 -1
  431. package/dist/sync/scanners/b2.d.cts +26 -7
  432. package/dist/sync/scanners/b2.d.cts.map +1 -1
  433. package/dist/sync/scanners/b2.d.ts +26 -7
  434. package/dist/sync/scanners/b2.d.ts.map +1 -1
  435. package/dist/sync/scanners/b2.js +239 -55
  436. package/dist/sync/scanners/b2.js.map +1 -1
  437. package/dist/sync/scanners/local.cjs +215 -56
  438. package/dist/sync/scanners/local.cjs.map +1 -1
  439. package/dist/sync/scanners/local.d.cts +22 -7
  440. package/dist/sync/scanners/local.d.cts.map +1 -1
  441. package/dist/sync/scanners/local.d.ts +22 -7
  442. package/dist/sync/scanners/local.d.ts.map +1 -1
  443. package/dist/sync/scanners/local.js +216 -57
  444. package/dist/sync/scanners/local.js.map +1 -1
  445. package/dist/sync/sha1-metadata.cjs +94 -0
  446. package/dist/sync/sha1-metadata.cjs.map +1 -0
  447. package/dist/sync/sha1-metadata.d.cts +82 -0
  448. package/dist/sync/sha1-metadata.d.cts.map +1 -0
  449. package/dist/sync/sha1-metadata.d.ts +82 -0
  450. package/dist/sync/sha1-metadata.d.ts.map +1 -0
  451. package/dist/sync/sha1-metadata.js +89 -0
  452. package/dist/sync/sha1-metadata.js.map +1 -0
  453. package/dist/sync/sha1-options.cjs +23 -0
  454. package/dist/sync/sha1-options.cjs.map +1 -0
  455. package/dist/sync/sha1-options.d.cts +14 -0
  456. package/dist/sync/sha1-options.d.cts.map +1 -0
  457. package/dist/sync/sha1-options.d.ts +14 -0
  458. package/dist/sync/sha1-options.d.ts.map +1 -0
  459. package/dist/sync/sha1-options.js +21 -0
  460. package/dist/sync/sha1-options.js.map +1 -0
  461. package/dist/sync/synchronizer.cjs +782 -197
  462. package/dist/sync/synchronizer.cjs.map +1 -1
  463. package/dist/sync/synchronizer.d.cts +47 -1
  464. package/dist/sync/synchronizer.d.cts.map +1 -1
  465. package/dist/sync/synchronizer.d.ts +47 -1
  466. package/dist/sync/synchronizer.d.ts.map +1 -1
  467. package/dist/sync/synchronizer.js +779 -173
  468. package/dist/sync/synchronizer.js.map +1 -1
  469. package/dist/sync/types.d.cts +208 -16
  470. package/dist/sync/types.d.cts.map +1 -1
  471. package/dist/sync/types.d.ts +208 -16
  472. package/dist/sync/types.d.ts.map +1 -1
  473. package/dist/types/auth.cjs +76 -56
  474. package/dist/types/auth.cjs.map +1 -1
  475. package/dist/types/auth.d.cts +67 -9
  476. package/dist/types/auth.d.cts.map +1 -1
  477. package/dist/types/auth.d.ts +67 -9
  478. package/dist/types/auth.d.ts.map +1 -1
  479. package/dist/types/auth.js +77 -57
  480. package/dist/types/auth.js.map +1 -1
  481. package/dist/types/bucket.cjs +74 -38
  482. package/dist/types/bucket.cjs.map +1 -1
  483. package/dist/types/bucket.js +75 -41
  484. package/dist/types/bucket.js.map +1 -1
  485. package/dist/types/encryption.cjs +364 -327
  486. package/dist/types/encryption.cjs.map +1 -1
  487. package/dist/types/encryption.d.cts +16 -0
  488. package/dist/types/encryption.d.cts.map +1 -1
  489. package/dist/types/encryption.d.ts +16 -0
  490. package/dist/types/encryption.d.ts.map +1 -1
  491. package/dist/types/encryption.js +364 -310
  492. package/dist/types/encryption.js.map +1 -1
  493. package/dist/types/errors.cjs +47 -0
  494. package/dist/types/errors.cjs.map +1 -0
  495. package/dist/types/errors.d.cts +13 -4
  496. package/dist/types/errors.d.cts.map +1 -1
  497. package/dist/types/errors.d.ts +13 -4
  498. package/dist/types/errors.d.ts.map +1 -1
  499. package/dist/types/errors.js +47 -0
  500. package/dist/types/errors.js.map +1 -0
  501. package/dist/types/file.cjs +36 -19
  502. package/dist/types/file.cjs.map +1 -1
  503. package/dist/types/file.d.cts +2 -2
  504. package/dist/types/file.d.cts.map +1 -1
  505. package/dist/types/file.d.ts +2 -2
  506. package/dist/types/file.d.ts.map +1 -1
  507. package/dist/types/file.js +37 -21
  508. package/dist/types/file.js.map +1 -1
  509. package/dist/types/ids.cjs +53 -9
  510. package/dist/types/ids.cjs.map +1 -1
  511. package/dist/types/ids.js +54 -15
  512. package/dist/types/ids.js.map +1 -1
  513. package/dist/types/index.d.cts +12 -11
  514. package/dist/types/index.d.cts.map +1 -1
  515. package/dist/types/index.d.ts +12 -11
  516. package/dist/types/index.d.ts.map +1 -1
  517. package/dist/types/key.d.cts +44 -8
  518. package/dist/types/key.d.cts.map +1 -1
  519. package/dist/types/key.d.ts +44 -8
  520. package/dist/types/key.d.ts.map +1 -1
  521. package/dist/types/lock.cjs +33 -13
  522. package/dist/types/lock.cjs.map +1 -1
  523. package/dist/types/lock.js +34 -15
  524. package/dist/types/lock.js.map +1 -1
  525. package/dist/types/notifications.cjs +44 -22
  526. package/dist/types/notifications.cjs.map +1 -1
  527. package/dist/types/notifications.js +45 -23
  528. package/dist/types/notifications.js.map +1 -1
  529. package/dist/types/upload.d.cts +39 -5
  530. package/dist/types/upload.d.cts.map +1 -1
  531. package/dist/types/upload.d.ts +39 -5
  532. package/dist/types/upload.d.ts.map +1 -1
  533. package/dist/upload/abort-scope.cjs +91 -0
  534. package/dist/upload/abort-scope.cjs.map +1 -0
  535. package/dist/upload/abort-scope.d.cts +48 -0
  536. package/dist/upload/abort-scope.d.cts.map +1 -0
  537. package/dist/upload/abort-scope.d.ts +48 -0
  538. package/dist/upload/abort-scope.d.ts.map +1 -0
  539. package/dist/upload/abort-scope.js +88 -0
  540. package/dist/upload/abort-scope.js.map +1 -0
  541. package/dist/upload/cancel.cjs +183 -8
  542. package/dist/upload/cancel.cjs.map +1 -1
  543. package/dist/upload/cancel.d.cts +110 -2
  544. package/dist/upload/cancel.d.cts.map +1 -1
  545. package/dist/upload/cancel.d.ts +110 -2
  546. package/dist/upload/cancel.d.ts.map +1 -1
  547. package/dist/upload/cancel.js +178 -9
  548. package/dist/upload/cancel.js.map +1 -1
  549. package/dist/upload/concurrency.cjs +79 -52
  550. package/dist/upload/concurrency.cjs.map +1 -1
  551. package/dist/upload/concurrency.js +79 -53
  552. package/dist/upload/concurrency.js.map +1 -1
  553. package/dist/upload/finish.cjs +59 -0
  554. package/dist/upload/finish.cjs.map +1 -0
  555. package/dist/upload/finish.d.cts +26 -0
  556. package/dist/upload/finish.d.cts.map +1 -0
  557. package/dist/upload/finish.d.ts +26 -0
  558. package/dist/upload/finish.d.ts.map +1 -0
  559. package/dist/upload/finish.js +59 -0
  560. package/dist/upload/finish.js.map +1 -0
  561. package/dist/upload/large.cjs +301 -218
  562. package/dist/upload/large.cjs.map +1 -1
  563. package/dist/upload/large.d.cts +76 -9
  564. package/dist/upload/large.d.cts.map +1 -1
  565. package/dist/upload/large.d.ts +76 -9
  566. package/dist/upload/large.d.ts.map +1 -1
  567. package/dist/upload/large.js +301 -218
  568. package/dist/upload/large.js.map +1 -1
  569. package/dist/upload/options.cjs +28 -0
  570. package/dist/upload/options.cjs.map +1 -0
  571. package/dist/upload/options.d.cts +104 -0
  572. package/dist/upload/options.d.cts.map +1 -0
  573. package/dist/upload/options.d.ts +104 -0
  574. package/dist/upload/options.d.ts.map +1 -0
  575. package/dist/upload/options.js +27 -0
  576. package/dist/upload/options.js.map +1 -0
  577. package/dist/upload/resume.cjs +333 -33
  578. package/dist/upload/resume.cjs.map +1 -1
  579. package/dist/upload/resume.d.cts +82 -12
  580. package/dist/upload/resume.d.cts.map +1 -1
  581. package/dist/upload/resume.d.ts +82 -12
  582. package/dist/upload/resume.d.ts.map +1 -1
  583. package/dist/upload/resume.js +330 -33
  584. package/dist/upload/resume.js.map +1 -1
  585. package/dist/upload/retry.cjs +186 -0
  586. package/dist/upload/retry.cjs.map +1 -0
  587. package/dist/upload/retry.d.cts +127 -0
  588. package/dist/upload/retry.d.cts.map +1 -0
  589. package/dist/upload/retry.d.ts +127 -0
  590. package/dist/upload/retry.d.ts.map +1 -0
  591. package/dist/upload/retry.js +182 -0
  592. package/dist/upload/retry.js.map +1 -0
  593. package/dist/upload/single.cjs +68 -44
  594. package/dist/upload/single.cjs.map +1 -1
  595. package/dist/upload/single.d.cts +2 -1
  596. package/dist/upload/single.d.cts.map +1 -1
  597. package/dist/upload/single.d.ts +2 -1
  598. package/dist/upload/single.d.ts.map +1 -1
  599. package/dist/upload/single.js +68 -44
  600. package/dist/upload/single.js.map +1 -1
  601. package/dist/upload/stream.cjs +317 -193
  602. package/dist/upload/stream.cjs.map +1 -1
  603. package/dist/upload/stream.d.cts +3 -1
  604. package/dist/upload/stream.d.cts.map +1 -1
  605. package/dist/upload/stream.d.ts +3 -1
  606. package/dist/upload/stream.d.ts.map +1 -1
  607. package/dist/upload/stream.js +316 -192
  608. package/dist/upload/stream.js.map +1 -1
  609. package/dist/util/best-effort.cjs +42 -8
  610. package/dist/util/best-effort.cjs.map +1 -1
  611. package/dist/util/best-effort.d.cts +2 -1
  612. package/dist/util/best-effort.d.cts.map +1 -1
  613. package/dist/util/best-effort.d.ts +2 -1
  614. package/dist/util/best-effort.d.ts.map +1 -1
  615. package/dist/util/best-effort.js +43 -9
  616. package/dist/util/best-effort.js.map +1 -1
  617. package/dist/util/bytes.cjs +23 -0
  618. package/dist/util/bytes.cjs.map +1 -0
  619. package/dist/util/bytes.d.cts +15 -0
  620. package/dist/util/bytes.d.cts.map +1 -0
  621. package/dist/util/bytes.d.ts +15 -0
  622. package/dist/util/bytes.d.ts.map +1 -0
  623. package/dist/util/bytes.js +23 -0
  624. package/dist/util/bytes.js.map +1 -0
  625. package/dist/util/crypto.cjs +68 -0
  626. package/dist/util/crypto.cjs.map +1 -0
  627. package/dist/util/crypto.d.cts +26 -0
  628. package/dist/util/crypto.d.cts.map +1 -0
  629. package/dist/util/crypto.d.ts +26 -0
  630. package/dist/util/crypto.d.ts.map +1 -0
  631. package/dist/util/crypto.js +66 -0
  632. package/dist/util/crypto.js.map +1 -0
  633. package/dist/util/defaults.cjs +25 -9
  634. package/dist/util/defaults.cjs.map +1 -1
  635. package/dist/util/defaults.js +26 -11
  636. package/dist/util/defaults.js.map +1 -1
  637. package/dist/util/error-reason.cjs +41 -0
  638. package/dist/util/error-reason.cjs.map +1 -0
  639. package/dist/util/error-reason.d.cts +9 -0
  640. package/dist/util/error-reason.d.cts.map +1 -0
  641. package/dist/util/error-reason.d.ts +9 -0
  642. package/dist/util/error-reason.d.ts.map +1 -0
  643. package/dist/util/error-reason.js +41 -0
  644. package/dist/util/error-reason.js.map +1 -0
  645. package/dist/util/http.cjs +23 -0
  646. package/dist/util/http.cjs.map +1 -0
  647. package/dist/util/http.d.cts +13 -0
  648. package/dist/util/http.d.cts.map +1 -0
  649. package/dist/util/http.d.ts +13 -0
  650. package/dist/util/http.d.ts.map +1 -0
  651. package/dist/util/http.js +23 -0
  652. package/dist/util/http.js.map +1 -0
  653. package/dist/util/normalize.cjs +66 -7
  654. package/dist/util/normalize.cjs.map +1 -1
  655. package/dist/util/normalize.js +67 -10
  656. package/dist/util/normalize.js.map +1 -1
  657. package/dist/util/paginator.cjs +63 -14
  658. package/dist/util/paginator.cjs.map +1 -1
  659. package/dist/util/paginator.js +64 -16
  660. package/dist/util/paginator.js.map +1 -1
  661. package/dist/util/plan-ranges.cjs +47 -22
  662. package/dist/util/plan-ranges.cjs.map +1 -1
  663. package/dist/util/plan-ranges.js +48 -24
  664. package/dist/util/plan-ranges.js.map +1 -1
  665. package/dist/util/sha1.cjs +27 -0
  666. package/dist/util/sha1.cjs.map +1 -0
  667. package/dist/util/sha1.d.cts +17 -0
  668. package/dist/util/sha1.d.cts.map +1 -0
  669. package/dist/util/sha1.d.ts +17 -0
  670. package/dist/util/sha1.d.ts.map +1 -0
  671. package/dist/util/sha1.js +26 -0
  672. package/dist/util/sha1.js.map +1 -0
  673. package/dist/util/text-codec.cjs +29 -5
  674. package/dist/util/text-codec.cjs.map +1 -1
  675. package/dist/util/text-codec.js +30 -7
  676. package/dist/util/text-codec.js.map +1 -1
  677. package/dist/util/to-error.cjs +18 -4
  678. package/dist/util/to-error.cjs.map +1 -1
  679. package/dist/util/to-error.js +19 -5
  680. package/dist/util/to-error.js.map +1 -1
  681. package/dist/version.cjs +17 -5
  682. package/dist/version.cjs.map +1 -1
  683. package/dist/version.d.cts +3 -3
  684. package/dist/version.d.ts +3 -3
  685. package/dist/version.js +19 -6
  686. package/dist/version.js.map +1 -1
  687. package/package.json +19 -16
  688. package/dist/auth/index.cjs.map +0 -1
  689. package/dist/auth/index.js.map +0 -1
  690. package/dist/index.cjs.map +0 -1
  691. package/dist/index.js.map +0 -1
  692. package/dist/notifications/index.cjs.map +0 -1
  693. package/dist/notifications/index.js.map +0 -1
  694. package/dist/package.json.cjs +0 -9
  695. package/dist/package.json.cjs.map +0 -1
  696. package/dist/package.json.js +0 -9
  697. package/dist/package.json.js.map +0 -1
  698. package/dist/streams/index.cjs.map +0 -1
  699. package/dist/streams/index.js.map +0 -1
  700. package/dist/sync/index.cjs.map +0 -1
  701. package/dist/sync/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sources":["../../src/auth/file.ts"],"sourcesContent":["import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport type { AuthorizeAccountResponse } from '../types/auth.ts'\nimport type { BucketId } from '../types/ids.ts'\nimport type { AccountInfo, UploadUrlEntry } from './account-info.ts'\nimport { InMemoryAccountInfo } from './in-memory.ts'\n\n/**\n * Node-only {@link AccountInfo} backend that persists the authorization\n * response to a JSON file. Upload URL pools remain in memory because URLs are\n * short-lived and shouldn't be shared across processes.\n *\n * On instantiation, call {@link FileAccountInfo.load} to populate state from\n * disk (or start fresh if the file is missing or corrupt). The authorization\n * response is written back to disk on every {@link setAuth} or {@link clear}\n * call so a process restart can resume without re-authorizing.\n *\n * This module imports `node:fs/promises`; do not load it in browser bundles.\n */\nexport class FileAccountInfo implements AccountInfo {\n private readonly inner = new InMemoryAccountInfo()\n private writeQueue: Promise<void> = Promise.resolve()\n\n /**\n * Constructs a `FileAccountInfo` bound to a JSON file on disk. The file is\n * created on the first `setAuth` write; reading it back happens via\n * {@link load}.\n *\n * @param path - Absolute path to the JSON file that backs this account info.\n */\n constructor(public readonly path: string) {}\n\n /**\n * Reads the JSON file at the configured path and populates in-memory state.\n * If the file is missing or contains invalid JSON, leaves state empty and\n * returns silently (a re-auth is expected next).\n *\n * @returns A promise that resolves when load is complete.\n */\n async load(): Promise<void> {\n try {\n const text = await readFile(this.path, 'utf8')\n const parsed = JSON.parse(text) as AuthorizeAccountResponse\n this.inner.setAuth(parsed)\n } catch {\n // Missing file, invalid JSON, or permission denied: start empty.\n }\n }\n\n /**\n * Persists the current auth response to the file. Atomically queues writes\n * so concurrent updates serialize.\n *\n * @returns A promise that resolves when the write completes.\n */\n private flush(): Promise<void> {\n const auth = this.inner.getAuth()\n const next = this.writeQueue.then(async () => {\n if (auth === null) {\n try {\n await writeFile(this.path, '', 'utf8')\n } catch {\n // Best-effort\n }\n return\n }\n await mkdir(dirname(this.path), { recursive: true })\n await writeFile(this.path, JSON.stringify(auth), 'utf8')\n })\n this.writeQueue = next.catch(() => {})\n return next\n }\n\n /**\n * Stores the given authorization response and triggers an async write to disk.\n *\n * @param auth - The authorize-account response to persist.\n */\n setAuth(auth: AuthorizeAccountResponse): void {\n this.inner.setAuth(auth)\n void this.flush()\n }\n\n /**\n * Returns the currently cached authorization response, or `null` if none.\n *\n * @returns The cached authorization response, or `null` if not authorized.\n */\n getAuth(): AuthorizeAccountResponse | null {\n return this.inner.getAuth()\n }\n\n /** Discards in-memory state and clears the on-disk file. */\n clear(): void {\n this.inner.clear()\n void this.flush()\n }\n\n /**\n * Returns the cached B2 API URL.\n *\n * @returns The base URL for B2 API calls.\n */\n getApiUrl(): string {\n return this.inner.getApiUrl()\n }\n\n /**\n * Returns the cached file-download URL.\n *\n * @returns The base URL for file downloads.\n */\n getDownloadUrl(): string {\n return this.inner.getDownloadUrl()\n }\n\n /**\n * Returns the cached session authorization token.\n *\n * @returns The current authorization token.\n */\n getAuthToken(): string {\n return this.inner.getAuthToken()\n }\n\n /**\n * Returns the cached account identifier.\n *\n * @returns The authorized account ID.\n */\n getAccountId(): string {\n return this.inner.getAccountId()\n }\n\n /**\n * Returns the server-recommended part size for multipart uploads.\n *\n * @returns The recommended part size in bytes.\n */\n getRecommendedPartSize(): number {\n return this.inner.getRecommendedPartSize()\n }\n\n /**\n * Returns the server-enforced minimum part size for multipart uploads.\n *\n * @returns The absolute minimum part size in bytes.\n */\n getAbsoluteMinimumPartSize(): number {\n return this.inner.getAbsoluteMinimumPartSize()\n }\n\n /**\n * Returns the cached S3-compatible API URL.\n *\n * @returns The base URL for the S3-compatible API.\n */\n getS3ApiUrl(): string {\n return this.inner.getS3ApiUrl()\n }\n\n /**\n * Returns the bucket the key is restricted to, if any.\n *\n * @returns The restricted bucket ID, or `null` if the key is unrestricted.\n */\n getAllowedBucketId(): BucketId | null {\n return this.inner.getAllowedBucketId()\n }\n\n /**\n * Takes an upload URL from the in-memory pool for the given bucket.\n *\n * @param bucketId - Bucket to check out an upload URL for.\n *\n * @returns A reusable upload URL entry, or `null` if none are pooled.\n */\n checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null {\n return this.inner.checkoutUploadUrl(bucketId)\n }\n\n /**\n * Returns a still-valid upload URL to the pool for reuse.\n *\n * @param bucketId - Bucket the upload URL belongs to.\n * @param entry - Upload URL entry to return.\n */\n returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.inner.returnUploadUrl(bucketId, entry)\n }\n\n /**\n * Removes an upload URL from the pool after an upload error.\n *\n * @param bucketId - Bucket the failed upload URL belongs to.\n * @param entry - Upload URL entry to evict.\n */\n evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.inner.evictUploadUrl(bucketId, entry)\n }\n\n /**\n * Takes a large-file part upload URL from the in-memory pool.\n *\n * @param fileId - Large file to check out a part upload URL for.\n *\n * @returns A reusable part upload URL entry, or `null` if none are pooled.\n */\n checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null {\n return this.inner.checkoutPartUploadUrl(fileId)\n }\n\n /**\n * Returns a still-valid part upload URL to the pool for reuse.\n *\n * @param fileId - Large file the part upload URL belongs to.\n * @param entry - Part upload URL entry to return.\n */\n returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.inner.returnPartUploadUrl(fileId, entry)\n }\n\n /**\n * Removes a part upload URL from the pool after an error.\n *\n * @param fileId - Large file the failed part upload URL belongs to.\n * @param entry - Part upload URL entry to evict.\n */\n evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.inner.evictPartUploadUrl(fileId, entry)\n }\n\n /**\n * Awaits any pending disk writes. Call before process exit to ensure the\n * latest state is persisted.\n *\n * @returns A promise that resolves once all queued writes are flushed.\n */\n async flushed(): Promise<void> {\n await this.writeQueue\n }\n}\n"],"names":[],"mappings":";;;AAmBO,MAAM,gBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,YAA4B,MAAc;AAAd,SAAA,OAAA;AAAA,EAAe;AAAA,EAV1B,QA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QA,mBAAmB,QAAgB,OAA6B;AAC9D,SAAK,MAAM,mBAAmB,QAAQ,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAyB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;"}
1
+ {"version":3,"file":"file.js","names":[],"sources":["../../src/auth/file.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\nimport { chmod, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'\nimport { basename, dirname, join } from 'node:path'\nimport type { AuthorizeAccountResponse } from '../types/auth.ts'\nimport type { BucketId } from '../types/ids.ts'\nimport type { AccountInfo, AuthContextAwareAccountInfo, UploadUrlEntry } from './account-info.ts'\nimport { InMemoryAccountInfo } from './in-memory.ts'\nimport { getRealmUrl } from './realms.ts'\n\nconst PRIVATE_FILE_MODE = 0o600\nconst PERSISTED_AUTH_VERSION = 1\nconst BUILT_IN_PRODUCTION_REALM_URL = getRealmUrl('production')\nconst BUILT_IN_STAGING_REALM_URL = getRealmUrl('staging')\nconst PRODUCTION_HOST_SUFFIX = 'backblazeb2.com'\nconst STAGING_HOST_SUFFIX = 'backblaze.net'\n\ninterface PersistedAuthState {\n readonly _b2sdk?: {\n readonly version?: number\n readonly realmUrl?: string\n readonly applicationKeyId?: string\n }\n}\n\n/** Reason a loaded auth cache entry was ignored for the current client. */\nexport type FileAccountInfoDiscardReason =\n | 'realm_mismatch'\n | 'application_key_mismatch'\n | 'endpoint_mismatch'\n\n/** Event emitted when a loaded cache entry is ignored without modifying disk. */\nexport interface FileAccountInfoDiscardEvent {\n /** Absolute path of the auth cache file. */\n readonly path: string\n /** Why the loaded auth entry could not be reused. */\n readonly reason: FileAccountInfoDiscardReason\n /** Realm URL stored in the cache metadata, or null for legacy entries. */\n readonly cachedRealmUrl: string | null | undefined\n /** Realm URL configured on the current client, if already bound. */\n readonly expectedRealmUrl: string | undefined\n /** Application key ID stored in cache metadata, or null for legacy entries. */\n readonly cachedApplicationKeyId: string | null | undefined\n /** Application key ID configured on the current client, if already bound. */\n readonly expectedApplicationKeyId: string | undefined\n}\n\n/** Event emitted when an asynchronous auth-cache write fails. */\nexport interface FileAccountInfoWriteErrorEvent {\n /** Absolute path of the auth cache file. */\n readonly path: string\n /** Underlying filesystem or serialization error. */\n readonly error: unknown\n}\n\n/** Optional observers for file-backed auth cache behavior. */\nexport interface FileAccountInfoOptions {\n /**\n * Called when loaded auth is ignored because its metadata or cached\n * endpoints are unsafe for this client. The on-disk file is left untouched\n * so another process using a different realm/key is not clobbered.\n */\n readonly onDiscard?: (event: FileAccountInfoDiscardEvent) => void\n /** Called when an asynchronous auth-cache write fails. */\n readonly onWriteError?: (event: FileAccountInfoWriteErrorEvent) => void\n}\n\nfunction readPersistedAuthState(value: unknown): {\n auth: AuthorizeAccountResponse\n realmUrl: string | null\n applicationKeyId: string | null\n} | null {\n if (value === null || typeof value !== 'object') return null\n\n const maybeState = value as PersistedAuthState\n if (\n maybeState._b2sdk?.version !== undefined &&\n maybeState._b2sdk.version !== PERSISTED_AUTH_VERSION\n ) {\n return null\n }\n const realmUrl =\n maybeState._b2sdk !== undefined && typeof maybeState._b2sdk.realmUrl === 'string'\n ? maybeState._b2sdk.realmUrl\n : null\n const applicationKeyId =\n maybeState._b2sdk !== undefined && typeof maybeState._b2sdk.applicationKeyId === 'string'\n ? maybeState._b2sdk.applicationKeyId\n : null\n return { auth: value as AuthorizeAccountResponse, realmUrl, applicationKeyId }\n}\n\nfunction isProductionBackblazeEndpoint(url: string): boolean {\n try {\n const parsed = new URL(url)\n return parsed.protocol === 'https:' && hasHostSuffix(parsed.hostname, PRODUCTION_HOST_SUFFIX)\n } catch {\n return false\n }\n}\n\nfunction isProductionAuthResponse(auth: AuthorizeAccountResponse): boolean {\n try {\n const storageApi = auth.apiInfo.storageApi\n return [storageApi.apiUrl, storageApi.downloadUrl, storageApi.s3ApiUrl].every(\n isProductionBackblazeEndpoint,\n )\n } catch {\n return false\n }\n}\n\nfunction verifiedRealmEndpointSuffix(realmUrl: string): string | null {\n try {\n const realm = new URL(realmUrl)\n if (realm.origin === new URL(BUILT_IN_PRODUCTION_REALM_URL).origin) {\n return PRODUCTION_HOST_SUFFIX\n }\n if (realm.origin === new URL(BUILT_IN_STAGING_REALM_URL).origin) {\n return STAGING_HOST_SUFFIX\n }\n } catch {\n // Fall through below.\n }\n return null\n}\n\nfunction hasHostSuffix(hostname: string, suffix: string): boolean {\n const host = hostname.toLowerCase()\n const lowered = suffix.toLowerCase()\n return host === lowered || host.endsWith(`.${lowered}`)\n}\n\nfunction isEndpointInRealm(url: string, realmUrl: string): boolean {\n try {\n const realm = new URL(realmUrl)\n const endpoint = new URL(url)\n const endpointHost = endpoint.hostname.toLowerCase()\n const realmHost = realm.hostname.toLowerCase()\n if (isLoopbackEndpointHost(endpointHost) || isLoopbackEndpointHost(realmHost)) {\n return endpoint.origin === realm.origin\n }\n\n const verifiedSuffix = verifiedRealmEndpointSuffix(realmUrl)\n if (verifiedSuffix !== null) {\n return endpoint.protocol === 'https:' && hasHostSuffix(endpointHost, verifiedSuffix)\n }\n\n return endpoint.protocol === realm.protocol && hasHostSuffix(endpointHost, realmHost)\n } catch {\n return false\n }\n}\n\nfunction isLoopbackEndpointHost(host: string): boolean {\n if (host === 'localhost' || host === '::1' || host === '[::1]') return true\n\n const parts = host.split('.')\n return (\n parts.length === 4 &&\n parts[0] === '127' &&\n parts.every((part) => /^\\d+$/.test(part) && Number(part) <= 255)\n )\n}\n\nfunction authEndpointsMatchRealm(auth: AuthorizeAccountResponse, realmUrl: string): boolean {\n try {\n const storageApi = auth.apiInfo.storageApi\n return [storageApi.apiUrl, storageApi.downloadUrl, storageApi.s3ApiUrl].every((url) =>\n isEndpointInRealm(url, realmUrl),\n )\n } catch {\n return false\n }\n}\n\n/**\n * Node-only {@link AccountInfo} backend that persists the authorization\n * response to a JSON file. Upload URL pools remain in memory because URLs are\n * short-lived and shouldn't be shared across processes.\n * The JSON file contains a live B2 authorization token, so treat it as\n * sensitive and keep it out of shared or world-readable locations.\n * `FileAccountInfo` serializes writes within one process but does not provide\n * inter-process locking. If multiple processes share one path, use\n * {@link FileAccountInfoOptions.onDiscard} and {@link FileAccountInfoOptions.onWriteError}\n * to observe cache churn, or prefer one cache path per resolved realm and key.\n *\n * On instantiation, call {@link FileAccountInfo.load} to populate state from\n * disk (or start fresh if the file is missing or corrupt). The authorization\n * response is written back to disk on every {@link setAuth} or {@link clear}\n * call so a process restart can resume without re-authorizing.\n * Cache files without an SDK metadata application-key binding are ignored once\n * bound to a `B2Client`, because the SDK cannot verify which key wrote them.\n *\n * This module imports `node:fs/promises`; do not load it in browser bundles.\n */\nexport class FileAccountInfo implements AccountInfo, AuthContextAwareAccountInfo {\n private readonly inner = new InMemoryAccountInfo()\n private writeQueue: Promise<void> = Promise.resolve()\n private realmUrl: string | undefined\n private loadedAuthRealmUrl: string | null | undefined\n private applicationKeyId: string | undefined\n private loadedAuthApplicationKeyId: string | null | undefined\n\n /**\n * Constructs a `FileAccountInfo` bound to a JSON file on disk. The file is\n * created on the first `setAuth` write; reading it back happens via\n * {@link load}.\n *\n * @param path - Absolute path to the JSON file that backs this account info.\n * @param options - Optional discard and write-error observers.\n */\n constructor(\n public readonly path: string,\n private readonly options: FileAccountInfoOptions = {},\n ) {}\n\n /**\n * Reads the JSON file at the configured path and populates in-memory state.\n * If the file is missing or contains invalid JSON, leaves state empty and\n * returns silently (a re-auth is expected next).\n *\n * @returns A promise that resolves when load is complete.\n */\n async load(): Promise<void> {\n try {\n const text = await readFile(this.path, 'utf8')\n const parsed = readPersistedAuthState(JSON.parse(text) as unknown)\n if (parsed === null) return\n this.inner.setAuth(parsed.auth)\n this.loadedAuthRealmUrl = parsed.realmUrl\n this.loadedAuthApplicationKeyId = parsed.applicationKeyId\n this.discardMismatchedAuth()\n } catch {\n // Missing file, invalid JSON, or permission denied: start empty.\n }\n }\n\n /**\n * Binds this cache to the configured realm URL. `B2Client` calls this when a\n * FileAccountInfo instance is supplied, so stale auth produced by another\n * realm is discarded before it can be used.\n *\n * @param realmUrl - Resolved authorize-account realm URL for the client.\n */\n setRealmUrl(realmUrl: string): void {\n this.realmUrl = realmUrl\n this.discardMismatchedAuth()\n }\n\n /**\n * Binds this cache to the configured application key ID. `B2Client` calls\n * this when a FileAccountInfo instance is supplied, so stale auth produced by\n * another key is discarded before it can be used.\n *\n * @param applicationKeyId - Application key ID configured on the client.\n */\n setApplicationKeyId(applicationKeyId: string): void {\n this.applicationKeyId = applicationKeyId\n this.discardMismatchedAuth()\n }\n\n private discardMismatchedAuth(): void {\n const auth = this.inner.getAuth()\n if (auth === null) return\n\n const reason = this.mismatchReason(auth)\n if (reason === null) return\n\n this.inner.clear()\n this.options.onDiscard?.({\n path: this.path,\n reason,\n cachedRealmUrl: this.loadedAuthRealmUrl,\n expectedRealmUrl: this.realmUrl,\n cachedApplicationKeyId: this.loadedAuthApplicationKeyId,\n expectedApplicationKeyId: this.applicationKeyId,\n })\n this.loadedAuthRealmUrl = undefined\n this.loadedAuthApplicationKeyId = undefined\n }\n\n private mismatchReason(auth: AuthorizeAccountResponse): FileAccountInfoDiscardReason | null {\n const realmMatches =\n this.realmUrl === undefined ||\n this.loadedAuthRealmUrl === this.realmUrl ||\n (this.loadedAuthRealmUrl === null &&\n this.realmUrl === BUILT_IN_PRODUCTION_REALM_URL &&\n isProductionAuthResponse(auth))\n const applicationKeyMatches =\n this.applicationKeyId === undefined ||\n this.loadedAuthApplicationKeyId === this.applicationKeyId\n if (!realmMatches) return 'realm_mismatch'\n if (!applicationKeyMatches) return 'application_key_mismatch'\n if (this.realmUrl !== undefined && !authEndpointsMatchRealm(auth, this.realmUrl)) {\n return 'endpoint_mismatch'\n }\n\n return null\n }\n\n /**\n * Persists the current auth response to the file. Atomically queues writes\n * so concurrent updates serialize.\n *\n * @returns A promise that resolves when the write completes.\n */\n private flush(): Promise<void> {\n const auth = this.inner.getAuth()\n const next = this.writeQueue.then(async () => {\n if (auth === null) {\n try {\n await this.writePrivateFileAtomically('')\n } catch {\n // Best-effort\n }\n return\n }\n const contents =\n this.realmUrl !== undefined\n ? JSON.stringify({\n ...auth,\n _b2sdk: {\n version: PERSISTED_AUTH_VERSION,\n realmUrl: this.realmUrl,\n ...(this.applicationKeyId !== undefined\n ? { applicationKeyId: this.applicationKeyId }\n : {}),\n },\n })\n : JSON.stringify(auth)\n await this.writePrivateFileAtomically(contents)\n })\n this.writeQueue = next.catch((error: unknown) => {\n this.options.onWriteError?.({ path: this.path, error })\n })\n return next\n }\n\n private async writePrivateFileAtomically(contents: string): Promise<void> {\n const dir = dirname(this.path)\n const tempPath = join(dir, `.${basename(this.path)}.${process.pid}.${randomUUID()}.tmp`)\n await mkdir(dir, { recursive: true })\n\n try {\n await writeFile(tempPath, contents, { encoding: 'utf8', mode: PRIVATE_FILE_MODE })\n await chmod(tempPath, PRIVATE_FILE_MODE)\n await rename(tempPath, this.path)\n await chmod(this.path, PRIVATE_FILE_MODE)\n } catch (error) {\n await rm(tempPath, { force: true }).catch(() => {})\n throw error\n }\n }\n\n /**\n * Stores the given authorization response and triggers an async write to disk.\n *\n * @param auth - The authorize-account response to persist.\n */\n setAuth(auth: AuthorizeAccountResponse): void {\n this.inner.setAuth(auth)\n this.loadedAuthRealmUrl = this.realmUrl ?? null\n this.loadedAuthApplicationKeyId = this.applicationKeyId ?? null\n void this.flush()\n }\n\n /**\n * Returns the currently cached authorization response, or `null` if none.\n *\n * @returns The cached authorization response, or `null` if not authorized.\n */\n getAuth(): AuthorizeAccountResponse | null {\n return this.inner.getAuth()\n }\n\n /** Discards in-memory state and clears the on-disk file. */\n clear(): void {\n this.inner.clear()\n this.loadedAuthRealmUrl = undefined\n this.loadedAuthApplicationKeyId = undefined\n void this.flush()\n }\n\n /**\n * Returns the cached B2 API URL.\n *\n * @returns The base URL for B2 API calls.\n */\n getApiUrl(): string {\n return this.inner.getApiUrl()\n }\n\n /**\n * Returns the cached file-download URL.\n *\n * @returns The base URL for file downloads.\n */\n getDownloadUrl(): string {\n return this.inner.getDownloadUrl()\n }\n\n /**\n * Returns the cached session authorization token.\n *\n * @returns The current authorization token.\n */\n getAuthToken(): string {\n return this.inner.getAuthToken()\n }\n\n /**\n * Returns the cached account identifier.\n *\n * @returns The authorized account ID.\n */\n getAccountId(): string {\n return this.inner.getAccountId()\n }\n\n /**\n * Returns the server-recommended part size for multipart uploads.\n *\n * @returns The recommended part size in bytes.\n */\n getRecommendedPartSize(): number {\n return this.inner.getRecommendedPartSize()\n }\n\n /**\n * Returns the server-enforced minimum part size for multipart uploads.\n *\n * @returns The absolute minimum part size in bytes.\n */\n getAbsoluteMinimumPartSize(): number {\n return this.inner.getAbsoluteMinimumPartSize()\n }\n\n /**\n * Returns the cached S3-compatible API URL.\n *\n * @returns The base URL for the S3-compatible API.\n */\n getS3ApiUrl(): string {\n return this.inner.getS3ApiUrl()\n }\n\n /**\n * Returns the bucket the key is restricted to, if any.\n *\n * @returns The restricted bucket ID, or `null` if the key is unrestricted.\n */\n getAllowedBucketId(): BucketId | null {\n return this.inner.getAllowedBucketId()\n }\n\n /**\n * Returns the buckets the key is restricted to, if any.\n *\n * @returns The restricted bucket IDs, or `null` if the key is unrestricted.\n */\n getAllowedBucketIds(): readonly BucketId[] | null {\n return this.inner.getAllowedBucketIds()\n }\n\n /**\n * Takes an upload URL from the in-memory pool for the given bucket.\n *\n * @param bucketId - Bucket to check out an upload URL for.\n *\n * @returns A reusable upload URL entry, or `null` if none are pooled.\n */\n checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null {\n return this.inner.checkoutUploadUrl(bucketId)\n }\n\n /**\n * Returns a still-valid upload URL to the pool for reuse.\n *\n * @param bucketId - Bucket the upload URL belongs to.\n * @param entry - Upload URL entry to return.\n */\n returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.inner.returnUploadUrl(bucketId, entry)\n }\n\n /**\n * Removes an upload URL from the pool after an upload error.\n *\n * @param bucketId - Bucket the failed upload URL belongs to.\n * @param entry - Upload URL entry to evict.\n */\n evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.inner.evictUploadUrl(bucketId, entry)\n }\n\n /**\n * Takes a large-file part upload URL from the in-memory pool.\n *\n * @param fileId - Large file to check out a part upload URL for.\n *\n * @returns A reusable part upload URL entry, or `null` if none are pooled.\n */\n checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null {\n return this.inner.checkoutPartUploadUrl(fileId)\n }\n\n /**\n * Returns a still-valid part upload URL to the pool for reuse.\n *\n * @param fileId - Large file the part upload URL belongs to.\n * @param entry - Part upload URL entry to return.\n */\n returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.inner.returnPartUploadUrl(fileId, entry)\n }\n\n /**\n * Removes a part upload URL from the pool after an error.\n *\n * @param fileId - Large file the failed part upload URL belongs to.\n * @param entry - Part upload URL entry to evict.\n */\n evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.inner.evictPartUploadUrl(fileId, entry)\n }\n\n /**\n * Awaits any pending disk writes. Call before process exit to ensure the\n * latest state is persisted.\n *\n * @returns A promise that resolves once all queued writes are flushed.\n */\n async flushed(): Promise<void> {\n await this.writeQueue\n }\n}\n"],"mappings":";;;;;;AASA,IAAM,oBAAoB;AAC1B,IAAM,yBAAyB;AAC/B,IAAM,gCAAgC,YAAY,YAAY;AAC9D,IAAM,6BAA6B,YAAY,SAAS;AACxD,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB;AAoD5B,SAAS,uBAAuB,OAIvB;CACP,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CAExD,MAAM,aAAa;CACnB,IACE,WAAW,QAAQ,YAAY,KAAA,KAC/B,WAAW,OAAO,YAAY,wBAE9B,OAAO;CAUT,OAAO;EAAE,MAAM;EAAmC,UAPhD,WAAW,WAAW,KAAA,KAAa,OAAO,WAAW,OAAO,aAAa,WACrE,WAAW,OAAO,WAClB;EAKsD,kBAH1D,WAAW,WAAW,KAAA,KAAa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,MAAM,2BAA2B;CAC/C;;;;;;CAOA,cAAsB;EACpB,OAAO,KAAK,MAAM,YAAY;CAChC;;;;;;CAOA,qBAAsC;EACpC,OAAO,KAAK,MAAM,mBAAmB;CACvC;;;;;;CAOA,sBAAkD;EAChD,OAAO,KAAK,MAAM,oBAAoB;CACxC;;;;;;;;CASA,kBAAkB,UAA2C;EAC3D,OAAO,KAAK,MAAM,kBAAkB,QAAQ;CAC9C;;;;;;;CAQA,gBAAgB,UAAoB,OAA6B;EAC/D,KAAK,MAAM,gBAAgB,UAAU,KAAK;CAC5C;;;;;;;CAQA,eAAe,UAAoB,OAA6B;EAC9D,KAAK,MAAM,eAAe,UAAU,KAAK;CAC3C;;;;;;;;CASA,sBAAsB,QAAuC;EAC3D,OAAO,KAAK,MAAM,sBAAsB,MAAM;CAChD;;;;;;;CAQA,oBAAoB,QAAgB,OAA6B;EAC/D,KAAK,MAAM,oBAAoB,QAAQ,KAAK;CAC9C;;;;;;;CAQA,mBAAmB,QAAgB,OAA6B;EAC9D,KAAK,MAAM,mBAAmB,QAAQ,KAAK;CAC7C;;;;;;;CAQA,MAAM,UAAyB;EAC7B,MAAM,KAAK;CACb;AACF"}
@@ -1,184 +1,213 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const uploadUrlPool = require("./upload-url-pool.cjs");
4
- class InMemoryAccountInfo {
5
- /** Cached authorization response, or null before authorize() is called. */
6
- auth = null;
7
- /** Pool of reusable small-file upload URLs, keyed by bucket ID. */
8
- uploadUrls = new uploadUrlPool.UploadUrlPool();
9
- /** Pool of reusable large-file part upload URLs, keyed by file ID. */
10
- partUploadUrls = new uploadUrlPool.UploadUrlPool();
11
- /**
12
- * Store a fresh authorization response, replacing any previous state.
13
- *
14
- * @param auth - The authorize account response to store.
15
- */
16
- setAuth(auth) {
17
- this.auth = auth;
18
- this.uploadUrls.clear();
19
- this.partUploadUrls.clear();
20
- }
21
- /**
22
- * Return the current authorization response, or null if not authorized.
23
- *
24
- * @returns The cached authorization response, or null if not yet authorized.
25
- */
26
- getAuth() {
27
- return this.auth;
28
- }
29
- /** Discard all cached authorization state and upload URLs. */
30
- clear() {
31
- this.auth = null;
32
- this.uploadUrls.clear();
33
- this.partUploadUrls.clear();
34
- }
35
- /**
36
- * Base URL for B2 API calls.
37
- *
38
- * @returns The base URL for B2 API calls.
39
- *
40
- * @throws Error if not yet authorized.
41
- */
42
- getApiUrl() {
43
- return this.requireAuth().apiInfo.storageApi.apiUrl;
44
- }
45
- /**
46
- * Base URL for file downloads.
47
- *
48
- * @returns The base URL for file downloads.
49
- *
50
- * @throws Error if not yet authorized.
51
- */
52
- getDownloadUrl() {
53
- return this.requireAuth().apiInfo.storageApi.downloadUrl;
54
- }
55
- /**
56
- * Current authorization token.
57
- *
58
- * @returns The current authorization token.
59
- *
60
- * @throws Error if not yet authorized.
61
- */
62
- getAuthToken() {
63
- return this.requireAuth().authorizationToken;
64
- }
65
- /**
66
- * The authorized account ID.
67
- *
68
- * @returns The authorized account identifier.
69
- *
70
- * @throws Error if not yet authorized.
71
- */
72
- getAccountId() {
73
- return this.requireAuth().accountId;
74
- }
75
- /**
76
- * Server-recommended part size for large file uploads, in bytes.
77
- *
78
- * @returns The server-recommended part size in bytes.
79
- *
80
- * @throws Error if not yet authorized.
81
- */
82
- getRecommendedPartSize() {
83
- return this.requireAuth().apiInfo.storageApi.recommendedPartSize;
84
- }
85
- /**
86
- * Smallest allowed part size for large file uploads, in bytes.
87
- *
88
- * @returns The smallest allowed part size in bytes.
89
- *
90
- * @throws Error if not yet authorized.
91
- */
92
- getAbsoluteMinimumPartSize() {
93
- return this.requireAuth().apiInfo.storageApi.absoluteMinimumPartSize;
94
- }
95
- /**
96
- * Base URL for the S3-compatible API.
97
- *
98
- * @returns The base URL for the S3-compatible API.
99
- *
100
- * @throws Error if not yet authorized.
101
- */
102
- getS3ApiUrl() {
103
- return this.requireAuth().apiInfo.storageApi.s3ApiUrl;
104
- }
105
- /**
106
- * Bucket ID the key is restricted to, or null if unrestricted.
107
- *
108
- * @returns The restricted bucket identifier, or null if the key is unrestricted.
109
- *
110
- * @throws Error if not yet authorized.
111
- */
112
- getAllowedBucketId() {
113
- return this.requireAuth().apiInfo.storageApi.allowed.bucketId ?? null;
114
- }
115
- /**
116
- * Take an upload URL from the pool for the given bucket, or null if none available.
117
- *
118
- * @param bucketId - The bucket to check out an upload URL for.
119
- *
120
- * @returns A reusable upload URL entry, or null if none are available.
121
- */
122
- checkoutUploadUrl(bucketId) {
123
- return this.uploadUrls.checkout(bucketId);
124
- }
125
- /**
126
- * Return a still-valid upload URL to the pool for reuse.
127
- *
128
- * @param bucketId - The bucket the upload URL belongs to.
129
- * @param entry - The upload URL entry to return to the pool.
130
- */
131
- returnUploadUrl(bucketId, entry) {
132
- this.uploadUrls.checkin(bucketId, entry);
133
- }
134
- /**
135
- * Remove an upload URL from the pool after an upload error.
136
- *
137
- * @param bucketId - The bucket the failed upload URL belongs to.
138
- * @param entry - The upload URL entry to remove from the pool.
139
- */
140
- evictUploadUrl(bucketId, entry) {
141
- this.uploadUrls.evict(bucketId, entry);
142
- }
143
- /**
144
- * Take a large-file part upload URL from the pool, or null if none available.
145
- *
146
- * @param fileId - The large file to check out a part upload URL for.
147
- *
148
- * @returns A reusable part upload URL entry, or null if none are available.
149
- */
150
- checkoutPartUploadUrl(fileId) {
151
- return this.partUploadUrls.checkout(fileId);
152
- }
153
- /**
154
- * Return a still-valid part upload URL to the pool for reuse.
155
- *
156
- * @param fileId - The large file the part upload URL belongs to.
157
- * @param entry - The part upload URL entry to return to the pool.
158
- */
159
- returnPartUploadUrl(fileId, entry) {
160
- this.partUploadUrls.checkin(fileId, entry);
161
- }
162
- /**
163
- * Remove a part upload URL from the pool after an error.
164
- *
165
- * @param fileId - The large file the failed part upload URL belongs to.
166
- * @param entry - The part upload URL entry to remove from the pool.
167
- */
168
- evictPartUploadUrl(fileId, entry) {
169
- this.partUploadUrls.evict(fileId, entry);
170
- }
171
- /**
172
- * Retrieve the cached auth response or throw if not yet authorized.
173
- *
174
- * @returns The cached authorization response.
175
- *
176
- * @throws Error if authorize() has not been called.
177
- */
178
- requireAuth() {
179
- if (!this.auth) throw new Error("Not authorized. Call authorize() first.");
180
- return this.auth;
181
- }
182
- }
1
+ const require_upload_url_pool = require("./upload-url-pool.cjs");
2
+ //#region src/auth/in-memory.ts
3
+ /**
4
+ * In-memory implementation of {@link AccountInfo}.
5
+ * Stores the authorization response and upload URL pools in plain object fields.
6
+ * Suitable for short-lived processes or tests; state is lost when the process exits.
7
+ */
8
+ var InMemoryAccountInfo = class {
9
+ /** Cached authorization response, or null before authorize() is called. */
10
+ auth = null;
11
+ /** Pool of reusable small-file upload URLs, keyed by bucket ID. */
12
+ uploadUrls = new require_upload_url_pool.UploadUrlPool();
13
+ /** Pool of reusable large-file part upload URLs, keyed by file ID. */
14
+ partUploadUrls = new require_upload_url_pool.UploadUrlPool();
15
+ /**
16
+ * Store a fresh authorization response, replacing any previous state.
17
+ *
18
+ * @param auth - The authorize account response to store.
19
+ */
20
+ setAuth(auth) {
21
+ this.auth = auth;
22
+ this.uploadUrls.clear();
23
+ this.partUploadUrls.clear();
24
+ }
25
+ /**
26
+ * Return the current authorization response, or null if not authorized.
27
+ *
28
+ * @returns The cached authorization response, or null if not yet authorized.
29
+ */
30
+ getAuth() {
31
+ return this.auth;
32
+ }
33
+ /** Discard all cached authorization state and upload URLs. */
34
+ clear() {
35
+ this.auth = null;
36
+ this.uploadUrls.clear();
37
+ this.partUploadUrls.clear();
38
+ }
39
+ /**
40
+ * Base URL for B2 API calls.
41
+ *
42
+ * @returns The base URL for B2 API calls.
43
+ *
44
+ * @throws Error if not yet authorized.
45
+ */
46
+ getApiUrl() {
47
+ return this.requireAuth().apiInfo.storageApi.apiUrl;
48
+ }
49
+ /**
50
+ * Base URL for file downloads.
51
+ *
52
+ * @returns The base URL for file downloads.
53
+ *
54
+ * @throws Error if not yet authorized.
55
+ */
56
+ getDownloadUrl() {
57
+ return this.requireAuth().apiInfo.storageApi.downloadUrl;
58
+ }
59
+ /**
60
+ * Current authorization token.
61
+ *
62
+ * @returns The current authorization token.
63
+ *
64
+ * @throws Error if not yet authorized.
65
+ */
66
+ getAuthToken() {
67
+ return this.requireAuth().authorizationToken;
68
+ }
69
+ /**
70
+ * The authorized account ID.
71
+ *
72
+ * @returns The authorized account identifier.
73
+ *
74
+ * @throws Error if not yet authorized.
75
+ */
76
+ getAccountId() {
77
+ return this.requireAuth().accountId;
78
+ }
79
+ /**
80
+ * Server-recommended part size for large file uploads, in bytes.
81
+ *
82
+ * @returns The server-recommended part size in bytes.
83
+ *
84
+ * @throws Error if not yet authorized.
85
+ */
86
+ getRecommendedPartSize() {
87
+ return this.requireAuth().apiInfo.storageApi.recommendedPartSize;
88
+ }
89
+ /**
90
+ * Smallest allowed part size for large file uploads, in bytes.
91
+ *
92
+ * @returns The smallest allowed part size in bytes.
93
+ *
94
+ * @throws Error if not yet authorized.
95
+ */
96
+ getAbsoluteMinimumPartSize() {
97
+ return this.requireAuth().apiInfo.storageApi.absoluteMinimumPartSize;
98
+ }
99
+ /**
100
+ * Base URL for the S3-compatible API.
101
+ *
102
+ * @returns The base URL for the S3-compatible API.
103
+ *
104
+ * @throws Error if not yet authorized.
105
+ */
106
+ getS3ApiUrl() {
107
+ return this.requireAuth().apiInfo.storageApi.s3ApiUrl;
108
+ }
109
+ /**
110
+ * Bucket ID the key is restricted to, or null if unrestricted.
111
+ *
112
+ * @returns The restricted bucket identifier, or null if the key is unrestricted.
113
+ *
114
+ * @throws Error if not yet authorized.
115
+ */
116
+ getAllowedBucketId() {
117
+ const allowed = this.requireAuth().apiInfo.storageApi.allowed;
118
+ const buckets = allowed.buckets;
119
+ if (buckets === void 0) return allowed.bucketId ?? null;
120
+ if (buckets !== null) {
121
+ if (buckets.length !== 1) throw new Error("Authorized key is not restricted to exactly one bucket; use getAllowedBucketIds()");
122
+ return buckets[0]?.id ?? null;
123
+ }
124
+ return null;
125
+ }
126
+ /**
127
+ * Bucket IDs the key is restricted to, or null if unrestricted.
128
+ *
129
+ * @returns The restricted bucket identifiers, or null if the key is unrestricted.
130
+ *
131
+ * @throws Error if not yet authorized.
132
+ */
133
+ getAllowedBucketIds() {
134
+ const allowed = this.requireAuth().apiInfo.storageApi.allowed;
135
+ const buckets = allowed.buckets;
136
+ if (buckets === void 0) {
137
+ const legacyBucketId = allowed.bucketId ?? null;
138
+ return legacyBucketId === null ? null : [legacyBucketId];
139
+ }
140
+ return buckets === null ? null : buckets.map((bucket) => bucket.id);
141
+ }
142
+ /**
143
+ * Take an upload URL from the pool for the given bucket, or null if none available.
144
+ *
145
+ * @param bucketId - The bucket to check out an upload URL for.
146
+ *
147
+ * @returns A reusable upload URL entry, or null if none are available.
148
+ */
149
+ checkoutUploadUrl(bucketId) {
150
+ return this.uploadUrls.checkout(bucketId);
151
+ }
152
+ /**
153
+ * Return a still-valid upload URL to the pool for reuse.
154
+ *
155
+ * @param bucketId - The bucket the upload URL belongs to.
156
+ * @param entry - The upload URL entry to return to the pool.
157
+ */
158
+ returnUploadUrl(bucketId, entry) {
159
+ this.uploadUrls.checkin(bucketId, entry);
160
+ }
161
+ /**
162
+ * Remove an upload URL from the pool after an upload error.
163
+ *
164
+ * @param bucketId - The bucket the failed upload URL belongs to.
165
+ * @param entry - The upload URL entry to remove from the pool.
166
+ */
167
+ evictUploadUrl(bucketId, entry) {
168
+ this.uploadUrls.evict(bucketId, entry);
169
+ }
170
+ /**
171
+ * Take a large-file part upload URL from the pool, or null if none available.
172
+ *
173
+ * @param fileId - The large file to check out a part upload URL for.
174
+ *
175
+ * @returns A reusable part upload URL entry, or null if none are available.
176
+ */
177
+ checkoutPartUploadUrl(fileId) {
178
+ return this.partUploadUrls.checkout(fileId);
179
+ }
180
+ /**
181
+ * Return a still-valid part upload URL to the pool for reuse.
182
+ *
183
+ * @param fileId - The large file the part upload URL belongs to.
184
+ * @param entry - The part upload URL entry to return to the pool.
185
+ */
186
+ returnPartUploadUrl(fileId, entry) {
187
+ this.partUploadUrls.checkin(fileId, entry);
188
+ }
189
+ /**
190
+ * Remove a part upload URL from the pool after an error.
191
+ *
192
+ * @param fileId - The large file the failed part upload URL belongs to.
193
+ * @param entry - The part upload URL entry to remove from the pool.
194
+ */
195
+ evictPartUploadUrl(fileId, entry) {
196
+ this.partUploadUrls.evict(fileId, entry);
197
+ }
198
+ /**
199
+ * Retrieve the cached auth response or throw if not yet authorized.
200
+ *
201
+ * @returns The cached authorization response.
202
+ *
203
+ * @throws Error if authorize() has not been called.
204
+ */
205
+ requireAuth() {
206
+ if (!this.auth) throw new Error("Not authorized. Call authorize() first.");
207
+ return this.auth;
208
+ }
209
+ };
210
+ //#endregion
183
211
  exports.InMemoryAccountInfo = InMemoryAccountInfo;
184
- //# sourceMappingURL=in-memory.cjs.map
212
+
213
+ //# sourceMappingURL=in-memory.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory.cjs","sources":["../../src/auth/in-memory.ts"],"sourcesContent":["import type { AuthorizeAccountResponse } from '../types/auth.ts'\nimport type { BucketId } from '../types/ids.ts'\nimport type { AccountInfo, UploadUrlEntry } from './account-info.ts'\nimport { UploadUrlPool } from './upload-url-pool.ts'\n\n/**\n * In-memory implementation of {@link AccountInfo}.\n * Stores the authorization response and upload URL pools in plain object fields.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryAccountInfo implements AccountInfo {\n /** Cached authorization response, or null before authorize() is called. */\n private auth: AuthorizeAccountResponse | null = null\n /** Pool of reusable small-file upload URLs, keyed by bucket ID. */\n private readonly uploadUrls = new UploadUrlPool()\n /** Pool of reusable large-file part upload URLs, keyed by file ID. */\n private readonly partUploadUrls = new UploadUrlPool()\n\n /**\n * Store a fresh authorization response, replacing any previous state.\n *\n * @param auth - The authorize account response to store.\n */\n setAuth(auth: AuthorizeAccountResponse): void {\n this.auth = auth\n this.uploadUrls.clear()\n this.partUploadUrls.clear()\n }\n\n /**\n * Return the current authorization response, or null if not authorized.\n *\n * @returns The cached authorization response, or null if not yet authorized.\n */\n getAuth(): AuthorizeAccountResponse | null {\n return this.auth\n }\n\n /** Discard all cached authorization state and upload URLs. */\n clear(): void {\n this.auth = null\n this.uploadUrls.clear()\n this.partUploadUrls.clear()\n }\n\n /**\n * Base URL for B2 API calls.\n *\n * @returns The base URL for B2 API calls.\n *\n * @throws Error if not yet authorized.\n */\n getApiUrl(): string {\n return this.requireAuth().apiInfo.storageApi.apiUrl\n }\n\n /**\n * Base URL for file downloads.\n *\n * @returns The base URL for file downloads.\n *\n * @throws Error if not yet authorized.\n */\n getDownloadUrl(): string {\n return this.requireAuth().apiInfo.storageApi.downloadUrl\n }\n\n /**\n * Current authorization token.\n *\n * @returns The current authorization token.\n *\n * @throws Error if not yet authorized.\n */\n getAuthToken(): string {\n return this.requireAuth().authorizationToken as string\n }\n\n /**\n * The authorized account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws Error if not yet authorized.\n */\n getAccountId(): string {\n return this.requireAuth().accountId as string\n }\n\n /**\n * Server-recommended part size for large file uploads, in bytes.\n *\n * @returns The server-recommended part size in bytes.\n *\n * @throws Error if not yet authorized.\n */\n getRecommendedPartSize(): number {\n return this.requireAuth().apiInfo.storageApi.recommendedPartSize\n }\n\n /**\n * Smallest allowed part size for large file uploads, in bytes.\n *\n * @returns The smallest allowed part size in bytes.\n *\n * @throws Error if not yet authorized.\n */\n getAbsoluteMinimumPartSize(): number {\n return this.requireAuth().apiInfo.storageApi.absoluteMinimumPartSize\n }\n\n /**\n * Base URL for the S3-compatible API.\n *\n * @returns The base URL for the S3-compatible API.\n *\n * @throws Error if not yet authorized.\n */\n getS3ApiUrl(): string {\n return this.requireAuth().apiInfo.storageApi.s3ApiUrl\n }\n\n /**\n * Bucket ID the key is restricted to, or null if unrestricted.\n *\n * @returns The restricted bucket identifier, or null if the key is unrestricted.\n *\n * @throws Error if not yet authorized.\n */\n getAllowedBucketId(): BucketId | null {\n return this.requireAuth().apiInfo.storageApi.allowed.bucketId ?? null\n }\n\n /**\n * Take an upload URL from the pool for the given bucket, or null if none available.\n *\n * @param bucketId - The bucket to check out an upload URL for.\n *\n * @returns A reusable upload URL entry, or null if none are available.\n */\n checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null {\n return this.uploadUrls.checkout(bucketId as string)\n }\n\n /**\n * Return a still-valid upload URL to the pool for reuse.\n *\n * @param bucketId - The bucket the upload URL belongs to.\n * @param entry - The upload URL entry to return to the pool.\n */\n returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.uploadUrls.checkin(bucketId as string, entry)\n }\n\n /**\n * Remove an upload URL from the pool after an upload error.\n *\n * @param bucketId - The bucket the failed upload URL belongs to.\n * @param entry - The upload URL entry to remove from the pool.\n */\n evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.uploadUrls.evict(bucketId as string, entry)\n }\n\n /**\n * Take a large-file part upload URL from the pool, or null if none available.\n *\n * @param fileId - The large file to check out a part upload URL for.\n *\n * @returns A reusable part upload URL entry, or null if none are available.\n */\n checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null {\n return this.partUploadUrls.checkout(fileId)\n }\n\n /**\n * Return a still-valid part upload URL to the pool for reuse.\n *\n * @param fileId - The large file the part upload URL belongs to.\n * @param entry - The part upload URL entry to return to the pool.\n */\n returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.partUploadUrls.checkin(fileId, entry)\n }\n\n /**\n * Remove a part upload URL from the pool after an error.\n *\n * @param fileId - The large file the failed part upload URL belongs to.\n * @param entry - The part upload URL entry to remove from the pool.\n */\n evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.partUploadUrls.evict(fileId, entry)\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws Error if authorize() has not been called.\n */\n private requireAuth(): AuthorizeAccountResponse {\n if (!this.auth) throw new Error('Not authorized. Call authorize() first.')\n return this.auth\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O,KAAK,YAAA,EAAc,QAAQ,WAAW;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,qBAAsC;AACpC,WAAO,KAAK,cAAc,QAAQ,WAAW,QAAQ,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,kBAAkB,UAA2C;AAC3D,WAAO,KAAK,WAAW,SAAS,QAAkB;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,gBAAgB,UAAoB,OAA6B;AAC/D,SAAK,WAAW,QAAQ,UAAoB,KAAK;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eAAe,UAAoB,OAA6B;AAC9D,SAAK,WAAW,MAAM,UAAoB,KAAK;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,sBAAsB,QAAuC;AAC3D,WAAO,KAAK,eAAe,SAAS,MAAM;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,oBAAoB,QAAgB,OAA6B;AAC/D,SAAK,eAAe,QAAQ,QAAQ,KAAK;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,QAAgB,OAA6B;AAC9D,SAAK,eAAe,MAAM,QAAQ,KAAK;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,cAAwC;AAC9C,QAAI,CAAC,KAAK,KAAM,OAAM,IAAI,MAAM,yCAAyC;AACzE,WAAO,KAAK;AAAA,EACd;AACF;;"}
1
+ {"version":3,"file":"in-memory.cjs","names":[],"sources":["../../src/auth/in-memory.ts"],"sourcesContent":["import type { AuthorizeAccountResponse } from '../types/auth.ts'\nimport type { BucketId } from '../types/ids.ts'\nimport type { AccountInfo, UploadUrlEntry } from './account-info.ts'\nimport { UploadUrlPool } from './upload-url-pool.ts'\n\n/**\n * In-memory implementation of {@link AccountInfo}.\n * Stores the authorization response and upload URL pools in plain object fields.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryAccountInfo implements AccountInfo {\n /** Cached authorization response, or null before authorize() is called. */\n private auth: AuthorizeAccountResponse | null = null\n /** Pool of reusable small-file upload URLs, keyed by bucket ID. */\n private readonly uploadUrls = new UploadUrlPool()\n /** Pool of reusable large-file part upload URLs, keyed by file ID. */\n private readonly partUploadUrls = new UploadUrlPool()\n\n /**\n * Store a fresh authorization response, replacing any previous state.\n *\n * @param auth - The authorize account response to store.\n */\n setAuth(auth: AuthorizeAccountResponse): void {\n this.auth = auth\n this.uploadUrls.clear()\n this.partUploadUrls.clear()\n }\n\n /**\n * Return the current authorization response, or null if not authorized.\n *\n * @returns The cached authorization response, or null if not yet authorized.\n */\n getAuth(): AuthorizeAccountResponse | null {\n return this.auth\n }\n\n /** Discard all cached authorization state and upload URLs. */\n clear(): void {\n this.auth = null\n this.uploadUrls.clear()\n this.partUploadUrls.clear()\n }\n\n /**\n * Base URL for B2 API calls.\n *\n * @returns The base URL for B2 API calls.\n *\n * @throws Error if not yet authorized.\n */\n getApiUrl(): string {\n return this.requireAuth().apiInfo.storageApi.apiUrl\n }\n\n /**\n * Base URL for file downloads.\n *\n * @returns The base URL for file downloads.\n *\n * @throws Error if not yet authorized.\n */\n getDownloadUrl(): string {\n return this.requireAuth().apiInfo.storageApi.downloadUrl\n }\n\n /**\n * Current authorization token.\n *\n * @returns The current authorization token.\n *\n * @throws Error if not yet authorized.\n */\n getAuthToken(): string {\n return this.requireAuth().authorizationToken as string\n }\n\n /**\n * The authorized account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws Error if not yet authorized.\n */\n getAccountId(): string {\n return this.requireAuth().accountId as string\n }\n\n /**\n * Server-recommended part size for large file uploads, in bytes.\n *\n * @returns The server-recommended part size in bytes.\n *\n * @throws Error if not yet authorized.\n */\n getRecommendedPartSize(): number {\n return this.requireAuth().apiInfo.storageApi.recommendedPartSize\n }\n\n /**\n * Smallest allowed part size for large file uploads, in bytes.\n *\n * @returns The smallest allowed part size in bytes.\n *\n * @throws Error if not yet authorized.\n */\n getAbsoluteMinimumPartSize(): number {\n return this.requireAuth().apiInfo.storageApi.absoluteMinimumPartSize\n }\n\n /**\n * Base URL for the S3-compatible API.\n *\n * @returns The base URL for the S3-compatible API.\n *\n * @throws Error if not yet authorized.\n */\n getS3ApiUrl(): string {\n return this.requireAuth().apiInfo.storageApi.s3ApiUrl\n }\n\n /**\n * Bucket ID the key is restricted to, or null if unrestricted.\n *\n * @returns The restricted bucket identifier, or null if the key is unrestricted.\n *\n * @throws Error if not yet authorized.\n */\n getAllowedBucketId(): BucketId | null {\n const allowed = this.requireAuth().apiInfo.storageApi.allowed\n const buckets: typeof allowed.buckets | undefined = allowed.buckets\n if (buckets === undefined) {\n return allowed.bucketId ?? null\n }\n if (buckets !== null) {\n if (buckets.length !== 1) {\n throw new Error(\n 'Authorized key is not restricted to exactly one bucket; use getAllowedBucketIds()',\n )\n }\n return buckets[0]?.id ?? null\n }\n return null\n }\n\n /**\n * Bucket IDs the key is restricted to, or null if unrestricted.\n *\n * @returns The restricted bucket identifiers, or null if the key is unrestricted.\n *\n * @throws Error if not yet authorized.\n */\n getAllowedBucketIds(): readonly BucketId[] | null {\n const allowed = this.requireAuth().apiInfo.storageApi.allowed\n const buckets: typeof allowed.buckets | undefined = allowed.buckets\n if (buckets === undefined) {\n const legacyBucketId = allowed.bucketId ?? null\n return legacyBucketId === null ? null : [legacyBucketId]\n }\n return buckets === null ? null : buckets.map((bucket) => bucket.id)\n }\n\n /**\n * Take an upload URL from the pool for the given bucket, or null if none available.\n *\n * @param bucketId - The bucket to check out an upload URL for.\n *\n * @returns A reusable upload URL entry, or null if none are available.\n */\n checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null {\n return this.uploadUrls.checkout(bucketId as string)\n }\n\n /**\n * Return a still-valid upload URL to the pool for reuse.\n *\n * @param bucketId - The bucket the upload URL belongs to.\n * @param entry - The upload URL entry to return to the pool.\n */\n returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.uploadUrls.checkin(bucketId as string, entry)\n }\n\n /**\n * Remove an upload URL from the pool after an upload error.\n *\n * @param bucketId - The bucket the failed upload URL belongs to.\n * @param entry - The upload URL entry to remove from the pool.\n */\n evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.uploadUrls.evict(bucketId as string, entry)\n }\n\n /**\n * Take a large-file part upload URL from the pool, or null if none available.\n *\n * @param fileId - The large file to check out a part upload URL for.\n *\n * @returns A reusable part upload URL entry, or null if none are available.\n */\n checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null {\n return this.partUploadUrls.checkout(fileId)\n }\n\n /**\n * Return a still-valid part upload URL to the pool for reuse.\n *\n * @param fileId - The large file the part upload URL belongs to.\n * @param entry - The part upload URL entry to return to the pool.\n */\n returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.partUploadUrls.checkin(fileId, entry)\n }\n\n /**\n * Remove a part upload URL from the pool after an error.\n *\n * @param fileId - The large file the failed part upload URL belongs to.\n * @param entry - The part upload URL entry to remove from the pool.\n */\n evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.partUploadUrls.evict(fileId, entry)\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws Error if authorize() has not been called.\n */\n private requireAuth(): AuthorizeAccountResponse {\n if (!this.auth) throw new Error('Not authorized. Call authorize() first.')\n return this.auth\n }\n}\n"],"mappings":";;;;;;;AAUA,IAAa,sBAAb,MAAwD;;CAEtD,OAAgD;;CAEhD,aAA8B,IAAI,wBAAA,cAAc;;CAEhD,iBAAkC,IAAI,wBAAA,cAAc;;;;;;CAOpD,QAAQ,MAAsC;EAC5C,KAAK,OAAO;EACZ,KAAK,WAAW,MAAM;EACtB,KAAK,eAAe,M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ACpE;;;;;;;;CASA,kBAAkB,UAA2C;EAC3D,OAAO,KAAK,WAAW,SAAS,QAAkB;CACpD;;;;;;;CAQA,gBAAgB,UAAoB,OAA6B;EAC/D,KAAK,WAAW,QAAQ,UAAoB,KAAK;CACnD;;;;;;;CAQA,eAAe,UAAoB,OAA6B;EAC9D,KAAK,WAAW,MAAM,UAAoB,KAAK;CACjD;;;;;;;;CASA,sBAAsB,QAAuC;EAC3D,OAAO,KAAK,eAAe,SAAS,MAAM;CAC5C;;;;;;;CAQA,oBAAoB,QAAgB,OAA6B;EAC/D,KAAK,eAAe,QAAQ,QAAQ,KAAK;CAC3C;;;;;;;CAQA,mBAAmB,QAAgB,OAA6B;EAC9D,KAAK,eAAe,MAAM,QAAQ,KAAK;CACzC;;;;;;;;CASA,cAAgD;EAC9C,IAAI,CAAC,KAAK,MAAM,MAAM,IAAI,MAAM,yCAAyC;EACzE,OAAO,KAAK;CACd;AACF"}
@@ -91,6 +91,14 @@ export declare class InMemoryAccountInfo implements AccountInfo {
91
91
  * @throws Error if not yet authorized.
92
92
  */
93
93
  getAllowedBucketId(): BucketId | null;
94
+ /**
95
+ * Bucket IDs the key is restricted to, or null if unrestricted.
96
+ *
97
+ * @returns The restricted bucket identifiers, or null if the key is unrestricted.
98
+ *
99
+ * @throws Error if not yet authorized.
100
+ */
101
+ getAllowedBucketIds(): readonly BucketId[] | null;
94
102
  /**
95
103
  * Take an upload URL from the pool for the given bucket, or null if none available.
96
104
  *
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/auth/in-memory.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGpE;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,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AAE,KAAK,EAAE,cAAc,GAAG,IAAI;IAIhE;;;;;OAKG;IACH,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI;IAI/D;;;;;;OAMG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAI5D;;;;;OAKG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI;IAIhE;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI;IAI/D;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;CAIpB"}
@@ -91,6 +91,14 @@ export declare class InMemoryAccountInfo implements AccountInfo {
91
91
  * @throws Error if not yet authorized.
92
92
  */
93
93
  getAllowedBucketId(): BucketId | null;
94
+ /**
95
+ * Bucket IDs the key is restricted to, or null if unrestricted.
96
+ *
97
+ * @returns The restricted bucket identifiers, or null if the key is unrestricted.
98
+ *
99
+ * @throws Error if not yet authorized.
100
+ */
101
+ getAllowedBucketIds(): readonly BucketId[] | null;
94
102
  /**
95
103
  * Take an upload URL from the pool for the given bucket, or null if none available.
96
104
  *
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/auth/in-memory.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGpE;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,WAAW;IACrD,2EAA2E;IAC3E,OAAO,CAAC,IAAI,CAAwC;IACpD,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IACjD,sEAAsE;IACtE,OAAO,CAA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