@onairosofficial/onairos-capacitor 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CAPACITOR_QUICK_START.md +379 -0
- package/CONNECTORS.md +122 -0
- package/LICENSE +194 -10
- package/OnairosofficialOnairosCapacitor.podspec +13 -0
- package/Package.swift +26 -0
- package/README.md +176 -25
- package/dist/onairos.capacitor.esm.js +1 -0
- package/dist/onairos.capacitor.esm.turbopack.js +1 -0
- package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
- package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
- package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
- package/docs/CROSS_SDK_PARITY.md +239 -0
- package/docs/DATA_FREQUENCY.md +57 -0
- package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
- package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
- package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
- package/docs/PLATFORM_APIS.md +559 -0
- package/docs/RAW_MEMORIES_API.md +305 -0
- package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
- package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
- package/docs/oldFixes.md +216 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
- package/onairos.d.ts +656 -0
- package/package.json +188 -37
- 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/nativeConnectors.js +5 -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 +15 -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,170 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
|
|
3
|
+
class GeminiConnector extends Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.state = {
|
|
7
|
+
connected: false,
|
|
8
|
+
open: false,
|
|
9
|
+
isConnecting: false,
|
|
10
|
+
};
|
|
11
|
+
this.handleClose = this.handleClose.bind(this);
|
|
12
|
+
this.handleOpen = this.handleOpen.bind(this);
|
|
13
|
+
this.geminiConnect = this.geminiConnect.bind(this);
|
|
14
|
+
this.setConnected = this.setConnected.bind(this);
|
|
15
|
+
this.setDisconnected = this.setDisconnected.bind(this);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setConnected() {
|
|
19
|
+
this.setState({ connected: true });
|
|
20
|
+
if (this.props.onConnectionChange) {
|
|
21
|
+
this.props.onConnectionChange('Gemini', true);
|
|
22
|
+
}
|
|
23
|
+
this.handleClose();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setDisconnected() {
|
|
27
|
+
this.setState({ connected: false });
|
|
28
|
+
if (this.props.onConnectionChange) {
|
|
29
|
+
this.props.onConnectionChange('Gemini', false);
|
|
30
|
+
}
|
|
31
|
+
this.handleClose();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handleOpen() {
|
|
35
|
+
this.setState({ open: true });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
handleClose() {
|
|
39
|
+
this.setState({ open: false });
|
|
40
|
+
if (this.props.onClose) {
|
|
41
|
+
this.props.onClose();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async geminiConnect() {
|
|
46
|
+
// Use the LLM Connector Manager if available, otherwise fallback to old behavior
|
|
47
|
+
const llmManager = this.props.llmConnectorManager;
|
|
48
|
+
|
|
49
|
+
if (llmManager) {
|
|
50
|
+
// New behavior: Use extension detection
|
|
51
|
+
llmManager.connectToLLM(
|
|
52
|
+
'gemini',
|
|
53
|
+
(platform) => {
|
|
54
|
+
// Success callback
|
|
55
|
+
console.log(`✅ ${platform} connected via extension`);
|
|
56
|
+
this.setConnected();
|
|
57
|
+
},
|
|
58
|
+
(platform, error) => {
|
|
59
|
+
// Error callback
|
|
60
|
+
console.error(`❌ ${platform} connection error:`, error);
|
|
61
|
+
alert(`Failed to connect to ${platform}. ${error}`);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
} else {
|
|
65
|
+
// Fallback: Original behavior for backward compatibility
|
|
66
|
+
this.setState({ isConnecting: true });
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
console.log('🤖 Opening Gemini in new tab (fallback mode)...');
|
|
70
|
+
|
|
71
|
+
const geminiWindow = window.open('https://gemini.google.com', '_blank');
|
|
72
|
+
|
|
73
|
+
if (!geminiWindow) {
|
|
74
|
+
throw new Error('Popup blocked. Please allow popups for this site.');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
console.log('✅ Gemini connection simulated (fallback)');
|
|
79
|
+
this.setConnected();
|
|
80
|
+
this.setState({ isConnecting: false });
|
|
81
|
+
}, 1000);
|
|
82
|
+
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error('❌ Gemini connection error:', error);
|
|
85
|
+
this.setState({ isConnecting: false });
|
|
86
|
+
alert('Failed to open Gemini. Please ensure popups are allowed and try again.');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
const { open = this.props.open || this.state.open } = this.props;
|
|
93
|
+
|
|
94
|
+
if (!open) return null;
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[2147483647]">
|
|
98
|
+
<div className="bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-full md:max-h-[90vh] overflow-hidden">
|
|
99
|
+
<div className="p-6">
|
|
100
|
+
<div className="flex items-center mb-4">
|
|
101
|
+
<img
|
|
102
|
+
src="/gemini-color.png"
|
|
103
|
+
alt="Gemini"
|
|
104
|
+
className="w-8 h-8 mr-3"
|
|
105
|
+
onError={(e) => {
|
|
106
|
+
// Fallback to emoji if image fails to load
|
|
107
|
+
e.target.style.display = 'none';
|
|
108
|
+
e.target.nextSibling.style.display = 'inline';
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
<span className="text-2xl mr-3" style={{display: 'none'}}>💎</span>
|
|
112
|
+
<h2 className="text-xl font-bold text-gray-900">
|
|
113
|
+
Connect to Gemini
|
|
114
|
+
</h2>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div className="space-y-4 text-gray-700">
|
|
118
|
+
<p>
|
|
119
|
+
This will open Gemini in a new tab where you can interact with Google's advanced AI assistant.
|
|
120
|
+
</p>
|
|
121
|
+
|
|
122
|
+
<div>
|
|
123
|
+
<p className="font-medium mb-2">What you can do with Gemini:</p>
|
|
124
|
+
<ul className="list-disc ml-6 space-y-1">
|
|
125
|
+
<li>Ask questions and get comprehensive answers</li>
|
|
126
|
+
<li>Analyze images, documents, and multimedia content</li>
|
|
127
|
+
<li>Get help with research and fact-checking</li>
|
|
128
|
+
<li>Work on creative projects and brainstorming</li>
|
|
129
|
+
<li>Receive coding assistance and technical help</li>
|
|
130
|
+
</ul>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<div className="bg-blue-50 border border-blue-200 rounded-lg p-3">
|
|
134
|
+
<p className="text-blue-800 text-sm font-medium">
|
|
135
|
+
<strong>Note:</strong> Gemini will open in a new tab. You can return to this page anytime.
|
|
136
|
+
</p>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<p className="text-sm">
|
|
140
|
+
By connecting to Gemini, you'll be redirected to{' '}
|
|
141
|
+
<a href="https://gemini.google.com" className="text-blue-600 hover:underline" target="_blank" rel="noopener noreferrer">
|
|
142
|
+
gemini.google.com
|
|
143
|
+
</a>
|
|
144
|
+
</p>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<div className="flex space-x-3 mt-6">
|
|
148
|
+
<button
|
|
149
|
+
onClick={this.handleClose}
|
|
150
|
+
disabled={this.state.isConnecting}
|
|
151
|
+
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"
|
|
152
|
+
>
|
|
153
|
+
Cancel
|
|
154
|
+
</button>
|
|
155
|
+
<button
|
|
156
|
+
onClick={this.geminiConnect}
|
|
157
|
+
disabled={this.state.isConnecting}
|
|
158
|
+
className="flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"
|
|
159
|
+
>
|
|
160
|
+
{this.state.isConnecting ? 'Opening...' : 'Open Gemini'}
|
|
161
|
+
</button>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export default GeminiConnector;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { getCapacitorBrowser, isCapacitorNativePlatform } from '../../utils/capacitorPlugins.js';
|
|
3
|
+
import { getUserAuthHeaders, isUserAuthenticated } from '../../utils/authHeaders';
|
|
4
|
+
import { API_CONFIG } from '../../config/api-config';
|
|
5
|
+
|
|
6
|
+
class GmailConnector extends Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.state = {
|
|
10
|
+
connected: false,
|
|
11
|
+
open: false,
|
|
12
|
+
isConnecting: false,
|
|
13
|
+
};
|
|
14
|
+
this.handleClose = this.handleClose.bind(this);
|
|
15
|
+
this.handleOpen = this.handleOpen.bind(this);
|
|
16
|
+
this.gmailConnect = this.gmailConnect.bind(this);
|
|
17
|
+
this.setConnected = this.setConnected.bind(this);
|
|
18
|
+
this.setDisconnected = this.setDisconnected.bind(this);
|
|
19
|
+
}
|
|
20
|
+
// ... (rest of the file until gmailConnect method)
|
|
21
|
+
async gmailConnect() {
|
|
22
|
+
this.setState({ isConnecting: true });
|
|
23
|
+
|
|
24
|
+
// TIER 2: Require user JWT for OAuth connections
|
|
25
|
+
if (!isUserAuthenticated()) {
|
|
26
|
+
console.error('[Gmail] User not authenticated - cannot connect');
|
|
27
|
+
this.setState({ isConnecting: false });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
console.log('Requesting Gmail authorization...');
|
|
33
|
+
const response = await fetch(`${API_CONFIG.getBaseUrl()}/gmail/authorize`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: getUserAuthHeaders(),
|
|
36
|
+
body: JSON.stringify({}), // Username extracted from JWT on backend
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const result = await response.json();
|
|
40
|
+
console.log('Gmail auth response:', result);
|
|
41
|
+
|
|
42
|
+
if (result.gmailURL) {
|
|
43
|
+
const isNative = isCapacitorNativePlatform();
|
|
44
|
+
console.log('Is Native Platform:', isNative);
|
|
45
|
+
|
|
46
|
+
if (isNative) {
|
|
47
|
+
// Google blocks OAuth in embedded webviews (WKWebView) with `disallowed_useragent`.
|
|
48
|
+
// Use the system browser (SFSafariViewController via Capacitor Browser plugin).
|
|
49
|
+
console.log('Detected Native Platform, opening secure browser for Gmail OAuth');
|
|
50
|
+
const CapBrowser = getCapacitorBrowser();
|
|
51
|
+
if (CapBrowser?.open) {
|
|
52
|
+
await CapBrowser.open({
|
|
53
|
+
url: result.gmailURL,
|
|
54
|
+
windowName: '_blank',
|
|
55
|
+
presentationStyle: 'fullscreen',
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
// Fallback (may be blocked by Google policy, but better than no-op)
|
|
59
|
+
window.location.href = result.gmailURL;
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
console.log('Web platform detected, using window.location');
|
|
63
|
+
window.location.href = result.gmailURL;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
console.error('No Gmail URL received');
|
|
67
|
+
this.setState({ isConnecting: false });
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Gmail connection error:', error);
|
|
71
|
+
this.setState({ isConnecting: false });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
render() {
|
|
76
|
+
// ... (rest of the file)
|
|
77
|
+
const { open = this.props.open || this.state.open } = this.props;
|
|
78
|
+
|
|
79
|
+
if (!open) return null;
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[2147483647]">
|
|
83
|
+
<div className="bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-full md:max-h-[90vh] overflow-hidden">
|
|
84
|
+
<div className="p-6">
|
|
85
|
+
<h2 className="text-xl font-bold text-gray-900 mb-4">
|
|
86
|
+
Grant Onairos Access to your Gmail Account?
|
|
87
|
+
</h2>
|
|
88
|
+
|
|
89
|
+
<div className="space-y-4 text-gray-700">
|
|
90
|
+
<p>
|
|
91
|
+
Grant Permission to your Gmail Account, so we can build your Data Models.
|
|
92
|
+
</p>
|
|
93
|
+
|
|
94
|
+
<div>
|
|
95
|
+
<p className="font-medium mb-2">We will access your Gmail:</p>
|
|
96
|
+
<ul className="list-disc ml-6 space-y-1">
|
|
97
|
+
<li>Basic Account Information</li>
|
|
98
|
+
<li>Email Metadata (subjects, dates, senders)</li>
|
|
99
|
+
<li>Email Categories and Labels</li>
|
|
100
|
+
<li>Communication Patterns</li>
|
|
101
|
+
</ul>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div className="bg-yellow-50 border border-yellow-200 rounded-lg p-3">
|
|
105
|
+
<p className="text-yellow-800 text-sm font-medium">
|
|
106
|
+
<strong>Note:</strong> We do NOT read the content of your emails. Only metadata is processed.
|
|
107
|
+
</p>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<p>
|
|
111
|
+
We will delete all the data used once your Model is Created
|
|
112
|
+
</p>
|
|
113
|
+
|
|
114
|
+
<p className="text-sm">
|
|
115
|
+
<a href="https://onairos.uk/compliance-google-policy" className="text-blue-600 hover:underline">
|
|
116
|
+
Onairos
|
|
117
|
+
</a>{' '}
|
|
118
|
+
complies with{' '}
|
|
119
|
+
<a href="https://policies.google.com/privacy" className="text-blue-600 hover:underline">
|
|
120
|
+
Google API Services User Data Policy
|
|
121
|
+
</a>
|
|
122
|
+
</p>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<div className="flex space-x-3 mt-6">
|
|
126
|
+
<button
|
|
127
|
+
onClick={this.handleClose}
|
|
128
|
+
disabled={this.state.isConnecting}
|
|
129
|
+
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"
|
|
130
|
+
>
|
|
131
|
+
Disagree
|
|
132
|
+
</button>
|
|
133
|
+
<button
|
|
134
|
+
onClick={this.gmailConnect}
|
|
135
|
+
disabled={this.state.isConnecting}
|
|
136
|
+
className="flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"
|
|
137
|
+
>
|
|
138
|
+
{this.state.isConnecting ? 'Connecting...' : 'Agree'}
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default GmailConnector;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { getCapacitorBrowser, isCapacitorNativePlatform } from '../../utils/capacitorPlugins.js';
|
|
3
|
+
import { getUserAuthHeaders, isUserAuthenticated } from '../../utils/authHeaders';
|
|
4
|
+
import { API_CONFIG } from '../../config/api-config';
|
|
5
|
+
|
|
6
|
+
class GmailConnector extends Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.state = {
|
|
10
|
+
connected: false,
|
|
11
|
+
open: false,
|
|
12
|
+
isConnecting: false,
|
|
13
|
+
};
|
|
14
|
+
this.handleClose = this.handleClose.bind(this);
|
|
15
|
+
this.handleOpen = this.handleOpen.bind(this);
|
|
16
|
+
this.gmailConnect = this.gmailConnect.bind(this);
|
|
17
|
+
this.setConnected = this.setConnected.bind(this);
|
|
18
|
+
this.setDisconnected = this.setDisconnected.bind(this);
|
|
19
|
+
}
|
|
20
|
+
// ... (rest of the file until gmailConnect method)
|
|
21
|
+
async gmailConnect() {
|
|
22
|
+
this.setState({ isConnecting: true });
|
|
23
|
+
|
|
24
|
+
// TIER 2: Require user JWT for OAuth connections
|
|
25
|
+
if (!isUserAuthenticated()) {
|
|
26
|
+
console.error('[Gmail] User not authenticated - cannot connect');
|
|
27
|
+
this.setState({ isConnecting: false });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
console.log('Requesting Gmail authorization...');
|
|
33
|
+
const response = await fetch(`${API_CONFIG.getBaseUrl()}/gmail/authorize`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: getUserAuthHeaders(),
|
|
36
|
+
body: JSON.stringify({}), // Username extracted from JWT on backend
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const result = await response.json();
|
|
40
|
+
console.log('Gmail auth response:', result);
|
|
41
|
+
|
|
42
|
+
if (result.gmailURL) {
|
|
43
|
+
const isNative = isCapacitorNativePlatform();
|
|
44
|
+
console.log('Is Native Platform:', isNative);
|
|
45
|
+
|
|
46
|
+
if (isNative) {
|
|
47
|
+
// Google blocks OAuth in embedded webviews (WKWebView) with `disallowed_useragent`.
|
|
48
|
+
// Use the system browser (SFSafariViewController via Capacitor Browser plugin).
|
|
49
|
+
console.log('Detected Native Platform, opening secure browser for Gmail OAuth');
|
|
50
|
+
const CapBrowser = getCapacitorBrowser();
|
|
51
|
+
if (CapBrowser?.open) {
|
|
52
|
+
await CapBrowser.open({
|
|
53
|
+
url: result.gmailURL,
|
|
54
|
+
windowName: '_blank',
|
|
55
|
+
presentationStyle: 'fullscreen',
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
// Fallback (may be blocked by Google policy, but better than no-op)
|
|
59
|
+
window.location.href = result.gmailURL;
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
console.log('Web platform detected, using window.location');
|
|
63
|
+
window.location.href = result.gmailURL;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
console.error('No Gmail URL received');
|
|
67
|
+
this.setState({ isConnecting: false });
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Gmail connection error:', error);
|
|
71
|
+
this.setState({ isConnecting: false });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
render() {
|
|
76
|
+
// ... (rest of the file)
|
|
77
|
+
const { open = this.props.open || this.state.open } = this.props;
|
|
78
|
+
|
|
79
|
+
if (!open) return null;
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[2147483647]">
|
|
83
|
+
<div className="bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-full md:max-h-[90vh] overflow-hidden">
|
|
84
|
+
<div className="p-6">
|
|
85
|
+
<h2 className="text-xl font-bold text-gray-900 mb-4">
|
|
86
|
+
Grant Onairos Access to your Gmail Account?
|
|
87
|
+
</h2>
|
|
88
|
+
|
|
89
|
+
<div className="space-y-4 text-gray-700">
|
|
90
|
+
<p>
|
|
91
|
+
Grant Permission to your Gmail Account, so we can build your Data Models.
|
|
92
|
+
</p>
|
|
93
|
+
|
|
94
|
+
<div>
|
|
95
|
+
<p className="font-medium mb-2">We will access your Gmail:</p>
|
|
96
|
+
<ul className="list-disc ml-6 space-y-1">
|
|
97
|
+
<li>Basic Account Information</li>
|
|
98
|
+
<li>Email Metadata (subjects, dates, senders)</li>
|
|
99
|
+
<li>Email Categories and Labels</li>
|
|
100
|
+
<li>Communication Patterns</li>
|
|
101
|
+
</ul>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div className="bg-yellow-50 border border-yellow-200 rounded-lg p-3">
|
|
105
|
+
<p className="text-yellow-800 text-sm font-medium">
|
|
106
|
+
<strong>Note:</strong> We do NOT read the content of your emails. Only metadata is processed.
|
|
107
|
+
</p>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<p>
|
|
111
|
+
We will delete all the data used once your Model is Created
|
|
112
|
+
</p>
|
|
113
|
+
|
|
114
|
+
<p className="text-sm">
|
|
115
|
+
<a href="https://onairos.uk/compliance-google-policy" className="text-blue-600 hover:underline">
|
|
116
|
+
Onairos
|
|
117
|
+
</a>{' '}
|
|
118
|
+
complies with{' '}
|
|
119
|
+
<a href="https://policies.google.com/privacy" className="text-blue-600 hover:underline">
|
|
120
|
+
Google API Services User Data Policy
|
|
121
|
+
</a>
|
|
122
|
+
</p>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<div className="flex space-x-3 mt-6">
|
|
126
|
+
<button
|
|
127
|
+
onClick={this.handleClose}
|
|
128
|
+
disabled={this.state.isConnecting}
|
|
129
|
+
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"
|
|
130
|
+
>
|
|
131
|
+
Disagree
|
|
132
|
+
</button>
|
|
133
|
+
<button
|
|
134
|
+
onClick={this.gmailConnect}
|
|
135
|
+
disabled={this.state.isConnecting}
|
|
136
|
+
className="flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"
|
|
137
|
+
>
|
|
138
|
+
{this.state.isConnecting ? 'Connecting...' : 'Agree'}
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default GmailConnector;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ConnectGrokModal from '../ConnectGrokModal.jsx';
|
|
3
|
+
|
|
4
|
+
export default function GrokConnector({ open, onClose, onConnectionChange }) {
|
|
5
|
+
return (
|
|
6
|
+
<ConnectGrokModal
|
|
7
|
+
open={open}
|
|
8
|
+
onClose={onClose}
|
|
9
|
+
onConnected={() => {
|
|
10
|
+
if (typeof onConnectionChange === 'function') {
|
|
11
|
+
onConnectionChange('Grok', true);
|
|
12
|
+
}
|
|
13
|
+
}}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ConnectGrokModal from '../ConnectGrokModal.jsx';
|
|
3
|
+
|
|
4
|
+
export default function GrokConnector({ open, onClose, onConnectionChange }) {
|
|
5
|
+
return (
|
|
6
|
+
<ConnectGrokModal
|
|
7
|
+
open={open}
|
|
8
|
+
onClose={onClose}
|
|
9
|
+
onConnected={() => {
|
|
10
|
+
if (typeof onConnectionChange === 'function') {
|
|
11
|
+
onConnectionChange('Grok', true);
|
|
12
|
+
}
|
|
13
|
+
}}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|