@onairos/react-native 3.7.2 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +116 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +109 -1
- package/lib/module/components/EmailInput.js +23 -1
- package/lib/module/components/GoogleButton.js +49 -1
- package/lib/module/components/HeadingGroup.js +36 -1
- package/lib/module/components/LLMDataInputModal.js +656 -7
- package/lib/module/components/ModalHeader.js +92 -1
- package/lib/module/components/ModalSheet.js +39 -1
- package/lib/module/components/Onairos.js +373 -1
- package/lib/module/components/OnairosButton.js +305 -1
- package/lib/module/components/OnairosSignInButton.js +121 -1
- package/lib/module/components/Overlay.js +456 -1
- package/lib/module/components/PersonaImage.js +129 -1
- package/lib/module/components/PersonaLoadingScreen.js +310 -1
- package/lib/module/components/PersonalizationConsentScreen.js +460 -1
- package/lib/module/components/PinCreationScreen.js +396 -1
- package/lib/module/components/PinInput.js +456 -1
- package/lib/module/components/PlatformConnectorsStep.js +1302 -6
- package/lib/module/components/PlatformList.js +129 -1
- package/lib/module/components/PlatformToggle.js +173 -1
- package/lib/module/components/PrimaryButton.js +172 -1
- package/lib/module/components/SignInMatchAnimation.js +189 -1
- package/lib/module/components/SignInStep.js +338 -1
- package/lib/module/components/UniversalOnboarding.js +2770 -1
- package/lib/module/components/VerificationStep.js +168 -1
- package/lib/module/components/WelcomeScreen.js +453 -1
- package/lib/module/components/icons/Basicproficon.js +30 -1
- package/lib/module/components/icons/Basicprofile.js +14 -1
- package/lib/module/components/icons/Checkbox.js +14 -1
- package/lib/module/components/icons/Checkmark.js +20 -1
- package/lib/module/components/icons/Contentanalysis.js +14 -1
- package/lib/module/components/icons/Contenticon.js +32 -1
- package/lib/module/components/icons/EnochE.js +34 -1
- package/lib/module/components/icons/Personalityicon.js +23 -1
- package/lib/module/components/icons/Personalityprofile.js +14 -1
- package/lib/module/components/icons/Personalitytraits.js +14 -1
- package/lib/module/components/icons/Userpreferences.js +14 -1
- package/lib/module/components/icons/index.js +13 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
- package/lib/module/components/onboarding/PinInput.js +274 -1
- package/lib/module/components/onboarding/PlatformConnector.js +240 -1
- package/lib/module/config/PLATFORM_APIS.md +849 -0
- package/lib/module/config/api.js +47 -1
- package/lib/module/constants/index.js +114 -1
- package/lib/module/context/AuthContext.js +335 -1
- package/lib/module/hooks/useConnectedAccounts.js +106 -1
- package/lib/module/hooks/useConnections.js +95 -1
- package/lib/module/hooks/useCredentials.js +171 -6
- package/lib/module/hooks/useUserConnections.js +140 -1
- package/lib/module/index.js +172 -1
- package/lib/module/services/apiClient.js +295 -1
- package/lib/module/services/biometricPinService.js +169 -1
- package/lib/module/services/chatGPTConversationExtractor.js +149 -1
- package/lib/module/services/chatGPTConversationService.js +268 -1
- package/lib/module/services/claudeConversationExtractor.js +97 -1
- package/lib/module/services/claudeConversationService.js +151 -1
- package/lib/module/services/connectedAccountsService.js +293 -1
- package/lib/module/services/googleAuthService.js +241 -1
- package/lib/module/services/hingeDataExtractor.js +99 -1
- package/lib/module/services/hingeDataService.js +143 -1
- package/lib/module/services/imageCompressionService.js +250 -1
- package/lib/module/services/instagramDataExtractor.js +120 -1
- package/lib/module/services/instagramDataService.js +156 -1
- package/lib/module/services/jwtStorageService.js +257 -1
- package/lib/module/services/linkedinDOMExtractor.js +234 -1
- package/lib/module/services/linkedinProfileService.js +210 -1
- package/lib/module/services/linkedinScrapingService.js +219 -1
- package/lib/module/services/llmDataStorage.js +277 -1
- package/lib/module/services/mobileTrainingService.js +173 -1
- package/lib/module/services/netflixDataExtractor.js +114 -1
- package/lib/module/services/netflixDataService.js +191 -1
- package/lib/module/services/pinEncryptionService.js +74 -6
- package/lib/module/services/pinStorageUtils.js +93 -1
- package/lib/module/services/platformAuthService.js +1461 -1
- package/lib/module/services/sephoraDataExtractor.js +134 -1
- package/lib/module/services/sephoraDataService.js +193 -1
- package/lib/module/services/spotifyDataExtractor.js +142 -1
- package/lib/module/services/spotifyDataService.js +234 -1
- package/lib/module/services/storageService.js +383 -1
- package/lib/module/services/telegramDataExtractor.js +109 -1
- package/lib/module/services/telegramDataService.js +493 -1
- package/lib/module/services/trainingApiHelpers.js +67 -1
- package/lib/module/services/userConnectionsService.js +329 -1
- package/lib/module/services/youtubeMigrationService.js +405 -1
- package/lib/module/theme/index.js +245 -1
- package/lib/module/types.js +10 -1
- package/lib/module/utils/Portal.js +90 -1
- package/lib/module/utils/api.js +118 -1
- package/lib/module/utils/assetRegistry.js +200 -34
- package/lib/module/utils/auth.js +100 -1
- package/lib/module/utils/connectorTests.js +600 -27
- package/lib/module/utils/crypto.js +54 -1
- package/lib/module/utils/debugHelper.js +54 -1
- package/lib/module/utils/encryption.js +67 -1
- package/lib/module/utils/eventUtils.js +270 -1
- package/lib/module/utils/haptics.js +59 -8
- package/lib/module/utils/imagePreloader.js +3 -1
- package/lib/module/utils/networkDiagnostics.js +217 -1
- package/lib/module/utils/onairosApi.js +333 -1
- package/lib/module/utils/programmaticFlow.js +111 -1
- package/lib/module/utils/retryHelper.js +211 -1
- package/lib/module/utils/secureStorage.js +330 -6
- package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
- package/lib/module/utils/webviewScripts/claude.js +370 -1
- package/lib/module/utils/webviewScripts/hinge.js +405 -1
- package/lib/module/utils/webviewScripts/index.js +434 -1
- package/lib/module/utils/webviewScripts/instagram.js +448 -1
- package/lib/module/utils/webviewScripts/linkedin.js +874 -1
- package/lib/module/utils/webviewScripts/netflix.js +376 -1
- package/lib/module/utils/webviewScripts/sephora.js +510 -1
- package/lib/module/utils/webviewScripts/spotify.js +413 -1
- package/lib/module/utils/webviewScripts/telegram.js +672 -1
- package/package.json +2 -2
|
@@ -1,11 +1,252 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Object[_0x2a6a(0x0)](exports,_0x2a6a(0x1),{'value':!![]}),exports[_0x2a6a(0x2)]=exports[_0x2a6a(0x3)]=exports[_0x2a6a(0x4)]=exports[_0x2a6a(0x5)]=void 0x0;var _googleSignin=__ONAIROS_REQ_FUNC__(0x0),_asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x1)),_api=__ONAIROS_REQ_FUNC__(0x2),_apiKeyService=__ONAIROS_REQ_FUNC__(0x3),_jwtStorageService=__ONAIROS_REQ_FUNC__(0x4);function _interopRequireDefault(_0x77ad1){return _0x77ad1&&_0x77ad1[_0x2a6a(0x1)]?_0x77ad1:{'default':_0x77ad1};}let WEB_CLIENT_ID=_0x2a6a(0x6),IOS_CLIENT_ID=_0x2a6a(0x6);const updateGoogleClientIds=_0x31983e=>{const _0x457f06={'EecIG':_0x2a6a(0x7),'NaiWc':function(_0x514f33,_0x4e1713){return _0x514f33===_0x4e1713;},'iHnKg':_0x2a6a(0x8)};_0x31983e[_0x2a6a(0x9)]&&(_0x457f06[_0x2a6a(0xa)](_0x457f06[_0x2a6a(0xb)],_0x457f06[_0x2a6a(0xb)])?WEB_CLIENT_ID=_0x31983e[_0x2a6a(0x9)]:(_0x2acf07[_0x2a6a(0x9)]&&(_0x10d164=_0x35e08c[_0x2a6a(0x9)]),_0x12e2ef[_0x2a6a(0xc)]&&(_0x4e2cec=_0x28fbb0[_0x2a6a(0xc)]),_0x5241d3[_0x2a6a(0xd)](_0x457f06[_0x2a6a(0xe)],{'webClientId':_0x2ba12f,'iosClientId':_0x3405ad}))),_0x31983e[_0x2a6a(0xc)]&&(IOS_CLIENT_ID=_0x31983e[_0x2a6a(0xc)]),console[_0x2a6a(0xd)](_0x457f06[_0x2a6a(0xe)],{'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID});};exports[_0x2a6a(0x2)]=updateGoogleClientIds;function _0x2a6a(_0x35e9b8,_0x2a6a1c){_0x35e9b8=_0x35e9b8-0x0;const _0x2d8849=_0x35e9();let _0x252428=_0x2d8849[_0x35e9b8];return _0x252428;}const initializeGoogleAuth=()=>{const _0xda6f27={'lRGcz':_0x2a6a(0xf),'ULQqs':_0x2a6a(0x10),'sWdyu':_0x2a6a(0x11)};_googleSignin[_0x2a6a(0x12)][_0x2a6a(0x13)]({'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID,'scopes':[_0xda6f27[_0x2a6a(0x14)],_0xda6f27[_0x2a6a(0x15)],_0xda6f27['sWdyu']],'offlineAccess':!![],'forceCodeForRefreshToken':!![],'hostedDomain':'','accountName':''});},signInWithGoogle=async()=>{const _0x47cf0e={'iZikn':_0x2a6a(0x16),'fyfvO':_0x2a6a(0x17),'pOFrM':'🔄\x20Signed\x20out\x20to\x20ensure\x20fresh\x20consent','GIzAY':function(_0xc0ad69,_0x5ee984){return _0xc0ad69!==_0x5ee984;},'tQUlG':'fVQUJ','rlDqA':'qRqgv','YFPmb':_0x2a6a(0x18),'XyNhm':'✅\x20Google\x20Sign-In\x20successful:','utlpd':function(_0x4fea5b,_0xccbd96){return _0x4fea5b===_0xccbd96;},'ISrGc':function(_0xf95acf,_0x1685d0){return _0xf95acf===_0x1685d0;},'PjWhn':_0x2a6a(0x19),'xYsHc':_0x2a6a(0x1a),'jQSlz':_0x2a6a(0x1b),'PRUBQ':function(_0x325441,_0x51f0c8){return _0x325441(_0x51f0c8);},'eYdQc':_0x2a6a(0x1c),'znbgV':_0x2a6a(0x1d),'fpCds':_0x2a6a(0x1e),'ZMiWH':'auth_method','kXMdG':_0x2a6a(0x1f),'jfGfg':function(_0x55945e,_0x212c34){return _0x55945e===_0x212c34;},'QSyLf':_0x2a6a(0x20),'meaxb':'❌\x20Google\x20Sign-In\x20error:','xuPix':'Google\x20Sign-In\x20was\x20cancelled','fyoVy':function(_0x11abc4,_0x39dc03){return _0x11abc4===_0x39dc03;},'cHhns':function(_0x426663,_0x4c3974){return _0x426663===_0x4c3974;},'mgKmL':'Google\x20Play\x20Services\x20not\x20available','dGyFq':_0x2a6a(0x21),'crsgq':_0x2a6a(0x22)};try{var _0x680338,_0x1dee6;console[_0x2a6a(0xd)](_0x47cf0e[_0x2a6a(0x23)]),initializeGoogleAuth(),await _googleSignin[_0x2a6a(0x12)][_0x2a6a(0x24)]();try{await _googleSignin[_0x2a6a(0x12)]['signOut'](),console[_0x2a6a(0xd)](_0x47cf0e[_0x2a6a(0x25)]);}catch(_0x4a5a70){if(_0x47cf0e[_0x2a6a(0x26)](_0x47cf0e[_0x2a6a(0x27)],_0x47cf0e['rlDqA']))console[_0x2a6a(0xd)](_0x47cf0e[_0x2a6a(0x28)],_0x4a5a70);else return{'isSignedIn':!![],'user':_0x4c0063===null||_0x2d962e===void 0x0?void 0x0:_0x10da8d[_0x2a6a(0x29)]};}const _0x3dafbd=await _googleSignin['GoogleSignin'][_0x2a6a(0x2a)]();console[_0x2a6a(0xd)](_0x47cf0e[_0x2a6a(0x2b)],_0x47cf0e[_0x2a6a(0x2c)](_0x680338=_0x3dafbd[_0x2a6a(0x2d)],null)||_0x47cf0e[_0x2a6a(0x2c)](_0x680338,void 0x0)||_0x47cf0e[_0x2a6a(0x2e)](_0x680338=_0x680338[_0x2a6a(0x29)],null)||_0x47cf0e[_0x2a6a(0x2e)](_0x680338,void 0x0)?void 0x0:_0x680338[_0x2a6a(0x11)]);const _0x193a3f=(_0x1dee6=_0x3dafbd[_0x2a6a(0x2d)])===null||_0x47cf0e[_0x2a6a(0x2c)](_0x1dee6,void 0x0)?void 0x0:_0x1dee6[_0x2a6a(0x29)];if(!_0x193a3f||!_0x193a3f[_0x2a6a(0x11)])throw new Error(_0x47cf0e['PjWhn']);console['log'](_0x47cf0e[_0x2a6a(0x2f)],{'email':_0x193a3f[_0x2a6a(0x11)],'name':_0x193a3f[_0x2a6a(0x30)],'photo':_0x193a3f[_0x2a6a(0x31)],'id':_0x193a3f['id']});const _0x3e0927=await _googleSignin[_0x2a6a(0x12)]['getTokens']();console[_0x2a6a(0xd)](_0x47cf0e[_0x2a6a(0x32)]);const _0x513e4f=await _0x47cf0e['PRUBQ'](createUserAccount,{'email':_0x193a3f[_0x2a6a(0x11)],'name':_0x193a3f[_0x2a6a(0x30)]||_0x193a3f['email']['split']('@')[0x0],'photoUrl':_0x193a3f[_0x2a6a(0x31)]||'','googleId':_0x193a3f['id'],'accessToken':_0x3e0927[_0x2a6a(0x33)],'idToken':_0x3e0927['idToken']});if(_0x513e4f[_0x2a6a(0x34)]){var _0x3edeea,_0x41f0a6;return console['log'](_0x47cf0e[_0x2a6a(0x35)]),await _asyncStorage[_0x2a6a(0x36)][_0x2a6a(0x37)](_0x47cf0e[_0x2a6a(0x38)],_0x193a3f[_0x2a6a(0x11)]),await _asyncStorage[_0x2a6a(0x36)][_0x2a6a(0x37)](_0x47cf0e[_0x2a6a(0x39)],_0x193a3f[_0x2a6a(0x11)][_0x2a6a(0x3a)]('@')[0x0]),await _asyncStorage[_0x2a6a(0x36)][_0x2a6a(0x37)](_0x47cf0e[_0x2a6a(0x3b)],_0x47cf0e[_0x2a6a(0x3c)]),_0x513e4f[_0x2a6a(0x3d)]&&await(0x0,_jwtStorageService['storeJWT'])(_0x513e4f[_0x2a6a(0x3d)]),{'success':!![],'user':{'id':(_0x47cf0e['jfGfg'](_0x3edeea=_0x513e4f[_0x2a6a(0x29)],null)||_0x3edeea===void 0x0?void 0x0:_0x3edeea['id'])||'','email':_0x193a3f[_0x2a6a(0x11)],'username':_0x193a3f[_0x2a6a(0x30)]||_0x193a3f[_0x2a6a(0x11)]['split']('@')[0x0],'odeanId':_0x47cf0e[_0x2a6a(0x2c)](_0x41f0a6=_0x513e4f[_0x2a6a(0x29)],null)||_0x41f0a6===void 0x0?void 0x0:_0x41f0a6['odeanId']},'token':_0x513e4f[_0x2a6a(0x3d)],'isNewUser':_0x513e4f['isNewUser']||![]};}else throw new Error(_0x513e4f[_0x2a6a(0x3e)]||_0x47cf0e[_0x2a6a(0x3f)]);}catch(_0x457d7a){console[_0x2a6a(0x40)](_0x47cf0e[_0x2a6a(0x41)],_0x457d7a);if(_0x47cf0e[_0x2a6a(0x42)](_0x457d7a['code'],_googleSignin[_0x2a6a(0x43)][_0x2a6a(0x44)]))return{'success':![],'message':_0x47cf0e['xuPix'],'cancelled':!![]};else{if(_0x47cf0e[_0x2a6a(0x45)](_0x457d7a[_0x2a6a(0x46)],_googleSignin['statusCodes'][_0x2a6a(0x47)]))return{'success':![],'message':_0x2a6a(0x48)};else return _0x47cf0e[_0x2a6a(0x49)](_0x457d7a['code'],_googleSignin['statusCodes']['PLAY_SERVICES_NOT_AVAILABLE'])?{'success':![],'message':_0x47cf0e[_0x2a6a(0x4a)]}:_0x47cf0e['GIzAY']('OWpBm',_0x47cf0e[_0x2a6a(0x4b)])?(_0x51bbf1[_0x2a6a(0x40)](_0x47cf0e['iZikn'],_0x50682b),![]):{'success':![],'message':_0x457d7a[_0x2a6a(0x3e)]||_0x47cf0e[_0x2a6a(0x4c)]};}}};exports[_0x2a6a(0x4)]=signInWithGoogle;function _0x35e9(){const _0x529983=['defineProperty','__esModule','updateGoogleClientIds','signOutFromGoogle','signInWithGoogle','isGoogleSignedIn','1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com','✅\x20Google\x20client\x20IDs\x20updated:','xvCjP','webClientId','NaiWc','iHnKg','iosClientId','log','EecIG','openid','profile','email','GoogleSignin','configure','lRGcz','ULQqs','❌\x20Google\x20sign-out\x20error:','🔗\x20Initiating\x20Google\x20Sign-In\x20for\x20user\x20authentication','ℹ️\x20Sign\x20out\x20not\x20needed\x20or\x20failed:','No\x20user\x20data\x20received\x20from\x20Google','👤\x20Google\x20user\x20data:','🔑\x20Got\x20Google\x20tokens','✅\x20User\x20account\x20created/authenticated\x20successfully','user_email','onairos_username','google','Failed\x20to\x20create\x20user\x20account','OWpBm','Google\x20Sign-In\x20failed','fyfvO','hasPlayServices','pOFrM','GIzAY','tQUlG','YFPmb','user','signIn','XyNhm','utlpd','data','ISrGc','xYsHc','name','photo','jQSlz','accessToken','success','eYdQc','default','setItem','znbgV','fpCds','split','ZMiWH','kXMdG','token','message','QSyLf','error','meaxb','jfGfg','statusCodes','SIGN_IN_CANCELLED','fyoVy','code','IN_PROGRESS','Google\x20Sign-In\x20is\x20already\x20in\x20progress','cHhns','mgKmL','dGyFq','crsgq','❌\x20Error\x20checking\x20Google\x20sign-in\x20status:','nuXMb','📡\x20Google\x20register\x20response\x20status:','🔗\x20Account\x20creation\x20response:','SxXsX','bpWap','zZZVG','🔐\x20Creating/authenticating\x20user\x20account\x20for:','🔐\x20Calling\x20generic\x20/register/google\x20endpoint...','lXdPb','API_CONFIG','BASE_URL','/register/google','stringify','dgKUR','status','json','VulPk','isNewUser','neefh','cBawr','Failed\x20to\x20create\x20account','Xliis','Account\x20created/authenticated\x20successfully','kSOus','nmmHd','jrjoj','rFcwV','xEMRG','WWHUi','ShKzS','HEOVo','signOut','CYNab','ZdQfJ'];_0x35e9=function(){return _0x529983;};return _0x35e9();}const createUserAccount=async _0x51a6fd=>{const _0x8f473c={'cBawr':'❌\x20Error\x20creating\x20user\x20account:','Xliis':_0x2a6a(0x4d),'zZZVG':_0x2a6a(0x4e),'lXdPb':function(_0x553baf,_0x31d1ff,_0x288532){return _0x553baf(_0x31d1ff,_0x288532);},'dgKUR':_0x2a6a(0x4f),'SAKRK':_0x2a6a(0x50),'VulPk':_0x2a6a(0x51),'bsrMs':_0x2a6a(0x52),'neefh':'Account\x20created/authenticated\x20successfully'};try{if(_0x8f473c[_0x2a6a(0x53)]===_0x8f473c[_0x2a6a(0x53)]){console[_0x2a6a(0xd)](_0x2a6a(0x54),_0x51a6fd[_0x2a6a(0x11)]),console['log'](_0x2a6a(0x55));const _0x24faeb=await(0x0,_apiKeyService['getDeveloperAuthHeaders'])(),_0x6ec329=await _0x8f473c[_0x2a6a(0x56)](fetch,_api[_0x2a6a(0x57)][_0x2a6a(0x58)]+_0x2a6a(0x59),{'method':'POST','headers':_0x24faeb,'body':JSON[_0x2a6a(0x5a)]({'credential':_0x51a6fd['idToken'],'email':_0x51a6fd[_0x2a6a(0x11)],'name':_0x51a6fd[_0x2a6a(0x30)],'photoUrl':_0x51a6fd['photoUrl']})});console[_0x2a6a(0xd)](_0x8f473c[_0x2a6a(0x5b)],_0x6ec329[_0x2a6a(0x5c)]);const _0x510587=await _0x6ec329[_0x2a6a(0x5d)]();return console['log'](_0x8f473c['SAKRK'],_0x510587),_0x6ec329['ok']&&_0x510587[_0x2a6a(0x3d)]?_0x8f473c[_0x2a6a(0x5e)]!==_0x8f473c['bsrMs']?{'success':!![],'token':_0x510587['token'],'user':_0x510587['user'],'isNewUser':_0x510587[_0x2a6a(0x5f)]||![],'message':_0x8f473c[_0x2a6a(0x60)]}:(_0x28540a[_0x2a6a(0x40)](_0x8f473c[_0x2a6a(0x61)],_0x58f72c),{'success':![],'message':_0x58ad26[_0x2a6a(0x3e)]||_0x2a6a(0x20)}):{'success':![],'message':_0x510587['message']||_0x510587[_0x2a6a(0x40)]||_0x2a6a(0x62)};}else return _0x50e939['error'](_0x8f473c[_0x2a6a(0x63)],_0x19286f),{'isSignedIn':![]};}catch(_0x21643a){return console['error'](_0x8f473c[_0x2a6a(0x61)],_0x21643a),{'success':![],'message':_0x21643a['message']||_0x2a6a(0x20)};}},isGoogleSignedIn=async()=>{const _0x36322e={'WWHUi':_0x2a6a(0x64),'kSOus':function(_0x418efa,_0x1e4cc5){return _0x418efa===_0x1e4cc5;},'nmmHd':'jrjoj','rFcwV':function(_0x46a7f5,_0x459bb8){return _0x46a7f5!==_0x459bb8;},'xEMRG':function(_0xa5dccb,_0xc0d77d){return _0xa5dccb===_0xc0d77d;},'Pjqud':function(_0x52616d,_0x2049c8){return _0x52616d===_0x2049c8;},'ShKzS':'❌\x20Error\x20checking\x20Google\x20sign-in\x20status:'};try{if(_0x36322e[_0x2a6a(0x65)](_0x36322e[_0x2a6a(0x66)],_0x2a6a(0x67))){const _0x1ef7a1=await _googleSignin[_0x2a6a(0x12)]['getCurrentUser'](),_0x32cc79=_0x36322e[_0x2a6a(0x68)](_0x1ef7a1,null);if(_0x32cc79)return{'isSignedIn':!![],'user':_0x36322e[_0x2a6a(0x69)](_0x1ef7a1,null)||_0x36322e['Pjqud'](_0x1ef7a1,void 0x0)?void 0x0:_0x1ef7a1[_0x2a6a(0x29)]};return{'isSignedIn':![]};}else return{'success':!![],'token':_0x4b266b[_0x2a6a(0x3d)],'user':_0x2343e1['user'],'isNewUser':_0x32004a['isNewUser']||![],'message':_0x36322e[_0x2a6a(0x6a)]};}catch(_0x26257b){return console[_0x2a6a(0x40)](_0x36322e[_0x2a6a(0x6b)],_0x26257b),{'isSignedIn':![]};}};exports[_0x2a6a(0x5)]=isGoogleSignedIn;const signOutFromGoogle=async()=>{const _0x3b27a3={'CYNab':_0x2a6a(0x6c),'ZdQfJ':_0x2a6a(0x16)};try{return await _googleSignin[_0x2a6a(0x12)][_0x2a6a(0x6d)](),console[_0x2a6a(0xd)]('✅\x20Google\x20sign-out\x20successful'),!![];}catch(_0x2c9a33){if(_0x2a6a(0x6c)!==_0x3b27a3[_0x2a6a(0x6e)])_0x3ea66a=_0x2f5c2c[_0x2a6a(0x9)];else return console[_0x2a6a(0x40)](_0x3b27a3[_0x2a6a(0x6f)],_0x2c9a33),![];}};exports[_0x2a6a(0x3)]=signOutFromGoogle;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateGoogleClientIds = exports.signOutFromGoogle = exports.signInWithGoogle = exports.isGoogleSignedIn = void 0;
|
|
7
|
+
var _googleSignin = require("@react-native-google-signin/google-signin");
|
|
8
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
+
var _api = require("../config/api");
|
|
10
|
+
var _apiKeyService = require("./apiKeyService");
|
|
11
|
+
var _jwtStorageService = require("./jwtStorageService");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
/**
|
|
14
|
+
* Google Authentication Service
|
|
15
|
+
* Handles Google Sign-In for user authentication and account creation
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// CRITICAL FIX: Use static imports to avoid Hermes transpilation issues
|
|
19
|
+
|
|
20
|
+
// 🔑 Using the same client ID configuration as platform auth
|
|
21
|
+
let WEB_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
22
|
+
let IOS_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Update Google OAuth client IDs for custom configurations
|
|
26
|
+
*/
|
|
27
|
+
const updateGoogleClientIds = config => {
|
|
28
|
+
if (config.webClientId) {
|
|
29
|
+
WEB_CLIENT_ID = config.webClientId;
|
|
30
|
+
}
|
|
31
|
+
if (config.iosClientId) {
|
|
32
|
+
IOS_CLIENT_ID = config.iosClientId;
|
|
33
|
+
}
|
|
34
|
+
console.log('✅ Google client IDs updated:', {
|
|
35
|
+
webClientId: WEB_CLIENT_ID,
|
|
36
|
+
iosClientId: IOS_CLIENT_ID
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Initialize Google Sign-In for user authentication
|
|
42
|
+
*/
|
|
43
|
+
exports.updateGoogleClientIds = updateGoogleClientIds;
|
|
44
|
+
const initializeGoogleAuth = () => {
|
|
45
|
+
_googleSignin.GoogleSignin.configure({
|
|
46
|
+
webClientId: WEB_CLIENT_ID,
|
|
47
|
+
iosClientId: IOS_CLIENT_ID,
|
|
48
|
+
// Basic scopes for user authentication
|
|
49
|
+
scopes: ['openid', 'profile', 'email'],
|
|
50
|
+
// Enable offline access for refresh tokens
|
|
51
|
+
offlineAccess: true,
|
|
52
|
+
forceCodeForRefreshToken: true,
|
|
53
|
+
// Clear settings to avoid conflicts
|
|
54
|
+
hostedDomain: '',
|
|
55
|
+
accountName: ''
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Sign in with Google and create/authenticate user account
|
|
61
|
+
*/
|
|
62
|
+
const signInWithGoogle = async () => {
|
|
63
|
+
try {
|
|
64
|
+
var _userInfo$data, _userInfo$data2;
|
|
65
|
+
console.log('🔗 Initiating Google Sign-In for user authentication');
|
|
66
|
+
|
|
67
|
+
// Initialize Google Sign-In
|
|
68
|
+
initializeGoogleAuth();
|
|
69
|
+
|
|
70
|
+
// Check if Google Play Services are available
|
|
71
|
+
await _googleSignin.GoogleSignin.hasPlayServices();
|
|
72
|
+
|
|
73
|
+
// Sign out first to ensure fresh consent
|
|
74
|
+
try {
|
|
75
|
+
await _googleSignin.GoogleSignin.signOut();
|
|
76
|
+
console.log('🔄 Signed out to ensure fresh consent');
|
|
77
|
+
} catch (signOutError) {
|
|
78
|
+
console.log('ℹ️ Sign out not needed or failed:', signOutError);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Sign in with Google
|
|
82
|
+
const userInfo = await _googleSignin.GoogleSignin.signIn();
|
|
83
|
+
console.log('✅ Google Sign-In successful:', (_userInfo$data = userInfo.data) === null || _userInfo$data === void 0 || (_userInfo$data = _userInfo$data.user) === null || _userInfo$data === void 0 ? void 0 : _userInfo$data.email);
|
|
84
|
+
const googleUser = (_userInfo$data2 = userInfo.data) === null || _userInfo$data2 === void 0 ? void 0 : _userInfo$data2.user;
|
|
85
|
+
if (!googleUser || !googleUser.email) {
|
|
86
|
+
throw new Error('No user data received from Google');
|
|
87
|
+
}
|
|
88
|
+
console.log('👤 Google user data:', {
|
|
89
|
+
email: googleUser.email,
|
|
90
|
+
name: googleUser.name,
|
|
91
|
+
photo: googleUser.photo,
|
|
92
|
+
id: googleUser.id
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Get tokens for account creation
|
|
96
|
+
const tokens = await _googleSignin.GoogleSignin.getTokens();
|
|
97
|
+
console.log('🔑 Got Google tokens');
|
|
98
|
+
|
|
99
|
+
// Create user account on backend
|
|
100
|
+
const accountResult = await createUserAccount({
|
|
101
|
+
email: googleUser.email,
|
|
102
|
+
name: googleUser.name || googleUser.email.split('@')[0],
|
|
103
|
+
photoUrl: googleUser.photo || '',
|
|
104
|
+
googleId: googleUser.id,
|
|
105
|
+
accessToken: tokens.accessToken,
|
|
106
|
+
idToken: tokens.idToken
|
|
107
|
+
});
|
|
108
|
+
if (accountResult.success) {
|
|
109
|
+
var _accountResult$user, _accountResult$user2;
|
|
110
|
+
console.log('✅ User account created/authenticated successfully');
|
|
111
|
+
|
|
112
|
+
// Store authentication data
|
|
113
|
+
await _asyncStorage.default.setItem('user_email', googleUser.email);
|
|
114
|
+
// ✅ FIX: Always use email prefix for username (matches backend userName field)
|
|
115
|
+
// This ensures LinkedIn scraper can find the user by userName
|
|
116
|
+
await _asyncStorage.default.setItem('onairos_username', googleUser.email.split('@')[0]);
|
|
117
|
+
await _asyncStorage.default.setItem('auth_method', 'google');
|
|
118
|
+
|
|
119
|
+
// Use simplified JWT storage
|
|
120
|
+
if (accountResult.token) {
|
|
121
|
+
await (0, _jwtStorageService.storeJWT)(accountResult.token);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
success: true,
|
|
125
|
+
user: {
|
|
126
|
+
id: ((_accountResult$user = accountResult.user) === null || _accountResult$user === void 0 ? void 0 : _accountResult$user.id) || '',
|
|
127
|
+
email: googleUser.email,
|
|
128
|
+
username: googleUser.name || googleUser.email.split('@')[0],
|
|
129
|
+
odeanId: (_accountResult$user2 = accountResult.user) === null || _accountResult$user2 === void 0 ? void 0 : _accountResult$user2.odeanId
|
|
130
|
+
},
|
|
131
|
+
token: accountResult.token,
|
|
132
|
+
isNewUser: accountResult.isNewUser || false
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
throw new Error(accountResult.message || 'Failed to create user account');
|
|
136
|
+
}
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error('❌ Google Sign-In error:', error);
|
|
139
|
+
|
|
140
|
+
// Handle specific Google Sign-In errors
|
|
141
|
+
if (error.code === _googleSignin.statusCodes.SIGN_IN_CANCELLED) {
|
|
142
|
+
return {
|
|
143
|
+
success: false,
|
|
144
|
+
message: 'Google Sign-In was cancelled',
|
|
145
|
+
cancelled: true
|
|
146
|
+
};
|
|
147
|
+
} else if (error.code === _googleSignin.statusCodes.IN_PROGRESS) {
|
|
148
|
+
return {
|
|
149
|
+
success: false,
|
|
150
|
+
message: 'Google Sign-In is already in progress'
|
|
151
|
+
};
|
|
152
|
+
} else if (error.code === _googleSignin.statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
153
|
+
return {
|
|
154
|
+
success: false,
|
|
155
|
+
message: 'Google Play Services not available'
|
|
156
|
+
};
|
|
157
|
+
} else {
|
|
158
|
+
return {
|
|
159
|
+
success: false,
|
|
160
|
+
message: error.message || 'Google Sign-In failed'
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Create or authenticate user account on backend using generic SDK endpoint
|
|
168
|
+
* NOTE: This is generic SDK auth - does NOT create EnochUser
|
|
169
|
+
* Consuming apps should call /enoch/users/register after this if needed
|
|
170
|
+
*/
|
|
171
|
+
exports.signInWithGoogle = signInWithGoogle;
|
|
172
|
+
const createUserAccount = async userData => {
|
|
173
|
+
try {
|
|
174
|
+
console.log('🔐 Creating/authenticating user account for:', userData.email);
|
|
175
|
+
console.log('🔐 Calling generic /register/google endpoint...');
|
|
176
|
+
const headers = await (0, _apiKeyService.getDeveloperAuthHeaders)();
|
|
177
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/register/google`, {
|
|
178
|
+
method: 'POST',
|
|
179
|
+
headers,
|
|
180
|
+
body: JSON.stringify({
|
|
181
|
+
credential: userData.idToken,
|
|
182
|
+
email: userData.email,
|
|
183
|
+
name: userData.name,
|
|
184
|
+
photoUrl: userData.photoUrl
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
console.log('📡 Google register response status:', response.status);
|
|
188
|
+
const responseData = await response.json();
|
|
189
|
+
console.log('🔗 Account creation response:', responseData);
|
|
190
|
+
if (response.ok && responseData.token) {
|
|
191
|
+
return {
|
|
192
|
+
success: true,
|
|
193
|
+
token: responseData.token,
|
|
194
|
+
user: responseData.user,
|
|
195
|
+
isNewUser: responseData.isNewUser || false,
|
|
196
|
+
message: 'Account created/authenticated successfully'
|
|
197
|
+
};
|
|
198
|
+
} else {
|
|
199
|
+
return {
|
|
200
|
+
success: false,
|
|
201
|
+
message: responseData.message || responseData.error || 'Failed to create account'
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error('❌ Error creating user account:', error);
|
|
206
|
+
return {
|
|
207
|
+
success: false,
|
|
208
|
+
message: error.message || 'Failed to create user account'
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Check if user is already signed in with Google
|
|
215
|
+
*/
|
|
216
|
+
const isGoogleSignedIn = async () => {
|
|
217
|
+
try {
|
|
218
|
+
const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
|
|
219
|
+
const isSignedIn = currentUser !== null;
|
|
220
|
+
if (isSignedIn) {
|
|
221
|
+
return {
|
|
222
|
+
isSignedIn: true,
|
|
223
|
+
user: currentUser === null || currentUser === void 0 ? void 0 : currentUser.user
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
isSignedIn: false
|
|
228
|
+
};
|
|
229
|
+
} catch (error) {
|
|
230
|
+
console.error('❌ Error checking Google sign-in status:', error);
|
|
231
|
+
return {
|
|
232
|
+
isSignedIn: false
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Sign out from Google
|
|
239
|
+
*/
|
|
240
|
+
exports.isGoogleSignedIn = isGoogleSignedIn;
|
|
241
|
+
const signOutFromGoogle = async () => {
|
|
242
|
+
try {
|
|
243
|
+
await _googleSignin.GoogleSignin.signOut();
|
|
244
|
+
console.log('✅ Google sign-out successful');
|
|
245
|
+
return true;
|
|
246
|
+
} catch (error) {
|
|
247
|
+
console.error('❌ Google sign-out error:', error);
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
exports.signOutFromGoogle = signOutFromGoogle;
|
|
252
|
+
//# sourceMappingURL=googleAuthService.js.map
|
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useHingeDataExtractor = void 0;
|
|
7
|
+
var _hingeDataService = require("./hingeDataService");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* Hinge Data Extractor
|
|
11
|
+
*
|
|
12
|
+
* Orchestrates the Hinge data export flow:
|
|
13
|
+
* 1. Receives extracted matches/chats from WebView
|
|
14
|
+
* 2. Validates and formats data
|
|
15
|
+
* 3. Sends to backend via hingeDataService
|
|
16
|
+
*
|
|
17
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
18
|
+
*
|
|
19
|
+
* @reference ChatGPT implementation: src/services/chatGPTConversationExtractor.ts
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Combined Hinge export data from WebView
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook for Hinge data extraction operations
|
|
28
|
+
*/
|
|
29
|
+
const useHingeDataExtractor = () => {
|
|
30
|
+
/**
|
|
31
|
+
* Initiate data export to backend
|
|
32
|
+
*
|
|
33
|
+
* @param username - User identifier
|
|
34
|
+
* @param data - Extracted Hinge data (matches and chats)
|
|
35
|
+
* @returns true if successful, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
const initiateDataExport = async (username, data) => {
|
|
38
|
+
var _data$chats;
|
|
39
|
+
console.log('🚀 [HINGE_EXTRACTOR] Initiating data export');
|
|
40
|
+
console.log('👤 [HINGE_EXTRACTOR] Username:', username);
|
|
41
|
+
console.log('📊 [HINGE_EXTRACTOR] Matches:', data.total_matches);
|
|
42
|
+
console.log('📊 [HINGE_EXTRACTOR] Chats:', data.total_chats);
|
|
43
|
+
console.log('📊 [HINGE_EXTRACTOR] Messages:', data.total_messages);
|
|
44
|
+
|
|
45
|
+
// Validation
|
|
46
|
+
if (!username) {
|
|
47
|
+
console.error('❌ [HINGE_EXTRACTOR] Username is required');
|
|
48
|
+
_reactNative.Alert.alert('Error', 'Username is required to export Hinge data.', [{
|
|
49
|
+
text: 'OK',
|
|
50
|
+
style: 'default'
|
|
51
|
+
}]);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Handle empty data as success - user might be new
|
|
56
|
+
if ((!data.matches || data.matches.length === 0) && (!data.chats || data.chats.length === 0)) {
|
|
57
|
+
console.log('ℹ️ [HINGE_EXTRACTOR] No data to export - treating as success (connected)');
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Validate chat structure
|
|
62
|
+
const validChats = (data.chats || []).filter(chat => {
|
|
63
|
+
const isValid = chat.match_id && Array.isArray(chat.user_messages) && chat.user_messages.length > 0;
|
|
64
|
+
if (!isValid) {
|
|
65
|
+
console.warn('⚠️ [HINGE_EXTRACTOR] Invalid chat:', chat);
|
|
66
|
+
}
|
|
67
|
+
return isValid;
|
|
68
|
+
});
|
|
69
|
+
if (validChats.length < (((_data$chats = data.chats) === null || _data$chats === void 0 ? void 0 : _data$chats.length) || 0)) {
|
|
70
|
+
var _data$chats2;
|
|
71
|
+
console.warn(`⚠️ [HINGE_EXTRACTOR] Filtered out ${(((_data$chats2 = data.chats) === null || _data$chats2 === void 0 ? void 0 : _data$chats2.length) || 0) - validChats.length} invalid chats`);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
console.log('📡 [HINGE_EXTRACTOR] Sending to backend...');
|
|
75
|
+
const result = await (0, _hingeDataService.storeHingeData)(username, {
|
|
76
|
+
matches: data.matches || [],
|
|
77
|
+
chats: validChats
|
|
78
|
+
});
|
|
79
|
+
if (result.success) {
|
|
80
|
+
console.log('✅ [HINGE_EXTRACTOR] Export completed successfully');
|
|
81
|
+
console.log('📊 [HINGE_EXTRACTOR] Backend response:', result.data);
|
|
82
|
+
return true;
|
|
83
|
+
} else {
|
|
84
|
+
console.error('❌ [HINGE_EXTRACTOR] Backend storage failed:', result.error);
|
|
85
|
+
_reactNative.Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
|
|
86
|
+
text: 'OK',
|
|
87
|
+
style: 'default'
|
|
88
|
+
}]);
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error('❌ [HINGE_EXTRACTOR] Unexpected error during export:', error);
|
|
93
|
+
_reactNative.Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
|
|
94
|
+
text: 'OK',
|
|
95
|
+
style: 'default'
|
|
96
|
+
}]);
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
initiateDataExport
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
exports.useHingeDataExtractor = useHingeDataExtractor;
|
|
105
|
+
//# sourceMappingURL=hingeDataExtractor.js.map
|
|
@@ -1,9 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.storeHingeData = void 0;
|
|
7
|
+
var _api = require("../config/api");
|
|
8
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* Hinge Data Service
|
|
13
|
+
*
|
|
14
|
+
* API layer for storing Hinge data on backend.
|
|
15
|
+
* Sends extracted matches and chats to /platform-data/store endpoint.
|
|
16
|
+
*
|
|
17
|
+
* MATCHES ChatGPT implementation pattern
|
|
18
|
+
* - Sends data in batches
|
|
19
|
+
* - Uses format: { platform, data, metadata }
|
|
20
|
+
* - Platform: "mobile-hinge"
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Structure of a single message in a chat
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Structure of chat data extracted from Hinge
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Structure of match data extracted from Hinge
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Combined Hinge data to store
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Response from backend endpoint
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Store Hinge data on backend
|
|
45
|
+
*
|
|
46
|
+
* @param userId - Username or identifier
|
|
47
|
+
* @param data - Hinge matches and chat data
|
|
48
|
+
* @returns Response indicating success/failure with metadata
|
|
49
|
+
*/
|
|
50
|
+
const storeHingeData = async (userId, data) => {
|
|
51
|
+
console.log('🚀 [HINGE_SERVICE] Storing Hinge data for:', userId);
|
|
52
|
+
console.log('📊 [HINGE_SERVICE] Matches:', data.matches.length);
|
|
53
|
+
console.log('📊 [HINGE_SERVICE] Chats:', data.chats.length);
|
|
54
|
+
console.log('📊 [HINGE_SERVICE] Total user messages:', data.chats.reduce((sum, c) => sum + c.user_messages.length, 0));
|
|
55
|
+
|
|
56
|
+
// Input validation
|
|
57
|
+
if (!userId) {
|
|
58
|
+
console.error('❌ [HINGE_SERVICE] Invalid input: userId missing');
|
|
59
|
+
return {
|
|
60
|
+
success: false,
|
|
61
|
+
error: 'Invalid input: userId missing.'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
// Get auth token - check all possible storage keys
|
|
66
|
+
const authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
67
|
+
if (!authToken) {
|
|
68
|
+
console.error('❌ [HINGE_SERVICE] No auth token found');
|
|
69
|
+
return {
|
|
70
|
+
success: false,
|
|
71
|
+
error: 'Authentication token not found. Please log in again.'
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
console.log('🔑 [HINGE_SERVICE] Auth token found');
|
|
75
|
+
|
|
76
|
+
// Mobile metadata
|
|
77
|
+
const mobileMetadata = {
|
|
78
|
+
platform: _reactNative.Platform.OS,
|
|
79
|
+
appVersion: '1.0.0',
|
|
80
|
+
osVersion: _reactNative.Platform.OS === 'ios' ? '17.0' : _reactNative.Platform.OS,
|
|
81
|
+
deviceModel: _reactNative.Platform.OS === 'ios' ? 'iPhone' : 'Android',
|
|
82
|
+
isOfflineSync: false,
|
|
83
|
+
extractedAt: new Date().toISOString()
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Build request body
|
|
87
|
+
const requestBody = {
|
|
88
|
+
platform: 'mobile-hinge',
|
|
89
|
+
dataType: 'dating',
|
|
90
|
+
data: {
|
|
91
|
+
matches: data.matches,
|
|
92
|
+
chats: data.chats.map(chat => ({
|
|
93
|
+
matchId: chat.match_id,
|
|
94
|
+
matchName: chat.match_name,
|
|
95
|
+
messages: chat.user_messages.map((msg, idx) => ({
|
|
96
|
+
id: `${chat.match_id}-msg-${idx}`,
|
|
97
|
+
content: msg.content,
|
|
98
|
+
timestamp: msg.timestamp || new Date().toISOString(),
|
|
99
|
+
role: 'user'
|
|
100
|
+
})),
|
|
101
|
+
totalMessages: chat.total_messages
|
|
102
|
+
}))
|
|
103
|
+
},
|
|
104
|
+
summary: {
|
|
105
|
+
matchCount: data.matches.length,
|
|
106
|
+
chatCount: data.chats.length,
|
|
107
|
+
totalUserMessages: data.chats.reduce((sum, c) => sum + c.user_messages.length, 0)
|
|
108
|
+
},
|
|
109
|
+
mobileMetadata: mobileMetadata
|
|
110
|
+
};
|
|
111
|
+
console.log('📡 [HINGE_SERVICE] Sending to backend...');
|
|
112
|
+
console.log('📍 [HINGE_SERVICE] URL:', `${_api.API_CONFIG.BASE_URL}/platform-data/store`);
|
|
113
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/platform-data/store`, {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers: {
|
|
116
|
+
'Content-Type': 'application/json',
|
|
117
|
+
'Authorization': `Bearer ${authToken}`,
|
|
118
|
+
'User-Agent': `OnairosSDK/1.0.0 (${_reactNative.Platform.OS})`
|
|
119
|
+
},
|
|
120
|
+
body: JSON.stringify(requestBody)
|
|
121
|
+
});
|
|
122
|
+
const responseData = await response.json();
|
|
123
|
+
if (response.ok) {
|
|
124
|
+
console.log('✅ [HINGE_SERVICE] Successfully stored Hinge data');
|
|
125
|
+
if (responseData.message) {
|
|
126
|
+
console.log(`📝 [HINGE_SERVICE] Backend response: ${responseData.message}`);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
success: true,
|
|
130
|
+
message: responseData.message || 'Hinge data stored successfully',
|
|
131
|
+
data: responseData.data
|
|
132
|
+
};
|
|
133
|
+
} else {
|
|
134
|
+
console.warn(`⚠️ [HINGE_SERVICE] Backend returned status: ${response.status}`);
|
|
135
|
+
console.warn(`⚠️ [HINGE_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
error: responseData.error || `HTTP ${response.status}`
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error('❌ [HINGE_SERVICE] Network error:', error);
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
exports.storeHingeData = storeHingeData;
|
|
150
|
+
//# sourceMappingURL=hingeDataService.js.map
|