@onairos/react-native 3.0.2 → 3.0.5
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/README.md +23 -3
- package/lib/commonjs/api/index.js +5 -1
- package/lib/commonjs/api/index.js.map +1 -1
- package/lib/commonjs/components/OnairosButton.js +5 -3
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/Overlay.js +274 -104
- package/lib/commonjs/components/Overlay.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +12 -0
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js +28 -9
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js +6 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -1
- package/lib/commonjs/components/screens/ConnectorScreen.js +3 -2
- package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -1
- package/lib/commonjs/constants/index.js +1 -1
- package/lib/commonjs/hooks/useConnections.js +77 -15
- package/lib/commonjs/hooks/useConnections.js.map +1 -1
- package/lib/commonjs/hooks/useCredentials.js +2 -0
- package/lib/commonjs/hooks/useCredentials.js.map +1 -1
- package/lib/commonjs/index.js +51 -56
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/oauthService.js +26 -51
- package/lib/commonjs/services/oauthService.js.map +1 -1
- package/lib/commonjs/types/ambient.d.js +2 -0
- package/lib/commonjs/types/ambient.d.js.map +1 -0
- package/lib/commonjs/types/node-fix.d.js +2 -0
- package/lib/commonjs/types/node-fix.d.js.map +1 -0
- package/lib/commonjs/types/node-override.d.js +2 -0
- package/lib/commonjs/types/node-override.d.js.map +1 -0
- package/lib/commonjs/types/types.d.js +2 -0
- package/lib/commonjs/types/types.d.js.map +1 -0
- package/lib/commonjs/utils/encryption.js +8 -2
- package/lib/commonjs/utils/encryption.js.map +1 -1
- package/lib/commonjs/utils/secureStorage.js +23 -4
- package/lib/commonjs/utils/secureStorage.js.map +1 -1
- package/lib/module/api/index.js +5 -1
- package/lib/module/api/index.js.map +1 -1
- package/lib/module/components/OnairosButton.js +6 -4
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/Overlay.js +275 -107
- package/lib/module/components/Overlay.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +12 -0
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js +28 -9
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/components/onboarding/PlatformConnector.js +6 -1
- package/lib/module/components/onboarding/PlatformConnector.js.map +1 -1
- package/lib/module/components/screens/ConnectorScreen.js +3 -2
- package/lib/module/components/screens/ConnectorScreen.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/hooks/useConnections.js +77 -14
- package/lib/module/hooks/useConnections.js.map +1 -1
- package/lib/module/hooks/useCredentials.js +2 -0
- package/lib/module/hooks/useCredentials.js.map +1 -1
- package/lib/module/index.js +27 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/oauthService.js +26 -33
- package/lib/module/services/oauthService.js.map +1 -1
- package/lib/module/types/ambient.d.js +2 -0
- package/lib/module/types/ambient.d.js.map +1 -0
- package/lib/module/types/node-fix.d.js +2 -0
- package/lib/module/types/node-fix.d.js.map +1 -0
- package/lib/module/types/node-override.d.js +2 -0
- package/lib/module/types/node-override.d.js.map +1 -0
- package/lib/module/types/types.d.js +2 -0
- package/lib/module/types/types.d.js.map +1 -0
- package/lib/module/utils/encryption.js +8 -2
- package/lib/module/utils/encryption.js.map +1 -1
- package/lib/module/utils/secureStorage.js +23 -3
- package/lib/module/utils/secureStorage.js.map +1 -1
- package/lib/typescript/api/index.d.ts +8 -0
- package/lib/typescript/api/index.d.ts.map +1 -0
- package/lib/typescript/components/DataRequestModal.d.ts +11 -0
- package/lib/typescript/components/DataRequestModal.d.ts.map +1 -0
- package/lib/typescript/components/Onairos.d.ts +29 -0
- package/lib/typescript/components/Onairos.d.ts.map +1 -0
- package/lib/typescript/components/OnairosButton.d.ts +7 -0
- package/lib/typescript/components/OnairosButton.d.ts.map +1 -0
- package/lib/typescript/components/Overlay.d.ts +18 -0
- package/lib/typescript/components/Overlay.d.ts.map +1 -0
- package/lib/typescript/components/PinInput.d.ts +4 -0
- package/lib/typescript/components/PinInput.d.ts.map +1 -0
- package/lib/typescript/components/PlatformList.d.ts +4 -0
- package/lib/typescript/components/PlatformList.d.ts.map +1 -0
- package/lib/typescript/components/TrainingModal.d.ts +4 -0
- package/lib/typescript/components/TrainingModal.d.ts.map +1 -0
- package/lib/typescript/components/UniversalOnboarding.d.ts +4 -0
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts +4 -0
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +11 -0
- package/lib/typescript/components/onboarding/OnboardingHeader.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/PinInput.d.ts +4 -0
- package/lib/typescript/components/onboarding/PinInput.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/PlatformConnector.d.ts +13 -0
- package/lib/typescript/components/onboarding/PlatformConnector.d.ts.map +1 -0
- package/lib/typescript/components/screens/ConnectorScreen.d.ts +9 -0
- package/lib/typescript/components/screens/ConnectorScreen.d.ts.map +1 -0
- package/lib/typescript/components/screens/LoadingScreen.d.ts +9 -0
- package/lib/typescript/components/screens/LoadingScreen.d.ts.map +1 -0
- package/lib/typescript/components/screens/PinCreationScreen.d.ts +10 -0
- package/lib/typescript/components/screens/PinCreationScreen.d.ts.map +1 -0
- package/lib/typescript/constants/index.d.ts +52 -0
- package/lib/typescript/constants/index.d.ts.map +1 -0
- package/lib/typescript/hooks/useConnections.d.ts +9 -0
- package/lib/typescript/hooks/useConnections.d.ts.map +1 -0
- package/lib/typescript/hooks/useCredentials.d.ts +9 -0
- package/lib/typescript/hooks/useCredentials.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +45 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/services/oauthService.d.ts +50 -0
- package/lib/typescript/services/oauthService.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +145 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +135 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils/api.d.ts +6 -0
- package/lib/typescript/utils/api.d.ts.map +1 -0
- package/lib/typescript/utils/auth.d.ts +6 -0
- package/lib/typescript/utils/auth.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts +4 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -0
- package/lib/typescript/utils/debugHelper.d.ts +29 -0
- package/lib/typescript/utils/debugHelper.d.ts.map +1 -0
- package/lib/typescript/utils/encryption.d.ts +19 -0
- package/lib/typescript/utils/encryption.d.ts.map +1 -0
- package/lib/typescript/utils/onairosApi.d.ts +72 -0
- package/lib/typescript/utils/onairosApi.d.ts.map +1 -0
- package/lib/typescript/utils/secureStorage.d.ts +63 -0
- package/lib/typescript/utils/secureStorage.d.ts.map +1 -0
- package/package.json +16 -4
- package/src/api/index.ts +11 -11
- package/src/components/OnairosButton.tsx +5 -3
- package/src/components/Overlay.tsx +319 -135
- package/src/components/UniversalOnboarding.tsx +12 -0
- package/src/components/onboarding/OAuthWebView.tsx +27 -7
- package/src/components/onboarding/PlatformConnector.tsx +5 -0
- package/src/components/screens/ConnectorScreen.tsx +3 -2
- package/src/constants/index.ts +81 -81
- package/src/hooks/useConnections.ts +76 -16
- package/src/hooks/useCredentials.ts +5 -1
- package/src/index.ts +29 -1
- package/src/services/oauthService.ts +412 -419
- package/src/types/ambient.d.ts +29 -0
- package/src/types/index.d.ts +48 -8
- package/src/types/index.ts +21 -15
- package/src/types/node-fix.d.ts +19 -0
- package/src/types/node-override.d.ts +24 -0
- package/src/types/types.d.ts +18 -0
- package/src/types.ts +121 -1
- package/src/utils/encryption.ts +7 -2
- package/src/utils/secureStorage.ts +25 -9
- package/types/index.d.ts +210 -0
- package/types/node-env.d.ts +15 -0
|
@@ -179,6 +179,11 @@ export const PlatformConnector: React.FC<PlatformConnectorProps> = ({
|
|
|
179
179
|
platform={activeWebview}
|
|
180
180
|
onComplete={handleWebViewComplete}
|
|
181
181
|
onClose={handleWebViewClose}
|
|
182
|
+
onSuccess={(code) => {
|
|
183
|
+
console.log(`Received authorization code for ${activeWebview}: ${code}`);
|
|
184
|
+
// In a real implementation, we'd pass this code to our API service
|
|
185
|
+
handleWebViewComplete();
|
|
186
|
+
}}
|
|
182
187
|
/>
|
|
183
188
|
)}
|
|
184
189
|
</View>
|
|
@@ -36,8 +36,9 @@ export const ConnectorScreen: React.FC<ConnectorScreenProps> = ({
|
|
|
36
36
|
// Transform platforms data to connection status format
|
|
37
37
|
Object.entries(credentials.platforms).forEach(([platform, data]) => {
|
|
38
38
|
if (data && 'username' in data) {
|
|
39
|
-
connectionStatus[platform
|
|
39
|
+
connectionStatus[platform] = {
|
|
40
40
|
userName: data.username,
|
|
41
|
+
connected: true
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
});
|
|
@@ -120,7 +121,7 @@ export const ConnectorScreen: React.FC<ConnectorScreenProps> = ({
|
|
|
120
121
|
|
|
121
122
|
// Check if user can proceed to next step
|
|
122
123
|
const canProceed = useCallback(() => {
|
|
123
|
-
const connectedPlatforms = Object.values(connections).filter(
|
|
124
|
+
const connectedPlatforms = Object.values(connections).filter(conn => conn.connected).length;
|
|
124
125
|
return connectedPlatforms >= 2;
|
|
125
126
|
}, [connections]);
|
|
126
127
|
|
package/src/constants/index.ts
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import type { PlatformConfig } from '../types';
|
|
2
|
-
|
|
3
|
-
export const COLORS = {
|
|
4
|
-
primary: '#1BA9D4',
|
|
5
|
-
headerBg: '#F8F9FA',
|
|
6
|
-
text: {
|
|
7
|
-
primary: '#000000',
|
|
8
|
-
secondary: '#666666',
|
|
9
|
-
},
|
|
10
|
-
border: '#E5E5E5',
|
|
11
|
-
success: '#34C759',
|
|
12
|
-
error: '#FF3B30',
|
|
13
|
-
instagram: '#E1306C',
|
|
14
|
-
pinterest: '#E60023',
|
|
15
|
-
reddit: '#FF4500',
|
|
16
|
-
youtube: '#FF0000',
|
|
17
|
-
white: '#FFFFFF',
|
|
18
|
-
black: '#000000',
|
|
19
|
-
gray: '#666666',
|
|
20
|
-
lightGray: '#E5E5E5',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const PLATFORMS: Record<string, PlatformConfig> = {
|
|
24
|
-
instagram: {
|
|
25
|
-
name: 'Instagram',
|
|
26
|
-
icon: 'instagram',
|
|
27
|
-
color: COLORS.instagram,
|
|
28
|
-
description: 'Connect your Instagram account to train your AI model',
|
|
29
|
-
},
|
|
30
|
-
pinterest: {
|
|
31
|
-
name: 'Pinterest',
|
|
32
|
-
icon: 'pinterest',
|
|
33
|
-
color: COLORS.pinterest,
|
|
34
|
-
description: 'Use your Pinterest boards for AI training',
|
|
35
|
-
},
|
|
36
|
-
reddit: {
|
|
37
|
-
name: 'Reddit',
|
|
38
|
-
icon: 'reddit',
|
|
39
|
-
color: COLORS.reddit,
|
|
40
|
-
description: 'Connect Reddit to enhance your AI model',
|
|
41
|
-
},
|
|
42
|
-
youtube: {
|
|
43
|
-
name: 'YouTube',
|
|
44
|
-
icon: 'youtube',
|
|
45
|
-
color: COLORS.youtube,
|
|
46
|
-
description: 'Use YouTube data to improve AI recommendations',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const API_ENDPOINTS = {
|
|
51
|
-
base: 'https://api2.onairos.uk',
|
|
52
|
-
oauth: {
|
|
53
|
-
instagram: '/instagram/auth',
|
|
54
|
-
pinterest: '/pinterest/auth',
|
|
55
|
-
reddit: '/reddit/auth',
|
|
56
|
-
youtube: '/youtube/auth',
|
|
57
|
-
},
|
|
58
|
-
callback: {
|
|
59
|
-
instagram: '/instagram/callback',
|
|
60
|
-
pinterest: '/pinterest/callback',
|
|
61
|
-
reddit: '/reddit/callback',
|
|
62
|
-
youtube: '/youtube/callback',
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const STORAGE_KEYS = {
|
|
67
|
-
credentials: 'onairos_credentials',
|
|
68
|
-
connections: 'onairos_connections',
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const PIN_REQUIREMENTS = {
|
|
72
|
-
minLength: 8,
|
|
73
|
-
requireUppercase: true,
|
|
74
|
-
requireLowercase: true,
|
|
75
|
-
requireNumber: true,
|
|
76
|
-
requireSpecialChar: true,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const DEEP_LINK_CONFIG = {
|
|
80
|
-
scheme: '
|
|
81
|
-
host: 'authenticate',
|
|
1
|
+
import type { PlatformConfig } from '../types';
|
|
2
|
+
|
|
3
|
+
export const COLORS = {
|
|
4
|
+
primary: '#1BA9D4',
|
|
5
|
+
headerBg: '#F8F9FA',
|
|
6
|
+
text: {
|
|
7
|
+
primary: '#000000',
|
|
8
|
+
secondary: '#666666',
|
|
9
|
+
},
|
|
10
|
+
border: '#E5E5E5',
|
|
11
|
+
success: '#34C759',
|
|
12
|
+
error: '#FF3B30',
|
|
13
|
+
instagram: '#E1306C',
|
|
14
|
+
pinterest: '#E60023',
|
|
15
|
+
reddit: '#FF4500',
|
|
16
|
+
youtube: '#FF0000',
|
|
17
|
+
white: '#FFFFFF',
|
|
18
|
+
black: '#000000',
|
|
19
|
+
gray: '#666666',
|
|
20
|
+
lightGray: '#E5E5E5',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const PLATFORMS: Record<string, PlatformConfig> = {
|
|
24
|
+
instagram: {
|
|
25
|
+
name: 'Instagram',
|
|
26
|
+
icon: 'instagram',
|
|
27
|
+
color: COLORS.instagram,
|
|
28
|
+
description: 'Connect your Instagram account to train your AI model',
|
|
29
|
+
},
|
|
30
|
+
pinterest: {
|
|
31
|
+
name: 'Pinterest',
|
|
32
|
+
icon: 'pinterest',
|
|
33
|
+
color: COLORS.pinterest,
|
|
34
|
+
description: 'Use your Pinterest boards for AI training',
|
|
35
|
+
},
|
|
36
|
+
reddit: {
|
|
37
|
+
name: 'Reddit',
|
|
38
|
+
icon: 'reddit',
|
|
39
|
+
color: COLORS.reddit,
|
|
40
|
+
description: 'Connect Reddit to enhance your AI model',
|
|
41
|
+
},
|
|
42
|
+
youtube: {
|
|
43
|
+
name: 'YouTube',
|
|
44
|
+
icon: 'youtube',
|
|
45
|
+
color: COLORS.youtube,
|
|
46
|
+
description: 'Use YouTube data to improve AI recommendations',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const API_ENDPOINTS = {
|
|
51
|
+
base: 'https://api2.onairos.uk',
|
|
52
|
+
oauth: {
|
|
53
|
+
instagram: '/instagram/auth',
|
|
54
|
+
pinterest: '/pinterest/auth',
|
|
55
|
+
reddit: '/reddit/auth',
|
|
56
|
+
youtube: '/youtube/auth',
|
|
57
|
+
},
|
|
58
|
+
callback: {
|
|
59
|
+
instagram: '/instagram/callback',
|
|
60
|
+
pinterest: '/pinterest/callback',
|
|
61
|
+
reddit: '/reddit/callback',
|
|
62
|
+
youtube: '/youtube/callback',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const STORAGE_KEYS = {
|
|
67
|
+
credentials: 'onairos_credentials',
|
|
68
|
+
connections: 'onairos_connections',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const PIN_REQUIREMENTS = {
|
|
72
|
+
minLength: 8,
|
|
73
|
+
requireUppercase: true,
|
|
74
|
+
requireLowercase: true,
|
|
75
|
+
requireNumber: true,
|
|
76
|
+
requireSpecialChar: true,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const DEEP_LINK_CONFIG = {
|
|
80
|
+
scheme: 'onairosanime',
|
|
81
|
+
host: 'authenticate',
|
|
82
82
|
};
|
|
@@ -1,35 +1,77 @@
|
|
|
1
1
|
import { useState, useCallback } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
3
|
import { STORAGE_KEYS } from '../constants';
|
|
4
4
|
import type { ConnectionStatus } from '../types';
|
|
5
5
|
|
|
6
|
+
// Create a mock storage for environments without Keychain access (like Expo Go)
|
|
7
|
+
const mockConnectionStorage: Record<string, ConnectionStatus> = {};
|
|
8
|
+
|
|
9
|
+
// Try to import Keychain, but provide fallbacks if not available
|
|
10
|
+
let Keychain: any = null;
|
|
11
|
+
try {
|
|
12
|
+
// This import might fail in Expo Go or environments without native modules
|
|
13
|
+
Keychain = require('react-native-keychain');
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.warn('react-native-keychain module not available in useConnections, using mock storage');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Check if Keychain is properly initialized and available
|
|
19
|
+
const isKeychainAvailable = () => {
|
|
20
|
+
try {
|
|
21
|
+
return Keychain && typeof Keychain.getGenericPassword === 'function';
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
6
27
|
export const useConnections = () => {
|
|
7
28
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
8
29
|
|
|
9
30
|
const getConnectionStatus = useCallback(async (): Promise<ConnectionStatus> => {
|
|
10
31
|
try {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
if (isKeychainAvailable()) {
|
|
33
|
+
const stored = await Keychain.getGenericPassword({
|
|
34
|
+
service: STORAGE_KEYS.connections
|
|
35
|
+
});
|
|
36
|
+
if (stored) {
|
|
37
|
+
return JSON.parse(stored.password);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
// Use in-memory mock storage if Keychain is not available
|
|
41
|
+
return mockConnectionStorage[STORAGE_KEYS.connections] || {};
|
|
16
42
|
}
|
|
17
43
|
return {};
|
|
18
44
|
} catch (error) {
|
|
19
45
|
console.error('Error getting connection status:', error);
|
|
46
|
+
|
|
47
|
+
// Return mock data in debug mode to prevent crashes
|
|
48
|
+
if (__DEV__) {
|
|
49
|
+
return {
|
|
50
|
+
instagram: { userName: 'instagram_debug_user', connected: true },
|
|
51
|
+
youtube: { userName: 'youtube_debug_user', connected: true }
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
20
55
|
return {};
|
|
21
56
|
}
|
|
22
57
|
}, []);
|
|
23
58
|
|
|
24
59
|
const saveConnectionStatus = useCallback(async (status: ConnectionStatus) => {
|
|
25
60
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
61
|
+
if (isKeychainAvailable()) {
|
|
62
|
+
await Keychain.setGenericPassword(
|
|
63
|
+
'connections',
|
|
64
|
+
JSON.stringify(status),
|
|
65
|
+
{ service: STORAGE_KEYS.connections }
|
|
66
|
+
);
|
|
67
|
+
} else {
|
|
68
|
+
// Use in-memory mock storage if Keychain is not available
|
|
69
|
+
mockConnectionStorage[STORAGE_KEYS.connections] = status;
|
|
70
|
+
}
|
|
31
71
|
} catch (error) {
|
|
32
72
|
console.error('Error saving connection status:', error);
|
|
73
|
+
// Save to mock storage as fallback
|
|
74
|
+
mockConnectionStorage[STORAGE_KEYS.connections] = status;
|
|
33
75
|
}
|
|
34
76
|
}, []);
|
|
35
77
|
|
|
@@ -39,7 +81,9 @@ export const useConnections = () => {
|
|
|
39
81
|
console.log(`[Mock] Connecting to ${platform}`);
|
|
40
82
|
|
|
41
83
|
// Simulate connection delay
|
|
42
|
-
await new Promise(resolve =>
|
|
84
|
+
await new Promise<void>((resolve) => {
|
|
85
|
+
setTimeout(() => resolve(), 1000);
|
|
86
|
+
});
|
|
43
87
|
|
|
44
88
|
const status = await getConnectionStatus();
|
|
45
89
|
status[platform] = {
|
|
@@ -51,7 +95,18 @@ export const useConnections = () => {
|
|
|
51
95
|
console.log(`[Mock] Successfully connected to ${platform}`);
|
|
52
96
|
} catch (error) {
|
|
53
97
|
console.error(`Error connecting to ${platform}:`, error);
|
|
54
|
-
|
|
98
|
+
// In development, provide mock data even on error
|
|
99
|
+
if (__DEV__) {
|
|
100
|
+
const status = {
|
|
101
|
+
[platform]: {
|
|
102
|
+
userName: `Fallback User (${platform})`,
|
|
103
|
+
connected: true
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
await saveConnectionStatus(status);
|
|
107
|
+
} else {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
55
110
|
} finally {
|
|
56
111
|
setIsConnecting(false);
|
|
57
112
|
}
|
|
@@ -60,11 +115,16 @@ export const useConnections = () => {
|
|
|
60
115
|
const disconnectPlatform = useCallback(async (platform: string) => {
|
|
61
116
|
try {
|
|
62
117
|
const status = await getConnectionStatus();
|
|
63
|
-
|
|
64
|
-
|
|
118
|
+
if (status && platform in status) {
|
|
119
|
+
delete status[platform];
|
|
120
|
+
await saveConnectionStatus(status);
|
|
121
|
+
}
|
|
65
122
|
} catch (error) {
|
|
66
123
|
console.error(`Error disconnecting ${platform}:`, error);
|
|
67
|
-
throw
|
|
124
|
+
// Don't throw in development mode
|
|
125
|
+
if (!__DEV__) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
68
128
|
}
|
|
69
129
|
}, [getConnectionStatus, saveConnectionStatus]);
|
|
70
130
|
|
|
@@ -77,12 +77,16 @@ export const useCredentials = () => {
|
|
|
77
77
|
|
|
78
78
|
const data = await response.json();
|
|
79
79
|
return {
|
|
80
|
+
success: true,
|
|
80
81
|
isValid: data.valid,
|
|
81
82
|
credentials: data.credentials,
|
|
82
83
|
};
|
|
83
84
|
} catch (error) {
|
|
84
85
|
console.error('Error validating credentials:', error);
|
|
85
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
success: false,
|
|
88
|
+
isValid: false
|
|
89
|
+
};
|
|
86
90
|
}
|
|
87
91
|
}, []);
|
|
88
92
|
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Main components
|
|
7
|
+
import { Onairos } from './components/Onairos';
|
|
8
|
+
import { OnairosButton } from './components/OnairosButton';
|
|
9
|
+
import { Overlay } from './components/Overlay';
|
|
10
|
+
import { UniversalOnboarding } from './components/UniversalOnboarding';
|
|
11
|
+
|
|
12
|
+
// Export main components
|
|
7
13
|
export { Onairos } from './components/Onairos';
|
|
8
14
|
export { OnairosButton } from './components/OnairosButton';
|
|
9
15
|
export { Overlay as OnairosOverlay } from './components/Overlay';
|
|
@@ -78,6 +84,10 @@ export type {
|
|
|
78
84
|
OAuthWebViewProps,
|
|
79
85
|
PlatformConfig,
|
|
80
86
|
ApiResponse,
|
|
87
|
+
CredentialsResult,
|
|
88
|
+
OverlayProps,
|
|
89
|
+
BiometricOptions,
|
|
90
|
+
PinRequirements,
|
|
81
91
|
} from './types';
|
|
82
92
|
|
|
83
93
|
export type { StorageOptions, OnairosCredentials } from './utils/secureStorage';
|
|
@@ -91,4 +101,22 @@ export { COLORS, PLATFORMS, API_ENDPOINTS, STORAGE_KEYS, PIN_REQUIREMENTS, DEEP_
|
|
|
91
101
|
export { onairosApi } from './api';
|
|
92
102
|
export { OAuthService } from './services/oauthService';
|
|
93
103
|
export * from './utils/secureStorage';
|
|
94
|
-
export * from './utils/encryption';
|
|
104
|
+
export * from './utils/encryption';
|
|
105
|
+
|
|
106
|
+
// Define component types for default export using React.ComponentType
|
|
107
|
+
import * as React from 'react';
|
|
108
|
+
import type { OnairosButtonProps, UniversalOnboardingProps } from './types';
|
|
109
|
+
|
|
110
|
+
interface OverlayComponent extends React.FC<any> {}
|
|
111
|
+
interface OnairosComponent extends React.FC<any> {}
|
|
112
|
+
|
|
113
|
+
// Define the public components for default export
|
|
114
|
+
const components = {
|
|
115
|
+
Onairos: Onairos as OnairosComponent,
|
|
116
|
+
OnairosButton: OnairosButton as React.ComponentType<OnairosButtonProps>,
|
|
117
|
+
OnairosOverlay: Overlay as OverlayComponent,
|
|
118
|
+
UniversalOnboarding: UniversalOnboarding as React.ComponentType<UniversalOnboardingProps>,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Export the components as the default export
|
|
122
|
+
export default components;
|