@onairosofficial/onairos-capacitor 0.1.1 → 0.1.3

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.
@@ -0,0 +1,379 @@
1
+ # Capacitor Quick Start Guide
2
+
3
+ ## TL;DR - What You Need to Know
4
+
5
+ ### ✅ **Core SDK works on iOS/Android via Capacitor**
6
+
7
+ The Onairos npm package works with React + Vite + Capacitor with **zero code changes** for core SDK flows (email auth, onboarding, data request).
8
+
9
+ **Note on Google login / Google-backed OAuth (YouTube/Gmail):**
10
+ - Embedded Google widgets can be blocked or fail to render in iOS WKWebView origins like `capacitor://localhost`.
11
+ - For the best experience, run your iOS WebView on `https://localhost` (`iosScheme: "https"`) and install `@capacitor/browser` so the SDK can open a secure browser when required by Google policy.
12
+
13
+ ### 🆕 **NEW: LLM Data Collection Without Browser Extension**
14
+
15
+ Capacitor apps can now collect LLM conversation data using the native API method - no browser extension required!
16
+
17
+ ---
18
+
19
+ ## Quick Setup (5 minutes)
20
+
21
+ ### 1. Install
22
+
23
+ ```bash
24
+ npm install onairos
25
+ ```
26
+
27
+ ### 2. Configure Vite
28
+
29
+ ```typescript
30
+ // vite.config.ts
31
+ export default defineConfig({
32
+ optimizeDeps: {
33
+ exclude: ['onairos']
34
+ }
35
+ });
36
+ ```
37
+
38
+ ### 3. Use OnairosButton (Same as Web!)
39
+
40
+ ```jsx
41
+ import { OnairosButton } from 'onairos';
42
+
43
+ function App() {
44
+ return (
45
+ <OnairosButton
46
+ requestData={["email", "profile"]}
47
+ webpageName="My iOS App"
48
+ onComplete={(result) => {
49
+ if (result.apiResponse) {
50
+ console.log('User data:', result.apiResponse);
51
+ }
52
+ }}
53
+ />
54
+ );
55
+ }
56
+ ```
57
+
58
+ That's it! You're done. 🎉
59
+
60
+ ---
61
+
62
+ ## LLM Data Collection (NEW!)
63
+
64
+ ### What's Changed?
65
+
66
+ **Before:** Browser extension required (didn't work in Capacitor)
67
+ **Now:** Direct API method available for Capacitor/mobile apps
68
+
69
+ ### How to Use
70
+
71
+ ```jsx
72
+ import {
73
+ OnairosButton,
74
+ storeCapacitorLLMData,
75
+ isCapacitor
76
+ } from 'onairos';
77
+
78
+ function App() {
79
+ const [userInfo, setUserInfo] = useState(null);
80
+
81
+ // 1. Get user info from Onairos
82
+ const handleComplete = (result) => {
83
+ if (result.apiResponse) {
84
+ setUserInfo({
85
+ username: result.apiResponse.email,
86
+ userId: result.apiResponse.userId,
87
+ sessionToken: result.apiResponse.token
88
+ });
89
+ }
90
+ };
91
+
92
+ // 2. Collect LLM conversation data
93
+ const collectLLMData = async (messages) => {
94
+ const result = await storeCapacitorLLMData(
95
+ {
96
+ messages: messages,
97
+ timestamp: new Date().toISOString()
98
+ },
99
+ userInfo,
100
+ 'chatgpt' // or 'claude', 'gemini', 'grok'
101
+ );
102
+
103
+ if (result.success) {
104
+ console.log('✅ LLM data stored!');
105
+ }
106
+ };
107
+
108
+ return (
109
+ <div>
110
+ <OnairosButton
111
+ requestData={["email", "profile"]}
112
+ webpageName="My App"
113
+ onComplete={handleComplete}
114
+ />
115
+
116
+ {userInfo && (
117
+ <button onClick={() => {
118
+ collectLLMData([
119
+ { role: 'user', content: 'Hello' },
120
+ { role: 'assistant', content: 'Hi!' }
121
+ ]);
122
+ }}>
123
+ Store LLM Conversation
124
+ </button>
125
+ )}
126
+ </div>
127
+ );
128
+ }
129
+ ```
130
+
131
+ ### Available Functions
132
+
133
+ ```jsx
134
+ import {
135
+ // Platform detection
136
+ isCapacitor,
137
+ isMobileApp,
138
+ getPlatformInfo,
139
+
140
+ // LLM data collection
141
+ storeCapacitorLLMData, // Store single conversation
142
+ storeBatchLLMData, // Store multiple conversations
143
+ getLLMHistory, // Retrieve history
144
+ getLLMStats, // Get usage stats
145
+ formatConversationData // Helper to format data
146
+ } from 'onairos';
147
+ ```
148
+
149
+ ---
150
+
151
+ ## What Works & What Doesn't
152
+
153
+ ### ✅ Works Perfectly (No Changes Needed)
154
+
155
+ - All React components
156
+ - Data requests (email, profile, social, etc.)
157
+ - API calls and authentication
158
+ - OAuth flows (auto-converts popups to redirects)
159
+ - Touch interactions
160
+ - **NEW:** LLM data collection via native method
161
+
162
+ ### ❌ Not Available in Capacitor
163
+
164
+ - Browser extension (web-only feature)
165
+ - Browser extension LLM monitoring (use native method instead)
166
+
167
+ ---
168
+
169
+ ## Changes Required
170
+
171
+ ### For Core Functionality: **ZERO**
172
+
173
+ The same code works on web and Capacitor:
174
+
175
+ ```jsx
176
+ // This exact code works on web AND Capacitor
177
+ <OnairosButton
178
+ requestData={["email", "profile"]}
179
+ webpageName="My App"
180
+ onComplete={(result) => console.log(result)}
181
+ />
182
+ ```
183
+
184
+ ### For LLM Data Collection: **Add One Function Call**
185
+
186
+ Instead of relying on browser extension (doesn't work in Capacitor), use the native method:
187
+
188
+ ```jsx
189
+ // Import the Capacitor-specific LLM function
190
+ import { storeCapacitorLLMData } from 'onairos';
191
+
192
+ // Use it to store LLM data
193
+ await storeCapacitorLLMData(conversationData, userInfo, platform);
194
+ ```
195
+
196
+ That's the only change needed!
197
+
198
+ ---
199
+
200
+ ## Example: Full Capacitor App with LLM
201
+
202
+ ```jsx
203
+ import React, { useState, useEffect } from 'react';
204
+ import {
205
+ OnairosButton,
206
+ storeCapacitorLLMData,
207
+ isCapacitor,
208
+ getPlatformInfo
209
+ } from 'onairos';
210
+
211
+ function MyCapacitorApp() {
212
+ const [userInfo, setUserInfo] = useState(null);
213
+ const [platform, setPlatform] = useState(null);
214
+
215
+ useEffect(() => {
216
+ // Check platform
217
+ const info = getPlatformInfo();
218
+ setPlatform(info);
219
+
220
+ if (isCapacitor()) {
221
+ console.log('✅ Running in Capacitor on', info.platform);
222
+ }
223
+ }, []);
224
+
225
+ const handleOnairosComplete = (result) => {
226
+ if (result.apiResponse) {
227
+ // Save user info for later use
228
+ const user = {
229
+ username: result.apiResponse.email,
230
+ userId: result.apiResponse.userId,
231
+ sessionToken: result.apiResponse.token
232
+ };
233
+
234
+ setUserInfo(user);
235
+ localStorage.setItem('userInfo', JSON.stringify(user));
236
+ }
237
+ };
238
+
239
+ const storeChatConversation = async (messages, llmPlatform) => {
240
+ if (!userInfo) {
241
+ alert('Please connect with Onairos first');
242
+ return;
243
+ }
244
+
245
+ const result = await storeCapacitorLLMData(
246
+ {
247
+ messages: messages,
248
+ timestamp: new Date().toISOString()
249
+ },
250
+ userInfo,
251
+ llmPlatform
252
+ );
253
+
254
+ if (result.success) {
255
+ alert('✅ Conversation saved!');
256
+ } else {
257
+ alert('❌ Error: ' + result.error);
258
+ }
259
+ };
260
+
261
+ return (
262
+ <div className="app">
263
+ <h1>My Capacitor App</h1>
264
+
265
+ {platform && (
266
+ <p>Platform: {platform.platform} | Capacitor: {platform.isCapacitor ? 'Yes' : 'No'}</p>
267
+ )}
268
+
269
+ <OnairosButton
270
+ requestData={["email", "profile", "social"]}
271
+ webpageName="My Capacitor App"
272
+ autoFetch={true}
273
+ onComplete={handleOnairosComplete}
274
+ />
275
+
276
+ {userInfo && (
277
+ <div className="llm-section">
278
+ <h2>LLM Data Collection</h2>
279
+ <p>✅ Connected as: {userInfo.username}</p>
280
+
281
+ <button onClick={() => {
282
+ storeChatConversation([
283
+ { role: 'user', content: 'What is AI?' },
284
+ { role: 'assistant', content: 'AI is artificial intelligence...' }
285
+ ], 'chatgpt');
286
+ }}>
287
+ Save ChatGPT Conversation
288
+ </button>
289
+
290
+ <button onClick={() => {
291
+ storeChatConversation([
292
+ { role: 'user', content: 'Hello Claude' },
293
+ { role: 'assistant', content: 'Hello! How can I help?' }
294
+ ], 'claude');
295
+ }}>
296
+ Save Claude Conversation
297
+ </button>
298
+ </div>
299
+ )}
300
+ </div>
301
+ );
302
+ }
303
+
304
+ export default MyCapacitorApp;
305
+ ```
306
+
307
+ ---
308
+
309
+ ## iOS Configuration
310
+
311
+ Add to `ios/App/App/Info.plist`:
312
+
313
+ ```xml
314
+ <key>NSAppTransportSecurity</key>
315
+ <dict>
316
+ <key>NSAllowsArbitraryLoads</key>
317
+ <true/>
318
+ </dict>
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Testing
324
+
325
+ ```bash
326
+ # iOS
327
+ npm run build
328
+ npx cap sync ios
329
+ npx cap open ios
330
+
331
+ # Android
332
+ npm run build
333
+ npx cap sync android
334
+ npx cap open android
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Common Questions
340
+
341
+ ### Q: Do I need to change my code for Capacitor?
342
+ **A:** No, for core functionality. Only add `storeCapacitorLLMData` if you want LLM data collection.
343
+
344
+ ### Q: Does the browser extension work in Capacitor?
345
+ **A:** No, but you don't need it. Use `storeCapacitorLLMData` instead for LLM data.
346
+
347
+ ### Q: Can I use the same code on web and Capacitor?
348
+ **A:** Yes! The package automatically detects the environment and adapts.
349
+
350
+ ### Q: How do I collect ChatGPT/Claude conversations?
351
+ **A:** Use `storeCapacitorLLMData` - see examples above.
352
+
353
+ ### Q: What about OAuth popups?
354
+ **A:** Automatically converted to redirects on mobile. No code changes needed.
355
+
356
+ ---
357
+
358
+ ## What Your Developer Needs to Do
359
+
360
+ 1. ✅ Install `onairos` via npm
361
+ 2. ✅ Add Vite config (`exclude: ['onairos']`)
362
+ 3. ✅ Use `OnairosButton` component (same as web)
363
+ 4. ✅ **Optional:** Import `storeCapacitorLLMData` for LLM data collection
364
+
365
+ **Total changes:** ~5 lines of config + normal component usage
366
+
367
+ ---
368
+
369
+ ## More Help
370
+
371
+ - **Full Guide:** [CAPACITOR_IOS_INTEGRATION.md](./CAPACITOR_IOS_INTEGRATION.md)
372
+ - **Mobile Compatibility:** [MOBILE_BROWSER_COMPATIBILITY.md](./MOBILE_BROWSER_COMPATIBILITY.md)
373
+ - **Main README:** [README.md](./README.md)
374
+
375
+ ---
376
+
377
+ **Bottom Line:** Everything works. LLM data collection now available via native method. Your developer is good to go! 🚀
378
+
379
+
package/CONNECTORS.md ADDED
@@ -0,0 +1,122 @@
1
+ # Onairos Connectors Reference
2
+
3
+ ## Available Connectors
4
+
5
+ | Connector | Type | ID | Description |
6
+ |-----------|------|-----|-------------|
7
+ | **ChatGPT** | LLM | `chatgpt` | OpenAI ChatGPT conversations |
8
+ | **Claude** | LLM | `claude` | Anthropic Claude conversations |
9
+ | **Gemini** | LLM | `gemini` | Google Gemini conversations |
10
+ | **Grok** | LLM | `grok` | X/Twitter Grok conversations |
11
+ | **YouTube** | OAuth | `youtube` | Watch history & subscriptions |
12
+ | **Gmail** | OAuth | `gmail` | Email metadata & patterns |
13
+ | **LinkedIn** | OAuth | `linkedin` | Professional profile & connections |
14
+ | **Pinterest** | OAuth | `pinterest` | Pins & boards |
15
+ | **Reddit** | OAuth | `reddit` | Posts, comments & subscriptions |
16
+ | **Instagram** | Data | `instagram-data` | Profile & interactions |
17
+ | **X (Twitter)** | OAuth | `x` | Posts & interactions |
18
+
19
+ ---
20
+
21
+ ## Quick Start
22
+
23
+ ### Show All Connectors (Default)
24
+ ```jsx
25
+ <OnairosButton webpageName="MyApp" />
26
+ ```
27
+
28
+ ### Show Only LLM Connectors
29
+ ```jsx
30
+ <OnairosButton
31
+ webpageName="MyApp"
32
+ rawMemoriesOnly={true}
33
+ />
34
+ // Shows: ChatGPT, Claude, Gemini, Grok
35
+ ```
36
+
37
+ ### Show Specific Connectors
38
+ ```jsx
39
+ <OnairosButton
40
+ webpageName="MyApp"
41
+ allowedPlatforms={['ChatGPT', 'YouTube', 'Gmail']}
42
+ />
43
+ // Shows only: ChatGPT, YouTube, Gmail
44
+ ```
45
+
46
+ ### Prioritize a Connector
47
+ ```jsx
48
+ <OnairosButton
49
+ webpageName="MyApp"
50
+ priorityPlatform="gmail"
51
+ />
52
+ // Shows all, but Gmail is highlighted first
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Props Reference
58
+
59
+ | Prop | Type | Default | Description |
60
+ |------|------|---------|-------------|
61
+ | `allowedPlatforms` | `string[]` | `null` | List of connector names/IDs to show. `null` = all |
62
+ | `rawMemoriesOnly` | `boolean` | `false` | Show only LLM connectors |
63
+ | `priorityPlatform` | `string` | `null` | Connector to highlight/prioritize |
64
+
65
+ ---
66
+
67
+ ## Examples
68
+
69
+ ### Social Media App
70
+ ```jsx
71
+ <OnairosButton
72
+ webpageName="SocialApp"
73
+ allowedPlatforms={['Instagram', 'YouTube', 'X']}
74
+ />
75
+ ```
76
+
77
+ ### AI/Chat App
78
+ ```jsx
79
+ <OnairosButton
80
+ webpageName="AIApp"
81
+ rawMemoriesOnly={true}
82
+ />
83
+ ```
84
+
85
+ ### Professional App
86
+ ```jsx
87
+ <OnairosButton
88
+ webpageName="ProApp"
89
+ allowedPlatforms={['LinkedIn', 'Gmail']}
90
+ priorityPlatform="linkedin"
91
+ />
92
+ ```
93
+
94
+ ### Shopping/Lifestyle App
95
+ ```jsx
96
+ <OnairosButton
97
+ webpageName="LifestyleApp"
98
+ allowedPlatforms={['Pinterest', 'Instagram', 'YouTube']}
99
+ />
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Connector IDs (for allowedPlatforms)
105
+
106
+ Use any of these values in the `allowedPlatforms` array:
107
+
108
+ ```
109
+ chatgpt, claude, gemini, grok,
110
+ youtube, gmail, linkedin, pinterest,
111
+ reddit, instagram, x
112
+ ```
113
+
114
+ **Note:** Both the display name (`ChatGPT`) and connector ID (`chatgpt`) work.
115
+
116
+ ---
117
+
118
+ ## Need Help?
119
+
120
+ - Documentation: https://docs.onairos.uk
121
+ - Support: support@onairos.uk
122
+
@@ -0,0 +1,13 @@
1
+ Pod::Spec.new do |s|
2
+ s.name = 'OnairosofficialOnairosCapacitor'
3
+ s.version = '0.1.3'
4
+ s.summary = 'Capacitor SDK and native WKWebView connectors for Onairos apps.'
5
+ s.license = { :type => 'Apache-2.0' }
6
+ s.homepage = 'https://onairos.io'
7
+ s.author = { 'Onairos' => 'team@onairos.io' }
8
+ s.source = { :git => 'https://github.com/zd819/onairos-capacitor.git', :tag => s.version.to_s }
9
+ s.source_files = 'ios/Sources/**/*.{swift,h,m}'
10
+ s.ios.deployment_target = '15.0'
11
+ s.swift_version = '5.9'
12
+ s.dependency 'Capacitor'
13
+ end
package/Package.swift ADDED
@@ -0,0 +1,26 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "OnairosofficialOnairosCapacitor",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "OnairosofficialOnairosCapacitor",
10
+ targets: ["OnairosNativeConnectorsPlugin"]
11
+ )
12
+ ],
13
+ dependencies: [
14
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
15
+ ],
16
+ targets: [
17
+ .target(
18
+ name: "OnairosNativeConnectorsPlugin",
19
+ dependencies: [
20
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
21
+ .product(name: "Cordova", package: "capacitor-swift-pm")
22
+ ],
23
+ path: "ios/Sources/OnairosNativeConnectorsPlugin"
24
+ )
25
+ ]
26
+ )
package/README.md CHANGED
@@ -1,28 +1,22 @@
1
- # onairos-npm-capacitor
1
+ # @onairosofficial/onairos-capacitor
2
2
 
