@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,268 @@
1
+ # Email Verification API Schema
2
+
3
+ ## Base URL
4
+ ```
5
+ https://api2.onairos.uk
6
+ ```
7
+
8
+ ## Authentication
9
+ - **Developer API Key**: `Bearer ${API_KEY}` (required for all requests)
10
+ - **Admin API Key**: `Bearer OnairosIsAUnicorn2025` (bypasses email sending, accepts any 6-digit code)
11
+
12
+ ---
13
+
14
+ ## 1. Request Verification Code
15
+
16
+ ### Endpoint
17
+ ```
18
+ POST /email/verify
19
+ ```
20
+
21
+ ### Request
22
+ ```json
23
+ {
24
+ "email": "user@example.com"
25
+ }
26
+ ```
27
+
28
+ ### Response
29
+ ```json
30
+ {
31
+ "success": true,
32
+ "message": "Verification code generated (testing mode - check server logs)",
33
+ "testingMode": true,
34
+ "emailSent": false,
35
+ "note": "Any code will be accepted for verification in testing mode",
36
+ "expiresIn": "30 minutes"
37
+ }
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 2. Verify Code & Get JWT Token
43
+
44
+ ### Endpoint
45
+ ```
46
+ POST /email/verify/confirm
47
+ ```
48
+
49
+ ### Request
50
+ ```json
51
+ {
52
+ "email": "user@example.com",
53
+ "code": "123456"
54
+ }
55
+ ```
56
+
57
+ ### Response (New User)
58
+ ```json
59
+ {
60
+ "success": true,
61
+ "isNewUser": true,
62
+ "userState": "new",
63
+ "flowType": "onboarding",
64
+ "token": "eyJhbGciOiJIUzI1NiIs...",
65
+ "user": {
66
+ "userId": "341",
67
+ "userName": "test44",
68
+ "email": "test44@gmail.com",
69
+ "verified": true,
70
+ "creationDate": "2025-01-09T06:22:58.000Z",
71
+ "lastLogin": "2025-01-09T06:22:58.000Z"
72
+ },
73
+ "enochInstructions": {
74
+ "recommendedFlow": "onboarding",
75
+ "nextActionTitle": "Get Started"
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### Response (Existing User)
81
+ ```json
82
+ {
83
+ "success": true,
84
+ "isNewUser": false,
85
+ "userState": "returning",
86
+ "flowType": "returning_user",
87
+ "token": "eyJhbGciOiJIUzI1NiIs...",
88
+ "user": {
89
+ "userId": "123",
90
+ "userName": "existinguser",
91
+ "email": "user@example.com",
92
+ "verified": true,
93
+ "creationDate": "2024-01-15T10:30:00.000Z",
94
+ "lastLogin": "2025-01-09T06:22:58.000Z"
95
+ },
96
+ "existingUserData": {
97
+ "hasExistingData": true,
98
+ "summary": {
99
+ "connectionsCount": 3,
100
+ "traitsCount": 5,
101
+ "hasPersonalityData": true
102
+ },
103
+ "connections": [
104
+ {
105
+ "platform": "YouTube",
106
+ "status": "active",
107
+ "connectedAt": "2024-01-15T10:30:00.000Z",
108
+ "hasData": true,
109
+ "displayName": "YouTube"
110
+ },
111
+ {
112
+ "platform": "LinkedIn",
113
+ "status": "active",
114
+ "connectedAt": "2024-02-20T14:22:00.000Z",
115
+ "hasData": true,
116
+ "displayName": "LinkedIn"
117
+ }
118
+ ]
119
+ },
120
+ "enochInstructions": {
121
+ "skipOnboarding": true,
122
+ "recommendedFlow": "dashboard",
123
+ "nextActionTitle": "View Your Data"
124
+ }
125
+ }
126
+ ```
127
+
128
+ ```
129
+
130
+ ### Error Responses
131
+ ```json
132
+ // Wrong Code
133
+ {
134
+ "success": false,
135
+ "error": "Invalid verification code",
136
+ "code": 400,
137
+ "attemptsRemaining": 2
138
+ }
139
+
140
+ // Missing Data
141
+ {
142
+ "success": false,
143
+ "error": "Email and code are required",
144
+ "code": 400
145
+ }
146
+
147
+ // Expired Code
148
+ {
149
+ "success": false,
150
+ "error": "Verification code has expired. Please request a new code.",
151
+ "code": 400
152
+ }
153
+ ```
154
+
155
+ ---
156
+
157
+ ## JWT Token Format
158
+
159
+ ### Payload
160
+ ```json
161
+ {
162
+ "id": "507f1f77bcf86cd799439011",
163
+ "email": "user@example.com",
164
+ "userId": "123",
165
+ "verified": true,
166
+ "iat": 1641123456,
167
+ "exp": 1641728256
168
+ }
169
+ ```
170
+
171
+ ### Properties
172
+ - **Expiration**: 7 days
173
+ - **Secret**: `ONAIROS_JWT_SECRET_KEY`
174
+ - **Algorithm**: HS256
175
+
176
+ ---
177
+
178
+ ## Usage Examples
179
+
180
+ ### JavaScript/React Native
181
+ ```javascript
182
+ // Step 1: Request code
183
+ const requestCode = await fetch('/email/verify', {
184
+ method: 'POST',
185
+ headers: {
186
+ 'Content-Type': 'application/json',
187
+ 'Authorization': `Bearer ${API_KEY}`
188
+ },
189
+ body: JSON.stringify({
190
+ email: 'user@example.com'
191
+ })
192
+ });
193
+
194
+ // Step 2: Verify code and get JWT
195
+ const verifyCode = await fetch('/email/verify/confirm', {
196
+ method: 'POST',
197
+ headers: {
198
+ 'Content-Type': 'application/json',
199
+ 'Authorization': `Bearer ${API_KEY}`
200
+ },
201
+ body: JSON.stringify({
202
+ email: 'user@example.com',
203
+ code: '123456'
204
+ })
205
+ });
206
+
207
+ const result = await verifyCode.json();
208
+ if (result.success) {
209
+ // Store JWT token
210
+ const jwtToken = result.token; // or result.jwtToken
211
+ localStorage.setItem('onairos_jwt_token', jwtToken);
212
+ }
213
+ ```
214
+
215
+ ### Using JWT Token
216
+ ```javascript
217
+ // Use JWT for authenticated requests
218
+ const response = await fetch('/store-pin/mobile', {
219
+ method: 'POST',
220
+ headers: {
221
+ 'Content-Type': 'application/json',
222
+ 'Authorization': `Bearer ${jwtToken}` // User JWT token
223
+ },
224
+ body: JSON.stringify({
225
+ username: 'user123',
226
+ pin: '1234'
227
+ })
228
+ });
229
+ ```
230
+
231
+ ---
232
+
233
+ ## Error Responses
234
+
235
+ ### Common Errors
236
+ ```json
237
+ {
238
+ "success": false,
239
+ "error": "Invalid email address or verification failed"
240
+ }
241
+ ```
242
+
243
+ ### Rate Limiting
244
+ ```json
245
+ {
246
+ "success": false,
247
+ "error": "Too many attempts. Please try again later."
248
+ }
249
+ ```
250
+
251
+ ### Invalid Code
252
+ ```json
253
+ {
254
+ "success": false,
255
+ "error": "Invalid or expired verification code"
256
+ }
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Key Points
262
+
263
+ 1. **Two Endpoints**: Use `/email/verify` for requesting codes and `/email/verify/confirm` for verification
264
+ 2. **New Response Format**: Returns `isNewUser`, `userState`, `flowType`, and `enochInstructions` for better flow control
265
+ 3. **Testing Mode**: Use testing mode for development, accepts any 6-digit code
266
+ 4. **Token Usage**: Include JWT in `Authorization: Bearer ${token}` for user requests
267
+ 5. **Error Handling**: Includes `attemptsRemaining` for better UX
268
+ 6. **Expiration**: JWT tokens last 7 days
@@ -0,0 +1,435 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ ScrollView,
7
+ KeyboardAvoidingView,
8
+ Platform,
9
+ } from 'react-native';
10
+ import { COLORS, SPACING } from '../theme';
11
+ import { triggerHaptic, HapticType } from '../../utils/haptics';
12
+ import PlatformToggle from './PlatformToggle';
13
+ import PersonaImage from './PersonaImage';
14
+ import PrimaryButton from './PrimaryButton';
15
+ import PersonalizationConsentScreen from './PersonalizationConsentScreen';
16
+ import PinCreationScreen from './PinCreationScreen';
17
+ import PersonaLoadingScreen from './PersonaLoadingScreen';
18
+ import { useConnections } from '../hooks/useConnections';
19
+ import { getPlatformIcon } from '../services/connectedAccountsService';
20
+ import { initiateOAuth, initiateNativeAuth, hasNativeSDK } from '../services/platformAuthService';
21
+ import { OAuthWebView } from './onairos/onboarding/OAuthWebView';
22
+ import { useAuth } from '../context/AuthContext';
23
+
24
+ interface PlatformConnectorsStepProps {
25
+ onUpdate: (connectedPlatforms: string[]) => void;
26
+ onSkip: () => void;
27
+ loading?: boolean;
28
+ onPinComplete?: (pin: string) => void;
29
+ }
30
+
31
+ const PlatformConnectorsStep: React.FC<PlatformConnectorsStepProps> = ({
32
+ onUpdate,
33
+ onSkip,
34
+ loading = false,
35
+ onPinComplete,
36
+ }) => {
37
+ const [connectedPlatforms, setConnectedPlatforms] = useState<Set<string>>(new Set());
38
+ const [showConsentScreen, setShowConsentScreen] = useState(false);
39
+ const [showPinScreen, setShowPinScreen] = useState(false);
40
+ const [showLoadingScreen, setShowLoadingScreen] = useState(false);
41
+ const [createdPin, setCreatedPin] = useState<string>('');
42
+ const [connectionStatuses, setConnectionStatuses] = useState<Record<string, string>>({});
43
+ const [showOAuthWebView, setShowOAuthWebView] = useState(false);
44
+ const [oauthUrl, setOauthUrl] = useState<string>('');
45
+ const [currentPlatform, setCurrentPlatform] = useState<string>('');
46
+
47
+ // Use the real platform connection hook
48
+ const { connectPlatform, disconnectPlatform, isConnecting } = useConnections();
49
+
50
+ // Get the authenticated user from auth context
51
+ const { user } = useAuth();
52
+ const username = user?.email || user?.name || `user_${Math.floor(Math.random() * 10000)}`;
53
+
54
+ // Real platforms that can be connected (from UniversalOnboarding)
55
+ const platforms = [
56
+ {
57
+ id: 'chatgpt',
58
+ name: 'ChatGPT',
59
+ icon: getPlatformIcon('chatgpt'),
60
+ description: 'Access AI-powered conversations and assistance for various tasks.',
61
+ },
62
+ {
63
+ id: 'pinterest',
64
+ name: 'Pinterest',
65
+ icon: getPlatformIcon('pinterest'),
66
+ description: 'We analyze your pins, boards, and interests to understand your style and preferences.',
67
+ },
68
+ {
69
+ id: 'youtube',
70
+ name: 'YouTube',
71
+ icon: getPlatformIcon('youtube'),
72
+ description: 'We analyze your watch history, likes, and subscriptions to understand your interests.',
73
+ },
74
+ {
75
+ id: 'linkedin',
76
+ name: 'LinkedIn',
77
+ icon: getPlatformIcon('linkedin'),
78
+ description: 'We analyze your professional network and career interests.',
79
+ },
80
+ {
81
+ id: 'reddit',
82
+ name: 'Reddit',
83
+ icon: getPlatformIcon('reddit'),
84
+ description: 'We analyze your posts and comments to understand your interests.',
85
+ },
86
+ {
87
+ id: 'gmail',
88
+ name: 'Gmail',
89
+ icon: getPlatformIcon('gmail'),
90
+ description: 'We analyze your email patterns to understand your communication style.',
91
+ },
92
+ ];
93
+
94
+ const handlePlatformToggle = async (platformId: string, enabled: boolean) => {
95
+ triggerHaptic(HapticType.BUTTON_PRESS);
96
+
97
+ try {
98
+ if (enabled) {
99
+ // Special behavior for ChatGPT: Always open chatgpt.com in new tab
100
+ if (platformId === 'chatgpt') {
101
+ console.log('🤖 ChatGPT toggle: Opening chatgpt.com...');
102
+ // For React Native, we might need to use Linking.openURL
103
+ // For now, simulate connection
104
+ const newConnected = new Set(connectedPlatforms);
105
+ newConnected.add(platformId);
106
+ setConnectedPlatforms(newConnected);
107
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'connected' }));
108
+ triggerHaptic(HapticType.SUCCESS);
109
+ return;
110
+ }
111
+
112
+ // Check if the platform has a native SDK
113
+ if (hasNativeSDK(platformId)) {
114
+ // Use native SDK authentication (YouTube)
115
+ setCurrentPlatform(platformId);
116
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'connecting' }));
117
+ const success = await initiateNativeAuth(platformId, username);
118
+
119
+ if (success) {
120
+ const newConnected = new Set(connectedPlatforms);
121
+ newConnected.add(platformId);
122
+ setConnectedPlatforms(newConnected);
123
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'connected' }));
124
+ triggerHaptic(HapticType.SUCCESS);
125
+ } else {
126
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'error' }));
127
+ triggerHaptic(HapticType.ERROR);
128
+ }
129
+ } else {
130
+ // For platforms like Pinterest, use OAuth WebView
131
+ setCurrentPlatform(platformId);
132
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'connecting' }));
133
+
134
+ const oauthUrl = await initiateOAuth(platformId, username);
135
+
136
+ if (oauthUrl) {
137
+ setOauthUrl(oauthUrl);
138
+ setShowOAuthWebView(true);
139
+ } else {
140
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'error' }));
141
+ triggerHaptic(HapticType.ERROR);
142
+ }
143
+ }
144
+ } else {
145
+ // Disconnect the platform
146
+ await disconnectPlatform(platformId);
147
+ const newConnected = new Set(connectedPlatforms);
148
+ newConnected.delete(platformId);
149
+ setConnectedPlatforms(newConnected);
150
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'disconnected' }));
151
+ triggerHaptic(HapticType.BUTTON_PRESS);
152
+ }
153
+ } catch (error) {
154
+ console.error(`Error toggling platform ${platformId}:`, error);
155
+ setConnectionStatuses(prev => ({ ...prev, [platformId]: 'error' }));
156
+ triggerHaptic(HapticType.ERROR);
157
+ }
158
+ };
159
+
160
+ const handleUpdate = () => {
161
+ triggerHaptic(HapticType.BUTTON_PRESS);
162
+ setShowPinScreen(true);
163
+ };
164
+
165
+ const handleConsentAccept = () => {
166
+ triggerHaptic(HapticType.BUTTON_PRESS);
167
+ if (onPinComplete) {
168
+ onPinComplete(createdPin);
169
+ } else {
170
+ onUpdate(Array.from(connectedPlatforms));
171
+ }
172
+ };
173
+
174
+ const handleConsentDecline = () => {
175
+ triggerHaptic(HapticType.BUTTON_PRESS);
176
+ setShowConsentScreen(false);
177
+ };
178
+
179
+ const handleSkip = () => {
180
+ triggerHaptic(HapticType.BUTTON_PRESS);
181
+ onSkip();
182
+ };
183
+
184
+ const handlePinComplete = (pin: string) => {
185
+ setCreatedPin(pin);
186
+ setShowPinScreen(false);
187
+ setShowLoadingScreen(true);
188
+ };
189
+
190
+ const handleLoadingComplete = () => {
191
+ setShowLoadingScreen(false);
192
+ setShowConsentScreen(true);
193
+ };
194
+
195
+ const handleOAuthSuccess = (code: string) => {
196
+ console.log(`OAuth success for ${currentPlatform} with code:`, code);
197
+
198
+ if (currentPlatform) {
199
+ // Update connected platforms
200
+ const newConnected = new Set(connectedPlatforms);
201
+ newConnected.add(currentPlatform);
202
+ setConnectedPlatforms(newConnected);
203
+ setConnectionStatuses(prev => ({ ...prev, [currentPlatform]: 'connected' }));
204
+ triggerHaptic(HapticType.SUCCESS);
205
+ }
206
+
207
+ // Close the OAuth window
208
+ setShowOAuthWebView(false);
209
+ setOauthUrl('');
210
+ setCurrentPlatform('');
211
+ };
212
+
213
+ const handleOAuthClose = () => {
214
+ setShowOAuthWebView(false);
215
+ setOauthUrl('');
216
+ if (currentPlatform) {
217
+ setConnectionStatuses(prev => ({ ...prev, [currentPlatform]: 'disconnected' }));
218
+ }
219
+ setCurrentPlatform('');
220
+ };
221
+
222
+ const handlePinBack = () => {
223
+ setShowPinScreen(false);
224
+ };
225
+
226
+ // Calculate persona level based on connected platforms (1-5)
227
+ const personaLevel = Math.min(5, Math.max(1, connectedPlatforms.size + 1));
228
+
229
+ // Show PIN screen if triggered
230
+ if (showPinScreen) {
231
+ return (
232
+ <PinCreationScreen
233
+ visible={showPinScreen}
234
+ onComplete={handlePinComplete}
235
+ onBack={handlePinBack}
236
+ />
237
+ );
238
+ }
239
+
240
+ // Show loading screen if triggered
241
+ if (showLoadingScreen) {
242
+ return (
243
+ <PersonaLoadingScreen
244
+ visible={showLoadingScreen}
245
+ onComplete={handleLoadingComplete}
246
+ />
247
+ );
248
+ }
249
+
250
+ // Show OAuth WebView if triggered
251
+ if (showOAuthWebView && oauthUrl) {
252
+ return (
253
+ <OAuthWebView
254
+ url={oauthUrl}
255
+ platform={currentPlatform}
256
+ onClose={handleOAuthClose}
257
+ onSuccess={handleOAuthSuccess}
258
+ onComplete={handleOAuthClose}
259
+ />
260
+ );
261
+ }
262
+
263
+ // Show consent screen if triggered
264
+ if (showConsentScreen) {
265
+ return (
266
+ <PersonalizationConsentScreen
267
+ visible={showConsentScreen}
268
+ onAccept={handleConsentAccept}
269
+ onDecline={handleConsentDecline}
270
+ />
271
+ );
272
+ }
273
+
274
+ return (
275
+ <View style={styles.container}>
276
+ {/* Fixed Header and Persona Section */}
277
+ <View style={styles.fixedHeaderSection}>
278
+ {/* Heading */}
279
+ <View style={styles.headingContainer}>
280
+ <Text style={styles.title}>Connect platforms</Text>
281
+ <Text style={styles.subtitle}>More connections, smarter personalization.</Text>
282
+ </View>
283
+
284
+ {/* Persona Image */}
285
+ <View style={styles.personaContainer}>
286
+ <PersonaImage level={personaLevel} style={styles.largePersona} />
287
+ </View>
288
+ </View>
289
+
290
+ {/* Scrollable Platform Section */}
291
+ <KeyboardAvoidingView
292
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
293
+ style={styles.scrollableSection}
294
+ >
295
+ <ScrollView
296
+ style={styles.scrollView}
297
+ showsVerticalScrollIndicator={false}
298
+ contentContainerStyle={styles.scrollContent}
299
+ >
300
+ <View style={styles.platformsContainer}>
301
+ {platforms.map((platform, index) => (
302
+ <PlatformToggle
303
+ key={platform.id}
304
+ platform={platform}
305
+ isEnabled={connectedPlatforms.has(platform.id)}
306
+ onToggle={handlePlatformToggle}
307
+ fullWidth={true}
308
+ isLast={index === platforms.length - 1}
309
+ customIconSize={platform.id === 'youtube' ? 36 : undefined}
310
+ />
311
+ ))}
312
+ </View>
313
+ </ScrollView>
314
+ </KeyboardAvoidingView>
315
+
316
+ {/* Fixed Bottom Buttons */}
317
+ <View style={styles.bottomContainer}>
318
+ <View style={styles.buttonContainer}>
319
+ <PrimaryButton
320
+ label="Update"
321
+ onPress={handleUpdate}
322
+ disabled={loading || connectedPlatforms.size === 0 || isConnecting}
323
+ loading={loading || isConnecting}
324
+ />
325
+ </View>
326
+
327
+ <View style={styles.skipContainer}>
328
+ <Text style={styles.skipButton} onPress={handleSkip}>
329
+ Skip
330
+ </Text>
331
+ </View>
332
+ </View>
333
+ </View>
334
+ );
335
+ };
336
+
337
+ const styles = StyleSheet.create({
338
+ container: {
339
+ flex: 1,
340
+ backgroundColor: COLORS.surface,
341
+ },
342
+
343
+ fixedHeaderSection: {
344
+ paddingTop: 8,
345
+ paddingHorizontal: 0,
346
+ backgroundColor: COLORS.surface,
347
+ maxHeight: '50%', // Limit fixed section to 50% of screen
348
+ overflow: 'hidden', // Hide any overflow
349
+ },
350
+
351
+ scrollableSection: {
352
+ flex: 1,
353
+ },
354
+
355
+ scrollView: {
356
+ flex: 1,
357
+ },
358
+
359
+ scrollContent: {
360
+ paddingTop: 0, // Ensure scroll starts at the top
361
+ },
362
+
363
+ headingContainer: {
364
+ width: '100%',
365
+ marginBottom: 0, // Remove margin to make persona very close
366
+ paddingHorizontal: 0,
367
+ },
368
+
369
+ title: {
370
+ fontFamily: 'IBM Plex Sans',
371
+ fontWeight: '700',
372
+ fontSize: 24,
373
+ lineHeight: 32,
374
+ color: COLORS.grey800,
375
+ textAlign: 'left',
376
+ marginBottom: 2,
377
+ },
378
+
379
+ subtitle: {
380
+ fontFamily: 'Inter',
381
+ fontWeight: '400',
382
+ fontSize: 16,
383
+ lineHeight: 24,
384
+ color: COLORS.grey600,
385
+ textAlign: 'left',
386
+ marginBottom: 0, // Remove bottom margin to bring persona closer
387
+ },
388
+
389
+ personaContainer: {
390
+ alignItems: 'center',
391
+ marginTop: -110, // Negative margin to pull persona up into header space
392
+ marginBottom: 0, // Remove bottom margin
393
+ },
394
+
395
+ largePersona: {
396
+ width: 650, // Make it bigger than default 200x200
397
+ height: 650,
398
+ marginTop: -20, // Additional negative margin to override internal spacing
399
+ marginBottom: -20, // Pull content below up as well
400
+ },
401
+
402
+ platformsContainer: {
403
+ paddingHorizontal: 0,
404
+ paddingTop: 8, // Reduced from 20 to minimize space at top of scroll area
405
+ paddingBottom: 120, // More space to account for fixed buttons at bottom
406
+ },
407
+
408
+ bottomContainer: {
409
+ position: 'absolute',
410
+ bottom: -40, // Position 40px from bottom of screen
411
+ left: 0,
412
+ right: 0,
413
+ paddingHorizontal: 0,
414
+ paddingBottom: SPACING.xl,
415
+ backgroundColor: COLORS.surface,
416
+ },
417
+
418
+ buttonContainer: {
419
+ marginBottom: 16,
420
+ },
421
+
422
+ skipContainer: {
423
+ alignItems: 'center',
424
+ },
425
+
426
+ skipButton: {
427
+ fontSize: 16,
428
+ fontFamily: 'Inter',
429
+ fontWeight: '500',
430
+ color: COLORS.grey600,
431
+ textAlign: 'center',
432
+ },
433
+ });
434
+
435
+ export default PlatformConnectorsStep;