@takeal/cusfront-sdk 0.6.4 → 0.6.6

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 (101) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +182 -3
  3. package/dist/{cards-ofoGRU9v.d.cts → cards-BiXmrz7h.d.cts} +126 -11
  4. package/dist/{cards-BrqeBqLV.d.ts → cards-DwmzjKDC.d.ts} +126 -11
  5. package/dist/{devices-B_YveTl9.d.ts → devices-C88c38hm.d.ts} +1 -1
  6. package/dist/{devices-a5Z45Mx_.d.cts → devices-CiJrlXum.d.cts} +1 -1
  7. package/dist/{http-DeANAoTs.d.cts → http-CL97TjMO.d.cts} +4 -0
  8. package/dist/{http-DeANAoTs.d.ts → http-CL97TjMO.d.ts} +4 -0
  9. package/dist/index.cjs +200 -15
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +22 -10
  12. package/dist/index.d.ts +22 -10
  13. package/dist/index.js +199 -16
  14. package/dist/index.js.map +1 -1
  15. package/dist/react/index.d.cts +6 -3
  16. package/dist/react/index.d.ts +6 -3
  17. package/dist/resources/attribution.d.cts +1 -1
  18. package/dist/resources/attribution.d.ts +1 -1
  19. package/dist/resources/auth.cjs.map +1 -1
  20. package/dist/resources/auth.d.cts +2 -2
  21. package/dist/resources/auth.d.ts +2 -2
  22. package/dist/resources/auth.js.map +1 -1
  23. package/dist/resources/balance.d.cts +1 -1
  24. package/dist/resources/balance.d.ts +1 -1
  25. package/dist/resources/blog.d.cts +1 -1
  26. package/dist/resources/blog.d.ts +1 -1
  27. package/dist/resources/bonus.d.cts +1 -1
  28. package/dist/resources/bonus.d.ts +1 -1
  29. package/dist/resources/branding.d.cts +1 -1
  30. package/dist/resources/branding.d.ts +1 -1
  31. package/dist/resources/cards.cjs +9 -2
  32. package/dist/resources/cards.cjs.map +1 -1
  33. package/dist/resources/cards.d.cts +2 -2
  34. package/dist/resources/cards.d.ts +2 -2
  35. package/dist/resources/cards.js +9 -2
  36. package/dist/resources/cards.js.map +1 -1
  37. package/dist/resources/close-requests.cjs +54 -0
  38. package/dist/resources/close-requests.cjs.map +1 -0
  39. package/dist/resources/close-requests.d.cts +155 -0
  40. package/dist/resources/close-requests.d.ts +155 -0
  41. package/dist/resources/close-requests.js +52 -0
  42. package/dist/resources/close-requests.js.map +1 -0
  43. package/dist/resources/codes.d.cts +1 -1
  44. package/dist/resources/codes.d.ts +1 -1
  45. package/dist/resources/consents.cjs +42 -7
  46. package/dist/resources/consents.cjs.map +1 -1
  47. package/dist/resources/consents.d.cts +59 -9
  48. package/dist/resources/consents.d.ts +59 -9
  49. package/dist/resources/consents.js +41 -8
  50. package/dist/resources/consents.js.map +1 -1
  51. package/dist/resources/debt.cjs +22 -0
  52. package/dist/resources/debt.cjs.map +1 -0
  53. package/dist/resources/debt.d.cts +76 -0
  54. package/dist/resources/debt.d.ts +76 -0
  55. package/dist/resources/debt.js +20 -0
  56. package/dist/resources/debt.js.map +1 -0
  57. package/dist/resources/deposits.cjs.map +1 -1
  58. package/dist/resources/deposits.d.cts +2 -2
  59. package/dist/resources/deposits.d.ts +2 -2
  60. package/dist/resources/deposits.js.map +1 -1
  61. package/dist/resources/devices.d.cts +2 -2
  62. package/dist/resources/devices.d.ts +2 -2
  63. package/dist/resources/documents.d.cts +1 -1
  64. package/dist/resources/documents.d.ts +1 -1
  65. package/dist/resources/funding-options.d.cts +2 -2
  66. package/dist/resources/funding-options.d.ts +2 -2
  67. package/dist/resources/history.cjs.map +1 -1
  68. package/dist/resources/history.d.cts +13 -2
  69. package/dist/resources/history.d.ts +13 -2
  70. package/dist/resources/history.js.map +1 -1
  71. package/dist/resources/me.d.cts +2 -2
  72. package/dist/resources/me.d.ts +2 -2
  73. package/dist/resources/notifications.d.cts +1 -1
  74. package/dist/resources/notifications.d.ts +1 -1
  75. package/dist/resources/push.d.cts +1 -1
  76. package/dist/resources/push.d.ts +1 -1
  77. package/dist/resources/receipts.d.cts +1 -1
  78. package/dist/resources/receipts.d.ts +1 -1
  79. package/dist/resources/referral.d.cts +1 -1
  80. package/dist/resources/referral.d.ts +1 -1
  81. package/dist/resources/sessions.d.cts +1 -1
  82. package/dist/resources/sessions.d.ts +1 -1
  83. package/dist/resources/subscription.d.cts +1 -1
  84. package/dist/resources/subscription.d.ts +1 -1
  85. package/dist/resources/subscriptions.d.cts +1 -1
  86. package/dist/resources/subscriptions.d.ts +1 -1
  87. package/dist/resources/support.cjs +69 -0
  88. package/dist/resources/support.cjs.map +1 -0
  89. package/dist/resources/support.d.cts +110 -0
  90. package/dist/resources/support.d.ts +110 -0
  91. package/dist/resources/support.js +67 -0
  92. package/dist/resources/support.js.map +1 -0
  93. package/dist/resources/wallet.d.cts +1 -1
  94. package/dist/resources/wallet.d.ts +1 -1
  95. package/dist/telegram.cjs +198 -15
  96. package/dist/telegram.cjs.map +1 -1
  97. package/dist/telegram.d.cts +6 -3
  98. package/dist/telegram.d.ts +6 -3
  99. package/dist/telegram.js +198 -15
  100. package/dist/telegram.js.map +1 -1
  101. package/package.json +16 -1
