@takeal/cusfront-sdk 0.3.18 → 0.5.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 (121) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/README.md +430 -9
  3. package/dist/analytics.cjs +417 -0
  4. package/dist/analytics.cjs.map +1 -0
  5. package/dist/analytics.d.cts +129 -0
  6. package/dist/analytics.d.ts +129 -0
  7. package/dist/analytics.js +403 -0
  8. package/dist/analytics.js.map +1 -0
  9. package/dist/cards-B_aNY35J.d.cts +514 -0
  10. package/dist/cards-Ba1wZttb.d.ts +514 -0
  11. package/dist/deposits-BEc8U80M.d.cts +310 -0
  12. package/dist/deposits-DScyT_D9.d.ts +310 -0
  13. package/dist/{devices-DP_hxwmW.d.ts → devices-B_YveTl9.d.ts} +1 -1
  14. package/dist/{devices-C3JHi2Hi.d.cts → devices-a5Z45Mx_.d.cts} +1 -1
  15. package/dist/{http-B-OQwMYn.d.cts → http-DeANAoTs.d.cts} +11 -3
  16. package/dist/{http-B-OQwMYn.d.ts → http-DeANAoTs.d.ts} +11 -3
  17. package/dist/index.cjs +964 -77
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +101 -13
  20. package/dist/index.d.ts +101 -13
  21. package/dist/index.js +949 -78
  22. package/dist/index.js.map +1 -1
  23. package/dist/react/index.d.cts +12 -5
  24. package/dist/react/index.d.ts +12 -5
  25. package/dist/resources/attribution.cjs +82 -0
  26. package/dist/resources/attribution.cjs.map +1 -0
  27. package/dist/resources/attribution.d.cts +100 -0
  28. package/dist/resources/attribution.d.ts +100 -0
  29. package/dist/resources/attribution.js +78 -0
  30. package/dist/resources/attribution.js.map +1 -0
  31. package/dist/resources/auth.cjs +81 -15
  32. package/dist/resources/auth.cjs.map +1 -1
  33. package/dist/resources/auth.d.cts +53 -6
  34. package/dist/resources/auth.d.ts +53 -6
  35. package/dist/resources/auth.js +81 -15
  36. package/dist/resources/auth.js.map +1 -1
  37. package/dist/resources/balance.d.cts +1 -1
  38. package/dist/resources/balance.d.ts +1 -1
  39. package/dist/resources/blog.cjs.map +1 -1
  40. package/dist/resources/blog.d.cts +8 -1
  41. package/dist/resources/blog.d.ts +8 -1
  42. package/dist/resources/blog.js.map +1 -1
  43. package/dist/resources/bonus.cjs +28 -0
  44. package/dist/resources/bonus.cjs.map +1 -0
  45. package/dist/resources/bonus.d.cts +121 -0
  46. package/dist/resources/bonus.d.ts +121 -0
  47. package/dist/resources/bonus.js +26 -0
  48. package/dist/resources/bonus.js.map +1 -0
  49. package/dist/resources/branding.d.cts +1 -1
  50. package/dist/resources/branding.d.ts +1 -1
  51. package/dist/resources/cards.cjs +73 -10
  52. package/dist/resources/cards.cjs.map +1 -1
  53. package/dist/resources/cards.d.cts +2 -281
  54. package/dist/resources/cards.d.ts +2 -281
  55. package/dist/resources/cards.js +73 -11
  56. package/dist/resources/cards.js.map +1 -1
  57. package/dist/resources/codes.cjs +20 -0
  58. package/dist/resources/codes.cjs.map +1 -0
  59. package/dist/resources/codes.d.cts +100 -0
  60. package/dist/resources/codes.d.ts +100 -0
  61. package/dist/resources/codes.js +18 -0
  62. package/dist/resources/codes.js.map +1 -0
  63. package/dist/resources/deposits.cjs +28 -3
  64. package/dist/resources/deposits.cjs.map +1 -1
  65. package/dist/resources/deposits.d.cts +3 -176
  66. package/dist/resources/deposits.d.ts +3 -176
  67. package/dist/resources/deposits.js +28 -3
  68. package/dist/resources/deposits.js.map +1 -1
  69. package/dist/resources/devices.d.cts +2 -2
  70. package/dist/resources/devices.d.ts +2 -2
  71. package/dist/resources/documents.cjs +64 -0
  72. package/dist/resources/documents.cjs.map +1 -0
  73. package/dist/resources/documents.d.cts +212 -0
  74. package/dist/resources/documents.d.ts +212 -0
  75. package/dist/resources/documents.js +62 -0
  76. package/dist/resources/documents.js.map +1 -0
  77. package/dist/resources/funding-options.cjs +16 -0
  78. package/dist/resources/funding-options.cjs.map +1 -0
  79. package/dist/resources/funding-options.d.cts +3 -0
  80. package/dist/resources/funding-options.d.ts +3 -0
  81. package/dist/resources/funding-options.js +14 -0
  82. package/dist/resources/funding-options.js.map +1 -0
  83. package/dist/resources/history.cjs +31 -0
  84. package/dist/resources/history.cjs.map +1 -0
  85. package/dist/resources/history.d.cts +95 -0
  86. package/dist/resources/history.d.ts +95 -0
  87. package/dist/resources/history.js +29 -0
  88. package/dist/resources/history.js.map +1 -0
  89. package/dist/resources/me.d.cts +3 -1
  90. package/dist/resources/me.d.ts +3 -1
  91. package/dist/resources/notifications.d.cts +1 -1
  92. package/dist/resources/notifications.d.ts +1 -1
  93. package/dist/resources/push.d.cts +1 -1
  94. package/dist/resources/push.d.ts +1 -1
  95. package/dist/resources/referral.cjs +16 -0
  96. package/dist/resources/referral.cjs.map +1 -0
  97. package/dist/resources/referral.d.cts +58 -0
  98. package/dist/resources/referral.d.ts +58 -0
  99. package/dist/resources/referral.js +14 -0
  100. package/dist/resources/referral.js.map +1 -0
  101. package/dist/resources/sessions.d.cts +1 -1
  102. package/dist/resources/sessions.d.ts +1 -1
  103. package/dist/resources/subscription.cjs +24 -0
  104. package/dist/resources/subscription.cjs.map +1 -0
  105. package/dist/resources/subscription.d.cts +48 -0
  106. package/dist/resources/subscription.d.ts +48 -0
  107. package/dist/resources/subscription.js +22 -0
  108. package/dist/resources/subscription.js.map +1 -0
  109. package/dist/resources/subscriptions.d.cts +1 -1
  110. package/dist/resources/subscriptions.d.ts +1 -1
  111. package/dist/resources/wallet.d.cts +1 -1
  112. package/dist/resources/wallet.d.ts +1 -1
  113. package/dist/telegram.cjs +499 -77
  114. package/dist/telegram.cjs.map +1 -1
  115. package/dist/telegram.d.cts +12 -5
  116. package/dist/telegram.d.ts +12 -5
  117. package/dist/telegram.js +499 -77
  118. package/dist/telegram.js.map +1 -1
  119. package/package.json +46 -1
  120. package/dist/customer-CoxPwe5o.d.cts +0 -32
  121. package/dist/customer-CoxPwe5o.d.ts +0 -32
