@lydianpay/sdk-web 3.0.1 → 3.2.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.
Files changed (72) hide show
  1. package/README.md +9 -8
  2. package/dist/chunks/index-BhtU_AAG.js +740 -0
  3. package/dist/chunks/{index-YAGlsS0s.js → index-CVTOXcSY.js} +13 -14
  4. package/dist/chunks/{metamask-sdk-CFm2IK48.js → metamask-sdk-BwVxHW1_.js} +1 -1
  5. package/dist/chunks/mountEngine-P1Ws89oo.js +34936 -0
  6. package/dist/lydian.js +1 -1
  7. package/dist/types/.tsbuildinfo +1 -1
  8. package/dist/types/constants.d.ts +6 -0
  9. package/dist/types/types.d.ts +1 -0
  10. package/dist/types/ui/Checkout.d.ts +11 -143
  11. package/dist/types/ui/checkoutCallbacks.d.ts +26 -0
  12. package/dist/types/ui/checkoutEngine.d.ts +28 -0
  13. package/dist/types/ui/checkoutPresentation.d.ts +24 -0
  14. package/dist/types/ui/checkoutSelection.d.ts +30 -0
  15. package/dist/types/ui/components/icons.d.ts +0 -1
  16. package/dist/types/ui/copyFields.d.ts +13 -0
  17. package/dist/types/ui/countdownClock.d.ts +5 -0
  18. package/dist/types/ui/dialogController.d.ts +35 -0
  19. package/dist/types/ui/failureReport.d.ts +13 -0
  20. package/dist/types/ui/flowConfig.d.ts +3 -2
  21. package/dist/types/ui/hostCallbacks.d.ts +10 -0
  22. package/dist/types/ui/kycFlow.d.ts +44 -0
  23. package/dist/types/ui/kycVerificationRequest.d.ts +17 -0
  24. package/dist/types/ui/networkListHelpers.d.ts +9 -1
  25. package/dist/types/ui/paymentFlow.d.ts +49 -0
  26. package/dist/types/ui/pollTick.d.ts +15 -0
  27. package/dist/types/ui/react/AssetSelectScreen.d.ts +1 -5
  28. package/dist/types/ui/react/CheckoutApp.d.ts +1 -4
  29. package/dist/types/ui/react/CloseTransactionDialogBody.d.ts +1 -6
  30. package/dist/types/ui/react/ConnectWithQrScreen.d.ts +1 -5
  31. package/dist/types/ui/react/ConnectingWalletScreen.d.ts +1 -5
  32. package/dist/types/ui/react/KycScreen.d.ts +1 -5
  33. package/dist/types/ui/react/LoadingScreen.d.ts +1 -8
  34. package/dist/types/ui/react/NetworkSelectScreen.d.ts +1 -5
  35. package/dist/types/ui/react/PaymentFailureScreen.d.ts +1 -5
  36. package/dist/types/ui/react/PaymentHeaderSection.d.ts +1 -12
  37. package/dist/types/ui/react/PaymentSuccessScreen.d.ts +1 -5
  38. package/dist/types/ui/react/RestoreDetailsDialogBody.d.ts +1 -4
  39. package/dist/types/ui/react/ScanToPayScreen.d.ts +1 -5
  40. package/dist/types/ui/react/TimerBanner/TimerBanner.d.ts +2 -0
  41. package/dist/types/ui/react/TimerBanner/timerBannerHelpers.d.ts +13 -0
  42. package/dist/types/ui/react/WalletSelectScreen.d.ts +1 -5
  43. package/dist/types/ui/react/checkoutActions.d.ts +107 -0
  44. package/dist/types/ui/react/checkoutContext.d.ts +9 -0
  45. package/dist/types/ui/react/checkoutReducer.d.ts +11 -0
  46. package/dist/types/ui/react/checkoutStore.d.ts +19 -11
  47. package/dist/types/ui/react/engine/CheckoutEngine.d.ts +30 -0
  48. package/dist/types/ui/react/engine/checkoutShell.d.ts +3 -0
  49. package/dist/types/ui/react/engine/mountEngine.d.ts +10 -0
  50. package/dist/types/ui/react/engine/useBranding.d.ts +1 -0
  51. package/dist/types/ui/react/engine/useCopyFields.d.ts +1 -0
  52. package/dist/types/ui/react/engine/useHostCallbacks.d.ts +2 -0
  53. package/dist/types/ui/react/engine/useProcessingOverlay.d.ts +1 -0
  54. package/dist/types/ui/react/engine/useScreenNavigator.d.ts +3 -0
  55. package/dist/types/ui/react/mount.d.ts +7 -5
  56. package/dist/types/ui/react/useQrCanvas.d.ts +9 -0
  57. package/dist/types/ui/screenNavigator.d.ts +13 -0
  58. package/dist/types/ui/sessionBootstrap.d.ts +36 -0
  59. package/dist/types/ui/sessionHelpers.d.ts +1 -2
  60. package/dist/types/ui/sessionLifecycle.d.ts +37 -0
  61. package/dist/types/ui/sessionQuoteWatcher.d.ts +7 -8
  62. package/dist/types/ui/settledOutcome.d.ts +14 -0
  63. package/dist/types/ui/transactionOutcome.d.ts +2 -0
  64. package/dist/types/ui/transactionPoller.d.ts +16 -0
  65. package/dist/types/ui/walletConnection.d.ts +48 -0
  66. package/package.json +2 -1
  67. package/dist/chunks/index-NI3RoQG3.js +0 -22485
  68. package/dist/chunks/mount-bhuHFGLm.js +0 -12914
  69. package/dist/types/ui/countdownBanner.d.ts +0 -33
  70. package/dist/types/ui/react/DownloadWalletScreen.d.ts +0 -4
  71. package/dist/types/ui/react/TimerBanner.d.ts +0 -4
  72. package/dist/types/ui/react/callbacksFixture.d.ts +0 -6
