@onairos/react-native 3.7.2 → 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 (237) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/components/BodyText.js +27 -9
  3. package/lib/commonjs/components/BrandMark.js +111 -10
  4. package/lib/commonjs/components/CodeInput.js +116 -9
  5. package/lib/commonjs/components/EmailInput.js +30 -8
  6. package/lib/commonjs/components/GoogleButton.js +56 -9
  7. package/lib/commonjs/components/HeadingGroup.js +43 -9
  8. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  9. package/lib/commonjs/components/ModalHeader.js +99 -9
  10. package/lib/commonjs/components/ModalSheet.js +47 -9
  11. package/lib/commonjs/components/Onairos.js +380 -14
  12. package/lib/commonjs/components/OnairosButton.js +313 -13
  13. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  14. package/lib/commonjs/components/Overlay.js +465 -13
  15. package/lib/commonjs/components/PersonaImage.js +137 -10
  16. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  17. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  18. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  19. package/lib/commonjs/components/PinInput.js +464 -9
  20. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  21. package/lib/commonjs/components/PlatformList.js +137 -10
  22. package/lib/commonjs/components/PlatformToggle.js +180 -9
  23. package/lib/commonjs/components/PrimaryButton.js +180 -10
  24. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  25. package/lib/commonjs/components/SignInStep.js +345 -12
  26. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  27. package/lib/commonjs/components/VerificationStep.js +176 -11
  28. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  29. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  30. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  31. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  32. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  33. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  34. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  35. package/lib/commonjs/components/icons/EnochE.js +41 -8
  36. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  37. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  38. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  39. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  40. package/lib/commonjs/components/icons/index.js +84 -17
  41. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  42. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  43. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  44. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  45. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  46. package/lib/commonjs/config/api.js +56 -7
  47. package/lib/commonjs/constants/index.js +120 -7
  48. package/lib/commonjs/context/AuthContext.js +345 -10
  49. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  50. package/lib/commonjs/hooks/useConnections.js +102 -8
  51. package/lib/commonjs/hooks/useCredentials.js +178 -10
  52. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  53. package/lib/commonjs/index.js +439 -34
  54. package/lib/commonjs/services/apiClient.js +298 -8
  55. package/lib/commonjs/services/biometricPinService.js +180 -8
  56. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  57. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  58. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  59. package/lib/commonjs/services/claudeConversationService.js +158 -9
  60. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  61. package/lib/commonjs/services/googleAuthService.js +252 -11
  62. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  63. package/lib/commonjs/services/hingeDataService.js +150 -9
  64. package/lib/commonjs/services/imageCompressionService.js +260 -7
  65. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  66. package/lib/commonjs/services/instagramDataService.js +163 -9
  67. package/lib/commonjs/services/jwtStorageService.js +276 -7
  68. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  69. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  70. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  71. package/lib/commonjs/services/llmDataStorage.js +294 -8
  72. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  73. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  74. package/lib/commonjs/services/netflixDataService.js +198 -9
  75. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  76. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  77. package/lib/commonjs/services/platformAuthService.js +1484 -12
  78. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  79. package/lib/commonjs/services/sephoraDataService.js +200 -9
  80. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  81. package/lib/commonjs/services/spotifyDataService.js +241 -9
  82. package/lib/commonjs/services/storageService.js +404 -8
  83. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  84. package/lib/commonjs/services/telegramDataService.js +499 -9
  85. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  86. package/lib/commonjs/services/userConnectionsService.js +340 -10
  87. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  88. package/lib/commonjs/theme/index.js +250 -7
  89. package/lib/commonjs/types/ambient.d.js +2 -1
  90. package/lib/commonjs/types/declarations.d.js +2 -1
  91. package/lib/commonjs/types/index.js +6 -1
  92. package/lib/commonjs/types/node-fix.d.js +2 -1
  93. package/lib/commonjs/types/node-override.d.js +2 -1
  94. package/lib/commonjs/types/opacity.d.js +2 -1
  95. package/lib/commonjs/types.js +14 -1
  96. package/lib/commonjs/utils/Portal.js +98 -8
  97. package/lib/commonjs/utils/api.js +130 -9
  98. package/lib/commonjs/utils/assetRegistry.js +210 -35
  99. package/lib/commonjs/utils/auth.js +112 -9
  100. package/lib/commonjs/utils/connectorTests.js +613 -29
  101. package/lib/commonjs/utils/crypto.js +62 -8
  102. package/lib/commonjs/utils/debugHelper.js +64 -1
  103. package/lib/commonjs/utils/encryption.js +76 -7
  104. package/lib/commonjs/utils/eventUtils.js +288 -1
  105. package/lib/commonjs/utils/haptics.js +66 -9
  106. package/lib/commonjs/utils/imagePreloader.js +6 -1
  107. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  108. package/lib/commonjs/utils/onairosApi.js +350 -9
  109. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  110. package/lib/commonjs/utils/retryHelper.js +220 -1
  111. package/lib/commonjs/utils/secureStorage.js +349 -10
  112. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  113. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  114. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  115. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  116. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  117. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  118. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  119. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  120. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  121. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  122. package/lib/module/api/index.js +211 -1
  123. package/lib/module/components/BodyText.js +20 -1
  124. package/lib/module/components/BrandMark.js +104 -1
  125. package/lib/module/components/CodeInput.js +109 -1
  126. package/lib/module/components/EmailInput.js +23 -1
  127. package/lib/module/components/GoogleButton.js +49 -1
  128. package/lib/module/components/HeadingGroup.js +36 -1
  129. package/lib/module/components/LLMDataInputModal.js +656 -7
  130. package/lib/module/components/ModalHeader.js +92 -1
  131. package/lib/module/components/ModalSheet.js +39 -1
  132. package/lib/module/components/Onairos.js +373 -1
  133. package/lib/module/components/OnairosButton.js +305 -1
  134. package/lib/module/components/OnairosSignInButton.js +121 -1
  135. package/lib/module/components/Overlay.js +456 -1
  136. package/lib/module/components/PersonaImage.js +129 -1
  137. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  138. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  139. package/lib/module/components/PinCreationScreen.js +396 -1
  140. package/lib/module/components/PinInput.js +456 -1
  141. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  142. package/lib/module/components/PlatformList.js +129 -1
  143. package/lib/module/components/PlatformToggle.js +173 -1
  144. package/lib/module/components/PrimaryButton.js +172 -1
  145. package/lib/module/components/SignInMatchAnimation.js +189 -1
  146. package/lib/module/components/SignInStep.js +338 -1
  147. package/lib/module/components/UniversalOnboarding.js +2770 -1
  148. package/lib/module/components/VerificationStep.js +168 -1
  149. package/lib/module/components/WelcomeScreen.js +453 -1
  150. package/lib/module/components/icons/Basicproficon.js +30 -1
  151. package/lib/module/components/icons/Basicprofile.js +14 -1
  152. package/lib/module/components/icons/Checkbox.js +14 -1
  153. package/lib/module/components/icons/Checkmark.js +20 -1
  154. package/lib/module/components/icons/Contentanalysis.js +14 -1
  155. package/lib/module/components/icons/Contenticon.js +32 -1
  156. package/lib/module/components/icons/EnochE.js +34 -1
  157. package/lib/module/components/icons/Personalityicon.js +23 -1
  158. package/lib/module/components/icons/Personalityprofile.js +14 -1
  159. package/lib/module/components/icons/Personalitytraits.js +14 -1
  160. package/lib/module/components/icons/Userpreferences.js +14 -1
  161. package/lib/module/components/icons/index.js +13 -1
  162. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  163. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  164. package/lib/module/components/onboarding/PinInput.js +274 -1
  165. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  166. package/lib/module/config/PLATFORM_APIS.md +849 -0
  167. package/lib/module/config/api.js +47 -1
  168. package/lib/module/constants/index.js +114 -1
  169. package/lib/module/context/AuthContext.js +335 -1
  170. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  171. package/lib/module/hooks/useConnections.js +95 -1
  172. package/lib/module/hooks/useCredentials.js +171 -6
  173. package/lib/module/hooks/useUserConnections.js +140 -1
  174. package/lib/module/index.js +172 -1
  175. package/lib/module/services/apiClient.js +295 -1
  176. package/lib/module/services/biometricPinService.js +169 -1
  177. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  178. package/lib/module/services/chatGPTConversationService.js +268 -1
  179. package/lib/module/services/claudeConversationExtractor.js +97 -1
  180. package/lib/module/services/claudeConversationService.js +151 -1
  181. package/lib/module/services/connectedAccountsService.js +293 -1
  182. package/lib/module/services/googleAuthService.js +241 -1
  183. package/lib/module/services/hingeDataExtractor.js +99 -1
  184. package/lib/module/services/hingeDataService.js +143 -1
  185. package/lib/module/services/imageCompressionService.js +250 -1
  186. package/lib/module/services/instagramDataExtractor.js +120 -1
  187. package/lib/module/services/instagramDataService.js +156 -1
  188. package/lib/module/services/jwtStorageService.js +257 -1
  189. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  190. package/lib/module/services/linkedinProfileService.js +210 -1
  191. package/lib/module/services/linkedinScrapingService.js +219 -1
  192. package/lib/module/services/llmDataStorage.js +277 -1
  193. package/lib/module/services/mobileTrainingService.js +173 -1
  194. package/lib/module/services/netflixDataExtractor.js +114 -1
  195. package/lib/module/services/netflixDataService.js +191 -1
  196. package/lib/module/services/pinEncryptionService.js +74 -6
  197. package/lib/module/services/pinStorageUtils.js +93 -1
  198. package/lib/module/services/platformAuthService.js +1461 -1
  199. package/lib/module/services/sephoraDataExtractor.js +134 -1
  200. package/lib/module/services/sephoraDataService.js +193 -1
  201. package/lib/module/services/spotifyDataExtractor.js +142 -1
  202. package/lib/module/services/spotifyDataService.js +234 -1
  203. package/lib/module/services/storageService.js +383 -1
  204. package/lib/module/services/telegramDataExtractor.js +109 -1
  205. package/lib/module/services/telegramDataService.js +493 -1
  206. package/lib/module/services/trainingApiHelpers.js +67 -1
  207. package/lib/module/services/userConnectionsService.js +329 -1
  208. package/lib/module/services/youtubeMigrationService.js +405 -1
  209. package/lib/module/theme/index.js +245 -1
  210. package/lib/module/types.js +10 -1
  211. package/lib/module/utils/Portal.js +90 -1
  212. package/lib/module/utils/api.js +118 -1
  213. package/lib/module/utils/assetRegistry.js +200 -34
  214. package/lib/module/utils/auth.js +100 -1
  215. package/lib/module/utils/connectorTests.js +600 -27
  216. package/lib/module/utils/crypto.js +54 -1
  217. package/lib/module/utils/debugHelper.js +54 -1
  218. package/lib/module/utils/encryption.js +67 -1
  219. package/lib/module/utils/eventUtils.js +270 -1
  220. package/lib/module/utils/haptics.js +59 -8
  221. package/lib/module/utils/imagePreloader.js +3 -1
  222. package/lib/module/utils/networkDiagnostics.js +217 -1
  223. package/lib/module/utils/onairosApi.js +333 -1
  224. package/lib/module/utils/programmaticFlow.js +111 -1
  225. package/lib/module/utils/retryHelper.js +211 -1
  226. package/lib/module/utils/secureStorage.js +330 -6
  227. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  228. package/lib/module/utils/webviewScripts/claude.js +370 -1
  229. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  230. package/lib/module/utils/webviewScripts/index.js +434 -1
  231. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  232. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  233. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  234. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  235. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  236. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  237. package/package.json +2 -2
