@onairos/react-native 3.0.42 → 3.0.45
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/lib/commonjs/components/OnairosButton.js +9 -3
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +121 -8
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/commonjs/index.js +12 -425
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/opacity.d.js +2 -0
- package/lib/commonjs/types/opacity.d.js.map +1 -0
- package/lib/module/components/OnairosButton.js +8 -2
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +122 -9
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/index.js +37 -37
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/opacity.d.js +2 -0
- package/lib/module/types/opacity.d.js.map +1 -0
- package/lib/typescript/components/OnairosButton.d.ts +1 -0
- package/lib/typescript/components/OnairosButton.d.ts.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +26 -32
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +1 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/OnairosButton.tsx +9 -3
- package/src/components/UniversalOnboarding.tsx +136 -8
- package/src/components/onboarding/OAuthWebView.tsx +11 -11
- package/src/index.ts +62 -67
- package/src/types/opacity.d.ts +16 -0
- package/src/types.ts +1 -0
- package/types/index.d.ts +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","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EAAE,MAAM,GAAG;YACb,IAAI,EAAE,MAAM,CAAC;YACb,YAAY,EAAE,MAAM,CAAC;YACrB,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;CAC9E;AAED,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;CAC7B"}
|
package/package.json
CHANGED
|
@@ -203,9 +203,9 @@ export const OnairosButton = forwardRef<OnairosButtonRef, OnairosButtonProps>(({
|
|
|
203
203
|
}
|
|
204
204
|
} catch (error) {
|
|
205
205
|
console.error('Error during button press flow:', error);
|
|
206
|
-
//
|
|
206
|
+
// Only call onRejection for actual errors, not when user cancels
|
|
207
|
+
// The onboarding component will handle user cancellation separately
|
|
207
208
|
setShowOnboarding(true);
|
|
208
|
-
onRejection?.(error instanceof Error ? error.message : 'Unknown error');
|
|
209
209
|
} finally {
|
|
210
210
|
setIsLoading(false);
|
|
211
211
|
}
|
|
@@ -348,4 +348,10 @@ const styles = StyleSheet.create({
|
|
|
348
348
|
fontWeight: '600',
|
|
349
349
|
textAlign: 'center',
|
|
350
350
|
},
|
|
351
|
-
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// Add displayName for better debugging
|
|
354
|
+
OnairosButton.displayName = 'OnairosButton';
|
|
355
|
+
|
|
356
|
+
// Ensure the component is properly exported
|
|
357
|
+
export default OnairosButton;
|
|
@@ -26,6 +26,11 @@ import { useConnections } from '../hooks/useConnections';
|
|
|
26
26
|
import { COLORS, DEEP_LINK_CONFIG } from '../constants';
|
|
27
27
|
import { initiateOAuth, initiateNativeAuth, hasNativeSDK, isOAuthCallback, testApiConnectivity } from '../services/platformAuthService';
|
|
28
28
|
import type { UniversalOnboardingProps, ConnectionStatus } from '../types';
|
|
29
|
+
import {
|
|
30
|
+
init as opacityInit,
|
|
31
|
+
OpacityEnvironment,
|
|
32
|
+
get as opacityGet,
|
|
33
|
+
} from '@opacity-labs/react-native-opacity';
|
|
29
34
|
|
|
30
35
|
const { height, width } = Dimensions.get('window');
|
|
31
36
|
|
|
@@ -56,6 +61,10 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
56
61
|
const [username, setUsername] = useState<string>('Avatar');
|
|
57
62
|
const [isConnectingPlatform, setIsConnectingPlatform] = useState<boolean>(false);
|
|
58
63
|
const [showLoginWebView, setShowLoginWebView] = useState<boolean>(false);
|
|
64
|
+
|
|
65
|
+
// Add refs for cleanup
|
|
66
|
+
const successTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
67
|
+
const isMountedRef = useRef<boolean>(true);
|
|
59
68
|
|
|
60
69
|
const platforms = [
|
|
61
70
|
{ id: 'instagram', name: 'Instagram', icon: require('../assets/images/instagram.png') },
|
|
@@ -73,6 +82,9 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
73
82
|
} = useConnections();
|
|
74
83
|
|
|
75
84
|
useEffect(() => {
|
|
85
|
+
// Set mounted flag
|
|
86
|
+
isMountedRef.current = true;
|
|
87
|
+
|
|
76
88
|
if (visible) {
|
|
77
89
|
loadInitialStatus();
|
|
78
90
|
// Animate in
|
|
@@ -97,12 +109,6 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
97
109
|
}
|
|
98
110
|
});
|
|
99
111
|
|
|
100
|
-
// Return cleanup function
|
|
101
|
-
return () => {
|
|
102
|
-
// Remove event listener using the subscription
|
|
103
|
-
subscription.remove();
|
|
104
|
-
};
|
|
105
|
-
|
|
106
112
|
// Initialize platform toggles
|
|
107
113
|
const initialToggles: { [key: string]: boolean } = {};
|
|
108
114
|
platforms.forEach((platform) => {
|
|
@@ -129,6 +135,12 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
129
135
|
[preferredPlatform]: { userName: `${preferredPlatform}_user`, connected: true }
|
|
130
136
|
}));
|
|
131
137
|
}
|
|
138
|
+
|
|
139
|
+
// Return cleanup function
|
|
140
|
+
return () => {
|
|
141
|
+
// Remove event listener using the subscription
|
|
142
|
+
subscription.remove();
|
|
143
|
+
};
|
|
132
144
|
} else {
|
|
133
145
|
// Animate out
|
|
134
146
|
Animated.timing(slideAnim, {
|
|
@@ -141,13 +153,38 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
141
153
|
}
|
|
142
154
|
}, [visible, preferredPlatform]);
|
|
143
155
|
|
|
156
|
+
// Cleanup effect for unmounting
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
return () => {
|
|
159
|
+
// Set mounted flag to false
|
|
160
|
+
isMountedRef.current = false;
|
|
161
|
+
|
|
162
|
+
// Clear any pending timeouts
|
|
163
|
+
if (successTimeoutRef.current) {
|
|
164
|
+
clearTimeout(successTimeoutRef.current);
|
|
165
|
+
successTimeoutRef.current = null;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}, []);
|
|
169
|
+
|
|
144
170
|
const handleClose = () => {
|
|
171
|
+
// Clear any pending timeouts before closing
|
|
172
|
+
if (successTimeoutRef.current) {
|
|
173
|
+
clearTimeout(successTimeoutRef.current);
|
|
174
|
+
successTimeoutRef.current = null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Set mounted flag to false
|
|
178
|
+
isMountedRef.current = false;
|
|
179
|
+
|
|
145
180
|
// Animate out and then call onClose
|
|
146
181
|
Animated.timing(slideAnim, {
|
|
147
182
|
toValue: height,
|
|
148
183
|
duration: 250,
|
|
149
184
|
useNativeDriver: true,
|
|
150
185
|
}).start(() => {
|
|
186
|
+
// Only call onClose if component is still meant to be mounted
|
|
187
|
+
// This prevents the "User closed onboarding" error
|
|
151
188
|
onClose();
|
|
152
189
|
});
|
|
153
190
|
};
|
|
@@ -176,6 +213,88 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
176
213
|
|
|
177
214
|
console.log('✅ API connectivity confirmed');
|
|
178
215
|
|
|
216
|
+
// Instagram: Use Opacity SDK exclusively
|
|
217
|
+
if (platformId === 'instagram') {
|
|
218
|
+
try {
|
|
219
|
+
console.log('🔌 Initializing Opacity SDK for Instagram...');
|
|
220
|
+
|
|
221
|
+
// Initialize Opacity SDK with your API key
|
|
222
|
+
const apiKey = 'OsamaTest-7bde2407-7360-462a-86b4-b26d7f890cbb';
|
|
223
|
+
|
|
224
|
+
await opacityInit({
|
|
225
|
+
apiKey,
|
|
226
|
+
environment: OpacityEnvironment.Production,
|
|
227
|
+
shouldShowErrorsInWebView: true,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
console.log('✅ Opacity SDK initialized successfully');
|
|
231
|
+
console.log('📱 Fetching Instagram profile...');
|
|
232
|
+
|
|
233
|
+
// Fetch Instagram profile using Opacity SDK
|
|
234
|
+
const profile = await opacityGet('flow:instagram:profile');
|
|
235
|
+
|
|
236
|
+
if (profile && typeof profile === 'object') {
|
|
237
|
+
console.log('✅ Instagram profile retrieved:', profile);
|
|
238
|
+
|
|
239
|
+
// Extract username from profile or use fallback
|
|
240
|
+
const instagramUsername = profile.username || profile.name || username;
|
|
241
|
+
|
|
242
|
+
// Update platform toggle state
|
|
243
|
+
setPlatformToggles(prev => ({
|
|
244
|
+
...prev,
|
|
245
|
+
[platformId]: true
|
|
246
|
+
}));
|
|
247
|
+
|
|
248
|
+
// Update connections state with Instagram data
|
|
249
|
+
setConnections(prev => ({
|
|
250
|
+
...prev,
|
|
251
|
+
[platformId]: {
|
|
252
|
+
userName: instagramUsername,
|
|
253
|
+
connected: true,
|
|
254
|
+
profileData: profile // Store additional profile data
|
|
255
|
+
}
|
|
256
|
+
}));
|
|
257
|
+
|
|
258
|
+
console.log(`✅ Instagram successfully connected for user: ${instagramUsername}`);
|
|
259
|
+
Alert.alert(
|
|
260
|
+
'Instagram Connected',
|
|
261
|
+
`Successfully connected to Instagram as ${instagramUsername} via Opacity SDK.`,
|
|
262
|
+
[{ text: 'OK', style: 'default' }]
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
return; // Exit early on success
|
|
266
|
+
} else {
|
|
267
|
+
throw new Error('Invalid or empty Instagram profile data returned from Opacity SDK');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
} catch (err) {
|
|
271
|
+
console.error('❌ Opacity SDK Instagram connection failed:', err);
|
|
272
|
+
|
|
273
|
+
// Provide user-friendly error messages
|
|
274
|
+
let errorMessage = 'Unknown error occurred';
|
|
275
|
+
if (err instanceof Error) {
|
|
276
|
+
if (err.message.includes('Initialize')) {
|
|
277
|
+
errorMessage = 'Failed to initialize Instagram connection. Please check your internet connection.';
|
|
278
|
+
} else if (err.message.includes('profile')) {
|
|
279
|
+
errorMessage = 'Unable to retrieve Instagram profile. Please try again or check your Instagram account permissions.';
|
|
280
|
+
} else {
|
|
281
|
+
errorMessage = err.message;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
Alert.alert(
|
|
286
|
+
'Instagram Connection Failed',
|
|
287
|
+
errorMessage,
|
|
288
|
+
[{ text: 'OK', style: 'default' }]
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
return; // Exit early on error
|
|
292
|
+
} finally {
|
|
293
|
+
setIsConnectingPlatform(false);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// For all other platforms (non-Instagram), use existing authentication methods
|
|
179
298
|
// Check if platform has a native SDK
|
|
180
299
|
if (hasNativeSDK(platformId)) {
|
|
181
300
|
console.log(`📱 Using native SDK for ${platformId}`);
|
|
@@ -367,9 +486,18 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
367
486
|
// Show success screen first
|
|
368
487
|
setStep('success');
|
|
369
488
|
|
|
489
|
+
// Clear any existing timeout
|
|
490
|
+
if (successTimeoutRef.current) {
|
|
491
|
+
clearTimeout(successTimeoutRef.current);
|
|
492
|
+
}
|
|
493
|
+
|
|
370
494
|
// After a delay, proceed to PIN
|
|
371
|
-
setTimeout(() => {
|
|
372
|
-
|
|
495
|
+
successTimeoutRef.current = setTimeout(() => {
|
|
496
|
+
// Only proceed if component is still mounted and visible
|
|
497
|
+
if (isMountedRef.current && visible) {
|
|
498
|
+
setStep('pin');
|
|
499
|
+
}
|
|
500
|
+
successTimeoutRef.current = null;
|
|
373
501
|
}, 3000);
|
|
374
502
|
};
|
|
375
503
|
|
|
@@ -137,10 +137,10 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
137
137
|
|
|
138
138
|
// Close the OAuth window after a short delay
|
|
139
139
|
setTimeout(() => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
if (onComplete) {
|
|
141
|
+
console.log('Calling onComplete to close OAuth window');
|
|
142
|
+
onComplete();
|
|
143
|
+
}
|
|
144
144
|
}, 1500);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
@@ -219,7 +219,7 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
219
219
|
}, 3000);
|
|
220
220
|
} else {
|
|
221
221
|
setError(errorMessage);
|
|
222
|
-
|
|
222
|
+
setIsLoading(false);
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
|
|
@@ -309,7 +309,7 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
309
309
|
</TouchableOpacity>
|
|
310
310
|
<TouchableOpacity style={styles.browserButton} onPress={handleOpenInBrowser}>
|
|
311
311
|
<Text style={styles.browserButtonText}>Open in Browser</Text>
|
|
312
|
-
|
|
312
|
+
</TouchableOpacity>
|
|
313
313
|
</View>
|
|
314
314
|
</View>
|
|
315
315
|
</SafeAreaView>
|
|
@@ -397,11 +397,11 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
397
397
|
</View>
|
|
398
398
|
)}
|
|
399
399
|
renderLoading={() => (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
400
|
+
<View style={styles.loadingContainer}>
|
|
401
|
+
<ActivityIndicator size="large" color={COLORS.primary} />
|
|
402
|
+
<Text style={styles.loadingText}>Loading {platform}...</Text>
|
|
403
|
+
</View>
|
|
404
|
+
)}
|
|
405
405
|
injectedJavaScript={`
|
|
406
406
|
// Prevent white screen issues
|
|
407
407
|
window.addEventListener('error', function(e) {
|
package/src/index.ts
CHANGED
|
@@ -3,38 +3,32 @@
|
|
|
3
3
|
* A React Native implementation for Onairos personalized data integration
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export { PinCreationScreen } from './components/screens/PinCreationScreen';
|
|
24
|
-
export { LoadingScreen } from './components/screens/LoadingScreen';
|
|
25
|
-
// export { SignInScreen } from './components/screens/SignInScreen';
|
|
6
|
+
// Export types first to avoid circular dependencies
|
|
7
|
+
export type {
|
|
8
|
+
OnairosButtonProps,
|
|
9
|
+
DataTier,
|
|
10
|
+
UniversalOnboardingProps,
|
|
11
|
+
ConnectionStatus,
|
|
12
|
+
PlatformListProps,
|
|
13
|
+
PinInputProps,
|
|
14
|
+
TrainingModalProps,
|
|
15
|
+
OAuthWebViewProps,
|
|
16
|
+
PlatformConfig,
|
|
17
|
+
ApiResponse,
|
|
18
|
+
CredentialsResult,
|
|
19
|
+
OverlayProps,
|
|
20
|
+
BiometricOptions,
|
|
21
|
+
PinRequirements,
|
|
22
|
+
} from './types';
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export { OnboardingHeader } from './components/onboarding/OnboardingHeader';
|
|
31
|
-
export { PinInput } from './components/onboarding/PinInput';
|
|
24
|
+
export type { StorageOptions, OnairosCredentials } from './utils/secureStorage';
|
|
25
|
+
export type { OAuthConfig } from './services/oauthService';
|
|
26
|
+
export type { ApiErrorType, ApiError } from './utils/onairosApi';
|
|
32
27
|
|
|
33
|
-
//
|
|
34
|
-
export {
|
|
35
|
-
export { useConnections } from './hooks/useConnections';
|
|
28
|
+
// Export constants
|
|
29
|
+
export { COLORS, PLATFORMS, API_ENDPOINTS, STORAGE_KEYS, PIN_REQUIREMENTS, DEEP_LINK_CONFIG } from './constants';
|
|
36
30
|
|
|
37
|
-
//
|
|
31
|
+
// Export utilities
|
|
38
32
|
export {
|
|
39
33
|
storeCredentials,
|
|
40
34
|
getCredentials,
|
|
@@ -67,7 +61,7 @@ export {
|
|
|
67
61
|
isDebugMode,
|
|
68
62
|
} from './utils/debugHelper';
|
|
69
63
|
|
|
70
|
-
//
|
|
64
|
+
// Export services
|
|
71
65
|
export {
|
|
72
66
|
connectPlatform,
|
|
73
67
|
disconnectPlatform,
|
|
@@ -76,52 +70,53 @@ export {
|
|
|
76
70
|
storePlatformConnection,
|
|
77
71
|
} from './services/oauthService';
|
|
78
72
|
|
|
79
|
-
//
|
|
80
|
-
export type {
|
|
81
|
-
OnairosButtonProps,
|
|
82
|
-
DataTier,
|
|
83
|
-
UniversalOnboardingProps,
|
|
84
|
-
ConnectionStatus,
|
|
85
|
-
PlatformListProps,
|
|
86
|
-
PinInputProps,
|
|
87
|
-
TrainingModalProps,
|
|
88
|
-
OAuthWebViewProps,
|
|
89
|
-
PlatformConfig,
|
|
90
|
-
ApiResponse,
|
|
91
|
-
CredentialsResult,
|
|
92
|
-
OverlayProps,
|
|
93
|
-
BiometricOptions,
|
|
94
|
-
PinRequirements,
|
|
95
|
-
} from './types';
|
|
96
|
-
|
|
97
|
-
export type { StorageOptions, OnairosCredentials } from './utils/secureStorage';
|
|
98
|
-
export type { OAuthConfig } from './services/oauthService';
|
|
99
|
-
export type { ApiErrorType, ApiError } from './utils/onairosApi';
|
|
100
|
-
|
|
101
|
-
// Constants
|
|
102
|
-
export { COLORS, PLATFORMS, API_ENDPOINTS, STORAGE_KEYS, PIN_REQUIREMENTS, DEEP_LINK_CONFIG } from './constants';
|
|
103
|
-
|
|
104
|
-
// API and Services
|
|
73
|
+
// Export API and Services
|
|
105
74
|
export { onairosApi } from './api';
|
|
106
75
|
export { OAuthService } from './services/oauthService';
|
|
107
76
|
export * from './utils/secureStorage';
|
|
108
77
|
export * from './utils/encryption';
|
|
109
78
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
import { PortalHost } from './utils/Portal';
|
|
79
|
+
// Export hooks
|
|
80
|
+
export { useCredentials } from './hooks/useCredentials';
|
|
81
|
+
export { useConnections } from './hooks/useConnections';
|
|
114
82
|
|
|
115
|
-
|
|
116
|
-
|
|
83
|
+
// Export Portal components
|
|
84
|
+
export { Portal, PortalHost } from './utils/Portal';
|
|
85
|
+
|
|
86
|
+
// Screen Components
|
|
87
|
+
export { ConnectorScreen } from './components/screens/ConnectorScreen';
|
|
88
|
+
export { PinCreationScreen } from './components/screens/PinCreationScreen';
|
|
89
|
+
export { LoadingScreen } from './components/screens/LoadingScreen';
|
|
90
|
+
|
|
91
|
+
// Onboarding Components
|
|
92
|
+
export { OAuthWebView } from './components/onboarding/OAuthWebView';
|
|
93
|
+
export { PlatformConnector } from './components/onboarding/PlatformConnector';
|
|
94
|
+
export { OnboardingHeader } from './components/onboarding/OnboardingHeader';
|
|
95
|
+
|
|
96
|
+
// Core Components - Export these last to avoid circular dependencies
|
|
97
|
+
export { PlatformList } from './components/PlatformList';
|
|
98
|
+
export { PinInput } from './components/PinInput';
|
|
99
|
+
export { TrainingModal } from './components/TrainingModal';
|
|
100
|
+
export { Overlay } from './components/Overlay';
|
|
101
|
+
export { UniversalOnboarding } from './components/UniversalOnboarding';
|
|
102
|
+
export { OnairosButton } from './components/OnairosButton';
|
|
103
|
+
export { Onairos } from './components/Onairos';
|
|
117
104
|
|
|
118
105
|
// Define the public components for default export
|
|
106
|
+
import * as React from 'react';
|
|
107
|
+
import { Onairos } from './components/Onairos';
|
|
108
|
+
import { OnairosButton } from './components/OnairosButton';
|
|
109
|
+
import { Overlay } from './components/Overlay';
|
|
110
|
+
import { UniversalOnboarding } from './components/UniversalOnboarding';
|
|
111
|
+
import { PortalHost } from './utils/Portal';
|
|
112
|
+
|
|
113
|
+
// Simple default export object - main types are available through named exports
|
|
119
114
|
const components = {
|
|
120
|
-
Onairos: Onairos as
|
|
121
|
-
OnairosButton: OnairosButton,
|
|
122
|
-
OnairosOverlay: Overlay as
|
|
123
|
-
UniversalOnboarding: UniversalOnboarding as
|
|
124
|
-
PortalHost: PortalHost,
|
|
115
|
+
Onairos: Onairos as any,
|
|
116
|
+
OnairosButton: OnairosButton as any,
|
|
117
|
+
OnairosOverlay: Overlay as any,
|
|
118
|
+
UniversalOnboarding: UniversalOnboarding as any,
|
|
119
|
+
PortalHost: PortalHost as any,
|
|
125
120
|
};
|
|
126
121
|
|
|
127
122
|
// Export the components as the default export
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare module '@opacity-labs/react-native-opacity' {
|
|
2
|
+
export enum OpacityEnvironment {
|
|
3
|
+
Production = 'production',
|
|
4
|
+
Development = 'development',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface OpacityInitConfig {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
environment: OpacityEnvironment;
|
|
10
|
+
shouldShowErrorsInWebView?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function init(config: OpacityInitConfig): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export function get(flow: string): Promise<any>;
|
|
16
|
+
}
|
package/src/types.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -81,7 +81,9 @@ export interface OnairosButtonProps {
|
|
|
81
81
|
/** Whether the button is enabled */
|
|
82
82
|
enabled?: boolean;
|
|
83
83
|
/** Button form style */
|
|
84
|
-
buttonForm?: 'default' | 'login' | 'signup';
|
|
84
|
+
buttonForm?: 'default' | 'login' | 'signup' | 'connect';
|
|
85
|
+
/** If true, makes API call automatically and returns result without showing UI */
|
|
86
|
+
auto?: boolean;
|
|
85
87
|
/** Called when authentication is rejected */
|
|
86
88
|
onRejection?: (error?: string) => void;
|
|
87
89
|
/** Called when authentication is completed successfully */
|
|
@@ -94,6 +96,8 @@ export interface OnairosButtonProps {
|
|
|
94
96
|
swerv?: boolean;
|
|
95
97
|
/** Enable debug logging */
|
|
96
98
|
debug?: boolean;
|
|
99
|
+
/** Enable dark mode styling */
|
|
100
|
+
darkMode?: boolean;
|
|
97
101
|
/** Preferred platform to highlight */
|
|
98
102
|
preferredPlatform?: string;
|
|
99
103
|
/** Whether to use test mode */
|