@onairos/react-native 2.0.6 → 2.0.9
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 +13 -15
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/Overlay.js +8 -15
- package/lib/commonjs/components/Overlay.js.map +1 -1
- package/lib/commonjs/hooks/useConnections.js +18 -36
- package/lib/commonjs/hooks/useConnections.js.map +1 -1
- package/lib/commonjs/utils/secureStorage.js +14 -103
- package/lib/commonjs/utils/secureStorage.js.map +1 -1
- package/lib/module/components/OnairosButton.js +13 -15
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/Overlay.js +8 -13
- package/lib/module/components/Overlay.js.map +1 -1
- package/lib/module/hooks/useConnections.js +19 -37
- package/lib/module/hooks/useConnections.js.map +1 -1
- package/lib/module/utils/secureStorage.js +14 -102
- package/lib/module/utils/secureStorage.js.map +1 -1
- package/package.json +1 -1
- package/src/components/OnairosButton.tsx +3 -15
- package/src/components/Overlay.tsx +8 -13
- package/src/hooks/useConnections.ts +26 -44
- package/src/utils/secureStorage.ts +14 -104
|
@@ -2,7 +2,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { useState, useEffect } from 'react';
|
|
3
3
|
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Alert, Platform } from 'react-native';
|
|
4
4
|
import { BottomSheetModal, BottomSheetBackdrop } from '@gorhom/bottom-sheet';
|
|
5
|
-
import DeviceInfo from 'react-native-device-info';
|
|
5
|
+
// import DeviceInfo from 'react-native-device-info'; // Comment out device info import
|
|
6
6
|
import { COLORS } from '../constants';
|
|
7
7
|
import { onairosApi } from '../api';
|
|
8
8
|
import { encryptModelKey, getServerPublicKey } from '../utils/encryption';
|
|
@@ -42,17 +42,12 @@ export const Overlay = ({
|
|
|
42
42
|
};
|
|
43
43
|
const confirmSelection = async () => {
|
|
44
44
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
default: 'unknown'
|
|
52
|
-
});
|
|
53
|
-
} catch (e) {
|
|
54
|
-
console.warn('Failed to get app identifier:', e);
|
|
55
|
-
}
|
|
45
|
+
// Mock app identifier
|
|
46
|
+
const appId = Platform.select({
|
|
47
|
+
ios: 'com.onairos.mock',
|
|
48
|
+
android: 'com.onairos.mock',
|
|
49
|
+
default: 'unknown'
|
|
50
|
+
});
|
|
56
51
|
const serverPublicKey = await getServerPublicKey();
|
|
57
52
|
const encryptedModelKey = encryptModelKey(serverPublicKey, modelKey);
|
|
58
53
|
const response = await onairosApi.post('getAPIUrlMobile', {
|
|
@@ -73,7 +68,7 @@ export const Overlay = ({
|
|
|
73
68
|
closeOverlay();
|
|
74
69
|
}
|
|
75
70
|
} catch (e) {
|
|
76
|
-
console.error('Error
|
|
71
|
+
console.error('Error confirming selection:', e);
|
|
77
72
|
showErrorModal('Failed to confirm selection. Please try again.');
|
|
78
73
|
}
|
|
79
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","useEffect","View","Text","StyleSheet","TouchableOpacity","ScrollView","Alert","Platform","BottomSheetModal","BottomSheetBackdrop","
|
|
1
|
+
{"version":3,"names":["React","useState","useEffect","View","Text","StyleSheet","TouchableOpacity","ScrollView","Alert","Platform","BottomSheetModal","BottomSheetBackdrop","COLORS","onairosApi","encryptModelKey","getServerPublicKey","Overlay","data","username","modelKey","onResolved","selections","setSelections","details","setDetails","bottomSheetRef","useRef","initialSelections","Object","keys","forEach","key","getDetails","response","post","Info","AccountInfo","e","console","error","closeOverlay","_bottomSheetRef$curre","current","dismiss","confirmSelection","appId","select","ios","android","default","serverPublicKey","encryptedModelKey","storage","confirmations","developerURL","EncryptedUserPin","account","proofMode","apiUrl","token","showErrorModal","errorMessage","alert","text","selectedCount","values","filter","Boolean","length","createElement","ref","snapPoints","backdropComponent","props","_extends","appearsOnIndex","disappearsOnIndex","style","styles","container","header","headerTitle","onPress","closeButton","content","entries","map","value","card","checkboxContainer","prev","checkbox","checkboxSelected","cardContent","cardTitle","type","cardDescription","descriptions","reward","cardReward","footer","footerButton","footerButtonText","create","flex","backgroundColor","white","borderTopLeftRadius","borderTopRightRadius","flexDirection","alignItems","justifyContent","padding","primary","fontSize","color","fontWeight","borderRadius","marginBottom","shadowColor","black","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","borderWidth","borderColor","marginRight","gray","success","borderTopWidth","borderTopColor","lightGray","paddingVertical","paddingHorizontal"],"sourceRoot":"..\\..\\..\\src","sources":["components/Overlay.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,QAAQ,QACH,cAAc;AACrB,SAASC,gBAAgB,EAAEC,mBAAmB,QAAQ,sBAAsB;AAC5E;AACA,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,UAAU,QAAQ,QAAQ;AACnC,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,qBAAqB;AAezE,OAAO,MAAMC,OAA+B,GAAGA,CAAC;EAC9CC,IAAI;EACJC,QAAQ;EACRC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGrB,QAAQ,CAA6B,CAAC,CAAC,CAAC;EAC5E,MAAM,CAACsB,OAAO,EAAEC,UAAU,CAAC,GAAGvB,QAAQ,CAAS,EAAE,CAAC;EAClD,MAAMwB,cAAc,GAAGzB,KAAK,CAAC0B,MAAM,CAAmB,IAAI,CAAC;EAE3DxB,SAAS,CAAC,MAAM;IACd;IACA,MAAMyB,iBAA6C,GAAG,CAAC,CAAC;IACxDC,MAAM,CAACC,IAAI,CAACZ,IAAI,CAAC,CAACa,OAAO,C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eAAe,EAAE7F,MAAM,CAACqG;EAC1B,CAAC;EACDpB,WAAW,EAAE;IACXW,IAAI,EAAE;EACR,CAAC;EACDV,SAAS,EAAE;IACToB,QAAQ,EAAE,EAAE;IACZE,UAAU,EAAE,MAAM;IAClBE,YAAY,EAAE;EAChB,CAAC;EACDtB,eAAe,EAAE;IACfkB,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAEvG,MAAM,CAACsH,IAAI;IAClBZ,YAAY,EAAE;EAChB,CAAC;EACDnB,UAAU,EAAE;IACVe,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAEvG,MAAM,CAACuH,OAAO;IACrBf,UAAU,EAAE;EACd,CAAC;EACDhB,MAAM,EAAE;IACNS,aAAa,EAAE,KAAK;IACpBE,cAAc,EAAE,eAAe;IAC/BD,UAAU,EAAE,QAAQ;IACpBE,OAAO,EAAE,EAAE;IACXoB,cAAc,EAAE,CAAC;IACjBC,cAAc,EAAEzH,MAAM,CAAC0H;EACzB,CAAC;EACDjC,YAAY,EAAE;IACZkC,eAAe,EAAE,CAAC;IAClBC,iBAAiB,EAAE,EAAE;IACrBnB,YAAY,EAAE,CAAC;IACfZ,eAAe,EAAE7F,MAAM,CAACqG;EAC1B,CAAC;EACDX,gBAAgB,EAAE;IAChBa,KAAK,EAAEvG,MAAM,CAAC8F,KAAK;IACnBQ,QAAQ,EAAE,EAAE;IACZE,UAAU,EAAE;EACd,CAAC;EACDpD,aAAa,EAAE;IACbkD,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAEvG,MAAM,CAACsH;EAChB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useState, useCallback } from 'react';
|
|
2
|
-
import { Linking } from 'react-native';
|
|
3
2
|
import * as Keychain from 'react-native-keychain';
|
|
4
|
-
import {
|
|
3
|
+
import { STORAGE_KEYS } from '../constants';
|
|
5
4
|
export const useConnections = () => {
|
|
6
5
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
7
6
|
const getConnectionStatus = useCallback(async () => {
|
|
@@ -20,7 +19,9 @@ export const useConnections = () => {
|
|
|
20
19
|
}, []);
|
|
21
20
|
const saveConnectionStatus = useCallback(async status => {
|
|
22
21
|
try {
|
|
23
|
-
await Keychain.setGenericPassword(
|
|
22
|
+
await Keychain.setGenericPassword('connections', JSON.stringify(status), {
|
|
23
|
+
service: STORAGE_KEYS.connections
|
|
24
|
+
});
|
|
24
25
|
} catch (error) {
|
|
25
26
|
console.error('Error saving connection status:', error);
|
|
26
27
|
}
|
|
@@ -28,43 +29,24 @@ export const useConnections = () => {
|
|
|
28
29
|
const connectPlatform = useCallback(async platform => {
|
|
29
30
|
setIsConnecting(true);
|
|
30
31
|
try {
|
|
31
|
-
console.log(`[
|
|
32
|
-
|
|
33
|
-
// Get OAuth URL from API
|
|
34
|
-
const oauthEndpoint = API_ENDPOINTS.oauth[platform];
|
|
35
|
-
if (!oauthEndpoint) {
|
|
36
|
-
throw new Error(`No OAuth endpoint configured for ${platform}`);
|
|
37
|
-
}
|
|
38
|
-
const apiUrl = `${API_ENDPOINTS.base}${oauthEndpoint}`;
|
|
39
|
-
console.log(`[OAuth] Fetching URL from: ${apiUrl}`);
|
|
40
|
-
const response = await fetch(apiUrl);
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
throw new Error(`API request failed with status ${response.status}`);
|
|
43
|
-
}
|
|
44
|
-
const {
|
|
45
|
-
url
|
|
46
|
-
} = await response.json();
|
|
47
|
-
if (!url) {
|
|
48
|
-
throw new Error('No OAuth URL received from API');
|
|
49
|
-
}
|
|
50
|
-
console.log(`[OAuth] Opening URL: ${url}`);
|
|
51
|
-
|
|
52
|
-
// Check if URL can be opened
|
|
53
|
-
const canOpen = await Linking.canOpenURL(url);
|
|
54
|
-
if (!canOpen) {
|
|
55
|
-
throw new Error(`Cannot open URL: ${url}`);
|
|
56
|
-
}
|
|
32
|
+
console.log(`[Mock] Connecting to ${platform}`);
|
|
57
33
|
|
|
58
|
-
//
|
|
59
|
-
await
|
|
60
|
-
|
|
34
|
+
// Simulate connection delay
|
|
35
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
36
|
+
const status = await getConnectionStatus();
|
|
37
|
+
status[platform] = {
|
|
38
|
+
userName: `Mock User (${platform})`,
|
|
39
|
+
connected: true
|
|
40
|
+
};
|
|
41
|
+
await saveConnectionStatus(status);
|
|
42
|
+
console.log(`[Mock] Successfully connected to ${platform}`);
|
|
61
43
|
} catch (error) {
|
|
62
|
-
console.error(`
|
|
44
|
+
console.error(`Error connecting to ${platform}:`, error);
|
|
63
45
|
throw error;
|
|
64
46
|
} finally {
|
|
65
47
|
setIsConnecting(false);
|
|
66
48
|
}
|
|
67
|
-
}, []);
|
|
49
|
+
}, [getConnectionStatus, saveConnectionStatus]);
|
|
68
50
|
const disconnectPlatform = useCallback(async platform => {
|
|
69
51
|
try {
|
|
70
52
|
const status = await getConnectionStatus();
|
|
@@ -77,16 +59,16 @@ export const useConnections = () => {
|
|
|
77
59
|
}, [getConnectionStatus, saveConnectionStatus]);
|
|
78
60
|
const handleOAuthCallback = useCallback(async (platform, data) => {
|
|
79
61
|
try {
|
|
80
|
-
console.log(`[
|
|
62
|
+
console.log(`[Mock] Handling callback for ${platform}`);
|
|
81
63
|
const status = await getConnectionStatus();
|
|
82
64
|
status[platform] = {
|
|
83
|
-
userName: data.userName || `User (${platform})`,
|
|
65
|
+
userName: data.userName || `Mock User (${platform})`,
|
|
84
66
|
connected: true
|
|
85
67
|
};
|
|
86
68
|
await saveConnectionStatus(status);
|
|
87
69
|
return true;
|
|
88
70
|
} catch (error) {
|
|
89
|
-
console.error('Error handling
|
|
71
|
+
console.error('Error handling callback:', error);
|
|
90
72
|
return false;
|
|
91
73
|
}
|
|
92
74
|
}, [getConnectionStatus, saveConnectionStatus]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","useCallback","
|
|
1
|
+
{"version":3,"names":["useState","useCallback","Keychain","STORAGE_KEYS","useConnections","isConnecting","setIsConnecting","getConnectionStatus","stored","getGenericPassword","service","connections","JSON","parse","password","error","console","saveConnectionStatus","status","setGenericPassword","stringify","connectPlatform","platform","log","Promise","resolve","setTimeout","userName","connected","disconnectPlatform","handleOAuthCallback","data"],"sourceRoot":"..\\..\\..\\src","sources":["hooks/useConnections.ts"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AAC7C,OAAO,KAAKC,QAAQ,MAAM,uBAAuB;AACjD,SAASC,YAAY,QAAQ,cAAc;AAG3C,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGN,QAAQ,CAAC,KAAK,CAAC;EAEvD,MAAMO,mBAAmB,GAAGN,WAAW,CAAC,YAAuC;IAC7E,IAAI;MACF,MAAMO,MAAM,GAAG,MAAMN,QAAQ,CAACO,kBAAkB,CAAC;QAC/CC,OAAO,EAAEP,YAAY,CAACQ;MACxB,CAAC,CAAC;MACF,IAAIH,MAAM,EAAE;QACV,OAAOI,IAAI,CAACC,KAAK,CAACL,MAAM,CAACM,QAAQ,CAAC;MACpC;MACA,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,kCAAkC,EAAEA,KAAK,CAAC;MACxD,OAAO,CAAC,CAAC;IACX;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,MAAME,oBAAoB,GAAGhB,WAAW,CAAC,MAAOiB,MAAwB,IAAK;IAC3E,IAAI;MACF,MAAMhB,QAAQ,CAACiB,kBAAkB,CAC/B,aAAa,EACbP,IAAI,CAACQ,SAAS,CAACF,MAAM,CAAC,EACtB;QAAER,OAAO,EAAEP,YAAY,CAACQ;MAAY,CACtC,CAAC;IACH,CAAC,CAAC,OAAOI,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,iCAAiC,EAAEA,KAAK,CAAC;IACzD;EACF,CAAC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OqB,QAAgB,EAAES,IAAS,KAAK;IAC7E,IAAI;MACFf,OAAO,CAACO,GAAG,CAAC,gCAAgCD,QAAQ,EAAE,CAAC;MACvD,MAAMJ,MAAM,GAAG,MAAMX,mBAAmB,CAAC,CAAC;MAC1CW,MAAM,CAACI,QAAQ,CAAC,GAAG;QACjBK,QAAQ,EAAEI,IAAI,CAACJ,QAAQ,IAAI,cAAcL,QAAQ,GAAG;QACpDM,SAAS,EAAE;MACb,CAAC;MACD,MAAMX,oBAAoB,CAACC,MAAM,CAAC;MAClC,OAAO,IAAI;IACb,CAAC,CAAC,OAAOH,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAAC;MAChD,OAAO,KAAK;IACd;EACF,CAAC,EAAE,CAACR,mBAAmB,EAAEU,oBAAoB,CAAC,CAAC;EAE/C,OAAO;IACLZ,YAAY;IACZgB,eAAe;IACfQ,kBAAkB;IAClBtB,mBAAmB;IACnBuB;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,51 +1,15 @@
|
|
|
1
|
-
import * as Keychain from 'react-native-keychain';
|
|
2
1
|
import { Platform } from 'react-native';
|
|
3
2
|
import { sha256 } from './crypto';
|
|
4
|
-
|
|
3
|
+
// Temporary in-memory storage
|
|
4
|
+
let mockStorage = {};
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Store credentials
|
|
7
|
+
* Store credentials in memory (temporary solution)
|
|
8
8
|
*/
|
|
9
9
|
export const storeCredentials = async (credentials, options = {}) => {
|
|
10
10
|
try {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
biometricPrompt
|
|
14
|
-
} = options;
|
|
15
|
-
|
|
16
|
-
// Create a JSON string of the credentials
|
|
17
|
-
const credentialsString = JSON.stringify(credentials);
|
|
18
|
-
|
|
19
|
-
// Configure security options based on platform
|
|
20
|
-
const securityOptions = {
|
|
21
|
-
service: CREDENTIALS_KEY,
|
|
22
|
-
accessible: Keychain.ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Add biometric protection if requested
|
|
26
|
-
if (useBiometrics) {
|
|
27
|
-
// iOS specific options
|
|
28
|
-
if (Platform.OS === 'ios') {
|
|
29
|
-
securityOptions.accessControl = Keychain.ACCESS_CONTROL.BIOMETRY_ANY_OR_DEVICE_PASSCODE;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Android specific options
|
|
33
|
-
if (Platform.OS === 'android') {
|
|
34
|
-
securityOptions.accessControl = Keychain.ACCESS_CONTROL.BIOMETRY_ANY;
|
|
35
|
-
if (biometricPrompt) {
|
|
36
|
-
securityOptions.authenticationType = Keychain.AUTHENTICATION_TYPE.BIOMETRIC;
|
|
37
|
-
securityOptions.authenticationPrompt = {
|
|
38
|
-
title: biometricPrompt.title || 'Biometric Authentication',
|
|
39
|
-
subtitle: biometricPrompt.subtitle,
|
|
40
|
-
description: 'Please authenticate to access your Onairos credentials',
|
|
41
|
-
cancel: 'Cancel'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Store in the secure keychain
|
|
48
|
-
await Keychain.setGenericPassword(credentials.username, credentialsString, securityOptions);
|
|
11
|
+
console.log('[Mock] Storing credentials:', credentials.username);
|
|
12
|
+
mockStorage[credentials.username] = JSON.stringify(credentials);
|
|
49
13
|
return true;
|
|
50
14
|
} catch (error) {
|
|
51
15
|
console.error('Error storing credentials:', error);
|
|
@@ -54,39 +18,16 @@ export const storeCredentials = async (credentials, options = {}) => {
|
|
|
54
18
|
};
|
|
55
19
|
|
|
56
20
|
/**
|
|
57
|
-
* Retrieve credentials from
|
|
21
|
+
* Retrieve credentials from memory (temporary solution)
|
|
58
22
|
*/
|
|
59
23
|
export const getCredentials = async (options = {}) => {
|
|
60
24
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} = options;
|
|
65
|
-
|
|
66
|
-
// Configure security options
|
|
67
|
-
const securityOptions = {
|
|
68
|
-
service: CREDENTIALS_KEY
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// Add biometric prompt if required
|
|
72
|
-
if (useBiometrics && biometricPrompt) {
|
|
73
|
-
securityOptions.authenticationPrompt = {
|
|
74
|
-
title: biometricPrompt.title || 'Biometric Authentication',
|
|
75
|
-
subtitle: biometricPrompt.subtitle,
|
|
76
|
-
description: 'Please authenticate to access your Onairos credentials',
|
|
77
|
-
cancel: 'Cancel'
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Retrieve from keychain
|
|
82
|
-
const result = await Keychain.getGenericPassword(securityOptions);
|
|
83
|
-
if (!result) {
|
|
25
|
+
// Get the first stored credential (temporary solution)
|
|
26
|
+
const storedCredential = Object.values(mockStorage)[0];
|
|
27
|
+
if (!storedCredential) {
|
|
84
28
|
return null;
|
|
85
29
|
}
|
|
86
|
-
|
|
87
|
-
// Parse the stored JSON
|
|
88
|
-
const credentials = JSON.parse(result.password);
|
|
89
|
-
return credentials;
|
|
30
|
+
return JSON.parse(storedCredential);
|
|
90
31
|
} catch (error) {
|
|
91
32
|
console.error('Error retrieving credentials:', error);
|
|
92
33
|
return null;
|
|
@@ -98,10 +39,7 @@ export const getCredentials = async (options = {}) => {
|
|
|
98
39
|
*/
|
|
99
40
|
export const hasCredentials = async () => {
|
|
100
41
|
try {
|
|
101
|
-
|
|
102
|
-
service: CREDENTIALS_KEY
|
|
103
|
-
});
|
|
104
|
-
return !!result;
|
|
42
|
+
return Object.keys(mockStorage).length > 0;
|
|
105
43
|
} catch (error) {
|
|
106
44
|
console.error('Error checking for credentials:', error);
|
|
107
45
|
return false;
|
|
@@ -113,9 +51,7 @@ export const hasCredentials = async () => {
|
|
|
113
51
|
*/
|
|
114
52
|
export const deleteCredentials = async () => {
|
|
115
53
|
try {
|
|
116
|
-
|
|
117
|
-
service: CREDENTIALS_KEY
|
|
118
|
-
});
|
|
54
|
+
mockStorage = {};
|
|
119
55
|
return true;
|
|
120
56
|
} catch (error) {
|
|
121
57
|
console.error('Error deleting credentials:', error);
|
|
@@ -128,19 +64,14 @@ export const deleteCredentials = async () => {
|
|
|
128
64
|
*/
|
|
129
65
|
export const updateCredentials = async (updates, options = {}) => {
|
|
130
66
|
try {
|
|
131
|
-
// Get current credentials
|
|
132
67
|
const currentCredentials = await getCredentials(options);
|
|
133
68
|
if (!currentCredentials) {
|
|
134
69
|
return false;
|
|
135
70
|
}
|
|
136
|
-
|
|
137
|
-
// Merge updates with current credentials
|
|
138
71
|
const updatedCredentials = {
|
|
139
72
|
...currentCredentials,
|
|
140
73
|
...updates
|
|
141
74
|
};
|
|
142
|
-
|
|
143
|
-
// Store updated credentials
|
|
144
75
|
return await storeCredentials(updatedCredentials, options);
|
|
145
76
|
} catch (error) {
|
|
146
77
|
console.error('Error updating credentials:', error);
|
|
@@ -153,40 +84,21 @@ export const updateCredentials = async (updates, options = {}) => {
|
|
|
153
84
|
*/
|
|
154
85
|
export const generateDeviceUsername = async () => {
|
|
155
86
|
try {
|
|
156
|
-
// Get a device-specific identifier that we can use
|
|
157
|
-
// This is a simplified example - in production you might want to use
|
|
158
|
-
// a more robust device identifier method
|
|
159
87
|
const deviceInfo = `${Platform.OS}-${Platform.Version}-${Date.now()}`;
|
|
160
|
-
|
|
161
|
-
// Hash it to create a unique identifier
|
|
162
88
|
const username = `onairos_${sha256(deviceInfo).substring(0, 10)}`;
|
|
163
89
|
return username;
|
|
164
90
|
} catch (error) {
|
|
165
91
|
console.error('Error generating device username:', error);
|
|
166
|
-
// Fallback to a timestamp-based username if there's an error
|
|
167
92
|
return `onairos_${Date.now().toString(36)}`;
|
|
168
93
|
}
|
|
169
94
|
};
|
|
170
95
|
|
|
171
96
|
/**
|
|
172
|
-
* Verify
|
|
97
|
+
* Verify credentials (temporary mock implementation)
|
|
173
98
|
*/
|
|
174
99
|
export const verifyCredentials = async credentials => {
|
|
175
100
|
try {
|
|
176
|
-
|
|
177
|
-
if (!credentials || !credentials.accessToken || !credentials.username) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Check for expiration (example: credentials expire after 30 days)
|
|
182
|
-
const thirtyDaysMs = 30 * 24 * 60 * 60 * 1000;
|
|
183
|
-
const isExpired = Date.now() - credentials.createdAt > thirtyDaysMs;
|
|
184
|
-
if (isExpired) {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Add any additional verification logic here
|
|
189
|
-
|
|
101
|
+
console.log('[Mock] Verifying credentials for:', credentials.username);
|
|
190
102
|
return true;
|
|
191
103
|
} catch (error) {
|
|
192
104
|
console.error('Error verifying credentials:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Platform","sha256","mockStorage","storeCredentials","credentials","options","console","log","username","JSON","stringify","error","getCredentials","storedCredential","Object","values","parse","hasCredentials","keys","length","deleteCredentials","updateCredentials","updates","currentCredentials","updatedCredentials","generateDeviceUsername","deviceInfo","OS","Version","Date","now","substring","toString","verifyCredentials"],"sourceRoot":"..\\..\\..\\src","sources":["utils/secureStorage.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,MAAM,QAAQ,UAAU;AAwBjC;AACA,IAAIC,WAAsC,GAAG,CAAC,CAAC;;AAE/C;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,WAA+B,EAC/BC,OAAuB,GAAG,CAAC,CAAC,KACP;EACrB,IAAI;IACFC,OAAO,CAACC,GAAG,CAAC,6BAA6B,EAAEH,WAAW,CAACI,QAAQ,CAAC;IAChEN,WAAW,CAACE,WAAW,CAACI,QAAQ,CAAC,GAAGC,IAAI,CAACC,SAAS,CAACN,WAAW,CAAC;IAC/D,OAAO,IAAI;EACb,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdL,OAAO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} from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet, View,
|
|
3
|
-
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, View, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import { UniversalOnboarding } from './UniversalOnboarding';
|
|
4
4
|
import { COLORS } from '../constants';
|
|
5
5
|
import type { OnairosButtonProps } from '../types';
|
|
6
6
|
|
|
@@ -37,17 +37,7 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
console.log('OAuth integration temporarily disabled');
|
|
42
|
-
onRejection?.();
|
|
43
|
-
/*
|
|
44
|
-
if (buttonForm === 'signup') {
|
|
45
|
-
setShowOnboarding(true);
|
|
46
|
-
} else {
|
|
47
|
-
// Handle login flow
|
|
48
|
-
// TODO: Implement login flow according to account.md
|
|
49
|
-
}
|
|
50
|
-
*/
|
|
40
|
+
setShowOnboarding(true);
|
|
51
41
|
};
|
|
52
42
|
|
|
53
43
|
const handleOnboardingComplete = (apiUrl: string, token: string, data: any) => {
|
|
@@ -81,7 +71,6 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
81
71
|
<Text style={textStyle}>{AppName}</Text>
|
|
82
72
|
</TouchableOpacity>
|
|
83
73
|
|
|
84
|
-
{/* Temporarily disabled UniversalOnboarding
|
|
85
74
|
<UniversalOnboarding
|
|
86
75
|
visible={showOnboarding}
|
|
87
76
|
onClose={() => setShowOnboarding(false)}
|
|
@@ -93,7 +82,6 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
93
82
|
debug={debug}
|
|
94
83
|
test={testMode}
|
|
95
84
|
/>
|
|
96
|
-
*/}
|
|
97
85
|
</View>
|
|
98
86
|
);
|
|
99
87
|
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
Platform,
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
import { BottomSheetModal, BottomSheetBackdrop } from '@gorhom/bottom-sheet';
|
|
12
|
-
import DeviceInfo from 'react-native-device-info';
|
|
12
|
+
// import DeviceInfo from 'react-native-device-info'; // Comment out device info import
|
|
13
13
|
import { COLORS } from '../constants';
|
|
14
14
|
import { onairosApi } from '../api';
|
|
15
15
|
import { encryptModelKey, getServerPublicKey } from '../utils/encryption';
|
|
@@ -66,17 +66,12 @@ export const Overlay: React.FC<OverlayProps> = ({
|
|
|
66
66
|
|
|
67
67
|
const confirmSelection = async () => {
|
|
68
68
|
try {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
default: 'unknown'
|
|
76
|
-
});
|
|
77
|
-
} catch (e) {
|
|
78
|
-
console.warn('Failed to get app identifier:', e);
|
|
79
|
-
}
|
|
69
|
+
// Mock app identifier
|
|
70
|
+
const appId = Platform.select({
|
|
71
|
+
ios: 'com.onairos.mock',
|
|
72
|
+
android: 'com.onairos.mock',
|
|
73
|
+
default: 'unknown'
|
|
74
|
+
});
|
|
80
75
|
|
|
81
76
|
const serverPublicKey = await getServerPublicKey();
|
|
82
77
|
const encryptedModelKey = encryptModelKey(serverPublicKey, modelKey);
|
|
@@ -98,7 +93,7 @@ export const Overlay: React.FC<OverlayProps> = ({
|
|
|
98
93
|
closeOverlay();
|
|
99
94
|
}
|
|
100
95
|
} catch (e) {
|
|
101
|
-
console.error('Error
|
|
96
|
+
console.error('Error confirming selection:', e);
|
|
102
97
|
showErrorModal('Failed to confirm selection. Please try again.');
|
|
103
98
|
}
|
|
104
99
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useState, useCallback } from 'react';
|
|
2
|
-
import { Linking, Platform } from 'react-native';
|
|
3
2
|
import * as Keychain from 'react-native-keychain';
|
|
4
|
-
import {
|
|
3
|
+
import { STORAGE_KEYS } from '../constants';
|
|
5
4
|
import type { ConnectionStatus } from '../types';
|
|
6
5
|
|
|
7
6
|
export const useConnections = () => {
|
|
@@ -9,7 +8,9 @@ export const useConnections = () => {
|
|
|
9
8
|
|
|
10
9
|
const getConnectionStatus = useCallback(async (): Promise<ConnectionStatus> => {
|
|
11
10
|
try {
|
|
12
|
-
const stored = await Keychain.getGenericPassword({
|
|
11
|
+
const stored = await Keychain.getGenericPassword({
|
|
12
|
+
service: STORAGE_KEYS.connections
|
|
13
|
+
});
|
|
13
14
|
if (stored) {
|
|
14
15
|
return JSON.parse(stored.password);
|
|
15
16
|
}
|
|
@@ -23,8 +24,9 @@ export const useConnections = () => {
|
|
|
23
24
|
const saveConnectionStatus = useCallback(async (status: ConnectionStatus) => {
|
|
24
25
|
try {
|
|
25
26
|
await Keychain.setGenericPassword(
|
|
26
|
-
|
|
27
|
-
JSON.stringify(status)
|
|
27
|
+
'connections',
|
|
28
|
+
JSON.stringify(status),
|
|
29
|
+
{ service: STORAGE_KEYS.connections }
|
|
28
30
|
);
|
|
29
31
|
} catch (error) {
|
|
30
32
|
console.error('Error saving connection status:', error);
|
|
@@ -34,51 +36,31 @@ export const useConnections = () => {
|
|
|
34
36
|
const connectPlatform = useCallback(async (platform: string) => {
|
|
35
37
|
setIsConnecting(true);
|
|
36
38
|
try {
|
|
37
|
-
console.log(`[
|
|
39
|
+
console.log(`[Mock] Connecting to ${platform}`);
|
|
38
40
|
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
if (!oauthEndpoint) {
|
|
42
|
-
throw new Error(`No OAuth endpoint configured for ${platform}`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const apiUrl = `${API_ENDPOINTS.base}${oauthEndpoint}`;
|
|
46
|
-
console.log(`[OAuth] Fetching URL from: ${apiUrl}`);
|
|
47
|
-
|
|
48
|
-
const response = await fetch(apiUrl);
|
|
49
|
-
if (!response.ok) {
|
|
50
|
-
throw new Error(`API request failed with status ${response.status}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const { url } = await response.json();
|
|
54
|
-
if (!url) {
|
|
55
|
-
throw new Error('No OAuth URL received from API');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
console.log(`[OAuth] Opening URL: ${url}`);
|
|
41
|
+
// Simulate connection delay
|
|
42
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
59
43
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
console.log(`[OAuth] URL opened successfully`);
|
|
69
|
-
|
|
44
|
+
const status = await getConnectionStatus();
|
|
45
|
+
status[platform] = {
|
|
46
|
+
userName: `Mock User (${platform})`,
|
|
47
|
+
connected: true
|
|
48
|
+
};
|
|
49
|
+
await saveConnectionStatus(status);
|
|
50
|
+
|
|
51
|
+
console.log(`[Mock] Successfully connected to ${platform}`);
|
|
70
52
|
} catch (error) {
|
|
71
|
-
console.error(`
|
|
53
|
+
console.error(`Error connecting to ${platform}:`, error);
|
|
72
54
|
throw error;
|
|
73
55
|
} finally {
|
|
74
56
|
setIsConnecting(false);
|
|
75
57
|
}
|
|
76
|
-
}, []);
|
|
58
|
+
}, [getConnectionStatus, saveConnectionStatus]);
|
|
77
59
|
|
|
78
60
|
const disconnectPlatform = useCallback(async (platform: string) => {
|
|
79
61
|
try {
|
|
80
62
|
const status = await getConnectionStatus();
|
|
81
|
-
delete status[platform
|
|
63
|
+
delete status[platform];
|
|
82
64
|
await saveConnectionStatus(status);
|
|
83
65
|
} catch (error) {
|
|
84
66
|
console.error(`Error disconnecting ${platform}:`, error);
|
|
@@ -88,16 +70,16 @@ export const useConnections = () => {
|
|
|
88
70
|
|
|
89
71
|
const handleOAuthCallback = useCallback(async (platform: string, data: any) => {
|
|
90
72
|
try {
|
|
91
|
-
console.log(`[
|
|
73
|
+
console.log(`[Mock] Handling callback for ${platform}`);
|
|
92
74
|
const status = await getConnectionStatus();
|
|
93
|
-
status[platform
|
|
94
|
-
userName: data.userName || `User (${platform})`,
|
|
95
|
-
connected: true
|
|
75
|
+
status[platform] = {
|
|
76
|
+
userName: data.userName || `Mock User (${platform})`,
|
|
77
|
+
connected: true
|
|
96
78
|
};
|
|
97
79
|
await saveConnectionStatus(status);
|
|
98
80
|
return true;
|
|
99
81
|
} catch (error) {
|
|
100
|
-
console.error('Error handling
|
|
82
|
+
console.error('Error handling callback:', error);
|
|
101
83
|
return false;
|
|
102
84
|
}
|
|
103
85
|
}, [getConnectionStatus, saveConnectionStatus]);
|