@onairos/react-native 3.0.25 → 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 +42 -83
- 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 -95
- 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 +43 -84
- 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 -93
- 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 +42 -83
- package/src/components/onboarding/OAuthWebView.tsx +59 -121
- package/src/constants/index.ts +3 -3
- package/src/services/platformAuthService.ts +80 -110
|
@@ -9,7 +9,6 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
var _reactNativeWebview = require("react-native-webview");
|
|
10
10
|
var _MaterialIcons = _interopRequireDefault(require("react-native-vector-icons/MaterialIcons"));
|
|
11
11
|
var _constants = require("../../constants");
|
|
12
|
-
var _platformAuthService = require("../../services/platformAuthService");
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
14
|
const OAuthWebView = ({
|
|
@@ -20,54 +19,33 @@ const OAuthWebView = ({
|
|
|
20
19
|
onSuccess
|
|
21
20
|
}) => {
|
|
22
21
|
const [loading, setLoading] = (0, _react.useState)(true);
|
|
23
|
-
const [currentUrl, setCurrentUrl] = (0, _react.useState)(url);
|
|
24
22
|
const handleNavigationStateChange = (0, _react.useCallback)(navState => {
|
|
25
|
-
console.log(
|
|
26
|
-
setCurrentUrl(navState.url);
|
|
23
|
+
console.log('Navigation state changed:', navState.url);
|
|
27
24
|
|
|
28
|
-
// Check for final redirect to onairos.uk/Home
|
|
29
|
-
|
|
30
|
-
console.log(`[OAuthWebView] Detected final redirect to onairos.uk/Home for ${platform}`);
|
|
25
|
+
// Check for the final redirect to onairos.uk/Home
|
|
26
|
+
const isFinalRedirect = navState.url.includes('onairos.uk/Home');
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
onSuccess('success');
|
|
35
|
-
if (onComplete) {
|
|
36
|
-
onComplete();
|
|
37
|
-
}
|
|
38
|
-
}, 500);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check for platform-specific success patterns using the service
|
|
43
|
-
if (platform && (0, _platformAuthService.isOAuthSuccess)(navState.url, platform)) {
|
|
44
|
-
console.log(`[OAuthWebView] Detected platform-specific success pattern for ${platform}`);
|
|
28
|
+
// Check for Instagram-specific success patterns
|
|
29
|
+
const isInstagramSuccess = platform === 'instagram' && (navState.url.includes('instagram.com/oauth/authorize') || navState.url.includes('instagram.com/accounts/login') || navState.url.includes('code='));
|
|
45
30
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// Don't close immediately for YouTube, wait for the onairos.uk/Home redirect
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// For other platforms, close immediately
|
|
54
|
-
setTimeout(() => {
|
|
55
|
-
onSuccess('success');
|
|
56
|
-
if (onComplete) {
|
|
57
|
-
onComplete();
|
|
58
|
-
}
|
|
59
|
-
}, 300);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
31
|
+
// Check for platform-specific success patterns
|
|
32
|
+
const isYouTubeSuccess = platform === 'youtube' && navState.url.includes('accounts.google.com/o/oauth2/approval');
|
|
33
|
+
const isLinkedInSuccess = platform === 'linkedin' && navState.url.includes('linkedin.com/oauth/v2/authorization/success');
|
|
62
34
|
|
|
63
35
|
// Check for callback URLs with authorization codes
|
|
64
|
-
|
|
65
|
-
console.log(`[OAuthWebView] Detected callback URL for ${platform}:`, navState.url);
|
|
36
|
+
const isCallbackUrl = navState.url.includes('/callback') || navState.url.includes('code=');
|
|
66
37
|
|
|
38
|
+
// If we detect success, close the window and update connection status
|
|
39
|
+
if (isFinalRedirect || isInstagramSuccess || isYouTubeSuccess || isLinkedInSuccess) {
|
|
40
|
+
onSuccess('success');
|
|
41
|
+
if (onComplete) {
|
|
42
|
+
onComplete();
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
} else if (isCallbackUrl) {
|
|
67
46
|
// Extract the authorization code
|
|
68
|
-
const authCode = (
|
|
47
|
+
const authCode = extractAuthCode(navState.url);
|
|
69
48
|
if (authCode) {
|
|
70
|
-
console.log(`[OAuthWebView] Extracted auth code for ${platform}:`, authCode);
|
|
71
49
|
onSuccess(authCode);
|
|
72
50
|
if (onComplete) {
|
|
73
51
|
onComplete();
|
|
@@ -76,22 +54,27 @@ const OAuthWebView = ({
|
|
|
76
54
|
return;
|
|
77
55
|
}
|
|
78
56
|
}, [platform, onComplete, onSuccess]);
|
|
79
|
-
const handleLoadStart = (0, _react.useCallback)(() => {
|
|
80
|
-
setLoading(true);
|
|
81
|
-
}, []);
|
|
82
57
|
const handleLoadEnd = (0, _react.useCallback)(() => {
|
|
83
58
|
setLoading(false);
|
|
84
59
|
}, []);
|
|
85
|
-
const handleError = (0, _react.useCallback)(syntheticEvent => {
|
|
86
|
-
const {
|
|
87
|
-
nativeEvent
|
|
88
|
-
} = syntheticEvent;
|
|
89
|
-
console.error(`[OAuthWebView] WebView error for ${platform}:`, nativeEvent);
|
|
90
|
-
setLoading(false);
|
|
91
|
-
}, [platform]);
|
|
92
60
|
|
|
93
|
-
//
|
|
94
|
-
const
|
|
61
|
+
// Extract auth code from redirect URL
|
|
62
|
+
const extractAuthCode = redirectUrl => {
|
|
63
|
+
try {
|
|
64
|
+
// First try to extract code from URL parameters
|
|
65
|
+
const codeMatch = redirectUrl.match(/code=([^&]+)/);
|
|
66
|
+
if (codeMatch && codeMatch[1]) {
|
|
67
|
+
return codeMatch[1];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// If that fails, try parsing as URL
|
|
71
|
+
const url = new URL(redirectUrl);
|
|
72
|
+
return url.searchParams.get('code') || '';
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('Error extracting auth code:', error);
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
};
|
|
95
78
|
return /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, {
|
|
96
79
|
style: styles.container
|
|
97
80
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
@@ -109,57 +92,31 @@ const OAuthWebView = ({
|
|
|
109
92
|
name: getPlatformIcon(platform || 'default'),
|
|
110
93
|
size: 20,
|
|
111
94
|
color: getPlatformColor(platform || 'default')
|
|
112
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
113
|
-
style: styles.platformTitle
|
|
114
|
-
}, "Connect ", platform ? platform.charAt(0).toUpperCase() + platform.slice(1) : 'Account')), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
115
|
-
style: styles.placeholder
|
|
116
|
-
})), /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
95
|
+
}))), /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
117
96
|
source: {
|
|
118
97
|
uri: url
|
|
119
98
|
},
|
|
120
99
|
onNavigationStateChange: handleNavigationStateChange,
|
|
121
|
-
onLoadStart: handleLoadStart,
|
|
122
100
|
onLoadEnd: handleLoadEnd,
|
|
123
|
-
onError: handleError,
|
|
124
101
|
startInLoadingState: true,
|
|
125
102
|
renderLoading: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, null),
|
|
126
|
-
style: styles.webView
|
|
127
|
-
// Essential WebView configuration for OAuth
|
|
128
|
-
,
|
|
103
|
+
style: styles.webView,
|
|
129
104
|
javaScriptEnabled: true,
|
|
130
105
|
domStorageEnabled: true,
|
|
131
|
-
cacheEnabled:
|
|
132
|
-
incognito: false
|
|
133
|
-
,
|
|
134
|
-
|
|
135
|
-
,
|
|
136
|
-
thirdPartyCookiesEnabled: true // Required for OAuth flows
|
|
137
|
-
,
|
|
138
|
-
userAgent: userAgent // iOS Safari for better compatibility
|
|
139
|
-
// Additional settings for better OAuth support
|
|
140
|
-
,
|
|
106
|
+
cacheEnabled: false,
|
|
107
|
+
incognito: false,
|
|
108
|
+
sharedCookiesEnabled: true,
|
|
109
|
+
thirdPartyCookiesEnabled: true,
|
|
141
110
|
allowsInlineMediaPlayback: true,
|
|
142
111
|
mediaPlaybackRequiresUserAction: false,
|
|
143
|
-
allowsBackForwardNavigationGestures: true
|
|
144
|
-
|
|
145
|
-
,
|
|
146
|
-
allowsLinkPreview: false,
|
|
147
|
-
allowFileAccess: false,
|
|
148
|
-
allowUniversalAccessFromFileURLs: false,
|
|
149
|
-
mixedContentMode: "compatibility"
|
|
112
|
+
allowsBackForwardNavigationGestures: true,
|
|
113
|
+
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"
|
|
150
114
|
}), loading && /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
151
115
|
style: styles.loadingContainer
|
|
152
116
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
|
|
153
117
|
size: "large",
|
|
154
118
|
color: _constants.COLORS.primary
|
|
155
|
-
})
|
|
156
|
-
style: styles.loadingText
|
|
157
|
-
}, "Connecting to ", platform ? platform.charAt(0).toUpperCase() + platform.slice(1) : 'platform', "...")), __DEV__ && /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
158
|
-
style: styles.debugContainer
|
|
159
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
160
|
-
style: styles.debugText,
|
|
161
|
-
numberOfLines: 1
|
|
162
|
-
}, currentUrl)));
|
|
119
|
+
})));
|
|
163
120
|
};
|
|
164
121
|
|
|
165
122
|
/**
|
|
@@ -176,8 +133,6 @@ const getPlatformIcon = platform => {
|
|
|
176
133
|
return 'push-pin';
|
|
177
134
|
case 'reddit':
|
|
178
135
|
return 'forum';
|
|
179
|
-
case 'email':
|
|
180
|
-
return 'email';
|
|
181
136
|
default:
|
|
182
137
|
return 'link';
|
|
183
138
|
}
|
|
@@ -196,8 +151,6 @@ const getPlatformColor = platform => {
|
|
|
196
151
|
return '#E60023';
|
|
197
152
|
case 'reddit':
|
|
198
153
|
return '#FF4500';
|
|
199
|
-
case 'email':
|
|
200
|
-
return '#4285F4';
|
|
201
154
|
default:
|
|
202
155
|
return _constants.COLORS.primary;
|
|
203
156
|
}
|
|
@@ -218,50 +171,22 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
218
171
|
},
|
|
219
172
|
titleContainer: {
|
|
220
173
|
flex: 1,
|
|
221
|
-
|
|
222
|
-
alignItems: 'center',
|
|
223
|
-
justifyContent: 'center'
|
|
224
|
-
},
|
|
225
|
-
platformTitle: {
|
|
226
|
-
fontSize: 16,
|
|
227
|
-
fontWeight: '600',
|
|
228
|
-
color: '#000',
|
|
229
|
-
marginLeft: 8
|
|
174
|
+
alignItems: 'center'
|
|
230
175
|
},
|
|
231
176
|
closeButton: {
|
|
232
177
|
padding: 8,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
width: 40
|
|
178
|
+
position: 'absolute',
|
|
179
|
+
left: 16,
|
|
180
|
+
zIndex: 10
|
|
237
181
|
},
|
|
238
182
|
webView: {
|
|
239
183
|
flex: 1
|
|
240
184
|
},
|
|
241
185
|
loadingContainer: {
|
|
242
186
|
..._reactNative.StyleSheet.absoluteFillObject,
|
|
243
|
-
backgroundColor: 'rgba(255, 255, 255, 0.
|
|
187
|
+
backgroundColor: 'rgba(255, 255, 255, 0.8)',
|
|
244
188
|
alignItems: 'center',
|
|
245
189
|
justifyContent: 'center'
|
|
246
|
-
},
|
|
247
|
-
loadingText: {
|
|
248
|
-
fontSize: 16,
|
|
249
|
-
color: '#666',
|
|
250
|
-
marginTop: 16,
|
|
251
|
-
textAlign: 'center'
|
|
252
|
-
},
|
|
253
|
-
debugContainer: {
|
|
254
|
-
position: 'absolute',
|
|
255
|
-
bottom: 0,
|
|
256
|
-
left: 0,
|
|
257
|
-
right: 0,
|
|
258
|
-
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
259
|
-
padding: 8
|
|
260
|
-
},
|
|
261
|
-
debugText: {
|
|
262
|
-
color: '#fff',
|
|
263
|
-
fontSize: 12,
|
|
264
|
-
fontFamily: 'monospace'
|
|
265
190
|
}
|
|
266
191
|
});
|
|
267
192
|
//# sourceMappingURL=OAuthWebView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_MaterialIcons","_interopRequireDefault","_constants","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_MaterialIcons","_interopRequireDefault","_constants","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","OAuthWebView","url","platform","onComplete","onClose","onSuccess","loading","setLoading","useState","handleNavigationStateChange","useCallback","navState","console","log","isFinalRedirect","includes","isInstagramSuccess","isYouTubeSuccess","isLinkedInSuccess","isCallbackUrl","authCode","extractAuthCode","handleLoadEnd","redirectUrl","codeMatch","match","URL","searchParams","error","createElement","SafeAreaView","style","styles","container","View","header","TouchableOpacity","onPress","closeButton","name","size","color","titleContainer","getPlatformIcon","getPlatformColor","WebView","source","uri","onNavigationStateChange","onLoadEnd","startInLoadingState","renderLoading","webView","javaScriptEnabled","domStorageEnabled","cacheEnabled","incognito","sharedCookiesEnabled","thirdPartyCookiesEnabled","allowsInlineMediaPlayback","mediaPlaybackRequiresUserAction","allowsBackForwardNavigationGestures","userAgent","loadingContainer","ActivityIndicator","COLORS","primary","exports","StyleSheet","create","flex","backgroundColor","flexDirection","alignItems","height","borderBottomWidth","borderBottomColor","paddingHorizontal","padding","position","left","zIndex","absoluteFillObject","justifyContent"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/onboarding/OAuthWebView.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK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AAE;EACR,CAAC;EACDP,gBAAgB,EAAE;IAChB,GAAGK,uBAAU,CAACc,kBAAkB;IAChCX,eAAe,EAAE,0BAA0B;IAC3CE,UAAU,EAAE,QAAQ;IACpBU,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -76,8 +76,8 @@ const PIN_REQUIREMENTS = exports.PIN_REQUIREMENTS = {
|
|
|
76
76
|
requireSpecialChar: true
|
|
77
77
|
};
|
|
78
78
|
const DEEP_LINK_CONFIG = exports.DEEP_LINK_CONFIG = {
|
|
79
|
-
scheme: '
|
|
80
|
-
host: '
|
|
81
|
-
redirectUri: '
|
|
79
|
+
scheme: 'onairosanime',
|
|
80
|
+
host: 'authenticate',
|
|
81
|
+
redirectUri: 'onairosanime://auth/'
|
|
82
82
|
};
|
|
83
83
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["COLORS","exports","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":";;;;;;AAEO,MAAMA,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG;EACpBE,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,SA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AE,CAAC;EACZC,gBAAgB,EAAE,IAAI;EACtBC,gBAAgB,EAAE,IAAI;EACtBC,aAAa,EAAE,IAAI;EACnBC,kBAAkB,EAAE;AACtB,CAAC;AAEM,MAAMC,gBAAgB,GAAAlC,OAAA,CAAAkC,gBAAA,GAAG;EAC9BC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"names":["COLORS","exports","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":";;;;;;AAEO,MAAMA,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG;EACpBE,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;AAEM,MAAMC,SAAyC,GAAAhB,OAAA,CAAAgB,SAAA,GAAG;EACvDR,SAAS,EAAE;IACTS,IAAI,EAAE,WAAW;IACjBC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAEpB,MAAM,CAACS,SAAS;IACvBY,WAAW,EAAE;EACf,CAAC;EACDX,SAAS,EAAE;IACTQ,IAAI,EAAE,WAAW;IACjBC,IAAI,EAAE,WAAW;IACjBC,K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|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.isOAuthCallback = exports.initiateOAuth = exports.initiateNativeAuth = exports.hasNativeSDK = exports.handleOAuthCallback = exports.getPlatformColor = exports.getAuthEndpoint = void 0;
|
|
7
7
|
// Define types for platform auth configuration
|
|
8
8
|
|
|
9
9
|
// Configuration for each platform's authentication
|
|
10
10
|
const PLATFORM_AUTH_CONFIG = {
|
|
11
11
|
instagram: {
|
|
12
12
|
hasNativeSDK: false,
|
|
13
|
-
// Instagram
|
|
13
|
+
// Instagram uses OAuth WebView flow
|
|
14
14
|
authEndpoint: 'https://api2.onairos.uk/instagram/authorize',
|
|
15
15
|
color: '#E1306C'
|
|
16
16
|
},
|
|
17
17
|
youtube: {
|
|
18
|
-
hasNativeSDK:
|
|
19
|
-
//
|
|
18
|
+
hasNativeSDK: true,
|
|
19
|
+
// YouTube uses Google Sign-In SDK
|
|
20
|
+
nativeSDKPackage: '@react-native-google-signin/google-signin',
|
|
20
21
|
authEndpoint: 'https://api2.onairos.uk/youtube/authorize',
|
|
21
22
|
color: '#FF0000'
|
|
22
23
|
},
|
|
@@ -64,69 +65,90 @@ const getPlatformColor = platform => {
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
|
-
* Initiates the OAuth flow for a platform
|
|
68
|
+
* Initiates the OAuth flow for a platform
|
|
68
69
|
* @param platform The platform to authenticate with
|
|
69
|
-
* @param
|
|
70
|
-
* @
|
|
70
|
+
* @param username The username to associate with the authentication
|
|
71
|
+
* @param appName The app name to use for the OAuth session (optional)
|
|
72
|
+
* @returns A Promise that resolves to the OAuth URL to open in a WebView or null if using native SDK
|
|
71
73
|
*/
|
|
72
74
|
exports.getPlatformColor = getPlatformColor;
|
|
73
|
-
const initiateOAuth = async (platform,
|
|
75
|
+
const initiateOAuth = async (platform, username, appName) => {
|
|
74
76
|
try {
|
|
75
77
|
// Check if the platform is supported
|
|
76
78
|
if (!PLATFORM_AUTH_CONFIG[platform]) {
|
|
77
79
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
78
80
|
}
|
|
79
|
-
console.log(`Initiating OAuth for ${platform} with user: ${userEmail}`);
|
|
80
81
|
|
|
81
|
-
//
|
|
82
|
-
|
|
82
|
+
// Check if platform has a native SDK
|
|
83
|
+
if (PLATFORM_AUTH_CONFIG[platform].hasNativeSDK) {
|
|
84
|
+
// Return null to indicate that we should use the native SDK
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Handle Instagram with specific API format
|
|
89
|
+
if (platform === 'instagram') {
|
|
90
|
+
const state = 'djksbfds';
|
|
91
|
+
const jsonData = {
|
|
92
|
+
session: {
|
|
93
|
+
oauthState: state,
|
|
94
|
+
username: username || 'Avatar'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const response = await fetch('https://api2.onairos.uk/instagram/authorize', {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: {
|
|
100
|
+
'Content-Type': 'application/json'
|
|
101
|
+
},
|
|
102
|
+
body: JSON.stringify(jsonData)
|
|
103
|
+
});
|
|
104
|
+
const responseData = await response.json();
|
|
105
|
+
if (responseData.instagramURL) {
|
|
106
|
+
return responseData.instagramURL;
|
|
107
|
+
}
|
|
108
|
+
throw new Error('No Instagram URL found in response');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Prepare the request body for other platforms
|
|
112
|
+
const jsonData = {
|
|
83
113
|
session: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
114
|
+
oauthState: 'djksbfds',
|
|
115
|
+
// Use same state for all platforms
|
|
116
|
+
username: username || 'Avatar',
|
|
117
|
+
appName: appName || 'DefaultApp'
|
|
87
118
|
}
|
|
88
119
|
};
|
|
89
|
-
console.log(`Making request to: ${PLATFORM_AUTH_CONFIG[platform].authEndpoint}`);
|
|
90
|
-
console.log('Request body:', JSON.stringify(requestBody, null, 2));
|
|
91
120
|
|
|
92
|
-
// Make the request to get the OAuth URL
|
|
121
|
+
// Make the request to get the OAuth URL
|
|
93
122
|
const response = await fetch(PLATFORM_AUTH_CONFIG[platform].authEndpoint, {
|
|
94
123
|
method: 'POST',
|
|
95
124
|
headers: {
|
|
96
|
-
'Content-Type': 'application/json'
|
|
97
|
-
'Accept': 'application/json'
|
|
125
|
+
'Content-Type': 'application/json'
|
|
98
126
|
},
|
|
99
|
-
body: JSON.stringify(
|
|
127
|
+
body: JSON.stringify(jsonData)
|
|
100
128
|
});
|
|
101
|
-
if (!response.ok) {
|
|
102
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
103
|
-
}
|
|
104
129
|
|
|
105
130
|
// Parse the response
|
|
106
131
|
const data = await response.json();
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (!oauthUrl) {
|
|
126
|
-
throw new Error(`No OAuth URL found in response for ${platform}. Response: ${JSON.stringify(data)}`);
|
|
132
|
+
|
|
133
|
+
// Check if the response contains the OAuth URL based on platform
|
|
134
|
+
switch (platform) {
|
|
135
|
+
case 'reddit':
|
|
136
|
+
if (data.redditURL) return data.redditURL;
|
|
137
|
+
break;
|
|
138
|
+
case 'pinterest':
|
|
139
|
+
if (data.pinterestURL) return data.pinterestURL;
|
|
140
|
+
break;
|
|
141
|
+
case 'youtube':
|
|
142
|
+
if (data.youtubeURL) return data.youtubeURL;
|
|
143
|
+
break;
|
|
144
|
+
case 'email':
|
|
145
|
+
if (data.emailURL) return data.emailURL;
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
if (data.url) return data.url;
|
|
149
|
+
break;
|
|
127
150
|
}
|
|
128
|
-
|
|
129
|
-
return oauthUrl;
|
|
151
|
+
throw new Error(`No OAuth URL found in response for ${platform}`);
|
|
130
152
|
} catch (error) {
|
|
131
153
|
console.error(`Error initiating OAuth for ${platform}:`, error);
|
|
132
154
|
throw error;
|
|
@@ -141,9 +163,17 @@ const initiateOAuth = async (platform, userEmail) => {
|
|
|
141
163
|
exports.initiateOAuth = initiateOAuth;
|
|
142
164
|
const initiateNativeAuth = async platform => {
|
|
143
165
|
try {
|
|
144
|
-
// Currently
|
|
145
|
-
|
|
146
|
-
|
|
166
|
+
// Currently only YouTube (Google Sign-In) is supported
|
|
167
|
+
if (platform === 'youtube') {
|
|
168
|
+
// This is a placeholder for the actual implementation
|
|
169
|
+
// In a real implementation, you would import and use the Google Sign-In SDK
|
|
170
|
+
console.log('Initiating native Google Sign-In for YouTube');
|
|
171
|
+
|
|
172
|
+
// Simulate a successful authentication
|
|
173
|
+
// In a real implementation, this would be the result of the Google Sign-In flow
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
throw new Error(`Native authentication not supported for ${platform}`);
|
|
147
177
|
} catch (error) {
|
|
148
178
|
console.error(`Error initiating native auth for ${platform}:`, error);
|
|
149
179
|
throw error;
|
|
@@ -158,15 +188,11 @@ const initiateNativeAuth = async platform => {
|
|
|
158
188
|
exports.initiateNativeAuth = initiateNativeAuth;
|
|
159
189
|
const handleOAuthCallback = url => {
|
|
160
190
|
try {
|
|
161
|
-
console.log('Handling OAuth callback URL:', url);
|
|
162
|
-
|
|
163
191
|
// Parse the URL
|
|
164
192
|
const parsedUrl = new URL(url);
|
|
165
193
|
|
|
166
194
|
// Extract the authorization code
|
|
167
|
-
|
|
168
|
-
console.log('Extracted authorization code:', code);
|
|
169
|
-
return code;
|
|
195
|
+
return parsedUrl.searchParams.get('code');
|
|
170
196
|
} catch (error) {
|
|
171
197
|
console.error('Error handling OAuth callback:', error);
|
|
172
198
|
return null;
|
|
@@ -180,48 +206,8 @@ const handleOAuthCallback = url => {
|
|
|
180
206
|
*/
|
|
181
207
|
exports.handleOAuthCallback = handleOAuthCallback;
|
|
182
208
|
const isOAuthCallback = url => {
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
console.log(`Checking if URL is OAuth callback: ${url} -> ${isCallback}`);
|
|
186
|
-
return isCallback;
|
|
209
|
+
// Check if the URL starts with our redirect URI
|
|
210
|
+
return url.startsWith('onairosanime://auth/');
|
|
187
211
|
};
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Detects if OAuth flow has completed successfully based on URL patterns
|
|
191
|
-
* @param url The current URL in the WebView
|
|
192
|
-
* @param platform The platform being authenticated
|
|
193
|
-
* @returns True if the OAuth flow has completed successfully
|
|
194
|
-
*/
|
|
195
212
|
exports.isOAuthCallback = isOAuthCallback;
|
|
196
|
-
const isOAuthSuccess = (url, platform) => {
|
|
197
|
-
console.log(`Checking OAuth success for ${platform} with URL: ${url}`);
|
|
198
|
-
|
|
199
|
-
// Check for final redirect to Onairos home page (indicates proxy has processed the callback)
|
|
200
|
-
if (url.includes('onairos.uk/Home')) {
|
|
201
|
-
console.log('Detected final redirect to onairos.uk/Home - OAuth success');
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Platform-specific success patterns
|
|
206
|
-
switch (platform) {
|
|
207
|
-
case 'youtube':
|
|
208
|
-
// YouTube/Google OAuth success patterns
|
|
209
|
-
return url.includes('accounts.google.com/o/oauth2/approval') || url.includes('consent.google.com/ml/save') || url.includes('myaccount.google.com');
|
|
210
|
-
case 'reddit':
|
|
211
|
-
// Reddit OAuth success patterns
|
|
212
|
-
return url.includes('/api/v1/authorize?done=true') || url.includes('reddit.com/api/v1/authorize/compact');
|
|
213
|
-
case 'pinterest':
|
|
214
|
-
// Pinterest OAuth success patterns
|
|
215
|
-
return url.includes('/oauth/success') || url.includes('/oauth/complete');
|
|
216
|
-
case 'instagram':
|
|
217
|
-
// Instagram OAuth success patterns
|
|
218
|
-
return url.includes('/oauth/authorize/?response_type=code') || url.includes('instagram.com/oauth/authorize');
|
|
219
|
-
case 'email':
|
|
220
|
-
// Email verification success patterns
|
|
221
|
-
return url.includes('/email/verify/success') || url.includes('/email/confirmed');
|
|
222
|
-
default:
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
exports.isOAuthSuccess = isOAuthSuccess;
|
|
227
213
|
//# sourceMappingURL=platformAuthService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PLATFORM_AUTH_CONFIG","instagram","hasNativeSDK","authEndpoint","color","youtube","reddit","pinterest","email","platform","config","exports","getAuthEndpoint","getPlatformColor","initiateOAuth","
|
|
1
|
+
{"version":3,"names":["PLATFORM_AUTH_CONFIG","instagram","hasNativeSDK","authEndpoint","color","youtube","nativeSDKPackage","reddit","pinterest","email","platform","config","exports","getAuthEndpoint","getPlatformColor","initiateOAuth","username","appName","Error","state","jsonData","session","oauthState","response","fetch","method","headers","body","JSON","stringify","responseData","json","instagramURL","data","redditURL","pinterestURL","youtubeURL","emailURL","url","error","console","initiateNativeAuth","log","handleOAuthCallback","parsedUrl","URL","searchParams","get","isOAuthCallback","startsWith"],"sourceRoot":"..\\..\\..\\src","sources":["services/platformAuthService.ts"],"mappings":";;;;;;AAGA;;AAQA;AACA,MAAMA,oBAAwD,GAAG;EAC/DC,SAAS,EAAE;IACTC,YAAY,EAAE,KAAK;IAAE;IACrBC,YAAY,EAAE,6CAA6C;IAC3DC,KAAK,EAAE;EACT,CAAC;EACDC,OAAO,EAAE;IACPH,YAAY,EAAE,IAAI;IAAE;IACpBI,gBAAgB,EAAE,2CAA2C;IAC7DH,YAAY,EAAE,2CAA2C;IACzDC,KAAK,EAAE;EACT,CAAC;EACDG,MAAM,EAAE;IACNL,YAAY,EAAE,KAAK;IACnBC,YAAY,EAAE,0CAA0C;IACxDC,KAAK,EAAE;EACT,CAAC;EACDI,SAAS,EAAE;IACTN,YAAY,EAAE,KAAK;IACnBC,YAAY,EAAE,6CAA6C;IAC3DC,KAAK,EAAE;EACT,CAAC;EACDK,KA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