@backblaze-labs/b2-sdk 0.1.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 (512) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +21 -0
  3. package/README.md +664 -0
  4. package/dist/auth/account-info.d.cts +51 -0
  5. package/dist/auth/account-info.d.cts.map +1 -0
  6. package/dist/auth/account-info.d.ts +51 -0
  7. package/dist/auth/account-info.d.ts.map +1 -0
  8. package/dist/auth/file.cjs +210 -0
  9. package/dist/auth/file.cjs.map +1 -0
  10. package/dist/auth/file.d.cts +157 -0
  11. package/dist/auth/file.d.cts.map +1 -0
  12. package/dist/auth/file.d.ts +157 -0
  13. package/dist/auth/file.d.ts.map +1 -0
  14. package/dist/auth/file.js +210 -0
  15. package/dist/auth/file.js.map +1 -0
  16. package/dist/auth/in-memory.cjs +184 -0
  17. package/dist/auth/in-memory.cjs.map +1 -0
  18. package/dist/auth/in-memory.d.cts +147 -0
  19. package/dist/auth/in-memory.d.cts.map +1 -0
  20. package/dist/auth/in-memory.d.ts +147 -0
  21. package/dist/auth/in-memory.d.ts.map +1 -0
  22. package/dist/auth/in-memory.js +184 -0
  23. package/dist/auth/in-memory.js.map +1 -0
  24. package/dist/auth/index.cjs +10 -0
  25. package/dist/auth/index.cjs.map +1 -0
  26. package/dist/auth/index.d.cts +6 -0
  27. package/dist/auth/index.d.cts.map +1 -0
  28. package/dist/auth/index.d.ts +6 -0
  29. package/dist/auth/index.d.ts.map +1 -0
  30. package/dist/auth/index.js +10 -0
  31. package/dist/auth/index.js.map +1 -0
  32. package/dist/auth/realms.cjs +12 -0
  33. package/dist/auth/realms.cjs.map +1 -0
  34. package/dist/auth/realms.d.cts +12 -0
  35. package/dist/auth/realms.d.cts.map +1 -0
  36. package/dist/auth/realms.d.ts +12 -0
  37. package/dist/auth/realms.d.ts.map +1 -0
  38. package/dist/auth/realms.js +12 -0
  39. package/dist/auth/realms.js.map +1 -0
  40. package/dist/auth/upload-url-pool.cjs +52 -0
  41. package/dist/auth/upload-url-pool.cjs.map +1 -0
  42. package/dist/auth/upload-url-pool.d.cts +35 -0
  43. package/dist/auth/upload-url-pool.d.cts.map +1 -0
  44. package/dist/auth/upload-url-pool.d.ts +35 -0
  45. package/dist/auth/upload-url-pool.d.ts.map +1 -0
  46. package/dist/auth/upload-url-pool.js +52 -0
  47. package/dist/auth/upload-url-pool.js.map +1 -0
  48. package/dist/bucket.cjs +789 -0
  49. package/dist/bucket.cjs.map +1 -0
  50. package/dist/bucket.d.cts +659 -0
  51. package/dist/bucket.d.cts.map +1 -0
  52. package/dist/bucket.d.ts +659 -0
  53. package/dist/bucket.d.ts.map +1 -0
  54. package/dist/bucket.js +789 -0
  55. package/dist/bucket.js.map +1 -0
  56. package/dist/client.cjs +230 -0
  57. package/dist/client.cjs.map +1 -0
  58. package/dist/client.d.cts +222 -0
  59. package/dist/client.d.cts.map +1 -0
  60. package/dist/client.d.ts +222 -0
  61. package/dist/client.d.ts.map +1 -0
  62. package/dist/client.js +230 -0
  63. package/dist/client.js.map +1 -0
  64. package/dist/copy/large.cjs +74 -0
  65. package/dist/copy/large.cjs.map +1 -0
  66. package/dist/copy/large.d.cts +53 -0
  67. package/dist/copy/large.d.cts.map +1 -0
  68. package/dist/copy/large.d.ts +53 -0
  69. package/dist/copy/large.d.ts.map +1 -0
  70. package/dist/copy/large.js +74 -0
  71. package/dist/copy/large.js.map +1 -0
  72. package/dist/download/parallel.cjs +122 -0
  73. package/dist/download/parallel.cjs.map +1 -0
  74. package/dist/download/parallel.d.cts +42 -0
  75. package/dist/download/parallel.d.cts.map +1 -0
  76. package/dist/download/parallel.d.ts +42 -0
  77. package/dist/download/parallel.d.ts.map +1 -0
  78. package/dist/download/parallel.js +122 -0
  79. package/dist/download/parallel.js.map +1 -0
  80. package/dist/download/single.cjs +117 -0
  81. package/dist/download/single.cjs.map +1 -0
  82. package/dist/download/single.d.cts +152 -0
  83. package/dist/download/single.d.cts.map +1 -0
  84. package/dist/download/single.d.ts +152 -0
  85. package/dist/download/single.d.ts.map +1 -0
  86. package/dist/download/single.js +117 -0
  87. package/dist/download/single.js.map +1 -0
  88. package/dist/errors/index.cjs +268 -0
  89. package/dist/errors/index.cjs.map +1 -0
  90. package/dist/errors/index.d.cts +264 -0
  91. package/dist/errors/index.d.cts.map +1 -0
  92. package/dist/errors/index.d.ts +264 -0
  93. package/dist/errors/index.d.ts.map +1 -0
  94. package/dist/errors/index.js +268 -0
  95. package/dist/errors/index.js.map +1 -0
  96. package/dist/http/retry.cjs +36 -0
  97. package/dist/http/retry.cjs.map +1 -0
  98. package/dist/http/retry.d.cts +34 -0
  99. package/dist/http/retry.d.cts.map +1 -0
  100. package/dist/http/retry.d.ts +34 -0
  101. package/dist/http/retry.d.ts.map +1 -0
  102. package/dist/http/retry.js +36 -0
  103. package/dist/http/retry.js.map +1 -0
  104. package/dist/http/transport.cjs +143 -0
  105. package/dist/http/transport.cjs.map +1 -0
  106. package/dist/http/transport.d.cts +122 -0
  107. package/dist/http/transport.d.cts.map +1 -0
  108. package/dist/http/transport.d.ts +122 -0
  109. package/dist/http/transport.d.ts.map +1 -0
  110. package/dist/http/transport.js +143 -0
  111. package/dist/http/transport.js.map +1 -0
  112. package/dist/http/url-guard.cjs +97 -0
  113. package/dist/http/url-guard.cjs.map +1 -0
  114. package/dist/http/url-guard.d.cts +88 -0
  115. package/dist/http/url-guard.d.cts.map +1 -0
  116. package/dist/http/url-guard.d.ts +88 -0
  117. package/dist/http/url-guard.d.ts.map +1 -0
  118. package/dist/http/url-guard.js +97 -0
  119. package/dist/http/url-guard.js.map +1 -0
  120. package/dist/http/user-agent.cjs +51 -0
  121. package/dist/http/user-agent.cjs.map +1 -0
  122. package/dist/http/user-agent.d.cts +28 -0
  123. package/dist/http/user-agent.d.cts.map +1 -0
  124. package/dist/http/user-agent.d.ts +28 -0
  125. package/dist/http/user-agent.d.ts.map +1 -0
  126. package/dist/http/user-agent.js +51 -0
  127. package/dist/http/user-agent.js.map +1 -0
  128. package/dist/index.cjs +78 -0
  129. package/dist/index.cjs.map +1 -0
  130. package/dist/index.d.cts +39 -0
  131. package/dist/index.d.cts.map +1 -0
  132. package/dist/index.d.ts +39 -0
  133. package/dist/index.d.ts.map +1 -0
  134. package/dist/index.js +78 -0
  135. package/dist/index.js.map +1 -0
  136. package/dist/notifications/index.cjs +7 -0
  137. package/dist/notifications/index.cjs.map +1 -0
  138. package/dist/notifications/index.d.cts +3 -0
  139. package/dist/notifications/index.d.cts.map +1 -0
  140. package/dist/notifications/index.d.ts +3 -0
  141. package/dist/notifications/index.d.ts.map +1 -0
  142. package/dist/notifications/index.js +7 -0
  143. package/dist/notifications/index.js.map +1 -0
  144. package/dist/notifications/webhook.cjs +106 -0
  145. package/dist/notifications/webhook.cjs.map +1 -0
  146. package/dist/notifications/webhook.d.cts +146 -0
  147. package/dist/notifications/webhook.d.cts.map +1 -0
  148. package/dist/notifications/webhook.d.ts +146 -0
  149. package/dist/notifications/webhook.d.ts.map +1 -0
  150. package/dist/notifications/webhook.js +106 -0
  151. package/dist/notifications/webhook.js.map +1 -0
  152. package/dist/object.cjs +212 -0
  153. package/dist/object.cjs.map +1 -0
  154. package/dist/object.d.cts +263 -0
  155. package/dist/object.d.cts.map +1 -0
  156. package/dist/object.d.ts +263 -0
  157. package/dist/object.d.ts.map +1 -0
  158. package/dist/object.js +212 -0
  159. package/dist/object.js.map +1 -0
  160. package/dist/package.json.cjs +9 -0
  161. package/dist/package.json.cjs.map +1 -0
  162. package/dist/package.json.js +9 -0
  163. package/dist/package.json.js.map +1 -0
  164. package/dist/raw/encoding.cjs +47 -0
  165. package/dist/raw/encoding.cjs.map +1 -0
  166. package/dist/raw/encoding.d.cts +46 -0
  167. package/dist/raw/encoding.d.cts.map +1 -0
  168. package/dist/raw/encoding.d.ts +46 -0
  169. package/dist/raw/encoding.d.ts.map +1 -0
  170. package/dist/raw/encoding.js +47 -0
  171. package/dist/raw/encoding.js.map +1 -0
  172. package/dist/raw/index.cjs +600 -0
  173. package/dist/raw/index.cjs.map +1 -0
  174. package/dist/raw/index.d.cts +381 -0
  175. package/dist/raw/index.d.cts.map +1 -0
  176. package/dist/raw/index.d.ts +381 -0
  177. package/dist/raw/index.d.ts.map +1 -0
  178. package/dist/raw/index.js +601 -0
  179. package/dist/raw/index.js.map +1 -0
  180. package/dist/s3/index.cjs +23 -0
  181. package/dist/s3/index.cjs.map +1 -0
  182. package/dist/s3/index.d.cts +74 -0
  183. package/dist/s3/index.d.cts.map +1 -0
  184. package/dist/s3/index.d.ts +74 -0
  185. package/dist/s3/index.d.ts.map +1 -0
  186. package/dist/s3/index.js +23 -0
  187. package/dist/s3/index.js.map +1 -0
  188. package/dist/simulator/capabilities.cjs +53 -0
  189. package/dist/simulator/capabilities.cjs.map +1 -0
  190. package/dist/simulator/capabilities.d.cts +15 -0
  191. package/dist/simulator/capabilities.d.cts.map +1 -0
  192. package/dist/simulator/capabilities.d.ts +15 -0
  193. package/dist/simulator/capabilities.d.ts.map +1 -0
  194. package/dist/simulator/capabilities.js +53 -0
  195. package/dist/simulator/capabilities.js.map +1 -0
  196. package/dist/simulator/index.cjs +1559 -0
  197. package/dist/simulator/index.cjs.map +1 -0
  198. package/dist/simulator/index.d.cts +495 -0
  199. package/dist/simulator/index.d.cts.map +1 -0
  200. package/dist/simulator/index.d.ts +495 -0
  201. package/dist/simulator/index.d.ts.map +1 -0
  202. package/dist/simulator/index.js +1560 -0
  203. package/dist/simulator/index.js.map +1 -0
  204. package/dist/simulator/validation.cjs +174 -0
  205. package/dist/simulator/validation.cjs.map +1 -0
  206. package/dist/simulator/validation.d.cts +104 -0
  207. package/dist/simulator/validation.d.cts.map +1 -0
  208. package/dist/simulator/validation.d.ts +104 -0
  209. package/dist/simulator/validation.d.ts.map +1 -0
  210. package/dist/simulator/validation.js +174 -0
  211. package/dist/simulator/validation.js.map +1 -0
  212. package/dist/streams/collect.cjs +26 -0
  213. package/dist/streams/collect.cjs.map +1 -0
  214. package/dist/streams/collect.d.cts +18 -0
  215. package/dist/streams/collect.d.cts.map +1 -0
  216. package/dist/streams/collect.d.ts +18 -0
  217. package/dist/streams/collect.d.ts.map +1 -0
  218. package/dist/streams/collect.js +26 -0
  219. package/dist/streams/collect.js.map +1 -0
  220. package/dist/streams/hash.cjs +123 -0
  221. package/dist/streams/hash.cjs.map +1 -0
  222. package/dist/streams/hash.d.cts +42 -0
  223. package/dist/streams/hash.d.cts.map +1 -0
  224. package/dist/streams/hash.d.ts +42 -0
  225. package/dist/streams/hash.d.ts.map +1 -0
  226. package/dist/streams/hash.js +101 -0
  227. package/dist/streams/hash.js.map +1 -0
  228. package/dist/streams/index.cjs +13 -0
  229. package/dist/streams/index.cjs.map +1 -0
  230. package/dist/streams/index.d.cts +7 -0
  231. package/dist/streams/index.d.cts.map +1 -0
  232. package/dist/streams/index.d.ts +7 -0
  233. package/dist/streams/index.d.ts.map +1 -0
  234. package/dist/streams/index.js +13 -0
  235. package/dist/streams/index.js.map +1 -0
  236. package/dist/streams/progress.cjs +47 -0
  237. package/dist/streams/progress.cjs.map +1 -0
  238. package/dist/streams/progress.d.cts +53 -0
  239. package/dist/streams/progress.d.cts.map +1 -0
  240. package/dist/streams/progress.d.ts +53 -0
  241. package/dist/streams/progress.d.ts.map +1 -0
  242. package/dist/streams/progress.js +47 -0
  243. package/dist/streams/progress.js.map +1 -0
  244. package/dist/streams/source.cjs +155 -0
  245. package/dist/streams/source.cjs.map +1 -0
  246. package/dist/streams/source.d.cts +140 -0
  247. package/dist/streams/source.d.cts.map +1 -0
  248. package/dist/streams/source.d.ts +140 -0
  249. package/dist/streams/source.d.ts.map +1 -0
  250. package/dist/streams/source.js +155 -0
  251. package/dist/streams/source.js.map +1 -0
  252. package/dist/sync/actions/index.cjs +191 -0
  253. package/dist/sync/actions/index.cjs.map +1 -0
  254. package/dist/sync/actions/index.d.cts +167 -0
  255. package/dist/sync/actions/index.d.cts.map +1 -0
  256. package/dist/sync/actions/index.d.ts +167 -0
  257. package/dist/sync/actions/index.d.ts.map +1 -0
  258. package/dist/sync/actions/index.js +191 -0
  259. package/dist/sync/actions/index.js.map +1 -0
  260. package/dist/sync/index.cjs +23 -0
  261. package/dist/sync/index.cjs.map +1 -0
  262. package/dist/sync/index.d.cts +21 -0
  263. package/dist/sync/index.d.cts.map +1 -0
  264. package/dist/sync/index.d.ts +21 -0
  265. package/dist/sync/index.d.ts.map +1 -0
  266. package/dist/sync/index.js +23 -0
  267. package/dist/sync/index.js.map +1 -0
  268. package/dist/sync/pairing.cjs +31 -0
  269. package/dist/sync/pairing.cjs.map +1 -0
  270. package/dist/sync/pairing.d.cts +13 -0
  271. package/dist/sync/pairing.d.cts.map +1 -0
  272. package/dist/sync/pairing.d.ts +13 -0
  273. package/dist/sync/pairing.d.ts.map +1 -0
  274. package/dist/sync/pairing.js +31 -0
  275. package/dist/sync/pairing.js.map +1 -0
  276. package/dist/sync/policies/compare.cjs +14 -0
  277. package/dist/sync/policies/compare.cjs.map +1 -0
  278. package/dist/sync/policies/compare.d.cts +13 -0
  279. package/dist/sync/policies/compare.d.cts.map +1 -0
  280. package/dist/sync/policies/compare.d.ts +13 -0
  281. package/dist/sync/policies/compare.d.ts.map +1 -0
  282. package/dist/sync/policies/compare.js +14 -0
  283. package/dist/sync/policies/compare.js.map +1 -0
  284. package/dist/sync/policies/index.cjs +74 -0
  285. package/dist/sync/policies/index.cjs.map +1 -0
  286. package/dist/sync/policies/index.d.cts +42 -0
  287. package/dist/sync/policies/index.d.cts.map +1 -0
  288. package/dist/sync/policies/index.d.ts +42 -0
  289. package/dist/sync/policies/index.d.ts.map +1 -0
  290. package/dist/sync/policies/index.js +74 -0
  291. package/dist/sync/policies/index.js.map +1 -0
  292. package/dist/sync/scanners/b2.cjs +57 -0
  293. package/dist/sync/scanners/b2.cjs.map +1 -0
  294. package/dist/sync/scanners/b2.d.cts +20 -0
  295. package/dist/sync/scanners/b2.d.cts.map +1 -0
  296. package/dist/sync/scanners/b2.d.ts +20 -0
  297. package/dist/sync/scanners/b2.d.ts.map +1 -0
  298. package/dist/sync/scanners/b2.js +57 -0
  299. package/dist/sync/scanners/b2.js.map +1 -0
  300. package/dist/sync/scanners/local.cjs +58 -0
  301. package/dist/sync/scanners/local.cjs.map +1 -0
  302. package/dist/sync/scanners/local.d.cts +24 -0
  303. package/dist/sync/scanners/local.d.cts.map +1 -0
  304. package/dist/sync/scanners/local.d.ts +24 -0
  305. package/dist/sync/scanners/local.d.ts.map +1 -0
  306. package/dist/sync/scanners/local.js +58 -0
  307. package/dist/sync/scanners/local.js.map +1 -0
  308. package/dist/sync/synchronizer.cjs +203 -0
  309. package/dist/sync/synchronizer.cjs.map +1 -0
  310. package/dist/sync/synchronizer.d.cts +52 -0
  311. package/dist/sync/synchronizer.d.cts.map +1 -0
  312. package/dist/sync/synchronizer.d.ts +52 -0
  313. package/dist/sync/synchronizer.d.ts.map +1 -0
  314. package/dist/sync/synchronizer.js +181 -0
  315. package/dist/sync/synchronizer.js.map +1 -0
  316. package/dist/sync/types.d.cts +121 -0
  317. package/dist/sync/types.d.cts.map +1 -0
  318. package/dist/sync/types.d.ts +121 -0
  319. package/dist/sync/types.d.ts.map +1 -0
  320. package/dist/types/auth.cjs +58 -0
  321. package/dist/types/auth.cjs.map +1 -0
  322. package/dist/types/auth.d.cts +150 -0
  323. package/dist/types/auth.d.cts.map +1 -0
  324. package/dist/types/auth.d.ts +150 -0
  325. package/dist/types/auth.d.ts.map +1 -0
  326. package/dist/types/auth.js +58 -0
  327. package/dist/types/auth.js.map +1 -0
  328. package/dist/types/bucket.cjs +44 -0
  329. package/dist/types/bucket.cjs.map +1 -0
  330. package/dist/types/bucket.d.cts +245 -0
  331. package/dist/types/bucket.d.cts.map +1 -0
  332. package/dist/types/bucket.d.ts +245 -0
  333. package/dist/types/bucket.d.ts.map +1 -0
  334. package/dist/types/bucket.js +44 -0
  335. package/dist/types/bucket.js.map +1 -0
  336. package/dist/types/download.d.cts +110 -0
  337. package/dist/types/download.d.cts.map +1 -0
  338. package/dist/types/download.d.ts +110 -0
  339. package/dist/types/download.d.ts.map +1 -0
  340. package/dist/types/encryption.cjs +343 -0
  341. package/dist/types/encryption.cjs.map +1 -0
  342. package/dist/types/encryption.d.cts +132 -0
  343. package/dist/types/encryption.d.cts.map +1 -0
  344. package/dist/types/encryption.d.ts +132 -0
  345. package/dist/types/encryption.d.ts.map +1 -0
  346. package/dist/types/encryption.js +321 -0
  347. package/dist/types/encryption.js.map +1 -0
  348. package/dist/types/errors.d.cts +16 -0
  349. package/dist/types/errors.d.cts.map +1 -0
  350. package/dist/types/errors.d.ts +16 -0
  351. package/dist/types/errors.d.ts.map +1 -0
  352. package/dist/types/file.cjs +23 -0
  353. package/dist/types/file.cjs.map +1 -0
  354. package/dist/types/file.d.cts +220 -0
  355. package/dist/types/file.d.cts.map +1 -0
  356. package/dist/types/file.d.ts +220 -0
  357. package/dist/types/file.d.ts.map +1 -0
  358. package/dist/types/file.js +23 -0
  359. package/dist/types/file.js.map +1 -0
  360. package/dist/types/ids.cjs +27 -0
  361. package/dist/types/ids.cjs.map +1 -0
  362. package/dist/types/ids.d.cts +84 -0
  363. package/dist/types/ids.d.cts.map +1 -0
  364. package/dist/types/ids.d.ts +84 -0
  365. package/dist/types/ids.d.ts.map +1 -0
  366. package/dist/types/ids.js +27 -0
  367. package/dist/types/ids.js.map +1 -0
  368. package/dist/types/index.d.cts +25 -0
  369. package/dist/types/index.d.cts.map +1 -0
  370. package/dist/types/index.d.ts +25 -0
  371. package/dist/types/index.d.ts.map +1 -0
  372. package/dist/types/key.d.cts +84 -0
  373. package/dist/types/key.d.cts.map +1 -0
  374. package/dist/types/key.d.ts +84 -0
  375. package/dist/types/key.d.ts.map +1 -0
  376. package/dist/types/lock.cjs +17 -0
  377. package/dist/types/lock.cjs.map +1 -0
  378. package/dist/types/lock.d.cts +92 -0
  379. package/dist/types/lock.d.cts.map +1 -0
  380. package/dist/types/lock.d.ts +92 -0
  381. package/dist/types/lock.d.ts.map +1 -0
  382. package/dist/types/lock.js +17 -0
  383. package/dist/types/lock.js.map +1 -0
  384. package/dist/types/notifications.cjs +24 -0
  385. package/dist/types/notifications.cjs.map +1 -0
  386. package/dist/types/notifications.d.cts +97 -0
  387. package/dist/types/notifications.d.cts.map +1 -0
  388. package/dist/types/notifications.d.ts +97 -0
  389. package/dist/types/notifications.d.ts.map +1 -0
  390. package/dist/types/notifications.js +24 -0
  391. package/dist/types/notifications.js.map +1 -0
  392. package/dist/types/replication.d.cts +42 -0
  393. package/dist/types/replication.d.cts.map +1 -0
  394. package/dist/types/replication.d.ts +42 -0
  395. package/dist/types/replication.d.ts.map +1 -0
  396. package/dist/types/upload.d.cts +219 -0
  397. package/dist/types/upload.d.cts.map +1 -0
  398. package/dist/types/upload.d.ts +219 -0
  399. package/dist/types/upload.d.ts.map +1 -0
  400. package/dist/upload/cancel.cjs +10 -0
  401. package/dist/upload/cancel.cjs.map +1 -0
  402. package/dist/upload/cancel.d.cts +23 -0
  403. package/dist/upload/cancel.d.cts.map +1 -0
  404. package/dist/upload/cancel.d.ts +23 -0
  405. package/dist/upload/cancel.d.ts.map +1 -0
  406. package/dist/upload/cancel.js +10 -0
  407. package/dist/upload/cancel.js.map +1 -0
  408. package/dist/upload/concurrency.cjs +54 -0
  409. package/dist/upload/concurrency.cjs.map +1 -0
  410. package/dist/upload/concurrency.d.cts +46 -0
  411. package/dist/upload/concurrency.d.cts.map +1 -0
  412. package/dist/upload/concurrency.d.ts +46 -0
  413. package/dist/upload/concurrency.d.ts.map +1 -0
  414. package/dist/upload/concurrency.js +54 -0
  415. package/dist/upload/concurrency.js.map +1 -0
  416. package/dist/upload/large.cjs +222 -0
  417. package/dist/upload/large.cjs.map +1 -0
  418. package/dist/upload/large.d.cts +71 -0
  419. package/dist/upload/large.d.cts.map +1 -0
  420. package/dist/upload/large.d.ts +71 -0
  421. package/dist/upload/large.d.ts.map +1 -0
  422. package/dist/upload/large.js +222 -0
  423. package/dist/upload/large.js.map +1 -0
  424. package/dist/upload/resume.cjs +34 -0
  425. package/dist/upload/resume.cjs.map +1 -0
  426. package/dist/upload/resume.d.cts +33 -0
  427. package/dist/upload/resume.d.cts.map +1 -0
  428. package/dist/upload/resume.d.ts +33 -0
  429. package/dist/upload/resume.d.ts.map +1 -0
  430. package/dist/upload/resume.js +34 -0
  431. package/dist/upload/resume.js.map +1 -0
  432. package/dist/upload/single.cjs +47 -0
  433. package/dist/upload/single.cjs.map +1 -0
  434. package/dist/upload/single.d.cts +51 -0
  435. package/dist/upload/single.d.cts.map +1 -0
  436. package/dist/upload/single.d.ts +51 -0
  437. package/dist/upload/single.d.ts.map +1 -0
  438. package/dist/upload/single.js +47 -0
  439. package/dist/upload/single.js.map +1 -0
  440. package/dist/upload/stream.cjs +198 -0
  441. package/dist/upload/stream.cjs.map +1 -0
  442. package/dist/upload/stream.d.cts +61 -0
  443. package/dist/upload/stream.d.cts.map +1 -0
  444. package/dist/upload/stream.d.ts +61 -0
  445. package/dist/upload/stream.d.ts.map +1 -0
  446. package/dist/upload/stream.js +198 -0
  447. package/dist/upload/stream.js.map +1 -0
  448. package/dist/util/best-effort.cjs +10 -0
  449. package/dist/util/best-effort.cjs.map +1 -0
  450. package/dist/util/best-effort.d.cts +31 -0
  451. package/dist/util/best-effort.d.cts.map +1 -0
  452. package/dist/util/best-effort.d.ts +31 -0
  453. package/dist/util/best-effort.d.ts.map +1 -0
  454. package/dist/util/best-effort.js +10 -0
  455. package/dist/util/best-effort.js.map +1 -0
  456. package/dist/util/defaults.cjs +11 -0
  457. package/dist/util/defaults.cjs.map +1 -0
  458. package/dist/util/defaults.d.cts +54 -0
  459. package/dist/util/defaults.d.cts.map +1 -0
  460. package/dist/util/defaults.d.ts +54 -0
  461. package/dist/util/defaults.d.ts.map +1 -0
  462. package/dist/util/defaults.js +11 -0
  463. package/dist/util/defaults.js.map +1 -0
  464. package/dist/util/normalize.cjs +16 -0
  465. package/dist/util/normalize.cjs.map +1 -0
  466. package/dist/util/normalize.d.cts +62 -0
  467. package/dist/util/normalize.d.cts.map +1 -0
  468. package/dist/util/normalize.d.ts +62 -0
  469. package/dist/util/normalize.d.ts.map +1 -0
  470. package/dist/util/normalize.js +16 -0
  471. package/dist/util/normalize.js.map +1 -0
  472. package/dist/util/paginator.cjs +20 -0
  473. package/dist/util/paginator.cjs.map +1 -0
  474. package/dist/util/paginator.d.cts +120 -0
  475. package/dist/util/paginator.d.cts.map +1 -0
  476. package/dist/util/paginator.d.ts +120 -0
  477. package/dist/util/paginator.d.ts.map +1 -0
  478. package/dist/util/paginator.js +20 -0
  479. package/dist/util/paginator.js.map +1 -0
  480. package/dist/util/plan-ranges.cjs +28 -0
  481. package/dist/util/plan-ranges.cjs.map +1 -0
  482. package/dist/util/plan-ranges.d.cts +56 -0
  483. package/dist/util/plan-ranges.d.cts.map +1 -0
  484. package/dist/util/plan-ranges.d.ts +56 -0
  485. package/dist/util/plan-ranges.d.ts.map +1 -0
  486. package/dist/util/plan-ranges.js +28 -0
  487. package/dist/util/plan-ranges.js.map +1 -0
  488. package/dist/util/text-codec.cjs +7 -0
  489. package/dist/util/text-codec.cjs.map +1 -0
  490. package/dist/util/text-codec.d.cts +26 -0
  491. package/dist/util/text-codec.d.cts.map +1 -0
  492. package/dist/util/text-codec.d.ts +26 -0
  493. package/dist/util/text-codec.d.ts.map +1 -0
  494. package/dist/util/text-codec.js +7 -0
  495. package/dist/util/text-codec.js.map +1 -0
  496. package/dist/util/to-error.cjs +7 -0
  497. package/dist/util/to-error.cjs.map +1 -0
  498. package/dist/util/to-error.d.cts +15 -0
  499. package/dist/util/to-error.d.cts.map +1 -0
  500. package/dist/util/to-error.d.ts +15 -0
  501. package/dist/util/to-error.d.ts.map +1 -0
  502. package/dist/util/to-error.js +7 -0
  503. package/dist/util/to-error.js.map +1 -0
  504. package/dist/version.cjs +6 -0
  505. package/dist/version.cjs.map +1 -0
  506. package/dist/version.d.cts +14 -0
  507. package/dist/version.d.cts.map +1 -0
  508. package/dist/version.d.ts +14 -0
  509. package/dist/version.d.ts.map +1 -0
  510. package/dist/version.js +6 -0
  511. package/dist/version.js.map +1 -0
  512. package/package.json +198 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const client = require("./client.cjs");