package/dist/index.d.cts CHANGED
@@ -1,13 +1,17 @@
1
- import { T as TokenStore, F as FetchLike } from './http-DeANAoTs.cjs';
2
- export { d as defaultBrowserStore, i as inMemoryStore } from './http-DeANAoTs.cjs';
1
+ import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.cjs';
2
+ export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.cjs';
3
3
  import { AuthResource } from './resources/auth.cjs';
4
4
  export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.cjs';
5
- import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-ofoGRU9v.cjs';
6
- export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardLoadStatus, h as CardOrder, i as CardOrderError, j as CardOrderInput, C as CardProduct, k as CardProductPrice, l as CardStatus, m as CardStatusSource, n as CardTopUp, o as CardTopUpStatus, p as CardTransfer, q as CardType, r as Cardholder, s as CloseBlockedReason, t as CreateCardInput, u as CreateDepositRefundInput, v as CreateQuoteInput, w as CustomerInfo, D as Deposit, x as DepositMethod, y as DepositStatus, z as DepositTarget, E as FeeKind, G as FunderMode, H as FundingOption, I as FundingQuote, J as InitiateDepositInput, K as IssuanceBonus, L as IssueCardInput, M as MethodTerms, R as Refund, N as RevealCardInput, O as RevealedCard, S as SetPinInput, T as TopUpInput, P as TopUpResult, Q as TopUpTerms, U as TransferInput, V as TransferResult, W as UpdateCardInput } from './cards-ofoGRU9v.cjs';
5
+ import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-BiXmrz7h.cjs';
6
+ export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput } from './cards-BiXmrz7h.cjs';
7
7
  import { BalanceResource } from './resources/balance.cjs';
8
8
  export { Balance } from './resources/balance.cjs';
9
9
  import { BonusResource } from './resources/bonus.cjs';
10
10
  export { BonusLot, BonusMovement, BonusPreview, BonusPreviewInput, BonusPurpose, BonusTarget, BonusWallet } from './resources/bonus.cjs';
11
+ import { DebtResource } from './resources/debt.cjs';
12
+ export { CardFeeKind, Debt, DebtAmount, DebtLine } from './resources/debt.cjs';
13
+ import { CloseRequestsResource } from './resources/close-requests.cjs';
14
+ export { CloseAmount, CloseRefund, CloseRequest, CloseRequestError, CloseRequestStatus, PayoutDetailsInput, PayoutDetailsShown } from './resources/close-requests.cjs';
11
15
  import { CodesResource } from './resources/codes.cjs';
12
16
  export { CodeCheck, CodeDiscount, CodeEffect, CodeEffectOutcome, CodeOperation, CodeRejection, CodeResult, ValidateCodeInput } from './resources/codes.cjs';
13
17
  import { ReferralResource } from './resources/referral.cjs';
