@onairos/react-native 3.0.1 → 3.0.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/lib/commonjs/api/index.js +105 -86
- package/lib/commonjs/api/index.js.map +1 -1
- package/lib/commonjs/components/OnairosButton.js +20 -12
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +18 -0
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/secureStorage.js +129 -42
- package/lib/commonjs/utils/secureStorage.js.map +1 -1
- package/lib/module/api/index.js +105 -86
- package/lib/module/api/index.js.map +1 -1
- package/lib/module/components/OnairosButton.js +21 -13
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +19 -1
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/utils/secureStorage.js +129 -42
- package/lib/module/utils/secureStorage.js.map +1 -1
- package/package.json +1 -1
- package/src/api/index.ts +86 -101
- package/src/components/OnairosButton.tsx +22 -13
- package/src/components/UniversalOnboarding.tsx +13 -0
- package/src/index.ts +1 -2
- package/src/utils/secureStorage.ts +140 -57
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { View, Text, StyleSheet, TouchableOpacity, Dimensions } from 'react-native';
|
|
2
|
+
import { View, Text, StyleSheet, TouchableOpacity, Dimensions, Platform } from 'react-native';
|
|
3
3
|
import BottomSheet from '@gorhom/bottom-sheet';
|
|
4
4
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
5
5
|
import { PlatformList } from './PlatformList';
|
|
@@ -42,6 +42,24 @@ export const UniversalOnboarding = ({
|
|
|
42
42
|
var _bottomSheetRef$curre;
|
|
43
43
|
(_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 || _bottomSheetRef$curre.expand();
|
|
44
44
|
loadInitialStatus();
|
|
45
|
+
|
|
46
|
+
// Debug mode for Expo Go
|
|
47
|
+
if (debug || Platform.OS === 'web') {
|
|
48
|
+
console.log('Debug mode enabled - Using mock data for onboarding');
|
|
49
|
+
// Pre-populate with mock connections in debug mode
|
|
50
|
+
if (test || Platform.OS === 'web') {
|
|
51
|
+
setConnections({
|
|
52
|
+
instagram: {
|
|
53
|
+
userName: 'instagram_user',
|
|
54
|
+
connected: true
|
|
55
|
+
},
|
|
56
|
+
youtube: {
|
|
57
|
+
userName: 'youtube_user',
|
|
58
|
+
connected: true
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
45
63
|
} else {
|
|
46
64
|
var _bottomSheetRef$curre2;
|
|
47
65
|
(_bottomSheetRef$curre2 = bottomSheetRef.current) === null || _bottomSheetRef$curre2 === void 0 || _bottomSheetRef$curre2.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useMemo","useRef","useState","View","Text","StyleSheet","TouchableOpacity","Dimensions","BottomSheet","Icon","PlatformList","PinInput","TrainingModal","useConnections","COLORS","height","get","UniversalOnboarding","visible","onClose","AppName","requestData","returnLink","onComplete","embedd","debug","test","bottomSheetRef","step","setStep","connections","setConnections","pin","setPin","selectedTier","setSelectedTier","training","setTraining","progress","eta","connectPlatform","disconnectPlatform","getConnectionStatus","isConnecting","snapPoints","_bottomSheetRef$curre","current","expand","loadInitialStatus","_bottomSheetRef$curre2","close","status","handlePlatformToggle","platform","connect","error","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useMemo","useRef","useState","View","Text","StyleSheet","TouchableOpacity","Dimensions","Platform","BottomSheet","Icon","PlatformList","PinInput","TrainingModal","useConnections","COLORS","height","get","UniversalOnboarding","visible","onClose","AppName","requestData","returnLink","onComplete","embedd","debug","test","bottomSheetRef","step","setStep","connections","setConnections","pin","setPin","selectedTier","setSelectedTier","training","setTraining","progress","eta","connectPlatform","disconnectPlatform","getConnectionStatus","isConnecting","snapPoints","_bottomSheetRef$curre","current","expand","loadInitialStatus","OS","console","log","instagram","userName","connected","youtube","_bottomSheetRef$curre2","close","status","handlePlatformToggle","platform","connect","error","handlePinSubmit","userPin","interval","setInterval","Math","round","clearInterval","tierData","canProceedToPin","connectedPlatforms","Object","values","filter","Boolean","length","renderHeader","createElement","style","styles","header","name","size","color","primary","headerTitle","onPress","closeButton","renderContent","onToggle","isLoading","canProceed","onProceed","onSubmit","minLength","requireSpecialChar","requireNumber","onCancel","ref","enablePanDownToClose","index","container","create","flex","backgroundColor","flexDirection","alignItems","padding","headerBg","borderTopLeftRadius","borderTopRightRadius","fontSize","fontWeight","marginLeft"],"sourceRoot":"..\\..\\..\\src","sources":["components/UniversalOnboarding.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAChF,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,gBAAgB,EAEhBC,UAAU,EACVC,QAAQ,QACH,cAAc;AACrB,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,IAAI,MAAM,yCAAyC;AAC1D,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,MAAM,QAAQ,cAAc;AAGrC,MAAM;EAAEC;AAAO,CAAC,GAAGT,UAAU,CAACU,GAAG,CAAC,QAAQ,CAAC;AAE3C,OAAO,MAAMC,mBAAuD,GAAGA,CAAC;EACtEC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,WAAW;EACXC,UAAU;EACVC,UAAU;EACVC,MAAM,GAAG,KAAK;EACdC,KAAK,GAAG,KAAK;EACbC,IAAI,GAAG;AACT,CAAC,KAAK;EACJ,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EACDxB,MAAM,EAAE;IACNyB,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,OAAO,EAAE,EAAE;IACXH,eAAe,EAAE5F,MAAM,CAACgG,QAAQ;IAChCC,mBAAmB,EAAE,EAAE;IACvBC,oBAAoB,EAAE;EACxB,CAAC;EACDzB,WAAW,EAAE;IACXkB,IAAI,EAAE,CAAC;IACPQ,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBC,UAAU,EAAE,EAAE;IACd9B,KAAK,EAAE;EACT,CAAC;EACDI,WAAW,EAAE;IACXoB,OAAO,EAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,15 +1,110 @@
|
|
|
1
|
+
import * as Keychain from 'react-native-keychain';
|
|
1
2
|
import { Platform } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { STORAGE_KEYS } from '../constants';
|
|
4
|
+
|
|
5
|
+
// Define OnairosCredentials interface locally to avoid circular dependencies
|
|
6
|
+
|
|
7
|
+
// Create a mock storage for environments without Keychain access (like Expo Go)
|
|
8
|
+
const mockStorage = {};
|
|
9
|
+
|
|
10
|
+
// Check if running in Expo Go or environments without native module access
|
|
11
|
+
const isKeychainAvailable = () => {
|
|
12
|
+
try {
|
|
13
|
+
return typeof Keychain.getGenericPassword === 'function';
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Wrapper for getGenericPassword that falls back to mock storage
|
|
20
|
+
const safeGetGenericPassword = async options => {
|
|
21
|
+
try {
|
|
22
|
+
if (isKeychainAvailable()) {
|
|
23
|
+
return await Keychain.getGenericPassword(options);
|
|
24
|
+
} else {
|
|
25
|
+
// Fall back to mock storage in memory
|
|
26
|
+
const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
|
|
27
|
+
return mockStorage[key] || null;
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.warn('Keychain access failed, using mock storage', error);
|
|
31
|
+
// Fall back to mock storage on error
|
|
32
|
+
const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
|
|
33
|
+
return mockStorage[key] || null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Wrapper for setGenericPassword that falls back to mock storage
|
|
38
|
+
const safeSetGenericPassword = async (username, password, options) => {
|
|
39
|
+
try {
|
|
40
|
+
if (isKeychainAvailable()) {
|
|
41
|
+
return await Keychain.setGenericPassword(username, password, options);
|
|
42
|
+
} else {
|
|
43
|
+
// Fall back to mock storage in memory
|
|
44
|
+
const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
|
|
45
|
+
mockStorage[key] = {
|
|
46
|
+
username,
|
|
47
|
+
password
|
|
48
|
+
};
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.warn('Keychain access failed, using mock storage', error);
|
|
53
|
+
// Fall back to mock storage on error
|
|
54
|
+
const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
|
|
55
|
+
mockStorage[key] = {
|
|
56
|
+
username,
|
|
57
|
+
password
|
|
58
|
+
};
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Wrapper for resetGenericPassword that falls back to mock storage
|
|
64
|
+
const safeResetGenericPassword = async options => {
|
|
65
|
+
try {
|
|
66
|
+
if (isKeychainAvailable()) {
|
|
67
|
+
return await Keychain.resetGenericPassword(options);
|
|
68
|
+
} else {
|
|
69
|
+
// Fall back to mock storage in memory
|
|
70
|
+
const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
|
|
71
|
+
delete mockStorage[key];
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.warn('Keychain access failed, using mock storage', error);
|
|
76
|
+
// Fall back to mock storage on error
|
|
77
|
+
const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
|
|
78
|
+
delete mockStorage[key];
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
5
82
|
|
|
6
83
|
/**
|
|
7
84
|
* Store credentials in memory (temporary solution)
|
|
8
85
|
*/
|
|
9
|
-
export const storeCredentials = async
|
|
86
|
+
export const storeCredentials = async credentials => {
|
|
10
87
|
try {
|
|
11
|
-
|
|
12
|
-
|
|
88
|
+
const existingCredentials = await getCredentials();
|
|
89
|
+
const updatedCredentials = {
|
|
90
|
+
...existingCredentials,
|
|
91
|
+
...credentials,
|
|
92
|
+
createdAt: (existingCredentials === null || existingCredentials === void 0 ? void 0 : existingCredentials.createdAt) || Date.now()
|
|
93
|
+
};
|
|
94
|
+
const username = updatedCredentials.username;
|
|
95
|
+
if (!username) {
|
|
96
|
+
throw new Error('Username is required for storing credentials');
|
|
97
|
+
}
|
|
98
|
+
const options = {
|
|
99
|
+
service: STORAGE_KEYS.credentials
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Only use secure storage options on real devices
|
|
103
|
+
if (Platform.OS !== 'web' && isKeychainAvailable()) {
|
|
104
|
+
options.accessControl = Keychain.ACCESS_CONTROL.BIOMETRY_ANY_OR_DEVICE_PASSCODE;
|
|
105
|
+
options.accessible = Keychain.ACCESSIBLE.WHEN_UNLOCKED;
|
|
106
|
+
}
|
|
107
|
+
await safeSetGenericPassword(username, JSON.stringify(updatedCredentials), options);
|
|
13
108
|
return true;
|
|
14
109
|
} catch (error) {
|
|
15
110
|
console.error('Error storing credentials:', error);
|
|
@@ -20,16 +115,17 @@ export const storeCredentials = async (credentials, options = {}) => {
|
|
|
20
115
|
/**
|
|
21
116
|
* Retrieve credentials from memory (temporary solution)
|
|
22
117
|
*/
|
|
23
|
-
export const getCredentials = async (
|
|
118
|
+
export const getCredentials = async () => {
|
|
24
119
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
120
|
+
const credentials = await safeGetGenericPassword({
|
|
121
|
+
service: STORAGE_KEYS.credentials
|
|
122
|
+
});
|
|
123
|
+
if (credentials) {
|
|
124
|
+
return JSON.parse(credentials.password);
|
|
29
125
|
}
|
|
30
|
-
return
|
|
126
|
+
return null;
|
|
31
127
|
} catch (error) {
|
|
32
|
-
console.error('Error
|
|
128
|
+
console.error('Error getting credentials:', error);
|
|
33
129
|
return null;
|
|
34
130
|
}
|
|
35
131
|
};
|
|
@@ -39,9 +135,12 @@ export const getCredentials = async (options = {}) => {
|
|
|
39
135
|
*/
|
|
40
136
|
export const hasCredentials = async () => {
|
|
41
137
|
try {
|
|
42
|
-
|
|
138
|
+
const credentials = await safeGetGenericPassword({
|
|
139
|
+
service: STORAGE_KEYS.credentials
|
|
140
|
+
});
|
|
141
|
+
return !!credentials;
|
|
43
142
|
} catch (error) {
|
|
44
|
-
console.error('Error checking
|
|
143
|
+
console.error('Error checking credentials:', error);
|
|
45
144
|
return false;
|
|
46
145
|
}
|
|
47
146
|
};
|
|
@@ -51,7 +150,9 @@ export const hasCredentials = async () => {
|
|
|
51
150
|
*/
|
|
52
151
|
export const deleteCredentials = async () => {
|
|
53
152
|
try {
|
|
54
|
-
|
|
153
|
+
await safeResetGenericPassword({
|
|
154
|
+
service: STORAGE_KEYS.credentials
|
|
155
|
+
});
|
|
55
156
|
return true;
|
|
56
157
|
} catch (error) {
|
|
57
158
|
console.error('Error deleting credentials:', error);
|
|
@@ -62,43 +163,29 @@ export const deleteCredentials = async () => {
|
|
|
62
163
|
/**
|
|
63
164
|
* Update specific fields in the stored credentials
|
|
64
165
|
*/
|
|
65
|
-
export const updateCredentials = async
|
|
66
|
-
|
|
67
|
-
const currentCredentials = await getCredentials(options);
|
|
68
|
-
if (!currentCredentials) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
const updatedCredentials = {
|
|
72
|
-
...currentCredentials,
|
|
73
|
-
...updates
|
|
74
|
-
};
|
|
75
|
-
return await storeCredentials(updatedCredentials, options);
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error('Error updating credentials:', error);
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
166
|
+
export const updateCredentials = async credentials => {
|
|
167
|
+
return storeCredentials(credentials);
|
|
80
168
|
};
|
|
81
169
|
|
|
82
170
|
/**
|
|
83
171
|
* Generate a device-specific unique username
|
|
84
172
|
*/
|
|
85
|
-
export const generateDeviceUsername =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const username = `onairos_${sha256(deviceInfo).substring(0, 10)}`;
|
|
89
|
-
return username;
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error('Error generating device username:', error);
|
|
92
|
-
return `onairos_${Date.now().toString(36)}`;
|
|
93
|
-
}
|
|
173
|
+
export const generateDeviceUsername = () => {
|
|
174
|
+
const randomId = Math.random().toString(36).substring(2, 10);
|
|
175
|
+
return `dev_${randomId}`;
|
|
94
176
|
};
|
|
95
177
|
|
|
96
178
|
/**
|
|
97
179
|
* Verify credentials (temporary mock implementation)
|
|
98
180
|
*/
|
|
99
|
-
export const verifyCredentials = async
|
|
181
|
+
export const verifyCredentials = async username => {
|
|
100
182
|
try {
|
|
101
|
-
|
|
183
|
+
// For Expo Go or development, always return true
|
|
184
|
+
if (!isKeychainAvailable()) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// TODO: Implement actual verification with API
|
|
102
189
|
return true;
|
|
103
190
|
} catch (error) {
|
|
104
191
|
console.error('Error verifying credentials:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","
|
|
1
|
+
{"version":3,"names":["Keychain","Platform","STORAGE_KEYS","mockStorage","isKeychainAvailable","getGenericPassword","e","safeGetGenericPassword","options","key","service","error","console","warn","safeSetGenericPassword","username","password","setGenericPassword","safeResetGenericPassword","resetGenericPassword","storeCredentials","credentials","existingCredentials","getCredentials","updatedCredentials","createdAt","Date","now","Error","OS","accessControl","ACCESS_CONTROL","BIOMETRY_ANY_OR_DEVICE_PASSCODE","accessible","ACCESSIBLE","WHEN_UNLOCKED","JSON","stringify","parse","hasCredentials","deleteCredentials","updateCredentials","generateDeviceUsername","randomId","Math","random","toString","substring","verifyCredentials"],"sourceRoot":"..\\..\\..\\src","sources":["utils/secureStorage.ts"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,uBAAuB;AACjD,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,YAAY,QAAQ,cAAc;;AAE3C;;AAqBA;AACA,MAAMC,WAAmE,GAAG,CAAC,CAAC;;AAE9E;AACA,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EAChC,IAAI;IACF,OAAO,OAAOJ,QAAQ,CAACK,kBAAkB,KAAK,UAAU;EAC1D,CAAC,CAAC,OAAOC,CAAC,EAAE;IACV,OAAO,KAAK;EACd;AACF,CAAC;;AAED;AACA,MAAMC,sBAAsB,GAAG,MAAOC,OAAyB,IAAK;EAClE,IAAI;IACF,IAAIJ,mBAAmB,CAAC,CAAC,EAAE;MACzB,OAAO,MAAMJ,QAAQ,CAACK,kBAAkB,CAACG,OAAO,CAAC;IACnD,CAAC,MAAM;MACL;MACA,MAAMC,GAAG,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,OAAO,KAAI,SAAS;MACzC,OAAOP,WAAW,CAACM,GAAG,CAAC,IAAI,IAAI;IACjC;EACF,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,4CAA4C,EAAEF,KAAK,CAAC;IACjE;IACA,MAAMF,GAAG,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,OAAO,KAAI,SAAS;IACzC,OAAOP,WAAW,CAACM,GAAG,CAAC,IAAI,IAAI;EACjC;AACF,CAAC;;AAED;AACA,MAAMK,sBAAsB,GAAG,MAAAA,CAC7BC,QAAgB,EAChBC,QAAgB,EAChBR,OAA0B,KACvB;EACH,IAAI;IACF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AMK,iBAAiB,GAAG,MAAOjC,QAAgB,IAAuB;EAC7E,IAAI;IACF;IACA,IAAI,CAACX,mBAAmB,CAAC,CAAC,EAAE;MAC1B,OAAO,IAAI;IACb;;IAEA;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,8BAA8B,EAAEA,KAAK,CAAC;IACpD,OAAO,KAAK;EACd;AACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -1,126 +1,111 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
1
|
+
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { API_ENDPOINTS } from '../constants';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
// Check if running in development mode
|
|
6
|
+
const isDevelopmentMode = () => {
|
|
7
|
+
return __DEV__ || process.env.NODE_ENV === 'development';
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Create mock response helper
|
|
11
|
+
const createMockResponse = (data: any) => {
|
|
12
|
+
return Promise.resolve({ data });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Create API instance
|
|
16
|
+
const apiInstance: AxiosInstance = axios.create({
|
|
17
|
+
baseURL: API_ENDPOINTS.base,
|
|
18
|
+
timeout: 10000,
|
|
19
|
+
headers: {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
'Accept': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Add error handling interceptor
|
|
26
|
+
apiInstance.interceptors.response.use(
|
|
27
|
+
(response) => response,
|
|
28
|
+
(error) => {
|
|
29
|
+
if (isDevelopmentMode()) {
|
|
30
|
+
console.warn('API error in development mode, using fallback:', error);
|
|
31
|
+
return createMockResponse({ success: true, data: { mockData: true } });
|
|
32
|
+
}
|
|
33
|
+
return Promise.reject(error);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// API service with Expo compatibility
|
|
6
38
|
export const onairosApi = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Make a GET request to the API
|
|
11
|
-
* @param endpoint The endpoint to request
|
|
12
|
-
* @returns The response data
|
|
13
|
-
*/
|
|
14
|
-
get: async (endpoint: string) => {
|
|
39
|
+
// Core API methods with fallbacks
|
|
40
|
+
async get(url: string) {
|
|
15
41
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
42
|
+
if (Platform.OS === 'web' && isDevelopmentMode()) {
|
|
43
|
+
return createMockResponse({ success: true, data: { mockData: true } });
|
|
44
|
+
}
|
|
45
|
+
return await apiInstance.get(url);
|
|
18
46
|
} catch (error) {
|
|
19
|
-
console.error(`GET ${
|
|
47
|
+
console.error(`GET ${url} error:`, error);
|
|
48
|
+
if (isDevelopmentMode()) {
|
|
49
|
+
return createMockResponse({ success: true, data: { mockData: true } });
|
|
50
|
+
}
|
|
20
51
|
throw error;
|
|
21
52
|
}
|
|
22
53
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Make a POST request to the API
|
|
26
|
-
* @param endpoint The endpoint to request
|
|
27
|
-
* @param data The data to send
|
|
28
|
-
* @returns The response data
|
|
29
|
-
*/
|
|
30
|
-
post: async (endpoint: string, data: any) => {
|
|
54
|
+
|
|
55
|
+
async post(url: string, data: any) {
|
|
31
56
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
);
|
|
36
|
-
return response.data;
|
|
57
|
+
if (Platform.OS === 'web' && isDevelopmentMode()) {
|
|
58
|
+
return createMockResponse({ success: true, data: { mockData: true } });
|
|
59
|
+
}
|
|
60
|
+
return await apiInstance.post(url, data);
|
|
37
61
|
} catch (error) {
|
|
38
|
-
console.error(`POST ${
|
|
62
|
+
console.error(`POST ${url} error:`, error);
|
|
63
|
+
if (isDevelopmentMode()) {
|
|
64
|
+
return createMockResponse({ success: true, data: { mockData: true } });
|
|
65
|
+
}
|
|
39
66
|
throw error;
|
|
40
67
|
}
|
|
41
68
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* @returns The server's public key
|
|
46
|
-
*/
|
|
47
|
-
getServerPublicKey: async () => {
|
|
48
|
-
try {
|
|
49
|
-
const response = await onairosApi.get('public/getPublicKey');
|
|
50
|
-
return response.publicKey;
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error('Error getting server public key:', error);
|
|
53
|
-
return '';
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Validate credentials with the server
|
|
59
|
-
* @param username The username to validate
|
|
60
|
-
* @returns Whether the credentials are valid
|
|
61
|
-
*/
|
|
62
|
-
validateCredentials: async (username: string) => {
|
|
69
|
+
|
|
70
|
+
// Helper methods for specific API endpoints
|
|
71
|
+
async validateCredentials(username: string) {
|
|
63
72
|
try {
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
if (isDevelopmentMode()) {
|
|
74
|
+
console.log('Using mock validation for:', username);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const response = await this.post('validate', { username });
|
|
79
|
+
return response.data?.success || false;
|
|
66
80
|
} catch (error) {
|
|
67
81
|
console.error('Error validating credentials:', error);
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get account information for a user
|
|
74
|
-
* @param username The username to get account info for
|
|
75
|
-
* @returns The account information
|
|
76
|
-
*/
|
|
77
|
-
getAccountInfo: async (username: string) => {
|
|
78
|
-
try {
|
|
79
|
-
const response = await onairosApi.post('getAccountInfo', {
|
|
80
|
-
Info: { username }
|
|
81
|
-
});
|
|
82
|
-
return response.AccountInfo;
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.error('Error getting account info:', error);
|
|
85
|
-
return null;
|
|
82
|
+
return isDevelopmentMode(); // Return true in dev mode to allow flow to continue
|
|
86
83
|
}
|
|
87
84
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* Get API URL and token for a user
|
|
91
|
-
* @param params The parameters for the request
|
|
92
|
-
* @returns The API URL and token
|
|
93
|
-
*/
|
|
94
|
-
getApiUrl: async (params: {
|
|
95
|
-
appId: string;
|
|
96
|
-
username: string;
|
|
97
|
-
encryptedModelKey: string;
|
|
98
|
-
confirmations: { [key: string]: boolean };
|
|
99
|
-
}) => {
|
|
85
|
+
|
|
86
|
+
async getUserProfile(token: string) {
|
|
100
87
|
try {
|
|
101
|
-
|
|
102
|
-
Info: {
|
|
103
|
-
storage: 'local',
|
|
104
|
-
appId: params.appId,
|
|
105
|
-
confirmations: params.confirmations,
|
|
106
|
-
developerURL: 'devURL',
|
|
107
|
-
EncryptedUserPin: params.encryptedModelKey,
|
|
108
|
-
account: params.username,
|
|
109
|
-
proofMode: false,
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
if (response && response.apiUrl && response.token) {
|
|
88
|
+
if (isDevelopmentMode()) {
|
|
114
89
|
return {
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
username: 'demo_user',
|
|
91
|
+
platforms: ['instagram', 'youtube'],
|
|
92
|
+
createdAt: Date.now(),
|
|
117
93
|
};
|
|
118
|
-
} else {
|
|
119
|
-
throw new Error('Invalid response from getAPIUrlMobile');
|
|
120
94
|
}
|
|
95
|
+
|
|
96
|
+
apiInstance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
97
|
+
const response = await this.get('user/profile');
|
|
98
|
+
return response.data?.data;
|
|
121
99
|
} catch (error) {
|
|
122
|
-
console.error('Error
|
|
100
|
+
console.error('Error fetching user profile:', error);
|
|
101
|
+
if (isDevelopmentMode()) {
|
|
102
|
+
return {
|
|
103
|
+
username: 'demo_user',
|
|
104
|
+
platforms: ['instagram', 'youtube'],
|
|
105
|
+
createdAt: Date.now(),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
123
108
|
throw error;
|
|
124
109
|
}
|
|
125
|
-
}
|
|
110
|
+
},
|
|
126
111
|
};
|
|
@@ -57,6 +57,7 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
57
57
|
const shouldProceed = await preCheck();
|
|
58
58
|
if (!shouldProceed) {
|
|
59
59
|
onRejection?.('Precheck validation failed');
|
|
60
|
+
setIsLoading(false);
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
@@ -68,33 +69,41 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
68
69
|
// If credentials exist, fetch them and verify
|
|
69
70
|
const credentials = await getCredentials();
|
|
70
71
|
|
|
71
|
-
if (!credentials || !credentials.username
|
|
72
|
+
if (!credentials || !credentials.username) {
|
|
72
73
|
// Invalid credentials, clear and start fresh
|
|
73
74
|
await clearCredentials();
|
|
74
75
|
setShowOnboarding(true);
|
|
76
|
+
setIsLoading(false);
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
try {
|
|
81
|
+
// Validate credentials with server - catch errors here to prevent crashing
|
|
82
|
+
const isValid = await onairosApi.validateCredentials(credentials.username);
|
|
83
|
+
|
|
84
|
+
if (!isValid) {
|
|
85
|
+
// Clear invalid credentials
|
|
86
|
+
await clearCredentials();
|
|
87
|
+
setShowOnboarding(true);
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Store and display overlay with valid credentials
|
|
93
|
+
setStoredCredentials(credentials);
|
|
94
|
+
setShowOverlay(true);
|
|
95
|
+
} catch (validationError) {
|
|
96
|
+
console.warn('Validation error, proceeding to onboarding:', validationError);
|
|
84
97
|
setShowOnboarding(true);
|
|
85
|
-
return;
|
|
86
98
|
}
|
|
87
|
-
|
|
88
|
-
// Store and display overlay with valid credentials
|
|
89
|
-
setStoredCredentials(credentials);
|
|
90
|
-
setShowOverlay(true);
|
|
91
99
|
} else {
|
|
92
100
|
// If no credentials, show onboarding
|
|
93
101
|
setShowOnboarding(true);
|
|
94
102
|
}
|
|
95
103
|
} catch (error) {
|
|
96
104
|
console.error('Error during button press flow:', error);
|
|
97
|
-
|
|
105
|
+
// Fall back to onboarding on error
|
|
106
|
+
setShowOnboarding(true);
|
|
98
107
|
onRejection?.(error instanceof Error ? error.message : 'Unknown error');
|
|
99
108
|
} finally {
|
|
100
109
|
setIsLoading(false);
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
TouchableOpacity,
|
|
7
7
|
ActivityIndicator,
|
|
8
8
|
Dimensions,
|
|
9
|
+
Platform,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import BottomSheet from '@gorhom/bottom-sheet';
|
|
11
12
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
@@ -52,6 +53,18 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
52
53
|
if (visible) {
|
|
53
54
|
bottomSheetRef.current?.expand();
|
|
54
55
|
loadInitialStatus();
|
|
56
|
+
|
|
57
|
+
// Debug mode for Expo Go
|
|
58
|
+
if (debug || Platform.OS === 'web') {
|
|
59
|
+
console.log('Debug mode enabled - Using mock data for onboarding');
|
|
60
|
+
// Pre-populate with mock connections in debug mode
|
|
61
|
+
if (test || Platform.OS === 'web') {
|
|
62
|
+
setConnections({
|
|
63
|
+
instagram: { userName: 'instagram_user', connected: true },
|
|
64
|
+
youtube: { userName: 'youtube_user', connected: true },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
55
68
|
} else {
|
|
56
69
|
bottomSheetRef.current?.close();
|
|
57
70
|
}
|
package/src/index.ts
CHANGED
|
@@ -72,7 +72,6 @@ export type {
|
|
|
72
72
|
DataTier,
|
|
73
73
|
UniversalOnboardingProps,
|
|
74
74
|
ConnectionStatus,
|
|
75
|
-
OnairosCredentials,
|
|
76
75
|
PlatformListProps,
|
|
77
76
|
PinInputProps,
|
|
78
77
|
TrainingModalProps,
|
|
@@ -81,7 +80,7 @@ export type {
|
|
|
81
80
|
ApiResponse,
|
|
82
81
|
} from './types';
|
|
83
82
|
|
|
84
|
-
export type { StorageOptions } from './utils/secureStorage';
|
|
83
|
+
export type { StorageOptions, OnairosCredentials } from './utils/secureStorage';
|
|
85
84
|
export type { OAuthConfig } from './services/oauthService';
|
|
86
85
|
export type { ApiErrorType, ApiError } from './utils/onairosApi';
|
|
87
86
|
|