@onairos/react-native 3.4.1 → 3.5.4
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.
- package/README.md +62 -13
- package/lib/commonjs/api/index.js +9 -145
- package/lib/commonjs/assets/animations/loaderani.json +1 -0
- package/lib/commonjs/assets/animations/persona-animation.json +1 -0
- package/lib/commonjs/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/lib/commonjs/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/lib/commonjs/assets/icons/Facebookicon.png +0 -0
- package/lib/commonjs/assets/icons/Gmail.png +0 -0
- package/lib/commonjs/assets/icons/Linkedinicon.png +0 -0
- package/lib/commonjs/assets/icons/Redditicon.png +0 -0
- package/lib/commonjs/assets/icons/YouTubeicon2.png +0 -0
- package/lib/commonjs/assets/icons/YouTubeicon3.png +0 -0
- package/lib/commonjs/assets/icons/chatgpt.png +0 -0
- package/lib/commonjs/assets/icons/claude.png +0 -0
- package/lib/commonjs/assets/icons/gemini.png +0 -0
- package/lib/commonjs/assets/icons/grok.png +0 -0
- package/lib/commonjs/assets/images/Checkbox.svg +3 -0
- package/lib/commonjs/assets/images/EnochE.svg +19 -0
- package/lib/commonjs/assets/images/Enochicon1.png +0 -0
- package/lib/commonjs/assets/images/Face_ID_logo.png +0 -0
- package/lib/commonjs/assets/images/Facebookicon.png +0 -0
- package/lib/commonjs/assets/images/Gmail.png +0 -0
- package/lib/commonjs/assets/images/Googlelogo.png +0 -0
- package/lib/commonjs/assets/images/Linkedinicon.png +0 -0
- package/lib/commonjs/assets/images/Onairoslogo.png +0 -0
- package/lib/commonjs/assets/images/Personalityprofile.svg +3 -0
- package/lib/commonjs/assets/images/Personalitytraits.svg +3 -0
- package/lib/commonjs/assets/images/Redditicon.png +0 -0
- package/lib/commonjs/assets/images/Userpreferences.svg +3 -0
- package/lib/commonjs/assets/images/YouTubeicon3.png +0 -0
- package/lib/commonjs/assets/images/arrow.svg +20 -0
- package/lib/commonjs/assets/images/basicproficon.svg +43 -0
- package/lib/commonjs/assets/images/basicprofile.svg +3 -0
- package/lib/commonjs/assets/images/chatgpt.png +0 -0
- package/lib/commonjs/assets/images/checkmark.svg +4 -0
- package/lib/commonjs/assets/images/claude.png +0 -0
- package/lib/commonjs/assets/images/contentanalysis.svg +3 -0
- package/lib/commonjs/assets/images/contenticon.svg +23 -0
- package/lib/commonjs/assets/images/gemini.png +0 -0
- package/lib/commonjs/assets/images/grok.png +0 -0
- package/lib/commonjs/assets/images/persona1.png +0 -0
- package/lib/commonjs/assets/images/persona2.png +0 -0
- package/lib/commonjs/assets/images/persona3.png +0 -0
- package/lib/commonjs/assets/images/persona4.png +0 -0
- package/lib/commonjs/assets/images/persona5.png +0 -0
- package/lib/commonjs/assets/images/personalityicon.svg +18 -0
- package/lib/commonjs/assets/images/x-close.svg +3 -0
- package/lib/commonjs/components/BodyText.js +9 -0
- package/lib/commonjs/components/BrandMark.js +10 -0
- package/lib/commonjs/components/CodeInput.js +9 -0
- package/lib/commonjs/components/EmailInput.js +8 -0
- package/lib/commonjs/components/GoogleButton.js +9 -0
- package/lib/commonjs/components/HeadingGroup.js +9 -0
- package/lib/commonjs/components/LLMDataInputModal.js +14 -0
- package/lib/commonjs/components/ModalHeader.js +9 -0
- package/lib/commonjs/components/ModalSheet.js +9 -0
- package/lib/commonjs/components/Onairos.js +14 -374
- package/lib/commonjs/components/OnairosButton.js +13 -309
- package/lib/commonjs/components/OnairosSignInButton.js +12 -0
- package/lib/commonjs/components/Overlay.js +13 -483
- package/lib/commonjs/components/PersonaImage.js +10 -0
- package/lib/commonjs/components/PersonaLoadingScreen.js +12 -0
- package/lib/commonjs/components/PersonalizationConsentScreen.js +13 -0
- package/lib/commonjs/components/PinCreationScreen.js +12 -0
- package/lib/commonjs/components/PinInput.js +9 -302
- package/lib/commonjs/components/PlatformConnectorsStep.js +22 -0
- package/lib/commonjs/components/PlatformList.js +10 -137
- package/lib/commonjs/components/PlatformToggle.js +9 -0
- package/lib/commonjs/components/PrimaryButton.js +10 -0
- package/lib/commonjs/components/SignInMatchAnimation.js +9 -0
- package/lib/commonjs/components/SignInStep.js +12 -0
- package/lib/commonjs/components/UniversalOnboarding.js +29 -1702
- package/lib/commonjs/components/VerificationStep.js +11 -0
- package/lib/commonjs/components/WelcomeScreen.js +21 -0
- package/lib/commonjs/components/icons/Basicproficon.js +8 -0
- package/lib/commonjs/components/icons/Basicprofile.js +8 -0
- package/lib/commonjs/components/icons/Checkbox.js +8 -0
- package/lib/commonjs/components/icons/Checkmark.js +8 -0
- package/lib/commonjs/components/icons/Contentanalysis.js +8 -0
- package/lib/commonjs/components/icons/Contenticon.js +8 -0
- package/lib/commonjs/components/icons/EnochE.js +8 -0
- package/lib/commonjs/components/icons/Personalityicon.js +8 -0
- package/lib/commonjs/components/icons/Personalityprofile.js +8 -0
- package/lib/commonjs/components/icons/Personalitytraits.js +8 -0
- package/lib/commonjs/components/icons/Userpreferences.js +8 -0
- package/lib/commonjs/components/icons/index.js +17 -0
- package/lib/commonjs/components/onboarding/OAuthWebView.js +14 -827
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +10 -74
- package/lib/commonjs/components/onboarding/PinInput.js +10 -283
- package/lib/commonjs/components/onboarding/PlatformConnector.js +11 -249
- package/lib/commonjs/config/api.js +7 -0
- package/lib/commonjs/constants/index.js +7 -83
- package/lib/commonjs/context/AuthContext.js +10 -0
- package/lib/commonjs/hooks/useConnectedAccounts.js +9 -0
- package/lib/commonjs/hooks/useConnections.js +8 -159
- package/lib/commonjs/hooks/useCredentials.js +10 -177
- package/lib/commonjs/hooks/useUserConnections.js +10 -0
- package/lib/commonjs/index.js +35 -106
- package/lib/commonjs/services/apiClient.js +8 -0
- package/lib/commonjs/services/apiKeyService.js +9 -952
- package/lib/commonjs/services/authService.js +10 -0
- package/lib/commonjs/services/biometricPinService.js +8 -0
- package/lib/commonjs/services/chatGPTConversationExtractor.js +8 -0
- package/lib/commonjs/services/chatGPTConversationService.js +9 -0
- package/lib/commonjs/services/claudeConversationExtractor.js +8 -0
- package/lib/commonjs/services/claudeConversationService.js +9 -0
- package/lib/commonjs/services/connectedAccountsService.js +10 -0
- package/lib/commonjs/services/googleAuthService.js +11 -0
- package/lib/commonjs/services/imageCompressionService.js +7 -0
- package/lib/commonjs/services/jwtStorageService.js +7 -0
- package/lib/commonjs/services/linkedinDOMExtractor.js +7 -0
- package/lib/commonjs/services/linkedinProfileService.js +9 -0
- package/lib/commonjs/services/linkedinScrapingService.js +8 -0
- package/lib/commonjs/services/llmDataStorage.js +8 -0
- package/lib/commonjs/services/mobileTrainingService.js +8 -0
- package/lib/commonjs/services/oauthService.js +11 -390
- package/lib/commonjs/services/pinEncryptionService.js +8 -0
- package/lib/commonjs/services/pinStorageUtils.js +7 -0
- package/lib/commonjs/services/platformAuthService.js +12 -1067
- package/lib/commonjs/services/storageService.js +8 -0
- package/lib/commonjs/services/trainingApiHelpers.js +7 -0
- package/lib/commonjs/services/userConnectionsService.js +10 -0
- package/lib/commonjs/services/youtubeMigrationService.js +10 -0
- package/lib/commonjs/theme/index.js +7 -0
- package/lib/commonjs/types/ambient.d.js +1 -2
- package/lib/commonjs/types/declarations.d.js +1 -2
- package/lib/commonjs/types/index.js +1 -6
- package/lib/commonjs/types/node-fix.d.js +1 -2
- package/lib/commonjs/types/node-override.d.js +1 -2
- package/lib/commonjs/types/opacity.d.js +1 -2
- package/lib/commonjs/types.js +1 -14
- package/lib/commonjs/utils/Portal.js +8 -98
- package/lib/commonjs/utils/api.js +9 -129
- package/lib/commonjs/utils/assetRegistry.js +33 -0
- package/lib/commonjs/utils/auth.js +9 -111
- package/lib/commonjs/utils/crypto.js +8 -62
- package/lib/commonjs/utils/debugHelper.js +1 -64
- package/lib/commonjs/utils/encryption.js +7 -76
- package/lib/commonjs/utils/eventUtils.js +1 -0
- package/lib/commonjs/utils/haptics.js +9 -0
- package/lib/commonjs/utils/imagePreloader.js +1 -0
- package/lib/commonjs/utils/networkDiagnostics.js +8 -0
- package/lib/commonjs/utils/onairosApi.js +9 -350
- package/lib/commonjs/utils/programmaticFlow.js +9 -117
- package/lib/commonjs/utils/retryHelper.js +1 -220
- package/lib/commonjs/utils/secureStorage.js +10 -349
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +1 -0
- package/lib/commonjs/utils/webviewScripts/claude.js +1 -0
- package/lib/commonjs/utils/webviewScripts/index.js +9 -0
- package/lib/commonjs/utils/webviewScripts/linkedin.js +1 -0
- package/lib/module/api/index.js +1 -139
- package/lib/module/assets/animations/loaderani.json +1 -0
- package/lib/module/assets/animations/persona-animation.json +1 -0
- package/lib/module/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/lib/module/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/lib/module/assets/icons/Facebookicon.png +0 -0
- package/lib/module/assets/icons/Gmail.png +0 -0
- package/lib/module/assets/icons/Linkedinicon.png +0 -0
- package/lib/module/assets/icons/Redditicon.png +0 -0
- package/lib/module/assets/icons/YouTubeicon2.png +0 -0
- package/lib/module/assets/icons/YouTubeicon3.png +0 -0
- package/lib/module/assets/icons/chatgpt.png +0 -0
- package/lib/module/assets/icons/claude.png +0 -0
- package/lib/module/assets/icons/farcaster.png +0 -0
- package/lib/module/assets/icons/gemini.png +0 -0
- package/lib/module/assets/icons/grok.png +0 -0
- package/lib/module/assets/icons/instagram.png +0 -0
- package/lib/module/assets/icons/pinterest.png +0 -0
- package/lib/module/assets/icons/swerv_logo.png +0 -0
- package/lib/module/assets/icons/twitter.jpg +0 -0
- package/lib/module/assets/images/Checkbox.svg +3 -0
- package/lib/module/assets/images/EnochE.svg +19 -0
- package/lib/module/assets/images/Enochicon1.png +0 -0
- package/lib/module/assets/images/Face_ID_logo.png +0 -0
- package/lib/module/assets/images/Facebookicon.png +0 -0
- package/lib/module/assets/images/Gmail.png +0 -0
- package/lib/module/assets/images/Googlelogo.png +0 -0
- package/lib/module/assets/images/Linkedinicon.png +0 -0
- package/lib/module/assets/images/Onairoslogo.png +0 -0
- package/lib/module/assets/images/Personalityprofile.svg +3 -0
- package/lib/module/assets/images/Personalitytraits.svg +3 -0
- package/lib/module/assets/images/Redditicon.png +0 -0
- package/lib/module/assets/images/Userpreferences.svg +3 -0
- package/lib/module/assets/images/YouTubeicon3.png +0 -0
- package/lib/module/assets/images/arrow.svg +20 -0
- package/lib/module/assets/images/basicproficon.svg +43 -0
- package/lib/module/assets/images/basicprofile.svg +3 -0
- package/lib/module/assets/images/chatgpt.png +0 -0
- package/lib/module/assets/images/checkmark.svg +4 -0
- package/lib/module/assets/images/claude.png +0 -0
- package/lib/module/assets/images/contentanalysis.svg +3 -0
- package/lib/module/assets/images/contenticon.svg +23 -0
- package/lib/module/assets/images/gemini.png +0 -0
- package/lib/module/assets/images/grok.png +0 -0
- package/lib/module/assets/images/persona1.png +0 -0
- package/lib/module/assets/images/persona2.png +0 -0
- package/lib/module/assets/images/persona3.png +0 -0
- package/lib/module/assets/images/persona4.png +0 -0
- package/lib/module/assets/images/persona5.png +0 -0
- package/lib/module/assets/images/personalityicon.svg +18 -0
- package/lib/module/assets/images/x-close.svg +3 -0
- package/lib/module/components/BodyText.js +1 -0
- package/lib/module/components/BrandMark.js +1 -0
- package/lib/module/components/CodeInput.js +1 -0
- package/lib/module/components/EmailInput.js +1 -0
- package/lib/module/components/GoogleButton.js +1 -0
- package/lib/module/components/HeadingGroup.js +1 -0
- package/lib/module/components/LLMDataInputModal.js +8 -0
- package/lib/module/components/ModalHeader.js +1 -0
- package/lib/module/components/ModalSheet.js +1 -0
- package/lib/module/components/Onairos.js +1 -367
- package/lib/module/components/OnairosButton.js +1 -302
- package/lib/module/components/OnairosSignInButton.js +1 -0
- package/lib/module/components/Overlay.js +1 -474
- package/lib/module/components/PersonaImage.js +1 -0
- package/lib/module/components/PersonaLoadingScreen.js +1 -0
- package/lib/module/components/PersonalizationConsentScreen.js +1 -0
- package/lib/module/components/PinCreationScreen.js +1 -0
- package/lib/module/components/PinInput.js +1 -293
- package/lib/module/components/PlatformConnectorsStep.js +1 -0
- package/lib/module/components/PlatformList.js +1 -129
- package/lib/module/components/PlatformToggle.js +1 -0
- package/lib/module/components/PrimaryButton.js +1 -0
- package/lib/module/components/SignInMatchAnimation.js +1 -0
- package/lib/module/components/SignInStep.js +1 -0
- package/lib/module/components/UniversalOnboarding.js +1 -1693
- package/lib/module/components/VerificationStep.js +1 -0
- package/lib/module/components/WelcomeScreen.js +1 -0
- package/lib/module/components/icons/Basicproficon.js +1 -0
- package/lib/module/components/icons/Basicprofile.js +1 -0
- package/lib/module/components/icons/Checkbox.js +1 -0
- package/lib/module/components/icons/Checkmark.js +1 -0
- package/lib/module/components/icons/Contentanalysis.js +1 -0
- package/lib/module/components/icons/Contenticon.js +1 -0
- package/lib/module/components/icons/EnochE.js +1 -0
- package/lib/module/components/icons/Personalityicon.js +1 -0
- package/lib/module/components/icons/Personalityprofile.js +1 -0
- package/lib/module/components/icons/Personalitytraits.js +1 -0
- package/lib/module/components/icons/Userpreferences.js +1 -0
- package/lib/module/components/icons/index.js +1 -0
- package/lib/module/components/onboarding/OAuthWebView.js +1 -818
- package/lib/module/components/onboarding/OnboardingHeader.js +1 -66
- package/lib/module/components/onboarding/PinInput.js +1 -274
- package/lib/module/components/onboarding/PlatformConnector.js +1 -240
- package/lib/module/config/api.js +1 -0
- package/lib/module/constants/index.js +1 -77
- package/lib/module/context/AuthContext.js +1 -0
- package/lib/module/hooks/useConnectedAccounts.js +1 -0
- package/lib/module/hooks/useConnections.js +1 -152
- package/lib/module/hooks/useCredentials.js +6 -169
- package/lib/module/hooks/useUserConnections.js +1 -0
- package/lib/module/index.js +1 -32
- package/lib/module/services/apiClient.js +1 -0
- package/lib/module/services/apiKeyService.js +1 -925
- package/lib/module/services/authService.js +1 -0
- package/lib/module/services/biometricPinService.js +1 -0
- package/lib/module/services/chatGPTConversationExtractor.js +1 -0
- package/lib/module/services/chatGPTConversationService.js +1 -0
- package/lib/module/services/claudeConversationExtractor.js +1 -0
- package/lib/module/services/claudeConversationService.js +1 -0
- package/lib/module/services/connectedAccountsService.js +1 -0
- package/lib/module/services/googleAuthService.js +1 -0
- package/lib/module/services/imageCompressionService.js +1 -0
- package/lib/module/services/jwtStorageService.js +1 -0
- package/lib/module/services/linkedinDOMExtractor.js +1 -0
- package/lib/module/services/linkedinProfileService.js +1 -0
- package/lib/module/services/linkedinScrapingService.js +1 -0
- package/lib/module/services/llmDataStorage.js +1 -0
- package/lib/module/services/mobileTrainingService.js +1 -0
- package/lib/module/services/oauthService.js +1 -380
- package/lib/module/services/pinEncryptionService.js +7 -0
- package/lib/module/services/pinStorageUtils.js +1 -0
- package/lib/module/services/platformAuthService.js +1 -1041
- package/lib/module/services/storageService.js +1 -0
- package/lib/module/services/trainingApiHelpers.js +1 -0
- package/lib/module/services/userConnectionsService.js +1 -0
- package/lib/module/services/youtubeMigrationService.js +1 -0
- package/lib/module/theme/index.js +1 -0
- package/lib/module/types.js +1 -10
- package/lib/module/utils/Portal.js +1 -90
- package/lib/module/utils/api.js +1 -117
- package/lib/module/utils/assetRegistry.js +33 -0
- package/lib/module/utils/auth.js +1 -99
- package/lib/module/utils/crypto.js +1 -54
- package/lib/module/utils/debugHelper.js +1 -54
- package/lib/module/utils/encryption.js +1 -67
- package/lib/module/utils/eventUtils.js +1 -0
- package/lib/module/utils/haptics.js +8 -0
- package/lib/module/utils/imagePreloader.js +1 -0
- package/lib/module/utils/networkDiagnostics.js +1 -0
- package/lib/module/utils/onairosApi.js +1 -333
- package/lib/module/utils/programmaticFlow.js +1 -111
- package/lib/module/utils/retryHelper.js +1 -211
- package/lib/module/utils/secureStorage.js +6 -330
- package/lib/module/utils/webviewScripts/chatgpt.js +1 -0
- package/lib/module/utils/webviewScripts/claude.js +1 -0
- package/lib/module/utils/webviewScripts/index.js +1 -0
- package/lib/module/utils/webviewScripts/linkedin.js +1 -0
- package/package.json +62 -39
- package/lib/commonjs/api/index.js.map +0 -1
- package/lib/commonjs/assets/images/email.png +0 -0
- package/lib/commonjs/assets/images/linkedin.png +0 -0
- package/lib/commonjs/assets/images/reddit.png +0 -0
- package/lib/commonjs/assets/images/youtube.png +0 -0
- package/lib/commonjs/components/DataRequestModal.js +0 -228
- package/lib/commonjs/components/DataRequestModal.js.map +0 -1
- package/lib/commonjs/components/DataRequestScreen.js +0 -329
- package/lib/commonjs/components/DataRequestScreen.js.map +0 -1
- package/lib/commonjs/components/EmailVerificationModal.js +0 -320
- package/lib/commonjs/components/EmailVerificationModal.js.map +0 -1
- package/lib/commonjs/components/Onairos.js.map +0 -1
- package/lib/commonjs/components/OnairosButton.js.map +0 -1
- package/lib/commonjs/components/Overlay.js.map +0 -1
- package/lib/commonjs/components/PinInput.js.map +0 -1
- package/lib/commonjs/components/PlatformList.js.map +0 -1
- package/lib/commonjs/components/TrainingModal.js +0 -717
- package/lib/commonjs/components/TrainingModal.js.map +0 -1
- package/lib/commonjs/components/UniversalOnboarding.js.map +0 -1
- package/lib/commonjs/components/UniversalOnboarding.tsx.new +0 -455
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +0 -1
- package/lib/commonjs/components/onboarding/OnboardingHeader.js.map +0 -1
- package/lib/commonjs/components/onboarding/PinInput.js.map +0 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js.map +0 -1
- package/lib/commonjs/components/screens/ConnectorScreen.js +0 -146
- package/lib/commonjs/components/screens/ConnectorScreen.js.map +0 -1
- package/lib/commonjs/components/screens/LoadingScreen.js +0 -91
- package/lib/commonjs/components/screens/LoadingScreen.js.map +0 -1
- package/lib/commonjs/components/screens/PinCreationScreen.js +0 -61
- package/lib/commonjs/components/screens/PinCreationScreen.js.map +0 -1
- package/lib/commonjs/constants/index.js.map +0 -1
- package/lib/commonjs/hooks/useConnections.js.map +0 -1
- package/lib/commonjs/hooks/useCredentials.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/services/apiKeyService.js.map +0 -1
- package/lib/commonjs/services/oauthService.js.map +0 -1
- package/lib/commonjs/services/platformAuthService.js.map +0 -1
- package/lib/commonjs/types/ambient.d.js.map +0 -1
- package/lib/commonjs/types/declarations.d.js.map +0 -1
- package/lib/commonjs/types/index.d.js.map +0 -1
- package/lib/commonjs/types/index.js.map +0 -1
- package/lib/commonjs/types/node-fix.d.js.map +0 -1
- package/lib/commonjs/types/node-override.d.js.map +0 -1
- package/lib/commonjs/types/opacity.d.js.map +0 -1
- package/lib/commonjs/types/types.d.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/Portal.js.map +0 -1
- package/lib/commonjs/utils/api.js.map +0 -1
- package/lib/commonjs/utils/auth.js.map +0 -1
- package/lib/commonjs/utils/crypto.js.map +0 -1
- package/lib/commonjs/utils/debugHelper.js.map +0 -1
- package/lib/commonjs/utils/encryption.js.map +0 -1
- package/lib/commonjs/utils/onairosApi.js.map +0 -1
- package/lib/commonjs/utils/programmaticFlow.js.map +0 -1
- package/lib/commonjs/utils/retryHelper.js.map +0 -1
- package/lib/commonjs/utils/secureStorage.js.map +0 -1
- package/lib/module/api/index.js.map +0 -1
- package/lib/module/assets/images/email.png +0 -0
- package/lib/module/assets/images/linkedin.png +0 -0
- package/lib/module/assets/images/reddit.png +0 -0
- package/lib/module/assets/images/youtube.png +0 -0
- package/lib/module/components/DataRequestModal.js +0 -220
- package/lib/module/components/DataRequestModal.js.map +0 -1
- package/lib/module/components/DataRequestScreen.js +0 -321
- package/lib/module/components/DataRequestScreen.js.map +0 -1
- package/lib/module/components/EmailVerificationModal.js +0 -311
- package/lib/module/components/EmailVerificationModal.js.map +0 -1
- package/lib/module/components/Onairos.js.map +0 -1
- package/lib/module/components/OnairosButton.js.map +0 -1
- package/lib/module/components/Overlay.js.map +0 -1
- package/lib/module/components/PinInput.js.map +0 -1
- package/lib/module/components/PlatformList.js.map +0 -1
- package/lib/module/components/TrainingModal.js +0 -708
- package/lib/module/components/TrainingModal.js.map +0 -1
- package/lib/module/components/UniversalOnboarding.js.map +0 -1
- package/lib/module/components/UniversalOnboarding.tsx.new +0 -455
- package/lib/module/components/onboarding/OAuthWebView.js.map +0 -1
- package/lib/module/components/onboarding/OnboardingHeader.js.map +0 -1
- package/lib/module/components/onboarding/PinInput.js.map +0 -1
- package/lib/module/components/onboarding/PlatformConnector.js.map +0 -1
- package/lib/module/components/screens/ConnectorScreen.js +0 -138
- package/lib/module/components/screens/ConnectorScreen.js.map +0 -1
- package/lib/module/components/screens/LoadingScreen.js +0 -83
- package/lib/module/components/screens/LoadingScreen.js.map +0 -1
- package/lib/module/components/screens/PinCreationScreen.js +0 -53
- package/lib/module/components/screens/PinCreationScreen.js.map +0 -1
- package/lib/module/constants/index.js.map +0 -1
- package/lib/module/hooks/useConnections.js.map +0 -1
- package/lib/module/hooks/useCredentials.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/services/apiKeyService.js.map +0 -1
- package/lib/module/services/oauthService.js.map +0 -1
- package/lib/module/services/platformAuthService.js.map +0 -1
- package/lib/module/types/ambient.d.js.map +0 -1
- package/lib/module/types/declarations.d.js.map +0 -1
- package/lib/module/types/index.d.js.map +0 -1
- package/lib/module/types/index.js.map +0 -1
- package/lib/module/types/node-fix.d.js.map +0 -1
- package/lib/module/types/node-override.d.js.map +0 -1
- package/lib/module/types/opacity.d.js.map +0 -1
- package/lib/module/types/types.d.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/Portal.js.map +0 -1
- package/lib/module/utils/api.js.map +0 -1
- package/lib/module/utils/auth.js.map +0 -1
- package/lib/module/utils/crypto.js.map +0 -1
- package/lib/module/utils/debugHelper.js.map +0 -1
- package/lib/module/utils/encryption.js.map +0 -1
- package/lib/module/utils/onairosApi.js.map +0 -1
- package/lib/module/utils/programmaticFlow.js.map +0 -1
- package/lib/module/utils/retryHelper.js.map +0 -1
- package/lib/module/utils/secureStorage.js.map +0 -1
- package/lib/typescript/api/index.d.ts +0 -8
- package/lib/typescript/api/index.d.ts.map +0 -1
- package/lib/typescript/components/DataRequestModal.d.ts +0 -11
- package/lib/typescript/components/DataRequestModal.d.ts.map +0 -1
- package/lib/typescript/components/DataRequestScreen.d.ts +0 -11
- package/lib/typescript/components/DataRequestScreen.d.ts.map +0 -1
- package/lib/typescript/components/EmailVerificationModal.d.ts +0 -11
- package/lib/typescript/components/EmailVerificationModal.d.ts.map +0 -1
- package/lib/typescript/components/Onairos.d.ts +0 -4
- package/lib/typescript/components/Onairos.d.ts.map +0 -1
- package/lib/typescript/components/OnairosButton.d.ts +0 -12
- package/lib/typescript/components/OnairosButton.d.ts.map +0 -1
- package/lib/typescript/components/Overlay.d.ts +0 -4
- package/lib/typescript/components/Overlay.d.ts.map +0 -1
- package/lib/typescript/components/PinInput.d.ts +0 -4
- package/lib/typescript/components/PinInput.d.ts.map +0 -1
- package/lib/typescript/components/PlatformList.d.ts +0 -4
- package/lib/typescript/components/PlatformList.d.ts.map +0 -1
- package/lib/typescript/components/TrainingModal.d.ts +0 -4
- package/lib/typescript/components/TrainingModal.d.ts.map +0 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts +0 -4
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +0 -1
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts +0 -10
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +0 -1
- package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +0 -11
- package/lib/typescript/components/onboarding/OnboardingHeader.d.ts.map +0 -1
- package/lib/typescript/components/onboarding/PinInput.d.ts +0 -4
- package/lib/typescript/components/onboarding/PinInput.d.ts.map +0 -1
- package/lib/typescript/components/onboarding/PlatformConnector.d.ts +0 -13
- package/lib/typescript/components/onboarding/PlatformConnector.d.ts.map +0 -1
- package/lib/typescript/components/screens/ConnectorScreen.d.ts +0 -9
- package/lib/typescript/components/screens/ConnectorScreen.d.ts.map +0 -1
- package/lib/typescript/components/screens/LoadingScreen.d.ts +0 -9
- package/lib/typescript/components/screens/LoadingScreen.d.ts.map +0 -1
- package/lib/typescript/components/screens/PinCreationScreen.d.ts +0 -10
- package/lib/typescript/components/screens/PinCreationScreen.d.ts.map +0 -1
- package/lib/typescript/constants/index.d.ts +0 -53
- package/lib/typescript/constants/index.d.ts.map +0 -1
- package/lib/typescript/hooks/useConnections.d.ts +0 -9
- package/lib/typescript/hooks/useConnections.d.ts.map +0 -1
- package/lib/typescript/hooks/useCredentials.d.ts +0 -9
- package/lib/typescript/hooks/useCredentials.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -18
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/services/apiKeyService.d.ts +0 -132
- package/lib/typescript/services/apiKeyService.d.ts.map +0 -1
- package/lib/typescript/services/oauthService.d.ts +0 -50
- package/lib/typescript/services/oauthService.d.ts.map +0 -1
- package/lib/typescript/services/platformAuthService.d.ts +0 -144
- package/lib/typescript/services/platformAuthService.d.ts.map +0 -1
- package/lib/typescript/types/index.d.ts +0 -231
- package/lib/typescript/types/index.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -270
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils/Portal.d.ts +0 -14
- package/lib/typescript/utils/Portal.d.ts.map +0 -1
- package/lib/typescript/utils/api.d.ts +0 -6
- package/lib/typescript/utils/api.d.ts.map +0 -1
- package/lib/typescript/utils/auth.d.ts +0 -6
- package/lib/typescript/utils/auth.d.ts.map +0 -1
- package/lib/typescript/utils/crypto.d.ts +0 -4
- package/lib/typescript/utils/crypto.d.ts.map +0 -1
- package/lib/typescript/utils/debugHelper.d.ts +0 -29
- package/lib/typescript/utils/debugHelper.d.ts.map +0 -1
- package/lib/typescript/utils/encryption.d.ts +0 -19
- package/lib/typescript/utils/encryption.d.ts.map +0 -1
- package/lib/typescript/utils/onairosApi.d.ts +0 -87
- package/lib/typescript/utils/onairosApi.d.ts.map +0 -1
- package/lib/typescript/utils/programmaticFlow.d.ts +0 -23
- package/lib/typescript/utils/programmaticFlow.d.ts.map +0 -1
- package/lib/typescript/utils/retryHelper.d.ts +0 -69
- package/lib/typescript/utils/retryHelper.d.ts.map +0 -1
- package/lib/typescript/utils/secureStorage.d.ts +0 -94
- package/lib/typescript/utils/secureStorage.d.ts.map +0 -1
- package/src/api/index.ts +0 -111
- package/src/assets/images/email.png +0 -0
- package/src/assets/images/linkedin.png +0 -0
- package/src/assets/images/onairos_logo.png +0 -0
- package/src/assets/images/reddit.png +0 -0
- package/src/assets/images/youtube.png +0 -0
- package/src/components/DataRequestModal.tsx +0 -227
- package/src/components/DataRequestScreen.tsx +0 -356
- package/src/components/EmailVerificationModal.tsx +0 -364
- package/src/components/Onairos.tsx +0 -425
- package/src/components/OnairosButton.tsx +0 -359
- package/src/components/Overlay.tsx +0 -506
- package/src/components/PinInput.tsx +0 -343
- package/src/components/PlatformList.tsx +0 -145
- package/src/components/TrainingModal.tsx +0 -737
- package/src/components/UniversalOnboarding.tsx +0 -1839
- package/src/components/UniversalOnboarding.tsx.new +0 -455
- package/src/components/onboarding/OAuthWebView.tsx +0 -838
- package/src/components/onboarding/OnboardingHeader.tsx +0 -70
- package/src/components/onboarding/PinInput.tsx +0 -356
- package/src/components/onboarding/PlatformConnector.tsx +0 -302
- package/src/components/screens/ConnectorScreen.tsx +0 -153
- package/src/components/screens/LoadingScreen.tsx +0 -100
- package/src/components/screens/PinCreationScreen.tsx +0 -67
- package/src/constants/index.ts +0 -83
- package/src/hooks/useConnections.ts +0 -163
- package/src/hooks/useCredentials.ts +0 -175
- package/src/index.js +0 -14
- package/src/index.ts +0 -50
- package/src/services/SDK_API_KEY_VALIDATION.md +0 -421
- package/src/services/apiKeyService.ts +0 -984
- package/src/services/oauthService.ts +0 -412
- package/src/services/platformAuthService.ts +0 -1113
- package/src/types/ambient.d.ts +0 -29
- package/src/types/declarations.d.ts +0 -26
- package/src/types/index.d.ts +0 -274
- package/src/types/index.ts +0 -244
- package/src/types/node-fix.d.ts +0 -19
- package/src/types/node-override.d.ts +0 -24
- package/src/types/opacity.d.ts +0 -16
- package/src/types/types.d.ts +0 -18
- package/src/types.ts +0 -298
- package/src/utils/Portal.tsx +0 -83
- package/src/utils/api.js +0 -112
- package/src/utils/auth.js +0 -104
- package/src/utils/crypto.js +0 -60
- package/src/utils/debugHelper.ts +0 -53
- package/src/utils/encryption.ts +0 -69
- package/src/utils/onairosApi.ts +0 -391
- package/src/utils/programmaticFlow.ts +0 -113
- package/src/utils/retryHelper.ts +0 -275
- package/src/utils/secureStorage.ts +0 -361
- package/types/index.d.ts +0 -218
- package/types/node-env.d.ts +0 -15
- /package/{src/assets/images → lib/commonjs/assets/icons}/farcaster.png +0 -0
- /package/{src/assets/images → lib/commonjs/assets/icons}/instagram.png +0 -0
- /package/{src/assets/images → lib/commonjs/assets/icons}/pinterest.png +0 -0
- /package/{src/assets/images → lib/commonjs/assets/icons}/swerv_logo.png +0 -0
- /package/{src/assets/images → lib/commonjs/assets/icons}/twitter.jpg +0 -0
package/src/utils/retryHelper.ts
DELETED
|
@@ -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
|
-
};
|