@n1xyz/wallet-widget 0.0.34 → 0.0.35-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge-assist/cctp-solana.d.ts +33 -0
- package/dist/bridge-assist/cctp-solana.js +392 -0
- package/dist/bridge-assist/cctp-solana.js.map +1 -0
- package/dist/main.css +1 -2
- package/dist/src/adapters/evm.d.ts +39 -0
- package/dist/src/adapters/evm.js +338 -0
- package/dist/src/adapters/evm.js.map +1 -0
- package/dist/src/adapters/factory.d.ts +37 -0
- package/dist/src/adapters/factory.js +82 -0
- package/dist/src/adapters/factory.js.map +1 -0
- package/dist/src/adapters/index.d.ts +33 -0
- package/dist/src/adapters/index.js +36 -0
- package/dist/src/adapters/index.js.map +1 -0
- package/dist/src/adapters/solana.d.ts +37 -0
- package/dist/src/adapters/solana.js +359 -0
- package/dist/src/adapters/solana.js.map +1 -0
- package/dist/src/adapters/types.d.ts +160 -0
- package/dist/src/adapters/types.js +20 -0
- package/dist/src/adapters/types.js.map +1 -0
- package/dist/src/animations/N1Loader.js.map +1 -0
- package/dist/src/animations/N1Loader.json +1 -0
- package/dist/src/animations/Processing.js.map +1 -0
- package/dist/src/animations/Processing.json +1 -0
- package/dist/{components → src/components}/LoadingFallback.d.ts +3 -0
- package/dist/{components → src/components}/LoadingFallback.js +3 -0
- package/dist/src/components/LoadingFallback.js.map +1 -0
- package/dist/{components → src/components}/Logo.d.ts +4 -0
- package/dist/{components → src/components}/Logo.js +4 -0
- package/dist/src/components/Logo.js.map +1 -0
- package/dist/src/components/N1ConnectButton.d.ts +13 -0
- package/dist/src/components/N1ConnectButton.js +66 -0
- package/dist/src/components/N1ConnectButton.js.map +1 -0
- package/dist/src/components/logos/ArbitrumLogo.js.map +1 -0
- package/dist/src/components/logos/BaseLogo.js +6 -0
- package/dist/src/components/logos/BaseLogo.js.map +1 -0
- package/dist/src/components/logos/BeraLogo.js.map +1 -0
- package/dist/src/components/logos/BitcoinLogo.js.map +1 -0
- package/dist/src/components/logos/EthereumLogo.js.map +1 -0
- package/dist/{components → src/components}/logos/HyperliquidLogo.js +1 -1
- package/dist/src/components/logos/HyperliquidLogo.js.map +1 -0
- package/dist/src/components/logos/OptimismLogo.js.map +1 -0
- package/dist/src/components/logos/SolanaLogo.js.map +1 -0
- package/dist/src/components/logos/ZeroOneLogo.js.map +1 -0
- package/dist/src/components/logos/index.js.map +1 -0
- package/dist/src/config/chains.d.ts +18 -0
- package/dist/src/config/chains.js +58 -0
- package/dist/src/config/chains.js.map +1 -0
- package/dist/src/config/dynamic.js +18 -0
- package/dist/src/config/dynamic.js.map +1 -0
- package/dist/src/config/solana.js.map +1 -0
- package/dist/src/config/turnkey.d.ts +2 -0
- package/dist/{config → src/config}/turnkey.js +9 -12
- package/dist/src/config/turnkey.js.map +1 -0
- package/dist/src/context/n1-wallet-context.js.map +1 -0
- package/dist/src/errors/types.d.ts +72 -0
- package/dist/src/errors/types.js +140 -0
- package/dist/src/errors/types.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/N1WalletModal.js +44 -29
- package/dist/src/features/onboarding-flow/N1WalletModal.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/OnboardingFlow.d.ts +2 -1
- package/dist/{features → src/features}/onboarding-flow/OnboardingFlow.js +54 -8
- package/dist/src/features/onboarding-flow/OnboardingFlow.js.map +1 -0
- package/dist/src/features/onboarding-flow/bridge-assist/client.d.ts +42 -0
- package/dist/src/features/onboarding-flow/bridge-assist/client.js +268 -0
- package/dist/src/features/onboarding-flow/bridge-assist/client.js.map +1 -0
- package/dist/src/features/onboarding-flow/bridge-assist/config.d.ts +4 -0
- package/dist/src/features/onboarding-flow/bridge-assist/config.js +11 -0
- package/dist/src/features/onboarding-flow/bridge-assist/config.js.map +1 -0
- package/dist/src/features/onboarding-flow/bridge-assist/index.d.ts +1 -0
- package/dist/src/features/onboarding-flow/bridge-assist/index.js +2 -0
- package/dist/src/features/onboarding-flow/bridge-assist/index.js.map +1 -0
- package/dist/src/features/onboarding-flow/bridge-assist/types.d.ts +5 -0
- package/dist/src/features/onboarding-flow/bridge-assist/types.js +28 -0
- package/dist/src/features/onboarding-flow/bridge-assist/types.js.map +1 -0
- package/dist/src/features/onboarding-flow/cctp/bridgeKitClient.d.ts +35 -0
- package/dist/src/features/onboarding-flow/cctp/bridgeKitClient.js +391 -0
- package/dist/src/features/onboarding-flow/cctp/bridgeKitClient.js.map +1 -0
- package/dist/src/features/onboarding-flow/cctp/clientFactory.d.ts +6 -0
- package/dist/src/features/onboarding-flow/cctp/clientFactory.js +9 -0
- package/dist/src/features/onboarding-flow/cctp/clientFactory.js.map +1 -0
- package/dist/src/features/onboarding-flow/cctp/config.d.ts +16 -0
- package/dist/src/features/onboarding-flow/cctp/config.js +55 -0
- package/dist/src/features/onboarding-flow/cctp/config.js.map +1 -0
- package/dist/src/features/onboarding-flow/cctp/mockCctpClient.d.ts +11 -0
- package/dist/src/features/onboarding-flow/cctp/mockCctpClient.js +85 -0
- package/dist/src/features/onboarding-flow/cctp/mockCctpClient.js.map +1 -0
- package/dist/src/features/onboarding-flow/cctp/solanaClaim.d.ts +1 -0
- package/dist/src/features/onboarding-flow/cctp/solanaClaim.js +2 -0
- package/dist/src/features/onboarding-flow/cctp/solanaClaim.js.map +1 -0
- package/dist/src/features/onboarding-flow/cctp/types.d.ts +50 -0
- package/dist/src/features/onboarding-flow/cctp/types.js +2 -0
- package/dist/src/features/onboarding-flow/cctp/types.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/components/ChainButton.d.ts +5 -2
- package/dist/src/features/onboarding-flow/components/ChainButton.js +14 -0
- package/dist/src/features/onboarding-flow/components/ChainButton.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/components/Header.d.ts +2 -2
- package/dist/src/features/onboarding-flow/components/Header.js +69 -0
- package/dist/src/features/onboarding-flow/components/Header.js.map +1 -0
- package/dist/src/features/onboarding-flow/components/ImageWithFallback.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/components/TransactionTable.d.ts +5 -0
- package/dist/{features → src/features}/onboarding-flow/components/TransactionTable.js +8 -3
- package/dist/src/features/onboarding-flow/components/TransactionTable.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/components/WaitingMessage.d.ts +4 -0
- package/dist/src/features/onboarding-flow/components/WaitingMessage.js.map +1 -0
- package/dist/src/features/onboarding-flow/components/index.js.map +1 -0
- package/dist/src/features/onboarding-flow/errors/depositError.d.ts +36 -0
- package/dist/src/features/onboarding-flow/errors/depositError.js +134 -0
- package/dist/src/features/onboarding-flow/errors/depositError.js.map +1 -0
- package/dist/src/features/onboarding-flow/hooks/useBridgeDeposit.d.ts +35 -0
- package/dist/src/features/onboarding-flow/hooks/useBridgeDeposit.js +585 -0
- package/dist/src/features/onboarding-flow/hooks/useBridgeDeposit.js.map +1 -0
- package/dist/src/features/onboarding-flow/hooks/useDepositAuth.d.ts +6 -0
- package/dist/src/features/onboarding-flow/hooks/useDepositAuth.js +141 -0
- package/dist/src/features/onboarding-flow/hooks/useDepositAuth.js.map +1 -0
- package/dist/src/features/onboarding-flow/hooks/useDepositHydration.d.ts +15 -0
- package/dist/src/features/onboarding-flow/hooks/useDepositHydration.js +83 -0
- package/dist/src/features/onboarding-flow/hooks/useDepositHydration.js.map +1 -0
- package/dist/src/features/onboarding-flow/hooks/usePendingDepositState.d.ts +6 -0
- package/dist/src/features/onboarding-flow/hooks/usePendingDepositState.js +45 -0
- package/dist/src/features/onboarding-flow/hooks/usePendingDepositState.js.map +1 -0
- package/dist/src/features/onboarding-flow/hooks/useSolanaDeposit.d.ts +13 -0
- package/dist/src/features/onboarding-flow/hooks/useSolanaDeposit.js +161 -0
- package/dist/src/features/onboarding-flow/hooks/useSolanaDeposit.js.map +1 -0
- package/dist/src/features/onboarding-flow/index.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/providers/DepositFlowProvider.d.ts +10 -3
- package/dist/src/features/onboarding-flow/providers/DepositFlowProvider.js +762 -0
- package/dist/src/features/onboarding-flow/providers/DepositFlowProvider.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/providers/OnboardingStateProvider.d.ts +5 -0
- package/dist/src/features/onboarding-flow/providers/OnboardingStateProvider.js +399 -0
- package/dist/src/features/onboarding-flow/providers/OnboardingStateProvider.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/providers/StateProvider.d.ts +2 -2
- package/dist/{features → src/features}/onboarding-flow/providers/StateProvider.js +2 -2
- package/dist/src/features/onboarding-flow/providers/StateProvider.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/providers/WalletConnectionProvider.d.ts +8 -0
- package/dist/src/features/onboarding-flow/providers/WalletConnectionProvider.js +938 -0
- package/dist/src/features/onboarding-flow/providers/WalletConnectionProvider.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/providers/debug.js +5 -1
- package/dist/src/features/onboarding-flow/providers/debug.js.map +1 -0
- package/dist/src/features/onboarding-flow/providers/index.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/providers/onboardingStateMachine.d.ts +28 -1
- package/dist/{features → src/features}/onboarding-flow/providers/onboardingStateMachine.js +38 -4
- package/dist/src/features/onboarding-flow/providers/onboardingStateMachine.js.map +1 -0
- package/dist/src/features/onboarding-flow/screens/00-EntrySelectionScreen.d.ts +4 -0
- package/dist/src/features/onboarding-flow/screens/00-EntrySelectionScreen.js +32 -0
- package/dist/src/features/onboarding-flow/screens/00-EntrySelectionScreen.js.map +1 -0
- package/dist/src/features/onboarding-flow/screens/01-ConnectWalletScreen.d.ts +5 -0
- package/dist/{features → src/features}/onboarding-flow/screens/01-ConnectWalletScreen.js +5 -0
- package/dist/src/features/onboarding-flow/screens/01-ConnectWalletScreen.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/screens/02-TurnkeyAuthScreen.js +8 -1
- package/dist/src/features/onboarding-flow/screens/02-TurnkeyAuthScreen.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/screens/03-TurnkeyPreparingScreen.js +8 -1
- package/dist/src/features/onboarding-flow/screens/03-TurnkeyPreparingScreen.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/screens/04-ChainSelectionScreen.d.ts +11 -11
- package/dist/{features → src/features}/onboarding-flow/screens/04-ChainSelectionScreen.js +59 -29
- package/dist/src/features/onboarding-flow/screens/04-ChainSelectionScreen.js.map +1 -0
- package/dist/src/features/onboarding-flow/screens/05-AmountInputScreen.d.ts +11 -0
- package/dist/src/features/onboarding-flow/screens/05-AmountInputScreen.js +585 -0
- package/dist/src/features/onboarding-flow/screens/05-AmountInputScreen.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/screens/06-DepositProgressScreen.d.ts +5 -0
- package/dist/src/features/onboarding-flow/screens/06-DepositProgressScreen.js +367 -0
- package/dist/src/features/onboarding-flow/screens/06-DepositProgressScreen.js.map +1 -0
- package/dist/src/features/onboarding-flow/screens/07-DepositSuccessScreen.d.ts +6 -0
- package/dist/{features → src/features}/onboarding-flow/screens/07-DepositSuccessScreen.js +11 -5
- package/dist/src/features/onboarding-flow/screens/07-DepositSuccessScreen.js.map +1 -0
- package/dist/src/features/onboarding-flow/screens/08-AuthLoadingScreen.d.ts +5 -0
- package/dist/{features → src/features}/onboarding-flow/screens/08-AuthLoadingScreen.js +5 -1
- package/dist/src/features/onboarding-flow/screens/08-AuthLoadingScreen.js.map +1 -0
- package/dist/src/features/onboarding-flow/screens/09-ErrorScreen.d.ts +5 -0
- package/dist/src/features/onboarding-flow/screens/09-ErrorScreen.js +43 -0
- package/dist/src/features/onboarding-flow/screens/09-ErrorScreen.js.map +1 -0
- package/dist/src/features/onboarding-flow/screens/index.d.ts +10 -0
- package/dist/src/features/onboarding-flow/screens/index.js +11 -0
- package/dist/src/features/onboarding-flow/screens/index.js.map +1 -0
- package/dist/src/features/onboarding-flow/turnkey/turnkeySessionMachine.d.ts +1 -0
- package/dist/src/features/onboarding-flow/turnkey/turnkeySessionMachine.js +2 -0
- package/dist/src/features/onboarding-flow/turnkey/turnkeySessionMachine.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/types.d.ts +38 -11
- package/dist/{features → src/features}/onboarding-flow/types.js +5 -0
- package/dist/src/features/onboarding-flow/types.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/bridgeUtils.d.ts +6 -0
- package/dist/src/features/onboarding-flow/utils/bridgeUtils.js +34 -0
- package/dist/src/features/onboarding-flow/utils/bridgeUtils.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/attestationUtils.d.ts +29 -0
- package/dist/src/features/onboarding-flow/utils/deposit/attestationUtils.js +82 -0
- package/dist/src/features/onboarding-flow/utils/deposit/attestationUtils.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/bridgeUtils.d.ts +5 -0
- package/dist/src/features/onboarding-flow/utils/deposit/bridgeUtils.js +10 -0
- package/dist/src/features/onboarding-flow/utils/deposit/bridgeUtils.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/claimConfirmation.d.ts +14 -0
- package/dist/src/features/onboarding-flow/utils/deposit/claimConfirmation.js +94 -0
- package/dist/src/features/onboarding-flow/utils/deposit/claimConfirmation.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/claimSubmission.d.ts +25 -0
- package/dist/src/features/onboarding-flow/utils/deposit/claimSubmission.js +212 -0
- package/dist/src/features/onboarding-flow/utils/deposit/claimSubmission.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/depositPolling.d.ts +37 -0
- package/dist/src/features/onboarding-flow/utils/deposit/depositPolling.js +199 -0
- package/dist/src/features/onboarding-flow/utils/deposit/depositPolling.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/evmTxInterceptor.d.ts +27 -0
- package/dist/src/features/onboarding-flow/utils/deposit/evmTxInterceptor.js +149 -0
- package/dist/src/features/onboarding-flow/utils/deposit/evmTxInterceptor.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/nonceUtils.d.ts +5 -0
- package/dist/src/features/onboarding-flow/utils/deposit/nonceUtils.js +121 -0
- package/dist/src/features/onboarding-flow/utils/deposit/nonceUtils.js.map +1 -0
- package/dist/{features/onboarding-flow/utils/transaction.d.ts → src/features/onboarding-flow/utils/deposit/solanaDepositTransaction.d.ts} +3 -3
- package/dist/src/features/onboarding-flow/utils/deposit/solanaDepositTransaction.js +8 -0
- package/dist/src/features/onboarding-flow/utils/deposit/solanaDepositTransaction.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/solanaUtils.d.ts +12 -0
- package/dist/src/features/onboarding-flow/utils/deposit/solanaUtils.js +150 -0
- package/dist/src/features/onboarding-flow/utils/deposit/solanaUtils.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/storage.d.ts +52 -0
- package/dist/src/features/onboarding-flow/utils/deposit/storage.js +243 -0
- package/dist/src/features/onboarding-flow/utils/deposit/storage.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/deposit/walletUtils.d.ts +36 -0
- package/dist/src/features/onboarding-flow/utils/deposit/walletUtils.js +304 -0
- package/dist/src/features/onboarding-flow/utils/deposit/walletUtils.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/depositPolling.d.ts +1 -0
- package/dist/src/features/onboarding-flow/utils/depositPolling.js +3 -0
- package/dist/src/features/onboarding-flow/utils/depositPolling.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/explorerUrl.d.ts +14 -0
- package/dist/src/features/onboarding-flow/utils/explorerUrl.js +44 -0
- package/dist/src/features/onboarding-flow/utils/explorerUrl.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/nordUtils.d.ts +8 -0
- package/dist/{features/onboarding-flow/utils/nordUser.js → src/features/onboarding-flow/utils/nordUtils.js} +14 -1
- package/dist/src/features/onboarding-flow/utils/nordUtils.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/pendingDepositCookie.d.ts +13 -0
- package/dist/src/features/onboarding-flow/utils/pendingDepositCookie.js +15 -0
- package/dist/src/features/onboarding-flow/utils/pendingDepositCookie.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/pendingDepositStorage.d.ts +15 -0
- package/dist/src/features/onboarding-flow/utils/pendingDepositStorage.js +94 -0
- package/dist/src/features/onboarding-flow/utils/pendingDepositStorage.js.map +1 -0
- package/dist/{features → src/features}/onboarding-flow/utils/utils.d.ts +9 -2
- package/dist/{features → src/features}/onboarding-flow/utils/utils.js +9 -4
- package/dist/src/features/onboarding-flow/utils/utils.js.map +1 -0
- package/dist/src/features/onboarding-flow/utils/withImageFallback.d.ts +6 -0
- package/dist/{features → src/features}/onboarding-flow/utils/withImageFallback.js +2 -3
- package/dist/src/features/onboarding-flow/utils/withImageFallback.js.map +1 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/useN1Wallet.d.ts +12 -0
- package/dist/{hooks → src/hooks}/useN1Wallet.js +10 -0
- package/dist/src/hooks/useN1Wallet.js.map +1 -0
- package/dist/src/hooks/useNordUserInitialization.d.ts +12 -0
- package/dist/{hooks → src/hooks}/useNordUserInitialization.js +74 -33
- package/dist/src/hooks/useNordUserInitialization.js.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.js +16 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/providers/LazyWalletProvider.d.ts +4 -0
- package/dist/src/providers/LazyWalletProvider.js +404 -0
- package/dist/src/providers/LazyWalletProvider.js.map +1 -0
- package/dist/src/providers/N1WalletProvider/ContextBridge.d.ts +28 -0
- package/dist/src/providers/N1WalletProvider/ContextBridge.js +273 -0
- package/dist/src/providers/N1WalletProvider/ContextBridge.js.map +1 -0
- package/dist/src/providers/N1WalletProvider/ModalProvider.d.ts +113 -0
- package/dist/src/providers/N1WalletProvider/ModalProvider.js +319 -0
- package/dist/src/providers/N1WalletProvider/ModalProvider.js.map +1 -0
- package/dist/src/providers/N1WalletProvider/NetworkProvider.d.ts +88 -0
- package/dist/src/providers/N1WalletProvider/NetworkProvider.js +252 -0
- package/dist/src/providers/N1WalletProvider/NetworkProvider.js.map +1 -0
- package/dist/src/providers/N1WalletProvider/SessionProvider.d.ts +71 -0
- package/dist/src/providers/N1WalletProvider/SessionProvider.js +187 -0
- package/dist/src/providers/N1WalletProvider/SessionProvider.js.map +1 -0
- package/dist/src/providers/N1WalletProvider/SigningProvider.d.ts +58 -0
- package/dist/src/providers/N1WalletProvider/SigningProvider.js +134 -0
- package/dist/src/providers/N1WalletProvider/SigningProvider.js.map +1 -0
- package/dist/src/providers/N1WalletProvider/ThemingProvider.d.ts +50 -0
- package/dist/src/providers/N1WalletProvider/ThemingProvider.js +102 -0
- package/dist/src/providers/N1WalletProvider/ThemingProvider.js.map +1 -0
- package/dist/src/providers/N1WalletProvider/index.d.ts +21 -0
- package/dist/src/providers/N1WalletProvider/index.js +27 -0
- package/dist/src/providers/N1WalletProvider/index.js.map +1 -0
- package/dist/src/providers/N1WalletProvider.d.ts +17 -0
- package/dist/src/providers/N1WalletProvider.js +102 -0
- package/dist/src/providers/N1WalletProvider.js.map +1 -0
- package/dist/{providers → src/providers}/ShadowRootWrapper.d.ts +4 -0
- package/dist/{providers → src/providers}/ShadowRootWrapper.js +4 -0
- package/dist/src/providers/ShadowRootWrapper.js.map +1 -0
- package/dist/{providers → src/providers}/WalletErrorBoundary.d.ts +7 -2
- package/dist/{providers → src/providers}/WalletErrorBoundary.js +5 -1
- package/dist/src/providers/WalletErrorBoundary.js.map +1 -0
- package/dist/src/services/bootstrap/DepositRecoveryService.d.ts +64 -0
- package/dist/src/services/bootstrap/DepositRecoveryService.js +245 -0
- package/dist/src/services/bootstrap/DepositRecoveryService.js.map +1 -0
- package/dist/src/services/bootstrap/DynamicSdkService.d.ts +62 -0
- package/dist/src/services/bootstrap/DynamicSdkService.js +335 -0
- package/dist/src/services/bootstrap/DynamicSdkService.js.map +1 -0
- package/dist/src/services/bootstrap/SessionBootstrapService.d.ts +78 -0
- package/dist/src/services/bootstrap/SessionBootstrapService.js +280 -0
- package/dist/src/services/bootstrap/SessionBootstrapService.js.map +1 -0
- package/dist/src/services/bootstrap/TurnkeyBootstrapService.d.ts +92 -0
- package/dist/src/services/bootstrap/TurnkeyBootstrapService.js +253 -0
- package/dist/src/services/bootstrap/TurnkeyBootstrapService.js.map +1 -0
- package/dist/src/services/bootstrap/index.d.ts +13 -0
- package/dist/src/services/bootstrap/index.js +16 -0
- package/dist/src/services/bootstrap/index.js.map +1 -0
- package/dist/src/services/bootstrap/types.d.ts +92 -0
- package/dist/src/services/bootstrap/types.js +7 -0
- package/dist/src/services/bootstrap/types.js.map +1 -0
- package/dist/src/services/storage/StorageService.d.ts +98 -0
- package/dist/src/services/storage/StorageService.js +360 -0
- package/dist/src/services/storage/StorageService.js.map +1 -0
- package/dist/src/services/storage/index.d.ts +9 -0
- package/dist/src/services/storage/index.js +10 -0
- package/dist/src/services/storage/index.js.map +1 -0
- package/dist/src/services/storage/keys.d.ts +28 -0
- package/dist/src/services/storage/keys.js +45 -0
- package/dist/src/services/storage/keys.js.map +1 -0
- package/dist/src/services/storage/types.d.ts +73 -0
- package/dist/src/services/storage/types.js +23 -0
- package/dist/src/services/storage/types.js.map +1 -0
- package/dist/src/store/index.d.ts +8 -0
- package/dist/src/store/index.js +24 -0
- package/dist/src/store/index.js.map +1 -0
- package/dist/src/store/selectors.d.ts +105 -0
- package/dist/src/store/selectors.js +183 -0
- package/dist/src/store/selectors.js.map +1 -0
- package/dist/src/store/slices/bootstrapSlice.d.ts +64 -0
- package/dist/src/store/slices/bootstrapSlice.js +78 -0
- package/dist/src/store/slices/bootstrapSlice.js.map +1 -0
- package/dist/src/store/slices/configSlice.d.ts +7 -0
- package/dist/src/store/slices/configSlice.js +14 -0
- package/dist/src/store/slices/configSlice.js.map +1 -0
- package/dist/src/store/slices/index.d.ts +10 -0
- package/dist/src/store/slices/index.js +10 -0
- package/dist/src/store/slices/index.js.map +1 -0
- package/dist/src/store/slices/sessionSlice.d.ts +7 -0
- package/dist/src/store/slices/sessionSlice.js +17 -0
- package/dist/src/store/slices/sessionSlice.js.map +1 -0
- package/dist/src/store/slices/signingSlice.d.ts +7 -0
- package/dist/src/store/slices/signingSlice.js +14 -0
- package/dist/src/store/slices/signingSlice.js.map +1 -0
- package/dist/src/store/slices/uiSlice.d.ts +9 -0
- package/dist/src/store/slices/uiSlice.js +25 -0
- package/dist/src/store/slices/uiSlice.js.map +1 -0
- package/dist/src/store/slices/walletSlice.d.ts +7 -0
- package/dist/src/store/slices/walletSlice.js +21 -0
- package/dist/src/store/slices/walletSlice.js.map +1 -0
- package/dist/src/store/store.d.ts +50 -0
- package/dist/src/store/store.js +259 -0
- package/dist/src/store/store.js.map +1 -0
- package/dist/src/store/subscriptions/depositPersistence.d.ts +32 -0
- package/dist/src/store/subscriptions/depositPersistence.js +106 -0
- package/dist/src/store/subscriptions/depositPersistence.js.map +1 -0
- package/dist/src/store/subscriptions/index.d.ts +34 -0
- package/dist/src/store/subscriptions/index.js +73 -0
- package/dist/src/store/subscriptions/index.js.map +1 -0
- package/dist/src/store/subscriptions/turnkeyPersistence.d.ts +42 -0
- package/dist/src/store/subscriptions/turnkeyPersistence.js +127 -0
- package/dist/src/store/subscriptions/turnkeyPersistence.js.map +1 -0
- package/dist/src/store/types.d.ts +166 -0
- package/dist/src/store/types.js +7 -0
- package/dist/src/store/types.js.map +1 -0
- package/dist/src/styles/cdn-fonts.d.ts +12 -0
- package/dist/src/styles/cdn-fonts.js +63 -0
- package/dist/src/styles/cdn-fonts.js.map +1 -0
- package/dist/src/styles/embedded-main-css.d.ts +2 -0
- package/dist/src/styles/embedded-main-css.js +3 -0
- package/dist/src/styles/embedded-main-css.js.map +1 -0
- package/dist/src/turnkey/TurnkeyProvider.d.ts +21 -0
- package/dist/src/turnkey/TurnkeyProvider.js +695 -0
- package/dist/src/turnkey/TurnkeyProvider.js.map +1 -0
- package/dist/src/turnkey/createTurnkeyWallet.d.ts +39 -0
- package/dist/src/turnkey/createTurnkeyWallet.js +319 -0
- package/dist/src/turnkey/createTurnkeyWallet.js.map +1 -0
- package/dist/src/turnkey/createWalletProvider.d.ts +8 -0
- package/dist/src/turnkey/createWalletProvider.js +286 -0
- package/dist/src/turnkey/createWalletProvider.js.map +1 -0
- package/dist/src/turnkey/index.d.ts +3 -0
- package/dist/src/turnkey/index.js +3 -0
- package/dist/src/turnkey/index.js.map +1 -0
- package/dist/src/turnkey/turnkeySessionMachine.d.ts +39 -0
- package/dist/src/turnkey/turnkeySessionMachine.js +77 -0
- package/dist/src/turnkey/turnkeySessionMachine.js.map +1 -0
- package/dist/src/turnkey/turnkeySessionStorage.d.ts +48 -0
- package/dist/src/turnkey/turnkeySessionStorage.js +183 -0
- package/dist/src/turnkey/turnkeySessionStorage.js.map +1 -0
- package/dist/{turnkey → src/turnkey}/types.d.ts +21 -8
- package/dist/src/turnkey/types.js +12 -0
- package/dist/src/turnkey/types.js.map +1 -0
- package/dist/{types → src/types}/wallet.d.ts +39 -13
- package/dist/src/types/wallet.js.map +1 -0
- package/dist/src/utils/address.d.ts +130 -0
- package/dist/src/utils/address.js +274 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/chain.d.ts +89 -0
- package/dist/src/utils/chain.js +282 -0
- package/dist/src/utils/chain.js.map +1 -0
- package/dist/{utils → src/utils}/ed25519.d.ts +0 -2
- package/dist/{utils → src/utils}/ed25519.js +4 -19
- package/dist/src/utils/ed25519.js.map +1 -0
- package/dist/src/utils/errors.d.ts +68 -0
- package/dist/src/utils/errors.js +190 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/events.d.ts +124 -0
- package/dist/src/utils/events.js +155 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/formatAmount.d.ts +4 -0
- package/dist/src/utils/formatAmount.js +9 -0
- package/dist/src/utils/formatAmount.js.map +1 -0
- package/dist/src/utils/logger.d.ts +45 -0
- package/dist/{utils → src/utils}/logger.js +68 -2
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/shortenString.d.ts +5 -0
- package/dist/src/utils/shortenString.js +16 -0
- package/dist/src/utils/shortenString.js.map +1 -0
- package/package.json +37 -15
- package/dist/animations/N1Loader.js.map +0 -1
- package/dist/animations/Processing.js.map +0 -1
- package/dist/components/LoadingFallback.js.map +0 -1
- package/dist/components/Logo.js.map +0 -1
- package/dist/components/N1ConnectButton.d.ts +0 -5
- package/dist/components/N1ConnectButton.js +0 -49
- package/dist/components/N1ConnectButton.js.map +0 -1
- package/dist/components/logos/ArbitrumLogo.js.map +0 -1
- package/dist/components/logos/BaseLogo.js +0 -6
- package/dist/components/logos/BaseLogo.js.map +0 -1
- package/dist/components/logos/BeraLogo.js.map +0 -1
- package/dist/components/logos/BitcoinLogo.js.map +0 -1
- package/dist/components/logos/EthereumLogo.js.map +0 -1
- package/dist/components/logos/HyperliquidLogo.js.map +0 -1
- package/dist/components/logos/OptimismLogo.js.map +0 -1
- package/dist/components/logos/SolanaLogo.js.map +0 -1
- package/dist/components/logos/ZeroOneLogo.js.map +0 -1
- package/dist/components/logos/index.js.map +0 -1
- package/dist/config/chains.d.ts +0 -0
- package/dist/config/chains.js +0 -2
- package/dist/config/chains.js.map +0 -1
- package/dist/config/dynamic.js +0 -13
- package/dist/config/dynamic.js.map +0 -1
- package/dist/config/solana.js.map +0 -1
- package/dist/config/turnkey.d.ts +0 -2
- package/dist/config/turnkey.js.map +0 -1
- package/dist/config.d.ts +0 -2
- package/dist/config.js +0 -3
- package/dist/config.js.map +0 -1
- package/dist/context/n1-wallet-context.js.map +0 -1
- package/dist/errors/types.d.ts +0 -25
- package/dist/errors/types.js +0 -77
- package/dist/errors/types.js.map +0 -1
- package/dist/features/onboarding-flow/N1WalletModal.js.map +0 -1
- package/dist/features/onboarding-flow/OnboardingFlow.js.map +0 -1
- package/dist/features/onboarding-flow/components/ChainButton.js +0 -21
- package/dist/features/onboarding-flow/components/ChainButton.js.map +0 -1
- package/dist/features/onboarding-flow/components/Header.js +0 -45
- package/dist/features/onboarding-flow/components/Header.js.map +0 -1
- package/dist/features/onboarding-flow/components/ImageWithFallback.js.map +0 -1
- package/dist/features/onboarding-flow/components/TransactionTable.js.map +0 -1
- package/dist/features/onboarding-flow/components/WaitingMessage.js.map +0 -1
- package/dist/features/onboarding-flow/components/index.js.map +0 -1
- package/dist/features/onboarding-flow/index.js.map +0 -1
- package/dist/features/onboarding-flow/providers/DepositFlowProvider.js +0 -525
- package/dist/features/onboarding-flow/providers/DepositFlowProvider.js.map +0 -1
- package/dist/features/onboarding-flow/providers/OnboardingStateProvider.js +0 -185
- package/dist/features/onboarding-flow/providers/OnboardingStateProvider.js.map +0 -1
- package/dist/features/onboarding-flow/providers/StateProvider.js.map +0 -1
- package/dist/features/onboarding-flow/providers/WalletConnectionProvider.js +0 -394
- package/dist/features/onboarding-flow/providers/WalletConnectionProvider.js.map +0 -1
- package/dist/features/onboarding-flow/providers/debug.js.map +0 -1
- package/dist/features/onboarding-flow/providers/index.js.map +0 -1
- package/dist/features/onboarding-flow/providers/onboardingStateMachine.js.map +0 -1
- package/dist/features/onboarding-flow/screens/01-ConnectWalletScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/01-ConnectWalletScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/02-ChainSelectionScreen.d.ts +0 -31
- package/dist/features/onboarding-flow/screens/02-ChainSelectionScreen.js +0 -100
- package/dist/features/onboarding-flow/screens/02-ChainSelectionScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/02-TurnkeyAuthScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/03-AmountInputScreen.d.ts +0 -6
- package/dist/features/onboarding-flow/screens/03-AmountInputScreen.js +0 -360
- package/dist/features/onboarding-flow/screens/03-AmountInputScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/03-TurnkeyPreparingScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/04-ChainSelectionScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/04-DepositProgressScreen.d.ts +0 -3
- package/dist/features/onboarding-flow/screens/04-DepositProgressScreen.js +0 -31
- package/dist/features/onboarding-flow/screens/04-DepositProgressScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/05-AmountInputScreen.d.ts +0 -6
- package/dist/features/onboarding-flow/screens/05-AmountInputScreen.js +0 -360
- package/dist/features/onboarding-flow/screens/05-AmountInputScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/05-DepositSuccessScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/05-DepositSuccessScreen.js +0 -136
- package/dist/features/onboarding-flow/screens/05-DepositSuccessScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/06-AuthLoadingScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/06-AuthLoadingScreen.js +0 -31
- package/dist/features/onboarding-flow/screens/06-AuthLoadingScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/06-DepositProgressScreen.js +0 -31
- package/dist/features/onboarding-flow/screens/06-DepositProgressScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/07-DepositSuccessScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/07-DepositSuccessScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/07-ErrorScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/07-ErrorScreen.js +0 -14
- package/dist/features/onboarding-flow/screens/07-ErrorScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/08-AuthLoadingScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/08-AuthLoadingScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/08-TurnkeyAuthScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/08-TurnkeyAuthScreen.js +0 -18
- package/dist/features/onboarding-flow/screens/08-TurnkeyAuthScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/09-ErrorScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/09-ErrorScreen.js +0 -14
- package/dist/features/onboarding-flow/screens/09-ErrorScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/09-TurnkeyPreparingScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/09-TurnkeyPreparingScreen.js +0 -18
- package/dist/features/onboarding-flow/screens/09-TurnkeyPreparingScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/TurnkeyAuthScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/TurnkeyAuthScreen.js +0 -18
- package/dist/features/onboarding-flow/screens/TurnkeyAuthScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/TurnkeyPreparingScreen.d.ts +0 -1
- package/dist/features/onboarding-flow/screens/TurnkeyPreparingScreen.js +0 -18
- package/dist/features/onboarding-flow/screens/TurnkeyPreparingScreen.js.map +0 -1
- package/dist/features/onboarding-flow/screens/index.d.ts +0 -7
- package/dist/features/onboarding-flow/screens/index.js +0 -8
- package/dist/features/onboarding-flow/screens/index.js.map +0 -1
- package/dist/features/onboarding-flow/types.js.map +0 -1
- package/dist/features/onboarding-flow/utils/depositStorage.d.ts +0 -4
- package/dist/features/onboarding-flow/utils/depositStorage.js +0 -48
- package/dist/features/onboarding-flow/utils/depositStorage.js.map +0 -1
- package/dist/features/onboarding-flow/utils/imageUtils.d.ts +0 -21
- package/dist/features/onboarding-flow/utils/imageUtils.js +0 -110
- package/dist/features/onboarding-flow/utils/imageUtils.js.map +0 -1
- package/dist/features/onboarding-flow/utils/nordUser.d.ts +0 -1
- package/dist/features/onboarding-flow/utils/nordUser.js.map +0 -1
- package/dist/features/onboarding-flow/utils/nordUtils.d.ts +0 -40
- package/dist/features/onboarding-flow/utils/nordUtils.js +0 -64
- package/dist/features/onboarding-flow/utils/nordUtils.js.map +0 -1
- package/dist/features/onboarding-flow/utils/session.d.ts +0 -17
- package/dist/features/onboarding-flow/utils/session.js +0 -69
- package/dist/features/onboarding-flow/utils/session.js.map +0 -1
- package/dist/features/onboarding-flow/utils/transaction.js +0 -8
- package/dist/features/onboarding-flow/utils/transaction.js.map +0 -1
- package/dist/features/onboarding-flow/utils/utils.js.map +0 -1
- package/dist/features/onboarding-flow/utils/withImageFallback.d.ts +0 -7
- package/dist/features/onboarding-flow/utils/withImageFallback.js.map +0 -1
- package/dist/features/turnkey/createTurnkeyWallet.d.ts +0 -25
- package/dist/features/turnkey/createTurnkeyWallet.js +0 -119
- package/dist/features/turnkey/createTurnkeyWallet.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useN1Wallet.d.ts +0 -2
- package/dist/hooks/useN1Wallet.js.map +0 -1
- package/dist/hooks/useNordUserInitialization.d.ts +0 -1
- package/dist/hooks/useNordUserInitialization.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/polyfills/windowEthereumGuard.d.ts +0 -6
- package/dist/polyfills/windowEthereumGuard.js +0 -28
- package/dist/polyfills/windowEthereumGuard.js.map +0 -1
- package/dist/providers/LazyWalletProvider.d.ts +0 -1
- package/dist/providers/LazyWalletProvider.js +0 -230
- package/dist/providers/LazyWalletProvider.js.map +0 -1
- package/dist/providers/N1WalletProvider.d.ts +0 -3
- package/dist/providers/N1WalletProvider.js +0 -267
- package/dist/providers/N1WalletProvider.js.map +0 -1
- package/dist/providers/ShadowRootWrapper.js.map +0 -1
- package/dist/providers/TurnkeyProviderBridge.d.ts +0 -7
- package/dist/providers/TurnkeyProviderBridge.js +0 -20
- package/dist/providers/TurnkeyProviderBridge.js.map +0 -1
- package/dist/providers/WalletErrorBoundary.js.map +0 -1
- package/dist/styles/embedded-main-css.d.ts +0 -2
- package/dist/styles/embedded-main-css.js +0 -3
- package/dist/styles/embedded-main-css.js.map +0 -1
- package/dist/turnkey/TurnkeyProvider.d.ts +0 -9
- package/dist/turnkey/TurnkeyProvider.js +0 -378
- package/dist/turnkey/TurnkeyProvider.js.map +0 -1
- package/dist/turnkey/createWalletProvider.d.ts +0 -3
- package/dist/turnkey/createWalletProvider.js +0 -180
- package/dist/turnkey/createWalletProvider.js.map +0 -1
- package/dist/turnkey/index.d.ts +0 -3
- package/dist/turnkey/index.js +0 -3
- package/dist/turnkey/index.js.map +0 -1
- package/dist/turnkey/types.js +0 -8
- package/dist/turnkey/types.js.map +0 -1
- package/dist/types/wallet.js.map +0 -1
- package/dist/utils/ed25519.js.map +0 -1
- package/dist/utils/getPseudoName.d.ts +0 -1
- package/dist/utils/getPseudoName.js +0 -5826
- package/dist/utils/getPseudoName.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -21
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/shortenString.d.ts +0 -2
- package/dist/utils/shortenString.js +0 -9
- package/dist/utils/shortenString.js.map +0 -1
- package/dist/utils/turnkeySessionStorage.d.ts +0 -3
- package/dist/utils/turnkeySessionStorage.js +0 -33
- package/dist/utils/turnkeySessionStorage.js.map +0 -1
- package/dist/utils/words.d.ts +0 -9
- package/dist/utils/words.js +0 -93572
- package/dist/utils/words.js.map +0 -1
- /package/dist/{animations → src/animations}/N1Loader.d.ts +0 -0
- /package/dist/{animations → src/animations}/N1Loader.js +0 -0
- /package/dist/{animations → src/animations}/Processing.d.ts +0 -0
- /package/dist/{animations → src/animations}/Processing.js +0 -0
- /package/dist/{components → src/components}/logos/ArbitrumLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/ArbitrumLogo.js +0 -0
- /package/dist/{components → src/components}/logos/BaseLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/BeraLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/BeraLogo.js +0 -0
- /package/dist/{components → src/components}/logos/BitcoinLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/BitcoinLogo.js +0 -0
- /package/dist/{components → src/components}/logos/EthereumLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/EthereumLogo.js +0 -0
- /package/dist/{components → src/components}/logos/HyperliquidLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/OptimismLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/OptimismLogo.js +0 -0
- /package/dist/{components → src/components}/logos/SolanaLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/SolanaLogo.js +0 -0
- /package/dist/{components → src/components}/logos/ZeroOneLogo.d.ts +0 -0
- /package/dist/{components → src/components}/logos/ZeroOneLogo.js +0 -0
- /package/dist/{components → src/components}/logos/index.d.ts +0 -0
- /package/dist/{components → src/components}/logos/index.js +0 -0
- /package/dist/{config → src/config}/dynamic.d.ts +0 -0
- /package/dist/{config → src/config}/solana.d.ts +0 -0
- /package/dist/{config → src/config}/solana.js +0 -0
- /package/dist/{context → src/context}/n1-wallet-context.d.ts +0 -0
- /package/dist/{context → src/context}/n1-wallet-context.js +0 -0
- /package/dist/{features → src/features}/onboarding-flow/N1WalletModal.d.ts +0 -0
- /package/dist/{features → src/features}/onboarding-flow/components/ImageWithFallback.d.ts +0 -0
- /package/dist/{features → src/features}/onboarding-flow/components/ImageWithFallback.js +0 -0
- /package/dist/{features → src/features}/onboarding-flow/components/WaitingMessage.js +0 -0
- /package/dist/{features → src/features}/onboarding-flow/components/index.d.ts +0 -0
- /package/dist/{features → src/features}/onboarding-flow/components/index.js +0 -0
- /package/dist/{features → src/features}/onboarding-flow/index.d.ts +0 -0
- /package/dist/{features → src/features}/onboarding-flow/index.js +0 -0
- /package/dist/{features → src/features}/onboarding-flow/providers/debug.d.ts +0 -0
- /package/dist/{features → src/features}/onboarding-flow/providers/index.d.ts +0 -0
- /package/dist/{features → src/features}/onboarding-flow/providers/index.js +0 -0
- /package/dist/{features → src/features}/onboarding-flow/screens/02-TurnkeyAuthScreen.d.ts +0 -0
- /package/dist/{features → src/features}/onboarding-flow/screens/03-TurnkeyPreparingScreen.d.ts +0 -0
- /package/dist/{hooks → src/hooks}/index.d.ts +0 -0
- /package/dist/{hooks → src/hooks}/index.js +0 -0
- /package/dist/{types → src/types}/wallet.js +0 -0
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
50
|
+
import { DEFAULT_SESSION_EXPIRATION_IN_SECONDS, StamperType, TurnkeyClient } from "@turnkey/core";
|
|
51
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
52
|
+
import { TURNKEY_CONFIG } from "../config/turnkey";
|
|
53
|
+
import { useN1WalletContext } from "../hooks";
|
|
54
|
+
import { useNetwork, useNetworkActions } from "../providers/N1WalletProvider/NetworkProvider";
|
|
55
|
+
import { logger } from "../utils/logger";
|
|
56
|
+
import { EVENTS, createTurnkeyEvent } from "../utils/events";
|
|
57
|
+
import { createTurnkeyError } from "../utils/errors";
|
|
58
|
+
import { createTurnkeySolanaWallet } from "./createTurnkeyWallet";
|
|
59
|
+
import { buildWalletProvider } from "./createWalletProvider";
|
|
60
|
+
import { TurnkeyAuthState, } from "./types";
|
|
61
|
+
import { normalizeAddress as normalizeAddressService, isUserRejectedError, isSessionForDifferentUser, hasStoredSession, getStoredSession, storeSession, clearSession, updateSessionSolanaAccount, getCachedSolanaAccount, TURNKEY_WALLET_NAME as SERVICE_TURNKEY_WALLET_NAME, SOLANA_ADDRESS_FORMAT as SERVICE_SOLANA_ADDRESS_FORMAT, } from "../services/bootstrap";
|
|
62
|
+
import { StorageService } from "../services/storage";
|
|
63
|
+
import { useWalletStore, getWalletActions } from "../store";
|
|
64
|
+
// Re-export constants for backwards compatibility
|
|
65
|
+
export var TURNKEY_WALLET_NAME = SERVICE_TURNKEY_WALLET_NAME;
|
|
66
|
+
var SOLANA_ADDRESS_FORMAT = SERVICE_SOLANA_ADDRESS_FORMAT;
|
|
67
|
+
// Use service for address normalization
|
|
68
|
+
var normalizeAddress = normalizeAddressService;
|
|
69
|
+
var TurnkeyContext = createContext(null);
|
|
70
|
+
/**
|
|
71
|
+
* Provider component that manages Turnkey authentication and wallet operations.
|
|
72
|
+
*
|
|
73
|
+
* Simplified Flow:
|
|
74
|
+
* 1. Monitor EVM address.
|
|
75
|
+
* 2. If EVM address changes or is missing -> Reset state.
|
|
76
|
+
* 3. If EVM address is present -> Run `prepareTurnkeyWallet`.
|
|
77
|
+
* a. Check if we need to logout (previous session != current address).
|
|
78
|
+
* b. Hydrate/Login.
|
|
79
|
+
* c. Ensure Solana account.
|
|
80
|
+
*/
|
|
81
|
+
export function TurnkeyProvider(_a) {
|
|
82
|
+
var _this = this;
|
|
83
|
+
var children = _a.children;
|
|
84
|
+
// -- State --
|
|
85
|
+
var turnkeyConfig = TURNKEY_CONFIG !== null && TURNKEY_CONFIG !== void 0 ? TURNKEY_CONFIG : undefined;
|
|
86
|
+
var _b = useState(TurnkeyAuthState.Unauthenticated), turnkeyAuthState = _b[0], setTurnkeyAuthState = _b[1];
|
|
87
|
+
var _c = useState([]), turnkeyWallets = _c[0], setTurnkeyWallets = _c[1];
|
|
88
|
+
var _d = useState(null), turnkeySession = _d[0], setTurnkeySession = _d[1];
|
|
89
|
+
var _e = useState(false), isHydratingSession = _e[0], setIsHydratingSession = _e[1];
|
|
90
|
+
var _f = useState(null), turnkeyAddress = _f[0], setTurnkeyAddress = _f[1];
|
|
91
|
+
// -- Bootstrap slice state (single source of truth for status/error) --
|
|
92
|
+
var turnkeyStatus = useWalletStore(function (state) { return state.bootstrap.turnkeyStatus; });
|
|
93
|
+
var turnkeyError = useWalletStore(function (state) { return state.bootstrap.turnkeyError; });
|
|
94
|
+
var bootstrapActions = getWalletActions().bootstrap;
|
|
95
|
+
// Helper to update turnkey status in the store
|
|
96
|
+
var setTurnkeyStatus = useCallback(function (status) {
|
|
97
|
+
bootstrapActions.setTurnkeyStatus(status);
|
|
98
|
+
}, [bootstrapActions]);
|
|
99
|
+
var setTurnkeyError = useCallback(function (error) {
|
|
100
|
+
bootstrapActions.setTurnkeyError(error);
|
|
101
|
+
}, [bootstrapActions]);
|
|
102
|
+
// Initialize status based on config
|
|
103
|
+
useEffect(function () {
|
|
104
|
+
if (!turnkeyConfig) {
|
|
105
|
+
setTurnkeyStatus('ready');
|
|
106
|
+
}
|
|
107
|
+
}, [turnkeyConfig, setTurnkeyStatus]);
|
|
108
|
+
// -- Refs --
|
|
109
|
+
var turnkeyClientRef = useRef(null);
|
|
110
|
+
var turnkeyClientInitPromiseRef = useRef(null);
|
|
111
|
+
var bootstrapInFlightRef = useRef(null);
|
|
112
|
+
var authenticatedWalletAddressRef = useRef(null);
|
|
113
|
+
var solanaAccountRef = useRef(null);
|
|
114
|
+
var lastTurnkeyWalletsRef = useRef([]);
|
|
115
|
+
var lastTurnkeyRefreshAtRef = useRef(0);
|
|
116
|
+
// -- Context --
|
|
117
|
+
var walletNetwork = useN1WalletContext().walletNetwork;
|
|
118
|
+
var _g = useNetwork(), evmAddress = _g.evmAddress, evmWallet = _g.evmWallet;
|
|
119
|
+
var _h = useNetworkActions(), setSolanaWallet = _h.setSolanaWallet, setSolanaAddress = _h.setSolanaAddress;
|
|
120
|
+
// -- Helpers --
|
|
121
|
+
var resetTurnkeyState = useCallback(function (options) {
|
|
122
|
+
logger.debug("[Turnkey] Resetting state");
|
|
123
|
+
bootstrapActions.setTurnkeyStatus(turnkeyConfig ? "idle" : "ready");
|
|
124
|
+
bootstrapActions.setTurnkeyError(null);
|
|
125
|
+
setTurnkeyAddress(null);
|
|
126
|
+
setTurnkeySession(null);
|
|
127
|
+
setTurnkeyAuthState(TurnkeyAuthState.Unauthenticated);
|
|
128
|
+
setTurnkeyWallets([]);
|
|
129
|
+
solanaAccountRef.current = null;
|
|
130
|
+
authenticatedWalletAddressRef.current = null;
|
|
131
|
+
if (!(options === null || options === void 0 ? void 0 : options.keepInFlight)) {
|
|
132
|
+
bootstrapInFlightRef.current = null;
|
|
133
|
+
}
|
|
134
|
+
// Clear N1 Context state
|
|
135
|
+
setSolanaWallet(null);
|
|
136
|
+
setSolanaAddress("");
|
|
137
|
+
}, [setSolanaAddress, setSolanaWallet, turnkeyConfig, bootstrapActions]);
|
|
138
|
+
var getTurnkeyClient = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
139
|
+
var _this = this;
|
|
140
|
+
return __generator(this, function (_a) {
|
|
141
|
+
if (!turnkeyConfig)
|
|
142
|
+
throw new Error("Turnkey config missing");
|
|
143
|
+
if (turnkeyClientRef.current)
|
|
144
|
+
return [2 /*return*/, turnkeyClientRef.current];
|
|
145
|
+
if (!turnkeyClientInitPromiseRef.current) {
|
|
146
|
+
turnkeyClientInitPromiseRef.current = (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
147
|
+
var client;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
client = new TurnkeyClient({
|
|
152
|
+
organizationId: turnkeyConfig.organizationId,
|
|
153
|
+
authProxyConfigId: turnkeyConfig.authProxyConfigId,
|
|
154
|
+
authProxyUrl: turnkeyConfig.authProxyUrl,
|
|
155
|
+
apiBaseUrl: turnkeyConfig.apiBaseUrl,
|
|
156
|
+
defaultStamperType: undefined, // We set this explicitly when needed
|
|
157
|
+
walletConfig: {
|
|
158
|
+
features: { auth: true, connecting: true },
|
|
159
|
+
chains: { ethereum: { native: true }, solana: { native: true } },
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
return [4 /*yield*/, client.init()];
|
|
163
|
+
case 1:
|
|
164
|
+
_a.sent();
|
|
165
|
+
turnkeyClientRef.current = client;
|
|
166
|
+
return [2 /*return*/, client];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}); })();
|
|
170
|
+
}
|
|
171
|
+
return [2 /*return*/, turnkeyClientInitPromiseRef.current];
|
|
172
|
+
});
|
|
173
|
+
}); }, [turnkeyConfig]);
|
|
174
|
+
var refreshTurnkeyWallets = useCallback(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
175
|
+
var now, client, wallets, error_1;
|
|
176
|
+
return __generator(this, function (_a) {
|
|
177
|
+
switch (_a.label) {
|
|
178
|
+
case 0:
|
|
179
|
+
now = Date.now();
|
|
180
|
+
// Cache for 5 seconds
|
|
181
|
+
if (!(options === null || options === void 0 ? void 0 : options.force) && now - lastTurnkeyRefreshAtRef.current < 5000 && lastTurnkeyWalletsRef.current.length > 0) {
|
|
182
|
+
return [2 /*return*/, lastTurnkeyWalletsRef.current];
|
|
183
|
+
}
|
|
184
|
+
_a.label = 1;
|
|
185
|
+
case 1:
|
|
186
|
+
_a.trys.push([1, 4, , 5]);
|
|
187
|
+
return [4 /*yield*/, getTurnkeyClient()];
|
|
188
|
+
case 2:
|
|
189
|
+
client = _a.sent();
|
|
190
|
+
return [4 /*yield*/, client.fetchWallets()];
|
|
191
|
+
case 3:
|
|
192
|
+
wallets = _a.sent();
|
|
193
|
+
if (Array.isArray(wallets)) {
|
|
194
|
+
setTurnkeyWallets(wallets);
|
|
195
|
+
lastTurnkeyWalletsRef.current = wallets;
|
|
196
|
+
lastTurnkeyRefreshAtRef.current = now;
|
|
197
|
+
return [2 /*return*/, wallets];
|
|
198
|
+
}
|
|
199
|
+
return [2 /*return*/, []];
|
|
200
|
+
case 4:
|
|
201
|
+
error_1 = _a.sent();
|
|
202
|
+
logger.logError(createTurnkeyError('WALLET_FETCH_FAILED', 'Failed to fetch Turnkey wallets', {
|
|
203
|
+
cause: error_1 instanceof Error ? error_1 : undefined,
|
|
204
|
+
}));
|
|
205
|
+
return [2 /*return*/, []];
|
|
206
|
+
case 5: return [2 /*return*/];
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}); }, [getTurnkeyClient]);
|
|
210
|
+
var signTurnkeyMessage = useCallback(function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
211
|
+
var client;
|
|
212
|
+
return __generator(this, function (_a) {
|
|
213
|
+
switch (_a.label) {
|
|
214
|
+
case 0: return [4 /*yield*/, getTurnkeyClient()];
|
|
215
|
+
case 1:
|
|
216
|
+
client = _a.sent();
|
|
217
|
+
return [4 /*yield*/, client.signMessage(params)];
|
|
218
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}); }, [getTurnkeyClient]);
|
|
222
|
+
var signTurnkeyTransaction = useCallback(function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
223
|
+
var client;
|
|
224
|
+
return __generator(this, function (_a) {
|
|
225
|
+
switch (_a.label) {
|
|
226
|
+
case 0: return [4 /*yield*/, getTurnkeyClient()];
|
|
227
|
+
case 1:
|
|
228
|
+
client = _a.sent();
|
|
229
|
+
return [4 /*yield*/, client.signTransaction(params)];
|
|
230
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}); }, [getTurnkeyClient]);
|
|
234
|
+
// -- Main Logic --
|
|
235
|
+
/**
|
|
236
|
+
* 1. Perform Logout / Cleanup if needed.
|
|
237
|
+
* Returns true if we are clean and ready to proceed with `targetAddress`.
|
|
238
|
+
*/
|
|
239
|
+
var ensureCleanSessionForAddress = function (targetAddress) { return __awaiter(_this, void 0, void 0, function () {
|
|
240
|
+
var isDifferentUser, client, e_1;
|
|
241
|
+
var _a;
|
|
242
|
+
return __generator(this, function (_b) {
|
|
243
|
+
switch (_b.label) {
|
|
244
|
+
case 0:
|
|
245
|
+
isDifferentUser = isSessionForDifferentUser(targetAddress);
|
|
246
|
+
if (!isDifferentUser) return [3 /*break*/, 6];
|
|
247
|
+
logger.debug("[Turnkey] User switch detected, cleaning up", { target: targetAddress });
|
|
248
|
+
_b.label = 1;
|
|
249
|
+
case 1:
|
|
250
|
+
_b.trys.push([1, 4, , 5]);
|
|
251
|
+
return [4 /*yield*/, getTurnkeyClient()];
|
|
252
|
+
case 2:
|
|
253
|
+
client = _b.sent();
|
|
254
|
+
return [4 /*yield*/, ((_a = client.logout) === null || _a === void 0 ? void 0 : _a.call(client))];
|
|
255
|
+
case 3:
|
|
256
|
+
_b.sent();
|
|
257
|
+
return [3 /*break*/, 5];
|
|
258
|
+
case 4:
|
|
259
|
+
e_1 = _b.sent();
|
|
260
|
+
return [3 /*break*/, 5];
|
|
261
|
+
case 5:
|
|
262
|
+
// Pass no address to unconditionally clear the OLD user's session
|
|
263
|
+
// (passing targetAddress would fail because the stored session belongs to the previous user)
|
|
264
|
+
clearSession();
|
|
265
|
+
resetTurnkeyState({ keepInFlight: true });
|
|
266
|
+
StorageService.writeTurnkeyClientAddress(targetAddress);
|
|
267
|
+
return [3 /*break*/, 7];
|
|
268
|
+
case 6:
|
|
269
|
+
if (!StorageService.readTurnkeyClientAddress()) {
|
|
270
|
+
StorageService.writeTurnkeyClientAddress(targetAddress);
|
|
271
|
+
}
|
|
272
|
+
_b.label = 7;
|
|
273
|
+
case 7: return [2 /*return*/];
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}); };
|
|
277
|
+
/**
|
|
278
|
+
* 2. Hydrate Session from Storage
|
|
279
|
+
*/
|
|
280
|
+
var hydrateSession = function (targetAddress) { return __awaiter(_this, void 0, void 0, function () {
|
|
281
|
+
var stored, client, session, error_2;
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0:
|
|
285
|
+
stored = getStoredSession(targetAddress);
|
|
286
|
+
if (!(stored === null || stored === void 0 ? void 0 : stored.sessionKey))
|
|
287
|
+
return [2 /*return*/, null];
|
|
288
|
+
_a.label = 1;
|
|
289
|
+
case 1:
|
|
290
|
+
_a.trys.push([1, 4, , 5]);
|
|
291
|
+
return [4 /*yield*/, getTurnkeyClient()];
|
|
292
|
+
case 2:
|
|
293
|
+
client = _a.sent();
|
|
294
|
+
// Verify if session is still valid? Turnkey client usually handles expiration.
|
|
295
|
+
return [4 /*yield*/, client.setActiveSession({ sessionKey: stored.sessionKey })];
|
|
296
|
+
case 3:
|
|
297
|
+
// Verify if session is still valid? Turnkey client usually handles expiration.
|
|
298
|
+
_a.sent();
|
|
299
|
+
session = __assign({ sessionKey: stored.sessionKey }, stored.session);
|
|
300
|
+
// We assume stored session is valid if we have it
|
|
301
|
+
setTurnkeySession(session);
|
|
302
|
+
setTurnkeyAuthState(TurnkeyAuthState.Authenticated);
|
|
303
|
+
authenticatedWalletAddressRef.current = targetAddress;
|
|
304
|
+
return [2 /*return*/, session];
|
|
305
|
+
case 4:
|
|
306
|
+
error_2 = _a.sent();
|
|
307
|
+
logger.logError(createTurnkeyError('SESSION_INVALID', 'Failed to hydrate Turnkey session', {
|
|
308
|
+
cause: error_2 instanceof Error ? error_2 : undefined,
|
|
309
|
+
context: { targetAddress: targetAddress },
|
|
310
|
+
}));
|
|
311
|
+
clearSession(targetAddress); // Clear invalid session
|
|
312
|
+
return [2 /*return*/, null];
|
|
313
|
+
case 5: return [2 /*return*/];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}); };
|
|
317
|
+
/**
|
|
318
|
+
* 3. Login (if not hydrated)
|
|
319
|
+
*/
|
|
320
|
+
var performLogin = function (wallet, targetAddress) { return __awaiter(_this, void 0, void 0, function () {
|
|
321
|
+
var client, previousStamper, walletProvider, expirationSeconds, sessionKey, sessionResponse, session, error_3;
|
|
322
|
+
var _a;
|
|
323
|
+
return __generator(this, function (_b) {
|
|
324
|
+
switch (_b.label) {
|
|
325
|
+
case 0:
|
|
326
|
+
setTurnkeyAuthState(TurnkeyAuthState.Authenticating);
|
|
327
|
+
logger.event(createTurnkeyEvent(EVENTS.TURNKEY.AUTH_START, {
|
|
328
|
+
evmAddress: targetAddress,
|
|
329
|
+
}));
|
|
330
|
+
return [4 /*yield*/, getTurnkeyClient()];
|
|
331
|
+
case 1:
|
|
332
|
+
client = _b.sent();
|
|
333
|
+
previousStamper = client.httpClient.defaultStamperType;
|
|
334
|
+
client.httpClient.defaultStamperType = StamperType.Wallet;
|
|
335
|
+
_b.label = 2;
|
|
336
|
+
case 2:
|
|
337
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
338
|
+
logger.debug("[Turnkey] [performLogin] Building wallet provider", { targetAddress: targetAddress });
|
|
339
|
+
return [4 /*yield*/, buildWalletProvider(wallet)];
|
|
340
|
+
case 3:
|
|
341
|
+
walletProvider = _b.sent();
|
|
342
|
+
expirationSeconds = (_a = turnkeyConfig === null || turnkeyConfig === void 0 ? void 0 : turnkeyConfig.sessionExpirationSeconds) !== null && _a !== void 0 ? _a : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
|
|
343
|
+
logger.debug("[Turnkey] [performLogin] Calling loginOrSignupWithWallet", { expirationSeconds: expirationSeconds });
|
|
344
|
+
return [4 /*yield*/, client.loginOrSignupWithWallet({
|
|
345
|
+
walletProvider: walletProvider,
|
|
346
|
+
expirationSeconds: expirationSeconds,
|
|
347
|
+
})];
|
|
348
|
+
case 4:
|
|
349
|
+
_b.sent();
|
|
350
|
+
logger.debug("[Turnkey] [performLogin] loginOrSignupWithWallet completed successfully");
|
|
351
|
+
return [4 /*yield*/, client.getActiveSessionKey()];
|
|
352
|
+
case 5:
|
|
353
|
+
sessionKey = _b.sent();
|
|
354
|
+
if (!sessionKey) {
|
|
355
|
+
logger.logError(createTurnkeyError('SESSION_INVALID', 'No session key after login'));
|
|
356
|
+
throw new Error("No session key after login");
|
|
357
|
+
}
|
|
358
|
+
logger.debug("[Turnkey] [performLogin] Got session key", { sessionKey: sessionKey.substring(0, 10) + "..." });
|
|
359
|
+
return [4 /*yield*/, client.getSession({ sessionKey: sessionKey })];
|
|
360
|
+
case 6:
|
|
361
|
+
sessionResponse = _b.sent();
|
|
362
|
+
session = __assign(__assign({}, sessionResponse), { sessionKey: sessionKey });
|
|
363
|
+
storeSession(targetAddress, sessionKey, {
|
|
364
|
+
evmAddress: targetAddress,
|
|
365
|
+
session: session,
|
|
366
|
+
});
|
|
367
|
+
setTurnkeySession(session);
|
|
368
|
+
setTurnkeyAuthState(TurnkeyAuthState.Authenticated);
|
|
369
|
+
authenticatedWalletAddressRef.current = targetAddress;
|
|
370
|
+
logger.event(createTurnkeyEvent(EVENTS.TURNKEY.AUTH_SUCCESS, {
|
|
371
|
+
evmAddress: targetAddress,
|
|
372
|
+
}));
|
|
373
|
+
return [2 /*return*/, session];
|
|
374
|
+
case 7:
|
|
375
|
+
error_3 = _b.sent();
|
|
376
|
+
// Log the error with context about where it occurred
|
|
377
|
+
logger.event(createTurnkeyEvent(EVENTS.TURNKEY.AUTH_FAILED, {
|
|
378
|
+
evmAddress: targetAddress,
|
|
379
|
+
errorCode: error_3 === null || error_3 === void 0 ? void 0 : error_3.code,
|
|
380
|
+
}));
|
|
381
|
+
logger.logError(createTurnkeyError('AUTH_FAILED', error_3 instanceof Error ? error_3.message : 'Login failed', {
|
|
382
|
+
cause: error_3 instanceof Error ? error_3 : undefined,
|
|
383
|
+
context: {
|
|
384
|
+
errorCode: error_3 === null || error_3 === void 0 ? void 0 : error_3.code,
|
|
385
|
+
errorName: error_3 === null || error_3 === void 0 ? void 0 : error_3.name,
|
|
386
|
+
targetAddress: targetAddress,
|
|
387
|
+
},
|
|
388
|
+
}));
|
|
389
|
+
throw error_3; // Re-throw to be handled by bootstrap error handler
|
|
390
|
+
case 8:
|
|
391
|
+
client.httpClient.defaultStamperType = previousStamper;
|
|
392
|
+
return [7 /*endfinally*/];
|
|
393
|
+
case 9: return [2 /*return*/];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}); };
|
|
397
|
+
/**
|
|
398
|
+
* 4. Ensure Solana Account
|
|
399
|
+
*/
|
|
400
|
+
var ensureSolanaWallet = function (targetAddress) { return __awaiter(_this, void 0, void 0, function () {
|
|
401
|
+
var cachedSolana, syntheticAccount, syntheticWallet, wallet, wallets, existing, client, previousStamper, walletId_1, error_4, account, turnkeyWallet;
|
|
402
|
+
var _a, _b;
|
|
403
|
+
return __generator(this, function (_c) {
|
|
404
|
+
switch (_c.label) {
|
|
405
|
+
case 0:
|
|
406
|
+
// Use cached if available
|
|
407
|
+
if (solanaAccountRef.current)
|
|
408
|
+
return [2 /*return*/, solanaAccountRef.current];
|
|
409
|
+
cachedSolana = getCachedSolanaAccount(targetAddress);
|
|
410
|
+
if ((_a = cachedSolana === null || cachedSolana === void 0 ? void 0 : cachedSolana.account) === null || _a === void 0 ? void 0 : _a.address) {
|
|
411
|
+
syntheticAccount = __assign(__assign({}, cachedSolana.account), { addressFormat: SOLANA_ADDRESS_FORMAT, walletId: cachedSolana.walletId });
|
|
412
|
+
syntheticWallet = {
|
|
413
|
+
walletId: cachedSolana.walletId,
|
|
414
|
+
walletName: TURNKEY_WALLET_NAME,
|
|
415
|
+
accounts: [syntheticAccount],
|
|
416
|
+
};
|
|
417
|
+
wallet = createTurnkeySolanaWallet({
|
|
418
|
+
walletAccount: syntheticAccount,
|
|
419
|
+
signMessage: signTurnkeyMessage,
|
|
420
|
+
signTransaction: signTurnkeyTransaction,
|
|
421
|
+
});
|
|
422
|
+
solanaAccountRef.current = { wallet: syntheticWallet, account: syntheticAccount };
|
|
423
|
+
setSolanaWallet(wallet);
|
|
424
|
+
setSolanaAddress(syntheticAccount.address);
|
|
425
|
+
setTurnkeyAddress(syntheticAccount.address);
|
|
426
|
+
return [2 /*return*/];
|
|
427
|
+
}
|
|
428
|
+
return [4 /*yield*/, refreshTurnkeyWallets({ force: true })];
|
|
429
|
+
case 1:
|
|
430
|
+
wallets = _c.sent();
|
|
431
|
+
existing = wallets.find(function (w) {
|
|
432
|
+
var _a;
|
|
433
|
+
return w.walletName === TURNKEY_WALLET_NAME &&
|
|
434
|
+
((_a = w.accounts) === null || _a === void 0 ? void 0 : _a.some(function (a) { return a.addressFormat === SOLANA_ADDRESS_FORMAT; }));
|
|
435
|
+
});
|
|
436
|
+
if (!!existing) return [3 /*break*/, 7];
|
|
437
|
+
return [4 /*yield*/, getTurnkeyClient()];
|
|
438
|
+
case 2:
|
|
439
|
+
client = _c.sent();
|
|
440
|
+
previousStamper = client.httpClient.defaultStamperType;
|
|
441
|
+
_c.label = 3;
|
|
442
|
+
case 3:
|
|
443
|
+
_c.trys.push([3, 6, , 7]);
|
|
444
|
+
return [4 /*yield*/, client.createWallet({
|
|
445
|
+
walletName: TURNKEY_WALLET_NAME,
|
|
446
|
+
accounts: [SOLANA_ADDRESS_FORMAT],
|
|
447
|
+
})];
|
|
448
|
+
case 4:
|
|
449
|
+
walletId_1 = _c.sent();
|
|
450
|
+
logger.event(createTurnkeyEvent(EVENTS.TURNKEY.WALLET_CREATE, {
|
|
451
|
+
walletId: walletId_1,
|
|
452
|
+
evmAddress: targetAddress,
|
|
453
|
+
}));
|
|
454
|
+
return [4 /*yield*/, refreshTurnkeyWallets({ force: true })];
|
|
455
|
+
case 5:
|
|
456
|
+
wallets = _c.sent();
|
|
457
|
+
existing = wallets.find(function (w) { return w.walletId === walletId_1; });
|
|
458
|
+
return [3 /*break*/, 7];
|
|
459
|
+
case 6:
|
|
460
|
+
error_4 = _c.sent();
|
|
461
|
+
logger.logError(createTurnkeyError('WALLET_CREATE_FAILED', 'Failed to create Turnkey wallet', {
|
|
462
|
+
cause: error_4 instanceof Error ? error_4 : undefined,
|
|
463
|
+
context: { targetAddress: targetAddress },
|
|
464
|
+
}));
|
|
465
|
+
throw error_4;
|
|
466
|
+
case 7:
|
|
467
|
+
if (!existing)
|
|
468
|
+
throw new Error("Failed to find or create Solana wallet");
|
|
469
|
+
account = (_b = existing.accounts) === null || _b === void 0 ? void 0 : _b.find(function (a) { return a.addressFormat === SOLANA_ADDRESS_FORMAT; });
|
|
470
|
+
if (!account)
|
|
471
|
+
throw new Error("Wallet created but missing Solana account");
|
|
472
|
+
// Update Storage using service helper
|
|
473
|
+
updateSessionSolanaAccount(targetAddress, {
|
|
474
|
+
walletId: existing.walletId,
|
|
475
|
+
account: { address: account.address, addressFormat: account.addressFormat }
|
|
476
|
+
});
|
|
477
|
+
turnkeyWallet = createTurnkeySolanaWallet({
|
|
478
|
+
walletAccount: account,
|
|
479
|
+
signMessage: signTurnkeyMessage,
|
|
480
|
+
signTransaction: signTurnkeyTransaction,
|
|
481
|
+
});
|
|
482
|
+
solanaAccountRef.current = { wallet: existing, account: account };
|
|
483
|
+
setSolanaWallet(turnkeyWallet);
|
|
484
|
+
setSolanaAddress(account.address);
|
|
485
|
+
setTurnkeyAddress(account.address);
|
|
486
|
+
return [2 /*return*/];
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}); };
|
|
490
|
+
// -- Bootstrap Effect --
|
|
491
|
+
useEffect(function () {
|
|
492
|
+
var bootstrap = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
493
|
+
var targetAddress, shouldReset;
|
|
494
|
+
var _this = this;
|
|
495
|
+
return __generator(this, function (_a) {
|
|
496
|
+
switch (_a.label) {
|
|
497
|
+
case 0:
|
|
498
|
+
targetAddress = normalizeAddress(evmAddress);
|
|
499
|
+
// DEBUG: Log all inputs to bootstrap effect
|
|
500
|
+
logger.debug("[Turnkey] Bootstrap effect running", {
|
|
501
|
+
hasConfig: !!turnkeyConfig,
|
|
502
|
+
walletNetwork: walletNetwork,
|
|
503
|
+
hasEvmWallet: !!evmWallet,
|
|
504
|
+
evmWalletAddress: evmWallet === null || evmWallet === void 0 ? void 0 : evmWallet.address,
|
|
505
|
+
targetAddress: targetAddress,
|
|
506
|
+
turnkeyStatus: turnkeyStatus,
|
|
507
|
+
hasBootstrapInFlight: !!bootstrapInFlightRef.current,
|
|
508
|
+
authenticatedAddress: authenticatedWalletAddressRef.current,
|
|
509
|
+
hasSolanaAccount: !!solanaAccountRef.current,
|
|
510
|
+
});
|
|
511
|
+
// 1. Pre-flight checks
|
|
512
|
+
if (!turnkeyConfig || walletNetwork !== 'evm' || !evmWallet || !targetAddress) {
|
|
513
|
+
shouldReset = !bootstrapInFlightRef.current &&
|
|
514
|
+
((turnkeyStatus !== 'idle' && turnkeyStatus !== 'ready' && turnkeyStatus !== 'error') ||
|
|
515
|
+
(turnkeyStatus === 'ready' && !evmWallet));
|
|
516
|
+
logger.debug("[Turnkey] Pre-flight failed", {
|
|
517
|
+
reason: !turnkeyConfig ? 'no config' : walletNetwork !== 'evm' ? "walletNetwork=".concat(walletNetwork) : !evmWallet ? 'no evmWallet' : 'no targetAddress',
|
|
518
|
+
shouldReset: shouldReset,
|
|
519
|
+
turnkeyStatus: turnkeyStatus,
|
|
520
|
+
});
|
|
521
|
+
if (shouldReset) {
|
|
522
|
+
resetTurnkeyState();
|
|
523
|
+
}
|
|
524
|
+
return [2 /*return*/];
|
|
525
|
+
}
|
|
526
|
+
// If we are already ready and address hasn't changed, do nothing
|
|
527
|
+
if (turnkeyStatus === 'ready' && authenticatedWalletAddressRef.current === targetAddress && solanaAccountRef.current) {
|
|
528
|
+
logger.debug("[Turnkey] Already ready, skipping");
|
|
529
|
+
return [2 /*return*/];
|
|
530
|
+
}
|
|
531
|
+
// Prevent concurrent runs
|
|
532
|
+
if (bootstrapInFlightRef.current) {
|
|
533
|
+
logger.debug("[Turnkey] Bootstrap in flight, skipping");
|
|
534
|
+
return [2 /*return*/];
|
|
535
|
+
}
|
|
536
|
+
// Only start bootstrap if status is 'idle' (initial or after reset)
|
|
537
|
+
// Skip if status is 'authenticating', 'creating', or 'error' - these are handled elsewhere
|
|
538
|
+
if (turnkeyStatus !== 'idle') {
|
|
539
|
+
logger.debug("[Turnkey] Status not idle, skipping", { turnkeyStatus: turnkeyStatus });
|
|
540
|
+
return [2 /*return*/];
|
|
541
|
+
}
|
|
542
|
+
logger.debug("[Turnkey] Starting bootstrap - setting authenticating");
|
|
543
|
+
setTurnkeyStatus("authenticating");
|
|
544
|
+
setTurnkeyError(null);
|
|
545
|
+
bootstrapInFlightRef.current = (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
546
|
+
var session, error_5, errorMessage, isUserRejection;
|
|
547
|
+
return __generator(this, function (_a) {
|
|
548
|
+
switch (_a.label) {
|
|
549
|
+
case 0:
|
|
550
|
+
_a.trys.push([0, 7, 8, 9]);
|
|
551
|
+
logger.debug("[Turnkey] Starting bootstrap", { targetAddress: targetAddress });
|
|
552
|
+
// 2. Ensure Clean Session
|
|
553
|
+
return [4 /*yield*/, ensureCleanSessionForAddress(targetAddress)];
|
|
554
|
+
case 1:
|
|
555
|
+
// 2. Ensure Clean Session
|
|
556
|
+
_a.sent();
|
|
557
|
+
session = null;
|
|
558
|
+
if (!hasStoredSession(targetAddress)) return [3 /*break*/, 3];
|
|
559
|
+
setIsHydratingSession(true);
|
|
560
|
+
return [4 /*yield*/, hydrateSession(targetAddress)];
|
|
561
|
+
case 2:
|
|
562
|
+
session = _a.sent();
|
|
563
|
+
setIsHydratingSession(false);
|
|
564
|
+
_a.label = 3;
|
|
565
|
+
case 3:
|
|
566
|
+
if (!!session) return [3 /*break*/, 5];
|
|
567
|
+
logger.debug("[Turnkey] No session, logging in...");
|
|
568
|
+
return [4 /*yield*/, performLogin(evmWallet, targetAddress)];
|
|
569
|
+
case 4:
|
|
570
|
+
session = _a.sent();
|
|
571
|
+
_a.label = 5;
|
|
572
|
+
case 5:
|
|
573
|
+
if (!session)
|
|
574
|
+
throw new Error("Failed to establish session");
|
|
575
|
+
// 4. Provision Solana Wallet
|
|
576
|
+
setTurnkeyStatus("creating");
|
|
577
|
+
return [4 /*yield*/, ensureSolanaWallet(targetAddress)];
|
|
578
|
+
case 6:
|
|
579
|
+
_a.sent();
|
|
580
|
+
setTurnkeyStatus("ready");
|
|
581
|
+
logger.debug("[Turnkey] Bootstrap complete");
|
|
582
|
+
return [3 /*break*/, 9];
|
|
583
|
+
case 7:
|
|
584
|
+
error_5 = _a.sent();
|
|
585
|
+
errorMessage = error_5 instanceof Error ? error_5.message : 'Turnkey bootstrap failed';
|
|
586
|
+
isUserRejection = isUserRejectedError(error_5);
|
|
587
|
+
logger.logError(createTurnkeyError('BOOTSTRAP_FAILED', errorMessage, {
|
|
588
|
+
cause: error_5 instanceof Error ? error_5 : undefined,
|
|
589
|
+
context: {
|
|
590
|
+
targetAddress: targetAddress,
|
|
591
|
+
errorCode: error_5 === null || error_5 === void 0 ? void 0 : error_5.code,
|
|
592
|
+
errorName: error_5 === null || error_5 === void 0 ? void 0 : error_5.name,
|
|
593
|
+
isUserRejection: isUserRejection,
|
|
594
|
+
},
|
|
595
|
+
}));
|
|
596
|
+
// Set error state so UI can show retry/disconnect options
|
|
597
|
+
setTurnkeyStatus('error');
|
|
598
|
+
setTurnkeyError(isUserRejection
|
|
599
|
+
? 'Signature request was cancelled. Please try again.'
|
|
600
|
+
: errorMessage);
|
|
601
|
+
return [3 /*break*/, 9];
|
|
602
|
+
case 8:
|
|
603
|
+
bootstrapInFlightRef.current = null;
|
|
604
|
+
setIsHydratingSession(false);
|
|
605
|
+
return [7 /*endfinally*/];
|
|
606
|
+
case 9: return [2 /*return*/];
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
}); })();
|
|
610
|
+
return [4 /*yield*/, bootstrapInFlightRef.current];
|
|
611
|
+
case 1:
|
|
612
|
+
_a.sent();
|
|
613
|
+
return [2 /*return*/];
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}); };
|
|
617
|
+
bootstrap();
|
|
618
|
+
}, [evmAddress, walletNetwork, evmWallet, turnkeyConfig, turnkeyStatus]); // Added turnkeyStatus to trigger bootstrap on retry
|
|
619
|
+
// -- Exposed API --
|
|
620
|
+
var waitForSessionHydration = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
621
|
+
return __generator(this, function (_a) {
|
|
622
|
+
switch (_a.label) {
|
|
623
|
+
case 0:
|
|
624
|
+
if (!bootstrapInFlightRef.current) return [3 /*break*/, 2];
|
|
625
|
+
return [4 /*yield*/, bootstrapInFlightRef.current];
|
|
626
|
+
case 1:
|
|
627
|
+
_a.sent();
|
|
628
|
+
_a.label = 2;
|
|
629
|
+
case 2: return [2 /*return*/];
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
}); }, []);
|
|
633
|
+
var createTurnkeyWallet = useCallback(function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
634
|
+
var client;
|
|
635
|
+
return __generator(this, function (_a) {
|
|
636
|
+
switch (_a.label) {
|
|
637
|
+
case 0: return [4 /*yield*/, getTurnkeyClient()];
|
|
638
|
+
case 1:
|
|
639
|
+
client = _a.sent();
|
|
640
|
+
return [4 /*yield*/, client.createWallet(params)];
|
|
641
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
}); }, [getTurnkeyClient]);
|
|
645
|
+
var retryTurnkeyBootstrap = useCallback(function () {
|
|
646
|
+
resetTurnkeyState(); // This will trigger the effect again as dependencies change or we reset
|
|
647
|
+
}, [resetTurnkeyState]);
|
|
648
|
+
var turnkeyContextValue = useMemo(function () { return ({
|
|
649
|
+
turnkeyAuthState: turnkeyAuthState,
|
|
650
|
+
turnkeySession: turnkeySession,
|
|
651
|
+
turnkeyWallets: turnkeyWallets,
|
|
652
|
+
isHydratingSession: isHydratingSession,
|
|
653
|
+
turnkeyStatus: turnkeyStatus,
|
|
654
|
+
turnkeyError: turnkeyError,
|
|
655
|
+
turnkeyAddress: turnkeyAddress,
|
|
656
|
+
createTurnkeyWallet: createTurnkeyWallet,
|
|
657
|
+
refreshTurnkeyWallets: refreshTurnkeyWallets,
|
|
658
|
+
signTurnkeyMessage: signTurnkeyMessage,
|
|
659
|
+
waitForSessionHydration: waitForSessionHydration,
|
|
660
|
+
loginWithTurnkeyWallet: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
661
|
+
return [2 /*return*/];
|
|
662
|
+
}); }); },
|
|
663
|
+
prepareTurnkeyWallet: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
664
|
+
return [2 /*return*/];
|
|
665
|
+
}); }); },
|
|
666
|
+
retryTurnkeyBootstrap: retryTurnkeyBootstrap,
|
|
667
|
+
}); }, [
|
|
668
|
+
turnkeyAuthState,
|
|
669
|
+
turnkeySession,
|
|
670
|
+
turnkeyWallets,
|
|
671
|
+
isHydratingSession,
|
|
672
|
+
turnkeyStatus,
|
|
673
|
+
turnkeyError,
|
|
674
|
+
turnkeyAddress,
|
|
675
|
+
createTurnkeyWallet,
|
|
676
|
+
refreshTurnkeyWallets,
|
|
677
|
+
signTurnkeyMessage,
|
|
678
|
+
waitForSessionHydration,
|
|
679
|
+
retryTurnkeyBootstrap,
|
|
680
|
+
]);
|
|
681
|
+
if (!turnkeyConfig)
|
|
682
|
+
return _jsx(_Fragment, { children: children });
|
|
683
|
+
return (_jsx(TurnkeyContext.Provider, { value: turnkeyContextValue, children: children }));
|
|
684
|
+
}
|
|
685
|
+
export var useTurnkey = function () {
|
|
686
|
+
var context = useContext(TurnkeyContext);
|
|
687
|
+
if (!context) {
|
|
688
|
+
throw new Error("useTurnkey must be used within a TurnkeyProvider");
|
|
689
|
+
}
|
|
690
|
+
return context;
|
|
691
|
+
};
|
|
692
|
+
export var useTurnkeyUnsafe = function () {
|
|
693
|
+
return useContext(TurnkeyContext);
|
|
694
|
+
};
|
|
695
|
+
//# sourceMappingURL=TurnkeyProvider.js.map
|