@takeal/cusfront-sdk 0.3.12 → 0.3.18

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/cards.ts"],"names":[],"mappings":";;;AA8NO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhD,MAAM,OAAO,KAAA,EAAuC;AAClD,IAAA,MAAM,EAAE,cAAA,EAAgB,SAAA,EAAW,MAAM,QAAA,EAAU,GAAG,MAAK,GAAI,KAAA;AAC/D,IAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,IAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,IAAA,IAAI,IAAA,KAAS,MAAA,EAAW,IAAA,CAAK,MAAM,CAAA,GAAI,IAAA;AACvC,IAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAW,WAAA,EAAa;AAAA,MACvC,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YAAA,GAAuC;AAC3C,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAmB,mBAAmB,CAAA;AAAA,EACzD;AAAA;AAAA,EAGA,MAAM,WAAW,EAAA,EAAkC;AACjD,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA;AAAA,MACf,CAAA,kBAAA,EAAqB,kBAAA,CAAmB,EAAE,CAAC,CAAA;AAAA,KAC7C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;A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KACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,MAAA,CAAO,EAAA,EAAY,MAAA,EAAiD;AACxE,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA,CAAS,CAAA;AAAA,EAClF;AAAA;AAAA,EAGA,MAAM,SAAS,EAAA,EAA2B;AACxC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,SAAA,CAAA;AAAA,MACnC,EAAE,IAAA,EAAM,EAAC;AAAE,KACb;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAA,CAAU,EAAA,EAAY,MAAA,EAAgC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA;AAAA,MACnC,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO;AAAE,KACrB;AAAA,EACF;AACF","file":"cards.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.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 /me/card-products → listProducts (the catalog)\n * GET /me/card-products/{id} → getProduct\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}/terminate → terminate (one-way)\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 * ## What is intentionally NOT here\n *\n * Card-data reveal (PAN / CVV) is a separate, security-sensitive flow with its\n * own re-auth + rate-limit + audit contract and is intentionally\n * NOT part of this resource (tracked separately).\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` is a transient state: the row exists but the\n * per-card issuance-fee debit has not yet succeeded; such cards have no\n * provider reference and no user-visible side effects.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"active\"\n | \"frozen\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\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 amount: string;\n currency: string;\n label: string;\n base_amount: string;\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. `designs` is the set the\n * user may pick from (may be empty when only the default applies); `design`\n * is what the card gets when no choice is made. `price` is `null` for a\n * 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 description: 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 /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\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 /** Decimal as a string. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | 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}\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 /** Decimal as a string. The prepaid load amount drained from wallet balance. */\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 * 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/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\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 */\nexport interface RevealedCard {\n pan: string;\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\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 */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, productId, name, designId, ...rest } = 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 return this.http.post<Card>(\"/me/cards\", {\n body,\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the deployment offers them\n * (the default product first). Each item carries its name, description,\n * artwork, the issuance price after the caller's subscription discount,\n * and the currency. Pass an item's `id` as `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>(\n `/me/card-products/${encodeURIComponent(id)}`,\n );\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>(\n `/me/cards/${encodeURIComponent(id)}/balance?${q}`,\n );\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional\n * `reason` is recorded on the audit trail. Resolves to the updated card.\n * 404 if the card isn't the caller's; 501 if the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/freeze`,\n { body: { reason } },\n );\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 * 401 bad re-auth · 403 not your card · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 provider error.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/unfreeze`,\n { body: {} },\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.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/terminate`,\n { body: { reason } },\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/cards.ts"],"names":[],"mappings":";;;AA+NO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhD,MAAM,OAAO,KAAA,EAAuC;AAClD,IAAA,MAAM,EAAE,cAAA,EAAgB,SAAA,EAAW,MAAM,QAAA,EAAU,GAAG,MAAK,GAAI,KAAA;AAC/D,IAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,IAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,IAAA,IAAI,IAAA,KAAS,MAAA,EAAW,IAAA,CAAK,MAAM,CAAA,GAAI,IAAA;AACvC,IAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,IAAA,O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AAAA,MACf,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA;AAAA,MACnC,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO;AAAE,KACrB;AAAA,EACF;AACF","file":"cards.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.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 * 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}/terminate → terminate (one-way)\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 * ## What is intentionally NOT here\n *\n * Card-data reveal (PAN / CVV) is a separate, security-sensitive flow with its\n * own re-auth + rate-limit + audit contract and is intentionally\n * NOT part of this resource (tracked separately).\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` is a transient state: the row exists but the\n * per-card issuance-fee debit has not yet succeeded; such cards have no\n * provider reference and no user-visible side effects.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"active\"\n | \"frozen\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\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 amount: string;\n currency: string;\n label: string;\n base_amount: string;\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. `designs` is the set the\n * user may pick from (may be empty when only the default applies); `design`\n * is what the card gets when no choice is made. `price` is `null` for a\n * 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 description: 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 /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\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 /** Decimal as a string. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | 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}\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 /** Decimal as a string. The prepaid load amount drained from wallet balance. */\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 * 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/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\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 */\nexport interface RevealedCard {\n pan: string;\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\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 */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, productId, name, designId, ...rest } = 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 return this.http.post<Card>(\"/me/cards\", {\n body,\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the deployment offers them\n * (the default product first). Each item carries its name, description,\n * artwork, the issuance price after the caller's subscription discount,\n * and the currency. Pass an item's `id` as `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>(\n `/me/card-products/${encodeURIComponent(id)}`,\n );\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>(\n `/me/cards/${encodeURIComponent(id)}/balance?${q}`,\n );\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional\n * `reason` is recorded on the audit trail. Resolves to the updated card.\n * 404 if the card isn't the caller's; 501 if the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/freeze`,\n { body: { reason } },\n );\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 * 401 bad re-auth · 403 not your card · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 provider error.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/unfreeze`,\n { body: {} },\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.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/terminate`,\n { body: { reason } },\n );\n }\n}\n"]}
@@ -8,7 +8,8 @@ import { C as CustomerInfo } from '../customer-CoxPwe5o.cjs';
8
8
  * their wallet balance via an issuer connector. Mirrors the Takeal API's
