@dynamic-labs/sdk-react-core 0.19.0-alpha.0 → 0.19.0-alpha.2

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.
Files changed (516) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +11 -10
  5. package/src/index.cjs +40 -12
  6. package/src/index.d.ts +4 -7
  7. package/src/index.js +22 -6
  8. package/src/lib/Main.cjs +14 -3
  9. package/src/lib/Main.js +14 -3
  10. package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.cjs +5 -1
  11. package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.js +5 -1
  12. package/src/lib/components/AnimatePresence/AnimatePresence.cjs +6 -2
  13. package/src/lib/components/AnimatePresence/AnimatePresence.js +6 -2
  14. package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +14 -7
  15. package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +14 -7
  16. package/src/lib/components/Button/Button.cjs +10 -7
  17. package/src/lib/components/Button/Button.d.ts +3 -3
  18. package/src/lib/components/Button/Button.js +10 -7
  19. package/src/lib/components/Divider/Divider.cjs +7 -3
  20. package/src/lib/components/Divider/Divider.js +7 -3
  21. package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
  22. package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
  23. package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
  24. package/src/lib/components/Icon/Icon.cjs +1 -0
  25. package/src/lib/components/Icon/Icon.js +1 -0
  26. package/src/lib/components/Icon/Icon.types.d.ts +1 -1
  27. package/src/lib/components/IconWithSpinner/IconWithSpinner.d.ts +1 -1
  28. package/src/lib/components/ListTile/ListTile.cjs +1 -1
  29. package/src/lib/components/ListTile/ListTile.js +1 -1
  30. package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
  31. package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +5 -1
  32. package/src/lib/components/MenuList/Dropdown/Dropdown.js +5 -1
  33. package/src/lib/components/Modal/Modal.cjs +5 -1
  34. package/src/lib/components/Modal/Modal.js +5 -1
  35. package/src/lib/components/ModalHeader/ModalHeader.cjs +2 -2
  36. package/src/lib/components/ModalHeader/ModalHeader.js +2 -2
  37. package/src/lib/components/ModalHeader/ModalHeader.types.d.ts +2 -1
  38. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +4 -2
  39. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +2 -1
  40. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +4 -2
  41. package/src/lib/components/NetworkPicker/NetworkPicker.cjs +6 -2
  42. package/src/lib/components/NetworkPicker/NetworkPicker.js +6 -2
  43. package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.cjs +7 -3
  44. package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.js +7 -3
  45. package/src/lib/components/NetworkPicker/components/Network/Network.cjs +7 -3
  46. package/src/lib/components/NetworkPicker/components/Network/Network.js +7 -3
  47. package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +7 -3
  48. package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +7 -3
  49. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +12 -6
  50. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +2 -0
  51. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +12 -6
  52. package/src/lib/components/OverlayCard/OverlayCard.cjs +5 -1
  53. package/src/lib/components/OverlayCard/OverlayCard.js +5 -1
  54. package/src/lib/components/Portal/Portal.cjs +5 -1
  55. package/src/lib/components/Portal/Portal.js +5 -1
  56. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.cjs +6 -2
  57. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.d.ts +1 -0
  58. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.js +6 -2
  59. package/src/lib/components/Tooltip/Tooltip.cjs +5 -1
  60. package/src/lib/components/Tooltip/Tooltip.js +5 -1
  61. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
  62. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
  63. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +7 -3
  64. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +7 -3
  65. package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.cjs +5 -1
  66. package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.js +5 -1
  67. package/src/lib/components/Typography/Typography.cjs +1 -0
  68. package/src/lib/components/Typography/Typography.js +1 -0
  69. package/src/lib/components/Typography/Typography.types.d.ts +1 -1
  70. package/src/lib/components/UserAddress/UserAddress.cjs +5 -1
  71. package/src/lib/components/UserAddress/UserAddress.js +5 -1
  72. package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.cjs +7 -3
  73. package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.js +7 -3
  74. package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.cjs +7 -3
  75. package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.js +7 -3
  76. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +7 -4
  77. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +7 -4
  78. package/src/lib/components/UserProfileForm/UserProfileForm.cjs +26 -14
  79. package/src/lib/components/UserProfileForm/UserProfileForm.d.ts +14 -3
  80. package/src/lib/components/UserProfileForm/UserProfileForm.js +27 -15
  81. package/src/lib/components/UserProfileForm/index.d.ts +1 -0
  82. package/src/lib/context/DynamicContext/DynamicContext.cjs +40 -11
  83. package/src/lib/context/DynamicContext/DynamicContext.js +42 -13
  84. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
  85. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
  86. package/src/lib/context/DynamicContext/internalEvents/index.d.ts +1 -0
  87. package/src/lib/context/DynamicContext/internalEvents/internalEvents.cjs +14 -0
  88. package/src/lib/context/DynamicContext/internalEvents/internalEvents.d.ts +8 -0
  89. package/src/lib/context/DynamicContext/internalEvents/internalEvents.js +6 -0
  90. package/src/lib/context/DynamicContext/types/index.d.ts +8 -5
  91. package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +9 -2
  92. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.cjs +5 -1
  93. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.js +5 -1
  94. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +64 -33
  95. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +3 -3
  96. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +64 -33
  97. package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
  98. package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
  99. package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
  100. package/src/lib/context/MockContext/MockContext.cjs +7 -3
  101. package/src/lib/context/MockContext/MockContext.js +7 -3
  102. package/src/lib/context/QrCodeContext/QrCodeContext.cjs +6 -2
  103. package/src/lib/context/QrCodeContext/QrCodeContext.js +6 -2
  104. package/src/lib/context/SendBalanceContext/SendBalanceContext.cjs +5 -1
  105. package/src/lib/context/SendBalanceContext/SendBalanceContext.js +5 -1
  106. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +8 -3
  107. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +8 -3
  108. package/src/lib/context/UserFieldEditorContext/UserFieldEditorContext.cjs +67 -0
  109. package/src/lib/context/UserFieldEditorContext/UserFieldEditorContext.d.ts +14 -0
  110. package/src/lib/context/UserFieldEditorContext/UserFieldEditorContext.js +62 -0
  111. package/src/lib/context/UserFieldEditorContext/index.d.ts +1 -0
  112. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  113. package/src/lib/context/WalletContext/WalletContext.cjs +1 -0
  114. package/src/lib/context/WalletContext/WalletContext.js +1 -0
  115. package/src/lib/data/api.cjs +33 -1
  116. package/src/lib/data/api.d.ts +3 -1
  117. package/src/lib/data/api.js +34 -4
  118. package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +7 -3
  119. package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +7 -3
  120. package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +18 -6
  121. package/src/lib/layout/DynamicAuthLayout/Header/header.js +18 -6
  122. package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.cjs +7 -3
  123. package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.js +7 -3
  124. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/Item/Item.cjs +7 -3
  125. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/Item/Item.js +7 -3
  126. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.cjs +7 -3
  127. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.js +7 -3
  128. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.cjs +7 -3
  129. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.js +7 -3
  130. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletMoreInfoContent/WalletMoreInfoContent.cjs +7 -3
  131. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletMoreInfoContent/WalletMoreInfoContent.js +7 -3
  132. package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.cjs +7 -3
  133. package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.js +7 -3
  134. package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.cjs +7 -3
  135. package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.js +7 -3
  136. package/src/lib/layouts/BridgeNextWalletToConnectLayout/BridgeNextWalletToConnectLayout.cjs +7 -3
  137. package/src/lib/layouts/BridgeNextWalletToConnectLayout/BridgeNextWalletToConnectLayout.js +7 -3
  138. package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.cjs +7 -3
  139. package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.js +7 -3
  140. package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.cjs +7 -3
  141. package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.js +7 -3
  142. package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +7 -3
  143. package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +7 -3
  144. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +7 -3
  145. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +7 -3
  146. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +18 -5
  147. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +18 -5
  148. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -0
  149. package/src/lib/modals/UserFieldEditorModal/UserFieldEditorModal.cjs +76 -0
  150. package/src/lib/modals/UserFieldEditorModal/UserFieldEditorModal.d.ts +10 -0
  151. package/src/lib/modals/UserFieldEditorModal/UserFieldEditorModal.js +72 -0
  152. package/src/lib/modals/UserFieldEditorModal/index.d.ts +1 -0
  153. package/src/lib/modals/index.d.ts +1 -0
  154. package/src/lib/shared/assets/at.cjs +53 -0
  155. package/src/lib/shared/assets/at.js +29 -0
  156. package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
  157. package/src/lib/shared/assets/double-arrow-right.js +29 -0
  158. package/src/lib/shared/assets/index.d.ts +11 -0
  159. package/src/lib/shared/assets/justified-text.cjs +53 -0
  160. package/src/lib/shared/assets/justified-text.js +29 -0
  161. package/src/lib/shared/assets/location.cjs +53 -0
  162. package/src/lib/shared/assets/location.js +29 -0
  163. package/src/lib/shared/assets/mail.cjs +53 -0
  164. package/src/lib/shared/assets/mail.js +29 -0
  165. package/src/lib/shared/assets/phone.cjs +53 -0
  166. package/src/lib/shared/assets/phone.js +29 -0
  167. package/src/lib/shared/assets/size-labels.cjs +53 -0
  168. package/src/lib/shared/assets/size-labels.js +29 -0
  169. package/src/lib/shared/assets/sparkles.cjs +53 -0
  170. package/src/lib/shared/assets/sparkles.js +29 -0
  171. package/src/lib/shared/assets/user-card.cjs +53 -0
  172. package/src/lib/shared/assets/user-card.js +29 -0
  173. package/src/lib/shared/assets/user.cjs +53 -0
  174. package/src/lib/shared/assets/user.js +29 -0
  175. package/src/lib/shared/assets/work-suitcase.cjs +53 -0
  176. package/src/lib/shared/assets/work-suitcase.js +29 -0
  177. package/src/lib/shared/types/index.d.ts +4 -0
  178. package/src/lib/shared/utils/functions/splitCamelCase/index.d.ts +1 -0
  179. package/src/lib/shared/utils/functions/splitCamelCase/splitCamelCase.cjs +8 -0
  180. package/src/lib/shared/utils/functions/splitCamelCase/splitCamelCase.d.ts +1 -0
  181. package/src/lib/shared/utils/functions/splitCamelCase/splitCamelCase.js +4 -0
  182. package/src/lib/styles/index.shadow.cjs +1 -1
  183. package/src/lib/styles/index.shadow.js +1 -1
  184. package/src/lib/utils/constants/errors.cjs +7 -0
  185. package/src/lib/utils/constants/errors.d.ts +1 -0
  186. package/src/lib/utils/constants/errors.js +3 -0
  187. package/src/lib/utils/constants/index.d.ts +1 -1
  188. package/src/lib/utils/constants/localStorage.cjs +3 -1
  189. package/src/lib/utils/constants/localStorage.d.ts +1 -0
  190. package/src/lib/utils/constants/localStorage.js +3 -2
  191. package/src/lib/utils/functions/digestSHA256/digestSHA256.cjs +11 -0
  192. package/src/lib/utils/functions/digestSHA256/digestSHA256.d.ts +1 -0
  193. package/src/lib/utils/functions/digestSHA256/digestSHA256.js +7 -0
  194. package/src/lib/utils/functions/digestSHA256/index.d.ts +1 -0
  195. package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.cjs +14 -0
  196. package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.d.ts +1 -0
  197. package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.js +10 -0
  198. package/src/lib/utils/functions/encodeBase64URL/index.d.ts +1 -0
  199. package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.cjs +1 -1
  200. package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +1 -1
  201. package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.cjs +33 -0
  202. package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.d.ts +1 -0
  203. package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.js +29 -0
  204. package/src/lib/utils/functions/getRedirectURIOrigin/index.d.ts +1 -0
  205. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
  206. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
  207. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
  208. package/src/lib/utils/functions/getUserProfileFields/index.d.ts +1 -0
  209. package/src/lib/utils/functions/index.d.ts +8 -0
  210. package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
  211. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
  212. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
  213. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
  214. package/src/lib/utils/functions/randomString/index.d.ts +1 -0
  215. package/src/lib/utils/functions/randomString/randomString.cjs +14 -0
  216. package/src/lib/utils/functions/randomString/randomString.d.ts +1 -0
  217. package/src/lib/utils/functions/randomString/randomString.js +10 -0
  218. package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +1 -0
  219. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +45 -0
  220. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +17 -0
  221. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +40 -0
  222. package/src/lib/utils/functions/stringifyURIQuery/index.d.ts +1 -0
  223. package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.cjs +13 -0
  224. package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.d.ts +1 -0
  225. package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.js +9 -0
  226. package/src/lib/utils/hooks/authenticationHooks/index.d.ts +1 -0
  227. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +7 -5
  228. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +4 -1
  229. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +7 -5
  230. package/src/lib/utils/hooks/index.d.ts +10 -2
  231. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
  232. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
  233. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
  234. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +11 -9
  235. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
  236. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +11 -9
  237. package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +1 -0
  238. package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +1 -0
  239. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
  240. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
  241. package/src/lib/utils/hooks/useAuthenticateConnectedUser/useAuthenticateConnectedUser.cjs +1 -0
  242. package/src/lib/utils/hooks/useAuthenticateConnectedUser/useAuthenticateConnectedUser.js +1 -0
  243. package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.cjs +7 -0
  244. package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.d.ts +6 -0
  245. package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.js +7 -0
  246. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
  247. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
  248. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
  249. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +7 -6
  250. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +7 -6
  251. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
  252. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
  253. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
  254. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
  255. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
  256. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
  257. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
  258. package/src/lib/utils/hooks/useFindSocialIcon/index.d.ts +1 -0
  259. package/src/lib/utils/hooks/{useGetSocialIcon/useGetSocialIcon.cjs → useFindSocialIcon/useFindSocialIcon.cjs} +3 -3
  260. package/src/lib/utils/hooks/useFindSocialIcon/useFindSocialIcon.d.ts +3 -0
  261. package/src/lib/utils/hooks/useFindSocialIcon/useFindSocialIcon.js +10 -0
  262. package/src/lib/utils/hooks/useOnUnmount/index.d.ts +1 -0
  263. package/src/lib/utils/hooks/useOnUnmount/useOnUnmount.cjs +21 -0
  264. package/src/lib/utils/hooks/useOnUnmount/useOnUnmount.d.ts +1 -0
  265. package/src/lib/utils/hooks/useOnUnmount/useOnUnmount.js +17 -0
  266. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -2
  267. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +2 -1
  268. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
  269. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +164 -35
  270. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +7 -3
  271. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +166 -37
  272. package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
  273. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +61 -0
  274. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
  275. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
  276. package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
  277. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +47 -0
  278. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
  279. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +43 -0
  280. package/src/lib/utils/hooks/useUserDataForm/index.d.ts +1 -0
  281. package/src/lib/utils/hooks/useUserUpdateRequest/index.d.ts +3 -0
  282. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/index.d.ts +1 -0
  283. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +107 -0
  284. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.d.ts +9 -0
  285. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +103 -0
  286. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/index.d.ts +2 -0
  287. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/types.d.ts +7 -0
  288. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs +73 -0
  289. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.d.ts +7 -0
  290. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js +69 -0
  291. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/validateUpdateRequest/index.d.ts +1 -0
  292. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/validateUpdateRequest/validateUpdateRequest.cjs +31 -0
  293. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/validateUpdateRequest/validateUpdateRequest.d.ts +6 -0
  294. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/validateUpdateRequest/validateUpdateRequest.js +27 -0
  295. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +7 -94
  296. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +4 -24
  297. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +7 -94
  298. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -0
  299. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -0
  300. package/src/lib/utils/hooks/useWalletConnectorEvent/index.d.ts +1 -0
  301. package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.cjs +42 -0
  302. package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.d.ts +12 -0
  303. package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.js +38 -0
  304. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +12 -0
  305. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +12 -0
  306. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +91 -136
  307. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
  308. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +92 -137
  309. package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +1 -0
  310. package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +1 -0
  311. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +8 -4
  312. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
  313. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +8 -4
  314. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
  315. package/src/lib/views/AccountExistsView/AccountExistsView.cjs +10 -6
  316. package/src/lib/views/AccountExistsView/AccountExistsView.js +10 -6
  317. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +17 -7
  318. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +17 -7
  319. package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +7 -3
  320. package/src/lib/views/CollectUserDataView/CollectUserDataView.js +7 -3
  321. package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +6 -2
  322. package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +6 -2
  323. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +11 -4
  324. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +11 -4
  325. package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.cjs +7 -3
  326. package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.js +7 -3
  327. package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +7 -3
  328. package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +7 -3
  329. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +20 -8
  330. package/src/lib/views/EmailUpdate/EmailUpdate.js +20 -8
  331. package/src/lib/views/EmailVerification/EmailVerification.cjs +56 -11
  332. package/src/lib/views/EmailVerification/EmailVerification.js +59 -14
  333. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +8 -3
  334. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +8 -3
  335. package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.cjs +7 -3
  336. package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.js +7 -3
  337. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +14 -8
  338. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.d.ts +5 -1
  339. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +15 -9
  340. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
  341. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
  342. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +10 -6
  343. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +10 -6
  344. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +114 -0
  345. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
  346. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +110 -0
  347. package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
  348. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +22 -6
  349. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +22 -6
  350. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +23 -7
  351. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +23 -7
  352. package/src/lib/views/NoAccess/NoAccess.cjs +7 -4
  353. package/src/lib/views/NoAccess/NoAccess.js +7 -4
  354. package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.cjs +7 -3
  355. package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.js +7 -3
  356. package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.cjs +7 -3
  357. package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.js +7 -3
  358. package/src/lib/views/PendingConnectView/PendingConnectView.cjs +7 -3
  359. package/src/lib/views/PendingConnectView/PendingConnectView.js +7 -3
  360. package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +7 -3
  361. package/src/lib/views/PendingSignatureView/PendingSignatureView.js +7 -3
  362. package/src/lib/views/QrCodeView/QRCode.cjs +5 -1
  363. package/src/lib/views/QrCodeView/QRCode.js +5 -1
  364. package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +7 -3
  365. package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +7 -3
  366. package/src/lib/views/QrCodeView/QrCodeView.cjs +7 -3
  367. package/src/lib/views/QrCodeView/QrCodeView.js +7 -3
  368. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +18 -17
  369. package/src/lib/views/SendBalanceView/SendBalanceView.js +18 -17
  370. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +71 -0
  371. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
  372. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +67 -0
  373. package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
  374. package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
  375. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +10 -7
  376. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +10 -7
  377. package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +10 -6
  378. package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +10 -6
  379. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +27 -5
  380. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +27 -5
  381. package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
  382. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
  383. package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.cjs → useTransactionGas/useTransactionGas.cjs} +22 -43
  384. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
  385. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.js +71 -0
  386. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
  387. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
  388. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +7 -0
  389. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
  390. package/src/lib/views/UserFieldEditorView/UserFieldEditorView.cjs +73 -0
  391. package/src/lib/views/UserFieldEditorView/UserFieldEditorView.d.ts +9 -0
  392. package/src/lib/views/UserFieldEditorView/UserFieldEditorView.js +69 -0
  393. package/src/lib/views/UserFieldEditorView/UserFieldsToIcon/UserFieldsToIcon.cjs +48 -0
  394. package/src/lib/views/UserFieldEditorView/UserFieldsToIcon/UserFieldsToIcon.d.ts +7 -0
  395. package/src/lib/views/UserFieldEditorView/UserFieldsToIcon/UserFieldsToIcon.js +44 -0
  396. package/src/lib/views/UserFieldEditorView/UserFieldsToIcon/index.d.ts +1 -0
  397. package/src/lib/views/UserFieldEditorView/index.d.ts +1 -0
  398. package/src/lib/views/UserFieldEditorView/useAssignDefaultValues/index.d.ts +1 -0
  399. package/src/lib/views/UserFieldEditorView/useAssignDefaultValues/useAssignDefaultValues.cjs +34 -0
  400. package/src/lib/views/UserFieldEditorView/useAssignDefaultValues/useAssignDefaultValues.d.ts +7 -0
  401. package/src/lib/views/UserFieldEditorView/useAssignDefaultValues/useAssignDefaultValues.js +30 -0
  402. package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.cjs +68 -0
  403. package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.d.ts +2 -0
  404. package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.js +64 -0
  405. package/src/lib/views/WalletCannotBeTransferredView/index.d.ts +1 -0
  406. package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.cjs +7 -3
  407. package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.js +7 -3
  408. package/src/lib/views/WalletList/WalletList.cjs +4 -1
  409. package/src/lib/views/WalletList/WalletList.js +4 -1
  410. package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +9 -3
  411. package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +9 -3
  412. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +27 -7
  413. package/src/lib/views/WalletLockedView/WalletLockedView.js +27 -7
  414. package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +7 -3
  415. package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +7 -3
  416. package/src/lib/views/WalletUsedView/WalletUsedView.cjs +7 -3
  417. package/src/lib/views/WalletUsedView/WalletUsedView.js +7 -3
  418. package/src/lib/views/viewToComponentMap.cjs +4 -0
  419. package/src/lib/views/viewToComponentMap.js +4 -0
  420. package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +7 -3
  421. package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +7 -3
  422. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.cjs +8 -4
  423. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.js +8 -4
  424. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.cjs +7 -3
  425. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.js +7 -3
  426. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +7 -3
  427. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +7 -3
  428. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.cjs +7 -3
  429. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js +7 -3
  430. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +8 -4
  431. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +8 -4
  432. package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +7 -3
  433. package/src/lib/widgets/DynamicWidget/DynamicWidget.js +7 -3
  434. package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.cjs +7 -3
  435. package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.js +7 -3
  436. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +7 -3
  437. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +7 -3
  438. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +7 -3
  439. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +7 -3
  440. package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.cjs +7 -3
  441. package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.js +7 -3
  442. package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.cjs +7 -3
  443. package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.js +7 -3
  444. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.cjs +2 -1
  445. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.js +2 -1
  446. package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.cjs +7 -3
  447. package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.js +7 -3
  448. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs +1 -1
  449. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.js +1 -1
  450. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs +6 -2
  451. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js +6 -2
  452. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +7 -3
  453. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +7 -3
  454. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.cjs +5 -1
  455. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.js +5 -1
  456. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.cjs +7 -3
  457. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.js +7 -3
  458. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +7 -3
  459. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +7 -3
  460. package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.cjs +7 -3
  461. package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.js +7 -3
  462. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +7 -3
  463. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +7 -3
  464. package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.cjs +7 -3
  465. package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.js +7 -3
  466. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.cjs +7 -3
  467. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.js +7 -3
  468. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +7 -3
  469. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +7 -3
  470. package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.cjs +7 -3
  471. package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.js +7 -3
  472. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +6 -2
  473. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +6 -2
  474. package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +4 -1
  475. package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +4 -1
  476. package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.cjs +7 -3
  477. package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.js +7 -3
  478. package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.cjs +7 -3
  479. package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.js +7 -3
  480. package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.cjs +7 -3
  481. package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.js +7 -3
  482. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.cjs +7 -3
  483. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.js +7 -3
  484. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.cjs +7 -3
  485. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.js +7 -3
  486. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +7 -3
  487. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +7 -3
  488. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +7 -3
  489. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +7 -3
  490. package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs +7 -3
  491. package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js +7 -3
  492. package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +7 -3
  493. package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +7 -3
  494. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +7 -3
  495. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +7 -3
  496. package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +7 -3
  497. package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +7 -3
  498. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +7 -2
  499. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +7 -2
  500. package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.cjs +8 -4
  501. package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.js +8 -4
  502. package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +9 -5
  503. package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +9 -5
  504. package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.cjs +7 -3
  505. package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.js +7 -3
  506. package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.cjs +13 -0
  507. package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.d.ts +2 -0
  508. package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.js +9 -0
  509. package/src/lib/widgets/OAuthIFrameContainer/index.d.ts +1 -0
  510. package/src/lib/widgets/index.d.ts +1 -0
  511. package/src/lib/utils/hooks/useGetSocialIcon/index.d.ts +0 -1
  512. package/src/lib/utils/hooks/useGetSocialIcon/useGetSocialIcon.d.ts +0 -2
  513. package/src/lib/utils/hooks/useGetSocialIcon/useGetSocialIcon.js +0 -10
  514. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
  515. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -18
  516. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +0 -92
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
6
  var React = require('react');
