@lydianpay/sdk-web 3.12.1 → 3.13.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/dist/chunks/{index-SPRFpU-C.js → index-BsBqHeHy.js} +8 -7
- package/dist/chunks/{index--ad5-TxB.js → index-fJBrLteK.js} +1 -1
- package/dist/chunks/{metamask-sdk-ECy5wqL0.js → metamask-sdk-BIbC0y1P.js} +1 -1
- package/dist/chunks/{mountEngine-D6tvuIMZ.js → mountEngine-BIIdZhCT.js} +10511 -10220
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +2 -0
- package/dist/types/ui/flowConfig.d.ts +1 -0
- package/dist/types/ui/ldkCheckout.d.ts +14 -0
- package/dist/types/ui/ldkHandoff.d.ts +29 -0
- package/dist/types/ui/pollSequentially.d.ts +14 -0
- package/dist/types/ui/react/WalletCheckoutScreen.d.ts +2 -0
- package/dist/types/ui/react/WalletLogo.d.ts +6 -0
- package/dist/types/ui/react/checkoutActions.d.ts +1 -1
- package/dist/types/ui/react/checkoutStore.d.ts +2 -0
- package/dist/types/ui/sessionPromotion.d.ts +25 -0
- package/dist/types/ui/walletConnection.d.ts +6 -0
- package/package.json +3 -2
package/dist/types/types.d.ts
CHANGED
|
@@ -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,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>;
|
|
@@ -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;
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lydianpay/sdk-web",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.1",
|
|
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.
|
|
87
|
+
"@lydianpay/lydianconnect": "^1.8.1",
|
|
87
88
|
"@lydianpay/lydianconnect-catalog": "^1.4.0",
|
|
88
89
|
"@solana/qr-code-styling": "^1.6.0",
|
|
89
90
|
"dompurify": "^3.4.12",
|