@backblaze-labs/b2-sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +18 -5
  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/reauth-coalescer.cjs +65 -0
  6. package/dist/auth/reauth-coalescer.cjs.map +1 -0
  7. package/dist/auth/reauth-coalescer.d.cts +34 -0
  8. package/dist/auth/reauth-coalescer.d.cts.map +1 -0
  9. package/dist/auth/reauth-coalescer.d.ts +34 -0
  10. package/dist/auth/reauth-coalescer.d.ts.map +1 -0
  11. package/dist/auth/reauth-coalescer.js +65 -0
  12. package/dist/auth/reauth-coalescer.js.map +1 -0
  13. package/dist/backup/raw.cjs +37 -15
  14. package/dist/backup/raw.cjs.map +1 -1
  15. package/dist/backup/raw.d.cts +2 -2
  16. package/dist/backup/raw.d.cts.map +1 -1
  17. package/dist/backup/raw.d.ts +2 -2
  18. package/dist/backup/raw.d.ts.map +1 -1
  19. package/dist/backup/raw.js +37 -15
  20. package/dist/backup/raw.js.map +1 -1
  21. package/dist/bucket-validation.cjs +111 -0
  22. package/dist/bucket-validation.cjs.map +1 -0
  23. package/dist/bucket-validation.d.cts +27 -0
  24. package/dist/bucket-validation.d.cts.map +1 -0
  25. package/dist/bucket-validation.d.ts +27 -0
  26. package/dist/bucket-validation.d.ts.map +1 -0
  27. package/dist/bucket-validation.js +109 -0
  28. package/dist/bucket-validation.js.map +1 -0
  29. package/dist/bucket.cjs +123 -73
  30. package/dist/bucket.cjs.map +1 -1
  31. package/dist/bucket.d.cts +156 -61
  32. package/dist/bucket.d.cts.map +1 -1
  33. package/dist/bucket.d.ts +156 -61
  34. package/dist/bucket.d.ts.map +1 -1
  35. package/dist/bucket.js +123 -73
  36. package/dist/bucket.js.map +1 -1
  37. package/dist/client.cjs +29 -8
  38. package/dist/client.cjs.map +1 -1
  39. package/dist/client.d.cts +30 -9
  40. package/dist/client.d.cts.map +1 -1
  41. package/dist/client.d.ts +30 -9
  42. package/dist/client.d.ts.map +1 -1
  43. package/dist/client.js +29 -8
  44. package/dist/client.js.map +1 -1
  45. package/dist/download/single.cjs +38 -13
  46. package/dist/download/single.cjs.map +1 -1
  47. package/dist/download/single.d.cts +10 -4
  48. package/dist/download/single.d.cts.map +1 -1
  49. package/dist/download/single.d.ts +10 -4
  50. package/dist/download/single.d.ts.map +1 -1
  51. package/dist/download/single.js +38 -13
  52. package/dist/download/single.js.map +1 -1
  53. package/dist/errors/index.cjs +27 -4
  54. package/dist/errors/index.cjs.map +1 -1
  55. package/dist/errors/index.d.cts +15 -0
  56. package/dist/errors/index.d.cts.map +1 -1
  57. package/dist/errors/index.d.ts +15 -0
  58. package/dist/errors/index.d.ts.map +1 -1
  59. package/dist/errors/index.js +27 -5
  60. package/dist/errors/index.js.map +1 -1
  61. package/dist/http/non-idempotent-mutations.cjs +38 -0
  62. package/dist/http/non-idempotent-mutations.cjs.map +1 -0
  63. package/dist/http/non-idempotent-mutations.d.cts +25 -0
  64. package/dist/http/non-idempotent-mutations.d.cts.map +1 -0
  65. package/dist/http/non-idempotent-mutations.d.ts +25 -0
  66. package/dist/http/non-idempotent-mutations.d.ts.map +1 -0
  67. package/dist/http/non-idempotent-mutations.js +35 -0
  68. package/dist/http/non-idempotent-mutations.js.map +1 -0
  69. package/dist/http/transport.cjs +9 -8
  70. package/dist/http/transport.cjs.map +1 -1
  71. package/dist/http/transport.d.cts +5 -0
  72. package/dist/http/transport.d.cts.map +1 -1
  73. package/dist/http/transport.d.ts +5 -0
  74. package/dist/http/transport.d.ts.map +1 -1
  75. package/dist/http/transport.js +9 -8
  76. package/dist/http/transport.js.map +1 -1
  77. package/dist/http/user-agent.cjs +12 -1
  78. package/dist/http/user-agent.cjs.map +1 -1
  79. package/dist/http/user-agent.d.cts +8 -0
  80. package/dist/http/user-agent.d.cts.map +1 -1
  81. package/dist/http/user-agent.d.ts +8 -0
  82. package/dist/http/user-agent.d.ts.map +1 -1
  83. package/dist/http/user-agent.js +13 -3
  84. package/dist/http/user-agent.js.map +1 -1
  85. package/dist/index.cjs +25 -0
  86. package/dist/index.d.cts +10 -9
  87. package/dist/index.d.cts.map +1 -1
  88. package/dist/index.d.ts +10 -9
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +7 -6
  91. package/dist/notifications/index.cjs +3 -0
  92. package/dist/notifications/index.d.cts +2 -0
  93. package/dist/notifications/index.d.cts.map +1 -1
  94. package/dist/notifications/index.d.ts +2 -0
  95. package/dist/notifications/index.d.ts.map +1 -1
  96. package/dist/notifications/index.js +2 -1
  97. package/dist/object.cjs +12 -1
  98. package/dist/object.cjs.map +1 -1
  99. package/dist/object.d.cts +7 -1
  100. package/dist/object.d.cts.map +1 -1
  101. package/dist/object.d.ts +7 -1
  102. package/dist/object.d.ts.map +1 -1
  103. package/dist/object.js +12 -1
  104. package/dist/object.js.map +1 -1
  105. package/dist/partner/auth-core.cjs +4 -23
  106. package/dist/partner/auth-core.cjs.map +1 -1
  107. package/dist/partner/auth-core.d.cts +1 -1
  108. package/dist/partner/auth-core.d.cts.map +1 -1
  109. package/dist/partner/auth-core.d.ts +1 -1
  110. package/dist/partner/auth-core.d.ts.map +1 -1
  111. package/dist/partner/auth-core.js +5 -24
  112. package/dist/partner/auth-core.js.map +1 -1
  113. package/dist/partner/client.cjs +25 -10
  114. package/dist/partner/client.cjs.map +1 -1
  115. package/dist/partner/client.d.cts +32 -10
  116. package/dist/partner/client.d.cts.map +1 -1
  117. package/dist/partner/client.d.ts +32 -10
  118. package/dist/partner/client.d.ts.map +1 -1
  119. package/dist/partner/client.js +25 -10
  120. package/dist/partner/client.js.map +1 -1
  121. package/dist/partner/endpoint-url.cjs +1 -0
  122. package/dist/partner/endpoint-url.cjs.map +1 -1
  123. package/dist/partner/endpoint-url.d.cts +2 -0
  124. package/dist/partner/endpoint-url.d.cts.map +1 -1
  125. package/dist/partner/endpoint-url.d.ts +2 -0
  126. package/dist/partner/endpoint-url.d.ts.map +1 -1
  127. package/dist/partner/endpoint-url.js +1 -0
  128. package/dist/partner/endpoint-url.js.map +1 -1
  129. package/dist/partner/in-memory.cjs.map +1 -1
  130. package/dist/partner/in-memory.js.map +1 -1
  131. package/dist/partner/index.cjs +9 -0
  132. package/dist/partner/index.d.cts +11 -2
  133. package/dist/partner/index.d.cts.map +1 -1
  134. package/dist/partner/index.d.ts +11 -2
  135. package/dist/partner/index.d.ts.map +1 -1
  136. package/dist/partner/index.js +3 -1
  137. package/dist/partner/raw.cjs +52 -44
  138. package/dist/partner/raw.cjs.map +1 -1
  139. package/dist/partner/raw.d.cts +16 -19
  140. package/dist/partner/raw.d.cts.map +1 -1
  141. package/dist/partner/raw.d.ts +16 -19
  142. package/dist/partner/raw.d.ts.map +1 -1
  143. package/dist/partner/raw.js +52 -44
  144. package/dist/partner/raw.js.map +1 -1
  145. package/dist/partner/redaction.cjs +133 -108
  146. package/dist/partner/redaction.cjs.map +1 -1
  147. package/dist/partner/redaction.d.cts +47 -13
  148. package/dist/partner/redaction.d.cts.map +1 -1
  149. package/dist/partner/redaction.d.ts +47 -13
  150. package/dist/partner/redaction.d.ts.map +1 -1
  151. package/dist/partner/redaction.js +133 -109
  152. package/dist/partner/redaction.js.map +1 -1
  153. package/dist/raw/encoding.cjs +29 -10
  154. package/dist/raw/encoding.cjs.map +1 -1
  155. package/dist/raw/encoding.d.cts +3 -2
  156. package/dist/raw/encoding.d.cts.map +1 -1
  157. package/dist/raw/encoding.d.ts +3 -2
  158. package/dist/raw/encoding.d.ts.map +1 -1
  159. package/dist/raw/encoding.js +29 -10
  160. package/dist/raw/encoding.js.map +1 -1
  161. package/dist/raw/index.cjs +64 -39
  162. package/dist/raw/index.cjs.map +1 -1
  163. package/dist/raw/index.d.cts +21 -19
  164. package/dist/raw/index.d.cts.map +1 -1
  165. package/dist/raw/index.d.ts +21 -19
  166. package/dist/raw/index.d.ts.map +1 -1
  167. package/dist/raw/index.js +47 -40
  168. package/dist/raw/index.js.map +1 -1
  169. package/dist/raw/url.cjs.map +1 -1
  170. package/dist/raw/url.d.cts +3 -3
  171. package/dist/raw/url.d.ts +3 -3
  172. package/dist/raw/url.js.map +1 -1
  173. package/dist/simulator/index.cjs +456 -125
  174. package/dist/simulator/index.cjs.map +1 -1
  175. package/dist/simulator/index.d.cts +16 -1
  176. package/dist/simulator/index.d.cts.map +1 -1
  177. package/dist/simulator/index.d.ts +16 -1
  178. package/dist/simulator/index.d.ts.map +1 -1
  179. package/dist/simulator/index.js +449 -130
  180. package/dist/simulator/index.js.map +1 -1
  181. package/dist/simulator/partner-capabilities.cjs +77 -0
  182. package/dist/simulator/partner-capabilities.cjs.map +1 -0
  183. package/dist/simulator/partner-capabilities.d.cts +53 -0
  184. package/dist/simulator/partner-capabilities.d.cts.map +1 -0
  185. package/dist/simulator/partner-capabilities.d.ts +53 -0
  186. package/dist/simulator/partner-capabilities.d.ts.map +1 -0
  187. package/dist/simulator/partner-capabilities.js +73 -0
  188. package/dist/simulator/partner-capabilities.js.map +1 -0
  189. package/dist/simulator/partner.cjs +55 -61
  190. package/dist/simulator/partner.cjs.map +1 -1
  191. package/dist/simulator/partner.d.cts +5 -2
  192. package/dist/simulator/partner.d.cts.map +1 -1
  193. package/dist/simulator/partner.d.ts +5 -2
  194. package/dist/simulator/partner.d.ts.map +1 -1
  195. package/dist/simulator/partner.js +56 -61
  196. package/dist/simulator/partner.js.map +1 -1
  197. package/dist/simulator/validation.cjs +160 -30
  198. package/dist/simulator/validation.cjs.map +1 -1
  199. package/dist/simulator/validation.d.cts +28 -6
  200. package/dist/simulator/validation.d.cts.map +1 -1
  201. package/dist/simulator/validation.d.ts +28 -6
  202. package/dist/simulator/validation.d.ts.map +1 -1
  203. package/dist/simulator/validation.js +148 -31
  204. package/dist/simulator/validation.js.map +1 -1
  205. package/dist/streams/file-source.cjs +1 -1
  206. package/dist/streams/file-source.cjs.map +1 -1
  207. package/dist/streams/file-source.js +1 -1
  208. package/dist/streams/file-source.js.map +1 -1
  209. package/dist/streams/hash.cjs +246 -13
  210. package/dist/streams/hash.cjs.map +1 -1
  211. package/dist/streams/hash.d.cts +37 -12
  212. package/dist/streams/hash.d.cts.map +1 -1
  213. package/dist/streams/hash.d.ts +37 -12
  214. package/dist/streams/hash.d.ts.map +1 -1
  215. package/dist/streams/hash.js +246 -15
  216. package/dist/streams/hash.js.map +1 -1
  217. package/dist/streams/index.cjs +2 -0
  218. package/dist/streams/index.d.cts +1 -1
  219. package/dist/streams/index.d.cts.map +1 -1
  220. package/dist/streams/index.d.ts +1 -1
  221. package/dist/streams/index.d.ts.map +1 -1
  222. package/dist/streams/index.js +2 -2
  223. package/dist/streams/progress.cjs +63 -4
  224. package/dist/streams/progress.cjs.map +1 -1
  225. package/dist/streams/progress.d.cts +28 -2
  226. package/dist/streams/progress.d.cts.map +1 -1
  227. package/dist/streams/progress.d.ts +28 -2
  228. package/dist/streams/progress.d.ts.map +1 -1
  229. package/dist/streams/progress.js +63 -4
  230. package/dist/streams/progress.js.map +1 -1
  231. package/dist/sync/download-staging.cjs +147 -35
  232. package/dist/sync/download-staging.cjs.map +1 -1
  233. package/dist/sync/download-staging.d.cts +25 -2
  234. package/dist/sync/download-staging.d.cts.map +1 -1
  235. package/dist/sync/download-staging.d.ts +25 -2
  236. package/dist/sync/download-staging.d.ts.map +1 -1
  237. package/dist/sync/download-staging.js +146 -36
  238. package/dist/sync/download-staging.js.map +1 -1
  239. package/dist/sync/index.d.cts +1 -1
  240. package/dist/sync/index.d.cts.map +1 -1
  241. package/dist/sync/index.d.ts +1 -1
  242. package/dist/sync/index.d.ts.map +1 -1
  243. package/dist/sync/local-file-io.cjs +5 -1
  244. package/dist/sync/local-file-io.cjs.map +1 -1
  245. package/dist/sync/local-file-io.d.cts +2 -0
  246. package/dist/sync/local-file-io.d.cts.map +1 -1
  247. package/dist/sync/local-file-io.d.ts +2 -0
  248. package/dist/sync/local-file-io.d.ts.map +1 -1
  249. package/dist/sync/local-file-io.js +5 -1
  250. package/dist/sync/local-file-io.js.map +1 -1
  251. package/dist/sync/pairing.cjs +1 -0
  252. package/dist/sync/pairing.cjs.map +1 -1
  253. package/dist/sync/pairing.js +1 -0
  254. package/dist/sync/pairing.js.map +1 -1
  255. package/dist/sync/scanners/b2.cjs +2 -0
  256. package/dist/sync/scanners/b2.cjs.map +1 -1
  257. package/dist/sync/scanners/b2.d.cts.map +1 -1
  258. package/dist/sync/scanners/b2.d.ts.map +1 -1
  259. package/dist/sync/scanners/b2.js +2 -0
  260. package/dist/sync/scanners/b2.js.map +1 -1
  261. package/dist/sync/scanners/local.cjs +150 -33
  262. package/dist/sync/scanners/local.cjs.map +1 -1
  263. package/dist/sync/scanners/local.d.cts +6 -0
  264. package/dist/sync/scanners/local.d.cts.map +1 -1
  265. package/dist/sync/scanners/local.d.ts +6 -0
  266. package/dist/sync/scanners/local.d.ts.map +1 -1
  267. package/dist/sync/scanners/local.js +150 -33
  268. package/dist/sync/scanners/local.js.map +1 -1
  269. package/dist/sync/synchronizer.cjs +76 -29
  270. package/dist/sync/synchronizer.cjs.map +1 -1
  271. package/dist/sync/synchronizer.d.cts +1 -0
  272. package/dist/sync/synchronizer.d.cts.map +1 -1
  273. package/dist/sync/synchronizer.d.ts +1 -0
  274. package/dist/sync/synchronizer.d.ts.map +1 -1
  275. package/dist/sync/synchronizer.js +76 -29
  276. package/dist/sync/synchronizer.js.map +1 -1
  277. package/dist/sync/types.d.cts +19 -3
  278. package/dist/sync/types.d.cts.map +1 -1
  279. package/dist/sync/types.d.ts +19 -3
  280. package/dist/sync/types.d.ts.map +1 -1
  281. package/dist/types/backup.d.cts +6 -1
  282. package/dist/types/backup.d.cts.map +1 -1
  283. package/dist/types/backup.d.ts +6 -1
  284. package/dist/types/backup.d.ts.map +1 -1
  285. package/dist/types/bucket.cjs +81 -11
  286. package/dist/types/bucket.cjs.map +1 -1
  287. package/dist/types/bucket.d.cts +190 -39
  288. package/dist/types/bucket.d.cts.map +1 -1
  289. package/dist/types/bucket.d.ts +190 -39
  290. package/dist/types/bucket.d.ts.map +1 -1
  291. package/dist/types/bucket.js +67 -12
  292. package/dist/types/bucket.js.map +1 -1
  293. package/dist/types/download.cjs.map +1 -1
  294. package/dist/types/download.d.cts +3 -17
  295. package/dist/types/download.d.cts.map +1 -1
  296. package/dist/types/download.d.ts +3 -17
  297. package/dist/types/download.d.ts.map +1 -1
  298. package/dist/types/download.js.map +1 -1
  299. package/dist/types/encryption.cjs +18 -0
  300. package/dist/types/encryption.cjs.map +1 -1
  301. package/dist/types/encryption.d.cts +21 -11
  302. package/dist/types/encryption.d.cts.map +1 -1
  303. package/dist/types/encryption.d.ts +21 -11
  304. package/dist/types/encryption.d.ts.map +1 -1
  305. package/dist/types/encryption.js +18 -0
  306. package/dist/types/encryption.js.map +1 -1
  307. package/dist/types/file.cjs +3 -0
  308. package/dist/types/file.cjs.map +1 -1
  309. package/dist/types/file.d.cts +125 -16
  310. package/dist/types/file.d.cts.map +1 -1
  311. package/dist/types/file.d.ts +125 -16
  312. package/dist/types/file.d.ts.map +1 -1
  313. package/dist/types/file.js +3 -1
  314. package/dist/types/file.js.map +1 -1
  315. package/dist/types/index.d.cts +7 -7
  316. package/dist/types/index.d.cts.map +1 -1
  317. package/dist/types/index.d.ts +7 -7
  318. package/dist/types/index.d.ts.map +1 -1
  319. package/dist/types/key.d.cts +4 -3
  320. package/dist/types/key.d.cts.map +1 -1
  321. package/dist/types/key.d.ts +4 -3
  322. package/dist/types/key.d.ts.map +1 -1
  323. package/dist/types/notifications.cjs +30 -0
  324. package/dist/types/notifications.cjs.map +1 -1
  325. package/dist/types/notifications.d.cts +26 -1
  326. package/dist/types/notifications.d.cts.map +1 -1
  327. package/dist/types/notifications.d.ts +26 -1
  328. package/dist/types/notifications.d.ts.map +1 -1
  329. package/dist/types/notifications.js +29 -1
  330. package/dist/types/notifications.js.map +1 -1
  331. package/dist/types/partner.cjs.map +1 -1
  332. package/dist/types/partner.d.cts +28 -36
  333. package/dist/types/partner.d.cts.map +1 -1
  334. package/dist/types/partner.d.ts +28 -36
  335. package/dist/types/partner.d.ts.map +1 -1
  336. package/dist/types/partner.js.map +1 -1
  337. package/dist/types/upload.d.cts +4 -0
  338. package/dist/types/upload.d.cts.map +1 -1
  339. package/dist/types/upload.d.ts +4 -0
  340. package/dist/types/upload.d.ts.map +1 -1
  341. package/dist/upload/large.cjs +10 -7
  342. package/dist/upload/large.cjs.map +1 -1
  343. package/dist/upload/large.d.cts +15 -6
  344. package/dist/upload/large.d.cts.map +1 -1
  345. package/dist/upload/large.d.ts +15 -6
  346. package/dist/upload/large.d.ts.map +1 -1
  347. package/dist/upload/large.js +10 -7
  348. package/dist/upload/large.js.map +1 -1
  349. package/dist/upload/options.cjs.map +1 -1
  350. package/dist/upload/options.d.cts +12 -0
  351. package/dist/upload/options.d.cts.map +1 -1
  352. package/dist/upload/options.d.ts +12 -0
  353. package/dist/upload/options.d.ts.map +1 -1
  354. package/dist/upload/options.js.map +1 -1
  355. package/dist/upload/resume.cjs +4 -3
  356. package/dist/upload/resume.cjs.map +1 -1
  357. package/dist/upload/resume.d.cts +6 -4
  358. package/dist/upload/resume.d.cts.map +1 -1
  359. package/dist/upload/resume.d.ts +6 -4
  360. package/dist/upload/resume.d.ts.map +1 -1
  361. package/dist/upload/resume.js +4 -3
  362. package/dist/upload/resume.js.map +1 -1
  363. package/dist/upload/retry.cjs +17 -10
  364. package/dist/upload/retry.cjs.map +1 -1
  365. package/dist/upload/retry.d.cts.map +1 -1
  366. package/dist/upload/retry.d.ts.map +1 -1
  367. package/dist/upload/retry.js +17 -10
  368. package/dist/upload/retry.js.map +1 -1
  369. package/dist/upload/single.cjs +35 -31
  370. package/dist/upload/single.cjs.map +1 -1
  371. package/dist/upload/single.d.cts +6 -0
  372. package/dist/upload/single.d.cts.map +1 -1
  373. package/dist/upload/single.d.ts +6 -0
  374. package/dist/upload/single.d.ts.map +1 -1
  375. package/dist/upload/single.js +35 -31
  376. package/dist/upload/single.js.map +1 -1
  377. package/dist/upload/stream.cjs +12 -1
  378. package/dist/upload/stream.cjs.map +1 -1
  379. package/dist/upload/stream.d.cts +6 -0
  380. package/dist/upload/stream.d.cts.map +1 -1
  381. package/dist/upload/stream.d.ts +6 -0
  382. package/dist/upload/stream.d.ts.map +1 -1
  383. package/dist/upload/stream.js +12 -1
  384. package/dist/upload/stream.js.map +1 -1
  385. package/dist/version.cjs +56 -4
  386. package/dist/version.cjs.map +1 -1
  387. package/dist/version.d.cts +53 -4
  388. package/dist/version.d.cts.map +1 -1
  389. package/dist/version.d.ts +53 -4
  390. package/dist/version.d.ts.map +1 -1
  391. package/dist/version.js +52 -5
  392. package/dist/version.js.map +1 -1
  393. package/package.json +11 -4
