@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 +1,173 @@
|
|
|
1
|
-
import{getAuthToken}from'./authService';import{API_CONFIG}from'../config/api';const API_BASE_URL=''+API_CONFIG[_0x49f9(0x0)];export const getTrainingStatus=async _0xa17d27=>{const _0xae4eb6={'yJbZy':_0x49f9(0x1),'RRDtf':_0x49f9(0x2),'kByzw':function(_0x279c09,_0x558e35){return _0x279c09===_0x558e35;},'gShHV':_0x49f9(0x3),'eGIeA':function(_0x3ad0f0){return _0x3ad0f0();},'HvFDF':'IqJlm','ijRNO':function(_0x593def,_0x1f7320,_0x412d7f){return _0x593def(_0x1f7320,_0x412d7f);},'NdTdR':_0x49f9(0x4),'qWofZ':_0x49f9(0x5)};try{if(_0xae4eb6[_0x49f9(0x6)](_0xae4eb6[_0x49f9(0x7)],_0xae4eb6[_0x49f9(0x7)])){const _0x550054=await _0xae4eb6['eGIeA'](getAuthToken);if(!_0x550054){if(_0xae4eb6[_0x49f9(0x6)](_0xae4eb6[_0x49f9(0x8)],_0xae4eb6[_0x49f9(0x8)]))throw new Error(_0x49f9(0x1));else throw new _0x148910(_0xae4eb6[_0x49f9(0x9)]);}const _0x425254=await _0xae4eb6[_0x49f9(0xa)](fetch,API_BASE_URL+_0x49f9(0xb)+_0xa17d27,{'method':'GET','headers':{'Authorization':_0x550054,'Content-Type':'application/json'}});if(!_0x425254['ok']){const _0x4d5f1a=await _0x425254[_0x49f9(0xc)]();throw new Error(_0x4d5f1a[_0x49f9(0xd)]||_0x49f9(0xe)+_0x425254[_0x49f9(0xf)]);}return await _0x425254[_0x49f9(0xc)]();}else return _0x2bb301['warn'](_0xae4eb6['RRDtf'],_0x4b564e),![];}catch(_0x5d744e){if(_0xae4eb6[_0x49f9(0x6)]('dQmuf',_0xae4eb6['NdTdR']))throw new _0xdda64c(_0x49f9(0x10)+_0x4db07f['status']+'\x20-\x20'+_0x34502f);else{console[_0x49f9(0xd)](_0xae4eb6[_0x49f9(0x11)],_0x5d744e);throw _0x5d744e;}}};export const getModelInfo=async()=>{const _0x278dcf={'AFhyZ':'❌\x20Training\x20start\x20error:','txSrw':function(_0x9145f1){return _0x9145f1();},'gcoyW':'No\x20authentication\x20token\x20available','kqRRv':function(_0x443a03,_0x40b43d,_0x5a4625){return _0x443a03(_0x40b43d,_0x5a4625);},'rVGkq':function(_0x3bcbe7,_0x22254a){return _0x3bcbe7===_0x22254a;},'cKUwj':_0x49f9(0x12),'SfjVT':'QrKov','BtokC':_0x49f9(0x13)};try{const _0x54018a=await _0x278dcf[_0x49f9(0x14)](getAuthToken);if(!_0x54018a)throw new Error(_0x278dcf[_0x49f9(0x15)]);const _0xda2e73=await _0x278dcf[_0x49f9(0x16)](fetch,API_BASE_URL+_0x49f9(0x17),{'method':'GET','headers':{'Authorization':_0x54018a,'Content-Type':'application/json'}});if(!_0xda2e73['ok']){if(_0x278dcf['rVGkq'](_0x278dcf[_0x49f9(0x18)],_0x278dcf['SfjVT'])){_0x21ab19[_0x49f9(0xd)](_0x278dcf['AFhyZ'],_0x451837);throw _0x2e04be;}else{const _0x2724e4=await _0xda2e73[_0x49f9(0xc)]();throw new Error(_0x2724e4[_0x49f9(0xd)]||_0x49f9(0xe)+_0xda2e73[_0x49f9(0xf)]);}}return await _0xda2e73[_0x49f9(0xc)]();}catch(_0x5a7252){console[_0x49f9(0xd)](_0x278dcf[_0x49f9(0x19)],_0x5a7252);throw _0x5a7252;}};export const getHealthCheck=async()=>{const _0x31688e={'Mtopy':function(_0x137532,_0x187bd6,_0x18b990){return _0x137532(_0x187bd6,_0x18b990);},'sXDQp':'❌\x20Failed\x20to\x20get\x20health\x20check:'};try{const _0x3ffd34=await _0x31688e[_0x49f9(0x1a)](fetch,API_BASE_URL+_0x49f9(0x1b),{'method':'GET','headers':{'Content-Type':'application/json'}});if(!_0x3ffd34['ok']){const _0x3106b5=await _0x3ffd34[_0x49f9(0xc)]();throw new Error(_0x3106b5['error']||_0x49f9(0xe)+_0x3ffd34[_0x49f9(0xf)]);}return await _0x3ffd34[_0x49f9(0xc)]();}catch(_0x2e2e1c){console[_0x49f9(0xd)](_0x31688e['sXDQp'],_0x2e2e1c);throw _0x2e2e1c;}};function _0x49f9(_0x32777c,_0x49f97a){_0x32777c=_0x32777c-0x0;const _0x305958=_0x3277();let _0x14b333=_0x305958[_0x32777c];return _0x14b333;}export const startEnochTrainingWithYouTubeCheck=async _0x5e56fe=>{const _0x3cd1c3={'UoIvn':_0x49f9(0x1c),'jDnYL':_0x49f9(0x1d),'gBDMH':_0x49f9(0x1e),'uiwWq':_0x49f9(0x1f),'txtsF':function(_0x29e28b,_0x34512b){return _0x29e28b(_0x34512b);},'wxBWr':_0x49f9(0x20),'XErJp':_0x49f9(0x21),'qpHXG':_0x49f9(0x22),'nKgyb':function(_0x4866f7,_0x288199){return _0x4866f7===_0x288199;},'UbqiS':_0x49f9(0x23),'kDBXZ':_0x49f9(0x24),'jcPwB':'❌\x20Training\x20error:'};try{const _0x35d7e4=_0x3cd1c3[_0x49f9(0x25)][_0x49f9(0x26)]('|');let _0x3252a6=0x0;while(!![]){switch(_0x35d7e4[_0x3252a6++]){case'0':console['log'](_0x49f9(0x27));continue;case'1':console['log'](_0x3cd1c3['jDnYL']);continue;case'2':console[_0x49f9(0x28)](_0x3cd1c3[_0x49f9(0x29)]);continue;case'3':console[_0x49f9(0x28)](_0x3cd1c3[_0x49f9(0x2a)]);continue;case'4':return await _0x3cd1c3[_0x49f9(0x2b)](startEnochTraining,_0x5e56fe);case'5':console[_0x49f9(0x28)](_0x3cd1c3[_0x49f9(0x2c)],_0x5e56fe[_0x49f9(0x2d)],_0x3cd1c3[_0x49f9(0x2e)]);continue;case'6':console['log'](_0x3cd1c3[_0x49f9(0x2f)]);continue;}break;}}catch(_0x1d0869){if(_0x3cd1c3[_0x49f9(0x30)](_0x3cd1c3[_0x49f9(0x31)],_0x3cd1c3[_0x49f9(0x32)])){_0x587e21[_0x49f9(0xd)](_0x49f9(0x33),_0x3c0ed2);throw _0x519828;}else{console[_0x49f9(0xd)](_0x3cd1c3['jcPwB'],_0x1d0869);throw _0x1d0869;}}};export const startEnochTraining=async _0x2e8e3a=>{const _0x1b48cf={'nIBrA':_0x49f9(0x34),'joGin':_0x49f9(0x35),'ScLGf':'No\x20authentication\x20token\x20available','EeAOb':_0x49f9(0x5),'KKOVw':function(_0xb602b5){return _0xb602b5();},'VBqzE':function(_0x57e787,_0x1e83db){return _0x57e787===_0x1e83db;},'yUKJi':_0x49f9(0x36),'mpXnM':_0x49f9(0x37),'nHedX':function(_0x30af8b,_0x48c9e1,_0x3d07e9){return _0x30af8b(_0x48c9e1,_0x3d07e9);},'sPlsI':'📡\x20Training\x20API\x20response\x20status:','AyGBN':function(_0x5c3463,_0x29c31e){return _0x5c3463!==_0x29c31e;},'nLsKm':_0x49f9(0x38),'LajWY':_0x49f9(0x39),'quRYT':_0x49f9(0x3a),'lKkkG':function(_0x477005,_0x2ba462){return _0x477005===_0x2ba462;},'MEMpa':_0x49f9(0x3b),'gzGzW':_0x49f9(0x3c),'bfTZP':_0x49f9(0x3d),'SZjwQ':_0x49f9(0x3e),'ZCAOT':'gfKHr','ISpYS':_0x49f9(0x3f)};try{const _0x469d04=await _0x1b48cf[_0x49f9(0x40)](getAuthToken);if(!_0x469d04){if(_0x1b48cf['VBqzE'](_0x1b48cf[_0x49f9(0x41)],_0x1b48cf[_0x49f9(0x41)]))throw new Error(_0x1b48cf[_0x49f9(0x42)]);else{_0x127079['error'](_0x49f9(0x13),_0x2f6fca);throw _0xdfa6d7;}}console['log'](_0x1b48cf['mpXnM'],_0x2e8e3a);const _0x3b20a0=await _0x1b48cf[_0x49f9(0x43)](fetch,API_BASE_URL+'/mobile-training/enoch',{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x469d04},'body':JSON[_0x49f9(0x44)](_0x2e8e3a)});console[_0x49f9(0x28)](_0x1b48cf['sPlsI'],_0x3b20a0[_0x49f9(0xf)]);if(!_0x3b20a0['ok']){if(_0x1b48cf[_0x49f9(0x45)](_0x1b48cf[_0x49f9(0x46)],_0x1b48cf[_0x49f9(0x47)])){const _0x54f7b0=await _0x3b20a0[_0x49f9(0x48)]();console[_0x49f9(0xd)](_0x1b48cf[_0x49f9(0x49)],_0x3b20a0['status'],_0x49f9(0x4a),_0x54f7b0);try{if(_0x1b48cf[_0x49f9(0x4b)](_0x1b48cf[_0x49f9(0x4c)],_0x1b48cf['gzGzW']))return _0x4fed57['warn'](_0x1b48cf['nIBrA'],_0x1ba2a3),null;else{const _0x3e1a8a=JSON[_0x49f9(0x4d)](_0x54f7b0);throw new Error(_0x3e1a8a['error']||'HTTP\x20'+_0x3b20a0[_0x49f9(0xf)]);}}catch(_0x34e61f){if(_0x1b48cf[_0x49f9(0x4b)](_0x1b48cf[_0x49f9(0x4e)],'hezFB'))throw new Error(_0x49f9(0x10)+_0x3b20a0[_0x49f9(0xf)]+_0x49f9(0x4f)+_0x54f7b0);else{_0x4e4794['error'](_0x1b48cf[_0x49f9(0x50)],_0x4709d1);throw _0x57d610;}}}else throw new _0xc7638c(_0x1b48cf[_0x49f9(0x42)]);}const _0x30b9a5=await _0x3b20a0['json']();return console['log'](_0x1b48cf[_0x49f9(0x51)],_0x30b9a5),_0x30b9a5;}catch(_0x502dbf){if(_0x1b48cf[_0x49f9(0x52)]===_0x1b48cf['ZCAOT']){console[_0x49f9(0xd)](_0x1b48cf[_0x49f9(0x53)],_0x502dbf);throw _0x502dbf;}else{_0x42494a[_0x49f9(0xd)](_0x1b48cf[_0x49f9(0x54)],_0x4c5823);throw _0x1852ae;}}};function _0x3277(){const _0x329046=['BASE_URL','No\x20authentication\x20token\x20available','⚠️\x20Could\x20not\x20check\x20training\x20status:','yEZsq','qeGrp','❌\x20Failed\x20to\x20get\x20training\x20status:','kByzw','gShHV','HvFDF','yJbZy','ijRNO','/mobile-training/status/','json','error','HTTP\x20','status','Training\x20API\x20failed:\x20','qWofZ','ABAke','❌\x20Failed\x20to\x20get\x20model\x20info:','txSrw','gcoyW','kqRRv','/mobile-training/model-info','cKUwj','BtokC','Mtopy','/mobile-training/health','5|1|0|6|3|2|4','🚀\x20[TRAINING]\x20Starting\x20training\x20-\x20backend\x20handles\x20all\x20YouTube\x20cases\x20automatically','\x20\x20\x20-\x20Backend\x20validation:\x20Handles\x20all\x20edge\x20cases\x20✅','\x20\x20\x20-\x20Full\x20refresh\x20tokens:\x20Auto-refresh\x20when\x20expired\x20✅','🚀\x20Starting\x20Enoch\x20training\x20for\x20user:','(backend\x20auto-handles\x20YouTube)','\x20\x20\x20-\x20Temporary\x20mode\x20connections:\x20Work\x20automatically\x20✅','QVxpc','FQtPI','UoIvn','split','ℹ️\x20[TRAINING]\x20No\x20migration\x20checks\x20needed:','log','gBDMH','uiwWq','txtsF','wxBWr','username','XErJp','qpHXG','nKgyb','UbqiS','kDBXZ','❌\x20Failed\x20to\x20get\x20health\x20check:','⚠️\x20Could\x20not\x20get\x20training\x20features:','❌\x20Training\x20error:','SyEGG','📤\x20Sending\x20training\x20data\x20to\x20/mobile-training/enoch:','WrzPo','Rddwm','❌\x20Training\x20API\x20failed\x20with\x20status:','QaHSM','CJgkY','hezFB','📡\x20Training\x20API\x20response:','❌\x20Training\x20start\x20error:','KKOVw','yUKJi','ScLGf','nHedX','stringify','AyGBN','nLsKm','LajWY','text','quRYT','Error:','lKkkG','MEMpa','parse','bfTZP','\x20-\x20','joGin','SZjwQ','ZCAOT','ISpYS','EeAOb','success','isTraining','warn','UVPTM','jNyuN','eOJaY','lCzvt','LPpZP','SBMtS','features'];_0x3277=function(){return _0x329046;};return _0x3277();}export const isTrainingInProgress=async _0x48facb=>{const _0x2da864={'RPcST':function(_0x5ed294,_0x4a2418){return _0x5ed294(_0x4a2418);},'UVPTM':'⚠️\x20Could\x20not\x20check\x20training\x20status:'};try{const _0x12bdd5=await _0x2da864['RPcST'](getTrainingStatus,_0x48facb);return _0x12bdd5[_0x49f9(0x55)]&&_0x12bdd5[_0x49f9(0x56)];}catch(_0x4f4e5f){return console[_0x49f9(0x57)](_0x2da864[_0x49f9(0x58)],_0x4f4e5f),![];}};export const getTrainingFeatures=async()=>{const _0x13ca5e={'LPpZP':_0x49f9(0x1),'eOJaY':function(_0x487eff,_0x32cce0){return _0x487eff===_0x32cce0;},'lCzvt':_0x49f9(0x59),'QvgtC':'NkBkZ','SBMtS':function(_0x577040){return _0x577040();},'HefUn':_0x49f9(0x34)};try{if(_0x13ca5e[_0x49f9(0x5a)](_0x13ca5e[_0x49f9(0x5b)],_0x13ca5e['QvgtC']))throw new _0x4a644c(_0x13ca5e[_0x49f9(0x5c)]);else{const _0x2f5d76=await _0x13ca5e[_0x49f9(0x5d)](getHealthCheck);return _0x2f5d76[_0x49f9(0x5e)];}}catch(_0x6223e7){return console[_0x49f9(0x57)](_0x13ca5e['HefUn'],_0x6223e7),null;}};
|
|
1
|
+
import { getAuthToken } from './authService';
|
|
2
|
+
import { API_CONFIG } from '../config/api';
|
|
3
|
+
// Migration functions no longer needed - backend handles all YouTube cases automatically
|
|
4
|
+
// import { checkAndFixYouTubeConnection, getYouTubeConnectionStatus, shouldShowYouTubeMigrationWarning } from './youtubeMigrationService';
|
|
5
|
+
|
|
6
|
+
const API_BASE_URL = `${API_CONFIG.BASE_URL}`;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Mobile Training API Service
|
|
10
|
+
* Implements the updated training spec routes
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Training Status Route
|
|
14
|
+
export const getTrainingStatus = async username => {
|
|
15
|
+
try {
|
|
16
|
+
const authToken = await getAuthToken();
|
|
17
|
+
if (!authToken) {
|
|
18
|
+
throw new Error('No authentication token available');
|
|
19
|
+
}
|
|
20
|
+
const response = await fetch(`${API_BASE_URL}/mobile-training/status/${username}`, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
headers: {
|
|
23
|
+
'Authorization': authToken,
|
|
24
|
+
'Content-Type': 'application/json'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
const errorData = await response.json();
|
|
29
|
+
throw new Error(errorData.error || `HTTP ${response.status}`);
|
|
30
|
+
}
|
|
31
|
+
return await response.json();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('❌ Failed to get training status:', error);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Model Info Route
|
|
39
|
+
export const getModelInfo = async () => {
|
|
40
|
+
try {
|
|
41
|
+
const authToken = await getAuthToken();
|
|
42
|
+
if (!authToken) {
|
|
43
|
+
throw new Error('No authentication token available');
|
|
44
|
+
}
|
|
45
|
+
const response = await fetch(`${API_BASE_URL}/mobile-training/model-info`, {
|
|
46
|
+
method: 'GET',
|
|
47
|
+
headers: {
|
|
48
|
+
'Authorization': authToken,
|
|
49
|
+
'Content-Type': 'application/json'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const errorData = await response.json();
|
|
54
|
+
throw new Error(errorData.error || `HTTP ${response.status}`);
|
|
55
|
+
}
|
|
56
|
+
return await response.json();
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('❌ Failed to get model info:', error);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Health Check Route
|
|
64
|
+
export const getHealthCheck = async () => {
|
|
65
|
+
try {
|
|
66
|
+
const response = await fetch(`${API_BASE_URL}/mobile-training/health`, {
|
|
67
|
+
method: 'GET',
|
|
68
|
+
headers: {
|
|
69
|
+
'Content-Type': 'application/json'
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
const errorData = await response.json();
|
|
74
|
+
throw new Error(errorData.error || `HTTP ${response.status}`);
|
|
75
|
+
}
|
|
76
|
+
return await response.json();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('❌ Failed to get health check:', error);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Start Enoch Training - Simplified Version
|
|
85
|
+
* Backend now handles all YouTube connection cases automatically (temporary mode, refresh tokens, etc.)
|
|
86
|
+
* No frontend migration checks needed anymore
|
|
87
|
+
*/
|
|
88
|
+
export const startEnochTrainingWithYouTubeCheck = async trainingData => {
|
|
89
|
+
try {
|
|
90
|
+
console.log('🚀 Starting Enoch training for user:', trainingData.username, '(backend auto-handles YouTube)');
|
|
91
|
+
|
|
92
|
+
// ✅ SIMPLIFIED: Backend handles all YouTube connection cases automatically
|
|
93
|
+
console.log('🚀 [TRAINING] Starting training - backend handles all YouTube cases automatically');
|
|
94
|
+
console.log('ℹ️ [TRAINING] No migration checks needed:');
|
|
95
|
+
console.log(' - Temporary mode connections: Work automatically ✅');
|
|
96
|
+
console.log(' - Full refresh tokens: Auto-refresh when expired ✅');
|
|
97
|
+
console.log(' - Backend validation: Handles all edge cases ✅');
|
|
98
|
+
|
|
99
|
+
// ✅ Proceed with training - backend handles YouTube automatically
|
|
100
|
+
return await startEnochTraining(trainingData);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('❌ Training error:', error);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Start Enoch Training
|
|
109
|
+
* Updated to use the new /mobile-training/enoch endpoint with proper error handling
|
|
110
|
+
*/
|
|
111
|
+
export const startEnochTraining = async trainingData => {
|
|
112
|
+
try {
|
|
113
|
+
const authToken = await getAuthToken();
|
|
114
|
+
if (!authToken) {
|
|
115
|
+
throw new Error('No authentication token available');
|
|
116
|
+
}
|
|
117
|
+
console.log('📤 Sending training data to /mobile-training/enoch:', trainingData);
|
|
118
|
+
const response = await fetch(`${API_BASE_URL}/mobile-training/enoch`, {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
headers: {
|
|
121
|
+
'Content-Type': 'application/json',
|
|
122
|
+
'Authorization': authToken
|
|
123
|
+
},
|
|
124
|
+
body: JSON.stringify(trainingData)
|
|
125
|
+
});
|
|
126
|
+
console.log('📡 Training API response status:', response.status);
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
const errorText = await response.text();
|
|
129
|
+
console.error('❌ Training API failed with status:', response.status, 'Error:', errorText);
|
|
130
|
+
|
|
131
|
+
// Try to parse error response
|
|
132
|
+
try {
|
|
133
|
+
const errorData = JSON.parse(errorText);
|
|
134
|
+
throw new Error(errorData.error || `HTTP ${response.status}`);
|
|
135
|
+
} catch (parseError) {
|
|
136
|
+
throw new Error(`Training API failed: ${response.status} - ${errorText}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const result = await response.json();
|
|
140
|
+
console.log('📡 Training API response:', result);
|
|
141
|
+
return result;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error('❌ Training start error:', error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Helper function to check if training is in progress
|
|
150
|
+
*/
|
|
151
|
+
export const isTrainingInProgress = async username => {
|
|
152
|
+
try {
|
|
153
|
+
const status = await getTrainingStatus(username);
|
|
154
|
+
return status.success && status.isTraining;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.warn('⚠️ Could not check training status:', error);
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Helper function to get training features info
|
|
163
|
+
*/
|
|
164
|
+
export const getTrainingFeatures = async () => {
|
|
165
|
+
try {
|
|
166
|
+
const health = await getHealthCheck();
|
|
167
|
+
return health.features;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.warn('⚠️ Could not get training features:', error);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=mobileTrainingService.js.map
|
|
@@ -1 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Netflix Data Extractor
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the Netflix data export flow:
|
|
5
|
+
* 1. Receives extracted viewing data from WebView
|
|
6
|
+
* 2. Validates and formats data
|
|
7
|
+
* 3. Sends to backend via netflixDataService
|
|
8
|
+
*
|
|
9
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
10
|
+
*
|
|
11
|
+
* @reference Sephora implementation: src/services/sephoraDataExtractor.ts
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { storeNetflixData } from './netflixDataService';
|
|
15
|
+
import { Alert } from 'react-native';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Combined Netflix export data from WebView - matches netflix.ts script output
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook for Netflix data extraction operations
|
|
23
|
+
*/
|
|
24
|
+
export const useNetflixDataExtractor = () => {
|
|
25
|
+
/**
|
|
26
|
+
* Initiate data export to backend
|
|
27
|
+
*
|
|
28
|
+
* @param username - User identifier
|
|
29
|
+
* @param data - Extracted Netflix data (viewingHistory, myList, ratings, profile)
|
|
30
|
+
* @returns true if successful, false otherwise
|
|
31
|
+
*/
|
|
32
|
+
const initiateDataExport = async (username, data) => {
|
|
33
|
+
var _data$viewingHistory, _data$myList, _data$ratings, _data$viewingHistory2;
|
|
34
|
+
console.log('🚀 [NETFLIX_EXTRACTOR] Initiating data export');
|
|
35
|
+
console.log('👤 [NETFLIX_EXTRACTOR] Username:', username);
|
|
36
|
+
console.log('📊 [NETFLIX_EXTRACTOR] Summary:', data.summary);
|
|
37
|
+
if (!username) {
|
|
38
|
+
console.error('❌ [NETFLIX_EXTRACTOR] Username is required');
|
|
39
|
+
Alert.alert('Error', 'Username is required to export Netflix data.', [{
|
|
40
|
+
text: 'OK',
|
|
41
|
+
style: 'default'
|
|
42
|
+
}]);
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const totalItems = (((_data$viewingHistory = data.viewingHistory) === null || _data$viewingHistory === void 0 || (_data$viewingHistory = _data$viewingHistory.items) === null || _data$viewingHistory === void 0 ? void 0 : _data$viewingHistory.length) || 0) + (((_data$myList = data.myList) === null || _data$myList === void 0 ? void 0 : _data$myList.length) || 0) + (((_data$ratings = data.ratings) === null || _data$ratings === void 0 ? void 0 : _data$ratings.length) || 0);
|
|
46
|
+
if (totalItems === 0) {
|
|
47
|
+
console.log('ℹ️ [NETFLIX_EXTRACTOR] No data to export - treating as success (connected)');
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
const validViewingHistory = (((_data$viewingHistory2 = data.viewingHistory) === null || _data$viewingHistory2 === void 0 ? void 0 : _data$viewingHistory2.items) || []).filter(item => {
|
|
51
|
+
const isValid = item.videoId && item.title;
|
|
52
|
+
if (!isValid) {
|
|
53
|
+
console.warn('⚠️ [NETFLIX_EXTRACTOR] Invalid viewing history item:', item);
|
|
54
|
+
}
|
|
55
|
+
return isValid;
|
|
56
|
+
});
|
|
57
|
+
const validMyList = (data.myList || []).filter(item => {
|
|
58
|
+
const isValid = item.videoId && item.title;
|
|
59
|
+
if (!isValid) {
|
|
60
|
+
console.warn('⚠️ [NETFLIX_EXTRACTOR] Invalid My List item:', item);
|
|
61
|
+
}
|
|
62
|
+
return isValid;
|
|
63
|
+
});
|
|
64
|
+
const validRatings = (data.ratings || []).filter(rating => {
|
|
65
|
+
const isValid = rating.videoId && rating.rating;
|
|
66
|
+
if (!isValid) {
|
|
67
|
+
console.warn('⚠️ [NETFLIX_EXTRACTOR] Invalid rating:', rating);
|
|
68
|
+
}
|
|
69
|
+
return isValid;
|
|
70
|
+
});
|
|
71
|
+
const originalCount = totalItems;
|
|
72
|
+
const validCount = validViewingHistory.length + validMyList.length + validRatings.length;
|
|
73
|
+
if (validCount < originalCount) {
|
|
74
|
+
console.warn(`⚠️ [NETFLIX_EXTRACTOR] Filtered out ${originalCount - validCount} invalid items`);
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
console.log('📡 [NETFLIX_EXTRACTOR] Sending to backend...');
|
|
78
|
+
const result = await storeNetflixData(username, {
|
|
79
|
+
viewingHistory: {
|
|
80
|
+
items: validViewingHistory,
|
|
81
|
+
totalCount: validViewingHistory.length
|
|
82
|
+
},
|
|
83
|
+
myList: validMyList,
|
|
84
|
+
ratings: validRatings,
|
|
85
|
+
profile: data.profile,
|
|
86
|
+
tokenExpiry: data.tokenExpiry,
|
|
87
|
+
profileId: data.profileId
|
|
88
|
+
});
|
|
89
|
+
if (result.success) {
|
|
90
|
+
console.log('✅ [NETFLIX_EXTRACTOR] Export completed successfully');
|
|
91
|
+
console.log('📊 [NETFLIX_EXTRACTOR] Backend response:', result.data);
|
|
92
|
+
return true;
|
|
93
|
+
} else {
|
|
94
|
+
console.error('❌ [NETFLIX_EXTRACTOR] Backend storage failed:', result.error);
|
|
95
|
+
Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
|
|
96
|
+
text: 'OK',
|
|
97
|
+
style: 'default'
|
|
98
|
+
}]);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('❌ [NETFLIX_EXTRACTOR] Unexpected error during export:', error);
|
|
103
|
+
Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
|
|
104
|
+
text: 'OK',
|
|
105
|
+
style: 'default'
|
|
106
|
+
}]);
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
initiateDataExport
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=netflixDataExtractor.js.map
|
|
@@ -1 +1,191 @@
|
|
|
1
|
-
function _0x39b7(){const _0x451a96=['❌\x20[NETFLIX_SERVICE]\x20No\x20auth\x20token\x20found','✅\x20[NETFLIX_SERVICE]\x20Successfully\x20stored\x20Netflix\x20data','Netflix\x20data\x20stored\x20successfully','📊\x20[NETFLIX_SERVICE]\x20Viewing\x20history\x20items:','📊\x20[NETFLIX_SERVICE]\x20My\x20List\x20items:','📊\x20[NETFLIX_SERVICE]\x20Ratings:','vtvJn','❌\x20[NETFLIX_SERVICE]\x20Invalid\x20input:\x20userId\x20missing','Invalid\x20input:\x20userId\x20missing.','🔑\x20[NETFLIX_SERVICE]\x20Auth\x20token\x20found','webview-api','1.0.0','ios','Android','unknown','📡\x20[NETFLIX_SERVICE]\x20Sending\x20to\x20backend...','📍\x20[NETFLIX_SERVICE]\x20URL:','Unknown\x20error','Network\x20error.\x20Please\x20check\x20your\x20connection.','log','CdXqF','biXbR','viewingHistory','VhOpy','jCLek','CVpnr','myList','length','nrPeE','jgsaE','RiAXD','WFkit','error','sBkdo','EWyQv','HzKKt','onairos_jwt_token','getItem','WxKVP','ySCrG','hRwoc','qIFCG','zXkFS','message','📝\x20[NETFLIX_SERVICE]\x20Backend\x20response:\x20','segNm','data','fiFKB','SidBA','dCfIf','ngTCV','17.0','iPhone','dFidF','toISOString','tokenExpiry','kGCoi','UuSaI','map','type','seriesTitle','episodeNumber','watchedAt','watchDuration','percentWatched','imageUrl','genres','totalCount','oCHQr','fwmgq','items','gbmVx','videoId','title','addedAt','maturityRating','year','ratings','rating','profile','profileId','profileName','subtitlePreferences','autoplayPreferences','SAkJC','Lsiqo','SCbPu','NBTxM','filter','thumbs_up','thumbs_down','mIQWb','UGHiF','dUVPC','BASE_URL','/platform-data/store','Bearer\x20','OnairosSDK/1.0.0\x20(','stringify','json','warn','⚠️\x20[NETFLIX_SERVICE]\x20Backend\x20returned\x20status:\x20','status','OnWDz','HTTP\x20','Pmqai'];_0x39b7=function(){return _0x451a96;};return _0x39b7();}import{API_CONFIG}from'../config/api';import AsyncStorage from'@react-native-async-storage/async-storage';function _0x4550(_0x39b7d8,_0x455009){_0x39b7d8=_0x39b7d8-0x0;const _0x6b711a=_0x39b7();let _0x223f11=_0x6b711a[_0x39b7d8];return _0x223f11;}import{Platform}from'react-native';export const storeNetflixData=async(_0x25c231,_0x256319)=>{const _0x1bf5d1={'sBkdo':_0x4550(0x0),'EWyQv':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','zXkFS':_0x4550(0x1),'segNm':_0x4550(0x2),'CdXqF':'🚀\x20[NETFLIX_SERVICE]\x20Storing\x20Netflix\x20data\x20for:','biXbR':_0x4550(0x3),'VhOpy':function(_0x33a28e,_0x3b49cd){return _0x33a28e===_0x3b49cd;},'jCLek':_0x4550(0x4),'CVpnr':function(_0x105f43,_0x5db1a5){return _0x105f43===_0x5db1a5;},'aimee':_0x4550(0x5),'lcjHm':function(_0x32b12c,_0x39d044){return _0x32b12c===_0x39d044;},'nrPeE':function(_0x523ddd,_0x1d25c0){return _0x523ddd===_0x1d25c0;},'jgsaE':'📊\x20[NETFLIX_SERVICE]\x20Has\x20profile:','RiAXD':function(_0x417196,_0x4c5f98){return _0x417196!==_0x4c5f98;},'WFkit':_0x4550(0x6),'HzKKt':_0x4550(0x7),'uTDzB':_0x4550(0x8),'WxKVP':'enoch_token','ySCrG':'auth_token','hRwoc':function(_0x255a3d,_0x52248d){return _0x255a3d===_0x52248d;},'fiFKB':_0x4550(0x9),'DcBrv':_0x4550(0xa),'SidBA':_0x4550(0xb),'dCfIf':function(_0x173198,_0xbaf148){return _0x173198===_0xbaf148;},'ngTCV':_0x4550(0xc),'Lsiqo':function(_0x4476c2,_0x277504){return _0x4476c2===_0x277504;},'dFidF':_0x4550(0xd),'taulp':'mobile-netflix','kGCoi':'streaming','UuSaI':function(_0x36fa5c,_0x251e33){return _0x36fa5c===_0x251e33;},'oCHQr':function(_0x2fbafc,_0x346c08){return _0x2fbafc===_0x346c08;},'fwmgq':function(_0x47d62c,_0x1d0f6a){return _0x47d62c===_0x1d0f6a;},'gbmVx':function(_0x4c1a12,_0xe19c9b){return _0x4c1a12===_0xe19c9b;},'SAkJC':function(_0x4af61c,_0x1b6ac7){return _0x4af61c===_0x1b6ac7;},'SCbPu':function(_0x15259d,_0x50033c){return _0x15259d===_0x50033c;},'NBTxM':function(_0x3a01c8,_0x3426c5){return _0x3a01c8===_0x3426c5;},'mIQWb':function(_0x110c5c,_0x1292ed){return _0x110c5c===_0x1292ed;},'UGHiF':_0x4550(0xe),'dUVPC':_0x4550(0xf),'cXgSw':_0x4550(0x10),'OnWDz':_0x4550(0x11),'Pmqai':'❌\x20[NETFLIX_SERVICE]\x20Network\x20error:','cgSMV':_0x4550(0x12)};var _0x105dd2,_0x598de9,_0x1ed72f;console[_0x4550(0x13)](_0x1bf5d1[_0x4550(0x14)],_0x25c231),console[_0x4550(0x13)](_0x1bf5d1[_0x4550(0x15)],((_0x105dd2=_0x256319[_0x4550(0x16)])===null||_0x1bf5d1[_0x4550(0x17)](_0x105dd2,void 0x0)||(_0x105dd2=_0x105dd2['items'])===null||_0x1bf5d1[_0x4550(0x17)](_0x105dd2,void 0x0)?void 0x0:_0x105dd2['length'])||0x0),console[_0x4550(0x13)](_0x1bf5d1[_0x4550(0x18)],(_0x1bf5d1[_0x4550(0x19)](_0x598de9=_0x256319[_0x4550(0x1a)],null)||_0x1bf5d1[_0x4550(0x17)](_0x598de9,void 0x0)?void 0x0:_0x598de9[_0x4550(0x1b)])||0x0),console[_0x4550(0x13)](_0x1bf5d1['aimee'],(_0x1bf5d1['lcjHm'](_0x1ed72f=_0x256319['ratings'],null)||_0x1bf5d1[_0x4550(0x1c)](_0x1ed72f,void 0x0)?void 0x0:_0x1ed72f[_0x4550(0x1b)])||0x0),console[_0x4550(0x13)](_0x1bf5d1[_0x4550(0x1d)],!!_0x256319['profile']);if(!_0x25c231)return _0x1bf5d1[_0x4550(0x1e)](_0x4550(0x6),_0x1bf5d1[_0x4550(0x1f)])?(_0x376cd2[_0x4550(0x20)](_0x1bf5d1[_0x4550(0x21)]),{'success':![],'error':_0x1bf5d1[_0x4550(0x22)]}):(console[_0x4550(0x20)](_0x1bf5d1[_0x4550(0x23)]),{'success':![],'error':_0x1bf5d1['uTDzB']});try{var _0xeadd8c,_0x3c2ed8,_0x2c0b32,_0x5ddea2,_0x1b571a,_0x1c5a5e,_0x2dd93b,_0x56b933;const _0x5f1a48=await AsyncStorage['getItem'](_0x4550(0x24))||await AsyncStorage[_0x4550(0x25)](_0x1bf5d1[_0x4550(0x26)])||await AsyncStorage[_0x4550(0x25)](_0x1bf5d1[_0x4550(0x27)]);if(!_0x5f1a48)return _0x1bf5d1[_0x4550(0x28)](_0x4550(0x29),_0x4550(0x29))?(console[_0x4550(0x20)](_0x1bf5d1[_0x4550(0x21)]),{'success':![],'error':_0x1bf5d1['EWyQv']}):(_0x37b7f2[_0x4550(0x13)](_0x1bf5d1[_0x4550(0x2a)]),_0x2e4184[_0x4550(0x2b)]&&_0x3120d0['log'](_0x4550(0x2c)+_0x430fce[_0x4550(0x2b)]),{'success':!![],'message':_0xd71c1c[_0x4550(0x2b)]||_0x1bf5d1[_0x4550(0x2d)],'data':_0x3b654a[_0x4550(0x2e)]});console[_0x4550(0x13)](_0x1bf5d1[_0x4550(0x2f)]);const _0x1043d5={'platform':Platform['OS'],'source':_0x1bf5d1['DcBrv'],'appVersion':_0x1bf5d1[_0x4550(0x30)],'osVersion':_0x1bf5d1[_0x4550(0x31)](Platform['OS'],_0x1bf5d1[_0x4550(0x32)])?_0x4550(0x33):Platform['OS'],'deviceModel':_0x1bf5d1['Lsiqo'](Platform['OS'],_0x4550(0xc))?_0x4550(0x34):_0x1bf5d1[_0x4550(0x35)],'isOfflineSync':![],'extractedAt':new Date()[_0x4550(0x36)](),'tokenExpiry':_0x256319[_0x4550(0x37)]},_0x5f98f9={'platform':_0x1bf5d1['taulp'],'dataType':_0x1bf5d1[_0x4550(0x38)],'data':{'viewingHistory':{'items':(((_0xeadd8c=_0x256319['viewingHistory'])===null||_0x1bf5d1[_0x4550(0x39)](_0xeadd8c,void 0x0)?void 0x0:_0xeadd8c['items'])||[])[_0x4550(0x3a)](_0x47066a=>({'videoId':_0x47066a['videoId'],'title':_0x47066a['title'],'type':_0x47066a[_0x4550(0x3b)],'seriesTitle':_0x47066a[_0x4550(0x3c)],'seasonNumber':_0x47066a['seasonNumber'],'episodeNumber':_0x47066a[_0x4550(0x3d)],'watchedAt':_0x47066a[_0x4550(0x3e)],'watchDuration':_0x47066a[_0x4550(0x3f)],'totalDuration':_0x47066a['totalDuration'],'percentWatched':_0x47066a[_0x4550(0x40)],'imageUrl':_0x47066a[_0x4550(0x41)],'genres':_0x47066a[_0x4550(0x42)]})),'totalCount':((_0x3c2ed8=_0x256319[_0x4550(0x16)])===null||_0x3c2ed8===void 0x0?void 0x0:_0x3c2ed8[_0x4550(0x43)])||(_0x1bf5d1[_0x4550(0x44)](_0x2c0b32=_0x256319[_0x4550(0x16)],null)||_0x1bf5d1[_0x4550(0x45)](_0x2c0b32,void 0x0)||_0x1bf5d1['CVpnr'](_0x2c0b32=_0x2c0b32[_0x4550(0x46)],null)||_0x1bf5d1[_0x4550(0x47)](_0x2c0b32,void 0x0)?void 0x0:_0x2c0b32[_0x4550(0x1b)])||0x0},'myList':(_0x256319[_0x4550(0x1a)]||[])[_0x4550(0x3a)](_0x27abfb=>({'videoId':_0x27abfb[_0x4550(0x48)],'title':_0x27abfb[_0x4550(0x49)],'type':_0x27abfb[_0x4550(0x3b)],'addedAt':_0x27abfb[_0x4550(0x4a)],'imageUrl':_0x27abfb[_0x4550(0x41)],'genres':_0x27abfb[_0x4550(0x42)],'maturityRating':_0x27abfb[_0x4550(0x4b)],'year':_0x27abfb[_0x4550(0x4c)]})),'ratings':(_0x256319[_0x4550(0x4d)]||[])[_0x4550(0x3a)](_0x4d16b7=>({'videoId':_0x4d16b7[_0x4550(0x48)],'title':_0x4d16b7['title'],'rating':_0x4d16b7[_0x4550(0x4e)],'ratedAt':_0x4d16b7['ratedAt']})),'profile':_0x256319[_0x4550(0x4f)]?{'profileId':_0x256319[_0x4550(0x4f)][_0x4550(0x50)],'profileName':_0x256319[_0x4550(0x4f)][_0x4550(0x51)],'maturityLevel':_0x256319['profile']['maturityLevel'],'language':_0x256319[_0x4550(0x4f)]['language'],'subtitlePreferences':_0x256319[_0x4550(0x4f)][_0x4550(0x52)],'autoplayPreferences':_0x256319[_0x4550(0x4f)][_0x4550(0x53)]}:null,'netflixProfileId':_0x256319[_0x4550(0x50)]||(_0x1bf5d1[_0x4550(0x54)](_0x5ddea2=_0x256319[_0x4550(0x4f)],null)||_0x1bf5d1[_0x4550(0x44)](_0x5ddea2,void 0x0)?void 0x0:_0x5ddea2[_0x4550(0x50)])},'summary':{'viewingHistoryCount':(_0x1bf5d1[_0x4550(0x55)](_0x1b571a=_0x256319[_0x4550(0x16)],null)||_0x1bf5d1[_0x4550(0x56)](_0x1b571a,void 0x0)||(_0x1b571a=_0x1b571a['items'])===null||_0x1bf5d1[_0x4550(0x28)](_0x1b571a,void 0x0)?void 0x0:_0x1b571a['length'])||0x0,'myListCount':(_0x1bf5d1[_0x4550(0x45)](_0x1c5a5e=_0x256319[_0x4550(0x1a)],null)||_0x1c5a5e===void 0x0?void 0x0:_0x1c5a5e[_0x4550(0x1b)])||0x0,'ratingsCount':(_0x1bf5d1[_0x4550(0x1c)](_0x2dd93b=_0x256319['ratings'],null)||_0x1bf5d1[_0x4550(0x57)](_0x2dd93b,void 0x0)?void 0x0:_0x2dd93b['length'])||0x0,'thumbsUpCount':(_0x256319[_0x4550(0x4d)]||[])[_0x4550(0x58)](_0x19d53a=>_0x19d53a[_0x4550(0x4e)]===_0x4550(0x59))[_0x4550(0x1b)],'thumbsDownCount':(_0x256319[_0x4550(0x4d)]||[])[_0x4550(0x58)](_0x12936d=>_0x12936d['rating']===_0x4550(0x5a))[_0x4550(0x1b)],'profileName':(_0x1bf5d1[_0x4550(0x5b)](_0x56b933=_0x256319[_0x4550(0x4f)],null)||_0x1bf5d1[_0x4550(0x39)](_0x56b933,void 0x0)?void 0x0:_0x56b933[_0x4550(0x51)])||_0x1bf5d1[_0x4550(0x5c)]},'mobileMetadata':_0x1043d5};console[_0x4550(0x13)](_0x1bf5d1[_0x4550(0x5d)]),console[_0x4550(0x13)](_0x1bf5d1['cXgSw'],API_CONFIG[_0x4550(0x5e)]+_0x4550(0x5f));const _0x1677b8=await fetch(API_CONFIG['BASE_URL']+_0x4550(0x5f),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x4550(0x60)+_0x5f1a48,'User-Agent':_0x4550(0x61)+Platform['OS']+')'},'body':JSON[_0x4550(0x62)](_0x5f98f9)}),_0x1a799a=await _0x1677b8[_0x4550(0x63)]();return _0x1677b8['ok']?(console[_0x4550(0x13)](_0x4550(0x1)),_0x1a799a[_0x4550(0x2b)]&&console[_0x4550(0x13)](_0x4550(0x2c)+_0x1a799a[_0x4550(0x2b)]),{'success':!![],'message':_0x1a799a[_0x4550(0x2b)]||_0x1bf5d1[_0x4550(0x2d)],'data':_0x1a799a['data']}):(console[_0x4550(0x64)](_0x4550(0x65)+_0x1677b8[_0x4550(0x66)]),console[_0x4550(0x64)]('⚠️\x20[NETFLIX_SERVICE]\x20Error:\x20'+(_0x1a799a[_0x4550(0x20)]||_0x1bf5d1[_0x4550(0x67)])),{'success':![],'error':_0x1a799a[_0x4550(0x20)]||_0x4550(0x68)+_0x1677b8['status']});}catch(_0x501607){return console['error'](_0x1bf5d1[_0x4550(0x69)],_0x501607),{'success':![],'error':_0x501607['message']||_0x1bf5d1['cgSMV']};}};
|
|
1
|
+
/**
|
|
2
|
+
* Netflix Data Service
|
|
3
|
+
*
|
|
4
|
+
* API layer for storing Netflix viewing data on backend.
|
|
5
|
+
* Sends extracted viewing history, watch later, and profile to /platform-data/store endpoint.
|
|
6
|
+
*
|
|
7
|
+
* MATCHES Sephora/ChatGPT implementation pattern
|
|
8
|
+
* - Uses format: { platform, data, metadata }
|
|
9
|
+
* - Platform: "mobile-netflix"
|
|
10
|
+
*
|
|
11
|
+
* Data Sources (from netflix.com - API details TBD):
|
|
12
|
+
* - Viewing History: User's watch history
|
|
13
|
+
* - My List: User's saved shows/movies
|
|
14
|
+
* - Profile: User preferences and settings
|
|
15
|
+
* - Ratings: User's thumbs up/down ratings
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { API_CONFIG } from '../config/api';
|
|
19
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
20
|
+
import { Platform } from 'react-native';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Structure of a viewed item - Netflix content
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Structure of viewing history
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Structure of a My List item
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Structure of a rating
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Structure of user profile
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Token expiry information
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Combined Netflix data to store - matches WebView export format
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Response from backend endpoint
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Store Netflix data on backend
|
|
56
|
+
*
|
|
57
|
+
* @param userId - Username or identifier
|
|
58
|
+
* @param data - Netflix viewing data (history, myList, ratings, profile)
|
|
59
|
+
* @returns Response indicating success/failure with metadata
|
|
60
|
+
*/
|
|
61
|
+
export const storeNetflixData = async (userId, data) => {
|
|
62
|
+
var _data$viewingHistory, _data$myList, _data$ratings;
|
|
63
|
+
console.log('🚀 [NETFLIX_SERVICE] Storing Netflix data for:', userId);
|
|
64
|
+
console.log('📊 [NETFLIX_SERVICE] Viewing history items:', ((_data$viewingHistory = data.viewingHistory) === null || _data$viewingHistory === void 0 || (_data$viewingHistory = _data$viewingHistory.items) === null || _data$viewingHistory === void 0 ? void 0 : _data$viewingHistory.length) || 0);
|
|
65
|
+
console.log('📊 [NETFLIX_SERVICE] My List items:', ((_data$myList = data.myList) === null || _data$myList === void 0 ? void 0 : _data$myList.length) || 0);
|
|
66
|
+
console.log('📊 [NETFLIX_SERVICE] Ratings:', ((_data$ratings = data.ratings) === null || _data$ratings === void 0 ? void 0 : _data$ratings.length) || 0);
|
|
67
|
+
console.log('📊 [NETFLIX_SERVICE] Has profile:', !!data.profile);
|
|
68
|
+
if (!userId) {
|
|
69
|
+
console.error('❌ [NETFLIX_SERVICE] Invalid input: userId missing');
|
|
70
|
+
return {
|
|
71
|
+
success: false,
|
|
72
|
+
error: 'Invalid input: userId missing.'
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
var _data$viewingHistory2, _data$viewingHistory3, _data$viewingHistory4, _data$profile, _data$viewingHistory5, _data$myList2, _data$ratings2, _data$profile2;
|
|
77
|
+
const authToken = (await AsyncStorage.getItem('onairos_jwt_token')) || (await AsyncStorage.getItem('enoch_token')) || (await AsyncStorage.getItem('auth_token'));
|
|
78
|
+
if (!authToken) {
|
|
79
|
+
console.error('❌ [NETFLIX_SERVICE] No auth token found');
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
error: 'Authentication token not found. Please log in again.'
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
console.log('🔑 [NETFLIX_SERVICE] Auth token found');
|
|
86
|
+
const mobileMetadata = {
|
|
87
|
+
platform: Platform.OS,
|
|
88
|
+
source: 'webview-api',
|
|
89
|
+
appVersion: '1.0.0',
|
|
90
|
+
osVersion: Platform.OS === 'ios' ? '17.0' : Platform.OS,
|
|
91
|
+
deviceModel: Platform.OS === 'ios' ? 'iPhone' : 'Android',
|
|
92
|
+
isOfflineSync: false,
|
|
93
|
+
extractedAt: new Date().toISOString(),
|
|
94
|
+
tokenExpiry: data.tokenExpiry
|
|
95
|
+
};
|
|
96
|
+
const requestBody = {
|
|
97
|
+
platform: 'mobile-netflix',
|
|
98
|
+
dataType: 'streaming',
|
|
99
|
+
data: {
|
|
100
|
+
viewingHistory: {
|
|
101
|
+
items: (((_data$viewingHistory2 = data.viewingHistory) === null || _data$viewingHistory2 === void 0 ? void 0 : _data$viewingHistory2.items) || []).map(item => ({
|
|
102
|
+
videoId: item.videoId,
|
|
103
|
+
title: item.title,
|
|
104
|
+
type: item.type,
|
|
105
|
+
seriesTitle: item.seriesTitle,
|
|
106
|
+
seasonNumber: item.seasonNumber,
|
|
107
|
+
episodeNumber: item.episodeNumber,
|
|
108
|
+
watchedAt: item.watchedAt,
|
|
109
|
+
watchDuration: item.watchDuration,
|
|
110
|
+
totalDuration: item.totalDuration,
|
|
111
|
+
percentWatched: item.percentWatched,
|
|
112
|
+
imageUrl: item.imageUrl,
|
|
113
|
+
genres: item.genres
|
|
114
|
+
})),
|
|
115
|
+
totalCount: ((_data$viewingHistory3 = data.viewingHistory) === null || _data$viewingHistory3 === void 0 ? void 0 : _data$viewingHistory3.totalCount) || ((_data$viewingHistory4 = data.viewingHistory) === null || _data$viewingHistory4 === void 0 || (_data$viewingHistory4 = _data$viewingHistory4.items) === null || _data$viewingHistory4 === void 0 ? void 0 : _data$viewingHistory4.length) || 0
|
|
116
|
+
},
|
|
117
|
+
myList: (data.myList || []).map(item => ({
|
|
118
|
+
videoId: item.videoId,
|
|
119
|
+
title: item.title,
|
|
120
|
+
type: item.type,
|
|
121
|
+
addedAt: item.addedAt,
|
|
122
|
+
imageUrl: item.imageUrl,
|
|
123
|
+
genres: item.genres,
|
|
124
|
+
maturityRating: item.maturityRating,
|
|
125
|
+
year: item.year
|
|
126
|
+
})),
|
|
127
|
+
ratings: (data.ratings || []).map(rating => ({
|
|
128
|
+
videoId: rating.videoId,
|
|
129
|
+
title: rating.title,
|
|
130
|
+
rating: rating.rating,
|
|
131
|
+
ratedAt: rating.ratedAt
|
|
132
|
+
})),
|
|
133
|
+
profile: data.profile ? {
|
|
134
|
+
profileId: data.profile.profileId,
|
|
135
|
+
profileName: data.profile.profileName,
|
|
136
|
+
maturityLevel: data.profile.maturityLevel,
|
|
137
|
+
language: data.profile.language,
|
|
138
|
+
subtitlePreferences: data.profile.subtitlePreferences,
|
|
139
|
+
autoplayPreferences: data.profile.autoplayPreferences
|
|
140
|
+
} : null,
|
|
141
|
+
netflixProfileId: data.profileId || ((_data$profile = data.profile) === null || _data$profile === void 0 ? void 0 : _data$profile.profileId)
|
|
142
|
+
},
|
|
143
|
+
summary: {
|
|
144
|
+
viewingHistoryCount: ((_data$viewingHistory5 = data.viewingHistory) === null || _data$viewingHistory5 === void 0 || (_data$viewingHistory5 = _data$viewingHistory5.items) === null || _data$viewingHistory5 === void 0 ? void 0 : _data$viewingHistory5.length) || 0,
|
|
145
|
+
myListCount: ((_data$myList2 = data.myList) === null || _data$myList2 === void 0 ? void 0 : _data$myList2.length) || 0,
|
|
146
|
+
ratingsCount: ((_data$ratings2 = data.ratings) === null || _data$ratings2 === void 0 ? void 0 : _data$ratings2.length) || 0,
|
|
147
|
+
thumbsUpCount: (data.ratings || []).filter(r => r.rating === 'thumbs_up').length,
|
|
148
|
+
thumbsDownCount: (data.ratings || []).filter(r => r.rating === 'thumbs_down').length,
|
|
149
|
+
profileName: ((_data$profile2 = data.profile) === null || _data$profile2 === void 0 ? void 0 : _data$profile2.profileName) || 'unknown'
|
|
150
|
+
},
|
|
151
|
+
mobileMetadata: mobileMetadata
|
|
152
|
+
};
|
|
153
|
+
console.log('📡 [NETFLIX_SERVICE] Sending to backend...');
|
|
154
|
+
console.log('📍 [NETFLIX_SERVICE] URL:', `${API_CONFIG.BASE_URL}/platform-data/store`);
|
|
155
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/platform-data/store`, {
|
|
156
|
+
method: 'POST',
|
|
157
|
+
headers: {
|
|
158
|
+
'Content-Type': 'application/json',
|
|
159
|
+
'Authorization': `Bearer ${authToken}`,
|
|
160
|
+
'User-Agent': `OnairosSDK/1.0.0 (${Platform.OS})`
|
|
161
|
+
},
|
|
162
|
+
body: JSON.stringify(requestBody)
|
|
163
|
+
});
|
|
164
|
+
const responseData = await response.json();
|
|
165
|
+
if (response.ok) {
|
|
166
|
+
console.log('✅ [NETFLIX_SERVICE] Successfully stored Netflix data');
|
|
167
|
+
if (responseData.message) {
|
|
168
|
+
console.log(`📝 [NETFLIX_SERVICE] Backend response: ${responseData.message}`);
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
success: true,
|
|
172
|
+
message: responseData.message || 'Netflix data stored successfully',
|
|
173
|
+
data: responseData.data
|
|
174
|
+
};
|
|
175
|
+
} else {
|
|
176
|
+
console.warn(`⚠️ [NETFLIX_SERVICE] Backend returned status: ${response.status}`);
|
|
177
|
+
console.warn(`⚠️ [NETFLIX_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
|
|
178
|
+
return {
|
|
179
|
+
success: false,
|
|
180
|
+
error: responseData.error || `HTTP ${response.status}`
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error('❌ [NETFLIX_SERVICE] Network error:', error);
|
|
185
|
+
return {
|
|
186
|
+
success: false,
|
|
187
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=netflixDataService.js.map
|
|
@@ -1,7 +1,75 @@
|
|
|
1
|
+
const CryptoJS = require('react-native-crypto-js');
|
|
2
|
+
import { getTemporaryPin } from './pinStorageUtils';
|
|
1
3
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
4
|
+
/**
|
|
5
|
+
* Service for encrypting PIN data before sending to APIs
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Encryption key - in production, this should come from a secure source
|
|
9
|
+
const ENCRYPTION_KEY = 'onairos-pin-encryption-key-2024';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Encrypt PIN using AES encryption
|
|
13
|
+
*/
|
|
14
|
+
export const encryptPin = pin => {
|
|
15
|
+
try {
|
|
16
|
+
const encrypted = CryptoJS.AES.encrypt(pin, ENCRYPTION_KEY).toString();
|
|
17
|
+
console.log('🔐 PIN encrypted successfully');
|
|
18
|
+
return encrypted;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('❌ Error encrypting PIN:', error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Decrypt PIN (for verification purposes)
|
|
27
|
+
*/
|
|
28
|
+
export const decryptPin = encryptedPin => {
|
|
29
|
+
try {
|
|
30
|
+
const decrypted = CryptoJS.AES.decrypt(encryptedPin, ENCRYPTION_KEY);
|
|
31
|
+
const pin = decrypted.toString(CryptoJS.enc.Utf8);
|
|
32
|
+
console.log('🔓 PIN decrypted successfully');
|
|
33
|
+
return pin;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('❌ Error decrypting PIN:', error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get encrypted PIN for API transmission
|
|
42
|
+
*/
|
|
43
|
+
export const getEncryptedPinForAPI = async () => {
|
|
44
|
+
try {
|
|
45
|
+
// Get the temporary PIN from memory
|
|
46
|
+
const pin = getTemporaryPin();
|
|
47
|
+
if (!pin) {
|
|
48
|
+
console.log('⚠️ No temporary PIN available for encryption');
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Encrypt the PIN
|
|
53
|
+
const encryptedPin = encryptPin(pin);
|
|
54
|
+
console.log('✅ PIN encrypted for API transmission');
|
|
55
|
+
return encryptedPin;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('❌ Error getting encrypted PIN for API:', error);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Hash PIN for verification (one-way hash)
|
|
64
|
+
*/
|
|
65
|
+
export const hashPin = pin => {
|
|
66
|
+
try {
|
|
67
|
+
const hash = CryptoJS.SHA256(pin + ENCRYPTION_KEY).toString();
|
|
68
|
+
console.log('🔒 PIN hashed successfully');
|
|
69
|
+
return hash;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('❌ Error hashing PIN:', error);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=pinEncryptionService.js.map
|