7
+ var types = require('@dynamic-labs/types');
7
8
  var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
8
9
  var api = require('../../../data/api.cjs');
9
10
  var useUpdateUserProfileByJWTCallback = require('../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
@@ -23,13 +24,35 @@ require('@dynamic-labs/multi-wallet');
23
24
  var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
24
25
  var index = require('../../functions/getEnabledOAuthProviders/index.cjs');
25
26
  var isSocialKycEnabled = require('../../functions/isSocialKycEnabled/isSocialKycEnabled.cjs');
27
+ var randomString = require('../../functions/randomString/randomString.cjs');
28
+ var stringifyURIQuery = require('../../functions/stringifyURIQuery/stringifyURIQuery.cjs');
29
+ var digestSHA256 = require('../../functions/digestSHA256/digestSHA256.cjs');
30
+ var encodeBase64URL = require('../../functions/encodeBase64URL/encodeBase64URL.cjs');
31
+ var getRedirectURIOrigin = require('../../functions/getRedirectURIOrigin/getRedirectURIOrigin.cjs');
26
32
 
27
- const useSocialAccounts = () => {
33
+ const socialProviders = [
34
+ 'discord',
35
+ 'facebook',
36
+ 'github',
37
+ 'google',
38
+ 'instagram',
39
+ 'twitch',
40
+ 'twitter',
41
+ ];
42
+ // pkce params are only required for twitter and break if added for other providers, like google
43
+ // so we should only add provider that support pkce to this list
44
+ const providersRequiringPkce = ['twitter', 'github'];
45
+ const providersWithoutWindowOpenerRefence = ['twitter'];
46
+ const useSocialAccounts = ({ sessionTimeout } = {
47
+ sessionTimeout: 10000,
48
+ }) => {
28
49
  var _a;
29
50
  const { environmentId, user, projectSettings, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
30
51
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
31
52
  const [isProcessing, setIsProcessing] = React.useState(false);
32
53
  const [error, setError] = React.useState();
54
+ const providersWaitingOauthMessages = React.useRef({});
55
+ const authWindowInterval = React.useRef();
33
56
  const userJwt = (_a = getAuthToken.getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
34
57
  const oauthProviders = index.getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
35
58
  const verifiedOAuthCredentialsMap = React.useMemo(() => {
@@ -43,89 +66,195 @@ const useSocialAccounts = () => {
43
66
  ];
44
67
  })));
45
68
  }, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
46
- const handleError = (message) => {
69
+ const handleError = (code, message) => {
47
70
  logger.logger.error(message);
48
71
  setIsProcessing(false);
49
- setError(message);
72
+ setError({ code, message });
50
73
  };
51
- const linkSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
52
- setError(undefined);
53
- setIsProcessing(true);
54
- if (!isSocialKycEnabled.isSocialKycEnabled(projectSettings)) {
55
- handleError('Social linking is not enabled on the dashboard');
74
+ const addOAuthIFrame = (url) => {
75
+ const container = document.getElementById('oauth-iframe-container');
76
+ let oauthIFrame = document.getElementById('oauth-iframe');
77
+ if (!container || oauthIFrame) {
56
78
  return;
57
79
  }
80
+ oauthIFrame = document.createElement('iframe');
81
+ oauthIFrame.setAttribute('id', 'oauth-iframe');
82
+ oauthIFrame.setAttribute('src', url);
83
+ container.appendChild(oauthIFrame);
84
+ };
85
+ const removeOAuthIFrame = () => {
86
+ const oauthIFrame = document.getElementById('oauth-iframe');
87
+ if (oauthIFrame) {
88
+ oauthIFrame.remove();
89
+ }
90
+ };
91
+ const checkValidProvider = (provider) => {
58
92
  if (!provider) {
59
- handleError('Provider is required');
60
- return;
93
+ handleError(types.SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required');
94
+ return false;
95
+ }
96
+ if (!socialProviders.includes(provider)) {
97
+ handleError(types.SocialOAuthErrorCode.INVALID_PROVIDER, `Invalid social provider. Valid providers are: ${socialProviders.join(', ')}`);
98
+ return false;
99
+ }
100
+ return true;
101
+ };
102
+ const checkValidOAuthLinking = (provider) => {
103
+ if (!isSocialKycEnabled.isSocialKycEnabled(projectSettings)) {
104
+ handleError(types.SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard');
105
+ return false;
106
+ }
107
+ if (!checkValidProvider(provider)) {
108
+ return false;
61
109
  }
62
110
  const verifiedCredential = verifiedOAuthCredentialsMap[provider];
63
111
  if (verifiedCredential) {
64
- handleError(`Account already linked for provider: ${provider}`);
65
- return;
112
+ handleError(types.SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`);
113
+ return false;
66
114
  }
67
115
  const oauthProvider = oauthProviders.find((p) => p.provider === provider);
68
116
  if (!oauthProvider) {
69
- handleError(`Provider is not enabled on the dashboard: ${provider}`);
117
+ handleError(types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`);
118
+ return false;
119
+ }
120
+ return true;
121
+ };
122
+ const linkSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
123
+ var _b;
124
+ clearInterval(authWindowInterval.current);
125
+ setError(undefined);
126
+ setIsProcessing(true);
127
+ // invalid linking request
128
+ if (!checkValidOAuthLinking(provider)) {
70
129
  return;
71
130
  }
131
+ const state = randomString.randomString(8);
132
+ const verifier = randomString.randomString(43);
133
+ const clearListeners = () => {
134
+ removeOAuthIFrame();
135
+ window.removeEventListener('message', handleAuthWindowMessage);
136
+ providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: false });
137
+ };
72
138
  const handleAuthWindowMessage = (event) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
73
- var _b, _c, _d;
74
- if (((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) === 'authorization_response') {
75
- logger.logger.debug('Message received', { data: event.data });
139
+ var _c;
140
+ const message = event.data;
141
+ const isAuthorizationMessage = (message === null || message === void 0 ? void 0 : message.type) === 'authorization_response';
142
+ if (isAuthorizationMessage) {
143
+ logger.logger.debug('Message received', { data: message });
76
144
  }
77
- if (((_c = event.data) === null || _c === void 0 ? void 0 : _c.type) !== 'authorization_response' ||
78
- ((_d = event.data) === null || _d === void 0 ? void 0 : _d.provider) !== provider) {
145
+ const isValidMessage = isAuthorizationMessage && (message === null || message === void 0 ? void 0 : message.provider) === provider;
146
+ // don't process imvalid messages for provider
147
+ if (!isValidMessage) {
148
+ return;
149
+ }
150
+ if (!((_c = providersWaitingOauthMessages.current) === null || _c === void 0 ? void 0 : _c[provider])) {
151
+ handleError(types.SocialOAuthErrorCode.SESSION_TIMEOUT, `Linking ${provider} account session timeout.`);
152
+ return;
153
+ }
154
+ clearListeners();
155
+ const { code, error } = message;
156
+ if (error && error !== 'undefined') {
157
+ handleError(types.SocialOAuthErrorCode.OAUTH_ERROR, `Failed to link ${provider} social account: ${error}`);
158
+ return;
159
+ }
160
+ if (!code) {
161
+ handleError(types.SocialOAuthErrorCode.NO_AUTH_CODE, `Failed to link ${provider} social account: no authorization code`);
79
162
  return;
80
163
  }
81
- const { code } = event.data;
82
164
  const jwt = yield api.verifyOAuth(environmentId, provider, {
83
165
  code,
166
+ codeVerifier: verifier,
167
+ state,
84
168
  }, String(userJwt));
85
169
  if (!jwt) {
86
- handleError(`Failed to link social account: ${provider}`);
170
+ handleError(types.SocialOAuthErrorCode.VERIFICATION_ERROR, `Failed to link social account: ${provider}`);
87
171
  return;
88
172
  }
89
173
  yield updateUserProfileByJWT(jwt);
90
174
  setIsProcessing(false);
91
175
  });
92
- window.addEventListener('message', handleAuthWindowMessage);
93
- const authWindow = window.open(oauthProvider.authorizationUrl, '_blank', 'width=500,height=600');
94
- const authWindowInterval = setInterval(() => {
95
- if (authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed) {
96
- window.removeEventListener('message', handleAuthWindowMessage);
97
- clearInterval(authWindowInterval);
176
+ const loginUrl = yield api.getOauthLoginUrl(environmentId, provider, String(userJwt));
177
+ if (!loginUrl) {
178
+ handleError(types.SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to link social account: ${provider}`);
179
+ return;
180
+ }
181
+ // we need to use an iframe to be the intermediary in communications between the popup and the sdk
182
+ // because of twitter limitations with accessing the window.opener and BroadcastChannel not working between
183
+ // different origins (our api redirect page and the app where the sdk is running)
184
+ const oauthIFrameUrl = `${getRedirectURIOrigin.getRedirectURIOrigin(loginUrl)}/sdkoauth`;
185
+ addOAuthIFrame(oauthIFrameUrl);
186
+ let oauthLoginUrl = loginUrl;
187
+ if (providersRequiringPkce.includes(provider)) {
188
+ const digest = yield digestSHA256.digestSHA256(verifier);
189
+ const pkceParams = stringifyURIQuery.stringifyURIQuery({
190
+ code_challenge: encodeBase64URL.encodeBase64URL(digest),
191
+ code_challenge_method: 'S256',
192
+ state: state,
193
+ });
194
+ oauthLoginUrl = `${loginUrl}&${pkceParams}`;
195
+ }
196
+ if (!((_b = providersWaitingOauthMessages.current) === null || _b === void 0 ? void 0 : _b[provider])) {
197
+ window.addEventListener('message', handleAuthWindowMessage);
198
+ providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: true });
199
+ }
200
+ const authWindow = window.open(oauthLoginUrl, '_blank', 'width=500,height=600');
201
+ if (!providersWithoutWindowOpenerRefence.includes(provider)) {
202
+ // For provider that support window.opener, we need to clear all states/listeners when the window is closed
203
+ authWindowInterval.current = setInterval(() => {
204
+ var _a;
205
+ if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
206
+ return;
207
+ }
208
+ // window was closed by user, before completing oauth
209
+ if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
210
+ clearListeners();
211
+ handleError(types.SocialOAuthErrorCode.OAUTH_WINDOW_CLOSED, `Linking ${provider} account window closed.`);
212
+ }
213
+ clearInterval(authWindowInterval.current);
98
214
  setIsProcessing(false);
99
- }
100
- }, 1000);
215
+ });
216
+ }
217
+ else {
218
+ // For provider that don't support window.opener, we need to use a timeout to try to detect when the
219
+ // window is closed
220
+ authWindowInterval.current = setInterval(() => {
221
+ var _a;
222
+ // user didn't complete oauth
223
+ if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
224
+ clearListeners();
225
+ handleError(types.SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Linking ${provider} account window timeout.`);
226
+ }
227
+ setIsProcessing(false);
228
+ clearInterval(authWindowInterval.current);
229
+ }, sessionTimeout);
230
+ }
101
231
  });
102
232
  const unlinkSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
103
- var _e;
233
+ var _d;
104
234
  setError(undefined);
105
235
  setIsProcessing(true);
106
- if (!provider) {
107
- handleError('Provider is required');
236
+ if (!checkValidProvider(provider)) {
108
237
  return;
109
238
  }
110
239
  const verifiedCredential = verifiedOAuthCredentialsMap[provider];
111
240
  if (!verifiedCredential) {
112
- handleError(`No account linked for provider: ${provider}`);
241
+ handleError(types.SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`);
113
242
  return;
114
243
  }
115
244
  try {
116
245
  const jwt = yield api.unlinkOAuth({
117
246
  environmentId,
118
- verifiedCrentialId: (_e = verifiedCredential.id) !== null && _e !== void 0 ? _e : '',
247
+ verifiedCrentialId: (_d = verifiedCredential.id) !== null && _d !== void 0 ? _d : '',
119
248
  }, String(userJwt));
120
249
  if (!jwt) {
121
- handleError(`Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
250
+ handleError(types.SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
122
251
  return;
123
252
  }
124
253
  yield updateUserProfileByJWT(jwt);
125
254
  setIsProcessing(false);
126
255
  }
127
256
  catch (err) {
128
- handleError(`Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
257
+ handleError(types.SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
129
258
  }
130
259
  });
131
260
  const isLinked = (provider) => Boolean(verifiedOAuthCredentialsMap[provider]);
@@ -1,10 +1,14 @@
1
1
  import { ProviderEnum } from '@dynamic-labs/sdk-api';
2
- import { SocialAccountInformation } from '@dynamic-labs/types';
3
- export declare const useSocialAccounts: () => {
4
- readonly error: string | undefined;
2
+ import { SocialAccountInformation, SocialOAuthError } from '@dynamic-labs/types';
3
+ type UseSocialAccountsProps = {
4
+ sessionTimeout: number;
5
+ };
6
+ export declare const useSocialAccounts: ({ sessionTimeout }?: UseSocialAccountsProps) => {
7
+ readonly error: SocialOAuthError | undefined;
5
8
  readonly getLinkedAccountInformation: (provider: ProviderEnum) => SocialAccountInformation | undefined;
6
9
  readonly isLinked: (provider: ProviderEnum) => boolean;
7
10
  readonly isProcessing: boolean;
8
11
  readonly linkSocialAccount: (provider: ProviderEnum) => Promise<void>;
9
12
  readonly unlinkSocialAccount: (provider: ProviderEnum) => Promise<void>;
10
13
  };
14
+ export {};
@@ -1,7 +1,8 @@
1
1
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
- import { useState, useMemo } from 'react';
2
+ import { useState, useRef, useMemo } from 'react';
3
+ import { SocialOAuthErrorCode } from '@dynamic-labs/types';
3
4
  import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
4
- import { unlinkOAuth, verifyOAuth } from '../../../data/api.js';
5
+ import { getOauthLoginUrl, unlinkOAuth, verifyOAuth } from '../../../data/api.js';
5
6
  import { useUpdateUserProfileByJWTCallback } from '../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
6
7
  import '@dynamic-labs/sdk-api';
7
8
  import { logger } from '../../../shared/logger.js';
@@ -19,13 +20,35 @@ import '@dynamic-labs/multi-wallet';
19
20
  import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
20
21
  import { getEnabledOAuthProviders } from '../../functions/getEnabledOAuthProviders/index.js';
21
22
  import { isSocialKycEnabled } from '../../functions/isSocialKycEnabled/isSocialKycEnabled.js';
23
+ import { randomString } from '../../functions/randomString/randomString.js';
24
+ import { stringifyURIQuery } from '../../functions/stringifyURIQuery/stringifyURIQuery.js';
25
+ import { digestSHA256 } from '../../functions/digestSHA256/digestSHA256.js';
26
+ import { encodeBase64URL } from '../../functions/encodeBase64URL/encodeBase64URL.js';
27
+ import { getRedirectURIOrigin } from '../../functions/getRedirectURIOrigin/getRedirectURIOrigin.js';
22
28
 
23
- const useSocialAccounts = () => {
29
+ const socialProviders = [
30
+ 'discord',
31
+ 'facebook',
32
+ 'github',
33
+ 'google',
34
+ 'instagram',
35
+ 'twitch',
36
+ 'twitter',
37
+ ];
38
+ // pkce params are only required for twitter and break if added for other providers, like google
39
+ // so we should only add provider that support pkce to this list
40
+ const providersRequiringPkce = ['twitter', 'github'];
41
+ const providersWithoutWindowOpenerRefence = ['twitter'];
42
+ const useSocialAccounts = ({ sessionTimeout } = {
43
+ sessionTimeout: 10000,
44
+ }) => {
24
45
  var _a;
25
46
  const { environmentId, user, projectSettings, onboardingOnlyJwt } = useInternalDynamicContext();
26
47
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
27
48
  const [isProcessing, setIsProcessing] = useState(false);
28
49
  const [error, setError] = useState();
50
+ const providersWaitingOauthMessages = useRef({});
51
+ const authWindowInterval = useRef();
29
52
  const userJwt = (_a = getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
30
53
  const oauthProviders = getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
31
54
  const verifiedOAuthCredentialsMap = useMemo(() => {
@@ -39,89 +62,195 @@ const useSocialAccounts = () => {
39
62
  ];
40
63
  })));
41
64
  }, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
42
- const handleError = (message) => {
65
+ const handleError = (code, message) => {
43
66
  logger.error(message);
44
67
  setIsProcessing(false);
45
- setError(message);
68
+ setError({ code, message });
46
69
  };
47
- const linkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
48
- setError(undefined);
49
- setIsProcessing(true);
50
- if (!isSocialKycEnabled(projectSettings)) {
51
- handleError('Social linking is not enabled on the dashboard');
70
+ const addOAuthIFrame = (url) => {
71
+ const container = document.getElementById('oauth-iframe-container');
72
+ let oauthIFrame = document.getElementById('oauth-iframe');
73
+ if (!container || oauthIFrame) {
52
74
  return;
53
75
  }
76
+ oauthIFrame = document.createElement('iframe');
77
+ oauthIFrame.setAttribute('id', 'oauth-iframe');
78
+ oauthIFrame.setAttribute('src', url);
79
+ container.appendChild(oauthIFrame);
80
+ };
81
+ const removeOAuthIFrame = () => {
82
+ const oauthIFrame = document.getElementById('oauth-iframe');
83
+ if (oauthIFrame) {
84
+ oauthIFrame.remove();
85
+ }
86
+ };
87
+ const checkValidProvider = (provider) => {
54
88
  if (!provider) {
55
- handleError('Provider is required');
56
- return;
89
+ handleError(SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required');
90
+ return false;
91
+ }
92
+ if (!socialProviders.includes(provider)) {
93
+ handleError(SocialOAuthErrorCode.INVALID_PROVIDER, `Invalid social provider. Valid providers are: ${socialProviders.join(', ')}`);
94
+ return false;
95
+ }
96
+ return true;
97
+ };
98
+ const checkValidOAuthLinking = (provider) => {
99
+ if (!isSocialKycEnabled(projectSettings)) {
100
+ handleError(SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard');
101
+ return false;
102
+ }
103
+ if (!checkValidProvider(provider)) {
104
+ return false;
57
105
  }
58
106
  const verifiedCredential = verifiedOAuthCredentialsMap[provider];
59
107
  if (verifiedCredential) {
60
- handleError(`Account already linked for provider: ${provider}`);
61
- return;
108
+ handleError(SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`);
109
+ return false;
62
110
  }
63
111
  const oauthProvider = oauthProviders.find((p) => p.provider === provider);
64
112
  if (!oauthProvider) {
65
- handleError(`Provider is not enabled on the dashboard: ${provider}`);
113
+ handleError(SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`);
114
+ return false;
115
+ }
116
+ return true;
117
+ };
118
+ const linkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
119
+ var _b;
120
+ clearInterval(authWindowInterval.current);
121
+ setError(undefined);
122
+ setIsProcessing(true);
123
+ // invalid linking request
124
+ if (!checkValidOAuthLinking(provider)) {
66
125
  return;
67
126
  }
127
+ const state = randomString(8);
128
+ const verifier = randomString(43);
129
+ const clearListeners = () => {
130
+ removeOAuthIFrame();
131
+ window.removeEventListener('message', handleAuthWindowMessage);
132
+ providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: false });
133
+ };
68
134
  const handleAuthWindowMessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
69
- var _b, _c, _d;
70
- if (((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) === 'authorization_response') {
71
- logger.debug('Message received', { data: event.data });
135
+ var _c;
136
+ const message = event.data;
137
+ const isAuthorizationMessage = (message === null || message === void 0 ? void 0 : message.type) === 'authorization_response';
138
+ if (isAuthorizationMessage) {
139
+ logger.debug('Message received', { data: message });
72
140
  }
73
- if (((_c = event.data) === null || _c === void 0 ? void 0 : _c.type) !== 'authorization_response' ||
74
- ((_d = event.data) === null || _d === void 0 ? void 0 : _d.provider) !== provider) {
141
+ const isValidMessage = isAuthorizationMessage && (message === null || message === void 0 ? void 0 : message.provider) === provider;
142
+ // don't process imvalid messages for provider
143
+ if (!isValidMessage) {
144
+ return;
145
+ }
146
+ if (!((_c = providersWaitingOauthMessages.current) === null || _c === void 0 ? void 0 : _c[provider])) {
147
+ handleError(SocialOAuthErrorCode.SESSION_TIMEOUT, `Linking ${provider} account session timeout.`);
148
+ return;
149
+ }
150
+ clearListeners();
151
+ const { code, error } = message;
152
+ if (error && error !== 'undefined') {
153
+ handleError(SocialOAuthErrorCode.OAUTH_ERROR, `Failed to link ${provider} social account: ${error}`);
154
+ return;
155
+ }
156
+ if (!code) {
157
+ handleError(SocialOAuthErrorCode.NO_AUTH_CODE, `Failed to link ${provider} social account: no authorization code`);
75
158
  return;
76
159
  }
77
- const { code } = event.data;
78
160
  const jwt = yield verifyOAuth(environmentId, provider, {
79
161
  code,
162
+ codeVerifier: verifier,
163
+ state,
80
164
  }, String(userJwt));
81
165
  if (!jwt) {
82
- handleError(`Failed to link social account: ${provider}`);
166
+ handleError(SocialOAuthErrorCode.VERIFICATION_ERROR, `Failed to link social account: ${provider}`);
83
167
  return;
84
168
  }
85
169
  yield updateUserProfileByJWT(jwt);
86
170
  setIsProcessing(false);
87
171
  });
88
- window.addEventListener('message', handleAuthWindowMessage);
89
- const authWindow = window.open(oauthProvider.authorizationUrl, '_blank', 'width=500,height=600');
90
- const authWindowInterval = setInterval(() => {
91
- if (authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed) {
92
- window.removeEventListener('message', handleAuthWindowMessage);
93
- clearInterval(authWindowInterval);
172
+ const loginUrl = yield getOauthLoginUrl(environmentId, provider, String(userJwt));
173
+ if (!loginUrl) {
174
+ handleError(SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to link social account: ${provider}`);
175
+ return;
176
+ }
177
+ // we need to use an iframe to be the intermediary in communications between the popup and the sdk
178
+ // because of twitter limitations with accessing the window.opener and BroadcastChannel not working between
179
+ // different origins (our api redirect page and the app where the sdk is running)
180
+ const oauthIFrameUrl = `${getRedirectURIOrigin(loginUrl)}/sdkoauth`;
181
+ addOAuthIFrame(oauthIFrameUrl);
182
+ let oauthLoginUrl = loginUrl;
183
+ if (providersRequiringPkce.includes(provider)) {
184
+ const digest = yield digestSHA256(verifier);
185
+ const pkceParams = stringifyURIQuery({
186
+ code_challenge: encodeBase64URL(digest),
187
+ code_challenge_method: 'S256',
188
+ state: state,
189
+ });
190
+ oauthLoginUrl = `${loginUrl}&${pkceParams}`;
191
+ }
192
+ if (!((_b = providersWaitingOauthMessages.current) === null || _b === void 0 ? void 0 : _b[provider])) {
193
+ window.addEventListener('message', handleAuthWindowMessage);
194
+ providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: true });
195
+ }
196
+ const authWindow = window.open(oauthLoginUrl, '_blank', 'width=500,height=600');
197
+ if (!providersWithoutWindowOpenerRefence.includes(provider)) {
198
+ // For provider that support window.opener, we need to clear all states/listeners when the window is closed
199
+ authWindowInterval.current = setInterval(() => {
200
+ var _a;
201
+ if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
202
+ return;
203
+ }
204
+ // window was closed by user, before completing oauth
205
+ if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
206
+ clearListeners();
207
+ handleError(SocialOAuthErrorCode.OAUTH_WINDOW_CLOSED, `Linking ${provider} account window closed.`);
208
+ }
209
+ clearInterval(authWindowInterval.current);
94
210
  setIsProcessing(false);
95
- }
96
- }, 1000);
211
+ });
212
+ }
213
+ else {
214
+ // For provider that don't support window.opener, we need to use a timeout to try to detect when the
215
+ // window is closed
216
+ authWindowInterval.current = setInterval(() => {
217
+ var _a;
218
+ // user didn't complete oauth
219
+ if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
220
+ clearListeners();
221
+ handleError(SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Linking ${provider} account window timeout.`);
222
+ }
223
+ setIsProcessing(false);
224
+ clearInterval(authWindowInterval.current);
225
+ }, sessionTimeout);
226
+ }
97
227
  });
98
228
  const unlinkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
99
- var _e;
229
+ var _d;
100
230
  setError(undefined);
101
231
  setIsProcessing(true);
102
- if (!provider) {
103
- handleError('Provider is required');
232
+ if (!checkValidProvider(provider)) {
104
233
  return;
105
234
  }
106
235
  const verifiedCredential = verifiedOAuthCredentialsMap[provider];
107
236
  if (!verifiedCredential) {
108
- handleError(`No account linked for provider: ${provider}`);
237
+ handleError(SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`);
109
238
  return;
110
239
  }
111
240
  try {
112
241
  const jwt = yield unlinkOAuth({
113
242
  environmentId,
114
- verifiedCrentialId: (_e = verifiedCredential.id) !== null && _e !== void 0 ? _e : '',
243
+ verifiedCrentialId: (_d = verifiedCredential.id) !== null && _d !== void 0 ? _d : '',
115
244
  }, String(userJwt));
116
245
  if (!jwt) {
117
- handleError(`Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
246
+ handleError(SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
118
247
  return;
119
248
  }
120
249
  yield updateUserProfileByJWT(jwt);
121
250
  setIsProcessing(false);
122
251
  }
123
252
  catch (err) {
124
- handleError(`Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
253
+ handleError(SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
125
254
  }
126
255
  });
127
256
  const isLinked = (provider) => Boolean(verifiedOAuthCredentialsMap[provider]);
@@ -0,0 +1 @@
1
+ export { useTransactionEstimatedGas } from './useTransactionEstimatedGas';
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
+ var usePromise = require('../usePromise/usePromise.cjs');
7
+ require('@dynamic-labs/sdk-api');
8
+ var logger = require('../../../shared/logger.cjs');
9
+ require('@dynamic-labs/iconic');
10
+ require('@dynamic-labs/wallet-connector-core');
11
+ require('react/jsx-runtime');
12
+ require('../../../context/ViewContext/ViewContext.cjs');
13
+ require('react');
14
+ require('@dynamic-labs/wallet-book');
15
+ require('@dynamic-labs/utils');
16
+ require('../../constants/colors.cjs');
17
+ require('../../../shared/utils/classes/storage/localStorage.cjs');
18
+ require('ethers');
19
+ require('../../../shared/consts/index.cjs');
20
+
21
+ /**
22
+ * Hook to estimate the gas required for a transaction.
23
+ *
24
+ * This hook uses the `usePromise` hook to asynchronously estimate the gas required for a transaction.
25
+ * It first tries to estimate the gas without the 'from' field in the transaction, as the Alchemy API
26
+ * checks the origin address funds and can return an error if the origin wallet has no funds for the transaction.
27
+ * If the error 'UNPREDICTABLE_GAS_LIMIT' is encountered, it tries to estimate the gas again with the
28
+ * original transaction.
29
+ *
30
+ * @see {@link https://docs.alchemy.com/reference/eth-estimategas}
31
+ * @see {@link https://docs.ethers.org/v5/troubleshooting/errors/#help-UNPREDICTABLE_GAS_LIMIT}
32
+ *
33
+ * @param {ethers.providers.Web3Provider} provider - The Web3 provider to use for estimating the gas.
34
+ * @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} transaction - The transaction for
35
+ * which to estimate the gas.
36
+ *
37
+ * @returns {PromiseState<ethers.BigNumber>} A promise that resolves to the estimated gas for the transaction.
38
+ */
39
+ const useTransactionEstimatedGas = (provider, transaction) => usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
40
+ // To safely run estimateGas using alchemy, we need to remove the from address
41
+ // because alchemy checks the origin address funds and can return an error if
42
+ // origin wallet has no funds for the transaction
43
+ // https://docs.alchemy.com/reference/eth-estimategas
44
+ const transactionWithNoOrigin = _tslib.__rest(transaction, ["from"]);
45
+ try {
46
+ return yield provider.estimateGas(transactionWithNoOrigin);
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ }
49
+ catch (err) {
50
+ logger.logger.error(err);
51
+ // If the error is UNPREDICTABLE_GAS_LIMIT, we try to estimate gas again
52
+ // with original transaction
53
+ // https://docs.ethers.org/v5/troubleshooting/errors/#help-UNPREDICTABLE_GAS_LIMIT
54
+ if (err.code === 'UNPREDICTABLE_GAS_LIMIT') {
55
+ return provider.estimateGas(transaction);
56
+ }
57
+ throw err;
58
+ }
59
+ }), { deps: [transaction, provider] });
60
+
61
+ exports.useTransactionEstimatedGas = useTransactionEstimatedGas;