@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,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[_0x5126(0x0)](exports,_0x5126(0x1),{'value':!![]}),exports[_0x5126(0x2)]=exports[_0x5126(0x3)]=exports[_0x5126(0x4)]=void 0x0,exports[_0x5126(0x5)]=fetchWithRetry,exports[_0x5126(0x6)]=healthCheck,exports[_0x5126(0x7)]=withRetry;function _0x5126(_0x487d78,_0x512634){_0x487d78=_0x487d78-0x0;const _0x24bef8=_0x487d();let _0x180803=_0x24bef8[_0x487d78];return _0x180803;}function _0x487d(){const _0xa977a4=['defineProperty','__esModule','NETWORK_RETRY_OPTIONS','DEFAULT_RETRY_OPTIONS','API_RETRY_OPTIONS','fetchWithRetry','healthCheck','withRetry','Network\x20request\x20failed','bnNxq','status','DLbGB','dQYTU','hQHKc','voZNw','name','message','includes','DKryZ','fetch','kDdcJ','snNtN','JSON\x20Parse\x20error','Unexpected\x20character','FRkzb','RzYgJ','Wqfyg','gOLAh','now','RmYvs','NVvPw','maxRetries','NxpaJ','wtxaO','ZJXcg','error','enableLogging','log','nZWnd','NhkQs','shouldRetry','baseDelay','exponentialBackoff','iGIHo','Jxeys','⏳\x20Waiting\x20','ms\x20before\x20retry\x20(attempt\x20','min','Wegtq','pow','maxDelay','Vijdk','oBqWk','random','onRetry','ylxvP','ZttRf','ynTgB','Unknown\x20error','DFeQD','mtvzr','LGyOF','timeout','ENOTFOUND','rLHqH','gFddY','PUXqy','xLKmM','RlUNB','kvMWa','KLASE','),\x20retrying\x20in\x20','ms:\x20','AbortError','ipAoE','hWFjW','DNS','LBhNY','zMDtX','success','data','OnairosReactNative/HealthCheck','KsrLa','signal','BshSl','yQujZ','ytxaO'];_0x487d=function(){return _0xa977a4;};return _0x487d();}const DEFAULT_RETRY_OPTIONS=exports[_0x5126(0x3)]={'maxRetries':0x3,'baseDelay':0x3e8,'maxDelay':0x1388,'exponentialBackoff':!![],'enableLogging':![],'shouldRetry':(_0x1e20cf,_0x5ce4a6)=>{const _0x140b30={'ndyxJ':function(_0x4057ee,_0x3fea27){return _0x4057ee>=_0x3fea27;},'DLbGB':function(_0x121181,_0x457877){return _0x121181<_0x457877;},'dQYTU':function(_0x988080,_0x32684c){return _0x988080!==_0x32684c;},'hQHKc':function(_0x207d58,_0x4e5792){return _0x207d58!==_0x4e5792;},'voZNw':function(_0x23f8d5,_0x4bc24a){return _0x23f8d5===_0x4bc24a;},'TAWTl':'AbortError','DKryZ':_0x5126(0x8),'kDdcJ':function(_0x527ada,_0x494b99){return _0x527ada>=_0x494b99;},'ZiCFY':'ZricP','snNtN':_0x5126(0x9)};if(_0x140b30['ndyxJ'](_0x1e20cf[_0x5126(0xa)],0x190)&&_0x140b30[_0x5126(0xb)](_0x1e20cf[_0x5126(0xa)],0x1f4)&&_0x140b30[_0x5126(0xc)](_0x1e20cf['status'],0x198)&&_0x140b30[_0x5126(0xd)](_0x1e20cf[_0x5126(0xa)],0x1ad))return![];if(_0x140b30[_0x5126(0xe)](_0x1e20cf[_0x5126(0xf)],_0x140b30['TAWTl'])||_0x1e20cf[_0x5126(0x10)][_0x5126(0x11)](_0x140b30[_0x5126(0x12)])||_0x1e20cf[_0x5126(0x10)]['includes'](_0x5126(0x13))||_0x1e20cf[_0x5126(0x10)][_0x5126(0x11)]('ENOTFOUND')||_0x1e20cf[_0x5126(0x10)][_0x5126(0x11)]('timeout')||_0x140b30[_0x5126(0x14)](_0x1e20cf[_0x5126(0xa)],0x1f4))return _0x140b30['ZiCFY']!==_0x140b30[_0x5126(0x15)]?!![]:!![];if(_0x1e20cf[_0x5126(0x10)][_0x5126(0x11)](_0x5126(0x16))||_0x1e20cf[_0x5126(0x10)]['includes'](_0x5126(0x17)))return!![];return![];}};async function withRetry(_0x32b519,_0x1c14e9={}){const _0x1ac2d0={'RmYvs':function(_0x179843,_0x5e297c){return _0x179843<=_0x5e297c;},'NVvPw':function(_0x40eb79,_0x266225){return _0x40eb79+_0x266225;},'NxpaJ':function(_0x1fd920,_0x1b6f82){return _0x1fd920===_0x1b6f82;},'wtxaO':_0x5126(0x18),'ZJXcg':_0x5126(0x19),'nZWnd':function(_0x22cc9e){return _0x22cc9e();},'mtvzr':function(_0x1c0298,_0x288dbd){return _0x1c0298-_0x288dbd;},'iGIHo':function(_0x97d511,_0x186e96){return _0x97d511!==_0x186e96;},'NhkQs':'IGAZT','TjKZs':_0x5126(0x1a),'vrHlX':function(_0x3eef9d,_0x521847){return _0x3eef9d>_0x521847;},'Jxeys':_0x5126(0x1b),'Wegtq':function(_0x25a836,_0x276545){return _0x25a836*_0x276545;},'Vijdk':function(_0x4ae31b,_0xf4b690){return _0x4ae31b*_0xf4b690;},'oBqWk':function(_0x359039,_0x48b3d0){return _0x359039*_0x48b3d0;},'gZxfG':'tZokF','ylxvP':'WoMDn','ZttRf':'wPtNZ','ynTgB':function(_0x15ef2b,_0x2f747a){return _0x15ef2b+_0x2f747a;},'DFeQD':function(_0x515d13,_0x42b14d){return _0x515d13+_0x42b14d;}},_0x52da8c={...DEFAULT_RETRY_OPTIONS,..._0x1c14e9},_0x36f775=Date[_0x5126(0x1c)]();let _0x2860d3=null;for(let _0x241e47=0x1;_0x1ac2d0[_0x5126(0x1d)](_0x241e47,_0x1ac2d0[_0x5126(0x1e)](_0x52da8c[_0x5126(0x1f)],0x1));_0x241e47++){if(_0x1ac2d0[_0x5126(0x20)](_0x1ac2d0[_0x5126(0x21)],_0x1ac2d0[_0x5126(0x22)]))_0xac6842[_0x5126(0x23)]('❌\x20All\x20retry\x20attempts\x20exhausted\x20or\x20error\x20not\x20retryable:\x20'+_0x4f2350[_0x5126(0x10)]);else try{_0x52da8c[_0x5126(0x24)]&&_0x241e47>0x1&&console[_0x5126(0x25)]('🔄\x20Retry\x20attempt\x20'+_0x241e47+'/'+_0x1ac2d0[_0x5126(0x1e)](_0x52da8c[_0x5126(0x1f)],0x1));const _0x5f0f77=await _0x1ac2d0[_0x5126(0x26)](_0x32b519);return{'success':!![],'data':_0x5f0f77,'attempts':_0x241e47,'totalDuration':_0x1ac2d0['mtvzr'](Date[_0x5126(0x1c)](),_0x36f775)};}catch(_0x2ef70a){if(_0x1ac2d0['iGIHo'](_0x1ac2d0[_0x5126(0x27)],_0x1ac2d0['TjKZs'])){_0x2860d3=_0x2ef70a;const _0x25f8b6=_0x52da8c[_0x5126(0x28)]?_0x52da8c[_0x5126(0x28)](_0x2ef70a,_0x241e47):!![];if(_0x1ac2d0['vrHlX'](_0x241e47,_0x52da8c['maxRetries'])||!_0x25f8b6){_0x52da8c[_0x5126(0x24)]&&console[_0x5126(0x23)]('❌\x20All\x20retry\x20attempts\x20exhausted\x20or\x20error\x20not\x20retryable:\x20'+_0x2ef70a['message']);break;}let _0x2548fd=_0x52da8c[_0x5126(0x29)];_0x52da8c[_0x5126(0x2a)]&&(_0x1ac2d0[_0x5126(0x2b)](_0x5126(0x1b),_0x1ac2d0[_0x5126(0x2c)])?_0x19eb15[_0x5126(0x25)](_0x5126(0x2d)+_0x3395b9+_0x5126(0x2e)+_0x46ffc0+'/'+(_0x4b46c4['maxRetries']+0x1)+')'):_0x2548fd=Math[_0x5126(0x2f)](_0x1ac2d0[_0x5126(0x30)](_0x52da8c['baseDelay'],Math[_0x5126(0x31)](0x2,_0x241e47-0x1)),_0x52da8c[_0x5126(0x32)]));const _0x24ee4e=_0x1ac2d0[_0x5126(0x33)](_0x1ac2d0[_0x5126(0x34)](Math[_0x5126(0x35)](),0.1),_0x2548fd);_0x2548fd=Math['floor'](_0x2548fd+_0x24ee4e);_0x52da8c[_0x5126(0x36)]&&(_0x1ac2d0[_0x5126(0x2b)](_0x1ac2d0['gZxfG'],_0x1ac2d0[_0x5126(0x37)])?_0x52da8c[_0x5126(0x36)](_0x2ef70a,_0x241e47,_0x2548fd):_0x30df76[_0x5126(0x36)](_0x5120dc,_0x195230,_0x1c0616));if(_0x52da8c[_0x5126(0x24)]){if(_0x1ac2d0[_0x5126(0x38)]!==_0x1ac2d0['ZttRf'])throw _0x2dc690['error'];else console[_0x5126(0x25)]('⏳\x20Waiting\x20'+_0x2548fd+_0x5126(0x2e)+_0x241e47+'/'+_0x1ac2d0[_0x5126(0x39)](_0x52da8c['maxRetries'],0x1)+')');}await new Promise(_0xabcdf7=>setTimeout(()=>_0xabcdf7(),_0x2548fd));}else return!![];}}return{'success':![],'error':_0x2860d3||new Error(_0x5126(0x3a)),'attempts':_0x1ac2d0[_0x5126(0x3b)](_0x52da8c[_0x5126(0x1f)],0x1),'totalDuration':_0x1ac2d0[_0x5126(0x3c)](Date[_0x5126(0x1c)](),_0x36f775)};}const API_RETRY_OPTIONS=exports[_0x5126(0x4)]={'maxRetries':0x3,'baseDelay':0x3e8,'maxDelay':0x1388,'exponentialBackoff':!![],'shouldRetry':(_0x298e62,_0x30b81e)=>{const _0x413787={'rLHqH':function(_0x3e6401,_0x41fda1){return _0x3e6401===_0x41fda1;},'toGIW':function(_0x122b5b,_0x103296){return _0x122b5b!==_0x103296;},'gFddY':_0x5126(0x3d),'xLKmM':function(_0x2b194c,_0x3aff3c){return _0x2b194c===_0x3aff3c;},'PUXqy':'validation\x20endpoint','RlUNB':function(_0x1ca398,_0x2799d3){return _0x1ca398>=_0x2799d3;},'yIctp':function(_0x10f901,_0x2526d9){return _0x10f901===_0x2526d9;},'Zhdic':_0x5126(0x3e),'kvMWa':_0x5126(0x13),'SyhAj':_0x5126(0x3f),'KLASE':_0x5126(0x16),'dBlpK':'HTML\x20page\x20instead\x20of\x20JSON'};if(_0x413787[_0x5126(0x40)](_0x298e62['status'],0x191)||_0x413787[_0x5126(0x40)](_0x298e62[_0x5126(0xa)],0x193))return _0x413787['toGIW'](_0x413787[_0x5126(0x41)],_0x413787['gFddY'])?![]:![];if(_0x298e62[_0x5126(0xa)]===0x190||_0x413787['xLKmM'](_0x298e62[_0x5126(0xa)],0x194)&&!_0x298e62[_0x5126(0x10)]['includes'](_0x413787[_0x5126(0x42)]))return![];if(_0x413787[_0x5126(0x43)](_0x298e62[_0x5126(0xa)],0x1ad))return _0x30b81e<=0x2;if(_0x413787[_0x5126(0x44)](_0x298e62[_0x5126(0xa)],0x1f4))return!![];if(_0x413787['yIctp'](_0x298e62[_0x5126(0xf)],'AbortError')||_0x298e62[_0x5126(0x10)][_0x5126(0x11)](_0x413787['Zhdic'])||_0x298e62[_0x5126(0x10)][_0x5126(0x11)](_0x5126(0x8))||_0x298e62[_0x5126(0x10)][_0x5126(0x11)](_0x413787[_0x5126(0x45)])||_0x298e62[_0x5126(0x10)]['includes'](_0x413787['SyhAj']))return!![];if(_0x298e62[_0x5126(0x10)][_0x5126(0x11)](_0x413787[_0x5126(0x46)])||_0x298e62[_0x5126(0x10)]['includes'](_0x5126(0x17))||_0x298e62[_0x5126(0x10)]['includes'](_0x413787['dBlpK']))return!![];return![];},'onRetry':(_0x2b7ac6,_0x22d4cf,_0x397c21)=>{console['warn']('⚠️\x20API\x20call\x20failed\x20(attempt\x20'+_0x22d4cf+_0x5126(0x47)+_0x397c21+_0x5126(0x48)+_0x2b7ac6[_0x5126(0x10)]);}},NETWORK_RETRY_OPTIONS=exports[_0x5126(0x2)]={'maxRetries':0x2,'baseDelay':0x7d0,'maxDelay':0x1f40,'exponentialBackoff':!![],'shouldRetry':(_0x49b54e,_0x2c484a)=>{const _0x1da2a5={'ipAoE':_0x5126(0x8),'hWFjW':_0x5126(0x3f),'LBhNY':_0x5126(0x49)};return _0x49b54e['message'][_0x5126(0x11)](_0x1da2a5[_0x5126(0x4a)])||_0x49b54e['message']['includes'](_0x1da2a5[_0x5126(0x4b)])||_0x49b54e[_0x5126(0x10)][_0x5126(0x11)](_0x5126(0x4c))||_0x49b54e['name']===_0x1da2a5[_0x5126(0x4d)];}};async function fetchWithRetry(_0x42c323,_0x456cbc={},_0xe14fe3=API_RETRY_OPTIONS){const _0x5f43fc={'zMDtX':function(_0x17fb00,_0x4bbfa8,_0x3cda3f){return _0x17fb00(_0x4bbfa8,_0x3cda3f);}},_0x2ce658=await _0x5f43fc[_0x5126(0x4e)](withRetry,()=>fetch(_0x42c323,_0x456cbc),_0xe14fe3);if(!_0x2ce658[_0x5126(0x4f)])throw _0x2ce658[_0x5126(0x23)];return _0x2ce658[_0x5126(0x50)];}async function healthCheck(_0x106fdd,_0x989d51=0x1388){const _0x2228c6={'CJGPj':function(_0x26f695,_0x4bee56,_0xa57587){return _0x26f695(_0x4bee56,_0xa57587);},'KsrLa':function(_0x360014,_0x57e40f,_0x505f67){return _0x360014(_0x57e40f,_0x505f67);},'BshSl':_0x5126(0x51),'yQujZ':function(_0x384aeb,_0x300362){return _0x384aeb-_0x300362;},'EkyZi':function(_0x310b0a,_0x33af3a){return _0x310b0a!==_0x33af3a;},'ytxaO':'FsUTm'},_0x409013=Date[_0x5126(0x1c)]();try{const _0x55aead=new AbortController(),_0x3d381f=_0x2228c6['CJGPj'](setTimeout,()=>_0x55aead['abort'](),_0x989d51),_0x16ae69=await _0x2228c6[_0x5126(0x52)](fetch,_0x106fdd,{'method':'GET','signal':_0x55aead[_0x5126(0x53)],'headers':{'User-Agent':_0x2228c6[_0x5126(0x54)]}});return clearTimeout(_0x3d381f),{'reachable':!![],'status':_0x16ae69[_0x5126(0xa)],'duration':_0x2228c6[_0x5126(0x55)](Date[_0x5126(0x1c)](),_0x409013)};}catch(_0x3bbf07){return _0x2228c6['EkyZi'](_0x2228c6[_0x5126(0x56)],_0x2228c6[_0x5126(0x56)])?!![]:{'reachable':![],'error':_0x3bbf07['message'],'duration':_0x2228c6[_0x5126(0x55)](Date[_0x5126(0x1c)](),_0x409013)};}}
|
|
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
|