@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.
- package/CAPACITOR_QUICK_START.md +379 -0
- package/CONNECTORS.md +122 -0
- package/LICENSE +194 -10
- package/OnairosofficialOnairosCapacitor.podspec +13 -0
- package/Package.swift +26 -0
- package/README.md +176 -25
- package/dist/onairos.capacitor.esm.js +1 -0
- package/dist/onairos.capacitor.esm.turbopack.js +1 -0
- package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
- package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
- package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
- package/docs/CROSS_SDK_PARITY.md +239 -0
- package/docs/DATA_FREQUENCY.md +57 -0
- package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
- package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
- package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
- package/docs/PLATFORM_APIS.md +559 -0
- package/docs/RAW_MEMORIES_API.md +305 -0
- package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
- package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
- package/docs/oldFixes.md +216 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
- package/onairos.d.ts +656 -0
- package/package.json +188 -37
- package/src/OnairosReconnectButton.jsx +272 -0
- package/src/RSA.jsx +57 -0
- package/src/assets/NewLogo.png +0 -0
- package/src/assets/OnairosNewLogo.png +0 -0
- package/src/assets/chatgpt-icon.png +0 -0
- package/src/assets/fire-horse.png +0 -0
- package/src/assets/fire-horse.transparent.png +0 -0
- package/src/assets/latest-firehorse.png +0 -0
- package/src/assets/perplexity.png +0 -0
- package/src/assets/persona.png +0 -0
- package/src/assets/persona1.png +0 -0
- package/src/assets/persona2.png +0 -0
- package/src/assets/persona3.png +0 -0
- package/src/assets/persona4.png +0 -0
- package/src/assets/persona5.png +0 -0
- package/src/capacitorConnectorCatalog.js +38 -0
- package/src/capacitorOAuthConfig.js +52 -0
- package/src/chatgptHostedImport/index.js +303 -0
- package/src/components/AuthButtons.jsx +48 -0
- package/src/components/ConnectChatGPTModal.jsx +666 -0
- package/src/components/ConnectClaudeModal.jsx +610 -0
- package/src/components/ConnectGeminiModal.jsx +639 -0
- package/src/components/ConnectGrokModal.jsx +701 -0
- package/src/components/ConnectPerplexityModal.jsx +726 -0
- package/src/components/DataExplainerScreen.jsx +349 -0
- package/src/components/DataRequest.js +885 -0
- package/src/components/DataRequest.jsx +1055 -0
- package/src/components/EmailAuth.js +1871 -0
- package/src/components/EmailAuth.jsx +2062 -0
- package/src/components/ExtensionInstallPrompt.jsx +142 -0
- package/src/components/GoogleButton.js +133 -0
- package/src/components/LLMConnectorManager.jsx +201 -0
- package/src/components/LoadingPage.jsx +19 -0
- package/src/components/LoadingScreen.jsx +81 -0
- package/src/components/LunarBirthdate.jsx +96 -0
- package/src/components/LunarLoadingPage.jsx +251 -0
- package/src/components/Notification.jsx +21 -0
- package/src/components/OnairosAppButton.jsx +85 -0
- package/src/components/OnairosSSO.jsx +645 -0
- package/src/components/OnairosTrigger.jsx +61 -0
- package/src/components/PerplexityLogo.jsx +43 -0
- package/src/components/PinSetup.js +200 -0
- package/src/components/PinSetup.jsx +228 -0
- package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
- package/src/components/SdkErrorBoundary.jsx +36 -0
- package/src/components/SecuritySetup.js +81 -0
- package/src/components/SessionUserBar.jsx +83 -0
- package/src/components/SignUp.js +123 -0
- package/src/components/TestTelegramButton.js +53 -0
- package/src/components/TrainingComponent.jsx +200 -0
- package/src/components/TrainingScreen.jsx +897 -0
- package/src/components/UniversalOnboarding.js +306 -0
- package/src/components/UniversalOnboarding.jsx +4837 -0
- package/src/components/ValentineLoadingPage.jsx +502 -0
- package/src/components/ValentineModeSelector.jsx +162 -0
- package/src/components/WelcomeScreen.jsx +435 -0
- package/src/components/WrappedLoadingPage.jsx +205 -0
- package/src/components/connectors/ChatGPTConnector.js +348 -0
- package/src/components/connectors/ChatGPTConnector.jsx +348 -0
- package/src/components/connectors/ClaudeConnector.js +44 -0
- package/src/components/connectors/ClaudeConnector.jsx +44 -0
- package/src/components/connectors/GeminiConnector.js +170 -0
- package/src/components/connectors/GeminiConnector.jsx +170 -0
- package/src/components/connectors/GmailConnector.js +148 -0
- package/src/components/connectors/GmailConnector.jsx +148 -0
- package/src/components/connectors/GrokConnector.js +16 -0
- package/src/components/connectors/GrokConnector.jsx +16 -0
- package/src/components/connectors/HingeConnector.js +419 -0
- package/src/components/connectors/HingeConnector.jsx +419 -0
- package/src/components/connectors/InstagramDataConnector.js +726 -0
- package/src/components/connectors/InstagramDataConnector.jsx +726 -0
- package/src/components/connectors/LinkedInConnector.js +4 -0
- package/src/components/connectors/LinkedInConnector.jsx +296 -0
- package/src/components/connectors/PerplexityConnector.jsx +16 -0
- package/src/components/connectors/PinterestConnector.js +208 -0
- package/src/components/connectors/PinterestConnector.jsx +208 -0
- package/src/components/connectors/README.md +292 -0
- package/src/components/connectors/RedditConnector.js +229 -0
- package/src/components/connectors/RedditConnector.jsx +229 -0
- package/src/components/connectors/SephoraConnector.js +482 -0
- package/src/components/connectors/SephoraConnector.jsx +482 -0
- package/src/components/connectors/TikTokConnector.jsx +430 -0
- package/src/components/connectors/YoutubeConnector.js +361 -0
- package/src/components/connectors/YoutubeConnector.jsx +361 -0
- package/src/components/connectors/index.js +50 -0
- package/src/components/icons.jsx +46 -0
- package/src/components/icons.tsx +21 -0
- package/src/components/ui/PageLayout.jsx +1255 -0
- package/src/components/ui/PrimaryButton.jsx +162 -0
- package/src/components/ui/button.jsx +49 -0
- package/src/components/ui/card.jsx +61 -0
- package/src/components/ui/checkbox.jsx +33 -0
- package/src/components/ui/label.jsx +29 -0
- package/src/components/utils/UpdateConnections.js +45 -0
- package/src/components/utils/oauthHelper.js +97 -0
- package/src/config/api-config.js +138 -0
- package/src/deepLink.jsx +38 -0
- package/src/getPin.js +26 -0
- package/src/icons/Avatar.png +0 -0
- package/src/icons/Sentiment.png +0 -0
- package/src/icons/Trait.png +0 -0
- package/src/iframe/DataRequestPage.jsx +285 -0
- package/src/iframe/OnairosButtonIntegration.md +148 -0
- package/src/iframe/components/Box.jsx +56 -0
- package/src/iframe/components/IndividualConnection.jsx +88 -0
- package/src/iframe/dataRequestHandler.js +714 -0
- package/src/iframe/data_request_iframe.html +27 -0
- package/src/iframe/data_request_page.js +47 -0
- package/src/iframe/icons/Avatar.png +1 -0
- package/src/iframe/icons/Avatar2.png +1 -0
- package/src/iframe/icons/Sentiment.png +1 -0
- package/src/iframe/icons/Trait.png +1 -0
- package/src/iframe/icons/onairos_logo.png +0 -0
- package/src/iframe/utils/api.js +57 -0
- package/src/index.js +274 -0
- package/src/laravel/OnairosVue.vue +410 -0
- package/src/laravel/blade-helpers.js +320 -0
- package/src/laravel/vite-plugin.js +179 -0
- package/src/mobile/MobileDataRequestPage.jsx +233 -0
- package/src/mobile/components/MobileBox.jsx +71 -0
- package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
- package/src/mobile/shims/browser-apis.js +78 -0
- package/src/mobile/shims/lucide-shim.js +85 -0
- package/src/nativeConnectors.js +5 -0
- package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
- package/src/newUI/PlatformConnectorsStep.tsx +435 -0
- package/src/newUI/PrimaryButton.tsx +213 -0
- package/src/newUI/SignInStep.tsx +194 -0
- package/src/newUI/VerificationStep.tsx +133 -0
- package/src/newUI/WelcomeScreen.tsx +311 -0
- package/src/newUI/services/connectedAccountsService.js +129 -0
- package/src/onairos.capacitor.jsx +15 -0
- package/src/onairos.core.jsx +133 -0
- package/src/onairos.jsx +14 -0
- package/src/onairos.native.jsx +15 -0
- package/src/onairosButton.jsx +9000 -0
- package/src/overlay/CheckBox.jsx +114 -0
- package/src/overlay/IndividualConnection copy.js +86 -0
- package/src/overlay/IndividualConnection.js +191 -0
- package/src/overlay/IndividualConnectionNew.jsx +157 -0
- package/src/overlay/box.js +84 -0
- package/src/overlay/overlay.js +437 -0
- package/src/styles/onairos-scoped-preflight.css +97 -0
- package/src/styles/sdkCssRegistry.js +20 -0
- package/src/styles/styleLoaderInsertShadow.js +69 -0
- package/src/styles/tailwind.capacitor.css +395 -0
- package/src/styles/tailwind.css +395 -0
- package/src/theme/colors.js +40 -0
- package/src/utils/apiKeyValidation.js +341 -0
- package/src/utils/apiResponseLogger.js +316 -0
- package/src/utils/authHeaders.js +275 -0
- package/src/utils/biometrics.js +26 -0
- package/src/utils/bookmarkletUtils.js +28 -0
- package/src/utils/capacitorDetection.js +278 -0
- package/src/utils/capacitorLLMHelper.js +352 -0
- package/src/utils/capacitorPlugins.js +366 -0
- package/src/utils/crossDomainSSO.js +587 -0
- package/src/utils/deepLinking.js +27 -0
- package/src/utils/devLogger.js +46 -0
- package/src/utils/extensionDetection.js +418 -0
- package/src/utils/extractMemory.js +277 -0
- package/src/utils/framerBrandingOverrides.js +40 -0
- package/src/utils/googleWebClientId.js +55 -0
- package/src/utils/overlayHandler.js +224 -0
- package/src/utils/platformDisconnect.js +309 -0
- package/src/utils/pollTrainingStatus.js +200 -0
- package/src/utils/rawMemoriesAccess.js +211 -0
- package/src/utils/resolveBackendAppId.js +47 -0
- package/src/utils/responseFormatter.js +140 -0
- package/src/utils/sdkDebugStorage.js +113 -0
- package/src/utils/sdkInitialization.js +645 -0
- package/src/utils/sessionManager.js +1258 -0
- package/src/utils/startBackgroundTraining.js +100 -0
- package/src/utils/userDataFormatter.js +222 -0
- package/index.d.ts +0 -1
- 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;
|