@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,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onairos Vite Plugin for Laravel
|
|
3
|
+
*
|
|
4
|
+
* This plugin provides seamless integration of Onairos components
|
|
5
|
+
* within Laravel Vite applications, handling both development and
|
|
6
|
+
* production builds.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { resolve } from 'path';
|
|
10
|
+
|
|
11
|
+
export function onairosLaravelPlugin(options = {}) {
|
|
12
|
+
const defaultOptions = {
|
|
13
|
+
autoImport: true,
|
|
14
|
+
injectGlobals: true,
|
|
15
|
+
optimizeDeps: true,
|
|
16
|
+
enableHMR: true,
|
|
17
|
+
bladeSupport: true
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const config = { ...defaultOptions, ...options };
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
name: 'onairos-laravel',
|
|
24
|
+
config(viteConfig, { command }) {
|
|
25
|
+
// Optimize dependencies for faster dev server startup
|
|
26
|
+
if (config.optimizeDeps) {
|
|
27
|
+
viteConfig.optimizeDeps = viteConfig.optimizeDeps || {};
|
|
28
|
+
viteConfig.optimizeDeps.include = viteConfig.optimizeDeps.include || [];
|
|
29
|
+
viteConfig.optimizeDeps.include.push('onairos');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Add alias for easier imports
|
|
33
|
+
viteConfig.resolve = viteConfig.resolve || {};
|
|
34
|
+
viteConfig.resolve.alias = viteConfig.resolve.alias || {};
|
|
35
|
+
viteConfig.resolve.alias['@onairos'] = resolve('node_modules/onairos');
|
|
36
|
+
|
|
37
|
+
// Configure for Laravel Blade support
|
|
38
|
+
if (config.bladeSupport && command === 'serve') {
|
|
39
|
+
viteConfig.server = viteConfig.server || {};
|
|
40
|
+
viteConfig.server.watch = viteConfig.server.watch || {};
|
|
41
|
+
viteConfig.server.watch.include = viteConfig.server.watch.include || [];
|
|
42
|
+
viteConfig.server.watch.include.push('resources/views/**/*.blade.php');
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
configureServer(server) {
|
|
47
|
+
if (config.enableHMR) {
|
|
48
|
+
// Add custom HMR handling for Onairos components
|
|
49
|
+
server.ws.on('onairos:reload', () => {
|
|
50
|
+
server.ws.send({
|
|
51
|
+
type: 'full-reload'
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
transformIndexHtml: {
|
|
58
|
+
enforce: 'pre',
|
|
59
|
+
transform(html, context) {
|
|
60
|
+
if (config.injectGlobals && context.server) {
|
|
61
|
+
// Inject Onairos initialization script for development
|
|
62
|
+
const initScript = `
|
|
63
|
+
<script type="module">
|
|
64
|
+
import { initializeOnairosForBlade } from '/node_modules/onairos/src/laravel/blade-helpers.js';
|
|
65
|
+
|
|
66
|
+
// Initialize Onairos for Laravel Blade templates
|
|
67
|
+
initializeOnairosForBlade({
|
|
68
|
+
testMode: true,
|
|
69
|
+
autoDetectMobile: true,
|
|
70
|
+
globalStyles: true
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Enable HMR for Onairos components
|
|
74
|
+
if (import.meta.hot) {
|
|
75
|
+
import.meta.hot.on('onairos:update', () => {
|
|
76
|
+
console.log('🔥 Onairos components updated');
|
|
77
|
+
window.location.reload();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
return html.replace('<head>', `<head>${initScript}`);
|
|
84
|
+
}
|
|
85
|
+
return html;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
generateBundle(options, bundle) {
|
|
90
|
+
// Add Onairos assets to the build output
|
|
91
|
+
if (config.autoImport) {
|
|
92
|
+
// Create a separate chunk for Laravel integration
|
|
93
|
+
this.emitFile({
|
|
94
|
+
type: 'chunk',
|
|
95
|
+
id: 'onairos-laravel-integration',
|
|
96
|
+
fileName: 'onairos-laravel.js'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
writeBundle(options, bundle) {
|
|
102
|
+
// Create Laravel-specific integration files
|
|
103
|
+
const laravelIntegrationCode = `
|
|
104
|
+
// Onairos Laravel Integration
|
|
105
|
+
import { initializeOnairosForBlade, createOnairosButton } from 'onairos/blade';
|
|
106
|
+
|
|
107
|
+
// Auto-initialize for production
|
|
108
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
109
|
+
initializeOnairosForBlade({
|
|
110
|
+
testMode: false,
|
|
111
|
+
autoDetectMobile: true,
|
|
112
|
+
globalStyles: true
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Export for manual usage
|
|
117
|
+
window.Onairos = {
|
|
118
|
+
init: initializeOnairosForBlade,
|
|
119
|
+
createButton: createOnairosButton
|
|
120
|
+
};
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
// Write the integration file
|
|
124
|
+
this.emitFile({
|
|
125
|
+
type: 'asset',
|
|
126
|
+
fileName: 'onairos-laravel-integration.js',
|
|
127
|
+
source: laravelIntegrationCode
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Vue.js specific plugin for Laravel
|
|
134
|
+
export function onairosVuePlugin(options = {}) {
|
|
135
|
+
return {
|
|
136
|
+
name: 'onairos-vue-laravel',
|
|
137
|
+
config(viteConfig) {
|
|
138
|
+
// Add Vue-specific optimizations for Onairos
|
|
139
|
+
viteConfig.optimizeDeps = viteConfig.optimizeDeps || {};
|
|
140
|
+
viteConfig.optimizeDeps.include = viteConfig.optimizeDeps.include || [];
|
|
141
|
+
viteConfig.optimizeDeps.include.push('onairos', 'vue');
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
transform(code, id) {
|
|
145
|
+
// Auto-import Onairos in Vue components
|
|
146
|
+
if (id.endsWith('.vue') && options.autoImport) {
|
|
147
|
+
if (code.includes('OnairosButton') && !code.includes('import.*OnairosButton')) {
|
|
148
|
+
return `import { OnairosButton } from 'onairos';\n${code}`;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// React specific plugin for Laravel
|
|
157
|
+
export function onairosReactPlugin(options = {}) {
|
|
158
|
+
return {
|
|
159
|
+
name: 'onairos-react-laravel',
|
|
160
|
+
config(viteConfig) {
|
|
161
|
+
// Add React-specific optimizations for Onairos
|
|
162
|
+
viteConfig.optimizeDeps = viteConfig.optimizeDeps || {};
|
|
163
|
+
viteConfig.optimizeDeps.include = viteConfig.optimizeDeps.include || [];
|
|
164
|
+
viteConfig.optimizeDeps.include.push('onairos', 'react', 'react-dom');
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
transform(code, id) {
|
|
168
|
+
// Auto-import Onairos in React components
|
|
169
|
+
if ((id.endsWith('.jsx') || id.endsWith('.tsx')) && options.autoImport) {
|
|
170
|
+
if (code.includes('OnairosButton') && !code.includes('import.*OnairosButton')) {
|
|
171
|
+
return `import { OnairosButton } from 'onairos';\n${code}`;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default onairosLaravelPlugin;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import MobileIndividualConnection from './components/MobileIndividualConnection';
|
|
3
|
+
import { getApiBaseUrl } from '../config/api-config.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* MobileDataRequestPage Component
|
|
7
|
+
* Mobile-optimized version of DataRequestPage for React Native environment
|
|
8
|
+
*/
|
|
9
|
+
const MobileDataRequestPage = ({
|
|
10
|
+
requestData = {},
|
|
11
|
+
dataRequester = 'App',
|
|
12
|
+
proofMode = false,
|
|
13
|
+
domain = '',
|
|
14
|
+
onComplete,
|
|
15
|
+
onCancel
|
|
16
|
+
}) => {
|
|
17
|
+
const [loading, setLoading] = useState(true);
|
|
18
|
+
const [activeModels, setActiveModels] = useState([]);
|
|
19
|
+
const [granted, setGranted] = useState(0);
|
|
20
|
+
const [allowSubmit, setAllowSubmit] = useState(false);
|
|
21
|
+
const selectedConnections = useRef([]);
|
|
22
|
+
|
|
23
|
+
// Update allowSubmit when granted changes
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setAllowSubmit(granted > 0);
|
|
26
|
+
}, [granted]);
|
|
27
|
+
|
|
28
|
+
// Simulate loading data
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const loadData = async () => {
|
|
31
|
+
try {
|
|
32
|
+
// Simulate API call
|
|
33
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
34
|
+
|
|
35
|
+
// Set sample data for mobile
|
|
36
|
+
setActiveModels(requestData?.activeModels || ['Personality', 'Demographics']);
|
|
37
|
+
setLoading(false);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error loading data:', error);
|
|
40
|
+
setLoading(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
loadData();
|
|
45
|
+
}, [requestData]);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Reject all data requests
|
|
49
|
+
*/
|
|
50
|
+
function rejectDataRequest() {
|
|
51
|
+
if (onCancel && typeof onCancel === 'function') {
|
|
52
|
+
onCancel();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Send the selected data requests to the parent window
|
|
58
|
+
*/
|
|
59
|
+
function sendDataRequest() {
|
|
60
|
+
if (granted === 0) {
|
|
61
|
+
rejectDataRequest();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Determine API endpoint based on test mode (default to live)
|
|
66
|
+
const testMode = false; // Can be made configurable
|
|
67
|
+
const apiBaseUrl = getApiBaseUrl();
|
|
68
|
+
const apiEndpoint = testMode
|
|
69
|
+
? `${apiBaseUrl}/inferenceTest`
|
|
70
|
+
: `${apiBaseUrl}/getAPIurlMobile`;
|
|
71
|
+
|
|
72
|
+
// Map approved connections to confirmations format
|
|
73
|
+
const mapConnectionsToConfirmations = (connections) => {
|
|
74
|
+
const confirmations = [];
|
|
75
|
+
const currentDate = new Date().toISOString();
|
|
76
|
+
|
|
77
|
+
// Map connection types to backend data types
|
|
78
|
+
const connectionMapping = {
|
|
79
|
+
'basic': 'Medium',
|
|
80
|
+
'personality': 'Large',
|
|
81
|
+
'preferences': 'Traits',
|
|
82
|
+
'social': 'Large',
|
|
83
|
+
'activity': 'Medium'
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
connections.forEach(connection => {
|
|
87
|
+
if (connectionMapping[connection]) {
|
|
88
|
+
confirmations.push({
|
|
89
|
+
data: connectionMapping[connection],
|
|
90
|
+
date: currentDate
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return confirmations;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const confirmations = mapConnectionsToConfirmations(selectedConnections.current);
|
|
99
|
+
|
|
100
|
+
// Create API response with the updated format
|
|
101
|
+
// PIN is stored on backend via /store-pin/mobile - no need to send placeholder
|
|
102
|
+
const apiResponse = {
|
|
103
|
+
success: true,
|
|
104
|
+
apiUrl: apiEndpoint,
|
|
105
|
+
testMode: testMode,
|
|
106
|
+
approvedRequests: selectedConnections.current,
|
|
107
|
+
confirmations: confirmations,
|
|
108
|
+
// Include Info format for backend compatibility
|
|
109
|
+
Info: {
|
|
110
|
+
storage: "local",
|
|
111
|
+
appId: "MobileApp",
|
|
112
|
+
confirmations: confirmations,
|
|
113
|
+
account: "mobile_user",
|
|
114
|
+
proofMode: false,
|
|
115
|
+
Domain: window.location?.hostname || "mobile.app",
|
|
116
|
+
web3Type: "standard",
|
|
117
|
+
OthentSub: null
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Call onComplete with API response
|
|
122
|
+
if (onComplete && typeof onComplete === 'function') {
|
|
123
|
+
onComplete(apiResponse);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Update the granted count
|
|
129
|
+
*/
|
|
130
|
+
function changeGranted(plusMinus) {
|
|
131
|
+
setGranted(prev => prev + plusMinus);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Handle selection of a connection/data request
|
|
136
|
+
*/
|
|
137
|
+
function handleConnectionSelection(dataRequester, modelType, index, title, reward, isSelected) {
|
|
138
|
+
const newDate = new Date();
|
|
139
|
+
const newConnection = {
|
|
140
|
+
requester: dataRequester,
|
|
141
|
+
date: newDate.toISOString(),
|
|
142
|
+
name: title,
|
|
143
|
+
reward: reward,
|
|
144
|
+
data: modelType
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
if (isSelected) {
|
|
148
|
+
// Add to selected connections if not already present
|
|
149
|
+
if (!selectedConnections.current.find(connection =>
|
|
150
|
+
connection.requester === dataRequester && connection.data === modelType)) {
|
|
151
|
+
selectedConnections.current = [...selectedConnections.current, newConnection];
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
// Remove from selected connections
|
|
155
|
+
selectedConnections.current = selectedConnections.current.filter(
|
|
156
|
+
connection => !(connection.requester === dataRequester && connection.data === modelType)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Main render
|
|
162
|
+
if (loading) {
|
|
163
|
+
return (
|
|
164
|
+
<div className="mobile-loading-container">
|
|
165
|
+
<div className="mobile-loading-spinner"></div>
|
|
166
|
+
<p className="mobile-loading-text">Loading...</p>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<div className="mobile-data-request-container" style={{ height: '60vh' }}>
|
|
173
|
+
<div className="mobile-data-request-header">
|
|
174
|
+
<h2 className="mobile-data-request-title">Data Requests from {dataRequester}</h2>
|
|
175
|
+
|
|
176
|
+
<div className="mobile-data-request-button-row">
|
|
177
|
+
<button
|
|
178
|
+
className="mobile-reject-button"
|
|
179
|
+
onClick={rejectDataRequest}
|
|
180
|
+
>
|
|
181
|
+
Reject All
|
|
182
|
+
</button>
|
|
183
|
+
|
|
184
|
+
<button
|
|
185
|
+
className="mobile-confirm-button"
|
|
186
|
+
disabled={!allowSubmit}
|
|
187
|
+
onClick={sendDataRequest}
|
|
188
|
+
>
|
|
189
|
+
Confirm ({granted})
|
|
190
|
+
</button>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<div className="mobile-data-request-content">
|
|
195
|
+
{activeModels.length === 0 ? (
|
|
196
|
+
<div className="mobile-no-models-message">
|
|
197
|
+
<p>
|
|
198
|
+
Please connect Onairos Personality to send {dataRequester} your data
|
|
199
|
+
</p>
|
|
200
|
+
</div>
|
|
201
|
+
) : (
|
|
202
|
+
<div className="mobile-connections-list">
|
|
203
|
+
{Object.keys(requestData)
|
|
204
|
+
.filter(key => requestData[key])
|
|
205
|
+
.map((key, index) => {
|
|
206
|
+
const product = requestData[key];
|
|
207
|
+
const active = activeModels.includes(product.type);
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<MobileIndividualConnection
|
|
211
|
+
key={key}
|
|
212
|
+
active={active}
|
|
213
|
+
title={product.type}
|
|
214
|
+
id={product}
|
|
215
|
+
number={index}
|
|
216
|
+
descriptions={product.descriptions}
|
|
217
|
+
rewards={product.reward}
|
|
218
|
+
size={key}
|
|
219
|
+
changeGranted={changeGranted}
|
|
220
|
+
onSelectionChange={(isSelected) =>
|
|
221
|
+
handleConnectionSelection(dataRequester, key, index, product.type, product.reward, isSelected)
|
|
222
|
+
}
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
})}
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export default MobileDataRequestPage;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MobileBox Component
|
|
5
|
+
* Mobile-optimized checkbox component for data request selections
|
|
6
|
+
*/
|
|
7
|
+
export default function MobileBox({
|
|
8
|
+
active,
|
|
9
|
+
onSelectionChange,
|
|
10
|
+
changeGranted,
|
|
11
|
+
number,
|
|
12
|
+
title,
|
|
13
|
+
type
|
|
14
|
+
}) {
|
|
15
|
+
const [isChecked, setIsChecked] = useState(false);
|
|
16
|
+
|
|
17
|
+
const handleCheckboxChange = (e) => {
|
|
18
|
+
// Get the checked state
|
|
19
|
+
const newCheckedState = e.target.checked;
|
|
20
|
+
setIsChecked(newCheckedState);
|
|
21
|
+
|
|
22
|
+
// Update the counter
|
|
23
|
+
if (newCheckedState) {
|
|
24
|
+
changeGranted(1);
|
|
25
|
+
} else {
|
|
26
|
+
changeGranted(-1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Report the selection change to parent
|
|
30
|
+
onSelectionChange(newCheckedState);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Reset checkbox when overlay closes or becomes inactive
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!active) {
|
|
36
|
+
setIsChecked(false);
|
|
37
|
+
}
|
|
38
|
+
}, [active]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="mobile-box-container">
|
|
42
|
+
<div
|
|
43
|
+
className={`mobile-checkbox-wrapper ${!active ? 'inactive' : 'active'}`}
|
|
44
|
+
>
|
|
45
|
+
<input
|
|
46
|
+
id={`mobile-checkbox-${number}`}
|
|
47
|
+
type="checkbox"
|
|
48
|
+
value=""
|
|
49
|
+
checked={isChecked}
|
|
50
|
+
onChange={handleCheckboxChange}
|
|
51
|
+
disabled={!active}
|
|
52
|
+
className={`mobile-checkbox ${isChecked && active ? 'checked' : ''}`}
|
|
53
|
+
/>
|
|
54
|
+
<label
|
|
55
|
+
htmlFor={`mobile-checkbox-${number}`}
|
|
56
|
+
className={`mobile-checkbox-label ${active ? 'active' : 'inactive'}`}
|
|
57
|
+
>
|
|
58
|
+
<span className="mobile-checkbox-title">
|
|
59
|
+
{title || `Request ${number}`}
|
|
60
|
+
</span>
|
|
61
|
+
</label>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
{!active && (
|
|
65
|
+
<div className="mobile-inactive-message">
|
|
66
|
+
Please create your Personality model to access this Grant Request
|
|
67
|
+
</div>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MobileIndividualConnection Component
|
|
5
|
+
* Mobile-optimized version of the IndividualConnection component
|
|
6
|
+
* for displaying data request options in React Native
|
|
7
|
+
*/
|
|
8
|
+
export default function MobileIndividualConnection({
|
|
9
|
+
active,
|
|
10
|
+
title,
|
|
11
|
+
id,
|
|
12
|
+
number,
|
|
13
|
+
descriptions,
|
|
14
|
+
rewards,
|
|
15
|
+
size,
|
|
16
|
+
changeGranted,
|
|
17
|
+
onSelectionChange,
|
|
18
|
+
}) {
|
|
19
|
+
const handleCheckboxChange = (isSelected) => {
|
|
20
|
+
// Report the selection to parent component
|
|
21
|
+
onSelectionChange(isSelected);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="mobile-connection-container">
|
|
26
|
+
<div className="mobile-connection-header">
|
|
27
|
+
<div className="mobile-connection-checkbox-area">
|
|
28
|
+
<input
|
|
29
|
+
type="checkbox"
|
|
30
|
+
disabled={!active}
|
|
31
|
+
className="mobile-connection-checkbox"
|
|
32
|
+
onChange={(e) => handleCheckboxChange(e.target.checked)}
|
|
33
|
+
/>
|
|
34
|
+
<span className="mobile-connection-title">{title}</span>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
{rewards && (
|
|
38
|
+
<div className="mobile-connection-rewards">
|
|
39
|
+
Rewards: {rewards}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
{descriptions && title !== "Avatar" && (
|
|
45
|
+
<div className="mobile-connection-description">
|
|
46
|
+
Intent: {descriptions}
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser APIs Shim for React Native
|
|
3
|
+
*
|
|
4
|
+
* This file provides mock implementations of browser APIs that are not available in React Native.
|
|
5
|
+
* These shims allow the code to run in React Native without errors.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Mock window.postMessage for React Native
|
|
9
|
+
if (typeof window !== 'undefined' && !window.postMessage) {
|
|
10
|
+
window.postMessage = function(message, targetOrigin, transfer) {
|
|
11
|
+
console.log('Shim: window.postMessage called with:', message);
|
|
12
|
+
// In a real implementation, you might want to use React Native's event system
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Mock localStorage for React Native
|
|
17
|
+
if (typeof localStorage === 'undefined') {
|
|
18
|
+
global.localStorage = {
|
|
19
|
+
_data: {},
|
|
20
|
+
setItem: function(id, val) {
|
|
21
|
+
this._data[id] = String(val);
|
|
22
|
+
return val;
|
|
23
|
+
},
|
|
24
|
+
getItem: function(id) {
|
|
25
|
+
return this._data.hasOwnProperty(id) ? this._data[id] : null;
|
|
26
|
+
},
|
|
27
|
+
removeItem: function(id) {
|
|
28
|
+
return delete this._data[id];
|
|
29
|
+
},
|
|
30
|
+
clear: function() {
|
|
31
|
+
this._data = {};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Mock sessionStorage for React Native
|
|
37
|
+
if (typeof sessionStorage === 'undefined') {
|
|
38
|
+
global.sessionStorage = {
|
|
39
|
+
_data: {},
|
|
40
|
+
setItem: function(id, val) {
|
|
41
|
+
this._data[id] = String(val);
|
|
42
|
+
return val;
|
|
43
|
+
},
|
|
44
|
+
getItem: function(id) {
|
|
45
|
+
return this._data.hasOwnProperty(id) ? this._data[id] : null;
|
|
46
|
+
},
|
|
47
|
+
removeItem: function(id) {
|
|
48
|
+
return delete this._data[id];
|
|
49
|
+
},
|
|
50
|
+
clear: function() {
|
|
51
|
+
this._data = {};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Mock document object for React Native if it doesn't exist
|
|
57
|
+
if (typeof document === 'undefined') {
|
|
58
|
+
global.document = {
|
|
59
|
+
createElement: () => ({
|
|
60
|
+
style: {},
|
|
61
|
+
setAttribute: () => {},
|
|
62
|
+
appendChild: () => {},
|
|
63
|
+
}),
|
|
64
|
+
body: {
|
|
65
|
+
appendChild: () => {},
|
|
66
|
+
removeChild: () => {},
|
|
67
|
+
},
|
|
68
|
+
head: {
|
|
69
|
+
appendChild: () => {},
|
|
70
|
+
},
|
|
71
|
+
createTextNode: () => ({}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Export API shims
|
|
76
|
+
export default {
|
|
77
|
+
// Add any specific exports here if needed
|
|
78
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lucide React Shim for React Native
|
|
3
|
+
*
|
|
4
|
+
* This file provides mock implementations of lucide-react icons for React Native compatibility.
|
|
5
|
+
* In a real implementation, you would replace these with appropriate React Native icon components.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
// Create a base icon component for React Native
|
|
11
|
+
const BaseIcon = ({ size = 24, color = 'currentColor', children, ...props }) => {
|
|
12
|
+
// For React Native we'll just provide a simple implementation
|
|
13
|
+
// This would be replaced with a proper RN svg or icon component
|
|
14
|
+
return React.createElement('div', {
|
|
15
|
+
style: {
|
|
16
|
+
width: size,
|
|
17
|
+
height: size,
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
color: color,
|
|
22
|
+
...props.style
|
|
23
|
+
},
|
|
24
|
+
...props
|
|
25
|
+
}, children || '□');
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Create mock implementations of commonly used Lucide icons
|
|
29
|
+
const ChevronRight = (props) => React.createElement(BaseIcon, props, '▶');
|
|
30
|
+
const ChevronLeft = (props) => React.createElement(BaseIcon, props, '◀');
|
|
31
|
+
const ChevronDown = (props) => React.createElement(BaseIcon, props, '▼');
|
|
32
|
+
const ChevronUp = (props) => React.createElement(BaseIcon, props, '▲');
|
|
33
|
+
const X = (props) => React.createElement(BaseIcon, props, '✕');
|
|
34
|
+
const Check = (props) => React.createElement(BaseIcon, props, '✓');
|
|
35
|
+
const Menu = (props) => React.createElement(BaseIcon, props, '☰');
|
|
36
|
+
const Settings = (props) => React.createElement(BaseIcon, props, '⚙');
|
|
37
|
+
const User = (props) => React.createElement(BaseIcon, props, '👤');
|
|
38
|
+
const Lock = (props) => React.createElement(BaseIcon, props, '🔒');
|
|
39
|
+
const Unlock = (props) => React.createElement(BaseIcon, props, '🔓');
|
|
40
|
+
|
|
41
|
+
// Adding the missing icons reported in build warnings
|
|
42
|
+
const Shield = (props) => React.createElement(BaseIcon, props, '🛡️');
|
|
43
|
+
const AlertCircle = (props) => React.createElement(BaseIcon, props, '⚠️');
|
|
44
|
+
const Send = (props) => React.createElement(BaseIcon, props, '📤');
|
|
45
|
+
const ExternalLink = (props) => React.createElement(BaseIcon, props, '🔗');
|
|
46
|
+
|
|
47
|
+
// Export all mock icons
|
|
48
|
+
export {
|
|
49
|
+
ChevronRight,
|
|
50
|
+
ChevronLeft,
|
|
51
|
+
ChevronDown,
|
|
52
|
+
ChevronUp,
|
|
53
|
+
X,
|
|
54
|
+
Check,
|
|
55
|
+
Menu,
|
|
56
|
+
Settings,
|
|
57
|
+
User,
|
|
58
|
+
Lock,
|
|
59
|
+
Unlock,
|
|
60
|
+
// New exports for the missing icons
|
|
61
|
+
Shield,
|
|
62
|
+
AlertCircle,
|
|
63
|
+
Send,
|
|
64
|
+
ExternalLink
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Export a default object with all icons to mimic lucide-react's structure
|
|
68
|
+
export default {
|
|
69
|
+
ChevronRight,
|
|
70
|
+
ChevronLeft,
|
|
71
|
+
ChevronDown,
|
|
72
|
+
ChevronUp,
|
|
73
|
+
X,
|
|
74
|
+
Check,
|
|
75
|
+
Menu,
|
|
76
|
+
Settings,
|
|
77
|
+
User,
|
|
78
|
+
Lock,
|
|
79
|
+
Unlock,
|
|
80
|
+
// Add the new icons to the default export
|
|
81
|
+
Shield,
|
|
82
|
+
AlertCircle,
|
|
83
|
+
Send,
|
|
84
|
+
ExternalLink
|
|
85
|
+
};
|