@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,8 +1,298 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function _0x1e89(){const _0x30133b=['defineProperty','__esModule','default','authenticatedRequest','apiPut','apiPost','apiGet','apiDelete','apiClient','ApiClient','API_CONFIG','BASE_URL','authTriggers','request','OnairosSDK/1.0.0','iYgtx','Request\x20cancelled','Unknown\x20error','set','log','\x20to:\x20','🎯\x20[API\x20Client]\x20Route\x20','\x20requires\x20','\x20token','getRequestHeaders','rBIds','requiresAuth','method','HYLRU','headers','signal','🔐\x20[API\x20Client]\x20Request\x20','\x20using\x20','rbSbB','baseUrl','\x20status:','status','qvlzf','handle401Error','json','delete','message','eGKLj','name','HfaVA','abort','🚫\x20[API\x20Client]\x20Request\x20','\x20was\x20cancelled','euYxJ','error','❌\x20[API\x20Client]\x20Request\x20','\x20failed:','TtfDM','getJWTForRoute','No\x20','.\x20Please\x20authenticate\x20first.','1|3|5|2|0|6|4','split','cancelRequestsForTokenType','🔄\x20[API\x20Client]\x20Clearing\x20','\x20token\x20due\x20to\x20401\x20error','.\x20Please\x20re-authenticate.','clearJWT','🔑\x20[API\x20Client]\x20','\x20token\x20cleared,\x20user\x20needs\x20to\x20re-authenticate','wCCzt','PuMvX','YdPPP','QymEE','🔑\x20[API\x20Client]\x20Triggering\x20Onairos\x20re-authentication','⚠️\x20[API\x20Client]\x20No\x20Onairos\x20re-auth\x20trigger\x20configured','hDCNN','🔄\x20[API\x20Client]\x20Triggering\x20re-auth\x20for\x20','\x20token\x20(endpoint:\x20','GYCWG','jmRPs','🚫\x20[API\x20Client]\x20Cancelled\x20','\x20requests\x20due\x20to\x20','\x20token\x20failure','TokenType','iEujO','Request\x20failed\x20with\x20status\x20','QtIZe','yUqxl','XVnqX','warn','yqiij','ONAIROS','hTyST','rbhyu','oaCau','apnRH','triggerOnairosReAuth','dGtij','triggerAuthTokenRefresh','XmlfD','⚠️\x20[API\x20Client]\x20No\x20auth\x20token\x20refresh\x20trigger\x20configured','❌\x20[API\x20Client]\x20Failed\x20to\x20trigger\x20re-auth\x20for\x20','QlYTn','ymNPq','lcTbI','tikot','yHuSC','Woerh','LiawH','sxhBs','ZXGfq','replaceTokenForType','🔄\x20[API\x20Client]\x20Replacing\x20','replaceJWTAfterVerification','✅\x20[API\x20Client]\x20','\x20token\x20replaced\x20and\x20related\x20requests\x20cancelled','debugTokens','wDaJc','eSKQR','RpocC','getAllTokens','entries','ymEfk','AlhKN','NXzFw','🔐\x20','substring','...\x20(length:\x20','length','NFZVY','📭\x20',':\x20null','setAuthTriggers','🔧\x20[API\x20Client]\x20Authentication\x20triggers\x20updated','get','bind','post','put'];_0x1e89=function(){return _0x30133b;};return _0x1e89();}function _0x51cb(_0x1e8910,_0x51cbea){_0x1e8910=_0x1e8910-0x0;const _0x5e0adc=_0x1e89();let _0x1ebca6=_0x5e0adc[_0x1e8910];return _0x1ebca6;}Object[_0x51cb(0x0)](exports,_0x51cb(0x1),{'value':!![]}),exports[_0x51cb(0x2)]=exports[_0x51cb(0x3)]=exports[_0x51cb(0x4)]=exports[_0x51cb(0x5)]=exports[_0x51cb(0x6)]=exports[_0x51cb(0x7)]=exports[_0x51cb(0x8)]=exports[_0x51cb(0x9)]=void 0x0;var _jwtStorageService=__ONAIROS_REQ_FUNC__(0x0),_api=__ONAIROS_REQ_FUNC__(0x1);let currentRequestId=0x0;const activeRequests=new Map();class ApiClient{constructor(_0x4aa5ac=_api[_0x51cb(0xa)][_0x51cb(0xb)],_0x107b7a={}){this['baseUrl']=_0x4aa5ac,this[_0x51cb(0xc)]=_0x107b7a;}async[_0x51cb(0xd)](_0x23f6b0,_0x405fba={}){const _0x4cae65={'rBIds':function(_0x4cd9e0,_0x57eb69){return _0x4cd9e0!==_0x57eb69;},'HYLRU':_0x51cb(0xe),'rbSbB':function(_0x3eea7b,_0x36a6cc,_0x4d84d3){return _0x3eea7b(_0x36a6cc,_0x4d84d3);},'qvlzf':function(_0x11085b,_0x38208e){return _0x11085b===_0x38208e;},'eGKLj':function(_0x5054dc,_0xb6cd0a){return _0x5054dc instanceof _0xb6cd0a;},'HfaVA':_0x51cb(0xf),'euYxJ':_0x51cb(0x10),'TtfDM':function(_0x877f9a,_0x18fc9b){return _0x877f9a instanceof _0x18fc9b;},'rJobq':_0x51cb(0x11)},_0x2372b5=++currentRequestId,_0xe9108f=new AbortController();activeRequests[_0x51cb(0x12)](_0x2372b5,_0xe9108f);try{console[_0x51cb(0x13)]('🔗\x20[API\x20Client]\x20Starting\x20request\x20'+_0x2372b5+_0x51cb(0x14)+_0x23f6b0);const _0xcef63b=(0x0,_jwtStorageService['getTokenTypeForRoute'])(_0x23f6b0);console[_0x51cb(0x13)](_0x51cb(0x15)+_0x23f6b0+_0x51cb(0x16)+_0xcef63b+_0x51cb(0x17));const _0x2307a5=await this[_0x51cb(0x18)](_0x23f6b0,_0x4cae65[_0x51cb(0x19)](_0x405fba[_0x51cb(0x1a)],![])),_0x3bff65={'method':_0x405fba[_0x51cb(0x1b)]||'GET','headers':{'Content-Type':'application/json','User-Agent':_0x4cae65[_0x51cb(0x1c)],..._0x2307a5,..._0x405fba[_0x51cb(0x1d)]},'body':_0x405fba['body']?JSON['stringify'](_0x405fba['body']):undefined,'signal':_0xe9108f[_0x51cb(0x1e)]};console[_0x51cb(0x13)](_0x51cb(0x1f)+_0x2372b5+_0x51cb(0x20)+_0xcef63b+'\x20token');const _0xc66e8f=await _0x4cae65[_0x51cb(0x21)](fetch,''+this[_0x51cb(0x22)]+_0x23f6b0,_0x3bff65);console[_0x51cb(0x13)]('📡\x20[API\x20Client]\x20Response\x20'+_0x2372b5+_0x51cb(0x23),_0xc66e8f[_0x51cb(0x24)]);if(_0x4cae65[_0x51cb(0x25)](_0xc66e8f[_0x51cb(0x24)],0x191))return await this[_0x51cb(0x26)](_0x2372b5,_0x23f6b0,_0xcef63b,_0x405fba);const _0x61cab5=await _0xc66e8f[_0x51cb(0x27)]();activeRequests[_0x51cb(0x28)](_0x2372b5);if(!_0xc66e8f['ok'])return{'success':![],'error':_0x61cab5[_0x51cb(0x29)]||'Request\x20failed\x20with\x20status\x20'+_0xc66e8f[_0x51cb(0x24)],'status':_0xc66e8f[_0x51cb(0x24)],'tokenType':_0xcef63b};return{'success':!![],'data':_0x61cab5,'status':_0xc66e8f[_0x51cb(0x24)],'tokenType':_0xcef63b};}catch(_0x37e786){activeRequests[_0x51cb(0x28)](_0x2372b5);if(_0x4cae65[_0x51cb(0x2a)](_0x37e786,Error)&&_0x4cae65[_0x51cb(0x25)](_0x37e786[_0x51cb(0x2b)],'AbortError')){if(_0x4cae65[_0x51cb(0x2c)]!==_0x4cae65[_0x51cb(0x2c)])_0x437a52[_0x51cb(0x2d)](),_0x252c1f[_0x51cb(0x28)](_0x6ef6f8),_0x497d5f++;else return console[_0x51cb(0x13)](_0x51cb(0x2e)+_0x2372b5+_0x51cb(0x2f)),{'success':![],'error':_0x4cae65[_0x51cb(0x30)],'status':0x0};}return console[_0x51cb(0x31)](_0x51cb(0x32)+_0x2372b5+_0x51cb(0x33),_0x37e786),{'success':![],'error':_0x4cae65[_0x51cb(0x34)](_0x37e786,Error)?_0x37e786[_0x51cb(0x29)]:_0x4cae65['rJobq'],'status':0x0};}}async[_0x51cb(0x18)](_0x206219,_0x4341a1){if(!_0x4341a1)return{};const _0x57ac2f=await(0x0,_jwtStorageService[_0x51cb(0x35)])(_0x206219);if(!_0x57ac2f){const _0x687941=(0x0,_jwtStorageService['getTokenTypeForRoute'])(_0x206219);throw new Error(_0x51cb(0x36)+_0x687941+'\x20token\x20available\x20for\x20route\x20'+_0x206219+_0x51cb(0x37));}return{'Authorization':_0x57ac2f};}async[_0x51cb(0x26)](_0x1962c6,_0x10a77a,_0x3327db,_0x56a566){const _0x526ca1=_0x51cb(0x38)[_0x51cb(0x39)]('|');let _0xed8e10=0x0;while(!![]){switch(_0x526ca1[_0xed8e10++]){case'0':await this['triggerReAuthForTokenType'](_0x3327db,_0x10a77a);continue;case'1':console[_0x51cb(0x31)](_0x51cb(0x2e)+_0x1962c6+'\x20received\x20401\x20for\x20'+_0x3327db+'\x20token\x20on\x20route:\x20'+_0x10a77a);continue;case'2':this[_0x51cb(0x3a)](_0x3327db,_0x1962c6);continue;case'3':console[_0x51cb(0x13)](_0x51cb(0x3b)+_0x3327db+_0x51cb(0x3c));continue;case'4':return{'success':![],'error':_0x3327db+'\x20authentication\x20expired\x20for\x20'+_0x10a77a+_0x51cb(0x3d),'status':0x191,'tokenType':_0x3327db};case'5':await(0x0,_jwtStorageService[_0x51cb(0x3e)])(_0x3327db);continue;case'6':console[_0x51cb(0x13)](_0x51cb(0x3f)+_0x3327db+_0x51cb(0x40));continue;}break;}}async['triggerReAuthForTokenType'](_0x286ad0,_0x167fb6){const _0x165a03={'yUqxl':function(_0x7ad3e1,_0x3cbc9b){return _0x7ad3e1!==_0x3cbc9b;},'jmRPs':function(_0x51332e,_0x15ecb9){return _0x51332e>_0x15ecb9;},'oaCau':_0x51cb(0x10),'yqiij':'⚠️\x20[API\x20Client]\x20No\x20Enoch\x20re-auth\x20trigger\x20configured','GYCWG':function(_0x2c1ea6,_0x2bf43e){return _0x2c1ea6===_0x2bf43e;},'zbQRR':_0x51cb(0x41),'NPuUX':_0x51cb(0x42),'iEujO':_0x51cb(0x43),'QtIZe':'📧\x20[API\x20Client]\x20Triggering\x20Enoch\x20email\x20re-verification','jmklo':'vJjtn','hTyST':_0x51cb(0x44),'rbhyu':'XSZNE','apnRH':_0x51cb(0x45),'dGtij':_0x51cb(0x46),'XmlfD':'🔄\x20[API\x20Client]\x20Triggering\x20auth\x20token\x20refresh','mnVAo':_0x51cb(0x47)};console[_0x51cb(0x13)](_0x51cb(0x48)+_0x286ad0+_0x51cb(0x49)+_0x167fb6+')');try{if(_0x165a03[_0x51cb(0x4a)](_0x165a03['zbQRR'],_0x165a03['NPuUX'])){let _0x2abcb6=0x0;for(const [_0x4f75ed,_0x38b8e6]of _0x2bb1bf['entries']()){_0x165a03['yUqxl'](_0x4f75ed,_0x15789a)&&(_0x38b8e6[_0x51cb(0x2d)](),_0x1e42c3[_0x51cb(0x28)](_0x4f75ed),_0x2abcb6++);}_0x165a03[_0x51cb(0x4b)](_0x2abcb6,0x0)&&_0x5e8780[_0x51cb(0x13)](_0x51cb(0x4c)+_0x2abcb6+_0x51cb(0x4d)+_0x46577b+_0x51cb(0x4e));}else switch(_0x286ad0){case _jwtStorageService[_0x51cb(0x4f)]['ENOCH']:if(this['authTriggers']['triggerEnochReAuth']){if(_0x165a03['yUqxl'](_0x51cb(0x43),_0x165a03[_0x51cb(0x50)]))return{'success':![],'error':_0x30e448['message']||_0x51cb(0x51)+_0x1d0fce[_0x51cb(0x24)],'status':_0x5c126d[_0x51cb(0x24)],'tokenType':_0x1d2007};else console[_0x51cb(0x13)](_0x165a03[_0x51cb(0x52)]),await this[_0x51cb(0xc)]['triggerEnochReAuth']();}else _0x165a03[_0x51cb(0x53)](_0x51cb(0x54),_0x165a03['jmklo'])?console[_0x51cb(0x55)](_0x165a03[_0x51cb(0x56)]):_0x273e47['log']('🚫\x20[API\x20Client]\x20Cancelled\x20'+_0x4ab695+_0x51cb(0x4d)+_0xd22eda+_0x51cb(0x4e));break;case _jwtStorageService[_0x51cb(0x4f)][_0x51cb(0x57)]:if(this[_0x51cb(0xc)]['triggerOnairosReAuth']){if(_0x165a03[_0x51cb(0x58)]===_0x165a03[_0x51cb(0x59)])return _0xce3923[_0x51cb(0x13)]('🚫\x20[API\x20Client]\x20Request\x20'+_0x2bbeb3+_0x51cb(0x2f)),{'success':![],'error':_0x165a03[_0x51cb(0x5a)],'status':0x0};else console[_0x51cb(0x13)](_0x165a03[_0x51cb(0x5b)]),await this[_0x51cb(0xc)][_0x51cb(0x5c)]();}else console['warn'](_0x165a03[_0x51cb(0x5d)]);break;case _jwtStorageService[_0x51cb(0x4f)]['AUTH']:this[_0x51cb(0xc)][_0x51cb(0x5e)]?(console[_0x51cb(0x13)](_0x165a03[_0x51cb(0x5f)]),await this[_0x51cb(0xc)][_0x51cb(0x5e)]()):console[_0x51cb(0x55)](_0x51cb(0x60));break;}}catch(_0x605015){_0x165a03['GYCWG']('nRpWg',_0x165a03['mnVAo'])?_0x20c756['warn'](_0x165a03[_0x51cb(0x56)]):console[_0x51cb(0x31)](_0x51cb(0x61)+_0x286ad0+':',_0x605015);}}[_0x51cb(0x3a)](_0x55eaba,_0x3d18ec){const _0x15ac41={'LiawH':_0x51cb(0x46),'tikot':function(_0x28fb2d,_0x2f81fe){return _0x28fb2d!==_0x2f81fe;},'yHuSC':function(_0x50ddd1,_0x23163f){return _0x50ddd1===_0x23163f;},'Woerh':_0x51cb(0x62),'sxhBs':_0x51cb(0x63),'ZXGfq':_0x51cb(0x64)};let _0x21ae63=0x0;for(const [_0x45b61c,_0x463923]of activeRequests['entries']()){_0x15ac41[_0x51cb(0x65)](_0x45b61c,_0x3d18ec)&&(_0x15ac41[_0x51cb(0x66)](_0x15ac41['Woerh'],_0x15ac41[_0x51cb(0x67)])?(_0x463923[_0x51cb(0x2d)](),activeRequests[_0x51cb(0x28)](_0x45b61c),_0x21ae63++):_0x40f3bc[_0x51cb(0x55)](_0x15ac41[_0x51cb(0x68)]));}if(_0x21ae63>0x0){if(_0x15ac41[_0x51cb(0x66)](_0x15ac41[_0x51cb(0x69)],_0x15ac41[_0x51cb(0x6a)]))return this[_0x51cb(0xd)](_0x42e7b8,{..._0x37d037,'method':'DELETE'});else console['log'](_0x51cb(0x4c)+_0x21ae63+_0x51cb(0x4d)+_0x55eaba+_0x51cb(0x4e));}}async[_0x51cb(0x6b)](_0xb990d3,_0x1d8444){console[_0x51cb(0x13)](_0x51cb(0x6c)+_0xb990d3+_0x51cb(0x17)),this[_0x51cb(0x3a)](_0xb990d3);const _0x1b5e60=await(0x0,_jwtStorageService[_0x51cb(0x6d)])(_0xb990d3,_0x1d8444);return _0x1b5e60&&console['log'](_0x51cb(0x6e)+_0xb990d3+_0x51cb(0x6f)),_0x1b5e60;}async[_0x51cb(0x70)](){const _0x450185={'RpocC':'🔍\x20[API\x20Client]\x20Debug:\x20Current\x20token\x20status','ymEfk':function(_0x1fc25e,_0x510bf6){return _0x1fc25e===_0x510bf6;},'AlhKN':_0x51cb(0x71),'NXzFw':_0x51cb(0x72),'iSqhU':'Ruzmc'};console[_0x51cb(0x13)](_0x450185[_0x51cb(0x73)]);const _0x4b8583=await(0x0,_jwtStorageService[_0x51cb(0x74)])();for(const [_0x3c1458,_0x4ff4a2]of Object[_0x51cb(0x75)](_0x4b8583)){_0x4ff4a2?_0x450185[_0x51cb(0x76)](_0x450185[_0x51cb(0x77)],_0x450185[_0x51cb(0x78)])?_0xfda4c9!==_0x34a34c&&(_0x294571['abort'](),_0x20ecef['delete'](_0xcc68d2),_0x4aeccb++):console[_0x51cb(0x13)](_0x51cb(0x79)+_0x3c1458+':\x20'+_0x4ff4a2[_0x51cb(0x7a)](0x0,0x14)+_0x51cb(0x7b)+_0x4ff4a2[_0x51cb(0x7c)]+')'):_0x450185['iSqhU']!==_0x51cb(0x7d)?console[_0x51cb(0x13)](_0x51cb(0x7e)+_0x3c1458+':\x20null'):_0x3f0636?_0x5ea8f6[_0x51cb(0x13)](_0x51cb(0x79)+_0x42a6b1+':\x20'+_0x4ed5d4['substring'](0x0,0x14)+_0x51cb(0x7b)+_0x1fac18[_0x51cb(0x7c)]+')'):_0x269a2e[_0x51cb(0x13)](_0x51cb(0x7e)+_0x2dd8b4+_0x51cb(0x7f));}return _0x4b8583;}[_0x51cb(0x80)](_0x386600){const _0x390b1a={'KdJYH':_0x51cb(0x81)};this[_0x51cb(0xc)]={...this[_0x51cb(0xc)],..._0x386600},console[_0x51cb(0x13)](_0x390b1a['KdJYH']);}async[_0x51cb(0x82)](_0x2f1527,_0x39b5e7={}){return this[_0x51cb(0xd)](_0x2f1527,{..._0x39b5e7,'method':'GET'});}async['post'](_0x270747,_0x2c2bce,_0x3fb597={}){return this['request'](_0x270747,{..._0x3fb597,'method':'POST','body':_0x2c2bce});}async['put'](_0x15ac91,_0x472591,_0x583406={}){return this['request'](_0x15ac91,{..._0x583406,'method':'PUT','body':_0x472591});}async['delete'](_0x4104ef,_0x133348={}){return this[_0x51cb(0xd)](_0x4104ef,{..._0x133348,'method':'DELETE'});}}exports['ApiClient']=ApiClient;const apiClient=exports['apiClient']=new ApiClient(),authenticatedRequest=exports['authenticatedRequest']=apiClient[_0x51cb(0xd)][_0x51cb(0x83)](apiClient),apiGet=exports[_0x51cb(0x6)]=apiClient['get'][_0x51cb(0x83)](apiClient),apiPost=exports[_0x51cb(0x5)]=apiClient[_0x51cb(0x84)][_0x51cb(0x83)](apiClient),apiPut=exports[_0x51cb(0x4)]=apiClient[_0x51cb(0x85)]['bind'](apiClient),apiDelete=exports[_0x51cb(0x7)]=apiClient[_0x51cb(0x28)][_0x51cb(0x83)](apiClient);var _default=exports[_0x51cb(0x2)]=apiClient;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.authenticatedRequest = exports.apiPut = exports.apiPost = exports.apiGet = exports.apiDelete = exports.apiClient = exports.ApiClient = void 0;
|
|
7
|
+
var _jwtStorageService = require("./jwtStorageService");
|
|
8
|
+
var _api = require("../config/api");
|
|
9
|
+
/**
|
|
10
|
+
* Centralized API Client with Route-Based JWT Token Management
|
|
11
|
+
* CORRECTED APPROACH: Uses different JWT tokens for different route families
|
|
12
|
+
*
|
|
13
|
+
* TOKEN ROUTING:
|
|
14
|
+
* - Enoch JWT: /enoch/*, /api/auth/*, /mobile-training/enoch
|
|
15
|
+
* - Onairos JWT: /youtube/*, /gmail/*, social connections
|
|
16
|
+
* - Auth Token: Context-specific auth flows
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Global request counter for tracking in-flight requests
|
|
21
|
+
*/
|
|
22
|
+
let currentRequestId = 0;
|
|
23
|
+
const activeRequests = new Map();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Route-specific authentication triggers
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create API client with route-based token management
|
|
31
|
+
*/
|
|
32
|
+
class ApiClient {
|
|
33
|
+
constructor(baseUrl = _api.API_CONFIG.BASE_URL, authTriggers = {}) {
|
|
34
|
+
this.baseUrl = baseUrl;
|
|
35
|
+
this.authTriggers = authTriggers;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Make authenticated API request with route-based token selection
|
|
40
|
+
* CRITICAL: Uses the correct token type based on route
|
|
41
|
+
*/
|
|
42
|
+
async request(endpoint, options = {}) {
|
|
43
|
+
const requestId = ++currentRequestId;
|
|
44
|
+
const abortController = new AbortController();
|
|
45
|
+
activeRequests.set(requestId, abortController);
|
|
46
|
+
try {
|
|
47
|
+
console.log(`🔗 [API Client] Starting request ${requestId} to: ${endpoint}`);
|
|
48
|
+
|
|
49
|
+
// CRITICAL FIX: Determine which token type to use based on route
|
|
50
|
+
const tokenType = (0, _jwtStorageService.getTokenTypeForRoute)(endpoint);
|
|
51
|
+
console.log(`🎯 [API Client] Route ${endpoint} requires ${tokenType} token`);
|
|
52
|
+
|
|
53
|
+
// Get route-specific headers
|
|
54
|
+
const headers = await this.getRequestHeaders(endpoint, options.requiresAuth !== false);
|
|
55
|
+
const fetchOptions = {
|
|
56
|
+
method: options.method || 'GET',
|
|
57
|
+
headers: {
|
|
58
|
+
'Content-Type': 'application/json',
|
|
59
|
+
'User-Agent': 'OnairosSDK/1.0.0',
|
|
60
|
+
...headers,
|
|
61
|
+
...options.headers
|
|
62
|
+
},
|
|
63
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
64
|
+
signal: abortController.signal
|
|
65
|
+
};
|
|
66
|
+
console.log(`🔐 [API Client] Request ${requestId} using ${tokenType} token`);
|
|
67
|
+
const response = await fetch(`${this.baseUrl}${endpoint}`, fetchOptions);
|
|
68
|
+
console.log(`📡 [API Client] Response ${requestId} status:`, response.status);
|
|
69
|
+
|
|
70
|
+
// CRITICAL FIX: Route-specific 401 handler
|
|
71
|
+
if (response.status === 401) {
|
|
72
|
+
return await this.handle401Error(requestId, endpoint, tokenType, options);
|
|
73
|
+
}
|
|
74
|
+
const result = await response.json();
|
|
75
|
+
activeRequests.delete(requestId);
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
return {
|
|
78
|
+
success: false,
|
|
79
|
+
error: result.message || `Request failed with status ${response.status}`,
|
|
80
|
+
status: response.status,
|
|
81
|
+
tokenType
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
success: true,
|
|
86
|
+
data: result,
|
|
87
|
+
status: response.status,
|
|
88
|
+
tokenType
|
|
89
|
+
};
|
|
90
|
+
} catch (error) {
|
|
91
|
+
activeRequests.delete(requestId);
|
|
92
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
93
|
+
console.log(`🚫 [API Client] Request ${requestId} was cancelled`);
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
error: 'Request cancelled',
|
|
97
|
+
status: 0
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
console.error(`❌ [API Client] Request ${requestId} failed:`, error);
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
104
|
+
status: 0
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get request headers with route-appropriate token
|
|
111
|
+
* CRITICAL: Selects correct token based on route
|
|
112
|
+
*/
|
|
113
|
+
async getRequestHeaders(endpoint, requiresAuth) {
|
|
114
|
+
if (!requiresAuth) {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// CRITICAL FIX: Get token specifically for this route
|
|
119
|
+
const token = await (0, _jwtStorageService.getJWTForRoute)(endpoint);
|
|
120
|
+
if (!token) {
|
|
121
|
+
const tokenType = (0, _jwtStorageService.getTokenTypeForRoute)(endpoint);
|
|
122
|
+
throw new Error(`No ${tokenType} token available for route ${endpoint}. Please authenticate first.`);
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
'Authorization': token
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Handle 401 errors with route-specific re-authentication
|
|
131
|
+
* CRITICAL FIX: Different auth flows for different token types
|
|
132
|
+
*/
|
|
133
|
+
async handle401Error(requestId, endpoint, tokenType, options) {
|
|
134
|
+
console.error(`🚫 [API Client] Request ${requestId} received 401 for ${tokenType} token on route: ${endpoint}`);
|
|
135
|
+
|
|
136
|
+
// CRITICAL FIX: Clear only the specific token type that failed
|
|
137
|
+
console.log(`🔄 [API Client] Clearing ${tokenType} token due to 401 error`);
|
|
138
|
+
await (0, _jwtStorageService.clearJWT)(tokenType);
|
|
139
|
+
|
|
140
|
+
// Cancel requests using the same token type
|
|
141
|
+
this.cancelRequestsForTokenType(tokenType, requestId);
|
|
142
|
+
|
|
143
|
+
// CRITICAL FIX: Route-specific re-authentication
|
|
144
|
+
await this.triggerReAuthForTokenType(tokenType, endpoint);
|
|
145
|
+
console.log(`🔑 [API Client] ${tokenType} token cleared, user needs to re-authenticate`);
|
|
146
|
+
return {
|
|
147
|
+
success: false,
|
|
148
|
+
error: `${tokenType} authentication expired for ${endpoint}. Please re-authenticate.`,
|
|
149
|
+
status: 401,
|
|
150
|
+
tokenType
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Trigger appropriate re-authentication based on token type
|
|
156
|
+
*/
|
|
157
|
+
async triggerReAuthForTokenType(tokenType, endpoint) {
|
|
158
|
+
console.log(`🔄 [API Client] Triggering re-auth for ${tokenType} token (endpoint: ${endpoint})`);
|
|
159
|
+
try {
|
|
160
|
+
switch (tokenType) {
|
|
161
|
+
case _jwtStorageService.TokenType.ENOCH:
|
|
162
|
+
if (this.authTriggers.triggerEnochReAuth) {
|
|
163
|
+
console.log('📧 [API Client] Triggering Enoch email re-verification');
|
|
164
|
+
await this.authTriggers.triggerEnochReAuth();
|
|
165
|
+
} else {
|
|
166
|
+
console.warn('⚠️ [API Client] No Enoch re-auth trigger configured');
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
case _jwtStorageService.TokenType.ONAIROS:
|
|
170
|
+
if (this.authTriggers.triggerOnairosReAuth) {
|
|
171
|
+
console.log('🔑 [API Client] Triggering Onairos re-authentication');
|
|
172
|
+
await this.authTriggers.triggerOnairosReAuth();
|
|
173
|
+
} else {
|
|
174
|
+
console.warn('⚠️ [API Client] No Onairos re-auth trigger configured');
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
case _jwtStorageService.TokenType.AUTH:
|
|
178
|
+
if (this.authTriggers.triggerAuthTokenRefresh) {
|
|
179
|
+
console.log('🔄 [API Client] Triggering auth token refresh');
|
|
180
|
+
await this.authTriggers.triggerAuthTokenRefresh();
|
|
181
|
+
} else {
|
|
182
|
+
console.warn('⚠️ [API Client] No auth token refresh trigger configured');
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
} catch (error) {
|
|
187
|
+
console.error(`❌ [API Client] Failed to trigger re-auth for ${tokenType}:`, error);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Cancel requests using a specific token type
|
|
193
|
+
*/
|
|
194
|
+
cancelRequestsForTokenType(tokenType, excludeRequestId) {
|
|
195
|
+
let cancelledCount = 0;
|
|
196
|
+
|
|
197
|
+
// Note: In a full implementation, we'd track which requests use which tokens
|
|
198
|
+
// For now, we cancel all other requests as a safety measure
|
|
199
|
+
for (const [requestId, controller] of activeRequests.entries()) {
|
|
200
|
+
if (requestId !== excludeRequestId) {
|
|
201
|
+
controller.abort();
|
|
202
|
+
activeRequests.delete(requestId);
|
|
203
|
+
cancelledCount++;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (cancelledCount > 0) {
|
|
207
|
+
console.log(`🚫 [API Client] Cancelled ${cancelledCount} requests due to ${tokenType} token failure`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Replace token for specific type and cancel related requests
|
|
213
|
+
*/
|
|
214
|
+
async replaceTokenForType(tokenType, newToken) {
|
|
215
|
+
console.log(`🔄 [API Client] Replacing ${tokenType} token`);
|
|
216
|
+
|
|
217
|
+
// Cancel all in-flight requests using this token type
|
|
218
|
+
this.cancelRequestsForTokenType(tokenType);
|
|
219
|
+
|
|
220
|
+
// Replace token using storage service
|
|
221
|
+
const replaced = await (0, _jwtStorageService.replaceJWTAfterVerification)(tokenType, newToken);
|
|
222
|
+
if (replaced) {
|
|
223
|
+
console.log(`✅ [API Client] ${tokenType} token replaced and related requests cancelled`);
|
|
224
|
+
}
|
|
225
|
+
return replaced;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Debug: Get all current tokens
|
|
230
|
+
*/
|
|
231
|
+
async debugTokens() {
|
|
232
|
+
console.log('🔍 [API Client] Debug: Current token status');
|
|
233
|
+
const tokens = await (0, _jwtStorageService.getAllTokens)();
|
|
234
|
+
for (const [tokenType, token] of Object.entries(tokens)) {
|
|
235
|
+
if (token) {
|
|
236
|
+
console.log(`🔐 ${tokenType}: ${token.substring(0, 20)}... (length: ${token.length})`);
|
|
237
|
+
} else {
|
|
238
|
+
console.log(`📭 ${tokenType}: null`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return tokens;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Set authentication triggers
|
|
246
|
+
*/
|
|
247
|
+
setAuthTriggers(triggers) {
|
|
248
|
+
this.authTriggers = {
|
|
249
|
+
...this.authTriggers,
|
|
250
|
+
...triggers
|
|
251
|
+
};
|
|
252
|
+
console.log('🔧 [API Client] Authentication triggers updated');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Convenience methods for common HTTP verbs
|
|
257
|
+
*/
|
|
258
|
+
async get(endpoint, options = {}) {
|
|
259
|
+
return this.request(endpoint, {
|
|
260
|
+
...options,
|
|
261
|
+
method: 'GET'
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
async post(endpoint, body, options = {}) {
|
|
265
|
+
return this.request(endpoint, {
|
|
266
|
+
...options,
|
|
267
|
+
method: 'POST',
|
|
268
|
+
body
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
async put(endpoint, body, options = {}) {
|
|
272
|
+
return this.request(endpoint, {
|
|
273
|
+
...options,
|
|
274
|
+
method: 'PUT',
|
|
275
|
+
body
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
async delete(endpoint, options = {}) {
|
|
279
|
+
return this.request(endpoint, {
|
|
280
|
+
...options,
|
|
281
|
+
method: 'DELETE'
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// SINGLE INSTANCE - Global API client
|
|
287
|
+
exports.ApiClient = ApiClient;
|
|
288
|
+
const apiClient = exports.apiClient = new ApiClient();
|
|
289
|
+
// Export convenience functions
|
|
290
|
+
const authenticatedRequest = exports.authenticatedRequest = apiClient.request.bind(apiClient);
|
|
291
|
+
const apiGet = exports.apiGet = apiClient.get.bind(apiClient);
|
|
292
|
+
const apiPost = exports.apiPost = apiClient.post.bind(apiClient);
|
|
293
|
+
const apiPut = exports.apiPut = apiClient.put.bind(apiClient);
|
|
294
|
+
const apiDelete = exports.apiDelete = apiClient.delete.bind(apiClient);
|
|
295
|
+
|
|
296
|
+
// Export types for external use
|
|
297
|
+
var _default = exports.default = apiClient;
|
|
298
|
+
//# sourceMappingURL=apiClient.js.map
|
|
@@ -1,8 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object[_0x4078(0x0)](exports,_0x4078(0x1),{'value':!![]}),exports['storePinWithBiometric']=exports['retrievePinWithBiometric']=exports[_0x4078(0x2)]=exports['isPinStored']=exports[_0x4078(0x3)]=exports['biometricPinService']=void 0x0;var Keychain=_interopRequireWildcard(__ONAIROS_REQ_FUNC__(0x0)),_reactNative=__ONAIROS_REQ_FUNC__(0x1);function _0x29ce(){const _0x7f550=['defineProperty','__esModule','removePinFromStorage','isBiometricAvailable','📱\x20Biometric\x20not\x20available','GdiiC','PSEBw','default','function','khcZa','EYnGj','LqQep','cAmJC','SJrSS','LCeCc','has','get','set','gwykb','hasOwnProperty','call','getOwnPropertyDescriptor','GZwuh','pEJUs','SRtJS','log','XTymQ','OnairosEventsPIN','WDVXB','JnvhM','Mdfta','SDMfx','BIOMETRY_TYPE','FACE_ID','TOUCH_ID','FACE','IRIS','ADlLP','VHKlU','error','ZbJRu','❌\x20Face\x20ID/Touch\x20ID\x20not\x20available\x20on\x20this\x20device','🔒\x20Face\x20ID\x20locked\x20out\x20-\x20too\x20many\x20failed\x20attempts','object','DQKRU','🔐\x20Starting\x20Face\x20ID\x20authentication\x20for\x20PIN\x20storage...','📱\x20Face\x20ID\x20available,\x20showing\x20authentication\x20prompt...','ios','Authenticate\x20with\x20Face\x20ID\x20to\x20secure\x20your\x20PIN','Cancel','android','Authenticate\x20with\x20biometric\x20to\x20secure\x20your\x20PIN','👤\x20Requesting\x20Face\x20ID\x20authentication...','❌\x20Error\x20details:','UserCancel','AuthenticationFailed','iQEJd','🚫\x20Face\x20ID\x20authentication\x20failed','FvzIL','kTnwA','zknBO','sBnoR','aAfBG','MOVZB','lZROv','BIOMETRY_CURRENT_SET','AUTHENTICATION_TYPE','BIOMETRICS','XmLBU','Platform','bHJrA','sBzqB','jASLS','dBbEd','setGenericPassword','✅\x20Face\x20ID\x20authentication\x20successful\x20-\x20PIN\x20stored\x20securely','DTkaE','myVqT','message','code','domain','userInfo','ywgzf','TrXwA','lgCgm','OtJfT','afFNR','gbdmP','includes','BiometryNotAvailable','kYWta','PACdP','CEQvz','aRmwY','📱\x20Face\x20ID/Touch\x20ID\x20not\x20available','eukjS','ajTtL','nvPgE','APTbz','CVlkO','htkMp','zjcEz','jcRiC','vwvtF','BvgZs','QRXnA','MXgjh','JaMYo','qqyEu','❌\x20Unknown\x20Face\x20ID\x20error:','storePinWithBiometric','❌\x20Error\x20removing\x20PIN\x20from\x20storage:','👤\x20User\x20cancelled\x20biometric\x20authentication','🔓\x20Retrieving\x20PIN\x20with\x20biometric\x20authentication...','✅\x20PIN\x20retrieved\x20successfully','qJLrx','rJLCD','TFoyW','kEHcn','SOABo','ZNmaF','wsqGT','qwdAx','⚠️\x20No\x20PIN\x20found\x20in\x20secure\x20storage','❌\x20Error\x20retrieving\x20PIN\x20with\x20biometric:','BfqTi','gvcdn','dTPhL','vKAus','JXPkW','gtfou','RUPDG','VkQqK','lJINq','TZzvi','yjqMj','thVfN','kGVnb','xhiaz','eNqZl','retrievePinWithBiometric','❌\x20Error\x20checking\x20PIN\x20storage:','isPinStored','🗑️\x20Removing\x20PIN\x20from\x20secure\x20storage...','resetGenericPassword','EpTQR','biometricPinService'];_0x29ce=function(){return _0x7f550;};return _0x29ce();}function _interopRequireWildcard(_0x28f8c7,_0x222b5b){const _0x5761fa={'gwykb':function(_0x3571a8,_0x49cfe2){return _0x3571a8===_0x49cfe2;},'joQkw':function(_0x562128,_0x520ff6){return _0x562128!=_0x520ff6;},'SJrSS':'object','GZwuh':function(_0x377cf2,_0x6fe37f,_0x145ece,_0x26f947){return _0x377cf2(_0x6fe37f,_0x145ece,_0x26f947);},'EYnGj':_0x4078(0x4),'sPTsd':function(_0x67e731,_0x477e40){return _0x67e731!==_0x477e40;},'LqQep':_0x4078(0x5),'cAmJC':_0x4078(0x6),'WSuWJ':function(_0x47447b,_0x4b3be8){return _0x47447b&&_0x4b3be8;},'pEJUs':function(_0xda0883,_0x58ad12){return _0xda0883!==_0x58ad12;},'SRtJS':_0x4078(0x7),'khcZa':_0x4078(0x8)};if(_0x5761fa[_0x4078(0x9)]==typeof WeakMap)var _0x557206=new WeakMap(),_0x5b6f2d=new WeakMap();return(_interopRequireWildcard=function(_0x18d8b3,_0x1d33a9){const _0xa79ccd={'XTymQ':_0x5761fa[_0x4078(0xa)]};if(_0x5761fa['sPTsd'](_0x5761fa[_0x4078(0xb)],_0x5761fa[_0x4078(0xc)])){if(_0x5761fa['WSuWJ'](!_0x1d33a9,_0x18d8b3)&&_0x18d8b3[_0x4078(0x1)])return _0x18d8b3;var _0x51648b,_0x46ef85,_0x52326e={'__proto__':null,'default':_0x18d8b3};if(null===_0x18d8b3||_0x5761fa['joQkw'](_0x5761fa[_0x4078(0xd)],typeof _0x18d8b3)&&'function'!=typeof _0x18d8b3)return _0x52326e;if(_0x51648b=_0x1d33a9?_0x5b6f2d:_0x557206){if(_0x4078(0xe)===_0x4078(0xe)){if(_0x51648b[_0x4078(0xf)](_0x18d8b3))return _0x51648b[_0x4078(0x10)](_0x18d8b3);_0x51648b[_0x4078(0x11)](_0x18d8b3,_0x52326e);}else{if(!_0x46387b&&_0x452ddd&&_0x59f687[_0x4078(0x1)])return _0x401c47;var _0x193d31,_0x1af30f,_0x4a9bef={'__proto__':null,'default':_0x30255b};if(_0x5761fa[_0x4078(0x12)](null,_0x1a599c)||_0x5761fa['joQkw'](_0x5761fa['SJrSS'],typeof _0x17ea0d)&&_0x4078(0x8)!=typeof _0x12a7bd)return _0x4a9bef;if(_0x193d31=_0x1c9be0?_0x590e63:_0x4c06e8){if(_0x193d31[_0x4078(0xf)](_0x180060))return _0x193d31['get'](_0x4329a8);_0x193d31['set'](_0x3f37bc,_0x4a9bef);}for(const _0x55deac in _0x494015)_0x4078(0x7)!==_0x55deac&&{}[_0x4078(0x13)][_0x4078(0x14)](_0xc1e66a,_0x55deac)&&((_0x1af30f=(_0x193d31=_0xbad19[_0x4078(0x0)])&&_0x489072[_0x4078(0x15)](_0x1618f4,_0x55deac))&&(_0x1af30f[_0x4078(0x10)]||_0x1af30f['set'])?_0x5761fa[_0x4078(0x16)](_0x193d31,_0x4a9bef,_0x55deac,_0x1af30f):_0x4a9bef[_0x55deac]=_0x3099b2[_0x55deac]);return _0x4a9bef;}}for(const _0x5cf503 in _0x18d8b3)_0x5761fa[_0x4078(0x17)](_0x5761fa[_0x4078(0x18)],_0x5cf503)&&{}[_0x4078(0x13)][_0x4078(0x14)](_0x18d8b3,_0x5cf503)&&((_0x46ef85=(_0x51648b=Object[_0x4078(0x0)])&&Object[_0x4078(0x15)](_0x18d8b3,_0x5cf503))&&(_0x46ef85[_0x4078(0x10)]||_0x46ef85[_0x4078(0x11)])?_0x5761fa[_0x4078(0x16)](_0x51648b,_0x52326e,_0x5cf503,_0x46ef85):_0x52326e[_0x5cf503]=_0x18d8b3[_0x5cf503]);return _0x52326e;}else return _0x1ee825[_0x4078(0x19)](_0xa79ccd[_0x4078(0x1a)]),null;})(_0x28f8c7,_0x222b5b);}const PIN_SERVICE_KEY=_0x4078(0x1b),PIN_USERNAME='user_pin',isBiometricAvailable=async()=>{const _0x2af520={'Mdfta':'📱\x20Biometric\x20support:','SDMfx':function(_0x445a00,_0x57b45c){return _0x445a00===_0x57b45c;},'VcTCV':function(_0x3dfc1e,_0x59c9d1){return _0x3dfc1e===_0x59c9d1;},'ADlLP':function(_0x1f2262,_0x528de5){return _0x1f2262!==_0x528de5;},'VHKlU':_0x4078(0x1c),'NVqcL':_0x4078(0x1d),'ZbJRu':'❌\x20Error\x20checking\x20biometric\x20availability:'};try{const _0x6b7f8a=await Keychain['getSupportedBiometryType']();return console[_0x4078(0x19)](_0x2af520[_0x4078(0x1e)],_0x6b7f8a),_0x2af520[_0x4078(0x1f)](_0x6b7f8a,Keychain[_0x4078(0x20)][_0x4078(0x21)])||_0x6b7f8a===Keychain['BIOMETRY_TYPE'][_0x4078(0x22)]||_0x2af520['VcTCV'](_0x6b7f8a,Keychain[_0x4078(0x20)]['FINGERPRINT'])||_0x2af520[_0x4078(0x1f)](_0x6b7f8a,Keychain[_0x4078(0x20)][_0x4078(0x23)])||_0x2af520[_0x4078(0x1f)](_0x6b7f8a,Keychain['BIOMETRY_TYPE'][_0x4078(0x24)]);}catch(_0x4bb930){return _0x2af520[_0x4078(0x25)](_0x2af520[_0x4078(0x26)],_0x2af520['NVqcL'])?(console[_0x4078(0x27)](_0x2af520[_0x4078(0x28)],_0x4bb930),![]):(_0x5a9e1b[_0x4078(0x27)](_0x4078(0x29)),![]);}};exports[_0x4078(0x3)]=isBiometricAvailable;const storePinWithBiometric=async _0x53593d=>{const _0x29a89a={'sBnoR':_0x4078(0x2a),'vwvtF':function(_0x56ca08,_0x1c871e){return _0x56ca08&&_0x1c871e;},'BvgZs':_0x4078(0x2b),'ElEiE':function(_0x5a01fa,_0x42cfc0){return _0x5a01fa!=_0x42cfc0;},'QRXnA':'function','MXgjh':function(_0x49dcfb,_0x3bd5b3){return _0x49dcfb!==_0x3bd5b3;},'JaMYo':'default','qqyEu':function(_0x5eaaf2,_0x50cbcd,_0x2fe792,_0x2ebc98){return _0x5eaaf2(_0x50cbcd,_0x2fe792,_0x2ebc98);},'jcRiC':function(_0x587197,_0x15e0ed){return _0x587197==_0x15e0ed;},'kTnwA':'xYdwo','zknBO':_0x4078(0x2c),'aAfBG':_0x4078(0x2d),'MOVZB':function(_0x3e2462){return _0x3e2462();},'VnWcj':_0x4078(0x29),'lZROv':_0x4078(0x2e),'XmLBU':function(_0x513396,_0x1dc18e){return _0x513396===_0x1dc18e;},'QBtys':_0x4078(0x2f),'oDSer':_0x4078(0x30),'bHJrA':_0x4078(0x31),'sBzqB':function(_0x4b2e9a,_0x1ac1ec){return _0x4b2e9a===_0x1ac1ec;},'jASLS':_0x4078(0x32),'FJKHb':_0x4078(0x33),'dBbEd':_0x4078(0x34),'DTkaE':'❌\x20Face\x20ID\x20authentication\x20failed:','myVqT':_0x4078(0x35),'ywgzf':function(_0x479bf6,_0x30917b){return _0x479bf6!==_0x30917b;},'TrXwA':function(_0x90281,_0x2691a4){return _0x90281!==_0x2691a4;},'lgCgm':_0x4078(0x36),'OtJfT':function(_0x5a8b3e,_0x49e1f7){return _0x5a8b3e===_0x49e1f7;},'afFNR':function(_0x5bf851,_0x1798bb){return _0x5bf851===_0x1798bb;},'gbdmP':function(_0x103390,_0x3d36e7){return _0x103390!==_0x3d36e7;},'WlJRF':'📱\x20Face\x20ID/Touch\x20ID\x20not\x20available','kYWta':function(_0x35f942,_0x30014b){return _0x35f942!==_0x30014b;},'ynBli':_0x4078(0x37),'PACdP':function(_0x566435,_0x1e4cd2){return _0x566435===_0x1e4cd2;},'CEQvz':_0x4078(0x38),'aRmwY':_0x4078(0x39),'eukjS':function(_0x3e15a4,_0x57d51b){return _0x3e15a4!==_0x57d51b;},'ajTtL':function(_0x4462a5,_0x4662f1){return _0x4462a5!==_0x4662f1;},'nvPgE':'BiometryLockout','APTbz':function(_0x16187f,_0x18a1ad){return _0x16187f===_0x18a1ad;},'CVlkO':function(_0x300972,_0x421bdf){return _0x300972===_0x421bdf;},'htkMp':function(_0x49df2f,_0x1b1222){return _0x49df2f===_0x1b1222;},'zjcEz':_0x4078(0x3a)};try{if(_0x29a89a[_0x4078(0x3b)]===_0x29a89a[_0x4078(0x3c)])return _0x585edb[_0x4078(0x19)](_0x29a89a[_0x4078(0x3d)]),![];else{console['log'](_0x29a89a[_0x4078(0x3e)]);const _0x413a8b=await _0x29a89a[_0x4078(0x3f)](isBiometricAvailable);if(!_0x413a8b)return console['error'](_0x29a89a['VnWcj']),![];console[_0x4078(0x19)](_0x29a89a[_0x4078(0x40)]);const _0x252858={'accessControl':Keychain['ACCESS_CONTROL'][_0x4078(0x41)],'authenticationType':Keychain[_0x4078(0x42)][_0x4078(0x43)],'touchID':!![],'showModal':!![],'kLocalizedFallbackTitle':'',..._0x29a89a[_0x4078(0x44)](_reactNative[_0x4078(0x45)]['OS'],_0x29a89a['QBtys'])&&{'localizedPrompt':_0x29a89a['oDSer'],'localizedCancel':_0x29a89a[_0x4078(0x46)]},..._0x29a89a[_0x4078(0x47)](_reactNative[_0x4078(0x45)]['OS'],_0x29a89a[_0x4078(0x48)])&&{'promptMessage':_0x29a89a['FJKHb'],'cancelButtonText':_0x29a89a[_0x4078(0x46)]}};console[_0x4078(0x19)](_0x29a89a[_0x4078(0x49)]);const _0xfaae6a=await Keychain[_0x4078(0x4a)](PIN_USERNAME,_0x53593d,{'service':PIN_SERVICE_KEY,..._0x252858});return console[_0x4078(0x19)](_0x4078(0x4b)),console[_0x4078(0x19)]('🔍\x20Keychain\x20storage\x20result:',_0xfaae6a),!![];}}catch(_0xcc96fa){var _0x11a42d,_0x566786,_0x1293bb,_0x4aff35;console[_0x4078(0x27)](_0x29a89a[_0x4078(0x4c)],_0xcc96fa),console['error'](_0x29a89a[_0x4078(0x4d)],{'message':_0xcc96fa[_0x4078(0x4e)],'code':_0xcc96fa[_0x4078(0x4f)],'domain':_0xcc96fa[_0x4078(0x50)],'userInfo':_0xcc96fa[_0x4078(0x51)]});if(_0x29a89a[_0x4078(0x52)](_0xcc96fa,null)&&_0x29a89a['TrXwA'](_0xcc96fa,void 0x0)&&_0x29a89a[_0x4078(0x53)](_0x11a42d=_0xcc96fa[_0x4078(0x4e)],null)&&_0x29a89a[_0x4078(0x53)](_0x11a42d,void 0x0)&&_0x11a42d['includes'](_0x29a89a[_0x4078(0x54)])||(_0x29a89a[_0x4078(0x55)](_0xcc96fa,null)||_0x29a89a[_0x4078(0x56)](_0xcc96fa,void 0x0)?void 0x0:_0xcc96fa[_0x4078(0x4f)])===-0x80)return console[_0x4078(0x19)]('👤\x20User\x20cancelled\x20Face\x20ID\x20authentication'),![];else{if(_0x29a89a[_0x4078(0x52)](_0xcc96fa,null)&&_0x29a89a[_0x4078(0x57)](_0xcc96fa,void 0x0)&&(_0x566786=_0xcc96fa[_0x4078(0x4e)])!==null&&_0x566786!==void 0x0&&_0x566786[_0x4078(0x58)](_0x4078(0x59))||(_0xcc96fa===null||_0xcc96fa===void 0x0?void 0x0:_0xcc96fa[_0x4078(0x4f)])===-0x6)return console[_0x4078(0x19)](_0x29a89a['WlJRF']),![];else{if(_0x29a89a[_0x4078(0x5a)](_0xcc96fa,null)&&_0xcc96fa!==void 0x0&&_0x29a89a[_0x4078(0x53)](_0x1293bb=_0xcc96fa[_0x4078(0x4e)],null)&&_0x29a89a[_0x4078(0x53)](_0x1293bb,void 0x0)&&_0x1293bb['includes'](_0x29a89a['ynBli'])||(_0xcc96fa===null||_0x29a89a[_0x4078(0x5b)](_0xcc96fa,void 0x0)?void 0x0:_0xcc96fa[_0x4078(0x4f)])===-0x1)return _0x29a89a[_0x4078(0x5c)]===_0x29a89a[_0x4078(0x5c)]?(console[_0x4078(0x19)](_0x29a89a[_0x4078(0x5d)]),![]):(_0x143701[_0x4078(0x19)](_0x4078(0x5e)),![]);else{if(_0x29a89a[_0x4078(0x5f)](_0xcc96fa,null)&&_0x29a89a[_0x4078(0x5f)](_0xcc96fa,void 0x0)&&(_0x4aff35=_0xcc96fa['message'])!==null&&_0x29a89a[_0x4078(0x60)](_0x4aff35,void 0x0)&&_0x4aff35[_0x4078(0x58)](_0x29a89a[_0x4078(0x61)])||_0x29a89a[_0x4078(0x62)](_0x29a89a[_0x4078(0x63)](_0xcc96fa,null)||_0xcc96fa===void 0x0?void 0x0:_0xcc96fa['code'],-0x8)){if(_0x29a89a[_0x4078(0x64)](_0x29a89a[_0x4078(0x65)],_0x29a89a[_0x4078(0x65)]))return console[_0x4078(0x19)](_0x29a89a['sBnoR']),![];else{if(_0x29a89a[_0x4078(0x66)](_0x4078(0x8),typeof _0x5064e6))var _0x284b6c=new _0x3b049d(),_0x5eb436=new _0xff11fb();return(_0x46ad19=function(_0x49488e,_0x322c58){if(_0x29a89a[_0x4078(0x67)](!_0x322c58,_0x49488e)&&_0x49488e['__esModule'])return _0x49488e;var _0x39fec2,_0x145378,_0x244b04={'__proto__':null,'default':_0x49488e};if(null===_0x49488e||_0x29a89a[_0x4078(0x68)]!=typeof _0x49488e&&_0x29a89a['ElEiE'](_0x29a89a[_0x4078(0x69)],typeof _0x49488e))return _0x244b04;if(_0x39fec2=_0x322c58?_0x5eb436:_0x284b6c){if(_0x39fec2['has'](_0x49488e))return _0x39fec2[_0x4078(0x10)](_0x49488e);_0x39fec2[_0x4078(0x11)](_0x49488e,_0x244b04);}for(const _0xa62145 in _0x49488e)_0x29a89a[_0x4078(0x6a)](_0x29a89a[_0x4078(0x6b)],_0xa62145)&&{}[_0x4078(0x13)][_0x4078(0x14)](_0x49488e,_0xa62145)&&((_0x145378=(_0x39fec2=_0x45164e[_0x4078(0x0)])&&_0x27bbf0[_0x4078(0x15)](_0x49488e,_0xa62145))&&(_0x145378[_0x4078(0x10)]||_0x145378['set'])?_0x29a89a[_0x4078(0x6c)](_0x39fec2,_0x244b04,_0xa62145,_0x145378):_0x244b04[_0xa62145]=_0x49488e[_0xa62145]);return _0x244b04;})(_0x2d964e,_0x345c4c);}}}}}return console[_0x4078(0x27)](_0x4078(0x6d),_0xcc96fa[_0x4078(0x4e)]),![];}};exports[_0x4078(0x6e)]=storePinWithBiometric;const retrievePinWithBiometric=async()=>{const _0x3cde52={'wsqGT':_0x4078(0x6f),'BfqTi':function(_0x287f3a,_0x15922d){return _0x287f3a!==_0x15922d;},'gvcdn':function(_0x1ce86a,_0x7868af){return _0x1ce86a!==_0x7868af;},'dTPhL':function(_0x2baccb,_0x3a9d02){return _0x2baccb!==_0x3a9d02;},'vKAus':_0x4078(0x36),'Puqyg':function(_0x3ee20a,_0x22ba66){return _0x3ee20a!==_0x22ba66;},'JXPkW':function(_0x4d82cf,_0x617698){return _0x4d82cf!==_0x617698;},'gtfou':'BiometryNotAvailable','RUPDG':_0x4078(0x4),'thVfN':_0x4078(0x70),'eNqZl':_0x4078(0x39),'FmZTy':_0x4078(0x71),'SOABo':'SLddm','ZNmaF':_0x4078(0x72),'qwdAx':_0x4078(0x73),'VkQqK':_0x4078(0x74),'fjOdC':'❌\x20Error\x20retrieving\x20PIN\x20with\x20biometric:','FfGMg':function(_0x52e947,_0x509524){return _0x52e947!==_0x509524;},'lJINq':function(_0x4f3913,_0x201f59){return _0x4f3913!==_0x201f59;},'TZzvi':'tGkbe','yjqMj':'fNruV','kGVnb':function(_0x561c5c,_0x2c54d3){return _0x561c5c!==_0x2c54d3;},'xhiaz':_0x4078(0x75),'qZXgt':_0x4078(0x76)};try{console[_0x4078(0x19)](_0x3cde52['FmZTy']);const _0x19ffdb=await Keychain['getGenericPassword']({'service':PIN_SERVICE_KEY});if(_0x19ffdb&&_0x19ffdb['password'])return _0x3cde52['JXPkW'](_0x3cde52[_0x4078(0x77)],'GvlhC')?(console['log'](_0x3cde52[_0x4078(0x78)]),_0x19ffdb['password']):(_0x3fc94e[_0x4078(0x27)](_0x3cde52[_0x4078(0x79)],_0x1e5c58),![]);else{if(_0x3cde52[_0x4078(0x7a)]===_0x3cde52[_0x4078(0x7a)])return console['log'](_0x4078(0x7b)),null;else{var _0x2f69bb,_0x4fb0c6;_0x51125e[_0x4078(0x27)](_0x4078(0x7c),_0x21d7c7);if(_0x3cde52[_0x4078(0x7d)](_0x500119,null)&&_0x3cde52[_0x4078(0x7e)](_0x4210a4,void 0x0)&&_0x3cde52[_0x4078(0x7f)](_0x2f69bb=_0x41879d['message'],null)&&_0x3cde52[_0x4078(0x7e)](_0x2f69bb,void 0x0)&&_0x2f69bb['includes'](_0x3cde52[_0x4078(0x80)]))return _0x4b9e92['log'](_0x4078(0x70)),null;else{if(_0x3cde52[_0x4078(0x7f)](_0x80bb15,null)&&_0x3cde52['Puqyg'](_0x17c5f3,void 0x0)&&_0x3cde52[_0x4078(0x7f)](_0x4fb0c6=_0x15b8f9['message'],null)&&_0x3cde52[_0x4078(0x81)](_0x4fb0c6,void 0x0)&&_0x4fb0c6[_0x4078(0x58)](_0x3cde52[_0x4078(0x82)]))return _0x47f7d2['log'](_0x3cde52[_0x4078(0x83)]),null;}return null;}}}catch(_0x3d044e){if(_0x3cde52[_0x4078(0x84)]!=='CFWya'){var _0xc14161,_0x36375e;console[_0x4078(0x27)](_0x3cde52['fjOdC'],_0x3d044e);if(_0x3d044e!==null&&_0x3cde52[_0x4078(0x7d)](_0x3d044e,void 0x0)&&_0x3cde52['FfGMg'](_0xc14161=_0x3d044e['message'],null)&&_0x3cde52[_0x4078(0x85)](_0xc14161,void 0x0)&&_0xc14161[_0x4078(0x58)](_0x3cde52[_0x4078(0x80)])){if(_0x3cde52['lJINq'](_0x3cde52[_0x4078(0x86)],_0x3cde52[_0x4078(0x87)]))return console[_0x4078(0x19)](_0x3cde52[_0x4078(0x88)]),null;else{if(_0x13b019[_0x4078(0xf)](_0x51abb2))return _0x51c637['get'](_0x1497aa);_0x5c9994[_0x4078(0x11)](_0x56cd5c,_0x5dd160);}}else{if(_0x3cde52[_0x4078(0x81)](_0x3d044e,null)&&_0x3cde52['lJINq'](_0x3d044e,void 0x0)&&_0x3cde52[_0x4078(0x81)](_0x36375e=_0x3d044e[_0x4078(0x4e)],null)&&_0x3cde52[_0x4078(0x89)](_0x36375e,void 0x0)&&_0x36375e[_0x4078(0x58)](_0x3cde52[_0x4078(0x82)]))return _0x3cde52[_0x4078(0x7d)](_0x3cde52[_0x4078(0x8a)],_0x3cde52['qZXgt'])?(console[_0x4078(0x19)](_0x3cde52['RUPDG']),null):(_0x57bce3['log'](_0x3cde52['thVfN']),null);}return null;}else return _0x2de2eb[_0x4078(0x19)](_0x3cde52[_0x4078(0x8b)]),![];}};exports[_0x4078(0x8c)]=retrievePinWithBiometric;const isPinStored=async()=>{const _0x41ad74={'ZvMkj':_0x4078(0x8d)};try{const _0x507c4a=await Keychain['getGenericPassword']({'service':PIN_SERVICE_KEY});return!!(_0x507c4a&&_0x507c4a['password']);}catch(_0x510364){return console[_0x4078(0x27)](_0x41ad74['ZvMkj'],_0x510364),![];}};exports[_0x4078(0x8e)]=isPinStored;function _0x4078(_0x29ce19,_0x4078c1){_0x29ce19=_0x29ce19-0x0;const _0x15e747=_0x29ce();let _0x431a50=_0x15e747[_0x29ce19];return _0x431a50;}const removePinFromStorage=async()=>{const _0x42b0f2={'lwujr':'✅\x20PIN\x20removed\x20successfully','EpTQR':_0x4078(0x6f)};try{return console[_0x4078(0x19)](_0x4078(0x8f)),await Keychain[_0x4078(0x90)]({'service':PIN_SERVICE_KEY}),console[_0x4078(0x19)](_0x42b0f2['lwujr']),!![];}catch(_0x2d480b){return console['error'](_0x42b0f2[_0x4078(0x91)],_0x2d480b),![];}};exports['removePinFromStorage']=removePinFromStorage;const biometricPinService=exports[_0x4078(0x92)]={'storePinWithBiometric':storePinWithBiometric,'retrievePinWithBiometric':retrievePinWithBiometric,'isPinStored':isPinStored,'removePinFromStorage':removePinFromStorage,'isBiometricAvailable':isBiometricAvailable};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.storePinWithBiometric = exports.retrievePinWithBiometric = exports.removePinFromStorage = exports.isPinStored = exports.isBiometricAvailable = exports.biometricPinService = void 0;
|
|
7
|
+
var Keychain = _interopRequireWildcard(require("react-native-keychain"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
|
+
// Service key for PIN storage
|
|
11
|
+
const PIN_SERVICE_KEY = 'OnairosEventsPIN';
|
|
12
|
+
const PIN_USERNAME = 'user_pin';
|
|
13
|
+
/**
|
|
14
|
+
* Check if biometric authentication is available on the device
|
|
15
|
+
*/
|
|
16
|
+
const isBiometricAvailable = async () => {
|
|
17
|
+
try {
|
|
18
|
+
const biometryType = await Keychain.getSupportedBiometryType();
|
|
19
|
+
console.log('📱 Biometric support:', biometryType);
|
|
20
|
+
|
|
21
|
+
// Check for Face ID on iOS or any biometric on Android
|
|
22
|
+
return biometryType === Keychain.BIOMETRY_TYPE.FACE_ID || biometryType === Keychain.BIOMETRY_TYPE.TOUCH_ID || biometryType === Keychain.BIOMETRY_TYPE.FINGERPRINT || biometryType === Keychain.BIOMETRY_TYPE.FACE || biometryType === Keychain.BIOMETRY_TYPE.IRIS;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('❌ Error checking biometric availability:', error);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Store PIN with biometric authentication
|
|
31
|
+
*/
|
|
32
|
+
exports.isBiometricAvailable = isBiometricAvailable;
|
|
33
|
+
const storePinWithBiometric = async pin => {
|
|
34
|
+
try {
|
|
35
|
+
console.log('🔐 Starting Face ID authentication for PIN storage...');
|
|
36
|
+
|
|
37
|
+
// Check if biometric is available - REQUIRED for this implementation
|
|
38
|
+
const biometricAvailable = await isBiometricAvailable();
|
|
39
|
+
if (!biometricAvailable) {
|
|
40
|
+
console.error('❌ Face ID/Touch ID not available on this device');
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
console.log('📱 Face ID available, showing authentication prompt...');
|
|
44
|
+
|
|
45
|
+
// Configure keychain options for MANDATORY biometric authentication
|
|
46
|
+
const keychainOptions = {
|
|
47
|
+
accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET,
|
|
48
|
+
authenticationType: Keychain.AUTHENTICATION_TYPE.BIOMETRICS,
|
|
49
|
+
touchID: true,
|
|
50
|
+
showModal: true,
|
|
51
|
+
kLocalizedFallbackTitle: '',
|
|
52
|
+
// Disable fallback to prevent passcode option
|
|
53
|
+
// Add explicit prompts for better UX
|
|
54
|
+
...(_reactNative.Platform.OS === 'ios' && {
|
|
55
|
+
localizedPrompt: 'Authenticate with Face ID to secure your PIN',
|
|
56
|
+
localizedCancel: 'Cancel'
|
|
57
|
+
}),
|
|
58
|
+
...(_reactNative.Platform.OS === 'android' && {
|
|
59
|
+
promptMessage: 'Authenticate with biometric to secure your PIN',
|
|
60
|
+
cancelButtonText: 'Cancel'
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Store the PIN - this will trigger the Face ID prompt
|
|
65
|
+
console.log('👤 Requesting Face ID authentication...');
|
|
66
|
+
const result = await Keychain.setGenericPassword(PIN_USERNAME, pin, {
|
|
67
|
+
service: PIN_SERVICE_KEY,
|
|
68
|
+
...keychainOptions
|
|
69
|
+
});
|
|
70
|
+
console.log('✅ Face ID authentication successful - PIN stored securely');
|
|
71
|
+
console.log('🔍 Keychain storage result:', result);
|
|
72
|
+
return true;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
var _error$message, _error$message2, _error$message3, _error$message4;
|
|
75
|
+
console.error('❌ Face ID authentication failed:', error);
|
|
76
|
+
console.error('❌ Error details:', {
|
|
77
|
+
message: error.message,
|
|
78
|
+
code: error.code,
|
|
79
|
+
domain: error.domain,
|
|
80
|
+
userInfo: error.userInfo
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Handle specific error cases
|
|
84
|
+
if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes('UserCancel') || (error === null || error === void 0 ? void 0 : error.code) === -128) {
|
|
85
|
+
console.log('👤 User cancelled Face ID authentication');
|
|
86
|
+
return false;
|
|
87
|
+
} else if (error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes('BiometryNotAvailable') || (error === null || error === void 0 ? void 0 : error.code) === -6) {
|
|
88
|
+
console.log('📱 Face ID/Touch ID not available');
|
|
89
|
+
return false;
|
|
90
|
+
} else if (error !== null && error !== void 0 && (_error$message3 = error.message) !== null && _error$message3 !== void 0 && _error$message3.includes('AuthenticationFailed') || (error === null || error === void 0 ? void 0 : error.code) === -1) {
|
|
91
|
+
console.log('🚫 Face ID authentication failed');
|
|
92
|
+
return false;
|
|
93
|
+
} else if (error !== null && error !== void 0 && (_error$message4 = error.message) !== null && _error$message4 !== void 0 && _error$message4.includes('BiometryLockout') || (error === null || error === void 0 ? void 0 : error.code) === -8) {
|
|
94
|
+
console.log('🔒 Face ID locked out - too many failed attempts');
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
console.error('❌ Unknown Face ID error:', error.message);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Retrieve PIN with biometric authentication
|
|
104
|
+
*/
|
|
105
|
+
exports.storePinWithBiometric = storePinWithBiometric;
|
|
106
|
+
const retrievePinWithBiometric = async () => {
|
|
107
|
+
try {
|
|
108
|
+
console.log('🔓 Retrieving PIN with biometric authentication...');
|
|
109
|
+
|
|
110
|
+
// Retrieve the PIN (will prompt for biometric if configured)
|
|
111
|
+
const credentials = await Keychain.getGenericPassword({
|
|
112
|
+
service: PIN_SERVICE_KEY
|
|
113
|
+
});
|
|
114
|
+
if (credentials && credentials.password) {
|
|
115
|
+
console.log('✅ PIN retrieved successfully');
|
|
116
|
+
return credentials.password;
|
|
117
|
+
} else {
|
|
118
|
+
console.log('⚠️ No PIN found in secure storage');
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
} catch (error) {
|
|
122
|
+
var _error$message5, _error$message6;
|
|
123
|
+
console.error('❌ Error retrieving PIN with biometric:', error);
|
|
124
|
+
|
|
125
|
+
// Handle specific error cases
|
|
126
|
+
if (error !== null && error !== void 0 && (_error$message5 = error.message) !== null && _error$message5 !== void 0 && _error$message5.includes('UserCancel')) {
|
|
127
|
+
console.log('👤 User cancelled biometric authentication');
|
|
128
|
+
return null;
|
|
129
|
+
} else if (error !== null && error !== void 0 && (_error$message6 = error.message) !== null && _error$message6 !== void 0 && _error$message6.includes('BiometryNotAvailable')) {
|
|
130
|
+
console.log('📱 Biometric not available');
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Check if PIN is stored in secure storage
|
|
139
|
+
*/
|
|
140
|
+
exports.retrievePinWithBiometric = retrievePinWithBiometric;
|
|
141
|
+
const isPinStored = async () => {
|
|
142
|
+
try {
|
|
143
|
+
const credentials = await Keychain.getGenericPassword({
|
|
144
|
+
service: PIN_SERVICE_KEY
|
|
145
|
+
});
|
|
146
|
+
return !!(credentials && credentials.password);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error('❌ Error checking PIN storage:', error);
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Remove PIN from secure storage
|
|
155
|
+
*/
|
|
156
|
+
exports.isPinStored = isPinStored;
|
|
157
|
+
const removePinFromStorage = async () => {
|
|
158
|
+
try {
|
|
159
|
+
console.log('🗑️ Removing PIN from secure storage...');
|
|
160
|
+
await Keychain.resetGenericPassword({
|
|
161
|
+
service: PIN_SERVICE_KEY
|
|
162
|
+
});
|
|
163
|
+
console.log('✅ PIN removed successfully');
|
|
164
|
+
return true;
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error('❌ Error removing PIN from storage:', error);
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// Export the service object
|
|
172
|
+
exports.removePinFromStorage = removePinFromStorage;
|
|
173
|
+
const biometricPinService = exports.biometricPinService = {
|
|
174
|
+
storePinWithBiometric,
|
|
175
|
+
retrievePinWithBiometric,
|
|
176
|
+
isPinStored,
|
|
177
|
+
removePinFromStorage,
|
|
178
|
+
isBiometricAvailable
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=biometricPinService.js.map
|