@backblaze-labs/b2-sdk 0.2.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 (460) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/README.md +20 -2
  3. package/dist/_virtual/_b2-sdk-version-json.cjs +1 -1
  4. package/dist/_virtual/_b2-sdk-version-json.js +1 -1
  5. package/dist/auth/file.cjs.map +1 -1
  6. package/dist/backup/client.cjs +206 -0
  7. package/dist/backup/client.cjs.map +1 -0
  8. package/dist/backup/client.d.cts +238 -0
  9. package/dist/backup/client.d.cts.map +1 -0
  10. package/dist/backup/client.d.ts +238 -0
  11. package/dist/backup/client.d.ts.map +1 -0
  12. package/dist/backup/client.js +206 -0
  13. package/dist/backup/client.js.map +1 -0
  14. package/dist/backup/index.cjs +15 -0
  15. package/dist/backup/index.d.cts +22 -0
  16. package/dist/backup/index.d.cts.map +1 -0
  17. package/dist/backup/index.d.ts +22 -0
  18. package/dist/backup/index.d.ts.map +1 -0
  19. package/dist/backup/index.js +7 -0
  20. package/dist/backup/raw.cjs +146 -0
  21. package/dist/backup/raw.cjs.map +1 -0
  22. package/dist/backup/raw.d.cts +122 -0
  23. package/dist/backup/raw.d.cts.map +1 -0
  24. package/dist/backup/raw.d.ts +122 -0
  25. package/dist/backup/raw.d.ts.map +1 -0
  26. package/dist/backup/raw.js +146 -0
  27. package/dist/backup/raw.js.map +1 -0
  28. package/dist/bucket.cjs +2 -1
  29. package/dist/bucket.cjs.map +1 -1
  30. package/dist/bucket.js +2 -1
  31. package/dist/bucket.js.map +1 -1
  32. package/dist/copy/large.cjs +5 -3
  33. package/dist/copy/large.cjs.map +1 -1
  34. package/dist/copy/large.d.cts.map +1 -1
  35. package/dist/copy/large.d.ts.map +1 -1
  36. package/dist/copy/large.js +5 -3
  37. package/dist/copy/large.js.map +1 -1
  38. package/dist/download/checksum.cjs +6 -2
  39. package/dist/download/checksum.cjs.map +1 -1
  40. package/dist/download/checksum.js +6 -2
  41. package/dist/download/checksum.js.map +1 -1
  42. package/dist/download/parallel.cjs +52 -15
  43. package/dist/download/parallel.cjs.map +1 -1
  44. package/dist/download/parallel.d.cts +8 -1
  45. package/dist/download/parallel.d.cts.map +1 -1
  46. package/dist/download/parallel.d.ts +8 -1
  47. package/dist/download/parallel.d.ts.map +1 -1
  48. package/dist/download/parallel.js +52 -15
  49. package/dist/download/parallel.js.map +1 -1
  50. package/dist/download/single.cjs +141 -6
  51. package/dist/download/single.cjs.map +1 -1
  52. package/dist/download/single.d.cts.map +1 -1
  53. package/dist/download/single.d.ts.map +1 -1
  54. package/dist/download/single.js +141 -6
  55. package/dist/download/single.js.map +1 -1
  56. package/dist/errors/index.cjs +173 -3
  57. package/dist/errors/index.cjs.map +1 -1
  58. package/dist/errors/index.d.cts +119 -0
  59. package/dist/errors/index.d.cts.map +1 -1
  60. package/dist/errors/index.d.ts +119 -0
  61. package/dist/errors/index.d.ts.map +1 -1
  62. package/dist/errors/index.js +161 -4
  63. package/dist/errors/index.js.map +1 -1
  64. package/dist/http/retry.cjs +1 -1
  65. package/dist/http/retry.cjs.map +1 -1
  66. package/dist/http/retry.js +1 -1
  67. package/dist/http/retry.js.map +1 -1
  68. package/dist/http/transport.cjs +61 -23
  69. package/dist/http/transport.cjs.map +1 -1
  70. package/dist/http/transport.d.cts +25 -3
  71. package/dist/http/transport.d.cts.map +1 -1
  72. package/dist/http/transport.d.ts +25 -3
  73. package/dist/http/transport.d.ts.map +1 -1
  74. package/dist/http/transport.js +59 -22
  75. package/dist/http/transport.js.map +1 -1
  76. package/dist/index.cjs +25 -2
  77. package/dist/index.d.cts +6 -4
  78. package/dist/index.d.cts.map +1 -1
  79. package/dist/index.d.ts +6 -4
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +8 -6
  82. package/dist/object.cjs +1 -1
  83. package/dist/object.cjs.map +1 -1
  84. package/dist/object.d.cts +4 -2
  85. package/dist/object.d.cts.map +1 -1
  86. package/dist/object.d.ts +4 -2
  87. package/dist/object.d.ts.map +1 -1
  88. package/dist/object.js +1 -1
  89. package/dist/object.js.map +1 -1
  90. package/dist/partner/account-info.d.cts +43 -0
  91. package/dist/partner/account-info.d.cts.map +1 -0
  92. package/dist/partner/account-info.d.ts +43 -0
  93. package/dist/partner/account-info.d.ts.map +1 -0
  94. package/dist/partner/auth-clone.cjs +64 -0
  95. package/dist/partner/auth-clone.cjs.map +1 -0
  96. package/dist/partner/auth-clone.d.cts +27 -0
  97. package/dist/partner/auth-clone.d.cts.map +1 -0
  98. package/dist/partner/auth-clone.d.ts +27 -0
  99. package/dist/partner/auth-clone.d.ts.map +1 -0
  100. package/dist/partner/auth-clone.js +63 -0
  101. package/dist/partner/auth-clone.js.map +1 -0
  102. package/dist/partner/auth-core.cjs +175 -0
  103. package/dist/partner/auth-core.cjs.map +1 -0
  104. package/dist/partner/auth-core.d.cts +111 -0
  105. package/dist/partner/auth-core.d.cts.map +1 -0
  106. package/dist/partner/auth-core.d.ts +111 -0
  107. package/dist/partner/auth-core.d.ts.map +1 -0
  108. package/dist/partner/auth-core.js +175 -0
  109. package/dist/partner/auth-core.js.map +1 -0
  110. package/dist/partner/auth-shape.cjs +36 -0
  111. package/dist/partner/auth-shape.cjs.map +1 -0
  112. package/dist/partner/auth-shape.d.cts +12 -0
  113. package/dist/partner/auth-shape.d.cts.map +1 -0
  114. package/dist/partner/auth-shape.d.ts +12 -0
  115. package/dist/partner/auth-shape.d.ts.map +1 -0
  116. package/dist/partner/auth-shape.js +36 -0
  117. package/dist/partner/auth-shape.js.map +1 -0
  118. package/dist/partner/client.cjs +255 -0
  119. package/dist/partner/client.cjs.map +1 -0
  120. package/dist/partner/client.d.cts +335 -0
  121. package/dist/partner/client.d.cts.map +1 -0
  122. package/dist/partner/client.d.ts +335 -0
  123. package/dist/partner/client.d.ts.map +1 -0
  124. package/dist/partner/client.js +255 -0
  125. package/dist/partner/client.js.map +1 -0
  126. package/dist/partner/endpoint-url.cjs +108 -0
  127. package/dist/partner/endpoint-url.cjs.map +1 -0
  128. package/dist/partner/endpoint-url.d.cts +72 -0
  129. package/dist/partner/endpoint-url.d.cts.map +1 -0
  130. package/dist/partner/endpoint-url.d.ts +72 -0
  131. package/dist/partner/endpoint-url.d.ts.map +1 -0
  132. package/dist/partner/endpoint-url.js +105 -0
  133. package/dist/partner/endpoint-url.js.map +1 -0
  134. package/dist/partner/in-memory.cjs +135 -0
  135. package/dist/partner/in-memory.cjs.map +1 -0
  136. package/dist/partner/in-memory.d.cts +99 -0
  137. package/dist/partner/in-memory.d.cts.map +1 -0
  138. package/dist/partner/in-memory.d.ts +99 -0
  139. package/dist/partner/in-memory.d.ts.map +1 -0
  140. package/dist/partner/in-memory.js +135 -0
  141. package/dist/partner/in-memory.js.map +1 -0
  142. package/dist/partner/index.cjs +18 -0
  143. package/dist/partner/index.d.cts +23 -0
  144. package/dist/partner/index.d.cts.map +1 -0
  145. package/dist/partner/index.d.ts +23 -0
  146. package/dist/partner/index.d.ts.map +1 -0
  147. package/dist/partner/index.js +7 -0
  148. package/dist/partner/raw.cjs +392 -0
  149. package/dist/partner/raw.cjs.map +1 -0
  150. package/dist/partner/raw.d.cts +223 -0
  151. package/dist/partner/raw.d.cts.map +1 -0
  152. package/dist/partner/raw.d.ts +223 -0
  153. package/dist/partner/raw.d.ts.map +1 -0
  154. package/dist/partner/raw.js +390 -0
  155. package/dist/partner/raw.js.map +1 -0
  156. package/dist/partner/redaction-placeholders.cjs +10 -0
  157. package/dist/partner/redaction-placeholders.cjs.map +1 -0
  158. package/dist/partner/redaction-placeholders.d.cts +5 -0
  159. package/dist/partner/redaction-placeholders.d.cts.map +1 -0
  160. package/dist/partner/redaction-placeholders.d.ts +5 -0
  161. package/dist/partner/redaction-placeholders.d.ts.map +1 -0
  162. package/dist/partner/redaction-placeholders.js +9 -0
  163. package/dist/partner/redaction-placeholders.js.map +1 -0
  164. package/dist/partner/redaction.cjs +267 -0
  165. package/dist/partner/redaction.cjs.map +1 -0
  166. package/dist/partner/redaction.d.cts +124 -0
  167. package/dist/partner/redaction.d.cts.map +1 -0
  168. package/dist/partner/redaction.d.ts +124 -0
  169. package/dist/partner/redaction.d.ts.map +1 -0
  170. package/dist/partner/redaction.js +257 -0
  171. package/dist/partner/redaction.js.map +1 -0
  172. package/dist/raw/index.cjs +81 -19
  173. package/dist/raw/index.cjs.map +1 -1
  174. package/dist/raw/index.d.cts +6 -2
  175. package/dist/raw/index.d.cts.map +1 -1
  176. package/dist/raw/index.d.ts +6 -2
  177. package/dist/raw/index.d.ts.map +1 -1
  178. package/dist/raw/index.js +81 -19
  179. package/dist/raw/index.js.map +1 -1
  180. package/dist/raw/url.cjs +111 -0
  181. package/dist/raw/url.cjs.map +1 -0
  182. package/dist/raw/url.d.cts +41 -0
  183. package/dist/raw/url.d.cts.map +1 -0
  184. package/dist/raw/url.d.ts +41 -0
  185. package/dist/raw/url.d.ts.map +1 -0
  186. package/dist/raw/url.js +110 -0
  187. package/dist/raw/url.js.map +1 -0
  188. package/dist/s3/sigv4.cjs +15 -10
  189. package/dist/s3/sigv4.cjs.map +1 -1
  190. package/dist/s3/sigv4.js +15 -10
  191. package/dist/s3/sigv4.js.map +1 -1
  192. package/dist/simulator/index.cjs +1197 -206
  193. package/dist/simulator/index.cjs.map +1 -1
  194. package/dist/simulator/index.d.cts +109 -11
  195. package/dist/simulator/index.d.cts.map +1 -1
  196. package/dist/simulator/index.d.ts +109 -11
  197. package/dist/simulator/index.d.ts.map +1 -1
  198. package/dist/simulator/index.js +1196 -209
  199. package/dist/simulator/index.js.map +1 -1
  200. package/dist/simulator/partner.cjs +719 -0
  201. package/dist/simulator/partner.cjs.map +1 -0
  202. package/dist/simulator/partner.d.cts +183 -0
  203. package/dist/simulator/partner.d.cts.map +1 -0
  204. package/dist/simulator/partner.d.ts +183 -0
  205. package/dist/simulator/partner.d.ts.map +1 -0
  206. package/dist/simulator/partner.js +718 -0
  207. package/dist/simulator/partner.js.map +1 -0
  208. package/dist/simulator/validation.cjs +577 -0
  209. package/dist/simulator/validation.cjs.map +1 -1
  210. package/dist/simulator/validation.d.cts +117 -0
  211. package/dist/simulator/validation.d.cts.map +1 -1
  212. package/dist/simulator/validation.d.ts +117 -0
  213. package/dist/simulator/validation.d.ts.map +1 -1
  214. package/dist/simulator/validation.js +563 -1
  215. package/dist/simulator/validation.js.map +1 -1
  216. package/dist/streams/file-source.cjs +1 -1
  217. package/dist/streams/file-source.cjs.map +1 -1
  218. package/dist/streams/file-source.js +1 -1
  219. package/dist/streams/file-source.js.map +1 -1
  220. package/dist/streams/index.cjs +1 -1
  221. package/dist/streams/index.js +1 -1
  222. package/dist/streams/source.cjs +2 -1
  223. package/dist/streams/source.cjs.map +1 -1
  224. package/dist/streams/source.js +2 -1
  225. package/dist/streams/source.js.map +1 -1
  226. package/dist/sync/b2-sha1-reader.cjs +6 -2
  227. package/dist/sync/b2-sha1-reader.cjs.map +1 -1
  228. package/dist/sync/b2-sha1-reader.d.cts.map +1 -1
  229. package/dist/sync/b2-sha1-reader.d.ts.map +1 -1
  230. package/dist/sync/b2-sha1-reader.js +6 -2
  231. package/dist/sync/b2-sha1-reader.js.map +1 -1
  232. package/dist/sync/download-staging.cjs +11 -10
  233. package/dist/sync/download-staging.cjs.map +1 -1
  234. package/dist/sync/download-staging.d.cts +2 -1
  235. package/dist/sync/download-staging.d.cts.map +1 -1
  236. package/dist/sync/download-staging.d.ts +2 -1
  237. package/dist/sync/download-staging.d.ts.map +1 -1
  238. package/dist/sync/download-staging.js +11 -10
  239. package/dist/sync/download-staging.js.map +1 -1
  240. package/dist/sync/filters.cjs.map +1 -1
  241. package/dist/sync/filters.js.map +1 -1
  242. package/dist/sync/local-file-io.cjs +11 -6
  243. package/dist/sync/local-file-io.cjs.map +1 -1
  244. package/dist/sync/local-file-io.d.cts +1 -0
  245. package/dist/sync/local-file-io.d.cts.map +1 -1
  246. package/dist/sync/local-file-io.d.ts +1 -0
  247. package/dist/sync/local-file-io.d.ts.map +1 -1
  248. package/dist/sync/local-file-io.js +11 -6
  249. package/dist/sync/local-file-io.js.map +1 -1
  250. package/dist/sync/local-sha1.cjs +6 -15
  251. package/dist/sync/local-sha1.cjs.map +1 -1
  252. package/dist/sync/local-sha1.d.cts +0 -8
  253. package/dist/sync/local-sha1.d.cts.map +1 -1
  254. package/dist/sync/local-sha1.d.ts +0 -8
  255. package/dist/sync/local-sha1.d.ts.map +1 -1
  256. package/dist/sync/local-sha1.js +7 -15
  257. package/dist/sync/local-sha1.js.map +1 -1
  258. package/dist/sync/policies/compare.cjs +5 -3
  259. package/dist/sync/policies/compare.cjs.map +1 -1
  260. package/dist/sync/policies/compare.d.cts.map +1 -1
  261. package/dist/sync/policies/compare.d.ts.map +1 -1
  262. package/dist/sync/policies/compare.js +6 -4
  263. package/dist/sync/policies/compare.js.map +1 -1
  264. package/dist/sync/policies/index.cjs +4 -10
  265. package/dist/sync/policies/index.cjs.map +1 -1
  266. package/dist/sync/policies/index.js +4 -10
  267. package/dist/sync/policies/index.js.map +1 -1
  268. package/dist/sync/scanners/b2.cjs +2 -2
  269. package/dist/sync/scanners/b2.cjs.map +1 -1
  270. package/dist/sync/scanners/b2.js +2 -2
  271. package/dist/sync/scanners/b2.js.map +1 -1
  272. package/dist/sync/scanners/local.cjs.map +1 -1
  273. package/dist/sync/scanners/local.js.map +1 -1
  274. package/dist/sync/synchronizer.cjs +3 -2
  275. package/dist/sync/synchronizer.cjs.map +1 -1
  276. package/dist/sync/synchronizer.js +3 -2
  277. package/dist/sync/synchronizer.js.map +1 -1
  278. package/dist/types/auth.cjs +4 -0
  279. package/dist/types/auth.cjs.map +1 -1
  280. package/dist/types/auth.d.cts +4 -0
  281. package/dist/types/auth.d.cts.map +1 -1
  282. package/dist/types/auth.d.ts +4 -0
  283. package/dist/types/auth.d.ts.map +1 -1
  284. package/dist/types/auth.js +4 -0
  285. package/dist/types/auth.js.map +1 -1
  286. package/dist/types/backup.d.cts +80 -0
  287. package/dist/types/backup.d.cts.map +1 -0
  288. package/dist/types/backup.d.ts +80 -0
  289. package/dist/types/backup.d.ts.map +1 -0
  290. package/dist/types/bucket.cjs.map +1 -1
  291. package/dist/types/bucket.d.cts +4 -2
  292. package/dist/types/bucket.d.cts.map +1 -1
  293. package/dist/types/bucket.d.ts +4 -2
  294. package/dist/types/bucket.d.ts.map +1 -1
  295. package/dist/types/bucket.js.map +1 -1
  296. package/dist/types/download.cjs +62 -0
  297. package/dist/types/download.cjs.map +1 -0
  298. package/dist/types/download.d.cts +98 -0
  299. package/dist/types/download.d.cts.map +1 -1
  300. package/dist/types/download.d.ts +98 -0
  301. package/dist/types/download.d.ts.map +1 -1
  302. package/dist/types/download.js +61 -0
  303. package/dist/types/download.js.map +1 -0
  304. package/dist/types/encryption.cjs +58 -229
  305. package/dist/types/encryption.cjs.map +1 -1
  306. package/dist/types/encryption.d.cts +32 -0
  307. package/dist/types/encryption.d.cts.map +1 -1
  308. package/dist/types/encryption.d.ts +32 -0
  309. package/dist/types/encryption.d.ts.map +1 -1
  310. package/dist/types/encryption.js +56 -229
  311. package/dist/types/encryption.js.map +1 -1
  312. package/dist/types/errors.cjs +9 -0
  313. package/dist/types/errors.cjs.map +1 -1
  314. package/dist/types/errors.d.cts +1 -1
  315. package/dist/types/errors.d.cts.map +1 -1
  316. package/dist/types/errors.d.ts +1 -1
  317. package/dist/types/errors.d.ts.map +1 -1
  318. package/dist/types/errors.js +9 -0
  319. package/dist/types/errors.js.map +1 -1
  320. package/dist/types/file.cjs.map +1 -1
  321. package/dist/types/file.d.cts +15 -2
  322. package/dist/types/file.d.cts.map +1 -1
  323. package/dist/types/file.d.ts +15 -2
  324. package/dist/types/file.d.ts.map +1 -1
  325. package/dist/types/file.js.map +1 -1
  326. package/dist/types/ids.cjs +30 -0
  327. package/dist/types/ids.cjs.map +1 -1
  328. package/dist/types/ids.d.cts +32 -0
  329. package/dist/types/ids.d.cts.map +1 -1
  330. package/dist/types/ids.d.ts +32 -0
  331. package/dist/types/ids.d.ts.map +1 -1
  332. package/dist/types/ids.js +28 -1
  333. package/dist/types/ids.js.map +1 -1
  334. package/dist/types/index.d.cts +10 -6
  335. package/dist/types/index.d.cts.map +1 -1
  336. package/dist/types/index.d.ts +10 -6
  337. package/dist/types/index.d.ts.map +1 -1
  338. package/dist/types/lock.cjs.map +1 -1
  339. package/dist/types/lock.d.cts +14 -0
  340. package/dist/types/lock.d.cts.map +1 -1
  341. package/dist/types/lock.d.ts +14 -0
  342. package/dist/types/lock.d.ts.map +1 -1
  343. package/dist/types/lock.js.map +1 -1
  344. package/dist/types/notifications.cjs +1 -1
  345. package/dist/types/notifications.cjs.map +1 -1
  346. package/dist/types/notifications.d.cts +5 -3
  347. package/dist/types/notifications.d.cts.map +1 -1
  348. package/dist/types/notifications.d.ts +5 -3
  349. package/dist/types/notifications.d.ts.map +1 -1
  350. package/dist/types/notifications.js +1 -1
  351. package/dist/types/notifications.js.map +1 -1
  352. package/dist/types/partner.cjs +32 -0
  353. package/dist/types/partner.cjs.map +1 -0
  354. package/dist/types/partner.d.cts +394 -0
  355. package/dist/types/partner.d.cts.map +1 -0
  356. package/dist/types/partner.d.ts +394 -0
  357. package/dist/types/partner.d.ts.map +1 -0
  358. package/dist/types/partner.js +29 -0
  359. package/dist/types/partner.js.map +1 -0
  360. package/dist/types/upload.d.cts +31 -18
  361. package/dist/types/upload.d.cts.map +1 -1
  362. package/dist/types/upload.d.ts +31 -18
  363. package/dist/types/upload.d.ts.map +1 -1
  364. package/dist/upload/abort-scope.cjs +0 -45
  365. package/dist/upload/abort-scope.cjs.map +1 -1
  366. package/dist/upload/abort-scope.d.cts +0 -22
  367. package/dist/upload/abort-scope.d.cts.map +1 -1
  368. package/dist/upload/abort-scope.d.ts +0 -22
  369. package/dist/upload/abort-scope.d.ts.map +1 -1
  370. package/dist/upload/abort-scope.js +1 -44
  371. package/dist/upload/abort-scope.js.map +1 -1
  372. package/dist/upload/finish.cjs +3 -8
  373. package/dist/upload/finish.cjs.map +1 -1
  374. package/dist/upload/finish.d.cts.map +1 -1
  375. package/dist/upload/finish.d.ts.map +1 -1
  376. package/dist/upload/finish.js +1 -6
  377. package/dist/upload/finish.js.map +1 -1
  378. package/dist/upload/large.cjs +5 -1
  379. package/dist/upload/large.cjs.map +1 -1
  380. package/dist/upload/large.d.cts +16 -2
  381. package/dist/upload/large.d.cts.map +1 -1
  382. package/dist/upload/large.d.ts +16 -2
  383. package/dist/upload/large.d.ts.map +1 -1
  384. package/dist/upload/large.js +5 -1
  385. package/dist/upload/large.js.map +1 -1
  386. package/dist/upload/options.cjs.map +1 -1
  387. package/dist/upload/options.d.cts +12 -0
  388. package/dist/upload/options.d.cts.map +1 -1
  389. package/dist/upload/options.d.ts +12 -0
  390. package/dist/upload/options.d.ts.map +1 -1
  391. package/dist/upload/options.js.map +1 -1
  392. package/dist/upload/resume.cjs +2 -1
  393. package/dist/upload/resume.cjs.map +1 -1
  394. package/dist/upload/resume.d.cts +3 -1
  395. package/dist/upload/resume.d.cts.map +1 -1
  396. package/dist/upload/resume.d.ts +3 -1
  397. package/dist/upload/resume.d.ts.map +1 -1
  398. package/dist/upload/resume.js +2 -1
  399. package/dist/upload/resume.js.map +1 -1
  400. package/dist/upload/retry.cjs +8 -3
  401. package/dist/upload/retry.cjs.map +1 -1
  402. package/dist/upload/retry.js +8 -3
  403. package/dist/upload/retry.js.map +1 -1
  404. package/dist/upload/single.cjs +2 -1
  405. package/dist/upload/single.cjs.map +1 -1
  406. package/dist/upload/single.d.cts +6 -0
  407. package/dist/upload/single.d.cts.map +1 -1
  408. package/dist/upload/single.d.ts +6 -0
  409. package/dist/upload/single.d.ts.map +1 -1
  410. package/dist/upload/single.js +2 -1
  411. package/dist/upload/single.js.map +1 -1
  412. package/dist/upload/stream.cjs +6 -4
  413. package/dist/upload/stream.cjs.map +1 -1
  414. package/dist/upload/stream.d.cts +6 -0
  415. package/dist/upload/stream.d.cts.map +1 -1
  416. package/dist/upload/stream.d.ts +6 -0
  417. package/dist/upload/stream.d.ts.map +1 -1
  418. package/dist/upload/stream.js +3 -1
  419. package/dist/upload/stream.js.map +1 -1
  420. package/dist/util/abort.cjs +114 -0
  421. package/dist/util/abort.cjs.map +1 -0
  422. package/dist/util/abort.d.cts +65 -0
  423. package/dist/util/abort.d.cts.map +1 -0
  424. package/dist/util/abort.d.ts +65 -0
  425. package/dist/util/abort.d.ts.map +1 -0
  426. package/dist/util/abort.js +109 -0
  427. package/dist/util/abort.js.map +1 -0
  428. package/dist/util/defaults.cjs +3 -0
  429. package/dist/util/defaults.cjs.map +1 -1
  430. package/dist/util/defaults.d.cts +2 -0
  431. package/dist/util/defaults.d.cts.map +1 -1
  432. package/dist/util/defaults.d.ts +2 -0
  433. package/dist/util/defaults.d.ts.map +1 -1
  434. package/dist/util/defaults.js +3 -1
  435. package/dist/util/defaults.js.map +1 -1
  436. package/dist/util/md5.cjs +211 -0
  437. package/dist/util/md5.cjs.map +1 -0
  438. package/dist/util/md5.d.cts +43 -0
  439. package/dist/util/md5.d.cts.map +1 -0
  440. package/dist/util/md5.d.ts +43 -0
  441. package/dist/util/md5.d.ts.map +1 -0
  442. package/dist/util/md5.js +209 -0
  443. package/dist/util/md5.js.map +1 -0
  444. package/dist/util/normalize.cjs +5 -5
  445. package/dist/util/normalize.cjs.map +1 -1
  446. package/dist/util/normalize.d.cts +7 -7
  447. package/dist/util/normalize.d.cts.map +1 -1
  448. package/dist/util/normalize.d.ts +7 -7
  449. package/dist/util/normalize.d.ts.map +1 -1
  450. package/dist/util/normalize.js +5 -5
  451. package/dist/util/normalize.js.map +1 -1
  452. package/dist/util/paginator.cjs +7 -1
  453. package/dist/util/paginator.cjs.map +1 -1
  454. package/dist/util/paginator.d.cts +3 -1
  455. package/dist/util/paginator.d.cts.map +1 -1
  456. package/dist/util/paginator.d.ts +3 -1
  457. package/dist/util/paginator.d.ts.map +1 -1
  458. package/dist/util/paginator.js +7 -1
  459. package/dist/util/paginator.js.map +1 -1
  460. package/package.json +38 -16
