@onairos/react-native 3.7.1 → 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/assets/icons/spotify.png +0 -0
- package/lib/commonjs/assets/images/spotify.png +0 -0
- 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/assets/icons/spotify.png +0 -0
- package/lib/module/assets/images/spotify.png +0 -0
- 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[_0x38c3(0x0)](exports,_0x38c3(0x1),{'value':!![]}),exports[_0x38c3(0x2)]=exports[_0x38c3(0x3)]=exports[_0x38c3(0x4)]=exports[_0x38c3(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(_0x1158f0){return _0x1158f0&&_0x1158f0[_0x38c3(0x1)]?_0x1158f0:{'default':_0x1158f0};}let WEB_CLIENT_ID='1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com',IOS_CLIENT_ID=_0x38c3(0x6);const updateGoogleClientIds=_0x406fc3=>{const _0x445376={'yBAgS':'openid','CgkVP':'email','uMmoN':function(_0x69c89a,_0x18771e){return _0x69c89a===_0x18771e;},'zDLcK':'nHgiU','RlHpq':_0x38c3(0x7),'eCuYP':_0x38c3(0x8)};_0x406fc3[_0x38c3(0x9)]&&(_0x445376[_0x38c3(0xa)](_0x445376[_0x38c3(0xb)],_0x445376[_0x38c3(0xc)])?_0x17886e['GoogleSignin'][_0x38c3(0xd)]({'webClientId':_0x3cbf8d,'iosClientId':_0x1791af,'scopes':[_0x445376['yBAgS'],_0x38c3(0xe),_0x445376[_0x38c3(0xf)]],'offlineAccess':!![],'forceCodeForRefreshToken':!![],'hostedDomain':'','accountName':''}):WEB_CLIENT_ID=_0x406fc3[_0x38c3(0x9)]),_0x406fc3[_0x38c3(0x10)]&&(IOS_CLIENT_ID=_0x406fc3[_0x38c3(0x10)]),console['log'](_0x445376[_0x38c3(0x11)],{'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID});};exports[_0x38c3(0x2)]=updateGoogleClientIds;const initializeGoogleAuth=()=>{const _0x32acf4={'WRRLy':_0x38c3(0x12),'yvqMD':_0x38c3(0xe),'YDjFb':_0x38c3(0x13)};_googleSignin['GoogleSignin'][_0x38c3(0xd)]({'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID,'scopes':[_0x32acf4[_0x38c3(0x14)],_0x32acf4[_0x38c3(0x15)],_0x32acf4[_0x38c3(0x16)]],'offlineAccess':!![],'forceCodeForRefreshToken':!![],'hostedDomain':'','accountName':''});},signInWithGoogle=async()=>{const _0x174747={'nllUO':_0x38c3(0x17),'ahOOr':_0x38c3(0x18),'omkWH':function(_0x2bd72b,_0x2d3297){return _0x2bd72b===_0x2d3297;},'SrlSr':'XtTBF','PWFEm':'🔗\x20Initiating\x20Google\x20Sign-In\x20for\x20user\x20authentication','LaFlC':function(_0x363a2a){return _0x363a2a();},'awdZQ':function(_0x95db13,_0x5cbcec){return _0x95db13!==_0x5cbcec;},'uOSwB':'AZdil','OdOwX':_0x38c3(0x19),'DEgtz':_0x38c3(0x1a),'MgpkQ':_0x38c3(0x1b),'iMJkj':function(_0xc80b9b,_0x24fcd2){return _0xc80b9b===_0x24fcd2;},'xxDKW':function(_0x518277,_0x2c2a94){return _0x518277===_0x2c2a94;},'GPsNw':function(_0x3c420d,_0x5b1528){return _0x3c420d===_0x5b1528;},'SwUfw':'👤\x20Google\x20user\x20data:','xwXXo':_0x38c3(0x1c),'QXfHs':function(_0x1c4ba3,_0x4ea822){return _0x1c4ba3(_0x4ea822);},'WCcDl':function(_0x13568a,_0xc0ba61){return _0x13568a===_0xc0ba61;},'CQtUA':'CFlbq','lwwxH':_0x38c3(0x1d),'zlfDP':function(_0x252857,_0x35bc37){return _0x252857===_0x35bc37;},'hedZf':function(_0x3c2f74,_0x5287c0){return _0x3c2f74===_0x5287c0;},'lxRxo':_0x38c3(0x1e),'dXqYK':_0x38c3(0x1f),'zXWvr':_0x38c3(0x20),'oTEgw':_0x38c3(0x21),'HHwkC':_0x38c3(0x22),'byDVg':function(_0x175e68,_0x345ff8){return _0x175e68!==_0x345ff8;},'ZazQy':_0x38c3(0x23),'MBRYD':_0x38c3(0x24),'ZiDly':_0x38c3(0x25),'lMEoa':_0x38c3(0x26)};try{if(_0x174747[_0x38c3(0x27)](_0x174747[_0x38c3(0x28)],_0x174747[_0x38c3(0x28)])){var _0xd2ff65,_0x40789a;console[_0x38c3(0x29)](_0x174747[_0x38c3(0x2a)]),_0x174747[_0x38c3(0x2b)](initializeGoogleAuth),await _googleSignin[_0x38c3(0x2c)][_0x38c3(0x2d)]();try{if(_0x174747[_0x38c3(0x2e)](_0x174747[_0x38c3(0x2f)],_0x174747[_0x38c3(0x2f)]))return _0x52b842&&_0x5c4ff9[_0x38c3(0x1)]?_0x516790:{'default':_0x32f5a9};else await _googleSignin[_0x38c3(0x2c)]['signOut'](),console[_0x38c3(0x29)](_0x174747[_0x38c3(0x30)]);}catch(_0x21fcc6){console['log'](_0x174747['DEgtz'],_0x21fcc6);}const _0x14b32d=await _googleSignin[_0x38c3(0x2c)]['signIn']();console[_0x38c3(0x29)](_0x174747[_0x38c3(0x31)],_0x174747[_0x38c3(0x32)](_0xd2ff65=_0x14b32d[_0x38c3(0x33)],null)||_0x174747[_0x38c3(0x34)](_0xd2ff65,void 0x0)||_0x174747[_0x38c3(0x32)](_0xd2ff65=_0xd2ff65[_0x38c3(0x35)],null)||_0xd2ff65===void 0x0?void 0x0:_0xd2ff65[_0x38c3(0x13)]);const _0x28f48b=_0x174747['GPsNw'](_0x40789a=_0x14b32d[_0x38c3(0x33)],null)||_0x40789a===void 0x0?void 0x0:_0x40789a[_0x38c3(0x35)];if(!_0x28f48b||!_0x28f48b[_0x38c3(0x13)])throw new Error(_0x174747[_0x38c3(0x36)]);console[_0x38c3(0x29)](_0x174747['SwUfw'],{'email':_0x28f48b[_0x38c3(0x13)],'name':_0x28f48b[_0x38c3(0x37)],'photo':_0x28f48b[_0x38c3(0x38)],'id':_0x28f48b['id']});const _0x59079b=await _googleSignin[_0x38c3(0x2c)][_0x38c3(0x39)]();console[_0x38c3(0x29)](_0x174747[_0x38c3(0x3a)]);const _0x3681ef=await _0x174747['QXfHs'](createUserAccount,{'email':_0x28f48b['email'],'name':_0x28f48b[_0x38c3(0x37)]||_0x28f48b['email'][_0x38c3(0x3b)]('@')[0x0],'photoUrl':_0x28f48b[_0x38c3(0x38)]||'','googleId':_0x28f48b['id'],'accessToken':_0x59079b[_0x38c3(0x3c)],'idToken':_0x59079b['idToken']});if(_0x3681ef[_0x38c3(0x3d)]){if(_0x174747[_0x38c3(0x3e)](_0x174747[_0x38c3(0x3f)],_0x38c3(0x40))){const _0x16426f=_0x174747[_0x38c3(0x41)][_0x38c3(0x3b)]('|');let _0x5eb686=0x0;while(!![]){switch(_0x16426f[_0x5eb686++]){case'0':_0x3681ef[_0x38c3(0x42)]&&await(0x0,_jwtStorageService[_0x38c3(0x43)])(_0x3681ef[_0x38c3(0x42)]);continue;case'1':return{'success':!![],'user':{'id':(_0x174747[_0x38c3(0x44)](_0x281050=_0x3681ef[_0x38c3(0x35)],null)||_0x174747[_0x38c3(0x32)](_0x281050,void 0x0)?void 0x0:_0x281050['id'])||'','email':_0x28f48b['email'],'username':_0x28f48b[_0x38c3(0x37)]||_0x28f48b['email'][_0x38c3(0x3b)]('@')[0x0],'odeanId':_0x174747['hedZf'](_0x149dba=_0x3681ef['user'],null)||_0x174747['omkWH'](_0x149dba,void 0x0)?void 0x0:_0x149dba[_0x38c3(0x45)]},'token':_0x3681ef[_0x38c3(0x42)],'isNewUser':_0x3681ef['isNewUser']||![]};case'2':await _asyncStorage[_0x38c3(0x46)]['setItem'](_0x174747[_0x38c3(0x47)],_0x28f48b[_0x38c3(0x13)]);continue;case'3':await _asyncStorage[_0x38c3(0x46)]['setItem'](_0x38c3(0x48),_0x28f48b[_0x38c3(0x13)]['split']('@')[0x0]);continue;case'4':await _asyncStorage['default'][_0x38c3(0x49)](_0x174747[_0x38c3(0x4a)],_0x174747['zXWvr']);continue;case'5':console['log'](_0x174747[_0x38c3(0x4b)]);continue;case'6':var _0x281050,_0x149dba;continue;}break;}}else throw new _0x4f646a(_0x174747['nllUO']);}else throw new Error(_0x3681ef['message']||'Failed\x20to\x20create\x20user\x20account');}else return{'success':![],'message':'Google\x20Sign-In\x20was\x20cancelled','cancelled':!![]};}catch(_0x127566){console[_0x38c3(0x4c)](_0x174747['HHwkC'],_0x127566);if(_0x174747[_0x38c3(0x3e)](_0x127566[_0x38c3(0x4d)],_googleSignin[_0x38c3(0x4e)][_0x38c3(0x4f)]))return _0x174747[_0x38c3(0x50)](_0x174747[_0x38c3(0x51)],_0x38c3(0x23))?(_0x136472['error'](_0x174747[_0x38c3(0x52)],_0x9fae95),![]):{'success':![],'message':_0x38c3(0x53),'cancelled':!![]};else{if(_0x174747[_0x38c3(0x32)](_0x127566[_0x38c3(0x4d)],_googleSignin[_0x38c3(0x4e)][_0x38c3(0x54)]))return{'success':![],'message':_0x174747[_0x38c3(0x55)]};else return _0x127566['code']===_googleSignin[_0x38c3(0x4e)][_0x38c3(0x56)]?{'success':![],'message':_0x174747[_0x38c3(0x57)]}:{'success':![],'message':_0x127566['message']||_0x174747['lMEoa']};}}};function _0x38c3(_0x161dff,_0x38c315){_0x161dff=_0x161dff-0x0;const _0x142b9d=_0x161d();let _0x3c17db=_0x142b9d[_0x161dff];return _0x3c17db;}exports[_0x38c3(0x4)]=signInWithGoogle;const createUserAccount=async _0x59bace=>{const _0xdddd1b={'PeFid':_0x38c3(0x58),'UuUuj':_0x38c3(0x24),'yvFXI':function(_0x1bea22,_0x1fcff0){return _0x1bea22!==_0x1fcff0;},'fGoqE':_0x38c3(0x59),'bArHB':_0x38c3(0x5a),'BnWWo':_0x38c3(0x5b),'vCwFt':function(_0x5115fe,_0x556a31,_0x5987c1){return _0x5115fe(_0x556a31,_0x5987c1);},'JDUrL':_0x38c3(0x5c),'hbnWi':_0x38c3(0x5d),'UhWsT':_0x38c3(0x5e),'qbkkY':_0x38c3(0x5f),'ESMtZ':function(_0x2b1e50,_0x517133){return _0x2b1e50===_0x517133;},'PDoiG':_0x38c3(0x60)};try{if(_0xdddd1b['yvFXI'](_0xdddd1b['fGoqE'],_0xdddd1b[_0x38c3(0x61)]))return _0x15d68f['error'](_0xdddd1b[_0x38c3(0x62)],_0x1daac9),{'isSignedIn':![]};else{console[_0x38c3(0x29)](_0xdddd1b[_0x38c3(0x63)],_0x59bace['email']),console[_0x38c3(0x29)](_0xdddd1b['BnWWo']);const _0x4d9906=await(0x0,_apiKeyService[_0x38c3(0x64)])(),_0x3b3fe6=await _0xdddd1b[_0x38c3(0x65)](fetch,_api[_0x38c3(0x66)][_0x38c3(0x67)]+_0x38c3(0x68),{'method':'POST','headers':_0x4d9906,'body':JSON['stringify']({'credential':_0x59bace[_0x38c3(0x69)],'email':_0x59bace[_0x38c3(0x13)],'name':_0x59bace['name'],'photoUrl':_0x59bace[_0x38c3(0x6a)]})});console[_0x38c3(0x29)](_0xdddd1b[_0x38c3(0x6b)],_0x3b3fe6['status']);const _0x4816a7=await _0x3b3fe6[_0x38c3(0x6c)]();return console[_0x38c3(0x29)](_0xdddd1b[_0x38c3(0x6d)],_0x4816a7),_0x3b3fe6['ok']&&_0x4816a7[_0x38c3(0x42)]?{'success':!![],'token':_0x4816a7['token'],'user':_0x4816a7[_0x38c3(0x35)],'isNewUser':_0x4816a7[_0x38c3(0x6e)]||![],'message':_0xdddd1b['UhWsT']}:{'success':![],'message':_0x4816a7[_0x38c3(0x6f)]||_0x4816a7[_0x38c3(0x4c)]||_0xdddd1b['qbkkY']};}}catch(_0x1d3327){return _0xdddd1b[_0x38c3(0x70)](_0xdddd1b[_0x38c3(0x71)],_0xdddd1b['PDoiG'])?(console[_0x38c3(0x4c)](_0x38c3(0x72),_0x1d3327),{'success':![],'message':_0x1d3327['message']||_0x38c3(0x73)}):{'success':![],'message':_0xdddd1b[_0x38c3(0x74)]};}},isGoogleSignedIn=async()=>{const _0x100714={'bQIGv':_0x38c3(0x26),'tKoBe':function(_0xa275a,_0x2b5dbb){return _0xa275a!==_0x2b5dbb;},'zDfgM':_0x38c3(0x75),'GEphd':function(_0x2e0101,_0x35bc38){return _0x2e0101===_0x35bc38;},'HKJRW':_0x38c3(0x76),'pprsu':function(_0x512e5e,_0x2dfd3a){return _0x512e5e===_0x2dfd3a;},'IvKpj':_0x38c3(0x58)};try{if(_0x100714['tKoBe']('RWKfo',_0x100714[_0x38c3(0x77)])){const _0x4a8184=await _googleSignin[_0x38c3(0x2c)][_0x38c3(0x78)](),_0x3e27c2=_0x4a8184!==null;if(_0x3e27c2)return _0x100714[_0x38c3(0x79)](_0x100714[_0x38c3(0x7a)],_0x100714[_0x38c3(0x7a)])?{'isSignedIn':!![],'user':_0x100714['pprsu'](_0x4a8184,null)||_0x100714[_0x38c3(0x7b)](_0x4a8184,void 0x0)?void 0x0:_0x4a8184[_0x38c3(0x35)]}:{'success':![],'message':_0x2b59ec[_0x38c3(0x6f)]||_0x100714['bQIGv']};return{'isSignedIn':![]};}else return{'success':![],'message':_0xaf05ff[_0x38c3(0x6f)]||_0x2ad55a[_0x38c3(0x4c)]||'Failed\x20to\x20create\x20account'};}catch(_0x4ae4da){return console[_0x38c3(0x4c)](_0x100714[_0x38c3(0x7c)],_0x4ae4da),{'isSignedIn':![]};}};function _0x161d(){const _0x12a22b=['defineProperty','__esModule','updateGoogleClientIds','signOutFromGoogle','signInWithGoogle','isGoogleSignedIn','1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com','CMivK','✅\x20Google\x20client\x20IDs\x20updated:','webClientId','uMmoN','zDLcK','RlHpq','configure','profile','CgkVP','iosClientId','eCuYP','openid','email','WRRLy','yvqMD','YDjFb','No\x20user\x20data\x20received\x20from\x20Google','❌\x20Google\x20sign-out\x20error:','🔄\x20Signed\x20out\x20to\x20ensure\x20fresh\x20consent','ℹ️\x20Sign\x20out\x20not\x20needed\x20or\x20failed:','✅\x20Google\x20Sign-In\x20successful:','🔑\x20Got\x20Google\x20tokens','6|5|2|3|4|0|1','user_email','auth_method','google','✅\x20User\x20account\x20created/authenticated\x20successfully','❌\x20Google\x20Sign-In\x20error:','tWbEr','Google\x20Sign-In\x20is\x20already\x20in\x20progress','Google\x20Play\x20Services\x20not\x20available','Google\x20Sign-In\x20failed','omkWH','SrlSr','log','PWFEm','LaFlC','GoogleSignin','hasPlayServices','awdZQ','uOSwB','OdOwX','MgpkQ','iMJkj','data','xxDKW','user','nllUO','name','photo','getTokens','xwXXo','split','accessToken','success','WCcDl','CQtUA','CFlbq','lwwxH','token','storeJWT','zlfDP','odeanId','default','lxRxo','onairos_username','setItem','dXqYK','oTEgw','error','code','statusCodes','SIGN_IN_CANCELLED','byDVg','ZazQy','ahOOr','Google\x20Sign-In\x20was\x20cancelled','IN_PROGRESS','MBRYD','PLAY_SERVICES_NOT_AVAILABLE','ZiDly','❌\x20Error\x20checking\x20Google\x20sign-in\x20status:','Mcuxi','🔐\x20Creating/authenticating\x20user\x20account\x20for:','🔐\x20Calling\x20generic\x20/register/google\x20endpoint...','📡\x20Google\x20register\x20response\x20status:','🔗\x20Account\x20creation\x20response:','Account\x20created/authenticated\x20successfully','Failed\x20to\x20create\x20account','WDCiP','fGoqE','PeFid','bArHB','getDeveloperAuthHeaders','vCwFt','API_CONFIG','BASE_URL','/register/google','idToken','photoUrl','JDUrL','json','hbnWi','isNewUser','message','ESMtZ','PDoiG','❌\x20Error\x20creating\x20user\x20account:','Failed\x20to\x20create\x20user\x20account','UuUuj','eOVwp','ppuNH','zDfgM','getCurrentUser','GEphd','HKJRW','pprsu','IvKpj','✅\x20Google\x20sign-out\x20successful','NWHEm','mLUBG','DbwYL'];_0x161d=function(){return _0x12a22b;};return _0x161d();}exports[_0x38c3(0x5)]=isGoogleSignedIn;const signOutFromGoogle=async()=>{const _0x5ad4c6={'NWHEm':function(_0x287d92,_0x2a0438){return _0x287d92!==_0x2a0438;},'DbwYL':'mLUBG','kIqfA':_0x38c3(0x7d)};try{if(_0x5ad4c6[_0x38c3(0x7e)](_0x38c3(0x7f),_0x5ad4c6[_0x38c3(0x80)]))_0x15fbde=_0x259691['iosClientId'];else return await _googleSignin[_0x38c3(0x2c)]['signOut'](),console[_0x38c3(0x29)](_0x5ad4c6['kIqfA']),!![];}catch(_0x26b589){return console['error'](_0x38c3(0x18),_0x26b589),![];}};exports['signOutFromGoogle']=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
|