@onairos/react-native 3.0.2 → 3.0.4

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 (155) hide show
  1. package/README.md +23 -3
  2. package/lib/commonjs/api/index.js +5 -1
  3. package/lib/commonjs/api/index.js.map +1 -1
  4. package/lib/commonjs/components/OnairosButton.js +0 -1
  5. package/lib/commonjs/components/OnairosButton.js.map +1 -1
  6. package/lib/commonjs/components/Overlay.js +260 -108
  7. package/lib/commonjs/components/Overlay.js.map +1 -1
  8. package/lib/commonjs/components/UniversalOnboarding.js +12 -0
  9. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  10. package/lib/commonjs/components/onboarding/OAuthWebView.js +28 -9
  11. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
  12. package/lib/commonjs/components/onboarding/PlatformConnector.js +6 -1
  13. package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -1
  14. package/lib/commonjs/components/screens/ConnectorScreen.js +3 -2
  15. package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -1
  16. package/lib/commonjs/constants/index.js +1 -1
  17. package/lib/commonjs/hooks/useConnections.js +77 -15
  18. package/lib/commonjs/hooks/useConnections.js.map +1 -1
  19. package/lib/commonjs/hooks/useCredentials.js +2 -0
  20. package/lib/commonjs/hooks/useCredentials.js.map +1 -1
  21. package/lib/commonjs/index.js +38 -0
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/services/oauthService.js +26 -51
  24. package/lib/commonjs/services/oauthService.js.map +1 -1
  25. package/lib/commonjs/types/ambient.d.js +2 -0
  26. package/lib/commonjs/types/ambient.d.js.map +1 -0
  27. package/lib/commonjs/types/node-fix.d.js +2 -0
  28. package/lib/commonjs/types/node-fix.d.js.map +1 -0
  29. package/lib/commonjs/types/node-override.d.js +2 -0
  30. package/lib/commonjs/types/node-override.d.js.map +1 -0
  31. package/lib/commonjs/types/types.d.js +2 -0
  32. package/lib/commonjs/types/types.d.js.map +1 -0
  33. package/lib/commonjs/utils/encryption.js +8 -2
  34. package/lib/commonjs/utils/encryption.js.map +1 -1
  35. package/lib/commonjs/utils/secureStorage.js +23 -4
  36. package/lib/commonjs/utils/secureStorage.js.map +1 -1
  37. package/lib/module/api/index.js +5 -1
  38. package/lib/module/api/index.js.map +1 -1
  39. package/lib/module/components/OnairosButton.js +0 -1
  40. package/lib/module/components/OnairosButton.js.map +1 -1
  41. package/lib/module/components/Overlay.js +260 -110
  42. package/lib/module/components/Overlay.js.map +1 -1
  43. package/lib/module/components/UniversalOnboarding.js +12 -0
  44. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  45. package/lib/module/components/onboarding/OAuthWebView.js +28 -9
  46. package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
  47. package/lib/module/components/onboarding/PlatformConnector.js +6 -1
  48. package/lib/module/components/onboarding/PlatformConnector.js.map +1 -1
  49. package/lib/module/components/screens/ConnectorScreen.js +3 -2
  50. package/lib/module/components/screens/ConnectorScreen.js.map +1 -1
  51. package/lib/module/constants/index.js +1 -1
  52. package/lib/module/hooks/useConnections.js +77 -14
  53. package/lib/module/hooks/useConnections.js.map +1 -1
  54. package/lib/module/hooks/useCredentials.js +2 -0
  55. package/lib/module/hooks/useCredentials.js.map +1 -1
  56. package/lib/module/index.js +27 -9
  57. package/lib/module/index.js.map +1 -1
  58. package/lib/module/services/oauthService.js +26 -33
  59. package/lib/module/services/oauthService.js.map +1 -1
  60. package/lib/module/types/ambient.d.js +2 -0
  61. package/lib/module/types/ambient.d.js.map +1 -0
  62. package/lib/module/types/node-fix.d.js +2 -0
  63. package/lib/module/types/node-fix.d.js.map +1 -0
  64. package/lib/module/types/node-override.d.js +2 -0
  65. package/lib/module/types/node-override.d.js.map +1 -0
  66. package/lib/module/types/types.d.js +2 -0
  67. package/lib/module/types/types.d.js.map +1 -0
  68. package/lib/module/utils/encryption.js +8 -2
  69. package/lib/module/utils/encryption.js.map +1 -1
  70. package/lib/module/utils/secureStorage.js +23 -3
  71. package/lib/module/utils/secureStorage.js.map +1 -1
  72. package/lib/typescript/api/index.d.ts +8 -0
  73. package/lib/typescript/api/index.d.ts.map +1 -0
  74. package/lib/typescript/components/DataRequestModal.d.ts +11 -0
  75. package/lib/typescript/components/DataRequestModal.d.ts.map +1 -0
  76. package/lib/typescript/components/Onairos.d.ts +29 -0
  77. package/lib/typescript/components/Onairos.d.ts.map +1 -0
  78. package/lib/typescript/components/OnairosButton.d.ts +7 -0
  79. package/lib/typescript/components/OnairosButton.d.ts.map +1 -0
  80. package/lib/typescript/components/Overlay.d.ts +18 -0
  81. package/lib/typescript/components/Overlay.d.ts.map +1 -0
  82. package/lib/typescript/components/PinInput.d.ts +4 -0
  83. package/lib/typescript/components/PinInput.d.ts.map +1 -0
  84. package/lib/typescript/components/PlatformList.d.ts +4 -0
  85. package/lib/typescript/components/PlatformList.d.ts.map +1 -0
  86. package/lib/typescript/components/TrainingModal.d.ts +4 -0
  87. package/lib/typescript/components/TrainingModal.d.ts.map +1 -0
  88. package/lib/typescript/components/UniversalOnboarding.d.ts +4 -0
  89. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -0
  90. package/lib/typescript/components/onboarding/OAuthWebView.d.ts +4 -0
  91. package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -0
  92. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +11 -0
  93. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts.map +1 -0
  94. package/lib/typescript/components/onboarding/PinInput.d.ts +4 -0
  95. package/lib/typescript/components/onboarding/PinInput.d.ts.map +1 -0
  96. package/lib/typescript/components/onboarding/PlatformConnector.d.ts +13 -0
  97. package/lib/typescript/components/onboarding/PlatformConnector.d.ts.map +1 -0
  98. package/lib/typescript/components/screens/ConnectorScreen.d.ts +9 -0
  99. package/lib/typescript/components/screens/ConnectorScreen.d.ts.map +1 -0
  100. package/lib/typescript/components/screens/LoadingScreen.d.ts +9 -0
  101. package/lib/typescript/components/screens/LoadingScreen.d.ts.map +1 -0
  102. package/lib/typescript/components/screens/PinCreationScreen.d.ts +10 -0
  103. package/lib/typescript/components/screens/PinCreationScreen.d.ts.map +1 -0
  104. package/lib/typescript/constants/index.d.ts +52 -0
  105. package/lib/typescript/constants/index.d.ts.map +1 -0
  106. package/lib/typescript/hooks/useConnections.d.ts +9 -0
  107. package/lib/typescript/hooks/useConnections.d.ts.map +1 -0
  108. package/lib/typescript/hooks/useCredentials.d.ts +9 -0
  109. package/lib/typescript/hooks/useCredentials.d.ts.map +1 -0
  110. package/lib/typescript/index.d.ts +45 -0
  111. package/lib/typescript/index.d.ts.map +1 -0
  112. package/lib/typescript/services/oauthService.d.ts +50 -0
  113. package/lib/typescript/services/oauthService.d.ts.map +1 -0
  114. package/lib/typescript/types/index.d.ts +145 -0
  115. package/lib/typescript/types/index.d.ts.map +1 -0
  116. package/lib/typescript/types.d.ts +135 -0
  117. package/lib/typescript/types.d.ts.map +1 -0
  118. package/lib/typescript/utils/api.d.ts +6 -0
  119. package/lib/typescript/utils/api.d.ts.map +1 -0
  120. package/lib/typescript/utils/auth.d.ts +6 -0
  121. package/lib/typescript/utils/auth.d.ts.map +1 -0
  122. package/lib/typescript/utils/crypto.d.ts +4 -0
  123. package/lib/typescript/utils/crypto.d.ts.map +1 -0
  124. package/lib/typescript/utils/debugHelper.d.ts +29 -0
  125. package/lib/typescript/utils/debugHelper.d.ts.map +1 -0
  126. package/lib/typescript/utils/encryption.d.ts +19 -0
  127. package/lib/typescript/utils/encryption.d.ts.map +1 -0
  128. package/lib/typescript/utils/onairosApi.d.ts +72 -0
  129. package/lib/typescript/utils/onairosApi.d.ts.map +1 -0
  130. package/lib/typescript/utils/secureStorage.d.ts +63 -0
  131. package/lib/typescript/utils/secureStorage.d.ts.map +1 -0
  132. package/package.json +16 -4
  133. package/src/api/index.ts +11 -11
  134. package/src/components/OnairosButton.tsx +0 -1
  135. package/src/components/Overlay.tsx +303 -138
  136. package/src/components/UniversalOnboarding.tsx +12 -0
  137. package/src/components/onboarding/OAuthWebView.tsx +27 -7
  138. package/src/components/onboarding/PlatformConnector.tsx +5 -0
  139. package/src/components/screens/ConnectorScreen.tsx +3 -2
  140. package/src/constants/index.ts +81 -81
  141. package/src/hooks/useConnections.ts +76 -16
  142. package/src/hooks/useCredentials.ts +5 -1
  143. package/src/index.ts +29 -1
  144. package/src/services/oauthService.ts +412 -419
  145. package/src/types/ambient.d.ts +29 -0
  146. package/src/types/index.d.ts +48 -8
  147. package/src/types/index.ts +21 -15
  148. package/src/types/node-fix.d.ts +19 -0
  149. package/src/types/node-override.d.ts +24 -0
  150. package/src/types/types.d.ts +18 -0
  151. package/src/types.ts +121 -1
  152. package/src/utils/encryption.ts +7 -2
  153. package/src/utils/secureStorage.ts +25 -9
  154. package/types/index.d.ts +210 -0
  155. package/types/node-env.d.ts +15 -0
