@onairos/react-native 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +334 -0
- package/lib/commonjs/components/DataRequestModal.js +176 -0
- package/lib/commonjs/components/DataRequestModal.js.map +1 -0
- package/lib/commonjs/components/Notification.js +106 -0
- package/lib/commonjs/components/Notification.js.map +1 -0
- package/lib/commonjs/components/OnairosButton.js +575 -0
- package/lib/commonjs/components/OnairosButton.js.map +1 -0
- package/lib/commonjs/components/Overlay.js +818 -0
- package/lib/commonjs/components/Overlay.js.map +1 -0
- package/lib/commonjs/components/UniversalOnboarding.js +173 -0
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -0
- package/lib/commonjs/components/onboarding/OAuthWebView.js +137 -0
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -0
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -0
- package/lib/commonjs/components/onboarding/OnboardingHeader.js.map +1 -0
- package/lib/commonjs/components/onboarding/PinInput.js +283 -0
- package/lib/commonjs/components/onboarding/PinInput.js.map +1 -0
- package/lib/commonjs/components/onboarding/PlatformConnector.js +244 -0
- package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -0
- package/lib/commonjs/components/screens/ConnectorScreen.js +145 -0
- package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -0
- package/lib/commonjs/components/screens/LoadingScreen.js +91 -0
- package/lib/commonjs/components/screens/LoadingScreen.js.map +1 -0
- package/lib/commonjs/components/screens/PinCreationScreen.js +61 -0
- package/lib/commonjs/components/screens/PinCreationScreen.js.map +1 -0
- package/lib/commonjs/constants/index.js +78 -0
- package/lib/commonjs/constants/index.js.map +1 -0
- package/lib/commonjs/hooks/useConnections.js +89 -0
- package/lib/commonjs/hooks/useConnections.js.map +1 -0
- package/lib/commonjs/hooks/useCredentials.js +85 -0
- package/lib/commonjs/hooks/useCredentials.js.map +1 -0
- package/lib/commonjs/index.js +282 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/services/oauthService.js +362 -0
- package/lib/commonjs/services/oauthService.js.map +1 -0
- package/lib/commonjs/types/declarations.d.js +2 -0
- package/lib/commonjs/types/declarations.d.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/api.js +129 -0
- package/lib/commonjs/utils/api.js.map +1 -0
- package/lib/commonjs/utils/auth.js +111 -0
- package/lib/commonjs/utils/auth.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +62 -0
- package/lib/commonjs/utils/crypto.js.map +1 -0
- package/lib/commonjs/utils/debugHelper.js +64 -0
- package/lib/commonjs/utils/debugHelper.js.map +1 -0
- package/lib/commonjs/utils/onairosApi.js +270 -0
- package/lib/commonjs/utils/onairosApi.js.map +1 -0
- package/lib/commonjs/utils/secureStorage.js +210 -0
- package/lib/commonjs/utils/secureStorage.js.map +1 -0
- package/lib/module/components/DataRequestModal.js +168 -0
- package/lib/module/components/DataRequestModal.js.map +1 -0
- package/lib/module/components/Notification.js +99 -0
- package/lib/module/components/Notification.js.map +1 -0
- package/lib/module/components/OnairosButton.js +550 -0
- package/lib/module/components/OnairosButton.js.map +1 -0
- package/lib/module/components/Overlay.js +825 -0
- package/lib/module/components/Overlay.js.map +1 -0
- package/lib/module/components/UniversalOnboarding.js +164 -0
- package/lib/module/components/UniversalOnboarding.js.map +1 -0
- package/lib/module/components/onboarding/OAuthWebView.js +128 -0
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -0
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -0
- package/lib/module/components/onboarding/OnboardingHeader.js.map +1 -0
- package/lib/module/components/onboarding/PinInput.js +274 -0
- package/lib/module/components/onboarding/PinInput.js.map +1 -0
- package/lib/module/components/onboarding/PlatformConnector.js +235 -0
- package/lib/module/components/onboarding/PlatformConnector.js.map +1 -0
- package/lib/module/components/screens/ConnectorScreen.js +137 -0
- package/lib/module/components/screens/ConnectorScreen.js.map +1 -0
- package/lib/module/components/screens/LoadingScreen.js +83 -0
- package/lib/module/components/screens/LoadingScreen.js.map +1 -0
- package/lib/module/components/screens/PinCreationScreen.js +53 -0
- package/lib/module/components/screens/PinCreationScreen.js.map +1 -0
- package/lib/module/constants/index.js +72 -0
- package/lib/module/constants/index.js.map +1 -0
- package/lib/module/hooks/useConnections.js +81 -0
- package/lib/module/hooks/useConnections.js.map +1 -0
- package/lib/module/hooks/useCredentials.js +77 -0
- package/lib/module/hooks/useCredentials.js.map +1 -0
- package/lib/module/index.js +34 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/services/oauthService.js +352 -0
- package/lib/module/services/oauthService.js.map +1 -0
- package/lib/module/types/declarations.d.js +2 -0
- package/lib/module/types/declarations.d.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/api.js +117 -0
- package/lib/module/utils/api.js.map +1 -0
- package/lib/module/utils/auth.js +99 -0
- package/lib/module/utils/auth.js.map +1 -0
- package/lib/module/utils/crypto.js +54 -0
- package/lib/module/utils/crypto.js.map +1 -0
- package/lib/module/utils/debugHelper.js +54 -0
- package/lib/module/utils/debugHelper.js.map +1 -0
- package/lib/module/utils/onairosApi.js +256 -0
- package/lib/module/utils/onairosApi.js.map +1 -0
- package/lib/module/utils/secureStorage.js +196 -0
- package/lib/module/utils/secureStorage.js.map +1 -0
- package/package.json +115 -0
- package/src/components/DataRequestModal.tsx +187 -0
- package/src/components/Notification.js +101 -0
- package/src/components/OnairosButton.js +604 -0
- package/src/components/OnairosButton.tsx +182 -0
- package/src/components/Overlay.js +854 -0
- package/src/components/Overlay.tsx +272 -0
- package/src/components/UniversalOnboarding.tsx +184 -0
- package/src/components/onboarding/OAuthWebView.tsx +134 -0
- package/src/components/onboarding/OnboardingHeader.tsx +70 -0
- package/src/components/onboarding/PinInput.tsx +356 -0
- package/src/components/onboarding/PlatformConnector.tsx +297 -0
- package/src/components/screens/ConnectorScreen.tsx +152 -0
- package/src/components/screens/LoadingScreen.tsx +100 -0
- package/src/components/screens/PinCreationScreen.tsx +67 -0
- package/src/constants/index.ts +78 -0
- package/src/hooks/useConnections.ts +90 -0
- package/src/hooks/useCredentials.ts +83 -0
- package/src/index.js +14 -0
- package/src/index.ts +82 -0
- package/src/services/oauthService.ts +360 -0
- package/src/types/declarations.d.ts +26 -0
- package/src/types/index.ts +82 -0
- package/src/utils/api.js +112 -0
- package/src/utils/auth.js +104 -0
- package/src/utils/crypto.js +60 -0
- package/src/utils/debugHelper.ts +53 -0
- package/src/utils/onairosApi.ts +303 -0
- package/src/utils/secureStorage.ts +230 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { Linking } from 'react-native';
|
|
3
|
+
import * as Keychain from 'react-native-keychain';
|
|
4
|
+
import { API_ENDPOINTS, STORAGE_KEYS } from '../constants';
|
|
5
|
+
export const useConnections = () => {
|
|
6
|
+
const [isConnecting, setIsConnecting] = useState(false);
|
|
7
|
+
const getConnectionStatus = useCallback(async () => {
|
|
8
|
+
try {
|
|
9
|
+
const stored = await Keychain.getGenericPassword(STORAGE_KEYS.connections);
|
|
10
|
+
if (stored) {
|
|
11
|
+
return JSON.parse(stored.password);
|
|
12
|
+
}
|
|
13
|
+
return {};
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error getting connection status:', error);
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
const saveConnectionStatus = useCallback(async status => {
|
|
20
|
+
try {
|
|
21
|
+
await Keychain.setGenericPassword(STORAGE_KEYS.connections, JSON.stringify(status));
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error saving connection status:', error);
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
const connectPlatform = useCallback(async platform => {
|
|
27
|
+
setIsConnecting(true);
|
|
28
|
+
try {
|
|
29
|
+
// Get OAuth URL from API
|
|
30
|
+
const response = await fetch(`${API_ENDPOINTS.base}${API_ENDPOINTS.oauth[platform]}`);
|
|
31
|
+
const {
|
|
32
|
+
url
|
|
33
|
+
} = await response.json();
|
|
34
|
+
if (!url) {
|
|
35
|
+
throw new Error('No OAuth URL received');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Open OAuth URL
|
|
39
|
+
await Linking.openURL(url);
|
|
40
|
+
|
|
41
|
+
// Connection status will be updated when the OAuth callback is received
|
|
42
|
+
// This is handled in the UniversalOnboarding component
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(`Error connecting to ${platform}:`, error);
|
|
45
|
+
throw error;
|
|
46
|
+
} finally {
|
|
47
|
+
setIsConnecting(false);
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
const disconnectPlatform = useCallback(async platform => {
|
|
51
|
+
try {
|
|
52
|
+
const status = await getConnectionStatus();
|
|
53
|
+
delete status[platform];
|
|
54
|
+
await saveConnectionStatus(status);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(`Error disconnecting ${platform}:`, error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}, [getConnectionStatus, saveConnectionStatus]);
|
|
60
|
+
const handleOAuthCallback = useCallback(async (platform, data) => {
|
|
61
|
+
try {
|
|
62
|
+
const status = await getConnectionStatus();
|
|
63
|
+
status[platform] = {
|
|
64
|
+
userName: data.userName
|
|
65
|
+
};
|
|
66
|
+
await saveConnectionStatus(status);
|
|
67
|
+
return true;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('Error handling OAuth callback:', error);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}, [getConnectionStatus, saveConnectionStatus]);
|
|
73
|
+
return {
|
|
74
|
+
isConnecting,
|
|
75
|
+
connectPlatform,
|
|
76
|
+
disconnectPlatform,
|
|
77
|
+
getConnectionStatus,
|
|
78
|
+
handleOAuthCallback
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=useConnections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useCallback","Linking","Keychain","API_ENDPOINTS","STORAGE_KEYS","useConnections","isConnecting","setIsConnecting","getConnectionStatus","stored","getGenericPassword","connections","JSON","parse","password","error","console","saveConnectionStatus","status","setGenericPassword","stringify","connectPlatform","platform","response","fetch","base","oauth","url","json","Error","openURL","disconnectPlatform","handleOAuthCallback","data","userName"],"sourceRoot":"..\\..\\..\\src","sources":["hooks/useConnections.ts"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AAC7C,SAASC,OAAO,QAAQ,cAAc;AACtC,OAAO,KAAKC,QAAQ,MAAM,uBAAuB;AACjD,SAASC,aAAa,EAAEC,YAAY,QAAQ,cAAc;AAG1D,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGR,QAAQ,CAAC,KAAK,CAAC;EAEvD,MAAMS,mBAAmB,GAAGR,WAAW,CAAC,YAAuC;IAC7E,IAAI;MACF,MAAMS,MAAM,GAAG,MAAMP,QAAQ,CAACQ,kBAAkB,CAACN,YAAY,CAACO,WAAW,CAAC;MAC1E,IAAIF,MAAM,EAAE;QACV,OAAOG,IAAI,CAACC,KAAK,CAACJ,MAAM,CAACK,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,GAAGjB,WAAW,CAAC,MAAOkB,MAAwB,IAAK;IAC3E,IAAI;MACF,MAAMhB,QAAQ,CAACiB,kBAAkB,CAC/Bf,YAAY,CAACO,WAAW,EACxBC,IAAI,CAACQ,SAAS,CAACF,MAAM,CACvB,CAAC;IAC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AAmB,GAAGhC,WAAW,CAAC,OAAOsB,QAAgB,EAAEW,IAAS,KAAK;IAC7E,IAAI;MACF,MAAMf,MAAM,GAAG,MAAMV,mBAAmB,CAAC,CAAC;MAC1CU,MAAM,CAACI,QAAQ,CAA2B,GAAG;QAAEY,QAAQ,EAAED,IAAI,CAACC;MAAS,CAAC;MACxE,MAAMjB,oBAAoB,CAACC,MAAM,CAAC;MAClC,OAAO,IAAI;IACb,CAAC,CAAC,OAAOH,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,gCAAgC,EAAEA,KAAK,CAAC;MACtD,OAAO,KAAK;IACd;EACF,CAAC,EAAE,CAACP,mBAAmB,EAAES,oBAAoB,CAAC,CAAC;EAE/C,OAAO;IACLX,YAAY;IACZe,eAAe;IACfU,kBAAkB;IAClBvB,mBAAmB;IACnBwB;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import * as Keychain from 'react-native-keychain';
|
|
3
|
+
import { STORAGE_KEYS } from '../constants';
|
|
4
|
+
export const useCredentials = () => {
|
|
5
|
+
const hasCredentials = useCallback(async () => {
|
|
6
|
+
try {
|
|
7
|
+
const credentials = await Keychain.getGenericPassword(STORAGE_KEYS.credentials);
|
|
8
|
+
return !!credentials;
|
|
9
|
+
} catch (error) {
|
|
10
|
+
console.error('Error checking credentials:', error);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}, []);
|
|
14
|
+
const getCredentials = useCallback(async () => {
|
|
15
|
+
try {
|
|
16
|
+
const credentials = await Keychain.getGenericPassword(STORAGE_KEYS.credentials);
|
|
17
|
+
if (credentials) {
|
|
18
|
+
return JSON.parse(credentials.password);
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Error getting credentials:', error);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
const storeCredentials = useCallback(async (username, userPin, accessToken) => {
|
|
27
|
+
try {
|
|
28
|
+
await Keychain.setGenericPassword(STORAGE_KEYS.credentials, JSON.stringify({
|
|
29
|
+
username,
|
|
30
|
+
userPin,
|
|
31
|
+
accessToken
|
|
32
|
+
}));
|
|
33
|
+
return true;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Error storing credentials:', error);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
const clearCredentials = useCallback(async () => {
|
|
40
|
+
try {
|
|
41
|
+
await Keychain.resetGenericPassword(STORAGE_KEYS.credentials);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Error clearing credentials:', error);
|
|
44
|
+
}
|
|
45
|
+
}, []);
|
|
46
|
+
const validateCredentials = useCallback(async username => {
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(`https://api2.onairos.uk/validate`, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json'
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify({
|
|
54
|
+
username
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
const data = await response.json();
|
|
58
|
+
return {
|
|
59
|
+
isValid: data.valid,
|
|
60
|
+
credentials: data.credentials
|
|
61
|
+
};
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Error validating credentials:', error);
|
|
64
|
+
return {
|
|
65
|
+
isValid: false
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}, []);
|
|
69
|
+
return {
|
|
70
|
+
hasCredentials,
|
|
71
|
+
getCredentials,
|
|
72
|
+
storeCredentials,
|
|
73
|
+
clearCredentials,
|
|
74
|
+
validateCredentials
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=useCredentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","Keychain","STORAGE_KEYS","useCredentials","hasCredentials","credentials","getGenericPassword","error","console","getCredentials","JSON","parse","password","storeCredentials","username","userPin","accessToken","setGenericPassword","stringify","clearCredentials","resetGenericPassword","validateCredentials","response","fetch","method","headers","body","data","json","isValid","valid"],"sourceRoot":"..\\..\\..\\src","sources":["hooks/useCredentials.ts"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AACnC,OAAO,KAAKC,QAAQ,MAAM,uBAAuB;AACjD,SAASC,YAAY,QAAQ,cAAc;AAG3C,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,MAAMC,cAAc,GAAGJ,WAAW,CAAC,YAA8B;IAC/D,IAAI;MACF,MAAMK,WAAW,GAAG,MAAMJ,QAAQ,CAACK,kBAAkB,CAACJ,YAAY,CAACG,WAAW,CAAC;MAC/E,OAAO,CAAC,CAACA,WAAW;IACtB,CAAC,CAAC,OAAOE,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,6BAA6B,EAAEA,KAAK,CAAC;MACnD,OAAO,KAAK;IACd;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,MAAME,cAAc,GAAGT,WAAW,CAAC,YAAY;IAC7C,IAAI;MACF,MAAMK,WAAW,GAAG,MAAMJ,QAAQ,CAACK,kBAAkB,CAACJ,YAAY,CAACG,WAAW,CAAC;MAC/E,IAAIA,WAAW,EAAE;QACf,OAAOK,IAAI,CAACC,KAAK,CAACN,WAAW,CAACO,QAAQ,CAAC;MACzC;MACA,OAAO,IAAI;IACb,CAAC,CAAC,OAAOL,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,4BAA4B,EAAEA,KAAK,CAAC;MAClD,OAAO,IAAI;IACb;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMM,gBAAgB,GAAGb,WAAW,CAAC,OACnCc,QAAgB,EAChBC,OAAe,EACfC,WAAmB,KACE;IACrB,IAAI;MACF,MAAMf,QAAQ,CAACgB,kBAAkB,CAC/Bf,YAAY,CAACG,WAAW,EACxBK,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","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Components
|
|
2
|
+
export { OnairosButton } from './components/OnairosButton';
|
|
3
|
+
export { UniversalOnboarding } from './components/UniversalOnboarding';
|
|
4
|
+
export { Overlay } from './components/Overlay';
|
|
5
|
+
|
|
6
|
+
// Screen Components
|
|
7
|
+
export { ConnectorScreen } from './components/screens/ConnectorScreen';
|
|
8
|
+
export { PinCreationScreen } from './components/screens/PinCreationScreen';
|
|
9
|
+
export { LoadingScreen } from './components/screens/LoadingScreen';
|
|
10
|
+
|
|
11
|
+
// Onboarding Components
|
|
12
|
+
export { OAuthWebView } from './components/onboarding/OAuthWebView';
|
|
13
|
+
export { PlatformConnector } from './components/onboarding/PlatformConnector';
|
|
14
|
+
export { OnboardingHeader } from './components/onboarding/OnboardingHeader';
|
|
15
|
+
export { PinInput } from './components/onboarding/PinInput';
|
|
16
|
+
|
|
17
|
+
// Hooks
|
|
18
|
+
export { useConnections } from './hooks/useConnections';
|
|
19
|
+
export { useCredentials } from './hooks/useCredentials';
|
|
20
|
+
|
|
21
|
+
// Utilities
|
|
22
|
+
export { storeCredentials, getCredentials, hasCredentials, deleteCredentials, updateCredentials, generateDeviceUsername, verifyCredentials } from './utils/secureStorage';
|
|
23
|
+
export { validateCredentials, createAccount, authenticate, refreshToken, getPlatformData, getUserProfile, updatePlatformConnections } from './utils/onairosApi';
|
|
24
|
+
export { rsaEncrypt, sha256, base64ToBuffer } from './utils/crypto';
|
|
25
|
+
export { logDebug, logError, isDebugMode } from './utils/debugHelper';
|
|
26
|
+
|
|
27
|
+
// Services
|
|
28
|
+
export { connectPlatform, disconnectPlatform, initializeOAuthService, cleanupOAuthService, storePlatformConnection } from './services/oauthService';
|
|
29
|
+
|
|
30
|
+
// Types
|
|
31
|
+
|
|
32
|
+
// Constants
|
|
33
|
+
export { COLORS, PLATFORMS, API_ENDPOINTS, STORAGE_KEYS, PIN_REQUIREMENTS, DEEP_LINK_CONFIG } from './constants';
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OnairosButton","UniversalOnboarding","Overlay","ConnectorScreen","PinCreationScreen","LoadingScreen","OAuthWebView","PlatformConnector","OnboardingHeader","PinInput","useConnections","useCredentials","storeCredentials","getCredentials","hasCredentials","deleteCredentials","updateCredentials","generateDeviceUsername","verifyCredentials","validateCredentials","createAccount","authenticate","refreshToken","getPlatformData","getUserProfile","updatePlatformConnections","rsaEncrypt","sha256","base64ToBuffer","logDebug","logError","isDebugMode","connectPlatform","disconnectPlatform","initializeOAuthService","cleanupOAuthService","storePlatformConnection","COLORS","PLATFORMS","API_ENDPOINTS","STORAGE_KEYS","PIN_REQUIREMENTS","DEEP_LINK_CONFIG"],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":"AAAA;AACA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,OAAO,QAAQ,sBAAsB;;AAE9C;AACA,SAASC,eAAe,QAAQ,sCAAsC;AACtE,SAASC,iBAAiB,QAAQ,wCAAwC;AAC1E,SAASC,aAAa,QAAQ,oCAAoC;;AAElE;AACA,SAASC,YAAY,QAAQ,sCAAsC;AACnE,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,gBAAgB,QAAQ,0CAA0C;AAC3E,SAASC,QAAQ,QAAQ,kCAAkC;;AAE3D;AACA,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,cAAc,QAAQ,wBAAwB;;AAEvD;AACA,SACEC,gBAAgB,EAChBC,cAAc,EACdC,cAAc,EACdC,iBAAiB,EACjBC,iBAAiB,EACjBC,sBAAsB,EACtBC,iBAAiB,QACZ,uBAAuB;AAE9B,SACEC,mBAAmB,EACnBC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,cAAc,EACdC,yBAAyB,QACpB,oBAAoB;AAE3B,SACEC,UAAU,EACVC,MAAM,EACNC,cAAc,QACT,gBAAgB;AAEvB,SACEC,QAAQ,EACRC,QAAQ,EACRC,WAAW,QACN,qBAAqB;;AAE5B;AACA,SACEC,eAAe,EACfC,kBAAkB,EAClBC,sBAAsB,EACtBC,mBAAmB,EACnBC,uBAAuB,QAClB,yBAAyB;;AAEhC;;AAkBA;AACA,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,YAAY,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAQ,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { Linking, Platform } from 'react-native';
|
|
2
|
+
import { updateCredentials } from '../utils/secureStorage';
|
|
3
|
+
import { sha256 } from '../utils/crypto';
|
|
4
|
+
|
|
5
|
+
// Define OAuth configuration types
|
|
6
|
+
|
|
7
|
+
// Platform-specific OAuth configurations
|
|
8
|
+
const OAUTH_CONFIGS = {
|
|
9
|
+
instagram: {
|
|
10
|
+
clientId: 'YOUR_INSTAGRAM_CLIENT_ID',
|
|
11
|
+
// Replace with actual client ID
|
|
12
|
+
redirectUri: 'onairosreact://auth/instagram',
|
|
13
|
+
scope: 'user_profile,user_media',
|
|
14
|
+
authorizationEndpoint: 'https://api.instagram.com/oauth/authorize',
|
|
15
|
+
tokenEndpoint: 'https://api.instagram.com/oauth/access_token',
|
|
16
|
+
responseType: 'code'
|
|
17
|
+
},
|
|
18
|
+
youtube: {
|
|
19
|
+
clientId: 'YOUR_YOUTUBE_CLIENT_ID',
|
|
20
|
+
// Replace with actual client ID
|
|
21
|
+
redirectUri: 'onairosreact://auth/youtube',
|
|
22
|
+
scope: 'https://www.googleapis.com/auth/youtube.readonly',
|
|
23
|
+
authorizationEndpoint: 'https://accounts.google.com/o/oauth2/auth',
|
|
24
|
+
tokenEndpoint: 'https://oauth2.googleapis.com/token',
|
|
25
|
+
responseType: 'code'
|
|
26
|
+
},
|
|
27
|
+
pinterest: {
|
|
28
|
+
clientId: 'YOUR_PINTEREST_CLIENT_ID',
|
|
29
|
+
// Replace with actual client ID
|
|
30
|
+
redirectUri: 'onairosreact://auth/pinterest',
|
|
31
|
+
scope: 'boards:read,pins:read',
|
|
32
|
+
authorizationEndpoint: 'https://www.pinterest.com/oauth/',
|
|
33
|
+
tokenEndpoint: 'https://api.pinterest.com/v5/oauth/token',
|
|
34
|
+
responseType: 'code'
|
|
35
|
+
},
|
|
36
|
+
reddit: {
|
|
37
|
+
clientId: 'YOUR_REDDIT_CLIENT_ID',
|
|
38
|
+
// Replace with actual client ID
|
|
39
|
+
redirectUri: 'onairosreact://auth/reddit',
|
|
40
|
+
scope: 'identity,read',
|
|
41
|
+
authorizationEndpoint: 'https://www.reddit.com/api/v1/authorize',
|
|
42
|
+
tokenEndpoint: 'https://www.reddit.com/api/v1/access_token',
|
|
43
|
+
responseType: 'code'
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generate a state value for OAuth to prevent CSRF attacks
|
|
49
|
+
*/
|
|
50
|
+
const generateState = () => {
|
|
51
|
+
const randomValue = Math.random().toString(36).substring(2, 15);
|
|
52
|
+
return sha256(randomValue).substring(0, 10);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Initialize OAuth service handlers and listeners
|
|
57
|
+
*/
|
|
58
|
+
export const initializeOAuthService = () => {
|
|
59
|
+
// Set up deep linking handlers for OAuth redirects
|
|
60
|
+
Linking.addEventListener('url', handleDeepLink);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Clean up OAuth service handlers and listeners
|
|
65
|
+
*/
|
|
66
|
+
export const cleanupOAuthService = () => {
|
|
67
|
+
// Clean up deep linking handlers
|
|
68
|
+
if (Platform.OS === 'android') {
|
|
69
|
+
Linking.removeEventListener('url', handleDeepLink);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Keep track of current OAuth state and callbacks
|
|
74
|
+
let currentOAuthState = null;
|
|
75
|
+
let currentOAuthPlatform = null;
|
|
76
|
+
let currentOAuthResolve = null;
|
|
77
|
+
let currentOAuthReject = null;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Handle deep link callbacks from OAuth providers
|
|
81
|
+
*/
|
|
82
|
+
const handleDeepLink = async event => {
|
|
83
|
+
try {
|
|
84
|
+
const {
|
|
85
|
+
url
|
|
86
|
+
} = event;
|
|
87
|
+
|
|
88
|
+
// Check if this is an OAuth callback URL
|
|
89
|
+
if (!url.startsWith('onairosreact://auth/')) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Extract platform from URL path
|
|
94
|
+
const platform = url.split('onairosreact://auth/')[1].split('?')[0];
|
|
95
|
+
|
|
96
|
+
// Only handle if it matches current OAuth flow
|
|
97
|
+
if (platform !== currentOAuthPlatform) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Parse URL parameters
|
|
102
|
+
const params = new URL(url).searchParams;
|
|
103
|
+
const code = params.get('code');
|
|
104
|
+
const state = params.get('state');
|
|
105
|
+
const error = params.get('error');
|
|
106
|
+
|
|
107
|
+
// Validate state to prevent CSRF attacks
|
|
108
|
+
if (state !== currentOAuthState) {
|
|
109
|
+
if (currentOAuthReject) {
|
|
110
|
+
currentOAuthReject(new Error('OAuth state mismatch - possible CSRF attack'));
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Handle errors
|
|
116
|
+
if (error) {
|
|
117
|
+
if (currentOAuthReject) {
|
|
118
|
+
currentOAuthReject(new Error(`OAuth error: ${error}`));
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Proceed with token exchange if code is present
|
|
124
|
+
if (code) {
|
|
125
|
+
const tokenResult = await exchangeCodeForToken(platform, code);
|
|
126
|
+
if (currentOAuthResolve) {
|
|
127
|
+
currentOAuthResolve(tokenResult);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
if (currentOAuthReject) {
|
|
131
|
+
currentOAuthReject(new Error('No authorization code received'));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error('Error handling OAuth deep link:', error);
|
|
136
|
+
if (currentOAuthReject) {
|
|
137
|
+
currentOAuthReject(error);
|
|
138
|
+
}
|
|
139
|
+
} finally {
|
|
140
|
+
// Reset state
|
|
141
|
+
currentOAuthState = null;
|
|
142
|
+
currentOAuthPlatform = null;
|
|
143
|
+
currentOAuthResolve = null;
|
|
144
|
+
currentOAuthReject = null;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Exchange OAuth authorization code for access token
|
|
150
|
+
*/
|
|
151
|
+
const exchangeCodeForToken = async (platform, code) => {
|
|
152
|
+
try {
|
|
153
|
+
const config = OAUTH_CONFIGS[platform];
|
|
154
|
+
if (!config) {
|
|
155
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Prepare token request parameters
|
|
159
|
+
const params = new URLSearchParams({
|
|
160
|
+
grant_type: 'authorization_code',
|
|
161
|
+
code,
|
|
162
|
+
redirect_uri: config.redirectUri,
|
|
163
|
+
client_id: config.clientId
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Exchange code for token
|
|
167
|
+
const response = await fetch(config.tokenEndpoint, {
|
|
168
|
+
method: 'POST',
|
|
169
|
+
headers: {
|
|
170
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
171
|
+
},
|
|
172
|
+
body: params.toString()
|
|
173
|
+
});
|
|
174
|
+
const data = await response.json();
|
|
175
|
+
if (!response.ok) {
|
|
176
|
+
throw new Error(data.error || 'Failed to exchange code for token');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Fetch user information based on the platform
|
|
180
|
+
const userInfo = await fetchUserInfo(platform, data.access_token);
|
|
181
|
+
return {
|
|
182
|
+
token: data.access_token,
|
|
183
|
+
refreshToken: data.refresh_token,
|
|
184
|
+
expiresIn: data.expires_in,
|
|
185
|
+
username: userInfo.username,
|
|
186
|
+
userId: userInfo.id
|
|
187
|
+
};
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error(`Error exchanging code for token (${platform}):`, error);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Fetch user information from the connected platform
|
|
196
|
+
*/
|
|
197
|
+
const fetchUserInfo = async (platform, accessToken) => {
|
|
198
|
+
try {
|
|
199
|
+
let endpoint;
|
|
200
|
+
let headers = {
|
|
201
|
+
Authorization: `Bearer ${accessToken}`
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// Platform-specific API endpoints for user info
|
|
205
|
+
switch (platform) {
|
|
206
|
+
case 'instagram':
|
|
207
|
+
endpoint = 'https://graph.instagram.com/me?fields=id,username';
|
|
208
|
+
break;
|
|
209
|
+
case 'youtube':
|
|
210
|
+
endpoint = 'https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true';
|
|
211
|
+
break;
|
|
212
|
+
case 'pinterest':
|
|
213
|
+
endpoint = 'https://api.pinterest.com/v5/user_account';
|
|
214
|
+
break;
|
|
215
|
+
case 'reddit':
|
|
216
|
+
endpoint = 'https://oauth.reddit.com/api/v1/me';
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
220
|
+
}
|
|
221
|
+
const response = await fetch(endpoint, {
|
|
222
|
+
headers
|
|
223
|
+
});
|
|
224
|
+
const data = await response.json();
|
|
225
|
+
if (!response.ok) {
|
|
226
|
+
throw new Error(data.error || 'Failed to fetch user info');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Extract user information based on platform-specific response format
|
|
230
|
+
switch (platform) {
|
|
231
|
+
case 'instagram':
|
|
232
|
+
return {
|
|
233
|
+
id: data.id,
|
|
234
|
+
username: data.username
|
|
235
|
+
};
|
|
236
|
+
case 'youtube':
|
|
237
|
+
return {
|
|
238
|
+
id: data.items[0].id,
|
|
239
|
+
username: data.items[0].snippet.title
|
|
240
|
+
};
|
|
241
|
+
case 'pinterest':
|
|
242
|
+
return {
|
|
243
|
+
id: data.id,
|
|
244
|
+
username: data.username || data.full_name
|
|
245
|
+
};
|
|
246
|
+
case 'reddit':
|
|
247
|
+
return {
|
|
248
|
+
id: data.id,
|
|
249
|
+
username: data.name
|
|
250
|
+
};
|
|
251
|
+
default:
|
|
252
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
253
|
+
}
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.error(`Error fetching user info (${platform}):`, error);
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Initiate OAuth flow for a specific platform
|
|
262
|
+
*/
|
|
263
|
+
export const connectPlatform = platform => {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
try {
|
|
266
|
+
const config = OAUTH_CONFIGS[platform];
|
|
267
|
+
if (!config) {
|
|
268
|
+
reject(new Error(`Unsupported platform: ${platform}`));
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Generate and save state for CSRF protection
|
|
273
|
+
const state = generateState();
|
|
274
|
+
currentOAuthState = state;
|
|
275
|
+
currentOAuthPlatform = platform;
|
|
276
|
+
currentOAuthResolve = resolve;
|
|
277
|
+
currentOAuthReject = reject;
|
|
278
|
+
|
|
279
|
+
// Build OAuth URL
|
|
280
|
+
const authUrl = new URL(config.authorizationEndpoint);
|
|
281
|
+
authUrl.searchParams.append('client_id', config.clientId);
|
|
282
|
+
authUrl.searchParams.append('redirect_uri', config.redirectUri);
|
|
283
|
+
authUrl.searchParams.append('response_type', config.responseType);
|
|
284
|
+
authUrl.searchParams.append('scope', config.scope);
|
|
285
|
+
authUrl.searchParams.append('state', state);
|
|
286
|
+
|
|
287
|
+
// Open browser to start OAuth flow
|
|
288
|
+
Linking.openURL(authUrl.toString());
|
|
289
|
+
} catch (error) {
|
|
290
|
+
reject(error);
|
|
291
|
+
|
|
292
|
+
// Reset state on error
|
|
293
|
+
currentOAuthState = null;
|
|
294
|
+
currentOAuthPlatform = null;
|
|
295
|
+
currentOAuthResolve = null;
|
|
296
|
+
currentOAuthReject = null;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Disconnect a platform by removing its credentials
|
|
303
|
+
*/
|
|
304
|
+
export const disconnectPlatform = async (platform, credentials) => {
|
|
305
|
+
try {
|
|
306
|
+
if (!credentials.platforms) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Create new credentials object with the platform removed
|
|
311
|
+
const updatedPlatforms = {
|
|
312
|
+
...credentials.platforms
|
|
313
|
+
};
|
|
314
|
+
delete updatedPlatforms[platform];
|
|
315
|
+
|
|
316
|
+
// Update stored credentials
|
|
317
|
+
const result = await updateCredentials({
|
|
318
|
+
platforms: updatedPlatforms
|
|
319
|
+
});
|
|
320
|
+
return result;
|
|
321
|
+
} catch (error) {
|
|
322
|
+
console.error(`Error disconnecting platform (${platform}):`, error);
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Store platform connection in credentials
|
|
329
|
+
*/
|
|
330
|
+
export const storePlatformConnection = async (platform, connectionData, credentials) => {
|
|
331
|
+
try {
|
|
332
|
+
// Create updated platforms object
|
|
333
|
+
const updatedPlatforms = {
|
|
334
|
+
...credentials.platforms,
|
|
335
|
+
[platform]: {
|
|
336
|
+
token: connectionData.token,
|
|
337
|
+
username: connectionData.username,
|
|
338
|
+
userId: connectionData.userId
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// Update stored credentials
|
|
343
|
+
const result = await updateCredentials({
|
|
344
|
+
platforms: updatedPlatforms
|
|
345
|
+
});
|
|
346
|
+
return result;
|
|
347
|
+
} catch (error) {
|
|
348
|
+
console.error(`Error storing platform connection (${platform}):`, error);
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
//# sourceMappingURL=oauthService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Linking","Platform","updateCredentials","sha256","OAUTH_CONFIGS","instagram","clientId","redirectUri","scope","authorizationEndpoint","tokenEndpoint","responseType","youtube","pinterest","reddit","generateState","randomValue","Math","random","toString","substring","initializeOAuthService","addEventListener","handleDeepLink","cleanupOAuthService","OS","removeEventListener","currentOAuthState","currentOAuthPlatform","currentOAuthResolve","currentOAuthReject","event","url","startsWith","platform","split","params","URL","searchParams","code","get","state","error","Error","tokenResult","exchangeCodeForToken","console","config","URLSearchParams","grant_type","redirect_uri","client_id","response","fetch","method","headers","body","data","json","ok","userInfo","fetchUserInfo","access_token","token","refreshToken","refresh_token","expiresIn","expires_in","username","userId","id","accessToken","endpoint","Authorization","items","snippet","title","full_name","name","connectPlatform","Promise","resolve","reject","authUrl","append","openURL","disconnectPlatform","credentials","platforms","updatedPlatforms","result","storePlatformConnection","connectionData"],"sourceRoot":"..\\..\\..\\src","sources":["services/oauthService.ts"],"mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,cAAc;AAChD,SAASC,iBAAiB,QAA4B,wBAAwB;AAC9E,SAASC,MAAM,QAAQ,iBAAiB;;AAExC;;AAUA;AACA,MAAMC,aAA0C,GAAG;EACjDC,SAAS,EAAE;IACTC,QAAQ,EAAE,0BAA0B;IAAE;IACtCC,WAAW,EAAE,+BAA+B;IAC5CC,KAAK,EAAE,yBAAyB;IAChCC,qBAAqB,EAAE,2CAA2C;IAClEC,aAAa,EAAE,8CAA8C;IAC7DC,YAAY,EAAE;EAChB,CAA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AM,GAAG,MAAMxF,iBAAiB,CAAC;MACrCsF,SAAS,EAAEC;IACb,CAAC,CAAC;IAEF,OAAOC,MAAM;EACf,CAAC,CAAC,OAAOhD,KAAK,EAAE;IACdI,OAAO,CAACJ,KAAK,CAAC,iCAAiCR,QAAQ,IAAI,EAAEQ,KAAK,CAAC;IACnE,OAAO,KAAK;EACd;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMiD,uBAAuB,GAAG,MAAAA,CACrCzD,QAAgB,EAChB0D,cAAmB,EACnBL,WAA+B,KACV;EACrB,IAAI;IACF;IACA,MAAME,gBAAgB,GAAG;MACvB,GAAGF,WAAW,CAACC,SAAS;MACxB,CAACtD,QAAQ,GAAG;QACV6B,KAAK,EAAE6B,cAAc,CAAC7B,KAAK;QAC3BK,QAAQ,EAAEwB,cAAc,CAACxB,QAAQ;QACjCC,MAAM,EAAEuB,cAAc,CAACvB;MACzB;IACF,CAAC;;IAED;IACA,MAAMqB,MAAM,GAAG,MAAMxF,iBAAiB,CAAC;MACrCsF,SAAS,EAAEC;IACb,CAAC,CAAC;IAEF,OAAOC,MAAM;EACf,CAAC,CAAC,OAAOhD,KAAK,EAAE;IACdI,OAAO,CAACJ,KAAK,CAAC,sCAAsCR,QAAQ,IAAI,EAAEQ,KAAK,CAAC;IACxE,OAAO,KAAK;EACd;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"..\\..\\..\\src","sources":["types/declarations.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"..\\..\\..\\src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
|