@takeal/cusfront-sdk 0.6.6 → 0.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -2
- package/README.md +60 -7
- package/dist/{cards-DwmzjKDC.d.ts → cards-CuUdrQ0H.d.ts} +65 -7
- package/dist/{cards-BiXmrz7h.d.cts → cards-nXmDP0ei.d.cts} +65 -7
- package/dist/index.cjs +80 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +80 -7
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +2 -1
- package/dist/resources/auth.d.ts +2 -1
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +33 -4
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -1
- package/dist/resources/cards.d.ts +2 -1
- package/dist/resources/cards.js +33 -5
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/claims.cjs +40 -0
- package/dist/resources/claims.cjs.map +1 -0
- package/dist/resources/claims.d.cts +114 -0
- package/dist/resources/claims.d.ts +114 -0
- package/dist/resources/claims.js +38 -0
- package/dist/resources/claims.js.map +1 -0
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +2 -1
- package/dist/resources/deposits.d.ts +2 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +2 -1
- package/dist/resources/funding-options.d.ts +2 -1
- package/dist/resources/me.d.cts +2 -1
- package/dist/resources/me.d.ts +2 -1
- package/dist/resources/subscription.cjs +9 -0
- package/dist/resources/subscription.cjs.map +1 -1
- package/dist/resources/subscription.d.cts +19 -2
- package/dist/resources/subscription.d.ts +19 -2
- package/dist/resources/subscription.js +9 -0
- package/dist/resources/subscription.js.map +1 -1
- package/dist/resources/support.cjs.map +1 -1
- package/dist/resources/support.d.cts +8 -3
- package/dist/resources/support.d.ts +8 -3
- package/dist/resources/support.js.map +1 -1
- package/dist/telegram.cjs +79 -6
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +2 -1
- package/dist/telegram.d.ts +2 -1
- package/dist/telegram.js +79 -6
- package/dist/telegram.js.map +1 -1
- package/package.json +9 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/support.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/resources/support.ts"],"names":[],"mappings":";AAwFA,SAAS,cAAc,KAAA,EAA2B;AAChD,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,MAAM,KAAA,GAAQ,KAAA;AACd,EAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,MAAA,EAAQ,KAAK,KAAA,EAAO;AAC5C,IAAA,MAAA,IAAU,MAAA,CAAO,aAAa,GAAG,KAAA,CAAM,SAAS,CAAA,EAAG,CAAA,GAAI,KAAK,CAAC,CAAA;AAAA,EAC/D;AACA,EAAA,OAAO,KAAK,MAAM,CAAA;AACpB;AAEA,eAAe,SAAS,IAAA,EAA4C;AAClE,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,EAAU,OAAO,IAAA;AACrC,EAAA,IAAI,IAAA,YAAgB,UAAA,EAAY,OAAO,aAAA,CAAc,IAAI,CAAA;AACzD,EAAA,IAAI,gBAAgB,WAAA,EAAa,OAAO,cAAc,IAAI,UAAA,CAAW,IAAI,CAAC,CAAA;AAC1E,EAAA,OAAO,cAAc,IAAI,UAAA,CAAW,MAAM,IAAA,CAAK,WAAA,EAAa,CAAC,CAAA;AAC/D;AAEO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA,EA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AO,KAAK,IAAA,CAAK,OAAA,CAAQ,2BAA2B,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAA,EAAI;AAAA,MAC5E,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AAAA;AAAA;AAAA,EAIA,MAAM,IAAA,CACJ,EAAA,EACA,MAAA,EACA,IAAA,GAAiC,EAAC,EACnB;AACf,IAAA,MAAM,KAAK,IAAA,CAAK,IAAA,CAAW,uBAAuB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAA,EAAI;AAAA,MAC1E,IAAA,EAAM,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,GAAI,MAAA,CAAO,OAAA,GAAU,EAAE,OAAA,EAAS,MAAA,CAAO,OAAA,EAAQ,GAAI,EAAC,EAAG;AAAA,MACtF,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,IAAA,GAAiC,EAAC,EAAuC;AACpF,IAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,KAAA,EAAO,GAAG,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA,EAAG,MAAA;AAAA,EAC9D;AACF","file":"support.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Support resource — `client.support.*`: the chat with support.\n *\n * GET /me/support/messages → list\n * POST /me/support/messages → send\n * GET /me/support/attachments/{id} → attachment\n * POST /me/support/ratings/{id} → rate\n *\n * What the person writes shows in the conversation at once, with the status\n * `queued`, and goes to support right after (`delivered`). Support answers\n * come back in the same conversation, with the text ready as cleaned HTML in\n * `html`: show it as it is, it carries only paragraphs, line breaks, bold,\n * italic, strikethrough, code, links, lists and quotes. A new answer also\n * comes as a `support_reply` notification.\n *\n * The person may write from the Telegram bot too; it is one conversation,\n * and `channel` says where each message came from. A message written in\n * Telegram keeps its formatting: `html` has it, `text` the plain words.\n * An answer sent to the person's Telegram is `queued` until all of it got\n * there, and `failed` if it could not get there.\n */\n\n/** Where a message came from, or where an answer was sent. */\nexport type SupportChannel = \"cabinet\" | \"telegram\" | (string & {});\n\n/** How far a message got: `queued` until support has it (for an answer\n * sent to Telegram, until the person has it). */\nexport type SupportMessageStatus = \"queued\" | \"delivered\" | \"failed\" | (string & {});\n\n/** The conversation's state: `none` until the person writes for the first\n * time, `resolved` once support closed it. Writing again reopens it. */\nexport type SupportConversationStatus = \"none\" | \"open\" | \"resolved\" | (string & {});\n\n/** A file in the conversation. Download it with `attachment(id)`. */\nexport interface SupportAttachment {\n id: string;\n file_name: string;\n content_type: string;\n /** Bytes. */\n size: number;\n}\n\n/** One message. */\nexport interface SupportMessage {\n id: string;\n /** `user` for what the person wrote, `support` for an answer. */\n author: \"user\" | \"support\" | (string & {});\n /** The name the support agent goes by; answers only. */\n operator_name: string | null;\n channel: SupportChannel | null;\n /** What the person wrote, plain text. Empty on answers. */\n text: string;\n /** The answer as cleaned HTML. On the person's own messages it is set\n * only for those written in Telegram, which keep their formatting. */\n html: string;\n attachments: SupportAttachment[];\n status: SupportMessageStatus;\n created_at: string;\n}\n\n/** Support closed the conversation and asks how it went. */\nexport interface SupportRatingRequest {\n id: string;\n asked_at: string;\n}\n\n/** A page of the conversation, oldest first. */\nexport interface SupportConversation {\n status: SupportConversationStatus;\n items: SupportMessage[];\n /** Older messages exist: `list({ before: items[0].created_at })`. */\n has_more: boolean;\n /** Show a 1–5 rating when set; answer with `rate()`. `null` otherwise. */\n rating_request: SupportRatingRequest | null;\n}\n\n/** A file to send. `data` may be a `Blob` (a `File` from an input), bytes,\n * or base64 already. */\nexport interface SupportFile {\n fileName: string;\n /** E.g. `image/png`. Pictures and PDF up to 20 MB by default; the platform\n * sets the list and the size. */\n contentType: string;\n data: Blob | ArrayBuffer | Uint8Array | string;\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n let binary = \"\";\n const chunk = 0x8000;\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n return btoa(binary);\n}\n\nasync function toBase64(data: SupportFile[\"data\"]): Promise<string> {\n if (typeof data === \"string\") return data;\n if (data instanceof Uint8Array) return bytesToBase64(data);\n if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));\n return bytesToBase64(new Uint8Array(await data.arrayBuffer()));\n}\n\nexport class SupportResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The latest messages, oldest first, and the conversation's status.\n * `before` reads further back; `limit` is 1 to 100 (50). */\n async list(\n opts: { before?: string; limit?: number; signal?: AbortSignal } = {},\n ): Promise<SupportConversation> {\n const q = new URLSearchParams();\n if (opts.before) q.set(\"before\", opts.before);\n if (opts.limit !== undefined) q.set(\"limit\", String(opts.limit));\n const qs = q.toString();\n return this.http.get<SupportConversation>(`/me/support/messages${qs ? `?${qs}` : \"\"}`, {\n signal: opts.signal,\n });\n }\n\n /** Write to support. Text, files or both; up to 10 files. */\n async send(\n message: { text?: string; files?: SupportFile[] },\n opts: { signal?: AbortSignal } = {},\n ): Promise<SupportMessage> {\n const attachments = await Promise.all(\n (message.files ?? []).map(async (f) => ({\n file_name: f.fileName,\n content_type: f.contentType,\n data_base64: await toBase64(f.data),\n })),\n );\n return this.http.post<SupportMessage>(\"/me/support/messages\", {\n body: { text: message.text ?? \"\", attachments },\n signal: opts.signal,\n });\n }\n\n /** A file from the conversation: the person's own or one support sent. */\n async attachment(id: string, opts: { signal?: AbortSignal } = {}): Promise<Blob> {\n return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {\n signal: opts.signal,\n });\n }\n\n /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person\n * wrote one. Each question takes one answer; a second one is a 404. */\n async rate(\n id: string,\n answer: { rating: 1 | 2 | 3 | 4 | 5; comment?: string },\n opts: { signal?: AbortSignal } = {},\n ): Promise<void> {\n await this.http.post<void>(`/me/support/ratings/${encodeURIComponent(id)}`, {\n body: { rating: answer.rating, ...(answer.comment ? { comment: answer.comment } : {}) },\n signal: opts.signal,\n });\n }\n\n /** Just the conversation's status. */\n async status(opts: { signal?: AbortSignal } = {}): Promise<SupportConversationStatus> {\n return (await this.list({ limit: 1, signal: opts.signal })).status;\n }\n}\n"]}
|
package/dist/telegram.cjs
CHANGED
|
@@ -184,6 +184,11 @@ function cardOrderBody(input) {
|
|
|
184
184
|
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
185
185
|
return body;
|
|
186
186
|
}
|
|
187
|
+
function revealState(r) {
|
|
188
|
+
if (r.details_pending) return "pending";
|
|
189
|
+
if (r.reveal_url) return "page";
|
|
190
|
+
return "numbers";
|
|
191
|
+
}
|
|
187
192
|
var CardsResource = class {
|
|
188
193
|
constructor(http) {
|
|
189
194
|
this.http = http;
|
|
@@ -339,15 +344,22 @@ var CardsResource = class {
|
|
|
339
344
|
* keep the result in volatile memory only, never write it to
|
|
340
345
|
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
341
346
|
*
|
|
342
|
-
*
|
|
343
|
-
* when the issuer shows them on a
|
|
344
|
-
* frame right away, it is
|
|
347
|
+
* `state` tells the three answers apart: `numbers`; `page`, with
|
|
348
|
+
* `reveal_url` and empty `pan` and `cvv` when the issuer shows them on a
|
|
349
|
+
* page of its own (open that page in a frame right away, it is
|
|
350
|
+
* short-lived); or `pending` while the card's details are still being
|
|
351
|
+
* prepared, which doesn't count against the limit. A card says the same
|
|
352
|
+
* in {@link Card.details_pending}, so there is no need to call this just
|
|
353
|
+
* to find out.
|
|
345
354
|
*
|
|
346
355
|
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
347
356
|
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
348
357
|
*/
|
|
349
358
|
async reveal(id, _input) {
|
|
350
|
-
|
|
359
|
+
const r = await this.http.post(
|
|
360
|
+
`/me/cards/${encodeURIComponent(id)}/reveal`
|
|
361
|
+
);
|
|
362
|
+
return { ...r, state: revealState(r) };
|
|
351
363
|
}
|
|
352
364
|
/**
|
|
353
365
|
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
@@ -358,6 +370,22 @@ var CardsResource = class {
|
|
|
358
370
|
async unfreeze(id) {
|
|
359
371
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
360
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Report the card lost or stolen. Works at any time, on an active or a
|
|
375
|
+
* frozen card. The report is recorded first with the server's time, which
|
|
376
|
+
* decides who pays for operations someone else made; then the card is
|
|
377
|
+
* frozen at its issuer and only support can unfreeze it. Resolves to the
|
|
378
|
+
* claim (`client.claims`): show its `number` and `reported_at`. When the
|
|
379
|
+
* issuer can't be reached, `card_freeze` is `"pending"`: the report still
|
|
380
|
+
* counts and support freezes the card by hand. Reporting again while the
|
|
381
|
+
* report is open returns the same claim. 404 / 403 not the user's card ·
|
|
382
|
+
* 409 `card_not_open`: the card is closed or was never issued.
|
|
383
|
+
*/
|
|
384
|
+
async reportLost(id, input) {
|
|
385
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/report-lost`, {
|
|
386
|
+
body: { kind: input.kind, details: input.details }
|
|
387
|
+
});
|
|
388
|
+
}
|
|
361
389
|
/**
|
|
362
390
|
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
363
391
|
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
@@ -810,6 +838,41 @@ var CloseRequestsResource = class {
|
|
|
810
838
|
}
|
|
811
839
|
};
|
|
812
840
|
|
|
841
|
+
// src/resources/claims.ts
|
|
842
|
+
var ClaimsResource = class {
|
|
843
|
+
constructor(http) {
|
|
844
|
+
this.http = http;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Dispute a card operation, or complain. 400 `validation`: a description
|
|
848
|
+
* that is too short or too long, an operation that isn't on the user's
|
|
849
|
+
* cards, or a lost or stolen card (use `cards.reportLost()`) · 404 no
|
|
850
|
+
* such card · 409 `too_many_claims`: 20 claims are waiting for an answer.
|
|
851
|
+
*/
|
|
852
|
+
async create(input) {
|
|
853
|
+
return this.http.post("/me/claims", {
|
|
854
|
+
body: {
|
|
855
|
+
kind: input.kind,
|
|
856
|
+
description: input.description,
|
|
857
|
+
card_id: input.cardId,
|
|
858
|
+
transaction_id: input.transactionId
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
/** The user's claims, lost and stolen cards included, newest first. */
|
|
863
|
+
async list(opts = {}) {
|
|
864
|
+
const qs = new URLSearchParams();
|
|
865
|
+
if (opts.limit != null) qs.set("limit", String(opts.limit));
|
|
866
|
+
if (opts.offset != null) qs.set("offset", String(opts.offset));
|
|
867
|
+
const q = qs.toString();
|
|
868
|
+
return this.http.get(`/me/claims${q ? `?${q}` : ""}`, { signal: opts.signal });
|
|
869
|
+
}
|
|
870
|
+
/** One claim. 404 when it isn't the user's. */
|
|
871
|
+
async get(id, opts = {}) {
|
|
872
|
+
return this.http.get(`/me/claims/${encodeURIComponent(id)}`, { signal: opts.signal });
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
|
|
813
876
|
// src/resources/codes.ts
|
|
814
877
|
var CodesResource = class {
|
|
815
878
|
constructor(http) {
|
|
@@ -853,6 +916,15 @@ var SubscriptionResource = class {
|
|
|
853
916
|
async setPromoCode(code) {
|
|
854
917
|
return this.http.put("/me/subscription/promo-code", { body: { code } });
|
|
855
918
|
}
|
|
919
|
+
/**
|
|
920
|
+
* Cancel the subscription now, in one step. What was paid for the current
|
|
921
|
+
* period comes back to the balance for the days not used. No subscription
|
|
922
|
+
* running → 404; 503 `refund_unavailable` when the refund can't be made
|
|
923
|
+
* right now (the subscription keeps running; try again).
|
|
924
|
+
*/
|
|
925
|
+
async cancel() {
|
|
926
|
+
return this.http.post("/me/subscription/cancel", {});
|
|
927
|
+
}
|
|
856
928
|
};
|
|
857
929
|
|
|
858
930
|
// src/resources/branding.ts
|
|
@@ -1495,7 +1567,7 @@ var FundingOptionsResource = class {
|
|
|
1495
1567
|
};
|
|
1496
1568
|
|
|
1497
1569
|
// src/version.ts
|
|
1498
|
-
var SDK_VERSION = "0.6.
|
|
1570
|
+
var SDK_VERSION = "0.6.11";
|
|
1499
1571
|
|
|
1500
1572
|
// src/client-platform.ts
|
|
1501
1573
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1570,7 +1642,7 @@ function isAbsolute(url) {
|
|
|
1570
1642
|
}
|
|
1571
1643
|
|
|
1572
1644
|
// src/compat.ts
|
|
1573
|
-
var SUPPORTED_MEISTER = ">=0.6
|
|
1645
|
+
var SUPPORTED_MEISTER = ">=0.7.6, <1.0.0";
|
|
1574
1646
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1575
1647
|
function parse(v) {
|
|
1576
1648
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1667,6 +1739,7 @@ function createClient(opts) {
|
|
|
1667
1739
|
bonus: new BonusResource(http),
|
|
1668
1740
|
debt: new DebtResource(http),
|
|
1669
1741
|
closeRequests: new CloseRequestsResource(http),
|
|
1742
|
+
claims: new ClaimsResource(http),
|
|
1670
1743
|
codes: new CodesResource(http),
|
|
1671
1744
|
referral: new ReferralResource(http),
|
|
1672
1745
|
subscription: new SubscriptionResource(http),
|