@@ -10,25 +10,45 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
10
10
  platform,
11
11
  onComplete,
12
12
  onClose,
13
+ onSuccess,
13
14
  }) => {
14
15
  const [loading, setLoading] = useState(true);
15
16
 
16
17
  const handleNavigationStateChange = useCallback(
17
18
  (navState: WebViewNavigation) => {
18
19
  // Check if the URL includes our redirect URI
19
- if (navState.url.startsWith('onairosreact://auth/')) {
20
- // OAuth flow is complete - callback will be handled by the deep link handler
21
- onComplete();
20
+ if (navState.url.startsWith('onairosanime://auth/')) {
21
+ // Extract the authorization code from the URL
22
+ const authCode = extractAuthCode(navState.url);
23
+ if (authCode) {
24
+ onSuccess(authCode);
25
+ }
26
+
27
+ // OAuth flow is complete
28
+ if (onComplete) {
29
+ onComplete();
30
+ }
22
31
  return;
23
32
  }
24
33
  },
25
- [onComplete]
34
+ [onComplete, onSuccess]
26
35
  );
27
36
 
28
37
  const handleLoadEnd = useCallback(() => {
29
38
  setLoading(false);
30
39
  }, []);
31
40
 
41
+ // Extract auth code from redirect URL
42
+ const extractAuthCode = (redirectUrl: string): string => {
43
+ try {
44
+ const url = new URL(redirectUrl);
45
+ return url.searchParams.get('code') || '';
46
+ } catch (error) {
47
+ console.error('Error extracting auth code:', error);
48
+ return '';
49
+ }
50
+ };
51
+
32
52
  return (
33
53
  <SafeAreaView style={styles.container}>
34
54
  <View style={styles.header}>
@@ -37,9 +57,9 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
37
57
  </TouchableOpacity>
38
58
  <View style={styles.titleContainer}>
39
59
  <Icon
40
- name={getPlatformIcon(platform)}
60
+ name={getPlatformIcon(platform || 'default')}
41
61
  size={20}
42
- color={getPlatformColor(platform)}
62
+ color={getPlatformColor(platform || 'default')}
43
63
  />
44
64
  </View>
45
65
  </View>
@@ -49,7 +69,7 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
49
69
  onNavigationStateChange={handleNavigationStateChange}
50
70
  onLoadEnd={handleLoadEnd}
51
71
  startInLoadingState={true}
52
- renderLoading={() => null} // We'll handle our own loading UI
72
+ renderLoading={() => <View />}
53
73
  style={styles.webView}
54
74
  />
55
75
 
@@ -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 as keyof ConnectionStatus] = {
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(Boolean).length;
124
+ const connectedPlatforms = Object.values(connections).filter(conn => conn.connected).length;
124
125
  return connectedPlatforms >= 2;
125
126
  }, [connections]);
126
127
 
@@ -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: 'onairosreact',
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 * as Keychain from 'react-native-keychain';
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
- const stored = await Keychain.getGenericPassword({
12
- service: STORAGE_KEYS.connections
13
- });
14
- if (stored) {
15
- return JSON.parse(stored.password);
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
- await Keychain.setGenericPassword(
27
- 'connections',
28
- JSON.stringify(status),
29
- { service: STORAGE_KEYS.connections }
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 => setTimeout(resolve, 1000));
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
- throw error;
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
- delete status[platform];
64
- await saveConnectionStatus(status);
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 error;
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 { isValid: false };
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;