@lydianpay/sdk-web 3.12.0 → 3.13.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.
@@ -10,6 +10,8 @@ export type Transaction = {
10
10
  export type InitFlowOptions = {
11
11
  walletConnect?: boolean;
12
12
  assetFirst?: boolean;
13
+ /** Lets Lydian Wallet run the checkout after connecting over WalletConnect. */
14
+ isLDKEnabled?: boolean;
13
15
  };
14
16
  /**
15
17
  * Every `redirectURL` below is the merchant's own URL from the session, and is only
@@ -0,0 +1,18 @@
1
+ type SessionId = string | null | undefined;
2
+ export declare function createCheckoutSessionRecord<T>({ name, isRecord, }: {
3
+ name: string;
4
+ isRecord: (value: unknown) => value is T;
5
+ }): {
6
+ parse: (raw: string | null) => T | null;
7
+ read({ sessionId }: {
8
+ sessionId: SessionId;
9
+ }): T | null;
10
+ write({ sessionId, record }: {
11
+ sessionId: SessionId;
12
+ record: T;
13
+ }): void;
14
+ clear({ sessionId }: {
15
+ sessionId: SessionId;
16
+ }): void;
17
+ };
18
+ export {};
@@ -2,6 +2,7 @@ import { CheckoutFlow, InitFlowOptions } from '../types';
2
2
  export type CheckoutFlowSettings = {
3
3
  walletConnect: boolean;
4
4
  assetFirst: boolean;
5
+ isLDKEnabled: boolean;
5
6
  showApprovalPage: boolean;
6
7
  hideOtherWallets: boolean;
7
8
  hideChangePaymentMethod: boolean;
@@ -0,0 +1,14 @@
1
+ export declare const LYDIAN_WALLET_ID = "lydian";
2
+ export declare const LDK_CHECKOUT_VERSION_PROPERTY = "com.lydianpay.checkout.version";
3
+ export declare const LDK_CHECKOUT_SESSION_ID_PROPERTY = "com.lydianpay.checkout.sessionId";
4
+ export declare function isLdkCheckout({ isLDKEnabled, walletId, }: {
5
+ isLDKEnabled: boolean;
6
+ walletId: string | undefined;
7
+ }): boolean;
8
+ export declare function getLdkCheckoutSessionProperties({ isLDKEnabled, walletId, sessionId, hasTransaction, }: {
9
+ isLDKEnabled: boolean;
10
+ walletId: string | undefined;
11
+ sessionId: string | undefined;
12
+ hasTransaction: boolean;
13
+ }): Record<string, string> | undefined;
14
+ export declare function isLdkHandoff(checkout: Parameters<typeof getLdkCheckoutSessionProperties>[0]): boolean;
@@ -0,0 +1,29 @@
1
+ import { type CheckoutStore } from './react/checkoutStore';
2
+ import { type SessionPromotionApi } from './sessionPromotion';
3
+ import type { CheckoutPresentation } from './checkoutPresentation';
4
+ import type { PaymentFlow } from './paymentFlow';
5
+ import type { ScreenNavigator } from './screenNavigator';
6
+ import type { SessionLifecycle } from './sessionLifecycle';
7
+ import type { GetTransactionResponse } from '../types';
8
+ /** Resolves once the wallet's payment is found, the session expires, or `signal` aborts. */
9
+ export declare function watchForWalletPayment({ api, sessionId, signal, onWalletPaid, onSessionExpired, onSustainedFailure, onRecovered, }: {
10
+ api: SessionPromotionApi;
11
+ /** The session the wallet was handed. */
12
+ sessionId: string;
13
+ signal: AbortSignal;
14
+ onWalletPaid: (transaction: GetTransactionResponse) => void;
15
+ onSessionExpired: () => void;
16
+ onSustainedFailure: () => void;
17
+ onRecovered: () => void;
18
+ }): Promise<void>;
19
+ export declare function showWalletCheckout({ screenNavigator, }: {
20
+ screenNavigator: Pick<ScreenNavigator, 'show' | 'setBack'>;
21
+ }): void;
22
+ export declare function adoptWalletPayment({ transaction, store, paymentFlow, sessionLifecycle, presentation, screenNavigator, }: {
23
+ transaction: GetTransactionResponse;
24
+ store: CheckoutStore;
25
+ paymentFlow: Pick<PaymentFlow, 'endCheckoutIfSettled' | 'startPolling'>;
26
+ sessionLifecycle: Pick<SessionLifecycle, 'markPromotedFrom'>;
27
+ presentation: Pick<CheckoutPresentation, 'clearErrorBanner'>;
28
+ screenNavigator: Pick<ScreenNavigator, 'show' | 'setBack'>;
29
+ }): void;
@@ -0,0 +1,14 @@
1
+ export type PollDecision = 'continue' | 'stop';
2
+ export type PollSequentiallyOptions<Result> = {
3
+ /** One attempt, or null when there is nothing to check yet: neither a success nor a failure. */
4
+ check: () => Promise<Result> | null;
5
+ onResult: (result: Result) => PollDecision;
6
+ /** Aborting cancels the poll; a 'stop' decision completes it. */
7
+ signal: AbortSignal;
8
+ failureMessage: string;
9
+ onSustainedFailure: () => void;
10
+ onRecovered: () => void;
11
+ intervalMs?: number;
12
+ };
13
+ /** Never rejects; resolves once the poll is cancelled, stopped by onResult, or ended by a failing callback. */
14
+ export declare function pollSequentially<Result>(options: PollSequentiallyOptions<Result>): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export default function WalletCheckoutScreen(): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import type { WalletConnectWallet } from '../../types';
3
+ export default function WalletLogo({ id, wallet, }: {
4
+ id: string;
5
+ wallet: Pick<WalletConnectWallet, 'name' | 'img'> | null;
6
+ }): React.JSX.Element;
@@ -115,4 +115,4 @@ export type CheckoutAction = {
115
115
  type: 'mode/applied';
116
116
  isEmbedded: boolean;
117
117
  };
118
- export declare const PRESERVED_ON_RESET: readonly ["brandLogoUrl", "brandLogoAlt", "termNoticeHtml", "session", "flowOverride", "isEmbedded", "walletConnectFlow", "assetFirstFlow", "hideOtherWallets", "showApprovalPage", "restoreDialogSession", "kycStepSession", "kycFormSession"];
118
+ export declare const PRESERVED_ON_RESET: readonly ["brandLogoUrl", "brandLogoAlt", "termNoticeHtml", "session", "flowOverride", "isEmbedded", "walletConnectFlow", "assetFirstFlow", "isLDKEnabled", "hideOtherWallets", "showApprovalPage", "restoreDialogSession", "kycStepSession", "kycFormSession"];
@@ -14,6 +14,7 @@ export declare const SCREEN_NAMES: {
14
14
  readonly SUCCESS: "success";
15
15
  readonly FAILURE: "failure";
16
16
  readonly CANCELED: "canceled";
17
+ readonly WALLET_CHECKOUT: "walletCheckout";
17
18
  };
18
19
  export type ActiveScreen = (typeof SCREEN_NAMES)[keyof typeof SCREEN_NAMES];
19
20
  export interface CheckoutState {
@@ -26,6 +27,7 @@ export interface CheckoutState {
26
27
  selectedWallet: WalletConnectWallet | null;
27
28
  walletConnectFlow: boolean;
28
29
  assetFirstFlow: boolean;
30
+ isLDKEnabled: boolean;
29
31
  hideOtherWallets: boolean;
30
32
  showApprovalPage: boolean;
31
33
  isCheckoutSettled: boolean;
@@ -1,3 +1,4 @@
1
+ import type { CreateTransactionResponse, GetTransactionResponse } from '../types';
1
2
  export declare function parseInstant(iso: string | undefined): number | null;
2
3
  export declare function isFutureInstant(iso: string | undefined, now?: number): boolean;
3
4
  export declare function isSessionPromotable(session: {
@@ -28,6 +29,7 @@ export declare function hasOutstandingPaymentRequest(payments: {
28
29
  status: number;
29
30
  expiration?: string;
30
31
  }[], now?: number): boolean;
32
+ export declare function cryptoTransactionFromLinked(linked: GetTransactionResponse): CreateTransactionResponse;
31
33
  export type RestoreContext = {
32
34
  customerUUID: string;
33
35
  country: string;
@@ -0,0 +1,25 @@
1
+ import type { API } from '../network';
2
+ import type { GetSessionResponse, GetTransactionResponse } from '../types';
3
+ export type SessionPromotionState = {
4
+ kind: 'awaitingPromotion';
5
+ } | {
6
+ kind: 'expired';
7
+ } | {
8
+ kind: 'promoted';
9
+ transactionID: string;
10
+ };
11
+ export type SessionPromotionApi = Pick<API, 'getSession' | 'getCryptoTransaction'>;
12
+ export type SessionPromotionCheck = {
13
+ kind: 'awaitingPromotion';
14
+ } | {
15
+ kind: 'expired';
16
+ } | {
17
+ kind: 'transactionDiscovered';
18
+ transaction: GetTransactionResponse;
19
+ };
20
+ export declare function getSessionPromotionState(session: GetSessionResponse): SessionPromotionState;
21
+ /** One read of the session and, once it is promoted, of its linked transaction. */
22
+ export declare function checkSessionPromotion({ api, sessionId, }: {
23
+ api: SessionPromotionApi;
24
+ sessionId: string;
25
+ }): Promise<SessionPromotionCheck>;
@@ -29,6 +29,8 @@ export interface WalletConnection {
29
29
  /** Pins the wallet connection to the selected payment network. */
30
30
  connect(networkCode: string): Promise<void>;
31
31
  cancelConnect(): void;
32
+ /** No navigation or failure report; a late result is ignored. */
33
+ abortPendingConnection(): void;
32
34
  /** Null unless a connected wallet can sign for the live transaction. */
33
35
  buildSend(): WalletRequest | null;
34
36
  /** The send to sign — the one held for the confirmation screen, or a fresh build. */
@@ -50,6 +52,10 @@ export interface WalletConnectionSeams {
50
52
  subMessage?: string | null;
51
53
  cancellable?: boolean;
52
54
  }): void;
55
+ handOffCheckout(): void;
56
+ /** Outlives a failed connect: the wallet may still pay. */
57
+ watchForHandoff(): void;
58
+ abandonHandoff(): void;
53
59
  }
54
60
  export declare function createWalletConnection({ store, presentation, screenNavigator, paymentFlow, getDialogs, getOptions, emit, seams, }: {
55
61
  store: CheckoutStore;
@@ -3,16 +3,15 @@ export type WalletHandoff = {
3
3
  v: typeof HANDOFF_VERSION;
4
4
  walletId: string;
5
5
  };
6
- type SessionId = string | null | undefined;
7
- export declare function readWalletHandoff({ sessionId }: {
8
- sessionId: SessionId;
9
- }): WalletHandoff | null;
6
+ export declare const readWalletHandoff: ({ sessionId }: {
7
+ sessionId: string | null | undefined;
8
+ }) => WalletHandoff | null;
9
+ export declare const clearWalletHandoff: ({ sessionId }: {
10
+ sessionId: string | null | undefined;
11
+ }) => void;
12
+ export declare const parseWalletHandoff: (raw: string | null) => WalletHandoff | null;
10
13
  export declare function writeWalletHandoff({ sessionId, walletId, }: {
11
- sessionId: SessionId;
14
+ sessionId: string | null | undefined;
12
15
  walletId: string;
13
16
  }): void;
14
- export declare function clearWalletHandoff({ sessionId }: {
15
- sessionId: SessionId;
16
- }): void;
17
- export declare function parseWalletHandoff(raw: string | null): WalletHandoff | null;
18
17
  export {};
@@ -0,0 +1,22 @@
1
+ declare const RECORD_VERSION = 1;
2
+ export type WalletPaymentInFlight = {
3
+ v: typeof RECORD_VERSION;
4
+ transactionId: string;
5
+ };
6
+ type SessionId = string | null | undefined;
7
+ export declare const readWalletPaymentInFlight: ({ sessionId }: {
8
+ sessionId: string | null | undefined;
9
+ }) => WalletPaymentInFlight | null;
10
+ export declare const clearWalletPaymentInFlight: ({ sessionId }: {
11
+ sessionId: string | null | undefined;
12
+ }) => void;
13
+ export declare const parseWalletPaymentInFlight: (raw: string | null) => WalletPaymentInFlight | null;
14
+ export declare function writeWalletPaymentInFlight({ sessionId, transactionId, }: {
15
+ sessionId: SessionId;
16
+ transactionId: string;
17
+ }): void;
18
+ export declare function hasWalletPaymentInFlight({ sessionId, transactionId, }: {
19
+ sessionId: SessionId;
20
+ transactionId: string;
21
+ }): boolean;
22
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lydianpay/sdk-web",
3
- "version": "3.12.0",
3
+ "version": "3.13.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": {
@@ -60,6 +60,7 @@
60
60
  "devDependencies": {
61
61
  "@eslint/js": "^9.0.0",
62
62
  "@testing-library/dom": "^10.4.1",
63
+ "@testing-library/jest-dom": "^7.0.1",
63
64
  "@testing-library/react": "^16.3.2",
64
65
  "@testing-library/user-event": "^14.6.5",
65
66
  "@types/qrcode": "^1.5.5",
@@ -83,7 +84,7 @@
83
84
  },
84
85
  "dependencies": {
85
86
  "@lydianpay/frontend-shared-helpers": "1.2.0",
86
- "@lydianpay/lydianconnect": "^1.7.1",
87
+ "@lydianpay/lydianconnect": "^1.8.0",
87
88
  "@lydianpay/lydianconnect-catalog": "^1.4.0",
88
89
  "@solana/qr-code-styling": "^1.6.0",
89
90
  "dompurify": "^3.4.12",