@@ -1,13 +1,2 @@
1
1
  import * as React from 'react';
2
- export default function PaymentHeaderSection({ logoVisible, logoUrl, logoAlt, backVisible, onBack, headerVisible, merchant, amount, changeMethodVisible, onChangePaymentMethod, }: {
3
- logoVisible: boolean;
4
- logoUrl: string | null;
5
- logoAlt: string;
6
- backVisible: boolean;
7
- onBack: () => void;
8
- headerVisible: boolean;
9
- merchant: string | null;
10
- amount: string;
11
- changeMethodVisible: boolean;
12
- onChangePaymentMethod: () => void;
13
- }): React.JSX.Element;
2
+ export default function PaymentHeaderSection(): React.JSX.Element;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function PaymentSuccessScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element;
2
+ export default function PaymentSuccessScreen(): React.JSX.Element;
@@ -1,5 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks } from './checkoutStore';
3
- export default function RestoreDetailsDialogBody({ callbacks }: {
4
- callbacks: CheckoutCallbacks;
5
- }): React.JSX.Element;
2
+ export default function RestoreDetailsDialogBody(): React.JSX.Element;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function ScanToPayScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element;
2
+ export default function ScanToPayScreen(): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export default function TimerBanner(): React.JSX.Element | null;
@@ -0,0 +1,13 @@
1
+ export declare function useCountdownTimer({ countdownExpiry, shouldRunCountdown, }: {
2
+ countdownExpiry: number | null;
3
+ shouldRunCountdown: boolean;
4
+ }): {
5
+ remainingTimeMs: number | null;
6
+ hasCountdownExpired: boolean;
7
+ };
8
+ export declare function useCountdownState(): {
9
+ countdownExpiry: number | null;
10
+ processingVisible: boolean;
11
+ isCheckoutSettled: boolean;
12
+ activeScreen: import("../checkoutStore").ActiveScreen | null;
13
+ };
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function WalletSelectScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element;
2
+ export default function WalletSelectScreen(): React.JSX.Element;
@@ -0,0 +1,107 @@
1
+ import type { ActiveScreen, CloseDialogVariant, KycDraft } from './checkoutStore';
2
+ import type { CreateTransactionResponse, DisplayAsset, GetSessionResponse, GetTransactionResponse, InitFlowOptions, WalletConnectWallet } from '../../types';
3
+ import type { RestoreContext } from '../sessionHelpers';
4
+ export type CheckoutAction = {
5
+ type: 'session/loaded';
6
+ session: GetSessionResponse | null;
7
+ } | {
8
+ type: 'session/flowOverride';
9
+ flow: InitFlowOptions | undefined;
10
+ } | {
11
+ type: 'transaction/set';
12
+ transaction: CreateTransactionResponse | null;
13
+ } | {
14
+ type: 'transaction/polledExpiration';
15
+ expiration: string | undefined;
16
+ } | {
17
+ type: 'transaction/settledFlag';
18
+ settled: boolean;
19
+ } | {
20
+ type: 'selection/asset';
21
+ asset: DisplayAsset | null;
22
+ } | {
23
+ type: 'selection/network';
24
+ network: string | null;
25
+ } | {
26
+ type: 'selection/wallet';
27
+ wallet: WalletConnectWallet | null;
28
+ } | {
29
+ type: 'restore/context';
30
+ context: RestoreContext | null;
31
+ } | {
32
+ type: 'screen/show';
33
+ screen: ActiveScreen;
34
+ } | {
35
+ type: 'screen/headerBack';
36
+ visible: boolean;
37
+ } | {
38
+ type: 'checkout/reset';
39
+ } | {
40
+ type: 'payment/succeeded';
41
+ transaction: GetTransactionResponse | null;
42
+ overpaidUSD: number;
43
+ } | {
44
+ type: 'payment/failed';
45
+ message: string;
46
+ } | {
47
+ type: 'payment/underpaid';
48
+ transaction: GetTransactionResponse;
49
+ } | {
50
+ type: 'payment/underpaidCleared';
51
+ } | {
52
+ type: 'banner/error';
53
+ message: string;
54
+ } | {
55
+ type: 'banner/wrongChain';
56
+ message: string;
57
+ } | {
58
+ type: 'banner/clear';
59
+ } | {
60
+ type: 'processing/show';
61
+ } | {
62
+ type: 'processing/hide';
63
+ } | {
64
+ type: 'processing/prompt';
65
+ message: string | null;
66
+ subMessage: string | null;
67
+ cancellable: boolean;
68
+ } | {
69
+ type: 'header/amount';
70
+ amount: string;
71
+ merchant: string | null;
72
+ } | {
73
+ type: 'header/shown';
74
+ } | {
75
+ type: 'header/hidden';
76
+ } | {
77
+ type: 'connect/connecting';
78
+ } | {
79
+ type: 'connect/pairingUri';
80
+ uri: string | null;
81
+ } | {
82
+ type: 'connect/openWallet';
83
+ } | {
84
+ type: 'connect/openFailed';
85
+ installHref: string | null;
86
+ } | {
87
+ type: 'connect/canSign';
88
+ canSign: boolean;
89
+ } | {
90
+ type: 'kyc/show';
91
+ } | {
92
+ type: 'kyc/formReset';
93
+ } | {
94
+ type: 'kyc/draft';
95
+ draft: KycDraft | null;
96
+ } | {
97
+ type: 'restore/dialogOpened';
98
+ } | {
99
+ type: 'dialog/closeVariant';
100
+ variant: CloseDialogVariant;
101
+ } | {
102
+ type: 'branding/applied';
103
+ logoUrl: string | null;
104
+ logoAlt: string;
105
+ termNoticeHtml: string;
106
+ };
107
+ export declare const PRESERVED_ON_RESET: readonly ["brandLogoUrl", "brandLogoAlt", "termNoticeHtml", "session", "flowOverride", "walletConnectFlow", "assetFirstFlow", "hideOtherWallets", "showApprovalPage", "restoreDialogSession", "kycStepSession", "kycFormSession"];
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import type { CheckoutCallbacks, CheckoutState, CheckoutStore } from './checkoutStore';
3
+ export declare function CheckoutProvider({ store, callbacks, children, }: {
4
+ store: CheckoutStore;
5
+ callbacks: CheckoutCallbacks;
6
+ children: React.ReactNode;
7
+ }): React.JSX.Element;
8
+ export declare function useCheckoutActions(): CheckoutCallbacks;
9
+ export declare function useCheckoutState<Slice>(selector: (state: CheckoutState) => Slice): Slice;
@@ -0,0 +1,11 @@
1
+ import { type CheckoutAction } from './checkoutActions';
2
+ import { type CheckoutState, type CheckoutStore } from './checkoutStore';
3
+ export declare function checkoutReducer(state: CheckoutState, action: CheckoutAction): CheckoutState;
4
+ /**
5
+ * Binds the reducer to a store. Orchestration writes only through this.
6
+ *
7
+ * It goes through `setState` with a whole state object on purpose: that keeps
8
+ * the store's own equality check as the last gate, so an action the reducer
9
+ * turned into a no-op cannot notify.
10
+ */
11
+ export declare function createDispatch(store: CheckoutStore): (action: CheckoutAction) => void;
@@ -1,11 +1,10 @@
1
- import type { CreateTransactionResponse, DisplayAsset, GetSessionResponse, GetTransactionResponse, WalletConnectWallet } from '../../types';
1
+ import type { CreateTransactionResponse, DisplayAsset, GetSessionResponse, GetTransactionResponse, InitFlowOptions, WalletConnectWallet } from '../../types';
2
2
  import type { CheckoutWallet } from '../../constants';
