@takeal/cusfront-sdk 0.8.0 → 0.8.3
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 +70 -0
- package/README.md +27 -1
- package/dist/analytics.cjs +88 -7
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +30 -2
- package/dist/analytics.d.ts +30 -2
- package/dist/analytics.js +86 -8
- package/dist/analytics.js.map +1 -1
- package/dist/index.cjs +122 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +122 -14
- package/dist/index.js.map +1 -1
- package/dist/resources/auth.cjs +36 -6
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +56 -7
- package/dist/resources/auth.d.ts +56 -7
- package/dist/resources/auth.js +36 -6
- package/dist/resources/auth.js.map +1 -1
- package/dist/telegram.cjs +37 -7
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.js +37 -7
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.cjs';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.cjs';
|
|
3
3
|
import { AuthResource } from './resources/auth.cjs';
|
|
4
|
-
export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.cjs';
|
|
4
|
+
export { ChangePasswordInput, ConfirmPasswordSetupInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, PasswordSetupRequested, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.cjs';
|
|
5
5
|
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-BPu8Ill7.cjs';
|
|
6
6
|
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, l as CardOrderQuote, m as CardOrderQuoteInput, C as CardProduct, n as CardProductPrice, o as CardStatus, p as CardStatusSource, q as CardTariff, r as CardTopUp, s as CardTopUpStatus, t as CardTransfer, u as CardType, v as Cardholder, w as CloseBlockedReason, x as CreateCardInput, y as CreateDepositRefundInput, z as CreateQuoteInput, E as CustomerInfo, D as Deposit, G as DepositMethod, H as DepositStatus, I as DepositTarget, J as FeeKind, K as FunderMode, L as FundingOption, M as FundingQuote, N as InitiateDepositInput, O as IssuanceBonus, P as IssueCardInput, Q as MethodTerms, R as PromoCodeQuote, S as PromoCodeStatus, T as Refund, U as RevealCardInput, V as RevealState, W as RevealedCard, X as SetPinInput, Y as TopUpInput, Z as TopUpResult, _ as TopUpTerms, $ as TransferInput, a0 as TransferResult, a1 as UpdateCardInput, a2 as priceChangedQuote, a3 as revealState } from './cards-BPu8Ill7.cjs';
|
|
7
7
|
import { BalanceResource } from './resources/balance.cjs';
|
|
@@ -187,7 +187,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
187
187
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
188
188
|
* release bump that forgets this file fails the test run.
|
|
189
189
|
*/
|
|
190
|
-
declare const SDK_VERSION = "0.8.
|
|
190
|
+
declare const SDK_VERSION = "0.8.3";
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.js';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.js';
|
|
3
3
|
import { AuthResource } from './resources/auth.js';
|
|
4
|
-
export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.js';
|
|
4
|
+
export { ChangePasswordInput, ConfirmPasswordSetupInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, PasswordSetupRequested, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.js';
|
|
5
5
|
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-DP1fJc_c.js';
|
|
6
6
|
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, l as CardOrderQuote, m as CardOrderQuoteInput, C as CardProduct, n as CardProductPrice, o as CardStatus, p as CardStatusSource, q as CardTariff, r as CardTopUp, s as CardTopUpStatus, t as CardTransfer, u as CardType, v as Cardholder, w as CloseBlockedReason, x as CreateCardInput, y as CreateDepositRefundInput, z as CreateQuoteInput, E as CustomerInfo, D as Deposit, G as DepositMethod, H as DepositStatus, I as DepositTarget, J as FeeKind, K as FunderMode, L as FundingOption, M as FundingQuote, N as InitiateDepositInput, O as IssuanceBonus, P as IssueCardInput, Q as MethodTerms, R as PromoCodeQuote, S as PromoCodeStatus, T as Refund, U as RevealCardInput, V as RevealState, W as RevealedCard, X as SetPinInput, Y as TopUpInput, Z as TopUpResult, _ as TopUpTerms, $ as TransferInput, a0 as TransferResult, a1 as UpdateCardInput, a2 as priceChangedQuote, a3 as revealState } from './cards-DP1fJc_c.js';
|
|
7
7
|
import { BalanceResource } from './resources/balance.js';
|
|
@@ -187,7 +187,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
187
187
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
188
188
|
* release bump that forgets this file fails the test run.
|
|
189
189
|
*/
|
|
190
|
-
declare const SDK_VERSION = "0.8.
|
|
190
|
+
declare const SDK_VERSION = "0.8.3";
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.js
CHANGED
|
@@ -806,13 +806,41 @@ var AuthResource = class {
|
|
|
806
806
|
}
|
|
807
807
|
/** Change the signed-in user's password. Every other session of the
|
|
808
808
|
* account is signed out; this one stays valid.
|
|
809
|
-
* Errors: 400 when the new password fails the policy,
|
|
810
|
-
*
|
|
809
|
+
* Errors: 400 `weak_password` when the new password fails the policy,
|
|
810
|
+
* 400 `no_password` when the account has none yet (use
|
|
811
|
+
* {@link requestPasswordSetup}), 401 when the current one is wrong. */
|
|
811
812
|
async changePassword(input) {
|
|
812
813
|
return this.http.post("/auth/password", {
|
|
813
814
|
body: input
|
|
814
815
|
});
|
|
815
816
|
}
|
|
817
|
+
/** Step one of setting the first password of an account that has none
|
|
818
|
+
* (`user.has_password === false`, e.g. made by signing in with an e-mail
|
|
819
|
+
* code): a six-digit code goes to the account's address and works for 5
|
|
820
|
+
* minutes. Nothing changes yet.
|
|
821
|
+
* Errors: 409 `password_exists` (use {@link changePassword}),
|
|
822
|
+
* `email_required` (a Telegram account with no address yet: attach one
|
|
823
|
+
* with {@link requestEmailChange} first), `email_not_proven` (sign in
|
|
824
|
+
* with an e-mail code first); 429 `too_many_requests` (five codes an
|
|
825
|
+
* hour); 503 `delivery_failed`. Platform 0.8.2 and newer. */
|
|
826
|
+
async requestPasswordSetup() {
|
|
827
|
+
return this.http.post("/auth/password/setup", {});
|
|
828
|
+
}
|
|
829
|
+
/** Step two: the code from the e-mail and the new password set the
|
|
830
|
+
* account's first password. Every other session of the account is signed
|
|
831
|
+
* out; this one stays valid, and signing in with a code keeps working.
|
|
832
|
+
* Errors: 400 `weak_password` (the code is not used up, fix the password
|
|
833
|
+
* and send again), 401 `invalid_code` (after five wrong codes ask for a
|
|
834
|
+
* new one), 409 `password_exists`. */
|
|
835
|
+
async confirmPasswordSetup(input) {
|
|
836
|
+
return this.http.post("/auth/password/setup/confirm", {
|
|
837
|
+
body: {
|
|
838
|
+
challenge_id: input.challengeId,
|
|
839
|
+
code: input.code,
|
|
840
|
+
new_password: input.newPassword
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
}
|
|
816
844
|
/** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
|
|
817
845
|
* telegram/email; for TOTP it short-circuits back to the challenge. */
|
|
818
846
|
async switchMethod(input) {
|
|
@@ -865,10 +893,12 @@ var AuthResource = class {
|
|
|
865
893
|
await Promise.resolve(this.tokens.set(resp.access_token));
|
|
866
894
|
return resp;
|
|
867
895
|
}
|
|
868
|
-
/**
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
* {@link requestEmailChange} and {@link confirmEmailChange}
|
|
896
|
+
/** Always answers 409 `email_change_needs_code` on platform 0.8.1 and
|
|
897
|
+
* newer: an address is attached only after a code sent to it comes back.
|
|
898
|
+
* For the first real email of a Telegram-made account use
|
|
899
|
+
* {@link requestEmailChange} and {@link confirmEmailChange}; they clear
|
|
900
|
+
* `email_pending` too.
|
|
901
|
+
* @deprecated Use {@link requestEmailChange} and {@link confirmEmailChange}. */
|
|
872
902
|
async linkEmail(input) {
|
|
873
903
|
return this.http.post("/me/email", { body: { email: input.email } });
|
|
874
904
|
}
|
|
@@ -1749,7 +1779,7 @@ var FundingOptionsResource = class {
|
|
|
1749
1779
|
};
|
|
1750
1780
|
|
|
1751
1781
|
// src/version.ts
|
|
1752
|
-
var SDK_VERSION = "0.8.
|
|
1782
|
+
var SDK_VERSION = "0.8.3";
|
|
1753
1783
|
|
|
1754
1784
|
// src/client-platform.ts
|
|
1755
1785
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -2021,6 +2051,67 @@ function digitCount(s) {
|
|
|
2021
2051
|
function redactText(v) {
|
|
2022
2052
|
return v.replace(EMAIL, "[email]").replace(DIGIT_RUN, (m) => digitCount(m) >= 9 && digitCount(m) <= 19 ? "[number]" : m);
|
|
2023
2053
|
}
|
|
2054
|
+
var UTM_PARAMS = [
|
|
2055
|
+
"utm_source",
|
|
2056
|
+
"utm_medium",
|
|
2057
|
+
"utm_campaign",
|
|
2058
|
+
"utm_content",
|
|
2059
|
+
"utm_term"
|
|
2060
|
+
];
|
|
2061
|
+
var CLICK_ID_PARAMS = [
|
|
2062
|
+
"yclid",
|
|
2063
|
+
"ysclid",
|
|
2064
|
+
"gclid",
|
|
2065
|
+
"gbraid",
|
|
2066
|
+
"wbraid",
|
|
2067
|
+
"fbclid",
|
|
2068
|
+
"ttclid",
|
|
2069
|
+
"msclkid",
|
|
2070
|
+
"rb_clickid"
|
|
2071
|
+
];
|
|
2072
|
+
var UTM_SET = new Set(UTM_PARAMS);
|
|
2073
|
+
var CLICK_ID_SET = new Set(CLICK_ID_PARAMS);
|
|
2074
|
+
var CLICK_ID_VALUE = /^[A-Za-z0-9._~-]{1,256}$/;
|
|
2075
|
+
function adField(key) {
|
|
2076
|
+
const k = key.replace(/^\$+/, "").toLowerCase().replace(/^initial_/, "");
|
|
2077
|
+
if (UTM_SET.has(k)) return "utm";
|
|
2078
|
+
if (CLICK_ID_SET.has(k)) return "click";
|
|
2079
|
+
return void 0;
|
|
2080
|
+
}
|
|
2081
|
+
function luhn(digits) {
|
|
2082
|
+
let sum = 0;
|
|
2083
|
+
for (let i = 0; i < digits.length; i++) {
|
|
2084
|
+
let d = digits.charCodeAt(digits.length - 1 - i) - 48;
|
|
2085
|
+
if (i % 2 === 1) {
|
|
2086
|
+
d *= 2;
|
|
2087
|
+
if (d > 9) d -= 9;
|
|
2088
|
+
}
|
|
2089
|
+
sum += d;
|
|
2090
|
+
}
|
|
2091
|
+
return sum % 10 === 0;
|
|
2092
|
+
}
|
|
2093
|
+
var NUMBER_RUN = /(?:\+\s*)?\d(?:[\d\s().-]*\d)?/g;
|
|
2094
|
+
function adValuePersonal(v) {
|
|
2095
|
+
if (v.includes("@")) return true;
|
|
2096
|
+
for (const m of v.match(NUMBER_RUN) ?? []) {
|
|
2097
|
+
const groups = m.split(/\D+/).filter(Boolean);
|
|
2098
|
+
const n = groups.join("").length;
|
|
2099
|
+
if (m.startsWith("+")) {
|
|
2100
|
+
if (n >= 9 && n <= 15) return true;
|
|
2101
|
+
continue;
|
|
2102
|
+
}
|
|
2103
|
+
if (groups.length === 1) {
|
|
2104
|
+
if (n >= 16 && n <= 19 && luhn(groups[0])) return true;
|
|
2105
|
+
continue;
|
|
2106
|
+
}
|
|
2107
|
+
if (n >= 9 && n <= 19 && (/[()]/.test(m) || groups.every((g) => g.length <= 4))) return true;
|
|
2108
|
+
}
|
|
2109
|
+
return v.split(/[\s_.~+-]+/).some((seg) => seg.length >= 20 && /\d.*\d/.test(seg) && /[A-Za-z].*[A-Za-z]/.test(seg));
|
|
2110
|
+
}
|
|
2111
|
+
function adValue(kind, v) {
|
|
2112
|
+
if (kind === "click") return CLICK_ID_VALUE.test(v) ? v : void 0;
|
|
2113
|
+
return adValuePersonal(v) ? void 0 : v;
|
|
2114
|
+
}
|
|
2024
2115
|
function idSegment(seg) {
|
|
2025
2116
|
let s = seg;
|
|
2026
2117
|
try {
|
|
@@ -2032,6 +2123,13 @@ function idSegment(seg) {
|
|
|
2032
2123
|
if (replaced !== s) return replaced;
|
|
2033
2124
|
return redactText(s) === s ? seg : PLACEHOLDER;
|
|
2034
2125
|
}
|
|
2126
|
+
function decodeQueryPart(s) {
|
|
2127
|
+
try {
|
|
2128
|
+
return decodeURIComponent(s.replace(/\+/g, " "));
|
|
2129
|
+
} catch {
|
|
2130
|
+
return s;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2035
2133
|
function sanitizeUrl(raw) {
|
|
2036
2134
|
const absolute = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw);
|
|
2037
2135
|
let u;
|
|
@@ -2042,14 +2140,22 @@ function sanitizeUrl(raw) {
|
|
|
2042
2140
|
}
|
|
2043
2141
|
const path = u.pathname.split("/").map((seg) => seg ? idSegment(seg) : seg).join("/");
|
|
2044
2142
|
const query = [];
|
|
2045
|
-
u.
|
|
2143
|
+
for (const pair of u.search.replace(/^\?/, "").split("&")) {
|
|
2144
|
+
if (!pair) continue;
|
|
2145
|
+
const eq = pair.indexOf("=");
|
|
2146
|
+
const rawKey = eq < 0 ? pair : pair.slice(0, eq);
|
|
2147
|
+
const key = decodeQueryPart(rawKey);
|
|
2148
|
+
const value = eq < 0 ? "" : decodeQueryPart(pair.slice(eq + 1));
|
|
2149
|
+
const ad = adField(key);
|
|
2150
|
+
if (ad) {
|
|
2151
|
+
if (adValue(ad, value) !== void 0) query.push(pair);
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2046
2154
|
const k = words(key);
|
|
2047
|
-
if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key))
|
|
2048
|
-
if (redactText(value) !== value)
|
|
2049
|
-
query.push(
|
|
2050
|
-
|
|
2051
|
-
);
|
|
2052
|
-
});
|
|
2155
|
+
if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) continue;
|
|
2156
|
+
if (redactText(value) !== value) continue;
|
|
2157
|
+
query.push(isId(value) ? `${rawKey}=${PLACEHOLDER}` : pair);
|
|
2158
|
+
}
|
|
2053
2159
|
const search = query.length ? `?${query.join("&")}` : "";
|
|
2054
2160
|
return (absolute ? `${u.protocol}//${u.host}` : "") + path + search;
|
|
2055
2161
|
}
|
|
@@ -2057,6 +2163,8 @@ function cleanValue(key, v, depth) {
|
|
|
2057
2163
|
if (v === null || v === void 0 || typeof v === "number" || typeof v === "boolean") return v;
|
|
2058
2164
|
if (typeof v === "string") {
|
|
2059
2165
|
if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;
|
|
2166
|
+
const ad = adField(key);
|
|
2167
|
+
if (ad) return adValue(ad, v);
|
|
2060
2168
|
if (urlKey(key) || /^https?:\/\//i.test(v)) return sanitizeUrl(v);
|
|
2061
2169
|
if (key === "$elements_chain") {
|
|
2062
2170
|
return redactText(v).replace(
|