cilantro-react 0.1.3 → 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 +507 -554
- package/dist/index.d.ts +507 -554
- package/dist/index.js +2473 -2474
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2497 -2501
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
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,60 +100,53 @@ 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[];
|
|
65
111
|
selectWallet: (walletId: string) => void;
|
|
66
112
|
refreshWallets: () => Promise<void>;
|
|
67
113
|
isLoading: boolean;
|
|
114
|
+
error: string | null;
|
|
68
115
|
}
|
|
69
|
-
interface WalletProviderProps {
|
|
70
|
-
children: ReactNode;
|
|
71
|
-
storageKey?: string;
|
|
72
|
-
}
|
|
73
|
-
declare function WalletProvider({ children, storageKey }: WalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
74
116
|
declare function useWallets(): WalletContextType;
|
|
75
117
|
|
|
76
|
-
|
|
77
|
-
|
|
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;
|
|
78
129
|
isLoading: boolean;
|
|
79
|
-
|
|
130
|
+
isAuthenticated: boolean;
|
|
131
|
+
login: (params: {
|
|
132
|
+
usernameOrEmail: string;
|
|
133
|
+
password: string;
|
|
134
|
+
}) => Promise<void>;
|
|
135
|
+
logout: () => void;
|
|
80
136
|
}
|
|
81
|
-
|
|
82
|
-
* Returns the currently selected wallet, loading state, and refresh.
|
|
83
|
-
* Use when you only need the current wallet, not the full wallet list.
|
|
84
|
-
* Must be used inside CilantroProvider (WalletProvider).
|
|
85
|
-
*/
|
|
86
|
-
declare function useSelectedWallet(): UseSelectedWalletResult;
|
|
137
|
+
declare function useAuth(): UseAuthResult;
|
|
87
138
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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;
|
|
94
150
|
|
|
95
151
|
/**
|
|
96
152
|
* Normalized signer shape aligned with SDK SignerDataDto / WalletSignerDataDto.
|
|
@@ -112,6 +168,11 @@ interface SignerData extends Omit<SignerInfo, "signerId"> {
|
|
|
112
168
|
signerCategory?: "onchain" | "authenticationsigner";
|
|
113
169
|
[key: string]: unknown;
|
|
114
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;
|
|
115
176
|
|
|
116
177
|
interface UseSignersOptions {
|
|
117
178
|
/** Wallet ID to load signers for. If not provided, uses selectedWallet?.id from context (call useWallets() in same component). */
|
|
@@ -122,393 +183,82 @@ interface UseSignersResult {
|
|
|
122
183
|
isLoading: boolean;
|
|
123
184
|
error: string | null;
|
|
124
185
|
refresh: () => Promise<void>;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
interface UseSignersForSelectedWalletOptions {
|
|
148
|
-
/** Override wallet ID; when omitted, uses the selected wallet from context. */
|
|
149
|
-
walletId?: string | null;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Returns signers for the currently selected wallet (or the given walletId override).
|
|
153
|
-
* Composes useWallets + useSigners so you don't have to pass walletId yourself.
|
|
154
|
-
* Must be used inside CilantroProvider.
|
|
155
|
-
*/
|
|
156
|
-
declare function useSignersForSelectedWallet(options?: UseSignersForSelectedWalletOptions): UseSignersResult;
|
|
157
|
-
|
|
158
|
-
/** SDK delegated key type (element of DelegatedKeysListResponseDto.data). Canonical id is delegatedKeyId. */
|
|
159
|
-
type DelegatedKeyDataDto = DelegatedKeyControllerFindAllResult["data"] extends readonly (infer E)[] ? E : DelegatedKeyControllerFindAllResult["data"] extends (infer E)[] ? E : never;
|
|
160
|
-
/** DelegatedKeyDataDto with backward-compat id alias (id = delegatedKeyId) for existing UI. */
|
|
161
|
-
type DelegatedKeyData = DelegatedKeyDataDto & {
|
|
162
|
-
id?: string;
|
|
163
|
-
};
|
|
164
|
-
interface UseDelegatedKeysOptions {
|
|
165
|
-
/** Wallet ID to load delegated keys for. When null/undefined, keys are empty. */
|
|
166
|
-
walletId?: string | null;
|
|
167
|
-
/** When true (default), filter to active keys and non-expired only. */
|
|
168
|
-
filterActive?: boolean;
|
|
169
|
-
}
|
|
170
|
-
interface UseDelegatedKeysResult {
|
|
171
|
-
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
|
+
}>;
|
|
172
207
|
isLoading: boolean;
|
|
173
|
-
error: string | null;
|
|
174
|
-
refresh: () => Promise<void>;
|
|
175
208
|
}
|
|
176
|
-
|
|
177
|
-
* Load delegated keys for a wallet. Use for custom delegated-key UI or logic.
|
|
178
|
-
* Must be used inside CilantroProvider (auth required).
|
|
179
|
-
*/
|
|
180
|
-
declare function useDelegatedKeys(options?: UseDelegatedKeysOptions): UseDelegatedKeysResult;
|
|
181
|
-
|
|
182
|
-
type SigningMethod = "wallet-adapter" | "sdk-signer";
|
|
183
|
-
interface UseSignerSelectionOptions {
|
|
184
|
-
/** Override wallet ID; if not set, uses selected wallet from WalletProvider */
|
|
185
|
-
walletId?: string | null;
|
|
186
|
-
/** Current signing method */
|
|
187
|
-
signingMethod?: SigningMethod | null;
|
|
188
|
-
}
|
|
189
|
-
interface UseSignerSelectionResult {
|
|
190
|
-
selectedWalletId: string;
|
|
191
|
-
setSelectedWalletId: (id: string) => void;
|
|
192
|
-
availableSigners: SignerData[];
|
|
193
|
-
selectedSigner: SignerData | null;
|
|
194
|
-
setSelectedSigner: (signer: SignerData | null) => void;
|
|
195
|
-
isLoadingSigners: boolean;
|
|
196
|
-
reset: () => void;
|
|
197
|
-
}
|
|
198
|
-
declare function useSignerSelection(options?: UseSignerSelectionOptions): UseSignerSelectionResult;
|
|
199
|
-
|
|
200
|
-
interface UseCanSignOptions {
|
|
201
|
-
/** Override signing method; when omitted, uses default "sdk-signer". */
|
|
202
|
-
signingMethod?: SigningMethod | null;
|
|
203
|
-
/** When true (default for sdk-signer), require a selected signer. When false, only wallet is required. */
|
|
204
|
-
requireSigner?: boolean;
|
|
205
|
-
/** When using wallet-adapter, pass true when the adapter is connected. Omit if not using wallet-adapter. */
|
|
206
|
-
walletAdapterConnected?: boolean;
|
|
207
|
-
}
|
|
208
|
-
interface UseCanSignResult {
|
|
209
|
-
/** True when the user has a valid token. */
|
|
210
|
-
hasToken: boolean;
|
|
211
|
-
/** True when a wallet is selected. */
|
|
212
|
-
hasWallet: boolean;
|
|
213
|
-
/** True when a signer is selected (sdk-signer) or wallet-adapter is connected (when walletAdapterConnected is passed). */
|
|
214
|
-
hasSigner: boolean;
|
|
215
|
-
/** True when ready to sign a message (hasToken + hasWallet + hasSigner for current method). */
|
|
216
|
-
canSignMessage: boolean;
|
|
217
|
-
/** True when ready to sign/send a transaction (same as canSignMessage; connection is required for send). */
|
|
218
|
-
canSignTransaction: boolean;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Derived "is the user ready to sign?" for disabling sign buttons or showing prompts.
|
|
222
|
-
* For wallet-adapter, pass walletAdapterConnected when your adapter is connected so canSign reflects it.
|
|
223
|
-
* Must be used inside CilantroProvider.
|
|
224
|
-
*/
|
|
225
|
-
declare function useCanSign(options?: UseCanSignOptions): UseCanSignResult;
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Type Utilities - common types and utilities for SDK interactions
|
|
229
|
-
*/
|
|
230
|
-
type ActionState<T = unknown> = {
|
|
231
|
-
status: "idle" | "loading" | "success" | "error";
|
|
232
|
-
message?: string;
|
|
233
|
-
detail?: T;
|
|
234
|
-
};
|
|
235
|
-
interface ErrorResponse {
|
|
236
|
-
message?: string;
|
|
237
|
-
error?: string;
|
|
238
|
-
code?: string | number;
|
|
239
|
-
status?: number;
|
|
240
|
-
statusText?: string;
|
|
241
|
-
data?: unknown;
|
|
242
|
-
stack?: string;
|
|
243
|
-
type?: string;
|
|
244
|
-
}
|
|
245
|
-
type ApiResponse<T> = T | {
|
|
246
|
-
data: T;
|
|
247
|
-
} | {
|
|
248
|
-
success: boolean;
|
|
249
|
-
data: T;
|
|
250
|
-
};
|
|
251
|
-
declare function extractResponseData<T>(response: unknown): T | null;
|
|
209
|
+
declare function usePasskey(walletId: string | undefined): UsePasskeyResult;
|
|
252
210
|
|
|
253
|
-
interface
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
/** Optional: callback when using wallet-adapter; signMessage(encodedMessage) => signature bytes */
|
|
259
|
-
walletAdapterSignMessage?: (message: Uint8Array) => Promise<Uint8Array>;
|
|
260
|
-
/** Optional: public key when using wallet-adapter (for result) */
|
|
261
|
-
walletAdapterPublicKey?: string | null;
|
|
262
|
-
}
|
|
263
|
-
interface UseMessageSigningResult {
|
|
264
|
-
messageText: string;
|
|
265
|
-
setMessageText: (text: string) => void;
|
|
266
|
-
signResultState: ActionState;
|
|
267
|
-
isSigning: boolean;
|
|
268
|
-
handleSign: () => Promise<void>;
|
|
269
|
-
reset: () => void;
|
|
270
|
-
}
|
|
271
|
-
declare function useMessageSigning(options: UseMessageSigningOptions): UseMessageSigningResult;
|
|
272
|
-
|
|
273
|
-
interface UseTransactionSigningOptions {
|
|
274
|
-
token: string | null;
|
|
275
|
-
signingMethod: SigningMethod | null;
|
|
276
|
-
selectedSigner: SignerData | null;
|
|
277
|
-
selectedWalletId: string;
|
|
278
|
-
/** Optional: wallet-adapter signTransaction(transaction) => signed transaction */
|
|
279
|
-
walletAdapterSignTransaction?: (transaction: Transaction) => Promise<Transaction>;
|
|
280
|
-
/** Optional: wallet-adapter public key (for building/sending) */
|
|
281
|
-
walletAdapterPublicKey?: string | null;
|
|
282
|
-
/** Optional: connection for sending (e.g. from @solana/web3.js). Used for wallet-adapter send. */
|
|
283
|
-
connection?: {
|
|
284
|
-
sendRawTransaction: (buf: Buffer) => Promise<string>;
|
|
285
|
-
getLatestBlockhash: () => Promise<{
|
|
286
|
-
blockhash: string;
|
|
287
|
-
lastValidBlockHeight: number;
|
|
288
|
-
}>;
|
|
289
|
-
confirmTransaction: (opts: {
|
|
290
|
-
signature: string;
|
|
291
|
-
blockhash: string;
|
|
292
|
-
lastValidBlockHeight: number;
|
|
293
|
-
}) => Promise<void>;
|
|
211
|
+
/** Minimal Solana wallet interface (Phantom, Solflare, etc.) */
|
|
212
|
+
interface SolanaWallet {
|
|
213
|
+
name: string;
|
|
214
|
+
publicKey: {
|
|
215
|
+
toString: () => string;
|
|
294
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
|
+
};
|
|
295
247
|
}
|
|
296
|
-
interface
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
trigger?: string;
|
|
309
|
-
content?: string;
|
|
310
|
-
item?: string;
|
|
311
|
-
skeleton?: string;
|
|
312
|
-
loading?: string;
|
|
313
|
-
}
|
|
314
|
-
interface WalletSelectorProps {
|
|
315
|
-
value?: string;
|
|
316
|
-
onWalletChange?: (walletId: string, wallet: WalletData | null) => void;
|
|
317
|
-
className?: string;
|
|
318
|
-
classNames?: WalletSelectorClassNames;
|
|
319
|
-
/** When true (default), show skeleton in trigger while loading; when false, show "Loading..." text. */
|
|
320
|
-
useSkeleton?: boolean;
|
|
321
|
-
placeholder?: string;
|
|
322
|
-
renderTrigger?: (props: {
|
|
323
|
-
selectedWallet: WalletData | null;
|
|
324
|
-
wallets: WalletData[];
|
|
325
|
-
isLoading: boolean;
|
|
326
|
-
open: boolean;
|
|
327
|
-
setOpen: (open: boolean) => void;
|
|
328
|
-
}) => React.ReactNode;
|
|
329
|
-
renderList?: (props: {
|
|
330
|
-
wallets: WalletData[];
|
|
331
|
-
selectedWallet: WalletData | null;
|
|
332
|
-
onSelect: (wallet: WalletData) => void;
|
|
333
|
-
isLoading: boolean;
|
|
334
|
-
}) => React.ReactNode;
|
|
335
|
-
children?: (props: {
|
|
336
|
-
wallets: WalletData[];
|
|
337
|
-
selectedWallet: WalletData | null;
|
|
338
|
-
selectWallet: (walletId: string) => void;
|
|
339
|
-
isLoading: boolean;
|
|
340
|
-
refreshWallets: () => Promise<void>;
|
|
341
|
-
}) => React.ReactNode;
|
|
342
|
-
}
|
|
343
|
-
declare function WalletSelector(props: WalletSelectorProps): react_jsx_runtime.JSX.Element;
|
|
344
|
-
|
|
345
|
-
interface SignerSelectorClassNames {
|
|
346
|
-
root?: string;
|
|
347
|
-
list?: string;
|
|
348
|
-
item?: string;
|
|
349
|
-
message?: string;
|
|
350
|
-
skeleton?: string;
|
|
351
|
-
loading?: string;
|
|
352
|
-
}
|
|
353
|
-
interface SignerSelectorProps {
|
|
354
|
-
/** Wallet ID (signers are loaded for this wallet when used with useSigners) */
|
|
355
|
-
selectedWalletId?: string;
|
|
356
|
-
/** Available signers (from useSigners or useSignerSelection) */
|
|
357
|
-
availableSigners: SignerData[];
|
|
358
|
-
/** Currently selected signer */
|
|
359
|
-
selectedSigner: SignerData | null;
|
|
360
|
-
/** Loading state */
|
|
361
|
-
isLoadingSigners?: boolean;
|
|
362
|
-
/** Callback when user selects a signer */
|
|
363
|
-
onSignerSelect: (signer: SignerData) => void;
|
|
364
|
-
/** Root class */
|
|
365
|
-
className?: string;
|
|
366
|
-
/** Override class names for sub-elements */
|
|
367
|
-
classNames?: SignerSelectorClassNames;
|
|
368
|
-
/** When true (default), show skeleton rows while loading; when false, show "Loading signers..." text. */
|
|
369
|
-
useSkeleton?: boolean;
|
|
370
|
-
/** Custom list render (headless) */
|
|
371
|
-
renderList?: (props: {
|
|
372
|
-
signers: SignerData[];
|
|
373
|
-
selectedSigner: SignerData | null;
|
|
374
|
-
onSelect: (signer: SignerData) => void;
|
|
375
|
-
isLoading: boolean;
|
|
376
|
-
getSignerDisplayName: (s: SignerData) => string;
|
|
377
|
-
getSignerTypeLabel: (type: string) => string;
|
|
378
|
-
getSignerUniqueId: (s: SignerData) => string;
|
|
379
|
-
}) => React.ReactNode;
|
|
380
|
-
/** Children render props */
|
|
381
|
-
children?: (props: {
|
|
382
|
-
signers: SignerData[];
|
|
383
|
-
selectedSigner: SignerData | null;
|
|
384
|
-
onSignerSelect: (signer: SignerData) => void;
|
|
385
|
-
isLoading: boolean;
|
|
386
|
-
}) => React.ReactNode;
|
|
387
|
-
}
|
|
388
|
-
declare function SignerSelector({ selectedWalletId, availableSigners, selectedSigner, isLoadingSigners, onSignerSelect, className, classNames, useSkeleton, renderList, children, }: SignerSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
389
|
-
|
|
390
|
-
interface DelegatedKeySelectorClassNames {
|
|
391
|
-
root?: string;
|
|
392
|
-
trigger?: string;
|
|
393
|
-
content?: string;
|
|
394
|
-
item?: string;
|
|
395
|
-
message?: string;
|
|
396
|
-
skeleton?: string;
|
|
397
|
-
loading?: string;
|
|
398
|
-
}
|
|
399
|
-
interface DelegatedKeySelectorProps {
|
|
400
|
-
walletId: string;
|
|
401
|
-
value?: string;
|
|
402
|
-
onChange?: (delegatedKeyId: string, key: DelegatedKeyData | null) => void;
|
|
403
|
-
filterActive?: boolean;
|
|
404
|
-
className?: string;
|
|
405
|
-
classNames?: DelegatedKeySelectorClassNames;
|
|
406
|
-
/** When true (default), show skeleton trigger while loading; when false, show "Loading delegated keys..." text. */
|
|
407
|
-
useSkeleton?: boolean;
|
|
408
|
-
placeholder?: string;
|
|
409
|
-
children?: (props: {
|
|
410
|
-
keys: DelegatedKeyData[];
|
|
411
|
-
selectedKeyId: string | undefined;
|
|
412
|
-
onSelect: (key: DelegatedKeyData) => void;
|
|
413
|
-
isLoading: boolean;
|
|
414
|
-
error: string | null;
|
|
415
|
-
refresh: () => Promise<void>;
|
|
416
|
-
}) => React.ReactNode;
|
|
417
|
-
}
|
|
418
|
-
declare function DelegatedKeySelector(props: DelegatedKeySelectorProps): react_jsx_runtime.JSX.Element;
|
|
419
|
-
|
|
420
|
-
interface MessageSigningFormClassNames {
|
|
421
|
-
root?: string;
|
|
422
|
-
header?: string;
|
|
423
|
-
title?: string;
|
|
424
|
-
description?: string;
|
|
425
|
-
context?: string;
|
|
426
|
-
label?: string;
|
|
427
|
-
textarea?: string;
|
|
428
|
-
charCount?: string;
|
|
429
|
-
button?: string;
|
|
430
|
-
resetButton?: string;
|
|
431
|
-
result?: string;
|
|
432
|
-
resultSuccess?: string;
|
|
433
|
-
resultError?: string;
|
|
434
|
-
resultPre?: string;
|
|
435
|
-
}
|
|
436
|
-
interface MessageSigningFormProps {
|
|
437
|
-
/** Optional: override token (default: from useCilantroAuth) */
|
|
438
|
-
token?: string | null;
|
|
439
|
-
/** Optional: override wallet/signer (default: from useSignerSelection) */
|
|
440
|
-
selectedWalletId?: string;
|
|
441
|
-
selectedSigner?: SignerData | null;
|
|
442
|
-
signingMethod?: SigningMethod | null;
|
|
443
|
-
/** Optional: wallet-adapter sign message (when signingMethod === "wallet-adapter") */
|
|
444
|
-
walletAdapterSignMessage?: (message: Uint8Array) => Promise<Uint8Array>;
|
|
445
|
-
walletAdapterPublicKey?: string | null;
|
|
446
|
-
/** Root class */
|
|
447
|
-
className?: string;
|
|
448
|
-
/** Override class names for sub-elements */
|
|
449
|
-
classNames?: MessageSigningFormClassNames;
|
|
450
|
-
/** Show wallet/signer context above the form (default: true when wallet/signer selected) */
|
|
451
|
-
showContext?: boolean;
|
|
452
|
-
/** Show character count below textarea (default: false) */
|
|
453
|
-
showCharCount?: boolean;
|
|
454
|
-
/** Headless: render form content */
|
|
455
|
-
children?: (props: {
|
|
456
|
-
messageText: string;
|
|
457
|
-
setMessageText: (text: string) => void;
|
|
458
|
-
signResultState: ActionState;
|
|
459
|
-
isSigning: boolean;
|
|
460
|
-
handleSign: () => Promise<void>;
|
|
461
|
-
reset: () => void;
|
|
462
|
-
}) => React.ReactNode;
|
|
463
|
-
}
|
|
464
|
-
declare function MessageSigningForm({ token: tokenOverride, selectedWalletId: walletIdOverride, selectedSigner: signerOverride, signingMethod: methodOverride, walletAdapterSignMessage, walletAdapterPublicKey, className, classNames, showContext, showCharCount, children, }: MessageSigningFormProps): react_jsx_runtime.JSX.Element;
|
|
465
|
-
|
|
466
|
-
interface TransactionSigningFormClassNames {
|
|
467
|
-
root?: string;
|
|
468
|
-
header?: string;
|
|
469
|
-
title?: string;
|
|
470
|
-
description?: string;
|
|
471
|
-
context?: string;
|
|
472
|
-
button?: string;
|
|
473
|
-
result?: string;
|
|
474
|
-
resultSuccess?: string;
|
|
475
|
-
resultError?: string;
|
|
476
|
-
resultPre?: string;
|
|
477
|
-
}
|
|
478
|
-
interface TransactionSigningFormProps {
|
|
479
|
-
token?: string | null;
|
|
480
|
-
selectedWalletId?: string;
|
|
481
|
-
selectedSigner?: SignerData | null;
|
|
482
|
-
signingMethod?: SigningMethod | null;
|
|
483
|
-
walletAdapterSignTransaction?: (tx: Transaction) => Promise<Transaction>;
|
|
484
|
-
walletAdapterPublicKey?: string | null;
|
|
485
|
-
connection?: {
|
|
486
|
-
sendRawTransaction: (buf: Buffer) => Promise<string>;
|
|
487
|
-
getLatestBlockhash: () => Promise<{
|
|
488
|
-
blockhash: string;
|
|
489
|
-
lastValidBlockHeight: number;
|
|
490
|
-
}>;
|
|
491
|
-
confirmTransaction: (opts: {
|
|
492
|
-
signature: string;
|
|
493
|
-
blockhash: string;
|
|
494
|
-
lastValidBlockHeight: number;
|
|
495
|
-
}) => Promise<void>;
|
|
496
|
-
} | null;
|
|
497
|
-
className?: string;
|
|
498
|
-
classNames?: TransactionSigningFormClassNames;
|
|
499
|
-
/** Show wallet/signer context above the form (default: true when wallet/signer selected) */
|
|
500
|
-
showContext?: boolean;
|
|
501
|
-
/** Headless: render content; consumer builds transaction and calls signTransaction(tx) / signAndSendTransaction(tx) */
|
|
502
|
-
children?: (props: {
|
|
503
|
-
transactionResultState: ActionState;
|
|
504
|
-
isSigningTransaction: boolean;
|
|
505
|
-
isSendingTransaction: boolean;
|
|
506
|
-
signTransaction: (transaction: Transaction) => Promise<void>;
|
|
507
|
-
signAndSendTransaction: (transaction: Transaction) => Promise<void>;
|
|
508
|
-
reset: () => void;
|
|
509
|
-
}) => 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;
|
|
510
260
|
}
|
|
511
|
-
declare function
|
|
261
|
+
declare function useSendTransaction(walletId: string | undefined, _signerId?: string, _signerType?: SignerType$2): UseSendTransactionResult;
|
|
512
262
|
|
|
513
263
|
interface LoginFormClassNames {
|
|
514
264
|
root?: string;
|
|
@@ -524,8 +274,10 @@ interface LoginFormClassNames {
|
|
|
524
274
|
interface LoginFormProps {
|
|
525
275
|
className?: string;
|
|
526
276
|
classNames?: LoginFormClassNames;
|
|
277
|
+
style?: React.CSSProperties;
|
|
527
278
|
onSuccess?: () => void;
|
|
528
|
-
onError?: (error:
|
|
279
|
+
onError?: (error: Error) => void;
|
|
280
|
+
rememberMe?: boolean;
|
|
529
281
|
/** Override submit button label */
|
|
530
282
|
submitLabel?: string;
|
|
531
283
|
/** Override title */
|
|
@@ -535,78 +287,15 @@ interface LoginFormProps {
|
|
|
535
287
|
/** Render "Create account" link (e.g. to switch to register). Shown below submit. */
|
|
536
288
|
renderSwitchToRegister?: () => React.ReactNode;
|
|
537
289
|
}
|
|
538
|
-
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;
|
|
539
291
|
|
|
540
|
-
interface
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
title?: string;
|
|
544
|
-
description?: string;
|
|
545
|
-
form?: string;
|
|
546
|
-
label?: string;
|
|
547
|
-
input?: string;
|
|
548
|
-
submitButton?: string;
|
|
549
|
-
error?: string;
|
|
550
|
-
}
|
|
551
|
-
interface RegisterFormProps {
|
|
292
|
+
interface LogoutButtonProps {
|
|
293
|
+
onLogout?: () => void;
|
|
294
|
+
confirmBeforeLogout?: boolean;
|
|
552
295
|
className?: string;
|
|
553
|
-
|
|
554
|
-
onSuccess?: () => void;
|
|
555
|
-
onError?: (error: string) => void;
|
|
556
|
-
/** Override submit button label */
|
|
557
|
-
submitLabel?: string;
|
|
558
|
-
/** Override title */
|
|
559
|
-
title?: string;
|
|
560
|
-
/** Override description */
|
|
561
|
-
description?: string;
|
|
562
|
-
/** Default is true (user is active after registration) */
|
|
563
|
-
isActive?: boolean;
|
|
564
|
-
/** Render "Already have an account? Sign in" link. Shown below submit. */
|
|
565
|
-
renderSwitchToLogin?: () => React.ReactNode;
|
|
566
|
-
}
|
|
567
|
-
declare function RegisterForm({ className, classNames, onSuccess, onError, submitLabel, title, description, isActive, renderSwitchToLogin, }: RegisterFormProps): react_jsx_runtime.JSX.Element;
|
|
568
|
-
|
|
569
|
-
type AuthFormMode = "login" | "register";
|
|
570
|
-
interface AuthFormClassNames {
|
|
571
|
-
root?: string;
|
|
572
|
-
header?: string;
|
|
573
|
-
title?: string;
|
|
574
|
-
description?: string;
|
|
575
|
-
form?: string;
|
|
576
|
-
label?: string;
|
|
577
|
-
input?: string;
|
|
578
|
-
submitButton?: string;
|
|
579
|
-
toggle?: string;
|
|
580
|
-
toggleLink?: string;
|
|
581
|
-
error?: string;
|
|
296
|
+
children?: ReactNode;
|
|
582
297
|
}
|
|
583
|
-
|
|
584
|
-
/** Initial mode: login or register */
|
|
585
|
-
defaultMode?: AuthFormMode;
|
|
586
|
-
className?: string;
|
|
587
|
-
classNames?: AuthFormClassNames;
|
|
588
|
-
onSuccess?: () => void;
|
|
589
|
-
onError?: (error: string) => void;
|
|
590
|
-
/** Login: submit button label */
|
|
591
|
-
loginSubmitLabel?: string;
|
|
592
|
-
/** Register: submit button label */
|
|
593
|
-
registerSubmitLabel?: string;
|
|
594
|
-
/** Login: title */
|
|
595
|
-
loginTitle?: string;
|
|
596
|
-
/** Register: title */
|
|
597
|
-
registerTitle?: string;
|
|
598
|
-
/** Login: description */
|
|
599
|
-
loginDescription?: string;
|
|
600
|
-
/** Register: description */
|
|
601
|
-
registerDescription?: string;
|
|
602
|
-
/** Text for "switch to register" link */
|
|
603
|
-
switchToRegisterText?: string;
|
|
604
|
-
/** Text for "switch to login" link */
|
|
605
|
-
switchToLoginText?: string;
|
|
606
|
-
/** Default is true (user is active after registration) */
|
|
607
|
-
isActive?: boolean;
|
|
608
|
-
}
|
|
609
|
-
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;
|
|
610
299
|
|
|
611
300
|
interface AuthGuardClassNames {
|
|
612
301
|
root?: string;
|
|
@@ -618,6 +307,8 @@ interface AuthGuardProps {
|
|
|
618
307
|
children: ReactNode;
|
|
619
308
|
/** Shown when not authenticated. Default: <LoginForm /> */
|
|
620
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;
|
|
621
312
|
/** Root class when showing fallback */
|
|
622
313
|
className?: string;
|
|
623
314
|
classNames?: AuthGuardClassNames;
|
|
@@ -628,34 +319,34 @@ interface AuthGuardProps {
|
|
|
628
319
|
}
|
|
629
320
|
/**
|
|
630
321
|
* Wraps content and shows fallback (e.g. LoginForm) when the user is not authenticated.
|
|
631
|
-
* Use inside
|
|
322
|
+
* Use inside CilantroProvider.
|
|
632
323
|
*/
|
|
633
|
-
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;
|
|
634
325
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
label?: string;
|
|
641
|
-
input?: string;
|
|
642
|
-
submitButton?: string;
|
|
643
|
-
cancelButton?: string;
|
|
644
|
-
error?: string;
|
|
326
|
+
interface CreateEmailSignerFormProps {
|
|
327
|
+
walletId: string;
|
|
328
|
+
onCreated?: (signer: SignerInfo) => void;
|
|
329
|
+
onError?: (error: Error) => void;
|
|
330
|
+
className?: string;
|
|
645
331
|
}
|
|
646
|
-
|
|
332
|
+
declare function CreateEmailSignerForm({ walletId, onCreated, onError, className, }: CreateEmailSignerFormProps): react_jsx_runtime.JSX.Element;
|
|
333
|
+
|
|
334
|
+
interface CreatePhoneSignerFormProps {
|
|
647
335
|
walletId: string;
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
336
|
+
onCreated?: (signer: SignerInfo) => void;
|
|
337
|
+
onError?: (error: Error) => void;
|
|
338
|
+
className?: string;
|
|
339
|
+
}
|
|
340
|
+
declare function CreatePhoneSignerForm({ walletId, onCreated, onError, className, }: CreatePhoneSignerFormProps): react_jsx_runtime.JSX.Element;
|
|
341
|
+
|
|
342
|
+
interface AddPasskeyButtonProps {
|
|
343
|
+
walletId: string;
|
|
344
|
+
onRegistered?: (signer: SignerInfo) => void;
|
|
345
|
+
onError?: (error: Error) => void;
|
|
653
346
|
className?: string;
|
|
654
|
-
|
|
655
|
-
/** When true, render as a dialog. When false, render inline. */
|
|
656
|
-
asDialog?: boolean;
|
|
347
|
+
children?: ReactNode;
|
|
657
348
|
}
|
|
658
|
-
declare function
|
|
349
|
+
declare function AddPasskeyButton({ walletId, onRegistered, onError, className, children, }: AddPasskeyButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
659
350
|
|
|
660
351
|
interface SignerListClassNames {
|
|
661
352
|
root?: string;
|
|
@@ -669,13 +360,11 @@ interface SignerListClassNames {
|
|
|
669
360
|
}
|
|
670
361
|
interface SignerListProps {
|
|
671
362
|
walletId: string;
|
|
363
|
+
onRevoke?: (signerId: string) => void;
|
|
672
364
|
className?: string;
|
|
673
365
|
classNames?: SignerListClassNames;
|
|
674
|
-
/** Callback when a signer is added (e.g. to refresh parent state) */
|
|
675
366
|
onSignerAdded?: () => void;
|
|
676
|
-
/** When true (default), show skeleton rows while loading; when false, show "Loading signers..." text. */
|
|
677
367
|
useSkeleton?: boolean;
|
|
678
|
-
/** Custom render for the list of signers */
|
|
679
368
|
children?: (props: {
|
|
680
369
|
signers: SignerData[];
|
|
681
370
|
isLoading: boolean;
|
|
@@ -684,30 +373,7 @@ interface SignerListProps {
|
|
|
684
373
|
openAddSigner: () => void;
|
|
685
374
|
}) => React.ReactNode;
|
|
686
375
|
}
|
|
687
|
-
declare function SignerList({ walletId, className, classNames, onSignerAdded, useSkeleton, children, }: SignerListProps): react_jsx_runtime.JSX.Element;
|
|
688
|
-
|
|
689
|
-
interface SkeletonProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
690
|
-
}
|
|
691
|
-
declare const Skeleton: React$1.ForwardRefExoticComponent<SkeletonProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
692
|
-
|
|
693
|
-
type Theme = "light" | "dark" | "system";
|
|
694
|
-
type ResolvedTheme = "light" | "dark";
|
|
695
|
-
interface ThemeProviderProps {
|
|
696
|
-
/** Current theme: "light", "dark", or "system" (follows prefers-color-scheme). */
|
|
697
|
-
theme?: Theme;
|
|
698
|
-
/** Default theme when theme is "system" or for initial render. */
|
|
699
|
-
defaultTheme?: ResolvedTheme;
|
|
700
|
-
/** Optional localStorage key for persisting theme when using "system". */
|
|
701
|
-
storageKey?: string;
|
|
702
|
-
/** Optional class for the wrapper div. */
|
|
703
|
-
className?: string;
|
|
704
|
-
children: React$1.ReactNode;
|
|
705
|
-
/** When true, inject the default theme CSS variables (light/dark). Your app must still use Tailwind. */
|
|
706
|
-
injectStyles?: boolean;
|
|
707
|
-
}
|
|
708
|
-
declare function ThemeProvider({ theme, defaultTheme, storageKey, className, children, injectStyles, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
709
|
-
|
|
710
|
-
declare function extractErrorMessage(error: unknown): string;
|
|
376
|
+
declare function SignerList({ walletId, onRevoke, className, classNames, onSignerAdded, useSkeleton, children, }: SignerListProps): react_jsx_runtime.JSX.Element;
|
|
711
377
|
|
|
712
378
|
declare function getSignerPublicKey(walletId: string, signer: SignerData, signerType: string, signerId: string): Promise<PublicKey>;
|
|
713
379
|
|
|
@@ -761,6 +427,293 @@ declare const SIGNER_TYPES: {
|
|
|
761
427
|
readonly EXTERNAL: "external";
|
|
762
428
|
readonly API_KEY: "apiKey";
|
|
763
429
|
};
|
|
764
|
-
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;
|
|
765
718
|
|
|
766
|
-
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 };
|