@@ -31,16 +35,18 @@ export { PushCapableRegistration, PushStatus, PushSubscriptionInput } from './re
31
35
  import { MeResource } from './resources/me.cjs';
32
36
  import { NotificationsResource } from './resources/notifications.cjs';
33
37
  export { CardOtpData, InboxItem, ListNotificationsParams, NotificationCategory, NotificationCategoryPreferences, NotificationChannel, NotificationLocale, NotificationPage, NotificationPreferences, NotificationPreferencesInput, isCardOtp } from './resources/notifications.cjs';
34
- import { C as ClientDescriptor, R as ResolvedClientDescriptor, D as DevicesResource } from './devices-a5Z45Mx_.cjs';
35
- export { a as CLIENT_HEADER, b as ClientPlatform, c as Device, d as DeviceKind, e as DevicePlatform, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, i as detectClientPlatform } from './devices-a5Z45Mx_.cjs';
38
+ import { C as ClientDescriptor, R as ResolvedClientDescriptor, D as DevicesResource } from './devices-CiJrlXum.cjs';
39
+ export { a as CLIENT_HEADER, b as ClientPlatform, c as Device, d as DeviceKind, e as DevicePlatform, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, i as detectClientPlatform } from './devices-CiJrlXum.cjs';
36
40
  import { AttributionResource } from './resources/attribution.cjs';
37
41
  export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, anonymousKey, currentTouch } from './resources/attribution.cjs';
38
42
  import { HistoryResource } from './resources/history.cjs';
39
43
  export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.cjs';
40
44
  import { ConsentsResource } from './resources/consents.cjs';
41
- export { ConsentChannel, ConsentDocument, ConsentKind, ConsentState, Consents, CookieChoiceInput } from './resources/consents.cjs';
45
+ export { ConsentChannel, ConsentDocument, ConsentKind, ConsentOptions, ConsentState, Consents, CookieChoiceInput, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT } from './resources/consents.cjs';
42
46
  import { ReceiptsResource } from './resources/receipts.cjs';
43
47
  export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.cjs';
48
+ import { SupportResource } from './resources/support.cjs';
49
+ export { SupportAttachment, SupportChannel, SupportConversation, SupportConversationStatus, SupportFile, SupportMessage, SupportMessageStatus, SupportRatingRequest } from './resources/support.cjs';
44
50
  export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.cjs';
45
51
 
46
52
  /**
@@ -73,7 +79,7 @@ interface BrandConfig {
73
79
  * Which platform versions this SDK works with, as a semver range:
74
80
  * comparators separated by ", ". Keep this the only definition.
75
81
  */
76
- declare const SUPPORTED_MEISTER = ">=0.6.9, <0.7.0";
82
+ declare const SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
77
83
  /** What `client.ready()` returns. */
