@lydianpay/sdk-web 3.5.0 → 3.6.0

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,4 +1,4 @@
1
- import { type Connection } from '@lydianpay/lydianconnect';
1
+ import { type ConnectInput, type Connection } from '@lydianpay/lydianconnect';
2
2
  export type WalletEventHandlers = {
3
3
  onDisplayUri?: (uri: string, deepLink: boolean) => void;
4
4
  onDisconnect?: (walletId: string) => void;
@@ -15,10 +15,10 @@ export declare class LydianConnectService {
15
15
  private handlers;
16
16
  init(walletConnectProjectId: string, handlers: WalletEventHandlers): Promise<void>;
17
17
  private dispatch;
18
- connect(walletId: string, chainId: string, signal?: AbortSignal): Promise<Connection>;
18
+ connect(input: ConnectInput): Promise<Connection>;
19
19
  openWallet(walletId: string, uri?: string, via?: 'scheme' | 'universal'): boolean;
20
20
  disconnect(walletId?: string): Promise<void>;
21
21
  reset(): Promise<void>;
22
22
  destroy(): void;
23
23
  }
24
- export type { Connection };
24
+ export type { ConnectInput, Connection };
@@ -29,6 +29,22 @@ export declare function filterNetworksByWalletSupport({ networkCodes, walletId,
29
29
  networkCodes: string[];
30
30
  isWalletSupportKnown: boolean;
31
31
  };
32
+ export declare function filterNetworksByApprovedChains({ networkCodes, approvedChains, }: {
33
+ networkCodes: string[];
34
+ approvedChains: readonly string[] | undefined;
35
+ }): string[];
36
+ export declare function intersectWalletNetworks({ networkCodes, walletId, approvedChains, }: {
37
+ networkCodes: string[];
38
+ walletId: string | null;
39
+ approvedChains: readonly string[] | undefined;
40
+ }): {
41
+ networkCodes: string[];
42
+ isWalletSupportKnown: boolean;
43
+ };
44
+ export declare function collectConnectableChainIds({ walletId, allowedAssets, }: {
45
+ walletId: string;
46
+ allowedAssets: SessionAllowedAsset[] | null | undefined;
47
+ }): string[];
32
48
  export declare function matchesExpectedChain(reported: string, expected: readonly string[]): boolean;
33
49
  export declare function shouldWarnWrongChain({ connected, reported, expected, }: {
34
50
  connected: boolean;
@@ -83,9 +83,14 @@ export type CheckoutAction = {
83
83
  } | {
84
84
  type: 'connect/openFailed';
85
85
  installHref: string | null;
86
+ } | {
87
+ type: 'connect/discoveryFailed';
86
88
  } | {
87
89
  type: 'connect/canSign';
88
90
  canSign: boolean;
91
+ } | {
92
+ type: 'connect/approvedChains';
93
+ approvedChains: readonly string[] | undefined;
89
94
  } | {
90
95
  type: 'connect/balances';
91
96
  balances: WalletBalances | null;
@@ -48,6 +48,9 @@ export interface CheckoutState {
48
48
  walletBalances: WalletBalances | null;
49
49
  connectOpenWalletVisible: boolean;
50
50
  connectOpenFailed: boolean;
51
+ didDiscoveryFail: boolean;
52
+ /** CAIP-2 chains granted by the wallet session; undefined means no grant is available. */
53
+ approvedChains: readonly string[] | undefined;
51
54
  connectPairingUri: string | null;
52
55
  connectInstallHref: string | null;
53
56
  termNoticeHtml: string;
@@ -102,7 +105,10 @@ export interface CheckoutCallbacks {
102
105
  onSelectAsset(assetCode: string): void;
103
106
  onSelectWallet(wallet: CheckoutWallet): void;
104
107
  onDoneSuccess(): void;
108
+ /** Cancels the active wallet connection attempt. */
105
109
  onCancelConnect(): void;
110
+ /** Retries discovery for the selected wallet. */
111
+ onRetryDiscovery(): void;
106
112
  onOpenWalletApp(): void;
107
113
  onOpenWalletUniversal(): void;
108
114
  onOpenInWallet(event: IslandClickEvent): void;
@@ -12,6 +12,9 @@ export interface WalletConnection {
12
12
  choose(wallet: CheckoutWallet): void;
13
13
  /** Whether the picked wallet is one checkout can actually connect to. */
14
14
  hasConnectable(): boolean;
15
+ /** Establishes the wallet session used to filter supported networks. */
16
+ discoverSupportedNetworks(): Promise<void>;
17
+ /** Pins the wallet connection to the selected payment network. */
15
18
  connect(networkCode: string): Promise<void>;
16
19
  cancelConnect(): void;
17
20
  /** Null unless a connected wallet can sign for the live transaction. */
@@ -0,0 +1 @@
1
+ export declare function isUserRejection(error: unknown): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lydianpay/sdk-web",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
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": {
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "dependencies": {
85
85
  "@lydianpay/frontend-shared-helpers": "1.1.0",
86
- "@lydianpay/lydianconnect": "^1.4.0",
86
+ "@lydianpay/lydianconnect": "^1.5.0",
87
87
  "@lydianpay/lydianconnect-catalog": "^1.3.1",
88
88
  "@solana/qr-code-styling": "^1.6.0",
89
89
  "dompurify": "^3.4.12",