cilantro-react 0.1.4 → 0.1.5
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 +146 -28
- package/dist/index.d.mts +506 -554
- package/dist/index.d.ts +506 -554
- package/dist/index.js +2470 -2524
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2468 -2525
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,86 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
import { WalletControllerFindAllResult,
|
|
3
|
+
import { ReactNode, Component, ErrorInfo } from 'react';
|
|
4
|
+
import { WalletControllerFindAllResult, WalletControllerCreateResult, WalletControllerSubmitTransactionResult } from 'cilantro-sdk/wallet';
|
|
5
5
|
export { WalletControllerFindAllResult, WalletControllerFindOneResult, WalletControllerListSignersResult, WalletControllerSubmitTransactionResult } from 'cilantro-sdk/wallet';
|
|
6
|
-
import { SignerInfo } from 'cilantro-sdk/helpers';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
6
|
+
import { createIndexedDBAdapter, SignerInfo } from 'cilantro-sdk/helpers';
|
|
7
|
+
export { createIndexedDBAdapter, createLocalStorageAdapter, createMemoryAdapter } from 'cilantro-sdk/helpers';
|
|
8
|
+
import { PublicKey, Transaction, Connection } from '@solana/web3.js';
|
|
10
9
|
export { AuthControllerLogin200Data } from 'cilantro-sdk/auth';
|
|
11
10
|
export { TransactionControllerSendRawPasskeyTransactionResult } from 'cilantro-sdk/transactions';
|
|
12
11
|
|
|
12
|
+
type DeviceKeyStorage = ReturnType<typeof createIndexedDBAdapter>;
|
|
13
|
+
|
|
14
|
+
/** Minimal user view; populated from SDK login result data.user when available. */
|
|
15
|
+
interface User {
|
|
16
|
+
username?: string;
|
|
17
|
+
email?: string;
|
|
18
|
+
userType?: string;
|
|
19
|
+
}
|
|
20
|
+
/** SDK wallet list item type. */
|
|
21
|
+
type WalletDataDto$1 = WalletControllerFindAllResult["data"] extends readonly (infer E)[] ? E : WalletControllerFindAllResult["data"] extends (infer E)[] ? E : never;
|
|
22
|
+
/** Wallet with backward-compat aliases (id, address, active). */
|
|
23
|
+
type WalletData = WalletDataDto$1 & {
|
|
24
|
+
id?: string;
|
|
25
|
+
address?: string;
|
|
26
|
+
active?: boolean;
|
|
27
|
+
};
|
|
28
|
+
interface CilantroConfig {
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
baseURL: string;
|
|
31
|
+
jwt?: string | null;
|
|
32
|
+
}
|
|
33
|
+
interface CilantroContextValue {
|
|
34
|
+
config: CilantroConfig;
|
|
35
|
+
storage: DeviceKeyStorage | null;
|
|
36
|
+
user: User | null;
|
|
37
|
+
jwt: string | null;
|
|
38
|
+
isAuthenticated: boolean;
|
|
39
|
+
isLoading: boolean;
|
|
40
|
+
login: (params: {
|
|
41
|
+
usernameOrEmail: string;
|
|
42
|
+
password: string;
|
|
43
|
+
}) => Promise<void>;
|
|
44
|
+
logout: () => void;
|
|
45
|
+
register: (username: string, email: string, password: string, isActive?: boolean) => Promise<void>;
|
|
46
|
+
clearSessionDueToAuthError: () => void;
|
|
47
|
+
wallet: WalletData | null;
|
|
48
|
+
wallets: WalletData[];
|
|
49
|
+
createWallet: (params: {
|
|
50
|
+
name: string;
|
|
51
|
+
userId?: string;
|
|
52
|
+
}) => Promise<WalletControllerCreateResult>;
|
|
53
|
+
selectWallet: (walletId: string) => void;
|
|
54
|
+
refreshWallets: () => Promise<void>;
|
|
55
|
+
walletError: string | null;
|
|
56
|
+
walletsLoading: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface CilantroContextProviderProps {
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
apiKey?: string;
|
|
61
|
+
baseURL?: string;
|
|
62
|
+
storageAdapter?: DeviceKeyStorage | null;
|
|
63
|
+
jwtStorageKey?: string;
|
|
64
|
+
walletStorageKey?: string;
|
|
65
|
+
onLoginSuccess?: () => void;
|
|
66
|
+
onLogout?: () => void;
|
|
67
|
+
onRegisterSuccess?: () => void;
|
|
68
|
+
onSessionExpired?: () => void;
|
|
69
|
+
}
|
|
70
|
+
declare function CilantroContextProvider({ children, apiKey, baseURL, storageAdapter, jwtStorageKey, walletStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, onSessionExpired, }: CilantroContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
71
|
+
declare function useCilantroContext(): CilantroContextValue;
|
|
72
|
+
|
|
13
73
|
interface CilantroProviderProps {
|
|
14
74
|
children: ReactNode;
|
|
15
|
-
|
|
75
|
+
/** Platform API key (guide: apiKey). Either apiKey or jwt via login is required for authenticated requests. */
|
|
76
|
+
apiKey?: string;
|
|
77
|
+
/** API base URL (guide: baseURL). Default: https://api.cilantro.gg */
|
|
78
|
+
baseURL?: string;
|
|
79
|
+
/** Storage for device keys - email/phone signers (guide: storageAdapter). Default: IndexedDB in browser. */
|
|
80
|
+
storageAdapter?: DeviceKeyStorage | null;
|
|
81
|
+
/** @deprecated Use apiKey instead. */
|
|
82
|
+
platformApiKey?: string;
|
|
83
|
+
/** @deprecated Use baseURL instead. */
|
|
16
84
|
apiUrl?: string;
|
|
17
85
|
/** localStorage key for JWT (default: cilantro_jwt) */
|
|
18
86
|
jwtStorageKey?: string;
|
|
@@ -21,15 +89,10 @@ interface CilantroProviderProps {
|
|
|
21
89
|
onLoginSuccess?: () => void;
|
|
22
90
|
onLogout?: () => void;
|
|
23
91
|
onRegisterSuccess?: () => void;
|
|
92
|
+
onSessionExpired?: () => void;
|
|
24
93
|
}
|
|
25
|
-
declare function CilantroProvider({ children, platformApiKey, apiUrl, jwtStorageKey, walletStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, }: CilantroProviderProps): react_jsx_runtime.JSX.Element;
|
|
94
|
+
declare function CilantroProvider({ children, apiKey: apiKeyProp, baseURL, storageAdapter, platformApiKey, apiUrl, jwtStorageKey, walletStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, onSessionExpired, }: CilantroProviderProps): react_jsx_runtime.JSX.Element;
|
|
26
95
|
|
|
27
|
-
/** Minimal user view; populated from SDK login result data.user when available. */
|
|
28
|
-
interface User {
|
|
29
|
-
username?: string;
|
|
30
|
-
email?: string;
|
|
31
|
-
userType?: string;
|
|
32
|
-
}
|
|
33
96
|
interface CilantroAuthContextType {
|
|
34
97
|
user: User | null;
|
|
35
98
|
token: string | null;
|
|
@@ -37,28 +100,11 @@ interface CilantroAuthContextType {
|
|
|
37
100
|
login: (usernameOrEmail: string, password: string) => Promise<void>;
|
|
38
101
|
register: (username: string, email: string, password: string, isActive?: boolean) => Promise<void>;
|
|
39
102
|
logout: () => void;
|
|
103
|
+
clearSessionDueToAuthError: () => void;
|
|
40
104
|
isLoading: boolean;
|
|
41
105
|
}
|
|
42
|
-
interface CilantroAuthProviderProps {
|
|
43
|
-
children: ReactNode;
|
|
44
|
-
platformApiKey: string;
|
|
45
|
-
apiUrl?: string;
|
|
46
|
-
jwtStorageKey?: string;
|
|
47
|
-
onLoginSuccess?: () => void;
|
|
48
|
-
onLogout?: () => void;
|
|
49
|
-
onRegisterSuccess?: () => void;
|
|
50
|
-
}
|
|
51
|
-
declare function CilantroAuthProvider({ children, platformApiKey, apiUrl, jwtStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, }: CilantroAuthProviderProps): react_jsx_runtime.JSX.Element;
|
|
52
106
|
declare function useCilantroAuth(): CilantroAuthContextType;
|
|
53
107
|
|
|
54
|
-
/** SDK wallet list item type (element of WalletsListResponseDto.data). */
|
|
55
|
-
type WalletDataDto = WalletControllerFindAllResult["data"] extends readonly (infer E)[] ? E : WalletControllerFindAllResult["data"] extends (infer E)[] ? E : never;
|
|
56
|
-
/** WalletDataDto with backward-compat aliases (id, address, active) for existing UI. */
|
|
57
|
-
type WalletData = WalletDataDto & {
|
|
58
|
-
id?: string;
|
|
59
|
-
address?: string;
|
|
60
|
-
active?: boolean;
|
|
61
|
-
};
|
|
62
108
|
interface WalletContextType {
|
|
63
109
|
selectedWallet: WalletData | null;
|
|
64
110
|
wallets: WalletData[];
|
|
@@ -67,31 +113,40 @@ interface WalletContextType {
|
|
|
67
113
|
isLoading: boolean;
|
|
68
114
|
error: string | null;
|
|
69
115
|
}
|
|
70
|
-
interface WalletProviderProps {
|
|
71
|
-
children: ReactNode;
|
|
72
|
-
storageKey?: string;
|
|
73
|
-
}
|
|
74
|
-
declare function WalletProvider({ children, storageKey }: WalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
75
116
|
declare function useWallets(): WalletContextType;
|
|
76
117
|
|
|
77
|
-
|
|
78
|
-
|
|
118
|
+
type WalletDataDto = WalletData;
|
|
119
|
+
|
|
120
|
+
interface UseCilantroConfigResult {
|
|
121
|
+
config: CilantroConfig;
|
|
122
|
+
storage: DeviceKeyStorage | null;
|
|
123
|
+
}
|
|
124
|
+
declare function useCilantroConfig(): UseCilantroConfigResult;
|
|
125
|
+
|
|
126
|
+
interface UseAuthResult {
|
|
127
|
+
user: User | null;
|
|
128
|
+
jwt: string | null;
|
|
79
129
|
isLoading: boolean;
|
|
80
|
-
|
|
130
|
+
isAuthenticated: boolean;
|
|
131
|
+
login: (params: {
|
|
132
|
+
usernameOrEmail: string;
|
|
133
|
+
password: string;
|
|
134
|
+
}) => Promise<void>;
|
|
135
|
+
logout: () => void;
|
|
81
136
|
}
|
|
82
|
-
|
|
83
|
-
* Returns the currently selected wallet, loading state, and refresh.
|
|
84
|
-
* Use when you only need the current wallet, not the full wallet list.
|
|
85
|
-
* Must be used inside CilantroProvider (WalletProvider).
|
|
86
|
-
*/
|
|
87
|
-
declare function useSelectedWallet(): UseSelectedWalletResult;
|
|
137
|
+
declare function useAuth(): UseAuthResult;
|
|
88
138
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
139
|
+
interface UseWalletResult {
|
|
140
|
+
wallet: WalletData | null;
|
|
141
|
+
wallets: WalletData[];
|
|
142
|
+
createWallet: (params: {
|
|
143
|
+
name: string;
|
|
144
|
+
userId?: string;
|
|
145
|
+
}) => Promise<WalletControllerCreateResult>;
|
|
146
|
+
selectWallet: (walletId: string) => void;
|
|
147
|
+
isLoading: boolean;
|
|
148
|
+
}
|
|
149
|
+
declare function useWallet(_walletId?: string): UseWalletResult;
|
|
95
150
|
|
|
96
151
|
/**
|
|
97
152
|
* Normalized signer shape aligned with SDK SignerDataDto / WalletSignerDataDto.
|
|
@@ -113,6 +168,11 @@ interface SignerData extends Omit<SignerInfo, "signerId"> {
|
|
|
113
168
|
signerCategory?: "onchain" | "authenticationsigner";
|
|
114
169
|
[key: string]: unknown;
|
|
115
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Normalize a raw signer DTO to SignerData (id, signerId, signerPubkey/publicKey, etc.).
|
|
173
|
+
* Use at API boundaries when ingesting signer data from the SDK.
|
|
174
|
+
*/
|
|
175
|
+
declare function normalizeSigner(signer: Record<string, unknown>, category: "onchain" | "authenticationsigner"): SignerData;
|
|
116
176
|
|
|
117
177
|
interface UseSignersOptions {
|
|
118
178
|
/** Wallet ID to load signers for. If not provided, uses selectedWallet?.id from context (call useWallets() in same component). */
|
|
@@ -123,393 +183,82 @@ interface UseSignersResult {
|
|
|
123
183
|
isLoading: boolean;
|
|
124
184
|
error: string | null;
|
|
125
185
|
refresh: () => Promise<void>;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
interface UseSignersForSelectedWalletOptions {
|
|
149
|
-
/** Override wallet ID; when omitted, uses the selected wallet from context. */
|
|
150
|
-
walletId?: string | null;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Returns signers for the currently selected wallet (or the given walletId override).
|
|
154
|
-
* Composes useWallets + useSigners so you don't have to pass walletId yourself.
|
|
155
|
-
* Must be used inside CilantroProvider.
|
|
156
|
-
*/
|
|
157
|
-
declare function useSignersForSelectedWallet(options?: UseSignersForSelectedWalletOptions): UseSignersResult;
|
|
158
|
-
|
|
159
|
-
/** SDK delegated key type (element of DelegatedKeysListResponseDto.data). Canonical id is delegatedKeyId. */
|
|
160
|
-
type DelegatedKeyDataDto = DelegatedKeyControllerFindAllResult["data"] extends readonly (infer E)[] ? E : DelegatedKeyControllerFindAllResult["data"] extends (infer E)[] ? E : never;
|
|
161
|
-
/** DelegatedKeyDataDto with backward-compat id alias (id = delegatedKeyId) for existing UI. */
|
|
162
|
-
type DelegatedKeyData = DelegatedKeyDataDto & {
|
|
163
|
-
id?: string;
|
|
164
|
-
};
|
|
165
|
-
interface UseDelegatedKeysOptions {
|
|
166
|
-
/** Wallet ID to load delegated keys for. When null/undefined, keys are empty. */
|
|
167
|
-
walletId?: string | null;
|
|
168
|
-
/** When true (default), filter to active keys and non-expired only. */
|
|
169
|
-
filterActive?: boolean;
|
|
170
|
-
}
|
|
171
|
-
interface UseDelegatedKeysResult {
|
|
172
|
-
keys: DelegatedKeyData[];
|
|
186
|
+
createEmailSigner: (params: {
|
|
187
|
+
email: string;
|
|
188
|
+
}) => Promise<SignerInfo>;
|
|
189
|
+
createPhoneSigner: (params: {
|
|
190
|
+
phone: string;
|
|
191
|
+
}) => Promise<SignerInfo>;
|
|
192
|
+
revokeSigner: (signerId: string) => Promise<void>;
|
|
193
|
+
}
|
|
194
|
+
declare function useSigners(walletIdOrOptions?: string | null | UseSignersOptions): UseSignersResult;
|
|
195
|
+
|
|
196
|
+
interface UsePasskeyResult {
|
|
197
|
+
isSupported: boolean;
|
|
198
|
+
register: () => Promise<{
|
|
199
|
+
signerId: string;
|
|
200
|
+
isNew: boolean;
|
|
201
|
+
credentialId?: string;
|
|
202
|
+
}>;
|
|
203
|
+
authenticate: (signerId?: string) => Promise<{
|
|
204
|
+
signature: string;
|
|
205
|
+
signerId: string;
|
|
206
|
+
}>;
|
|
173
207
|
isLoading: boolean;
|
|
174
|
-
error: string | null;
|
|
175
|
-
refresh: () => Promise<void>;
|
|
176
208
|
}
|
|
177
|
-
|
|
178
|
-
* Load delegated keys for a wallet. Use for custom delegated-key UI or logic.
|
|
179
|
-
* Must be used inside CilantroProvider (auth required).
|
|
180
|
-
*/
|
|
181
|
-
declare function useDelegatedKeys(options?: UseDelegatedKeysOptions): UseDelegatedKeysResult;
|
|
182
|
-
|
|
183
|
-
type SigningMethod = "wallet-adapter" | "sdk-signer";
|
|
184
|
-
interface UseSignerSelectionOptions {
|
|
185
|
-
/** Override wallet ID; if not set, uses selected wallet from WalletProvider */
|
|
186
|
-
walletId?: string | null;
|
|
187
|
-
/** Current signing method */
|
|
188
|
-
signingMethod?: SigningMethod | null;
|
|
189
|
-
}
|
|
190
|
-
interface UseSignerSelectionResult {
|
|
191
|
-
selectedWalletId: string;
|
|
192
|
-
setSelectedWalletId: (id: string) => void;
|
|
193
|
-
availableSigners: SignerData[];
|
|
194
|
-
selectedSigner: SignerData | null;
|
|
195
|
-
setSelectedSigner: (signer: SignerData | null) => void;
|
|
196
|
-
isLoadingSigners: boolean;
|
|
197
|
-
reset: () => void;
|
|
198
|
-
}
|
|
199
|
-
declare function useSignerSelection(options?: UseSignerSelectionOptions): UseSignerSelectionResult;
|
|
200
|
-
|
|
201
|
-
interface UseCanSignOptions {
|
|
202
|
-
/** Override signing method; when omitted, uses default "sdk-signer". */
|
|
203
|
-
signingMethod?: SigningMethod | null;
|
|
204
|
-
/** When true (default for sdk-signer), require a selected signer. When false, only wallet is required. */
|
|
205
|
-
requireSigner?: boolean;
|
|
206
|
-
/** When using wallet-adapter, pass true when the adapter is connected. Omit if not using wallet-adapter. */
|
|
207
|
-
walletAdapterConnected?: boolean;
|
|
208
|
-
}
|
|
209
|
-
interface UseCanSignResult {
|
|
210
|
-
/** True when the user has a valid token. */
|
|
211
|
-
hasToken: boolean;
|
|
212
|
-
/** True when a wallet is selected. */
|
|
213
|
-
hasWallet: boolean;
|
|
214
|
-
/** True when a signer is selected (sdk-signer) or wallet-adapter is connected (when walletAdapterConnected is passed). */
|
|
215
|
-
hasSigner: boolean;
|
|
216
|
-
/** True when ready to sign a message (hasToken + hasWallet + hasSigner for current method). */
|
|
217
|
-
canSignMessage: boolean;
|
|
218
|
-
/** True when ready to sign/send a transaction (same as canSignMessage; connection is required for send). */
|
|
219
|
-
canSignTransaction: boolean;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Derived "is the user ready to sign?" for disabling sign buttons or showing prompts.
|
|
223
|
-
* For wallet-adapter, pass walletAdapterConnected when your adapter is connected so canSign reflects it.
|
|
224
|
-
* Must be used inside CilantroProvider.
|
|
225
|
-
*/
|
|
226
|
-
declare function useCanSign(options?: UseCanSignOptions): UseCanSignResult;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Type Utilities - common types and utilities for SDK interactions
|
|
230
|
-
*/
|
|
231
|
-
type ActionState<T = unknown> = {
|
|
232
|
-
status: "idle" | "loading" | "success" | "error";
|
|
233
|
-
message?: string;
|
|
234
|
-
detail?: T;
|
|
235
|
-
};
|
|
236
|
-
interface ErrorResponse {
|
|
237
|
-
message?: string;
|
|
238
|
-
error?: string;
|
|
239
|
-
code?: string | number;
|
|
240
|
-
status?: number;
|
|
241
|
-
statusText?: string;
|
|
242
|
-
data?: unknown;
|
|
243
|
-
stack?: string;
|
|
244
|
-
type?: string;
|
|
245
|
-
}
|
|
246
|
-
type ApiResponse<T> = T | {
|
|
247
|
-
data: T;
|
|
248
|
-
} | {
|
|
249
|
-
success: boolean;
|
|
250
|
-
data: T;
|
|
251
|
-
};
|
|
252
|
-
declare function extractResponseData<T>(response: unknown): T | null;
|
|
209
|
+
declare function usePasskey(walletId: string | undefined): UsePasskeyResult;
|
|
253
210
|
|
|
254
|
-
interface
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
/** Optional: callback when using wallet-adapter; signMessage(encodedMessage) => signature bytes */
|
|
260
|
-
walletAdapterSignMessage?: (message: Uint8Array) => Promise<Uint8Array>;
|
|
261
|
-
/** Optional: public key when using wallet-adapter (for result) */
|
|
262
|
-
walletAdapterPublicKey?: string | null;
|
|
263
|
-
}
|
|
264
|
-
interface UseMessageSigningResult {
|
|
265
|
-
messageText: string;
|
|
266
|
-
setMessageText: (text: string) => void;
|
|
267
|
-
signResultState: ActionState;
|
|
268
|
-
isSigning: boolean;
|
|
269
|
-
handleSign: () => Promise<void>;
|
|
270
|
-
reset: () => void;
|
|
271
|
-
}
|
|
272
|
-
declare function useMessageSigning(options: UseMessageSigningOptions): UseMessageSigningResult;
|
|
273
|
-
|
|
274
|
-
interface UseTransactionSigningOptions {
|
|
275
|
-
token: string | null;
|
|
276
|
-
signingMethod: SigningMethod | null;
|
|
277
|
-
selectedSigner: SignerData | null;
|
|
278
|
-
selectedWalletId: string;
|
|
279
|
-
/** Optional: wallet-adapter signTransaction(transaction) => signed transaction */
|
|
280
|
-
walletAdapterSignTransaction?: (transaction: Transaction) => Promise<Transaction>;
|
|
281
|
-
/** Optional: wallet-adapter public key (for building/sending) */
|
|
282
|
-
walletAdapterPublicKey?: string | null;
|
|
283
|
-
/** Optional: connection for sending (e.g. from @solana/web3.js). Used for wallet-adapter send. */
|
|
284
|
-
connection?: {
|
|
285
|
-
sendRawTransaction: (buf: Buffer) => Promise<string>;
|
|
286
|
-
getLatestBlockhash: () => Promise<{
|
|
287
|
-
blockhash: string;
|
|
288
|
-
lastValidBlockHeight: number;
|
|
289
|
-
}>;
|
|
290
|
-
confirmTransaction: (opts: {
|
|
291
|
-
signature: string;
|
|
292
|
-
blockhash: string;
|
|
293
|
-
lastValidBlockHeight: number;
|
|
294
|
-
}) => Promise<void>;
|
|
211
|
+
/** Minimal Solana wallet interface (Phantom, Solflare, etc.) */
|
|
212
|
+
interface SolanaWallet {
|
|
213
|
+
name: string;
|
|
214
|
+
publicKey: {
|
|
215
|
+
toString: () => string;
|
|
295
216
|
} | null;
|
|
217
|
+
connect: () => Promise<{
|
|
218
|
+
publicKey: {
|
|
219
|
+
toString: () => string;
|
|
220
|
+
};
|
|
221
|
+
}>;
|
|
222
|
+
disconnect: () => Promise<void>;
|
|
223
|
+
}
|
|
224
|
+
declare global {
|
|
225
|
+
interface Window {
|
|
226
|
+
solana?: SolanaWallet & {
|
|
227
|
+
isPhantom?: boolean;
|
|
228
|
+
};
|
|
229
|
+
solflare?: SolanaWallet;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
interface UseExternalWalletResult {
|
|
233
|
+
wallets: SolanaWallet[];
|
|
234
|
+
connectedWallet: SolanaWallet | null;
|
|
235
|
+
connect: (wallet: SolanaWallet) => Promise<string>;
|
|
236
|
+
disconnect: () => Promise<void>;
|
|
237
|
+
}
|
|
238
|
+
declare function useExternalWallet(): UseExternalWalletResult;
|
|
239
|
+
|
|
240
|
+
type SignerType$2 = "email" | "phone" | "passkey" | "external";
|
|
241
|
+
interface SubmitTransactionResult {
|
|
242
|
+
success: boolean;
|
|
243
|
+
data: {
|
|
244
|
+
signature?: string;
|
|
245
|
+
[key: string]: unknown;
|
|
246
|
+
};
|
|
296
247
|
}
|
|
297
|
-
interface
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
trigger?: string;
|
|
310
|
-
content?: string;
|
|
311
|
-
item?: string;
|
|
312
|
-
skeleton?: string;
|
|
313
|
-
loading?: string;
|
|
314
|
-
}
|
|
315
|
-
interface WalletSelectorProps {
|
|
316
|
-
value?: string;
|
|
317
|
-
onWalletChange?: (walletId: string, wallet: WalletData | null) => void;
|
|
318
|
-
className?: string;
|
|
319
|
-
classNames?: WalletSelectorClassNames;
|
|
320
|
-
/** When true (default), show skeleton in trigger while loading; when false, show "Loading..." text. */
|
|
321
|
-
useSkeleton?: boolean;
|
|
322
|
-
placeholder?: string;
|
|
323
|
-
renderTrigger?: (props: {
|
|
324
|
-
selectedWallet: WalletData | null;
|
|
325
|
-
wallets: WalletData[];
|
|
326
|
-
isLoading: boolean;
|
|
327
|
-
open: boolean;
|
|
328
|
-
setOpen: (open: boolean) => void;
|
|
329
|
-
}) => React.ReactNode;
|
|
330
|
-
renderList?: (props: {
|
|
331
|
-
wallets: WalletData[];
|
|
332
|
-
selectedWallet: WalletData | null;
|
|
333
|
-
onSelect: (wallet: WalletData) => void;
|
|
334
|
-
isLoading: boolean;
|
|
335
|
-
}) => React.ReactNode;
|
|
336
|
-
children?: (props: {
|
|
337
|
-
wallets: WalletData[];
|
|
338
|
-
selectedWallet: WalletData | null;
|
|
339
|
-
selectWallet: (walletId: string) => void;
|
|
340
|
-
isLoading: boolean;
|
|
341
|
-
refreshWallets: () => Promise<void>;
|
|
342
|
-
}) => React.ReactNode;
|
|
343
|
-
}
|
|
344
|
-
declare function WalletSelector(props: WalletSelectorProps): react_jsx_runtime.JSX.Element;
|
|
345
|
-
|
|
346
|
-
interface SignerSelectorClassNames {
|
|
347
|
-
root?: string;
|
|
348
|
-
list?: string;
|
|
349
|
-
item?: string;
|
|
350
|
-
message?: string;
|
|
351
|
-
skeleton?: string;
|
|
352
|
-
loading?: string;
|
|
353
|
-
}
|
|
354
|
-
interface SignerSelectorProps {
|
|
355
|
-
/** Wallet ID (signers are loaded for this wallet when used with useSigners) */
|
|
356
|
-
selectedWalletId?: string;
|
|
357
|
-
/** Available signers (from useSigners or useSignerSelection) */
|
|
358
|
-
availableSigners: SignerData[];
|
|
359
|
-
/** Currently selected signer */
|
|
360
|
-
selectedSigner: SignerData | null;
|
|
361
|
-
/** Loading state */
|
|
362
|
-
isLoadingSigners?: boolean;
|
|
363
|
-
/** Callback when user selects a signer */
|
|
364
|
-
onSignerSelect: (signer: SignerData) => void;
|
|
365
|
-
/** Root class */
|
|
366
|
-
className?: string;
|
|
367
|
-
/** Override class names for sub-elements */
|
|
368
|
-
classNames?: SignerSelectorClassNames;
|
|
369
|
-
/** When true (default), show skeleton rows while loading; when false, show "Loading signers..." text. */
|
|
370
|
-
useSkeleton?: boolean;
|
|
371
|
-
/** Custom list render (headless) */
|
|
372
|
-
renderList?: (props: {
|
|
373
|
-
signers: SignerData[];
|
|
374
|
-
selectedSigner: SignerData | null;
|
|
375
|
-
onSelect: (signer: SignerData) => void;
|
|
376
|
-
isLoading: boolean;
|
|
377
|
-
getSignerDisplayName: (s: SignerData) => string;
|
|
378
|
-
getSignerTypeLabel: (type: string) => string;
|
|
379
|
-
getSignerUniqueId: (s: SignerData) => string;
|
|
380
|
-
}) => React.ReactNode;
|
|
381
|
-
/** Children render props */
|
|
382
|
-
children?: (props: {
|
|
383
|
-
signers: SignerData[];
|
|
384
|
-
selectedSigner: SignerData | null;
|
|
385
|
-
onSignerSelect: (signer: SignerData) => void;
|
|
386
|
-
isLoading: boolean;
|
|
387
|
-
}) => React.ReactNode;
|
|
388
|
-
}
|
|
389
|
-
declare function SignerSelector({ selectedWalletId, availableSigners, selectedSigner, isLoadingSigners, onSignerSelect, className, classNames, useSkeleton, renderList, children, }: SignerSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
390
|
-
|
|
391
|
-
interface DelegatedKeySelectorClassNames {
|
|
392
|
-
root?: string;
|
|
393
|
-
trigger?: string;
|
|
394
|
-
content?: string;
|
|
395
|
-
item?: string;
|
|
396
|
-
message?: string;
|
|
397
|
-
skeleton?: string;
|
|
398
|
-
loading?: string;
|
|
399
|
-
}
|
|
400
|
-
interface DelegatedKeySelectorProps {
|
|
401
|
-
walletId: string;
|
|
402
|
-
value?: string;
|
|
403
|
-
onChange?: (delegatedKeyId: string, key: DelegatedKeyData | null) => void;
|
|
404
|
-
filterActive?: boolean;
|
|
405
|
-
className?: string;
|
|
406
|
-
classNames?: DelegatedKeySelectorClassNames;
|
|
407
|
-
/** When true (default), show skeleton trigger while loading; when false, show "Loading delegated keys..." text. */
|
|
408
|
-
useSkeleton?: boolean;
|
|
409
|
-
placeholder?: string;
|
|
410
|
-
children?: (props: {
|
|
411
|
-
keys: DelegatedKeyData[];
|
|
412
|
-
selectedKeyId: string | undefined;
|
|
413
|
-
onSelect: (key: DelegatedKeyData) => void;
|
|
414
|
-
isLoading: boolean;
|
|
415
|
-
error: string | null;
|
|
416
|
-
refresh: () => Promise<void>;
|
|
417
|
-
}) => React.ReactNode;
|
|
418
|
-
}
|
|
419
|
-
declare function DelegatedKeySelector(props: DelegatedKeySelectorProps): react_jsx_runtime.JSX.Element;
|
|
420
|
-
|
|
421
|
-
interface MessageSigningFormClassNames {
|
|
422
|
-
root?: string;
|
|
423
|
-
header?: string;
|
|
424
|
-
title?: string;
|
|
425
|
-
description?: string;
|
|
426
|
-
context?: string;
|
|
427
|
-
label?: string;
|
|
428
|
-
textarea?: string;
|
|
429
|
-
charCount?: string;
|
|
430
|
-
button?: string;
|
|
431
|
-
resetButton?: string;
|
|
432
|
-
result?: string;
|
|
433
|
-
resultSuccess?: string;
|
|
434
|
-
resultError?: string;
|
|
435
|
-
resultPre?: string;
|
|
436
|
-
}
|
|
437
|
-
interface MessageSigningFormProps {
|
|
438
|
-
/** Optional: override token (default: from useCilantroAuth) */
|
|
439
|
-
token?: string | null;
|
|
440
|
-
/** Optional: override wallet/signer (default: from useSignerSelection) */
|
|
441
|
-
selectedWalletId?: string;
|
|
442
|
-
selectedSigner?: SignerData | null;
|
|
443
|
-
signingMethod?: SigningMethod | null;
|
|
444
|
-
/** Optional: wallet-adapter sign message (when signingMethod === "wallet-adapter") */
|
|
445
|
-
walletAdapterSignMessage?: (message: Uint8Array) => Promise<Uint8Array>;
|
|
446
|
-
walletAdapterPublicKey?: string | null;
|
|
447
|
-
/** Root class */
|
|
448
|
-
className?: string;
|
|
449
|
-
/** Override class names for sub-elements */
|
|
450
|
-
classNames?: MessageSigningFormClassNames;
|
|
451
|
-
/** Show wallet/signer context above the form (default: true when wallet/signer selected) */
|
|
452
|
-
showContext?: boolean;
|
|
453
|
-
/** Show character count below textarea (default: false) */
|
|
454
|
-
showCharCount?: boolean;
|
|
455
|
-
/** Headless: render form content */
|
|
456
|
-
children?: (props: {
|
|
457
|
-
messageText: string;
|
|
458
|
-
setMessageText: (text: string) => void;
|
|
459
|
-
signResultState: ActionState;
|
|
460
|
-
isSigning: boolean;
|
|
461
|
-
handleSign: () => Promise<void>;
|
|
462
|
-
reset: () => void;
|
|
463
|
-
}) => React.ReactNode;
|
|
464
|
-
}
|
|
465
|
-
declare function MessageSigningForm({ token: tokenOverride, selectedWalletId: walletIdOverride, selectedSigner: signerOverride, signingMethod: methodOverride, walletAdapterSignMessage, walletAdapterPublicKey, className, classNames, showContext, showCharCount, children, }: MessageSigningFormProps): react_jsx_runtime.JSX.Element;
|
|
466
|
-
|
|
467
|
-
interface TransactionSigningFormClassNames {
|
|
468
|
-
root?: string;
|
|
469
|
-
header?: string;
|
|
470
|
-
title?: string;
|
|
471
|
-
description?: string;
|
|
472
|
-
context?: string;
|
|
473
|
-
button?: string;
|
|
474
|
-
result?: string;
|
|
475
|
-
resultSuccess?: string;
|
|
476
|
-
resultError?: string;
|
|
477
|
-
resultPre?: string;
|
|
478
|
-
}
|
|
479
|
-
interface TransactionSigningFormProps {
|
|
480
|
-
token?: string | null;
|
|
481
|
-
selectedWalletId?: string;
|
|
482
|
-
selectedSigner?: SignerData | null;
|
|
483
|
-
signingMethod?: SigningMethod | null;
|
|
484
|
-
walletAdapterSignTransaction?: (tx: Transaction) => Promise<Transaction>;
|
|
485
|
-
walletAdapterPublicKey?: string | null;
|
|
486
|
-
connection?: {
|
|
487
|
-
sendRawTransaction: (buf: Buffer) => Promise<string>;
|
|
488
|
-
getLatestBlockhash: () => Promise<{
|
|
489
|
-
blockhash: string;
|
|
490
|
-
lastValidBlockHeight: number;
|
|
491
|
-
}>;
|
|
492
|
-
confirmTransaction: (opts: {
|
|
493
|
-
signature: string;
|
|
494
|
-
blockhash: string;
|
|
495
|
-
lastValidBlockHeight: number;
|
|
496
|
-
}) => Promise<void>;
|
|
497
|
-
} | null;
|
|
498
|
-
className?: string;
|
|
499
|
-
classNames?: TransactionSigningFormClassNames;
|
|
500
|
-
/** Show wallet/signer context above the form (default: true when wallet/signer selected) */
|
|
501
|
-
showContext?: boolean;
|
|
502
|
-
/** Headless: render content; consumer builds transaction and calls signTransaction(tx) / signAndSendTransaction(tx) */
|
|
503
|
-
children?: (props: {
|
|
504
|
-
transactionResultState: ActionState;
|
|
505
|
-
isSigningTransaction: boolean;
|
|
506
|
-
isSendingTransaction: boolean;
|
|
507
|
-
signTransaction: (transaction: Transaction) => Promise<void>;
|
|
508
|
-
signAndSendTransaction: (transaction: Transaction) => Promise<void>;
|
|
509
|
-
reset: () => void;
|
|
510
|
-
}) => React.ReactNode;
|
|
248
|
+
interface UseSendTransactionResult {
|
|
249
|
+
sendSOL: (params: {
|
|
250
|
+
recipientAddress: string;
|
|
251
|
+
amountLamports: number;
|
|
252
|
+
}) => Promise<SubmitTransactionResult>;
|
|
253
|
+
sendSPL: (params: {
|
|
254
|
+
mintAddress: string;
|
|
255
|
+
recipientAddress: string;
|
|
256
|
+
amount: number;
|
|
257
|
+
}) => Promise<SubmitTransactionResult>;
|
|
258
|
+
isPending: boolean;
|
|
259
|
+
error: string | null;
|
|
511
260
|
}
|
|
512
|
-
declare function
|
|
261
|
+
declare function useSendTransaction(walletId: string | undefined, _signerId?: string, _signerType?: SignerType$2): UseSendTransactionResult;
|
|
513
262
|
|
|
514
263
|
interface LoginFormClassNames {
|
|
515
264
|
root?: string;
|
|
@@ -525,8 +274,10 @@ interface LoginFormClassNames {
|
|
|
525
274
|
interface LoginFormProps {
|
|
526
275
|
className?: string;
|
|
527
276
|
classNames?: LoginFormClassNames;
|
|
277
|
+
style?: React.CSSProperties;
|
|
528
278
|
onSuccess?: () => void;
|
|
529
|
-
onError?: (error:
|
|
279
|
+
onError?: (error: Error) => void;
|
|
280
|
+
rememberMe?: boolean;
|
|
530
281
|
/** Override submit button label */
|
|
531
282
|
submitLabel?: string;
|
|
532
283
|
/** Override title */
|
|
@@ -536,78 +287,15 @@ interface LoginFormProps {
|
|
|
536
287
|
/** Render "Create account" link (e.g. to switch to register). Shown below submit. */
|
|
537
288
|
renderSwitchToRegister?: () => React.ReactNode;
|
|
538
289
|
}
|
|
539
|
-
declare function LoginForm({ className, classNames, onSuccess, onError, submitLabel, title, description, renderSwitchToRegister, }: LoginFormProps): react_jsx_runtime.JSX.Element;
|
|
290
|
+
declare function LoginForm({ className, classNames, style, onSuccess, onError, submitLabel, title, description, renderSwitchToRegister, }: LoginFormProps): react_jsx_runtime.JSX.Element;
|
|
540
291
|
|
|
541
|
-
interface
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
title?: string;
|
|
545
|
-
description?: string;
|
|
546
|
-
form?: string;
|
|
547
|
-
label?: string;
|
|
548
|
-
input?: string;
|
|
549
|
-
submitButton?: string;
|
|
550
|
-
error?: string;
|
|
551
|
-
}
|
|
552
|
-
interface RegisterFormProps {
|
|
292
|
+
interface LogoutButtonProps {
|
|
293
|
+
onLogout?: () => void;
|
|
294
|
+
confirmBeforeLogout?: boolean;
|
|
553
295
|
className?: string;
|
|
554
|
-
|
|
555
|
-
onSuccess?: () => void;
|
|
556
|
-
onError?: (error: string) => void;
|
|
557
|
-
/** Override submit button label */
|
|
558
|
-
submitLabel?: string;
|
|
559
|
-
/** Override title */
|
|
560
|
-
title?: string;
|
|
561
|
-
/** Override description */
|
|
562
|
-
description?: string;
|
|
563
|
-
/** Default is true (user is active after registration) */
|
|
564
|
-
isActive?: boolean;
|
|
565
|
-
/** Render "Already have an account? Sign in" link. Shown below submit. */
|
|
566
|
-
renderSwitchToLogin?: () => React.ReactNode;
|
|
567
|
-
}
|
|
568
|
-
declare function RegisterForm({ className, classNames, onSuccess, onError, submitLabel, title, description, isActive, renderSwitchToLogin, }: RegisterFormProps): react_jsx_runtime.JSX.Element;
|
|
569
|
-
|
|
570
|
-
type AuthFormMode = "login" | "register";
|
|
571
|
-
interface AuthFormClassNames {
|
|
572
|
-
root?: string;
|
|
573
|
-
header?: string;
|
|
574
|
-
title?: string;
|
|
575
|
-
description?: string;
|
|
576
|
-
form?: string;
|
|
577
|
-
label?: string;
|
|
578
|
-
input?: string;
|
|
579
|
-
submitButton?: string;
|
|
580
|
-
toggle?: string;
|
|
581
|
-
toggleLink?: string;
|
|
582
|
-
error?: string;
|
|
296
|
+
children?: ReactNode;
|
|
583
297
|
}
|
|
584
|
-
|
|
585
|
-
/** Initial mode: login or register */
|
|
586
|
-
defaultMode?: AuthFormMode;
|
|
587
|
-
className?: string;
|
|
588
|
-
classNames?: AuthFormClassNames;
|
|
589
|
-
onSuccess?: () => void;
|
|
590
|
-
onError?: (error: string) => void;
|
|
591
|
-
/** Login: submit button label */
|
|
592
|
-
loginSubmitLabel?: string;
|
|
593
|
-
/** Register: submit button label */
|
|
594
|
-
registerSubmitLabel?: string;
|
|
595
|
-
/** Login: title */
|
|
596
|
-
loginTitle?: string;
|
|
597
|
-
/** Register: title */
|
|
598
|
-
registerTitle?: string;
|
|
599
|
-
/** Login: description */
|
|
600
|
-
loginDescription?: string;
|
|
601
|
-
/** Register: description */
|
|
602
|
-
registerDescription?: string;
|
|
603
|
-
/** Text for "switch to register" link */
|
|
604
|
-
switchToRegisterText?: string;
|
|
605
|
-
/** Text for "switch to login" link */
|
|
606
|
-
switchToLoginText?: string;
|
|
607
|
-
/** Default is true (user is active after registration) */
|
|
608
|
-
isActive?: boolean;
|
|
609
|
-
}
|
|
610
|
-
declare function AuthForm({ defaultMode, className, classNames, onSuccess, onError, loginSubmitLabel, registerSubmitLabel, loginTitle, registerTitle, loginDescription, registerDescription, switchToRegisterText, switchToLoginText, isActive, }: AuthFormProps): react_jsx_runtime.JSX.Element;
|
|
298
|
+
declare function LogoutButton({ onLogout, confirmBeforeLogout, className, children, }: LogoutButtonProps): react_jsx_runtime.JSX.Element;
|
|
611
299
|
|
|
612
300
|
interface AuthGuardClassNames {
|
|
613
301
|
root?: string;
|
|
@@ -619,6 +307,8 @@ interface AuthGuardProps {
|
|
|
619
307
|
children: ReactNode;
|
|
620
308
|
/** Shown when not authenticated. Default: <LoginForm /> */
|
|
621
309
|
fallback?: ReactNode;
|
|
310
|
+
/** If using a router, redirect to this path when not authenticated (consumer can pass fallback={<Navigate to={redirectTo} />}) */
|
|
311
|
+
redirectTo?: string;
|
|
622
312
|
/** Root class when showing fallback */
|
|
623
313
|
className?: string;
|
|
624
314
|
classNames?: AuthGuardClassNames;
|
|
@@ -629,34 +319,34 @@ interface AuthGuardProps {
|
|
|
629
319
|
}
|
|
630
320
|
/**
|
|
631
321
|
* Wraps content and shows fallback (e.g. LoginForm) when the user is not authenticated.
|
|
632
|
-
* Use inside
|
|
322
|
+
* Use inside CilantroProvider.
|
|
633
323
|
*/
|
|
634
|
-
declare function AuthGuard({ children, fallback, className, classNames, showFallback, useSkeleton, }: AuthGuardProps): react_jsx_runtime.JSX.Element | null;
|
|
324
|
+
declare function AuthGuard({ children, fallback, redirectTo, className, classNames, showFallback, useSkeleton, }: AuthGuardProps): react_jsx_runtime.JSX.Element | null;
|
|
635
325
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
326
|
+
interface CreateEmailSignerFormProps {
|
|
327
|
+
walletId: string;
|
|
328
|
+
onCreated?: (signer: SignerInfo) => void;
|
|
329
|
+
onError?: (error: Error) => void;
|
|
330
|
+
className?: string;
|
|
331
|
+
}
|
|
332
|
+
declare function CreateEmailSignerForm({ walletId, onCreated, onError, className, }: CreateEmailSignerFormProps): react_jsx_runtime.JSX.Element;
|
|
333
|
+
|
|
334
|
+
interface CreatePhoneSignerFormProps {
|
|
335
|
+
walletId: string;
|
|
336
|
+
onCreated?: (signer: SignerInfo) => void;
|
|
337
|
+
onError?: (error: Error) => void;
|
|
338
|
+
className?: string;
|
|
646
339
|
}
|
|
647
|
-
|
|
340
|
+
declare function CreatePhoneSignerForm({ walletId, onCreated, onError, className, }: CreatePhoneSignerFormProps): react_jsx_runtime.JSX.Element;
|
|
341
|
+
|
|
342
|
+
interface AddPasskeyButtonProps {
|
|
648
343
|
walletId: string;
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
onSuccess?: () => void;
|
|
652
|
-
onCancel?: () => void;
|
|
653
|
-
onError?: (error: string) => void;
|
|
344
|
+
onRegistered?: (signer: SignerInfo) => void;
|
|
345
|
+
onError?: (error: Error) => void;
|
|
654
346
|
className?: string;
|
|
655
|
-
|
|
656
|
-
/** When true, render as a dialog. When false, render inline. */
|
|
657
|
-
asDialog?: boolean;
|
|
347
|
+
children?: ReactNode;
|
|
658
348
|
}
|
|
659
|
-
declare function
|
|
349
|
+
declare function AddPasskeyButton({ walletId, onRegistered, onError, className, children, }: AddPasskeyButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
660
350
|
|
|
661
351
|
interface SignerListClassNames {
|
|
662
352
|
root?: string;
|
|
@@ -670,13 +360,11 @@ interface SignerListClassNames {
|
|
|
670
360
|
}
|
|
671
361
|
interface SignerListProps {
|
|
672
362
|
walletId: string;
|
|
363
|
+
onRevoke?: (signerId: string) => void;
|
|
673
364
|
className?: string;
|
|
674
365
|
classNames?: SignerListClassNames;
|
|
675
|
-
/** Callback when a signer is added (e.g. to refresh parent state) */
|
|
676
366
|
onSignerAdded?: () => void;
|
|
677
|
-
/** When true (default), show skeleton rows while loading; when false, show "Loading signers..." text. */
|
|
678
367
|
useSkeleton?: boolean;
|
|
679
|
-
/** Custom render for the list of signers */
|
|
680
368
|
children?: (props: {
|
|
681
369
|
signers: SignerData[];
|
|
682
370
|
isLoading: boolean;
|
|
@@ -685,30 +373,7 @@ interface SignerListProps {
|
|
|
685
373
|
openAddSigner: () => void;
|
|
686
374
|
}) => React.ReactNode;
|
|
687
375
|
}
|
|
688
|
-
declare function SignerList({ walletId, className, classNames, onSignerAdded, useSkeleton, children, }: SignerListProps): react_jsx_runtime.JSX.Element;
|
|
689
|
-
|
|
690
|
-
interface SkeletonProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
691
|
-
}
|
|
692
|
-
declare const Skeleton: React$1.ForwardRefExoticComponent<SkeletonProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
693
|
-
|
|
694
|
-
type Theme = "light" | "dark" | "system";
|
|
695
|
-
type ResolvedTheme = "light" | "dark";
|
|
696
|
-
interface ThemeProviderProps {
|
|
697
|
-
/** Current theme: "light", "dark", or "system" (follows prefers-color-scheme). */
|
|
698
|
-
theme?: Theme;
|
|
699
|
-
/** Default theme when theme is "system" or for initial render. */
|
|
700
|
-
defaultTheme?: ResolvedTheme;
|
|
701
|
-
/** Optional localStorage key for persisting theme when using "system". */
|
|
702
|
-
storageKey?: string;
|
|
703
|
-
/** Optional class for the wrapper div. */
|
|
704
|
-
className?: string;
|
|
705
|
-
children: React$1.ReactNode;
|
|
706
|
-
/** When true, inject the default theme CSS variables (light/dark). Your app must still use Tailwind. */
|
|
707
|
-
injectStyles?: boolean;
|
|
708
|
-
}
|
|
709
|
-
declare function ThemeProvider({ theme, defaultTheme, storageKey, className, children, injectStyles, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
710
|
-
|
|
711
|
-
declare function extractErrorMessage(error: unknown): string;
|
|
376
|
+
declare function SignerList({ walletId, onRevoke, className, classNames, onSignerAdded, useSkeleton, children, }: SignerListProps): react_jsx_runtime.JSX.Element;
|
|
712
377
|
|
|
713
378
|
declare function getSignerPublicKey(walletId: string, signer: SignerData, signerType: string, signerId: string): Promise<PublicKey>;
|
|
714
379
|
|
|
@@ -762,6 +427,293 @@ declare const SIGNER_TYPES: {
|
|
|
762
427
|
readonly EXTERNAL: "external";
|
|
763
428
|
readonly API_KEY: "apiKey";
|
|
764
429
|
};
|
|
765
|
-
type SignerType = (typeof SIGNER_TYPES)[keyof typeof SIGNER_TYPES];
|
|
430
|
+
type SignerType$1 = (typeof SIGNER_TYPES)[keyof typeof SIGNER_TYPES];
|
|
431
|
+
|
|
432
|
+
interface SignerSelectorClassNames {
|
|
433
|
+
root?: string;
|
|
434
|
+
list?: string;
|
|
435
|
+
item?: string;
|
|
436
|
+
message?: string;
|
|
437
|
+
skeleton?: string;
|
|
438
|
+
loading?: string;
|
|
439
|
+
}
|
|
440
|
+
/** Guide API: walletId + value + onChange(signerId, signerType) */
|
|
441
|
+
interface SignerSelectorProps {
|
|
442
|
+
walletId: string;
|
|
443
|
+
value?: string;
|
|
444
|
+
onChange: (signerId: string, signerType: SignerType$1) => void;
|
|
445
|
+
className?: string;
|
|
446
|
+
classNames?: SignerSelectorClassNames;
|
|
447
|
+
useSkeleton?: boolean;
|
|
448
|
+
/** Legacy: when provided with availableSigners/selectedSigner/onSignerSelect, use legacy API */
|
|
449
|
+
selectedWalletId?: string;
|
|
450
|
+
availableSigners?: SignerData[];
|
|
451
|
+
selectedSigner?: SignerData | null;
|
|
452
|
+
isLoadingSigners?: boolean;
|
|
453
|
+
onSignerSelect?: (signer: SignerData) => void;
|
|
454
|
+
renderList?: (props: {
|
|
455
|
+
signers: SignerData[];
|
|
456
|
+
selectedSigner: SignerData | null;
|
|
457
|
+
onSelect: (signer: SignerData) => void;
|
|
458
|
+
isLoading: boolean;
|
|
459
|
+
getSignerDisplayName: (s: SignerData) => string;
|
|
460
|
+
getSignerTypeLabel: (type: string) => string;
|
|
461
|
+
getSignerUniqueId: (s: SignerData) => string;
|
|
462
|
+
}) => React.ReactNode;
|
|
463
|
+
children?: (props: {
|
|
464
|
+
signers: SignerData[];
|
|
465
|
+
selectedSigner: SignerData | null;
|
|
466
|
+
onSignerSelect: (signer: SignerData) => void;
|
|
467
|
+
isLoading: boolean;
|
|
468
|
+
}) => React.ReactNode;
|
|
469
|
+
}
|
|
470
|
+
declare function SignerSelector({ walletId, value, onChange, className, classNames, useSkeleton, selectedWalletId, availableSigners: availableSignersProp, selectedSigner: selectedSignerProp, isLoadingSigners: isLoadingSignersProp, onSignerSelect, renderList, children, }: SignerSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
471
|
+
|
|
472
|
+
interface ConnectWalletButtonProps {
|
|
473
|
+
onConnect?: (publicKey: string, wallet: SolanaWallet) => void;
|
|
474
|
+
onDisconnect?: () => void;
|
|
475
|
+
className?: string;
|
|
476
|
+
children?: ReactNode;
|
|
477
|
+
}
|
|
478
|
+
declare function ConnectWalletButton({ onConnect, onDisconnect, className, children, }: ConnectWalletButtonProps): react_jsx_runtime.JSX.Element;
|
|
479
|
+
|
|
480
|
+
interface CreateWalletFormProps {
|
|
481
|
+
userId?: string;
|
|
482
|
+
onCreated?: (wallet: WalletControllerCreateResult) => void;
|
|
483
|
+
onError?: (error: Error) => void;
|
|
484
|
+
className?: string;
|
|
485
|
+
}
|
|
486
|
+
declare function CreateWalletForm({ userId, onCreated, onError, className, }: CreateWalletFormProps): react_jsx_runtime.JSX.Element;
|
|
487
|
+
|
|
488
|
+
interface WalletSelectorClassNames {
|
|
489
|
+
root?: string;
|
|
490
|
+
trigger?: string;
|
|
491
|
+
content?: string;
|
|
492
|
+
item?: string;
|
|
493
|
+
skeleton?: string;
|
|
494
|
+
loading?: string;
|
|
495
|
+
}
|
|
496
|
+
interface WalletSelectorProps {
|
|
497
|
+
value?: string;
|
|
498
|
+
onChange?: (walletId: string) => void;
|
|
499
|
+
onWalletChange?: (walletId: string, wallet: WalletData | null) => void;
|
|
500
|
+
className?: string;
|
|
501
|
+
classNames?: WalletSelectorClassNames;
|
|
502
|
+
useSkeleton?: boolean;
|
|
503
|
+
placeholder?: string;
|
|
504
|
+
renderTrigger?: (props: {
|
|
505
|
+
selectedWallet: WalletData | null;
|
|
506
|
+
wallets: WalletData[];
|
|
507
|
+
isLoading: boolean;
|
|
508
|
+
open: boolean;
|
|
509
|
+
setOpen: (open: boolean) => void;
|
|
510
|
+
}) => React.ReactNode;
|
|
511
|
+
renderList?: (props: {
|
|
512
|
+
wallets: WalletData[];
|
|
513
|
+
selectedWallet: WalletData | null;
|
|
514
|
+
onSelect: (wallet: WalletData) => void;
|
|
515
|
+
isLoading: boolean;
|
|
516
|
+
}) => React.ReactNode;
|
|
517
|
+
children?: (props: {
|
|
518
|
+
wallets: WalletData[];
|
|
519
|
+
selectedWallet: WalletData | null;
|
|
520
|
+
selectWallet: (walletId: string) => void;
|
|
521
|
+
isLoading: boolean;
|
|
522
|
+
refreshWallets: () => Promise<void>;
|
|
523
|
+
}) => React.ReactNode;
|
|
524
|
+
}
|
|
525
|
+
declare function WalletSelector(props: WalletSelectorProps): react_jsx_runtime.JSX.Element;
|
|
526
|
+
|
|
527
|
+
interface WalletAddressProps {
|
|
528
|
+
address: string;
|
|
529
|
+
short?: boolean;
|
|
530
|
+
copyable?: boolean;
|
|
531
|
+
className?: string;
|
|
532
|
+
}
|
|
533
|
+
declare function WalletAddress({ address, short, copyable, className, }: WalletAddressProps): react_jsx_runtime.JSX.Element;
|
|
534
|
+
|
|
535
|
+
interface WalletBalanceProps {
|
|
536
|
+
walletId: string;
|
|
537
|
+
showTokens?: boolean;
|
|
538
|
+
className?: string;
|
|
539
|
+
}
|
|
540
|
+
declare function WalletBalance({ walletId, showTokens, className, }: WalletBalanceProps): react_jsx_runtime.JSX.Element;
|
|
541
|
+
|
|
542
|
+
type SignerType = "email" | "phone" | "passkey" | "external";
|
|
543
|
+
interface SendSOLFormProps {
|
|
544
|
+
walletId: string;
|
|
545
|
+
signerId?: string;
|
|
546
|
+
signerType?: SignerType;
|
|
547
|
+
onSuccess?: (result: SubmitTransactionResult) => void;
|
|
548
|
+
onError?: (error: Error) => void;
|
|
549
|
+
className?: string;
|
|
550
|
+
}
|
|
551
|
+
declare function SendSOLForm({ walletId, signerId, signerType, onSuccess, onError, className, }: SendSOLFormProps): react_jsx_runtime.JSX.Element;
|
|
552
|
+
|
|
553
|
+
interface SendSPLFormProps {
|
|
554
|
+
walletId: string;
|
|
555
|
+
signerId?: string;
|
|
556
|
+
signerType?: SignerType$2;
|
|
557
|
+
mintAddress?: string;
|
|
558
|
+
onSuccess?: (result: SubmitTransactionResult) => void;
|
|
559
|
+
onError?: (error: Error) => void;
|
|
560
|
+
className?: string;
|
|
561
|
+
}
|
|
562
|
+
declare function SendSPLForm({ walletId, signerId, signerType, mintAddress: initialMint, onSuccess, onError, className, }: SendSPLFormProps): react_jsx_runtime.JSX.Element;
|
|
563
|
+
|
|
564
|
+
interface TransactionStatusProps {
|
|
565
|
+
signature: string;
|
|
566
|
+
cluster?: "mainnet-beta" | "devnet" | "testnet";
|
|
567
|
+
className?: string;
|
|
568
|
+
}
|
|
569
|
+
declare function TransactionStatus({ signature, cluster, className, }: TransactionStatusProps): react_jsx_runtime.JSX.Element;
|
|
570
|
+
|
|
571
|
+
interface TransactionHistoryProps {
|
|
572
|
+
walletId: string;
|
|
573
|
+
pageSize?: number;
|
|
574
|
+
className?: string;
|
|
575
|
+
}
|
|
576
|
+
declare function TransactionHistory({ walletId, pageSize, className, }: TransactionHistoryProps): react_jsx_runtime.JSX.Element;
|
|
577
|
+
|
|
578
|
+
interface WalletInfo extends WalletData {
|
|
579
|
+
}
|
|
580
|
+
interface CilantroConnectProps {
|
|
581
|
+
onConnect?: (wallet: WalletInfo, signers: SignerInfo[]) => void;
|
|
582
|
+
onDisconnect?: () => void;
|
|
583
|
+
className?: string;
|
|
584
|
+
}
|
|
585
|
+
declare function CilantroConnect({ onConnect, onDisconnect, className, }: CilantroConnectProps): react_jsx_runtime.JSX.Element;
|
|
586
|
+
|
|
587
|
+
interface LoadingOverlayProps {
|
|
588
|
+
isLoading: boolean;
|
|
589
|
+
message?: string;
|
|
590
|
+
children: ReactNode;
|
|
591
|
+
className?: string;
|
|
592
|
+
}
|
|
593
|
+
declare function LoadingOverlay({ isLoading, message, children, className, }: LoadingOverlayProps): react_jsx_runtime.JSX.Element;
|
|
594
|
+
|
|
595
|
+
interface ErrorBoundaryProps {
|
|
596
|
+
fallback?: ReactNode;
|
|
597
|
+
onRetry?: () => void;
|
|
598
|
+
children: ReactNode;
|
|
599
|
+
}
|
|
600
|
+
interface State {
|
|
601
|
+
hasError: boolean;
|
|
602
|
+
error: Error | null;
|
|
603
|
+
}
|
|
604
|
+
declare class ErrorBoundary extends Component<ErrorBoundaryProps, State> {
|
|
605
|
+
state: State;
|
|
606
|
+
static getDerivedStateFromError(error: Error): State;
|
|
607
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
608
|
+
handleRetry: () => void;
|
|
609
|
+
render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
interface SkeletonProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
613
|
+
}
|
|
614
|
+
declare const Skeleton: React$1.ForwardRefExoticComponent<SkeletonProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
615
|
+
|
|
616
|
+
type Theme = "light" | "dark" | "system";
|
|
617
|
+
type ResolvedTheme = "light" | "dark";
|
|
618
|
+
interface ThemeProviderProps {
|
|
619
|
+
/** Current theme: "light", "dark", or "system" (follows prefers-color-scheme). */
|
|
620
|
+
theme?: Theme;
|
|
621
|
+
/** Default theme when theme is "system" or for initial render. */
|
|
622
|
+
defaultTheme?: ResolvedTheme;
|
|
623
|
+
/** Optional localStorage key for persisting theme when using "system". */
|
|
624
|
+
storageKey?: string;
|
|
625
|
+
/** Optional class for the wrapper div. */
|
|
626
|
+
className?: string;
|
|
627
|
+
children: React$1.ReactNode;
|
|
628
|
+
/** When true, inject the default theme CSS variables (light/dark). Your app must still use Tailwind. */
|
|
629
|
+
injectStyles?: boolean;
|
|
630
|
+
}
|
|
631
|
+
declare function ThemeProvider({ theme, defaultTheme, storageKey, className, children, injectStyles, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Type Utilities - common types and utilities for SDK interactions
|
|
635
|
+
*/
|
|
636
|
+
type ActionState<T = unknown> = {
|
|
637
|
+
status: "idle" | "loading" | "success" | "error";
|
|
638
|
+
message?: string;
|
|
639
|
+
detail?: T;
|
|
640
|
+
};
|
|
641
|
+
interface ErrorResponse {
|
|
642
|
+
message?: string;
|
|
643
|
+
error?: string;
|
|
644
|
+
code?: string | number;
|
|
645
|
+
status?: number;
|
|
646
|
+
statusText?: string;
|
|
647
|
+
data?: unknown;
|
|
648
|
+
stack?: string;
|
|
649
|
+
type?: string;
|
|
650
|
+
}
|
|
651
|
+
type ApiResponse<T> = T | {
|
|
652
|
+
data: T;
|
|
653
|
+
} | {
|
|
654
|
+
success: boolean;
|
|
655
|
+
data: T;
|
|
656
|
+
};
|
|
657
|
+
declare function extractResponseData<T>(response: unknown): T | null;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Normalization at the boundary: map SDK DTOs to a consistent shape with id/address (and aliases).
|
|
661
|
+
* Use these when ingesting wallet/signer data from the SDK so consumers can rely on id and address.
|
|
662
|
+
*/
|
|
663
|
+
/** Normalized wallet shape: always has id and address. */
|
|
664
|
+
interface NormalizedWallet {
|
|
665
|
+
id: string;
|
|
666
|
+
address: string;
|
|
667
|
+
active?: boolean;
|
|
668
|
+
[key: string]: unknown;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Normalize a wallet DTO so that id and address are always present.
|
|
672
|
+
* Use at the boundary when loading wallets from the SDK.
|
|
673
|
+
* Accepts any object with optional walletId/id, walletAddress/address, isActive.
|
|
674
|
+
*/
|
|
675
|
+
declare function normalizeWallet(dto: Record<string, unknown>): NormalizedWallet;
|
|
676
|
+
|
|
677
|
+
declare function extractErrorMessage(error: unknown): string;
|
|
678
|
+
declare function isAuthError(error: unknown): boolean;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Check if a JWT is expired using the payload `exp` claim.
|
|
682
|
+
* @param token - JWT string (assumes 3 segments separated by dots).
|
|
683
|
+
* @param bufferSeconds - Optional buffer in seconds; if exp is within this many seconds of now, treat as expired (default 60).
|
|
684
|
+
* @returns true if token is expired or invalid/not a JWT.
|
|
685
|
+
*/
|
|
686
|
+
declare function isJwtExpired(token: string, bufferSeconds?: number): boolean;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Adapter to use @solana/web3.js Connection for sign-and-send (advanced usage).
|
|
690
|
+
* Pass the result as the connection prop so you don't need type assertions.
|
|
691
|
+
*/
|
|
692
|
+
|
|
693
|
+
/** Connection shape expected for sign-and-send (advanced usage). */
|
|
694
|
+
interface SignAndSendConnectionAdapter {
|
|
695
|
+
sendRawTransaction: (buf: Buffer) => Promise<string>;
|
|
696
|
+
getLatestBlockhash: () => Promise<{
|
|
697
|
+
blockhash: string;
|
|
698
|
+
lastValidBlockHeight: number;
|
|
699
|
+
}>;
|
|
700
|
+
confirmTransaction: (opts: {
|
|
701
|
+
signature: string;
|
|
702
|
+
blockhash: string;
|
|
703
|
+
lastValidBlockHeight: number;
|
|
704
|
+
}) => Promise<void>;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Wrap a @solana/web3.js Connection for sign-and-send (advanced usage).
|
|
708
|
+
* Use when you have a Solana Connection and need the adapter shape without type assertions.
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* import { Connection } from '@solana/web3.js';
|
|
712
|
+
* import { adaptSolanaConnection } from 'cilantro-react';
|
|
713
|
+
*
|
|
714
|
+
* const connection = new Connection(rpcUrl);
|
|
715
|
+
* const adapter = adaptSolanaConnection(connection);
|
|
716
|
+
*/
|
|
717
|
+
declare function adaptSolanaConnection(connection: Connection): SignAndSendConnectionAdapter;
|
|
766
718
|
|
|
767
|
-
export { type ActionState,
|
|
719
|
+
export { type ActionState, AddPasskeyButton, type AddPasskeyButtonProps, type ApiResponse, AuthGuard, type AuthGuardClassNames, type AuthGuardProps, type CilantroAuthContextType, type CilantroConfig, CilantroConnect, type CilantroConnectProps, CilantroContextProvider, type CilantroContextValue, CilantroProvider, type CilantroProviderProps, ConnectWalletButton, type ConnectWalletButtonProps, CreateEmailSignerForm, type CreateEmailSignerFormProps, CreatePhoneSignerForm, type CreatePhoneSignerFormProps, CreateWalletForm, type CreateWalletFormProps, type DeviceKeyStorage, ErrorBoundary, type ErrorBoundaryProps, type ErrorResponse, LoadingOverlay, type LoadingOverlayProps, LoginForm, type LoginFormClassNames, type LoginFormProps, LogoutButton, type LogoutButtonProps, type NormalizedWallet, type ResolvedTheme, SIGNER_TYPES, SendSOLForm, type SendSOLFormProps, type SignerType as SendSOLSignerType, SendSPLForm, type SendSPLFormProps, type SignerType$2 as SendTransactionSignerType, type SignAndSendConnection, type SignAndSendConnectionAdapter, type SignAndSendResult, type SignMessageResult, type SignerData, SignerList, type SignerListClassNames, type SignerListProps, SignerSelector, type SignerSelectorClassNames, type SignerSelectorProps, type SignerType$1 as SignerType, Skeleton, type SolanaWallet, type SubmitTransactionDataDto, type SubmitTransactionResult, type Theme, ThemeProvider, type ThemeProviderProps, TransactionHistory, type TransactionHistoryProps, TransactionStatus, type TransactionStatusProps, type UseAuthResult, type UseCilantroConfigResult, type UseExternalWalletResult, type UsePasskeyResult, type UseSendTransactionResult, type UseSignersOptions, type UseSignersResult, type UseWalletResult, type User, WalletAddress, type WalletAddressProps, WalletBalance, type WalletBalanceProps, type WalletContextType, type WalletData, type WalletDataDto$1 as WalletDataDto, type WalletDataDto as WalletDataDtoFromHook, type WalletData as WalletDataFromHook, type WalletInfo, WalletSelector, type WalletSelectorClassNames, type WalletSelectorProps, adaptSolanaConnection, extractErrorMessage, extractResponseData, getSignerPublicKey, getWalletData, isAuthError, isJwtExpired, normalizeSigner, normalizeWallet, signAndSendTransactionWithSigner, signMessageWithSigner, signTransactionWithSigner, useAuth, useCilantroAuth, useCilantroConfig, useCilantroContext, useExternalWallet, usePasskey, useSendTransaction, useSigners, useWallet, useWallets };
|