@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.
Files changed (202) hide show
  1. package/CAPACITOR_QUICK_START.md +379 -0
  2. package/CONNECTORS.md +122 -0
  3. package/LICENSE +194 -10
  4. package/OnairosofficialOnairosCapacitor.podspec +13 -0
  5. package/Package.swift +26 -0
  6. package/README.md +176 -25
  7. package/dist/onairos.capacitor.esm.js +1 -0
  8. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  9. package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
  10. package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
  11. package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
  12. package/docs/CROSS_SDK_PARITY.md +239 -0
  13. package/docs/DATA_FREQUENCY.md +57 -0
  14. package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
  15. package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
  16. package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
  17. package/docs/PLATFORM_APIS.md +559 -0
  18. package/docs/RAW_MEMORIES_API.md +305 -0
  19. package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
  20. package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
  21. package/docs/oldFixes.md +216 -0
  22. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
  23. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
  24. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
  25. package/onairos.d.ts +656 -0
  26. package/package.json +188 -37
  27. package/src/OnairosReconnectButton.jsx +272 -0
  28. package/src/RSA.jsx +57 -0
  29. package/src/assets/NewLogo.png +0 -0
  30. package/src/assets/OnairosNewLogo.png +0 -0
  31. package/src/assets/chatgpt-icon.png +0 -0
  32. package/src/assets/fire-horse.png +0 -0
  33. package/src/assets/fire-horse.transparent.png +0 -0
  34. package/src/assets/latest-firehorse.png +0 -0
  35. package/src/assets/perplexity.png +0 -0
  36. package/src/assets/persona.png +0 -0
  37. package/src/assets/persona1.png +0 -0
  38. package/src/assets/persona2.png +0 -0
  39. package/src/assets/persona3.png +0 -0
  40. package/src/assets/persona4.png +0 -0
  41. package/src/assets/persona5.png +0 -0
  42. package/src/capacitorConnectorCatalog.js +38 -0
  43. package/src/capacitorOAuthConfig.js +52 -0
  44. package/src/chatgptHostedImport/index.js +303 -0
  45. package/src/components/AuthButtons.jsx +48 -0
  46. package/src/components/ConnectChatGPTModal.jsx +666 -0
  47. package/src/components/ConnectClaudeModal.jsx +610 -0
  48. package/src/components/ConnectGeminiModal.jsx +639 -0
  49. package/src/components/ConnectGrokModal.jsx +701 -0
  50. package/src/components/ConnectPerplexityModal.jsx +726 -0
  51. package/src/components/DataExplainerScreen.jsx +349 -0
  52. package/src/components/DataRequest.js +885 -0
  53. package/src/components/DataRequest.jsx +1055 -0
  54. package/src/components/EmailAuth.js +1871 -0
  55. package/src/components/EmailAuth.jsx +2062 -0
  56. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  57. package/src/components/GoogleButton.js +133 -0
  58. package/src/components/LLMConnectorManager.jsx +201 -0
  59. package/src/components/LoadingPage.jsx +19 -0
  60. package/src/components/LoadingScreen.jsx +81 -0
  61. package/src/components/LunarBirthdate.jsx +96 -0
  62. package/src/components/LunarLoadingPage.jsx +251 -0
  63. package/src/components/Notification.jsx +21 -0
  64. package/src/components/OnairosAppButton.jsx +85 -0
  65. package/src/components/OnairosSSO.jsx +645 -0
  66. package/src/components/OnairosTrigger.jsx +61 -0
  67. package/src/components/PerplexityLogo.jsx +43 -0
  68. package/src/components/PinSetup.js +200 -0
  69. package/src/components/PinSetup.jsx +228 -0
  70. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  71. package/src/components/SdkErrorBoundary.jsx +36 -0
  72. package/src/components/SecuritySetup.js +81 -0
  73. package/src/components/SessionUserBar.jsx +83 -0
  74. package/src/components/SignUp.js +123 -0
  75. package/src/components/TestTelegramButton.js +53 -0
  76. package/src/components/TrainingComponent.jsx +200 -0
  77. package/src/components/TrainingScreen.jsx +897 -0
  78. package/src/components/UniversalOnboarding.js +306 -0
  79. package/src/components/UniversalOnboarding.jsx +4837 -0
  80. package/src/components/ValentineLoadingPage.jsx +502 -0
  81. package/src/components/ValentineModeSelector.jsx +162 -0
  82. package/src/components/WelcomeScreen.jsx +435 -0
  83. package/src/components/WrappedLoadingPage.jsx +205 -0
  84. package/src/components/connectors/ChatGPTConnector.js +348 -0
  85. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  86. package/src/components/connectors/ClaudeConnector.js +44 -0
  87. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  88. package/src/components/connectors/GeminiConnector.js +170 -0
  89. package/src/components/connectors/GeminiConnector.jsx +170 -0
  90. package/src/components/connectors/GmailConnector.js +148 -0
  91. package/src/components/connectors/GmailConnector.jsx +148 -0
  92. package/src/components/connectors/GrokConnector.js +16 -0
  93. package/src/components/connectors/GrokConnector.jsx +16 -0
  94. package/src/components/connectors/HingeConnector.js +419 -0
  95. package/src/components/connectors/HingeConnector.jsx +419 -0
  96. package/src/components/connectors/InstagramDataConnector.js +726 -0
  97. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  98. package/src/components/connectors/LinkedInConnector.js +4 -0
  99. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  100. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  101. package/src/components/connectors/PinterestConnector.js +208 -0
  102. package/src/components/connectors/PinterestConnector.jsx +208 -0
  103. package/src/components/connectors/README.md +292 -0
  104. package/src/components/connectors/RedditConnector.js +229 -0
  105. package/src/components/connectors/RedditConnector.jsx +229 -0
  106. package/src/components/connectors/SephoraConnector.js +482 -0
  107. package/src/components/connectors/SephoraConnector.jsx +482 -0
  108. package/src/components/connectors/TikTokConnector.jsx +430 -0
  109. package/src/components/connectors/YoutubeConnector.js +361 -0
  110. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  111. package/src/components/connectors/index.js +50 -0
  112. package/src/components/icons.jsx +46 -0
  113. package/src/components/icons.tsx +21 -0
  114. package/src/components/ui/PageLayout.jsx +1255 -0
  115. package/src/components/ui/PrimaryButton.jsx +162 -0
  116. package/src/components/ui/button.jsx +49 -0
  117. package/src/components/ui/card.jsx +61 -0
  118. package/src/components/ui/checkbox.jsx +33 -0
  119. package/src/components/ui/label.jsx +29 -0
  120. package/src/components/utils/UpdateConnections.js +45 -0
  121. package/src/components/utils/oauthHelper.js +97 -0
  122. package/src/config/api-config.js +138 -0
  123. package/src/deepLink.jsx +38 -0
  124. package/src/getPin.js +26 -0
  125. package/src/icons/Avatar.png +0 -0
  126. package/src/icons/Sentiment.png +0 -0
  127. package/src/icons/Trait.png +0 -0
  128. package/src/iframe/DataRequestPage.jsx +285 -0
  129. package/src/iframe/OnairosButtonIntegration.md +148 -0
  130. package/src/iframe/components/Box.jsx +56 -0
  131. package/src/iframe/components/IndividualConnection.jsx +88 -0
  132. package/src/iframe/dataRequestHandler.js +714 -0
  133. package/src/iframe/data_request_iframe.html +27 -0
  134. package/src/iframe/data_request_page.js +47 -0
  135. package/src/iframe/icons/Avatar.png +1 -0
  136. package/src/iframe/icons/Avatar2.png +1 -0
  137. package/src/iframe/icons/Sentiment.png +1 -0
  138. package/src/iframe/icons/Trait.png +1 -0
  139. package/src/iframe/icons/onairos_logo.png +0 -0
  140. package/src/iframe/utils/api.js +57 -0
  141. package/src/index.js +274 -0
  142. package/src/laravel/OnairosVue.vue +410 -0
  143. package/src/laravel/blade-helpers.js +320 -0
  144. package/src/laravel/vite-plugin.js +179 -0
  145. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  146. package/src/mobile/components/MobileBox.jsx +71 -0
  147. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  148. package/src/mobile/shims/browser-apis.js +78 -0
  149. package/src/mobile/shims/lucide-shim.js +85 -0
  150. package/src/nativeConnectors.js +5 -0
  151. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  152. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  153. package/src/newUI/PrimaryButton.tsx +213 -0
  154. package/src/newUI/SignInStep.tsx +194 -0
  155. package/src/newUI/VerificationStep.tsx +133 -0
  156. package/src/newUI/WelcomeScreen.tsx +311 -0
  157. package/src/newUI/services/connectedAccountsService.js +129 -0
  158. package/src/onairos.capacitor.jsx +15 -0
  159. package/src/onairos.core.jsx +133 -0
  160. package/src/onairos.jsx +14 -0
  161. package/src/onairos.native.jsx +15 -0
  162. package/src/onairosButton.jsx +9000 -0
  163. package/src/overlay/CheckBox.jsx +114 -0
  164. package/src/overlay/IndividualConnection copy.js +86 -0
  165. package/src/overlay/IndividualConnection.js +191 -0
  166. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  167. package/src/overlay/box.js +84 -0
  168. package/src/overlay/overlay.js +437 -0
  169. package/src/styles/onairos-scoped-preflight.css +97 -0
  170. package/src/styles/sdkCssRegistry.js +20 -0
  171. package/src/styles/styleLoaderInsertShadow.js +69 -0
  172. package/src/styles/tailwind.capacitor.css +395 -0
  173. package/src/styles/tailwind.css +395 -0
  174. package/src/theme/colors.js +40 -0
  175. package/src/utils/apiKeyValidation.js +341 -0
  176. package/src/utils/apiResponseLogger.js +316 -0
  177. package/src/utils/authHeaders.js +275 -0
  178. package/src/utils/biometrics.js +26 -0
  179. package/src/utils/bookmarkletUtils.js +28 -0
  180. package/src/utils/capacitorDetection.js +278 -0
  181. package/src/utils/capacitorLLMHelper.js +352 -0
  182. package/src/utils/capacitorPlugins.js +366 -0
  183. package/src/utils/crossDomainSSO.js +587 -0
  184. package/src/utils/deepLinking.js +27 -0
  185. package/src/utils/devLogger.js +46 -0
  186. package/src/utils/extensionDetection.js +418 -0
  187. package/src/utils/extractMemory.js +277 -0
  188. package/src/utils/framerBrandingOverrides.js +40 -0
  189. package/src/utils/googleWebClientId.js +55 -0
  190. package/src/utils/overlayHandler.js +224 -0
  191. package/src/utils/platformDisconnect.js +309 -0
  192. package/src/utils/pollTrainingStatus.js +200 -0
  193. package/src/utils/rawMemoriesAccess.js +211 -0
  194. package/src/utils/resolveBackendAppId.js +47 -0
  195. package/src/utils/responseFormatter.js +140 -0
  196. package/src/utils/sdkDebugStorage.js +113 -0
  197. package/src/utils/sdkInitialization.js +645 -0
  198. package/src/utils/sessionManager.js +1258 -0
  199. package/src/utils/startBackgroundTraining.js +100 -0
  200. package/src/utils/userDataFormatter.js +222 -0
  201. package/index.d.ts +0 -1
  202. package/index.js +0 -1
