@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,645 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onairos SSO Components
|
|
3
|
+
* Google-like SSO loading animation with Onairos branding
|
|
4
|
+
*
|
|
5
|
+
* Components:
|
|
6
|
+
* - SSOLoadingIndicator: Mini loading spinner (for corner placement)
|
|
7
|
+
* - SSOFullScreenLoader: Full-screen loading (for page transitions)
|
|
8
|
+
* - SSOStatusBadge: Shows current SSO status
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React, { useEffect, useState, useCallback } from 'react';
|
|
12
|
+
import {
|
|
13
|
+
isOnairosApp,
|
|
14
|
+
getOnairosAppType,
|
|
15
|
+
performAutoSSO,
|
|
16
|
+
getSSOStatus,
|
|
17
|
+
checkSSOSession
|
|
18
|
+
} from '../utils/crossDomainSSO.js';
|
|
19
|
+
|
|
20
|
+
// Import Onairos logo
|
|
21
|
+
const ONAIROS_LOGO_URL = 'https://onairos.sirv.com/Images/OnairosNewLogo.png';
|
|
22
|
+
const ONAIROS_WHITE_LOGO = 'https://onairos.sirv.com/Images/OnairosWhite.png';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Mini SSO Loading Indicator - Shows in corner (like Google)
|
|
26
|
+
* Use this for non-blocking SSO verification
|
|
27
|
+
*/
|
|
28
|
+
export function SSOLoadingIndicator({
|
|
29
|
+
position = 'top-left', // 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
|
|
30
|
+
size = 'small', // 'small' | 'medium' | 'large'
|
|
31
|
+
showText = false,
|
|
32
|
+
theme = 'light' // 'light' | 'dark'
|
|
33
|
+
}) {
|
|
34
|
+
const [isVerifying, setIsVerifying] = useState(true);
|
|
35
|
+
const [status, setStatus] = useState('checking');
|
|
36
|
+
|
|
37
|
+
const sizeMap = {
|
|
38
|
+
small: { logo: 24, spinner: 32, text: 10 },
|
|
39
|
+
medium: { logo: 32, spinner: 44, text: 12 },
|
|
40
|
+
large: { logo: 48, spinner: 64, text: 14 }
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const s = sizeMap[size] || sizeMap.small;
|
|
44
|
+
|
|
45
|
+
const positionStyles = {
|
|
46
|
+
'top-left': { top: 16, left: 16 },
|
|
47
|
+
'top-right': { top: 16, right: 16 },
|
|
48
|
+
'bottom-left': { bottom: 16, left: 16 },
|
|
49
|
+
'bottom-right': { bottom: 16, right: 16 }
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const checkSSO = async () => {
|
|
54
|
+
const ssoCheck = checkSSOSession();
|
|
55
|
+
|
|
56
|
+
if (!ssoCheck.hasSSO) {
|
|
57
|
+
setStatus('not-authenticated');
|
|
58
|
+
setIsVerifying(false);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!ssoCheck.needsVerification) {
|
|
63
|
+
setStatus('authenticated');
|
|
64
|
+
setIsVerifying(false);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Verify in background
|
|
69
|
+
setStatus('verifying');
|
|
70
|
+
const result = await performAutoSSO({
|
|
71
|
+
onSuccess: () => {
|
|
72
|
+
setStatus('authenticated');
|
|
73
|
+
setIsVerifying(false);
|
|
74
|
+
},
|
|
75
|
+
onError: () => {
|
|
76
|
+
setStatus('error');
|
|
77
|
+
setIsVerifying(false);
|
|
78
|
+
},
|
|
79
|
+
onNotAuthenticated: () => {
|
|
80
|
+
setStatus('not-authenticated');
|
|
81
|
+
setIsVerifying(false);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
checkSSO();
|
|
87
|
+
}, []);
|
|
88
|
+
|
|
89
|
+
// Hide if not verifying and no need to show
|
|
90
|
+
if (!isVerifying && status !== 'verifying') {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const isDark = theme === 'dark';
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
style={{
|
|
99
|
+
position: 'fixed',
|
|
100
|
+
...positionStyles[position],
|
|
101
|
+
zIndex: 9999,
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
gap: 8,
|
|
105
|
+
padding: '8px 12px',
|
|
106
|
+
backgroundColor: isDark ? 'rgba(17, 24, 39, 0.95)' : 'rgba(255, 255, 255, 0.95)',
|
|
107
|
+
borderRadius: 24,
|
|
108
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
109
|
+
backdropFilter: 'blur(8px)',
|
|
110
|
+
animation: 'sso-fade-in 0.3s ease-out'
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{/* Spinning ring around logo */}
|
|
114
|
+
<div style={{ position: 'relative', width: s.spinner, height: s.spinner }}>
|
|
115
|
+
{/* Spinner ring */}
|
|
116
|
+
<svg
|
|
117
|
+
style={{
|
|
118
|
+
position: 'absolute',
|
|
119
|
+
top: 0,
|
|
120
|
+
left: 0,
|
|
121
|
+
width: s.spinner,
|
|
122
|
+
height: s.spinner,
|
|
123
|
+
animation: 'sso-spin 1.2s linear infinite'
|
|
124
|
+
}}
|
|
125
|
+
viewBox="0 0 50 50"
|
|
126
|
+
>
|
|
127
|
+
<circle
|
|
128
|
+
cx="25"
|
|
129
|
+
cy="25"
|
|
130
|
+
r="22"
|
|
131
|
+
fill="none"
|
|
132
|
+
stroke={isDark ? 'rgba(255, 255, 255, 0.15)' : 'rgba(0, 0, 0, 0.08)'}
|
|
133
|
+
strokeWidth="3"
|
|
134
|
+
/>
|
|
135
|
+
<circle
|
|
136
|
+
cx="25"
|
|
137
|
+
cy="25"
|
|
138
|
+
r="22"
|
|
139
|
+
fill="none"
|
|
140
|
+
stroke="#2563eb"
|
|
141
|
+
strokeWidth="3"
|
|
142
|
+
strokeLinecap="round"
|
|
143
|
+
strokeDasharray="80 120"
|
|
144
|
+
/>
|
|
145
|
+
</svg>
|
|
146
|
+
|
|
147
|
+
{/* Onairos logo in center */}
|
|
148
|
+
<img
|
|
149
|
+
src={ONAIROS_LOGO_URL}
|
|
150
|
+
alt="Onairos"
|
|
151
|
+
style={{
|
|
152
|
+
position: 'absolute',
|
|
153
|
+
top: '50%',
|
|
154
|
+
left: '50%',
|
|
155
|
+
transform: 'translate(-50%, -50%)',
|
|
156
|
+
width: s.logo,
|
|
157
|
+
height: s.logo,
|
|
158
|
+
borderRadius: '50%',
|
|
159
|
+
objectFit: 'contain'
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
{showText && (
|
|
165
|
+
<span
|
|
166
|
+
style={{
|
|
167
|
+
fontSize: s.text,
|
|
168
|
+
fontWeight: 500,
|
|
169
|
+
color: isDark ? 'rgba(255, 255, 255, 0.9)' : 'rgba(0, 0, 0, 0.7)',
|
|
170
|
+
fontFamily: 'system-ui, -apple-system, sans-serif'
|
|
171
|
+
}}
|
|
172
|
+
>
|
|
173
|
+
Signing in...
|
|
174
|
+
</span>
|
|
175
|
+
)}
|
|
176
|
+
|
|
177
|
+
<style>{`
|
|
178
|
+
@keyframes sso-spin {
|
|
179
|
+
from { transform: rotate(0deg); }
|
|
180
|
+
to { transform: rotate(360deg); }
|
|
181
|
+
}
|
|
182
|
+
@keyframes sso-fade-in {
|
|
183
|
+
from { opacity: 0; transform: scale(0.9); }
|
|
184
|
+
to { opacity: 1; transform: scale(1); }
|
|
185
|
+
}
|
|
186
|
+
`}</style>
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Full-Screen SSO Loading - For page transitions
|
|
193
|
+
* Shows Onairos logo with animated loading ring (like Google)
|
|
194
|
+
*/
|
|
195
|
+
export function SSOFullScreenLoader({
|
|
196
|
+
onComplete,
|
|
197
|
+
onError,
|
|
198
|
+
message = 'Signing you in...',
|
|
199
|
+
theme = 'light',
|
|
200
|
+
showProgress = false,
|
|
201
|
+
autoHide = true,
|
|
202
|
+
autoHideDelay = 500
|
|
203
|
+
}) {
|
|
204
|
+
const [status, setStatus] = useState('loading'); // 'loading' | 'success' | 'error' | 'hidden'
|
|
205
|
+
const [progress, setProgress] = useState(0);
|
|
206
|
+
const [userData, setUserData] = useState(null);
|
|
207
|
+
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
let progressInterval;
|
|
210
|
+
|
|
211
|
+
if (showProgress) {
|
|
212
|
+
progressInterval = setInterval(() => {
|
|
213
|
+
setProgress(p => Math.min(p + Math.random() * 15, 90));
|
|
214
|
+
}, 200);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const performSSO = async () => {
|
|
218
|
+
const result = await performAutoSSO({
|
|
219
|
+
onStart: () => setStatus('loading'),
|
|
220
|
+
onSuccess: (user) => {
|
|
221
|
+
setProgress(100);
|
|
222
|
+
setUserData(user);
|
|
223
|
+
setStatus('success');
|
|
224
|
+
|
|
225
|
+
if (autoHide) {
|
|
226
|
+
setTimeout(() => {
|
|
227
|
+
setStatus('hidden');
|
|
228
|
+
onComplete?.(user);
|
|
229
|
+
}, autoHideDelay);
|
|
230
|
+
} else {
|
|
231
|
+
onComplete?.(user);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
onError: (error) => {
|
|
235
|
+
setStatus('error');
|
|
236
|
+
onError?.(error);
|
|
237
|
+
},
|
|
238
|
+
onNotAuthenticated: () => {
|
|
239
|
+
setStatus('hidden');
|
|
240
|
+
onError?.('Not authenticated');
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
if (!result.authenticated) {
|
|
245
|
+
setStatus('hidden');
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
performSSO();
|
|
250
|
+
|
|
251
|
+
return () => {
|
|
252
|
+
if (progressInterval) clearInterval(progressInterval);
|
|
253
|
+
};
|
|
254
|
+
}, [onComplete, onError, showProgress, autoHide, autoHideDelay]);
|
|
255
|
+
|
|
256
|
+
if (status === 'hidden') return null;
|
|
257
|
+
|
|
258
|
+
const isDark = theme === 'dark';
|
|
259
|
+
const bgColor = isDark ? '#0f172a' : '#ffffff';
|
|
260
|
+
const textColor = isDark ? '#f8fafc' : '#1e293b';
|
|
261
|
+
const subTextColor = isDark ? '#94a3b8' : '#64748b';
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<div
|
|
265
|
+
style={{
|
|
266
|
+
position: 'fixed',
|
|
267
|
+
top: 0,
|
|
268
|
+
left: 0,
|
|
269
|
+
right: 0,
|
|
270
|
+
bottom: 0,
|
|
271
|
+
backgroundColor: bgColor,
|
|
272
|
+
display: 'flex',
|
|
273
|
+
flexDirection: 'column',
|
|
274
|
+
alignItems: 'center',
|
|
275
|
+
justifyContent: 'center',
|
|
276
|
+
zIndex: 10000,
|
|
277
|
+
animation: status === 'hidden' ? 'sso-fade-out 0.3s ease-out forwards' : 'sso-fade-in 0.3s ease-out'
|
|
278
|
+
}}
|
|
279
|
+
>
|
|
280
|
+
{/* Logo with spinning ring */}
|
|
281
|
+
<div style={{ position: 'relative', width: 120, height: 120, marginBottom: 24 }}>
|
|
282
|
+
{/* Outer spinning ring */}
|
|
283
|
+
<svg
|
|
284
|
+
style={{
|
|
285
|
+
position: 'absolute',
|
|
286
|
+
top: 0,
|
|
287
|
+
left: 0,
|
|
288
|
+
width: 120,
|
|
289
|
+
height: 120,
|
|
290
|
+
animation: status === 'loading' ? 'sso-spin 1.5s ease-in-out infinite' : 'none'
|
|
291
|
+
}}
|
|
292
|
+
viewBox="0 0 120 120"
|
|
293
|
+
>
|
|
294
|
+
{/* Background circle */}
|
|
295
|
+
<circle
|
|
296
|
+
cx="60"
|
|
297
|
+
cy="60"
|
|
298
|
+
r="54"
|
|
299
|
+
fill="none"
|
|
300
|
+
stroke={isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.06)'}
|
|
301
|
+
strokeWidth="4"
|
|
302
|
+
/>
|
|
303
|
+
|
|
304
|
+
{/* Animated arc */}
|
|
305
|
+
<circle
|
|
306
|
+
cx="60"
|
|
307
|
+
cy="60"
|
|
308
|
+
r="54"
|
|
309
|
+
fill="none"
|
|
310
|
+
stroke={status === 'success' ? '#22c55e' : status === 'error' ? '#ef4444' : '#2563eb'}
|
|
311
|
+
strokeWidth="4"
|
|
312
|
+
strokeLinecap="round"
|
|
313
|
+
strokeDasharray={status === 'success' ? '340' : '100 240'}
|
|
314
|
+
style={{
|
|
315
|
+
transition: 'stroke-dasharray 0.5s ease-out, stroke 0.3s ease'
|
|
316
|
+
}}
|
|
317
|
+
/>
|
|
318
|
+
</svg>
|
|
319
|
+
|
|
320
|
+
{/* Inner pulsing glow */}
|
|
321
|
+
<div
|
|
322
|
+
style={{
|
|
323
|
+
position: 'absolute',
|
|
324
|
+
top: '50%',
|
|
325
|
+
left: '50%',
|
|
326
|
+
transform: 'translate(-50%, -50%)',
|
|
327
|
+
width: 88,
|
|
328
|
+
height: 88,
|
|
329
|
+
borderRadius: '50%',
|
|
330
|
+
background: `radial-gradient(circle, ${isDark ? 'rgba(37, 99, 235, 0.2)' : 'rgba(37, 99, 235, 0.1)'} 0%, transparent 70%)`,
|
|
331
|
+
animation: 'sso-pulse 2s ease-in-out infinite'
|
|
332
|
+
}}
|
|
333
|
+
/>
|
|
334
|
+
|
|
335
|
+
{/* Logo */}
|
|
336
|
+
<img
|
|
337
|
+
src={ONAIROS_LOGO_URL}
|
|
338
|
+
alt="Onairos"
|
|
339
|
+
style={{
|
|
340
|
+
position: 'absolute',
|
|
341
|
+
top: '50%',
|
|
342
|
+
left: '50%',
|
|
343
|
+
transform: 'translate(-50%, -50%)',
|
|
344
|
+
width: 64,
|
|
345
|
+
height: 64,
|
|
346
|
+
borderRadius: '50%',
|
|
347
|
+
objectFit: 'contain',
|
|
348
|
+
backgroundColor: isDark ? '#1e293b' : '#fff',
|
|
349
|
+
padding: 8,
|
|
350
|
+
boxShadow: '0 4px 24px rgba(0, 0, 0, 0.1)'
|
|
351
|
+
}}
|
|
352
|
+
/>
|
|
353
|
+
|
|
354
|
+
{/* Success checkmark overlay */}
|
|
355
|
+
{status === 'success' && (
|
|
356
|
+
<div
|
|
357
|
+
style={{
|
|
358
|
+
position: 'absolute',
|
|
359
|
+
top: '50%',
|
|
360
|
+
left: '50%',
|
|
361
|
+
transform: 'translate(-50%, -50%)',
|
|
362
|
+
width: 80,
|
|
363
|
+
height: 80,
|
|
364
|
+
display: 'flex',
|
|
365
|
+
alignItems: 'center',
|
|
366
|
+
justifyContent: 'center',
|
|
367
|
+
animation: 'sso-check-pop 0.4s ease-out'
|
|
368
|
+
}}
|
|
369
|
+
>
|
|
370
|
+
<svg width="32" height="32" viewBox="0 0 24 24" fill="none">
|
|
371
|
+
<path
|
|
372
|
+
d="M5 13l4 4L19 7"
|
|
373
|
+
stroke="#22c55e"
|
|
374
|
+
strokeWidth="3"
|
|
375
|
+
strokeLinecap="round"
|
|
376
|
+
strokeLinejoin="round"
|
|
377
|
+
style={{
|
|
378
|
+
strokeDasharray: 24,
|
|
379
|
+
strokeDashoffset: 0,
|
|
380
|
+
animation: 'sso-check-draw 0.4s ease-out forwards'
|
|
381
|
+
}}
|
|
382
|
+
/>
|
|
383
|
+
</svg>
|
|
384
|
+
</div>
|
|
385
|
+
)}
|
|
386
|
+
</div>
|
|
387
|
+
|
|
388
|
+
{/* Message */}
|
|
389
|
+
<div style={{ textAlign: 'center' }}>
|
|
390
|
+
<p
|
|
391
|
+
style={{
|
|
392
|
+
fontSize: 18,
|
|
393
|
+
fontWeight: 600,
|
|
394
|
+
color: textColor,
|
|
395
|
+
margin: 0,
|
|
396
|
+
fontFamily: 'system-ui, -apple-system, sans-serif'
|
|
397
|
+
}}
|
|
398
|
+
>
|
|
399
|
+
{status === 'success' ? 'Welcome back!' : status === 'error' ? 'Sign in failed' : message}
|
|
400
|
+
</p>
|
|
401
|
+
|
|
402
|
+
{userData?.email && status === 'success' && (
|
|
403
|
+
<p
|
|
404
|
+
style={{
|
|
405
|
+
fontSize: 14,
|
|
406
|
+
color: subTextColor,
|
|
407
|
+
marginTop: 8,
|
|
408
|
+
fontFamily: 'system-ui, -apple-system, sans-serif'
|
|
409
|
+
}}
|
|
410
|
+
>
|
|
411
|
+
{userData.email}
|
|
412
|
+
</p>
|
|
413
|
+
)}
|
|
414
|
+
|
|
415
|
+
{showProgress && status === 'loading' && (
|
|
416
|
+
<div
|
|
417
|
+
style={{
|
|
418
|
+
marginTop: 16,
|
|
419
|
+
width: 200,
|
|
420
|
+
height: 4,
|
|
421
|
+
backgroundColor: isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.06)',
|
|
422
|
+
borderRadius: 2,
|
|
423
|
+
overflow: 'hidden'
|
|
424
|
+
}}
|
|
425
|
+
>
|
|
426
|
+
<div
|
|
427
|
+
style={{
|
|
428
|
+
width: `${progress}%`,
|
|
429
|
+
height: '100%',
|
|
430
|
+
backgroundColor: '#2563eb',
|
|
431
|
+
borderRadius: 2,
|
|
432
|
+
transition: 'width 0.3s ease-out'
|
|
433
|
+
}}
|
|
434
|
+
/>
|
|
435
|
+
</div>
|
|
436
|
+
)}
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
<style>{`
|
|
440
|
+
@keyframes sso-spin {
|
|
441
|
+
from { transform: rotate(0deg); }
|
|
442
|
+
to { transform: rotate(360deg); }
|
|
443
|
+
}
|
|
444
|
+
@keyframes sso-fade-in {
|
|
445
|
+
from { opacity: 0; }
|
|
446
|
+
to { opacity: 1; }
|
|
447
|
+
}
|
|
448
|
+
@keyframes sso-fade-out {
|
|
449
|
+
from { opacity: 1; }
|
|
450
|
+
to { opacity: 0; }
|
|
451
|
+
}
|
|
452
|
+
@keyframes sso-pulse {
|
|
453
|
+
0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
|
|
454
|
+
50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
|
|
455
|
+
}
|
|
456
|
+
@keyframes sso-check-pop {
|
|
457
|
+
0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
|
|
458
|
+
60% { transform: translate(-50%, -50%) scale(1.2); }
|
|
459
|
+
100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
|
|
460
|
+
}
|
|
461
|
+
@keyframes sso-check-draw {
|
|
462
|
+
from { stroke-dashoffset: 24; }
|
|
463
|
+
to { stroke-dashoffset: 0; }
|
|
464
|
+
}
|
|
465
|
+
`}</style>
|
|
466
|
+
</div>
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* SSO Status Badge - Shows authentication status
|
|
472
|
+
* Can be used in navbar or profile area
|
|
473
|
+
*/
|
|
474
|
+
export function SSOStatusBadge({
|
|
475
|
+
showDetails = false,
|
|
476
|
+
theme = 'light'
|
|
477
|
+
}) {
|
|
478
|
+
const [status, setStatus] = useState(null);
|
|
479
|
+
|
|
480
|
+
useEffect(() => {
|
|
481
|
+
setStatus(getSSOStatus());
|
|
482
|
+
}, []);
|
|
483
|
+
|
|
484
|
+
if (!status) return null;
|
|
485
|
+
|
|
486
|
+
const isDark = theme === 'dark';
|
|
487
|
+
|
|
488
|
+
const statusColors = {
|
|
489
|
+
authenticated: { bg: 'rgba(34, 197, 94, 0.1)', border: '#22c55e', text: '#15803d' },
|
|
490
|
+
verifying: { bg: 'rgba(37, 99, 235, 0.1)', border: '#2563eb', text: '#1d4ed8' },
|
|
491
|
+
error: { bg: 'rgba(239, 68, 68, 0.1)', border: '#ef4444', text: '#dc2626' }
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
const currentStatus = status.hasSSO && status.tokenValid
|
|
495
|
+
? 'authenticated'
|
|
496
|
+
: status.needsVerification
|
|
497
|
+
? 'verifying'
|
|
498
|
+
: 'error';
|
|
499
|
+
|
|
500
|
+
const colors = statusColors[currentStatus];
|
|
501
|
+
|
|
502
|
+
return (
|
|
503
|
+
<div
|
|
504
|
+
style={{
|
|
505
|
+
display: 'inline-flex',
|
|
506
|
+
alignItems: 'center',
|
|
507
|
+
gap: 8,
|
|
508
|
+
padding: '6px 12px',
|
|
509
|
+
backgroundColor: colors.bg,
|
|
510
|
+
border: `1px solid ${colors.border}`,
|
|
511
|
+
borderRadius: 20,
|
|
512
|
+
fontFamily: 'system-ui, -apple-system, sans-serif'
|
|
513
|
+
}}
|
|
514
|
+
>
|
|
515
|
+
<div
|
|
516
|
+
style={{
|
|
517
|
+
width: 8,
|
|
518
|
+
height: 8,
|
|
519
|
+
borderRadius: '50%',
|
|
520
|
+
backgroundColor: colors.border,
|
|
521
|
+
animation: currentStatus === 'verifying' ? 'sso-pulse-dot 1.5s ease-in-out infinite' : 'none'
|
|
522
|
+
}}
|
|
523
|
+
/>
|
|
524
|
+
|
|
525
|
+
<span style={{ fontSize: 12, fontWeight: 500, color: colors.text }}>
|
|
526
|
+
{currentStatus === 'authenticated' ? 'Signed in' :
|
|
527
|
+
currentStatus === 'verifying' ? 'Verifying...' :
|
|
528
|
+
'Not signed in'}
|
|
529
|
+
</span>
|
|
530
|
+
|
|
531
|
+
{showDetails && status.hasSSO && (
|
|
532
|
+
<span style={{ fontSize: 11, color: isDark ? '#94a3b8' : '#64748b' }}>
|
|
533
|
+
({status.appType || 'onairos'})
|
|
534
|
+
</span>
|
|
535
|
+
)}
|
|
536
|
+
|
|
537
|
+
<style>{`
|
|
538
|
+
@keyframes sso-pulse-dot {
|
|
539
|
+
0%, 100% { opacity: 1; }
|
|
540
|
+
50% { opacity: 0.4; }
|
|
541
|
+
}
|
|
542
|
+
`}</style>
|
|
543
|
+
</div>
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* React Hook for SSO state management
|
|
549
|
+
* Use this in your app to handle SSO authentication
|
|
550
|
+
*/
|
|
551
|
+
export function useOnairosSSO(options = {}) {
|
|
552
|
+
const {
|
|
553
|
+
autoVerify = true,
|
|
554
|
+
onAuthenticated,
|
|
555
|
+
onNotAuthenticated,
|
|
556
|
+
onError
|
|
557
|
+
} = options;
|
|
558
|
+
|
|
559
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
560
|
+
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
561
|
+
const [userData, setUserData] = useState(null);
|
|
562
|
+
const [error, setError] = useState(null);
|
|
563
|
+
const [ssoStatus, setSsoStatus] = useState(null);
|
|
564
|
+
|
|
565
|
+
const checkAuth = useCallback(async () => {
|
|
566
|
+
setIsLoading(true);
|
|
567
|
+
setError(null);
|
|
568
|
+
|
|
569
|
+
try {
|
|
570
|
+
const status = getSSOStatus();
|
|
571
|
+
setSsoStatus(status);
|
|
572
|
+
|
|
573
|
+
if (!status.hasSSO) {
|
|
574
|
+
setIsAuthenticated(false);
|
|
575
|
+
setUserData(null);
|
|
576
|
+
setIsLoading(false);
|
|
577
|
+
onNotAuthenticated?.();
|
|
578
|
+
return { authenticated: false };
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (!status.needsVerification) {
|
|
582
|
+
// Use cached session
|
|
583
|
+
const session = checkSSOSession();
|
|
584
|
+
setIsAuthenticated(true);
|
|
585
|
+
setUserData(session.userData);
|
|
586
|
+
setIsLoading(false);
|
|
587
|
+
onAuthenticated?.(session.userData);
|
|
588
|
+
return { authenticated: true, userData: session.userData };
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// Need to verify
|
|
592
|
+
const result = await performAutoSSO({
|
|
593
|
+
onSuccess: (user) => {
|
|
594
|
+
setIsAuthenticated(true);
|
|
595
|
+
setUserData(user);
|
|
596
|
+
onAuthenticated?.(user);
|
|
597
|
+
},
|
|
598
|
+
onError: (err) => {
|
|
599
|
+
setError(err);
|
|
600
|
+
setIsAuthenticated(false);
|
|
601
|
+
onError?.(err);
|
|
602
|
+
},
|
|
603
|
+
onNotAuthenticated: () => {
|
|
604
|
+
setIsAuthenticated(false);
|
|
605
|
+
onNotAuthenticated?.();
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
setIsLoading(false);
|
|
610
|
+
return result;
|
|
611
|
+
} catch (e) {
|
|
612
|
+
setError(e.message);
|
|
613
|
+
setIsLoading(false);
|
|
614
|
+
onError?.(e.message);
|
|
615
|
+
return { authenticated: false, error: e.message };
|
|
616
|
+
}
|
|
617
|
+
}, [onAuthenticated, onNotAuthenticated, onError]);
|
|
618
|
+
|
|
619
|
+
useEffect(() => {
|
|
620
|
+
if (autoVerify && isOnairosApp()) {
|
|
621
|
+
checkAuth();
|
|
622
|
+
} else {
|
|
623
|
+
setIsLoading(false);
|
|
624
|
+
}
|
|
625
|
+
}, [autoVerify, checkAuth]);
|
|
626
|
+
|
|
627
|
+
return {
|
|
628
|
+
isLoading,
|
|
629
|
+
isAuthenticated,
|
|
630
|
+
userData,
|
|
631
|
+
error,
|
|
632
|
+
ssoStatus,
|
|
633
|
+
checkAuth,
|
|
634
|
+
isOnairosApp: isOnairosApp(),
|
|
635
|
+
appType: getOnairosAppType()
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export default {
|
|
640
|
+
SSOLoadingIndicator,
|
|
641
|
+
SSOFullScreenLoader,
|
|
642
|
+
SSOStatusBadge,
|
|
643
|
+
useOnairosSSO
|
|
644
|
+
};
|
|
645
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GoogleOAuthProvider } from '@react-oauth/google';
|
|
3
|
+
import OnairosButton from '../onairosButton.jsx';
|
|
4
|
+
import SdkErrorBoundary from './SdkErrorBoundary.jsx';
|
|
5
|
+
import { resolveGoogleWebClientId } from '../utils/googleWebClientId.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* OnairosTrigger
|
|
9
|
+
*
|
|
10
|
+
* Thin sugar around <Onairos> for the render-props use case. Lets host apps
|
|
11
|
+
* supply their own button/anchor/element while the SDK manages the overlay
|
|
12
|
+
* and consent flow.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* <OnairosTrigger config={{ webpageName, requestData, inputData, onComplete, apiKey }}>
|
|
16
|
+
* {({ open, isLoading, isReady, isSignedIn, isConnected, triggerLabel }) => (
|
|
17
|
+
* <button onClick={open} disabled={!isReady || isLoading} className="my-btn">
|
|
18
|
+
* {isLoading ? 'Connecting...' : (isConnected ? 'Connected' : isSignedIn ? 'Signed in' : 'Sign in with Onairos')}
|
|
19
|
+
* </button>
|
|
20
|
+
* )}
|
|
21
|
+
* </OnairosTrigger>
|
|
22
|
+
*
|
|
23
|
+
* `config` accepts every prop that <Onairos> does (requestData, inputData,
|
|
24
|
+
* onComplete, apiKey, allowedPlatforms, etc.). `children` MUST be a function.
|
|
25
|
+
*/
|
|
26
|
+
function OnairosTriggerInner({ config = {}, children }) {
|
|
27
|
+
const googleClientId = resolveGoogleWebClientId(config.googleClientId);
|
|
28
|
+
|
|
29
|
+
if (typeof children !== 'function') {
|
|
30
|
+
if (typeof console !== 'undefined') {
|
|
31
|
+
console.warn(
|
|
32
|
+
'[OnairosTrigger] `children` must be a function — received',
|
|
33
|
+
typeof children,
|
|
34
|
+
'. Falling back to default <Onairos> button.'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return (
|
|
38
|
+
<SdkErrorBoundary onError={config.onSdkError}>
|
|
39
|
+
<GoogleOAuthProvider clientId={googleClientId}>
|
|
40
|
+
<OnairosButton {...config} googleClientId={googleClientId} />
|
|
41
|
+
</GoogleOAuthProvider>
|
|
42
|
+
</SdkErrorBoundary>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<SdkErrorBoundary onError={config.onSdkError}>
|
|
48
|
+
<GoogleOAuthProvider clientId={googleClientId}>
|
|
49
|
+
<OnairosButton {...config} googleClientId={googleClientId}>
|
|
50
|
+
{children}
|
|
51
|
+
</OnairosButton>
|
|
52
|
+
</GoogleOAuthProvider>
|
|
53
|
+
</SdkErrorBoundary>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function OnairosTrigger(props) {
|
|
58
|
+
return <OnairosTriggerInner {...props} />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default OnairosTrigger;
|