@onairos/react-native 3.4.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (574) hide show
  1. package/README.md +423 -374
  2. package/lib/commonjs/api/index.js +9 -145
  3. package/lib/commonjs/assets/animations/loaderani.json +1 -0
  4. package/lib/commonjs/assets/animations/persona-animation.json +1 -0
  5. package/lib/commonjs/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  6. package/lib/commonjs/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  7. package/lib/commonjs/assets/icons/Facebookicon.png +0 -0
  8. package/lib/commonjs/assets/icons/Gmail.png +0 -0
  9. package/lib/commonjs/assets/icons/Linkedinicon.png +0 -0
  10. package/lib/commonjs/assets/icons/Redditicon.png +0 -0
  11. package/lib/commonjs/assets/icons/YouTubeicon2.png +0 -0
  12. package/lib/commonjs/assets/icons/YouTubeicon3.png +0 -0
  13. package/lib/commonjs/assets/icons/chatgpt.png +0 -0
  14. package/lib/commonjs/assets/icons/claude.png +0 -0
  15. package/lib/commonjs/assets/icons/gemini.png +0 -0
  16. package/lib/commonjs/assets/icons/grok.png +0 -0
  17. package/lib/commonjs/assets/images/Checkbox.svg +3 -0
  18. package/lib/commonjs/assets/images/EnochE.svg +19 -0
  19. package/lib/commonjs/assets/images/Enochicon1.png +0 -0
  20. package/lib/commonjs/assets/images/Face_ID_logo.png +0 -0
  21. package/lib/commonjs/assets/images/Facebookicon.png +0 -0
  22. package/lib/commonjs/assets/images/Gmail.png +0 -0
  23. package/lib/commonjs/assets/images/Googlelogo.png +0 -0
  24. package/lib/commonjs/assets/images/Linkedinicon.png +0 -0
  25. package/lib/commonjs/assets/images/OnairosNewLogo.png +0 -0
  26. package/lib/commonjs/assets/images/Onairoslogo.png +0 -0
  27. package/lib/commonjs/assets/images/Personalityprofile.svg +3 -0
  28. package/lib/commonjs/assets/images/Personalitytraits.svg +3 -0
  29. package/lib/commonjs/assets/images/Redditicon.png +0 -0
  30. package/lib/commonjs/assets/images/Userpreferences.svg +3 -0
  31. package/lib/commonjs/assets/images/YouTubeicon3.png +0 -0
  32. package/lib/commonjs/assets/images/arrow.svg +20 -0
  33. package/lib/commonjs/assets/images/basicproficon.svg +43 -0
  34. package/lib/commonjs/assets/images/basicprofile.svg +3 -0
  35. package/lib/commonjs/assets/images/chatgpt.png +0 -0
  36. package/lib/commonjs/assets/images/checkmark.svg +4 -0
  37. package/lib/commonjs/assets/images/claude.png +0 -0
  38. package/lib/commonjs/assets/images/contentanalysis.svg +3 -0
  39. package/lib/commonjs/assets/images/contenticon.svg +23 -0
  40. package/lib/commonjs/assets/images/gemini.png +0 -0
  41. package/lib/commonjs/assets/images/grok.png +0 -0
  42. package/lib/commonjs/assets/images/persona1.png +0 -0
  43. package/lib/commonjs/assets/images/persona2.png +0 -0
  44. package/lib/commonjs/assets/images/persona3.png +0 -0
  45. package/lib/commonjs/assets/images/persona4.png +0 -0
  46. package/lib/commonjs/assets/images/persona5.png +0 -0
  47. package/lib/commonjs/assets/images/personalityicon.svg +18 -0
  48. package/lib/commonjs/assets/images/x-close.svg +3 -0
  49. package/lib/commonjs/components/BodyText.js +9 -0
  50. package/lib/commonjs/components/BrandMark.js +10 -0
  51. package/lib/commonjs/components/CodeInput.js +9 -0
  52. package/lib/commonjs/components/EmailInput.js +8 -0
  53. package/lib/commonjs/components/GoogleButton.js +9 -0
  54. package/lib/commonjs/components/HeadingGroup.js +9 -0
  55. package/lib/commonjs/components/LLMDataInputModal.js +14 -0
  56. package/lib/commonjs/components/ModalHeader.js +9 -0
  57. package/lib/commonjs/components/ModalSheet.js +9 -0
  58. package/lib/commonjs/components/Onairos.js +14 -374
  59. package/lib/commonjs/components/OnairosButton.js +13 -309
  60. package/lib/commonjs/components/OnairosSignInButton.js +12 -0
  61. package/lib/commonjs/components/Overlay.js +13 -483
  62. package/lib/commonjs/components/PersonaImage.js +10 -0
  63. package/lib/commonjs/components/PersonaLoadingScreen.js +12 -0
  64. package/lib/commonjs/components/PersonalizationConsentScreen.js +13 -0
  65. package/lib/commonjs/components/PinCreationScreen.js +12 -0
  66. package/lib/commonjs/components/PinInput.js +9 -302
  67. package/lib/commonjs/components/PlatformConnectorsStep.js +23 -0
  68. package/lib/commonjs/components/PlatformList.js +10 -137
  69. package/lib/commonjs/components/PlatformToggle.js +9 -0
  70. package/lib/commonjs/components/PrimaryButton.js +10 -0
  71. package/lib/commonjs/components/SignInMatchAnimation.js +9 -0
  72. package/lib/commonjs/components/SignInStep.js +12 -0
  73. package/lib/commonjs/components/UniversalOnboarding.js +30 -1702
  74. package/lib/commonjs/components/VerificationStep.js +11 -0
  75. package/lib/commonjs/components/WelcomeScreen.js +22 -0
  76. package/lib/commonjs/components/icons/Basicproficon.js +8 -0
  77. package/lib/commonjs/components/icons/Basicprofile.js +8 -0
  78. package/lib/commonjs/components/icons/Checkbox.js +8 -0
  79. package/lib/commonjs/components/icons/Checkmark.js +8 -0
  80. package/lib/commonjs/components/icons/Contentanalysis.js +8 -0
  81. package/lib/commonjs/components/icons/Contenticon.js +8 -0
  82. package/lib/commonjs/components/icons/EnochE.js +8 -0
  83. package/lib/commonjs/components/icons/Personalityicon.js +8 -0
  84. package/lib/commonjs/components/icons/Personalityprofile.js +8 -0
  85. package/lib/commonjs/components/icons/Personalitytraits.js +8 -0
  86. package/lib/commonjs/components/icons/Userpreferences.js +8 -0
  87. package/lib/commonjs/components/icons/index.js +17 -0
  88. package/lib/commonjs/components/onboarding/OAuthWebView.js +18 -827
  89. package/lib/commonjs/components/onboarding/OnboardingHeader.js +10 -74
  90. package/lib/commonjs/components/onboarding/PinInput.js +10 -283
  91. package/lib/commonjs/components/onboarding/PlatformConnector.js +11 -249
  92. package/lib/commonjs/config/api.js +7 -0
  93. package/lib/commonjs/constants/index.js +7 -83
  94. package/lib/commonjs/context/AuthContext.js +10 -0
  95. package/lib/commonjs/hooks/useConnectedAccounts.js +9 -0
  96. package/lib/commonjs/hooks/useConnections.js +8 -159
  97. package/lib/commonjs/hooks/useCredentials.js +10 -177
  98. package/lib/commonjs/hooks/useUserConnections.js +10 -0
  99. package/lib/commonjs/index.js +34 -106
  100. package/lib/commonjs/services/SDK_API_KEY_VALIDATION.md +421 -421
  101. package/lib/commonjs/services/apiClient.js +8 -0
  102. package/lib/commonjs/services/apiKeyService.js +9 -952
  103. package/lib/commonjs/services/authService.js +10 -0
  104. package/lib/commonjs/services/biometricPinService.js +8 -0
  105. package/lib/commonjs/services/chatGPTConversationExtractor.js +8 -0
  106. package/lib/commonjs/services/chatGPTConversationService.js +9 -0
  107. package/lib/commonjs/services/claudeConversationExtractor.js +8 -0
  108. package/lib/commonjs/services/claudeConversationService.js +9 -0
  109. package/lib/commonjs/services/connectedAccountsService.js +10 -0
  110. package/lib/commonjs/services/googleAuthService.js +11 -0
  111. package/lib/commonjs/services/hingeDataExtractor.js +8 -0
  112. package/lib/commonjs/services/hingeDataService.js +9 -0
  113. package/lib/commonjs/services/imageCompressionService.js +7 -0
  114. package/lib/commonjs/services/instagramDataExtractor.js +8 -0
  115. package/lib/commonjs/services/instagramDataService.js +9 -0
  116. package/lib/commonjs/services/jwtStorageService.js +7 -0
  117. package/lib/commonjs/services/linkedinDOMExtractor.js +7 -0
  118. package/lib/commonjs/services/linkedinProfileService.js +9 -0
  119. package/lib/commonjs/services/linkedinScrapingService.js +8 -0
  120. package/lib/commonjs/services/llmDataStorage.js +8 -0
  121. package/lib/commonjs/services/mobileTrainingService.js +8 -0
  122. package/lib/commonjs/services/oauthService.js +11 -390
  123. package/lib/commonjs/services/pinEncryptionService.js +8 -0
  124. package/lib/commonjs/services/pinStorageUtils.js +7 -0
  125. package/lib/commonjs/services/platformAuthService.js +12 -1067
  126. package/lib/commonjs/services/sephoraDataExtractor.js +8 -0
  127. package/lib/commonjs/services/sephoraDataService.js +9 -0
  128. package/lib/commonjs/services/storageService.js +8 -0
  129. package/lib/commonjs/services/telegramDataExtractor.js +8 -0
  130. package/lib/commonjs/services/telegramDataService.js +11 -0
  131. package/lib/commonjs/services/trainingApiHelpers.js +7 -0
  132. package/lib/commonjs/services/userConnectionsService.js +10 -0
  133. package/lib/commonjs/services/youtubeMigrationService.js +10 -0
  134. package/lib/commonjs/theme/index.js +7 -0
  135. package/lib/commonjs/types/ambient.d.js +1 -2
  136. package/lib/commonjs/types/declarations.d.js +1 -2
  137. package/lib/commonjs/types/index.js +1 -6
  138. package/lib/commonjs/types/node-fix.d.js +1 -2
  139. package/lib/commonjs/types/node-override.d.js +1 -2
  140. package/lib/commonjs/types/opacity.d.js +1 -2
  141. package/lib/commonjs/types.js +1 -14
  142. package/lib/commonjs/utils/Portal.js +8 -98
  143. package/lib/commonjs/utils/api.js +9 -129
  144. package/lib/commonjs/utils/assetRegistry.js +33 -0
  145. package/lib/commonjs/utils/auth.js +9 -111
  146. package/lib/commonjs/utils/connectorTests.js +29 -0
  147. package/lib/commonjs/utils/crypto.js +8 -62
  148. package/lib/commonjs/utils/debugHelper.js +1 -64
  149. package/lib/commonjs/utils/encryption.js +7 -76
  150. package/lib/commonjs/utils/eventUtils.js +1 -0
  151. package/lib/commonjs/utils/haptics.js +9 -0
  152. package/lib/commonjs/utils/imagePreloader.js +1 -0
  153. package/lib/commonjs/utils/networkDiagnostics.js +8 -0
  154. package/lib/commonjs/utils/onairosApi.js +9 -350
  155. package/lib/commonjs/utils/programmaticFlow.js +9 -117
  156. package/lib/commonjs/utils/retryHelper.js +1 -220
  157. package/lib/commonjs/utils/secureStorage.js +10 -349
  158. package/lib/commonjs/utils/webviewScripts/chatgpt.js +1 -0
  159. package/lib/commonjs/utils/webviewScripts/claude.js +1 -0
  160. package/lib/commonjs/utils/webviewScripts/hinge.js +1 -0
  161. package/lib/commonjs/utils/webviewScripts/index.js +13 -0
  162. package/lib/commonjs/utils/webviewScripts/instagram.js +1 -0
  163. package/lib/commonjs/utils/webviewScripts/linkedin.js +1 -0
  164. package/lib/commonjs/utils/webviewScripts/sephora.js +1 -0
  165. package/lib/commonjs/utils/webviewScripts/telegram.js +1 -0
  166. package/lib/module/api/index.js +1 -139
  167. package/lib/module/assets/animations/loaderani.json +1 -0
  168. package/lib/module/assets/animations/persona-animation.json +1 -0
  169. package/lib/module/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  170. package/lib/module/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  171. package/lib/module/assets/icons/Facebookicon.png +0 -0
  172. package/lib/module/assets/icons/Gmail.png +0 -0
  173. package/lib/module/assets/icons/Linkedinicon.png +0 -0
  174. package/lib/module/assets/icons/Redditicon.png +0 -0
  175. package/lib/module/assets/icons/YouTubeicon2.png +0 -0
  176. package/lib/module/assets/icons/YouTubeicon3.png +0 -0
  177. package/lib/module/assets/icons/chatgpt.png +0 -0
  178. package/lib/module/assets/icons/claude.png +0 -0
  179. package/lib/module/assets/icons/farcaster.png +0 -0
  180. package/lib/module/assets/icons/gemini.png +0 -0
  181. package/lib/module/assets/icons/grok.png +0 -0
  182. package/lib/module/assets/icons/instagram.png +0 -0
  183. package/lib/module/assets/icons/pinterest.png +0 -0
  184. package/lib/module/assets/icons/swerv_logo.png +0 -0
  185. package/lib/module/assets/icons/twitter.jpg +0 -0
  186. package/lib/module/assets/images/Checkbox.svg +3 -0
  187. package/lib/module/assets/images/EnochE.svg +19 -0
  188. package/lib/module/assets/images/Enochicon1.png +0 -0
  189. package/lib/module/assets/images/Face_ID_logo.png +0 -0
  190. package/lib/module/assets/images/Facebookicon.png +0 -0
  191. package/lib/module/assets/images/Gmail.png +0 -0
  192. package/lib/module/assets/images/Googlelogo.png +0 -0
  193. package/lib/module/assets/images/Linkedinicon.png +0 -0
  194. package/lib/module/assets/images/OnairosNewLogo.png +0 -0
  195. package/lib/module/assets/images/Onairoslogo.png +0 -0
  196. package/lib/module/assets/images/Personalityprofile.svg +3 -0
  197. package/lib/module/assets/images/Personalitytraits.svg +3 -0
  198. package/lib/module/assets/images/Redditicon.png +0 -0
  199. package/lib/module/assets/images/Userpreferences.svg +3 -0
  200. package/lib/module/assets/images/YouTubeicon3.png +0 -0
  201. package/lib/module/assets/images/arrow.svg +20 -0
  202. package/lib/module/assets/images/basicproficon.svg +43 -0
  203. package/lib/module/assets/images/basicprofile.svg +3 -0
  204. package/lib/module/assets/images/chatgpt.png +0 -0
  205. package/lib/module/assets/images/checkmark.svg +4 -0
  206. package/lib/module/assets/images/claude.png +0 -0
  207. package/lib/module/assets/images/contentanalysis.svg +3 -0
  208. package/lib/module/assets/images/contenticon.svg +23 -0
  209. package/lib/module/assets/images/gemini.png +0 -0
  210. package/lib/module/assets/images/grok.png +0 -0
  211. package/lib/module/assets/images/persona1.png +0 -0
  212. package/lib/module/assets/images/persona2.png +0 -0
  213. package/lib/module/assets/images/persona3.png +0 -0
  214. package/lib/module/assets/images/persona4.png +0 -0
  215. package/lib/module/assets/images/persona5.png +0 -0
  216. package/lib/module/assets/images/personalityicon.svg +18 -0
  217. package/lib/module/assets/images/x-close.svg +3 -0
  218. package/lib/module/components/BodyText.js +1 -0
  219. package/lib/module/components/BrandMark.js +1 -0
  220. package/lib/module/components/CodeInput.js +1 -0
  221. package/lib/module/components/EmailInput.js +1 -0
  222. package/lib/module/components/GoogleButton.js +1 -0
  223. package/lib/module/components/HeadingGroup.js +1 -0
  224. package/lib/module/components/LLMDataInputModal.js +8 -0
  225. package/lib/module/components/ModalHeader.js +1 -0
  226. package/lib/module/components/ModalSheet.js +1 -0
  227. package/lib/module/components/Onairos.js +1 -367
  228. package/lib/module/components/OnairosButton.js +1 -302
  229. package/lib/module/components/OnairosSignInButton.js +1 -0
  230. package/lib/module/components/Overlay.js +1 -474
  231. package/lib/module/components/PersonaImage.js +1 -0
  232. package/lib/module/components/PersonaLoadingScreen.js +1 -0
  233. package/lib/module/components/PersonalizationConsentScreen.js +1 -0
  234. package/lib/module/components/PinCreationScreen.js +1 -0
  235. package/lib/module/components/PinInput.js +1 -293
  236. package/lib/module/components/PlatformConnectorsStep.js +7 -0
  237. package/lib/module/components/PlatformList.js +1 -129
  238. package/lib/module/components/PlatformToggle.js +1 -0
  239. package/lib/module/components/PrimaryButton.js +1 -0
  240. package/lib/module/components/SignInMatchAnimation.js +1 -0
  241. package/lib/module/components/SignInStep.js +1 -0
  242. package/lib/module/components/UniversalOnboarding.js +1 -1693
  243. package/lib/module/components/VerificationStep.js +1 -0
  244. package/lib/module/components/WelcomeScreen.js +1 -0
  245. package/lib/module/components/icons/Basicproficon.js +1 -0
  246. package/lib/module/components/icons/Basicprofile.js +1 -0
  247. package/lib/module/components/icons/Checkbox.js +1 -0
  248. package/lib/module/components/icons/Checkmark.js +1 -0
  249. package/lib/module/components/icons/Contentanalysis.js +1 -0
  250. package/lib/module/components/icons/Contenticon.js +1 -0
  251. package/lib/module/components/icons/EnochE.js +1 -0
  252. package/lib/module/components/icons/Personalityicon.js +1 -0
  253. package/lib/module/components/icons/Personalityprofile.js +1 -0
  254. package/lib/module/components/icons/Personalitytraits.js +1 -0
  255. package/lib/module/components/icons/Userpreferences.js +1 -0
  256. package/lib/module/components/icons/index.js +1 -0
  257. package/lib/module/components/onboarding/OAuthWebView.js +1 -818
  258. package/lib/module/components/onboarding/OnboardingHeader.js +1 -66
  259. package/lib/module/components/onboarding/PinInput.js +1 -274
  260. package/lib/module/components/onboarding/PlatformConnector.js +1 -240
  261. package/lib/module/config/api.js +1 -0
  262. package/lib/module/constants/index.js +1 -77
  263. package/lib/module/context/AuthContext.js +1 -0
  264. package/lib/module/hooks/useConnectedAccounts.js +1 -0
  265. package/lib/module/hooks/useConnections.js +1 -152
  266. package/lib/module/hooks/useCredentials.js +6 -169
  267. package/lib/module/hooks/useUserConnections.js +1 -0
  268. package/lib/module/index.js +1 -32
  269. package/lib/module/services/SDK_API_KEY_VALIDATION.md +421 -421
  270. package/lib/module/services/apiClient.js +1 -0
  271. package/lib/module/services/apiKeyService.js +1 -925
  272. package/lib/module/services/authService.js +1 -0
  273. package/lib/module/services/biometricPinService.js +1 -0
  274. package/lib/module/services/chatGPTConversationExtractor.js +1 -0
  275. package/lib/module/services/chatGPTConversationService.js +1 -0
  276. package/lib/module/services/claudeConversationExtractor.js +1 -0
  277. package/lib/module/services/claudeConversationService.js +1 -0
  278. package/lib/module/services/connectedAccountsService.js +1 -0
  279. package/lib/module/services/googleAuthService.js +1 -0
  280. package/lib/module/services/hingeDataExtractor.js +1 -0
  281. package/lib/module/services/hingeDataService.js +1 -0
  282. package/lib/module/services/imageCompressionService.js +1 -0
  283. package/lib/module/services/instagramDataExtractor.js +1 -0
  284. package/lib/module/services/instagramDataService.js +1 -0
  285. package/lib/module/services/jwtStorageService.js +1 -0
  286. package/lib/module/services/linkedinDOMExtractor.js +1 -0
  287. package/lib/module/services/linkedinProfileService.js +1 -0
  288. package/lib/module/services/linkedinScrapingService.js +1 -0
  289. package/lib/module/services/llmDataStorage.js +1 -0
  290. package/lib/module/services/mobileTrainingService.js +1 -0
  291. package/lib/module/services/oauthService.js +1 -380
  292. package/lib/module/services/pinEncryptionService.js +7 -0
  293. package/lib/module/services/pinStorageUtils.js +1 -0
  294. package/lib/module/services/platformAuthService.js +1 -1041
  295. package/lib/module/services/sephoraDataExtractor.js +1 -0
  296. package/lib/module/services/sephoraDataService.js +1 -0
  297. package/lib/module/services/storageService.js +1 -0
  298. package/lib/module/services/telegramDataExtractor.js +1 -0
  299. package/lib/module/services/telegramDataService.js +8 -0
  300. package/lib/module/services/trainingApiHelpers.js +1 -0
  301. package/lib/module/services/userConnectionsService.js +1 -0
  302. package/lib/module/services/youtubeMigrationService.js +1 -0
  303. package/lib/module/theme/index.js +1 -0
  304. package/lib/module/types.js +1 -10
  305. package/lib/module/utils/Portal.js +1 -90
  306. package/lib/module/utils/api.js +1 -117
  307. package/lib/module/utils/assetRegistry.js +33 -0
  308. package/lib/module/utils/auth.js +1 -99
  309. package/lib/module/utils/connectorTests.js +28 -0
  310. package/lib/module/utils/crypto.js +1 -54
  311. package/lib/module/utils/debugHelper.js +1 -54
  312. package/lib/module/utils/encryption.js +1 -67
  313. package/lib/module/utils/eventUtils.js +1 -0
  314. package/lib/module/utils/haptics.js +8 -0
  315. package/lib/module/utils/imagePreloader.js +1 -0
  316. package/lib/module/utils/networkDiagnostics.js +1 -0
  317. package/lib/module/utils/onairosApi.js +1 -333
  318. package/lib/module/utils/programmaticFlow.js +1 -111
  319. package/lib/module/utils/retryHelper.js +1 -211
  320. package/lib/module/utils/secureStorage.js +6 -330
  321. package/lib/module/utils/webviewScripts/chatgpt.js +1 -0
  322. package/lib/module/utils/webviewScripts/claude.js +1 -0
  323. package/lib/module/utils/webviewScripts/hinge.js +1 -0
  324. package/lib/module/utils/webviewScripts/index.js +1 -0
  325. package/lib/module/utils/webviewScripts/instagram.js +1 -0
  326. package/lib/module/utils/webviewScripts/linkedin.js +1 -0
  327. package/lib/module/utils/webviewScripts/sephora.js +1 -0
  328. package/lib/module/utils/webviewScripts/telegram.js +1 -0
  329. package/package.json +62 -39
  330. package/lib/commonjs/api/index.js.map +0 -1
  331. package/lib/commonjs/assets/images/email.png +0 -0
  332. package/lib/commonjs/assets/images/linkedin.png +0 -0
  333. package/lib/commonjs/assets/images/reddit.png +0 -0
  334. package/lib/commonjs/assets/images/youtube.png +0 -0
  335. package/lib/commonjs/components/DataRequestModal.js +0 -228
  336. package/lib/commonjs/components/DataRequestModal.js.map +0 -1
  337. package/lib/commonjs/components/DataRequestScreen.js +0 -329
  338. package/lib/commonjs/components/DataRequestScreen.js.map +0 -1
  339. package/lib/commonjs/components/EmailVerificationModal.js +0 -320
  340. package/lib/commonjs/components/EmailVerificationModal.js.map +0 -1
  341. package/lib/commonjs/components/Onairos.js.map +0 -1
  342. package/lib/commonjs/components/OnairosButton.js.map +0 -1
  343. package/lib/commonjs/components/Overlay.js.map +0 -1
  344. package/lib/commonjs/components/PinInput.js.map +0 -1
  345. package/lib/commonjs/components/PlatformList.js.map +0 -1
  346. package/lib/commonjs/components/TrainingModal.js +0 -717
  347. package/lib/commonjs/components/TrainingModal.js.map +0 -1
  348. package/lib/commonjs/components/UniversalOnboarding.js.map +0 -1
  349. package/lib/commonjs/components/UniversalOnboarding.tsx.new +0 -455
  350. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +0 -1
  351. package/lib/commonjs/components/onboarding/OnboardingHeader.js.map +0 -1
  352. package/lib/commonjs/components/onboarding/PinInput.js.map +0 -1
  353. package/lib/commonjs/components/onboarding/PlatformConnector.js.map +0 -1
  354. package/lib/commonjs/components/screens/ConnectorScreen.js +0 -146
  355. package/lib/commonjs/components/screens/ConnectorScreen.js.map +0 -1
  356. package/lib/commonjs/components/screens/LoadingScreen.js +0 -91
  357. package/lib/commonjs/components/screens/LoadingScreen.js.map +0 -1
  358. package/lib/commonjs/components/screens/PinCreationScreen.js +0 -61
  359. package/lib/commonjs/components/screens/PinCreationScreen.js.map +0 -1
  360. package/lib/commonjs/constants/index.js.map +0 -1
  361. package/lib/commonjs/hooks/useConnections.js.map +0 -1
  362. package/lib/commonjs/hooks/useCredentials.js.map +0 -1
  363. package/lib/commonjs/index.js.map +0 -1
  364. package/lib/commonjs/services/apiKeyService.js.map +0 -1
  365. package/lib/commonjs/services/oauthService.js.map +0 -1
  366. package/lib/commonjs/services/platformAuthService.js.map +0 -1
  367. package/lib/commonjs/types/ambient.d.js.map +0 -1
  368. package/lib/commonjs/types/declarations.d.js.map +0 -1
  369. package/lib/commonjs/types/index.d.js.map +0 -1
  370. package/lib/commonjs/types/index.js.map +0 -1
  371. package/lib/commonjs/types/node-fix.d.js.map +0 -1
  372. package/lib/commonjs/types/node-override.d.js.map +0 -1
  373. package/lib/commonjs/types/opacity.d.js.map +0 -1
  374. package/lib/commonjs/types/types.d.js.map +0 -1
  375. package/lib/commonjs/types.js.map +0 -1
  376. package/lib/commonjs/utils/Portal.js.map +0 -1
  377. package/lib/commonjs/utils/api.js.map +0 -1
  378. package/lib/commonjs/utils/auth.js.map +0 -1
  379. package/lib/commonjs/utils/crypto.js.map +0 -1
  380. package/lib/commonjs/utils/debugHelper.js.map +0 -1
  381. package/lib/commonjs/utils/encryption.js.map +0 -1
  382. package/lib/commonjs/utils/onairosApi.js.map +0 -1
  383. package/lib/commonjs/utils/programmaticFlow.js.map +0 -1
  384. package/lib/commonjs/utils/retryHelper.js.map +0 -1
  385. package/lib/commonjs/utils/secureStorage.js.map +0 -1
  386. package/lib/module/api/index.js.map +0 -1
  387. package/lib/module/assets/images/email.png +0 -0
  388. package/lib/module/assets/images/linkedin.png +0 -0
  389. package/lib/module/assets/images/reddit.png +0 -0
  390. package/lib/module/assets/images/youtube.png +0 -0
  391. package/lib/module/components/DataRequestModal.js +0 -220
  392. package/lib/module/components/DataRequestModal.js.map +0 -1
  393. package/lib/module/components/DataRequestScreen.js +0 -321
  394. package/lib/module/components/DataRequestScreen.js.map +0 -1
  395. package/lib/module/components/EmailVerificationModal.js +0 -311
  396. package/lib/module/components/EmailVerificationModal.js.map +0 -1
  397. package/lib/module/components/Onairos.js.map +0 -1
  398. package/lib/module/components/OnairosButton.js.map +0 -1
  399. package/lib/module/components/Overlay.js.map +0 -1
  400. package/lib/module/components/PinInput.js.map +0 -1
  401. package/lib/module/components/PlatformList.js.map +0 -1
  402. package/lib/module/components/TrainingModal.js +0 -708
  403. package/lib/module/components/TrainingModal.js.map +0 -1
  404. package/lib/module/components/UniversalOnboarding.js.map +0 -1
  405. package/lib/module/components/UniversalOnboarding.tsx.new +0 -455
  406. package/lib/module/components/onboarding/OAuthWebView.js.map +0 -1
  407. package/lib/module/components/onboarding/OnboardingHeader.js.map +0 -1
  408. package/lib/module/components/onboarding/PinInput.js.map +0 -1
  409. package/lib/module/components/onboarding/PlatformConnector.js.map +0 -1
  410. package/lib/module/components/screens/ConnectorScreen.js +0 -138
  411. package/lib/module/components/screens/ConnectorScreen.js.map +0 -1
  412. package/lib/module/components/screens/LoadingScreen.js +0 -83
  413. package/lib/module/components/screens/LoadingScreen.js.map +0 -1
  414. package/lib/module/components/screens/PinCreationScreen.js +0 -53
  415. package/lib/module/components/screens/PinCreationScreen.js.map +0 -1
  416. package/lib/module/constants/index.js.map +0 -1
  417. package/lib/module/hooks/useConnections.js.map +0 -1
  418. package/lib/module/hooks/useCredentials.js.map +0 -1
  419. package/lib/module/index.js.map +0 -1
  420. package/lib/module/services/apiKeyService.js.map +0 -1
  421. package/lib/module/services/oauthService.js.map +0 -1
  422. package/lib/module/services/platformAuthService.js.map +0 -1
  423. package/lib/module/types/ambient.d.js.map +0 -1
  424. package/lib/module/types/declarations.d.js.map +0 -1
  425. package/lib/module/types/index.d.js.map +0 -1
  426. package/lib/module/types/index.js.map +0 -1
  427. package/lib/module/types/node-fix.d.js.map +0 -1
  428. package/lib/module/types/node-override.d.js.map +0 -1
  429. package/lib/module/types/opacity.d.js.map +0 -1
  430. package/lib/module/types/types.d.js.map +0 -1
  431. package/lib/module/types.js.map +0 -1
  432. package/lib/module/utils/Portal.js.map +0 -1
  433. package/lib/module/utils/api.js.map +0 -1
  434. package/lib/module/utils/auth.js.map +0 -1
  435. package/lib/module/utils/crypto.js.map +0 -1
  436. package/lib/module/utils/debugHelper.js.map +0 -1
  437. package/lib/module/utils/encryption.js.map +0 -1
  438. package/lib/module/utils/onairosApi.js.map +0 -1
  439. package/lib/module/utils/programmaticFlow.js.map +0 -1
  440. package/lib/module/utils/retryHelper.js.map +0 -1
  441. package/lib/module/utils/secureStorage.js.map +0 -1
  442. package/lib/typescript/api/index.d.ts +0 -8
  443. package/lib/typescript/api/index.d.ts.map +0 -1
  444. package/lib/typescript/components/DataRequestModal.d.ts +0 -11
  445. package/lib/typescript/components/DataRequestModal.d.ts.map +0 -1
  446. package/lib/typescript/components/DataRequestScreen.d.ts +0 -11
  447. package/lib/typescript/components/DataRequestScreen.d.ts.map +0 -1
  448. package/lib/typescript/components/EmailVerificationModal.d.ts +0 -11
  449. package/lib/typescript/components/EmailVerificationModal.d.ts.map +0 -1
  450. package/lib/typescript/components/Onairos.d.ts +0 -4
  451. package/lib/typescript/components/Onairos.d.ts.map +0 -1
  452. package/lib/typescript/components/OnairosButton.d.ts +0 -12
  453. package/lib/typescript/components/OnairosButton.d.ts.map +0 -1
  454. package/lib/typescript/components/Overlay.d.ts +0 -4
  455. package/lib/typescript/components/Overlay.d.ts.map +0 -1
  456. package/lib/typescript/components/PinInput.d.ts +0 -4
  457. package/lib/typescript/components/PinInput.d.ts.map +0 -1
  458. package/lib/typescript/components/PlatformList.d.ts +0 -4
  459. package/lib/typescript/components/PlatformList.d.ts.map +0 -1
  460. package/lib/typescript/components/TrainingModal.d.ts +0 -4
  461. package/lib/typescript/components/TrainingModal.d.ts.map +0 -1
  462. package/lib/typescript/components/UniversalOnboarding.d.ts +0 -4
  463. package/lib/typescript/components/UniversalOnboarding.d.ts.map +0 -1
  464. package/lib/typescript/components/onboarding/OAuthWebView.d.ts +0 -10
  465. package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +0 -1
  466. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +0 -11
  467. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts.map +0 -1
  468. package/lib/typescript/components/onboarding/PinInput.d.ts +0 -4
  469. package/lib/typescript/components/onboarding/PinInput.d.ts.map +0 -1
  470. package/lib/typescript/components/onboarding/PlatformConnector.d.ts +0 -13
  471. package/lib/typescript/components/onboarding/PlatformConnector.d.ts.map +0 -1
  472. package/lib/typescript/components/screens/ConnectorScreen.d.ts +0 -9
  473. package/lib/typescript/components/screens/ConnectorScreen.d.ts.map +0 -1
  474. package/lib/typescript/components/screens/LoadingScreen.d.ts +0 -9
  475. package/lib/typescript/components/screens/LoadingScreen.d.ts.map +0 -1
  476. package/lib/typescript/components/screens/PinCreationScreen.d.ts +0 -10
  477. package/lib/typescript/components/screens/PinCreationScreen.d.ts.map +0 -1
  478. package/lib/typescript/constants/index.d.ts +0 -53
  479. package/lib/typescript/constants/index.d.ts.map +0 -1
  480. package/lib/typescript/hooks/useConnections.d.ts +0 -9
  481. package/lib/typescript/hooks/useConnections.d.ts.map +0 -1
  482. package/lib/typescript/hooks/useCredentials.d.ts +0 -9
  483. package/lib/typescript/hooks/useCredentials.d.ts.map +0 -1
  484. package/lib/typescript/index.d.ts +0 -18
  485. package/lib/typescript/index.d.ts.map +0 -1
  486. package/lib/typescript/services/apiKeyService.d.ts +0 -132
  487. package/lib/typescript/services/apiKeyService.d.ts.map +0 -1
  488. package/lib/typescript/services/oauthService.d.ts +0 -50
  489. package/lib/typescript/services/oauthService.d.ts.map +0 -1
  490. package/lib/typescript/services/platformAuthService.d.ts +0 -144
  491. package/lib/typescript/services/platformAuthService.d.ts.map +0 -1
  492. package/lib/typescript/types/index.d.ts +0 -231
  493. package/lib/typescript/types/index.d.ts.map +0 -1
  494. package/lib/typescript/types.d.ts +0 -270
  495. package/lib/typescript/types.d.ts.map +0 -1
  496. package/lib/typescript/utils/Portal.d.ts +0 -14
  497. package/lib/typescript/utils/Portal.d.ts.map +0 -1
  498. package/lib/typescript/utils/api.d.ts +0 -6
  499. package/lib/typescript/utils/api.d.ts.map +0 -1
  500. package/lib/typescript/utils/auth.d.ts +0 -6
  501. package/lib/typescript/utils/auth.d.ts.map +0 -1
  502. package/lib/typescript/utils/crypto.d.ts +0 -4
  503. package/lib/typescript/utils/crypto.d.ts.map +0 -1
  504. package/lib/typescript/utils/debugHelper.d.ts +0 -29
  505. package/lib/typescript/utils/debugHelper.d.ts.map +0 -1
  506. package/lib/typescript/utils/encryption.d.ts +0 -19
  507. package/lib/typescript/utils/encryption.d.ts.map +0 -1
  508. package/lib/typescript/utils/onairosApi.d.ts +0 -87
  509. package/lib/typescript/utils/onairosApi.d.ts.map +0 -1
  510. package/lib/typescript/utils/programmaticFlow.d.ts +0 -23
  511. package/lib/typescript/utils/programmaticFlow.d.ts.map +0 -1
  512. package/lib/typescript/utils/retryHelper.d.ts +0 -69
  513. package/lib/typescript/utils/retryHelper.d.ts.map +0 -1
  514. package/lib/typescript/utils/secureStorage.d.ts +0 -94
  515. package/lib/typescript/utils/secureStorage.d.ts.map +0 -1
  516. package/src/api/index.ts +0 -111
  517. package/src/assets/images/email.png +0 -0
  518. package/src/assets/images/linkedin.png +0 -0
  519. package/src/assets/images/onairos_logo.png +0 -0
  520. package/src/assets/images/reddit.png +0 -0
  521. package/src/assets/images/youtube.png +0 -0
  522. package/src/components/DataRequestModal.tsx +0 -227
  523. package/src/components/DataRequestScreen.tsx +0 -356
  524. package/src/components/EmailVerificationModal.tsx +0 -364
  525. package/src/components/Onairos.tsx +0 -425
  526. package/src/components/OnairosButton.tsx +0 -359
  527. package/src/components/Overlay.tsx +0 -506
  528. package/src/components/PinInput.tsx +0 -343
  529. package/src/components/PlatformList.tsx +0 -145
  530. package/src/components/TrainingModal.tsx +0 -737
  531. package/src/components/UniversalOnboarding.tsx +0 -1839
  532. package/src/components/UniversalOnboarding.tsx.new +0 -455
  533. package/src/components/onboarding/OAuthWebView.tsx +0 -838
  534. package/src/components/onboarding/OnboardingHeader.tsx +0 -70
  535. package/src/components/onboarding/PinInput.tsx +0 -356
  536. package/src/components/onboarding/PlatformConnector.tsx +0 -302
  537. package/src/components/screens/ConnectorScreen.tsx +0 -153
  538. package/src/components/screens/LoadingScreen.tsx +0 -100
  539. package/src/components/screens/PinCreationScreen.tsx +0 -67
  540. package/src/constants/index.ts +0 -83
  541. package/src/hooks/useConnections.ts +0 -163
  542. package/src/hooks/useCredentials.ts +0 -175
  543. package/src/index.js +0 -14
  544. package/src/index.ts +0 -50
  545. package/src/services/SDK_API_KEY_VALIDATION.md +0 -421
  546. package/src/services/apiKeyService.ts +0 -984
  547. package/src/services/oauthService.ts +0 -412
  548. package/src/services/platformAuthService.ts +0 -1113
  549. package/src/types/ambient.d.ts +0 -29
  550. package/src/types/declarations.d.ts +0 -26
  551. package/src/types/index.d.ts +0 -274
  552. package/src/types/index.ts +0 -244
  553. package/src/types/node-fix.d.ts +0 -19
  554. package/src/types/node-override.d.ts +0 -24
  555. package/src/types/opacity.d.ts +0 -16
  556. package/src/types/types.d.ts +0 -18
  557. package/src/types.ts +0 -298
  558. package/src/utils/Portal.tsx +0 -83
  559. package/src/utils/api.js +0 -112
  560. package/src/utils/auth.js +0 -104
  561. package/src/utils/crypto.js +0 -60
  562. package/src/utils/debugHelper.ts +0 -53
  563. package/src/utils/encryption.ts +0 -69
  564. package/src/utils/onairosApi.ts +0 -391
  565. package/src/utils/programmaticFlow.ts +0 -113
  566. package/src/utils/retryHelper.ts +0 -275
  567. package/src/utils/secureStorage.ts +0 -361
  568. package/types/index.d.ts +0 -218
  569. package/types/node-env.d.ts +0 -15
  570. /package/{src/assets/images → lib/commonjs/assets/icons}/farcaster.png +0 -0
  571. /package/{src/assets/images → lib/commonjs/assets/icons}/instagram.png +0 -0
  572. /package/{src/assets/images → lib/commonjs/assets/icons}/pinterest.png +0 -0
  573. /package/{src/assets/images → lib/commonjs/assets/icons}/swerv_logo.png +0 -0
  574. /package/{src/assets/images → lib/commonjs/assets/icons}/twitter.jpg +0 -0