@@ -0,0 +1,310 @@
1
+ import { H as HttpClient } from './http-DeANAoTs.cjs';
2
+ import { k as CustomerInfo, j as CreateCardInput } from './cards-B_aNY35J.cjs';
3
+
4
+ /**
5
+ * Funding options resource — `client.fundingOptions.*`.
6
+ *
7
+ * The ways the user can top up on this deployment: each funding connector,
8
+ * where its top-ups may land and which payment methods it takes. Build the
9
+ * top-up screen from this list instead of fixed connector names: a
10
+ * deployment may top up the wallet only, cards only (no wallet at all), or
11
+ * let the user choose.
12
+ *
13
+ * Mirrors `GET /me/funding-options`.
14
+ */
15
+ /**
16
+ * Where a funding connector's top-ups may land: `wallet` (the wallet
17
+ * only), `spool` (straight onto cards only) or `mixed` (either).
18
+ */
19
+ type FunderMode = "wallet" | "spool" | "mixed";
20
+ /** Where one top-up goes: the wallet, or one of the user's cards. */
21
+ type DepositTarget = "wallet" | "card";
22
+ /** One way to top up. */
23
+ interface FundingOption {
24
+ /** Pass it as `funder_slug` to `deposits.initiate`. */
25
+ slug: string;
26
+ mode: FunderMode;
27
+ /** Where a top-up through it may land. */
28
+ targets: DepositTarget[];
29
+ /** Payment methods it takes. */
30
+ methods: DepositMethod[];
31
+ /**
32
+ * Whether a new card can be issued with a top-up through it
33
+ * (`issue_card` on `deposits.initiate`).
34
+ */
35
+ issue_card: boolean;
36
+ }
37
+ declare class FundingOptionsResource {
38
+ private readonly http;
39
+ constructor(http: HttpClient);
40
+ /** The ways to top up, preferred first. Empty when none is configured. */
41
+ list(): Promise<FundingOption[]>;
42
+ }
43
+
44
+ /**
45
+ * Deposits resource — `client.deposits.*`.
46
+ *
47
+ * The "money IN" surface: an end user tops up their wallet balance via a
48
+ * funder connector, or one of their cards straight away, past the wallet
49
+ * (`card_id`, or `issue_card` for a new card). Which of the two a
50
+ * deployment allows is in `client.fundingOptions.list()`. Mirrors the
51
+ * Takeal API's `/me/deposits` routes:
52
+ *
53
+ * POST /me/deposits → initiate
54
+ * GET /me/deposits → list (most recent first)
55
+ * GET /me/deposits/{id} → get
56
+ * POST /me/deposits/{id}/refunds → refund
57
+ *
58
+ * A deposit is rarely terminal on the initiate call: real PSPs return
59
+ * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via
60
+ * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's
61
+ * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.
62
+ */
63
+ /** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */
64
+ type DepositStatus = "pending" | "redirect_required" | "confirmed" | "failed";
65
+ /** Top-up rail. The chosen funder decides which it supports. */
66
+ type DepositMethod = "card" | "crypto" | "bank_transfer";
67
+ /**
68
+ * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the
69
+ * server-side `id` is the stable handle the SDK polls against. `idempotency_key`
70
+ * and `request_fingerprint` are server-internal and never serialised.
71
+ */
72
+ /** Input for `quote()` — price a cross-currency deposit before paying. */
73
+ interface CreateQuoteInput {
74
+ /** Decimal string, e.g. `"5000.00"`. */
75
+ amount: string;
76
+ /** ISO 4217 source currency — must differ from the currency credited. */
77
+ currency: string;
78
+ /**
79
+ * Quote a top-up of this card: credited in the card's currency. Pass the
80
+ * same `card_id` to `initiate()`.
81
+ */
82
+ card_id?: string;
83
+ /**
84
+ * Quote into this currency instead of the wallet's: the currency of a
85
+ * card issued with the top-up (`issue_card`). Ignored with `card_id`.
86
+ */
87
+ target_currency?: string;
88
+ }
89
+ /** How far a top-up meant for a card has got. */
90
+ type CardLoadStatus = "pending" | "succeeded" | "failed";
91
+ /**
92
+ * A card to issue with the top-up: the fields of `cards.create` without
93
+ * its idempotency key (the deposit's covers both). The card's price is
94
+ * paid from the top-up and the rest becomes its starting balance.
95
+ */
96
+ type IssueCardInput = Omit<CreateCardInput, "idempotencyKey" | "currency"> & {
97
+ /** Optional with `productId`: the product names the currency. */
98
+ currency?: string;
99
+ };
100
+ /**
101
+ * A rate-locked funding quote: pay `source_amount source_currency`, the
102
+ * wallet is credited `credited_amount credited_currency` (net of the
103
+ * platform's conversion spread). Execute by passing `id` as `quote_id` to
104
+ * `initiate()` before `expires_at`; after that the API returns 409 and a new
105
+ * quote is needed.
106
+ */
107
+ interface FundingQuote {
108
+ id: string;
109
+ source_amount: string;
110
+ source_currency: string;
111
+ credited_amount: string;
112
+ credited_currency: string;
113
+ /** Provider rate before spread (credited units per 1 source unit). */
114
+ rate: string;
115
+ spread_bps: number;
116
+ provider: string;
117
+ expires_at: string;
118
+ }
119
+ interface Deposit {
120
+ id: string;
121
+ user_id: string;
122
+ /** Slug of the funder that handled this deposit, as configured by the deployment. */
123
+ connector_slug: string;
124
+ /** The connector's own reference, populated once it responds. */
125
+ provider_reference: string | null;
126
+ status: DepositStatus;
127
+ /** Decimal serialised as a string to avoid float drift. */
128
+ amount: string;
129
+ currency: string;
130
+ method: DepositMethod;
131
+ /** Present when `status === "redirect_required"` — send the user here. */
132
+ redirect_url: string | null;
133
+ failure_reason: string | null;
134
+ /** Final settled amount once confirmed (may differ from `amount` on FX). */
135
+ confirmed_amount: string | null;
136
+ confirmed_at: string | null;
137
+ /** Set on cross-currency deposits: the quote this deposit executed against. */
138
+ quote_id?: string | null;
139
+ /** Locked provider rate (credited units per 1 source unit). */
140
+ fx_rate?: string | null;
141
+ fx_spread_bps?: number | null;
142
+ /** The wallet's local currency the deposit converted into. */
143
+ credited_currency?: string | null;
144
+ /** What the wallet was actually credited, net of spread. */
145
+ credited_amount?: string | null;
146
+ /** Bonuses added on top of the top-up, when any were. */
147
+ bonus_units?: string | null;
148
+ /** What those bonuses added to the wallet, in the credited currency. */
149
+ bonus_value?: string | null;
150
+ /** The promo code the top-up was made with; its discount came off the commission. */
151
+ promo_code?: string | null;
152
+ /** Where the money goes. Older deployments leave it out: the wallet. */
153
+ target?: DepositTarget;
154
+ /** For a top-up onto a card: the card. */
155
+ card_id?: string | null;
156
+ /** The funding connector's mode when the top-up was made. */
157
+ funder_mode?: FunderMode | null;
158
+ /** True when the card was issued with this top-up. */
159
+ issues_card?: boolean;
160
+ /**
161
+ * For a top-up onto a card: `pending` until the card provider has loaded
162
+ * the card, then `succeeded` or `failed`. Show the top-up as done only
163
+ * once it is `succeeded`, or once `returned_to_wallet_at` is set.
164
+ */
165
+ card_load_status?: CardLoadStatus | null;
166
+ /** Why the card could not take it, when `card_load_status` is `failed`. */
167
+ card_load_error?: string | null;
168
+ /** What went towards the card, in its currency, bonuses included. */
169
+ card_amount?: string | null;
170
+ /** The commission taken from a top-up onto a card, in the card's currency. */
171
+ card_commission?: string | null;
172
+ /** The money part of the price of a card issued with the top-up. */
173
+ issue_fee?: string | null;
174
+ /** The bonus part of that price. */
175
+ issue_bonus_units?: string | null;
176
+ issue_bonus_value?: string | null;
177
+ card_loaded_at?: string | null;
178
+ /**
179
+ * Set when the card could not take the top-up and the money went to the
180
+ * wallet instead (funding connectors in `mixed` mode). The user is told.
181
+ */
182
+ returned_to_wallet_at?: string | null;
183
+ created_at: string;
184
+ updated_at: string;
185
+ }
186
+ interface InitiateDepositInput {
187
+ /** Decimal as a string (`"100.00"`) — avoids float-precision loss on the wire. */
188
+ amount: string;
189
+ /** ISO 4217 code, e.g. `"USD"`. */
190
+ currency: string;
191
+ method: DepositMethod;
192
+ /**
193
+ * Optional. Slug of a specific funder to route through. Omit to
194
+ * let the Takeal API pick the first active funder. Unknown slug → 400; empty
195
+ * funder list → 503.
196
+ */
197
+ funder_slug?: string;
198
+ /**
199
+ * Passed to the funding connector and stored with the deposit. Two keys
200
+ * work across connectors: `return_url`, where the provider sends the user
201
+ * back after a 3-D Secure step (pair it with `redirect_required`), and on
202
+ * test deployments with the mock funder `mock_scenario`, which picks the
203
+ * outcome: `happy` (confirmed at once, the default), `pending` (confirmed
204
+ * about 15 s later), `redirect` (a hosted page where the user approves or
205
+ * declines) or `fail`.
206
+ */
207
+ metadata?: Record<string, string>;
208
+ /** Structured billing details — real PSPs require these for 3DS / compliance. */
209
+ customer?: CustomerInfo;
210
+ /**
211
+ * Required by the Takeal API on this write endpoint. Same key + body replays the
212
+ * original deposit; same key + different body returns 409. Supply a stable
213
+ * UUID per logical attempt so a retried network call is safe.
214
+ */
215
+ idempotencyKey: string;
216
+ /**
217
+ * Required when `currency` differs from the wallet's local currency: a
218
+ * fresh quote id from `quote()`. Cross-currency deposits without one are
219
+ * rejected with 400; expired quotes with 409.
220
+ */
221
+ quote_id?: string;
222
+ /**
223
+ * Add bonuses on top of the top-up: the user pays `amount`, the wallet
224
+ * gets `amount` plus what the bonuses add. On by default whenever the
225
+ * user has bonuses that can go to a top-up (only ones that came with a
226
+ * payment can); `false` tops up without them.
227
+ */
228
+ use_bonus?: boolean;
229
+ /** The most bonuses to add, decimal string. Omit to add as many as allowed. */
230
+ bonus_amount?: string;
231
+ /**
232
+ * Top up this card instead of the wallet. It must be the user's, active
233
+ * and prepaid. A funding connector that tops up the wallet only answers
234
+ * 400 `target_not_allowed`; one that tops up cards only needs `card_id`
235
+ * or `issue_card`. Paying in another currency than the card's needs a
236
+ * quote made with the same `card_id`.
237
+ */
238
+ card_id?: string;
239
+ /**
240
+ * Issue a new card and put this top-up on it. The card shows up as
241
+ * `pending_payment` and is issued once the top-up is confirmed; if the
242
+ * top-up fails, so does the card. Too small to cover the price → 400
243
+ * `amount_too_small`. Not together with `card_id`.
244
+ */
245
+ issue_card?: IssueCardInput;
246
+ /**
247
+ * A promo code for this top-up, to the wallet or to a card. Its discount
248
+ * comes off the commission; bonuses or a gift that come with the code
249
+ * arrive once the top-up is confirmed. A code that can't be used fails the
250
+ * request with 400 `promo_code_*` and the reason. `client.codes.validate`
251
+ * checks it first.
252
+ */
253
+ promo_code?: string;
254
+ }
255
+ interface CreateDepositRefundInput {
256
+ /** Omit for a full refund of the original confirmed amount; same currency. */
257
+ amount?: string;
258
+ /** Human-readable reason, e.g. `"customer_request"`. */
259
+ reason?: string;
260
+ metadata?: Record<string, string>;
261
+ /** Required. Replays are keyed on this. */
262
+ idempotencyKey: string;
263
+ }
264
+ /** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */
265
+ interface Refund {
266
+ id: string;
267
+ target_type: string;
268
+ deposit_id?: string;
269
+ payment_id?: string;
270
+ connector_slug: string;
271
+ amount: string;
272
+ currency: string;
273
+ reason: string;
274
+ status: string;
275
+ provider_refund_reference?: string;
276
+ failure_reason?: string;
277
+ requestor_type: string;
278
+ requestor_id: string;
279
+ created_at: string;
280
+ updated_at: string;
281
+ }
282
+ declare class DepositsResource {
283
+ private readonly http;
284
+ constructor(http: HttpClient);
285
+ /**
286
+ * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose
287
+ * `status` may already be `confirmed` (synchronous rails / mock) or
288
+ * `redirect_required` (3DS / APM — forward the user to `redirect_url`).
289
+ */
290
+ /**
291
+ * Price a cross-currency deposit BEFORE paying. The rate is locked
292
+ * server-side until `expires_at`; deposits already in the currency they
293
+ * credit (the wallet's, or the card's with `card_id`) need no quote (the
294
+ * API answers 400 `no_quote_needed`).
295
+ */
296
+ quote(input: CreateQuoteInput): Promise<FundingQuote>;
297
+ initiate(input: InitiateDepositInput): Promise<Deposit>;
298
+ /** Fetch one deposit by id — the poll target while a redirect resolves. */
299
+ get(id: string): Promise<Deposit>;
300
+ /** List the caller's deposits, most recent first. */
301
+ list(): Promise<Deposit[]>;
302
+ /**
303
+ * Refund a previously-confirmed deposit. Synchronous when the
304
+ * connector settles inline; otherwise the row stays `pending` and flips
305
+ * later via the inbound `deposit.refunded` event.
306
+ */
307
+ refund(depositId: string, input: CreateDepositRefundInput): Promise<Refund>;
308
+ }
309
+
310
+ export { type CardLoadStatus as C, type Deposit as D, FundingOptionsResource as F, type InitiateDepositInput as I, type Refund as R, DepositsResource as a, type CreateDepositRefundInput as b, type CreateQuoteInput as c, type DepositMethod as d, type DepositStatus as e, type DepositTarget as f, type FunderMode as g, type FundingOption as h, type FundingQuote as i, type IssueCardInput as j };
@@ -0,0 +1,310 @@
1
+ import { H as HttpClient } from './http-DeANAoTs.js';
2
+ import { k as CustomerInfo, j as CreateCardInput } from './cards-Ba1wZttb.js';
3
+
4
+ /**
5
+ * Funding options resource — `client.fundingOptions.*`.
6
+ *
7
+ * The ways the user can top up on this deployment: each funding connector,
8
+ * where its top-ups may land and which payment methods it takes. Build the
9
+ * top-up screen from this list instead of fixed connector names: a
10
+ * deployment may top up the wallet only, cards only (no wallet at all), or
11
+ * let the user choose.
12
+ *
13
+ * Mirrors `GET /me/funding-options`.
14
+ */
15
+ /**
16
+ * Where a funding connector's top-ups may land: `wallet` (the wallet
17
+ * only), `spool` (straight onto cards only) or `mixed` (either).
18
+ */
19
+ type FunderMode = "wallet" | "spool" | "mixed";
20
+ /** Where one top-up goes: the wallet, or one of the user's cards. */
21
+ type DepositTarget = "wallet" | "card";
22
+ /** One way to top up. */
23
+ interface FundingOption {
24
+ /** Pass it as `funder_slug` to `deposits.initiate`. */
25
+ slug: string;
26
+ mode: FunderMode;
27
+ /** Where a top-up through it may land. */
28
+ targets: DepositTarget[];
29
+ /** Payment methods it takes. */
30
+ methods: DepositMethod[];
31
+ /**
32
+ * Whether a new card can be issued with a top-up through it
33
+ * (`issue_card` on `deposits.initiate`).
34
+ */
35
+ issue_card: boolean;
36
+ }
37
+ declare class FundingOptionsResource {
38
+ private readonly http;
39
+ constructor(http: HttpClient);
40
+ /** The ways to top up, preferred first. Empty when none is configured. */
41
+ list(): Promise<FundingOption[]>;
42
+ }
43
+
44
+ /**
45
+ * Deposits resource — `client.deposits.*`.
46
+ *
47
+ * The "money IN" surface: an end user tops up their wallet balance via a
48
+ * funder connector, or one of their cards straight away, past the wallet
49
+ * (`card_id`, or `issue_card` for a new card). Which of the two a
50
+ * deployment allows is in `client.fundingOptions.list()`. Mirrors the
51
+ * Takeal API's `/me/deposits` routes:
52
+ *
53
+ * POST /me/deposits → initiate
54
+ * GET /me/deposits → list (most recent first)
55
+ * GET /me/deposits/{id} → get
56
+ * POST /me/deposits/{id}/refunds → refund
57
+ *
58
+ * A deposit is rarely terminal on the initiate call: real PSPs return
59
+ * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via
60
+ * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's
61
+ * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.
62
+ */
63
+ /** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */
64
+ type DepositStatus = "pending" | "redirect_required" | "confirmed" | "failed";
65
+ /** Top-up rail. The chosen funder decides which it supports. */
66
+ type DepositMethod = "card" | "crypto" | "bank_transfer";
67
+ /**
68
+ * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the
69
+ * server-side `id` is the stable handle the SDK polls against. `idempotency_key`
70
+ * and `request_fingerprint` are server-internal and never serialised.
71
+ */
72
+ /** Input for `quote()` — price a cross-currency deposit before paying. */
73
+ interface CreateQuoteInput {
74
+ /** Decimal string, e.g. `"5000.00"`. */
75
+ amount: string;
76
+ /** ISO 4217 source currency — must differ from the currency credited. */
77
+ currency: string;
78
+ /**
79
+ * Quote a top-up of this card: credited in the card's currency. Pass the
80
+ * same `card_id` to `initiate()`.
81
+ */
82
+ card_id?: string;
83
+ /**
84
+ * Quote into this currency instead of the wallet's: the currency of a
85
+ * card issued with the top-up (`issue_card`). Ignored with `card_id`.
86
+ */
87
+ target_currency?: string;
88
+ }
89
+ /** How far a top-up meant for a card has got. */
90
+ type CardLoadStatus = "pending" | "succeeded" | "failed";
91
+ /**
92
+ * A card to issue with the top-up: the fields of `cards.create` without
93
+ * its idempotency key (the deposit's covers both). The card's price is
94
+ * paid from the top-up and the rest becomes its starting balance.
95
+ */
96
+ type IssueCardInput = Omit<CreateCardInput, "idempotencyKey" | "currency"> & {
97
+ /** Optional with `productId`: the product names the currency. */
98
+ currency?: string;
99
+ };
100
+ /**
101
+ * A rate-locked funding quote: pay `source_amount source_currency`, the
102
+ * wallet is credited `credited_amount credited_currency` (net of the
103
+ * platform's conversion spread). Execute by passing `id` as `quote_id` to
104
+ * `initiate()` before `expires_at`; after that the API returns 409 and a new
105
+ * quote is needed.
106
+ */
107
+ interface FundingQuote {
108
+ id: string;
109
+ source_amount: string;
110
+ source_currency: string;
111
+ credited_amount: string;
112
+ credited_currency: string;
113
+ /** Provider rate before spread (credited units per 1 source unit). */
114
+ rate: string;
115
+ spread_bps: number;
116
+ provider: string;
117
+ expires_at: string;
118
+ }
119
+ interface Deposit {
120
+ id: string;
121
+ user_id: string;
122
+ /** Slug of the funder that handled this deposit, as configured by the deployment. */
123
+ connector_slug: string;
124
+ /** The connector's own reference, populated once it responds. */
125
+ provider_reference: string | null;
126
+ status: DepositStatus;
127
+ /** Decimal serialised as a string to avoid float drift. */
128
+ amount: string;
129
+ currency: string;
130
+ method: DepositMethod;
131
+ /** Present when `status === "redirect_required"` — send the user here. */
132
+ redirect_url: string | null;
133
+ failure_reason: string | null;
134
+ /** Final settled amount once confirmed (may differ from `amount` on FX). */
135
+ confirmed_amount: string | null;
136
+ confirmed_at: string | null;
137
+ /** Set on cross-currency deposits: the quote this deposit executed against. */
138
+ quote_id?: string | null;
139
+ /** Locked provider rate (credited units per 1 source unit). */
140
+ fx_rate?: string | null;
141
+ fx_spread_bps?: number | null;
142
+ /** The wallet's local currency the deposit converted into. */
143
+ credited_currency?: string | null;
144
+ /** What the wallet was actually credited, net of spread. */
145
+ credited_amount?: string | null;
146
+ /** Bonuses added on top of the top-up, when any were. */
147
+ bonus_units?: string | null;
148
+ /** What those bonuses added to the wallet, in the credited currency. */
149
+ bonus_value?: string | null;
150
+ /** The promo code the top-up was made with; its discount came off the commission. */
151
+ promo_code?: string | null;
152
+ /** Where the money goes. Older deployments leave it out: the wallet. */
153
+ target?: DepositTarget;
154
+ /** For a top-up onto a card: the card. */
155
+ card_id?: string | null;
156
+ /** The funding connector's mode when the top-up was made. */
157
+ funder_mode?: FunderMode | null;
158
+ /** True when the card was issued with this top-up. */
159
+ issues_card?: boolean;
160
+ /**
161
+ * For a top-up onto a card: `pending` until the card provider has loaded
162
+ * the card, then `succeeded` or `failed`. Show the top-up as done only
163
+ * once it is `succeeded`, or once `returned_to_wallet_at` is set.
164
+ */
165
+ card_load_status?: CardLoadStatus | null;
166
+ /** Why the card could not take it, when `card_load_status` is `failed`. */
167
+ card_load_error?: string | null;
168
+ /** What went towards the card, in its currency, bonuses included. */
169
+ card_amount?: string | null;
170
+ /** The commission taken from a top-up onto a card, in the card's currency. */
171
+ card_commission?: string | null;
172
+ /** The money part of the price of a card issued with the top-up. */
173
+ issue_fee?: string | null;
174
+ /** The bonus part of that price. */
175
+ issue_bonus_units?: string | null;
176
+ issue_bonus_value?: string | null;
177
+ card_loaded_at?: string | null;
178
+ /**
179
+ * Set when the card could not take the top-up and the money went to the
180
+ * wallet instead (funding connectors in `mixed` mode). The user is told.
181
+ */
182
+ returned_to_wallet_at?: string | null;
183
+ created_at: string;
184
+ updated_at: string;
185
+ }
186
+ interface InitiateDepositInput {
187
+ /** Decimal as a string (`"100.00"`) — avoids float-precision loss on the wire. */
188
+ amount: string;
189
+ /** ISO 4217 code, e.g. `"USD"`. */
190
+ currency: string;
191
+ method: DepositMethod;
192
+ /**
193
+ * Optional. Slug of a specific funder to route through. Omit to
194
+ * let the Takeal API pick the first active funder. Unknown slug → 400; empty
195
+ * funder list → 503.
196
+ */
197
+ funder_slug?: string;
198
+ /**
199
+ * Passed to the funding connector and stored with the deposit. Two keys
200
+ * work across connectors: `return_url`, where the provider sends the user
201
+ * back after a 3-D Secure step (pair it with `redirect_required`), and on
202
+ * test deployments with the mock funder `mock_scenario`, which picks the
203
+ * outcome: `happy` (confirmed at once, the default), `pending` (confirmed
204
+ * about 15 s later), `redirect` (a hosted page where the user approves or
205
+ * declines) or `fail`.
206
+ */
207
+ metadata?: Record<string, string>;
208
+ /** Structured billing details — real PSPs require these for 3DS / compliance. */
209
+ customer?: CustomerInfo;
210
+ /**
211
+ * Required by the Takeal API on this write endpoint. Same key + body replays the
212
+ * original deposit; same key + different body returns 409. Supply a stable
213
+ * UUID per logical attempt so a retried network call is safe.
214
+ */
215
+ idempotencyKey: string;
216
+ /**
217
+ * Required when `currency` differs from the wallet's local currency: a
218
+ * fresh quote id from `quote()`. Cross-currency deposits without one are
219
+ * rejected with 400; expired quotes with 409.
220
+ */
221
+ quote_id?: string;
222
+ /**
223
+ * Add bonuses on top of the top-up: the user pays `amount`, the wallet
224
+ * gets `amount` plus what the bonuses add. On by default whenever the
225
+ * user has bonuses that can go to a top-up (only ones that came with a
226
+ * payment can); `false` tops up without them.
227
+ */
228
+ use_bonus?: boolean;
229
+ /** The most bonuses to add, decimal string. Omit to add as many as allowed. */
230
+ bonus_amount?: string;
231
+ /**
232
+ * Top up this card instead of the wallet. It must be the user's, active
233
+ * and prepaid. A funding connector that tops up the wallet only answers
234
+ * 400 `target_not_allowed`; one that tops up cards only needs `card_id`
235
+ * or `issue_card`. Paying in another currency than the card's needs a
236
+ * quote made with the same `card_id`.
237
+ */
238
+ card_id?: string;
239
+ /**
240
+ * Issue a new card and put this top-up on it. The card shows up as
241
+ * `pending_payment` and is issued once the top-up is confirmed; if the
242
+ * top-up fails, so does the card. Too small to cover the price → 400
243
+ * `amount_too_small`. Not together with `card_id`.
244
+ */
245
+ issue_card?: IssueCardInput;
246
+ /**
247
+ * A promo code for this top-up, to the wallet or to a card. Its discount
248
+ * comes off the commission; bonuses or a gift that come with the code
249
+ * arrive once the top-up is confirmed. A code that can't be used fails the
250
+ * request with 400 `promo_code_*` and the reason. `client.codes.validate`
251
+ * checks it first.
252
+ */
253
+ promo_code?: string;
254
+ }
255
+ interface CreateDepositRefundInput {
256
+ /** Omit for a full refund of the original confirmed amount; same currency. */
257
+ amount?: string;
258
+ /** Human-readable reason, e.g. `"customer_request"`. */
259
+ reason?: string;
260
+ metadata?: Record<string, string>;
261
+ /** Required. Replays are keyed on this. */
262
+ idempotencyKey: string;
263
+ }
264
+ /** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */
265
+ interface Refund {
266
+ id: string;
267
+ target_type: string;
268
+ deposit_id?: string;
269
+ payment_id?: string;
270
+ connector_slug: string;
271
+ amount: string;
272
+ currency: string;
273
+ reason: string;
274
+ status: string;
275
+ provider_refund_reference?: string;
276
+ failure_reason?: string;
277
+ requestor_type: string;
278
+ requestor_id: string;
279
+ created_at: string;
280
+ updated_at: string;
281
+ }
282
+ declare class DepositsResource {
283
+ private readonly http;
284
+ constructor(http: HttpClient);
285
+ /**
286
+ * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose
287
+ * `status` may already be `confirmed` (synchronous rails / mock) or
288
+ * `redirect_required` (3DS / APM — forward the user to `redirect_url`).
289
+ */
290
+ /**
291
+ * Price a cross-currency deposit BEFORE paying. The rate is locked
292
+ * server-side until `expires_at`; deposits already in the currency they
293
+ * credit (the wallet's, or the card's with `card_id`) need no quote (the
294
+ * API answers 400 `no_quote_needed`).
295
+ */
296
+ quote(input: CreateQuoteInput): Promise<FundingQuote>;
297
+ initiate(input: InitiateDepositInput): Promise<Deposit>;
298
+ /** Fetch one deposit by id — the poll target while a redirect resolves. */
299
+ get(id: string): Promise<Deposit>;
300
+ /** List the caller's deposits, most recent first. */
301
+ list(): Promise<Deposit[]>;
302
+ /**
303
+ * Refund a previously-confirmed deposit. Synchronous when the
304
+ * connector settles inline; otherwise the row stays `pending` and flips
305
+ * later via the inbound `deposit.refunded` event.
306
+ */
307
+ refund(depositId: string, input: CreateDepositRefundInput): Promise<Refund>;
308
+ }
309
+
310
+ export { type CardLoadStatus as C, type Deposit as D, FundingOptionsResource as F, type InitiateDepositInput as I, type Refund as R, DepositsResource as a, type CreateDepositRefundInput as b, type CreateQuoteInput as c, type DepositMethod as d, type DepositStatus as e, type DepositTarget as f, type FunderMode as g, type FundingOption as h, type FundingQuote as i, type IssueCardInput as j };
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from './http-B-OQwMYn.js';
1
+ import { H as HttpClient } from './http-DeANAoTs.js';
2
2
  import { PushCapableRegistration } from './resources/push.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from './http-B-OQwMYn.cjs';
