@onairosofficial/onairos-capacitor 0.1.0 → 0.1.2

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 (202) hide show
  1. package/CAPACITOR_QUICK_START.md +379 -0
  2. package/CONNECTORS.md +122 -0
  3. package/LICENSE +194 -10
  4. package/OnairosofficialOnairosCapacitor.podspec +13 -0
  5. package/Package.swift +26 -0
  6. package/README.md +176 -25
  7. package/dist/onairos.capacitor.esm.js +1 -0
  8. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  9. package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
  10. package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
  11. package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
  12. package/docs/CROSS_SDK_PARITY.md +239 -0
  13. package/docs/DATA_FREQUENCY.md +57 -0
  14. package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
  15. package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
  16. package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
  17. package/docs/PLATFORM_APIS.md +559 -0
  18. package/docs/RAW_MEMORIES_API.md +305 -0
  19. package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
  20. package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
  21. package/docs/oldFixes.md +216 -0
  22. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
  23. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
  24. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
  25. package/onairos.d.ts +656 -0
  26. package/package.json +188 -37
  27. package/src/OnairosReconnectButton.jsx +272 -0
  28. package/src/RSA.jsx +57 -0
  29. package/src/assets/NewLogo.png +0 -0
  30. package/src/assets/OnairosNewLogo.png +0 -0
  31. package/src/assets/chatgpt-icon.png +0 -0
  32. package/src/assets/fire-horse.png +0 -0
  33. package/src/assets/fire-horse.transparent.png +0 -0
  34. package/src/assets/latest-firehorse.png +0 -0
  35. package/src/assets/perplexity.png +0 -0
  36. package/src/assets/persona.png +0 -0
  37. package/src/assets/persona1.png +0 -0
  38. package/src/assets/persona2.png +0 -0
  39. package/src/assets/persona3.png +0 -0
  40. package/src/assets/persona4.png +0 -0
  41. package/src/assets/persona5.png +0 -0
  42. package/src/capacitorConnectorCatalog.js +38 -0
  43. package/src/capacitorOAuthConfig.js +52 -0
  44. package/src/chatgptHostedImport/index.js +303 -0
  45. package/src/components/AuthButtons.jsx +48 -0
  46. package/src/components/ConnectChatGPTModal.jsx +666 -0
  47. package/src/components/ConnectClaudeModal.jsx +610 -0
  48. package/src/components/ConnectGeminiModal.jsx +639 -0
  49. package/src/components/ConnectGrokModal.jsx +701 -0
  50. package/src/components/ConnectPerplexityModal.jsx +726 -0
  51. package/src/components/DataExplainerScreen.jsx +349 -0
  52. package/src/components/DataRequest.js +885 -0
  53. package/src/components/DataRequest.jsx +1055 -0
  54. package/src/components/EmailAuth.js +1871 -0
  55. package/src/components/EmailAuth.jsx +2062 -0
  56. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  57. package/src/components/GoogleButton.js +133 -0
  58. package/src/components/LLMConnectorManager.jsx +201 -0
  59. package/src/components/LoadingPage.jsx +19 -0
  60. package/src/components/LoadingScreen.jsx +81 -0
  61. package/src/components/LunarBirthdate.jsx +96 -0
  62. package/src/components/LunarLoadingPage.jsx +251 -0
  63. package/src/components/Notification.jsx +21 -0
  64. package/src/components/OnairosAppButton.jsx +85 -0
  65. package/src/components/OnairosSSO.jsx +645 -0
  66. package/src/components/OnairosTrigger.jsx +61 -0
  67. package/src/components/PerplexityLogo.jsx +43 -0
  68. package/src/components/PinSetup.js +200 -0
  69. package/src/components/PinSetup.jsx +228 -0
  70. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  71. package/src/components/SdkErrorBoundary.jsx +36 -0
  72. package/src/components/SecuritySetup.js +81 -0
  73. package/src/components/SessionUserBar.jsx +83 -0
  74. package/src/components/SignUp.js +123 -0
  75. package/src/components/TestTelegramButton.js +53 -0
  76. package/src/components/TrainingComponent.jsx +200 -0
  77. package/src/components/TrainingScreen.jsx +897 -0
  78. package/src/components/UniversalOnboarding.js +306 -0
  79. package/src/components/UniversalOnboarding.jsx +4837 -0
  80. package/src/components/ValentineLoadingPage.jsx +502 -0
  81. package/src/components/ValentineModeSelector.jsx +162 -0
  82. package/src/components/WelcomeScreen.jsx +435 -0
  83. package/src/components/WrappedLoadingPage.jsx +205 -0
  84. package/src/components/connectors/ChatGPTConnector.js +348 -0
  85. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  86. package/src/components/connectors/ClaudeConnector.js +44 -0
  87. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  88. package/src/components/connectors/GeminiConnector.js +170 -0
  89. package/src/components/connectors/GeminiConnector.jsx +170 -0
  90. package/src/components/connectors/GmailConnector.js +148 -0
  91. package/src/components/connectors/GmailConnector.jsx +148 -0
  92. package/src/components/connectors/GrokConnector.js +16 -0
  93. package/src/components/connectors/GrokConnector.jsx +16 -0
  94. package/src/components/connectors/HingeConnector.js +419 -0
  95. package/src/components/connectors/HingeConnector.jsx +419 -0
  96. package/src/components/connectors/InstagramDataConnector.js +726 -0
  97. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  98. package/src/components/connectors/LinkedInConnector.js +4 -0
  99. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  100. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  101. package/src/components/connectors/PinterestConnector.js +208 -0
  102. package/src/components/connectors/PinterestConnector.jsx +208 -0
  103. package/src/components/connectors/README.md +292 -0
  104. package/src/components/connectors/RedditConnector.js +229 -0
  105. package/src/components/connectors/RedditConnector.jsx +229 -0
  106. package/src/components/connectors/SephoraConnector.js +482 -0
  107. package/src/components/connectors/SephoraConnector.jsx +482 -0
  108. package/src/components/connectors/TikTokConnector.jsx +430 -0
  109. package/src/components/connectors/YoutubeConnector.js +361 -0
  110. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  111. package/src/components/connectors/index.js +50 -0
  112. package/src/components/icons.jsx +46 -0
  113. package/src/components/icons.tsx +21 -0
  114. package/src/components/ui/PageLayout.jsx +1255 -0
  115. package/src/components/ui/PrimaryButton.jsx +162 -0
  116. package/src/components/ui/button.jsx +49 -0
  117. package/src/components/ui/card.jsx +61 -0
  118. package/src/components/ui/checkbox.jsx +33 -0
  119. package/src/components/ui/label.jsx +29 -0
  120. package/src/components/utils/UpdateConnections.js +45 -0
  121. package/src/components/utils/oauthHelper.js +97 -0
  122. package/src/config/api-config.js +138 -0
  123. package/src/deepLink.jsx +38 -0
  124. package/src/getPin.js +26 -0
  125. package/src/icons/Avatar.png +0 -0
  126. package/src/icons/Sentiment.png +0 -0
  127. package/src/icons/Trait.png +0 -0
  128. package/src/iframe/DataRequestPage.jsx +285 -0
  129. package/src/iframe/OnairosButtonIntegration.md +148 -0
  130. package/src/iframe/components/Box.jsx +56 -0
  131. package/src/iframe/components/IndividualConnection.jsx +88 -0
  132. package/src/iframe/dataRequestHandler.js +714 -0
  133. package/src/iframe/data_request_iframe.html +27 -0
  134. package/src/iframe/data_request_page.js +47 -0
  135. package/src/iframe/icons/Avatar.png +1 -0
  136. package/src/iframe/icons/Avatar2.png +1 -0
  137. package/src/iframe/icons/Sentiment.png +1 -0
  138. package/src/iframe/icons/Trait.png +1 -0
  139. package/src/iframe/icons/onairos_logo.png +0 -0
  140. package/src/iframe/utils/api.js +57 -0
  141. package/src/index.js +274 -0
  142. package/src/laravel/OnairosVue.vue +410 -0
  143. package/src/laravel/blade-helpers.js +320 -0
  144. package/src/laravel/vite-plugin.js +179 -0
  145. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  146. package/src/mobile/components/MobileBox.jsx +71 -0
  147. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  148. package/src/mobile/shims/browser-apis.js +78 -0
  149. package/src/mobile/shims/lucide-shim.js +85 -0
  150. package/src/nativeConnectors.js +5 -0
  151. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  152. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  153. package/src/newUI/PrimaryButton.tsx +213 -0
  154. package/src/newUI/SignInStep.tsx +194 -0
  155. package/src/newUI/VerificationStep.tsx +133 -0
  156. package/src/newUI/WelcomeScreen.tsx +311 -0
  157. package/src/newUI/services/connectedAccountsService.js +129 -0
  158. package/src/onairos.capacitor.jsx +15 -0
  159. package/src/onairos.core.jsx +133 -0
  160. package/src/onairos.jsx +14 -0
  161. package/src/onairos.native.jsx +15 -0
  162. package/src/onairosButton.jsx +9000 -0
  163. package/src/overlay/CheckBox.jsx +114 -0
  164. package/src/overlay/IndividualConnection copy.js +86 -0
  165. package/src/overlay/IndividualConnection.js +191 -0
  166. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  167. package/src/overlay/box.js +84 -0
  168. package/src/overlay/overlay.js +437 -0
  169. package/src/styles/onairos-scoped-preflight.css +97 -0
  170. package/src/styles/sdkCssRegistry.js +20 -0
  171. package/src/styles/styleLoaderInsertShadow.js +69 -0
  172. package/src/styles/tailwind.capacitor.css +395 -0
  173. package/src/styles/tailwind.css +395 -0
  174. package/src/theme/colors.js +40 -0
  175. package/src/utils/apiKeyValidation.js +341 -0
  176. package/src/utils/apiResponseLogger.js +316 -0
  177. package/src/utils/authHeaders.js +275 -0
  178. package/src/utils/biometrics.js +26 -0
  179. package/src/utils/bookmarkletUtils.js +28 -0
  180. package/src/utils/capacitorDetection.js +278 -0
  181. package/src/utils/capacitorLLMHelper.js +352 -0
  182. package/src/utils/capacitorPlugins.js +366 -0
  183. package/src/utils/crossDomainSSO.js +587 -0
  184. package/src/utils/deepLinking.js +27 -0
  185. package/src/utils/devLogger.js +46 -0
  186. package/src/utils/extensionDetection.js +418 -0
  187. package/src/utils/extractMemory.js +277 -0
  188. package/src/utils/framerBrandingOverrides.js +40 -0
  189. package/src/utils/googleWebClientId.js +55 -0
  190. package/src/utils/overlayHandler.js +224 -0
  191. package/src/utils/platformDisconnect.js +309 -0
  192. package/src/utils/pollTrainingStatus.js +200 -0
  193. package/src/utils/rawMemoriesAccess.js +211 -0
  194. package/src/utils/resolveBackendAppId.js +47 -0
  195. package/src/utils/responseFormatter.js +140 -0
  196. package/src/utils/sdkDebugStorage.js +113 -0
  197. package/src/utils/sdkInitialization.js +645 -0
  198. package/src/utils/sessionManager.js +1258 -0
  199. package/src/utils/startBackgroundTraining.js +100 -0
  200. package/src/utils/userDataFormatter.js +222 -0
  201. package/index.d.ts +0 -1
  202. package/index.js +0 -1
