cilantro-react 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -2
- package/dist/index.d.mts +177 -27
- package/dist/index.d.ts +177 -27
- package/dist/index.js +732 -379
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +684 -337
- package/dist/index.mjs.map +1 -1
- package/dist/themes/default.css +43 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|
|
59
59
|
- **CilantroProvider** – Root provider: initializes storage, auth, and wallet context. Requires `platformApiKey`; optional `apiUrl`, storage keys, and callbacks. Use this unless you only need auth.
|
|
60
60
|
- **CilantroAuthProvider** – Auth only (token, user, login, register, logout). Use when you don’t need the full provider stack (e.g. auth-only pages).
|
|
61
61
|
- **WalletProvider** – Wallet list and selection. Depends on auth; usually used inside `CilantroProvider`.
|
|
62
|
+
- **ThemeProvider** – Optional: sets `data-theme="light"` or `"dark"` on a wrapper and injects default CSS variables for light/dark. Props: `theme` (`"light"` | `"dark"` | `"system"`), `defaultTheme`, `storageKey`, `className`, `injectStyles`. See [Themes](#built-in-theme-themeprovider).
|
|
62
63
|
|
|
63
64
|
**CilantroAuthProvider props:** `platformApiKey` (required), `apiUrl`, `jwtStorageKey`, `onLoginSuccess`, `onLogout`, `onRegisterSuccess`.
|
|
64
65
|
|
|
@@ -106,6 +107,32 @@ Wallet list and selection. Use inside `CilantroProvider` (which includes `Wallet
|
|
|
106
107
|
|
|
107
108
|
---
|
|
108
109
|
|
|
110
|
+
#### useSelectedWallet
|
|
111
|
+
|
|
112
|
+
Convenience hook when you only need the currently selected wallet (and loading/refresh), not the full list. Use inside `CilantroProvider`.
|
|
113
|
+
|
|
114
|
+
**Returns:** `UseSelectedWalletResult`
|
|
115
|
+
|
|
116
|
+
| Property | Type | Description |
|
|
117
|
+
|----------|------|-------------|
|
|
118
|
+
| `selectedWallet` | `WalletData \| null` | Currently selected wallet. |
|
|
119
|
+
| `isLoading` | `boolean` | True while loading wallets. |
|
|
120
|
+
| `refreshWallets` | `() => Promise<void>` | Reload wallets from the API. |
|
|
121
|
+
|
|
122
|
+
**Use when:** You need the current wallet without the full wallet list or `selectWallet`.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
#### useWalletAddress
|
|
127
|
+
|
|
128
|
+
Returns the address of the currently selected wallet (handles both `address` and `walletAddress` on WalletData). Use inside `CilantroProvider`.
|
|
129
|
+
|
|
130
|
+
**Returns:** `string | null`
|
|
131
|
+
|
|
132
|
+
**Use when:** You need the selected wallet's address for display or building transactions.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
109
136
|
#### useSigners
|
|
110
137
|
|
|
111
138
|
Load signers for a wallet. Use inside `CilantroProvider` (auth required).
|
|
@@ -129,6 +156,22 @@ When `walletId` is null/undefined, `signers` is empty and `refresh` no-ops.
|
|
|
129
156
|
|
|
130
157
|
---
|
|
131
158
|
|
|
159
|
+
#### useSignersForSelectedWallet
|
|
160
|
+
|
|
161
|
+
Signers for the currently selected wallet (or a `walletId` override). Composes `useWallets` + `useSigners` so you don't pass `walletId` yourself. Use inside `CilantroProvider`.
|
|
162
|
+
|
|
163
|
+
**Options:** `UseSignersForSelectedWalletOptions`
|
|
164
|
+
|
|
165
|
+
| Option | Type | Description |
|
|
166
|
+
|--------|------|-------------|
|
|
167
|
+
| `walletId` | `string \| null \| undefined` | Override; when omitted, uses the selected wallet from context. |
|
|
168
|
+
|
|
169
|
+
**Returns:** Same as `useSigners` – `UseSignersResult` (`signers`, `isLoading`, `error`, `refresh`).
|
|
170
|
+
|
|
171
|
+
**Use when:** You need signers for the current wallet without calling `useWallets()` and `useSigners({ walletId })` in every component (e.g. SignerList-style UIs).
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
132
175
|
#### useSignerSelection
|
|
133
176
|
|
|
134
177
|
Wallet + signer selection state for signing flows. Uses `useWallets` and `useSigners` internally. Use inside `CilantroProvider`.
|
|
@@ -156,6 +199,56 @@ Wallet + signer selection state for signing flows. Uses `useWallets` and `useSig
|
|
|
156
199
|
|
|
157
200
|
---
|
|
158
201
|
|
|
202
|
+
#### useDelegatedKeys
|
|
203
|
+
|
|
204
|
+
Load delegated keys for a wallet (same data as DelegatedKeySelector). Use for custom delegated-key UI or logic. Use inside `CilantroProvider` (auth required).
|
|
205
|
+
|
|
206
|
+
**Options:** `UseDelegatedKeysOptions`
|
|
207
|
+
|
|
208
|
+
| Option | Type | Description |
|
|
209
|
+
|--------|------|-------------|
|
|
210
|
+
| `walletId` | `string \| null \| undefined` | Wallet ID to load delegated keys for. When null/undefined, keys are empty. |
|
|
211
|
+
| `filterActive` | `boolean` | When true (default), filter to active and non-expired keys only. |
|
|
212
|
+
|
|
213
|
+
**Returns:** `UseDelegatedKeysResult`
|
|
214
|
+
|
|
215
|
+
| Property | Type | Description |
|
|
216
|
+
|----------|------|-------------|
|
|
217
|
+
| `keys` | `DelegatedKeyData[]` | List of delegated keys. |
|
|
218
|
+
| `isLoading` | `boolean` | True while loading. |
|
|
219
|
+
| `error` | `string \| null` | Error message if load failed. |
|
|
220
|
+
| `refresh` | `() => Promise<void>` | Reload delegated keys. |
|
|
221
|
+
|
|
222
|
+
**Use when:** You need the list of delegated keys in custom UI or logic without using the DelegatedKeySelector component.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
#### useCanSign
|
|
227
|
+
|
|
228
|
+
Derived "is the user ready to sign?" for disabling sign buttons or showing prompts. Use inside `CilantroProvider`.
|
|
229
|
+
|
|
230
|
+
**Options:** `UseCanSignOptions`
|
|
231
|
+
|
|
232
|
+
| Option | Type | Description |
|
|
233
|
+
|--------|------|-------------|
|
|
234
|
+
| `signingMethod` | `SigningMethod \| null` | Override; default `'sdk-signer'`. |
|
|
235
|
+
| `requireSigner` | `boolean` | When true (default), require a selected signer for sdk-signer. |
|
|
236
|
+
| `walletAdapterConnected` | `boolean` | When using wallet-adapter, pass true when the adapter is connected so `canSign*` reflects it. |
|
|
237
|
+
|
|
238
|
+
**Returns:** `UseCanSignResult`
|
|
239
|
+
|
|
240
|
+
| Property | Type | Description |
|
|
241
|
+
|----------|------|-------------|
|
|
242
|
+
| `hasToken` | `boolean` | True when the user has a valid token. |
|
|
243
|
+
| `hasWallet` | `boolean` | True when a wallet is selected. |
|
|
244
|
+
| `hasSigner` | `boolean` | True when a signer is selected (sdk-signer) or wallet-adapter is connected (when `walletAdapterConnected` is passed). |
|
|
245
|
+
| `canSignMessage` | `boolean` | True when ready to sign a message. |
|
|
246
|
+
| `canSignTransaction` | `boolean` | True when ready to sign/send a transaction (connection still required for send). |
|
|
247
|
+
|
|
248
|
+
**Use when:** You need to disable sign buttons or show "Select wallet" / "Select signer" prompts without reimplementing token/wallet/signer checks. For wallet-adapter, pass `walletAdapterConnected` from your adapter state.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
159
252
|
#### useMessageSigning
|
|
160
253
|
|
|
161
254
|
Sign a message with the selected signer or wallet-adapter. Use inside `CilantroProvider`.
|
|
@@ -238,6 +331,11 @@ All components accept `className`. Many accept a `classNames` object (see TypeSc
|
|
|
238
331
|
| **AddSignerForm** | Add signer (email, phone, passkey, external wallet). | `walletId`, `open?`, `onOpenChange?`, `onSuccess?`, `onCancel?`, `onError?(error)`, `asDialog?` (default true), `className`, `classNames?`. |
|
|
239
332
|
| **DelegatedKeySelector** | Select delegated key for a wallet. | `walletId`, `value?`, `onChange?(keyId, key)`, `filterActive?` (default true), `placeholder`, `className`, `classNames?`. Headless: `children?` (keys, selectedKeyId, onSelect, isLoading, error, refresh). |
|
|
240
333
|
|
|
334
|
+
#### UI primitives
|
|
335
|
+
|
|
336
|
+
- **Skeleton** – Shadcn-style skeleton placeholder (`rounded-md bg-muted animate-pulse`). Use for loading states or custom UI. Exported for headless use.
|
|
337
|
+
- **ThemeProvider** – See [Themes](#built-in-theme-themeprovider).
|
|
338
|
+
|
|
241
339
|
#### Signing form components
|
|
242
340
|
|
|
243
341
|
| Component | Purpose | Key props |
|
|
@@ -636,9 +734,64 @@ See TypeScript types and [cilantro-sdk](https://www.npmjs.com/package/cilantro-s
|
|
|
636
734
|
|
|
637
735
|
## Theming
|
|
638
736
|
|
|
639
|
-
Components use Shadcn-style class names and CSS variables (e.g. `border-input`, `bg-primary`, `text-muted-foreground`). Ensure your app has Tailwind
|
|
737
|
+
Components use Shadcn-style class names and CSS variables (e.g. `border-input`, `bg-primary`, `text-muted-foreground`). Ensure your app has **Tailwind CSS** so utility classes work; the library does not bundle Tailwind.
|
|
738
|
+
|
|
739
|
+
### Built-in theme (ThemeProvider)
|
|
740
|
+
|
|
741
|
+
You can opt into a built-in light/dark theme without bringing your own Shadcn setup. Wrap your app (or just the Cilantro UI) with `ThemeProvider`:
|
|
742
|
+
|
|
743
|
+
```tsx
|
|
744
|
+
import { ThemeProvider } from 'cilantro-react'
|
|
745
|
+
|
|
746
|
+
<ThemeProvider theme="system" defaultTheme="dark" className="min-h-screen">
|
|
747
|
+
<CilantroProvider platformApiKey="...">
|
|
748
|
+
{children}
|
|
749
|
+
</CilantroProvider>
|
|
750
|
+
</ThemeProvider>
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
- **theme** – `"light"` | `"dark"` | `"system"`. `"system"` follows `prefers-color-scheme`.
|
|
754
|
+
- **defaultTheme** – Initial theme when using `"system"` (default: `"dark"`).
|
|
755
|
+
- **storageKey** – Optional localStorage key to persist the resolved theme when using `"system"`.
|
|
756
|
+
- **injectStyles** – When `true` (default), the provider injects a minimal set of CSS variables (`--background`, `--foreground`, `--primary`, `--muted`, `--border`, `--input`, `--ring`, etc.) for light and `[data-theme="dark"]`. You can set `injectStyles={false}` and import the theme file yourself: `import 'cilantro-react/themes/default.css'`.
|
|
757
|
+
|
|
758
|
+
Tailwind is still required so utility classes apply; ThemeProvider only sets the variables.
|
|
759
|
+
|
|
760
|
+
For full Shadcn theming, see [Theming - shadcn/ui](https://ui.shadcn.com/docs/theming).
|
|
761
|
+
|
|
762
|
+
---
|
|
763
|
+
|
|
764
|
+
## Accessibility
|
|
765
|
+
|
|
766
|
+
Components are built with screen readers and keyboard use in mind:
|
|
767
|
+
|
|
768
|
+
- **Live regions** – Signing result messages (MessageSigningForm, TransactionSigningForm) use `role="status"` and `aria-live="polite"` (or `assertive` for errors). Loading states use `aria-busy`.
|
|
769
|
+
- **Form labels** – Auth, login, register, message signing, and add-signer forms use visible labels with correct `id` / `htmlFor`. Error blocks use `role="alert"` so errors are announced immediately.
|
|
770
|
+
- **Selects and dialogs** – WalletSelector and DelegatedKeySelector triggers have `aria-label`. Radix Dialog handles focus trap and restore in AddSignerForm.
|
|
771
|
+
- **Loading** – WalletSelector, SignerSelector, SignerList, DelegatedKeySelector, and AuthGuard use `aria-busy` and `aria-live="polite"` when loading so screen readers announce loading state.
|
|
772
|
+
|
|
773
|
+
Buttons use `focus-visible:ring-2` for focus indication; icon-only or custom buttons can receive `aria-label` via standard HTML attributes.
|
|
774
|
+
|
|
775
|
+
---
|
|
776
|
+
|
|
777
|
+
## Mobile
|
|
778
|
+
|
|
779
|
+
Key actions use touch-friendly targets and dialogs are responsive:
|
|
780
|
+
|
|
781
|
+
- **Touch targets** – The Button component has a `touch` size (`min-h-[44px] min-w-[44px]`) used on primary actions: AuthForm/LoginForm/RegisterForm submit, MessageSigningForm sign button, and SignerList “Add signer”. Use `size="touch"` on your own primary buttons when needed.
|
|
782
|
+
- **Responsive layout** – Auth forms use `w-full max-w-sm`. MessageSigningForm and TransactionSigningForm use responsive button groups (`flex-col` on small screens). Result blocks use `overflow-auto` on `<pre>` so content doesn’t overflow.
|
|
783
|
+
- **Dialog** – DialogContent has `max-h-[100dvh] sm:max-h-[90vh]` and `overflow-y-auto` so dialogs (e.g. AddSignerForm) are scrollable on small screens. You can add `className="rounded-none sm:rounded-lg"` or full-height classes for a more mobile-friendly dialog.
|
|
784
|
+
|
|
785
|
+
---
|
|
786
|
+
|
|
787
|
+
## Loading states
|
|
788
|
+
|
|
789
|
+
Loading is shown with skeleton placeholders where it improves perceived performance:
|
|
640
790
|
|
|
641
|
-
|
|
791
|
+
- **Skeleton** – A `Skeleton` UI primitive is available (`import { Skeleton } from 'cilantro-react'`). Components use it when loading: WalletSelector and DelegatedKeySelector show a skeleton trigger; SignerSelector and SignerList show 2–3 skeleton rows.
|
|
792
|
+
- **useSkeleton** – WalletSelector, SignerSelector, SignerList, and DelegatedKeySelector accept an optional **useSkeleton** prop (default: `true`). Set `useSkeleton={false}` to show plain “Loading…” text instead.
|
|
793
|
+
- **classNames** – These components support `classNames.skeleton` and `classNames.loading` so you can style the skeleton or the loading container.
|
|
794
|
+
- **AuthGuard** – Optional skeleton while checking auth: set **useSkeleton={true}** to show a small skeleton card instead of “Loading…” text.
|
|
642
795
|
|
|
643
796
|
---
|
|
644
797
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React$1 from 'react';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
4
|
+
import { WalletControllerFindAllResult, WalletControllerListSignersResult, WalletControllerSubmitTransactionResult } from 'cilantro-sdk/wallet';
|
|
5
|
+
export { WalletControllerFindAllResult, WalletControllerFindOneResult, WalletControllerListSignersResult, WalletControllerSubmitTransactionResult } from 'cilantro-sdk/wallet';
|
|
3
6
|
import { SignerInfo } from 'cilantro-sdk/helpers';
|
|
7
|
+
import { DelegatedKeyControllerFindAllResult } from 'cilantro-sdk/delegated-keys';
|
|
8
|
+
export { DelegatedKeyControllerFindAllResult } from 'cilantro-sdk/delegated-keys';
|
|
4
9
|
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
10
|
+
export { AuthControllerLogin200Data } from 'cilantro-sdk/auth';
|
|
11
|
+
export { TransactionControllerSendRawPasskeyTransactionResult } from 'cilantro-sdk/transactions';
|
|
5
12
|
|
|
6
13
|
interface CilantroProviderProps {
|
|
7
14
|
children: ReactNode;
|
|
@@ -17,6 +24,7 @@ interface CilantroProviderProps {
|
|
|
17
24
|
}
|
|
18
25
|
declare function CilantroProvider({ children, platformApiKey, apiUrl, jwtStorageKey, walletStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, }: CilantroProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
26
|
|
|
27
|
+
/** Minimal user view; populated from SDK login result data.user when available. */
|
|
20
28
|
interface User {
|
|
21
29
|
username?: string;
|
|
22
30
|
email?: string;
|
|
@@ -43,16 +51,14 @@ interface CilantroAuthProviderProps {
|
|
|
43
51
|
declare function CilantroAuthProvider({ children, platformApiKey, apiUrl, jwtStorageKey, onLoginSuccess, onLogout, onRegisterSuccess, }: CilantroAuthProviderProps): react_jsx_runtime.JSX.Element;
|
|
44
52
|
declare function useCilantroAuth(): CilantroAuthContextType;
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
50
59
|
address?: string;
|
|
51
|
-
walletAddress?: string;
|
|
52
|
-
chain?: string;
|
|
53
60
|
active?: boolean;
|
|
54
|
-
|
|
55
|
-
}
|
|
61
|
+
};
|
|
56
62
|
interface WalletContextType {
|
|
57
63
|
selectedWallet: WalletData | null;
|
|
58
64
|
wallets: WalletData[];
|
|
@@ -67,6 +73,29 @@ interface WalletProviderProps {
|
|
|
67
73
|
declare function WalletProvider({ children, storageKey }: WalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
68
74
|
declare function useWallets(): WalletContextType;
|
|
69
75
|
|
|
76
|
+
interface UseSelectedWalletResult {
|
|
77
|
+
selectedWallet: WalletData | null;
|
|
78
|
+
isLoading: boolean;
|
|
79
|
+
refreshWallets: () => Promise<void>;
|
|
80
|
+
}
|
|
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;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns the address of the currently selected wallet.
|
|
90
|
+
* Handles both `address` and `walletAddress` on WalletData.
|
|
91
|
+
* Must be used inside CilantroProvider (WalletProvider).
|
|
92
|
+
*/
|
|
93
|
+
declare function useWalletAddress(): string | null;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Normalized signer shape aligned with SDK SignerDataDto / WalletSignerDataDto.
|
|
97
|
+
* Uses SDK field names (signerId, signerType, signerPubkey, authId); id is an alias for signerId or WalletSignerDataDto.id.
|
|
98
|
+
*/
|
|
70
99
|
interface SignerData extends Omit<SignerInfo, "signerId"> {
|
|
71
100
|
id: string;
|
|
72
101
|
signerId: string;
|
|
@@ -96,6 +125,60 @@ interface UseSignersResult {
|
|
|
96
125
|
}
|
|
97
126
|
declare function useSigners(options?: UseSignersOptions): UseSignersResult;
|
|
98
127
|
|
|
128
|
+
type SignersListResponseDto = WalletControllerListSignersResult;
|
|
129
|
+
interface UseSignersRawOptions {
|
|
130
|
+
/** Wallet ID to load signers for. When null/undefined, response is null. */
|
|
131
|
+
walletId?: string | null;
|
|
132
|
+
}
|
|
133
|
+
interface UseSignersRawResult {
|
|
134
|
+
/** Exact SDK response from listSigners (success, data: { authenticationSigners, onChainSigners }). */
|
|
135
|
+
signersRaw: SignersListResponseDto | null;
|
|
136
|
+
isLoading: boolean;
|
|
137
|
+
error: string | null;
|
|
138
|
+
refresh: () => Promise<void>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Load signers for a wallet and return the exact SDK shape (SignersListResponseDto).
|
|
142
|
+
* Use when you need SDK-exact output; for a normalized list use useSigners instead.
|
|
143
|
+
* Must be used inside CilantroProvider (auth required).
|
|
144
|
+
*/
|
|
145
|
+
declare function useSignersRaw(options?: UseSignersRawOptions): UseSignersRawResult;
|
|
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[];
|
|
172
|
+
isLoading: boolean;
|
|
173
|
+
error: string | null;
|
|
174
|
+
refresh: () => Promise<void>;
|
|
175
|
+
}
|
|
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
|
+
|
|
99
182
|
type SigningMethod = "wallet-adapter" | "sdk-signer";
|
|
100
183
|
interface UseSignerSelectionOptions {
|
|
101
184
|
/** Override wallet ID; if not set, uses selected wallet from WalletProvider */
|
|
@@ -114,6 +197,33 @@ interface UseSignerSelectionResult {
|
|
|
114
197
|
}
|
|
115
198
|
declare function useSignerSelection(options?: UseSignerSelectionOptions): UseSignerSelectionResult;
|
|
116
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
|
+
|
|
117
227
|
/**
|
|
118
228
|
* Type Utilities - common types and utilities for SDK interactions
|
|
119
229
|
*/
|
|
@@ -198,12 +308,16 @@ interface WalletSelectorClassNames {
|
|
|
198
308
|
trigger?: string;
|
|
199
309
|
content?: string;
|
|
200
310
|
item?: string;
|
|
311
|
+
skeleton?: string;
|
|
312
|
+
loading?: string;
|
|
201
313
|
}
|
|
202
314
|
interface WalletSelectorProps {
|
|
203
315
|
value?: string;
|
|
204
316
|
onWalletChange?: (walletId: string, wallet: WalletData | null) => void;
|
|
205
317
|
className?: string;
|
|
206
318
|
classNames?: WalletSelectorClassNames;
|
|
319
|
+
/** When true (default), show skeleton in trigger while loading; when false, show "Loading..." text. */
|
|
320
|
+
useSkeleton?: boolean;
|
|
207
321
|
placeholder?: string;
|
|
208
322
|
renderTrigger?: (props: {
|
|
209
323
|
selectedWallet: WalletData | null;
|
|
@@ -233,6 +347,8 @@ interface SignerSelectorClassNames {
|
|
|
233
347
|
list?: string;
|
|
234
348
|
item?: string;
|
|
235
349
|
message?: string;
|
|
350
|
+
skeleton?: string;
|
|
351
|
+
loading?: string;
|
|
236
352
|
}
|
|
237
353
|
interface SignerSelectorProps {
|
|
238
354
|
/** Wallet ID (signers are loaded for this wallet when used with useSigners) */
|
|
@@ -249,6 +365,8 @@ interface SignerSelectorProps {
|
|
|
249
365
|
className?: string;
|
|
250
366
|
/** Override class names for sub-elements */
|
|
251
367
|
classNames?: SignerSelectorClassNames;
|
|
368
|
+
/** When true (default), show skeleton rows while loading; when false, show "Loading signers..." text. */
|
|
369
|
+
useSkeleton?: boolean;
|
|
252
370
|
/** Custom list render (headless) */
|
|
253
371
|
renderList?: (props: {
|
|
254
372
|
signers: SignerData[];
|
|
@@ -267,25 +385,16 @@ interface SignerSelectorProps {
|
|
|
267
385
|
isLoading: boolean;
|
|
268
386
|
}) => React.ReactNode;
|
|
269
387
|
}
|
|
270
|
-
declare function SignerSelector({ selectedWalletId, availableSigners, selectedSigner, isLoadingSigners, onSignerSelect, className, classNames, renderList, children, }: SignerSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
388
|
+
declare function SignerSelector({ selectedWalletId, availableSigners, selectedSigner, isLoadingSigners, onSignerSelect, className, classNames, useSkeleton, renderList, children, }: SignerSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
271
389
|
|
|
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
390
|
interface DelegatedKeySelectorClassNames {
|
|
284
391
|
root?: string;
|
|
285
392
|
trigger?: string;
|
|
286
393
|
content?: string;
|
|
287
394
|
item?: string;
|
|
288
395
|
message?: string;
|
|
396
|
+
skeleton?: string;
|
|
397
|
+
loading?: string;
|
|
289
398
|
}
|
|
290
399
|
interface DelegatedKeySelectorProps {
|
|
291
400
|
walletId: string;
|
|
@@ -294,6 +403,8 @@ interface DelegatedKeySelectorProps {
|
|
|
294
403
|
filterActive?: boolean;
|
|
295
404
|
className?: string;
|
|
296
405
|
classNames?: DelegatedKeySelectorClassNames;
|
|
406
|
+
/** When true (default), show skeleton trigger while loading; when false, show "Loading delegated keys..." text. */
|
|
407
|
+
useSkeleton?: boolean;
|
|
297
408
|
placeholder?: string;
|
|
298
409
|
children?: (props: {
|
|
299
410
|
keys: DelegatedKeyData[];
|
|
@@ -500,6 +611,8 @@ declare function AuthForm({ defaultMode, className, classNames, onSuccess, onErr
|
|
|
500
611
|
interface AuthGuardClassNames {
|
|
501
612
|
root?: string;
|
|
502
613
|
fallback?: string;
|
|
614
|
+
skeleton?: string;
|
|
615
|
+
loading?: string;
|
|
503
616
|
}
|
|
504
617
|
interface AuthGuardProps {
|
|
505
618
|
children: ReactNode;
|
|
@@ -510,12 +623,14 @@ interface AuthGuardProps {
|
|
|
510
623
|
classNames?: AuthGuardClassNames;
|
|
511
624
|
/** When true, show fallback (login) instead of children when unauthenticated. When false, render null when unauthenticated. */
|
|
512
625
|
showFallback?: boolean;
|
|
626
|
+
/** When true, show a small skeleton card while loading; when false (default), show "Loading..." text. */
|
|
627
|
+
useSkeleton?: boolean;
|
|
513
628
|
}
|
|
514
629
|
/**
|
|
515
630
|
* Wraps content and shows fallback (e.g. LoginForm) when the user is not authenticated.
|
|
516
631
|
* Use inside CilantroAuthProvider.
|
|
517
632
|
*/
|
|
518
|
-
declare function AuthGuard({ children, fallback, className, classNames, showFallback, }: AuthGuardProps): react_jsx_runtime.JSX.Element | null;
|
|
633
|
+
declare function AuthGuard({ children, fallback, className, classNames, showFallback, useSkeleton, }: AuthGuardProps): react_jsx_runtime.JSX.Element | null;
|
|
519
634
|
|
|
520
635
|
type AddSignerType = "email" | "phone" | "passkey" | "external";
|
|
521
636
|
interface AddSignerFormClassNames {
|
|
@@ -549,6 +664,8 @@ interface SignerListClassNames {
|
|
|
549
664
|
item?: string;
|
|
550
665
|
addButton?: string;
|
|
551
666
|
message?: string;
|
|
667
|
+
skeleton?: string;
|
|
668
|
+
loading?: string;
|
|
552
669
|
}
|
|
553
670
|
interface SignerListProps {
|
|
554
671
|
walletId: string;
|
|
@@ -556,6 +673,8 @@ interface SignerListProps {
|
|
|
556
673
|
classNames?: SignerListClassNames;
|
|
557
674
|
/** Callback when a signer is added (e.g. to refresh parent state) */
|
|
558
675
|
onSignerAdded?: () => void;
|
|
676
|
+
/** When true (default), show skeleton rows while loading; when false, show "Loading signers..." text. */
|
|
677
|
+
useSkeleton?: boolean;
|
|
559
678
|
/** Custom render for the list of signers */
|
|
560
679
|
children?: (props: {
|
|
561
680
|
signers: SignerData[];
|
|
@@ -565,18 +684,44 @@ interface SignerListProps {
|
|
|
565
684
|
openAddSigner: () => void;
|
|
566
685
|
}) => React.ReactNode;
|
|
567
686
|
}
|
|
568
|
-
declare function SignerList({ walletId, className, classNames, onSignerAdded, children, }: SignerListProps): react_jsx_runtime.JSX.Element;
|
|
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;
|
|
569
709
|
|
|
570
710
|
declare function extractErrorMessage(error: unknown): string;
|
|
571
711
|
|
|
572
712
|
declare function getSignerPublicKey(walletId: string, signer: SignerData, signerType: string, signerId: string): Promise<PublicKey>;
|
|
573
713
|
|
|
574
|
-
|
|
714
|
+
/** Result shape aligned with SDK SignMessageDataDto (signature base64, message) plus optional helper fields. */
|
|
715
|
+
interface SignMessageResult {
|
|
716
|
+
/** Signature in base64 (SDK SignMessageDataDto shape). */
|
|
575
717
|
signature: string;
|
|
718
|
+
/** Original message that was signed (SDK SignMessageDataDto shape). */
|
|
719
|
+
message: string;
|
|
576
720
|
publicKey?: string;
|
|
577
721
|
signerType: string;
|
|
578
722
|
signer?: string;
|
|
579
|
-
}
|
|
723
|
+
}
|
|
724
|
+
declare function signMessageWithSigner(walletId: string, signer: SignerData, messageText: string): Promise<SignMessageResult>;
|
|
580
725
|
|
|
581
726
|
/** Connection-like interface for sign-and-send (passkey). Consumer provides from their Solana config. */
|
|
582
727
|
interface SignAndSendConnection {
|
|
@@ -590,14 +735,19 @@ interface SignAndSendConnection {
|
|
|
590
735
|
lastValidBlockHeight: number;
|
|
591
736
|
}) => Promise<void>;
|
|
592
737
|
}
|
|
738
|
+
/** SDK submit transaction data (SubmitTransactionResponseDto.data). */
|
|
739
|
+
type SubmitTransactionDataDto = WalletControllerSubmitTransactionResult["data"];
|
|
593
740
|
declare function signTransactionWithSigner(walletId: string, signer: SignerData, transactionBuffer: Uint8Array): Promise<{
|
|
594
741
|
signature: string;
|
|
595
742
|
signerType: string;
|
|
596
743
|
}>;
|
|
597
|
-
|
|
744
|
+
/** Result of sign-and-send; status is the SDK SubmitTransactionDataDto.status, confirmationStatus is the same for backward compat. */
|
|
745
|
+
interface SignAndSendResult {
|
|
598
746
|
signature: string;
|
|
747
|
+
status: string;
|
|
599
748
|
confirmationStatus: string;
|
|
600
|
-
}
|
|
749
|
+
}
|
|
750
|
+
declare function signAndSendTransactionWithSigner(walletId: string, signer: SignerData, transaction: Transaction, connection?: SignAndSendConnection | null): Promise<SignAndSendResult>;
|
|
601
751
|
|
|
602
752
|
declare function getWalletData(walletId: string): Promise<{
|
|
603
753
|
walletPublicKey: PublicKey;
|
|
@@ -613,4 +763,4 @@ declare const SIGNER_TYPES: {
|
|
|
613
763
|
};
|
|
614
764
|
type SignerType = (typeof SIGNER_TYPES)[keyof typeof SIGNER_TYPES];
|
|
615
765
|
|
|
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 };
|
|
766
|
+
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, type DelegatedKeyDataDto, DelegatedKeySelector, type DelegatedKeySelectorClassNames, type DelegatedKeySelectorProps, type ErrorResponse, LoginForm, type LoginFormClassNames, type LoginFormProps, MessageSigningForm, type MessageSigningFormClassNames, type MessageSigningFormProps, RegisterForm, type RegisterFormClassNames, type RegisterFormProps, type ResolvedTheme, SIGNER_TYPES, type SignAndSendConnection, type SignAndSendResult, type SignMessageResult, type SignerData, SignerList, type SignerListClassNames, type SignerListProps, SignerSelector, type SignerSelectorClassNames, type SignerSelectorProps, type SignerType, type SignersListResponseDto, type SigningMethod, Skeleton, type SubmitTransactionDataDto, type Theme, ThemeProvider, type ThemeProviderProps, TransactionSigningForm, type TransactionSigningFormClassNames, type TransactionSigningFormProps, type UseCanSignOptions, type UseCanSignResult, type UseDelegatedKeysOptions, type UseDelegatedKeysResult, type UseMessageSigningOptions, type UseMessageSigningResult, type UseSelectedWalletResult, type UseSignerSelectionOptions, type UseSignerSelectionResult, type UseSignersForSelectedWalletOptions, type UseSignersOptions, type UseSignersRawOptions, type UseSignersRawResult, type UseSignersResult, type UseTransactionSigningOptions, type UseTransactionSigningResult, type User, type WalletContextType, type WalletData, type WalletDataDto, WalletProvider, type WalletProviderProps, WalletSelector, type WalletSelectorClassNames, type WalletSelectorProps, extractErrorMessage, extractResponseData, getSignerPublicKey, getWalletData, signAndSendTransactionWithSigner, signMessageWithSigner, signTransactionWithSigner, useCanSign, useCilantroAuth, useDelegatedKeys, useMessageSigning, useSelectedWallet, useSignerSelection, useSigners, useSignersForSelectedWallet, useSignersRaw, useTransactionSigning, useWalletAddress, useWallets };
|