1
+ import { H as HttpClient } from './http-DeANAoTs.cjs';
2
2
  import { PushCapableRegistration } from './resources/push.cjs';
3
3
 
4
4
  /**
@@ -41,9 +41,9 @@ declare function inMemoryStore(): TokenStore;
41
41
  * - Surface network failures (DNS, abort, broken pipe) as
42
42
  * `NetworkError`.
43
43
  *
44
- * Auto-refresh + retry policies are deliberately NOT in here — they
45
- * belong to the resource layer (auth.refresh) which has the right
46
- * context for "is this refreshable" decisions.
44
+ * A 401 on an authenticated call asks the refresher (set by the auth
45
+ * resource when a remembered sign-in exists) for a new session once, and
46
+ * repeats the call when it got one. Concurrent 401s share one refresh.
47
47
  */
48
48
  type FetchLike = typeof fetch;
49
49
  interface HttpOptions {
@@ -59,6 +59,8 @@ interface HttpOptions {
59
59
  skipAuth?: boolean;
60
60
  /** AbortSignal forwarded to fetch. */
61
61
  signal?: AbortSignal;
62
+ /** Internal: this is the repeat after a refresh. */
63
+ retried?: boolean;
62
64
  }
63
65
  declare class HttpClient {
64
66
  private readonly baseUrl;
@@ -71,6 +73,12 @@ declare class HttpClient {
71
73
  /** Headers sent on every request, below the per-call `headers`
72
74
  * (a caller can still override one). */
73
75
  defaultHeaders?: Record<string, string>);
76
+ private refresher;
77
+ private refreshing;
78
+ /** Called once on a 401; resolves `true` when a new session was stored. */
79
+ setRefresher(fn: (() => Promise<boolean>) | undefined): void;
80
+ /** One refresh at a time, whoever asks. */
81
+ refreshOnce(): Promise<boolean>;
74
82
  get<T>(path: string, opts?: HttpOptions): Promise<T>;
75
83
  post<T>(path: string, opts?: HttpOptions): Promise<T>;
76
84
  put<T>(path: string, opts?: HttpOptions): Promise<T>;