@@ -0,0 +1,361 @@
1
+ import React, { useState, useCallback } from 'react';
2
+ import { useGoogleLogin, GoogleOAuthProvider } from '@react-oauth/google';
3
+ import { getUserAuthHeaders, isUserAuthenticated } from '../../utils/authHeaders';
4
+ import { API_CONFIG } from '../../config/api-config';
5
+ import { getCapacitorApp, getCapacitorBrowser, isCapacitorNativePlatform, tryCapacitorBrowserClose } from '../../utils/capacitorPlugins.js';
6
+
7
+ // YouTube-specific Google Client ID (different from Sign-In client ID)
8
+ const YOUTUBE_CLIENT_ID =
9
+ (typeof window !== 'undefined' && window.onairosYoutubeClientId) ||
10
+ '1030678346906-rp6adil4r02a9e98q8rmeeajj6sok8kr.apps.googleusercontent.com';
11
+
12
+ // YouTube OAuth scopes
13
+ const YOUTUBE_SCOPES = [
14
+ 'https://www.googleapis.com/auth/youtube.readonly',
15
+ 'openid',
16
+ 'profile',
17
+ 'email'
18
+ ].join(' ');
19
+
20
+ /**
21
+ * Inner component that uses the useGoogleLogin hook
22
+ * Must be wrapped in GoogleOAuthProvider with YouTube client ID
23
+ */
24
+ function YoutubeConnectorInner({
25
+ onClose,
26
+ onConnectionChange,
27
+ username
28
+ }) {
29
+ const [isConnecting, setIsConnecting] = useState(false);
30
+ const [error, setError] = useState(null);
31
+ const [awaitingBrowserReturn, setAwaitingBrowserReturn] = useState(false);
32
+
33
+ // Handle auth code from Google - send to backend
34
+ const handleAuthCode = useCallback(async (authCode) => {
35
+ console.log('[YouTube] ✅ Received auth code from native SDK, sending to backend...');
36
+ setError(null);
37
+
38
+ try {
39
+ // Get user info from stored session
40
+ const storedUser = localStorage.getItem('onairosUser');
41
+ const userData = storedUser ? JSON.parse(storedUser) : {};
42
+
43
+ const response = await fetch(`${API_CONFIG.getBaseUrl()}/youtube/web-native-auth`, {
44
+ method: 'POST',
45
+ headers: {
46
+ ...getUserAuthHeaders(),
47
+ 'Content-Type': 'application/json',
48
+ },
49
+ body: JSON.stringify({
50
+ authCode: authCode,
51
+ sdkType: 'web',
52
+ userAccountInfo: {
53
+ username: username || userData.username || userData.email,
54
+ email: userData.email
55
+ }
56
+ }),
57
+ });
58
+
59
+ if (!response.ok) {
60
+ const errorText = await response.text();
61
+ console.error('[YouTube] Backend error:', response.status, errorText);
62
+
63
+ let errorMessage = `Server error: ${response.status}`;
64
+ try {
65
+ const errorJson = JSON.parse(errorText);
66
+ errorMessage = errorJson.message || errorJson.error || errorMessage;
67
+ } catch (e) {
68
+ if (errorText) errorMessage = errorText;
69
+ }
70
+
71
+ throw new Error(errorMessage);
72
+ }
73
+
74
+ const result = await response.json();
75
+
76
+ if (result.success) {
77
+ console.log('[YouTube] ✅ Connected successfully:', {
78
+ channelName: result.channelName,
79
+ channelId: result.channelId,
80
+ hasRefreshToken: result.hasRefreshToken
81
+ });
82
+
83
+ if (onConnectionChange) {
84
+ onConnectionChange('youtube', true, {
85
+ channelName: result.channelName,
86
+ channelId: result.channelId,
87
+ connectionHealth: result.connectionHealth
88
+ });
89
+ }
90
+
91
+ setIsConnecting(false);
92
+ if (onClose) onClose();
93
+ } else {
94
+ throw new Error(result.message || result.error || 'Failed to connect YouTube');
95
+ }
96
+ } catch (err) {
97
+ console.error('[YouTube] Connection error:', err);
98
+ setError(err.message || 'Failed to connect YouTube account');
99
+ setIsConnecting(false);
100
+ }
101
+ }, [username, onConnectionChange, onClose]);
102
+
103
+ const startNativeYoutubeOAuth = useCallback(async () => {
104
+ setError(null);
105
+ setIsConnecting(true);
106
+ setAwaitingBrowserReturn(false);
107
+
108
+ if (!isUserAuthenticated()) {
109
+ setError('Please sign in first before connecting YouTube');
110
+ setIsConnecting(false);
111
+ return;
112
+ }
113
+
114
+ const AppPlugin = getCapacitorApp();
115
+ const BrowserPlugin = getCapacitorBrowser();
116
+
117
+ let removeUrlOpen = null;
118
+ try {
119
+ // Listen for deep-link return (e.g. onairoscaptest://oauth?...code=...)
120
+ if (AppPlugin?.addListener) {
121
+ const handler = (event) => {
122
+ try {
123
+ const url = event?.url || '';
124
+ if (!url) return;
125
+ const u = new URL(url);
126
+ const code = u.searchParams.get('code');
127
+ const err = u.searchParams.get('error');
128
+ if (err) {
129
+ setError(`YouTube sign-in failed: ${err}`);
130
+ setIsConnecting(false);
131
+ setAwaitingBrowserReturn(false);
132
+ tryCapacitorBrowserClose();
133
+ return;
134
+ }
135
+ if (code) {
136
+ // Close browser UI if still open, then exchange code with backend
137
+ tryCapacitorBrowserClose();
138
+ setAwaitingBrowserReturn(false);
139
+ handleAuthCode(code);
140
+ }
141
+ } catch {}
142
+ };
143
+ const sub = await AppPlugin.addListener('appUrlOpen', handler);
144
+ removeUrlOpen = () => {
145
+ try { sub?.remove?.(); } catch {}
146
+ };
147
+ }
148
+
149
+ // Ask backend for an authorize URL that is safe for system browser.
150
+ // (Google blocks OAuth in embedded WKWebView with disallowed_useragent.)
151
+ const resp = await fetch(`${API_CONFIG.getBaseUrl()}/youtube/authorize`, {
152
+ method: 'POST',
153
+ headers: {
154
+ ...getUserAuthHeaders(),
155
+ 'Content-Type': 'application/json',
156
+ },
157
+ body: JSON.stringify({}),
158
+ });
159
+
160
+ const result = await resp.json().catch(() => ({}));
161
+ const youtubeURL = result?.youtubeURL || result?.youtubeUrl || result?.youtube_url;
162
+ if (!youtubeURL) {
163
+ throw new Error(result?.message || result?.error || 'No YouTube authorization URL received');
164
+ }
165
+
166
+ setAwaitingBrowserReturn(true);
167
+
168
+ if (BrowserPlugin?.open) {
169
+ await BrowserPlugin.open({
170
+ url: youtubeURL,
171
+ windowName: '_blank',
172
+ presentationStyle: 'fullscreen',
173
+ });
174
+ } else {
175
+ // IMPORTANT: Never hard-navigate the Capacitor WKWebView to Google (can trap the user and triggers disallowed_useragent).
176
+ throw new Error('Capacitor Browser plugin not available to open YouTube sign-in securely.');
177
+ }
178
+ } catch (e) {
179
+ setError(e?.message || String(e));
180
+ setIsConnecting(false);
181
+ setAwaitingBrowserReturn(false);
182
+ try { removeUrlOpen?.(); } catch {}
183
+ }
184
+
185
+ // If we successfully opened the browser, keep listener until close/cancel.
186
+ return () => {
187
+ try { removeUrlOpen?.(); } catch {}
188
+ };
189
+ }, [handleAuthCode]);
190
+
191
+ // Native Google Login hook - gets auth CODE (not token) for backend exchange
192
+ const googleLogin = useGoogleLogin({
193
+ flow: 'auth-code', // Get auth code for backend to exchange
194
+ scope: YOUTUBE_SCOPES,
195
+ onSuccess: (codeResponse) => {
196
+ console.log('[YouTube] Google OAuth success, code received');
197
+ if (codeResponse.code) {
198
+ handleAuthCode(codeResponse.code);
199
+ } else {
200
+ setError('No authorization code received');
201
+ setIsConnecting(false);
202
+ }
203
+ },
204
+ onError: (errorResponse) => {
205
+ console.error('[YouTube] Google OAuth error:', errorResponse);
206
+ setError(errorResponse.error_description || errorResponse.error || 'Sign-in failed');
207
+ setIsConnecting(false);
208
+ },
209
+ onNonOAuthError: (nonOAuthError) => {
210
+ console.error('[YouTube] Non-OAuth error:', nonOAuthError);
211
+ if (nonOAuthError.type === 'popup_closed') {
212
+ setError('Sign-in was cancelled');
213
+ } else if (nonOAuthError.type === 'popup_failed_to_open') {
214
+ setError('Popup was blocked. Please allow popups and try again.');
215
+ } else {
216
+ setError('Sign-in failed. Please try again.');
217
+ }
218
+ setIsConnecting(false);
219
+ }
220
+ });
221
+
222
+ const handleConnect = useCallback(() => {
223
+ // Extra safety: if we are somehow on a web protocol (http/https) and not in a native shell,
224
+ // force the web flow. This prevents "web-in-mobile-browser" from hitting the native path.
225
+ const isWebProtocol = typeof window !== 'undefined' &&
226
+ (window.location.protocol === 'http:' || window.location.protocol === 'https:');
227
+
228
+ // Check if we are truly native. isCapacitorNativePlatform() now includes a platform check,
229
+ // but if the user is running a web build that mocks Capacitor, we need to be careful.
230
+ if (isCapacitorNativePlatform() && !isWebProtocol) {
231
+ console.log('[YouTube] Capacitor native detected → using system browser OAuth (avoid disallowed_useragent)');
232
+ startNativeYoutubeOAuth();
233
+ return;
234
+ }
235
+
236
+ if (!isUserAuthenticated()) {
237
+ setError('Please sign in first before connecting YouTube');
238
+ return;
239
+ }
240
+
241
+ setIsConnecting(true);
242
+ setError(null);
243
+
244
+ console.log('[YouTube] Web detected → using @react-oauth/google popup flow...');
245
+ googleLogin();
246
+ }, [googleLogin, startNativeYoutubeOAuth]);
247
+
248
+ // Handle close
249
+ const handleClose = () => {
250
+ setError(null);
251
+ setIsConnecting(false);
252
+ setAwaitingBrowserReturn(false);
253
+ tryCapacitorBrowserClose();
254
+ if (onClose) onClose();
255
+ };
256
+
257
+ return (
258
+ <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[2147483647]">
259
+ <div className="bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-full md:max-h-[90vh] overflow-hidden">
260
+ <div className="p-6">
261
+ <h2 className="text-xl font-bold text-gray-900 mb-4">
262
+ Connect your YouTube Account
263
+ </h2>
264
+
265
+ <div className="space-y-4 text-gray-700">
266
+ <p>
267
+ Grant permission to your YouTube account so we can build your personalized Data Models.
268
+ </p>
269
+
270
+ <div>
271
+ <p className="font-medium mb-2">We will access your YouTube:</p>
272
+ <ul className="list-disc ml-6 space-y-1">
273
+ <li>Basic Account Info</li>
274
+ <li>Liked and Watched Videos</li>
275
+ <li>Subscribed Channels and Playlist Videos</li>
276
+ </ul>
277
+ </div>
278
+
279
+ <p>
280
+ We will delete all the data used once your Model is created.
281
+ </p>
282
+
283
+ <p className="text-sm">
284
+ <a href="https://onairos.uk/compliance-google-policy" className="text-blue-600 hover:underline">
285
+ Onairos
286
+ </a>{' '}
287
+ complies with{' '}
288
+ <a href="https://policies.google.com/privacy" className="text-blue-600 hover:underline">
289
+ Google API Services User Data Policy
290
+ </a>
291
+ </p>
292
+
293
+ {error && (
294
+ <div className="p-3 bg-red-50 border border-red-200 rounded-lg">
295
+ <p className="text-sm text-red-600">{error}</p>
296
+ </div>
297
+ )}
298
+
299
+ {awaitingBrowserReturn && (
300
+ <div className="p-3 bg-blue-50 border border-blue-200 rounded-lg">
301
+ <p className="text-sm text-blue-700">
302
+ Finish connecting in the browser, then return to the app. If you get stuck, tap “Cancel” to go back.
303
+ </p>
304
+ </div>
305
+ )}
306
+ </div>
307
+
308
+ <div className="flex space-x-3 mt-6">
309
+ <button
310
+ onClick={handleClose}
311
+ // Always allow exit so the user can get back to Universal Onboarding even if OAuth is blocked.
312
+ disabled={false}
313
+ className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"
314
+ >
315
+ Cancel
316
+ </button>
317
+ <button
318
+ onClick={handleConnect}
319
+ disabled={isConnecting}
320
+ className="flex-1 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50 flex items-center justify-center gap-2"
321
+ >
322
+ {isConnecting ? (
323
+ <>
324
+ <svg className="animate-spin h-4 w-4" viewBox="0 0 24 24">
325
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none" />
326
+ <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
327
+ </svg>
328
+ Connecting...
329
+ </>
330
+ ) : (
331
+ <>
332
+ <svg className="w-5 h-5" viewBox="0 0 24 24" fill="currentColor">
333
+ <path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/>
334
+ </svg>
335
+ Connect YouTube
336
+ </>
337
+ )}
338
+ </button>
339
+ </div>
340
+ </div>
341
+ </div>
342
+ </div>
343
+ );
344
+ }
345
+
346
+ /**
347
+ * YouTubeConnector - Wrapper that provides YouTube-specific GoogleOAuthProvider
348
+ * This uses a DIFFERENT client ID than the main Google Sign-In
349
+ */
350
+ function YoutubeConnector({ open, ...props }) {
351
+ if (!open) return null;
352
+
353
+ // Wrap with YouTube-specific OAuth provider
354
+ return (
355
+ <GoogleOAuthProvider clientId={YOUTUBE_CLIENT_ID}>
356
+ <YoutubeConnectorInner {...props} />
357
+ </GoogleOAuthProvider>
358
+ );
359
+ }
360
+
361
+ export default YoutubeConnector;