@@ -134,9 +134,9 @@ var PartnerClient = class {
134
134
  });
135
135
  return {
136
136
  page: resp,
137
- nextCursor: resp[0]?.nextEmail ?? void 0
137
+ nextCursor: resp.nextEmail ?? void 0
138
138
  };
139
- }, (page) => page.flatMap((result) => result.groupMembers), options.signal);
139
+ }, (page) => [...page.groupMembers], options.signal);
140
140
  }
141
141
  /**
142
142
  * Creates a new Backblaze account and adds it to a Partner group.
@@ -147,7 +147,7 @@ var PartnerClient = class {
147
147
  *
148
148
  * @param options - Group ID, member email, and optional region.
149
149
  *
150
- * @returns The created member result array, including the member application key.
150
+ * @returns The created member result, including the member application key.
151
151
  *
152
152
  * @experimental Partner API surface; shape may change as the Partner API docs evolve.
153
153
  */
@@ -183,26 +183,41 @@ var PartnerClient = class {
183
183
  }, options.signal !== void 0 ? { signal: options.signal } : void 0);
184
184
  }
185
185
  /**
186
- * Reserves one or more new B2 Reserve trial accounts.
186
+ * Reserves a new B2 Reserve trial account.
187
187
  *
188
188
  * This operation is non-idempotent and automatic retries/expired-token
189
189
  * reauthorization are disabled at the raw layer. If the request fails after
190
- * the server processes it, the returned application keys may be
191
- * unrecoverable; reconcile account state before reissuing a batch.
190
+ * the server processes it, the returned application key may be unrecoverable;
191
+ * reconcile account state before reissuing a request for the same email.
192
192
  *
193
- * @param request - A single trial account request or a non-empty request array.
193
+ * @param request - Email, trial duration, storage, and optional region for the account to create.
194
194
  * @param options - Optional abort signal.
195
195
  *
196
- * @returns The created reserve-trial account result array.
196
+ * @returns The created reserve-trial account result.
197
197
  *
198
198
  * @experimental Partner API surface; shape may change as the Partner API docs evolve.
199
199
  */
