@b3dotfun/sdk 0.1.69-alpha.23 → 0.1.69-alpha.25

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.
Files changed (72) hide show
  1. package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +3 -1
  2. package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +4 -2
  3. package/dist/cjs/global-account/react/components/ManageAccount/Header.js +37 -4
  4. package/dist/cjs/global-account/react/components/ManageAccount/HomeContent.js +4 -1
  5. package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +5 -3
  6. package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +3 -1
  7. package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +25 -14
  8. package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +6 -1
  9. package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +2 -2
  10. package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
  11. package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.js +85 -0
  12. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +14 -4
  13. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  14. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
  15. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +3 -1
  16. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +2 -2
  17. package/dist/cjs/global-account/react/components/index.d.ts +1 -0
  18. package/dist/cjs/global-account/react/components/index.js +5 -3
  19. package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +1 -1
  20. package/dist/cjs/global-account/react/hooks/useBetterAuth.js +5 -4
  21. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
  22. package/dist/cjs/shared/constants/index.d.ts +1 -0
  23. package/dist/cjs/shared/constants/index.js +2 -1
  24. package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +3 -1
  25. package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +5 -3
  26. package/dist/esm/global-account/react/components/ManageAccount/Header.js +38 -5
  27. package/dist/esm/global-account/react/components/ManageAccount/HomeContent.js +4 -1
  28. package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +6 -4
  29. package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +4 -2
  30. package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +25 -14
  31. package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +6 -1
  32. package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +2 -2
  33. package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
  34. package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.js +82 -0
  35. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +16 -6
  36. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  37. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
  38. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +3 -1
  39. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +2 -2
  40. package/dist/esm/global-account/react/components/index.d.ts +1 -0
  41. package/dist/esm/global-account/react/components/index.js +1 -0
  42. package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +1 -1
  43. package/dist/esm/global-account/react/hooks/useBetterAuth.js +5 -4
  44. package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
  45. package/dist/esm/shared/constants/index.d.ts +1 -0
  46. package/dist/esm/shared/constants/index.js +1 -0
  47. package/dist/styles/index.css +1 -1
  48. package/dist/types/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +6 -1
  49. package/dist/types/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
  50. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  51. package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +3 -1
  52. package/dist/types/global-account/react/components/index.d.ts +1 -0
  53. package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +1 -1
  54. package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
  55. package/dist/types/shared/constants/index.d.ts +1 -0
  56. package/package.json +1 -1
  57. package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +3 -1
  58. package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +18 -14
  59. package/src/global-account/react/components/ManageAccount/Header.tsx +74 -4
  60. package/src/global-account/react/components/ManageAccount/HomeContent.tsx +25 -19
  61. package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +14 -7
  62. package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +18 -14
  63. package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +29 -20
  64. package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +7 -1
  65. package/src/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.tsx +155 -0
  66. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +43 -14
  67. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +8 -1
  68. package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +4 -2
  69. package/src/global-account/react/components/index.ts +5 -0
  70. package/src/global-account/react/hooks/useBetterAuth.ts +5 -4
  71. package/src/global-account/react/stores/useModalStore.ts +2 -0
  72. package/src/shared/constants/index.ts +2 -0
@@ -4,16 +4,19 @@ import {
4
4
  SignInWithB3ModalProps,
5
5
  StyleRoot,
6
6
  useAccountWallet,
7
+ useAuthStore,
7
8
  useAuthentication,
8
9
  useB3Config,
9
10
  useIsMobile,
10
11
  } from "@b3dotfun/sdk/global-account/react";
11
12
  import Icon from "@b3dotfun/sdk/global-account/react/components/custom/Icon";
