@ton-pay/ui-react 0.1.2 → 0.2.0-beta.2
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/README.md +126 -98
- package/dist/index.d.mts +257 -28
- package/dist/index.d.ts +257 -28
- package/dist/index.js +3217 -319
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3155 -257
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
1
3
|
import { SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
|
|
4
|
+
import { Chain, CreateMoonpayTransferParams, MoonpayGeoResult, MoonpayAmountLimits } from '@ton-pay/api';
|
|
5
|
+
export { Chain } from '@ton-pay/api';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
7
|
|
|
3
8
|
type TonPayPreset = "default" | "gradient";
|
|
4
|
-
type
|
|
9
|
+
type TonPayVariant = "long" | "short";
|
|
10
|
+
type OnRampProvider = "moonpay";
|
|
11
|
+
type TonPayMessage = SendTransactionRequest["messages"][number] & {
|
|
12
|
+
payload: string;
|
|
13
|
+
};
|
|
14
|
+
type GetMessageFn<T extends object = object> = (senderAddr: string) => Promise<{
|
|
15
|
+
message: TonPayMessage;
|
|
16
|
+
} & T>;
|
|
17
|
+
type PayInfo<T extends object = object> = {
|
|
18
|
+
message: TonPayMessage;
|
|
19
|
+
txResult: SendTransactionResponse;
|
|
20
|
+
} & T;
|
|
21
|
+
interface TonPayButtonProps {
|
|
5
22
|
handlePay: () => Promise<void>;
|
|
6
23
|
isLoading?: boolean;
|
|
7
|
-
variant?:
|
|
24
|
+
variant?: TonPayVariant;
|
|
8
25
|
preset?: TonPayPreset;
|
|
9
26
|
onError?: (error: unknown) => void;
|
|
10
27
|
showErrorNotification?: boolean;
|
|
@@ -16,47 +33,259 @@ type TonPayButtonProps = {
|
|
|
16
33
|
height?: number | string;
|
|
17
34
|
text?: string;
|
|
18
35
|
loadingText?: string;
|
|
19
|
-
style?:
|
|
36
|
+
style?: CSSProperties;
|
|
20
37
|
className?: string;
|
|
21
38
|
showMenu?: boolean;
|
|
22
39
|
disabled?: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
amount?: number | string;
|
|
41
|
+
currency?: string;
|
|
42
|
+
apiKey?: string;
|
|
43
|
+
isOnRampAvailable?: boolean;
|
|
44
|
+
onCardPaymentSuccess?: () => void;
|
|
45
|
+
itemTitle?: string;
|
|
46
|
+
}
|
|
47
|
+
interface NotificationProps {
|
|
27
48
|
title: string;
|
|
28
49
|
text?: string;
|
|
29
|
-
icon?:
|
|
50
|
+
icon?: ReactNode;
|
|
30
51
|
className?: string;
|
|
31
|
-
style?:
|
|
32
|
-
}
|
|
52
|
+
style?: CSSProperties;
|
|
53
|
+
}
|
|
54
|
+
interface PaymentModalProps {
|
|
55
|
+
isOpen: boolean;
|
|
56
|
+
onClose: () => void;
|
|
57
|
+
onPayWithCrypto: () => void;
|
|
58
|
+
amount?: string;
|
|
59
|
+
currency?: string;
|
|
60
|
+
itemTitle?: string;
|
|
61
|
+
walletAddress?: string;
|
|
62
|
+
onDisconnect?: () => void;
|
|
63
|
+
fetchOnRampLink?: (providerId: string) => Promise<string>;
|
|
64
|
+
onRampAvailable?: boolean;
|
|
65
|
+
onPaymentSuccess?: () => void;
|
|
66
|
+
}
|
|
67
|
+
type PaymentViewState = "main" | "card" | "success" | "error";
|
|
68
|
+
interface BottomSheetProps {
|
|
69
|
+
isOpen: boolean;
|
|
70
|
+
onClose: () => void;
|
|
71
|
+
detents?: number[];
|
|
72
|
+
initialDetent?: number;
|
|
73
|
+
children: ReactNode;
|
|
74
|
+
className?: string;
|
|
75
|
+
backdropClassName?: string;
|
|
76
|
+
handleClassName?: string;
|
|
77
|
+
contentClassName?: string;
|
|
78
|
+
enableBackdropClose?: boolean;
|
|
79
|
+
enableSwipeToClose?: boolean;
|
|
80
|
+
maxHeight?: number | string;
|
|
81
|
+
minHeight?: number | string;
|
|
82
|
+
}
|
|
83
|
+
interface UseMoonPayIframeOptions {
|
|
84
|
+
apiKey?: string;
|
|
85
|
+
chain?: Chain;
|
|
86
|
+
provider?: OnRampProvider;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare const TonPayButton: React.FC<TonPayButtonProps>;
|
|
90
|
+
|
|
91
|
+
declare const PaymentModal: React.FC<PaymentModalProps>;
|
|
92
|
+
|
|
93
|
+
declare const BottomSheet: React.FC<BottomSheetProps>;
|
|
94
|
+
|
|
33
95
|
declare const NotificationCard: React.FC<NotificationProps>;
|
|
34
96
|
declare const NotificationRoot: React.FC<{
|
|
35
97
|
children?: React.ReactNode;
|
|
36
98
|
}>;
|
|
37
|
-
declare const ErrorDotIcon: React.FC<{
|
|
38
|
-
color?: string;
|
|
39
|
-
}>;
|
|
40
99
|
|
|
41
|
-
|
|
100
|
+
interface ErrorTransactionNotificationProps {
|
|
42
101
|
text?: string;
|
|
43
102
|
className?: string;
|
|
44
103
|
style?: React.CSSProperties;
|
|
45
|
-
}
|
|
104
|
+
}
|
|
105
|
+
declare const ErrorTransactionNotification: React.FC<ErrorTransactionNotificationProps>;
|
|
46
106
|
|
|
47
|
-
|
|
48
|
-
|
|
107
|
+
declare function useTonPay(): {
|
|
108
|
+
pay: <T extends object = object>(getMessage: GetMessageFn<T>) => Promise<PayInfo<T>>;
|
|
109
|
+
address: string;
|
|
49
110
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
address: string | null;
|
|
111
|
+
|
|
112
|
+
declare function useMoonPayIframe({ apiKey, chain, }: UseMoonPayIframeOptions): {
|
|
113
|
+
loading: boolean;
|
|
114
|
+
error: string | null;
|
|
115
|
+
link: string | null;
|
|
116
|
+
fetchOnRampLink: (params: CreateMoonpayTransferParams) => Promise<string>;
|
|
117
|
+
checkAvailability: (amount: number, asset: string, ipAddress: string) => Promise<boolean>;
|
|
118
|
+
geoResult: MoonpayGeoResult | null;
|
|
119
|
+
limits: MoonpayAmountLimits | null;
|
|
60
120
|
};
|
|
61
121
|
|
|
62
|
-
|
|
122
|
+
interface KeyPair {
|
|
123
|
+
publicKey: Uint8Array;
|
|
124
|
+
privateKey: Uint8Array;
|
|
125
|
+
}
|
|
126
|
+
declare function generateKeyPair(): Promise<KeyPair>;
|
|
127
|
+
declare function signMessage(privateKey: Uint8Array, message: Uint8Array): Promise<Uint8Array>;
|
|
128
|
+
declare function verifySignlessSignature(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
129
|
+
|
|
130
|
+
interface EncryptedKeyVault {
|
|
131
|
+
salt: string;
|
|
132
|
+
iv: string;
|
|
133
|
+
encryptedBlob: string;
|
|
134
|
+
publicKey: string;
|
|
135
|
+
version: number;
|
|
136
|
+
}
|
|
137
|
+
declare function encryptPrivateKey(privateKey: Uint8Array, publicKey: Uint8Array, pin: string): Promise<EncryptedKeyVault>;
|
|
138
|
+
declare function decryptPrivateKey(vault: EncryptedKeyVault, pin: string): Promise<Uint8Array>;
|
|
139
|
+
|
|
140
|
+
interface WebAuthnCredentialInfo {
|
|
141
|
+
credentialId: string;
|
|
142
|
+
publicKey: string;
|
|
143
|
+
transports?: AuthenticatorTransport[];
|
|
144
|
+
}
|
|
145
|
+
declare function isWebAuthnSupported(): boolean;
|
|
146
|
+
declare function createWebAuthnCredential(walletAddress: string): Promise<WebAuthnCredentialInfo>;
|
|
147
|
+
declare function getWebAuthnCredential(credentialInfo: WebAuthnCredentialInfo): Promise<ArrayBuffer>;
|
|
148
|
+
|
|
149
|
+
type SignlessAuthMethod = "pin" | "biometric" | "none";
|
|
150
|
+
type SignlessStatus = "disabled" | "not_setup" | "locked" | "unlocked" | "setting_up";
|
|
151
|
+
interface SignlessConfig {
|
|
152
|
+
enabled: boolean;
|
|
153
|
+
authMethod: SignlessAuthMethod;
|
|
154
|
+
autoLockTimeout?: number;
|
|
155
|
+
storageKey?: string;
|
|
156
|
+
}
|
|
157
|
+
interface SignlessState {
|
|
158
|
+
status: SignlessStatus;
|
|
159
|
+
isEnabled: boolean;
|
|
160
|
+
isSetup: boolean;
|
|
161
|
+
isUnlocked: boolean;
|
|
162
|
+
authMethod: SignlessAuthMethod;
|
|
163
|
+
publicKey: string | null;
|
|
164
|
+
walletAddress: string | null;
|
|
165
|
+
}
|
|
166
|
+
interface SignlessVaultData {
|
|
167
|
+
vault: EncryptedKeyVault;
|
|
168
|
+
authMethod: SignlessAuthMethod;
|
|
169
|
+
walletAddress: string;
|
|
170
|
+
webauthnCredential?: WebAuthnCredentialInfo;
|
|
171
|
+
createdAt: number;
|
|
172
|
+
updatedAt: number;
|
|
173
|
+
}
|
|
174
|
+
interface SignlessSetupParams {
|
|
175
|
+
authMethod: SignlessAuthMethod;
|
|
176
|
+
pin?: string;
|
|
177
|
+
}
|
|
178
|
+
interface SignlessUnlockParams {
|
|
179
|
+
pin?: string;
|
|
180
|
+
}
|
|
181
|
+
interface SignlessPayloadParams {
|
|
182
|
+
recipient: string;
|
|
183
|
+
amount: string;
|
|
184
|
+
token?: string;
|
|
185
|
+
payload?: string;
|
|
186
|
+
reference?: string;
|
|
187
|
+
validUntil?: number;
|
|
188
|
+
}
|
|
189
|
+
interface SignlessSignedPayload {
|
|
190
|
+
payload: Uint8Array;
|
|
191
|
+
signature: Uint8Array;
|
|
192
|
+
publicKey: string;
|
|
193
|
+
reference: string;
|
|
194
|
+
validUntil: number;
|
|
195
|
+
}
|
|
196
|
+
interface SignlessContextValue {
|
|
197
|
+
state: SignlessState;
|
|
198
|
+
config: SignlessConfig;
|
|
199
|
+
setup: (params: SignlessSetupParams) => Promise<void>;
|
|
200
|
+
unlock: (params: SignlessUnlockParams) => Promise<void>;
|
|
201
|
+
lock: () => void;
|
|
202
|
+
reset: () => Promise<void>;
|
|
203
|
+
signPayload: (params: SignlessPayloadParams) => Promise<SignlessSignedPayload>;
|
|
204
|
+
updateConfig: (config: Partial<SignlessConfig>) => void;
|
|
205
|
+
isBiometricAvailable: boolean;
|
|
206
|
+
}
|
|
207
|
+
interface PinInputProps {
|
|
208
|
+
length?: number;
|
|
209
|
+
onComplete: (pin: string) => void;
|
|
210
|
+
onCancel?: () => void;
|
|
211
|
+
title?: string;
|
|
212
|
+
subtitle?: string;
|
|
213
|
+
error?: string | null;
|
|
214
|
+
isLoading?: boolean;
|
|
215
|
+
showBiometric?: boolean;
|
|
216
|
+
onBiometricPress?: () => void;
|
|
217
|
+
}
|
|
218
|
+
interface SignlessSetupModalProps {
|
|
219
|
+
isOpen: boolean;
|
|
220
|
+
onClose: () => void;
|
|
221
|
+
onComplete: () => void;
|
|
222
|
+
showBiometric?: boolean;
|
|
223
|
+
}
|
|
224
|
+
interface SignlessUnlockModalProps {
|
|
225
|
+
isOpen: boolean;
|
|
226
|
+
onClose: () => void;
|
|
227
|
+
onUnlock: () => void;
|
|
228
|
+
showBiometric?: boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
interface SignlessProviderProps {
|
|
232
|
+
children: React.ReactNode;
|
|
233
|
+
config?: Partial<SignlessConfig>;
|
|
234
|
+
}
|
|
235
|
+
declare function SignlessProvider({ children, config }: SignlessProviderProps): react_jsx_runtime.JSX.Element;
|
|
236
|
+
declare function useSignless(): SignlessContextValue;
|
|
237
|
+
|
|
238
|
+
interface UseTonPaySignlessResult {
|
|
239
|
+
pay: <T extends object = object>(getMessage: GetMessageFn<T>) => Promise<PayInfo<T>>;
|
|
240
|
+
paySignless: (params: SignlessPayloadParams) => Promise<SignlessSignedPayload>;
|
|
241
|
+
address: string;
|
|
242
|
+
signless: {
|
|
243
|
+
state: SignlessState;
|
|
244
|
+
config: SignlessConfig;
|
|
245
|
+
setup: (params: SignlessSetupParams) => Promise<void>;
|
|
246
|
+
unlock: (params: SignlessUnlockParams) => Promise<void>;
|
|
247
|
+
lock: () => void;
|
|
248
|
+
reset: () => Promise<void>;
|
|
249
|
+
updateConfig: (config: Partial<SignlessConfig>) => void;
|
|
250
|
+
isBiometricAvailable: boolean;
|
|
251
|
+
isEnabled: boolean;
|
|
252
|
+
isSetup: boolean;
|
|
253
|
+
isUnlocked: boolean;
|
|
254
|
+
requiresUnlock: boolean;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
declare function useTonPaySignless(): UseTonPaySignlessResult;
|
|
258
|
+
|
|
259
|
+
type SignlessModalType = "setup" | "unlock" | null;
|
|
260
|
+
interface UseSignlessModalResult {
|
|
261
|
+
modalType: SignlessModalType;
|
|
262
|
+
isOpen: boolean;
|
|
263
|
+
openSetup: () => void;
|
|
264
|
+
openUnlock: () => void;
|
|
265
|
+
close: () => void;
|
|
266
|
+
onSetupComplete: () => void;
|
|
267
|
+
onUnlockComplete: () => void;
|
|
268
|
+
}
|
|
269
|
+
declare function useSignlessModal(): UseSignlessModalResult;
|
|
270
|
+
|
|
271
|
+
declare const PinInput: React.FC<PinInputProps>;
|
|
272
|
+
|
|
273
|
+
declare const SignlessSetupModal: React.FC<SignlessSetupModalProps>;
|
|
274
|
+
|
|
275
|
+
declare const SignlessUnlockModal: React.FC<SignlessUnlockModalProps>;
|
|
276
|
+
|
|
277
|
+
declare class SignlessStorage {
|
|
278
|
+
private storageKey;
|
|
279
|
+
constructor(storageKey?: string);
|
|
280
|
+
private getStorage;
|
|
281
|
+
saveVault(walletAddress: string, vault: EncryptedKeyVault, authMethod: SignlessAuthMethod, webauthnCredential?: WebAuthnCredentialInfo): Promise<void>;
|
|
282
|
+
loadVault(walletAddress: string): Promise<SignlessVaultData | null>;
|
|
283
|
+
deleteVault(walletAddress: string): Promise<void>;
|
|
284
|
+
hasVault(walletAddress: string): Promise<boolean>;
|
|
285
|
+
updateVaultTimestamp(walletAddress: string): Promise<void>;
|
|
286
|
+
getAllWalletsWithVaults(): Promise<string[]>;
|
|
287
|
+
private getStorageKeyForWallet;
|
|
288
|
+
}
|
|
289
|
+
declare const signlessStorage: SignlessStorage;
|
|
290
|
+
|
|
291
|
+
export { BottomSheet, type BottomSheetProps, type EncryptedKeyVault, ErrorTransactionNotification, type GetMessageFn, NotificationCard, type NotificationProps, NotificationRoot, type OnRampProvider, type PayInfo, PaymentModal, type PaymentModalProps, type PaymentViewState, PinInput, type PinInputProps, type SignlessAuthMethod, type SignlessConfig, type SignlessContextValue, type SignlessModalType, type SignlessPayloadParams, SignlessProvider, SignlessSetupModal, type SignlessSetupModalProps, type SignlessSetupParams, type SignlessSignedPayload, type SignlessState, type SignlessStatus, SignlessStorage, SignlessUnlockModal, type SignlessUnlockModalProps, type SignlessUnlockParams, type SignlessVaultData, TonPayButton, type TonPayButtonProps, type TonPayMessage, type TonPayPreset, type TonPayVariant, type UseMoonPayIframeOptions, type UseSignlessModalResult, type UseTonPaySignlessResult, type WebAuthnCredentialInfo, createWebAuthnCredential, decryptPrivateKey, encryptPrivateKey, generateKeyPair, getWebAuthnCredential, isWebAuthnSupported, signMessage, signlessStorage, useMoonPayIframe, useSignless, useSignlessModal, useTonPay, useTonPaySignless, verifySignlessSignature };
|