@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.
- package/README.md +423 -374
- 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/OnairosNewLogo.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 +23 -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 +30 -1702
- package/lib/commonjs/components/VerificationStep.js +11 -0
- package/lib/commonjs/components/WelcomeScreen.js +22 -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 +18 -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 +34 -106
- package/lib/commonjs/services/SDK_API_KEY_VALIDATION.md +421 -421
- 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/hingeDataExtractor.js +8 -0
- package/lib/commonjs/services/hingeDataService.js +9 -0
- package/lib/commonjs/services/imageCompressionService.js +7 -0
- package/lib/commonjs/services/instagramDataExtractor.js +8 -0
- package/lib/commonjs/services/instagramDataService.js +9 -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/sephoraDataExtractor.js +8 -0
- package/lib/commonjs/services/sephoraDataService.js +9 -0
- package/lib/commonjs/services/storageService.js +8 -0
- package/lib/commonjs/services/telegramDataExtractor.js +8 -0
- package/lib/commonjs/services/telegramDataService.js +11 -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/connectorTests.js +29 -0
- 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/hinge.js +1 -0
- package/lib/commonjs/utils/webviewScripts/index.js +13 -0
- package/lib/commonjs/utils/webviewScripts/instagram.js +1 -0
- package/lib/commonjs/utils/webviewScripts/linkedin.js +1 -0
- package/lib/commonjs/utils/webviewScripts/sephora.js +1 -0
- package/lib/commonjs/utils/webviewScripts/telegram.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/OnairosNewLogo.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 +7 -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/SDK_API_KEY_VALIDATION.md +421 -421
- 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/hingeDataExtractor.js +1 -0
- package/lib/module/services/hingeDataService.js +1 -0
- package/lib/module/services/imageCompressionService.js +1 -0
- package/lib/module/services/instagramDataExtractor.js +1 -0
- package/lib/module/services/instagramDataService.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/sephoraDataExtractor.js +1 -0
- package/lib/module/services/sephoraDataService.js +1 -0
- package/lib/module/services/storageService.js +1 -0
- package/lib/module/services/telegramDataExtractor.js +1 -0
- package/lib/module/services/telegramDataService.js +8 -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/connectorTests.js +28 -0
- 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/hinge.js +1 -0
- package/lib/module/utils/webviewScripts/index.js +1 -0
- package/lib/module/utils/webviewScripts/instagram.js +1 -0
- package/lib/module/utils/webviewScripts/linkedin.js +1 -0
- package/lib/module/utils/webviewScripts/sephora.js +1 -0
- package/lib/module/utils/webviewScripts/telegram.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/encryption.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { onairosApi } from '../api';
|
|
2
|
-
import RSA from 'react-native-rsa-native';
|
|
3
|
-
import { ApiResponse } from '../types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Encrypt a model key using RSA with a public key
|
|
7
|
-
* @param publicKey The public key to encrypt with
|
|
8
|
-
* @param modelKey The model key to encrypt
|
|
9
|
-
* @returns The encrypted model key
|
|
10
|
-
*/
|
|
11
|
-
export const encryptModelKey = (publicKey: string, modelKey: string): string => {
|
|
12
|
-
try {
|
|
13
|
-
console.log('Encrypting model key');
|
|
14
|
-
|
|
15
|
-
if (!publicKey || !modelKey) {
|
|
16
|
-
throw new Error('Public key or model key is missing');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// In a production environment, this would use RSA encryption
|
|
20
|
-
// For now, we'll use a mock implementation
|
|
21
|
-
// return RSA.encrypt(modelKey, publicKey);
|
|
22
|
-
|
|
23
|
-
// Return a fake encrypted value
|
|
24
|
-
return `encrypted_${modelKey}_${Date.now()}`;
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error('Error encrypting model key:', error);
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get the server's public key
|
|
33
|
-
* @returns The server's public key
|
|
34
|
-
*/
|
|
35
|
-
export const getServerPublicKey = async (): Promise<string> => {
|
|
36
|
-
try {
|
|
37
|
-
// Use the API without generics to prevent TypeScript errors
|
|
38
|
-
const response = await onairosApi.get('public/getPublicKey');
|
|
39
|
-
|
|
40
|
-
// Check for the public key in the response data
|
|
41
|
-
if (response?.data?.data?.publicKey) {
|
|
42
|
-
return response.data.data.publicKey;
|
|
43
|
-
} else if (response?.data?.publicKey) {
|
|
44
|
-
return response.data.publicKey;
|
|
45
|
-
} else {
|
|
46
|
-
throw new Error('No public key found in response');
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error('Error getting server public key:', error);
|
|
50
|
-
// For testing, return a mock public key
|
|
51
|
-
return 'mock_public_key_for_testing';
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Hash a string using SHA-256
|
|
57
|
-
* @param input The string to hash
|
|
58
|
-
* @returns The hashed string
|
|
59
|
-
*/
|
|
60
|
-
export const hashString = async (input: string): Promise<string> => {
|
|
61
|
-
try {
|
|
62
|
-
// In a production environment, this would use a proper hashing function
|
|
63
|
-
// For now, we'll return a mock hash
|
|
64
|
-
return `hash_${input.replace(/\s+/g, '_')}_${Date.now()}`;
|
|
65
|
-
} catch (error) {
|
|
66
|
-
console.error('Error hashing string:', error);
|
|
67
|
-
return `fallback_hash_${Date.now()}`;
|
|
68
|
-
}
|
|
69
|
-
};
|
package/src/utils/onairosApi.ts
DELETED
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import NetInfo from '@react-native-community/netinfo';
|
|
3
|
-
import { OnairosCredentials } from './secureStorage';
|
|
4
|
-
import { logDebug } from './debugHelper';
|
|
5
|
-
import { getJWT, makeUserRequest, makeDeveloperRequest, isUserAuthenticated, extractUsernameFromJWT } from '../services/apiKeyService';
|
|
6
|
-
|
|
7
|
-
// API response types
|
|
8
|
-
export interface ApiResponse<T = any> {
|
|
9
|
-
success: boolean;
|
|
10
|
-
data?: T;
|
|
11
|
-
error?: {
|
|
12
|
-
code: string;
|
|
13
|
-
message: string;
|
|
14
|
-
details?: any;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Error types
|
|
19
|
-
export type ApiErrorType =
|
|
20
|
-
| 'network_error'
|
|
21
|
-
| 'timeout_error'
|
|
22
|
-
| 'auth_error'
|
|
23
|
-
| 'server_error'
|
|
24
|
-
| 'validation_error'
|
|
25
|
-
| 'unknown_error';
|
|
26
|
-
|
|
27
|
-
// API error structure
|
|
28
|
-
export class ApiError extends Error {
|
|
29
|
-
type: ApiErrorType;
|
|
30
|
-
code?: string;
|
|
31
|
-
details?: any;
|
|
32
|
-
|
|
33
|
-
constructor(message: string, type: ApiErrorType, code?: string, details?: any) {
|
|
34
|
-
super(message);
|
|
35
|
-
this.type = type;
|
|
36
|
-
this.code = code;
|
|
37
|
-
this.details = details;
|
|
38
|
-
this.name = 'ApiError';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Check if the device has an active network connection
|
|
44
|
-
*/
|
|
45
|
-
const checkNetworkConnection = async (): Promise<boolean> => {
|
|
46
|
-
const networkState = await NetInfo.fetch();
|
|
47
|
-
return networkState.isConnected === true;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Make user-authenticated API request using JWT token
|
|
52
|
-
*/
|
|
53
|
-
const makeUserApiRequest = async <T>(
|
|
54
|
-
endpoint: string,
|
|
55
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',
|
|
56
|
-
options: {
|
|
57
|
-
data?: any;
|
|
58
|
-
headers?: Record<string, string>;
|
|
59
|
-
debug?: boolean;
|
|
60
|
-
} = {}
|
|
61
|
-
): Promise<ApiResponse<T>> => {
|
|
62
|
-
const { data, headers = {}, debug = false } = options;
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
// Check for network connectivity
|
|
66
|
-
const isConnected = await checkNetworkConnection();
|
|
67
|
-
if (!isConnected) {
|
|
68
|
-
throw new ApiError(
|
|
69
|
-
'No network connection available',
|
|
70
|
-
'network_error'
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Check if user is authenticated
|
|
75
|
-
if (!isUserAuthenticated()) {
|
|
76
|
-
throw new ApiError(
|
|
77
|
-
'User not authenticated. Please verify email first.',
|
|
78
|
-
'auth_error'
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Log request information if debug mode is enabled
|
|
83
|
-
if (debug) {
|
|
84
|
-
logDebug('User API Request', {
|
|
85
|
-
endpoint,
|
|
86
|
-
method,
|
|
87
|
-
headers: { ...headers, Authorization: '[REDACTED]' },
|
|
88
|
-
data: data || null,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Make authenticated request using JWT token
|
|
93
|
-
const response = await makeUserRequest(endpoint, {
|
|
94
|
-
method,
|
|
95
|
-
headers,
|
|
96
|
-
...(data ? { body: JSON.stringify(data) } : {}),
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Parse response as JSON
|
|
100
|
-
const responseData = await response.json();
|
|
101
|
-
|
|
102
|
-
// Log response if debug mode is enabled
|
|
103
|
-
if (debug) {
|
|
104
|
-
logDebug('User API Response', {
|
|
105
|
-
status: response.status,
|
|
106
|
-
data: responseData,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Handle API error responses
|
|
111
|
-
if (!response.ok) {
|
|
112
|
-
const errorType: ApiErrorType =
|
|
113
|
-
response.status === 401 || response.status === 403 ? 'auth_error' :
|
|
114
|
-
response.status === 400 ? 'validation_error' :
|
|
115
|
-
response.status >= 500 ? 'server_error' : 'unknown_error';
|
|
116
|
-
|
|
117
|
-
throw new ApiError(
|
|
118
|
-
responseData.error?.message || 'API request failed',
|
|
119
|
-
errorType,
|
|
120
|
-
responseData.error?.code,
|
|
121
|
-
responseData.error?.details
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return responseData as ApiResponse<T>;
|
|
126
|
-
} catch (error) {
|
|
127
|
-
// Handle specific error types
|
|
128
|
-
if (error instanceof ApiError) {
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (error.name === 'AbortError') {
|
|
133
|
-
throw new ApiError('Request timed out', 'timeout_error');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Log error if debug mode is enabled
|
|
137
|
-
if (debug) {
|
|
138
|
-
logDebug('User API Error', {
|
|
139
|
-
endpoint,
|
|
140
|
-
method,
|
|
141
|
-
error: error.message || 'Unknown error',
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Return a generic error for all other cases
|
|
146
|
-
throw new ApiError(
|
|
147
|
-
error.message || 'An unexpected error occurred',
|
|
148
|
-
'unknown_error'
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Make developer-authenticated API request using API key
|
|
155
|
-
*/
|
|
156
|
-
const makeDeveloperApiRequest = async <T>(
|
|
157
|
-
endpoint: string,
|
|
158
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',
|
|
159
|
-
options: {
|
|
160
|
-
data?: any;
|
|
161
|
-
headers?: Record<string, string>;
|
|
162
|
-
debug?: boolean;
|
|
163
|
-
} = {}
|
|
164
|
-
): Promise<ApiResponse<T>> => {
|
|
165
|
-
const { data, headers = {}, debug = false } = options;
|
|
166
|
-
|
|
167
|
-
try {
|
|
168
|
-
// Check for network connectivity
|
|
169
|
-
const isConnected = await checkNetworkConnection();
|
|
170
|
-
if (!isConnected) {
|
|
171
|
-
throw new ApiError(
|
|
172
|
-
'No network connection available',
|
|
173
|
-
'network_error'
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Log request information if debug mode is enabled
|
|
178
|
-
if (debug) {
|
|
179
|
-
logDebug('Developer API Request', {
|
|
180
|
-
endpoint,
|
|
181
|
-
method,
|
|
182
|
-
headers: { ...headers, Authorization: '[REDACTED]' },
|
|
183
|
-
data: data || null,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Make authenticated request using developer API key
|
|
188
|
-
const response = await makeDeveloperRequest(endpoint, {
|
|
189
|
-
method,
|
|
190
|
-
headers,
|
|
191
|
-
...(data ? { body: JSON.stringify(data) } : {}),
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// Parse response as JSON
|
|
195
|
-
const responseData = await response.json();
|
|
196
|
-
|
|
197
|
-
// Log response if debug mode is enabled
|
|
198
|
-
if (debug) {
|
|
199
|
-
logDebug('Developer API Response', {
|
|
200
|
-
status: response.status,
|
|
201
|
-
data: responseData,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Handle API error responses
|
|
206
|
-
if (!response.ok) {
|
|
207
|
-
const errorType: ApiErrorType =
|
|
208
|
-
response.status === 401 || response.status === 403 ? 'auth_error' :
|
|
209
|
-
response.status === 400 ? 'validation_error' :
|
|
210
|
-
response.status >= 500 ? 'server_error' : 'unknown_error';
|
|
211
|
-
|
|
212
|
-
throw new ApiError(
|
|
213
|
-
responseData.error?.message || 'API request failed',
|
|
214
|
-
errorType,
|
|
215
|
-
responseData.error?.code,
|
|
216
|
-
responseData.error?.details
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return responseData as ApiResponse<T>;
|
|
221
|
-
} catch (error) {
|
|
222
|
-
// Handle specific error types
|
|
223
|
-
if (error instanceof ApiError) {
|
|
224
|
-
throw error;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (error.name === 'AbortError') {
|
|
228
|
-
throw new ApiError('Request timed out', 'timeout_error');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Log error if debug mode is enabled
|
|
232
|
-
if (debug) {
|
|
233
|
-
logDebug('Developer API Error', {
|
|
234
|
-
endpoint,
|
|
235
|
-
method,
|
|
236
|
-
error: error.message || 'Unknown error',
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Return a generic error for all other cases
|
|
241
|
-
throw new ApiError(
|
|
242
|
-
error.message || 'An unexpected error occurred',
|
|
243
|
-
'unknown_error'
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Validate user credentials with the API (uses JWT)
|
|
250
|
-
*/
|
|
251
|
-
export const validateCredentials = async (
|
|
252
|
-
username: string,
|
|
253
|
-
options = { debug: false }
|
|
254
|
-
): Promise<{ isValid: boolean; message?: string }> => {
|
|
255
|
-
try {
|
|
256
|
-
const response = await makeUserApiRequest<{ isValid: boolean }>('auth/validate', 'POST', {
|
|
257
|
-
data: { username },
|
|
258
|
-
debug: options.debug,
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
isValid: response.success && response.data?.isValid === true,
|
|
263
|
-
message: response.error?.message,
|
|
264
|
-
};
|
|
265
|
-
} catch (error) {
|
|
266
|
-
return {
|
|
267
|
-
isValid: false,
|
|
268
|
-
message: error.message,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Create a new user account (uses developer API key)
|
|
275
|
-
*/
|
|
276
|
-
export const createAccount = async (
|
|
277
|
-
credentials: Partial<OnairosCredentials>,
|
|
278
|
-
options = { debug: false }
|
|
279
|
-
): Promise<ApiResponse<{ accessToken: string; userId: string }>> => {
|
|
280
|
-
return makeDeveloperApiRequest('auth/register', 'POST', {
|
|
281
|
-
data: {
|
|
282
|
-
username: credentials.username,
|
|
283
|
-
platforms: credentials.platforms,
|
|
284
|
-
},
|
|
285
|
-
debug: options.debug,
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Authenticate with the API using credentials (uses JWT)
|
|
291
|
-
*/
|
|
292
|
-
export const authenticate = async (
|
|
293
|
-
credentials: Partial<OnairosCredentials>,
|
|
294
|
-
options = { debug: false }
|
|
295
|
-
): Promise<ApiResponse<{ accessToken: string; refreshToken: string }>> => {
|
|
296
|
-
return makeUserApiRequest('auth/login', 'POST', {
|
|
297
|
-
data: {
|
|
298
|
-
username: credentials.username,
|
|
299
|
-
pin: credentials.userPin,
|
|
300
|
-
},
|
|
301
|
-
debug: options.debug,
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Refresh authentication token (uses JWT)
|
|
307
|
-
*/
|
|
308
|
-
export const refreshToken = async (
|
|
309
|
-
refreshToken: string,
|
|
310
|
-
options = { debug: false }
|
|
311
|
-
): Promise<ApiResponse<{ accessToken: string; refreshToken: string }>> => {
|
|
312
|
-
return makeUserApiRequest('auth/refresh', 'POST', {
|
|
313
|
-
data: { refreshToken },
|
|
314
|
-
debug: options.debug,
|
|
315
|
-
});
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Get user's connected platform data (uses JWT)
|
|
320
|
-
*/
|
|
321
|
-
export const getPlatformData = async (
|
|
322
|
-
platform: string,
|
|
323
|
-
options = { debug: false }
|
|
324
|
-
): Promise<ApiResponse<any>> => {
|
|
325
|
-
return makeUserApiRequest(`platforms/${platform}/data`, 'GET', {
|
|
326
|
-
debug: options.debug,
|
|
327
|
-
});
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Get user profile information (uses JWT)
|
|
332
|
-
*/
|
|
333
|
-
export const getUserProfile = async (
|
|
334
|
-
options = { debug: false }
|
|
335
|
-
): Promise<ApiResponse<any>> => {
|
|
336
|
-
return makeUserApiRequest('user/profile', 'GET', {
|
|
337
|
-
debug: options.debug,
|
|
338
|
-
});
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Update user platform connections (uses JWT)
|
|
343
|
-
*/
|
|
344
|
-
export const updatePlatformConnections = async (
|
|
345
|
-
platforms: Record<string, any>,
|
|
346
|
-
options = { debug: false }
|
|
347
|
-
): Promise<ApiResponse<any>> => {
|
|
348
|
-
return makeUserApiRequest('user/platforms', 'PUT', {
|
|
349
|
-
data: { platforms },
|
|
350
|
-
debug: options.debug,
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Store user PIN (uses JWT and extracts username from JWT)
|
|
356
|
-
*/
|
|
357
|
-
export const storePIN = async (
|
|
358
|
-
pin: string,
|
|
359
|
-
options: { debug?: boolean; username?: string } = {}
|
|
360
|
-
): Promise<ApiResponse<any>> => {
|
|
361
|
-
const { debug = false, username } = options;
|
|
362
|
-
|
|
363
|
-
// Extract username from JWT if not provided
|
|
364
|
-
const userToStore = username || extractUsernameFromJWT();
|
|
365
|
-
|
|
366
|
-
if (!userToStore) {
|
|
367
|
-
throw new ApiError(
|
|
368
|
-
'No username available - either provide username or ensure JWT token is valid',
|
|
369
|
-
'auth_error'
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return makeUserApiRequest('store-pin/mobile', 'POST', {
|
|
374
|
-
data: { username: userToStore, pin },
|
|
375
|
-
debug,
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Get current JWT token
|
|
381
|
-
*/
|
|
382
|
-
export const getCurrentUserToken = async (): Promise<string | null> => {
|
|
383
|
-
return await getJWT();
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Check if user is authenticated with JWT
|
|
388
|
-
*/
|
|
389
|
-
export const isCurrentUserAuthenticated = (): boolean => {
|
|
390
|
-
return isUserAuthenticated();
|
|
391
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Programmatic Onairos Flow
|
|
3
|
-
*
|
|
4
|
-
* This function executes the complete Onairos authentication and onboarding flow
|
|
5
|
-
* that can be attached to custom buttons or called programmatically.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { OnairosButtonProps } from '../types';
|
|
9
|
-
import { initializePlatformAuthService } from '../services/platformAuthService';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Execute the complete Onairos flow programmatically
|
|
13
|
-
* This is the same logic that the OnairosButton uses internally
|
|
14
|
-
*
|
|
15
|
-
* @param options Configuration options for the flow
|
|
16
|
-
* @returns Promise that resolves when flow is complete
|
|
17
|
-
*/
|
|
18
|
-
export const executeOnairosFlow = async (options: OnairosButtonProps): Promise<void> => {
|
|
19
|
-
try {
|
|
20
|
-
console.log('🚀 Starting Onairos flow programmatically...');
|
|
21
|
-
|
|
22
|
-
// Initialize API key service if not already initialized
|
|
23
|
-
await initializePlatformAuthService();
|
|
24
|
-
|
|
25
|
-
// Import components dynamically to avoid circular dependencies
|
|
26
|
-
const { UniversalOnboarding } = await import('../components/UniversalOnboarding');
|
|
27
|
-
const React = await import('react');
|
|
28
|
-
|
|
29
|
-
// Create a promise that resolves when the flow is complete
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
let modalRef: any = null;
|
|
32
|
-
|
|
33
|
-
const handleComplete = (apiUrl: string, token: string, userData: any) => {
|
|
34
|
-
console.log('✅ Onairos flow completed successfully');
|
|
35
|
-
|
|
36
|
-
// Clean up modal
|
|
37
|
-
if (modalRef && modalRef.close) {
|
|
38
|
-
modalRef.close();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Call user's onResolved callback
|
|
42
|
-
if (options.onResolved) {
|
|
43
|
-
options.onResolved(apiUrl, token, userData);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
resolve();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const handleRejection = (error?: string) => {
|
|
50
|
-
console.log('❌ Onairos flow rejected:', error);
|
|
51
|
-
|
|
52
|
-
// Clean up modal
|
|
53
|
-
if (modalRef && modalRef.close) {
|
|
54
|
-
modalRef.close();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Call user's onRejection callback
|
|
58
|
-
if (options.onRejection) {
|
|
59
|
-
options.onRejection(error);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
reject(new Error(error || 'Onairos flow was rejected'));
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Create and show the Universal Onboarding modal
|
|
66
|
-
const modalElement = React.createElement(UniversalOnboarding, {
|
|
67
|
-
visible: true,
|
|
68
|
-
onClose: () => handleRejection('User closed the modal'),
|
|
69
|
-
AppName: options.AppName,
|
|
70
|
-
requestData: options.requestData,
|
|
71
|
-
returnLink: options.returnLink,
|
|
72
|
-
onComplete: handleComplete,
|
|
73
|
-
preferredPlatform: options.preferredPlatform,
|
|
74
|
-
debug: options.debug,
|
|
75
|
-
testMode: options.testMode,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Store modal reference for cleanup
|
|
79
|
-
modalRef = modalElement;
|
|
80
|
-
|
|
81
|
-
// Note: In a real implementation, you'd need to render this modal
|
|
82
|
-
// This is a simplified version - the actual implementation would
|
|
83
|
-
// need to handle React rendering in the current app context
|
|
84
|
-
console.log('📱 Onairos modal should be displayed');
|
|
85
|
-
});
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.error('❌ Failed to execute Onairos flow:', error);
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Simple wrapper function that matches the OnairosButton click behavior
|
|
94
|
-
*
|
|
95
|
-
* @param options Configuration options for the flow
|
|
96
|
-
* @returns Promise that resolves when flow is complete
|
|
97
|
-
*/
|
|
98
|
-
export const startOnairosFlow = async (options: OnairosButtonProps): Promise<void> => {
|
|
99
|
-
// Pre-check if provided
|
|
100
|
-
if (options.preCheck) {
|
|
101
|
-
const canProceed = await options.preCheck();
|
|
102
|
-
if (!canProceed) {
|
|
103
|
-
console.log('❌ Pre-check failed, not starting Onairos flow');
|
|
104
|
-
if (options.onRejection) {
|
|
105
|
-
options.onRejection('Pre-check failed');
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Execute the flow
|
|
112
|
-
return executeOnairosFlow(options);
|
|
113
|
-
};
|