200
- async reserveTrialAccounts(request, options) {
201
- if (Array.isArray(request) && request.length === 0) throw new TypeError("reserveTrialAccounts request array must include at least one account request.");
200
+ async reserveTrialAccount(request, options) {
202
201
  const { groupsApiUrl, authToken } = this.groupsCoordinates(this.ensureGroupsAuthorization());
203
202
  return this.raw.reserveTrialCreateAccount(groupsApiUrl, authToken, request, options?.signal !== void 0 ? { signal: options.signal } : void 0);
204
203
  }
205
204
  /**
205
+ * Reserves a new B2 Reserve trial account.
206
+ *
207
+ * @param request - Email, trial duration, storage, and optional region for the account to create.
208
+ * @param options - Optional abort signal.
209
+ *
210
+ * @returns The created reserve-trial account result.
211
+ *
212
+ * @deprecated Use {@link reserveTrialAccount}. This plural alias is kept for
213
+ * callers that picked up the original experimental facade name.
214
+ *
215
+ * @experimental Partner API surface; shape may change as the Partner API docs evolve.
216
+ */
217
+ async reserveTrialAccounts(request, options) {
218
+ return this.reserveTrialAccount(request, options);
219
+ }
220
+ /**
206
221
  * Hides credentials and Partner tokens from `JSON.stringify(client)`.
207
222
  *
208
223
  * @returns A redacted diagnostic object.
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../../src/partner/client.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } 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 { AccountId, GroupId, PartnerToken } from '../types/ids.ts'\nimport type {\n CreateGroupMemberResponse,\n EjectGroupMemberResponse,\n ListedGroupMember,\n ListGroupMembersResponse,\n ListGroupsResponse,\n PartnerAuthorizeResponse,\n PartnerGroup,\n Region,\n ReserveTrialCreateAccountRequest,\n ReserveTrialCreateAccountRequestEntry,\n ReserveTrialCreateAccountResponse,\n} from '../types/partner.ts'\nimport { paginateItems } from '../util/paginator.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { PartnerAuthCore } from './auth-core.ts'\nimport type { PartnerRawClient } from './raw.ts'\nimport { PARTNER_TOKEN_REDACTED } from './redaction.ts'\n\nconst MASTER_KEY_REDACTED = '[redacted Master Application Key]'\n\n/**\n * Configuration options for creating a {@link PartnerClient}.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PartnerClientOptions {\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 * are trusted with the Master Application Key during authorize, so never\n * derive `realm` from untrusted input. URL values must use HTTPS, or\n * loopback IP literal HTTP for local testing only; Master Application Key\n * credentials are sent unencrypted over loopback HTTP. Unsupported schemes,\n * malformed URLs, non-URL strings, plaintext HTTP hostnames such as\n * `localhost`, and non-loopback plaintext HTTP are rejected before\n * credentials are sent. URL values must not include userinfo, query strings,\n * or fragments. Defaults to `\"production\"`.\n */\n readonly realm?: string\n /**\n * Storage backend for Partner authorization state. Defaults to\n * {@link InMemoryPartnerAccountInfo}. Cached authorization whose endpoint\n * URLs fail the configured realm policy is ignored by this client until\n * `authorize()` replaces it; shared stores are not cleared during\n * 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. By default the SDK locks the\n * default transport to host suffixes derived from the Partner authorize\n * response. Pass an explicit list to add trusted hosts, for example a test\n * proxy. An empty array adds no hosts and leaves the default guard enabled.\n *\n * Only consulted when {@link PartnerClientOptions.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 * This is intended only for controlled simulator/private-proxy tests. Never\n * enable it for URLs derived from untrusted input or production credentials.\n * Only consulted when {@link PartnerClientOptions.transport} is unset.\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.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PartnerAuthorizeOptions {\n /** Abort signal for cancelling the authorize request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for listing Partner groups.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface ListGroupsOptions {\n /** Optional group name filter. Multiple groups may share the same name. */\n readonly groupName?: string\n /** Group ID to start listing from for pagination. */\n readonly startGroupId?: GroupId\n /** Maximum groups to return in this page. Forwarded to `maxGroupCount`. */\n readonly pageSize?: number\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for paginating Partner groups.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PaginateGroupsOptions extends Omit<ListGroupsOptions, 'startGroupId'> {\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 listing Partner group members.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface ListGroupMembersOptions {\n /** Group ID whose active members should be listed. */\n readonly groupId: GroupId\n /** First member email address to return for pagination. */\n readonly startEmail?: string\n /** Maximum members to return in this page. Forwarded to `maxMemberCount`. */\n readonly pageSize?: number\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for paginating Partner group members.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PaginateGroupMembersOptions extends Omit<ListGroupMembersOptions, 'startEmail'> {\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 creating a Partner group member.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface CreateGroupMemberOptions {\n /** Group ID that the new Backblaze account will join. */\n readonly groupId: GroupId\n /** Email address for the new group member account. */\n readonly memberEmail: string\n /** Region for the new account's data, or null to use the current default region. */\n readonly region?: Region | null\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for ejecting a Partner group member.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface EjectGroupMemberOptions {\n /** Group ID that currently contains the member. */\n readonly groupId: GroupId\n /** Account ID of the group member being ejected. */\n readonly memberAccountId: AccountId\n /** Replacement email for the ejected account, or null to keep the current email address. */\n readonly email?: string | null\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for reserving B2 Reserve trial accounts.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface ReserveTrialAccountsOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/** Coordinates needed for Partner groups API requests. */\ninterface PartnerGroupsCoordinates {\n readonly groupsApiUrl: string\n readonly authToken: PartnerToken\n readonly adminAccountId: AccountId\n}\n\n/** Redacted JSON diagnostic shape emitted by {@link PartnerClient.toJSON}. */\nexport interface PartnerClientJson {\n /** Object kind for log consumers. */\n readonly type: 'PartnerClient'\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 Partner API client for groups, members, and B2 Reserve trials.\n *\n * @example\n * ```ts\n * const partner = new PartnerClient({\n * masterKeyId: process.env.B2_MASTER_KEY_ID,\n * masterKey: process.env.B2_MASTER_KEY,\n * })\n * await partner.authorize()\n * for await (const group of partner.paginateGroups()) {\n * console.log(group.groupName)\n * }\n * ```\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport class PartnerClient {\n /** Low-level client for direct Partner API calls. */\n readonly raw: PartnerRawClient\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 PartnerClient. Call {@link authorize} before making API requests.\n *\n * @param options - Configuration including credentials, realm, and transport settings.\n */\n constructor(options: PartnerClientOptions) {\n this.authCore = new PartnerAuthCore(options)\n this.raw = this.authCore.raw\n this.partnerAccountInfo = this.authCore.partnerAccountInfo\n this.urlGuard = this.authCore.urlGuard\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 Partner API surface; shape may change as the Partner API docs evolve.\n */\n async authorize(options?: PartnerAuthorizeOptions): Promise<PartnerAuthorizeResponse> {\n return this.authCore.authorize(options)\n }\n\n /**\n * Lists Partner groups for the authorized partner administrator account.\n *\n * @param options - Optional group filter and pagination settings.\n *\n * @returns A page of Partner groups with an optional continuation cursor.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async listGroups(options?: ListGroupsOptions): Promise<ListGroupsResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.listGroups(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n ...(options?.groupName !== undefined ? { groupName: options.groupName } : {}),\n ...(options?.startGroupId !== undefined ? { startGroupId: options.startGroupId } : {}),\n ...(options?.pageSize !== undefined ? { maxGroupCount: options.pageSize } : {}),\n },\n options?.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Async iterator that yields every Partner group for the authorized account.\n *\n * @param options - Optional group filter, page size, and abort signal.\n *\n * @returns An async iterable of {@link PartnerGroup} entries.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n paginateGroups(options?: PaginateGroupsOptions): AsyncIterableIterator<PartnerGroup> {\n return paginateItems(\n async (cursor: GroupId | undefined) => {\n const resp = await this.listGroups({\n ...(options?.groupName !== undefined ? { groupName: options.groupName } : {}),\n ...(options?.pageSize !== undefined ? { pageSize: options.pageSize } : {}),\n ...(cursor !== undefined ? { startGroupId: cursor } : {}),\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n })\n return { page: resp, nextCursor: resp.nextGroupId ?? undefined }\n },\n (page) => page.groups,\n options?.signal,\n )\n }\n\n /**\n * Lists active members for a Partner group.\n *\n * @param options - Group ID plus optional pagination settings.\n *\n * @returns A page of group-member results with an optional continuation cursor.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async listGroupMembers(options: ListGroupMembersOptions): Promise<ListGroupMembersResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.listGroupMembers(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n groupId: options.groupId,\n ...(options.startEmail !== undefined ? { startEmail: options.startEmail } : {}),\n ...(options.pageSize !== undefined ? { maxMemberCount: options.pageSize } : {}),\n },\n options.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Async iterator that yields every active member for a Partner group.\n *\n * @param options - Group ID plus optional page size and abort signal.\n *\n * @returns An async iterable of {@link ListedGroupMember} entries.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n paginateGroupMembers(\n options: PaginateGroupMembersOptions,\n ): AsyncIterableIterator<ListedGroupMember> {\n return paginateItems(\n async (cursor: string | undefined) => {\n const resp = await this.listGroupMembers({\n groupId: options.groupId,\n ...(options.pageSize !== undefined ? { pageSize: options.pageSize } : {}),\n ...(cursor !== undefined ? { startEmail: cursor } : {}),\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n })\n // The API returns an array for consistency with batch-capable Partner\n // surfaces, but this request is scoped to one group ID.\n const result = resp[0]\n return {\n page: resp,\n nextCursor: result?.nextEmail ?? undefined,\n }\n },\n (page) => page.flatMap((result) => result.groupMembers),\n options.signal,\n )\n }\n\n /**\n * Creates a new Backblaze account and adds it to a Partner group.\n *\n * This mutation is non-idempotent. Automatic retries and expired-token\n * reauthorization are disabled; long-running batch callers must catch token\n * expiry, call {@link authorize}, and decide whether to issue a new request.\n *\n * @param options - Group ID, member email, and optional region.\n *\n * @returns The created member result array, including the member application key.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async createGroupMember(options: CreateGroupMemberOptions): Promise<CreateGroupMemberResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.createGroupMember(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n groupId: options.groupId,\n memberEmail: options.memberEmail,\n ...(options.region !== undefined ? { region: options.region } : {}),\n },\n options.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Ejects an active member from a Partner group without deleting the account.\n *\n * This mutation is non-idempotent. Automatic retries and expired-token\n * reauthorization are disabled; long-running batch callers must catch token\n * expiry, call {@link authorize}, and decide whether to issue a new request.\n *\n * @param options - Group ID, member account ID, and optional replacement email.\n *\n * @returns The ejected member object.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async ejectGroupMember(options: EjectGroupMemberOptions): Promise<EjectGroupMemberResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.ejectGroupMember(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n groupId: options.groupId,\n memberAccountId: options.memberAccountId,\n ...(options.email !== undefined ? { email: options.email } : {}),\n },\n options.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Reserves one or more new B2 Reserve trial accounts.\n *\n * This operation is non-idempotent and automatic retries/expired-token\n * reauthorization are disabled at the raw layer. If the request fails after\n * the server processes it, the returned application keys may be\n * unrecoverable; reconcile account state before reissuing a batch.\n *\n * @param request - A single trial account request or a non-empty request array.\n * @param options - Optional abort signal.\n *\n * @returns The created reserve-trial account result array.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async reserveTrialAccounts(\n request: ReserveTrialCreateAccountRequestEntry | ReserveTrialCreateAccountRequest,\n options?: ReserveTrialAccountsOptions,\n ): Promise<ReserveTrialCreateAccountResponse> {\n if (Array.isArray(request) && request.length === 0) {\n throw new TypeError(\n 'reserveTrialAccounts request array must include at least one account request.',\n )\n }\n const { groupsApiUrl, authToken } = this.groupsCoordinates(this.ensureGroupsAuthorization())\n return this.raw.reserveTrialCreateAccount(\n groupsApiUrl,\n authToken,\n request,\n options?.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Hides credentials and Partner tokens from `JSON.stringify(client)`.\n *\n * @returns A redacted diagnostic object.\n */\n toJSON(): PartnerClientJson {\n return {\n type: 'PartnerClient',\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 `[PartnerClient ${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 private ensureGroupsAuthorization(): PartnerAuthorizeResponse {\n const auth = this.partnerAccountInfo.getAuth()\n if (auth === null) {\n throw new B2PartnerAuthorizationError('Not authorized. Call PartnerClient.authorize() first.')\n }\n const suffixes = this.authCore.activateEndpointSuffixes(auth)\n this.raw.setAuthorizedEndpointSuffixes(suffixes)\n return auth\n }\n\n private groupsCoordinates(auth: PartnerAuthorizeResponse): PartnerGroupsCoordinates {\n const groupsApiUrl = auth.apiInfo.groupsApi?.groupsApiUrl\n if (groupsApiUrl === undefined) {\n throw new B2PartnerAuthorizationError(\n 'Partner API is not available; PartnerClient.authorize() did not return apiInfo.groupsApi.',\n )\n }\n return {\n groupsApiUrl,\n authToken: auth.authorizationToken,\n adminAccountId: auth.accountId,\n }\n }\n}\n"],"mappings":";;;;;AAwBA,IAAM,sBAAsB;;;;;;;;;;;;;;;;;;AA2N5B,IAAa,gBAAb,MAA2B;;CAEzB;;CAEA;;;;;;CAMA;CACA;;;;;;CAOA,YAAY,SAA+B;EACzC,KAAK,WAAW,IAAI,gBAAgB,OAAO;EAC3C,KAAK,MAAM,KAAK,SAAS;EACzB,KAAK,qBAAqB,KAAK,SAAS;EACxC,KAAK,WAAW,KAAK,SAAS;CAChC;;;;;;;;;;CAWA,MAAM,UAAU,SAAsE;EACpF,OAAO,KAAK,SAAS,UAAU,OAAO;CACxC;;;;;;;;;;CAWA,MAAM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,GACA,QAAQ,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,KAAA,CAC9D;CACF;;;;;;;;;;;;;;;;CAiBA,MAAM,qBACJ,SACA,SAC4C;EAC5C,IAAI,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,GAC/C,MAAM,IAAI,UACR,+EACF;EAEF,MAAM,EAAE,cAAc,cAAc,KAAK,kBAAkB,KAAK,0BAA0B,CAAC;EAC3F,OAAO,KAAK,IAAI,0BACd,cACA,WACA,SACA,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,KAAA,CAC/D;CACF;;;;;;CAOA,SAA4B;EAC1B,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,kBAAkB,oBAAoB;CAC/C;;;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;CAEA,4BAA8D;EAC5D,MAAM,OAAO,KAAK,mBAAmB,QAAQ;EAC7C,IAAI,SAAS,MACX,MAAM,IAAI,4BAA4B,uDAAuD;EAE/F,MAAM,WAAW,KAAK,SAAS,yBAAyB,IAAI;EAC5D,KAAK,IAAI,8BAA8B,QAAQ;EAC/C,OAAO;CACT;CAEA,kBAA0B,MAA0D;EAClF,MAAM,eAAe,KAAK,QAAQ,WAAW;EAC7C,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,4BACR,2FACF;EAEF,OAAO;GACL;GACA,WAAW,KAAK;GAChB,gBAAgB,KAAK;EACvB;CACF;AACF"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/partner/client.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } 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 { AccountId, GroupId, PartnerToken } from '../types/ids.ts'\nimport type {\n CreateGroupMemberResponse,\n EjectGroupMemberResponse,\n ListedGroupMember,\n ListGroupMembersResponse,\n ListGroupsResponse,\n PartnerAuthorizeResponse,\n PartnerGroup,\n Region,\n ReserveTrialCreateAccountRequest,\n ReserveTrialCreateAccountResponse,\n} from '../types/partner.ts'\nimport { paginateItems } from '../util/paginator.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { PartnerAuthCore } from './auth-core.ts'\nimport type { PartnerRawClient } from './raw.ts'\nimport { PARTNER_TOKEN_REDACTED } from './redaction.ts'\n\nconst MASTER_KEY_REDACTED = '[redacted Master Application Key]'\n\n/**\n * Configuration options for creating a {@link PartnerClient}.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PartnerClientOptions {\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 * are trusted with the Master Application Key during authorize, so never\n * derive `realm` from untrusted input. URL values must use HTTPS, or\n * loopback IP literal HTTP for local testing only; Master Application Key\n * credentials are sent unencrypted over loopback HTTP. Unsupported schemes,\n * malformed URLs, non-URL strings, plaintext HTTP hostnames such as\n * `localhost`, and non-loopback plaintext HTTP are rejected before\n * credentials are sent. URL values must not include userinfo, query strings,\n * or fragments. Defaults to `\"production\"`.\n */\n readonly realm?: string\n /**\n * Storage backend for Partner authorization state. Defaults to\n * {@link InMemoryPartnerAccountInfo}. Cached authorization whose endpoint\n * URLs fail the configured realm policy is ignored by this client until\n * `authorize()` replaces it; shared stores are not cleared during\n * 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. By default the SDK locks the\n * default transport to host suffixes derived from the Partner authorize\n * response. Pass an explicit list to add trusted hosts, for example a test\n * proxy. An empty array adds no hosts and leaves the default guard enabled.\n *\n * Only consulted when {@link PartnerClientOptions.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 * This is intended only for controlled simulator/private-proxy tests. Never\n * enable it for URLs derived from untrusted input or production credentials.\n * Only consulted when {@link PartnerClientOptions.transport} is unset.\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.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PartnerAuthorizeOptions {\n /** Abort signal for cancelling the authorize request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for listing Partner groups.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface ListGroupsOptions {\n /** Optional group name filter. Multiple groups may share the same name. */\n readonly groupName?: string\n /** Group ID to start listing from for pagination. */\n readonly startGroupId?: GroupId\n /** Maximum groups to return in this page. Forwarded to `maxGroupCount`. */\n readonly pageSize?: number\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for paginating Partner groups.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PaginateGroupsOptions extends Omit<ListGroupsOptions, 'startGroupId'> {\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 listing Partner group members.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface ListGroupMembersOptions {\n /** Group ID whose active members should be listed. */\n readonly groupId: GroupId\n /** First member email address to return for pagination. */\n readonly startEmail?: string\n /** Maximum members to return in this page. Forwarded to `maxMemberCount`. */\n readonly pageSize?: number\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for paginating Partner group members.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface PaginateGroupMembersOptions extends Omit<ListGroupMembersOptions, 'startEmail'> {\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 creating a Partner group member.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface CreateGroupMemberOptions {\n /** Group ID that the new Backblaze account will join. */\n readonly groupId: GroupId\n /** Email address for the new group member account. */\n readonly memberEmail: string\n /** Region for the new account's data, or null to use the current default region. */\n readonly region?: Region | null\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for ejecting a Partner group member.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface EjectGroupMemberOptions {\n /** Group ID that currently contains the member. */\n readonly groupId: GroupId\n /** Account ID of the group member being ejected. */\n readonly memberAccountId: AccountId\n /** Replacement email for the ejected account, or null to keep the current email address. */\n readonly email?: string | null\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for reserving a B2 Reserve trial account.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport interface ReserveTrialAccountOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Options for reserving a B2 Reserve trial account.\n *\n * @deprecated Use {@link ReserveTrialAccountOptions}.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport type ReserveTrialAccountsOptions = ReserveTrialAccountOptions\n\n/** Coordinates needed for Partner groups API requests. */\ninterface PartnerGroupsCoordinates {\n readonly groupsApiUrl: string\n readonly authToken: PartnerToken\n readonly adminAccountId: AccountId\n}\n\n/** Redacted JSON diagnostic shape emitted by {@link PartnerClient.toJSON}. */\nexport interface PartnerClientJson {\n /** Object kind for log consumers. */\n readonly type: 'PartnerClient'\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 Partner API client for groups, members, and B2 Reserve trials.\n *\n * @example\n * ```ts\n * const partner = new PartnerClient({\n * masterKeyId: process.env.B2_MASTER_KEY_ID,\n * masterKey: process.env.B2_MASTER_KEY,\n * })\n * await partner.authorize()\n * for await (const group of partner.paginateGroups()) {\n * console.log(group.groupName)\n * }\n * ```\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\nexport class PartnerClient {\n /** Low-level client for direct Partner API calls. */\n readonly raw: PartnerRawClient\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 PartnerClient. Call {@link authorize} before making API requests.\n *\n * @param options - Configuration including credentials, realm, and transport settings.\n */\n constructor(options: PartnerClientOptions) {\n this.authCore = new PartnerAuthCore(options)\n this.raw = this.authCore.raw\n this.partnerAccountInfo = this.authCore.partnerAccountInfo\n this.urlGuard = this.authCore.urlGuard\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 Partner API surface; shape may change as the Partner API docs evolve.\n */\n async authorize(options?: PartnerAuthorizeOptions): Promise<PartnerAuthorizeResponse> {\n return this.authCore.authorize(options)\n }\n\n /**\n * Lists Partner groups for the authorized partner administrator account.\n *\n * @param options - Optional group filter and pagination settings.\n *\n * @returns A page of Partner groups with an optional continuation cursor.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async listGroups(options?: ListGroupsOptions): Promise<ListGroupsResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.listGroups(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n ...(options?.groupName !== undefined ? { groupName: options.groupName } : {}),\n ...(options?.startGroupId !== undefined ? { startGroupId: options.startGroupId } : {}),\n ...(options?.pageSize !== undefined ? { maxGroupCount: options.pageSize } : {}),\n },\n options?.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Async iterator that yields every Partner group for the authorized account.\n *\n * @param options - Optional group filter, page size, and abort signal.\n *\n * @returns An async iterable of {@link PartnerGroup} entries.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n paginateGroups(options?: PaginateGroupsOptions): AsyncIterableIterator<PartnerGroup> {\n return paginateItems(\n async (cursor: GroupId | undefined) => {\n const resp = await this.listGroups({\n ...(options?.groupName !== undefined ? { groupName: options.groupName } : {}),\n ...(options?.pageSize !== undefined ? { pageSize: options.pageSize } : {}),\n ...(cursor !== undefined ? { startGroupId: cursor } : {}),\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n })\n return { page: resp, nextCursor: resp.nextGroupId ?? undefined }\n },\n (page) => page.groups,\n options?.signal,\n )\n }\n\n /**\n * Lists active members for a Partner group.\n *\n * @param options - Group ID plus optional pagination settings.\n *\n * @returns A page of group-member results with an optional continuation cursor.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async listGroupMembers(options: ListGroupMembersOptions): Promise<ListGroupMembersResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.listGroupMembers(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n groupId: options.groupId,\n ...(options.startEmail !== undefined ? { startEmail: options.startEmail } : {}),\n ...(options.pageSize !== undefined ? { maxMemberCount: options.pageSize } : {}),\n },\n options.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Async iterator that yields every active member for a Partner group.\n *\n * @param options - Group ID plus optional page size and abort signal.\n *\n * @returns An async iterable of {@link ListedGroupMember} entries.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n paginateGroupMembers(\n options: PaginateGroupMembersOptions,\n ): AsyncIterableIterator<ListedGroupMember> {\n return paginateItems(\n async (cursor: string | undefined) => {\n const resp = await this.listGroupMembers({\n groupId: options.groupId,\n ...(options.pageSize !== undefined ? { pageSize: options.pageSize } : {}),\n ...(cursor !== undefined ? { startEmail: cursor } : {}),\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n })\n return {\n page: resp,\n nextCursor: resp.nextEmail ?? undefined,\n }\n },\n (page) => [...page.groupMembers],\n options.signal,\n )\n }\n\n /**\n * Creates a new Backblaze account and adds it to a Partner group.\n *\n * This mutation is non-idempotent. Automatic retries and expired-token\n * reauthorization are disabled; long-running batch callers must catch token\n * expiry, call {@link authorize}, and decide whether to issue a new request.\n *\n * @param options - Group ID, member email, and optional region.\n *\n * @returns The created member result, including the member application key.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async createGroupMember(options: CreateGroupMemberOptions): Promise<CreateGroupMemberResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.createGroupMember(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n groupId: options.groupId,\n memberEmail: options.memberEmail,\n ...(options.region !== undefined ? { region: options.region } : {}),\n },\n options.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Ejects an active member from a Partner group without deleting the account.\n *\n * This mutation is non-idempotent. Automatic retries and expired-token\n * reauthorization are disabled; long-running batch callers must catch token\n * expiry, call {@link authorize}, and decide whether to issue a new request.\n *\n * @param options - Group ID, member account ID, and optional replacement email.\n *\n * @returns The ejected member object.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async ejectGroupMember(options: EjectGroupMemberOptions): Promise<EjectGroupMemberResponse> {\n const { groupsApiUrl, authToken, adminAccountId } = this.groupsCoordinates(\n this.ensureGroupsAuthorization(),\n )\n return this.raw.ejectGroupMember(\n groupsApiUrl,\n authToken,\n {\n adminAccountId,\n groupId: options.groupId,\n memberAccountId: options.memberAccountId,\n ...(options.email !== undefined ? { email: options.email } : {}),\n },\n options.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Reserves a new B2 Reserve trial account.\n *\n * This operation is non-idempotent and automatic retries/expired-token\n * reauthorization are disabled at the raw layer. If the request fails after\n * the server processes it, the returned application key may be unrecoverable;\n * reconcile account state before reissuing a request for the same email.\n *\n * @param request - Email, trial duration, storage, and optional region for the account to create.\n * @param options - Optional abort signal.\n *\n * @returns The created reserve-trial account result.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async reserveTrialAccount(\n request: ReserveTrialCreateAccountRequest,\n options?: ReserveTrialAccountOptions,\n ): Promise<ReserveTrialCreateAccountResponse> {\n const { groupsApiUrl, authToken } = this.groupsCoordinates(this.ensureGroupsAuthorization())\n return this.raw.reserveTrialCreateAccount(\n groupsApiUrl,\n authToken,\n request,\n options?.signal !== undefined ? { signal: options.signal } : undefined,\n )\n }\n\n /**\n * Reserves a new B2 Reserve trial account.\n *\n * @param request - Email, trial duration, storage, and optional region for the account to create.\n * @param options - Optional abort signal.\n *\n * @returns The created reserve-trial account result.\n *\n * @deprecated Use {@link reserveTrialAccount}. This plural alias is kept for\n * callers that picked up the original experimental facade name.\n *\n * @experimental Partner API surface; shape may change as the Partner API docs evolve.\n */\n async reserveTrialAccounts(\n request: ReserveTrialCreateAccountRequest,\n options?: ReserveTrialAccountsOptions,\n ): Promise<ReserveTrialCreateAccountResponse> {\n return this.reserveTrialAccount(request, options)\n }\n\n /**\n * Hides credentials and Partner tokens from `JSON.stringify(client)`.\n *\n * @returns A redacted diagnostic object.\n */\n toJSON(): PartnerClientJson {\n return {\n type: 'PartnerClient',\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 `[PartnerClient ${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 private ensureGroupsAuthorization(): PartnerAuthorizeResponse {\n const auth = this.partnerAccountInfo.getAuth()\n if (auth === null) {\n throw new B2PartnerAuthorizationError('Not authorized. Call PartnerClient.authorize() first.')\n }\n const suffixes = this.authCore.activateEndpointSuffixes(auth)\n this.raw.setAuthorizedEndpointSuffixes(suffixes)\n return auth\n }\n\n private groupsCoordinates(auth: PartnerAuthorizeResponse): PartnerGroupsCoordinates {\n const groupsApiUrl = auth.apiInfo.groupsApi?.groupsApiUrl\n if (groupsApiUrl === undefined) {\n throw new B2PartnerAuthorizationError(\n 'Partner API is not available; PartnerClient.authorize() did not return apiInfo.groupsApi.',\n )\n }\n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IAAI,SAAS,MACX,MAAM,IAAI,4BAA4B,uDAAuD;EAE/F,MAAM,WAAW,KAAK,SAAS,yBAAyB,IAAI;EAC5D,KAAK,IAAI,8BAA8B,QAAQ;EAC/C,OAAO;CACT;CAEA,kBAA0B,MAA0D;EAClF,MAAM,eAAe,KAAK,QAAQ,WAAW;EAC7C,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,4BACR,2FACF;EAEF,OAAO;GACL;GACA,WAAW,KAAK;GAChB,gBAAgB,KAAK;EACvB;CACF;AACF"}
@@ -93,6 +93,7 @@ function withQueryString(url, query) {
93
93
  function nonRetryingMutationRequestOptions(options) {
94
94
  return {
95
95
  ...options?.signal !== void 0 ? { signal: options.signal } : {},
96
+ idempotent: false,
96
97
  retry: {
97
98
  ...options?.retry ?? {},
98
99
  maxRetries: 0
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-url.cjs","names":[],"sources":["../../src/partner/endpoint-url.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { RetryOptions } from '../http/retry.ts'\nimport { getTransportUrlGuard, type HttpTransport } from '../http/transport.ts'\nimport { hostMatchesAllowedSuffix, UrlGuard } from '../http/url-guard.ts'\n\n/** Partner authorize endpoint URL field names that are validated before token use. */\nexport type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl'\n\n/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */\nexport interface EndpointAllowedSuffixMessages {\n /** Error message when no validated suffixes and no URL guard are available. */\n readonly missingGuard: string\n /** Error message when a URL guard exists but has not been locked to suffixes. */\n readonly unlockedGuard: string\n}\n\n/** Query-string scalar value supported by Partner and Backup endpoint helpers. */\nexport type QueryValue = string | number\n/** Query-string parameter map supported by Partner and Backup endpoint helpers. */\nexport type QueryParams = Readonly<Record<string, QueryValue>>\n\n/** Shared request options shape for non-idempotent Partner and Backup mutations. */\nexport interface MutationRequestOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n /** Per-request retry override. */\n readonly retry?: Partial<RetryOptions>\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const host = hostname.toLowerCase()\n if (host === '[::1]' || host === '::1') return true\n\n const parts = host.split('.')\n return (\n parts.length === 4 &&\n parts[0] === '127' &&\n parts.every((part) => /^\\d+$/.test(part) && Number(part) <= 255)\n )\n}\n\nfunction hostAllowedBySuffixes(hostname: string, allowedSuffixes: readonly string[]): boolean {\n return allowedSuffixes.some((suffix) => hostMatchesAllowedSuffix(hostname, suffix))\n}\n\n/**\n * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.\n *\n * @param transport - Transport whose URL guard may already be locked.\n * @param authorizedSuffixes - Suffixes derived from validated Partner authorization.\n * @param messages - Surface-specific failure messages.\n *\n * @returns The suffixes safe for credential-bearing endpoint requests.\n *\n * @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.\n *\n * @internal\n */\nexport function endpointAllowedSuffixes(\n transport: HttpTransport,\n authorizedSuffixes: readonly string[],\n messages: EndpointAllowedSuffixMessages,\n): readonly string[] {\n if (authorizedSuffixes.length > 0) return authorizedSuffixes\n\n const guard = getTransportUrlGuard(transport)\n if (guard === undefined) {\n throw new B2PartnerAuthorizationError(messages.missingGuard)\n }\n\n const suffixes = guard.getAllowedSuffixes()\n if (suffixes.length === 0) {\n throw new B2PartnerAuthorizationError(messages.unlockedGuard)\n }\n\n return suffixes\n}\n\n/**\n * Validates a Partner-derived endpoint URL before a Partner token is sent to it.\n *\n * @param rawUrl - Endpoint URL from Partner authorization or cache.\n * @param fieldName - Authorize-response field being validated.\n * @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.\n *\n * @returns The original URL when it is safe to use.\n *\n * @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.\n *\n * @internal\n */\nexport function validatePartnerEndpointUrl(\n rawUrl: string,\n fieldName: PartnerEndpointUrlField,\n allowedSuffixes: readonly string[],\n): string {\n let url: URL\n try {\n url = new URL(rawUrl)\n } catch {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response included malformed ${fieldName}`,\n )\n }\n\n const host = url.hostname.toLowerCase()\n const isAllowedLoopbackHttp =\n url.protocol === 'http:' && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes)\n\n if (url.protocol !== 'https:' && !isAllowedLoopbackHttp) {\n throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`)\n }\n if (url.username !== '' || url.password !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include userinfo`,\n )\n }\n if (url.search !== '' || url.hash !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include query or fragment`,\n )\n }\n\n if (isAllowedLoopbackHttp) return rawUrl\n\n const guard = new UrlGuard()\n guard.setAllowedSuffixes(allowedSuffixes)\n try {\n guard.check(rawUrl)\n } catch (err) {\n throw new B2PartnerAuthorizationError(\n err instanceof Error\n ? `Partner authorize response included unsafe ${fieldName}: ${err.message}`\n : `Partner authorize response included unsafe ${fieldName}`,\n )\n }\n\n return rawUrl\n}\n\n/**\n * Appends query parameters using the SDK's B2 URL encoding semantics.\n *\n * @param url - Base URL without query string.\n * @param query - Query keys and string/number values to append.\n *\n * @returns URL with encoded query parameters, or the original URL for an empty query.\n *\n * @internal\n */\nexport function withQueryString(url: string, query: QueryParams): string {\n // Match the storage raw client's encodeURIComponent query semantics: spaces\n // are `%20`, not form-style `+`.\n const queryString = Object.entries(query)\n .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)\n .join('&')\n return queryString.length === 0 ? url : `${url}?${queryString}`\n}\n\n/**\n * Forces non-idempotent mutation calls to opt out of automatic request replay.\n *\n * @param options - Caller-provided request options.\n *\n * @returns Request options with `retry.maxRetries` set to zero.\n *\n * @internal\n */\nexport function nonRetryingMutationRequestOptions(\n options: MutationRequestOptions | undefined,\n): MutationRequestOptions {\n return {\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n retry: { ...(options?.retry ?? {}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IAAI,SAAS,IACpC,MAAM,IAAI,qBAAA,4BACR,8BAA8B,UAAU,oCAC1C;CAGF,IAAI,uBAAuB,OAAO;CAElC,MAAM,QAAQ,IAAI,kBAAA,SAAS;CAC3B,MAAM,mBAAmB,eAAe;CACxC,IAAI;EACF,MAAM,MAAM,MAAM;CACpB,SAAS,KAAK;EACZ,MAAM,IAAI,qBAAA,4BACR,eAAe,QACX,8CAA8C,UAAU,IAAI,IAAI,YAChE,8CAA8C,WACpD;CACF;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,gBAAgB,KAAa,OAA4B;CAGvE,MAAM,cAAc,OAAO,QAAQ,KAAK,CAAC,CACtC,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,GAAG,mBAAmB,OAAO,KAAK,CAAC,GAAG,CAAC,CACpE,KAAK,GAAG;CACX,OAAO,YAAY,WAAW,IAAI,MAAM,GAAG,IAAI,GAAG;AACpD;;;;;;;;;;AAWA,SAAgB,kCACd,SACwB;CACxB,OAAO;EACL,GAAI,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EAClE,OAAO;GAAE,GAAI,SAAS,SAAS,CAAC;GAAI,YAAY;EAAE;CACpD;AACF"}
1
+ {"version":3,"file":"endpoint-url.cjs","names":[],"sources":["../../src/partner/endpoint-url.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { RetryOptions } from '../http/retry.ts'\nimport { getTransportUrlGuard, type HttpTransport } from '../http/transport.ts'\nimport { hostMatchesAllowedSuffix, UrlGuard } from '../http/url-guard.ts'\n\n/** Partner authorize endpoint URL field names that are validated before token use. */\nexport type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl'\n\n/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */\nexport interface EndpointAllowedSuffixMessages {\n /** Error message when no validated suffixes and no URL guard are available. */\n readonly missingGuard: string\n /** Error message when a URL guard exists but has not been locked to suffixes. */\n readonly unlockedGuard: string\n}\n\n/** Query-string scalar value supported by Partner and Backup endpoint helpers. */\nexport type QueryValue = string | number\n/** Query-string parameter map supported by Partner and Backup endpoint helpers. */\nexport type QueryParams = Readonly<Record<string, QueryValue>>\n\n/** Shared request options shape for non-idempotent Partner and Backup mutations. */\nexport interface MutationRequestOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n /** Per-request retry override. */\n readonly retry?: Partial<RetryOptions>\n /** Marks the request unsafe for transport-level retry or reauth replay. */\n readonly idempotent?: false\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const host = hostname.toLowerCase()\n if (host === '[::1]' || host === '::1') return true\n\n const parts = host.split('.')\n return (\n parts.length === 4 &&\n parts[0] === '127' &&\n parts.every((part) => /^\\d+$/.test(part) && Number(part) <= 255)\n )\n}\n\nfunction hostAllowedBySuffixes(hostname: string, allowedSuffixes: readonly string[]): boolean {\n return allowedSuffixes.some((suffix) => hostMatchesAllowedSuffix(hostname, suffix))\n}\n\n/**\n * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.\n *\n * @param transport - Transport whose URL guard may already be locked.\n * @param authorizedSuffixes - Suffixes derived from validated Partner authorization.\n * @param messages - Surface-specific failure messages.\n *\n * @returns The suffixes safe for credential-bearing endpoint requests.\n *\n * @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.\n *\n * @internal\n */\nexport function endpointAllowedSuffixes(\n transport: HttpTransport,\n authorizedSuffixes: readonly string[],\n messages: EndpointAllowedSuffixMessages,\n): readonly string[] {\n if (authorizedSuffixes.length > 0) return authorizedSuffixes\n\n const guard = getTransportUrlGuard(transport)\n if (guard === undefined) {\n throw new B2PartnerAuthorizationError(messages.missingGuard)\n }\n\n const suffixes = guard.getAllowedSuffixes()\n if (suffixes.length === 0) {\n throw new B2PartnerAuthorizationError(messages.unlockedGuard)\n }\n\n return suffixes\n}\n\n/**\n * Validates a Partner-derived endpoint URL before a Partner token is sent to it.\n *\n * @param rawUrl - Endpoint URL from Partner authorization or cache.\n * @param fieldName - Authorize-response field being validated.\n * @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.\n *\n * @returns The original URL when it is safe to use.\n *\n * @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.\n *\n * @internal\n */\nexport function validatePartnerEndpointUrl(\n rawUrl: string,\n fieldName: PartnerEndpointUrlField,\n allowedSuffixes: readonly string[],\n): string {\n let url: URL\n try {\n url = new URL(rawUrl)\n } catch {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response included malformed ${fieldName}`,\n )\n }\n\n const host = url.hostname.toLowerCase()\n const isAllowedLoopbackHttp =\n url.protocol === 'http:' && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes)\n\n if (url.protocol !== 'https:' && !isAllowedLoopbackHttp) {\n throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`)\n }\n if (url.username !== '' || url.password !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include userinfo`,\n )\n }\n if (url.search !== '' || url.hash !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include query or fragment`,\n )\n }\n\n if (isAllowedLoopbackHttp) return rawUrl\n\n const guard = new UrlGuard()\n guard.setAllowedSuffixes(allowedSuffixes)\n try {\n guard.check(rawUrl)\n } catch (err) {\n throw new B2PartnerAuthorizationError(\n err instanceof Error\n ? `Partner authorize response included unsafe ${fieldName}: ${err.message}`\n : `Partner authorize response included unsafe ${fieldName}`,\n )\n }\n\n return rawUrl\n}\n\n/**\n * Appends query parameters using the SDK's B2 URL encoding semantics.\n *\n * @param url - Base URL without query string.\n * @param query - Query keys and string/number values to append.\n *\n * @returns URL with encoded query parameters, or the original URL for an empty query.\n *\n * @internal\n */\nexport function withQueryString(url: string, query: QueryParams): string {\n // Match the storage raw client's encodeURIComponent query semantics: spaces\n // are `%20`, not form-style `+`.\n const queryString = Object.entries(query)\n .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)\n .join('&')\n return queryString.length === 0 ? url : `${url}?${queryString}`\n}\n\n/**\n * Forces non-idempotent mutation calls to opt out of automatic request replay.\n *\n * @param options - Caller-provided request options.\n *\n * @returns Request options with `retry.maxRetries` set to zero.\n *\n * @internal\n */\nexport function nonRetryingMutationRequestOptions(\n options: MutationRequestOptions | undefined,\n): MutationRequestOptions {\n return {\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n idempotent: false,\n retry: { ...(options?.retry ?? {}), maxRetries: 0 },\n }\n}\n"],"mappings":";;;;AA+BA,SAAS,eAAe,UAA2B;CACjD,MAAM,OAAO,SAAS,YAAY;CAClC,IAAI,SAAS,WAAW,SAAS,OAAO,OAAO;CAE/C,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,OACE,MAAM,WAAW,KACjB,MAAM,OAAO,SACb,MAAM,OAAO,SAAS,QAAQ,KAAK,IAAI,KAAK,OAAO,IAAI,KAAK,GAAG;AAEnE;AAEA,SAAS,sBAAsB,UAAkB,iBAA6C;CAC5F,OAAO,gBAAgB,MAAM,WAAW,kBAAA,yBAAyB,UAAU,MAAM,CAAC;AACpF;;;;;;;;;;;;;;AAeA,SAAgB,wBACd,WACA,oBACA,UACmB;CACnB,IAAI,mBAAmB,SAAS,GAAG,OAAO;CAE1C,MAAM,QAAQ,kBAAA,qBAAqB,SAAS;CAC5C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,qBAAA,4BAA4B,SAAS,YAAY;CAG7D,MAAM,WAAW,MAAM,mBAAmB;CAC1C,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,qBAAA,4BAA4B,SAAS,aAAa;CAG9D,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,2BACd,QACA,WACA,iBACQ;CACR,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,MAAM;CACtB,QAAQ;EACN,MAAM,IAAI,qBAAA,4BACR,iDAAiD,WACnD;CACF;CAEA,MAAM,OAAO,IAAI,SAAS,YAAY;CACtC,MAAM,wBACJ,IAAI,aAAa,WAAW,eAAe,IAAI,KAAK,sBAAsB,MAAM,eAAe;CAEjG,IAAI,IAAI,aAAa,YAAY,CAAC,uBAChC,MAAM,IAAI,qBAAA,4BAA4B,8BAA8B,UAAU,gBAAgB;CAEhG,IAAI,IAAI,aAAa,MAAM,IAAI,aAAa,IAC1C,MAAM,IAAI,qBAAA,4BACR,8BAA8B,UAAU,2BAC1C;CAEF,IAAI,IAAI,WAAW,MAAM,IAAI,SAAS,IACpC,MAAM,IAAI,qBAAA,4BACR,8BAA8B,UAAU,oCAC1C;CAGF,IAAI,uBAAuB,OAAO;CAElC,MAAM,QAAQ,IAAI,kBAAA,SAAS;CAC3B,MAAM,mBAAmB,eAAe;CACxC,IAAI;EACF,MAAM,MAAM,MAAM;CACpB,SAAS,KAAK;EACZ,MAAM,IAAI,qBAAA,4BACR,eAAe,QACX,8CAA8C,UAAU,IAAI,IAAI,YAChE,8CAA8C,WACpD;CACF;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,gBAAgB,KAAa,OAA4B;CAGvE,MAAM,cAAc,OAAO,QAAQ,KAAK,CAAC,CACtC,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,GAAG,mBAAmB,OAAO,KAAK,CAAC,GAAG,CAAC,CACpE,KAAK,GAAG;CACX,OAAO,YAAY,WAAW,IAAI,MAAM,GAAG,IAAI,GAAG;AACpD;;;;;;;;;;AAWA,SAAgB,kCACd,SACwB;CACxB,OAAO;EACL,GAAI,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EAClE,YAAY;EACZ,OAAO;GAAE,GAAI,SAAS,SAAS,CAAC;GAAI,YAAY;EAAE;CACpD;AACF"}
@@ -19,6 +19,8 @@ export interface MutationRequestOptions {
19
19
  readonly signal?: AbortSignal;
20
20
  /** Per-request retry override. */
21
21
  readonly retry?: Partial<RetryOptions>;
22
+ /** Marks the request unsafe for transport-level retry or reauth replay. */
23
+ readonly idempotent?: false;
22
24
  }
23
25
  /**
24
26
  * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-url.d.ts","sourceRoot":"","sources":["../../src/partner/endpoint-url.js"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG/E,sFAAsF;AACtF,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,cAAc,CAAA;AAErE,4FAA4F;AAC5F,MAAM,WAAW,6BAA6B;IAC5C,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;AACxC,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;AAE9D,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CACvC;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,aAAa,EACxB,kBAAkB,EAAE,SAAS,MAAM,EAAE,EACrC,QAAQ,EAAE,6BAA6B,GACtC,SAAS,MAAM,EAAE,CAcnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,uBAAuB,EAClC,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,MAAM,CA2CR;AA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AM,EAAE,CAcnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,uBAAuB,EAClC,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,MAAM,CA2CR;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,sBAAsB,GAAG,SAAS,GAC1C,sBAAsB,CAMxB"}
@@ -19,6 +19,8 @@ export interface MutationRequestOptions {
19
19
  readonly signal?: AbortSignal;
20
20
  /** Per-request retry override. */
21
21
  readonly retry?: Partial<RetryOptions>;
22
+ /** Marks the request unsafe for transport-level retry or reauth replay. */
23
+ readonly idempotent?: false;
22
24
  }
23
25
  /**
24
26
  * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-url.d.ts","sourceRoot":"","sources":["../../src/partner/endpoint-url.js"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG/E,sFAAsF;AACtF,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,cAAc,CAAA;AAErE,4FAA4F;AAC5F,MAAM,WAAW,6BAA6B;IAC5C,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;AACxC,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CA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;AACxC,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;AAE9D,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAC5B;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,aAAa,EACxB,kBAAkB,EAAE,SAAS,MAAM,EAAE,EACrC,QAAQ,EAAE,6BAA6B,GACtC,SAAS,MAAM,EAAE,CAcnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,uBAAuB,EAClC,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,MAAM,CA2CR;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,sBAAsB,GAAG,SAAS,GAC1C,sBAAsB,CAMxB"}
@@ -93,6 +93,7 @@ function withQueryString(url, query) {
93
93
  function nonRetryingMutationRequestOptions(options) {
94
94
  return {
95
95
  ...options?.signal !== void 0 ? { signal: options.signal } : {},
96
+ idempotent: false,
96
97
  retry: {
97
98
  ...options?.retry ?? {},
98
99
  maxRetries: 0
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-url.js","names":[],"sources":["../../src/partner/endpoint-url.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { RetryOptions } from '../http/retry.ts'\nimport { getTransportUrlGuard, type HttpTransport } from '../http/transport.ts'\nimport { hostMatchesAllowedSuffix, UrlGuard } from '../http/url-guard.ts'\n\n/** Partner authorize endpoint URL field names that are validated before token use. */\nexport type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl'\n\n/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */\nexport interface EndpointAllowedSuffixMessages {\n /** Error message when no validated suffixes and no URL guard are available. */\n readonly missingGuard: string\n /** Error message when a URL guard exists but has not been locked to suffixes. */\n readonly unlockedGuard: string\n}\n\n/** Query-string scalar value supported by Partner and Backup endpoint helpers. */\nexport type QueryValue = string | number\n/** Query-string parameter map supported by Partner and Backup endpoint helpers. */\nexport type QueryParams = Readonly<Record<string, QueryValue>>\n\n/** Shared request options shape for non-idempotent Partner and Backup mutations. */\nexport interface MutationRequestOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n /** Per-request retry override. */\n readonly retry?: Partial<RetryOptions>\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const host = hostname.toLowerCase()\n if (host === '[::1]' || host === '::1') return true\n\n const parts = host.split('.')\n return (\n parts.length === 4 &&\n parts[0] === '127' &&\n parts.every((part) => /^\\d+$/.test(part) && Number(part) <= 255)\n )\n}\n\nfunction hostAllowedBySuffixes(hostname: string, allowedSuffixes: readonly string[]): boolean {\n return allowedSuffixes.some((suffix) => hostMatchesAllowedSuffix(hostname, suffix))\n}\n\n/**\n * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.\n *\n * @param transport - Transport whose URL guard may already be locked.\n * @param authorizedSuffixes - Suffixes derived from validated Partner authorization.\n * @param messages - Surface-specific failure messages.\n *\n * @returns The suffixes safe for credential-bearing endpoint requests.\n *\n * @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.\n *\n * @internal\n */\nexport function endpointAllowedSuffixes(\n transport: HttpTransport,\n authorizedSuffixes: readonly string[],\n messages: EndpointAllowedSuffixMessages,\n): readonly string[] {\n if (authorizedSuffixes.length > 0) return authorizedSuffixes\n\n const guard = getTransportUrlGuard(transport)\n if (guard === undefined) {\n throw new B2PartnerAuthorizationError(messages.missingGuard)\n }\n\n const suffixes = guard.getAllowedSuffixes()\n if (suffixes.length === 0) {\n throw new B2PartnerAuthorizationError(messages.unlockedGuard)\n }\n\n return suffixes\n}\n\n/**\n * Validates a Partner-derived endpoint URL before a Partner token is sent to it.\n *\n * @param rawUrl - Endpoint URL from Partner authorization or cache.\n * @param fieldName - Authorize-response field being validated.\n * @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.\n *\n * @returns The original URL when it is safe to use.\n *\n * @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.\n *\n * @internal\n */\nexport function validatePartnerEndpointUrl(\n rawUrl: string,\n fieldName: PartnerEndpointUrlField,\n allowedSuffixes: readonly string[],\n): string {\n let url: URL\n try {\n url = new URL(rawUrl)\n } catch {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response included malformed ${fieldName}`,\n )\n }\n\n const host = url.hostname.toLowerCase()\n const isAllowedLoopbackHttp =\n url.protocol === 'http:' && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes)\n\n if (url.protocol !== 'https:' && !isAllowedLoopbackHttp) {\n throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`)\n }\n if (url.username !== '' || url.password !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include userinfo`,\n )\n }\n if (url.search !== '' || url.hash !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include query or fragment`,\n )\n }\n\n if (isAllowedLoopbackHttp) return rawUrl\n\n const guard = new UrlGuard()\n guard.setAllowedSuffixes(allowedSuffixes)\n try {\n guard.check(rawUrl)\n } catch (err) {\n throw new B2PartnerAuthorizationError(\n err instanceof Error\n ? `Partner authorize response included unsafe ${fieldName}: ${err.message}`\n : `Partner authorize response included unsafe ${fieldName}`,\n )\n }\n\n return rawUrl\n}\n\n/**\n * Appends query parameters using the SDK's B2 URL encoding semantics.\n *\n * @param url - Base URL without query string.\n * @param query - Query keys and string/number values to append.\n *\n * @returns URL with encoded query parameters, or the original URL for an empty query.\n *\n * @internal\n */\nexport function withQueryString(url: string, query: QueryParams): string {\n // Match the storage raw client's encodeURIComponent query semantics: spaces\n // are `%20`, not form-style `+`.\n const queryString = Object.entries(query)\n .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)\n .join('&')\n return queryString.length === 0 ? url : `${url}?${queryString}`\n}\n\n/**\n * Forces non-idempotent mutation calls to opt out of automatic request replay.\n *\n * @param options - Caller-provided request options.\n *\n * @returns Request options with `retry.maxRetries` set to zero.\n *\n * @internal\n */\nexport function nonRetryingMutationRequestOptions(\n options: MutationRequestOptions | undefined,\n): MutationRequestOptions {\n return {\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n retry: { ...(options?.retry ?? {}), maxRetries: 0 },\n }\n}\n"],"mappings":";;;;AA6BA,SAAS,eAAe,UAA2B;CACjD,MAAM,OAAO,SAAS,YAAY;CAClC,IAAI,SAAS,WAAW,SAAS,OAAO,OAAO;CAE/C,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,OACE,MAAM,WAAW,KACjB,MAAM,OAAO,SACb,MAAM,OAAO,SAAS,QAAQ,KAAK,IAAI,KAAK,OAAO,IAAI,KAAK,GAAG;AAEnE;AAEA,SAAS,sBAAsB,UAAkB,iBAA6C;CAC5F,OAAO,gBAAgB,MAAM,WAAW,yBAAyB,UAAU,MAAM,CAAC;AACpF;;;;;;;;;;;;;;AAeA,SAAgB,wBACd,WACA,oBACA,UACmB;CACnB,IAAI,mBAAmB,SAAS,GAAG,OAAO;CAE1C,MAAM,QAAQ,qBAAqB,SAAS;CAC5C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,4BAA4B,SAAS,YAAY;CAG7D,MAAM,WAAW,MAAM,mBAAmB;CAC1C,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,4BA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C;GAAI,YAAY;EAAE;CACpD;AACF"}
1
+ {"version":3,"file":"endpoint-url.js","names":[],"sources":["../../src/partner/endpoint-url.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { RetryOptions } from '../http/retry.ts'\nimport { getTransportUrlGuard, type HttpTransport } from '../http/transport.ts'\nimport { hostMatchesAllowedSuffix, UrlGuard } from '../http/url-guard.ts'\n\n/** Partner authorize endpoint URL field names that are validated before token use. */\nexport type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl'\n\n/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */\nexport interface EndpointAllowedSuffixMessages {\n /** Error message when no validated suffixes and no URL guard are available. */\n readonly missingGuard: string\n /** Error message when a URL guard exists but has not been locked to suffixes. */\n readonly unlockedGuard: string\n}\n\n/** Query-string scalar value supported by Partner and Backup endpoint helpers. */\nexport type QueryValue = string | number\n/** Query-string parameter map supported by Partner and Backup endpoint helpers. */\nexport type QueryParams = Readonly<Record<string, QueryValue>>\n\n/** Shared request options shape for non-idempotent Partner and Backup mutations. */\nexport interface MutationRequestOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n /** Per-request retry override. */\n readonly retry?: Partial<RetryOptions>\n /** Marks the request unsafe for transport-level retry or reauth replay. */\n readonly idempotent?: false\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const host = hostname.toLowerCase()\n if (host === '[::1]' || host === '::1') return true\n\n const parts = host.split('.')\n return (\n parts.length === 4 &&\n parts[0] === '127' &&\n parts.every((part) => /^\\d+$/.test(part) && Number(part) <= 255)\n )\n}\n\nfunction hostAllowedBySuffixes(hostname: string, allowedSuffixes: readonly string[]): boolean {\n return allowedSuffixes.some((suffix) => hostMatchesAllowedSuffix(hostname, suffix))\n}\n\n/**\n * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.\n *\n * @param transport - Transport whose URL guard may already be locked.\n * @param authorizedSuffixes - Suffixes derived from validated Partner authorization.\n * @param messages - Surface-specific failure messages.\n *\n * @returns The suffixes safe for credential-bearing endpoint requests.\n *\n * @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.\n *\n * @internal\n */\nexport function endpointAllowedSuffixes(\n transport: HttpTransport,\n authorizedSuffixes: readonly string[],\n messages: EndpointAllowedSuffixMessages,\n): readonly string[] {\n if (authorizedSuffixes.length > 0) return authorizedSuffixes\n\n const guard = getTransportUrlGuard(transport)\n if (guard === undefined) {\n throw new B2PartnerAuthorizationError(messages.missingGuard)\n }\n\n const suffixes = guard.getAllowedSuffixes()\n if (suffixes.length === 0) {\n throw new B2PartnerAuthorizationError(messages.unlockedGuard)\n }\n\n return suffixes\n}\n\n/**\n * Validates a Partner-derived endpoint URL before a Partner token is sent to it.\n *\n * @param rawUrl - Endpoint URL from Partner authorization or cache.\n * @param fieldName - Authorize-response field being validated.\n * @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.\n *\n * @returns The original URL when it is safe to use.\n *\n * @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.\n *\n * @internal\n */\nexport function validatePartnerEndpointUrl(\n rawUrl: string,\n fieldName: PartnerEndpointUrlField,\n allowedSuffixes: readonly string[],\n): string {\n let url: URL\n try {\n url = new URL(rawUrl)\n } catch {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response included malformed ${fieldName}`,\n )\n }\n\n const host = url.hostname.toLowerCase()\n const isAllowedLoopbackHttp =\n url.protocol === 'http:' && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes)\n\n if (url.protocol !== 'https:' && !isAllowedLoopbackHttp) {\n throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`)\n }\n if (url.username !== '' || url.password !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include userinfo`,\n )\n }\n if (url.search !== '' || url.hash !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include query or fragment`,\n )\n }\n\n if (isAllowedLoopbackHttp) return rawUrl\n\n const guard = new UrlGuard()\n guard.setAllowedSuffixes(allowedSuffixes)\n try {\n guard.check(rawUrl)\n } catch (err) {\n throw new B2PartnerAuthorizationError(\n err instanceof Error\n ? `Partner authorize response included unsafe ${fieldName}: ${err.message}`\n : `Partner authorize response included unsafe ${fieldName}`,\n )\n }\n\n return rawUrl\n}\n\n/**\n * Appends query parameters using the SDK's B2 URL encoding semantics.\n *\n * @param url - Base URL without query string.\n * @param query - Query keys and string/number values to append.\n *\n * @returns URL with encoded query parameters, or the original URL for an empty query.\n *\n * @internal\n */\nexport function withQueryString(url: string, query: QueryParams): string {\n // Match the storage raw client's encodeURIComponent query semantics: spaces\n // are `%20`, not form-style `+`.\n const queryString = Object.entries(query)\n .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)\n .join('&')\n return queryString.length === 0 ? url : `${url}?${queryString}`\n}\n\n/**\n * Forces non-idempotent mutation calls to opt out of automatic request replay.\n *\n * @param options - Caller-provided request options.\n *\n * @returns Request options with `retry.maxRetries` set to zero.\n *\n * @internal\n */\nexport function nonRetryingMutationRequestOptions(\n options: MutationRequestOptions | undefined,\n): MutationRequestOptions {\n return {\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n idempotent: false,\n retry: { ...(options?.retry ?? {}), maxRetries: 0 },\n }\n}\n"],"mappings":";;;;AA+BA,SAAS,eAAe,UAA2B;CACjD,MAAM,OAAO,SAAS,YAAY;CAClC,IAAI,SAAS,WAAW,SAAS,OAAO,OAAO;CAE/C,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,OACE,MAAM,WAAW,KACjB,MAAM,OAAO,SACb,MAAM,OAAO,SAAS,QAAQ,KAAK,IAAI,KAAK,OAAO,IAAI,KAAK,GAAG;AAEnE;AAEA,SAAS,sBAAsB,UAAkB,iBAA6C;CAC5F,OAAO,gBAAgB,MAAM,WAAW,yBAAyB,UAAU,MAAM,CAAC;AACpF;;;;;;;;;;;;;;AAeA,SAAgB,wBACd,WACA,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AK,GAAG;CACX,OAAO,YAAY,WAAW,IAAI,MAAM,GAAG,IAAI,GAAG;AACpD;;;;;;;;;;AAWA,SAAgB,kCACd,SACwB;CACxB,OAAO;EACL,GAAI,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EAClE,YAAY;EACZ,OAAO;GAAE,GAAI,SAAS,SAAS,CAAC;GAAI,YAAY;EAAE;CACpD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory.cjs","names":["#auth"],"sources":["../../src/partner/in-memory.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { AccountId, PartnerToken } from '../types/ids.ts'\nimport type { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { clonePartnerAuthorizeResponse } from './auth-clone.ts'\nimport {\n PARTNER_TOKEN_REDACTED,\n partnerAuthorizeResponseToRedactedJson,\n type RedactedPartnerAuthorizeResponseJson,\n redactPartnerAuthorizeResponse,\n} from './redaction.ts'\n\n/** Redacted JSON diagnostic shape emitted by {@link InMemoryPartnerAccountInfo.toJSON}. */\nexport interface InMemoryPartnerAccountInfoJson {\n /** Redacted cached authorization state, or null before authorization. */\n readonly auth: RedactedPartnerAuthorizeResponseJson | null\n}\n\nfunction clonePartnerAuth(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse {\n return redactPartnerAuthorizeResponse(clonePartnerAuthorizeResponse(auth))\n}\n\n/**\n * In-memory implementation of {@link PartnerAccountInfo}.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryPartnerAccountInfo implements PartnerAccountInfo {\n /** Cached Partner authorization response, or null before authorizePartner() is called. */\n #auth: PartnerAuthorizeResponse | null = null\n\n /**\n * Store a fresh Partner authorization response, replacing any previous state.\n *\n * @param auth - The Partner authorize response to store.\n */\n setAuth(auth: PartnerAuthorizeResponse): void {\n this.#auth = clonePartnerAuth(auth)\n }\n\n /**\n * Return the current Partner authorization response, or null if not authorized.\n *\n * @returns The cached Partner authorization response, or null if not yet authorized.\n */\n getAuth(): PartnerAuthorizeResponse | null {\n return this.#auth\n }\n\n /** Discard all cached Partner authorization state. */\n clear(): void {\n this.#auth = null\n }\n\n /**\n * Current Partner/Backup authorization token.\n *\n * @returns The current Partner token.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getPartnerToken(): PartnerToken {\n return this.requireAuth().authorizationToken\n }\n\n /**\n * Base URL for Partner API calls.\n *\n * @returns The base URL for Partner API calls.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsApiUrl(): string | null {\n return this.requireAuth().apiInfo.groupsApi?.groupsApiUrl ?? null\n }\n\n /**\n * Base URL for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API URL, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupApiUrl(): string | null {\n return this.requireAuth().backupApiUrl ?? null\n }\n\n /**\n * The authorized partner administrator account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getAccountId(): AccountId {\n return this.requireAuth().accountId\n }\n\n /**\n * Capabilities granted for Partner API calls.\n *\n * @returns The Partner API capabilities.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().apiInfo.groupsApi?.capabilities ?? null\n }\n\n /**\n * Capabilities granted for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API capabilities, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().backupCapabilities ?? null\n }\n\n /**\n * Hides the Partner token from `JSON.stringify(accountInfo)`.\n *\n * @returns Redacted Partner auth state, or null when not authorized.\n */\n toJSON(): InMemoryPartnerAccountInfoJson {\n return {\n auth: this.#auth === null ? null : partnerAuthorizeResponseToRedactedJson(this.#auth),\n }\n }\n\n /**\n * Hides the Partner token from default stringification.\n *\n * @returns A short opaque label for this account info store.\n */\n toString(): string {\n return this.#auth === null\n ? '[InMemoryPartnerAccountInfo unauthorized]'\n : `[InMemoryPartnerAccountInfo ${PARTNER_TOKEN_REDACTED}]`\n }\n\n /**\n * Hides the Partner token from Node's `util.inspect`.\n *\n * @returns A short opaque label for this account info store.\n */\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws B2PartnerAuthorizationError if authorizePartner() has not been called.\n */\n private requireAuth(): PartnerAuthorizeResponse {\n if (!this.#auth) {\n throw new B2PartnerAuthorizationError('Not authorized. Call authorizePartner() first.')\n }\n return this.#auth\n }\n}\n"],"mappings":";;;;;AAkBA,SAAS,iBAAiB,MAA0D;CAClF,OAAO,kBAAA,+BAA+B,mBAAA,8BAA8B,IAAI,CAAC;AAC3E;;;;;AAMA,IAAa,6BAAb,MAAsE;;CAEpE,QAAyC;;;;;;CAOzC,QAAQ,MAAsC;EAC5C,KAAKA,QAAQ,iBAAiB,IAAI;CACpC;;;;;;CAOA,UAA2C;EACzC,OAAO,KAAKA;CACd;;CAGA,QAAc;EACZ,KAAKA,QAAQ;CACf;;;;;;;;CASA,kBAAgC;EAC9B,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,gBAAgB;CAC5C;;;;;;;;CASA,eAA0B;EACxB,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,sBAAsB;CAClD;;;;;;CAOA,SAAyC;EACvC,OAAO,EACL,MAAM,KAAKA,UAAU,OAAO,OAAO,kBAAA,uCAAuC,KAAKA,KAAK,EACtF;CACF;;;;;;CAOA,WAAmB;EACjB,OAAO,KAAKA,UAAU,OAClB,8CACA,+BAA+B,+BAAA,uBAAuB;CAC5D;;;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;;;;;;;;CASA,cAAgD;EAC9C,IAAI,CAAC,KAAKA,OACR,MAAM,IAAI,qBAAA,4BAA4B,gDAAgD;EAExF,OAAO,KAAKA;CACd;AACF"}
1
+ {"version":3,"file":"in-memory.cjs","names":[],"sources":["../../src/partner/in-memory.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { AccountId, PartnerToken } from '../types/ids.ts'\nimport type { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { clonePartnerAuthorizeResponse } from './auth-clone.ts'\nimport {\n PARTNER_TOKEN_REDACTED,\n partnerAuthorizeResponseToRedactedJson,\n type RedactedPartnerAuthorizeResponseJson,\n redactPartnerAuthorizeResponse,\n} from './redaction.ts'\n\n/** Redacted JSON diagnostic shape emitted by {@link InMemoryPartnerAccountInfo.toJSON}. */\nexport interface InMemoryPartnerAccountInfoJson {\n /** Redacted cached authorization state, or null before authorization. */\n readonly auth: RedactedPartnerAuthorizeResponseJson | null\n}\n\nfunction clonePartnerAuth(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse {\n return redactPartnerAuthorizeResponse(clonePartnerAuthorizeResponse(auth))\n}\n\n/**\n * In-memory implementation of {@link PartnerAccountInfo}.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryPartnerAccountInfo implements PartnerAccountInfo {\n /** Cached Partner authorization response, or null before authorizePartner() is called. */\n #auth: PartnerAuthorizeResponse | null = null\n\n /**\n * Store a fresh Partner authorization response, replacing any previous state.\n *\n * @param auth - The Partner authorize response to store.\n */\n setAuth(auth: PartnerAuthorizeResponse): void {\n this.#auth = clonePartnerAuth(auth)\n }\n\n /**\n * Return the current Partner authorization response, or null if not authorized.\n *\n * @returns The cached Partner authorization response, or null if not yet authorized.\n */\n getAuth(): PartnerAuthorizeResponse | null {\n return this.#auth\n }\n\n /** Discard all cached Partner authorization state. */\n clear(): void {\n this.#auth = null\n }\n\n /**\n * Current Partner/Backup authorization token.\n *\n * @returns The current Partner token.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getPartnerToken(): PartnerToken {\n return this.requireAuth().authorizationToken\n }\n\n /**\n * Base URL for Partner API calls.\n *\n * @returns The base URL for Partner API calls.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsApiUrl(): string | null {\n return this.requireAuth().apiInfo.groupsApi?.groupsApiUrl ?? null\n }\n\n /**\n * Base URL for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API URL, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupApiUrl(): string | null {\n return this.requireAuth().backupApiUrl ?? null\n }\n\n /**\n * The authorized partner administrator account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getAccountId(): AccountId {\n return this.requireAuth().accountId\n }\n\n /**\n * Capabilities granted for Partner API calls.\n *\n * @returns The Partner API capabilities.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().apiInfo.groupsApi?.capabilities ?? null\n }\n\n /**\n * Capabilities granted for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API capabilities, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().backupCapabilities ?? null\n }\n\n /**\n * Hides the Partner token from `JSON.stringify(accountInfo)`.\n *\n * @returns Redacted Partner auth state, or null when not authorized.\n */\n toJSON(): InMemoryPartnerAccountInfoJson {\n return {\n auth: this.#auth === null ? null : partnerAuthorizeResponseToRedactedJson(this.#auth),\n }\n }\n\n /**\n * Hides the Partner token from default stringification.\n *\n * @returns A short opaque label for this account info store.\n */\n toString(): string {\n return this.#auth === null\n ? '[InMemoryPartnerAccountInfo unauthorized]'\n : `[InMemoryPartnerAccountInfo ${PARTNER_TOKEN_REDACTED}]`\n }\n\n /**\n * Hides the Partner token from Node's `util.inspect`.\n *\n * @returns A short opaque label for this account info store.\n */\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws B2PartnerAuthorizationError if authorizePartner() has not been called.\n */\n private requireAuth(): PartnerAuthorizeResponse {\n if (!this.#auth) {\n throw new B2PartnerAuthorizationError('Not authorized. Call authorizePartner() first.')\n }\n return this.#auth\n }\n}\n"],"mappings":";;;;;AAkBA,SAAS,iBAAiB,MAA0D;CAClF,OAAO,kBAAA,+BAA+B,mBAAA,8BAA8B,IAAI,CAAC;AAC3E;;;;;AAMA,IAAa,6BAAb,MAAsE;;CAEpE,QAAyC;;;;;;CAOzC,QAAQ,MAAsC;EAC5C,KAAK,QAAQ,iBAAiB,IAAI;CACpC;;;;;;CAOA,UAA2C;EACzC,OAAO,KAAK;CACd;;CAGA,QAAc;EACZ,KAAK,QAAQ;CACf;;;;;;;;CASA,kBAAgC;EAC9B,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,gBAAgB;CAC5C;;;;;;;;CASA,eAA0B;EACxB,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,sBAAsB;CAClD;;;;;;CAOA,SAAyC;EACvC,OAAO,EACL,MAAM,KAAK,UAAU,OAAO,OAAO,kBAAA,uCAAuC,KAAK,KAAK,EACtF;CACF;;;;;;CAOA,WAAmB;EACjB,OAAO,KAAK,UAAU,OAClB,8CACA,+BAA+B,+BAAA,uBAAuB;CAC5D;;;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;;;;;;;;CASA,cAAgD;EAC9C,IAAI,CAAC,KAAK,OACR,MAAM,IAAI,qBAAA,4BAA4B,gDAAgD;EAExF,OAAO,KAAK;CACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory.js","names":["#auth"],"sources":["../../src/partner/in-memory.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { AccountId, PartnerToken } from '../types/ids.ts'\nimport type { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { clonePartnerAuthorizeResponse } from './auth-clone.ts'\nimport {\n PARTNER_TOKEN_REDACTED,\n partnerAuthorizeResponseToRedactedJson,\n type RedactedPartnerAuthorizeResponseJson,\n redactPartnerAuthorizeResponse,\n} from './redaction.ts'\n\n/** Redacted JSON diagnostic shape emitted by {@link InMemoryPartnerAccountInfo.toJSON}. */\nexport interface InMemoryPartnerAccountInfoJson {\n /** Redacted cached authorization state, or null before authorization. */\n readonly auth: RedactedPartnerAuthorizeResponseJson | null\n}\n\nfunction clonePartnerAuth(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse {\n return redactPartnerAuthorizeResponse(clonePartnerAuthorizeResponse(auth))\n}\n\n/**\n * In-memory implementation of {@link PartnerAccountInfo}.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryPartnerAccountInfo implements PartnerAccountInfo {\n /** Cached Partner authorization response, or null before authorizePartner() is called. */\n #auth: PartnerAuthorizeResponse | null = null\n\n /**\n * Store a fresh Partner authorization response, replacing any previous state.\n *\n * @param auth - The Partner authorize response to store.\n */\n setAuth(auth: PartnerAuthorizeResponse): void {\n this.#auth = clonePartnerAuth(auth)\n }\n\n /**\n * Return the current Partner authorization response, or null if not authorized.\n *\n * @returns The cached Partner authorization response, or null if not yet authorized.\n */\n getAuth(): PartnerAuthorizeResponse | null {\n return this.#auth\n }\n\n /** Discard all cached Partner authorization state. */\n clear(): void {\n this.#auth = null\n }\n\n /**\n * Current Partner/Backup authorization token.\n *\n * @returns The current Partner token.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getPartnerToken(): PartnerToken {\n return this.requireAuth().authorizationToken\n }\n\n /**\n * Base URL for Partner API calls.\n *\n * @returns The base URL for Partner API calls.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsApiUrl(): string | null {\n return this.requireAuth().apiInfo.groupsApi?.groupsApiUrl ?? null\n }\n\n /**\n * Base URL for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API URL, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupApiUrl(): string | null {\n return this.requireAuth().backupApiUrl ?? null\n }\n\n /**\n * The authorized partner administrator account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getAccountId(): AccountId {\n return this.requireAuth().accountId\n }\n\n /**\n * Capabilities granted for Partner API calls.\n *\n * @returns The Partner API capabilities.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().apiInfo.groupsApi?.capabilities ?? null\n }\n\n /**\n * Capabilities granted for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API capabilities, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().backupCapabilities ?? null\n }\n\n /**\n * Hides the Partner token from `JSON.stringify(accountInfo)`.\n *\n * @returns Redacted Partner auth state, or null when not authorized.\n */\n toJSON(): InMemoryPartnerAccountInfoJson {\n return {\n auth: this.#auth === null ? null : partnerAuthorizeResponseToRedactedJson(this.#auth),\n }\n }\n\n /**\n * Hides the Partner token from default stringification.\n *\n * @returns A short opaque label for this account info store.\n */\n toString(): string {\n return this.#auth === null\n ? '[InMemoryPartnerAccountInfo unauthorized]'\n : `[InMemoryPartnerAccountInfo ${PARTNER_TOKEN_REDACTED}]`\n }\n\n /**\n * Hides the Partner token from Node's `util.inspect`.\n *\n * @returns A short opaque label for this account info store.\n */\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws B2PartnerAuthorizationError if authorizePartner() has not been called.\n */\n private requireAuth(): PartnerAuthorizeResponse {\n if (!this.#auth) {\n throw new B2PartnerAuthorizationError('Not authorized. Call authorizePartner() first.')\n }\n return this.#auth\n }\n}\n"],"mappings":";;;;;AAkBA,SAAS,iBAAiB,MAA0D;CAClF,OAAO,+BAA+B,8BAA8B,IAAI,CAAC;AAC3E;;;;;AAMA,IAAa,6BAAb,MAAsE;;CAEpE,QAAyC;;;;;;CAOzC,QAAQ,MAAsC;EAC5C,KAAKA,QAAQ,iBAAiB,IAAI;CACpC;;;;;;CAOA,UAA2C;EACzC,OAAO,KAAKA;CACd;;CAGA,QAAc;EACZ,KAAKA,QAAQ;CACf;;;;;;;;CASA,kBAAgC;EAC9B,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,gBAAgB;CAC5C;;;;;;;;CASA,eAA0B;EACxB,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,sBAAsB;CAClD;;;;;;CAOA,SAAyC;EACvC,OAAO,EACL,MAAM,KAAKA,UAAU,OAAO,OAAO,uCAAuC,KAAKA,KAAK,EACtF;CACF;;;;;;CAOA,WAAmB;EACjB,OAAO,KAAKA,UAAU,OAClB,8CACA,+BAA+B,uBAAuB;CAC5D;;;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;;;;;;;;CASA,cAAgD;EAC9C,IAAI,CAAC,KAAKA,OACR,MAAM,IAAI,4BAA4B,gDAAgD;EAExF,OAAO,KAAKA;CACd;AACF"}
1
+ {"version":3,"file":"in-memory.js","names":[],"sources":["../../src/partner/in-memory.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { AccountId, PartnerToken } from '../types/ids.ts'\nimport type { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { clonePartnerAuthorizeResponse } from './auth-clone.ts'\nimport {\n PARTNER_TOKEN_REDACTED,\n partnerAuthorizeResponseToRedactedJson,\n type RedactedPartnerAuthorizeResponseJson,\n redactPartnerAuthorizeResponse,\n} from './redaction.ts'\n\n/** Redacted JSON diagnostic shape emitted by {@link InMemoryPartnerAccountInfo.toJSON}. */\nexport interface InMemoryPartnerAccountInfoJson {\n /** Redacted cached authorization state, or null before authorization. */\n readonly auth: RedactedPartnerAuthorizeResponseJson | null\n}\n\nfunction clonePartnerAuth(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse {\n return redactPartnerAuthorizeResponse(clonePartnerAuthorizeResponse(auth))\n}\n\n/**\n * In-memory implementation of {@link PartnerAccountInfo}.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryPartnerAccountInfo implements PartnerAccountInfo {\n /** Cached Partner authorization response, or null before authorizePartner() is called. */\n #auth: PartnerAuthorizeResponse | null = null\n\n /**\n * Store a fresh Partner authorization response, replacing any previous state.\n *\n * @param auth - The Partner authorize response to store.\n */\n setAuth(auth: PartnerAuthorizeResponse): void {\n this.#auth = clonePartnerAuth(auth)\n }\n\n /**\n * Return the current Partner authorization response, or null if not authorized.\n *\n * @returns The cached Partner authorization response, or null if not yet authorized.\n */\n getAuth(): PartnerAuthorizeResponse | null {\n return this.#auth\n }\n\n /** Discard all cached Partner authorization state. */\n clear(): void {\n this.#auth = null\n }\n\n /**\n * Current Partner/Backup authorization token.\n *\n * @returns The current Partner token.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getPartnerToken(): PartnerToken {\n return this.requireAuth().authorizationToken\n }\n\n /**\n * Base URL for Partner API calls.\n *\n * @returns The base URL for Partner API calls.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsApiUrl(): string | null {\n return this.requireAuth().apiInfo.groupsApi?.groupsApiUrl ?? null\n }\n\n /**\n * Base URL for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API URL, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupApiUrl(): string | null {\n return this.requireAuth().backupApiUrl ?? null\n }\n\n /**\n * The authorized partner administrator account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getAccountId(): AccountId {\n return this.requireAuth().accountId\n }\n\n /**\n * Capabilities granted for Partner API calls.\n *\n * @returns The Partner API capabilities.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().apiInfo.groupsApi?.capabilities ?? null\n }\n\n /**\n * Capabilities granted for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API capabilities, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().backupCapabilities ?? null\n }\n\n /**\n * Hides the Partner token from `JSON.stringify(accountInfo)`.\n *\n * @returns Redacted Partner auth state, or null when not authorized.\n */\n toJSON(): InMemoryPartnerAccountInfoJson {\n return {\n auth: this.#auth === null ? null : partnerAuthorizeResponseToRedactedJson(this.#auth),\n }\n }\n\n /**\n * Hides the Partner token from default stringification.\n *\n * @returns A short opaque label for this account info store.\n */\n toString(): string {\n return this.#auth === null\n ? '[InMemoryPartnerAccountInfo unauthorized]'\n : `[InMemoryPartnerAccountInfo ${PARTNER_TOKEN_REDACTED}]`\n }\n\n /**\n * Hides the Partner token from Node's `util.inspect`.\n *\n * @returns A short opaque label for this account info store.\n */\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws B2PartnerAuthorizationError if authorizePartner() has not been called.\n */\n private requireAuth(): PartnerAuthorizeResponse {\n if (!this.#auth) {\n throw new B2PartnerAuthorizationError('Not authorized. Call authorizePartner() first.')\n }\n return this.#auth\n }\n}\n"],"mappings":";;;;;AAkBA,SAAS,iBAAiB,MAA0D;CAClF,OAAO,+BAA+B,8BAA8B,IAAI,CAAC;AAC3E;;;;;AAMA,IAAa,6BAAb,MAAsE;;CAEpE,QAAyC;;;;;;CAOzC,QAAQ,MAAsC;EAC5C,KAAK,QAAQ,iBAAiB,IAAI;CACpC;;;;;;CAOA,UAA2C;EACzC,OAAO,KAAK;CACd;;CAGA,QAAc;EACZ,KAAK,QAAQ;CACf;;;;;;;;CASA,kBAAgC;EAC9B,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,gBAAgB;CAC5C;;;;;;;;CASA,eAA0B;EACxB,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,sBAAsB;CAClD;;;;;;CAOA,SAAyC;EACvC,OAAO,EACL,MAAM,KAAK,UAAU,OAAO,OAAO,uCAAuC,KAAK,KAAK,EACtF;CACF;;;;;;CAOA,WAAmB;EACjB,OAAO,KAAK,UAAU,OAClB,8CACA,+BAA+B,uBAAuB;CAC5D;;;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;;;;;;;;CASA,cAAgD;EAC9C,IAAI,CAAC,KAAK,OACR,MAAM,IAAI,4BAA4B,gDAAgD;EAExF,OAAO,KAAK;CACd;AACF"}
@@ -1,11 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_ids = require("../types/ids.cjs");
3
3
  const require_partner = require("../types/partner.cjs");
4
+ const require_redaction_placeholders = require("./redaction-placeholders.cjs");
4
5
  const require_auth_clone = require("./auth-clone.cjs");
6
+ const require_redaction = require("./redaction.cjs");
5
7
  const require_in_memory = require("./in-memory.cjs");
6
8
  const require_raw = require("./raw.cjs");
7
9
  const require_client = require("./client.cjs");
10
+ exports.APPLICATION_KEY_REDACTED = require_redaction_placeholders.APPLICATION_KEY_REDACTED;
8
11
  exports.InMemoryPartnerAccountInfo = require_in_memory.InMemoryPartnerAccountInfo;
12
+ exports.PARTNER_TOKEN_REDACTED = require_redaction_placeholders.PARTNER_TOKEN_REDACTED;
9
13
  exports.PartnerCapability = require_partner.PartnerCapability;
10
14
  exports.PartnerClient = require_client.PartnerClient;
11
15
  exports.PartnerRawClient = require_raw.PartnerRawClient;
@@ -13,6 +17,11 @@ exports.Region = require_partner.Region;
13
17
  exports.accountId = require_ids.accountId;
14
18
  exports.applicationKeyId = require_ids.applicationKeyId;
15
19
  exports.computerId = require_ids.computerId;
20
+ exports.createGroupMemberResponseToRedactedJson = require_redaction.createGroupMemberResponseToRedactedJson;
21
+ exports.createGroupMemberResultToRedactedJson = require_redaction.createGroupMemberResultToRedactedJson;
16
22
  exports.groupId = require_ids.groupId;
17
23
  exports.partnerAuthorizeResponseForPersistence = require_auth_clone.partnerAuthorizeResponseForPersistence;
24
+ exports.partnerAuthorizeResponseToRedactedJson = require_redaction.partnerAuthorizeResponseToRedactedJson;
18
25
  exports.partnerToken = require_ids.partnerToken;
26
+ exports.reserveTrialCreateAccountResponseToRedactedJson = require_redaction.reserveTrialCreateAccountResponseToRedactedJson;
27
+ exports.reserveTrialCreateAccountResultToRedactedJson = require_redaction.reserveTrialCreateAccountResultToRedactedJson;
@@ -7,6 +7,14 @@
7
7
  * prerequisites required by the Partner API operation you are calling. Partner
8
8
  * authorization is separate from storage authorization and returns Partner API
9
9
  * and Computer Backup endpoint information through {@link PartnerAccountInfo}.
10
+ * Pure redacted-projection helpers such as
11
+ * {@link partnerAuthorizeResponseToRedactedJson},
12
+ * {@link createGroupMemberResponseToRedactedJson}, and
13
+ * {@link reserveTrialCreateAccountResponseToRedactedJson} return JSON-safe
14
+ * copies for logs, audit records, and other untrusted output without exposing
15
+ * Partner tokens or one-time application key secrets. The SDK's in-place
16
+ * serialization hook installers remain internal to the client and raw binding
17
+ * implementations.
10
18
  *
11
19
  * @packageDocumentation
12
20
  */
@@ -16,8 +24,9 @@ export type { CreateGroupMemberRequest, CreateGroupMemberResponse, CreateGroupMe
16
24
  export { computerId, groupId, PartnerCapability, Region } from '../types/partner.js';
17
25
  export type { PartnerAccountInfo } from './account-info.js';
18
26
  export { partnerAuthorizeResponseForPersistence } from './auth-clone.js';
19
- export { type CreateGroupMemberOptions, type EjectGroupMemberOptions, type ListGroupMembersOptions, type ListGroupsOptions, type PaginateGroupMembersOptions, type PaginateGroupsOptions, type PartnerAuthorizeOptions, PartnerClient, type PartnerClientJson, type PartnerClientOptions, type ReserveTrialAccountsOptions, } from './client.js';
27
+ export { type CreateGroupMemberOptions, type EjectGroupMemberOptions, type ListGroupMembersOptions, type ListGroupsOptions, type PaginateGroupMembersOptions, type PaginateGroupsOptions, type PartnerAuthorizeOptions, PartnerClient, type PartnerClientJson, type PartnerClientOptions, type ReserveTrialAccountOptions, type ReserveTrialAccountsOptions, } from './client.js';
20
28
  export { InMemoryPartnerAccountInfo, type InMemoryPartnerAccountInfoJson, } from './in-memory.js';
21
29
  export { PartnerRawClient, type PartnerRawClientOptions, type PartnerRawRequestOptions, } from './raw.js';
22
- export type { RedactedPartnerAuthorizeResponseJson } from './redaction.js';
30
+ export type { RedactedCreateGroupMemberResponseJson, RedactedCreateGroupMemberResultJson, RedactedPartnerAuthorizeResponseJson, RedactedReserveTrialCreateAccountResponseJson, RedactedReserveTrialCreateAccountResultJson, } from './redaction.js';
31
+ export { APPLICATION_KEY_REDACTED, createGroupMemberResponseToRedactedJson, createGroupMemberResultToRedactedJson, PARTNER_TOKEN_REDACTED, partnerAuthorizeResponseToRedactedJson, reserveTrialCreateAccountResponseToRedactedJson, reserveTrialCreateAccountResultToRedactedJson, } from './redaction.js';
23
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/partner/index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,YAAY,GACb,MAAM,iBAAiB,CAAA;AACxB,OAA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,wBAAwB,GAC9B,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,qCAAqC,EACrC,mCAAmC,EACnC,oCAAoC,EACpC,6CAA6C,EAC7C,2CAA2C,GAC5C,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,wBAAwB,EACxB,uCAAuC,EACvC,qCAAqC,EACrC,sBAAsB,EACtB,sCAAsC,EACtC,+CAA+C,EAC/C,6CAA6C,GAC9C,MAAM,gBAAgB,CAAA"}
@@ -7,6 +7,14 @@
7
7
  * prerequisites required by the Partner API operation you are calling. Partner
8
8
  * authorization is separate from storage authorization and returns Partner API
9
9
  * and Computer Backup endpoint information through {@link PartnerAccountInfo}.
10
+ * Pure redacted-projection helpers such as
11
+ * {@link partnerAuthorizeResponseToRedactedJson},
12
+ * {@link createGroupMemberResponseToRedactedJson}, and
13
+ * {@link reserveTrialCreateAccountResponseToRedactedJson} return JSON-safe
14
+ * copies for logs, audit records, and other untrusted output without exposing
15
+ * Partner tokens or one-time application key secrets. The SDK's in-place
16
+ * serialization hook installers remain internal to the client and raw binding
17
+ * implementations.
10
18
  *
11
19
  * @packageDocumentation
12
20
  */
@@ -16,8 +24,9 @@ export type { CreateGroupMemberRequest, CreateGroupMemberResponse, CreateGroupMe
16
24
  export { computerId, groupId, PartnerCapability, Region } from '../types/partner.js';
17
25
  export type { PartnerAccountInfo } from './account-info.js';
18
26
  export { partnerAuthorizeResponseForPersistence } from './auth-clone.js';
19
- export { type CreateGroupMemberOptions, type EjectGroupMemberOptions, type ListGroupMembersOptions, type ListGroupsOptions, type PaginateGroupMembersOptions, type PaginateGroupsOptions, type PartnerAuthorizeOptions, PartnerClient, type PartnerClientJson, type PartnerClientOptions, type ReserveTrialAccountsOptions, } from './client.js';
27
+ export { type CreateGroupMemberOptions, type EjectGroupMemberOptions, type ListGroupMembersOptions, type ListGroupsOptions, type PaginateGroupMembersOptions, type PaginateGroupsOptions, type PartnerAuthorizeOptions, PartnerClient, type PartnerClientJson, type PartnerClientOptions, type ReserveTrialAccountOptions, type ReserveTrialAccountsOptions, } from './client.js';
20
28
  export { InMemoryPartnerAccountInfo, type InMemoryPartnerAccountInfoJson, } from './in-memory.js';
21
29
  export { PartnerRawClient, type PartnerRawClientOptions, type PartnerRawRequestOptions, } from './raw.js';
22
- export type { RedactedPartnerAuthorizeResponseJson } from './redaction.js';
30
+ export type { RedactedCreateGroupMemberResponseJson, RedactedCreateGroupMemberResultJson, RedactedPartnerAuthorizeResponseJson, RedactedReserveTrialCreateAccountResponseJson, RedactedReserveTrialCreateAccountResultJson, } from './redaction.js';
31
+ export { APPLICATION_KEY_REDACTED, createGroupMemberResponseToRedactedJson, createGroupMemberResultToRedactedJson, PARTNER_TOKEN_REDACTED, partnerAuthorizeResponseToRedactedJson, reserveTrialCreateAccountResponseToRedactedJson, reserveTrialCreateAccountResultToRedactedJson, } from './redaction.js';
23
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/partner/index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,YAAY,GACb,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC3E,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,6BAA6B,EAC7B,cAAc,EACd,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gCAAgC,EAChC,qCAAqC,EACrC,iCAAiC,EACjC,+BAA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,EACd,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gCAAgC,EAChC,qCAAqC,EACrC,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACpF,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,sCAAsC,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,GACjC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,0BAA0B,EAC1B,KAAK,8BAA8B,GACpC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,qCAAqC,EACrC,mCAAmC,EACnC,oCAAoC,EACpC,6CAA6C,EAC7C,2CAA2C,GAC5C,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,wBAAwB,EACxB,uCAAuC,EACvC,qCAAqC,EACrC,sBAAsB,EACtB,sCAAsC,EACtC,+CAA+C,EAC/C,6CAA6C,GAC9C,MAAM,gBAAgB,CAAA"}
@@ -1,7 +1,9 @@
1
1
  import { accountId, applicationKeyId, computerId, groupId, partnerToken } from "../types/ids.js";
2
2
  import { PartnerCapability, Region } from "../types/partner.js";
3
+ import { APPLICATION_KEY_REDACTED, PARTNER_TOKEN_REDACTED } from "./redaction-placeholders.js";
3
4
  import { partnerAuthorizeResponseForPersistence } from "./auth-clone.js";
5
+ import { createGroupMemberResponseToRedactedJson, createGroupMemberResultToRedactedJson, partnerAuthorizeResponseToRedactedJson, reserveTrialCreateAccountResponseToRedactedJson, reserveTrialCreateAccountResultToRedactedJson } from "./redaction.js";
4
6
  import { InMemoryPartnerAccountInfo } from "./in-memory.js";
5
7
  import { PartnerRawClient } from "./raw.js";
6
8
  import { PartnerClient } from "./client.js";
7
- export { InMemoryPartnerAccountInfo, PartnerCapability, PartnerClient, PartnerRawClient, Region, accountId, applicationKeyId, computerId, groupId, partnerAuthorizeResponseForPersistence, partnerToken };
9
+ export { APPLICATION_KEY_REDACTED, InMemoryPartnerAccountInfo, PARTNER_TOKEN_REDACTED, PartnerCapability, PartnerClient, PartnerRawClient, Region, accountId, applicationKeyId, computerId, createGroupMemberResponseToRedactedJson, createGroupMemberResultToRedactedJson, groupId, partnerAuthorizeResponseForPersistence, partnerAuthorizeResponseToRedactedJson, partnerToken, reserveTrialCreateAccountResponseToRedactedJson, reserveTrialCreateAccountResultToRedactedJson };