@b3dotfun/sdk 0.1.69-alpha.9 → 0.1.69-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/constants/rpc.d.ts +1 -1
- package/dist/cjs/anyspend/constants/rpc.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +10 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +3 -3
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +43 -23
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +10 -9
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/cjs/anyspend/utils/chain.js +8 -7
- package/dist/cjs/global-account/better-auth-client.d.ts +1883 -0
- package/dist/cjs/global-account/better-auth-client.js +17 -0
- package/dist/cjs/global-account/bsmnt.d.ts +0 -1
- package/dist/cjs/global-account/bsmnt.js +0 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +9 -12
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -9
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +120 -0
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/cjs/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +15 -6
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- package/dist/cjs/global-account/react/components/Send/Send.js +5 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +67 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +163 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +138 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +5 -1
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/index.d.ts +3 -0
- package/dist/cjs/global-account/react/components/index.js +7 -3
- package/dist/cjs/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAuth.js +24 -11
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +21 -8
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +157 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/cjs/global-account/react/utils/index.d.ts +0 -1
- package/dist/cjs/global-account/react/utils/index.js +0 -1
- package/dist/cjs/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/cjs/shared/constants/chains/b3Chain.js +4 -4
- package/dist/cjs/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/cjs/shared/constants/chains/b3Viem.js +19 -0
- package/dist/cjs/shared/constants/chains/supported.d.ts +1 -1
- package/dist/cjs/shared/generated/chain-networks.json +2 -2
- package/dist/cjs/shared/utils/chains.d.ts +1 -1
- package/dist/cjs/shared/utils/chains.js +2 -2
- package/dist/cjs/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.js +467 -0
- package/dist/cjs/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/cjs/wallet/react/components/WalletProvider.js +20 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.js +22 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.js +63 -0
- package/dist/cjs/wallet/react/index.d.ts +5 -0
- package/dist/cjs/wallet/react/index.js +16 -0
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/cjs/wallet/utils/createWalletConfig.js +24 -0
- package/dist/esm/anyspend/constants/rpc.d.ts +1 -1
- package/dist/esm/anyspend/constants/rpc.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +10 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +3 -3
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +44 -24
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -8
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/esm/anyspend/utils/chain.js +10 -9
- package/dist/esm/global-account/better-auth-client.d.ts +1883 -0
- package/dist/esm/global-account/better-auth-client.js +13 -0
- package/dist/esm/global-account/bsmnt.d.ts +0 -1
- package/dist/esm/global-account/bsmnt.js +0 -5
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +4 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -5
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +115 -0
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/esm/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +13 -7
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- package/dist/esm/global-account/react/components/Send/Send.js +5 -2
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +64 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +160 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +135 -0
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +5 -1
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/esm/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +3 -0
- package/dist/esm/global-account/react/components/index.js +2 -0
- package/dist/esm/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuth.js +24 -11
- package/dist/esm/global-account/react/hooks/useAuthentication.js +21 -8
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +149 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/esm/global-account/react/utils/index.d.ts +0 -1
- package/dist/esm/global-account/react/utils/index.js +0 -1
- package/dist/esm/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/esm/shared/constants/chains/b3Chain.js +4 -4
- package/dist/esm/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/esm/shared/constants/chains/b3Viem.js +16 -0
- package/dist/esm/shared/constants/chains/supported.d.ts +1 -1
- package/dist/esm/shared/generated/chain-networks.json +2 -2
- package/dist/esm/shared/utils/chains.d.ts +1 -1
- package/dist/esm/shared/utils/chains.js +2 -2
- package/dist/esm/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/esm/wallet/react/components/ConnectWallet.js +431 -0
- package/dist/esm/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/esm/wallet/react/components/WalletProvider.js +17 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.js +19 -0
- package/dist/esm/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/esm/wallet/react/hooks/useWalletState.js +60 -0
- package/dist/esm/wallet/react/index.d.ts +5 -0
- package/dist/esm/wallet/react/index.js +8 -0
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/esm/wallet/utils/createWalletConfig.js +21 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/rpc.d.ts +1 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/types/global-account/better-auth-client.d.ts +1883 -0
- package/dist/types/global-account/bsmnt.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/types/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/types/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/types/global-account/react/components/index.d.ts +3 -0
- package/dist/types/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/types/global-account/react/utils/index.d.ts +0 -1
- package/dist/types/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/types/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/types/shared/constants/chains/supported.d.ts +1 -1
- package/dist/types/shared/utils/chains.d.ts +1 -1
- package/dist/types/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/types/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/types/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/types/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/types/wallet/react/index.d.ts +5 -0
- package/dist/types/wallet/utils/createWalletConfig.d.ts +21 -0
- package/package.json +14 -6
- package/src/anyspend/constants/rpc.ts +2 -1
- package/src/anyspend/react/components/AnySpendNFT.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +15 -1
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +3 -3
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +45 -27
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +10 -8
- package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +4 -4
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
- package/src/anyspend/utils/chain.ts +9 -9
- package/src/global-account/better-auth-client.ts +17 -0
- package/src/global-account/bsmnt.ts +0 -6
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +6 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +14 -20
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +52 -40
- package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +127 -0
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.tsx +17 -10
- package/src/global-account/react/components/LinkAccount/LinkedAccountItem.tsx +2 -1
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +29 -11
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +2 -2
- package/src/global-account/react/components/Send/Send.tsx +8 -5
- package/src/global-account/react/components/SignInWithB3/BetterAuthResetPassword.tsx +146 -0
- package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +426 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -4
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +308 -0
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +5 -1
- package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +2 -1
- package/src/global-account/react/components/index.ts +3 -0
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAuth.ts +24 -11
- package/src/global-account/react/hooks/useAuthentication.ts +21 -8
- package/src/global-account/react/hooks/useBetterAuth.ts +191 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +6 -7
- package/src/global-account/react/utils/index.ts +0 -1
- package/src/global-account/react/utils/profileDisplay.ts +21 -19
- package/src/shared/constants/chains/b3Chain.ts +5 -5
- package/src/shared/constants/chains/b3Viem.ts +18 -0
- package/src/shared/generated/chain-networks.json +2 -2
- package/src/shared/utils/chains.ts +3 -2
- package/src/wallet/__tests__/createWalletConfig.test.ts +39 -0
- package/src/wallet/react/components/ConnectWallet.tsx +665 -0
- package/src/wallet/react/components/WalletProvider.tsx +64 -0
- package/src/wallet/react/hooks/useWalletDisconnect.ts +22 -0
- package/src/wallet/react/hooks/useWalletState.ts +93 -0
- package/src/wallet/react/index.ts +10 -0
- package/src/wallet/utils/createWalletConfig.ts +39 -0
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -54
- package/dist/cjs/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/cjs/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/cjs/global-account/react/hooks/useRPMToken.js +0 -11
- package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/cjs/global-account/react/utils/updateAvatar.js +0 -54
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -51
- package/dist/esm/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/esm/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/esm/global-account/react/hooks/useRPMToken.js +0 -8
- package/dist/esm/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/esm/global-account/react/utils/updateAvatar.js +0 -18
- package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/types/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/types/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +0 -90
- package/src/global-account/react/components/ProfileAvatar.tsx +0 -138
- package/src/global-account/react/hooks/useRPMToken.ts +0 -17
- package/src/global-account/react/utils/updateAvatar.ts +0 -21
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/client";
|
|
2
|
+
import { B3_API_URL } from "../app.shared.js";
|
|
3
|
+
export function createB3BetterAuthClient(baseURL = B3_API_URL) {
|
|
4
|
+
return createAuthClient({
|
|
5
|
+
baseURL,
|
|
6
|
+
basePath: "/auth",
|
|
7
|
+
fetchOptions: {
|
|
8
|
+
credentials: "include",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
// Default singleton for standard usage
|
|
13
|
+
export const betterAuthClient = createB3BetterAuthClient();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
declare const app: import("@b3dotfun/basement-api").ClientApplication;
|
|
2
2
|
export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
|
|
3
3
|
export declare const resetSocket: () => void;
|
|
4
|
-
export declare function extractAvatarIdFromUrl(url: string): string | null;
|
|
5
4
|
export declare const authenticateWithB3JWT: (fullToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
|
|
6
5
|
export default app;
|
|
@@ -60,11 +60,6 @@ export const resetSocket = () => {
|
|
|
60
60
|
socket.connect();
|
|
61
61
|
// reset the socket connection
|
|
62
62
|
};
|
|
63
|
-
export function extractAvatarIdFromUrl(url) {
|
|
64
|
-
const regex = /https:\/\/models\.readyplayer\.me\/([a-f0-9]{24})\.[a-zA-Z0-9]+/;
|
|
65
|
-
const match = url.match(regex);
|
|
66
|
-
return match ? match[1] : null;
|
|
67
|
-
}
|
|
68
63
|
export const authenticateWithB3JWT = async (fullToken, params) => {
|
|
69
64
|
// Do not authenticate if there is no token
|
|
70
65
|
if (!fullToken) {
|
|
@@ -3,6 +3,7 @@ import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendC
|
|
|
3
3
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
4
4
|
import { Account } from "thirdweb/wallets";
|
|
5
5
|
import { ClientType } from "../../../client-manager";
|
|
6
|
+
export type AuthStrategy = "thirdweb" | "better-auth";
|
|
6
7
|
export interface B3ConfigContextType {
|
|
7
8
|
accountOverride?: Account;
|
|
8
9
|
automaticallySetFirstEoa: boolean;
|
|
@@ -13,8 +14,9 @@ export interface B3ConfigContextType {
|
|
|
13
14
|
partnerId: string;
|
|
14
15
|
stripePublishableKey?: string;
|
|
15
16
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
17
|
+
authStrategy: AuthStrategy;
|
|
16
18
|
}
|
|
17
|
-
export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, }: {
|
|
19
|
+
export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, authStrategy, }: {
|
|
18
20
|
children: React.ReactNode;
|
|
19
21
|
accountOverride?: Account;
|
|
20
22
|
environment?: "development" | "production";
|
|
@@ -25,5 +27,6 @@ export declare function B3ConfigProvider({ children, accountOverride, environmen
|
|
|
25
27
|
partnerId: string;
|
|
26
28
|
stripePublishableKey?: string;
|
|
27
29
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
30
|
+
authStrategy?: AuthStrategy;
|
|
28
31
|
}): import("react/jsx-runtime").JSX.Element;
|
|
29
32
|
export declare function useB3Config(): B3ConfigContextType;
|
|
@@ -10,7 +10,7 @@ const DEFAULT_PERMISSIONS = {
|
|
|
10
10
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
11
11
|
};
|
|
12
12
|
const B3ConfigContext = createContext(null);
|
|
13
|
-
export function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId, }) {
|
|
13
|
+
export function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId, authStrategy = "thirdweb", }) {
|
|
14
14
|
return (_jsx(B3ConfigContext.Provider, { value: {
|
|
15
15
|
accountOverride,
|
|
16
16
|
environment,
|
|
@@ -21,6 +21,7 @@ export function B3ConfigProvider({ children, accountOverride, environment = "dev
|
|
|
21
21
|
partnerId,
|
|
22
22
|
stripePublishableKey,
|
|
23
23
|
createClientReferenceId,
|
|
24
|
+
authStrategy,
|
|
24
25
|
}, children: children }));
|
|
25
26
|
}
|
|
26
27
|
export function useB3Config() {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
2
|
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
3
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
4
|
+
import type { AuthStrategy } from "./B3ConfigProvider";
|
|
4
5
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
6
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
5
7
|
import { Account, EIP1193, Wallet } from "thirdweb/wallets";
|
|
6
8
|
import { CreateConnectorFn } from "wagmi";
|
|
7
9
|
import { ClientType } from "../../../client-manager";
|
|
8
10
|
/**
|
|
9
11
|
* Main B3Provider component
|
|
10
12
|
*/
|
|
11
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, }: {
|
|
13
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication, queryClient, authStrategy, }: {
|
|
12
14
|
theme: "light" | "dark";
|
|
13
15
|
children: React.ReactNode;
|
|
14
16
|
accountOverride?: Account;
|
|
@@ -32,4 +34,9 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
32
34
|
overrideDefaultConnectors?: boolean;
|
|
33
35
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
34
36
|
defaultPermissions?: PermissionsConfig;
|
|
37
|
+
disableBSMNTAuthentication?: boolean;
|
|
38
|
+
/** Provide your own QueryClient for React Query. If omitted, WalletProvider creates one internally. */
|
|
39
|
+
queryClient?: QueryClient;
|
|
40
|
+
/** Auth strategy: "thirdweb" (default, ecosystem wallet) or "better-auth" (email/password via Better Auth) */
|
|
41
|
+
authStrategy?: AuthStrategy;
|
|
35
42
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,25 +2,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { RelayKitProviderWrapper, TooltipProvider } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { createWagmiConfig } from "../../../../global-account/react/utils/createWagmiConfig.js";
|
|
4
4
|
import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
5
|
+
import { WalletProvider } from "../../../../wallet/react/index.js";
|
|
5
6
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
6
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
7
7
|
import { useEffect, useMemo } from "react";
|
|
8
|
-
import { ThirdwebProvider } from "thirdweb/react";
|
|
9
|
-
import { WagmiProvider } from "wagmi";
|
|
10
8
|
import { setClientType } from "../../../client-manager.js";
|
|
11
9
|
import { StyleRoot } from "../StyleRoot.js";
|
|
12
10
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index.js";
|
|
13
11
|
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
14
12
|
import { B3ConfigProvider } from "./B3ConfigProvider.js";
|
|
13
|
+
import BetterAuthProvider from "./BetterAuthProvider.js";
|
|
15
14
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
16
|
-
// Create queryClient instance
|
|
17
|
-
const queryClient = new QueryClient();
|
|
18
15
|
/**
|
|
19
16
|
* Main B3Provider component
|
|
20
17
|
*/
|
|
21
18
|
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey,
|
|
22
19
|
// deprecated since v0.0.87
|
|
23
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, }) {
|
|
20
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication = false, queryClient, authStrategy = "thirdweb", }) {
|
|
24
21
|
// Initialize Google Analytics on mount
|
|
25
22
|
useEffect(() => {
|
|
26
23
|
loadGA4Script();
|
|
@@ -30,7 +27,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
30
27
|
setClientType(clientType);
|
|
31
28
|
}, [clientType]);
|
|
32
29
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
33
|
-
return (_jsx(
|
|
30
|
+
return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, queryClient: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, disableBSMNTAuthentication: disableBSMNTAuthentication, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, defaultPermissions: defaultPermissions, authStrategy: authStrategy, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), authStrategy === "better-auth" ? (_jsx(BetterAuthProvider, { partnerId: partnerId })) : (_jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa, defaultEoaProvider: defaultEoaProvider }))] }) }) }) }) }));
|
|
34
31
|
}
|
|
35
32
|
/**
|
|
36
33
|
* Component to connect the toast context to the global toast API
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { WalletProvider } from "../../../../wallet/react/index.js";
|
|
3
3
|
import { ThirdwebProvider } from "thirdweb/react";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import { WagmiProvider } from "wagmi";
|
|
6
5
|
import { createWagmiConfig } from "../../utils/createWagmiConfig.js";
|
|
7
6
|
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
8
7
|
import { B3ConfigProvider } from "./B3ConfigProvider.js";
|
|
9
8
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
10
|
-
// Create queryClient instance
|
|
11
|
-
const queryClient = new QueryClient();
|
|
12
9
|
/**
|
|
13
10
|
* Main B3Provider component
|
|
14
11
|
*/
|
|
@@ -20,5 +17,5 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
|
|
|
20
17
|
*/
|
|
21
18
|
export function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
22
19
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls }), [partnerId, rpcUrls]);
|
|
23
|
-
return (_jsx(
|
|
20
|
+
return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, children: _jsx(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: children }) }));
|
|
24
21
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parallel to AuthenticationProvider for Better Auth strategy.
|
|
3
|
+
*
|
|
4
|
+
* Manages the isAuthenticating lifecycle for Better Auth:
|
|
5
|
+
* 1. On mount, try to restore an existing Feathers JWT (from a previous login)
|
|
6
|
+
* 2. If no Feathers JWT, check for a Better Auth session (e.g. after OAuth redirect)
|
|
7
|
+
* and exchange it for a Feathers JWT
|
|
8
|
+
* 3. If neither exists, set isAuthenticating: false so the login UI renders
|
|
9
|
+
*
|
|
10
|
+
* Also patches app.logout() so any code path that calls it (useAuthentication,
|
|
11
|
+
* useAuth, SignIn component, etc.) automatically clears the Better Auth session.
|
|
12
|
+
*/
|
|
13
|
+
declare const BetterAuthProvider: ({ partnerId }: {
|
|
14
|
+
partnerId: string;
|
|
15
|
+
}) => null;
|
|
16
|
+
export default BetterAuthProvider;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import app from "../../../../global-account/app.js";
|
|
2
|
+
import { useAuthStore } from "../../../../global-account/react/index.js";
|
|
3
|
+
import { B3_AUTH_COOKIE_NAME } from "../../../../shared/constants/index.js";
|
|
4
|
+
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
5
|
+
import Cookies from "js-cookie";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { betterAuthClient } from "../../../better-auth-client.js";
|
|
8
|
+
import { useUserQuery } from "../../hooks/useUserQuery.js";
|
|
9
|
+
const debug = debugB3React("BetterAuthProvider");
|
|
10
|
+
/**
|
|
11
|
+
* Parallel to AuthenticationProvider for Better Auth strategy.
|
|
12
|
+
*
|
|
13
|
+
* Manages the isAuthenticating lifecycle for Better Auth:
|
|
14
|
+
* 1. On mount, try to restore an existing Feathers JWT (from a previous login)
|
|
15
|
+
* 2. If no Feathers JWT, check for a Better Auth session (e.g. after OAuth redirect)
|
|
16
|
+
* and exchange it for a Feathers JWT
|
|
17
|
+
* 3. If neither exists, set isAuthenticating: false so the login UI renders
|
|
18
|
+
*
|
|
19
|
+
* Also patches app.logout() so any code path that calls it (useAuthentication,
|
|
20
|
+
* useAuth, SignIn component, etc.) automatically clears the Better Auth session.
|
|
21
|
+
*/
|
|
22
|
+
const BetterAuthProvider = ({ partnerId }) => {
|
|
23
|
+
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
24
|
+
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
25
|
+
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
26
|
+
const { setUser } = useUserQuery();
|
|
27
|
+
const hasAttemptedRestore = useRef(false);
|
|
28
|
+
const hasPatched = useRef(false);
|
|
29
|
+
// Patch app.logout() to also clear the Better Auth session.
|
|
30
|
+
// This ensures any existing logout path (useAuthentication, useAuth, SignIn
|
|
31
|
+
// dropdown, etc.) clears both the Feathers JWT and the Better Auth session.
|
|
32
|
+
// Patch app.logout() to also clear the Better Auth session.
|
|
33
|
+
// Only handles Better Auth signOut — state cleanup (isAuthenticated, isConnected,
|
|
34
|
+
// setUser, localStorage) is handled by useAuthentication/useAuth's own logout.
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (hasPatched.current)
|
|
37
|
+
return;
|
|
38
|
+
hasPatched.current = true;
|
|
39
|
+
const originalLogout = app.logout.bind(app);
|
|
40
|
+
app.logout = async () => {
|
|
41
|
+
debug("Patched logout: clearing Better Auth session");
|
|
42
|
+
try {
|
|
43
|
+
await betterAuthClient.signOut();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
debug("Better Auth signOut failed (non-critical)");
|
|
47
|
+
}
|
|
48
|
+
return originalLogout();
|
|
49
|
+
};
|
|
50
|
+
return () => {
|
|
51
|
+
app.logout = originalLogout;
|
|
52
|
+
hasPatched.current = false;
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
// Session restore on mount
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (hasAttemptedRestore.current)
|
|
58
|
+
return;
|
|
59
|
+
hasAttemptedRestore.current = true;
|
|
60
|
+
const restoreSession = async () => {
|
|
61
|
+
debug("Attempting session restore");
|
|
62
|
+
// 1. Try existing Feathers JWT first (fastest — no network call to Better Auth)
|
|
63
|
+
try {
|
|
64
|
+
const response = await app.reAuthenticate();
|
|
65
|
+
if (response?.user) {
|
|
66
|
+
debug("Feathers JWT restored", { userId: response.user.userId });
|
|
67
|
+
setUser(response.user);
|
|
68
|
+
setIsAuthenticated(true);
|
|
69
|
+
setIsConnected(true);
|
|
70
|
+
setIsAuthenticating(false);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
debug("No existing Feathers JWT");
|
|
76
|
+
}
|
|
77
|
+
// 2. Check for a Better Auth session (e.g. after OAuth redirect sets a cookie)
|
|
78
|
+
try {
|
|
79
|
+
const session = await betterAuthClient.getSession();
|
|
80
|
+
if (session.data?.session?.token) {
|
|
81
|
+
debug("Better Auth session found, exchanging for Feathers JWT", {
|
|
82
|
+
betterAuthUserId: session.data.user?.id,
|
|
83
|
+
});
|
|
84
|
+
const response = await app.authenticate({
|
|
85
|
+
strategy: "better-auth",
|
|
86
|
+
accessToken: session.data.session.token,
|
|
87
|
+
partnerId,
|
|
88
|
+
});
|
|
89
|
+
if (response.accessToken) {
|
|
90
|
+
Cookies.set(B3_AUTH_COOKIE_NAME, response.accessToken, {
|
|
91
|
+
secure: true,
|
|
92
|
+
sameSite: "Lax",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (response.user) {
|
|
96
|
+
setUser(response.user);
|
|
97
|
+
setIsAuthenticated(true);
|
|
98
|
+
setIsConnected(true);
|
|
99
|
+
}
|
|
100
|
+
debug("OAuth session exchanged for Feathers JWT", { userId: response.user?.userId });
|
|
101
|
+
setIsAuthenticating(false);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
debug("No Better Auth session to restore");
|
|
107
|
+
}
|
|
108
|
+
// 3. Nothing found — show login UI
|
|
109
|
+
setIsAuthenticating(false);
|
|
110
|
+
};
|
|
111
|
+
restoreSession();
|
|
112
|
+
}, [setIsAuthenticated, setIsAuthenticating, setIsConnected, setUser, partnerId]);
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
115
|
+
export default BetterAuthProvider;
|
|
@@ -6,13 +6,15 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
6
6
|
export interface LocalSDKContextType {
|
|
7
7
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
8
8
|
onLogoutCallback?: () => void | Promise<void>;
|
|
9
|
+
disableBSMNTAuthentication?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const LocalSDKContext: import("react").Context<LocalSDKContextType>;
|
|
11
12
|
/**
|
|
12
13
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
13
14
|
*/
|
|
14
|
-
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }: {
|
|
15
|
+
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, disableBSMNTAuthentication, }: {
|
|
15
16
|
children: React.ReactNode;
|
|
16
17
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
17
18
|
onLogoutCallback?: () => void | Promise<void>;
|
|
19
|
+
disableBSMNTAuthentication?: boolean;
|
|
18
20
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,13 +3,15 @@ import { createContext } from "react";
|
|
|
3
3
|
export const LocalSDKContext = createContext({
|
|
4
4
|
onConnectCallback: undefined,
|
|
5
5
|
onLogoutCallback: undefined,
|
|
6
|
+
disableBSMNTAuthentication: false,
|
|
6
7
|
});
|
|
7
8
|
/**
|
|
8
9
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
9
10
|
*/
|
|
10
|
-
export function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }) {
|
|
11
|
+
export function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, disableBSMNTAuthentication, }) {
|
|
11
12
|
return (_jsx(LocalSDKContext.Provider, { value: {
|
|
12
13
|
onConnectCallback,
|
|
13
14
|
onLogoutCallback,
|
|
15
|
+
disableBSMNTAuthentication,
|
|
14
16
|
}, children: children }));
|
|
15
17
|
}
|
|
@@ -16,6 +16,8 @@ interface IPFSMediaRendererProps {
|
|
|
16
16
|
controls?: boolean;
|
|
17
17
|
/** Style object */
|
|
18
18
|
style?: React.CSSProperties;
|
|
19
|
+
/** Callback when media fails to load */
|
|
20
|
+
onError?: () => void;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* IPFSMediaRenderer - A wrapper around Thirdweb's MediaRenderer that configures
|
|
@@ -35,5 +37,5 @@ interface IPFSMediaRendererProps {
|
|
|
35
37
|
* />
|
|
36
38
|
* ```
|
|
37
39
|
*/
|
|
38
|
-
export declare function IPFSMediaRenderer({ src, alt, className, client, width, height, controls, style, }: IPFSMediaRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare function IPFSMediaRenderer({ src, alt, className, client, width, height, controls, style, onError, }: IPFSMediaRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
39
41
|
export {};
|
|
@@ -21,7 +21,7 @@ import { MediaRenderer } from "thirdweb/react";
|
|
|
21
21
|
* />
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export function IPFSMediaRenderer({ src, alt = "Media", className, client = defaultClient, width, height, controls, style, }) {
|
|
24
|
+
export function IPFSMediaRenderer({ src, alt = "Media", className, client = defaultClient, width, height, controls, style, onError, }) {
|
|
25
25
|
// If no source, render fallback
|
|
26
26
|
if (!src) {
|
|
27
27
|
return (_jsx("div", { className: className, style: style, "aria-label": alt, children: _jsx("div", { className: "bg-b3-primary-wash flex h-full w-full items-center justify-center rounded-full", children: _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-xs", children: alt.charAt(0).toUpperCase() }) }) }));
|
|
@@ -29,5 +29,7 @@ export function IPFSMediaRenderer({ src, alt = "Media", className, client = defa
|
|
|
29
29
|
// Convert IPFS URLs to HTTP gateway URLs using our preferred gateway
|
|
30
30
|
// This avoids Thirdweb's default cloudflare-ipfs.com which can be unreliable
|
|
31
31
|
const resolvedSrc = src.startsWith("ipfs://") ? getIpfsUrl(src) : src;
|
|
32
|
-
|
|
32
|
+
// Wrap in a span with onErrorCapture to catch img/video load errors from
|
|
33
|
+
// MediaRenderer, which doesn't expose an onError prop itself.
|
|
34
|
+
return (_jsx("span", { onErrorCapture: onError, className: "contents", children: _jsx(MediaRenderer, { src: resolvedSrc, client: client, alt: alt, className: className, width: width ? width.toString() : undefined, height: height ? height.toString() : undefined, controls: controls, style: style }) }));
|
|
33
35
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, toast, useProfile } from "../../../../global-account/react/index.js";
|
|
3
|
+
import { validateImageUrl } from "../../../../global-account/react/utils/profileDisplay.js";
|
|
3
4
|
import { truncateAddress } from "../../../../shared/utils/truncateAddress.js";
|
|
4
5
|
import { Copy, Loader2, UnlinkIcon } from "lucide-react";
|
|
5
6
|
// Helper function to check if a string is a wallet address and format it
|
|
@@ -30,7 +31,7 @@ const LinkedAccountItem = ({ profile, profileToUnlink, unlinkingAccountId, isUnl
|
|
|
30
31
|
toast.error("Failed to copy address");
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
|
-
const displayImageUrl = profileData?.avatar || profile.imageUrl;
|
|
34
|
+
const displayImageUrl = validateImageUrl(profileData?.avatar) || validateImageUrl(profile.imageUrl);
|
|
34
35
|
const displayName = profileData?.name || displayTitle;
|
|
35
36
|
return (_jsxs("div", { className: "linked-account-item hover:bg-b3-line group flex cursor-pointer items-center justify-between rounded-xl p-4 transition-colors", children: [_jsxs("div", { className: "linked-account-info flex items-center gap-3", children: [displayImageUrl ? (_jsx("img", { src: displayImageUrl, alt: profile.title, className: "linked-account-avatar linked-account-avatar-image size-10 rounded-full" })) : (_jsx("div", { className: "linked-account-avatar linked-account-avatar-placeholder bg-b3-primary-wash flex h-10 w-10 items-center justify-center rounded-full", children: _jsx("span", { className: "linked-account-initial text-b3-grey font-neue-montreal-semibold text-sm uppercase", children: profile.initial }) })), _jsxs("div", { className: "linked-account-details", children: [_jsxs("div", { className: "linked-account-title-row flex items-center gap-2", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("span", { className: `linked-account-title text-b3-grey font-neue-montreal-semibold ${isAddress
|
|
36
37
|
? "font-mono text-sm" // Use monospace font for addresses
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useAccountWallet, useModalStore, useProfile, useSimBalance, useUser, } from "../../../../global-account/react/index.js";
|
|
3
|
+
import { validateImageUrl } from "../../../../global-account/react/utils/profileDisplay.js";
|
|
3
4
|
import { formatUsername } from "../../../../shared/utils/index.js";
|
|
4
5
|
import { formatDisplayNumber } from "../../../../shared/utils/number.js";
|
|
6
|
+
import Avatar from "boring-avatars";
|
|
5
7
|
import { Pencil } from "lucide-react";
|
|
6
|
-
import { useMemo } from "react";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
9
|
import { useActiveAccount } from "thirdweb/react";
|
|
8
10
|
import { useFirstEOA } from "../../hooks/useFirstEOA.js";
|
|
9
11
|
import { IPFSMediaRenderer } from "../IPFSMediaRenderer/IPFSMediaRenderer.js";
|
|
12
|
+
const AVATAR_COLORS = ["#3368ef", "#272727", "#6366f1", "#06b6d4", "#eeb0d9", "#ba3fbf", "#ff777b", "#dfbb53"];
|
|
10
13
|
const ProfileSection = () => {
|
|
11
14
|
const account = useActiveAccount();
|
|
12
15
|
const { address: eoaAddress } = useFirstEOA();
|
|
@@ -20,7 +23,8 @@ const ProfileSection = () => {
|
|
|
20
23
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
21
24
|
const navigateBack = useModalStore(state => state.navigateBack);
|
|
22
25
|
const { data: simBalance } = useSimBalance(smartWalletAddress);
|
|
23
|
-
|
|
26
|
+
const [imgError, setImgError] = useState(false);
|
|
27
|
+
const handleImgError = useCallback(() => setImgError(true), []);
|
|
24
28
|
const totalBalanceUsd = useMemo(() => {
|
|
25
29
|
if (!simBalance?.balances)
|
|
26
30
|
return 0;
|
|
@@ -31,15 +35,17 @@ const ProfileSection = () => {
|
|
|
31
35
|
setB3ModalContentType({
|
|
32
36
|
type: "avatarEditor",
|
|
33
37
|
onSuccess: () => {
|
|
34
|
-
// navigate back on success
|
|
35
38
|
navigateBack();
|
|
36
39
|
},
|
|
37
40
|
});
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const avatarSrc = useMemo(() => validateImageUrl(user?.avatar) || validateImageUrl(profile?.avatar), [user?.avatar, profile?.avatar]);
|
|
43
|
+
// Reset error state when avatar source changes (e.g. user uploads a new avatar)
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setImgError(false);
|
|
46
|
+
}, [avatarSrc]);
|
|
42
47
|
const currentUsername = user?.username || profile?.displayName || formatUsername(profile?.name || "");
|
|
43
|
-
|
|
48
|
+
const avatarSeed = eoaAddress || account?.address || smartWalletAddress || currentUsername || "user";
|
|
49
|
+
return (_jsx("div", { className: "flex items-center justify-between px-5 py-6", children: _jsxs("div", { className: "global-account-profile flex items-center gap-4", children: [_jsxs("div", { className: "global-account-profile-avatar relative", children: [_jsx("div", { className: "border-b3-line border-1 bg-b3-primary-wash size-14 overflow-hidden rounded-full border", children: avatarSrc && !imgError ? (_jsx(IPFSMediaRenderer, { src: avatarSrc, alt: "Profile Avatar", className: "h-full w-full object-cover", onError: handleImgError })) : (_jsx(Avatar, { name: avatarSeed, variant: "beam", size: 56, colors: AVATAR_COLORS })) }), _jsx("button", { onClick: handleEditAvatar, className: "border-b3-background hover:bg-b3-grey/80 absolute -bottom-1 -right-1 flex size-6 items-center justify-center rounded-full border-4 bg-[#a0a0ab] transition-colors", children: _jsx(Pencil, { size: 10, className: "text-b3-background" }) })] }), _jsxs("div", { className: "global-account-profile-info flex flex-col gap-1", children: [_jsxs("h2", { className: "text-b3-grey font-neue-montreal-semibold flex h-[38px] items-center gap-1 text-xl", children: [_jsx("div", { className: "text-b3-foreground-muted", children: " $" }), _jsx("div", { className: "text-[30px]", children: formatDisplayNumber(totalBalanceUsd, { fractionDigits: 2 }) })] }), _jsx("div", { className: "b3-modal-username font-neue-montreal-semibold text-base leading-none text-[#0B57C2]", children: currentUsername })] })] }) }));
|
|
44
50
|
};
|
|
45
51
|
export default ProfileSection;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { ens_normalize } from "@adraffy/ens-normalize";
|
|
3
3
|
import app from "../../../../global-account/app.js";
|
|
4
4
|
import { toast, useAuthentication, useB3Config, useModalStore, useProfile } from "../../../../global-account/react/index.js";
|
|
5
|
+
import { validateImageUrl } from "../../../../global-account/react/utils/profileDisplay.js";
|
|
5
6
|
import { formatUsername } from "../../../../shared/utils/index.js";
|
|
6
7
|
import { Check, Loader2, Pencil, X } from "lucide-react";
|
|
7
8
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -25,8 +26,7 @@ const SettingsProfileCard = () => {
|
|
|
25
26
|
const [editedUsername, setEditedUsername] = useState("");
|
|
26
27
|
const [isSaving, setIsSaving] = useState(false);
|
|
27
28
|
const inputRef = useRef(null);
|
|
28
|
-
|
|
29
|
-
const avatarSrc = user?.avatar || profile?.avatar;
|
|
29
|
+
const avatarSrc = validateImageUrl(user?.avatar) || validateImageUrl(profile?.avatar);
|
|
30
30
|
// Get current username - prioritize user.username, fallback to profile data
|
|
31
31
|
const currentUsername = user?.username || profile?.displayName || formatUsername(profile?.name || "");
|
|
32
32
|
// Focus input when entering edit mode
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { ALL_CHAINS, getExplorerTxUrl } from "../../../../anyspend/index.js";
|
|
3
3
|
import { ChainTokenIcon } from "../../../../anyspend/react/components/common/ChainTokenIcon.js";
|
|
4
4
|
import { toast, useAccountWallet, useAnalytics, useModalStore, useProfile, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
|
|
5
|
+
import { validateImageUrl } from "../../../../global-account/react/utils/profileDisplay.js";
|
|
5
6
|
import { formatDisplayNumber, formatTokenAmount } from "../../../../shared/utils/number.js";
|
|
6
7
|
import invariant from "invariant";
|
|
7
8
|
import { CircleHelp, Clock, Loader2, Send as SendIcon, Wallet } from "lucide-react";
|
|
@@ -14,7 +15,8 @@ import { Button } from "../ui/button.js";
|
|
|
14
15
|
// Component for displaying a recent address with profile data
|
|
15
16
|
function RecentAddressItem({ address, onClick }) {
|
|
16
17
|
const { data: profileData } = useProfile({ address });
|
|
17
|
-
|
|
18
|
+
const validatedAvatar = validateImageUrl(profileData?.avatar);
|
|
19
|
+
return (_jsxs("button", { onClick: onClick, className: "flex items-center gap-2 rounded-xl px-3 py-2 transition-colors hover:bg-[#fafafa]", children: [validatedAvatar ? (_jsx("img", { src: validatedAvatar, alt: profileData?.name || address, className: "h-10 w-10 rounded-full" })) : (_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full border border-[#e4e4e7] bg-[#f4f4f5]", children: _jsx(Wallet, { className: "h-5 w-5 text-[#a0a0ab]" }) })), _jsx("div", { className: "flex flex-col items-start", children: _jsxs("span", { className: "font-neue-montreal-medium text-base tracking-[-0.32px] text-[#70707b]", children: [address.slice(0, 6), "...", address.slice(-4), profileData?.name && ` (${profileData.name})`] }) })] }));
|
|
18
20
|
}
|
|
19
21
|
export function Send({ recipientAddress: initialRecipient, onSuccess }) {
|
|
20
22
|
const { address } = useAccountWallet();
|
|
@@ -39,6 +41,7 @@ export function Send({ recipientAddress: initialRecipient, onSuccess }) {
|
|
|
39
41
|
const { data: validatedProfileData } = useProfile({
|
|
40
42
|
address: showValidatedResult && recipientAddress && isAddress(recipientAddress) ? recipientAddress : undefined,
|
|
41
43
|
});
|
|
44
|
+
const validatedRecipientAvatar = validateImageUrl(validatedProfileData?.avatar);
|
|
42
45
|
// Address validation
|
|
43
46
|
const handleRecipientAddressChange = (value) => {
|
|
44
47
|
setRecipientAddress(value);
|
|
@@ -179,7 +182,7 @@ export function Send({ recipientAddress: initialRecipient, onSuccess }) {
|
|
|
179
182
|
return "Send";
|
|
180
183
|
}
|
|
181
184
|
};
|
|
182
|
-
return (_jsxs("div", { className: "dark:bg-b3-background flex h-[600px] w-full flex-col bg-white", children: [_jsx(ModalHeader, { handleBack: handleBack, title: getStepTitle() }), _jsxs("div", { className: "flex-1 overflow-y-auto", children: [step === "recipient" && (_jsxs("div", { className: "flex flex-col gap-6 p-5", children: [_jsxs("div", { className: "dark:border-b3-line dark:bg-b3-background flex h-12 w-full items-stretch overflow-hidden rounded-lg border border-[#d1d1d6] bg-white", children: [_jsx("div", { className: "flex w-12 items-center justify-center bg-transparent px-3 py-2", children: _jsx("span", { className: "font-neue-montreal-medium text-base text-[#3f3f46] dark:text-white", children: "To" }) }), _jsxs("div", { className: "flex flex-1 items-center border-l border-[#d1d1d6] px-3 py-2", children: [_jsx("input", { type: "text", value: recipientAddress, onChange: e => handleRecipientAddressChange(e.target.value), placeholder: "ENS or Address", className: "font-neue-montreal-medium dark:bg-b3-background flex-1 text-base text-[#70707b] outline-none placeholder:text-[#70707b] dark:text-white dark:placeholder:text-white" }), _jsx("button", { onClick: handlePaste, className: "font-inter ml-2 rounded-md border border-[#e4e4e7] bg-[#fafafa] px-2.5 py-0.5 text-sm font-medium text-[#3f3f46] transition-colors hover:bg-[#f4f4f5]", children: "Paste" })] })] }), addressError && _jsx("p", { className: "font-neue-montreal-medium -mt-4 text-xs text-red-500", children: addressError }), showValidatedResult && recipientAddress && isAddress(recipientAddress) && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex items-center gap-1", children: _jsx("span", { className: "font-sf-pro-text text-sm font-semibold leading-[1.3] tracking-[-0.41px] text-[#0b57c2]", children: "Result" }) }), _jsxs("button", { onClick: handleSelectValidatedAddress, className: "dark:bg-b3-background dark:border-b3-line flex items-center gap-2 rounded-xl bg-[#f4f4f5] px-3 py-2 transition-colors hover:bg-[#e4e4e7]", children: [
|
|
185
|
+
return (_jsxs("div", { className: "dark:bg-b3-background flex h-[600px] w-full flex-col bg-white", children: [_jsx(ModalHeader, { handleBack: handleBack, title: getStepTitle() }), _jsxs("div", { className: "flex-1 overflow-y-auto", children: [step === "recipient" && (_jsxs("div", { className: "flex flex-col gap-6 p-5", children: [_jsxs("div", { className: "dark:border-b3-line dark:bg-b3-background flex h-12 w-full items-stretch overflow-hidden rounded-lg border border-[#d1d1d6] bg-white", children: [_jsx("div", { className: "flex w-12 items-center justify-center bg-transparent px-3 py-2", children: _jsx("span", { className: "font-neue-montreal-medium text-base text-[#3f3f46] dark:text-white", children: "To" }) }), _jsxs("div", { className: "flex flex-1 items-center border-l border-[#d1d1d6] px-3 py-2", children: [_jsx("input", { type: "text", value: recipientAddress, onChange: e => handleRecipientAddressChange(e.target.value), placeholder: "ENS or Address", className: "font-neue-montreal-medium dark:bg-b3-background flex-1 text-base text-[#70707b] outline-none placeholder:text-[#70707b] dark:text-white dark:placeholder:text-white" }), _jsx("button", { onClick: handlePaste, className: "font-inter ml-2 rounded-md border border-[#e4e4e7] bg-[#fafafa] px-2.5 py-0.5 text-sm font-medium text-[#3f3f46] transition-colors hover:bg-[#f4f4f5]", children: "Paste" })] })] }), addressError && _jsx("p", { className: "font-neue-montreal-medium -mt-4 text-xs text-red-500", children: addressError }), showValidatedResult && recipientAddress && isAddress(recipientAddress) && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex items-center gap-1", children: _jsx("span", { className: "font-sf-pro-text text-sm font-semibold leading-[1.3] tracking-[-0.41px] text-[#0b57c2]", children: "Result" }) }), _jsxs("button", { onClick: handleSelectValidatedAddress, className: "dark:bg-b3-background dark:border-b3-line flex items-center gap-2 rounded-xl bg-[#f4f4f5] px-3 py-2 transition-colors hover:bg-[#e4e4e7]", children: [validatedRecipientAvatar ? (_jsx("img", { src: validatedRecipientAvatar, alt: validatedProfileData?.name || recipientAddress, className: "h-10 w-10 rounded-full" })) : (_jsx("div", { className: "dark:border-b3-line dark:bg-b3-background flex h-10 w-10 items-center justify-center rounded-full border border-[#e4e4e7] bg-[#f4f4f5]", children: _jsx(Wallet, { className: "h-5 w-5 text-[#a0a0ab] dark:text-white" }) })), _jsxs("span", { className: "font-neue-montreal-medium text-base tracking-[-0.32px] text-[#70707b] dark:text-white", children: [recipientAddress.slice(0, 6), "...", recipientAddress.slice(-4), validatedProfileData?.name && ` (${validatedProfileData.name})`] })] })] })), recentAddresses.length > 0 && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Clock, { className: "h-3.5 w-3.5 text-[#3f3f46]" }), _jsx("span", { className: "font-sf-pro-text text-sm font-semibold leading-[1.3] tracking-[-0.41px] text-[#3f3f46]", children: "Recents" })] }), _jsx("div", { className: "flex flex-col", children: recentAddresses.map((recent, index) => (_jsx(RecentAddressItem, { address: recent.address, onClick: () => {
|
|
183
186
|
// Just fill the input and show validation - don't auto-proceed
|
|
184
187
|
handleRecipientAddressChange(recent.address);
|
|
185
188
|
} }, index))) })] }))] })), step === "token" && (_jsx("div", { className: "flex flex-col p-5", children: isLoadingBalance ? (_jsx("div", { className: "space-y-4", children: _jsx("div", { className: "space-y-1", children: [...Array(3)].map((_, index) => (_jsxs("div", { className: "flex items-center justify-between rounded-xl p-3", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "bg-b3-line h-10 w-10 animate-pulse rounded-full" }), _jsxs("div", { children: [_jsx("div", { className: "bg-b3-line mb-1 h-4 w-16 animate-pulse rounded" }), _jsx("div", { className: "bg-b3-line h-3 w-24 animate-pulse rounded" })] })] }), _jsxs("div", { className: "text-right", children: [_jsx("div", { className: "bg-b3-line mb-1 h-4 w-20 animate-pulse rounded" }), _jsx("div", { className: "bg-b3-line h-3 w-16 animate-pulse rounded" })] })] }, index))) }) })) : simBalance?.balances && simBalance.balances.length > 0 ? (_jsx("div", { className: "space-y-4", children: _jsx("div", { className: "space-y-1", children: simBalance.balances.map(token => (_jsxs("div", { className: "hover:bg-b3-line/60 dark:hover:bg-b3-primary-wash/40 group flex cursor-pointer items-center justify-between rounded-xl p-3 transition-all duration-200", onClick: () => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface BetterAuthResetPasswordProps {
|
|
2
|
+
/** The reset token from the URL query param */
|
|
3
|
+
token: string;
|
|
4
|
+
/** Called after password is successfully reset */
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
/** Called on error */
|
|
7
|
+
onError?: (error: Error) => void;
|
|
8
|
+
/** Optional class name */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Standalone reset password form. Render this on your reset password page.
|
|
13
|
+
* Reads the token from props (extract it from the URL query string).
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const token = new URLSearchParams(window.location.search).get("token");
|
|
18
|
+
* <BetterAuthResetPassword token={token} onSuccess={() => navigate("/login")} />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function BetterAuthResetPassword({ token, onSuccess, onError, className }: BetterAuthResetPasswordProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Input } from "../../../../global-account/react/index.js";
|
|
3
|
+
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useBetterAuth } from "../../hooks/useBetterAuth.js";
|
|
6
|
+
const debug = debugB3React("BetterAuthResetPassword");
|
|
7
|
+
/**
|
|
8
|
+
* Standalone reset password form. Render this on your reset password page.
|
|
9
|
+
* Reads the token from props (extract it from the URL query string).
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const token = new URLSearchParams(window.location.search).get("token");
|
|
14
|
+
* <BetterAuthResetPassword token={token} onSuccess={() => navigate("/login")} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function BetterAuthResetPassword({ token, onSuccess, onError, className }) {
|
|
18
|
+
const { resetPassword } = useBetterAuth();
|
|
19
|
+
const [password, setPassword] = useState("");
|
|
20
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
21
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
22
|
+
const [error, setError] = useState(null);
|
|
23
|
+
const [success, setSuccess] = useState(false);
|
|
24
|
+
const handleSubmit = async () => {
|
|
25
|
+
if (!password) {
|
|
26
|
+
setError("Please enter a new password");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (password.length < 8) {
|
|
30
|
+
setError("Password must be at least 8 characters");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (password !== confirmPassword) {
|
|
34
|
+
setError("Passwords do not match");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
setIsLoading(true);
|
|
39
|
+
setError(null);
|
|
40
|
+
await resetPassword(password, token);
|
|
41
|
+
setSuccess(true);
|
|
42
|
+
debug("Password reset successful");
|
|
43
|
+
onSuccess?.();
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
const message = err instanceof Error ? err.message : "Password reset failed";
|
|
47
|
+
setError(message);
|
|
48
|
+
debug("Password reset failed", err);
|
|
49
|
+
onError?.(err);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setPassword("");
|
|
53
|
+
setConfirmPassword("");
|
|
54
|
+
setIsLoading(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
if (!token) {
|
|
58
|
+
return (_jsx("div", { className: `w-full max-w-[400px] px-6 text-center ${className || ""}`, children: _jsx("p", { className: "text-sm text-red-500", children: "Invalid or missing reset token." }) }));
|
|
59
|
+
}
|
|
60
|
+
return (_jsxs("div", { className: `w-full max-w-[400px] px-6 ${className || ""}`, children: [_jsxs("div", { className: "mb-10 text-center", children: [_jsx("h1", { className: "text-[28px] font-semibold tracking-tight text-gray-900 dark:text-gray-100", children: success ? "Password reset" : "Set new password" }), _jsx("p", { className: "mt-3 text-[15px] text-gray-500 dark:text-gray-400", children: success ? "Your password has been updated." : "Enter your new password below." })] }), success ? (_jsx("div", { className: "space-y-4 text-center", children: _jsx("div", { className: "mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100", children: _jsx("svg", { className: "h-6 w-6 text-green-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }) }) })) : (_jsxs("div", { className: "space-y-5", children: [_jsxs("div", { children: [_jsx("label", { className: "mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300", children: "New password" }), _jsx(Input, { type: "password", placeholder: "At least 8 characters", value: password, onChange: e => setPassword(e.target.value), disabled: isLoading, className: "h-11 px-4 text-[15px]" })] }), _jsxs("div", { children: [_jsx("label", { className: "mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300", children: "Confirm password" }), _jsx(Input, { type: "password", placeholder: "Repeat your password", value: confirmPassword, onChange: e => setConfirmPassword(e.target.value), disabled: isLoading, onKeyDown: e => {
|
|
61
|
+
if (e.key === "Enter")
|
|
62
|
+
handleSubmit();
|
|
63
|
+
}, className: "h-11 px-4 text-[15px]" })] }), error && _jsx("p", { className: "text-sm text-red-500", children: error }), _jsx(Button, { onClick: handleSubmit, disabled: isLoading, className: "h-11 w-full bg-gray-900 text-[15px] font-medium text-white hover:bg-gray-800 dark:bg-white dark:text-gray-900 dark:hover:bg-gray-100", children: isLoading ? "Resetting..." : "Reset password" })] }))] }));
|
|
64
|
+
}
|