@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,172 @@
1
- console[_0x51b0(0x0)](_0x51b0(0x1)),console[_0x51b0(0x0)]('\uD83D\uDE80 [ONAIROS SDK] Source: onairos-npm-react-native/src/index.ts');export{OnairosButton}from'./components/OnairosButton';export{OnairosSignInButton}from'./components/OnairosSignInButton';export{Onairos}from'./components/Onairos';export{UniversalOnboarding}from'./components/UniversalOnboarding';export{OAuthWebView}from'./components/onboarding/OAuthWebView';export{PortalHost,Portal}from'./utils/Portal';export{default as WelcomeScreen}from'./components/WelcomeScreen';export{PrimaryButton}from'./components/PrimaryButton';export{ModalSheet}from'./components/ModalSheet';export{ModalHeader}from'./components/ModalHeader';export{BrandMark}from'./components/BrandMark';export{HeadingGroup}from'./components/HeadingGroup';export{BodyText}from'./components/BodyText';export{SignInStep}from'./components/SignInStep';export{VerificationStep}from'./components/VerificationStep';export{default as PlatformConnectorsStep}from'./components/PlatformConnectorsStep';export{PersonalizationConsentScreen}from'./components/PersonalizationConsentScreen';export{PinCreationScreen}from'./components/PinCreationScreen';export{default as PersonaImage}from'./components/PersonaImage';export{useConnections}from'./hooks/useConnections';export{initializeApiKey}from'./services/apiKeyService';export{extractUsernameFromJWT,extractUserDataFromJWT,decodeJWTPayload}from'./services/apiKeyService';export{isAuthenticated}from'./services/authService';export{clearAllAuthTokens}from'./services/authService';function _0x51b0(_0x5833a5,_0x51b063){_0x5833a5=_0x5833a5-0x0;var _0x251c77=_0x5833();var _0x15d244=_0x251c77[_0x5833a5];return _0x15d244;}export{updateGoogleClientIds}from'./services/googleAuthService';export{testApiConnectivity}from'./services/platformAuthService';export{runFullDiagnostics,isApiReachable,getNetworkStatus}from'./utils/networkDiagnostics';export{scrapeLinkedInProfile,extractLinkedInUsername,isValidLinkedInUrl,formatLinkedInUrl,canScrapeProfile,getLinkedInConnectionStatus}from'./services/linkedinScrapingService';export{parseExtractionMessage,initiateProfileScraping,checkScrapingStatus,validateExtractedUrl,completeLinkedInExtraction}from'./services/linkedinDOMExtractor';export{ApiClient}from'./services/apiClient';function _0x5833(){var _0x2473bb=['log','🚀\x20[ONAIROS\x20SDK]\x20LOCAL\x20SDK\x20LOADED\x20-\x20Version\x205.0.0-local-dev'];_0x5833=function(){return _0x2473bb;};return _0x5833();}
1
+ /**
2
+ * Onairos React Native SDK v5.0.0
3
+ * A React Native implementation for Onairos personalized data integration
4
+ *
5
+ * PUBLIC API - Generic SDK (Enoch-specific code removed)
6
+ *
7
+ * NOTE: This SDK provides generic authentication (Google, Apple, Email).
8
+ * It does NOT create app-specific users (like EnochUser).
9
+ * Consuming apps should handle app-specific user creation after SDK auth completes.
10
+ *
11
+ * MINIMAL INTEGRATION:
12
+ * 1. Call initializeApiKey({ apiKey: 'your-dev-key' }) at app startup
13
+ * 2. Use <OnairosButton /> or <Onairos /> component
14
+ * 3. That's it! The SDK handles all auth internally.
15
+ */
16
+
17
+ console.log('🚀 [ONAIROS SDK] Loaded - Version 3.7.3');
18
+
19
+ // ============================================================================
20
+ // TYPES - TypeScript definitions for SDK configuration
21
+ // ============================================================================
22
+
23
+ // ============================================================================
24
+ // CORE COMPONENTS - Main SDK UI components for developer use
25
+ // ============================================================================
26
+
27
+ // Primary components - use these to integrate Onairos into your app
28
+ export { OnairosButton } from './components/OnairosButton';
29
+ export { OnairosSignInButton } from './components/OnairosSignInButton';
30
+ export { Onairos } from './components/Onairos';
31
+ export { UniversalOnboarding } from './components/UniversalOnboarding';
32
+ export { OAuthWebView } from './components/onboarding/OAuthWebView';
33
+
34
+ // Portal System for Modal Overlays - required for proper overlay rendering
35
+ export { PortalHost, Portal } from './utils/Portal';
36
+
37
+ // ============================================================================
38
+ // UI BUILDING BLOCKS - For custom onboarding flows
39
+ // ============================================================================
40
+
41
+ export { default as WelcomeScreen } from './components/WelcomeScreen';
42
+ export { PrimaryButton } from './components/PrimaryButton';
43
+ export { ModalSheet } from './components/ModalSheet';
44
+ export { ModalHeader } from './components/ModalHeader';
45
+ export { BrandMark } from './components/BrandMark';
46
+ export { HeadingGroup } from './components/HeadingGroup';
47
+ export { BodyText } from './components/BodyText';
48
+ export { SignInStep } from './components/SignInStep';
49
+ export { VerificationStep } from './components/VerificationStep';
50
+ export { default as PlatformConnectorsStep } from './components/PlatformConnectorsStep';
51
+ export { PersonalizationConsentScreen } from './components/PersonalizationConsentScreen';
52
+ export { PinCreationScreen } from './components/PinCreationScreen';
53
+ export { default as PersonaImage } from './components/PersonaImage';
54
+
55
+ // ============================================================================
56
+ // HOOKS - React hooks for connection state management
57
+ // ============================================================================
58
+
59
+ // NOTE: useConnections manages local state only (backend sync is handled internally)
60
+ export { useConnections } from './hooks/useConnections';
61
+
62
+ // ============================================================================
63
+ // SDK INITIALIZATION - Required before using any SDK features
64
+ // ============================================================================
65
+
66
+ /**
67
+ * Initialize the SDK with your developer API key
68
+ * MUST be called before using OnairosButton or Onairos components
69
+ *
70
+ * @example
71
+ * import { initializeApiKey } from '@onairos/react-native';
72
+ *
73
+ * // At app startup
74
+ * await initializeApiKey({ apiKey: 'your-dev-key-from-dashboard' });
75
+ */
76
+ export { initializeApiKey } from './services/apiKeyService';
77
+
78
+ // JWT utilities - useful for extracting user data from tokens
79
+ export { extractUsernameFromJWT, extractUserDataFromJWT, decodeJWTPayload } from './services/apiKeyService';
80
+
81
+ // ============================================================================
82
+ // AUTH STATUS - Check if user is authenticated with Onairos
83
+ // ============================================================================
84
+
85
+ /**
86
+ * Check if user is authenticated with Onairos
87
+ * @returns Promise<boolean> - true if user has valid authentication
88
+ */
89
+ export { isAuthenticated } from './services/authService';
90
+
91
+ /**
92
+ * Clear all auth tokens - use this for logout functionality
93
+ * Removes all stored authentication data
94
+ */
95
+ export { clearAllAuthTokens } from './services/authService';
96
+
97
+ // ============================================================================
98
+ // GOOGLE SIGN-IN CONFIGURATION
99
+ // ============================================================================
100
+
101
+ /**
102
+ * Configure Google Sign-In with your client IDs
103
+ * Call this before showing any auth UI that includes Google
104
+ *
105
+ * @example
106
+ * import { updateGoogleClientIds } from '@onairos/react-native';
107
+ *
108
+ * updateGoogleClientIds({
109
+ * iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
110
+ * webClientId: 'your-web-client-id.apps.googleusercontent.com',
111
+ * });
112
+ */
113
+ export { updateGoogleClientIds } from './services/googleAuthService';
114
+
115
+ // ============================================================================
116
+ // NETWORK DIAGNOSTICS - Debug connectivity issues
117
+ // ============================================================================
118
+
119
+ /**
120
+ * Test API connectivity - useful for debugging OAuth issues
121
+ * @example
122
+ * import { testApiConnectivity } from '@onairos/react-native';
123
+ * const result = await testApiConnectivity();
124
+ */
125
+ export { testApiConnectivity } from './services/platformAuthService';
126
+
127
+ /**
128
+ * Run full network diagnostics
129
+ * Use this to debug connection issues with the Onairos backend
130
+ */
131
+ export { runFullDiagnostics, isApiReachable, getNetworkStatus } from './utils/networkDiagnostics';
132
+
133
+ // ============================================================================
134
+ // ADVANCED: LINKEDIN PROFILE INTEGRATION
135
+ // ============================================================================
136
+
137
+ // LinkedIn Profile Scraping - For apps that need LinkedIn data integration
138
+ export { scrapeLinkedInProfile, extractLinkedInUsername, isValidLinkedInUrl, formatLinkedInUrl, canScrapeProfile, getLinkedInConnectionStatus } from './services/linkedinScrapingService';
139
+
140
+ // LinkedIn DOM Extractor - For WebView profile extraction
141
+ export { parseExtractionMessage, initiateProfileScraping, checkScrapingStatus, validateExtractedUrl, completeLinkedInExtraction } from './services/linkedinDOMExtractor';
142
+
143
+ // ============================================================================
144
+ // ADVANCED: API CLIENT
145
+ // ============================================================================
146
+
147
+ // Direct API access for advanced use cases
148
+ export { ApiClient } from './services/apiClient';
149
+
150
+ // ============================================================================
151
+ // INTERNAL EXPORTS - NOT PART OF PUBLIC API
152
+ // These are used internally by SDK components and should not be used directly.
153
+ // They may change or be removed without notice.
154
+ // ============================================================================
155
+
156
+ // NOTE: The following functions are intentionally NOT exported:
157
+ // - getAuthToken, saveAuthToken, removeAuthToken (internal token management)
158
+ // - getOnairosUsername (internal user data)
159
+ // - authenticateWithApple, authenticateWithOnairos, authenticateWithOnairosSignIn (called by SDK UI)
160
+ // - sendEmailVerificationCode, confirmEmailVerificationCode (called by SDK UI)
161
+ // - storeJWT, getJWT, clearJWT, hasValidJWT, replaceJWT (internal JWT storage)
162
+ // - initiateOAuth, initiateNativeAuth, hasNativeSDK, isOAuthCallback (internal OAuth)
163
+ // - signInWithGoogle, isGoogleSignedIn, signOutFromGoogle (internal Google auth)
164
+ //
165
+ // If you previously used these functions, please update your integration:
166
+ // - Use isAuthenticated() to check auth status
167
+ // - Use clearAllAuthTokens() for logout
168
+ // - Use OnairosButton or Onairos components for authentication flows
169
+
170
+ // Default export removed to avoid duplicate declarations
171
+ // Use named exports instead: import { Onairos, OnairosButton } from '@onairos/react-native'
172
+ //# sourceMappingURL=index.js.map
@@ -1 +1,295 @@
1
- import{getJWTForRoute,TokenType,getTokenTypeForRoute,clearJWT,getAllTokens,replaceJWTAfterVerification}from'./jwtStorageService';import{API_CONFIG}from'../config/api';function _0xf2c3(_0x808687,_0xf2c350){_0x808687=_0x808687-0x0;const _0x1cba4c=_0x8086();let _0x1b4ea3=_0x1cba4c[_0x808687];return _0x1b4ea3;}let currentRequestId=0x0;const activeRequests=new Map();class ApiClient{constructor(_0x37573f=API_CONFIG[_0xf2c3(0x0)],_0xe91641={}){this['baseUrl']=_0x37573f,this[_0xf2c3(0x1)]=_0xe91641;}async[_0xf2c3(0x2)](_0x2b1b4b,_0x34c893={}){const _0x4d1d1e={'SvTkd':function(_0x4760f1,_0xdfc2b1){return _0x4760f1===_0xdfc2b1;},'Ssqif':'ZccsR','wrgfL':'BQXrb','PrdaK':function(_0x16fafe,_0x353285){return _0x16fafe(_0x353285);},'gSQli':function(_0x3d4618,_0x4d5930){return _0x3d4618!==_0x4d5930;},'qBtMD':'OnairosSDK/1.0.0','RNVDm':function(_0x11c510,_0x2942c1,_0xfb1f66){return _0x11c510(_0x2942c1,_0xfb1f66);},'Nbccd':'ovWEH','DCFQr':function(_0x99d79e,_0x4a3e6d){return _0x99d79e===_0x4a3e6d;},'zyCxQ':_0xf2c3(0x3),'hOwTw':function(_0xb974c6,_0x309df4){return _0xb974c6 instanceof _0x309df4;},'IwyFt':function(_0x5d57fd,_0x1e66a2){return _0x5d57fd===_0x1e66a2;},'dBimO':'AbortError','uKeUS':_0xf2c3(0x4),'WilQt':_0xf2c3(0x5),'MIeco':'Unknown\x20error'},_0x35ffb3=++currentRequestId,_0x38f478=new AbortController();activeRequests[_0xf2c3(0x6)](_0x35ffb3,_0x38f478);try{if(_0x4d1d1e[_0xf2c3(0x7)](_0x4d1d1e[_0xf2c3(0x8)],_0x4d1d1e[_0xf2c3(0x9)]))_0x87c1f0[_0xf2c3(0xa)](_0xf2c3(0xb)+_0x5a103e+':\x20'+_0x3c1499[_0xf2c3(0xc)](0x0,0x14)+_0xf2c3(0xd)+_0x3ef93d[_0xf2c3(0xe)]+')');else{console[_0xf2c3(0xa)](_0xf2c3(0xf)+_0x35ffb3+'\x20to:\x20'+_0x2b1b4b);const _0x3918ce=_0x4d1d1e[_0xf2c3(0x10)](getTokenTypeForRoute,_0x2b1b4b);console[_0xf2c3(0xa)](_0xf2c3(0x11)+_0x2b1b4b+'\x20requires\x20'+_0x3918ce+_0xf2c3(0x12));const _0x262b01=await this[_0xf2c3(0x13)](_0x2b1b4b,_0x4d1d1e[_0xf2c3(0x14)](_0x34c893[_0xf2c3(0x15)],![])),_0x4a867d={'method':_0x34c893[_0xf2c3(0x16)]||'GET','headers':{'Content-Type':'application/json','User-Agent':_0x4d1d1e[_0xf2c3(0x17)],..._0x262b01,..._0x34c893[_0xf2c3(0x18)]},'body':_0x34c893[_0xf2c3(0x19)]?JSON[_0xf2c3(0x1a)](_0x34c893[_0xf2c3(0x19)]):undefined,'signal':_0x38f478['signal']};console[_0xf2c3(0xa)](_0xf2c3(0x1b)+_0x35ffb3+'\x20using\x20'+_0x3918ce+_0xf2c3(0x12));const _0x22260a=await _0x4d1d1e[_0xf2c3(0x1c)](fetch,''+this[_0xf2c3(0x1d)]+_0x2b1b4b,_0x4a867d);console[_0xf2c3(0xa)](_0xf2c3(0x1e)+_0x35ffb3+'\x20status:',_0x22260a[_0xf2c3(0x1f)]);if(_0x22260a[_0xf2c3(0x1f)]===0x191)return _0x4d1d1e[_0xf2c3(0x14)](_0x4d1d1e[_0xf2c3(0x20)],_0x4d1d1e[_0xf2c3(0x20)])?this[_0xf2c3(0x2)](_0x3a0f01,{..._0x4c582b,'method':'PUT','body':_0x4701a1}):await this[_0xf2c3(0x21)](_0x35ffb3,_0x2b1b4b,_0x3918ce,_0x34c893);const _0x445cbb=await _0x22260a[_0xf2c3(0x22)]();activeRequests['delete'](_0x35ffb3);if(!_0x22260a['ok'])return _0x4d1d1e[_0xf2c3(0x23)](_0x4d1d1e[_0xf2c3(0x24)],_0x4d1d1e[_0xf2c3(0x24)])?{'success':![],'error':_0x445cbb['message']||_0xf2c3(0x25)+_0x22260a[_0xf2c3(0x1f)],'status':_0x22260a['status'],'tokenType':_0x3918ce}:this[_0xf2c3(0x2)](_0xae5884,{..._0x55934c,'method':'POST','body':_0x5a7e82});return{'success':!![],'data':_0x445cbb,'status':_0x22260a['status'],'tokenType':_0x3918ce};}}catch(_0x188059){activeRequests[_0xf2c3(0x26)](_0x35ffb3);if(_0x4d1d1e[_0xf2c3(0x27)](_0x188059,Error)&&_0x4d1d1e['IwyFt'](_0x188059[_0xf2c3(0x28)],_0x4d1d1e['dBimO']))return _0x4d1d1e[_0xf2c3(0x7)](_0x4d1d1e['uKeUS'],_0x4d1d1e['uKeUS'])?(console[_0xf2c3(0xa)](_0xf2c3(0x29)+_0x35ffb3+_0xf2c3(0x2a)),{'success':![],'error':_0x4d1d1e[_0xf2c3(0x2b)],'status':0x0}):{'success':![],'error':_0x323f25[_0xf2c3(0x2c)]||'Request\x20failed\x20with\x20status\x20'+_0x49f2b5[_0xf2c3(0x1f)],'status':_0x1a0951[_0xf2c3(0x1f)],'tokenType':_0x2e3d1d};return console[_0xf2c3(0x2d)](_0xf2c3(0x2e)+_0x35ffb3+_0xf2c3(0x2f),_0x188059),{'success':![],'error':_0x188059 instanceof Error?_0x188059[_0xf2c3(0x2c)]:_0x4d1d1e[_0xf2c3(0x30)],'status':0x0};}}async[_0xf2c3(0x13)](_0x26e5dc,_0x541589){const _0x2929ba={'dGRlQ':function(_0x1b4ca0,_0x3250bb){return _0x1b4ca0!==_0x3250bb;},'UjxSK':_0xf2c3(0x31),'ayMoB':function(_0x3e2beb,_0x53c3d6){return _0x3e2beb(_0x53c3d6);}};if(!_0x541589)return{};const _0x59cb85=await getJWTForRoute(_0x26e5dc);if(!_0x59cb85){if(_0x2929ba[_0xf2c3(0x32)]('yNGrC',_0x2929ba[_0xf2c3(0x33)])){const _0x5b70d2=_0x2929ba[_0xf2c3(0x34)](getTokenTypeForRoute,_0x26e5dc);throw new Error('No\x20'+_0x5b70d2+_0xf2c3(0x35)+_0x26e5dc+_0xf2c3(0x36));}else _0x1abe63['warn'](_0xf2c3(0x37));}return{'Authorization':_0x59cb85};}async[_0xf2c3(0x21)](_0x4bfecd,_0x161973,_0x1289f9,_0x17972b){const _0x5ebec9={'lHDsL':function(_0x392219,_0x1d5b37){return _0x392219(_0x1d5b37);}};return console[_0xf2c3(0x2d)](_0xf2c3(0x29)+_0x4bfecd+_0xf2c3(0x38)+_0x1289f9+_0xf2c3(0x39)+_0x161973),console[_0xf2c3(0xa)](_0xf2c3(0x3a)+_0x1289f9+_0xf2c3(0x3b)),await _0x5ebec9[_0xf2c3(0x3c)](clearJWT,_0x1289f9),this[_0xf2c3(0x3d)](_0x1289f9,_0x4bfecd),await this[_0xf2c3(0x3e)](_0x1289f9,_0x161973),console['log']('🔑\x20[API\x20Client]\x20'+_0x1289f9+_0xf2c3(0x3f)),{'success':![],'error':_0x1289f9+_0xf2c3(0x40)+_0x161973+_0xf2c3(0x41),'status':0x191,'tokenType':_0x1289f9};}async[_0xf2c3(0x3e)](_0x4eabf4,_0xf24f74){const _0x122808={'jtxmV':function(_0x4e3adf,_0x4207ae){return _0x4e3adf!==_0x4207ae;},'NSHvY':function(_0x2bbb97,_0x2833c0){return _0x2bbb97 instanceof _0x2833c0;},'sTHXO':function(_0x5eb352,_0x44f796){return _0x5eb352===_0x44f796;},'qroer':'AbortError','ZeWxw':'Request\x20cancelled','KqEeH':_0xf2c3(0x42),'kQDZm':_0xf2c3(0x43),'zrZSo':_0xf2c3(0x44),'WayHV':function(_0x52f0e8,_0x335601){return _0x52f0e8===_0x335601;},'Jgtzk':_0xf2c3(0x45),'ziPhe':_0xf2c3(0x46),'JnCgo':_0xf2c3(0x47),'MLMYU':_0xf2c3(0x48),'qQsfF':function(_0xf864a,_0xa6dbe5){return _0xf864a===_0xa6dbe5;},'oAQDP':_0xf2c3(0x49),'QdwPD':_0xf2c3(0x4a),'euEmz':'pNbYi','DUhcw':_0xf2c3(0x4b),'dobEi':_0xf2c3(0x37)};console[_0xf2c3(0xa)](_0xf2c3(0x4c)+_0x4eabf4+'\x20token\x20(endpoint:\x20'+_0xf24f74+')');try{if(_0x122808[_0xf2c3(0x4d)](_0xf2c3(0x4e),_0x122808['kQDZm']))_0x122808[_0xf2c3(0x4f)](_0x20081f,_0x57dcc4)&&(_0x4594bd[_0xf2c3(0x50)](),_0x474931[_0xf2c3(0x26)](_0x132c79),_0x151af0++);else switch(_0x4eabf4){case TokenType[_0xf2c3(0x51)]:if(this['authTriggers']['triggerEnochReAuth'])console[_0xf2c3(0xa)](_0x122808[_0xf2c3(0x52)]),await this[_0xf2c3(0x1)][_0xf2c3(0x53)]();else{if(_0x122808[_0xf2c3(0x54)](_0x122808[_0xf2c3(0x55)],_0x122808[_0xf2c3(0x55)]))console[_0xf2c3(0x56)](_0x122808[_0xf2c3(0x57)]);else return this[_0xf2c3(0x2)](_0x7c6935,{..._0x33222f,'method':'GET'});}break;case TokenType[_0xf2c3(0x58)]:if(this[_0xf2c3(0x1)][_0xf2c3(0x59)])_0x122808['JnCgo']===_0x122808['JnCgo']?(console[_0xf2c3(0xa)](_0x122808['MLMYU']),await this['authTriggers'][_0xf2c3(0x59)]()):(this['baseUrl']=_0x5a00cd,this[_0xf2c3(0x1)]=_0x31ae48);else{if(_0x122808[_0xf2c3(0x5a)](_0x122808[_0xf2c3(0x5b)],_0x122808[_0xf2c3(0x5b)]))console['warn'](_0x122808['QdwPD']);else{_0x567378[_0xf2c3(0x26)](_0x1ccc3c);if(_0x122808['NSHvY'](_0x46726d,_0x5bf31a)&&_0x122808[_0xf2c3(0x4d)](_0x34967f[_0xf2c3(0x28)],_0x122808[_0xf2c3(0x5c)]))return _0x1d24fd[_0xf2c3(0xa)](_0xf2c3(0x29)+_0x29ff25+_0xf2c3(0x2a)),{'success':![],'error':_0x122808[_0xf2c3(0x5d)],'status':0x0};return _0xcae6d0[_0xf2c3(0x2d)](_0xf2c3(0x2e)+_0x28cd5d+'\x20failed:',_0x4291d5),{'success':![],'error':_0x122808['NSHvY'](_0x113b1f,_0x126648)?_0x3549c0['message']:_0x122808['KqEeH'],'status':0x0};}}break;case TokenType['AUTH']:if(this[_0xf2c3(0x1)][_0xf2c3(0x5e)]){if(_0x122808[_0xf2c3(0x4f)](_0x122808['euEmz'],_0x122808[_0xf2c3(0x5f)]))console[_0xf2c3(0xa)](_0xf2c3(0x60)),await this[_0xf2c3(0x1)]['triggerAuthTokenRefresh']();else return _0x44d67d[_0xf2c3(0xa)](_0xf2c3(0x29)+_0xff4e19+_0xf2c3(0x2a)),{'success':![],'error':_0x122808[_0xf2c3(0x5d)],'status':0x0};}else console[_0xf2c3(0x56)](_0x122808['dobEi']);break;}}catch(_0x47aa5f){console[_0xf2c3(0x2d)]('❌\x20[API\x20Client]\x20Failed\x20to\x20trigger\x20re-auth\x20for\x20'+_0x4eabf4+':',_0x47aa5f);}}[_0xf2c3(0x3d)](_0x52c7c8,_0xfbc0d1){const _0x2ce76a={'RjfeO':_0xf2c3(0x4a),'wWdAc':function(_0x5ad9e5,_0x51d79a){return _0x5ad9e5===_0x51d79a;},'PsrQb':function(_0x49a159,_0x3babbe){return _0x49a159!==_0x3babbe;},'ezRpv':function(_0x5e61d5,_0xd702ab){return _0x5e61d5>_0xd702ab;}};let _0x462d9d=0x0;for(const [_0x39e70b,_0x3f2957]of activeRequests[_0xf2c3(0x61)]()){_0x2ce76a[_0xf2c3(0x62)](_0xf2c3(0x63),_0xf2c3(0x63))?_0x2ce76a[_0xf2c3(0x64)](_0x39e70b,_0xfbc0d1)&&(_0x3f2957[_0xf2c3(0x50)](),activeRequests[_0xf2c3(0x26)](_0x39e70b),_0x462d9d++):_0x3fa5a7[_0xf2c3(0x56)](_0x2ce76a[_0xf2c3(0x65)]);}_0x2ce76a[_0xf2c3(0x66)](_0x462d9d,0x0)&&console[_0xf2c3(0xa)](_0xf2c3(0x67)+_0x462d9d+_0xf2c3(0x68)+_0x52c7c8+'\x20token\x20failure');}async['replaceTokenForType'](_0x265cb3,_0x572024){const _0x57e7cc={'uMVuD':function(_0x2ca2be,_0x5a931e,_0x3a6885){return _0x2ca2be(_0x5a931e,_0x3a6885);}};console[_0xf2c3(0xa)](_0xf2c3(0x69)+_0x265cb3+_0xf2c3(0x12)),this[_0xf2c3(0x3d)](_0x265cb3);const _0xb6db57=await _0x57e7cc[_0xf2c3(0x6a)](replaceJWTAfterVerification,_0x265cb3,_0x572024);return _0xb6db57&&console[_0xf2c3(0xa)](_0xf2c3(0x6b)+_0x265cb3+_0xf2c3(0x6c)),_0xb6db57;}async[_0xf2c3(0x6d)](){const _0x1be1f4={'PZfOG':_0xf2c3(0x46),'uqSpu':_0xf2c3(0x6e),'MMhTP':function(_0x4713c4){return _0x4713c4();},'kBNfR':function(_0x4bd252,_0x59ff5a){return _0x4bd252!==_0x59ff5a;},'cSIGo':_0xf2c3(0x6f)};console[_0xf2c3(0xa)](_0x1be1f4[_0xf2c3(0x70)]);const _0x26613f=await _0x1be1f4[_0xf2c3(0x71)](getAllTokens);for(const [_0x450d7c,_0x104696]of Object[_0xf2c3(0x61)](_0x26613f)){_0x104696?_0x1be1f4[_0xf2c3(0x72)](_0x1be1f4[_0xf2c3(0x73)],_0xf2c3(0x74))?console[_0xf2c3(0xa)](_0xf2c3(0xb)+_0x450d7c+':\x20'+_0x104696[_0xf2c3(0xc)](0x0,0x14)+'...\x20(length:\x20'+_0x104696[_0xf2c3(0xe)]+')'):_0xeb7a53[_0xf2c3(0x56)](_0x1be1f4[_0xf2c3(0x75)]):console[_0xf2c3(0xa)]('📭\x20'+_0x450d7c+_0xf2c3(0x76));}return _0x26613f;}[_0xf2c3(0x77)](_0x4b8f0c){const _0x438e18={'uajhp':_0xf2c3(0x78)};this[_0xf2c3(0x1)]={...this[_0xf2c3(0x1)],..._0x4b8f0c},console[_0xf2c3(0xa)](_0x438e18[_0xf2c3(0x79)]);}async['get'](_0x4d86c3,_0x1bbf8f={}){return this['request'](_0x4d86c3,{..._0x1bbf8f,'method':'GET'});}async[_0xf2c3(0x7a)](_0x2bdb5e,_0x35210c,_0x17566e={}){return this[_0xf2c3(0x2)](_0x2bdb5e,{..._0x17566e,'method':'POST','body':_0x35210c});}async[_0xf2c3(0x7b)](_0x2a458c,_0x20cfc0,_0xe43aac={}){return this['request'](_0x2a458c,{..._0xe43aac,'method':'PUT','body':_0x20cfc0});}async['delete'](_0x1eb5aa,_0x51b748={}){return this['request'](_0x1eb5aa,{..._0x51b748,'method':'DELETE'});}}export const apiClient=new ApiClient();export{ApiClient};export const authenticatedRequest=apiClient[_0xf2c3(0x2)][_0xf2c3(0x7c)](apiClient);export const apiGet=apiClient[_0xf2c3(0x7d)][_0xf2c3(0x7c)](apiClient);function _0x8086(){const _0x42dc0f=['BASE_URL','authTriggers','request','UdwCl','IXuHw','Request\x20cancelled','set','SvTkd','Ssqif','wrgfL','log','🔐\x20','substring','...\x20(length:\x20','length','🔗\x20[API\x20Client]\x20Starting\x20request\x20','PrdaK','🎯\x20[API\x20Client]\x20Route\x20','\x20token','getRequestHeaders','gSQli','requiresAuth','method','qBtMD','headers','body','stringify','🔐\x20[API\x20Client]\x20Request\x20','RNVDm','baseUrl','📡\x20[API\x20Client]\x20Response\x20','status','Nbccd','handle401Error','json','DCFQr','zyCxQ','Request\x20failed\x20with\x20status\x20','delete','hOwTw','name','🚫\x20[API\x20Client]\x20Request\x20','\x20was\x20cancelled','WilQt','message','error','❌\x20[API\x20Client]\x20Request\x20','\x20failed:','MIeco','enCzD','dGRlQ','UjxSK','ayMoB','\x20token\x20available\x20for\x20route\x20','.\x20Please\x20authenticate\x20first.','⚠️\x20[API\x20Client]\x20No\x20auth\x20token\x20refresh\x20trigger\x20configured','\x20received\x20401\x20for\x20','\x20token\x20on\x20route:\x20','🔄\x20[API\x20Client]\x20Clearing\x20','\x20token\x20due\x20to\x20401\x20error','lHDsL','cancelRequestsForTokenType','triggerReAuthForTokenType','\x20token\x20cleared,\x20user\x20needs\x20to\x20re-authenticate','\x20authentication\x20expired\x20for\x20','.\x20Please\x20re-authenticate.','Unknown\x20error','wARib','📧\x20[API\x20Client]\x20Triggering\x20Enoch\x20email\x20re-verification','elaII','⚠️\x20[API\x20Client]\x20No\x20Enoch\x20re-auth\x20trigger\x20configured','kJLdE','🔑\x20[API\x20Client]\x20Triggering\x20Onairos\x20re-authentication','FLAIT','⚠️\x20[API\x20Client]\x20No\x20Onairos\x20re-auth\x20trigger\x20configured','tAwVI','🔄\x20[API\x20Client]\x20Triggering\x20re-auth\x20for\x20','sTHXO','XVGol','jtxmV','abort','ENOCH','zrZSo','triggerEnochReAuth','WayHV','Jgtzk','warn','ziPhe','ONAIROS','triggerOnairosReAuth','qQsfF','oAQDP','qroer','ZeWxw','triggerAuthTokenRefresh','DUhcw','🔄\x20[API\x20Client]\x20Triggering\x20auth\x20token\x20refresh','entries','wWdAc','TXooD','PsrQb','RjfeO','ezRpv','🚫\x20[API\x20Client]\x20Cancelled\x20','\x20requests\x20due\x20to\x20','🔄\x20[API\x20Client]\x20Replacing\x20','uMVuD','✅\x20[API\x20Client]\x20','\x20token\x20replaced\x20and\x20related\x20requests\x20cancelled','debugTokens','🔍\x20[API\x20Client]\x20Debug:\x20Current\x20token\x20status','WqDyw','uqSpu','MMhTP','kBNfR','cSIGo','CSHvs','PZfOG',':\x20null','setAuthTriggers','🔧\x20[API\x20Client]\x20Authentication\x20triggers\x20updated','uajhp','post','put','bind','get'];_0x8086=function(){return _0x42dc0f;};return _0x8086();}export const apiPost=apiClient[_0xf2c3(0x7a)][_0xf2c3(0x7c)](apiClient);export const apiPut=apiClient[_0xf2c3(0x7b)]['bind'](apiClient);export const apiDelete=apiClient[_0xf2c3(0x26)][_0xf2c3(0x7c)](apiClient);export default apiClient;
1
+ import { getJWTForRoute, TokenType, getTokenTypeForRoute, clearJWT, getAllTokens, replaceJWTAfterVerification } from './jwtStorageService';
2
+ import { API_CONFIG } from '../config/api';
3
+
4
+ /**
5
+ * Centralized API Client with Route-Based JWT Token Management
6
+ * CORRECTED APPROACH: Uses different JWT tokens for different route families
7
+ *
8
+ * TOKEN ROUTING:
9
+ * - Enoch JWT: /enoch/*, /api/auth/*, /mobile-training/enoch
10
+ * - Onairos JWT: /youtube/*, /gmail/*, social connections
11
+ * - Auth Token: Context-specific auth flows
12
+ */
13
+
14
+ /**
15
+ * Global request counter for tracking in-flight requests
16
+ */
17
+ let currentRequestId = 0;
18
+ const activeRequests = new Map();
19
+
20
+ /**
21
+ * Route-specific authentication triggers
22
+ */
23
+
24
+ /**
25
+ * Create API client with route-based token management
26
+ */
27
+ class ApiClient {
28
+ constructor(baseUrl = API_CONFIG.BASE_URL, authTriggers = {}) {
29
+ this.baseUrl = baseUrl;
30
+ this.authTriggers = authTriggers;
31
+ }
32
+
33
+ /**
34
+ * Make authenticated API request with route-based token selection
35
+ * CRITICAL: Uses the correct token type based on route
36
+ */
37
+ async request(endpoint, options = {}) {
38
+ const requestId = ++currentRequestId;
39
+ const abortController = new AbortController();
40
+ activeRequests.set(requestId, abortController);
41
+ try {
42
+ console.log(`🔗 [API Client] Starting request ${requestId} to: ${endpoint}`);
43
+
44
+ // CRITICAL FIX: Determine which token type to use based on route
45
+ const tokenType = getTokenTypeForRoute(endpoint);
46
+ console.log(`🎯 [API Client] Route ${endpoint} requires ${tokenType} token`);
47
+
48
+ // Get route-specific headers
49
+ const headers = await this.getRequestHeaders(endpoint, options.requiresAuth !== false);
50
+ const fetchOptions = {
51
+ method: options.method || 'GET',
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ 'User-Agent': 'OnairosSDK/1.0.0',
55
+ ...headers,
56
+ ...options.headers
57
+ },
58
+ body: options.body ? JSON.stringify(options.body) : undefined,
59
+ signal: abortController.signal
60
+ };
61
+ console.log(`🔐 [API Client] Request ${requestId} using ${tokenType} token`);
62
+ const response = await fetch(`${this.baseUrl}${endpoint}`, fetchOptions);
63
+ console.log(`📡 [API Client] Response ${requestId} status:`, response.status);
64
+
65
+ // CRITICAL FIX: Route-specific 401 handler
66
+ if (response.status === 401) {
67
+ return await this.handle401Error(requestId, endpoint, tokenType, options);
68
+ }
69
+ const result = await response.json();
70
+ activeRequests.delete(requestId);
71
+ if (!response.ok) {
72
+ return {
73
+ success: false,
74
+ error: result.message || `Request failed with status ${response.status}`,
75
+ status: response.status,
76
+ tokenType
77
+ };
78
+ }
79
+ return {
80
+ success: true,
81
+ data: result,
82
+ status: response.status,
83
+ tokenType
84
+ };
85
+ } catch (error) {
86
+ activeRequests.delete(requestId);
87
+ if (error instanceof Error && error.name === 'AbortError') {
88
+ console.log(`🚫 [API Client] Request ${requestId} was cancelled`);
89
+ return {
90
+ success: false,
91
+ error: 'Request cancelled',
92
+ status: 0
93
+ };
94
+ }
95
+ console.error(`❌ [API Client] Request ${requestId} failed:`, error);
96
+ return {
97
+ success: false,
98
+ error: error instanceof Error ? error.message : 'Unknown error',
99
+ status: 0
100
+ };
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Get request headers with route-appropriate token
106
+ * CRITICAL: Selects correct token based on route
107
+ */
108
+ async getRequestHeaders(endpoint, requiresAuth) {
109
+ if (!requiresAuth) {
110
+ return {};
111
+ }
112
+
113
+ // CRITICAL FIX: Get token specifically for this route
114
+ const token = await getJWTForRoute(endpoint);
115
+ if (!token) {
116
+ const tokenType = getTokenTypeForRoute(endpoint);
117
+ throw new Error(`No ${tokenType} token available for route ${endpoint}. Please authenticate first.`);
118
+ }
119
+ return {
120
+ 'Authorization': token
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Handle 401 errors with route-specific re-authentication
126
+ * CRITICAL FIX: Different auth flows for different token types
127
+ */
128
+ async handle401Error(requestId, endpoint, tokenType, options) {
129
+ console.error(`🚫 [API Client] Request ${requestId} received 401 for ${tokenType} token on route: ${endpoint}`);
130
+
131
+ // CRITICAL FIX: Clear only the specific token type that failed
132
+ console.log(`🔄 [API Client] Clearing ${tokenType} token due to 401 error`);
133
+ await clearJWT(tokenType);
134
+
135
+ // Cancel requests using the same token type
136
+ this.cancelRequestsForTokenType(tokenType, requestId);
137
+
138
+ // CRITICAL FIX: Route-specific re-authentication
139
+ await this.triggerReAuthForTokenType(tokenType, endpoint);
140
+ console.log(`🔑 [API Client] ${tokenType} token cleared, user needs to re-authenticate`);
141
+ return {
142
+ success: false,
143
+ error: `${tokenType} authentication expired for ${endpoint}. Please re-authenticate.`,
144
+ status: 401,
145
+ tokenType
146
+ };
147
+ }
148
+
149
+ /**
150
+ * Trigger appropriate re-authentication based on token type
151
+ */
152
+ async triggerReAuthForTokenType(tokenType, endpoint) {
153
+ console.log(`🔄 [API Client] Triggering re-auth for ${tokenType} token (endpoint: ${endpoint})`);
154
+ try {
155
+ switch (tokenType) {
156
+ case TokenType.ENOCH:
157
+ if (this.authTriggers.triggerEnochReAuth) {
158
+ console.log('📧 [API Client] Triggering Enoch email re-verification');
159
+ await this.authTriggers.triggerEnochReAuth();
160
+ } else {
161
+ console.warn('⚠️ [API Client] No Enoch re-auth trigger configured');
162
+ }
163
+ break;
164
+ case TokenType.ONAIROS:
165
+ if (this.authTriggers.triggerOnairosReAuth) {
166
+ console.log('🔑 [API Client] Triggering Onairos re-authentication');
167
+ await this.authTriggers.triggerOnairosReAuth();
168
+ } else {
169
+ console.warn('⚠️ [API Client] No Onairos re-auth trigger configured');
170
+ }
171
+ break;
172
+ case TokenType.AUTH:
173
+ if (this.authTriggers.triggerAuthTokenRefresh) {
174
+ console.log('🔄 [API Client] Triggering auth token refresh');
175
+ await this.authTriggers.triggerAuthTokenRefresh();
176
+ } else {
177
+ console.warn('⚠️ [API Client] No auth token refresh trigger configured');
178
+ }
179
+ break;
180
+ }
181
+ } catch (error) {
182
+ console.error(`❌ [API Client] Failed to trigger re-auth for ${tokenType}:`, error);
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Cancel requests using a specific token type
188
+ */
189
+ cancelRequestsForTokenType(tokenType, excludeRequestId) {
190
+ let cancelledCount = 0;
191
+
192
+ // Note: In a full implementation, we'd track which requests use which tokens
193
+ // For now, we cancel all other requests as a safety measure
194
+ for (const [requestId, controller] of activeRequests.entries()) {
195
+ if (requestId !== excludeRequestId) {
196
+ controller.abort();
197
+ activeRequests.delete(requestId);
198
+ cancelledCount++;
199
+ }
200
+ }
201
+ if (cancelledCount > 0) {
202
+ console.log(`🚫 [API Client] Cancelled ${cancelledCount} requests due to ${tokenType} token failure`);
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Replace token for specific type and cancel related requests
208
+ */
209
+ async replaceTokenForType(tokenType, newToken) {
210
+ console.log(`🔄 [API Client] Replacing ${tokenType} token`);
211
+
212
+ // Cancel all in-flight requests using this token type
213
+ this.cancelRequestsForTokenType(tokenType);
214
+
215
+ // Replace token using storage service
216
+ const replaced = await replaceJWTAfterVerification(tokenType, newToken);
217
+ if (replaced) {
218
+ console.log(`✅ [API Client] ${tokenType} token replaced and related requests cancelled`);
219
+ }
220
+ return replaced;
221
+ }
222
+
223
+ /**
224
+ * Debug: Get all current tokens
225
+ */
226
+ async debugTokens() {
227
+ console.log('🔍 [API Client] Debug: Current token status');
228
+ const tokens = await getAllTokens();
229
+ for (const [tokenType, token] of Object.entries(tokens)) {
230
+ if (token) {
231
+ console.log(`🔐 ${tokenType}: ${token.substring(0, 20)}... (length: ${token.length})`);
232
+ } else {
233
+ console.log(`📭 ${tokenType}: null`);
234
+ }
235
+ }
236
+ return tokens;
237
+ }
238
+
239
+ /**
240
+ * Set authentication triggers
241
+ */
242
+ setAuthTriggers(triggers) {
243
+ this.authTriggers = {
244
+ ...this.authTriggers,
245
+ ...triggers
246
+ };
247
+ console.log('🔧 [API Client] Authentication triggers updated');
248
+ }
249
+
250
+ /**
251
+ * Convenience methods for common HTTP verbs
252
+ */
253
+ async get(endpoint, options = {}) {
254
+ return this.request(endpoint, {
255
+ ...options,
256
+ method: 'GET'
257
+ });
258
+ }
259
+ async post(endpoint, body, options = {}) {
260
+ return this.request(endpoint, {
261
+ ...options,
262
+ method: 'POST',
263
+ body
264
+ });
265
+ }
266
+ async put(endpoint, body, options = {}) {
267
+ return this.request(endpoint, {
268
+ ...options,
269
+ method: 'PUT',
270
+ body
271
+ });
272
+ }
273
+ async delete(endpoint, options = {}) {
274
+ return this.request(endpoint, {
275
+ ...options,
276
+ method: 'DELETE'
277
+ });
278
+ }
279
+ }
280
+
281
+ // SINGLE INSTANCE - Global API client
282
+ export const apiClient = new ApiClient();
283
+ export { ApiClient };
284
+
285
+ // Export convenience functions
286
+ export const authenticatedRequest = apiClient.request.bind(apiClient);
287
+ export const apiGet = apiClient.get.bind(apiClient);
288
+ export const apiPost = apiClient.post.bind(apiClient);
289
+ export const apiPut = apiClient.put.bind(apiClient);
290
+ export const apiDelete = apiClient.delete.bind(apiClient);
291
+
292
+ // Export types for external use
293
+
294
+ export default apiClient;
295
+ //# sourceMappingURL=apiClient.js.map