@onairos/react-native 3.7.2 → 3.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +120 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +113 -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,9 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startOnairosFlow = exports.executeOnairosFlow = void 0;
|
|
7
|
+
var _platformAuthService = require("../services/platformAuthService");
|
|
8
|
+
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); } /**
|
|
9
|
+
* Programmatic Onairos Flow
|
|
10
|
+
*
|
|
11
|
+
* This function executes the complete Onairos authentication and onboarding flow
|
|
12
|
+
* that can be attached to custom buttons or called programmatically.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Execute the complete Onairos flow programmatically
|
|
16
|
+
* This is the same logic that the OnairosButton uses internally
|
|
17
|
+
*
|
|
18
|
+
* @param options Configuration options for the flow
|
|
19
|
+
* @returns Promise that resolves when flow is complete
|
|
20
|
+
*/
|
|
21
|
+
const executeOnairosFlow = async options => {
|
|
22
|
+
try {
|
|
23
|
+
console.log('🚀 Starting Onairos flow programmatically...');
|
|
24
|
+
|
|
25
|
+
// Initialize API key service if not already initialized
|
|
26
|
+
await (0, _platformAuthService.initializePlatformAuthService)();
|
|
27
|
+
|
|
28
|
+
// Import components dynamically to avoid circular dependencies
|
|
29
|
+
const {
|
|
30
|
+
UniversalOnboarding
|
|
31
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('../components/UniversalOnboarding')));
|
|
32
|
+
const React = await Promise.resolve().then(() => _interopRequireWildcard(require('react')));
|
|
33
|
+
|
|
34
|
+
// Create a promise that resolves when the flow is complete
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
let modalRef = null;
|
|
37
|
+
const handleComplete = (apiUrl, token, userData) => {
|
|
38
|
+
console.log('✅ Onairos flow completed successfully');
|
|
39
|
+
|
|
40
|
+
// Clean up modal
|
|
41
|
+
if (modalRef && modalRef.close) {
|
|
42
|
+
modalRef.close();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Call user's onResolved callback
|
|
46
|
+
if (options.onResolved) {
|
|
47
|
+
options.onResolved(apiUrl, token, userData);
|
|
48
|
+
}
|
|
49
|
+
resolve();
|
|
50
|
+
};
|
|
51
|
+
const handleRejection = error => {
|
|
52
|
+
console.log('❌ Onairos flow rejected:', error);
|
|
53
|
+
|
|
54
|
+
// Clean up modal
|
|
55
|
+
if (modalRef && modalRef.close) {
|
|
56
|
+
modalRef.close();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Call user's onRejection callback
|
|
60
|
+
if (options.onRejection) {
|
|
61
|
+
options.onRejection(error);
|
|
62
|
+
}
|
|
63
|
+
reject(new Error(error || 'Onairos flow was rejected'));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Create and show the Universal Onboarding modal
|
|
67
|
+
const modalElement = React.createElement(UniversalOnboarding, {
|
|
68
|
+
visible: true,
|
|
69
|
+
onClose: () => handleRejection('User closed the modal'),
|
|
70
|
+
AppName: options.AppName,
|
|
71
|
+
requestData: options.requestData,
|
|
72
|
+
returnLink: options.returnLink,
|
|
73
|
+
onComplete: handleComplete,
|
|
74
|
+
preferredPlatform: options.preferredPlatform,
|
|
75
|
+
debug: options.debug,
|
|
76
|
+
testMode: options.testMode
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Store modal reference for cleanup
|
|
80
|
+
modalRef = modalElement;
|
|
81
|
+
|
|
82
|
+
// Note: In a real implementation, you'd need to render this modal
|
|
83
|
+
// This is a simplified version - the actual implementation would
|
|
84
|
+
// need to handle React rendering in the current app context
|
|
85
|
+
console.log('📱 Onairos modal should be displayed');
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error('❌ Failed to execute Onairos flow:', error);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Simple wrapper function that matches the OnairosButton click behavior
|
|
95
|
+
*
|
|
96
|
+
* @param options Configuration options for the flow
|
|
97
|
+
* @returns Promise that resolves when flow is complete
|
|
98
|
+
*/
|
|
99
|
+
exports.executeOnairosFlow = executeOnairosFlow;
|
|
100
|
+
const startOnairosFlow = async options => {
|
|
101
|
+
// Pre-check if provided
|
|
102
|
+
if (options.preCheck) {
|
|
103
|
+
const canProceed = await options.preCheck();
|
|
104
|
+
if (!canProceed) {
|
|
105
|
+
console.log('❌ Pre-check failed, not starting Onairos flow');
|
|
106
|
+
if (options.onRejection) {
|
|
107
|
+
options.onRejection('Pre-check failed');
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Execute the flow
|
|
114
|
+
return executeOnairosFlow(options);
|
|
115
|
+
};
|
|
116
|
+
exports.startOnairosFlow = startOnairosFlow;
|
|
117
|
+
//# sourceMappingURL=programmaticFlow.js.map
|
|
@@ -1 +1,220 @@
|
|
|
1
|
-
'use strict';Object[_0x109b(0x0)](exports,_0x109b(0x1),{'value':!![]}),exports[_0x109b(0x2)]=exports[_0x109b(0x3)]=exports[_0x109b(0x4)]=void 0x0,exports['fetchWithRetry']=fetchWithRetry,exports[_0x109b(0x5)]=healthCheck,exports[_0x109b(0x6)]=withRetry;function _0x109b(_0x300019,_0x109b24){_0x300019=_0x300019-0x0;const _0x2d2e82=_0x3000();let _0x411fc5=_0x2d2e82[_0x300019];return _0x411fc5;}const DEFAULT_RETRY_OPTIONS=exports[_0x109b(0x3)]={'maxRetries':0x3,'baseDelay':0x3e8,'maxDelay':0x1388,'exponentialBackoff':!![],'enableLogging':![],'shouldRetry':(_0x41474c,_0x5cb1d6)=>{const _0x2268c6={'OSzNC':function(_0x33ed8f,_0x203aad){return _0x33ed8f>=_0x203aad;},'yAEYi':function(_0x3a2dd4,_0x7541){return _0x3a2dd4<_0x7541;},'Ypbri':function(_0x5e778f,_0x35330f){return _0x5e778f!==_0x35330f;},'LPZWS':function(_0x1d530c,_0x54d91c){return _0x1d530c!==_0x54d91c;},'qKhDx':function(_0x41c584,_0x5f352f){return _0x41c584===_0x5f352f;},'DUJvE':'AbortError','JZlEn':_0x109b(0x7),'krEUy':_0x109b(0x8),'iDRom':_0x109b(0x9),'TSkDZ':'Unexpected\x20character','HQrwy':function(_0x24013b,_0x53b46b){return _0x24013b===_0x53b46b;},'tOoVN':'dgmCj'};if(_0x2268c6['OSzNC'](_0x41474c[_0x109b(0xa)],0x190)&&_0x2268c6[_0x109b(0xb)](_0x41474c[_0x109b(0xa)],0x1f4)&&_0x2268c6[_0x109b(0xc)](_0x41474c['status'],0x198)&&_0x2268c6[_0x109b(0xd)](_0x41474c['status'],0x1ad))return![];if(_0x2268c6[_0x109b(0xe)](_0x41474c[_0x109b(0xf)],_0x2268c6[_0x109b(0x10)])||_0x41474c[_0x109b(0x11)][_0x109b(0x12)](_0x2268c6[_0x109b(0x13)])||_0x41474c[_0x109b(0x11)][_0x109b(0x12)]('fetch')||_0x41474c['message'][_0x109b(0x12)](_0x2268c6[_0x109b(0x14)])||_0x41474c[_0x109b(0x11)][_0x109b(0x12)](_0x109b(0x15))||_0x2268c6[_0x109b(0x16)](_0x41474c[_0x109b(0xa)],0x1f4))return!![];if(_0x41474c[_0x109b(0x11)][_0x109b(0x12)](_0x2268c6[_0x109b(0x17)])||_0x41474c[_0x109b(0x11)][_0x109b(0x12)](_0x2268c6[_0x109b(0x18)]))return _0x2268c6[_0x109b(0x19)](_0x2268c6[_0x109b(0x1a)],_0x2268c6[_0x109b(0x1a)])?!![]:!![];return![];}};function _0x3000(){const _0x82ec82=['defineProperty','__esModule','NETWORK_RETRY_OPTIONS','DEFAULT_RETRY_OPTIONS','API_RETRY_OPTIONS','healthCheck','withRetry','Network\x20request\x20failed','ENOTFOUND','JSON\x20Parse\x20error','status','yAEYi','Ypbri','LPZWS','qKhDx','name','DUJvE','message','includes','JZlEn','krEUy','timeout','OSzNC','iDRom','TSkDZ','HQrwy','tOoVN','Tqgbu','OCwKd','PHNpL','Unknown\x20error','now','QGspf','maxRetries','enableLogging','HNkVT','log','🔄\x20Retry\x20attempt\x20','osQuu','LiePw','msgnN','dQpRe','sSagX','shouldRetry','Ggmoj','FEgUV','⏳\x20Waiting\x20','ms\x20before\x20retry\x20(attempt\x20','error','❌\x20All\x20retry\x20attempts\x20exhausted\x20or\x20error\x20not\x20retryable:\x20','baseDelay','exponentialBackoff','LkiEy','MHMaD','TYztd','min','uRZPT','pow','maxDelay','random','floor','nbQiu','onRetry','pDJdz','jyiqr','warn','),\x20retrying\x20in\x20','iZcrS','sxWkM','AbortError','ssBNj','eSsmn','fetch','Unexpected\x20character','HTML\x20page\x20instead\x20of\x20JSON','Ixwqs','tPYUU','zvWfq','validation\x20endpoint','cILwi','TzeMO','cmkGe','BimkA','OQrel','Yizao','dCTBx','phBbD','GUzHC','FuhIx','XNFdw','ceCXZ','pJrZs','⚠️\x20API\x20call\x20failed\x20(attempt\x20','ms:\x20','DNS','rrOML','Xvwwz','nxYJr','xUION','iHZzg','success','XJyKw','qkVhx','data','gnAFM','abort','OnairosReactNative/HealthCheck','cfDHV','qQfZC','WODNl'];_0x3000=function(){return _0x82ec82;};return _0x3000();}async function withRetry(_0x2001e8,_0x4aafab={}){const _0x47d138={'NgbZx':function(_0x2a3c67,_0xb238ab){return _0x2a3c67<=_0xb238ab;},'QGspf':function(_0x2131ab,_0x16cb68){return _0x2131ab+_0x16cb68;},'HNkVT':function(_0x1e65cf,_0x34f181){return _0x1e65cf>_0x34f181;},'osQuu':function(_0x41939,_0x57a50c){return _0x41939+_0x57a50c;},'LiePw':function(_0xf0c246){return _0xf0c246();},'msgnN':function(_0x926b53,_0x88d4d7){return _0x926b53-_0x88d4d7;},'sSagX':_0x109b(0x1b),'bwpgF':function(_0x397577,_0x521f6b){return _0x397577>_0x521f6b;},'FEgUV':'agfHf','LkiEy':function(_0x61ca1b,_0x137c64){return _0x61ca1b!==_0x137c64;},'MHMaD':_0x109b(0x1c),'TYztd':'uBkZz','uRZPT':function(_0x59a7ba,_0x5e5596){return _0x59a7ba*_0x5e5596;},'nbQiu':function(_0x363501,_0x45dd34){return _0x363501+_0x45dd34;},'pDJdz':function(_0x1cdea3,_0x90100e){return _0x1cdea3!==_0x90100e;},'jyiqr':_0x109b(0x1d),'iZcrS':_0x109b(0x1e),'sxWkM':function(_0x456a16,_0x52b312){return _0x456a16-_0x52b312;}},_0x1b641d={...DEFAULT_RETRY_OPTIONS,..._0x4aafab},_0x6b0573=Date[_0x109b(0x1f)]();let _0x10046b=null;for(let _0x4d37a8=0x1;_0x47d138['NgbZx'](_0x4d37a8,_0x47d138[_0x109b(0x20)](_0x1b641d[_0x109b(0x21)],0x1));_0x4d37a8++){try{_0x1b641d[_0x109b(0x22)]&&_0x47d138[_0x109b(0x23)](_0x4d37a8,0x1)&&console[_0x109b(0x24)](_0x109b(0x25)+_0x4d37a8+'/'+_0x47d138[_0x109b(0x26)](_0x1b641d[_0x109b(0x21)],0x1));const _0x18ff53=await _0x47d138[_0x109b(0x27)](_0x2001e8);return{'success':!![],'data':_0x18ff53,'attempts':_0x4d37a8,'totalDuration':_0x47d138[_0x109b(0x28)](Date[_0x109b(0x1f)](),_0x6b0573)};}catch(_0x76c293){if(_0x109b(0x29)!==_0x47d138[_0x109b(0x2a)]){_0x10046b=_0x76c293;const _0x41c937=_0x1b641d[_0x109b(0x2b)]?_0x1b641d['shouldRetry'](_0x76c293,_0x4d37a8):!![];if(_0x47d138['bwpgF'](_0x4d37a8,_0x1b641d[_0x109b(0x21)])||!_0x41c937){if(_0x109b(0x2c)===_0x47d138[_0x109b(0x2d)])_0x5c9574[_0x109b(0x24)](_0x109b(0x2e)+_0x55132f+_0x109b(0x2f)+_0x23652f+'/'+(_0x33b80c[_0x109b(0x21)]+0x1)+')');else{_0x1b641d[_0x109b(0x22)]&&console[_0x109b(0x30)](_0x109b(0x31)+_0x76c293[_0x109b(0x11)]);break;}}let _0x5177da=_0x1b641d[_0x109b(0x32)];_0x1b641d[_0x109b(0x33)]&&(_0x47d138[_0x109b(0x34)](_0x47d138[_0x109b(0x35)],_0x47d138[_0x109b(0x36)])?_0x5177da=Math[_0x109b(0x37)](_0x47d138[_0x109b(0x38)](_0x1b641d['baseDelay'],Math[_0x109b(0x39)](0x2,_0x47d138[_0x109b(0x28)](_0x4d37a8,0x1))),_0x1b641d[_0x109b(0x3a)]):_0x4948d1[_0x109b(0x30)](_0x109b(0x31)+_0x45b4e7[_0x109b(0x11)]));const _0x4d129e=Math[_0x109b(0x3b)]()*0.1*_0x5177da;_0x5177da=Math[_0x109b(0x3c)](_0x47d138[_0x109b(0x3d)](_0x5177da,_0x4d129e)),_0x1b641d[_0x109b(0x3e)]&&(_0x47d138[_0x109b(0x3f)](_0x47d138[_0x109b(0x40)],_0x47d138[_0x109b(0x40)])?_0x181a2e[_0x109b(0x41)]('⚠️\x20API\x20call\x20failed\x20(attempt\x20'+_0x51425b+_0x109b(0x42)+_0x43af5b+'ms:\x20'+_0x1cdd91['message']):_0x1b641d[_0x109b(0x3e)](_0x76c293,_0x4d37a8,_0x5177da)),_0x1b641d[_0x109b(0x22)]&&console['log'](_0x109b(0x2e)+_0x5177da+_0x109b(0x2f)+_0x4d37a8+'/'+_0x47d138[_0x109b(0x20)](_0x1b641d['maxRetries'],0x1)+')'),await new Promise(_0x4e7f01=>setTimeout(()=>_0x4e7f01(),_0x5177da));}else return![];}}return{'success':![],'error':_0x10046b||new Error(_0x47d138[_0x109b(0x43)]),'attempts':_0x47d138[_0x109b(0x20)](_0x1b641d[_0x109b(0x21)],0x1),'totalDuration':_0x47d138[_0x109b(0x44)](Date[_0x109b(0x1f)](),_0x6b0573)};}const API_RETRY_OPTIONS=exports[_0x109b(0x4)]={'maxRetries':0x3,'baseDelay':0x3e8,'maxDelay':0x1388,'exponentialBackoff':!![],'shouldRetry':(_0x592db2,_0x56d90e)=>{const _0x1efb40={'OQrel':_0x109b(0x7),'OQmcP':_0x109b(0x8),'gWxJI':'DNS','zvWfq':function(_0x4eea22,_0x17ab91){return _0x4eea22===_0x17ab91;},'GXhKX':_0x109b(0x45),'pJrZs':function(_0x2e57f4,_0x4c9f29){return _0x2e57f4-_0x4c9f29;},'tPYUU':function(_0x254e4e,_0x1674c9){return _0x254e4e===_0x1674c9;},'cILwi':function(_0x43413c,_0x38d579){return _0x43413c===_0x38d579;},'TzeMO':_0x109b(0x46),'STfam':'BimkA','Yizao':function(_0x465143,_0x775dd3){return _0x465143<=_0x775dd3;},'XVBIl':function(_0x372282,_0x50b3b4){return _0x372282!==_0x50b3b4;},'dCTBx':_0x109b(0x47),'GUzHC':_0x109b(0x48),'FuhIx':_0x109b(0x9),'WOVtm':_0x109b(0x49),'XNFdw':_0x109b(0x4a),'ceCXZ':_0x109b(0x4b)};if(_0x592db2['status']===0x191||_0x1efb40[_0x109b(0x4c)](_0x592db2[_0x109b(0xa)],0x193))return![];if(_0x1efb40['zvWfq'](_0x592db2[_0x109b(0xa)],0x190)||_0x1efb40[_0x109b(0x4d)](_0x592db2[_0x109b(0xa)],0x194)&&!_0x592db2[_0x109b(0x11)][_0x109b(0x12)](_0x109b(0x4e)))return _0x1efb40[_0x109b(0x4f)](_0x1efb40[_0x109b(0x50)],_0x109b(0x51))?![]:![];if(_0x592db2[_0x109b(0xa)]===0x1ad)return _0x1efb40['STfam']!==_0x109b(0x52)?_0x20d72f[_0x109b(0x11)][_0x109b(0x12)](_0x1efb40[_0x109b(0x53)])||_0x5a134f['message'][_0x109b(0x12)](_0x1efb40['OQmcP'])||_0x12aac6[_0x109b(0x11)]['includes'](_0x1efb40['gWxJI'])||_0x1efb40[_0x109b(0x4d)](_0xae988d[_0x109b(0xf)],_0x1efb40['GXhKX']):_0x1efb40[_0x109b(0x54)](_0x56d90e,0x2);if(_0x592db2[_0x109b(0xa)]>=0x1f4){if(_0x1efb40['XVBIl'](_0x1efb40[_0x109b(0x55)],_0x109b(0x56)))return!![];else _0x3c9d73[_0x109b(0x3e)](_0x1f711b,_0x446edd,_0x42070d);}if(_0x1efb40['tPYUU'](_0x592db2[_0x109b(0xf)],_0x1efb40['GXhKX'])||_0x592db2[_0x109b(0x11)][_0x109b(0x12)]('timeout')||_0x592db2[_0x109b(0x11)][_0x109b(0x12)](_0x1efb40[_0x109b(0x53)])||_0x592db2[_0x109b(0x11)]['includes'](_0x1efb40[_0x109b(0x57)])||_0x592db2[_0x109b(0x11)][_0x109b(0x12)](_0x1efb40['OQmcP']))return!![];if(_0x592db2[_0x109b(0x11)][_0x109b(0x12)](_0x1efb40[_0x109b(0x58)])||_0x592db2[_0x109b(0x11)][_0x109b(0x12)](_0x1efb40['WOVtm'])||_0x592db2['message'][_0x109b(0x12)](_0x1efb40[_0x109b(0x59)]))return _0x1efb40['XVBIl'](_0x1efb40[_0x109b(0x5a)],_0x1efb40[_0x109b(0x5a)])?{'reachable':![],'error':_0x5b5698[_0x109b(0x11)],'duration':_0x1efb40[_0x109b(0x5b)](_0x3695cb['now'](),_0x2c94c0)}:!![];return![];},'onRetry':(_0x51c30b,_0x61998d,_0x5314f9)=>{console[_0x109b(0x41)](_0x109b(0x5c)+_0x61998d+'),\x20retrying\x20in\x20'+_0x5314f9+_0x109b(0x5d)+_0x51c30b[_0x109b(0x11)]);}},NETWORK_RETRY_OPTIONS=exports[_0x109b(0x2)]={'maxRetries':0x2,'baseDelay':0x7d0,'maxDelay':0x1f40,'exponentialBackoff':!![],'shouldRetry':(_0x6ec6bf,_0x28c0bb)=>{const _0x5b2a48={'rrOML':_0x109b(0x7),'Xvwwz':_0x109b(0x5e),'nxYJr':function(_0x61c141,_0x452138){return _0x61c141===_0x452138;}};return _0x6ec6bf[_0x109b(0x11)][_0x109b(0x12)](_0x5b2a48[_0x109b(0x5f)])||_0x6ec6bf[_0x109b(0x11)][_0x109b(0x12)](_0x109b(0x8))||_0x6ec6bf[_0x109b(0x11)][_0x109b(0x12)](_0x5b2a48[_0x109b(0x60)])||_0x5b2a48[_0x109b(0x61)](_0x6ec6bf[_0x109b(0xf)],'AbortError');}};async function fetchWithRetry(_0x2f69de,_0xc381fd={},_0x596e65=API_RETRY_OPTIONS){const _0x3cd9f5={'iHZzg':function(_0x19d92b,_0x2a5952,_0x1b7b14){return _0x19d92b(_0x2a5952,_0x1b7b14);},'XJyKw':function(_0x9160c6,_0x2192a7){return _0x9160c6===_0x2192a7;},'qkVhx':_0x109b(0x62)},_0x366ed0=await _0x3cd9f5[_0x109b(0x63)](withRetry,()=>fetch(_0x2f69de,_0xc381fd),_0x596e65);if(!_0x366ed0[_0x109b(0x64)]){if(_0x3cd9f5[_0x109b(0x65)](_0x109b(0x62),_0x3cd9f5[_0x109b(0x66)]))throw _0x366ed0[_0x109b(0x30)];else return!![];}return _0x366ed0[_0x109b(0x67)];}async function healthCheck(_0x3018ad,_0x1a1e9b=0x1388){const _0x21d18c={'gnAFM':function(_0x435e1d,_0x2e3c26,_0x819dc5){return _0x435e1d(_0x2e3c26,_0x819dc5);},'cfDHV':function(_0x58eda6,_0x3cde81){return _0x58eda6(_0x3cde81);},'qQfZC':function(_0x2e7f3e,_0x2509f8){return _0x2e7f3e-_0x2509f8;},'WODNl':function(_0x59a27f,_0x80ac45){return _0x59a27f-_0x80ac45;}},_0x704ee3=Date[_0x109b(0x1f)]();try{const _0x4ce4b1=new AbortController(),_0x315ee6=_0x21d18c[_0x109b(0x68)](setTimeout,()=>_0x4ce4b1[_0x109b(0x69)](),_0x1a1e9b),_0x4f125d=await _0x21d18c[_0x109b(0x68)](fetch,_0x3018ad,{'method':'GET','signal':_0x4ce4b1['signal'],'headers':{'User-Agent':_0x109b(0x6a)}});return _0x21d18c[_0x109b(0x6b)](clearTimeout,_0x315ee6),{'reachable':!![],'status':_0x4f125d[_0x109b(0xa)],'duration':_0x21d18c[_0x109b(0x6c)](Date[_0x109b(0x1f)](),_0x704ee3)};}catch(_0xa6ff6b){return{'reachable':![],'error':_0xa6ff6b[_0x109b(0x11)],'duration':_0x21d18c[_0x109b(0x6d)](Date[_0x109b(0x1f)](),_0x704ee3)};}}
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NETWORK_RETRY_OPTIONS = exports.DEFAULT_RETRY_OPTIONS = exports.API_RETRY_OPTIONS = void 0;
|
|
7
|
+
exports.fetchWithRetry = fetchWithRetry;
|
|
8
|
+
exports.healthCheck = healthCheck;
|
|
9
|
+
exports.withRetry = withRetry;
|
|
10
|
+
/**
|
|
11
|
+
* 🔄 Retry Helper Utility
|
|
12
|
+
*
|
|
13
|
+
* Provides robust retry logic with exponential backoff for network operations.
|
|
14
|
+
* Used throughout the Onairos SDK for handling transient failures gracefully.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Default retry options for the Onairos SDK
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_RETRY_OPTIONS = exports.DEFAULT_RETRY_OPTIONS = {
|
|
21
|
+
maxRetries: 3,
|
|
22
|
+
baseDelay: 1000,
|
|
23
|
+
maxDelay: 5000,
|
|
24
|
+
exponentialBackoff: true,
|
|
25
|
+
enableLogging: false,
|
|
26
|
+
shouldRetry: (error, attempt) => {
|
|
27
|
+
// Don't retry client errors (4xx) except for 408 (timeout) and 429 (rate limit)
|
|
28
|
+
if (error.status >= 400 && error.status < 500 && error.status !== 408 && error.status !== 429) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Retry network errors, timeouts, and server errors (5xx)
|
|
33
|
+
if (error.name === 'AbortError' || error.message.includes('Network request failed') || error.message.includes('fetch') || error.message.includes('ENOTFOUND') || error.message.includes('timeout') || error.status >= 500) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Retry JSON parse errors (likely server issues)
|
|
38
|
+
if (error.message.includes('JSON Parse error') || error.message.includes('Unexpected character')) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Execute a function with retry logic and exponential backoff
|
|
47
|
+
* @param fn Function to execute (should return a Promise)
|
|
48
|
+
* @param options Retry configuration options
|
|
49
|
+
* @returns Promise with retry result
|
|
50
|
+
*/
|
|
51
|
+
async function withRetry(fn, options = {}) {
|
|
52
|
+
const config = {
|
|
53
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
54
|
+
...options
|
|
55
|
+
};
|
|
56
|
+
const startTime = Date.now();
|
|
57
|
+
let lastError = null;
|
|
58
|
+
for (let attempt = 1; attempt <= config.maxRetries + 1; attempt++) {
|
|
59
|
+
try {
|
|
60
|
+
if (config.enableLogging && attempt > 1) {
|
|
61
|
+
console.log(`🔄 Retry attempt ${attempt}/${config.maxRetries + 1}`);
|
|
62
|
+
}
|
|
63
|
+
const result = await fn();
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
data: result,
|
|
67
|
+
attempts: attempt,
|
|
68
|
+
totalDuration: Date.now() - startTime
|
|
69
|
+
};
|
|
70
|
+
} catch (error) {
|
|
71
|
+
lastError = error;
|
|
72
|
+
|
|
73
|
+
// Check if we should retry this error
|
|
74
|
+
const shouldRetryError = config.shouldRetry ? config.shouldRetry(error, attempt) : true;
|
|
75
|
+
|
|
76
|
+
// If this is the last attempt or we shouldn't retry, throw the error
|
|
77
|
+
if (attempt > config.maxRetries || !shouldRetryError) {
|
|
78
|
+
if (config.enableLogging) {
|
|
79
|
+
console.error(`❌ All retry attempts exhausted or error not retryable: ${error.message}`);
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Calculate delay for next attempt
|
|
85
|
+
let delay = config.baseDelay;
|
|
86
|
+
if (config.exponentialBackoff) {
|
|
87
|
+
delay = Math.min(config.baseDelay * Math.pow(2, attempt - 1), config.maxDelay);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Add some jitter to prevent thundering herd
|
|
91
|
+
const jitter = Math.random() * 0.1 * delay;
|
|
92
|
+
delay = Math.floor(delay + jitter);
|
|
93
|
+
if (config.onRetry) {
|
|
94
|
+
config.onRetry(error, attempt, delay);
|
|
95
|
+
}
|
|
96
|
+
if (config.enableLogging) {
|
|
97
|
+
console.log(`⏳ Waiting ${delay}ms before retry (attempt ${attempt}/${config.maxRetries + 1})`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Wait before next attempt
|
|
101
|
+
await new Promise(resolve => setTimeout(() => resolve(), delay));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
error: lastError || new Error('Unknown error'),
|
|
107
|
+
attempts: config.maxRetries + 1,
|
|
108
|
+
totalDuration: Date.now() - startTime
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Retry configuration for API calls
|
|
114
|
+
*/
|
|
115
|
+
const API_RETRY_OPTIONS = exports.API_RETRY_OPTIONS = {
|
|
116
|
+
maxRetries: 3,
|
|
117
|
+
baseDelay: 1000,
|
|
118
|
+
maxDelay: 5000,
|
|
119
|
+
exponentialBackoff: true,
|
|
120
|
+
shouldRetry: (error, attempt) => {
|
|
121
|
+
// Enhanced retry logic for API calls
|
|
122
|
+
|
|
123
|
+
// Never retry authentication errors (401) or permission errors (403)
|
|
124
|
+
if (error.status === 401 || error.status === 403) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Never retry bad request errors (400) or not found (404) unless it's a specific case
|
|
129
|
+
if (error.status === 400 || error.status === 404 && !error.message.includes('validation endpoint')) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Retry rate limiting (429) with longer delays
|
|
134
|
+
if (error.status === 429) {
|
|
135
|
+
return attempt <= 2; // Limit retries for rate limiting
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Retry server errors (5xx)
|
|
139
|
+
if (error.status >= 500) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Retry timeout and network errors
|
|
144
|
+
if (error.name === 'AbortError' || error.message.includes('timeout') || error.message.includes('Network request failed') || error.message.includes('fetch') || error.message.includes('ENOTFOUND')) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Retry JSON parse errors (server returning HTML instead of JSON)
|
|
149
|
+
if (error.message.includes('JSON Parse error') || error.message.includes('Unexpected character') || error.message.includes('HTML page instead of JSON')) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
},
|
|
154
|
+
onRetry: (error, attempt, delay) => {
|
|
155
|
+
console.warn(`⚠️ API call failed (attempt ${attempt}), retrying in ${delay}ms: ${error.message}`);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Specialized retry for network/connectivity issues
|
|
161
|
+
*/
|
|
162
|
+
const NETWORK_RETRY_OPTIONS = exports.NETWORK_RETRY_OPTIONS = {
|
|
163
|
+
maxRetries: 2,
|
|
164
|
+
baseDelay: 2000,
|
|
165
|
+
maxDelay: 8000,
|
|
166
|
+
exponentialBackoff: true,
|
|
167
|
+
shouldRetry: (error, attempt) => {
|
|
168
|
+
// Only retry actual network/connectivity issues
|
|
169
|
+
return error.message.includes('Network request failed') || error.message.includes('ENOTFOUND') || error.message.includes('DNS') || error.name === 'AbortError';
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Create a retry wrapper for fetch requests
|
|
175
|
+
* @param url Request URL
|
|
176
|
+
* @param options Fetch options
|
|
177
|
+
* @param retryOptions Retry configuration
|
|
178
|
+
* @returns Promise with fetch response
|
|
179
|
+
*/
|
|
180
|
+
async function fetchWithRetry(url, options = {}, retryOptions = API_RETRY_OPTIONS) {
|
|
181
|
+
const result = await withRetry(() => fetch(url, options), retryOptions);
|
|
182
|
+
if (!result.success) {
|
|
183
|
+
throw result.error;
|
|
184
|
+
}
|
|
185
|
+
return result.data;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Health check function with retry for testing connectivity
|
|
190
|
+
* @param url URL to check
|
|
191
|
+
* @param timeout Timeout in milliseconds
|
|
192
|
+
* @returns Promise indicating if the service is reachable
|
|
193
|
+
*/
|
|
194
|
+
async function healthCheck(url, timeout = 5000) {
|
|
195
|
+
const startTime = Date.now();
|
|
196
|
+
try {
|
|
197
|
+
const controller = new AbortController();
|
|
198
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
199
|
+
const response = await fetch(url, {
|
|
200
|
+
method: 'GET',
|
|
201
|
+
signal: controller.signal,
|
|
202
|
+
headers: {
|
|
203
|
+
'User-Agent': 'OnairosReactNative/HealthCheck'
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
clearTimeout(timeoutId);
|
|
207
|
+
return {
|
|
208
|
+
reachable: true,
|
|
209
|
+
status: response.status,
|
|
210
|
+
duration: Date.now() - startTime
|
|
211
|
+
};
|
|
212
|
+
} catch (error) {
|
|
213
|
+
return {
|
|
214
|
+
reachable: false,
|
|
215
|
+
error: error.message,
|
|
216
|
+
duration: Date.now() - startTime
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=retryHelper.js.map
|