@onairos/react-native 3.7.1 → 3.7.3

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 (241) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/assets/icons/spotify.png +0 -0
  3. package/lib/commonjs/assets/images/spotify.png +0 -0
  4. package/lib/commonjs/components/BodyText.js +27 -9
  5. package/lib/commonjs/components/BrandMark.js +111 -10
  6. package/lib/commonjs/components/CodeInput.js +116 -9
  7. package/lib/commonjs/components/EmailInput.js +30 -8
  8. package/lib/commonjs/components/GoogleButton.js +56 -9
  9. package/lib/commonjs/components/HeadingGroup.js +43 -9
  10. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  11. package/lib/commonjs/components/ModalHeader.js +99 -9
  12. package/lib/commonjs/components/ModalSheet.js +47 -9
  13. package/lib/commonjs/components/Onairos.js +380 -14
  14. package/lib/commonjs/components/OnairosButton.js +313 -13
  15. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  16. package/lib/commonjs/components/Overlay.js +465 -13
  17. package/lib/commonjs/components/PersonaImage.js +137 -10
  18. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  19. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  20. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  21. package/lib/commonjs/components/PinInput.js +464 -9
  22. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  23. package/lib/commonjs/components/PlatformList.js +137 -10
  24. package/lib/commonjs/components/PlatformToggle.js +180 -9
  25. package/lib/commonjs/components/PrimaryButton.js +180 -10
  26. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  27. package/lib/commonjs/components/SignInStep.js +345 -12
  28. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  29. package/lib/commonjs/components/VerificationStep.js +176 -11
  30. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  31. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  32. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  33. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  34. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  35. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  36. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  37. package/lib/commonjs/components/icons/EnochE.js +41 -8
  38. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  39. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  40. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  41. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  42. package/lib/commonjs/components/icons/index.js +84 -17
  43. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  44. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  45. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  46. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  47. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  48. package/lib/commonjs/config/api.js +56 -7
  49. package/lib/commonjs/constants/index.js +120 -7
  50. package/lib/commonjs/context/AuthContext.js +345 -10
  51. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  52. package/lib/commonjs/hooks/useConnections.js +102 -8
  53. package/lib/commonjs/hooks/useCredentials.js +178 -10
  54. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  55. package/lib/commonjs/index.js +439 -34
  56. package/lib/commonjs/services/apiClient.js +298 -8
  57. package/lib/commonjs/services/biometricPinService.js +180 -8
  58. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  59. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  60. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  61. package/lib/commonjs/services/claudeConversationService.js +158 -9
  62. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  63. package/lib/commonjs/services/googleAuthService.js +252 -11
  64. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  65. package/lib/commonjs/services/hingeDataService.js +150 -9
  66. package/lib/commonjs/services/imageCompressionService.js +260 -7
  67. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  68. package/lib/commonjs/services/instagramDataService.js +163 -9
  69. package/lib/commonjs/services/jwtStorageService.js +276 -7
  70. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  71. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  72. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  73. package/lib/commonjs/services/llmDataStorage.js +294 -8
  74. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  75. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  76. package/lib/commonjs/services/netflixDataService.js +198 -9
  77. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  78. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  79. package/lib/commonjs/services/platformAuthService.js +1484 -12
  80. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  81. package/lib/commonjs/services/sephoraDataService.js +200 -9
  82. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  83. package/lib/commonjs/services/spotifyDataService.js +241 -9
  84. package/lib/commonjs/services/storageService.js +404 -8
  85. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  86. package/lib/commonjs/services/telegramDataService.js +499 -9
  87. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  88. package/lib/commonjs/services/userConnectionsService.js +340 -10
  89. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  90. package/lib/commonjs/theme/index.js +250 -7
  91. package/lib/commonjs/types/ambient.d.js +2 -1
  92. package/lib/commonjs/types/declarations.d.js +2 -1
  93. package/lib/commonjs/types/index.js +6 -1
  94. package/lib/commonjs/types/node-fix.d.js +2 -1
  95. package/lib/commonjs/types/node-override.d.js +2 -1
  96. package/lib/commonjs/types/opacity.d.js +2 -1
  97. package/lib/commonjs/types.js +14 -1
  98. package/lib/commonjs/utils/Portal.js +98 -8
  99. package/lib/commonjs/utils/api.js +130 -9
  100. package/lib/commonjs/utils/assetRegistry.js +210 -35
  101. package/lib/commonjs/utils/auth.js +112 -9
  102. package/lib/commonjs/utils/connectorTests.js +613 -29
  103. package/lib/commonjs/utils/crypto.js +62 -8
  104. package/lib/commonjs/utils/debugHelper.js +64 -1
  105. package/lib/commonjs/utils/encryption.js +76 -7
  106. package/lib/commonjs/utils/eventUtils.js +288 -1
  107. package/lib/commonjs/utils/haptics.js +66 -9
  108. package/lib/commonjs/utils/imagePreloader.js +6 -1
  109. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  110. package/lib/commonjs/utils/onairosApi.js +350 -9
  111. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  112. package/lib/commonjs/utils/retryHelper.js +220 -1
  113. package/lib/commonjs/utils/secureStorage.js +349 -10
  114. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  115. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  116. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  117. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  118. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  119. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  120. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  121. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  122. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  123. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  124. package/lib/module/api/index.js +211 -1
  125. package/lib/module/assets/icons/spotify.png +0 -0
  126. package/lib/module/assets/images/spotify.png +0 -0
  127. package/lib/module/components/BodyText.js +20 -1
  128. package/lib/module/components/BrandMark.js +104 -1
  129. package/lib/module/components/CodeInput.js +109 -1
  130. package/lib/module/components/EmailInput.js +23 -1
  131. package/lib/module/components/GoogleButton.js +49 -1
  132. package/lib/module/components/HeadingGroup.js +36 -1
  133. package/lib/module/components/LLMDataInputModal.js +656 -7
  134. package/lib/module/components/ModalHeader.js +92 -1
  135. package/lib/module/components/ModalSheet.js +39 -1
  136. package/lib/module/components/Onairos.js +373 -1
  137. package/lib/module/components/OnairosButton.js +305 -1
  138. package/lib/module/components/OnairosSignInButton.js +121 -1
  139. package/lib/module/components/Overlay.js +456 -1
  140. package/lib/module/components/PersonaImage.js +129 -1
  141. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  142. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  143. package/lib/module/components/PinCreationScreen.js +396 -1
  144. package/lib/module/components/PinInput.js +456 -1
  145. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  146. package/lib/module/components/PlatformList.js +129 -1
  147. package/lib/module/components/PlatformToggle.js +173 -1
  148. package/lib/module/components/PrimaryButton.js +172 -1
  149. package/lib/module/components/SignInMatchAnimation.js +189 -1
  150. package/lib/module/components/SignInStep.js +338 -1
  151. package/lib/module/components/UniversalOnboarding.js +2770 -1
  152. package/lib/module/components/VerificationStep.js +168 -1
  153. package/lib/module/components/WelcomeScreen.js +453 -1
  154. package/lib/module/components/icons/Basicproficon.js +30 -1
  155. package/lib/module/components/icons/Basicprofile.js +14 -1
  156. package/lib/module/components/icons/Checkbox.js +14 -1
  157. package/lib/module/components/icons/Checkmark.js +20 -1
  158. package/lib/module/components/icons/Contentanalysis.js +14 -1
  159. package/lib/module/components/icons/Contenticon.js +32 -1
  160. package/lib/module/components/icons/EnochE.js +34 -1
  161. package/lib/module/components/icons/Personalityicon.js +23 -1
  162. package/lib/module/components/icons/Personalityprofile.js +14 -1
  163. package/lib/module/components/icons/Personalitytraits.js +14 -1
  164. package/lib/module/components/icons/Userpreferences.js +14 -1
  165. package/lib/module/components/icons/index.js +13 -1
  166. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  167. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  168. package/lib/module/components/onboarding/PinInput.js +274 -1
  169. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  170. package/lib/module/config/PLATFORM_APIS.md +849 -0
  171. package/lib/module/config/api.js +47 -1
  172. package/lib/module/constants/index.js +114 -1
  173. package/lib/module/context/AuthContext.js +335 -1
  174. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  175. package/lib/module/hooks/useConnections.js +95 -1
  176. package/lib/module/hooks/useCredentials.js +171 -6
  177. package/lib/module/hooks/useUserConnections.js +140 -1
  178. package/lib/module/index.js +172 -1
  179. package/lib/module/services/apiClient.js +295 -1
  180. package/lib/module/services/biometricPinService.js +169 -1
  181. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  182. package/lib/module/services/chatGPTConversationService.js +268 -1
  183. package/lib/module/services/claudeConversationExtractor.js +97 -1
  184. package/lib/module/services/claudeConversationService.js +151 -1
  185. package/lib/module/services/connectedAccountsService.js +293 -1
  186. package/lib/module/services/googleAuthService.js +241 -1
  187. package/lib/module/services/hingeDataExtractor.js +99 -1
  188. package/lib/module/services/hingeDataService.js +143 -1
  189. package/lib/module/services/imageCompressionService.js +250 -1
  190. package/lib/module/services/instagramDataExtractor.js +120 -1
  191. package/lib/module/services/instagramDataService.js +156 -1
  192. package/lib/module/services/jwtStorageService.js +257 -1
  193. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  194. package/lib/module/services/linkedinProfileService.js +210 -1
  195. package/lib/module/services/linkedinScrapingService.js +219 -1
  196. package/lib/module/services/llmDataStorage.js +277 -1
  197. package/lib/module/services/mobileTrainingService.js +173 -1
  198. package/lib/module/services/netflixDataExtractor.js +114 -1
  199. package/lib/module/services/netflixDataService.js +191 -1
  200. package/lib/module/services/pinEncryptionService.js +74 -6
  201. package/lib/module/services/pinStorageUtils.js +93 -1
  202. package/lib/module/services/platformAuthService.js +1461 -1
  203. package/lib/module/services/sephoraDataExtractor.js +134 -1
  204. package/lib/module/services/sephoraDataService.js +193 -1
  205. package/lib/module/services/spotifyDataExtractor.js +142 -1
  206. package/lib/module/services/spotifyDataService.js +234 -1
  207. package/lib/module/services/storageService.js +383 -1
  208. package/lib/module/services/telegramDataExtractor.js +109 -1
  209. package/lib/module/services/telegramDataService.js +493 -1
  210. package/lib/module/services/trainingApiHelpers.js +67 -1
  211. package/lib/module/services/userConnectionsService.js +329 -1
  212. package/lib/module/services/youtubeMigrationService.js +405 -1
  213. package/lib/module/theme/index.js +245 -1
  214. package/lib/module/types.js +10 -1
  215. package/lib/module/utils/Portal.js +90 -1
  216. package/lib/module/utils/api.js +118 -1
  217. package/lib/module/utils/assetRegistry.js +200 -34
  218. package/lib/module/utils/auth.js +100 -1
  219. package/lib/module/utils/connectorTests.js +600 -27
  220. package/lib/module/utils/crypto.js +54 -1
  221. package/lib/module/utils/debugHelper.js +54 -1
  222. package/lib/module/utils/encryption.js +67 -1
  223. package/lib/module/utils/eventUtils.js +270 -1
  224. package/lib/module/utils/haptics.js +59 -8
  225. package/lib/module/utils/imagePreloader.js +3 -1
  226. package/lib/module/utils/networkDiagnostics.js +217 -1
  227. package/lib/module/utils/onairosApi.js +333 -1
  228. package/lib/module/utils/programmaticFlow.js +111 -1
  229. package/lib/module/utils/retryHelper.js +211 -1
  230. package/lib/module/utils/secureStorage.js +330 -6
  231. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  232. package/lib/module/utils/webviewScripts/claude.js +370 -1
  233. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  234. package/lib/module/utils/webviewScripts/index.js +434 -1
  235. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  236. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  237. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  238. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  239. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  240. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  241. package/package.json +2 -2