@@ -0,0 +1,206 @@
1
+ import { computerId } from "../types/ids.js";
2
+ import { B2PartnerAuthorizationError, BadJsonError } from "../errors/index.js";
3
+ import { paginateItems } from "../util/paginator.js";
4
+ import { PARTNER_TOKEN_REDACTED } from "../partner/redaction-placeholders.js";
5
+ import { PartnerAuthCore } from "../partner/auth-core.js";
6
+ import { BackupRawClient } from "./raw.js";
7
+ //#region src/backup/client.ts
8
+ var MASTER_KEY_REDACTED = "[redacted Master Application Key]";
9
+ function badListComputersResponse(message) {
10
+ return new BadJsonError({
11
+ status: 400,
12
+ code: "bad_json",
13
+ message: `bz_list_computers response did not match documented wire shape: ${message}`
14
+ });
15
+ }
16
+ function isRecord(value) {
17
+ return typeof value === "object" && value !== null;
18
+ }
19
+ function normalizeListComputersResponse(response) {
20
+ if (!isRecord(response) || Array.isArray(response)) throw badListComputersResponse("expected a JSON object");
21
+ const resultComputers = response["computers"];
22
+ if (!Array.isArray(resultComputers)) throw badListComputersResponse("response must include a computers array");
23
+ const cursor = response["nextComputerId"];
24
+ if (cursor !== null && typeof cursor !== "string") throw badListComputersResponse("response must include nextComputerId as string or null");
25
+ return {
26
+ nextComputerId: cursor === null ? null : computerId(cursor),
27
+ computers: resultComputers
28
+ };
29
+ }
30
+ /**
31
+ * High-level Computer Backup API client for listing and deleting backup records.
32
+ *
33
+ * The client uses Partner authorization and the `backupApiUrl` returned by
34
+ * `authorizePartner`. The target account must belong to a group with
35
+ * Enterprise Controls enabled, and the caller must be a group admin. Deleting
36
+ * a backup also requires the Enterprise Controls setting that permits admins
37
+ * to delete member backups.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const backup = new BackupClient({
42
+ * masterKeyId: process.env.B2_MASTER_KEY_ID,
43
+ * masterKey: process.env.B2_MASTER_KEY,
44
+ * })
45
+ * await backup.authorize()
46
+ * for await (const computer of backup.paginateComputers()) {
47
+ * console.log(computer.computerName)
48
+ * }
49
+ * ```
50
+ *
51
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
52
+ */
53
+ var BackupClient = class {
54
+ /** Low-level client for direct Computer Backup API calls. */
55
+ raw;
56
+ /** Partner authorization state storage (tokens, URLs, capabilities). */
57
+ partnerAccountInfo;
58
+ /**
59
+ * SSRF allow-list applied by the default transport. `null` when
60
+ * a custom transport was supplied; in that case the SDK does not own the
61
+ * guard.
62
+ */
63
+ urlGuard;
64
+ authCore;
65
+ /**
66
+ * Creates a new BackupClient. Call {@link authorize} before making API requests
67
+ * unless `partnerAccountInfo` already contains valid Partner authorization.
68
+ *
69
+ * @param options - Configuration including credentials, realm, and transport settings.
70
+ */
71
+ constructor(options) {
72
+ this.authCore = new PartnerAuthCore(options);
73
+ this.partnerAccountInfo = this.authCore.partnerAccountInfo;
74
+ this.urlGuard = this.authCore.urlGuard;
75
+ this.raw = new BackupRawClient({
76
+ transport: this.authCore.transport,
77
+ ...this.authCore.cachedEndpointSuffixes !== void 0 ? { authorizedBackupEndpointSuffixes: this.authCore.cachedEndpointSuffixes } : {}
78
+ });
79
+ }
80
+ /**
81
+ * Authenticates with B2 Partner authorization and stores the authorization state.
82
+ *
83
+ * @param options - Optional abort signal.
84
+ *
85
+ * @returns The Partner authorization response containing tokens, URLs, and capabilities.
86
+ *
87
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
88
+ */
89
+ async authorize(options) {
90
+ const auth = await this.authCore.authorize(options);
91
+ this.raw.setAuthorizedEndpointSuffixes(this.authCore.activateEndpointSuffixes(auth));
92
+ return auth;
93
+ }
94
+ /**
95
+ * Lists active Computer Backup records for an account.
96
+ *
97
+ * @param options - Optional target account and pagination settings.
98
+ *
99
+ * @returns A normalized page of computer backup records with an optional continuation cursor.
100
+ *
101
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
102
+ */
103
+ async listComputers(options) {
104
+ const auth = this.ensureBackupAuthorization();
105
+ const { backupApiUrl, authToken, accountId } = this.backupCoordinates(auth, options?.accountId);
106
+ return normalizeListComputersResponse(await this.raw.listComputers(backupApiUrl, authToken, {
107
+ accountId,
108
+ ...options?.startComputerId !== void 0 ? { startComputerId: options.startComputerId } : {},
109
+ ...options?.pageSize !== void 0 ? { maxComputerCount: options.pageSize } : {}
110
+ }, options?.signal !== void 0 ? { signal: options.signal } : void 0));
111
+ }
112
+ /**
113
+ * Async iterator that yields every active Computer Backup record for an account.
114
+ *
115
+ * @param options - Optional target account, page size, and abort signal.
116
+ *
117
+ * @returns An async iterable of {@link ComputerBackup} entries.
118
+ *
119
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
120
+ */
121
+ paginateComputers(options) {
122
+ return paginateItems(async (cursor) => {
123
+ const resp = await this.listComputers({
124
+ ...options?.accountId !== void 0 ? { accountId: options.accountId } : {},
125
+ ...options?.pageSize !== void 0 ? { pageSize: options.pageSize } : {},
126
+ ...cursor !== void 0 ? { startComputerId: cursor } : {},
127
+ ...options?.signal !== void 0 ? { signal: options.signal } : {}
128
+ });
129
+ return {
130
+ page: resp,
131
+ nextCursor: resp.nextComputerId ?? void 0
132
+ };
133
+ }, (page) => page.computers, options?.signal);
134
+ }
135
+ /**
136
+ * Deletes a Computer Backup record.
137
+ *
138
+ * This destructive mutation is not automatically retried or reauthorized in
139
+ * place; callers should reconcile backup state before issuing a new delete
140
+ * after an ambiguous failure.
141
+ *
142
+ * @param options - Target account, computer ID, and optional abort signal.
143
+ *
144
+ * @returns The deleted computer backup record array.
145
+ *
146
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
147
+ */
148
+ async deleteComputer(options) {
149
+ const auth = this.ensureBackupAuthorization();
150
+ const { backupApiUrl, authToken, accountId } = this.backupCoordinates(auth, options.accountId);
151
+ return this.raw.deleteComputer(backupApiUrl, authToken, {
152
+ accountId,
153
+ computerId: options.computerId
154
+ }, options.signal !== void 0 ? { signal: options.signal } : void 0);
155
+ }
156
+ ensureBackupAuthorization() {
157
+ const auth = this.partnerAccountInfo.getAuth();
158
+ if (auth === null) throw new B2PartnerAuthorizationError("Not authorized. Call BackupClient.authorize() first.");
159
+ const suffixes = this.authCore.activateEndpointSuffixes(auth);
160
+ this.raw.setAuthorizedEndpointSuffixes(suffixes);
161
+ return auth;
162
+ }
163
+ backupCoordinates(auth, accountIdOverride) {
164
+ const backupApiUrl = auth.apiInfo.backupApi?.backupApiUrl;
165
+ if (backupApiUrl === void 0) throw new B2PartnerAuthorizationError("Computer Backup API is not available; Partner authorization did not return apiInfo.backupApi.");
166
+ return {
167
+ backupApiUrl,
168
+ authToken: auth.authorizationToken,
169
+ accountId: accountIdOverride ?? auth.accountId
170
+ };
171
+ }
172
+ /**
173
+ * Hides credentials and Partner tokens from `JSON.stringify(client)`.
174
+ *
175
+ * @returns A redacted diagnostic object.
176
+ */
177
+ toJSON() {
178
+ return {
179
+ type: "BackupClient",
180
+ credentials: MASTER_KEY_REDACTED,
181
+ authorization: this.partnerAccountInfo.getAuth() === null ? "[unauthorized]" : PARTNER_TOKEN_REDACTED,
182
+ authorized: this.partnerAccountInfo.getAuth() !== null,
183
+ urlGuardAllowedSuffixes: this.urlGuard?.getAllowedSuffixes() ?? null
184
+ };
185
+ }
186
+ /**
187
+ * Hides credentials and Partner tokens from default stringification.
188
+ *
189
+ * @returns A short redacted label.
190
+ */
191
+ toString() {
192
+ return `[BackupClient ${MASTER_KEY_REDACTED}]`;
193
+ }
194
+ /**
195
+ * Hides credentials and Partner tokens from Node's `util.inspect`.
196
+ *
197
+ * @returns A short redacted label.
198
+ */
199
+ [Symbol.for("nodejs.util.inspect.custom")]() {
200
+ return this.toString();
201
+ }
202
+ };
203
+ //#endregion
204
+ export { BackupClient };
205
+
206
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/backup/client.ts"],"sourcesContent":["import { B2PartnerAuthorizationError, BadJsonError } from '../errors/index.ts'\nimport type { RetryOptions } from '../http/retry.ts'\nimport type { HttpTransport } from '../http/transport.ts'\nimport type { UrlGuard } from '../http/url-guard.ts'\nimport type { PartnerAccountInfo } from '../partner/account-info.ts'\nimport { PartnerAuthCore } from '../partner/auth-core.ts'\nimport { PARTNER_TOKEN_REDACTED } from '../partner/redaction.ts'\nimport type {\n ComputerBackup,\n DeleteComputerResponse,\n ListComputersResponse,\n ListComputersResult,\n} from '../types/backup.ts'\nimport { type AccountId, type ComputerId, computerId, type PartnerToken } from '../types/ids.ts'\nimport type { PartnerAuthorizeResponse } from '../types/partner.ts'\nimport { paginateItems } from '../util/paginator.ts'\nimport { BackupRawClient } from './raw.ts'\n\nconst MASTER_KEY_REDACTED = '[redacted Master Application Key]'\n\n/**\n * Configuration options for creating a {@link BackupClient}.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\nexport interface BackupClientOptions {\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 /**\n * B2 realm to authenticate against. Accepts a known realm-map key\n * (`\"production\"` or `\"staging\"`) or a direct base URL. Custom HTTPS hosts\n * and loopback IP literal HTTP URLs for local testing are trusted with the\n * Master Application Key during Partner authorize, so never derive `realm`\n * from untrusted input. Defaults to `\"production\"`.\n */\n readonly realm?: string\n /**\n * Shared Partner authorization state. Defaults to\n * {@link InMemoryPartnerAccountInfo}. Pass the same store to\n * {@link BackupClient} and Partner clients when both surfaces should reuse\n * one Partner token. Cached authorization whose endpoints fail this client's\n * realm policy is ignored locally until `authorize()` replaces it; shared\n * stores are not cleared during construction.\n */\n readonly partnerAccountInfo?: PartnerAccountInfo\n /** Custom HTTP transport. Defaults to `FetchTransport`. Wrapped by `RetryTransport`. */\n readonly transport?: HttpTransport\n /** Override retry behavior (max retries, backoff, and per-attempt timeout). */\n readonly retry?: Partial<RetryOptions>\n /** Custom user-agent string prepended to the SDK default. */\n readonly userAgent?: string\n /**\n * Additional SSRF allow-list host suffixes for the default transport.\n *\n * Only consulted when {@link BackupClientOptions.transport} is unset; a\n * custom transport is the user's responsibility to harden.\n */\n readonly additionalAllowedHostSuffixes?: readonly string[]\n /**\n * Explicitly disable the default SSRF guard after authorize.\n *\n * Intended only for controlled simulator/private-proxy tests. Never enable\n * it for URLs derived from untrusted input or production credentials.\n */\n readonly disableSsrfGuard?: boolean\n /**\n * Follow same-origin GET/HEAD redirects in the default fetch transport after\n * checking each target with the SSRF guard. POST redirects remain blocked.\n * Defaults to true.\n */\n readonly followSameOriginRedirects?: boolean\n /**\n * Allow direct custom authorize realms for tests or private proxies.\n * Leave disabled unless the configured host is trusted with the Master\n * Application Key.\n */\n readonly allowCustomAuthorizeRealm?: boolean\n}\n\n/**\n * Options for Partner authorization performed by {@link BackupClient}.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\nexport interface BackupAuthorizeOptions {\n /** Abort signal for cancelling the authorize request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for listing Computer Backup records.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\nexport interface ListComputersOptions {\n /**\n * Account whose active computer backups should be listed. Defaults to the\n * partner administrator account ID from authorization.\n */\n readonly accountId?: AccountId\n /** Computer ID to start listing from for pagination. */\n readonly startComputerId?: ComputerId\n /** Maximum computers to return in this page. Forwarded to `maxComputerCount`. */\n readonly pageSize?: number\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for paginating Computer Backup records.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\nexport interface PaginateComputersOptions extends Omit<ListComputersOptions, 'startComputerId'> {\n /**\n * Aborts the iteration between page fetches. The signal is also forwarded to\n * each underlying list request.\n */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for deleting a Computer Backup record.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\nexport interface DeleteComputerOptions {\n /**\n * Account that owns the computer backup. Defaults to the partner\n * administrator account ID from authorization.\n */\n readonly accountId?: AccountId\n /** Computer ID of the backup to delete. */\n readonly computerId: ComputerId\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\ninterface BackupCoordinates {\n readonly backupApiUrl: string\n readonly authToken: PartnerToken\n readonly accountId: AccountId\n}\n\nfunction badListComputersResponse(message: string): BadJsonError {\n return new BadJsonError({\n status: 400,\n code: 'bad_json',\n message: `bz_list_computers response did not match documented wire shape: ${message}`,\n })\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === 'object' && value !== null\n}\n\nfunction normalizeListComputersResponse(response: ListComputersResponse): ListComputersResult {\n // Archived Backup API docs model bz_list_computers as a single result object\n // with a pagination cursor and a `computers` array (an empty account returns\n // an empty `computers` array, not a top-level empty array).\n if (!isRecord(response) || Array.isArray(response)) {\n throw badListComputersResponse('expected a JSON object')\n }\n const resultComputers = response['computers']\n if (!Array.isArray(resultComputers)) {\n throw badListComputersResponse('response must include a computers array')\n }\n const cursor = response['nextComputerId']\n if (cursor !== null && typeof cursor !== 'string') {\n throw badListComputersResponse('response must include nextComputerId as string or null')\n }\n\n return {\n nextComputerId: cursor === null ? null : computerId(cursor),\n computers: resultComputers as readonly ComputerBackup[],\n }\n}\n\n/** Redacted JSON diagnostic shape emitted by {@link BackupClient.toJSON}. */\nexport interface BackupClientJson {\n /** Object kind for log consumers. */\n readonly type: 'BackupClient'\n /** Redacted Master Application Key credential placeholder. */\n readonly credentials: string\n /** Redacted Partner token placeholder, or unauthorized state. */\n readonly authorization: string\n /** Whether this client currently has Partner authorization state. */\n readonly authorized: boolean\n /** Current default URL guard suffixes, or null when a custom transport owns guarding. */\n readonly urlGuardAllowedSuffixes: readonly string[] | null\n}\n\n/**\n * High-level Computer Backup API client for listing and deleting backup records.\n *\n * The client uses Partner authorization and the `backupApiUrl` returned by\n * `authorizePartner`. The target account must belong to a group with\n * Enterprise Controls enabled, and the caller must be a group admin. Deleting\n * a backup also requires the Enterprise Controls setting that permits admins\n * to delete member backups.\n *\n * @example\n * ```ts\n * const backup = new BackupClient({\n * masterKeyId: process.env.B2_MASTER_KEY_ID,\n * masterKey: process.env.B2_MASTER_KEY,\n * })\n * await backup.authorize()\n * for await (const computer of backup.paginateComputers()) {\n * console.log(computer.computerName)\n * }\n * ```\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\nexport class BackupClient {\n /** Low-level client for direct Computer Backup API calls. */\n readonly raw: BackupRawClient\n /** Partner authorization state storage (tokens, URLs, capabilities). */\n readonly partnerAccountInfo: PartnerAccountInfo\n /**\n * SSRF allow-list applied by the default transport. `null` when\n * a custom transport was supplied; in that case the SDK does not own the\n * guard.\n */\n readonly urlGuard: UrlGuard | null\n private readonly authCore: PartnerAuthCore\n\n /**\n * Creates a new BackupClient. Call {@link authorize} before making API requests\n * unless `partnerAccountInfo` already contains valid Partner authorization.\n *\n * @param options - Configuration including credentials, realm, and transport settings.\n */\n constructor(options: BackupClientOptions) {\n this.authCore = new PartnerAuthCore(options)\n this.partnerAccountInfo = this.authCore.partnerAccountInfo\n this.urlGuard = this.authCore.urlGuard\n this.raw = new BackupRawClient({\n transport: this.authCore.transport,\n ...(this.authCore.cachedEndpointSuffixes !== undefined\n ? { authorizedBackupEndpointSuffixes: this.authCore.cachedEndpointSuffixes }\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 Partner authorization response containing tokens, URLs, and capabilities.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\n async authorize(options?: BackupAuthorizeOptions): Promise<PartnerAuthorizeResponse> {\n const auth = await this.authCore.authorize(options)\n this.raw.setAuthorizedEndpointSuffixes(this.authCore.activateEndpointSuffixes(auth))\n return auth\n }\n\n /**\n * Lists active Computer Backup records for an account.\n *\n * @param options - Optional target account and pagination settings.\n *\n * @returns A normalized page of computer backup records with an optional continuation cursor.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\n async listComputers(options?: ListComputersOptions): Promise<ListComputersResult> {\n const auth = this.ensureBackupAuthorization()\n const { backupApiUrl, authToken, accountId } = this.backupCoordinates(auth, options?.accountId)\n const response = await this.raw.listComputers(\n backupApiUrl,\n authToken,\n {\n accountId,\n ...(options?.startComputerId !== undefined\n ? { startComputerId: options.startComputerId }\n : {}),\n ...(options?.pageSize !== undefined ? { maxComputerCount: options.pageSize } : {}),\n },\n options?.signal !== undefined ? { signal: options.signal } : undefined,\n )\n return normalizeListComputersResponse(response)\n }\n\n /**\n * Async iterator that yields every active Computer Backup record for an account.\n *\n * @param options - Optional target account, page size, and abort signal.\n *\n * @returns An async iterable of {@link ComputerBackup} entries.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\n paginateComputers(options?: PaginateComputersOptions): AsyncIterableIterator<ComputerBackup> {\n return paginateItems(\n async (cursor: ComputerId | undefined) => {\n const resp = await this.listComputers({\n ...(options?.accountId !== undefined ? { accountId: options.accountId } : {}),\n ...(options?.pageSize !== undefined ? { pageSize: options.pageSize } : {}),\n ...(cursor !== undefined ? { startComputerId: cursor } : {}),\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n })\n return { page: resp, nextCursor: resp.nextComputerId ?? undefined }\n },\n (page) => page.computers,\n options?.signal,\n )\n }\n\n /**\n * Deletes a Computer Backup record.\n *\n * This destructive mutation is not automatically retried or reauthorized in\n * place; callers should reconcile backup state before issuing a new delete\n * after an ambiguous failure.\n *\n * @param options - Target account, computer ID, and optional abort signal.\n *\n * @returns The deleted computer backup record array.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\n async deleteComputer(options: DeleteComputerOptions): Promise<DeleteComputerResponse> {\n const auth = this.ensureBackupAuthorization()\n const { backupApiUrl, authToken, accountId } = this.backupCoordinates(auth, options.accountId)\n return this.raw.deleteComputer(\n backupApiUrl,\n authToken,\n {\n accountId,\n computerId: options.computerId,\n },\n options.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n private ensureBackupAuthorization(): PartnerAuthorizeResponse {\n const auth = this.partnerAccountInfo.getAuth()\n if (auth === null) {\n throw new B2PartnerAuthorizationError('Not authorized. Call BackupClient.authorize() first.')\n }\n const suffixes = this.authCore.activateEndpointSuffixes(auth)\n this.raw.setAuthorizedEndpointSuffixes(suffixes)\n return auth\n }\n\n private backupCoordinates(\n auth: PartnerAuthorizeResponse,\n accountIdOverride: AccountId | undefined,\n ): BackupCoordinates {\n const backupApiUrl = auth.apiInfo.backupApi?.backupApiUrl\n if (backupApiUrl === undefined) {\n throw new B2PartnerAuthorizationError(\n 'Computer Backup API is not available; Partner authorization did not return apiInfo.backupApi.',\n )\n }\n return {\n backupApiUrl,\n authToken: auth.authorizationToken,\n accountId: accountIdOverride ?? auth.accountId,\n }\n }\n\n /**\n * Hides credentials and Partner tokens from `JSON.stringify(client)`.\n *\n * @returns A redacted diagnostic object.\n */\n toJSON(): BackupClientJson {\n return {\n type: 'BackupClient',\n credentials: MASTER_KEY_REDACTED,\n authorization:\n this.partnerAccountInfo.getAuth() === null ? '[unauthorized]' : PARTNER_TOKEN_REDACTED,\n authorized: this.partnerAccountInfo.getAuth() !== null,\n urlGuardAllowedSuffixes: this.urlGuard?.getAllowedSuffixes() ?? null,\n }\n }\n\n /**\n * Hides credentials and Partner tokens from default stringification.\n *\n * @returns A short redacted label.\n */\n toString(): string {\n return `[BackupClient ${MASTER_KEY_REDACTED}]`\n }\n\n /**\n * Hides credentials and Partner tokens from Node's `util.inspect`.\n *\n * @returns A short redacted label.\n */\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n"],"mappings":";;;;;;;AAkBA,IAAM,sBAAsB;AAgI5B,SAAS,yBAAyB,SAA+B;CAC/D,OAAO,IAAI,aAAa;EACtB,QAAQ;EACR,MAAM;EACN,SAAS,mEAAmE;CAC9E,CAAC;AACH;AAEA,SAAS,SAAS,OAA4D;CAC5E,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD;AAEA,SAAS,+BAA+B,UAAsD;CAI5F,IAAI,CAAC,SAAS,QAAQ,KAAK,MA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,WAAW,qBAAqB,KAAK;EACvC;CACF;;;;;;CAOA,SAA2B;EACzB,OAAO;GACL,MAAM;GACN,aAAa;GACb,eACE,KAAK,mBAAmB,QAAQ,MAAM,OAAO,mBAAmB;GAClE,YAAY,KAAK,mBAAmB,QAAQ,MAAM;GAClD,yBAAyB,KAAK,UAAU,mBAAmB,KAAK;EAClE;CACF;;;;;;CAOA,WAAmB;EACjB,OAAO,iBAAiB,oBAAoB;CAC9C;;;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;AACF"}
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_ids = require("../types/ids.cjs");
3
+ const require_partner = require("../types/partner.cjs");
4
+ const require_auth_clone = require("../partner/auth-clone.cjs");
5
+ const require_in_memory = require("../partner/in-memory.cjs");
6
+ const require_raw = require("./raw.cjs");
7
+ const require_client = require("./client.cjs");
8
+ exports.BackupClient = require_client.BackupClient;
9
+ exports.BackupRawClient = require_raw.BackupRawClient;
10
+ exports.InMemoryPartnerAccountInfo = require_in_memory.InMemoryPartnerAccountInfo;
11
+ exports.PartnerCapability = require_partner.PartnerCapability;
12
+ exports.accountId = require_ids.accountId;
13
+ exports.computerId = require_ids.computerId;
14
+ exports.partnerAuthorizeResponseForPersistence = require_auth_clone.partnerAuthorizeResponseForPersistence;
15
+ exports.partnerToken = require_ids.partnerToken;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Computer Backup API client, raw bindings, and types for listing and deleting
3
+ * backup records.
4
+ *
5
+ * Use this subpath when your account has sales-approved Partner API access,
6
+ * a Master Application Key, and Enterprise Controls enabled for the target
7
+ * group. The Backup client shares the Partner authorization model and uses the
8
+ * `backupApiUrl` returned by Partner authorization.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ export type { PartnerAccountInfo } from '../partner/account-info.js';
13
+ export { partnerAuthorizeResponseForPersistence } from '../partner/auth-clone.js';
14
+ export { InMemoryPartnerAccountInfo } from '../partner/in-memory.js';
15
+ export type { ComputerBackup, DeleteComputerRequest, DeleteComputerResponse, DeleteComputerResult, ListComputersRequest, ListComputersResponse, ListComputersResult, } from '../types/backup.js';
16
+ export type { AccountId, ComputerId, PartnerToken } from '../types/ids.js';
17
+ export { accountId, computerId, partnerToken } from '../types/ids.js';
18
+ export type { PartnerApiInfo, PartnerAuthorizeResponse, PartnerBackupApiInfo, } from '../types/partner.js';
19
+ export { PartnerCapability } from '../types/partner.js';
20
+ export { type BackupAuthorizeOptions, BackupClient, type BackupClientJson, type BackupClientOptions, type DeleteComputerOptions, type ListComputersOptions, type PaginateComputersOptions, } from './client.js';
21
+ export { BackupRawClient, type BackupRawClientOptions, type BackupRawRequestOptions, } from './raw.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backup/index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,sCAAsC,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AACpE,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACrE,YAAY,EACV,cAAc,EACd,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EACL,KAAK,sBAAsB,EAC3B,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,UAAU,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Computer Backup API client, raw bindings, and types for listing and deleting
3
+ * backup records.
4
+ *
5
+ * Use this subpath when your account has sales-approved Partner API access,
6
+ * a Master Application Key, and Enterprise Controls enabled for the target
7
+ * group. The Backup client shares the Partner authorization model and uses the
8
+ * `backupApiUrl` returned by Partner authorization.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ export type { PartnerAccountInfo } from '../partner/account-info.js';
13
+ export { partnerAuthorizeResponseForPersistence } from '../partner/auth-clone.js';
14
+ export { InMemoryPartnerAccountInfo } from '../partner/in-memory.js';
15
+ export type { ComputerBackup, DeleteComputerRequest, DeleteComputerResponse, DeleteComputerResult, ListComputersRequest, ListComputersResponse, ListComputersResult, } from '../types/backup.js';
16
+ export type { AccountId, ComputerId, PartnerToken } from '../types/ids.js';
17
+ export { accountId, computerId, partnerToken } from '../types/ids.js';
18
+ export type { PartnerApiInfo, PartnerAuthorizeResponse, PartnerBackupApiInfo, } from '../types/partner.js';
19
+ export { PartnerCapability } from '../types/partner.js';
20
+ export { type BackupAuthorizeOptions, BackupClient, type BackupClientJson, type BackupClientOptions, type DeleteComputerOptions, type ListComputersOptions, type PaginateComputersOptions, } from './client.js';
21
+ export { BackupRawClient, type BackupRawClientOptions, type BackupRawRequestOptions, } from './raw.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backup/index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,sCAAsC,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AACpE,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACrE,YAAY,EACV,cAAc,EACd,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EACL,KAAK,sBAAsB,EAC3B,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,UAAU,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { accountId, computerId, partnerToken } from "../types/ids.js";
2
+ import { PartnerCapability } from "../types/partner.js";
3
+ import { partnerAuthorizeResponseForPersistence } from "../partner/auth-clone.js";
4
+ import { InMemoryPartnerAccountInfo } from "../partner/in-memory.js";
5
+ import { BackupRawClient } from "./raw.js";
6
+ import { BackupClient } from "./client.js";
7
+ export { BackupClient, BackupRawClient, InMemoryPartnerAccountInfo, PartnerCapability, accountId, computerId, partnerAuthorizeResponseForPersistence, partnerToken };
@@ -0,0 +1,146 @@
1
+ const require_url = require("../raw/url.cjs");
2
+ const require_endpoint_url = require("../partner/endpoint-url.cjs");
3
+ //#region src/backup/raw.ts
4
+ var BACKUP_API_V1 = {
5
+ prefix: "api/backup",
6
+ version: "v1"
7
+ };
8
+ function backupEndpointAllowedSuffixes(transport, authorizedSuffixes) {
9
+ return require_endpoint_url.endpointAllowedSuffixes(transport, authorizedSuffixes, {
10
+ missingGuard: "Computer Backup endpoint requests require BackupClient.authorize() or a locked URL guard before sending Partner tokens",
11
+ unlockedGuard: "Computer Backup endpoint requests require a locked URL guard before sending Partner tokens"
12
+ });
13
+ }
14
+ /**
15
+ * Low-level client for Computer Backup API endpoint bindings.
16
+ *
17
+ * Each method maps directly to one `bz_*` HTTP call under the
18
+ * `/api/backup/v1/` route using the `backupApiUrl` returned by Partner
19
+ * authorization.
20
+ *
21
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
22
+ */
23
+ var BackupRawClient = class {
24
+ /** @internal */
25
+ transport;
26
+ authorizedEndpointSuffixes;
27
+ /**
28
+ * Creates a new BackupRawClient with the given transport.
29
+ *
30
+ * @param options - The constructor configuration.
31
+ */
32
+ constructor(options) {
33
+ this.transport = options.transport;
34
+ this.authorizedEndpointSuffixes = Array.from(options.authorizedBackupEndpointSuffixes ?? []);
35
+ }
36
+ /**
37
+ * Replaces the validated Computer Backup endpoint host suffixes.
38
+ *
39
+ * @param suffixes - Host suffixes derived from Partner authorization.
40
+ *
41
+ * @internal
42
+ */
43
+ setAuthorizedEndpointSuffixes(suffixes) {
44
+ this.authorizedEndpointSuffixes = Array.from(suffixes);
45
+ }
46
+ /**
47
+ * Calls `bz_list_computers`.
48
+ *
49
+ * Uses the documented GET form. The wire response is a single JSON object
50
+ * with a `nextComputerId` cursor and active computer backup records.
51
+ *
52
+ * @param backupApiUrl - The Computer Backup API base URL from `authorizePartner`.
53
+ * @param authToken - The Partner authorization token.
54
+ * @param request - The computer listing query parameters.
55
+ * @param options - Optional abort and per-request retry settings.
56
+ *
57
+ * @returns The single-object computer backup wire response.
58
+ *
59
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
60
+ */
61
+ async listComputers(backupApiUrl, authToken, request, options) {
62
+ return this.getJson(backupApiUrl, authToken, "bz_list_computers", {
63
+ accountId: request.accountId,
64
+ ...request.startComputerId !== void 0 ? { startComputerId: request.startComputerId } : {},
65
+ ...request.maxComputerCount !== void 0 ? { maxComputerCount: request.maxComputerCount } : {}
66
+ }, options);
67
+ }
68
+ /**
69
+ * Calls `bz_delete_computer`.
70
+ *
71
+ * The documented wire response is a JSON array of deletion records. This
72
+ * destructive mutation is not automatically retried or reauthorized in place.
73
+ *
74
+ * @param backupApiUrl - The Computer Backup API base URL from `authorizePartner`.
75
+ * @param authToken - The Partner authorization token.
76
+ * @param request - The computer deletion request body.
77
+ * @param options - Optional abort and per-request retry settings.
78
+ *
79
+ * @returns The deleted computer backup record array.
80
+ *
81
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
82
+ */
83
+ async deleteComputer(backupApiUrl, authToken, request, options) {
84
+ return this.postJson(backupApiUrl, authToken, "bz_delete_computer", {
85
+ accountId: request.accountId,
86
+ computerId: request.computerId
87
+ }, require_endpoint_url.nonRetryingMutationRequestOptions(options));
88
+ }
89
+ safeBackupApiUrl(backupApiUrl) {
90
+ return require_endpoint_url.validatePartnerEndpointUrl(backupApiUrl, "backupApiUrl", backupEndpointAllowedSuffixes(this.transport, this.authorizedEndpointSuffixes));
91
+ }
92
+ /**
93
+ * Sends a JSON GET request to the specified Computer Backup API endpoint.
94
+ *
95
+ * @param backupApiUrl - The Computer Backup API base URL.
96
+ * @param authToken - The Partner authorization token.
97
+ * @param endpoint - The Computer Backup API endpoint name.
98
+ * @param query - The query-string parameters.
99
+ * @param options - Optional abort and per-request retry settings.
100
+ *
101
+ * @returns The parsed JSON response.
102
+ */
103
+ async getJson(backupApiUrl, authToken, endpoint, query, options) {
104
+ return (await this.transport.send({
105
+ url: require_endpoint_url.withQueryString(require_url.b2Url(this.safeBackupApiUrl(backupApiUrl), {
106
+ ...BACKUP_API_V1,
107
+ endpoint
108
+ }), query),
109
+ method: "GET",
110
+ headers: { Authorization: authToken },
111
+ ...options?.signal !== void 0 ? { signal: options.signal } : {},
112
+ ...options?.retry !== void 0 ? { retry: options.retry } : {}
113
+ })).json();
114
+ }
115
+ /**
116
+ * Sends a JSON POST request to the specified Computer Backup API endpoint.
117
+ *
118
+ * @param backupApiUrl - The Computer Backup API base URL.
119
+ * @param authToken - The Partner authorization token.
120
+ * @param endpoint - The Computer Backup API endpoint name.
121
+ * @param body - The JSON request body.
122
+ * @param options - Optional abort and per-request retry settings.
123
+ *
124
+ * @returns The parsed JSON response.
125
+ */
126
+ async postJson(backupApiUrl, authToken, endpoint, body, options) {
127
+ return (await this.transport.send({
128
+ url: require_url.b2Url(this.safeBackupApiUrl(backupApiUrl), {
129
+ ...BACKUP_API_V1,
130
+ endpoint
131
+ }),
132
+ method: "POST",
133
+ headers: {
134
+ Authorization: authToken,
135
+ "Content-Type": "application/json"
136
+ },
137
+ body: JSON.stringify(body),
138
+ ...options?.signal !== void 0 ? { signal: options.signal } : {},
139
+ ...options?.retry !== void 0 ? { retry: options.retry } : {}
140
+ })).json();
141
+ }
142
+ };
143
+ //#endregion
144
+ exports.BackupRawClient = BackupRawClient;
145
+
146
+ //# sourceMappingURL=raw.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw.cjs","names":[],"sources":["../../src/backup/raw.ts"],"sourcesContent":["import type { RetryOptions } from '../http/retry.ts'\nimport type { HttpTransport } from '../http/transport.ts'\nimport {\n endpointAllowedSuffixes,\n nonRetryingMutationRequestOptions,\n type QueryParams,\n validatePartnerEndpointUrl,\n withQueryString,\n} from '../partner/endpoint-url.ts'\nimport { type B2EndpointUrlOptions, b2Url } from '../raw/url.ts'\nimport type {\n DeleteComputerRequest,\n DeleteComputerResponse,\n ListComputersRequest,\n ListComputersResponse,\n} from '../types/backup.ts'\n\nconst BACKUP_API_V1: B2EndpointUrlOptions = { prefix: 'api/backup', version: 'v1' }\n\n/** Configuration for constructing a {@link BackupRawClient}. */\nexport interface BackupRawClientOptions {\n /**\n * The HTTP transport used to send requests.\n *\n * Computer Backup endpoint calls validate URLs against suffixes recorded by\n * Partner authorization. A rehydrated client that skips authorization must\n * use `authorizedBackupEndpointSuffixes` or a transport with a locked\n * `urlGuard`. Because Partner authorize responses redact\n * `authorizationToken` under `JSON.stringify`, durable caches should persist\n * `partnerAuthorizeResponseForPersistence(auth)` only to encrypted or\n * otherwise credential-grade storage, or use another secure token-preserving\n * representation.\n */\n readonly transport: HttpTransport\n /**\n * Validated Computer Backup endpoint host suffixes restored from cached\n * Partner authorization. Facades normally manage this after authorization;\n * direct raw clients can pass trusted suffixes derived from\n * `derivePartnerAllowedSuffixes()`. Do not derive this cache with\n * `JSON.stringify(authorizePartner())`, which intentionally stores a redacted\n * token placeholder instead of a usable Partner token. Rehydrating that\n * placeholder fails fast.\n */\n readonly authorizedBackupEndpointSuffixes?: readonly string[]\n}\n\n/** Optional controls for raw Computer Backup API requests. */\nexport interface BackupRawRequestOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n /** Per-request retry override. */\n readonly retry?: Partial<RetryOptions>\n}\n\nfunction backupEndpointAllowedSuffixes(\n transport: HttpTransport,\n authorizedSuffixes: readonly string[],\n): readonly string[] {\n return endpointAllowedSuffixes(transport, authorizedSuffixes, {\n missingGuard:\n 'Computer Backup endpoint requests require BackupClient.authorize() or a locked URL guard before sending Partner tokens',\n unlockedGuard:\n 'Computer Backup endpoint requests require a locked URL guard before sending Partner tokens',\n })\n}\n\n/**\n * Low-level client for Computer Backup API endpoint bindings.\n *\n * Each method maps directly to one `bz_*` HTTP call under the\n * `/api/backup/v1/` route using the `backupApiUrl` returned by Partner\n * authorization.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\nexport class BackupRawClient {\n /** @internal */\n private readonly transport: HttpTransport\n private authorizedEndpointSuffixes: readonly string[]\n\n /**\n * Creates a new BackupRawClient with the given transport.\n *\n * @param options - The constructor configuration.\n */\n constructor(options: BackupRawClientOptions) {\n this.transport = options.transport\n this.authorizedEndpointSuffixes = Array.from(options.authorizedBackupEndpointSuffixes ?? [])\n }\n\n /**\n * Replaces the validated Computer Backup endpoint host suffixes.\n *\n * @param suffixes - Host suffixes derived from Partner authorization.\n *\n * @internal\n */\n setAuthorizedEndpointSuffixes(suffixes: readonly string[]): void {\n this.authorizedEndpointSuffixes = Array.from(suffixes)\n }\n\n /**\n * Calls `bz_list_computers`.\n *\n * Uses the documented GET form. The wire response is a single JSON object\n * with a `nextComputerId` cursor and active computer backup records.\n *\n * @param backupApiUrl - The Computer Backup API base URL from `authorizePartner`.\n * @param authToken - The Partner authorization token.\n * @param request - The computer listing query parameters.\n * @param options - Optional abort and per-request retry settings.\n *\n * @returns The single-object computer backup wire response.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\n async listComputers(\n backupApiUrl: string,\n authToken: string,\n request: ListComputersRequest,\n options?: BackupRawRequestOptions,\n ): Promise<ListComputersResponse> {\n return this.getJson<ListComputersResponse>(\n backupApiUrl,\n authToken,\n 'bz_list_computers',\n {\n accountId: request.accountId,\n ...(request.startComputerId !== undefined\n ? { startComputerId: request.startComputerId }\n : {}),\n ...(request.maxComputerCount !== undefined\n ? { maxComputerCount: request.maxComputerCount }\n : {}),\n },\n options,\n )\n }\n\n /**\n * Calls `bz_delete_computer`.\n *\n * The documented wire response is a JSON array of deletion records. This\n * destructive mutation is not automatically retried or reauthorized in place.\n *\n * @param backupApiUrl - The Computer Backup API base URL from `authorizePartner`.\n * @param authToken - The Partner authorization token.\n * @param request - The computer deletion request body.\n * @param options - Optional abort and per-request retry settings.\n *\n * @returns The deleted computer backup record array.\n *\n * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.\n */\n async deleteComputer(\n backupApiUrl: string,\n authToken: string,\n request: DeleteComputerRequest,\n options?: BackupRawRequestOptions,\n ): Promise<DeleteComputerResponse> {\n return this.postJson<DeleteComputerResponse>(\n backupApiUrl,\n authToken,\n 'bz_delete_computer',\n {\n accountId: request.accountId,\n computerId: request.computerId,\n },\n nonRetryingMutationRequestOptions(options),\n )\n }\n\n private safeBackupApiUrl(backupApiUrl: string): string {\n return validatePartnerEndpointUrl(\n backupApiUrl,\n 'backupApiUrl',\n backupEndpointAllowedSuffixes(this.transport, this.authorizedEndpointSuffixes),\n )\n }\n\n /**\n * Sends a JSON GET request to the specified Computer Backup API endpoint.\n *\n * @param backupApiUrl - The Computer Backup API base URL.\n * @param authToken - The Partner authorization token.\n * @param endpoint - The Computer Backup API endpoint name.\n * @param query - The query-string parameters.\n * @param options - Optional abort and per-request retry settings.\n *\n * @returns The parsed JSON response.\n */\n private async getJson<T>(\n backupApiUrl: string,\n authToken: string,\n endpoint: string,\n query: QueryParams,\n options?: BackupRawRequestOptions,\n ): Promise<T> {\n const response = await this.transport.send({\n url: withQueryString(\n b2Url(this.safeBackupApiUrl(backupApiUrl), { ...BACKUP_API_V1, endpoint }),\n query,\n ),\n method: 'GET',\n headers: {\n Authorization: authToken,\n },\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n ...(options?.retry !== undefined ? { retry: options.retry } : {}),\n })\n return response.json<T>()\n }\n\n /**\n * Sends a JSON POST request to the specified Computer Backup API endpoint.\n *\n * @param backupApiUrl - The Computer Backup API base URL.\n * @param authToken - The Partner authorization token.\n * @param endpoint - The Computer Backup API endpoint name.\n * @param body - The JSON request body.\n * @param options - Optional abort and per-request retry settings.\n *\n * @returns The parsed JSON response.\n */\n private async postJson<T>(\n backupApiUrl: string,\n authToken: string,\n endpoint: string,\n body: unknown,\n options?: BackupRawRequestOptions,\n ): Promise<T> {\n const response = await this.transport.send({\n url: b2Url(this.safeBackupApiUrl(backupApiUrl), { ...BACKUP_API_V1, endpoint }),\n method: 'POST',\n headers: {\n Authorization: authToken,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n ...(options?.retry !== undefined ? { retry: options.retry } : {}),\n })\n return response.json<T>()\n }\n}\n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eAAe,UACjB;GACA,GAAI,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;GAClE,GAAI,SAAS,UAAU,KAAA,IAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EACjE,CAAC,EAAA,CACe,KAAQ;CAC1B;;;;;;;;;;;;CAaA,MAAc,SACZ,cACA,WACA,UACA,MACA,SACY;EAYZ,QAAO,MAXgB,KAAK,UAAU,KAAK;GACzC,KAAK,YAAA,MAAM,KAAK,iBAAiB,YAAY,GAAG;IAAE,GAAG;IAAe;GAAS,CAAC;GAC9E,QAAQ;GACR,SAAS;IACP,eAAe;IACf,gBAAgB;GAClB;GACA,MAAM,KAAK,UAAU,IAAI;GACzB,GAAI,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;GAClE,GAAI,SAAS,UAAU,KAAA,IAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EACjE,CAAC,EAAA,CACe,KAAQ;CAC1B;AACF"}
@@ -0,0 +1,122 @@
1
+ import { RetryOptions } from '../http/retry.js';
2
+ import { HttpTransport } from '../http/transport.js';
3
+ import { DeleteComputerRequest, DeleteComputerResponse, ListComputersRequest, ListComputersResponse } from '../types/backup.js';
4
+ /** Configuration for constructing a {@link BackupRawClient}. */
5
+ export interface BackupRawClientOptions {
6
+ /**
7
+ * The HTTP transport used to send requests.
8
+ *
9
+ * Computer Backup endpoint calls validate URLs against suffixes recorded by
10
+ * Partner authorization. A rehydrated client that skips authorization must
11
+ * use `authorizedBackupEndpointSuffixes` or a transport with a locked
12
+ * `urlGuard`. Because Partner authorize responses redact
13
+ * `authorizationToken` under `JSON.stringify`, durable caches should persist
14
+ * `partnerAuthorizeResponseForPersistence(auth)` only to encrypted or
15
+ * otherwise credential-grade storage, or use another secure token-preserving
16
+ * representation.
17
+ */
18
+ readonly transport: HttpTransport;
19
+ /**
20
+ * Validated Computer Backup endpoint host suffixes restored from cached
21
+ * Partner authorization. Facades normally manage this after authorization;
22
+ * direct raw clients can pass trusted suffixes derived from
23
+ * `derivePartnerAllowedSuffixes()`. Do not derive this cache with
24
+ * `JSON.stringify(authorizePartner())`, which intentionally stores a redacted
25
+ * token placeholder instead of a usable Partner token. Rehydrating that
26
+ * placeholder fails fast.
27
+ */
28
+ readonly authorizedBackupEndpointSuffixes?: readonly string[];
29
+ }
30
+ /** Optional controls for raw Computer Backup API requests. */
31
+ export interface BackupRawRequestOptions {
32
+ /** Abort signal for cancelling the request. */
33
+ readonly signal?: AbortSignal;
34
+ /** Per-request retry override. */
35
+ readonly retry?: Partial<RetryOptions>;
36
+ }
37
+ /**
38
+ * Low-level client for Computer Backup API endpoint bindings.
39
+ *
40
+ * Each method maps directly to one `bz_*` HTTP call under the
41
+ * `/api/backup/v1/` route using the `backupApiUrl` returned by Partner
42
+ * authorization.
43
+ *
44
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
45
+ */
46
+ export declare class BackupRawClient {
47
+ /** @internal */
48
+ private readonly transport;
49
+ private authorizedEndpointSuffixes;
50
+ /**
51
+ * Creates a new BackupRawClient with the given transport.
52
+ *
53
+ * @param options - The constructor configuration.
54
+ */
55
+ constructor(options: BackupRawClientOptions);
56
+ /**
57
+ * Replaces the validated Computer Backup endpoint host suffixes.
58
+ *
59
+ * @param suffixes - Host suffixes derived from Partner authorization.
60
+ *
61
+ * @internal
62
+ */
63
+ setAuthorizedEndpointSuffixes(suffixes: readonly string[]): void;
64
+ /**
65
+ * Calls `bz_list_computers`.
66
+ *
67
+ * Uses the documented GET form. The wire response is a single JSON object
68
+ * with a `nextComputerId` cursor and active computer backup records.
69
+ *
70
+ * @param backupApiUrl - The Computer Backup API base URL from `authorizePartner`.
71
+ * @param authToken - The Partner authorization token.
72
+ * @param request - The computer listing query parameters.
73
+ * @param options - Optional abort and per-request retry settings.
74
+ *
75
+ * @returns The single-object computer backup wire response.
76
+ *
77
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
78
+ */
79
+ listComputers(backupApiUrl: string, authToken: string, request: ListComputersRequest, options?: BackupRawRequestOptions): Promise<ListComputersResponse>;
80
+ /**
81
+ * Calls `bz_delete_computer`.
82
+ *
83
+ * The documented wire response is a JSON array of deletion records. This
84
+ * destructive mutation is not automatically retried or reauthorized in place.
85
+ *
86
+ * @param backupApiUrl - The Computer Backup API base URL from `authorizePartner`.
87
+ * @param authToken - The Partner authorization token.
88
+ * @param request - The computer deletion request body.
89
+ * @param options - Optional abort and per-request retry settings.
90
+ *
91
+ * @returns The deleted computer backup record array.
92
+ *
93
+ * @experimental Computer Backup API surface; shape may change as the Backup API docs evolve.
94
+ */
95
+ deleteComputer(backupApiUrl: string, authToken: string, request: DeleteComputerRequest, options?: BackupRawRequestOptions): Promise<DeleteComputerResponse>;
96
+ private safeBackupApiUrl;
97
+ /**
98
+ * Sends a JSON GET request to the specified Computer Backup API endpoint.
99
+ *
100
+ * @param backupApiUrl - The Computer Backup API base URL.
101
+ * @param authToken - The Partner authorization token.
102
+ * @param endpoint - The Computer Backup API endpoint name.
103
+ * @param query - The query-string parameters.
104
+ * @param options - Optional abort and per-request retry settings.
105
+ *
106
+ * @returns The parsed JSON response.
107
+ */
108
+ private getJson;
109
+ /**
110
+ * Sends a JSON POST request to the specified Computer Backup API endpoint.
111
+ *
112
+ * @param backupApiUrl - The Computer Backup API base URL.
113
+ * @param authToken - The Partner authorization token.
114
+ * @param endpoint - The Computer Backup API endpoint name.
115
+ * @param body - The JSON request body.
116
+ * @param options - Optional abort and per-request retry settings.
117
+ *
118
+ * @returns The parsed JSON response.
119
+ */
120
+ private postJson;
121
+ }
122
+ //# sourceMappingURL=raw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../src/backup/raw.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,M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