@@ -0,0 +1,251 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import Lottie from 'lottie-react';
3
+
4
+ export default function LunarLoadingPage({ appName, isComplete = false, onTransitionComplete, errorMessage, onBack, onRetry }) {
5
+ const [animationData, setAnimationData] = useState(null);
6
+ const [progress, setProgress] = useState(0);
7
+ const [messageIndex, setMessageIndex] = useState(0);
8
+ const [isAnimatingToComplete, setIsAnimatingToComplete] = useState(false);
9
+ const [autoRetryStatus, setAutoRetryStatus] = useState(null); // { attempt: number, inMs: number } | null
10
+ const autoRetryRef = useRef({ attempts: 0, timer: null });
11
+
12
+ const messages = [
13
+ 'Consulting the lunar calendar…',
14
+ 'Calculating your zodiac animal…',
15
+ 'Reading your data footprint…',
16
+ 'Aligning cosmic signals…',
17
+ 'Preparing your Lunar report…',
18
+ ];
19
+
20
+ useEffect(() => {
21
+ fetch('/rain-anim.json')
22
+ .then((res) => {
23
+ if (!res.ok) throw new Error('Failed to fetch local animation');
24
+ return res.json();
25
+ })
26
+ .then((data) => setAnimationData(data))
27
+ .catch(() => {
28
+ fetch('https://onairos.sirv.com/rain-anim.json')
29
+ .then((res) => res.json())
30
+ .then((data) => setAnimationData(data))
31
+ .catch(() => {});
32
+ });
33
+ }, []);
34
+
35
+ useEffect(() => {
36
+ if (isAnimatingToComplete) return;
37
+ const duration = 90000; // 90s
38
+ const interval = 100;
39
+ const increment = (interval / duration) * 100;
40
+ const timer = setInterval(() => {
41
+ setProgress((prev) => {
42
+ const next = prev + increment;
43
+ return next >= 95 ? 95 : next;
44
+ });
45
+ }, interval);
46
+ return () => clearInterval(timer);
47
+ }, [isAnimatingToComplete]);
48
+
49
+ useEffect(() => {
50
+ if (!isComplete || isAnimatingToComplete) return;
51
+ setIsAnimatingToComplete(true);
52
+ const startProgress = progress;
53
+ const duration = 500;
54
+ const startTime = Date.now();
55
+ const animateToComplete = () => {
56
+ const elapsed = Date.now() - startTime;
57
+ const t = Math.min(elapsed / duration, 1);
58
+ const eased = 1 - Math.pow(1 - t, 3);
59
+ const currentProgress = startProgress + (100 - startProgress) * eased;
60
+ setProgress(currentProgress);
61
+ if (t < 1) requestAnimationFrame(animateToComplete);
62
+ else {
63
+ setTimeout(() => onTransitionComplete?.(), 200);
64
+ }
65
+ };
66
+ requestAnimationFrame(animateToComplete);
67
+ }, [isComplete, isAnimatingToComplete, progress, onTransitionComplete]);
68
+
69
+ useEffect(() => {
70
+ const messageTimer = setInterval(() => {
71
+ setMessageIndex((prev) => (prev + 1) % messages.length);
72
+ }, 4000);
73
+ return () => clearInterval(messageTimer);
74
+ }, []);
75
+
76
+ // Auto-retry transient network failures so users don't get stuck on a stale error panel
77
+ // when the backend becomes reachable moments later.
78
+ useEffect(() => {
79
+ // Clear any pending timer on changes/unmount.
80
+ if (autoRetryRef.current.timer) {
81
+ clearTimeout(autoRetryRef.current.timer);
82
+ autoRetryRef.current.timer = null;
83
+ }
84
+
85
+ // Reset status when there's no error or we're done.
86
+ if (!errorMessage || isComplete) {
87
+ autoRetryRef.current.attempts = 0;
88
+ setAutoRetryStatus(null);
89
+ return;
90
+ }
91
+
92
+ if (typeof onRetry !== 'function') return;
93
+
94
+ const msg = String(errorMessage || '');
95
+ const isTransient =
96
+ /Failed to fetch|NetworkError|Load failed|TypeError/i.test(msg) &&
97
+ !/CORS/i.test(msg);
98
+ if (!isTransient) {
99
+ autoRetryRef.current.attempts = 0;
100
+ setAutoRetryStatus(null);
101
+ return;
102
+ }
103
+
104
+ const MAX_AUTO_RETRIES = 4;
105
+ const attempt = autoRetryRef.current.attempts + 1;
106
+ if (attempt > MAX_AUTO_RETRIES) {
107
+ setAutoRetryStatus(null);
108
+ return;
109
+ }
110
+
111
+ const delays = [1500, 3000, 6000, 10000];
112
+ const inMs = delays[Math.min(attempt - 1, delays.length - 1)];
113
+ autoRetryRef.current.attempts = attempt;
114
+ setAutoRetryStatus({ attempt, inMs });
115
+
116
+ autoRetryRef.current.timer = setTimeout(() => {
117
+ try {
118
+ onRetry();
119
+ } catch (_) {}
120
+ }, inMs);
121
+
122
+ return () => {
123
+ if (autoRetryRef.current.timer) {
124
+ clearTimeout(autoRetryRef.current.timer);
125
+ autoRetryRef.current.timer = null;
126
+ }
127
+ };
128
+ }, [errorMessage, isComplete, onRetry]);
129
+
130
+ return (
131
+ <div className="flex flex-col items-center justify-center h-full px-4 py-4 md:px-6 overflow-hidden" style={{ backgroundColor: '#ffffff' }}>
132
+ <div className="flex flex-col items-center justify-center w-full max-w-2xl space-y-2 md:space-y-4 h-full max-h-[600px]">
133
+ <div className="text-center flex-shrink-0 mt-0">
134
+ <h2 className="text-lg md:text-2xl font-bold mb-1" style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#b45309' }}>
135
+ Preparing your Lunar report 🧧
136
+ </h2>
137
+ <p className="text-xs md:text-sm px-4 font-medium" style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e' }}>
138
+ Generating your personalized slides for {appName || 'Onairos Lunar'}
139
+ </p>
140
+ </div>
141
+
142
+ {animationData ? (
143
+ <div className="w-full max-w-[200px] md:max-w-[260px] mx-auto flex-shrink-1 min-h-0 aspect-square flex items-center justify-center">
144
+ <div style={{ filter: 'hue-rotate(20deg) saturate(1.2)', width: '100%', height: '100%' }}>
145
+ <Lottie animationData={animationData} loop autoplay style={{ width: '100%', height: '100%' }} />
146
+ </div>
147
+ </div>
148
+ ) : (
149
+ <div className="w-full max-w-sm h-32 md:h-48 flex items-center justify-center flex-shrink-0">
150
+ <div className="animate-spin rounded-full h-12 w-12 border-b-4" style={{ borderColor: '#b45309' }} />
151
+ </div>
152
+ )}
153
+
154
+ <div className="w-full max-w-md px-2 flex-shrink-0">
155
+ {/* If we’ve completed, never show the error panel (it can be stale from a transient fetch failure). */}
156
+ {!!errorMessage && !isComplete && (
157
+ <div className="w-full mb-4 rounded-xl border border-amber-200 bg-amber-50 p-3">
158
+ <div className="text-sm font-semibold" style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e' }}>
159
+ Couldn’t reach the Lunar backend
160
+ </div>
161
+ <div className="text-xs mt-1" style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e' }}>
162
+ {errorMessage}
163
+ </div>
164
+ {!!autoRetryStatus && (
165
+ <div className="text-[11px] mt-2" style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e' }}>
166
+ Reconnecting automatically… (attempt {autoRetryStatus.attempt}/4)
167
+ </div>
168
+ )}
169
+ <div className="flex gap-2 mt-3">
170
+ {typeof onBack === 'function' && (
171
+ <button
172
+ type="button"
173
+ onClick={onBack}
174
+ className="px-3 py-2 rounded-lg border border-amber-300 bg-white text-xs font-semibold"
175
+ style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e' }}
176
+ >
177
+ Back
178
+ </button>
179
+ )}
180
+ {typeof onRetry === 'function' && (
181
+ <button
182
+ type="button"
183
+ onClick={onRetry}
184
+ className="px-3 py-2 rounded-lg text-xs font-semibold"
185
+ style={{ fontFamily: 'Inter, system-ui, sans-serif', backgroundColor: '#b45309', color: 'white' }}
186
+ >
187
+ Retry
188
+ </button>
189
+ )}
190
+ </div>
191
+ </div>
192
+ )}
193
+ <div className="flex justify-between text-[11px] font-semibold mb-2 px-1" style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e' }}>
194
+ <span>Generating…</span>
195
+ <span>{Math.round(progress)}%</span>
196
+ </div>
197
+
198
+ <div className="relative w-full">
199
+ <img
200
+ src="/latest-firehorse.png"
201
+ onError={(e) => { e.currentTarget.src = 'https://anushkasirv.sirv.com/latest-firehorse.png'; }}
202
+ className="absolute bottom-3 transition-all duration-300 ease-out"
203
+ style={{
204
+ left: `${progress}%`,
205
+ transform: 'translateX(-50%)',
206
+ width: '64px',
207
+ height: 'auto',
208
+ zIndex: 10
209
+ }}
210
+ alt=""
211
+ />
212
+ <div className="relative w-full h-4 overflow-hidden rounded-full" style={{ backgroundColor: '#fef3c7', boxShadow: 'inset 0 0 0 1px rgba(146,64,14,0.2)' }}>
213
+ <div
214
+ className="absolute top-0 left-0 h-full transition-all duration-300 ease-out"
215
+ style={{ width: `${progress}%`, backgroundColor: '#b45309' }}
216
+ >
217
+ <div className="w-full h-full absolute inset-0 bg-white/20 animate-pulse" />
218
+ </div>
219
+ </div>
220
+ </div>
221
+
222
+ <div className="h-8 mt-3 flex items-center justify-center">
223
+ <p
224
+ key={messageIndex}
225
+ className="text-center text-sm font-medium"
226
+ style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e', animation: 'fadeIn 0.5s ease-in-out' }}
227
+ >
228
+ {messages[messageIndex]}
229
+ </p>
230
+ </div>
231
+
232
+ <div className="mt-5 flex flex-col items-center gap-1.5 max-w-sm mx-auto">
233
+ <div className="h-px w-12 bg-gradient-to-r from-transparent via-amber-300 to-transparent mb-1.5" />
234
+ <p className="text-xs text-center leading-relaxed font-medium" style={{ fontFamily: 'Inter, system-ui, sans-serif', color: '#92400e' }}>
235
+ This can take 1–3 minutes.
236
+ </p>
237
+ </div>
238
+ </div>
239
+
240
+ <style>{`
241
+ @keyframes fadeIn {
242
+ 0% { opacity: 0; transform: translateY(-4px); }
243
+ 100% { opacity: 1; transform: translateY(0); }
244
+ }
245
+ `}</style>
246
+ </div>
247
+ </div>
248
+ );
249
+ }
250
+
251
+
@@ -0,0 +1,21 @@
1
+ import React, {useState, useEffect } from 'react';
2
+
3
+ export default function Notification({ message, color=null, again=false }) {
4
+ const [show, setShow] = useState(true);
5
+ useEffect(() => {
6
+ setShow(true); // Show notification again when `again` changes
7
+ const timer = setTimeout(() => {
8
+ setShow(false);
9
+ }, 5000);
10
+
11
+ // Clear timeout if the component unmounts or `again` changes
12
+ return () => clearTimeout(timer);
13
+ }, [again]); // Dependency array includes `again` so it resets when the prop changes
14
+
15
+ return (
16
+ show &&
17
+ <div className={`fixed top-0 left-1/2 transform -translate-x-1/2 text-white px-4 py-2 rounded-b-md shadow-lg z-[2147483647] text-center ${color == null ? 'bg-red-600' : `bg-${color}-600`}`}>
18
+ {message}
19
+ </div>
20
+ );
21
+ }
@@ -0,0 +1,85 @@
1
+ import { useState } from 'react';
2
+ import { authenticateWithBiometrics } from '../utils/biometrics.js';
3
+ import { getApiBaseUrl } from '../config/api-config.js';
4
+
5
+ export default function OnairosAppButton({ onLoginSuccess }) {
6
+ const [loading, setLoading] = useState(false);
7
+
8
+ const verifySavedCredentials = async () => {
9
+ const savedCredentials = localStorage.getItem('onairosCredentials');
10
+ if (!savedCredentials) return null;
11
+
12
+ try {
13
+ const credentials = JSON.parse(savedCredentials);
14
+ const response = await fetch(`${getApiBaseUrl()}/verify`, {
15
+ method: 'POST',
16
+ headers: {
17
+ 'Content-Type': 'application/json',
18
+ },
19
+ body: JSON.stringify({
20
+ username: credentials.username,
21
+ token: credentials.token
22
+ })
23
+ });
24
+
25
+ if (!response.ok) {
26
+ localStorage.removeItem('onairosCredentials');
27
+ return null;
28
+ }
29
+
30
+ return credentials;
31
+ } catch (error) {
32
+ console.error('Verification failed:', error);
33
+ return null;
34
+ }
35
+ };
36
+
37
+ const handleAppLogin = async () => {
38
+ setLoading(true);
39
+ try {
40
+ const credentials = await verifySavedCredentials();
41
+
42
+ if (credentials) {
43
+ const isAuthenticated = await authenticateWithBiometrics();
44
+ if (isAuthenticated) {
45
+ await onLoginSuccess(credentials.username);
46
+ return;
47
+ }
48
+ }
49
+
50
+ // If no credentials or biometrics failed, launch app
51
+ const nonce = Date.now();
52
+ const returnLink = encodeURIComponent(window.location.origin + '/auth/callback');
53
+ const onairosUrl = `onairos://authenticate?nonce=${nonce}&callback=${returnLink}&appName=google`;
54
+
55
+ window.location.href = onairosUrl;
56
+
57
+ // Fallback to app store after timeout
58
+ setTimeout(() => {
59
+ window.location.href = 'https://apps.apple.com/app/onairos/id123456789';
60
+ }, 2500);
61
+
62
+ } catch (error) {
63
+ console.error('App login failed:', error);
64
+ } finally {
65
+ setLoading(false);
66
+ }
67
+ };
68
+
69
+ return (
70
+ <div className="flex flex-col items-center">
71
+ <button
72
+ onClick={handleAppLogin}
73
+ disabled={loading}
74
+ className="w-12 h-12 rounded-full shadow-md hover:shadow-lg transition-shadow duration-200 flex items-center justify-center bg-white"
75
+ >
76
+ <img
77
+ src="https://onairos.sirv.com/Images/OnairosBlack.png"
78
+ alt="Onairos"
79
+ className="w-10 h-6"
80
+ />
81
+ </button>
82
+ <span className="text-xs mt-2 text-gray-600">Login with App</span>
83
+ </div>
84
+ );
85
+ }