@onairosofficial/onairos-capacitor 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/CAPACITOR_QUICK_START.md +379 -0
  2. package/CONNECTORS.md +122 -0
  3. package/LICENSE +194 -10
  4. package/OnairosofficialOnairosCapacitor.podspec +13 -0
  5. package/Package.swift +26 -0
  6. package/README.md +176 -25
  7. package/dist/onairos.capacitor.esm.js +1 -0
  8. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  9. package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
  10. package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
  11. package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
  12. package/docs/CROSS_SDK_PARITY.md +239 -0
  13. package/docs/DATA_FREQUENCY.md +57 -0
  14. package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
  15. package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
  16. package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
  17. package/docs/PLATFORM_APIS.md +559 -0
  18. package/docs/RAW_MEMORIES_API.md +305 -0
  19. package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
  20. package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
  21. package/docs/oldFixes.md +216 -0
  22. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
  23. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
  24. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
  25. package/onairos.d.ts +656 -0
  26. package/package.json +188 -37
  27. package/src/OnairosReconnectButton.jsx +272 -0
  28. package/src/RSA.jsx +57 -0
  29. package/src/assets/NewLogo.png +0 -0
  30. package/src/assets/OnairosNewLogo.png +0 -0
  31. package/src/assets/chatgpt-icon.png +0 -0
  32. package/src/assets/fire-horse.png +0 -0
  33. package/src/assets/fire-horse.transparent.png +0 -0
  34. package/src/assets/latest-firehorse.png +0 -0
  35. package/src/assets/perplexity.png +0 -0
  36. package/src/assets/persona.png +0 -0
  37. package/src/assets/persona1.png +0 -0
  38. package/src/assets/persona2.png +0 -0
  39. package/src/assets/persona3.png +0 -0
  40. package/src/assets/persona4.png +0 -0
  41. package/src/assets/persona5.png +0 -0
  42. package/src/capacitorConnectorCatalog.js +38 -0
  43. package/src/capacitorOAuthConfig.js +52 -0
  44. package/src/chatgptHostedImport/index.js +303 -0
  45. package/src/components/AuthButtons.jsx +48 -0
  46. package/src/components/ConnectChatGPTModal.jsx +666 -0
  47. package/src/components/ConnectClaudeModal.jsx +610 -0
  48. package/src/components/ConnectGeminiModal.jsx +639 -0
  49. package/src/components/ConnectGrokModal.jsx +701 -0
  50. package/src/components/ConnectPerplexityModal.jsx +726 -0
  51. package/src/components/DataExplainerScreen.jsx +349 -0
  52. package/src/components/DataRequest.js +885 -0
  53. package/src/components/DataRequest.jsx +1055 -0
  54. package/src/components/EmailAuth.js +1871 -0
  55. package/src/components/EmailAuth.jsx +2062 -0
  56. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  57. package/src/components/GoogleButton.js +133 -0
  58. package/src/components/LLMConnectorManager.jsx +201 -0
  59. package/src/components/LoadingPage.jsx +19 -0
  60. package/src/components/LoadingScreen.jsx +81 -0
  61. package/src/components/LunarBirthdate.jsx +96 -0
  62. package/src/components/LunarLoadingPage.jsx +251 -0
  63. package/src/components/Notification.jsx +21 -0
  64. package/src/components/OnairosAppButton.jsx +85 -0
  65. package/src/components/OnairosSSO.jsx +645 -0
  66. package/src/components/OnairosTrigger.jsx +61 -0
  67. package/src/components/PerplexityLogo.jsx +43 -0
  68. package/src/components/PinSetup.js +200 -0
  69. package/src/components/PinSetup.jsx +228 -0
  70. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  71. package/src/components/SdkErrorBoundary.jsx +36 -0
  72. package/src/components/SecuritySetup.js +81 -0
  73. package/src/components/SessionUserBar.jsx +83 -0
  74. package/src/components/SignUp.js +123 -0
  75. package/src/components/TestTelegramButton.js +53 -0
  76. package/src/components/TrainingComponent.jsx +200 -0
  77. package/src/components/TrainingScreen.jsx +897 -0
  78. package/src/components/UniversalOnboarding.js +306 -0
  79. package/src/components/UniversalOnboarding.jsx +4837 -0
  80. package/src/components/ValentineLoadingPage.jsx +502 -0
  81. package/src/components/ValentineModeSelector.jsx +162 -0
  82. package/src/components/WelcomeScreen.jsx +435 -0
  83. package/src/components/WrappedLoadingPage.jsx +205 -0
  84. package/src/components/connectors/ChatGPTConnector.js +348 -0
  85. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  86. package/src/components/connectors/ClaudeConnector.js +44 -0
  87. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  88. package/src/components/connectors/GeminiConnector.js +170 -0
  89. package/src/components/connectors/GeminiConnector.jsx +170 -0
  90. package/src/components/connectors/GmailConnector.js +148 -0
  91. package/src/components/connectors/GmailConnector.jsx +148 -0
  92. package/src/components/connectors/GrokConnector.js +16 -0
  93. package/src/components/connectors/GrokConnector.jsx +16 -0
  94. package/src/components/connectors/HingeConnector.js +419 -0
  95. package/src/components/connectors/HingeConnector.jsx +419 -0
  96. package/src/components/connectors/InstagramDataConnector.js +726 -0
  97. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  98. package/src/components/connectors/LinkedInConnector.js +4 -0
  99. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  100. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  101. package/src/components/connectors/PinterestConnector.js +208 -0
  102. package/src/components/connectors/PinterestConnector.jsx +208 -0
  103. package/src/components/connectors/README.md +292 -0
  104. package/src/components/connectors/RedditConnector.js +229 -0
  105. package/src/components/connectors/RedditConnector.jsx +229 -0
  106. package/src/components/connectors/SephoraConnector.js +482 -0
  107. package/src/components/connectors/SephoraConnector.jsx +482 -0
  108. package/src/components/connectors/TikTokConnector.jsx +430 -0
  109. package/src/components/connectors/YoutubeConnector.js +361 -0
  110. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  111. package/src/components/connectors/index.js +50 -0
  112. package/src/components/icons.jsx +46 -0
  113. package/src/components/icons.tsx +21 -0
  114. package/src/components/ui/PageLayout.jsx +1255 -0
  115. package/src/components/ui/PrimaryButton.jsx +162 -0
  116. package/src/components/ui/button.jsx +49 -0
  117. package/src/components/ui/card.jsx +61 -0
  118. package/src/components/ui/checkbox.jsx +33 -0
  119. package/src/components/ui/label.jsx +29 -0
  120. package/src/components/utils/UpdateConnections.js +45 -0
  121. package/src/components/utils/oauthHelper.js +97 -0
  122. package/src/config/api-config.js +138 -0
  123. package/src/deepLink.jsx +38 -0
  124. package/src/getPin.js +26 -0
  125. package/src/icons/Avatar.png +0 -0
  126. package/src/icons/Sentiment.png +0 -0
  127. package/src/icons/Trait.png +0 -0
  128. package/src/iframe/DataRequestPage.jsx +285 -0
  129. package/src/iframe/OnairosButtonIntegration.md +148 -0
  130. package/src/iframe/components/Box.jsx +56 -0
  131. package/src/iframe/components/IndividualConnection.jsx +88 -0
  132. package/src/iframe/dataRequestHandler.js +714 -0
  133. package/src/iframe/data_request_iframe.html +27 -0
  134. package/src/iframe/data_request_page.js +47 -0
  135. package/src/iframe/icons/Avatar.png +1 -0
  136. package/src/iframe/icons/Avatar2.png +1 -0
  137. package/src/iframe/icons/Sentiment.png +1 -0
  138. package/src/iframe/icons/Trait.png +1 -0
  139. package/src/iframe/icons/onairos_logo.png +0 -0
  140. package/src/iframe/utils/api.js +57 -0
  141. package/src/index.js +274 -0
  142. package/src/laravel/OnairosVue.vue +410 -0
  143. package/src/laravel/blade-helpers.js +320 -0
  144. package/src/laravel/vite-plugin.js +179 -0
  145. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  146. package/src/mobile/components/MobileBox.jsx +71 -0
  147. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  148. package/src/mobile/shims/browser-apis.js +78 -0
  149. package/src/mobile/shims/lucide-shim.js +85 -0
  150. package/src/nativeConnectors.js +5 -0
  151. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  152. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  153. package/src/newUI/PrimaryButton.tsx +213 -0
  154. package/src/newUI/SignInStep.tsx +194 -0
  155. package/src/newUI/VerificationStep.tsx +133 -0
  156. package/src/newUI/WelcomeScreen.tsx +311 -0
  157. package/src/newUI/services/connectedAccountsService.js +129 -0
  158. package/src/onairos.capacitor.jsx +15 -0
  159. package/src/onairos.core.jsx +133 -0
  160. package/src/onairos.jsx +14 -0
  161. package/src/onairos.native.jsx +15 -0
  162. package/src/onairosButton.jsx +9000 -0
  163. package/src/overlay/CheckBox.jsx +114 -0
  164. package/src/overlay/IndividualConnection copy.js +86 -0
  165. package/src/overlay/IndividualConnection.js +191 -0
  166. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  167. package/src/overlay/box.js +84 -0
  168. package/src/overlay/overlay.js +437 -0
  169. package/src/styles/onairos-scoped-preflight.css +97 -0
  170. package/src/styles/sdkCssRegistry.js +20 -0
  171. package/src/styles/styleLoaderInsertShadow.js +69 -0
  172. package/src/styles/tailwind.capacitor.css +395 -0
  173. package/src/styles/tailwind.css +395 -0
  174. package/src/theme/colors.js +40 -0
  175. package/src/utils/apiKeyValidation.js +341 -0
  176. package/src/utils/apiResponseLogger.js +316 -0
  177. package/src/utils/authHeaders.js +275 -0
  178. package/src/utils/biometrics.js +26 -0
  179. package/src/utils/bookmarkletUtils.js +28 -0
  180. package/src/utils/capacitorDetection.js +278 -0
  181. package/src/utils/capacitorLLMHelper.js +352 -0
  182. package/src/utils/capacitorPlugins.js +366 -0
  183. package/src/utils/crossDomainSSO.js +587 -0
  184. package/src/utils/deepLinking.js +27 -0
  185. package/src/utils/devLogger.js +46 -0
  186. package/src/utils/extensionDetection.js +418 -0
  187. package/src/utils/extractMemory.js +277 -0
  188. package/src/utils/framerBrandingOverrides.js +40 -0
  189. package/src/utils/googleWebClientId.js +55 -0
  190. package/src/utils/overlayHandler.js +224 -0
  191. package/src/utils/platformDisconnect.js +309 -0
  192. package/src/utils/pollTrainingStatus.js +200 -0
  193. package/src/utils/rawMemoriesAccess.js +211 -0
  194. package/src/utils/resolveBackendAppId.js +47 -0
  195. package/src/utils/responseFormatter.js +140 -0
  196. package/src/utils/sdkDebugStorage.js +113 -0
  197. package/src/utils/sdkInitialization.js +645 -0
  198. package/src/utils/sessionManager.js +1258 -0
  199. package/src/utils/startBackgroundTraining.js +100 -0
  200. package/src/utils/userDataFormatter.js +222 -0
  201. package/index.d.ts +0 -1
  202. package/index.js +0 -1