@@ -1 +1,172 @@
1
- console[_0x2932(0x0)]('🚀\x20[ONAIROS\x20SDK]\x20LOCAL\x20SDK\x20LOADED\x20-\x20Version\x205.0.0-local-dev'),console['log']('\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';export{updateGoogleClientIds}from'./services/googleAuthService';function _0x58f0(){var _0x3478fe=['log'];_0x58f0=function(){return _0x3478fe;};return _0x58f0();}export{testApiConnectivity}from'./services/platformAuthService';export{runFullDiagnostics,isApiReachable,getNetworkStatus}from'./utils/networkDiagnostics';function _0x2932(_0x58f030,_0x29325f){_0x58f030=_0x58f030-0x0;var _0x4539b7=_0x58f0();var _0x4e450d=_0x4539b7[_0x58f030];return _0x4e450d;}export{scrapeLinkedInProfile,extractLinkedInUsername,isValidLinkedInUrl,formatLinkedInUrl,canScrapeProfile,getLinkedInConnectionStatus}from'./services/linkedinScrapingService';export{parseExtractionMessage,initiateProfileScraping,checkScrapingStatus,validateExtractedUrl,completeLinkedInExtraction}from'./services/linkedinDOMExtractor';export{ApiClient}from'./services/apiClient';
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';let currentRequestId=0x0;const activeRequests=new Map();function _0x53f4(){const _0x4d545a=['BASE_URL','baseUrl','authTriggers','request','IzzqB','Unknown\x20error','log','\x20to:\x20','pRlRL','🎯\x20[API\x20Client]\x20Route\x20','\x20requires\x20','requiresAuth','method','hsfzN','headers','body','stringify','signal','🔐\x20[API\x20Client]\x20Request\x20','\x20status:','status','hvlUY','handle401Error','json','delete','HhyWO','XAzIg','cLrxB','error','message','Request\x20failed\x20with\x20status\x20','MgCYp','aIVgO','name','🚫\x20[API\x20Client]\x20Request\x20','erSUI','\x20failed:','rzoyS','getRequestHeaders','lGByB','BnaVg','.\x20Please\x20authenticate\x20first.','split','Cpnre','\x20authentication\x20expired\x20for\x20','.\x20Please\x20re-authenticate.','🔑\x20[API\x20Client]\x20','\x20token\x20cleared,\x20user\x20needs\x20to\x20re-authenticate','🔄\x20[API\x20Client]\x20Clearing\x20','\x20token\x20due\x20to\x20401\x20error','cancelRequestsForTokenType','triggerReAuthForTokenType','\x20received\x20401\x20for\x20','\x20token\x20on\x20route:\x20','⚠️\x20[API\x20Client]\x20No\x20Enoch\x20re-auth\x20trigger\x20configured','nPKIF','🔄\x20[API\x20Client]\x20Triggering\x20auth\x20token\x20refresh','⚠️\x20[API\x20Client]\x20No\x20auth\x20token\x20refresh\x20trigger\x20configured','BegVG','🔄\x20[API\x20Client]\x20Triggering\x20re-auth\x20for\x20','ENOCH','warn','oJZCf','ONAIROS','cKAQN','zMnTi','CnfxK','triggerAuthTokenRefresh','yDAhr','❌\x20[API\x20Client]\x20Failed\x20to\x20trigger\x20re-auth\x20for\x20','🚫\x20[API\x20Client]\x20Cancelled\x20','\x20token\x20failure','entries','abort','GxSbH','\x20requests\x20due\x20to\x20','replaceTokenForType','JKdQj','zTeYh','kquEJ','KHLUF','ERkER','Rurdv','dDQcM','fZZSq','✅\x20[API\x20Client]\x20','\x20token\x20replaced\x20and\x20related\x20requests\x20cancelled','🔍\x20[API\x20Client]\x20Debug:\x20Current\x20token\x20status','IygTb','xjvUg','zpLCb','URJLf','JKJql','cRkre','🔐\x20','substring','length','📭\x20',':\x20null','setAuthTriggers','get','post','put','bind'];_0x53f4=function(){return _0x4d545a;};return _0x53f4();}class ApiClient{constructor(_0x1cb8d8=API_CONFIG[_0x565f(0x0)],_0x509f80={}){this[_0x565f(0x1)]=_0x1cb8d8,this[_0x565f(0x2)]=_0x509f80;}async[_0x565f(0x3)](_0x12339e,_0x62a225={}){const _0x2620c3={'pRlRL':function(_0x13555a,_0x4f42a4){return _0x13555a(_0x4f42a4);},'KQDbG':function(_0x2f6fed,_0x335309){return _0x2f6fed!==_0x335309;},'hsfzN':'OnairosSDK/1.0.0','hvlUY':function(_0x4f07bc,_0x481a8d){return _0x4f07bc===_0x481a8d;},'HhyWO':function(_0xfbb63c,_0xe81f64){return _0xfbb63c===_0xe81f64;},'XAzIg':_0x565f(0x4),'MgCYp':function(_0x5bc579,_0x56405a){return _0x5bc579 instanceof _0x56405a;},'aIVgO':function(_0x2fd141,_0x4efc68){return _0x2fd141===_0x4efc68;},'erSUI':'Request\x20cancelled','rzoyS':_0x565f(0x5)},_0xaf79a0=++currentRequestId,_0x439820=new AbortController();activeRequests['set'](_0xaf79a0,_0x439820);try{console[_0x565f(0x6)]('🔗\x20[API\x20Client]\x20Starting\x20request\x20'+_0xaf79a0+_0x565f(0x7)+_0x12339e);const _0x34c8ce=_0x2620c3[_0x565f(0x8)](getTokenTypeForRoute,_0x12339e);console['log'](_0x565f(0x9)+_0x12339e+_0x565f(0xa)+_0x34c8ce+'\x20token');const _0x3cfa54=await this['getRequestHeaders'](_0x12339e,_0x2620c3['KQDbG'](_0x62a225[_0x565f(0xb)],![])),_0x1616eb={'method':_0x62a225[_0x565f(0xc)]||'GET','headers':{'Content-Type':'application/json','User-Agent':_0x2620c3[_0x565f(0xd)],..._0x3cfa54,..._0x62a225[_0x565f(0xe)]},'body':_0x62a225[_0x565f(0xf)]?JSON[_0x565f(0x10)](_0x62a225['body']):undefined,'signal':_0x439820[_0x565f(0x11)]};console[_0x565f(0x6)](_0x565f(0x12)+_0xaf79a0+'\x20using\x20'+_0x34c8ce+'\x20token');const _0x1a1364=await fetch(''+this[_0x565f(0x1)]+_0x12339e,_0x1616eb);console[_0x565f(0x6)]('📡\x20[API\x20Client]\x20Response\x20'+_0xaf79a0+_0x565f(0x13),_0x1a1364[_0x565f(0x14)]);if(_0x2620c3[_0x565f(0x15)](_0x1a1364['status'],0x191))return await this[_0x565f(0x16)](_0xaf79a0,_0x12339e,_0x34c8ce,_0x62a225);const _0x45b95b=await _0x1a1364[_0x565f(0x17)]();activeRequests[_0x565f(0x18)](_0xaf79a0);if(!_0x1a1364['ok']){if(_0x2620c3[_0x565f(0x19)](_0x2620c3[_0x565f(0x1a)],_0x565f(0x1b)))_0x2bf213[_0x565f(0x1c)]('❌\x20[API\x20Client]\x20Failed\x20to\x20trigger\x20re-auth\x20for\x20'+_0x36d24b+':',_0x82d3d1);else return{'success':![],'error':_0x45b95b[_0x565f(0x1d)]||_0x565f(0x1e)+_0x1a1364[_0x565f(0x14)],'status':_0x1a1364['status'],'tokenType':_0x34c8ce};}return{'success':!![],'data':_0x45b95b,'status':_0x1a1364[_0x565f(0x14)],'tokenType':_0x34c8ce};}catch(_0x29d119){activeRequests['delete'](_0xaf79a0);if(_0x2620c3[_0x565f(0x1f)](_0x29d119,Error)&&_0x2620c3[_0x565f(0x20)](_0x29d119[_0x565f(0x21)],'AbortError'))return console[_0x565f(0x6)](_0x565f(0x22)+_0xaf79a0+'\x20was\x20cancelled'),{'success':![],'error':_0x2620c3[_0x565f(0x23)],'status':0x0};return console['error']('❌\x20[API\x20Client]\x20Request\x20'+_0xaf79a0+_0x565f(0x24),_0x29d119),{'success':![],'error':_0x29d119 instanceof Error?_0x29d119[_0x565f(0x1d)]:_0x2620c3[_0x565f(0x25)],'status':0x0};}}async[_0x565f(0x26)](_0xc669d4,_0x2d667a){const _0x1f1102={'lDBqP':function(_0x3085cc,_0x23e186){return _0x3085cc!==_0x23e186;},'BnaVg':function(_0x5a2d90,_0x2f3f26){return _0x5a2d90(_0x2f3f26);}};if(!_0x2d667a)return{};const _0x3fa455=await getJWTForRoute(_0xc669d4);if(!_0x3fa455){if(_0x1f1102['lDBqP'](_0x565f(0x27),'lpFeS')){const _0x24643d=_0x1f1102[_0x565f(0x28)](getTokenTypeForRoute,_0xc669d4);throw new Error('No\x20'+_0x24643d+'\x20token\x20available\x20for\x20route\x20'+_0xc669d4+_0x565f(0x29));}else this['baseUrl']=_0x52079c,this[_0x565f(0x2)]=_0x14c6cb;}return{'Authorization':_0x3fa455};}async['handle401Error'](_0x534ef7,_0x559ba1,_0x4c7431,_0x280a7b){const _0xcd5558={'Gitru':'6|3|0|4|5|2|1','Cpnre':function(_0x3d9095,_0xf8cecf){return _0x3d9095(_0xf8cecf);}},_0x577582=_0xcd5558['Gitru'][_0x565f(0x2a)]('|');let _0x1277b2=0x0;while(!![]){switch(_0x577582[_0x1277b2++]){case'0':await _0xcd5558[_0x565f(0x2b)](clearJWT,_0x4c7431);continue;case'1':return{'success':![],'error':_0x4c7431+_0x565f(0x2c)+_0x559ba1+_0x565f(0x2d),'status':0x191,'tokenType':_0x4c7431};case'2':console[_0x565f(0x6)](_0x565f(0x2e)+_0x4c7431+_0x565f(0x2f));continue;case'3':console[_0x565f(0x6)](_0x565f(0x30)+_0x4c7431+_0x565f(0x31));continue;case'4':this[_0x565f(0x32)](_0x4c7431,_0x534ef7);continue;case'5':await this[_0x565f(0x33)](_0x4c7431,_0x559ba1);continue;case'6':console[_0x565f(0x1c)](_0x565f(0x22)+_0x534ef7+_0x565f(0x34)+_0x4c7431+_0x565f(0x35)+_0x559ba1);continue;}break;}}async[_0x565f(0x33)](_0x1890b6,_0x1c2cec){const _0x19842b={'oJZCf':_0x565f(0x36),'cKAQN':function(_0x31ed5b,_0x178e9b){return _0x31ed5b!==_0x178e9b;},'pUpjo':'gLoWc','Plefi':_0x565f(0x37),'FfQHM':'zMnTi','CnfxK':_0x565f(0x38),'ReRYX':_0x565f(0x39),'RicPl':_0x565f(0x3a)};console[_0x565f(0x6)](_0x565f(0x3b)+_0x1890b6+'\x20token\x20(endpoint:\x20'+_0x1c2cec+')');try{switch(_0x1890b6){case TokenType[_0x565f(0x3c)]:this['authTriggers']['triggerEnochReAuth']?(console['log']('📧\x20[API\x20Client]\x20Triggering\x20Enoch\x20email\x20re-verification'),await this['authTriggers']['triggerEnochReAuth']()):console[_0x565f(0x3d)](_0x19842b[_0x565f(0x3e)]);break;case TokenType[_0x565f(0x3f)]:if(this[_0x565f(0x2)]['triggerOnairosReAuth']){if(_0x19842b[_0x565f(0x40)](_0x19842b['pUpjo'],_0x19842b['Plefi']))console[_0x565f(0x6)]('🔑\x20[API\x20Client]\x20Triggering\x20Onairos\x20re-authentication'),await this['authTriggers']['triggerOnairosReAuth']();else return this['request'](_0x135b83,{..._0x81385d,'method':'PUT','body':_0x52d8ce});}else console[_0x565f(0x3d)]('⚠️\x20[API\x20Client]\x20No\x20Onairos\x20re-auth\x20trigger\x20configured');break;case TokenType['AUTH']:if(this[_0x565f(0x2)]['triggerAuthTokenRefresh']){if(_0x19842b['cKAQN'](_0x19842b['FfQHM'],_0x565f(0x41)))return{'success':![],'error':_0x5616c3['message']||_0x565f(0x1e)+_0x201ee2[_0x565f(0x14)],'status':_0x2d22db[_0x565f(0x14)],'tokenType':_0x35f744};else console[_0x565f(0x6)](_0x19842b[_0x565f(0x42)]),await this['authTriggers'][_0x565f(0x43)]();}else console['warn'](_0x19842b['ReRYX']);break;}}catch(_0x4fa54a){_0x19842b[_0x565f(0x40)](_0x19842b['RicPl'],_0x565f(0x44))?console[_0x565f(0x1c)](_0x565f(0x45)+_0x1890b6+':',_0x4fa54a):_0x495c6d[_0x565f(0x6)](_0x565f(0x46)+_0x1678e5+'\x20requests\x20due\x20to\x20'+_0x16cc48+_0x565f(0x47));}}[_0x565f(0x32)](_0x37790e,_0x2421f7){const _0x4f5a57={'GxSbH':function(_0x27881b,_0x2d4fff){return _0x27881b>_0x2d4fff;}};let _0x3620ef=0x0;for(const [_0x3d30ee,_0x1849e5]of activeRequests[_0x565f(0x48)]()){_0x3d30ee!==_0x2421f7&&(_0x1849e5[_0x565f(0x49)](),activeRequests[_0x565f(0x18)](_0x3d30ee),_0x3620ef++);}_0x4f5a57[_0x565f(0x4a)](_0x3620ef,0x0)&&console[_0x565f(0x6)](_0x565f(0x46)+_0x3620ef+_0x565f(0x4b)+_0x37790e+_0x565f(0x47));}async[_0x565f(0x4c)](_0x2c7f1b,_0x4d7913){const _0x1d026c={'dDQcM':function(_0x44b769,_0x5c70e4){return _0x44b769!==_0x5c70e4;},'fZZSq':function(_0x28e91e,_0x2bd2ac){return _0x28e91e>_0x2bd2ac;},'kquEJ':function(_0x4c7b07,_0x450413,_0x200759){return _0x4c7b07(_0x450413,_0x200759);},'KHLUF':function(_0x20d76f,_0xbd4ae3){return _0x20d76f===_0xbd4ae3;},'ERkER':_0x565f(0x4d),'Rurdv':_0x565f(0x4e)};console[_0x565f(0x6)]('🔄\x20[API\x20Client]\x20Replacing\x20'+_0x2c7f1b+'\x20token'),this[_0x565f(0x32)](_0x2c7f1b);const _0xdb22d4=await _0x1d026c[_0x565f(0x4f)](replaceJWTAfterVerification,_0x2c7f1b,_0x4d7913);if(_0xdb22d4){if(_0x1d026c[_0x565f(0x50)](_0x1d026c[_0x565f(0x51)],_0x1d026c[_0x565f(0x52)])){let _0x1dcbc4=0x0;for(const [_0x10c070,_0x3d1965]of _0x143cff[_0x565f(0x48)]()){_0x1d026c[_0x565f(0x53)](_0x10c070,_0x55269)&&(_0x3d1965[_0x565f(0x49)](),_0x139344[_0x565f(0x18)](_0x10c070),_0x1dcbc4++);}_0x1d026c[_0x565f(0x54)](_0x1dcbc4,0x0)&&_0x543451[_0x565f(0x6)](_0x565f(0x46)+_0x1dcbc4+'\x20requests\x20due\x20to\x20'+_0x17a916+_0x565f(0x47));}else console[_0x565f(0x6)](_0x565f(0x55)+_0x2c7f1b+_0x565f(0x56));}return _0xdb22d4;}async['debugTokens'](){const _0x200f76={'xjvUg':_0x565f(0x57),'zpLCb':function(_0x322002){return _0x322002();},'URJLf':function(_0x106aca,_0x18ba86){return _0x106aca===_0x18ba86;},'JKJql':_0x565f(0x58)};console[_0x565f(0x6)](_0x200f76[_0x565f(0x59)]);const _0x1b4365=await _0x200f76[_0x565f(0x5a)](getAllTokens);for(const [_0x2c9aeb,_0x17f920]of Object['entries'](_0x1b4365)){if(_0x17f920){if(_0x200f76[_0x565f(0x5b)](_0x200f76[_0x565f(0x5c)],_0x565f(0x5d)))return this[_0x565f(0x3)](_0x3d3375,{..._0xd72381,'method':'GET'});else console['log'](_0x565f(0x5e)+_0x2c9aeb+':\x20'+_0x17f920[_0x565f(0x5f)](0x0,0x14)+'...\x20(length:\x20'+_0x17f920[_0x565f(0x60)]+')');}else console[_0x565f(0x6)](_0x565f(0x61)+_0x2c9aeb+_0x565f(0x62));}return _0x1b4365;}[_0x565f(0x63)](_0xdb10fd){this[_0x565f(0x2)]={...this[_0x565f(0x2)],..._0xdb10fd},console[_0x565f(0x6)]('🔧\x20[API\x20Client]\x20Authentication\x20triggers\x20updated');}async[_0x565f(0x64)](_0xfcbdfe,_0x4ff803={}){return this[_0x565f(0x3)](_0xfcbdfe,{..._0x4ff803,'method':'GET'});}async[_0x565f(0x65)](_0x4164a9,_0x17a3bd,_0x1d053e={}){return this[_0x565f(0x3)](_0x4164a9,{..._0x1d053e,'method':'POST','body':_0x17a3bd});}async[_0x565f(0x66)](_0x87de20,_0x11f5df,_0x365b94={}){return this[_0x565f(0x3)](_0x87de20,{..._0x365b94,'method':'PUT','body':_0x11f5df});}async[_0x565f(0x18)](_0x43f1d4,_0x2c24f7={}){return this[_0x565f(0x3)](_0x43f1d4,{..._0x2c24f7,'method':'DELETE'});}}export const apiClient=new ApiClient();export{ApiClient};export const authenticatedRequest=apiClient['request'][_0x565f(0x67)](apiClient);export const apiGet=apiClient[_0x565f(0x64)][_0x565f(0x67)](apiClient);export const apiPost=apiClient['post']['bind'](apiClient);export const apiPut=apiClient[_0x565f(0x66)][_0x565f(0x67)](apiClient);function _0x565f(_0x53f45a,_0x565f02){_0x53f45a=_0x53f45a-0x0;const _0x1be063=_0x53f4();let _0x109cce=_0x1be063[_0x53f45a];return _0x109cce;}export const apiDelete=apiClient[_0x565f(0x18)]['bind'](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