@onairos/react-native 3.0.40 → 3.0.42

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.
Files changed (26) hide show
  1. package/lib/commonjs/components/TrainingModal.js +14 -8
  2. package/lib/commonjs/components/TrainingModal.js.map +1 -1
  3. package/lib/commonjs/components/UniversalOnboarding.js +21 -9
  4. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  5. package/lib/commonjs/components/onboarding/OAuthWebView.js +56 -5
  6. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
  7. package/lib/commonjs/services/platformAuthService.js +64 -1
  8. package/lib/commonjs/services/platformAuthService.js.map +1 -1
  9. package/lib/module/components/TrainingModal.js +14 -8
  10. package/lib/module/components/TrainingModal.js.map +1 -1
  11. package/lib/module/components/UniversalOnboarding.js +23 -11
  12. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  13. package/lib/module/components/onboarding/OAuthWebView.js +56 -5
  14. package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
  15. package/lib/module/services/platformAuthService.js +62 -0
  16. package/lib/module/services/platformAuthService.js.map +1 -1
  17. package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
  18. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
  19. package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
  20. package/lib/typescript/services/platformAuthService.d.ts +7 -0
  21. package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
  22. package/package.json +2 -1
  23. package/src/components/TrainingModal.tsx +13 -7
  24. package/src/components/UniversalOnboarding.tsx +25 -10
  25. package/src/components/onboarding/OAuthWebView.tsx +51 -5
  26. package/src/services/platformAuthService.ts +64 -0
@@ -72,17 +72,26 @@ export const getPlatformColor = (platform: string): string => {
72
72
  */
73
73
  export const initiateOAuth = async (platform: string, username: string, appName?: string): Promise<string | null> => {
74
74
  try {
75
+ console.log('🚀 Initiating OAuth for platform:', platform);
76
+ console.log('👤 Username:', username);
77
+ console.log('📱 App name:', appName);
78
+
75
79
  // Check if the platform is supported
76
80
  if (!PLATFORM_AUTH_CONFIG[platform]) {
81
+ console.error('❌ Unsupported platform:', platform);
77
82
  throw new Error(`Unsupported platform: ${platform}`);
78
83
  }
79
84
 
80
85
  // Check if platform has a native SDK
81
86
  if (PLATFORM_AUTH_CONFIG[platform].hasNativeSDK) {
87
+ console.log('📱 Platform uses native SDK, returning null');
82
88
  // Return null to indicate that we should use the native SDK
83
89
  return null;
84
90
  }
85
91
 
92
+ console.log('🌐 Platform uses OAuth WebView flow');
93
+ console.log('🔗 Auth endpoint:', PLATFORM_AUTH_CONFIG[platform].authEndpoint);
94
+
86
95
  // Handle Instagram with specific API format
87
96
  if (platform === 'instagram') {
88
97
  const state = 'djksbfds';
@@ -93,6 +102,8 @@ export const initiateOAuth = async (platform: string, username: string, appName?
93
102
  },
94
103
  };
95
104
 
105
+ console.log('📤 Sending Instagram OAuth request:', jsonData);
106
+
96
107
  const response = await fetch('https://api2.onairos.uk/instagram/authorize', {
97
108
  method: 'POST',
98
109
  headers: {
@@ -101,12 +112,24 @@ export const initiateOAuth = async (platform: string, username: string, appName?
101
112
  body: JSON.stringify(jsonData),
102
113
  });
103
114
 
115
+ console.log('📡 Instagram OAuth response status:', response.status);
116
+ console.log('📡 Instagram OAuth response headers:', response.headers);
117
+
118
+ if (!response.ok) {
119
+ const errorText = await response.text();
120
+ console.error('❌ Instagram OAuth API error:', errorText);
121
+ throw new Error(`Instagram OAuth API error: ${response.status} - ${errorText}`);
122
+ }
123
+
104
124
  const responseData = await response.json();
125
+ console.log('📥 Instagram OAuth response data:', responseData);
105
126
 
106
127
  if (responseData.instagramURL) {
128
+ console.log('✅ Instagram OAuth URL received:', responseData.instagramURL);
107
129
  return responseData.instagramURL;
108
130
  }
109
131
 
132
+ console.error('❌ No Instagram URL found in response');
110
133
  throw new Error('No Instagram URL found in response');
111
134
  }
112
135
 
@@ -119,6 +142,8 @@ export const initiateOAuth = async (platform: string, username: string, appName?
119
142
  },
120
143
  };
121
144
 
145
+ console.log(`📤 Sending ${platform} OAuth request:`, jsonData);
146
+
122
147
  // Make the request to get the OAuth URL
123
148
  const response = await fetch(PLATFORM_AUTH_CONFIG[platform].authEndpoint, {
124
149
  method: 'POST',
@@ -128,8 +153,18 @@ export const initiateOAuth = async (platform: string, username: string, appName?
128
153
  body: JSON.stringify(jsonData),
129
154
  });
130
155
 
156
+ console.log(`📡 ${platform} OAuth response status:`, response.status);
157
+ console.log(`📡 ${platform} OAuth response headers:`, response.headers);
158
+
159
+ if (!response.ok) {
160
+ const errorText = await response.text();
161
+ console.error(`❌ ${platform} OAuth API error:`, errorText);
162
+ throw new Error(`${platform} OAuth API error: ${response.status} - ${errorText}`);
163
+ }
164
+
131
165
  // Parse the response
132
166
  const data = await response.json();
167
+ console.log(`📥 ${platform} OAuth response data:`, data);
133
168
 
134
169
  // Check if the response contains the OAuth URL based on platform
135
170
  switch (platform) {
@@ -249,3 +284,32 @@ export const isOAuthCallback = (url: string): boolean => {
249
284
  // Check if the URL starts with our redirect URI
250
285
  return url.startsWith('onairosanime://auth/');
251
286
  };
287
+
288
+ /**
289
+ * Test connectivity to the Onairos API server
290
+ */
291
+ export const testApiConnectivity = async (): Promise<{ success: boolean; error?: string }> => {
292
+ try {
293
+ console.log('🔍 Testing connectivity to Onairos API...');
294
+
295
+ const response = await fetch('https://api2.onairos.uk/health', {
296
+ method: 'GET',
297
+ headers: {
298
+ 'Content-Type': 'application/json',
299
+ },
300
+ });
301
+
302
+ console.log('🌐 API connectivity test response:', response.status);
303
+
304
+ if (response.ok) {
305
+ console.log('✅ API server is reachable');
306
+ return { success: true };
307
+ } else {
308
+ console.log('⚠️ API server responded with error:', response.status);
309
+ return { success: false, error: `API server error: ${response.status}` };
310
+ }
311
+ } catch (error) {
312
+ console.error('❌ API connectivity test failed:', error);
313
+ return { success: false, error: error instanceof Error ? error.message : 'Unknown error' };
314
+ }
315
+ };