@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,159 @@
|
|
|
1
|
+
## Capacitor Integration Guide (React/Vite → iOS/Android)
|
|
2
|
+
|
|
3
|
+
This guide is for teams shipping a Capacitor app (WKWebView) who want to integrate the `onairos` npm SDK with **minimal changes**.
|
|
4
|
+
|
|
5
|
+
### What you get
|
|
6
|
+
|
|
7
|
+
- **Same UI as mobile web** (SDK modal + onboarding + data request).
|
|
8
|
+
- **Works with dynamic import** (`await import('onairos')`) on iOS WKWebView.
|
|
9
|
+
- **OAuth connectors**: mobile-friendly redirect flows; Google-backed connectors use secure browser when available.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1) Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install onairos
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2) Vite config (recommended)
|
|
22
|
+
|
|
23
|
+
In your host app’s `vite.config.ts`, exclude `onairos` from dependency pre-bundling:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { defineConfig } from 'vite';
|
|
27
|
+
import react from '@vitejs/plugin-react';
|
|
28
|
+
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
plugins: [react()],
|
|
31
|
+
optimizeDeps: {
|
|
32
|
+
exclude: ['onairos'],
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 3) Add the SDK (single-line integration)
|
|
40
|
+
|
|
41
|
+
Render the button anywhere in your app:
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
import { OnairosButton } from 'onairos';
|
|
45
|
+
|
|
46
|
+
export default function SettingsScreen() {
|
|
47
|
+
return (
|
|
48
|
+
<OnairosButton
|
|
49
|
+
webpageName="My App"
|
|
50
|
+
requestData={['email', 'profile', 'social']}
|
|
51
|
+
onComplete={(result) => {
|
|
52
|
+
// result.approved
|
|
53
|
+
// result.apiResponse (when autoFetch is enabled)
|
|
54
|
+
console.log(result);
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### API key + base URL (recommended)
|
|
62
|
+
|
|
63
|
+
If you want to provide an API key / base URL without wiring env vars, set globals once before rendering:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
window.onairosApiKey = 'ona_...';
|
|
67
|
+
window.onairosBaseUrl = 'https://api2.onairos.uk'; // optional
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 4) Capacitor config (best experience)
|
|
73
|
+
|
|
74
|
+
The SDK will run without special config for many flows, but these settings make OAuth navigation far more reliable.
|
|
75
|
+
|
|
76
|
+
### `capacitor.config.*`
|
|
77
|
+
|
|
78
|
+
- **Recommended**: run iOS WebView as `https://localhost` (helps with OAuth and embedded widgets).
|
|
79
|
+
- **Recommended**: allow navigation to Onairos + OAuth domains so redirects stay in-app where appropriate.
|
|
80
|
+
|
|
81
|
+
Example:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"appId": "com.yourapp.id",
|
|
86
|
+
"appName": "Your App",
|
|
87
|
+
"webDir": "dist",
|
|
88
|
+
"server": {
|
|
89
|
+
"hostname": "localhost",
|
|
90
|
+
"iosScheme": "https",
|
|
91
|
+
"allowNavigation": [
|
|
92
|
+
"*.onairos.uk",
|
|
93
|
+
"onairos.uk",
|
|
94
|
+
"accounts.google.com",
|
|
95
|
+
"*.google.com",
|
|
96
|
+
"*.twitter.com",
|
|
97
|
+
"*.linkedin.com",
|
|
98
|
+
"*.reddit.com"
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Capacitor plugins (OAuth)
|
|
105
|
+
|
|
106
|
+
- **Recommended**: install the Browser plugin for Google-backed OAuth (YouTube/Gmail).
|
|
107
|
+
- Google often blocks embedded WKWebView with `disallowed_useragent`; a secure browser is required.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npm install @capacitor/browser
|
|
111
|
+
npx cap sync
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> Note: the SDK will still attempt to fall back gracefully if the plugin isn’t available, but Google-backed flows may be blocked by policy in embedded webviews.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 5) Build & run on device
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm run build
|
|
122
|
+
npx cap sync ios
|
|
123
|
+
npx cap open ios
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
In Xcode, select your iPhone and Run.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 6) Troubleshooting
|
|
131
|
+
|
|
132
|
+
### “import('onairos') crashes on iOS”
|
|
133
|
+
|
|
134
|
+
- Ensure you’re on a recent `onairos` version (5.2.x+ contains WKWebView import-time fixes).
|
|
135
|
+
- Ensure the host app isn’t polyfilling/rewriting globals that WKWebView doesn’t support.
|
|
136
|
+
|
|
137
|
+
### “OAuth returns but the modal closes / doesn’t reopen”
|
|
138
|
+
|
|
139
|
+
- Ensure your app isn’t stripping query params from `capacitor://localhost` navigations.
|
|
140
|
+
- If you have a router, make sure it doesn’t hard-reset to a “home screen” on every reload.
|
|
141
|
+
- The SDK uses localStorage/sessionStorage flags to reopen the modal after OAuth redirects.
|
|
142
|
+
|
|
143
|
+
### “Google button doesn’t show in Capacitor”
|
|
144
|
+
|
|
145
|
+
- Some iOS WKWebView origins (especially `capacitor://localhost`) don’t reliably support the embedded Google widget.
|
|
146
|
+
- Use `iosScheme: "https"` + `hostname: "localhost"` so the origin becomes `https://localhost`.
|
|
147
|
+
- For Google-backed OAuth connectors (YouTube/Gmail), install `@capacitor/browser` so the SDK can open a secure browser.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Capacitor (iOS WKWebView) Mock App Testing
|
|
2
|
+
|
|
3
|
+
This SDK previously bundled static imports of `@capacitor/*` into the published entrypoint, which meant **`import('onairos')` could evaluate Capacitor packages immediately**. In some iOS WKWebView environments, that evaluation can crash before any “platform guard” code runs.
|
|
4
|
+
|
|
5
|
+
We fixed this by removing **all static** `@capacitor/*` imports from `src/` and switching to runtime access via `window.Capacitor.Plugins.*` only when actually running in a native Capacitor app.
|
|
6
|
+
|
|
7
|
+
## What changed in the SDK (high level)
|
|
8
|
+
|
|
9
|
+
- Added `src/utils/capacitorPlugins.js` which only reads:
|
|
10
|
+
- `window.Capacitor`
|
|
11
|
+
- `window.Capacitor.isNativePlatform()`
|
|
12
|
+
- `window.Capacitor.Plugins.Browser`
|
|
13
|
+
- `window.Capacitor.Plugins.App`
|
|
14
|
+
- Updated the following files to use that helper instead of importing `@capacitor/*`:
|
|
15
|
+
- `src/onairosButton.jsx`
|
|
16
|
+
- `src/components/UniversalOnboarding.jsx`
|
|
17
|
+
- `src/components/GoogleButton.js`
|
|
18
|
+
- `src/components/EmailAuth.js`
|
|
19
|
+
- `src/components/connectors/GmailConnector.js`
|
|
20
|
+
- `src/components/connectors/YoutubeConnector.js`
|
|
21
|
+
- Verified the built entrypoints contain **no `@capacitor/*` imports**:
|
|
22
|
+
- `dist/onairos.esm.js`
|
|
23
|
+
- `dist/onairos.bundle.js`
|
|
24
|
+
|
|
25
|
+
## How to test on an iPhone via Xcode (mock Capacitor app)
|
|
26
|
+
|
|
27
|
+
### 1) Build/pack the SDK locally
|
|
28
|
+
|
|
29
|
+
From this repo (`onairos-npm`):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run build
|
|
33
|
+
npm pack
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This produces a tarball like `onairos-5.1.1.tgz`.
|
|
37
|
+
|
|
38
|
+
### 2) Create a new Capacitor app (React + Vite example)
|
|
39
|
+
|
|
40
|
+
In a separate folder (outside this repo is fine):
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm create vite@latest onairos-cap-test -- --template react
|
|
44
|
+
cd onairos-cap-test
|
|
45
|
+
npm install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Install Capacitor:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install @capacitor/core @capacitor/cli @capacitor/ios
|
|
52
|
+
npx cap init onairos.cap.test com.onairos.captest --web-dir dist
|
|
53
|
+
npx cap add ios
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 3) Install the SDK tarball into the mock app
|
|
57
|
+
|
|
58
|
+
From the mock app folder, install the tarball you created in step 1:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install /absolute/path/to/onairos-npm/onairos-5.1.1.tgz
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 4) Add a “dynamic import” crash test
|
|
65
|
+
|
|
66
|
+
In `src/App.jsx`, add a button like:
|
|
67
|
+
|
|
68
|
+
```jsx
|
|
69
|
+
import { useState } from 'react';
|
|
70
|
+
|
|
71
|
+
export default function App() {
|
|
72
|
+
const [status, setStatus] = useState('idle');
|
|
73
|
+
|
|
74
|
+
const testDynamicImport = async () => {
|
|
75
|
+
setStatus('importing...');
|
|
76
|
+
console.log('[cap-test] before import(onairos)');
|
|
77
|
+
try {
|
|
78
|
+
const mod = await import('onairos');
|
|
79
|
+
console.log('[cap-test] after import(onairos)', Object.keys(mod));
|
|
80
|
+
setStatus('import ok');
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error('[cap-test] import failed', e);
|
|
83
|
+
setStatus('import failed (caught)');
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div style={{ padding: 16 }}>
|
|
89
|
+
<button onClick={testDynamicImport}>Test import('onairos')</button>
|
|
90
|
+
<div>Status: {status}</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 5) Run on device
|
|
97
|
+
|
|
98
|
+
Build the web assets, sync, then open Xcode:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run build
|
|
102
|
+
npx cap sync ios
|
|
103
|
+
npx cap open ios
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
In Xcode:
|
|
107
|
+
- Select your connected iPhone as the run target
|
|
108
|
+
- Run
|
|
109
|
+
|
|
110
|
+
### 6) What “pass” looks like
|
|
111
|
+
|
|
112
|
+
- Tapping **Test import('onairos')** should **not crash the app**
|
|
113
|
+
- You should see logs:
|
|
114
|
+
- `[cap-test] before import(onairos)`
|
|
115
|
+
- `[cap-test] after import(onairos) ...`
|
|
116
|
+
|
|
117
|
+
If it still crashes *at import time*, it indicates there’s still some iOS-incompatible code being evaluated at module load (we can then binary-search by trimming exports / entrypoints further).
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## (NEW) Tailwind “host app pollution” test (preflight isolation)
|
|
122
|
+
|
|
123
|
+
The SDK ships Tailwind utilities for its own UI. However, Tailwind **preflight** (base layer) is a global reset that can unintentionally change the host app’s default element styles (e.g. `h1` margins).
|
|
124
|
+
|
|
125
|
+
To verify the SDK **does not** reset host styles:
|
|
126
|
+
|
|
127
|
+
### A) Add a host-style probe UI
|
|
128
|
+
|
|
129
|
+
In the mock app’s `src/App.jsx`, add a host “probe” that measures default `h1` margin **before and after** importing the SDK.
|
|
130
|
+
|
|
131
|
+
```jsx
|
|
132
|
+
import { useMemo, useRef, useState } from 'react';
|
|
133
|
+
|
|
134
|
+
export default function App() {
|
|
135
|
+
const h1Ref = useRef(null);
|
|
136
|
+
const [status, setStatus] = useState('idle');
|
|
137
|
+
const [probe, setProbe] = useState({ before: null, after: null });
|
|
138
|
+
|
|
139
|
+
const readH1Margin = () => {
|
|
140
|
+
const el = h1Ref.current;
|
|
141
|
+
if (!el) return null;
|
|
142
|
+
const cs = window.getComputedStyle(el);
|
|
143
|
+
return { marginTop: cs.marginTop, marginBottom: cs.marginBottom };
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const testDynamicImport = async () => {
|
|
147
|
+
setStatus('importing...');
|
|
148
|
+
const before = readH1Margin();
|
|
149
|
+
setProbe((p) => ({ ...p, before }));
|
|
150
|
+
console.log('[cap-test] h1 margin BEFORE import(onairos)', before);
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
const mod = await import('onairos');
|
|
154
|
+
console.log('[cap-test] after import(onairos)', Object.keys(mod));
|
|
155
|
+
} catch (e) {
|
|
156
|
+
console.error('[cap-test] import failed', e);
|
|
157
|
+
setStatus('import failed (caught)');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const after = readH1Margin();
|
|
162
|
+
setProbe((p) => ({ ...p, after }));
|
|
163
|
+
console.log('[cap-test] h1 margin AFTER import(onairos)', after);
|
|
164
|
+
setStatus('import ok');
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const same =
|
|
168
|
+
probe.before &&
|
|
169
|
+
probe.after &&
|
|
170
|
+
probe.before.marginTop === probe.after.marginTop &&
|
|
171
|
+
probe.before.marginBottom === probe.after.marginBottom;
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<div style={{ padding: 16, fontFamily: 'system-ui, sans-serif' }}>
|
|
175
|
+
<div style={{ border: '2px solid #f97316', padding: 12, borderRadius: 12 }}>
|
|
176
|
+
<div style={{ fontSize: 12, opacity: 0.75 }}>Host UI probe (should NOT change)</div>
|
|
177
|
+
<h1 ref={h1Ref} style={{ background: '#fee2e2' }}>
|
|
178
|
+
Host H1 default margins
|
|
179
|
+
</h1>
|
|
180
|
+
<div style={{ fontSize: 12 }}>
|
|
181
|
+
BEFORE: {probe.before ? JSON.stringify(probe.before) : '—'}<br />
|
|
182
|
+
AFTER: {probe.after ? JSON.stringify(probe.after) : '—'}<br />
|
|
183
|
+
Result: {probe.before && probe.after ? (same ? 'PASS ✅ (unchanged)' : 'FAIL ❌ (changed)') : '—'}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div style={{ height: 12 }} />
|
|
188
|
+
|
|
189
|
+
<button onClick={testDynamicImport} style={{ padding: 12, borderRadius: 10 }}>
|
|
190
|
+
Test import('onairos')
|
|
191
|
+
</button>
|
|
192
|
+
<div>Status: {status}</div>
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### B) Expected results
|
|
199
|
+
|
|
200
|
+
- **PASS**: The `h1` margins reported **before/after** import are identical.
|
|
201
|
+
- **FAIL**: The margins change after import (classic sign of Tailwind preflight/base being applied globally).
|
|
202
|
+
|
|
203
|
+
### C) Run on device
|
|
204
|
+
|
|
205
|
+
Same as above:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npm run build
|
|
209
|
+
npx cap sync ios
|
|
210
|
+
npx cap open ios
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
## Capacitor / iOS WKWebView Compatibility Fixes (SDK Summary)
|
|
2
|
+
|
|
3
|
+
This doc summarizes the changes made in the `onairos` npm package to ensure **Capacitor iOS (WKWebView)** compatibility, especially around **`import('onairos')`** stability, styling parity, and OAuth return behavior.
|
|
4
|
+
|
|
5
|
+
### Goals
|
|
6
|
+
|
|
7
|
+
- **No WKWebView crash at module import time** (including dynamic import).
|
|
8
|
+
- **Same UI styling/layout** as mobile Safari (SDK should look identical).
|
|
9
|
+
- **OAuth flows return back into the SDK modal** (especially on iOS where popups are unreliable).
|
|
10
|
+
- **Safe for web + mobile Safari** (changes are guarded and/or ESM-only when required).
|
|
11
|
+
|
|
12
|
+
### Key fixes (high-level)
|
|
13
|
+
|
|
14
|
+
- **Removed import-time WKWebView hazards**
|
|
15
|
+
- **No static `@capacitor/*` imports at module top-level** (prevents premature evaluation in environments that don’t fully support them).
|
|
16
|
+
- **Guarded all `process.env` access** with `typeof process !== 'undefined'` to prevent `ReferenceError: Can't find variable: process` on iOS.
|
|
17
|
+
- **Disabled ESM obfuscation** after it caused WebKit-specific TDZ crashes (`Cannot access uninitialized variable`).
|
|
18
|
+
|
|
19
|
+
- **Ensured SDK CSS always loads (no “unstyled Capacitor UI”)**
|
|
20
|
+
- `package.json` now includes `sideEffects: ["*.css"]` so bundlers do not tree-shake the SDK’s global CSS.
|
|
21
|
+
- `src/onairos.jsx` imports `src/styles/tailwind.css`.
|
|
22
|
+
- ESM output uses runtime CSS injection (via `style-loader`) to work reliably in Vite/Capacitor consumers.
|
|
23
|
+
|
|
24
|
+
- **Modal layout parity for Capacitor**
|
|
25
|
+
- `ModalPageLayout` treats Capacitor native as “mobile modal” and uses bottom-sheet sizing (safe-area friendly) instead of full-screen top-aligned layouts.
|
|
26
|
+
|
|
27
|
+
- **OAuth return reliability (don’t “lose the modal” after connecting)**
|
|
28
|
+
- The OAuth callback page and the SDK coordinate via localStorage/sessionStorage flags so that after iOS redirects/reloads, the SDK **reopens directly into UniversalOnboarding**.
|
|
29
|
+
- The SDK now stores a **clean** `onairos_return_url` (strips any stale `onairos_oauth_*` params) so the next connector does not inherit old OAuth-return query params.
|
|
30
|
+
|
|
31
|
+
### Files touched / where to look
|
|
32
|
+
|
|
33
|
+
- **Build / packaging**
|
|
34
|
+
- `package.json` (CSS sideEffects)
|
|
35
|
+
- `webpack.config.js` (ESM: style injection, obfuscation disabled)
|
|
36
|
+
|
|
37
|
+
- **WKWebView runtime safety**
|
|
38
|
+
- `src/components/UniversalOnboarding.jsx` (guarded env access; OAuth handling)
|
|
39
|
+
- `src/onairosButton.jsx` (OAuth return handling; modal restore)
|
|
40
|
+
- `src/utils/apiKeyValidation.js` (guarded `process.env.NODE_ENV`)
|
|
41
|
+
|
|
42
|
+
- **Styling parity**
|
|
43
|
+
- `src/onairos.jsx` (imports Tailwind CSS)
|
|
44
|
+
- `src/styles/tailwind.css`
|
|
45
|
+
|
|
46
|
+
- **OAuth callback page**
|
|
47
|
+
- `public/oauth-callback.html` (preserves/sets onboarding return flags for reliable modal restore)
|
|
48
|
+
|
|
49
|
+
### Known platform constraints (not SDK bugs)
|
|
50
|
+
|
|
51
|
+
- **Google Sign-In in embedded WKWebView**
|
|
52
|
+
- The embedded Google button (`@react-oauth/google` / `GoogleLogin`) can fail to render or be blocked in WKWebView contexts such as `capacitor://localhost` depending on origin/scheme and Google policy.
|
|
53
|
+
- For Google-backed OAuth connectors (YouTube/Gmail), Google commonly enforces **`disallowed_useragent`** in embedded webviews. The SDK therefore prefers **opening a secure system browser** in Capacitor (when available) for those flows.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Cross-SDK parity guide (from React Native implementation)
|
|
2
|
+
|
|
3
|
+
This document describes **behaviors and contracts** implemented in the Onairos **React Native** SDK so **web, iOS, Android, and other** SDKs can match them. It focuses on features that affect host-app integration: props, completion payloads, backend shapes, and polling rules.
|
|
4
|
+
|
|
5
|
+
For the **web** `OnairosButton` prop map and file locations, see [`ONAIROS_BUTTON_PROPS.md`](./ONAIROS_BUTTON_PROPS.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Completion contract: `OnairosResult` / `onComplete`
|
|
10
|
+
|
|
11
|
+
All first-party SDKs should converge on a single **success callback** shape (RN: `onComplete?: (result: OnairosResult) => void`).
|
|
12
|
+
|
|
13
|
+
### Core fields (always present when success fires)
|
|
14
|
+
|
|
15
|
+
| Field | Type | Meaning |
|
|
16
|
+
|--------|------|---------|
|
|
17
|
+
| `token` | `string` | Bearer token for authenticated calls to `apiUrl` and to `training.statusUrl` when polling. |
|
|
18
|
+
| `apiUrl` | `string` | Resolved data/inference URL from the mobile URL-resolution step (not necessarily the raw API base). |
|
|
19
|
+
| `approved` | `string[]` | Human-readable / tier ids the user approved (e.g. `basic`, `personality`, …). |
|
|
20
|
+
| `userData` | object | `email?`, `username?`, `connectedAccounts` (RN maps from `connectedPlatforms`), `skipped?`. |
|
|
21
|
+
|
|
22
|
+
### Optional fields (host apps should handle absence)
|
|
23
|
+
|
|
24
|
+
| Field | Type | Meaning |
|
|
25
|
+
|--------|------|---------|
|
|
26
|
+
| `apiResponse` | `any` | Populated when **`autoFetch`** successfully loaded user insights/traits after training is ready (or when traits-only path returns data). |
|
|
27
|
+
| `platformData` | `Record<string, any>` | Raw per-connector payloads (e.g. ChatGPT conversations/memories) when the flow attaches them. |
|
|
28
|
+
| `authorizedData` | `AuthorizedData` | Backend-aligned flags for what was authorized (see §2). |
|
|
29
|
+
| `training` | `TrainingStatus` | Training gate + polling hints (see §3–4). |
|
|
30
|
+
|
|
31
|
+
### Legacy callback
|
|
32
|
+
|
|
33
|
+
- **`onResolved(apiUrl, token, userData)`** — deprecated; may still fire for backward compatibility after `onComplete`. New integrations should use **`onComplete` only**.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 2. `authorizedData` (backend-aligned)
|
|
38
|
+
|
|
39
|
+
Other SDKs should use the **same keys** as the backend / JWT payload:
|
|
40
|
+
|
|
41
|
+
| Key | Meaning |
|
|
42
|
+
|-----|---------|
|
|
43
|
+
| `basic` | Always `true` when present in a valid authorization. |
|
|
44
|
+
| `personality?` | Personality / LLM profile tier. |
|
|
45
|
+
| `preferences?` | Inference / sentiment tier. |
|
|
46
|
+
| `rawMemories?` | Raw LLM conversation data tier. |
|
|
47
|
+
| `fastTraits?` | Fast traits mode (remote flag). |
|
|
48
|
+
| `wrappedTraits?` | Wrapped-app-only mode. |
|
|
49
|
+
|
|
50
|
+
**Parity rule:** Do not rename to older labels (`Small` / `Medium` / `Large`) in API responses; those may still appear in **UI-only** `requestData` in some apps, but **`authorizedData` in `OnairosResult` should match the table above.**
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 3. `training` / `TrainingStatus`
|
|
55
|
+
|
|
56
|
+
Returned from the same resolution step as `apiUrl` (e.g. after `/getAPIurlMobile`-style response is normalized).
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface TrainingStatus {
|
|
60
|
+
/** If true, the SDK may fetch from apiUrl immediately (subject to autoFetch). */
|
|
61
|
+
ready: boolean;
|
|
62
|
+
/** When ready is false, host or SDK polls this URL until training is done. */
|
|
63
|
+
statusUrl?: string;
|
|
64
|
+
/** Suggested delay between polls in milliseconds. */
|
|
65
|
+
pollIntervalMs?: number;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Example backend fragment (illustrative):**
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"apiUrl": "https://api2.onairos.uk/combinedInference",
|
|
74
|
+
"token": "eyJ...",
|
|
75
|
+
"authorizedData": {
|
|
76
|
+
"basic": true,
|
|
77
|
+
"personality": true,
|
|
78
|
+
"preferences": true,
|
|
79
|
+
"rawMemories": false
|
|
80
|
+
},
|
|
81
|
+
"training": {
|
|
82
|
+
"ready": true,
|
|
83
|
+
"statusUrl": "https://api2.onairos.uk/training/status",
|
|
84
|
+
"pollIntervalMs": 5000
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Default host:** RN defaults and fallbacks align with **`production` → `api2.onairos.uk`** when no environment is set (see changelog: routing / env).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 4. `autoFetch` + `backgroundLoadData` (training and data loading)
|
|
94
|
+
|
|
95
|
+
These two booleans control **who waits** for training and **who calls** `apiUrl`.
|
|
96
|
+
|
|
97
|
+
### Props
|
|
98
|
+
|
|
99
|
+
| Prop | Default | Purpose |
|
|
100
|
+
|------|---------|---------|
|
|
101
|
+
| `autoFetch` | `false` | If `true`, after URL resolution the SDK **POSTs** to `apiUrl` with the session token (and inference body when applicable) and merges the result into the completion payload (`apiResponse` / insights). |
|
|
102
|
+
| `backgroundLoadData` | `false` | If `true`, when training is **not** ready the SDK **does not** block on the built-in training UI for that branch; it returns **early** so the host can show custom loading and poll **`training.statusUrl`** itself. |
|
|
103
|
+
|
|
104
|
+
### Decision matrix (normative for parity)
|
|
105
|
+
|
|
106
|
+
Assume URL resolution returned `training` and `apiUrl` / `token`. Let “traits-only” mean `apiUrl` includes the substring **`traits-only`** (RN skips training wait for that case to align with web).
|
|
107
|
+
|
|
108
|
+
| `autoFetch` | `backgroundLoadData` | `training.ready` | Expected behavior |
|
|
109
|
+
|-------------|------------------------|------------------|-------------------|
|
|
110
|
+
| `false` | any | any | Return metadata only: `apiUrl`, `token`, `authorizedData`, `training`. **No** automatic fetch from `apiUrl`. Host fetches when ready. |
|
|
111
|
+
| `true` | `false` | `true` | SDK fetches from `apiUrl` (after any in-SDK training UI / socket rules). `apiResponse` populated when successful. |
|
|
112
|
+
| `true` | `false` | `false` + `statusUrl` + **not** traits-only | SDK **polls** `statusUrl` (see §5) until ready or timeout, then fetches from `apiUrl`. |
|
|
113
|
+
| `true` | `true` | `false` + `statusUrl` + **not** traits-only | SDK **returns immediately** with `data: null` / no `apiResponse`, **`training` unchanged** (`ready: false`). Host polls `statusUrl`, then fetches `apiUrl`. |
|
|
114
|
+
| `true` | any | `false` but **traits-only** `apiUrl` | **No** training poll (RN explicitly skips). Proceed to fetch `apiUrl` per inference/traits rules. |
|
|
115
|
+
|
|
116
|
+
**Parity note:** When `autoFetch=false` and `backgroundLoadData=true`, behavior matches **`autoFetch=false` and `backgroundLoadData=false`**: the host always owns fetching; the second flag mainly changes UX when **`autoFetch=true`** and training is pending.
|
|
117
|
+
|
|
118
|
+
**Web implementation:** `src/utils/pollTrainingStatus.js` (`pollTrainingStatus`, `normalizeTrainingFromResolution`) and `src/onairosButton.jsx` (`handleDataRequestComplete`, non–special apps only for the training gate).
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 5. Polling `training.statusUrl` (contract for all SDKs)
|
|
123
|
+
|
|
124
|
+
When the host (or the SDK in “blocking” mode) polls **`training.statusUrl`**, behavior should match RN’s `pollTrainingStatus`:
|
|
125
|
+
|
|
126
|
+
| Rule | RN behavior |
|
|
127
|
+
|------|-------------|
|
|
128
|
+
| HTTP method | `GET` |
|
|
129
|
+
| Headers | `Authorization: Bearer <token>` (same token as `apiUrl` fetch), `Content-Type: application/json`. |
|
|
130
|
+
| Interval | Prefer **`polling.recommendedIntervalMs`** from each JSON response when present (≥ 50 ms); else **`training.pollIntervalMs`** between attempts; default **5000 ms** if omitted. |
|
|
131
|
+
| Max attempts | **60** attempts (~5 minutes at 5s). |
|
|
132
|
+
| HTTP 429 | Wait using **`Retry-After`** header (seconds or HTTP-date), else JSON **`retryAfter`** / **`recommendedIntervalMs`**, else **max(500, 2 × pollIntervalMs)**; **retry without counting** as a failed attempt (RN `continue` in loop). |
|
|
133
|
+
| Other non-OK | Log, wait one interval, continue. |
|
|
134
|
+
| Success conditions | RN treats training as complete if any of: `data.ready === true`, `data.status === 'complete'`, or **heuristics** on `trainingStatus` / `trainingHistory` / `isCurrentlyTraining` / `lastTrainingDate` (see implementation). |
|
|
135
|
+
| Exhausted attempts | Returns “not ready”; RN may attach `neverTrained: true` on training object in some failure paths. |
|
|
136
|
+
|
|
137
|
+
**Parity rule:** Other SDKs should implement the **same URL, headers, interval, backoff, and max attempts**, or document intentional differences. Response JSON shape may evolve; RN already accepts **multiple** “ready” shapes—web should not assume a single field unless backend guarantees one.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 6. `autoFetch` data fetch (correct endpoint flow)
|
|
142
|
+
|
|
143
|
+
RN **does not** use a hardcoded `/developer/user-data` path for this flow. The normative sequence is:
|
|
144
|
+
|
|
145
|
+
1. Call mobile URL resolution (e.g. **`/getAPIurlMobile`**) → `{ apiUrl, token, authorizedData?, training? }`.
|
|
146
|
+
2. If `autoFetch` and conditions are met, **`POST`** to that **`apiUrl`** with `Authorization: Bearer <token>` and body from **`buildInferenceRequestBody(apiUrl, inferenceData)`** (may be empty/minimal for some URLs).
|
|
147
|
+
3. Normalize response for `apiResponse` / insights.
|
|
148
|
+
|
|
149
|
+
**Parity rule:** Web and native SDKs must use **`apiUrl` from step 1**, not a fixed traits URL, unless the resolved URL is explicitly traits-only.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 7. Related props (configuration parity)
|
|
154
|
+
|
|
155
|
+
These should exist with the **same names and semantics** on other surface APIs (button, headless flow, etc.):
|
|
156
|
+
|
|
157
|
+
| Prop | Purpose |
|
|
158
|
+
|------|---------|
|
|
159
|
+
| `trainingScreenMode` | `'real' \| 'mock'` — mock skips or simulates training UI where applicable. |
|
|
160
|
+
| `fastTraits` | Prefer faster trait generation (`traits-only-fast` vs `traits-only` style URLs in RN). |
|
|
161
|
+
| `inferenceData` | Host-provided payload for inference POST body; if missing when required, RN may fall back to traits-only with a warning. |
|
|
162
|
+
| `allowedPlatforms` / `recommendedPlatforms` | Filter and badge platform list; order preserved for allowlist. |
|
|
163
|
+
| `dataUsageDescription` | Custom pre-onboarding explainer copy. |
|
|
164
|
+
| `primaryAuthOnly` | Limit flow to primary auth when supported. |
|
|
165
|
+
| `useNewWelcomeFlow` | Swap to simplified welcome path (RN: fewer props honored on that path—document per SDK). |
|
|
166
|
+
| `apiKey` | Optional per-component init of API key service. |
|
|
167
|
+
| `skipApiKeyInitialization` | Test-only gate bypass (RN still checks init on press unless tests mock it). |
|
|
168
|
+
| `preferencesMbti` | (Web v7.1.2+) When `true` and `preferences` is in approved tiers, handshake sets `Info.Options.preferencesMbti` and inference POSTs include `preferencesMbti: true` for the server MBTI probe — see `sdk-integration/MBTI_INFERENCE_INPUT_PRESET.md`. |
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 8. Initialization and button visibility (RN parity with web)
|
|
173
|
+
|
|
174
|
+
- **`OnairosButton`** returns **`null`** until SDK auth initialization is **ready** (aligned with web: no tappable button before keys are valid).
|
|
175
|
+
- Optional **`apiKey`** on the button triggers **`initializeApiKey`** from the component when the key changes.
|
|
176
|
+
- **`skipApiKeyInitialization`** is for automated tests.
|
|
177
|
+
|
|
178
|
+
Other SDKs should expose the same **gate** behavior or document why (e.g. embedded web always has parent init).
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 9. JWT storage compatibility (RN-specific but affects API calls)
|
|
183
|
+
|
|
184
|
+
RN **`jwtStorageService` / `apiKeyService`** support a transition between **`sdk_jwt_token`** and **`onairos_jwt_token`**: read from the new key, fall back to legacy, mirror writes during migration. PIN and platform flows were updated to accept both.
|
|
185
|
+
|
|
186
|
+
**Parity rule:** Non-RN SDKs on the same backend should follow the **same key names** the backend expects when storing session JWTs for mobile.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 10. Training completion over socket (RN “Unreleased” / latest behavior)
|
|
191
|
+
|
|
192
|
+
Changelog (Unreleased): RN **does not** treat early socket events as final completion if they lack **traits-bearing** payloads; it waits for **`personality_analysis_complete`** or a completion payload that includes traits, so **`onComplete` is not fired prematurely** with metadata-only results.
|
|
193
|
+
|
|
194
|
+
**Parity rule:** Web and other clients using the same socket protocol should apply the **same completion gating** so `onComplete` / `apiResponse` semantics match RN.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 11. PIN / user API guard (RN)
|
|
199
|
+
|
|
200
|
+
`makeUserApiRequest()` hydrates JWT from persistence when the in-memory user token is missing (before failing auth).
|
|
201
|
+
|
|
202
|
+
**Parity rule:** Any SDK wrapper around user-authenticated HTTP should **load persisted session** the same way to avoid false “not authenticated” after cold start.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 12. `requestData` consent models (RN)
|
|
207
|
+
|
|
208
|
+
RN supports flexible **`requestData`** shapes (object, array of objects, array of strings) with defaults for missing descriptions. **`basic`** is always shown; **`rawMemories`** may only appear if allowed in `requestData` **and** the user connected an LLM platform.
|
|
209
|
+
|
|
210
|
+
**Parity rule:** Consent screens and “which toggles exist” logic should match across SDKs for the same `requestData` input.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 13. Known gaps to fix for parity inside RN
|
|
215
|
+
|
|
216
|
+
| Area | Issue |
|
|
217
|
+
|------|--------|
|
|
218
|
+
| **Exported `OnairosButtonProps`** | Re-exported from `src/types.ts`; may be **missing** props that `OnairosButton.tsx` accepts (`useNewWelcomeFlow`, `allowedPlatforms`, `apiKey`, etc.). Types should be unified. |
|
|
219
|
+
| **`executeOnairosFlow`** | Only forwards a **subset** of props to `UniversalOnboarding`; does not match the button surface. Headless flows on other platforms should still implement the full matrix in §4–6. |
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 14. Reference implementation (React Native)
|
|
224
|
+
|
|
225
|
+
| Concern | Primary files |
|
|
226
|
+
|---------|---------------|
|
|
227
|
+
| Result types | `src/components/OnairosButton.tsx` (`OnairosResult`, `TrainingStatus`, `AuthorizedData`) |
|
|
228
|
+
| URL resolution, autoFetch, polling | `src/components/UniversalOnboarding.tsx` (`fetchUserDataWithApiUrl`, `pollTrainingStatus`, `buildInferenceRequestBody`) |
|
|
229
|
+
| API config / env | `src/config/api.ts`, `src/services/apiKeyService.ts` |
|
|
230
|
+
| Changelog narrative | `CHANGELOG.md` (sections: `backgroundLoadData`, Background polling, `autoFetch` fix, AuthorizedData, requestData, Unreleased training/socket) |
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Changelog
|
|
235
|
+
|
|
236
|
+
- **2026-04-26** — Documented web `preferencesMbti` (MBTI inference input preset) for cross-SDK awareness; full contract in `sdk-integration/MBTI_INFERENCE_INPUT_PRESET.md`.
|
|
237
|
+
- **2026-04-22** — Added `docs/CROSS_SDK_PARITY.md` consolidating RN contracts for multi-SDK alignment.
|
|
238
|
+
- **2026-04-22** — Moved parity + web props docs under `docs/`; web implements `pollTrainingStatus`, `backgroundLoadData`, and related `OnairosButton` props (see `CHANGELOG.md`).
|
|
239
|
+
- **2026-04-24** — Polling aligns with **`GET …/training/status`** (legacy **`/mobile-training/status`**); `pollTrainingStatus` uses **`polling.recommendedIntervalMs`** and improved **429** handling. Developer guide: **`docs/DEVELOPER_SDK_CHANGES.md`**.
|