78
84
  interface ReadyInfo {
79
85
  /** `true` when the platform reported a version inside `supportedMeister`. */
@@ -179,7 +185,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
179
185
  * `define`. `src/version.test.ts` checks it matches `package.json`, so a
180
186
  * release bump that forgets this file fails the test run.
181
187
  */
182
- declare const SDK_VERSION = "0.6.4";
188
+ declare const SDK_VERSION = "0.6.6";
183
189
 
184
190
  /**
185
191
  * `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
@@ -242,6 +248,10 @@ interface CusfrontClient {
242
248
  readonly balance: BalanceResource;
243
249
  /** Bonuses: a discount on the platform's services. Balance, credits, history and a price preview. */
244
250
  readonly bonus: BonusResource;
251
+ /** Card fees the user's cards could not cover: paid first from the next top-up. */
252
+ readonly debt: DebtResource;
253
+ /** Close a card that still holds money: the rest goes back the way it was paid. */
254
+ readonly closeRequests: CloseRequestsResource;
245
255
  /** Promo and referral codes: check what a code would do before using it. */
246
256
  readonly codes: CodesResource;
247
257
  /** For referrers: the referral code, the link to share, invited friends and rewards. */
@@ -279,6 +289,8 @@ interface CusfrontClient {
279
289
  readonly consents: ConsentsResource;
280
290
  /** A numbered receipt for every payment. */
281
291
  readonly receipts: ReceiptsResource;
292
+ /** The chat with support: messages, files, the conversation's status. */
293
+ readonly support: SupportResource;
282
294
  /** Direct access to the token store (e.g. for an explicit sign-out
283
295
  * on Capacitor's lifecycle "app pausing" event). */
284
296
  readonly tokens: TokenStore;
@@ -309,4 +321,4 @@ interface CusfrontClient {
309
321
  */
310
322
  declare function createClient(opts: CreateClientOptions): CusfrontClient;
311
323
 
312
- export { ApiError, type BrandConfig, ClientDescriptor, ConsentsResource, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ReceiptsResource, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
324
+ export { ApiError, type BrandConfig, ClientDescriptor, ConsentsResource, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ReceiptsResource, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, SupportResource, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,17 @@
1
- import { T as TokenStore, F as FetchLike } from './http-DeANAoTs.js';
2
- export { d as defaultBrowserStore, i as inMemoryStore } from './http-DeANAoTs.js';
1
+ import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.js';
2
+ export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.js';
3
3
  import { AuthResource } from './resources/auth.js';
4
4
  export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.js';
5
- import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-BrqeBqLV.js';
6
- export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardLoadStatus, h as CardOrder, i as CardOrderError, j as CardOrderInput, C as CardProduct, k as CardProductPrice, l as CardStatus, m as CardStatusSource, n as CardTopUp, o as CardTopUpStatus, p as CardTransfer, q as CardType, r as Cardholder, s as CloseBlockedReason, t as CreateCardInput, u as CreateDepositRefundInput, v as CreateQuoteInput, w as CustomerInfo, D as Deposit, x as DepositMethod, y as DepositStatus, z as DepositTarget, E as FeeKind, G as FunderMode, H as FundingOption, I as FundingQuote, J as InitiateDepositInput, K as IssuanceBonus, L as IssueCardInput, M as MethodTerms, R as Refund, N as RevealCardInput, O as RevealedCard, S as SetPinInput, T as TopUpInput, P as TopUpResult, Q as TopUpTerms, U as TransferInput, V as TransferResult, W as UpdateCardInput } from './cards-BrqeBqLV.js';
5
+ import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-DwmzjKDC.js';
6
+ export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput } from './cards-DwmzjKDC.js';
7
7
  import { BalanceResource } from './resources/balance.js';
8
8
  export { Balance } from './resources/balance.js';
9
9
  import { BonusResource } from './resources/bonus.js';
10
10
  export { BonusLot, BonusMovement, BonusPreview, BonusPreviewInput, BonusPurpose, BonusTarget, BonusWallet } from './resources/bonus.js';
11
+ import { DebtResource } from './resources/debt.js';
12
+ export { CardFeeKind, Debt, DebtAmount, DebtLine } from './resources/debt.js';
13
+ import { CloseRequestsResource } from './resources/close-requests.js';
14
+ export { CloseAmount, CloseRefund, CloseRequest, CloseRequestError, CloseRequestStatus, PayoutDetailsInput, PayoutDetailsShown } from './resources/close-requests.js';
11
15
  import { CodesResource } from './resources/codes.js';
12
16
  export { CodeCheck, CodeDiscount, CodeEffect, CodeEffectOutcome, CodeOperation, CodeRejection, CodeResult, ValidateCodeInput } from './resources/codes.js';
13
17
  import { ReferralResource } from './resources/referral.js';
@@ -31,16 +35,18 @@ export { PushCapableRegistration, PushStatus, PushSubscriptionInput } from './re
31
35
  import { MeResource } from './resources/me.js';
32
36
  import { NotificationsResource } from './resources/notifications.js';
33
37
  export { CardOtpData, InboxItem, ListNotificationsParams, NotificationCategory, NotificationCategoryPreferences, NotificationChannel, NotificationLocale, NotificationPage, NotificationPreferences, NotificationPreferencesInput, isCardOtp } from './resources/notifications.js';
34
- import { C as ClientDescriptor, R as ResolvedClientDescriptor, D as DevicesResource } from './devices-B_YveTl9.js';
35
- export { a as CLIENT_HEADER, b as ClientPlatform, c as Device, d as DeviceKind, e as DevicePlatform, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, i as detectClientPlatform } from './devices-B_YveTl9.js';
38
+ import { C as ClientDescriptor, R as ResolvedClientDescriptor, D as DevicesResource } from './devices-C88c38hm.js';
39
+ export { a as CLIENT_HEADER, b as ClientPlatform, c as Device, d as DeviceKind, e as DevicePlatform, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, i as detectClientPlatform } from './devices-C88c38hm.js';
36
40
  import { AttributionResource } from './resources/attribution.js';
37
41
  export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, anonymousKey, currentTouch } from './resources/attribution.js';
38
42
  import { HistoryResource } from './resources/history.js';
39
43
  export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.js';
40
44
  import { ConsentsResource } from './resources/consents.js';
41
- export { ConsentChannel, ConsentDocument, ConsentKind, ConsentState, Consents, CookieChoiceInput } from './resources/consents.js';
45
+ export { ConsentChannel, ConsentDocument, ConsentKind, ConsentOptions, ConsentState, Consents, CookieChoiceInput, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT } from './resources/consents.js';
42
46
  import { ReceiptsResource } from './resources/receipts.js';
43
47
  export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.js';
48
+ import { SupportResource } from './resources/support.js';
49
+ export { SupportAttachment, SupportChannel, SupportConversation, SupportConversationStatus, SupportFile, SupportMessage, SupportMessageStatus, SupportRatingRequest } from './resources/support.js';
44
50
  export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.js';
45
51
 
46
52
  /**
@@ -73,7 +79,7 @@ interface BrandConfig {
73
79
  * Which platform versions this SDK works with, as a semver range:
74
80
  * comparators separated by ", ". Keep this the only definition.
75
81
  */
76
- declare const SUPPORTED_MEISTER = ">=0.6.9, <0.7.0";
82
+ declare const SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
77
83
  /** What `client.ready()` returns. */
78
84
  interface ReadyInfo {
79
85
  /** `true` when the platform reported a version inside `supportedMeister`. */
@@ -179,7 +185,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
179
185
  * `define`. `src/version.test.ts` checks it matches `package.json`, so a
180
186
  * release bump that forgets this file fails the test run.
181
187
  */
182
- declare const SDK_VERSION = "0.6.4";
188
+ declare const SDK_VERSION = "0.6.6";
183
189
 
184
190
  /**
185
191
  * `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
@@ -242,6 +248,10 @@ interface CusfrontClient {
242
248
  readonly balance: BalanceResource;
243
249
  /** Bonuses: a discount on the platform's services. Balance, credits, history and a price preview. */
244
250
  readonly bonus: BonusResource;
251
+ /** Card fees the user's cards could not cover: paid first from the next top-up. */
252
+ readonly debt: DebtResource;
253
+ /** Close a card that still holds money: the rest goes back the way it was paid. */
254
+ readonly closeRequests: CloseRequestsResource;
245
255
  /** Promo and referral codes: check what a code would do before using it. */
246
256
  readonly codes: CodesResource;
247
257
  /** For referrers: the referral code, the link to share, invited friends and rewards. */
@@ -279,6 +289,8 @@ interface CusfrontClient {
279
289
  readonly consents: ConsentsResource;
280
290
  /** A numbered receipt for every payment. */
281
291
  readonly receipts: ReceiptsResource;
292
+ /** The chat with support: messages, files, the conversation's status. */
293
+ readonly support: SupportResource;
282
294
  /** Direct access to the token store (e.g. for an explicit sign-out
283
295
  * on Capacitor's lifecycle "app pausing" event). */
284
296
  readonly tokens: TokenStore;
@@ -309,4 +321,4 @@ interface CusfrontClient {
309
321
  */
310
322
  declare function createClient(opts: CreateClientOptions): CusfrontClient;
311
323
 
312
- export { ApiError, type BrandConfig, ClientDescriptor, ConsentsResource, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ReceiptsResource, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
324
+ export { ApiError, type BrandConfig, ClientDescriptor, ConsentsResource, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ReceiptsResource, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, SupportResource, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
package/dist/index.js CHANGED
@@ -71,10 +71,20 @@ var HttpClient = class {
71
71
  async delete(path, opts = {}) {
72
72
  return this.request("DELETE", path, opts);
73
73
  }
74
+ /** GET a file. Same auth and refresh as the JSON calls; an error status
75
+ * throws `ApiError` the same way. */
76
+ async getBlob(path, opts = {}) {
77
+ const resp = await this.send("GET", path, { ...opts, accept: "*/*" });
78
+ if (!resp.ok) return parseResponse(resp);
79
+ return resp.blob();
80
+ }
74
81
  async request(method, path, opts) {
82
+ return parseResponse(await this.send(method, path, opts));
83
+ }
84
+ async send(method, path, opts) {
75
85
  const url = this.absolute(path);
76
86
  const headers = {
77
- Accept: "application/json",
87
+ Accept: opts.accept ?? "application/json",
78
88
  ...this.defaultHeaders
79
89
  };
80
90
  if (opts.body !== void 0) headers["Content-Type"] = "application/json";
@@ -100,10 +110,10 @@ var HttpClient = class {
100
110
  }
101
111
  if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
102
112
  if (await this.refreshOnce()) {
103
- return this.request(method, path, { ...opts, retried: true });
113
+ return this.send(method, path, { ...opts, retried: true });
104
114
  }
105
115
  }
106
- return parseResponse(resp);
116
+ return resp;
107
117
  }
108
118
  absolute(path) {
109
119
  if (path.startsWith("http://") || path.startsWith("https://")) return path;
@@ -184,6 +194,8 @@ var CardsResource = class {
184
194
  * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
185
195
  * to `failed` (never an orphaned active card); inspect `status` /
186
196
  * `failure_reason` on the result.
197
+ * Errors: 409 `holder_data_consent_required` when the product has
198
+ * `holder_data_required` and the user has not agreed to it.
187
199
  */
188
200
  async create(input) {
189
201
  const { idempotencyKey, ...card } = input;
@@ -199,7 +211,9 @@ var CardsResource = class {
199
211
  * `pending_payment` until the payment is confirmed. The same
200
212
  * `idempotencyKey` returns the same order.
201
213
  * Errors: 400 `unknown_product` / `method_not_available` / a limit of the
202
- * way of paying, 503 no funding connector or no exchange rate.
214
+ * way of paying, 409 `holder_data_consent_required` (the product has
215
+ * `holder_data_required` and the user has not agreed to it), 503 no
216
+ * funding connector or no exchange rate.
203
217
  */
204
218
  async order(input) {
205
219
  const { idempotencyKey, ...order } = input;
@@ -361,7 +375,10 @@ var CardsResource = class {
361
375
  /**
362
376
  * Terminate the caller's own card. **One-way** — a terminated card cannot be
363
377
  * reactivated. The optional `reason` is audited. Idempotent on an
364
- * already-terminated card.
378
+ * already-terminated card. A card that still holds money is refused (409
379
+ * `move_balance_first` or `contact_support_to_close`): close it with
380
+ * `client.closeRequests.request(id)` instead, and the money goes back the
381
+ * way it was paid.
365
382
  */
366
383
  async terminate(id, reason) {
367
384
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
@@ -728,6 +745,72 @@ var BonusResource = class {
728
745
  }
729
746
  };
730
747
 
748
+ // src/resources/debt.ts
749
+ var DebtResource = class {
750
+ constructor(http) {
751
+ this.http = http;
752
+ }
753
+ /** What the user owes in card fees, per currency, and what for. */
754
+ async get(opts = {}) {
755
+ return this.http.get("/me/debt", { signal: opts.signal });
756
+ }
757
+ /** What the user owes in `currency`, decimal string; `"0"` when nothing. */
758
+ async owedIn(currency, opts = {}) {
759
+ const debt = await this.get(opts);
760
+ const want = currency.trim().toUpperCase();
761
+ return debt.total.find((d) => d.currency.toUpperCase() === want)?.amount ?? "0";
762
+ }
763
+ };
764
+
765
+ // src/resources/close-requests.ts
766
+ var CloseRequestsResource = class {
767
+ constructor(http) {
768
+ this.http = http;
769
+ }
770
+ /**
771
+ * Close a card that holds money, the rest going back the way it was paid.
772
+ * Asking again for the same card returns the same request. 404 no such
773
+ * card · 409 {@link CloseRequestError}: `no_balance` means the card holds
774
+ * nothing, close it with `cards.terminate()` · 503 the issuer can't be
775
+ * reached; the card stays as it was.
776
+ */
777
+ async request(cardId, input = {}) {
778
+ return this.http.post(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {
779
+ body: { reason: input.reason }
780
+ });
781
+ }
782
+ /** Every card close request of the user, newest first. */
783
+ async list(opts = {}) {
784
+ const res = await this.http.get("/me/close-requests", {
785
+ signal: opts.signal
786
+ });
787
+ return res.items;
788
+ }
789
+ /** One close request. 404 when it isn't the user's. */
790
+ async get(id, opts = {}) {
791
+ return this.http.get(`/me/close-requests/${encodeURIComponent(id)}`, {
792
+ signal: opts.signal
793
+ });
794
+ }
795
+ /** The request for this card, if the user made one. */
796
+ async forCard(cardId, opts = {}) {
797
+ const all = await this.list(opts);
798
+ return all.find((r) => r.card_id === cardId) ?? null;
799
+ }
800
+ /**
801
+ * Give a bank account or a card in the user's own name, when the request
802
+ * is `payout_details_required` (or `identity_check`, to correct them). 400
803
+ * `validation`: a name, number or bank code that doesn't look right · 409
804
+ * `details_not_needed`.
805
+ */
806
+ async submitPayoutDetails(id, details) {
807
+ return this.http.post(
808
+ `/me/close-requests/${encodeURIComponent(id)}/payout-details`,
809
+ { body: details }
810
+ );
811
+ }
812
+ };
813
+
731
814
  // src/resources/codes.ts
732
815
  var CodesResource = class {
733
816
  constructor(http) {
@@ -1259,6 +1342,8 @@ var HistoryResource = class {
1259
1342
  };
1260
1343
 
1261
1344
  // src/resources/consents.ts
1345
+ var HOLDER_DATA_CONSENT = "holder_data_transfer";
1346
+ var DISPUTE_DOCUMENTS_CONSENT = "dispute_documents_transfer";
1262
1347
  var ConsentsResource = class {
1263
1348
  constructor(http) {
1264
1349
  this.http = http;
@@ -1267,20 +1352,51 @@ var ConsentsResource = class {
1267
1352
  async get() {
1268
1353
  return this.http.get("/me/consents");
1269
1354
  }
1355
+ /** Whether `kind` stands now: given and not withdrawn since. */
1356
+ async stands(kind) {
1357
+ const { consents } = await this.get();
1358
+ return consents.some((c) => c.kind === kind && c.given);
1359
+ }
1270
1360
  /**
1271
- * Give (`true`) or withdraw (`false`) an optional consent: `marketing` or
1272
- * `cookies_analytics`. Withdrawing `marketing` turns advertising off in
1273
- * every channel at once; giving it turns on advertising by e-mail. A call
1274
- * that changes nothing records nothing.
1361
+ * Give (`true`) or withdraw (`false`) an optional consent: `marketing`,
1362
+ * `cookies_analytics`, `holder_data_transfer` or
1363
+ * `dispute_documents_transfer`. Withdrawing `marketing` turns advertising
1364
+ * off in every channel at once; giving it turns on advertising by e-mail.
1365
+ * Withdrawing `holder_data_transfer` leaves the user's cards alone and
1366
+ * stops new cards whose product has `holder_data_required`. A call that
1367
+ * changes nothing records nothing, unless it names a card.
1368
+ *
1369
+ * The third argument is the channel, or {@link ConsentOptions} with the
1370
+ * channel and the card.
1275
1371
  *
1276
1372
  * Errors: 400 `consent_required` for `terms` or `personal_data`,
1277
- * 400 `unknown_consent`.
1373
+ * 400 `unknown_consent`, 400 `card_not_allowed` (a card named with a kind
1374
+ * that takes none), 404 `not_found` (not one of the user's cards).
1278
1375
  */
1279
- async set(kind, given, channel) {
1376
+ async set(kind, given, options) {
1377
+ const opts = typeof options === "string" ? { channel: options } : options ?? {};
1280
1378
  const body = { kind, given };
1281
- if (channel !== void 0) body.channel = channel;
1379
+ if (opts.channel !== void 0) body.channel = opts.channel;
1380
+ if (opts.cardId !== void 0) body.card_id = opts.cardId;
1282
1381
  return this.http.post("/me/consents", { body });
1283
1382
  }
1383
+ /**
1384
+ * The user agreed on the consent screen that their real personal details
1385
+ * go to the card issuer (`holder_data_transfer`). Needed before ordering a
1386
+ * product with `holder_data_required`, unless the order itself carries the
1387
+ * kind in its `consents`.
1388
+ */
1389
+ async allowHolderData(options) {
1390
+ return this.set(HOLDER_DATA_CONSENT, true, options);
1391
+ }
1392
+ /**
1393
+ * The user agreed that their documents go to the card issuer for a
1394
+ * dispute (`dispute_documents_transfer`). Name the disputed card with
1395
+ * `cardId`; each call is then recorded on its own.
1396
+ */
1397
+ async allowDisputeDocuments(options) {
1398
+ return this.set(DISPUTE_DOCUMENTS_CONSENT, true, options);
1399
+ }
1284
1400
  /**
1285
1401
  * Record what the cookie banner or the cookie settings say about
1286
1402
  * analytics. Works signed in or not: before sign-in the choice is kept
@@ -1321,6 +1437,70 @@ var ReceiptsResource = class {
1321
1437
  }
1322
1438
  };
1323
1439
 
1440
+ // src/resources/support.ts
1441
+ function bytesToBase64(bytes) {
1442
+ let binary = "";
1443
+ const chunk = 32768;
1444
+ for (let i = 0; i < bytes.length; i += chunk) {
1445
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
1446
+ }
1447
+ return btoa(binary);
1448
+ }
1449
+ async function toBase64(data) {
1450
+ if (typeof data === "string") return data;
1451
+ if (data instanceof Uint8Array) return bytesToBase64(data);
1452
+ if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
1453
+ return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
1454
+ }
1455
+ var SupportResource = class {
1456
+ constructor(http) {
1457
+ this.http = http;
1458
+ }
1459
+ /** The latest messages, oldest first, and the conversation's status.
1460
+ * `before` reads further back; `limit` is 1 to 100 (50). */
1461
+ async list(opts = {}) {
1462
+ const q = new URLSearchParams();
1463
+ if (opts.before) q.set("before", opts.before);
1464
+ if (opts.limit !== void 0) q.set("limit", String(opts.limit));
1465
+ const qs = q.toString();
1466
+ return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
1467
+ signal: opts.signal
1468
+ });
1469
+ }
1470
+ /** Write to support. Text, files or both; up to 10 files. */
1471
+ async send(message, opts = {}) {
1472
+ const attachments = await Promise.all(
1473
+ (message.files ?? []).map(async (f) => ({
1474
+ file_name: f.fileName,
1475
+ content_type: f.contentType,
1476
+ data_base64: await toBase64(f.data)
1477
+ }))
1478
+ );
1479
+ return this.http.post("/me/support/messages", {
1480
+ body: { text: message.text ?? "", attachments },
1481
+ signal: opts.signal
1482
+ });
1483
+ }
1484
+ /** A file from the conversation: the person's own or one support sent. */
1485
+ async attachment(id, opts = {}) {
1486
+ return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
1487
+ signal: opts.signal
1488
+ });
1489
+ }
1490
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
1491
+ * wrote one. Each question takes one answer; a second one is a 404. */
1492
+ async rate(id, answer, opts = {}) {
1493
+ await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
1494
+ body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
1495
+ signal: opts.signal
1496
+ });
1497
+ }
1498
+ /** Just the conversation's status. */
1499
+ async status(opts = {}) {
1500
+ return (await this.list({ limit: 1, signal: opts.signal })).status;
1501
+ }
1502
+ };
1503
+
1324
1504
  // src/resources/funding-options.ts
1325
1505
  var FundingOptionsResource = class {
1326
1506
  constructor(http) {
@@ -1333,7 +1513,7 @@ var FundingOptionsResource = class {
1333
1513
  };
1334
1514
 
1335
1515
  // src/version.ts
1336
- var SDK_VERSION = "0.6.4";
1516
+ var SDK_VERSION = "0.6.6";
1337
1517
 
1338
1518
  // src/client-platform.ts
1339
1519
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1408,7 +1588,7 @@ function isAbsolute(url) {
1408
1588
  }
1409
1589
 
1410
1590
  // src/compat.ts
1411
- var SUPPORTED_MEISTER = ">=0.6.9, <0.7.0";
1591
+ var SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
1412
1592
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1413
1593
  function parse(v) {
1414
1594
  const m = SEMVER.exec(v.trim());
@@ -1921,6 +2101,8 @@ function createClient(opts) {
1921
2101
  cards: new CardsResource(http),
1922
2102
  balance: new BalanceResource(http),
1923
2103
  bonus: new BonusResource(http),
2104
+ debt: new DebtResource(http),
2105
+ closeRequests: new CloseRequestsResource(http),
1924
2106
  codes: new CodesResource(http),
1925
2107
  referral: new ReferralResource(http),
1926
2108
  subscription: new SubscriptionResource(http),
@@ -1937,7 +2119,8 @@ function createClient(opts) {
1937
2119
  attribution: new AttributionResource(http),
1938
2120
  history: new HistoryResource(http),
1939
2121
  consents: new ConsentsResource(http),
1940
- receipts: new ReceiptsResource(http)
2122
+ receipts: new ReceiptsResource(http),
2123
+ support: new SupportResource(http)
1941
2124
  };
1942
2125
  }
1943
2126
  function pickDefaultStore(key) {
@@ -1955,6 +2138,6 @@ function defaultFetch() {
1955
2138
  );
1956
2139
  }
1957
2140
 
1958
- export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, page, posthogDistinctId, resetAnalytics, resolveAssetUrl, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsZone, track };
2141
+ export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, page, posthogDistinctId, resetAnalytics, resolveAssetUrl, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsZone, track };
1959
2142
  //# sourceMappingURL=index.js.map
1960
2143
  //# sourceMappingURL=index.js.map