3
3
  import type { RestoreContext } from '../sessionHelpers';
4
4
  import type { KycFieldValues } from '../kycValidation';
5
5
  export declare const SCREEN_NAMES: {
6
6
  readonly PAY_BUTTONS: "payButtons";
7
7
  readonly WALLETS: "wallets";
8
- readonly DOWNLOAD_WALLET: "downloadWallet";
9
8
  readonly NETWORKS: "networks";
10
9
  readonly CONNECTING: "connecting";
11
10
  readonly CONNECT_QR: "connectQr";
@@ -25,10 +24,25 @@ export interface CheckoutState {
25
24
  selectedNetwork: string | null;
26
25
  selectedWallet: WalletConnectWallet | null;
27
26
  walletConnectFlow: boolean;
28
- hideNoWalletOption: boolean;
27
+ assetFirstFlow: boolean;
28
+ hideOtherWallets: boolean;
29
+ showApprovalPage: boolean;
29
30
  isCheckoutSettled: boolean;
31
+ /** The embed's `flow` option. Kept so the reducer can derive the flags below. */
32
+ flowOverride: InitFlowOptions | null;
33
+ /**
34
+ * Whether the wrong-network banner currently on screen is ours. Lives here so
35
+ * clearing the banner clears it in the same transition — drifting apart is its
36
+ * entire bug history.
37
+ */
38
+ walletChainWarned: boolean;
39
+ /** Header visibility saved across the processing overlay, restored on hide. */
40
+ paymentHeaderWasVisible: boolean;
41
+ logoHeaderWasVisible: boolean;
30
42
  settledTransaction: GetTransactionResponse | null;
31
43
  overpaidUSD: number;
44
+ polledExpiration: number | null;
45
+ countdownExpiry: number | null;
32
46
  underpaidTransaction: GetTransactionResponse | null;
33
47
  canSignWithConnectedWallet: boolean;
34
48
  connectOpenWalletVisible: boolean;
@@ -70,8 +84,7 @@ export interface IslandClickEvent {
70
84
  target: EventTarget | null;
71
85
  }
72
86
  export interface CheckoutCallbacks {
73
- onDownloadWalletBack(): void;
74
- onTimerClockElement(element: HTMLSpanElement | null): void;
87
+ onCountdownLapsed(): void;
75
88
  onCryptoPay(): void;
76
89
  onLoadingCancel(): void;
77
90
  onHeaderBack(): void;
@@ -82,20 +95,15 @@ export interface CheckoutCallbacks {
82
95
  onSelectNetwork(networkCode: string): void;
83
96
  onSelectAsset(assetCode: string): void;
84
97
  onSelectWallet(wallet: CheckoutWallet): void;
85
- onNoWallet(): void;
86
98
  onDoneSuccess(): void;
87
- onConnectQrElement(element: HTMLDivElement | null): void;
88
99
  onCancelConnect(): void;
89
100
  onOpenWalletApp(): void;
90
101
  onOpenWalletUniversal(): void;
91
102
  onOpenInWallet(event: IslandClickEvent): void;
92
103
  onPanelClick(event: IslandClickEvent): void;
93
- onDownloadQr(): void;
94
104
  onChangeCoin(): void;
95
105
  onCancel(): void;
96
106
  onChooseDifferentAsset(): void;
97
- onCanvasElement(element: HTMLDivElement | null): void;
98
- onPanelElement(element: HTMLDivElement | null): void;
99
107
  onCancelSelection(): void;
100
108
  onSendRestoreOtp(details: {
101
109
  email: string;
@@ -126,13 +134,13 @@ export interface CheckoutCallbacks {
126
134
  onKycCoinSummaryRow(): void;
127
135
  onWalletSummaryRow(): void;
128
136
  onNetworkSummaryRow(): void;
137
+ onNetworkCoinSummaryRow(): void;
129
138
  onAssetWalletSummaryRow(): void;
130
139
  }
131
140
  export interface CheckoutStore {
132
141
  getState(): CheckoutState;
133
142
  setState(partial: Partial<CheckoutState>): void;
134
143
  subscribe(listener: () => void): () => void;
135
- reset(): void;
136
144
  }
137
145
  export declare function defaultCheckoutState(): CheckoutState;
138
146
  export declare function createCheckoutStore(initial?: CheckoutState): CheckoutStore;
@@ -0,0 +1,30 @@
1
+ import * as React from 'react';
2
+ import type { CheckoutCallbacks, CheckoutStore } from '../checkoutStore';
3
+ import type { CheckoutAppTargets } from '../checkoutTargets';
4
+ import { type CheckoutHost, type CheckoutStartup } from '../../checkoutEngine';
5
+ import type { CheckoutInitOptions, Transaction } from '../../../types';
6
+ import type { DialogController } from '../../dialogController';
7
+ export interface CheckoutEngineHandle {
8
+ initialize(options: CheckoutInitOptions, startup: CheckoutStartup): Promise<void>;
9
+ updateTransaction(transaction: Transaction): Promise<void>;
10
+ teardown(): void;
11
+ }
12
+ export interface CheckoutRuntime {
13
+ shadowRoot: ShadowRoot;
14
+ host: CheckoutHost;
15
+ targets: CheckoutAppTargets;
16
+ dialogs: DialogController;
17
+ }
18
+ export declare function useCheckoutRuntime(): CheckoutRuntime;
19
+ export default function CheckoutEngine({ host, shadowRoot, targets, ref, }: {
20
+ host: CheckoutHost;
21
+ shadowRoot: ShadowRoot;
22
+ targets: CheckoutAppTargets;
23
+ ref: React.Ref<CheckoutEngineHandle>;
24
+ }): React.JSX.Element;
25
+ export declare function CheckoutTree({ store, callbacks, runtime, targets, }: {
26
+ store: CheckoutStore;
27
+ callbacks: CheckoutCallbacks;
28
+ runtime: CheckoutRuntime;
29
+ targets: CheckoutAppTargets;
30
+ }): React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { CheckoutInitOptions } from '../../../types';
2
+ export declare function renderCheckoutShell(shadowRoot: ShadowRoot): void;
3
+ export declare function applyCheckoutMode(shadowRoot: ShadowRoot, options: CheckoutInitOptions): void;
@@ -0,0 +1,10 @@
1
+ import type { CheckoutEngineHandle } from './CheckoutEngine';
2
+ import type { CheckoutHost } from '../../checkoutEngine';
3
+ export type { CheckoutEngineHandle } from './CheckoutEngine';
4
+ export type MountedCheckoutEngine = CheckoutEngineHandle & {
5
+ unmount(): void;
6
+ };
7
+ export declare function mountCheckoutEngine({ host, shadowRoot, }: {
8
+ host: CheckoutHost;
9
+ shadowRoot: ShadowRoot;
10
+ }): MountedCheckoutEngine;
@@ -0,0 +1 @@
1
+ export declare function useBranding(): void;
@@ -0,0 +1 @@
1
+ export declare function useCopyFields(): void;
@@ -0,0 +1,2 @@
1
+ import { type HostCallbacks } from '../../hostCallbacks';
2
+ export declare function useHostCallbacks(): HostCallbacks;
@@ -0,0 +1 @@
1
+ export declare function useProcessingOverlay(): void;
@@ -0,0 +1,3 @@
1
+ import { type ScreenNavigator } from '../../screenNavigator';
2
+ import type { CheckoutStore } from '../checkoutStore';
3
+ export declare function useScreenNavigator(store: CheckoutStore): ScreenNavigator;
@@ -1,10 +1,12 @@
1
- import { type CheckoutAppTargets } from './CheckoutApp';
2
- import type { CheckoutCallbacks, CheckoutStore } from './checkoutStore';
1
+ import { type CheckoutEngineHandle } from './engine/CheckoutEngine';
2
+ import type { CheckoutAppTargets } from './checkoutTargets';
3
+ import type { CheckoutHost } from '../checkoutEngine';
3
4
  export interface CheckoutAppHandle {
5
+ engine: CheckoutEngineHandle;
4
6
  unmount(): void;
5
7
  }
6
- export declare function mountCheckoutApp({ targets, store, callbacks, }: {
8
+ export declare function mountCheckoutApp({ host, shadowRoot, targets, }: {
9
+ host: CheckoutHost;
10
+ shadowRoot: ShadowRoot;
7
11
  targets: CheckoutAppTargets;
8
- store: CheckoutStore;
9
- callbacks: CheckoutCallbacks;
10
12
  }): CheckoutAppHandle;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import QRCodeStyling, { type Options as QrOptions } from '@solana/qr-code-styling';
3
+ export declare function useQrCanvas({ ref, data, options, }: {
4
+ ref: React.RefObject<HTMLDivElement | null>;
5
+ data: string | null | undefined;
6
+ options: Omit<QrOptions, 'data'>;
7
+ }): {
8
+ download: (downloadOptions: Parameters<QRCodeStyling['download']>[0]) => void;
9
+ };
@@ -0,0 +1,13 @@
1
+ import { type ActiveScreen, type CheckoutStore, type KycDraft } from './react/checkoutStore';
2
+ export interface ScreenNavigator {
3
+ show(screen: ActiveScreen): void;
4
+ payButtons(): void;
5
+ wallets(): void;
6
+ networks(): void;
7
+ assets(): void;
8
+ setBack(action: (() => void) | null): void;
9
+ back(): void;
10
+ registerKycDraftSource(getDraft: (() => KycDraft) | null): void;
11
+ stashKycDraft(): void;
12
+ }
13
+ export declare function createScreenNavigator(store: CheckoutStore): ScreenNavigator;
@@ -0,0 +1,36 @@
1
+ import type { API } from '../network';
2
+ import type { CheckoutEventName, CheckoutInitOptions, GetSessionResponse, GetTransactionResponse } from '../types';
3
+ export type SessionBootstrapApi = Pick<API, 'createSession' | 'getSession' | 'getCryptoTransaction'>;
4
+ export type SessionSnapshot = {
5
+ session: GetSessionResponse;
6
+ sessionPromoted: boolean;
7
+ };
8
+ export type SessionBootstrapResult = {
9
+ ok: true;
10
+ session: GetSessionResponse;
11
+ sessionPromoted: boolean;
12
+ linkedTransaction: GetTransactionResponse | null;
13
+ } | {
14
+ ok: false;
15
+ };
16
+ type Emit = (name: CheckoutEventName, data?: Record<string, unknown>) => void;
17
+ export declare function bootstrapSession({ api, options, emit, }: {
18
+ api: SessionBootstrapApi;
19
+ options: CheckoutInitOptions;
20
+ emit: Emit;
21
+ }): Promise<SessionBootstrapResult>;
22
+ export declare function resolveSessionId({ api, options, }: {
23
+ api: SessionBootstrapApi;
24
+ options: CheckoutInitOptions;
25
+ }): Promise<string>;
26
+ export declare function readSession({ api, sessionID, }: {
27
+ api: SessionBootstrapApi;
28
+ sessionID: string;
29
+ }): Promise<SessionSnapshot>;
30
+ export declare function sessionLoadedEvent(session: GetSessionResponse): Record<string, unknown>;
31
+ export declare function isAlreadyPromoted(session: GetSessionResponse): boolean;
32
+ export declare function fetchLinkedTransaction({ api, transactionID, }: {
33
+ api: SessionBootstrapApi;
34
+ transactionID: string | undefined;
35
+ }): Promise<GetTransactionResponse | null>;
36
+ export {};
@@ -8,8 +8,7 @@ export declare function getTransactionIdToRequote(session: {
8
8
  } | null, cryptoTransaction: {
9
9
  transactionId?: string;
10
10
  } | null, promoted: boolean): string | null;
11
- export type TransactionOutcome = 'succeeded' | 'failed' | 'active';
12
- export declare function transactionOutcome(status: number): TransactionOutcome;
11
+ export { transactionOutcome, type TransactionOutcome } from './transactionOutcome';
13
12
  export declare const POLL_FAILURES_BEFORE_NOTICE = 5;
14
13
  export declare function shouldReportPollFailure(consecutiveFailures: number): boolean;
15
14
  export declare function getSessionQuoteExpiry(session: {
@@ -0,0 +1,37 @@
1
+ import { type SessionBootstrapResult } from './sessionBootstrap';
2
+ import type { API } from '../network';
3
+ import type { CheckoutStore } from './react/checkoutStore';
4
+ import type { CheckoutEventName, CheckoutInitOptions, CreateTransactionResponse, GetTransactionResponse, NewSessionInitOptions, Transaction } from '../types';
5
+ export interface SessionLifecycle {
6
+ /** Whether the current session has already been promoted. */
7
+ readonly promoted: boolean;
8
+ /** Transaction previously created from a supplied session, if any. */
9
+ readonly linkedTransaction: GetTransactionResponse | null;
10
+ /** Adopt the session loaded during checkout sessionResult. */
11
+ initializeFromSessionResult(sessionResult: SessionBootstrapResult): boolean;
12
+ /** Create and load a replacement session. */
13
+ create(): Promise<void>;
14
+ /** Replace the current session only when it can no longer be promoted. */
15
+ ensureFresh(): Promise<void>;
16
+ /** Whether the SDK is allowed to replace the current session. */
17
+ canReplace(): boolean;
18
+ markPromotedFrom(response: CreateTransactionResponse): void;
19
+ amountForDisplay(): {
20
+ amount: number;
21
+ currency: string | null;
22
+ } | null;
23
+ }
24
+ export declare function createSessionLifecycle({ store, getApi, getOptions, emit, }: {
25
+ store: CheckoutStore;
26
+ getApi: () => API | null;
27
+ getOptions: () => CheckoutInitOptions | null;
28
+ emit: (name: CheckoutEventName, data?: Record<string, unknown>) => void;
29
+ }): SessionLifecycle;
30
+ export type TransactionUpdateCheck = {
31
+ ok: true;
32
+ options: NewSessionInitOptions;
33
+ } | {
34
+ ok: false;
35
+ message: string;
36
+ };
37
+ export declare function checkTransactionUpdate(options: CheckoutInitOptions | null, transaction: Transaction): TransactionUpdateCheck;
@@ -2,14 +2,13 @@ export type SessionQuoteWatcherOptions = {
2
2
  getExpiry: () => number | null;
3
3
  onExpired: () => Promise<void>;
4
4
  };
5
- export declare class SessionQuoteWatcher {
6
- private readonly options;
7
- private timeoutID;
8
- private consecutiveRefreshes;
9
- constructor(options: SessionQuoteWatcherOptions);
5
+ export interface SessionQuoteWatcher {
6
+ /**
7
+ * Call when the customer starts on a quote the SDK didn't just refresh —
8
+ * checkout init, or updateTransaction. Clears the refresh budget.
9
+ */
10
10
  start(): void;
11
11
  stop(): void;
12
- get isRunning(): boolean;
13
- private schedule;
14
- private onDeadline;
12
+ readonly isRunning: boolean;
15
13
  }
14
+ export declare function createSessionQuoteWatcher(options: SessionQuoteWatcherOptions): SessionQuoteWatcher;
@@ -0,0 +1,14 @@
1
+ import type { GetSessionResponse, GetTransactionResponse, PaymentFailure, PaymentResult } from '../types';
2
+ export type SettledOutcomeReport = {
3
+ outcome: 'succeeded';
4
+ event: Record<string, unknown>;
5
+ result: PaymentResult;
6
+ } | {
7
+ outcome: 'failed';
8
+ message: string;
9
+ failure: PaymentFailure;
10
+ };
11
+ export declare function settledOutcomeReport({ transaction, session, }: {
12
+ transaction: GetTransactionResponse;
13
+ session: GetSessionResponse | null;
14
+ }): SettledOutcomeReport | null;
@@ -0,0 +1,2 @@
1
+ export type TransactionOutcome = 'succeeded' | 'failed' | 'active';
2
+ export declare function transactionOutcome(status: number): TransactionOutcome;
@@ -0,0 +1,16 @@
1
+ export interface TransactionPollerCallbacks {
2
+ /** One tick's work. Rejecting counts as a failed poll. */
3
+ poll(): Promise<void>;
4
+ /** A poll succeeded after the outage notice went up. */
5
+ onRecovered(): void;
6
+ /** Enough consecutive failures that the customer should be told. */
7
+ onSustainedFailure(): void;
8
+ }
9
+ export interface TransactionPoller {
10
+ /** Restarts from a clean failure count. Safe to call while already running. */
11
+ start(): void;
12
+ stop(): void;
13
+ }
14
+ export declare function createTransactionPoller(callbacks: TransactionPollerCallbacks, { intervalMs }?: {
15
+ intervalMs?: number;
16
+ }): TransactionPoller;
@@ -0,0 +1,48 @@
1
+ import { type BuiltSend } from '../chains/adapters';
2
+ import { type CheckoutWallet } from '../constants';
3
+ import { type CheckoutStore } from './react/checkoutStore';
4
+ import type { CheckoutPresentation } from './checkoutPresentation';
5
+ import type { DialogController } from './dialogController';
6
+ import type { PaymentFlow } from './paymentFlow';
7
+ import type { ScreenNavigator } from './screenNavigator';
8
+ import type { CheckoutEventName, CheckoutInitOptions, PaymentFailureReason } from '../types';
9
+ export interface WalletConnection {
10
+ /** Off by default: only a walletConnect-flow merchant with a project id gets a service. */
11
+ initialize(): Promise<void>;
12
+ choose(wallet: CheckoutWallet): void;
13
+ /** Whether the picked wallet is one checkout can actually connect to. */
14
+ hasConnectable(): boolean;
15
+ connect(networkCode: string): Promise<void>;
16
+ cancelConnect(): void;
17
+ /** Null unless a connected wallet can sign for the live transaction. */
18
+ buildSend(): BuiltSend | null;
19
+ /** The send to sign — the one held for the confirmation screen, or a fresh build. */
20
+ sendForSigning(): BuiltSend | null;
21
+ /** Held while the customer looks at the confirmation screen. */
22
+ setPendingSend(built: BuiltSend | null): void;
23
+ hasPendingSend(): boolean;
24
+ signAndSubmit(built: BuiltSend): Promise<void>;
25
+ openWallet(link?: 'universal'): void;
26
+ showConnectWithQr(): void;
27
+ teardown(): void;
28
+ }
29
+ export interface WalletConnectionSeams {
30
+ reportFailure(message: string, reason: PaymentFailureReason, options?: {
31
+ shouldEndCheckout?: boolean;
32
+ }): void;
33
+ setProcessingMessage(prompt: {
34
+ message: string | null;
35
+ subMessage?: string | null;
36
+ cancellable?: boolean;
37
+ }): void;
38
+ }
39
+ export declare function createWalletConnection({ store, presentation, screenNavigator, paymentFlow, getDialogs, getOptions, emit, seams, }: {
40
+ store: CheckoutStore;
41
+ presentation: CheckoutPresentation;
42
+ screenNavigator: ScreenNavigator;
43
+ paymentFlow: PaymentFlow;
44
+ getDialogs: () => DialogController | null;
45
+ getOptions: () => CheckoutInitOptions | null;
46
+ emit: (name: CheckoutEventName, data?: Record<string, unknown>) => void;
47
+ seams: WalletConnectionSeams;
48
+ }): WalletConnection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lydianpay/sdk-web",
3
- "version": "3.0.1",
3
+ "version": "3.2.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": {
@@ -68,6 +68,7 @@
68
68
  "@vitest/coverage-v8": "^3.0.0",
69
69
  "autoprefixer": "^10.4.0",
70
70
  "eslint": "^9.0.0",
71
+ "eslint-plugin-react-hooks": "^7.1.1",
71
72
  "globals": "^16.0.0",
72
73
  "jsdom": "^29.1.1",
73
74
  "npm-run-all2": "^7.0.2",