@onairosofficial/onairos-capacitor 0.1.0 → 0.1.1
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/LICENSE +194 -10
- package/README.md +182 -25
- package/dist/onairos.capacitor.esm.js +1 -0
- package/dist/onairos.capacitor.esm.turbopack.js +1 -0
- package/onairos.d.ts +656 -0
- package/package.json +186 -38
- 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/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 +16 -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,437 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import AuthButtons from '../components/AuthButtons.jsx';
|
|
3
|
+
import IndividualConnection from './IndividualConnection.js';
|
|
4
|
+
import SecuritySetup from '../components/SecuritySetup.js';
|
|
5
|
+
import UniversalOnboarding from '../components/UniversalOnboarding.jsx';
|
|
6
|
+
import SignUp from '../components/SignUp.js';
|
|
7
|
+
import { ModalPageLayout } from '../components/ui/PageLayout.jsx';
|
|
8
|
+
import PrimaryButton from '../components/ui/PrimaryButton.jsx';
|
|
9
|
+
import { getApiBaseUrl } from '../config/api-config.js';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export default function Overlay({
|
|
13
|
+
setOthentConnected,
|
|
14
|
+
dataRequester,
|
|
15
|
+
NoAccount,
|
|
16
|
+
NoModel,
|
|
17
|
+
activeModels,
|
|
18
|
+
avatar,
|
|
19
|
+
setAvatar,
|
|
20
|
+
traits,
|
|
21
|
+
setTraits,
|
|
22
|
+
requestData,
|
|
23
|
+
handleConnectionSelection,
|
|
24
|
+
changeGranted,
|
|
25
|
+
granted,
|
|
26
|
+
allowSubmit,
|
|
27
|
+
rejectDataRequest,
|
|
28
|
+
sendDataRequest,
|
|
29
|
+
isAuthenticated,
|
|
30
|
+
onClose,
|
|
31
|
+
onLoginSuccess,
|
|
32
|
+
setOthentUser,
|
|
33
|
+
setHashedOthentSub,
|
|
34
|
+
setEncryptedPin,
|
|
35
|
+
accountInfo
|
|
36
|
+
}) {
|
|
37
|
+
const [loginError, setLoginError] = useState(null);
|
|
38
|
+
const [loading, setLoading] = useState(false);
|
|
39
|
+
const overlayRef = useRef(null);
|
|
40
|
+
|
|
41
|
+
// Manages Checkboxes
|
|
42
|
+
// Maintain the `isChecked` state for all checkboxes in the parent
|
|
43
|
+
const [checkedStates, setCheckedStates] = useState({});
|
|
44
|
+
|
|
45
|
+
const handleCheckboxChange = (key, isChecked) => {
|
|
46
|
+
console.log(key, " is being changed check to:", isChecked)
|
|
47
|
+
setCheckedStates((prevState) => ({
|
|
48
|
+
...prevState,
|
|
49
|
+
[key]: isChecked,
|
|
50
|
+
}));
|
|
51
|
+
// Call the `changeGranted` function accordingly
|
|
52
|
+
changeGranted(isChecked ? 1 : -1);
|
|
53
|
+
|
|
54
|
+
// Call the `handleConnectionSelection` function
|
|
55
|
+
const product = requestData[key];
|
|
56
|
+
handleConnectionSelection(
|
|
57
|
+
dataRequester,
|
|
58
|
+
key,
|
|
59
|
+
product.index,
|
|
60
|
+
product.type,
|
|
61
|
+
product.reward,
|
|
62
|
+
isChecked
|
|
63
|
+
);
|
|
64
|
+
console.log(product, " Selection registered")
|
|
65
|
+
handleConnectionSelection(dataRequester, key, product.index, product.type, product.reward, true)
|
|
66
|
+
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const [currentView, setCurrentView] = useState(() => {
|
|
71
|
+
if (isAuthenticated) {
|
|
72
|
+
if (accountInfo && accountInfo.models?.length > 0) {
|
|
73
|
+
return 'datarequests';
|
|
74
|
+
}
|
|
75
|
+
return 'onboarding';
|
|
76
|
+
}
|
|
77
|
+
return 'login';
|
|
78
|
+
});
|
|
79
|
+
const [formData, setFormData] = useState({
|
|
80
|
+
username: '',
|
|
81
|
+
password: ''
|
|
82
|
+
});
|
|
83
|
+
const [loginCompleted, setLoginCompleted] = useState(false);
|
|
84
|
+
const API_URL = getApiBaseUrl();
|
|
85
|
+
|
|
86
|
+
// Set dynamic viewport height
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const setVH = () => {
|
|
89
|
+
const vh = window.innerHeight * 0.01;
|
|
90
|
+
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
|
91
|
+
};
|
|
92
|
+
setVH();
|
|
93
|
+
window.addEventListener('resize', setVH);
|
|
94
|
+
window.addEventListener('orientationchange', setVH);
|
|
95
|
+
return () => {
|
|
96
|
+
window.removeEventListener('resize', setVH);
|
|
97
|
+
window.removeEventListener('orientationchange', setVH);
|
|
98
|
+
};
|
|
99
|
+
}, []);
|
|
100
|
+
|
|
101
|
+
const handleClose = () => {
|
|
102
|
+
onClose();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Handle click outside
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const handleClickOutside = (event) => {
|
|
108
|
+
if (overlayRef.current && !overlayRef.current.contains(event.target)) {
|
|
109
|
+
handleClose?.();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
113
|
+
document.addEventListener('touchstart', handleClickOutside);
|
|
114
|
+
return () => {
|
|
115
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
116
|
+
document.removeEventListener('touchstart', handleClickOutside);
|
|
117
|
+
};
|
|
118
|
+
}, [handleClose]);
|
|
119
|
+
|
|
120
|
+
const handleInputChange = (e) => {
|
|
121
|
+
setFormData({
|
|
122
|
+
...formData,
|
|
123
|
+
[e.target.name]: e.target.value
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const handleOnairosLogin = async (e) => {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
try {
|
|
130
|
+
setLoginError(null);
|
|
131
|
+
const loginAttempt = {
|
|
132
|
+
details: {
|
|
133
|
+
username: formData.username,
|
|
134
|
+
password: formData.password,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const response = await fetch(`${API_URL}/login`, {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
headers: {
|
|
141
|
+
'Content-Type': 'application/json',
|
|
142
|
+
},
|
|
143
|
+
body: JSON.stringify(loginAttempt),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const data = await response.json();
|
|
147
|
+
|
|
148
|
+
if (data.authentication === 'Accepted') {
|
|
149
|
+
localStorage.setItem('onairosToken', data.token);
|
|
150
|
+
localStorage.setItem('username', formData.username);
|
|
151
|
+
await handleLoginSuccess(formData.username);
|
|
152
|
+
} else {
|
|
153
|
+
throw new Error('Invalid credentials');
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error('Login failed:', error);
|
|
157
|
+
setLoginError('Invalid username or password');
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const handleLoginSuccess = async (identifier, isEmail = false) => {
|
|
162
|
+
setLoading(true);
|
|
163
|
+
try {
|
|
164
|
+
const result = await onLoginSuccess(identifier, isEmail);
|
|
165
|
+
|
|
166
|
+
setLoginError(null);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error('Login process failed:', error);
|
|
169
|
+
setLoginError('Failed to complete login process');
|
|
170
|
+
} finally {
|
|
171
|
+
setLoading(false);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const handleOnboardingComplete = () => {
|
|
176
|
+
setCurrentView('security');
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const handleSecurityComplete = (securityDetails) => {
|
|
180
|
+
// Handle security setup completion
|
|
181
|
+
if (securityDetails.method === 'othent') {
|
|
182
|
+
setOthentUser(true);
|
|
183
|
+
} else if (securityDetails.method === 'pin') {
|
|
184
|
+
setEncryptedPin(securityDetails.value);
|
|
185
|
+
}
|
|
186
|
+
setCurrentView('datarequests');
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const DataRequestsSection = ({
|
|
190
|
+
dataRequester,
|
|
191
|
+
granted,
|
|
192
|
+
allowSubmit,
|
|
193
|
+
rejectDataRequest,
|
|
194
|
+
sendDataRequest,
|
|
195
|
+
activeModels,
|
|
196
|
+
requestData,
|
|
197
|
+
handleConnectionSelection,
|
|
198
|
+
changeGranted,
|
|
199
|
+
avatar,
|
|
200
|
+
traits
|
|
201
|
+
}) => {
|
|
202
|
+
return (
|
|
203
|
+
<div className="flex flex-col h-full">
|
|
204
|
+
<div className="px-6">
|
|
205
|
+
<h1 className="text-lg font-semibold text-gray-900 mb-6">
|
|
206
|
+
Data Requests from {dataRequester}
|
|
207
|
+
</h1>
|
|
208
|
+
|
|
209
|
+
<div className="flex items-center justify-between mb-6">
|
|
210
|
+
<button
|
|
211
|
+
className="bg-gray-500 hover:bg-gray-600 text-white font-bold py-2 px-8 rounded-full"
|
|
212
|
+
onClick={rejectDataRequest}
|
|
213
|
+
>
|
|
214
|
+
Reject All
|
|
215
|
+
</button>
|
|
216
|
+
<button
|
|
217
|
+
disabled={!allowSubmit || granted === 0}
|
|
218
|
+
className={`${
|
|
219
|
+
allowSubmit && granted > 0
|
|
220
|
+
? 'bg-blue-500 hover:bg-blue-600'
|
|
221
|
+
: 'bg-gray-300 cursor-not-allowed'
|
|
222
|
+
} text-white font-bold py-2 px-8 rounded-full`}
|
|
223
|
+
onClick={sendDataRequest}
|
|
224
|
+
>
|
|
225
|
+
Confirm ({granted})
|
|
226
|
+
</button>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<div className="flex-1 overflow-y-auto px-6">
|
|
231
|
+
{activeModels.length === 0 ? (
|
|
232
|
+
<div className="flex flex-col items-center justify-center py-8">
|
|
233
|
+
<img src="https://onairos.sirv.com/Images/OnairosWhite.png" alt="Onairos Logo" className="w-24 h-24 mb-4" />
|
|
234
|
+
<p className="text-center text-gray-800 font-medium">
|
|
235
|
+
Please connect <a href="https://onairos.uk/connections" className="text-blue-500 hover:underline">Onairos</a> Personality
|
|
236
|
+
to send {dataRequester} your data
|
|
237
|
+
</p>
|
|
238
|
+
</div>
|
|
239
|
+
) : (
|
|
240
|
+
<div className="space-y-4">
|
|
241
|
+
{Object.keys(requestData)
|
|
242
|
+
.sort((a, b) => {
|
|
243
|
+
const aIsActive = activeModels.includes(requestData[a].type);
|
|
244
|
+
const bIsActive = activeModels.includes(requestData[b].type);
|
|
245
|
+
if (requestData[a].type === "Avatar") return 1;
|
|
246
|
+
if (requestData[b].type === "Avatar") return -1;
|
|
247
|
+
if (requestData[b].type === "Traits") return 1;
|
|
248
|
+
if (requestData[a].type === "Traits") return -1;
|
|
249
|
+
if (aIsActive && !bIsActive) return -1;
|
|
250
|
+
if (bIsActive && !aIsActive) return 1;
|
|
251
|
+
return 0;
|
|
252
|
+
})
|
|
253
|
+
.map((key, index) => {
|
|
254
|
+
const product = requestData[key];
|
|
255
|
+
const active = product.type === 'Personality'
|
|
256
|
+
? activeModels.includes(product.type)
|
|
257
|
+
: product.type === 'Avatar'
|
|
258
|
+
? avatar
|
|
259
|
+
: product.type === 'Traits'
|
|
260
|
+
? traits
|
|
261
|
+
: false;
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<IndividualConnection
|
|
265
|
+
key={key}
|
|
266
|
+
active={active}
|
|
267
|
+
title={product.type}
|
|
268
|
+
id={product}
|
|
269
|
+
number={index}
|
|
270
|
+
descriptions={product.descriptions}
|
|
271
|
+
rewards={product.reward}
|
|
272
|
+
size={key}
|
|
273
|
+
isChecked={!!checkedStates[key]} // Pass the state from the parent
|
|
274
|
+
onCheckboxChange={(isChecked) => handleCheckboxChange(key, isChecked)} // Handle the change
|
|
275
|
+
/>
|
|
276
|
+
);
|
|
277
|
+
})}
|
|
278
|
+
</div>
|
|
279
|
+
)}
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const renderContent = () => {
|
|
286
|
+
switch (currentView) {
|
|
287
|
+
case 'signup':
|
|
288
|
+
return (
|
|
289
|
+
<SignUp
|
|
290
|
+
onSignUpSuccess={handleLoginSuccess}
|
|
291
|
+
setOthentUser={setOthentUser}
|
|
292
|
+
setHashedOthentSub={setHashedOthentSub}
|
|
293
|
+
setEncryptedPin={setEncryptedPin}
|
|
294
|
+
/>
|
|
295
|
+
);
|
|
296
|
+
case 'onboarding':
|
|
297
|
+
return <UniversalOnboarding onComplete={handleOnboardingComplete} username={accountInfo?.username || formData.username} />;
|
|
298
|
+
case 'security':
|
|
299
|
+
return <SecuritySetup onComplete={handleSecurityComplete} />;
|
|
300
|
+
case 'datarequests':
|
|
301
|
+
return (
|
|
302
|
+
<DataRequestsSection
|
|
303
|
+
dataRequester={dataRequester}
|
|
304
|
+
granted={granted}
|
|
305
|
+
allowSubmit={allowSubmit}
|
|
306
|
+
rejectDataRequest={rejectDataRequest}
|
|
307
|
+
sendDataRequest={sendDataRequest}
|
|
308
|
+
activeModels={activeModels}
|
|
309
|
+
requestData={requestData}
|
|
310
|
+
handleConnectionSelection={handleConnectionSelection}
|
|
311
|
+
changeGranted={changeGranted}
|
|
312
|
+
avatar={avatar}
|
|
313
|
+
traits={traits}
|
|
314
|
+
/>
|
|
315
|
+
);
|
|
316
|
+
default:
|
|
317
|
+
return (
|
|
318
|
+
<div className="flex flex-col items-center justify-start max-w-sm mx-auto space-y-6 pt-4">
|
|
319
|
+
{loginError && (
|
|
320
|
+
<div className="w-full bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg">
|
|
321
|
+
{loginError}
|
|
322
|
+
</div>
|
|
323
|
+
)}
|
|
324
|
+
|
|
325
|
+
<AuthButtons
|
|
326
|
+
onLoginSuccess={handleLoginSuccess}
|
|
327
|
+
setOthentUser={setOthentUser}
|
|
328
|
+
setHashedOthentSub={setHashedOthentSub}
|
|
329
|
+
setEncryptedPin={setEncryptedPin}
|
|
330
|
+
/>
|
|
331
|
+
|
|
332
|
+
<div className="w-full flex items-center justify-center space-x-4">
|
|
333
|
+
<hr className="flex-grow border-gray-300" />
|
|
334
|
+
<span className="text-gray-500">or</span>
|
|
335
|
+
<hr className="flex-grow border-gray-300" />
|
|
336
|
+
</div>
|
|
337
|
+
|
|
338
|
+
<form onSubmit={handleOnairosLogin} className="w-full space-y-4">
|
|
339
|
+
<input
|
|
340
|
+
type="text"
|
|
341
|
+
name="username"
|
|
342
|
+
value={formData.username}
|
|
343
|
+
onChange={handleInputChange}
|
|
344
|
+
placeholder="Username"
|
|
345
|
+
className="w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
346
|
+
required
|
|
347
|
+
/>
|
|
348
|
+
<input
|
|
349
|
+
type="password"
|
|
350
|
+
name="password"
|
|
351
|
+
value={formData.password}
|
|
352
|
+
onChange={handleInputChange}
|
|
353
|
+
placeholder="Password"
|
|
354
|
+
className="w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
355
|
+
required
|
|
356
|
+
/>
|
|
357
|
+
<button
|
|
358
|
+
type="submit"
|
|
359
|
+
className="w-full bg-blue-500 text-white font-semibold py-3 px-4 rounded-lg hover:bg-blue-600 transition-colors"
|
|
360
|
+
>
|
|
361
|
+
Sign In
|
|
362
|
+
</button>
|
|
363
|
+
</form>
|
|
364
|
+
|
|
365
|
+
<button
|
|
366
|
+
onClick={() => setCurrentView('signup')}
|
|
367
|
+
className="w-full text-center text-blue-500 hover:text-blue-600"
|
|
368
|
+
>
|
|
369
|
+
Don't have an account? Sign up
|
|
370
|
+
</button>
|
|
371
|
+
</div>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
if (isAuthenticated && accountInfo) {
|
|
378
|
+
if (accountInfo.models?.length > 0) {
|
|
379
|
+
setCurrentView('datarequests');
|
|
380
|
+
} else {
|
|
381
|
+
setCurrentView('onboarding');
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}, [isAuthenticated, accountInfo]);
|
|
385
|
+
|
|
386
|
+
useEffect(() => {
|
|
387
|
+
return () => {
|
|
388
|
+
setLoginCompleted(false);
|
|
389
|
+
};
|
|
390
|
+
}, []);
|
|
391
|
+
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
}, [isAuthenticated, accountInfo])
|
|
394
|
+
|
|
395
|
+
// if (loading) {
|
|
396
|
+
// return (
|
|
397
|
+
// <>
|
|
398
|
+
// <div className="fixed inset-0 bg-black bg-opacity-50" />
|
|
399
|
+
// <div
|
|
400
|
+
// ref={overlayRef}
|
|
401
|
+
// className="fixed bottom-0 left-0 right-0 w-full bg-white rounded-t-3xl shadow-2xl transform transition-transform duration-300 ease-out flex items-center justify-center"
|
|
402
|
+
// style={{ height: 'calc(var(--vh, 1vh) * 50)' }}
|
|
403
|
+
// >
|
|
404
|
+
// <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"></div>
|
|
405
|
+
// </div>
|
|
406
|
+
// </>
|
|
407
|
+
// );
|
|
408
|
+
// }
|
|
409
|
+
|
|
410
|
+
return (
|
|
411
|
+
<ModalPageLayout
|
|
412
|
+
visible={true}
|
|
413
|
+
onClose={handleClose}
|
|
414
|
+
showBackButton={currentView === 'signup' || currentView === 'onboarding'}
|
|
415
|
+
onBack={() => {
|
|
416
|
+
if (currentView === 'signup') setCurrentView('login');
|
|
417
|
+
if (currentView === 'onboarding') setCurrentView('login');
|
|
418
|
+
}}
|
|
419
|
+
title={
|
|
420
|
+
currentView === 'login' ? 'Welcome to Onairos' :
|
|
421
|
+
currentView === 'signup' ? 'Create Account' :
|
|
422
|
+
currentView === 'onboarding' ? 'Connect Your Data' :
|
|
423
|
+
currentView === 'datarequests' ? 'Data Request' : ''
|
|
424
|
+
}
|
|
425
|
+
subtitle={
|
|
426
|
+
currentView === 'login' ? 'OnairOS personalizes your digital experience on every app so you can just enjoy being you' :
|
|
427
|
+
currentView === 'signup' ? 'Create your Onairos account to get started' :
|
|
428
|
+
currentView === 'onboarding' ? 'Choose which accounts to connect for a personalized experience' :
|
|
429
|
+
currentView === 'datarequests' ? `Select the data you want to share with ${dataRequester}` : ''
|
|
430
|
+
}
|
|
431
|
+
icon="🧠"
|
|
432
|
+
centerContent={true}
|
|
433
|
+
>
|
|
434
|
+
{renderContent()}
|
|
435
|
+
</ModalPageLayout>
|
|
436
|
+
);
|
|
437
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Scoped “preflight-like” reset for the SDK UI ONLY.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists:
|
|
5
|
+
* - Tailwind preflight (base layer) is global and can change the host app styling.
|
|
6
|
+
* - Without any reset, the SDK UI can look wrong in iOS WebViews (forms/spacing/box-sizing).
|
|
7
|
+
*
|
|
8
|
+
* This file restores the minimal resets the SDK needs, but ONLY inside `.onairos-modal`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
.onairos-modal,
|
|
12
|
+
.onairos-modal * ,
|
|
13
|
+
.onairos-modal *::before,
|
|
14
|
+
.onairos-modal *::after {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
border-width: 0;
|
|
17
|
+
border-style: solid;
|
|
18
|
+
border-color: currentColor;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Remove default margins inside the SDK modal */
|
|
22
|
+
.onairos-modal h1,
|
|
23
|
+
.onairos-modal h2,
|
|
24
|
+
.onairos-modal h3,
|
|
25
|
+
.onairos-modal h4,
|
|
26
|
+
.onairos-modal h5,
|
|
27
|
+
.onairos-modal h6,
|
|
28
|
+
.onairos-modal p,
|
|
29
|
+
.onairos-modal figure,
|
|
30
|
+
.onairos-modal blockquote,
|
|
31
|
+
.onairos-modal dl,
|
|
32
|
+
.onairos-modal dd,
|
|
33
|
+
.onairos-modal ul,
|
|
34
|
+
.onairos-modal ol,
|
|
35
|
+
.onairos-modal pre {
|
|
36
|
+
margin: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.onairos-modal ul,
|
|
40
|
+
.onairos-modal ol {
|
|
41
|
+
padding: 0;
|
|
42
|
+
list-style: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Media elements behave more predictably */
|
|
46
|
+
.onairos-modal img,
|
|
47
|
+
.onairos-modal svg,
|
|
48
|
+
.onairos-modal video,
|
|
49
|
+
.onairos-modal canvas,
|
|
50
|
+
.onairos-modal audio,
|
|
51
|
+
.onairos-modal iframe,
|
|
52
|
+
.onairos-modal embed,
|
|
53
|
+
.onairos-modal object {
|
|
54
|
+
display: block;
|
|
55
|
+
vertical-align: middle;
|
|
56
|
+
max-width: 100%;
|
|
57
|
+
height: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Make typography inherit consistently inside the SDK */
|
|
61
|
+
.onairos-modal button,
|
|
62
|
+
.onairos-modal input,
|
|
63
|
+
.onairos-modal optgroup,
|
|
64
|
+
.onairos-modal select,
|
|
65
|
+
.onairos-modal textarea {
|
|
66
|
+
font: inherit;
|
|
67
|
+
color: inherit;
|
|
68
|
+
letter-spacing: inherit;
|
|
69
|
+
margin: 0;
|
|
70
|
+
padding: 0;
|
|
71
|
+
line-height: inherit;
|
|
72
|
+
background-color: transparent;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.onairos-modal button,
|
|
76
|
+
.onairos-modal [type='button'],
|
|
77
|
+
.onairos-modal [type='reset'],
|
|
78
|
+
.onairos-modal [type='submit'] {
|
|
79
|
+
-webkit-appearance: button;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.onairos-modal ::placeholder {
|
|
83
|
+
opacity: 0.6;
|
|
84
|
+
color: inherit;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.onairos-modal textarea {
|
|
88
|
+
resize: vertical;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Links/buttons default styling */
|
|
92
|
+
.onairos-modal a {
|
|
93
|
+
color: inherit;
|
|
94
|
+
text-decoration: inherit;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Shared registry so the Capacitor entrypoint can provide compiled CSS text
|
|
2
|
+
// and the modal renderer can inject it into a ShadowRoot.
|
|
3
|
+
//
|
|
4
|
+
// This is the most robust way to ensure:
|
|
5
|
+
// - SDK looks correct (Tailwind available)
|
|
6
|
+
// - Host app is NOT polluted (no document.head style injection)
|
|
7
|
+
|
|
8
|
+
let _cssText = '';
|
|
9
|
+
|
|
10
|
+
export function registerOnairosCssText(cssText) {
|
|
11
|
+
if (typeof cssText === 'string' && cssText.trim()) {
|
|
12
|
+
_cssText = cssText;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getOnairosCssText() {
|
|
17
|
+
return _cssText;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* style-loader insert hook for Capacitor builds.
|
|
3
|
+
*
|
|
4
|
+
* Goal: keep SDK Tailwind/utilities fully working, WITHOUT injecting any CSS into
|
|
5
|
+
* document.head (which can "pollute" the host app by affecting elements that
|
|
6
|
+
* share Tailwind utility classnames).
|
|
7
|
+
*
|
|
8
|
+
* Strategy:
|
|
9
|
+
* - Create (or reuse) a host div on document.body
|
|
10
|
+
* - Attach a ShadowRoot
|
|
11
|
+
* - Append style-loader <style> tags inside the ShadowRoot
|
|
12
|
+
* - Also ensure a mount point exists for React portals (`#onairos-modal-shadow-mount`)
|
|
13
|
+
*
|
|
14
|
+
* IMPORTANT:
|
|
15
|
+
* - This only affects the Capacitor ESM bundle (webpack config points here).
|
|
16
|
+
* - Modal UI must render into the ShadowRoot to receive these styles.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
function insertIntoOnairosShadowRoot(styleEl) {
|
|
20
|
+
try {
|
|
21
|
+
if (typeof document === 'undefined') return;
|
|
22
|
+
if (!document.body) return;
|
|
23
|
+
if (typeof HTMLElement === 'undefined' || !HTMLElement.prototype.attachShadow) return;
|
|
24
|
+
|
|
25
|
+
const hostId = 'onairos-modal-shadow-host';
|
|
26
|
+
let host = document.getElementById(hostId);
|
|
27
|
+
if (!host) {
|
|
28
|
+
host = document.createElement('div');
|
|
29
|
+
host.id = hostId;
|
|
30
|
+
// Keep the host inert; modal backdrop handles pointer events.
|
|
31
|
+
host.style.all = 'initial';
|
|
32
|
+
document.body.appendChild(host);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const shadow = host.shadowRoot || host.attachShadow({ mode: 'open' });
|
|
36
|
+
|
|
37
|
+
// Tag so ModalPageLayout can detect "styles are present in shadow" without needing a <link>.
|
|
38
|
+
try {
|
|
39
|
+
styleEl.setAttribute('data-onairos-style-in-shadow', 'true');
|
|
40
|
+
} catch {}
|
|
41
|
+
|
|
42
|
+
// Group styles (optional) to keep DOM tidy.
|
|
43
|
+
let styleBucket = shadow.querySelector('#onairos-shadow-style-bucket');
|
|
44
|
+
if (!styleBucket) {
|
|
45
|
+
styleBucket = document.createElement('div');
|
|
46
|
+
styleBucket.id = 'onairos-shadow-style-bucket';
|
|
47
|
+
shadow.appendChild(styleBucket);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
styleBucket.appendChild(styleEl);
|
|
51
|
+
|
|
52
|
+
// Ensure mount exists for React portal.
|
|
53
|
+
let mount = shadow.querySelector('#onairos-modal-shadow-mount');
|
|
54
|
+
if (!mount) {
|
|
55
|
+
mount = document.createElement('div');
|
|
56
|
+
mount.id = 'onairos-modal-shadow-mount';
|
|
57
|
+
shadow.appendChild(mount);
|
|
58
|
+
}
|
|
59
|
+
} catch {
|
|
60
|
+
// Fail-safe: if anything goes wrong, do nothing (styles may be lost, but never crash host app).
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// style-loader may import this module as an ES module and expect a `default` export.
|
|
65
|
+
// Provide both CJS and default to be robust across bundler/runtime variations.
|
|
66
|
+
module.exports = insertIntoOnairosShadowRoot;
|
|
67
|
+
module.exports.default = insertIntoOnairosShadowRoot;
|
|
68
|
+
|
|
69
|
+
|