@onairos/react-native 3.1.17 โ†’ 3.2.0

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