@n1xyz/wallet-widget 0.0.1 → 0.0.5
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/LICENSE +44 -0
- package/README.md +210 -0
- package/dist/Logic/sessionManager.d.ts +53 -0
- package/dist/Logic/sessionManager.js +178 -0
- package/dist/Logic/transactionManager.d.ts +41 -0
- package/dist/Logic/transactionManager.js +192 -0
- package/dist/Logic/utils.d.ts +1 -0
- package/dist/Logic/utils.js +47 -9
- package/dist/Modal/BackButton.js +14 -1
- package/dist/Modal/ConnectView.js +20 -23
- package/dist/Modal/CreateSessionView.js +23 -11
- package/dist/Modal/CreateUserView.js +1 -1
- package/dist/Modal/LoadingFallback.d.ts +2 -0
- package/dist/Modal/LoadingFallback.js +2 -0
- package/dist/Modal/ModalHeader.js +14 -3
- package/dist/Modal/N1WalletModal.js +91 -79
- package/dist/Modal/NTSFlow/LoadingFallback.d.ts +2 -0
- package/dist/Modal/NTSFlow/LoadingFallback.js +2 -0
- package/dist/Modal/NTSFlow/NTSFlow.d.ts +4 -0
- package/dist/Modal/NTSFlow/NTSFlow.js +30 -0
- package/dist/Modal/NTSFlow/NordFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/Modal/NTSFlow/NordFlow/WalletConnectionFlow.js +145 -0
- package/dist/Modal/NTSFlow/NordFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/Modal/NTSFlow/NordFlow/components/AnimatedButton.js +75 -0
- package/dist/Modal/NTSFlow/NordFlow/components/ChainButton.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/components/ChainButton.js +5 -0
- package/dist/Modal/NTSFlow/NordFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/Modal/NTSFlow/NordFlow/components/LoadingSquares.js +5 -0
- package/dist/Modal/NTSFlow/NordFlow/components/TransactionTable.d.ts +13 -0
- package/dist/Modal/NTSFlow/NordFlow/components/TransactionTable.js +58 -0
- package/dist/Modal/NTSFlow/NordFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/components/WaitingMessage.js +6 -0
- package/dist/Modal/NTSFlow/NordFlow/components/index.d.ts +5 -0
- package/dist/Modal/NTSFlow/NordFlow/components/index.js +5 -0
- package/dist/Modal/NTSFlow/NordFlow/constants.d.ts +37 -0
- package/dist/Modal/NTSFlow/NordFlow/constants.js +223 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/index.d.ts +8 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/index.js +8 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useButtonTyping.js +43 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useDepositFlow.d.ts +38 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useDepositFlow.js +166 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useFlowState.js +163 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useInterruptHandler.d.ts +27 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useInterruptHandler.js +101 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useNordSession.js +193 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useTableValues.js +69 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWalletConnect.d.ts +30 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWalletConnect.js +132 -0
- package/dist/Modal/NTSFlow/NordFlow/index.d.ts +3 -0
- package/dist/Modal/NTSFlow/NordFlow/index.js +3 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/03-ChainSelectionScreen.js +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/04-AmountInputScreen.d.ts +8 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/04-AmountInputScreen.js +20 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/05-DepositProgressScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/05-DepositProgressScreen.js +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/06-DepositSuccessScreen.js +99 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/07-NordAuthScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/07-NordAuthScreen.js +14 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/08-AuthLoadingScreen.js +20 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/09-FinalSuccessScreen.js +18 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/10-ErrorScreen.js +13 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/index.d.ts +10 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/index.js +10 -0
- package/dist/Modal/NTSFlow/NordFlow/types.d.ts +105 -0
- package/dist/Modal/NTSFlow/NordFlow/types.js +34 -0
- package/dist/Modal/NTSFlow/NordFlow/utils/persistence.d.ts +24 -0
- package/dist/Modal/NTSFlow/NordFlow/utils/persistence.js +83 -0
- package/dist/Modal/NTSFlow/components/BackButton.d.ts +3 -0
- package/dist/Modal/NTSFlow/components/BackButton.js +26 -0
- package/dist/Modal/NTSFlow/components/ModalHeader.d.ts +1 -0
- package/dist/Modal/NTSFlow/components/ModalHeader.js +20 -0
- package/dist/Modal/NTSFlow/index.d.ts +1 -0
- package/dist/Modal/NTSFlow/index.js +1 -0
- package/dist/Modal/NTSFlow/views/ConnectView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/ConnectView.js +68 -0
- package/dist/Modal/NTSFlow/views/CreateSessionView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/CreateSessionView.js +245 -0
- package/dist/Modal/NTSFlow/views/CreateUserView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/CreateUserView.js +105 -0
- package/dist/Modal/NTSFlow/views/NoWhitelistView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/NoWhitelistView.js +42 -0
- package/dist/Modal/NTSFlow/views/SigningView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/SigningView.js +5 -0
- package/dist/Modal/NTSFlow/views/SuccessView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/SuccessView.js +10 -0
- package/dist/Modal/NoWhitelistView.js +14 -1
- package/dist/Modal/NordFlow/NordFlow.d.ts +9 -0
- package/dist/Modal/NordFlow/NordFlow.js +262 -0
- package/dist/Modal/NordFlow/NordFlowWrapper.d.ts +11 -0
- package/dist/Modal/NordFlow/NordFlowWrapper.js +11 -0
- package/dist/Modal/NordFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/Modal/NordFlow/WalletConnectionFlow.js +145 -0
- package/dist/Modal/NordFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/Modal/NordFlow/components/AnimatedButton.js +75 -0
- package/dist/Modal/NordFlow/components/ChainButton.d.ts +8 -0
- package/dist/Modal/NordFlow/components/ChainButton.js +21 -0
- package/dist/Modal/NordFlow/components/ImageWithFallback.d.ts +17 -0
- package/dist/Modal/NordFlow/components/ImageWithFallback.js +32 -0
- package/dist/Modal/NordFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/Modal/NordFlow/components/LoadingSquares.js +5 -0
- package/dist/Modal/NordFlow/components/TransactionTable.d.ts +13 -0
- package/dist/Modal/NordFlow/components/TransactionTable.js +83 -0
- package/dist/Modal/NordFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/Modal/NordFlow/components/WaitingMessage.js +6 -0
- package/dist/Modal/NordFlow/components/index.d.ts +5 -0
- package/dist/Modal/NordFlow/components/index.js +5 -0
- package/dist/Modal/NordFlow/constants.d.ts +37 -0
- package/dist/Modal/NordFlow/constants.js +192 -0
- package/dist/Modal/NordFlow/hoc/index.d.ts +1 -0
- package/dist/Modal/NordFlow/hoc/index.js +1 -0
- package/dist/Modal/NordFlow/hoc/withImageFallback.d.ts +7 -0
- package/dist/Modal/NordFlow/hoc/withImageFallback.js +60 -0
- package/dist/Modal/NordFlow/hooks/index.d.ts +5 -0
- package/dist/Modal/NordFlow/hooks/index.js +5 -0
- package/dist/Modal/NordFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/Modal/NordFlow/hooks/useButtonTyping.js +43 -0
- package/dist/Modal/NordFlow/hooks/useDepositFlow.d.ts +52 -0
- package/dist/Modal/NordFlow/hooks/useDepositFlow.js +365 -0
- package/dist/Modal/NordFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/Modal/NordFlow/hooks/useFlowState.js +166 -0
- package/dist/Modal/NordFlow/hooks/useInterruptHandler.d.ts +24 -0
- package/dist/Modal/NordFlow/hooks/useInterruptHandler.js +56 -0
- package/dist/Modal/NordFlow/hooks/useNordInstance.d.ts +10 -0
- package/dist/Modal/NordFlow/hooks/useNordInstance.js +310 -0
- package/dist/Modal/NordFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/Modal/NordFlow/hooks/useNordSession.js +391 -0
- package/dist/Modal/NordFlow/hooks/useNordWalletConnect.d.ts +14 -0
- package/dist/Modal/NordFlow/hooks/useNordWalletConnect.js +231 -0
- package/dist/Modal/NordFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/Modal/NordFlow/hooks/useTableValues.js +69 -0
- package/dist/Modal/NordFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/Modal/NordFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/Modal/NordFlow/hooks/useWalletConnect.d.ts +14 -0
- package/dist/Modal/NordFlow/hooks/useWalletConnect.js +221 -0
- package/dist/Modal/NordFlow/index copy.d.ts +1 -0
- package/dist/Modal/NordFlow/index copy.js +1 -0
- package/dist/Modal/NordFlow/index.d.ts +1 -0
- package/dist/Modal/NordFlow/index.js +1 -0
- package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.js +47 -0
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.d.ts +10 -0
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js +165 -0
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js +44 -0
- package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js +119 -0
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js +126 -0
- package/dist/Modal/NordFlow/screens/07-NordAuthScreen.d.ts +5 -0
- package/dist/Modal/NordFlow/screens/07-NordAuthScreen.js +17 -0
- package/dist/Modal/NordFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/08-AuthLoadingScreen.js +153 -0
- package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.d.ts +5 -0
- package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.js +36 -0
- package/dist/Modal/NordFlow/screens/09-ErrorScreen.d.ts +7 -0
- package/dist/Modal/NordFlow/screens/09-ErrorScreen.js +62 -0
- package/dist/Modal/NordFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/Modal/NordFlow/screens/09-FinalSuccessScreen.js +47 -0
- package/dist/Modal/NordFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/Modal/NordFlow/screens/10-ErrorScreen.js +62 -0
- package/dist/Modal/NordFlow/screens/index.d.ts +9 -0
- package/dist/Modal/NordFlow/screens/index.js +9 -0
- package/dist/Modal/NordFlow/types.d.ts +108 -0
- package/dist/Modal/NordFlow/types.js +32 -0
- package/dist/Modal/NordFlow/utils/imageUtils.d.ts +21 -0
- package/dist/Modal/NordFlow/utils/imageUtils.js +109 -0
- package/dist/Modal/NordFlow/utils/index.d.ts +3 -0
- package/dist/Modal/NordFlow/utils/index.js +3 -0
- package/dist/Modal/NordFlow/utils/nordUtils.d.ts +40 -0
- package/dist/Modal/NordFlow/utils/nordUtils.js +61 -0
- package/dist/Modal/NordFlow/utils/persistence.d.ts +24 -0
- package/dist/Modal/NordFlow/utils/persistence.js +83 -0
- package/dist/Modal/Sidebar/N1Sidebar.js +167 -14
- package/dist/Modal/Sidebar/NordTradingView/AccountSummary/AccountSummary.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/AccountSummary/AccountSummary.js +116 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketOverview.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketOverview.js +86 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.d.ts +6 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.js +38 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketStats.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketStats.js +15 -0
- package/dist/Modal/Sidebar/NordTradingView/NordTradingView.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/NordTradingView.js +54 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBook.d.ts +5 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBook.js +197 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookDepthVisualizer.d.ts +10 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookDepthVisualizer.js +61 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.js +28 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.d.ts +11 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.js +22 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/AmountInput.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/AmountInput.js +19 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/BuySellTabs.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/BuySellTabs.js +23 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.js +76 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.d.ts +9 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.js +103 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/PriceInput.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/PriceInput.js +29 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.d.ts +9 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.js +39 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.js +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.d.ts +8 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.js +249 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeHistory/TradeHistory.d.ts +5 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeHistory/TradeHistory.js +138 -0
- package/dist/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.js +108 -0
- package/dist/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.js +177 -0
- package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.js +188 -0
- package/dist/Modal/SigningView.js +1 -1
- package/dist/NordFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/NordFlow/WalletConnectionFlow.js +145 -0
- package/dist/NordFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/NordFlow/components/AnimatedButton.js +75 -0
- package/dist/NordFlow/components/ChainButton.d.ts +7 -0
- package/dist/NordFlow/components/ChainButton.js +5 -0
- package/dist/NordFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/NordFlow/components/LoadingSquares.js +5 -0
- package/dist/NordFlow/components/TransactionTable.d.ts +13 -0
- package/dist/NordFlow/components/TransactionTable.js +58 -0
- package/dist/NordFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/NordFlow/components/WaitingMessage.js +6 -0
- package/dist/NordFlow/components/index.d.ts +5 -0
- package/dist/NordFlow/components/index.js +5 -0
- package/dist/NordFlow/constants.d.ts +37 -0
- package/dist/NordFlow/constants.js +223 -0
- package/dist/NordFlow/hooks/index.d.ts +8 -0
- package/dist/NordFlow/hooks/index.js +8 -0
- package/dist/NordFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/NordFlow/hooks/useButtonTyping.js +43 -0
- package/dist/NordFlow/hooks/useDepositFlow.d.ts +38 -0
- package/dist/NordFlow/hooks/useDepositFlow.js +166 -0
- package/dist/NordFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/NordFlow/hooks/useFlowState.js +163 -0
- package/dist/NordFlow/hooks/useInterruptHandler.d.ts +27 -0
- package/dist/NordFlow/hooks/useInterruptHandler.js +101 -0
- package/dist/NordFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/NordFlow/hooks/useNordSession.js +193 -0
- package/dist/NordFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/NordFlow/hooks/useTableValues.js +69 -0
- package/dist/NordFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/NordFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/NordFlow/hooks/useWalletConnect.d.ts +30 -0
- package/dist/NordFlow/hooks/useWalletConnect.js +132 -0
- package/dist/NordFlow/index.d.ts +3 -0
- package/dist/NordFlow/index.js +3 -0
- package/dist/NordFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/NordFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/NordFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/NordFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/NordFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/NordFlow/screens/03-ChainSelectionScreen.js +7 -0
- package/dist/NordFlow/screens/04-AmountInputScreen.d.ts +8 -0
- package/dist/NordFlow/screens/04-AmountInputScreen.js +20 -0
- package/dist/NordFlow/screens/05-DepositProgressScreen.d.ts +7 -0
- package/dist/NordFlow/screens/05-DepositProgressScreen.js +6 -0
- package/dist/NordFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/NordFlow/screens/06-DepositSuccessScreen.js +99 -0
- package/dist/NordFlow/screens/07-NordAuthScreen.d.ts +7 -0
- package/dist/NordFlow/screens/07-NordAuthScreen.js +14 -0
- package/dist/NordFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/NordFlow/screens/08-AuthLoadingScreen.js +20 -0
- package/dist/NordFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/NordFlow/screens/09-FinalSuccessScreen.js +18 -0
- package/dist/NordFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/NordFlow/screens/10-ErrorScreen.js +13 -0
- package/dist/NordFlow/screens/index.d.ts +10 -0
- package/dist/NordFlow/screens/index.js +10 -0
- package/dist/NordFlow/types.d.ts +105 -0
- package/dist/NordFlow/types.js +34 -0
- package/dist/NordFlow/utils/persistence.d.ts +24 -0
- package/dist/NordFlow/utils/persistence.js +83 -0
- package/dist/Provider/LazyWalletProvider.js +75 -38
- package/dist/Provider/N1WalletProvider.d.ts +1 -1
- package/dist/Provider/N1WalletProvider.js +63 -42
- package/dist/Provider/types.d.ts +69 -0
- package/dist/WalletConnectionFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/WalletConnectionFlow/WalletConnectionFlow.js +145 -0
- package/dist/WalletConnectionFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/WalletConnectionFlow/components/AnimatedButton.js +75 -0
- package/dist/WalletConnectionFlow/components/ChainButton.d.ts +7 -0
- package/dist/WalletConnectionFlow/components/ChainButton.js +5 -0
- package/dist/WalletConnectionFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/WalletConnectionFlow/components/LoadingSquares.js +5 -0
- package/dist/WalletConnectionFlow/components/TransactionTable.d.ts +13 -0
- package/dist/WalletConnectionFlow/components/TransactionTable.js +58 -0
- package/dist/WalletConnectionFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/WalletConnectionFlow/components/WaitingMessage.js +6 -0
- package/dist/WalletConnectionFlow/components/index.d.ts +5 -0
- package/dist/WalletConnectionFlow/components/index.js +5 -0
- package/dist/WalletConnectionFlow/constants.d.ts +37 -0
- package/dist/WalletConnectionFlow/constants.js +223 -0
- package/dist/WalletConnectionFlow/hooks/index.d.ts +8 -0
- package/dist/WalletConnectionFlow/hooks/index.js +8 -0
- package/dist/WalletConnectionFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/WalletConnectionFlow/hooks/useButtonTyping.js +43 -0
- package/dist/WalletConnectionFlow/hooks/useDepositFlow.d.ts +38 -0
- package/dist/WalletConnectionFlow/hooks/useDepositFlow.js +166 -0
- package/dist/WalletConnectionFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/WalletConnectionFlow/hooks/useFlowState.js +163 -0
- package/dist/WalletConnectionFlow/hooks/useInterruptHandler.d.ts +27 -0
- package/dist/WalletConnectionFlow/hooks/useInterruptHandler.js +101 -0
- package/dist/WalletConnectionFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/WalletConnectionFlow/hooks/useNordSession.js +193 -0
- package/dist/WalletConnectionFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/WalletConnectionFlow/hooks/useTableValues.js +69 -0
- package/dist/WalletConnectionFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/WalletConnectionFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/WalletConnectionFlow/hooks/useWalletConnect.d.ts +30 -0
- package/dist/WalletConnectionFlow/hooks/useWalletConnect.js +132 -0
- package/dist/WalletConnectionFlow/index.d.ts +3 -0
- package/dist/WalletConnectionFlow/index.js +3 -0
- package/dist/WalletConnectionFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/WalletConnectionFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/WalletConnectionFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/03-ChainSelectionScreen.js +7 -0
- package/dist/WalletConnectionFlow/screens/04-AmountInputScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/04-AmountInputScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/05-DepositProgressScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/05-DepositProgressScreen.js +6 -0
- package/dist/WalletConnectionFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/06-DepositSuccessScreen.js +99 -0
- package/dist/WalletConnectionFlow/screens/07-NordAuthScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/07-NordAuthScreen.js +14 -0
- package/dist/WalletConnectionFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/08-AuthLoadingScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/WalletConnectionFlow/screens/09-FinalSuccessScreen.js +18 -0
- package/dist/WalletConnectionFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/10-ErrorScreen.js +13 -0
- package/dist/WalletConnectionFlow/screens/AmountInputScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/AmountInputScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/AppsTableScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/AppsTableScreen.js +28 -0
- package/dist/WalletConnectionFlow/screens/AuthLoadingScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/AuthLoadingScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/ChainSelectionScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/ChainSelectionScreen.js +7 -0
- package/dist/WalletConnectionFlow/screens/ConnectWalletScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/ConnectWalletScreen.js +17 -0
- package/dist/WalletConnectionFlow/screens/DepositProgressScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/DepositProgressScreen.js +6 -0
- package/dist/WalletConnectionFlow/screens/DepositSuccessScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/DepositSuccessScreen.js +99 -0
- package/dist/WalletConnectionFlow/screens/ErrorScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/ErrorScreen.js +13 -0
- package/dist/WalletConnectionFlow/screens/EthToSolAuthScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/EthToSolAuthScreen.js +47 -0
- package/dist/WalletConnectionFlow/screens/EvmWalletAuthScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/EvmWalletAuthScreen.js +47 -0
- package/dist/WalletConnectionFlow/screens/FinalSuccessScreen.d.ts +5 -0
- package/dist/WalletConnectionFlow/screens/FinalSuccessScreen.js +18 -0
- package/dist/WalletConnectionFlow/screens/NordAuthScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/NordAuthScreen.js +14 -0
- package/dist/WalletConnectionFlow/screens/SigningScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/SigningScreen.js +6 -0
- package/dist/WalletConnectionFlow/screens/index.d.ts +10 -0
- package/dist/WalletConnectionFlow/screens/index.js +10 -0
- package/dist/WalletConnectionFlow/types.d.ts +105 -0
- package/dist/WalletConnectionFlow/types.js +34 -0
- package/dist/WalletConnectionFlow/utils/persistence.d.ts +24 -0
- package/dist/WalletConnectionFlow/utils/persistence.js +83 -0
- package/dist/components/Logo.d.ts +7 -0
- package/dist/components/Logo.js +118 -0
- package/dist/components/QRCodeLoader.d.ts +4 -0
- package/dist/components/QRCodeLoader.js +8 -0
- package/dist/components/WalletDeposit/AnimatedButton.d.ts +17 -0
- package/dist/components/WalletDeposit/AnimatedButton.js +29 -0
- package/dist/components/WalletDeposit/components/ChainButton.d.ts +7 -0
- package/dist/components/WalletDeposit/components/ChainButton.js +5 -0
- package/dist/components/WalletDeposit/components/LoadingSquares.d.ts +1 -0
- package/dist/components/WalletDeposit/components/LoadingSquares.js +5 -0
- package/dist/components/WalletDeposit/components/TransactionTable.d.ts +13 -0
- package/dist/components/WalletDeposit/components/TransactionTable.js +58 -0
- package/dist/components/WalletDeposit/components/WaitingMessage.d.ts +6 -0
- package/dist/components/WalletDeposit/components/WaitingMessage.js +6 -0
- package/dist/components/WalletDeposit/constants.d.ts +15 -0
- package/dist/components/WalletDeposit/constants.js +32 -0
- package/dist/components/WalletDeposit/hooks.d.ts +9 -0
- package/dist/components/WalletDeposit/hooks.js +185 -0
- package/dist/components/WalletDeposit/index.d.ts +1 -0
- package/dist/components/WalletDeposit/index.js +136 -0
- package/dist/components/WalletDeposit/screens/AmountInputScreen.d.ts +12 -0
- package/dist/components/WalletDeposit/screens/AmountInputScreen.js +18 -0
- package/dist/components/WalletDeposit/screens/AppsTableScreen.d.ts +8 -0
- package/dist/components/WalletDeposit/screens/AppsTableScreen.js +28 -0
- package/dist/components/WalletDeposit/screens/ChainSelectionScreen.d.ts +5 -0
- package/dist/components/WalletDeposit/screens/ChainSelectionScreen.js +8 -0
- package/dist/components/WalletDeposit/screens/InitialScreen.d.ts +9 -0
- package/dist/components/WalletDeposit/screens/InitialScreen.js +18 -0
- package/dist/components/WalletDeposit/screens/SigningScreen.d.ts +6 -0
- package/dist/components/WalletDeposit/screens/SigningScreen.js +6 -0
- package/dist/components/WalletDeposit/screens/SuccessScreen.d.ts +12 -0
- package/dist/components/WalletDeposit/screens/SuccessScreen.js +7 -0
- package/dist/components/WalletDeposit/types.d.ts +48 -0
- package/dist/config/dynamic.d.ts +20 -0
- package/dist/config/dynamic.js +47 -0
- package/dist/config/solana.d.ts +25 -0
- package/dist/config/solana.js +41 -0
- package/dist/errors/types.d.ts +5 -1
- package/dist/errors/types.js +12 -0
- package/dist/hooks/useSolanaSession.d.ts +17 -0
- package/dist/hooks/useSolanaSession.js +180 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/main.css +1 -1
- package/dist/utils/dynamicImports.d.ts +24 -0
- package/dist/utils/dynamicImports.js +41 -0
- package/dist/utils/shortenString.d.ts +2 -0
- package/dist/utils/shortenString.js +8 -0
- package/dist/utils/solana-session.d.ts +84 -0
- package/dist/utils/solana-session.js +230 -0
- package/package.json +24 -17
- package/.eslintrc.js +0 -29
- package/dist/Common/NIcon.js +0 -7
- package/dist/components/AnimatedButton.d.ts +0 -9
- package/dist/components/AnimatedButton.js +0 -5
- package/postcss.config.js +0 -6
- package/src/Logic/getPseudoName.ts +0 -5832
- package/src/Logic/utils.ts +0 -162
- package/src/Logic/words.ts +0 -93571
- package/src/Modal/BackButton.tsx +0 -23
- package/src/Modal/ConnectView.tsx +0 -88
- package/src/Modal/CreateSessionView.tsx +0 -242
- package/src/Modal/CreateUserView.tsx +0 -195
- package/src/Modal/ModalHeader.tsx +0 -64
- package/src/Modal/N1WalletModal.tsx +0 -275
- package/src/Modal/NoWhitelistView.tsx +0 -61
- package/src/Modal/Sidebar/N1Sidebar.tsx +0 -172
- package/src/Modal/SigningView.tsx +0 -18
- package/src/Modal/SuccessView.tsx +0 -36
- package/src/Provider/LazyWalletProvider.tsx +0 -136
- package/src/Provider/N1WalletProvider.tsx +0 -208
- package/src/Provider/context.ts +0 -11
- package/src/Provider/hooks.ts +0 -22
- package/src/Provider/icons/CoinbaseWalletIcon.tsx +0 -27
- package/src/Provider/icons/ConnectionDotsSVG.tsx +0 -19
- package/src/Provider/icons/MetamaskIcon.tsx +0 -58
- package/src/Provider/icons/PhantomIcon.tsx +0 -26
- package/src/Provider/icons/UserIcon.tsx +0 -15
- package/src/Provider/icons/WalletConnectIcon.tsx +0 -15
- package/src/Provider/index.ts +0 -3
- package/src/Provider/types.ts +0 -77
- package/src/WidgetButton/N1ConnectButton.tsx +0 -72
- package/src/components/LazyLoadWrapper.tsx +0 -19
- package/src/config.ts +0 -2
- package/src/errors/types.ts +0 -49
- package/src/index.ts +0 -5
- package/src/main.css +0 -3
- package/src/styles/main.css +0 -3
- package/src/utils/lazyLoad.ts +0 -12
- package/src/utils/logger.ts +0 -98
- package/src/utils/react-shim.js +0 -8
- package/tailwind.config.js +0 -44
- package/tsconfig.json +0 -21
- /package/dist/{Common/NIcon.d.ts → components/WalletDeposit/types.js} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the wallet connection flow state machine
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Enum representing all possible states in the wallet connection flow
|
|
6
|
+
*/
|
|
7
|
+
export declare enum FlowState {
|
|
8
|
+
IDLE = "IDLE",
|
|
9
|
+
CONNECTING_WALLET = "CONNECTING_WALLET",
|
|
10
|
+
WALLET_CONNECTED = "WALLET_CONNECTED",
|
|
11
|
+
ETH_TO_SOL_AUTH = "ETH_TO_SOL_AUTH",
|
|
12
|
+
CHAIN_SELECTION = "CHAIN_SELECTION",
|
|
13
|
+
AMOUNT_INPUT = "AMOUNT_INPUT",
|
|
14
|
+
DEPOSIT_PROGRESS = "DEPOSIT_PROGRESS",
|
|
15
|
+
DEPOSIT_SUCCESS = "DEPOSIT_SUCCESS",
|
|
16
|
+
NORD_AUTH = "NORD_AUTH",
|
|
17
|
+
AUTH_LOADING = "AUTH_LOADING",
|
|
18
|
+
FINAL_SUCCESS = "FINAL_SUCCESS",
|
|
19
|
+
ERROR = "ERROR"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Interface representing the flow context, containing all data necessary
|
|
23
|
+
* for the wallet connection flow
|
|
24
|
+
*/
|
|
25
|
+
export interface FlowContext {
|
|
26
|
+
walletType: 'solana' | 'ethereum' | null;
|
|
27
|
+
hasNordAccount: boolean;
|
|
28
|
+
hasActiveSession: boolean;
|
|
29
|
+
selectedChain: string | null;
|
|
30
|
+
amount: string;
|
|
31
|
+
transactionId: string | null;
|
|
32
|
+
error: Error | null;
|
|
33
|
+
lastInterruption: {
|
|
34
|
+
timestamp: number;
|
|
35
|
+
state: FlowState;
|
|
36
|
+
context: Partial<FlowContext>;
|
|
37
|
+
} | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Interface for state transitions in the flow
|
|
41
|
+
*/
|
|
42
|
+
export interface StateTransition {
|
|
43
|
+
from: FlowState | FlowState[];
|
|
44
|
+
to: FlowState;
|
|
45
|
+
condition?: (context: FlowContext) => boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Initial flow context with default values
|
|
49
|
+
*/
|
|
50
|
+
export declare const initialFlowContext: FlowContext;
|
|
51
|
+
export interface TableValues {
|
|
52
|
+
amount?: {
|
|
53
|
+
text: string;
|
|
54
|
+
visible: boolean;
|
|
55
|
+
typing: boolean;
|
|
56
|
+
};
|
|
57
|
+
tx: {
|
|
58
|
+
text: string;
|
|
59
|
+
visible: boolean;
|
|
60
|
+
typing: boolean;
|
|
61
|
+
};
|
|
62
|
+
from: {
|
|
63
|
+
text: string;
|
|
64
|
+
visible: boolean;
|
|
65
|
+
typing: boolean;
|
|
66
|
+
};
|
|
67
|
+
to: {
|
|
68
|
+
text: string;
|
|
69
|
+
visible: boolean;
|
|
70
|
+
typing: boolean;
|
|
71
|
+
};
|
|
72
|
+
network: {
|
|
73
|
+
text: string;
|
|
74
|
+
visible: boolean;
|
|
75
|
+
typing: boolean;
|
|
76
|
+
};
|
|
77
|
+
status: {
|
|
78
|
+
text: string;
|
|
79
|
+
visible: boolean;
|
|
80
|
+
typing: boolean;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface WaitingMessageState {
|
|
84
|
+
title: string;
|
|
85
|
+
subtitle: string;
|
|
86
|
+
visible: boolean;
|
|
87
|
+
isTyping: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface Chain {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
logo: string;
|
|
93
|
+
}
|
|
94
|
+
export interface App {
|
|
95
|
+
name: string;
|
|
96
|
+
color: string;
|
|
97
|
+
progress: number;
|
|
98
|
+
}
|
|
99
|
+
export type ButtonKey = 'deposit' | 'continue' | 'openApp';
|
|
100
|
+
export interface ButtonState {
|
|
101
|
+
text: string;
|
|
102
|
+
isTyping: boolean;
|
|
103
|
+
showCursor: boolean;
|
|
104
|
+
}
|
|
105
|
+
export type ButtonStates = Record<ButtonKey, ButtonState>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the wallet connection flow state machine
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Enum representing all possible states in the wallet connection flow
|
|
6
|
+
*/
|
|
7
|
+
export var FlowState;
|
|
8
|
+
(function (FlowState) {
|
|
9
|
+
FlowState["IDLE"] = "IDLE";
|
|
10
|
+
FlowState["CONNECTING_WALLET"] = "CONNECTING_WALLET";
|
|
11
|
+
FlowState["WALLET_CONNECTED"] = "WALLET_CONNECTED";
|
|
12
|
+
FlowState["ETH_TO_SOL_AUTH"] = "ETH_TO_SOL_AUTH";
|
|
13
|
+
FlowState["CHAIN_SELECTION"] = "CHAIN_SELECTION";
|
|
14
|
+
FlowState["AMOUNT_INPUT"] = "AMOUNT_INPUT";
|
|
15
|
+
FlowState["DEPOSIT_PROGRESS"] = "DEPOSIT_PROGRESS";
|
|
16
|
+
FlowState["DEPOSIT_SUCCESS"] = "DEPOSIT_SUCCESS";
|
|
17
|
+
FlowState["NORD_AUTH"] = "NORD_AUTH";
|
|
18
|
+
FlowState["AUTH_LOADING"] = "AUTH_LOADING";
|
|
19
|
+
FlowState["FINAL_SUCCESS"] = "FINAL_SUCCESS";
|
|
20
|
+
FlowState["ERROR"] = "ERROR";
|
|
21
|
+
})(FlowState || (FlowState = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Initial flow context with default values
|
|
24
|
+
*/
|
|
25
|
+
export var initialFlowContext = {
|
|
26
|
+
walletType: null,
|
|
27
|
+
hasNordAccount: false,
|
|
28
|
+
hasActiveSession: false,
|
|
29
|
+
selectedChain: null,
|
|
30
|
+
amount: '',
|
|
31
|
+
transactionId: null,
|
|
32
|
+
error: null,
|
|
33
|
+
lastInterruption: null,
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FlowContext, FlowState } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Saves the current flow state and context to localStorage
|
|
4
|
+
* @param state Current flow state
|
|
5
|
+
* @param context Current flow context
|
|
6
|
+
*/
|
|
7
|
+
export declare const saveStateToLocalStorage: (state: FlowState, context: FlowContext) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Loads the flow state and context from localStorage if available and not expired
|
|
10
|
+
* @returns The loaded state and context, or null if not available or expired
|
|
11
|
+
*/
|
|
12
|
+
export declare const loadStateFromLocalStorage: () => {
|
|
13
|
+
state: FlowState;
|
|
14
|
+
context: FlowContext;
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* Clears the stored flow state from localStorage
|
|
18
|
+
*/
|
|
19
|
+
export declare const clearStoredState: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if there is a stored state that can be recovered
|
|
22
|
+
* @returns True if there is a recoverable state, false otherwise
|
|
23
|
+
*/
|
|
24
|
+
export declare const hasRecoverableState: () => boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { initialFlowContext } from '../types';
|
|
13
|
+
import { FLOW_STATE_STORAGE_KEY, STATE_EXPIRY_TIME } from '../constants';
|
|
14
|
+
/**
|
|
15
|
+
* Saves the current flow state and context to localStorage
|
|
16
|
+
* @param state Current flow state
|
|
17
|
+
* @param context Current flow context
|
|
18
|
+
*/
|
|
19
|
+
export var saveStateToLocalStorage = function (state, context) {
|
|
20
|
+
try {
|
|
21
|
+
var persistedData = {
|
|
22
|
+
state: state,
|
|
23
|
+
context: __assign(__assign({}, context), {
|
|
24
|
+
// Filter out any sensitive data or error objects that shouldn't be persisted
|
|
25
|
+
error: context.error
|
|
26
|
+
? {
|
|
27
|
+
message: context.error.message,
|
|
28
|
+
name: context.error.name,
|
|
29
|
+
}
|
|
30
|
+
: null }),
|
|
31
|
+
timestamp: Date.now(),
|
|
32
|
+
};
|
|
33
|
+
localStorage.setItem(FLOW_STATE_STORAGE_KEY, JSON.stringify(persistedData));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Failed to save flow state:', error);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Loads the flow state and context from localStorage if available and not expired
|
|
41
|
+
* @returns The loaded state and context, or null if not available or expired
|
|
42
|
+
*/
|
|
43
|
+
export var loadStateFromLocalStorage = function () {
|
|
44
|
+
try {
|
|
45
|
+
var storedData = localStorage.getItem(FLOW_STATE_STORAGE_KEY);
|
|
46
|
+
if (!storedData) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
var parsedData = JSON.parse(storedData);
|
|
50
|
+
var state = parsedData.state, context = parsedData.context, timestamp = parsedData.timestamp;
|
|
51
|
+
// Check if data is expired
|
|
52
|
+
if (Date.now() - timestamp > STATE_EXPIRY_TIME) {
|
|
53
|
+
localStorage.removeItem(FLOW_STATE_STORAGE_KEY);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
state: state,
|
|
58
|
+
context: __assign(__assign({}, initialFlowContext), context),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error('Failed to load flow state:', error);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Clears the stored flow state from localStorage
|
|
68
|
+
*/
|
|
69
|
+
export var clearStoredState = function () {
|
|
70
|
+
try {
|
|
71
|
+
localStorage.removeItem(FLOW_STATE_STORAGE_KEY);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error('Failed to clear flow state:', error);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Checks if there is a stored state that can be recovered
|
|
79
|
+
* @returns True if there is a recoverable state, false otherwise
|
|
80
|
+
*/
|
|
81
|
+
export var hasRecoverableState = function () {
|
|
82
|
+
return loadStateFromLocalStorage() !== null;
|
|
83
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useN1WalletInternalContext } from '../../../Provider/hooks';
|
|
4
|
+
import { N1ModalViewMode } from '../../../Provider/types';
|
|
5
|
+
import { ANIMATION_EASE } from '../../NordFlow/constants';
|
|
6
|
+
export function BackButton(props) {
|
|
7
|
+
var _a = useN1WalletInternalContext(), setViewMode = _a.setViewMode, dynamicHandleLogOut = _a.dynamicHandleLogOut;
|
|
8
|
+
var _b = useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
9
|
+
var _c = useState(false), isPressed = _c[0], setIsPressed = _c[1];
|
|
10
|
+
function back() {
|
|
11
|
+
// todo: disconnect
|
|
12
|
+
console.log('back');
|
|
13
|
+
dynamicHandleLogOut();
|
|
14
|
+
setViewMode(N1ModalViewMode.Connect);
|
|
15
|
+
}
|
|
16
|
+
return (_jsx("button", { onClick: props.onClick || back, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () {
|
|
17
|
+
setIsHovered(false);
|
|
18
|
+
setIsPressed(false);
|
|
19
|
+
}, onMouseDown: function () { return setIsPressed(true); }, onMouseUp: function () { return setIsPressed(false); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-pointer border-gray-200 dark:border-gray-800 hover:border-gray-400 dark:hover:border-white/60\n "), style: {
|
|
20
|
+
transform: isPressed
|
|
21
|
+
? 'scale(0.98)'
|
|
22
|
+
: isHovered
|
|
23
|
+
? 'scale(0.99)'
|
|
24
|
+
: 'scale(1)',
|
|
25
|
+
}, children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center", children: _jsx("span", { className: "\n text-base font-medium tracking-wide transition-colors duration-300 ".concat(ANIMATION_EASE, "\n text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white\n "), children: "Back" }) }) }) }));
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ModalHeader(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useN1WalletContext, useN1WalletInternalContext, } from '../../../Provider/hooks';
|
|
3
|
+
import { N1ModalViewMode } from '../../../Provider/types';
|
|
4
|
+
import { X } from 'lucide-react';
|
|
5
|
+
import Logo from '../../../components/Logo';
|
|
6
|
+
import { ANIMATION_EASE } from '../../NordFlow/constants';
|
|
7
|
+
export function ModalHeader() {
|
|
8
|
+
var _a = useN1WalletInternalContext(), setViewMode = _a.setViewMode, setStartClosingLogin = _a.setStartClosingLogin, setDynamicWallet = _a.setDynamicWallet, setAddress = _a.setAddress, dynamicHandleLogOut = _a.dynamicHandleLogOut;
|
|
9
|
+
var viewMode = useN1WalletContext().viewMode;
|
|
10
|
+
var close = function () {
|
|
11
|
+
setStartClosingLogin(true);
|
|
12
|
+
if (viewMode === N1ModalViewMode.CreateSession) {
|
|
13
|
+
setDynamicWallet(null);
|
|
14
|
+
setAddress('');
|
|
15
|
+
dynamicHandleLogOut();
|
|
16
|
+
setViewMode(N1ModalViewMode.Connect);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return (_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "w-6 h-6 text-gray-50", children: _jsx(Logo, { size: 24 }) }), _jsxs("h2", { className: "text-xl text-gray-400 flex items-center gap-2", children: ["Connect", viewMode === N1ModalViewMode.CreateSession && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Session" })), viewMode === N1ModalViewMode.Signing && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Sign" })), viewMode === N1ModalViewMode.CreatingUser && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Create User" })), viewMode === N1ModalViewMode.Success && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Success" }))] })] }), _jsx("button", { onClick: close, className: "\n text-neutral-400 hover:text-gray-900 dark:hover:text-white \n transition-colors duration-300 ".concat(ANIMATION_EASE, "\n h-10 w-10 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800\n flex items-center justify-center\n "), children: _jsx(X, { size: 20 }) })] }));
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NTSFlow } from './NTSFlow';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NTSFlow } from './NTSFlow';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ConnectView(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
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);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
|
+
import { useState } from 'react';
|
|
39
|
+
import { IoMdWallet } from 'react-icons/io';
|
|
40
|
+
import { useN1WalletInternalContext } from '../../../Provider/hooks';
|
|
41
|
+
import { ANIMATION_EASE } from '../../NordFlow/constants';
|
|
42
|
+
import { ModalHeader } from '../components/ModalHeader';
|
|
43
|
+
export function ConnectView() {
|
|
44
|
+
var _this = this;
|
|
45
|
+
var _a = useN1WalletInternalContext(), showDynamicWidget = _a.showDynamicWidget, handleError = _a.handleError;
|
|
46
|
+
var _b = useState(null), isHovered = _b[0], setIsHovered = _b[1];
|
|
47
|
+
var handleConnect = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
48
|
+
var error_1;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
_a.trys.push([0, 2, , 3]);
|
|
53
|
+
return [4 /*yield*/, showDynamicWidget(true)];
|
|
54
|
+
case 1:
|
|
55
|
+
_a.sent();
|
|
56
|
+
return [3 /*break*/, 3];
|
|
57
|
+
case 2:
|
|
58
|
+
error_1 = _a.sent();
|
|
59
|
+
handleError(error_1);
|
|
60
|
+
return [3 /*break*/, 3];
|
|
61
|
+
case 3: return [2 /*return*/];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); };
|
|
65
|
+
return (_jsxs("div", { className: "bg-gray-50 dark:bg-gray-950 relative border border-gray-200 dark:border-gray-800 rounded-md transition-[max-width,transform,opacity] duration-[3000ms] ease-[cubic-bezier(0.16,1,0.3,1)] w-full max-w-sm m-4 origin-center will-change-[max-width,transform,opacity]", children: [_jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-800", children: _jsx(ModalHeader, {}) }), _jsx("div", { className: "p-6 overflow-hidden relative", children: _jsxs("div", { className: "space-y-4", children: [_jsx("button", { onClick: handleConnect, onMouseEnter: function () { return setIsHovered('wallet'); }, onMouseLeave: function () { return setIsHovered(null); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-pointer border-gray-200 dark:border-gray-800 hover:border-gray-400 dark:hover:border-white/60\n "), style: {
|
|
66
|
+
transform: isHovered === 'wallet' ? 'scale(0.99)' : 'scale(1)',
|
|
67
|
+
}, children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsxs("div", { className: "flex items-center", children: [_jsx(IoMdWallet, { className: "w-5 h-5 text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white transition-colors duration-300" }), _jsx("span", { className: "\n ml-2 text-base font-medium tracking-wide transition-colors duration-300 ".concat(ANIMATION_EASE, "\n text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white\n "), children: "Continue with Wallet" })] }) }) }), _jsx("button", { disabled: true, onMouseEnter: function () { return setIsHovered('google'); }, onMouseLeave: function () { return setIsHovered(null); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-not-allowed border-gray-200 dark:border-gray-800 opacity-50\n "), children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center", children: _jsx("span", { className: "text-base font-medium tracking-wide text-gray-500 dark:text-neutral-400", children: "Continue with Google (soon)" }) }) }) }), _jsx("button", { disabled: true, onMouseEnter: function () { return setIsHovered('email'); }, onMouseLeave: function () { return setIsHovered(null); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-not-allowed border-gray-200 dark:border-gray-800 opacity-50\n "), children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center", children: _jsx("span", { className: "text-base font-medium tracking-wide text-gray-500 dark:text-neutral-400", children: "Continue with Email (soon)" }) }) }) })] }) })] }));
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CreateSessionView(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
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);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
|
+
import { useEffect, useState } from 'react';
|
|
39
|
+
import { ANIMATION_EASE } from '../../NordFlow/constants';
|
|
40
|
+
import { WalletError, WalletErrorCode } from '../../../errors/types';
|
|
41
|
+
import { createWebSession, generateSessionKeyPair, getUser, storeSessionKeysInLocalStorage, } from '../../../Logic/utils';
|
|
42
|
+
import { useN1WalletContext, useN1WalletInternalContext, } from '../../../Provider/hooks';
|
|
43
|
+
import { N1ModalViewMode } from '../../../Provider/types';
|
|
44
|
+
import { logger } from '../../../utils/logger';
|
|
45
|
+
import { BackButton } from '../components/BackButton';
|
|
46
|
+
import { ModalHeader } from '../components/ModalHeader';
|
|
47
|
+
import { signEd25519 } from '@n1xyz/nts-sdk';
|
|
48
|
+
export function CreateSessionView() {
|
|
49
|
+
var _this = this;
|
|
50
|
+
var _a = useState(false), isHovered = _a[0], setIsHovered = _a[1];
|
|
51
|
+
var _b = useState(false), isPressed = _b[0], setIsPressed = _b[1];
|
|
52
|
+
var _c = useState(null), NTSComponents = _c[0], setNTSComponents = _c[1];
|
|
53
|
+
var _d = useState(null), keyPair = _d[0], setKeyPair = _d[1];
|
|
54
|
+
var _e = useN1WalletInternalContext(), setViewMode = _e.setViewMode, setUsername = _e.setUsername, setStartClosingLogin = _e.setStartClosingLogin, setIsConnected = _e.setIsConnected, dynamicWallet = _e.dynamicWallet, handleError = _e.handleError, setSessionPubKey = _e.setSessionPubKey, setSignMessageWithSessionKey = _e.setSignMessageWithSessionKey, dynamicHandleLogOut = _e.dynamicHandleLogOut, setDynamicWallet = _e.setDynamicWallet, setAddress = _e.setAddress, setSignMessageWithWalletKey = _e.setSignMessageWithWalletKey;
|
|
55
|
+
var _f = useN1WalletContext(), ntsInterface = _f.ntsInterface, walletPubKey = _f.walletPubKey, address = _f.address;
|
|
56
|
+
// Initialize NTS SDK and generate key pair
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
var loadNTSSDK = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
59
|
+
var _a, Transaction, AdminAction, CoreApps, newKeyPair, error_1;
|
|
60
|
+
return __generator(this, function (_b) {
|
|
61
|
+
switch (_b.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
_b.trys.push([0, 3, , 4]);
|
|
64
|
+
return [4 /*yield*/, import('@n1xyz/nts-sdk')];
|
|
65
|
+
case 1:
|
|
66
|
+
_a = _b.sent(), Transaction = _a.Transaction, AdminAction = _a.AdminAction, CoreApps = _a.CoreApps;
|
|
67
|
+
setNTSComponents({ Transaction: Transaction, AdminAction: AdminAction, CoreApps: CoreApps });
|
|
68
|
+
return [4 /*yield*/, generateSessionKeyPair()];
|
|
69
|
+
case 2:
|
|
70
|
+
newKeyPair = _b.sent();
|
|
71
|
+
setKeyPair(newKeyPair);
|
|
72
|
+
return [3 /*break*/, 4];
|
|
73
|
+
case 3:
|
|
74
|
+
error_1 = _b.sent();
|
|
75
|
+
handleError(new WalletError(WalletErrorCode.CONNECTION_FAILED, 'Failed to initialize NTS SDK', { originalError: error_1 }));
|
|
76
|
+
return [3 /*break*/, 4];
|
|
77
|
+
case 4: return [2 /*return*/];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); };
|
|
81
|
+
loadNTSSDK();
|
|
82
|
+
}, [handleError]);
|
|
83
|
+
var signWithWallet = function (msg) { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
var signature, binaryString, signatureUint8Array, i, sig, error_2;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
_a.trys.push([0, 4, , 5]);
|
|
89
|
+
if (!dynamicWallet) {
|
|
90
|
+
throw new WalletError(WalletErrorCode.WALLET_NOT_FOUND, 'Wallet not found for signing');
|
|
91
|
+
}
|
|
92
|
+
if (!(dynamicWallet.chain === 'SOL')) return [3 /*break*/, 2];
|
|
93
|
+
return [4 /*yield*/, dynamicWallet.signMessage(msg)];
|
|
94
|
+
case 1:
|
|
95
|
+
signature = _a.sent();
|
|
96
|
+
binaryString = atob(signature);
|
|
97
|
+
signatureUint8Array = new Uint8Array(binaryString.length);
|
|
98
|
+
for (i = 0; i < binaryString.length; i++) {
|
|
99
|
+
signatureUint8Array[i] = binaryString.charCodeAt(i);
|
|
100
|
+
}
|
|
101
|
+
return [2 /*return*/, signatureUint8Array];
|
|
102
|
+
case 2: return [4 /*yield*/, dynamicWallet.signMessage(msg)];
|
|
103
|
+
case 3:
|
|
104
|
+
sig = (_a.sent());
|
|
105
|
+
logger.debug('Wallet signature received', { signature: sig });
|
|
106
|
+
return [2 /*return*/, Uint8Array.from(Buffer.from(sig.slice(2), 'hex'))];
|
|
107
|
+
case 4:
|
|
108
|
+
error_2 = _a.sent();
|
|
109
|
+
throw new WalletError(WalletErrorCode.USER_REJECTED, 'Failed to sign message with wallet', { originalError: error_2 });
|
|
110
|
+
case 5: return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}); };
|
|
114
|
+
var handleSign = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
115
|
+
var sessionKeyHex, transactionData, tx, txRes, _1, signFn_1, user, error_3;
|
|
116
|
+
var _this = this;
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
logger.debug('handleSign');
|
|
121
|
+
if (!NTSComponents || !keyPair) {
|
|
122
|
+
logger.warn('Required components not initialized');
|
|
123
|
+
return [2 /*return*/];
|
|
124
|
+
}
|
|
125
|
+
setViewMode(N1ModalViewMode.Signing);
|
|
126
|
+
_a.label = 1;
|
|
127
|
+
case 1:
|
|
128
|
+
_a.trys.push([1, 9, , 10]);
|
|
129
|
+
sessionKeyHex = Buffer.from(keyPair.publicKey).toString('hex');
|
|
130
|
+
logger.debug('Generated session key', { sessionKey: sessionKeyHex });
|
|
131
|
+
transactionData = {
|
|
132
|
+
appId: NTSComponents.CoreApps.Admin,
|
|
133
|
+
action: NTSComponents.AdminAction.addSessionKey,
|
|
134
|
+
framework: 'ts',
|
|
135
|
+
data: [
|
|
136
|
+
{
|
|
137
|
+
sessionKey: sessionKeyHex,
|
|
138
|
+
appId: 'hub',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
setSignMessageWithWalletKey(signWithWallet);
|
|
143
|
+
tx = new NTSComponents.Transaction(transactionData, walletPubKey);
|
|
144
|
+
return [4 /*yield*/, tx.signWithWalletFunction(signWithWallet)];
|
|
145
|
+
case 2:
|
|
146
|
+
_a.sent();
|
|
147
|
+
_a.label = 3;
|
|
148
|
+
case 3:
|
|
149
|
+
_a.trys.push([3, 5, , 6]);
|
|
150
|
+
return [4 /*yield*/, ntsInterface.sendTransaction(tx, tx.signature, walletPubKey)];
|
|
151
|
+
case 4:
|
|
152
|
+
txRes = _a.sent();
|
|
153
|
+
if (txRes.success) {
|
|
154
|
+
logger.debug('txRes', txRes);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
logger.debug('txRes', txRes);
|
|
158
|
+
throw new WalletError(WalletErrorCode.TRANSACTION_FAILED, 'Transaction failed');
|
|
159
|
+
}
|
|
160
|
+
return [3 /*break*/, 6];
|
|
161
|
+
case 5:
|
|
162
|
+
_1 = _a.sent();
|
|
163
|
+
throw new WalletError(WalletErrorCode.TRANSACTION_FAILED, 'Transaction did not succeed');
|
|
164
|
+
case 6:
|
|
165
|
+
signFn_1 = function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
166
|
+
var _2;
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
switch (_a.label) {
|
|
169
|
+
case 0:
|
|
170
|
+
_a.trys.push([0, 2, , 3]);
|
|
171
|
+
return [4 /*yield*/, signEd25519(message, keyPair.privateKey)];
|
|
172
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
173
|
+
case 2:
|
|
174
|
+
_2 = _a.sent();
|
|
175
|
+
console.log('error', _2);
|
|
176
|
+
throw _2;
|
|
177
|
+
case 3: return [2 /*return*/];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}); };
|
|
181
|
+
// Store session keys
|
|
182
|
+
logger.debug('Storing session keys');
|
|
183
|
+
storeSessionKeysInLocalStorage({
|
|
184
|
+
privKey: keyPair.privateKey,
|
|
185
|
+
walletPublicKey: address,
|
|
186
|
+
chainName: dynamicWallet.chain,
|
|
187
|
+
});
|
|
188
|
+
setSessionPubKey(keyPair.publicKey);
|
|
189
|
+
setSignMessageWithSessionKey(function () { return signFn_1; });
|
|
190
|
+
// Initialize web session with Argus who verifies that the session is
|
|
191
|
+
// registered with Core, and if so, grants you access to its user metadata db
|
|
192
|
+
return [4 /*yield*/, createWebSession(signFn_1, keyPair.publicKey, walletPubKey)];
|
|
193
|
+
case 7:
|
|
194
|
+
// Initialize web session with Argus who verifies that the session is
|
|
195
|
+
// registered with Core, and if so, grants you access to its user metadata db
|
|
196
|
+
_a.sent();
|
|
197
|
+
return [4 /*yield*/, getUser()];
|
|
198
|
+
case 8:
|
|
199
|
+
user = _a.sent();
|
|
200
|
+
if (user === null || user === void 0 ? void 0 : user.name) {
|
|
201
|
+
logger.info('Existing user found, completing login');
|
|
202
|
+
setUsername(user.name);
|
|
203
|
+
localStorage.setItem("n1_".concat(address, "_username"), user.name);
|
|
204
|
+
setStartClosingLogin(true);
|
|
205
|
+
setIsConnected(true);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
logger.info('No user found, transitioning to user creation');
|
|
209
|
+
setViewMode(N1ModalViewMode.CreatingUser);
|
|
210
|
+
}
|
|
211
|
+
return [3 /*break*/, 10];
|
|
212
|
+
case 9:
|
|
213
|
+
error_3 = _a.sent();
|
|
214
|
+
logger.error('Session creation failed:', error_3);
|
|
215
|
+
if (error_3.name === 'WalletError') {
|
|
216
|
+
handleError(error_3);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
handleError(new WalletError(WalletErrorCode.CONNECTION_FAILED, 'Failed to create session', { originalError: JSON.stringify(error_3) }));
|
|
220
|
+
}
|
|
221
|
+
setViewMode(N1ModalViewMode.CreateSession);
|
|
222
|
+
return [3 /*break*/, 10];
|
|
223
|
+
case 10: return [2 /*return*/];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}); };
|
|
227
|
+
return (_jsxs("div", { className: "bg-gray-50 dark:bg-gray-950 relative border border-gray-200 dark:border-gray-800 rounded-md transition-[max-width,transform,opacity] duration-[3000ms] ease-[cubic-bezier(0.16,1,0.3,1)] w-full max-w-sm m-4 origin-center will-change-[max-width,transform,opacity]", children: [_jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-800", children: _jsx(ModalHeader, {}) }), _jsx("div", { className: "p-6 overflow-hidden relative", children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "text-center", children: [_jsx("h3", { className: "text-xl font-medium text-gray-900 dark:text-white mb-2", children: "Create Session" }), _jsx("p", { className: "text-gray-500 dark:text-gray-400", children: "Please authenticate to create a new session." })] }), _jsx("button", { onClick: handleSign, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () {
|
|
228
|
+
setIsHovered(false);
|
|
229
|
+
setIsPressed(false);
|
|
230
|
+
}, onMouseDown: function () { return setIsPressed(true); }, onMouseUp: function () { return setIsPressed(false); }, disabled: !NTSComponents || !keyPair, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-left\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n ").concat(!NTSComponents || !keyPair
|
|
231
|
+
? 'cursor-not-allowed border-gray-200 dark:border-gray-800 opacity-50'
|
|
232
|
+
: 'cursor-pointer border-gray-200 dark:border-gray-800 hover:border-gray-400 dark:hover:border-white/60', "\n "), style: {
|
|
233
|
+
transform: isPressed && (!NTSComponents || !keyPair)
|
|
234
|
+
? 'scale(0.98)'
|
|
235
|
+
: isHovered && (!NTSComponents || !keyPair)
|
|
236
|
+
? 'scale(0.99)'
|
|
237
|
+
: 'scale(1)',
|
|
238
|
+
}, children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center justify-start", children: _jsx("span", { className: "\n text-base font-medium tracking-wide transition-colors duration-300 ".concat(ANIMATION_EASE, "\n text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white\n "), children: "Authenticate" }) }) }) }), _jsx(BackButton, { onClick: function () {
|
|
239
|
+
logger.debug('BackButton clicked');
|
|
240
|
+
setDynamicWallet(null);
|
|
241
|
+
setAddress('');
|
|
242
|
+
dynamicHandleLogOut();
|
|
243
|
+
setViewMode(N1ModalViewMode.Connect);
|
|
244
|
+
} })] }) })] }));
|
|
245
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CreateUserView(): import("react/jsx-runtime").JSX.Element;
|