12
- import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
13
+ import { AVATAR_COLORS, ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
13
14
  import { cn, truncateAddress } from "@b3dotfun/sdk/shared/utils";
14
15
  import { Menu, MenuButton, MenuItems, Transition } from "@headlessui/react";
16
+ import Avatar from "boring-avatars";
15
17
  import { ReactNode, useEffect } from "react";
16
18
  import { useConnectedWallets, useSetActiveWallet, useWalletImage } from "thirdweb/react";
19
+ import { useUser } from "../../hooks/useUser";
17
20
  import { ManageAccountButton } from "../custom/ManageAccountButton";
18
21
 
19
22
  type SignInProps = {
@@ -30,7 +33,9 @@ type SignInWithB3Props = Omit<SignInWithB3ModalProps, "type" | "showBackButton">
30
33
 
31
34
  export function SignIn(props: SignInWithB3Props) {
32
35
  const { className } = props;
33
- const { automaticallySetFirstEoa, partnerId } = useB3Config();
36
+ const { automaticallySetFirstEoa, partnerId, authStrategy } = useB3Config();
37
+ const isBetterAuth = authStrategy === "better-auth";
38
+
34
39
  const {
35
40
  address: globalAddress,
36
41
  ensName,
@@ -53,6 +58,11 @@ export function SignIn(props: SignInWithB3Props) {
53
58
 
54
59
  const setActiveWallet = useSetActiveWallet();
55
60
 
61
+ // Better Auth state
62
+ const isAuthenticated = useAuthStore(state => state.isAuthenticated);
63
+ const { user } = useUser();
64
+ const userDisplayName = user?.username || user?.email || "Account";
65
+
56
66
  const handleSetActiveAccount = (selectedWalletId: string | undefined) => {
57
67
  if (
58
68
  !selectedWalletId ||
@@ -72,21 +82,29 @@ export function SignIn(props: SignInWithB3Props) {
72
82
  }
73
83
  }, [connectedEOAWallet, isActiveEOAWallet, setActiveWallet, automaticallySetFirstEoa]);
74
84
 
85
+ const isLoggedIn = isBetterAuth ? isAuthenticated : !!globalAddress;
86
+
75
87
  // Desktop version - original dropdown menu
76
88
  return (
77
89
  <StyleRoot>
78
90
  <Menu className={`relative flex items-center ${className || ""}`} as="div">
79
- {globalAddress ? (
91
+ {isLoggedIn ? (
80
92
  <>
81
93
  <MenuButton className="bg-b3-react-background group flex h-10 items-center gap-1 rounded-xl px-3 focus:outline-none">
82
- {!!walletImage && (
83
- <IPFSMediaRenderer
84
- src={walletImage}
85
- alt="Wallet Image"
86
- className="bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100"
87
- />
94
+ {isBetterAuth ? (
95
+ <Avatar name={userDisplayName} variant="beam" size={24} colors={AVATAR_COLORS} />
96
+ ) : (
97
+ !!walletImage && (
98
+ <IPFSMediaRenderer
99
+ src={walletImage}
100
+ alt="Wallet Image"
101
+ className="bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100"
102
+ />
103
+ )
88
104
  )}
89
- <div className="text-as-primary">{ensName ? ensName : truncateAddress(globalAddress)}</div>
105
+ <div className="text-as-primary">
106
+ {isBetterAuth ? userDisplayName : ensName ? ensName : truncateAddress(globalAddress ?? "")}
107
+ </div>
90
108
  </MenuButton>
91
109
  <Transition
92
110
  enter="duration-200 ease-out"
@@ -103,7 +121,16 @@ export function SignIn(props: SignInWithB3Props) {
103
121
  anchor={isMobile ? "top end" : undefined}
104
122
  >
105
123
  <div className="bg-b3-react-background">
106
- {connectedEOAWallet ? (
124
+ {isBetterAuth ? (
125
+ /* Better Auth: show user info instead of wallet switching */
126
+ <div className="flex items-center gap-3 rounded-xl p-3">
127
+ <Avatar name={userDisplayName} variant="beam" size={48} colors={AVATAR_COLORS} />
128
+ <div className="flex flex-col gap-0.5">
129
+ {user?.username && <div className="text-b3-react-primary font-semibold">{user.username}</div>}
130
+ {user?.email && <div className="text-b3-react-secondary text-sm">{user.email}</div>}
131
+ </div>
132
+ </div>
133
+ ) : connectedEOAWallet ? (
107
134
  <div
108
135
  className={cn(
109
136
  "border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3",
@@ -118,7 +145,7 @@ export function SignIn(props: SignInWithB3Props) {
118
145
  />
119
146
  <div className="ml-4 grow">
120
147
  {ensName && <div>{ensName}</div>}
121
- <div>{truncateAddress(globalAddress)}</div>
148
+ <div>{truncateAddress(globalAddress ?? "")}</div>
122
149
  {/* <div>{walletInfo?.name}</div> */}
123
150
  </div>
124
151
  </div>
@@ -143,7 +170,7 @@ export function SignIn(props: SignInWithB3Props) {
143
170
  />
144
171
  <div className="grow pl-4">
145
172
  {ensName && <div>{ensName}</div>}
146
- <div>{truncateAddress(globalAddress)}</div>
173
+ <div>{truncateAddress(globalAddress ?? "")}</div>
147
174
  <div>Smart wallet</div>
148
175
  </div>
149
176
  </div>
@@ -159,7 +186,9 @@ export function SignIn(props: SignInWithB3Props) {
159
186
  <button className="mb-2 w-full space-y-1" onClick={onDisconnect}>
160
187
  <div className="hover:bg-b3-react-background group flex h-12 items-center rounded-xl px-4 transition-colors">
161
188
  <Icon className="fill-b3-react-primary mr-4 shrink-0 transition-colors" name="logout" />
162
- <div className="text-b3-react-primary mr-auto transition-colors">Disconnect</div>
189
+ <div className="text-b3-react-primary mr-auto transition-colors">
190
+ {isBetterAuth ? "Sign out" : "Disconnect"}
191
+ </div>
163
192
  </div>
164
193
  </button>
165
194
  </div>
@@ -34,6 +34,7 @@ export function SignInWithB3Flow({
34
34
  closeAfterLogin = false,
35
35
  source = "signInWithB3Button",
36
36
  signersEnabled = false,
37
+ verifyEmailRedirectTo,
37
38
  }: SignInWithB3ModalProps) {
38
39
  const { automaticallySetFirstEoa, authStrategy } = useB3Config();
39
40
  // skipAutoConnect: this component intentionally logs out on mount to show a fresh login screen.
@@ -292,7 +293,13 @@ export function SignInWithB3Flow({
292
293
  // Better Auth manages its own loading/verification states internally.
293
294
  // Don't gate on isAuthenticating — it would unmount the component
294
295
  // and lose verification state when setIsAuthenticating(false) fires.
295
- content = <LoginStepBetterAuth onSuccess={() => handleLoginSuccess({} as Account)} onError={onError} />;
296
+ content = (
297
+ <LoginStepBetterAuth
298
+ onSuccess={() => handleLoginSuccess({} as Account)}
299
+ onError={onError}
300
+ verifyEmailRedirectTo={verifyEmailRedirectTo}
301
+ />
302
+ );
296
303
  } else if (!readyToShowLogin || isAuthenticating || isFetchingSigners) {
297
304
  content = (
298
305
  <LoginStepContainer partnerId={partnerId}>
@@ -23,9 +23,11 @@ const SOCIAL_PROVIDERS: { id: BetterAuthSocialProvider; label: string }[] = [
23
23
  interface LoginStepBetterAuthProps {
24
24
  onSuccess?: () => void;
25
25
  onError?: (error: Error) => Promise<void>;
26
+ /** URL Better Auth redirects to after server-side email verification. */
27
+ verifyEmailRedirectTo?: string;
26
28
  }
27
29
 
28
- export function LoginStepBetterAuth({ onSuccess, onError }: LoginStepBetterAuthProps) {
30
+ export function LoginStepBetterAuth({ onSuccess, onError, verifyEmailRedirectTo }: LoginStepBetterAuthProps) {
29
31
  const { partnerId } = useB3Config();
30
32
  const { signInWithEmail, signUpWithEmail, signInWithSocial, requestPasswordReset } = useBetterAuth();
31
33
 
@@ -63,7 +65,7 @@ export function LoginStepBetterAuth({ onSuccess, onError }: LoginStepBetterAuthP
63
65
 
64
66
  if (mode === "sign-up") {
65
67
  debug("Signing up", { email: normalizedEmail, name: name.trim() });
66
- await signUpWithEmail(normalizedEmail, password, name.trim());
68
+ await signUpWithEmail(normalizedEmail, password, name.trim(), verifyEmailRedirectTo);
67
69
  } else {
68
70
  debug("Signing in", { email: normalizedEmail });
69
71
  await signInWithEmail(normalizedEmail, password);
@@ -12,6 +12,11 @@ export { StyleRoot } from "./StyleRoot";
12
12
  // SignInWithB3 Components
13
13
  export { BetterAuthResetPassword, type BetterAuthResetPasswordProps } from "./SignInWithB3/BetterAuthResetPassword";
14
14
  export { BetterAuthSignIn, type BetterAuthSignInProps } from "./SignInWithB3/BetterAuthSignIn";
15
+ export {
16
+ BetterAuthVerifyEmail,
17
+ type BetterAuthVerifyEmailProps,
18
+ type BetterAuthVerifyEmailState,
19
+ } from "./SignInWithB3/BetterAuthVerifyEmail";
15
20
  export { AuthButton } from "./SignInWithB3/components/AuthButton";
16
21
  export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
17
22
  export { WalletRow } from "./SignInWithB3/components/WalletRow";
@@ -87,7 +87,7 @@ export function useBetterAuth() {
87
87
  );
88
88
 
89
89
  const signUpWithEmail = useCallback(
90
- async (email: string, password: string, name: string) => {
90
+ async (email: string, password: string, name: string, verifyCallbackURL?: string) => {
91
91
  debug("Signing up with email", { email, name });
92
92
  setHasStartedConnecting(true);
93
93
  setIsAuthenticating(true);
@@ -101,11 +101,12 @@ export function useBetterAuth() {
101
101
 
102
102
  const token = result.data?.token;
103
103
  if (!token) {
104
- // requireEmailVerification is enabled — send verification email
105
- // with the client's origin as callbackURL so the user returns here
104
+ // requireEmailVerification is enabled — send verification email with
105
+ // a callbackURL Better Auth redirects to after server-side verify.
106
+ // Pass verifyCallbackURL to land on a dedicated confirmation page.
106
107
  await betterAuthClient.sendVerificationEmail({
107
108
  email,
108
- callbackURL: `${window.location.origin}?authStrategy=better-auth`,
109
+ callbackURL: verifyCallbackURL || `${window.location.origin}?authStrategy=better-auth`,
109
110
  });
110
111
  throw new EmailVerificationRequiredError();
111
112
  }
@@ -44,6 +44,8 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
44
44
  source?: "signInWithB3Button" | "requestPermissions";
45
45
  /** Whether to show the signers enabled modal */
46
46
  signersEnabled?: boolean;
47
+ /** URL Better Auth redirects to after server-side email verification. */
48
+ verifyEmailRedirectTo?: string;
47
49
  }
48
50
 
49
51
  /**
@@ -32,3 +32,5 @@ export const B3_AUTH_COOKIE_NAME = "b3-auth";
32
32
  export const ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
33
33
 
34
34
  export const PUBLIC_BASE_RPC_URL = "https://base-rpc.publicnode.com";
35
+
36
+ export const AVATAR_COLORS = ["#3368ef", "#272727", "#6366f1", "#06b6d4", "#eeb0d9", "#ba3fbf", "#ff777b", "#dfbb53"];