@wallet-ui/react 4.0.5 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,27 +1,32 @@
1
- import React18, { createContext, useContext, useEffect, useId, useMemo, useState, useCallback } from 'react';
1
+ import React19, { createContext, useContext, useEffect, useId, useMemo, useState, useCallback } from 'react';
2
2
  import { useConnect, useDisconnect, useWallets, getUiWalletAccountStorageKey, uiWalletAccountsAreSame, uiWalletAccountBelongsToUiWallet } from '@wallet-standard/react';
3
3
  export * from '@wallet-standard/react';
4
4
  import { Portal, useMachine, normalizeProps } from '@zag-js/react';
5
5
  import * as menu from '@zag-js/menu';
6
6
  import * as dialog from '@zag-js/dialog';
7
- import { useWalletAccountTransactionSendingSigner } from '@solana/react';
7
+ import { SolanaSignMessage, SolanaSignIn } from '@solana/wallet-standard-features';
8
+ export * from '@solana/wallet-standard-features';
9
+ import { createSignInMessage } from '@solana/wallet-standard-util';
10
+ import { uiWalletAccountBelongsToUiWallet as uiWalletAccountBelongsToUiWallet$1, getWalletAccountFeature, getWalletFeature } from '@wallet-standard/ui';
11
+ export { getWalletAccountFeature, getWalletFeature, uiWalletAccountBelongsToUiWallet, uiWalletAccountsAreSame } from '@wallet-standard/ui';
12
+ import { getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from '@wallet-standard/ui-registry';
13
+ import { useWalletAccountTransactionSendingSigner, useSignMessage } from '@solana/react';
8
14
  export * from '@solana/react';
9
15
  import { useStore } from '@nanostores/react';
10
16
  import { createStorageAccount, createStorageCluster, handleCopyText } from '@wallet-ui/core';
11
17
  export * from '@wallet-ui/core';
12
- export * from '@solana/wallet-standard-features';
18
+ import { StandardConnect } from '@wallet-standard/core';
13
19
  export * from '@wallet-standard/core';
14
- export { getWalletAccountFeature, getWalletFeature, uiWalletAccountBelongsToUiWallet, uiWalletAccountsAreSame } from '@wallet-standard/ui';
15
20
 
16
21
  // src/base-button.tsx
17
22
  function BaseButton({ className, label, leftSection, onClick, rightSection, ...props }) {
18
- return /* @__PURE__ */ React18.createElement("button", { "data-wu": "base-button", className: `${className ?? ""}`, onClick, ...props }, leftSection ? /* @__PURE__ */ React18.createElement("span", { "data-wu": "base-button-left-section" }, leftSection) : null, label, rightSection ? /* @__PURE__ */ React18.createElement("span", { "data-wu": "base-button-right-section" }, rightSection) : null);
23
+ return /* @__PURE__ */ React19.createElement("button", { "data-wu": "base-button", className: `${className ?? ""}`, onClick, ...props }, leftSection ? /* @__PURE__ */ React19.createElement("span", { "data-wu": "base-button-left-section" }, leftSection) : null, label, rightSection ? /* @__PURE__ */ React19.createElement("span", { "data-wu": "base-button-right-section" }, rightSection) : null);
19
24
  }
20
- var WalletUiContext = React18.createContext({});
25
+ var WalletUiContext = React19.createContext({});
21
26
 
22
27
  // src/use-wallet-ui.tsx
23
28
  function useWalletUi() {
24
- return React18.useContext(WalletUiContext);
29
+ return React19.useContext(WalletUiContext);
25
30
  }
26
31
  var WalletUiAccountContext = createContext({});
27
32
 
@@ -59,7 +64,7 @@ function WalletUiIcon({ className, wallet, ...props }) {
59
64
  if (!wallet) {
60
65
  return null;
61
66
  }
62
- return /* @__PURE__ */ React18.createElement("img", { "data-wu": "wallet-ui-icon", src: wallet.icon, alt: wallet.name, className: className ?? "", ...props });
67
+ return /* @__PURE__ */ React19.createElement("img", { "data-wu": "wallet-ui-icon", src: wallet.icon, alt: wallet.name, className: className ?? "", ...props });
63
68
  }
64
69
 
65
70
  // src/base-dropdown.tsx
@@ -73,16 +78,16 @@ var BaseDropdownItemType = /* @__PURE__ */ ((BaseDropdownItemType2) => {
73
78
  })(BaseDropdownItemType || {});
74
79
  function BaseDropdown({ buttonProps, dropdown, items, showIndicator }) {
75
80
  const api = dropdown.api;
76
- const trigger = /* @__PURE__ */ React18.createElement(
81
+ const trigger = /* @__PURE__ */ React19.createElement(
77
82
  BaseButton,
78
83
  {
79
84
  ...api.getTriggerProps(),
80
- rightSection: showIndicator ? /* @__PURE__ */ React18.createElement("span", { ...api.getIndicatorProps() }, /* @__PURE__ */ React18.createElement(BaseDropdownChevronDown, null)) : null,
85
+ rightSection: showIndicator ? /* @__PURE__ */ React19.createElement("span", { ...api.getIndicatorProps() }, /* @__PURE__ */ React19.createElement(BaseDropdownChevronDown, null)) : null,
81
86
  ...buttonProps
82
87
  }
83
88
  );
84
- return /* @__PURE__ */ React18.createElement("div", { "data-wu": "base-dropdown" }, trigger, /* @__PURE__ */ React18.createElement("div", { ...api.getPositionerProps(), "data-wu": "base-dropdown-wrapper" }, /* @__PURE__ */ React18.createElement("div", { ...api.getContentProps(), "data-wu": "base-dropdown-list", "data-part": "content" }, items.map((item) => {
85
- return /* @__PURE__ */ React18.createElement(
89
+ return /* @__PURE__ */ React19.createElement("div", { "data-wu": "base-dropdown" }, trigger, /* @__PURE__ */ React19.createElement("div", { ...api.getPositionerProps(), "data-wu": "base-dropdown-wrapper" }, /* @__PURE__ */ React19.createElement("div", { ...api.getContentProps(), "data-wu": "base-dropdown-list", "data-part": "content" }, items.map((item) => {
90
+ return /* @__PURE__ */ React19.createElement(
86
91
  BaseDropdownItem,
87
92
  {
88
93
  ...api.getItemProps({ value: item.value }),
@@ -102,17 +107,17 @@ function BaseDropdown({ buttonProps, dropdown, items, showIndicator }) {
102
107
  }
103
108
  function BaseDropdownItem({ afterClick, item }) {
104
109
  if (!item.wallet) {
105
- return /* @__PURE__ */ React18.createElement(BaseDropdownItemRender, { afterClick, item });
110
+ return /* @__PURE__ */ React19.createElement(BaseDropdownItemRender, { afterClick, item });
106
111
  }
107
112
  switch (item.type) {
108
113
  case "Item" /* Item */:
109
- return /* @__PURE__ */ React18.createElement(BaseDropdownItemRender, { afterClick, item });
114
+ return /* @__PURE__ */ React19.createElement(BaseDropdownItemRender, { afterClick, item });
110
115
  case "WalletConnect" /* WalletConnect */:
111
- return /* @__PURE__ */ React18.createElement(BaseDropdownItemWalletConnect, { afterClick, item, wallet: item.wallet });
116
+ return /* @__PURE__ */ React19.createElement(BaseDropdownItemWalletConnect, { afterClick, item, wallet: item.wallet });
112
117
  case "WalletCopy" /* WalletCopy */:
113
- return /* @__PURE__ */ React18.createElement(BaseDropdownItemRender, { afterClick, item });
118
+ return /* @__PURE__ */ React19.createElement(BaseDropdownItemRender, { afterClick, item });
114
119
  case "WalletDisconnect" /* WalletDisconnect */:
115
- return /* @__PURE__ */ React18.createElement(BaseDropdownItemWalletDisconnect, { afterClick, item, wallet: item.wallet });
120
+ return /* @__PURE__ */ React19.createElement(BaseDropdownItemWalletDisconnect, { afterClick, item, wallet: item.wallet });
116
121
  }
117
122
  }
118
123
  function BaseDropdownItemWalletConnect({
@@ -121,7 +126,7 @@ function BaseDropdownItemWalletConnect({
121
126
  wallet
122
127
  }) {
123
128
  const { connect: connect3 } = useWalletUiWallet({ wallet });
124
- return /* @__PURE__ */ React18.createElement(
129
+ return /* @__PURE__ */ React19.createElement(
125
130
  BaseDropdownItemRender,
126
131
  {
127
132
  afterClick,
@@ -131,7 +136,7 @@ function BaseDropdownItemWalletConnect({
131
136
  await connect3();
132
137
  return await item.handler();
133
138
  },
134
- leftSection: wallet ? /* @__PURE__ */ React18.createElement(WalletUiIcon, { wallet }) : void 0
139
+ leftSection: wallet ? /* @__PURE__ */ React19.createElement(WalletUiIcon, { wallet }) : void 0
135
140
  }
136
141
  }
137
142
  );
@@ -142,7 +147,7 @@ function BaseDropdownItemWalletDisconnect({
142
147
  wallet
143
148
  }) {
144
149
  const { disconnect } = useWalletUiWallet({ wallet });
145
- return /* @__PURE__ */ React18.createElement(
150
+ return /* @__PURE__ */ React19.createElement(
146
151
  BaseDropdownItemRender,
147
152
  {
148
153
  afterClick,
@@ -165,10 +170,10 @@ function BaseDropdownItemRender({ afterClick, item }) {
165
170
  afterClick();
166
171
  });
167
172
  }
168
- return /* @__PURE__ */ React18.createElement("button", { type: "button", "data-wu": "base-dropdown-item", "data-part": "item", onClick }, item.leftSection ? /* @__PURE__ */ React18.createElement("span", { "data-wu": "base-dropdown-item-left-section" }, item.leftSection) : null, item.label, item.rightSection ? /* @__PURE__ */ React18.createElement("span", { "data-wu": "base-dropdown-item-right-section" }, item.rightSection) : null);
173
+ return /* @__PURE__ */ React19.createElement("button", { type: "button", "data-wu": "base-dropdown-item", "data-part": "item", onClick }, item.leftSection ? /* @__PURE__ */ React19.createElement("span", { "data-wu": "base-dropdown-item-left-section" }, item.leftSection) : null, item.label, item.rightSection ? /* @__PURE__ */ React19.createElement("span", { "data-wu": "base-dropdown-item-right-section" }, item.rightSection) : null);
169
174
  }
170
175
  function BaseDropdownChevronDown(props) {
171
- return /* @__PURE__ */ React18.createElement(
176
+ return /* @__PURE__ */ React19.createElement(
172
177
  "svg",
173
178
  {
174
179
  xmlns: "http://www.w3.org/2000/svg",
@@ -182,16 +187,16 @@ function BaseDropdownChevronDown(props) {
182
187
  strokeLinejoin: "round",
183
188
  ...props
184
189
  },
185
- /* @__PURE__ */ React18.createElement("path", { d: "m6 9 6 6 6-6" })
190
+ /* @__PURE__ */ React19.createElement("path", { d: "m6 9 6 6 6-6" })
186
191
  );
187
192
  }
188
193
  function BaseSvg({ ...props }) {
189
- return /* @__PURE__ */ React18.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", ...props }, props.children);
194
+ return /* @__PURE__ */ React19.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", ...props }, props.children);
190
195
  }
191
196
 
192
197
  // src/wallet-ui-icon-close.tsx
193
198
  function WalletUiIconClose({ ...props }) {
194
- return /* @__PURE__ */ React18.createElement(
199
+ return /* @__PURE__ */ React19.createElement(
195
200
  BaseSvg,
196
201
  {
197
202
  fill: "none",
@@ -202,14 +207,14 @@ function WalletUiIconClose({ ...props }) {
202
207
  viewBox: "0 0 14 14",
203
208
  ...props
204
209
  },
205
- /* @__PURE__ */ React18.createElement("path", { d: "M14 12.461 8.3 6.772l5.234-5.233L12.006 0 6.772 5.234 1.54 0 0 1.539l5.234 5.233L0 12.006l1.539 1.528L6.772 8.3l5.69 5.7L14 12.461z" })
210
+ /* @__PURE__ */ React19.createElement("path", { d: "M14 12.461 8.3 6.772l5.234-5.233L12.006 0 6.772 5.234 1.54 0 0 1.539l5.234 5.233L0 12.006l1.539 1.528L6.772 8.3l5.69 5.7L14 12.461z" })
206
211
  );
207
212
  }
208
213
 
209
214
  // src/base-modal.tsx
210
215
  function BaseModal({ modal, buttonLabel, buttonProps = {}, ...props }) {
211
216
  const api = modal.api;
212
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, buttonLabel ? /* @__PURE__ */ React18.createElement(BaseButton, { label: buttonLabel, ...buttonProps, ...api.getTriggerProps() }) : null, api.open && /* @__PURE__ */ React18.createElement(Portal, null, /* @__PURE__ */ React18.createElement("div", { ...api.getBackdropProps() }), /* @__PURE__ */ React18.createElement("div", { ...api.getPositionerProps() }, /* @__PURE__ */ React18.createElement("div", { ...api.getContentProps() }, /* @__PURE__ */ React18.createElement("header", null, /* @__PURE__ */ React18.createElement("button", { ...api.getCloseTriggerProps() }, /* @__PURE__ */ React18.createElement(WalletUiIconClose, null))), props.description ? /* @__PURE__ */ React18.createElement("p", { ...api.getDescriptionProps() }, props.description) : null, /* @__PURE__ */ React18.createElement("main", null, props.children)))));
217
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, buttonLabel ? /* @__PURE__ */ React19.createElement(BaseButton, { label: buttonLabel, ...buttonProps, ...api.getTriggerProps() }) : null, api.open && /* @__PURE__ */ React19.createElement(Portal, null, /* @__PURE__ */ React19.createElement("div", { ...api.getBackdropProps() }), /* @__PURE__ */ React19.createElement("div", { ...api.getPositionerProps() }, /* @__PURE__ */ React19.createElement("div", { ...api.getContentProps() }, /* @__PURE__ */ React19.createElement("header", null, /* @__PURE__ */ React19.createElement("button", { ...api.getCloseTriggerProps() }, /* @__PURE__ */ React19.createElement(WalletUiIconClose, null))), props.description ? /* @__PURE__ */ React19.createElement("p", { ...api.getDescriptionProps() }, props.description) : null, /* @__PURE__ */ React19.createElement("main", null, props.children)))));
213
218
  }
214
219
  function useBaseDropdown() {
215
220
  const service = useMachine(menu.machine, { id: useId() });
@@ -229,6 +234,232 @@ function useBaseModal() {
229
234
  open: () => service.send({ type: "OPEN" })
230
235
  };
231
236
  }
237
+
238
+ // src/wallet-ui-auth-types.ts
239
+ var AUTH_ERROR_MESSAGES = {
240
+ "auth-unsupported": "The selected wallet does not support Sign In With Solana or message signing.",
241
+ "message-signing-unavailable": "The selected wallet account does not support message signing.",
242
+ "missing-domain": "A Sign In With Solana fallback message requires a domain.",
243
+ "wallet-not-connected": "Connect a wallet account before signing in."
244
+ };
245
+ var WalletUiAuthError = class extends Error {
246
+ cause;
247
+ reason;
248
+ constructor(reason, cause) {
249
+ super(AUTH_ERROR_MESSAGES[reason]);
250
+ this.cause = cause;
251
+ this.name = "WalletUiAuthError";
252
+ this.reason = reason;
253
+ }
254
+ };
255
+ var getOrCreateUiWalletAccountForStandardWalletAccount = getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
256
+ var getWalletAccountForUiWalletAccount = getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
257
+ var getWalletForHandle = getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
258
+
259
+ // src/wallet-ui-auth-utils.ts
260
+ function getTargetAccount(account, wallet) {
261
+ if (account && uiWalletAccountBelongsToUiWallet$1(account, wallet)) {
262
+ return account;
263
+ }
264
+ return void 0;
265
+ }
266
+ function hasFeature(handle, featureName) {
267
+ return Boolean(handle && handle.features.includes(featureName));
268
+ }
269
+ async function signInWithMessageFeature({
270
+ account,
271
+ input
272
+ }) {
273
+ const messageSignInInput = getMessageSignInInput(account, input);
274
+ const { signMessage } = getWalletAccountFeature(
275
+ account,
276
+ SolanaSignMessage
277
+ );
278
+ const walletAccount = getWalletAccountForUiWalletAccount(account);
279
+ const [output] = await signMessage({ account: walletAccount, message: createSignInMessage(messageSignInInput) });
280
+ if (!output) {
281
+ throw new WalletUiAuthError("message-signing-unavailable");
282
+ }
283
+ return getMessageSignInResult({ account, input: messageSignInInput, output });
284
+ }
285
+ async function signInWithMessageSigner({
286
+ account,
287
+ input,
288
+ signMessage
289
+ }) {
290
+ const messageSignInInput = getMessageSignInInput(account, input);
291
+ const output = await signMessage({ message: createSignInMessage(messageSignInInput) });
292
+ return getMessageSignInResult({ account, input: messageSignInInput, output });
293
+ }
294
+ function getMessageSignInResult({
295
+ account,
296
+ input,
297
+ output
298
+ }) {
299
+ return {
300
+ account,
301
+ input,
302
+ method: SolanaSignMessage,
303
+ signature: output.signature,
304
+ signedMessage: output.signedMessage
305
+ };
306
+ }
307
+ async function signInWithNativeFeature({
308
+ account,
309
+ connect: connect3,
310
+ input,
311
+ wallet
312
+ }) {
313
+ const signInInput = account?.address && !input.address ? { ...input, address: account.address } : { ...input };
314
+ const { signIn } = getWalletFeature(wallet, SolanaSignIn);
315
+ const [output] = await signIn(signInInput);
316
+ if (!output) {
317
+ throw new WalletUiAuthError("auth-unsupported");
318
+ }
319
+ const uiAccount = getUiWalletAccountForSignedInAccount({ account, output, wallet });
320
+ if (wallet.accounts.includes(uiAccount)) {
321
+ connect3(uiAccount);
322
+ }
323
+ return {
324
+ account: uiAccount,
325
+ input: signInInput,
326
+ method: SolanaSignIn,
327
+ signature: output.signature,
328
+ signedMessage: output.signedMessage
329
+ };
330
+ }
331
+ function getUiWalletAccountForSignedInAccount({
332
+ account,
333
+ output,
334
+ wallet
335
+ }) {
336
+ const matchingCurrentAccount = account?.address === output.account.address ? account : void 0;
337
+ return wallet.accounts.find((walletAccount) => walletAccount.address === output.account.address) ?? matchingCurrentAccount ?? getOrCreateUiWalletAccountForStandardWalletAccount(getWalletForHandle(wallet), output.account);
338
+ }
339
+ function getLocationHost() {
340
+ if (typeof location === "undefined") {
341
+ return void 0;
342
+ }
343
+ return location.host || void 0;
344
+ }
345
+ function getMessageSignInInput(account, input) {
346
+ const domain = input.domain ?? getLocationHost();
347
+ if (!domain) {
348
+ throw new WalletUiAuthError("missing-domain");
349
+ }
350
+ return {
351
+ ...input,
352
+ address: account.address,
353
+ domain
354
+ };
355
+ }
356
+
357
+ // src/use-wallet-ui-auth-message.ts
358
+ function useWalletUiAuthMessage({
359
+ account,
360
+ enabled = Boolean(account),
361
+ reason = account ? "message-signing-unavailable" : "wallet-not-connected",
362
+ signMessage
363
+ }) {
364
+ const [isSigningIn, setIsSigningIn] = useState(false);
365
+ const canSignIn = Boolean(enabled && account);
366
+ const unavailableReason = account ? reason : "wallet-not-connected";
367
+ const signIn = useCallback(
368
+ async ({ input = {} } = {}) => {
369
+ if (!canSignIn || !account) {
370
+ throw new WalletUiAuthError(unavailableReason);
371
+ }
372
+ setIsSigningIn(true);
373
+ try {
374
+ if (signMessage) {
375
+ return await signInWithMessageSigner({
376
+ account,
377
+ input,
378
+ signMessage
379
+ });
380
+ }
381
+ return await signInWithMessageFeature({
382
+ account,
383
+ input
384
+ });
385
+ } finally {
386
+ setIsSigningIn(false);
387
+ }
388
+ },
389
+ [account, canSignIn, signMessage, unavailableReason]
390
+ );
391
+ return {
392
+ canSignIn,
393
+ isSigningIn,
394
+ messageSigningAvailable: canSignIn,
395
+ nativeSignInAvailable: false,
396
+ reason: canSignIn ? void 0 : unavailableReason,
397
+ signIn
398
+ };
399
+ }
400
+ function useWalletUiAuthNative({ enabled = true, wallet }) {
401
+ const { account, connect: connect3 } = useWalletUi();
402
+ const [isSigningIn, setIsSigningIn] = useState(false);
403
+ const targetAccount = getTargetAccount(account, wallet);
404
+ const messageSigningAvailable = hasFeature(targetAccount, SolanaSignMessage);
405
+ const signIn = useCallback(
406
+ async ({ input = {} } = {}) => {
407
+ if (!enabled) {
408
+ throw new WalletUiAuthError("auth-unsupported");
409
+ }
410
+ setIsSigningIn(true);
411
+ try {
412
+ return await signInWithNativeFeature({
413
+ account: targetAccount,
414
+ connect: connect3,
415
+ input,
416
+ wallet
417
+ });
418
+ } finally {
419
+ setIsSigningIn(false);
420
+ }
421
+ },
422
+ [connect3, enabled, targetAccount, wallet]
423
+ );
424
+ return {
425
+ canSignIn: enabled,
426
+ isSigningIn,
427
+ messageSigningAvailable,
428
+ nativeSignInAvailable: enabled,
429
+ reason: enabled ? void 0 : "auth-unsupported",
430
+ signIn
431
+ };
432
+ }
433
+
434
+ // src/use-wallet-ui-auth.tsx
435
+ function useWalletUiAuth({ wallet }) {
436
+ const { account } = useWalletUi();
437
+ const targetAccount = getTargetAccount(account, wallet);
438
+ const nativeSignInAvailable = hasFeature(wallet, SolanaSignIn);
439
+ const messageSigningAvailable = Boolean(targetAccount && hasFeature(targetAccount, SolanaSignMessage));
440
+ const nativeAuth = useWalletUiAuthNative({ enabled: nativeSignInAvailable, wallet });
441
+ const messageAuth = useWalletUiAuthMessage({
442
+ account: targetAccount,
443
+ enabled: messageSigningAvailable,
444
+ reason: targetAccount ? "message-signing-unavailable" : "wallet-not-connected"});
445
+ if (nativeSignInAvailable) {
446
+ return nativeAuth;
447
+ }
448
+ if (messageSigningAvailable) {
449
+ return messageAuth;
450
+ }
451
+ const reason = targetAccount || !hasFeature(wallet, SolanaSignMessage) ? "auth-unsupported" : "wallet-not-connected";
452
+ return {
453
+ canSignIn: false,
454
+ isSigningIn: false,
455
+ messageSigningAvailable: false,
456
+ nativeSignInAvailable: false,
457
+ reason,
458
+ signIn() {
459
+ return Promise.reject(new WalletUiAuthError(reason));
460
+ }
461
+ };
462
+ }
232
463
  var WalletUiClusterContext = createContext({});
233
464
 
234
465
  // src/use-wallet-ui-cluster.tsx
@@ -300,7 +531,7 @@ function useWalletUiDropdown() {
300
531
  const buttonProps = useMemo(() => {
301
532
  return {
302
533
  label: connected ? (account ? ellipsify(account.address) : wallet?.name) ?? "Connected" : "Select Wallet",
303
- leftSection: connected ? /* @__PURE__ */ React18.createElement(WalletUiIcon, { wallet }) : void 0
534
+ leftSection: connected ? /* @__PURE__ */ React19.createElement(WalletUiIcon, { wallet }) : void 0
304
535
  };
305
536
  }, [account, connected, wallet]);
306
537
  return {
@@ -411,7 +642,7 @@ function WalletUiAccountContextProvider({ children, cluster, storage }) {
411
642
  }
412
643
  return [cluster.id, getUiWalletAccountStorageKey(walletAccount)].filter(Boolean);
413
644
  }, [walletAccount, cluster.id]);
414
- return /* @__PURE__ */ React18.createElement(
645
+ return /* @__PURE__ */ React19.createElement(
415
646
  WalletUiAccountContext.Provider,
416
647
  {
417
648
  value: useMemo(
@@ -450,7 +681,7 @@ function WalletUiClusterContextProvider({ clusters, render, storage }) {
450
681
  }),
451
682
  [clusters, first, found, storage]
452
683
  );
453
- return /* @__PURE__ */ React18.createElement(WalletUiClusterContext.Provider, { value }, render(value));
684
+ return /* @__PURE__ */ React19.createElement(WalletUiClusterContext.Provider, { value }, render(value));
454
685
  }
455
686
  function WalletUiContextProvider({ children }) {
456
687
  const { account, accountKeys, cluster, setAccount, wallet } = useWalletUiAccount();
@@ -475,7 +706,7 @@ function WalletUiContextProvider({ children }) {
475
706
  }),
476
707
  [account, accountKeys, cluster, setAccount, connected, wallet, wallets]
477
708
  );
478
- return /* @__PURE__ */ React18.createElement(WalletUiContext.Provider, { value }, children);
709
+ return /* @__PURE__ */ React19.createElement(WalletUiContext.Provider, { value }, children);
479
710
  }
480
711
 
481
712
  // src/wallet-ui.tsx
@@ -483,31 +714,102 @@ function createWalletUiConfig(props) {
483
714
  return { ...props };
484
715
  }
485
716
  function WalletUi({ children, config: { accountStorage, clusters, clusterStorage, ...config } }) {
486
- return /* @__PURE__ */ React18.createElement(
717
+ return /* @__PURE__ */ React19.createElement(
487
718
  WalletUiClusterContextProvider,
488
719
  {
489
720
  clusters,
490
721
  storage: clusterStorage,
491
722
  render: ({ cluster }) => {
492
- return /* @__PURE__ */ React18.createElement(WalletUiAccountContextProvider, { cluster, storage: accountStorage }, /* @__PURE__ */ React18.createElement(WalletUiContextProvider, { ...config }, children));
723
+ return /* @__PURE__ */ React19.createElement(WalletUiAccountContextProvider, { cluster, storage: accountStorage }, /* @__PURE__ */ React19.createElement(WalletUiContextProvider, { ...config }, children));
493
724
  }
494
725
  }
495
726
  );
496
727
  }
497
728
  function WalletUiDropdown({ ...props }) {
498
729
  const { buttonProps, items, dropdown } = useWalletUiDropdown();
499
- return /* @__PURE__ */ React18.createElement(BaseDropdown, { ...props, buttonProps: { ...buttonProps }, dropdown, items });
730
+ return /* @__PURE__ */ React19.createElement(BaseDropdown, { ...props, buttonProps: { ...buttonProps }, dropdown, items });
500
731
  }
501
732
 
502
733
  // src/wallet-ui-account-guard.tsx
503
- function WalletUiAccountGuard({ fallback = /* @__PURE__ */ React18.createElement(WalletUiDropdown, null), render }) {
734
+ function WalletUiAccountGuard({ fallback = /* @__PURE__ */ React19.createElement(WalletUiDropdown, null), render }) {
504
735
  const { account, accountKeys, cluster, wallet } = useWalletUiAccount();
505
736
  return account ? render({ account, accountKeys, cluster, wallet }) : fallback;
506
737
  }
738
+ function WalletUiAuth({ children, wallet }) {
739
+ const { account } = useWalletUi();
740
+ const targetAccount = getTargetAccount(account, wallet);
741
+ if (hasFeature(wallet, SolanaSignIn)) {
742
+ return /* @__PURE__ */ React19.createElement(WalletUiAuthNative, { wallet }, children);
743
+ }
744
+ if (targetAccount && hasFeature(targetAccount, SolanaSignMessage)) {
745
+ return /* @__PURE__ */ React19.createElement(WalletUiAuthMessage, { account: targetAccount, wallet }, children);
746
+ }
747
+ if (hasFeature(wallet, SolanaSignMessage) && hasFeature(wallet, StandardConnect)) {
748
+ return /* @__PURE__ */ React19.createElement(WalletUiAuthMessageConnect, { wallet }, children);
749
+ }
750
+ return children({
751
+ canSignIn: false,
752
+ isSigningIn: false,
753
+ messageSigningAvailable: false,
754
+ nativeSignInAvailable: false,
755
+ reason: "auth-unsupported",
756
+ signIn() {
757
+ return Promise.reject(new WalletUiAuthError("auth-unsupported"));
758
+ }
759
+ });
760
+ }
761
+ function WalletUiAuthMessage({
762
+ account,
763
+ children,
764
+ wallet
765
+ }) {
766
+ const signMessage = useSignMessage(account);
767
+ const auth = useWalletUiAuthMessage({ account, signMessage});
768
+ return children(auth);
769
+ }
770
+ function WalletUiAuthMessageConnect({ children, wallet }) {
771
+ const { connect: selectAccount } = useWalletUi();
772
+ const [isConnecting, connectWallet] = useConnect(wallet);
773
+ const [isSigningIn, setIsSigningIn] = useState(false);
774
+ const signIn = useCallback(
775
+ async ({ input = {} } = {}) => {
776
+ setIsSigningIn(true);
777
+ try {
778
+ const [firstAccount] = await connectWallet();
779
+ if (!firstAccount) {
780
+ throw new WalletUiAuthError("wallet-not-connected");
781
+ }
782
+ if (!hasFeature(firstAccount, SolanaSignMessage)) {
783
+ throw new WalletUiAuthError("auth-unsupported");
784
+ }
785
+ const result = await signInWithMessageFeature({
786
+ account: firstAccount,
787
+ input
788
+ });
789
+ selectAccount(firstAccount);
790
+ return result;
791
+ } finally {
792
+ setIsSigningIn(false);
793
+ }
794
+ },
795
+ [connectWallet, selectAccount]
796
+ );
797
+ return children({
798
+ canSignIn: true,
799
+ isSigningIn: isConnecting || isSigningIn,
800
+ messageSigningAvailable: false,
801
+ nativeSignInAvailable: false,
802
+ reason: void 0,
803
+ signIn
804
+ });
805
+ }
806
+ function WalletUiAuthNative({ children, wallet }) {
807
+ return children(useWalletUiAuthNative({ wallet }));
808
+ }
507
809
  function WalletUiClusterDropdown({ buttonProps, ...props }) {
508
810
  const dropdown = useBaseDropdown();
509
811
  const { cluster, clusters, setCluster } = useWalletUiCluster();
510
- return /* @__PURE__ */ React18.createElement(
812
+ return /* @__PURE__ */ React19.createElement(
511
813
  BaseDropdown,
512
814
  {
513
815
  buttonProps: { ...buttonProps, label: cluster.label },
@@ -526,7 +828,7 @@ function WalletUiClusterDropdown({ buttonProps, ...props }) {
526
828
  );
527
829
  }
528
830
  function WalletUiIconNoWallet({ ...props }) {
529
- return /* @__PURE__ */ React18.createElement(BaseSvg, { fill: "none", height: 100, width: 100, viewBox: "0 0 97 96", ...props }, /* @__PURE__ */ React18.createElement("circle", { cx: "48.5", cy: "48", r: "48", fill: "url(#paint0_linear_880_5115)", fillOpacity: "0.1" }), /* @__PURE__ */ React18.createElement(
831
+ return /* @__PURE__ */ React19.createElement(BaseSvg, { fill: "none", height: 100, width: 100, viewBox: "0 0 97 96", ...props }, /* @__PURE__ */ React19.createElement("circle", { cx: "48.5", cy: "48", r: "48", fill: "url(#paint0_linear_880_5115)", fillOpacity: "0.1" }), /* @__PURE__ */ React19.createElement(
530
832
  "circle",
531
833
  {
532
834
  cx: "48.5",
@@ -536,19 +838,19 @@ function WalletUiIconNoWallet({ ...props }) {
536
838
  strokeOpacity: "0.4",
537
839
  strokeWidth: "2"
538
840
  }
539
- ), /* @__PURE__ */ React18.createElement("g", { clipPath: "url(#clip0_880_5115)" }, /* @__PURE__ */ React18.createElement(
841
+ ), /* @__PURE__ */ React19.createElement("g", { clipPath: "url(#clip0_880_5115)" }, /* @__PURE__ */ React19.createElement(
540
842
  "path",
541
843
  {
542
844
  d: "M65.5769 28.1523H31.4231C27.6057 28.1523 24.5 31.258 24.5 35.0754V60.9215C24.5 64.7389 27.6057 67.8446 31.4231 67.8446H65.5769C69.3943 67.8446 72.5 64.7389 72.5 60.9215V35.0754C72.5 31.258 69.3943 28.1523 65.5769 28.1523ZM69.7308 52.1523H59.5769C57.2865 52.1523 55.4231 50.289 55.4231 47.9985C55.4231 45.708 57.2864 43.8446 59.5769 43.8446H69.7308V52.1523ZM69.7308 41.0754H59.5769C55.7595 41.0754 52.6539 44.1811 52.6539 47.9985C52.6539 51.8159 55.7595 54.9215 59.5769 54.9215H69.7308V60.9215C69.7308 63.2119 67.8674 65.0754 65.5769 65.0754H31.4231C29.1327 65.0754 27.2692 63.212 27.2692 60.9215V35.0754C27.2692 32.785 29.1326 30.9215 31.4231 30.9215H65.5769C67.8673 30.9215 69.7308 32.7849 69.7308 35.0754V41.0754Z",
543
845
  fill: "url(#paint2_linear_880_5115)"
544
846
  }
545
- ), /* @__PURE__ */ React18.createElement(
847
+ ), /* @__PURE__ */ React19.createElement(
546
848
  "path",
547
849
  {
548
850
  d: "M61.4231 46.6172H59.577C58.8123 46.6172 58.1924 47.2371 58.1924 48.0018C58.1924 48.7665 58.8123 49.3863 59.577 49.3863H61.4231C62.1878 49.3863 62.8077 48.7664 62.8077 48.0018C62.8077 47.2371 62.1878 46.6172 61.4231 46.6172Z",
549
851
  fill: "url(#paint3_linear_880_5115)"
550
852
  }
551
- )), /* @__PURE__ */ React18.createElement("defs", null, /* @__PURE__ */ React18.createElement(
853
+ )), /* @__PURE__ */ React19.createElement("defs", null, /* @__PURE__ */ React19.createElement(
552
854
  "linearGradient",
553
855
  {
554
856
  id: "paint0_linear_880_5115",
@@ -558,13 +860,13 @@ function WalletUiIconNoWallet({ ...props }) {
558
860
  y2: "8.42498",
559
861
  gradientUnits: "userSpaceOnUse"
560
862
  },
561
- /* @__PURE__ */ React18.createElement("stop", { stopColor: "#9945FF" }),
562
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
563
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
564
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
565
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
566
- /* @__PURE__ */ React18.createElement("stop", { offset: "1", stopColor: "#00D18C" })
567
- ), /* @__PURE__ */ React18.createElement(
863
+ /* @__PURE__ */ React19.createElement("stop", { stopColor: "#9945FF" }),
864
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
865
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
866
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
867
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
868
+ /* @__PURE__ */ React19.createElement("stop", { offset: "1", stopColor: "#00D18C" })
869
+ ), /* @__PURE__ */ React19.createElement(
568
870
  "linearGradient",
569
871
  {
570
872
  id: "paint1_linear_880_5115",
@@ -574,13 +876,13 @@ function WalletUiIconNoWallet({ ...props }) {
574
876
  y2: "8.42498",
575
877
  gradientUnits: "userSpaceOnUse"
576
878
  },
577
- /* @__PURE__ */ React18.createElement("stop", { stopColor: "#9945FF" }),
578
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
579
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
580
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
581
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
582
- /* @__PURE__ */ React18.createElement("stop", { offset: "1", stopColor: "#00D18C" })
583
- ), /* @__PURE__ */ React18.createElement(
879
+ /* @__PURE__ */ React19.createElement("stop", { stopColor: "#9945FF" }),
880
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
881
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
882
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
883
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
884
+ /* @__PURE__ */ React19.createElement("stop", { offset: "1", stopColor: "#00D18C" })
885
+ ), /* @__PURE__ */ React19.createElement(
584
886
  "linearGradient",
585
887
  {
586
888
  id: "paint2_linear_880_5115",
@@ -590,13 +892,13 @@ function WalletUiIconNoWallet({ ...props }) {
590
892
  y2: "23.7879",
591
893
  gradientUnits: "userSpaceOnUse"
592
894
  },
593
- /* @__PURE__ */ React18.createElement("stop", { stopColor: "#9945FF" }),
594
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
595
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
596
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
597
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
598
- /* @__PURE__ */ React18.createElement("stop", { offset: "1", stopColor: "#00D18C" })
599
- ), /* @__PURE__ */ React18.createElement(
895
+ /* @__PURE__ */ React19.createElement("stop", { stopColor: "#9945FF" }),
896
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
897
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
898
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
899
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
900
+ /* @__PURE__ */ React19.createElement("stop", { offset: "1", stopColor: "#00D18C" })
901
+ ), /* @__PURE__ */ React19.createElement(
600
902
  "linearGradient",
601
903
  {
602
904
  id: "paint3_linear_880_5115",
@@ -606,22 +908,22 @@ function WalletUiIconNoWallet({ ...props }) {
606
908
  y2: "45.4453",
607
909
  gradientUnits: "userSpaceOnUse"
608
910
  },
609
- /* @__PURE__ */ React18.createElement("stop", { stopColor: "#9945FF" }),
610
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
611
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
612
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
613
- /* @__PURE__ */ React18.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
614
- /* @__PURE__ */ React18.createElement("stop", { offset: "1", stopColor: "#00D18C" })
615
- ), /* @__PURE__ */ React18.createElement("clipPath", { id: "clip0_880_5115" }, /* @__PURE__ */ React18.createElement("rect", { width: "48", height: "48", fill: "white", transform: "translate(24.5 24)" }))));
911
+ /* @__PURE__ */ React19.createElement("stop", { stopColor: "#9945FF" }),
912
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.14", stopColor: "#8A53F4" }),
913
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.42", stopColor: "#6377D6" }),
914
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.79", stopColor: "#24B0A7" }),
915
+ /* @__PURE__ */ React19.createElement("stop", { offset: "0.99", stopColor: "#00D18C" }),
916
+ /* @__PURE__ */ React19.createElement("stop", { offset: "1", stopColor: "#00D18C" })
917
+ ), /* @__PURE__ */ React19.createElement("clipPath", { id: "clip0_880_5115" }, /* @__PURE__ */ React19.createElement("rect", { width: "48", height: "48", fill: "white", transform: "translate(24.5 24)" }))));
616
918
  }
617
919
  function WalletUiLabel({ className, wallet, ...props }) {
618
920
  if (!wallet) {
619
921
  return null;
620
922
  }
621
- return /* @__PURE__ */ React18.createElement("span", { "data-wu": "wallet-ui-label", className: `${className ?? ""}`, ...props }, wallet.name);
923
+ return /* @__PURE__ */ React19.createElement("span", { "data-wu": "wallet-ui-label", className: `${className ?? ""}`, ...props }, wallet.name);
622
924
  }
623
925
  function WalletUiListButton({ className, select, wallet, ...props }) {
624
- const [pending, setPending] = React18.useState(false);
926
+ const [pending, setPending] = React19.useState(false);
625
927
  function handleSelect() {
626
928
  if (!select) {
627
929
  return;
@@ -633,7 +935,7 @@ function WalletUiListButton({ className, select, wallet, ...props }) {
633
935
  }
634
936
  void select(account).finally(() => setPending(false));
635
937
  }
636
- return /* @__PURE__ */ React18.createElement(
938
+ return /* @__PURE__ */ React19.createElement(
637
939
  "button",
638
940
  {
639
941
  disabled: pending,
@@ -642,22 +944,22 @@ function WalletUiListButton({ className, select, wallet, ...props }) {
642
944
  onClick: handleSelect,
643
945
  ...props
644
946
  },
645
- /* @__PURE__ */ React18.createElement(WalletUiIcon, { wallet }),
646
- /* @__PURE__ */ React18.createElement(WalletUiLabel, { wallet })
947
+ /* @__PURE__ */ React19.createElement(WalletUiIcon, { wallet }),
948
+ /* @__PURE__ */ React19.createElement(WalletUiLabel, { wallet })
647
949
  );
648
950
  }
649
951
 
650
952
  // src/wallet-ui-list.tsx
651
953
  function WalletUiList({ className, select, wallets, ...props }) {
652
- return /* @__PURE__ */ React18.createElement("div", { "data-wu": "wallet-ui-list", className: `${className ?? ""}`, ...props }, wallets.map((wallet) => /* @__PURE__ */ React18.createElement(WalletUiListButton, { key: wallet.name, select, wallet })));
954
+ return /* @__PURE__ */ React19.createElement("div", { "data-wu": "wallet-ui-list", className: `${className ?? ""}`, ...props }, wallets.map((wallet) => /* @__PURE__ */ React19.createElement(WalletUiListButton, { key: wallet.name, select, wallet })));
653
955
  }
654
956
  function WalletUiModal({ wallets, select, ...props }) {
655
- return /* @__PURE__ */ React18.createElement(BaseModal, { description: "Connect a wallet on Solana to continue", ...props }, /* @__PURE__ */ React18.createElement(WalletUiList, { wallets, select }));
957
+ return /* @__PURE__ */ React19.createElement(BaseModal, { description: "Connect a wallet on Solana to continue", ...props }, /* @__PURE__ */ React19.createElement(WalletUiList, { wallets, select }));
656
958
  }
657
959
  function WalletUiModalTrigger({ label = "Select Wallet", modal, ...props }) {
658
- return /* @__PURE__ */ React18.createElement(BaseButton, { label, onClick: () => void modal.open(), ...props });
960
+ return /* @__PURE__ */ React19.createElement(BaseButton, { label, onClick: () => void modal.open(), ...props });
659
961
  }
660
962
 
661
- export { BaseButton, BaseDropdown, BaseDropdownChevronDown, BaseDropdownItemType, BaseModal, BaseSvg, WalletUi, WalletUiAccountContext, WalletUiAccountContextProvider, WalletUiAccountGuard, WalletUiClusterContext, WalletUiClusterContextProvider, WalletUiClusterDropdown, WalletUiContext, WalletUiContextProvider, WalletUiDropdown, WalletUiIcon, WalletUiIconClose, WalletUiIconNoWallet, WalletUiLabel, WalletUiList, WalletUiListButton, WalletUiModal, WalletUiModalTrigger, createWalletUiConfig, ellipsify, useBaseDropdown, useBaseModal, useWalletUi, useWalletUiAccount, useWalletUiCluster, useWalletUiDropdown, useWalletUiSigner, useWalletUiWallet, useWalletUiWallets };
963
+ export { BaseButton, BaseDropdown, BaseDropdownChevronDown, BaseDropdownItemType, BaseModal, BaseSvg, WalletUi, WalletUiAccountContext, WalletUiAccountContextProvider, WalletUiAccountGuard, WalletUiAuth, WalletUiAuthError, WalletUiClusterContext, WalletUiClusterContextProvider, WalletUiClusterDropdown, WalletUiContext, WalletUiContextProvider, WalletUiDropdown, WalletUiIcon, WalletUiIconClose, WalletUiIconNoWallet, WalletUiLabel, WalletUiList, WalletUiListButton, WalletUiModal, WalletUiModalTrigger, createWalletUiConfig, ellipsify, useBaseDropdown, useBaseModal, useWalletUi, useWalletUiAccount, useWalletUiAuth, useWalletUiCluster, useWalletUiDropdown, useWalletUiSigner, useWalletUiWallet, useWalletUiWallets };
662
964
  //# sourceMappingURL=index.native.mjs.map
663
965
  //# sourceMappingURL=index.native.mjs.map