@onairos/react-native 3.1.18 โ†’ 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (734) hide show
  1. package/README.md +374 -403
  2. package/lib/commonjs/api/index.js +1 -75
  3. package/lib/commonjs/api/index.js.map +1 -1
  4. package/lib/commonjs/assets/images/email.png +0 -0
  5. package/lib/commonjs/assets/images/linkedin.png +0 -0
  6. package/lib/commonjs/assets/images/reddit.png +0 -0
  7. package/lib/commonjs/assets/images/youtube.png +0 -0
  8. package/lib/commonjs/components/DataRequestModal.js.map +1 -1
  9. package/lib/commonjs/components/DataRequestScreen.js.map +1 -1
  10. package/lib/commonjs/components/EmailVerificationModal.js.map +1 -1
  11. package/lib/commonjs/components/Onairos.js +3 -1
  12. package/lib/commonjs/components/Onairos.js.map +1 -1
  13. package/lib/commonjs/components/OnairosButton.js +190 -171
  14. package/lib/commonjs/components/OnairosButton.js.map +1 -1
  15. package/lib/commonjs/components/Overlay.js +5 -5
  16. package/lib/commonjs/components/Overlay.js.map +1 -1
  17. package/lib/commonjs/components/PinInput.js +120 -282
  18. package/lib/commonjs/components/PinInput.js.map +1 -1
  19. package/lib/commonjs/components/PlatformList.js.map +1 -1
  20. package/lib/commonjs/components/TrainingModal.js +563 -808
  21. package/lib/commonjs/components/TrainingModal.js.map +1 -1
  22. package/lib/commonjs/components/UniversalOnboarding.js +1296 -2302
  23. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  24. package/lib/commonjs/components/UniversalOnboarding.tsx.new +455 -0
  25. package/lib/commonjs/components/onboarding/OAuthWebView.js +743 -134
  26. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
  27. package/lib/commonjs/components/onboarding/OnboardingHeader.js.map +1 -1
  28. package/lib/commonjs/components/onboarding/PinInput.js.map +1 -1
  29. package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -1
  30. package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -1
  31. package/lib/commonjs/components/screens/LoadingScreen.js.map +1 -1
  32. package/lib/commonjs/components/screens/PinCreationScreen.js.map +1 -1
  33. package/lib/commonjs/constants/index.js.map +1 -1
  34. package/lib/commonjs/hooks/useConnections.js +125 -120
  35. package/lib/commonjs/hooks/useConnections.js.map +1 -1
  36. package/lib/commonjs/hooks/useCredentials.js.map +1 -1
  37. package/lib/commonjs/index.js +27 -157
  38. package/lib/commonjs/index.js.map +1 -1
  39. package/lib/commonjs/services/SDK_API_KEY_VALIDATION.md +428 -0
  40. package/lib/commonjs/services/apiKeyService.js +106 -105
  41. package/lib/commonjs/services/apiKeyService.js.map +1 -1
  42. package/lib/commonjs/services/oauthService.js.map +1 -1
  43. package/lib/commonjs/services/platformAuthService.js +722 -956
  44. package/lib/commonjs/services/platformAuthService.js.map +1 -1
  45. package/lib/commonjs/types/ambient.d.js.map +1 -1
  46. package/lib/commonjs/types/declarations.d.js.map +1 -1
  47. package/lib/commonjs/types/index.d.js.map +1 -1
  48. package/lib/commonjs/types/index.js.map +1 -1
  49. package/lib/commonjs/types/node-fix.d.js.map +1 -1
  50. package/lib/commonjs/types/node-override.d.js.map +1 -1
  51. package/lib/commonjs/types/opacity.d.js.map +1 -1
  52. package/lib/commonjs/types/types.d.js.map +1 -1
  53. package/lib/commonjs/types.js.map +1 -1
  54. package/lib/commonjs/utils/Portal.js +4 -4
  55. package/lib/commonjs/utils/Portal.js.map +1 -1
  56. package/lib/commonjs/utils/api.js +24 -24
  57. package/lib/commonjs/utils/api.js.map +1 -1
  58. package/lib/commonjs/utils/auth.js +18 -18
  59. package/lib/commonjs/utils/auth.js.map +1 -1
  60. package/lib/commonjs/utils/crypto.js +13 -13
  61. package/lib/commonjs/utils/crypto.js.map +1 -1
  62. package/lib/commonjs/utils/debugHelper.js.map +1 -1
  63. package/lib/commonjs/utils/encryption.js +12 -12
  64. package/lib/commonjs/utils/encryption.js.map +1 -1
  65. package/lib/commonjs/utils/onairosApi.js.map +1 -1
  66. package/lib/commonjs/utils/programmaticFlow.js +16 -16
  67. package/lib/commonjs/utils/programmaticFlow.js.map +1 -1
  68. package/lib/commonjs/utils/retryHelper.js +27 -27
  69. package/lib/commonjs/utils/retryHelper.js.map +1 -1
  70. package/lib/commonjs/utils/secureStorage.js.map +1 -1
  71. package/lib/module/api/index.js +0 -72
  72. package/lib/module/api/index.js.map +1 -1
  73. package/lib/module/assets/images/email.png +0 -0
  74. package/lib/module/assets/images/linkedin.png +0 -0
  75. package/lib/module/assets/images/reddit.png +0 -0
  76. package/lib/module/assets/images/youtube.png +0 -0
  77. package/lib/module/components/DataRequestModal.js.map +1 -1
  78. package/lib/module/components/DataRequestScreen.js.map +1 -1
  79. package/lib/module/components/EmailVerificationModal.js.map +1 -1
  80. package/lib/module/components/Onairos.js +3 -1
  81. package/lib/module/components/Onairos.js.map +1 -1
  82. package/lib/module/components/OnairosButton.js +192 -172
  83. package/lib/module/components/OnairosButton.js.map +1 -1
  84. package/lib/module/components/Overlay.js +5 -5
  85. package/lib/module/components/Overlay.js.map +1 -1
  86. package/lib/module/components/PinInput.js +120 -283
  87. package/lib/module/components/PinInput.js.map +1 -1
  88. package/lib/module/components/PlatformList.js.map +1 -1
  89. package/lib/module/components/TrainingModal.js +565 -809
  90. package/lib/module/components/TrainingModal.js.map +1 -1
  91. package/lib/module/components/UniversalOnboarding.js +1297 -2305
  92. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  93. package/lib/module/components/UniversalOnboarding.tsx.new +455 -0
  94. package/lib/module/components/onboarding/OAuthWebView.js +744 -136
  95. package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
  96. package/lib/module/components/onboarding/OnboardingHeader.js.map +1 -1
  97. package/lib/module/components/onboarding/PinInput.js.map +1 -1
  98. package/lib/module/components/onboarding/PlatformConnector.js.map +1 -1
  99. package/lib/module/components/screens/ConnectorScreen.js.map +1 -1
  100. package/lib/module/components/screens/LoadingScreen.js.map +1 -1
  101. package/lib/module/components/screens/PinCreationScreen.js.map +1 -1
  102. package/lib/module/constants/index.js.map +1 -1
  103. package/lib/module/hooks/useConnections.js +125 -119
  104. package/lib/module/hooks/useConnections.js.map +1 -1
  105. package/lib/module/hooks/useCredentials.js.map +1 -1
  106. package/lib/module/index.js +17 -55
  107. package/lib/module/index.js.map +1 -1
  108. package/lib/module/services/SDK_API_KEY_VALIDATION.md +428 -0
  109. package/lib/module/services/apiKeyService.js +106 -105
  110. package/lib/module/services/apiKeyService.js.map +1 -1
  111. package/lib/module/services/oauthService.js.map +1 -1
  112. package/lib/module/services/platformAuthService.js +704 -943
  113. package/lib/module/services/platformAuthService.js.map +1 -1
  114. package/lib/module/types/ambient.d.js.map +1 -1
  115. package/lib/module/types/declarations.d.js.map +1 -1
  116. package/lib/module/types/index.d.js.map +1 -1
  117. package/lib/module/types/index.js.map +1 -1
  118. package/lib/module/types/node-fix.d.js.map +1 -1
  119. package/lib/module/types/node-override.d.js.map +1 -1
  120. package/lib/module/types/opacity.d.js.map +1 -1
  121. package/lib/module/types/types.d.js.map +1 -1
  122. package/lib/module/types.js.map +1 -1
  123. package/lib/module/utils/Portal.js +4 -4
  124. package/lib/module/utils/Portal.js.map +1 -1
  125. package/lib/module/utils/api.js +24 -24
  126. package/lib/module/utils/api.js.map +1 -1
  127. package/lib/module/utils/auth.js +18 -18
  128. package/lib/module/utils/auth.js.map +1 -1
  129. package/lib/module/utils/crypto.js +13 -13
  130. package/lib/module/utils/crypto.js.map +1 -1
  131. package/lib/module/utils/debugHelper.js.map +1 -1
  132. package/lib/module/utils/encryption.js +12 -12
  133. package/lib/module/utils/encryption.js.map +1 -1
  134. package/lib/module/utils/onairosApi.js.map +1 -1
  135. package/lib/module/utils/programmaticFlow.js +16 -16
  136. package/lib/module/utils/programmaticFlow.js.map +1 -1
  137. package/lib/module/utils/retryHelper.js +27 -27
  138. package/lib/module/utils/retryHelper.js.map +1 -1
  139. package/lib/module/utils/secureStorage.js.map +1 -1
  140. package/lib/typescript/api/index.d.ts +7 -15
  141. package/lib/typescript/api/index.d.ts.map +1 -1
  142. package/lib/typescript/components/DataRequestModal.d.ts +10 -10
  143. package/lib/typescript/components/DataRequestScreen.d.ts +10 -10
  144. package/lib/typescript/components/EmailVerificationModal.d.ts +10 -10
  145. package/lib/typescript/components/Onairos.d.ts +3 -3
  146. package/lib/typescript/components/Onairos.d.ts.map +1 -1
  147. package/lib/typescript/components/OnairosButton.d.ts +11 -36
  148. package/lib/typescript/components/OnairosButton.d.ts.map +1 -1
  149. package/lib/typescript/components/Overlay.d.ts +3 -3
  150. package/lib/typescript/components/PinInput.d.ts +3 -13
  151. package/lib/typescript/components/PinInput.d.ts.map +1 -1
  152. package/lib/typescript/components/PlatformList.d.ts +3 -3
  153. package/lib/typescript/components/TrainingModal.d.ts +3 -14
  154. package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
  155. package/lib/typescript/components/UniversalOnboarding.d.ts +3 -16
  156. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
  157. package/lib/typescript/components/onboarding/OAuthWebView.d.ts +9 -9
  158. package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
  159. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +10 -10
  160. package/lib/typescript/components/onboarding/PinInput.d.ts +3 -3
  161. package/lib/typescript/components/onboarding/PlatformConnector.d.ts +12 -12
  162. package/lib/typescript/components/screens/ConnectorScreen.d.ts +8 -8
  163. package/lib/typescript/components/screens/LoadingScreen.d.ts +8 -8
  164. package/lib/typescript/components/screens/PinCreationScreen.d.ts +9 -9
  165. package/lib/typescript/constants/index.d.ts +52 -52
  166. package/lib/typescript/hooks/useConnections.d.ts +8 -13
  167. package/lib/typescript/hooks/useConnections.d.ts.map +1 -1
  168. package/lib/typescript/hooks/useCredentials.d.ts +8 -8
  169. package/lib/typescript/index.d.ts +17 -38
  170. package/lib/typescript/index.d.ts.map +1 -1
  171. package/lib/typescript/services/apiKeyService.d.ts +131 -131
  172. package/lib/typescript/services/apiKeyService.d.ts.map +1 -1
  173. package/lib/typescript/services/oauthService.d.ts +49 -49
  174. package/lib/typescript/services/platformAuthService.d.ts +143 -68
  175. package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
  176. package/lib/typescript/types/index.d.ts +228 -264
  177. package/lib/typescript/types/index.d.ts.map +1 -1
  178. package/lib/typescript/types.d.ts +268 -266
  179. package/lib/typescript/types.d.ts.map +1 -1
  180. package/lib/typescript/utils/Portal.d.ts +13 -13
  181. package/lib/typescript/utils/api.d.ts +5 -5
  182. package/lib/typescript/utils/auth.d.ts +5 -5
  183. package/lib/typescript/utils/crypto.d.ts +3 -3
  184. package/lib/typescript/utils/debugHelper.d.ts +28 -28
  185. package/lib/typescript/utils/encryption.d.ts +18 -18
  186. package/lib/typescript/utils/onairosApi.d.ts +86 -86
  187. package/lib/typescript/utils/programmaticFlow.d.ts +22 -22
  188. package/lib/typescript/utils/retryHelper.d.ts +68 -68
  189. package/lib/typescript/utils/secureStorage.d.ts +93 -93
  190. package/package.json +149 -145
  191. package/src/api/index.ts +110 -151
  192. package/src/assets/images/email.png +0 -0
  193. package/src/assets/images/linkedin.png +0 -0
  194. package/src/assets/images/reddit.png +0 -0
  195. package/src/assets/images/youtube.png +0 -0
  196. package/src/components/DataRequestScreen.tsx +355 -355
  197. package/src/components/EmailVerificationModal.tsx +363 -363
  198. package/src/components/Onairos.tsx +424 -422
  199. package/src/components/OnairosButton.tsx +359 -339
  200. package/src/components/Overlay.tsx +506 -506
  201. package/src/components/PinInput.tsx +343 -555
  202. package/src/components/PlatformList.tsx +144 -144
  203. package/src/components/TrainingModal.tsx +737 -1047
  204. package/src/components/UniversalOnboarding.tsx +1839 -2888
  205. package/src/components/UniversalOnboarding.tsx.new +455 -0
  206. package/src/components/onboarding/OAuthWebView.tsx +838 -232
  207. package/src/hooks/useConnections.ts +163 -161
  208. package/src/hooks/useCredentials.ts +174 -174
  209. package/src/index.js +14 -14
  210. package/src/index.ts +49 -99
  211. package/src/services/SDK_API_KEY_VALIDATION.md +428 -0
  212. package/src/services/apiKeyService.ts +921 -919
  213. package/src/services/platformAuthService.ts +1113 -1346
  214. package/src/types/ambient.d.ts +28 -28
  215. package/src/types/index.ts +241 -265
  216. package/src/types/node-fix.d.ts +18 -18
  217. package/src/types/node-override.d.ts +23 -23
  218. package/src/types/opacity.d.ts +15 -15
  219. package/src/types/types.d.ts +17 -17
  220. package/src/types.ts +6 -4
  221. package/src/utils/Portal.tsx +82 -82
  222. package/src/utils/api.js +111 -111
  223. package/src/utils/auth.js +103 -103
  224. package/src/utils/crypto.js +59 -59
  225. package/src/utils/encryption.ts +68 -68
  226. package/src/utils/programmaticFlow.ts +112 -112
  227. package/src/utils/retryHelper.ts +274 -274
  228. package/types/index.d.ts +213 -213
  229. package/types/node-env.d.ts +14 -14
  230. package/lib/commonjs/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  231. package/lib/commonjs/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  232. package/lib/commonjs/assets/icons/Facebookicon.png +0 -0
  233. package/lib/commonjs/assets/icons/Gmail.png +0 -0
  234. package/lib/commonjs/assets/icons/Linkedinicon.png +0 -0
  235. package/lib/commonjs/assets/icons/Redditicon.png +0 -0
  236. package/lib/commonjs/assets/icons/YouTubeicon2.png +0 -0
  237. package/lib/commonjs/assets/icons/YouTubeicon3.png +0 -0
  238. package/lib/commonjs/assets/icons/farcaster.png +0 -0
  239. package/lib/commonjs/assets/icons/instagram.png +0 -0
  240. package/lib/commonjs/assets/icons/pinterest.png +0 -0
  241. package/lib/commonjs/assets/icons/swerv_logo.png +0 -0
  242. package/lib/commonjs/assets/icons/twitter.jpg +0 -0
  243. package/lib/commonjs/assets/images/Checkbox.svg +0 -3
  244. package/lib/commonjs/assets/images/EnochE.svg +0 -19
  245. package/lib/commonjs/assets/images/Enochicon1.png +0 -0
  246. package/lib/commonjs/assets/images/Face_ID_logo.png +0 -0
  247. package/lib/commonjs/assets/images/Facebookicon.png +0 -0
  248. package/lib/commonjs/assets/images/Gmail.png +0 -0
  249. package/lib/commonjs/assets/images/Googlelogo.png +0 -0
  250. package/lib/commonjs/assets/images/Linkedinicon.png +0 -0
  251. package/lib/commonjs/assets/images/Onairoslogo.png +0 -0
  252. package/lib/commonjs/assets/images/Personalityprofile.svg +0 -3
  253. package/lib/commonjs/assets/images/Personalitytraits.svg +0 -3
  254. package/lib/commonjs/assets/images/Redditicon.png +0 -0
  255. package/lib/commonjs/assets/images/Userpreferences.svg +0 -3
  256. package/lib/commonjs/assets/images/YouTubeicon3.png +0 -0
  257. package/lib/commonjs/assets/images/arrow.svg +0 -20
  258. package/lib/commonjs/assets/images/basicproficon.svg +0 -43
  259. package/lib/commonjs/assets/images/basicprofile.svg +0 -3
  260. package/lib/commonjs/assets/images/checkmark.svg +0 -4
  261. package/lib/commonjs/assets/images/contentanalysis.svg +0 -3
  262. package/lib/commonjs/assets/images/contenticon.svg +0 -23
  263. package/lib/commonjs/assets/images/persona1.png +0 -0
  264. package/lib/commonjs/assets/images/persona2.png +0 -0
  265. package/lib/commonjs/assets/images/persona3.png +0 -0
  266. package/lib/commonjs/assets/images/persona4.png +0 -0
  267. package/lib/commonjs/assets/images/persona5.png +0 -0
  268. package/lib/commonjs/assets/images/personalityicon.svg +0 -18
  269. package/lib/commonjs/assets/images/x-close.svg +0 -3
  270. package/lib/commonjs/components/BodyText.js +0 -27
  271. package/lib/commonjs/components/BodyText.js.map +0 -1
  272. package/lib/commonjs/components/BrandMark.js +0 -44
  273. package/lib/commonjs/components/BrandMark.js.map +0 -1
  274. package/lib/commonjs/components/CodeInput.js +0 -30
  275. package/lib/commonjs/components/CodeInput.js.map +0 -1
  276. package/lib/commonjs/components/EmailInput.js +0 -30
  277. package/lib/commonjs/components/EmailInput.js.map +0 -1
  278. package/lib/commonjs/components/ExistingUserDataConfirmation.js +0 -474
  279. package/lib/commonjs/components/ExistingUserDataConfirmation.js.map +0 -1
  280. package/lib/commonjs/components/GoogleButton.js +0 -55
  281. package/lib/commonjs/components/GoogleButton.js.map +0 -1
  282. package/lib/commonjs/components/HeadingGroup.js +0 -43
  283. package/lib/commonjs/components/HeadingGroup.js.map +0 -1
  284. package/lib/commonjs/components/ModalHeader.js +0 -99
  285. package/lib/commonjs/components/ModalHeader.js.map +0 -1
  286. package/lib/commonjs/components/ModalSheet.js +0 -47
  287. package/lib/commonjs/components/ModalSheet.js.map +0 -1
  288. package/lib/commonjs/components/OnairosSignInButton.js +0 -129
  289. package/lib/commonjs/components/OnairosSignInButton.js.map +0 -1
  290. package/lib/commonjs/components/PersonaImage.js +0 -60
  291. package/lib/commonjs/components/PersonaImage.js.map +0 -1
  292. package/lib/commonjs/components/PersonaLoadingScreen.js +0 -156
  293. package/lib/commonjs/components/PersonaLoadingScreen.js.map +0 -1
  294. package/lib/commonjs/components/PersonalizationConsentScreen.js +0 -316
  295. package/lib/commonjs/components/PersonalizationConsentScreen.js.map +0 -1
  296. package/lib/commonjs/components/PinCreationScreen.js +0 -393
  297. package/lib/commonjs/components/PinCreationScreen.js.map +0 -1
  298. package/lib/commonjs/components/PlatformConnectorsStep.js +0 -828
  299. package/lib/commonjs/components/PlatformConnectorsStep.js.map +0 -1
  300. package/lib/commonjs/components/PlatformToggle.js +0 -180
  301. package/lib/commonjs/components/PlatformToggle.js.map +0 -1
  302. package/lib/commonjs/components/PrimaryButton.js +0 -180
  303. package/lib/commonjs/components/PrimaryButton.js.map +0 -1
  304. package/lib/commonjs/components/SignInMatchAnimation.js +0 -197
  305. package/lib/commonjs/components/SignInMatchAnimation.js.map +0 -1
  306. package/lib/commonjs/components/SignInStep.js +0 -179
  307. package/lib/commonjs/components/SignInStep.js.map +0 -1
  308. package/lib/commonjs/components/VerificationStep.js +0 -154
  309. package/lib/commonjs/components/VerificationStep.js.map +0 -1
  310. package/lib/commonjs/components/WelcomeScreen.js +0 -401
  311. package/lib/commonjs/components/WelcomeScreen.js.map +0 -1
  312. package/lib/commonjs/components/icons/Basicproficon.js +0 -37
  313. package/lib/commonjs/components/icons/Basicproficon.js.map +0 -1
  314. package/lib/commonjs/components/icons/Basicprofile.js +0 -21
  315. package/lib/commonjs/components/icons/Basicprofile.js.map +0 -1
  316. package/lib/commonjs/components/icons/Checkbox.js +0 -21
  317. package/lib/commonjs/components/icons/Checkbox.js.map +0 -1
  318. package/lib/commonjs/components/icons/Checkmark.js +0 -27
  319. package/lib/commonjs/components/icons/Checkmark.js.map +0 -1
  320. package/lib/commonjs/components/icons/Contentanalysis.js +0 -21
  321. package/lib/commonjs/components/icons/Contentanalysis.js.map +0 -1
  322. package/lib/commonjs/components/icons/Contenticon.js +0 -39
  323. package/lib/commonjs/components/icons/Contenticon.js.map +0 -1
  324. package/lib/commonjs/components/icons/EnochE.js +0 -41
  325. package/lib/commonjs/components/icons/EnochE.js.map +0 -1
  326. package/lib/commonjs/components/icons/Personalityicon.js +0 -30
  327. package/lib/commonjs/components/icons/Personalityicon.js.map +0 -1
  328. package/lib/commonjs/components/icons/Personalityprofile.js +0 -21
  329. package/lib/commonjs/components/icons/Personalityprofile.js.map +0 -1
  330. package/lib/commonjs/components/icons/Personalitytraits.js +0 -21
  331. package/lib/commonjs/components/icons/Personalitytraits.js.map +0 -1
  332. package/lib/commonjs/components/icons/Userpreferences.js +0 -21
  333. package/lib/commonjs/components/icons/Userpreferences.js.map +0 -1
  334. package/lib/commonjs/components/icons/index.js +0 -84
  335. package/lib/commonjs/components/icons/index.js.map +0 -1
  336. package/lib/commonjs/config/api.js +0 -34
  337. package/lib/commonjs/config/api.js.map +0 -1
  338. package/lib/commonjs/context/AuthContext.js +0 -345
  339. package/lib/commonjs/context/AuthContext.js.map +0 -1
  340. package/lib/commonjs/hooks/useConnectedAccounts.js +0 -111
  341. package/lib/commonjs/hooks/useConnectedAccounts.js.map +0 -1
  342. package/lib/commonjs/hooks/useUserConnections.js +0 -148
  343. package/lib/commonjs/hooks/useUserConnections.js.map +0 -1
  344. package/lib/commonjs/services/apiClient.js +0 -302
  345. package/lib/commonjs/services/apiClient.js.map +0 -1
  346. package/lib/commonjs/services/authService.js +0 -935
  347. package/lib/commonjs/services/authService.js.map +0 -1
  348. package/lib/commonjs/services/biometricPinService.js +0 -184
  349. package/lib/commonjs/services/biometricPinService.js.map +0 -1
  350. package/lib/commonjs/services/connectedAccountsService.js +0 -268
  351. package/lib/commonjs/services/connectedAccountsService.js.map +0 -1
  352. package/lib/commonjs/services/googleAuthService.js +0 -268
  353. package/lib/commonjs/services/googleAuthService.js.map +0 -1
  354. package/lib/commonjs/services/imageCompressionService.js +0 -260
  355. package/lib/commonjs/services/imageCompressionService.js.map +0 -1
  356. package/lib/commonjs/services/jwtStorageService.js +0 -256
  357. package/lib/commonjs/services/jwtStorageService.js.map +0 -1
  358. package/lib/commonjs/services/mobileTrainingService.js +0 -185
  359. package/lib/commonjs/services/mobileTrainingService.js.map +0 -1
  360. package/lib/commonjs/services/pinEncryptionService.js +0 -84
  361. package/lib/commonjs/services/pinEncryptionService.js.map +0 -1
  362. package/lib/commonjs/services/pinStorageUtils.js +0 -105
  363. package/lib/commonjs/services/pinStorageUtils.js.map +0 -1
  364. package/lib/commonjs/services/storageService.js +0 -404
  365. package/lib/commonjs/services/storageService.js.map +0 -1
  366. package/lib/commonjs/services/trainingApiHelpers.js +0 -73
  367. package/lib/commonjs/services/trainingApiHelpers.js.map +0 -1
  368. package/lib/commonjs/services/userConnectionsService.js +0 -486
  369. package/lib/commonjs/services/userConnectionsService.js.map +0 -1
  370. package/lib/commonjs/services/youtubeMigrationService.js +0 -415
  371. package/lib/commonjs/services/youtubeMigrationService.js.map +0 -1
  372. package/lib/commonjs/theme/index.js +0 -249
  373. package/lib/commonjs/theme/index.js.map +0 -1
  374. package/lib/commonjs/utils/eventUtils.js +0 -288
  375. package/lib/commonjs/utils/eventUtils.js.map +0 -1
  376. package/lib/commonjs/utils/haptics.js +0 -66
  377. package/lib/commonjs/utils/haptics.js.map +0 -1
  378. package/lib/commonjs/utils/imagePreloader.js +0 -6
  379. package/lib/commonjs/utils/imagePreloader.js.map +0 -1
  380. package/lib/module/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  381. package/lib/module/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  382. package/lib/module/assets/icons/Facebookicon.png +0 -0
  383. package/lib/module/assets/icons/Gmail.png +0 -0
  384. package/lib/module/assets/icons/Linkedinicon.png +0 -0
  385. package/lib/module/assets/icons/Redditicon.png +0 -0
  386. package/lib/module/assets/icons/YouTubeicon2.png +0 -0
  387. package/lib/module/assets/icons/YouTubeicon3.png +0 -0
  388. package/lib/module/assets/icons/farcaster.png +0 -0
  389. package/lib/module/assets/icons/instagram.png +0 -0
  390. package/lib/module/assets/icons/pinterest.png +0 -0
  391. package/lib/module/assets/icons/swerv_logo.png +0 -0
  392. package/lib/module/assets/icons/twitter.jpg +0 -0
  393. package/lib/module/assets/images/Checkbox.svg +0 -3
  394. package/lib/module/assets/images/EnochE.svg +0 -19
  395. package/lib/module/assets/images/Enochicon1.png +0 -0
  396. package/lib/module/assets/images/Face_ID_logo.png +0 -0
  397. package/lib/module/assets/images/Facebookicon.png +0 -0
  398. package/lib/module/assets/images/Gmail.png +0 -0
  399. package/lib/module/assets/images/Googlelogo.png +0 -0
  400. package/lib/module/assets/images/Linkedinicon.png +0 -0
  401. package/lib/module/assets/images/Onairoslogo.png +0 -0
  402. package/lib/module/assets/images/Personalityprofile.svg +0 -3
  403. package/lib/module/assets/images/Personalitytraits.svg +0 -3
  404. package/lib/module/assets/images/Redditicon.png +0 -0
  405. package/lib/module/assets/images/Userpreferences.svg +0 -3
  406. package/lib/module/assets/images/YouTubeicon3.png +0 -0
  407. package/lib/module/assets/images/arrow.svg +0 -20
  408. package/lib/module/assets/images/basicproficon.svg +0 -43
  409. package/lib/module/assets/images/basicprofile.svg +0 -3
  410. package/lib/module/assets/images/checkmark.svg +0 -4
  411. package/lib/module/assets/images/contentanalysis.svg +0 -3
  412. package/lib/module/assets/images/contenticon.svg +0 -23
  413. package/lib/module/assets/images/persona1.png +0 -0
  414. package/lib/module/assets/images/persona2.png +0 -0
  415. package/lib/module/assets/images/persona3.png +0 -0
  416. package/lib/module/assets/images/persona4.png +0 -0
  417. package/lib/module/assets/images/persona5.png +0 -0
  418. package/lib/module/assets/images/personalityicon.svg +0 -18
  419. package/lib/module/assets/images/x-close.svg +0 -3
  420. package/lib/module/components/BodyText.js +0 -20
  421. package/lib/module/components/BodyText.js.map +0 -1
  422. package/lib/module/components/BrandMark.js +0 -37
  423. package/lib/module/components/BrandMark.js.map +0 -1
  424. package/lib/module/components/CodeInput.js +0 -23
  425. package/lib/module/components/CodeInput.js.map +0 -1
  426. package/lib/module/components/EmailInput.js +0 -23
  427. package/lib/module/components/EmailInput.js.map +0 -1
  428. package/lib/module/components/ExistingUserDataConfirmation.js +0 -465
  429. package/lib/module/components/ExistingUserDataConfirmation.js.map +0 -1
  430. package/lib/module/components/GoogleButton.js +0 -48
  431. package/lib/module/components/GoogleButton.js.map +0 -1
  432. package/lib/module/components/HeadingGroup.js +0 -36
  433. package/lib/module/components/HeadingGroup.js.map +0 -1
  434. package/lib/module/components/ModalHeader.js +0 -92
  435. package/lib/module/components/ModalHeader.js.map +0 -1
  436. package/lib/module/components/ModalSheet.js +0 -39
  437. package/lib/module/components/ModalSheet.js.map +0 -1
  438. package/lib/module/components/OnairosSignInButton.js +0 -120
  439. package/lib/module/components/OnairosSignInButton.js.map +0 -1
  440. package/lib/module/components/PersonaImage.js +0 -53
  441. package/lib/module/components/PersonaImage.js.map +0 -1
  442. package/lib/module/components/PersonaLoadingScreen.js +0 -148
  443. package/lib/module/components/PersonaLoadingScreen.js.map +0 -1
  444. package/lib/module/components/PersonalizationConsentScreen.js +0 -309
  445. package/lib/module/components/PersonalizationConsentScreen.js.map +0 -1
  446. package/lib/module/components/PinCreationScreen.js +0 -386
  447. package/lib/module/components/PinCreationScreen.js.map +0 -1
  448. package/lib/module/components/PlatformConnectorsStep.js +0 -820
  449. package/lib/module/components/PlatformConnectorsStep.js.map +0 -1
  450. package/lib/module/components/PlatformToggle.js +0 -173
  451. package/lib/module/components/PlatformToggle.js.map +0 -1
  452. package/lib/module/components/PrimaryButton.js +0 -172
  453. package/lib/module/components/PrimaryButton.js.map +0 -1
  454. package/lib/module/components/SignInMatchAnimation.js +0 -189
  455. package/lib/module/components/SignInMatchAnimation.js.map +0 -1
  456. package/lib/module/components/SignInStep.js +0 -171
  457. package/lib/module/components/SignInStep.js.map +0 -1
  458. package/lib/module/components/VerificationStep.js +0 -146
  459. package/lib/module/components/VerificationStep.js.map +0 -1
  460. package/lib/module/components/WelcomeScreen.js +0 -393
  461. package/lib/module/components/WelcomeScreen.js.map +0 -1
  462. package/lib/module/components/icons/Basicproficon.js +0 -30
  463. package/lib/module/components/icons/Basicproficon.js.map +0 -1
  464. package/lib/module/components/icons/Basicprofile.js +0 -14
  465. package/lib/module/components/icons/Basicprofile.js.map +0 -1
  466. package/lib/module/components/icons/Checkbox.js +0 -14
  467. package/lib/module/components/icons/Checkbox.js.map +0 -1
  468. package/lib/module/components/icons/Checkmark.js +0 -20
  469. package/lib/module/components/icons/Checkmark.js.map +0 -1
  470. package/lib/module/components/icons/Contentanalysis.js +0 -14
  471. package/lib/module/components/icons/Contentanalysis.js.map +0 -1
  472. package/lib/module/components/icons/Contenticon.js +0 -32
  473. package/lib/module/components/icons/Contenticon.js.map +0 -1
  474. package/lib/module/components/icons/EnochE.js +0 -34
  475. package/lib/module/components/icons/EnochE.js.map +0 -1
  476. package/lib/module/components/icons/Personalityicon.js +0 -23
  477. package/lib/module/components/icons/Personalityicon.js.map +0 -1
  478. package/lib/module/components/icons/Personalityprofile.js +0 -14
  479. package/lib/module/components/icons/Personalityprofile.js.map +0 -1
  480. package/lib/module/components/icons/Personalitytraits.js +0 -14
  481. package/lib/module/components/icons/Personalitytraits.js.map +0 -1
  482. package/lib/module/components/icons/Userpreferences.js +0 -14
  483. package/lib/module/components/icons/Userpreferences.js.map +0 -1
  484. package/lib/module/components/icons/index.js +0 -13
  485. package/lib/module/components/icons/index.js.map +0 -1
  486. package/lib/module/config/api.js +0 -26
  487. package/lib/module/config/api.js.map +0 -1
  488. package/lib/module/context/AuthContext.js +0 -335
  489. package/lib/module/context/AuthContext.js.map +0 -1
  490. package/lib/module/hooks/useConnectedAccounts.js +0 -106
  491. package/lib/module/hooks/useConnectedAccounts.js.map +0 -1
  492. package/lib/module/hooks/useUserConnections.js +0 -140
  493. package/lib/module/hooks/useUserConnections.js.map +0 -1
  494. package/lib/module/services/apiClient.js +0 -298
  495. package/lib/module/services/apiClient.js.map +0 -1
  496. package/lib/module/services/authService.js +0 -905
  497. package/lib/module/services/authService.js.map +0 -1
  498. package/lib/module/services/biometricPinService.js +0 -173
  499. package/lib/module/services/biometricPinService.js.map +0 -1
  500. package/lib/module/services/connectedAccountsService.js +0 -255
  501. package/lib/module/services/connectedAccountsService.js.map +0 -1
  502. package/lib/module/services/googleAuthService.js +0 -258
  503. package/lib/module/services/googleAuthService.js.map +0 -1
  504. package/lib/module/services/imageCompressionService.js +0 -250
  505. package/lib/module/services/imageCompressionService.js.map +0 -1
  506. package/lib/module/services/jwtStorageService.js +0 -239
  507. package/lib/module/services/jwtStorageService.js.map +0 -1
  508. package/lib/module/services/mobileTrainingService.js +0 -172
  509. package/lib/module/services/mobileTrainingService.js.map +0 -1
  510. package/lib/module/services/pinEncryptionService.js +0 -75
  511. package/lib/module/services/pinEncryptionService.js.map +0 -1
  512. package/lib/module/services/pinStorageUtils.js +0 -93
  513. package/lib/module/services/pinStorageUtils.js.map +0 -1
  514. package/lib/module/services/storageService.js +0 -383
  515. package/lib/module/services/storageService.js.map +0 -1
  516. package/lib/module/services/trainingApiHelpers.js +0 -67
  517. package/lib/module/services/trainingApiHelpers.js.map +0 -1
  518. package/lib/module/services/userConnectionsService.js +0 -476
  519. package/lib/module/services/userConnectionsService.js.map +0 -1
  520. package/lib/module/services/youtubeMigrationService.js +0 -404
  521. package/lib/module/services/youtubeMigrationService.js.map +0 -1
  522. package/lib/module/theme/index.js +0 -244
  523. package/lib/module/theme/index.js.map +0 -1
  524. package/lib/module/utils/eventUtils.js +0 -270
  525. package/lib/module/utils/eventUtils.js.map +0 -1
  526. package/lib/module/utils/haptics.js +0 -59
  527. package/lib/module/utils/haptics.js.map +0 -1
  528. package/lib/module/utils/imagePreloader.js +0 -3
  529. package/lib/module/utils/imagePreloader.js.map +0 -1
  530. package/lib/typescript/components/BodyText.d.ts +0 -10
  531. package/lib/typescript/components/BodyText.d.ts.map +0 -1
  532. package/lib/typescript/components/BrandMark.d.ts +0 -11
  533. package/lib/typescript/components/BrandMark.d.ts.map +0 -1
  534. package/lib/typescript/components/CodeInput.d.ts +0 -10
  535. package/lib/typescript/components/CodeInput.d.ts.map +0 -1
  536. package/lib/typescript/components/EmailInput.d.ts +0 -8
  537. package/lib/typescript/components/EmailInput.d.ts.map +0 -1
  538. package/lib/typescript/components/ExistingUserDataConfirmation.d.ts +0 -12
  539. package/lib/typescript/components/ExistingUserDataConfirmation.d.ts.map +0 -1
  540. package/lib/typescript/components/GoogleButton.d.ts +0 -11
  541. package/lib/typescript/components/GoogleButton.d.ts.map +0 -1
  542. package/lib/typescript/components/HeadingGroup.d.ts +0 -11
  543. package/lib/typescript/components/HeadingGroup.d.ts.map +0 -1
  544. package/lib/typescript/components/ModalHeader.d.ts +0 -11
  545. package/lib/typescript/components/ModalHeader.d.ts.map +0 -1
  546. package/lib/typescript/components/ModalSheet.d.ts +0 -13
  547. package/lib/typescript/components/ModalSheet.d.ts.map +0 -1
  548. package/lib/typescript/components/OnairosSignInButton.d.ts +0 -13
  549. package/lib/typescript/components/OnairosSignInButton.d.ts.map +0 -1
  550. package/lib/typescript/components/PersonaImage.d.ts +0 -8
  551. package/lib/typescript/components/PersonaImage.d.ts.map +0 -1
  552. package/lib/typescript/components/PersonaLoadingScreen.d.ts +0 -10
  553. package/lib/typescript/components/PersonaLoadingScreen.d.ts.map +0 -1
  554. package/lib/typescript/components/PersonalizationConsentScreen.d.ts +0 -10
  555. package/lib/typescript/components/PersonalizationConsentScreen.d.ts.map +0 -1
  556. package/lib/typescript/components/PinCreationScreen.d.ts +0 -10
  557. package/lib/typescript/components/PinCreationScreen.d.ts.map +0 -1
  558. package/lib/typescript/components/PlatformConnectorsStep.d.ts +0 -11
  559. package/lib/typescript/components/PlatformConnectorsStep.d.ts.map +0 -1
  560. package/lib/typescript/components/PlatformToggle.d.ts +0 -20
  561. package/lib/typescript/components/PlatformToggle.d.ts.map +0 -1
  562. package/lib/typescript/components/PrimaryButton.d.ts +0 -22
  563. package/lib/typescript/components/PrimaryButton.d.ts.map +0 -1
  564. package/lib/typescript/components/SignInMatchAnimation.d.ts +0 -9
  565. package/lib/typescript/components/SignInMatchAnimation.d.ts.map +0 -1
  566. package/lib/typescript/components/SignInStep.d.ts +0 -12
  567. package/lib/typescript/components/SignInStep.d.ts.map +0 -1
  568. package/lib/typescript/components/VerificationStep.d.ts +0 -13
  569. package/lib/typescript/components/VerificationStep.d.ts.map +0 -1
  570. package/lib/typescript/components/WelcomeScreen.d.ts +0 -9
  571. package/lib/typescript/components/WelcomeScreen.d.ts.map +0 -1
  572. package/lib/typescript/components/icons/Basicproficon.d.ts +0 -5
  573. package/lib/typescript/components/icons/Basicproficon.d.ts.map +0 -1
  574. package/lib/typescript/components/icons/Basicprofile.d.ts +0 -5
  575. package/lib/typescript/components/icons/Basicprofile.d.ts.map +0 -1
  576. package/lib/typescript/components/icons/Checkbox.d.ts +0 -5
  577. package/lib/typescript/components/icons/Checkbox.d.ts.map +0 -1
  578. package/lib/typescript/components/icons/Checkmark.d.ts +0 -5
  579. package/lib/typescript/components/icons/Checkmark.d.ts.map +0 -1
  580. package/lib/typescript/components/icons/Contentanalysis.d.ts +0 -5
  581. package/lib/typescript/components/icons/Contentanalysis.d.ts.map +0 -1
  582. package/lib/typescript/components/icons/Contenticon.d.ts +0 -5
  583. package/lib/typescript/components/icons/Contenticon.d.ts.map +0 -1
  584. package/lib/typescript/components/icons/EnochE.d.ts +0 -5
  585. package/lib/typescript/components/icons/EnochE.d.ts.map +0 -1
  586. package/lib/typescript/components/icons/Personalityicon.d.ts +0 -5
  587. package/lib/typescript/components/icons/Personalityicon.d.ts.map +0 -1
  588. package/lib/typescript/components/icons/Personalityprofile.d.ts +0 -5
  589. package/lib/typescript/components/icons/Personalityprofile.d.ts.map +0 -1
  590. package/lib/typescript/components/icons/Personalitytraits.d.ts +0 -5
  591. package/lib/typescript/components/icons/Personalitytraits.d.ts.map +0 -1
  592. package/lib/typescript/components/icons/Userpreferences.d.ts +0 -5
  593. package/lib/typescript/components/icons/Userpreferences.d.ts.map +0 -1
  594. package/lib/typescript/components/icons/index.d.ts +0 -12
  595. package/lib/typescript/components/icons/index.d.ts.map +0 -1
  596. package/lib/typescript/config/api.d.ts +0 -24
  597. package/lib/typescript/config/api.d.ts.map +0 -1
  598. package/lib/typescript/context/AuthContext.d.ts +0 -34
  599. package/lib/typescript/context/AuthContext.d.ts.map +0 -1
  600. package/lib/typescript/hooks/useConnectedAccounts.d.ts +0 -11
  601. package/lib/typescript/hooks/useConnectedAccounts.d.ts.map +0 -1
  602. package/lib/typescript/hooks/useUserConnections.d.ts +0 -12
  603. package/lib/typescript/hooks/useUserConnections.d.ts.map +0 -1
  604. package/lib/typescript/services/apiClient.d.ts +0 -91
  605. package/lib/typescript/services/apiClient.d.ts.map +0 -1
  606. package/lib/typescript/services/authService.d.ts +0 -216
  607. package/lib/typescript/services/authService.d.ts.map +0 -1
  608. package/lib/typescript/services/biometricPinService.d.ts +0 -29
  609. package/lib/typescript/services/biometricPinService.d.ts.map +0 -1
  610. package/lib/typescript/services/connectedAccountsService.d.ts +0 -56
  611. package/lib/typescript/services/connectedAccountsService.d.ts.map +0 -1
  612. package/lib/typescript/services/googleAuthService.d.ts +0 -63
  613. package/lib/typescript/services/googleAuthService.d.ts.map +0 -1
  614. package/lib/typescript/services/imageCompressionService.d.ts +0 -37
  615. package/lib/typescript/services/imageCompressionService.d.ts.map +0 -1
  616. package/lib/typescript/services/jwtStorageService.d.ts +0 -86
  617. package/lib/typescript/services/jwtStorageService.d.ts.map +0 -1
  618. package/lib/typescript/services/mobileTrainingService.d.ts +0 -45
  619. package/lib/typescript/services/mobileTrainingService.d.ts.map +0 -1
  620. package/lib/typescript/services/pinEncryptionService.d.ts +0 -17
  621. package/lib/typescript/services/pinEncryptionService.d.ts.map +0 -1
  622. package/lib/typescript/services/pinStorageUtils.d.ts +0 -25
  623. package/lib/typescript/services/pinStorageUtils.d.ts.map +0 -1
  624. package/lib/typescript/services/storageService.d.ts +0 -128
  625. package/lib/typescript/services/storageService.d.ts.map +0 -1
  626. package/lib/typescript/services/trainingApiHelpers.d.ts +0 -38
  627. package/lib/typescript/services/trainingApiHelpers.d.ts.map +0 -1
  628. package/lib/typescript/services/userConnectionsService.d.ts +0 -90
  629. package/lib/typescript/services/userConnectionsService.d.ts.map +0 -1
  630. package/lib/typescript/services/youtubeMigrationService.d.ts +0 -12
  631. package/lib/typescript/services/youtubeMigrationService.d.ts.map +0 -1
  632. package/lib/typescript/theme/index.d.ts +0 -416
  633. package/lib/typescript/theme/index.d.ts.map +0 -1
  634. package/lib/typescript/utils/eventUtils.d.ts +0 -108
  635. package/lib/typescript/utils/eventUtils.d.ts.map +0 -1
  636. package/lib/typescript/utils/haptics.d.ts +0 -11
  637. package/lib/typescript/utils/haptics.d.ts.map +0 -1
  638. package/lib/typescript/utils/imagePreloader.d.ts +0 -2
  639. package/lib/typescript/utils/imagePreloader.d.ts.map +0 -1
  640. package/src/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  641. package/src/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  642. package/src/assets/icons/Facebookicon.png +0 -0
  643. package/src/assets/icons/Gmail.png +0 -0
  644. package/src/assets/icons/Linkedinicon.png +0 -0
  645. package/src/assets/icons/Redditicon.png +0 -0
  646. package/src/assets/icons/YouTubeicon2.png +0 -0
  647. package/src/assets/icons/YouTubeicon3.png +0 -0
  648. package/src/assets/icons/farcaster.png +0 -0
  649. package/src/assets/icons/instagram.png +0 -0
  650. package/src/assets/icons/pinterest.png +0 -0
  651. package/src/assets/icons/swerv_logo.png +0 -0
  652. package/src/assets/icons/twitter.jpg +0 -0
  653. package/src/assets/images/Checkbox.svg +0 -3
  654. package/src/assets/images/EnochE.svg +0 -19
  655. package/src/assets/images/Enochicon1.png +0 -0
  656. package/src/assets/images/Face_ID_logo.png +0 -0
  657. package/src/assets/images/Facebookicon.png +0 -0
  658. package/src/assets/images/Gmail.png +0 -0
  659. package/src/assets/images/Googlelogo.png +0 -0
  660. package/src/assets/images/Linkedinicon.png +0 -0
  661. package/src/assets/images/Onairoslogo.png +0 -0
  662. package/src/assets/images/Personalityprofile.svg +0 -3
  663. package/src/assets/images/Personalitytraits.svg +0 -3
  664. package/src/assets/images/Redditicon.png +0 -0
  665. package/src/assets/images/Userpreferences.svg +0 -3
  666. package/src/assets/images/YouTubeicon3.png +0 -0
  667. package/src/assets/images/arrow.svg +0 -20
  668. package/src/assets/images/basicproficon.svg +0 -43
  669. package/src/assets/images/basicprofile.svg +0 -3
  670. package/src/assets/images/checkmark.svg +0 -4
  671. package/src/assets/images/contentanalysis.svg +0 -3
  672. package/src/assets/images/contenticon.svg +0 -23
  673. package/src/assets/images/persona1.png +0 -0
  674. package/src/assets/images/persona2.png +0 -0
  675. package/src/assets/images/persona3.png +0 -0
  676. package/src/assets/images/persona4.png +0 -0
  677. package/src/assets/images/persona5.png +0 -0
  678. package/src/assets/images/personalityicon.svg +0 -18
  679. package/src/assets/images/x-close.svg +0 -3
  680. package/src/components/BodyText.tsx +0 -33
  681. package/src/components/BrandMark.tsx +0 -62
  682. package/src/components/CodeInput.tsx +0 -32
  683. package/src/components/EmailInput.tsx +0 -31
  684. package/src/components/ExistingUserDataConfirmation.tsx +0 -507
  685. package/src/components/GoogleButton.tsx +0 -55
  686. package/src/components/HeadingGroup.tsx +0 -49
  687. package/src/components/ModalHeader.tsx +0 -125
  688. package/src/components/ModalSheet.tsx +0 -59
  689. package/src/components/OnairosSignInButton.tsx +0 -132
  690. package/src/components/PersonaImage.tsx +0 -79
  691. package/src/components/PersonaLoadingScreen.tsx +0 -201
  692. package/src/components/PersonalizationConsentScreen.tsx +0 -410
  693. package/src/components/PinCreationScreen.tsx +0 -492
  694. package/src/components/PlatformConnectorsStep.tsx +0 -892
  695. package/src/components/PlatformToggle.tsx +0 -226
  696. package/src/components/PrimaryButton.tsx +0 -214
  697. package/src/components/SignInMatchAnimation.tsx +0 -225
  698. package/src/components/SignInStep.tsx +0 -217
  699. package/src/components/VerificationStep.tsx +0 -198
  700. package/src/components/WelcomeScreen.tsx +0 -490
  701. package/src/components/icons/Basicproficon.tsx +0 -30
  702. package/src/components/icons/Basicprofile.tsx +0 -17
  703. package/src/components/icons/Checkbox.tsx +0 -17
  704. package/src/components/icons/Checkmark.tsx +0 -24
  705. package/src/components/icons/Contentanalysis.tsx +0 -17
  706. package/src/components/icons/Contenticon.tsx +0 -30
  707. package/src/components/icons/EnochE.tsx +0 -39
  708. package/src/components/icons/Personalityicon.tsx +0 -22
  709. package/src/components/icons/Personalityprofile.tsx +0 -17
  710. package/src/components/icons/Personalitytraits.tsx +0 -17
  711. package/src/components/icons/Userpreferences.tsx +0 -17
  712. package/src/components/icons/index.ts +0 -12
  713. package/src/config/api.ts +0 -25
  714. package/src/context/AuthContext.tsx +0 -393
  715. package/src/hooks/useConnectedAccounts.ts +0 -139
  716. package/src/hooks/useUserConnections.ts +0 -166
  717. package/src/services/apiClient.ts +0 -337
  718. package/src/services/authService.ts +0 -1008
  719. package/src/services/biometricPinService.ts +0 -193
  720. package/src/services/connectedAccountsService.ts +0 -290
  721. package/src/services/googleAuthService.ts +0 -279
  722. package/src/services/imageCompressionService.ts +0 -303
  723. package/src/services/jwtStorageService.ts +0 -257
  724. package/src/services/mobileTrainingService.ts +0 -204
  725. package/src/services/pinEncryptionService.ts +0 -76
  726. package/src/services/pinStorageUtils.ts +0 -97
  727. package/src/services/storageService.ts +0 -452
  728. package/src/services/trainingApiHelpers.ts +0 -67
  729. package/src/services/userConnectionsService.ts +0 -557
  730. package/src/services/youtubeMigrationService.ts +0 -454
  731. package/src/theme/index.ts +0 -239
  732. package/src/utils/eventUtils.ts +0 -303
  733. package/src/utils/haptics.ts +0 -59
  734. package/src/utils/imagePreloader.ts +0 -2
