@onairos/react-native 3.1.12 → 3.1.14

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 (604) hide show
  1. package/README.md +403 -374
  2. package/lib/commonjs/api/index.js +75 -1
  3. package/lib/commonjs/api/index.js.map +1 -1
  4. package/lib/commonjs/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  5. package/lib/commonjs/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  6. package/lib/commonjs/assets/icons/Facebookicon.png +0 -0
  7. package/lib/commonjs/assets/icons/Gmail.png +0 -0
  8. package/lib/commonjs/assets/icons/Linkedinicon.png +0 -0
  9. package/lib/commonjs/assets/icons/Redditicon.png +0 -0
  10. package/lib/commonjs/assets/icons/YouTubeicon2.png +0 -0
  11. package/lib/commonjs/assets/icons/YouTubeicon3.png +0 -0
  12. package/lib/commonjs/assets/icons/farcaster.png +0 -0
  13. package/lib/commonjs/assets/icons/instagram.png +0 -0
  14. package/lib/commonjs/assets/icons/pinterest.png +0 -0
  15. package/lib/commonjs/assets/icons/swerv_logo.png +0 -0
  16. package/lib/commonjs/assets/icons/twitter.jpg +0 -0
  17. package/lib/commonjs/assets/images/Checkbox.svg +3 -0
  18. package/lib/commonjs/assets/images/EnochE.svg +19 -0
  19. package/lib/commonjs/assets/images/Enochicon1.png +0 -0
  20. package/lib/commonjs/assets/images/Face_ID_logo.png +0 -0
  21. package/lib/commonjs/assets/images/Facebookicon.png +0 -0
  22. package/lib/commonjs/assets/images/Gmail.png +0 -0
  23. package/lib/commonjs/assets/images/Googlelogo.png +0 -0
  24. package/lib/commonjs/assets/images/Linkedinicon.png +0 -0
  25. package/lib/commonjs/assets/images/Onairoslogo.png +0 -0
  26. package/lib/commonjs/assets/images/Personalityprofile.svg +3 -0
  27. package/lib/commonjs/assets/images/Personalitytraits.svg +3 -0
  28. package/lib/commonjs/assets/images/Redditicon.png +0 -0
  29. package/lib/commonjs/assets/images/Userpreferences.svg +3 -0
  30. package/lib/commonjs/assets/images/YouTubeicon3.png +0 -0
  31. package/lib/commonjs/assets/images/arrow.svg +20 -0
  32. package/lib/commonjs/assets/images/basicproficon.svg +43 -0
  33. package/lib/commonjs/assets/images/basicprofile.svg +3 -0
  34. package/lib/commonjs/assets/images/checkmark.svg +4 -0
  35. package/lib/commonjs/assets/images/contentanalysis.svg +3 -0
  36. package/lib/commonjs/assets/images/contenticon.svg +23 -0
  37. package/lib/commonjs/assets/images/persona1.png +0 -0
  38. package/lib/commonjs/assets/images/persona2.png +0 -0
  39. package/lib/commonjs/assets/images/persona3.png +0 -0
  40. package/lib/commonjs/assets/images/persona4.png +0 -0
  41. package/lib/commonjs/assets/images/persona5.png +0 -0
  42. package/lib/commonjs/assets/images/personalityicon.svg +18 -0
  43. package/lib/commonjs/assets/images/x-close.svg +3 -0
  44. package/lib/commonjs/components/BodyText.js +27 -0
  45. package/lib/commonjs/components/BodyText.js.map +1 -0
  46. package/lib/commonjs/components/BrandMark.js +44 -0
  47. package/lib/commonjs/components/BrandMark.js.map +1 -0
  48. package/lib/commonjs/components/CodeInput.js +30 -0
  49. package/lib/commonjs/components/CodeInput.js.map +1 -0
  50. package/lib/commonjs/components/EmailInput.js +30 -0
  51. package/lib/commonjs/components/EmailInput.js.map +1 -0
  52. package/lib/commonjs/components/ExistingUserDataConfirmation.js +474 -0
  53. package/lib/commonjs/components/ExistingUserDataConfirmation.js.map +1 -0
  54. package/lib/commonjs/components/GoogleButton.js +55 -0
  55. package/lib/commonjs/components/GoogleButton.js.map +1 -0
  56. package/lib/commonjs/components/HeadingGroup.js +43 -0
  57. package/lib/commonjs/components/HeadingGroup.js.map +1 -0
  58. package/lib/commonjs/components/ModalHeader.js +99 -0
  59. package/lib/commonjs/components/ModalHeader.js.map +1 -0
  60. package/lib/commonjs/components/ModalSheet.js +41 -0
  61. package/lib/commonjs/components/ModalSheet.js.map +1 -0
  62. package/lib/commonjs/components/Onairos.js +1 -3
  63. package/lib/commonjs/components/Onairos.js.map +1 -1
  64. package/lib/commonjs/components/OnairosButton.js +171 -190
  65. package/lib/commonjs/components/OnairosButton.js.map +1 -1
  66. package/lib/commonjs/components/OnairosSignInButton.js +169 -0
  67. package/lib/commonjs/components/OnairosSignInButton.js.map +1 -0
  68. package/lib/commonjs/components/Overlay.js +5 -5
  69. package/lib/commonjs/components/Overlay.js.map +1 -1
  70. package/lib/commonjs/components/PersonaImage.js +60 -0
  71. package/lib/commonjs/components/PersonaImage.js.map +1 -0
  72. package/lib/commonjs/components/PersonaLoadingScreen.js +156 -0
  73. package/lib/commonjs/components/PersonaLoadingScreen.js.map +1 -0
  74. package/lib/commonjs/components/PersonalizationConsentScreen.js +316 -0
  75. package/lib/commonjs/components/PersonalizationConsentScreen.js.map +1 -0
  76. package/lib/commonjs/components/PinCreationScreen.js +393 -0
  77. package/lib/commonjs/components/PinCreationScreen.js.map +1 -0
  78. package/lib/commonjs/components/PinInput.js +282 -120
  79. package/lib/commonjs/components/PinInput.js.map +1 -1
  80. package/lib/commonjs/components/PlatformConnectorsStep.js +828 -0
  81. package/lib/commonjs/components/PlatformConnectorsStep.js.map +1 -0
  82. package/lib/commonjs/components/PlatformToggle.js +180 -0
  83. package/lib/commonjs/components/PlatformToggle.js.map +1 -0
  84. package/lib/commonjs/components/PrimaryButton.js +180 -0
  85. package/lib/commonjs/components/PrimaryButton.js.map +1 -0
  86. package/lib/commonjs/components/SignInMatchAnimation.js +197 -0
  87. package/lib/commonjs/components/SignInMatchAnimation.js.map +1 -0
  88. package/lib/commonjs/components/SignInStep.js +179 -0
  89. package/lib/commonjs/components/SignInStep.js.map +1 -0
  90. package/lib/commonjs/components/TrainingModal.js +808 -563
  91. package/lib/commonjs/components/TrainingModal.js.map +1 -1
  92. package/lib/commonjs/components/UniversalOnboarding.js +2304 -1283
  93. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  94. package/lib/commonjs/components/VerificationStep.js +154 -0
  95. package/lib/commonjs/components/VerificationStep.js.map +1 -0
  96. package/lib/commonjs/components/WelcomeScreen.js +385 -0
  97. package/lib/commonjs/components/WelcomeScreen.js.map +1 -0
  98. package/lib/commonjs/components/icons/Basicproficon.js +37 -0
  99. package/lib/commonjs/components/icons/Basicproficon.js.map +1 -0
  100. package/lib/commonjs/components/icons/Basicprofile.js +21 -0
  101. package/lib/commonjs/components/icons/Basicprofile.js.map +1 -0
  102. package/lib/commonjs/components/icons/Checkbox.js +21 -0
  103. package/lib/commonjs/components/icons/Checkbox.js.map +1 -0
  104. package/lib/commonjs/components/icons/Checkmark.js +27 -0
  105. package/lib/commonjs/components/icons/Checkmark.js.map +1 -0
  106. package/lib/commonjs/components/icons/Contentanalysis.js +21 -0
  107. package/lib/commonjs/components/icons/Contentanalysis.js.map +1 -0
  108. package/lib/commonjs/components/icons/Contenticon.js +39 -0
  109. package/lib/commonjs/components/icons/Contenticon.js.map +1 -0
  110. package/lib/commonjs/components/icons/EnochE.js +41 -0
  111. package/lib/commonjs/components/icons/EnochE.js.map +1 -0
  112. package/lib/commonjs/components/icons/Personalityicon.js +30 -0
  113. package/lib/commonjs/components/icons/Personalityicon.js.map +1 -0
  114. package/lib/commonjs/components/icons/Personalityprofile.js +21 -0
  115. package/lib/commonjs/components/icons/Personalityprofile.js.map +1 -0
  116. package/lib/commonjs/components/icons/Personalitytraits.js +21 -0
  117. package/lib/commonjs/components/icons/Personalitytraits.js.map +1 -0
  118. package/lib/commonjs/components/icons/Userpreferences.js +21 -0
  119. package/lib/commonjs/components/icons/Userpreferences.js.map +1 -0
  120. package/lib/commonjs/components/icons/index.js +84 -0
  121. package/lib/commonjs/components/icons/index.js.map +1 -0
  122. package/lib/commonjs/components/onboarding/OAuthWebView.js +134 -743
  123. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
  124. package/lib/commonjs/config/api.js +34 -0
  125. package/lib/commonjs/config/api.js.map +1 -0
  126. package/lib/commonjs/context/AuthContext.js +345 -0
  127. package/lib/commonjs/context/AuthContext.js.map +1 -0
  128. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -0
  129. package/lib/commonjs/hooks/useConnectedAccounts.js.map +1 -0
  130. package/lib/commonjs/hooks/useConnections.js +120 -125
  131. package/lib/commonjs/hooks/useConnections.js.map +1 -1
  132. package/lib/commonjs/hooks/useUserConnections.js +148 -0
  133. package/lib/commonjs/hooks/useUserConnections.js.map +1 -0
  134. package/lib/commonjs/index.js +12 -100
  135. package/lib/commonjs/index.js.map +1 -1
  136. package/lib/commonjs/services/apiClient.js +302 -0
  137. package/lib/commonjs/services/apiClient.js.map +1 -0
  138. package/lib/commonjs/services/apiKeyService.js +8 -9
  139. package/lib/commonjs/services/apiKeyService.js.map +1 -1
  140. package/lib/commonjs/services/authService.js +935 -0
  141. package/lib/commonjs/services/authService.js.map +1 -0
  142. package/lib/commonjs/services/biometricPinService.js +184 -0
  143. package/lib/commonjs/services/biometricPinService.js.map +1 -0
  144. package/lib/commonjs/services/connectedAccountsService.js +268 -0
  145. package/lib/commonjs/services/connectedAccountsService.js.map +1 -0
  146. package/lib/commonjs/services/googleAuthService.js +268 -0
  147. package/lib/commonjs/services/googleAuthService.js.map +1 -0
  148. package/lib/commonjs/services/imageCompressionService.js +260 -0
  149. package/lib/commonjs/services/imageCompressionService.js.map +1 -0
  150. package/lib/commonjs/services/jwtStorageService.js +256 -0
  151. package/lib/commonjs/services/jwtStorageService.js.map +1 -0
  152. package/lib/commonjs/services/mobileTrainingService.js +185 -0
  153. package/lib/commonjs/services/mobileTrainingService.js.map +1 -0
  154. package/lib/commonjs/services/pinEncryptionService.js +84 -0
  155. package/lib/commonjs/services/pinEncryptionService.js.map +1 -0
  156. package/lib/commonjs/services/pinStorageUtils.js +105 -0
  157. package/lib/commonjs/services/pinStorageUtils.js.map +1 -0
  158. package/lib/commonjs/services/platformAuthService.js +956 -722
  159. package/lib/commonjs/services/platformAuthService.js.map +1 -1
  160. package/lib/commonjs/services/storageService.js +404 -0
  161. package/lib/commonjs/services/storageService.js.map +1 -0
  162. package/lib/commonjs/services/trainingApiHelpers.js +73 -0
  163. package/lib/commonjs/services/trainingApiHelpers.js.map +1 -0
  164. package/lib/commonjs/services/userConnectionsService.js +486 -0
  165. package/lib/commonjs/services/userConnectionsService.js.map +1 -0
  166. package/lib/commonjs/services/youtubeMigrationService.js +415 -0
  167. package/lib/commonjs/services/youtubeMigrationService.js.map +1 -0
  168. package/lib/commonjs/theme/index.js +249 -0
  169. package/lib/commonjs/theme/index.js.map +1 -0
  170. package/lib/commonjs/utils/eventUtils.js +288 -0
  171. package/lib/commonjs/utils/eventUtils.js.map +1 -0
  172. package/lib/commonjs/utils/haptics.js +66 -0
  173. package/lib/commonjs/utils/haptics.js.map +1 -0
  174. package/lib/commonjs/utils/imagePreloader.js +6 -0
  175. package/lib/commonjs/utils/imagePreloader.js.map +1 -0
  176. package/lib/module/api/index.js +72 -0
  177. package/lib/module/api/index.js.map +1 -1
  178. package/lib/module/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  179. package/lib/module/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  180. package/lib/module/assets/icons/Facebookicon.png +0 -0
  181. package/lib/module/assets/icons/Gmail.png +0 -0
  182. package/lib/module/assets/icons/Linkedinicon.png +0 -0
  183. package/lib/module/assets/icons/Redditicon.png +0 -0
  184. package/lib/module/assets/icons/YouTubeicon2.png +0 -0
  185. package/lib/module/assets/icons/YouTubeicon3.png +0 -0
  186. package/lib/module/assets/icons/farcaster.png +0 -0
  187. package/lib/module/assets/icons/instagram.png +0 -0
  188. package/lib/module/assets/icons/pinterest.png +0 -0
  189. package/lib/module/assets/icons/swerv_logo.png +0 -0
  190. package/lib/module/assets/icons/twitter.jpg +0 -0
  191. package/lib/module/assets/images/Checkbox.svg +3 -0
  192. package/lib/module/assets/images/EnochE.svg +19 -0
  193. package/lib/module/assets/images/Enochicon1.png +0 -0
  194. package/lib/module/assets/images/Face_ID_logo.png +0 -0
  195. package/lib/module/assets/images/Facebookicon.png +0 -0
  196. package/lib/module/assets/images/Gmail.png +0 -0
  197. package/lib/module/assets/images/Googlelogo.png +0 -0
  198. package/lib/module/assets/images/Linkedinicon.png +0 -0
  199. package/lib/module/assets/images/Onairoslogo.png +0 -0
  200. package/lib/module/assets/images/Personalityprofile.svg +3 -0
  201. package/lib/module/assets/images/Personalitytraits.svg +3 -0
  202. package/lib/module/assets/images/Redditicon.png +0 -0
  203. package/lib/module/assets/images/Userpreferences.svg +3 -0
  204. package/lib/module/assets/images/YouTubeicon3.png +0 -0
  205. package/lib/module/assets/images/arrow.svg +20 -0
  206. package/lib/module/assets/images/basicproficon.svg +43 -0
  207. package/lib/module/assets/images/basicprofile.svg +3 -0
  208. package/lib/module/assets/images/checkmark.svg +4 -0
  209. package/lib/module/assets/images/contentanalysis.svg +3 -0
  210. package/lib/module/assets/images/contenticon.svg +23 -0
  211. package/lib/module/assets/images/persona1.png +0 -0
  212. package/lib/module/assets/images/persona2.png +0 -0
  213. package/lib/module/assets/images/persona3.png +0 -0
  214. package/lib/module/assets/images/persona4.png +0 -0
  215. package/lib/module/assets/images/persona5.png +0 -0
  216. package/lib/module/assets/images/personalityicon.svg +18 -0
  217. package/lib/module/assets/images/x-close.svg +3 -0
  218. package/lib/module/components/BodyText.js +20 -0
  219. package/lib/module/components/BodyText.js.map +1 -0
  220. package/lib/module/components/BrandMark.js +37 -0
  221. package/lib/module/components/BrandMark.js.map +1 -0
  222. package/lib/module/components/CodeInput.js +23 -0
  223. package/lib/module/components/CodeInput.js.map +1 -0
  224. package/lib/module/components/EmailInput.js +23 -0
  225. package/lib/module/components/EmailInput.js.map +1 -0
  226. package/lib/module/components/ExistingUserDataConfirmation.js +465 -0
  227. package/lib/module/components/ExistingUserDataConfirmation.js.map +1 -0
  228. package/lib/module/components/GoogleButton.js +48 -0
  229. package/lib/module/components/GoogleButton.js.map +1 -0
  230. package/lib/module/components/HeadingGroup.js +36 -0
  231. package/lib/module/components/HeadingGroup.js.map +1 -0
  232. package/lib/module/components/ModalHeader.js +92 -0
  233. package/lib/module/components/ModalHeader.js.map +1 -0
  234. package/lib/module/components/ModalSheet.js +34 -0
  235. package/lib/module/components/ModalSheet.js.map +1 -0
  236. package/lib/module/components/Onairos.js +1 -3
  237. package/lib/module/components/Onairos.js.map +1 -1
  238. package/lib/module/components/OnairosButton.js +172 -192
  239. package/lib/module/components/OnairosButton.js.map +1 -1
  240. package/lib/module/components/OnairosSignInButton.js +160 -0
  241. package/lib/module/components/OnairosSignInButton.js.map +1 -0
  242. package/lib/module/components/Overlay.js +5 -5
  243. package/lib/module/components/Overlay.js.map +1 -1
  244. package/lib/module/components/PersonaImage.js +53 -0
  245. package/lib/module/components/PersonaImage.js.map +1 -0
  246. package/lib/module/components/PersonaLoadingScreen.js +148 -0
  247. package/lib/module/components/PersonaLoadingScreen.js.map +1 -0
  248. package/lib/module/components/PersonalizationConsentScreen.js +309 -0
  249. package/lib/module/components/PersonalizationConsentScreen.js.map +1 -0
  250. package/lib/module/components/PinCreationScreen.js +386 -0
  251. package/lib/module/components/PinCreationScreen.js.map +1 -0
  252. package/lib/module/components/PinInput.js +283 -120
  253. package/lib/module/components/PinInput.js.map +1 -1
  254. package/lib/module/components/PlatformConnectorsStep.js +820 -0
  255. package/lib/module/components/PlatformConnectorsStep.js.map +1 -0
  256. package/lib/module/components/PlatformToggle.js +173 -0
  257. package/lib/module/components/PlatformToggle.js.map +1 -0
  258. package/lib/module/components/PrimaryButton.js +172 -0
  259. package/lib/module/components/PrimaryButton.js.map +1 -0
  260. package/lib/module/components/SignInMatchAnimation.js +189 -0
  261. package/lib/module/components/SignInMatchAnimation.js.map +1 -0
  262. package/lib/module/components/SignInStep.js +171 -0
  263. package/lib/module/components/SignInStep.js.map +1 -0
  264. package/lib/module/components/TrainingModal.js +809 -565
  265. package/lib/module/components/TrainingModal.js.map +1 -1
  266. package/lib/module/components/UniversalOnboarding.js +2307 -1284
  267. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  268. package/lib/module/components/VerificationStep.js +146 -0
  269. package/lib/module/components/VerificationStep.js.map +1 -0
  270. package/lib/module/components/WelcomeScreen.js +378 -0
  271. package/lib/module/components/WelcomeScreen.js.map +1 -0
  272. package/lib/module/components/icons/Basicproficon.js +30 -0
  273. package/lib/module/components/icons/Basicproficon.js.map +1 -0
  274. package/lib/module/components/icons/Basicprofile.js +14 -0
  275. package/lib/module/components/icons/Basicprofile.js.map +1 -0
  276. package/lib/module/components/icons/Checkbox.js +14 -0
  277. package/lib/module/components/icons/Checkbox.js.map +1 -0
  278. package/lib/module/components/icons/Checkmark.js +20 -0
  279. package/lib/module/components/icons/Checkmark.js.map +1 -0
  280. package/lib/module/components/icons/Contentanalysis.js +14 -0
  281. package/lib/module/components/icons/Contentanalysis.js.map +1 -0
  282. package/lib/module/components/icons/Contenticon.js +32 -0
  283. package/lib/module/components/icons/Contenticon.js.map +1 -0
  284. package/lib/module/components/icons/EnochE.js +34 -0
  285. package/lib/module/components/icons/EnochE.js.map +1 -0
  286. package/lib/module/components/icons/Personalityicon.js +23 -0
  287. package/lib/module/components/icons/Personalityicon.js.map +1 -0
  288. package/lib/module/components/icons/Personalityprofile.js +14 -0
  289. package/lib/module/components/icons/Personalityprofile.js.map +1 -0
  290. package/lib/module/components/icons/Personalitytraits.js +14 -0
  291. package/lib/module/components/icons/Personalitytraits.js.map +1 -0
  292. package/lib/module/components/icons/Userpreferences.js +14 -0
  293. package/lib/module/components/icons/Userpreferences.js.map +1 -0
  294. package/lib/module/components/icons/index.js +13 -0
  295. package/lib/module/components/icons/index.js.map +1 -0
  296. package/lib/module/components/onboarding/OAuthWebView.js +136 -744
  297. package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
  298. package/lib/module/config/api.js +26 -0
  299. package/lib/module/config/api.js.map +1 -0
  300. package/lib/module/context/AuthContext.js +335 -0
  301. package/lib/module/context/AuthContext.js.map +1 -0
  302. package/lib/module/hooks/useConnectedAccounts.js +106 -0
  303. package/lib/module/hooks/useConnectedAccounts.js.map +1 -0
  304. package/lib/module/hooks/useConnections.js +119 -125
  305. package/lib/module/hooks/useConnections.js.map +1 -1
  306. package/lib/module/hooks/useUserConnections.js +140 -0
  307. package/lib/module/hooks/useUserConnections.js.map +1 -0
  308. package/lib/module/index.js +51 -15
  309. package/lib/module/index.js.map +1 -1
  310. package/lib/module/services/apiClient.js +298 -0
  311. package/lib/module/services/apiClient.js.map +1 -0
  312. package/lib/module/services/apiKeyService.js +8 -9
  313. package/lib/module/services/apiKeyService.js.map +1 -1
  314. package/lib/module/services/authService.js +905 -0
  315. package/lib/module/services/authService.js.map +1 -0
  316. package/lib/module/services/biometricPinService.js +173 -0
  317. package/lib/module/services/biometricPinService.js.map +1 -0
  318. package/lib/module/services/connectedAccountsService.js +255 -0
  319. package/lib/module/services/connectedAccountsService.js.map +1 -0
  320. package/lib/module/services/googleAuthService.js +258 -0
  321. package/lib/module/services/googleAuthService.js.map +1 -0
  322. package/lib/module/services/imageCompressionService.js +250 -0
  323. package/lib/module/services/imageCompressionService.js.map +1 -0
  324. package/lib/module/services/jwtStorageService.js +239 -0
  325. package/lib/module/services/jwtStorageService.js.map +1 -0
  326. package/lib/module/services/mobileTrainingService.js +172 -0
  327. package/lib/module/services/mobileTrainingService.js.map +1 -0
  328. package/lib/module/services/pinEncryptionService.js +75 -0
  329. package/lib/module/services/pinEncryptionService.js.map +1 -0
  330. package/lib/module/services/pinStorageUtils.js +93 -0
  331. package/lib/module/services/pinStorageUtils.js.map +1 -0
  332. package/lib/module/services/platformAuthService.js +943 -704
  333. package/lib/module/services/platformAuthService.js.map +1 -1
  334. package/lib/module/services/storageService.js +383 -0
  335. package/lib/module/services/storageService.js.map +1 -0
  336. package/lib/module/services/trainingApiHelpers.js +67 -0
  337. package/lib/module/services/trainingApiHelpers.js.map +1 -0
  338. package/lib/module/services/userConnectionsService.js +476 -0
  339. package/lib/module/services/userConnectionsService.js.map +1 -0
  340. package/lib/module/services/youtubeMigrationService.js +404 -0
  341. package/lib/module/services/youtubeMigrationService.js.map +1 -0
  342. package/lib/module/theme/index.js +244 -0
  343. package/lib/module/theme/index.js.map +1 -0
  344. package/lib/module/utils/eventUtils.js +270 -0
  345. package/lib/module/utils/eventUtils.js.map +1 -0
  346. package/lib/module/utils/haptics.js +59 -0
  347. package/lib/module/utils/haptics.js.map +1 -0
  348. package/lib/module/utils/imagePreloader.js +3 -0
  349. package/lib/module/utils/imagePreloader.js.map +1 -0
  350. package/lib/typescript/api/index.d.ts +8 -0
  351. package/lib/typescript/api/index.d.ts.map +1 -1
  352. package/lib/typescript/components/BodyText.d.ts +10 -0
  353. package/lib/typescript/components/BodyText.d.ts.map +1 -0
  354. package/lib/typescript/components/BrandMark.d.ts +11 -0
  355. package/lib/typescript/components/BrandMark.d.ts.map +1 -0
  356. package/lib/typescript/components/CodeInput.d.ts +10 -0
  357. package/lib/typescript/components/CodeInput.d.ts.map +1 -0
  358. package/lib/typescript/components/EmailInput.d.ts +8 -0
  359. package/lib/typescript/components/EmailInput.d.ts.map +1 -0
  360. package/lib/typescript/components/ExistingUserDataConfirmation.d.ts +12 -0
  361. package/lib/typescript/components/ExistingUserDataConfirmation.d.ts.map +1 -0
  362. package/lib/typescript/components/GoogleButton.d.ts +11 -0
  363. package/lib/typescript/components/GoogleButton.d.ts.map +1 -0
  364. package/lib/typescript/components/HeadingGroup.d.ts +11 -0
  365. package/lib/typescript/components/HeadingGroup.d.ts.map +1 -0
  366. package/lib/typescript/components/ModalHeader.d.ts +11 -0
  367. package/lib/typescript/components/ModalHeader.d.ts.map +1 -0
  368. package/lib/typescript/components/ModalSheet.d.ts +13 -0
  369. package/lib/typescript/components/ModalSheet.d.ts.map +1 -0
  370. package/lib/typescript/components/Onairos.d.ts.map +1 -1
  371. package/lib/typescript/components/OnairosButton.d.ts +29 -4
  372. package/lib/typescript/components/OnairosButton.d.ts.map +1 -1
  373. package/lib/typescript/components/OnairosSignInButton.d.ts +14 -0
  374. package/lib/typescript/components/OnairosSignInButton.d.ts.map +1 -0
  375. package/lib/typescript/components/PersonaImage.d.ts +8 -0
  376. package/lib/typescript/components/PersonaImage.d.ts.map +1 -0
  377. package/lib/typescript/components/PersonaLoadingScreen.d.ts +10 -0
  378. package/lib/typescript/components/PersonaLoadingScreen.d.ts.map +1 -0
  379. package/lib/typescript/components/PersonalizationConsentScreen.d.ts +10 -0
  380. package/lib/typescript/components/PersonalizationConsentScreen.d.ts.map +1 -0
  381. package/lib/typescript/components/PinCreationScreen.d.ts +10 -0
  382. package/lib/typescript/components/PinCreationScreen.d.ts.map +1 -0
  383. package/lib/typescript/components/PinInput.d.ts +11 -1
  384. package/lib/typescript/components/PinInput.d.ts.map +1 -1
  385. package/lib/typescript/components/PlatformConnectorsStep.d.ts +11 -0
  386. package/lib/typescript/components/PlatformConnectorsStep.d.ts.map +1 -0
  387. package/lib/typescript/components/PlatformToggle.d.ts +20 -0
  388. package/lib/typescript/components/PlatformToggle.d.ts.map +1 -0
  389. package/lib/typescript/components/PrimaryButton.d.ts +22 -0
  390. package/lib/typescript/components/PrimaryButton.d.ts.map +1 -0
  391. package/lib/typescript/components/SignInMatchAnimation.d.ts +9 -0
  392. package/lib/typescript/components/SignInMatchAnimation.d.ts.map +1 -0
  393. package/lib/typescript/components/SignInStep.d.ts +12 -0
  394. package/lib/typescript/components/SignInStep.d.ts.map +1 -0
  395. package/lib/typescript/components/TrainingModal.d.ts +12 -1
  396. package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
  397. package/lib/typescript/components/UniversalOnboarding.d.ts +14 -1
  398. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
  399. package/lib/typescript/components/VerificationStep.d.ts +13 -0
  400. package/lib/typescript/components/VerificationStep.d.ts.map +1 -0
  401. package/lib/typescript/components/WelcomeScreen.d.ts +9 -0
  402. package/lib/typescript/components/WelcomeScreen.d.ts.map +1 -0
  403. package/lib/typescript/components/icons/Basicproficon.d.ts +5 -0
  404. package/lib/typescript/components/icons/Basicproficon.d.ts.map +1 -0
  405. package/lib/typescript/components/icons/Basicprofile.d.ts +5 -0
  406. package/lib/typescript/components/icons/Basicprofile.d.ts.map +1 -0
  407. package/lib/typescript/components/icons/Checkbox.d.ts +5 -0
  408. package/lib/typescript/components/icons/Checkbox.d.ts.map +1 -0
  409. package/lib/typescript/components/icons/Checkmark.d.ts +5 -0
  410. package/lib/typescript/components/icons/Checkmark.d.ts.map +1 -0
  411. package/lib/typescript/components/icons/Contentanalysis.d.ts +5 -0
  412. package/lib/typescript/components/icons/Contentanalysis.d.ts.map +1 -0
  413. package/lib/typescript/components/icons/Contenticon.d.ts +5 -0
  414. package/lib/typescript/components/icons/Contenticon.d.ts.map +1 -0
  415. package/lib/typescript/components/icons/EnochE.d.ts +5 -0
  416. package/lib/typescript/components/icons/EnochE.d.ts.map +1 -0
  417. package/lib/typescript/components/icons/Personalityicon.d.ts +5 -0
  418. package/lib/typescript/components/icons/Personalityicon.d.ts.map +1 -0
  419. package/lib/typescript/components/icons/Personalityprofile.d.ts +5 -0
  420. package/lib/typescript/components/icons/Personalityprofile.d.ts.map +1 -0
  421. package/lib/typescript/components/icons/Personalitytraits.d.ts +5 -0
  422. package/lib/typescript/components/icons/Personalitytraits.d.ts.map +1 -0
  423. package/lib/typescript/components/icons/Userpreferences.d.ts +5 -0
  424. package/lib/typescript/components/icons/Userpreferences.d.ts.map +1 -0
  425. package/lib/typescript/components/icons/index.d.ts +12 -0
  426. package/lib/typescript/components/icons/index.d.ts.map +1 -0
  427. package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
  428. package/lib/typescript/config/api.d.ts +24 -0
  429. package/lib/typescript/config/api.d.ts.map +1 -0
  430. package/lib/typescript/context/AuthContext.d.ts +34 -0
  431. package/lib/typescript/context/AuthContext.d.ts.map +1 -0
  432. package/lib/typescript/hooks/useConnectedAccounts.d.ts +11 -0
  433. package/lib/typescript/hooks/useConnectedAccounts.d.ts.map +1 -0
  434. package/lib/typescript/hooks/useConnections.d.ts +10 -5
  435. package/lib/typescript/hooks/useConnections.d.ts.map +1 -1
  436. package/lib/typescript/hooks/useUserConnections.d.ts +12 -0
  437. package/lib/typescript/hooks/useUserConnections.d.ts.map +1 -0
  438. package/lib/typescript/index.d.ts +24 -6
  439. package/lib/typescript/index.d.ts.map +1 -1
  440. package/lib/typescript/services/apiClient.d.ts +91 -0
  441. package/lib/typescript/services/apiClient.d.ts.map +1 -0
  442. package/lib/typescript/services/apiKeyService.d.ts.map +1 -1
  443. package/lib/typescript/services/authService.d.ts +216 -0
  444. package/lib/typescript/services/authService.d.ts.map +1 -0
  445. package/lib/typescript/services/biometricPinService.d.ts +29 -0
  446. package/lib/typescript/services/biometricPinService.d.ts.map +1 -0
  447. package/lib/typescript/services/connectedAccountsService.d.ts +56 -0
  448. package/lib/typescript/services/connectedAccountsService.d.ts.map +1 -0
  449. package/lib/typescript/services/googleAuthService.d.ts +63 -0
  450. package/lib/typescript/services/googleAuthService.d.ts.map +1 -0
  451. package/lib/typescript/services/imageCompressionService.d.ts +37 -0
  452. package/lib/typescript/services/imageCompressionService.d.ts.map +1 -0
  453. package/lib/typescript/services/jwtStorageService.d.ts +86 -0
  454. package/lib/typescript/services/jwtStorageService.d.ts.map +1 -0
  455. package/lib/typescript/services/mobileTrainingService.d.ts +45 -0
  456. package/lib/typescript/services/mobileTrainingService.d.ts.map +1 -0
  457. package/lib/typescript/services/pinEncryptionService.d.ts +17 -0
  458. package/lib/typescript/services/pinEncryptionService.d.ts.map +1 -0
  459. package/lib/typescript/services/pinStorageUtils.d.ts +25 -0
  460. package/lib/typescript/services/pinStorageUtils.d.ts.map +1 -0
  461. package/lib/typescript/services/platformAuthService.d.ts +34 -109
  462. package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
  463. package/lib/typescript/services/storageService.d.ts +128 -0
  464. package/lib/typescript/services/storageService.d.ts.map +1 -0
  465. package/lib/typescript/services/trainingApiHelpers.d.ts +38 -0
  466. package/lib/typescript/services/trainingApiHelpers.d.ts.map +1 -0
  467. package/lib/typescript/services/userConnectionsService.d.ts +90 -0
  468. package/lib/typescript/services/userConnectionsService.d.ts.map +1 -0
  469. package/lib/typescript/services/youtubeMigrationService.d.ts +12 -0
  470. package/lib/typescript/services/youtubeMigrationService.d.ts.map +1 -0
  471. package/lib/typescript/theme/index.d.ts +416 -0
  472. package/lib/typescript/theme/index.d.ts.map +1 -0
  473. package/lib/typescript/types/index.d.ts +39 -0
  474. package/lib/typescript/types/index.d.ts.map +1 -1
  475. package/lib/typescript/utils/eventUtils.d.ts +108 -0
  476. package/lib/typescript/utils/eventUtils.d.ts.map +1 -0
  477. package/lib/typescript/utils/haptics.d.ts +11 -0
  478. package/lib/typescript/utils/haptics.d.ts.map +1 -0
  479. package/lib/typescript/utils/imagePreloader.d.ts +2 -0
  480. package/lib/typescript/utils/imagePreloader.d.ts.map +1 -0
  481. package/package.json +163 -145
  482. package/src/api/index.ts +41 -0
  483. package/src/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  484. package/src/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  485. package/src/assets/icons/Facebookicon.png +0 -0
  486. package/src/assets/icons/Gmail.png +0 -0
  487. package/src/assets/icons/Linkedinicon.png +0 -0
  488. package/src/assets/icons/Redditicon.png +0 -0
  489. package/src/assets/icons/YouTubeicon2.png +0 -0
  490. package/src/assets/icons/YouTubeicon3.png +0 -0
  491. package/src/assets/icons/farcaster.png +0 -0
  492. package/src/assets/icons/instagram.png +0 -0
  493. package/src/assets/icons/pinterest.png +0 -0
  494. package/src/assets/icons/swerv_logo.png +0 -0
  495. package/src/assets/icons/twitter.jpg +0 -0
  496. package/src/assets/images/Checkbox.svg +3 -0
  497. package/src/assets/images/EnochE.svg +19 -0
  498. package/src/assets/images/Enochicon1.png +0 -0
  499. package/src/assets/images/Face_ID_logo.png +0 -0
  500. package/src/assets/images/Facebookicon.png +0 -0
  501. package/src/assets/images/Gmail.png +0 -0
  502. package/src/assets/images/Googlelogo.png +0 -0
  503. package/src/assets/images/Linkedinicon.png +0 -0
  504. package/src/assets/images/Onairoslogo.png +0 -0
  505. package/src/assets/images/Personalityprofile.svg +3 -0
  506. package/src/assets/images/Personalitytraits.svg +3 -0
  507. package/src/assets/images/Redditicon.png +0 -0
  508. package/src/assets/images/Userpreferences.svg +3 -0
  509. package/src/assets/images/YouTubeicon3.png +0 -0
  510. package/src/assets/images/arrow.svg +20 -0
  511. package/src/assets/images/basicproficon.svg +43 -0
  512. package/src/assets/images/basicprofile.svg +3 -0
  513. package/src/assets/images/checkmark.svg +4 -0
  514. package/src/assets/images/contentanalysis.svg +3 -0
  515. package/src/assets/images/contenticon.svg +23 -0
  516. package/src/assets/images/persona1.png +0 -0
  517. package/src/assets/images/persona2.png +0 -0
  518. package/src/assets/images/persona3.png +0 -0
  519. package/src/assets/images/persona4.png +0 -0
  520. package/src/assets/images/persona5.png +0 -0
  521. package/src/assets/images/personalityicon.svg +18 -0
  522. package/src/assets/images/x-close.svg +3 -0
  523. package/src/components/BodyText.tsx +33 -0
  524. package/src/components/BrandMark.tsx +62 -0
  525. package/src/components/CodeInput.tsx +32 -0
  526. package/src/components/EmailInput.tsx +31 -0
  527. package/src/components/ExistingUserDataConfirmation.tsx +507 -0
  528. package/src/components/GoogleButton.tsx +55 -0
  529. package/src/components/HeadingGroup.tsx +49 -0
  530. package/src/components/ModalHeader.tsx +125 -0
  531. package/src/components/ModalSheet.tsx +57 -0
  532. package/src/components/Onairos.tsx +422 -424
  533. package/src/components/OnairosButton.tsx +339 -359
  534. package/src/components/OnairosSignInButton.tsx +166 -0
  535. package/src/components/Overlay.tsx +506 -506
  536. package/src/components/PersonaImage.tsx +79 -0
  537. package/src/components/PersonaLoadingScreen.tsx +201 -0
  538. package/src/components/PersonalizationConsentScreen.tsx +410 -0
  539. package/src/components/PinCreationScreen.tsx +492 -0
  540. package/src/components/PinInput.tsx +555 -343
  541. package/src/components/PlatformConnectorsStep.tsx +892 -0
  542. package/src/components/PlatformToggle.tsx +226 -0
  543. package/src/components/PrimaryButton.tsx +214 -0
  544. package/src/components/SignInMatchAnimation.tsx +225 -0
  545. package/src/components/SignInStep.tsx +217 -0
  546. package/src/components/TrainingModal.tsx +1047 -737
  547. package/src/components/UniversalOnboarding.tsx +2888 -1820
  548. package/src/components/VerificationStep.tsx +198 -0
  549. package/src/components/WelcomeScreen.tsx +473 -0
  550. package/src/components/icons/Basicproficon.tsx +30 -0
  551. package/src/components/icons/Basicprofile.tsx +17 -0
  552. package/src/components/icons/Checkbox.tsx +17 -0
  553. package/src/components/icons/Checkmark.tsx +24 -0
  554. package/src/components/icons/Contentanalysis.tsx +17 -0
  555. package/src/components/icons/Contenticon.tsx +30 -0
  556. package/src/components/icons/EnochE.tsx +39 -0
  557. package/src/components/icons/Personalityicon.tsx +22 -0
  558. package/src/components/icons/Personalityprofile.tsx +17 -0
  559. package/src/components/icons/Personalitytraits.tsx +17 -0
  560. package/src/components/icons/Userpreferences.tsx +17 -0
  561. package/src/components/icons/index.ts +12 -0
  562. package/src/components/onboarding/OAuthWebView.tsx +232 -838
  563. package/src/config/api.ts +25 -0
  564. package/src/context/AuthContext.tsx +393 -0
  565. package/src/hooks/useConnectedAccounts.ts +139 -0
  566. package/src/hooks/useConnections.ts +129 -131
  567. package/src/hooks/useUserConnections.ts +166 -0
  568. package/src/index.ts +94 -49
  569. package/src/services/apiClient.ts +337 -0
  570. package/src/services/apiKeyService.ts +9 -11
  571. package/src/services/authService.ts +1008 -0
  572. package/src/services/biometricPinService.ts +193 -0
  573. package/src/services/connectedAccountsService.ts +290 -0
  574. package/src/services/googleAuthService.ts +279 -0
  575. package/src/services/imageCompressionService.ts +303 -0
  576. package/src/services/jwtStorageService.ts +257 -0
  577. package/src/services/mobileTrainingService.ts +204 -0
  578. package/src/services/pinEncryptionService.ts +76 -0
  579. package/src/services/pinStorageUtils.ts +97 -0
  580. package/src/services/platformAuthService.ts +1346 -1113
  581. package/src/services/storageService.ts +452 -0
  582. package/src/services/trainingApiHelpers.ts +67 -0
  583. package/src/services/userConnectionsService.ts +557 -0
  584. package/src/services/youtubeMigrationService.ts +454 -0
  585. package/src/theme/index.ts +239 -0
  586. package/src/types/index.ts +265 -238
  587. package/src/utils/eventUtils.ts +303 -0
  588. package/src/utils/haptics.ts +59 -0
  589. package/src/utils/imagePreloader.ts +2 -0
  590. package/lib/commonjs/assets/images/email.png +0 -0
  591. package/lib/commonjs/assets/images/linkedin.png +0 -0
  592. package/lib/commonjs/assets/images/reddit.png +0 -0
  593. package/lib/commonjs/assets/images/youtube.png +0 -0
  594. package/lib/commonjs/components/UniversalOnboarding.tsx.new +0 -455
  595. package/lib/module/assets/images/email.png +0 -0
  596. package/lib/module/assets/images/linkedin.png +0 -0
  597. package/lib/module/assets/images/reddit.png +0 -0
  598. package/lib/module/assets/images/youtube.png +0 -0
  599. package/lib/module/components/UniversalOnboarding.tsx.new +0 -455
  600. package/src/assets/images/email.png +0 -0
  601. package/src/assets/images/linkedin.png +0 -0
  602. package/src/assets/images/reddit.png +0 -0
  603. package/src/assets/images/youtube.png +0 -0
  604. package/src/components/UniversalOnboarding.tsx.new +0 -455
