@openfort/react 0.3.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +230 -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/SolanaSend.d.ts +1 -0
- package/build/components/Pages/Send/SolanaSend.js +93 -0
- package/build/components/Pages/Send/SolanaSend.js.map +1 -0
- package/build/components/Pages/Send/index.d.ts +7 -1
- package/build/components/Pages/Send/index.js +18 -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/Pages/SolanaSendConfirmation/index.d.ts +1 -0
- package/build/components/Pages/SolanaSendConfirmation/index.js +152 -0
- package/build/components/Pages/SolanaSendConfirmation/index.js.map +1 -0
- package/build/components/Pages/SolanaWallets/index.d.ts +1 -0
- package/build/components/Pages/SolanaWallets/index.js +36 -0
- package/build/components/Pages/SolanaWallets/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/validation.d.ts +15 -0
- package/build/shared/utils/validation.js +27 -0
- package/build/shared/utils/validation.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/constants.d.ts +21 -0
- package/build/solana/constants.js +24 -0
- package/build/solana/constants.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 +2 -0
- package/build/solana/hooks/utils.js +18 -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/solana/utils/transfer.d.ts +9 -0
- package/build/solana/utils/transfer.js +20 -0
- package/build/solana/utils/transfer.js.map +1 -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,496 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../../types.js';
|
|
3
|
+
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
4
|
+
import { logger } from '../../../utils/logger.js';
|
|
5
|
+
import { isValidEmail } from '../../../utils/validation.js';
|
|
6
|
+
import { onError, onSuccess } from '../hookConsistency.js';
|
|
7
|
+
import { useUI } from '../useUI.js';
|
|
8
|
+
import { buildCallbackUrl } from './requestEmailVerification.js';
|
|
9
|
+
import { mapStatus } from './status.js';
|
|
10
|
+
import { useConnectToWalletPostAuth } from './useConnectToWalletPostAuth.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Hook for email-based authentication operations
|
|
14
|
+
*
|
|
15
|
+
* This hook manages email authentication flows including sign-in, sign-up, password reset,
|
|
16
|
+
* email verification, and email linking. It handles both password and passwordless authentication
|
|
17
|
+
* and automatically manages wallet connection after successful authentication.
|
|
18
|
+
*
|
|
19
|
+
* @param hookOptions - Optional configuration with callback functions and authentication options
|
|
20
|
+
* @returns Current authentication state with email auth actions
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const emailAuth = useEmailAuth({
|
|
25
|
+
* onSignInEmailSuccess: (result) => console.log('Signed in:', result.user),
|
|
26
|
+
* onSignInEmailError: (error) => console.error('Sign-in failed:', error),
|
|
27
|
+
* emailVerificationRedirectTo: 'https://yourapp.com/verify',
|
|
28
|
+
* recoverWalletAutomatically: true,
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Sign up with email and password
|
|
32
|
+
* await emailAuth.signUpEmail({
|
|
33
|
+
* email: 'user@example.com',
|
|
34
|
+
* password: 'securePassword123',
|
|
35
|
+
* name: 'John Doe',
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Sign in with email and password
|
|
39
|
+
* await emailAuth.signInEmail({
|
|
40
|
+
* email: 'user@example.com',
|
|
41
|
+
* password: 'securePassword123',
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Request password reset
|
|
45
|
+
* await emailAuth.requestResetPassword({
|
|
46
|
+
* email: 'user@example.com',
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Reset password with state token
|
|
50
|
+
* await emailAuth.resetPassword({
|
|
51
|
+
* email: 'user@example.com',
|
|
52
|
+
* password: 'newPassword123',
|
|
53
|
+
* state: 'reset-token-from-email',
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Verify email with state token
|
|
57
|
+
* await emailAuth.verifyEmail({
|
|
58
|
+
* email: 'user@example.com',
|
|
59
|
+
* state: 'verification-token-from-email',
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Link email to existing authenticated account
|
|
63
|
+
* await emailAuth.linkEmail({
|
|
64
|
+
* email: 'secondary@example.com',
|
|
65
|
+
* password: 'password123',
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* // Check authentication state
|
|
69
|
+
* if (emailAuth.isLoading) {
|
|
70
|
+
* console.log('Processing authentication...');
|
|
71
|
+
* } else if (emailAuth.isError) {
|
|
72
|
+
* console.error('Authentication error:', emailAuth.error);
|
|
73
|
+
* } else if (emailAuth.isSuccess) {
|
|
74
|
+
* console.log('Authentication successful');
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* // Handle email verification requirement
|
|
78
|
+
* if (emailAuth.requiresEmailVerification) {
|
|
79
|
+
* console.log('Please check your email to verify your account');
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
const useEmailAuth = (hookOptions = {}) => {
|
|
84
|
+
const { client, updateUser } = useOpenfortCore();
|
|
85
|
+
const { isOpen } = useUI();
|
|
86
|
+
const [requiresEmailVerification, setRequiresEmailVerification] = useState(false);
|
|
87
|
+
const [status, setStatus] = useState({
|
|
88
|
+
status: 'idle',
|
|
89
|
+
});
|
|
90
|
+
const reset = useCallback(() => {
|
|
91
|
+
setStatus({
|
|
92
|
+
status: 'idle',
|
|
93
|
+
});
|
|
94
|
+
setRequiresEmailVerification(false);
|
|
95
|
+
}, []);
|
|
96
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
97
|
+
const signInEmail = useCallback(async (options) => {
|
|
98
|
+
var _a, _b, _c;
|
|
99
|
+
try {
|
|
100
|
+
setStatus({
|
|
101
|
+
status: 'loading',
|
|
102
|
+
});
|
|
103
|
+
setRequiresEmailVerification(false);
|
|
104
|
+
if (!options.email || !options.password) {
|
|
105
|
+
const error = new OpenfortError('Email and password are required', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
106
|
+
setStatus({
|
|
107
|
+
status: 'error',
|
|
108
|
+
error,
|
|
109
|
+
});
|
|
110
|
+
return onError({
|
|
111
|
+
hookOptions,
|
|
112
|
+
options,
|
|
113
|
+
error,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (!isValidEmail(options.email)) {
|
|
117
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
118
|
+
setStatus({
|
|
119
|
+
status: 'error',
|
|
120
|
+
error,
|
|
121
|
+
});
|
|
122
|
+
return onError({
|
|
123
|
+
hookOptions,
|
|
124
|
+
options,
|
|
125
|
+
error,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const result = await client.auth.logInWithEmailPassword({
|
|
129
|
+
email: options.email,
|
|
130
|
+
password: options.password,
|
|
131
|
+
});
|
|
132
|
+
if ('action' in result) {
|
|
133
|
+
setStatus({
|
|
134
|
+
status: 'awaiting-input',
|
|
135
|
+
});
|
|
136
|
+
client.auth.requestEmailVerification({
|
|
137
|
+
email: options.email,
|
|
138
|
+
redirectUrl: buildCallbackUrl({
|
|
139
|
+
email: options.email,
|
|
140
|
+
callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
|
|
141
|
+
provider: 'email',
|
|
142
|
+
isOpen,
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
setRequiresEmailVerification(true);
|
|
146
|
+
return onSuccess({
|
|
147
|
+
data: { requiresEmailVerification: true },
|
|
148
|
+
hookOptions,
|
|
149
|
+
options,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const { wallet } = await tryUseWallet({
|
|
154
|
+
logoutOnError: (_b = options.logoutOnError) !== null && _b !== void 0 ? _b : hookOptions.logoutOnError,
|
|
155
|
+
recoverWalletAutomatically: (_c = options.recoverWalletAutomatically) !== null && _c !== void 0 ? _c : hookOptions.recoverWalletAutomatically,
|
|
156
|
+
});
|
|
157
|
+
setStatus({
|
|
158
|
+
status: 'success',
|
|
159
|
+
});
|
|
160
|
+
const user = result.user;
|
|
161
|
+
await updateUser();
|
|
162
|
+
return onSuccess({
|
|
163
|
+
data: { user, wallet },
|
|
164
|
+
hookOptions,
|
|
165
|
+
options,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
const error = new OpenfortError('Failed to login with email and password', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
171
|
+
error: e,
|
|
172
|
+
});
|
|
173
|
+
setStatus({
|
|
174
|
+
status: 'error',
|
|
175
|
+
error,
|
|
176
|
+
});
|
|
177
|
+
return onError({
|
|
178
|
+
hookOptions,
|
|
179
|
+
options,
|
|
180
|
+
error,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
184
|
+
const requestResetPassword = useCallback(async (options) => {
|
|
185
|
+
var _a;
|
|
186
|
+
try {
|
|
187
|
+
if (!isValidEmail(options.email)) {
|
|
188
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
189
|
+
setStatus({
|
|
190
|
+
status: 'error',
|
|
191
|
+
error,
|
|
192
|
+
});
|
|
193
|
+
return onError({
|
|
194
|
+
hookOptions,
|
|
195
|
+
options,
|
|
196
|
+
error,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
setStatus({
|
|
200
|
+
status: 'loading',
|
|
201
|
+
});
|
|
202
|
+
setRequiresEmailVerification(false);
|
|
203
|
+
await client.auth.requestResetPassword({
|
|
204
|
+
email: options.email,
|
|
205
|
+
redirectUrl: buildCallbackUrl({
|
|
206
|
+
email: options.email,
|
|
207
|
+
callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
|
|
208
|
+
provider: 'password',
|
|
209
|
+
isOpen,
|
|
210
|
+
}),
|
|
211
|
+
});
|
|
212
|
+
setStatus({
|
|
213
|
+
status: 'success',
|
|
214
|
+
});
|
|
215
|
+
setRequiresEmailVerification(true);
|
|
216
|
+
return onSuccess({
|
|
217
|
+
data: { requiresEmailVerification: true },
|
|
218
|
+
hookOptions,
|
|
219
|
+
options,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
const error = new OpenfortError('Failed to reset password', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
224
|
+
error: e,
|
|
225
|
+
});
|
|
226
|
+
setStatus({
|
|
227
|
+
status: 'error',
|
|
228
|
+
error,
|
|
229
|
+
});
|
|
230
|
+
return onError({
|
|
231
|
+
hookOptions,
|
|
232
|
+
options,
|
|
233
|
+
error,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
237
|
+
const resetPassword = useCallback(async (options) => {
|
|
238
|
+
try {
|
|
239
|
+
if (!isValidEmail(options.email)) {
|
|
240
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
241
|
+
setStatus({
|
|
242
|
+
status: 'error',
|
|
243
|
+
error,
|
|
244
|
+
});
|
|
245
|
+
return onError({
|
|
246
|
+
hookOptions,
|
|
247
|
+
options,
|
|
248
|
+
error,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
setStatus({
|
|
252
|
+
status: 'loading',
|
|
253
|
+
});
|
|
254
|
+
setRequiresEmailVerification(false);
|
|
255
|
+
await client.auth.resetPassword({
|
|
256
|
+
password: options.password,
|
|
257
|
+
token: options.state,
|
|
258
|
+
});
|
|
259
|
+
setStatus({
|
|
260
|
+
status: 'success',
|
|
261
|
+
});
|
|
262
|
+
setRequiresEmailVerification(true);
|
|
263
|
+
return onSuccess({
|
|
264
|
+
data: { requiresEmailVerification: true },
|
|
265
|
+
hookOptions,
|
|
266
|
+
options,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
const error = new OpenfortError('Failed to reset password', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
271
|
+
error: e,
|
|
272
|
+
});
|
|
273
|
+
setStatus({
|
|
274
|
+
status: 'error',
|
|
275
|
+
error,
|
|
276
|
+
});
|
|
277
|
+
return onError({
|
|
278
|
+
hookOptions,
|
|
279
|
+
options,
|
|
280
|
+
error,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
284
|
+
const signUpEmail = useCallback(async (options) => {
|
|
285
|
+
var _a, _b, _c;
|
|
286
|
+
try {
|
|
287
|
+
if (!options.email || !options.password) {
|
|
288
|
+
const error = new OpenfortError('Email and password are required', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
289
|
+
setStatus({
|
|
290
|
+
status: 'error',
|
|
291
|
+
error,
|
|
292
|
+
});
|
|
293
|
+
return onError({
|
|
294
|
+
hookOptions,
|
|
295
|
+
options,
|
|
296
|
+
error,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
if (!isValidEmail(options.email)) {
|
|
300
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
301
|
+
setStatus({
|
|
302
|
+
status: 'error',
|
|
303
|
+
error,
|
|
304
|
+
});
|
|
305
|
+
return onError({
|
|
306
|
+
hookOptions,
|
|
307
|
+
options,
|
|
308
|
+
error,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
setStatus({
|
|
312
|
+
status: 'loading',
|
|
313
|
+
});
|
|
314
|
+
setRequiresEmailVerification(false);
|
|
315
|
+
const result = await client.auth.signUpWithEmailPassword({
|
|
316
|
+
email: options.email,
|
|
317
|
+
password: options.password,
|
|
318
|
+
callbackURL: buildCallbackUrl({
|
|
319
|
+
email: options.email,
|
|
320
|
+
callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
|
|
321
|
+
provider: 'email',
|
|
322
|
+
isOpen,
|
|
323
|
+
}),
|
|
324
|
+
...(options.name && { name: options.name }),
|
|
325
|
+
});
|
|
326
|
+
// API returns token when auth succeeds immediately; otherwise requires email verification
|
|
327
|
+
if ('token' in result && result.token != null) {
|
|
328
|
+
const { wallet } = await tryUseWallet({
|
|
329
|
+
logoutOnError: (_b = options.logoutOnError) !== null && _b !== void 0 ? _b : hookOptions.logoutOnError,
|
|
330
|
+
recoverWalletAutomatically: (_c = options.recoverWalletAutomatically) !== null && _c !== void 0 ? _c : hookOptions.recoverWalletAutomatically,
|
|
331
|
+
});
|
|
332
|
+
setStatus({
|
|
333
|
+
status: 'success',
|
|
334
|
+
});
|
|
335
|
+
const user = result.user;
|
|
336
|
+
await updateUser(user);
|
|
337
|
+
return onSuccess({
|
|
338
|
+
data: { user, wallet },
|
|
339
|
+
hookOptions,
|
|
340
|
+
options,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
setStatus({
|
|
345
|
+
status: 'awaiting-input',
|
|
346
|
+
});
|
|
347
|
+
setRequiresEmailVerification(true);
|
|
348
|
+
return onSuccess({
|
|
349
|
+
data: { requiresEmailVerification: true },
|
|
350
|
+
hookOptions,
|
|
351
|
+
options,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch (e) {
|
|
356
|
+
const error = new OpenfortError('Failed to login with email and password', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
357
|
+
error: e,
|
|
358
|
+
});
|
|
359
|
+
setStatus({
|
|
360
|
+
status: 'error',
|
|
361
|
+
error,
|
|
362
|
+
});
|
|
363
|
+
return onError({
|
|
364
|
+
hookOptions,
|
|
365
|
+
options,
|
|
366
|
+
error,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}, [client, setStatus, updateUser, hookOptions, isOpen]);
|
|
370
|
+
const linkEmail = useCallback(async (options) => {
|
|
371
|
+
var _a;
|
|
372
|
+
try {
|
|
373
|
+
if (!isValidEmail(options.email)) {
|
|
374
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
375
|
+
setStatus({
|
|
376
|
+
status: 'error',
|
|
377
|
+
error,
|
|
378
|
+
});
|
|
379
|
+
return onError({
|
|
380
|
+
hookOptions,
|
|
381
|
+
options,
|
|
382
|
+
error,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
await client.validateAndRefreshToken();
|
|
386
|
+
const authToken = await client.getAccessToken();
|
|
387
|
+
if (!authToken) {
|
|
388
|
+
logger.log('No token found');
|
|
389
|
+
const error = new OpenfortError('No token found', OpenfortReactErrorType.AUTHENTICATION_ERROR);
|
|
390
|
+
setStatus({
|
|
391
|
+
status: 'error',
|
|
392
|
+
error,
|
|
393
|
+
});
|
|
394
|
+
return onError({
|
|
395
|
+
hookOptions,
|
|
396
|
+
options,
|
|
397
|
+
error,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
await client.auth.addEmail({
|
|
401
|
+
// name: options.name || '',
|
|
402
|
+
email: options.email,
|
|
403
|
+
// password: options.password,
|
|
404
|
+
// method: 'password',
|
|
405
|
+
callbackURL: buildCallbackUrl({
|
|
406
|
+
callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
|
|
407
|
+
email: options.email,
|
|
408
|
+
provider: 'email',
|
|
409
|
+
isOpen,
|
|
410
|
+
}),
|
|
411
|
+
});
|
|
412
|
+
logger.log('Email linked successfully');
|
|
413
|
+
return onSuccess({
|
|
414
|
+
data: {},
|
|
415
|
+
hookOptions,
|
|
416
|
+
options,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
catch (e) {
|
|
420
|
+
const error = new OpenfortError('Failed to link email', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
421
|
+
error: e,
|
|
422
|
+
});
|
|
423
|
+
setStatus({
|
|
424
|
+
status: 'error',
|
|
425
|
+
error,
|
|
426
|
+
});
|
|
427
|
+
return onError({
|
|
428
|
+
hookOptions,
|
|
429
|
+
options,
|
|
430
|
+
error,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}, [client, setStatus, updateUser, hookOptions, isOpen]);
|
|
434
|
+
const verifyEmail = useCallback(async (options) => {
|
|
435
|
+
setStatus({
|
|
436
|
+
status: 'loading',
|
|
437
|
+
});
|
|
438
|
+
try {
|
|
439
|
+
if (!isValidEmail(options.email)) {
|
|
440
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
441
|
+
setStatus({
|
|
442
|
+
status: 'error',
|
|
443
|
+
error,
|
|
444
|
+
});
|
|
445
|
+
return onError({
|
|
446
|
+
hookOptions,
|
|
447
|
+
options,
|
|
448
|
+
error,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
await client.auth.verifyEmail({
|
|
452
|
+
token: options.state,
|
|
453
|
+
});
|
|
454
|
+
setStatus({
|
|
455
|
+
status: 'success',
|
|
456
|
+
});
|
|
457
|
+
return onSuccess({
|
|
458
|
+
hookOptions,
|
|
459
|
+
options,
|
|
460
|
+
data: {
|
|
461
|
+
email: options.email,
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
catch (e) {
|
|
466
|
+
const error = new OpenfortError('Failed to verify email', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
467
|
+
error: e,
|
|
468
|
+
});
|
|
469
|
+
setStatus({
|
|
470
|
+
status: 'error',
|
|
471
|
+
error,
|
|
472
|
+
});
|
|
473
|
+
logger.error('Error verifying email', e);
|
|
474
|
+
return onError({
|
|
475
|
+
hookOptions,
|
|
476
|
+
options,
|
|
477
|
+
error,
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}, [client, hookOptions]);
|
|
481
|
+
return {
|
|
482
|
+
signInEmail,
|
|
483
|
+
signUpEmail,
|
|
484
|
+
verifyEmail,
|
|
485
|
+
linkEmail,
|
|
486
|
+
requestResetPassword,
|
|
487
|
+
resetPassword,
|
|
488
|
+
reset,
|
|
489
|
+
...mapStatus(status),
|
|
490
|
+
requiresEmailVerification,
|
|
491
|
+
isAwaitingInput: status.status === 'awaiting-input',
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
export { useEmailAuth };
|
|
496
|
+
//# sourceMappingURL=useEmailAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEmailAuth.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { User } from '@openfort/openfort-js';
|
|
2
|
-
import { OpenfortError
|
|
3
|
-
import type {
|
|
2
|
+
import { OpenfortError } from '../../../core/errors';
|
|
3
|
+
import type { OpenfortHookOptions } from '../../../types';
|
|
4
|
+
import type { EthereumUserWallet, SolanaUserWallet } from '../walletTypes';
|
|
4
5
|
import { type CreateWalletPostAuthOptions } from './useConnectToWalletPostAuth';
|
|
5
6
|
type EmailOtpAuthResult = {
|
|
6
7
|
error?: OpenfortError;
|
|
7
8
|
user?: User;
|
|
8
|
-
wallet?:
|
|
9
|
+
wallet?: EthereumUserWallet | SolanaUserWallet;
|
|
9
10
|
};
|
|
10
11
|
type LoginWithEmailOtpOptions = {
|
|
11
12
|
email: string;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../../types.js';
|
|
3
|
+
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
4
|
+
import { isValidEmail } from '../../../utils/validation.js';
|
|
5
|
+
import { onError, onSuccess } from '../hookConsistency.js';
|
|
6
|
+
import { mapStatus } from './status.js';
|
|
7
|
+
import { useConnectToWalletPostAuth } from './useConnectToWalletPostAuth.js';
|
|
8
|
+
|
|
9
|
+
const useEmailOtpAuth = (hookOptions = {}) => {
|
|
10
|
+
const { client, updateUser } = useOpenfortCore();
|
|
11
|
+
const [status, setStatus] = useState({
|
|
12
|
+
status: 'idle',
|
|
13
|
+
});
|
|
14
|
+
const reset = useCallback(() => {
|
|
15
|
+
setStatus({
|
|
16
|
+
status: 'idle',
|
|
17
|
+
});
|
|
18
|
+
}, []);
|
|
19
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
20
|
+
const signInEmailOtp = useCallback(async (options) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
try {
|
|
23
|
+
setStatus({
|
|
24
|
+
status: 'loading',
|
|
25
|
+
});
|
|
26
|
+
if (!options.email || !options.otp) {
|
|
27
|
+
const error = new OpenfortError('Email and OTP are required', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
28
|
+
setStatus({
|
|
29
|
+
status: 'error',
|
|
30
|
+
error,
|
|
31
|
+
});
|
|
32
|
+
return onError({
|
|
33
|
+
hookOptions,
|
|
34
|
+
options,
|
|
35
|
+
error,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (!isValidEmail(options.email)) {
|
|
39
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
40
|
+
setStatus({
|
|
41
|
+
status: 'error',
|
|
42
|
+
error,
|
|
43
|
+
});
|
|
44
|
+
return onError({
|
|
45
|
+
hookOptions,
|
|
46
|
+
options,
|
|
47
|
+
error,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const result = await client.auth.logInWithEmailOtp({
|
|
51
|
+
email: options.email,
|
|
52
|
+
otp: options.otp,
|
|
53
|
+
});
|
|
54
|
+
const { wallet } = await tryUseWallet({
|
|
55
|
+
logoutOnError: (_a = options.logoutOnError) !== null && _a !== void 0 ? _a : hookOptions.logoutOnError,
|
|
56
|
+
recoverWalletAutomatically: (_b = options.recoverWalletAutomatically) !== null && _b !== void 0 ? _b : hookOptions.recoverWalletAutomatically,
|
|
57
|
+
});
|
|
58
|
+
setStatus({
|
|
59
|
+
status: 'success',
|
|
60
|
+
});
|
|
61
|
+
const user = result.user;
|
|
62
|
+
await updateUser();
|
|
63
|
+
return onSuccess({
|
|
64
|
+
data: { user, wallet },
|
|
65
|
+
hookOptions,
|
|
66
|
+
options,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
const error = new OpenfortError('Failed to login with email OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
71
|
+
error: e,
|
|
72
|
+
});
|
|
73
|
+
setStatus({
|
|
74
|
+
status: 'error',
|
|
75
|
+
error,
|
|
76
|
+
});
|
|
77
|
+
return onError({
|
|
78
|
+
hookOptions,
|
|
79
|
+
options,
|
|
80
|
+
error,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
84
|
+
const requestEmailOtp = useCallback(async (options) => {
|
|
85
|
+
try {
|
|
86
|
+
setStatus({
|
|
87
|
+
status: 'requesting',
|
|
88
|
+
});
|
|
89
|
+
if (!options.email) {
|
|
90
|
+
const error = new OpenfortError('Email is required', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
91
|
+
setStatus({
|
|
92
|
+
status: 'error',
|
|
93
|
+
error,
|
|
94
|
+
});
|
|
95
|
+
return onError({
|
|
96
|
+
hookOptions,
|
|
97
|
+
options,
|
|
98
|
+
error,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (!isValidEmail(options.email)) {
|
|
102
|
+
const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
103
|
+
setStatus({
|
|
104
|
+
status: 'error',
|
|
105
|
+
error,
|
|
106
|
+
});
|
|
107
|
+
return onError({
|
|
108
|
+
hookOptions,
|
|
109
|
+
options,
|
|
110
|
+
error,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
await client.auth.requestEmailOtp({
|
|
114
|
+
email: options.email,
|
|
115
|
+
});
|
|
116
|
+
setStatus({
|
|
117
|
+
status: 'success',
|
|
118
|
+
});
|
|
119
|
+
return onSuccess({
|
|
120
|
+
data: {},
|
|
121
|
+
hookOptions,
|
|
122
|
+
options,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
const error = new OpenfortError('Failed to request email OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
127
|
+
error: e,
|
|
128
|
+
});
|
|
129
|
+
setStatus({
|
|
130
|
+
status: 'error',
|
|
131
|
+
error,
|
|
132
|
+
});
|
|
133
|
+
return onError({
|
|
134
|
+
hookOptions,
|
|
135
|
+
options,
|
|
136
|
+
error,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
140
|
+
return {
|
|
141
|
+
signInEmailOtp,
|
|
142
|
+
requestEmailOtp,
|
|
143
|
+
reset,
|
|
144
|
+
isRequesting: status.status === 'requesting',
|
|
145
|
+
...mapStatus(status),
|
|
146
|
+
isAwaitingInput: status.status === 'awaiting-input',
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export { useEmailOtpAuth };
|
|
151
|
+
//# sourceMappingURL=useEmailOtpAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEmailOtpAuth.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { User } from '@openfort/openfort-js';
|
|
2
|
-
import { OpenfortError
|
|
3
|
-
import type {
|
|
2
|
+
import { OpenfortError } from '../../../core/errors';
|
|
3
|
+
import type { OpenfortHookOptions } from '../../../types';
|
|
4
|
+
import type { EthereumUserWallet, SolanaUserWallet } from '../walletTypes';
|
|
4
5
|
import { type CreateWalletPostAuthOptions } from './useConnectToWalletPostAuth';
|
|
5
6
|
type GuestHookResult = {
|
|
6
7
|
error?: OpenfortError;
|
|
7
8
|
user?: User;
|
|
8
|
-
wallet?:
|
|
9
|
+
wallet?: EthereumUserWallet | SolanaUserWallet;
|
|
9
10
|
};
|
|
10
11
|
type GuestHookOptions = OpenfortHookOptions<GuestHookResult> & CreateWalletPostAuthOptions;
|
|
11
12
|
/**
|