@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,526 @@
|
|
|
1
|
+
# SDK PIN Integration - Required Changes
|
|
2
|
+
|
|
3
|
+
## Date: 2026-03-12
|
|
4
|
+
## Priority: HIGH
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Problem Summary
|
|
9
|
+
|
|
10
|
+
85% of Enoch users (306 out of 361) do not have their encrypted PIN stored in the database. This prevents model encryption from working and causes training completion failures.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Required SDK Changes
|
|
15
|
+
|
|
16
|
+
### 1. Store PIN After User Sets It
|
|
17
|
+
|
|
18
|
+
**When to call:** Immediately after user completes PIN setup in the app.
|
|
19
|
+
|
|
20
|
+
#### Endpoint
|
|
21
|
+
```
|
|
22
|
+
POST https://api2.onairos.uk/store-pin/mobile
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### Headers
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"Authorization": "Bearer <user_jwt_token>",
|
|
29
|
+
"Content-Type": "application/json"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### Request Body
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"username": "user@example.com",
|
|
37
|
+
"pin": "SecurePin123!"
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**PIN Requirements:**
|
|
42
|
+
- Minimum 8 characters
|
|
43
|
+
- At least 1 uppercase letter (A-Z)
|
|
44
|
+
- At least 1 symbol (!@#$%^&*(),.?":{}|<>)
|
|
45
|
+
|
|
46
|
+
#### Success Response (200 OK)
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"success": true,
|
|
50
|
+
"message": "PIN stored successfully",
|
|
51
|
+
"timestamp": "2026-03-12T15:30:00.000Z"
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Error Responses
|
|
56
|
+
|
|
57
|
+
**400 Bad Request - Missing Fields:**
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"success": false,
|
|
61
|
+
"message": "Username and PIN are required"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**400 Bad Request - Invalid PIN Format:**
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"success": false,
|
|
69
|
+
"message": "PIN must be at least 8 characters with 1 capital letter and 1 symbol"
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**401 Unauthorized - Invalid Token:**
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"success": false,
|
|
77
|
+
"message": "Invalid or expired token"
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**404 Not Found - User Not Found:**
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"success": false,
|
|
85
|
+
"message": "User not found"
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**500 Internal Server Error:**
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"success": false,
|
|
93
|
+
"message": "Internal server error"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### 2. Check PIN Status Before Training
|
|
100
|
+
|
|
101
|
+
**When to call:** Before initiating model training to ensure PIN is stored.
|
|
102
|
+
|
|
103
|
+
#### Endpoint
|
|
104
|
+
```
|
|
105
|
+
GET https://api2.onairos.uk/store-pin/status-by-email/{email}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Headers
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"Authorization": "Bearer <user_jwt_token>"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### URL Parameters
|
|
116
|
+
| Parameter | Type | Description |
|
|
117
|
+
|-----------|------|-------------|
|
|
118
|
+
| email | string | User's email address (URL encoded) |
|
|
119
|
+
|
|
120
|
+
#### Success Response (200 OK)
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"success": true,
|
|
124
|
+
"hasPinStored": true,
|
|
125
|
+
"userType": "Enoch",
|
|
126
|
+
"userName": "username",
|
|
127
|
+
"email": "user@example.com",
|
|
128
|
+
"userId": "60f1a2b3c4d5e6f7g8h9i0j1",
|
|
129
|
+
"debug": {
|
|
130
|
+
"encryptedPinType": "string",
|
|
131
|
+
"encryptedPinLength": 65,
|
|
132
|
+
"encryptedPinValue": "[HIDDEN]"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**When PIN is NOT stored:**
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"success": true,
|
|
141
|
+
"hasPinStored": false,
|
|
142
|
+
"userType": "Enoch",
|
|
143
|
+
"userName": "username",
|
|
144
|
+
"email": "user@example.com",
|
|
145
|
+
"userId": "60f1a2b3c4d5e6f7g8h9i0j1",
|
|
146
|
+
"debug": {
|
|
147
|
+
"encryptedPinType": "object",
|
|
148
|
+
"encryptedPinLength": 0,
|
|
149
|
+
"encryptedPinValue": "null"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Error Responses
|
|
155
|
+
|
|
156
|
+
**404 Not Found:**
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"success": false,
|
|
160
|
+
"message": "User not found in any database",
|
|
161
|
+
"searchedEmail": "user@example.com",
|
|
162
|
+
"searchedDatabases": ["Onairos", "Enoch"]
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### 3. Updated getAPIurlMobile Request
|
|
169
|
+
|
|
170
|
+
The `/getAPIurlMobile` endpoint now accepts and stores the encrypted PIN as a fallback.
|
|
171
|
+
|
|
172
|
+
#### Endpoint
|
|
173
|
+
```
|
|
174
|
+
POST https://api2.onairos.uk/getAPIurlMobile
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### Request Body
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"Info": {
|
|
181
|
+
"storage": "local",
|
|
182
|
+
"appId": "your-app-id",
|
|
183
|
+
"account": "user@example.com",
|
|
184
|
+
"confirmations": ["basic", "traits", "preferences"],
|
|
185
|
+
"EncryptedUserPin": "<encrypted_pin_string>",
|
|
186
|
+
"proofMode": false,
|
|
187
|
+
"fastTraits": false
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**IMPORTANT:**
|
|
193
|
+
- `EncryptedUserPin` should be the **actual encrypted PIN** (length > 20 characters)
|
|
194
|
+
- Do NOT send `"pending_pin_integration"` as placeholder
|
|
195
|
+
- If PIN is not available, omit the field entirely
|
|
196
|
+
|
|
197
|
+
#### Success Response (200 OK)
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"apiUrl": "https://api2.onairos.uk/combinedInference",
|
|
201
|
+
"token": "<jwt_token>",
|
|
202
|
+
"authorizedData": {
|
|
203
|
+
"basic": true,
|
|
204
|
+
"personality": true,
|
|
205
|
+
"preferences": true,
|
|
206
|
+
"rawMemories": false,
|
|
207
|
+
"fastTraits": false
|
|
208
|
+
},
|
|
209
|
+
"traitsMode": "standard",
|
|
210
|
+
"training": {
|
|
211
|
+
"ready": true,
|
|
212
|
+
"statusUrl": "https://api2.onairos.uk/mobile-training/status",
|
|
213
|
+
"pollIntervalMs": 5000
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## SDK Implementation Examples
|
|
221
|
+
|
|
222
|
+
### TypeScript/JavaScript SDK
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
class OnairosSDK {
|
|
226
|
+
private baseUrl = 'https://api2.onairos.uk';
|
|
227
|
+
private jwtToken: string;
|
|
228
|
+
|
|
229
|
+
constructor(jwtToken: string) {
|
|
230
|
+
this.jwtToken = jwtToken;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Store user's PIN - MUST be called after user sets PIN
|
|
235
|
+
*/
|
|
236
|
+
async storePin(username: string, pin: string): Promise<StorePinResponse> {
|
|
237
|
+
const response = await fetch(`${this.baseUrl}/store-pin/mobile`, {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
headers: {
|
|
240
|
+
'Authorization': `Bearer ${this.jwtToken}`,
|
|
241
|
+
'Content-Type': 'application/json'
|
|
242
|
+
},
|
|
243
|
+
body: JSON.stringify({ username, pin })
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
if (!response.ok) {
|
|
247
|
+
const error = await response.json();
|
|
248
|
+
throw new Error(error.message || 'Failed to store PIN');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return response.json();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Check if user has PIN stored - call before training
|
|
256
|
+
*/
|
|
257
|
+
async checkPinStatus(email: string): Promise<PinStatusResponse> {
|
|
258
|
+
const response = await fetch(
|
|
259
|
+
`${this.baseUrl}/store-pin/status-by-email/${encodeURIComponent(email)}`,
|
|
260
|
+
{
|
|
261
|
+
headers: {
|
|
262
|
+
'Authorization': `Bearer ${this.jwtToken}`
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
return response.json();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Initiate training with PIN check
|
|
272
|
+
*/
|
|
273
|
+
async initiateTraining(username: string, email: string): Promise<void> {
|
|
274
|
+
// Step 1: Check PIN status
|
|
275
|
+
const pinStatus = await this.checkPinStatus(email);
|
|
276
|
+
|
|
277
|
+
if (!pinStatus.hasPinStored) {
|
|
278
|
+
throw new Error('PIN_NOT_STORED: Please set your PIN before training');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Step 2: Proceed with training
|
|
282
|
+
// ... existing training logic
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Types
|
|
287
|
+
interface StorePinResponse {
|
|
288
|
+
success: boolean;
|
|
289
|
+
message: string;
|
|
290
|
+
timestamp: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
interface PinStatusResponse {
|
|
294
|
+
success: boolean;
|
|
295
|
+
hasPinStored: boolean;
|
|
296
|
+
userType: 'Onairos' | 'Enoch';
|
|
297
|
+
userName: string | null;
|
|
298
|
+
email: string | null;
|
|
299
|
+
userId: string | null;
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Swift (iOS) SDK
|
|
304
|
+
|
|
305
|
+
```swift
|
|
306
|
+
class OnairosSDK {
|
|
307
|
+
private let baseURL = "https://api2.onairos.uk"
|
|
308
|
+
private var jwtToken: String
|
|
309
|
+
|
|
310
|
+
init(jwtToken: String) {
|
|
311
|
+
self.jwtToken = jwtToken
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/// Store user's PIN - MUST be called after user sets PIN
|
|
315
|
+
func storePin(username: String, pin: String) async throws -> StorePinResponse {
|
|
316
|
+
guard let url = URL(string: "\(baseURL)/store-pin/mobile") else {
|
|
317
|
+
throw OnairosError.invalidURL
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
var request = URLRequest(url: url)
|
|
321
|
+
request.httpMethod = "POST"
|
|
322
|
+
request.setValue("Bearer \(jwtToken)", forHTTPHeaderField: "Authorization")
|
|
323
|
+
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
324
|
+
|
|
325
|
+
let body = ["username": username, "pin": pin]
|
|
326
|
+
request.httpBody = try JSONSerialization.data(withJSONObject: body)
|
|
327
|
+
|
|
328
|
+
let (data, response) = try await URLSession.shared.data(for: request)
|
|
329
|
+
|
|
330
|
+
guard let httpResponse = response as? HTTPURLResponse else {
|
|
331
|
+
throw OnairosError.invalidResponse
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if httpResponse.statusCode != 200 {
|
|
335
|
+
let errorResponse = try JSONDecoder().decode(ErrorResponse.self, from: data)
|
|
336
|
+
throw OnairosError.apiError(errorResponse.message)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return try JSONDecoder().decode(StorePinResponse.self, from: data)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/// Check if user has PIN stored - call before training
|
|
343
|
+
func checkPinStatus(email: String) async throws -> PinStatusResponse {
|
|
344
|
+
guard let encodedEmail = email.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed),
|
|
345
|
+
let url = URL(string: "\(baseURL)/store-pin/status-by-email/\(encodedEmail)") else {
|
|
346
|
+
throw OnairosError.invalidURL
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
var request = URLRequest(url: url)
|
|
350
|
+
request.setValue("Bearer \(jwtToken)", forHTTPHeaderField: "Authorization")
|
|
351
|
+
|
|
352
|
+
let (data, _) = try await URLSession.shared.data(for: request)
|
|
353
|
+
return try JSONDecoder().decode(PinStatusResponse.self, from: data)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
struct StorePinResponse: Codable {
|
|
358
|
+
let success: Bool
|
|
359
|
+
let message: String
|
|
360
|
+
let timestamp: String
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
struct PinStatusResponse: Codable {
|
|
364
|
+
let success: Bool
|
|
365
|
+
let hasPinStored: Bool
|
|
366
|
+
let userType: String
|
|
367
|
+
let userName: String?
|
|
368
|
+
let email: String?
|
|
369
|
+
let userId: String?
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
enum OnairosError: Error {
|
|
373
|
+
case invalidURL
|
|
374
|
+
case invalidResponse
|
|
375
|
+
case apiError(String)
|
|
376
|
+
case pinNotStored
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Kotlin (Android) SDK
|
|
381
|
+
|
|
382
|
+
```kotlin
|
|
383
|
+
class OnairosSDK(private val jwtToken: String) {
|
|
384
|
+
private val baseUrl = "https://api2.onairos.uk"
|
|
385
|
+
private val client = OkHttpClient()
|
|
386
|
+
private val json = Json { ignoreUnknownKeys = true }
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Store user's PIN - MUST be called after user sets PIN
|
|
390
|
+
*/
|
|
391
|
+
suspend fun storePin(username: String, pin: String): StorePinResponse {
|
|
392
|
+
val body = """{"username": "$username", "pin": "$pin"}"""
|
|
393
|
+
.toRequestBody("application/json".toMediaType())
|
|
394
|
+
|
|
395
|
+
val request = Request.Builder()
|
|
396
|
+
.url("$baseUrl/store-pin/mobile")
|
|
397
|
+
.addHeader("Authorization", "Bearer $jwtToken")
|
|
398
|
+
.post(body)
|
|
399
|
+
.build()
|
|
400
|
+
|
|
401
|
+
return withContext(Dispatchers.IO) {
|
|
402
|
+
client.newCall(request).execute().use { response ->
|
|
403
|
+
val responseBody = response.body?.string() ?: throw Exception("Empty response")
|
|
404
|
+
|
|
405
|
+
if (!response.isSuccessful) {
|
|
406
|
+
val error = json.decodeFromString<ErrorResponse>(responseBody)
|
|
407
|
+
throw Exception(error.message)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
json.decodeFromString<StorePinResponse>(responseBody)
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Check if user has PIN stored - call before training
|
|
417
|
+
*/
|
|
418
|
+
suspend fun checkPinStatus(email: String): PinStatusResponse {
|
|
419
|
+
val encodedEmail = URLEncoder.encode(email, "UTF-8")
|
|
420
|
+
|
|
421
|
+
val request = Request.Builder()
|
|
422
|
+
.url("$baseUrl/store-pin/status-by-email/$encodedEmail")
|
|
423
|
+
.addHeader("Authorization", "Bearer $jwtToken")
|
|
424
|
+
.get()
|
|
425
|
+
.build()
|
|
426
|
+
|
|
427
|
+
return withContext(Dispatchers.IO) {
|
|
428
|
+
client.newCall(request).execute().use { response ->
|
|
429
|
+
val responseBody = response.body?.string() ?: throw Exception("Empty response")
|
|
430
|
+
json.decodeFromString<PinStatusResponse>(responseBody)
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
@Serializable
|
|
437
|
+
data class StorePinResponse(
|
|
438
|
+
val success: Boolean,
|
|
439
|
+
val message: String,
|
|
440
|
+
val timestamp: String
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
@Serializable
|
|
444
|
+
data class PinStatusResponse(
|
|
445
|
+
val success: Boolean,
|
|
446
|
+
val hasPinStored: Boolean,
|
|
447
|
+
val userType: String,
|
|
448
|
+
val userName: String? = null,
|
|
449
|
+
val email: String? = null,
|
|
450
|
+
val userId: String? = null
|
|
451
|
+
)
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## Integration Flow
|
|
457
|
+
|
|
458
|
+
```
|
|
459
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
460
|
+
│ USER ONBOARDING FLOW │
|
|
461
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
462
|
+
│
|
|
463
|
+
▼
|
|
464
|
+
┌─────────────────┐
|
|
465
|
+
│ User Signs Up │
|
|
466
|
+
└────────┬────────┘
|
|
467
|
+
│
|
|
468
|
+
▼
|
|
469
|
+
┌─────────────────┐
|
|
470
|
+
│ User Sets PIN │
|
|
471
|
+
│ (in-app UI) │
|
|
472
|
+
└────────┬────────┘
|
|
473
|
+
│
|
|
474
|
+
▼
|
|
475
|
+
┌───────────────────────────────┐
|
|
476
|
+
│ SDK calls POST /store-pin/ │ ◄── REQUIRED
|
|
477
|
+
│ mobile with username & PIN │
|
|
478
|
+
└───────────────┬───────────────┘
|
|
479
|
+
│
|
|
480
|
+
▼
|
|
481
|
+
┌─────────────────┐
|
|
482
|
+
│ PIN stored in │
|
|
483
|
+
│ database │
|
|
484
|
+
└────────┬────────┘
|
|
485
|
+
│
|
|
486
|
+
▼
|
|
487
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
488
|
+
│ TRAINING FLOW │
|
|
489
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
490
|
+
│
|
|
491
|
+
▼
|
|
492
|
+
┌───────────────────────────────┐
|
|
493
|
+
│ SDK calls GET /store-pin/ │ ◄── RECOMMENDED
|
|
494
|
+
│ status-by-email/{email} │
|
|
495
|
+
└───────────────┬───────────────┘
|
|
496
|
+
│
|
|
497
|
+
┌─────────┴─────────┐
|
|
498
|
+
│ │
|
|
499
|
+
hasPinStored? hasPinStored?
|
|
500
|
+
= true = false
|
|
501
|
+
│ │
|
|
502
|
+
▼ ▼
|
|
503
|
+
┌──────────────┐ ┌──────────────────┐
|
|
504
|
+
│ Proceed │ │ Prompt user to │
|
|
505
|
+
│ Training │ │ set PIN │
|
|
506
|
+
└──────────────┘ └──────────────────┘
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
## Checklist for SDK Teams
|
|
512
|
+
|
|
513
|
+
- [ ] Add `storePin()` method that calls `POST /store-pin/mobile`
|
|
514
|
+
- [ ] Call `storePin()` immediately after user completes PIN setup UI
|
|
515
|
+
- [ ] Add `checkPinStatus()` method that calls `GET /store-pin/status-by-email/{email}`
|
|
516
|
+
- [ ] Call `checkPinStatus()` before initiating training
|
|
517
|
+
- [ ] Handle `hasPinStored: false` by prompting user to set PIN
|
|
518
|
+
- [ ] Remove `"pending_pin_integration"` placeholder - send actual PIN or omit field
|
|
519
|
+
- [ ] Add proper error handling for all PIN-related API calls
|
|
520
|
+
- [ ] Update SDK documentation with PIN requirements
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Questions?
|
|
525
|
+
|
|
526
|
+
Contact the backend team for any clarification on API endpoints or integration flow.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Prevents SDK render failures from unmounting the host React tree.
|
|
5
|
+
*/
|
|
6
|
+
export default class SdkErrorBoundary extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.state = { error: null };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static getDerivedStateFromError(error) {
|
|
13
|
+
return { error };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
componentDidCatch(error, errorInfo) {
|
|
17
|
+
try {
|
|
18
|
+
console.error('[Onairos] SDK render error (caught by SdkErrorBoundary):', error, errorInfo);
|
|
19
|
+
} catch (_) {}
|
|
20
|
+
try {
|
|
21
|
+
if (typeof this.props.onError === 'function') {
|
|
22
|
+
this.props.onError(error, errorInfo);
|
|
23
|
+
}
|
|
24
|
+
} catch (_) {}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
if (this.state.error) {
|
|
29
|
+
if (this.props.fallback != null) {
|
|
30
|
+
return this.props.fallback;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return this.props.children;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export default function SecuritySetup({ onComplete }) {
|
|
4
|
+
const [securityMethod, setSecurityMethod] = useState('pin');
|
|
5
|
+
|
|
6
|
+
const handlePinSetup = () => {
|
|
7
|
+
onComplete({ method: 'pin' });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const handleEmailSetup = () => {
|
|
11
|
+
onComplete({ method: 'email' });
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="max-w-md mx-auto bg-white rounded-lg shadow-lg p-6">
|
|
16
|
+
<h2 className="text-2xl font-bold text-center mb-6">Choose Security Method</h2>
|
|
17
|
+
|
|
18
|
+
<div className="space-y-4">
|
|
19
|
+
{/* PIN Security Option */}
|
|
20
|
+
<div
|
|
21
|
+
className={`p-4 border-2 rounded-lg cursor-pointer transition-colors ${
|
|
22
|
+
securityMethod === 'pin'
|
|
23
|
+
? 'border-blue-500 bg-blue-50'
|
|
24
|
+
: 'border-gray-200 hover:border-gray-300'
|
|
25
|
+
}`}
|
|
26
|
+
onClick={() => setSecurityMethod('pin')}
|
|
27
|
+
>
|
|
28
|
+
<div className="flex items-center">
|
|
29
|
+
<div className="w-8 h-8 mr-3 bg-blue-500 rounded-full flex items-center justify-center">
|
|
30
|
+
<span className="text-white font-bold">🔒</span>
|
|
31
|
+
</div>
|
|
32
|
+
<span className="text-gray-700">Secure with PIN</span>
|
|
33
|
+
</div>
|
|
34
|
+
<p className="text-sm text-gray-500 mt-2 ml-11">
|
|
35
|
+
Create a secure PIN for quick access
|
|
36
|
+
</p>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{/* Email Security Option */}
|
|
40
|
+
<div
|
|
41
|
+
className={`p-4 border-2 rounded-lg cursor-pointer transition-colors ${
|
|
42
|
+
securityMethod === 'email'
|
|
43
|
+
? 'border-green-500 bg-green-50'
|
|
44
|
+
: 'border-gray-200 hover:border-gray-300'
|
|
45
|
+
}`}
|
|
46
|
+
onClick={() => setSecurityMethod('email')}
|
|
47
|
+
>
|
|
48
|
+
<div className="flex items-center">
|
|
49
|
+
<div className="w-8 h-8 mr-3 bg-green-500 rounded-full flex items-center justify-center">
|
|
50
|
+
<span className="text-white font-bold">📧</span>
|
|
51
|
+
</div>
|
|
52
|
+
<span className="text-gray-700">Secure with Email</span>
|
|
53
|
+
</div>
|
|
54
|
+
<p className="text-sm text-gray-500 mt-2 ml-11">
|
|
55
|
+
Use email verification for security
|
|
56
|
+
</p>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div className="mt-6">
|
|
61
|
+
{securityMethod === 'pin' && (
|
|
62
|
+
<button
|
|
63
|
+
onClick={handlePinSetup}
|
|
64
|
+
className="w-full bg-blue-600 text-white py-3 px-4 rounded-lg hover:bg-blue-700 transition-colors"
|
|
65
|
+
>
|
|
66
|
+
Continue with PIN
|
|
67
|
+
</button>
|
|
68
|
+
)}
|
|
69
|
+
|
|
70
|
+
{securityMethod === 'email' && (
|
|
71
|
+
<button
|
|
72
|
+
onClick={handleEmailSetup}
|
|
73
|
+
className="w-full bg-green-600 text-white py-3 px-4 rounded-lg hover:bg-green-700 transition-colors"
|
|
74
|
+
>
|
|
75
|
+
Continue with Email
|
|
76
|
+
</button>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|