package/package.json CHANGED
@@ -1,56 +1,207 @@
1
1
  {
2
2
  "name": "@onairosofficial/onairos-capacitor",
3
- "version": "0.1.0",
4
- "description": "Dedicated Capacitor package entry point for the Onairos SDK.",
5
- "license": "Apache-2.0",
6
- "author": "Zion Darko",
7
- "type": "module",
8
- "main": "./index.js",
9
- "types": "./index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./index.d.ts",
13
- "import": "./index.js",
14
- "default": "./index.js"
3
+ "version": "0.1.2",
4
+ "engines": {
5
+ "node": ">=20 <26"
6
+ },
7
+ "dependencies": {
8
+ "@capacitor/app": "^8.0.0",
9
+ "@capacitor/browser": "^8.0.0",
10
+ "@capacitor/core": "^8.0.0",
11
+ "@capgo/capacitor-social-login": "^8.3.9",
12
+ "@react-oauth/google": "^0.12.2",
13
+ "@telegram-apps/sdk-react": "^2.0.25",
14
+ "axios": "^1.15.1",
15
+ "buffer": "^6.0.3",
16
+ "caniuse-lite": "^1.0.30001718",
17
+ "lottie-react": "^2.4.1",
18
+ "process": "^0.11.10",
19
+ "simple-icons": "^15.16.1",
20
+ "socket.io-client": "^4.8.1",
21
+ "stream-browserify": "^3.0.0",
22
+ "tty-browserify": "^0.0.1",
23
+ "web-vitals": "^2.1.4"
24
+ },
25
+ "overrides": {
26
+ "react-scripts": {
27
+ "babel-loader": "9.1.3",
28
+ "@babel/plugin-proposal-class-properties": "7.18.6"
15
29
  },
16
- "./package.json": "./package.json"
30
+ "socket.io-parser": "4.2.6"
17
31
  },
18
- "files": [
19
- "index.js",
20
- "index.d.ts",
21
- "README.md",
22
- "LICENSE"
32
+ "sideEffects": [
33
+ "*.css"
23
34
  ],
24
35
  "scripts": {
25
- "test": "node --test",
26
- "pack:check": "npm pack --dry-run"
36
+ "build": "node scripts/build-capacitor.cjs",
37
+ "build:fast": "npm run build",
38
+ "build:protected": "PROTECT_BUILD=1 node scripts/build-capacitor.cjs",
39
+ "clean": "node scripts/clean-dist.cjs",
40
+ "dev": "webpack --mode development --watch --config webpack.capacitor.config.cjs",
41
+ "prepack": "npm run build && node scripts/verify-capacitor-package.cjs",
42
+ "test:package": "node scripts/verify-capacitor-package.cjs"
43
+ },
44
+ "eslintConfig": {
45
+ "extends": [
46
+ "react-app",
47
+ "react-app/jest"
48
+ ]
49
+ },
50
+ "browserslist": {
51
+ "production": [
52
+ ">0.2%",
53
+ "not dead",
54
+ "not op_mini all"
55
+ ],
56
+ "development": [
57
+ "last 1 chrome version",
58
+ "last 1 firefox version",
59
+ "last 1 safari version"
60
+ ]
61
+ },
62
+ "devDependencies": {
63
+ "@babel/cli": "^7.23.0",
64
+ "@babel/core": "^7.28.5",
65
+ "@babel/plugin-bugfix-firefox-class-in-computed-class-key": "^7.28.5",
66
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
67
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
68
+ "@babel/plugin-transform-modules-commonjs": "^7.23.3",
69
+ "@babel/plugin-transform-runtime": "^7.23.7",
70
+ "@babel/preset-env": "^7.28.5",
71
+ "@babel/preset-react": "^7.27.1",
72
+ "@playwright/test": "^1.59.1",
73
+ "@radix-ui/react-checkbox": "^1.3.1",
74
+ "@radix-ui/react-label": "^2.1.6",
75
+ "@rollup/plugin-babel": "^6.0.4",
76
+ "@rollup/plugin-commonjs": "^28.0.2",
77
+ "@rollup/plugin-inject": "^5.0.5",
78
+ "@rollup/plugin-json": "^6.1.0",
79
+ "@rollup/plugin-node-resolve": "^16.0.0",
80
+ "@rollup/plugin-typescript": "^12.1.2",
81
+ "@tailwindcss/postcss": ">=3.0.0",
82
+ "@testing-library/jest-dom": "^5.17.0",
83
+ "@testing-library/react": "^13.4.0",
84
+ "@testing-library/user-event": "^13.5.0",
85
+ "@vitejs/plugin-vue": "^5.0.4",
86
+ "@vue/test-utils": "^2.4.4",
87
+ "ajv": "^8.17.1",
88
+ "assert": "^2.1.0",
89
+ "babel-loader": "^9.2.1",
90
+ "browserify-zlib": "^0.2.0",
91
+ "copy-webpack-plugin": "^11.0.0",
92
+ "crypto-browserify": "^3.12.1",
93
+ "css-loader": "^7.1.2",
94
+ "file-loader": "^6.2.0",
95
+ "html-webpack-plugin": "^5.6.3",
96
+ "https-browserify": "^1.0.0",
97
+ "javascript-obfuscator": "^5.1.0",
98
+ "jsdom": "^24.0.0",
99
+ "lucide-react": "^0.503.0",
100
+ "mini-css-extract-plugin": "^2.9.2",
101
+ "os-browserify": "^0.3.0",
102
+ "path-browserify": "^1.0.1",
103
+ "pngjs": "^7.0.0",
104
+ "postcss": "^8.4.47",
105
+ "postcss-loader": "^8.1.1",
106
+ "react": "^18.2.0",
107
+ "react-dom": "^18.2.0",
108
+ "react-scripts": "^5.0.1",
109
+ "rollup": "^2.79.2",
110
+ "rollup-plugin-terser": "^7.0.2",
111
+ "rollup-plugin-use-client": "^1.4.0",
112
+ "stream-http": "^3.2.0",
113
+ "style-loader": "^4.0.0",
114
+ "tailwindcss": ">=3.0.0",
115
+ "terser-webpack-plugin": "^5.3.10",
116
+ "url": "^0.11.4",
117
+ "vitest": "^1.2.0",
118
+ "vm-browserify": "^1.1.2",
119
+ "vue": "^3.4.15",
120
+ "webpack": "^5.89.0",
121
+ "webpack-bundle-analyzer": "^4.10.1",
122
+ "webpack-cli": "^5.1.4",
123
+ "webpack-obfuscator": "^3.6.0"
27
124
  },
28
125
  "peerDependencies": {
29
- "@capacitor/core": "^8.0.0",
30
- "onairos": "^8.4.8"
126
+ "react": "^18.2.0 || ^19.0.0",
127
+ "react-dom": "^18.2.0 || ^19.0.0",
128
+ "tailwindcss": ">=3.0.0"
31
129
  },
32
- "engines": {
33
- "node": ">=20 <25"
130
+ "peerDependenciesMeta": {
131
+ "tailwindcss": {
132
+ "optional": true
133
+ }
134
+ },
135
+ "description": "Capacitor-first Onairos SDK package with scoped styles, native-friendly connector flows, and the full Onairos connector catalog.",
136
+ "main": "dist/onairos.capacitor.esm.turbopack.js",
137
+ "module": "dist/onairos.capacitor.esm.turbopack.js",
138
+ "types": "onairos.d.ts",
139
+ "browser": "dist/onairos.capacitor.esm.turbopack.js",
140
+ "exports": {
141
+ "./package.json": "./package.json",
142
+ ".": {
143
+ "types": "./onairos.d.ts",
144
+ "module": "./dist/onairos.capacitor.esm.turbopack.js",
145
+ "import": "./dist/onairos.capacitor.esm.turbopack.js",
146
+ "browser": {
147
+ "import": "./dist/onairos.capacitor.esm.turbopack.js"
148
+ },
149
+ "default": "./dist/onairos.capacitor.esm.turbopack.js"
150
+ },
151
+ "./capacitor": {
152
+ "types": "./onairos.d.ts",
153
+ "module": "./dist/onairos.capacitor.esm.turbopack.js",
154
+ "import": "./dist/onairos.capacitor.esm.turbopack.js",
155
+ "browser": {
156
+ "import": "./dist/onairos.capacitor.esm.turbopack.js"
157
+ },
158
+ "default": "./dist/onairos.capacitor.esm.turbopack.js"
159
+ },
160
+ "./connectors": {
161
+ "types": "./onairos.d.ts",
162
+ "module": "./dist/onairos.capacitor.esm.turbopack.js",
163
+ "import": "./dist/onairos.capacitor.esm.turbopack.js",
164
+ "default": "./dist/onairos.capacitor.esm.turbopack.js"
165
+ }
34
166
  },
35
167
  "repository": {
36
168
  "type": "git",
37
169
  "url": "git+https://github.com/zd819/onairos-capacitor.git"
38
170
  },
171
+ "keywords": [
172
+ "Onairos",
173
+ "Identity",
174
+ "Authentication",
175
+ "Data-Sharing",
176
+ "Privacy",
177
+ "Vite",
178
+ "React",
179
+ "Capacitor",
180
+ "iOS",
181
+ "Android"
182
+ ],
183
+ "author": "Zion Darko",
184
+ "license": "Apache-2.0",
185
+ "capacitor": {
186
+ "ios": {
187
+ "src": "ios"
188
+ }
189
+ },
39
190
  "bugs": {
40
191
  "url": "https://github.com/zd819/onairos-capacitor/issues"
41
192
  },
42
- "homepage": "https://docs.onairos.io/",
43
- "keywords": [
44
- "onairos",
45
- "capacitor",
193
+ "homepage": "https://onairos.uk",
194
+ "files": [
195
+ "dist",
196
+ "src",
46
197
  "ios",
47
- "android",
48
- "identity",
49
- "authentication",
50
- "personalization"
51
- ],
52
- "publishConfig": {
53
- "access": "public",
54
- "provenance": true
55
- }
198
+ "Package.swift",
199
+ "OnairosofficialOnairosCapacitor.podspec",
200
+ "onairos.d.ts",
201
+ "package.json",
202
+ "README.md",
203
+ "docs",
204
+ "CONNECTORS.md",
205
+ "CAPACITOR_QUICK_START.md"
206
+ ]
56
207
  }
@@ -0,0 +1,272 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import UniversalOnboarding from './components/UniversalOnboarding.jsx';
3
+ import { ModalPageLayout } from './components/ui/PageLayout.jsx';
4
+ import { isMobileApp, isMobileBrowser } from './utils/capacitorDetection.js';
5
+
6
+ /**
7
+ * OnairosReconnectButton - A button that allows users to reconnect or change their data sources
8
+ *
9
+ * This button checks if user Onairos data is stored and opens the data connection page
10
+ * to allow users to modify their connected accounts/data sources.
11
+ *
12
+ * @param {Object} props - Component props
13
+ * @param {string} props.buttonText - Text to display on the button (default: "Reconnect Data Sources")
14
+ * @param {string} props.buttonClass - Custom CSS classes for the button
15
+ * @param {Object} props.buttonStyle - Custom inline styles for the button
16
+ * @param {string} props.appIcon - Icon URL for the app (optional)
17
+ * @param {string} props.appName - Name of the app (optional)
18
+ * @param {Function} props.onComplete - Callback when connection changes are complete
19
+ * @param {Function} props.onNoUserData - Callback when no user data is found
20
+ * @param {string} props.priorityPlatform - Platform to prioritize (e.g., 'gmail', 'pinterest', 'linkedin')
21
+ * @param {boolean} props.rawMemoriesOnly - Show only LLM connections (ChatGPT, Claude, Gemini, Grok) when true
22
+ * @param {Object} props.rawMemoriesConfig - Configuration for RAW memories collection
23
+ * @param {Array} props.allowedPlatforms - Array of platform names to show (e.g., ['ChatGPT', 'YouTube']). Null = show all.
24
+ */
25
+ export function OnairosReconnectButton({
26
+ buttonText = "Reconnect Data Sources",
27
+ buttonClass = "",
28
+ buttonStyle = {},
29
+ appIcon = null,
30
+ appName = "Your App",
31
+ onComplete = null,
32
+ onNoUserData = null,
33
+ priorityPlatform = null,
34
+ rawMemoriesOnly = false,
35
+ rawMemoriesConfig = null,
36
+ allowedPlatforms = null
37
+ }) {
38
+ const [showOverlay, setShowOverlay] = useState(false);
39
+ const [userData, setUserData] = useState(null);
40
+ const [isMobileDevice, setIsMobileDevice] = useState(false);
41
+
42
+ // Detect mobile for conditional styling
43
+ useEffect(() => {
44
+ const computeMobile = () => {
45
+ try {
46
+ const hasWindow = typeof window !== 'undefined';
47
+ if (!hasWindow) {
48
+ setIsMobileDevice(false);
49
+ return;
50
+ }
51
+
52
+ let width = window.innerWidth || document.documentElement?.clientWidth || document.body?.clientWidth || 0;
53
+
54
+ try {
55
+ if (window.parent && window.parent !== window && window.parent.innerWidth) {
56
+ width = Math.max(width, window.parent.innerWidth);
57
+ }
58
+ } catch (_) {
59
+ // Cross-origin access can fail; ignore
60
+ }
61
+
62
+ const isCapNative = !!window.Capacitor?.isNativePlatform?.();
63
+ const detectedMobile = isCapNative || width < 1024;
64
+
65
+ setIsMobileDevice(detectedMobile);
66
+ } catch (e) {
67
+ setIsMobileDevice(false);
68
+ }
69
+ };
70
+
71
+ computeMobile();
72
+
73
+ if (typeof window !== 'undefined') {
74
+ window.addEventListener('resize', computeMobile);
75
+ return () => window.removeEventListener('resize', computeMobile);
76
+ }
77
+ }, []);
78
+
79
+ // Lock background scroll on DESKTOP while modal is open
80
+ useEffect(() => {
81
+ if (typeof document === 'undefined') return;
82
+
83
+ const body = document.body;
84
+ if (!body) return;
85
+
86
+ if (showOverlay && !isMobileDevice) {
87
+ if (!body.dataset.onairosPrevOverflow) {
88
+ body.dataset.onairosPrevOverflow = body.style.overflow || '';
89
+ }
90
+ body.style.overflow = 'hidden';
91
+ } else {
92
+ if (body.dataset.onairosPrevOverflow !== undefined) {
93
+ body.style.overflow = body.dataset.onairosPrevOverflow;
94
+ delete body.dataset.onairosPrevOverflow;
95
+ }
96
+ }
97
+ }, [showOverlay, isMobileDevice]);
98
+
99
+ const handleButtonClick = () => {
100
+ // Check if user data exists in localStorage
101
+ try {
102
+ const savedUser = localStorage.getItem('onairosUser');
103
+
104
+ if (!savedUser) {
105
+ console.warn('⚠️ No Onairos user data found. User needs to sign in first.');
106
+ if (onNoUserData) {
107
+ onNoUserData();
108
+ } else {
109
+ alert('No Onairos account found. Please sign in first using the main Onairos button.');
110
+ }
111
+ return;
112
+ }
113
+
114
+ const user = JSON.parse(savedUser);
115
+
116
+ // Validate that we have essential user data
117
+ if (!user.email && !user.username) {
118
+ console.warn('⚠️ Invalid user data - missing email/username');
119
+ if (onNoUserData) {
120
+ onNoUserData();
121
+ } else {
122
+ alert('Invalid session data. Please sign in again.');
123
+ }
124
+ return;
125
+ }
126
+
127
+ console.log('✅ User data found, opening reconnect modal:', {
128
+ email: user.email,
129
+ connectedAccounts: user.connectedAccounts?.length || 0
130
+ });
131
+
132
+ setUserData(user);
133
+ setShowOverlay(true);
134
+ } catch (error) {
135
+ console.error('❌ Error checking user data:', error);
136
+ if (onNoUserData) {
137
+ onNoUserData();
138
+ } else {
139
+ alert('Error accessing user data. Please try again.');
140
+ }
141
+ }
142
+ };
143
+
144
+ const handleCloseOverlay = () => {
145
+ setShowOverlay(false);
146
+
147
+ // Refresh userData from localStorage in case it was updated
148
+ try {
149
+ const savedUser = localStorage.getItem('onairosUser');
150
+ if (savedUser) {
151
+ const user = JSON.parse(savedUser);
152
+ setUserData(user);
153
+ }
154
+ } catch (error) {
155
+ console.error('❌ Error refreshing user data:', error);
156
+ }
157
+ };
158
+
159
+ const handleOnboardingComplete = (onboardingData) => {
160
+ console.log('🎯 Reconnection completed:', onboardingData);
161
+ console.log('🔍 Updated connected accounts:', onboardingData.connectedAccounts);
162
+
163
+ // Update user data with new connections
164
+ const updatedUserData = {
165
+ ...userData,
166
+ connectedAccounts: onboardingData.connectedAccounts || []
167
+ };
168
+
169
+ console.log('💾 Saving updated userData with connectedAccounts:', updatedUserData.connectedAccounts);
170
+ setUserData(updatedUserData);
171
+ localStorage.setItem('onairosUser', JSON.stringify(updatedUserData));
172
+
173
+ // Close the overlay
174
+ setShowOverlay(false);
175
+
176
+ // Call onComplete callback if provided
177
+ if (onComplete) {
178
+ onComplete({
179
+ connectedAccounts: updatedUserData.connectedAccounts,
180
+ userData: updatedUserData,
181
+ timestamp: new Date().toISOString()
182
+ });
183
+ }
184
+ };
185
+
186
+ // Default button styling
187
+ const defaultButtonClass = "flex items-center justify-center font-bold rounded cursor-pointer px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white transition-colors";
188
+ const finalButtonClass = buttonClass || defaultButtonClass;
189
+
190
+ return (
191
+ <>
192
+ <button
193
+ className={finalButtonClass}
194
+ onClick={handleButtonClick}
195
+ style={buttonStyle}
196
+ >
197
+ {buttonText}
198
+ </button>
199
+
200
+ {/* Modal for reconnecting data sources */}
201
+ {showOverlay && userData && (
202
+ <>
203
+ {isMobileDevice ? (
204
+ // Mobile Layout
205
+ <ModalPageLayout
206
+ visible={showOverlay}
207
+ onClose={handleCloseOverlay}
208
+ showBackButton={false}
209
+ showCloseButton={true}
210
+ title=""
211
+ subtitle=""
212
+ icon={null}
213
+ centerContent={true}
214
+ contentClassName="!p-0"
215
+ modalClassName="onairos-modal onairos-modal-mobile"
216
+ >
217
+ <div className="onairos-modal-shell flex-1 min-h-0 flex flex-col">
218
+ <UniversalOnboarding
219
+ isMobile={true}
220
+ initialConnectedAccounts={userData?.connectedAccounts}
221
+ onComplete={handleOnboardingComplete}
222
+ onBack={handleCloseOverlay}
223
+ appIcon={appIcon || "https://onairos.sirv.com/Images/OnairosBlack.png"}
224
+ appName={appName}
225
+ username={userData?.email || userData?.username}
226
+ priorityPlatform={priorityPlatform}
227
+ rawMemoriesOnly={rawMemoriesOnly}
228
+ rawMemoriesConfig={rawMemoriesConfig}
229
+ allowedPlatforms={allowedPlatforms}
230
+ />
231
+ </div>
232
+ </ModalPageLayout>
233
+ ) : (
234
+ // Desktop Layout
235
+ <ModalPageLayout
236
+ visible={showOverlay}
237
+ onClose={handleCloseOverlay}
238
+ showBackButton={false}
239
+ showCloseButton={true}
240
+ modalStyle={{ height: '90vh', maxHeight: '90vh' }}
241
+ title=""
242
+ subtitle=""
243
+ icon={null}
244
+ centerContent={true}
245
+ contentClassName="!p-0"
246
+ modalClassName="onairos-modal"
247
+ >
248
+ <div className="onairos-modal-shell flex-1 min-h-0 flex flex-col">
249
+ <UniversalOnboarding
250
+ isMobile={false}
251
+ initialConnectedAccounts={userData?.connectedAccounts}
252
+ onComplete={handleOnboardingComplete}
253
+ onBack={handleCloseOverlay}
254
+ appIcon={appIcon || "https://onairos.sirv.com/Images/OnairosBlack.png"}
255
+ appName={appName}
256
+ username={userData?.email || userData?.username}
257
+ priorityPlatform={priorityPlatform}
258
+ rawMemoriesOnly={rawMemoriesOnly}
259
+ rawMemoriesConfig={rawMemoriesConfig}
260
+ allowedPlatforms={allowedPlatforms}
261
+ />
262
+ </div>
263
+ </ModalPageLayout>
264
+ )}
265
+ </>
266
+ )}
267
+ </>
268
+ );
269
+ }
270
+
271
+ export default OnairosReconnectButton;
272
+
package/src/RSA.jsx ADDED
@@ -0,0 +1,57 @@
1
+ // Function to convert PEM encoded public key to a format usable by the Web Crypto API
2
+ function pemToBuffer(pem) {
3
+ // Remove the first and last lines (headers), and all line breaks
4
+ const base64String = pem
5
+ .replace(/-----BEGIN PUBLIC KEY-----/, '')
6
+ .replace(/-----END PUBLIC KEY-----/, '')
7
+ .replace(/\s/g, ''); // remove all whitespace, not just line breaks
8
+ const binaryString = window.atob(base64String);
9
+ const bytes = new Uint8Array(binaryString.length);
10
+ for (let i = 0; i < binaryString.length; i++) {
11
+ bytes[i] = binaryString.charCodeAt(i);
12
+ }
13
+ return bytes.buffer;
14
+ }
15
+
16
+ // Function to encrypt data using RSA
17
+ export async function rsaEncrypt(publicKeyPem, data) {
18
+ try {
19
+ const publicKeyBuffer = pemToBuffer(publicKeyPem);
20
+ const importedKey = await window.crypto.subtle.importKey(
21
+ 'spki',
22
+ publicKeyBuffer,
23
+ {
24
+ name: 'RSA-OAEP',
25
+ hash: {name: 'SHA-256'}
26
+ },
27
+ true,
28
+ ['encrypt']
29
+ );
30
+ const encrypted = await window.crypto.subtle.encrypt(
31
+ { name: 'RSA-OAEP' },
32
+ importedKey,
33
+ new TextEncoder().encode(data)
34
+ );
35
+ return bufferToBase64(encrypted);
36
+ } catch (error) {
37
+ console.error("rsaEncrypt error:", error);
38
+ return null;
39
+ }
40
+ }
41
+
42
+ // Function to convert ArrayBuffer to Base64
43
+ function bufferToBase64(buffer) {
44
+ try{
45
+ let binary = '';
46
+ const bytes = new Uint8Array(buffer);
47
+ const len = bytes.byteLength;
48
+ for (let i = 0; i < len; i++) {
49
+ binary += String.fromCharCode(bytes[i]);
50
+ }
51
+ return window.btoa(binary);
52
+ }catch(e){
53
+ console.error("Eror in buffertoBase64 : ", e)
54
+ }
55
+ }
56
+
57
+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,38 @@
1
+ // TODO(onairos-capacitor): Re-enable these once the native/mobile connector UX
2
+ // is stable enough for consumer apps.
3
+ export const TEMP_DISABLED_CONNECTORS = new Set([
4
+ 'claude',
5
+ 'gemini',
6
+ 'grok',
7
+ 'perplexity',
8
+ 'sephora',
9
+ 'instagram-data',
10
+ 'gmail',
11
+ 'hinge',
12
+ 'netflix',
13
+ ]);
14
+
15
+ export const ALL_CAPACITOR_PLATFORMS = [
16
+ { name: 'ChatGPT', connector: 'chatgpt', endpoint: null, type: 'llm', url: 'https://chatgpt.com' },
17
+ { name: 'Claude', connector: 'claude', endpoint: null, type: 'llm', url: 'https://claude.ai' },
18
+ { name: 'Gemini', connector: 'gemini', endpoint: null, type: 'llm', url: 'https://gemini.google.com' },
19
+ { name: 'Grok', connector: 'grok', endpoint: null, type: 'llm', url: 'https://grok.com' },
20
+ { name: 'Perplexity', connector: 'perplexity', endpoint: null, type: 'llm', url: 'https://www.perplexity.ai' },
21
+ { name: 'YouTube', connector: 'youtube', endpoint: '/youtube/authorize', type: 'oauth' },
22
+ { name: 'LinkedIn', connector: 'linkedin', endpoint: '/linkedin/authorize', type: 'oauth' },
23
+ { name: 'Pinterest', connector: 'pinterest', endpoint: '/pinterest/authorize', type: 'oauth' },
24
+ { name: 'Reddit', connector: 'reddit', endpoint: '/reddit/authorize', type: 'oauth' },
25
+ { name: 'Gmail', connector: 'gmail', endpoint: '/gmail/authorize', type: 'oauth' },
26
+ { name: 'Hinge', connector: 'hinge', endpoint: '/platform-data/store', type: 'webview', url: 'https://hinge.co', platformId: 'mobile-hinge', dataType: 'dating' },
27
+ { name: 'Sephora', connector: 'sephora', endpoint: '/platform-data/store', type: 'webview', url: 'https://www.sephora.com', platformId: 'mobile-sephora', dataType: 'ecommerce' },
28
+ { name: 'InstagramData', connector: 'instagram-data', endpoint: '/platform-data/store', type: 'webview', url: 'https://www.instagram.com', platformId: 'mobile-instagram', dataType: 'social' },
29
+ { name: 'Spotify', connector: 'spotify', endpoint: '/platform-data/store', type: 'webview', url: 'https://open.spotify.com', platformId: 'mobile-spotify', dataType: 'streaming' },
30
+ { name: 'Netflix', connector: 'netflix', endpoint: '/platform-data/store', type: 'webview', url: 'https://www.netflix.com', platformId: 'mobile-netflix', dataType: 'entertainment' },
31
+ { name: 'TikTok', connector: 'tiktok', endpoint: '/tiktok/authorize', type: 'oauth', url: 'https://www.tiktok.com', platformId: 'mobile-tiktok', dataType: 'social_video' },
32
+ ];
33
+
34
+ export const SUPPORTED_PLATFORMS = ALL_CAPACITOR_PLATFORMS.filter(
35
+ (platform) => !TEMP_DISABLED_CONNECTORS.has(platform.connector)
36
+ );
37
+
38
+ export const CONNECTOR_IDS = SUPPORTED_PLATFORMS.map((platform) => platform.connector);