@@ -1,275 +0,0 @@
1
- /**
2
- * 🔄 Retry Helper Utility
3
- *
4
- * Provides robust retry logic with exponential backoff for network operations.
5
- * Used throughout the Onairos SDK for handling transient failures gracefully.
6
- */
7
-
8
- export interface RetryOptions {
9
- /** Maximum number of retry attempts */
10
- maxRetries: number;
11
- /** Base delay between retries in milliseconds */
12
- baseDelay: number;
13
- /** Maximum delay between retries in milliseconds */
14
- maxDelay: number;
15
- /** Whether to use exponential backoff */
16
- exponentialBackoff: boolean;
17
- /** Function to determine if an error should trigger a retry */
18
- shouldRetry?: (error: any, attempt: number) => boolean;
19
- /** Function called before each retry attempt */
20
- onRetry?: (error: any, attempt: number, nextDelay: number) => void;
21
- /** Enable logging of retry attempts */
22
- enableLogging: boolean;
23
- }
24
-
25
- export interface RetryResult<T> {
26
- success: boolean;
27
- data?: T;
28
- error?: Error;
29
- attempts: number;
30
- totalDuration: number;
31
- }
32
-
33
- /**
34
- * Default retry options for the Onairos SDK
35
- */
36
- export const DEFAULT_RETRY_OPTIONS: RetryOptions = {
37
- maxRetries: 3,
38
- baseDelay: 1000,
39
- maxDelay: 5000,
40
- exponentialBackoff: true,
41
- enableLogging: false,
42
- shouldRetry: (error: any, attempt: number) => {
43
- // Don't retry client errors (4xx) except for 408 (timeout) and 429 (rate limit)
44
- if (error.status >= 400 && error.status < 500 && error.status !== 408 && error.status !== 429) {
45
- return false;
46
- }
47
-
48
- // Retry network errors, timeouts, and server errors (5xx)
49
- if (error.name === 'AbortError' ||
50
- error.message.includes('Network request failed') ||
51
- error.message.includes('fetch') ||
52
- error.message.includes('ENOTFOUND') ||
53
- error.message.includes('timeout') ||
54
- (error.status >= 500)) {
55
- return true;
56
- }
57
-
58
- // Retry JSON parse errors (likely server issues)
59
- if (error.message.includes('JSON Parse error') || error.message.includes('Unexpected character')) {
60
- return true;
61
- }
62
-
63
- return false;
64
- }
65
- };
66
-
67
- /**
68
- * Execute a function with retry logic and exponential backoff
69
- * @param fn Function to execute (should return a Promise)
70
- * @param options Retry configuration options
71
- * @returns Promise with retry result
72
- */
73
- export async function withRetry<T>(
74
- fn: () => Promise<T>,
75
- options: Partial<RetryOptions> = {}
76
- ): Promise<RetryResult<T>> {
77
- const config = { ...DEFAULT_RETRY_OPTIONS, ...options };
78
- const startTime = Date.now();
79
- let lastError: Error | null = null;
80
-
81
- for (let attempt = 1; attempt <= config.maxRetries + 1; attempt++) {
82
- try {
83
- if (config.enableLogging && attempt > 1) {
84
- console.log(`🔄 Retry attempt ${attempt}/${config.maxRetries + 1}`);
85
- }
86
-
87
- const result = await fn();
88
-
89
- return {
90
- success: true,
91
- data: result,
92
- attempts: attempt,
93
- totalDuration: Date.now() - startTime
94
- };
95
-
96
- } catch (error: any) {
97
- lastError = error;
98
-
99
- // Check if we should retry this error
100
- const shouldRetryError = config.shouldRetry ? config.shouldRetry(error, attempt) : true;
101
-
102
- // If this is the last attempt or we shouldn't retry, throw the error
103
- if (attempt > config.maxRetries || !shouldRetryError) {
104
- if (config.enableLogging) {
105
- console.error(`❌ All retry attempts exhausted or error not retryable: ${error.message}`);
106
- }
107
- break;
108
- }
109
-
110
- // Calculate delay for next attempt
111
- let delay = config.baseDelay;
112
- if (config.exponentialBackoff) {
113
- delay = Math.min(config.baseDelay * Math.pow(2, attempt - 1), config.maxDelay);
114
- }
115
-
116
- // Add some jitter to prevent thundering herd
117
- const jitter = Math.random() * 0.1 * delay;
118
- delay = Math.floor(delay + jitter);
119
-
120
- if (config.onRetry) {
121
- config.onRetry(error, attempt, delay);
122
- }
123
-
124
- if (config.enableLogging) {
125
- console.log(`⏳ Waiting ${delay}ms before retry (attempt ${attempt}/${config.maxRetries + 1})`);
126
- }
127
-
128
- // Wait before next attempt
129
- await new Promise<void>(resolve => setTimeout(() => resolve(), delay));
130
- }
131
- }
132
-
133
- return {
134
- success: false,
135
- error: lastError || new Error('Unknown error'),
136
- attempts: config.maxRetries + 1,
137
- totalDuration: Date.now() - startTime
138
- };
139
- }
140
-
141
- /**
142
- * Retry configuration for API calls
143
- */
144
- export const API_RETRY_OPTIONS: Partial<RetryOptions> = {
145
- maxRetries: 3,
146
- baseDelay: 1000,
147
- maxDelay: 5000,
148
- exponentialBackoff: true,
149
- shouldRetry: (error: any, attempt: number) => {
150
- // Enhanced retry logic for API calls
151
-
152
- // Never retry authentication errors (401) or permission errors (403)
153
- if (error.status === 401 || error.status === 403) {
154
- return false;
155
- }
156
-
157
- // Never retry bad request errors (400) or not found (404) unless it's a specific case
158
- if (error.status === 400 || (error.status === 404 && !error.message.includes('validation endpoint'))) {
159
- return false;
160
- }
161
-
162
- // Retry rate limiting (429) with longer delays
163
- if (error.status === 429) {
164
- return attempt <= 2; // Limit retries for rate limiting
165
- }
166
-
167
- // Retry server errors (5xx)
168
- if (error.status >= 500) {
169
- return true;
170
- }
171
-
172
- // Retry timeout and network errors
173
- if (error.name === 'AbortError' ||
174
- error.message.includes('timeout') ||
175
- error.message.includes('Network request failed') ||
176
- error.message.includes('fetch') ||
177
- error.message.includes('ENOTFOUND')) {
178
- return true;
179
- }
180
-
181
- // Retry JSON parse errors (server returning HTML instead of JSON)
182
- if (error.message.includes('JSON Parse error') ||
183
- error.message.includes('Unexpected character') ||
184
- error.message.includes('HTML page instead of JSON')) {
185
- return true;
186
- }
187
-
188
- return false;
189
- },
190
- onRetry: (error: any, attempt: number, delay: number) => {
191
- console.warn(`⚠️ API call failed (attempt ${attempt}), retrying in ${delay}ms: ${error.message}`);
192
- }
193
- };
194
-
195
- /**
196
- * Specialized retry for network/connectivity issues
197
- */
198
- export const NETWORK_RETRY_OPTIONS: Partial<RetryOptions> = {
199
- maxRetries: 2,
200
- baseDelay: 2000,
201
- maxDelay: 8000,
202
- exponentialBackoff: true,
203
- shouldRetry: (error: any, attempt: number) => {
204
- // Only retry actual network/connectivity issues
205
- return error.message.includes('Network request failed') ||
206
- error.message.includes('ENOTFOUND') ||
207
- error.message.includes('DNS') ||
208
- error.name === 'AbortError';
209
- }
210
- };
211
-
212
- /**
213
- * Create a retry wrapper for fetch requests
214
- * @param url Request URL
215
- * @param options Fetch options
216
- * @param retryOptions Retry configuration
217
- * @returns Promise with fetch response
218
- */
219
- export async function fetchWithRetry(
220
- url: string,
221
- options: RequestInit = {},
222
- retryOptions: Partial<RetryOptions> = API_RETRY_OPTIONS
223
- ): Promise<Response> {
224
- const result = await withRetry(
225
- () => fetch(url, options),
226
- retryOptions
227
- );
228
-
229
- if (!result.success) {
230
- throw result.error;
231
- }
232
-
233
- return result.data!;
234
- }
235
-
236
- /**
237
- * Health check function with retry for testing connectivity
238
- * @param url URL to check
239
- * @param timeout Timeout in milliseconds
240
- * @returns Promise indicating if the service is reachable
241
- */
242
- export async function healthCheck(
243
- url: string,
244
- timeout: number = 5000
245
- ): Promise<{ reachable: boolean; status?: number; error?: string; duration: number }> {
246
- const startTime = Date.now();
247
-
248
- try {
249
- const controller = new AbortController();
250
- const timeoutId = setTimeout(() => controller.abort(), timeout);
251
-
252
- const response = await fetch(url, {
253
- method: 'GET',
254
- signal: controller.signal,
255
- headers: {
256
- 'User-Agent': 'OnairosReactNative/HealthCheck'
257
- }
258
- });
259
-
260
- clearTimeout(timeoutId);
261
-
262
- return {
263
- reachable: true,
264
- status: response.status,
265
- duration: Date.now() - startTime
266
- };
267
-
268
- } catch (error: any) {
269
- return {
270
- reachable: false,
271
- error: error.message,
272
- duration: Date.now() - startTime
273
- };
274
- }
275
- }
@@ -1,361 +0,0 @@
1
- import { Platform } from 'react-native';
2
- import { sha256 } from './crypto';
3
- import { STORAGE_KEYS } from '../constants';
4
- import AsyncStorage from '@react-native-async-storage/async-storage';
5
-
6
- // JWT token storage key
7
- const JWT_TOKEN_KEY = 'onairos_jwt_token';
8
-
9
- // Define OnairosCredentials interface locally to avoid circular dependencies
10
- export interface OnairosCredentials {
11
- username: string;
12
- accessToken?: string;
13
- refreshToken?: string;
14
- userPin?: string;
15
- platforms?: {
16
- instagram?: { token: string; username: string; userId?: string };
17
- youtube?: { token: string; username: string; userId?: string };
18
- pinterest?: { token: string; username: string; userId?: string };
19
- reddit?: { token: string; username: string; userId?: string };
20
- };
21
- createdAt: number;
22
- }
23
-
24
- export interface StorageOptions {
25
- service?: string;
26
- accessControl?: any;
27
- accessible?: any;
28
- }
29
-
30
- // Create a mock storage for environments without Keychain access (like Expo Go)
31
- const mockStorage: Record<string, { username: string; password: string }> = {};
32
-
33
- // Try to import Keychain, but provide fallbacks if not available
34
- let Keychain: any = null;
35
- try {
36
- // This import might fail in Expo Go or environments without native modules
37
- Keychain = require('react-native-keychain');
38
- } catch (error) {
39
- console.warn('react-native-keychain module not available, using mock storage');
40
- // Create minimal mock implementation
41
- Keychain = {
42
- ACCESS_CONTROL: { BIOMETRY_ANY_OR_DEVICE_PASSCODE: 'mock' },
43
- ACCESSIBLE: { WHEN_UNLOCKED: 'mock' },
44
- getGenericPassword: async () => null,
45
- setGenericPassword: async () => true,
46
- resetGenericPassword: async () => true,
47
- };
48
- }
49
-
50
- // Check if Keychain is properly initialized and available
51
- const isKeychainAvailable = () => {
52
- try {
53
- return Keychain && typeof Keychain.getGenericPassword === 'function';
54
- } catch (e) {
55
- return false;
56
- }
57
- };
58
-
59
- // Wrapper for getGenericPassword that falls back to mock storage
60
- const safeGetGenericPassword = async (options: any) => {
61
- try {
62
- if (isKeychainAvailable()) {
63
- return await Keychain.getGenericPassword(options);
64
- } else {
65
- // Fall back to mock storage in memory
66
- const key = options?.service || 'default';
67
- return mockStorage[key] || null;
68
- }
69
- } catch (error) {
70
- console.warn('Keychain access failed, using mock storage', error);
71
- // Fall back to mock storage on error
72
- const key = options?.service || 'default';
73
- return mockStorage[key] || null;
74
- }
75
- };
76
-
77
- // Wrapper for setGenericPassword that falls back to mock storage
78
- const safeSetGenericPassword = async (
79
- username: string,
80
- password: string,
81
- options?: any
82
- ) => {
83
- try {
84
- if (isKeychainAvailable()) {
85
- return await Keychain.setGenericPassword(username, password, options);
86
- } else {
87
- // Fall back to mock storage in memory
88
- const key = options?.service || 'default';
89
- mockStorage[key] = { username, password };
90
- return true;
91
- }
92
- } catch (error) {
93
- console.warn('Keychain access failed, using mock storage', error);
94
- // Fall back to mock storage on error
95
- const key = options?.service || 'default';
96
- mockStorage[key] = { username, password };
97
- return true;
98
- }
99
- };
100
-
101
- // Wrapper for resetGenericPassword that falls back to mock storage
102
- const safeResetGenericPassword = async (options?: any) => {
103
- try {
104
- if (isKeychainAvailable()) {
105
- return await Keychain.resetGenericPassword(options);
106
- } else {
107
- // Fall back to mock storage in memory
108
- const key = options?.service || 'default';
109
- delete mockStorage[key];
110
- return true;
111
- }
112
- } catch (error) {
113
- console.warn('Keychain access failed, using mock storage', error);
114
- // Fall back to mock storage on error
115
- const key = options?.service || 'default';
116
- delete mockStorage[key];
117
- return true;
118
- }
119
- };
120
-
121
- /**
122
- * Store credentials in memory (temporary solution)
123
- */
124
- export const storeCredentials = async (
125
- credentials: Partial<OnairosCredentials>
126
- ): Promise<boolean> => {
127
- try {
128
- const existingCredentials = await getCredentials();
129
- const updatedCredentials: OnairosCredentials = {
130
- ...existingCredentials,
131
- ...credentials,
132
- createdAt: existingCredentials?.createdAt || Date.now(),
133
- } as OnairosCredentials;
134
-
135
- const username = updatedCredentials.username;
136
- if (!username) {
137
- throw new Error('Username is required for storing credentials');
138
- }
139
-
140
- const options: any = {
141
- service: STORAGE_KEYS.credentials,
142
- };
143
-
144
- // Only use secure storage options on real devices
145
- if (Platform.OS !== 'web' && isKeychainAvailable()) {
146
- options.accessControl = Keychain.ACCESS_CONTROL.BIOMETRY_ANY_OR_DEVICE_PASSCODE;
147
- options.accessible = Keychain.ACCESSIBLE.WHEN_UNLOCKED;
148
- }
149
-
150
- await safeSetGenericPassword(
151
- username,
152
- JSON.stringify(updatedCredentials),
153
- options
154
- );
155
- return true;
156
- } catch (error) {
157
- console.error('Error storing credentials:', error);
158
- return false;
159
- }
160
- };
161
-
162
- /**
163
- * Retrieve credentials from memory (temporary solution)
164
- */
165
- export const getCredentials = async (): Promise<OnairosCredentials | null> => {
166
- try {
167
- const credentials = await safeGetGenericPassword({
168
- service: STORAGE_KEYS.credentials,
169
- });
170
- if (credentials) {
171
- return JSON.parse(credentials.password);
172
- }
173
- return null;
174
- } catch (error) {
175
- console.error('Error getting credentials:', error);
176
- return null;
177
- }
178
- };
179
-
180
- /**
181
- * Check if the user has stored credentials
182
- */
183
- export const hasCredentials = async (): Promise<boolean> => {
184
- try {
185
- const credentials = await safeGetGenericPassword({
186
- service: STORAGE_KEYS.credentials,
187
- });
188
- return !!credentials;
189
- } catch (error) {
190
- console.error('Error checking credentials:', error);
191
- return false;
192
- }
193
- };
194
-
195
- /**
196
- * Delete stored credentials
197
- */
198
- export const deleteCredentials = async (): Promise<boolean> => {
199
- try {
200
- await safeResetGenericPassword({
201
- service: STORAGE_KEYS.credentials,
202
- });
203
- return true;
204
- } catch (error) {
205
- console.error('Error deleting credentials:', error);
206
- return false;
207
- }
208
- };
209
-
210
- /**
211
- * Update specific fields in the stored credentials
212
- */
213
- export const updateCredentials = async (
214
- credentials: Partial<OnairosCredentials>
215
- ): Promise<boolean> => {
216
- return storeCredentials(credentials);
217
- };
218
-
219
- /**
220
- * Generate a device-specific unique username
221
- */
222
- export const generateDeviceUsername = (): string => {
223
- const randomId = Math.random().toString(36).substring(2, 10);
224
- return `dev_${randomId}`;
225
- };
226
-
227
- /**
228
- * Verify credentials (temporary mock implementation)
229
- */
230
- export const verifyCredentials = async (username: string): Promise<boolean> => {
231
- try {
232
- // For Expo Go or development, always return true
233
- if (!isKeychainAvailable()) {
234
- return true;
235
- }
236
-
237
- // TODO: Implement actual verification with API
238
- return true;
239
- } catch (error) {
240
- console.error('Error verifying credentials:', error);
241
- return false;
242
- }
243
- };
244
-
245
- /**
246
- * JWT Token Storage Functions
247
- * These functions handle JWT tokens from email verification
248
- *
249
- * Note: Main JWT token management is handled in apiKeyService.ts
250
- * These are utility functions for backwards compatibility
251
- */
252
-
253
- /**
254
- * Retrieve JWT token
255
- * @returns JWT token or null if not found
256
- */
257
- export const getJWT = async (): Promise<string | null> => {
258
- try {
259
- const token = await AsyncStorage.getItem(JWT_TOKEN_KEY);
260
- return token;
261
- } catch (error) {
262
- console.error('❌ Failed to retrieve JWT token:', error);
263
- return null;
264
- }
265
- };
266
-
267
- /**
268
- * Check if JWT token exists
269
- * @returns True if JWT token exists
270
- */
271
- export const hasJWT = async (): Promise<boolean> => {
272
- try {
273
- const token = await AsyncStorage.getItem(JWT_TOKEN_KEY);
274
- return !!token;
275
- } catch (error) {
276
- console.error('❌ Failed to check JWT token:', error);
277
- return false;
278
- }
279
- };
280
-
281
- /**
282
- * Clear JWT token
283
- */
284
- export const clearJWT = async (): Promise<boolean> => {
285
- try {
286
- await AsyncStorage.removeItem(JWT_TOKEN_KEY);
287
- console.log('🗑️ JWT token cleared');
288
- return true;
289
- } catch (error) {
290
- console.error('❌ Failed to clear JWT token:', error);
291
- return false;
292
- }
293
- };
294
-
295
- /**
296
- * Simple base64 decoder for React Native
297
- */
298
- const base64Decode = (str: string): string => {
299
- // Add padding if needed
300
- while (str.length % 4) {
301
- str += '=';
302
- }
303
-
304
- // Simple base64 decoding
305
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
306
- let result = '';
307
-
308
- for (let i = 0; i < str.length; i += 4) {
309
- const a = chars.indexOf(str.charAt(i));
310
- const b = chars.indexOf(str.charAt(i + 1));
311
- const c = chars.indexOf(str.charAt(i + 2));
312
- const d = chars.indexOf(str.charAt(i + 3));
313
-
314
- const bitmap = (a << 18) | (b << 12) | (c << 6) | d;
315
-
316
- result += String.fromCharCode((bitmap >> 16) & 255);
317
- if (c !== 64) result += String.fromCharCode((bitmap >> 8) & 255);
318
- if (d !== 64) result += String.fromCharCode(bitmap & 255);
319
- }
320
-
321
- return result;
322
- };
323
-
324
- /**
325
- * Get JWT token payload (decoded)
326
- * @returns Decoded JWT payload or null if invalid
327
- */
328
- export const getJWTPayload = async (): Promise<any | null> => {
329
- try {
330
- const token = await getJWT();
331
- if (!token) return null;
332
-
333
- // Decode JWT payload (middle part of token)
334
- const parts = token.split('.');
335
- if (parts.length !== 3) return null;
336
-
337
- const decodedPayload = base64Decode(parts[1]);
338
- const payload = JSON.parse(decodedPayload);
339
- return payload;
340
- } catch (error) {
341
- console.error('❌ Failed to decode JWT payload:', error);
342
- return null;
343
- }
344
- };
345
-
346
- /**
347
- * Check if JWT token is expired
348
- * @returns True if token is expired or invalid
349
- */
350
- export const isJWTExpired = async (): Promise<boolean> => {
351
- try {
352
- const payload = await getJWTPayload();
353
- if (!payload || !payload.exp) return true;
354
-
355
- const currentTime = Math.floor(Date.now() / 1000);
356
- return payload.exp < currentTime;
357
- } catch (error) {
358
- console.error('❌ Failed to check JWT expiration:', error);
359
- return true;
360
- }
361
- };