@onairos/react-native 3.0.38 → 3.0.40
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/components/TrainingModal.js +183 -13
- package/lib/commonjs/components/TrainingModal.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +51 -16
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js +40 -68
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/components/TrainingModal.js +183 -14
- package/lib/module/components/TrainingModal.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +51 -16
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js +40 -68
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/TrainingModal.tsx +190 -10
- package/src/components/UniversalOnboarding.tsx +53 -15
- package/src/components/onboarding/OAuthWebView.tsx +51 -113
|
@@ -257,9 +257,8 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
257
257
|
|
|
258
258
|
// Function to handle "Already have an account" button
|
|
259
259
|
const handleAlreadyHaveAccount = useCallback(() => {
|
|
260
|
-
console.log('Already have an account clicked - opening login WebView');
|
|
260
|
+
console.log('Already have an account clicked - opening Onairos login WebView');
|
|
261
261
|
setShowLoginWebView(true);
|
|
262
|
-
// TODO: Open WebView to check for existing Onairos login details
|
|
263
262
|
}, []);
|
|
264
263
|
|
|
265
264
|
// Function to check for existing account (spoofed for now)
|
|
@@ -271,15 +270,55 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
271
270
|
}, []);
|
|
272
271
|
|
|
273
272
|
// Function to handle login WebView completion
|
|
274
|
-
const handleLoginWebViewComplete = useCallback(() => {
|
|
275
|
-
console.log('Login WebView completed');
|
|
273
|
+
const handleLoginWebViewComplete = useCallback((result?: any) => {
|
|
274
|
+
console.log('Login WebView completed with result:', result);
|
|
276
275
|
setShowLoginWebView(false);
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
|
|
277
|
+
// If login was successful (detected existing cookies/session)
|
|
278
|
+
if (result === 'onairos_login_success') {
|
|
279
|
+
console.log('Existing Onairos account detected, skipping onboarding');
|
|
280
|
+
// Skip the entire onboarding flow and call onComplete directly
|
|
281
|
+
onComplete('https://api2.onairos.uk', 'existing-session-token', {
|
|
282
|
+
existingAccount: true,
|
|
283
|
+
username: 'existing_user',
|
|
284
|
+
skipOnboarding: true,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
// If no existing account found, continue with normal onboarding
|
|
288
|
+
}, [onComplete]);
|
|
279
289
|
|
|
280
290
|
const handlePinSubmit = useCallback(async (userPin: string) => {
|
|
281
291
|
setPin(userPin);
|
|
282
292
|
setStep('training');
|
|
293
|
+
|
|
294
|
+
// Save session data for "Never Connect Again" functionality
|
|
295
|
+
try {
|
|
296
|
+
const sessionData = {
|
|
297
|
+
pin: userPin,
|
|
298
|
+
connections,
|
|
299
|
+
platformToggles,
|
|
300
|
+
selectedTier,
|
|
301
|
+
username,
|
|
302
|
+
timestamp: Date.now(),
|
|
303
|
+
appName: AppName,
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// Store session data in secure storage for future use
|
|
307
|
+
console.log('Saving session data for future "Never Connect Again" functionality:', sessionData);
|
|
308
|
+
|
|
309
|
+
// TODO: Implement actual secure storage of session data
|
|
310
|
+
// This would typically involve:
|
|
311
|
+
// 1. Storing encrypted session data locally
|
|
312
|
+
// 2. Setting cookies in WebView for onairos.uk domain
|
|
313
|
+
// 3. Storing authentication tokens securely
|
|
314
|
+
|
|
315
|
+
// For now, we'll simulate this with console logging
|
|
316
|
+
console.log('Session data saved - future apps will detect existing account');
|
|
317
|
+
|
|
318
|
+
} catch (error) {
|
|
319
|
+
console.error('Failed to save session data:', error);
|
|
320
|
+
}
|
|
321
|
+
|
|
283
322
|
// Simulate training progress over 10 seconds
|
|
284
323
|
let progress = 0;
|
|
285
324
|
const interval = setInterval(() => {
|
|
@@ -297,10 +336,11 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
297
336
|
platformToggles,
|
|
298
337
|
selectedTier,
|
|
299
338
|
tierData: requestData?.[selectedTier],
|
|
339
|
+
sessionSaved: true, // Indicate that session was saved
|
|
300
340
|
});
|
|
301
341
|
}
|
|
302
342
|
}, 1000); // Update every 1 second
|
|
303
|
-
}, [connections, onComplete, selectedTier, requestData, platformToggles]);
|
|
343
|
+
}, [connections, onComplete, selectedTier, requestData, platformToggles, username, AppName]);
|
|
304
344
|
|
|
305
345
|
const canProceedToPin = useCallback(() => {
|
|
306
346
|
// Check if at least one platform is toggled on
|
|
@@ -455,13 +495,14 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
455
495
|
|
|
456
496
|
<Text style={styles.successTitle}>Never Connect Again!</Text>
|
|
457
497
|
<Text style={styles.successSubtitle}>
|
|
458
|
-
|
|
498
|
+
Your login session has been saved
|
|
459
499
|
</Text>
|
|
460
500
|
|
|
461
501
|
<View style={styles.successMessage}>
|
|
462
502
|
<Text style={styles.successMessageText}>
|
|
463
|
-
Your connections are saved
|
|
464
|
-
you'll be automatically
|
|
503
|
+
Your Onairos account and platform connections are now saved in your browser cookies.
|
|
504
|
+
Next time you use any app with Onairos, you'll be automatically signed in without
|
|
505
|
+
needing to reconnect your accounts.
|
|
465
506
|
</Text>
|
|
466
507
|
</View>
|
|
467
508
|
|
|
@@ -520,13 +561,10 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
520
561
|
{/* Login WebView for existing account check */}
|
|
521
562
|
{showLoginWebView && (
|
|
522
563
|
<OAuthWebView
|
|
523
|
-
url="https://onairos.uk/
|
|
564
|
+
url="https://onairos.uk/signin"
|
|
524
565
|
platform="onairos"
|
|
525
566
|
onClose={() => setShowLoginWebView(false)}
|
|
526
|
-
onSuccess={
|
|
527
|
-
console.log('Login successful:', result);
|
|
528
|
-
handleLoginWebViewComplete();
|
|
529
|
-
}}
|
|
567
|
+
onSuccess={handleLoginWebViewComplete}
|
|
530
568
|
onComplete={handleLoginWebViewComplete}
|
|
531
569
|
/>
|
|
532
570
|
)}
|
|
@@ -71,6 +71,11 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
71
71
|
const handleNavigationStateChange = (navState: any) => {
|
|
72
72
|
console.log(`Navigation state changed for ${platform}:`, navState.url);
|
|
73
73
|
|
|
74
|
+
// Don't process navigation changes while still loading the initial page
|
|
75
|
+
if (isLoading) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
// Check for error states first
|
|
75
80
|
if (navState.url.includes('error=') || navState.url.includes('access_denied')) {
|
|
76
81
|
console.log('OAuth error detected:', navState.url);
|
|
@@ -78,138 +83,71 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
78
83
|
return;
|
|
79
84
|
}
|
|
80
85
|
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
navState.url.includes('onairos.uk/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// Enhanced platform-specific success patterns
|
|
91
|
-
const platformSuccessPatterns: Record<string, RegExp[]> = {
|
|
92
|
-
reddit: [
|
|
93
|
-
/reddit\.com\/api\/v1\/authorize\?done=true/,
|
|
94
|
-
/reddit\.com\/api\/v1\/authorize\/success/,
|
|
95
|
-
/reddit\.com.*code=/
|
|
96
|
-
],
|
|
97
|
-
pinterest: [
|
|
98
|
-
/pinterest\.com\/oauth\/success/,
|
|
99
|
-
/pinterest\.com\/oauth\/complete/,
|
|
100
|
-
/pinterest\.com.*code=/,
|
|
101
|
-
/api2\.onairos\.uk\/pinterest\/callback/,
|
|
102
|
-
/onairos\.uk.*pinterest/
|
|
103
|
-
],
|
|
104
|
-
linkedin: [
|
|
105
|
-
/linkedin\.com\/oauth\/success/,
|
|
106
|
-
/linkedin\.com\/oauth\/complete/,
|
|
107
|
-
/linkedin\.com\/uas\/oauth2\/authorization\/success/,
|
|
108
|
-
/linkedin\.com.*code=/
|
|
109
|
-
],
|
|
110
|
-
email: [/success/, /complete/],
|
|
111
|
-
instagram: [
|
|
112
|
-
/instagram\.com\/oauth\/authorize\?done=true/,
|
|
113
|
-
/instagram\.com\/oauth\/success/,
|
|
114
|
-
/instagram\.com.*code=/,
|
|
115
|
-
/api2\.onairos\.uk\/instagram\/callback/,
|
|
116
|
-
/onairos\.uk.*instagram/
|
|
117
|
-
],
|
|
118
|
-
youtube: [
|
|
119
|
-
/accounts\.google\.com\/o\/oauth2\/approval/,
|
|
120
|
-
/youtube\.com\/oauth\/success/,
|
|
121
|
-
/accounts\.google\.com.*code=/,
|
|
122
|
-
/api2\.onairos\.uk\/youtube\/callback/
|
|
123
|
-
]
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// Check for platform-specific success patterns
|
|
127
|
-
const isPlatformSuccess = platform && platformSuccessPatterns[platform] ?
|
|
128
|
-
platformSuccessPatterns[platform].some(pattern => pattern.test(navState.url)) :
|
|
129
|
-
false;
|
|
130
|
-
|
|
131
|
-
// Check for callback URLs that might contain the authorization code
|
|
132
|
-
const isCallbackUrl = (
|
|
133
|
-
navState.url.includes('/callback') ||
|
|
134
|
-
navState.url.includes('code=') ||
|
|
135
|
-
navState.url.includes('token=') ||
|
|
136
|
-
navState.url.includes('access_token=') ||
|
|
137
|
-
navState.url.includes('api2.onairos.uk') ||
|
|
138
|
-
navState.url.includes('oauth_token=')
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
// Extract authorization code or token if present
|
|
142
|
-
let authCode = null;
|
|
143
|
-
if (isCallbackUrl) {
|
|
144
|
-
console.log('Detected callback URL with possible code/token');
|
|
145
|
-
|
|
146
|
-
// Try to extract code or token using different patterns
|
|
147
|
-
const codeMatch = navState.url.match(/code=([^&]+)/);
|
|
148
|
-
const tokenMatch = navState.url.match(/(?:token|access_token)=([^&]+)/);
|
|
149
|
-
const oauthTokenMatch = navState.url.match(/oauth_token=([^&]+)/);
|
|
150
|
-
|
|
151
|
-
if (codeMatch && codeMatch[1]) {
|
|
152
|
-
authCode = decodeURIComponent(codeMatch[1]);
|
|
153
|
-
console.log('OAuth code extracted:', authCode);
|
|
154
|
-
} else if (tokenMatch && tokenMatch[1]) {
|
|
155
|
-
authCode = decodeURIComponent(tokenMatch[1]);
|
|
156
|
-
console.log('OAuth token extracted:', authCode);
|
|
157
|
-
} else if (oauthTokenMatch && oauthTokenMatch[1]) {
|
|
158
|
-
authCode = decodeURIComponent(oauthTokenMatch[1]);
|
|
159
|
-
console.log('OAuth token extracted:', authCode);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Call onSuccess with the extracted code/token
|
|
163
|
-
if (authCode) {
|
|
164
|
-
console.log(`Calling onSuccess for ${platform} with code:`, authCode);
|
|
86
|
+
// Special handling for Onairos login page (existing account check)
|
|
87
|
+
if (platform === 'onairos') {
|
|
88
|
+
// Check if user successfully logged in to Onairos
|
|
89
|
+
if (navState.url.includes('onairos.uk/Home') ||
|
|
90
|
+
navState.url.includes('onairos.uk/dashboard') ||
|
|
91
|
+
navState.url.includes('onairos.uk/profile')) {
|
|
92
|
+
console.log('Onairos login successful - existing account detected');
|
|
165
93
|
|
|
166
|
-
// Clear timeout since
|
|
94
|
+
// Clear timeout since login completed successfully
|
|
167
95
|
if (timeoutRef.current) {
|
|
168
96
|
clearTimeout(timeoutRef.current);
|
|
169
97
|
}
|
|
170
98
|
|
|
171
|
-
onSuccess(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}, 1000);
|
|
99
|
+
onSuccess('onairos_login_success');
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// If still on login page, don't close
|
|
104
|
+
if (navState.url.includes('onairos.uk/signin') ||
|
|
105
|
+
navState.url.includes('onairos.uk/login')) {
|
|
106
|
+
console.log('Still on Onairos login page, waiting for user to complete login');
|
|
180
107
|
return;
|
|
181
108
|
}
|
|
182
109
|
}
|
|
183
110
|
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
111
|
+
// For platform OAuth flows, only close when we get the FINAL redirect from Onairos backend
|
|
112
|
+
// This happens AFTER the user has logged in and the backend has processed the OAuth callback
|
|
113
|
+
const isFinalOAuthRedirect = (
|
|
114
|
+
navState.url.includes('onairos.uk/Home') ||
|
|
115
|
+
navState.url.includes('onairos.uk/home') ||
|
|
116
|
+
navState.url.includes('onairos.uk/success') ||
|
|
117
|
+
navState.url.includes('onairos.uk/dashboard') ||
|
|
118
|
+
(navState.url.includes('onairos.uk') && navState.url.includes('complete'))
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Only close when we get the final redirect from Onairos backend
|
|
122
|
+
if (isFinalOAuthRedirect) {
|
|
123
|
+
console.log(`Final OAuth redirect detected for ${platform} - user has completed login`);
|
|
187
124
|
|
|
188
|
-
//
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
onSuccess('success');
|
|
125
|
+
// Clear timeout since OAuth completed successfully
|
|
126
|
+
if (timeoutRef.current) {
|
|
127
|
+
clearTimeout(timeoutRef.current);
|
|
192
128
|
}
|
|
193
129
|
|
|
194
|
-
|
|
195
|
-
if (onComplete) {
|
|
196
|
-
console.log('Calling onComplete to close OAuth window');
|
|
197
|
-
onComplete();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Handle specific redirect patterns that indicate completion
|
|
202
|
-
if (navState.url.includes('api2.onairos.uk') &&
|
|
203
|
-
(navState.url.includes('callback') || navState.url.includes('success'))) {
|
|
204
|
-
console.log(`Backend callback detected for ${platform}`);
|
|
205
|
-
onSuccess('backend_callback_success');
|
|
130
|
+
onSuccess('oauth_complete');
|
|
206
131
|
|
|
132
|
+
// Close the OAuth window after a short delay
|
|
207
133
|
setTimeout(() => {
|
|
208
134
|
if (onComplete) {
|
|
135
|
+
console.log('Calling onComplete to close OAuth window');
|
|
209
136
|
onComplete();
|
|
210
137
|
}
|
|
211
138
|
}, 1500);
|
|
139
|
+
return;
|
|
212
140
|
}
|
|
141
|
+
|
|
142
|
+
// Log intermediate steps but don't close the WebView
|
|
143
|
+
if (navState.url.includes('/callback') || navState.url.includes('code=')) {
|
|
144
|
+
console.log(`OAuth callback detected for ${platform}, but waiting for final redirect from Onairos backend`);
|
|
145
|
+
// Don't close here - wait for the final redirect
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Log other navigation for debugging
|
|
150
|
+
console.log(`${platform} OAuth navigation:`, navState.url);
|
|
213
151
|
};
|
|
214
152
|
|
|
215
153
|
const handleLoadEnd = () => {
|