@openfort/react 0.3.2 → 1.0.1
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/build/assets/browsers.js +13 -0
- package/build/assets/browsers.js.map +1 -0
- package/build/assets/chains.js +139 -0
- package/build/assets/chains.js.map +1 -0
- package/build/assets/icons.js +41 -0
- package/build/assets/icons.js.map +1 -0
- package/build/assets/logos.js +173 -0
- package/build/assets/logos.js.map +1 -0
- package/build/assets/wave.js +6 -0
- package/build/assets/wave.js.map +1 -0
- package/build/components/BalanceButton/index.js +89 -0
- package/build/components/BalanceButton/index.js.map +1 -0
- package/build/components/Common/Alert/index.js +10 -0
- package/build/components/Common/Alert/index.js.map +1 -0
- package/build/components/Common/Alert/styles.js +55 -0
- package/build/components/Common/Alert/styles.js.map +1 -0
- package/build/components/Common/Avatar/index.d.ts +11 -3
- package/build/components/Common/Avatar/index.js +100 -0
- package/build/components/Common/Avatar/index.js.map +1 -0
- package/build/components/Common/Avatar/styles.js +59 -0
- package/build/components/Common/Avatar/styles.js.map +1 -0
- package/build/components/Common/BrowserIcon/index.js +28 -0
- package/build/components/Common/BrowserIcon/index.js.map +1 -0
- package/build/components/Common/BrowserIcon/styles.js +20 -0
- package/build/components/Common/BrowserIcon/styles.js.map +1 -0
- package/build/components/Common/Button/index.js +36 -0
- package/build/components/Common/Button/index.js.map +1 -0
- package/build/components/Common/Button/styles.js +302 -0
- package/build/components/Common/Button/styles.js.map +1 -0
- package/build/components/Common/Button/types.d.ts +1 -0
- package/build/components/Common/Chain/index.d.ts +8 -0
- package/build/components/Common/Chain/index.js +38 -0
- package/build/components/Common/Chain/index.js.map +1 -0
- package/build/components/Common/Chain/styles.js +94 -0
- package/build/components/Common/Chain/styles.js.map +1 -0
- package/build/components/Common/ConnectorList/index.js +58 -0
- package/build/components/Common/ConnectorList/index.js.map +1 -0
- package/build/components/Common/ConnectorList/styles.js +324 -0
- package/build/components/Common/ConnectorList/styles.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyButton.js +12 -0
- package/build/components/Common/CopyToClipboard/CopyButton.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyIcon.js +76 -0
- package/build/components/Common/CopyToClipboard/CopyIcon.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyIconButton.js +38 -0
- package/build/components/Common/CopyToClipboard/CopyIconButton.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyText.js +26 -0
- package/build/components/Common/CopyToClipboard/CopyText.js.map +1 -0
- package/build/components/Common/CustomQRCode/QRCode.js +60 -0
- package/build/components/Common/CustomQRCode/QRCode.js.map +1 -0
- package/build/components/Common/CustomQRCode/index.js +22 -0
- package/build/components/Common/CustomQRCode/index.js.map +1 -0
- package/build/components/Common/CustomQRCode/styles.js +155 -0
- package/build/components/Common/CustomQRCode/styles.js.map +1 -0
- package/build/components/Common/FitText/index.js +28 -0
- package/build/components/Common/FitText/index.js.map +1 -0
- package/build/components/Common/Input/index.js +17 -0
- package/build/components/Common/Input/index.js.map +1 -0
- package/build/components/Common/Input/styles.js +53 -0
- package/build/components/Common/Input/styles.js.map +1 -0
- package/build/components/Common/LargeButton/index.js +10 -0
- package/build/components/Common/LargeButton/index.js.map +1 -0
- package/build/components/Common/LargeButton/styles.js +69 -0
- package/build/components/Common/LargeButton/styles.js.map +1 -0
- package/build/components/Common/Loading/index.js +96 -0
- package/build/components/Common/Loading/index.js.map +1 -0
- package/build/components/Common/Modal/index.js +272 -0
- package/build/components/Common/Modal/index.js.map +1 -0
- package/build/components/Common/Modal/styles.d.ts +0 -1
- package/build/components/Common/Modal/styles.js +657 -0
- package/build/components/Common/Modal/styles.js.map +1 -0
- package/build/components/Common/OTPInput/index.js +108 -0
- package/build/components/Common/OTPInput/index.js.map +1 -0
- package/build/components/Common/OTPInput/styles.js +153 -0
- package/build/components/Common/OTPInput/styles.js.map +1 -0
- package/build/components/Common/Portal/index.js +31 -0
- package/build/components/Common/Portal/index.js.map +1 -0
- package/build/components/Common/PoweredByFooter/index.js +103 -0
- package/build/components/Common/PoweredByFooter/index.js.map +1 -0
- package/build/components/Common/Providers/ProviderHeader.d.ts +2 -2
- package/build/components/Common/Providers/ProviderHeader.js +55 -0
- package/build/components/Common/Providers/ProviderHeader.js.map +1 -0
- package/build/components/Common/Providers/ProviderIcon.d.ts +2 -2
- package/build/components/Common/Providers/ProviderIcon.js +41 -0
- package/build/components/Common/Providers/ProviderIcon.js.map +1 -0
- package/build/components/Common/Providers/getProviderName.d.ts +1 -1
- package/build/components/Common/Providers/getProviderName.js +15 -0
- package/build/components/Common/Providers/getProviderName.js.map +1 -0
- package/build/components/Common/ScrollArea/index.js +58 -0
- package/build/components/Common/ScrollArea/index.js.map +1 -0
- package/build/components/Common/ScrollArea/styles.js +168 -0
- package/build/components/Common/ScrollArea/styles.js.map +1 -0
- package/build/components/Common/Spinner/index.js +24 -0
- package/build/components/Common/Spinner/index.js.map +1 -0
- package/build/components/Common/Spinner/styles.js +22 -0
- package/build/components/Common/Spinner/styles.js.map +1 -0
- package/build/components/Common/SquircleSpinner/index.js +15 -0
- package/build/components/Common/SquircleSpinner/index.js.map +1 -0
- package/build/components/Common/SquircleSpinner/styles.js +66 -0
- package/build/components/Common/SquircleSpinner/styles.js.map +1 -0
- package/build/components/Common/ThemedButton/index.js +25 -0
- package/build/components/Common/ThemedButton/index.js.map +1 -0
- package/build/components/Common/ThemedButton/styles.js +152 -0
- package/build/components/Common/ThemedButton/styles.js.map +1 -0
- package/build/components/Common/TickList/index.js +11 -0
- package/build/components/Common/TickList/index.js.map +1 -0
- package/build/components/Common/TickList/styles.js +28 -0
- package/build/components/Common/TickList/styles.js.map +1 -0
- package/build/components/Common/Tooltip/index.js +91 -0
- package/build/components/Common/Tooltip/index.js.map +1 -0
- package/build/components/Common/Tooltip/styles.js +81 -0
- package/build/components/Common/Tooltip/styles.js.map +1 -0
- package/build/components/Common/WalletRecoveryIcon/index.d.ts +4 -0
- package/build/components/Common/WalletRecoveryIcon/index.js +19 -0
- package/build/components/Common/WalletRecoveryIcon/index.js.map +1 -0
- package/build/components/ConnectButton/index.d.ts +12 -4
- package/build/components/ConnectButton/index.js +266 -0
- package/build/components/ConnectButton/index.js.map +1 -0
- package/build/components/ConnectButton/styles.js +50 -0
- package/build/components/ConnectButton/styles.js.map +1 -0
- package/build/components/ConnectKitThemeProvider/ConnectKitThemeProvider.js +20 -0
- package/build/components/ConnectKitThemeProvider/ConnectKitThemeProvider.js.map +1 -0
- package/build/components/ConnectModal/ConnectUsing.d.ts +1 -1
- package/build/components/ConnectModal/ConnectUsing.js +68 -0
- package/build/components/ConnectModal/ConnectUsing.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/index.js +17 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/index.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/styles.js +118 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/styles.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/index.d.ts +0 -2
- package/build/components/ConnectModal/ConnectWithInjector/index.js +295 -0
- package/build/components/ConnectModal/ConnectWithInjector/index.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/styles.js +133 -0
- package/build/components/ConnectModal/ConnectWithInjector/styles.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithMobile.js +99 -0
- package/build/components/ConnectModal/ConnectWithMobile.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithOAuth.js +128 -0
- package/build/components/ConnectModal/ConnectWithOAuth.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithQRCode.js +78 -0
- package/build/components/ConnectModal/ConnectWithQRCode.js.map +1 -0
- package/build/components/ConnectModal/index.js +227 -0
- package/build/components/ConnectModal/index.js.map +1 -0
- package/build/components/FloatingGraphic/index.js +13 -0
- package/build/components/FloatingGraphic/index.js.map +1 -0
- package/build/components/FloatingGraphic/styles.js +175 -0
- package/build/components/FloatingGraphic/styles.js.map +1 -0
- package/build/components/Openfort/OpenfortProvider.d.ts +10 -25
- package/build/components/Openfort/OpenfortProvider.js +351 -0
- package/build/components/Openfort/OpenfortProvider.js.map +1 -0
- package/build/components/Openfort/context.d.ts +48 -5
- package/build/components/Openfort/context.js +7 -0
- package/build/components/Openfort/context.js.map +1 -0
- package/build/components/Openfort/routeHelpers.d.ts +5 -0
- package/build/components/Openfort/routeHelpers.js +20 -0
- package/build/components/Openfort/routeHelpers.js.map +1 -0
- package/build/components/Openfort/types.d.ts +57 -23
- package/build/components/Openfort/types.js +119 -0
- package/build/components/Openfort/types.js.map +1 -0
- package/build/components/Openfort/useOpenfort.d.ts +2 -0
- package/build/components/Openfort/useOpenfort.js +12 -0
- package/build/components/Openfort/useOpenfort.js.map +1 -0
- package/build/components/PageContent/index.js +55 -0
- package/build/components/PageContent/index.js.map +1 -0
- package/build/components/PageContent/styles.js +11 -0
- package/build/components/PageContent/styles.js.map +1 -0
- package/build/components/Pages/About/graphics.js +193 -0
- package/build/components/Pages/About/graphics.js.map +1 -0
- package/build/components/Pages/About/index.js +142 -0
- package/build/components/Pages/About/index.js.map +1 -0
- package/build/components/Pages/About/styles.js +142 -0
- package/build/components/Pages/About/styles.js.map +1 -0
- package/build/components/Pages/AssetInventory/index.js +66 -0
- package/build/components/Pages/AssetInventory/index.js.map +1 -0
- package/build/components/Pages/Buy/coinbaseApi.js +106 -0
- package/build/components/Pages/Buy/coinbaseApi.js.map +1 -0
- package/build/components/Pages/Buy/index.js +88 -0
- package/build/components/Pages/Buy/index.js.map +1 -0
- package/build/components/Pages/Buy/onrampApi.js +57 -0
- package/build/components/Pages/Buy/onrampApi.js.map +1 -0
- package/build/components/Pages/Buy/providers.js +39 -0
- package/build/components/Pages/Buy/providers.js.map +1 -0
- package/build/components/Pages/Buy/stripeApi.js +74 -0
- package/build/components/Pages/Buy/stripeApi.js.map +1 -0
- package/build/components/Pages/Buy/styles.js +230 -0
- package/build/components/Pages/Buy/styles.js.map +1 -0
- package/build/components/Pages/Buy/utils.js +71 -0
- package/build/components/Pages/Buy/utils.js.map +1 -0
- package/build/components/Pages/BuyComplete/index.js +47 -0
- package/build/components/Pages/BuyComplete/index.js.map +1 -0
- package/build/components/Pages/BuyProcessing/index.js +231 -0
- package/build/components/Pages/BuyProcessing/index.js.map +1 -0
- package/build/components/Pages/BuyProviderSelect/index.js +55 -0
- package/build/components/Pages/BuyProviderSelect/index.js.map +1 -0
- package/build/components/Pages/BuyProviderSelect/styles.js +103 -0
- package/build/components/Pages/BuyProviderSelect/styles.js.map +1 -0
- package/build/components/Pages/BuySelectProvider/index.js +245 -0
- package/build/components/Pages/BuySelectProvider/index.js.map +1 -0
- package/build/components/Pages/Connected/ConnectedPageLayout.d.ts +22 -0
- package/build/components/Pages/Connected/ConnectedPageLayout.js +11 -0
- package/build/components/Pages/Connected/ConnectedPageLayout.js.map +1 -0
- package/build/components/Pages/Connected/EthereumConnected.d.ts +3 -0
- package/build/components/Pages/Connected/EthereumConnected.js +133 -0
- package/build/components/Pages/Connected/EthereumConnected.js.map +1 -0
- package/build/components/Pages/Connected/SolanaConnected.d.ts +3 -0
- package/build/components/Pages/Connected/SolanaConnected.js +96 -0
- package/build/components/Pages/Connected/SolanaConnected.js.map +1 -0
- package/build/components/Pages/Connected/index.d.ts +2 -2
- package/build/components/Pages/Connected/index.js +18 -0
- package/build/components/Pages/Connected/index.js.map +1 -0
- package/build/components/Pages/Connected/styles.js +122 -0
- package/build/components/Pages/Connected/styles.js.map +1 -0
- package/build/components/Pages/ConnectedSuccess/index.js +19 -0
- package/build/components/Pages/ConnectedSuccess/index.js.map +1 -0
- package/build/components/Pages/Connectors/index.js +73 -0
- package/build/components/Pages/Connectors/index.js.map +1 -0
- package/build/components/Pages/CreateGuestUserPage/index.js +28 -0
- package/build/components/Pages/CreateGuestUserPage/index.js.map +1 -0
- package/build/components/Pages/CreateWallet/SolanaCreateWallet.d.ts +6 -0
- package/build/components/Pages/CreateWallet/SolanaCreateWallet.js +241 -0
- package/build/components/Pages/CreateWallet/SolanaCreateWallet.js.map +1 -0
- package/build/components/Pages/CreateWallet/index.js +303 -0
- package/build/components/Pages/CreateWallet/index.js.map +1 -0
- package/build/components/Pages/CreateWallet/styles.js +17 -0
- package/build/components/Pages/CreateWallet/styles.js.map +1 -0
- package/build/components/Pages/DownloadApp/index.js +32 -0
- package/build/components/Pages/DownloadApp/index.js.map +1 -0
- package/build/components/Pages/EmailLogin/index.js +118 -0
- package/build/components/Pages/EmailLogin/index.js.map +1 -0
- package/build/components/Pages/EmailLogin/styles.js +24 -0
- package/build/components/Pages/EmailLogin/styles.js.map +1 -0
- package/build/components/Pages/EmailOTP/index.js +116 -0
- package/build/components/Pages/EmailOTP/index.js.map +1 -0
- package/build/components/Pages/EmailOTP/styles.js +38 -0
- package/build/components/Pages/EmailOTP/styles.js.map +1 -0
- package/build/components/Pages/EmailVerification/index.js +86 -0
- package/build/components/Pages/EmailVerification/index.js.map +1 -0
- package/build/components/Pages/ExportKey/index.js +44 -0
- package/build/components/Pages/ExportKey/index.js.map +1 -0
- package/build/components/Pages/ForgotPassword/index.js +129 -0
- package/build/components/Pages/ForgotPassword/index.js.map +1 -0
- package/build/components/Pages/LinkEmail/index.js +63 -0
- package/build/components/Pages/LinkEmail/index.js.map +1 -0
- package/build/components/Pages/LinkedProvider/index.d.ts +3 -0
- package/build/components/Pages/LinkedProvider/index.js +90 -0
- package/build/components/Pages/LinkedProvider/index.js.map +1 -0
- package/build/components/Pages/LinkedProviders/index.js +45 -0
- package/build/components/Pages/LinkedProviders/index.js.map +1 -0
- package/build/components/Pages/LinkedProviders/styles.js +51 -0
- package/build/components/Pages/LinkedProviders/styles.js.map +1 -0
- package/build/components/Pages/LoadWallets/index.js +91 -0
- package/build/components/Pages/LoadWallets/index.js.map +1 -0
- package/build/components/Pages/Loading/index.js +61 -0
- package/build/components/Pages/Loading/index.js.map +1 -0
- package/build/components/Pages/MobileConnectors/index.js +71 -0
- package/build/components/Pages/MobileConnectors/index.js.map +1 -0
- package/build/components/Pages/MobileConnectors/styles.js +65 -0
- package/build/components/Pages/MobileConnectors/styles.js.map +1 -0
- package/build/components/Pages/NoAssetsAvailable/index.js +45 -0
- package/build/components/Pages/NoAssetsAvailable/index.js.map +1 -0
- package/build/components/Pages/NoAssetsAvailable/styles.js +10 -0
- package/build/components/Pages/NoAssetsAvailable/styles.js.map +1 -0
- package/build/components/Pages/Onboarding/index.js +20 -0
- package/build/components/Pages/Onboarding/index.js.map +1 -0
- package/build/components/Pages/PhoneOTP/index.js +128 -0
- package/build/components/Pages/PhoneOTP/index.js.map +1 -0
- package/build/components/Pages/PhoneOTP/styles.js +38 -0
- package/build/components/Pages/PhoneOTP/styles.js.map +1 -0
- package/build/components/Pages/Profile/index.js +35 -0
- package/build/components/Pages/Profile/index.js.map +1 -0
- package/build/components/Pages/Providers/index.js +157 -0
- package/build/components/Pages/Providers/index.js.map +1 -0
- package/build/components/Pages/Providers/styles.js +156 -0
- package/build/components/Pages/Providers/styles.js.map +1 -0
- package/build/components/Pages/Receive/index.js +61 -0
- package/build/components/Pages/Receive/index.js.map +1 -0
- package/build/components/Pages/Receive/styles.d.ts +1 -0
- package/build/components/Pages/Receive/styles.js +52 -0
- package/build/components/Pages/Receive/styles.js.map +1 -0
- package/build/components/Pages/Recover/index.js +252 -0
- package/build/components/Pages/Recover/index.js.map +1 -0
- package/build/components/Pages/Recover/recoveryRegistry.d.ts +32 -0
- package/build/components/Pages/Recover/recoveryRegistry.js +61 -0
- package/build/components/Pages/Recover/recoveryRegistry.js.map +1 -0
- package/build/components/Pages/RemoveLinkedProvider/index.js +104 -0
- package/build/components/Pages/RemoveLinkedProvider/index.js.map +1 -0
- package/build/components/Pages/SelectToken/index.js +102 -0
- package/build/components/Pages/SelectToken/index.js.map +1 -0
- package/build/components/Pages/SelectToken/styles.js +78 -0
- package/build/components/Pages/SelectToken/styles.js.map +1 -0
- package/build/components/Pages/SelectWalletToRecover/index.d.ts +1 -2
- package/build/components/Pages/SelectWalletToRecover/index.js +70 -0
- package/build/components/Pages/SelectWalletToRecover/index.js.map +1 -0
- package/build/components/Pages/Send/EthereumSend.d.ts +1 -0
- package/build/components/Pages/Send/EthereumSend.js +88 -0
- package/build/components/Pages/Send/EthereumSend.js.map +1 -0
- package/build/components/Pages/Send/index.d.ts +7 -1
- package/build/components/Pages/Send/index.js +17 -0
- package/build/components/Pages/Send/index.js.map +1 -0
- package/build/components/Pages/Send/styles.js +112 -0
- package/build/components/Pages/Send/styles.js.map +1 -0
- package/build/components/Pages/Send/utils.d.ts +1 -1
- package/build/components/Pages/Send/utils.js +63 -0
- package/build/components/Pages/Send/utils.js.map +1 -0
- package/build/components/Pages/SendConfirmation/EstimatedFees.js +66 -0
- package/build/components/Pages/SendConfirmation/EstimatedFees.js.map +1 -0
- package/build/components/Pages/SendConfirmation/index.js +331 -0
- package/build/components/Pages/SendConfirmation/index.js.map +1 -0
- package/build/components/Pages/SendConfirmation/styles.js +129 -0
- package/build/components/Pages/SendConfirmation/styles.js.map +1 -0
- package/build/components/Pages/SocialProviders/index.js +15 -0
- package/build/components/Pages/SocialProviders/index.js.map +1 -0
- package/build/components/PasswordStrength/PasswordStrengthIndicator.js +62 -0
- package/build/components/PasswordStrength/PasswordStrengthIndicator.js.map +1 -0
- package/build/components/PasswordStrength/password-utility.js +128 -0
- package/build/components/PasswordStrength/password-utility.js.map +1 -0
- package/build/constants/chainConfigs.js +316 -0
- package/build/constants/chainConfigs.js.map +1 -0
- package/build/constants/defaultTheme.js +6 -0
- package/build/constants/defaultTheme.js.map +1 -0
- package/build/constants/openfort.d.ts +4 -0
- package/build/constants/openfort.js +8 -0
- package/build/constants/openfort.js.map +1 -0
- package/build/core/ConnectionStrategy.d.ts +31 -0
- package/build/core/ConnectionStrategy.js +9 -0
- package/build/core/ConnectionStrategy.js.map +1 -0
- package/build/core/ConnectionStrategyContext.d.ts +16 -0
- package/build/core/ConnectionStrategyContext.js +22 -0
- package/build/core/ConnectionStrategyContext.js.map +1 -0
- package/build/core/errors.d.ts +1 -0
- package/build/core/strategies/EthereumBridgeStrategy.d.ts +11 -0
- package/build/core/strategies/EthereumBridgeStrategy.js +83 -0
- package/build/core/strategies/EthereumBridgeStrategy.js.map +1 -0
- package/build/core/strategies/EthereumEmbeddedStrategy.d.ts +8 -0
- package/build/core/strategies/EthereumEmbeddedStrategy.js +85 -0
- package/build/core/strategies/EthereumEmbeddedStrategy.js.map +1 -0
- package/build/core/strategies/SolanaEmbeddedStrategy.d.ts +9 -0
- package/build/core/strategies/SolanaEmbeddedStrategy.js +53 -0
- package/build/core/strategies/SolanaEmbeddedStrategy.js.map +1 -0
- package/build/core/strategyUtils.d.ts +6 -0
- package/build/core/strategyUtils.js +31 -0
- package/build/core/strategyUtils.js.map +1 -0
- package/build/ethereum/OpenfortEthereumBridgeContext.d.ts +87 -0
- package/build/ethereum/OpenfortEthereumBridgeContext.js +18 -0
- package/build/ethereum/OpenfortEthereumBridgeContext.js.map +1 -0
- package/build/ethereum/hooks/getEmbeddedWalletClient.d.ts +14 -0
- package/build/ethereum/hooks/getEmbeddedWalletClient.js +24 -0
- package/build/ethereum/hooks/getEmbeddedWalletClient.js.map +1 -0
- package/build/ethereum/hooks/useEthereumEmbeddedWallet.d.ts +17 -0
- package/build/ethereum/hooks/useEthereumEmbeddedWallet.js +425 -0
- package/build/ethereum/hooks/useEthereumEmbeddedWallet.js.map +1 -0
- package/build/ethereum/hooks/useEthereumWalletAssets.d.ts +29 -0
- package/build/ethereum/hooks/useEthereumWalletAssets.js +204 -0
- package/build/ethereum/hooks/useEthereumWalletAssets.js.map +1 -0
- package/build/ethereum/index.d.ts +11 -0
- package/build/ethereum/index.js +3 -0
- package/build/ethereum/index.js.map +1 -0
- package/build/ethereum/types.d.ts +140 -0
- package/build/hooks/openfort/auth/requestEmailVerification.js +21 -0
- package/build/hooks/openfort/auth/requestEmailVerification.js.map +1 -0
- package/build/hooks/openfort/auth/status.js +11 -0
- package/build/hooks/openfort/auth/status.js.map +1 -0
- package/build/hooks/openfort/auth/useAuthCallback.d.ts +2 -1
- package/build/hooks/openfort/auth/useAuthCallback.js +197 -0
- package/build/hooks/openfort/auth/useAuthCallback.js.map +1 -0
- package/build/hooks/openfort/auth/useConnectToWalletPostAuth.d.ts +2 -2
- package/build/hooks/openfort/auth/useConnectToWalletPostAuth.js +161 -0
- package/build/hooks/openfort/auth/useConnectToWalletPostAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useEmailAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useEmailAuth.js +496 -0
- package/build/hooks/openfort/auth/useEmailAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useEmailOtpAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useEmailOtpAuth.js +151 -0
- package/build/hooks/openfort/auth/useEmailOtpAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useGuestAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useGuestAuth.js +142 -0
- package/build/hooks/openfort/auth/useGuestAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useOAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useOAuth.js +217 -0
- package/build/hooks/openfort/auth/useOAuth.js.map +1 -0
- package/build/hooks/openfort/auth/usePhoneOtpAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/usePhoneOtpAuth.js +174 -0
- package/build/hooks/openfort/auth/usePhoneOtpAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useSignOut.d.ts +2 -1
- package/build/hooks/openfort/auth/useSignOut.js +104 -0
- package/build/hooks/openfort/auth/useSignOut.js.map +1 -0
- package/build/hooks/openfort/hookConsistency.js +17 -0
- package/build/hooks/openfort/hookConsistency.js.map +1 -0
- package/build/hooks/openfort/use7702Authorization.js +73 -0
- package/build/hooks/openfort/use7702Authorization.js.map +1 -0
- package/build/hooks/openfort/useGrantPermissions.d.ts +7 -76
- package/build/hooks/openfort/useGrantPermissions.js +221 -0
- package/build/hooks/openfort/useGrantPermissions.js.map +1 -0
- package/build/hooks/openfort/useProviders.js +75 -0
- package/build/hooks/openfort/useProviders.js.map +1 -0
- package/build/hooks/openfort/useRevokePermissions.d.ts +2 -1
- package/build/hooks/openfort/useRevokePermissions.js +126 -0
- package/build/hooks/openfort/useRevokePermissions.js.map +1 -0
- package/build/hooks/openfort/useUI.d.ts +4 -45
- package/build/hooks/openfort/useUI.js +122 -0
- package/build/hooks/openfort/useUI.js.map +1 -0
- package/build/hooks/openfort/useUser.d.ts +12 -35
- package/build/hooks/openfort/useUser.js +61 -0
- package/build/hooks/openfort/useUser.js.map +1 -0
- package/build/hooks/openfort/walletTypes.d.ts +32 -0
- package/build/hooks/openfort/walletTypes.js +53 -0
- package/build/hooks/openfort/walletTypes.js.map +1 -0
- package/build/hooks/useBalance.d.ts +50 -0
- package/build/hooks/useBalance.js +80 -0
- package/build/hooks/useBalance.js.map +1 -0
- package/build/hooks/useConnectLifecycle.d.ts +7 -0
- package/build/hooks/useConnectLifecycle.js +43 -0
- package/build/hooks/useConnectLifecycle.js.map +1 -0
- package/build/hooks/useConnectors.d.ts +3 -5
- package/build/hooks/useConnectors.js +26 -0
- package/build/hooks/useConnectors.js.map +1 -0
- package/build/hooks/useCopyToClipboard.js +29 -0
- package/build/hooks/useCopyToClipboard.js.map +1 -0
- package/build/hooks/useFitText.js +125 -0
- package/build/hooks/useFitText.js.map +1 -0
- package/build/hooks/useFocusTrap.d.ts +4 -1
- package/build/hooks/useFocusTrap.js +60 -0
- package/build/hooks/useFocusTrap.js.map +1 -0
- package/build/hooks/useGoogleFont.js +43 -0
- package/build/hooks/useGoogleFont.js.map +1 -0
- package/build/hooks/useIsMobile.js +17 -0
- package/build/hooks/useIsMobile.js.map +1 -0
- package/build/hooks/useIsMounted.js +10 -0
- package/build/hooks/useIsMounted.js.map +1 -0
- package/build/hooks/useLastConnector.js +39 -0
- package/build/hooks/useLastConnector.js.map +1 -0
- package/build/hooks/useLocales.d.ts +1 -1
- package/build/hooks/useLocales.js +68 -0
- package/build/hooks/useLocales.js.map +1 -0
- package/build/hooks/useLockBodyScroll.js +53 -0
- package/build/hooks/useLockBodyScroll.js.map +1 -0
- package/build/hooks/usePrevious.js +14 -0
- package/build/hooks/usePrevious.js.map +1 -0
- package/build/hooks/useResolvedIdentity.d.ts +70 -0
- package/build/hooks/useResolvedIdentity.js +90 -0
- package/build/hooks/useResolvedIdentity.js.map +1 -0
- package/build/hooks/useRouteProps.d.ts +10 -5
- package/build/hooks/useRouteProps.js +27 -0
- package/build/hooks/useRouteProps.js.map +1 -0
- package/build/hooks/useWalletConnectModal.js +59 -0
- package/build/hooks/useWalletConnectModal.js.map +1 -0
- package/build/hooks/useWindowSize.js +23 -0
- package/build/hooks/useWindowSize.js.map +1 -0
- package/build/index.d.ts +61 -16
- package/build/index.js +31 -0
- package/build/index.js.map +1 -0
- package/build/localizations/index.js +57 -0
- package/build/localizations/index.js.map +1 -0
- package/build/localizations/locales/ar-AE.js +100 -0
- package/build/localizations/locales/ar-AE.js.map +1 -0
- package/build/localizations/locales/ca-AD.js +98 -0
- package/build/localizations/locales/ca-AD.js.map +1 -0
- package/build/localizations/locales/ee-EE.js +98 -0
- package/build/localizations/locales/ee-EE.js.map +1 -0
- package/build/localizations/locales/en-US.js +115 -0
- package/build/localizations/locales/en-US.js.map +1 -0
- package/build/localizations/locales/es-ES.js +98 -0
- package/build/localizations/locales/es-ES.js.map +1 -0
- package/build/localizations/locales/fa-IR.js +98 -0
- package/build/localizations/locales/fa-IR.js.map +1 -0
- package/build/localizations/locales/fr-FR.js +98 -0
- package/build/localizations/locales/fr-FR.js.map +1 -0
- package/build/localizations/locales/ja-JP.js +98 -0
- package/build/localizations/locales/ja-JP.js.map +1 -0
- package/build/localizations/locales/pt-BR.js +98 -0
- package/build/localizations/locales/pt-BR.js.map +1 -0
- package/build/localizations/locales/ru-RU.js +98 -0
- package/build/localizations/locales/ru-RU.js.map +1 -0
- package/build/localizations/locales/tr-TR.js +98 -0
- package/build/localizations/locales/tr-TR.js.map +1 -0
- package/build/localizations/locales/vi-VN.js +98 -0
- package/build/localizations/locales/vi-VN.js.map +1 -0
- package/build/localizations/locales/zh-CN.js +98 -0
- package/build/localizations/locales/zh-CN.js.map +1 -0
- package/build/openfort/CoreOpenfortProvider.d.ts +9 -22
- package/build/openfort/CoreOpenfortProvider.js +389 -0
- package/build/openfort/CoreOpenfortProvider.js.map +1 -0
- package/build/{hooks/useConnectCallback.d.ts → openfort/connectCallbackTypes.d.ts} +2 -2
- package/build/openfort/context.d.ts +3 -2
- package/build/openfort/context.js +6 -0
- package/build/openfort/context.js.map +1 -0
- package/build/openfort/core/client.d.ts +2 -1
- package/build/openfort/core/client.js +23 -0
- package/build/openfort/core/client.js.map +1 -0
- package/build/openfort/hooks/useActiveAddressSync.d.ts +20 -0
- package/build/openfort/hooks/useActiveAddressSync.js +76 -0
- package/build/openfort/hooks/useActiveAddressSync.js.map +1 -0
- package/build/openfort/hooks/useAutoRecovery.d.ts +26 -0
- package/build/openfort/hooks/useAutoRecovery.js +102 -0
- package/build/openfort/hooks/useAutoRecovery.js.map +1 -0
- package/build/openfort/hooks/useEmbeddedStateMachine.d.ts +31 -0
- package/build/openfort/hooks/useEmbeddedStateMachine.js +77 -0
- package/build/openfort/hooks/useEmbeddedStateMachine.js.map +1 -0
- package/build/openfort/selectors.d.ts +9 -0
- package/build/openfort/selectors.js +15 -0
- package/build/openfort/selectors.js.map +1 -0
- package/build/openfort/store.d.ts +46 -0
- package/build/openfort/store.js +116 -0
- package/build/openfort/store.js.map +1 -0
- package/build/openfort/useOpenfort.d.ts +9 -3
- package/build/openfort/useOpenfort.js +15 -0
- package/build/openfort/useOpenfort.js.map +1 -0
- package/build/openfort/useOpenfortStore.d.ts +2 -0
- package/build/openfort/useOpenfortStore.js +13 -0
- package/build/openfort/useOpenfortStore.js.map +1 -0
- package/build/query/index.d.ts +2 -0
- package/build/query/queryKeys.d.ts +12 -0
- package/build/query/queryKeys.js +15 -0
- package/build/query/queryKeys.js.map +1 -0
- package/build/query/queryOptions.d.ts +23 -0
- package/build/query/queryOptions.js +31 -0
- package/build/query/queryOptions.js.map +1 -0
- package/build/shared/hooks/useAsyncData.d.ts +19 -0
- package/build/shared/hooks/useAsyncData.js +69 -0
- package/build/shared/hooks/useAsyncData.js.map +1 -0
- package/build/shared/hooks/useRecoveryOTP.d.ts +11 -0
- package/build/shared/hooks/useRecoveryOTP.js +64 -0
- package/build/shared/hooks/useRecoveryOTP.js.map +1 -0
- package/build/shared/types.d.ts +65 -0
- package/build/shared/utils/embeddedWalletStatusMapper.d.ts +15 -0
- package/build/shared/utils/embeddedWalletStatusMapper.js +22 -0
- package/build/shared/utils/embeddedWalletStatusMapper.js.map +1 -0
- package/build/shared/utils/explorer.d.ts +24 -0
- package/build/shared/utils/explorer.js +71 -0
- package/build/shared/utils/explorer.js.map +1 -0
- package/build/shared/utils/otpError.d.ts +8 -0
- package/build/shared/utils/otpError.js +17 -0
- package/build/shared/utils/otpError.js.map +1 -0
- package/build/shared/utils/recovery.d.ts +15 -0
- package/build/shared/utils/recovery.js +96 -0
- package/build/shared/utils/recovery.js.map +1 -0
- package/build/shared/utils/walletStatusProps.d.ts +18 -0
- package/build/shared/utils/walletStatusProps.js +45 -0
- package/build/shared/utils/walletStatusProps.js.map +1 -0
- package/build/siwe/create-siwe-message.d.ts +15 -1
- package/build/siwe/create-siwe-message.js +32 -0
- package/build/siwe/create-siwe-message.js.map +1 -0
- package/build/solana/SolanaContext.d.ts +43 -0
- package/build/solana/SolanaContext.js +87 -0
- package/build/solana/SolanaContext.js.map +1 -0
- package/build/solana/hooks/recoveryResolver.d.ts +16 -0
- package/build/solana/hooks/recoveryResolver.js +39 -0
- package/build/solana/hooks/recoveryResolver.js.map +1 -0
- package/build/solana/hooks/useSolanaEmbeddedWallet.d.ts +17 -0
- package/build/solana/hooks/useSolanaEmbeddedWallet.js +389 -0
- package/build/solana/hooks/useSolanaEmbeddedWallet.js.map +1 -0
- package/build/solana/hooks/utils.d.ts +1 -0
- package/build/solana/hooks/utils.js +10 -0
- package/build/solana/hooks/utils.js.map +1 -0
- package/build/solana/index.d.ts +12 -0
- package/build/solana/index.js +2 -0
- package/build/solana/index.js.map +1 -0
- package/build/solana/operations.d.ts +22 -0
- package/build/solana/operations.js +40 -0
- package/build/solana/operations.js.map +1 -0
- package/build/solana/provider.d.ts +131 -0
- package/build/solana/provider.js +126 -0
- package/build/solana/provider.js.map +1 -0
- package/build/solana/types.d.ts +253 -0
- package/build/styles/index.js +334 -0
- package/build/styles/index.js.map +1 -0
- package/build/styles/styled/index.js +14 -0
- package/build/styles/styled/index.js.map +1 -0
- package/build/styles/themes/base.js +147 -0
- package/build/styles/themes/base.js.map +1 -0
- package/build/styles/themes/index.js +13 -0
- package/build/styles/themes/index.js.map +1 -0
- package/build/styles/themes/midnight.js +78 -0
- package/build/styles/themes/midnight.js.map +1 -0
- package/build/styles/themes/minimal.js +100 -0
- package/build/styles/themes/minimal.js.map +1 -0
- package/build/styles/themes/nouns.js +83 -0
- package/build/styles/themes/nouns.js.map +1 -0
- package/build/styles/themes/retro.js +110 -0
- package/build/styles/themes/retro.js.map +1 -0
- package/build/styles/themes/rounded.js +110 -0
- package/build/styles/themes/rounded.js.map +1 -0
- package/build/styles/themes/soft.js +73 -0
- package/build/styles/themes/soft.js.map +1 -0
- package/build/styles/themes/web95.js +136 -0
- package/build/styles/themes/web95.js.map +1 -0
- package/build/types.d.ts +5 -6
- package/build/types.js +33 -0
- package/build/types.js.map +1 -0
- package/build/utils/banner.d.ts +1 -0
- package/build/utils/banner.js +14 -0
- package/build/utils/banner.js.map +1 -0
- package/build/utils/errorHandling.js +331 -0
- package/build/utils/errorHandling.js.map +1 -0
- package/build/utils/format.d.ts +18 -0
- package/build/utils/format.js +59 -0
- package/build/utils/format.js.map +1 -0
- package/build/utils/index.d.ts +2 -3
- package/build/utils/index.js +67 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/logger.js +13 -0
- package/build/utils/logger.js.map +1 -0
- package/build/utils/oauthErrorHandler.d.ts +1 -1
- package/build/utils/oauthErrorHandler.js +42 -0
- package/build/utils/oauthErrorHandler.js.map +1 -0
- package/build/utils/p3.js +14 -0
- package/build/utils/p3.js.map +1 -0
- package/build/utils/rpc.d.ts +34 -0
- package/build/utils/rpc.js +93 -0
- package/build/utils/rpc.js.map +1 -0
- package/build/utils/useOnUserReturn.js +25 -0
- package/build/utils/useOnUserReturn.js.map +1 -0
- package/build/utils/validation.js +7 -0
- package/build/utils/validation.js.map +1 -0
- package/build/utils/wallets.d.ts +6 -0
- package/build/utils/wallets.js +14 -0
- package/build/utils/wallets.js.map +1 -0
- package/build/version.d.ts +1 -1
- package/build/version.js +4 -0
- package/build/version.js.map +1 -0
- package/build/wagmi/OpenfortWagmiBridge.d.ts +3 -0
- package/build/wagmi/OpenfortWagmiBridge.js +166 -0
- package/build/wagmi/OpenfortWagmiBridge.js.map +1 -0
- package/build/wagmi/components/ChainSelect/index.js +140 -0
- package/build/wagmi/components/ChainSelect/index.js.map +1 -0
- package/build/wagmi/components/ChainSelectDropdown/index.js +144 -0
- package/build/wagmi/components/ChainSelectDropdown/index.js.map +1 -0
- package/build/wagmi/components/ChainSelectDropdown/styles.js +47 -0
- package/build/wagmi/components/ChainSelectDropdown/styles.js.map +1 -0
- package/build/wagmi/components/ChainSelectList/index.js +109 -0
- package/build/wagmi/components/ChainSelectList/index.js.map +1 -0
- package/build/wagmi/components/ChainSelectList/styles.js +225 -0
- package/build/wagmi/components/ChainSelectList/styles.js.map +1 -0
- package/build/wagmi/components/SwitchNetworks/index.js +22 -0
- package/build/wagmi/components/SwitchNetworks/index.js.map +1 -0
- package/build/wagmi/connectorFilter.d.ts +6 -0
- package/build/wagmi/connectorFilter.js +16 -0
- package/build/wagmi/connectorFilter.js.map +1 -0
- package/build/{defaultConfig.d.ts → wagmi/defaultConfig.d.ts} +1 -2
- package/build/wagmi/defaultConfig.js +27 -0
- package/build/wagmi/defaultConfig.js.map +1 -0
- package/build/wagmi/defaultConnectors.js +36 -0
- package/build/wagmi/defaultConnectors.js.map +1 -0
- package/build/wagmi/embeddedConnector.d.ts +4 -0
- package/build/wagmi/embeddedConnector.js +80 -0
- package/build/wagmi/embeddedConnector.js.map +1 -0
- package/build/wagmi/index.d.ts +10 -0
- package/build/wagmi/index.js +10 -0
- package/build/wagmi/index.js.map +1 -0
- package/build/wagmi/useChainIsSupported.d.ts +20 -0
- package/build/wagmi/useChainIsSupported.js +30 -0
- package/build/wagmi/useChainIsSupported.js.map +1 -0
- package/build/wagmi/useChains.d.ts +29 -0
- package/build/wagmi/useChains.js +38 -0
- package/build/wagmi/useChains.js.map +1 -0
- package/build/wagmi/useConnectWithSiwe.d.ts +22 -0
- package/build/wagmi/useConnectWithSiwe.js +115 -0
- package/build/wagmi/useConnectWithSiwe.js.map +1 -0
- package/build/wagmi/useEmbeddedWalletWagmiSync.d.ts +2 -0
- package/build/wagmi/useEmbeddedWalletWagmiSync.js +55 -0
- package/build/wagmi/useEmbeddedWalletWagmiSync.js.map +1 -0
- package/build/wagmi/useWalletAuth.d.ts +24 -0
- package/build/wagmi/useWalletAuth.js +180 -0
- package/build/wagmi/useWalletAuth.js.map +1 -0
- package/build/wallets/useExternalConnectors.d.ts +17 -0
- package/build/wallets/useExternalConnectors.js +98 -0
- package/build/wallets/useExternalConnectors.js.map +1 -0
- package/build/wallets/walletConfigs.js +344 -0
- package/build/wallets/walletConfigs.js.map +1 -0
- package/package.json +62 -11
- package/build/components/PageLayout/index.d.ts +0 -6
- package/build/components/contexts/web3/index.d.ts +0 -13
- package/build/constants/erc20.d.ts +0 -42
- package/build/hooks/openfort/auth/useWalletAuth.d.ts +0 -20
- package/build/hooks/openfort/useConnectWithSiwe.d.ts +0 -8
- package/build/hooks/openfort/useWalletAssets.d.ts +0 -16
- package/build/hooks/openfort/useWallets.d.ts +0 -134
- package/build/hooks/useChainIsSupported.d.ts +0 -24
- package/build/hooks/useChains.d.ts +0 -41
- package/build/hooks/useConnect.d.ts +0 -24
- package/build/hooks/useEnsFallbackConfig.d.ts +0 -1
- package/build/index.es.js +0 -19627
- package/build/index.es.js.map +0 -1
- package/build/openfortCustomTypes.d.ts +0 -10
- package/build/wallets/index.d.ts +0 -7
- package/build/wallets/useWagmiWallets.d.ts +0 -9
- /package/build/components/Pages/{SoicalProviders → SocialProviders}/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelect/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectDropdown/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectDropdown/styles.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectList/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectList/styles.d.ts +0 -0
- /package/build/{components/Pages → wagmi/components}/SwitchNetworks/index.d.ts +0 -0
- /package/build/{defaultConnectors.d.ts → wagmi/defaultConnectors.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignOut.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const onSuccess = ({ hookOptions, options, data, }) => {
|
|
2
|
+
var _a, _b;
|
|
3
|
+
(_a = hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.onSuccess) === null || _a === void 0 ? void 0 : _a.call(hookOptions, data);
|
|
4
|
+
(_b = options === null || options === void 0 ? void 0 : options.onSuccess) === null || _b === void 0 ? void 0 : _b.call(options, data);
|
|
5
|
+
return data;
|
|
6
|
+
};
|
|
7
|
+
const onError = ({ hookOptions, options, error, }) => {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
(_a = hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.onError) === null || _a === void 0 ? void 0 : _a.call(hookOptions, error);
|
|
10
|
+
(_b = options === null || options === void 0 ? void 0 : options.onError) === null || _b === void 0 ? void 0 : _b.call(options, error);
|
|
11
|
+
if ((hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.throwOnError) || (options === null || options === void 0 ? void 0 : options.throwOnError))
|
|
12
|
+
throw error;
|
|
13
|
+
return { error };
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { onError, onSuccess };
|
|
17
|
+
//# sourceMappingURL=hookConsistency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hookConsistency.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { parseSignature } from 'viem';
|
|
3
|
+
import { hashAuthorization } from 'viem/utils';
|
|
4
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
|
|
5
|
+
import { useOpenfortCore } from '../../openfort/useOpenfort.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hook for signing EIP-7702 wallet authorizations
|
|
9
|
+
*
|
|
10
|
+
* This hook leverages the embedded Openfort client to sign authorization payloads prepared via viem.
|
|
11
|
+
* It mirrors viem's `signAuthorization` behaviour while always returning the structured authorization object,
|
|
12
|
+
* keeping private key management inside the Openfort SDK.
|
|
13
|
+
*
|
|
14
|
+
* @returns Helper with a `signAuthorization` function that signs authorizations with the active Openfort wallet
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { prepareAuthorization } from 'viem/actions';
|
|
19
|
+
* import { use7702Authorization } from '@openfort/openfort-react';
|
|
20
|
+
*
|
|
21
|
+
* const { signAuthorization } = use7702Authorization();
|
|
22
|
+
*
|
|
23
|
+
* const authorization = await prepareAuthorization(pimlicoClient, {
|
|
24
|
+
* account: eoaAccount.address,
|
|
25
|
+
* contractAddress: implementationAddress,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const signedAuthorization = await signAuthorization({
|
|
29
|
+
* ...authorization,
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function use7702Authorization() {
|
|
34
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: use7702Authorization is a valid hook name
|
|
35
|
+
const { client } = useOpenfortCore();
|
|
36
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: use7702Authorization is a valid hook name
|
|
37
|
+
const signAuthorization = useCallback(async (parameters, options = {
|
|
38
|
+
hashMessage: false,
|
|
39
|
+
arrayifyMessage: false,
|
|
40
|
+
}) => {
|
|
41
|
+
if (!client) {
|
|
42
|
+
throw new OpenfortError('Openfort client is not initialized.', OpenfortReactErrorType.CONFIGURATION_ERROR);
|
|
43
|
+
}
|
|
44
|
+
const authorization = parameters;
|
|
45
|
+
if (!authorization.contractAddress) {
|
|
46
|
+
throw new OpenfortError('Authorization is missing the contract address to sign.', OpenfortReactErrorType.CONFIGURATION_ERROR);
|
|
47
|
+
}
|
|
48
|
+
const hash = hashAuthorization(authorization);
|
|
49
|
+
try {
|
|
50
|
+
const signature = await client.embeddedWallet.signMessage(hash, {
|
|
51
|
+
hashMessage: options.hashMessage,
|
|
52
|
+
arrayifyMessage: options.arrayifyMessage,
|
|
53
|
+
});
|
|
54
|
+
const { r, s, v, yParity } = parseSignature(signature);
|
|
55
|
+
return {
|
|
56
|
+
address: authorization.contractAddress,
|
|
57
|
+
chainId: authorization.chainId,
|
|
58
|
+
nonce: authorization.nonce,
|
|
59
|
+
r,
|
|
60
|
+
s,
|
|
61
|
+
v,
|
|
62
|
+
yParity,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw new OpenfortError('Failed to sign authorization.', OpenfortReactErrorType.WALLET_ERROR, { error });
|
|
67
|
+
}
|
|
68
|
+
}, [client]);
|
|
69
|
+
return { signAuthorization };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { use7702Authorization };
|
|
73
|
+
//# sourceMappingURL=use7702Authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use7702Authorization.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
2
|
import { type GrantPermissionsParameters, type GrantPermissionsReturnType } from 'viem/experimental';
|
|
3
|
-
import { OpenfortError
|
|
3
|
+
import { OpenfortError } from '../../core/errors';
|
|
4
|
+
import type { OpenfortHookOptions } from '../../types';
|
|
4
5
|
type GrantPermissionsRequest = {
|
|
5
6
|
request: GrantPermissionsParameters;
|
|
6
7
|
sessionKey: Hex;
|
|
@@ -13,85 +14,15 @@ type GrantPermissionsHookResult = {
|
|
|
13
14
|
} & Partial<GrantPermissionsResult>;
|
|
14
15
|
type GrantPermissionsHookOptions = OpenfortHookOptions<GrantPermissionsHookResult>;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Grants session key permissions for EIP-7702 / account abstraction.
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* like session-based authentication and gasless transactions within defined scopes.
|
|
21
|
-
* The hook leverages EIP-7715 for permission granting.
|
|
22
|
-
*
|
|
23
|
-
* @param hookOptions - Optional configuration with callback functions
|
|
24
|
-
* @returns Current grant permissions state and actions
|
|
19
|
+
* @param hookOptions - Optional callbacks and configuration
|
|
20
|
+
* @returns grantPermissions(request), status, data, error
|
|
25
21
|
*
|
|
26
22
|
* @example
|
|
27
23
|
* ```tsx
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* const { grantPermissions, isLoading, isError, error } = useGrantPermissions({
|
|
32
|
-
* onSuccess: (result) => console.log('Permissions granted:', result),
|
|
33
|
-
* onError: (error) => console.error('Permission grant failed:', error),
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* // Grant permissions to a session key
|
|
37
|
-
* const handleGrantPermissions = async () => {
|
|
38
|
-
* try {
|
|
39
|
-
* // Generate a new session key
|
|
40
|
-
* const sessionKey = generatePrivateKey();
|
|
41
|
-
* const accountSession = privateKeyToAccount(sessionKey).address;
|
|
42
|
-
*
|
|
43
|
-
* const result = await grantPermissions({
|
|
44
|
-
* sessionKey,
|
|
45
|
-
* request: {
|
|
46
|
-
* signer: {
|
|
47
|
-
* type: 'account',
|
|
48
|
-
* data: {
|
|
49
|
-
* id: accountSession,
|
|
50
|
-
* },
|
|
51
|
-
* },
|
|
52
|
-
* expiry: 60 * 60 * 24, // 24 hours
|
|
53
|
-
* permissions: [
|
|
54
|
-
* {
|
|
55
|
-
* type: 'contract-call',
|
|
56
|
-
* data: {
|
|
57
|
-
* address: '0x2522f4fc9af2e1954a3d13f7a5b2683a00a4543a',
|
|
58
|
-
* },
|
|
59
|
-
* },
|
|
60
|
-
* ],
|
|
61
|
-
* },
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* if (result.address) {
|
|
65
|
-
* console.log('Session created with address:', result.address);
|
|
66
|
-
* console.log('Session private key:', result.privateKey);
|
|
67
|
-
* }
|
|
68
|
-
* } catch (error) {
|
|
69
|
-
* console.error('Failed to grant permissions:', error);
|
|
70
|
-
* }
|
|
71
|
-
* };
|
|
72
|
-
*
|
|
73
|
-
* // Check permission grant state
|
|
74
|
-
* if (isLoading) {
|
|
75
|
-
* console.log('Granting permissions...');
|
|
76
|
-
* } else if (isError) {
|
|
77
|
-
* console.error('Permission grant error:', error);
|
|
78
|
-
* }
|
|
79
|
-
*
|
|
80
|
-
* // Example usage in component
|
|
81
|
-
* return (
|
|
82
|
-
* <div>
|
|
83
|
-
* <button
|
|
84
|
-
* onClick={handleGrantPermissions}
|
|
85
|
-
* disabled={isLoading}
|
|
86
|
-
* >
|
|
87
|
-
* {isLoading ? 'Granting Permissions...' : 'Create Session'}
|
|
88
|
-
* </button>
|
|
89
|
-
*
|
|
90
|
-
* {isError && (
|
|
91
|
-
* <p>Error: {error?.message}</p>
|
|
92
|
-
* )}
|
|
93
|
-
* </div>
|
|
94
|
-
* );
|
|
24
|
+
* const { grantPermissions } = useGrantPermissions()
|
|
25
|
+
* await grantPermissions({ request: { ... } })
|
|
95
26
|
* ```
|
|
96
27
|
*/
|
|
97
28
|
export declare const useGrantPermissions: (hookOptions?: GrantPermissionsHookOptions) => {
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { custom, createWalletClient } from 'viem';
|
|
3
|
+
import { erc7715Actions } from 'viem/experimental';
|
|
4
|
+
import { useOpenfort } from '../../components/Openfort/useOpenfort.js';
|
|
5
|
+
import { DEFAULT_TESTNET_CHAIN_ID } from '../../core/ConnectionStrategy.js';
|
|
6
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
|
|
7
|
+
import { useEthereumEmbeddedWallet } from '../../ethereum/hooks/useEthereumEmbeddedWallet.js';
|
|
8
|
+
import { useEthereumBridge } from '../../ethereum/OpenfortEthereumBridgeContext.js';
|
|
9
|
+
import { useOpenfortCore } from '../../openfort/useOpenfort.js';
|
|
10
|
+
import { logger } from '../../utils/logger.js';
|
|
11
|
+
import { mapStatus } from './auth/status.js';
|
|
12
|
+
import { onSuccess, onError } from './hookConsistency.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Hook for granting permissions to session keys (EIP-7715)
|
|
16
|
+
*
|
|
17
|
+
* This hook manages the creation and authorization of session keys, allowing users to
|
|
18
|
+
* delegate permissions to specific accounts for a limited time. This enables use cases
|
|
19
|
+
* like session-based authentication and gasless transactions within defined scopes.
|
|
20
|
+
* The hook leverages EIP-7715 for permission granting.
|
|
21
|
+
*
|
|
22
|
+
* @param hookOptions - Optional configuration with callback functions
|
|
23
|
+
* @returns Current grant permissions state and actions
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
28
|
+
* import { useGrantPermissions } from '@openfort/openfort-react';
|
|
29
|
+
*
|
|
30
|
+
* const { grantPermissions, isLoading, isError, error } = useGrantPermissions({
|
|
31
|
+
* onSuccess: (result) => console.log('Permissions granted:', result),
|
|
32
|
+
* onError: (error) => console.error('Permission grant failed:', error),
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Grant permissions to a session key
|
|
36
|
+
* const handleGrantPermissions = async () => {
|
|
37
|
+
* try {
|
|
38
|
+
* // Generate a new session key
|
|
39
|
+
* const sessionKey = generatePrivateKey();
|
|
40
|
+
* const accountSession = privateKeyToAccount(sessionKey).address;
|
|
41
|
+
*
|
|
42
|
+
* const result = await grantPermissions({
|
|
43
|
+
* sessionKey,
|
|
44
|
+
* request: {
|
|
45
|
+
* signer: {
|
|
46
|
+
* type: 'account',
|
|
47
|
+
* data: {
|
|
48
|
+
* id: accountSession,
|
|
49
|
+
* },
|
|
50
|
+
* },
|
|
51
|
+
* expiry: 60 * 60 * 24, // 24 hours
|
|
52
|
+
* permissions: [
|
|
53
|
+
* {
|
|
54
|
+
* type: 'contract-call',
|
|
55
|
+
* data: {
|
|
56
|
+
* address: '0x2522f4fc9af2e1954a3d13f7a5b2683a00a4543a',
|
|
57
|
+
* },
|
|
58
|
+
* },
|
|
59
|
+
* ],
|
|
60
|
+
* },
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* if (result.address) {
|
|
64
|
+
* console.log('Session created with address:', result.address);
|
|
65
|
+
* console.log('Session private key:', result.privateKey);
|
|
66
|
+
* }
|
|
67
|
+
* } catch (error) {
|
|
68
|
+
* console.error('Failed to grant permissions:', error);
|
|
69
|
+
* }
|
|
70
|
+
* };
|
|
71
|
+
*
|
|
72
|
+
* // Check permission grant state
|
|
73
|
+
* if (isLoading) {
|
|
74
|
+
* console.log('Granting permissions...');
|
|
75
|
+
* } else if (isError) {
|
|
76
|
+
* console.error('Permission grant error:', error);
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* // Example usage in component
|
|
80
|
+
* return (
|
|
81
|
+
* <div>
|
|
82
|
+
* <button
|
|
83
|
+
* onClick={handleGrantPermissions}
|
|
84
|
+
* disabled={isLoading}
|
|
85
|
+
* >
|
|
86
|
+
* {isLoading ? 'Granting Permissions...' : 'Create Session'}
|
|
87
|
+
* </button>
|
|
88
|
+
*
|
|
89
|
+
* {isError && (
|
|
90
|
+
* <p>Error: {error?.message}</p>
|
|
91
|
+
* )}
|
|
92
|
+
* </div>
|
|
93
|
+
* );
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
async function getEmbeddedWalletClientWithErc7715(provider, chain) {
|
|
97
|
+
const accounts = (await provider.request({ method: 'eth_accounts' }));
|
|
98
|
+
if (!(accounts === null || accounts === void 0 ? void 0 : accounts.length))
|
|
99
|
+
throw new OpenfortError('No accounts available', OpenfortReactErrorType.WALLET_ERROR);
|
|
100
|
+
const account = accounts[0];
|
|
101
|
+
const transport = custom(provider);
|
|
102
|
+
const baseClient = createWalletClient({ account, chain, transport });
|
|
103
|
+
return baseClient.extend(erc7715Actions());
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Grants session key permissions for EIP-7702 / account abstraction.
|
|
107
|
+
*
|
|
108
|
+
* @param hookOptions - Optional callbacks and configuration
|
|
109
|
+
* @returns grantPermissions(request), status, data, error
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* const { grantPermissions } = useGrantPermissions()
|
|
114
|
+
* await grantPermissions({ request: { ... } })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
const useGrantPermissions = (hookOptions = {}) => {
|
|
118
|
+
var _a, _b;
|
|
119
|
+
const bridge = useEthereumBridge();
|
|
120
|
+
const { chains } = useOpenfort();
|
|
121
|
+
const { client } = useOpenfortCore();
|
|
122
|
+
const ethereum = useEthereumEmbeddedWallet();
|
|
123
|
+
const chainId = (_b = (_a = bridge === null || bridge === void 0 ? void 0 : bridge.chainId) !== null && _a !== void 0 ? _a : (ethereum.status === 'connected' ? ethereum.chainId : undefined)) !== null && _b !== void 0 ? _b : DEFAULT_TESTNET_CHAIN_ID;
|
|
124
|
+
const [status, setStatus] = useState({
|
|
125
|
+
status: 'idle',
|
|
126
|
+
});
|
|
127
|
+
const [data, setData] = useState(null);
|
|
128
|
+
const grantPermissions = useCallback(async ({ request }, options = {}) => {
|
|
129
|
+
try {
|
|
130
|
+
logger.log('Granting permissions with request:', request);
|
|
131
|
+
const chain = chains.find((c) => c.id === chainId);
|
|
132
|
+
if (!chain) {
|
|
133
|
+
throw new OpenfortError('No chain configured', OpenfortReactErrorType.CONFIGURATION_ERROR);
|
|
134
|
+
}
|
|
135
|
+
setStatus({
|
|
136
|
+
status: 'loading',
|
|
137
|
+
});
|
|
138
|
+
let account;
|
|
139
|
+
let grantPermissionsResult;
|
|
140
|
+
if (bridge === null || bridge === void 0 ? void 0 : bridge.getWalletClient) {
|
|
141
|
+
// Wagmi connector may still be connecting after auto-recover → READY transition.
|
|
142
|
+
// Poll briefly before giving up.
|
|
143
|
+
let rawClient = await bridge.getWalletClient();
|
|
144
|
+
for (let attempt = 0; !rawClient && attempt < 4; attempt++) {
|
|
145
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
146
|
+
rawClient = await bridge.getWalletClient();
|
|
147
|
+
if (rawClient)
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (!rawClient) {
|
|
151
|
+
throw new OpenfortError('Wallet client not available', OpenfortReactErrorType.WALLET_ERROR);
|
|
152
|
+
}
|
|
153
|
+
const walletClient = rawClient.extend(erc7715Actions());
|
|
154
|
+
const [addr] = await walletClient.getAddresses();
|
|
155
|
+
if (!addr)
|
|
156
|
+
throw new OpenfortError('No account on wallet client', OpenfortReactErrorType.WALLET_ERROR);
|
|
157
|
+
account = addr;
|
|
158
|
+
grantPermissionsResult = await walletClient.grantPermissions(request);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
let provider;
|
|
162
|
+
if (ethereum.status === 'connected') {
|
|
163
|
+
provider = await ethereum.activeWallet.getProvider();
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
provider = (await client.embeddedWallet.getEthereumProvider());
|
|
167
|
+
await provider.request({ method: 'eth_requestAccounts' });
|
|
168
|
+
}
|
|
169
|
+
const walletClient = await getEmbeddedWalletClientWithErc7715(provider, chain);
|
|
170
|
+
const [addr] = await walletClient.getAddresses();
|
|
171
|
+
if (!addr)
|
|
172
|
+
throw new OpenfortError('No account on wallet client', OpenfortReactErrorType.WALLET_ERROR);
|
|
173
|
+
account = addr;
|
|
174
|
+
grantPermissionsResult = await walletClient.grantPermissions(request);
|
|
175
|
+
}
|
|
176
|
+
const data = {
|
|
177
|
+
address: account,
|
|
178
|
+
...grantPermissionsResult,
|
|
179
|
+
};
|
|
180
|
+
logger.log('Grant permissions result:', data);
|
|
181
|
+
setData(data);
|
|
182
|
+
setStatus({
|
|
183
|
+
status: 'success',
|
|
184
|
+
});
|
|
185
|
+
return onSuccess({
|
|
186
|
+
hookOptions,
|
|
187
|
+
options,
|
|
188
|
+
data,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
const isUnsupported = error instanceof Error &&
|
|
193
|
+
/Method not supported|grantPermissions|wallet_grantPermissions|does not support/i.test(error.message);
|
|
194
|
+
const message = isUnsupported
|
|
195
|
+
? 'Session keys (grantPermissions) are not supported by the embedded wallet provider. Use an external wallet for this flow.'
|
|
196
|
+
: undefined;
|
|
197
|
+
const openfortError = new OpenfortError(message !== null && message !== void 0 ? message : 'Failed to grant permissions', OpenfortReactErrorType.WALLET_ERROR, { error });
|
|
198
|
+
setStatus({
|
|
199
|
+
status: 'error',
|
|
200
|
+
error: openfortError,
|
|
201
|
+
});
|
|
202
|
+
return onError({
|
|
203
|
+
hookOptions,
|
|
204
|
+
options,
|
|
205
|
+
error: openfortError,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}, [bridge, chains, chainId, client, ethereum, hookOptions]);
|
|
209
|
+
return {
|
|
210
|
+
grantPermissions,
|
|
211
|
+
data,
|
|
212
|
+
reset: () => {
|
|
213
|
+
setStatus({ status: 'idle' });
|
|
214
|
+
setData(null);
|
|
215
|
+
},
|
|
216
|
+
...mapStatus(status),
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export { useGrantPermissions };
|
|
221
|
+
//# sourceMappingURL=useGrantPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGrantPermissions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { UIAuthProvider, socialProviders } from '../../components/Openfort/types.js';
|
|
3
|
+
import { useOpenfort } from '../../components/Openfort/useOpenfort.js';
|
|
4
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
|
|
5
|
+
import { useOpenfortCore } from '../../openfort/useOpenfort.js';
|
|
6
|
+
import { logger } from '../../utils/logger.js';
|
|
7
|
+
|
|
8
|
+
function useProviders() {
|
|
9
|
+
const { user, linkedAccounts } = useOpenfortCore();
|
|
10
|
+
const { uiConfig: options, thirdPartyAuth, setOpen } = useOpenfort();
|
|
11
|
+
const allProviders = (options === null || options === void 0 ? void 0 : options.authProviders) || [];
|
|
12
|
+
const providers = allProviders.filter((p) => p !== UIAuthProvider.GUEST) || [];
|
|
13
|
+
const linkedProviders = user ? providers.filter((p) => linkedAccounts === null || linkedAccounts === void 0 ? void 0 : linkedAccounts.find((a) => a.provider === p)) : [];
|
|
14
|
+
const availableProviders = user
|
|
15
|
+
? providers.filter((provider) => {
|
|
16
|
+
if (provider === UIAuthProvider.WALLET)
|
|
17
|
+
return true; // Wallet is always available
|
|
18
|
+
if (user.email && (provider === UIAuthProvider.EMAIL_PASSWORD || provider === UIAuthProvider.EMAIL_OTP)) {
|
|
19
|
+
return false; // If user has email, don't show email password or otp
|
|
20
|
+
}
|
|
21
|
+
if (provider === UIAuthProvider.EMAIL_PASSWORD)
|
|
22
|
+
return false; // Disable email password linking for now
|
|
23
|
+
if (user.phoneNumber && provider === UIAuthProvider.PHONE) {
|
|
24
|
+
return false; // If user has phone number, don't show phone otp
|
|
25
|
+
}
|
|
26
|
+
return !(linkedAccounts === null || linkedAccounts === void 0 ? void 0 : linkedAccounts.find((a) => a.provider === provider));
|
|
27
|
+
})
|
|
28
|
+
: providers;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (thirdPartyAuth) {
|
|
31
|
+
setOpen(false);
|
|
32
|
+
logger.error(new OpenfortError('When using external third party auth providers, openfort Auth providers are not available. Either remove the `thirdPartyAuth` or authenticate your users using Auth hooks.', OpenfortReactErrorType.CONFIGURATION_ERROR));
|
|
33
|
+
}
|
|
34
|
+
}, [thirdPartyAuth, setOpen]);
|
|
35
|
+
const maxProviders = (options === null || options === void 0 ? void 0 : options.authProvidersLength) || 4;
|
|
36
|
+
const { mainProviders, hasExcessProviders, remainingSocialProviders } = useMemo(() => {
|
|
37
|
+
const activeProviders = user ? availableProviders : allProviders;
|
|
38
|
+
if (activeProviders.length <= maxProviders) {
|
|
39
|
+
return { mainProviders: activeProviders, hasExcessProviders: false, remainingSocialProviders: [] };
|
|
40
|
+
}
|
|
41
|
+
// Separate social and non-social providers
|
|
42
|
+
const nonSocial = activeProviders.filter((p, _, array) => {
|
|
43
|
+
if (p === UIAuthProvider.EMAIL_OTP && array.includes(UIAuthProvider.EMAIL_PASSWORD)) {
|
|
44
|
+
// If both email otp and email password are present, treat email otp as social to avoid showing both
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return !socialProviders.includes(p);
|
|
48
|
+
});
|
|
49
|
+
const social = activeProviders.filter((p) => socialProviders.includes(p));
|
|
50
|
+
// Allow as many non-socials as possible, then fill the rest with socials
|
|
51
|
+
const remainingSlots = maxProviders - nonSocial.length;
|
|
52
|
+
const remainingSocialProviders = social.slice(Math.max(0, remainingSlots - 1));
|
|
53
|
+
return {
|
|
54
|
+
mainProviders: [...nonSocial, ...social.slice(0, Math.max(0, remainingSlots - 1))].sort((a, b) => {
|
|
55
|
+
// sort them in the original order
|
|
56
|
+
const indexA = activeProviders.indexOf(a);
|
|
57
|
+
const indexB = activeProviders.indexOf(b);
|
|
58
|
+
return indexA - indexB;
|
|
59
|
+
}),
|
|
60
|
+
hasExcessProviders: social.length > remainingSlots - 1,
|
|
61
|
+
remainingSocialProviders,
|
|
62
|
+
};
|
|
63
|
+
}, [user, availableProviders, allProviders, maxProviders]);
|
|
64
|
+
return {
|
|
65
|
+
availableProviders,
|
|
66
|
+
linkedProviders,
|
|
67
|
+
allProviders,
|
|
68
|
+
mainProviders,
|
|
69
|
+
hasExcessProviders,
|
|
70
|
+
remainingSocialProviders,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { useProviders };
|
|
75
|
+
//# sourceMappingURL=useProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProviders.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SessionResponse } from '@openfort/openfort-js';
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
|
-
import { OpenfortError
|
|
3
|
+
import { OpenfortError } from '../../core/errors';
|
|
4
|
+
import type { OpenfortHookOptions } from '../../types';
|
|
4
5
|
type RevokePermissionsRequest = {
|
|
5
6
|
sessionKey: Hex;
|
|
6
7
|
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useOpenfort } from '../../components/Openfort/useOpenfort.js';
|
|
3
|
+
import { DEFAULT_TESTNET_CHAIN_ID } from '../../core/ConnectionStrategy.js';
|
|
4
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
|
|
5
|
+
import { getEmbeddedWalletClient } from '../../ethereum/hooks/getEmbeddedWalletClient.js';
|
|
6
|
+
import { useEthereumEmbeddedWallet } from '../../ethereum/hooks/useEthereumEmbeddedWallet.js';
|
|
7
|
+
import { useOpenfortCore } from '../../openfort/useOpenfort.js';
|
|
8
|
+
import { logger } from '../../utils/logger.js';
|
|
9
|
+
import { mapStatus } from './auth/status.js';
|
|
10
|
+
import { onSuccess, onError } from './hookConsistency.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Hook for revoking permissions to session keys (EIP-7715)
|
|
14
|
+
*
|
|
15
|
+
* This hook manages the creation and authorization of session keys, allowing users to
|
|
16
|
+
* delegate permissions to specific accounts for a limited time. This enables use cases
|
|
17
|
+
* like session-based authentication and gasless transactions within defined scopes.
|
|
18
|
+
* The hook leverages EIP-7715 for permission revocation.
|
|
19
|
+
*
|
|
20
|
+
* @param hookOptions - Optional configuration with callback functions
|
|
21
|
+
* @returns Current revoke permissions state and actions
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
26
|
+
* import { useRevokePermissions } from '@openfort/openfort-react';
|
|
27
|
+
*
|
|
28
|
+
* const { revokePermissions, isLoading, isError, error } = useRevokePermissions({
|
|
29
|
+
* onSuccess: (result) => console.log('Permissions revoked:', result),
|
|
30
|
+
* onError: (error) => console.error('Permission revoke failed:', error),
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Revoke Permissions to a session key
|
|
34
|
+
* const handleRevokePermissions = async () => {
|
|
35
|
+
* try {
|
|
36
|
+
* const sessionKey = '0x...'; // The session key to revoke permissions for
|
|
37
|
+
*
|
|
38
|
+
* const result = await revokePermissions({
|
|
39
|
+
* sessionKey,
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* console.log('Revoke result:', result);
|
|
43
|
+
* } catch (error) {
|
|
44
|
+
* console.error('Error revoking permissions:', error);
|
|
45
|
+
* }
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
const useRevokePermissions = (hookOptions = {}) => {
|
|
50
|
+
var _a;
|
|
51
|
+
const { chains } = useOpenfort();
|
|
52
|
+
const { client } = useOpenfortCore();
|
|
53
|
+
const ethereum = useEthereumEmbeddedWallet();
|
|
54
|
+
const chainId = (_a = ethereum.chainId) !== null && _a !== void 0 ? _a : DEFAULT_TESTNET_CHAIN_ID;
|
|
55
|
+
const [status, setStatus] = useState({
|
|
56
|
+
status: 'idle',
|
|
57
|
+
});
|
|
58
|
+
const [data, setData] = useState(null);
|
|
59
|
+
const revokePermissions = useCallback(async ({ sessionKey }, options = {}) => {
|
|
60
|
+
try {
|
|
61
|
+
const chain = chains.find((c) => c.id === chainId);
|
|
62
|
+
if (!chain) {
|
|
63
|
+
throw new OpenfortError('No chain configured', OpenfortReactErrorType.CONFIGURATION_ERROR);
|
|
64
|
+
}
|
|
65
|
+
logger.log('Revoking permissions for session key:', sessionKey);
|
|
66
|
+
setStatus({
|
|
67
|
+
status: 'loading',
|
|
68
|
+
});
|
|
69
|
+
const revokeParams = [
|
|
70
|
+
{
|
|
71
|
+
permissionContext: sessionKey,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
let provider;
|
|
75
|
+
if (ethereum.status === 'connected') {
|
|
76
|
+
provider = await ethereum.activeWallet.getProvider();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
provider = (await client.embeddedWallet.getEthereumProvider());
|
|
80
|
+
await provider.request({ method: 'eth_requestAccounts' });
|
|
81
|
+
}
|
|
82
|
+
const walletClient = await getEmbeddedWalletClient(provider, chain);
|
|
83
|
+
const revokePermissionsResult = await walletClient.request({
|
|
84
|
+
method: 'wallet_revokePermissions',
|
|
85
|
+
params: revokeParams,
|
|
86
|
+
});
|
|
87
|
+
logger.log('Revoke permissions result:', revokePermissionsResult);
|
|
88
|
+
const data = revokePermissionsResult;
|
|
89
|
+
setData(data);
|
|
90
|
+
setStatus({
|
|
91
|
+
status: 'success',
|
|
92
|
+
});
|
|
93
|
+
return onSuccess({
|
|
94
|
+
hookOptions,
|
|
95
|
+
options,
|
|
96
|
+
data,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const openfortError = new OpenfortError('Failed to revoke permissions', OpenfortReactErrorType.WALLET_ERROR, {
|
|
101
|
+
error,
|
|
102
|
+
});
|
|
103
|
+
setStatus({
|
|
104
|
+
status: 'error',
|
|
105
|
+
error: openfortError,
|
|
106
|
+
});
|
|
107
|
+
return onError({
|
|
108
|
+
hookOptions,
|
|
109
|
+
options,
|
|
110
|
+
error: openfortError,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, [chains, chainId, client, ethereum, hookOptions]);
|
|
114
|
+
return {
|
|
115
|
+
revokePermissions,
|
|
116
|
+
data,
|
|
117
|
+
reset: () => {
|
|
118
|
+
setStatus({ status: 'idle' });
|
|
119
|
+
setData(null);
|
|
120
|
+
},
|
|
121
|
+
...mapStatus(status),
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { useRevokePermissions };
|
|
126
|
+
//# sourceMappingURL=useRevokePermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRevokePermissions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|