9
9
  * `/me/cards` routes:
10
10
  *
11
- * GET /me/card-products → listProducts (the catalog)
11
+ * GET /card-products → catalog (public, before sign-in)
12
+ * GET /me/card-products → listProducts (the catalog, personal price)
12
13
  * GET /me/card-products/{id} → getProduct
13
14
  * POST /me/cards → create
14
15
  * GET /me/cards → list (most recent first)
@@ -224,6 +225,14 @@ declare class CardsResource {
224
225
  listProducts(): Promise<CardProduct[]>;
225
226
  /** One product from the catalog. 404 when unknown, disabled or hidden. */
226
227
  getProduct(id: string): Promise<CardProduct>;
228
+ /**
229
+ * The public catalog: the same products, order and default as
230
+ * {@link listProducts}, but readable before sign-in, for a landing page or
231
+ * the cabinet's first screen. Prices are list prices (`discount_bps` is
232
+ * always 0); once the user is signed in, {@link listProducts} shows what
233
+ * they pay. The API lets caches keep this response for a minute.
234
+ */
235
+ catalog(): Promise<CardProduct[]>;
227
236
  /**
228
237
  * Rename the caller's own card or change its design. Resolves to the
229
238
  * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
@@ -8,7 +8,8 @@ import { C as CustomerInfo } from '../customer-CoxPwe5o.js';
8
8
  * their wallet balance via an issuer connector. Mirrors the Takeal API's
9
9
  * `/me/cards` routes:
10
10
  *
11
- * GET /me/card-products → listProducts (the catalog)
11
+ * GET /card-products → catalog (public, before sign-in)
12
+ * GET /me/card-products → listProducts (the catalog, personal price)
12
13
  * GET /me/card-products/{id} → getProduct
13
14
  * POST /me/cards → create
14
15
  * GET /me/cards → list (most recent first)
@@ -224,6 +225,14 @@ declare class CardsResource {
224
225
  listProducts(): Promise<CardProduct[]>;
225
226
  /** One product from the catalog. 404 when unknown, disabled or hidden. */
226
227
  getProduct(id: string): Promise<CardProduct>;
228
+ /**
229
+ * The public catalog: the same products, order and default as
230
+ * {@link listProducts}, but readable before sign-in, for a landing page or
231
+ * the cabinet's first screen. Prices are list prices (`discount_bps` is
232
+ * always 0); once the user is signed in, {@link listProducts} shows what
233
+ * they pay. The API lets caches keep this response for a minute.
234
+ */
235
+ catalog(): Promise<CardProduct[]>;
227
236
  /**
228
237
  * Rename the caller's own card or change its design. Resolves to the
229
238
  * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
@@ -35,6 +35,16 @@ var CardsResource = class {
35
35
  `/me/card-products/${encodeURIComponent(id)}`
36
36
  );
37
37
  }
38
+ /**
39
+ * The public catalog: the same products, order and default as
40
+ * {@link listProducts}, but readable before sign-in, for a landing page or
41
+ * the cabinet's first screen. Prices are list prices (`discount_bps` is
42
+ * always 0); once the user is signed in, {@link listProducts} shows what
43
+ * they pay. The API lets caches keep this response for a minute.
44
+ */
45
+ async catalog() {
46
+ return this.http.get("/card-products");
47
+ }
38
48
  /**
39
49
  * Rename the caller's own card or change its design. Resolves to the
40
50
  * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/cards.ts"],"names":[],"mappings":";AA8NO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhD,MAAM,OAAO,KAAA,EAAuC;AAClD,IAAA,MAAM,EAAE,cAAA,EAAgB,SAAA,EAAW,MAAM,QAAA,EAAU,GAAG,MAAK,GAAI,KAAA;AAC/D,IAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,IAAA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M,SAAA,CAAU,EAAA,EAAY,MAAA,EAAgC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA;AAAA,MACnC,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO;AAAE,KACrB;AAAA,EACF;AACF","file":"cards.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.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 /me/card-products → listProducts (the catalog)\n * GET /me/card-products/{id} → getProduct\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}/terminate → terminate (one-way)\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 * ## What is intentionally NOT here\n *\n * Card-data reveal (PAN / CVV) is a separate, security-sensitive flow with its\n * own re-auth + rate-limit + audit contract and is intentionally\n * NOT part of this resource (tracked separately).\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` is a transient state: the row exists but the\n * per-card issuance-fee debit has not yet succeeded; such cards have no\n * provider reference and no user-visible side effects.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"active\"\n | \"frozen\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\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 amount: string;\n currency: string;\n label: string;\n base_amount: string;\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. `designs` is the set the\n * user may pick from (may be empty when only the default applies); `design`\n * is what the card gets when no choice is made. `price` is `null` for a\n * 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 description: 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 /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\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 /** Decimal as a string. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | 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}\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 /** Decimal as a string. The prepaid load amount drained from wallet balance. */\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 * 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/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\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 */\nexport interface RevealedCard {\n pan: string;\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\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 */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, productId, name, designId, ...rest } = 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 return this.http.post<Card>(\"/me/cards\", {\n body,\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the deployment offers them\n * (the default product first). Each item carries its name, description,\n * artwork, the issuance price after the caller's subscription discount,\n * and the currency. Pass an item's `id` as `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>(\n `/me/card-products/${encodeURIComponent(id)}`,\n );\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>(\n `/me/cards/${encodeURIComponent(id)}/balance?${q}`,\n );\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional\n * `reason` is recorded on the audit trail. Resolves to the updated card.\n * 404 if the card isn't the caller's; 501 if the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/freeze`,\n { body: { reason } },\n );\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 * 401 bad re-auth · 403 not your card · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 provider error.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/unfreeze`,\n { body: {} },\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.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n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AAE,CAAC,CAAA,OAAA,CAAA;AAAA,MACnC,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO;AAAE,KACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,MAAA,CAAO,EAAA,EAAY,MAAA,EAAiD;AACxE,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA,CAAS,CAAA;AAAA,EAClF;AAAA;AAAA,EAGA,MAAM,SAAS,EAAA,EAA2B;AACxC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,SAAA,CAAA;AAAA,MACnC,EAAE,IAAA,EAAM,EAAC;AAAE,KACb;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAA,CAAU,EAAA,EAAY,MAAA,EAAgC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA;AAAA,MACnC,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO;AAAE,KACrB;AAAA,EACF;AACF","file":"cards.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.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 * 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}/terminate → terminate (one-way)\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 * ## What is intentionally NOT here\n *\n * Card-data reveal (PAN / CVV) is a separate, security-sensitive flow with its\n * own re-auth + rate-limit + audit contract and is intentionally\n * NOT part of this resource (tracked separately).\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` is a transient state: the row exists but the\n * per-card issuance-fee debit has not yet succeeded; such cards have no\n * provider reference and no user-visible side effects.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"active\"\n | \"frozen\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\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 amount: string;\n currency: string;\n label: string;\n base_amount: string;\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. `designs` is the set the\n * user may pick from (may be empty when only the default applies); `design`\n * is what the card gets when no choice is made. `price` is `null` for a\n * 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 description: 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 /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\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 /** Decimal as a string. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | 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}\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 /** Decimal as a string. The prepaid load amount drained from wallet balance. */\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 * 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/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\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 */\nexport interface RevealedCard {\n pan: string;\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\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 */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, productId, name, designId, ...rest } = 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 return this.http.post<Card>(\"/me/cards\", {\n body,\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the deployment offers them\n * (the default product first). Each item carries its name, description,\n * artwork, the issuance price after the caller's subscription discount,\n * and the currency. Pass an item's `id` as `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>(\n `/me/card-products/${encodeURIComponent(id)}`,\n );\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>(\n `/me/cards/${encodeURIComponent(id)}/balance?${q}`,\n );\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional\n * `reason` is recorded on the audit trail. Resolves to the updated card.\n * 404 if the card isn't the caller's; 501 if the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/freeze`,\n { body: { reason } },\n );\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 * 401 bad re-auth · 403 not your card · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 provider error.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/unfreeze`,\n { body: {} },\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.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(\n `/me/cards/${encodeURIComponent(id)}/terminate`,\n { body: { reason } },\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/deposits.ts"],"names":[],"mappings":";;;AAyJO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYhD,MAAM,MAAM,KAAA,EAAgD;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,uBAAuB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC5E;AAAA,EAEA,MAAM,SAAS,KAAA,EAA+C;AAC5D,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAc,cAAA,EAAgB;AAAA,MAC7C,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,EAAA,EAA8B;AACtC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAa,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,IAAA,GAA2B;AAC/B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAe,cAAc,CAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,CACJ,SAAA,EACA,KAAA,EACiB;AACjB,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,aAAA,EAAgB,kBAAA,CAAmB,SAAS,CAAC,CAAA,QAAA,CAAA;AAAA,MAC7C,EAAE,MAAM,cAAA;AAAe,KACzB;AAAA,EACF;AACF","file":"deposits.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\n\n/**\n * Deposits resource — `client.deposits.*`.\n *\n * The \"money IN\" surface: an end user tops up their wallet balance via a\n * funder connector. Mirrors the Takeal API's `/me/deposits` routes:\n *\n * POST /me/deposits → initiate\n * GET /me/deposits → list (most recent first)\n * GET /me/deposits/{id} → get\n * POST /me/deposits/{id}/refunds → refund\n *\n * A deposit is rarely terminal on the initiate call: real PSPs return\n * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via\n * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's\n * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.\n */\n\n/** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */\nexport type DepositStatus =\n | \"pending\"\n | \"redirect_required\"\n | \"confirmed\"\n | \"failed\";\n\n/** Top-up rail. The chosen funder decides which it supports. */\nexport type DepositMethod = \"card\" | \"crypto\" | \"bank_transfer\";\n\n/**\n * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the\n * server-side `id` is the stable handle the SDK polls against. `idempotency_key`\n * and `request_fingerprint` are server-internal and never serialised.\n */\n/** Input for `quote()` — price a cross-currency deposit before paying. */\nexport interface CreateQuoteInput {\n /** Decimal string, e.g. `\"5000.00\"`. */\n amount: string;\n /** ISO 4217 source currency — must differ from the wallet's local currency. */\n currency: string;\n}\n\n/**\n * A rate-locked funding quote: pay `source_amount source_currency`, the\n * wallet is credited `credited_amount credited_currency` (net of the\n * platform's conversion spread). Execute by passing `id` as `quote_id` to\n * `initiate()` before `expires_at`; after that the API returns 409 and a new\n * quote is needed.\n */\nexport interface FundingQuote {\n id: string;\n source_amount: string;\n source_currency: string;\n credited_amount: string;\n credited_currency: string;\n /** Provider rate before spread (credited units per 1 source unit). */\n rate: string;\n spread_bps: number;\n provider: string;\n expires_at: string;\n}\n\nexport interface Deposit {\n id: string;\n user_id: string;\n /** Slug of the funder that handled this deposit, as configured by the deployment. */\n connector_slug: string;\n /** The connector's own reference, populated once it responds. */\n provider_reference: string | null;\n status: DepositStatus;\n /** Decimal serialised as a string to avoid float drift. */\n amount: string;\n currency: string;\n method: DepositMethod;\n /** Present when `status === \"redirect_required\"` — send the user here. */\n redirect_url: string | null;\n failure_reason: string | null;\n /** Final settled amount once confirmed (may differ from `amount` on FX). */\n confirmed_amount: string | null;\n confirmed_at: string | null;\n /** Set on cross-currency deposits: the quote this deposit executed against. */\n quote_id?: string | null;\n /** Locked provider rate (credited units per 1 source unit). */\n fx_rate?: string | null;\n fx_spread_bps?: number | null;\n /** The wallet's local currency the deposit converted into. */\n credited_currency?: string | null;\n /** What the wallet was actually credited, net of spread. */\n credited_amount?: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface InitiateDepositInput {\n /** Decimal as a string (`\"100.00\"`) — avoids float-precision loss on the wire. */\n amount: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n method: DepositMethod;\n /**\n * Optional. Slug of a specific funder to route through. Omit to\n * let the Takeal API pick the first active funder. Unknown slug → 400; empty\n * funder list → 503.\n */\n funder_slug?: string;\n /** Provider-specific extras. The mock funder reads `mock_scenario`. */\n metadata?: Record<string, string>;\n /** Structured billing details — real PSPs require these for 3DS / compliance. */\n customer?: CustomerInfo;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original deposit; same key + different body returns 409. Supply a stable\n * UUID per logical attempt so a retried network call is safe.\n */\n idempotencyKey: string;\n /**\n * Required when `currency` differs from the wallet's local currency: a\n * fresh quote id from `quote()`. Cross-currency deposits without one are\n * rejected with 400; expired quotes with 409.\n */\n quote_id?: string;\n}\n\nexport interface CreateDepositRefundInput {\n /** Omit for a full refund of the original confirmed amount; same currency. */\n amount?: string;\n /** Human-readable reason, e.g. `\"customer_request\"`. */\n reason?: string;\n metadata?: Record<string, string>;\n /** Required. Replays are keyed on this. */\n idempotencyKey: string;\n}\n\n/** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */\nexport interface Refund {\n id: string;\n target_type: string;\n deposit_id?: string;\n payment_id?: string;\n connector_slug: string;\n amount: string;\n currency: string;\n reason: string;\n status: string;\n provider_refund_reference?: string;\n failure_reason?: string;\n requestor_type: string;\n requestor_id: string;\n created_at: string;\n updated_at: string;\n}\n\nexport class DepositsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose\n * `status` may already be `confirmed` (synchronous rails / mock) or\n * `redirect_required` (3DS / APM — forward the user to `redirect_url`).\n */\n /**\n * Price a cross-currency deposit BEFORE paying. The rate is locked\n * server-side until `expires_at`; deposits in the local currency need no\n * quote (the API answers 400 `no_quote_needed`).\n */\n async quote(input: CreateQuoteInput): Promise<FundingQuote> {\n return this.http.post<FundingQuote>(\"/me/deposits/quotes\", { body: input });\n }\n\n async initiate(input: InitiateDepositInput): Promise<Deposit> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Deposit>(\"/me/deposits\", {\n body,\n idempotencyKey,\n });\n }\n\n /** Fetch one deposit by id — the poll target while a redirect resolves. */\n async get(id: string): Promise<Deposit> {\n return this.http.get<Deposit>(`/me/deposits/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's deposits, most recent first. */\n async list(): Promise<Deposit[]> {\n return this.http.get<Deposit[]>(\"/me/deposits\");\n }\n\n /**\n * Refund a previously-confirmed deposit. Synchronous when the\n * connector settles inline; otherwise the row stays `pending` and flips\n * later via the inbound `deposit.refunded` event.\n */\n async refund(\n depositId: string,\n input: CreateDepositRefundInput,\n ): Promise<Refund> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Refund>(\n `/me/deposits/${encodeURIComponent(depositId)}/refunds`,\n { body, idempotencyKey },\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/deposits.ts"],"names":[],"mappings":";;;AAiKO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYhD,MAAM,MAAM,KAAA,EAAgD;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,uBAAuB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC5E;AAAA,EAEA,MAAM,SAAS,KAAA,EAA+C;AAC5D,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAc,cAAA,EAAgB;AAAA,MAC7C,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,EAAA,EAA8B;AACtC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAa,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,IAAA,GAA2B;AAC/B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAe,cAAc,CAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,CACJ,SAAA,EACA,KAAA,EACiB;AACjB,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,aAAA,EAAgB,kBAAA,CAAmB,SAAS,CAAC,CAAA,QAAA,CAAA;AAAA,MAC7C,EAAE,MAAM,cAAA;AAAe,KACzB;AAAA,EACF;AACF","file":"deposits.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\n\n/**\n * Deposits resource — `client.deposits.*`.\n *\n * The \"money IN\" surface: an end user tops up their wallet balance via a\n * funder connector. Mirrors the Takeal API's `/me/deposits` routes:\n *\n * POST /me/deposits → initiate\n * GET /me/deposits → list (most recent first)\n * GET /me/deposits/{id} → get\n * POST /me/deposits/{id}/refunds → refund\n *\n * A deposit is rarely terminal on the initiate call: real PSPs return\n * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via\n * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's\n * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.\n */\n\n/** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */\nexport type DepositStatus =\n | \"pending\"\n | \"redirect_required\"\n | \"confirmed\"\n | \"failed\";\n\n/** Top-up rail. The chosen funder decides which it supports. */\nexport type DepositMethod = \"card\" | \"crypto\" | \"bank_transfer\";\n\n/**\n * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the\n * server-side `id` is the stable handle the SDK polls against. `idempotency_key`\n * and `request_fingerprint` are server-internal and never serialised.\n */\n/** Input for `quote()` — price a cross-currency deposit before paying. */\nexport interface CreateQuoteInput {\n /** Decimal string, e.g. `\"5000.00\"`. */\n amount: string;\n /** ISO 4217 source currency — must differ from the wallet's local currency. */\n currency: string;\n}\n\n/**\n * A rate-locked funding quote: pay `source_amount source_currency`, the\n * wallet is credited `credited_amount credited_currency` (net of the\n * platform's conversion spread). Execute by passing `id` as `quote_id` to\n * `initiate()` before `expires_at`; after that the API returns 409 and a new\n * quote is needed.\n */\nexport interface FundingQuote {\n id: string;\n source_amount: string;\n source_currency: string;\n credited_amount: string;\n credited_currency: string;\n /** Provider rate before spread (credited units per 1 source unit). */\n rate: string;\n spread_bps: number;\n provider: string;\n expires_at: string;\n}\n\nexport interface Deposit {\n id: string;\n user_id: string;\n /** Slug of the funder that handled this deposit, as configured by the deployment. */\n connector_slug: string;\n /** The connector's own reference, populated once it responds. */\n provider_reference: string | null;\n status: DepositStatus;\n /** Decimal serialised as a string to avoid float drift. */\n amount: string;\n currency: string;\n method: DepositMethod;\n /** Present when `status === \"redirect_required\"` — send the user here. */\n redirect_url: string | null;\n failure_reason: string | null;\n /** Final settled amount once confirmed (may differ from `amount` on FX). */\n confirmed_amount: string | null;\n confirmed_at: string | null;\n /** Set on cross-currency deposits: the quote this deposit executed against. */\n quote_id?: string | null;\n /** Locked provider rate (credited units per 1 source unit). */\n fx_rate?: string | null;\n fx_spread_bps?: number | null;\n /** The wallet's local currency the deposit converted into. */\n credited_currency?: string | null;\n /** What the wallet was actually credited, net of spread. */\n credited_amount?: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface InitiateDepositInput {\n /** Decimal as a string (`\"100.00\"`) — avoids float-precision loss on the wire. */\n amount: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n method: DepositMethod;\n /**\n * Optional. Slug of a specific funder to route through. Omit to\n * let the Takeal API pick the first active funder. Unknown slug → 400; empty\n * funder list → 503.\n */\n funder_slug?: string;\n /**\n * Passed to the funding connector and stored with the deposit. Two keys\n * work across connectors: `return_url`, where the provider sends the user\n * back after a 3-D Secure step (pair it with `redirect_required`), and on\n * test deployments with the mock funder `mock_scenario`, which picks the\n * outcome: `happy` (confirmed at once, the default), `pending` (confirmed\n * about 15 s later), `redirect` (a hosted page where the user approves or\n * declines) or `fail`.\n */\n metadata?: Record<string, string>;\n /** Structured billing details — real PSPs require these for 3DS / compliance. */\n customer?: CustomerInfo;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original deposit; same key + different body returns 409. Supply a stable\n * UUID per logical attempt so a retried network call is safe.\n */\n idempotencyKey: string;\n /**\n * Required when `currency` differs from the wallet's local currency: a\n * fresh quote id from `quote()`. Cross-currency deposits without one are\n * rejected with 400; expired quotes with 409.\n */\n quote_id?: string;\n}\n\nexport interface CreateDepositRefundInput {\n /** Omit for a full refund of the original confirmed amount; same currency. */\n amount?: string;\n /** Human-readable reason, e.g. `\"customer_request\"`. */\n reason?: string;\n metadata?: Record<string, string>;\n /** Required. Replays are keyed on this. */\n idempotencyKey: string;\n}\n\n/** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */\nexport interface Refund {\n id: string;\n target_type: string;\n deposit_id?: string;\n payment_id?: string;\n connector_slug: string;\n amount: string;\n currency: string;\n reason: string;\n status: string;\n provider_refund_reference?: string;\n failure_reason?: string;\n requestor_type: string;\n requestor_id: string;\n created_at: string;\n updated_at: string;\n}\n\nexport class DepositsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose\n * `status` may already be `confirmed` (synchronous rails / mock) or\n * `redirect_required` (3DS / APM — forward the user to `redirect_url`).\n */\n /**\n * Price a cross-currency deposit BEFORE paying. The rate is locked\n * server-side until `expires_at`; deposits in the local currency need no\n * quote (the API answers 400 `no_quote_needed`).\n */\n async quote(input: CreateQuoteInput): Promise<FundingQuote> {\n return this.http.post<FundingQuote>(\"/me/deposits/quotes\", { body: input });\n }\n\n async initiate(input: InitiateDepositInput): Promise<Deposit> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Deposit>(\"/me/deposits\", {\n body,\n idempotencyKey,\n });\n }\n\n /** Fetch one deposit by id — the poll target while a redirect resolves. */\n async get(id: string): Promise<Deposit> {\n return this.http.get<Deposit>(`/me/deposits/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's deposits, most recent first. */\n async list(): Promise<Deposit[]> {\n return this.http.get<Deposit[]>(\"/me/deposits\");\n }\n\n /**\n * Refund a previously-confirmed deposit. Synchronous when the\n * connector settles inline; otherwise the row stays `pending` and flips\n * later via the inbound `deposit.refunded` event.\n */\n async refund(\n depositId: string,\n input: CreateDepositRefundInput,\n ): Promise<Refund> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Refund>(\n `/me/deposits/${encodeURIComponent(depositId)}/refunds`,\n { body, idempotencyKey },\n );\n }\n}\n"]}
