@delopay/sdk 0.499.0 → 0.501.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 (293) hide show
  1. package/dist/airwallexCard.cjs.map +1 -1
  2. package/dist/branding.cjs.map +1 -1
  3. package/dist/cardFormStyles.cjs.map +1 -1
  4. package/dist/checkoutSession.cjs +2 -2
  5. package/dist/checkoutSession.cjs.map +1 -1
  6. package/dist/checkoutSession.js +1 -1
  7. package/dist/chunk-244VZFFO.cjs.map +1 -1
  8. package/dist/chunk-2IJRBJXW.cjs.map +1 -1
  9. package/dist/{chunk-I5KOMBQ3.js → chunk-2OJJ3KGP.js} +25 -1
  10. package/dist/chunk-2OJJ3KGP.js.map +1 -0
  11. package/dist/chunk-34PC72O7.cjs.map +1 -1
  12. package/dist/chunk-3GBWQWTP.cjs.map +1 -1
  13. package/dist/chunk-3YBBJT3Y.cjs.map +1 -1
  14. package/dist/chunk-44QBWVRS.cjs.map +1 -1
  15. package/dist/chunk-4EKAWNYI.cjs.map +1 -1
  16. package/dist/chunk-4LN4BR2T.cjs.map +1 -1
  17. package/dist/chunk-4T4XHPYN.cjs.map +1 -1
  18. package/dist/chunk-575SNLIT.cjs.map +1 -1
  19. package/dist/chunk-5CITBN33.cjs.map +1 -1
  20. package/dist/chunk-5HCKC4HF.cjs.map +1 -1
  21. package/dist/chunk-5O2JSQYA.cjs.map +1 -1
  22. package/dist/chunk-5QS67SBO.cjs.map +1 -1
  23. package/dist/chunk-6EBY2KKL.cjs.map +1 -1
  24. package/dist/chunk-6LFOM6HV.cjs.map +1 -1
  25. package/dist/chunk-6LOWE2YI.cjs.map +1 -1
  26. package/dist/chunk-6LSG5Z4T.cjs.map +1 -1
  27. package/dist/chunk-6SU2MTN2.cjs.map +1 -1
  28. package/dist/chunk-6YCDLSIU.cjs.map +1 -1
  29. package/dist/chunk-75E5WNJG.cjs.map +1 -1
  30. package/dist/chunk-7JV6VVO7.cjs.map +1 -1
  31. package/dist/chunk-7NKJD5ST.cjs.map +1 -1
  32. package/dist/chunk-7QZCUXWB.cjs.map +1 -1
  33. package/dist/chunk-7VXF5D67.cjs.map +1 -1
  34. package/dist/chunk-ABWAYMN5.cjs.map +1 -1
  35. package/dist/chunk-ACZ2R47X.cjs.map +1 -1
  36. package/dist/chunk-AYUYJO3I.cjs.map +1 -1
  37. package/dist/chunk-BCA3TCGS.cjs.map +1 -1
  38. package/dist/chunk-BP6KDQ6I.cjs.map +1 -1
  39. package/dist/chunk-BRY3W7N3.cjs.map +1 -1
  40. package/dist/chunk-BT3UAUEV.cjs.map +1 -1
  41. package/dist/chunk-CCN44NZJ.cjs.map +1 -1
  42. package/dist/chunk-CR3JBTP3.cjs.map +1 -1
  43. package/dist/chunk-DJASVBOJ.cjs.map +1 -1
  44. package/dist/chunk-EEB2HDYL.cjs.map +1 -1
  45. package/dist/chunk-ENPSUWTS.cjs.map +1 -1
  46. package/dist/chunk-EQ6P6ZND.cjs.map +1 -1
  47. package/dist/chunk-EXPWQBI3.cjs.map +1 -1
  48. package/dist/chunk-EYHSXJMJ.cjs.map +1 -1
  49. package/dist/chunk-F3I5DOWV.cjs.map +1 -1
  50. package/dist/chunk-F46K5H3U.cjs.map +1 -1
  51. package/dist/chunk-F6QJB4XP.cjs.map +1 -1
  52. package/dist/chunk-F6S3WCCB.cjs.map +1 -1
  53. package/dist/chunk-FQRC4NJG.cjs.map +1 -1
  54. package/dist/chunk-FTWGI7UZ.cjs.map +1 -1
  55. package/dist/chunk-FYISDU2Y.cjs.map +1 -1
  56. package/dist/chunk-GG52SAHA.cjs.map +1 -1
  57. package/dist/chunk-GK5FWN4H.cjs.map +1 -1
  58. package/dist/chunk-GSQN5EOO.cjs.map +1 -1
  59. package/dist/chunk-GW7IHYXR.cjs.map +1 -1
  60. package/dist/chunk-GWSVQXEY.cjs.map +1 -1
  61. package/dist/chunk-HLKFUOAQ.cjs.map +1 -1
  62. package/dist/chunk-HLYGHP6F.cjs.map +1 -1
  63. package/dist/chunk-HSJABE7X.cjs.map +1 -1
  64. package/dist/chunk-I2W7AO4B.cjs.map +1 -1
  65. package/dist/chunk-I2XGNALG.cjs.map +1 -1
  66. package/dist/{chunk-K3XXGAOR.cjs → chunk-IDY2LP4Q.cjs} +3 -3
  67. package/dist/chunk-IDY2LP4Q.cjs.map +1 -0
  68. package/dist/chunk-IKXGA2Z5.cjs.map +1 -1
  69. package/dist/{chunk-7H2VFIPS.js → chunk-IPN7D5PP.js} +4 -4
  70. package/dist/chunk-IR2LFKKA.cjs.map +1 -1
  71. package/dist/{chunk-ZMJT2YPZ.cjs → chunk-IUXCU3DW.cjs} +7 -7
  72. package/dist/chunk-IUXCU3DW.cjs.map +1 -0
  73. package/dist/chunk-J4ZB7MU4.cjs.map +1 -1
  74. package/dist/chunk-J5RPSRBQ.cjs.map +1 -1
  75. package/dist/chunk-JPPRDMTJ.cjs.map +1 -1
  76. package/dist/chunk-K5Q2H3VD.cjs.map +1 -1
  77. package/dist/chunk-KD5Y2YWK.cjs.map +1 -1
  78. package/dist/chunk-KJDMNF2T.cjs.map +1 -1
  79. package/dist/chunk-KLONGJCL.cjs.map +1 -1
  80. package/dist/chunk-LJ2EG6JK.cjs.map +1 -1
  81. package/dist/chunk-LLYY4TCZ.cjs.map +1 -1
  82. package/dist/chunk-LYIBTVK6.cjs.map +1 -1
  83. package/dist/chunk-M3HWE7KT.cjs.map +1 -1
  84. package/dist/chunk-M3SJHFT4.cjs.map +1 -1
  85. package/dist/chunk-MLG6NXI6.cjs.map +1 -1
  86. package/dist/chunk-MYAXAWBQ.cjs.map +1 -1
  87. package/dist/chunk-NFB3S2E6.cjs.map +1 -1
  88. package/dist/chunk-NULOAF7W.cjs.map +1 -1
  89. package/dist/chunk-NX36HDXE.cjs.map +1 -1
  90. package/dist/chunk-NYL3BNHR.cjs.map +1 -1
  91. package/dist/chunk-O4AYHLQX.cjs.map +1 -1
  92. package/dist/{chunk-YFRAI34Y.cjs → chunk-O53VOQK7.cjs} +67 -1
  93. package/dist/chunk-O53VOQK7.cjs.map +1 -0
  94. package/dist/chunk-OAEKP665.cjs.map +1 -1
  95. package/dist/chunk-ODPNVNYE.cjs.map +1 -1
  96. package/dist/chunk-OG2KJAYD.cjs.map +1 -1
  97. package/dist/chunk-OYZP6NF6.cjs.map +1 -1
  98. package/dist/chunk-P4UILJVU.cjs.map +1 -1
  99. package/dist/chunk-P7DYLUUI.cjs.map +1 -1
  100. package/dist/chunk-PKAE6AQT.cjs.map +1 -1
  101. package/dist/chunk-Q7M7DO7M.cjs.map +1 -1
  102. package/dist/chunk-QKUWFMZP.cjs.map +1 -1
  103. package/dist/chunk-QRSA72B3.cjs.map +1 -1
  104. package/dist/chunk-QYNRNDIY.cjs.map +1 -1
  105. package/dist/chunk-R4GA6BVP.cjs.map +1 -1
  106. package/dist/chunk-R5VYSZ3Q.cjs.map +1 -1
  107. package/dist/chunk-RHFUXHQN.cjs.map +1 -1
  108. package/dist/{chunk-CAMALM35.cjs → chunk-RHT27R27.cjs} +25 -1
  109. package/dist/chunk-RHT27R27.cjs.map +1 -0
  110. package/dist/chunk-RI42IDRR.cjs.map +1 -1
  111. package/dist/chunk-S77LQWYC.cjs.map +1 -1
  112. package/dist/chunk-S7SBNOGS.cjs.map +1 -1
  113. package/dist/{chunk-CQQW5JU7.js → chunk-SAXTZZQL.js} +2 -2
  114. package/dist/{chunk-OEREK6NU.js → chunk-TDCB2FQI.js} +67 -1
  115. package/dist/chunk-TDCB2FQI.js.map +1 -0
  116. package/dist/chunk-TMAJE5P2.cjs.map +1 -1
  117. package/dist/chunk-TNIJ6OSH.cjs.map +1 -1
  118. package/dist/chunk-U3JK7NBG.cjs.map +1 -1
  119. package/dist/chunk-UGSM7RJ2.cjs.map +1 -1
  120. package/dist/chunk-UKLZAOLW.cjs.map +1 -1
  121. package/dist/chunk-UTCXNBID.cjs.map +1 -1
  122. package/dist/chunk-V47G7P6L.cjs.map +1 -1
  123. package/dist/chunk-VH5A6SMU.cjs.map +1 -1
  124. package/dist/chunk-VHMH4QMY.cjs.map +1 -1
  125. package/dist/chunk-VYC7WUM5.cjs.map +1 -1
  126. package/dist/chunk-W457XUA6.cjs.map +1 -1
  127. package/dist/{chunk-DDXERBGG.js → chunk-W7KJTMAF.js} +12 -1
  128. package/dist/{chunk-PYNHK6AP.cjs.map → chunk-W7KJTMAF.js.map} +1 -1
  129. package/dist/chunk-WHDI3TMP.cjs.map +1 -1
  130. package/dist/chunk-WITCPKNL.cjs.map +1 -1
  131. package/dist/chunk-WX6NP7UU.cjs.map +1 -1
  132. package/dist/chunk-XQLRIBVR.cjs.map +1 -1
  133. package/dist/chunk-Y7LSSRNJ.cjs.map +1 -1
  134. package/dist/chunk-YK3P5QNZ.cjs.map +1 -1
  135. package/dist/chunk-YW4DVKNT.cjs.map +1 -1
  136. package/dist/{chunk-PYNHK6AP.cjs → chunk-Z7AVB6VI.cjs} +12 -1
  137. package/dist/chunk-Z7AVB6VI.cjs.map +1 -0
  138. package/dist/chunk-ZGMIHHGL.cjs.map +1 -1
  139. package/dist/chunk-ZKPVUCQV.cjs.map +1 -1
  140. package/dist/chunk-ZUULK36E.cjs.map +1 -1
  141. package/dist/client.cjs +2 -2
  142. package/dist/client.cjs.map +1 -1
  143. package/dist/client.js +1 -1
  144. package/dist/core.cjs.map +1 -1
  145. package/dist/currencies.cjs.map +1 -1
  146. package/dist/enigmaCardForm.cjs.map +1 -1
  147. package/dist/error.cjs.map +1 -1
  148. package/dist/eventStream.cjs.map +1 -1
  149. package/dist/exportDownload.cjs.map +1 -1
  150. package/dist/feeProgram.cjs.map +1 -1
  151. package/dist/index.cjs +6 -6
  152. package/dist/index.cjs.map +1 -1
  153. package/dist/index.d.cts +1 -1
  154. package/dist/index.d.ts +1 -1
  155. package/dist/index.js +5 -5
  156. package/dist/internal/resources/admin.cjs.map +1 -1
  157. package/dist/internal/resources/adminBranding.cjs.map +1 -1
  158. package/dist/internal/resources/adminCheckoutDomains.cjs.map +1 -1
  159. package/dist/internal/resources/adminFeePlans.cjs.map +1 -1
  160. package/dist/internal/resources/adminFileScans.cjs.map +1 -1
  161. package/dist/internal/resources/adminIndustries.cjs.map +1 -1
  162. package/dist/internal/resources/adminLive.cjs.map +1 -1
  163. package/dist/internal/resources/adminNotices.cjs.map +1 -1
  164. package/dist/internal/resources/adminPortal.cjs.map +1 -1
  165. package/dist/internal/resources/adminPricing.cjs.map +1 -1
  166. package/dist/internal/resources/adminSupport.cjs.map +1 -1
  167. package/dist/internal/resources/auditLogs.cjs.map +1 -1
  168. package/dist/internal/resources/cache.cjs.map +1 -1
  169. package/dist/internal/resources/cardIssuers.cjs.map +1 -1
  170. package/dist/internal/resources/configs.cjs.map +1 -1
  171. package/dist/internal/resources/connectorRestrictionRules.cjs.map +1 -1
  172. package/dist/internal/resources/connectorRestrictions.cjs.map +1 -1
  173. package/dist/internal/resources/diagnostic.cjs.map +1 -1
  174. package/dist/internal/resources/gsm.cjs.map +1 -1
  175. package/dist/internal/resources/nativeRenewals.cjs.map +1 -1
  176. package/dist/internal/resources/platformBilling.cjs.map +1 -1
  177. package/dist/internal/resources/platformFees.cjs.map +1 -1
  178. package/dist/internal/resources/platformMessageTemplates.cjs.map +1 -1
  179. package/dist/internal/resources/platformSettings.cjs.map +1 -1
  180. package/dist/internal.cjs +7 -7
  181. package/dist/internal.cjs.map +1 -1
  182. package/dist/internal.d.cts +1 -1
  183. package/dist/internal.d.ts +1 -1
  184. package/dist/internal.js +5 -5
  185. package/dist/listQuery.cjs.map +1 -1
  186. package/dist/panes.cjs.map +1 -1
  187. package/dist/paymentPresentation.cjs.map +1 -1
  188. package/dist/recordCounter.cjs.map +1 -1
  189. package/dist/resources/aiTools.cjs.map +1 -1
  190. package/dist/resources/analytics.cjs.map +1 -1
  191. package/dist/resources/analyticsDashboard.cjs.map +1 -1
  192. package/dist/resources/apiKeys.cjs.map +1 -1
  193. package/dist/resources/audit.cjs.map +1 -1
  194. package/dist/resources/authentication.cjs.map +1 -1
  195. package/dist/resources/availabilityOverrides.cjs.map +1 -1
  196. package/dist/resources/billing.cjs.map +1 -1
  197. package/dist/resources/buyerAccount.cjs.map +1 -1
  198. package/dist/resources/buyerBlocklist.cjs.map +1 -1
  199. package/dist/resources/buyerConversations.cjs.map +1 -1
  200. package/dist/resources/buyerEvidenceReviews.cjs.map +1 -1
  201. package/dist/resources/buyerPortal.cjs +2 -2
  202. package/dist/resources/buyerPortal.cjs.map +1 -1
  203. package/dist/resources/buyerPortal.d.cts +7 -1
  204. package/dist/resources/buyerPortal.d.ts +7 -1
  205. package/dist/resources/buyerPortal.js +1 -1
  206. package/dist/resources/cards.cjs.map +1 -1
  207. package/dist/resources/chargebackPrevention.cjs.map +1 -1
  208. package/dist/resources/checkoutDomains.cjs.map +1 -1
  209. package/dist/resources/checkoutMethods.cjs.map +1 -1
  210. package/dist/resources/checkoutRecovery.cjs.map +1 -1
  211. package/dist/resources/checkoutTemplates.cjs.map +1 -1
  212. package/dist/resources/connectors.cjs.map +1 -1
  213. package/dist/resources/contentEncryption.cjs.map +1 -1
  214. package/dist/resources/costRules.cjs.map +1 -1
  215. package/dist/resources/customers.cjs.map +1 -1
  216. package/dist/resources/deploymentBranding.cjs.map +1 -1
  217. package/dist/resources/disputes.cjs.map +1 -1
  218. package/dist/resources/ephemeralKeys.cjs.map +1 -1
  219. package/dist/resources/events.cjs.map +1 -1
  220. package/dist/resources/export.cjs.map +1 -1
  221. package/dist/resources/externalRecords.cjs.map +1 -1
  222. package/dist/resources/featureMatrix.cjs.map +1 -1
  223. package/dist/resources/fees.cjs.map +1 -1
  224. package/dist/resources/files.cjs.map +1 -1
  225. package/dist/resources/forex.cjs.map +1 -1
  226. package/dist/resources/identityVerifications.cjs.map +1 -1
  227. package/dist/resources/industries.cjs.map +1 -1
  228. package/dist/resources/invoiceSettings.cjs.map +1 -1
  229. package/dist/resources/invoices.cjs.map +1 -1
  230. package/dist/resources/live.cjs.map +1 -1
  231. package/dist/resources/mandates.cjs.map +1 -1
  232. package/dist/resources/merchantAccounts.cjs.map +1 -1
  233. package/dist/resources/messageTemplates.cjs.map +1 -1
  234. package/dist/resources/notices.cjs.map +1 -1
  235. package/dist/resources/operationLimits.cjs.map +1 -1
  236. package/dist/resources/paymentLinks.cjs.map +1 -1
  237. package/dist/resources/paymentMethods.cjs.map +1 -1
  238. package/dist/resources/payments.cjs.map +1 -1
  239. package/dist/resources/payoutDestinations.cjs.map +1 -1
  240. package/dist/resources/payouts.cjs.map +1 -1
  241. package/dist/resources/paypalDisputes.cjs.map +1 -1
  242. package/dist/resources/persons.cjs.map +1 -1
  243. package/dist/resources/poll.cjs.map +1 -1
  244. package/dist/resources/processorCosts.cjs.map +1 -1
  245. package/dist/resources/processorImports.cjs.map +1 -1
  246. package/dist/resources/products.cjs.map +1 -1
  247. package/dist/resources/profileAcquirers.cjs.map +1 -1
  248. package/dist/resources/profiles.cjs.map +1 -1
  249. package/dist/resources/projects.cjs.map +1 -1
  250. package/dist/resources/refunds.cjs.map +1 -1
  251. package/dist/resources/regions.cjs.map +1 -1
  252. package/dist/resources/relay.cjs.map +1 -1
  253. package/dist/resources/risk.cjs.map +1 -1
  254. package/dist/resources/routing.cjs.map +1 -1
  255. package/dist/resources/search.cjs.map +1 -1
  256. package/dist/resources/sellToRestrictions.cjs.map +1 -1
  257. package/dist/resources/settings.cjs.map +1 -1
  258. package/dist/resources/settlement.cjs.map +1 -1
  259. package/dist/resources/shareLinks.cjs.map +1 -1
  260. package/dist/resources/shopLabels.cjs.map +1 -1
  261. package/dist/resources/shopify.cjs +2 -2
  262. package/dist/resources/shopify.cjs.map +1 -1
  263. package/dist/resources/shopify.d.cts +41 -4
  264. package/dist/resources/shopify.d.ts +41 -4
  265. package/dist/resources/shopify.js +1 -1
  266. package/dist/resources/shops.cjs.map +1 -1
  267. package/dist/resources/stripeConnect.cjs.map +1 -1
  268. package/dist/resources/subscriptions.cjs +2 -2
  269. package/dist/resources/subscriptions.cjs.map +1 -1
  270. package/dist/resources/subscriptions.d.cts +6 -1
  271. package/dist/resources/subscriptions.d.ts +6 -1
  272. package/dist/resources/subscriptions.js +1 -1
  273. package/dist/resources/support.cjs.map +1 -1
  274. package/dist/resources/threeDsRules.cjs.map +1 -1
  275. package/dist/resources/users.cjs.map +1 -1
  276. package/dist/resources/vatRates.cjs.map +1 -1
  277. package/dist/resources/verification.cjs.map +1 -1
  278. package/dist/resources/webhooks.cjs.map +1 -1
  279. package/dist/resources/whopResolutionCases.cjs.map +1 -1
  280. package/dist/trustedOrigins.cjs.map +1 -1
  281. package/dist/types.cjs.map +1 -1
  282. package/dist/types.d.cts +222 -3
  283. package/dist/types.d.ts +222 -3
  284. package/package.json +17 -19
  285. package/dist/chunk-CAMALM35.cjs.map +0 -1
  286. package/dist/chunk-DDXERBGG.js.map +0 -1
  287. package/dist/chunk-I5KOMBQ3.js.map +0 -1
  288. package/dist/chunk-K3XXGAOR.cjs.map +0 -1
  289. package/dist/chunk-OEREK6NU.js.map +0 -1
  290. package/dist/chunk-YFRAI34Y.cjs.map +0 -1
  291. package/dist/chunk-ZMJT2YPZ.cjs.map +0 -1
  292. /package/dist/{chunk-7H2VFIPS.js.map → chunk-IPN7D5PP.js.map} +0 -0
  293. /package/dist/{chunk-CQQW5JU7.js.map → chunk-SAXTZZQL.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["/tmp/publish-sdk-04990/dist/chunk-HSJABE7X.cjs","../src/core.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACDA,IAAM,eAAA,EAAiB,yBAAA;AACvB,IAAM,YAAA,EAAc,iCAAA;AAEpB,IAAM,mBAAA,EAAqB,IAAA;AAC3B,IAAM,mBAAA,EAAqB,GAAA;AAE3B,SAAS,eAAA,CAAgB,MAAA,EAAsC;AAC7D,EAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,IAAA;AACpB,EAAA,MAAM,QAAA,EAAU,MAAA,CAAO,IA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AAA;AACsB,QAAA;AACL,QAAA;AACnB,MAAA;AACF,IAAA;AAEM,IAAA;AACR,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CqB,EAAA;AACgD,IAAA;AACH,IAAA;AACnD,IAAA;AACT,IAAA;AACS,IAAA;AAC8C,MAAA;AAK3C,MAAA;AACmC,QAAA;AAC1C,MAAA;AACS,QAAA;AAChB,MAAA;AACgC,MAAA;AACsB,MAAA;AAC9B,MAAA;AACE,MAAA;AAClB,QAAA;AACR,MAAA;AAC6B,MAAA;AACf,MAAA;AACuB,QAAA;AACX,QAAA;AACH,QAAA;AACI,QAAA;AACpB,MAAA;AACW,QAAA;AAClB,MAAA;AACF,IAAA;AACF,EAAA;AACF;ADjc+E;AACA;AACA;AACA","file":"/tmp/publish-sdk-04990/dist/chunk-HSJABE7X.cjs","sourcesContent":[null,"import { DelopayError, DelopayAuthenticationError } from './error';\nimport { EventStreamParser } from './eventStream';\nimport type { EventStreamDispatch } from './eventStream';\nimport type { TokenResponse } from './types';\n\nexport { DelopayError, DelopayAuthenticationError } from './error';\n\nconst PRODUCTION_URL = 'https://api.delopay.net';\nconst SANDBOX_URL = 'https://sandbox.delopay.net/api';\n\nconst MAX_RAW_BODY_BYTES = 2048;\nconst MAX_RETRY_AFTER_MS = 30_000;\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const trimmed = header.trim();\n const seconds = Number(trimmed);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(seconds * 1000, MAX_RETRY_AFTER_MS);\n }\n const date = Date.parse(trimmed);\n if (Number.isFinite(date)) {\n const delta = date - Date.now();\n return delta > 0 ? Math.min(delta, MAX_RETRY_AFTER_MS) : 0;\n }\n return null;\n}\n\nfunction truncateRawBody(raw: string): string | undefined {\n if (!raw) return undefined;\n return raw.length > MAX_RAW_BODY_BYTES ? raw.slice(0, MAX_RAW_BODY_BYTES) + '…' : raw;\n}\n\n/**\n * The error a non-2xx response stands for, read off its body.\n *\n * The API wraps errors as `{ error: { message, code, type, data? } }`; a body\n * that is not JSON (an HTML 502 from a proxy) is kept, truncated, as\n * `rawBody`. A 401 is a {@link DelopayAuthenticationError} unless it is a\n * connector's passthrough.\n */\nasync function errorFromResponse(\n response: Response,\n requestId: string | undefined,\n): Promise<DelopayError> {\n const rawBody = await response.text().catch(() => '');\n let parsed: Record<string, unknown> = {};\n if (rawBody) {\n try {\n parsed = JSON.parse(rawBody) as Record<string, unknown>;\n } catch {\n // non-JSON error body (HTML from a proxy, truncated stream, etc.) — keep raw\n }\n }\n // API wraps errors as { error: { message, code, type, data? } } — unwrap if present\n const err = (parsed.error as Record<string, unknown>) ?? parsed;\n const message = (err.message as string) ?? `Request failed with status ${response.status}`;\n const code = (err.code as string) ?? '';\n const type = (err.error_type as string) ?? (err.type as string) ?? '';\n const data =\n err.data && typeof err.data === 'object' && !Array.isArray(err.data)\n ? (err.data as Record<string, unknown>)\n : undefined;\n const truncatedRaw = truncateRawBody(rawBody);\n\n // A 401 usually means OUR credential (API key / JWT) was rejected —\n // but connector-passthrough errors (`CE_*` / type \"connector\", e.g.\n // a PSP rejecting the merchant's stored Stripe key) propagate the\n // upstream status and are NOT a Delopay authentication failure, so\n // they stay a plain DelopayError instead of triggering the\n // \"re-authenticate\" handling dashboards attach to auth errors.\n const isConnectorPassthrough = type === 'connector' || code.startsWith('CE_');\n if (response.status === 401 && !isConnectorPassthrough) {\n return new DelopayAuthenticationError(message, {\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n }\n\n return new DelopayError(message, {\n status: response.status,\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n}\n\nfunction findIdempotencyKey(headers: Record<string, string>): string | undefined {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === 'idempotency-key') return v;\n }\n return undefined;\n}\n\ninterface CombinedSignal {\n signal: AbortSignal;\n dispose: () => void;\n}\n\nfunction noop(): void {\n // Intentionally empty: no listeners registered, nothing to clean up.\n}\n\n/**\n * A `onDownloadProgress` listener threw. Carried out of the transport as-is so\n * the retry logic never mistakes the caller's own failure — a `TypeError` in a\n * progress bar, say — for a network error and downloads the body again.\n */\nclass ListenerFailure {\n constructor(readonly cause: unknown) {}\n}\n\n/**\n * The body stream failed after the headers arrived: the connection dropped, or\n * the server aborted it because it could not finish the body it had started.\n * Surfaced as the transport's ordinary network error, so it is retried on\n * exactly the same terms as a failure before the first byte.\n */\nclass BodyStreamFailure {\n constructor(readonly cause: unknown) {}\n}\n\nfunction abortError(): Error {\n const error = new Error('The operation was aborted');\n error.name = 'AbortError';\n return error;\n}\n\n/** `Content-Length` as a byte count, or `null` when absent or unreadable. */\nfunction parseContentLength(header: string | null): number | null {\n if (header === null || !/^\\s*\\d+\\s*$/.test(header)) return null;\n const value = Number(header);\n return Number.isSafeInteger(value) ? value : null;\n}\n\n/**\n * One `reader.read()`, raced against the request's signal.\n *\n * A conforming `fetch` errors the body stream itself when its signal aborts,\n * but not every stream a runtime or a polyfill hands back does, and a read\n * that never settles would hold a timed-out or cancelled download open for\n * good. The race makes the abort reach the reader either way.\n */\nfunction readChunk(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n signal: AbortSignal,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n if (signal.aborted) return Promise.reject(abortError());\n return new Promise((resolve, reject) => {\n const onAbort = () => reject(abortError());\n signal.addEventListener('abort', onAbort, { once: true });\n reader.read().then(\n (result) => {\n signal.removeEventListener('abort', onAbort);\n resolve(result);\n },\n (cause: unknown) => {\n signal.removeEventListener('abort', onAbort);\n reject(signal.aborted ? abortError() : new BodyStreamFailure(cause));\n },\n );\n });\n}\n\n/** The chunks as one buffer of exactly `length` bytes. */\nfunction concatChunks(chunks: Uint8Array[], length: number): ArrayBuffer {\n const out = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n}\n\n/**\n * Read a 2xx body chunk by chunk, reporting each one, and decode it as\n * `responseType` asks — the `onDownloadProgress` path of `request()`.\n *\n * `onActivity` is called when the headers arrive and on every chunk; the\n * caller uses it to restart its idle timer.\n */\nasync function receiveWithProgress(\n response: Response,\n responseType: RequestOptions['responseType'],\n listener: (event: DownloadProgressEvent) => void,\n attempt: number,\n signal: AbortSignal,\n onActivity: () => void,\n): Promise<unknown> {\n const headers = response.headers ?? new Headers();\n const total = parseContentLength(headers.get('content-length'));\n let loaded = 0;\n const notify = (chunk: Uint8Array) => {\n try {\n // A copy: the request resolves to the bytes it read, whatever a\n // listener does with the ones it was shown.\n listener({ loaded, total, chunk: chunk.slice(), headers, attempt });\n } catch (cause) {\n throw new ListenerFailure(cause);\n }\n };\n\n onActivity();\n notify(new Uint8Array(0));\n\n const body = response.body;\n if (!body || typeof body.getReader !== 'function') {\n // No readable stream: a null-body status, or a runtime whose `fetch` does\n // not expose one. The body is read whole, and reported as one chunk.\n if (responseType === 'blob') {\n const blob = await response.blob();\n const bytes = new Uint8Array(await blob.arrayBuffer());\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return blob;\n }\n if (responseType === 'arraybuffer') {\n const buffer = await response.arrayBuffer();\n loaded = buffer.byteLength;\n if (loaded > 0) notify(new Uint8Array(buffer));\n return buffer;\n }\n const text = await response.text();\n const bytes = new TextEncoder().encode(text);\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return text ? JSON.parse(text) : undefined;\n }\n\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n try {\n for (;;) {\n const { done, value } = await readChunk(reader, signal);\n if (done) break;\n if (!value || value.byteLength === 0) continue;\n chunks.push(value);\n loaded += value.byteLength;\n onActivity();\n notify(value);\n }\n } catch (err) {\n // Release the connection rather than leave a half-read body behind it.\n reader.cancel().catch(noop);\n throw err;\n }\n\n const bytes = concatChunks(chunks, loaded);\n if (responseType === 'blob') {\n return new Blob([bytes], { type: headers.get('content-type') ?? '' });\n }\n if (responseType === 'arraybuffer') {\n return bytes;\n }\n const text = new TextDecoder().decode(bytes);\n return text ? JSON.parse(text) : undefined;\n}\n\nfunction combineSignals(signals: AbortSignal[]): CombinedSignal {\n const controller = new AbortController();\n const listeners: { signal: AbortSignal; handler: () => void }[] = [];\n const dispose = () => {\n for (const { signal, handler } of listeners) {\n signal.removeEventListener('abort', handler);\n }\n listeners.length = 0;\n };\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n dispose();\n return { signal: controller.signal, dispose: noop };\n }\n const handler = () => {\n controller.abort(signal.reason);\n dispose();\n };\n signal.addEventListener('abort', handler, { once: true });\n listeners.push({ signal, handler });\n }\n return { signal: controller.signal, dispose };\n}\n\n/**\n * Events emitted by the debug logger.\n * - `request` — about to send a request (`method`, `url`, `path`)\n * - `response` — response received (`status`, `method`, `path`, `requestId?`)\n * - `retry` — about to retry after a transient failure (`attempt`, `maxRetries`, `method`, `path`)\n */\nexport type DelopayLogger = (\n event: 'request' | 'response' | 'retry',\n data: Record<string, unknown>,\n) => void;\n\n/**\n * Configuration options for the Delopay client.\n */\nexport interface DelopayOptions {\n /**\n * Use the sandbox environment (`https://sandbox.delopay.net/api`). Defaults\n * to `false` (production). Request paths are appended to that address, so a\n * payment is created at `https://sandbox.delopay.net/api/payments`.\n */\n sandbox?: boolean;\n /** Override the base URL entirely. Takes precedence over `sandbox`. */\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to `30000` (30 seconds). */\n timeout?: number;\n /**\n * Maximum number of automatic retries for transient failures (5xx, timeout, network errors).\n * Retries use exponential backoff. Set to `0` to disable. Defaults to `2`.\n * Only idempotent-safe requests (GET, DELETE, and requests with an `Idempotency-Key` header) are retried.\n */\n maxRetries?: number;\n /** Enable debug logging of requests and responses. Defaults to `false`. */\n debug?: boolean;\n /**\n * Custom logger for debug events (`request`, `response`, `retry`). When omitted,\n * debug output is written to `console.log`. Has no effect unless `debug` is `true`.\n * Useful for routing SDK logs through pino, winston, or similar structured loggers.\n */\n logger?: DelopayLogger;\n /**\n * The shop (business profile) every request acts on, sent as `X-Profile-Id`.\n * An API key bound to several shops must name one of them on every request;\n * create one client per shop. A header a call sets itself takes precedence.\n */\n profileId?: string;\n}\n\nconst SENSITIVE_QUERY_KEYS = new Set([\n 'client_secret',\n 'ephemeral_key',\n 'api_key',\n 'publishable_key',\n]);\n\n/**\n * Return a copy of `url` with the values of known-sensitive query parameters\n * replaced by `REDACTED`, leaving the rest of the query string intact.\n * Used only to sanitize URLs before they hit debug logs.\n */\nfunction redactUrlForLogging(url: string): string {\n const qIdx = url.indexOf('?');\n if (qIdx === -1) return url;\n const base = url.slice(0, qIdx);\n const query = url.slice(qIdx + 1);\n const parts = query.split('&').map((pair) => {\n const eqIdx = pair.indexOf('=');\n if (eqIdx === -1) return pair;\n const key = pair.slice(0, eqIdx);\n if (SENSITIVE_QUERY_KEYS.has(decodeURIComponent(key).toLowerCase())) {\n return `${key}=REDACTED`;\n }\n return pair;\n });\n return `${base}?${parts.join('&')}`;\n}\n\n/**\n * One step of a response body's download, reported to\n * {@link RequestOptions.onDownloadProgress}.\n */\nexport interface DownloadProgressEvent {\n /** Body bytes received so far on this attempt, `chunk` included. */\n loaded: number;\n /**\n * `Content-Length`, when the response carried one — a buffered body such as\n * a PDF. `null` for a streamed (chunked) body, whose size is not known\n * until it ends. With a compressed transfer it is the compressed size, so\n * `loaded` can pass it.\n */\n total: number | null;\n /**\n * The bytes this event reports. Empty on the first event of an attempt,\n * which fires as soon as the headers arrive, before any of the body.\n * A copy: changing it cannot change the value the request resolves to.\n */\n chunk: Uint8Array;\n /** The response headers, available from the first event on. */\n headers: Headers;\n /**\n * Which attempt this is, from `0`. A retried request reports its body\n * again from the start under the next number, so a listener that\n * accumulates state resets it when this changes.\n */\n attempt: number;\n}\n\n/**\n * Low-level options forwarded to a single HTTP request.\n */\nexport interface RequestOptions {\n /** Request body, serialised as JSON. */\n body?: unknown;\n /**\n * @internal Resource assertion that this operation deduplicates by the JSON\n * body's idempotency_key. Null means that optional key is absent, so the write\n * must not be retried. The transport checks the assertion against the body;\n * it does not send this option or copy a JSON key into an HTTP header.\n */\n bodyIdempotencyKey?: string | null;\n /**\n * Query-string parameters. `undefined` and `null` values are omitted.\n * Array values are emitted as repeated keys (`?tag=a&tag=b`) — not comma-joined.\n */\n query?: Record<\n string,\n string | number | boolean | null | undefined | (string | number | boolean)[]\n >;\n /** Additional HTTP headers merged with the default `api-key` header. */\n headers?: Record<string, string>;\n /**\n * Override the client-level timeout for this request, in milliseconds.\n *\n * Covers the whole request, body included — unless `onDownloadProgress` is\n * set, in which case it is an **idle** timeout: it restarts when the\n * headers arrive and on every chunk of the body, so a long download that\n * keeps making progress is never cut off, and one that stalls still is.\n */\n timeout?: number;\n /**\n * Caller-provided `AbortSignal`. Aborting it cancels the in-flight request and rejects\n * with a `DelopayError` carrying code `'ABORTED'`. Combined with the per-request timeout.\n */\n signal?: AbortSignal;\n /**\n * How to decode a 2xx response body. `'json'` (the default) parses JSON;\n * `'blob'` / `'arraybuffer'` return the raw bytes for binary endpoints\n * such as PDF exports. Error responses are always decoded as JSON and\n * thrown as `DelopayError` regardless of this setting.\n */\n responseType?: 'json' | 'blob' | 'arraybuffer';\n /**\n * Pass `keepalive: true` to let the request outlive its page — e.g.\n * telemetry sent while the document is navigating away. Browsers cap\n * keepalive request bodies at ~64 KiB and reject larger ones.\n */\n keepalive?: boolean;\n /**\n * Report a 2xx response body as it downloads. Called once as soon as the\n * headers arrive (with an empty `chunk` and `loaded: 0`), then once per\n * chunk of the body; the value the request resolves to is decoded from\n * those same bytes, per `responseType`. Error responses are not reported.\n *\n * Setting it turns `timeout` into an idle timeout (see there). A body that\n * fails part-way rejects with the ordinary `NETWORK` error and is retried\n * on the usual terms, starting again under the next `attempt`. A listener\n * that throws rejects the request with that error, unretried.\n */\n onDownloadProgress?: (event: DownloadProgressEvent) => void;\n}\n\nexport type RequestFn = <T>(method: string, path: string, options?: RequestOptions) => Promise<T>;\n\n/**\n * Per-call options that resource methods accept as an optional final argument:\n * extra HTTP headers (e.g. `Idempotency-Key`), a per-request timeout override,\n * an `AbortSignal` for cancellation, and a download-progress listener — the\n * last is what a file download (a statement PDF, a report CSV) reports its\n * bytes through.\n */\nexport type RequestExtras = Pick<\n RequestOptions,\n 'headers' | 'timeout' | 'signal' | 'onDownloadProgress'\n>;\n\n/** How long an event stream may stay silent before it is given up. */\nconst DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45_000;\n\n/** Options of one `text/event-stream` request. */\nexport interface EventStreamRequestOptions {\n /** Query-string parameters, as {@link RequestOptions.query}. */\n query?: RequestOptions['query'];\n /** Additional HTTP headers, merged over the auth header. */\n headers?: Record<string, string>;\n /**\n * Aborting it before the response arrives rejects with code `ABORTED`;\n * aborting it later ends the dispatches without an error.\n */\n signal?: AbortSignal;\n /**\n * How long the stream may stay silent, response headers included, before\n * it fails with code `TIMEOUT`. Paused while the consumer holds a dispatch.\n * Defaults to 45 seconds.\n */\n idleTimeoutMs?: number;\n /** Sent as `Last-Event-ID`, and the id the stream starts from. */\n lastEventId?: string | null;\n}\n\n/**\n * An open event stream. Its body is read as it is iterated and never kept:\n * only the line and the event in progress are held.\n */\nexport interface EventStreamConnection {\n /**\n * The stream's dispatches, in order. Ends when the server closes the\n * stream or the caller aborts or closes it; throws a `DelopayError` with\n * code `TIMEOUT` when the stream is silent too long, and `NETWORK` when\n * the connection fails. Iterate it once.\n */\n readonly dispatches: AsyncIterable<EventStreamDispatch>;\n /** Close the stream: the iteration ends and the connection is released. */\n close(): void;\n}\n\n/** Opens a `GET` event stream; what resources that stream receive. */\nexport type EventStreamFn = (\n path: string,\n options?: EventStreamRequestOptions,\n) => Promise<EventStreamConnection>;\n\n/**\n * What a resource class is built from: the client's request and event-stream\n * functions. Every resource takes the request function first; the few that\n * stream (`Live`, `ProcessorImports`) also take the stream opener.\n */\nexport interface DelopayTransport {\n /** Send one request with the client's credentials, retries and timeout. */\n readonly request: RequestFn;\n /** Open one `text/event-stream` request with the client's credentials. */\n readonly openStream: EventStreamFn;\n /** The resolved base URL every request goes to. */\n readonly baseUrl: string;\n}\n\n/** A resource class that {@link DelopayCore.use} can build. */\nexport type ResourceConstructor<T> = new (request: RequestFn, openStream: EventStreamFn) => T;\n\n/**\n * The Delopay client without its resources: credentials, configuration,\n * transport, sessions and pagination.\n *\n * {@link Delopay} extends it with every resource as a property, which puts\n * every resource in the application's bundle. An application that wants only\n * the resources it calls builds them from this class instead, importing each\n * one from its own module, so a bundler leaves the rest out and can load each\n * one with the code that uses it:\n *\n * @example\n * ```typescript\n * import { DelopayCore } from '@delopay/sdk/core';\n * import { Refunds } from '@delopay/sdk/resources/refunds';\n *\n * const client = new DelopayCore('snd_...', { sandbox: true });\n * const refunds = client.use(Refunds);\n * const refund = await refunds.create({ payment_id: 'pay_abc123' });\n * ```\n *\n * A resource built this way shares the client's credentials: a token set with\n * {@link DelopayCore.setJwtToken} applies to it at once.\n */\nexport class DelopayCore {\n /** The resolved base URL used for all API requests. */\n readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly debug: boolean;\n private readonly logger?: DelopayLogger;\n private readonly profileId?: string;\n private jwtToken?: string;\n\n /** The functions every resource is built from; see {@link DelopayCore.use}. */\n readonly transport: DelopayTransport;\n\n private readonly resources = new Map<ResourceConstructor<unknown>, unknown>();\n\n /**\n * Create a new client.\n *\n * @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).\n * Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).\n * @param options - Optional configuration (sandbox mode, base URL override, timeout).\n */\n constructor(apiKey?: string, options?: DelopayOptions) {\n this.apiKey = apiKey ?? '';\n this.timeout = options?.timeout ?? 30_000;\n this.maxRetries = options?.maxRetries ?? 2;\n this.debug = options?.debug ?? false;\n if (options?.logger !== undefined) this.logger = options.logger;\n if (options?.profileId !== undefined && options.profileId !== '') {\n this.profileId = options.profileId;\n }\n\n if (options?.baseUrl !== undefined) {\n this.baseUrl = options.baseUrl;\n } else if (options?.sandbox) {\n this.baseUrl = SANDBOX_URL;\n } else {\n this.baseUrl = PRODUCTION_URL;\n }\n\n this.transport = {\n request: this.request.bind(this) as RequestFn,\n openStream: this.openEventStream.bind(this),\n baseUrl: this.baseUrl,\n };\n }\n\n /**\n * The client's instance of a resource class, built on first use from this\n * client's transport. Later calls with the same class return the same\n * instance.\n *\n * A resource whose constructor takes something else besides the transport\n * (`Branding` takes the base URL) is built directly instead:\n * `new Branding(client.transport.request, client.baseUrl)`.\n *\n * @param Resource - The resource class, imported from its own module.\n * @returns The resource, bound to this client.\n */\n use<T>(Resource: ResourceConstructor<T>): T {\n let resource = this.resources.get(Resource) as T | undefined;\n if (resource === undefined) {\n resource = new Resource(this.transport.request, this.transport.openStream);\n this.resources.set(Resource, resource);\n }\n return resource;\n }\n\n /**\n * Set a JWT token for subsequent requests.\n * When set, requests use `Authorization: Bearer <token>` instead of `api-key`.\n * Useful after `users.signIn()` returns a JWT for dashboard operations.\n */\n setJwtToken(token: string): void {\n this.jwtToken = token;\n }\n\n /**\n * Clear the JWT token, reverting to API key authentication.\n */\n clearJwtToken(): void {\n this.jwtToken = undefined;\n }\n\n /**\n * End the current login session on the server (`POST /user/signout`), the\n * same request as {@link Users.signOut}. The token stays set on this\n * client: clear it with {@link DelopayCore.clearJwtToken} afterwards. The\n * request's `Authorization` header is built when this is called, so\n * clearing the token straight after still signs out the session it held.\n */\n async signOut(): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/signout');\n }\n\n /**\n * Refresh the current login JWT (see {@link Users.refreshToken}) and\n * apply the fresh token to this client, so subsequent requests use it.\n * Returns the fresh token for the caller to persist (e.g. session\n * storage) — the backend has already re-set the `login_token` cookie.\n *\n * If the client's auth state changes while the refresh is pending —\n * `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another\n * session — the stale completion is discarded and this rejects with a\n * `session_changed` `DelopayError` (status 0), so the explicit change\n * wins and the caller never persists a token for a session that is gone.\n *\n * Otherwise throws like any other request; in particular a 401 means the\n * session is dead (expired/blacklisted/revoked), a 429 means a refresh\n * was already minted for this session within the last minute, and a 400\n * means this token has no revocable session to slide (no `jti` — team\n * impersonation is the case in practice) and can never be refreshed,\n * though it stays valid for ordinary calls.\n */\n async refreshSession(): Promise<TokenResponse> {\n const originatingToken = this.jwtToken;\n const response = await this.request<TokenResponse>('POST', '/user/token/refresh');\n if (this.jwtToken !== originatingToken) {\n throw new DelopayError(\n 'Auth state changed while the refresh was pending; refreshed token discarded',\n {\n status: 0,\n code: 'session_changed',\n type: 'session_changed',\n },\n );\n }\n this.setJwtToken(response.token);\n return response;\n }\n\n /** `path` on the base URL, with the query string `query` makes. */\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n let url = `${this.baseUrl}${path}`;\n if (query) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else {\n params.set(key, String(value));\n }\n }\n const qs = params.toString();\n if (qs) {\n url += `?${qs}`;\n }\n }\n return url;\n }\n\n /** The credential header: the JWT when one is set, else the API key. */\n /**\n * The client's `X-Profile-Id`, unless the call names one itself (in any\n * letter case: two spellings would be sent as one joined value).\n */\n private profileHeaders(callHeaders?: Record<string, string>): Record<string, string> {\n if (this.profileId === undefined) return {};\n const named = Object.keys(callHeaders ?? {}).some(\n (name) => name.toLowerCase() === 'x-profile-id',\n );\n return named ? {} : { 'X-Profile-Id': this.profileId };\n }\n\n private authHeaders(): Record<string, string> {\n if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };\n if (this.apiKey) return { 'api-key': this.apiKey };\n return {};\n }\n\n /** One debug event, when `debug` is on. */\n private log(event: 'request' | 'response' | 'retry', data: Record<string, unknown>): void {\n if (!this.debug) return;\n if (this.logger) {\n this.logger(event, data);\n return;\n }\n if (event === 'request')\n console.log(`[delopay] ${data.method as string} ${data.url as string}`);\n else if (event === 'response')\n console.log(\n `[delopay] ${data.status as number} ${data.method as string} ${data.path as string}`,\n );\n else\n console.log(\n `[delopay] retry ${data.attempt as number}/${data.maxRetries as number} ${data.method as string} ${data.path as string}`,\n );\n }\n\n /**\n * Open a `GET` `text/event-stream` and read it as it arrives.\n *\n * `request()` keeps every chunk of a body until the body ends, which a\n * stream that stays open for half an hour must not do; this reads the body\n * chunk by chunk through {@link EventStreamParser} and keeps nothing it has\n * dispatched. Credentials, the base URL, debug logging and the mapping of a\n * non-2xx answer to `DelopayError` / `DelopayAuthenticationError` are the\n * ones `request()` uses.\n *\n * Never retried, and never reconnected: the caller owns reconnection.\n * Resolves once the response headers arrive; rejects on a non-2xx answer,\n * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and\n * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.\n */\n protected async openEventStream(\n path: string,\n options: EventStreamRequestOptions = {},\n ): Promise<EventStreamConnection> {\n const url = this.buildUrl(path, options.query);\n const lastEventId = options.lastEventId ?? '';\n const headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options.headers),\n Accept: 'text/event-stream',\n ...(lastEventId ? { 'Last-Event-ID': lastEventId } : {}),\n ...options.headers,\n };\n const idleMs = options.idleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;\n const callerSignal = options.signal;\n const aborted = () =>\n new DelopayError('Request aborted', { status: 0, code: 'ABORTED', type: 'abort_error' });\n if (callerSignal?.aborted) throw aborted();\n\n const idleCtrl = new AbortController();\n const closeCtrl = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const stopIdleTimer = () => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n };\n const startIdleTimer = () => {\n stopIdleTimer();\n if (!idleCtrl.signal.aborted) timer = setTimeout(() => idleCtrl.abort(), idleMs);\n };\n const combined = combineSignals(\n callerSignal\n ? [idleCtrl.signal, closeCtrl.signal, callerSignal]\n : [idleCtrl.signal, closeCtrl.signal],\n );\n const release = () => {\n stopIdleTimer();\n combined.dispose();\n };\n const timedOut = () =>\n new DelopayError(`Event stream silent for ${idleMs} ms`, {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n const network = (cause: unknown) =>\n new DelopayError(\n `Network error: ${cause instanceof Error ? cause.message : String(cause ?? 'stream failed')}`,\n { status: 0, code: 'NETWORK', type: 'network_error' },\n );\n\n this.log('request', { method: 'GET', url: redactUrlForLogging(url), path });\n startIdleTimer();\n let response: Response;\n try {\n response = await fetch(url, { method: 'GET', headers, signal: combined.signal });\n } catch (err) {\n release();\n if (callerSignal?.aborted) throw aborted();\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err);\n }\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n this.log('response', { status: response.status, method: 'GET', path, requestId });\n\n if (!response.ok) {\n // Read under the idle timer: a body that never ends gives up as empty.\n const error = await errorFromResponse(response, requestId);\n release();\n throw error;\n }\n\n const body = response.body;\n const contentType = response.headers?.get('content-type') ?? '';\n const mediaType = (contentType.split(';')[0] ?? '').trim().toLowerCase();\n if (mediaType !== 'text/event-stream' || !body || typeof body.getReader !== 'function') {\n release();\n body?.cancel().catch(noop);\n throw new DelopayError(\n mediaType === 'text/event-stream'\n ? 'The event stream has no readable body'\n : `Expected a text/event-stream response, got ${contentType ? `\"${contentType}\"` : 'no content type'}`,\n {\n status: response.status,\n code: 'NOT_EVENT_STREAM',\n type: 'invalid_response',\n requestId,\n },\n );\n }\n\n // The idle timer runs only while a read is pending: a consumer busy with\n // an event, or one that has not started iterating, is not silence.\n stopIdleTimer();\n const reader = body.getReader();\n const parser = new EventStreamParser(lastEventId);\n const decoder = new TextDecoder();\n const stopped = () => Boolean(callerSignal?.aborted) || closeCtrl.signal.aborted;\n let finished = false;\n const finish = () => {\n if (finished) return;\n finished = true;\n release();\n reader.cancel().catch(noop);\n };\n\n async function* dispatches(): AsyncGenerator<EventStreamDispatch, void, undefined> {\n try {\n for (;;) {\n let result: ReadableStreamReadResult<Uint8Array>;\n startIdleTimer();\n try {\n result = await readChunk(reader, combined.signal);\n } catch (err) {\n if (callerSignal?.aborted || closeCtrl.signal.aborted) return;\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err instanceof BodyStreamFailure ? err.cause : err);\n } finally {\n stopIdleTimer();\n }\n if (result.done) {\n // An event the stream did not finish with a blank line is\n // discarded, as the standard has it; only completed ones count.\n for (const dispatch of parser.push(decoder.decode())) {\n if (stopped()) return;\n yield dispatch;\n }\n return;\n }\n if (!result.value || result.value.byteLength === 0) continue;\n for (const dispatch of parser.push(decoder.decode(result.value, { stream: true }))) {\n // Aborted or closed while the consumer held the previous one.\n if (stopped()) return;\n yield dispatch;\n }\n }\n } finally {\n finish();\n }\n }\n\n return {\n dispatches: dispatches(),\n close: () => {\n closeCtrl.abort();\n finish();\n },\n };\n }\n\n /**\n * Make a raw HTTP request to the Delopay API.\n *\n * You rarely need to call this directly — prefer the typed resource methods.\n * Use it only for endpoints not yet covered by a resource class.\n *\n * @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).\n * @param path - API path starting with `/` (e.g. `/payments`).\n * @param options - Optional body, query parameters, and headers.\n * @returns Parsed JSON response body typed as `T`.\n * @throws {DelopayAuthenticationError} On 401 responses.\n * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.\n */\n async request<T>(method: string, path: string, options?: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options?.query);\n\n let headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options?.headers),\n ...options?.headers,\n };\n\n // FormData / Blob / ArrayBuffer / URLSearchParams pass through unchanged so callers\n // can send multipart uploads. The runtime (browser or Node 18+ fetch) sets the\n // appropriate Content-Type including the multipart boundary, so we don't touch it.\n const isRawBody =\n options?.body !== undefined &&\n options?.body !== null &&\n (options.body instanceof FormData ||\n options.body instanceof Blob ||\n options.body instanceof ArrayBuffer ||\n options.body instanceof URLSearchParams);\n\n if (options?.body && !isRawBody) {\n headers['Content-Type'] = 'application/json';\n }\n\n // Serialize body once so circular-reference errors surface immediately and big payloads\n // aren't re-stringified on every retry attempt. Raw bodies pass through untouched.\n let serializedBody: BodyInit | undefined;\n if (isRawBody) {\n serializedBody = options?.body as BodyInit;\n } else if (options?.body) {\n serializedBody = JSON.stringify(options.body);\n }\n\n let idempotencyKey = findIdempotencyKey(headers)?.trim();\n if (options && Object.prototype.hasOwnProperty.call(options, 'bodyIdempotencyKey')) {\n const bodyKey = options?.bodyIdempotencyKey;\n const serialized: unknown =\n !isRawBody && typeof serializedBody === 'string' ? JSON.parse(serializedBody) : null;\n const actualKey =\n serialized && typeof serialized === 'object' && !Array.isArray(serialized)\n ? ((serialized as Record<string, unknown>).idempotency_key ?? null)\n : null;\n const suppliedHeaders = Object.keys(headers).filter(\n (name) => name.toLowerCase() === 'idempotency-key',\n );\n if (\n (bodyKey !== null && typeof bodyKey !== 'string') ||\n actualKey !== bodyKey ||\n suppliedHeaders.some(\n (name) => headers[name] !== bodyKey || headers[name]?.trim() !== headers[name],\n )\n ) {\n throw new DelopayError('Request retry keys must match the JSON body key', {\n status: 0,\n code: 'IDEMPOTENCY_KEY_MISMATCH',\n type: 'invalid_request',\n });\n }\n idempotencyKey = bodyKey?.trim();\n // Collapse differently cased copies so fetch cannot combine them into a\n // different header value. Other caller headers remain untouched.\n if (suppliedHeaders.length > 0) {\n headers = {\n ...Object.fromEntries(\n Object.entries(headers).filter(([name]) => name.toLowerCase() !== 'idempotency-key'),\n ),\n 'Idempotency-Key': idempotencyKey ?? '',\n };\n }\n }\n const isRetryable =\n method === 'GET' ||\n method === 'DELETE' ||\n (idempotencyKey !== undefined && idempotencyKey !== '');\n\n const callerSignal = options?.signal;\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n\n const timeoutMs = options?.timeout ?? this.timeout;\n\n let lastError: unknown;\n let retryAfterOverrideMs: number | null = null;\n\n const safeUrl = () => redactUrlForLogging(url);\n const emit = (event: 'request' | 'response' | 'retry', data: Record<string, unknown>) =>\n this.log(event, data);\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const base = Math.min(500 * 2 ** (attempt - 1), 5000);\n // Full jitter: pick uniformly in [0, base) to avoid synchronized retry storms.\n const jittered = Math.random() * base;\n const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);\n retryAfterOverrideMs = null;\n await new Promise((resolve) => setTimeout(resolve, delay));\n emit('retry', { attempt, maxRetries: this.maxRetries, method, path });\n }\n\n const timeoutCtrl = new AbortController();\n let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n // With a progress listener the timeout measures silence, not the whole\n // download: each sign of life restarts it.\n const restartIdleTimer = () => {\n if (timeoutCtrl.signal.aborted) return;\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n };\n const combined = combineSignals(\n callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal],\n );\n\n try {\n emit('request', { method, url: safeUrl(), path });\n\n const response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: combined.signal,\n ...(options?.keepalive !== undefined ? { keepalive: options.keepalive } : {}),\n });\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n\n emit('response', { status: response.status, method, path, requestId });\n\n if (!response.ok) {\n // A 401 that is our credential's comes back as a\n // DelopayAuthenticationError; its status is never transient, so it\n // is thrown below without a retry.\n const error = await errorFromResponse(response, requestId);\n\n // Retry on 5xx and 429 (rate limit). 4xx other than 429 are not transient.\n const isTransientStatus = response.status >= 500 || response.status === 429;\n if (isTransientStatus && isRetryable && attempt < this.maxRetries) {\n if (response.status === 429) {\n retryAfterOverrideMs = parseRetryAfter(response.headers?.get('retry-after') ?? null);\n }\n lastError = error;\n continue;\n }\n\n throw error;\n }\n\n if (options?.onDownloadProgress) {\n return (await receiveWithProgress(\n response,\n options.responseType,\n options.onDownloadProgress,\n attempt,\n combined.signal,\n restartIdleTimer,\n )) as T;\n }\n if (options?.responseType === 'blob') {\n return (await response.blob()) as T;\n }\n if (options?.responseType === 'arraybuffer') {\n return (await response.arrayBuffer()) as T;\n }\n const text = await response.text();\n return (text ? JSON.parse(text) : undefined) as T;\n } catch (err) {\n if (err instanceof DelopayError || err instanceof DelopayAuthenticationError) {\n throw err;\n }\n if (err instanceof ListenerFailure) {\n throw err.cause;\n }\n if (err instanceof BodyStreamFailure) {\n const cause = err.cause;\n const detail =\n cause instanceof Error ? cause.message : String(cause ?? 'body stream failed');\n lastError = new DelopayError(`Network error: ${detail}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof Error && err.name === 'AbortError') {\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n lastError = new DelopayError('Request timed out', {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof TypeError) {\n lastError = new DelopayError(`Network error: ${err.message}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n combined.dispose();\n }\n }\n\n throw lastError;\n }\n\n /**\n * Auto-paginate a list endpoint. Yields items one by one, fetching\n * the next page automatically when the current one is exhausted.\n *\n * Delopay list endpoints use one of two pagination styles, so this helper\n * supports both:\n * - **Offset** (default) — for endpoints like `customers.list` that accept\n * `offset`/`limit`. Each page advances `offset` by the number of items returned.\n * - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page\n * with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor\n * that returns the id of an item; the next page is requested with\n * `starting_after` set to the last item's id.\n *\n * @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.\n * @param params - Additional parameters to pass to every page request.\n * @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.\n * Provide `cursor` to switch to cursor pagination.\n *\n * @example\n * ```typescript\n * // Offset endpoint (customers):\n * for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {\n * console.log(c.customer_id);\n * }\n *\n * // Cursor endpoint (payments): extract the id used as the next cursor.\n * for await (const payment of delopay.paginate(\n * (p) => delopay.payments.list(p),\n * undefined,\n * { cursor: (p) => p.payment_id },\n * )) {\n * console.log(payment.payment_id);\n * }\n * ```\n */\n async *paginate<T, P extends Record<string, unknown>>(\n listFn: (\n params: P & { limit: number; offset?: number; starting_after?: string },\n ) => Promise<{ data: T[] } | T[]>,\n params?: P,\n options?: number | { pageSize?: number; cursor?: (item: T) => string | undefined },\n ): AsyncGenerator<T> {\n const pageSize = typeof options === 'number' ? options : (options?.pageSize ?? 50);\n const cursorOf = typeof options === 'object' ? options.cursor : undefined;\n let offset = 0;\n let after: string | undefined;\n while (true) {\n const page = { ...((params ?? {}) as P), limit: pageSize } as P & {\n limit: number;\n offset?: number;\n starting_after?: string;\n };\n if (cursorOf) {\n if (after !== undefined) page.starting_after = after;\n } else {\n page.offset = offset;\n }\n const result = await listFn(page);\n const items = Array.isArray(result) ? result : result.data;\n if (items.length === 0) break;\n for (const item of items) {\n yield item;\n }\n if (items.length < pageSize) break;\n if (cursorOf) {\n const last = items[items.length - 1];\n if (last === undefined) break;\n after = cursorOf(last);\n if (after === undefined) break;\n } else {\n offset += items.length;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["/tmp/w3-sdk-publish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AA;AACO,UAAA;AAC/C,YAAA;AACF,YAAA;AACA,YAAA;AACP,UAAA;AAC6C,UAAA;AACxC,UAAA;AACR,QAAA;AACuD,QAAA;AAC1B,UAAA;AACiB,YAAA;AAChC,cAAA;AACF,cAAA;AACA,cAAA;AACP,YAAA;AACH,UAAA;AACkD,UAAA;AACxC,YAAA;AACF,YAAA;AACA,YAAA;AACP,UAAA;AAC6C,UAAA;AACxC,UAAA;AACR,QAAA;AAC8B,QAAA;AACkC,UAAA;AACpD,YAAA;AACF,YAAA;AACA,YAAA;AACP,UAAA;AAC6C,UAAA;AACxC,UAAA;AACR,QAAA;AACM,QAAA;AACN,MAAA;AACsB,QAAA;AACL,QAAA;AACnB,MAAA;AACF,IAAA;AAEM,IAAA;AACR,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CqB,EAAA;AACgD,IAAA;AACH,IAAA;AACnD,IAAA;AACT,IAAA;AACS,IAAA;AAC8C,MAAA;AAK3C,MAAA;AACmC,QAAA;AAC1C,MAAA;AACS,QAAA;AAChB,MAAA;AACgC,MAAA;AACsB,MAAA;AAC9B,MAAA;AACE,MAAA;AAClB,QAAA;AACR,MAAA;AAC6B,MAAA;AACf,MAAA;AACuB,QAAA;AACX,QAAA;AACH,QAAA;AACI,QAAA;AACpB,MAAA;AACW,QAAA;AAClB,MAAA;AACF,IAAA;AACF,EAAA;AACF;ADjc+E;AACA;AACA;AACA","file":"/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-HSJABE7X.cjs","sourcesContent":[null,"import { DelopayError, DelopayAuthenticationError } from './error';\nimport { EventStreamParser } from './eventStream';\nimport type { EventStreamDispatch } from './eventStream';\nimport type { TokenResponse } from './types';\n\nexport { DelopayError, DelopayAuthenticationError } from './error';\n\nconst PRODUCTION_URL = 'https://api.delopay.net';\nconst SANDBOX_URL = 'https://sandbox.delopay.net/api';\n\nconst MAX_RAW_BODY_BYTES = 2048;\nconst MAX_RETRY_AFTER_MS = 30_000;\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const trimmed = header.trim();\n const seconds = Number(trimmed);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(seconds * 1000, MAX_RETRY_AFTER_MS);\n }\n const date = Date.parse(trimmed);\n if (Number.isFinite(date)) {\n const delta = date - Date.now();\n return delta > 0 ? Math.min(delta, MAX_RETRY_AFTER_MS) : 0;\n }\n return null;\n}\n\nfunction truncateRawBody(raw: string): string | undefined {\n if (!raw) return undefined;\n return raw.length > MAX_RAW_BODY_BYTES ? raw.slice(0, MAX_RAW_BODY_BYTES) + '…' : raw;\n}\n\n/**\n * The error a non-2xx response stands for, read off its body.\n *\n * The API wraps errors as `{ error: { message, code, type, data? } }`; a body\n * that is not JSON (an HTML 502 from a proxy) is kept, truncated, as\n * `rawBody`. A 401 is a {@link DelopayAuthenticationError} unless it is a\n * connector's passthrough.\n */\nasync function errorFromResponse(\n response: Response,\n requestId: string | undefined,\n): Promise<DelopayError> {\n const rawBody = await response.text().catch(() => '');\n let parsed: Record<string, unknown> = {};\n if (rawBody) {\n try {\n parsed = JSON.parse(rawBody) as Record<string, unknown>;\n } catch {\n // non-JSON error body (HTML from a proxy, truncated stream, etc.) — keep raw\n }\n }\n // API wraps errors as { error: { message, code, type, data? } } — unwrap if present\n const err = (parsed.error as Record<string, unknown>) ?? parsed;\n const message = (err.message as string) ?? `Request failed with status ${response.status}`;\n const code = (err.code as string) ?? '';\n const type = (err.error_type as string) ?? (err.type as string) ?? '';\n const data =\n err.data && typeof err.data === 'object' && !Array.isArray(err.data)\n ? (err.data as Record<string, unknown>)\n : undefined;\n const truncatedRaw = truncateRawBody(rawBody);\n\n // A 401 usually means OUR credential (API key / JWT) was rejected —\n // but connector-passthrough errors (`CE_*` / type \"connector\", e.g.\n // a PSP rejecting the merchant's stored Stripe key) propagate the\n // upstream status and are NOT a Delopay authentication failure, so\n // they stay a plain DelopayError instead of triggering the\n // \"re-authenticate\" handling dashboards attach to auth errors.\n const isConnectorPassthrough = type === 'connector' || code.startsWith('CE_');\n if (response.status === 401 && !isConnectorPassthrough) {\n return new DelopayAuthenticationError(message, {\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n }\n\n return new DelopayError(message, {\n status: response.status,\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n}\n\nfunction findIdempotencyKey(headers: Record<string, string>): string | undefined {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === 'idempotency-key') return v;\n }\n return undefined;\n}\n\ninterface CombinedSignal {\n signal: AbortSignal;\n dispose: () => void;\n}\n\nfunction noop(): void {\n // Intentionally empty: no listeners registered, nothing to clean up.\n}\n\n/**\n * A `onDownloadProgress` listener threw. Carried out of the transport as-is so\n * the retry logic never mistakes the caller's own failure — a `TypeError` in a\n * progress bar, say — for a network error and downloads the body again.\n */\nclass ListenerFailure {\n constructor(readonly cause: unknown) {}\n}\n\n/**\n * The body stream failed after the headers arrived: the connection dropped, or\n * the server aborted it because it could not finish the body it had started.\n * Surfaced as the transport's ordinary network error, so it is retried on\n * exactly the same terms as a failure before the first byte.\n */\nclass BodyStreamFailure {\n constructor(readonly cause: unknown) {}\n}\n\nfunction abortError(): Error {\n const error = new Error('The operation was aborted');\n error.name = 'AbortError';\n return error;\n}\n\n/** `Content-Length` as a byte count, or `null` when absent or unreadable. */\nfunction parseContentLength(header: string | null): number | null {\n if (header === null || !/^\\s*\\d+\\s*$/.test(header)) return null;\n const value = Number(header);\n return Number.isSafeInteger(value) ? value : null;\n}\n\n/**\n * One `reader.read()`, raced against the request's signal.\n *\n * A conforming `fetch` errors the body stream itself when its signal aborts,\n * but not every stream a runtime or a polyfill hands back does, and a read\n * that never settles would hold a timed-out or cancelled download open for\n * good. The race makes the abort reach the reader either way.\n */\nfunction readChunk(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n signal: AbortSignal,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n if (signal.aborted) return Promise.reject(abortError());\n return new Promise((resolve, reject) => {\n const onAbort = () => reject(abortError());\n signal.addEventListener('abort', onAbort, { once: true });\n reader.read().then(\n (result) => {\n signal.removeEventListener('abort', onAbort);\n resolve(result);\n },\n (cause: unknown) => {\n signal.removeEventListener('abort', onAbort);\n reject(signal.aborted ? abortError() : new BodyStreamFailure(cause));\n },\n );\n });\n}\n\n/** The chunks as one buffer of exactly `length` bytes. */\nfunction concatChunks(chunks: Uint8Array[], length: number): ArrayBuffer {\n const out = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n}\n\n/**\n * Read a 2xx body chunk by chunk, reporting each one, and decode it as\n * `responseType` asks — the `onDownloadProgress` path of `request()`.\n *\n * `onActivity` is called when the headers arrive and on every chunk; the\n * caller uses it to restart its idle timer.\n */\nasync function receiveWithProgress(\n response: Response,\n responseType: RequestOptions['responseType'],\n listener: (event: DownloadProgressEvent) => void,\n attempt: number,\n signal: AbortSignal,\n onActivity: () => void,\n): Promise<unknown> {\n const headers = response.headers ?? new Headers();\n const total = parseContentLength(headers.get('content-length'));\n let loaded = 0;\n const notify = (chunk: Uint8Array) => {\n try {\n // A copy: the request resolves to the bytes it read, whatever a\n // listener does with the ones it was shown.\n listener({ loaded, total, chunk: chunk.slice(), headers, attempt });\n } catch (cause) {\n throw new ListenerFailure(cause);\n }\n };\n\n onActivity();\n notify(new Uint8Array(0));\n\n const body = response.body;\n if (!body || typeof body.getReader !== 'function') {\n // No readable stream: a null-body status, or a runtime whose `fetch` does\n // not expose one. The body is read whole, and reported as one chunk.\n if (responseType === 'blob') {\n const blob = await response.blob();\n const bytes = new Uint8Array(await blob.arrayBuffer());\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return blob;\n }\n if (responseType === 'arraybuffer') {\n const buffer = await response.arrayBuffer();\n loaded = buffer.byteLength;\n if (loaded > 0) notify(new Uint8Array(buffer));\n return buffer;\n }\n const text = await response.text();\n const bytes = new TextEncoder().encode(text);\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return text ? JSON.parse(text) : undefined;\n }\n\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n try {\n for (;;) {\n const { done, value } = await readChunk(reader, signal);\n if (done) break;\n if (!value || value.byteLength === 0) continue;\n chunks.push(value);\n loaded += value.byteLength;\n onActivity();\n notify(value);\n }\n } catch (err) {\n // Release the connection rather than leave a half-read body behind it.\n reader.cancel().catch(noop);\n throw err;\n }\n\n const bytes = concatChunks(chunks, loaded);\n if (responseType === 'blob') {\n return new Blob([bytes], { type: headers.get('content-type') ?? '' });\n }\n if (responseType === 'arraybuffer') {\n return bytes;\n }\n const text = new TextDecoder().decode(bytes);\n return text ? JSON.parse(text) : undefined;\n}\n\nfunction combineSignals(signals: AbortSignal[]): CombinedSignal {\n const controller = new AbortController();\n const listeners: { signal: AbortSignal; handler: () => void }[] = [];\n const dispose = () => {\n for (const { signal, handler } of listeners) {\n signal.removeEventListener('abort', handler);\n }\n listeners.length = 0;\n };\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n dispose();\n return { signal: controller.signal, dispose: noop };\n }\n const handler = () => {\n controller.abort(signal.reason);\n dispose();\n };\n signal.addEventListener('abort', handler, { once: true });\n listeners.push({ signal, handler });\n }\n return { signal: controller.signal, dispose };\n}\n\n/**\n * Events emitted by the debug logger.\n * - `request` — about to send a request (`method`, `url`, `path`)\n * - `response` — response received (`status`, `method`, `path`, `requestId?`)\n * - `retry` — about to retry after a transient failure (`attempt`, `maxRetries`, `method`, `path`)\n */\nexport type DelopayLogger = (\n event: 'request' | 'response' | 'retry',\n data: Record<string, unknown>,\n) => void;\n\n/**\n * Configuration options for the Delopay client.\n */\nexport interface DelopayOptions {\n /**\n * Use the sandbox environment (`https://sandbox.delopay.net/api`). Defaults\n * to `false` (production). Request paths are appended to that address, so a\n * payment is created at `https://sandbox.delopay.net/api/payments`.\n */\n sandbox?: boolean;\n /** Override the base URL entirely. Takes precedence over `sandbox`. */\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to `30000` (30 seconds). */\n timeout?: number;\n /**\n * Maximum number of automatic retries for transient failures (5xx, timeout, network errors).\n * Retries use exponential backoff. Set to `0` to disable. Defaults to `2`.\n * Only idempotent-safe requests (GET, DELETE, and requests with an `Idempotency-Key` header) are retried.\n */\n maxRetries?: number;\n /** Enable debug logging of requests and responses. Defaults to `false`. */\n debug?: boolean;\n /**\n * Custom logger for debug events (`request`, `response`, `retry`). When omitted,\n * debug output is written to `console.log`. Has no effect unless `debug` is `true`.\n * Useful for routing SDK logs through pino, winston, or similar structured loggers.\n */\n logger?: DelopayLogger;\n /**\n * The shop (business profile) every request acts on, sent as `X-Profile-Id`.\n * An API key bound to several shops must name one of them on every request;\n * create one client per shop. A header a call sets itself takes precedence.\n */\n profileId?: string;\n}\n\nconst SENSITIVE_QUERY_KEYS = new Set([\n 'client_secret',\n 'ephemeral_key',\n 'api_key',\n 'publishable_key',\n]);\n\n/**\n * Return a copy of `url` with the values of known-sensitive query parameters\n * replaced by `REDACTED`, leaving the rest of the query string intact.\n * Used only to sanitize URLs before they hit debug logs.\n */\nfunction redactUrlForLogging(url: string): string {\n const qIdx = url.indexOf('?');\n if (qIdx === -1) return url;\n const base = url.slice(0, qIdx);\n const query = url.slice(qIdx + 1);\n const parts = query.split('&').map((pair) => {\n const eqIdx = pair.indexOf('=');\n if (eqIdx === -1) return pair;\n const key = pair.slice(0, eqIdx);\n if (SENSITIVE_QUERY_KEYS.has(decodeURIComponent(key).toLowerCase())) {\n return `${key}=REDACTED`;\n }\n return pair;\n });\n return `${base}?${parts.join('&')}`;\n}\n\n/**\n * One step of a response body's download, reported to\n * {@link RequestOptions.onDownloadProgress}.\n */\nexport interface DownloadProgressEvent {\n /** Body bytes received so far on this attempt, `chunk` included. */\n loaded: number;\n /**\n * `Content-Length`, when the response carried one — a buffered body such as\n * a PDF. `null` for a streamed (chunked) body, whose size is not known\n * until it ends. With a compressed transfer it is the compressed size, so\n * `loaded` can pass it.\n */\n total: number | null;\n /**\n * The bytes this event reports. Empty on the first event of an attempt,\n * which fires as soon as the headers arrive, before any of the body.\n * A copy: changing it cannot change the value the request resolves to.\n */\n chunk: Uint8Array;\n /** The response headers, available from the first event on. */\n headers: Headers;\n /**\n * Which attempt this is, from `0`. A retried request reports its body\n * again from the start under the next number, so a listener that\n * accumulates state resets it when this changes.\n */\n attempt: number;\n}\n\n/**\n * Low-level options forwarded to a single HTTP request.\n */\nexport interface RequestOptions {\n /** Request body, serialised as JSON. */\n body?: unknown;\n /**\n * @internal Resource assertion that this operation deduplicates by the JSON\n * body's idempotency_key. Null means that optional key is absent, so the write\n * must not be retried. The transport checks the assertion against the body;\n * it does not send this option or copy a JSON key into an HTTP header.\n */\n bodyIdempotencyKey?: string | null;\n /**\n * Query-string parameters. `undefined` and `null` values are omitted.\n * Array values are emitted as repeated keys (`?tag=a&tag=b`) — not comma-joined.\n */\n query?: Record<\n string,\n string | number | boolean | null | undefined | (string | number | boolean)[]\n >;\n /** Additional HTTP headers merged with the default `api-key` header. */\n headers?: Record<string, string>;\n /**\n * Override the client-level timeout for this request, in milliseconds.\n *\n * Covers the whole request, body included — unless `onDownloadProgress` is\n * set, in which case it is an **idle** timeout: it restarts when the\n * headers arrive and on every chunk of the body, so a long download that\n * keeps making progress is never cut off, and one that stalls still is.\n */\n timeout?: number;\n /**\n * Caller-provided `AbortSignal`. Aborting it cancels the in-flight request and rejects\n * with a `DelopayError` carrying code `'ABORTED'`. Combined with the per-request timeout.\n */\n signal?: AbortSignal;\n /**\n * How to decode a 2xx response body. `'json'` (the default) parses JSON;\n * `'blob'` / `'arraybuffer'` return the raw bytes for binary endpoints\n * such as PDF exports. Error responses are always decoded as JSON and\n * thrown as `DelopayError` regardless of this setting.\n */\n responseType?: 'json' | 'blob' | 'arraybuffer';\n /**\n * Pass `keepalive: true` to let the request outlive its page — e.g.\n * telemetry sent while the document is navigating away. Browsers cap\n * keepalive request bodies at ~64 KiB and reject larger ones.\n */\n keepalive?: boolean;\n /**\n * Report a 2xx response body as it downloads. Called once as soon as the\n * headers arrive (with an empty `chunk` and `loaded: 0`), then once per\n * chunk of the body; the value the request resolves to is decoded from\n * those same bytes, per `responseType`. Error responses are not reported.\n *\n * Setting it turns `timeout` into an idle timeout (see there). A body that\n * fails part-way rejects with the ordinary `NETWORK` error and is retried\n * on the usual terms, starting again under the next `attempt`. A listener\n * that throws rejects the request with that error, unretried.\n */\n onDownloadProgress?: (event: DownloadProgressEvent) => void;\n}\n\nexport type RequestFn = <T>(method: string, path: string, options?: RequestOptions) => Promise<T>;\n\n/**\n * Per-call options that resource methods accept as an optional final argument:\n * extra HTTP headers (e.g. `Idempotency-Key`), a per-request timeout override,\n * an `AbortSignal` for cancellation, and a download-progress listener — the\n * last is what a file download (a statement PDF, a report CSV) reports its\n * bytes through.\n */\nexport type RequestExtras = Pick<\n RequestOptions,\n 'headers' | 'timeout' | 'signal' | 'onDownloadProgress'\n>;\n\n/** How long an event stream may stay silent before it is given up. */\nconst DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45_000;\n\n/** Options of one `text/event-stream` request. */\nexport interface EventStreamRequestOptions {\n /** Query-string parameters, as {@link RequestOptions.query}. */\n query?: RequestOptions['query'];\n /** Additional HTTP headers, merged over the auth header. */\n headers?: Record<string, string>;\n /**\n * Aborting it before the response arrives rejects with code `ABORTED`;\n * aborting it later ends the dispatches without an error.\n */\n signal?: AbortSignal;\n /**\n * How long the stream may stay silent, response headers included, before\n * it fails with code `TIMEOUT`. Paused while the consumer holds a dispatch.\n * Defaults to 45 seconds.\n */\n idleTimeoutMs?: number;\n /** Sent as `Last-Event-ID`, and the id the stream starts from. */\n lastEventId?: string | null;\n}\n\n/**\n * An open event stream. Its body is read as it is iterated and never kept:\n * only the line and the event in progress are held.\n */\nexport interface EventStreamConnection {\n /**\n * The stream's dispatches, in order. Ends when the server closes the\n * stream or the caller aborts or closes it; throws a `DelopayError` with\n * code `TIMEOUT` when the stream is silent too long, and `NETWORK` when\n * the connection fails. Iterate it once.\n */\n readonly dispatches: AsyncIterable<EventStreamDispatch>;\n /** Close the stream: the iteration ends and the connection is released. */\n close(): void;\n}\n\n/** Opens a `GET` event stream; what resources that stream receive. */\nexport type EventStreamFn = (\n path: string,\n options?: EventStreamRequestOptions,\n) => Promise<EventStreamConnection>;\n\n/**\n * What a resource class is built from: the client's request and event-stream\n * functions. Every resource takes the request function first; the few that\n * stream (`Live`, `ProcessorImports`) also take the stream opener.\n */\nexport interface DelopayTransport {\n /** Send one request with the client's credentials, retries and timeout. */\n readonly request: RequestFn;\n /** Open one `text/event-stream` request with the client's credentials. */\n readonly openStream: EventStreamFn;\n /** The resolved base URL every request goes to. */\n readonly baseUrl: string;\n}\n\n/** A resource class that {@link DelopayCore.use} can build. */\nexport type ResourceConstructor<T> = new (request: RequestFn, openStream: EventStreamFn) => T;\n\n/**\n * The Delopay client without its resources: credentials, configuration,\n * transport, sessions and pagination.\n *\n * {@link Delopay} extends it with every resource as a property, which puts\n * every resource in the application's bundle. An application that wants only\n * the resources it calls builds them from this class instead, importing each\n * one from its own module, so a bundler leaves the rest out and can load each\n * one with the code that uses it:\n *\n * @example\n * ```typescript\n * import { DelopayCore } from '@delopay/sdk/core';\n * import { Refunds } from '@delopay/sdk/resources/refunds';\n *\n * const client = new DelopayCore('snd_...', { sandbox: true });\n * const refunds = client.use(Refunds);\n * const refund = await refunds.create({ payment_id: 'pay_abc123' });\n * ```\n *\n * A resource built this way shares the client's credentials: a token set with\n * {@link DelopayCore.setJwtToken} applies to it at once.\n */\nexport class DelopayCore {\n /** The resolved base URL used for all API requests. */\n readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly debug: boolean;\n private readonly logger?: DelopayLogger;\n private readonly profileId?: string;\n private jwtToken?: string;\n\n /** The functions every resource is built from; see {@link DelopayCore.use}. */\n readonly transport: DelopayTransport;\n\n private readonly resources = new Map<ResourceConstructor<unknown>, unknown>();\n\n /**\n * Create a new client.\n *\n * @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).\n * Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).\n * @param options - Optional configuration (sandbox mode, base URL override, timeout).\n */\n constructor(apiKey?: string, options?: DelopayOptions) {\n this.apiKey = apiKey ?? '';\n this.timeout = options?.timeout ?? 30_000;\n this.maxRetries = options?.maxRetries ?? 2;\n this.debug = options?.debug ?? false;\n if (options?.logger !== undefined) this.logger = options.logger;\n if (options?.profileId !== undefined && options.profileId !== '') {\n this.profileId = options.profileId;\n }\n\n if (options?.baseUrl !== undefined) {\n this.baseUrl = options.baseUrl;\n } else if (options?.sandbox) {\n this.baseUrl = SANDBOX_URL;\n } else {\n this.baseUrl = PRODUCTION_URL;\n }\n\n this.transport = {\n request: this.request.bind(this) as RequestFn,\n openStream: this.openEventStream.bind(this),\n baseUrl: this.baseUrl,\n };\n }\n\n /**\n * The client's instance of a resource class, built on first use from this\n * client's transport. Later calls with the same class return the same\n * instance.\n *\n * A resource whose constructor takes something else besides the transport\n * (`Branding` takes the base URL) is built directly instead:\n * `new Branding(client.transport.request, client.baseUrl)`.\n *\n * @param Resource - The resource class, imported from its own module.\n * @returns The resource, bound to this client.\n */\n use<T>(Resource: ResourceConstructor<T>): T {\n let resource = this.resources.get(Resource) as T | undefined;\n if (resource === undefined) {\n resource = new Resource(this.transport.request, this.transport.openStream);\n this.resources.set(Resource, resource);\n }\n return resource;\n }\n\n /**\n * Set a JWT token for subsequent requests.\n * When set, requests use `Authorization: Bearer <token>` instead of `api-key`.\n * Useful after `users.signIn()` returns a JWT for dashboard operations.\n */\n setJwtToken(token: string): void {\n this.jwtToken = token;\n }\n\n /**\n * Clear the JWT token, reverting to API key authentication.\n */\n clearJwtToken(): void {\n this.jwtToken = undefined;\n }\n\n /**\n * End the current login session on the server (`POST /user/signout`), the\n * same request as {@link Users.signOut}. The token stays set on this\n * client: clear it with {@link DelopayCore.clearJwtToken} afterwards. The\n * request's `Authorization` header is built when this is called, so\n * clearing the token straight after still signs out the session it held.\n */\n async signOut(): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/signout');\n }\n\n /**\n * Refresh the current login JWT (see {@link Users.refreshToken}) and\n * apply the fresh token to this client, so subsequent requests use it.\n * Returns the fresh token for the caller to persist (e.g. session\n * storage) — the backend has already re-set the `login_token` cookie.\n *\n * If the client's auth state changes while the refresh is pending —\n * `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another\n * session — the stale completion is discarded and this rejects with a\n * `session_changed` `DelopayError` (status 0), so the explicit change\n * wins and the caller never persists a token for a session that is gone.\n *\n * Otherwise throws like any other request; in particular a 401 means the\n * session is dead (expired/blacklisted/revoked), a 429 means a refresh\n * was already minted for this session within the last minute, and a 400\n * means this token has no revocable session to slide (no `jti` — team\n * impersonation is the case in practice) and can never be refreshed,\n * though it stays valid for ordinary calls.\n */\n async refreshSession(): Promise<TokenResponse> {\n const originatingToken = this.jwtToken;\n const response = await this.request<TokenResponse>('POST', '/user/token/refresh');\n if (this.jwtToken !== originatingToken) {\n throw new DelopayError(\n 'Auth state changed while the refresh was pending; refreshed token discarded',\n {\n status: 0,\n code: 'session_changed',\n type: 'session_changed',\n },\n );\n }\n this.setJwtToken(response.token);\n return response;\n }\n\n /** `path` on the base URL, with the query string `query` makes. */\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n let url = `${this.baseUrl}${path}`;\n if (query) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else {\n params.set(key, String(value));\n }\n }\n const qs = params.toString();\n if (qs) {\n url += `?${qs}`;\n }\n }\n return url;\n }\n\n /** The credential header: the JWT when one is set, else the API key. */\n /**\n * The client's `X-Profile-Id`, unless the call names one itself (in any\n * letter case: two spellings would be sent as one joined value).\n */\n private profileHeaders(callHeaders?: Record<string, string>): Record<string, string> {\n if (this.profileId === undefined) return {};\n const named = Object.keys(callHeaders ?? {}).some(\n (name) => name.toLowerCase() === 'x-profile-id',\n );\n return named ? {} : { 'X-Profile-Id': this.profileId };\n }\n\n private authHeaders(): Record<string, string> {\n if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };\n if (this.apiKey) return { 'api-key': this.apiKey };\n return {};\n }\n\n /** One debug event, when `debug` is on. */\n private log(event: 'request' | 'response' | 'retry', data: Record<string, unknown>): void {\n if (!this.debug) return;\n if (this.logger) {\n this.logger(event, data);\n return;\n }\n if (event === 'request')\n console.log(`[delopay] ${data.method as string} ${data.url as string}`);\n else if (event === 'response')\n console.log(\n `[delopay] ${data.status as number} ${data.method as string} ${data.path as string}`,\n );\n else\n console.log(\n `[delopay] retry ${data.attempt as number}/${data.maxRetries as number} ${data.method as string} ${data.path as string}`,\n );\n }\n\n /**\n * Open a `GET` `text/event-stream` and read it as it arrives.\n *\n * `request()` keeps every chunk of a body until the body ends, which a\n * stream that stays open for half an hour must not do; this reads the body\n * chunk by chunk through {@link EventStreamParser} and keeps nothing it has\n * dispatched. Credentials, the base URL, debug logging and the mapping of a\n * non-2xx answer to `DelopayError` / `DelopayAuthenticationError` are the\n * ones `request()` uses.\n *\n * Never retried, and never reconnected: the caller owns reconnection.\n * Resolves once the response headers arrive; rejects on a non-2xx answer,\n * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and\n * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.\n */\n protected async openEventStream(\n path: string,\n options: EventStreamRequestOptions = {},\n ): Promise<EventStreamConnection> {\n const url = this.buildUrl(path, options.query);\n const lastEventId = options.lastEventId ?? '';\n const headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options.headers),\n Accept: 'text/event-stream',\n ...(lastEventId ? { 'Last-Event-ID': lastEventId } : {}),\n ...options.headers,\n };\n const idleMs = options.idleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;\n const callerSignal = options.signal;\n const aborted = () =>\n new DelopayError('Request aborted', { status: 0, code: 'ABORTED', type: 'abort_error' });\n if (callerSignal?.aborted) throw aborted();\n\n const idleCtrl = new AbortController();\n const closeCtrl = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const stopIdleTimer = () => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n };\n const startIdleTimer = () => {\n stopIdleTimer();\n if (!idleCtrl.signal.aborted) timer = setTimeout(() => idleCtrl.abort(), idleMs);\n };\n const combined = combineSignals(\n callerSignal\n ? [idleCtrl.signal, closeCtrl.signal, callerSignal]\n : [idleCtrl.signal, closeCtrl.signal],\n );\n const release = () => {\n stopIdleTimer();\n combined.dispose();\n };\n const timedOut = () =>\n new DelopayError(`Event stream silent for ${idleMs} ms`, {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n const network = (cause: unknown) =>\n new DelopayError(\n `Network error: ${cause instanceof Error ? cause.message : String(cause ?? 'stream failed')}`,\n { status: 0, code: 'NETWORK', type: 'network_error' },\n );\n\n this.log('request', { method: 'GET', url: redactUrlForLogging(url), path });\n startIdleTimer();\n let response: Response;\n try {\n response = await fetch(url, { method: 'GET', headers, signal: combined.signal });\n } catch (err) {\n release();\n if (callerSignal?.aborted) throw aborted();\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err);\n }\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n this.log('response', { status: response.status, method: 'GET', path, requestId });\n\n if (!response.ok) {\n // Read under the idle timer: a body that never ends gives up as empty.\n const error = await errorFromResponse(response, requestId);\n release();\n throw error;\n }\n\n const body = response.body;\n const contentType = response.headers?.get('content-type') ?? '';\n const mediaType = (contentType.split(';')[0] ?? '').trim().toLowerCase();\n if (mediaType !== 'text/event-stream' || !body || typeof body.getReader !== 'function') {\n release();\n body?.cancel().catch(noop);\n throw new DelopayError(\n mediaType === 'text/event-stream'\n ? 'The event stream has no readable body'\n : `Expected a text/event-stream response, got ${contentType ? `\"${contentType}\"` : 'no content type'}`,\n {\n status: response.status,\n code: 'NOT_EVENT_STREAM',\n type: 'invalid_response',\n requestId,\n },\n );\n }\n\n // The idle timer runs only while a read is pending: a consumer busy with\n // an event, or one that has not started iterating, is not silence.\n stopIdleTimer();\n const reader = body.getReader();\n const parser = new EventStreamParser(lastEventId);\n const decoder = new TextDecoder();\n const stopped = () => Boolean(callerSignal?.aborted) || closeCtrl.signal.aborted;\n let finished = false;\n const finish = () => {\n if (finished) return;\n finished = true;\n release();\n reader.cancel().catch(noop);\n };\n\n async function* dispatches(): AsyncGenerator<EventStreamDispatch, void, undefined> {\n try {\n for (;;) {\n let result: ReadableStreamReadResult<Uint8Array>;\n startIdleTimer();\n try {\n result = await readChunk(reader, combined.signal);\n } catch (err) {\n if (callerSignal?.aborted || closeCtrl.signal.aborted) return;\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err instanceof BodyStreamFailure ? err.cause : err);\n } finally {\n stopIdleTimer();\n }\n if (result.done) {\n // An event the stream did not finish with a blank line is\n // discarded, as the standard has it; only completed ones count.\n for (const dispatch of parser.push(decoder.decode())) {\n if (stopped()) return;\n yield dispatch;\n }\n return;\n }\n if (!result.value || result.value.byteLength === 0) continue;\n for (const dispatch of parser.push(decoder.decode(result.value, { stream: true }))) {\n // Aborted or closed while the consumer held the previous one.\n if (stopped()) return;\n yield dispatch;\n }\n }\n } finally {\n finish();\n }\n }\n\n return {\n dispatches: dispatches(),\n close: () => {\n closeCtrl.abort();\n finish();\n },\n };\n }\n\n /**\n * Make a raw HTTP request to the Delopay API.\n *\n * You rarely need to call this directly — prefer the typed resource methods.\n * Use it only for endpoints not yet covered by a resource class.\n *\n * @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).\n * @param path - API path starting with `/` (e.g. `/payments`).\n * @param options - Optional body, query parameters, and headers.\n * @returns Parsed JSON response body typed as `T`.\n * @throws {DelopayAuthenticationError} On 401 responses.\n * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.\n */\n async request<T>(method: string, path: string, options?: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options?.query);\n\n let headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options?.headers),\n ...options?.headers,\n };\n\n // FormData / Blob / ArrayBuffer / URLSearchParams pass through unchanged so callers\n // can send multipart uploads. The runtime (browser or Node 18+ fetch) sets the\n // appropriate Content-Type including the multipart boundary, so we don't touch it.\n const isRawBody =\n options?.body !== undefined &&\n options?.body !== null &&\n (options.body instanceof FormData ||\n options.body instanceof Blob ||\n options.body instanceof ArrayBuffer ||\n options.body instanceof URLSearchParams);\n\n if (options?.body && !isRawBody) {\n headers['Content-Type'] = 'application/json';\n }\n\n // Serialize body once so circular-reference errors surface immediately and big payloads\n // aren't re-stringified on every retry attempt. Raw bodies pass through untouched.\n let serializedBody: BodyInit | undefined;\n if (isRawBody) {\n serializedBody = options?.body as BodyInit;\n } else if (options?.body) {\n serializedBody = JSON.stringify(options.body);\n }\n\n let idempotencyKey = findIdempotencyKey(headers)?.trim();\n if (options && Object.prototype.hasOwnProperty.call(options, 'bodyIdempotencyKey')) {\n const bodyKey = options?.bodyIdempotencyKey;\n const serialized: unknown =\n !isRawBody && typeof serializedBody === 'string' ? JSON.parse(serializedBody) : null;\n const actualKey =\n serialized && typeof serialized === 'object' && !Array.isArray(serialized)\n ? ((serialized as Record<string, unknown>).idempotency_key ?? null)\n : null;\n const suppliedHeaders = Object.keys(headers).filter(\n (name) => name.toLowerCase() === 'idempotency-key',\n );\n if (\n (bodyKey !== null && typeof bodyKey !== 'string') ||\n actualKey !== bodyKey ||\n suppliedHeaders.some(\n (name) => headers[name] !== bodyKey || headers[name]?.trim() !== headers[name],\n )\n ) {\n throw new DelopayError('Request retry keys must match the JSON body key', {\n status: 0,\n code: 'IDEMPOTENCY_KEY_MISMATCH',\n type: 'invalid_request',\n });\n }\n idempotencyKey = bodyKey?.trim();\n // Collapse differently cased copies so fetch cannot combine them into a\n // different header value. Other caller headers remain untouched.\n if (suppliedHeaders.length > 0) {\n headers = {\n ...Object.fromEntries(\n Object.entries(headers).filter(([name]) => name.toLowerCase() !== 'idempotency-key'),\n ),\n 'Idempotency-Key': idempotencyKey ?? '',\n };\n }\n }\n const isRetryable =\n method === 'GET' ||\n method === 'DELETE' ||\n (idempotencyKey !== undefined && idempotencyKey !== '');\n\n const callerSignal = options?.signal;\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n\n const timeoutMs = options?.timeout ?? this.timeout;\n\n let lastError: unknown;\n let retryAfterOverrideMs: number | null = null;\n\n const safeUrl = () => redactUrlForLogging(url);\n const emit = (event: 'request' | 'response' | 'retry', data: Record<string, unknown>) =>\n this.log(event, data);\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const base = Math.min(500 * 2 ** (attempt - 1), 5000);\n // Full jitter: pick uniformly in [0, base) to avoid synchronized retry storms.\n const jittered = Math.random() * base;\n const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);\n retryAfterOverrideMs = null;\n await new Promise((resolve) => setTimeout(resolve, delay));\n emit('retry', { attempt, maxRetries: this.maxRetries, method, path });\n }\n\n const timeoutCtrl = new AbortController();\n let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n // With a progress listener the timeout measures silence, not the whole\n // download: each sign of life restarts it.\n const restartIdleTimer = () => {\n if (timeoutCtrl.signal.aborted) return;\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n };\n const combined = combineSignals(\n callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal],\n );\n\n try {\n emit('request', { method, url: safeUrl(), path });\n\n const response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: combined.signal,\n ...(options?.keepalive !== undefined ? { keepalive: options.keepalive } : {}),\n });\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n\n emit('response', { status: response.status, method, path, requestId });\n\n if (!response.ok) {\n // A 401 that is our credential's comes back as a\n // DelopayAuthenticationError; its status is never transient, so it\n // is thrown below without a retry.\n const error = await errorFromResponse(response, requestId);\n\n // Retry on 5xx and 429 (rate limit). 4xx other than 429 are not transient.\n const isTransientStatus = response.status >= 500 || response.status === 429;\n if (isTransientStatus && isRetryable && attempt < this.maxRetries) {\n if (response.status === 429) {\n retryAfterOverrideMs = parseRetryAfter(response.headers?.get('retry-after') ?? null);\n }\n lastError = error;\n continue;\n }\n\n throw error;\n }\n\n if (options?.onDownloadProgress) {\n return (await receiveWithProgress(\n response,\n options.responseType,\n options.onDownloadProgress,\n attempt,\n combined.signal,\n restartIdleTimer,\n )) as T;\n }\n if (options?.responseType === 'blob') {\n return (await response.blob()) as T;\n }\n if (options?.responseType === 'arraybuffer') {\n return (await response.arrayBuffer()) as T;\n }\n const text = await response.text();\n return (text ? JSON.parse(text) : undefined) as T;\n } catch (err) {\n if (err instanceof DelopayError || err instanceof DelopayAuthenticationError) {\n throw err;\n }\n if (err instanceof ListenerFailure) {\n throw err.cause;\n }\n if (err instanceof BodyStreamFailure) {\n const cause = err.cause;\n const detail =\n cause instanceof Error ? cause.message : String(cause ?? 'body stream failed');\n lastError = new DelopayError(`Network error: ${detail}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof Error && err.name === 'AbortError') {\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n lastError = new DelopayError('Request timed out', {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof TypeError) {\n lastError = new DelopayError(`Network error: ${err.message}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n combined.dispose();\n }\n }\n\n throw lastError;\n }\n\n /**\n * Auto-paginate a list endpoint. Yields items one by one, fetching\n * the next page automatically when the current one is exhausted.\n *\n * Delopay list endpoints use one of two pagination styles, so this helper\n * supports both:\n * - **Offset** (default) — for endpoints like `customers.list` that accept\n * `offset`/`limit`. Each page advances `offset` by the number of items returned.\n * - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page\n * with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor\n * that returns the id of an item; the next page is requested with\n * `starting_after` set to the last item's id.\n *\n * @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.\n * @param params - Additional parameters to pass to every page request.\n * @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.\n * Provide `cursor` to switch to cursor pagination.\n *\n * @example\n * ```typescript\n * // Offset endpoint (customers):\n * for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {\n * console.log(c.customer_id);\n * }\n *\n * // Cursor endpoint (payments): extract the id used as the next cursor.\n * for await (const payment of delopay.paginate(\n * (p) => delopay.payments.list(p),\n * undefined,\n * { cursor: (p) => p.payment_id },\n * )) {\n * console.log(payment.payment_id);\n * }\n * ```\n */\n async *paginate<T, P extends Record<string, unknown>>(\n listFn: (\n params: P & { limit: number; offset?: number; starting_after?: string },\n ) => Promise<{ data: T[] } | T[]>,\n params?: P,\n options?: number | { pageSize?: number; cursor?: (item: T) => string | undefined },\n ): AsyncGenerator<T> {\n const pageSize = typeof options === 'number' ? options : (options?.pageSize ?? 50);\n const cursorOf = typeof options === 'object' ? options.cursor : undefined;\n let offset = 0;\n let after: string | undefined;\n while (true) {\n const page = { ...((params ?? {}) as P), limit: pageSize } as P & {\n limit: number;\n offset?: number;\n starting_after?: string;\n };\n if (cursorOf) {\n if (after !== undefined) page.starting_after = after;\n } else {\n page.offset = offset;\n }\n const result = await listFn(page);\n const items = Array.isArray(result) ? result : result.data;\n if (items.length === 0) break;\n for (const item of items) {\n yield item;\n }\n if (items.length < pageSize) break;\n if (cursorOf) {\n const last = items[items.length - 1];\n if (last === undefined) break;\n after = cursorOf(last);\n if (after === undefined) break;\n } else {\n offset += items.length;\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/tmp/publish-sdk-04990/dist/chunk-I2W7AO4B.cjs","../src/error.ts"],"names":[],"mappings":"AAAA;ACeO,IAAM,aAAA,EAAN,MAAA,QAA2B,MAAM;AAAA,EAsBtC,WAAA,CACE,OAAA,EACA,OAAA,EAQA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAChD,IAAA,IAAA,CAAK,KAAA,EAAO,cAAA;AACZ,IAAA,IAAA,CAAK,OAAA,EAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,KAAA,EAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,IAAA,CAAK,KAAA,EAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,GAAA,CAAI,OAAA,CAAQ,UAAA,IAAc,KAAA,CAAA,EAAW,IAAA,CAAK,UAAA,EAAY,OAAA,CAAQ,SAAA;AAC9D,IAAA,GAAA,CAAI,OAAA,CAAQ,QAAA,IAAY,KAAA,CAAA,EAAW,IAAA,CAAK,QAAA,EAAU,OAAA,CAAQ,OAAA;AAC1D,IAAA,GAAA,CAAI,OAAA,CAAQ,KAAA,IAAS,KAAA,CAAA,EAAW,IAAA,CAAK,KAAA,EAAO,OAAA,CAAQ,IAAA;AAAA,EACtD;AACF,CAAA;AAYO,IAAM,2BAAA,EAAN,MAAA,QAAyC,aAAa;AAAA,EAC3D,WAAA,CACE,QAAA,EAAU,iBAAA,EACV,OAAA,EAOA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS;AAAA,MACb,MAAA,EAAQ,GAAA;AAAA;AAAA;AAAA;AAAA,MAIR,IAAA,kBAAM,OAAA,2BAAS,OAAA,GAAQ,SAAA;AAAA,MACvB,IAAA,kBAAM,OAAA,6BAAS,OAAA,GAAQ,sBAAA;AAAA,MACvB,SAAA,kBAAW,OAAA,6BAAS,WAAA;AAAA,MACpB,OAAA,kBAAS,OAAA,6BAAS,SAAA;AAAA,MAClB,IAAA,kBAAM,OAAA,6BAAS;AAAA,IACjB,CAAC,CAAA;AACD,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAChD,IAAA,IAAA,CAAK,KAAA,EAAO,4BAAA;AAAA,EACd;AACF,CAAA;ADhEA;AACA;AACE;AACA;AACF,qGAAC","file":"/tmp/publish-sdk-04990/dist/chunk-I2W7AO4B.cjs","sourcesContent":[null,"/**\n * Error thrown when the Delopay API returns a non-2xx response, or when a\n * timeout or network error occurs.\n *\n * @example\n * ```typescript\n * try {\n * await delopay.payments.create({ amount: 5000, currency: 'EUR' });\n * } catch (e) {\n * if (e instanceof DelopayError) {\n * console.error(e.status, e.code, e.requestId, e.message);\n * }\n * }\n * ```\n */\nexport class DelopayError extends Error {\n /** HTTP status code returned by the API, or `0` for timeout/network errors. */\n readonly status: number;\n /** Machine-readable error code returned by the API (e.g. `'HE_00'`). */\n readonly code: string;\n /** Error category (e.g. `'invalid_request'`, `'timeout_error'`). */\n readonly type: string;\n /** Value of the `x-request-id` response header, when present. Include this when contacting support. */\n readonly requestId?: string;\n /**\n * Raw response body (truncated to ~2 KB). Populated when the server returns a\n * non-JSON error body (e.g. an HTML 502 from an upstream proxy) so debugging\n * still has something to go on.\n */\n readonly rawBody?: string;\n /**\n * Structured error context the API attaches under `error.data` for select\n * codes — e.g. `{ retry_after_secs: 248 }` on rate-limit / max-attempt\n * lockouts. Schema is per-code; consult the API reference for the shape.\n */\n readonly data?: Record<string, unknown>;\n\n constructor(\n message: string,\n options: {\n status: number;\n code: string;\n type: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayError';\n this.status = options.status;\n this.code = options.code;\n this.type = options.type;\n if (options.requestId !== undefined) this.requestId = options.requestId;\n if (options.rawBody !== undefined) this.rawBody = options.rawBody;\n if (options.data !== undefined) this.data = options.data;\n }\n}\n\n/**\n * Thrown when the API key is missing, invalid, or revoked (HTTP 401).\n *\n * @example\n * ```typescript\n * if (e instanceof DelopayAuthenticationError) {\n * // Prompt user to re-enter their API key.\n * }\n * ```\n */\nexport class DelopayAuthenticationError extends DelopayError {\n constructor(\n message = 'Invalid API key',\n options?: {\n code?: string;\n type?: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message, {\n status: 401,\n // Default to the generic \"invalid API key\" code, but let callers pass\n // through the server-reported code (e.g. `UR_05` for unverified-email\n // 401s) so they can differentiate between auth failure reasons.\n code: options?.code || 'AUTH_01',\n type: options?.type || 'authentication_error',\n requestId: options?.requestId,\n rawBody: options?.rawBody,\n data: options?.data,\n });\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayAuthenticationError';\n }\n}\n"]}
1
+ {"version":3,"sources":["/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-I2W7AO4B.cjs","../src/error.ts"],"names":[],"mappings":"AAAA;ACeO,IAAM,aAAA,EAAN,MAAA,QAA2B,MAAM;AAAA,EAsBtC,WAAA,CACE,OAAA,EACA,OAAA,EAQA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,MAAA,CAAO,cAAA,CAAe,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E;AACA;AACF,qGAAC","file":"/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-I2W7AO4B.cjs","sourcesContent":[null,"/**\n * Error thrown when the Delopay API returns a non-2xx response, or when a\n * timeout or network error occurs.\n *\n * @example\n * ```typescript\n * try {\n * await delopay.payments.create({ amount: 5000, currency: 'EUR' });\n * } catch (e) {\n * if (e instanceof DelopayError) {\n * console.error(e.status, e.code, e.requestId, e.message);\n * }\n * }\n * ```\n */\nexport class DelopayError extends Error {\n /** HTTP status code returned by the API, or `0` for timeout/network errors. */\n readonly status: number;\n /** Machine-readable error code returned by the API (e.g. `'HE_00'`). */\n readonly code: string;\n /** Error category (e.g. `'invalid_request'`, `'timeout_error'`). */\n readonly type: string;\n /** Value of the `x-request-id` response header, when present. Include this when contacting support. */\n readonly requestId?: string;\n /**\n * Raw response body (truncated to ~2 KB). Populated when the server returns a\n * non-JSON error body (e.g. an HTML 502 from an upstream proxy) so debugging\n * still has something to go on.\n */\n readonly rawBody?: string;\n /**\n * Structured error context the API attaches under `error.data` for select\n * codes — e.g. `{ retry_after_secs: 248 }` on rate-limit / max-attempt\n * lockouts. Schema is per-code; consult the API reference for the shape.\n */\n readonly data?: Record<string, unknown>;\n\n constructor(\n message: string,\n options: {\n status: number;\n code: string;\n type: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayError';\n this.status = options.status;\n this.code = options.code;\n this.type = options.type;\n if (options.requestId !== undefined) this.requestId = options.requestId;\n if (options.rawBody !== undefined) this.rawBody = options.rawBody;\n if (options.data !== undefined) this.data = options.data;\n }\n}\n\n/**\n * Thrown when the API key is missing, invalid, or revoked (HTTP 401).\n *\n * @example\n * ```typescript\n * if (e instanceof DelopayAuthenticationError) {\n * // Prompt user to re-enter their API key.\n * }\n * ```\n */\nexport class DelopayAuthenticationError extends DelopayError {\n constructor(\n message = 'Invalid API key',\n options?: {\n code?: string;\n type?: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message, {\n status: 401,\n // Default to the generic \"invalid API key\" code, but let callers pass\n // through the server-reported code (e.g. `UR_05` for unverified-email\n // 401s) so they can differentiate between auth failure reasons.\n code: options?.code || 'AUTH_01',\n type: options?.type || 'authentication_error',\n requestId: options?.requestId,\n rawBody: options?.rawBody,\n data: options?.data,\n });\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayAuthenticationError';\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/tmp/publish-sdk-04990/dist/chunk-I2XGNALG.cjs","../src/resources/forex.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,MAAA,EAAN,MAAY;AAAA,EACjB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA,EAGlD,MAAM,QAAA,CACJ,MAAA,EACkC;AAClC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,cAAA,EAAgB,EAAE,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,EAC9D;AAAA;AAAA,EAGA,MAAM,gBAAA,CACJ,MAAA,EACkC;AAClC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,2BAAA,EAA6B,EAAE,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,EAC3E;AACF,CAAA;ADJA;AACA;AACE;AACF,sBAAC","file":"/tmp/publish-sdk-04990/dist/chunk-I2XGNALG.cjs","sourcesContent":[null,"import type { RequestFn } from '../client';\n\nexport class Forex {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve forex rates. `GET /forex/rates` */\n async getRates(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/rates', { query: params });\n }\n\n /** Convert from minor currency. `GET /forex/convert-from-minor` */\n async convertFromMinor(\n params: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/convert-from-minor', { query: params });\n }\n}\n"]}
1
+ {"version":3,"sources":["/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-I2XGNALG.cjs","../src/resources/forex.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,MAAA,EAAN,MAAY;AAAA,EACjB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA,EAGlD,MAAM,QAAA,CACJ,MAAA,EACkC;AAClC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,cAAA,EAAgB,EAAE,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,EAC9D;AAAA;AAAA,EAGA,MAAM,gBAAA,CACJ,MAAA,EACkC;AAClC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,2BAAA,EAA6B,EAAE,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,EAC3E;AACF,CAAA;ADJA;AACA;AACE;AACF,sBAAC","file":"/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-I2XGNALG.cjs","sourcesContent":[null,"import type { RequestFn } from '../client';\n\nexport class Forex {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve forex rates. `GET /forex/rates` */\n async getRates(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/rates', { query: params });\n }\n\n /** Convert from minor currency. `GET /forex/convert-from-minor` */\n async convertFromMinor(\n params: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/convert-from-minor', { query: params });\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkZMJT2YPZcjs = require('./chunk-ZMJT2YPZ.cjs');
3
+ var _chunkIUXCU3DWcjs = require('./chunk-IUXCU3DW.cjs');
4
4
 
5
5
 
6
6
  var _chunkI2W7AO4Bcjs = require('./chunk-I2W7AO4B.cjs');
@@ -69,7 +69,7 @@ var CheckoutSession = class {
69
69
  this.paymentId = options.paymentId;
70
70
  this.publishableKey = options.publishableKey;
71
71
  this.clientSecret = options.clientSecret;
72
- this.client = new (0, _chunkZMJT2YPZcjs.Delopay)("", {
72
+ this.client = new (0, _chunkIUXCU3DWcjs.Delopay)("", {
73
73
  baseUrl: options.baseUrl,
74
74
  sandbox: options.sandbox,
75
75
  timeout: options.timeout,
@@ -1040,4 +1040,4 @@ var CheckoutSession = class {
1040
1040
 
1041
1041
 
1042
1042
  exports.CheckoutSession = CheckoutSession;
1043
- //# sourceMappingURL=chunk-K3XXGAOR.cjs.map
1043
+ //# sourceMappingURL=chunk-IDY2LP4Q.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-IDY2LP4Q.cjs","../src/checkoutSession.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACoEA,SAAS,wBAAA,CAAyB,KAAA,EAAwD;AACxF,EAAA,GAAA,CAAI,CAAC,KAAA,EAAO,OAAO,CAAC,CAAA;AACpB,EAAA,MAAM,IAAA,EAA8B,CAAC,CAAA;AACrC,EAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EA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,IAAA;AACF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAasC,EAAA;AACkB,IAAA;AACyB,MAAA;AAC1E,MAAA;AACqC,MAAA;AACzC,IAAA;AACH,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgB8C,EAAA;AAC+B,IAAA;AAClE,MAAA;AACmC,QAAA;AACvB,QAAA;AACD,QAAA;AACU,QAAA;AAC5B,MAAA;AACG,MAAA;AACqC,MAAA;AACzC,IAAA;AACH,EAAA;AACF;AD/VsG;AACA;AACA;AACA","file":"/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-IDY2LP4Q.cjs","sourcesContent":[null,"import { Delopay } from './client';\nimport type { DelopayLogger, RequestExtras } from './client';\nimport { DelopayError } from './error';\nimport type {\n BrowserCardClaimRequest,\n BrowserCardClaimResponse,\n CheckoutAddonChoiceRequest,\n CheckoutAddonChoiceResponse,\n CheckoutDataResponse,\n CheckoutTax,\n CheckoutTaxRequest,\n CheckoutIdentityEmailCodeRequest,\n CheckoutIdentityEmailCodeResponse,\n CheckoutIdentityEmailVerifyRequest,\n CheckoutIdentityEmailVerifyResponse,\n CheckoutIdentityReuseRequest,\n CheckoutIdentityVerificationResponse,\n CheckoutIdentityVerificationStartRequest,\n CheckoutDeviceSessionCompleteRequest,\n CheckoutDeviceSessionResponse,\n ConfirmSubscriptionRequest,\n ConfirmSubscriptionResponse,\n EpayoutsMethodsOptions,\n EpayoutsMethodsResponse,\n MollieApplePaySessionRequest,\n MollieApplePaySessionResponse,\n MicropaymentBankSessionRequest,\n MicropaymentBankSessionResponse,\n EpayoutsPaypalDeclineRequest,\n EpayoutsPaypalDeclineResponse,\n EpayoutsPaypalOrderResponse,\n PaymentAbandonAttemptResponse,\n PaymentReopenAttemptResponse,\n PaymentConfirmRequest,\n PaymentMethodListResponse,\n PaymentMethodPresentationResponse,\n PaymentResponse,\n PaymentsPostSessionTokensRequest,\n PaymentsPostSessionTokensResponse,\n PaymentUpdateRequest,\n RecordCheckoutEventRequest,\n RecordCheckoutEventResponse,\n ReplayIngestParams,\n ReplayIngestResponse,\n NomupayCardAuthorizationRequest,\n NomupayCardAuthorizationResponse,\n StripeHostedConfirmRequest,\n SubscriptionCheckoutResponse,\n SubscriptionReturnStatusResponse,\n SelectSubscriptionMethodRequest,\n SubscriptionCheckoutMethod,\n SubscriptionMethodOptionsResponse,\n SubscriptionResponse,\n StripeHostedConfirmResponse,\n EnigmaFormSession,\n VaultCollectSessionParams,\n VaultCollectSessionResponse,\n VaultPaymentMethodRequest,\n VaultPaymentMethodResponse,\n VaultSavedCardsResponse,\n} from './types';\n\n/**\n * A publishable (browser-safe) API key. The template type rejects secret\n * keys (`prd_…` / `snd_…`) at compile time, so a checkout cannot be handed\n * a credential that would reach secret-key routes.\n */\nexport type PublishableKey = `pk_${string}`;\n\n/**\n * Drop any caller-supplied credential headers (case-insensitively), so a\n * route can only ever carry the one credential its family requires — the\n * class's isolation guarantee must hold against per-call `headers` too.\n * Non-credential extras (`Idempotency-Key`, `X-Dp-*`, …) pass through.\n */\nfunction withoutCredentialHeaders(extra?: Record<string, string>): Record<string, string> {\n if (!extra) return {};\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(extra)) {\n const lower = key.toLowerCase();\n if (lower === 'api-key' || lower === 'authorization') continue;\n out[key] = value;\n }\n return out;\n}\n\n/** The query a vault form session is asked with: the buyer's locale and the form's look. */\nfunction vaultFormQuery(params?: VaultCollectSessionParams): Record<string, string | undefined> {\n const look = params?.appearance;\n return {\n locale: params?.locale,\n form_surface: look?.surface,\n form_text: look?.text,\n form_border: look?.border,\n form_accent: look?.accent,\n form_danger: look?.danger,\n form_font: look?.font,\n form_radius: look?.radius,\n form_size: look?.size,\n form_labels: look?.labels,\n form_chrome: look?.chrome,\n form_label: look?.label,\n form_hints: look?.hints === undefined ? undefined : String(look.hints),\n form_order: look?.order,\n form_marks: look?.marks,\n form_focus: look?.focus,\n form_motion: look?.motion,\n form_height: look?.height,\n form_gap: look?.gap,\n form_corner: look?.corner,\n form_fill: look?.fill,\n form_custom: look?.custom ? 'true' : undefined,\n };\n}\n\n/** Drop one header (case-insensitively) from a caller-supplied extras map. */\nfunction withoutHeader(headers: Record<string, string>, name: string): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === name) continue;\n out[key] = value;\n }\n return out;\n}\n\n/** Configuration for a {@link CheckoutSession}. */\nexport interface CheckoutSessionOptions {\n /** The merchant the payment belongs to. */\n merchantId: string;\n /** The payment this session is about. */\n paymentId: string;\n /**\n * The merchant's publishable key (`pk_prd_…` / `pk_snd_…`), from the\n * checkout payload's `pub_key`. Required for the `/payments/*` and\n * `/payment-methods` calls.\n */\n publishableKey?: PublishableKey;\n /**\n * The payment's client secret, from the checkout payload. Required for\n * every `/payment-link/*` call, and rides along on the payment calls.\n */\n clientSecret?: string;\n /** Override the API base URL (e.g. `/api` behind a same-origin proxy). */\n baseUrl?: string;\n /** Use the sandbox environment. Ignored when `baseUrl` is set. */\n sandbox?: boolean;\n /** Per-request timeout in milliseconds. */\n timeout?: number;\n /** Maximum automatic retries for retryable requests. */\n maxRetries?: number;\n debug?: boolean;\n logger?: DelopayLogger;\n}\n\n/**\n * Buyer-side client for a single hosted-checkout payment.\n *\n * Binds the two browser-safe credentials once — the merchant's publishable\n * key and the payment's client secret — and sends each request with exactly\n * the credential its route expects:\n *\n * - `/payment-link/*` side-channel routes authenticate with\n * `Authorization: Bearer <client_secret>`.\n * - `/payments/*` and `/payment-methods` authenticate with the publishable\n * key in the `api-key` header, with the client secret as query parameter\n * or body field.\n *\n * Neither credential can reach a secret-key route: the publishable key is\n * typed to the `pk_` prefix and the client secret only ever leaves as a\n * bearer token / parameter, never as an `api-key`.\n *\n * @example\n * ```typescript\n * const session = new CheckoutSession({\n * merchantId: checkout.merchant_id,\n * paymentId: checkout.payment_id,\n * publishableKey: checkout.pub_key,\n * clientSecret: checkout.client_secret,\n * });\n * const catalog = await session.epayoutsMethods('de');\n * ```\n */\n/**\n * A `CompressionStream` constructor, as much of it as this module uses.\n *\n * Declared structurally rather than taken from the DOM lib: the global is\n * absent in some runtimes this SDK is dropped into, and a type that asserts it\n * exists would make the feature test look redundant to the next reader.\n */\ntype GzipStreamCtor = new (format: 'gzip') => {\n readable: ReadableStream<Uint8Array>;\n writable: WritableStream<Uint8Array>;\n};\n\n/**\n * Gzip a JSON body, or answer `null` where the runtime cannot.\n *\n * `null` is not a failure — it is the caller's instruction to send the body\n * uncompressed. `CompressionStream` is a global in Node 18+ and in current\n * browsers but is missing from older Safari and from some embedded runtimes,\n * and this SDK carries no runtime dependencies, so there is no polyfill to\n * reach for. Sending plain JSON is always correct; the server reads the\n * encoding off the header it is given.\n *\n * The compressed stream is drained to an `ArrayBuffer` rather than handed to\n * `fetch` as a stream. A streamed request body needs `duplex: 'half'`, cannot\n * be replayed on a retry, and is refused outright together with `keepalive` —\n * which is precisely the case a recorder needs when the page is navigating\n * away.\n */\nasync function gzipJson(value: unknown): Promise<ArrayBuffer | null> {\n const ctor = (globalThis as { CompressionStream?: GzipStreamCtor }).CompressionStream;\n if (typeof ctor !== 'function') return null;\n try {\n const bytes = new TextEncoder().encode(JSON.stringify(value));\n return await new Response(\n new Blob([bytes]).stream().pipeThrough(new ctor('gzip')),\n ).arrayBuffer();\n } catch {\n // A runtime carrying the constructor but unable to run it — no\n // `Blob.prototype.stream`, no `pipeThrough` — is the uncompressed case\n // too. A recording must never cost the caller a payment page.\n return null;\n }\n}\n\nexport class CheckoutSession {\n private readonly client: Delopay;\n private readonly merchantId: string;\n private readonly paymentId: string;\n private readonly publishableKey?: PublishableKey;\n private readonly clientSecret?: string;\n\n constructor(options: CheckoutSessionOptions) {\n this.merchantId = options.merchantId;\n this.paymentId = options.paymentId;\n this.publishableKey = options.publishableKey;\n this.clientSecret = options.clientSecret;\n // Constructed WITHOUT a key: every call attaches its own credential\n // explicitly, so a bearer-authenticated route never carries an api-key\n // header and vice versa.\n this.client = new Delopay('', {\n baseUrl: options.baseUrl,\n sandbox: options.sandbox,\n timeout: options.timeout,\n maxRetries: options.maxRetries,\n debug: options.debug,\n logger: options.logger,\n });\n }\n\n private get linkBase(): string {\n return `/payment-link/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`;\n }\n\n /** Headers for the client-secret bearer routes (`/payment-link/*`). */\n private bearerHeaders(extra?: Record<string, string>): Record<string, string> {\n return {\n ...withoutCredentialHeaders(extra),\n Authorization: `Bearer ${this.requireClientSecret()}`,\n };\n }\n\n /** Headers for the publishable-key routes (`/payments/*`, `/payment-methods`). */\n private pkHeaders(extra?: Record<string, string>): Record<string, string> {\n if (!this.publishableKey) {\n throw new DelopayError('This call requires the publishable key', {\n status: 0,\n code: 'MISSING_CREDENTIAL',\n type: 'invalid_request',\n });\n }\n return { ...withoutCredentialHeaders(extra), 'api-key': this.publishableKey };\n }\n\n private requireClientSecret(): string {\n if (!this.clientSecret) {\n throw new DelopayError('This call requires the payment client secret', {\n status: 0,\n code: 'MISSING_CREDENTIAL',\n type: 'invalid_request',\n });\n }\n return this.clientSecret;\n }\n\n /**\n * The hosted checkout's bootstrap payload for a one-time payment —\n * `CheckoutDetails` while payable, a status view once settled.\n *\n * Deliberately unauthenticated: a `pay_` link bootstraps before any\n * credential exists, so no credential header is ever attached (caller\n * extras are still stripped of credentials). Core fields and the collection\n * policy are typed; provider-specific fields remain available as unknown.\n *\n * `theme` (a named checkout variant) and `country` are the route's declared\n * query parameters. `country` is a manual override of the buyer country the\n * router otherwise resolves from the client IP — it decides which payment\n * methods the layout shows — as an ISO 3166-1 alpha-2 code, sent uppercased\n * and omitted when empty. `locale` travels as `Accept-Language` — the only\n * channel the backend's locale resolution reads; a `?locale=` query is\n * silently ignored by this route.\n *\n * `cardOnly` is a direct link to the card form (`payment_method=card`):\n * when the Stripe card form being prepared is the one the link names, its\n * PaymentIntent is created for `card` alone. `cardProvider` and\n * `cardAccount` name that form's connector and account; absent or blank\n * matches any.\n *\n * `entry` opens one of the shop's checkout entries (`?entry=`): the layout\n * holds only that entry's methods and is drawn in its named look, and\n * `entry` on the answer says whether it had anything to offer.\n *\n * `GET /payment-link/data/{merchantId}/{paymentId}`\n */\n async fetchCheckoutData(\n params?: {\n locale?: string;\n theme?: string;\n country?: string;\n cardOnly?: boolean;\n cardProvider?: string;\n cardAccount?: string;\n entry?: string;\n },\n options?: RequestExtras,\n ): Promise<CheckoutDataResponse> {\n const country = params?.country?.trim().toUpperCase();\n return this.client.request(\n 'GET',\n `/payment-link/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n query: {\n theme: params?.theme,\n country: country || undefined,\n card_only: params?.cardOnly || undefined,\n card_provider: params?.cardOnly ? params.cardProvider?.trim() || undefined : undefined,\n card_account: params?.cardOnly ? params.cardAccount?.trim() || undefined : undefined,\n entry: params?.entry?.trim() || undefined,\n },\n ...options,\n headers: {\n ...(params?.locale\n ? {\n ...withoutHeader(withoutCredentialHeaders(options?.headers), 'accept-language'),\n 'Accept-Language': params.locale,\n }\n : withoutCredentialHeaders(options?.headers)),\n },\n },\n );\n }\n\n /**\n * The subscription twin of {@link CheckoutSession.fetchCheckoutData}: the\n * bootstrap payload for a `sub_` checkout. Authenticated with the\n * subscription's client secret (construct the session with the `sub_…` id\n * in the `paymentId` slot). `locale` travels as `Accept-Language`, same\n * as {@link CheckoutSession.fetchCheckoutData}.\n *\n * `GET /subscriptions/data/{merchantId}/{subscriptionId}`\n */\n async fetchSubscriptionData(\n params?: { locale?: string },\n options?: RequestExtras,\n ): Promise<SubscriptionCheckoutResponse> {\n return this.client.request(\n 'GET',\n `/subscriptions/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n ...options,\n headers: {\n ...(params?.locale\n ? {\n ...withoutHeader(this.bearerHeaders(options?.headers), 'accept-language'),\n 'Accept-Language': params.locale,\n }\n : this.bearerHeaders(options?.headers)),\n },\n },\n );\n }\n\n /**\n * Report buyer/device signals for rails that never reach\n * `/payments/{id}/confirm` (the Stripe SAQ-A rail: raw cards, Apple Pay,\n * Google Pay). Same telemetry contract as\n * {@link CheckoutSession.recordEvent}: sent with `keepalive: true`, and\n * failures resolve instead of rejecting — signals must never block or\n * break a checkout. Unauthenticated by design.\n *\n * `POST /payment-link/client-signals/{merchantId}/{paymentId}`\n */\n async reportClientSignals(\n params: {\n browser_info?: Record<string, unknown>;\n signals: Record<string, unknown>;\n },\n options?: RequestExtras,\n ): Promise<void> {\n try {\n await this.client.request(\n 'POST',\n `/payment-link/client-signals/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n body: params,\n keepalive: true,\n ...options,\n headers: withoutCredentialHeaders(options?.headers),\n },\n );\n } catch {\n // Telemetry: swallowing is the contract, not an oversight.\n }\n }\n\n /**\n * Store one slice of the buyer's checkout recording on our own side.\n * Called by the hosted checkout as the buyer works through the page; the\n * client secret is attached automatically.\n *\n * **Not telemetry semantics, on purpose.** Unlike\n * {@link CheckoutSession.recordEvent}, this rejects with a `DelopayError`\n * like every other payment call, because the recorder has to tell the\n * answers apart: a `400` with code `IR_16` means the backend will not take\n * this recording (recording is off on that deployment, the recording is\n * full, the payment is already recording a different session, or this\n * number is stored with different content) and the recorder must stop; any\n * other `400` is the slice itself being refused; a transport failure may be\n * retried with the **same** bytes under the **same** number, which the\n * backend answers with `duplicate: true`.\n *\n * Pass `keepalive: true` for the last slice of a page that is navigating\n * away (a redirect rail); browsers refuse keepalive bodies over ~64 KiB, so\n * only a small final slice should carry it.\n *\n * Pass `compress: true` to send the slice gzipped. Recorded page events\n * compress heavily, so this is mostly a saving on the buyer's connection. It\n * is opt-in and degrades silently: a runtime without `CompressionStream`\n * sends the same slice uncompressed rather than failing, so a caller never\n * has to feature-test before asking for it.\n *\n * ⚠️ `keepalive` overrides it. Compressing means awaiting a stream read\n * before the request is made, and `keepalive` protects a request only once\n * it has been initiated — so a page torn down mid-compression would drop the\n * final slice altogether. A slice sent with `keepalive` therefore always\n * travels uncompressed, whatever `compress` says. Passing both is allowed and\n * is what a recorder should do: every ordinary slice compresses, and the last\n * one is sent the way that actually arrives.\n *\n * For a precompressed event array, pass `compressed_events` and `gzipBody`.\n * The latter receives the complete JSON request (including the session's\n * client secret) and must return gzip bytes synchronously. Fetch then starts\n * before this method yields, including on a page-navigation slice. A\n * keepalive request is used only when that prepared body is at most 60 KiB.\n *\n * `POST /payments/{paymentId}/replay/slice` (publishable key)\n */\n async storeReplaySlice(\n params: ReplayIngestParams,\n options?: RequestExtras & {\n keepalive?: boolean;\n compress?: boolean;\n /** Gzip a prepared JSON envelope synchronously before the request starts. */\n gzipBody?: (body: Uint8Array) => Uint8Array;\n },\n ): Promise<ReplayIngestResponse> {\n const { keepalive, compress, gzipBody, ...extras } = options ?? {};\n // Built before anything can be compressed, so a missing credential still\n // rejects without a request going out.\n const body = { ...params, client_secret: this.requireClientSecret() };\n const headers = this.pkHeaders(extras.headers);\n // `keepalive` wins over `compress`, and that is a correctness rule rather\n // than a preference. `keepalive` preserves a request only once it has been\n // *initiated*; compressing first means awaiting a stream read, and a page\n // torn down during that await never reaches `fetch()` at all — the final\n // slice is then lost outright, which is the one thing `keepalive` exists to\n // prevent. Losing a slice to save bytes is the wrong trade, so the slice a\n // page is navigating away from travels uncompressed. It is also the\n // smallest one: browsers refuse keepalive bodies over ~64 KiB anyway.\n const encoded = gzipBody?.(new TextEncoder().encode(JSON.stringify(body)));\n const gzipped = encoded\n ? Uint8Array.from(encoded).buffer\n : compress === true && keepalive !== true\n ? await gzipJson(body)\n : null;\n return this.client.request(\n 'POST',\n `/payments/${encodeURIComponent(this.paymentId)}/replay/slice`,\n {\n body: gzipped ?? body,\n ...(keepalive !== undefined\n ? { keepalive: encoded ? keepalive && encoded.byteLength <= 60 * 1024 : keepalive }\n : {}),\n ...extras,\n // `Content-Type` has to be stated for the compressed body: the client\n // only sets it for a body it serialises itself, and the bytes are\n // still JSON — gzip is how they travel, not what they are.\n headers:\n gzipped === null\n ? headers\n : { ...headers, 'Content-Type': 'application/json', 'Content-Encoding': 'gzip' },\n },\n );\n }\n\n /**\n * The status a buyer coming back from the processor's checkout may read:\n * the subscription's status, and whether the processor has reported it yet\n * (`awaiting_processor`). Construct the session with the `sub_…` id in the\n * `paymentId` slot.\n *\n * Authenticated with the return token (`rt`) the return URL carried, sent as\n * `Authorization: Bearer <rt>`. That token reads only this, for a day; it is\n * never the client secret, which this call does not send.\n *\n * `GET /subscriptions/return-status/{merchantId}/{subscriptionId}`\n */\n async subscriptionReturnStatus(\n returnToken: string,\n options?: RequestExtras,\n ): Promise<SubscriptionReturnStatusResponse> {\n if (!returnToken) {\n throw new DelopayError('This call requires the return token (rt) from the return URL', {\n status: 0,\n code: 'MISSING_CREDENTIAL',\n type: 'invalid_request',\n });\n }\n return this.client.request(\n 'GET',\n `/subscriptions/return-status/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n ...options,\n headers: {\n ...withoutCredentialHeaders(options?.headers),\n Authorization: `Bearer ${returnToken}`,\n },\n },\n );\n }\n\n /**\n * The methods the buyer may pick for a subscription that waits for the\n * choice (`method_choice_pending`), judged for the buyer. Call it from the\n * buyer's browser: the sell-to country is read from this request's own\n * connection. A cancelled subscription answers 400, and one that already\n * bills on an account answers 409 (`DE_20`). Authenticated with the\n * subscription's client secret.\n *\n * `GET /subscriptions/method-options/{merchantId}/{subscriptionId}`\n */\n async subscriptionMethodOptions(\n options?: RequestExtras,\n ): Promise<SubscriptionMethodOptionsResponse> {\n return this.client.request(\n 'GET',\n `/subscriptions/method-options/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n },\n );\n }\n\n /**\n * Bind a waiting subscription to the method the buyer picked and open its\n * first cycle on that method's billing account. The methods are judged\n * again from this request; afterwards\n * {@link CheckoutSession.fetchSubscriptionData} describes the bound\n * subscription (Stripe's Payment Element for `card`, `confirmSubscription`\n * for the others). Picking the same method again answers the bound\n * subscription. A subscription bound to another method already, or whose\n * billing account changed meanwhile, answers 409 (`DE_20`); a method not\n * offered to this buyer, or a cancelled subscription, answers 400.\n * Authenticated with the subscription's client secret.\n *\n * `POST /subscriptions/select-method/{merchantId}/{subscriptionId}`\n */\n async selectSubscriptionMethod(\n method: SubscriptionCheckoutMethod,\n options?: RequestExtras,\n ): Promise<SubscriptionResponse> {\n const body: SelectSubscriptionMethodRequest = { method };\n return this.client.request(\n 'POST',\n `/subscriptions/select-method/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n body,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n },\n );\n }\n\n /**\n * Confirm a subscription (PayPal approval rail). The client secret is\n * attached automatically; the shop's profile id travels as the\n * `X-Profile-Id` header the subscription routes require.\n *\n * `POST /subscriptions/{subscriptionId}/confirm` (publishable key)\n */\n async confirmSubscription(\n subscriptionId: string,\n profileId: string,\n params: Omit<ConfirmSubscriptionRequest, 'client_secret'>,\n options?: RequestExtras,\n ): Promise<ConfirmSubscriptionResponse> {\n return this.client.request(\n 'POST',\n `/subscriptions/${encodeURIComponent(subscriptionId)}/confirm`,\n {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n // Strip any caller-supplied x-profile-id first (case-insensitively):\n // Fetch folds duplicate headers into `caller, pro_x`, and the\n // subscription routes must see exactly one profile scope.\n headers: {\n ...withoutHeader(this.pkHeaders(options?.headers), 'x-profile-id'),\n 'X-Profile-Id': profileId,\n },\n },\n );\n }\n\n /**\n * The e-Payouts rail catalog for the buyer's country, plus the set of\n * countries that have at least one vendor.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/epayouts/methods`\n *\n * Pass `{ paypalSdk: true }` from a checkout drawing an experimental PayPal\n * SDK pane to also receive e-Payouts' PayPal client id\n * (`paypal_client_id`, `paypal_currency`); it is present only when `ppal`\n * is among the methods.\n *\n * @param country - Lowercase ISO 3166-1 alpha-2 country code.\n */\n async epayoutsMethods(\n country: string,\n options?: RequestExtras & EpayoutsMethodsOptions,\n ): Promise<EpayoutsMethodsResponse> {\n const { paypalSdk, merchantConnectorId, ...extras } = options ?? {};\n return this.client.request('GET', `${this.linkBase}/epayouts/methods`, {\n query: paypalSdk\n ? {\n cc: country,\n paypal_sdk: 'true',\n ...(merchantConnectorId ? { merchant_connector_id: merchantConnectorId } : {}),\n }\n : { cc: country },\n ...extras,\n headers: this.bearerHeaders(extras.headers),\n });\n }\n\n /**\n * The PayPal order e-Payouts created for the payment, for the PayPal SDK's\n * `createOrder` on the PayPal Express or Pay with card pane, after the payment\n * was confirmed through that pane. Return `order_id` from `createOrder` and\n * send the buyer to `approve_url` once PayPal approved it; without an order,\n * or when PayPal's button cannot be drawn, send the buyer to `redirect_url`.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/epayouts/paypal-order`\n */\n async epayoutsPaypalOrder(options?: RequestExtras): Promise<EpayoutsPaypalOrderResponse> {\n return this.client.request('POST', `${this.linkBase}/epayouts/paypal-order`, {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Report PayPal's refusal of the card or the payer on the PayPal Express or\n * Pay with card pane (for example `INSTRUMENT_DECLINED`, `PAYER_CANNOT_PAY`,\n * or `AUTHENTICATION_FAILED` for a failed 3-D Secure). The attempt is\n * recorded declined and the payment stays payable with another card or\n * method. An issue that is not a refusal, or a payment that no longer awaits\n * PayPal, is left as it is (`declined: false`). Nothing here captures: the\n * payment settles from e-Payouts' notification.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/epayouts/paypal-decline`\n */\n async epayoutsPaypalDecline(\n params: EpayoutsPaypalDeclineRequest,\n options?: RequestExtras,\n ): Promise<EpayoutsPaypalDeclineResponse> {\n return this.client.request('POST', `${this.linkBase}/epayouts/paypal-decline`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Record a buyer-side checkout event on the payment's status timeline.\n *\n * Telemetry semantics, built in so callers can genuinely fire-and-forget:\n * the request is sent with `keepalive: true` (it survives the document\n * navigating away, e.g. right before a `window.open`), and transport or\n * server failures resolve to `undefined` instead of rejecting — telemetry\n * must never break a checkout or surface an unhandled rejection. Do not\n * `await` this in a click handler that must stay synchronous.\n *\n * A missing client secret still throws `MISSING_CREDENTIAL`: that is a\n * wiring bug, not a telemetry failure.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/checkout-events`\n */\n async recordEvent(\n params: RecordCheckoutEventRequest,\n options?: RequestExtras,\n ): Promise<RecordCheckoutEventResponse | undefined> {\n const headers = this.bearerHeaders(options?.headers);\n try {\n return await this.client.request('POST', `${this.linkBase}/checkout-events`, {\n body: params,\n keepalive: true,\n ...options,\n headers,\n });\n } catch {\n return undefined;\n }\n }\n\n /** Create a new Apple merchant-validation session for a payable Mollie checkout.\n * Requires a live Mollie validation key even for a test payment; never charges.\n * Browser Origin must match the configured checkout domain.\n */\n async mollieApplePaySession(\n params: MollieApplePaySessionRequest,\n options?: RequestExtras,\n ): Promise<MollieApplePaySessionResponse> {\n return this.client.request('POST', `${this.linkBase}/mollie/apple-pay-session`, {\n ...options,\n body: params,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Prepare MicroPayment transfer instructions or an unsigned SEPA mandate.\n * No debit is approved. Show the returned mandate disclosure before collecting\n * acceptance, then confirm with metadata.micropayment_preparation and, for\n * new SEPA mandates, explicit customer_acceptance. Every SEPA confirm must\n * acknowledge its amount/date notice with metadata.micropayment_prenotified.\n * Echo native_pane_merchant_connector_id and the returned\n * native_pane_quote_generation on confirm. Saved reuse sends\n * recurring_details: { type: 'payment_method_id', data: payment_method_id }\n * with payment_method: 'bank_debit', payment_method_type: 'sepa' and no raw\n * bank data. Only saved off-session preparation may omit quote_generation.\n * Transfer instructions become available only after canonical confirmation.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/micropayment/bank-session`\n */\n async micropaymentBankSession(\n params: MicropaymentBankSessionRequest,\n options?: RequestExtras,\n ): Promise<MicropaymentBankSessionResponse> {\n return this.client.request('POST', `${this.linkBase}/micropayment/bank-session`, {\n ...options,\n body: params,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * A short-lived VGS Collect session for browser-side card capture.\n *\n * **Exactly one refusal means \"this shop has no vault\": a 400 carrying\n * `IR_19`.** Every other refusal means a vault exists and could not be used,\n * and answering it by falling back to the processor's own card pane sends an\n * unprotected card number to the very processor the shop pays to hide it\n * from — the bug this endpoint's error contract exists to prevent.\n *\n * A **404 is not benign.** The router answers it when the shop's vault\n * account cannot be found — the state a shop is left in when its vault\n * connector is deleted while the profile keeps naming the id: it still\n * reports the vault as enabled and still expects its cards cloaked. The same\n * status also covers a payment that does not exist.\n *\n * `params.appearance` asks for a form styled to match the page (Enigma\n * Vault). The answer then carries `height`, the frame height to use. If the\n * vault refuses the styled form the answer is the plain one, without\n * `height`. `params.locale` is the buyer's locale.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`\n */\n async vaultCollectSession(\n options?: RequestExtras,\n params?: VaultCollectSessionParams,\n ): Promise<VaultCollectSessionResponse> {\n return this.client.request('GET', `${this.linkBase}/vault/collect-session`, {\n ...options,\n query: vaultFormQuery(params),\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * The saved cards the buyer of this payment can pay with, on a shop whose\n * vault keeps the security code itself (Enigma Vault): the cards of the\n * payment's own customer that the shop's vault holds, most recently used\n * first. A payment without a customer answers an empty list.\n *\n * Draw saved cards from this list, not from the customer's payment-method\n * list: that one also carries cards the security-code form cannot open.\n * To pay with one, mint its form with {@link vaultSecurityCodeSession},\n * and confirm with its `payment_token` once the form reports the code\n * stored.\n *\n * A shop without a vault, and a VGS shop, answer `400`.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/vault/saved-cards`\n */\n async vaultSavedCards(options?: RequestExtras): Promise<VaultSavedCardsResponse> {\n return this.client.request('GET', `${this.linkBase}/vault/saved-cards`, {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Remove one of the buyer's saved cards, named by its `payment_token` from\n * {@link vaultSavedCards}: from the customer's saved cards and from the\n * shop's vault, with every saved copy of the same card. Only a card of the\n * payment's own customer that the shop's vault holds can be removed, and\n * only within the payment's session.\n *\n * Refusals throw a `DelopayError`:\n *\n * - `400` with code `IR_16` and `data.reason` set to a\n * {@link VaultSavedCardRemovalRefusal}: the card stays listed.\n * `saved_card_in_use` means a subscription or agreement still charges it,\n * `saved_card_payment_in_progress` a payment with it is in flight, and\n * `saved_card_removal_unavailable` that the shop cannot remove cards here.\n * - `404`: the card is not one this buyer can remove, for example because it\n * is already gone.\n * - `422` with code `IR_29`: the token is no longer held. Read\n * {@link vaultSavedCards} again and remove the card by its new token.\n *\n * `DELETE /payment-link/{merchantId}/{paymentId}/vault/saved-cards/{paymentToken}`\n */\n async vaultRemoveSavedCard(paymentToken: string, options?: RequestExtras): Promise<void> {\n await this.client.request(\n 'DELETE',\n `${this.linkBase}/vault/saved-cards/${encodeURIComponent(paymentToken)}`,\n {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n },\n );\n }\n\n /**\n * Mint the security-code form for a saved card, on a shop whose vault keeps\n * the code itself (Enigma Vault). The buyer re-enters the code into the\n * vault's own form, so it never reaches the checkout; confirm with the saved\n * card's `payment_token` once the form reports it stored.\n *\n * `paymentToken` is the saved card's token from {@link vaultSavedCards}. A\n * VGS shop answers `400`: VGS re-collects the code with Collect.\n *\n * `params.appearance` asks for a form styled to match the page, as on\n * {@link vaultCollectSession}. The styled form is the security-code field\n * alone, with no label: draw the label beside the frame, and size the frame\n * to the answer's `height`. `labels` is ignored. If the vault refuses the\n * styled form the answer is the plain one, without `height`.\n *\n * The form stores one code and then disables itself. After a failed\n * payment, mint a new form before the buyer tries again.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/vault/security-code-session`\n */\n async vaultSecurityCodeSession(\n paymentToken: string,\n options?: RequestExtras,\n params?: VaultCollectSessionParams,\n ): Promise<EnigmaFormSession> {\n return this.client.request('GET', `${this.linkBase}/vault/security-code-session`, {\n ...options,\n query: { payment_token: paymentToken, ...vaultFormQuery(params) },\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Register the aliased card as a payment method and mint the one-shot\n * `payment_token` the confirm call spends.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/vault/payment-method`\n */\n async registerVaultPaymentMethod(\n params: VaultPaymentMethodRequest,\n options?: RequestExtras,\n ): Promise<VaultPaymentMethodResponse> {\n return this.client.request('POST', `${this.linkBase}/vault/payment-method`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Reserve this payment attempt before a hosted card form contacts Stripe,\n * Airwallex, or NomuPay. Send the provider object rendered to this checkout\n * and retain the same `flow_id` across retries and any 3-D Secure step.\n *\n * Only `authorized: true` permits the form to contact its processor. A\n * competing flow receives `false` and must reload; an unresolved provider\n * outcome stays reserved, regardless of elapsed time. A buyer-blocklist\n * refusal throws a `DelopayError` with code `DE_14`; a shop whose payments\n * DeloPay stopped is refused with `DE_22`, and a shop whose payments the\n * merchant switched off with `DE_21`.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/browser-card-claim`\n */\n async claimBrowserCard(\n params: BrowserCardClaimRequest,\n options?: RequestExtras,\n ): Promise<BrowserCardClaimResponse> {\n return this.client.request('POST', `${this.linkBase}/browser-card-claim`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Confirm the Stripe card form's PaymentIntent through the router, for a\n * checkout payload with `card_connector_server_confirm: true`. Stripe refuses\n * a Stripe.js confirm of such an intent.\n *\n * Send the PaymentMethod `stripe.createPaymentMethod` produced from the\n * Payment Element (or Express Checkout Element), which needs\n * `paymentMethodCreation: 'manual'` on the Elements instance. A\n * ConfirmationToken is refused with `400`: Stripe will not confirm such an\n * intent with one.\n *\n * The router judges the card's issuing country and the buyer's IP country\n * against the shop's sell-to restrictions before Stripe authorises, and a\n * refusal throws a `DelopayError` with code `DE_10`. A buyer on the\n * merchant's buyer blocklist is refused before any Stripe call with code\n * `DE_14` (`buyer_blocked`, 422), which names no entry, a shop whose\n * payments DeloPay stopped with `DE_22`, and a shop whose payments the\n * merchant switched off with `DE_21`. A buyer the merchant's buyer risk\n * model refuses fails with `DE_23` (`buyer_risk_refused`, 422), which says\n * nothing about the signals. When the answer's\n * `status` is `requires_action`, run `stripe.handleNextAction` with its\n * `client_secret` — safe, because the intent is `confirmation_method=manual`\n * and that secret confirms nothing without the secret key — then call this\n * again without a payment method to finalize.\n *\n * Reserve the attempt with {@link claimBrowserCard} first. Send its granted\n * `flow_id` as `browser_flow_id` on both the initial and post-action confirm;\n * an omitted, null or nonholder flow is refused with `400` and code `IR_16`.\n *\n * A PaymentMethod rules out what `stripe.createPaymentMethod` cannot\n * produce: Stripe names Amazon Pay and Klarna in the Express Checkout\n * Element, which need `stripe.createConfirmationToken` instead. Neither can\n * be paid through this route, so a caller must not offer them on a\n * server-confirmed intent — mount the Express Checkout Element with those\n * methods `'never'`, as DeloPay's own checkout does. The router drops only\n * the methods its server-side confirm cannot finish at all (BLIK and ACSS\n * pre-authorized debits) from the card form's mount, so the rest of the\n * selection still reaches the element and is the caller's to constrain.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/stripe-confirm`\n */\n async confirmStripeCardForm(\n params: StripeHostedConfirmRequest,\n options?: RequestExtras,\n ): Promise<StripeHostedConfirmResponse> {\n return this.client.request('POST', `${this.linkBase}/stripe-confirm`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Make the buyer's add-on choice while the checkout data answers\n * `type: 'addon_choice'`.\n *\n * Only price ids and quantities are sent; the router prices them from the\n * catalog and judges every selection group's bounds. The payment's lines and\n * amount change together, once: the choice is final afterwards, the same\n * choice sent again answers the same result, and another is refused with\n * `IR_16` — as is a choice once anything could have been charged at the\n * previous amount. Fetch the checkout data again afterwards for the payment\n * methods at the final amount.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/addons`\n */\n async chooseAddons(\n params: CheckoutAddonChoiceRequest,\n options?: RequestExtras,\n ): Promise<CheckoutAddonChoiceResponse> {\n return this.client.request('POST', `${this.linkBase}/addons`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Send the buyer's tax country, region and VAT ID while the checkout data's\n * `tax.step` is `open`, and get the VAT the payment carries for them.\n *\n * `close: false` recalculates and keeps the step open, for a live total\n * while the buyer types; it also opens a confirmed step again while nothing\n * was prepared at a provider. `close: true` recalculates and confirms: the\n * payment is charged what the answer says, and the checkout data, fetched\n * again, answers the payment methods with `tax.step` `closed`. A confirmed\n * step answers the same closing request again. A change once something was\n * prepared at a provider is refused with `DE_28` (409), as is one while the\n * add-on choice is open or after the checkout expired. A malformed country\n * or region is refused with `IR_06` (400).\n *\n * `POST /payment-link/{merchantId}/{paymentId}/tax`\n */\n async submitTax(params: CheckoutTaxRequest, options?: RequestExtras): Promise<CheckoutTax> {\n return this.client.request('POST', `${this.linkBase}/tax`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * The payment's identity verification step: whether the payment asked for\n * one, its outcome, and the provider's page while it is pending. A pending\n * verification is read from the provider first, so call this when the buyer\n * comes back from the provider's page.\n *\n * `required` is `false` when the payment asked for no verification.\n * `can_retry` is `true` after an expired or abandoned attempt; start a new\n * one with {@link CheckoutSession.startIdentityVerification}.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/identity-verification`\n */\n async identityVerification(\n options?: RequestExtras,\n ): Promise<CheckoutIdentityVerificationResponse> {\n return this.client.request('GET', `${this.linkBase}/identity-verification`, {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Resume the payment's pending identity verification, start it, or start a\n * new attempt after an expired or abandoned one. For legacy single-step\n * verifications, send the buyer to the returned top-level\n * `verification_url`. When starting or resuming a specific `step_index` in\n * a multi-step flow, locate the matching entry in `response.steps` by\n * `step_index` and redirect to its `verification_url` (top-level\n * `verification_url` summarizes the first unverified step, not necessarily\n * the requested index). The provider sends the buyer back to `return_url`,\n * which must be on the payment's checkout origin.\n *\n * Refusals throw a `DelopayError`: `400` when the return URL is not on the\n * payment's checkout or the verification is already decided, `404` when the\n * payment asked for no verification.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/identity-verification`\n */\n async startIdentityVerification(\n params: CheckoutIdentityVerificationStartRequest,\n options?: RequestExtras,\n ): Promise<CheckoutIdentityVerificationResponse> {\n return this.client.request('POST', `${this.linkBase}/identity-verification`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Mail the buyer a code that confirms their email, so the payment can reuse\n * a verification the merchant already has for them. Offer it only while the\n * checkout data says `identity_verification_reuse_allowed`. The answer is\n * the same whether or not the merchant verified anyone with the address.\n *\n * Refusals throw a `DelopayError`: `400` with code `DE_26` and the reason as\n * its message (`IV_REUSE_OFF` when the payment's requirement does not allow\n * reuse, `IV_REUSE_STEP` when the payment has no verification step a reuse\n * can stand for, `IV_EMAIL_INVALID`), `429` after too many codes for the\n * caller or the address.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/identity-verification/email-code`\n */\n async sendIdentityEmailCode(\n params: CheckoutIdentityEmailCodeRequest,\n options?: RequestExtras,\n ): Promise<CheckoutIdentityEmailCodeResponse> {\n return this.client.request('POST', `${this.linkBase}/identity-verification/email-code`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Check the code the buyer entered. `reusable` says only whether the\n * merchant has a verification the payment can reuse; then call\n * {@link CheckoutSession.reuseIdentityVerification}. Otherwise pass the\n * `challenge_id` as `email_challenge_id` to\n * {@link CheckoutSession.startIdentityVerification}, so a later payment can\n * reuse the verification it starts.\n *\n * Refusals throw a `DelopayError`: `400` with code `DE_26` and the reason as\n * its message. `IV_CODE_INCORRECT` is a wrong code, with the tries left in\n * `data.attempts_left`; `IV_CODE_EXPIRED` is an expired code or one out of\n * tries; `IV_CHALLENGE_UNKNOWN` names no code of this payment.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/identity-verification/email-code/verify`\n */\n async verifyIdentityEmailCode(\n params: CheckoutIdentityEmailVerifyRequest,\n options?: RequestExtras,\n ): Promise<CheckoutIdentityEmailVerifyResponse> {\n return this.client.request('POST', `${this.linkBase}/identity-verification/email-code/verify`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Reuse the merchant's verification for the buyer's confirmed email as the\n * payment's verification. Needs the challenge confirmed on this payment in\n * the last 30 minutes, and uses it up. No provider session, provider cost or\n * DeloPay fee is made. Answers the payment's verification step, verified.\n *\n * Refusals throw a `DelopayError`: `400` with code `DE_26` and the reason as\n * its message (`IV_CHALLENGE_NOT_CONFIRMED`, `IV_REUSE_NOT_ELIGIBLE`,\n * `IV_REUSE_OFF`, `IV_REUSE_STEP`).\n *\n * `POST /payment-link/{merchantId}/{paymentId}/identity-verification/reuse`\n */\n async reuseIdentityVerification(\n params: CheckoutIdentityReuseRequest,\n options?: RequestExtras,\n ): Promise<CheckoutIdentityVerificationResponse> {\n return this.client.request('POST', `${this.linkBase}/identity-verification/reuse`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Start the device assessment of the payment's checkout. `required` is\n * `false` when the shop assesses no devices, the payment's device is already\n * assessed, or the provider cannot start a session: go on without it. Run\n * the named `library` with the `token`, then call\n * {@link CheckoutSession.completeDeviceSession}.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/device-session`\n */\n async startDeviceSession(options?: RequestExtras): Promise<CheckoutDeviceSessionResponse> {\n return this.client.request('POST', `${this.linkBase}/device-session`, {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Report the device assessment finished. The router records it with the\n * provider and stores the signal on the payment. Refused with `400` when the\n * session and token are not the payment's pending ones.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/device-session/complete`\n */\n async completeDeviceSession(\n params: CheckoutDeviceSessionCompleteRequest,\n options?: RequestExtras,\n ): Promise<void> {\n await this.client.request('POST', `${this.linkBase}/device-session/complete`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Ask whether NomuPay's COPYandPAY widget may submit a card, from the\n * form's pre-submit hook.\n *\n * Only for a checkout stamped `NomupayOppwaCheckoutData.submit_grant`: the\n * card form sits beside always-shown wallet buttons of another account, and\n * this answer closes those buttons before it allows the card. `authorized`\n * is `false` when the payment no longer waits for a payment method, or when\n * this is not the attempt's live card-form checkout; when a wallet beside it\n * is already being paid, the route answers an error instead. Submit the\n * widget only on `true`.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/nomupay-card-authorization`\n */\n async nomupayCardAuthorization(\n params: NomupayCardAuthorizationRequest,\n options?: RequestExtras,\n ): Promise<NomupayCardAuthorizationResponse> {\n return this.client.request('POST', `${this.linkBase}/nomupay-card-authorization`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * The payment's current state — status polling for redirect/popup rails.\n *\n * `GET /payments/{paymentId}` (publishable key + client secret)\n */\n async retrievePayment(options?: RequestExtras): Promise<PaymentResponse> {\n return this.client.request('GET', `/payments/${encodeURIComponent(this.paymentId)}`, {\n query: { client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Update the payment before confirmation (e.g. persist custom-field\n * answers as `metadata` on rails that never hit `/confirm`). The client\n * secret is attached automatically.\n *\n * `POST /payments/{paymentId}` (publishable key)\n */\n async updatePayment(\n params: PaymentUpdateRequest,\n options?: RequestExtras,\n ): Promise<PaymentResponse> {\n return this.client.request('POST', `/payments/${encodeURIComponent(this.paymentId)}`, {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Confirm the payment. The client secret is attached automatically; pass\n * an `Idempotency-Key` header via `options` to make retries safe.\n *\n * `POST /payments/{paymentId}/confirm` (publishable key)\n */\n async confirmPayment(\n params: PaymentConfirmRequest,\n options?: RequestExtras,\n ): Promise<PaymentResponse> {\n return this.client.request('POST', `/payments/${encodeURIComponent(this.paymentId)}/confirm`, {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Mint the processor-side session a browser SDK completes — the PayPal\n * order that PayPal's buttons or Card Fields attach the buyer's choice to.\n * The client secret is attached automatically.\n *\n * For PayPal Card Fields pass `payment_method: 'card'` and the\n * `merchant_connector_id` the checkout was rendered with; the order id comes\n * back in `next_action.next_action_data.order_id` and is what the SDK's\n * `createOrder` returns. The confirm that captures it sends the same order\n * and account as `payment_method_data.card_reference`.\n *\n * Send a distinct `Idempotency-Key` through `options.headers` for each new\n * card submission; reuse it only to retry that same session request. The\n * returned order is bound to this attempt and account. Sessions cannot\n * replace an order while authentication or money processing is unresolved,\n * or after authorization/capture; stale or foreign references are refused.\n *\n * `POST /payments/{paymentId}/post-session-tokens` (publishable key)\n */\n async postSessionTokens(\n params: PaymentsPostSessionTokensRequest,\n options?: RequestExtras,\n ): Promise<PaymentsPostSessionTokensResponse> {\n return this.client.request(\n 'POST',\n `/payments/${encodeURIComponent(this.paymentId)}/post-session-tokens`,\n {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n },\n );\n }\n\n /**\n * Abandon the attempt the buyer left open on a connector's hosted page\n * (the payment sits in `requires_customer_action`) and open a fresh attempt\n * awaiting a payment method, so the same payment can be confirmed again\n * with another method or connector. Nothing has been authorised on the\n * abandoned attempt; it is voided locally and kept in the attempt history.\n * Idempotent: a payment already in `requires_payment_method` comes back\n * unchanged with `abandoned_attempt_id: null`.\n *\n * `POST /payments/{paymentId}/abandon-attempt` (publishable key + client secret)\n */\n async abandonAttempt(options?: RequestExtras): Promise<PaymentAbandonAttemptResponse> {\n return this.client.request(\n 'POST',\n `/payments/${encodeURIComponent(this.paymentId)}/abandon-attempt`,\n {\n body: { client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n },\n );\n }\n\n /**\n * Reopen a provider session the buyer switched away from, when they pick the\n * same method again, instead of opening a second session at the provider\n *. Pass an `attempt_id` from the checkout's\n * `reopenable_attempts`; the attempt becomes the payment's active one again\n * and `redirect_url` sends the buyer back to it. Refused (`IR_16`) when the\n * payment no longer awaits a method, a payment is under way on the checkout,\n * or the session can no longer be reopened (settled, lapsed at the provider,\n * ended by the switch); open a new session as usual then.\n *\n * `POST /payments/{paymentId}/reopen-attempt` (publishable key + client secret)\n */\n async reopenAttempt(\n attemptId: string,\n options?: RequestExtras,\n ): Promise<PaymentReopenAttemptResponse> {\n return this.client.request(\n 'POST',\n `/payments/${encodeURIComponent(this.paymentId)}/reopen-attempt`,\n {\n body: { client_secret: this.requireClientSecret(), attempt_id: attemptId },\n ...options,\n headers: this.pkHeaders(options?.headers),\n },\n );\n }\n\n /**\n * Payment methods available for this payment.\n *\n * `GET /payment-methods` (publishable key + client secret)\n *\n * @param params - Optional filters; `country` is the highest-precedence\n * geo hint, ahead of billing address and IP geolocation.\n */\n async listPaymentMethods(\n params?: { country?: string },\n options?: RequestExtras,\n ): Promise<PaymentMethodListResponse> {\n return this.client.request('GET', '/payment-methods', {\n query: { client_secret: this.requireClientSecret(), country: params?.country },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * This payment's checkout buttons, as the hosted checkout draws them: order,\n * labels, artwork, and what selecting each one does. The shop, environment,\n * currency and amount are the payment's. Ask again when the cart changes;\n * an answer is never reused for another payment.\n *\n * `GET /account/payment-methods/presentation` (publishable key + client secret)\n *\n * @param params - `country` outranks the billing address and IP\n * geolocation; `locale` names the language of the labels.\n */\n async paymentMethodPresentation(\n params?: { country?: string; locale?: string; contract_version?: number },\n options?: RequestExtras,\n ): Promise<PaymentMethodPresentationResponse> {\n return this.client.request('GET', '/account/payment-methods/presentation', {\n query: {\n client_secret: this.requireClientSecret(),\n country: params?.country,\n locale: params?.locale,\n contract_version: params?.contract_version,\n },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/tmp/publish-sdk-04990/dist/chunk-IKXGA2Z5.cjs","../src/resources/featureMatrix.ts"],"names":[],"mappings":"AAAA;ACOO,IAAM,cAAA,EAAN,MAAoB;AAAA,EACzB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA,EAGlD,MAAM,QAAA,CAAA,EAA2C;AAC/C,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,iBAAiB,CAAA;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,mBAAA,CAAoB,UAAA,EAAoD;AAC5E,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA,gBAAA,EAAmB,kBAAA,CAAmB,UAAU,CAAC,CAAA,CAAA;AAC9E,EAAA;AACF;ADLiF;AACA;AACA;AACA","file":"/tmp/publish-sdk-04990/dist/chunk-IKXGA2Z5.cjs","sourcesContent":[null,"import type { FeatureMatrixResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * What each connector can do: payment methods, capture methods, webhook\n * flows, and whether an unverified webhook is acted on.\n */\nexport class FeatureMatrix {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve the feature matrix. `GET /feature-matrix` */\n async retrieve(): Promise<FeatureMatrixResponse> {\n return this.request('GET', '/feature-matrix');\n }\n\n /**\n * Retrieve the feature matrix scoped to a merchant. Beta connectors\n * are filtered against the merchant's allowlist so the dashboard only\n * surfaces connectors the merchant can actually attach.\n * `GET /feature-matrix/{merchantId}`\n */\n async retrieveForMerchant(merchantId: string): Promise<FeatureMatrixResponse> {\n return this.request('GET', `/feature-matrix/${encodeURIComponent(merchantId)}`);\n }\n}\n"]}
1
+ {"version":3,"sources":["/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-IKXGA2Z5.cjs","../src/resources/featureMatrix.ts"],"names":[],"mappings":"AAAA;ACOO,IAAM,cAAA,EAAN,MAAoB;AAAA,EACzB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA,EAGlD,MAAM,QAAA,CAAA,EAA2C;AAC/C,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,iBAAiB,CAAA;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,mBAAA,CAAoB,UAAA,EAAoD;AAC5E,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA,gBAAA,EAAmB,kBAAA,CAAmB,UAAU,CAAC,CAAA,CAAA;AAC9E,EAAA;AACF;ADLiF;AACA;AACA;AACA","file":"/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-IKXGA2Z5.cjs","sourcesContent":[null,"import type { FeatureMatrixResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * What each connector can do: payment methods, capture methods, webhook\n * flows, and whether an unverified webhook is acted on.\n */\nexport class FeatureMatrix {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve the feature matrix. `GET /feature-matrix` */\n async retrieve(): Promise<FeatureMatrixResponse> {\n return this.request('GET', '/feature-matrix');\n }\n\n /**\n * Retrieve the feature matrix scoped to a merchant. Beta connectors\n * are filtered against the merchant's allowlist so the dashboard only\n * surfaces connectors the merchant can actually attach.\n * `GET /feature-matrix/{merchantId}`\n */\n async retrieveForMerchant(merchantId: string): Promise<FeatureMatrixResponse> {\n return this.request('GET', `/feature-matrix/${encodeURIComponent(merchantId)}`);\n }\n}\n"]}
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-OMGDHJYX.js";
10
10
  import {
11
11
  Shopify
12
- } from "./chunk-OEREK6NU.js";
12
+ } from "./chunk-TDCB2FQI.js";
13
13
  import {
14
14
  Shops
15
15
  } from "./chunk-MTFLXMYI.js";
@@ -18,7 +18,7 @@ import {
18
18
  } from "./chunk-JAJOUFPM.js";
19
19
  import {
20
20
  Subscriptions
21
- } from "./chunk-DDXERBGG.js";
21
+ } from "./chunk-W7KJTMAF.js";
22
22
  import {
23
23
  Support
24
24
  } from "./chunk-WZK3BIHG.js";
@@ -177,7 +177,7 @@ import {
177
177
  } from "./chunk-R4TZEQ33.js";
178
178
  import {
179
179
  BuyerPortal
180
- } from "./chunk-I5KOMBQ3.js";
180
+ } from "./chunk-2OJJ3KGP.js";
181
181
  import {
182
182
  Cards
183
183
  } from "./chunk-55XO7BFC.js";
@@ -337,4 +337,4 @@ Delopay.webhooks = Webhooks;
337
337
  export {
338
338
  Delopay
339
339
  };
340
- //# sourceMappingURL=chunk-7H2VFIPS.js.map
340
+ //# sourceMappingURL=chunk-IPN7D5PP.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/tmp/publish-sdk-04990/dist/chunk-IR2LFKKA.cjs","../src/internal/resources/admin.ts"],"names":[],"mappings":"AAAA;ACaO,IAAM,MAAA,EAAN,MAAY;AAAA,EACjB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA,EAElD,MAAM,MAAA,CAAO,MAAA,EAAmD;AAC9D,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,eAAA,EAAiB,EAAE,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EAC/D;AAAA,EAEA,MAAM,kBAAA,CAAmB,MAAA,EAA+D;AACtF,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,wBAAA,EAA0B,EAAE,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EACxE;AAAA,EAEA,MAAM,YAAA,CAAa,MAAA,EAA6D;AAC9E,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,sBAAA,EAAwB,EAAE,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,oBAAA,CAAqB,MAAA,EAAiE;AAC1F,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,gCAAA,EAAkC,EAAE,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EAChF;AAAA;AAAA,EAGA,MAAM,iBAAA,CAAkB,MAAA,EAA4D;AAClF,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,wBAAA,EAA0B,EAAE,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,iBAAA,CAAA,EAAmD;AACvD,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,wBAAwB,CAAA;AAAA,EACrD;AAAA;AAAA,EAGA,MAAM,eAAA,CAAgB,MAAA,EAAkE;AACtF,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,yBAAA,EAA2B,EAAE,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EACzE;AACF,CAAA;ADhBA;AACA;AACE;AACF,sBAAC","file":"/tmp/publish-sdk-04990/dist/chunk-IR2LFKKA.cjs","sourcesContent":[null,"import type { AuthResponse, SignUpWithMerchantIdRequest } from '../../types';\nimport type {\n AdminSignInRequest,\n AuthorizeResponse,\n CreateInternalUserRequest,\n CreateTenantUserRequest,\n OnboardMerchantRequest,\n OnboardMerchantResponse,\n SignupToggleRequest,\n SignupToggleResponse,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class Admin {\n constructor(private readonly request: RequestFn) {}\n\n async signIn(params: AdminSignInRequest): Promise<AuthResponse> {\n return this.request('POST', '/admin/signin', { body: params });\n }\n\n async createInternalUser(params: CreateInternalUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/internal-signup', { body: params });\n }\n\n async createTenant(params: CreateTenantUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/tenant-signup', { body: params });\n }\n\n /**\n * Create a new merchant admin user and merchant account atomically.\n *\n * This is the correct endpoint for bootstrapping the first admin user in a\n * fresh deployment — `internal-signup`/`tenant-signup` both require\n * pre-existing merchant records that don't exist on a clean database.\n *\n * `POST /admin/signup-with-merchant-id`\n */\n async signupWithMerchantId(params: SignUpWithMerchantIdRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/signup-with-merchant-id', { body: params });\n }\n\n /** Toggle public signup on/off. `POST /admin/settings/signup` */\n async setSignupSettings(params: SignupToggleRequest): Promise<SignupToggleResponse> {\n return this.request('POST', '/admin/settings/signup', { body: params });\n }\n\n /** Read current public-signup status. `GET /admin/settings/signup` */\n async getSignupSettings(): Promise<SignupToggleResponse> {\n return this.request('GET', '/admin/settings/signup');\n }\n\n /** Full merchant bootstrap — user + merchant + project + profile + keys. `POST /admin/onboard-merchant` */\n async onboardMerchant(params: OnboardMerchantRequest): Promise<OnboardMerchantResponse> {\n return this.request('POST', '/admin/onboard-merchant', { body: params });\n }\n}\n"]}
1
+ {"version":3,"sources":["/tmp/w3-sdk-publish-0501/delopay-typescript-sdk/dist/chunk-IR2LFKKA.cjs","../src/internal/resources/admin.ts"],"names":[],"mappings":"AAAA;ACaO,IAAM,MAAA,EAAN,MAAY;AAAA,EACjB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA,EAElD,MAAM,MAAA,CAAO,MAAA,EAAmD;AAC9D,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,eAAA,EAAiB,E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SignInRequest,\n AuthorizeResponse,\n CreateInternalUserRequest,\n CreateTenantUserRequest,\n OnboardMerchantRequest,\n OnboardMerchantResponse,\n SignupToggleRequest,\n SignupToggleResponse,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class Admin {\n constructor(private readonly request: RequestFn) {}\n\n async signIn(params: AdminSignInRequest): Promise<AuthResponse> {\n return this.request('POST', '/admin/signin', { body: params });\n }\n\n async createInternalUser(params: CreateInternalUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/internal-signup', { body: params });\n }\n\n async createTenant(params: CreateTenantUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/tenant-signup', { body: params });\n }\n\n /**\n * Create a new merchant admin user and merchant account atomically.\n *\n * This is the correct endpoint for bootstrapping the first admin user in a\n * fresh deployment — `internal-signup`/`tenant-signup` both require\n * pre-existing merchant records that don't exist on a clean database.\n *\n * `POST /admin/signup-with-merchant-id`\n */\n async signupWithMerchantId(params: SignUpWithMerchantIdRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/signup-with-merchant-id', { body: params });\n }\n\n /** Toggle public signup on/off. `POST /admin/settings/signup` */\n async setSignupSettings(params: SignupToggleRequest): Promise<SignupToggleResponse> {\n return this.request('POST', '/admin/settings/signup', { body: params });\n }\n\n /** Read current public-signup status. `GET /admin/settings/signup` */\n async getSignupSettings(): Promise<SignupToggleResponse> {\n return this.request('GET', '/admin/settings/signup');\n }\n\n /** Full merchant bootstrap — user + merchant + project + profile + keys. `POST /admin/onboard-merchant` */\n async onboardMerchant(params: OnboardMerchantRequest): Promise<OnboardMerchantResponse> {\n return this.request('POST', '/admin/onboard-merchant', { body: params });\n }\n}\n"]}