@lydianpay/sdk-web 2.0.1 → 2.0.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.
@@ -39,7 +39,6 @@ export declare const AllowedAssetUSDP = "USDP";
39
39
  export declare const AllowedAssetUSDS = "USDS";
40
40
  export declare const AllowedAssetUSDT = "USDT";
41
41
  export declare const AllowedAssetZKsync = "ZKSYNC";
42
- export declare const SupportedCheckoutNetworks: string[];
43
42
  export declare const AssetUSDT: DisplayAsset;
44
43
  export declare const AssetUSDC: DisplayAsset;
45
44
  export declare const AssetEthereum: DisplayAsset;
@@ -73,6 +72,8 @@ export type CheckoutNetwork = {
73
72
  };
74
73
  export declare const CheckoutNetworks: Record<string, CheckoutNetwork>;
75
74
  export declare const NetworkAssetContracts: Record<string, Record<string, string>>;
75
+ export declare const SupportedCheckoutNetworks: string[];
76
+ export declare const CheckoutNativeAssets: Record<string, string>;
76
77
  /** The onchain contract for an asset on a network, or undefined for a native coin. */
77
78
  export declare function tokenContract(networkCode: string, assetCode: string): string | undefined;
78
79
  export type CheckoutWallet = {
@@ -109,7 +109,8 @@ export declare class Checkout extends HTMLElement {
109
109
  private city;
110
110
  private region;
111
111
  private postalCode;
112
- private country;
112
+ private countryInput;
113
+ private countryCombobox;
113
114
  private documentType;
114
115
  private documentFileFront;
115
116
  private documentFileBackContainer;
@@ -122,6 +123,7 @@ export declare class Checkout extends HTMLElement {
122
123
  private kycStepBasic;
123
124
  private kycStepAddress;
124
125
  private kycStepDocument;
126
+ private btnKycWalletSummaryRow;
125
127
  private btnKycNetworkSummaryRow;
126
128
  private btnCoinSummaryRow;
127
129
  private kycSteps;
@@ -226,6 +228,7 @@ export declare class Checkout extends HTMLElement {
226
228
  private populateKycSummaryRows;
227
229
  private applyKycFieldVisibility;
228
230
  private renderKycStep;
231
+ private syncKycContinueEnabled;
229
232
  private readKycFieldValues;
230
233
  private showKycFieldError;
231
234
  private clearKycFieldErrors;
@@ -1,5 +1,6 @@
1
1
  import { CheckoutWallet } from '../../constants';
2
- export default function WalletButton({ wallet, badgeLabel, }: {
2
+ export default function WalletButton({ wallet, badgeLabel, iconSvg, }: {
3
3
  wallet: CheckoutWallet;
4
4
  badgeLabel?: string;
5
+ iconSvg?: string;
5
6
  }): string;
@@ -0,0 +1,7 @@
1
+ export declare function fieldShell({ id, label, control, labelFor, }: {
2
+ id: string;
3
+ label: string;
4
+ control: string;
5
+ labelFor: string;
6
+ }): string;
7
+ export declare function fieldCaret(id?: string): string;
@@ -1,9 +1,9 @@
1
1
  export declare const caretDownIconSvg = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2.5 5.5L8 11L13.5 5.5\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
2
2
  export declare const arrowLeftIconSvg = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M19 12H5M5 12L11 6M5 12L11 18\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
3
3
  export declare const caretRightIconSvg = "<svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9 4.5L16.5 12L9 19.5\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
4
- export declare const alertCircleIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 512 512\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M256 32C132.3 32 32 132.3 32 256s100.3 224 224 224 224-100.3 224-224S379.7 32 256 32zm0 338a26 26 0 1 1 0-52 26 26 0 0 1 0 52zm25-122c-.7 15-11.5 25-25 25s-24.3-10-25-25l-6-114c-.6-17.6 12.2-32 31-32s31.6 14.4 31 32z\"/>\n</svg>";
4
+ export declare const alertCircleIconSvg = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 512 512\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M256 32C132.3 32 32 132.3 32 256s100.3 224 224 224 224-100.3 224-224S379.7 32 256 32zm0 338a26 26 0 1 1 0-52 26 26 0 0 1 0 52zm25-122c-.7 15-11.5 25-25 25s-24.3-10-25-25l-6-114c-.6-17.6 12.2-32 31-32s31.6 14.4 31 32z\"/>\n</svg>";
5
5
  export declare const warningTriangleIconSvg = "<svg width=\"20\" height=\"18\" viewBox=\"0 0 21 19\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M10.5 2.23152L18.7952 16.7657H2.20476L10.5 2.23152ZM0.298949 15.6485C-0.549302 17.1344 0.508258 19 2.20476 19H18.7952C20.4917 19 21.5493 17.1344 20.7011 15.6485L12.4058 1.11436C11.5576 -0.371454 9.44244 -0.371454 8.59419 1.11436L0.298949 15.6485ZM9.39837 7.82846V10.0628C9.39837 10.6772 9.89411 11.1799 10.5 11.1799C11.1059 11.1799 11.6016 10.6772 11.6016 10.0628V7.82846C11.6016 7.21402 11.1059 6.7113 10.5 6.7113C9.89411 6.7113 9.39837 7.21402 9.39837 7.82846ZM9.39837 13.4142H11.6016V15.6485H9.39837Z\" fill=\"currentColor\"/>\n</svg>";
6
- export declare const clockIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M8.62788 16.8262C7.9509 16.6726 7.30072 16.4186 6.69896 16.0725M11.739 3.17285C13.2854 3.52603 14.6661 4.39375 15.655 5.63395C16.6438 6.87415 17.1824 8.41335 17.1824 9.99954C17.1824 11.5857 16.6438 13.1249 15.655 14.3651C14.6661 15.6053 13.2854 16.4731 11.739 16.8262M4.41149 13.9611C3.98721 13.3447 3.66497 12.6639 3.45714 11.945M3.27979 8.83275C3.40423 8.09385 3.64379 7.39384 3.9798 6.75216L4.11125 6.51493M6.22233 4.22754C6.95008 3.72656 7.7665 3.36863 8.62805 3.17285M10.1835 6.88863V9.99981L12.5168 12.3332\" stroke=\"currentColor\" stroke-width=\"1.66667\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
6
+ export declare const clockIconSvg = "<svg width=\"28\" height=\"28\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M8.62788 16.8262C7.9509 16.6726 7.30072 16.4186 6.69896 16.0725M11.739 3.17285C13.2854 3.52603 14.6661 4.39375 15.655 5.63395C16.6438 6.87415 17.1824 8.41335 17.1824 9.99954C17.1824 11.5857 16.6438 13.1249 15.655 14.3651C14.6661 15.6053 13.2854 16.4731 11.739 16.8262M4.41149 13.9611C3.98721 13.3447 3.66497 12.6639 3.45714 11.945M3.27979 8.83275C3.40423 8.09385 3.64379 7.39384 3.9798 6.75216L4.11125 6.51493M6.22233 4.22754C6.95008 3.72656 7.7665 3.36863 8.62805 3.17285M10.1835 6.88863V9.99981L12.5168 12.3332\" stroke=\"currentColor\" stroke-width=\"1.66667\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
7
7
  export declare const checkCircleIconSvg = "<svg width=\"72\" height=\"72\" viewBox=\"0 0 64 64\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"32\" cy=\"32\" r=\"32\" fill=\"currentColor\"/>\n <path d=\"M19 33L28 42L45 24\" stroke=\"#ffffff\" stroke-width=\"5.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
8
8
  export declare const copyIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M15 1H4C2.9 1 2 1.9 2 3V16C2 16.55 2.45 17 3 17C3.55 17 4 16.55 4 16V4C4 3.45 4.45 3 5 3H15C15.55 3 16 2.55 16 2C16 1.45 15.55 1 15 1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM18 21H9C8.45 21 8 20.55 8 20V8C8 7.45 8.45 7 9 7H18C18.55 7 19 7.45 19 8V20C19 20.55 18.55 21 18 21Z\"/>\n</svg>";
9
9
  export declare const arrowBendIconSvg = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path fill-rule=\"evenodd\" d=\"M14.854 4.854a.5.5 0 0 0 0-.708l-4-4a.5.5 0 0 0-.708.708L13.293 4H3.5A2.5 2.5 0 0 0 1 6.5v8a.5.5 0 0 0 1 0v-8A1.5 1.5 0 0 1 3.5 5h9.793l-3.147 3.146a.5.5 0 0 0 .708.708l4-4z\"/>\n</svg>";
@@ -16,3 +16,4 @@ export declare const checkMarkIconSvg = "<svg width=\"14\" height=\"14\" viewBox
16
16
  export declare const xCircleIconSvg = "<svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"11\" stroke=\"currentColor\" stroke-width=\"1.6\"/>\n <path d=\"M9 9l6 6M15 9l-6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>\n</svg>";
17
17
  export declare const alertCircleOutlineIconSvg = "<svg width=\"40\" height=\"40\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"1.6\"/>\n <path d=\"M12 7v6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>\n <circle cx=\"12\" cy=\"16.5\" r=\"1.1\" fill=\"currentColor\"/>\n</svg>";
18
18
  export declare const walletIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 7V5.5A1.5 1.5 0 0 0 16.5 4H5a2 2 0 0 0 0 4h13a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <circle cx=\"16.5\" cy=\"13.5\" r=\"1.25\" fill=\"currentColor\"/>\n</svg>";
19
+ export declare const otherWalletsIconSvg = "<svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"8\" cy=\"16\" r=\"2.5\" fill=\"currentColor\"/>\n <circle cx=\"16\" cy=\"16\" r=\"2.5\" fill=\"currentColor\"/>\n <circle cx=\"24\" cy=\"16\" r=\"2.5\" fill=\"currentColor\"/>\n</svg>";
@@ -0,0 +1,18 @@
1
+ import type { SelectOption } from './formSelect';
2
+ export type SearchSelectFieldProps = {
3
+ id: string;
4
+ label: string;
5
+ placeholder?: string;
6
+ ariaLabel?: string;
7
+ };
8
+ export default function SearchSelectField({ id, label, placeholder, ariaLabel, }: SearchSelectFieldProps): string;
9
+ export declare const searchInputId: (id: string) => string;
10
+ export declare const listId: (id: string) => string;
11
+ export declare const caretId: (id: string) => string;
12
+ export declare const optionId: (id: string, index: number) => string;
13
+ export declare function searchSelectOptionList({ id, options, selectedValue, query, }: {
14
+ id: string;
15
+ options: SelectOption[];
16
+ selectedValue: string;
17
+ query: string;
18
+ }): string;
@@ -1,6 +1,10 @@
1
1
  import { AllowedWalletConfig, Asset, GetSessionResponse } from '../types';
2
2
  export declare function resolveAllowedAssets(allowedCrypto: string[] | null | undefined): Asset[];
3
3
  export declare function collectNetworksFromAssets(allowedAssets: Asset[]): string[];
4
+ export declare function hoistRecommendedNetwork({ networks, recommendedNetwork, }: {
5
+ networks: string[];
6
+ recommendedNetwork: string | null | undefined;
7
+ }): string[];
4
8
  export declare function filterAssetsByNetwork(allowedAssets: Asset[], networkCode: string): Asset[];
5
9
  type NetworkFeeSource = Pick<GetSessionResponse, 'customFlatFeePerNetwork' | 'customFeePercentagePerNetwork'>;
6
10
  type CryptoTotalSource = Pick<GetSessionResponse, 'calculatedCryptoTotals' | 'calculatedCryptoTotalsPerNetwork'>;
@@ -0,0 +1,8 @@
1
+ import type { SelectOption } from './components/formSelect';
2
+ export declare function filterOptions(options: SelectOption[], query: string): SelectOption[];
3
+ export declare function resolveOption(options: SelectOption[], query: string): SelectOption | null;
4
+ export declare function initialHighlightIndex(options: SelectOption[], value: string | undefined): number;
5
+ export declare function wrapIndex({ index, count }: {
6
+ index: number;
7
+ count: number;
8
+ }): number;
@@ -10,7 +10,8 @@ export declare class RestoreDetailsController {
10
10
  private readonly dialog;
11
11
  private readonly views;
12
12
  private readonly emailInput;
13
- private readonly countrySelect;
13
+ private readonly countryInput;
14
+ private readonly countryCombobox;
14
15
  private readonly emailError;
15
16
  private readonly otpError;
16
17
  private readonly otpEmailLabel;
@@ -0,0 +1,28 @@
1
+ import type { SelectOption } from './components/formSelect';
2
+ export type SearchSelectOptions = {
3
+ id: string;
4
+ options: SelectOption[];
5
+ onChange?: (value: string) => void;
6
+ };
7
+ export declare class SearchSelectController {
8
+ private readonly elements;
9
+ private readonly caret;
10
+ private readonly options;
11
+ private readonly onChange?;
12
+ private visibleOptions;
13
+ private activeIndex;
14
+ constructor(root: ShadowRoot | HTMLElement, { id, options, onChange }: SearchSelectOptions);
15
+ /** Sets the selection from a code, or clears it when the code is unknown. */
16
+ setValue(code: string): void;
17
+ reset(): void;
18
+ private findOption;
19
+ private wire;
20
+ private onKeyDown;
21
+ private isOpen;
22
+ private open;
23
+ private highlight;
24
+ private close;
25
+ private dismiss;
26
+ private commitTypedText;
27
+ private commitSelection;
28
+ }
@@ -0,0 +1,19 @@
1
+ import { CheckoutWallet } from '../constants';
2
+ import { WalletConnectWallet } from '../types';
3
+ export declare function otherWalletsTile(): CheckoutWallet;
4
+ export declare function getWalletSummaryValue({ walletConnect, selectedWallet, }: {
5
+ walletConnect: boolean;
6
+ selectedWallet: WalletConnectWallet | null;
7
+ }): {
8
+ img: string;
9
+ label: string;
10
+ } | null;
11
+ export declare function getScanPayHeading({ walletConnect, selectedWallet, }: {
12
+ walletConnect: boolean;
13
+ selectedWallet: WalletConnectWallet | null;
14
+ }): {
15
+ key: string;
16
+ params?: {
17
+ wallet: string;
18
+ };
19
+ };
@@ -0,0 +1,14 @@
1
+ /** The items in first-seen order, with later duplicates dropped. */
2
+ export declare function unique<T>(items: T[]): T[];
3
+ /**
4
+ * The items with every match first, leaving both the matches and the rest in their
5
+ * original order — the source order, not the order a caller listed its targets in.
6
+ * Relies on Array.prototype.sort being stable, which it has been required to be
7
+ * since ES2019.
8
+ */
9
+ export declare function matchesFirst<T>(items: T[], isMatch: (item: T) => boolean): T[];
10
+ /**
11
+ * Collects `[key, value]` entries into a Map of key to every value seen for it,
12
+ * both in first-seen order. Keys with one value still get an array.
13
+ */
14
+ export declare function groupValuesByKey<K, V>(entries: [K, V][]): Map<K, V[]>;
@@ -5,12 +5,8 @@ export declare function capitalizeFirstLetter(str: string): string;
5
5
  * @param currency - The currency code (USD or TRY)
6
6
  * @returns Formatted currency string
7
7
  */
8
- export declare function formatCurrency(amount: number, currency?: string | null): string;
8
+ export declare function formatCurrency(amount: number, currency?: string | null, maximumFractionDigits?: number): string;
9
9
  export declare function formatExchangeRate(asset: string, cryptoRatePerUSD: number, fxRateToUSD: number, currency: string): string;
10
10
  export declare function formatDateForTransactionDetails(isoDateString: string): string;
11
11
  export declare function formatDateShort(isoDateString?: string | null): string;
12
- export declare function formatCryptoAmount(num: number): string;
13
- export declare function trimTrailingZeros(decimal: string): string;
14
- export declare function formatToTwoDecimals(num: number): string;
15
- export declare function formatToNDecimals(num: number, precision: number): string;
16
12
  export declare function canvasSafeImageUrl(imageUrl: string): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A USD figure in the customer's local currency.
3
+ *
4
+ * fxRateToUSD is USD-per-local, so this divides. A zero rate returns null rather
5
+ * than Infinity — the caller hides the row instead of printing a nonsense amount.
6
+ */
7
+ export declare function localFromUsd(usdAmount: number, fxRateToUSD: number): number | null;
8
+ /** How much of a partially-paid invoice has landed, in local currency. */
9
+ export declare function paidSoFar(totalLocal: number, remainingLocal: number): number;
10
+ /**
11
+ * The local-currency price of one unit of the asset.
12
+ *
13
+ * cryptoRatePerUSD is USD-per-crypto and fxRateToUSD is USD-per-local, so
14
+ * local-per-crypto is their quotient in this order — inverting it reads correctly
15
+ * only when both are 1. Returns null when either rate is missing or the result is
16
+ * not finite, which is the caller's signal to print nothing.
17
+ */
18
+ export declare function localPerCrypto(cryptoRatePerUSD: number, fxRateToUSD: number): number | null;
19
+ export declare function rateFractionDigits(value: number): number;
20
+ export declare function formatCryptoAmount(num: number): string;
21
+ export declare function trimTrailingZeros(decimal: string): string;
22
+ export declare function formatToTwoDecimals(num: number): string;
23
+ export declare function formatToNDecimals(num: number, precision: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lydianpay/sdk-web",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Drop-in crypto payment checkout for the web — a <lydian-checkout> web component and window.Lydian API across 20+ chains and major stablecoins.",
5
5
  "license": "MIT",
6
6
  "repository": {