3
3
  Capacitor-first Onairos SDK package for React, Vite, iOS, and Android apps.
4
4
 
5
5
  The package root exports the Capacitor-safe SDK entry:
6
6
 
7
7
  ```jsx
8
- import { OnairosButton, SUPPORTED_PLATFORMS } from 'onairos-npm-capacitor';
8
+ import { OnairosButton, SUPPORTED_PLATFORMS } from '@onairosofficial/onairos-capacitor';
9
9
  ```
10
10
 
11
11
  ## Install
12
12
 
13
13
  ```bash
14
- npm install onairos-npm-capacitor
14
+ npm install @onairosofficial/onairos-capacitor
15
15
  npm install @capacitor/core @capacitor/app @capacitor/browser @capgo/capacitor-social-login
16
- ```
17
-
18
- For native LLM/WebView data connectors such as Spotify, install the bundled native connector package too:
19
-
20
- ```bash
21
- npm install @onairosofficial/capacitor-llm-onairos
22
16
  npx cap sync ios
23
17
  ```
24
18
 
25
- This repo includes a local SPM-capable copy of `@onairosofficial/capacitor-llm-onairos` at `packages/capacitor-llm-onairos`. The test app links it with a file dependency so `npx cap sync ios` includes the native Swift plugin implementations.
19
+ The package includes the Capacitor iOS plugin files for native WKWebView connectors such as Spotify and ChatGPT. Consumers do not need to install a separate Onairos native connector package.
26
20
 