@@ -1 +1,47 @@
1
- import{getAuthToken}from'../services/authService';function _0x5576(_0x435640,_0x5576d8){_0x435640=_0x435640-0x0;const _0x5153e8=_0x4356();let _0x122d19=_0x5153e8[_0x435640];return _0x122d19;}export const API_CONFIG={'BASE_URL':'https://api2.onairos.uk','ENDPOINTS':{'AUTH':_0x5576(0x0),'USER':_0x5576(0x1),'CONNECTIONS':_0x5576(0x2),'TRAINING':_0x5576(0x3),'OAUTH':_0x5576(0x4)},'TIMEOUT':0x7530};export const getApiHeaders=()=>({'Content-Type':'application/json','Accept':'application/json'});export const getAuthHeaders=_0x3fd3b7=>({...getApiHeaders(),..._0x3fd3b7&&{'Authorization':'Bearer\x20'+_0x3fd3b7}});function _0x4356(){const _0x53d2bc=['/auth','/user','/connections','/training','/oauth','User\x20not\x20authenticated\x20-\x20no\x20JWT\x20token\x20found','QqbIE','Bearer\x20'];_0x4356=function(){return _0x53d2bc;};return _0x4356();}export const getUserAuthHeaders=async()=>{const _0x44e5ed={'QqbIE':_0x5576(0x5)},_0x3f5be6=await getAuthToken();if(!_0x3f5be6)throw new Error(_0x44e5ed[_0x5576(0x6)]);return{...getApiHeaders(),'Authorization':_0x5576(0x7)+_0x3f5be6};};
1
+ /**
2
+ * API Configuration for Onairos SDK
3
+ *
4
+ * IMPORTANT: This is the single source of truth for the API base URL.
5
+ * All files should import API_CONFIG.BASE_URL instead of hardcoding URLs.
6
+ */
7
+
8
+ import { getAuthToken } from '../services/authService';
9
+ export const API_CONFIG = {
10
+ BASE_URL: 'https://api2.onairos.uk',
11
+ ENDPOINTS: {
12
+ AUTH: '/auth',
13
+ USER: '/user',
14
+ CONNECTIONS: '/connections',
15
+ TRAINING: '/training',
16
+ OAUTH: '/oauth'
17
+ },
18
+ TIMEOUT: 30000
19
+ };
20
+ export const getApiHeaders = () => ({
21
+ 'Content-Type': 'application/json',
22
+ 'Accept': 'application/json'
23
+ });
24
+ export const getAuthHeaders = token => ({
25
+ ...getApiHeaders(),
26
+ ...(token && {
27
+ 'Authorization': `Bearer ${token}`
28
+ })
29
+ });
30
+
31
+ /**
32
+ * Get headers with User JWT for authenticated requests
33
+ * Use this for all post-login API calls (platform connects, etc.)
34
+ *
35
+ * TIER 2 Authentication: User must be logged in
36
+ */
37
+ export const getUserAuthHeaders = async () => {
38
+ const token = await getAuthToken();
39
+ if (!token) {
40
+ throw new Error('User not authenticated - no JWT token found');
41
+ }
42
+ return {
43
+ ...getApiHeaders(),
44
+ 'Authorization': `Bearer ${token}`
45
+ };
46
+ };
47
+ //# sourceMappingURL=api.js.map
@@ -1 +1,114 @@
1
- import{API_CONFIG}from'../config/api';export const COLORS={'primary':_0x13f1(0x0),'headerBg':_0x13f1(0x1),'text':{'primary':_0x13f1(0x2),'secondary':'#666666'},'border':_0x13f1(0x3),'success':_0x13f1(0x4),'error':'#FF3B30','instagram':_0x13f1(0x5),'pinterest':_0x13f1(0x6),'reddit':_0x13f1(0x7),'youtube':_0x13f1(0x8),'chatgpt':_0x13f1(0x9),'llm':'#10A37F','netflix':'#E50914','spotify':_0x13f1(0xa),'white':_0x13f1(0xb),'black':'#000000','gray':_0x13f1(0xc),'lightGray':_0x13f1(0x3)};function _0x1700(){const _0x2bcbae=['#1BA9D4','#F8F9FA','#000000','#E5E5E5','#34C759','#E1306C','#E60023','#FF4500','#FF0000','#10A37F','#1DB954','#FFFFFF','#666666','Instagram','instagram','Connect\x20your\x20Instagram\x20account\x20to\x20train\x20your\x20AI\x20model','Pinterest','pinterest','Use\x20your\x20Pinterest\x20boards\x20for\x20AI\x20training','Reddit','reddit','Connect\x20Reddit\x20to\x20enhance\x20your\x20AI\x20model','YouTube','youtube','ChatGPT','chat','chatgpt','Connect\x20your\x20ChatGPT\x20conversations\x20for\x20AI\x20insights','llm','Connect\x20your\x20AI\x20conversation\x20data','Netflix','netflix','Spotify','spotify','Connect\x20your\x20Spotify\x20listening\x20data\x20for\x20music\x20preferences','BASE_URL','/instagram/auth','/youtube/auth','/chatgpt/auth','/instagram/callback','/reddit/callback','/youtube/callback','/chatgpt/callback','/llmdata','/llmdata/request','onairos_credentials','onairosanime','authenticate','onairosanime://auth/'];_0x1700=function(){return _0x2bcbae;};return _0x1700();}export const PLATFORMS={'instagram':{'name':_0x13f1(0xd),'icon':_0x13f1(0xe),'color':COLORS[_0x13f1(0xe)],'description':_0x13f1(0xf)},'pinterest':{'name':_0x13f1(0x10),'icon':_0x13f1(0x11),'color':COLORS['pinterest'],'description':_0x13f1(0x12)},'reddit':{'name':_0x13f1(0x13),'icon':_0x13f1(0x14),'color':COLORS[_0x13f1(0x14)],'description':_0x13f1(0x15)},'youtube':{'name':_0x13f1(0x16),'icon':_0x13f1(0x17),'color':COLORS[_0x13f1(0x17)],'description':'Use\x20YouTube\x20data\x20to\x20improve\x20AI\x20recommendations'},'chatgpt':{'name':_0x13f1(0x18),'icon':_0x13f1(0x19),'color':COLORS[_0x13f1(0x1a)],'description':_0x13f1(0x1b)},'llm':{'name':'LLM\x20Data','icon':'psychology','color':COLORS[_0x13f1(0x1c)],'description':_0x13f1(0x1d)},'netflix':{'name':_0x13f1(0x1e),'icon':_0x13f1(0x1f),'color':COLORS['netflix'],'description':'Connect\x20your\x20Netflix\x20viewing\x20history\x20for\x20personalized\x20insights'},'spotify':{'name':_0x13f1(0x20),'icon':'spotify','color':COLORS[_0x13f1(0x21)],'description':_0x13f1(0x22)}};function _0x13f1(_0x17009b,_0x13f16b){_0x17009b=_0x17009b-0x0;const _0x2dcfc3=_0x1700();let _0x2d60b0=_0x2dcfc3[_0x17009b];return _0x2d60b0;}export const API_ENDPOINTS={'base':API_CONFIG[_0x13f1(0x23)],'oauth':{'instagram':_0x13f1(0x24),'pinterest':'/pinterest/auth','reddit':'/reddit/auth','youtube':_0x13f1(0x25),'chatgpt':_0x13f1(0x26),'llm':'/chatgpt/auth'},'callback':{'instagram':_0x13f1(0x27),'pinterest':'/pinterest/callback','reddit':_0x13f1(0x28),'youtube':_0x13f1(0x29),'chatgpt':_0x13f1(0x2a),'llm':'/chatgpt/callback'},'llm':{'dataIngest':_0x13f1(0x2b),'dataRequest':_0x13f1(0x2c)}};export const STORAGE_KEYS={'credentials':_0x13f1(0x2d),'connections':'onairos_connections'};export const PIN_REQUIREMENTS={'minLength':0x8,'requireUppercase':!![],'requireLowercase':!![],'requireNumber':!![],'requireSpecialChar':!![]};export const DEEP_LINK_CONFIG={'scheme':_0x13f1(0x2e),'host':_0x13f1(0x2f),'redirectUri':_0x13f1(0x30)};
1
+ import { API_CONFIG } from '../config/api';
2
+ export const COLORS = {
3
+ primary: '#1BA9D4',
4
+ headerBg: '#F8F9FA',
5
+ text: {
6
+ primary: '#000000',
7
+ secondary: '#666666'
8
+ },
9
+ border: '#E5E5E5',
10
+ success: '#34C759',
11
+ error: '#FF3B30',
12
+ instagram: '#E1306C',
13
+ pinterest: '#E60023',
14
+ reddit: '#FF4500',
15
+ youtube: '#FF0000',
16
+ chatgpt: '#10A37F',
17
+ llm: '#10A37F',
18
+ netflix: '#E50914',
19
+ spotify: '#1DB954',
20
+ white: '#FFFFFF',
21
+ black: '#000000',
22
+ gray: '#666666',
23
+ lightGray: '#E5E5E5'
24
+ };
25
+ export const PLATFORMS = {
26
+ instagram: {
27
+ name: 'Instagram',
28
+ icon: 'instagram',
29
+ color: COLORS.instagram,
30
+ description: 'Connect your Instagram account to train your AI model'
31
+ },
32
+ pinterest: {
33
+ name: 'Pinterest',
34
+ icon: 'pinterest',
35
+ color: COLORS.pinterest,
36
+ description: 'Use your Pinterest boards for AI training'
37
+ },
38
+ reddit: {
39
+ name: 'Reddit',
40
+ icon: 'reddit',
41
+ color: COLORS.reddit,
42
+ description: 'Connect Reddit to enhance your AI model'
43
+ },
44
+ youtube: {
45
+ name: 'YouTube',
46
+ icon: 'youtube',
47
+ color: COLORS.youtube,
48
+ description: 'Use YouTube data to improve AI recommendations'
49
+ },
50
+ chatgpt: {
51
+ name: 'ChatGPT',
52
+ icon: 'chat',
53
+ color: COLORS.chatgpt,
54
+ description: 'Connect your ChatGPT conversations for AI insights'
55
+ },
56
+ llm: {
57
+ name: 'LLM Data',
58
+ icon: 'psychology',
59
+ color: COLORS.llm,
60
+ description: 'Connect your AI conversation data'
61
+ },
62
+ netflix: {
63
+ name: 'Netflix',
64
+ icon: 'netflix',
65
+ color: COLORS.netflix,
66
+ description: 'Connect your Netflix viewing history for personalized insights'
67
+ },
68
+ spotify: {
69
+ name: 'Spotify',
70
+ icon: 'spotify',
71
+ color: COLORS.spotify,
72
+ description: 'Connect your Spotify listening data for music preferences'
73
+ }
74
+ };
75
+ export const API_ENDPOINTS = {
76
+ base: API_CONFIG.BASE_URL,
77
+ oauth: {
78
+ instagram: '/instagram/auth',
79
+ pinterest: '/pinterest/auth',
80
+ reddit: '/reddit/auth',
81
+ youtube: '/youtube/auth',
82
+ chatgpt: '/chatgpt/auth',
83
+ llm: '/chatgpt/auth'
84
+ },
85
+ callback: {
86
+ instagram: '/instagram/callback',
87
+ pinterest: '/pinterest/callback',
88
+ reddit: '/reddit/callback',
89
+ youtube: '/youtube/callback',
90
+ chatgpt: '/chatgpt/callback',
91
+ llm: '/chatgpt/callback'
92
+ },
93
+ llm: {
94
+ dataIngest: '/llmdata',
95
+ dataRequest: '/llmdata/request'
96
+ }
97
+ };
98
+ export const STORAGE_KEYS = {
99
+ credentials: 'onairos_credentials',
100
+ connections: 'onairos_connections'
101
+ };
102
+ export const PIN_REQUIREMENTS = {
103
+ minLength: 8,
104
+ requireUppercase: true,
105
+ requireLowercase: true,
106
+ requireNumber: true,
107
+ requireSpecialChar: true
108
+ };
109
+ export const DEEP_LINK_CONFIG = {
110
+ scheme: 'onairosanime',
111
+ host: 'authenticate',
112
+ redirectUri: 'onairosanime://auth/'
113
+ };
114
+ //# sourceMappingURL=index.js.map
@@ -1 +1,335 @@
1
- import React,{createContext,useState,useEffect,useContext}from'react';function _0x4fad(){const _0x965542=['useAuth\x20must\x20be\x20used\x20within\x20an\x20AuthProvider','🎯\x20Found\x20event\x20access\x20token\x20-\x20user\x20has\x20completed\x20onboarding,\x20authentication\x20confirmed','aHlXt','ZRwVJ','saqvb','user','Failed\x20to\x20fetch\x20user\x20profile:','401','Akskq','aynVu','Onairos\x20User','onboardingCompleted','iCUbI','NpFkE','BtlSe','OJrtv','Sqylj','Failed\x20to\x20remove\x20user\x20data:','qdXFS','apple','onairos','User\x20logged\x20in\x20with\x20onboarded=false:','pHRJd','onairosUserId','JQrOC','lastConnectedAt','🔗\x20Stored\x20Onairos\x20connection\x20status:','hasConnectedOnairos','false','🍎\x20Apple\x20sign-in\x20completed\x20-\x20auth_method\x20set\x20to\x20\x22apple\x22','Apple\x20sign-in\x20failed:','oXRgX','qKMwH','Onairos\x20sign-in\x20failed:','auth_method','🔑\x20Onairos\x20sign-in\x20completed\x20-\x20auth_method\x20set\x20to\x20\x22onairos\x22','xTqAr','nWqmy','zVJty','wZOca','🌐\x20Network\x20verification\x20failed,\x20using\x20local\x20token\x20validation:','Failed\x20to\x20delete\x20account:','VBTiG','tFYTh','PEdnR','2|5|4|0|1|3|6','Account\x20deleted\x20successfully','nfxLp','dWZAX','xJyMM','Failed\x20to\x20load\x20authentication\x20state:','XWXiq','XwiFj','LbjkN','iVuue','qRmnS','QSPsD','jitWm','kVWfz','CNbLU','YHCeP','URyRT','YnLbk','XwjzJ','LJVee','🌐\x20Profile\x20fetch\x20failed\x20(likely\x20network),\x20keeping\x20authentication\x20state','aMWML','KCNMO','jSibX','JjnmK','OoXuH','rPGhU','MWXBM','EdDLU','fJASm','zzqEo','gVZCb','uGgnH','fGscp','pvHTU','getItem','mJJXX','log','parse','WeAdn','HVzju','GuyAQ','jCVoW','error','XRdqQ','cKFxE','iemdk','ALKTO','warn','Ysczr','PXNxI','WrCOP','stringify','KtVSH','VtSkw','dprIF','includes','PEvlN','HNlKw','peAdN','MCDCK','user@onairos.com','setItem','HjJJQ','hWwWL','wifHG','rydIq','nCmnu','sWHXC','seLiR','VkcrY','ufqmB','SIlLH','UmoVH','KKwfN','IiSkr','lkmIn','DiqWB','JqHLA','TNcyf','TsrAz','vsTYJ','email','name','eNnXs','ZHilh','AVHvY','JIgrY','token','JFDqB','fShBa','LOaSY','xmcEX','qSgoL','Vzgwc','ArfOp','profilePicture','mtXyv','EPSyr','oGHus','split','qRgHU','edTxG','SnQSN','aODHB','uNkfi','JzXbv','HoCNU','cGSaQ','MLtsu','Tscif','eivDi','AJiFL','mtEmH','psNlN','KdwCX','nHBKJ','pSeRF','JXiyz','pRFyN','poTqc','wEbFg','Failed\x20to\x20save\x20user\x20data:','jrvwm','yYlKG','PbwFA','cBRcG','Failed\x20to\x20update\x20onboarded\x20status:','scuTb','mfvHT','VpwjA','FZvdB','JvUrz','KVJoi','QDTFy','MGxwf','createElement','KiCnG','mlJqa'];_0x4fad=function(){return _0x965542;};return _0x4fad();}import AsyncStorage from'@react-native-async-storage/async-storage';import{saveAuthToken,getAuthToken,removeAuthToken,verifyToken,getUserProfile,authenticateWithApple,authenticateWithOnairos,updateUserOnboardedStatus}from'../services/authService';import{saveAuthState,clearUserData,getResumeTarget,markStepCompleted,updateLastScreen,isReturningUser,markEventPageReached,hasEventAccessToken}from'../services/storageService';function _0xf906(_0x4fad3a,_0xf906f){_0x4fad3a=_0x4fad3a-0x0;const _0x17cc94=_0x4fad();let _0x32c41d=_0x17cc94[_0x4fad3a];return _0x32c41d;}const AuthContext=createContext(undefined);export const AuthProvider=({children:_0x1a405f})=>{const _0x2e9af3={'XWXiq':_0xf906(0x0),'XwiFj':function(_0x418789,_0x1b2088){return _0x418789(_0x1b2088);},'LbjkN':function(_0x10ea17){return _0x10ea17();},'iVuue':function(_0x425c6c,_0x5f3345){return _0x425c6c&&_0x5f3345;},'qRmnS':_0xf906(0x1),'YHCeP':function(_0x237b2e,_0x260d43){return _0x237b2e(_0x260d43);},'QSPsD':function(_0x4aa6b2,_0x458909){return _0x4aa6b2===_0x458909;},'jitWm':_0xf906(0x2),'kVWfz':_0xf906(0x3),'LOaSY':function(_0x5cd32b,_0x59b2f4){return _0x5cd32b!==_0x59b2f4;},'CNbLU':_0xf906(0x4),'pRFyN':'💾\x20Network\x20unreachable,\x20trusting\x20local\x20authentication\x20state','SpWsq':function(_0x5c1587){return _0x5c1587();},'URyRT':_0xf906(0x5),'YnLbk':_0xf906(0x6),'XwjzJ':function(_0x246314,_0xab2c3c){return _0x246314 instanceof _0xab2c3c;},'bOuJZ':_0xf906(0x7),'LJVee':_0xf906(0x8),'aMWML':function(_0x510821,_0x2a907f){return _0x510821!==_0x2a907f;},'KCNMO':_0xf906(0x9),'jSibX':'offline_user','JjnmK':_0xf906(0xa),'OoXuH':function(_0x30bcc2,_0x1f94e2){return _0x30bcc2(_0x1f94e2);},'rPGhU':_0xf906(0xb),'MWXBM':'true','EdDLU':function(_0x4c22ce,_0x45d997){return _0x4c22ce===_0x45d997;},'fJASm':_0xf906(0xc),'zzqEo':_0xf906(0xd),'FKFBO':function(_0x6b5a61,_0x1ccd53){return _0x6b5a61!==_0x1ccd53;},'gVZCb':_0xf906(0xe),'uGgnH':_0xf906(0xf),'JzXbv':function(_0x588426,_0x6dfbf0){return _0x588426(_0x6dfbf0);},'fGscp':_0xf906(0x10),'lkmIn':'Failed\x20to\x20complete\x20onboarding:','DiqWB':_0xf906(0x11),'JqHLA':function(_0x535c0d,_0x43b546){return _0x535c0d!==_0x43b546;},'TNcyf':_0xf906(0x12),'TsrAz':_0xf906(0x13),'vsTYJ':_0xf906(0x14),'wuUvC':_0xf906(0x15),'IXxBt':'eNnXs','FCxkf':'Failed\x20to\x20save\x20user\x20data:','vtCwf':'2|1|4|3|5|0','AVHvY':function(_0x16eecf,_0x24f173){return _0x16eecf(_0x24f173);},'jrvwm':function(_0x23c7fb,_0x408930){return _0x23c7fb(_0x408930);},'JIgrY':function(_0x11b8e2,_0x355826){return _0x11b8e2(_0x355826);},'JFDqB':_0xf906(0x16),'fShBa':_0xf906(0x17),'tOVqc':'oroey','xmcEX':_0xf906(0x18),'qSgoL':_0xf906(0x19),'nmZoF':_0xf906(0x1a),'Vzgwc':_0xf906(0x1b),'ArfOp':_0xf906(0x1c),'Omtgd':_0xf906(0x1d),'mtXyv':_0xf906(0x1e),'EPSyr':_0xf906(0x1f),'leTmu':_0xf906(0x20),'aODHB':function(_0x75d6e1,_0x349ec8){return _0x75d6e1(_0x349ec8);},'Tscif':_0xf906(0x21),'uNkfi':function(_0xdeff63,_0x3a1900){return _0xdeff63(_0x3a1900);},'KzMJg':function(_0x218f30,_0x58514f){return _0x218f30(_0x58514f);},'HoCNU':_0xf906(0x22),'cGSaQ':function(_0x4ca1bf,_0x511abb){return _0x4ca1bf(_0x511abb);},'MLtsu':_0xf906(0x23),'eivDi':'MhyjC','dFIdR':_0xf906(0x24),'AJiFL':function(_0x5280cc,_0x46f8b1){return _0x5280cc(_0x46f8b1);},'psNlN':'Failed\x20to\x20update\x20user\x20data:','KdwCX':function(_0x3ddf2b,_0xdc1721){return _0x3ddf2b===_0xdc1721;},'nHBKJ':_0xf906(0x25),'JXiyz':function(_0x2f829f,_0x21f133){return _0x2f829f(_0x21f133);},'NAmKk':_0xf906(0x26),'RvljG':function(_0x1b5f3d,_0x2dceb8){return _0x1b5f3d(_0x2dceb8);},'poTqc':function(_0x11aed1,_0x110bd3){return _0x11aed1!==_0x110bd3;},'wEbFg':_0xf906(0x27),'UCtbu':'tQlEc','vFGkj':_0xf906(0x28),'MGxwf':_0xf906(0x29),'hwGac':function(_0x18bc32){return _0x18bc32();},'yYlKG':function(_0x3c01e0,_0x58c634){return _0x3c01e0(_0x58c634);},'PbwFA':function(_0x7bf88e,_0x3f4f89){return _0x7bf88e===_0x3f4f89;},'cBRcG':_0xf906(0x2a),'mfvHT':function(_0x43c388,_0x43542f){return _0x43c388!==_0x43542f;},'VpwjA':_0xf906(0x2b),'FZvdB':function(_0x52561a,_0x3ef134){return _0x52561a(_0x3ef134);},'JvUrz':function(_0x434b22,_0x1043c5){return _0x434b22===_0x1043c5;},'KVJoi':'TamvU','fmvcz':_0xf906(0x2c),'OsOvN':_0xf906(0x2d),'QDTFy':_0xf906(0x2e),'ZEkVd':function(_0x3f92af,_0x2a0776){return _0x3f92af(_0x2a0776);},'nfxLp':function(_0x5430ae,_0x4ea8f2){return _0x5430ae(_0x4ea8f2);},'dWZAX':function(_0x51a733,_0x3c7b65){return _0x51a733(_0x3c7b65);},'xJyMM':function(_0x153355,_0x5f269c,_0x3d0f77){return _0x153355(_0x5f269c,_0x3d0f77);}},[_0x458e04,_0x46de0f]=_0x2e9af3['ZEkVd'](useState,null),[_0x2f4390,_0x1e01a2]=_0x2e9af3[_0xf906(0x2f)](useState,!![]),[_0x4fdad9,_0xc82de5]=useState(![]),[_0x350936,_0x4743f6]=_0x2e9af3[_0xf906(0x30)](useState,![]);_0x2e9af3[_0xf906(0x31)](useEffect,()=>{const _0x5cfca8={'XRdqQ':'Failed\x20to\x20update\x20onboarded\x20status:','ALKTO':function(_0x449751,_0x608069){return _0x449751(_0x608069);},'wifHG':_0xf906(0x32),'SIlLH':_0x2e9af3[_0xf906(0x33)],'pvHTU':function(_0x5f3ba2,_0x2e8089){return _0x2e9af3[_0xf906(0x34)](_0x5f3ba2,_0x2e8089);},'AVqQq':function(_0x3f64d9){return _0x2e9af3[_0xf906(0x35)](_0x3f64d9);},'mJJXX':function(_0x70e9f7,_0x21d421){return _0x2e9af3[_0xf906(0x36)](_0x70e9f7,_0x21d421);},'XCAYf':_0x2e9af3[_0xf906(0x37)],'zAPgR':function(_0x26d512,_0x5d4844){return _0x2e9af3['XwiFj'](_0x26d512,_0x5d4844);},'WeAdn':function(_0x1eb382,_0x495ea1){return _0x2e9af3['XwiFj'](_0x1eb382,_0x495ea1);},'VkcrY':function(_0x38ef48,_0x518ca7){return _0x2e9af3['YHCeP'](_0x38ef48,_0x518ca7);},'HVzju':function(_0x24d32b,_0x3a265c){return _0x2e9af3[_0xf906(0x38)](_0x24d32b,_0x3a265c);},'GuyAQ':_0x2e9af3[_0xf906(0x39)],'jCVoW':_0x2e9af3[_0xf906(0x3a)],'cKFxE':function(_0x76b1a6){return _0x2e9af3[_0xf906(0x35)](_0x76b1a6);},'Bvteu':function(_0x891bf8,_0xbc5f11){return _0x2e9af3['LOaSY'](_0x891bf8,_0xbc5f11);},'iemdk':_0x2e9af3[_0xf906(0x3b)],'pBjsz':'🌐\x20Network\x20verification\x20failed,\x20using\x20local\x20token\x20validation:','Ysczr':_0x2e9af3['pRFyN'],'PXNxI':function(_0x2ca950,_0x1adc68){return _0x2e9af3[_0xf906(0x3c)](_0x2ca950,_0x1adc68);},'VAicy':function(_0x2d2766){return _0x2e9af3['SpWsq'](_0x2d2766);},'WrCOP':_0x2e9af3[_0xf906(0x3d)],'KtVSH':function(_0x2eda7b,_0x539921){return _0x2e9af3[_0xf906(0x34)](_0x2eda7b,_0x539921);},'VtSkw':_0x2e9af3[_0xf906(0x3e)],'dprIF':function(_0x259346,_0x54de9e){return _0x2e9af3[_0xf906(0x3f)](_0x259346,_0x54de9e);},'PEvlN':_0x2e9af3['bOuJZ'],'HNlKw':function(_0x32adc4,_0x23b93f){return _0x32adc4!==_0x23b93f;},'bvgzl':_0x2e9af3[_0xf906(0x40)],'THIKH':_0xf906(0x41),'peAdN':function(_0x2fb550,_0xfa1b46){return _0x2e9af3[_0xf906(0x42)](_0x2fb550,_0xfa1b46);},'TMSjf':_0x2e9af3[_0xf906(0x43)],'FjAFU':_0x2e9af3[_0xf906(0x44)],'nxBCU':_0x2e9af3[_0xf906(0x45)],'HjJJQ':function(_0x5d0cdc,_0x5da682){return _0x2e9af3[_0xf906(0x46)](_0x5d0cdc,_0x5da682);},'hWwWL':function(_0x50eb20,_0x4a7f06){return _0x2e9af3[_0xf906(0x34)](_0x50eb20,_0x4a7f06);},'rydIq':_0x2e9af3[_0xf906(0x47)],'nCmnu':_0x2e9af3[_0xf906(0x48)],'sWHXC':function(_0x5d4762,_0x12d3f4){return _0x2e9af3[_0xf906(0x49)](_0x5d4762,_0x12d3f4);},'seLiR':_0x2e9af3[_0xf906(0x4a)],'ufqmB':_0x2e9af3[_0xf906(0x4b)],'UmoVH':function(_0x1c275d,_0x8c27df){return _0x2e9af3['FKFBO'](_0x1c275d,_0x8c27df);},'VQQIm':_0x2e9af3[_0xf906(0x4c)],'KKwfN':_0x2e9af3[_0xf906(0x4d)],'IiSkr':function(_0x46ada3,_0x236954){return _0x2e9af3['JzXbv'](_0x46ada3,_0x236954);}};if(_0x2e9af3[_0xf906(0x38)](_0x2e9af3[_0xf906(0x4e)],_0xf906(0x10))){const _0x2d79a6=async()=>{const _0x1ca66b={'Besyv':function(_0x1d63e1,_0x13aafe){return _0x5cfca8[_0xf906(0x4f)](_0x1d63e1,_0x13aafe);}};try{const _0x4cdc8c=await _0x5cfca8['AVqQq'](hasEventAccessToken),_0x57426a=await AsyncStorage[_0xf906(0x50)](_0xf906(0x5));if(_0x5cfca8[_0xf906(0x51)](_0x4cdc8c,_0x57426a)){console[_0xf906(0x52)](_0x5cfca8['XCAYf']),_0x5cfca8['zAPgR'](_0x46de0f,JSON[_0xf906(0x53)](_0x57426a)),_0x5cfca8[_0xf906(0x54)](_0x4743f6,!![]),_0x5cfca8['VkcrY'](_0xc82de5,!![]),_0x5cfca8['WeAdn'](_0x1e01a2,![]);return;}const _0x38c3d4=await _0x5cfca8['AVqQq'](getAuthToken);if(_0x38c3d4){if(_0x5cfca8[_0xf906(0x55)](_0x5cfca8[_0xf906(0x56)],_0x5cfca8[_0xf906(0x57)])){_0xa22e86[_0xf906(0x58)](_0x5cfca8[_0xf906(0x59)],_0x2dbcd8);throw _0x57da4;}else{let _0x56a5c8=![];try{_0x56a5c8=await _0x5cfca8[_0xf906(0x5a)](verifyToken);}catch(_0x194694){_0x5cfca8['Bvteu'](_0x5cfca8[_0xf906(0x5b)],_0x5cfca8['iemdk'])?_0x5cfca8[_0xf906(0x5c)](_0x53c564,![]):(console[_0xf906(0x5d)](_0x5cfca8['pBjsz'],_0x194694),_0x57426a&&(console[_0xf906(0x52)](_0x5cfca8[_0xf906(0x5e)]),_0x56a5c8=!![]));}if(_0x56a5c8){if(_0x57426a)_0x46de0f(JSON[_0xf906(0x53)](_0x57426a)),_0x5cfca8[_0xf906(0x5f)](_0x4743f6,!![]);else try{const _0x16a132=await _0x5cfca8['VAicy'](getUserProfile);await AsyncStorage['setItem'](_0x5cfca8[_0xf906(0x60)],JSON[_0xf906(0x61)](_0x16a132)),_0x5cfca8[_0xf906(0x4f)](_0x46de0f,_0x16a132),_0x5cfca8[_0xf906(0x62)](_0x4743f6,!![]);}catch(_0x126152){console[_0xf906(0x58)](_0x5cfca8[_0xf906(0x63)],_0x126152);const _0x16a3d4=_0x5cfca8[_0xf906(0x64)](_0x126152,Error)?_0x126152['message']:String(_0x126152);if(_0x16a3d4[_0xf906(0x65)](_0x5cfca8[_0xf906(0x66)])||_0x16a3d4['includes']('403'))_0x5cfca8[_0xf906(0x67)](_0x5cfca8['bvgzl'],_0x5cfca8['bvgzl'])?_0x1ca66b['Besyv'](_0x8546ca,![]):await _0x5cfca8['AVqQq'](removeAuthToken);else{console['log'](_0x5cfca8['THIKH']);if(_0x38c3d4){if(_0x5cfca8[_0xf906(0x68)](_0xf906(0x69),_0x5cfca8['TMSjf'])){const _0xb2d8b1={'id':_0x5cfca8['FjAFU'],'name':_0x5cfca8['nxBCU'],'email':_0xf906(0x6a),'onboarded':![]};await AsyncStorage[_0xf906(0x6b)](_0x5cfca8['WrCOP'],JSON[_0xf906(0x61)](_0xb2d8b1)),_0x5cfca8[_0xf906(0x6c)](_0x46de0f,_0xb2d8b1),_0x5cfca8[_0xf906(0x6d)](_0x4743f6,!![]);}else _0x19dbcb['error'](_0x5cfca8[_0xf906(0x6e)],_0x49acab);}}}}else await _0x5cfca8[_0xf906(0x5a)](removeAuthToken);}}const _0x26f23e=await AsyncStorage[_0xf906(0x50)](_0x5cfca8[_0xf906(0x6f)]);_0x26f23e===_0x5cfca8[_0xf906(0x70)]&&(_0x5cfca8[_0xf906(0x71)](_0x5cfca8[_0xf906(0x72)],_0x5cfca8[_0xf906(0x72)])?_0x5cfca8[_0xf906(0x73)](_0xc82de5,!![]):_0x5cfca8['ALKTO'](_0x4afe3b,![]));}catch(_0x24082d){if(_0x5cfca8['HVzju'](_0x5cfca8[_0xf906(0x74)],_0x5cfca8[_0xf906(0x74)]))console['error'](_0xf906(0x32),_0x24082d);else{const _0x4a756e=useContext(_0x5a427d);if(_0x4a756e===_0x2b500b)throw new _0x37a826(_0x5cfca8[_0xf906(0x75)]);return _0x4a756e;}}finally{_0x5cfca8[_0xf906(0x76)](_0x5cfca8['VQQIm'],_0x5cfca8[_0xf906(0x77)])?_0x5cfca8[_0xf906(0x78)](_0x1e01a2,![]):(_0x5cfca8[_0xf906(0x5c)](_0x31bf33,_0x1e9e92['parse'](_0x2142f3)),_0x5cfca8[_0xf906(0x5c)](_0x4a957d,!![]));}};_0x2d79a6();}else throw new _0x4609d3(_0x2e9af3[_0xf906(0x33)]);},[]);const _0x11d4b4=async _0x3432c1=>{const _0x497ad0={'kVfJa':_0x2e9af3[_0xf906(0x79)],'ZHilh':_0x2e9af3[_0xf906(0x7a)]};if(_0x2e9af3[_0xf906(0x7b)]('WNMRz',_0x2e9af3[_0xf906(0x7c)]))try{var _0x2f1068;const _0xf3e6cb={..._0x3432c1,'onboarded':![]};await AsyncStorage[_0xf906(0x6b)](_0x2e9af3[_0xf906(0x3d)],JSON[_0xf906(0x61)](_0xf3e6cb)),_0x2e9af3['YHCeP'](_0x46de0f,_0xf3e6cb),_0x2e9af3[_0xf906(0x3c)](_0x4743f6,!![]),await saveAuthState({'isAuthenticated':!![],'authMethod':(_0x2f1068=_0x3432c1['email'])!==null&&_0x2f1068!==void 0x0&&_0x2f1068[_0xf906(0x65)](_0x2e9af3[_0xf906(0x7d)])?_0x2e9af3[_0xf906(0x7d)]:_0x2e9af3[_0xf906(0x7e)],'hasValidToken':!![],'userEmail':_0x3432c1[_0xf906(0x7f)],'userName':_0x3432c1[_0xf906(0x80)]}),await _0x2e9af3[_0xf906(0x46)](markStepCompleted,'authentication'),console['log'](_0x2e9af3['wuUvC'],_0xf3e6cb);}catch(_0x276e3d){if(_0x2e9af3[_0xf906(0x42)](_0xf906(0x81),_0x2e9af3['IXxBt'])){_0x145337['error'](_0x497ad0['kVfJa'],_0x1fec21);throw _0x2f7f8f;}else console[_0xf906(0x58)](_0x2e9af3['FCxkf'],_0x276e3d);}else _0x4c6980[_0xf906(0x58)](_0x497ad0[_0xf906(0x82)],_0x2a10d8);},_0x7018c5=async _0x219dbb=>{const _0x3bf1d3={'oGHus':_0x2e9af3['vtCwf'],'qRgHU':function(_0x41d742,_0x1adb96){return _0x2e9af3[_0xf906(0x46)](_0x41d742,_0x1adb96);},'UlSba':_0x2e9af3[_0xf906(0x37)],'edTxG':function(_0x4771eb,_0x4cd882){return _0x2e9af3['JzXbv'](_0x4771eb,_0x4cd882);},'SnQSN':function(_0x3ae768,_0x40da81){return _0x2e9af3[_0xf906(0x83)](_0x3ae768,_0x40da81);}};try{_0x2e9af3['jrvwm'](_0x1e01a2,!![]);const _0x11073e=await _0x2e9af3[_0xf906(0x84)](authenticateWithApple,_0x219dbb);await saveAuthToken(_0x11073e[_0xf906(0x85)]),await AsyncStorage[_0xf906(0x6b)](_0xf906(0x22),_0x2e9af3[_0xf906(0x7d)]);_0x11073e[_0xf906(0x14)]?_0x2e9af3[_0xf906(0x38)](_0x2e9af3[_0xf906(0x86)],_0x2e9af3[_0xf906(0x86)])?(await AsyncStorage[_0xf906(0x6b)](_0xf906(0x1b),_0x11073e[_0xf906(0x14)][_0xf906(0x1b)]['toString']()),_0x11073e['onairos'][_0xf906(0x17)]&&await AsyncStorage[_0xf906(0x6b)](_0x2e9af3[_0xf906(0x87)],_0x11073e[_0xf906(0x14)][_0xf906(0x17)]),_0x11073e[_0xf906(0x14)][_0xf906(0x19)]&&(_0x2e9af3[_0xf906(0x88)](_0x2e9af3['tOVqc'],_0x2e9af3[_0xf906(0x89)])?await AsyncStorage[_0xf906(0x6b)](_0x2e9af3[_0xf906(0x8a)],_0x11073e[_0xf906(0x14)][_0xf906(0x19)]):_0x2e9af3[_0xf906(0x3c)](_0xde10d2,!![])),console['log'](_0x2e9af3['nmZoF'],_0x11073e[_0xf906(0x14)][_0xf906(0x1b)])):_0x397ec5(![]):(await AsyncStorage[_0xf906(0x6b)](_0x2e9af3[_0xf906(0x8b)],_0x2e9af3[_0xf906(0x8c)]),console['log']('🔗\x20No\x20Onairos\x20connection\x20info\x20from\x20backend,\x20defaulting\x20to\x20false'));const _0xf52fc={'id':_0x11073e[_0xf906(0x5)]['id'],'name':_0x11073e[_0xf906(0x5)]['name']||_0x2e9af3[_0xf906(0x45)],'email':_0x11073e[_0xf906(0x5)][_0xf906(0x7f)],'profilePicture':_0x11073e[_0xf906(0x5)][_0xf906(0x8d)],'onboarded':![]};return await AsyncStorage[_0xf906(0x6b)](_0x2e9af3[_0xf906(0x3d)],JSON[_0xf906(0x61)](_0xf52fc)),_0x46de0f(_0xf52fc),_0x2e9af3['JIgrY'](_0x4743f6,!![]),console[_0xf906(0x52)](_0x2e9af3['Omtgd']),_0xf52fc;}catch(_0x30c8d3){console[_0xf906(0x58)](_0x2e9af3[_0xf906(0x8e)],_0x30c8d3);throw _0x30c8d3;}finally{if(_0x2e9af3['QSPsD'](_0x2e9af3[_0xf906(0x8f)],_0x2e9af3['leTmu'])){const _0x12d0e7=_0x3bf1d3[_0xf906(0x90)][_0xf906(0x91)]('|');let _0x3e4419=0x0;while(!![]){switch(_0x12d0e7[_0x3e4419++]){case'0':return;case'1':_0x3bf1d3[_0xf906(0x92)](_0x4b6b01,_0x2e2382[_0xf906(0x53)](_0x4eda7a));continue;case'2':_0x2c79da[_0xf906(0x52)](_0x3bf1d3['UlSba']);continue;case'3':_0x3bf1d3[_0xf906(0x93)](_0x27a7c7,!![]);continue;case'4':_0x3bf1d3['edTxG'](_0x2d30af,!![]);continue;case'5':_0x3bf1d3[_0xf906(0x94)](_0x4f9a6b,![]);continue;}break;}}else _0x2e9af3[_0xf906(0x95)](_0x1e01a2,![]);}},_0x3cc732=async _0xb0b23a=>{const _0x375be={'mtEmH':_0x2e9af3['Tscif']};try{_0x2e9af3[_0xf906(0x96)](_0x1e01a2,!![]);const _0x22a156=await _0x2e9af3[_0xf906(0x97)](authenticateWithOnairos,_0xb0b23a);await _0x2e9af3['KzMJg'](saveAuthToken,_0x22a156['token']),await AsyncStorage[_0xf906(0x6b)](_0x2e9af3[_0xf906(0x98)],_0x2e9af3[_0xf906(0x7e)]);const _0x1cf2fe={'id':_0x22a156['user']['id'],'name':_0x22a156['user']['name']||_0x2e9af3[_0xf906(0x45)],'email':_0x22a156['user'][_0xf906(0x7f)],'profilePicture':_0x22a156['user'][_0xf906(0x8d)],'onboarded':![]};return await AsyncStorage['setItem'](_0x2e9af3['URyRT'],JSON[_0xf906(0x61)](_0x1cf2fe)),_0x2e9af3[_0xf906(0x99)](_0x46de0f,_0x1cf2fe),_0x4743f6(!![]),console['log'](_0x2e9af3[_0xf906(0x9a)]),_0x1cf2fe;}catch(_0x42f2bb){console[_0xf906(0x58)](_0x2e9af3[_0xf906(0x9b)],_0x42f2bb);throw _0x42f2bb;}finally{if(_0x2e9af3['aMWML'](_0x2e9af3[_0xf906(0x9c)],_0x2e9af3['dFIdR']))_0x2e9af3[_0xf906(0x9d)](_0x1e01a2,![]);else{_0x3270d1[_0xf906(0x58)](_0x375be[_0xf906(0x9e)],_0x32d9c4);throw _0x4310d6;}}},_0x469ccb=async()=>{const _0x104254={'pSeRF':_0x2e9af3[_0xf906(0x9f)]};if(_0x2e9af3[_0xf906(0xa0)](_0x2e9af3[_0xf906(0xa1)],'klswa'))_0x420a5d['error'](_0x104254[_0xf906(0xa2)],_0x35b00b);else try{await clearUserData(),_0x2e9af3[_0xf906(0x95)](_0x46de0f,null),_0x2e9af3[_0xf906(0xa3)](_0x4743f6,![]);}catch(_0x4c3328){console['error'](_0x2e9af3['DiqWB'],_0x4c3328);}},_0x184961=async _0x4e9dd1=>{if(_0x2e9af3[_0xf906(0x38)](_0x2e9af3['NAmKk'],_0xf906(0x26)))try{const _0x4d6ff8={..._0x458e04,..._0x4e9dd1};await AsyncStorage[_0xf906(0x6b)](_0x2e9af3[_0xf906(0x3d)],JSON['stringify'](_0x4d6ff8)),_0x2e9af3['RvljG'](_0x46de0f,_0x4d6ff8),await _0x2c9982();}catch(_0x1cf435){console[_0xf906(0x58)](_0x2e9af3[_0xf906(0x79)],_0x1cf435);throw _0x1cf435;}else _0x3f4c2d[_0xf906(0x52)](_0x2e9af3[_0xf906(0xa4)]),_0x406a3c=!![];},_0x1760da=async _0x5ac9c9=>{try{if(!_0x458e04)return;const _0x4e1dd1={..._0x458e04,..._0x5ac9c9};await AsyncStorage[_0xf906(0x6b)]('user',JSON['stringify'](_0x4e1dd1)),_0x46de0f(_0x4e1dd1);}catch(_0x5085ab){_0x2e9af3[_0xf906(0xa5)](_0x2e9af3[_0xf906(0xa6)],_0x2e9af3['UCtbu'])?console['error'](_0x2e9af3[_0xf906(0x9f)],_0x5085ab):_0x3148a7[_0xf906(0x58)](_0xf906(0xa7),_0x44cb37);}},_0x2c9982=async()=>{const _0x32dc1f={'scuTb':_0x2e9af3['vFGkj'],'KPeyK':_0x2e9af3[_0xf906(0xa4)],'KrWAq':_0x2e9af3['MGxwf']};try{_0x2e9af3[_0xf906(0xa8)](_0x1e01a2,!![]),await _0x2e9af3['hwGac'](updateUserOnboardedStatus);if(_0x458e04){const _0x26e008={..._0x458e04,'onboarded':!![]};await AsyncStorage[_0xf906(0x6b)](_0xf906(0x5),JSON[_0xf906(0x61)](_0x26e008)),_0x2e9af3[_0xf906(0xa9)](_0x46de0f,_0x26e008);}}catch(_0x511403){if(_0x2e9af3[_0xf906(0xaa)](_0x2e9af3[_0xf906(0xab)],_0x2e9af3[_0xf906(0xab)])){console['error'](_0xf906(0xac),_0x511403);throw _0x511403;}else _0x2819ab[_0xf906(0x5d)](_0x32dc1f[_0xf906(0xad)],_0x2b8378),_0x32fd68&&(_0x5f22f7[_0xf906(0x52)](_0x32dc1f['KPeyK']),_0x5306d6=!![]);}finally{if(_0x2e9af3[_0xf906(0xae)](_0x2e9af3[_0xf906(0xaf)],_0xf906(0x2b))){_0x591d85[_0xf906(0x58)](_0x32dc1f['KrWAq'],_0x163a4a);throw _0x25e163;}else _0x2e9af3[_0xf906(0xb0)](_0x1e01a2,![]);}},_0x4bbc7d=async()=>{if(_0x2e9af3[_0xf906(0xb1)](_0x2e9af3[_0xf906(0xb2)],_0x2e9af3['fmvcz'])){_0x4554ae[_0xf906(0x58)](_0xf906(0x1e),_0x24a0e9);throw _0x38d248;}else try{const _0x3216a5=_0x2e9af3['OsOvN'][_0xf906(0x91)]('|');let _0xfdd551=0x0;while(!![]){switch(_0x3216a5[_0xfdd551++]){case'0':_0x46de0f(null);continue;case'1':_0x2e9af3[_0xf906(0x34)](_0x4743f6,![]);continue;case'2':await AsyncStorage['removeItem'](_0x2e9af3[_0xf906(0x3d)]);continue;case'3':_0x2e9af3[_0xf906(0xa3)](_0xc82de5,![]);continue;case'4':await AsyncStorage['removeItem'](_0x2e9af3[_0xf906(0x47)]);continue;case'5':await _0x2e9af3['hwGac'](removeAuthToken);continue;case'6':console['log'](_0x2e9af3[_0xf906(0xb3)]);continue;}break;}}catch(_0x3670b1){console[_0xf906(0x58)](_0x2e9af3[_0xf906(0xb4)],_0x3670b1);throw _0x3670b1;}};return React[_0xf906(0xb5)](AuthContext['Provider'],{'value':{'user':_0x458e04,'isLoading':_0x2f4390,'hasCompletedOnboarding':_0x4fdad9,'login':_0x11d4b4,'logout':_0x469ccb,'deleteAccount':_0x4bbc7d,'completeOnboarding':_0x184961,'updateUser':_0x1760da,'appleSignIn':_0x7018c5,'onairosSignIn':_0x3cc732,'isAuthenticated':_0x350936,'updateOnboardedStatus':_0x2c9982,'getResumeTarget':getResumeTarget,'markStepCompleted':markStepCompleted,'updateLastScreen':updateLastScreen,'isReturningUser':isReturningUser,'markEventPageReached':markEventPageReached,'hasEventAccessToken':hasEventAccessToken}},_0x1a405f);};export const useAuth=()=>{const _0x3bbcab={'KiCnG':function(_0x2c88e9,_0x16bd6f){return _0x2c88e9(_0x16bd6f);},'mlJqa':function(_0x234ec0,_0x4a5bef){return _0x234ec0===_0x4a5bef;},'uUgCj':_0xf906(0x0)},_0x55c96e=_0x3bbcab[_0xf906(0xb6)](useContext,AuthContext);if(_0x3bbcab[_0xf906(0xb7)](_0x55c96e,undefined))throw new Error(_0x3bbcab['uUgCj']);return _0x55c96e;};
1
+ import React, { createContext, useState, useEffect, useContext } from 'react';
2
+ import AsyncStorage from '@react-native-async-storage/async-storage';
3
+ import { saveAuthToken, getAuthToken, removeAuthToken, verifyToken, getUserProfile, authenticateWithApple, authenticateWithOnairos, updateUserOnboardedStatus } from '../services/authService';
4
+ import { saveAuthState, clearUserData, getResumeTarget, markStepCompleted, updateLastScreen, isReturningUser, markEventPageReached, hasEventAccessToken } from '../services/storageService';
5
+ const AuthContext = /*#__PURE__*/createContext(undefined);
6
+ export const AuthProvider = ({
7
+ children
8
+ }) => {
9
+ const [user, setUser] = useState(null);
10
+ const [isLoading, setIsLoading] = useState(true);
11
+ const [hasCompletedOnboarding, setHasCompletedOnboarding] = useState(false);
12
+ const [isAuthenticated, setIsAuthenticated] = useState(false);
13
+ useEffect(() => {
14
+ // Check if user is already logged in
15
+ const loadStoredUser = async () => {
16
+ try {
17
+ // PRIORITY 1: Check if user has completed onboarding (for release mode reliability)
18
+ const hasEventToken = await hasEventAccessToken();
19
+ const storedUser = await AsyncStorage.getItem('user');
20
+ if (hasEventToken && storedUser) {
21
+ console.log('🎯 Found event access token - user has completed onboarding, authentication confirmed');
22
+ setUser(JSON.parse(storedUser));
23
+ setIsAuthenticated(true);
24
+ setHasCompletedOnboarding(true);
25
+ setIsLoading(false);
26
+ return; // Skip network verification for completed users
27
+ }
28
+
29
+ // PRIORITY 2: Check if we have a JWT token for users still in onboarding
30
+ const token = await getAuthToken();
31
+ if (token) {
32
+ // For users with tokens but no completion token, try network verification
33
+ // but don't fail if network is unreachable (important for release mode)
34
+ let isValid = false;
35
+ try {
36
+ isValid = await verifyToken();
37
+ } catch (networkError) {
38
+ console.warn('🌐 Network verification failed, using local token validation:', networkError);
39
+ // In release mode, network might be slow/unreliable
40
+ // If we have a token and stored user, trust the local state
41
+ if (storedUser) {
42
+ console.log('💾 Network unreachable, trusting local authentication state');
43
+ isValid = true; // Trust local state when network fails
44
+ }
45
+ }
46
+ if (isValid) {
47
+ // Token is valid (or we're trusting local state), get user data
48
+ if (storedUser) {
49
+ setUser(JSON.parse(storedUser));
50
+ setIsAuthenticated(true);
51
+ } else {
52
+ // If user data is not in AsyncStorage, try to fetch it
53
+ try {
54
+ const userData = await getUserProfile();
55
+ await AsyncStorage.setItem('user', JSON.stringify(userData));
56
+ setUser(userData);
57
+ setIsAuthenticated(true);
58
+ } catch (profileError) {
59
+ console.error('Failed to fetch user profile:', profileError);
60
+ // Only remove token if we're sure it's invalid (not just network issues)
61
+ const errorMessage = profileError instanceof Error ? profileError.message : String(profileError);
62
+ if (errorMessage.includes('401') || errorMessage.includes('403')) {
63
+ await removeAuthToken();
64
+ } else {
65
+ console.log('🌐 Profile fetch failed (likely network), keeping authentication state');
66
+ // Create fallback user for offline scenarios
67
+ if (token) {
68
+ const fallbackUser = {
69
+ id: 'offline_user',
70
+ name: 'Onairos User',
71
+ email: 'user@onairos.com',
72
+ onboarded: false
73
+ };
74
+ await AsyncStorage.setItem('user', JSON.stringify(fallbackUser));
75
+ setUser(fallbackUser);
76
+ setIsAuthenticated(true);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ } else {
82
+ // Token verification definitely failed - remove it
83
+ await removeAuthToken();
84
+ }
85
+ }
86
+ const onboardingCompleted = await AsyncStorage.getItem('onboardingCompleted');
87
+ if (onboardingCompleted === 'true') {
88
+ setHasCompletedOnboarding(true);
89
+ }
90
+ } catch (error) {
91
+ console.error('Failed to load authentication state:', error);
92
+ } finally {
93
+ setIsLoading(false);
94
+ }
95
+ };
96
+ loadStoredUser();
97
+ }, []);
98
+ const login = async userData => {
99
+ try {
100
+ var _userData$email;
101
+ // Ensure onboarded is set to false for new users
102
+ const userWithOnboarded = {
103
+ ...userData,
104
+ onboarded: false // Always force camera flow for new logins
105
+ };
106
+ await AsyncStorage.setItem('user', JSON.stringify(userWithOnboarded));
107
+ setUser(userWithOnboarded);
108
+ setIsAuthenticated(true);
109
+
110
+ // Save auth state and mark authentication step as completed
111
+ await saveAuthState({
112
+ isAuthenticated: true,
113
+ authMethod: (_userData$email = userData.email) !== null && _userData$email !== void 0 && _userData$email.includes('apple') ? 'apple' : 'onairos',
114
+ hasValidToken: true,
115
+ userEmail: userData.email,
116
+ userName: userData.name
117
+ });
118
+ await markStepCompleted('authentication');
119
+ console.log('User logged in with onboarded=false:', userWithOnboarded);
120
+ } catch (error) {
121
+ console.error('Failed to save user data:', error);
122
+ }
123
+ };
124
+
125
+ // Handle Apple Sign-In
126
+ const appleSignIn = async appleAuthData => {
127
+ try {
128
+ setIsLoading(true);
129
+
130
+ // Call the API to authenticate with Apple
131
+ const authResponse = await authenticateWithApple(appleAuthData);
132
+
133
+ // Save the JWT token
134
+ await saveAuthToken(authResponse.token);
135
+
136
+ // CRITICAL: Save auth method as 'apple' for proper button logic
137
+ await AsyncStorage.setItem('auth_method', 'apple');
138
+
139
+ // Save Onairos connection status from backend response
140
+ if (authResponse.onairos) {
141
+ await AsyncStorage.setItem('hasConnectedOnairos', authResponse.onairos.hasConnectedOnairos.toString());
142
+ if (authResponse.onairos.onairosUserId) {
143
+ await AsyncStorage.setItem('onairosUserId', authResponse.onairos.onairosUserId);
144
+ }
145
+ if (authResponse.onairos.lastConnectedAt) {
146
+ await AsyncStorage.setItem('lastConnectedAt', authResponse.onairos.lastConnectedAt);
147
+ }
148
+ console.log('🔗 Stored Onairos connection status:', authResponse.onairos.hasConnectedOnairos);
149
+ } else {
150
+ // Default to false if no Onairos info provided
151
+ await AsyncStorage.setItem('hasConnectedOnairos', 'false');
152
+ console.log('🔗 No Onairos connection info from backend, defaulting to false');
153
+ }
154
+
155
+ // Create user object from response
156
+ const userData = {
157
+ id: authResponse.user.id,
158
+ name: authResponse.user.name || 'Onairos User',
159
+ email: authResponse.user.email,
160
+ profilePicture: authResponse.user.profilePicture,
161
+ onboarded: false // Default to false for new Apple sign-ins
162
+ };
163
+
164
+ // Save user data to AsyncStorage and update state
165
+ await AsyncStorage.setItem('user', JSON.stringify(userData));
166
+ setUser(userData);
167
+ setIsAuthenticated(true);
168
+ console.log('🍎 Apple sign-in completed - auth_method set to "apple"');
169
+ return userData;
170
+ } catch (error) {
171
+ console.error('Apple sign-in failed:', error);
172
+ throw error;
173
+ } finally {
174
+ setIsLoading(false);
175
+ }
176
+ };
177
+
178
+ // Handle Onairos Sign-In (similar to Apple)
179
+ const onairosSignIn = async onairosAuthData => {
180
+ try {
181
+ setIsLoading(true);
182
+
183
+ // Call the API to authenticate with Onairos
184
+ const authResponse = await authenticateWithOnairos(onairosAuthData);
185
+
186
+ // Save the JWT token
187
+ await saveAuthToken(authResponse.token);
188
+
189
+ // CRITICAL: Save auth method as 'onairos' for proper button logic
190
+ await AsyncStorage.setItem('auth_method', 'onairos');
191
+
192
+ // Create user object from response
193
+ const userData = {
194
+ id: authResponse.user.id,
195
+ name: authResponse.user.name || 'Onairos User',
196
+ email: authResponse.user.email,
197
+ profilePicture: authResponse.user.profilePicture,
198
+ onboarded: false // Default to false for new Onairos sign-ins
199
+ };
200
+
201
+ // Save user data to AsyncStorage and update state
202
+ await AsyncStorage.setItem('user', JSON.stringify(userData));
203
+ setUser(userData);
204
+ setIsAuthenticated(true);
205
+ console.log('🔑 Onairos sign-in completed - auth_method set to "onairos"');
206
+ return userData;
207
+ } catch (error) {
208
+ console.error('Onairos sign-in failed:', error);
209
+ throw error;
210
+ } finally {
211
+ setIsLoading(false);
212
+ }
213
+ };
214
+ const logout = async () => {
215
+ try {
216
+ // Clear all user data using the new storage service
217
+ await clearUserData();
218
+ setUser(null);
219
+ setIsAuthenticated(false);
220
+ } catch (error) {
221
+ console.error('Failed to remove user data:', error);
222
+ }
223
+ };
224
+ const completeOnboarding = async userData => {
225
+ try {
226
+ // Update user data
227
+ const updatedUser = {
228
+ ...user,
229
+ ...userData
230
+ };
231
+ await AsyncStorage.setItem('user', JSON.stringify(updatedUser));
232
+ setUser(updatedUser);
233
+
234
+ // Update onboarded status on backend
235
+ await updateOnboardedStatus();
236
+ } catch (error) {
237
+ console.error('Failed to complete onboarding:', error);
238
+ throw error;
239
+ }
240
+ };
241
+ const updateUser = async userData => {
242
+ try {
243
+ if (!user) return;
244
+ const updatedUser = {
245
+ ...user,
246
+ ...userData
247
+ };
248
+ await AsyncStorage.setItem('user', JSON.stringify(updatedUser));
249
+ setUser(updatedUser);
250
+ } catch (error) {
251
+ console.error('Failed to update user data:', error);
252
+ }
253
+ };
254
+
255
+ // Update user onboarded status
256
+ const updateOnboardedStatus = async () => {
257
+ try {
258
+ setIsLoading(true);
259
+
260
+ // Call the API to update onboarded status
261
+ await updateUserOnboardedStatus();
262
+
263
+ // Update local user data
264
+ if (user) {
265
+ const updatedUser = {
266
+ ...user,
267
+ onboarded: true
268
+ };
269
+ await AsyncStorage.setItem('user', JSON.stringify(updatedUser));
270
+ setUser(updatedUser);
271
+ }
272
+ } catch (error) {
273
+ console.error('Failed to update onboarded status:', error);
274
+ throw error;
275
+ } finally {
276
+ setIsLoading(false);
277
+ }
278
+ };
279
+ const deleteAccount = async () => {
280
+ try {
281
+ // In a real app, you would make an API call to delete the user account on the server
282
+ // For example: await api.deleteUser(user.id);
283
+
284
+ // Remove user data from AsyncStorage
285
+ await AsyncStorage.removeItem('user');
286
+
287
+ // Remove JWT token
288
+ await removeAuthToken();
289
+
290
+ // Clear any other user-related data from AsyncStorage
291
+ await AsyncStorage.removeItem('onboardingCompleted');
292
+
293
+ // Update state
294
+ setUser(null);
295
+ setIsAuthenticated(false);
296
+ setHasCompletedOnboarding(false);
297
+ console.log('Account deleted successfully');
298
+ } catch (error) {
299
+ console.error('Failed to delete account:', error);
300
+ throw error;
301
+ }
302
+ };
303
+ return /*#__PURE__*/React.createElement(AuthContext.Provider, {
304
+ value: {
305
+ user,
306
+ isLoading,
307
+ hasCompletedOnboarding,
308
+ login,
309
+ logout,
310
+ deleteAccount,
311
+ completeOnboarding,
312
+ updateUser,
313
+ appleSignIn,
314
+ onairosSignIn,
315
+ isAuthenticated,
316
+ updateOnboardedStatus,
317
+ // Progress tracking methods
318
+ getResumeTarget,
319
+ markStepCompleted,
320
+ updateLastScreen,
321
+ isReturningUser,
322
+ // Event access token methods
323
+ markEventPageReached,
324
+ hasEventAccessToken
325
+ }
326
+ }, children);
327
+ };
328
+ export const useAuth = () => {
329
+ const context = useContext(AuthContext);
330
+ if (context === undefined) {
331
+ throw new Error('useAuth must be used within an AuthProvider');
332
+ }
333
+ return context;
334
+ };
335
+ //# sourceMappingURL=AuthContext.js.map