@onairos/react-native 3.0.26 → 3.0.27
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/TrainingModal.js +16 -120
- package/lib/commonjs/components/TrainingModal.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +98 -186
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js +49 -124
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/commonjs/constants/index.js +3 -3
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/services/platformAuthService.js +81 -99
- package/lib/commonjs/services/platformAuthService.js.map +1 -1
- package/lib/module/components/TrainingModal.js +17 -120
- package/lib/module/components/TrainingModal.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +99 -187
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js +50 -125
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/constants/index.js +3 -3
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/index.js +9 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/platformAuthService.js +80 -97
- package/lib/module/services/platformAuthService.js.map +1 -1
- package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
- package/lib/typescript/services/platformAuthService.d.ts +5 -11
- package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/TrainingModal.tsx +61 -202
- package/src/components/UniversalOnboarding.tsx +86 -179
- package/src/components/onboarding/OAuthWebView.tsx +59 -121
- package/src/constants/index.ts +3 -3
- package/src/services/platformAuthService.ts +80 -115
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import { View, StyleSheet, ActivityIndicator, SafeAreaView, TouchableOpacity
|
|
2
|
+
import { View, StyleSheet, ActivityIndicator, SafeAreaView, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { WebView } from 'react-native-webview';
|
|
4
4
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
5
5
|
import { COLORS } from '../../constants';
|
|
6
|
-
import { isOAuthSuccess, handleOAuthCallback } from '../../services/platformAuthService';
|
|
7
6
|
export const OAuthWebView = ({
|
|
8
7
|
url,
|
|
9
8
|
platform,
|
|
@@ -12,54 +11,33 @@ export const OAuthWebView = ({
|
|
|
12
11
|
onSuccess
|
|
13
12
|
}) => {
|
|
14
13
|
const [loading, setLoading] = useState(true);
|
|
15
|
-
const [currentUrl, setCurrentUrl] = useState(url);
|
|
16
14
|
const handleNavigationStateChange = useCallback(navState => {
|
|
17
|
-
console.log(
|
|
18
|
-
setCurrentUrl(navState.url);
|
|
15
|
+
console.log('Navigation state changed:', navState.url);
|
|
19
16
|
|
|
20
|
-
// Check for final redirect to onairos.uk/Home
|
|
21
|
-
|
|
22
|
-
console.log(`[OAuthWebView] Detected final redirect to onairos.uk/Home for ${platform}`);
|
|
17
|
+
// Check for the final redirect to onairos.uk/Home
|
|
18
|
+
const isFinalRedirect = navState.url.includes('onairos.uk/Home');
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
onSuccess('success');
|
|
27
|
-
if (onComplete) {
|
|
28
|
-
onComplete();
|
|
29
|
-
}
|
|
30
|
-
}, 500);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Check for platform-specific success patterns using the service
|
|
35
|
-
if (platform && isOAuthSuccess(navState.url, platform)) {
|
|
36
|
-
console.log(`[OAuthWebView] Detected platform-specific success pattern for ${platform}`);
|
|
20
|
+
// Check for Instagram-specific success patterns
|
|
21
|
+
const isInstagramSuccess = platform === 'instagram' && (navState.url.includes('instagram.com/oauth/authorize') || navState.url.includes('instagram.com/accounts/login') || navState.url.includes('code='));
|
|
37
22
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Don't close immediately for YouTube, wait for the onairos.uk/Home redirect
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// For other platforms, close immediately
|
|
46
|
-
setTimeout(() => {
|
|
47
|
-
onSuccess('success');
|
|
48
|
-
if (onComplete) {
|
|
49
|
-
onComplete();
|
|
50
|
-
}
|
|
51
|
-
}, 300);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
23
|
+
// Check for platform-specific success patterns
|
|
24
|
+
const isYouTubeSuccess = platform === 'youtube' && navState.url.includes('accounts.google.com/o/oauth2/approval');
|
|
25
|
+
const isLinkedInSuccess = platform === 'linkedin' && navState.url.includes('linkedin.com/oauth/v2/authorization/success');
|
|
54
26
|
|
|
55
27
|
// Check for callback URLs with authorization codes
|
|
56
|
-
|
|
57
|
-
console.log(`[OAuthWebView] Detected callback URL for ${platform}:`, navState.url);
|
|
28
|
+
const isCallbackUrl = navState.url.includes('/callback') || navState.url.includes('code=');
|
|
58
29
|
|
|
30
|
+
// If we detect success, close the window and update connection status
|
|
31
|
+
if (isFinalRedirect || isInstagramSuccess || isYouTubeSuccess || isLinkedInSuccess) {
|
|
32
|
+
onSuccess('success');
|
|
33
|
+
if (onComplete) {
|
|
34
|
+
onComplete();
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
} else if (isCallbackUrl) {
|
|
59
38
|
// Extract the authorization code
|
|
60
|
-
const authCode =
|
|
39
|
+
const authCode = extractAuthCode(navState.url);
|
|
61
40
|
if (authCode) {
|
|
62
|
-
console.log(`[OAuthWebView] Extracted auth code for ${platform}:`, authCode);
|
|
63
41
|
onSuccess(authCode);
|
|
64
42
|
if (onComplete) {
|
|
65
43
|
onComplete();
|
|
@@ -68,22 +46,27 @@ export const OAuthWebView = ({
|
|
|
68
46
|
return;
|
|
69
47
|
}
|
|
70
48
|
}, [platform, onComplete, onSuccess]);
|
|
71
|
-
const handleLoadStart = useCallback(() => {
|
|
72
|
-
setLoading(true);
|
|
73
|
-
}, []);
|
|
74
49
|
const handleLoadEnd = useCallback(() => {
|
|
75
50
|
setLoading(false);
|
|
76
51
|
}, []);
|
|
77
|
-
const handleError = useCallback(syntheticEvent => {
|
|
78
|
-
const {
|
|
79
|
-
nativeEvent
|
|
80
|
-
} = syntheticEvent;
|
|
81
|
-
console.error(`[OAuthWebView] WebView error for ${platform}:`, nativeEvent);
|
|
82
|
-
setLoading(false);
|
|
83
|
-
}, [platform]);
|
|
84
52
|
|
|
85
|
-
//
|
|
86
|
-
const
|
|
53
|
+
// Extract auth code from redirect URL
|
|
54
|
+
const extractAuthCode = redirectUrl => {
|
|
55
|
+
try {
|
|
56
|
+
// First try to extract code from URL parameters
|
|
57
|
+
const codeMatch = redirectUrl.match(/code=([^&]+)/);
|
|
58
|
+
if (codeMatch && codeMatch[1]) {
|
|
59
|
+
return codeMatch[1];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// If that fails, try parsing as URL
|
|
63
|
+
const url = new URL(redirectUrl);
|
|
64
|
+
return url.searchParams.get('code') || '';
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Error extracting auth code:', error);
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
};
|
|
87
70
|
return /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
88
71
|
style: styles.container
|
|
89
72
|
}, /*#__PURE__*/React.createElement(View, {
|
|
@@ -101,57 +84,31 @@ export const OAuthWebView = ({
|
|
|
101
84
|
name: getPlatformIcon(platform || 'default'),
|
|
102
85
|
size: 20,
|
|
103
86
|
color: getPlatformColor(platform || 'default')
|
|
104
|
-
}), /*#__PURE__*/React.createElement(
|
|
105
|
-
style: styles.platformTitle
|
|
106
|
-
}, "Connect ", platform ? platform.charAt(0).toUpperCase() + platform.slice(1) : 'Account')), /*#__PURE__*/React.createElement(View, {
|
|
107
|
-
style: styles.placeholder
|
|
108
|
-
})), /*#__PURE__*/React.createElement(WebView, {
|
|
87
|
+
}))), /*#__PURE__*/React.createElement(WebView, {
|
|
109
88
|
source: {
|
|
110
89
|
uri: url
|
|
111
90
|
},
|
|
112
91
|
onNavigationStateChange: handleNavigationStateChange,
|
|
113
|
-
onLoadStart: handleLoadStart,
|
|
114
92
|
onLoadEnd: handleLoadEnd,
|
|
115
|
-
onError: handleError,
|
|
116
93
|
startInLoadingState: true,
|
|
117
94
|
renderLoading: () => /*#__PURE__*/React.createElement(View, null),
|
|
118
|
-
style: styles.webView
|
|
119
|
-
// Essential WebView configuration for OAuth
|
|
120
|
-
,
|
|
95
|
+
style: styles.webView,
|
|
121
96
|
javaScriptEnabled: true,
|
|
122
97
|
domStorageEnabled: true,
|
|
123
|
-
cacheEnabled:
|
|
124
|
-
incognito: false
|
|
125
|
-
,
|
|
126
|
-
|
|
127
|
-
,
|
|
128
|
-
thirdPartyCookiesEnabled: true // Required for OAuth flows
|
|
129
|
-
,
|
|
130
|
-
userAgent: userAgent // iOS Safari for better compatibility
|
|
131
|
-
// Additional settings for better OAuth support
|
|
132
|
-
,
|
|
98
|
+
cacheEnabled: false,
|
|
99
|
+
incognito: false,
|
|
100
|
+
sharedCookiesEnabled: true,
|
|
101
|
+
thirdPartyCookiesEnabled: true,
|
|
133
102
|
allowsInlineMediaPlayback: true,
|
|
134
103
|
mediaPlaybackRequiresUserAction: false,
|
|
135
|
-
allowsBackForwardNavigationGestures: true
|
|
136
|
-
|
|
137
|
-
,
|
|
138
|
-
allowsLinkPreview: false,
|
|
139
|
-
allowFileAccess: false,
|
|
140
|
-
allowUniversalAccessFromFileURLs: false,
|
|
141
|
-
mixedContentMode: "compatibility"
|
|
104
|
+
allowsBackForwardNavigationGestures: true,
|
|
105
|
+
userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1"
|
|
142
106
|
}), loading && /*#__PURE__*/React.createElement(View, {
|
|
143
107
|
style: styles.loadingContainer
|
|
144
108
|
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
145
109
|
size: "large",
|
|
146
110
|
color: COLORS.primary
|
|
147
|
-
})
|
|
148
|
-
style: styles.loadingText
|
|
149
|
-
}, "Connecting to ", platform ? platform.charAt(0).toUpperCase() + platform.slice(1) : 'platform', "...")), __DEV__ && /*#__PURE__*/React.createElement(View, {
|
|
150
|
-
style: styles.debugContainer
|
|
151
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
152
|
-
style: styles.debugText,
|
|
153
|
-
numberOfLines: 1
|
|
154
|
-
}, currentUrl)));
|
|
111
|
+
})));
|
|
155
112
|
};
|
|
156
113
|
|
|
157
114
|
/**
|
|
@@ -167,8 +124,6 @@ const getPlatformIcon = platform => {
|
|
|
167
124
|
return 'push-pin';
|
|
168
125
|
case 'reddit':
|
|
169
126
|
return 'forum';
|
|
170
|
-
case 'email':
|
|
171
|
-
return 'email';
|
|
172
127
|
default:
|
|
173
128
|
return 'link';
|
|
174
129
|
}
|
|
@@ -187,8 +142,6 @@ const getPlatformColor = platform => {
|
|
|
187
142
|
return '#E60023';
|
|
188
143
|
case 'reddit':
|
|
189
144
|
return '#FF4500';
|
|
190
|
-
case 'email':
|
|
191
|
-
return '#4285F4';
|
|
192
145
|
default:
|
|
193
146
|
return COLORS.primary;
|
|
194
147
|
}
|
|
@@ -209,50 +162,22 @@ const styles = StyleSheet.create({
|
|
|
209
162
|
},
|
|
210
163
|
titleContainer: {
|
|
211
164
|
flex: 1,
|
|
212
|
-
|
|
213
|
-
alignItems: 'center',
|
|
214
|
-
justifyContent: 'center'
|
|
215
|
-
},
|
|
216
|
-
platformTitle: {
|
|
217
|
-
fontSize: 16,
|
|
218
|
-
fontWeight: '600',
|
|
219
|
-
color: '#000',
|
|
220
|
-
marginLeft: 8
|
|
165
|
+
alignItems: 'center'
|
|
221
166
|
},
|
|
222
167
|
closeButton: {
|
|
223
168
|
padding: 8,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
width: 40
|
|
169
|
+
position: 'absolute',
|
|
170
|
+
left: 16,
|
|
171
|
+
zIndex: 10
|
|
228
172
|
},
|
|
229
173
|
webView: {
|
|
230
174
|
flex: 1
|
|
231
175
|
},
|
|
232
176
|
loadingContainer: {
|
|
233
177
|
...StyleSheet.absoluteFillObject,
|
|
234
|
-
backgroundColor: 'rgba(255, 255, 255, 0.
|
|
178
|
+
backgroundColor: 'rgba(255, 255, 255, 0.8)',
|
|
235
179
|
alignItems: 'center',
|
|
236
180
|
justifyContent: 'center'
|
|
237
|
-
},
|
|
238
|
-
loadingText: {
|
|
239
|
-
fontSize: 16,
|
|
240
|
-
color: '#666',
|
|
241
|
-
marginTop: 16,
|
|
242
|
-
textAlign: 'center'
|
|
243
|
-
},
|
|
244
|
-
debugContainer: {
|
|
245
|
-
position: 'absolute',
|
|
246
|
-
bottom: 0,
|
|
247
|
-
left: 0,
|
|
248
|
-
right: 0,
|
|
249
|
-
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
250
|
-
padding: 8
|
|
251
|
-
},
|
|
252
|
-
debugText: {
|
|
253
|
-
color: '#fff',
|
|
254
|
-
fontSize: 12,
|
|
255
|
-
fontFamily: 'monospace'
|
|
256
181
|
}
|
|
257
182
|
});
|
|
258
183
|
//# sourceMappingURL=OAuthWebView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useState","View","StyleSheet","ActivityIndicator","SafeAreaView","TouchableOpacity","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useState","View","StyleSheet","ActivityIndicator","SafeAreaView","TouchableOpacity","WebView","Icon","COLORS","OAuthWebView","url","platform","onComplete","onClose","onSuccess","loading","setLoading","handleNavigationStateChange","navState","console","log","isFinalRedirect","includes","isInstagramSuccess","isYouTubeSuccess","isLinkedInSuccess","isCallbackUrl","authCode","extractAuthCode","handleLoadEnd","redirectUrl","codeMatch","match","URL","searchParams","get","error","createElement","style","styles","container","header","onPress","closeButton","name","size","color","titleContainer","getPlatformIcon","getPlatformColor","source","uri","onNavigationStateChange","onLoadEnd","startInLoadingState","renderLoading","webView","javaScriptEnabled","domStorageEnabled","cacheEnabled","incognito","sharedCookiesEnabled","thirdPartyCookiesEnabled","allowsInlineMediaPlayback","mediaPlaybackRequiresUserAction","allowsBackForwardNavigationGestures","userAgent","loadingContainer","primary","create","flex","backgroundColor","flexDirection","alignItems","height","borderBottomWidth","borderBottomColor","paddingHorizontal","padding","position","left","zIndex","absoluteFillObject","justifyContent"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/onboarding/OAuthWebView.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACpD,SAASC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,gBAAgB,QAAQ,cAAc;AAClG,SAASC,OAAO,QAA2B,sBAAsB;AACjE,OAAOC,IAAI,MAAM,yCAAyC;AAC1D,SAASC,MAAM,QAAQ,iBAAiB;AAGxC,OAAO,MAAMC,YAAyC,GAAGA,CAAC;EACxDC,GAAG;EACHC,QAAQ;EACRC,UAAU;EACVC,OAAO;EACPC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGhB,QAAQ,CAAC,IAAI,CAAC;EAE5C,MAAMiB,2BAA2B,GAAGlB,WAAW,CAC5CmB,QAA2B,IAAK;IAC/BC,OAAO,CAACC,GAAG,CAAC,2BAA2B,EAAEF,QAAQ,CAACR,GAAG,CAAC;;IAEtD;IACA,MAAMW,eAAe,GAAGH,QAAQ,CAACR,GAAG,CAACY,QAAQ,CAAC,iBAAiB,CAAC;;IAEhE;IACA,MAAMC,kBAAkB,GACtBZ,QAAQ,KAAK,WAAW,KACvBO,QAAQ,CAACR,GAAG,CAACY,QAAQ,CAAC,+BAA+B,CAAC,IACtDJ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CAAC;EAC/B7B,SAAS,EAAE;IACT8B,IAAI,EAAE,CAAC;IACPC,eAAe,EAAE;EACnB,CAAC;EACD9B,MAAM,EAAE;IACN+B,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,MAAM,EAAE,EAAE;IACVH,eAAe,EAAE,SAAS;IAC1BI,iBAAiB,EAAE,CAAC;IACpBC,iBAAiB,EAAE,SAAS;IAC5BC,iBAAiB,EAAE;EACrB,CAAC;EACD9B,cAAc,EAAE;IACduB,IAAI,EAAE,CAAC;IACPG,UAAU,EAAE;EACd,CAAC;EACD9B,WAAW,EAAE;IACXmC,OAAO,EAAE,CAAC;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,EAAE;IACRC,MAAM,EAAE;EACV,CAAC;EACDzB,OAAO,EAAE;IACPc,IAAI,EAAE;EACR,CAAC;EACDH,gBAAgB,EAAE;IAChB,GAAGjE,UAAU,CAACgF,kBAAkB;IAChCX,eAAe,EAAE,0BAA0B;IAC3CE,UAAU,EAAE,QAAQ;IACpBU,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -70,8 +70,8 @@ export const PIN_REQUIREMENTS = {
|
|
|
70
70
|
requireSpecialChar: true
|
|
71
71
|
};
|
|
72
72
|
export const DEEP_LINK_CONFIG = {
|
|
73
|
-
scheme: '
|
|
74
|
-
host: '
|
|
75
|
-
redirectUri: '
|
|
73
|
+
scheme: 'onairosanime',
|
|
74
|
+
host: 'authenticate',
|
|
75
|
+
redirectUri: 'onairosanime://auth/'
|
|
76
76
|
};
|
|
77
77
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["COLORS","primary","headerBg","text","secondary","border","success","error","instagram","pinterest","reddit","youtube","white","black","gray","lightGray","PLATFORMS","name","icon","color","description","API_ENDPOINTS","base","oauth","callback","STORAGE_KEYS","credentials","connections","PIN_REQUIREMENTS","minLength","requireUppercase","requireLowercase","requireNumber","requireSpecialChar","DEEP_LINK_CONFIG","scheme","host","redirectUri"],"sourceRoot":"..\\..\\..\\src","sources":["constants/index.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAG;EACpBC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE,SAAS;EACnBC,IAAI,EAAE;IACJF,OAAO,EAAE,SAAS;IAClBG,SAAS,EAAE;EACb,CAAC;EACDC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,SAAS;EAChBC,SAAS,EAAE,SAAS;EACpBC,SAAS,EAAE,SAAS;EACpBC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE,SAAS;EACfC,SAAS,EAAE;AACb,CAAC;AAED,OAAO,MAAMC,SAAyC,GAAG;EACvDR,SAAS,EAAE;IACTS,IAAI,EAAE,WAAW;IACjBC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAEnB,MAAM,CAACQ,SAAS;IACvBY,WAAW,EAAE;EACf,CAAC;EACDX,SAAS,EAAE;IACTQ,IAAI,EAAE,WAAW;IACjBC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAEnB,MAAM,CAACS,SAAS;IACvBW,WAAW,EAAE;EACf,CAAC;EACDV,MAAM,EAAE;IACNO,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAEnB,MAAM,CAACU,MAAM;IACpBU,WAAW,EAAE;EACf,CAAC;EACDT,OAAO,EAAE;IACPM,IAAI,EAAE,SAAS;IACfC,IAAI,EAAE,SAAS;IACfC,KAAK,EAAEnB,MAAM,CAACW,OAAO;IACrBS,WAAW,EAAE;EACf;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC3BC,IAAI,EAAE,yBAAyB;EAC/BC,KAAK,EAAE;IACLf,SAAS,EAAE,iBAAiB;IAC5BC,SAAS,EAAE,iBAAiB;IAC5BC,MAAM,EAAE,cAAc;IACtBC,OAAO,EAAE;EACX,CAAC;EACDa,QAAQ,EAAE;IACRhB,SAAS,EAAE,qBAAqB;IAChCC,SAAS,EAAE,qBAAqB;IAChCC,MAAM,EAAE,kBAAkB;IAC1BC,OAAO,EAAE;EACX;AACF,CAAC;AAED,OAAO,MAAMc,YAAY,GAAG;EAC1BC,WAAW,EAAE,qBAAqB;EAClCC,WAAW,EAAE;AACf,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,SAAS,EAAE,CAAC;EACZC,gBAAgB,EAAE,IAAI;EACtBC,gBAAgB,EAAE,IAAI;EACtBC,aAAa,EAAE,IAAI;EACnBC,kBAAkB,EAAE;AACtB,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"names":["COLORS","primary","headerBg","text","secondary","border","success","error","instagram","pinterest","reddit","youtube","white","black","gray","lightGray","PLATFORMS","name","icon","color","description","API_ENDPOINTS","base","oauth","callback","STORAGE_KEYS","credentials","connections","PIN_REQUIREMENTS","minLength","requireUppercase","requireLowercase","requireNumber","requireSpecialChar","DEEP_LINK_CONFIG","scheme","host","redirectUri"],"sourceRoot":"..\\..\\..\\src","sources":["constants/index.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAG;EACpBC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE,SAAS;EACnBC,IAAI,EAAE;IACJF,OAAO,EAAE,SAAS;IAClBG,SAAS,EAAE;EACb,CAAC;EACDC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,SAAS;EAChBC,SAAS,EAAE,SAAS;EACpBC,SAAS,EAAE,SAAS;EACpBC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE,S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AgB,GAAG;EAC9BC,MAAM,EAAE,cAAc;EACtBC,IAAI,EAAE,cAAc;EACpBC,WAAW,EAAE;AACf,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
1
|
+
import OnairosButton from './components/OnairosButton';
|
|
2
|
+
import * as AuthUtils from './utils/auth';
|
|
3
|
+
import * as CryptoUtils from './utils/crypto';
|
|
4
|
+
import * as ApiUtils from './utils/api';
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import { OnairosButton } from './components/OnairosButton';
|
|
9
|
-
import { Overlay } from './components/Overlay';
|
|
10
|
-
import { UniversalOnboarding } from './components/UniversalOnboarding';
|
|
6
|
+
// Export the main component
|
|
7
|
+
export default OnairosButton;
|
|
11
8
|
|
|
12
|
-
// Export
|
|
9
|
+
// Export utilities for advanced usage
|
|
10
|
+
export { AuthUtils, CryptoUtils, ApiUtils };
|
|
11
|
+
//# sourceMappingURL=index.js.mapport main components
|
|
13
12
|
export { Onairos } from './components/Onairos';
|
|
14
13
|
export { OnairosButton } from './components/OnairosButton';
|
|
15
14
|
export { Overlay } from './components/Overlay';
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["OnairosButton","AuthUtils","CryptoUtils","ApiUtils"],"sourceRoot":"..\\..\\src","sources":["index.js"],"mappings":"AAAA,OAAOA,aAAa,MAAM,4BAA4B;AACtD,OAAO,KAAKC,SAAS,MAAM,cAAc;AACzC,OAAO,KAAKC,WAAW,MAAM,gBAAgB;AAC7C,OAAO,KAAKC,QAAQ,MAAM,aAAa;;AAEvC;AACA,eAAeH,aAAa;;AAE5B;AACA,SACEC,SAAS,EACTC,WAAW,EACXC,QAAQ","ignoreList":[]}
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
const PLATFORM_AUTH_CONFIG = {
|
|
5
5
|
instagram: {
|
|
6
6
|
hasNativeSDK: false,
|
|
7
|
-
// Instagram
|
|
7
|
+
// Instagram uses OAuth WebView flow
|
|
8
8
|
authEndpoint: 'https://api2.onairos.uk/instagram/authorize',
|
|
9
9
|
color: '#E1306C'
|
|
10
10
|
},
|
|
11
11
|
youtube: {
|
|
12
|
-
hasNativeSDK:
|
|
13
|
-
//
|
|
12
|
+
hasNativeSDK: true,
|
|
13
|
+
// YouTube uses Google Sign-In SDK
|
|
14
|
+
nativeSDKPackage: '@react-native-google-signin/google-signin',
|
|
14
15
|
authEndpoint: 'https://api2.onairos.uk/youtube/authorize',
|
|
15
16
|
color: '#FF0000'
|
|
16
17
|
},
|
|
@@ -56,72 +57,89 @@ export const getPlatformColor = platform => {
|
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
|
-
* Initiates the OAuth flow for a platform
|
|
60
|
+
* Initiates the OAuth flow for a platform
|
|
60
61
|
* @param platform The platform to authenticate with
|
|
61
|
-
* @param
|
|
62
|
-
* @
|
|
62
|
+
* @param username The username to associate with the authentication
|
|
63
|
+
* @param appName The app name to use for the OAuth session (optional)
|
|
64
|
+
* @returns A Promise that resolves to the OAuth URL to open in a WebView or null if using native SDK
|
|
63
65
|
*/
|
|
64
|
-
export const initiateOAuth = async (platform,
|
|
66
|
+
export const initiateOAuth = async (platform, username, appName) => {
|
|
65
67
|
try {
|
|
66
68
|
// Check if the platform is supported
|
|
67
69
|
if (!PLATFORM_AUTH_CONFIG[platform]) {
|
|
68
70
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
69
71
|
}
|
|
70
|
-
console.log(`Initiating OAuth for ${platform} with user: ${userEmail}`);
|
|
71
72
|
|
|
72
|
-
//
|
|
73
|
-
|
|
73
|
+
// Check if platform has a native SDK
|
|
74
|
+
if (PLATFORM_AUTH_CONFIG[platform].hasNativeSDK) {
|
|
75
|
+
// Return null to indicate that we should use the native SDK
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Handle Instagram with specific API format
|
|
80
|
+
if (platform === 'instagram') {
|
|
81
|
+
const state = 'djksbfds';
|
|
82
|
+
const jsonData = {
|
|
83
|
+
session: {
|
|
84
|
+
oauthState: state,
|
|
85
|
+
username: username || 'Avatar'
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const response = await fetch('https://api2.onairos.uk/instagram/authorize', {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
headers: {
|
|
91
|
+
'Content-Type': 'application/json'
|
|
92
|
+
},
|
|
93
|
+
body: JSON.stringify(jsonData)
|
|
94
|
+
});
|
|
95
|
+
const responseData = await response.json();
|
|
96
|
+
if (responseData.instagramURL) {
|
|
97
|
+
return responseData.instagramURL;
|
|
98
|
+
}
|
|
99
|
+
throw new Error('No Instagram URL found in response');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Prepare the request body for other platforms
|
|
103
|
+
const jsonData = {
|
|
74
104
|
session: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
105
|
+
oauthState: 'djksbfds',
|
|
106
|
+
// Use same state for all platforms
|
|
107
|
+
username: username || 'Avatar',
|
|
108
|
+
appName: appName || 'DefaultApp'
|
|
78
109
|
}
|
|
79
110
|
};
|
|
80
|
-
console.log(`Making request to: ${PLATFORM_AUTH_CONFIG[platform].authEndpoint}`);
|
|
81
|
-
console.log('Request body:', JSON.stringify(requestBody, null, 2));
|
|
82
111
|
|
|
83
|
-
// Make the request to get the OAuth URL
|
|
112
|
+
// Make the request to get the OAuth URL
|
|
84
113
|
const response = await fetch(PLATFORM_AUTH_CONFIG[platform].authEndpoint, {
|
|
85
114
|
method: 'POST',
|
|
86
115
|
headers: {
|
|
87
|
-
'Content-Type': 'application/json'
|
|
88
|
-
'Accept': 'application/json'
|
|
116
|
+
'Content-Type': 'application/json'
|
|
89
117
|
},
|
|
90
|
-
body: JSON.stringify(
|
|
118
|
+
body: JSON.stringify(jsonData)
|
|
91
119
|
});
|
|
92
|
-
console.log(`Response status: ${response.status}`);
|
|
93
|
-
console.log(`Response headers:`, response.headers);
|
|
94
|
-
if (!response.ok) {
|
|
95
|
-
const errorText = await response.text();
|
|
96
|
-
console.error(`HTTP error! status: ${response.status}, body: ${errorText}`);
|
|
97
|
-
throw new Error(`HTTP error! status: ${response.status} - ${errorText}`);
|
|
98
|
-
}
|
|
99
120
|
|
|
100
121
|
// Parse the response
|
|
101
122
|
const data = await response.json();
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (!oauthUrl) {
|
|
121
|
-
throw new Error(`No OAuth URL found in response for ${platform}. Response: ${JSON.stringify(data)}`);
|
|
123
|
+
|
|
124
|
+
// Check if the response contains the OAuth URL based on platform
|
|
125
|
+
switch (platform) {
|
|
126
|
+
case 'reddit':
|
|
127
|
+
if (data.redditURL) return data.redditURL;
|
|
128
|
+
break;
|
|
129
|
+
case 'pinterest':
|
|
130
|
+
if (data.pinterestURL) return data.pinterestURL;
|
|
131
|
+
break;
|
|
132
|
+
case 'youtube':
|
|
133
|
+
if (data.youtubeURL) return data.youtubeURL;
|
|
134
|
+
break;
|
|
135
|
+
case 'email':
|
|
136
|
+
if (data.emailURL) return data.emailURL;
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
if (data.url) return data.url;
|
|
140
|
+
break;
|
|
122
141
|
}
|
|
123
|
-
|
|
124
|
-
return oauthUrl;
|
|
142
|
+
throw new Error(`No OAuth URL found in response for ${platform}`);
|
|
125
143
|
} catch (error) {
|
|
126
144
|
console.error(`Error initiating OAuth for ${platform}:`, error);
|
|
127
145
|
throw error;
|
|
@@ -135,9 +153,17 @@ export const initiateOAuth = async (platform, userEmail) => {
|
|
|
135
153
|
*/
|
|
136
154
|
export const initiateNativeAuth = async platform => {
|
|
137
155
|
try {
|
|
138
|
-
// Currently
|
|
139
|
-
|
|
140
|
-
|
|
156
|
+
// Currently only YouTube (Google Sign-In) is supported
|
|
157
|
+
if (platform === 'youtube') {
|
|
158
|
+
// This is a placeholder for the actual implementation
|
|
159
|
+
// In a real implementation, you would import and use the Google Sign-In SDK
|
|
160
|
+
console.log('Initiating native Google Sign-In for YouTube');
|
|
161
|
+
|
|
162
|
+
// Simulate a successful authentication
|
|
163
|
+
// In a real implementation, this would be the result of the Google Sign-In flow
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
throw new Error(`Native authentication not supported for ${platform}`);
|
|
141
167
|
} catch (error) {
|
|
142
168
|
console.error(`Error initiating native auth for ${platform}:`, error);
|
|
143
169
|
throw error;
|
|
@@ -151,15 +177,11 @@ export const initiateNativeAuth = async platform => {
|
|
|
151
177
|
*/
|
|
152
178
|
export const handleOAuthCallback = url => {
|
|
153
179
|
try {
|
|
154
|
-
console.log('Handling OAuth callback URL:', url);
|
|
155
|
-
|
|
156
180
|
// Parse the URL
|
|
157
181
|
const parsedUrl = new URL(url);
|
|
158
182
|
|
|
159
183
|
// Extract the authorization code
|
|
160
|
-
|
|
161
|
-
console.log('Extracted authorization code:', code);
|
|
162
|
-
return code;
|
|
184
|
+
return parsedUrl.searchParams.get('code');
|
|
163
185
|
} catch (error) {
|
|
164
186
|
console.error('Error handling OAuth callback:', error);
|
|
165
187
|
return null;
|
|
@@ -172,46 +194,7 @@ export const handleOAuthCallback = url => {
|
|
|
172
194
|
* @returns True if the URL is an OAuth callback
|
|
173
195
|
*/
|
|
174
196
|
export const isOAuthCallback = url => {
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
console.log(`Checking if URL is OAuth callback: ${url} -> ${isCallback}`);
|
|
178
|
-
return isCallback;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Detects if OAuth flow has completed successfully based on URL patterns
|
|
183
|
-
* @param url The current URL in the WebView
|
|
184
|
-
* @param platform The platform being authenticated
|
|
185
|
-
* @returns True if the OAuth flow has completed successfully
|
|
186
|
-
*/
|
|
187
|
-
export const isOAuthSuccess = (url, platform) => {
|
|
188
|
-
console.log(`Checking OAuth success for ${platform} with URL: ${url}`);
|
|
189
|
-
|
|
190
|
-
// Check for final redirect to Onairos home page (indicates proxy has processed the callback)
|
|
191
|
-
if (url.includes('onairos.uk/Home')) {
|
|
192
|
-
console.log('Detected final redirect to onairos.uk/Home - OAuth success');
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Platform-specific success patterns
|
|
197
|
-
switch (platform) {
|
|
198
|
-
case 'youtube':
|
|
199
|
-
// YouTube/Google OAuth success patterns
|
|
200
|
-
return url.includes('accounts.google.com/o/oauth2/approval') || url.includes('consent.google.com/ml/save') || url.includes('myaccount.google.com');
|
|
201
|
-
case 'reddit':
|
|
202
|
-
// Reddit OAuth success patterns
|
|
203
|
-
return url.includes('/api/v1/authorize?done=true') || url.includes('reddit.com/api/v1/authorize/compact');
|
|
204
|
-
case 'pinterest':
|
|
205
|
-
// Pinterest OAuth success patterns
|
|
206
|
-
return url.includes('/oauth/success') || url.includes('/oauth/complete');
|
|
207
|
-
case 'instagram':
|
|
208
|
-
// Instagram OAuth success patterns
|
|
209
|
-
return url.includes('/oauth/authorize/?response_type=code') || url.includes('instagram.com/oauth/authorize');
|
|
210
|
-
case 'email':
|
|
211
|
-
// Email verification success patterns
|
|
212
|
-
return url.includes('/email/verify/success') || url.includes('/email/confirmed');
|
|
213
|
-
default:
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
197
|
+
// Check if the URL starts with our redirect URI
|
|
198
|
+
return url.startsWith('onairosanime://auth/');
|
|
216
199
|
};
|
|
217
200
|
//# sourceMappingURL=platformAuthService.js.map
|