@@ -1,838 +1,232 @@
1
- import React, { useState, useRef } from 'react';
2
- import {
3
- View,
4
- Text,
5
- StyleSheet,
6
- TouchableOpacity,
7
- ActivityIndicator,
8
- SafeAreaView,
9
- Dimensions,
10
- Linking,
11
- } from 'react-native';
12
- import { WebView } from 'react-native-webview';
13
- import Icon from 'react-native-vector-icons/MaterialIcons';
14
- import { COLORS } from '../../constants';
15
-
16
- const { width, height } = Dimensions.get('window');
17
-
18
- export interface OAuthWebViewProps {
19
- url: string;
20
- onClose: () => void;
21
- onSuccess: (code: string) => void;
22
- platform?: string;
23
- onComplete?: () => void;
24
- }
25
-
26
- export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
27
- url,
28
- onClose,
29
- onSuccess,
30
- platform = 'platform',
31
- onComplete,
32
- }) => {
33
- const [isLoading, setIsLoading] = useState(true);
34
- const [error, setError] = useState<string | null>(null);
35
- const [errorMessage, setErrorMessage] = useState<string>('');
36
- const [isRetryable, setIsRetryable] = useState(true);
37
- const [retryCount, setRetryCount] = useState(0);
38
- const webViewRef = useRef<WebView>(null);
39
- const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
40
-
41
- console.log('🌐 Opening OAuth WebView with URL:', url);
42
- console.log('🔗 Platform:', platform);
43
- console.log('📱 URL Components:', {
44
- protocol: url.split('://')[0],
45
- domain: url.split('://')[1]?.split('/')[0],
46
- path: url.split('://')[1]?.split('/').slice(1).join('/'),
47
- });
48
-
49
- // Set up timeout for OAuth flow
50
- React.useEffect(() => {
51
- // Clear any existing timeout
52
- if (timeoutRef.current) {
53
- clearTimeout(timeoutRef.current);
54
- }
55
-
56
- // Set a 60-second timeout for OAuth completion
57
- timeoutRef.current = setTimeout(() => {
58
- console.log('OAuth flow timeout - no completion detected');
59
- setError('OAuth flow is taking too long. Please try again or use the browser option.');
60
- setIsLoading(false);
61
- }, 60000);
62
-
63
- return () => {
64
- if (timeoutRef.current) {
65
- clearTimeout(timeoutRef.current);
66
- }
67
- };
68
- }, [url]);
69
-
70
- // Clear timeout when component unmounts or OAuth completes
71
- React.useEffect(() => {
72
- return () => {
73
- if (timeoutRef.current) {
74
- clearTimeout(timeoutRef.current);
75
- }
76
- };
77
- }, []);
78
-
79
- const onNavigationStateChange = (navState: any) => {
80
- const currentUrl = navState.url;
81
- console.log('🌐 Navigation state changed:', {
82
- url: currentUrl,
83
- canGoBack: navState.canGoBack,
84
- canGoForward: navState.canGoForward,
85
- loading: navState.loading,
86
- title: navState.title,
87
- });
88
-
89
- // Don't process if still loading
90
- if (navState.loading) {
91
- return;
92
- }
93
-
94
- // Check if this URL indicates OAuth completion
95
- if (isOAuthComplete(currentUrl)) {
96
- console.log('🎉 OAuth completion detected!');
97
-
98
- // Extract the result
99
- const result = extractOAuthResult(currentUrl);
100
-
101
- if (result.success) {
102
- console.log('✅ OAuth completed successfully:', result);
103
-
104
- // Clear timeout
105
- if (timeoutRef.current) {
106
- clearTimeout(timeoutRef.current);
107
- timeoutRef.current = null;
108
- }
109
-
110
- // Call success callback
111
- if (onSuccess && result.code) {
112
- onSuccess(result.code);
113
- }
114
-
115
- // Close the WebView
116
- if (onComplete) {
117
- onComplete();
118
- }
119
- } else {
120
- console.error('❌ OAuth failed:', result.error);
121
-
122
- // Clear timeout
123
- if (timeoutRef.current) {
124
- clearTimeout(timeoutRef.current);
125
- timeoutRef.current = null;
126
- }
127
-
128
- // Set error state
129
- setError('OAuth authentication failed');
130
- setErrorMessage(result.error || 'Authentication failed');
131
- setIsRetryable(true);
132
- }
133
- }
134
-
135
- // Additional check for Gmail specific patterns
136
- if (platform === 'email' || platform === 'gmail') {
137
- const gmailPatterns = [
138
- 'onairos.uk/Home',
139
- 'onairos.uk/home',
140
- 'https://onairos.uk/Home',
141
- 'https://onairos.uk/home',
142
- ];
143
-
144
- for (const pattern of gmailPatterns) {
145
- if (currentUrl.includes(pattern)) {
146
- console.log('✅ Gmail OAuth success detected via home page redirect');
147
-
148
- // Clear timeout
149
- if (timeoutRef.current) {
150
- clearTimeout(timeoutRef.current);
151
- timeoutRef.current = null;
152
- }
153
-
154
- // Call success callback with Gmail-specific code
155
- if (onSuccess) {
156
- onSuccess('gmail_success');
157
- }
158
-
159
- // Close the WebView
160
- if (onComplete) {
161
- onComplete();
162
- }
163
-
164
- return;
165
- }
166
- }
167
- }
168
-
169
- // Check for error URLs
170
- const errorPatterns = [
171
- 'error=',
172
- 'error_description=',
173
- 'access_denied',
174
- 'user_cancelled',
175
- 'cancelled',
176
- 'denied',
177
- ];
178
-
179
- for (const pattern of errorPatterns) {
180
- if (currentUrl.includes(pattern)) {
181
- console.log('❌ OAuth error detected in URL:', pattern);
182
-
183
- // Clear timeout
184
- if (timeoutRef.current) {
185
- clearTimeout(timeoutRef.current);
186
- timeoutRef.current = null;
187
- }
188
-
189
- // Parse error details
190
- try {
191
- const urlObj = new URL(currentUrl);
192
- const params = new URLSearchParams(urlObj.search);
193
- const errorDescription = params.get('error_description') || params.get('error') || 'Authentication failed';
194
-
195
- setError('OAuth authentication failed');
196
- setErrorMessage(errorDescription);
197
- setIsRetryable(true);
198
- } catch (parseError) {
199
- setError('OAuth authentication failed');
200
- setErrorMessage('Authentication failed');
201
- setIsRetryable(true);
202
- }
203
-
204
- return;
205
- }
206
- }
207
- };
208
-
209
- const handleLoadEnd = () => {
210
- setIsLoading(false);
211
- setError(null);
212
- setErrorMessage('');
213
- };
214
-
215
- const handleError = (syntheticEvent: any) => {
216
- const { nativeEvent } = syntheticEvent;
217
- console.error('🚨 WebView error details:', {
218
- description: nativeEvent.description,
219
- code: nativeEvent.code,
220
- domain: nativeEvent.domain,
221
- url: nativeEvent.url,
222
- canGoBack: nativeEvent.canGoBack,
223
- canGoForward: nativeEvent.canGoForward,
224
- loading: nativeEvent.loading,
225
- target: nativeEvent.target,
226
- title: nativeEvent.title,
227
- });
228
-
229
- // Check for specific NSURLErrorDomain codes
230
- let errorMessage = 'Failed to load OAuth page.';
231
- let isRetryable = true;
232
-
233
- if (nativeEvent.domain === 'NSURLErrorDomain') {
234
- switch (nativeEvent.code) {
235
- case -1009: // NSURLErrorNotConnectedToInternet
236
- errorMessage = 'No internet connection. Please check your network and try again.';
237
- isRetryable = true;
238
- break;
239
- case -1003: // NSURLErrorCannotFindHost
240
- errorMessage = 'Cannot reach authentication server. Please check your internet connection.';
241
- isRetryable = true;
242
- break;
243
- case -1001: // NSURLErrorTimedOut
244
- errorMessage = 'Connection timed out. Please try again.';
245
- isRetryable = true;
246
- break;
247
- case -1200: // NSURLErrorSecureConnectionFailed
248
- errorMessage = 'Secure connection failed. Please try again.';
249
- isRetryable = true;
250
- break;
251
- case -1022: // NSURLErrorAppTransportSecurityRequiresSecureConnection
252
- errorMessage = 'App Transport Security error. Connection must be secure.';
253
- isRetryable = false;
254
- break;
255
- case -1004: // NSURLErrorCannotConnectToHost
256
- errorMessage = 'Cannot connect to authentication server. Please try again later.';
257
- isRetryable = true;
258
- break;
259
- case -1005: // NSURLErrorNetworkConnectionLost
260
- errorMessage = 'Network connection lost. Please check your connection and try again.';
261
- isRetryable = true;
262
- break;
263
- case -1020: // NSURLErrorDataNotAllowed
264
- errorMessage = 'Data not allowed. Please check your cellular data settings.';
265
- isRetryable = true;
266
- break;
267
- default:
268
- errorMessage = `Network error (${nativeEvent.code}): ${nativeEvent.description || 'Please check your connection and try again.'}`;
269
- isRetryable = true;
270
- }
271
- } else if (nativeEvent.domain === 'WebKitErrorDomain') {
272
- switch (nativeEvent.code) {
273
- case 102: // WebKitErrorFrameLoadInterruptedByPolicyChange
274
- errorMessage = 'Page load was interrupted. Please try again.';
275
- isRetryable = true;
276
- break;
277
- case 204: // WebKitErrorPlugInLoadFailed
278
- errorMessage = 'Plugin failed to load. Please try again.';
279
- isRetryable = true;
280
- break;
281
- default:
282
- errorMessage = `WebKit error (${nativeEvent.code}): ${nativeEvent.description || 'Please try again.'}`;
283
- isRetryable = true;
284
- }
285
- }
286
-
287
- console.error('🔴 OAuth WebView Error:', errorMessage);
288
-
289
- // Implement smart retry logic
290
- if (isRetryable && retryCount < 3) {
291
- console.log(`🔄 Auto-retrying OAuth load (attempt ${retryCount + 1}/3) in 3 seconds...`);
292
- setRetryCount(prev => prev + 1);
293
- setIsLoading(true);
294
- setError(null);
295
-
296
- // Retry after a delay with exponential backoff
297
- const retryDelay = 3000 * Math.pow(2, retryCount); // 3s, 6s, 12s
298
- setTimeout(() => {
299
- if (webViewRef.current) {
300
- console.log(`🔄 Attempting retry ${retryCount + 1}...`);
301
- webViewRef.current.reload();
302
- }
303
- }, retryDelay);
304
- } else {
305
- setError(errorMessage);
306
- setIsLoading(false);
307
-
308
- // Show additional help for persistent errors
309
- if (retryCount >= 3) {
310
- console.log('❌ Maximum retries reached, showing error to user');
311
- }
312
- }
313
- };
314
-
315
- const handleOpenInBrowser = () => {
316
- console.log('Opening OAuth URL in external browser:', url);
317
- Linking.openURL(url).catch(err => {
318
- console.error('Failed to open URL in browser:', err);
319
- setError('Unable to open browser. Please check your device settings.');
320
- });
321
- };
322
-
323
- const handleRetry = () => {
324
- console.log('Manual retry requested');
325
- setError(null);
326
- setErrorMessage('');
327
- setIsRetryable(true);
328
- setIsLoading(true);
329
- setRetryCount(0);
330
-
331
- if (webViewRef.current) {
332
- webViewRef.current.reload();
333
- }
334
- };
335
-
336
- /**
337
- * Get platform-specific icon
338
- */
339
- const getPlatformIcon = (platform: string): string => {
340
- switch (platform) {
341
- case 'instagram':
342
- return 'photo-camera';
343
- case 'youtube':
344
- return 'smart-display';
345
- case 'pinterest':
346
- return 'push-pin';
347
- case 'reddit':
348
- return 'forum';
349
- case 'email':
350
- return 'email';
351
- default:
352
- return 'link';
353
- }
354
- };
355
-
356
- /**
357
- * Get platform-specific color
358
- */
359
- const getPlatformColor = (platform: string): string => {
360
- switch (platform) {
361
- case 'instagram':
362
- return '#E1306C';
363
- case 'youtube':
364
- return '#FF0000';
365
- case 'pinterest':
366
- return '#E60023';
367
- case 'reddit':
368
- return '#FF4500';
369
- case 'email':
370
- return '#4285F4';
371
- default:
372
- return COLORS.primary;
373
- }
374
- };
375
-
376
- // Check if URL indicates OAuth completion
377
- const isOAuthComplete = (url: string): boolean => {
378
- // Gmail OAuth completion patterns
379
- const gmailSuccessPatterns = [
380
- 'https://onairos.uk/Home',
381
- 'https://onairos.uk/home',
382
- 'onairos.uk/Home',
383
- 'onairos.uk/home',
384
- process.env.APP_HOME_URL,
385
- ].filter(Boolean);
386
-
387
- // Check for success redirect patterns
388
- for (const pattern of gmailSuccessPatterns) {
389
- if (url.includes(pattern)) {
390
- console.log('✅ OAuth success detected via redirect to:', pattern);
391
- return true;
392
- }
393
- }
394
-
395
- // Check for traditional OAuth callback patterns (more specific)
396
- // Only match actual query parameters, not just any occurrence in the URL
397
- const callbackPatterns = [
398
- 'code=',
399
- 'access_token=',
400
- 'oauth_token=',
401
- 'authorization_code=',
402
- 'auth_code=',
403
- 'token=',
404
- ];
405
-
406
- for (const pattern of callbackPatterns) {
407
- if (url.includes(pattern)) {
408
- console.log('✅ OAuth success detected via callback parameter:', pattern);
409
- return true;
410
- }
411
- }
412
-
413
- // Check for specific callback URLs (more targeted than generic words)
414
- const callbackUrlPatterns = [
415
- '/callback',
416
- '/oauth/callback',
417
- '/auth/callback',
418
- 'redirect_uri',
419
- 'onairos.uk/callback',
420
- 'onairos.uk/oauth',
421
- ];
422
-
423
- for (const pattern of callbackUrlPatterns) {
424
- if (url.includes(pattern)) {
425
- console.log('✅ OAuth success detected via callback URL pattern:', pattern);
426
- return true;
427
- }
428
- }
429
-
430
- // Check for error patterns
431
- const errorPatterns = [
432
- 'error=',
433
- 'error_description=',
434
- 'oauth_error=',
435
- 'auth_error=',
436
- 'access_denied',
437
- 'user_cancelled',
438
- 'cancelled',
439
- 'denied',
440
- ];
441
-
442
- for (const pattern of errorPatterns) {
443
- if (url.includes(pattern)) {
444
- console.log('❌ OAuth error detected via pattern:', pattern);
445
- return false;
446
- }
447
- }
448
-
449
- return false;
450
- };
451
-
452
- // Extract OAuth result from URL
453
- const extractOAuthResult = (url: string): { success: boolean; code?: string; error?: string } => {
454
- try {
455
- const urlObj = new URL(url);
456
- const params = new URLSearchParams(urlObj.search);
457
-
458
- // Check for error first
459
- const error = params.get('error') || params.get('error_description') || params.get('oauth_error');
460
- if (error) {
461
- return { success: false, error };
462
- }
463
-
464
- // Check for success indicators
465
- const code = params.get('code') || params.get('authorization_code') || params.get('auth_code');
466
- const accessToken = params.get('access_token') || params.get('oauth_token') || params.get('token');
467
-
468
- if (code || accessToken) {
469
- return { success: true, code: code || accessToken };
470
- }
471
-
472
- // Check for success redirect to home page (Gmail pattern)
473
- const gmailSuccessPatterns = [
474
- 'https://onairos.uk/Home',
475
- 'https://onairos.uk/home',
476
- 'onairos.uk/Home',
477
- 'onairos.uk/home',
478
- ];
479
-
480
- for (const pattern of gmailSuccessPatterns) {
481
- if (url.includes(pattern)) {
482
- console.log('✅ Gmail OAuth success detected via home page redirect');
483
- return { success: true, code: 'gmail_home_redirect' };
484
- }
485
- }
486
-
487
- // If we reached here and isOAuthComplete returned true, assume success
488
- if (isOAuthComplete(url)) {
489
- return { success: true, code: 'oauth_complete' };
490
- }
491
-
492
- return { success: false, error: 'OAuth completion not detected' };
493
- } catch (error) {
494
- console.error('Error parsing OAuth URL:', error);
495
- return { success: false, error: 'Invalid OAuth callback URL' };
496
- }
497
- };
498
-
499
- if (error) {
500
- return (
501
- <SafeAreaView style={styles.container}>
502
- <View style={styles.header}>
503
- <TouchableOpacity onPress={onClose} style={styles.closeButton}>
504
- <Icon name="close" size={24} color="#000" />
505
- </TouchableOpacity>
506
- <View style={styles.titleContainer}>
507
- <Icon
508
- name={getPlatformIcon(platform)}
509
- size={20}
510
- color={getPlatformColor(platform)}
511
- />
512
- <Text style={styles.titleText}>{platform.charAt(0).toUpperCase() + platform.slice(1)} OAuth</Text>
513
- </View>
514
- </View>
515
-
516
- <View style={styles.errorContainer}>
517
- <Icon name="error-outline" size={48} color="#FF6B6B" />
518
- <Text style={styles.errorTitle}>Connection Error</Text>
519
- <Text style={styles.errorMessage}>{errorMessage || error}</Text>
520
-
521
- {/* Help text based on error type */}
522
- {error.includes('internet') || error.includes('network') ? (
523
- <View style={styles.helpContainer}>
524
- <Text style={styles.helpTitle}>💡 Troubleshooting Steps:</Text>
525
- <Text style={styles.helpText}>• Check your Wi-Fi or cellular connection</Text>
526
- <Text style={styles.helpText}>• Try switching between Wi-Fi and cellular</Text>
527
- <Text style={styles.helpText}>• Ensure you're not using a VPN that blocks OAuth</Text>
528
- <Text style={styles.helpText}>• Close other apps that might be using bandwidth</Text>
529
- </View>
530
- ) : error.includes('timeout') ? (
531
- <View style={styles.helpContainer}>
532
- <Text style={styles.helpTitle}>⏱️ Connection Timeout:</Text>
533
- <Text style={styles.helpText}>• Your connection might be slow</Text>
534
- <Text style={styles.helpText}>• Try again when you have a stronger signal</Text>
535
- <Text style={styles.helpText}>• Use "Open in Browser" for better reliability</Text>
536
- </View>
537
- ) : error.includes('secure') || error.includes('SSL') ? (
538
- <View style={styles.helpContainer}>
539
- <Text style={styles.helpTitle}>🔒 Security Error:</Text>
540
- <Text style={styles.helpText}>• Check your device's date and time settings</Text>
541
- <Text style={styles.helpText}>• Update your device's operating system</Text>
542
- <Text style={styles.helpText}>• Try "Open in Browser" as an alternative</Text>
543
- </View>
544
- ) : (
545
- <View style={styles.helpContainer}>
546
- <Text style={styles.helpTitle}>🔧 General Solutions:</Text>
547
- <Text style={styles.helpText}>• Close and reopen the app</Text>
548
- <Text style={styles.helpText}>• Check your internet connection</Text>
549
- <Text style={styles.helpText}>• Use "Open in Browser" for better reliability</Text>
550
- </View>
551
- )}
552
-
553
- <View style={styles.buttonContainer}>
554
- {isRetryable && (
555
- <TouchableOpacity style={styles.retryButton} onPress={handleRetry}>
556
- <Icon name="refresh" size={20} color="#fff" style={styles.buttonIcon} />
557
- <Text style={styles.retryButtonText}>Retry</Text>
558
- </TouchableOpacity>
559
- )}
560
- <TouchableOpacity style={styles.browserButton} onPress={handleOpenInBrowser}>
561
- <Icon name="open-in-browser" size={20} color="#666" style={styles.buttonIcon} />
562
- <Text style={styles.browserButtonText}>Open in Browser</Text>
563
- </TouchableOpacity>
564
- </View>
565
-
566
- {retryCount >= 3 && (
567
- <View style={styles.persistentErrorContainer}>
568
- <Text style={styles.persistentErrorText}>
569
- Still having trouble? Try these steps:
570
- </Text>
571
- <Text style={styles.persistentErrorStep}>
572
- 1. Use "Open in Browser" for more reliable authentication
573
- </Text>
574
- <Text style={styles.persistentErrorStep}>
575
- 2. Check if other apps can access the internet
576
- </Text>
577
- <Text style={styles.persistentErrorStep}>
578
- 3. Restart your device if the problem persists
579
- </Text>
580
- </View>
581
- )}
582
- </View>
583
- </SafeAreaView>
584
- );
585
- }
586
-
587
- return (
588
- <SafeAreaView style={styles.container}>
589
- <View style={styles.header}>
590
- <TouchableOpacity onPress={onClose} style={styles.closeButton}>
591
- <Icon name="close" size={24} color="#000" />
592
- </TouchableOpacity>
593
- <View style={styles.titleContainer}>
594
- <Icon
595
- name={getPlatformIcon(platform)}
596
- size={20}
597
- color={getPlatformColor(platform)}
598
- />
599
- <Text style={styles.titleText}>{platform.charAt(0).toUpperCase() + platform.slice(1)} OAuth</Text>
600
- </View>
601
- <TouchableOpacity onPress={handleOpenInBrowser} style={styles.browserButton}>
602
- <Icon name="open-in-browser" size={20} color="#666" />
603
- </TouchableOpacity>
604
- </View>
605
-
606
- <WebView
607
- ref={webViewRef}
608
- source={{ uri: url }}
609
- onNavigationStateChange={onNavigationStateChange}
610
- onLoadEnd={handleLoadEnd}
611
- onError={handleError}
612
- onHttpError={(syntheticEvent) => {
613
- const { nativeEvent } = syntheticEvent;
614
- console.error('WebView HTTP error:', nativeEvent);
615
- setError('Failed to load OAuth page. Please check your internet connection.');
616
- setIsLoading(false);
617
- }}
618
- style={styles.webView}
619
- javaScriptEnabled={true}
620
- domStorageEnabled={true}
621
- startInLoadingState={true}
622
- scalesPageToFit={true}
623
- allowsInlineMediaPlayback={true}
624
- mediaPlaybackRequiresUserAction={false}
625
- mixedContentMode="compatibility"
626
- thirdPartyCookiesEnabled={true}
627
- sharedCookiesEnabled={true}
628
- cacheEnabled={true}
629
- allowsBackForwardNavigationGestures={true}
630
- allowsLinkPreview={false}
631
- userAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1"
632
- onShouldStartLoadWithRequest={(request) => {
633
- console.log('WebView attempting to load:', request.url);
634
-
635
- // Block about:srcdoc and other problematic URLs
636
- if (request.url.startsWith('about:') ||
637
- request.url.startsWith('data:') ||
638
- request.url === 'about:blank') {
639
- console.log('Blocking problematic URL:', request.url);
640
- return false;
641
- }
642
-
643
- // Allow all other requests
644
- return true;
645
- }}
646
- onLoadStart={(syntheticEvent) => {
647
- const { nativeEvent } = syntheticEvent;
648
- console.log('WebView load started:', nativeEvent.url);
649
- setIsLoading(true);
650
- }}
651
- onLoadProgress={(syntheticEvent) => {
652
- const { nativeEvent } = syntheticEvent;
653
- console.log('WebView load progress:', nativeEvent.progress);
654
- }}
655
- renderError={(errorName) => (
656
- <View style={styles.errorContainer}>
657
- <Icon name="error-outline" size={48} color="#FF6B6B" />
658
- <Text style={styles.errorTitle}>WebView Error</Text>
659
- <Text style={styles.errorMessage}>
660
- Failed to load the authentication page. Error: {errorName}
661
- </Text>
662
- <TouchableOpacity style={styles.retryButton} onPress={handleRetry}>
663
- <Text style={styles.retryButtonText}>Retry</Text>
664
- </TouchableOpacity>
665
- </View>
666
- )}
667
- renderLoading={() => (
668
- <View style={styles.loadingContainer}>
669
- <ActivityIndicator size="large" color={COLORS.primary} />
670
- <Text style={styles.loadingText}>Loading {platform}...</Text>
671
- </View>
672
- )}
673
- injectedJavaScript={`
674
- // Prevent white screen issues
675
- window.addEventListener('error', function(e) {
676
- console.log('JavaScript error:', e.message);
677
- });
678
-
679
- // Handle OAuth redirects
680
- window.addEventListener('beforeunload', function(e) {
681
- console.log('Page unloading:', window.location.href);
682
- });
683
-
684
- // Monitor for OAuth completion
685
- setInterval(function() {
686
- if (window.location.href.includes('code=') ||
687
- window.location.href.includes('access_token=') ||
688
- window.location.href.includes('oauth_token=') ||
689
- window.location.href.includes('api2.onairos.uk')) {
690
- console.log('OAuth completion detected:', window.location.href);
691
- }
692
- }, 1000);
693
-
694
- true; // Required for injected JavaScript
695
- `}
696
- />
697
- </SafeAreaView>
698
- );
699
- };
700
-
701
- const styles = StyleSheet.create({
702
- container: {
703
- flex: 1,
704
- backgroundColor: '#fff',
705
- },
706
- header: {
707
- flexDirection: 'row',
708
- alignItems: 'center',
709
- height: 56,
710
- backgroundColor: '#f8f8f8',
711
- borderBottomWidth: 1,
712
- borderBottomColor: '#e0e0e0',
713
- paddingHorizontal: 16,
714
- },
715
- titleContainer: {
716
- flex: 1,
717
- flexDirection: 'row',
718
- alignItems: 'center',
719
- justifyContent: 'center',
720
- },
721
- titleText: {
722
- marginLeft: 8,
723
- fontSize: 16,
724
- fontWeight: '500',
725
- color: '#000',
726
- },
727
- closeButton: {
728
- padding: 8,
729
- position: 'absolute',
730
- left: 16,
731
- zIndex: 10,
732
- },
733
- browserButton: {
734
- backgroundColor: 'transparent',
735
- borderWidth: 1,
736
- borderColor: '#666',
737
- paddingHorizontal: 24,
738
- paddingVertical: 12,
739
- borderRadius: 8,
740
- flexDirection: 'row',
741
- alignItems: 'center',
742
- justifyContent: 'center',
743
- },
744
- webView: {
745
- flex: 1,
746
- },
747
- loadingContainer: {
748
- ...StyleSheet.absoluteFillObject,
749
- backgroundColor: 'rgba(255, 255, 255, 0.8)',
750
- alignItems: 'center',
751
- justifyContent: 'center',
752
- },
753
- loadingText: {
754
- marginTop: 10,
755
- fontSize: 16,
756
- color: '#666',
757
- },
758
- errorContainer: {
759
- flex: 1,
760
- alignItems: 'center',
761
- justifyContent: 'center',
762
- padding: 20,
763
- },
764
- errorTitle: {
765
- fontSize: 18,
766
- fontWeight: '600',
767
- color: '#333',
768
- marginTop: 16,
769
- marginBottom: 8,
770
- },
771
- errorMessage: {
772
- fontSize: 14,
773
- color: '#666',
774
- textAlign: 'center',
775
- marginBottom: 20,
776
- },
777
- retryButton: {
778
- backgroundColor: COLORS.primary,
779
- paddingHorizontal: 24,
780
- paddingVertical: 12,
781
- borderRadius: 8,
782
- marginRight: 10,
783
- flexDirection: 'row',
784
- alignItems: 'center',
785
- justifyContent: 'center',
786
- },
787
- retryButtonText: {
788
- color: '#fff',
789
- fontSize: 16,
790
- fontWeight: '600',
791
- },
792
- buttonContainer: {
793
- flexDirection: 'row',
794
- justifyContent: 'center',
795
- alignItems: 'center',
796
- marginTop: 10,
797
- },
798
- browserButtonText: {
799
- color: '#666',
800
- fontSize: 16,
801
- fontWeight: '600',
802
- },
803
- helpContainer: {
804
- marginBottom: 20,
805
- },
806
- helpTitle: {
807
- fontSize: 18,
808
- fontWeight: '600',
809
- color: '#333',
810
- marginBottom: 8,
811
- },
812
- helpText: {
813
- fontSize: 14,
814
- color: '#666',
815
- textAlign: 'center',
816
- },
817
- buttonIcon: {
818
- marginRight: 10,
819
- },
820
- persistentErrorContainer: {
821
- marginTop: 20,
822
- padding: 20,
823
- backgroundColor: '#f8f8f8',
824
- borderRadius: 8,
825
- },
826
- persistentErrorText: {
827
- fontSize: 16,
828
- fontWeight: '600',
829
- color: '#333',
830
- marginBottom: 10,
831
- },
832
- persistentErrorStep: {
833
- fontSize: 14,
834
- color: '#666',
835
- textAlign: 'center',
836
- marginBottom: 5,
837
- },
838
- });
1
+ import React, { useState } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ ActivityIndicator,
8
+ SafeAreaView,
9
+ Dimensions,
10
+ } from 'react-native';
11
+ import { WebView } from 'react-native-webview';
12
+
13
+ const { width, height } = Dimensions.get('window');
14
+
15
+ export interface OAuthWebViewProps {
16
+ url: string;
17
+ onClose: () => void;
18
+ onSuccess: (code: string) => void;
19
+ platform?: string;
20
+ onComplete?: () => void;
21
+ }
22
+
23
+ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
24
+ url,
25
+ onClose,
26
+ onSuccess,
27
+ platform = 'platform',
28
+ onComplete,
29
+ }) => {
30
+ const [isLoading, setIsLoading] = useState(true);
31
+ const [timeoutReached, setTimeoutReached] = useState(false);
32
+
33
+ console.log('Opening OAuth WebView with URL:', url);
34
+
35
+ // Set up a timeout to prevent infinite waiting
36
+ React.useEffect(() => {
37
+ const timeout = setTimeout(() => {
38
+ console.log(`⏰ OAuth timeout reached for ${platform} after 1 minutes`);
39
+ setTimeoutReached(true);
40
+ }, 60000); // 1 minutes timeout
41
+
42
+ return () => clearTimeout(timeout);
43
+ }, [platform]);
44
+
45
+ const handleNavigationStateChange = (navState: any) => {
46
+ console.log(`Navigation state changed for ${platform}:`, navState.url);
47
+
48
+ // Check for the final redirect to onairos.uk domain (this means backend callback completed)
49
+ const isFinalRedirect = (
50
+ navState.url.includes('onairos.uk/Home') ||
51
+ navState.url.includes('onairos.uk/home') ||
52
+ navState.url.includes('onairos.uk/success') ||
53
+ navState.url.startsWith('https://onairos.uk/Home') ||
54
+ navState.url.startsWith('https://onairos.uk/home')
55
+ );
56
+
57
+ // For all platforms, we need to wait for the backend callback to complete
58
+ // The backend processes the OAuth callback and then redirects to onairos.uk/Home
59
+ if (isFinalRedirect) {
60
+ console.log(`${platform} OAuth completed - backend callback finished and redirected to Home`);
61
+ onSuccess('success');
62
+
63
+ // Close the OAuth window after a small delay to ensure redirect is processed
64
+ setTimeout(() => {
65
+ if (onComplete) {
66
+ console.log(`Closing ${platform} OAuth window after callback completion`);
67
+ onComplete();
68
+ }
69
+ }, 1000); // Increased delay to ensure backend processing completes
70
+ return; // Exit early to avoid other triggers
71
+ }
72
+
73
+ // Log intermediate callback URLs for debugging but don't close yet
74
+ const isIntermediateCallback = (
75
+ navState.url.includes('/callback') ||
76
+ navState.url.includes('code=') ||
77
+ navState.url.includes('token=') ||
78
+ navState.url.includes('access_token=')
79
+ );
80
+
81
+ if (isIntermediateCallback && !isFinalRedirect) {
82
+ console.log(`Detected intermediate callback URL for ${platform}:`, navState.url);
83
+ console.log('Waiting for backend processing to complete and final redirect...');
84
+
85
+ // Extract authorization code for logging purposes
86
+ const codeMatch = navState.url.match(/code=([^&]+)/);
87
+ if (codeMatch && codeMatch[1]) {
88
+ console.log('OAuth code detected:', codeMatch[1]);
89
+ }
90
+
91
+ // Don't close yet - wait for the backend to process and redirect
92
+ return;
93
+ }
94
+ };
95
+
96
+ return (
97
+ <View style={styles.modalContainer}>
98
+ <SafeAreaView style={styles.container}>
99
+ <View style={styles.header}>
100
+ <Text style={styles.title}>Connect {platform.charAt(0).toUpperCase() + platform.slice(1)}</Text>
101
+ {timeoutReached && (
102
+ <Text style={styles.timeoutText}>Taking longer than expected...</Text>
103
+ )}
104
+ <TouchableOpacity onPress={onClose} style={styles.closeButton}>
105
+ <Text style={styles.closeButtonText}>✕</Text>
106
+ </TouchableOpacity>
107
+ </View>
108
+
109
+ <View style={styles.webViewContainer}>
110
+ {isLoading && (
111
+ <View style={styles.loadingContainer}>
112
+ <ActivityIndicator size="large" color="#1BA9D4" />
113
+ <Text style={styles.loadingText}>Loading...</Text>
114
+ </View>
115
+ )}
116
+
117
+ <WebView
118
+ source={{ uri: url }}
119
+ onNavigationStateChange={handleNavigationStateChange}
120
+ onLoadStart={() => setIsLoading(true)}
121
+ onLoadEnd={() => setIsLoading(false)}
122
+ style={styles.webView}
123
+ javaScriptEnabled={true}
124
+ domStorageEnabled={true}
125
+ cacheEnabled={true} // Enable cache to remember previous logins
126
+ incognito={false} // Disable incognito mode to remember previous logins
127
+ thirdPartyCookiesEnabled={true}
128
+ sharedCookiesEnabled={true} // Enable shared cookies for Google sign-in
129
+ userAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1"
130
+ onError={(syntheticEvent) => {
131
+ const { nativeEvent } = syntheticEvent;
132
+ console.error(`WebView error for ${platform}:`, nativeEvent);
133
+ // Don't automatically close on error - let user retry or manually close
134
+ }}
135
+ onHttpError={(syntheticEvent) => {
136
+ const { nativeEvent } = syntheticEvent;
137
+ console.error(`WebView HTTP error for ${platform}: ${nativeEvent.statusCode}`, nativeEvent.url);
138
+
139
+ // If we get a 404 or similar error on the final redirect, it might still be successful
140
+ if (nativeEvent.url && nativeEvent.url.includes('onairos.uk')) {
141
+ console.log('HTTP error on onairos.uk domain - treating as potential success');
142
+ onSuccess('success');
143
+ if (onComplete) {
144
+ setTimeout(() => onComplete(), 1000);
145
+ }
146
+ }
147
+ }}
148
+ />
149
+ </View>
150
+ </SafeAreaView>
151
+ </View>
152
+ );
153
+ };
154
+
155
+ const styles = StyleSheet.create({
156
+ modalContainer: {
157
+ position: 'absolute',
158
+ top: 0,
159
+ left: 0,
160
+ right: 0,
161
+ bottom: 0,
162
+ width: width,
163
+ height: height,
164
+ backgroundColor: '#fff',
165
+ zIndex: 9999,
166
+ },
167
+ container: {
168
+ flex: 1,
169
+ backgroundColor: '#fff',
170
+ width: width,
171
+ height: height,
172
+ position: 'absolute',
173
+ top: 0,
174
+ left: 0,
175
+ right: 0,
176
+ bottom: 0,
177
+ zIndex: 999,
178
+ },
179
+ header: {
180
+ flexDirection: 'row',
181
+ alignItems: 'center',
182
+ justifyContent: 'space-between',
183
+ paddingHorizontal: 16,
184
+ paddingVertical: 12,
185
+ borderBottomWidth: 1,
186
+ borderBottomColor: '#E5E5E5',
187
+ backgroundColor: '#fff',
188
+ zIndex: 1000,
189
+ },
190
+ title: {
191
+ fontSize: 18,
192
+ fontWeight: '600',
193
+ color: '#333',
194
+ flex: 1,
195
+ textAlign: 'center',
196
+ },
197
+ closeButton: {
198
+ padding: 8,
199
+ },
200
+ closeButtonText: {
201
+ fontSize: 20,
202
+ color: '#666',
203
+ },
204
+ webViewContainer: {
205
+ flex: 1,
206
+ width: width,
207
+ height: height - 60, // Adjust for header height
208
+ },
209
+ webView: {
210
+ flex: 1,
211
+ width: '100%',
212
+ height: '100%',
213
+ },
214
+ loadingContainer: {
215
+ ...StyleSheet.absoluteFillObject,
216
+ alignItems: 'center',
217
+ justifyContent: 'center',
218
+ backgroundColor: 'rgba(255, 255, 255, 0.9)',
219
+ zIndex: 1,
220
+ },
221
+ loadingText: {
222
+ marginTop: 12,
223
+ fontSize: 16,
224
+ color: '#666',
225
+ },
226
+ timeoutText: {
227
+ fontSize: 12,
228
+ color: '#FF6B6B',
229
+ textAlign: 'center',
230
+ marginTop: 4,
231
+ },
232
+ });