@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,142 @@
|
|
|
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 { onSuccess, onError } from '../hookConsistency.js';
|
|
6
|
+
import { mapStatus } from './status.js';
|
|
7
|
+
import { useConnectToWalletPostAuth } from './useConnectToWalletPostAuth.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Hook for guest authentication operations
|
|
11
|
+
*
|
|
12
|
+
* This hook manages guest user authentication, allowing users to create temporary
|
|
13
|
+
* accounts without providing email or other credentials. Guest authentication provides
|
|
14
|
+
* a quick way for users to get started with the application before committing to
|
|
15
|
+
* full registration. After authentication, it automatically handles wallet connection.
|
|
16
|
+
*
|
|
17
|
+
* @param hookOptions - Optional configuration with callback functions and authentication options
|
|
18
|
+
* @returns Current guest authentication state and actions
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const guestAuth = useGuestAuth({
|
|
23
|
+
* onSignUpGuestSuccess: (result) => console.log('Guest user created:', result.user),
|
|
24
|
+
* onSignUpGuestError: (error) => console.error('Guest signup failed:', error),
|
|
25
|
+
* recoverWalletAutomatically: true,
|
|
26
|
+
* logoutOnError: false,
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Sign up as guest user
|
|
30
|
+
* const handleGuestSignup = async () => {
|
|
31
|
+
* try {
|
|
32
|
+
* const result = await guestAuth.signUpGuest();
|
|
33
|
+
* if (result.user) {
|
|
34
|
+
* console.log('Guest user created:', result.user.id);
|
|
35
|
+
* console.log('User wallet:', result.wallet);
|
|
36
|
+
* }
|
|
37
|
+
* } catch (error) {
|
|
38
|
+
* console.error('Guest signup failed:', error);
|
|
39
|
+
* }
|
|
40
|
+
* };
|
|
41
|
+
*
|
|
42
|
+
* // Check authentication state
|
|
43
|
+
* if (guestAuth.isLoading) {
|
|
44
|
+
* console.log('Creating guest account...');
|
|
45
|
+
* } else if (guestAuth.isError) {
|
|
46
|
+
* console.error('Guest auth error:', guestAuth.error);
|
|
47
|
+
* } else if (guestAuth.isSuccess) {
|
|
48
|
+
* console.log('Guest authentication successful');
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* // Example usage in component
|
|
52
|
+
* return (
|
|
53
|
+
* <div>
|
|
54
|
+
* <button
|
|
55
|
+
* onClick={handleGuestSignup}
|
|
56
|
+
* disabled={guestAuth.isLoading}
|
|
57
|
+
* >
|
|
58
|
+
* {guestAuth.isLoading ? 'Creating Guest Account...' : 'Continue as Guest'}
|
|
59
|
+
* </button>
|
|
60
|
+
*
|
|
61
|
+
* {guestAuth.isError && (
|
|
62
|
+
* <p>Error: {guestAuth.error?.message}</p>
|
|
63
|
+
* )}
|
|
64
|
+
* </div>
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
const useGuestAuth = (hookOptions = {}) => {
|
|
69
|
+
const { client, updateUser, updateEmbeddedAccounts } = useOpenfortCore();
|
|
70
|
+
const [status, setStatus] = useState({
|
|
71
|
+
status: 'idle',
|
|
72
|
+
});
|
|
73
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
74
|
+
const signUpGuest = useCallback(async (options = {}) => {
|
|
75
|
+
var _a, _b, _c, _d;
|
|
76
|
+
try {
|
|
77
|
+
setStatus({
|
|
78
|
+
status: 'loading',
|
|
79
|
+
});
|
|
80
|
+
let user;
|
|
81
|
+
try {
|
|
82
|
+
logger.log('Guest signup: calling auth.signUpGuest()');
|
|
83
|
+
const result = await client.auth.signUpGuest();
|
|
84
|
+
user = result.user;
|
|
85
|
+
logger.log('Guest signup: auth OK, user id:', user === null || user === void 0 ? void 0 : user.id);
|
|
86
|
+
}
|
|
87
|
+
catch (authError) {
|
|
88
|
+
const isAlreadyLoggedIn = ((_a = authError === null || authError === void 0 ? void 0 : authError.message) === null || _a === void 0 ? void 0 : _a.includes('Already logged in')) ||
|
|
89
|
+
(authError === null || authError === void 0 ? void 0 : authError.name) === 'SessionError';
|
|
90
|
+
if (isAlreadyLoggedIn) {
|
|
91
|
+
logger.log('Guest signup: already logged in, using existing session');
|
|
92
|
+
user = (_b = (await client.user.get())) !== null && _b !== void 0 ? _b : undefined;
|
|
93
|
+
if (!user)
|
|
94
|
+
throw authError;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
throw authError;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
await updateUser(user);
|
|
101
|
+
logger.log('Guest signup: calling tryUseWallet()');
|
|
102
|
+
const { wallet } = await tryUseWallet({
|
|
103
|
+
logoutOnError: (_c = options.logoutOnError) !== null && _c !== void 0 ? _c : hookOptions.logoutOnError,
|
|
104
|
+
recoverWalletAutomatically: (_d = options.recoverWalletAutomatically) !== null && _d !== void 0 ? _d : hookOptions.recoverWalletAutomatically,
|
|
105
|
+
});
|
|
106
|
+
if (wallet && typeof updateEmbeddedAccounts === 'function') {
|
|
107
|
+
await updateEmbeddedAccounts();
|
|
108
|
+
}
|
|
109
|
+
setStatus({
|
|
110
|
+
status: 'success',
|
|
111
|
+
});
|
|
112
|
+
logger.log('Guest signup: success', wallet ? '(wallet created)' : '(no wallet)');
|
|
113
|
+
return onSuccess({
|
|
114
|
+
hookOptions,
|
|
115
|
+
options,
|
|
116
|
+
data: { user, wallet },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
logger.error('Guest signup failed:', error);
|
|
121
|
+
const openfortError = new OpenfortError('Failed to signup guest', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
122
|
+
error,
|
|
123
|
+
});
|
|
124
|
+
setStatus({
|
|
125
|
+
status: 'error',
|
|
126
|
+
error: openfortError,
|
|
127
|
+
});
|
|
128
|
+
return onError({
|
|
129
|
+
hookOptions,
|
|
130
|
+
options,
|
|
131
|
+
error: openfortError,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}, [client, setStatus, updateUser, updateEmbeddedAccounts, tryUseWallet, hookOptions]);
|
|
135
|
+
return {
|
|
136
|
+
signUpGuest,
|
|
137
|
+
...mapStatus(status),
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export { useGuestAuth };
|
|
142
|
+
//# sourceMappingURL=useGuestAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuestAuth.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OAuthProvider, 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 InitializeOAuthOptions = {
|
|
6
7
|
provider: OAuthProvider;
|
|
@@ -11,7 +12,7 @@ type InitOAuthReturnType = {
|
|
|
11
12
|
};
|
|
12
13
|
export type StoreCredentialsResult = {
|
|
13
14
|
user?: User;
|
|
14
|
-
wallet?:
|
|
15
|
+
wallet?: EthereumUserWallet | SolanaUserWallet;
|
|
15
16
|
error?: OpenfortError;
|
|
16
17
|
};
|
|
17
18
|
type StoreCredentialsOptions = {
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../../types.js';
|
|
3
|
+
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
4
|
+
import { onSuccess, onError } from '../hookConsistency.js';
|
|
5
|
+
import { useUI } from '../useUI.js';
|
|
6
|
+
import { buildCallbackUrl } from './requestEmailVerification.js';
|
|
7
|
+
import { mapStatus } from './status.js';
|
|
8
|
+
import { useConnectToWalletPostAuth } from './useConnectToWalletPostAuth.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook for OAuth-based authentication operations
|
|
12
|
+
*
|
|
13
|
+
* This hook manages OAuth authentication flows including provider initialization,
|
|
14
|
+
* credential storage, and wallet connection after successful OAuth authentication.
|
|
15
|
+
* It supports multiple OAuth providers and handles the complete authentication lifecycle
|
|
16
|
+
* from provider selection to wallet setup.
|
|
17
|
+
*
|
|
18
|
+
* @param hookOptions - Optional configuration with callback functions and authentication options
|
|
19
|
+
* @returns Current OAuth authentication state and actions
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const oauth = useOAuth({
|
|
24
|
+
* onInitializeOAuthSuccess: (result) => console.log('OAuth initialized'),
|
|
25
|
+
* onInitializeOAuthError: (error) => console.error('OAuth init failed:', error),
|
|
26
|
+
* onStoreCredentialsSuccess: (result) => console.log('Authenticated:', result.user),
|
|
27
|
+
* redirectTo: 'https://yourapp.com/auth/callback',
|
|
28
|
+
* recoverWalletAutomatically: true,
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Initialize OAuth with a provider
|
|
32
|
+
* const handleGoogleAuth = async () => {
|
|
33
|
+
* await oauth.initOAuth({
|
|
34
|
+
* provider: OAuthProvider.GOOGLE,
|
|
35
|
+
* redirectTo: 'https://yourapp.com/auth/callback',
|
|
36
|
+
* });
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* const handleDiscordAuth = async () => {
|
|
40
|
+
* await oauth.initOAuth({
|
|
41
|
+
* provider: OAuthProvider.DISCORD,
|
|
42
|
+
* });
|
|
43
|
+
* };
|
|
44
|
+
*
|
|
45
|
+
* // Store OAuth credentials (typically called from callback handler)
|
|
46
|
+
* const handleStoreCredentials = async () => {
|
|
47
|
+
* await oauth.storeCredentials({
|
|
48
|
+
* player: 'player-id-from-callback',
|
|
49
|
+
* accessToken: 'access-token-from-callback',
|
|
50
|
+
* refreshToken: 'refresh-token-from-callback',
|
|
51
|
+
* });
|
|
52
|
+
* };
|
|
53
|
+
*
|
|
54
|
+
* // Link OAuth provider to existing authenticated account
|
|
55
|
+
* const handleLinkOAuth = async () => {
|
|
56
|
+
* await oauth.linkOauth({
|
|
57
|
+
* provider: OAuthProvider.GOOGLE,
|
|
58
|
+
* redirectTo: 'https://yourapp.com/auth/callback',
|
|
59
|
+
* });
|
|
60
|
+
* };
|
|
61
|
+
*
|
|
62
|
+
* // Check authentication state
|
|
63
|
+
* if (oauth.isLoading) {
|
|
64
|
+
* console.log('Processing OAuth authentication...');
|
|
65
|
+
* } else if (oauth.isError) {
|
|
66
|
+
* console.error('OAuth error:', oauth.error);
|
|
67
|
+
* } else if (oauth.isSuccess) {
|
|
68
|
+
* console.log('OAuth authentication successful');
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* // Example usage in component with multiple providers
|
|
72
|
+
* return (
|
|
73
|
+
* <div>
|
|
74
|
+
* <button onClick={handleGoogleAuth} disabled={oauth.isLoading}>
|
|
75
|
+
* Sign in with Google
|
|
76
|
+
* </button>
|
|
77
|
+
* <button onClick={handleDiscordAuth} disabled={oauth.isLoading}>
|
|
78
|
+
* Sign in with Discord
|
|
79
|
+
* </button>
|
|
80
|
+
* </div>
|
|
81
|
+
* );
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
const useOAuth = (hookOptions = {}) => {
|
|
85
|
+
const { client, updateUser } = useOpenfortCore();
|
|
86
|
+
const [status, setStatus] = useState({
|
|
87
|
+
status: 'idle',
|
|
88
|
+
});
|
|
89
|
+
const { isOpen } = useUI();
|
|
90
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
91
|
+
const storeCredentials = useCallback(async ({ userId, token, ...options }) => {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
setStatus({
|
|
94
|
+
status: 'loading',
|
|
95
|
+
});
|
|
96
|
+
try {
|
|
97
|
+
await client.auth.storeCredentials({
|
|
98
|
+
userId,
|
|
99
|
+
token,
|
|
100
|
+
});
|
|
101
|
+
setStatus({
|
|
102
|
+
status: 'success',
|
|
103
|
+
});
|
|
104
|
+
const user = (await updateUser()) || undefined;
|
|
105
|
+
const { wallet } = await tryUseWallet({
|
|
106
|
+
logoutOnError: (_a = options.logoutOnError) !== null && _a !== void 0 ? _a : hookOptions.logoutOnError,
|
|
107
|
+
recoverWalletAutomatically: (_b = options.recoverWalletAutomatically) !== null && _b !== void 0 ? _b : hookOptions.recoverWalletAutomatically,
|
|
108
|
+
});
|
|
109
|
+
return onSuccess({
|
|
110
|
+
data: { user, wallet, type: 'storeCredentials' },
|
|
111
|
+
hookOptions,
|
|
112
|
+
options,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
const error = new OpenfortError('Failed to store credentials', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
117
|
+
error: e,
|
|
118
|
+
});
|
|
119
|
+
setStatus({
|
|
120
|
+
status: 'error',
|
|
121
|
+
error,
|
|
122
|
+
});
|
|
123
|
+
return onError({
|
|
124
|
+
hookOptions,
|
|
125
|
+
options,
|
|
126
|
+
error,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}, [client, hookOptions]);
|
|
130
|
+
const initOAuth = useCallback(async (options) => {
|
|
131
|
+
var _a;
|
|
132
|
+
const authProvider = options.provider;
|
|
133
|
+
try {
|
|
134
|
+
setStatus({
|
|
135
|
+
status: 'loading',
|
|
136
|
+
});
|
|
137
|
+
const redirectUrl = await client.auth.initOAuth({
|
|
138
|
+
provider: authProvider,
|
|
139
|
+
redirectTo: buildCallbackUrl({
|
|
140
|
+
provider: authProvider,
|
|
141
|
+
callbackUrl: (_a = hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.redirectTo) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.redirectTo,
|
|
142
|
+
isOpen,
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
window.location.href = redirectUrl;
|
|
146
|
+
return onSuccess({
|
|
147
|
+
data: {},
|
|
148
|
+
hookOptions,
|
|
149
|
+
options,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
const error = new OpenfortError('Failed to login with OAuth', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
154
|
+
error: e,
|
|
155
|
+
});
|
|
156
|
+
setStatus({
|
|
157
|
+
status: 'error',
|
|
158
|
+
error,
|
|
159
|
+
});
|
|
160
|
+
return onError({
|
|
161
|
+
hookOptions,
|
|
162
|
+
options,
|
|
163
|
+
error,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}, [client, setStatus, updateUser, hookOptions, isOpen]);
|
|
167
|
+
const linkOauth = useCallback(async (options) => {
|
|
168
|
+
var _a;
|
|
169
|
+
const authProvider = options.provider;
|
|
170
|
+
try {
|
|
171
|
+
setStatus({
|
|
172
|
+
status: 'loading',
|
|
173
|
+
});
|
|
174
|
+
const authToken = await client.getAccessToken();
|
|
175
|
+
if (!authToken) {
|
|
176
|
+
throw new OpenfortError('No auth token found', OpenfortReactErrorType.AUTHENTICATION_ERROR);
|
|
177
|
+
}
|
|
178
|
+
const redirectUrl = await client.auth.initLinkOAuth({
|
|
179
|
+
provider: authProvider,
|
|
180
|
+
redirectTo: buildCallbackUrl({
|
|
181
|
+
provider: authProvider,
|
|
182
|
+
callbackUrl: (_a = options === null || options === void 0 ? void 0 : options.redirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.redirectTo,
|
|
183
|
+
isOpen,
|
|
184
|
+
}),
|
|
185
|
+
});
|
|
186
|
+
window.location.href = redirectUrl;
|
|
187
|
+
return onSuccess({
|
|
188
|
+
data: {},
|
|
189
|
+
hookOptions,
|
|
190
|
+
options,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
const error = new OpenfortError('Failed to link OAuth', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
195
|
+
error: e,
|
|
196
|
+
});
|
|
197
|
+
setStatus({
|
|
198
|
+
status: 'error',
|
|
199
|
+
error,
|
|
200
|
+
});
|
|
201
|
+
return onError({
|
|
202
|
+
hookOptions,
|
|
203
|
+
options,
|
|
204
|
+
error,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}, [client, setStatus, updateUser, hookOptions, isOpen]);
|
|
208
|
+
return {
|
|
209
|
+
initOAuth,
|
|
210
|
+
linkOauth,
|
|
211
|
+
storeCredentials,
|
|
212
|
+
...mapStatus(status),
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export { useOAuth };
|
|
217
|
+
//# sourceMappingURL=useOAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOAuth.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 PhoneAuthResult = {
|
|
6
7
|
error?: OpenfortError;
|
|
7
8
|
user?: User;
|
|
8
|
-
wallet?:
|
|
9
|
+
wallet?: EthereumUserWallet | SolanaUserWallet;
|
|
9
10
|
};
|
|
10
11
|
type LoginWithPhoneOtpOptions = {
|
|
11
12
|
phoneNumber: string;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../../types.js';
|
|
3
|
+
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
4
|
+
import { onError, onSuccess } from '../hookConsistency.js';
|
|
5
|
+
import { mapStatus } from './status.js';
|
|
6
|
+
import { useConnectToWalletPostAuth } from './useConnectToWalletPostAuth.js';
|
|
7
|
+
|
|
8
|
+
const usePhoneOtpAuth = (hookOptions = {}) => {
|
|
9
|
+
const { client, updateUser } = useOpenfortCore();
|
|
10
|
+
const [status, setStatus] = useState({
|
|
11
|
+
status: 'idle',
|
|
12
|
+
});
|
|
13
|
+
const reset = useCallback(() => {
|
|
14
|
+
setStatus({
|
|
15
|
+
status: 'idle',
|
|
16
|
+
});
|
|
17
|
+
}, []);
|
|
18
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
19
|
+
const logInWithPhoneOtp = useCallback(async (options) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
try {
|
|
22
|
+
setStatus({
|
|
23
|
+
status: 'loading',
|
|
24
|
+
});
|
|
25
|
+
if (!options.phoneNumber || !options.otp) {
|
|
26
|
+
const error = new OpenfortError('Phone and OTP are required', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
27
|
+
setStatus({
|
|
28
|
+
status: 'error',
|
|
29
|
+
error,
|
|
30
|
+
});
|
|
31
|
+
return onError({
|
|
32
|
+
hookOptions,
|
|
33
|
+
options,
|
|
34
|
+
error,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const result = await client.auth.logInWithPhoneOtp({
|
|
38
|
+
phoneNumber: options.phoneNumber,
|
|
39
|
+
otp: options.otp,
|
|
40
|
+
});
|
|
41
|
+
const { wallet } = await tryUseWallet({
|
|
42
|
+
logoutOnError: (_a = options.logoutOnError) !== null && _a !== void 0 ? _a : hookOptions.logoutOnError,
|
|
43
|
+
recoverWalletAutomatically: (_b = options.recoverWalletAutomatically) !== null && _b !== void 0 ? _b : hookOptions.recoverWalletAutomatically,
|
|
44
|
+
});
|
|
45
|
+
setStatus({
|
|
46
|
+
status: 'success',
|
|
47
|
+
});
|
|
48
|
+
const user = result.user;
|
|
49
|
+
await updateUser();
|
|
50
|
+
return onSuccess({
|
|
51
|
+
data: { user, wallet },
|
|
52
|
+
hookOptions,
|
|
53
|
+
options,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
const error = new OpenfortError('Failed to login with phone OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
58
|
+
error: e,
|
|
59
|
+
});
|
|
60
|
+
setStatus({
|
|
61
|
+
status: 'error',
|
|
62
|
+
error,
|
|
63
|
+
});
|
|
64
|
+
return onError({
|
|
65
|
+
hookOptions,
|
|
66
|
+
options,
|
|
67
|
+
error,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
71
|
+
const requestPhoneOtp = useCallback(async (options) => {
|
|
72
|
+
try {
|
|
73
|
+
setStatus({
|
|
74
|
+
status: 'requesting',
|
|
75
|
+
});
|
|
76
|
+
if (!options.phoneNumber) {
|
|
77
|
+
const error = new OpenfortError('Phone number is required', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
78
|
+
setStatus({
|
|
79
|
+
status: 'error',
|
|
80
|
+
error,
|
|
81
|
+
});
|
|
82
|
+
return onError({
|
|
83
|
+
hookOptions,
|
|
84
|
+
options,
|
|
85
|
+
error,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
await client.auth.requestPhoneOtp({
|
|
89
|
+
phoneNumber: options.phoneNumber,
|
|
90
|
+
});
|
|
91
|
+
setStatus({
|
|
92
|
+
status: 'idle',
|
|
93
|
+
});
|
|
94
|
+
return onSuccess({
|
|
95
|
+
data: {},
|
|
96
|
+
hookOptions,
|
|
97
|
+
options,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
const error = new OpenfortError('Failed to request phone OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
102
|
+
error: e,
|
|
103
|
+
});
|
|
104
|
+
setStatus({
|
|
105
|
+
status: 'error',
|
|
106
|
+
error,
|
|
107
|
+
});
|
|
108
|
+
return onError({
|
|
109
|
+
hookOptions,
|
|
110
|
+
options,
|
|
111
|
+
error,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
115
|
+
const linkPhoneOtp = useCallback(async (options) => {
|
|
116
|
+
try {
|
|
117
|
+
setStatus({
|
|
118
|
+
status: 'loading',
|
|
119
|
+
});
|
|
120
|
+
if (!options.phoneNumber || !options.otp) {
|
|
121
|
+
const error = new OpenfortError('Phone and OTP are required', OpenfortReactErrorType.VALIDATION_ERROR);
|
|
122
|
+
setStatus({
|
|
123
|
+
status: 'error',
|
|
124
|
+
error,
|
|
125
|
+
});
|
|
126
|
+
return onError({
|
|
127
|
+
hookOptions,
|
|
128
|
+
options,
|
|
129
|
+
error,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const result = await client.auth.linkPhoneOtp({
|
|
133
|
+
phoneNumber: options.phoneNumber,
|
|
134
|
+
otp: options.otp,
|
|
135
|
+
});
|
|
136
|
+
setStatus({
|
|
137
|
+
status: 'success',
|
|
138
|
+
});
|
|
139
|
+
const user = result.user;
|
|
140
|
+
await updateUser();
|
|
141
|
+
return onSuccess({
|
|
142
|
+
data: { user },
|
|
143
|
+
hookOptions,
|
|
144
|
+
options,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
const error = new OpenfortError('Failed to link phone OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
|
|
149
|
+
error: e,
|
|
150
|
+
});
|
|
151
|
+
setStatus({
|
|
152
|
+
status: 'error',
|
|
153
|
+
error,
|
|
154
|
+
});
|
|
155
|
+
return onError({
|
|
156
|
+
hookOptions,
|
|
157
|
+
options,
|
|
158
|
+
error,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}, [client, setStatus, updateUser, hookOptions]);
|
|
162
|
+
return {
|
|
163
|
+
logInWithPhoneOtp,
|
|
164
|
+
requestPhoneOtp,
|
|
165
|
+
linkPhoneOtp,
|
|
166
|
+
reset,
|
|
167
|
+
isRequesting: status.status === 'requesting',
|
|
168
|
+
...mapStatus(status),
|
|
169
|
+
isAwaitingInput: status.status === 'awaiting-input',
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export { usePhoneOtpAuth };
|
|
174
|
+
//# sourceMappingURL=usePhoneOtpAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePhoneOtpAuth.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../../types.js';
|
|
3
|
+
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
4
|
+
import { onSuccess, onError } from '../hookConsistency.js';
|
|
5
|
+
import { mapStatus } from './status.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hook for user sign out operations
|
|
9
|
+
*
|
|
10
|
+
* This hook manages user logout functionality, clearing authentication state
|
|
11
|
+
* and disconnecting from all services. It provides a clean way to sign out users
|
|
12
|
+
* while handling any cleanup operations and providing loading/error states.
|
|
13
|
+
* The hook ensures complete logout by clearing all stored credentials and state.
|
|
14
|
+
*
|
|
15
|
+
* @param hookOptions - Optional configuration with callback functions
|
|
16
|
+
* @returns Current sign out state and actions
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const signOutHook = useSignOut({
|
|
21
|
+
* onSignOutSuccess: () => console.log('User signed out successfully'),
|
|
22
|
+
* onSignOutError: (error) => console.error('Sign out failed:', error),
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Sign out user
|
|
26
|
+
* const handleSignOut = async () => {
|
|
27
|
+
* try {
|
|
28
|
+
* await signOutHook.signOut();
|
|
29
|
+
* console.log('User has been signed out');
|
|
30
|
+
* // Redirect to login page or update UI
|
|
31
|
+
* } catch (error) {
|
|
32
|
+
* console.error('Sign out failed:', error);
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* // Sign out with custom options
|
|
37
|
+
* const handleCustomSignOut = async () => {
|
|
38
|
+
* await signOutHook.signOut({
|
|
39
|
+
* onSuccess: () => console.log('Custom success handler'),
|
|
40
|
+
* onError: (error) => console.error('Custom error handler:', error),
|
|
41
|
+
* });
|
|
42
|
+
* };
|
|
43
|
+
*
|
|
44
|
+
* // Check sign out state
|
|
45
|
+
* if (signOutHook.isLoading) {
|
|
46
|
+
* console.log('Signing out...');
|
|
47
|
+
* } else if (signOutHook.isError) {
|
|
48
|
+
* console.error('Sign out error:', signOutHook.error);
|
|
49
|
+
* } else if (signOutHook.isSuccess) {
|
|
50
|
+
* console.log('Sign out successful');
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* // Example usage in component
|
|
54
|
+
* return (
|
|
55
|
+
* <button
|
|
56
|
+
* onClick={handleSignOut}
|
|
57
|
+
* disabled={signOutHook.isLoading}
|
|
58
|
+
* >
|
|
59
|
+
* {signOutHook.isLoading ? 'Signing out...' : 'Sign Out'}
|
|
60
|
+
* </button>
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function useSignOut(hookOptions = {}) {
|
|
65
|
+
const { logout } = useOpenfortCore();
|
|
66
|
+
const [status, setStatus] = useState({
|
|
67
|
+
status: 'idle',
|
|
68
|
+
});
|
|
69
|
+
const signOut = useCallback(async (options = {}) => {
|
|
70
|
+
setStatus({
|
|
71
|
+
status: 'loading',
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
logout();
|
|
75
|
+
setStatus({
|
|
76
|
+
status: 'success',
|
|
77
|
+
});
|
|
78
|
+
return onSuccess({
|
|
79
|
+
hookOptions,
|
|
80
|
+
options,
|
|
81
|
+
data: {},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
const error = new OpenfortError('Failed to sign out', OpenfortReactErrorType.AUTHENTICATION_ERROR);
|
|
86
|
+
setStatus({
|
|
87
|
+
status: 'error',
|
|
88
|
+
error,
|
|
89
|
+
});
|
|
90
|
+
return onError({
|
|
91
|
+
hookOptions,
|
|
92
|
+
options,
|
|
93
|
+
error,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}, [logout, setStatus, hookOptions]);
|
|
97
|
+
return {
|
|
98
|
+
...mapStatus(status),
|
|
99
|
+
signOut,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { useSignOut };
|
|
104
|
+
//# sourceMappingURL=useSignOut.js.map
|