4
+ const bucket = require("./bucket.cjs");
5
+ const object = require("./object.cjs");
6
+ const raw_index = require("./raw/index.cjs");
7
+ const errors_index = require("./errors/index.cjs");
8
+ const inMemory = require("./auth/in-memory.cjs");
9
+ const hash = require("./streams/hash.cjs");
10
+ const source = require("./streams/source.cjs");
11
+ const transport = require("./http/transport.cjs");
12
+ const urlGuard = require("./http/url-guard.cjs");
13
+ const encryption = require("./types/encryption.cjs");
14
+ const paginator = require("./util/paginator.cjs");
15
+ const bucket$1 = require("./types/bucket.cjs");
16
+ const auth = require("./types/auth.cjs");
17
+ const notifications = require("./types/notifications.cjs");
18
+ const file = require("./types/file.cjs");
19
+ const lock = require("./types/lock.cjs");
20
+ const ids = require("./types/ids.cjs");
21
+ const version = require("./version.cjs");
22
+ exports.B2Client = client.B2Client;
23
+ exports.Bucket = bucket.Bucket;
24
+ exports.B2Object = object.B2Object;
25
+ exports.RawClient = raw_index.RawClient;
26
+ exports.AccessDeniedError = errors_index.AccessDeniedError;
27
+ exports.B2Error = errors_index.B2Error;
28
+ exports.B2InsufficientCapabilityError = errors_index.B2InsufficientCapabilityError;
29
+ exports.B2SsrfError = errors_index.B2SsrfError;
30
+ exports.BadAuthTokenError = errors_index.BadAuthTokenError;
31
+ exports.BadRequestError = errors_index.BadRequestError;
32
+ exports.BadUploadUrlError = errors_index.BadUploadUrlError;
33
+ exports.CapExceededError = errors_index.CapExceededError;
34
+ exports.ChecksumMismatchError = errors_index.ChecksumMismatchError;
35
+ exports.DuplicateBucketNameError = errors_index.DuplicateBucketNameError;
36
+ exports.ExpiredAuthTokenError = errors_index.ExpiredAuthTokenError;
37
+ exports.FileNotPresentError = errors_index.FileNotPresentError;
38
+ exports.NetworkError = errors_index.NetworkError;
39
+ exports.RequestTimeoutError = errors_index.RequestTimeoutError;
40
+ exports.ServiceUnavailableError = errors_index.ServiceUnavailableError;
41
+ exports.TooManyRequestsError = errors_index.TooManyRequestsError;
42
+ exports.classifyError = errors_index.classifyError;
43
+ exports.InMemoryAccountInfo = inMemory.InMemoryAccountInfo;
44
+ exports.IncrementalSha1 = hash.IncrementalSha1;
45
+ exports.sha1Hex = hash.sha1Hex;
46
+ exports.BlobSource = source.BlobSource;
47
+ exports.BufferSource = source.BufferSource;
48
+ exports.StreamSource = source.StreamSource;
49
+ exports.toContentSource = source.toContentSource;
50
+ exports.FetchTransport = transport.FetchTransport;
51
+ exports.RetryTransport = transport.RetryTransport;
52
+ exports.UrlGuard = urlGuard.UrlGuard;
53
+ exports.deriveAllowedSuffixes = urlGuard.deriveAllowedSuffixes;
54
+ exports.EncryptionAlgorithm = encryption.EncryptionAlgorithm;
55
+ exports.EncryptionKey = encryption.EncryptionKey;
56
+ exports.EncryptionMode = encryption.EncryptionMode;
57
+ exports.SSE_B2 = encryption.SSE_B2;
58
+ exports.SSE_NONE = encryption.SSE_NONE;
59
+ exports.sseCustomer = encryption.sseCustomer;
60
+ exports.paginateItems = paginator.paginateItems;
61
+ exports.paginatePages = paginator.paginatePages;
62
+ exports.BucketRetentionMode = bucket$1.BucketRetentionMode;
63
+ exports.BucketType = bucket$1.BucketType;
64
+ exports.CorsOperation = bucket$1.CorsOperation;
65
+ exports.Capability = auth.Capability;
66
+ exports.EventType = notifications.EventType;
67
+ exports.FileAction = file.FileAction;
68
+ exports.MetadataDirective = file.MetadataDirective;
69
+ exports.LegalHoldValue = lock.LegalHoldValue;
70
+ exports.RetentionMode = lock.RetentionMode;
71
+ exports.accountId = ids.accountId;
72
+ exports.applicationKeyId = ids.applicationKeyId;
73
+ exports.bucketId = ids.bucketId;
74
+ exports.fileId = ids.fileId;
75
+ exports.keyId = ids.keyId;
76
+ exports.largeFileId = ids.largeFileId;
77
+ exports.VERSION = version.VERSION;
78
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Backblaze B2 Cloud Storage SDK for TypeScript/JavaScript.
3
+ *
4
+ * The root module re-exports the high-level facade ({@link B2Client}, {@link Bucket},
5
+ * {@link B2Object}), error types, auth backends, streaming utilities, HTTP transport,
6
+ * and all request/response type definitions. Most applications only need this import.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { B2Client, type B2ClientOptions, type CapabilityCheckResult } from './client.js';
11
+ export { Bucket, type DeleteAllDeleteEvent, type DeleteAllErrorEvent, type DeleteAllEvent, type DeleteAllSkipEvent, type DeleteError, type DeleteManyResult, type DeleteTarget, } from './bucket.js';
12
+ export { B2Object, type DownloadCallOptions, type HeadCallOptions } from './object.js';
13
+ export type { UploadWriteHandle } from './upload/stream.js';
14
+ export { RawClient, type RawClientOptions, type DownloadFileOptions, type SseCDownloadKey, } from './raw/index.js';
15
+ export { B2Error, ExpiredAuthTokenError, BadAuthTokenError, ServiceUnavailableError, RequestTimeoutError, TooManyRequestsError, CapExceededError, AccessDeniedError, FileNotPresentError, DuplicateBucketNameError, BadRequestError, BadUploadUrlError, ChecksumMismatchError, B2InsufficientCapabilityError, B2SsrfError, NetworkError, classifyError, } from './errors/index.js';
16
+ export { InMemoryAccountInfo } from './auth/in-memory.js';
17
+ export type { AccountInfo, UploadUrlEntry } from './auth/account-info.js';
18
+ export { IncrementalSha1, sha1Hex } from './streams/hash.js';
19
+ export { toContentSource, BlobSource, BufferSource, StreamSource } from './streams/source.js';
20
+ export type { ContentSource } from './streams/source.js';
21
+ export type { ProgressEvent, ProgressListener } from './streams/progress.js';
22
+ export { FetchTransport, RetryTransport } from './http/transport.js';
23
+ export type { HttpTransport, HttpRequest, HttpResponse, RetryTransportOptions, } from './http/transport.js';
24
+ export { UrlGuard, deriveAllowedSuffixes } from './http/url-guard.js';
25
+ export type { RetryOptions } from './http/retry.js';
26
+ export type { DownloadResult, HeadResult } from './download/single.js';
27
+ export { EncryptionKey, SSE_B2, SSE_NONE, sseCustomer } from './types/encryption.js';
28
+ export { paginateItems, paginatePages } from './util/paginator.js';
29
+ export type { PageFetcher, PaginatorOptions } from './util/paginator.js';
30
+ export { BucketRetentionMode, BucketType, CorsOperation } from './types/bucket.js';
31
+ export { Capability } from './types/auth.js';
32
+ export { EncryptionAlgorithm, EncryptionMode } from './types/encryption.js';
33
+ export { EventType } from './types/notifications.js';
34
+ export { FileAction, MetadataDirective } from './types/file.js';
35
+ export { LegalHoldValue, RetentionMode } from './types/lock.js';
36
+ export type * from './types/index.js';
37
+ export { accountId, applicationKeyId, bucketId, fileId, keyId, largeFileId, } from './types/ids.js';
38
+ export { VERSION } from './version.js';
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EACL,MAAM,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAA;AAEtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,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gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAOxE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/D,mBAAmB,kBAAkB,CAAA;AAQrC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,WAAW,GACZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Backblaze B2 Cloud Storage SDK for TypeScript/JavaScript.
3
+ *
4
+ * The root module re-exports the high-level facade ({@link B2Client}, {@link Bucket},
5
+ * {@link B2Object}), error types, auth backends, streaming utilities, HTTP transport,
6
+ * and all request/response type definitions. Most applications only need this import.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { B2Client, type B2ClientOptions, type CapabilityCheckResult } from './client.js';
11
+ export { Bucket, type DeleteAllDeleteEvent, type DeleteAllErrorEvent, type DeleteAllEvent, type DeleteAllSkipEvent, type DeleteError, type DeleteManyResult, type DeleteTarget, } from './bucket.js';
12
+ export { B2Object, type DownloadCallOptions, type HeadCallOptions } from './object.js';
13
+ export type { UploadWriteHandle } from './upload/stream.js';
14
+ export { RawClient, type RawClientOptions, type DownloadFileOptions, type SseCDownloadKey, } from './raw/index.js';
15
+ export { B2Error, ExpiredAuthTokenError, BadAuthTokenError, ServiceUnavailableError, RequestTimeoutError, TooManyRequestsError, CapExceededError, AccessDeniedError, FileNotPresentError, DuplicateBucketNameError, BadRequestError, BadUploadUrlError, ChecksumMismatchError, B2InsufficientCapabilityError, B2SsrfError, NetworkError, classifyError, } from './errors/index.js';
16
+ export { InMemoryAccountInfo } from './auth/in-memory.js';
17
+ export type { AccountInfo, UploadUrlEntry } from './auth/account-info.js';
18
+ export { IncrementalSha1, sha1Hex } from './streams/hash.js';
19
+ export { toContentSource, BlobSource, BufferSource, StreamSource } from './streams/source.js';
20
+ export type { ContentSource } from './streams/source.js';
21
+ export type { ProgressEvent, ProgressListener } from './streams/progress.js';
22
+ export { FetchTransport, RetryTransport } from './http/transport.js';
23
+ export type { HttpTransport, HttpRequest, HttpResponse, RetryTransportOptions, } from './http/transport.js';
24
+ export { UrlGuard, deriveAllowedSuffixes } from './http/url-guard.js';
25
+ export type { RetryOptions } from './http/retry.js';
26
+ export type { DownloadResult, HeadResult } from './download/single.js';
27
+ export { EncryptionKey, SSE_B2, SSE_NONE, sseCustomer } from './types/encryption.js';
28
+ export { paginateItems, paginatePages } from './util/paginator.js';
29
+ export type { PageFetcher, PaginatorOptions } from './util/paginator.js';
30
+ export { BucketRetentionMode, BucketType, CorsOperation } from './types/bucket.js';
31
+ export { Capability } from './types/auth.js';
32
+ export { EncryptionAlgorithm, EncryptionMode } from './types/encryption.js';
33
+ export { EventType } from './types/notifications.js';
34
+ export { FileAction, MetadataDirective } from './types/file.js';
35
+ export { LegalHoldValue, RetentionMode } from './types/lock.js';
36
+ export type * from './types/index.js';
37
+ export { accountId, applicationKeyId, bucketId, fileId, keyId, largeFileId, } from './types/ids.js';
38
+ export { VERSION } from './version.js';
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxF,O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B,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AACrE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAKpF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAClE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAOxE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/D,mBAAmB,kBAAkB,CAAA;AAQrC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,WAAW,GACZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,78 @@
1
+ import { B2Client } from "./client.js";
2
+ import { Bucket } from "./bucket.js";
3
+ import { B2Object } from "./object.js";
4
+ import { RawClient } from "./raw/index.js";
5
+ import { AccessDeniedError, B2Error, B2InsufficientCapabilityError, B2SsrfError, BadAuthTokenError, BadRequestError, BadUploadUrlError, CapExceededError, ChecksumMismatchError, DuplicateBucketNameError, ExpiredAuthTokenError, FileNotPresentError, NetworkError, RequestTimeoutError, ServiceUnavailableError, TooManyRequestsError, classifyError } from "./errors/index.js";
6
+ import { InMemoryAccountInfo } from "./auth/in-memory.js";
7
+ import { IncrementalSha1, sha1Hex } from "./streams/hash.js";
8
+ import { BlobSource, BufferSource, StreamSource, toContentSource } from "./streams/source.js";
9
+ import { FetchTransport, RetryTransport } from "./http/transport.js";
10
+ import { UrlGuard, deriveAllowedSuffixes } from "./http/url-guard.js";
11
+ import { EncryptionAlgorithm, EncryptionKey, EncryptionMode, SSE_B2, SSE_NONE, sseCustomer } from "./types/encryption.js";
12
+ import { paginateItems, paginatePages } from "./util/paginator.js";
13
+ import { BucketRetentionMode, BucketType, CorsOperation } from "./types/bucket.js";
14
+ import { Capability } from "./types/auth.js";
15
+ import { EventType } from "./types/notifications.js";
16
+ import { FileAction, MetadataDirective } from "./types/file.js";
17
+ import { LegalHoldValue, RetentionMode } from "./types/lock.js";
18
+ import { accountId, applicationKeyId, bucketId, fileId, keyId, largeFileId } from "./types/ids.js";
19
+ import { VERSION } from "./version.js";
20
+ export {
21
+ AccessDeniedError,
22
+ B2Client,
23
+ B2Error,
24
+ B2InsufficientCapabilityError,
25
+ B2Object,
26
+ B2SsrfError,
27
+ BadAuthTokenError,
28
+ BadRequestError,
29
+ BadUploadUrlError,
30
+ BlobSource,
31
+ Bucket,
32
+ BucketRetentionMode,
33
+ BucketType,
34
+ BufferSource,
35
+ CapExceededError,
36
+ Capability,
37
+ ChecksumMismatchError,
38
+ CorsOperation,
39
+ DuplicateBucketNameError,
40
+ EncryptionAlgorithm,
41
+ EncryptionKey,
42
+ EncryptionMode,
43
+ EventType,
44
+ ExpiredAuthTokenError,
45
+ FetchTransport,
46
+ FileAction,
47
+ FileNotPresentError,
48
+ InMemoryAccountInfo,
49
+ IncrementalSha1,
50
+ LegalHoldValue,
51
+ MetadataDirective,
52
+ NetworkError,
53
+ RawClient,
54
+ RequestTimeoutError,
55
+ RetentionMode,
56
+ RetryTransport,
57
+ SSE_B2,
58
+ SSE_NONE,
59
+ ServiceUnavailableError,
60
+ StreamSource,
61
+ TooManyRequestsError,
62
+ UrlGuard,
63
+ VERSION,
64
+ accountId,
65
+ applicationKeyId,
66
+ bucketId,
67
+ classifyError,
68
+ deriveAllowedSuffixes,
69
+ fileId,
70
+ keyId,
71
+ largeFileId,
72
+ paginateItems,
73
+ paginatePages,
74
+ sha1Hex,
75
+ sseCustomer,
76
+ toContentSource
77
+ };
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const webhook = require("./webhook.cjs");
4
+ exports.B2_WEBHOOK_SIGNATURE_HEADER = webhook.B2_WEBHOOK_SIGNATURE_HEADER;
5
+ exports.requireValidWebhook = webhook.requireValidWebhook;
6
+ exports.verifyWebhookSignature = webhook.verifyWebhookSignature;
7
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,3 @@
1
+ export { B2_WEBHOOK_SIGNATURE_HEADER, requireValidWebhook, verifyWebhookSignature, } from './webhook.js';
2
+ export type { VerifyWebhookOptions, VerifyWebhookResult, WebhookEvent, WebhookPayload, } from './webhook.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.js"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,cAAc,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { B2_WEBHOOK_SIGNATURE_HEADER, requireValidWebhook, verifyWebhookSignature, } from './webhook.js';
2
+ export type { VerifyWebhookOptions, VerifyWebhookResult, WebhookEvent, WebhookPayload, } from './webhook.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.js"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,cAAc,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { B2_WEBHOOK_SIGNATURE_HEADER, requireValidWebhook, verifyWebhookSignature } from "./webhook.js";
2
+ export {
3
+ B2_WEBHOOK_SIGNATURE_HEADER,
4
+ requireValidWebhook,
5
+ verifyWebhookSignature
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const textCodec = require("../util/text-codec.cjs");
4
+ const B2_WEBHOOK_SIGNATURE_HEADER = "x-bz-event-notification-signature";
5
+ const SIGNATURE_VERSION_PREFIX = "v1=";
6
+ function timingSafeEqual(a, b) {
7
+ if (a.byteLength !== b.byteLength) return false;
8
+ let diff = 0;
9
+ for (let i = 0; i < a.byteLength; i++) {
10
+ diff |= a[i] ^ b[i];
11
+ }
12
+ return diff === 0;
13
+ }
14
+ function hexToBytes(hex) {
15
+ if (hex.length % 2 !== 0) return null;
16
+ const out = new Uint8Array(hex.length / 2);
17
+ for (let i = 0; i < out.byteLength; i++) {
18
+ const byte = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
19
+ if (Number.isNaN(byte)) return null;
20
+ out[i] = byte;
21
+ }
22
+ return out;
23
+ }
24
+ function pickSignature(raw) {
25
+ if (raw === void 0) return null;
26
+ if (Array.isArray(raw)) {
27
+ for (const v of raw) {
28
+ if (typeof v === "string" && v.length > 0) return v;
29
+ }
30
+ return null;
31
+ }
32
+ return typeof raw === "string" && raw.length > 0 ? raw : null;
33
+ }
34
+ function bytes(s) {
35
+ return textCodec.utf8Encoder.encode(s);
36
+ }
37
+ function bodyBytes(body) {
38
+ return typeof body === "string" ? bytes(body) : body;
39
+ }
40
+ async function hmacSha256(secret, body) {
41
+ const secretBytes = bytes(secret);
42
+ const key = await globalThis.crypto.subtle.importKey(
43
+ "raw",
44
+ secretBytes.buffer.slice(
45
+ secretBytes.byteOffset,
46
+ secretBytes.byteOffset + secretBytes.byteLength
47
+ ),
48
+ { name: "HMAC", hash: "SHA-256" },
49
+ false,
50
+ ["sign"]
51
+ );
52
+ const sig = await globalThis.crypto.subtle.sign(
53
+ "HMAC",
54
+ key,
55
+ body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength)
56
+ );
57
+ return new Uint8Array(sig);
58
+ }
59
+ function tryParse(raw) {
60
+ try {
61
+ return JSON.parse(raw);
62
+ } catch {
63
+ return null;
64
+ }
65
+ }
66
+ function looksLikePayload(value) {
67
+ return typeof value === "object" && value !== null && Array.isArray(value.events);
68
+ }
69
+ async function verifyWebhookSignature(opts) {
70
+ if (typeof opts.secret !== "string" || opts.secret.length === 0) {
71
+ return { valid: false, payload: null, reason: "missing signing secret" };
72
+ }
73
+ const signature = pickSignature(opts.signature);
74
+ if (signature === null) {
75
+ return { valid: false, payload: null, reason: "missing signature header" };
76
+ }
77
+ if (!signature.startsWith(SIGNATURE_VERSION_PREFIX)) {
78
+ return { valid: false, payload: null, reason: "unsupported signature version" };
79
+ }
80
+ const claimed = hexToBytes(signature.slice(SIGNATURE_VERSION_PREFIX.length).toLowerCase());
81
+ if (claimed === null) {
82
+ return { valid: false, payload: null, reason: "bad signature format" };
83
+ }
84
+ const raw = bodyBytes(opts.body);
85
+ const expected = await hmacSha256(opts.secret, raw);
86
+ if (!timingSafeEqual(claimed, expected)) {
87
+ return { valid: false, payload: null, reason: "signature mismatch" };
88
+ }
89
+ const decoded = typeof opts.body === "string" ? opts.body : textCodec.utf8Decoder.decode(raw);
90
+ const parsed = tryParse(decoded);
91
+ if (!looksLikePayload(parsed)) {
92
+ return { valid: false, payload: null, reason: "invalid payload shape" };
93
+ }
94
+ return { valid: true, payload: parsed, reason: null };
95
+ }
96
+ async function requireValidWebhook(opts) {
97
+ const result = await verifyWebhookSignature(opts);
98
+ if (!result.valid || result.payload === null) {
99
+ throw new Error(`B2 webhook verification failed: ${result.reason ?? "unknown"}`);
100
+ }
101
+ return result.payload;
102
+ }
103
+ exports.B2_WEBHOOK_SIGNATURE_HEADER = B2_WEBHOOK_SIGNATURE_HEADER;
104
+ exports.requireValidWebhook = requireValidWebhook;
105
+ exports.verifyWebhookSignature = verifyWebhookSignature;
106
+ //# sourceMappingURL=webhook.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.cjs","sources":["../../src/notifications/webhook.ts"],"sourcesContent":["import type { EventType } from '../types/notifications.ts'\nimport { utf8Decoder, utf8Encoder } from '../util/text-codec.ts'\n\n/**\n * The HTTP header B2 attaches to every event-notification webhook delivery.\n * The value is a versioned HMAC-SHA256 signature of the raw request body:\n * `v1=<lowercase-hex>`.\n *\n * The lowercase form matches Node's `req.headers` normalisation and most\n * server-framework conventions. Producers must compare case-insensitively.\n */\nexport const B2_WEBHOOK_SIGNATURE_HEADER = 'x-bz-event-notification-signature'\n\n/** Current B2 event-notification signature scheme prefix. */\nconst SIGNATURE_VERSION_PREFIX = 'v1='\n\n/**\n * A single event entry inside a B2 webhook payload.\n *\n * The `events` array on the parsed body contains zero or more of these. Most\n * deliveries hold a single event, but B2 may coalesce multiple events from the\n * same bucket into one delivery for efficiency, so callers should iterate.\n *\n * @see https://www.backblaze.com/apidocs/event-notifications-overview\n */\nexport interface WebhookEvent {\n /** Account that owns the bucket the event fired on. */\n readonly accountId: string\n /** Bucket ID the event fired on. */\n readonly bucketId: string\n /** Bucket name at the moment the event fired. */\n readonly bucketName: string\n /** Globally unique event identifier (useful for idempotency on the receiver). */\n readonly eventId: string\n /** Event time in UNIX milliseconds (UTC). */\n readonly eventTimestamp: number\n /** Specific event type, e.g. `'b2:ObjectCreated:Upload'`. */\n readonly eventType: EventType\n /** Schema version of the event payload. Currently `1`. */\n readonly eventVersion: number\n /** Name of the `EventNotificationRule` on the bucket that matched. */\n readonly matchedRuleName: string\n /** B2 file name of the affected object. */\n readonly objectName: string\n /** Affected object's size in bytes, when present (absent for some delete events). */\n readonly objectSize?: number\n /** Specific file version ID, when applicable. */\n readonly objectVersionId?: string\n}\n\n/**\n * The complete JSON body B2 POSTs to a webhook endpoint after signature\n * verification succeeds. See {@link verifyWebhookSignature}.\n */\nexport interface WebhookPayload {\n /** One or more event entries. Always non-empty on real deliveries. */\n readonly events: readonly WebhookEvent[]\n}\n\n/**\n * Options for {@link verifyWebhookSignature} and {@link requireValidWebhook}.\n */\nexport interface VerifyWebhookOptions {\n /**\n * The raw request body B2 sent. MUST be the exact bytes received: any\n * JSON re-serialisation or whitespace normalisation will break the HMAC.\n *\n * Pass a `Uint8Array` whenever the surrounding framework gives you raw\n * bytes (e.g. `req.rawBody` in fastify, `req.arrayBuffer()` in Hono /\n * Workers). The string overload is provided for convenience when a\n * framework already decoded the body as UTF-8.\n */\n readonly body: string | Uint8Array\n /**\n * Value of the {@link B2_WEBHOOK_SIGNATURE_HEADER} header.\n *\n * Accepts a single string or an array (Node's `req.headers` returns\n * `string | string[] | undefined`). When an array is supplied, the first\n * non-empty element is used: B2 only ever sends one value, and rejecting\n * the multi-value case prevents callers from accidentally trusting a\n * spoofed second header injected by a buggy reverse proxy.\n */\n readonly signature: string | readonly string[] | undefined\n /**\n * The signing secret from `EventNotificationRule.targetConfiguration.hmacSha256SigningSecret`.\n *\n * This is the exact string B2 returned in the `b2_set_bucket_notification_rules`\n * response. Do NOT base64-decode or otherwise transform it.\n */\n readonly secret: string\n}\n\n/**\n * Outcome of {@link verifyWebhookSignature}.\n *\n * The verifier never throws; instead it returns a discriminated result so\n * callers can branch on `valid` and log `reason` without try/catch noise.\n * Use {@link requireValidWebhook} when an exception-based control flow is\n * more convenient.\n */\nexport interface VerifyWebhookResult {\n /** `true` only when the HMAC matched and the body parsed as a valid payload. */\n readonly valid: boolean\n /** Parsed payload when {@link valid} is `true`; otherwise `null`. */\n readonly payload: WebhookPayload | null\n /** Short reason describing why verification failed, or `null` on success. */\n readonly reason: string | null\n}\n\n/**\n * Constant-time comparison of two equal-length byte sequences.\n *\n * Web Crypto exposes no native timing-safe compare, so we do the standard\n * XOR-and-OR pattern ourselves. The early-out on length mismatch is fine\n * here because the signature length is publicly fixed (32 bytes for\n * HMAC-SHA256), so a length-mismatch branch leaks nothing about the secret.\n *\n * @param a - First byte sequence.\n * @param b - Second byte sequence.\n *\n * @returns `true` if the byte sequences are byte-for-byte equal.\n */\nfunction timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.byteLength !== b.byteLength) return false\n let diff = 0\n for (let i = 0; i < a.byteLength; i++) {\n // Non-null asserted: `a` and `b` have the same length and `i` is in range.\n diff |= (a[i] as number) ^ (b[i] as number)\n }\n return diff === 0\n}\n\n/**\n * Decode a lowercase hex string into bytes. Returns `null` on any malformed\n * input (odd length, non-hex characters). We don't surface a thrown error\n * because all malformed signatures should land in the same\n * `reason: 'bad signature format'` bucket on the verifier's caller,\n * regardless of which specific malformation triggered it.\n *\n * @param hex - The lowercase hex string to decode.\n *\n * @returns The decoded bytes, or `null` if the input was not valid hex.\n */\nfunction hexToBytes(hex: string): Uint8Array | null {\n if (hex.length % 2 !== 0) return null\n const out = new Uint8Array(hex.length / 2)\n for (let i = 0; i < out.byteLength; i++) {\n const byte = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16)\n if (Number.isNaN(byte)) return null\n out[i] = byte\n }\n return out\n}\n\n/**\n * Pick the single signature string from {@link VerifyWebhookOptions.signature}.\n * Returns `null` if absent, empty, or supplied as an empty array.\n *\n * @param raw - The signature value as supplied by the caller.\n *\n * @returns The chosen signature string, or `null` if no candidate was usable.\n */\nfunction pickSignature(raw: VerifyWebhookOptions['signature']): string | null {\n if (raw === undefined) return null\n if (Array.isArray(raw)) {\n for (const v of raw) {\n if (typeof v === 'string' && v.length > 0) return v\n }\n return null\n }\n return typeof raw === 'string' && raw.length > 0 ? raw : null\n}\n\n/**\n * Encode a UTF-8 string into bytes using a shared encoder.\n *\n * @param s - The string to encode.\n *\n * @returns The UTF-8 encoded bytes.\n */\nfunction bytes(s: string): Uint8Array {\n return utf8Encoder.encode(s)\n}\n\n/**\n * Normalise the body parameter to a `Uint8Array` view of its raw bytes.\n *\n * Strings are UTF-8 encoded. `Uint8Array` inputs pass through untouched.\n *\n * @param body - The raw request body as supplied by the caller.\n *\n * @returns The body as a byte sequence ready for HMAC computation.\n */\nfunction bodyBytes(body: string | Uint8Array): Uint8Array {\n return typeof body === 'string' ? bytes(body) : body\n}\n\n/**\n * Compute the HMAC-SHA256 of `body` under `secret` using the isomorphic Web\n * Crypto API. Works in Node 22+, browsers, Bun, Deno, and Cloudflare Workers\n * without any platform-specific code.\n *\n * @param secret - The HMAC signing secret.\n * @param body - The bytes to sign.\n *\n * @returns The 32-byte HMAC-SHA256 digest.\n */\nasync function hmacSha256(secret: string, body: Uint8Array): Promise<Uint8Array> {\n // The explicit `slice(byteOffset, byteOffset + byteLength)` defends against\n // a Uint8Array view that points at a subset of a larger buffer. Casting to\n // `ArrayBuffer` is needed because TS 5.7+ types Uint8Array's buffer as\n // `ArrayBufferLike`, which includes `SharedArrayBuffer`. Web Crypto's\n // signatures only accept the plain `ArrayBuffer` variant.\n const secretBytes = bytes(secret)\n const key = await globalThis.crypto.subtle.importKey(\n 'raw',\n secretBytes.buffer.slice(\n secretBytes.byteOffset,\n secretBytes.byteOffset + secretBytes.byteLength,\n ) as ArrayBuffer,\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign'],\n )\n const sig = await globalThis.crypto.subtle.sign(\n 'HMAC',\n key,\n body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength) as ArrayBuffer,\n )\n return new Uint8Array(sig)\n}\n\n/**\n * Best-effort JSON parse that returns `null` on failure. We accept partial\n * structural mismatches (no `events` array etc.) at the caller's discretion.\n *\n * @param raw - The decoded request body string.\n *\n * @returns The parsed payload, or `null` if `raw` is not valid JSON.\n */\nfunction tryParse(raw: string): unknown {\n try {\n return JSON.parse(raw) as unknown\n } catch {\n return null\n }\n}\n\n/**\n * Narrow `value` to {@link WebhookPayload}. Currently only checks that\n * `events` is an array; per-event validation is the caller's responsibility\n * since B2 may add new optional fields and we don't want to reject deliveries\n * that include them.\n *\n * @param value - The parsed JSON value to validate.\n *\n * @returns `true` if the value matches the {@link WebhookPayload} shape.\n */\nfunction looksLikePayload(value: unknown): value is WebhookPayload {\n return (\n typeof value === 'object' &&\n value !== null &&\n Array.isArray((value as { events?: unknown }).events)\n )\n}\n\n/**\n * Verify the HMAC-SHA256 signature B2 attaches to event-notification webhooks\n * and parse the body on success.\n *\n * Never throws: returns a discriminated {@link VerifyWebhookResult}. Use this\n * when you want a single, explicit place to branch on `valid` and log the\n * `reason` on rejection.\n *\n * @param opts - The body, signature header, and signing secret. See {@link VerifyWebhookOptions}.\n *\n * @returns Verification result with optional parsed payload and failure reason.\n *\n * @example\n * ```ts\n * import { verifyWebhookSignature, B2_WEBHOOK_SIGNATURE_HEADER } from '@backblaze-labs/b2-sdk/notifications'\n *\n * app.post('/webhook', async (req, res) => {\n * const raw = await readRawBody(req) // raw bytes, NOT json\n * const result = await verifyWebhookSignature({\n * body: raw,\n * signature: req.headers[B2_WEBHOOK_SIGNATURE_HEADER],\n * secret: process.env.B2_WEBHOOK_SECRET,\n * })\n * if (!result.valid) return res.status(401).send(result.reason)\n * for (const event of result.payload.events) handleEvent(event)\n * res.status(204).end()\n * })\n * ```\n *\n */\nexport async function verifyWebhookSignature(\n opts: VerifyWebhookOptions,\n): Promise<VerifyWebhookResult> {\n if (typeof opts.secret !== 'string' || opts.secret.length === 0) {\n return { valid: false, payload: null, reason: 'missing signing secret' }\n }\n\n const signature = pickSignature(opts.signature)\n if (signature === null) {\n return { valid: false, payload: null, reason: 'missing signature header' }\n }\n\n if (!signature.startsWith(SIGNATURE_VERSION_PREFIX)) {\n return { valid: false, payload: null, reason: 'unsupported signature version' }\n }\n\n const claimed = hexToBytes(signature.slice(SIGNATURE_VERSION_PREFIX.length).toLowerCase())\n if (claimed === null) {\n return { valid: false, payload: null, reason: 'bad signature format' }\n }\n\n const raw = bodyBytes(opts.body)\n const expected = await hmacSha256(opts.secret, raw)\n\n if (!timingSafeEqual(claimed, expected)) {\n return { valid: false, payload: null, reason: 'signature mismatch' }\n }\n\n const decoded = typeof opts.body === 'string' ? opts.body : utf8Decoder.decode(raw)\n const parsed = tryParse(decoded)\n if (!looksLikePayload(parsed)) {\n return { valid: false, payload: null, reason: 'invalid payload shape' }\n }\n\n return { valid: true, payload: parsed, reason: null }\n}\n\n/**\n * Throwing wrapper around {@link verifyWebhookSignature}. Returns the parsed\n * payload on success; throws an `Error` whose message is the verifier's\n * `reason` string on any failure.\n *\n * Useful when you want the verification to integrate with your framework's\n * existing error-handling middleware rather than handling the result inline.\n *\n * @param opts - The body, signature header, and signing secret. See {@link VerifyWebhookOptions}.\n *\n * @returns The parsed webhook payload.\n *\n * @throws When verification fails for any reason.\n */\nexport async function requireValidWebhook(opts: VerifyWebhookOptions): Promise<WebhookPayload> {\n const result = await verifyWebhookSignature(opts)\n if (!result.valid || result.payload === null) {\n throw new Error(`B2 webhook verification failed: ${result.reason ?? 'unknown'}`)\n }\n return result.payload\n}\n"],"names":["utf8Encoder","utf8Decoder"],"mappings":";;;AAWO,MAAM,8BAA8B;AAG3C,MAAM,2BAA2B;AA4GjC,SAAS,gBAAgB,GAAe,GAAwB;AAC9D,MAAI,EAAE,eA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AS,SAAS,OAAO;AAC/B,MAAI,CAAC,iBAAiB,MAAM,GAAG;AAC7B,WAAO,EAAE,OAAO,OAAO,SAAS,MAAM,QAAQ,wBAAA;AAAA,EAChD;AAEA,SAAO,EAAE,OAAO,MAAM,SAAS,QAAQ,QAAQ,KAAA;AACjD;AAgBA,eAAsB,oBAAoB,MAAqD;AAC7F,QAAM,SAAS,MAAM,uBAAuB,IAAI;AAChD,MAAI,CAAC,OAAO,SAAS,OAAO,YAAY,MAAM;AAC5C,UAAM,IAAI,MAAM,mCAAmC,OAAO,UAAU,SAAS,EAAE;AAAA,EACjF;AACA,SAAO,OAAO;AAChB;;;;"}
@@ -0,0 +1,146 @@
1
+ import { EventType } from '../types/notifications.js';
2
+ /**
3
+ * The HTTP header B2 attaches to every event-notification webhook delivery.
4
+ * The value is a versioned HMAC-SHA256 signature of the raw request body:
5
+ * `v1=<lowercase-hex>`.
6
+ *
7
+ * The lowercase form matches Node's `req.headers` normalisation and most
8
+ * server-framework conventions. Producers must compare case-insensitively.
9
+ */
10
+ export declare const B2_WEBHOOK_SIGNATURE_HEADER = "x-bz-event-notification-signature";
11
+ /**
12
+ * A single event entry inside a B2 webhook payload.
13
+ *
14
+ * The `events` array on the parsed body contains zero or more of these. Most
15
+ * deliveries hold a single event, but B2 may coalesce multiple events from the
16
+ * same bucket into one delivery for efficiency, so callers should iterate.
17
+ *
18
+ * @see https://www.backblaze.com/apidocs/event-notifications-overview
19
+ */
20
+ export interface WebhookEvent {
21
+ /** Account that owns the bucket the event fired on. */
22
+ readonly accountId: string;
23
+ /** Bucket ID the event fired on. */
24
+ readonly bucketId: string;
25
+ /** Bucket name at the moment the event fired. */
26
+ readonly bucketName: string;
27
+ /** Globally unique event identifier (useful for idempotency on the receiver). */
28
+ readonly eventId: string;
29
+ /** Event time in UNIX milliseconds (UTC). */
30
+ readonly eventTimestamp: number;
31
+ /** Specific event type, e.g. `'b2:ObjectCreated:Upload'`. */
32
+ readonly eventType: EventType;
33
+ /** Schema version of the event payload. Currently `1`. */
34
+ readonly eventVersion: number;
35
+ /** Name of the `EventNotificationRule` on the bucket that matched. */
36
+ readonly matchedRuleName: string;
37
+ /** B2 file name of the affected object. */
38
+ readonly objectName: string;
39
+ /** Affected object's size in bytes, when present (absent for some delete events). */
40
+ readonly objectSize?: number;
41
+ /** Specific file version ID, when applicable. */
42
+ readonly objectVersionId?: string;
43
+ }
44
+ /**
45
+ * The complete JSON body B2 POSTs to a webhook endpoint after signature
46
+ * verification succeeds. See {@link verifyWebhookSignature}.
47
+ */
48
+ export interface WebhookPayload {
49
+ /** One or more event entries. Always non-empty on real deliveries. */
50
+ readonly events: readonly WebhookEvent[];
51
+ }
52
+ /**
53
+ * Options for {@link verifyWebhookSignature} and {@link requireValidWebhook}.
54
+ */
55
+ export interface VerifyWebhookOptions {
56
+ /**
57
+ * The raw request body B2 sent. MUST be the exact bytes received: any
58
+ * JSON re-serialisation or whitespace normalisation will break the HMAC.
59
+ *
60
+ * Pass a `Uint8Array` whenever the surrounding framework gives you raw
61
+ * bytes (e.g. `req.rawBody` in fastify, `req.arrayBuffer()` in Hono /
62
+ * Workers). The string overload is provided for convenience when a
63
+ * framework already decoded the body as UTF-8.
64
+ */
65
+ readonly body: string | Uint8Array;
66
+ /**
67
+ * Value of the {@link B2_WEBHOOK_SIGNATURE_HEADER} header.
68
+ *
69
+ * Accepts a single string or an array (Node's `req.headers` returns
70
+ * `string | string[] | undefined`). When an array is supplied, the first
71
+ * non-empty element is used: B2 only ever sends one value, and rejecting
72
+ * the multi-value case prevents callers from accidentally trusting a
73
+ * spoofed second header injected by a buggy reverse proxy.
74
+ */
75
+ readonly signature: string | readonly string[] | undefined;
76
+ /**
77
+ * The signing secret from `EventNotificationRule.targetConfiguration.hmacSha256SigningSecret`.
78
+ *
79
+ * This is the exact string B2 returned in the `b2_set_bucket_notification_rules`
80
+ * response. Do NOT base64-decode or otherwise transform it.
81
+ */
82
+ readonly secret: string;
83
+ }
84
+ /**
85
+ * Outcome of {@link verifyWebhookSignature}.
86
+ *
87
+ * The verifier never throws; instead it returns a discriminated result so
88
+ * callers can branch on `valid` and log `reason` without try/catch noise.
89
+ * Use {@link requireValidWebhook} when an exception-based control flow is
90
+ * more convenient.
91
+ */
92
+ export interface VerifyWebhookResult {
93
+ /** `true` only when the HMAC matched and the body parsed as a valid payload. */
94
+ readonly valid: boolean;
95
+ /** Parsed payload when {@link valid} is `true`; otherwise `null`. */
96
+ readonly payload: WebhookPayload | null;
97
+ /** Short reason describing why verification failed, or `null` on success. */
98
+ readonly reason: string | null;
99
+ }
100
+ /**
101
+ * Verify the HMAC-SHA256 signature B2 attaches to event-notification webhooks
102
+ * and parse the body on success.
103
+ *
104
+ * Never throws: returns a discriminated {@link VerifyWebhookResult}. Use this
105
+ * when you want a single, explicit place to branch on `valid` and log the
106
+ * `reason` on rejection.
107
+ *
108
+ * @param opts - The body, signature header, and signing secret. See {@link VerifyWebhookOptions}.
109
+ *
110
+ * @returns Verification result with optional parsed payload and failure reason.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * import { verifyWebhookSignature, B2_WEBHOOK_SIGNATURE_HEADER } from '@backblaze-labs/b2-sdk/notifications'
115
+ *
116
+ * app.post('/webhook', async (req, res) => {
117
+ * const raw = await readRawBody(req) // raw bytes, NOT json
118
+ * const result = await verifyWebhookSignature({
119
+ * body: raw,
120
+ * signature: req.headers[B2_WEBHOOK_SIGNATURE_HEADER],
121
+ * secret: process.env.B2_WEBHOOK_SECRET,
122
+ * })
123
+ * if (!result.valid) return res.status(401).send(result.reason)
124
+ * for (const event of result.payload.events) handleEvent(event)
125
+ * res.status(204).end()
126
+ * })
127
+ * ```
128
+ *
129
+ */
130
+ export declare function verifyWebhookSignature(opts: VerifyWebhookOptions): Promise<VerifyWebhookResult>;
131
+ /**
132
+ * Throwing wrapper around {@link verifyWebhookSignature}. Returns the parsed
133
+ * payload on success; throws an `Error` whose message is the verifier's
134
+ * `reason` string on any failure.
135
+ *
136
+ * Useful when you want the verification to integrate with your framework's
137
+ * existing error-handling middleware rather than handling the result inline.
138
+ *
139
+ * @param opts - The body, signature header, and signing secret. See {@link VerifyWebhookOptions}.
140
+ *
141
+ * @returns The parsed webhook payload.
142
+ *
143
+ * @throws When verification fails for any reason.
144
+ */
145
+ export declare function requireValidWebhook(opts: VerifyWebhookOptions): Promise<WebhookPayload>;
146
+ //# sourceMappingURL=webhook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/notifications/webhook.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAG1D;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,sCAAsC,CAAA;AAK9E;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,qFAAqF;IACrF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,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