@@ -3,753 +3,399 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.verifyEmailCode = exports.testYouTubeRefreshToken = exports.requestEmailVerification = exports.refreshYouTubeTokens = exports.reconnectYouTube = exports.isOAuthCallback = exports.initiateOAuth = exports.initiateNativeAuth = exports.initializePlatformAuthService = exports.hasNativeSDK = exports.forceYouTubeReconnectionWithRevoke = exports.forceYouTubeReconnectionWithConsent = exports.fixUserYouTubeConnection = exports.exchangeCodeForToken = exports.checkEmailVerificationStatus = void 0;
7
- var _googleSignin = require("@react-native-google-signin/google-signin");
6
+ exports.verifyEmailCode = exports.updateGoogleClientIds = exports.testApiConnectivity = exports.storePIN = exports.requestEmailVerification = exports.refreshYouTubeTokens = exports.refreshGoogleTokens = exports.isOAuthCallback = exports.initiateOAuth = exports.initiateNativeAuth = exports.initializePlatformAuthService = exports.hasNativeSDK = exports.handleOAuthCallbackUrl = exports.handleOAuthCallback = exports.getStoredJwtToken = exports.getPlatformColor = exports.getAuthEndpoint = exports.disconnectPlatform = exports.clearStoredTokens = exports.checkEmailVerificationStatus = void 0;
8
7
  var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
