@varity-labs/ui-kit 2.0.0-beta.8 → 2.0.0-beta.9
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/components/Dashboard/DashboardHeader.js +4 -4
- package/dist/components/Dashboard/DashboardHeader.js.map +1 -1
- package/dist/components/Dashboard/DashboardLayout.d.ts +3 -3
- package/dist/components/Dashboard/DashboardLayout.d.ts.map +1 -1
- package/dist/components/Dashboard/DashboardLayout.js +1 -1
- package/dist/components/InAppWallet/EmailLoginButton.d.ts +27 -0
- package/dist/components/InAppWallet/EmailLoginButton.d.ts.map +1 -0
- package/dist/components/InAppWallet/EmailLoginButton.js +84 -0
- package/dist/components/InAppWallet/EmailLoginButton.js.map +1 -0
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts +54 -0
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts.map +1 -0
- package/dist/components/InAppWallet/InAppWalletProvider.js +225 -0
- package/dist/components/InAppWallet/InAppWalletProvider.js.map +1 -0
- package/dist/components/InAppWallet/OnboardingFlow.d.ts +25 -0
- package/dist/components/InAppWallet/OnboardingFlow.d.ts.map +1 -0
- package/dist/components/InAppWallet/OnboardingFlow.js +159 -0
- package/dist/components/InAppWallet/OnboardingFlow.js.map +1 -0
- package/dist/components/InAppWallet/SocialLoginButtons.d.ts +28 -0
- package/dist/components/InAppWallet/SocialLoginButtons.d.ts.map +1 -0
- package/dist/components/InAppWallet/SocialLoginButtons.js +128 -0
- package/dist/components/InAppWallet/SocialLoginButtons.js.map +1 -0
- package/dist/components/InAppWallet/index.d.ts +15 -0
- package/dist/components/InAppWallet/index.d.ts.map +1 -0
- package/dist/components/InAppWallet/index.js +14 -0
- package/dist/components/InAppWallet/index.js.map +1 -0
- package/dist/components/PaymentWidget/PaymentWidget.d.ts +19 -7
- package/dist/components/PaymentWidget/PaymentWidget.d.ts.map +1 -1
- package/dist/components/PaymentWidget/PaymentWidget.js +176 -10
- package/dist/components/PaymentWidget/PaymentWidget.js.map +1 -1
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts +34 -8
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts.map +1 -1
- package/dist/components/PaymentWidget/useSeamlessPayment.js +158 -12
- package/dist/components/PaymentWidget/useSeamlessPayment.js.map +1 -1
- package/dist/components/PaymentWidget/useVarityPayment.d.ts +6 -5
- package/dist/components/PaymentWidget/useVarityPayment.d.ts.map +1 -1
- package/dist/components/PaymentWidget/useVarityPayment.js +147 -11
- package/dist/components/PaymentWidget/useVarityPayment.js.map +1 -1
- package/dist/components/Payments/CheckoutModal.d.ts +19 -0
- package/dist/components/Payments/CheckoutModal.d.ts.map +1 -0
- package/dist/components/Payments/CheckoutModal.js +194 -0
- package/dist/components/Payments/CheckoutModal.js.map +1 -0
- package/dist/components/Payments/SubscriptionWidget.d.ts +17 -0
- package/dist/components/Payments/SubscriptionWidget.d.ts.map +1 -0
- package/dist/components/Payments/SubscriptionWidget.js +89 -0
- package/dist/components/Payments/SubscriptionWidget.js.map +1 -0
- package/dist/components/Payments/constants.d.ts +59 -0
- package/dist/components/Payments/constants.d.ts.map +1 -0
- package/dist/components/Payments/constants.js +145 -0
- package/dist/components/Payments/constants.js.map +1 -0
- package/dist/components/Payments/index.d.ts +10 -0
- package/dist/components/Payments/index.d.ts.map +1 -0
- package/dist/components/Payments/index.js +12 -0
- package/dist/components/Payments/index.js.map +1 -0
- package/dist/components/Payments/types.d.ts +119 -0
- package/dist/components/Payments/types.d.ts.map +1 -0
- package/dist/components/Payments/types.js +27 -0
- package/dist/components/Payments/types.js.map +1 -0
- package/dist/components/Payments/usePayments.d.ts +33 -0
- package/dist/components/Payments/usePayments.d.ts.map +1 -0
- package/dist/components/Payments/usePayments.js +249 -0
- package/dist/components/Payments/usePayments.js.map +1 -0
- package/dist/components/SIWE/AuthStatus.d.ts +15 -0
- package/dist/components/SIWE/AuthStatus.d.ts.map +1 -0
- package/dist/components/SIWE/AuthStatus.js +47 -0
- package/dist/components/SIWE/AuthStatus.js.map +1 -0
- package/dist/components/SIWE/ProtectedRoute.d.ts +17 -0
- package/dist/components/SIWE/ProtectedRoute.d.ts.map +1 -0
- package/dist/components/SIWE/ProtectedRoute.js +52 -0
- package/dist/components/SIWE/ProtectedRoute.js.map +1 -0
- package/dist/components/SIWE/SIWEButton.d.ts +22 -0
- package/dist/components/SIWE/SIWEButton.d.ts.map +1 -0
- package/dist/components/SIWE/SIWEButton.js +106 -0
- package/dist/components/SIWE/SIWEButton.js.map +1 -0
- package/dist/components/SIWE/SIWEModal.d.ts +19 -0
- package/dist/components/SIWE/SIWEModal.d.ts.map +1 -0
- package/dist/components/SIWE/SIWEModal.js +75 -0
- package/dist/components/SIWE/SIWEModal.js.map +1 -0
- package/dist/components/SIWE/SIWEProvider.d.ts +38 -0
- package/dist/components/SIWE/SIWEProvider.d.ts.map +1 -0
- package/dist/components/SIWE/SIWEProvider.js +227 -0
- package/dist/components/SIWE/SIWEProvider.js.map +1 -0
- package/dist/components/SIWE/index.d.ts +15 -0
- package/dist/components/SIWE/index.d.ts.map +1 -0
- package/dist/components/SIWE/index.js +10 -0
- package/dist/components/SIWE/index.js.map +1 -0
- package/dist/hooks/web3/index.d.ts +5 -0
- package/dist/hooks/web3/index.d.ts.map +1 -0
- package/dist/hooks/web3/index.js +6 -0
- package/dist/hooks/web3/index.js.map +1 -0
- package/dist/hooks/web3/useAddressValidation.d.ts +37 -0
- package/dist/hooks/web3/useAddressValidation.d.ts.map +1 -0
- package/dist/hooks/web3/useAddressValidation.js +59 -0
- package/dist/hooks/web3/useAddressValidation.js.map +1 -0
- package/dist/hooks/web3/useBlockExplorer.d.ts +37 -0
- package/dist/hooks/web3/useBlockExplorer.d.ts.map +1 -0
- package/dist/hooks/web3/useBlockExplorer.js +59 -0
- package/dist/hooks/web3/useBlockExplorer.js.map +1 -0
- package/dist/hooks/web3/useUSDCFormat.d.ts +34 -0
- package/dist/hooks/web3/useUSDCFormat.d.ts.map +1 -0
- package/dist/hooks/web3/useUSDCFormat.js +43 -0
- package/dist/hooks/web3/useUSDCFormat.js.map +1 -0
- package/dist/hooks/web3/useVarityWallet.d.ts +48 -0
- package/dist/hooks/web3/useVarityWallet.d.ts.map +1 -0
- package/dist/hooks/web3/useVarityWallet.js +70 -0
- package/dist/hooks/web3/useVarityWallet.js.map +1 -0
- package/dist/providers/ChainContext.d.ts +65 -0
- package/dist/providers/ChainContext.d.ts.map +1 -0
- package/dist/providers/ChainContext.js +92 -0
- package/dist/providers/ChainContext.js.map +1 -0
- package/dist/providers/PrivyStack.d.ts +17 -50
- package/dist/providers/PrivyStack.d.ts.map +1 -1
- package/dist/providers/PrivyStack.js +15 -43
- package/dist/providers/PrivyStack.js.map +1 -1
- package/dist/providers/VarityDashboardProvider.d.ts +2 -2
- package/dist/providers/VarityDashboardProvider.d.ts.map +1 -1
- package/dist/providers/VarityDashboardProvider.js +26 -3
- package/dist/providers/VarityDashboardProvider.js.map +1 -1
- package/dist/providers/VarityProvider.d.ts +32 -0
- package/dist/providers/VarityProvider.d.ts.map +1 -0
- package/dist/providers/VarityProvider.js +56 -0
- package/dist/providers/VarityProvider.js.map +1 -0
- package/dist/providers/WalletContext.d.ts +68 -0
- package/dist/providers/WalletContext.d.ts.map +1 -0
- package/dist/providers/WalletContext.js +98 -0
- package/dist/providers/WalletContext.js.map +1 -0
- package/dist/providers/WalletSyncProvider.d.ts +15 -18
- package/dist/providers/WalletSyncProvider.d.ts.map +1 -1
- package/dist/providers/WalletSyncProvider.js +12 -15
- package/dist/providers/WalletSyncProvider.js.map +1 -1
- package/dist/providers/index.d.ts +48 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +53 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/wallets/SimpleSmartWallet.d.ts +68 -0
- package/dist/wallets/SimpleSmartWallet.d.ts.map +1 -0
- package/dist/wallets/SimpleSmartWallet.js +74 -0
- package/dist/wallets/SimpleSmartWallet.js.map +1 -0
- package/dist/wallets/SmartWalletProvider.d.ts +217 -0
- package/dist/wallets/SmartWalletProvider.d.ts.map +1 -0
- package/dist/wallets/SmartWalletProvider.js +366 -0
- package/dist/wallets/SmartWalletProvider.js.map +1 -0
- package/dist/wallets/config.d.ts +222 -0
- package/dist/wallets/config.d.ts.map +1 -0
- package/dist/wallets/config.js +206 -0
- package/dist/wallets/config.js.map +1 -0
- package/dist/wallets/index.d.ts +9 -0
- package/dist/wallets/index.d.ts.map +1 -0
- package/dist/wallets/index.js +9 -0
- package/dist/wallets/index.js.map +1 -0
- package/dist/web3/AddressDisplay/AddressDisplay.d.ts +33 -0
- package/dist/web3/AddressDisplay/AddressDisplay.d.ts.map +1 -0
- package/dist/web3/AddressDisplay/AddressDisplay.js +42 -0
- package/dist/web3/AddressDisplay/AddressDisplay.js.map +1 -0
- package/dist/web3/AddressInput/AddressInput.d.ts +36 -0
- package/dist/web3/AddressInput/AddressInput.d.ts.map +1 -0
- package/dist/web3/AddressInput/AddressInput.js +54 -0
- package/dist/web3/AddressInput/AddressInput.js.map +1 -0
- package/dist/web3/AmountInput/AmountInput.d.ts +41 -0
- package/dist/web3/AmountInput/AmountInput.d.ts.map +1 -0
- package/dist/web3/AmountInput/AmountInput.js +74 -0
- package/dist/web3/AmountInput/AmountInput.js.map +1 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts +30 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts.map +1 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.js +35 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.js.map +1 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts +41 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts.map +1 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.js +46 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.js.map +1 -0
- package/dist/web3/ConnectWallet/ConnectWallet.d.ts +35 -0
- package/dist/web3/ConnectWallet/ConnectWallet.d.ts.map +1 -0
- package/dist/web3/ConnectWallet/ConnectWallet.js +58 -0
- package/dist/web3/ConnectWallet/ConnectWallet.js.map +1 -0
- package/dist/web3/DisconnectButton/DisconnectButton.d.ts +30 -0
- package/dist/web3/DisconnectButton/DisconnectButton.d.ts.map +1 -0
- package/dist/web3/DisconnectButton/DisconnectButton.js +48 -0
- package/dist/web3/DisconnectButton/DisconnectButton.js.map +1 -0
- package/dist/web3/WalletBalance/WalletBalance.d.ts +27 -0
- package/dist/web3/WalletBalance/WalletBalance.d.ts.map +1 -0
- package/dist/web3/WalletBalance/WalletBalance.js +49 -0
- package/dist/web3/WalletBalance/WalletBalance.js.map +1 -0
- package/dist/web3/WalletDropdown/WalletDropdown.d.ts +29 -0
- package/dist/web3/WalletDropdown/WalletDropdown.d.ts.map +1 -0
- package/dist/web3/WalletDropdown/WalletDropdown.js +93 -0
- package/dist/web3/WalletDropdown/WalletDropdown.js.map +1 -0
- package/dist/web3/WalletInfo/WalletInfo.d.ts +31 -0
- package/dist/web3/WalletInfo/WalletInfo.d.ts.map +1 -0
- package/dist/web3/WalletInfo/WalletInfo.js +41 -0
- package/dist/web3/WalletInfo/WalletInfo.js.map +1 -0
- package/dist/web3/index.d.ts +11 -0
- package/dist/web3/index.d.ts.map +1 -0
- package/dist/web3/index.js +14 -0
- package/dist/web3/index.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSIWE } from './SIWEProvider';
|
|
3
|
+
import { useActiveAccount } from 'thirdweb/react';
|
|
4
|
+
export const AuthStatus = ({ className = '', theme = 'dark', showAddress = true, showChainId = true, compact = false, }) => {
|
|
5
|
+
const { isAuthenticated, user, isLoading } = useSIWE();
|
|
6
|
+
const account = useActiveAccount();
|
|
7
|
+
if (isLoading) {
|
|
8
|
+
return (React.createElement("div", { className: `flex items-center gap-2 ${className}` },
|
|
9
|
+
React.createElement("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" }),
|
|
10
|
+
React.createElement("span", { className: theme === 'dark' ? 'text-gray-400' : 'text-gray-600' }, "Checking authentication...")));
|
|
11
|
+
}
|
|
12
|
+
if (!account) {
|
|
13
|
+
return (React.createElement("div", { className: `flex items-center gap-2 ${className}` },
|
|
14
|
+
React.createElement("div", { className: `w-2 h-2 rounded-full ${theme === 'dark' ? 'bg-gray-500' : 'bg-gray-400'}` }),
|
|
15
|
+
React.createElement("span", { className: theme === 'dark' ? 'text-gray-400' : 'text-gray-600' }, "Wallet not connected")));
|
|
16
|
+
}
|
|
17
|
+
if (!isAuthenticated) {
|
|
18
|
+
return (React.createElement("div", { className: `flex items-center gap-2 ${className}` },
|
|
19
|
+
React.createElement("div", { className: "w-2 h-2 rounded-full bg-yellow-500 animate-pulse" }),
|
|
20
|
+
React.createElement("span", { className: theme === 'dark' ? 'text-gray-400' : 'text-gray-600' }, "Not authenticated")));
|
|
21
|
+
}
|
|
22
|
+
if (compact) {
|
|
23
|
+
return (React.createElement("div", { className: `flex items-center gap-2 ${className}` },
|
|
24
|
+
React.createElement("div", { className: "w-2 h-2 rounded-full bg-green-500" }),
|
|
25
|
+
React.createElement("span", { className: theme === 'dark' ? 'text-gray-300' : 'text-gray-700' }, formatAddress(user?.address || ''))));
|
|
26
|
+
}
|
|
27
|
+
return (React.createElement("div", { className: `flex flex-col gap-2 ${className}` },
|
|
28
|
+
React.createElement("div", { className: "flex items-center gap-2" },
|
|
29
|
+
React.createElement("div", { className: "w-2 h-2 rounded-full bg-green-500" }),
|
|
30
|
+
React.createElement("span", { className: `font-semibold ${theme === 'dark' ? 'text-white' : 'text-gray-900'}` }, "Authenticated")),
|
|
31
|
+
showAddress && user?.address && (React.createElement("div", { className: "flex items-center gap-2 text-sm" },
|
|
32
|
+
React.createElement("span", { className: theme === 'dark' ? 'text-gray-500' : 'text-gray-600' }, "Address:"),
|
|
33
|
+
React.createElement("code", { className: `px-2 py-1 rounded ${theme === 'dark' ? 'bg-gray-800 text-gray-300' : 'bg-gray-100 text-gray-700'}` }, formatAddress(user.address)))),
|
|
34
|
+
showChainId && user?.chainId && (React.createElement("div", { className: "flex items-center gap-2 text-sm" },
|
|
35
|
+
React.createElement("span", { className: theme === 'dark' ? 'text-gray-500' : 'text-gray-600' }, "Chain ID:"),
|
|
36
|
+
React.createElement("code", { className: `px-2 py-1 rounded ${theme === 'dark' ? 'bg-gray-800 text-gray-300' : 'bg-gray-100 text-gray-700'}` }, user.chainId)))));
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Format Ethereum address for display
|
|
40
|
+
*/
|
|
41
|
+
function formatAddress(address) {
|
|
42
|
+
if (!address)
|
|
43
|
+
return '';
|
|
44
|
+
return `${address.substring(0, 6)}...${address.substring(address.length - 4)}`;
|
|
45
|
+
}
|
|
46
|
+
export default AuthStatus;
|
|
47
|
+
//# sourceMappingURL=AuthStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthStatus.js","sourceRoot":"","sources":["../../../src/components/SIWE/AuthStatus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAelD,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EACpD,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,MAAM,EACd,WAAW,GAAG,IAAI,EAClB,WAAW,GAAG,IAAI,EAClB,OAAO,GAAG,KAAK,GAChB,EAAE,EAAE;IACH,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;IACvD,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CACL,6BAAK,SAAS,EAAE,2BAA2B,SAAS,EAAE;YACpD,6BAAK,SAAS,EAAC,8DA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YAAY,CAAC,CAAC,CAAC,eAAe,EAAE,oBAE9E,CACH;QACL,WAAW,IAAI,IAAI,EAAE,OAAO,IAAI,CAC/B,6BAAK,SAAS,EAAC,iCAAiC;YAC9C,8BAAM,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,eAE9D;YACP,8BAAM,SAAS,EAAE,qBAAqB,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,2BAA2B,EAAE,IACjH,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CACvB,CACH,CACP;QACA,WAAW,IAAI,IAAI,EAAE,OAAO,IAAI,CAC/B,6BAAK,SAAS,EAAC,iCAAiC;YAC9C,8BAAM,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,gBAE9D;YACP,8BAAM,SAAS,EAAE,qBAAqB,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,2BAA2B,EAAE,IACjH,IAAI,CAAC,OAAO,CACR,CACH,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AACjF,CAAC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Protected Route Component
|
|
4
|
+
* Wrapper for routes that require authentication
|
|
5
|
+
*/
|
|
6
|
+
interface ProtectedRouteProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
fallback?: React.ReactNode;
|
|
9
|
+
redirectTo?: string;
|
|
10
|
+
clientId: string;
|
|
11
|
+
onUnauthorized?: () => void;
|
|
12
|
+
requireAuth?: boolean;
|
|
13
|
+
loadingComponent?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const ProtectedRoute: React.FC<ProtectedRouteProps>;
|
|
16
|
+
export default ProtectedRoute;
|
|
17
|
+
//# sourceMappingURL=ProtectedRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtectedRoute.d.ts","sourceRoot":"","sources":["../../../src/components/SIWE/ProtectedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD;;;GAGG;AAEH,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAuDxD,CAAC;AAiDF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { useSIWE } from './SIWEProvider';
|
|
3
|
+
import { SIWEModal } from './SIWEModal';
|
|
4
|
+
export const ProtectedRoute = ({ children, fallback, redirectTo, clientId, onUnauthorized, requireAuth = true, loadingComponent, }) => {
|
|
5
|
+
const { isAuthenticated, isLoading } = useSIWE();
|
|
6
|
+
const [showAuthModal, setShowAuthModal] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!isLoading && !isAuthenticated && requireAuth) {
|
|
9
|
+
if (redirectTo) {
|
|
10
|
+
window.location.href = redirectTo;
|
|
11
|
+
}
|
|
12
|
+
else if (onUnauthorized) {
|
|
13
|
+
onUnauthorized();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
setShowAuthModal(true);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}, [isAuthenticated, isLoading, requireAuth, redirectTo, onUnauthorized]);
|
|
20
|
+
// Show loading state
|
|
21
|
+
if (isLoading) {
|
|
22
|
+
return loadingComponent ? (React.createElement(React.Fragment, null, loadingComponent)) : (React.createElement(DefaultLoadingScreen, null));
|
|
23
|
+
}
|
|
24
|
+
// Show unauthorized fallback
|
|
25
|
+
if (!isAuthenticated && requireAuth) {
|
|
26
|
+
return (React.createElement(React.Fragment, null,
|
|
27
|
+
fallback || (React.createElement(DefaultUnauthorizedScreen, { onLogin: () => setShowAuthModal(true) })),
|
|
28
|
+
React.createElement(SIWEModal, { isOpen: showAuthModal, onClose: () => setShowAuthModal(false), clientId: clientId, requireAuth: requireAuth, onSuccess: () => setShowAuthModal(false) })));
|
|
29
|
+
}
|
|
30
|
+
// Render protected content
|
|
31
|
+
return React.createElement(React.Fragment, null, children);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Default Loading Screen
|
|
35
|
+
*/
|
|
36
|
+
const DefaultLoadingScreen = () => (React.createElement("div", { className: "min-h-screen flex items-center justify-center bg-gray-900" },
|
|
37
|
+
React.createElement("div", { className: "text-center" },
|
|
38
|
+
React.createElement("div", { className: "inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mb-4" }),
|
|
39
|
+
React.createElement("p", { className: "text-gray-400" }, "Loading..."))));
|
|
40
|
+
/**
|
|
41
|
+
* Default Unauthorized Screen
|
|
42
|
+
*/
|
|
43
|
+
const DefaultUnauthorizedScreen = ({ onLogin }) => (React.createElement("div", { className: "min-h-screen flex items-center justify-center bg-gray-900" },
|
|
44
|
+
React.createElement("div", { className: "text-center max-w-md px-4" },
|
|
45
|
+
React.createElement("div", { className: "mb-8" },
|
|
46
|
+
React.createElement("svg", { className: "w-20 h-20 text-gray-600 mx-auto mb-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
47
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" }))),
|
|
48
|
+
React.createElement("h1", { className: "text-3xl font-bold text-white mb-4" }, "Authentication Required"),
|
|
49
|
+
React.createElement("p", { className: "text-gray-400 mb-8" }, "You need to sign in with your Ethereum wallet to access this page."),
|
|
50
|
+
React.createElement("button", { onClick: onLogin, className: "px-8 py-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg transition-colors" }, "Sign In with Ethereum"))));
|
|
51
|
+
export default ProtectedRoute;
|
|
52
|
+
//# sourceMappingURL=ProtectedRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtectedRoute.js","sourceRoot":"","sources":["../../../src/components/SIWE/ProtectedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAiBxC,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAC5D,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,cAAc,EACd,WAAW,GAAG,IAAI,EAClB,gBAAgB,GACjB,EAAE,EAAE;IACH,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;IACjD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,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xE,6BAAK,SAAS,EAAC,aAAa;QAC1B,6BAAK,SAAS,EAAC,kFAAkF,GAAG;QACpG,2BAAG,SAAS,EAAC,eAAe,iBAAe,CACvC,CACF,CACP,CAAC;AAEF;;GAEG;AACH,MAAM,yBAAyB,GAAsC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CACpF,6BAAK,SAAS,EAAC,2DAA2D;IACxE,6BAAK,SAAS,EAAC,2BAA2B;QACxC,6BAAK,SAAS,EAAC,MAAM;YACnB,6BACE,SAAS,EAAC,sCAAsC,EAChD,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,OAAO,EAAC,WAAW;gBAEnB,8BACE,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,WAAW,EAAE,CAAC,EACd,CAAC,EAAC,sGAAsG,GACxG,CACE,CACF;QACN,4BAAI,SAAS,EAAC,oCAAoC,8BAA6B;QAC/E,2BAAG,SAAS,EAAC,oBAAoB,yEAE7B;QACJ,gCACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,+FAA+F,4BAGlG,CACL,CACF,CACP,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* SIWE Button Component
|
|
4
|
+
* Combines wallet connection with SIWE authentication
|
|
5
|
+
*/
|
|
6
|
+
interface SIWEButtonProps {
|
|
7
|
+
clientId: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
loginText?: string;
|
|
10
|
+
logoutText?: string;
|
|
11
|
+
connectWalletText?: string;
|
|
12
|
+
loadingText?: string;
|
|
13
|
+
onLoginStart?: () => void;
|
|
14
|
+
onLoginComplete?: () => void;
|
|
15
|
+
onLogoutComplete?: () => void;
|
|
16
|
+
theme?: 'light' | 'dark';
|
|
17
|
+
variant?: 'primary' | 'secondary' | 'outline';
|
|
18
|
+
size?: 'sm' | 'md' | 'lg';
|
|
19
|
+
}
|
|
20
|
+
export declare const SIWEButton: React.FC<SIWEButtonProps>;
|
|
21
|
+
export default SIWEButton;
|
|
22
|
+
//# sourceMappingURL=SIWEButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SIWEButton.d.ts","sourceRoot":"","sources":["../../../src/components/SIWE/SIWEButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC;;;GAGG;AAEH,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IAC9C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAuIhD,CAAC;AAmEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { ConnectButton, useActiveAccount } from 'thirdweb/react';
|
|
3
|
+
import { createThirdwebClient } from 'thirdweb';
|
|
4
|
+
import { useSIWE } from './SIWEProvider';
|
|
5
|
+
export const SIWEButton = ({ clientId, className = '', loginText = 'Sign In with Ethereum', logoutText = 'Sign Out', connectWalletText = 'Connect Wallet', loadingText = 'Signing in...', onLoginStart, onLoginComplete, onLogoutComplete, theme = 'dark', variant = 'primary', size = 'md', }) => {
|
|
6
|
+
const { isAuthenticated, isLoading, login, logout, error } = useSIWE();
|
|
7
|
+
const account = useActiveAccount();
|
|
8
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
9
|
+
const client = createThirdwebClient({ clientId });
|
|
10
|
+
// Handle SIWE login
|
|
11
|
+
const handleLogin = async () => {
|
|
12
|
+
setIsProcessing(true);
|
|
13
|
+
onLoginStart?.();
|
|
14
|
+
try {
|
|
15
|
+
await login();
|
|
16
|
+
onLoginComplete?.();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error('SIWE login failed:', error);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
setIsProcessing(false);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
// Handle logout
|
|
26
|
+
const handleLogout = async () => {
|
|
27
|
+
setIsProcessing(true);
|
|
28
|
+
try {
|
|
29
|
+
await logout();
|
|
30
|
+
onLogoutComplete?.();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error('Logout failed:', error);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
setIsProcessing(false);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// Get button styles based on variant and size
|
|
40
|
+
const getButtonStyles = () => {
|
|
41
|
+
const baseStyles = 'font-semibold rounded-lg transition-all duration-200 flex items-center justify-center gap-2';
|
|
42
|
+
const sizeStyles = {
|
|
43
|
+
sm: 'px-4 py-2 text-sm',
|
|
44
|
+
md: 'px-6 py-3 text-base',
|
|
45
|
+
lg: 'px-8 py-4 text-lg',
|
|
46
|
+
};
|
|
47
|
+
const variantStyles = {
|
|
48
|
+
primary: theme === 'dark'
|
|
49
|
+
? 'bg-blue-600 hover:bg-blue-700 text-white'
|
|
50
|
+
: 'bg-blue-500 hover:bg-blue-600 text-white',
|
|
51
|
+
secondary: theme === 'dark'
|
|
52
|
+
? 'bg-gray-700 hover:bg-gray-600 text-white'
|
|
53
|
+
: 'bg-gray-200 hover:bg-gray-300 text-gray-900',
|
|
54
|
+
outline: theme === 'dark'
|
|
55
|
+
? 'border-2 border-blue-600 text-blue-600 hover:bg-blue-600 hover:text-white'
|
|
56
|
+
: 'border-2 border-blue-500 text-blue-500 hover:bg-blue-500 hover:text-white',
|
|
57
|
+
};
|
|
58
|
+
return `${baseStyles} ${sizeStyles[size]} ${variantStyles[variant]} ${className}`;
|
|
59
|
+
};
|
|
60
|
+
// If wallet is not connected, show connect button
|
|
61
|
+
if (!account) {
|
|
62
|
+
return (React.createElement("div", { className: className },
|
|
63
|
+
React.createElement(ConnectButton, { client: client, theme: theme, connectButton: {
|
|
64
|
+
label: connectWalletText,
|
|
65
|
+
} })));
|
|
66
|
+
}
|
|
67
|
+
// If authenticated, show sign out button
|
|
68
|
+
if (isAuthenticated) {
|
|
69
|
+
return (React.createElement("button", { onClick: handleLogout, disabled: isProcessing, className: getButtonStyles() }, isProcessing ? (React.createElement(React.Fragment, null,
|
|
70
|
+
React.createElement(LoadingSpinner, null),
|
|
71
|
+
loadingText)) : (React.createElement(React.Fragment, null,
|
|
72
|
+
React.createElement(CheckIcon, null),
|
|
73
|
+
logoutText))));
|
|
74
|
+
}
|
|
75
|
+
// If wallet connected but not authenticated, show SIWE button
|
|
76
|
+
return (React.createElement("div", { className: "space-y-2" },
|
|
77
|
+
React.createElement("button", { onClick: handleLogin, disabled: isLoading || isProcessing, className: getButtonStyles() }, isLoading || isProcessing ? (React.createElement(React.Fragment, null,
|
|
78
|
+
React.createElement(LoadingSpinner, null),
|
|
79
|
+
loadingText)) : (React.createElement(React.Fragment, null,
|
|
80
|
+
React.createElement(EthereumIcon, null),
|
|
81
|
+
loginText))),
|
|
82
|
+
error && (React.createElement("p", { className: "text-sm text-red-500 mt-2" }, error))));
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Loading Spinner Icon
|
|
86
|
+
*/
|
|
87
|
+
const LoadingSpinner = () => (React.createElement("svg", { className: "animate-spin h-5 w-5", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24" },
|
|
88
|
+
React.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
89
|
+
React.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })));
|
|
90
|
+
/**
|
|
91
|
+
* Ethereum Icon
|
|
92
|
+
*/
|
|
93
|
+
const EthereumIcon = () => (React.createElement("svg", { className: "h-5 w-5", viewBox: "0 0 256 417", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor" },
|
|
94
|
+
React.createElement("path", { d: "M127.961 0l-2.795 9.5v275.668l2.795 2.79 127.962-75.638z", fillOpacity: ".602" }),
|
|
95
|
+
React.createElement("path", { d: "M127.962 0L0 212.32l127.962 75.639V0z" }),
|
|
96
|
+
React.createElement("path", { d: "M127.961 312.187l-1.575 1.92v98.199l1.575 4.6L256 236.587z", fillOpacity: ".602" }),
|
|
97
|
+
React.createElement("path", { d: "M127.962 416.905v-104.72L0 236.585z" }),
|
|
98
|
+
React.createElement("path", { d: "M127.961 287.958l127.96-75.637-127.96-58.162z", fillOpacity: ".2" }),
|
|
99
|
+
React.createElement("path", { d: "M0 212.32l127.96 75.638v-133.8z", fillOpacity: ".602" })));
|
|
100
|
+
/**
|
|
101
|
+
* Check Icon
|
|
102
|
+
*/
|
|
103
|
+
const CheckIcon = () => (React.createElement("svg", { className: "h-5 w-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" },
|
|
104
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" })));
|
|
105
|
+
export default SIWEButton;
|
|
106
|
+
//# sourceMappingURL=SIWEButton.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Y,EACtB,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,iHAAiH,GACnH,CACE,CACP,CAAC;AAEF;;GAEG;AACH,MAAM,YAAY,GAAa,GAAG,EAAE,CAAC,CACnC,6BACE,SAAS,EAAC,SAAS,EACnB,OAAO,EAAC,aAAa,EACrB,KAAK,EAAC,4BAA4B,EAClC,IAAI,EAAC,cAAc;IAEnB,8BAAM,CAAC,EAAC,0DAA0D,EAAC,WAAW,EAAC,MAAM,GAAG;IACxF,8BAAM,CAAC,EAAC,uCAAuC,GAAG;IAClD,8BAAM,CAAC,EAAC,4DAA4D,EAAC,WAAW,EAAC,MAAM,GAAG;IAC1F,8BAAM,CAAC,EAAC,qCAAqC,GAAG;IAChD,8BAAM,CAAC,EAAC,+CAA+C,EAAC,WAAW,EAAC,IAAI,GAAG;IAC3E,8BAAM,CAAC,EAAC,iCAAiC,EAAC,WAAW,EAAC,MAAM,GAAG,CAC3D,CACP,CAAC;AAEF;;GAEG;AACH,MAAM,SAAS,GAAa,GAAG,EAAE,CAAC,CAChC,6BACE,SAAS,EAAC,SAAS,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,4BAA4B;IAElC,8BACE,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,WAAW,EAAE,CAAC,EACd,CAAC,EAAC,gBAAgB,GAClB,CACE,CACP,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* SIWE Modal Component
|
|
4
|
+
* Full-screen authentication modal with SIWE flow
|
|
5
|
+
*/
|
|
6
|
+
interface SIWEModalProps {
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
clientId: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
logoUrl?: string;
|
|
13
|
+
onSuccess?: () => void;
|
|
14
|
+
theme?: 'light' | 'dark';
|
|
15
|
+
requireAuth?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const SIWEModal: React.FC<SIWEModalProps>;
|
|
18
|
+
export default SIWEModal;
|
|
19
|
+
//# sourceMappingURL=SIWEModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SIWEModal.d.ts","sourceRoot":"","sources":["../../../src/components/SIWE/SIWEModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD;;;GAGG;AAEH,UAAU,cAAc;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAmJ9C,CAAC;AA+CF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { useActiveAccount } from 'thirdweb/react';
|
|
3
|
+
import { useSIWE } from './SIWEProvider';
|
|
4
|
+
import { SIWEButton } from './SIWEButton';
|
|
5
|
+
export const SIWEModal = ({ isOpen, onClose, clientId, title = 'Sign In to Varity', description = 'Connect your wallet and sign the message to authenticate', logoUrl, onSuccess, theme = 'dark', requireAuth = false, }) => {
|
|
6
|
+
const { isAuthenticated } = useSIWE();
|
|
7
|
+
const account = useActiveAccount();
|
|
8
|
+
const [showSuccess, setShowSuccess] = useState(false);
|
|
9
|
+
// Close modal when authenticated
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (isAuthenticated && isOpen) {
|
|
12
|
+
setShowSuccess(true);
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
onSuccess?.();
|
|
15
|
+
onClose();
|
|
16
|
+
setShowSuccess(false);
|
|
17
|
+
}, 2000);
|
|
18
|
+
}
|
|
19
|
+
}, [isAuthenticated, isOpen, onSuccess, onClose]);
|
|
20
|
+
// Don't render if not open
|
|
21
|
+
if (!isOpen)
|
|
22
|
+
return null;
|
|
23
|
+
const bgColor = theme === 'dark' ? 'bg-gray-900' : 'bg-white';
|
|
24
|
+
const textColor = theme === 'dark' ? 'text-white' : 'text-gray-900';
|
|
25
|
+
const borderColor = theme === 'dark' ? 'border-gray-700' : 'border-gray-200';
|
|
26
|
+
return (React.createElement("div", { className: "fixed inset-0 z-50 flex items-center justify-center" },
|
|
27
|
+
React.createElement("div", { className: "absolute inset-0 bg-black bg-opacity-50", onClick: !requireAuth ? onClose : undefined }),
|
|
28
|
+
React.createElement("div", { className: `relative w-full max-w-md mx-4 rounded-2xl shadow-2xl ${bgColor} ${textColor} border ${borderColor}` },
|
|
29
|
+
!requireAuth && (React.createElement("button", { onClick: onClose, className: "absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors" },
|
|
30
|
+
React.createElement("svg", { className: "w-6 h-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
31
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })))),
|
|
32
|
+
React.createElement("div", { className: "p-8" },
|
|
33
|
+
logoUrl && (React.createElement("div", { className: "flex justify-center mb-6" },
|
|
34
|
+
React.createElement("img", { src: logoUrl, alt: "Logo", className: "h-16 w-auto" }))),
|
|
35
|
+
React.createElement("h2", { className: "text-2xl font-bold text-center mb-2" }, title),
|
|
36
|
+
React.createElement("p", { className: `text-center mb-8 ${theme === 'dark' ? 'text-gray-400' : 'text-gray-600'}` }, description),
|
|
37
|
+
showSuccess ? (React.createElement("div", { className: "text-center py-8" },
|
|
38
|
+
React.createElement("div", { className: "inline-flex items-center justify-center w-16 h-16 rounded-full bg-green-500 text-white mb-4" },
|
|
39
|
+
React.createElement("svg", { className: "w-8 h-8", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
40
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }))),
|
|
41
|
+
React.createElement("p", { className: "text-xl font-semibold text-green-500" }, "Successfully Authenticated!"))) : (React.createElement(React.Fragment, null,
|
|
42
|
+
React.createElement("div", { className: "space-y-4 mb-8" },
|
|
43
|
+
React.createElement(Step, { number: 1, title: "Connect Wallet", description: "Connect your Ethereum wallet", isComplete: !!account, theme: theme }),
|
|
44
|
+
React.createElement(Step, { number: 2, title: "Sign Message", description: "Sign the authentication message", isComplete: isAuthenticated, isActive: !!account && !isAuthenticated, theme: theme }),
|
|
45
|
+
React.createElement(Step, { number: 3, title: "Access Dashboard", description: "Start using the platform", isComplete: isAuthenticated, theme: theme })),
|
|
46
|
+
React.createElement("div", { className: "flex justify-center" },
|
|
47
|
+
React.createElement(SIWEButton, { clientId: clientId, theme: theme, variant: "primary", size: "lg", className: "w-full", onLoginComplete: () => {
|
|
48
|
+
setShowSuccess(true);
|
|
49
|
+
} })))),
|
|
50
|
+
React.createElement("div", { className: `mt-6 p-4 rounded-lg ${theme === 'dark' ? 'bg-gray-800' : 'bg-gray-100'}` },
|
|
51
|
+
React.createElement("div", { className: "flex items-start gap-3" },
|
|
52
|
+
React.createElement("svg", { className: "w-5 h-5 text-blue-500 mt-0.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
53
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" })),
|
|
54
|
+
React.createElement("div", null,
|
|
55
|
+
React.createElement("p", { className: `text-sm font-semibold mb-1 ${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'}` }, "Secure Authentication"),
|
|
56
|
+
React.createElement("p", { className: `text-xs ${theme === 'dark' ? 'text-gray-500' : 'text-gray-600'}` }, "Your wallet signature is used to verify ownership. We never have access to your private keys."))))))));
|
|
57
|
+
};
|
|
58
|
+
const Step = ({ number, title, description, isComplete, isActive, theme }) => {
|
|
59
|
+
const bgColor = isComplete
|
|
60
|
+
? 'bg-green-500'
|
|
61
|
+
: isActive
|
|
62
|
+
? 'bg-blue-500'
|
|
63
|
+
: theme === 'dark'
|
|
64
|
+
? 'bg-gray-700'
|
|
65
|
+
: 'bg-gray-300';
|
|
66
|
+
const textColor = theme === 'dark' ? 'text-gray-400' : 'text-gray-600';
|
|
67
|
+
return (React.createElement("div", { className: "flex items-center gap-4" },
|
|
68
|
+
React.createElement("div", { className: `flex-shrink-0 w-10 h-10 rounded-full ${bgColor} flex items-center justify-center text-white font-bold` }, isComplete ? (React.createElement("svg", { className: "w-6 h-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
69
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }))) : (number)),
|
|
70
|
+
React.createElement("div", { className: "flex-1" },
|
|
71
|
+
React.createElement("p", { className: `font-semibold ${isComplete || isActive ? 'text-current' : textColor}` }, title),
|
|
72
|
+
React.createElement("p", { className: `text-sm ${textColor}` }, description))));
|
|
73
|
+
};
|
|
74
|
+
export default SIWEModal;
|
|
75
|
+
//# sourceMappingURL=SIWEModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SIWEModal.js","sourceRoot":"","sources":["../../../src/components/SIWE/SIWEModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SA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GN,6BAAK,SAAS,EAAC,QAAQ;YACrB,2BAAG,SAAS,EAAE,iBAAiB,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EAAE,IAAG,KAAK,CAAK;YACjG,2BAAG,SAAS,EAAE,WAAW,SAAS,EAAE,IAAG,WAAW,CAAK,CACnD,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface AuthUser {
|
|
3
|
+
address: string;
|
|
4
|
+
chainId: number;
|
|
5
|
+
ens?: string;
|
|
6
|
+
}
|
|
7
|
+
interface AuthState {
|
|
8
|
+
isAuthenticated: boolean;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
user: AuthUser | null;
|
|
11
|
+
accessToken: string | null;
|
|
12
|
+
refreshToken: string | null;
|
|
13
|
+
error: string | null;
|
|
14
|
+
}
|
|
15
|
+
interface AuthContextValue extends AuthState {
|
|
16
|
+
login: () => Promise<void>;
|
|
17
|
+
logout: () => Promise<void>;
|
|
18
|
+
refreshAccessToken: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
interface SIWEProviderProps {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
apiUrl: string;
|
|
23
|
+
chainId?: number;
|
|
24
|
+
onLoginSuccess?: (user: AuthUser) => void;
|
|
25
|
+
onLoginError?: (error: Error) => void;
|
|
26
|
+
onLogoutSuccess?: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* SIWE Provider Component
|
|
30
|
+
* Manages authentication state and provides login/logout functionality
|
|
31
|
+
*/
|
|
32
|
+
export declare const SIWEProvider: React.FC<SIWEProviderProps>;
|
|
33
|
+
/**
|
|
34
|
+
* Custom hook to use SIWE authentication context
|
|
35
|
+
*/
|
|
36
|
+
export declare const useSIWE: () => AuthContextValue;
|
|
37
|
+
export default SIWEProvider;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