@takeal/cusfront-sdk 0.6.8 → 0.6.11
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.
- package/CHANGELOG.md +39 -2
- package/README.md +23 -7
- package/dist/{cards-BgY00UpU.d.ts → cards-CuUdrQ0H.d.ts} +48 -7
- package/dist/{cards-DGz4Rqu1.d.cts → cards-nXmDP0ei.d.cts} +48 -7
- package/dist/index.cjs +19 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +1 -1
- package/dist/resources/auth.d.ts +1 -1
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +17 -4
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +1 -1
- package/dist/resources/cards.d.ts +1 -1
- package/dist/resources/cards.js +17 -5
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +1 -1
- package/dist/resources/funding-options.d.ts +1 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +18 -6
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +1 -1
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +18 -6
- package/dist/telegram.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/error.ts","../../src/resources/cards.ts","../../src/resources/auth.ts"],"names":[],"mappings":";AA2CO,SAAS,WAAW,CAAA,EAA2B;AACpD,EAAA,OAAO,OAAO,C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AAA,CAAK,UAAA,GAAa,MAAM,OAAA,CAAQ,QAAQ,IAAA,CAAK,UAAA,CAAW,GAAA,EAAK,CAAA,GAAI,IAAA;AAClF,IAAA,IAAI;AACF,MAAA,MAAM,IAAA,CAAK,IAAA,CAAK,IAAA,CAAW,cAAA,EAAgB;AAAA,QACzC,MAAM,QAAA,GAAW,EAAE,cAAA,EAAgB,QAAA,KAAa,EAAC;AAAA,QACjD,OAAA,EAAS;AAAA,OACV,CAAA;AAAA,IACH,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA;AACzC,IAAA,IAAI,IAAA,CAAK,YAAY,MAAM,OAAA,CAAQ,QAAQ,IAAA,CAAK,UAAA,CAAW,OAAO,CAAA;AAAA,EACpE;AACF","file":"auth.js","sourcesContent":["/**\n * Errors surfaced by the SDK. All HTTP failures map onto `ApiError`;\n * network-level / abort / serialisation failures get the generic\n * `NetworkError`. Consumers catch on the discriminator field\n * (`isApiError` / `isNetworkError`) rather than `instanceof` — works\n * across bundler boundaries where multiple copies of the class can\n * coexist.\n */\nexport class ApiError extends Error {\n readonly isApiError = true as const;\n\n constructor(\n /** HTTP status code returned by the Takeal API. */\n public readonly status: number,\n /** Stable machine-readable code (e.g. `\"insufficient_funds\"`,\n * `\"permission_required\"`, `\"validation\"`). Same enum the\n * TypeScript types pin via openapi-typescript. */\n public readonly code: string,\n /** Human-readable message. English; the consumer maps to its\n * own i18n layer before showing to end-users. */\n message: string,\n /** Full parsed response body when available. Carries field-level\n * validation details for `code = \"validation\"`. */\n public readonly body?: unknown,\n ) {\n super(message);\n this.name = \"ApiError\";\n }\n}\n\nexport class NetworkError extends Error {\n readonly isNetworkError = true as const;\n\n constructor(\n message: string,\n public readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"NetworkError\";\n }\n}\n\n/** Type guard — preferred over `instanceof` (bundler-safe). */\nexport function isApiError(e: unknown): e is ApiError {\n return typeof e === \"object\" && e !== null && (e as { isApiError?: boolean }).isApiError === true;\n}\n\nexport function isNetworkError(e: unknown): e is NetworkError {\n return (\n typeof e === \"object\" &&\n e !== null &&\n (e as { isNetworkError?: boolean }).isNetworkError === true\n );\n}\n","import type { Claim } from \"./claims.js\";\nimport type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\nimport type { Deposit, DepositMethod } from \"./deposits.js\";\n\n/**\n * Cards resource — `client.cards.*`.\n *\n * The end-user \"money OUT\" surface: a user issues themselves a card backed by\n * their wallet balance via an issuer connector. Mirrors the Takeal API's\n * `/me/cards` routes:\n *\n * GET /card-products → catalog (public, before sign-in)\n * GET /me/card-products → listProducts (the catalog, personal price)\n * GET /me/card-products/{id} → getProduct\n * GET /me/cards/{id}/topup → topUpTerms\n * POST /me/cards/{id}/topup → topUp\n * POST /me/cards → create\n * GET /me/cards → list (most recent first)\n * GET /me/cards/{id} → get\n * PATCH /me/cards/{id} → update (name, design)\n * GET /me/cards/{id}/balance → balance (prepaid remaining)\n * POST /me/cards/{id}/freeze → freeze\n * POST /me/cards/{id}/unfreeze → unfreeze\n * POST /me/cards/{id}/report-lost → reportLost (lost or stolen: frozen at once)\n * POST /me/cards/{id}/transfer → transfer (to another of their cards)\n * POST /me/cards/{id}/terminate → terminate (one-way)\n * POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)\n * POST /me/cards/{id}/pin → setPin (physical cards)\n *\n * The lifecycle actions are ownership-gated server-side: a caller can only\n * freeze / unfreeze / terminate a card that belongs to them (else 404).\n *\n * Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from\n * the Takeal API until their issuer flows land.\n */\n\n/** Card product. Only `prepaid` is fully implemented today. */\nexport type CardType = \"credit\" | \"prepaid\" | \"gift\";\n\n/**\n * Card lifecycle state.\n *\n * - `pending_payment`: the row exists but the issuance fee has not been\n * paid yet; the provider has not been called and nothing is visible.\n * - `pending`: the issuer accepted the order and has not issued the card\n * yet. The price is charged. Show the card as \"being issued\" with no\n * numbers; it becomes `active` on its own, or `failed` with the price\n * back on the wallet. Some issuers take minutes, some a day.\n * - `active`, `frozen`: the usual states. Read `status_source` before\n * offering to unfreeze.\n * - `terminating`: the holder (or the issuer) closed the card and the\n * issuer has not finished: the balance comes back to the wallet when it\n * does. Show it as closing; no actions apply.\n * - `terminated`, `redeemed`, `failed`: final.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"pending\"\n | \"active\"\n | \"frozen\"\n | \"terminating\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\n\n/**\n * Who made the card's last status change. `provider` on a `frozen` card\n * means the issuer froze it (a risk check, a lost-card report): the holder\n * cannot unfreeze it, so do not offer the button; say the freeze is lifted\n * through the issuer's support. `holder` and `operator` freezes are undone\n * with `unfreeze()` as usual.\n */\nexport type CardStatusSource = \"holder\" | \"operator\" | \"provider\";\n\n/** `virtual` cards show their numbers in the app; `physical` cards are plastic and have a PIN. */\nexport type CardForm = \"virtual\" | \"physical\";\n\n/**\n * Why `terminate()` is refused right now: `first_purchase_required` (the\n * card closes after its first purchase) or `card_locked` (only support can\n * change it).\n */\nexport type CloseBlockedReason = \"first_purchase_required\" | \"card_locked\";\n\n/**\n * A card design: the artwork a card is shown with. `image_url` is the front,\n * `image_url_back` the back; both are either absolute URLs or paths relative\n * to the API origin (the deployment's default design is\n * `/card-designs/default.svg`, its back `/card-designs/default.svg?side=back`)\n * — pass them through `client.assetUrl()` before rendering. `image_url_back`\n * is `null` or absent for a one-sided design: show the front on both sides.\n * The picture is in the proportions of a plastic card (1586×1000) and draws\n * no chip or card data; the client renders the number, name and expiry on\n * top. `id` is `null` for the deployment default, which is rendered from the\n * branding settings.\n */\nexport interface CardDesignRef {\n id: string | null;\n name?: string;\n image_url: string;\n image_url_back?: string | null;\n}\n\n/**\n * What issuing a card costs the caller. `amount` is the price after the\n * user's subscription discount; `base_amount` is the list price and\n * `discount_bps` the discount in basis points (1000 = 10 %). `label` is the\n * operator's wording for the fee line (\"Card issuance\").\n */\nexport interface CardProductPrice {\n /** What the user pays, decimal string, after their subscription discount. */\n amount: string;\n /**\n * ISO 4217 code: the currency the buyer pays in. A signed-in user sees\n * their wallet currency, converted the way issuance will charge it; the\n * public catalog shows the currency the operator priced the card in. It\n * is not necessarily the currency the card is held in (`CardProduct.currency`).\n */\n currency: string;\n /** Wording for the fee line, e.g. \"Card issuance\". */\n label: string;\n /** The list price before the discount, decimal string, in the same currency. */\n base_amount: string;\n /** Discount applied, in basis points (1000 = 10%). */\n discount_bps: number;\n}\n\n/**\n * A card the user can order, as listed by `GET /me/card-products`. The id is\n * opaque — it names a product, never a provider. The list comes in the\n * order the operator arranged the storefront; `is_default` marks the\n * product issued when none is chosen, wherever it sits. `designs` is the\n * set the user may pick from (may be empty when only the default applies);\n * `design` is what the card gets when no choice is made. `price` is `null`\n * for a free card. `features` is an operator-defined object (scheme, wallet\n * support, load limits, …) with no fixed keys.\n */\nexport interface CardProduct {\n id: string;\n name: string;\n /** One line under the name on the tile, or `null`. */\n tagline: string | null;\n description: string | null;\n /** Selling points to list on the product card, in order. May be empty. */\n benefits: string[];\n /**\n * Picture for the product tile, absolute URL, or `null`: show the card\n * design (`design.image_url`) then.\n */\n tile_image_url: string | null;\n card_type: CardType;\n currency: string | null;\n features: Record<string, unknown>;\n design: CardDesignRef;\n designs: CardDesignRef[];\n price: CardProductPrice | null;\n /**\n * The balance a new card comes with, already included in `price`; `null`\n * when the card starts empty and is funded with `topUp()` afterwards.\n */\n starting_balance: CardBalance | null;\n /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\n /**\n * Issuing this card sends the user's real personal details to the card\n * issuer. Show the consent screen before the order and send\n * `holder_data_transfer` in its `consents` (or give it once with\n * `client.consents.allowHolderData()`); without it the order fails with\n * 409 `holder_data_consent_required`. `false`: the issuer gets no real\n * details and no extra consent is asked.\n */\n holder_data_required: boolean;\n /**\n * What a card on this product costs to use, on top of the payments\n * themselves. A fee the card can't cover is owed and paid from the next\n * top-up (see `client.debt`). Every line is `\"0\"` when the product\n * charges nothing for it.\n */\n tariff: CardTariff;\n}\n\n/**\n * A card product's fees for using the card. Decimal strings: the fixed\n * amounts are in `currency` (the card's), the shares in percent of the\n * operation's amount.\n */\nexport interface CardTariff {\n /** `null` for a product held in several currencies: the card's own then. */\n currency: string | null;\n /** Per settled card payment, fixed. */\n operation_fixed: string;\n /** Per settled card payment, percent of its amount. */\n operation_percent: string;\n /**\n * Per payment declined through the user's own doing: not enough money,\n * wrong card details, a frozen card, a subscription not cancelled with the\n * merchant. A decline caused by the issuer or the platform costs nothing.\n */\n decline: string;\n /** Per cash withdrawal, fixed; charged instead of the payment fee. */\n cash_withdrawal_fixed: string;\n /** Per cash withdrawal, percent of its amount. */\n cash_withdrawal_percent: string;\n}\n\n/**\n * A card record as the Takeal API returns it. Mirrors the `cards` table. Note the\n * SDK never receives the full PAN or CVV here — only `last4` + expiry. The\n * gift-card `redemption_code` is returned exactly once (on create) and\n * scrubbed from subsequent list/get responses.\n */\nexport interface Card {\n id: string;\n user_id: string;\n card_type: CardType;\n status: CardStatus;\n /** Last four digits of the PAN — safe to display. */\n last4: string | null;\n expiry_month: number | null;\n expiry_year: number | null;\n /** Gift cards only, present once on create then scrubbed. */\n redemption_code?: string;\n /** The balance the card was issued with, decimal string; `null` or `\"0\"` for a card issued empty. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | null;\n /** Who changed the status last; `null` when it never changed. See {@link CardStatusSource}. */\n status_source: CardStatusSource | null;\n /** Virtual or plastic. A `physical` card takes a PIN with {@link CardsResource.setPin}. */\n card_form: CardForm;\n /** Why the card cannot be closed right now, or `null` when it can. */\n close_blocked: CloseBlockedReason | null;\n /**\n * Top-ups the issuer has accepted and not loaded yet, summed, decimal\n * string in `currency`; `null` when there are none. Show it next to the\n * balance as money on its way to the card.\n */\n topups_pending: string | null;\n /**\n * Top-ups the issuer has held for too long, summed, decimal string in\n * `currency`; `null` when there are none. The money is safe and waits for\n * support to settle it; say so instead of offering a retry.\n */\n topups_held: string | null;\n /**\n * The card this one replaced: support reissued it for free because that\n * card stopped working before its term. `null` otherwise.\n */\n reissued_from_card_id?: string | null;\n /** The card support issued to replace this one, or `null`. */\n reissued_to_card_id?: string | null;\n /**\n * What was left on the card this one replaced, on its way here. Show it as\n * money in transit next to the balance, not as part of it. `null` when\n * nothing is on its way.\n */\n in_transit?: CardInTransit | null;\n /** The name the user gave the card, or `null`. */\n name: string | null;\n /** The artwork the card is shown with. Always present. */\n design: CardDesignRef;\n /** The product the card was issued from; `null` for cards issued without one. */\n product: { id: string; name: string } | null;\n created_at: string;\n updated_at: string;\n /** Only on the result of `create`, when bonuses paid part of the price. */\n bonus?: IssuanceBonus;\n}\n\n/**\n * The balance of a closed card on its way to the card that replaced it. It\n * waits for the old card's issuer to return the money (`stage: \"issuer\"`),\n * then it is loaded onto this card (`stage: \"loading\"`); once it is there,\n * `in_transit` is `null` and the card's balance has it. The move is in the\n * history as a `closed_card_balance` entry.\n */\nexport interface CardInTransit {\n /** Decimal string in `currency`. What the issuer returned once it did; before that, what the old card held. */\n amount: string;\n currency: string;\n /** The closed card the money comes from. */\n from_card_id: string;\n stage: \"issuer\" | \"loading\" | (string & {});\n}\n\n/** How bonuses changed a new card's price (\"was / now\"). Decimal strings in `currency`. */\nexport interface IssuanceBonus {\n /** Bonuses used. */\n units: string;\n /** The price before bonuses (\"was\"). */\n price: string;\n /** What the bonuses covered. */\n covered: string;\n /** What the wallet paid (\"now\"). */\n paid: string;\n currency: string;\n}\n\nexport interface CreateCardInput {\n /**\n * A product id from {@link CardsResource.listProducts}. Sent as\n * `product_id`. When given, `type` and `issuer_slug` may be omitted; when\n * both are given they must agree with the product (400 `product_mismatch`).\n * Unknown, disabled or hidden product → 400 `unknown_product`.\n */\n productId?: string;\n /** A name for the card, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * One of the product's `designs`. Sent as `design_id`. `null` or omitted\n * picks the product's default design; a design outside the product's set →\n * 400 `design_not_allowed`.\n */\n designId?: string | null;\n /**\n * `prepaid` (the only fully-wired type today), `credit`, or `gift`.\n * Optional when `productId` is given, required otherwise.\n */\n type?: CardType;\n /**\n * @deprecated Ignored since 0.3.21. A card is issued for its product price;\n * the balance it starts with, if the product includes one, is part of that\n * price (see `CardProduct.starting_balance`). Money is added afterwards\n * with {@link CardsResource.topUp}. The field is no longer sent.\n */\n initial_amount?: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n /**\n * Optional. Slug of a specific issuer to mint with. Omit to let\n * the Takeal API pick the first active issuer. Unknown slug → 400; empty issuer\n * list → 503.\n */\n issuer_slug?: string;\n metadata?: Record<string, string>;\n /** Structured billing details — real issuers require these for 3DS / KYC. */\n customer?: CustomerInfo;\n /**\n * Pay part of the price with bonuses. Sent as `use_bonus`. On by default\n * whenever the user has bonuses; `false` pays it all from the wallet.\n */\n useBonus?: boolean;\n /** The most bonuses to use, decimal string. Sent as `bonus_amount`. */\n bonusAmount?: string;\n /**\n * A promo code for the card's price. Sent as `promo_code`. Its discount\n * comes off before bonuses; `client.codes.validate` shows it first. A code\n * that can't be used fails the request with 400 `promo_code_*` and the\n * reason. Without one, the code the user signed up with applies when it\n * covers cards. Ignored inside `deposits.initiate({ issue_card })`: send\n * `promo_code` on the top-up there.\n */\n promoCode?: string;\n /**\n * Consents the user gave with the order (`terms`, `personal_data`,\n * `marketing`, `holder_data_transfer`). Recorded with the card, or with the\n * top-up inside `deposits.initiate({ issue_card })`, at the version of\n * their documents in force now. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original card; same key + different body returns 409.\n */\n idempotencyKey: string;\n}\n\n/**\n * The wire body of a card request: the camelCase fields renamed to what\n * the API reads. Shared by {@link CardsResource.create} and the\n * `issue_card` block of `deposits.initiate`.\n */\nexport function cardRequestBody(\n input: Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & { currency?: string },\n): Record<string, unknown> {\n const {\n productId,\n name,\n designId,\n useBonus,\n bonusAmount,\n promoCode,\n consentChannel,\n initial_amount: _ignored,\n ...rest\n } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (name !== undefined) body[\"name\"] = name;\n if (designId !== undefined) body[\"design_id\"] = designId;\n if (useBonus !== undefined) body[\"use_bonus\"] = useBonus;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n if (promoCode !== undefined) body[\"promo_code\"] = promoCode;\n if (consentChannel !== undefined) body[\"consent_channel\"] = consentChannel;\n return body;\n}\n\n/**\n * A card bought in one step with {@link CardsResource.order}: the product and\n * how the user pays. The platform works out the amount to pay in the\n * payment's currency, locks the rate and opens the top-up that issues the\n * card.\n */\nexport interface CardOrderInput {\n /** A product id from {@link CardsResource.listProducts}. Sent as `product_id`. */\n productId: string;\n /** One of the product's designs; omit for its default. Sent as `design_id`. */\n designId?: string;\n /** A name for the card, 1 to 40 characters; defaults to the product name. */\n name?: string;\n /** How the user pays, e.g. `\"sbp\"`. */\n method: DepositMethod;\n /** The funding connector to pay through; omit to let the API pick one that takes `method`. Sent as `funder_slug`. */\n funderSlug?: string;\n /** ISO 4217 code of the payment; defaults to the currency the method is priced in. */\n currency?: string;\n /** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */\n extraLoad?: string;\n /** A promo code for the payment. Sent as `promo_code`. */\n promoCode?: string;\n /** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */\n useBonus?: boolean;\n /**\n * Consents given with the order. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Passed to the payment provider; `return_url` is where the payment page sends the user back. */\n metadata?: Record<string, string>;\n}\n\n/** What {@link CardsResource.order} returns: the top-up to pay and its price. */\nexport interface CardOrder {\n /** Send the user to `deposit.redirect_url` when `deposit.status` is `redirect_required`. The card is issued once the payment is confirmed. */\n deposit: Deposit;\n /** What the user pays, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the payment brings: the card's price, its starting balance and `debt_withheld`, in `card_currency`. */\n card_amount: string;\n card_currency: string;\n /**\n * What the user owes in card fees, in `card_currency`: included in\n * `card_amount` and paid from it first. `\"0\"` when nothing is owed. Show\n * it before the payment. Older platforms leave it out.\n */\n debt_withheld?: string;\n}\n\n/** Why a card ordered with the sign-up was not placed. The account exists all the same. */\nexport interface CardOrderError {\n code: string;\n message: string;\n}\n\n/** Build the API body of a card order. */\nexport function cardOrderBody(input: CardOrderInput): Record<string, unknown> {\n const body: Record<string, unknown> = {\n product_id: input.productId,\n method: input.method,\n };\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.funderSlug !== undefined) body[\"funder_slug\"] = input.funderSlug;\n if (input.currency !== undefined) body[\"currency\"] = input.currency;\n if (input.extraLoad !== undefined) body[\"extra_load\"] = input.extraLoad;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.useBonus !== undefined) body[\"use_bonus\"] = input.useBonus;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.metadata !== undefined) body[\"metadata\"] = input.metadata;\n return body;\n}\n\n/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\n}\n\n/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */\nexport interface TopUpTerms {\n /** Whether the card can be topped up at this moment. */\n available: boolean;\n /** Why not, in plain words, when `available` is false. */\n reason: string | null;\n /** Currency top-ups are made in: the card's. */\n currency: string;\n /** What the wallet holds right now, in the wallet's currency. */\n wallet_available: CardBalance;\n /** Smallest single top-up the product allows, or `null` for no floor. */\n min: CardBalance | null;\n /** Largest single top-up the product allows, or `null` for no cap. */\n max: CardBalance | null;\n /**\n * What the user owes in card fees, in the card's currency, or `null` when\n * nothing is. A top-up from a wallet in the same currency pays it first\n * and the card gets the rest: show it before the top-up. Older platforms\n * leave it out.\n */\n debt?: CardBalance | null;\n}\n\nexport interface TopUpInput {\n /** Amount to add, decimal string, in the card's currency. */\n amount: string;\n /**\n * Required. Same key + same amount replays the first outcome; same key +\n * different amount is 409. Use a stable UUID per attempt so a retried\n * network call cannot move the money twice.\n */\n idempotencyKey: string;\n}\n\n/**\n * Where a top-up stands.\n *\n * - `pending`: the issuer accepted it and has not loaded the card yet. The\n * wallet is debited, the card balance is unchanged, the amount shows in\n * `Card.topups_pending`. Most issuers finish within minutes.\n * - `confirmed`: the money is on the card.\n * - `failed`: the issuer refused; the wallet is credited back.\n * - `stalled`: pending for longer than the deployment allows. The money is\n * safe and waits for support; it shows in `Card.topups_held`.\n * - `returned`: support sent the money back to the wallet.\n * - `written_off`: support closed it without the money coming back (the\n * issuer kept it); `failure_reason` says so.\n */\nexport type CardTopUpStatus =\n \"pending\" | \"confirmed\" | \"failed\" | \"stalled\" | \"returned\" | \"written_off\";\n\n/** One top-up attempt as the API records it. */\nexport interface CardTopUp {\n id: string;\n card_id: string;\n status: CardTopUpStatus;\n /** What landed on the card, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the wallet paid, decimal string, in `wallet_currency`. */\n wallet_amount: string;\n wallet_currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * The outcome of a top-up with the state to redraw: card, its balance, the\n * wallet. When `topup.status` is `pending`, the wallet has paid and\n * `card_balance` has not moved yet: show the amount as on its way\n * (`card.topups_pending`) and refresh the card later or on the\n * `card_topup` notification.\n */\nexport interface TopUpResult {\n topup: CardTopUp;\n card: Card;\n card_balance: CardBalance;\n wallet: CardBalance;\n}\n\n/** Fields a user can change on their own card. Omitted fields are left as they are. */\nexport interface UpdateCardInput {\n /** New name, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * New design (one of the product's `designs`), or `null` for the product's\n * default. Sent as `design_id`.\n */\n designId?: string | null;\n}\n\n/**\n * Kept for callers written against 0.3.x: the API no longer asks for a\n * password or a code on reveal, the session is enough. Both fields are\n * ignored and will be dropped in the next major.\n * @deprecated\n */\nexport interface RevealCardInput {\n password?: string;\n totpCode?: string;\n}\n\n/**\n * Full card data from a successful reveal. **Security**: never persist this,\n * keep it in volatile memory only, clear it within `expires_in_seconds`, and\n * never write it to localStorage / logs (the API marks the response no-store).\n *\n * Some issuers hand out a page that shows the numbers instead of the\n * numbers themselves. Then `reveal_url` is set, `pan` and `cvv` are empty,\n * and the client opens the page in a frame; see the README for the frame.\n */\nexport interface RevealedCard {\n /** The card number; empty when `reveal_url` is set. */\n pan: string;\n /** The security code; empty when `reveal_url` is set. */\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /**\n * A page at the card issuer that shows the details to the holder. Present\n * only for issuers that give a page instead of the numbers. Short-lived,\n * often single use: open it at once in an `<iframe>` and never store it.\n */\n reveal_url?: string;\n /**\n * The person the card is registered to at its issuer: what a checkout\n * asks for. Absent for cards issued before holders were kept.\n */\n cardholder?: Cardholder;\n /**\n * The address the card is registered at — what a merchant's checkout asks\n * for, and the postal code some of them decline a payment over. Absent\n * when the deployment has not set one.\n */\n billing_address?: BillingAddress;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\n}\n\n/** Postal address a card is registered at. Which parts exist depends on the country. */\nexport interface BillingAddress {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postal_code?: string;\n country?: string;\n}\n\n/**\n * The cardholder the issuer knows: the details to type into a checkout\n * that asks for the name, phone or address on the card. `source` says\n * whether the platform made them up (`generated`), the user supplied them\n * (`provided`) or both (`mixed`).\n */\nexport interface Cardholder {\n id: string;\n first_name: string;\n last_name: string;\n /** `YYYY-MM-DD`. */\n birth_date: string;\n /** E.164. */\n phone: string;\n /** A mailbox the platform owns; mail the issuer sends there reaches the user. */\n email: string;\n address: BillingAddress;\n source: \"generated\" | \"provided\" | \"mixed\";\n}\n\n/** The new PIN for a physical card. */\nexport interface SetPinInput {\n /**\n * Four to six digits, as the user typed them. Sent once to the issuer and\n * kept nowhere: not by the SDK, not by the API. Never log it.\n */\n pin: string;\n}\n\n/** What to move, and the key that makes a retry safe. */\nexport interface TransferInput {\n /** The card the money lands on. Must be the caller's, and of the same kind and currency. */\n toCardId: string;\n /** Amount to move, decimal string, in the cards' currency. */\n amount: string;\n /**\n * Required. The same key with the same body replays the first outcome; a\n * different body on the same key is 409.\n */\n idempotencyKey: string;\n}\n\n/** One transfer attempt as the API records it. */\nexport interface CardTransfer {\n id: string;\n from_card_id: string;\n to_card_id: string;\n /**\n * `confirmed` — the money is on the other card. `on_wallet` — it came off\n * the first card but the second did not take it, so it is on the wallet\n * and `failure_reason` says so in words. `pending` / `failed` otherwise.\n */\n status: \"pending\" | \"confirmed\" | \"on_wallet\" | \"failed\";\n amount: string;\n currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A finished transfer with the balances to redraw both cards and the wallet. */\nexport interface TransferResult {\n transfer: CardTransfer;\n from_balance: CardBalance;\n to_balance: CardBalance;\n /** Holds the money when `transfer.status` is `on_wallet`. */\n wallet: CardBalance;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Issue a card backed by the user's wallet balance. Resolves to the new\n * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row\n * to `failed` (never an orphaned active card); inspect `status` /\n * `failure_reason` on the result.\n * Errors: 409 `holder_data_consent_required` when the product has\n * `holder_data_required` and the user has not agreed to it.\n */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, ...card } = input;\n return this.http.post<Card>(\"/me/cards\", {\n body: cardRequestBody(card),\n idempotencyKey,\n });\n }\n\n /**\n * Buy a card in one step: the API prices the product in the payment's\n * currency, locks the rate and opens the top-up that issues the card.\n * Send the user to `order.deposit.redirect_url`; the card shows as\n * `pending_payment` until the payment is confirmed. The same\n * `idempotencyKey` returns the same order.\n * Errors: 400 `unknown_product` / `method_not_available` / a limit of the\n * way of paying, 409 `holder_data_consent_required` (the product has\n * `holder_data_required` and the user has not agreed to it), 503 no\n * funding connector or no exchange rate.\n */\n async order(input: CardOrderInput & { idempotencyKey: string }): Promise<CardOrder> {\n const { idempotencyKey, ...order } = input;\n return this.http.post<CardOrder>(\"/me/card-orders\", {\n body: cardOrderBody(order),\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the storefront shows them\n * (`is_default` marks the one issued when none is chosen). Each item\n * carries its product card (name, tagline, benefits, tile picture),\n * artwork, and the issuance price after the caller's subscription\n * discount, in the caller's wallet currency. Pass an item's `id` as\n * `productId` to {@link create}.\n */\n async listProducts(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/me/card-products\");\n }\n\n /** One product from the catalog. 404 when unknown, disabled or hidden. */\n async getProduct(id: string): Promise<CardProduct> {\n return this.http.get<CardProduct>(`/me/card-products/${encodeURIComponent(id)}`);\n }\n\n /**\n * The public catalog: the same products, order and default as\n * {@link listProducts}, but readable before sign-in, for a landing page or\n * the cabinet's first screen. Prices are list prices (`discount_bps` is\n * always 0); once the user is signed in, {@link listProducts} shows what\n * they pay. The API lets caches keep this response for a minute.\n */\n async catalog(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/card-products\");\n }\n\n /**\n * Rename the caller's own card or change its design. Resolves to the\n * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /\n * `design_not_allowed` on a bad value.\n */\n async update(id: string, input: UpdateCardInput): Promise<Card> {\n const body: Record<string, unknown> = {};\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n return this.http.patch<Card>(`/me/cards/${encodeURIComponent(id)}`, {\n body,\n });\n }\n\n /** Fetch one card by id. */\n async get(id: string): Promise<Card> {\n return this.http.get<Card>(`/me/cards/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's cards, most recent first. */\n async list(): Promise<Card[]> {\n return this.http.get<Card[]>(\"/me/cards\");\n }\n\n /**\n * Remaining balance of a prepaid card. `currency` is required by the Takeal API and\n * forwarded as a query param.\n */\n async balance(id: string, currency: string): Promise<CardBalance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<CardBalance>(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);\n }\n\n /**\n * What a top-up of this card can be right now: whether it is possible, the\n * currency, the wallet balance, and the product's floor and cap for one\n * top-up. Read it before drawing the form. 404 if the card isn't the caller's.\n */\n async topUpTerms(id: string): Promise<TopUpTerms> {\n return this.http.get<TopUpTerms>(`/me/cards/${encodeURIComponent(id)}/topup`);\n }\n\n /**\n * Move money from the wallet onto the caller's own card. The wallet is\n * debited first, then the card's provider loads the card; if the provider\n * refuses, the money is back on the wallet and the error says so. Resolves\n * to the card, its new balance and the wallet balance, so no second call\n * is needed. Errors carry a sentence the user can read: 400 outside the\n * floor or cap · 402 not enough in the wallet · 404 not the caller's card ·\n * 409 card frozen, closed or still being issued · 501 provider can't top\n * up · 502/503 provider declined or unreachable (wallet untouched).\n */\n async topUp(id: string, input: TopUpInput): Promise<TopUpResult> {\n const { idempotencyKey, amount } = input;\n return this.http.post<TopUpResult>(`/me/cards/${encodeURIComponent(id)}/topup`, {\n body: { amount },\n idempotencyKey,\n });\n }\n\n /**\n * Move money from one of the caller's cards to another. Both must be\n * theirs, active, in the same currency and of the same kind. The money\n * travels through the wallet one leg at a time: when the second leg does\n * not go through, the call still resolves, `transfer.status` is\n * `on_wallet` and the money is on the wallet — never between two cards.\n * Errors carry a sentence the user can read: 400 the same card twice,\n * different currencies or different kinds · 402 the card holds less than\n * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed\n * or still being issued, or the key was reused with a different body ·\n * 501/502/503 the provider cannot or will not move it.\n */\n async transfer(fromCardId: string, input: TransferInput): Promise<TransferResult> {\n const { toCardId, amount, idempotencyKey } = input;\n return this.http.post<TransferResult>(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {\n body: { to_card_id: toCardId, amount },\n idempotencyKey,\n });\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze} while\n * `status_source` is `holder` or `operator`. The optional `reason` is\n * recorded on the audit trail. Resolves to the updated card. 404 if the\n * card isn't the caller's; 409 `card_locked` when support holds it; 501 if\n * the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });\n }\n\n /**\n * Reveal the FULL PAN + CVV for the caller's own card. The signed-in\n * session is all the API asks for; the call is rate-limited and audited\n * server-side. The Takeal API never persists this data and marks the\n * response no-store; the SDK returns it verbatim and holds nothing.\n *\n * **Consumer security duties** (the SDK can't enforce these for you):\n * keep the result in volatile memory only, never write it to\n * localStorage / logs, and clear it within `expires_in_seconds`.\n *\n * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`\n * when the issuer shows them on a page of its own: open that page in a\n * frame right away, it is short-lived.\n *\n * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 `provider_unavailable`.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /**\n * Unfreeze a previously-frozen card. Idempotent on an already-active card.\n * A card the issuer froze (`status_source: \"provider\"`) is not the\n * holder's to unfreeze: the API answers 409 `card_locked`, so hide the\n * button and say the freeze is lifted through the issuer's support.\n */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });\n }\n\n /**\n * Report the card lost or stolen. Works at any time, on an active or a\n * frozen card. The report is recorded first with the server's time, which\n * decides who pays for operations someone else made; then the card is\n * frozen at its issuer and only support can unfreeze it. Resolves to the\n * claim (`client.claims`): show its `number` and `reported_at`. When the\n * issuer can't be reached, `card_freeze` is `\"pending\"`: the report still\n * counts and support freezes the card by hand. Reporting again while the\n * report is open returns the same claim. 404 / 403 not the user's card ·\n * 409 `card_not_open`: the card is closed or was never issued.\n */\n async reportLost(\n id: string,\n input: { kind: \"lost\" | \"stolen\"; details?: string },\n ): Promise<Claim> {\n return this.http.post<Claim>(`/me/cards/${encodeURIComponent(id)}/report-lost`, {\n body: { kind: input.kind, details: input.details },\n });\n }\n\n /**\n * Set the PIN of the caller's own physical card. The session is enough; the\n * call is rate-limited like {@link reveal} and the PIN is kept nowhere.\n * Resolves to the card; the user also gets a notification that the PIN\n * was set. 400 not four to six digits or the card is not active · 403 not\n * your card · 409 `card_locked`, or `provider_refused` when the issuer did\n * not take it · 429 too many attempts · 501 a virtual card has no PIN.\n */\n async setPin(id: string, input: SetPinInput): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/pin`, {\n body: { pin: input.pin },\n });\n }\n\n /**\n * Terminate the caller's own card. **One-way** — a terminated card cannot be\n * reactivated. The optional `reason` is audited. Idempotent on an\n * already-terminated card. A card that still holds money is refused (409\n * `move_balance_first` or `contact_support_to_close`): close it with\n * `client.closeRequests.request(id)` instead, and the money goes back the\n * way it was paid.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/terminate`, {\n body: { reason },\n });\n }\n}\n","import type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { TokenStore } from \"../token-store.js\";\nimport { isApiError } from \"../error.js\";\nimport type { SignupAttribution } from \"./attribution.js\";\nimport type { CodeResult } from \"./codes.js\";\nimport {\n cardOrderBody,\n type CardOrder,\n type CardOrderError,\n type CardOrderInput,\n} from \"./cards.js\";\n\n/**\n * Auth resource — `client.auth.*`.\n *\n * Covers the end-user-facing staged auth flow: password login\n * with optional TOTP/OTP step-up, and signing in (or up) with a code sent\n * to the e-mail, no password. The shape mirrors the responses\n * the Takeal API returns from `/auth/login`, `/auth/login/totp`,\n * `/auth/login/otp/verify`, `/auth/login/2fa/switch`, and `/auth/me`.\n *\n * The login methods stash the JWT in the configured `TokenStore` on\n * success so subsequent `client.*` calls authenticate automatically.\n * Step-up responses (TotpRequired / OtpSent) carry their own short-\n * lived challenge token which the caller passes to the next method\n * — those tokens DO NOT go through the TokenStore (they're not the\n * end-state JWT).\n */\n\nexport interface User {\n id: string;\n email: string;\n role: string;\n is_active: boolean;\n /** True for users auto-provisioned via the Telegram Mini App who still hold\n * a synthetic placeholder email. The client should prompt for a real email\n * and attach it via `auth.linkEmail` — this flips the flag to false. */\n email_pending?: boolean;\n created_at: string;\n updated_at: string;\n /** ISO 4217 code the user's wallet is held in (their own choice, else the\n * deployment default). Present on `GET /auth/me`. */\n wallet_currency?: string;\n /** The Telegram account linked to this user, or `null` when none is.\n * Present on `GET /auth/me` and inside every `stage: \"jwt\"` envelope. */\n telegram?: TelegramLink | null;\n}\n\n/** A Telegram account attached to a user. One Telegram per account and one\n * account per Telegram. */\nexport interface TelegramLink {\n /** Telegram username without the `@`, or `null` when the user has none. */\n username: string | null;\n /** When the link was made, ISO-8601. */\n linked_at: string;\n}\n\nexport interface ExchangeTelegramInput {\n /** Raw `window.Telegram.WebApp.initData`, passed to the server verbatim. */\n initData: string;\n /** Analytics ids for a new account. The Telegram id is the anonymous key\n * here, and a `startapp` code in `initData` is read by the server. */\n attribution?: SignupAttribution;\n /** Create an account for a Telegram id the deployment has not seen before.\n * Default `true`. With `false` the exchange resolves to\n * `{ stage: \"unknown\" }` instead, so the app can offer \"create an account\"\n * or \"I already have one\". */\n provision?: boolean;\n /** A promo or referral code for a new account. Without it the server\n * reads the `startapp` of the link the Mini App was opened with, when\n * that is a code. The result comes back as `code_result`. */\n code?: string;\n /** Consents for a new account, as in `register`. Sent as `consents`;\n * ignored for an account that already exists. */\n consents?: ConsentKind[];\n /** Sent as `consent_channel`; the server takes `miniapp` when omitted. */\n consentChannel?: ConsentChannel;\n}\n\n/** `exchangeTelegram({ provision: false })` for a Telegram id nobody has\n * signed in with yet. No account was created and no JWT was stored. */\nexport interface TelegramUnknown {\n stage: \"unknown\";\n}\n\nexport interface LinkTelegramInput {\n /** Raw `window.Telegram.WebApp.initData`, passed to the server verbatim. */\n initData: string;\n email: string;\n password: string;\n}\n\nexport interface LoginInput {\n email: string;\n password: string;\n /** Keep this browser signed in: the SDK stores the remember token it gets\n * and renews the session by itself when it ends. For accounts with a\n * second factor, pass it again to `verifyTotp` / `verifyOtp` /\n * `completeTotpSetup`. */\n remember?: boolean;\n}\n\n/** Discriminated union — `stage` is the discriminator. */\nexport type LoginResponse = JwtIssued | TotpRequired | TotpSetupRequired;\n\nexport interface JwtIssued {\n stage: \"jwt\";\n access_token: string;\n expires_at: string;\n user: User;\n /** `exchangeTelegram` for a new account opened with a code (`startapp`\n * or `code`): whether it was applied and what it gave. */\n code_result?: CodeResult;\n /** Present when the sign-in was remembered. The SDK keeps it in the\n * remember store; you don't need to. */\n remember_token?: string;\n remember_expires_at?: string;\n /** True iff the user's role grants `system.view_hub`.\n * Cusfront ignores this; the operator console uses it to gate `/dashboard`. */\n hub_access?: boolean;\n}\n\nexport interface TotpRequired {\n stage: \"totp_required\";\n challenge_token: string;\n expires_at: string;\n /** Alternate second factors. Pick one with `/2fa/switch`. */\n available_methods: AvailableMethod[];\n}\n\nexport interface TotpSetupRequired {\n stage: \"totp_setup_required\";\n challenge_token: string;\n expires_at: string;\n /** OTPAuth URI rendered as a QR by the consumer. */\n otpauth_url: string;\n /** Same secret base32-encoded — for manual entry alongside QR. */\n secret_base32: string;\n}\n\nexport interface AvailableMethod {\n kind: \"totp\" | \"telegram_otp\" | \"email_otp\";\n /** Short user-facing hint, e.g. `\"Telegram (@user)\"` or `\"e****@example.com\"`. */\n hint?: string;\n}\n\nexport interface TotpVerifyInput {\n challenge_token: string;\n /** 6-digit TOTP code OR `XXXX-XXXX` backup code. */\n code: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n}\n\nexport interface OtpVerifyInput {\n challenge_token: string;\n /** 6-digit one-time code delivered via the selected channel. */\n code: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n}\n\nexport interface SwitchMethodInput {\n challenge_token: string;\n method: AvailableMethod[\"kind\"];\n}\n\nexport interface RegisterInput {\n email: string;\n password: string;\n /** ISO 4217 code for the new wallet; must be offered by the deployment. */\n wallet_currency?: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n /** Where the new user came from: the anonymous key their visits were\n * sent with (`client.attribution.touch`) and the analytics ids. Without\n * it the account is recorded with an unknown source. */\n attribution?: SignupAttribution;\n /** A promo or referral code. An unknown or expired code doesn't stop the\n * sign-up: the account is created and `code_result` says why the code\n * was not applied, so the app can show it. */\n code?: string;\n /** The boxes the user ticked: `terms` (offer, tariffs and privacy policy),\n * `personal_data`, `marketing`. A deployment can require the first two\n * (400 `consents_required` without them). */\n consents?: ConsentKind[];\n /** Where they were ticked. Read from the client header when omitted. */\n consent_channel?: ConsentChannel;\n /** Buy this card right after signing up, as `cards.order` would. The\n * sign-up's consents go with the order. The result then carries\n * `card_order` (send the user to its `deposit.redirect_url`) or, when the\n * order could not be placed, `card_order_error`; the account is created\n * either way. */\n cardOrder?: Omit<CardOrderInput, \"consents\" | \"consentChannel\">;\n}\n\nexport interface RequestEmailCodeInput {\n email: string;\n /** Language of the e-mail when the address has no account yet (`ru`,\n * `en`, …). An account's own language wins; without either the server\n * reads the browser's. */\n locale?: string;\n}\n\n/** What `requestEmailCode` returns. The same for an address with an account\n * and one without. */\nexport interface EmailCodeSent {\n /** Send it back with the code to `verifyEmailCode`. */\n challenge_id: string;\n /** When the code stops working, ISO-8601. */\n expires_at: string;\n /** When another code can be asked for, ISO-8601: keep \"send again\" off\n * until then. */\n resend_at: string;\n}\n\nexport interface VerifyEmailCodeInput {\n /** From `requestEmailCode`. Sent as `challenge_id`. */\n challengeId: string;\n /** The six digits from the e-mail. */\n code: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n /** Wallet currency for a new account; ignored for an existing one. Sent\n * as `wallet_currency`. */\n walletCurrency?: string;\n /** Where a new user came from, as in `register`. */\n attribution?: SignupAttribution;\n /** A promo or referral code for a new account, as `code` in `register`.\n * One that covers cards also lowers the price of `cardOrder`. Sent as\n * `promo_code`; the result comes back as `code_result`. */\n promoCode?: string;\n /** The boxes ticked on the form. A new account records them with its\n * sign-up and the card order with itself. A deployment can require\n * `terms` and `personal_data` for a new account: 400\n * `consents_required`, and the same code works again with them. */\n consents?: ConsentKind[];\n /** Where they were ticked. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Buy this card right after signing in, as `cards.order` would, with\n * the consents above. The result carries `card_order` (send the user to\n * its `deposit.redirect_url`) or `card_order_error` when no payment was\n * opened; the sign-in stands either way. */\n cardOrder?: Omit<CardOrderInput, \"consents\" | \"consentChannel\">;\n}\n\n/** What `verifyEmailCode` returns: a `stage: \"jwt\"` session, plus whether\n * the account was made just now and the card order. */\nexport type EmailCodeSession = JwtIssued & {\n /** `true` when the address had no account and got one with this code. */\n account_created: boolean;\n card_order?: CardOrder;\n card_order_error?: CardOrderError;\n};\n\n/** What `requestEmailChange` returns: send `challenge_id` back with the code. */\nexport interface EmailChangeRequested {\n challenge_id: string;\n /** Where the code went, partly hidden: `al***@example.com`. */\n destination_hint: string;\n expires_at: string;\n}\n\n/** A signed-in session without the login `stage` marker — what\n * `register` returns. With a `code`, `code_result` is set; with a\n * `cardOrder`, `card_order` or `card_order_error`. */\nexport type Session = Omit<JwtIssued, \"stage\"> & {\n card_order?: CardOrder;\n card_order_error?: CardOrderError;\n};\n\nexport interface TotpSetupComplete extends Session {\n /** Ten one-time `XXXX-XXXX` codes, returned only this once. */\n backup_codes: string[];\n}\n\nexport interface ChangePasswordInput {\n current_password: string;\n /** At least 12 characters with a lower-case letter, an upper-case letter\n * and a digit; must differ from the current password. */\n new_password: string;\n}\n\nexport interface OtpSentResponse {\n stage: \"otp_sent\";\n challenge_token: string;\n expires_at: string;\n method: AvailableMethod[\"kind\"];\n hint?: string;\n available_methods: AvailableMethod[];\n}\n\n/** Send `remember` as the API's `remember_me`. */\nfunction withRemember<T extends { remember?: boolean }>(\n input: T,\n): Omit<T, \"remember\"> & { remember_me?: boolean } {\n const { remember, ...rest } = input;\n return remember ? { ...rest, remember_me: true } : rest;\n}\n\nexport class AuthResource {\n constructor(\n private readonly http: HttpClient,\n private readonly tokens: TokenStore,\n private readonly remembered?: TokenStore,\n ) {\n if (remembered) http.setRefresher(() => this.renew().then((r) => r.kind !== \"gone\"));\n }\n\n /** Store what a finished sign-in returned. */\n private async keep(resp: { access_token: string; remember_token?: string }): Promise<void> {\n await Promise.resolve(this.tokens.set(resp.access_token));\n if (resp.remember_token && this.remembered) {\n await Promise.resolve(this.remembered.set(resp.remember_token));\n }\n }\n\n /** Renew a remembered sign-in: a new session and a new remember token,\n * both stored. Resolves `null` (and forgets the remember token) when there\n * is none or it no longer works; the app then shows the sign-in form.\n * The SDK does this by itself on a 401; call it on app start to resume a\n * session without a request failing first. */\n async refresh(): Promise<JwtIssued | null> {\n const r = await this.renew();\n if (r.kind === \"renewed\") return r.resp;\n if (r.kind === \"taken_over\") {\n // Another tab renewed first: its session is already stored.\n const access = await Promise.resolve(this.tokens.get());\n const user = await this.me();\n return { stage: \"jwt\", access_token: access ?? \"\", expires_at: \"\", user };\n }\n return null;\n }\n\n /** The renewal itself, for the 401 path: it must not call the API again\n * through the client, or a second 401 would wait on this very renewal. */\n private async renew(): Promise<\n { kind: \"renewed\"; resp: JwtIssued } | { kind: \"taken_over\" } | { kind: \"gone\" }\n > {\n const token = this.remembered ? await Promise.resolve(this.remembered.get()) : null;\n if (!token) return { kind: \"gone\" };\n try {\n const resp = await this.http.post<JwtIssued>(\"/auth/refresh\", {\n body: { remember_token: token },\n skipAuth: true,\n });\n await this.keep(resp);\n return { kind: \"renewed\", resp };\n } catch (e) {\n if (isApiError(e) && e.status === 401) {\n // Another tab of the same browser may have renewed first; its\n // tokens are then already in the (shared) stores.\n const now = await Promise.resolve(this.remembered!.get());\n if (now && now !== token && (await Promise.resolve(this.tokens.get()))) {\n return { kind: \"taken_over\" };\n }\n await Promise.resolve(this.remembered!.clear());\n await Promise.resolve(this.tokens.clear());\n return { kind: \"gone\" };\n }\n throw e;\n }\n }\n\n /** Password-auth entry. May resolve to a JWT, or to a step-up\n * challenge that needs `verifyTotp` / `verifyOtp` next. */\n async login(input: LoginInput): Promise<LoginResponse> {\n const resp = await this.http.post<LoginResponse>(\"/auth/login\", {\n body: withRemember(input),\n skipAuth: true,\n });\n if (resp.stage === \"jwt\") {\n await this.keep(resp);\n }\n return resp;\n }\n\n /** Verify a TOTP code (or XXXX-XXXX backup code) against a\n * `totp_required` challenge. On success the JWT is stored. */\n async verifyTotp(input: TotpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/totp\", {\n body: withRemember(input),\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Verify a 6-digit OTP code (Telegram / email) against an\n * `otp_sent` challenge. */\n async verifyOtp(input: OtpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/otp/verify\", {\n body: withRemember(input),\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Create an end-user account and sign it in. The JWT is stored.\n * `wallet_currency` must be one the deployment offers; omit it to take\n * the deployment default (it can be switched later via `client.wallet`\n * while the wallet is empty).\n * Errors: 400 `validation` / `currency_not_allowed` / `consents_required`\n * / `unknown_consent`, 409 email taken. */\n async register(input: RegisterInput): Promise<Session> {\n const { cardOrder, ...rest } = input;\n const body: Record<string, unknown> = withRemember(rest);\n if (cardOrder !== undefined) body[\"card_order\"] = cardOrderBody(cardOrder);\n const resp = await this.http.post<Session>(\"/auth/register\", {\n body,\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Step one of signing in without a password: a six-digit code goes to\n * the address. It works for an address with an account and for a new one\n * alike, and the answer doesn't say which. The code works for 10 minutes;\n * another can be asked for after `resend_at` and replaces it.\n * Errors: 400 `validation` (not an address), 429 `resend_too_soon` /\n * `too_many_requests` (the message says when to try again), 503\n * `delivery_failed`. */\n async requestEmailCode(input: RequestEmailCodeInput): Promise<EmailCodeSent> {\n const body: Record<string, unknown> = { email: input.email };\n if (input.locale !== undefined) body[\"locale\"] = input.locale;\n return this.http.post<EmailCodeSent>(\"/auth/email-code\", { body, skipAuth: true });\n }\n\n /** Step two: the code signs in to the account with that address, or\n * creates one (no password) when there is none; `account_created` says\n * which. The JWT is stored. With `cardOrder`, the card is ordered for\n * that account in the same call.\n * Errors: 401 `invalid_code` (wrong, expired or used; after five checks a\n * new code is needed), 400 `consents_required` for a new account, 403\n * `user_disabled` / `second_factor_required` (operator accounts sign in\n * with a password and their authenticator). */\n async verifyEmailCode(input: VerifyEmailCodeInput): Promise<EmailCodeSession> {\n const body: Record<string, unknown> = {\n challenge_id: input.challengeId,\n code: input.code,\n };\n if (input.remember) body[\"remember_me\"] = true;\n if (input.walletCurrency !== undefined) body[\"wallet_currency\"] = input.walletCurrency;\n if (input.attribution !== undefined) body[\"attribution\"] = input.attribution;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.cardOrder !== undefined) body[\"card_order\"] = cardOrderBody(input.cardOrder);\n const resp = await this.http.post<EmailCodeSession>(\"/auth/email-code/verify\", {\n body,\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Finish a `totp_setup_required` login: send the first code from the\n * authenticator app. The JWT is stored. The response carries ten\n * one-time `backup_codes` that are never returned again, so show them to\n * the user right away and don't keep them on the device. */\n async completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete> {\n const resp = await this.http.post<TotpSetupComplete>(\"/auth/login/totp-setup\", {\n body: withRemember(input),\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Change the signed-in user's password. Every other session of the\n * account is signed out; this one stays valid.\n * Errors: 400 when the new password fails the policy, 401 when the\n * current one is wrong. */\n async changePassword(input: ChangePasswordInput): Promise<{ revoked_sessions: number }> {\n return this.http.post<{ revoked_sessions: number }>(\"/auth/password\", {\n body: input,\n });\n }\n\n /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for\n * telegram/email; for TOTP it short-circuits back to the challenge. */\n async switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse> {\n return this.http.post<OtpSentResponse>(\"/auth/login/2fa/switch\", {\n body: input,\n skipAuth: true,\n });\n }\n\n /** Exchange a signed Telegram Mini App `initData` payload for a session\n * JWT. The server validates the initData HMAC against the deployment's bot\n * token, then looks the Telegram id up. A known id signs in. An unknown id\n * gets a fresh account (`user.email_pending === true` — prompt for a real\n * email and call {@link linkEmail}) unless `provision: false` is passed, in\n * which case the call resolves to `{ stage: \"unknown\" }`, nothing is\n * created and nothing is stored; the app then offers to create the account\n * (call again with `provision: true`) or to attach the Telegram to an\n * existing one ({@link linkTelegram}). Stores the JWT on `stage: \"jwt\"`.\n *\n * Every other error still throws an `ApiError` (401 `invalid_init_data`,\n * 503 `telegram_not_configured`, …).\n *\n * Most consumers use the higher-level `fromInitData` / `fromTelegramWebApp`\n * helpers in `@takeal/cusfront-sdk/telegram`; reach for this directly when\n * you already hold a configured client. */\n exchangeTelegram(input: { initData: string; provision?: true }): Promise<JwtIssued>;\n exchangeTelegram(input: ExchangeTelegramInput): Promise<JwtIssued | TelegramUnknown>;\n async exchangeTelegram(input: ExchangeTelegramInput): Promise<JwtIssued | TelegramUnknown> {\n const body: {\n init_data: string;\n provision?: boolean;\n attribution?: SignupAttribution;\n code?: string;\n consents?: ConsentKind[];\n consent_channel?: ConsentChannel;\n } = {\n init_data: input.initData,\n };\n if (input.provision !== undefined) body.provision = input.provision;\n if (input.attribution !== undefined) body.attribution = input.attribution;\n if (input.code !== undefined) body.code = input.code;\n if (input.consents !== undefined) body.consents = input.consents;\n if (input.consentChannel !== undefined) body.consent_channel = input.consentChannel;\n let resp: JwtIssued;\n try {\n resp = await this.http.post<JwtIssued>(\"/auth/telegram/exchange\", {\n body,\n skipAuth: true,\n });\n } catch (e) {\n if (isApiError(e) && e.status === 404 && e.code === \"telegram_unknown\") {\n return { stage: \"unknown\" };\n }\n throw e;\n }\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach the Telegram account behind `initData` to an existing email +\n * password account and sign in as that account. No bearer needed; the\n * password is checked the same way `login` checks it. The JWT is stored.\n *\n * Errors: 401 `unauthenticated` (wrong email or password, as with\n * `login`) / `invalid_init_data`; 403\n * `user_disabled` / `second_factor_required` (accounts that sign in with\n * a second factor can't be linked from a Mini App); 409\n * `telegram_already_linked_other` (this account already has a different\n * Telegram; unlink it first) / `telegram_in_use` (this Telegram belongs to\n * another account); 503 `telegram_not_configured`. */\n async linkTelegram(input: LinkTelegramInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/telegram/link\", {\n body: { init_data: input.initData, email: input.email, password: input.password },\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach the first real email to a Telegram-made account (and clear\n * `email_pending`). 409 if taken. An account that already has a real\n * address gets 409 `email_change_needs_code`: change it with\n * {@link requestEmailChange} and {@link confirmEmailChange}. */\n async linkEmail(input: { email: string }): Promise<User> {\n return this.http.post<User>(\"/me/email\", { body: { email: input.email } });\n }\n\n /** Step one of an email change: a six-digit code goes to the new address\n * and works for 5 minutes. Nothing changes yet.\n * Errors: 400 `same_email`, 409 address taken, 429 `too_many_requests`\n * (five codes an hour). */\n async requestEmailChange(input: { email: string }): Promise<EmailChangeRequested> {\n return this.http.post<EmailChangeRequested>(\"/me/email/change\", {\n body: { email: input.email },\n });\n }\n\n /** Step two: the code from the e-mail changes the address; the old one\n * gets a notice. Errors: 401 `invalid_code` (after five wrong codes a new\n * request is needed), 409 the address was taken meanwhile. */\n async confirmEmailChange(input: { challengeId: string; code: string }): Promise<User> {\n return this.http.post<User>(\"/me/email/change/confirm\", {\n body: { challenge_id: input.challengeId, code: input.code },\n });\n }\n\n /** Current user — fails 401 when the stored JWT is expired or\n * missing. Useful as a \"do I have a session\" probe on app boot. */\n async me(): Promise<User> {\n return this.http.get<User>(\"/auth/me\");\n }\n\n /** Sign out: ends this session and the remembered sign-in on the\n * server (best effort: a network failure still signs out locally), then\n * forgets both tokens. */\n async signOut(): Promise<void> {\n const remember = this.remembered ? await Promise.resolve(this.remembered.get()) : null;\n try {\n await this.http.post<void>(\"/auth/logout\", {\n body: remember ? { remember_token: remember } : {},\n retried: true,\n });\n } catch {\n // Signed out locally either way.\n }\n await Promise.resolve(this.tokens.clear());\n if (this.remembered) await Promise.resolve(this.remembered.clear());\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/error.ts","../../src/resources/cards.ts","../../src/resources/auth.ts"],"names":[],"mappings":";AA2CO,SAAS,WAAW,CAAA,EAA2B;AACpD,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,IAAY,CAAA,KAAM,IAAA,IAAS,EAA+B,UAAA,KAAe,IAAA;AAC/F;;;AC2aO,SAAS,cAAc,KAAA,EAAgD;AAC5E,EAAA,MAAM,IAAA,GAAgC;AAAA,IACpC,YAAY,KAAA,CAAM,SAAA;AAAA,IAClB,QAAQ,KAAA,CAAM;AAAA,GAChB;AACA,EAAA,IAAI,MAAM,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,IAAI,KAAA,CAAM,QAAA;AAC5D,EAAA,IAAI,MAAM,IAAA,KAAS,MAAA,EAAW,IAAA,CAAK,MAAM,IAAI,KAAA,CAAM,IAAA;AACnD,EAAA,IAAI,MAAM,UAAA,KAAe,MAAA,EAAW,IAAA,CAAK,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Q,QAAQ,IAAA,CAAK,UAAA,CAAW,OAAO,CAAA;AAAA,EACpE;AACF","file":"auth.js","sourcesContent":["/**\n * Errors surfaced by the SDK. All HTTP failures map onto `ApiError`;\n * network-level / abort / serialisation failures get the generic\n * `NetworkError`. Consumers catch on the discriminator field\n * (`isApiError` / `isNetworkError`) rather than `instanceof` — works\n * across bundler boundaries where multiple copies of the class can\n * coexist.\n */\nexport class ApiError extends Error {\n readonly isApiError = true as const;\n\n constructor(\n /** HTTP status code returned by the Takeal API. */\n public readonly status: number,\n /** Stable machine-readable code (e.g. `\"insufficient_funds\"`,\n * `\"permission_required\"`, `\"validation\"`). Same enum the\n * TypeScript types pin via openapi-typescript. */\n public readonly code: string,\n /** Human-readable message. English; the consumer maps to its\n * own i18n layer before showing to end-users. */\n message: string,\n /** Full parsed response body when available. Carries field-level\n * validation details for `code = \"validation\"`. */\n public readonly body?: unknown,\n ) {\n super(message);\n this.name = \"ApiError\";\n }\n}\n\nexport class NetworkError extends Error {\n readonly isNetworkError = true as const;\n\n constructor(\n message: string,\n public readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"NetworkError\";\n }\n}\n\n/** Type guard — preferred over `instanceof` (bundler-safe). */\nexport function isApiError(e: unknown): e is ApiError {\n return typeof e === \"object\" && e !== null && (e as { isApiError?: boolean }).isApiError === true;\n}\n\nexport function isNetworkError(e: unknown): e is NetworkError {\n return (\n typeof e === \"object\" &&\n e !== null &&\n (e as { isNetworkError?: boolean }).isNetworkError === true\n );\n}\n","import type { Claim } from \"./claims.js\";\nimport type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\nimport type { Deposit, DepositMethod } from \"./deposits.js\";\n\n/**\n * Cards resource — `client.cards.*`.\n *\n * The end-user \"money OUT\" surface: a user issues themselves a card backed by\n * their wallet balance via an issuer connector. Mirrors the Takeal API's\n * `/me/cards` routes:\n *\n * GET /card-products → catalog (public, before sign-in)\n * GET /me/card-products → listProducts (the catalog, personal price)\n * GET /me/card-products/{id} → getProduct\n * GET /me/cards/{id}/topup → topUpTerms\n * POST /me/cards/{id}/topup → topUp\n * POST /me/cards → create\n * GET /me/cards → list (most recent first)\n * GET /me/cards/{id} → get\n * PATCH /me/cards/{id} → update (name, design)\n * GET /me/cards/{id}/balance → balance (prepaid remaining)\n * POST /me/cards/{id}/freeze → freeze\n * POST /me/cards/{id}/unfreeze → unfreeze\n * POST /me/cards/{id}/report-lost → reportLost (lost or stolen: frozen at once)\n * POST /me/cards/{id}/transfer → transfer (to another of their cards)\n * POST /me/cards/{id}/terminate → terminate (one-way)\n * POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)\n * POST /me/cards/{id}/pin → setPin (physical cards)\n *\n * The lifecycle actions are ownership-gated server-side: a caller can only\n * freeze / unfreeze / terminate a card that belongs to them (else 404).\n *\n * Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from\n * the Takeal API until their issuer flows land.\n */\n\n/** Card product. Only `prepaid` is fully implemented today. */\nexport type CardType = \"credit\" | \"prepaid\" | \"gift\";\n\n/**\n * Card lifecycle state.\n *\n * - `pending_payment`: the row exists but the issuance fee has not been\n * paid yet; the provider has not been called and nothing is visible.\n * - `pending`: the issuer accepted the order and has not issued the card\n * yet. The price is charged. Show the card as \"being issued\" with no\n * numbers; it becomes `active` on its own, or `failed` with the price\n * back on the wallet. Some issuers take minutes, some a day.\n * - `active`, `frozen`: the usual states. Read `status_source` before\n * offering to unfreeze.\n * - `terminating`: the holder (or the issuer) closed the card and the\n * issuer has not finished: the balance comes back to the wallet when it\n * does. Show it as closing; no actions apply.\n * - `terminated`, `redeemed`, `failed`: final.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"pending\"\n | \"active\"\n | \"frozen\"\n | \"terminating\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\n\n/**\n * Who made the card's last status change. `provider` on a `frozen` card\n * means the issuer froze it (a risk check, a lost-card report): the holder\n * cannot unfreeze it, so do not offer the button; say the freeze is lifted\n * through the issuer's support. `holder` and `operator` freezes are undone\n * with `unfreeze()` as usual.\n */\nexport type CardStatusSource = \"holder\" | \"operator\" | \"provider\";\n\n/** `virtual` cards show their numbers in the app; `physical` cards are plastic and have a PIN. */\nexport type CardForm = \"virtual\" | \"physical\";\n\n/**\n * Why `terminate()` is refused right now: `first_purchase_required` (the\n * card closes after its first purchase) or `card_locked` (only support can\n * change it).\n */\nexport type CloseBlockedReason = \"first_purchase_required\" | \"card_locked\";\n\n/**\n * A card design: the artwork a card is shown with. `image_url` is the front,\n * `image_url_back` the back; both are either absolute URLs or paths relative\n * to the API origin (the deployment's default design is\n * `/card-designs/default.svg`, its back `/card-designs/default.svg?side=back`)\n * — pass them through `client.assetUrl()` before rendering. `image_url_back`\n * is `null` or absent for a one-sided design: show the front on both sides.\n * The picture is in the proportions of a plastic card (1586×1000) and draws\n * no chip or card data; the client renders the number, name and expiry on\n * top. `id` is `null` for the deployment default, which is rendered from the\n * branding settings.\n */\nexport interface CardDesignRef {\n id: string | null;\n name?: string;\n image_url: string;\n image_url_back?: string | null;\n}\n\n/**\n * What issuing a card costs the caller. `amount` is the price after the\n * user's subscription discount; `base_amount` is the list price and\n * `discount_bps` the discount in basis points (1000 = 10 %). `label` is the\n * operator's wording for the fee line (\"Card issuance\").\n */\nexport interface CardProductPrice {\n /** What the user pays, decimal string, after their subscription discount. */\n amount: string;\n /**\n * ISO 4217 code: the currency the buyer pays in. A signed-in user sees\n * their wallet currency, converted the way issuance will charge it; the\n * public catalog shows the currency the operator priced the card in. It\n * is not necessarily the currency the card is held in (`CardProduct.currency`).\n */\n currency: string;\n /** Wording for the fee line, e.g. \"Card issuance\". */\n label: string;\n /** The list price before the discount, decimal string, in the same currency. */\n base_amount: string;\n /** Discount applied, in basis points (1000 = 10%). */\n discount_bps: number;\n}\n\n/**\n * A card the user can order, as listed by `GET /me/card-products`. The id is\n * opaque — it names a product, never a provider. The list comes in the\n * order the operator arranged the storefront; `is_default` marks the\n * product issued when none is chosen, wherever it sits. `designs` is the\n * set the user may pick from (may be empty when only the default applies);\n * `design` is what the card gets when no choice is made. `price` is `null`\n * for a free card. `features` is an operator-defined object (scheme, wallet\n * support, load limits, …) with no fixed keys.\n */\nexport interface CardProduct {\n id: string;\n name: string;\n /** One line under the name on the tile, or `null`. */\n tagline: string | null;\n description: string | null;\n /** Selling points to list on the product card, in order. May be empty. */\n benefits: string[];\n /**\n * Picture for the product tile, absolute URL, or `null`: show the card\n * design (`design.image_url`) then.\n */\n tile_image_url: string | null;\n card_type: CardType;\n currency: string | null;\n features: Record<string, unknown>;\n design: CardDesignRef;\n designs: CardDesignRef[];\n price: CardProductPrice | null;\n /**\n * The balance a new card comes with, already included in `price`; `null`\n * when the card starts empty and is funded with `topUp()` afterwards.\n */\n starting_balance: CardBalance | null;\n /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\n /**\n * Issuing this card sends the user's real personal details to the card\n * issuer. Show the consent screen before the order and send\n * `holder_data_transfer` in its `consents` (or give it once with\n * `client.consents.allowHolderData()`); without it the order fails with\n * 409 `holder_data_consent_required`. `false`: the issuer gets no real\n * details and no extra consent is asked.\n */\n holder_data_required: boolean;\n /**\n * What a card on this product costs to use, on top of the payments\n * themselves. A fee the card can't cover is owed and paid from the next\n * top-up (see `client.debt`). Every line is `\"0\"` when the product\n * charges nothing for it.\n */\n tariff: CardTariff;\n}\n\n/**\n * A card product's fees for using the card. Decimal strings: the fixed\n * amounts are in `currency` (the card's), the shares in percent of the\n * operation's amount.\n */\nexport interface CardTariff {\n /** `null` for a product held in several currencies: the card's own then. */\n currency: string | null;\n /** Per settled card payment, fixed. */\n operation_fixed: string;\n /** Per settled card payment, percent of its amount. */\n operation_percent: string;\n /**\n * Per payment declined through the user's own doing: not enough money,\n * wrong card details, a frozen card, a subscription not cancelled with the\n * merchant. A decline caused by the issuer or the platform costs nothing.\n */\n decline: string;\n /** Per cash withdrawal, fixed; charged instead of the payment fee. */\n cash_withdrawal_fixed: string;\n /** Per cash withdrawal, percent of its amount. */\n cash_withdrawal_percent: string;\n}\n\n/**\n * A card record as the Takeal API returns it. Mirrors the `cards` table. Note the\n * SDK never receives the full PAN or CVV here — only `last4` + expiry. The\n * gift-card `redemption_code` is returned exactly once (on create) and\n * scrubbed from subsequent list/get responses.\n */\nexport interface Card {\n id: string;\n user_id: string;\n card_type: CardType;\n status: CardStatus;\n /** Last four digits of the PAN — safe to display. */\n last4: string | null;\n expiry_month: number | null;\n expiry_year: number | null;\n /** Gift cards only, present once on create then scrubbed. */\n redemption_code?: string;\n /** The balance the card was issued with, decimal string; `null` or `\"0\"` for a card issued empty. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | null;\n /** Who changed the status last; `null` when it never changed. See {@link CardStatusSource}. */\n status_source: CardStatusSource | null;\n /** Virtual or plastic. A `physical` card takes a PIN with {@link CardsResource.setPin}. */\n card_form: CardForm;\n /** Why the card cannot be closed right now, or `null` when it can. */\n close_blocked: CloseBlockedReason | null;\n /**\n * Top-ups the issuer has accepted and not loaded yet, summed, decimal\n * string in `currency`; `null` when there are none. It counts top-ups from\n * the wallet and top-ups paid straight to the card. Show it next to the\n * balance as money on its way to the card.\n */\n topups_pending: string | null;\n /**\n * `true` while the card's details are being prepared: the card can be\n * used and topped up, but its number can't be shown yet. Show \"Details\n * are being prepared\" instead of the reveal button and refresh the card\n * later; it turns `false` on its own, usually within minutes. Absent\n * from platforms before 0.7.6.\n */\n details_pending?: boolean;\n /**\n * Top-ups the issuer has held for too long, summed, decimal string in\n * `currency`; `null` when there are none. The money is safe and waits for\n * support to settle it; say so instead of offering a retry.\n */\n topups_held: string | null;\n /**\n * The card this one replaced: support reissued it for free because that\n * card stopped working before its term. `null` otherwise.\n */\n reissued_from_card_id?: string | null;\n /** The card support issued to replace this one, or `null`. */\n reissued_to_card_id?: string | null;\n /**\n * What was left on the card this one replaced, on its way here. Show it as\n * money in transit next to the balance, not as part of it. `null` when\n * nothing is on its way.\n */\n in_transit?: CardInTransit | null;\n /** The name the user gave the card, or `null`. */\n name: string | null;\n /** The artwork the card is shown with. Always present. */\n design: CardDesignRef;\n /** The product the card was issued from; `null` for cards issued without one. */\n product: { id: string; name: string } | null;\n created_at: string;\n updated_at: string;\n /** Only on the result of `create`, when bonuses paid part of the price. */\n bonus?: IssuanceBonus;\n}\n\n/**\n * The balance of a closed card on its way to the card that replaced it. It\n * waits for the old card's issuer to return the money (`stage: \"issuer\"`),\n * then it is loaded onto this card (`stage: \"loading\"`); once it is there,\n * `in_transit` is `null` and the card's balance has it. The move is in the\n * history as a `closed_card_balance` entry.\n */\nexport interface CardInTransit {\n /** Decimal string in `currency`. What the issuer returned once it did; before that, what the old card held. */\n amount: string;\n currency: string;\n /** The closed card the money comes from. */\n from_card_id: string;\n stage: \"issuer\" | \"loading\" | (string & {});\n}\n\n/** How bonuses changed a new card's price (\"was / now\"). Decimal strings in `currency`. */\nexport interface IssuanceBonus {\n /** Bonuses used. */\n units: string;\n /** The price before bonuses (\"was\"). */\n price: string;\n /** What the bonuses covered. */\n covered: string;\n /** What the wallet paid (\"now\"). */\n paid: string;\n currency: string;\n}\n\nexport interface CreateCardInput {\n /**\n * A product id from {@link CardsResource.listProducts}. Sent as\n * `product_id`. When given, `type` and `issuer_slug` may be omitted; when\n * both are given they must agree with the product (400 `product_mismatch`).\n * Unknown, disabled or hidden product → 400 `unknown_product`.\n */\n productId?: string;\n /** A name for the card, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * One of the product's `designs`. Sent as `design_id`. `null` or omitted\n * picks the product's default design; a design outside the product's set →\n * 400 `design_not_allowed`.\n */\n designId?: string | null;\n /**\n * `prepaid` (the only fully-wired type today), `credit`, or `gift`.\n * Optional when `productId` is given, required otherwise.\n */\n type?: CardType;\n /**\n * @deprecated Ignored since 0.3.21. A card is issued for its product price;\n * the balance it starts with, if the product includes one, is part of that\n * price (see `CardProduct.starting_balance`). Money is added afterwards\n * with {@link CardsResource.topUp}. The field is no longer sent.\n */\n initial_amount?: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n /**\n * Optional. Slug of a specific issuer to mint with. Omit to let\n * the Takeal API pick the first active issuer. Unknown slug → 400; empty issuer\n * list → 503.\n */\n issuer_slug?: string;\n metadata?: Record<string, string>;\n /** Structured billing details — real issuers require these for 3DS / KYC. */\n customer?: CustomerInfo;\n /**\n * Pay part of the price with bonuses. Sent as `use_bonus`. On by default\n * whenever the user has bonuses; `false` pays it all from the wallet.\n */\n useBonus?: boolean;\n /** The most bonuses to use, decimal string. Sent as `bonus_amount`. */\n bonusAmount?: string;\n /**\n * A promo code for the card's price. Sent as `promo_code`. Its discount\n * comes off before bonuses; `client.codes.validate` shows it first. A code\n * that can't be used fails the request with 400 `promo_code_*` and the\n * reason. Without one, the code the user signed up with applies when it\n * covers cards. Ignored inside `deposits.initiate({ issue_card })`: send\n * `promo_code` on the top-up there.\n */\n promoCode?: string;\n /**\n * Consents the user gave with the order (`terms`, `personal_data`,\n * `marketing`, `holder_data_transfer`). Recorded with the card, or with the\n * top-up inside `deposits.initiate({ issue_card })`, at the version of\n * their documents in force now. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original card; same key + different body returns 409.\n */\n idempotencyKey: string;\n}\n\n/**\n * The wire body of a card request: the camelCase fields renamed to what\n * the API reads. Shared by {@link CardsResource.create} and the\n * `issue_card` block of `deposits.initiate`.\n */\nexport function cardRequestBody(\n input: Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & { currency?: string },\n): Record<string, unknown> {\n const {\n productId,\n name,\n designId,\n useBonus,\n bonusAmount,\n promoCode,\n consentChannel,\n initial_amount: _ignored,\n ...rest\n } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (name !== undefined) body[\"name\"] = name;\n if (designId !== undefined) body[\"design_id\"] = designId;\n if (useBonus !== undefined) body[\"use_bonus\"] = useBonus;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n if (promoCode !== undefined) body[\"promo_code\"] = promoCode;\n if (consentChannel !== undefined) body[\"consent_channel\"] = consentChannel;\n return body;\n}\n\n/**\n * A card bought in one step with {@link CardsResource.order}: the product and\n * how the user pays. The platform works out the amount to pay in the\n * payment's currency, locks the rate and opens the top-up that issues the\n * card.\n */\nexport interface CardOrderInput {\n /** A product id from {@link CardsResource.listProducts}. Sent as `product_id`. */\n productId: string;\n /** One of the product's designs; omit for its default. Sent as `design_id`. */\n designId?: string;\n /** A name for the card, 1 to 40 characters; defaults to the product name. */\n name?: string;\n /** How the user pays, e.g. `\"sbp\"`. */\n method: DepositMethod;\n /** The funding connector to pay through; omit to let the API pick one that takes `method`. Sent as `funder_slug`. */\n funderSlug?: string;\n /** ISO 4217 code of the payment; defaults to the currency the method is priced in. */\n currency?: string;\n /** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */\n extraLoad?: string;\n /** A promo code for the payment. Sent as `promo_code`. */\n promoCode?: string;\n /** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */\n useBonus?: boolean;\n /**\n * Consents given with the order. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Passed to the payment provider; `return_url` is where the payment page sends the user back. */\n metadata?: Record<string, string>;\n}\n\n/** What {@link CardsResource.order} returns: the top-up to pay and its price. */\nexport interface CardOrder {\n /** Send the user to `deposit.redirect_url` when `deposit.status` is `redirect_required`. The card is issued once the payment is confirmed. */\n deposit: Deposit;\n /** What the user pays, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the payment brings: the card's price, its starting balance and `debt_withheld`, in `card_currency`. */\n card_amount: string;\n card_currency: string;\n /**\n * What the user owes in card fees, in `card_currency`: included in\n * `card_amount` and paid from it first. `\"0\"` when nothing is owed. Show\n * it before the payment. Older platforms leave it out.\n */\n debt_withheld?: string;\n}\n\n/** Why a card ordered with the sign-up was not placed. The account exists all the same. */\nexport interface CardOrderError {\n code: string;\n message: string;\n}\n\n/** Build the API body of a card order. */\nexport function cardOrderBody(input: CardOrderInput): Record<string, unknown> {\n const body: Record<string, unknown> = {\n product_id: input.productId,\n method: input.method,\n };\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.funderSlug !== undefined) body[\"funder_slug\"] = input.funderSlug;\n if (input.currency !== undefined) body[\"currency\"] = input.currency;\n if (input.extraLoad !== undefined) body[\"extra_load\"] = input.extraLoad;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.useBonus !== undefined) body[\"use_bonus\"] = input.useBonus;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.metadata !== undefined) body[\"metadata\"] = input.metadata;\n return body;\n}\n\n/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\n /**\n * From `cards.balance()` only: top-ups the issuer has accepted and not\n * confirmed yet, summed, decimal string in `currency`; `null` when there\n * are none. Not part of `amount`, even when the issuer already shows the\n * money: show it next to the balance as on its way.\n */\n pending?: string | null;\n}\n\n/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */\nexport interface TopUpTerms {\n /** Whether the card can be topped up at this moment. */\n available: boolean;\n /** Why not, in plain words, when `available` is false. */\n reason: string | null;\n /** Currency top-ups are made in: the card's. */\n currency: string;\n /** What the wallet holds right now, in the wallet's currency. */\n wallet_available: CardBalance;\n /** Smallest single top-up the product allows, or `null` for no floor. */\n min: CardBalance | null;\n /** Largest single top-up the product allows, or `null` for no cap. */\n max: CardBalance | null;\n /**\n * What the user owes in card fees, in the card's currency, or `null` when\n * nothing is. A top-up from a wallet in the same currency pays it first\n * and the card gets the rest: show it before the top-up. Older platforms\n * leave it out.\n */\n debt?: CardBalance | null;\n}\n\nexport interface TopUpInput {\n /** Amount to add, decimal string, in the card's currency. */\n amount: string;\n /**\n * Required. Same key + same amount replays the first outcome; same key +\n * different amount is 409. Use a stable UUID per attempt so a retried\n * network call cannot move the money twice.\n */\n idempotencyKey: string;\n}\n\n/**\n * Where a top-up stands.\n *\n * - `pending`: the issuer accepted it and has not loaded the card yet. The\n * wallet is debited, the card balance is unchanged, the amount shows in\n * `Card.topups_pending`. Most issuers finish within minutes.\n * - `confirmed`: the money is on the card.\n * - `failed`: the issuer refused; the wallet is credited back.\n * - `stalled`: pending for longer than the deployment allows. The money is\n * safe and waits for support; it shows in `Card.topups_held`.\n * - `returned`: support sent the money back to the wallet.\n * - `written_off`: support closed it without the money coming back (the\n * issuer kept it); `failure_reason` says so.\n */\nexport type CardTopUpStatus =\n \"pending\" | \"confirmed\" | \"failed\" | \"stalled\" | \"returned\" | \"written_off\";\n\n/** One top-up attempt as the API records it. */\nexport interface CardTopUp {\n id: string;\n card_id: string;\n status: CardTopUpStatus;\n /** What landed on the card, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the wallet paid, decimal string, in `wallet_currency`. */\n wallet_amount: string;\n wallet_currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * The outcome of a top-up with the state to redraw: card, its balance, the\n * wallet. When `topup.status` is `pending`, the wallet has paid and\n * `card_balance` has not moved yet: show the amount as on its way\n * (`card.topups_pending`) and refresh the card later or on the\n * `card_topup` notification.\n */\nexport interface TopUpResult {\n topup: CardTopUp;\n card: Card;\n card_balance: CardBalance;\n wallet: CardBalance;\n}\n\n/** Fields a user can change on their own card. Omitted fields are left as they are. */\nexport interface UpdateCardInput {\n /** New name, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * New design (one of the product's `designs`), or `null` for the product's\n * default. Sent as `design_id`.\n */\n designId?: string | null;\n}\n\n/**\n * Kept for callers written against 0.3.x: the API no longer asks for a\n * password or a code on reveal, the session is enough. Both fields are\n * ignored and will be dropped in the next major.\n * @deprecated\n */\nexport interface RevealCardInput {\n password?: string;\n totpCode?: string;\n}\n\n/**\n * What a reveal gave, so a client can switch on one field:\n *\n * - `numbers`: `pan`, `cvv` and the expiry are filled in;\n * - `page`: the issuer shows the numbers on a page of its own, `reveal_url`\n * is set and `pan` and `cvv` are empty;\n * - `pending`: the card's details are still being prepared, nothing else\n * is filled in. Show \"Details are being prepared\" and try again in a\n * minute or two; the attempt didn't count against the reveal limit.\n */\nexport type RevealState = \"numbers\" | \"page\" | \"pending\";\n\n/**\n * Full card data from a successful reveal. **Security**: never persist this,\n * keep it in volatile memory only, clear it within `expires_in_seconds`, and\n * never write it to localStorage / logs (the API marks the response no-store).\n *\n * `state` says which of three answers this is (see {@link RevealState}).\n * Some issuers hand out a page that shows the numbers instead of the\n * numbers themselves; for some cards the details are still being prepared\n * right after issuance.\n */\nexport interface RevealedCard {\n /** Which answer this is; set by the SDK from the fields below. */\n state: RevealState;\n /** The card number; empty when `reveal_url` is set. */\n pan: string;\n /** The security code; empty when `reveal_url` is set. */\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /**\n * A page at the card issuer that shows the details to the holder. Present\n * only for issuers that give a page instead of the numbers. Short-lived,\n * often single use: open it at once in an `<iframe>` and never store it.\n */\n reveal_url?: string;\n /**\n * The person the card is registered to at its issuer: what a checkout\n * asks for. Absent for cards issued before holders were kept.\n */\n cardholder?: Cardholder;\n /**\n * The address the card is registered at — what a merchant's checkout asks\n * for, and the postal code some of them decline a payment over. Absent\n * when the deployment has not set one.\n */\n billing_address?: BillingAddress;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\n /**\n * `true` when the details are still being prepared (`state: \"pending\"`).\n * Absent from platforms before 0.7.6.\n */\n details_pending?: boolean;\n}\n\n/** The three answers of a reveal told apart; see {@link RevealState}. */\nexport function revealState(r: Omit<RevealedCard, \"state\">): RevealState {\n if (r.details_pending) return \"pending\";\n if (r.reveal_url) return \"page\";\n return \"numbers\";\n}\n\n/** Postal address a card is registered at. Which parts exist depends on the country. */\nexport interface BillingAddress {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postal_code?: string;\n country?: string;\n}\n\n/**\n * The cardholder the issuer knows: the details to type into a checkout\n * that asks for the name, phone or address on the card. `source` says\n * whether the platform made them up (`generated`), the user supplied them\n * (`provided`) or both (`mixed`).\n */\nexport interface Cardholder {\n id: string;\n first_name: string;\n last_name: string;\n /** `YYYY-MM-DD`. */\n birth_date: string;\n /** E.164. */\n phone: string;\n /** A mailbox the platform owns; mail the issuer sends there reaches the user. */\n email: string;\n address: BillingAddress;\n source: \"generated\" | \"provided\" | \"mixed\";\n}\n\n/** The new PIN for a physical card. */\nexport interface SetPinInput {\n /**\n * Four to six digits, as the user typed them. Sent once to the issuer and\n * kept nowhere: not by the SDK, not by the API. Never log it.\n */\n pin: string;\n}\n\n/** What to move, and the key that makes a retry safe. */\nexport interface TransferInput {\n /** The card the money lands on. Must be the caller's, and of the same kind and currency. */\n toCardId: string;\n /** Amount to move, decimal string, in the cards' currency. */\n amount: string;\n /**\n * Required. The same key with the same body replays the first outcome; a\n * different body on the same key is 409.\n */\n idempotencyKey: string;\n}\n\n/** One transfer attempt as the API records it. */\nexport interface CardTransfer {\n id: string;\n from_card_id: string;\n to_card_id: string;\n /**\n * `confirmed` — the money is on the other card. `on_wallet` — it came off\n * the first card but the second did not take it, so it is on the wallet\n * and `failure_reason` says so in words. `pending` / `failed` otherwise.\n */\n status: \"pending\" | \"confirmed\" | \"on_wallet\" | \"failed\";\n amount: string;\n currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A finished transfer with the balances to redraw both cards and the wallet. */\nexport interface TransferResult {\n transfer: CardTransfer;\n from_balance: CardBalance;\n to_balance: CardBalance;\n /** Holds the money when `transfer.status` is `on_wallet`. */\n wallet: CardBalance;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Issue a card backed by the user's wallet balance. Resolves to the new\n * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row\n * to `failed` (never an orphaned active card); inspect `status` /\n * `failure_reason` on the result.\n * Errors: 409 `holder_data_consent_required` when the product has\n * `holder_data_required` and the user has not agreed to it.\n */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, ...card } = input;\n return this.http.post<Card>(\"/me/cards\", {\n body: cardRequestBody(card),\n idempotencyKey,\n });\n }\n\n /**\n * Buy a card in one step: the API prices the product in the payment's\n * currency, locks the rate and opens the top-up that issues the card.\n * Send the user to `order.deposit.redirect_url`; the card shows as\n * `pending_payment` until the payment is confirmed. The same\n * `idempotencyKey` returns the same order.\n * Errors: 400 `unknown_product` / `method_not_available` / a limit of the\n * way of paying, 409 `holder_data_consent_required` (the product has\n * `holder_data_required` and the user has not agreed to it), 503 no\n * funding connector or no exchange rate.\n */\n async order(input: CardOrderInput & { idempotencyKey: string }): Promise<CardOrder> {\n const { idempotencyKey, ...order } = input;\n return this.http.post<CardOrder>(\"/me/card-orders\", {\n body: cardOrderBody(order),\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the storefront shows them\n * (`is_default` marks the one issued when none is chosen). Each item\n * carries its product card (name, tagline, benefits, tile picture),\n * artwork, and the issuance price after the caller's subscription\n * discount, in the caller's wallet currency. Pass an item's `id` as\n * `productId` to {@link create}.\n */\n async listProducts(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/me/card-products\");\n }\n\n /** One product from the catalog. 404 when unknown, disabled or hidden. */\n async getProduct(id: string): Promise<CardProduct> {\n return this.http.get<CardProduct>(`/me/card-products/${encodeURIComponent(id)}`);\n }\n\n /**\n * The public catalog: the same products, order and default as\n * {@link listProducts}, but readable before sign-in, for a landing page or\n * the cabinet's first screen. Prices are list prices (`discount_bps` is\n * always 0); once the user is signed in, {@link listProducts} shows what\n * they pay. The API lets caches keep this response for a minute.\n */\n async catalog(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/card-products\");\n }\n\n /**\n * Rename the caller's own card or change its design. Resolves to the\n * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /\n * `design_not_allowed` on a bad value.\n */\n async update(id: string, input: UpdateCardInput): Promise<Card> {\n const body: Record<string, unknown> = {};\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n return this.http.patch<Card>(`/me/cards/${encodeURIComponent(id)}`, {\n body,\n });\n }\n\n /** Fetch one card by id. */\n async get(id: string): Promise<Card> {\n return this.http.get<Card>(`/me/cards/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's cards, most recent first. */\n async list(): Promise<Card[]> {\n return this.http.get<Card[]>(\"/me/cards\");\n }\n\n /**\n * Remaining balance of a prepaid card. `currency` is required by the Takeal API and\n * forwarded as a query param.\n */\n async balance(id: string, currency: string): Promise<CardBalance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<CardBalance>(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);\n }\n\n /**\n * What a top-up of this card can be right now: whether it is possible, the\n * currency, the wallet balance, and the product's floor and cap for one\n * top-up. Read it before drawing the form. 404 if the card isn't the caller's.\n */\n async topUpTerms(id: string): Promise<TopUpTerms> {\n return this.http.get<TopUpTerms>(`/me/cards/${encodeURIComponent(id)}/topup`);\n }\n\n /**\n * Move money from the wallet onto the caller's own card. The wallet is\n * debited first, then the card's provider loads the card; if the provider\n * refuses, the money is back on the wallet and the error says so. Resolves\n * to the card, its new balance and the wallet balance, so no second call\n * is needed. Errors carry a sentence the user can read: 400 outside the\n * floor or cap · 402 not enough in the wallet · 404 not the caller's card ·\n * 409 card frozen, closed or still being issued · 501 provider can't top\n * up · 502/503 provider declined or unreachable (wallet untouched).\n */\n async topUp(id: string, input: TopUpInput): Promise<TopUpResult> {\n const { idempotencyKey, amount } = input;\n return this.http.post<TopUpResult>(`/me/cards/${encodeURIComponent(id)}/topup`, {\n body: { amount },\n idempotencyKey,\n });\n }\n\n /**\n * Move money from one of the caller's cards to another. Both must be\n * theirs, active, in the same currency and of the same kind. The money\n * travels through the wallet one leg at a time: when the second leg does\n * not go through, the call still resolves, `transfer.status` is\n * `on_wallet` and the money is on the wallet — never between two cards.\n * Errors carry a sentence the user can read: 400 the same card twice,\n * different currencies or different kinds · 402 the card holds less than\n * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed\n * or still being issued, or the key was reused with a different body ·\n * 501/502/503 the provider cannot or will not move it.\n */\n async transfer(fromCardId: string, input: TransferInput): Promise<TransferResult> {\n const { toCardId, amount, idempotencyKey } = input;\n return this.http.post<TransferResult>(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {\n body: { to_card_id: toCardId, amount },\n idempotencyKey,\n });\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze} while\n * `status_source` is `holder` or `operator`. The optional `reason` is\n * recorded on the audit trail. Resolves to the updated card. 404 if the\n * card isn't the caller's; 409 `card_locked` when support holds it; 501 if\n * the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });\n }\n\n /**\n * Reveal the FULL PAN + CVV for the caller's own card. The signed-in\n * session is all the API asks for; the call is rate-limited and audited\n * server-side. The Takeal API never persists this data and marks the\n * response no-store; the SDK returns it verbatim and holds nothing.\n *\n * **Consumer security duties** (the SDK can't enforce these for you):\n * keep the result in volatile memory only, never write it to\n * localStorage / logs, and clear it within `expires_in_seconds`.\n *\n * `state` tells the three answers apart: `numbers`; `page`, with\n * `reveal_url` and empty `pan` and `cvv` when the issuer shows them on a\n * page of its own (open that page in a frame right away, it is\n * short-lived); or `pending` while the card's details are still being\n * prepared, which doesn't count against the limit. A card says the same\n * in {@link Card.details_pending}, so there is no need to call this just\n * to find out.\n *\n * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 `provider_unavailable`.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n const r = await this.http.post<Omit<RevealedCard, \"state\">>(\n `/me/cards/${encodeURIComponent(id)}/reveal`,\n );\n return { ...r, state: revealState(r) };\n }\n\n /**\n * Unfreeze a previously-frozen card. Idempotent on an already-active card.\n * A card the issuer froze (`status_source: \"provider\"`) is not the\n * holder's to unfreeze: the API answers 409 `card_locked`, so hide the\n * button and say the freeze is lifted through the issuer's support.\n */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });\n }\n\n /**\n * Report the card lost or stolen. Works at any time, on an active or a\n * frozen card. The report is recorded first with the server's time, which\n * decides who pays for operations someone else made; then the card is\n * frozen at its issuer and only support can unfreeze it. Resolves to the\n * claim (`client.claims`): show its `number` and `reported_at`. When the\n * issuer can't be reached, `card_freeze` is `\"pending\"`: the report still\n * counts and support freezes the card by hand. Reporting again while the\n * report is open returns the same claim. 404 / 403 not the user's card ·\n * 409 `card_not_open`: the card is closed or was never issued.\n */\n async reportLost(\n id: string,\n input: { kind: \"lost\" | \"stolen\"; details?: string },\n ): Promise<Claim> {\n return this.http.post<Claim>(`/me/cards/${encodeURIComponent(id)}/report-lost`, {\n body: { kind: input.kind, details: input.details },\n });\n }\n\n /**\n * Set the PIN of the caller's own physical card. The session is enough; the\n * call is rate-limited like {@link reveal} and the PIN is kept nowhere.\n * Resolves to the card; the user also gets a notification that the PIN\n * was set. 400 not four to six digits or the card is not active · 403 not\n * your card · 409 `card_locked`, or `provider_refused` when the issuer did\n * not take it · 429 too many attempts · 501 a virtual card has no PIN.\n */\n async setPin(id: string, input: SetPinInput): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/pin`, {\n body: { pin: input.pin },\n });\n }\n\n /**\n * Terminate the caller's own card. **One-way** — a terminated card cannot be\n * reactivated. The optional `reason` is audited. Idempotent on an\n * already-terminated card. A card that still holds money is refused (409\n * `move_balance_first` or `contact_support_to_close`): close it with\n * `client.closeRequests.request(id)` instead, and the money goes back the\n * way it was paid.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/terminate`, {\n body: { reason },\n });\n }\n}\n","import type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { TokenStore } from \"../token-store.js\";\nimport { isApiError } from \"../error.js\";\nimport type { SignupAttribution } from \"./attribution.js\";\nimport type { CodeResult } from \"./codes.js\";\nimport {\n cardOrderBody,\n type CardOrder,\n type CardOrderError,\n type CardOrderInput,\n} from \"./cards.js\";\n\n/**\n * Auth resource — `client.auth.*`.\n *\n * Covers the end-user-facing staged auth flow: password login\n * with optional TOTP/OTP step-up, and signing in (or up) with a code sent\n * to the e-mail, no password. The shape mirrors the responses\n * the Takeal API returns from `/auth/login`, `/auth/login/totp`,\n * `/auth/login/otp/verify`, `/auth/login/2fa/switch`, and `/auth/me`.\n *\n * The login methods stash the JWT in the configured `TokenStore` on\n * success so subsequent `client.*` calls authenticate automatically.\n * Step-up responses (TotpRequired / OtpSent) carry their own short-\n * lived challenge token which the caller passes to the next method\n * — those tokens DO NOT go through the TokenStore (they're not the\n * end-state JWT).\n */\n\nexport interface User {\n id: string;\n email: string;\n role: string;\n is_active: boolean;\n /** True for users auto-provisioned via the Telegram Mini App who still hold\n * a synthetic placeholder email. The client should prompt for a real email\n * and attach it via `auth.linkEmail` — this flips the flag to false. */\n email_pending?: boolean;\n created_at: string;\n updated_at: string;\n /** ISO 4217 code the user's wallet is held in (their own choice, else the\n * deployment default). Present on `GET /auth/me`. */\n wallet_currency?: string;\n /** The Telegram account linked to this user, or `null` when none is.\n * Present on `GET /auth/me` and inside every `stage: \"jwt\"` envelope. */\n telegram?: TelegramLink | null;\n}\n\n/** A Telegram account attached to a user. One Telegram per account and one\n * account per Telegram. */\nexport interface TelegramLink {\n /** Telegram username without the `@`, or `null` when the user has none. */\n username: string | null;\n /** When the link was made, ISO-8601. */\n linked_at: string;\n}\n\nexport interface ExchangeTelegramInput {\n /** Raw `window.Telegram.WebApp.initData`, passed to the server verbatim. */\n initData: string;\n /** Analytics ids for a new account. The Telegram id is the anonymous key\n * here, and a `startapp` code in `initData` is read by the server. */\n attribution?: SignupAttribution;\n /** Create an account for a Telegram id the deployment has not seen before.\n * Default `true`. With `false` the exchange resolves to\n * `{ stage: \"unknown\" }` instead, so the app can offer \"create an account\"\n * or \"I already have one\". */\n provision?: boolean;\n /** A promo or referral code for a new account. Without it the server\n * reads the `startapp` of the link the Mini App was opened with, when\n * that is a code. The result comes back as `code_result`. */\n code?: string;\n /** Consents for a new account, as in `register`. Sent as `consents`;\n * ignored for an account that already exists. */\n consents?: ConsentKind[];\n /** Sent as `consent_channel`; the server takes `miniapp` when omitted. */\n consentChannel?: ConsentChannel;\n}\n\n/** `exchangeTelegram({ provision: false })` for a Telegram id nobody has\n * signed in with yet. No account was created and no JWT was stored. */\nexport interface TelegramUnknown {\n stage: \"unknown\";\n}\n\nexport interface LinkTelegramInput {\n /** Raw `window.Telegram.WebApp.initData`, passed to the server verbatim. */\n initData: string;\n email: string;\n password: string;\n}\n\nexport interface LoginInput {\n email: string;\n password: string;\n /** Keep this browser signed in: the SDK stores the remember token it gets\n * and renews the session by itself when it ends. For accounts with a\n * second factor, pass it again to `verifyTotp` / `verifyOtp` /\n * `completeTotpSetup`. */\n remember?: boolean;\n}\n\n/** Discriminated union — `stage` is the discriminator. */\nexport type LoginResponse = JwtIssued | TotpRequired | TotpSetupRequired;\n\nexport interface JwtIssued {\n stage: \"jwt\";\n access_token: string;\n expires_at: string;\n user: User;\n /** `exchangeTelegram` for a new account opened with a code (`startapp`\n * or `code`): whether it was applied and what it gave. */\n code_result?: CodeResult;\n /** Present when the sign-in was remembered. The SDK keeps it in the\n * remember store; you don't need to. */\n remember_token?: string;\n remember_expires_at?: string;\n /** True iff the user's role grants `system.view_hub`.\n * Cusfront ignores this; the operator console uses it to gate `/dashboard`. */\n hub_access?: boolean;\n}\n\nexport interface TotpRequired {\n stage: \"totp_required\";\n challenge_token: string;\n expires_at: string;\n /** Alternate second factors. Pick one with `/2fa/switch`. */\n available_methods: AvailableMethod[];\n}\n\nexport interface TotpSetupRequired {\n stage: \"totp_setup_required\";\n challenge_token: string;\n expires_at: string;\n /** OTPAuth URI rendered as a QR by the consumer. */\n otpauth_url: string;\n /** Same secret base32-encoded — for manual entry alongside QR. */\n secret_base32: string;\n}\n\nexport interface AvailableMethod {\n kind: \"totp\" | \"telegram_otp\" | \"email_otp\";\n /** Short user-facing hint, e.g. `\"Telegram (@user)\"` or `\"e****@example.com\"`. */\n hint?: string;\n}\n\nexport interface TotpVerifyInput {\n challenge_token: string;\n /** 6-digit TOTP code OR `XXXX-XXXX` backup code. */\n code: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n}\n\nexport interface OtpVerifyInput {\n challenge_token: string;\n /** 6-digit one-time code delivered via the selected channel. */\n code: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n}\n\nexport interface SwitchMethodInput {\n challenge_token: string;\n method: AvailableMethod[\"kind\"];\n}\n\nexport interface RegisterInput {\n email: string;\n password: string;\n /** ISO 4217 code for the new wallet; must be offered by the deployment. */\n wallet_currency?: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n /** Where the new user came from: the anonymous key their visits were\n * sent with (`client.attribution.touch`) and the analytics ids. Without\n * it the account is recorded with an unknown source. */\n attribution?: SignupAttribution;\n /** A promo or referral code. An unknown or expired code doesn't stop the\n * sign-up: the account is created and `code_result` says why the code\n * was not applied, so the app can show it. */\n code?: string;\n /** The boxes the user ticked: `terms` (offer, tariffs and privacy policy),\n * `personal_data`, `marketing`. A deployment can require the first two\n * (400 `consents_required` without them). */\n consents?: ConsentKind[];\n /** Where they were ticked. Read from the client header when omitted. */\n consent_channel?: ConsentChannel;\n /** Buy this card right after signing up, as `cards.order` would. The\n * sign-up's consents go with the order. The result then carries\n * `card_order` (send the user to its `deposit.redirect_url`) or, when the\n * order could not be placed, `card_order_error`; the account is created\n * either way. */\n cardOrder?: Omit<CardOrderInput, \"consents\" | \"consentChannel\">;\n}\n\nexport interface RequestEmailCodeInput {\n email: string;\n /** Language of the e-mail when the address has no account yet (`ru`,\n * `en`, …). An account's own language wins; without either the server\n * reads the browser's. */\n locale?: string;\n}\n\n/** What `requestEmailCode` returns. The same for an address with an account\n * and one without. */\nexport interface EmailCodeSent {\n /** Send it back with the code to `verifyEmailCode`. */\n challenge_id: string;\n /** When the code stops working, ISO-8601. */\n expires_at: string;\n /** When another code can be asked for, ISO-8601: keep \"send again\" off\n * until then. */\n resend_at: string;\n}\n\nexport interface VerifyEmailCodeInput {\n /** From `requestEmailCode`. Sent as `challenge_id`. */\n challengeId: string;\n /** The six digits from the e-mail. */\n code: string;\n /** Keep this browser signed in, as in `login`. */\n remember?: boolean;\n /** Wallet currency for a new account; ignored for an existing one. Sent\n * as `wallet_currency`. */\n walletCurrency?: string;\n /** Where a new user came from, as in `register`. */\n attribution?: SignupAttribution;\n /** A promo or referral code for a new account, as `code` in `register`.\n * One that covers cards also lowers the price of `cardOrder`. Sent as\n * `promo_code`; the result comes back as `code_result`. */\n promoCode?: string;\n /** The boxes ticked on the form. A new account records them with its\n * sign-up and the card order with itself. A deployment can require\n * `terms` and `personal_data` for a new account: 400\n * `consents_required`, and the same code works again with them. */\n consents?: ConsentKind[];\n /** Where they were ticked. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Buy this card right after signing in, as `cards.order` would, with\n * the consents above. The result carries `card_order` (send the user to\n * its `deposit.redirect_url`) or `card_order_error` when no payment was\n * opened; the sign-in stands either way. */\n cardOrder?: Omit<CardOrderInput, \"consents\" | \"consentChannel\">;\n}\n\n/** What `verifyEmailCode` returns: a `stage: \"jwt\"` session, plus whether\n * the account was made just now and the card order. */\nexport type EmailCodeSession = JwtIssued & {\n /** `true` when the address had no account and got one with this code. */\n account_created: boolean;\n card_order?: CardOrder;\n card_order_error?: CardOrderError;\n};\n\n/** What `requestEmailChange` returns: send `challenge_id` back with the code. */\nexport interface EmailChangeRequested {\n challenge_id: string;\n /** Where the code went, partly hidden: `al***@example.com`. */\n destination_hint: string;\n expires_at: string;\n}\n\n/** A signed-in session without the login `stage` marker — what\n * `register` returns. With a `code`, `code_result` is set; with a\n * `cardOrder`, `card_order` or `card_order_error`. */\nexport type Session = Omit<JwtIssued, \"stage\"> & {\n card_order?: CardOrder;\n card_order_error?: CardOrderError;\n};\n\nexport interface TotpSetupComplete extends Session {\n /** Ten one-time `XXXX-XXXX` codes, returned only this once. */\n backup_codes: string[];\n}\n\nexport interface ChangePasswordInput {\n current_password: string;\n /** At least 12 characters with a lower-case letter, an upper-case letter\n * and a digit; must differ from the current password. */\n new_password: string;\n}\n\nexport interface OtpSentResponse {\n stage: \"otp_sent\";\n challenge_token: string;\n expires_at: string;\n method: AvailableMethod[\"kind\"];\n hint?: string;\n available_methods: AvailableMethod[];\n}\n\n/** Send `remember` as the API's `remember_me`. */\nfunction withRemember<T extends { remember?: boolean }>(\n input: T,\n): Omit<T, \"remember\"> & { remember_me?: boolean } {\n const { remember, ...rest } = input;\n return remember ? { ...rest, remember_me: true } : rest;\n}\n\nexport class AuthResource {\n constructor(\n private readonly http: HttpClient,\n private readonly tokens: TokenStore,\n private readonly remembered?: TokenStore,\n ) {\n if (remembered) http.setRefresher(() => this.renew().then((r) => r.kind !== \"gone\"));\n }\n\n /** Store what a finished sign-in returned. */\n private async keep(resp: { access_token: string; remember_token?: string }): Promise<void> {\n await Promise.resolve(this.tokens.set(resp.access_token));\n if (resp.remember_token && this.remembered) {\n await Promise.resolve(this.remembered.set(resp.remember_token));\n }\n }\n\n /** Renew a remembered sign-in: a new session and a new remember token,\n * both stored. Resolves `null` (and forgets the remember token) when there\n * is none or it no longer works; the app then shows the sign-in form.\n * The SDK does this by itself on a 401; call it on app start to resume a\n * session without a request failing first. */\n async refresh(): Promise<JwtIssued | null> {\n const r = await this.renew();\n if (r.kind === \"renewed\") return r.resp;\n if (r.kind === \"taken_over\") {\n // Another tab renewed first: its session is already stored.\n const access = await Promise.resolve(this.tokens.get());\n const user = await this.me();\n return { stage: \"jwt\", access_token: access ?? \"\", expires_at: \"\", user };\n }\n return null;\n }\n\n /** The renewal itself, for the 401 path: it must not call the API again\n * through the client, or a second 401 would wait on this very renewal. */\n private async renew(): Promise<\n { kind: \"renewed\"; resp: JwtIssued } | { kind: \"taken_over\" } | { kind: \"gone\" }\n > {\n const token = this.remembered ? await Promise.resolve(this.remembered.get()) : null;\n if (!token) return { kind: \"gone\" };\n try {\n const resp = await this.http.post<JwtIssued>(\"/auth/refresh\", {\n body: { remember_token: token },\n skipAuth: true,\n });\n await this.keep(resp);\n return { kind: \"renewed\", resp };\n } catch (e) {\n if (isApiError(e) && e.status === 401) {\n // Another tab of the same browser may have renewed first; its\n // tokens are then already in the (shared) stores.\n const now = await Promise.resolve(this.remembered!.get());\n if (now && now !== token && (await Promise.resolve(this.tokens.get()))) {\n return { kind: \"taken_over\" };\n }\n await Promise.resolve(this.remembered!.clear());\n await Promise.resolve(this.tokens.clear());\n return { kind: \"gone\" };\n }\n throw e;\n }\n }\n\n /** Password-auth entry. May resolve to a JWT, or to a step-up\n * challenge that needs `verifyTotp` / `verifyOtp` next. */\n async login(input: LoginInput): Promise<LoginResponse> {\n const resp = await this.http.post<LoginResponse>(\"/auth/login\", {\n body: withRemember(input),\n skipAuth: true,\n });\n if (resp.stage === \"jwt\") {\n await this.keep(resp);\n }\n return resp;\n }\n\n /** Verify a TOTP code (or XXXX-XXXX backup code) against a\n * `totp_required` challenge. On success the JWT is stored. */\n async verifyTotp(input: TotpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/totp\", {\n body: withRemember(input),\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Verify a 6-digit OTP code (Telegram / email) against an\n * `otp_sent` challenge. */\n async verifyOtp(input: OtpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/otp/verify\", {\n body: withRemember(input),\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Create an end-user account and sign it in. The JWT is stored.\n * `wallet_currency` must be one the deployment offers; omit it to take\n * the deployment default (it can be switched later via `client.wallet`\n * while the wallet is empty).\n * Errors: 400 `validation` / `currency_not_allowed` / `consents_required`\n * / `unknown_consent`, 409 email taken. */\n async register(input: RegisterInput): Promise<Session> {\n const { cardOrder, ...rest } = input;\n const body: Record<string, unknown> = withRemember(rest);\n if (cardOrder !== undefined) body[\"card_order\"] = cardOrderBody(cardOrder);\n const resp = await this.http.post<Session>(\"/auth/register\", {\n body,\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Step one of signing in without a password: a six-digit code goes to\n * the address. It works for an address with an account and for a new one\n * alike, and the answer doesn't say which. The code works for 10 minutes;\n * another can be asked for after `resend_at` and replaces it.\n * Errors: 400 `validation` (not an address), 429 `resend_too_soon` /\n * `too_many_requests` (the message says when to try again), 503\n * `delivery_failed`. */\n async requestEmailCode(input: RequestEmailCodeInput): Promise<EmailCodeSent> {\n const body: Record<string, unknown> = { email: input.email };\n if (input.locale !== undefined) body[\"locale\"] = input.locale;\n return this.http.post<EmailCodeSent>(\"/auth/email-code\", { body, skipAuth: true });\n }\n\n /** Step two: the code signs in to the account with that address, or\n * creates one (no password) when there is none; `account_created` says\n * which. The JWT is stored. With `cardOrder`, the card is ordered for\n * that account in the same call.\n * Errors: 401 `invalid_code` (wrong, expired or used; after five checks a\n * new code is needed), 400 `consents_required` for a new account, 403\n * `user_disabled` / `second_factor_required` (operator accounts sign in\n * with a password and their authenticator). */\n async verifyEmailCode(input: VerifyEmailCodeInput): Promise<EmailCodeSession> {\n const body: Record<string, unknown> = {\n challenge_id: input.challengeId,\n code: input.code,\n };\n if (input.remember) body[\"remember_me\"] = true;\n if (input.walletCurrency !== undefined) body[\"wallet_currency\"] = input.walletCurrency;\n if (input.attribution !== undefined) body[\"attribution\"] = input.attribution;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.cardOrder !== undefined) body[\"card_order\"] = cardOrderBody(input.cardOrder);\n const resp = await this.http.post<EmailCodeSession>(\"/auth/email-code/verify\", {\n body,\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Finish a `totp_setup_required` login: send the first code from the\n * authenticator app. The JWT is stored. The response carries ten\n * one-time `backup_codes` that are never returned again, so show them to\n * the user right away and don't keep them on the device. */\n async completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete> {\n const resp = await this.http.post<TotpSetupComplete>(\"/auth/login/totp-setup\", {\n body: withRemember(input),\n skipAuth: true,\n });\n await this.keep(resp);\n return resp;\n }\n\n /** Change the signed-in user's password. Every other session of the\n * account is signed out; this one stays valid.\n * Errors: 400 when the new password fails the policy, 401 when the\n * current one is wrong. */\n async changePassword(input: ChangePasswordInput): Promise<{ revoked_sessions: number }> {\n return this.http.post<{ revoked_sessions: number }>(\"/auth/password\", {\n body: input,\n });\n }\n\n /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for\n * telegram/email; for TOTP it short-circuits back to the challenge. */\n async switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse> {\n return this.http.post<OtpSentResponse>(\"/auth/login/2fa/switch\", {\n body: input,\n skipAuth: true,\n });\n }\n\n /** Exchange a signed Telegram Mini App `initData` payload for a session\n * JWT. The server validates the initData HMAC against the deployment's bot\n * token, then looks the Telegram id up. A known id signs in. An unknown id\n * gets a fresh account (`user.email_pending === true` — prompt for a real\n * email and call {@link linkEmail}) unless `provision: false` is passed, in\n * which case the call resolves to `{ stage: \"unknown\" }`, nothing is\n * created and nothing is stored; the app then offers to create the account\n * (call again with `provision: true`) or to attach the Telegram to an\n * existing one ({@link linkTelegram}). Stores the JWT on `stage: \"jwt\"`.\n *\n * Every other error still throws an `ApiError` (401 `invalid_init_data`,\n * 503 `telegram_not_configured`, …).\n *\n * Most consumers use the higher-level `fromInitData` / `fromTelegramWebApp`\n * helpers in `@takeal/cusfront-sdk/telegram`; reach for this directly when\n * you already hold a configured client. */\n exchangeTelegram(input: { initData: string; provision?: true }): Promise<JwtIssued>;\n exchangeTelegram(input: ExchangeTelegramInput): Promise<JwtIssued | TelegramUnknown>;\n async exchangeTelegram(input: ExchangeTelegramInput): Promise<JwtIssued | TelegramUnknown> {\n const body: {\n init_data: string;\n provision?: boolean;\n attribution?: SignupAttribution;\n code?: string;\n consents?: ConsentKind[];\n consent_channel?: ConsentChannel;\n } = {\n init_data: input.initData,\n };\n if (input.provision !== undefined) body.provision = input.provision;\n if (input.attribution !== undefined) body.attribution = input.attribution;\n if (input.code !== undefined) body.code = input.code;\n if (input.consents !== undefined) body.consents = input.consents;\n if (input.consentChannel !== undefined) body.consent_channel = input.consentChannel;\n let resp: JwtIssued;\n try {\n resp = await this.http.post<JwtIssued>(\"/auth/telegram/exchange\", {\n body,\n skipAuth: true,\n });\n } catch (e) {\n if (isApiError(e) && e.status === 404 && e.code === \"telegram_unknown\") {\n return { stage: \"unknown\" };\n }\n throw e;\n }\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach the Telegram account behind `initData` to an existing email +\n * password account and sign in as that account. No bearer needed; the\n * password is checked the same way `login` checks it. The JWT is stored.\n *\n * Errors: 401 `unauthenticated` (wrong email or password, as with\n * `login`) / `invalid_init_data`; 403\n * `user_disabled` / `second_factor_required` (accounts that sign in with\n * a second factor can't be linked from a Mini App); 409\n * `telegram_already_linked_other` (this account already has a different\n * Telegram; unlink it first) / `telegram_in_use` (this Telegram belongs to\n * another account); 503 `telegram_not_configured`. */\n async linkTelegram(input: LinkTelegramInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/telegram/link\", {\n body: { init_data: input.initData, email: input.email, password: input.password },\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach the first real email to a Telegram-made account (and clear\n * `email_pending`). 409 if taken. An account that already has a real\n * address gets 409 `email_change_needs_code`: change it with\n * {@link requestEmailChange} and {@link confirmEmailChange}. */\n async linkEmail(input: { email: string }): Promise<User> {\n return this.http.post<User>(\"/me/email\", { body: { email: input.email } });\n }\n\n /** Step one of an email change: a six-digit code goes to the new address\n * and works for 5 minutes. Nothing changes yet.\n * Errors: 400 `same_email`, 409 address taken, 429 `too_many_requests`\n * (five codes an hour). */\n async requestEmailChange(input: { email: string }): Promise<EmailChangeRequested> {\n return this.http.post<EmailChangeRequested>(\"/me/email/change\", {\n body: { email: input.email },\n });\n }\n\n /** Step two: the code from the e-mail changes the address; the old one\n * gets a notice. Errors: 401 `invalid_code` (after five wrong codes a new\n * request is needed), 409 the address was taken meanwhile. */\n async confirmEmailChange(input: { challengeId: string; code: string }): Promise<User> {\n return this.http.post<User>(\"/me/email/change/confirm\", {\n body: { challenge_id: input.challengeId, code: input.code },\n });\n }\n\n /** Current user — fails 401 when the stored JWT is expired or\n * missing. Useful as a \"do I have a session\" probe on app boot. */\n async me(): Promise<User> {\n return this.http.get<User>(\"/auth/me\");\n }\n\n /** Sign out: ends this session and the remembered sign-in on the\n * server (best effort: a network failure still signs out locally), then\n * forgets both tokens. */\n async signOut(): Promise<void> {\n const remember = this.remembered ? await Promise.resolve(this.remembered.get()) : null;\n try {\n await this.http.post<void>(\"/auth/logout\", {\n body: remember ? { remember_token: remember } : {},\n retried: true,\n });\n } catch {\n // Signed out locally either way.\n }\n await Promise.resolve(this.tokens.clear());\n if (this.remembered) await Promise.resolve(this.remembered.clear());\n }\n}\n"]}
|
package/dist/resources/cards.cjs
CHANGED
|
@@ -40,6 +40,11 @@ function cardOrderBody(input) {
|
|
|
40
40
|
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
41
41
|
return body;
|
|
42
42
|
}
|
|
43
|
+
function revealState(r) {
|
|
44
|
+
if (r.details_pending) return "pending";
|
|
45
|
+
if (r.reveal_url) return "page";
|
|
46
|
+
return "numbers";
|
|
47
|
+
}
|
|
43
48
|
var CardsResource = class {
|
|
44
49
|
constructor(http) {
|
|
45
50
|
this.http = http;
|
|
@@ -195,15 +200,22 @@ var CardsResource = class {
|
|
|
195
200
|
* keep the result in volatile memory only, never write it to
|
|
196
201
|
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
197
202
|
*
|
|
198
|
-
*
|
|
199
|
-
* when the issuer shows them on a
|
|
200
|
-
* frame right away, it is
|
|
203
|
+
* `state` tells the three answers apart: `numbers`; `page`, with
|
|
204
|
+
* `reveal_url` and empty `pan` and `cvv` when the issuer shows them on a
|
|
205
|
+
* page of its own (open that page in a frame right away, it is
|
|
206
|
+
* short-lived); or `pending` while the card's details are still being
|
|
207
|
+
* prepared, which doesn't count against the limit. A card says the same
|
|
208
|
+
* in {@link Card.details_pending}, so there is no need to call this just
|
|
209
|
+
* to find out.
|
|
201
210
|
*
|
|
202
211
|
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
203
212
|
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
204
213
|
*/
|
|
205
214
|
async reveal(id, _input) {
|
|
206
|
-
|
|
215
|
+
const r = await this.http.post(
|
|
216
|
+
`/me/cards/${encodeURIComponent(id)}/reveal`
|
|
217
|
+
);
|
|
218
|
+
return { ...r, state: revealState(r) };
|
|
207
219
|
}
|
|
208
220
|
/**
|
|
209
221
|
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
@@ -261,5 +273,6 @@ var CardsResource = class {
|
|
|
261
273
|
exports.CardsResource = CardsResource;
|
|
262
274
|
exports.cardOrderBody = cardOrderBody;
|
|
263
275
|
exports.cardRequestBody = cardRequestBody;
|
|
276
|
+
exports.revealState = revealState;
|
|
264
277
|
//# sourceMappingURL=cards.cjs.map
|
|
265
278
|
//# sourceMappingURL=cards.cjs.map
|