@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,285 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import UniversalOnboarding from '../components/UniversalOnboarding.jsx';
|
|
3
|
+
import IndividualConnection from './components/IndividualConnection';
|
|
4
|
+
import onairosLogo from './icons/onairos_logo.png';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* DataRequestPage Component
|
|
8
|
+
* Displays different data requests and handles user interactions
|
|
9
|
+
*/
|
|
10
|
+
const DataRequestPage = ({ requestData = {}, dataRequester = 'App', proofMode = false, domain = '', appIcon = '' }) => {
|
|
11
|
+
const [loading, setLoading] = useState(true);
|
|
12
|
+
const [activeModels, setActiveModels] = useState([]);
|
|
13
|
+
const [granted, setGranted] = useState(0);
|
|
14
|
+
const [allowSubmit, setAllowSubmit] = useState(false);
|
|
15
|
+
const [userConnections, setUserConnections] = useState(['instagram', 'youtube', 'email']);
|
|
16
|
+
const [selectedRequests, setSelectedRequests] = useState({});
|
|
17
|
+
const selectedConnections = useRef([]);
|
|
18
|
+
const userSub = useRef(null);
|
|
19
|
+
const encryptedUserPin = useRef(null);
|
|
20
|
+
|
|
21
|
+
// Update allowSubmit when granted changes
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (granted > 0) {
|
|
24
|
+
setAllowSubmit(true);
|
|
25
|
+
} else {
|
|
26
|
+
setAllowSubmit(false);
|
|
27
|
+
}
|
|
28
|
+
}, [granted]);
|
|
29
|
+
|
|
30
|
+
// Simulate loading data
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
// In a real implementation, this would fetch active models from a service
|
|
33
|
+
const loadData = async () => {
|
|
34
|
+
try {
|
|
35
|
+
// Simulate API call
|
|
36
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
37
|
+
|
|
38
|
+
// Sample active models - this would come from your backend
|
|
39
|
+
setActiveModels(['Profile', 'User Memories']);
|
|
40
|
+
setLoading(false);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('Error loading data:', error);
|
|
43
|
+
setLoading(false);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
loadData();
|
|
48
|
+
|
|
49
|
+
// Message handler to receive data from parent window
|
|
50
|
+
const handleMessage = (event) => {
|
|
51
|
+
if (event.data && event.data.type === 'dataRequest') {
|
|
52
|
+
// Process received data
|
|
53
|
+
if (event.data.requestData) {
|
|
54
|
+
// Update request data state
|
|
55
|
+
}
|
|
56
|
+
if (event.data.activeModels) {
|
|
57
|
+
setActiveModels(event.data.activeModels);
|
|
58
|
+
}
|
|
59
|
+
if (event.data.userSub) {
|
|
60
|
+
userSub.current = event.data.userSub;
|
|
61
|
+
}
|
|
62
|
+
if (event.data.encryptedUserPin) {
|
|
63
|
+
encryptedUserPin.current = event.data.encryptedUserPin;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Add message listener
|
|
69
|
+
window.addEventListener('message', handleMessage);
|
|
70
|
+
|
|
71
|
+
// Clean up listener
|
|
72
|
+
return () => {
|
|
73
|
+
window.removeEventListener('message', handleMessage);
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reject all data requests
|
|
79
|
+
*/
|
|
80
|
+
async function rejectDataRequest() {
|
|
81
|
+
window.top.postMessage({type: 'closeIframe'}, '*');
|
|
82
|
+
window.postMessage({type: 'closeIframe'}, '*');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Send the selected data requests to the parent window
|
|
87
|
+
*/
|
|
88
|
+
async function sendDataRequest() {
|
|
89
|
+
if (granted === 0) {
|
|
90
|
+
window.close();
|
|
91
|
+
return;
|
|
92
|
+
} else {
|
|
93
|
+
const SignMessage = {
|
|
94
|
+
message: 'Confirm ' + dataRequester + ' Data Access',
|
|
95
|
+
confirmations: selectedConnections.current
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Send simplified response
|
|
99
|
+
try {
|
|
100
|
+
window.top.postMessage({
|
|
101
|
+
type: 'dataRequestComplete',
|
|
102
|
+
approved: selectedConnections.current,
|
|
103
|
+
message: SignMessage
|
|
104
|
+
}, '*');
|
|
105
|
+
|
|
106
|
+
window.postMessage({
|
|
107
|
+
type: 'dataRequestComplete',
|
|
108
|
+
approved: selectedConnections.current,
|
|
109
|
+
message: SignMessage
|
|
110
|
+
}, '*');
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error("Error sending data request:", error);
|
|
113
|
+
window.close();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Update the granted count
|
|
120
|
+
*/
|
|
121
|
+
function changeGranted(plusMinus) {
|
|
122
|
+
setGranted(granted + plusMinus);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Handle selection of a connection/data request
|
|
127
|
+
*/
|
|
128
|
+
function handleConnectionSelection(dataRequester, modelType, index, title, reward, isSelected) {
|
|
129
|
+
const newDate = new Date();
|
|
130
|
+
const newConnection = {
|
|
131
|
+
requester: dataRequester,
|
|
132
|
+
date: newDate.toISOString(),
|
|
133
|
+
name: title,
|
|
134
|
+
reward: reward,
|
|
135
|
+
data: modelType
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (isSelected) {
|
|
139
|
+
console.log(`Adding connection: ${JSON.stringify(newConnection)}`);
|
|
140
|
+
if (!selectedConnections.current.find(connection => connection.requester === dataRequester && connection.data === modelType)) {
|
|
141
|
+
selectedConnections.current.push(newConnection);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
console.log(`Removing connection for: ${modelType}`);
|
|
145
|
+
selectedConnections.current = selectedConnections.current.filter(
|
|
146
|
+
connection => !(connection.requester === dataRequester && connection.data === modelType)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
console.log('Current selected connections:', selectedConnections.current);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div className="min-h-screen bg-gray-100">
|
|
155
|
+
{loading ? (
|
|
156
|
+
<div className="flex items-center justify-center min-h-screen">
|
|
157
|
+
<div className="animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"></div>
|
|
158
|
+
</div>
|
|
159
|
+
) : activeModels.length === 0 ? (
|
|
160
|
+
<UniversalOnboarding
|
|
161
|
+
appIcon="https://onairos.sirv.com/Images/OnairosBlack.png"
|
|
162
|
+
appName={dataRequester}
|
|
163
|
+
username={localStorage.getItem("username")}
|
|
164
|
+
/>
|
|
165
|
+
) : (
|
|
166
|
+
<div className="max-w-md mx-auto p-6 space-y-4">
|
|
167
|
+
<header className="bg-white p-6 rounded-xl shadow-md">
|
|
168
|
+
<div className="flex items-center justify-between mb-6">
|
|
169
|
+
<div className="flex items-center space-x-2">
|
|
170
|
+
<img src={onairosLogo} alt="Onairos Logo" className="w-8 h-8" />
|
|
171
|
+
<div className="text-gray-400 mx-2">→</div>
|
|
172
|
+
{appIcon ? (
|
|
173
|
+
<img src={appIcon} alt={`${dataRequester} Logo`} className="w-8 h-8 rounded-full" />
|
|
174
|
+
) : (
|
|
175
|
+
<div className="w-8 h-8 bg-gray-200 rounded-full flex items-center justify-center">
|
|
176
|
+
<span className="text-gray-600 text-xs font-bold">{dataRequester.charAt(0)}</span>
|
|
177
|
+
</div>
|
|
178
|
+
)}
|
|
179
|
+
</div>
|
|
180
|
+
<h2 className="text-lg font-bold text-gray-800">{dataRequester}</h2>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<h1 className="text-xl font-bold text-gray-800 mb-4">Data Access Request</h1>
|
|
184
|
+
<p className="text-gray-600 mb-6">Select the data you want to share with {dataRequester}</p>
|
|
185
|
+
|
|
186
|
+
<div className="flex items-center justify-between gap-4">
|
|
187
|
+
<button
|
|
188
|
+
onClick={rejectDataRequest}
|
|
189
|
+
className="border w-full border border-gray-300 hover:bg-gray-50 text-gray-700 font-medium py-3 px-4 rounded-lg transition-colors"
|
|
190
|
+
>
|
|
191
|
+
Decline
|
|
192
|
+
</button>
|
|
193
|
+
<button
|
|
194
|
+
disabled={!allowSubmit}
|
|
195
|
+
onClick={sendDataRequest}
|
|
196
|
+
className="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
|
197
|
+
>
|
|
198
|
+
Approve {granted > 0 && `(${granted})`}
|
|
199
|
+
</button>
|
|
200
|
+
</div>
|
|
201
|
+
</header>
|
|
202
|
+
|
|
203
|
+
<div className="space-y-3">
|
|
204
|
+
{/* Only show Profile and User Memories */}
|
|
205
|
+
{['Profile', 'User Memories'].map((dataType, index) => {
|
|
206
|
+
const key = dataType.toLowerCase().replace(' ', '_');
|
|
207
|
+
const product = {
|
|
208
|
+
type: dataType,
|
|
209
|
+
descriptions: dataType === 'Profile' ?
|
|
210
|
+
'Basic profile information and preferences' :
|
|
211
|
+
'Your personal context and memory data',
|
|
212
|
+
reward: dataType === 'Profile' ?
|
|
213
|
+
'Personalized experience' :
|
|
214
|
+
'Contextual understanding of your preferences'
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<IndividualConnection
|
|
219
|
+
key={key}
|
|
220
|
+
active={true}
|
|
221
|
+
title={product.type}
|
|
222
|
+
id={product}
|
|
223
|
+
number={index}
|
|
224
|
+
descriptions={product.descriptions}
|
|
225
|
+
rewards={product.reward}
|
|
226
|
+
size={key}
|
|
227
|
+
changeGranted={changeGranted}
|
|
228
|
+
onSelectionChange={(isSelected) =>
|
|
229
|
+
handleConnectionSelection(dataRequester, key, index, product.type, product.reward, isSelected)
|
|
230
|
+
}
|
|
231
|
+
/>
|
|
232
|
+
);
|
|
233
|
+
})}
|
|
234
|
+
|
|
235
|
+
{/* User Connections Section */}
|
|
236
|
+
<div className="bg-white p-4 rounded-xl shadow-sm mt-4">
|
|
237
|
+
<h3 className="text-sm font-semibold text-gray-700 mb-3">Your Connected Services</h3>
|
|
238
|
+
<div className="flex items-center space-x-3">
|
|
239
|
+
{userConnections.map((connection, index) => {
|
|
240
|
+
const getConnectionIcon = (type) => {
|
|
241
|
+
switch(type) {
|
|
242
|
+
case 'instagram':
|
|
243
|
+
return (
|
|
244
|
+
<div className="w-10 h-10 rounded-full bg-linear-to-tr from-purple-500 via-pink-500 to-yellow-500 flex items-center justify-center">
|
|
245
|
+
<span className="text-white text-xs">IG</span>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
case 'youtube':
|
|
249
|
+
return (
|
|
250
|
+
<div className="w-10 h-10 rounded-full bg-red-600 flex items-center justify-center">
|
|
251
|
+
<span className="text-white text-xs">YT</span>
|
|
252
|
+
</div>
|
|
253
|
+
);
|
|
254
|
+
case 'email':
|
|
255
|
+
return (
|
|
256
|
+
<div className="w-10 h-10 rounded-full bg-blue-500 flex items-center justify-center">
|
|
257
|
+
<span className="text-white text-xs">@</span>
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
default:
|
|
261
|
+
return (
|
|
262
|
+
<div className="w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center">
|
|
263
|
+
<span className="text-gray-600 text-xs">{type.charAt(0).toUpperCase()}</span>
|
|
264
|
+
</div>
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
return (
|
|
270
|
+
<div key={index} className="flex flex-col items-center">
|
|
271
|
+
{getConnectionIcon(connection)}
|
|
272
|
+
<span className="text-xs text-gray-600 mt-1">{connection}</span>
|
|
273
|
+
</div>
|
|
274
|
+
);
|
|
275
|
+
})}
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
)}
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export default DataRequestPage;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Onairos Button Integration Guide
|
|
2
|
+
|
|
3
|
+
This document provides guidance on how to integrate the new iframe-based data request system into the OnairosButton component when ready.
|
|
4
|
+
|
|
5
|
+
## Changes Required to OnairosButton.jsx
|
|
6
|
+
|
|
7
|
+
When you're ready to implement the iframe approach (replacing the window.message approach), you'll need to make the following changes to `onairosButton.jsx`:
|
|
8
|
+
|
|
9
|
+
### 1. Import the iframe handler module
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Add this near the top of the file with other imports
|
|
13
|
+
import { openDataRequestIframe, closeDataRequestIframe, sendDataToIframe, listenForIframeMessages } from './iframe/dataRequestHandler.js';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 2. Modify the `openTerminal` function in OnairosButton
|
|
17
|
+
|
|
18
|
+
Current implementation:
|
|
19
|
+
```javascript
|
|
20
|
+
const openTerminal = async () => {
|
|
21
|
+
window.postMessage({
|
|
22
|
+
action: 'terminalOpened',
|
|
23
|
+
requestData: requestData,
|
|
24
|
+
webpageName: webpageName,
|
|
25
|
+
activeModels: activeModels,
|
|
26
|
+
avatar: avatar,
|
|
27
|
+
traits: traits
|
|
28
|
+
}, '*');
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
New implementation using iframe:
|
|
33
|
+
```javascript
|
|
34
|
+
const openTerminal = async () => {
|
|
35
|
+
// Open the iframe in a new window at the top-right corner
|
|
36
|
+
const iframeWindow = openDataRequestIframe();
|
|
37
|
+
|
|
38
|
+
// If the window opened successfully, send data to it
|
|
39
|
+
if (iframeWindow) {
|
|
40
|
+
// Store reference to the iframe window
|
|
41
|
+
setIframeWindowRef(iframeWindow);
|
|
42
|
+
|
|
43
|
+
// Wait for the iframe to initialize
|
|
44
|
+
const initializeIframe = () => {
|
|
45
|
+
// Send data to the iframe
|
|
46
|
+
sendDataToIframe(iframeWindow, {
|
|
47
|
+
type: 'initDataRequest',
|
|
48
|
+
requestData: requestData,
|
|
49
|
+
dataRequester: webpageName,
|
|
50
|
+
activeModels: activeModels,
|
|
51
|
+
avatar: avatar,
|
|
52
|
+
traits: traits
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Listen for messages from the iframe
|
|
57
|
+
listenForIframeMessages((data) => {
|
|
58
|
+
if (data.action === 'iframeReady') {
|
|
59
|
+
// The iframe is ready to receive data
|
|
60
|
+
initializeIframe();
|
|
61
|
+
} else if (data.action === 'dataRequestConfirmed') {
|
|
62
|
+
// Handle confirmed data request
|
|
63
|
+
handleApprovedDataRequest(data.approvedRequests);
|
|
64
|
+
} else if (data.action === 'dataRequestRejected') {
|
|
65
|
+
// Handle rejected data request
|
|
66
|
+
handleRejectedDataRequest();
|
|
67
|
+
} else if (data.action === 'terminalClosed') {
|
|
68
|
+
// Handle iframe closed event
|
|
69
|
+
setIframeWindowRef(null);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Add state for storing the iframe window reference
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
// Add near other state declarations
|
|
80
|
+
const [iframeWindowRef, setIframeWindowRef] = useState(null);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 4. Implement handlers for iframe responses
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// Add these new functions to handle responses from the iframe
|
|
87
|
+
const handleApprovedDataRequest = (approvedRequests) => {
|
|
88
|
+
// This replaces the current handleAPIResponse logic
|
|
89
|
+
// Process the approved requests from the iframe
|
|
90
|
+
console.log('Approved data requests:', approvedRequests);
|
|
91
|
+
|
|
92
|
+
// Continue with your existing flow to process the requests
|
|
93
|
+
// e.g., call makeApiCall with the approved requests
|
|
94
|
+
|
|
95
|
+
// Clear the iframe reference
|
|
96
|
+
setIframeWindowRef(null);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const handleRejectedDataRequest = () => {
|
|
100
|
+
console.log('Data request rejected by user');
|
|
101
|
+
|
|
102
|
+
// Handle rejection - reset states if needed
|
|
103
|
+
setSelectedRequests({});
|
|
104
|
+
setGranted(0);
|
|
105
|
+
|
|
106
|
+
// Clear the iframe reference
|
|
107
|
+
setIframeWindowRef(null);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 5. Clean up iframe when component unmounts
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
// Modify your existing useEffect cleanup or add a new one
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
return () => {
|
|
117
|
+
// Close the iframe if it's still open when the component unmounts
|
|
118
|
+
if (iframeWindowRef) {
|
|
119
|
+
closeDataRequestIframe(iframeWindowRef);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}, [iframeWindowRef]);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Testing
|
|
126
|
+
|
|
127
|
+
When implementing this change:
|
|
128
|
+
|
|
129
|
+
1. Test the iframe opens correctly in the top right corner
|
|
130
|
+
2. Verify data flows correctly from the main app to the iframe
|
|
131
|
+
3. Confirm user selections in the iframe are properly sent back to the main app
|
|
132
|
+
4. Ensure the iframe closes properly after user action or when the component unmounts
|
|
133
|
+
|
|
134
|
+
## Progressive Implementation
|
|
135
|
+
|
|
136
|
+
You can implement this change gradually:
|
|
137
|
+
|
|
138
|
+
1. First, keep both systems in parallel (window.message and iframe)
|
|
139
|
+
2. Test the iframe approach with a feature flag
|
|
140
|
+
3. Once confirmed working, remove the old window.message implementation
|
|
141
|
+
|
|
142
|
+
## Build Configuration
|
|
143
|
+
|
|
144
|
+
Ensure your build process is configured to:
|
|
145
|
+
|
|
146
|
+
1. Copy the iframe HTML file to the correct location
|
|
147
|
+
2. Bundle the iframe JavaScript correctly
|
|
148
|
+
3. Update your manifest.json to include the new HTML file in web_accessible_resources
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Box Component
|
|
5
|
+
* Displays a checkbox item for data access requests
|
|
6
|
+
*/
|
|
7
|
+
const Box = (props) => {
|
|
8
|
+
const handleChange = (e) => {
|
|
9
|
+
const checked = e.target.checked;
|
|
10
|
+
console.log(`Checkbox ${props.title} is now: ${checked ? 'checked' : 'unchecked'}`);
|
|
11
|
+
if (checked) {
|
|
12
|
+
props.setSelected(true);
|
|
13
|
+
props.changeGranted(1);
|
|
14
|
+
} else {
|
|
15
|
+
props.setSelected(false);
|
|
16
|
+
props.changeGranted(-1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
props.onSelectionChange(checked);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="relative inline-flex items-center">
|
|
24
|
+
<input
|
|
25
|
+
type="checkbox"
|
|
26
|
+
id={`request-${props.number}`}
|
|
27
|
+
disabled={!props.active}
|
|
28
|
+
onChange={handleChange}
|
|
29
|
+
className={`
|
|
30
|
+
appearance-none w-5 h-5 border rounded
|
|
31
|
+
${!props.active ? 'border-gray-300 bg-gray-100 cursor-not-allowed' : 'border-blue-500 cursor-pointer'}
|
|
32
|
+
checked:bg-blue-600 checked:border-blue-600
|
|
33
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500/30
|
|
34
|
+
transition-colors
|
|
35
|
+
`}
|
|
36
|
+
/>
|
|
37
|
+
<svg
|
|
38
|
+
className="absolute left-0.5 top-0.5 w-4 h-4 text-white pointer-events-none opacity-0 peer-checked:opacity-100"
|
|
39
|
+
fill="none"
|
|
40
|
+
stroke="currentColor"
|
|
41
|
+
viewBox="0 0 24 24"
|
|
42
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
43
|
+
>
|
|
44
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="3" d="M5 13l4 4L19 7"></path>
|
|
45
|
+
</svg>
|
|
46
|
+
|
|
47
|
+
{!props.active && (
|
|
48
|
+
<span className="ml-2 text-xs text-red-500 font-medium">
|
|
49
|
+
Not available
|
|
50
|
+
</span>
|
|
51
|
+
)}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default Box;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Box from './Box';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* IndividualConnection Component
|
|
6
|
+
* Displays a card for each data connection request
|
|
7
|
+
*/
|
|
8
|
+
function IndividualConnection(props) {
|
|
9
|
+
const [selected, setSelected] = useState(false);
|
|
10
|
+
|
|
11
|
+
const handleSelectionChange = (isSelected) => {
|
|
12
|
+
setSelected(isSelected);
|
|
13
|
+
props.onSelectionChange(isSelected);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Get icon based on data type
|
|
17
|
+
const getDataTypeIcon = () => {
|
|
18
|
+
switch(props.title) {
|
|
19
|
+
case "Profile":
|
|
20
|
+
return (
|
|
21
|
+
<div className="w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center">
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-blue-600" viewBox="0 0 20 20" fill="currentColor">
|
|
23
|
+
<path fillRule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clipRule="evenodd" />
|
|
24
|
+
</svg>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
case "User Memories":
|
|
28
|
+
return (
|
|
29
|
+
<div className="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center">
|
|
30
|
+
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-purple-600" viewBox="0 0 20 20" fill="currentColor">
|
|
31
|
+
<path d="M7 3a1 1 0 000 2h6a1 1 0 100-2H7zM4 7a1 1 0 011-1h10a1 1 0 110 2H5a1 1 0 01-1-1zM2 11a2 2 0 012-2h12a2 2 0 012 2v4a2 2 0 01-2 2H4a2 2 0 01-2-2v-4z" />
|
|
32
|
+
</svg>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
default:
|
|
36
|
+
return (
|
|
37
|
+
<div className="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center">
|
|
38
|
+
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-gray-600" viewBox="0 0 20 20" fill="currentColor">
|
|
39
|
+
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z" clipRule="evenodd" />
|
|
40
|
+
</svg>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="bg-white rounded-xl shadow-sm hover:shadow-md transition-all overflow-hidden">
|
|
48
|
+
<div className="p-5">
|
|
49
|
+
<div className="flex items-start space-x-4">
|
|
50
|
+
{getDataTypeIcon()}
|
|
51
|
+
<div className="flex-1">
|
|
52
|
+
<div className="flex items-center justify-between">
|
|
53
|
+
<h3 className="font-medium text-gray-800">{props.title}</h3>
|
|
54
|
+
<Box
|
|
55
|
+
active={props.active}
|
|
56
|
+
onSelectionChange={handleSelectionChange}
|
|
57
|
+
changeGranted={props.changeGranted}
|
|
58
|
+
setSelected={setSelected}
|
|
59
|
+
number={props.number + 1}
|
|
60
|
+
type={"Test"}
|
|
61
|
+
title={props.title}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
{props.descriptions && (
|
|
66
|
+
<div className="mt-2">
|
|
67
|
+
<p className="text-sm text-gray-600">{props.descriptions}</p>
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
{props.rewards && (
|
|
74
|
+
<div className="mt-3 pt-3 border-t border-gray-100">
|
|
75
|
+
<div className="flex items-center">
|
|
76
|
+
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-yellow-500 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
|
77
|
+
<path fillRule="evenodd" d="M5 2a1 1 0 011 1v1h1a1 1 0 010 2H6v1a1 1 0 01-2 0V6H3a1 1 0 010-2h1V3a1 1 0 011-1zm0 10a1 1 0 011 1v1h1a1 1 0 110 2H6v1a1 1 0 11-2 0v-1H3a1 1 0 110-2h1v-1a1 1 0 011-1zM12 2a1 1 0 01.967.744L14.146 7.2 17.5 9.134a1 1 0 010 1.732l-3.354 1.935-1.18 4.455a1 1 0 01-1.933 0L9.854 12.8 6.5 10.866a1 1 0 010-1.732l3.354-1.935 1.18-4.455A1 1 0 0112 2z" clipRule="evenodd" />
|
|
78
|
+
</svg>
|
|
79
|
+
<span className="text-xs text-gray-500">Benefit: <span className="text-gray-700">{props.rewards}</span></span>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default IndividualConnection;
|