9
- var _api = require("../config/api");
8
+ var _apiKeyService = require("./apiKeyService");
10
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- /**
12
- * Platform Authentication Service
13
- * Handles OAuth flows for different platforms
10
+ // ๐Ÿ”‘ CRITICAL: Use two-tier authentication system
11
+ // - Developer API key for email verification requests
12
+ // - JWT tokens for user-authenticated requests after email verification
13
+
14
+ /**
15
+ * Initialize the platform auth service
16
+ * This service now uses the two-tier authentication system
14
17
  */
18
+ const initializePlatformAuthService = async () => {
19
+ try {
20
+ // Check if app is already initialized with API key
21
+ const existingConfig = (0, _apiKeyService.getApiConfig)();
22
+ if (existingConfig && existingConfig.apiKey) {
23
+ console.log('๐Ÿ”‘ Platform auth service using existing app configuration');
24
+ console.log(`โœ… Environment: ${existingConfig.environment}`);
25
+ return;
26
+ }
15
27
 
16
- // ๐Ÿ”‘ CRITICAL: Using the same client ID for both web and iOS to avoid audience errors
17
- const WEB_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
18
- const IOS_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
19
- // OAuth configuration for different platforms
20
- const OAUTH_CONFIG = {
28
+ // If no app initialization, we can't proceed
29
+ console.error('โŒ Platform auth service requires app-level API key initialization');
30
+ throw new Error('Platform auth service requires app-level API key initialization. Please call initializeApiKey() first.');
31
+ } catch (error) {
32
+ console.error('โŒ Failed to initialize platform auth service:', error);
33
+ throw error;
34
+ }
35
+ };
36
+
37
+ // Configuration for each platform's authentication
38
+ exports.initializePlatformAuthService = initializePlatformAuthService;
39
+ let PLATFORM_AUTH_CONFIG = {
21
40
  instagram: {
22
- authUrl: 'https://api.instagram.com/oauth/authorize',
23
- clientId: 'demo_instagram_client_id',
24
- redirectUri: 'onairosevents://auth/callback',
25
- scope: 'user_profile,user_media',
26
- responseType: 'code',
27
- hasNativeSDK: false
41
+ hasNativeSDK: false,
42
+ // Instagram uses OAuth WebView flow
43
+ authEndpoint: '/instagram/authorize',
44
+ color: '#E1306C'
28
45
  },
29
46
  youtube: {
30
- authUrl: 'https://api2.onairos.uk/youtube/authorize',
47
+ hasNativeSDK: true,
48
+ // Native Google Sign-In SDK enabled
49
+ nativeSDKPackage: '@react-native-google-signin/google-signin',
50
+ authEndpoint: '/youtube/authorize',
51
+ color: '#FF0000',
31
52
  clientId: '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com',
32
53
  redirectUri: 'onairosevents://auth/callback',
33
54
  scope: 'https://www.googleapis.com/auth/youtube.readonly',
34
- responseType: 'code',
35
- hasNativeSDK: true // Changed to true for native SDK
55
+ responseType: 'code'
36
56
  },
37
57
  reddit: {
38
- authUrl: 'https://api2.onairos.uk/reddit/authorize',
39
- clientId: 'demo_reddit_client_id',
40
- redirectUri: 'onairosevents://auth/callback',
41
- scope: 'identity,read',
42
- responseType: 'code',
43
- hasNativeSDK: false
58
+ hasNativeSDK: false,
59
+ authEndpoint: '/reddit/authorize',
60
+ color: '#FF4500'
44
61
  },
45
62
  pinterest: {
46
- authUrl: 'https://api2.onairos.uk/pinterest/authorize',
47
- clientId: 'demo_pinterest_client_id',
48
- redirectUri: 'onairosevents://auth/callback',
49
- scope: 'boards:read,pins:read',
50
- responseType: 'code',
51
- hasNativeSDK: false
52
- },
53
- facebook: {
54
- authUrl: 'https://www.facebook.com/v12.0/dialog/oauth',
55
- clientId: 'demo_facebook_client_id',
56
- redirectUri: 'onairosevents://auth/callback',
57
- scope: 'public_profile,email',
58
- responseType: 'code',
59
- hasNativeSDK: false
60
- },
61
- // GitHub connector is temporarily commented out
62
- // github: {
63
- // authUrl: 'https://github.com/login/oauth/authorize',
64
- // clientId: 'demo_github_client_id',
65
- // redirectUri: 'onairosevents://auth/callback',
66
- // scope: 'repo,user',
67
- // responseType: 'code',
68
- // hasNativeSDK: false
69
- // },
70
- linkedin: {
71
- authUrl: 'https://api2.onairos.uk/linkedin/authorize',
72
- clientId: '',
73
- // No client ID needed - backend handles OAuth
74
- redirectUri: 'onairosevents://auth/callback',
75
- scope: 'openid profile email',
76
- // Updated to OpenID Connect scopes as per your backend
77
- responseType: 'code',
78
- hasNativeSDK: false // LinkedIn has no modern native SDK
79
- },
80
- gmail: {
81
- authUrl: 'https://api2.onairos.uk/gmail/authorize',
82
- clientId: 'demo_gmail_client_id',
83
- redirectUri: 'onairosevents://auth/callback',
84
- scope: 'https://www.googleapis.com/auth/gmail.readonly',
85
- responseType: 'code',
86
- hasNativeSDK: false
63
+ hasNativeSDK: false,
64
+ authEndpoint: '/pinterest/authorize',
65
+ color: '#E60023'
87
66
  },
88
67
  email: {
89
- // Email doesn't use OAuth but we still need to handle it in the flow
90
68
  hasNativeSDK: false,
91
- authUrl: 'https://api2.onairos.uk/email/authorize' // Proxy endpoint for email verification
69
+ authEndpoint: '/gmail/authorize',
70
+ color: '#4285F4'
92
71
  }
93
72
  };
94
73
 
95
- /**
96
- * Check if the platform has a native SDK
74
+ /**
75
+ * Checks if a native SDK is available for the given platform
97
76
  */
98
77
  const hasNativeSDK = platform => {
99
- var _OAUTH_CONFIG$platfor;
100
- return ((_OAUTH_CONFIG$platfor = OAUTH_CONFIG[platform]) === null || _OAUTH_CONFIG$platfor === void 0 ? void 0 : _OAUTH_CONFIG$platfor.hasNativeSDK) || false;
78
+ const config = PLATFORM_AUTH_CONFIG[platform];
79
+ return (config === null || config === void 0 ? void 0 : config.hasNativeSDK) || false;
101
80
  };
102
81
 
103
- /**
104
- * Initiate OAuth flow for a platform
82
+ /**
83
+ * Gets the auth endpoint URL for a platform
105
84
  */
106
85
  exports.hasNativeSDK = hasNativeSDK;
107
- const initiateOAuth = async (platform, username) => {
108
- try {
109
- console.log(`๐Ÿš€ [OAUTH] Starting OAuth for platform: ${platform}, username: "${username}"`);
110
-
111
- // Validate username
112
- if (!username || username.trim() === '') {
113
- console.error(`โŒ [OAUTH] Username is required for ${platform} OAuth`);
114
- return null;
115
- }
116
-
117
- // For platforms that don't need OAuth (like email), handle differently
118
- if (platform === 'email') {
119
- console.log('๐Ÿ“ง [OAUTH] Email platform selected, returning mock auth URL');
120
- return 'https://api2.onairos.uk/email/authorize?action=verify';
121
- }
122
-
123
- // Construct the proxy URL
124
- const proxyUrl = `https://api2.onairos.uk/${platform}/authorize`;
125
- console.log(`๐ŸŒ [OAUTH] Proxy URL: ${proxyUrl}`);
126
- const requestBody = {
127
- session: {
128
- username: username.trim(),
129
- platform: platform,
130
- timestamp: new Date().toISOString()
131
- }
132
- };
133
- console.log(`๐Ÿ“ค [OAUTH] Request body:`, requestBody);
134
- console.log(`๐Ÿ”‘ [OAUTH] Headers:`, (0, _api.getApiHeaders)());
135
-
136
- // Make a POST request to the proxy
137
- const response = await fetch(proxyUrl, {
138
- method: 'POST',
139
- headers: (0, _api.getApiHeaders)(),
140
- body: JSON.stringify(requestBody)
141
- });
142
- console.log(`๐Ÿ“ก [OAUTH] Response status: ${response.status} ${response.statusText}`);
143
- if (!response.ok) {
144
- const errorText = await response.text();
145
- console.error(`โŒ [OAUTH] Error initiating OAuth for ${platform}: ${response.status} - ${errorText}`);
146
- return null;
147
- }
148
- const data = await response.json();
149
- console.log(`๐Ÿ“‹ [OAUTH] Response data for ${platform}:`, data);
150
-
151
- // Get the authorization URL from the response
152
- // Different platforms might use different keys (e.g., pinterestURL, youtubeURL)
153
- const urlKey = `${platform}URL`;
154
- const authUrl = data[urlKey] || data.url || null;
155
- console.log(`๐Ÿ”— [OAUTH] Auth URL for ${platform} (key: ${urlKey}):`, authUrl);
156
- return authUrl;
157
- } catch (error) {
158
- console.error(`Error initiating OAuth for ${platform}:`, error);
159
- return null;
160
- }
86
+ const getAuthEndpoint = platform => {
87
+ const config = PLATFORM_AUTH_CONFIG[platform];
88
+ return (config === null || config === void 0 ? void 0 : config.authEndpoint) || '';
161
89
  };
162
90
 
163
- /**
164
- * Initialize Google Sign-In configuration with enhanced refresh token support
165
- * Updated with CRITICAL parameters for refresh token generation
91
+ /**
92
+ * Gets the color associated with a platform
166
93
  */
167
- exports.initiateOAuth = initiateOAuth;
168
- const initializeGoogleSignIn = () => {
169
- _googleSignin.GoogleSignin.configure({
170
- webClientId: WEB_CLIENT_ID,
171
- // โœ… CRITICAL: Web client ID for refresh tokens
172
- iosClientId: IOS_CLIENT_ID,
173
- // โœ… iOS client ID for native auth
174
-
175
- // ๐Ÿ”‘ CRITICAL: These parameters are REQUIRED for refresh tokens
176
- offlineAccess: true,
177
- // โ† CRITICAL: Enables refresh tokens
178
- forceCodeForRefreshToken: true,
179
- // โ† CRITICAL: Forces refresh token generation
180
-
181
- // โœ… Enhanced scopes for YouTube
182
- scopes: ['https://www.googleapis.com/auth/youtube.readonly', 'openid', 'profile', 'email'],
183
- // โœ… Clear settings to avoid conflicts
184
- hostedDomain: '',
185
- accountName: ''
186
- });
94
+ exports.getAuthEndpoint = getAuthEndpoint;
95
+ const getPlatformColor = platform => {
96
+ const config = PLATFORM_AUTH_CONFIG[platform];
97
+ return (config === null || config === void 0 ? void 0 : config.color) || '#000000';
187
98
  };
188
99
 
189
- /**
190
- * Force YouTube reconnection with consent screen to get refresh tokens
191
- * This is the key function to fix YouTube token expiry issues
100
+ /**
101
+ * Initiates the OAuth flow for a platform
102
+ * @param platform The platform to authenticate with
103
+ * @param username The username to associate with the authentication
104
+ * @param appName The app name to use for the OAuth session (optional)
105
+ * @returns A Promise that resolves to the OAuth URL to open in a WebView or null if using native SDK
192
106
  */
193
- const forceYouTubeReconnectionWithConsent = async username => {
107
+ exports.getPlatformColor = getPlatformColor;
108
+ const initiateOAuth = async (platform, username, appName) => {
194
109
  try {
195
- var _userInfo$data, _userInfo$data2, _userInfo$data3;
196
- console.log('๐Ÿ”„ FORCING fresh YouTube consent for refresh token...');
197
- console.log('๐Ÿ‘ค User:', username);
198
-
199
- // Step 1: โœ… CRITICAL: Complete sign out (clears all cached consent)
200
- try {
201
- await _googleSignin.GoogleSignin.signOut();
202
- console.log('โœ… Signed out - consent cache cleared');
203
- } catch (signOutError) {
204
- console.log('โ„น๏ธ Sign out not needed:', signOutError);
110
+ console.log('๐Ÿš€ Initiating OAuth for platform:', platform);
111
+ console.log('๐Ÿ‘ค Username:', username);
112
+ console.log('๐Ÿ“ฑ App name:', appName);
113
+
114
+ // Check if the platform is supported
115
+ if (!PLATFORM_AUTH_CONFIG[platform]) {
116
+ console.error('โŒ Unsupported platform:', platform);
117
+ throw new Error(`Unsupported platform: ${platform}`);
205
118
  }
206
119
 
207
- // Step 2: โœ… CRITICAL: Clear cached tokens if available
208
- try {
209
- const existingTokens = await _googleSignin.GoogleSignin.getTokens();
210
- if (existingTokens.accessToken) {
211
- await _googleSignin.GoogleSignin.clearCachedAccessToken(existingTokens.accessToken);
212
- console.log('โœ… Token cache cleared');
213
- }
214
- } catch (clearError) {
215
- console.log('โ„น๏ธ No token cache to clear');
120
+ // Check if platform has a native SDK
121
+ if (PLATFORM_AUTH_CONFIG[platform].hasNativeSDK) {
122
+ console.log('๐Ÿ“ฑ Platform uses native SDK, returning null');
123
+ // Return null to indicate that we should use the native SDK
124
+ return null;
216
125
  }
126
+ console.log('๐ŸŒ Platform uses OAuth WebView flow');
127
+ console.log('๐Ÿ”— Auth endpoint:', PLATFORM_AUTH_CONFIG[platform].authEndpoint);
128
+
129
+ // Pre-flight connectivity check
130
+ console.log('๐Ÿ” Performing pre-flight connectivity check...');
131
+ const connectivityResult = await testApiConnectivity();
132
+ if (!connectivityResult.success) {
133
+ console.error('โŒ Pre-flight connectivity check failed:', connectivityResult.error);
134
+ throw new Error(`Cannot reach authentication server: ${connectivityResult.error}`);
135
+ }
136
+ console.log('โœ… Pre-flight connectivity check passed');
217
137
 
218
- // Step 3: โœ… CRITICAL: Configure Google Sign-In for FORCED consent
219
- console.log('๐Ÿ”ง Configuring Google Sign-In for forced consent...');
220
- _googleSignin.GoogleSignin.configure({
221
- webClientId: WEB_CLIENT_ID,
222
- // โœ… CRITICAL: Web client ID for refresh tokens
223
- iosClientId: IOS_CLIENT_ID,
224
- // โœ… iOS client ID for native auth
225
-
226
- // ๐Ÿ”‘ FORCE REFRESH TOKEN SETTINGS:
227
- offlineAccess: true,
228
- // Request offline access
229
- forceCodeForRefreshToken: true,
230
- // Force refresh token generation
231
-
232
- // ๐Ÿ”‘ FORCE CONSENT SCREEN:
233
- scopes: ['https://www.googleapis.com/auth/youtube.readonly', 'openid', 'profile', 'email'],
234
- // โœ… CRITICAL: Clear settings to force fresh consent
235
- hostedDomain: '',
236
- accountName: ''
237
- });
238
-
239
- // Step 4: โœ… Check Play Services
240
- await _googleSignin.GoogleSignin.hasPlayServices();
241
- console.log('โœ… Play Services available');
242
-
243
- // Step 5: โœ… CRITICAL: Sign in (this SHOULD show consent screen)
244
- console.log('๐Ÿ” Initiating sign-in - consent screen should appear...');
245
- console.log('๐Ÿ“ฑ User should see: "Allow [App] to access your YouTube account when you\'re not using the app?"');
246
- const userInfo = await _googleSignin.GoogleSignin.signIn();
247
- console.log('โœ… Sign-in completed - checking for refresh token...');
248
- console.log('๐Ÿ‘ค User email:', (_userInfo$data = userInfo.data) === null || _userInfo$data === void 0 || (_userInfo$data = _userInfo$data.user) === null || _userInfo$data === void 0 ? void 0 : _userInfo$data.email);
249
-
250
- // Step 6: โœ… Get tokens after consent
251
- const tokens = await _googleSignin.GoogleSignin.getTokens();
252
- const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
253
- console.log('๐Ÿ“‹ FULL userInfo object from forceYouTubeReconnectionWithConsent:');
254
- console.log(JSON.stringify(userInfo, null, 2));
255
- console.log('๐Ÿ“‹ FULL tokens object from forceYouTubeReconnectionWithConsent:');
256
- console.log(JSON.stringify(tokens, null, 2));
257
- console.log('๐Ÿ“‹ FULL currentUser object from forceYouTubeReconnectionWithConsent:');
258
- console.log(JSON.stringify(currentUser, null, 2));
259
- console.log('๐Ÿ” Token analysis:');
260
- console.log('- Access token:', tokens.accessToken ? `${tokens.accessToken.substring(0, 20)}...` : 'Missing');
261
- console.log('- ID token:', tokens.idToken ? 'Present' : 'Missing');
262
- console.log('- ServerAuthCode (userInfo):', (_userInfo$data2 = userInfo.data) !== null && _userInfo$data2 !== void 0 && _userInfo$data2.serverAuthCode ? `${userInfo.data.serverAuthCode.substring(0, 20)}...` : 'Missing');
263
- console.log('- ServerAuthCode (currentUser):', currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? `${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing');
264
-
265
- // Step 7: โœ… Extract refresh capability
266
- const refreshToken = ((_userInfo$data3 = userInfo.data) === null || _userInfo$data3 === void 0 ? void 0 : _userInfo$data3.serverAuthCode) || (currentUser === null || currentUser === void 0 ? void 0 : currentUser.serverAuthCode);
267
- if (refreshToken) {
268
- var _userInfo$data0, _userInfo$data1, _userInfo$data10, _userInfo$data11, _userInfo$data12, _userInfo$data13;
269
- console.log('โœ… SUCCESS: Got refresh token after consent!');
270
- console.log('๐Ÿ”‘ Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
271
- console.log('๐Ÿ”‘ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
272
-
273
- // Step 8: โœ… Get YouTube channel info
274
- let channelName = 'Unknown Channel';
275
- let channelId = null;
276
- try {
277
- console.log('๐Ÿ“บ Fetching YouTube channel information...');
278
- const channelResponse = await fetch('https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true', {
279
- headers: {
280
- 'Authorization': `Bearer ${tokens.accessToken}`,
281
- 'Accept': 'application/json'
282
- }
283
- });
284
- if (channelResponse.ok) {
285
- const channelData = await channelResponse.json();
286
- if (channelData.items && channelData.items.length > 0) {
287
- channelName = channelData.items[0].snippet.title;
288
- channelId = channelData.items[0].id;
289
- console.log('โœ… YouTube channel found:', channelName, 'ID:', channelId);
290
- } else {
291
- var _userInfo$data4, _userInfo$data5;
292
- console.log('โš ๏ธ No YouTube channel found for user');
293
- channelName = ((_userInfo$data4 = userInfo.data) === null || _userInfo$data4 === void 0 || (_userInfo$data4 = _userInfo$data4.user) === null || _userInfo$data4 === void 0 ? void 0 : _userInfo$data4.name) || ((_userInfo$data5 = userInfo.data) === null || _userInfo$data5 === void 0 || (_userInfo$data5 = _userInfo$data5.user) === null || _userInfo$data5 === void 0 ? void 0 : _userInfo$data5.email) || 'No Channel';
294
- }
295
- } else {
296
- var _userInfo$data6, _userInfo$data7;
297
- console.log('โš ๏ธ Failed to fetch YouTube channel info:', channelResponse.status);
298
- channelName = ((_userInfo$data6 = userInfo.data) === null || _userInfo$data6 === void 0 || (_userInfo$data6 = _userInfo$data6.user) === null || _userInfo$data6 === void 0 ? void 0 : _userInfo$data6.name) || ((_userInfo$data7 = userInfo.data) === null || _userInfo$data7 === void 0 || (_userInfo$data7 = _userInfo$data7.user) === null || _userInfo$data7 === void 0 ? void 0 : _userInfo$data7.email) || 'Unknown Channel';
299
- }
300
- } catch (channelError) {
301
- var _userInfo$data8, _userInfo$data9;
302
- console.log('โš ๏ธ Error fetching YouTube channel info:', channelError);
303
- channelName = ((_userInfo$data8 = userInfo.data) === null || _userInfo$data8 === void 0 || (_userInfo$data8 = _userInfo$data8.user) === null || _userInfo$data8 === void 0 ? void 0 : _userInfo$data8.name) || ((_userInfo$data9 = userInfo.data) === null || _userInfo$data9 === void 0 || (_userInfo$data9 = _userInfo$data9.user) === null || _userInfo$data9 === void 0 ? void 0 : _userInfo$data9.email) || 'Unknown Channel';
304
- }
305
-
306
- // Step 9: โœ… Get authentication token
307
- let authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
308
- if (!authToken || authToken.trim().length < 20) {
309
- console.log('๐Ÿ” Creating authentication token for YouTube connection...');
310
- // Create token logic here if needed
311
- authToken = 'temp_token_for_youtube_connection';
312
- }
313
-
314
- // Step 10: โœ… Send comprehensive data to backend
315
- const backendPayload = {
138
+ // Handle Instagram with specific API format
139
+ if (platform === 'instagram') {
140
+ const state = 'djksbfds';
141
+ const jsonData = {
316
142
  session: {
317
- username: username,
318
- platform: 'youtube',
319
- timestamp: new Date().toISOString(),
320
- channelName: channelName,
321
- channelId: channelId,
322
- forceConsent: true // Flag to indicate this was forced consent
323
- },
324
- googleUser: (_userInfo$data0 = userInfo.data) === null || _userInfo$data0 === void 0 ? void 0 : _userInfo$data0.user,
325
- accessToken: tokens.accessToken,
326
- idToken: tokens.idToken,
327
- refreshToken: refreshToken,
328
- // โœ… CRITICAL: The refresh token!
329
- serverAuthCode: refreshToken,
330
- // โœ… Same as refresh token
331
-
332
- // โœ… CRITICAL: Additional compatibility fields for backend
333
- refresh_token: refreshToken,
334
- // Snake case version
335
- server_auth_code: refreshToken,
336
- // Snake case version
337
- authCode: refreshToken,
338
- // Alternative naming
339
-
340
- userAccountInfo: {
341
- username: username,
342
- email: (_userInfo$data1 = userInfo.data) === null || _userInfo$data1 === void 0 || (_userInfo$data1 = _userInfo$data1.user) === null || _userInfo$data1 === void 0 ? void 0 : _userInfo$data1.email,
343
- authToken: authToken,
344
- channelName: channelName,
345
- channelId: channelId,
346
- userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${(_userInfo$data10 = userInfo.data) === null || _userInfo$data10 === void 0 || (_userInfo$data10 = _userInfo$data10.user) === null || _userInfo$data10 === void 0 ? void 0 : _userInfo$data10.email}`,
347
- googleId: (_userInfo$data11 = userInfo.data) === null || _userInfo$data11 === void 0 || (_userInfo$data11 = _userInfo$data11.user) === null || _userInfo$data11 === void 0 ? void 0 : _userInfo$data11.id,
348
- // โœ… CRITICAL: Also include refresh token in userAccountInfo
349
- refreshToken: refreshToken,
350
- serverAuthCode: refreshToken
351
- },
352
- tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
353
- // 1 hour from now
354
- requestRefreshToken: true,
355
- debugInfo: {
356
- hasRefreshToken: true,
357
- refreshTokenType: refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken',
358
- configuredForRefresh: true,
359
- forcedConsent: true,
360
- consentMethod: 'signOut_and_configure',
361
- refreshTokenValue: refreshToken // Include actual value for debugging
143
+ oauthState: state,
144
+ username: username || 'Avatar'
362
145
  }
363
146
  };
364
- console.log('๐Ÿ“ค Sending comprehensive payload with REFRESH TOKEN to backend:', {
365
- hasAccessToken: !!backendPayload.accessToken,
366
- hasRefreshToken: !!backendPayload.refreshToken,
367
- hasServerAuthCode: !!backendPayload.serverAuthCode,
368
- refreshTokenType: backendPayload.debugInfo.refreshTokenType,
369
- userEmail: (_userInfo$data12 = userInfo.data) === null || _userInfo$data12 === void 0 || (_userInfo$data12 = _userInfo$data12.user) === null || _userInfo$data12 === void 0 ? void 0 : _userInfo$data12.email,
370
- forcedConsent: true
371
- });
372
-
373
- // Step 11: โœ… Send to backend with ENHANCED LOGGING
374
- console.log('๐Ÿš€ [YOUTUBE REAUTH] ===== SENDING REAUTH SIGNAL TO BACKEND =====');
375
- console.log('๐Ÿš€ [YOUTUBE REAUTH] Endpoint: https://api2.onairos.uk/youtube/native-auth');
376
- console.log('๐Ÿš€ [YOUTUBE REAUTH] Method: POST');
377
- console.log('๐Ÿš€ [YOUTUBE REAUTH] Headers:', {
378
- 'Content-Type': 'application/json',
379
- 'Authorization': authToken ? `${authToken.substring(0, 20)}...` : 'NO AUTH TOKEN'
380
- });
381
- console.log('๐Ÿš€ [YOUTUBE REAUTH] Payload Summary:', {
382
- hasAccessToken: !!backendPayload.accessToken,
383
- hasRefreshToken: !!backendPayload.refreshToken,
384
- hasServerAuthCode: !!backendPayload.serverAuthCode,
385
- refreshTokenType: backendPayload.debugInfo.refreshTokenType,
386
- userEmail: (_userInfo$data13 = userInfo.data) === null || _userInfo$data13 === void 0 || (_userInfo$data13 = _userInfo$data13.user) === null || _userInfo$data13 === void 0 ? void 0 : _userInfo$data13.email,
387
- channelName: channelName,
388
- forcedConsent: true,
389
- requestRefreshToken: true
390
- });
391
- console.log('๐Ÿš€ [YOUTUBE REAUTH] FULL PAYLOAD:', JSON.stringify(backendPayload, null, 2));
392
- const backendResponse = await fetch('https://api2.onairos.uk/youtube/native-auth', {
147
+ console.log('๐Ÿ“ค Sending Instagram OAuth request:', jsonData);
148
+ const response = await (0, _apiKeyService.makeDeveloperRequest)(PLATFORM_AUTH_CONFIG[platform].authEndpoint, {
393
149
  method: 'POST',
394
- headers: {
395
- 'Content-Type': 'application/json',
396
- ...(authToken && {
397
- 'Authorization': authToken
398
- })
399
- },
400
- body: JSON.stringify(backendPayload)
150
+ body: JSON.stringify(jsonData)
401
151
  });
402
- console.log('๐Ÿ“ก [YOUTUBE REAUTH] Response Status:', backendResponse.status);
403
- console.log('๐Ÿ“ก [YOUTUBE REAUTH] Response Status Text:', backendResponse.statusText);
404
- console.log('๐Ÿ“ก [YOUTUBE REAUTH] Response Headers:', backendResponse.headers);
405
- if (backendResponse.ok) {
406
- var _responseData$validat, _responseData$tempora;
407
- const responseData = await backendResponse.json();
408
- console.log('โœ… [YOUTUBE REAUTH] Backend Response SUCCESS:', JSON.stringify(responseData, null, 2));
409
-
410
- // Enhanced verification with detailed logging and temporary mode detection (exact backend fields)
411
- const isTemporaryMode = ((_responseData$validat = responseData.validation) === null || _responseData$validat === void 0 ? void 0 : _responseData$validat.isTemporaryMode) === true || ((_responseData$tempora = responseData.temporaryMode) === null || _responseData$tempora === void 0 ? void 0 : _responseData$tempora.enabled) === true || responseData.isTemporaryMode === true || responseData.message && responseData.message.includes('temporary access token mode');
412
- if (isTemporaryMode) {
413
- console.log('๐Ÿ”„ [YOUTUBE REAUTH] YouTube connected in temporary mode');
414
- console.log('โœ… [YOUTUBE REAUTH] Training will work, but connection expires in ~1 hour');
415
- console.log('๐ŸŽ‰ [YOUTUBE REAUTH] SUCCESS: Temporary YouTube connection established!');
416
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] Connection Details:');
417
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] Mode: Temporary (expires ~1 hour)');
418
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] Training Ready: Yes');
419
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] Refresh token sent:', refreshToken ? 'Yes' : 'No');
420
- } else if (responseData.hasRefreshToken || responseData.refreshTokenReceived) {
421
- console.log('โœ… [YOUTUBE REAUTH] Backend CONFIRMED refresh token received');
422
- console.log('โœ… [YOUTUBE REAUTH] Response hasRefreshToken:', responseData.hasRefreshToken);
423
- console.log('๐ŸŽ‰ [YOUTUBE REAUTH] SUCCESS: Full YouTube connection with refresh tokens!');
424
-
425
- // CRITICAL: Print the refresh token that was sent for debugging
426
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] REFRESH TOKEN SENT TO BACKEND:');
427
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] Full refresh token:', refreshToken);
428
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
429
- console.log('๐Ÿ”‘ [YOUTUBE REAUTH] Refresh token length:', refreshToken.length);
430
- } else {
431
- console.warn('โš ๏ธ [YOUTUBE REAUTH] Backend did NOT confirm refresh token reception');
432
- console.warn('โš ๏ธ [YOUTUBE REAUTH] Response data:', responseData);
433
- console.warn('โš ๏ธ [YOUTUBE REAUTH] Expected hasRefreshToken or refreshTokenReceived in response');
434
- return false;
435
- }
152
+ console.log('๐Ÿ“ก Instagram OAuth response status:', response.status);
153
+ if (!response.ok) {
154
+ const errorText = await response.text();
155
+ console.error('โŒ Instagram OAuth API error:', errorText);
156
+ throw new Error(`Instagram OAuth API error: ${response.status} - ${errorText}`);
157
+ }
158
+ const responseData = await response.json();
159
+ console.log('๐Ÿ“ฅ Instagram OAuth response data:', responseData);
160
+ if (responseData.instagramURL) {
161
+ console.log('โœ… Instagram OAuth URL received:', responseData.instagramURL);
436
162
 
437
- // CRITICAL: Signal training system to restart with new connection
438
- console.log('๐Ÿ”„ [YOUTUBE REAUTH] Signaling training system to restart...');
439
- try {
440
- await triggerTrainingRestart(username, authToken);
441
- console.log('โœ… [YOUTUBE REAUTH] Training restart signal sent successfully');
442
- } catch (restartError) {
443
- console.warn('โš ๏ธ [YOUTUBE REAUTH] Training restart signal failed:', restartError);
444
- console.warn('โš ๏ธ [YOUTUBE REAUTH] User may need to manually restart training');
163
+ // Validate the URL before returning
164
+ if (await validateOAuthUrl(responseData.instagramURL)) {
165
+ return responseData.instagramURL;
166
+ } else {
167
+ throw new Error('Received invalid Instagram OAuth URL');
445
168
  }
446
- return true;
447
- } else {
448
- const errorData = await backendResponse.text();
449
- console.error('โŒ [YOUTUBE REAUTH] Backend processing FAILED:', backendResponse.status, errorData);
450
- console.error('โŒ [YOUTUBE REAUTH] This means the reauth signal was not processed');
451
- return false;
452
169
  }
453
- } else {
454
- console.error('โŒ CRITICAL: No refresh token even after consent screen');
455
- console.error('โŒ This means consent screen did not appear or user denied permissions');
456
- console.error('๐Ÿ’ก Solutions:');
457
- console.error(' 1. Try the revoke method: forceYouTubeReconnectionWithRevoke()');
458
- console.error(' 2. Check Google Console OAuth configuration');
459
- console.error(' 3. Ensure user clicks "Allow" on consent screen');
460
- return false;
461
- }
462
- } catch (error) {
463
- console.error('โŒ Error forcing YouTube consent:', error);
464
- if (error.code === _googleSignin.statusCodes.SIGN_IN_CANCELLED) {
465
- console.error('โŒ User cancelled sign-in - no refresh token obtained');
466
- console.error('๐Ÿ’ก User must click "Allow" to get refresh token');
467
- } else if (error.code === _googleSignin.statusCodes.IN_PROGRESS) {
468
- console.error('โŒ Sign-in already in progress');
469
- } else if (error.code === _googleSignin.statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
470
- console.error('โŒ Google Play Services not available');
170
+ console.error('โŒ No Instagram URL found in response');
171
+ throw new Error('No Instagram URL found in response');
471
172
  }
472
- return false;
473
- }
474
- };
475
173
 
476
- /**
477
- * Alternative method: Force consent by revoking existing permissions
478
- */
479
- exports.forceYouTubeReconnectionWithConsent = forceYouTubeReconnectionWithConsent;
480
- const forceYouTubeReconnectionWithRevoke = async username => {
481
- try {
482
- var _userInfo$data14;
483
- console.log('๐Ÿ”„ FORCING YouTube consent via REVOKE method...');
484
- console.log('๐Ÿ‘ค User:', username);
485
-
486
- // Step 1: Initialize Google Sign-In
487
- initializeGoogleSignIn();
488
- await _googleSignin.GoogleSignin.hasPlayServices();
174
+ // Prepare the request body for other platforms
175
+ const jsonData = {
176
+ session: {
177
+ oauthState: 'djksbfds',
178
+ // Use same state for all platforms
179
+ username: username || 'Avatar',
180
+ appName: appName || 'DefaultApp'
181
+ }
182
+ };
183
+ console.log(`๐Ÿ“ค Sending ${platform} OAuth request:`, jsonData);
489
184
 
490
- // Step 2: โœ… CRITICAL: Revoke existing permissions (forces fresh consent)
491
- try {
492
- await _googleSignin.GoogleSignin.revokeAccess();
493
- console.log('โœ… Revoked existing permissions - fresh consent REQUIRED');
494
- } catch (revokeError) {
495
- console.log('โ„น๏ธ No existing permissions to revoke:', revokeError);
185
+ // Make the authenticated request to get the OAuth URL
186
+ const response = await (0, _apiKeyService.makeDeveloperRequest)(PLATFORM_AUTH_CONFIG[platform].authEndpoint, {
187
+ method: 'POST',
188
+ body: JSON.stringify(jsonData)
189
+ });
190
+ console.log(`๐Ÿ“ก ${platform} OAuth response status:`, response.status);
191
+ if (!response.ok) {
192
+ const errorText = await response.text();
193
+ console.error(`โŒ ${platform} OAuth API error:`, errorText);
194
+ throw new Error(`${platform} OAuth API error: ${response.status} - ${errorText}`);
496
195
  }
497
196
 
498
- // Step 3: Sign out completely
499
- await _googleSignin.GoogleSignin.signOut();
500
- console.log('โœ… Signed out completely');
501
-
502
- // Step 4: โœ… Now sign in again (will DEFINITELY show consent screen)
503
- console.log('๐Ÿ” Signing in after revoke - consent screen MUST appear...');
504
- const userInfo = await _googleSignin.GoogleSignin.signIn();
197
+ // Parse the response
198
+ const data = await response.json();
199
+ console.log(`๐Ÿ“ฅ ${platform} OAuth response data:`, data);
505
200
 
506
- // Step 5: โœ… User will definitely see consent screen now
507
- const tokens = await _googleSignin.GoogleSignin.getTokens();
508
- const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
509
- const refreshToken = ((_userInfo$data14 = userInfo.data) === null || _userInfo$data14 === void 0 ? void 0 : _userInfo$data14.serverAuthCode) || (currentUser === null || currentUser === void 0 ? void 0 : currentUser.serverAuthCode);
510
- if (refreshToken) {
511
- console.log('โœ… SUCCESS: Got refresh token after REVOKE + consent!');
512
- console.log('๐Ÿ”‘ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
201
+ // Extra logging for Gmail to help debug
202
+ if (platform === 'email') {
203
+ console.log('๐Ÿ” Gmail OAuth response keys:', Object.keys(data));
204
+ console.log('๐Ÿ” Gmail OAuth full response:', JSON.stringify(data, null, 2));
205
+ }
513
206
 
514
- // Continue with the same backend submission logic as above
515
- // (Similar to forceYouTubeReconnectionWithConsent)
207
+ // Check if the response contains the OAuth URL based on platform
208
+ let oauthUrl = null;
209
+ switch (platform) {
210
+ case 'reddit':
211
+ oauthUrl = data.redditURL;
212
+ break;
213
+ case 'pinterest':
214
+ oauthUrl = data.pinterestURL;
215
+ break;
216
+ case 'youtube':
217
+ oauthUrl = data.youtubeURL;
218
+ break;
219
+ case 'email':
220
+ // Gmail might return under different field names
221
+ oauthUrl = data.emailURL || data.gmailURL || data.authUrl || data.url;
222
+ break;
223
+ default:
224
+ oauthUrl = data.url;
225
+ break;
226
+ }
227
+ if (!oauthUrl) {
228
+ console.error(`โŒ No OAuth URL found in response for ${platform}. Response:`, data);
229
+ throw new Error(`No OAuth URL found in response for ${platform}`);
230
+ }
231
+ console.log(`โœ… ${platform} OAuth URL received:`, oauthUrl);
516
232
 
517
- return true;
233
+ // Validate the URL before returning
234
+ if (await validateOAuthUrl(oauthUrl)) {
235
+ return oauthUrl;
518
236
  } else {
519
- console.error('โŒ Still no refresh token after revoke method');
520
- return false;
237
+ throw new Error(`Received invalid ${platform} OAuth URL`);
521
238
  }
522
239
  } catch (error) {
523
- console.error('โŒ Error with revoke method:', error);
524
- return false;
525
- }
526
- };
527
-
528
- /**
529
- * Fix YouTube connection for a specific user (like nicholase50)
530
- */
531
- exports.forceYouTubeReconnectionWithRevoke = forceYouTubeReconnectionWithRevoke;
532
- const fixUserYouTubeConnection = async username => {
533
- console.log(`๐Ÿ”ง Fixing YouTube connection for user: ${username}`);
534
-
535
- // Method 1: Try forced consent via configuration
536
- console.log('๐Ÿ”„ Method 1: Trying forced consent via configuration...');
537
- let success = await forceYouTubeReconnectionWithConsent(username);
538
- if (success) {
539
- console.log(`โœ… ${username} YouTube connection fixed via Method 1!`);
540
- return true;
541
- }
542
-
543
- // Method 2: Try forced consent via revoke
544
- console.log('๐Ÿ”„ Method 2: Trying forced consent via revoke...');
545
- success = await forceYouTubeReconnectionWithRevoke(username);
546
- if (success) {
547
- console.log(`โœ… ${username} YouTube connection fixed via Method 2!`);
548
- return true;
240
+ console.error(`Error initiating OAuth for ${platform}:`, error);
241
+ throw error;
549
242
  }
550
- console.error(`โŒ Failed to fix ${username} YouTube connection with both methods`);
551
- return false;
552
243
  };
553
244
 
554
- /**
555
- * Get fresh tokens using refresh token
245
+ /**
246
+ * Validates an OAuth URL to ensure it's reachable
247
+ * @param url The OAuth URL to validate
248
+ * @returns Promise<boolean> indicating if the URL is valid and reachable
556
249
  */
557
- exports.fixUserYouTubeConnection = fixUserYouTubeConnection;
558
- const refreshGoogleTokens = async () => {
250
+ exports.initiateOAuth = initiateOAuth;
251
+ const validateOAuthUrl = async url => {
559
252
  try {
560
- console.log('๐Ÿ”„ Attempting to refresh Google tokens...');
253
+ console.log('๐Ÿ” Validating OAuth URL:', url);
561
254
 
562
- // Check if user is signed in
563
- const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
564
- if (!currentUser) {
565
- console.log('โŒ User not signed in to Google, cannot refresh tokens');
566
- return null;
255
+ // Basic URL format validation
256
+ if (!url || typeof url !== 'string') {
257
+ console.error('โŒ Invalid URL format:', url);
258
+ return false;
567
259
  }
568
260
 
569
- // Get fresh tokens
570
- const tokens = await _googleSignin.GoogleSignin.getTokens();
571
- console.log('โœ… Successfully refreshed Google tokens');
572
- return {
573
- accessToken: tokens.accessToken,
574
- idToken: tokens.idToken
575
- };
576
- } catch (error) {
577
- console.error('โŒ Failed to refresh Google tokens:', error);
578
-
579
- // If refresh fails, try to sign in again
580
- try {
581
- console.log('๐Ÿ”„ Refresh failed, attempting re-authentication...');
582
- const userInfo = await _googleSignin.GoogleSignin.signIn();
583
- const tokens = await _googleSignin.GoogleSignin.getTokens();
584
- console.log('โœ… Re-authentication successful');
585
- return {
586
- accessToken: tokens.accessToken,
587
- idToken: tokens.idToken
588
- };
589
- } catch (signInError) {
590
- console.error('โŒ Re-authentication also failed:', signInError);
591
- return null;
261
+ // Check if URL starts with https
262
+ if (!url.startsWith('https://')) {
263
+ console.error('โŒ URL must use HTTPS:', url);
264
+ return false;
592
265
  }
593
- }
594
- };
595
-
596
- /**
597
- * Debug YouTube tokens to verify refresh token availability
598
- */
599
- const debugYouTubeTokens = async () => {
600
- try {
601
- var _currentUser$user;
602
- const tokens = await _googleSignin.GoogleSignin.getTokens();
603
- const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
604
- console.log('๐Ÿ” YouTube Token Debug:', {
605
- accessToken: tokens.accessToken ? `${tokens.accessToken.substring(0, 20)}...` : 'Missing',
606
- idToken: tokens.idToken ? 'Present' : 'Missing',
607
- serverAuthCode: currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? `${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing',
608
- userEmail: (currentUser === null || currentUser === void 0 || (_currentUser$user = currentUser.user) === null || _currentUser$user === void 0 ? void 0 : _currentUser$user.email) || 'Missing'
609
- });
610
- return {
611
- hasRefreshToken: !!(currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode),
612
- refreshTokenType: currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? 'serverAuthCode' : 'none'
613
- };
614
- } catch (error) {
615
- console.error('โŒ Debug tokens failed:', error);
616
- return {
617
- hasRefreshToken: false,
618
- refreshTokenType: 'error'
619
- };
620
- }
621
- };
622
266
 
623
- /**
624
- * Force fresh YouTube reconnection with proper refresh token
625
- */
626
- const reconnectYouTube = async username => {
627
- try {
628
- console.log('๐Ÿ”„ Forcing fresh YouTube reconnection for refresh token...');
629
-
630
- // 1. Sign out completely to force fresh consent
267
+ // Try to parse the URL
631
268
  try {
632
- await _googleSignin.GoogleSignin.signOut();
633
- console.log('โœ… Signed out from Google');
634
- } catch (signOutError) {
635
- console.log('โ„น๏ธ Already signed out or sign out failed:', signOutError);
269
+ new URL(url);
270
+ } catch (parseError) {
271
+ console.error('โŒ URL parsing failed:', parseError);
272
+ return false;
636
273
  }
637
274
 
638
- // 2. Clear any cached tokens
639
- try {
640
- const currentTokens = await _googleSignin.GoogleSignin.getTokens();
641
- if (currentTokens.accessToken) {
642
- await _googleSignin.GoogleSignin.clearCachedAccessToken(currentTokens.accessToken);
643
- console.log('โœ… Cleared cached access token');
644
- }
645
- } catch (clearError) {
646
- console.log('โ„น๏ธ Token clearing failed or not needed:', clearError);
647
- }
275
+ // Make a HEAD request to check if the URL is reachable
276
+ const controller = new AbortController();
277
+ const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
648
278
 
649
- // 3. Re-authenticate with fresh consent
650
- const result = await initiateNativeAuth('youtube', username);
651
- if (result) {
652
- console.log('โœ… YouTube reconnected successfully with refresh token');
279
+ try {
280
+ const response = await fetch(url, {
281
+ method: 'HEAD',
282
+ signal: controller.signal
283
+ });
284
+ clearTimeout(timeoutId);
653
285
 
654
- // 4. Verify we now have a refresh token
655
- const debugInfo = await debugYouTubeTokens();
656
- if (debugInfo.hasRefreshToken) {
657
- console.log('โœ… Refresh token confirmed:', debugInfo.refreshTokenType);
658
- } else {
659
- console.warn('โš ๏ธ Still no refresh token after reconnection');
660
- }
286
+ // Accept any response that's not a network error
287
+ // OAuth pages might return various status codes
288
+ console.log('โœ… OAuth URL validation successful, status:', response.status);
661
289
  return true;
662
- } else {
663
- console.error('โŒ YouTube reconnection failed');
664
- return false;
290
+ } catch (fetchError) {
291
+ clearTimeout(timeoutId);
292
+ if (fetchError.name === 'AbortError') {
293
+ console.warn('โš ๏ธ OAuth URL validation timeout, but proceeding anyway');
294
+ return true; // Allow timeout as URLs might be slow to respond
295
+ }
296
+ console.warn('โš ๏ธ OAuth URL validation failed, but proceeding anyway:', fetchError.message);
297
+ return true; // Allow network errors as they might be temporary
665
298
  }
666
299
  } catch (error) {
667
- console.error('โŒ YouTube reconnection error:', error);
668
- return false;
300
+ console.warn('โš ๏ธ OAuth URL validation error, but proceeding anyway:', error);
301
+ return true; // Allow validation errors to not block the flow
669
302
  }
670
303
  };
671
304
 
672
- /**
673
- * Initiate native authentication for platforms with SDKs
305
+ /**
306
+ * Initiates the native SDK authentication flow for a platform
307
+ * @param platform The platform to authenticate with
308
+ * @returns A Promise that resolves to the authentication result
674
309
  */
675
- exports.reconnectYouTube = reconnectYouTube;
676
310
  const initiateNativeAuth = async (platform, username) => {
677
311
  if (platform === 'youtube') {
678
312
  console.log('๐Ÿ”— Initiating native Google Sign-In for YouTube');
679
-
680
- // Validate username for YouTube
681
- if (!username || username.trim() === '') {
682
- console.error('โŒ [YOUTUBE AUTH] Username is required for YouTube authentication');
683
- return false;
684
- }
685
313
  try {
686
- var _userInfo$data15, _currentUser$user2, _userInfo$data16, _userInfo$data17, _userInfo$data24, _userInfo$data27, _userInfo$data28, _userInfo$data29, _userInfo$data30, _authToken, _userInfo$data31;
687
- // Initialize Google Sign-In if not already done
688
- // โœ… CRITICAL: Initialize with CORRECT iOS Client ID
689
- initializeGoogleSignIn();
314
+ var _currentUser$user, _userInfo$user4, _userInfo$user6, _userInfo$user7, _userInfo$user8;
315
+ // Check if Google Sign-In package is available
316
+ let GoogleSignin, statusCodes;
317
+ try {
318
+ const googleSignInModule = require('@react-native-google-signin/google-signin');
319
+ GoogleSignin = googleSignInModule.GoogleSignin;
320
+ statusCodes = googleSignInModule.statusCodes;
321
+ } catch (importError) {
322
+ console.error('โŒ Google Sign-In package not available:', importError);
323
+ throw new Error('Google Sign-In SDK not installed. Please install @react-native-google-signin/google-signin');
324
+ }
690
325
 
691
- // Check if Google Play Services are available
692
- await _googleSignin.GoogleSignin.hasPlayServices();
326
+ // Configure Google Sign-In with better error handling
327
+ try {
328
+ const youtubeConfig = PLATFORM_AUTH_CONFIG.youtube;
329
+ const webClientId = youtubeConfig.clientId || '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
330
+ const iosClientId = youtubeConfig.iosClientId || webClientId;
331
+ await GoogleSignin.configure({
332
+ webClientId: webClientId,
333
+ iosClientId: iosClientId,
334
+ scopes: ['https://www.googleapis.com/auth/youtube.readonly'],
335
+ offlineAccess: true,
336
+ hostedDomain: '',
337
+ forceCodeForRefreshToken: true,
338
+ accountName: ''
339
+ });
340
+ console.log('โœ… Google Sign-In configured successfully with client ID:', webClientId.substring(0, 20) + '...');
341
+ } catch (configError) {
342
+ console.error('โŒ Google Sign-In configuration failed:', configError);
343
+ throw new Error(`Google Sign-In configuration failed: ${configError.message || configError}`);
344
+ }
693
345
 
694
- // โœ… CRITICAL: Force sign out first to ensure fresh consent
346
+ // Check if Google Play Services are available (Android only)
695
347
  try {
696
- await _googleSignin.GoogleSignin.signOut();
697
- console.log('๐Ÿ”„ Signed out to force fresh consent');
698
- } catch (signOutError) {
699
- console.log('โ„น๏ธ Sign out not needed or failed:', signOutError);
348
+ await GoogleSignin.hasPlayServices({
349
+ showPlayServicesUpdateDialog: true
350
+ });
351
+ console.log('โœ… Google Play Services available');
352
+ } catch (playServicesError) {
353
+ console.error('โŒ Google Play Services error:', playServicesError);
354
+ throw new Error(`Google Play Services not available: ${playServicesError.message || playServicesError}`);
700
355
  }
701
356
 
702
- // Sign in with Google (this will show consent screen due to our config)
703
- const userInfo = await _googleSignin.GoogleSignin.signIn();
704
- console.log('โœ… Google Sign-In successful:', (_userInfo$data15 = userInfo.data) === null || _userInfo$data15 === void 0 || (_userInfo$data15 = _userInfo$data15.user) === null || _userInfo$data15 === void 0 ? void 0 : _userInfo$data15.email);
705
- console.log('๐Ÿ“‹ FULL userInfo object:');
706
- console.log(JSON.stringify(userInfo, null, 2));
357
+ // Sign in with Google
358
+ let userInfo;
359
+ try {
360
+ var _userInfo$user;
361
+ userInfo = await GoogleSignin.signIn();
362
+ console.log('โœ… Google Sign-In successful:', (_userInfo$user = userInfo.user) === null || _userInfo$user === void 0 ? void 0 : _userInfo$user.email);
363
+ } catch (signInError) {
364
+ console.error('โŒ Google Sign-In failed:', signInError);
365
+
366
+ // Handle specific error codes
367
+ if (signInError.code === statusCodes.SIGN_IN_CANCELLED) {
368
+ throw new Error('Google Sign-In was cancelled by user');
369
+ } else if (signInError.code === statusCodes.IN_PROGRESS) {
370
+ throw new Error('Google Sign-In already in progress');
371
+ } else if (signInError.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
372
+ throw new Error('Google Play Services not available or outdated');
373
+ } else {
374
+ throw new Error(`Google Sign-In failed: ${signInError.message || signInError}`);
375
+ }
376
+ }
707
377
 
708
378
  // Get access token for API calls
709
- const tokens = await _googleSignin.GoogleSignin.getTokens();
379
+ const tokens = await GoogleSignin.getTokens();
710
380
  console.log('๐Ÿ”‘ Got Google tokens');
711
- console.log('๐Ÿ“‹ FULL tokens object:');
712
- console.log(JSON.stringify(tokens, null, 2));
713
381
 
714
- // CRITICAL: Get the current user info which contains the refresh token
715
- const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
716
- console.log('๐Ÿ‘ค Current user info:', currentUser === null || currentUser === void 0 || (_currentUser$user2 = currentUser.user) === null || _currentUser$user2 === void 0 ? void 0 : _currentUser$user2.email);
717
- console.log('๐Ÿ“‹ FULL currentUser object:');
718
- console.log(JSON.stringify(currentUser, null, 2));
382
+ // Get current user info with refresh token
383
+ const currentUser = await GoogleSignin.getCurrentUser();
384
+ console.log('๐Ÿ‘ค Current user info:', currentUser === null || currentUser === void 0 || (_currentUser$user = currentUser.user) === null || _currentUser$user === void 0 ? void 0 : _currentUser$user.email);
719
385
 
720
- // โœ… CRITICAL: Extract refresh token properly using serverAuthCode
386
+ // Extract refresh token from server auth code
721
387
  let refreshToken = null;
722
- console.log('๐Ÿ” REFRESH TOKEN EXTRACTION:');
723
- console.log('- userInfo.data?.serverAuthCode:', (_userInfo$data16 = userInfo.data) !== null && _userInfo$data16 !== void 0 && _userInfo$data16.serverAuthCode ? `Present: ${userInfo.data.serverAuthCode.substring(0, 20)}...` : 'Missing');
724
- console.log('- currentUser?.serverAuthCode:', currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? `Present: ${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing');
725
- console.log('- tokens.idToken:', tokens.idToken ? `Present: ${tokens.idToken.substring(0, 20)}...` : 'Missing');
726
- console.log('- tokens.accessToken:', tokens.accessToken ? `Present: ${tokens.accessToken.substring(0, 20)}...` : 'Missing');
727
-
728
- // The serverAuthCode is the refresh token mechanism for React Native Google Sign-In
729
388
  if (currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode) {
389
+ console.log('๐Ÿ”„ Server auth code available for refresh token');
730
390
  refreshToken = currentUser.serverAuthCode;
731
- console.log('โœ… Got serverAuthCode (refresh token mechanism)');
732
- console.log('๐Ÿ”‘ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
733
- } else if ((_userInfo$data17 = userInfo.data) !== null && _userInfo$data17 !== void 0 && _userInfo$data17.serverAuthCode) {
734
- refreshToken = userInfo.data.serverAuthCode;
735
- console.log('โœ… Got serverAuthCode from sign-in response');
736
- console.log('๐Ÿ”‘ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
737
391
  }
738
-
739
- // โœ… CRITICAL: Verify refresh token availability
740
392
  if (!refreshToken) {
741
- console.error('โŒ CRITICAL: No refresh token available - YouTube connection will fail when token expires');
742
- console.error('๐Ÿ’ก User needs to reconnect with proper consent screen');
743
- console.error('๐Ÿ’ก Check Google Sign-In configuration: offlineAccess, forceCodeForRefreshToken');
744
-
745
- // Still continue but warn about the issue
746
- console.warn('โš ๏ธ Continuing without refresh token - connection may fail later');
393
+ console.warn('โš ๏ธ No refresh token available - token refresh may fail later');
747
394
  } else {
748
395
  console.log('โœ… Refresh token available for YouTube connection');
749
- console.log('๐Ÿ”‘ Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
750
396
  }
751
397
 
752
- // Fetch YouTube channel information using the access token
398
+ // Fetch YouTube channel information
753
399
  let channelName = 'Unknown Channel';
754
400
  let channelId = null;
755
401
  try {
@@ -765,60 +411,28 @@ const initiateNativeAuth = async (platform, username) => {
765
411
  if (channelData.items && channelData.items.length > 0) {
766
412
  channelName = channelData.items[0].snippet.title;
767
413
  channelId = channelData.items[0].id;
768
- console.log('โœ… YouTube channel found:', channelName, 'ID:', channelId);
769
- } else {
770
- var _userInfo$data18, _userInfo$data19;
771
- console.log('โš ๏ธ No YouTube channel found for user');
772
- channelName = ((_userInfo$data18 = userInfo.data) === null || _userInfo$data18 === void 0 || (_userInfo$data18 = _userInfo$data18.user) === null || _userInfo$data18 === void 0 ? void 0 : _userInfo$data18.name) || ((_userInfo$data19 = userInfo.data) === null || _userInfo$data19 === void 0 || (_userInfo$data19 = _userInfo$data19.user) === null || _userInfo$data19 === void 0 ? void 0 : _userInfo$data19.email) || 'No Channel';
414
+ console.log('โœ… YouTube channel found:', channelName);
773
415
  }
774
- } else {
775
- var _userInfo$data20, _userInfo$data21;
776
- console.log('โš ๏ธ Failed to fetch YouTube channel info:', channelResponse.status);
777
- channelName = ((_userInfo$data20 = userInfo.data) === null || _userInfo$data20 === void 0 || (_userInfo$data20 = _userInfo$data20.user) === null || _userInfo$data20 === void 0 ? void 0 : _userInfo$data20.name) || ((_userInfo$data21 = userInfo.data) === null || _userInfo$data21 === void 0 || (_userInfo$data21 = _userInfo$data21.user) === null || _userInfo$data21 === void 0 ? void 0 : _userInfo$data21.email) || 'Unknown Channel';
778
416
  }
779
417
  } catch (channelError) {
780
- var _userInfo$data22, _userInfo$data23;
418
+ var _userInfo$user2, _userInfo$user3;
781
419
  console.log('โš ๏ธ Error fetching YouTube channel info:', channelError);
782
- channelName = ((_userInfo$data22 = userInfo.data) === null || _userInfo$data22 === void 0 || (_userInfo$data22 = _userInfo$data22.user) === null || _userInfo$data22 === void 0 ? void 0 : _userInfo$data22.name) || ((_userInfo$data23 = userInfo.data) === null || _userInfo$data23 === void 0 || (_userInfo$data23 = _userInfo$data23.user) === null || _userInfo$data23 === void 0 ? void 0 : _userInfo$data23.email) || 'Unknown Channel';
420
+ channelName = ((_userInfo$user2 = userInfo.user) === null || _userInfo$user2 === void 0 ? void 0 : _userInfo$user2.name) || ((_userInfo$user3 = userInfo.user) === null || _userInfo$user3 === void 0 ? void 0 : _userInfo$user3.email) || 'Unknown Channel';
783
421
  }
784
422
 
785
- // Get stored authentication info to link YouTube data to user account
423
+ // Get authentication info
786
424
  let authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
787
425
  const storedUsername = await _asyncStorage.default.getItem('onairos_username');
788
- const finalUsername = storedUsername || username || ((_userInfo$data24 = userInfo.data) === null || _userInfo$data24 === void 0 || (_userInfo$data24 = _userInfo$data24.user) === null || _userInfo$data24 === void 0 ? void 0 : _userInfo$data24.email) || 'youtube_user';
426
+ const finalUsername = storedUsername || username || ((_userInfo$user4 = userInfo.user) === null || _userInfo$user4 === void 0 ? void 0 : _userInfo$user4.email) || 'youtube_user';
789
427
 
790
- // If no auth token exists, create one now to ensure YouTube data is linked to user account
428
+ // Create auth token if needed
791
429
  if (!authToken || authToken.trim().length < 20) {
792
- console.log('๐Ÿ” No valid authentication token found, creating one for YouTube authentication...');
430
+ console.log('๐Ÿ” Creating authentication token for YouTube...');
793
431
  try {
794
- var _userInfo$data25;
795
- // Create user accounts and get proper Enoch token
796
- const fallbackEmail = ((_userInfo$data25 = userInfo.data) === null || _userInfo$data25 === void 0 || (_userInfo$data25 = _userInfo$data25.user) === null || _userInfo$data25 === void 0 ? void 0 : _userInfo$data25.email) || `${finalUsername}@youtube.temp`;
797
-
798
- // Step 1: Create Enoch user first
799
- console.log('๐Ÿ” Step 1: Creating Enoch user for YouTube auth...');
800
- try {
801
- var _userInfo$data26;
802
- const enochRegisterResponse = await fetch('https://api2.onairos.uk/enoch/users/register', {
803
- method: 'POST',
804
- headers: {
805
- 'Content-Type': 'application/json'
806
- },
807
- body: JSON.stringify({
808
- email: fallbackEmail,
809
- name: finalUsername,
810
- photoUrl: ((_userInfo$data26 = userInfo.data) === null || _userInfo$data26 === void 0 || (_userInfo$data26 = _userInfo$data26.user) === null || _userInfo$data26 === void 0 ? void 0 : _userInfo$data26.photo) || ''
811
- })
812
- });
813
- console.log('๐Ÿ“ก Enoch register response status:', enochRegisterResponse.status);
814
- const enochResponseData = await enochRegisterResponse.json();
815
- console.log('๐Ÿ”— Enoch user creation response:', enochResponseData);
816
- } catch (enochError) {
817
- console.warn('โš ๏ธ Enoch user creation failed (continuing):', enochError);
818
- }
432
+ var _userInfo$user5;
433
+ const fallbackEmail = ((_userInfo$user5 = userInfo.user) === null || _userInfo$user5 === void 0 ? void 0 : _userInfo$user5.email) || `${finalUsername}@youtube.temp`;
819
434
 
820
- // Step 2: Create Onairos account to get JWT token
821
- console.log('๐Ÿ” Step 2: Creating Onairos account for YouTube auth...');
435
+ // Create user accounts and get JWT token
822
436
  const onairosSignupResponse = await fetch('https://api2.onairos.uk/register/enoch', {
823
437
  method: 'POST',
824
438
  headers: {
@@ -830,248 +444,255 @@ const initiateNativeAuth = async (platform, username) => {
830
444
  name: finalUsername
831
445
  })
832
446
  });
833
- console.log('๐Ÿ“ก Onairos register response status:', onairosSignupResponse.status);
834
447
  if (onairosSignupResponse.ok) {
835
448
  var _onairosResponseData$;
836
449
  const onairosResponseData = await onairosSignupResponse.json();
837
- console.log('๐Ÿ”— Onairos account creation response:', onairosResponseData);
838
-
839
- // Extract the token from the response
840
- if (onairosResponseData.token) {
841
- authToken = onairosResponseData.token;
842
- } else if ((_onairosResponseData$ = onairosResponseData.data) !== null && _onairosResponseData$ !== void 0 && _onairosResponseData$.token) {
843
- authToken = onairosResponseData.data.token;
844
- } else if (onairosResponseData.jwt) {
845
- authToken = onairosResponseData.jwt;
846
- }
450
+
451
+ // Extract token from response
452
+ authToken = onairosResponseData.token || ((_onairosResponseData$ = onairosResponseData.data) === null || _onairosResponseData$ === void 0 ? void 0 : _onairosResponseData$.token) || onairosResponseData.jwt;
847
453
  if (authToken) {
848
- // Store the Enoch token in all the standard locations
454
+ // Store tokens
849
455
  await _asyncStorage.default.setItem('onairos_jwt_token', authToken);
850
456
  await _asyncStorage.default.setItem('enoch_token', authToken);
851
457
  await _asyncStorage.default.setItem('auth_token', authToken);
852
458
  await _asyncStorage.default.setItem('onairos_username', onairosResponseData.username || finalUsername);
853
- console.log('โœ… Successfully created and stored Enoch authentication token for YouTube');
854
- console.log('๐Ÿ”‘ Enoch token preview:', `${authToken.substring(0, 20)}...`);
459
+ console.log('โœ… Successfully created and stored authentication token');
855
460
  }
856
- } else {
857
- const errorText = await onairosSignupResponse.text();
858
- console.warn('โš ๏ธ Could not create Enoch auth token for YouTube:', errorText);
859
461
  }
860
462
  } catch (tokenError) {
861
- console.warn('โš ๏ธ Error creating Enoch auth token for YouTube:', tokenError);
862
- // Continue without token - backend will handle gracefully
463
+ console.warn('โš ๏ธ Error creating auth token:', tokenError);
863
464
  }
864
- } else {
865
- console.log('โœ… Found existing authentication token for YouTube auth');
866
- console.log('๐Ÿ”‘ Token preview:', `${authToken.substring(0, 20)}...`);
867
465
  }
868
466
  console.log('๐Ÿ”— Linking YouTube data to user:', finalUsername);
869
- console.log('๐Ÿ”‘ Using auth token for linking:', authToken ? `${authToken.substring(0, 20)}...` : 'No token');
870
467
  console.log('๐Ÿ“บ YouTube channel name:', channelName);
871
468
 
872
- // โœ… CRITICAL: Enhanced payload with comprehensive refresh token data
873
- const backendPayload = {
874
- session: {
875
- username: finalUsername,
876
- platform: 'youtube',
877
- timestamp: new Date().toISOString(),
878
- channelName: channelName,
879
- channelId: channelId
880
- },
881
- googleUser: (_userInfo$data27 = userInfo.data) === null || _userInfo$data27 === void 0 ? void 0 : _userInfo$data27.user,
882
- accessToken: tokens.accessToken,
883
- idToken: tokens.idToken,
884
- refreshToken: refreshToken,
885
- // โœ… CRITICAL: Include refresh token
886
- serverAuthCode: refreshToken,
887
- // โœ… Alternative refresh mechanism (same as refreshToken)
888
-
889
- // โœ… CRITICAL: Additional compatibility fields for backend
890
- refresh_token: refreshToken,
891
- // Snake case version
892
- server_auth_code: refreshToken,
893
- // Snake case version
894
- authCode: refreshToken,
895
- // Alternative naming
896
-
897
- // Include user account linking information
898
- userAccountInfo: {
899
- username: finalUsername,
900
- email: (_userInfo$data28 = userInfo.data) === null || _userInfo$data28 === void 0 || (_userInfo$data28 = _userInfo$data28.user) === null || _userInfo$data28 === void 0 ? void 0 : _userInfo$data28.email,
901
- authToken: authToken,
902
- channelName: channelName,
903
- channelId: channelId,
904
- // CRITICAL: Include user identifier that matches your database
905
- userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${(_userInfo$data29 = userInfo.data) === null || _userInfo$data29 === void 0 || (_userInfo$data29 = _userInfo$data29.user) === null || _userInfo$data29 === void 0 ? void 0 : _userInfo$data29.email}`,
906
- googleId: (_userInfo$data30 = userInfo.data) === null || _userInfo$data30 === void 0 || (_userInfo$data30 = _userInfo$data30.user) === null || _userInfo$data30 === void 0 ? void 0 : _userInfo$data30.id,
907
- appleUserId: (_authToken = authToken) !== null && _authToken !== void 0 && _authToken.includes('apple') ? authToken.split('.')[1] : null,
908
- // โœ… CRITICAL: Also include refresh token in userAccountInfo
909
- refreshToken: refreshToken,
910
- serverAuthCode: refreshToken
911
- },
912
- // Token expiry information
913
- tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
914
- // 1 hour from now
915
- // Force refresh token request
916
- requestRefreshToken: true,
917
- // โœ… CRITICAL: Debug information for backend
918
- debugInfo: {
919
- hasRefreshToken: !!refreshToken,
920
- refreshTokenType: refreshToken ? refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken' : 'none',
921
- configuredForRefresh: true,
922
- forcedConsent: true,
923
- refreshTokenValue: refreshToken // Include actual value for debugging
924
- }
925
- };
926
- console.log('๐Ÿ“ค BACKEND PAYLOAD SUMMARY:');
927
- console.log('- hasAccessToken:', !!backendPayload.accessToken);
928
- console.log('- hasRefreshToken:', !!backendPayload.refreshToken);
929
- console.log('- hasServerAuthCode:', !!backendPayload.serverAuthCode);
930
- console.log('- refreshTokenType:', backendPayload.debugInfo.refreshTokenType);
931
- console.log('- userEmail:', (_userInfo$data31 = userInfo.data) === null || _userInfo$data31 === void 0 || (_userInfo$data31 = _userInfo$data31.user) === null || _userInfo$data31 === void 0 ? void 0 : _userInfo$data31.email);
932
- console.log('- channelName:', channelName);
933
- console.log('๐Ÿ“‹ COMPLETE BACKEND PAYLOAD:');
934
- console.log(JSON.stringify(backendPayload, null, 2));
935
-
936
- // Send the tokens to your backend for YouTube data processing with ENHANCED LOGGING
937
- console.log('๐Ÿ“ค Sending YouTube auth to backend with refresh token:', !!refreshToken);
469
+ // Send tokens to backend for YouTube data processing
938
470
  const backendResponse = await fetch('https://api2.onairos.uk/youtube/native-auth', {
939
471
  method: 'POST',
940
472
  headers: {
941
473
  'Content-Type': 'application/json',
942
474
  ...(authToken && {
943
- 'Authorization': authToken
944
- }) // Include auth token if available
475
+ 'Authorization': `Bearer ${authToken}`
476
+ })
945
477
  },
946
- body: JSON.stringify(backendPayload)
478
+ body: JSON.stringify({
479
+ session: {
480
+ username: finalUsername,
481
+ platform: 'youtube',
482
+ timestamp: new Date().toISOString(),
483
+ channelName: channelName,
484
+ channelId: channelId
485
+ },
486
+ googleUser: userInfo.user,
487
+ accessToken: tokens.accessToken,
488
+ idToken: tokens.idToken,
489
+ refreshToken: refreshToken,
490
+ // CRITICAL: Include refresh token
491
+ serverAuthCode: currentUser === null || currentUser === void 0 ? void 0 : currentUser.serverAuthCode,
492
+ userAccountInfo: {
493
+ username: finalUsername,
494
+ email: (_userInfo$user6 = userInfo.user) === null || _userInfo$user6 === void 0 ? void 0 : _userInfo$user6.email,
495
+ authToken: authToken,
496
+ channelName: channelName,
497
+ channelId: channelId,
498
+ userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${(_userInfo$user7 = userInfo.user) === null || _userInfo$user7 === void 0 ? void 0 : _userInfo$user7.email}`,
499
+ googleId: (_userInfo$user8 = userInfo.user) === null || _userInfo$user8 === void 0 ? void 0 : _userInfo$user8.id
500
+ },
501
+ tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
502
+ // 1 hour from now
503
+ requestRefreshToken: true
504
+ })
947
505
  });
948
- console.log('๐Ÿ“ก Backend response status:', backendResponse.status);
949
- console.log('๐Ÿ“ก Backend response headers:', backendResponse.headers);
950
506
  if (backendResponse.ok) {
951
- var _responseData$validat2, _responseData$tempora2;
952
507
  const responseData = await backendResponse.json();
953
- console.log('โœ… YouTube connection successful');
954
- console.log('๐Ÿ“‹ COMPLETE BACKEND RESPONSE:');
955
- console.log(JSON.stringify(responseData, null, 2));
956
-
957
- // โœ… Enhanced verification with temporary mode detection (exact backend fields)
958
- const isTemporaryMode = ((_responseData$validat2 = responseData.validation) === null || _responseData$validat2 === void 0 ? void 0 : _responseData$validat2.isTemporaryMode) === true || ((_responseData$tempora2 = responseData.temporaryMode) === null || _responseData$tempora2 === void 0 ? void 0 : _responseData$tempora2.enabled) === true || responseData.isTemporaryMode === true || responseData.message && responseData.message.includes('temporary access token mode');
959
- if (isTemporaryMode) {
960
- console.log('๐Ÿ”„ [YOUTUBE AUTH] YouTube connected in temporary mode');
961
- console.log('โœ… [YOUTUBE AUTH] Training will work, but connection expires in ~1 hour');
962
- console.log('โ„น๏ธ [YOUTUBE AUTH] User can reconnect later for refresh tokens if needed');
963
- } else if (responseData.hasRefreshToken || responseData.refreshTokenReceived) {
964
- console.log('โœ… [YOUTUBE AUTH] Backend confirmed refresh token received');
965
- console.log('โœ… [YOUTUBE AUTH] Full YouTube connection with persistent access');
966
- } else {
967
- console.warn('โš ๏ธ [YOUTUBE AUTH] Backend did not confirm refresh token');
968
- console.warn('๐Ÿ” [YOUTUBE AUTH] Response data keys:', Object.keys(responseData));
969
- console.warn('โš ๏ธ [YOUTUBE AUTH] Connection may fail when tokens expire');
970
- }
508
+ console.log('โœ… YouTube connection processed by backend:', responseData);
971
509
  return true;
972
510
  } else {
973
511
  const errorData = await backendResponse.text();
974
- console.error('โŒ YouTube auth failed:', backendResponse.status);
975
- console.error('๐Ÿ“‹ BACKEND ERROR RESPONSE:');
976
- console.error(errorData);
512
+ console.error('โŒ Backend processing failed:', backendResponse.status, errorData);
977
513
  return false;
978
514
  }
979
515
  } catch (error) {
980
516
  console.error('โŒ Google Sign-In error:', error);
981
- if (error.code === _googleSignin.statusCodes.SIGN_IN_CANCELLED) {
517
+ const {
518
+ statusCodes: StatusCodes
519
+ } = require('@react-native-google-signin/google-signin');
520
+ if (error.code === StatusCodes.SIGN_IN_CANCELLED) {
982
521
  console.log('User cancelled Google Sign-In');
983
- } else if (error.code === _googleSignin.statusCodes.IN_PROGRESS) {
522
+ } else if (error.code === StatusCodes.IN_PROGRESS) {
984
523
  console.log('Google Sign-In already in progress');
985
- } else if (error.code === _googleSignin.statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
524
+ } else if (error.code === StatusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
986
525
  console.log('Google Play Services not available');
987
526
  }
988
527
  return false;
989
528
  }
990
529
  }
991
-
992
- // Instagram is commented out in the UI, but keeping the code for future use
993
- if (platform === 'instagram') {
994
- // Simulate Facebook Login SDK for Instagram
995
- console.log('Initiating Facebook Login for Instagram');
996
- return new Promise(resolve => {
997
- setTimeout(() => {
998
- console.log('Facebook Login completed successfully');
999
- resolve(true);
1000
- }, 1000);
1001
- });
1002
- }
1003
530
  return false;
1004
531
  };
1005
532
 
1006
- /**
1007
- * Check if a URL is an OAuth callback
533
+ /**
534
+ * Handles the OAuth callback
535
+ * @param url The callback URL
536
+ * @returns The authorization code extracted from the URL
1008
537
  */
1009
538
  exports.initiateNativeAuth = initiateNativeAuth;
539
+ const handleOAuthCallback = url => {
540
+ try {
541
+ // Parse the URL
542
+ const parsedUrl = new URL(url);
543
+
544
+ // Extract the authorization code
545
+ return parsedUrl.searchParams.get('code');
546
+ } catch (error) {
547
+ console.error('Error handling OAuth callback:', error);
548
+ return null;
549
+ }
550
+ };
551
+
552
+ /**
553
+ * Checks if a URL is an OAuth callback
554
+ * @param url The URL to check
555
+ * @returns True if the URL is an OAuth callback
556
+ */
557
+ exports.handleOAuthCallback = handleOAuthCallback;
1010
558
  const isOAuthCallback = url => {
1011
- return url.includes('auth/callback') || url.includes('code=');
559
+ // Check if the URL starts with our redirect URI
560
+ return url.startsWith('onairosanime://auth/');
1012
561
  };
1013
562
 
1014
- /**
1015
- * Exchange authorization code for access token
1016
- * This would typically be done on a server, but we're simulating it here
563
+ /**
564
+ * Test connectivity to the Onairos API server
1017
565
  */
1018
566
  exports.isOAuthCallback = isOAuthCallback;
1019
- const exchangeCodeForToken = async (code, platform) => {
1020
- console.log(`Exchanging code for token for platform: ${platform}`);
567
+ const testApiConnectivity = async () => {
1021
568
  try {
1022
- // Use the proxy server to exchange the code for a token
1023
- const tokenUrl = `https://api2.onairos.uk/${platform}/token`;
569
+ console.log('๐Ÿ” Testing connectivity to Onairos API...');
1024
570
 
1025
- // Make a POST request to the proxy
1026
- const response = await fetch(tokenUrl, {
1027
- method: 'POST',
1028
- headers: {
1029
- 'Content-Type': 'application/json'
1030
- },
1031
- body: JSON.stringify({
1032
- code: code,
1033
- platform: platform
1034
- })
1035
- });
1036
- if (!response.ok) {
1037
- console.error(`Error exchanging code for token: ${response.status}`);
1038
- throw new Error(`Token exchange failed with status ${response.status}`);
571
+ // Test multiple endpoints for better reliability
572
+ const testEndpoints = ['https://api2.onairos.uk/health', 'https://api2.onairos.uk' // Base URL
573
+ ];
574
+ let lastError = null;
575
+ for (const endpoint of testEndpoints) {
576
+ try {
577
+ console.log(`๐Ÿ” Testing endpoint: ${endpoint}`);
578
+ const controller = new AbortController();
579
+ const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
580
+
581
+ const response = await fetch(endpoint, {
582
+ method: 'GET',
583
+ headers: {
584
+ 'Content-Type': 'application/json',
585
+ 'User-Agent': 'OnairosReactNative/1.0'
586
+ },
587
+ signal: controller.signal
588
+ });
589
+ clearTimeout(timeoutId);
590
+ console.log(`๐ŸŒ API connectivity test response for ${endpoint}:`, response.status);
591
+ if (response.ok || response.status === 404) {
592
+ // Accept 404 as it means the server is reachable
593
+ console.log('โœ… API server is reachable');
594
+ return {
595
+ success: true
596
+ };
597
+ } else {
598
+ console.log(`โš ๏ธ API server responded with status ${response.status} for ${endpoint}`);
599
+ lastError = `API server error: ${response.status}`;
600
+ // Continue to next endpoint
601
+ }
602
+ } catch (fetchError) {
603
+ console.log(`โŒ Failed to reach ${endpoint}:`, fetchError);
604
+ if (fetchError.name === 'AbortError') {
605
+ lastError = 'Connection timeout - API server took too long to respond';
606
+ } else if (fetchError.message.includes('Network request failed')) {
607
+ lastError = 'Network error - check your internet connection';
608
+ } else if (fetchError.message.includes('not connected to the internet')) {
609
+ lastError = 'No internet connection';
610
+ } else {
611
+ lastError = `Network error: ${fetchError.message}`;
612
+ }
613
+
614
+ // Continue to next endpoint
615
+ }
1039
616
  }
1040
- const data = await response.json();
1041
- console.log(`Token exchange successful for ${platform}`);
1042
- return data;
617
+ console.error('โŒ All API connectivity tests failed');
618
+ return {
619
+ success: false,
620
+ error: lastError || 'Cannot reach API server'
621
+ };
1043
622
  } catch (error) {
1044
- console.error(`Error exchanging code for token:`, error);
623
+ console.error('โŒ API connectivity test failed:', error);
624
+ return {
625
+ success: false,
626
+ error: error instanceof Error ? error.message : 'Unknown error'
627
+ };
628
+ }
629
+ };
1045
630
 
1046
- // Fallback to simulation if the API call fails
1047
- console.log('Falling back to simulated token response');
631
+ /**
632
+ * ๐Ÿ”„ REFRESH GOOGLE TOKENS
633
+ */
634
+ exports.testApiConnectivity = testApiConnectivity;
635
+ const refreshGoogleTokens = async () => {
636
+ try {
637
+ console.log('๐Ÿ”„ Attempting to refresh Google tokens...');
638
+ const {
639
+ GoogleSignin
640
+ } = require('@react-native-google-signin/google-signin');
641
+ const currentUser = await GoogleSignin.getCurrentUser();
642
+ if (!currentUser) {
643
+ console.log('โŒ User not signed in to Google, cannot refresh tokens');
644
+ return null;
645
+ }
646
+ const tokens = await GoogleSignin.getTokens();
647
+ console.log('โœ… Successfully refreshed Google tokens');
1048
648
  return {
1049
- access_token: `${platform}_access_token_${Math.random().toString(36).substring(7)}`,
1050
- refresh_token: `${platform}_refresh_token_${Math.random().toString(36).substring(7)}`,
1051
- expires_in: 3600
649
+ accessToken: tokens.accessToken,
650
+ idToken: tokens.idToken
1052
651
  };
652
+ } catch (error) {
653
+ console.error('โŒ Failed to refresh Google tokens:', error);
654
+
655
+ // If refresh fails, try to sign in again
656
+ try {
657
+ console.log('๐Ÿ”„ Refresh failed, attempting re-authentication...');
658
+ const {
659
+ GoogleSignin
660
+ } = require('@react-native-google-signin/google-signin');
661
+ const userInfo = await GoogleSignin.signIn();
662
+ const tokens = await GoogleSignin.getTokens();
663
+ console.log('โœ… Re-authentication successful');
664
+ return {
665
+ accessToken: tokens.accessToken,
666
+ idToken: tokens.idToken
667
+ };
668
+ } catch (signInError) {
669
+ console.error('โŒ Re-authentication also failed:', signInError);
670
+ return null;
671
+ }
1053
672
  }
1054
673
  };
1055
674
 
1056
- /**
1057
- * Refresh YouTube tokens when they expire
1058
- * This should be called when the backend reports token expiry
675
+ /**
676
+ * ๐Ÿ”„ REFRESH YOUTUBE TOKENS
1059
677
  */
1060
- exports.exchangeCodeForToken = exchangeCodeForToken;
678
+ exports.refreshGoogleTokens = refreshGoogleTokens;
1061
679
  const refreshYouTubeTokens = async () => {
1062
680
  try {
1063
- var _currentUser$user3;
681
+ var _currentUser$user2;
1064
682
  console.log('๐Ÿ”„ Refreshing YouTube tokens...');
1065
683
 
1066
684
  // Get fresh tokens from Google SDK
1067
- const freshTokens = await _googleSignin.GoogleSignin.getTokens();
685
+ const freshTokens = await refreshGoogleTokens();
1068
686
  if (!freshTokens) {
1069
687
  console.error('โŒ Failed to get fresh tokens from Google SDK');
1070
688
  return false;
1071
689
  }
1072
690
 
1073
691
  // Get current user info
1074
- const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
692
+ const {
693
+ GoogleSignin
694
+ } = require('@react-native-google-signin/google-signin');
695
+ const currentUser = await GoogleSignin.getCurrentUser();
1075
696
  if (!currentUser) {
1076
697
  console.error('โŒ No current Google user found');
1077
698
  return false;
@@ -1089,15 +710,14 @@ const refreshYouTubeTokens = async () => {
1089
710
  method: 'POST',
1090
711
  headers: {
1091
712
  'Content-Type': 'application/json',
1092
- 'Authorization': authToken
713
+ 'Authorization': `Bearer ${authToken}`
1093
714
  },
1094
715
  body: JSON.stringify({
1095
716
  accessToken: freshTokens.accessToken,
1096
717
  idToken: freshTokens.idToken,
1097
718
  refreshToken: currentUser.serverAuthCode,
1098
- userEmail: (_currentUser$user3 = currentUser.user) === null || _currentUser$user3 === void 0 ? void 0 : _currentUser$user3.email,
719
+ userEmail: (_currentUser$user2 = currentUser.user) === null || _currentUser$user2 === void 0 ? void 0 : _currentUser$user2.email,
1099
720
  tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
1100
- // 1 hour from now
1101
721
  timestamp: new Date().toISOString()
1102
722
  })
1103
723
  });
@@ -1116,186 +736,332 @@ const refreshYouTubeTokens = async () => {
1116
736
  }
1117
737
  };
1118
738
 
1119
- /**
1120
- * Trigger training restart after YouTube re-authentication
1121
- * This signals the backend to restart training with the new refresh token
739
+ /**
740
+ * ๐ŸŽฏ ENHANCED OAUTH CALLBACK HANDLER
1122
741
  */
1123
742
  exports.refreshYouTubeTokens = refreshYouTubeTokens;
1124
- const triggerTrainingRestart = async (username, authToken) => {
743
+ const handleOAuthCallbackUrl = url => {
1125
744
  try {
1126
- console.log('๐Ÿ”„ [TRAINING RESTART] Triggering training restart for user:', username);
1127
- const response = await fetch('https://api2.onairos.uk/mobile-training/restart', {
1128
- method: 'POST',
1129
- headers: {
1130
- 'Content-Type': 'application/json',
1131
- 'Authorization': authToken
1132
- },
1133
- body: JSON.stringify({
1134
- username: username,
1135
- reason: 'youtube_reauth',
1136
- platform: 'youtube',
1137
- timestamp: new Date().toISOString(),
1138
- requestNewTraining: true
1139
- })
1140
- });
1141
- if (response.ok) {
1142
- const responseData = await response.json();
1143
- console.log('โœ… [TRAINING RESTART] Training restart successful:', responseData);
1144
- } else {
1145
- const errorData = await response.text();
1146
- console.error('โŒ [TRAINING RESTART] Training restart failed:', response.status, errorData);
1147
- throw new Error(`Training restart failed: ${response.status}`);
745
+ console.log('๐Ÿ” Processing OAuth callback URL:', url);
746
+
747
+ // Parse the URL
748
+ const parsedUrl = new URL(url);
749
+
750
+ // Extract platform and code
751
+ const platform = parsedUrl.searchParams.get('platform') || parsedUrl.pathname.split('/').find(segment => ['instagram', 'youtube', 'reddit', 'pinterest', 'email'].includes(segment));
752
+ const code = parsedUrl.searchParams.get('code');
753
+ const error = parsedUrl.searchParams.get('error');
754
+ if (error) {
755
+ console.error('โŒ OAuth error in callback:', error);
756
+ return {
757
+ success: false
758
+ };
1148
759
  }
760
+ if (code && platform) {
761
+ console.log(`โœ… OAuth callback processed: ${platform} with code: ${code.substring(0, 10)}...`);
762
+ return {
763
+ platform,
764
+ code,
765
+ success: true
766
+ };
767
+ }
768
+ console.warn('โš ๏ธ OAuth callback missing platform or code');
769
+ return {
770
+ success: false
771
+ };
1149
772
  } catch (error) {
1150
- console.error('โŒ [TRAINING RESTART] Error triggering training restart:', error);
1151
- throw error;
773
+ console.error('โŒ Error processing OAuth callback:', error);
774
+ return {
775
+ success: false
776
+ };
1152
777
  }
1153
778
  };
1154
779
 
1155
- /**
1156
- * Test function to verify YouTube refresh token functionality
1157
- * Call this in your app to test the YouTube connection
780
+ /**
781
+ * ๐Ÿ”ง UPDATE GOOGLE CLIENT IDS
782
+ * Allows apps to configure their own Google client IDs
1158
783
  */
1159
- const testYouTubeRefreshToken = async username => {
1160
- console.log('๐Ÿงช Testing YouTube refresh token functionality...');
1161
- console.log('๐Ÿ‘ค User:', username);
1162
- try {
1163
- // Test the debug function first
1164
- const debugInfo = await debugYouTubeTokens();
1165
- console.log('๐Ÿ” Current token status:', debugInfo);
1166
- if (!debugInfo.hasRefreshToken) {
1167
- console.log('โš ๏ธ No refresh token found - attempting to fix...');
1168
- const success = await fixUserYouTubeConnection(username);
1169
- if (success) {
1170
- console.log('โœ… YouTube connection fixed! Testing again...');
1171
- const newDebugInfo = await debugYouTubeTokens();
1172
- console.log('๐Ÿ” New token status:', newDebugInfo);
1173
- } else {
1174
- console.error('โŒ Failed to fix YouTube connection');
1175
- }
1176
- } else {
1177
- console.log('โœ… Refresh token already available');
1178
- }
1179
- } catch (error) {
1180
- console.error('โŒ Error testing YouTube refresh token:', error);
784
+ exports.handleOAuthCallbackUrl = handleOAuthCallbackUrl;
785
+ const updateGoogleClientIds = config => {
786
+ console.log('๐Ÿ”ง Updating Google client IDs configuration');
787
+ if (config.webClientId || config.iosClientId) {
788
+ // Update the YouTube configuration
789
+ PLATFORM_AUTH_CONFIG.youtube = {
790
+ ...PLATFORM_AUTH_CONFIG.youtube,
791
+ clientId: config.webClientId || PLATFORM_AUTH_CONFIG.youtube.clientId,
792
+ iosClientId: config.iosClientId || PLATFORM_AUTH_CONFIG.youtube.iosClientId
793
+ };
794
+ console.log('โœ… Google client IDs updated successfully');
795
+ console.log(' - Web Client ID:', config.webClientId ? config.webClientId.substring(0, 20) + '...' : 'not provided');
796
+ console.log(' - iOS Client ID:', config.iosClientId ? config.iosClientId.substring(0, 20) + '...' : 'not provided');
1181
797
  }
1182
798
  };
1183
799
 
1184
- /**
1185
- * Request email verification code
800
+ /**
801
+ * Request email verification using developer API key
802
+ * @param email Email address to verify
803
+ * @param testMode Whether to use test mode
804
+ * @returns Promise with verification result
1186
805
  */
1187
- exports.testYouTubeRefreshToken = testYouTubeRefreshToken;
806
+ exports.updateGoogleClientIds = updateGoogleClientIds;
1188
807
  const requestEmailVerification = async (email, testMode = false) => {
1189
808
  try {
1190
809
  console.log('๐Ÿ“ง Requesting email verification for:', email);
1191
- const response = await fetch(`${_api.API_CONFIG.BASE_URL}/email/verification`, {
810
+ const response = await (0, _apiKeyService.makeDeveloperRequest)('/email/verification', {
1192
811
  method: 'POST',
1193
- headers: (0, _api.getApiHeaders)(),
1194
812
  body: JSON.stringify({
1195
813
  email,
1196
814
  action: 'request',
1197
815
  testMode
1198
816
  })
1199
817
  });
1200
- const result = await response.json();
1201
- if (response.ok) {
818
+ const data = await response.json();
819
+ if (response.ok && data.success) {
820
+ console.log('โœ… Email verification requested successfully');
1202
821
  return {
1203
822
  success: true,
1204
- message: result.message || 'Verification code sent to your email'
823
+ message: data.message || 'Verification code sent to your email'
1205
824
  };
1206
825
  } else {
826
+ console.error('โŒ Email verification request failed:', data.error);
1207
827
  return {
1208
828
  success: false,
1209
- error: result.message || 'Failed to send verification code'
829
+ error: data.error || 'Failed to send verification code'
1210
830
  };
1211
831
  }
1212
832
  } catch (error) {
1213
833
  console.error('โŒ Error requesting email verification:', error);
1214
834
  return {
1215
835
  success: false,
1216
- error: 'Network error. Please check your connection and try again.'
836
+ error: error instanceof Error ? error.message : 'Network error'
1217
837
  };
1218
838
  }
1219
839
  };
1220
840
 
1221
- /**
1222
- * Verify email code
841
+ /**
842
+ * Verify email code and store JWT token
843
+ * @param email Email address
844
+ * @param code Verification code
845
+ * @param testMode Whether to use test mode
846
+ * @returns Promise with verification result and JWT token
1223
847
  */
1224
848
  exports.requestEmailVerification = requestEmailVerification;
1225
849
  const verifyEmailCode = async (email, code, testMode = false) => {
1226
850
  try {
1227
851
  console.log('๐Ÿ” Verifying email code for:', email);
1228
- const response = await fetch(`${_api.API_CONFIG.BASE_URL}/email/verification`, {
852
+ const response = await (0, _apiKeyService.makeDeveloperRequest)('/email/verification', {
1229
853
  method: 'POST',
1230
- headers: (0, _api.getApiHeaders)(),
1231
854
  body: JSON.stringify({
1232
855
  email,
1233
- code,
1234
856
  action: 'verify',
857
+ code,
1235
858
  testMode
1236
859
  })
1237
860
  });
1238
- const result = await response.json();
1239
- if (response.ok) {
861
+ const data = await response.json();
862
+ if (response.ok && data.success) {
863
+ console.log('โœ… Email verification successful');
864
+
865
+ // Store JWT token if received
866
+ if (data.token || data.jwtToken) {
867
+ const jwtToken = data.token || data.jwtToken;
868
+ await (0, _apiKeyService.storeJWT)(jwtToken);
869
+ console.log('๐ŸŽซ JWT token stored successfully');
870
+ }
1240
871
  return {
1241
872
  success: true,
1242
- message: result.message || 'Email verified successfully',
1243
- existingUser: result.existingUser || false,
1244
- token: result.token
873
+ message: data.message || 'Email verified successfully',
874
+ existingUser: data.existingUser || false,
875
+ token: data.token || data.jwtToken
1245
876
  };
1246
877
  } else {
878
+ console.error('โŒ Email verification failed:', data.error);
1247
879
  return {
1248
880
  success: false,
1249
- error: result.message || 'Invalid verification code'
881
+ error: data.error || 'Invalid verification code'
1250
882
  };
1251
883
  }
1252
884
  } catch (error) {
1253
885
  console.error('โŒ Error verifying email code:', error);
1254
886
  return {
1255
887
  success: false,
1256
- error: 'Network error. Please check your connection and try again.'
888
+ error: error instanceof Error ? error.message : 'Network error'
1257
889
  };
1258
890
  }
1259
891
  };
1260
892
 
1261
- /**
1262
- * Check email verification status
893
+ /**
894
+ * Check email verification status
895
+ * @param email Email address
896
+ * @param testMode Whether to use test mode
897
+ * @returns Promise with status result
1263
898
  */
1264
899
  exports.verifyEmailCode = verifyEmailCode;
1265
900
  const checkEmailVerificationStatus = async (email, testMode = false) => {
1266
901
  try {
1267
- const response = await fetch(`${_api.API_CONFIG.BASE_URL}/email/verification/status`, {
902
+ console.log('๐Ÿ” Checking email verification status for:', email);
903
+ const response = await (0, _apiKeyService.makeDeveloperRequest)('/email/verification/status', {
1268
904
  method: 'POST',
1269
- headers: (0, _api.getApiHeaders)(),
1270
905
  body: JSON.stringify({
1271
906
  email,
1272
907
  testMode
1273
908
  })
1274
909
  });
1275
- const result = await response.json();
1276
- return {
1277
- success: response.ok,
1278
- isPending: result.isPending || false,
1279
- message: result.message
1280
- };
910
+ const data = await response.json();
911
+ if (response.ok && data.success) {
912
+ return {
913
+ success: true,
914
+ isPending: data.isPending || false
915
+ };
916
+ } else {
917
+ return {
918
+ success: false,
919
+ error: data.error || 'Failed to check verification status'
920
+ };
921
+ }
1281
922
  } catch (error) {
1282
923
  console.error('โŒ Error checking email verification status:', error);
1283
924
  return {
1284
925
  success: false,
1285
- isPending: false,
1286
- error: 'Network error'
926
+ error: error instanceof Error ? error.message : 'Network error'
1287
927
  };
1288
928
  }
1289
929
  };
1290
930
 
1291
- /**
1292
- * Initialize platform auth service
931
+ /**
932
+ * Disconnect a platform (uses developer API key)
933
+ * @param platform Platform to disconnect
934
+ * @param username Username associated with the platform
935
+ * @returns Promise with disconnect result
1293
936
  */
1294
937
  exports.checkEmailVerificationStatus = checkEmailVerificationStatus;
1295
- const initializePlatformAuthService = () => {
1296
- console.log('๐Ÿ”ง Platform auth service initialized');
1297
- // Initialize Google Sign-In
1298
- initializeGoogleSignIn();
938
+ const disconnectPlatform = async (platform, username) => {
939
+ try {
940
+ console.log('๐Ÿ”Œ Disconnecting platform:', platform, 'for user:', username);
941
+
942
+ // Make authenticated API call to disconnect platform
943
+ const response = await (0, _apiKeyService.makeDeveloperRequest)('/revoke', {
944
+ method: 'POST',
945
+ body: JSON.stringify({
946
+ platform,
947
+ username
948
+ })
949
+ });
950
+ const data = await response.json();
951
+ if (response.ok && data.success) {
952
+ console.log(`โœ… ${platform} disconnected successfully`);
953
+ return {
954
+ success: true
955
+ };
956
+ } else {
957
+ console.error(`โŒ Failed to disconnect ${platform}:`, data.error);
958
+ return {
959
+ success: false,
960
+ error: data.error || 'Failed to disconnect platform'
961
+ };
962
+ }
963
+ } catch (error) {
964
+ console.error(`โŒ Error disconnecting ${platform}:`, error);
965
+ return {
966
+ success: false,
967
+ error: error instanceof Error ? error.message : 'Network error'
968
+ };
969
+ }
1299
970
  };
1300
- exports.initializePlatformAuthService = initializePlatformAuthService;
971
+
972
+ /**
973
+ * Store PIN for user (uses JWT authentication and extracts username from JWT)
974
+ * @param pin User PIN
975
+ * @param username Optional username (if not provided, extracts from JWT)
976
+ * @returns Promise with result
977
+ */
978
+ exports.disconnectPlatform = disconnectPlatform;
979
+ const storePIN = async (pin, username) => {
980
+ try {
981
+ // Extract username from JWT if not provided
982
+ const userToStore = username || (0, _apiKeyService.extractUsernameFromJWT)();
983
+ if (!userToStore) {
984
+ console.error('โŒ No username available - either provide username or ensure JWT token is valid');
985
+ return {
986
+ success: false,
987
+ error: 'No username available for PIN storage'
988
+ };
989
+ }
990
+ console.log('๐Ÿ” Storing PIN for user:', userToStore);
991
+
992
+ // Make authenticated request to store PIN (using developer API key for now)
993
+ const response = await (0, _apiKeyService.makeDeveloperRequest)('/store-pin/web', {
994
+ method: 'POST',
995
+ headers: {
996
+ 'Content-Type': 'application/json'
997
+ },
998
+ body: JSON.stringify({
999
+ username: userToStore,
1000
+ pin
1001
+ })
1002
+ });
1003
+ const data = await response.json();
1004
+ if (response.ok && data.success) {
1005
+ console.log('โœ… PIN stored successfully for user:', userToStore);
1006
+ return {
1007
+ success: true
1008
+ };
1009
+ } else {
1010
+ console.error('โŒ Failed to store PIN:', data.error);
1011
+ return {
1012
+ success: false,
1013
+ error: data.error || 'Failed to store PIN'
1014
+ };
1015
+ }
1016
+ } catch (error) {
1017
+ console.error('โŒ Error storing PIN:', error);
1018
+ return {
1019
+ success: false,
1020
+ error: error instanceof Error ? error.message : 'Network error'
1021
+ };
1022
+ }
1023
+ };
1024
+
1025
+ /**
1026
+ * ๐ŸŽซ GET STORED JWT TOKEN
1027
+ * Helper function to retrieve stored JWT token from email verification or other sources
1028
+ */
1029
+ exports.storePIN = storePIN;
1030
+ const getStoredJwtToken = async () => {
1031
+ try {
1032
+ console.log('๐ŸŽซ Retrieving stored JWT token...');
1033
+
1034
+ // Try different storage keys in order of preference
1035
+ const tokenSources = ['email_verification_token', 'onairos_jwt_token', 'enoch_token', 'auth_token'];
1036
+ for (const source of tokenSources) {
1037
+ const token = await _asyncStorage.default.getItem(source);
1038
+ if (token && token.length > 20) {
1039
+ console.log(`โœ… JWT token found in ${source}:`, token.substring(0, 20) + '...');
1040
+ return token;
1041
+ }
1042
+ }
1043
+ console.warn('โš ๏ธ No JWT token found in storage');
1044
+ return null;
1045
+ } catch (error) {
1046
+ console.error('โŒ Error retrieving JWT token:', error);
1047
+ return null;
1048
+ }
1049
+ };
1050
+
1051
+ /**
1052
+ * ๐ŸŽซ CLEAR STORED TOKENS
1053
+ * Helper function to clear all stored tokens (useful for logout)
1054
+ */
1055
+ exports.getStoredJwtToken = getStoredJwtToken;
1056
+ const clearStoredTokens = async () => {
1057
+ try {
1058
+ console.log('๐Ÿงน Clearing all stored tokens...');
1059
+ const tokenKeys = ['email_verification_token', 'onairos_jwt_token', 'enoch_token', 'auth_token', 'email_verification_email', 'email_verification_request_id', 'email_verification_request_email', 'token_timestamp', 'user_pin_stored', 'pin_storage_timestamp'];
1060
+ await Promise.all(tokenKeys.map(key => _asyncStorage.default.removeItem(key)));
1061
+ console.log('โœ… All tokens cleared successfully');
1062
+ } catch (error) {
1063
+ console.error('โŒ Error clearing tokens:', error);
1064
+ }
1065
+ };
1066
+ exports.clearStoredTokens = clearStoredTokens;
1301
1067
  //# sourceMappingURL=platformAuthService.js.map