@@ -94,7 +94,15 @@ interface InitiateDepositInput {
94
94
  * funder list → 503.
95
95
  */
96
96
  funder_slug?: string;
97
- /** Provider-specific extras. The mock funder reads `mock_scenario`. */
97
+ /**
98
+ * Passed to the funding connector and stored with the deposit. Two keys
99
+ * work across connectors: `return_url`, where the provider sends the user
100
+ * back after a 3-D Secure step (pair it with `redirect_required`), and on
101
+ * test deployments with the mock funder `mock_scenario`, which picks the
102
+ * outcome: `happy` (confirmed at once, the default), `pending` (confirmed
103
+ * about 15 s later), `redirect` (a hosted page where the user approves or
104
+ * declines) or `fail`.
105
+ */
98
106
  metadata?: Record<string, string>;
99
107
  /** Structured billing details — real PSPs require these for 3DS / compliance. */
100
108
  customer?: CustomerInfo;
@@ -94,7 +94,15 @@ interface InitiateDepositInput {
94
94
  * funder list → 503.
95
95
  */
96
96
  funder_slug?: string;
97
- /** Provider-specific extras. The mock funder reads `mock_scenario`. */
97
+ /**
98
+ * Passed to the funding connector and stored with the deposit. Two keys
99
+ * work across connectors: `return_url`, where the provider sends the user
100
+ * back after a 3-D Secure step (pair it with `redirect_required`), and on
101
+ * test deployments with the mock funder `mock_scenario`, which picks the
102
+ * outcome: `happy` (confirmed at once, the default), `pending` (confirmed
103
+ * about 15 s later), `redirect` (a hosted page where the user approves or
104
+ * declines) or `fail`.
105
+ */
98
106
  metadata?: Record<string, string>;
99
107
  /** Structured billing details — real PSPs require these for 3DS / compliance. */
100
108
  customer?: CustomerInfo;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/deposits.ts"],"names":[],"mappings":";AAyJO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYhD,MAAM,MAAM,KAAA,EAAgD;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,uBAAuB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC5E;AAAA,EAEA,MAAM,SAAS,KAAA,EAA+C;AAC5D,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAc,cAAA,EAAgB;AAAA,MAC7C,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,EAAA,EAA8B;AACtC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAa,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,IAAA,GAA2B;AAC/B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAe,cAAc,CAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,CACJ,SAAA,EACA,KAAA,EACiB;AACjB,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,aAAA,EAAgB,kBAAA,CAAmB,SAAS,CAAC,CAAA,QAAA,CAAA;AAAA,MAC7C,EAAE,MAAM,cAAA;AAAe,KACzB;AAAA,EACF;AACF","file":"deposits.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\n\n/**\n * Deposits resource — `client.deposits.*`.\n *\n * The \"money IN\" surface: an end user tops up their wallet balance via a\n * funder connector. Mirrors the Takeal API's `/me/deposits` routes:\n *\n * POST /me/deposits → initiate\n * GET /me/deposits → list (most recent first)\n * GET /me/deposits/{id} → get\n * POST /me/deposits/{id}/refunds → refund\n *\n * A deposit is rarely terminal on the initiate call: real PSPs return\n * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via\n * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's\n * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.\n */\n\n/** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */\nexport type DepositStatus =\n | \"pending\"\n | \"redirect_required\"\n | \"confirmed\"\n | \"failed\";\n\n/** Top-up rail. The chosen funder decides which it supports. */\nexport type DepositMethod = \"card\" | \"crypto\" | \"bank_transfer\";\n\n/**\n * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the\n * server-side `id` is the stable handle the SDK polls against. `idempotency_key`\n * and `request_fingerprint` are server-internal and never serialised.\n */\n/** Input for `quote()` — price a cross-currency deposit before paying. */\nexport interface CreateQuoteInput {\n /** Decimal string, e.g. `\"5000.00\"`. */\n amount: string;\n /** ISO 4217 source currency — must differ from the wallet's local currency. */\n currency: string;\n}\n\n/**\n * A rate-locked funding quote: pay `source_amount source_currency`, the\n * wallet is credited `credited_amount credited_currency` (net of the\n * platform's conversion spread). Execute by passing `id` as `quote_id` to\n * `initiate()` before `expires_at`; after that the API returns 409 and a new\n * quote is needed.\n */\nexport interface FundingQuote {\n id: string;\n source_amount: string;\n source_currency: string;\n credited_amount: string;\n credited_currency: string;\n /** Provider rate before spread (credited units per 1 source unit). */\n rate: string;\n spread_bps: number;\n provider: string;\n expires_at: string;\n}\n\nexport interface Deposit {\n id: string;\n user_id: string;\n /** Slug of the funder that handled this deposit, as configured by the deployment. */\n connector_slug: string;\n /** The connector's own reference, populated once it responds. */\n provider_reference: string | null;\n status: DepositStatus;\n /** Decimal serialised as a string to avoid float drift. */\n amount: string;\n currency: string;\n method: DepositMethod;\n /** Present when `status === \"redirect_required\"` — send the user here. */\n redirect_url: string | null;\n failure_reason: string | null;\n /** Final settled amount once confirmed (may differ from `amount` on FX). */\n confirmed_amount: string | null;\n confirmed_at: string | null;\n /** Set on cross-currency deposits: the quote this deposit executed against. */\n quote_id?: string | null;\n /** Locked provider rate (credited units per 1 source unit). */\n fx_rate?: string | null;\n fx_spread_bps?: number | null;\n /** The wallet's local currency the deposit converted into. */\n credited_currency?: string | null;\n /** What the wallet was actually credited, net of spread. */\n credited_amount?: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface InitiateDepositInput {\n /** Decimal as a string (`\"100.00\"`) — avoids float-precision loss on the wire. */\n amount: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n method: DepositMethod;\n /**\n * Optional. Slug of a specific funder to route through. Omit to\n * let the Takeal API pick the first active funder. Unknown slug → 400; empty\n * funder list → 503.\n */\n funder_slug?: string;\n /** Provider-specific extras. The mock funder reads `mock_scenario`. */\n metadata?: Record<string, string>;\n /** Structured billing details — real PSPs require these for 3DS / compliance. */\n customer?: CustomerInfo;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original deposit; same key + different body returns 409. Supply a stable\n * UUID per logical attempt so a retried network call is safe.\n */\n idempotencyKey: string;\n /**\n * Required when `currency` differs from the wallet's local currency: a\n * fresh quote id from `quote()`. Cross-currency deposits without one are\n * rejected with 400; expired quotes with 409.\n */\n quote_id?: string;\n}\n\nexport interface CreateDepositRefundInput {\n /** Omit for a full refund of the original confirmed amount; same currency. */\n amount?: string;\n /** Human-readable reason, e.g. `\"customer_request\"`. */\n reason?: string;\n metadata?: Record<string, string>;\n /** Required. Replays are keyed on this. */\n idempotencyKey: string;\n}\n\n/** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */\nexport interface Refund {\n id: string;\n target_type: string;\n deposit_id?: string;\n payment_id?: string;\n connector_slug: string;\n amount: string;\n currency: string;\n reason: string;\n status: string;\n provider_refund_reference?: string;\n failure_reason?: string;\n requestor_type: string;\n requestor_id: string;\n created_at: string;\n updated_at: string;\n}\n\nexport class DepositsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose\n * `status` may already be `confirmed` (synchronous rails / mock) or\n * `redirect_required` (3DS / APM — forward the user to `redirect_url`).\n */\n /**\n * Price a cross-currency deposit BEFORE paying. The rate is locked\n * server-side until `expires_at`; deposits in the local currency need no\n * quote (the API answers 400 `no_quote_needed`).\n */\n async quote(input: CreateQuoteInput): Promise<FundingQuote> {\n return this.http.post<FundingQuote>(\"/me/deposits/quotes\", { body: input });\n }\n\n async initiate(input: InitiateDepositInput): Promise<Deposit> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Deposit>(\"/me/deposits\", {\n body,\n idempotencyKey,\n });\n }\n\n /** Fetch one deposit by id — the poll target while a redirect resolves. */\n async get(id: string): Promise<Deposit> {\n return this.http.get<Deposit>(`/me/deposits/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's deposits, most recent first. */\n async list(): Promise<Deposit[]> {\n return this.http.get<Deposit[]>(\"/me/deposits\");\n }\n\n /**\n * Refund a previously-confirmed deposit. Synchronous when the\n * connector settles inline; otherwise the row stays `pending` and flips\n * later via the inbound `deposit.refunded` event.\n */\n async refund(\n depositId: string,\n input: CreateDepositRefundInput,\n ): Promise<Refund> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Refund>(\n `/me/deposits/${encodeURIComponent(depositId)}/refunds`,\n { body, idempotencyKey },\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/deposits.ts"],"names":[],"mappings":";AAiKO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYhD,MAAM,MAAM,KAAA,EAAgD;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,uBAAuB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC5E;AAAA,EAEA,MAAM,SAAS,KAAA,EAA+C;AAC5D,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAc,cAAA,EAAgB;AAAA,MAC7C,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,EAAA,EAA8B;AACtC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAa,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,IAAA,GAA2B;AAC/B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAe,cAAc,CAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,CACJ,SAAA,EACA,KAAA,EACiB;AACjB,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,aAAA,EAAgB,kBAAA,CAAmB,SAAS,CAAC,CAAA,QAAA,CAAA;AAAA,MAC7C,EAAE,MAAM,cAAA;AAAe,KACzB;AAAA,EACF;AACF","file":"deposits.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\n\n/**\n * Deposits resource — `client.deposits.*`.\n *\n * The \"money IN\" surface: an end user tops up their wallet balance via a\n * funder connector. Mirrors the Takeal API's `/me/deposits` routes:\n *\n * POST /me/deposits → initiate\n * GET /me/deposits → list (most recent first)\n * GET /me/deposits/{id} → get\n * POST /me/deposits/{id}/refunds → refund\n *\n * A deposit is rarely terminal on the initiate call: real PSPs return\n * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via\n * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's\n * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.\n */\n\n/** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */\nexport type DepositStatus =\n | \"pending\"\n | \"redirect_required\"\n | \"confirmed\"\n | \"failed\";\n\n/** Top-up rail. The chosen funder decides which it supports. */\nexport type DepositMethod = \"card\" | \"crypto\" | \"bank_transfer\";\n\n/**\n * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the\n * server-side `id` is the stable handle the SDK polls against. `idempotency_key`\n * and `request_fingerprint` are server-internal and never serialised.\n */\n/** Input for `quote()` — price a cross-currency deposit before paying. */\nexport interface CreateQuoteInput {\n /** Decimal string, e.g. `\"5000.00\"`. */\n amount: string;\n /** ISO 4217 source currency — must differ from the wallet's local currency. */\n currency: string;\n}\n\n/**\n * A rate-locked funding quote: pay `source_amount source_currency`, the\n * wallet is credited `credited_amount credited_currency` (net of the\n * platform's conversion spread). Execute by passing `id` as `quote_id` to\n * `initiate()` before `expires_at`; after that the API returns 409 and a new\n * quote is needed.\n */\nexport interface FundingQuote {\n id: string;\n source_amount: string;\n source_currency: string;\n credited_amount: string;\n credited_currency: string;\n /** Provider rate before spread (credited units per 1 source unit). */\n rate: string;\n spread_bps: number;\n provider: string;\n expires_at: string;\n}\n\nexport interface Deposit {\n id: string;\n user_id: string;\n /** Slug of the funder that handled this deposit, as configured by the deployment. */\n connector_slug: string;\n /** The connector's own reference, populated once it responds. */\n provider_reference: string | null;\n status: DepositStatus;\n /** Decimal serialised as a string to avoid float drift. */\n amount: string;\n currency: string;\n method: DepositMethod;\n /** Present when `status === \"redirect_required\"` — send the user here. */\n redirect_url: string | null;\n failure_reason: string | null;\n /** Final settled amount once confirmed (may differ from `amount` on FX). */\n confirmed_amount: string | null;\n confirmed_at: string | null;\n /** Set on cross-currency deposits: the quote this deposit executed against. */\n quote_id?: string | null;\n /** Locked provider rate (credited units per 1 source unit). */\n fx_rate?: string | null;\n fx_spread_bps?: number | null;\n /** The wallet's local currency the deposit converted into. */\n credited_currency?: string | null;\n /** What the wallet was actually credited, net of spread. */\n credited_amount?: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface InitiateDepositInput {\n /** Decimal as a string (`\"100.00\"`) — avoids float-precision loss on the wire. */\n amount: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n method: DepositMethod;\n /**\n * Optional. Slug of a specific funder to route through. Omit to\n * let the Takeal API pick the first active funder. Unknown slug → 400; empty\n * funder list → 503.\n */\n funder_slug?: string;\n /**\n * Passed to the funding connector and stored with the deposit. Two keys\n * work across connectors: `return_url`, where the provider sends the user\n * back after a 3-D Secure step (pair it with `redirect_required`), and on\n * test deployments with the mock funder `mock_scenario`, which picks the\n * outcome: `happy` (confirmed at once, the default), `pending` (confirmed\n * about 15 s later), `redirect` (a hosted page where the user approves or\n * declines) or `fail`.\n */\n metadata?: Record<string, string>;\n /** Structured billing details — real PSPs require these for 3DS / compliance. */\n customer?: CustomerInfo;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original deposit; same key + different body returns 409. Supply a stable\n * UUID per logical attempt so a retried network call is safe.\n */\n idempotencyKey: string;\n /**\n * Required when `currency` differs from the wallet's local currency: a\n * fresh quote id from `quote()`. Cross-currency deposits without one are\n * rejected with 400; expired quotes with 409.\n */\n quote_id?: string;\n}\n\nexport interface CreateDepositRefundInput {\n /** Omit for a full refund of the original confirmed amount; same currency. */\n amount?: string;\n /** Human-readable reason, e.g. `\"customer_request\"`. */\n reason?: string;\n metadata?: Record<string, string>;\n /** Required. Replays are keyed on this. */\n idempotencyKey: string;\n}\n\n/** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */\nexport interface Refund {\n id: string;\n target_type: string;\n deposit_id?: string;\n payment_id?: string;\n connector_slug: string;\n amount: string;\n currency: string;\n reason: string;\n status: string;\n provider_refund_reference?: string;\n failure_reason?: string;\n requestor_type: string;\n requestor_id: string;\n created_at: string;\n updated_at: string;\n}\n\nexport class DepositsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose\n * `status` may already be `confirmed` (synchronous rails / mock) or\n * `redirect_required` (3DS / APM — forward the user to `redirect_url`).\n */\n /**\n * Price a cross-currency deposit BEFORE paying. The rate is locked\n * server-side until `expires_at`; deposits in the local currency need no\n * quote (the API answers 400 `no_quote_needed`).\n */\n async quote(input: CreateQuoteInput): Promise<FundingQuote> {\n return this.http.post<FundingQuote>(\"/me/deposits/quotes\", { body: input });\n }\n\n async initiate(input: InitiateDepositInput): Promise<Deposit> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Deposit>(\"/me/deposits\", {\n body,\n idempotencyKey,\n });\n }\n\n /** Fetch one deposit by id — the poll target while a redirect resolves. */\n async get(id: string): Promise<Deposit> {\n return this.http.get<Deposit>(`/me/deposits/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's deposits, most recent first. */\n async list(): Promise<Deposit[]> {\n return this.http.get<Deposit[]>(\"/me/deposits\");\n }\n\n /**\n * Refund a previously-confirmed deposit. Synchronous when the\n * connector settles inline; otherwise the row stays `pending` and flips\n * later via the inbound `deposit.refunded` event.\n */\n async refund(\n depositId: string,\n input: CreateDepositRefundInput,\n ): Promise<Refund> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Refund>(\n `/me/deposits/${encodeURIComponent(depositId)}/refunds`,\n { body, idempotencyKey },\n );\n }\n}\n"]}
package/dist/telegram.cjs CHANGED
@@ -338,6 +338,16 @@ var CardsResource = class {
338
338
  `/me/card-products/${encodeURIComponent(id)}`
339
339
  );
340
340
  }
341
+ /**
342
+ * The public catalog: the same products, order and default as
343
+ * {@link listProducts}, but readable before sign-in, for a landing page or
344
+ * the cabinet's first screen. Prices are list prices (`discount_bps` is
345
+ * always 0); once the user is signed in, {@link listProducts} shows what
346
+ * they pay. The API lets caches keep this response for a minute.
347
+ */
348
+ async catalog() {
349
+ return this.http.get("/card-products");
350
+ }
341
351
  /**
342
352
  * Rename the caller's own card or change its design. Resolves to the
343
353
  * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
@@ -748,7 +758,7 @@ var DevicesResource = class {
748
758
  };
749
759
 
750
760
  // src/version.ts
751
- var SDK_VERSION = "0.3.12";
761
+ var SDK_VERSION = "0.3.18";
752
762
 
753
763
  // src/client-platform.ts
754
764
  var CLIENT_HEADER = "X-Takeal-Client";