cilantro-react 0.1.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.
- package/README.md +647 -0
- package/dist/index.d.mts +616 -0
- package/dist/index.d.ts +616 -0
- package/dist/index.js +2867 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2837 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SignerInfo } from 'cilantro-sdk/helpers';
|
|
4
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
5
|
+
|
|
6
|
+
interface CilantroProviderProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
platformApiKey: string;
|
|
9
|
+
apiUrl?: string;
|
|
10
|
+
/** localStorage key for JWT (default: cilantro_jwt) */
|
|
11
|
+
jwtStorageKey?: string;
|
|
12
|
+
/** localStorage key for selected wallet id (default: cilantro_selected_wallet_id) */
|
|
13
|
+
walletStorageKey?: string;
|
|
14
|
+
onLoginSuccess?: () => void;
|
|
15
|
+
onLogout?: () => void;
|
|
16
|
+
onRegisterSuccess?: () => void;
|
|
17
|
+
}
|
|
18
|
+
declare function CilantroProvider({ children, platformApiKey, apiUrl, jwtStorageKey, walletStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, }: CilantroProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
interface User {
|
|
21
|
+
username?: string;
|
|
22
|
+
email?: string;
|
|
23
|
+
userType?: string;
|
|
24
|
+
}
|
|
25
|
+
interface CilantroAuthContextType {
|
|
26
|
+
user: User | null;
|
|
27
|
+
token: string | null;
|
|
28
|
+
isAuthenticated: boolean;
|
|
29
|
+
login: (usernameOrEmail: string, password: string) => Promise<void>;
|
|
30
|
+
register: (username: string, email: string, password: string, isActive?: boolean) => Promise<void>;
|
|
31
|
+
logout: () => void;
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface CilantroAuthProviderProps {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
platformApiKey: string;
|
|
37
|
+
apiUrl?: string;
|
|
38
|
+
jwtStorageKey?: string;
|
|
39
|
+
onLoginSuccess?: () => void;
|
|
40
|
+
onLogout?: () => void;
|
|
41
|
+
onRegisterSuccess?: () => void;
|
|
42
|
+
}
|
|
43
|
+
declare function CilantroAuthProvider({ children, platformApiKey, apiUrl, jwtStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, }: CilantroAuthProviderProps): react_jsx_runtime.JSX.Element;
|
|
44
|
+
declare function useCilantroAuth(): CilantroAuthContextType;
|
|
45
|
+
|
|
46
|
+
interface WalletData {
|
|
47
|
+
id: string;
|
|
48
|
+
walletId: string;
|
|
49
|
+
walletName?: string;
|
|
50
|
+
address?: string;
|
|
51
|
+
walletAddress?: string;
|
|
52
|
+
chain?: string;
|
|
53
|
+
active?: boolean;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
interface WalletContextType {
|
|
57
|
+
selectedWallet: WalletData | null;
|
|
58
|
+
wallets: WalletData[];
|
|
59
|
+
selectWallet: (walletId: string) => void;
|
|
60
|
+
refreshWallets: () => Promise<void>;
|
|
61
|
+
isLoading: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface WalletProviderProps {
|
|
64
|
+
children: ReactNode;
|
|
65
|
+
storageKey?: string;
|
|
66
|
+
}
|
|
67
|
+
declare function WalletProvider({ children, storageKey }: WalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
declare function useWallets(): WalletContextType;
|
|
69
|
+
|
|
70
|
+
interface SignerData extends Omit<SignerInfo, "signerId"> {
|
|
71
|
+
id: string;
|
|
72
|
+
signerId: string;
|
|
73
|
+
signerType?: string;
|
|
74
|
+
signerPubkey?: string;
|
|
75
|
+
signerConfig?: {
|
|
76
|
+
email?: string;
|
|
77
|
+
phone?: string;
|
|
78
|
+
credentialId?: string;
|
|
79
|
+
};
|
|
80
|
+
deviceIdentities?: unknown[];
|
|
81
|
+
credentialId?: string;
|
|
82
|
+
authId?: string;
|
|
83
|
+
signerCategory?: "onchain" | "authenticationsigner";
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface UseSignersOptions {
|
|
88
|
+
/** Wallet ID to load signers for. If not provided, uses selectedWallet?.id from context (call useWallets() in same component). */
|
|
89
|
+
walletId?: string | null;
|
|
90
|
+
}
|
|
91
|
+
interface UseSignersResult {
|
|
92
|
+
signers: SignerData[];
|
|
93
|
+
isLoading: boolean;
|
|
94
|
+
error: string | null;
|
|
95
|
+
refresh: () => Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
declare function useSigners(options?: UseSignersOptions): UseSignersResult;
|
|
98
|
+
|
|
99
|
+
type SigningMethod = "wallet-adapter" | "sdk-signer";
|
|
100
|
+
interface UseSignerSelectionOptions {
|
|
101
|
+
/** Override wallet ID; if not set, uses selected wallet from WalletProvider */
|
|
102
|
+
walletId?: string | null;
|
|
103
|
+
/** Current signing method */
|
|
104
|
+
signingMethod?: SigningMethod | null;
|
|
105
|
+
}
|
|
106
|
+
interface UseSignerSelectionResult {
|
|
107
|
+
selectedWalletId: string;
|
|
108
|
+
setSelectedWalletId: (id: string) => void;
|
|
109
|
+
availableSigners: SignerData[];
|
|
110
|
+
selectedSigner: SignerData | null;
|
|
111
|
+
setSelectedSigner: (signer: SignerData | null) => void;
|
|
112
|
+
isLoadingSigners: boolean;
|
|
113
|
+
reset: () => void;
|
|
114
|
+
}
|
|
115
|
+
declare function useSignerSelection(options?: UseSignerSelectionOptions): UseSignerSelectionResult;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Type Utilities - common types and utilities for SDK interactions
|
|
119
|
+
*/
|
|
120
|
+
type ActionState<T = unknown> = {
|
|
121
|
+
status: "idle" | "loading" | "success" | "error";
|
|
122
|
+
message?: string;
|
|
123
|
+
detail?: T;
|
|
124
|
+
};
|
|
125
|
+
interface ErrorResponse {
|
|
126
|
+
message?: string;
|
|
127
|
+
error?: string;
|
|
128
|
+
code?: string | number;
|
|
129
|
+
status?: number;
|
|
130
|
+
statusText?: string;
|
|
131
|
+
data?: unknown;
|
|
132
|
+
stack?: string;
|
|
133
|
+
type?: string;
|
|
134
|
+
}
|
|
135
|
+
type ApiResponse<T> = T | {
|
|
136
|
+
data: T;
|
|
137
|
+
} | {
|
|
138
|
+
success: boolean;
|
|
139
|
+
data: T;
|
|
140
|
+
};
|
|
141
|
+
declare function extractResponseData<T>(response: unknown): T | null;
|
|
142
|
+
|
|
143
|
+
interface UseMessageSigningOptions {
|
|
144
|
+
token: string | null;
|
|
145
|
+
signingMethod: SigningMethod | null;
|
|
146
|
+
selectedSigner: SignerData | null;
|
|
147
|
+
selectedWalletId: string;
|
|
148
|
+
/** Optional: callback when using wallet-adapter; signMessage(encodedMessage) => signature bytes */
|
|
149
|
+
walletAdapterSignMessage?: (message: Uint8Array) => Promise<Uint8Array>;
|
|
150
|
+
/** Optional: public key when using wallet-adapter (for result) */
|
|
151
|
+
walletAdapterPublicKey?: string | null;
|
|
152
|
+
}
|
|
153
|
+
interface UseMessageSigningResult {
|
|
154
|
+
messageText: string;
|
|
155
|
+
setMessageText: (text: string) => void;
|
|
156
|
+
signResultState: ActionState;
|
|
157
|
+
isSigning: boolean;
|
|
158
|
+
handleSign: () => Promise<void>;
|
|
159
|
+
reset: () => void;
|
|
160
|
+
}
|
|
161
|
+
declare function useMessageSigning(options: UseMessageSigningOptions): UseMessageSigningResult;
|
|
162
|
+
|
|
163
|
+
interface UseTransactionSigningOptions {
|
|
164
|
+
token: string | null;
|
|
165
|
+
signingMethod: SigningMethod | null;
|
|
166
|
+
selectedSigner: SignerData | null;
|
|
167
|
+
selectedWalletId: string;
|
|
168
|
+
/** Optional: wallet-adapter signTransaction(transaction) => signed transaction */
|
|
169
|
+
walletAdapterSignTransaction?: (transaction: Transaction) => Promise<Transaction>;
|
|
170
|
+
/** Optional: wallet-adapter public key (for building/sending) */
|
|
171
|
+
walletAdapterPublicKey?: string | null;
|
|
172
|
+
/** Optional: connection for sending (e.g. from @solana/web3.js). Used for wallet-adapter send. */
|
|
173
|
+
connection?: {
|
|
174
|
+
sendRawTransaction: (buf: Buffer) => Promise<string>;
|
|
175
|
+
getLatestBlockhash: () => Promise<{
|
|
176
|
+
blockhash: string;
|
|
177
|
+
lastValidBlockHeight: number;
|
|
178
|
+
}>;
|
|
179
|
+
confirmTransaction: (opts: {
|
|
180
|
+
signature: string;
|
|
181
|
+
blockhash: string;
|
|
182
|
+
lastValidBlockHeight: number;
|
|
183
|
+
}) => Promise<void>;
|
|
184
|
+
} | null;
|
|
185
|
+
}
|
|
186
|
+
interface UseTransactionSigningResult {
|
|
187
|
+
transactionResultState: ActionState;
|
|
188
|
+
isSigningTransaction: boolean;
|
|
189
|
+
isSendingTransaction: boolean;
|
|
190
|
+
signTransaction: (transaction: Transaction) => Promise<void>;
|
|
191
|
+
signAndSendTransaction: (transaction: Transaction) => Promise<void>;
|
|
192
|
+
reset: () => void;
|
|
193
|
+
}
|
|
194
|
+
declare function useTransactionSigning(options: UseTransactionSigningOptions): UseTransactionSigningResult;
|
|
195
|
+
|
|
196
|
+
interface WalletSelectorClassNames {
|
|
197
|
+
root?: string;
|
|
198
|
+
trigger?: string;
|
|
199
|
+
content?: string;
|
|
200
|
+
item?: string;
|
|
201
|
+
}
|
|
202
|
+
interface WalletSelectorProps {
|
|
203
|
+
value?: string;
|
|
204
|
+
onWalletChange?: (walletId: string, wallet: WalletData | null) => void;
|
|
205
|
+
className?: string;
|
|
206
|
+
classNames?: WalletSelectorClassNames;
|
|
207
|
+
placeholder?: string;
|
|
208
|
+
renderTrigger?: (props: {
|
|
209
|
+
selectedWallet: WalletData | null;
|
|
210
|
+
wallets: WalletData[];
|
|
211
|
+
isLoading: boolean;
|
|
212
|
+
open: boolean;
|
|
213
|
+
setOpen: (open: boolean) => void;
|
|
214
|
+
}) => React.ReactNode;
|
|
215
|
+
renderList?: (props: {
|
|
216
|
+
wallets: WalletData[];
|
|
217
|
+
selectedWallet: WalletData | null;
|
|
218
|
+
onSelect: (wallet: WalletData) => void;
|
|
219
|
+
isLoading: boolean;
|
|
220
|
+
}) => React.ReactNode;
|
|
221
|
+
children?: (props: {
|
|
222
|
+
wallets: WalletData[];
|
|
223
|
+
selectedWallet: WalletData | null;
|
|
224
|
+
selectWallet: (walletId: string) => void;
|
|
225
|
+
isLoading: boolean;
|
|
226
|
+
refreshWallets: () => Promise<void>;
|
|
227
|
+
}) => React.ReactNode;
|
|
228
|
+
}
|
|
229
|
+
declare function WalletSelector(props: WalletSelectorProps): react_jsx_runtime.JSX.Element;
|
|
230
|
+
|
|
231
|
+
interface SignerSelectorClassNames {
|
|
232
|
+
root?: string;
|
|
233
|
+
list?: string;
|
|
234
|
+
item?: string;
|
|
235
|
+
message?: string;
|
|
236
|
+
}
|
|
237
|
+
interface SignerSelectorProps {
|
|
238
|
+
/** Wallet ID (signers are loaded for this wallet when used with useSigners) */
|
|
239
|
+
selectedWalletId?: string;
|
|
240
|
+
/** Available signers (from useSigners or useSignerSelection) */
|
|
241
|
+
availableSigners: SignerData[];
|
|
242
|
+
/** Currently selected signer */
|
|
243
|
+
selectedSigner: SignerData | null;
|
|
244
|
+
/** Loading state */
|
|
245
|
+
isLoadingSigners?: boolean;
|
|
246
|
+
/** Callback when user selects a signer */
|
|
247
|
+
onSignerSelect: (signer: SignerData) => void;
|
|
248
|
+
/** Root class */
|
|
249
|
+
className?: string;
|
|
250
|
+
/** Override class names for sub-elements */
|
|
251
|
+
classNames?: SignerSelectorClassNames;
|
|
252
|
+
/** Custom list render (headless) */
|
|
253
|
+
renderList?: (props: {
|
|
254
|
+
signers: SignerData[];
|
|
255
|
+
selectedSigner: SignerData | null;
|
|
256
|
+
onSelect: (signer: SignerData) => void;
|
|
257
|
+
isLoading: boolean;
|
|
258
|
+
getSignerDisplayName: (s: SignerData) => string;
|
|
259
|
+
getSignerTypeLabel: (type: string) => string;
|
|
260
|
+
getSignerUniqueId: (s: SignerData) => string;
|
|
261
|
+
}) => React.ReactNode;
|
|
262
|
+
/** Children render props */
|
|
263
|
+
children?: (props: {
|
|
264
|
+
signers: SignerData[];
|
|
265
|
+
selectedSigner: SignerData | null;
|
|
266
|
+
onSignerSelect: (signer: SignerData) => void;
|
|
267
|
+
isLoading: boolean;
|
|
268
|
+
}) => React.ReactNode;
|
|
269
|
+
}
|
|
270
|
+
declare function SignerSelector({ selectedWalletId, availableSigners, selectedSigner, isLoadingSigners, onSignerSelect, className, classNames, renderList, children, }: SignerSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
271
|
+
|
|
272
|
+
interface DelegatedKeyData {
|
|
273
|
+
id: string;
|
|
274
|
+
walletId: string;
|
|
275
|
+
name?: string;
|
|
276
|
+
publicKey: string;
|
|
277
|
+
permissions: Record<string, unknown>;
|
|
278
|
+
isActive?: boolean;
|
|
279
|
+
createdAt?: string;
|
|
280
|
+
expiresAt?: string;
|
|
281
|
+
[key: string]: unknown;
|
|
282
|
+
}
|
|
283
|
+
interface DelegatedKeySelectorClassNames {
|
|
284
|
+
root?: string;
|
|
285
|
+
trigger?: string;
|
|
286
|
+
content?: string;
|
|
287
|
+
item?: string;
|
|
288
|
+
message?: string;
|
|
289
|
+
}
|
|
290
|
+
interface DelegatedKeySelectorProps {
|
|
291
|
+
walletId: string;
|
|
292
|
+
value?: string;
|
|
293
|
+
onChange?: (delegatedKeyId: string, key: DelegatedKeyData | null) => void;
|
|
294
|
+
filterActive?: boolean;
|
|
295
|
+
className?: string;
|
|
296
|
+
classNames?: DelegatedKeySelectorClassNames;
|
|
297
|
+
placeholder?: string;
|
|
298
|
+
children?: (props: {
|
|
299
|
+
keys: DelegatedKeyData[];
|
|
300
|
+
selectedKeyId: string | undefined;
|
|
301
|
+
onSelect: (key: DelegatedKeyData) => void;
|
|
302
|
+
isLoading: boolean;
|
|
303
|
+
error: string | null;
|
|
304
|
+
refresh: () => Promise<void>;
|
|
305
|
+
}) => React.ReactNode;
|
|
306
|
+
}
|
|
307
|
+
declare function DelegatedKeySelector(props: DelegatedKeySelectorProps): react_jsx_runtime.JSX.Element;
|
|
308
|
+
|
|
309
|
+
interface MessageSigningFormClassNames {
|
|
310
|
+
root?: string;
|
|
311
|
+
header?: string;
|
|
312
|
+
title?: string;
|
|
313
|
+
description?: string;
|
|
314
|
+
context?: string;
|
|
315
|
+
label?: string;
|
|
316
|
+
textarea?: string;
|
|
317
|
+
charCount?: string;
|
|
318
|
+
button?: string;
|
|
319
|
+
resetButton?: string;
|
|
320
|
+
result?: string;
|
|
321
|
+
resultSuccess?: string;
|
|
322
|
+
resultError?: string;
|
|
323
|
+
resultPre?: string;
|
|
324
|
+
}
|
|
325
|
+
interface MessageSigningFormProps {
|
|
326
|
+
/** Optional: override token (default: from useCilantroAuth) */
|
|
327
|
+
token?: string | null;
|
|
328
|
+
/** Optional: override wallet/signer (default: from useSignerSelection) */
|
|
329
|
+
selectedWalletId?: string;
|
|
330
|
+
selectedSigner?: SignerData | null;
|
|
331
|
+
signingMethod?: SigningMethod | null;
|
|
332
|
+
/** Optional: wallet-adapter sign message (when signingMethod === "wallet-adapter") */
|
|
333
|
+
walletAdapterSignMessage?: (message: Uint8Array) => Promise<Uint8Array>;
|
|
334
|
+
walletAdapterPublicKey?: string | null;
|
|
335
|
+
/** Root class */
|
|
336
|
+
className?: string;
|
|
337
|
+
/** Override class names for sub-elements */
|
|
338
|
+
classNames?: MessageSigningFormClassNames;
|
|
339
|
+
/** Show wallet/signer context above the form (default: true when wallet/signer selected) */
|
|
340
|
+
showContext?: boolean;
|
|
341
|
+
/** Show character count below textarea (default: false) */
|
|
342
|
+
showCharCount?: boolean;
|
|
343
|
+
/** Headless: render form content */
|
|
344
|
+
children?: (props: {
|
|
345
|
+
messageText: string;
|
|
346
|
+
setMessageText: (text: string) => void;
|
|
347
|
+
signResultState: ActionState;
|
|
348
|
+
isSigning: boolean;
|
|
349
|
+
handleSign: () => Promise<void>;
|
|
350
|
+
reset: () => void;
|
|
351
|
+
}) => React.ReactNode;
|
|
352
|
+
}
|
|
353
|
+
declare function MessageSigningForm({ token: tokenOverride, selectedWalletId: walletIdOverride, selectedSigner: signerOverride, signingMethod: methodOverride, walletAdapterSignMessage, walletAdapterPublicKey, className, classNames, showContext, showCharCount, children, }: MessageSigningFormProps): react_jsx_runtime.JSX.Element;
|
|
354
|
+
|
|
355
|
+
interface TransactionSigningFormClassNames {
|
|
356
|
+
root?: string;
|
|
357
|
+
header?: string;
|
|
358
|
+
title?: string;
|
|
359
|
+
description?: string;
|
|
360
|
+
context?: string;
|
|
361
|
+
button?: string;
|
|
362
|
+
result?: string;
|
|
363
|
+
resultSuccess?: string;
|
|
364
|
+
resultError?: string;
|
|
365
|
+
resultPre?: string;
|
|
366
|
+
}
|
|
367
|
+
interface TransactionSigningFormProps {
|
|
368
|
+
token?: string | null;
|
|
369
|
+
selectedWalletId?: string;
|
|
370
|
+
selectedSigner?: SignerData | null;
|
|
371
|
+
signingMethod?: SigningMethod | null;
|
|
372
|
+
walletAdapterSignTransaction?: (tx: Transaction) => Promise<Transaction>;
|
|
373
|
+
walletAdapterPublicKey?: string | null;
|
|
374
|
+
connection?: {
|
|
375
|
+
sendRawTransaction: (buf: Buffer) => Promise<string>;
|
|
376
|
+
getLatestBlockhash: () => Promise<{
|
|
377
|
+
blockhash: string;
|
|
378
|
+
lastValidBlockHeight: number;
|
|
379
|
+
}>;
|
|
380
|
+
confirmTransaction: (opts: {
|
|
381
|
+
signature: string;
|
|
382
|
+
blockhash: string;
|
|
383
|
+
lastValidBlockHeight: number;
|
|
384
|
+
}) => Promise<void>;
|
|
385
|
+
} | null;
|
|
386
|
+
className?: string;
|
|
387
|
+
classNames?: TransactionSigningFormClassNames;
|
|
388
|
+
/** Show wallet/signer context above the form (default: true when wallet/signer selected) */
|
|
389
|
+
showContext?: boolean;
|
|
390
|
+
/** Headless: render content; consumer builds transaction and calls signTransaction(tx) / signAndSendTransaction(tx) */
|
|
391
|
+
children?: (props: {
|
|
392
|
+
transactionResultState: ActionState;
|
|
393
|
+
isSigningTransaction: boolean;
|
|
394
|
+
isSendingTransaction: boolean;
|
|
395
|
+
signTransaction: (transaction: Transaction) => Promise<void>;
|
|
396
|
+
signAndSendTransaction: (transaction: Transaction) => Promise<void>;
|
|
397
|
+
reset: () => void;
|
|
398
|
+
}) => React.ReactNode;
|
|
399
|
+
}
|
|
400
|
+
declare function TransactionSigningForm({ token: tokenOverride, selectedWalletId: walletIdOverride, selectedSigner: signerOverride, signingMethod: methodOverride, walletAdapterSignTransaction, walletAdapterPublicKey, connection, className, classNames, showContext, children, }: TransactionSigningFormProps): react_jsx_runtime.JSX.Element;
|
|
401
|
+
|
|
402
|
+
interface LoginFormClassNames {
|
|
403
|
+
root?: string;
|
|
404
|
+
header?: string;
|
|
405
|
+
title?: string;
|
|
406
|
+
description?: string;
|
|
407
|
+
form?: string;
|
|
408
|
+
label?: string;
|
|
409
|
+
input?: string;
|
|
410
|
+
submitButton?: string;
|
|
411
|
+
error?: string;
|
|
412
|
+
}
|
|
413
|
+
interface LoginFormProps {
|
|
414
|
+
className?: string;
|
|
415
|
+
classNames?: LoginFormClassNames;
|
|
416
|
+
onSuccess?: () => void;
|
|
417
|
+
onError?: (error: string) => void;
|
|
418
|
+
/** Override submit button label */
|
|
419
|
+
submitLabel?: string;
|
|
420
|
+
/** Override title */
|
|
421
|
+
title?: string;
|
|
422
|
+
/** Override description */
|
|
423
|
+
description?: string;
|
|
424
|
+
/** Render "Create account" link (e.g. to switch to register). Shown below submit. */
|
|
425
|
+
renderSwitchToRegister?: () => React.ReactNode;
|
|
426
|
+
}
|
|
427
|
+
declare function LoginForm({ className, classNames, onSuccess, onError, submitLabel, title, description, renderSwitchToRegister, }: LoginFormProps): react_jsx_runtime.JSX.Element;
|
|
428
|
+
|
|
429
|
+
interface RegisterFormClassNames {
|
|
430
|
+
root?: string;
|
|
431
|
+
header?: string;
|
|
432
|
+
title?: string;
|
|
433
|
+
description?: string;
|
|
434
|
+
form?: string;
|
|
435
|
+
label?: string;
|
|
436
|
+
input?: string;
|
|
437
|
+
submitButton?: string;
|
|
438
|
+
error?: string;
|
|
439
|
+
}
|
|
440
|
+
interface RegisterFormProps {
|
|
441
|
+
className?: string;
|
|
442
|
+
classNames?: RegisterFormClassNames;
|
|
443
|
+
onSuccess?: () => void;
|
|
444
|
+
onError?: (error: string) => void;
|
|
445
|
+
/** Override submit button label */
|
|
446
|
+
submitLabel?: string;
|
|
447
|
+
/** Override title */
|
|
448
|
+
title?: string;
|
|
449
|
+
/** Override description */
|
|
450
|
+
description?: string;
|
|
451
|
+
/** Default is true (user is active after registration) */
|
|
452
|
+
isActive?: boolean;
|
|
453
|
+
/** Render "Already have an account? Sign in" link. Shown below submit. */
|
|
454
|
+
renderSwitchToLogin?: () => React.ReactNode;
|
|
455
|
+
}
|
|
456
|
+
declare function RegisterForm({ className, classNames, onSuccess, onError, submitLabel, title, description, isActive, renderSwitchToLogin, }: RegisterFormProps): react_jsx_runtime.JSX.Element;
|
|
457
|
+
|
|
458
|
+
type AuthFormMode = "login" | "register";
|
|
459
|
+
interface AuthFormClassNames {
|
|
460
|
+
root?: string;
|
|
461
|
+
header?: string;
|
|
462
|
+
title?: string;
|
|
463
|
+
description?: string;
|
|
464
|
+
form?: string;
|
|
465
|
+
label?: string;
|
|
466
|
+
input?: string;
|
|
467
|
+
submitButton?: string;
|
|
468
|
+
toggle?: string;
|
|
469
|
+
toggleLink?: string;
|
|
470
|
+
error?: string;
|
|
471
|
+
}
|
|
472
|
+
interface AuthFormProps {
|
|
473
|
+
/** Initial mode: login or register */
|
|
474
|
+
defaultMode?: AuthFormMode;
|
|
475
|
+
className?: string;
|
|
476
|
+
classNames?: AuthFormClassNames;
|
|
477
|
+
onSuccess?: () => void;
|
|
478
|
+
onError?: (error: string) => void;
|
|
479
|
+
/** Login: submit button label */
|
|
480
|
+
loginSubmitLabel?: string;
|
|
481
|
+
/** Register: submit button label */
|
|
482
|
+
registerSubmitLabel?: string;
|
|
483
|
+
/** Login: title */
|
|
484
|
+
loginTitle?: string;
|
|
485
|
+
/** Register: title */
|
|
486
|
+
registerTitle?: string;
|
|
487
|
+
/** Login: description */
|
|
488
|
+
loginDescription?: string;
|
|
489
|
+
/** Register: description */
|
|
490
|
+
registerDescription?: string;
|
|
491
|
+
/** Text for "switch to register" link */
|
|
492
|
+
switchToRegisterText?: string;
|
|
493
|
+
/** Text for "switch to login" link */
|
|
494
|
+
switchToLoginText?: string;
|
|
495
|
+
/** Default is true (user is active after registration) */
|
|
496
|
+
isActive?: boolean;
|
|
497
|
+
}
|
|
498
|
+
declare function AuthForm({ defaultMode, className, classNames, onSuccess, onError, loginSubmitLabel, registerSubmitLabel, loginTitle, registerTitle, loginDescription, registerDescription, switchToRegisterText, switchToLoginText, isActive, }: AuthFormProps): react_jsx_runtime.JSX.Element;
|
|
499
|
+
|
|
500
|
+
interface AuthGuardClassNames {
|
|
501
|
+
root?: string;
|
|
502
|
+
fallback?: string;
|
|
503
|
+
}
|
|
504
|
+
interface AuthGuardProps {
|
|
505
|
+
children: ReactNode;
|
|
506
|
+
/** Shown when not authenticated. Default: <LoginForm /> */
|
|
507
|
+
fallback?: ReactNode;
|
|
508
|
+
/** Root class when showing fallback */
|
|
509
|
+
className?: string;
|
|
510
|
+
classNames?: AuthGuardClassNames;
|
|
511
|
+
/** When true, show fallback (login) instead of children when unauthenticated. When false, render null when unauthenticated. */
|
|
512
|
+
showFallback?: boolean;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Wraps content and shows fallback (e.g. LoginForm) when the user is not authenticated.
|
|
516
|
+
* Use inside CilantroAuthProvider.
|
|
517
|
+
*/
|
|
518
|
+
declare function AuthGuard({ children, fallback, className, classNames, showFallback, }: AuthGuardProps): react_jsx_runtime.JSX.Element | null;
|
|
519
|
+
|
|
520
|
+
type AddSignerType = "email" | "phone" | "passkey" | "external";
|
|
521
|
+
interface AddSignerFormClassNames {
|
|
522
|
+
root?: string;
|
|
523
|
+
dialog?: string;
|
|
524
|
+
form?: string;
|
|
525
|
+
label?: string;
|
|
526
|
+
input?: string;
|
|
527
|
+
submitButton?: string;
|
|
528
|
+
cancelButton?: string;
|
|
529
|
+
error?: string;
|
|
530
|
+
}
|
|
531
|
+
interface AddSignerFormProps {
|
|
532
|
+
walletId: string;
|
|
533
|
+
open?: boolean;
|
|
534
|
+
onOpenChange?: (open: boolean) => void;
|
|
535
|
+
onSuccess?: () => void;
|
|
536
|
+
onCancel?: () => void;
|
|
537
|
+
onError?: (error: string) => void;
|
|
538
|
+
className?: string;
|
|
539
|
+
classNames?: AddSignerFormClassNames;
|
|
540
|
+
/** When true, render as a dialog. When false, render inline. */
|
|
541
|
+
asDialog?: boolean;
|
|
542
|
+
}
|
|
543
|
+
declare function AddSignerForm({ walletId, open, onOpenChange, onSuccess, onCancel, onError, className, classNames, asDialog, }: AddSignerFormProps): react_jsx_runtime.JSX.Element;
|
|
544
|
+
|
|
545
|
+
interface SignerListClassNames {
|
|
546
|
+
root?: string;
|
|
547
|
+
header?: string;
|
|
548
|
+
list?: string;
|
|
549
|
+
item?: string;
|
|
550
|
+
addButton?: string;
|
|
551
|
+
message?: string;
|
|
552
|
+
}
|
|
553
|
+
interface SignerListProps {
|
|
554
|
+
walletId: string;
|
|
555
|
+
className?: string;
|
|
556
|
+
classNames?: SignerListClassNames;
|
|
557
|
+
/** Callback when a signer is added (e.g. to refresh parent state) */
|
|
558
|
+
onSignerAdded?: () => void;
|
|
559
|
+
/** Custom render for the list of signers */
|
|
560
|
+
children?: (props: {
|
|
561
|
+
signers: SignerData[];
|
|
562
|
+
isLoading: boolean;
|
|
563
|
+
error: string | null;
|
|
564
|
+
refresh: () => Promise<void>;
|
|
565
|
+
openAddSigner: () => void;
|
|
566
|
+
}) => React.ReactNode;
|
|
567
|
+
}
|
|
568
|
+
declare function SignerList({ walletId, className, classNames, onSignerAdded, children, }: SignerListProps): react_jsx_runtime.JSX.Element;
|
|
569
|
+
|
|
570
|
+
declare function extractErrorMessage(error: unknown): string;
|
|
571
|
+
|
|
572
|
+
declare function getSignerPublicKey(walletId: string, signer: SignerData, signerType: string, signerId: string): Promise<PublicKey>;
|
|
573
|
+
|
|
574
|
+
declare function signMessageWithSigner(walletId: string, signer: SignerData, messageText: string): Promise<{
|
|
575
|
+
signature: string;
|
|
576
|
+
publicKey?: string;
|
|
577
|
+
signerType: string;
|
|
578
|
+
signer?: string;
|
|
579
|
+
}>;
|
|
580
|
+
|
|
581
|
+
/** Connection-like interface for sign-and-send (passkey). Consumer provides from their Solana config. */
|
|
582
|
+
interface SignAndSendConnection {
|
|
583
|
+
getLatestBlockhash: (commitment?: string) => Promise<{
|
|
584
|
+
blockhash: string;
|
|
585
|
+
lastValidBlockHeight: number;
|
|
586
|
+
}>;
|
|
587
|
+
confirmTransaction: (opts: {
|
|
588
|
+
signature: string;
|
|
589
|
+
blockhash: string;
|
|
590
|
+
lastValidBlockHeight: number;
|
|
591
|
+
}) => Promise<void>;
|
|
592
|
+
}
|
|
593
|
+
declare function signTransactionWithSigner(walletId: string, signer: SignerData, transactionBuffer: Uint8Array): Promise<{
|
|
594
|
+
signature: string;
|
|
595
|
+
signerType: string;
|
|
596
|
+
}>;
|
|
597
|
+
declare function signAndSendTransactionWithSigner(walletId: string, signer: SignerData, transaction: Transaction, connection?: SignAndSendConnection | null): Promise<{
|
|
598
|
+
signature: string;
|
|
599
|
+
confirmationStatus: string;
|
|
600
|
+
}>;
|
|
601
|
+
|
|
602
|
+
declare function getWalletData(walletId: string): Promise<{
|
|
603
|
+
walletPublicKey: PublicKey;
|
|
604
|
+
adminSignerPubkey: PublicKey;
|
|
605
|
+
}>;
|
|
606
|
+
|
|
607
|
+
declare const SIGNER_TYPES: {
|
|
608
|
+
readonly EMAIL: "email";
|
|
609
|
+
readonly PHONE: "phone";
|
|
610
|
+
readonly PASSKEY: "passkey";
|
|
611
|
+
readonly EXTERNAL: "external";
|
|
612
|
+
readonly API_KEY: "apiKey";
|
|
613
|
+
};
|
|
614
|
+
type SignerType = (typeof SIGNER_TYPES)[keyof typeof SIGNER_TYPES];
|
|
615
|
+
|
|
616
|
+
export { type ActionState, AddSignerForm, type AddSignerFormClassNames, type AddSignerFormProps, type AddSignerType, type ApiResponse, AuthForm, type AuthFormClassNames, type AuthFormMode, type AuthFormProps, AuthGuard, type AuthGuardClassNames, type AuthGuardProps, type CilantroAuthContextType, CilantroAuthProvider, type CilantroAuthProviderProps, CilantroProvider, type DelegatedKeyData, DelegatedKeySelector, type DelegatedKeySelectorClassNames, type DelegatedKeySelectorProps, type ErrorResponse, LoginForm, type LoginFormClassNames, type LoginFormProps, MessageSigningForm, type MessageSigningFormClassNames, type MessageSigningFormProps, RegisterForm, type RegisterFormClassNames, type RegisterFormProps, SIGNER_TYPES, type SignAndSendConnection, type SignerData, SignerList, type SignerListClassNames, type SignerListProps, SignerSelector, type SignerSelectorClassNames, type SignerSelectorProps, type SignerType, type SigningMethod, TransactionSigningForm, type TransactionSigningFormClassNames, type TransactionSigningFormProps, type UseMessageSigningOptions, type UseMessageSigningResult, type UseSignerSelectionOptions, type UseSignerSelectionResult, type UseSignersOptions, type UseSignersResult, type UseTransactionSigningOptions, type UseTransactionSigningResult, type User, type WalletContextType, type WalletData, WalletProvider, type WalletProviderProps, WalletSelector, type WalletSelectorClassNames, type WalletSelectorProps, extractErrorMessage, extractResponseData, getSignerPublicKey, getWalletData, signAndSendTransactionWithSigner, signMessageWithSigner, signTransactionWithSigner, useCilantroAuth, useMessageSigning, useSignerSelection, useSigners, useTransactionSigning, useWallets };
|