@takeal/cusfront-sdk 0.6.14 → 0.8.1
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 +57 -0
- package/README.md +53 -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/{cards-D_krTWzr.d.cts → cards-BPu8Ill7.d.cts} +122 -2
- package/dist/{cards-DPlgx76p.d.ts → cards-DP1fJc_c.d.ts} +122 -2
- package/dist/index.cjs +147 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +147 -15
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/auth.cjs +8 -4
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +17 -6
- package/dist/resources/auth.d.ts +17 -6
- package/dist/resources/auth.js +8 -4
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +60 -1
- 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 +59 -2
- package/dist/resources/cards.js.map +1 -1
- 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 +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +54 -7
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +2 -2
- package/dist/telegram.d.ts +2 -2
- package/dist/telegram.js +54 -7
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Claim } from './resources/claims.js';
|
|
2
|
+
import { CodeRejection, CodeDiscount, CodeEffect } from './resources/codes.js';
|
|
2
3
|
import { ConsentKind, ConsentChannel } from './resources/consents.js';
|
|
3
4
|
import { H as HttpClient } from './http-CL97TjMO.js';
|
|
4
5
|
import { AnalyticsIds } from './resources/attribution.js';
|
|
@@ -847,6 +848,92 @@ interface CardOrderInput {
|
|
|
847
848
|
/** The visitor's analytics ids for the order's server-side conversions.
|
|
848
849
|
* Leave out to send the ones this browser holds (see `analyticsIds`). */
|
|
849
850
|
analyticsIds?: AnalyticsIds;
|
|
851
|
+
/**
|
|
852
|
+
* The amount the user was shown and agreed to pay: `amount` of the
|
|
853
|
+
* quote. If the order comes to anything else, no payment is opened and
|
|
854
|
+
* the API answers 409 `price_changed` with the new quote (see
|
|
855
|
+
* {@link priceChangedQuote}). Leave it out and the payment opens for
|
|
856
|
+
* whatever the order comes to. Sent as `expected_amount`.
|
|
857
|
+
*/
|
|
858
|
+
expectedAmount?: string;
|
|
859
|
+
/** `currency` of the same quote. Sent as `expected_currency`. */
|
|
860
|
+
expectedCurrency?: string;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* A card order to price with {@link CardsResource.quote} or
|
|
864
|
+
* {@link CardsResource.quotePublic}: the same fields as the order.
|
|
865
|
+
*/
|
|
866
|
+
interface CardOrderQuoteInput {
|
|
867
|
+
/** Sent as `product_id`. */
|
|
868
|
+
productId: string;
|
|
869
|
+
/** Sent as `design_id`. */
|
|
870
|
+
designId?: string;
|
|
871
|
+
method: DepositMethod;
|
|
872
|
+
/** Sent as `funder_slug`. */
|
|
873
|
+
funderSlug?: string;
|
|
874
|
+
currency?: string;
|
|
875
|
+
/** Sent as `extra_load`. */
|
|
876
|
+
extraLoad?: string;
|
|
877
|
+
/** The code the user typed. Sent as `promo_code`. */
|
|
878
|
+
promoCode?: string;
|
|
879
|
+
/** Signed in only: pay part of the price with bonuses, on by default. Sent as `use_bonus`. */
|
|
880
|
+
useBonus?: boolean;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Where a promo code stands in a quote. `applied`: its discount is in the
|
|
884
|
+
* amount. `conditional` (before sign-in only): it works for someone who
|
|
885
|
+
* meets `conditions`, which are checked after sign-in, and the amount is
|
|
886
|
+
* provisional. `rejected`: it can't be used, for `reason`; an order that
|
|
887
|
+
* keeps the code is refused, so drop it from the order. `unavailable`: it
|
|
888
|
+
* couldn't be checked right now; the amount is without it.
|
|
889
|
+
*/
|
|
890
|
+
type PromoCodeStatus = "applied" | "conditional" | "rejected" | "unavailable";
|
|
891
|
+
/** What a promo code does to a card order. */
|
|
892
|
+
interface PromoCodeQuote {
|
|
893
|
+
/** The code as stored, or as typed when it wasn't found. */
|
|
894
|
+
code: string;
|
|
895
|
+
status: PromoCodeStatus;
|
|
896
|
+
/** For `rejected`. */
|
|
897
|
+
reason: CodeRejection | null;
|
|
898
|
+
/**
|
|
899
|
+
* For `conditional`: `not_first_operation` (first card only) or
|
|
900
|
+
* `own_code` (not for the person it belongs to).
|
|
901
|
+
*/
|
|
902
|
+
conditions: CodeRejection[];
|
|
903
|
+
/** A sentence to show next to the code, in English. Null when the discount says it all. */
|
|
904
|
+
message: string | null;
|
|
905
|
+
/**
|
|
906
|
+
* The discount and what it comes off: `card_issuance` (the card's price,
|
|
907
|
+
* in `discount` of the quote) or `funding_commission` (the payment's
|
|
908
|
+
* commission: the amount stays the same and more goes onto the card).
|
|
909
|
+
*/
|
|
910
|
+
discount: CodeDiscount | null;
|
|
911
|
+
/** What else the code gives, once the card is issued. */
|
|
912
|
+
effects: CodeEffect[];
|
|
913
|
+
/** The code the user signed up with, applied without being typed. */
|
|
914
|
+
from_sign_up: boolean;
|
|
915
|
+
}
|
|
916
|
+
/** What a card order would cost now, from {@link CardsResource.quote} or {@link CardsResource.quotePublic}. */
|
|
917
|
+
interface CardOrderQuote {
|
|
918
|
+
/** What the user pays, decimal string, in `currency`. Pass it to the order as `expectedAmount`. */
|
|
919
|
+
amount: string;
|
|
920
|
+
/** Pass it to the order as `expectedCurrency`. */
|
|
921
|
+
currency: string;
|
|
922
|
+
/** The same order without the promo code, decimal string, in `currency`. */
|
|
923
|
+
price: string;
|
|
924
|
+
/** `price` less `amount`: what the code takes off. `"0"` without one. */
|
|
925
|
+
discount: string;
|
|
926
|
+
/** What the payment brings, in `card_currency`, as in {@link CardOrder}. */
|
|
927
|
+
card_amount: string;
|
|
928
|
+
card_currency: string;
|
|
929
|
+
/** Card fees owed, in `card_currency`, included in `card_amount`. Always `"0"` before sign-in. */
|
|
930
|
+
debt_withheld: string;
|
|
931
|
+
/** Bonuses that pay part of the price; null before sign-in. */
|
|
932
|
+
bonus_units: string | null;
|
|
933
|
+
/** The amount may still change after sign-in: show it as provisional. */
|
|
934
|
+
preliminary: boolean;
|
|
935
|
+
/** Null when no code was typed and none applies by itself. */
|
|
936
|
+
promo_code: PromoCodeQuote | null;
|
|
850
937
|
}
|
|
851
938
|
/** What {@link CardsResource.order} returns: the top-up to pay and its price. */
|
|
852
939
|
interface CardOrder {
|
|
@@ -869,7 +956,19 @@ interface CardOrder {
|
|
|
869
956
|
interface CardOrderError {
|
|
870
957
|
code: string;
|
|
871
958
|
message: string;
|
|
959
|
+
/** With `code: "price_changed"`: what the card costs now. */
|
|
960
|
+
quote?: CardOrderQuote;
|
|
872
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* The new quote of an order that opened no payment because its price
|
|
964
|
+
* changed (`price_changed`), from either a thrown {@link ApiError} of
|
|
965
|
+
* {@link CardsResource.order} or the `card_order_error` of a sign-in.
|
|
966
|
+
* Show its amount; once the user agrees, send the order again with
|
|
967
|
+
* `expectedAmount` set to it. `undefined` for any other error.
|
|
968
|
+
*/
|
|
969
|
+
declare function priceChangedQuote(error: unknown): CardOrderQuote | undefined;
|
|
970
|
+
/** Build the API body of a card order quote. */
|
|
971
|
+
declare function cardOrderQuoteBody(input: CardOrderQuoteInput): Record<string, unknown>;
|
|
873
972
|
/** Build the API body of a card order. */
|
|
874
973
|
declare function cardOrderBody(input: CardOrderInput): Record<string, unknown>;
|
|
875
974
|
/** Remaining balance of a prepaid card. */
|
|
@@ -1133,11 +1232,32 @@ declare class CardsResource {
|
|
|
1133
1232
|
* `holder_data_required` and the user has not agreed to it), 409
|
|
1134
1233
|
* `payments_on_hold` (a payment on this account was not accepted and new
|
|
1135
1234
|
* ones wait until support sorts it out: show the message and point the
|
|
1136
|
-
* user to support),
|
|
1235
|
+
* user to support), 409 `price_changed` (the order came to another amount
|
|
1236
|
+
* than `expectedAmount`; no payment was opened, and
|
|
1237
|
+
* {@link priceChangedQuote} gives the new quote), 503 no funding connector
|
|
1238
|
+
* or no exchange rate.
|
|
1137
1239
|
*/
|
|
1138
1240
|
order(input: CardOrderInput & {
|
|
1139
1241
|
idempotencyKey: string;
|
|
1140
1242
|
}): Promise<CardOrder>;
|
|
1243
|
+
/**
|
|
1244
|
+
* What an order of this card would cost the signed-in user now, with the
|
|
1245
|
+
* promo code: the same calculation {@link order} makes, with every
|
|
1246
|
+
* condition of the code checked. Nothing is reserved or used up. Pass
|
|
1247
|
+
* `amount` and `currency` to the order as `expectedAmount` and
|
|
1248
|
+
* `expectedCurrency`.
|
|
1249
|
+
*/
|
|
1250
|
+
quote(input: CardOrderQuoteInput): Promise<CardOrderQuote>;
|
|
1251
|
+
/**
|
|
1252
|
+
* The same quote before sign-in, for a landing page or the purchase form
|
|
1253
|
+
* before the e-mail code. Prices are list prices, and a code whose
|
|
1254
|
+
* conditions depend on the person (first card only, say) comes back
|
|
1255
|
+
* `conditional`, with `preliminary` set. Send `expectedAmount` with the
|
|
1256
|
+
* order placed at sign-in: if the price turns out different, no payment
|
|
1257
|
+
* is opened and `card_order_error` carries the new quote. The API limits
|
|
1258
|
+
* how often one address can ask (429 `too_many_requests`).
|
|
1259
|
+
*/
|
|
1260
|
+
quotePublic(input: Omit<CardOrderQuoteInput, "useBonus">): Promise<CardOrderQuote>;
|
|
1141
1261
|
/**
|
|
1142
1262
|
* The cards the caller can order, in the order the storefront shows them
|
|
1143
1263
|
* (`is_default` marks the one issued when none is chosen). Each item
|
|
@@ -1276,4 +1396,4 @@ declare class CardsResource {
|
|
|
1276
1396
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1277
1397
|
}
|
|
1278
1398
|
|
|
1279
|
-
export {
|
|
1399
|
+
export { type TransferInput as $, type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type CustomerInfo as E, FundingOptionsResource as F, type DepositMethod as G, type DepositStatus as H, type DepositTarget as I, type FeeKind as J, type FunderMode as K, type FundingOption as L, type FundingQuote as M, type InitiateDepositInput as N, type IssuanceBonus as O, type IssueCardInput as P, type MethodTerms as Q, type PromoCodeQuote as R, type PromoCodeStatus as S, type Refund as T, type RevealCardInput as U, type RevealState as V, type RevealedCard as W, type SetPinInput as X, type TopUpInput as Y, type TopUpResult as Z, type TopUpTerms as _, type Card as a, type TransferResult as a0, type UpdateCardInput as a1, priceChangedQuote as a2, revealState as a3, cardOrderBody as a4, cardOrderQuoteBody as a5, cardRequestBody as a6, DepositsResource as b, CardsResource as c, type CardBalance as d, type CardDesignRef as e, type CardForm as f, type CardInTransit as g, type CardLoadStatus as h, type CardOrder as i, type CardOrderError as j, type CardOrderInput as k, type CardOrderQuote as l, type CardOrderQuoteInput as m, type CardProductPrice as n, type CardStatus as o, type CardStatusSource as p, type CardTariff as q, type CardTopUp as r, type CardTopUpStatus as s, type CardTransfer as t, type CardType as u, type Cardholder as v, type CloseBlockedReason as w, type CreateCardInput as x, type CreateDepositRefundInput as y, type CreateQuoteInput as z };
|
package/dist/index.cjs
CHANGED
|
@@ -336,6 +336,26 @@ function cardRequestBody(input) {
|
|
|
336
336
|
if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
|
|
337
337
|
return body;
|
|
338
338
|
}
|
|
339
|
+
function priceChangedQuote(error) {
|
|
340
|
+
const body = isApiError(error) ? error.body : error;
|
|
341
|
+
if (typeof body !== "object" || body === null) return void 0;
|
|
342
|
+
const { code, quote } = body;
|
|
343
|
+
if (code !== "price_changed" || typeof quote !== "object" || quote === null) return void 0;
|
|
344
|
+
return quote;
|
|
345
|
+
}
|
|
346
|
+
function cardOrderQuoteBody(input) {
|
|
347
|
+
const body = {
|
|
348
|
+
product_id: input.productId,
|
|
349
|
+
method: input.method
|
|
350
|
+
};
|
|
351
|
+
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
352
|
+
if (input.funderSlug !== void 0) body["funder_slug"] = input.funderSlug;
|
|
353
|
+
if (input.currency !== void 0) body["currency"] = input.currency;
|
|
354
|
+
if (input.extraLoad !== void 0) body["extra_load"] = input.extraLoad;
|
|
355
|
+
if (input.promoCode !== void 0) body["promo_code"] = input.promoCode;
|
|
356
|
+
if (input.useBonus !== void 0) body["use_bonus"] = input.useBonus;
|
|
357
|
+
return body;
|
|
358
|
+
}
|
|
339
359
|
function cardOrderBody(input) {
|
|
340
360
|
const body = {
|
|
341
361
|
product_id: input.productId,
|
|
@@ -353,6 +373,8 @@ function cardOrderBody(input) {
|
|
|
353
373
|
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
354
374
|
const ids = input.analyticsIds ?? analyticsIds();
|
|
355
375
|
if (ids !== void 0) body["analytics_ids"] = ids;
|
|
376
|
+
if (input.expectedAmount !== void 0) body["expected_amount"] = input.expectedAmount;
|
|
377
|
+
if (input.expectedCurrency !== void 0) body["expected_currency"] = input.expectedCurrency;
|
|
356
378
|
return body;
|
|
357
379
|
}
|
|
358
380
|
function revealState(r) {
|
|
@@ -390,7 +412,10 @@ var CardsResource = class {
|
|
|
390
412
|
* `holder_data_required` and the user has not agreed to it), 409
|
|
391
413
|
* `payments_on_hold` (a payment on this account was not accepted and new
|
|
392
414
|
* ones wait until support sorts it out: show the message and point the
|
|
393
|
-
* user to support),
|
|
415
|
+
* user to support), 409 `price_changed` (the order came to another amount
|
|
416
|
+
* than `expectedAmount`; no payment was opened, and
|
|
417
|
+
* {@link priceChangedQuote} gives the new quote), 503 no funding connector
|
|
418
|
+
* or no exchange rate.
|
|
394
419
|
*/
|
|
395
420
|
async order(input) {
|
|
396
421
|
const { idempotencyKey, ...order } = input;
|
|
@@ -399,6 +424,33 @@ var CardsResource = class {
|
|
|
399
424
|
idempotencyKey
|
|
400
425
|
});
|
|
401
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* What an order of this card would cost the signed-in user now, with the
|
|
429
|
+
* promo code: the same calculation {@link order} makes, with every
|
|
430
|
+
* condition of the code checked. Nothing is reserved or used up. Pass
|
|
431
|
+
* `amount` and `currency` to the order as `expectedAmount` and
|
|
432
|
+
* `expectedCurrency`.
|
|
433
|
+
*/
|
|
434
|
+
async quote(input) {
|
|
435
|
+
return this.http.post("/me/card-orders/quote", {
|
|
436
|
+
body: cardOrderQuoteBody(input)
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* The same quote before sign-in, for a landing page or the purchase form
|
|
441
|
+
* before the e-mail code. Prices are list prices, and a code whose
|
|
442
|
+
* conditions depend on the person (first card only, say) comes back
|
|
443
|
+
* `conditional`, with `preliminary` set. Send `expectedAmount` with the
|
|
444
|
+
* order placed at sign-in: if the price turns out different, no payment
|
|
445
|
+
* is opened and `card_order_error` carries the new quote. The API limits
|
|
446
|
+
* how often one address can ask (429 `too_many_requests`).
|
|
447
|
+
*/
|
|
448
|
+
async quotePublic(input) {
|
|
449
|
+
return this.http.post("/card-orders/quote", {
|
|
450
|
+
body: cardOrderQuoteBody(input),
|
|
451
|
+
skipAuth: true
|
|
452
|
+
});
|
|
453
|
+
}
|
|
402
454
|
/**
|
|
403
455
|
* The cards the caller can order, in the order the storefront shows them
|
|
404
456
|
* (`is_default` marks the one issued when none is chosen). Each item
|
|
@@ -815,10 +867,12 @@ var AuthResource = class {
|
|
|
815
867
|
await Promise.resolve(this.tokens.set(resp.access_token));
|
|
816
868
|
return resp;
|
|
817
869
|
}
|
|
818
|
-
/**
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
* {@link requestEmailChange} and {@link confirmEmailChange}
|
|
870
|
+
/** Always answers 409 `email_change_needs_code` on platform 0.8.1 and
|
|
871
|
+
* newer: an address is attached only after a code sent to it comes back.
|
|
872
|
+
* For the first real email of a Telegram-made account use
|
|
873
|
+
* {@link requestEmailChange} and {@link confirmEmailChange}; they clear
|
|
874
|
+
* `email_pending` too.
|
|
875
|
+
* @deprecated Use {@link requestEmailChange} and {@link confirmEmailChange}. */
|
|
822
876
|
async linkEmail(input) {
|
|
823
877
|
return this.http.post("/me/email", { body: { email: input.email } });
|
|
824
878
|
}
|
|
@@ -1699,7 +1753,7 @@ var FundingOptionsResource = class {
|
|
|
1699
1753
|
};
|
|
1700
1754
|
|
|
1701
1755
|
// src/version.ts
|
|
1702
|
-
var SDK_VERSION = "0.
|
|
1756
|
+
var SDK_VERSION = "0.8.1";
|
|
1703
1757
|
|
|
1704
1758
|
// src/client-platform.ts
|
|
1705
1759
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1774,7 +1828,7 @@ function isAbsolute(url) {
|
|
|
1774
1828
|
}
|
|
1775
1829
|
|
|
1776
1830
|
// src/compat.ts
|
|
1777
|
-
var SUPPORTED_MEISTER = ">=0.
|
|
1831
|
+
var SUPPORTED_MEISTER = ">=0.8.0, <1.0.0";
|
|
1778
1832
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1779
1833
|
function parse(v) {
|
|
1780
1834
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1971,6 +2025,67 @@ function digitCount(s) {
|
|
|
1971
2025
|
function redactText(v) {
|
|
1972
2026
|
return v.replace(EMAIL, "[email]").replace(DIGIT_RUN, (m) => digitCount(m) >= 9 && digitCount(m) <= 19 ? "[number]" : m);
|
|
1973
2027
|
}
|
|
2028
|
+
var UTM_PARAMS = [
|
|
2029
|
+
"utm_source",
|
|
2030
|
+
"utm_medium",
|
|
2031
|
+
"utm_campaign",
|
|
2032
|
+
"utm_content",
|
|
2033
|
+
"utm_term"
|
|
2034
|
+
];
|
|
2035
|
+
var CLICK_ID_PARAMS = [
|
|
2036
|
+
"yclid",
|
|
2037
|
+
"ysclid",
|
|
2038
|
+
"gclid",
|
|
2039
|
+
"gbraid",
|
|
2040
|
+
"wbraid",
|
|
2041
|
+
"fbclid",
|
|
2042
|
+
"ttclid",
|
|
2043
|
+
"msclkid",
|
|
2044
|
+
"rb_clickid"
|
|
2045
|
+
];
|
|
2046
|
+
var UTM_SET = new Set(UTM_PARAMS);
|
|
2047
|
+
var CLICK_ID_SET = new Set(CLICK_ID_PARAMS);
|
|
2048
|
+
var CLICK_ID_VALUE = /^[A-Za-z0-9._~-]{1,256}$/;
|
|
2049
|
+
function adField(key) {
|
|
2050
|
+
const k = key.replace(/^\$+/, "").toLowerCase().replace(/^initial_/, "");
|
|
2051
|
+
if (UTM_SET.has(k)) return "utm";
|
|
2052
|
+
if (CLICK_ID_SET.has(k)) return "click";
|
|
2053
|
+
return void 0;
|
|
2054
|
+
}
|
|
2055
|
+
function luhn(digits) {
|
|
2056
|
+
let sum = 0;
|
|
2057
|
+
for (let i = 0; i < digits.length; i++) {
|
|
2058
|
+
let d = digits.charCodeAt(digits.length - 1 - i) - 48;
|
|
2059
|
+
if (i % 2 === 1) {
|
|
2060
|
+
d *= 2;
|
|
2061
|
+
if (d > 9) d -= 9;
|
|
2062
|
+
}
|
|
2063
|
+
sum += d;
|
|
2064
|
+
}
|
|
2065
|
+
return sum % 10 === 0;
|
|
2066
|
+
}
|
|
2067
|
+
var NUMBER_RUN = /(?:\+\s*)?\d(?:[\d\s().-]*\d)?/g;
|
|
2068
|
+
function adValuePersonal(v) {
|
|
2069
|
+
if (v.includes("@")) return true;
|
|
2070
|
+
for (const m of v.match(NUMBER_RUN) ?? []) {
|
|
2071
|
+
const groups = m.split(/\D+/).filter(Boolean);
|
|
2072
|
+
const n = groups.join("").length;
|
|
2073
|
+
if (m.startsWith("+")) {
|
|
2074
|
+
if (n >= 9 && n <= 15) return true;
|
|
2075
|
+
continue;
|
|
2076
|
+
}
|
|
2077
|
+
if (groups.length === 1) {
|
|
2078
|
+
if (n >= 16 && n <= 19 && luhn(groups[0])) return true;
|
|
2079
|
+
continue;
|
|
2080
|
+
}
|
|
2081
|
+
if (n >= 9 && n <= 19 && (/[()]/.test(m) || groups.every((g) => g.length <= 4))) return true;
|
|
2082
|
+
}
|
|
2083
|
+
return v.split(/[\s_.~+-]+/).some((seg) => seg.length >= 20 && /\d.*\d/.test(seg) && /[A-Za-z].*[A-Za-z]/.test(seg));
|
|
2084
|
+
}
|
|
2085
|
+
function adValue(kind, v) {
|
|
2086
|
+
if (kind === "click") return CLICK_ID_VALUE.test(v) ? v : void 0;
|
|
2087
|
+
return adValuePersonal(v) ? void 0 : v;
|
|
2088
|
+
}
|
|
1974
2089
|
function idSegment(seg) {
|
|
1975
2090
|
let s = seg;
|
|
1976
2091
|
try {
|
|
@@ -1982,6 +2097,13 @@ function idSegment(seg) {
|
|
|
1982
2097
|
if (replaced !== s) return replaced;
|
|
1983
2098
|
return redactText(s) === s ? seg : PLACEHOLDER;
|
|
1984
2099
|
}
|
|
2100
|
+
function decodeQueryPart(s) {
|
|
2101
|
+
try {
|
|
2102
|
+
return decodeURIComponent(s.replace(/\+/g, " "));
|
|
2103
|
+
} catch {
|
|
2104
|
+
return s;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
1985
2107
|
function sanitizeUrl(raw) {
|
|
1986
2108
|
const absolute = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw);
|
|
1987
2109
|
let u;
|
|
@@ -1992,14 +2114,22 @@ function sanitizeUrl(raw) {
|
|
|
1992
2114
|
}
|
|
1993
2115
|
const path = u.pathname.split("/").map((seg) => seg ? idSegment(seg) : seg).join("/");
|
|
1994
2116
|
const query = [];
|
|
1995
|
-
u.
|
|
2117
|
+
for (const pair of u.search.replace(/^\?/, "").split("&")) {
|
|
2118
|
+
if (!pair) continue;
|
|
2119
|
+
const eq = pair.indexOf("=");
|
|
2120
|
+
const rawKey = eq < 0 ? pair : pair.slice(0, eq);
|
|
2121
|
+
const key = decodeQueryPart(rawKey);
|
|
2122
|
+
const value = eq < 0 ? "" : decodeQueryPart(pair.slice(eq + 1));
|
|
2123
|
+
const ad = adField(key);
|
|
2124
|
+
if (ad) {
|
|
2125
|
+
if (adValue(ad, value) !== void 0) query.push(pair);
|
|
2126
|
+
continue;
|
|
2127
|
+
}
|
|
1996
2128
|
const k = words(key);
|
|
1997
|
-
if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key))
|
|
1998
|
-
if (redactText(value) !== value)
|
|
1999
|
-
query.push(
|
|
2000
|
-
|
|
2001
|
-
);
|
|
2002
|
-
});
|
|
2129
|
+
if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) continue;
|
|
2130
|
+
if (redactText(value) !== value) continue;
|
|
2131
|
+
query.push(isId(value) ? `${rawKey}=${PLACEHOLDER}` : pair);
|
|
2132
|
+
}
|
|
2003
2133
|
const search = query.length ? `?${query.join("&")}` : "";
|
|
2004
2134
|
return (absolute ? `${u.protocol}//${u.host}` : "") + path + search;
|
|
2005
2135
|
}
|
|
@@ -2007,6 +2137,8 @@ function cleanValue(key, v, depth) {
|
|
|
2007
2137
|
if (v === null || v === void 0 || typeof v === "number" || typeof v === "boolean") return v;
|
|
2008
2138
|
if (typeof v === "string") {
|
|
2009
2139
|
if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;
|
|
2140
|
+
const ad = adField(key);
|
|
2141
|
+
if (ad) return adValue(ad, v);
|
|
2010
2142
|
if (urlKey(key) || /^https?:\/\//i.test(v)) return sanitizeUrl(v);
|
|
2011
2143
|
if (key === "$elements_chain") {
|
|
2012
2144
|
return redactText(v).replace(
|
|
@@ -2353,6 +2485,7 @@ exports.isCardOtp = isCardOtp;
|
|
|
2353
2485
|
exports.isNetworkError = isNetworkError;
|
|
2354
2486
|
exports.page = page;
|
|
2355
2487
|
exports.posthogDistinctId = posthogDistinctId;
|
|
2488
|
+
exports.priceChangedQuote = priceChangedQuote;
|
|
2356
2489
|
exports.rememberAnalyticsIds = rememberAnalyticsIds;
|
|
2357
2490
|
exports.resetAnalytics = resetAnalytics;
|
|
2358
2491
|
exports.resolveAssetUrl = resolveAssetUrl;
|