@onairos/react-native 3.7.2 → 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/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/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,7 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getUserAuthHeaders = exports.getAuthHeaders = exports.getApiHeaders = exports.API_CONFIG = void 0;
|
|
7
|
+
var _authService = require("../services/authService");
|
|
8
|
+
/**
|
|
9
|
+
* API Configuration for Onairos SDK
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT: This is the single source of truth for the API base URL.
|
|
12
|
+
* All files should import API_CONFIG.BASE_URL instead of hardcoding URLs.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const API_CONFIG = exports.API_CONFIG = {
|
|
16
|
+
BASE_URL: 'https://api2.onairos.uk',
|
|
17
|
+
ENDPOINTS: {
|
|
18
|
+
AUTH: '/auth',
|
|
19
|
+
USER: '/user',
|
|
20
|
+
CONNECTIONS: '/connections',
|
|
21
|
+
TRAINING: '/training',
|
|
22
|
+
OAUTH: '/oauth'
|
|
23
|
+
},
|
|
24
|
+
TIMEOUT: 30000
|
|
25
|
+
};
|
|
26
|
+
const getApiHeaders = () => ({
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Accept': 'application/json'
|
|
29
|
+
});
|
|
30
|
+
exports.getApiHeaders = getApiHeaders;
|
|
31
|
+
const getAuthHeaders = token => ({
|
|
32
|
+
...getApiHeaders(),
|
|
33
|
+
...(token && {
|
|
34
|
+
'Authorization': `Bearer ${token}`
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get headers with User JWT for authenticated requests
|
|
40
|
+
* Use this for all post-login API calls (platform connects, etc.)
|
|
41
|
+
*
|
|
42
|
+
* TIER 2 Authentication: User must be logged in
|
|
43
|
+
*/
|
|
44
|
+
exports.getAuthHeaders = getAuthHeaders;
|
|
45
|
+
const getUserAuthHeaders = async () => {
|
|
46
|
+
const token = await (0, _authService.getAuthToken)();
|
|
47
|
+
if (!token) {
|
|
48
|
+
throw new Error('User not authenticated - no JWT token found');
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
...getApiHeaders(),
|
|
52
|
+
'Authorization': `Bearer ${token}`
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.getUserAuthHeaders = getUserAuthHeaders;
|
|
56
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -1,7 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.STORAGE_KEYS = exports.PLATFORMS = exports.PIN_REQUIREMENTS = exports.DEEP_LINK_CONFIG = exports.COLORS = exports.API_ENDPOINTS = void 0;
|
|
7
|
+
var _api = require("../config/api");
|
|
8
|
+
const COLORS = exports.COLORS = {
|
|
9
|
+
primary: '#1BA9D4',
|
|
10
|
+
headerBg: '#F8F9FA',
|
|
11
|
+
text: {
|
|
12
|
+
primary: '#000000',
|
|
13
|
+
secondary: '#666666'
|
|
14
|
+
},
|
|
15
|
+
border: '#E5E5E5',
|
|
16
|
+
success: '#34C759',
|
|
17
|
+
error: '#FF3B30',
|
|
18
|
+
instagram: '#E1306C',
|
|
19
|
+
pinterest: '#E60023',
|
|
20
|
+
reddit: '#FF4500',
|
|
21
|
+
youtube: '#FF0000',
|
|
22
|
+
chatgpt: '#10A37F',
|
|
23
|
+
llm: '#10A37F',
|
|
24
|
+
netflix: '#E50914',
|
|
25
|
+
spotify: '#1DB954',
|
|
26
|
+
white: '#FFFFFF',
|
|
27
|
+
black: '#000000',
|
|
28
|
+
gray: '#666666',
|
|
29
|
+
lightGray: '#E5E5E5'
|
|
30
|
+
};
|
|
31
|
+
const PLATFORMS = exports.PLATFORMS = {
|
|
32
|
+
instagram: {
|
|
33
|
+
name: 'Instagram',
|
|
34
|
+
icon: 'instagram',
|
|
35
|
+
color: COLORS.instagram,
|
|
36
|
+
description: 'Connect your Instagram account to train your AI model'
|
|
37
|
+
},
|
|
38
|
+
pinterest: {
|
|
39
|
+
name: 'Pinterest',
|
|
40
|
+
icon: 'pinterest',
|
|
41
|
+
color: COLORS.pinterest,
|
|
42
|
+
description: 'Use your Pinterest boards for AI training'
|
|
43
|
+
},
|
|
44
|
+
reddit: {
|
|
45
|
+
name: 'Reddit',
|
|
46
|
+
icon: 'reddit',
|
|
47
|
+
color: COLORS.reddit,
|
|
48
|
+
description: 'Connect Reddit to enhance your AI model'
|
|
49
|
+
},
|
|
50
|
+
youtube: {
|
|
51
|
+
name: 'YouTube',
|
|
52
|
+
icon: 'youtube',
|
|
53
|
+
color: COLORS.youtube,
|
|
54
|
+
description: 'Use YouTube data to improve AI recommendations'
|
|
55
|
+
},
|
|
56
|
+
chatgpt: {
|
|
57
|
+
name: 'ChatGPT',
|
|
58
|
+
icon: 'chat',
|
|
59
|
+
color: COLORS.chatgpt,
|
|
60
|
+
description: 'Connect your ChatGPT conversations for AI insights'
|
|
61
|
+
},
|
|
62
|
+
llm: {
|
|
63
|
+
name: 'LLM Data',
|
|
64
|
+
icon: 'psychology',
|
|
65
|
+
color: COLORS.llm,
|
|
66
|
+
description: 'Connect your AI conversation data'
|
|
67
|
+
},
|
|
68
|
+
netflix: {
|
|
69
|
+
name: 'Netflix',
|
|
70
|
+
icon: 'netflix',
|
|
71
|
+
color: COLORS.netflix,
|
|
72
|
+
description: 'Connect your Netflix viewing history for personalized insights'
|
|
73
|
+
},
|
|
74
|
+
spotify: {
|
|
75
|
+
name: 'Spotify',
|
|
76
|
+
icon: 'spotify',
|
|
77
|
+
color: COLORS.spotify,
|
|
78
|
+
description: 'Connect your Spotify listening data for music preferences'
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const API_ENDPOINTS = exports.API_ENDPOINTS = {
|
|
82
|
+
base: _api.API_CONFIG.BASE_URL,
|
|
83
|
+
oauth: {
|
|
84
|
+
instagram: '/instagram/auth',
|
|
85
|
+
pinterest: '/pinterest/auth',
|
|
86
|
+
reddit: '/reddit/auth',
|
|
87
|
+
youtube: '/youtube/auth',
|
|
88
|
+
chatgpt: '/chatgpt/auth',
|
|
89
|
+
llm: '/chatgpt/auth'
|
|
90
|
+
},
|
|
91
|
+
callback: {
|
|
92
|
+
instagram: '/instagram/callback',
|
|
93
|
+
pinterest: '/pinterest/callback',
|
|
94
|
+
reddit: '/reddit/callback',
|
|
95
|
+
youtube: '/youtube/callback',
|
|
96
|
+
chatgpt: '/chatgpt/callback',
|
|
97
|
+
llm: '/chatgpt/callback'
|
|
98
|
+
},
|
|
99
|
+
llm: {
|
|
100
|
+
dataIngest: '/llmdata',
|
|
101
|
+
dataRequest: '/llmdata/request'
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const STORAGE_KEYS = exports.STORAGE_KEYS = {
|
|
105
|
+
credentials: 'onairos_credentials',
|
|
106
|
+
connections: 'onairos_connections'
|
|
107
|
+
};
|
|
108
|
+
const PIN_REQUIREMENTS = exports.PIN_REQUIREMENTS = {
|
|
109
|
+
minLength: 8,
|
|
110
|
+
requireUppercase: true,
|
|
111
|
+
requireLowercase: true,
|
|
112
|
+
requireNumber: true,
|
|
113
|
+
requireSpecialChar: true
|
|
114
|
+
};
|
|
115
|
+
const DEEP_LINK_CONFIG = exports.DEEP_LINK_CONFIG = {
|
|
116
|
+
scheme: 'onairosanime',
|
|
117
|
+
host: 'authenticate',
|
|
118
|
+
redirectUri: 'onairosanime://auth/'
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,345 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object[_0x33d4(0x0)](exports,_0x33d4(0x1),{'value':!![]}),exports['useAuth']=exports[_0x33d4(0x2)]=void 0x0;var _react=_interopRequireWildcard(__ONAIROS_REQ_FUNC__(0x0)),_asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x1)),_authService=__ONAIROS_REQ_FUNC__(0x2),_storageService=__ONAIROS_REQ_FUNC__(0x3);function _interopRequireDefault(_0x41b335){return _0x41b335&&_0x41b335[_0x33d4(0x1)]?_0x41b335:{'default':_0x41b335};}function _interopRequireWildcard(_0x1fd231,_0x1b854a){const _0x4c025f={'LWsdZ':function(_0x57de06,_0x45c177){return _0x57de06(_0x45c177);},'OPmeq':function(_0x2d3617,_0x252604){return _0x2d3617!==_0x252604;},'mCOrb':_0x33d4(0x3),'Unmpd':function(_0x579aa2,_0x32422f){return _0x579aa2===_0x32422f;},'hUBQA':function(_0x580bfd,_0x2ffa80){return _0x580bfd!=_0x2ffa80;},'fmINS':_0x33d4(0x4),'gugSa':_0x33d4(0x5),'XGItM':function(_0x246e3d,_0x461384){return _0x246e3d!==_0x461384;},'PvXgB':function(_0x4453f4,_0x3f38e5,_0x1a4a35,_0x100b56){return _0x4453f4(_0x3f38e5,_0x1a4a35,_0x100b56);},'Sutsi':function(_0x3241ec,_0x413aa2){return _0x3241ec==_0x413aa2;}};if(_0x4c025f[_0x33d4(0x6)](_0x4c025f['gugSa'],typeof WeakMap))var _0x1a3991=new WeakMap(),_0x365d82=new WeakMap();return(_interopRequireWildcard=function(_0x4f094a,_0x5ca477){if(_0x4c025f[_0x33d4(0x7)](_0x33d4(0x3),_0x4c025f[_0x33d4(0x8)]))_0x4c025f[_0x33d4(0x9)](_0x38ec83,_0x4c1386['parse'](_0x3f92a0)),_0x354b16(!![]);else{if(!_0x5ca477&&_0x4f094a&&_0x4f094a[_0x33d4(0x1)])return _0x4f094a;var _0x214e2e,_0x3feec8,_0x4f8481={'__proto__':null,'default':_0x4f094a};if(_0x4c025f[_0x33d4(0xa)](null,_0x4f094a)||_0x4c025f[_0x33d4(0xb)](_0x4c025f[_0x33d4(0xc)],typeof _0x4f094a)&&_0x4c025f['hUBQA'](_0x4c025f['gugSa'],typeof _0x4f094a))return _0x4f8481;if(_0x214e2e=_0x5ca477?_0x365d82:_0x1a3991){if(_0x214e2e['has'](_0x4f094a))return _0x214e2e[_0x33d4(0xd)](_0x4f094a);_0x214e2e[_0x33d4(0xe)](_0x4f094a,_0x4f8481);}for(const _0x165ecf in _0x4f094a)_0x4c025f[_0x33d4(0xf)]('default',_0x165ecf)&&{}[_0x33d4(0x10)][_0x33d4(0x11)](_0x4f094a,_0x165ecf)&&((_0x3feec8=(_0x214e2e=Object[_0x33d4(0x0)])&&Object[_0x33d4(0x12)](_0x4f094a,_0x165ecf))&&(_0x3feec8['get']||_0x3feec8[_0x33d4(0xe)])?_0x4c025f['PvXgB'](_0x214e2e,_0x4f8481,_0x165ecf,_0x3feec8):_0x4f8481[_0x165ecf]=_0x4f094a[_0x165ecf]);return _0x4f8481;}})(_0x1fd231,_0x1b854a);}function _0x33d4(_0x3168c6,_0x33d46b){_0x3168c6=_0x3168c6-0x0;const _0x5bed48=_0x3168();let _0x51aa79=_0x5bed48[_0x3168c6];return _0x51aa79;}const AuthContext=(0x0,_react[_0x33d4(0x13)])(undefined),AuthProvider=({children:_0x170781})=>{const _0x13a94f={'pmtWl':function(_0x4a2c24,_0x29b824){return _0x4a2c24(_0x29b824);},'UxGQh':_0x33d4(0x14),'YdLQk':'Failed\x20to\x20update\x20user\x20data:','gaDSS':_0x33d4(0x15),'OXDAr':function(_0x1d346a,_0x4255bf){return _0x1d346a===_0x4255bf;},'pTTQr':'rhaBo','wnHZI':_0x33d4(0x16),'MpLUL':'🎯\x20Found\x20event\x20access\x20token\x20-\x20user\x20has\x20completed\x20onboarding,\x20authentication\x20confirmed','izNlD':function(_0x7f8a1e,_0x122ea7){return _0x7f8a1e!==_0x122ea7;},'MLJmq':_0x33d4(0x17),'QQksz':_0x33d4(0x18),'puKJo':'user','VlUlF':_0x33d4(0x19),'hNxLR':_0x33d4(0x1a),'baQAT':_0x33d4(0x1b),'Muidl':_0x33d4(0x1c),'lstdK':_0x33d4(0x1d),'LkkSP':_0x33d4(0x1e),'AYQwC':_0x33d4(0x1f),'cQCyh':_0x33d4(0x20),'ZuSbE':'onboardingCompleted','EPzlQ':function(_0x5b2825,_0x5a6760){return _0x5b2825===_0x5a6760;},'DKati':'true','feWzz':'Failed\x20to\x20load\x20authentication\x20state:','jswPM':_0x33d4(0x21),'AAaVW':_0x33d4(0x22),'ipeFs':function(_0x21f174,_0x5545ef){return _0x21f174(_0x5545ef);},'JDZeX':function(_0x7f016d){return _0x7f016d();},'FLnBm':function(_0x2df91b,_0x123bb0){return _0x2df91b(_0x123bb0);},'lCVKO':'apple','VTYhv':_0x33d4(0x23),'paeRk':_0x33d4(0x24),'XOVPG':_0x33d4(0x25),'rtwpw':_0x33d4(0x26),'wxfkf':function(_0x5608f0,_0xf43a28){return _0x5608f0!==_0xf43a28;},'gDHku':'iPIqc','HExtB':_0x33d4(0x27),'BnNLv':function(_0x4e6d7a,_0x5004df){return _0x4e6d7a(_0x5004df);},'topzl':_0x33d4(0x28),'envAd':'hasConnectedOnairos','ArFiC':_0x33d4(0x29),'iWdKx':_0x33d4(0x2a),'obgeE':_0x33d4(0x2b),'FJzDE':_0x33d4(0x2c),'MqUOe':function(_0x31a8c5,_0x30f084){return _0x31a8c5(_0x30f084);},'jwKXK':'Apple\x20sign-in\x20failed:','CkQMM':_0x33d4(0x2d),'cbGbo':function(_0x3e2e2a,_0x8a8310){return _0x3e2e2a(_0x8a8310);},'iadUi':_0x33d4(0x2e),'iklZG':'FQvtV','TCSGA':function(_0x3a16dd,_0x448468){return _0x3a16dd(_0x448468);},'hBCiJ':_0x33d4(0x2f),'zlzkK':function(_0x1b6af2,_0x3990b8){return _0x1b6af2!==_0x3990b8;},'TlgYU':_0x33d4(0x30),'KLnGy':function(_0x5321e1,_0x39b1d1){return _0x5321e1(_0x39b1d1);},'KwduM':_0x33d4(0x31),'WDjfV':_0x33d4(0x32),'GMBPa':function(_0x170bdb,_0x1310b6){return _0x170bdb===_0x1310b6;},'gXUJT':_0x33d4(0x33),'UQwfo':function(_0x3f198b,_0x4c769a){return _0x3f198b(_0x4c769a);},'sNEyS':'tjptS','OdXmz':_0x33d4(0x34),'AqpLN':_0x33d4(0x35),'CgMuA':function(_0x5cf580,_0x480e05){return _0x5cf580(_0x480e05);},'iOdZc':function(_0x3915e8,_0x65111d){return _0x3915e8(_0x65111d);}},[_0x5c8005,_0x2ae69f]=(0x0,_react[_0x33d4(0x36)])(null),[_0x47cdff,_0x23bbac]=(0x0,_react[_0x33d4(0x36)])(!![]),[_0x11a123,_0x12947c]=(0x0,_react[_0x33d4(0x36)])(![]),[_0x45797d,_0x210ee0]=(0x0,_react[_0x33d4(0x36)])(![]);(0x0,_react['useEffect'])(()=>{const _0x26f0cb={'heTzD':function(_0x53c1bb,_0x524edf){return _0x13a94f[_0x33d4(0x37)](_0x53c1bb,_0x524edf);},'jBaBy':_0x13a94f[_0x33d4(0x38)],'Eekoh':_0x13a94f[_0x33d4(0x39)],'VfBDC':_0x33d4(0x32),'sHJsB':_0x13a94f['gaDSS'],'CsZrm':function(_0x282fae,_0x573659){return _0x13a94f[_0x33d4(0x3a)](_0x282fae,_0x573659);},'zlGKR':_0x13a94f[_0x33d4(0x3b)],'odRes':function(_0x14f75a,_0x2db16a){return _0x14f75a&&_0x2db16a;},'IpqAu':_0x13a94f[_0x33d4(0x3c)],'SCnFL':_0x13a94f[_0x33d4(0x3d)],'tHYXD':function(_0x334327,_0x106414){return _0x334327(_0x106414);},'YWDUF':function(_0x2bd45f,_0x4d1d3c){return _0x13a94f[_0x33d4(0x37)](_0x2bd45f,_0x4d1d3c);},'ejMwb':function(_0x4a6afd,_0x2453e2){return _0x13a94f[_0x33d4(0x3a)](_0x4a6afd,_0x2453e2);},'XGxDF':_0x33d4(0x3e),'wnkft':function(_0x151522,_0x4abd8e){return _0x13a94f[_0x33d4(0x3f)](_0x151522,_0x4abd8e);},'ELglm':_0x13a94f['MLJmq'],'LoaNf':_0x33d4(0x26),'eNLgt':'GmGSe','tQqcq':_0x13a94f[_0x33d4(0x40)],'kSLzO':_0x13a94f[_0x33d4(0x41)],'sUJZK':_0x13a94f[_0x33d4(0x42)],'RrvUC':function(_0x4d0d1c,_0x356c76){return _0x4d0d1c instanceof _0x356c76;},'zPLPs':_0x13a94f[_0x33d4(0x43)],'YUuJH':_0x33d4(0x44),'BOaLy':_0x13a94f[_0x33d4(0x45)],'MmDSP':_0x13a94f[_0x33d4(0x46)],'nIovz':_0x13a94f[_0x33d4(0x47)],'uFomL':_0x13a94f[_0x33d4(0x48)],'PPmJt':_0x13a94f[_0x33d4(0x49)],'DhCNr':_0x13a94f[_0x33d4(0x4a)],'TTXWa':_0x13a94f[_0x33d4(0x4b)],'eNgnv':function(_0x1861f3,_0x3fb269){return _0x13a94f[_0x33d4(0x4c)](_0x1861f3,_0x3fb269);},'JCnra':_0x13a94f[_0x33d4(0x4d)],'jjSaC':function(_0x25f425,_0x5538f0){return _0x25f425(_0x5538f0);},'GQXpk':_0x13a94f[_0x33d4(0x4e)],'HWTDQ':_0x13a94f['jswPM'],'hSaQp':_0x13a94f[_0x33d4(0x4f)],'UFUTC':function(_0x1ba3d6,_0x5885ab){return _0x13a94f[_0x33d4(0x50)](_0x1ba3d6,_0x5885ab);}},_0x249717=async()=>{const _0x4acfc5={'wdkUz':_0x26f0cb[_0x33d4(0x51)],'JnZfl':function(_0x3d691b,_0x6ea483){return _0x3d691b===_0x6ea483;},'Jcvca':_0x26f0cb[_0x33d4(0x52)],'nKCSE':_0x26f0cb[_0x33d4(0x53)]};try{if(_0x26f0cb[_0x33d4(0x54)](_0x33d4(0x55),_0x26f0cb[_0x33d4(0x56)])){if(_0x9344e6[_0x33d4(0x57)](_0x88468e))return _0x1ec198[_0x33d4(0xd)](_0x40ed6f);_0x42b1e3[_0x33d4(0xe)](_0x5dd0a6,_0x41759a);}else{const _0x43192b=await(0x0,_storageService[_0x33d4(0x58)])(),_0x3b1cb7=await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x5a)]('user');if(_0x26f0cb['odRes'](_0x43192b,_0x3b1cb7)){const _0x53288f=_0x26f0cb[_0x33d4(0x5b)][_0x33d4(0x5c)]('|');let _0x5def72=0x0;while(!![]){switch(_0x53288f[_0x5def72++]){case'0':_0x2ae69f(JSON[_0x33d4(0x5d)](_0x3b1cb7));continue;case'1':return;case'2':console['log'](_0x26f0cb['SCnFL']);continue;case'3':_0x26f0cb['heTzD'](_0x12947c,!![]);continue;case'4':_0x26f0cb[_0x33d4(0x5e)](_0x23bbac,![]);continue;case'5':_0x26f0cb['YWDUF'](_0x210ee0,!![]);continue;}break;}}const _0x2d2794=await(0x0,_authService['getAuthToken'])();if(_0x2d2794){if(_0x26f0cb[_0x33d4(0x5f)](_0x26f0cb['XGxDF'],'xyIKn'))_0x5cf266[_0x33d4(0x60)](_0x4acfc5[_0x33d4(0x61)],_0x127b99);else{let _0x3d4834=![];try{_0x3d4834=await(0x0,_authService[_0x33d4(0x62)])();}catch(_0x332a04){console[_0x33d4(0x63)]('🌐\x20Network\x20verification\x20failed,\x20using\x20local\x20token\x20validation:',_0x332a04),_0x3b1cb7&&(_0x26f0cb[_0x33d4(0x64)](_0x26f0cb['ELglm'],_0x33d4(0x17))?_0x26f0cb['heTzD'](_0x503b89,![]):(console[_0x33d4(0x65)](_0x26f0cb['LoaNf']),_0x3d4834=!![]));}if(_0x3d4834){if(_0x3b1cb7)_0x2ae69f(JSON[_0x33d4(0x5d)](_0x3b1cb7)),_0x210ee0(!![]);else{if(_0x26f0cb[_0x33d4(0x66)]!==_0x26f0cb[_0x33d4(0x67)])try{const _0x5b343a=await(0x0,_authService[_0x33d4(0x68)])();await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x26f0cb['kSLzO'],JSON[_0x33d4(0x6a)](_0x5b343a)),_0x26f0cb[_0x33d4(0x5e)](_0x2ae69f,_0x5b343a),_0x26f0cb['YWDUF'](_0x210ee0,!![]);}catch(_0xada852){console['error'](_0x26f0cb[_0x33d4(0x6b)],_0xada852);const _0x5d0c11=_0x26f0cb[_0x33d4(0x6c)](_0xada852,Error)?_0xada852[_0x33d4(0x6d)]:_0x26f0cb[_0x33d4(0x6e)](String,_0xada852);if(_0x5d0c11[_0x33d4(0x6f)](_0x26f0cb['zPLPs'])||_0x5d0c11[_0x33d4(0x6f)]('403'))await(0x0,_authService['removeAuthToken'])();else{console[_0x33d4(0x65)](_0x26f0cb[_0x33d4(0x70)]);if(_0x2d2794){if(_0x26f0cb['BOaLy']!==_0x26f0cb['MmDSP']){const _0x122178={'id':_0x33d4(0x71),'name':_0x26f0cb['nIovz'],'email':_0x26f0cb[_0x33d4(0x72)],'onboarded':![]};await _asyncStorage[_0x33d4(0x59)]['setItem'](_0x26f0cb['kSLzO'],JSON['stringify'](_0x122178)),_0x2ae69f(_0x122178),_0x210ee0(!![]);}else _0x1ec863[_0x33d4(0x60)](_0x33d4(0x73),_0x5ce3fa);}}}else{_0x57cc60[_0x33d4(0x60)](_0x26f0cb[_0x33d4(0x74)],_0x1a0ce6);throw _0x224bfd;}}}else{if(_0x26f0cb[_0x33d4(0x64)](_0x26f0cb['PPmJt'],_0x26f0cb['DhCNr']))await(0x0,_authService[_0x33d4(0x75)])();else{const _0x37a4c9=(0x0,_0x57bca7[_0x33d4(0x76)])(_0x33efc);if(_0x4acfc5[_0x33d4(0x77)](_0x37a4c9,_0x452f1f))throw new _0x2879e4(_0x4acfc5['Jcvca']);return _0x37a4c9;}}}}const _0x448d25=await _asyncStorage[_0x33d4(0x59)]['getItem'](_0x26f0cb[_0x33d4(0x78)]);_0x26f0cb[_0x33d4(0x79)](_0x448d25,_0x26f0cb['JCnra'])&&_0x26f0cb['jjSaC'](_0x12947c,!![]);}}catch(_0x55c243){console[_0x33d4(0x60)](_0x26f0cb[_0x33d4(0x7a)],_0x55c243);}finally{if(_0x26f0cb[_0x33d4(0x64)](_0x26f0cb[_0x33d4(0x7b)],_0x26f0cb['hSaQp']))_0x26f0cb[_0x33d4(0x7c)](_0x23bbac,![]);else{_0x240a9e[_0x33d4(0x60)](_0x4acfc5[_0x33d4(0x7d)],_0x3fca03);throw _0x5eb6bd;}}};_0x13a94f[_0x33d4(0x7e)](_0x249717);},[]);const _0x450177=async _0x34b8f7=>{try{var _0x310857;const _0x30fe06={..._0x34b8f7,'onboarded':![]};await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f['puKJo'],JSON['stringify'](_0x30fe06)),_0x13a94f['FLnBm'](_0x2ae69f,_0x30fe06),_0x13a94f['ipeFs'](_0x210ee0,!![]),await(0x0,_storageService['saveAuthState'])({'isAuthenticated':!![],'authMethod':_0x13a94f[_0x33d4(0x3f)](_0x310857=_0x34b8f7['email'],null)&&_0x13a94f[_0x33d4(0x3f)](_0x310857,void 0x0)&&_0x310857[_0x33d4(0x6f)](_0x13a94f[_0x33d4(0x7f)])?_0x13a94f[_0x33d4(0x7f)]:_0x13a94f[_0x33d4(0x80)],'hasValidToken':!![],'userEmail':_0x34b8f7[_0x33d4(0x81)],'userName':_0x34b8f7['name']}),await(0x0,_storageService['markStepCompleted'])(_0x13a94f[_0x33d4(0x82)]),console[_0x33d4(0x65)](_0x13a94f[_0x33d4(0x83)],_0x30fe06);}catch(_0x517101){console[_0x33d4(0x60)](_0x33d4(0x73),_0x517101);}},_0x4481c2=async _0x2c2479=>{if(_0x13a94f[_0x33d4(0x84)](_0x13a94f[_0x33d4(0x85)],_0x13a94f[_0x33d4(0x85)]))_0x4fa815(!![]);else try{if(_0x13a94f[_0x33d4(0x4c)](_0x13a94f[_0x33d4(0x86)],_0x33d4(0x27))){_0x13a94f['BnNLv'](_0x23bbac,!![]);const _0x30e5da=await(0x0,_authService['authenticateWithApple'])(_0x2c2479);await(0x0,_authService[_0x33d4(0x87)])(_0x30e5da[_0x33d4(0x88)]),await _asyncStorage['default'][_0x33d4(0x69)](_0x13a94f[_0x33d4(0x89)],_0x13a94f[_0x33d4(0x7f)]);_0x30e5da[_0x33d4(0x23)]?(await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f['envAd'],_0x30e5da['onairos'][_0x33d4(0x8a)][_0x33d4(0x8b)]()),_0x30e5da['onairos']['onairosUserId']&&await _asyncStorage['default'][_0x33d4(0x69)](_0x13a94f[_0x33d4(0x8c)],_0x30e5da[_0x33d4(0x23)]['onairosUserId']),_0x30e5da[_0x33d4(0x23)][_0x33d4(0x2a)]&&await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f[_0x33d4(0x8d)],_0x30e5da[_0x33d4(0x23)][_0x33d4(0x2a)]),console[_0x33d4(0x65)](_0x13a94f[_0x33d4(0x8e)],_0x30e5da[_0x33d4(0x23)][_0x33d4(0x8a)])):(await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f['envAd'],_0x13a94f['FJzDE']),console['log'](_0x33d4(0x8f)));const _0x2209b4={'id':_0x30e5da['user']['id'],'name':_0x30e5da[_0x33d4(0x90)][_0x33d4(0x91)]||_0x13a94f[_0x33d4(0x47)],'email':_0x30e5da[_0x33d4(0x90)][_0x33d4(0x81)],'profilePicture':_0x30e5da[_0x33d4(0x90)][_0x33d4(0x92)],'onboarded':![]};return await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f[_0x33d4(0x41)],JSON[_0x33d4(0x6a)](_0x2209b4)),_0x13a94f['FLnBm'](_0x2ae69f,_0x2209b4),_0x13a94f[_0x33d4(0x93)](_0x210ee0,!![]),console[_0x33d4(0x65)](_0x33d4(0x94)),_0x2209b4;}else _0x108c9c['warn'](_0x33d4(0x95),_0x353352),_0x2de0c1&&(_0x19127e[_0x33d4(0x65)](_0x13a94f[_0x33d4(0x96)]),_0x2f63c9=!![]);}catch(_0x3566f9){console['error'](_0x13a94f[_0x33d4(0x97)],_0x3566f9);throw _0x3566f9;}finally{_0x13a94f[_0x33d4(0x98)](_0x23bbac,![]);}},_0x1d06e6=async _0x444a09=>{const _0xbedaf8={'HMjYS':_0x13a94f[_0x33d4(0x3d)],'MGGFU':function(_0x5434ab,_0x249daf){return _0x5434ab(_0x249daf);},'UyMGA':function(_0x3bdf94,_0x515c5c){return _0x13a94f['ipeFs'](_0x3bdf94,_0x515c5c);},'RIpxl':function(_0x2c717a,_0x3531d4){return _0x13a94f['cbGbo'](_0x2c717a,_0x3531d4);}};if(_0x33d4(0x99)===_0x13a94f[_0x33d4(0x9a)]){_0x48a156[_0x33d4(0x60)](_0x13a94f[_0x33d4(0x9b)],_0x5e6974);throw _0x3546e3;}else try{_0x13a94f[_0x33d4(0x9c)](_0x23bbac,!![]);const _0x26cd4e=await(0x0,_authService[_0x33d4(0x9d)])(_0x444a09);await(0x0,_authService[_0x33d4(0x87)])(_0x26cd4e[_0x33d4(0x88)]),await _asyncStorage['default']['setItem'](_0x13a94f[_0x33d4(0x89)],_0x13a94f[_0x33d4(0x80)]);const _0x46fe79={'id':_0x26cd4e[_0x33d4(0x90)]['id'],'name':_0x26cd4e[_0x33d4(0x90)]['name']||_0x13a94f[_0x33d4(0x47)],'email':_0x26cd4e[_0x33d4(0x90)][_0x33d4(0x81)],'profilePicture':_0x26cd4e[_0x33d4(0x90)]['profilePicture'],'onboarded':![]};return await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f[_0x33d4(0x41)],JSON['stringify'](_0x46fe79)),_0x2ae69f(_0x46fe79),_0x210ee0(!![]),console[_0x33d4(0x65)]('🔑\x20Onairos\x20sign-in\x20completed\x20-\x20auth_method\x20set\x20to\x20\x22onairos\x22'),_0x46fe79;}catch(_0x2c56b9){if(_0x13a94f['wxfkf'](_0x13a94f[_0x33d4(0x9e)],_0x13a94f[_0x33d4(0x9e)])){const _0x2be5f0=_0x33d4(0x9f)[_0x33d4(0x5c)]('|');let _0x2ef8ff=0x0;while(!![]){switch(_0x2be5f0[_0x2ef8ff++]){case'0':_0x20e35e[_0x33d4(0x65)](_0xbedaf8[_0x33d4(0xa0)]);continue;case'1':_0xbedaf8[_0x33d4(0xa1)](_0x4fae94,_0x826b83['parse'](_0x57494c));continue;case'2':_0xbedaf8[_0x33d4(0xa1)](_0x3e02c7,!![]);continue;case'3':return;case'4':_0xbedaf8[_0x33d4(0xa2)](_0x3c3a5d,!![]);continue;case'5':_0xbedaf8[_0x33d4(0xa3)](_0xc57688,![]);continue;}break;}}else{console[_0x33d4(0x60)](_0x33d4(0x14),_0x2c56b9);throw _0x2c56b9;}}finally{_0x13a94f[_0x33d4(0xa4)](_0x23bbac,![]);}},_0x399d56=async()=>{const _0x261e77={'yEqOz':function(_0x2c0a4a,_0x3a9e1c){return _0x13a94f['TCSGA'](_0x2c0a4a,_0x3a9e1c);}};try{_0x13a94f[_0x33d4(0x3f)]('TWecf',_0x13a94f[_0x33d4(0xa5)])?_0x261e77[_0x33d4(0xa6)](_0x35e090,![]):(await(0x0,_storageService[_0x33d4(0xa7)])(),_0x13a94f[_0x33d4(0x37)](_0x2ae69f,null),_0x13a94f[_0x33d4(0x37)](_0x210ee0,![]));}catch(_0x4bbd59){_0x13a94f[_0x33d4(0xa8)](_0x33d4(0xa9),_0x33d4(0xaa))?console[_0x33d4(0x60)](_0x13a94f[_0x33d4(0xab)],_0x4bbd59):_0x261e77[_0x33d4(0xa6)](_0x295464,![]);}},_0x1897f0=async _0x54d8dc=>{try{const _0x44e100={..._0x5c8005,..._0x54d8dc};await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f[_0x33d4(0x41)],JSON[_0x33d4(0x6a)](_0x44e100)),_0x13a94f[_0x33d4(0xac)](_0x2ae69f,_0x44e100),await _0x4b3c66();}catch(_0x5359dd){console[_0x33d4(0x60)](_0x13a94f['KwduM'],_0x5359dd);throw _0x5359dd;}},_0x406018=async _0x449ba4=>{const _0x10c4b9={'QDNFV':_0x13a94f[_0x33d4(0xad)]};try{if(_0x13a94f[_0x33d4(0xae)](_0x13a94f[_0x33d4(0xaf)],_0x13a94f['gXUJT'])){if(!_0x5c8005)return;const _0x4fa1d8={..._0x5c8005,..._0x449ba4};await _asyncStorage[_0x33d4(0x59)]['setItem'](_0x13a94f[_0x33d4(0x41)],JSON[_0x33d4(0x6a)](_0x4fa1d8)),_0x2ae69f(_0x4fa1d8);}else throw new _0x5de514(_0x10c4b9[_0x33d4(0xb0)]);}catch(_0x200c0a){console['error'](_0x13a94f[_0x33d4(0x39)],_0x200c0a);}},_0x4b3c66=async()=>{try{_0x13a94f[_0x33d4(0x93)](_0x23bbac,!![]),await(0x0,_authService[_0x33d4(0xb1)])();if(_0x5c8005){const _0x181e6c={..._0x5c8005,'onboarded':!![]};await _asyncStorage[_0x33d4(0x59)][_0x33d4(0x69)](_0x13a94f['puKJo'],JSON[_0x33d4(0x6a)](_0x181e6c)),_0x13a94f[_0x33d4(0xb2)](_0x2ae69f,_0x181e6c);}}catch(_0x5ed6a3){if(_0x13a94f[_0x33d4(0xb3)]===_0x33d4(0xb4)){console[_0x33d4(0x60)](_0x13a94f[_0x33d4(0x9b)],_0x5ed6a3);throw _0x5ed6a3;}else{_0xf41980[_0x33d4(0x60)](_0x13a94f[_0x33d4(0xb5)],_0x1c0f4c);throw _0x14ad74;}}finally{_0x13a94f[_0x33d4(0xb2)](_0x23bbac,![]);}},_0xe55234=async()=>{try{const _0x52890a=_0x13a94f[_0x33d4(0xb6)][_0x33d4(0x5c)]('|');let _0x9837d1=0x0;while(!![]){switch(_0x52890a[_0x9837d1++]){case'0':await _asyncStorage['default']['removeItem'](_0x33d4(0xb7));continue;case'1':console[_0x33d4(0x65)](_0x13a94f['AqpLN']);continue;case'2':await _asyncStorage[_0x33d4(0x59)][_0x33d4(0xb8)](_0x13a94f[_0x33d4(0x41)]);continue;case'3':_0x13a94f[_0x33d4(0xb9)](_0x12947c,![]);continue;case'4':_0x210ee0(![]);continue;case'5':_0x13a94f['iOdZc'](_0x2ae69f,null);continue;case'6':await(0x0,_authService[_0x33d4(0x75)])();continue;}break;}}catch(_0x45245e){console['error'](_0x13a94f['gaDSS'],_0x45245e);throw _0x45245e;}};return _react[_0x33d4(0x59)][_0x33d4(0xba)](AuthContext[_0x33d4(0xbb)],{'value':{'user':_0x5c8005,'isLoading':_0x47cdff,'hasCompletedOnboarding':_0x11a123,'login':_0x450177,'logout':_0x399d56,'deleteAccount':_0xe55234,'completeOnboarding':_0x1897f0,'updateUser':_0x406018,'appleSignIn':_0x4481c2,'onairosSignIn':_0x1d06e6,'isAuthenticated':_0x45797d,'updateOnboardedStatus':_0x4b3c66,'getResumeTarget':_storageService[_0x33d4(0xbc)],'markStepCompleted':_storageService[_0x33d4(0xbd)],'updateLastScreen':_storageService[_0x33d4(0xbe)],'isReturningUser':_storageService[_0x33d4(0xbf)],'markEventPageReached':_storageService[_0x33d4(0xc0)],'hasEventAccessToken':_storageService[_0x33d4(0x58)]}},_0x170781);};exports[_0x33d4(0x2)]=AuthProvider;function _0x3168(){const _0x57cf90=['defineProperty','__esModule','AuthProvider','qlmVw','object','function','Sutsi','OPmeq','mCOrb','LWsdZ','Unmpd','hUBQA','fmINS','get','set','XGItM','hasOwnProperty','call','getOwnPropertyDescriptor','createContext','Onairos\x20sign-in\x20failed:','Failed\x20to\x20delete\x20account:','2|0|5|3|4|1','zcpha','MRrbW','Failed\x20to\x20fetch\x20user\x20profile:','401','xlCEF','FgABm','Onairos\x20User','user@onairos.com','cNkoI','NDthm','oVRRP','DSUUd','onairos','authentication','User\x20logged\x20in\x20with\x20onboarded=false:','💾\x20Network\x20unreachable,\x20trusting\x20local\x20authentication\x20state','IoPgN','auth_method','onairosUserId','lastConnectedAt','🔗\x20Stored\x20Onairos\x20connection\x20status:','false','Failed\x20to\x20update\x20onboarded\x20status:','glNQt','TWecf','Failed\x20to\x20remove\x20user\x20data:','Failed\x20to\x20complete\x20onboarding:','useAuth\x20must\x20be\x20used\x20within\x20an\x20AuthProvider','VVlTU','2|6|0|5|4|3|1','Account\x20deleted\x20successfully','useState','pmtWl','UxGQh','YdLQk','OXDAr','pTTQr','wnHZI','MpLUL','RjpUM','izNlD','QQksz','puKJo','VlUlF','hNxLR','🌐\x20Profile\x20fetch\x20failed\x20(likely\x20network),\x20keeping\x20authentication\x20state','baQAT','Muidl','lstdK','LkkSP','AYQwC','cQCyh','ZuSbE','EPzlQ','DKati','feWzz','AAaVW','ipeFs','Eekoh','VfBDC','sHJsB','CsZrm','WYsjM','zlGKR','has','hasEventAccessToken','default','getItem','IpqAu','split','parse','tHYXD','ejMwb','error','wdkUz','verifyToken','warn','wnkft','log','eNLgt','tQqcq','getUserProfile','setItem','stringify','sUJZK','RrvUC','message','YWDUF','includes','YUuJH','offline_user','uFomL','Failed\x20to\x20save\x20user\x20data:','jBaBy','removeAuthToken','useContext','JnZfl','TTXWa','eNgnv','GQXpk','HWTDQ','UFUTC','nKCSE','JDZeX','lCVKO','VTYhv','email','paeRk','XOVPG','wxfkf','gDHku','HExtB','saveAuthToken','token','topzl','hasConnectedOnairos','toString','ArFiC','iWdKx','obgeE','🔗\x20No\x20Onairos\x20connection\x20info\x20from\x20backend,\x20defaulting\x20to\x20false','user','name','profilePicture','MqUOe','🍎\x20Apple\x20sign-in\x20completed\x20-\x20auth_method\x20set\x20to\x20\x22apple\x22','🌐\x20Network\x20verification\x20failed,\x20using\x20local\x20token\x20validation:','rtwpw','jwKXK','FLnBm','jkaPi','iadUi','CkQMM','cbGbo','authenticateWithOnairos','iklZG','0|1|2|4|5|3','HMjYS','MGGFU','UyMGA','RIpxl','TCSGA','hBCiJ','yEqOz','clearUserData','zlzkK','LXDZj','sbkOb','TlgYU','KLnGy','WDjfV','GMBPa','gXUJT','QDNFV','updateUserOnboardedStatus','UQwfo','sNEyS','tjptS','KwduM','OdXmz','onboardingCompleted','removeItem','CgMuA','createElement','Provider','getResumeTarget','markStepCompleted','updateLastScreen','isReturningUser','markEventPageReached','tYIqz','IRhhT','useAuth'];_0x3168=function(){return _0x57cf90;};return _0x3168();}const useAuth=()=>{const _0xd45244={'tYIqz':function(_0x1cdfd5,_0x303fd0){return _0x1cdfd5===_0x303fd0;},'IRhhT':'useAuth\x20must\x20be\x20used\x20within\x20an\x20AuthProvider'},_0x27c468=(0x0,_react['useContext'])(AuthContext);if(_0xd45244[_0x33d4(0xc1)](_0x27c468,undefined))throw new Error(_0xd45244[_0x33d4(0xc2)]);return _0x27c468;};exports[_0x33d4(0xc3)]=useAuth;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAuth = exports.AuthProvider = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
+
var _authService = require("../services/authService");
|
|
10
|
+
var _storageService = require("../services/storageService");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
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); }
|
|
13
|
+
const AuthContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
14
|
+
const AuthProvider = ({
|
|
15
|
+
children
|
|
16
|
+
}) => {
|
|
17
|
+
const [user, setUser] = (0, _react.useState)(null);
|
|
18
|
+
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
19
|
+
const [hasCompletedOnboarding, setHasCompletedOnboarding] = (0, _react.useState)(false);
|
|
20
|
+
const [isAuthenticated, setIsAuthenticated] = (0, _react.useState)(false);
|
|
21
|
+
(0, _react.useEffect)(() => {
|
|
22
|
+
// Check if user is already logged in
|
|
23
|
+
const loadStoredUser = async () => {
|
|
24
|
+
try {
|
|
25
|
+
// PRIORITY 1: Check if user has completed onboarding (for release mode reliability)
|
|
26
|
+
const hasEventToken = await (0, _storageService.hasEventAccessToken)();
|
|
27
|
+
const storedUser = await _asyncStorage.default.getItem('user');
|
|
28
|
+
if (hasEventToken && storedUser) {
|
|
29
|
+
console.log('🎯 Found event access token - user has completed onboarding, authentication confirmed');
|
|
30
|
+
setUser(JSON.parse(storedUser));
|
|
31
|
+
setIsAuthenticated(true);
|
|
32
|
+
setHasCompletedOnboarding(true);
|
|
33
|
+
setIsLoading(false);
|
|
34
|
+
return; // Skip network verification for completed users
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// PRIORITY 2: Check if we have a JWT token for users still in onboarding
|
|
38
|
+
const token = await (0, _authService.getAuthToken)();
|
|
39
|
+
if (token) {
|
|
40
|
+
// For users with tokens but no completion token, try network verification
|
|
41
|
+
// but don't fail if network is unreachable (important for release mode)
|
|
42
|
+
let isValid = false;
|
|
43
|
+
try {
|
|
44
|
+
isValid = await (0, _authService.verifyToken)();
|
|
45
|
+
} catch (networkError) {
|
|
46
|
+
console.warn('🌐 Network verification failed, using local token validation:', networkError);
|
|
47
|
+
// In release mode, network might be slow/unreliable
|
|
48
|
+
// If we have a token and stored user, trust the local state
|
|
49
|
+
if (storedUser) {
|
|
50
|
+
console.log('💾 Network unreachable, trusting local authentication state');
|
|
51
|
+
isValid = true; // Trust local state when network fails
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (isValid) {
|
|
55
|
+
// Token is valid (or we're trusting local state), get user data
|
|
56
|
+
if (storedUser) {
|
|
57
|
+
setUser(JSON.parse(storedUser));
|
|
58
|
+
setIsAuthenticated(true);
|
|
59
|
+
} else {
|
|
60
|
+
// If user data is not in AsyncStorage, try to fetch it
|
|
61
|
+
try {
|
|
62
|
+
const userData = await (0, _authService.getUserProfile)();
|
|
63
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(userData));
|
|
64
|
+
setUser(userData);
|
|
65
|
+
setIsAuthenticated(true);
|
|
66
|
+
} catch (profileError) {
|
|
67
|
+
console.error('Failed to fetch user profile:', profileError);
|
|
68
|
+
// Only remove token if we're sure it's invalid (not just network issues)
|
|
69
|
+
const errorMessage = profileError instanceof Error ? profileError.message : String(profileError);
|
|
70
|
+
if (errorMessage.includes('401') || errorMessage.includes('403')) {
|
|
71
|
+
await (0, _authService.removeAuthToken)();
|
|
72
|
+
} else {
|
|
73
|
+
console.log('🌐 Profile fetch failed (likely network), keeping authentication state');
|
|
74
|
+
// Create fallback user for offline scenarios
|
|
75
|
+
if (token) {
|
|
76
|
+
const fallbackUser = {
|
|
77
|
+
id: 'offline_user',
|
|
78
|
+
name: 'Onairos User',
|
|
79
|
+
email: 'user@onairos.com',
|
|
80
|
+
onboarded: false
|
|
81
|
+
};
|
|
82
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(fallbackUser));
|
|
83
|
+
setUser(fallbackUser);
|
|
84
|
+
setIsAuthenticated(true);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
// Token verification definitely failed - remove it
|
|
91
|
+
await (0, _authService.removeAuthToken)();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const onboardingCompleted = await _asyncStorage.default.getItem('onboardingCompleted');
|
|
95
|
+
if (onboardingCompleted === 'true') {
|
|
96
|
+
setHasCompletedOnboarding(true);
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error('Failed to load authentication state:', error);
|
|
100
|
+
} finally {
|
|
101
|
+
setIsLoading(false);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
loadStoredUser();
|
|
105
|
+
}, []);
|
|
106
|
+
const login = async userData => {
|
|
107
|
+
try {
|
|
108
|
+
var _userData$email;
|
|
109
|
+
// Ensure onboarded is set to false for new users
|
|
110
|
+
const userWithOnboarded = {
|
|
111
|
+
...userData,
|
|
112
|
+
onboarded: false // Always force camera flow for new logins
|
|
113
|
+
};
|
|
114
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(userWithOnboarded));
|
|
115
|
+
setUser(userWithOnboarded);
|
|
116
|
+
setIsAuthenticated(true);
|
|
117
|
+
|
|
118
|
+
// Save auth state and mark authentication step as completed
|
|
119
|
+
await (0, _storageService.saveAuthState)({
|
|
120
|
+
isAuthenticated: true,
|
|
121
|
+
authMethod: (_userData$email = userData.email) !== null && _userData$email !== void 0 && _userData$email.includes('apple') ? 'apple' : 'onairos',
|
|
122
|
+
hasValidToken: true,
|
|
123
|
+
userEmail: userData.email,
|
|
124
|
+
userName: userData.name
|
|
125
|
+
});
|
|
126
|
+
await (0, _storageService.markStepCompleted)('authentication');
|
|
127
|
+
console.log('User logged in with onboarded=false:', userWithOnboarded);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error('Failed to save user data:', error);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Handle Apple Sign-In
|
|
134
|
+
const appleSignIn = async appleAuthData => {
|
|
135
|
+
try {
|
|
136
|
+
setIsLoading(true);
|
|
137
|
+
|
|
138
|
+
// Call the API to authenticate with Apple
|
|
139
|
+
const authResponse = await (0, _authService.authenticateWithApple)(appleAuthData);
|
|
140
|
+
|
|
141
|
+
// Save the JWT token
|
|
142
|
+
await (0, _authService.saveAuthToken)(authResponse.token);
|
|
143
|
+
|
|
144
|
+
// CRITICAL: Save auth method as 'apple' for proper button logic
|
|
145
|
+
await _asyncStorage.default.setItem('auth_method', 'apple');
|
|
146
|
+
|
|
147
|
+
// Save Onairos connection status from backend response
|
|
148
|
+
if (authResponse.onairos) {
|
|
149
|
+
await _asyncStorage.default.setItem('hasConnectedOnairos', authResponse.onairos.hasConnectedOnairos.toString());
|
|
150
|
+
if (authResponse.onairos.onairosUserId) {
|
|
151
|
+
await _asyncStorage.default.setItem('onairosUserId', authResponse.onairos.onairosUserId);
|
|
152
|
+
}
|
|
153
|
+
if (authResponse.onairos.lastConnectedAt) {
|
|
154
|
+
await _asyncStorage.default.setItem('lastConnectedAt', authResponse.onairos.lastConnectedAt);
|
|
155
|
+
}
|
|
156
|
+
console.log('🔗 Stored Onairos connection status:', authResponse.onairos.hasConnectedOnairos);
|
|
157
|
+
} else {
|
|
158
|
+
// Default to false if no Onairos info provided
|
|
159
|
+
await _asyncStorage.default.setItem('hasConnectedOnairos', 'false');
|
|
160
|
+
console.log('🔗 No Onairos connection info from backend, defaulting to false');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Create user object from response
|
|
164
|
+
const userData = {
|
|
165
|
+
id: authResponse.user.id,
|
|
166
|
+
name: authResponse.user.name || 'Onairos User',
|
|
167
|
+
email: authResponse.user.email,
|
|
168
|
+
profilePicture: authResponse.user.profilePicture,
|
|
169
|
+
onboarded: false // Default to false for new Apple sign-ins
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// Save user data to AsyncStorage and update state
|
|
173
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(userData));
|
|
174
|
+
setUser(userData);
|
|
175
|
+
setIsAuthenticated(true);
|
|
176
|
+
console.log('🍎 Apple sign-in completed - auth_method set to "apple"');
|
|
177
|
+
return userData;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('Apple sign-in failed:', error);
|
|
180
|
+
throw error;
|
|
181
|
+
} finally {
|
|
182
|
+
setIsLoading(false);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// Handle Onairos Sign-In (similar to Apple)
|
|
187
|
+
const onairosSignIn = async onairosAuthData => {
|
|
188
|
+
try {
|
|
189
|
+
setIsLoading(true);
|
|
190
|
+
|
|
191
|
+
// Call the API to authenticate with Onairos
|
|
192
|
+
const authResponse = await (0, _authService.authenticateWithOnairos)(onairosAuthData);
|
|
193
|
+
|
|
194
|
+
// Save the JWT token
|
|
195
|
+
await (0, _authService.saveAuthToken)(authResponse.token);
|
|
196
|
+
|
|
197
|
+
// CRITICAL: Save auth method as 'onairos' for proper button logic
|
|
198
|
+
await _asyncStorage.default.setItem('auth_method', 'onairos');
|
|
199
|
+
|
|
200
|
+
// Create user object from response
|
|
201
|
+
const userData = {
|
|
202
|
+
id: authResponse.user.id,
|
|
203
|
+
name: authResponse.user.name || 'Onairos User',
|
|
204
|
+
email: authResponse.user.email,
|
|
205
|
+
profilePicture: authResponse.user.profilePicture,
|
|
206
|
+
onboarded: false // Default to false for new Onairos sign-ins
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// Save user data to AsyncStorage and update state
|
|
210
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(userData));
|
|
211
|
+
setUser(userData);
|
|
212
|
+
setIsAuthenticated(true);
|
|
213
|
+
console.log('🔑 Onairos sign-in completed - auth_method set to "onairos"');
|
|
214
|
+
return userData;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.error('Onairos sign-in failed:', error);
|
|
217
|
+
throw error;
|
|
218
|
+
} finally {
|
|
219
|
+
setIsLoading(false);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
const logout = async () => {
|
|
223
|
+
try {
|
|
224
|
+
// Clear all user data using the new storage service
|
|
225
|
+
await (0, _storageService.clearUserData)();
|
|
226
|
+
setUser(null);
|
|
227
|
+
setIsAuthenticated(false);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error('Failed to remove user data:', error);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const completeOnboarding = async userData => {
|
|
233
|
+
try {
|
|
234
|
+
// Update user data
|
|
235
|
+
const updatedUser = {
|
|
236
|
+
...user,
|
|
237
|
+
...userData
|
|
238
|
+
};
|
|
239
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(updatedUser));
|
|
240
|
+
setUser(updatedUser);
|
|
241
|
+
|
|
242
|
+
// Update onboarded status on backend
|
|
243
|
+
await updateOnboardedStatus();
|
|
244
|
+
} catch (error) {
|
|
245
|
+
console.error('Failed to complete onboarding:', error);
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const updateUser = async userData => {
|
|
250
|
+
try {
|
|
251
|
+
if (!user) return;
|
|
252
|
+
const updatedUser = {
|
|
253
|
+
...user,
|
|
254
|
+
...userData
|
|
255
|
+
};
|
|
256
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(updatedUser));
|
|
257
|
+
setUser(updatedUser);
|
|
258
|
+
} catch (error) {
|
|
259
|
+
console.error('Failed to update user data:', error);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// Update user onboarded status
|
|
264
|
+
const updateOnboardedStatus = async () => {
|
|
265
|
+
try {
|
|
266
|
+
setIsLoading(true);
|
|
267
|
+
|
|
268
|
+
// Call the API to update onboarded status
|
|
269
|
+
await (0, _authService.updateUserOnboardedStatus)();
|
|
270
|
+
|
|
271
|
+
// Update local user data
|
|
272
|
+
if (user) {
|
|
273
|
+
const updatedUser = {
|
|
274
|
+
...user,
|
|
275
|
+
onboarded: true
|
|
276
|
+
};
|
|
277
|
+
await _asyncStorage.default.setItem('user', JSON.stringify(updatedUser));
|
|
278
|
+
setUser(updatedUser);
|
|
279
|
+
}
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error('Failed to update onboarded status:', error);
|
|
282
|
+
throw error;
|
|
283
|
+
} finally {
|
|
284
|
+
setIsLoading(false);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const deleteAccount = async () => {
|
|
288
|
+
try {
|
|
289
|
+
// In a real app, you would make an API call to delete the user account on the server
|
|
290
|
+
// For example: await api.deleteUser(user.id);
|
|
291
|
+
|
|
292
|
+
// Remove user data from AsyncStorage
|
|
293
|
+
await _asyncStorage.default.removeItem('user');
|
|
294
|
+
|
|
295
|
+
// Remove JWT token
|
|
296
|
+
await (0, _authService.removeAuthToken)();
|
|
297
|
+
|
|
298
|
+
// Clear any other user-related data from AsyncStorage
|
|
299
|
+
await _asyncStorage.default.removeItem('onboardingCompleted');
|
|
300
|
+
|
|
301
|
+
// Update state
|
|
302
|
+
setUser(null);
|
|
303
|
+
setIsAuthenticated(false);
|
|
304
|
+
setHasCompletedOnboarding(false);
|
|
305
|
+
console.log('Account deleted successfully');
|
|
306
|
+
} catch (error) {
|
|
307
|
+
console.error('Failed to delete account:', error);
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
return /*#__PURE__*/_react.default.createElement(AuthContext.Provider, {
|
|
312
|
+
value: {
|
|
313
|
+
user,
|
|
314
|
+
isLoading,
|
|
315
|
+
hasCompletedOnboarding,
|
|
316
|
+
login,
|
|
317
|
+
logout,
|
|
318
|
+
deleteAccount,
|
|
319
|
+
completeOnboarding,
|
|
320
|
+
updateUser,
|
|
321
|
+
appleSignIn,
|
|
322
|
+
onairosSignIn,
|
|
323
|
+
isAuthenticated,
|
|
324
|
+
updateOnboardedStatus,
|
|
325
|
+
// Progress tracking methods
|
|
326
|
+
getResumeTarget: _storageService.getResumeTarget,
|
|
327
|
+
markStepCompleted: _storageService.markStepCompleted,
|
|
328
|
+
updateLastScreen: _storageService.updateLastScreen,
|
|
329
|
+
isReturningUser: _storageService.isReturningUser,
|
|
330
|
+
// Event access token methods
|
|
331
|
+
markEventPageReached: _storageService.markEventPageReached,
|
|
332
|
+
hasEventAccessToken: _storageService.hasEventAccessToken
|
|
333
|
+
}
|
|
334
|
+
}, children);
|
|
335
|
+
};
|
|
336
|
+
exports.AuthProvider = AuthProvider;
|
|
337
|
+
const useAuth = () => {
|
|
338
|
+
const context = (0, _react.useContext)(AuthContext);
|
|
339
|
+
if (context === undefined) {
|
|
340
|
+
throw new Error('useAuth must be used within an AuthProvider');
|
|
341
|
+
}
|
|
342
|
+
return context;
|
|
343
|
+
};
|
|
344
|
+
exports.useAuth = useAuth;
|
|
345
|
+
//# sourceMappingURL=AuthContext.js.map
|