27
21
  ## Build This Package
28
22
 
@@ -64,7 +58,7 @@ export default defineConfig({
64
58
  },
65
59
  optimizeDeps: {
66
60
  include: ['react', 'react-dom', 'react/jsx-runtime'],
67
- exclude: ['onairos-npm-capacitor'],
61
+ exclude: ['@onairosofficial/onairos-capacitor'],
68
62
  },
69
63
  });
70
64
  ```
@@ -112,25 +106,37 @@ This is what brings users back from OAuth connectors like YouTube, TikTok, Pinte
112
106
 
113
107
  ## Google Sign-In
114
108
 
115
- Capacitor apps must provide their own Google OAuth client IDs:
109
+ A packaged Capacitor project is a native mobile app for Google OAuth. It does not need to be listed in the App Store or Google Play, but the developer must create native OAuth credentials for the app's identity:
110
+
111
+ - iOS: create an **iOS** OAuth client using the exact bundle ID from `capacitor.config.*` (`appId`).
112
+ - Android: create an **Android** OAuth client using the same package name plus the SHA-1 fingerprint of the debug or release signing certificate.
113
+
114
+ The developer passes only those native client IDs to the SDK:
116
115
 
117
116
  ```jsx
118
- import { updateGoogleClientIds } from 'onairos-npm-capacitor';
117
+ import { updateGoogleClientIds } from '@onairosofficial/onairos-capacitor';
119
118
 
