@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,162 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { COLORS } from '../../theme/colors.js';
|
|
3
|
+
|
|
4
|
+
// Icon Circle component matching the React Native version
|
|
5
|
+
const IconCircle = ({
|
|
6
|
+
size = 40,
|
|
7
|
+
children,
|
|
8
|
+
className = ''
|
|
9
|
+
}) => {
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
className={`relative flex items-center justify-center border border-black border-opacity-25 ${className}`}
|
|
13
|
+
style={{
|
|
14
|
+
width: size,
|
|
15
|
+
height: size,
|
|
16
|
+
borderRadius: size / 2,
|
|
17
|
+
background: `linear-gradient(to bottom, ${COLORS.iconCircleGradientStart}, ${COLORS.iconCircleGradientEnd})`
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
20
|
+
{children || (
|
|
21
|
+
<span
|
|
22
|
+
className="font-semibold opacity-95"
|
|
23
|
+
style={{
|
|
24
|
+
fontSize: '20px',
|
|
25
|
+
color: COLORS.btnLabel,
|
|
26
|
+
backgroundColor: 'transparent',
|
|
27
|
+
fontFamily: 'Inter, system-ui, sans-serif'
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
→
|
|
31
|
+
</span>
|
|
32
|
+
)}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Primary Button component matching the React Native design
|
|
38
|
+
const PrimaryButton = ({
|
|
39
|
+
label = "Get Started",
|
|
40
|
+
onClick,
|
|
41
|
+
iconRight,
|
|
42
|
+
loading = false,
|
|
43
|
+
disabled = false,
|
|
44
|
+
testId,
|
|
45
|
+
className = '',
|
|
46
|
+
style = {},
|
|
47
|
+
textStyle = {},
|
|
48
|
+
centered = false,
|
|
49
|
+
...props
|
|
50
|
+
}) => {
|
|
51
|
+
const [pressed, setPressed] = useState(false);
|
|
52
|
+
|
|
53
|
+
const handleMouseDown = () => setPressed(true);
|
|
54
|
+
const handleMouseUp = () => setPressed(false);
|
|
55
|
+
const handleMouseLeave = () => setPressed(false);
|
|
56
|
+
|
|
57
|
+
const buttonStyle = {
|
|
58
|
+
height: '48px',
|
|
59
|
+
borderRadius: '100px',
|
|
60
|
+
border: `1px solid ${COLORS.btnBorder}`,
|
|
61
|
+
background: `linear-gradient(to bottom, ${COLORS.btnGradStart}, ${COLORS.btnGradEnd})`,
|
|
62
|
+
backgroundColor: COLORS.btnGradEnd, // fallback if gradients are stripped
|
|
63
|
+
position: 'relative',
|
|
64
|
+
overflow: 'hidden',
|
|
65
|
+
width: centered ? 'auto' : '100%',
|
|
66
|
+
minWidth: centered ? '250px' : 'auto',
|
|
67
|
+
maxWidth: centered ? '350px' : 'none',
|
|
68
|
+
margin: centered ? '0 auto' : '0',
|
|
69
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
70
|
+
opacity: disabled ? 0.65 : 1,
|
|
71
|
+
boxShadow: disabled ? 'none' : '20px 30px 40px rgba(0,0,0,0.10)',
|
|
72
|
+
transition: 'all 0.2s ease',
|
|
73
|
+
appearance: 'none',
|
|
74
|
+
WebkitAppearance: 'none',
|
|
75
|
+
...style
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const pressedOverlayStyle = {
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
top: 0,
|
|
81
|
+
left: 0,
|
|
82
|
+
right: 0,
|
|
83
|
+
bottom: 0,
|
|
84
|
+
backgroundColor: 'rgba(0,0,0,0.1)',
|
|
85
|
+
borderRadius: '100px',
|
|
86
|
+
opacity: pressed ? 1 : 0,
|
|
87
|
+
transition: 'opacity 0.1s ease'
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const textContainerStyle = {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
left: 0,
|
|
93
|
+
right: 0,
|
|
94
|
+
top: 0,
|
|
95
|
+
bottom: 0,
|
|
96
|
+
display: 'flex',
|
|
97
|
+
justifyContent: 'center',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
backgroundColor: 'transparent'
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const iconPositionStyle = {
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
right: '4px',
|
|
105
|
+
top: '4px',
|
|
106
|
+
bottom: '4px',
|
|
107
|
+
width: '40px',
|
|
108
|
+
display: 'flex',
|
|
109
|
+
justifyContent: 'center',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
backgroundColor: 'transparent'
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const labelStyle = {
|
|
115
|
+
fontFamily: 'Inter, system-ui, sans-serif',
|
|
116
|
+
fontWeight: '600',
|
|
117
|
+
fontSize: '16px',
|
|
118
|
+
color: COLORS.btnLabel,
|
|
119
|
+
WebkitTextFillColor: COLORS.btnLabel,
|
|
120
|
+
textAlign: 'center',
|
|
121
|
+
backgroundColor: 'transparent',
|
|
122
|
+
...textStyle
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<button
|
|
127
|
+
className={`relative ${className}`}
|
|
128
|
+
style={buttonStyle}
|
|
129
|
+
onClick={onClick}
|
|
130
|
+
onMouseDown={handleMouseDown}
|
|
131
|
+
onMouseUp={handleMouseUp}
|
|
132
|
+
onMouseLeave={handleMouseLeave}
|
|
133
|
+
disabled={disabled || loading}
|
|
134
|
+
data-testid={testId}
|
|
135
|
+
aria-label={label}
|
|
136
|
+
{...props}
|
|
137
|
+
>
|
|
138
|
+
{/* Pressed state overlay */}
|
|
139
|
+
<div style={pressedOverlayStyle} />
|
|
140
|
+
|
|
141
|
+
{/* Centered text container */}
|
|
142
|
+
<div style={textContainerStyle}>
|
|
143
|
+
{loading ? (
|
|
144
|
+
<div
|
|
145
|
+
className="animate-spin rounded-full border-2 border-white border-t-transparent"
|
|
146
|
+
style={{ width: '20px', height: '20px' }}
|
|
147
|
+
/>
|
|
148
|
+
) : (
|
|
149
|
+
<span style={labelStyle}>{label}</span>
|
|
150
|
+
)}
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
{/* Icon in fixed position on right */}
|
|
154
|
+
<div style={iconPositionStyle}>
|
|
155
|
+
{!loading && (iconRight || <IconCircle />)}
|
|
156
|
+
</div>
|
|
157
|
+
</button>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export { IconCircle };
|
|
162
|
+
export default PrimaryButton;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Button Component
|
|
5
|
+
* A customizable button component with various style variants
|
|
6
|
+
*/
|
|
7
|
+
export function Button({
|
|
8
|
+
children,
|
|
9
|
+
className = '',
|
|
10
|
+
variant = 'default',
|
|
11
|
+
size = 'default',
|
|
12
|
+
onClick,
|
|
13
|
+
disabled = false,
|
|
14
|
+
...props
|
|
15
|
+
}) {
|
|
16
|
+
// Base classes
|
|
17
|
+
const baseClasses = 'inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none';
|
|
18
|
+
|
|
19
|
+
// Size classes
|
|
20
|
+
const sizeClasses = {
|
|
21
|
+
default: 'h-10 py-2 px-4',
|
|
22
|
+
sm: 'h-9 px-3',
|
|
23
|
+
lg: 'h-11 px-8',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Variant classes
|
|
27
|
+
const variantClasses = {
|
|
28
|
+
default: 'bg-black text-white hover:bg-black/90',
|
|
29
|
+
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
30
|
+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
31
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
32
|
+
link: 'underline-offset-4 hover:underline text-primary',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const classes = `${baseClasses} ${sizeClasses[size]} ${variantClasses[variant]} ${className}`;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<button
|
|
39
|
+
className={classes}
|
|
40
|
+
onClick={onClick}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</button>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default Button;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Card Component
|
|
5
|
+
* A container component with various parts for creating card-based UIs
|
|
6
|
+
*/
|
|
7
|
+
export function Card({ className = '', ...props }) {
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
className={`rounded-lg border bg-card text-card-foreground shadow-sm ${className}`}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function CardHeader({ className = '', ...props }) {
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
className={`flex flex-col space-y-1.5 p-6 ${className}`}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function CardTitle({ className = '', ...props }) {
|
|
26
|
+
return (
|
|
27
|
+
<h3
|
|
28
|
+
className={`text-lg font-semibold leading-none tracking-tight ${className}`}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function CardDescription({ className = '', ...props }) {
|
|
35
|
+
return (
|
|
36
|
+
<p
|
|
37
|
+
className={`text-sm text-muted-foreground ${className}`}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function CardContent({ className = '', ...props }) {
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={`p-6 pt-0 ${className}`}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function CardFooter({ className = '', ...props }) {
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
className={`flex items-center p-6 pt-0 ${className}`}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default Card;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checkbox Component
|
|
5
|
+
* A customizable checkbox component
|
|
6
|
+
*/
|
|
7
|
+
export function Checkbox({
|
|
8
|
+
id,
|
|
9
|
+
className = '',
|
|
10
|
+
checked,
|
|
11
|
+
onCheckedChange,
|
|
12
|
+
disabled = false,
|
|
13
|
+
...props
|
|
14
|
+
}) {
|
|
15
|
+
// Base classes
|
|
16
|
+
const baseClasses = 'peer h-4 w-4 shrink-0 rounded-sm border border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground';
|
|
17
|
+
|
|
18
|
+
const classes = `${baseClasses} ${className}`;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<input
|
|
22
|
+
type="checkbox"
|
|
23
|
+
id={id}
|
|
24
|
+
className={classes}
|
|
25
|
+
checked={checked}
|
|
26
|
+
onChange={(e) => onCheckedChange(e.target.checked)}
|
|
27
|
+
disabled={disabled}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default Checkbox;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Label Component
|
|
5
|
+
* A customizable label component for form elements
|
|
6
|
+
*/
|
|
7
|
+
export function Label({
|
|
8
|
+
htmlFor,
|
|
9
|
+
children,
|
|
10
|
+
className = '',
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
// Base classes
|
|
14
|
+
const baseClasses = 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70';
|
|
15
|
+
|
|
16
|
+
const classes = `${baseClasses} ${className}`;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<label
|
|
20
|
+
htmlFor={htmlFor}
|
|
21
|
+
className={classes}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</label>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default Label;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UpdateConnections Utility
|
|
3
|
+
* Handles adding and removing user connections to/from the Onairos server
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { getApiBaseUrl } from '../../config/api-config.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Update user connections on the Onairos server
|
|
10
|
+
* @param {Object} options - Update options
|
|
11
|
+
* @param {string} options.updateType - 'Add' or 'Remove'
|
|
12
|
+
* @param {string} options.newConnection - The connection name to add/remove
|
|
13
|
+
* @param {string} options.username - Username (optional, will use localStorage if not provided)
|
|
14
|
+
* @returns {Promise} - Promise resolving with the server response
|
|
15
|
+
*/
|
|
16
|
+
export default async function UpdateConnections({ updateType, newConnection, username = null }) {
|
|
17
|
+
const jsonData = {
|
|
18
|
+
session: {
|
|
19
|
+
username: username || localStorage.getItem("username")
|
|
20
|
+
},
|
|
21
|
+
updateType,
|
|
22
|
+
newConnection
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const response = await fetch(`${getApiBaseUrl()}/connections/update`, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify(jsonData),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const result = await response.json();
|
|
39
|
+
console.log(`UpdateConnections: ${updateType} ${newConnection}`, result);
|
|
40
|
+
return result;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('UpdateConnections error:', error);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Helper Functions
|
|
3
|
+
* Provides utility functions for OAuth authentication
|
|
4
|
+
* Compatible with both web and React Native environments
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Detect the runtime environment (React Native or Web)
|
|
9
|
+
* @returns {boolean} True if running in React Native
|
|
10
|
+
*/
|
|
11
|
+
export const isReactNative = () => {
|
|
12
|
+
return typeof global !== 'undefined' && global.nativeModuleProxy !== undefined ||
|
|
13
|
+
typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create OAuth authorization window
|
|
18
|
+
* @param {string} url - OAuth URL to open
|
|
19
|
+
* @param {Object} options - Options for the OAuth window
|
|
20
|
+
* @returns {Promise} - Promise resolving with the auth result
|
|
21
|
+
*/
|
|
22
|
+
export const createOAuthWindow = (url, options = {}) => {
|
|
23
|
+
return openAuthWindow(url, options);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Open OAuth authorization window
|
|
28
|
+
* Handles differences between web and React Native
|
|
29
|
+
* @param {string} url - OAuth URL to open
|
|
30
|
+
* @param {Object} options - Options for the OAuth window
|
|
31
|
+
* @returns {Promise} - Promise resolving with the auth result
|
|
32
|
+
*/
|
|
33
|
+
export const openAuthWindow = (url, options = {}) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
if (isReactNative()) {
|
|
36
|
+
// For React Native, we would typically use Linking API
|
|
37
|
+
// This is a placeholder - in real implementation, you would use
|
|
38
|
+
// react-native's Linking or a library like react-native-app-auth
|
|
39
|
+
console.log("OAuth in React Native environment would open:", url);
|
|
40
|
+
|
|
41
|
+
// Mock successful authentication for testing
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
resolve({
|
|
44
|
+
success: true,
|
|
45
|
+
token: 'mock-oauth-token-for-react-native'
|
|
46
|
+
});
|
|
47
|
+
}, 1000);
|
|
48
|
+
} else {
|
|
49
|
+
// Web implementation
|
|
50
|
+
const width = options.width || 600;
|
|
51
|
+
const height = options.height || 700;
|
|
52
|
+
const left = window.screen.width / 2 - width / 2;
|
|
53
|
+
const top = window.screen.height / 2 - height / 2;
|
|
54
|
+
|
|
55
|
+
const authWindow = window.open(
|
|
56
|
+
url,
|
|
57
|
+
'Auth Window',
|
|
58
|
+
`width=${width},height=${height},top=${top},left=${left}`
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// This would be implemented with message listeners in a real app
|
|
62
|
+
if (!authWindow) {
|
|
63
|
+
reject(new Error('Could not open auth window'));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Mock auth for testing
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
resolve({
|
|
69
|
+
success: true,
|
|
70
|
+
token: 'mock-oauth-token-for-web'
|
|
71
|
+
});
|
|
72
|
+
}, 1000);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Handle OAuth callback
|
|
79
|
+
* @param {string} url - Callback URL with auth parameters
|
|
80
|
+
* @returns {Object} - Parsed auth result
|
|
81
|
+
*/
|
|
82
|
+
export const handleOAuthCallback = (url) => {
|
|
83
|
+
// Parse URL parameters to extract token, etc.
|
|
84
|
+
const params = new URLSearchParams(url.split('?')[1]);
|
|
85
|
+
return {
|
|
86
|
+
token: params.get('token') || 'mock-token',
|
|
87
|
+
state: params.get('state'),
|
|
88
|
+
error: params.get('error')
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default {
|
|
93
|
+
isReactNative,
|
|
94
|
+
openAuthWindow,
|
|
95
|
+
createOAuthWindow,
|
|
96
|
+
handleOAuthCallback
|
|
97
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Configuration for Onairos
|
|
3
|
+
* Centralized configuration for API endpoints
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: All API calls should use getApiBaseUrl() from this file
|
|
6
|
+
* to ensure proper routing for internship.onairos.uk -> api2.onairos.uk
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// SSR-safe window check
|
|
10
|
+
const isBrowser = typeof window !== 'undefined';
|
|
11
|
+
|
|
12
|
+
// Environment detection (SSR-safe)
|
|
13
|
+
const getIsDevelopment = () => {
|
|
14
|
+
if (!isBrowser) return false;
|
|
15
|
+
return window.location.hostname === 'localhost' ||
|
|
16
|
+
window.location.hostname === '127.0.0.1' ||
|
|
17
|
+
window.location.port === '3000' ||
|
|
18
|
+
window.location.port === '5173' ||
|
|
19
|
+
window.location.port === '8080';
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Internship demo detection - uses configured API host
|
|
23
|
+
// Routes all requests to api2.onairos.uk when on internship.onairos.uk domain
|
|
24
|
+
const getIsInternshipDemo = () => {
|
|
25
|
+
if (!isBrowser) return false;
|
|
26
|
+
return window.location.hostname === 'internship.onairos.uk';
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Allow override via environment variable or window object
|
|
30
|
+
const getForceProduction = () => {
|
|
31
|
+
if (!isBrowser) return false;
|
|
32
|
+
return window.ONAIROS_FORCE_PRODUCTION ||
|
|
33
|
+
(typeof process !== 'undefined' && process.env?.VITE_ONAIROS_FORCE_PRODUCTION === 'true');
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Allow host apps to override the SDK base URL at runtime before bootstrap.
|
|
37
|
+
// This is useful for local/dev harnesses that need to point the SDK at a custom API host
|
|
38
|
+
// without changing the package defaults.
|
|
39
|
+
const getWindowBaseUrlOverride = () => {
|
|
40
|
+
if (!isBrowser) return null;
|
|
41
|
+
const candidate = window.onairosBaseUrl;
|
|
42
|
+
if (typeof candidate !== 'string') return null;
|
|
43
|
+
const trimmed = candidate.trim();
|
|
44
|
+
if (!trimmed.startsWith('http://') && !trimmed.startsWith('https://')) return null;
|
|
45
|
+
return trimmed.replace(/\/$/, '');
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Base URLs
|
|
49
|
+
const URLS = {
|
|
50
|
+
DEVELOPMENT: 'https://api2.onairos.uk',
|
|
51
|
+
DEV_SERVER: 'https://api2.onairos.uk',
|
|
52
|
+
PRODUCTION: 'https://api2.onairos.uk',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get the API base URL based on current domain
|
|
57
|
+
* - internship.onairos.uk -> https://api2.onairos.uk
|
|
58
|
+
* - All other domains -> https://api2.onairos.uk while dev backend changes are being tested
|
|
59
|
+
*
|
|
60
|
+
* @returns {string} The API base URL
|
|
61
|
+
*/
|
|
62
|
+
export function getApiBaseUrl() {
|
|
63
|
+
// SSR fallback
|
|
64
|
+
if (!isBrowser) {
|
|
65
|
+
return URLS.PRODUCTION;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const override = getWindowBaseUrlOverride();
|
|
69
|
+
if (override) {
|
|
70
|
+
return override;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Force production override
|
|
74
|
+
if (getForceProduction()) {
|
|
75
|
+
return URLS.PRODUCTION;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Internship demo domain uses the configured dev server URL.
|
|
79
|
+
if (getIsInternshipDemo()) {
|
|
80
|
+
return URLS.DEV_SERVER;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Default to production
|
|
84
|
+
return URLS.PRODUCTION;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// API Configuration object for backwards compatibility
|
|
88
|
+
export const API_CONFIG = {
|
|
89
|
+
// Base URLs
|
|
90
|
+
DEVELOPMENT_URL: URLS.DEVELOPMENT,
|
|
91
|
+
DEV_SERVER_URL: URLS.DEV_SERVER,
|
|
92
|
+
PRODUCTION_URL: URLS.PRODUCTION,
|
|
93
|
+
|
|
94
|
+
// Current environment (computed on access for SSR safety)
|
|
95
|
+
get IS_DEVELOPMENT() { return getIsDevelopment(); },
|
|
96
|
+
get IS_INTERNSHIP_DEMO() { return getIsInternshipDemo(); },
|
|
97
|
+
|
|
98
|
+
// Get base URL based on environment
|
|
99
|
+
getBaseUrl() {
|
|
100
|
+
return getApiBaseUrl();
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// Email verification endpoints
|
|
104
|
+
EMAIL_VERIFY: '/email/verify',
|
|
105
|
+
EMAIL_VERIFY_CONFIRM: '/email/verify/confirm',
|
|
106
|
+
|
|
107
|
+
// Get full URLs
|
|
108
|
+
getEmailVerifyUrl() {
|
|
109
|
+
return `${this.getBaseUrl()}${this.EMAIL_VERIFY}`;
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
getEmailVerifyConfirmUrl() {
|
|
113
|
+
return `${this.getBaseUrl()}${this.EMAIL_VERIFY_CONFIRM}`;
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// Debug info
|
|
117
|
+
getDebugInfo() {
|
|
118
|
+
if (!isBrowser) {
|
|
119
|
+
return { environment: 'ssr', baseUrl: URLS.PRODUCTION };
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
environment: this.IS_INTERNSHIP_DEMO ? 'internship-demo' : (this.IS_DEVELOPMENT ? 'development' : 'production'),
|
|
123
|
+
baseUrl: this.getBaseUrl(),
|
|
124
|
+
hostname: window.location.hostname,
|
|
125
|
+
port: window.location.port,
|
|
126
|
+
isInternshipDemo: this.IS_INTERNSHIP_DEMO,
|
|
127
|
+
emailVerifyUrl: this.getEmailVerifyUrl(),
|
|
128
|
+
emailVerifyConfirmUrl: this.getEmailVerifyConfirmUrl()
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Log configuration on load (only in browser)
|
|
134
|
+
if (isBrowser) {
|
|
135
|
+
console.log('🔧 API Configuration loaded:', API_CONFIG.getDebugInfo());
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export default API_CONFIG;
|
package/src/deepLink.jsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const DeepLink = () => {
|
|
4
|
+
const [message, setMessage] = useState("No message passed!");
|
|
5
|
+
const [mode, setMode] = useState("default");
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
// Check if Telegram's WebApp object is available
|
|
9
|
+
if (window.Telegram && window.Telegram.WebApp) {
|
|
10
|
+
// Tell Telegram the app is ready
|
|
11
|
+
window.Telegram.WebApp.ready();
|
|
12
|
+
|
|
13
|
+
// Access initData
|
|
14
|
+
const initData = window.Telegram.WebApp.initDataUnsafe;
|
|
15
|
+
const startParam = initData?.start_param || "No data found!";
|
|
16
|
+
const modeParam = initData?.mode || "default";
|
|
17
|
+
|
|
18
|
+
setMessage(startParam);
|
|
19
|
+
setMode(modeParam);
|
|
20
|
+
} else {
|
|
21
|
+
// Handle case where Telegram SDK is not available
|
|
22
|
+
console.warn("Telegram WebApp is not available!");
|
|
23
|
+
setMessage("Telegram WebApp is not available!");
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="min-h-screen flex items-center justify-center bg-gray-100">
|
|
29
|
+
<div className="p-4 bg-white shadow-lg rounded-lg">
|
|
30
|
+
<h1 className="text-2xl font-bold">Welcome to Onairos Mini App</h1>
|
|
31
|
+
<p className="mt-4 text-lg">Message: {message}</p>
|
|
32
|
+
<p className="mt-2 text-sm">Mode: {mode}</p>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default DeepLink;
|
package/src/getPin.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getApiBaseUrl } from './config/api-config.js';
|
|
2
|
+
|
|
3
|
+
export default async function getPin(userSub){
|
|
4
|
+
try {
|
|
5
|
+
const response = await fetch(`${getApiBaseUrl()}/getAccountInfoFromUserSub`, {
|
|
6
|
+
method: 'POST',
|
|
7
|
+
headers: {
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
},
|
|
10
|
+
body: JSON.stringify({
|
|
11
|
+
'userSub': userSub
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await response.json();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error('Error getting PIN:', error);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|