120
119
  updateGoogleClientIds({
121
- webClientId: import.meta.env.VITE_ONAIROS_GOOGLE_WEB_CLIENT_ID,
122
120
  iosClientId: import.meta.env.VITE_ONAIROS_GOOGLE_IOS_CLIENT_ID,
123
121
  androidClientId: import.meta.env.VITE_ONAIROS_GOOGLE_ANDROID_CLIENT_ID,
124
- serverClientId: import.meta.env.VITE_ONAIROS_GOOGLE_WEB_CLIENT_ID,
125
122
  });
126
123
  ```
127
124
 
128
- For iOS Google login, also add the reversed iOS client ID URL scheme that Google provides to `Info.plist`.
125
+ Do not set `webClientId` or `serverClientId` to an iOS or Android client ID. Since `0.1.3`, the SDK owns those values and defaults both to the Onairos web OAuth client that the backend verifies. The native client identifies the installed app; the web/server client is the ID token's `aud` value. Mixing them causes `Google token audience mismatch`.
126
+
127
+ ### Google Cloud setup
128
+
129
+ 1. Configure the OAuth consent screen in the Google Cloud project used for the native app.
130
+ 2. For iOS, create an iOS OAuth client using the exact `appId`/bundle ID. Add Google's reversed iOS client ID as a URL scheme in `ios/App/App/Info.plist`, then run `npx cap sync ios`.
131
+ 3. For Android, create an Android OAuth client using the exact `appId`/package name and signing SHA-1. Use `cd android && ./gradlew signingReport` (or `.\gradlew signingReport` on Windows) to obtain the debug SHA-1, and create a separate credential for the production signing key. Add the Google-generated native configuration required by `@capgo/capacitor-social-login`, then run `npx cap sync android`.
132
+ 4. Keep native client IDs in environment configuration. They are OAuth identifiers rather than client secrets, but environment configuration prevents accidental cross-app reuse.
133
+
134
+ The app does not need to be published in either store for these credentials to work in local development, TestFlight, or internal testing.
129
135
 
130
136
  ## Basic Usage
131
137
 
132
138
  ```jsx
133
- import { OnairosButton } from 'onairos-npm-capacitor';
139
+ import { OnairosButton } from '@onairosofficial/onairos-capacitor';
134
140
 
135
141
  export default function App() {
136
142
  return (
@@ -175,7 +181,7 @@ npm run test:package
175
181
  npm publish
176
182
  ```
177
183
 
178
- The package is currently prepared as `0.1.1`.
184
+ The package is currently prepared as `0.1.3`.
179
185
 
180
186
  ## Local Test App
181
187
 
@@ -193,7 +199,6 @@ For local development, create `test-app/.env.local` with:
193
199
 
194
200
  ```bash
195
201
  VITE_ONAIROS_API_KEY=...
196
- VITE_ONAIROS_GOOGLE_WEB_CLIENT_ID=...
197
202
  VITE_ONAIROS_GOOGLE_IOS_CLIENT_ID=...
198
203
  VITE_ONAIROS_GOOGLE_ANDROID_CLIENT_ID=...
199
204
  ```