@onairos/react-native 3.1.18 โ 3.2.1
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 +374 -403
- package/lib/commonjs/api/index.js +1 -75
- package/lib/commonjs/api/index.js.map +1 -1
- package/lib/commonjs/assets/images/email.png +0 -0
- package/lib/commonjs/assets/images/linkedin.png +0 -0
- package/lib/commonjs/assets/images/reddit.png +0 -0
- package/lib/commonjs/assets/images/youtube.png +0 -0
- package/lib/commonjs/components/DataRequestModal.js.map +1 -1
- package/lib/commonjs/components/DataRequestScreen.js.map +1 -1
- package/lib/commonjs/components/EmailVerificationModal.js.map +1 -1
- package/lib/commonjs/components/Onairos.js +3 -1
- package/lib/commonjs/components/Onairos.js.map +1 -1
- package/lib/commonjs/components/OnairosButton.js +190 -171
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/Overlay.js +5 -5
- package/lib/commonjs/components/Overlay.js.map +1 -1
- package/lib/commonjs/components/PinInput.js +120 -282
- package/lib/commonjs/components/PinInput.js.map +1 -1
- package/lib/commonjs/components/PlatformList.js.map +1 -1
- package/lib/commonjs/components/TrainingModal.js +563 -808
- package/lib/commonjs/components/TrainingModal.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +1296 -2302
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.tsx.new +455 -0
- package/lib/commonjs/components/onboarding/OAuthWebView.js +743 -134
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/commonjs/components/onboarding/OnboardingHeader.js.map +1 -1
- package/lib/commonjs/components/onboarding/PinInput.js.map +1 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -1
- package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -1
- package/lib/commonjs/components/screens/LoadingScreen.js.map +1 -1
- package/lib/commonjs/components/screens/PinCreationScreen.js.map +1 -1
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/hooks/useConnections.js +125 -120
- package/lib/commonjs/hooks/useConnections.js.map +1 -1
- package/lib/commonjs/hooks/useCredentials.js.map +1 -1
- package/lib/commonjs/index.js +27 -157
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/SDK_API_KEY_VALIDATION.md +428 -0
- package/lib/commonjs/services/apiKeyService.js +106 -105
- package/lib/commonjs/services/apiKeyService.js.map +1 -1
- package/lib/commonjs/services/oauthService.js.map +1 -1
- package/lib/commonjs/services/platformAuthService.js +722 -956
- package/lib/commonjs/services/platformAuthService.js.map +1 -1
- package/lib/commonjs/types/ambient.d.js.map +1 -1
- package/lib/commonjs/types/declarations.d.js.map +1 -1
- package/lib/commonjs/types/index.d.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/node-fix.d.js.map +1 -1
- package/lib/commonjs/types/node-override.d.js.map +1 -1
- package/lib/commonjs/types/opacity.d.js.map +1 -1
- package/lib/commonjs/types/types.d.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/Portal.js +4 -4
- package/lib/commonjs/utils/Portal.js.map +1 -1
- package/lib/commonjs/utils/api.js +24 -24
- package/lib/commonjs/utils/api.js.map +1 -1
- package/lib/commonjs/utils/auth.js +18 -18
- package/lib/commonjs/utils/auth.js.map +1 -1
- package/lib/commonjs/utils/crypto.js +13 -13
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/debugHelper.js.map +1 -1
- package/lib/commonjs/utils/encryption.js +12 -12
- package/lib/commonjs/utils/encryption.js.map +1 -1
- package/lib/commonjs/utils/onairosApi.js.map +1 -1
- package/lib/commonjs/utils/programmaticFlow.js +16 -16
- package/lib/commonjs/utils/programmaticFlow.js.map +1 -1
- package/lib/commonjs/utils/retryHelper.js +27 -27
- package/lib/commonjs/utils/retryHelper.js.map +1 -1
- package/lib/commonjs/utils/secureStorage.js.map +1 -1
- package/lib/module/api/index.js +0 -72
- package/lib/module/api/index.js.map +1 -1
- package/lib/module/assets/images/email.png +0 -0
- package/lib/module/assets/images/linkedin.png +0 -0
- package/lib/module/assets/images/reddit.png +0 -0
- package/lib/module/assets/images/youtube.png +0 -0
- package/lib/module/components/DataRequestModal.js.map +1 -1
- package/lib/module/components/DataRequestScreen.js.map +1 -1
- package/lib/module/components/EmailVerificationModal.js.map +1 -1
- package/lib/module/components/Onairos.js +3 -1
- package/lib/module/components/Onairos.js.map +1 -1
- package/lib/module/components/OnairosButton.js +192 -172
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/Overlay.js +5 -5
- package/lib/module/components/Overlay.js.map +1 -1
- package/lib/module/components/PinInput.js +120 -283
- package/lib/module/components/PinInput.js.map +1 -1
- package/lib/module/components/PlatformList.js.map +1 -1
- package/lib/module/components/TrainingModal.js +565 -809
- package/lib/module/components/TrainingModal.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +1297 -2305
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.tsx.new +455 -0
- package/lib/module/components/onboarding/OAuthWebView.js +744 -136
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/components/onboarding/OnboardingHeader.js.map +1 -1
- package/lib/module/components/onboarding/PinInput.js.map +1 -1
- package/lib/module/components/onboarding/PlatformConnector.js.map +1 -1
- package/lib/module/components/screens/ConnectorScreen.js.map +1 -1
- package/lib/module/components/screens/LoadingScreen.js.map +1 -1
- package/lib/module/components/screens/PinCreationScreen.js.map +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/useConnections.js +125 -119
- package/lib/module/hooks/useConnections.js.map +1 -1
- package/lib/module/hooks/useCredentials.js.map +1 -1
- package/lib/module/index.js +17 -55
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/SDK_API_KEY_VALIDATION.md +428 -0
- package/lib/module/services/apiKeyService.js +106 -105
- package/lib/module/services/apiKeyService.js.map +1 -1
- package/lib/module/services/oauthService.js.map +1 -1
- package/lib/module/services/platformAuthService.js +704 -943
- package/lib/module/services/platformAuthService.js.map +1 -1
- package/lib/module/types/ambient.d.js.map +1 -1
- package/lib/module/types/declarations.d.js.map +1 -1
- package/lib/module/types/index.d.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/node-fix.d.js.map +1 -1
- package/lib/module/types/node-override.d.js.map +1 -1
- package/lib/module/types/opacity.d.js.map +1 -1
- package/lib/module/types/types.d.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/Portal.js +4 -4
- package/lib/module/utils/Portal.js.map +1 -1
- package/lib/module/utils/api.js +24 -24
- package/lib/module/utils/api.js.map +1 -1
- package/lib/module/utils/auth.js +18 -18
- package/lib/module/utils/auth.js.map +1 -1
- package/lib/module/utils/crypto.js +13 -13
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/debugHelper.js.map +1 -1
- package/lib/module/utils/encryption.js +12 -12
- package/lib/module/utils/encryption.js.map +1 -1
- package/lib/module/utils/onairosApi.js.map +1 -1
- package/lib/module/utils/programmaticFlow.js +16 -16
- package/lib/module/utils/programmaticFlow.js.map +1 -1
- package/lib/module/utils/retryHelper.js +27 -27
- package/lib/module/utils/retryHelper.js.map +1 -1
- package/lib/module/utils/secureStorage.js.map +1 -1
- package/lib/typescript/api/index.d.ts +7 -15
- package/lib/typescript/api/index.d.ts.map +1 -1
- package/lib/typescript/components/DataRequestModal.d.ts +10 -10
- package/lib/typescript/components/DataRequestScreen.d.ts +10 -10
- package/lib/typescript/components/EmailVerificationModal.d.ts +10 -10
- package/lib/typescript/components/Onairos.d.ts +3 -3
- package/lib/typescript/components/Onairos.d.ts.map +1 -1
- package/lib/typescript/components/OnairosButton.d.ts +11 -36
- package/lib/typescript/components/OnairosButton.d.ts.map +1 -1
- package/lib/typescript/components/Overlay.d.ts +3 -3
- package/lib/typescript/components/PinInput.d.ts +3 -13
- package/lib/typescript/components/PinInput.d.ts.map +1 -1
- package/lib/typescript/components/PlatformList.d.ts +3 -3
- package/lib/typescript/components/TrainingModal.d.ts +3 -14
- package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts +3 -16
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts +9 -9
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
- package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +10 -10
- package/lib/typescript/components/onboarding/PinInput.d.ts +3 -3
- package/lib/typescript/components/onboarding/PlatformConnector.d.ts +12 -12
- package/lib/typescript/components/screens/ConnectorScreen.d.ts +8 -8
- package/lib/typescript/components/screens/LoadingScreen.d.ts +8 -8
- package/lib/typescript/components/screens/PinCreationScreen.d.ts +9 -9
- package/lib/typescript/constants/index.d.ts +52 -52
- package/lib/typescript/hooks/useConnections.d.ts +8 -13
- package/lib/typescript/hooks/useConnections.d.ts.map +1 -1
- package/lib/typescript/hooks/useCredentials.d.ts +8 -8
- package/lib/typescript/index.d.ts +17 -38
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/services/apiKeyService.d.ts +131 -131
- package/lib/typescript/services/apiKeyService.d.ts.map +1 -1
- package/lib/typescript/services/oauthService.d.ts +49 -49
- package/lib/typescript/services/platformAuthService.d.ts +143 -68
- package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +228 -264
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +268 -266
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/Portal.d.ts +13 -13
- package/lib/typescript/utils/api.d.ts +5 -5
- package/lib/typescript/utils/auth.d.ts +5 -5
- package/lib/typescript/utils/crypto.d.ts +3 -3
- package/lib/typescript/utils/debugHelper.d.ts +28 -28
- package/lib/typescript/utils/encryption.d.ts +18 -18
- package/lib/typescript/utils/onairosApi.d.ts +86 -86
- package/lib/typescript/utils/programmaticFlow.d.ts +22 -22
- package/lib/typescript/utils/retryHelper.d.ts +68 -68
- package/lib/typescript/utils/secureStorage.d.ts +93 -93
- package/package.json +149 -145
- package/src/api/index.ts +110 -151
- package/src/assets/images/email.png +0 -0
- package/src/assets/images/linkedin.png +0 -0
- package/src/assets/images/reddit.png +0 -0
- package/src/assets/images/youtube.png +0 -0
- package/src/components/DataRequestScreen.tsx +355 -355
- package/src/components/EmailVerificationModal.tsx +363 -363
- package/src/components/Onairos.tsx +424 -422
- package/src/components/OnairosButton.tsx +359 -339
- package/src/components/Overlay.tsx +506 -506
- package/src/components/PinInput.tsx +343 -555
- package/src/components/PlatformList.tsx +144 -144
- package/src/components/TrainingModal.tsx +737 -1047
- package/src/components/UniversalOnboarding.tsx +1839 -2888
- package/src/components/UniversalOnboarding.tsx.new +455 -0
- package/src/components/onboarding/OAuthWebView.tsx +838 -232
- package/src/hooks/useConnections.ts +163 -161
- package/src/hooks/useCredentials.ts +174 -174
- package/src/index.js +14 -14
- package/src/index.ts +49 -99
- package/src/services/SDK_API_KEY_VALIDATION.md +428 -0
- package/src/services/apiKeyService.ts +921 -919
- package/src/services/platformAuthService.ts +1113 -1346
- package/src/types/ambient.d.ts +28 -28
- package/src/types/index.ts +241 -265
- package/src/types/node-fix.d.ts +18 -18
- package/src/types/node-override.d.ts +23 -23
- package/src/types/opacity.d.ts +15 -15
- package/src/types/types.d.ts +17 -17
- package/src/types.ts +6 -4
- package/src/utils/Portal.tsx +82 -82
- package/src/utils/api.js +111 -111
- package/src/utils/auth.js +103 -103
- package/src/utils/crypto.js +59 -59
- package/src/utils/encryption.ts +68 -68
- package/src/utils/programmaticFlow.ts +112 -112
- package/src/utils/retryHelper.ts +274 -274
- package/types/index.d.ts +213 -213
- package/types/node-env.d.ts +14 -14
- package/lib/commonjs/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/lib/commonjs/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/lib/commonjs/assets/icons/Facebookicon.png +0 -0
- package/lib/commonjs/assets/icons/Gmail.png +0 -0
- package/lib/commonjs/assets/icons/Linkedinicon.png +0 -0
- package/lib/commonjs/assets/icons/Redditicon.png +0 -0
- package/lib/commonjs/assets/icons/YouTubeicon2.png +0 -0
- package/lib/commonjs/assets/icons/YouTubeicon3.png +0 -0
- package/lib/commonjs/assets/icons/farcaster.png +0 -0
- package/lib/commonjs/assets/icons/instagram.png +0 -0
- package/lib/commonjs/assets/icons/pinterest.png +0 -0
- package/lib/commonjs/assets/icons/swerv_logo.png +0 -0
- package/lib/commonjs/assets/icons/twitter.jpg +0 -0
- package/lib/commonjs/assets/images/Checkbox.svg +0 -3
- package/lib/commonjs/assets/images/EnochE.svg +0 -19
- package/lib/commonjs/assets/images/Enochicon1.png +0 -0
- package/lib/commonjs/assets/images/Face_ID_logo.png +0 -0
- package/lib/commonjs/assets/images/Facebookicon.png +0 -0
- package/lib/commonjs/assets/images/Gmail.png +0 -0
- package/lib/commonjs/assets/images/Googlelogo.png +0 -0
- package/lib/commonjs/assets/images/Linkedinicon.png +0 -0
- package/lib/commonjs/assets/images/Onairoslogo.png +0 -0
- package/lib/commonjs/assets/images/Personalityprofile.svg +0 -3
- package/lib/commonjs/assets/images/Personalitytraits.svg +0 -3
- package/lib/commonjs/assets/images/Redditicon.png +0 -0
- package/lib/commonjs/assets/images/Userpreferences.svg +0 -3
- package/lib/commonjs/assets/images/YouTubeicon3.png +0 -0
- package/lib/commonjs/assets/images/arrow.svg +0 -20
- package/lib/commonjs/assets/images/basicproficon.svg +0 -43
- package/lib/commonjs/assets/images/basicprofile.svg +0 -3
- package/lib/commonjs/assets/images/checkmark.svg +0 -4
- package/lib/commonjs/assets/images/contentanalysis.svg +0 -3
- package/lib/commonjs/assets/images/contenticon.svg +0 -23
- package/lib/commonjs/assets/images/persona1.png +0 -0
- package/lib/commonjs/assets/images/persona2.png +0 -0
- package/lib/commonjs/assets/images/persona3.png +0 -0
- package/lib/commonjs/assets/images/persona4.png +0 -0
- package/lib/commonjs/assets/images/persona5.png +0 -0
- package/lib/commonjs/assets/images/personalityicon.svg +0 -18
- package/lib/commonjs/assets/images/x-close.svg +0 -3
- package/lib/commonjs/components/BodyText.js +0 -27
- package/lib/commonjs/components/BodyText.js.map +0 -1
- package/lib/commonjs/components/BrandMark.js +0 -44
- package/lib/commonjs/components/BrandMark.js.map +0 -1
- package/lib/commonjs/components/CodeInput.js +0 -30
- package/lib/commonjs/components/CodeInput.js.map +0 -1
- package/lib/commonjs/components/EmailInput.js +0 -30
- package/lib/commonjs/components/EmailInput.js.map +0 -1
- package/lib/commonjs/components/ExistingUserDataConfirmation.js +0 -474
- package/lib/commonjs/components/ExistingUserDataConfirmation.js.map +0 -1
- package/lib/commonjs/components/GoogleButton.js +0 -55
- package/lib/commonjs/components/GoogleButton.js.map +0 -1
- package/lib/commonjs/components/HeadingGroup.js +0 -43
- package/lib/commonjs/components/HeadingGroup.js.map +0 -1
- package/lib/commonjs/components/ModalHeader.js +0 -99
- package/lib/commonjs/components/ModalHeader.js.map +0 -1
- package/lib/commonjs/components/ModalSheet.js +0 -47
- package/lib/commonjs/components/ModalSheet.js.map +0 -1
- package/lib/commonjs/components/OnairosSignInButton.js +0 -129
- package/lib/commonjs/components/OnairosSignInButton.js.map +0 -1
- package/lib/commonjs/components/PersonaImage.js +0 -60
- package/lib/commonjs/components/PersonaImage.js.map +0 -1
- package/lib/commonjs/components/PersonaLoadingScreen.js +0 -156
- package/lib/commonjs/components/PersonaLoadingScreen.js.map +0 -1
- package/lib/commonjs/components/PersonalizationConsentScreen.js +0 -316
- package/lib/commonjs/components/PersonalizationConsentScreen.js.map +0 -1
- package/lib/commonjs/components/PinCreationScreen.js +0 -393
- package/lib/commonjs/components/PinCreationScreen.js.map +0 -1
- package/lib/commonjs/components/PlatformConnectorsStep.js +0 -828
- package/lib/commonjs/components/PlatformConnectorsStep.js.map +0 -1
- package/lib/commonjs/components/PlatformToggle.js +0 -180
- package/lib/commonjs/components/PlatformToggle.js.map +0 -1
- package/lib/commonjs/components/PrimaryButton.js +0 -180
- package/lib/commonjs/components/PrimaryButton.js.map +0 -1
- package/lib/commonjs/components/SignInMatchAnimation.js +0 -197
- package/lib/commonjs/components/SignInMatchAnimation.js.map +0 -1
- package/lib/commonjs/components/SignInStep.js +0 -179
- package/lib/commonjs/components/SignInStep.js.map +0 -1
- package/lib/commonjs/components/VerificationStep.js +0 -154
- package/lib/commonjs/components/VerificationStep.js.map +0 -1
- package/lib/commonjs/components/WelcomeScreen.js +0 -401
- package/lib/commonjs/components/WelcomeScreen.js.map +0 -1
- package/lib/commonjs/components/icons/Basicproficon.js +0 -37
- package/lib/commonjs/components/icons/Basicproficon.js.map +0 -1
- package/lib/commonjs/components/icons/Basicprofile.js +0 -21
- package/lib/commonjs/components/icons/Basicprofile.js.map +0 -1
- package/lib/commonjs/components/icons/Checkbox.js +0 -21
- package/lib/commonjs/components/icons/Checkbox.js.map +0 -1
- package/lib/commonjs/components/icons/Checkmark.js +0 -27
- package/lib/commonjs/components/icons/Checkmark.js.map +0 -1
- package/lib/commonjs/components/icons/Contentanalysis.js +0 -21
- package/lib/commonjs/components/icons/Contentanalysis.js.map +0 -1
- package/lib/commonjs/components/icons/Contenticon.js +0 -39
- package/lib/commonjs/components/icons/Contenticon.js.map +0 -1
- package/lib/commonjs/components/icons/EnochE.js +0 -41
- package/lib/commonjs/components/icons/EnochE.js.map +0 -1
- package/lib/commonjs/components/icons/Personalityicon.js +0 -30
- package/lib/commonjs/components/icons/Personalityicon.js.map +0 -1
- package/lib/commonjs/components/icons/Personalityprofile.js +0 -21
- package/lib/commonjs/components/icons/Personalityprofile.js.map +0 -1
- package/lib/commonjs/components/icons/Personalitytraits.js +0 -21
- package/lib/commonjs/components/icons/Personalitytraits.js.map +0 -1
- package/lib/commonjs/components/icons/Userpreferences.js +0 -21
- package/lib/commonjs/components/icons/Userpreferences.js.map +0 -1
- package/lib/commonjs/components/icons/index.js +0 -84
- package/lib/commonjs/components/icons/index.js.map +0 -1
- package/lib/commonjs/config/api.js +0 -34
- package/lib/commonjs/config/api.js.map +0 -1
- package/lib/commonjs/context/AuthContext.js +0 -345
- package/lib/commonjs/context/AuthContext.js.map +0 -1
- package/lib/commonjs/hooks/useConnectedAccounts.js +0 -111
- package/lib/commonjs/hooks/useConnectedAccounts.js.map +0 -1
- package/lib/commonjs/hooks/useUserConnections.js +0 -148
- package/lib/commonjs/hooks/useUserConnections.js.map +0 -1
- package/lib/commonjs/services/apiClient.js +0 -302
- package/lib/commonjs/services/apiClient.js.map +0 -1
- package/lib/commonjs/services/authService.js +0 -935
- package/lib/commonjs/services/authService.js.map +0 -1
- package/lib/commonjs/services/biometricPinService.js +0 -184
- package/lib/commonjs/services/biometricPinService.js.map +0 -1
- package/lib/commonjs/services/connectedAccountsService.js +0 -268
- package/lib/commonjs/services/connectedAccountsService.js.map +0 -1
- package/lib/commonjs/services/googleAuthService.js +0 -268
- package/lib/commonjs/services/googleAuthService.js.map +0 -1
- package/lib/commonjs/services/imageCompressionService.js +0 -260
- package/lib/commonjs/services/imageCompressionService.js.map +0 -1
- package/lib/commonjs/services/jwtStorageService.js +0 -256
- package/lib/commonjs/services/jwtStorageService.js.map +0 -1
- package/lib/commonjs/services/mobileTrainingService.js +0 -185
- package/lib/commonjs/services/mobileTrainingService.js.map +0 -1
- package/lib/commonjs/services/pinEncryptionService.js +0 -84
- package/lib/commonjs/services/pinEncryptionService.js.map +0 -1
- package/lib/commonjs/services/pinStorageUtils.js +0 -105
- package/lib/commonjs/services/pinStorageUtils.js.map +0 -1
- package/lib/commonjs/services/storageService.js +0 -404
- package/lib/commonjs/services/storageService.js.map +0 -1
- package/lib/commonjs/services/trainingApiHelpers.js +0 -73
- package/lib/commonjs/services/trainingApiHelpers.js.map +0 -1
- package/lib/commonjs/services/userConnectionsService.js +0 -486
- package/lib/commonjs/services/userConnectionsService.js.map +0 -1
- package/lib/commonjs/services/youtubeMigrationService.js +0 -415
- package/lib/commonjs/services/youtubeMigrationService.js.map +0 -1
- package/lib/commonjs/theme/index.js +0 -249
- package/lib/commonjs/theme/index.js.map +0 -1
- package/lib/commonjs/utils/eventUtils.js +0 -288
- package/lib/commonjs/utils/eventUtils.js.map +0 -1
- package/lib/commonjs/utils/haptics.js +0 -66
- package/lib/commonjs/utils/haptics.js.map +0 -1
- package/lib/commonjs/utils/imagePreloader.js +0 -6
- package/lib/commonjs/utils/imagePreloader.js.map +0 -1
- package/lib/module/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/lib/module/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/lib/module/assets/icons/Facebookicon.png +0 -0
- package/lib/module/assets/icons/Gmail.png +0 -0
- package/lib/module/assets/icons/Linkedinicon.png +0 -0
- package/lib/module/assets/icons/Redditicon.png +0 -0
- package/lib/module/assets/icons/YouTubeicon2.png +0 -0
- package/lib/module/assets/icons/YouTubeicon3.png +0 -0
- package/lib/module/assets/icons/farcaster.png +0 -0
- package/lib/module/assets/icons/instagram.png +0 -0
- package/lib/module/assets/icons/pinterest.png +0 -0
- package/lib/module/assets/icons/swerv_logo.png +0 -0
- package/lib/module/assets/icons/twitter.jpg +0 -0
- package/lib/module/assets/images/Checkbox.svg +0 -3
- package/lib/module/assets/images/EnochE.svg +0 -19
- package/lib/module/assets/images/Enochicon1.png +0 -0
- package/lib/module/assets/images/Face_ID_logo.png +0 -0
- package/lib/module/assets/images/Facebookicon.png +0 -0
- package/lib/module/assets/images/Gmail.png +0 -0
- package/lib/module/assets/images/Googlelogo.png +0 -0
- package/lib/module/assets/images/Linkedinicon.png +0 -0
- package/lib/module/assets/images/Onairoslogo.png +0 -0
- package/lib/module/assets/images/Personalityprofile.svg +0 -3
- package/lib/module/assets/images/Personalitytraits.svg +0 -3
- package/lib/module/assets/images/Redditicon.png +0 -0
- package/lib/module/assets/images/Userpreferences.svg +0 -3
- package/lib/module/assets/images/YouTubeicon3.png +0 -0
- package/lib/module/assets/images/arrow.svg +0 -20
- package/lib/module/assets/images/basicproficon.svg +0 -43
- package/lib/module/assets/images/basicprofile.svg +0 -3
- package/lib/module/assets/images/checkmark.svg +0 -4
- package/lib/module/assets/images/contentanalysis.svg +0 -3
- package/lib/module/assets/images/contenticon.svg +0 -23
- package/lib/module/assets/images/persona1.png +0 -0
- package/lib/module/assets/images/persona2.png +0 -0
- package/lib/module/assets/images/persona3.png +0 -0
- package/lib/module/assets/images/persona4.png +0 -0
- package/lib/module/assets/images/persona5.png +0 -0
- package/lib/module/assets/images/personalityicon.svg +0 -18
- package/lib/module/assets/images/x-close.svg +0 -3
- package/lib/module/components/BodyText.js +0 -20
- package/lib/module/components/BodyText.js.map +0 -1
- package/lib/module/components/BrandMark.js +0 -37
- package/lib/module/components/BrandMark.js.map +0 -1
- package/lib/module/components/CodeInput.js +0 -23
- package/lib/module/components/CodeInput.js.map +0 -1
- package/lib/module/components/EmailInput.js +0 -23
- package/lib/module/components/EmailInput.js.map +0 -1
- package/lib/module/components/ExistingUserDataConfirmation.js +0 -465
- package/lib/module/components/ExistingUserDataConfirmation.js.map +0 -1
- package/lib/module/components/GoogleButton.js +0 -48
- package/lib/module/components/GoogleButton.js.map +0 -1
- package/lib/module/components/HeadingGroup.js +0 -36
- package/lib/module/components/HeadingGroup.js.map +0 -1
- package/lib/module/components/ModalHeader.js +0 -92
- package/lib/module/components/ModalHeader.js.map +0 -1
- package/lib/module/components/ModalSheet.js +0 -39
- package/lib/module/components/ModalSheet.js.map +0 -1
- package/lib/module/components/OnairosSignInButton.js +0 -120
- package/lib/module/components/OnairosSignInButton.js.map +0 -1
- package/lib/module/components/PersonaImage.js +0 -53
- package/lib/module/components/PersonaImage.js.map +0 -1
- package/lib/module/components/PersonaLoadingScreen.js +0 -148
- package/lib/module/components/PersonaLoadingScreen.js.map +0 -1
- package/lib/module/components/PersonalizationConsentScreen.js +0 -309
- package/lib/module/components/PersonalizationConsentScreen.js.map +0 -1
- package/lib/module/components/PinCreationScreen.js +0 -386
- package/lib/module/components/PinCreationScreen.js.map +0 -1
- package/lib/module/components/PlatformConnectorsStep.js +0 -820
- package/lib/module/components/PlatformConnectorsStep.js.map +0 -1
- package/lib/module/components/PlatformToggle.js +0 -173
- package/lib/module/components/PlatformToggle.js.map +0 -1
- package/lib/module/components/PrimaryButton.js +0 -172
- package/lib/module/components/PrimaryButton.js.map +0 -1
- package/lib/module/components/SignInMatchAnimation.js +0 -189
- package/lib/module/components/SignInMatchAnimation.js.map +0 -1
- package/lib/module/components/SignInStep.js +0 -171
- package/lib/module/components/SignInStep.js.map +0 -1
- package/lib/module/components/VerificationStep.js +0 -146
- package/lib/module/components/VerificationStep.js.map +0 -1
- package/lib/module/components/WelcomeScreen.js +0 -393
- package/lib/module/components/WelcomeScreen.js.map +0 -1
- package/lib/module/components/icons/Basicproficon.js +0 -30
- package/lib/module/components/icons/Basicproficon.js.map +0 -1
- package/lib/module/components/icons/Basicprofile.js +0 -14
- package/lib/module/components/icons/Basicprofile.js.map +0 -1
- package/lib/module/components/icons/Checkbox.js +0 -14
- package/lib/module/components/icons/Checkbox.js.map +0 -1
- package/lib/module/components/icons/Checkmark.js +0 -20
- package/lib/module/components/icons/Checkmark.js.map +0 -1
- package/lib/module/components/icons/Contentanalysis.js +0 -14
- package/lib/module/components/icons/Contentanalysis.js.map +0 -1
- package/lib/module/components/icons/Contenticon.js +0 -32
- package/lib/module/components/icons/Contenticon.js.map +0 -1
- package/lib/module/components/icons/EnochE.js +0 -34
- package/lib/module/components/icons/EnochE.js.map +0 -1
- package/lib/module/components/icons/Personalityicon.js +0 -23
- package/lib/module/components/icons/Personalityicon.js.map +0 -1
- package/lib/module/components/icons/Personalityprofile.js +0 -14
- package/lib/module/components/icons/Personalityprofile.js.map +0 -1
- package/lib/module/components/icons/Personalitytraits.js +0 -14
- package/lib/module/components/icons/Personalitytraits.js.map +0 -1
- package/lib/module/components/icons/Userpreferences.js +0 -14
- package/lib/module/components/icons/Userpreferences.js.map +0 -1
- package/lib/module/components/icons/index.js +0 -13
- package/lib/module/components/icons/index.js.map +0 -1
- package/lib/module/config/api.js +0 -26
- package/lib/module/config/api.js.map +0 -1
- package/lib/module/context/AuthContext.js +0 -335
- package/lib/module/context/AuthContext.js.map +0 -1
- package/lib/module/hooks/useConnectedAccounts.js +0 -106
- package/lib/module/hooks/useConnectedAccounts.js.map +0 -1
- package/lib/module/hooks/useUserConnections.js +0 -140
- package/lib/module/hooks/useUserConnections.js.map +0 -1
- package/lib/module/services/apiClient.js +0 -298
- package/lib/module/services/apiClient.js.map +0 -1
- package/lib/module/services/authService.js +0 -905
- package/lib/module/services/authService.js.map +0 -1
- package/lib/module/services/biometricPinService.js +0 -173
- package/lib/module/services/biometricPinService.js.map +0 -1
- package/lib/module/services/connectedAccountsService.js +0 -255
- package/lib/module/services/connectedAccountsService.js.map +0 -1
- package/lib/module/services/googleAuthService.js +0 -258
- package/lib/module/services/googleAuthService.js.map +0 -1
- package/lib/module/services/imageCompressionService.js +0 -250
- package/lib/module/services/imageCompressionService.js.map +0 -1
- package/lib/module/services/jwtStorageService.js +0 -239
- package/lib/module/services/jwtStorageService.js.map +0 -1
- package/lib/module/services/mobileTrainingService.js +0 -172
- package/lib/module/services/mobileTrainingService.js.map +0 -1
- package/lib/module/services/pinEncryptionService.js +0 -75
- package/lib/module/services/pinEncryptionService.js.map +0 -1
- package/lib/module/services/pinStorageUtils.js +0 -93
- package/lib/module/services/pinStorageUtils.js.map +0 -1
- package/lib/module/services/storageService.js +0 -383
- package/lib/module/services/storageService.js.map +0 -1
- package/lib/module/services/trainingApiHelpers.js +0 -67
- package/lib/module/services/trainingApiHelpers.js.map +0 -1
- package/lib/module/services/userConnectionsService.js +0 -476
- package/lib/module/services/userConnectionsService.js.map +0 -1
- package/lib/module/services/youtubeMigrationService.js +0 -404
- package/lib/module/services/youtubeMigrationService.js.map +0 -1
- package/lib/module/theme/index.js +0 -244
- package/lib/module/theme/index.js.map +0 -1
- package/lib/module/utils/eventUtils.js +0 -270
- package/lib/module/utils/eventUtils.js.map +0 -1
- package/lib/module/utils/haptics.js +0 -59
- package/lib/module/utils/haptics.js.map +0 -1
- package/lib/module/utils/imagePreloader.js +0 -3
- package/lib/module/utils/imagePreloader.js.map +0 -1
- package/lib/typescript/components/BodyText.d.ts +0 -10
- package/lib/typescript/components/BodyText.d.ts.map +0 -1
- package/lib/typescript/components/BrandMark.d.ts +0 -11
- package/lib/typescript/components/BrandMark.d.ts.map +0 -1
- package/lib/typescript/components/CodeInput.d.ts +0 -10
- package/lib/typescript/components/CodeInput.d.ts.map +0 -1
- package/lib/typescript/components/EmailInput.d.ts +0 -8
- package/lib/typescript/components/EmailInput.d.ts.map +0 -1
- package/lib/typescript/components/ExistingUserDataConfirmation.d.ts +0 -12
- package/lib/typescript/components/ExistingUserDataConfirmation.d.ts.map +0 -1
- package/lib/typescript/components/GoogleButton.d.ts +0 -11
- package/lib/typescript/components/GoogleButton.d.ts.map +0 -1
- package/lib/typescript/components/HeadingGroup.d.ts +0 -11
- package/lib/typescript/components/HeadingGroup.d.ts.map +0 -1
- package/lib/typescript/components/ModalHeader.d.ts +0 -11
- package/lib/typescript/components/ModalHeader.d.ts.map +0 -1
- package/lib/typescript/components/ModalSheet.d.ts +0 -13
- package/lib/typescript/components/ModalSheet.d.ts.map +0 -1
- package/lib/typescript/components/OnairosSignInButton.d.ts +0 -13
- package/lib/typescript/components/OnairosSignInButton.d.ts.map +0 -1
- package/lib/typescript/components/PersonaImage.d.ts +0 -8
- package/lib/typescript/components/PersonaImage.d.ts.map +0 -1
- package/lib/typescript/components/PersonaLoadingScreen.d.ts +0 -10
- package/lib/typescript/components/PersonaLoadingScreen.d.ts.map +0 -1
- package/lib/typescript/components/PersonalizationConsentScreen.d.ts +0 -10
- package/lib/typescript/components/PersonalizationConsentScreen.d.ts.map +0 -1
- package/lib/typescript/components/PinCreationScreen.d.ts +0 -10
- package/lib/typescript/components/PinCreationScreen.d.ts.map +0 -1
- package/lib/typescript/components/PlatformConnectorsStep.d.ts +0 -11
- package/lib/typescript/components/PlatformConnectorsStep.d.ts.map +0 -1
- package/lib/typescript/components/PlatformToggle.d.ts +0 -20
- package/lib/typescript/components/PlatformToggle.d.ts.map +0 -1
- package/lib/typescript/components/PrimaryButton.d.ts +0 -22
- package/lib/typescript/components/PrimaryButton.d.ts.map +0 -1
- package/lib/typescript/components/SignInMatchAnimation.d.ts +0 -9
- package/lib/typescript/components/SignInMatchAnimation.d.ts.map +0 -1
- package/lib/typescript/components/SignInStep.d.ts +0 -12
- package/lib/typescript/components/SignInStep.d.ts.map +0 -1
- package/lib/typescript/components/VerificationStep.d.ts +0 -13
- package/lib/typescript/components/VerificationStep.d.ts.map +0 -1
- package/lib/typescript/components/WelcomeScreen.d.ts +0 -9
- package/lib/typescript/components/WelcomeScreen.d.ts.map +0 -1
- package/lib/typescript/components/icons/Basicproficon.d.ts +0 -5
- package/lib/typescript/components/icons/Basicproficon.d.ts.map +0 -1
- package/lib/typescript/components/icons/Basicprofile.d.ts +0 -5
- package/lib/typescript/components/icons/Basicprofile.d.ts.map +0 -1
- package/lib/typescript/components/icons/Checkbox.d.ts +0 -5
- package/lib/typescript/components/icons/Checkbox.d.ts.map +0 -1
- package/lib/typescript/components/icons/Checkmark.d.ts +0 -5
- package/lib/typescript/components/icons/Checkmark.d.ts.map +0 -1
- package/lib/typescript/components/icons/Contentanalysis.d.ts +0 -5
- package/lib/typescript/components/icons/Contentanalysis.d.ts.map +0 -1
- package/lib/typescript/components/icons/Contenticon.d.ts +0 -5
- package/lib/typescript/components/icons/Contenticon.d.ts.map +0 -1
- package/lib/typescript/components/icons/EnochE.d.ts +0 -5
- package/lib/typescript/components/icons/EnochE.d.ts.map +0 -1
- package/lib/typescript/components/icons/Personalityicon.d.ts +0 -5
- package/lib/typescript/components/icons/Personalityicon.d.ts.map +0 -1
- package/lib/typescript/components/icons/Personalityprofile.d.ts +0 -5
- package/lib/typescript/components/icons/Personalityprofile.d.ts.map +0 -1
- package/lib/typescript/components/icons/Personalitytraits.d.ts +0 -5
- package/lib/typescript/components/icons/Personalitytraits.d.ts.map +0 -1
- package/lib/typescript/components/icons/Userpreferences.d.ts +0 -5
- package/lib/typescript/components/icons/Userpreferences.d.ts.map +0 -1
- package/lib/typescript/components/icons/index.d.ts +0 -12
- package/lib/typescript/components/icons/index.d.ts.map +0 -1
- package/lib/typescript/config/api.d.ts +0 -24
- package/lib/typescript/config/api.d.ts.map +0 -1
- package/lib/typescript/context/AuthContext.d.ts +0 -34
- package/lib/typescript/context/AuthContext.d.ts.map +0 -1
- package/lib/typescript/hooks/useConnectedAccounts.d.ts +0 -11
- package/lib/typescript/hooks/useConnectedAccounts.d.ts.map +0 -1
- package/lib/typescript/hooks/useUserConnections.d.ts +0 -12
- package/lib/typescript/hooks/useUserConnections.d.ts.map +0 -1
- package/lib/typescript/services/apiClient.d.ts +0 -91
- package/lib/typescript/services/apiClient.d.ts.map +0 -1
- package/lib/typescript/services/authService.d.ts +0 -216
- package/lib/typescript/services/authService.d.ts.map +0 -1
- package/lib/typescript/services/biometricPinService.d.ts +0 -29
- package/lib/typescript/services/biometricPinService.d.ts.map +0 -1
- package/lib/typescript/services/connectedAccountsService.d.ts +0 -56
- package/lib/typescript/services/connectedAccountsService.d.ts.map +0 -1
- package/lib/typescript/services/googleAuthService.d.ts +0 -63
- package/lib/typescript/services/googleAuthService.d.ts.map +0 -1
- package/lib/typescript/services/imageCompressionService.d.ts +0 -37
- package/lib/typescript/services/imageCompressionService.d.ts.map +0 -1
- package/lib/typescript/services/jwtStorageService.d.ts +0 -86
- package/lib/typescript/services/jwtStorageService.d.ts.map +0 -1
- package/lib/typescript/services/mobileTrainingService.d.ts +0 -45
- package/lib/typescript/services/mobileTrainingService.d.ts.map +0 -1
- package/lib/typescript/services/pinEncryptionService.d.ts +0 -17
- package/lib/typescript/services/pinEncryptionService.d.ts.map +0 -1
- package/lib/typescript/services/pinStorageUtils.d.ts +0 -25
- package/lib/typescript/services/pinStorageUtils.d.ts.map +0 -1
- package/lib/typescript/services/storageService.d.ts +0 -128
- package/lib/typescript/services/storageService.d.ts.map +0 -1
- package/lib/typescript/services/trainingApiHelpers.d.ts +0 -38
- package/lib/typescript/services/trainingApiHelpers.d.ts.map +0 -1
- package/lib/typescript/services/userConnectionsService.d.ts +0 -90
- package/lib/typescript/services/userConnectionsService.d.ts.map +0 -1
- package/lib/typescript/services/youtubeMigrationService.d.ts +0 -12
- package/lib/typescript/services/youtubeMigrationService.d.ts.map +0 -1
- package/lib/typescript/theme/index.d.ts +0 -416
- package/lib/typescript/theme/index.d.ts.map +0 -1
- package/lib/typescript/utils/eventUtils.d.ts +0 -108
- package/lib/typescript/utils/eventUtils.d.ts.map +0 -1
- package/lib/typescript/utils/haptics.d.ts +0 -11
- package/lib/typescript/utils/haptics.d.ts.map +0 -1
- package/lib/typescript/utils/imagePreloader.d.ts +0 -2
- package/lib/typescript/utils/imagePreloader.d.ts.map +0 -1
- package/src/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/src/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/src/assets/icons/Facebookicon.png +0 -0
- package/src/assets/icons/Gmail.png +0 -0
- package/src/assets/icons/Linkedinicon.png +0 -0
- package/src/assets/icons/Redditicon.png +0 -0
- package/src/assets/icons/YouTubeicon2.png +0 -0
- package/src/assets/icons/YouTubeicon3.png +0 -0
- package/src/assets/icons/farcaster.png +0 -0
- package/src/assets/icons/instagram.png +0 -0
- package/src/assets/icons/pinterest.png +0 -0
- package/src/assets/icons/swerv_logo.png +0 -0
- package/src/assets/icons/twitter.jpg +0 -0
- package/src/assets/images/Checkbox.svg +0 -3
- package/src/assets/images/EnochE.svg +0 -19
- package/src/assets/images/Enochicon1.png +0 -0
- package/src/assets/images/Face_ID_logo.png +0 -0
- package/src/assets/images/Facebookicon.png +0 -0
- package/src/assets/images/Gmail.png +0 -0
- package/src/assets/images/Googlelogo.png +0 -0
- package/src/assets/images/Linkedinicon.png +0 -0
- package/src/assets/images/Onairoslogo.png +0 -0
- package/src/assets/images/Personalityprofile.svg +0 -3
- package/src/assets/images/Personalitytraits.svg +0 -3
- package/src/assets/images/Redditicon.png +0 -0
- package/src/assets/images/Userpreferences.svg +0 -3
- package/src/assets/images/YouTubeicon3.png +0 -0
- package/src/assets/images/arrow.svg +0 -20
- package/src/assets/images/basicproficon.svg +0 -43
- package/src/assets/images/basicprofile.svg +0 -3
- package/src/assets/images/checkmark.svg +0 -4
- package/src/assets/images/contentanalysis.svg +0 -3
- package/src/assets/images/contenticon.svg +0 -23
- package/src/assets/images/persona1.png +0 -0
- package/src/assets/images/persona2.png +0 -0
- package/src/assets/images/persona3.png +0 -0
- package/src/assets/images/persona4.png +0 -0
- package/src/assets/images/persona5.png +0 -0
- package/src/assets/images/personalityicon.svg +0 -18
- package/src/assets/images/x-close.svg +0 -3
- package/src/components/BodyText.tsx +0 -33
- package/src/components/BrandMark.tsx +0 -62
- package/src/components/CodeInput.tsx +0 -32
- package/src/components/EmailInput.tsx +0 -31
- package/src/components/ExistingUserDataConfirmation.tsx +0 -507
- package/src/components/GoogleButton.tsx +0 -55
- package/src/components/HeadingGroup.tsx +0 -49
- package/src/components/ModalHeader.tsx +0 -125
- package/src/components/ModalSheet.tsx +0 -59
- package/src/components/OnairosSignInButton.tsx +0 -132
- package/src/components/PersonaImage.tsx +0 -79
- package/src/components/PersonaLoadingScreen.tsx +0 -201
- package/src/components/PersonalizationConsentScreen.tsx +0 -410
- package/src/components/PinCreationScreen.tsx +0 -492
- package/src/components/PlatformConnectorsStep.tsx +0 -892
- package/src/components/PlatformToggle.tsx +0 -226
- package/src/components/PrimaryButton.tsx +0 -214
- package/src/components/SignInMatchAnimation.tsx +0 -225
- package/src/components/SignInStep.tsx +0 -217
- package/src/components/VerificationStep.tsx +0 -198
- package/src/components/WelcomeScreen.tsx +0 -490
- package/src/components/icons/Basicproficon.tsx +0 -30
- package/src/components/icons/Basicprofile.tsx +0 -17
- package/src/components/icons/Checkbox.tsx +0 -17
- package/src/components/icons/Checkmark.tsx +0 -24
- package/src/components/icons/Contentanalysis.tsx +0 -17
- package/src/components/icons/Contenticon.tsx +0 -30
- package/src/components/icons/EnochE.tsx +0 -39
- package/src/components/icons/Personalityicon.tsx +0 -22
- package/src/components/icons/Personalityprofile.tsx +0 -17
- package/src/components/icons/Personalitytraits.tsx +0 -17
- package/src/components/icons/Userpreferences.tsx +0 -17
- package/src/components/icons/index.ts +0 -12
- package/src/config/api.ts +0 -25
- package/src/context/AuthContext.tsx +0 -393
- package/src/hooks/useConnectedAccounts.ts +0 -139
- package/src/hooks/useUserConnections.ts +0 -166
- package/src/services/apiClient.ts +0 -337
- package/src/services/authService.ts +0 -1008
- package/src/services/biometricPinService.ts +0 -193
- package/src/services/connectedAccountsService.ts +0 -290
- package/src/services/googleAuthService.ts +0 -279
- package/src/services/imageCompressionService.ts +0 -303
- package/src/services/jwtStorageService.ts +0 -257
- package/src/services/mobileTrainingService.ts +0 -204
- package/src/services/pinEncryptionService.ts +0 -76
- package/src/services/pinStorageUtils.ts +0 -97
- package/src/services/storageService.ts +0 -452
- package/src/services/trainingApiHelpers.ts +0 -67
- package/src/services/userConnectionsService.ts +0 -557
- package/src/services/youtubeMigrationService.ts +0 -454
- package/src/theme/index.ts +0 -239
- package/src/utils/eventUtils.ts +0 -303
- package/src/utils/haptics.ts +0 -59
- package/src/utils/imagePreloader.ts +0 -2
|
@@ -3,753 +3,399 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.verifyEmailCode = exports.
|
|
7
|
-
var _googleSignin = require("@react-native-google-signin/google-signin");
|
|
6
|
+
exports.verifyEmailCode = exports.updateGoogleClientIds = exports.testApiConnectivity = exports.storePIN = exports.requestEmailVerification = exports.refreshYouTubeTokens = exports.refreshGoogleTokens = exports.isOAuthCallback = exports.initiateOAuth = exports.initiateNativeAuth = exports.initializePlatformAuthService = exports.hasNativeSDK = exports.handleOAuthCallbackUrl = exports.handleOAuthCallback = exports.getStoredJwtToken = exports.getPlatformColor = exports.getAuthEndpoint = exports.disconnectPlatform = exports.clearStoredTokens = exports.checkEmailVerificationStatus = void 0;
|
|
8
7
|
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
-
var
|
|
8
|
+
var _apiKeyService = require("./apiKeyService");
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
// ๐ CRITICAL: Use two-tier authentication system
|
|
11
|
+
// - Developer API key for email verification requests
|
|
12
|
+
// - JWT tokens for user-authenticated requests after email verification
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Initialize the platform auth service
|
|
16
|
+
* This service now uses the two-tier authentication system
|
|
14
17
|
*/
|
|
18
|
+
const initializePlatformAuthService = async () => {
|
|
19
|
+
try {
|
|
20
|
+
// Check if app is already initialized with API key
|
|
21
|
+
const existingConfig = (0, _apiKeyService.getApiConfig)();
|
|
22
|
+
if (existingConfig && existingConfig.apiKey) {
|
|
23
|
+
console.log('๐ Platform auth service using existing app configuration');
|
|
24
|
+
console.log(`โ
Environment: ${existingConfig.environment}`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
15
27
|
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
// If no app initialization, we can't proceed
|
|
29
|
+
console.error('โ Platform auth service requires app-level API key initialization');
|
|
30
|
+
throw new Error('Platform auth service requires app-level API key initialization. Please call initializeApiKey() first.');
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('โ Failed to initialize platform auth service:', error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Configuration for each platform's authentication
|
|
38
|
+
exports.initializePlatformAuthService = initializePlatformAuthService;
|
|
39
|
+
let PLATFORM_AUTH_CONFIG = {
|
|
21
40
|
instagram: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
responseType: 'code',
|
|
27
|
-
hasNativeSDK: false
|
|
41
|
+
hasNativeSDK: false,
|
|
42
|
+
// Instagram uses OAuth WebView flow
|
|
43
|
+
authEndpoint: '/instagram/authorize',
|
|
44
|
+
color: '#E1306C'
|
|
28
45
|
},
|
|
29
46
|
youtube: {
|
|
30
|
-
|
|
47
|
+
hasNativeSDK: true,
|
|
48
|
+
// Native Google Sign-In SDK enabled
|
|
49
|
+
nativeSDKPackage: '@react-native-google-signin/google-signin',
|
|
50
|
+
authEndpoint: '/youtube/authorize',
|
|
51
|
+
color: '#FF0000',
|
|
31
52
|
clientId: '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com',
|
|
32
53
|
redirectUri: 'onairosevents://auth/callback',
|
|
33
54
|
scope: 'https://www.googleapis.com/auth/youtube.readonly',
|
|
34
|
-
responseType: 'code'
|
|
35
|
-
hasNativeSDK: true // Changed to true for native SDK
|
|
55
|
+
responseType: 'code'
|
|
36
56
|
},
|
|
37
57
|
reddit: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
scope: 'identity,read',
|
|
42
|
-
responseType: 'code',
|
|
43
|
-
hasNativeSDK: false
|
|
58
|
+
hasNativeSDK: false,
|
|
59
|
+
authEndpoint: '/reddit/authorize',
|
|
60
|
+
color: '#FF4500'
|
|
44
61
|
},
|
|
45
62
|
pinterest: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
scope: 'boards:read,pins:read',
|
|
50
|
-
responseType: 'code',
|
|
51
|
-
hasNativeSDK: false
|
|
52
|
-
},
|
|
53
|
-
facebook: {
|
|
54
|
-
authUrl: 'https://www.facebook.com/v12.0/dialog/oauth',
|
|
55
|
-
clientId: 'demo_facebook_client_id',
|
|
56
|
-
redirectUri: 'onairosevents://auth/callback',
|
|
57
|
-
scope: 'public_profile,email',
|
|
58
|
-
responseType: 'code',
|
|
59
|
-
hasNativeSDK: false
|
|
60
|
-
},
|
|
61
|
-
// GitHub connector is temporarily commented out
|
|
62
|
-
// github: {
|
|
63
|
-
// authUrl: 'https://github.com/login/oauth/authorize',
|
|
64
|
-
// clientId: 'demo_github_client_id',
|
|
65
|
-
// redirectUri: 'onairosevents://auth/callback',
|
|
66
|
-
// scope: 'repo,user',
|
|
67
|
-
// responseType: 'code',
|
|
68
|
-
// hasNativeSDK: false
|
|
69
|
-
// },
|
|
70
|
-
linkedin: {
|
|
71
|
-
authUrl: 'https://api2.onairos.uk/linkedin/authorize',
|
|
72
|
-
clientId: '',
|
|
73
|
-
// No client ID needed - backend handles OAuth
|
|
74
|
-
redirectUri: 'onairosevents://auth/callback',
|
|
75
|
-
scope: 'openid profile email',
|
|
76
|
-
// Updated to OpenID Connect scopes as per your backend
|
|
77
|
-
responseType: 'code',
|
|
78
|
-
hasNativeSDK: false // LinkedIn has no modern native SDK
|
|
79
|
-
},
|
|
80
|
-
gmail: {
|
|
81
|
-
authUrl: 'https://api2.onairos.uk/gmail/authorize',
|
|
82
|
-
clientId: 'demo_gmail_client_id',
|
|
83
|
-
redirectUri: 'onairosevents://auth/callback',
|
|
84
|
-
scope: 'https://www.googleapis.com/auth/gmail.readonly',
|
|
85
|
-
responseType: 'code',
|
|
86
|
-
hasNativeSDK: false
|
|
63
|
+
hasNativeSDK: false,
|
|
64
|
+
authEndpoint: '/pinterest/authorize',
|
|
65
|
+
color: '#E60023'
|
|
87
66
|
},
|
|
88
67
|
email: {
|
|
89
|
-
// Email doesn't use OAuth but we still need to handle it in the flow
|
|
90
68
|
hasNativeSDK: false,
|
|
91
|
-
|
|
69
|
+
authEndpoint: '/gmail/authorize',
|
|
70
|
+
color: '#4285F4'
|
|
92
71
|
}
|
|
93
72
|
};
|
|
94
73
|
|
|
95
|
-
/**
|
|
96
|
-
*
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a native SDK is available for the given platform
|
|
97
76
|
*/
|
|
98
77
|
const hasNativeSDK = platform => {
|
|
99
|
-
|
|
100
|
-
return (
|
|
78
|
+
const config = PLATFORM_AUTH_CONFIG[platform];
|
|
79
|
+
return (config === null || config === void 0 ? void 0 : config.hasNativeSDK) || false;
|
|
101
80
|
};
|
|
102
81
|
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
82
|
+
/**
|
|
83
|
+
* Gets the auth endpoint URL for a platform
|
|
105
84
|
*/
|
|
106
85
|
exports.hasNativeSDK = hasNativeSDK;
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// Validate username
|
|
112
|
-
if (!username || username.trim() === '') {
|
|
113
|
-
console.error(`โ [OAUTH] Username is required for ${platform} OAuth`);
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// For platforms that don't need OAuth (like email), handle differently
|
|
118
|
-
if (platform === 'email') {
|
|
119
|
-
console.log('๐ง [OAUTH] Email platform selected, returning mock auth URL');
|
|
120
|
-
return 'https://api2.onairos.uk/email/authorize?action=verify';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Construct the proxy URL
|
|
124
|
-
const proxyUrl = `https://api2.onairos.uk/${platform}/authorize`;
|
|
125
|
-
console.log(`๐ [OAUTH] Proxy URL: ${proxyUrl}`);
|
|
126
|
-
const requestBody = {
|
|
127
|
-
session: {
|
|
128
|
-
username: username.trim(),
|
|
129
|
-
platform: platform,
|
|
130
|
-
timestamp: new Date().toISOString()
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
console.log(`๐ค [OAUTH] Request body:`, requestBody);
|
|
134
|
-
console.log(`๐ [OAUTH] Headers:`, (0, _api.getApiHeaders)());
|
|
135
|
-
|
|
136
|
-
// Make a POST request to the proxy
|
|
137
|
-
const response = await fetch(proxyUrl, {
|
|
138
|
-
method: 'POST',
|
|
139
|
-
headers: (0, _api.getApiHeaders)(),
|
|
140
|
-
body: JSON.stringify(requestBody)
|
|
141
|
-
});
|
|
142
|
-
console.log(`๐ก [OAUTH] Response status: ${response.status} ${response.statusText}`);
|
|
143
|
-
if (!response.ok) {
|
|
144
|
-
const errorText = await response.text();
|
|
145
|
-
console.error(`โ [OAUTH] Error initiating OAuth for ${platform}: ${response.status} - ${errorText}`);
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
const data = await response.json();
|
|
149
|
-
console.log(`๐ [OAUTH] Response data for ${platform}:`, data);
|
|
150
|
-
|
|
151
|
-
// Get the authorization URL from the response
|
|
152
|
-
// Different platforms might use different keys (e.g., pinterestURL, youtubeURL)
|
|
153
|
-
const urlKey = `${platform}URL`;
|
|
154
|
-
const authUrl = data[urlKey] || data.url || null;
|
|
155
|
-
console.log(`๐ [OAUTH] Auth URL for ${platform} (key: ${urlKey}):`, authUrl);
|
|
156
|
-
return authUrl;
|
|
157
|
-
} catch (error) {
|
|
158
|
-
console.error(`Error initiating OAuth for ${platform}:`, error);
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
86
|
+
const getAuthEndpoint = platform => {
|
|
87
|
+
const config = PLATFORM_AUTH_CONFIG[platform];
|
|
88
|
+
return (config === null || config === void 0 ? void 0 : config.authEndpoint) || '';
|
|
161
89
|
};
|
|
162
90
|
|
|
163
|
-
/**
|
|
164
|
-
*
|
|
165
|
-
* Updated with CRITICAL parameters for refresh token generation
|
|
91
|
+
/**
|
|
92
|
+
* Gets the color associated with a platform
|
|
166
93
|
*/
|
|
167
|
-
exports.
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// โ
CRITICAL: Web client ID for refresh tokens
|
|
172
|
-
iosClientId: IOS_CLIENT_ID,
|
|
173
|
-
// โ
iOS client ID for native auth
|
|
174
|
-
|
|
175
|
-
// ๐ CRITICAL: These parameters are REQUIRED for refresh tokens
|
|
176
|
-
offlineAccess: true,
|
|
177
|
-
// โ CRITICAL: Enables refresh tokens
|
|
178
|
-
forceCodeForRefreshToken: true,
|
|
179
|
-
// โ CRITICAL: Forces refresh token generation
|
|
180
|
-
|
|
181
|
-
// โ
Enhanced scopes for YouTube
|
|
182
|
-
scopes: ['https://www.googleapis.com/auth/youtube.readonly', 'openid', 'profile', 'email'],
|
|
183
|
-
// โ
Clear settings to avoid conflicts
|
|
184
|
-
hostedDomain: '',
|
|
185
|
-
accountName: ''
|
|
186
|
-
});
|
|
94
|
+
exports.getAuthEndpoint = getAuthEndpoint;
|
|
95
|
+
const getPlatformColor = platform => {
|
|
96
|
+
const config = PLATFORM_AUTH_CONFIG[platform];
|
|
97
|
+
return (config === null || config === void 0 ? void 0 : config.color) || '#000000';
|
|
187
98
|
};
|
|
188
99
|
|
|
189
|
-
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
100
|
+
/**
|
|
101
|
+
* Initiates the OAuth flow for a platform
|
|
102
|
+
* @param platform The platform to authenticate with
|
|
103
|
+
* @param username The username to associate with the authentication
|
|
104
|
+
* @param appName The app name to use for the OAuth session (optional)
|
|
105
|
+
* @returns A Promise that resolves to the OAuth URL to open in a WebView or null if using native SDK
|
|
192
106
|
*/
|
|
193
|
-
|
|
107
|
+
exports.getPlatformColor = getPlatformColor;
|
|
108
|
+
const initiateOAuth = async (platform, username, appName) => {
|
|
194
109
|
try {
|
|
195
|
-
|
|
196
|
-
console.log('
|
|
197
|
-
console.log('
|
|
198
|
-
|
|
199
|
-
//
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
} catch (signOutError) {
|
|
204
|
-
console.log('โน๏ธ Sign out not needed:', signOutError);
|
|
110
|
+
console.log('๐ Initiating OAuth for platform:', platform);
|
|
111
|
+
console.log('๐ค Username:', username);
|
|
112
|
+
console.log('๐ฑ App name:', appName);
|
|
113
|
+
|
|
114
|
+
// Check if the platform is supported
|
|
115
|
+
if (!PLATFORM_AUTH_CONFIG[platform]) {
|
|
116
|
+
console.error('โ Unsupported platform:', platform);
|
|
117
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
205
118
|
}
|
|
206
119
|
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
console.log('โ
Token cache cleared');
|
|
213
|
-
}
|
|
214
|
-
} catch (clearError) {
|
|
215
|
-
console.log('โน๏ธ No token cache to clear');
|
|
120
|
+
// Check if platform has a native SDK
|
|
121
|
+
if (PLATFORM_AUTH_CONFIG[platform].hasNativeSDK) {
|
|
122
|
+
console.log('๐ฑ Platform uses native SDK, returning null');
|
|
123
|
+
// Return null to indicate that we should use the native SDK
|
|
124
|
+
return null;
|
|
216
125
|
}
|
|
126
|
+
console.log('๐ Platform uses OAuth WebView flow');
|
|
127
|
+
console.log('๐ Auth endpoint:', PLATFORM_AUTH_CONFIG[platform].authEndpoint);
|
|
128
|
+
|
|
129
|
+
// Pre-flight connectivity check
|
|
130
|
+
console.log('๐ Performing pre-flight connectivity check...');
|
|
131
|
+
const connectivityResult = await testApiConnectivity();
|
|
132
|
+
if (!connectivityResult.success) {
|
|
133
|
+
console.error('โ Pre-flight connectivity check failed:', connectivityResult.error);
|
|
134
|
+
throw new Error(`Cannot reach authentication server: ${connectivityResult.error}`);
|
|
135
|
+
}
|
|
136
|
+
console.log('โ
Pre-flight connectivity check passed');
|
|
217
137
|
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
// โ
CRITICAL: Web client ID for refresh tokens
|
|
223
|
-
iosClientId: IOS_CLIENT_ID,
|
|
224
|
-
// โ
iOS client ID for native auth
|
|
225
|
-
|
|
226
|
-
// ๐ FORCE REFRESH TOKEN SETTINGS:
|
|
227
|
-
offlineAccess: true,
|
|
228
|
-
// Request offline access
|
|
229
|
-
forceCodeForRefreshToken: true,
|
|
230
|
-
// Force refresh token generation
|
|
231
|
-
|
|
232
|
-
// ๐ FORCE CONSENT SCREEN:
|
|
233
|
-
scopes: ['https://www.googleapis.com/auth/youtube.readonly', 'openid', 'profile', 'email'],
|
|
234
|
-
// โ
CRITICAL: Clear settings to force fresh consent
|
|
235
|
-
hostedDomain: '',
|
|
236
|
-
accountName: ''
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
// Step 4: โ
Check Play Services
|
|
240
|
-
await _googleSignin.GoogleSignin.hasPlayServices();
|
|
241
|
-
console.log('โ
Play Services available');
|
|
242
|
-
|
|
243
|
-
// Step 5: โ
CRITICAL: Sign in (this SHOULD show consent screen)
|
|
244
|
-
console.log('๐ Initiating sign-in - consent screen should appear...');
|
|
245
|
-
console.log('๐ฑ User should see: "Allow [App] to access your YouTube account when you\'re not using the app?"');
|
|
246
|
-
const userInfo = await _googleSignin.GoogleSignin.signIn();
|
|
247
|
-
console.log('โ
Sign-in completed - checking for refresh token...');
|
|
248
|
-
console.log('๐ค User email:', (_userInfo$data = userInfo.data) === null || _userInfo$data === void 0 || (_userInfo$data = _userInfo$data.user) === null || _userInfo$data === void 0 ? void 0 : _userInfo$data.email);
|
|
249
|
-
|
|
250
|
-
// Step 6: โ
Get tokens after consent
|
|
251
|
-
const tokens = await _googleSignin.GoogleSignin.getTokens();
|
|
252
|
-
const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
|
|
253
|
-
console.log('๐ FULL userInfo object from forceYouTubeReconnectionWithConsent:');
|
|
254
|
-
console.log(JSON.stringify(userInfo, null, 2));
|
|
255
|
-
console.log('๐ FULL tokens object from forceYouTubeReconnectionWithConsent:');
|
|
256
|
-
console.log(JSON.stringify(tokens, null, 2));
|
|
257
|
-
console.log('๐ FULL currentUser object from forceYouTubeReconnectionWithConsent:');
|
|
258
|
-
console.log(JSON.stringify(currentUser, null, 2));
|
|
259
|
-
console.log('๐ Token analysis:');
|
|
260
|
-
console.log('- Access token:', tokens.accessToken ? `${tokens.accessToken.substring(0, 20)}...` : 'Missing');
|
|
261
|
-
console.log('- ID token:', tokens.idToken ? 'Present' : 'Missing');
|
|
262
|
-
console.log('- ServerAuthCode (userInfo):', (_userInfo$data2 = userInfo.data) !== null && _userInfo$data2 !== void 0 && _userInfo$data2.serverAuthCode ? `${userInfo.data.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
263
|
-
console.log('- ServerAuthCode (currentUser):', currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? `${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
264
|
-
|
|
265
|
-
// Step 7: โ
Extract refresh capability
|
|
266
|
-
const refreshToken = ((_userInfo$data3 = userInfo.data) === null || _userInfo$data3 === void 0 ? void 0 : _userInfo$data3.serverAuthCode) || (currentUser === null || currentUser === void 0 ? void 0 : currentUser.serverAuthCode);
|
|
267
|
-
if (refreshToken) {
|
|
268
|
-
var _userInfo$data0, _userInfo$data1, _userInfo$data10, _userInfo$data11, _userInfo$data12, _userInfo$data13;
|
|
269
|
-
console.log('โ
SUCCESS: Got refresh token after consent!');
|
|
270
|
-
console.log('๐ Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
|
|
271
|
-
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
272
|
-
|
|
273
|
-
// Step 8: โ
Get YouTube channel info
|
|
274
|
-
let channelName = 'Unknown Channel';
|
|
275
|
-
let channelId = null;
|
|
276
|
-
try {
|
|
277
|
-
console.log('๐บ Fetching YouTube channel information...');
|
|
278
|
-
const channelResponse = await fetch('https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true', {
|
|
279
|
-
headers: {
|
|
280
|
-
'Authorization': `Bearer ${tokens.accessToken}`,
|
|
281
|
-
'Accept': 'application/json'
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
if (channelResponse.ok) {
|
|
285
|
-
const channelData = await channelResponse.json();
|
|
286
|
-
if (channelData.items && channelData.items.length > 0) {
|
|
287
|
-
channelName = channelData.items[0].snippet.title;
|
|
288
|
-
channelId = channelData.items[0].id;
|
|
289
|
-
console.log('โ
YouTube channel found:', channelName, 'ID:', channelId);
|
|
290
|
-
} else {
|
|
291
|
-
var _userInfo$data4, _userInfo$data5;
|
|
292
|
-
console.log('โ ๏ธ No YouTube channel found for user');
|
|
293
|
-
channelName = ((_userInfo$data4 = userInfo.data) === null || _userInfo$data4 === void 0 || (_userInfo$data4 = _userInfo$data4.user) === null || _userInfo$data4 === void 0 ? void 0 : _userInfo$data4.name) || ((_userInfo$data5 = userInfo.data) === null || _userInfo$data5 === void 0 || (_userInfo$data5 = _userInfo$data5.user) === null || _userInfo$data5 === void 0 ? void 0 : _userInfo$data5.email) || 'No Channel';
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
var _userInfo$data6, _userInfo$data7;
|
|
297
|
-
console.log('โ ๏ธ Failed to fetch YouTube channel info:', channelResponse.status);
|
|
298
|
-
channelName = ((_userInfo$data6 = userInfo.data) === null || _userInfo$data6 === void 0 || (_userInfo$data6 = _userInfo$data6.user) === null || _userInfo$data6 === void 0 ? void 0 : _userInfo$data6.name) || ((_userInfo$data7 = userInfo.data) === null || _userInfo$data7 === void 0 || (_userInfo$data7 = _userInfo$data7.user) === null || _userInfo$data7 === void 0 ? void 0 : _userInfo$data7.email) || 'Unknown Channel';
|
|
299
|
-
}
|
|
300
|
-
} catch (channelError) {
|
|
301
|
-
var _userInfo$data8, _userInfo$data9;
|
|
302
|
-
console.log('โ ๏ธ Error fetching YouTube channel info:', channelError);
|
|
303
|
-
channelName = ((_userInfo$data8 = userInfo.data) === null || _userInfo$data8 === void 0 || (_userInfo$data8 = _userInfo$data8.user) === null || _userInfo$data8 === void 0 ? void 0 : _userInfo$data8.name) || ((_userInfo$data9 = userInfo.data) === null || _userInfo$data9 === void 0 || (_userInfo$data9 = _userInfo$data9.user) === null || _userInfo$data9 === void 0 ? void 0 : _userInfo$data9.email) || 'Unknown Channel';
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Step 9: โ
Get authentication token
|
|
307
|
-
let authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
308
|
-
if (!authToken || authToken.trim().length < 20) {
|
|
309
|
-
console.log('๐ Creating authentication token for YouTube connection...');
|
|
310
|
-
// Create token logic here if needed
|
|
311
|
-
authToken = 'temp_token_for_youtube_connection';
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Step 10: โ
Send comprehensive data to backend
|
|
315
|
-
const backendPayload = {
|
|
138
|
+
// Handle Instagram with specific API format
|
|
139
|
+
if (platform === 'instagram') {
|
|
140
|
+
const state = 'djksbfds';
|
|
141
|
+
const jsonData = {
|
|
316
142
|
session: {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
timestamp: new Date().toISOString(),
|
|
320
|
-
channelName: channelName,
|
|
321
|
-
channelId: channelId,
|
|
322
|
-
forceConsent: true // Flag to indicate this was forced consent
|
|
323
|
-
},
|
|
324
|
-
googleUser: (_userInfo$data0 = userInfo.data) === null || _userInfo$data0 === void 0 ? void 0 : _userInfo$data0.user,
|
|
325
|
-
accessToken: tokens.accessToken,
|
|
326
|
-
idToken: tokens.idToken,
|
|
327
|
-
refreshToken: refreshToken,
|
|
328
|
-
// โ
CRITICAL: The refresh token!
|
|
329
|
-
serverAuthCode: refreshToken,
|
|
330
|
-
// โ
Same as refresh token
|
|
331
|
-
|
|
332
|
-
// โ
CRITICAL: Additional compatibility fields for backend
|
|
333
|
-
refresh_token: refreshToken,
|
|
334
|
-
// Snake case version
|
|
335
|
-
server_auth_code: refreshToken,
|
|
336
|
-
// Snake case version
|
|
337
|
-
authCode: refreshToken,
|
|
338
|
-
// Alternative naming
|
|
339
|
-
|
|
340
|
-
userAccountInfo: {
|
|
341
|
-
username: username,
|
|
342
|
-
email: (_userInfo$data1 = userInfo.data) === null || _userInfo$data1 === void 0 || (_userInfo$data1 = _userInfo$data1.user) === null || _userInfo$data1 === void 0 ? void 0 : _userInfo$data1.email,
|
|
343
|
-
authToken: authToken,
|
|
344
|
-
channelName: channelName,
|
|
345
|
-
channelId: channelId,
|
|
346
|
-
userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${(_userInfo$data10 = userInfo.data) === null || _userInfo$data10 === void 0 || (_userInfo$data10 = _userInfo$data10.user) === null || _userInfo$data10 === void 0 ? void 0 : _userInfo$data10.email}`,
|
|
347
|
-
googleId: (_userInfo$data11 = userInfo.data) === null || _userInfo$data11 === void 0 || (_userInfo$data11 = _userInfo$data11.user) === null || _userInfo$data11 === void 0 ? void 0 : _userInfo$data11.id,
|
|
348
|
-
// โ
CRITICAL: Also include refresh token in userAccountInfo
|
|
349
|
-
refreshToken: refreshToken,
|
|
350
|
-
serverAuthCode: refreshToken
|
|
351
|
-
},
|
|
352
|
-
tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
|
|
353
|
-
// 1 hour from now
|
|
354
|
-
requestRefreshToken: true,
|
|
355
|
-
debugInfo: {
|
|
356
|
-
hasRefreshToken: true,
|
|
357
|
-
refreshTokenType: refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken',
|
|
358
|
-
configuredForRefresh: true,
|
|
359
|
-
forcedConsent: true,
|
|
360
|
-
consentMethod: 'signOut_and_configure',
|
|
361
|
-
refreshTokenValue: refreshToken // Include actual value for debugging
|
|
143
|
+
oauthState: state,
|
|
144
|
+
username: username || 'Avatar'
|
|
362
145
|
}
|
|
363
146
|
};
|
|
364
|
-
console.log('๐ค Sending
|
|
365
|
-
|
|
366
|
-
hasRefreshToken: !!backendPayload.refreshToken,
|
|
367
|
-
hasServerAuthCode: !!backendPayload.serverAuthCode,
|
|
368
|
-
refreshTokenType: backendPayload.debugInfo.refreshTokenType,
|
|
369
|
-
userEmail: (_userInfo$data12 = userInfo.data) === null || _userInfo$data12 === void 0 || (_userInfo$data12 = _userInfo$data12.user) === null || _userInfo$data12 === void 0 ? void 0 : _userInfo$data12.email,
|
|
370
|
-
forcedConsent: true
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
// Step 11: โ
Send to backend with ENHANCED LOGGING
|
|
374
|
-
console.log('๐ [YOUTUBE REAUTH] ===== SENDING REAUTH SIGNAL TO BACKEND =====');
|
|
375
|
-
console.log('๐ [YOUTUBE REAUTH] Endpoint: https://api2.onairos.uk/youtube/native-auth');
|
|
376
|
-
console.log('๐ [YOUTUBE REAUTH] Method: POST');
|
|
377
|
-
console.log('๐ [YOUTUBE REAUTH] Headers:', {
|
|
378
|
-
'Content-Type': 'application/json',
|
|
379
|
-
'Authorization': authToken ? `${authToken.substring(0, 20)}...` : 'NO AUTH TOKEN'
|
|
380
|
-
});
|
|
381
|
-
console.log('๐ [YOUTUBE REAUTH] Payload Summary:', {
|
|
382
|
-
hasAccessToken: !!backendPayload.accessToken,
|
|
383
|
-
hasRefreshToken: !!backendPayload.refreshToken,
|
|
384
|
-
hasServerAuthCode: !!backendPayload.serverAuthCode,
|
|
385
|
-
refreshTokenType: backendPayload.debugInfo.refreshTokenType,
|
|
386
|
-
userEmail: (_userInfo$data13 = userInfo.data) === null || _userInfo$data13 === void 0 || (_userInfo$data13 = _userInfo$data13.user) === null || _userInfo$data13 === void 0 ? void 0 : _userInfo$data13.email,
|
|
387
|
-
channelName: channelName,
|
|
388
|
-
forcedConsent: true,
|
|
389
|
-
requestRefreshToken: true
|
|
390
|
-
});
|
|
391
|
-
console.log('๐ [YOUTUBE REAUTH] FULL PAYLOAD:', JSON.stringify(backendPayload, null, 2));
|
|
392
|
-
const backendResponse = await fetch('https://api2.onairos.uk/youtube/native-auth', {
|
|
147
|
+
console.log('๐ค Sending Instagram OAuth request:', jsonData);
|
|
148
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)(PLATFORM_AUTH_CONFIG[platform].authEndpoint, {
|
|
393
149
|
method: 'POST',
|
|
394
|
-
|
|
395
|
-
'Content-Type': 'application/json',
|
|
396
|
-
...(authToken && {
|
|
397
|
-
'Authorization': authToken
|
|
398
|
-
})
|
|
399
|
-
},
|
|
400
|
-
body: JSON.stringify(backendPayload)
|
|
150
|
+
body: JSON.stringify(jsonData)
|
|
401
151
|
});
|
|
402
|
-
console.log('๐ก
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (isTemporaryMode) {
|
|
413
|
-
console.log('๐ [YOUTUBE REAUTH] YouTube connected in temporary mode');
|
|
414
|
-
console.log('โ
[YOUTUBE REAUTH] Training will work, but connection expires in ~1 hour');
|
|
415
|
-
console.log('๐ [YOUTUBE REAUTH] SUCCESS: Temporary YouTube connection established!');
|
|
416
|
-
console.log('๐ [YOUTUBE REAUTH] Connection Details:');
|
|
417
|
-
console.log('๐ [YOUTUBE REAUTH] Mode: Temporary (expires ~1 hour)');
|
|
418
|
-
console.log('๐ [YOUTUBE REAUTH] Training Ready: Yes');
|
|
419
|
-
console.log('๐ [YOUTUBE REAUTH] Refresh token sent:', refreshToken ? 'Yes' : 'No');
|
|
420
|
-
} else if (responseData.hasRefreshToken || responseData.refreshTokenReceived) {
|
|
421
|
-
console.log('โ
[YOUTUBE REAUTH] Backend CONFIRMED refresh token received');
|
|
422
|
-
console.log('โ
[YOUTUBE REAUTH] Response hasRefreshToken:', responseData.hasRefreshToken);
|
|
423
|
-
console.log('๐ [YOUTUBE REAUTH] SUCCESS: Full YouTube connection with refresh tokens!');
|
|
424
|
-
|
|
425
|
-
// CRITICAL: Print the refresh token that was sent for debugging
|
|
426
|
-
console.log('๐ [YOUTUBE REAUTH] REFRESH TOKEN SENT TO BACKEND:');
|
|
427
|
-
console.log('๐ [YOUTUBE REAUTH] Full refresh token:', refreshToken);
|
|
428
|
-
console.log('๐ [YOUTUBE REAUTH] Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
|
|
429
|
-
console.log('๐ [YOUTUBE REAUTH] Refresh token length:', refreshToken.length);
|
|
430
|
-
} else {
|
|
431
|
-
console.warn('โ ๏ธ [YOUTUBE REAUTH] Backend did NOT confirm refresh token reception');
|
|
432
|
-
console.warn('โ ๏ธ [YOUTUBE REAUTH] Response data:', responseData);
|
|
433
|
-
console.warn('โ ๏ธ [YOUTUBE REAUTH] Expected hasRefreshToken or refreshTokenReceived in response');
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
152
|
+
console.log('๐ก Instagram OAuth response status:', response.status);
|
|
153
|
+
if (!response.ok) {
|
|
154
|
+
const errorText = await response.text();
|
|
155
|
+
console.error('โ Instagram OAuth API error:', errorText);
|
|
156
|
+
throw new Error(`Instagram OAuth API error: ${response.status} - ${errorText}`);
|
|
157
|
+
}
|
|
158
|
+
const responseData = await response.json();
|
|
159
|
+
console.log('๐ฅ Instagram OAuth response data:', responseData);
|
|
160
|
+
if (responseData.instagramURL) {
|
|
161
|
+
console.log('โ
Instagram OAuth URL received:', responseData.instagramURL);
|
|
436
162
|
|
|
437
|
-
//
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
} catch (restartError) {
|
|
443
|
-
console.warn('โ ๏ธ [YOUTUBE REAUTH] Training restart signal failed:', restartError);
|
|
444
|
-
console.warn('โ ๏ธ [YOUTUBE REAUTH] User may need to manually restart training');
|
|
163
|
+
// Validate the URL before returning
|
|
164
|
+
if (await validateOAuthUrl(responseData.instagramURL)) {
|
|
165
|
+
return responseData.instagramURL;
|
|
166
|
+
} else {
|
|
167
|
+
throw new Error('Received invalid Instagram OAuth URL');
|
|
445
168
|
}
|
|
446
|
-
return true;
|
|
447
|
-
} else {
|
|
448
|
-
const errorData = await backendResponse.text();
|
|
449
|
-
console.error('โ [YOUTUBE REAUTH] Backend processing FAILED:', backendResponse.status, errorData);
|
|
450
|
-
console.error('โ [YOUTUBE REAUTH] This means the reauth signal was not processed');
|
|
451
|
-
return false;
|
|
452
169
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
console.error('โ This means consent screen did not appear or user denied permissions');
|
|
456
|
-
console.error('๐ก Solutions:');
|
|
457
|
-
console.error(' 1. Try the revoke method: forceYouTubeReconnectionWithRevoke()');
|
|
458
|
-
console.error(' 2. Check Google Console OAuth configuration');
|
|
459
|
-
console.error(' 3. Ensure user clicks "Allow" on consent screen');
|
|
460
|
-
return false;
|
|
461
|
-
}
|
|
462
|
-
} catch (error) {
|
|
463
|
-
console.error('โ Error forcing YouTube consent:', error);
|
|
464
|
-
if (error.code === _googleSignin.statusCodes.SIGN_IN_CANCELLED) {
|
|
465
|
-
console.error('โ User cancelled sign-in - no refresh token obtained');
|
|
466
|
-
console.error('๐ก User must click "Allow" to get refresh token');
|
|
467
|
-
} else if (error.code === _googleSignin.statusCodes.IN_PROGRESS) {
|
|
468
|
-
console.error('โ Sign-in already in progress');
|
|
469
|
-
} else if (error.code === _googleSignin.statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
470
|
-
console.error('โ Google Play Services not available');
|
|
170
|
+
console.error('โ No Instagram URL found in response');
|
|
171
|
+
throw new Error('No Instagram URL found in response');
|
|
471
172
|
}
|
|
472
|
-
return false;
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
173
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
// Step 1: Initialize Google Sign-In
|
|
487
|
-
initializeGoogleSignIn();
|
|
488
|
-
await _googleSignin.GoogleSignin.hasPlayServices();
|
|
174
|
+
// Prepare the request body for other platforms
|
|
175
|
+
const jsonData = {
|
|
176
|
+
session: {
|
|
177
|
+
oauthState: 'djksbfds',
|
|
178
|
+
// Use same state for all platforms
|
|
179
|
+
username: username || 'Avatar',
|
|
180
|
+
appName: appName || 'DefaultApp'
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
console.log(`๐ค Sending ${platform} OAuth request:`, jsonData);
|
|
489
184
|
|
|
490
|
-
//
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
185
|
+
// Make the authenticated request to get the OAuth URL
|
|
186
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)(PLATFORM_AUTH_CONFIG[platform].authEndpoint, {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
body: JSON.stringify(jsonData)
|
|
189
|
+
});
|
|
190
|
+
console.log(`๐ก ${platform} OAuth response status:`, response.status);
|
|
191
|
+
if (!response.ok) {
|
|
192
|
+
const errorText = await response.text();
|
|
193
|
+
console.error(`โ ${platform} OAuth API error:`, errorText);
|
|
194
|
+
throw new Error(`${platform} OAuth API error: ${response.status} - ${errorText}`);
|
|
496
195
|
}
|
|
497
196
|
|
|
498
|
-
//
|
|
499
|
-
await
|
|
500
|
-
console.log(
|
|
501
|
-
|
|
502
|
-
// Step 4: โ
Now sign in again (will DEFINITELY show consent screen)
|
|
503
|
-
console.log('๐ Signing in after revoke - consent screen MUST appear...');
|
|
504
|
-
const userInfo = await _googleSignin.GoogleSignin.signIn();
|
|
197
|
+
// Parse the response
|
|
198
|
+
const data = await response.json();
|
|
199
|
+
console.log(`๐ฅ ${platform} OAuth response data:`, data);
|
|
505
200
|
|
|
506
|
-
//
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
console.log('โ
SUCCESS: Got refresh token after REVOKE + consent!');
|
|
512
|
-
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
201
|
+
// Extra logging for Gmail to help debug
|
|
202
|
+
if (platform === 'email') {
|
|
203
|
+
console.log('๐ Gmail OAuth response keys:', Object.keys(data));
|
|
204
|
+
console.log('๐ Gmail OAuth full response:', JSON.stringify(data, null, 2));
|
|
205
|
+
}
|
|
513
206
|
|
|
514
|
-
|
|
515
|
-
|
|
207
|
+
// Check if the response contains the OAuth URL based on platform
|
|
208
|
+
let oauthUrl = null;
|
|
209
|
+
switch (platform) {
|
|
210
|
+
case 'reddit':
|
|
211
|
+
oauthUrl = data.redditURL;
|
|
212
|
+
break;
|
|
213
|
+
case 'pinterest':
|
|
214
|
+
oauthUrl = data.pinterestURL;
|
|
215
|
+
break;
|
|
216
|
+
case 'youtube':
|
|
217
|
+
oauthUrl = data.youtubeURL;
|
|
218
|
+
break;
|
|
219
|
+
case 'email':
|
|
220
|
+
// Gmail might return under different field names
|
|
221
|
+
oauthUrl = data.emailURL || data.gmailURL || data.authUrl || data.url;
|
|
222
|
+
break;
|
|
223
|
+
default:
|
|
224
|
+
oauthUrl = data.url;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
if (!oauthUrl) {
|
|
228
|
+
console.error(`โ No OAuth URL found in response for ${platform}. Response:`, data);
|
|
229
|
+
throw new Error(`No OAuth URL found in response for ${platform}`);
|
|
230
|
+
}
|
|
231
|
+
console.log(`โ
${platform} OAuth URL received:`, oauthUrl);
|
|
516
232
|
|
|
517
|
-
|
|
233
|
+
// Validate the URL before returning
|
|
234
|
+
if (await validateOAuthUrl(oauthUrl)) {
|
|
235
|
+
return oauthUrl;
|
|
518
236
|
} else {
|
|
519
|
-
|
|
520
|
-
return false;
|
|
237
|
+
throw new Error(`Received invalid ${platform} OAuth URL`);
|
|
521
238
|
}
|
|
522
239
|
} catch (error) {
|
|
523
|
-
console.error(
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Fix YouTube connection for a specific user (like nicholase50)
|
|
530
|
-
*/
|
|
531
|
-
exports.forceYouTubeReconnectionWithRevoke = forceYouTubeReconnectionWithRevoke;
|
|
532
|
-
const fixUserYouTubeConnection = async username => {
|
|
533
|
-
console.log(`๐ง Fixing YouTube connection for user: ${username}`);
|
|
534
|
-
|
|
535
|
-
// Method 1: Try forced consent via configuration
|
|
536
|
-
console.log('๐ Method 1: Trying forced consent via configuration...');
|
|
537
|
-
let success = await forceYouTubeReconnectionWithConsent(username);
|
|
538
|
-
if (success) {
|
|
539
|
-
console.log(`โ
${username} YouTube connection fixed via Method 1!`);
|
|
540
|
-
return true;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
// Method 2: Try forced consent via revoke
|
|
544
|
-
console.log('๐ Method 2: Trying forced consent via revoke...');
|
|
545
|
-
success = await forceYouTubeReconnectionWithRevoke(username);
|
|
546
|
-
if (success) {
|
|
547
|
-
console.log(`โ
${username} YouTube connection fixed via Method 2!`);
|
|
548
|
-
return true;
|
|
240
|
+
console.error(`Error initiating OAuth for ${platform}:`, error);
|
|
241
|
+
throw error;
|
|
549
242
|
}
|
|
550
|
-
console.error(`โ Failed to fix ${username} YouTube connection with both methods`);
|
|
551
|
-
return false;
|
|
552
243
|
};
|
|
553
244
|
|
|
554
|
-
/**
|
|
555
|
-
*
|
|
245
|
+
/**
|
|
246
|
+
* Validates an OAuth URL to ensure it's reachable
|
|
247
|
+
* @param url The OAuth URL to validate
|
|
248
|
+
* @returns Promise<boolean> indicating if the URL is valid and reachable
|
|
556
249
|
*/
|
|
557
|
-
exports.
|
|
558
|
-
const
|
|
250
|
+
exports.initiateOAuth = initiateOAuth;
|
|
251
|
+
const validateOAuthUrl = async url => {
|
|
559
252
|
try {
|
|
560
|
-
console.log('
|
|
253
|
+
console.log('๐ Validating OAuth URL:', url);
|
|
561
254
|
|
|
562
|
-
//
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
return null;
|
|
255
|
+
// Basic URL format validation
|
|
256
|
+
if (!url || typeof url !== 'string') {
|
|
257
|
+
console.error('โ Invalid URL format:', url);
|
|
258
|
+
return false;
|
|
567
259
|
}
|
|
568
260
|
|
|
569
|
-
//
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
accessToken: tokens.accessToken,
|
|
574
|
-
idToken: tokens.idToken
|
|
575
|
-
};
|
|
576
|
-
} catch (error) {
|
|
577
|
-
console.error('โ Failed to refresh Google tokens:', error);
|
|
578
|
-
|
|
579
|
-
// If refresh fails, try to sign in again
|
|
580
|
-
try {
|
|
581
|
-
console.log('๐ Refresh failed, attempting re-authentication...');
|
|
582
|
-
const userInfo = await _googleSignin.GoogleSignin.signIn();
|
|
583
|
-
const tokens = await _googleSignin.GoogleSignin.getTokens();
|
|
584
|
-
console.log('โ
Re-authentication successful');
|
|
585
|
-
return {
|
|
586
|
-
accessToken: tokens.accessToken,
|
|
587
|
-
idToken: tokens.idToken
|
|
588
|
-
};
|
|
589
|
-
} catch (signInError) {
|
|
590
|
-
console.error('โ Re-authentication also failed:', signInError);
|
|
591
|
-
return null;
|
|
261
|
+
// Check if URL starts with https
|
|
262
|
+
if (!url.startsWith('https://')) {
|
|
263
|
+
console.error('โ URL must use HTTPS:', url);
|
|
264
|
+
return false;
|
|
592
265
|
}
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Debug YouTube tokens to verify refresh token availability
|
|
598
|
-
*/
|
|
599
|
-
const debugYouTubeTokens = async () => {
|
|
600
|
-
try {
|
|
601
|
-
var _currentUser$user;
|
|
602
|
-
const tokens = await _googleSignin.GoogleSignin.getTokens();
|
|
603
|
-
const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
|
|
604
|
-
console.log('๐ YouTube Token Debug:', {
|
|
605
|
-
accessToken: tokens.accessToken ? `${tokens.accessToken.substring(0, 20)}...` : 'Missing',
|
|
606
|
-
idToken: tokens.idToken ? 'Present' : 'Missing',
|
|
607
|
-
serverAuthCode: currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? `${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing',
|
|
608
|
-
userEmail: (currentUser === null || currentUser === void 0 || (_currentUser$user = currentUser.user) === null || _currentUser$user === void 0 ? void 0 : _currentUser$user.email) || 'Missing'
|
|
609
|
-
});
|
|
610
|
-
return {
|
|
611
|
-
hasRefreshToken: !!(currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode),
|
|
612
|
-
refreshTokenType: currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? 'serverAuthCode' : 'none'
|
|
613
|
-
};
|
|
614
|
-
} catch (error) {
|
|
615
|
-
console.error('โ Debug tokens failed:', error);
|
|
616
|
-
return {
|
|
617
|
-
hasRefreshToken: false,
|
|
618
|
-
refreshTokenType: 'error'
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
266
|
|
|
623
|
-
|
|
624
|
-
* Force fresh YouTube reconnection with proper refresh token
|
|
625
|
-
*/
|
|
626
|
-
const reconnectYouTube = async username => {
|
|
627
|
-
try {
|
|
628
|
-
console.log('๐ Forcing fresh YouTube reconnection for refresh token...');
|
|
629
|
-
|
|
630
|
-
// 1. Sign out completely to force fresh consent
|
|
267
|
+
// Try to parse the URL
|
|
631
268
|
try {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
269
|
+
new URL(url);
|
|
270
|
+
} catch (parseError) {
|
|
271
|
+
console.error('โ URL parsing failed:', parseError);
|
|
272
|
+
return false;
|
|
636
273
|
}
|
|
637
274
|
|
|
638
|
-
//
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
if (currentTokens.accessToken) {
|
|
642
|
-
await _googleSignin.GoogleSignin.clearCachedAccessToken(currentTokens.accessToken);
|
|
643
|
-
console.log('โ
Cleared cached access token');
|
|
644
|
-
}
|
|
645
|
-
} catch (clearError) {
|
|
646
|
-
console.log('โน๏ธ Token clearing failed or not needed:', clearError);
|
|
647
|
-
}
|
|
275
|
+
// Make a HEAD request to check if the URL is reachable
|
|
276
|
+
const controller = new AbortController();
|
|
277
|
+
const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
|
|
648
278
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
279
|
+
try {
|
|
280
|
+
const response = await fetch(url, {
|
|
281
|
+
method: 'HEAD',
|
|
282
|
+
signal: controller.signal
|
|
283
|
+
});
|
|
284
|
+
clearTimeout(timeoutId);
|
|
653
285
|
|
|
654
|
-
//
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
console.log('โ
Refresh token confirmed:', debugInfo.refreshTokenType);
|
|
658
|
-
} else {
|
|
659
|
-
console.warn('โ ๏ธ Still no refresh token after reconnection');
|
|
660
|
-
}
|
|
286
|
+
// Accept any response that's not a network error
|
|
287
|
+
// OAuth pages might return various status codes
|
|
288
|
+
console.log('โ
OAuth URL validation successful, status:', response.status);
|
|
661
289
|
return true;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
|
|
290
|
+
} catch (fetchError) {
|
|
291
|
+
clearTimeout(timeoutId);
|
|
292
|
+
if (fetchError.name === 'AbortError') {
|
|
293
|
+
console.warn('โ ๏ธ OAuth URL validation timeout, but proceeding anyway');
|
|
294
|
+
return true; // Allow timeout as URLs might be slow to respond
|
|
295
|
+
}
|
|
296
|
+
console.warn('โ ๏ธ OAuth URL validation failed, but proceeding anyway:', fetchError.message);
|
|
297
|
+
return true; // Allow network errors as they might be temporary
|
|
665
298
|
}
|
|
666
299
|
} catch (error) {
|
|
667
|
-
console.
|
|
668
|
-
return
|
|
300
|
+
console.warn('โ ๏ธ OAuth URL validation error, but proceeding anyway:', error);
|
|
301
|
+
return true; // Allow validation errors to not block the flow
|
|
669
302
|
}
|
|
670
303
|
};
|
|
671
304
|
|
|
672
|
-
/**
|
|
673
|
-
*
|
|
305
|
+
/**
|
|
306
|
+
* Initiates the native SDK authentication flow for a platform
|
|
307
|
+
* @param platform The platform to authenticate with
|
|
308
|
+
* @returns A Promise that resolves to the authentication result
|
|
674
309
|
*/
|
|
675
|
-
exports.reconnectYouTube = reconnectYouTube;
|
|
676
310
|
const initiateNativeAuth = async (platform, username) => {
|
|
677
311
|
if (platform === 'youtube') {
|
|
678
312
|
console.log('๐ Initiating native Google Sign-In for YouTube');
|
|
679
|
-
|
|
680
|
-
// Validate username for YouTube
|
|
681
|
-
if (!username || username.trim() === '') {
|
|
682
|
-
console.error('โ [YOUTUBE AUTH] Username is required for YouTube authentication');
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
313
|
try {
|
|
686
|
-
var
|
|
687
|
-
//
|
|
688
|
-
|
|
689
|
-
|
|
314
|
+
var _currentUser$user, _userInfo$user4, _userInfo$user6, _userInfo$user7, _userInfo$user8;
|
|
315
|
+
// Check if Google Sign-In package is available
|
|
316
|
+
let GoogleSignin, statusCodes;
|
|
317
|
+
try {
|
|
318
|
+
const googleSignInModule = require('@react-native-google-signin/google-signin');
|
|
319
|
+
GoogleSignin = googleSignInModule.GoogleSignin;
|
|
320
|
+
statusCodes = googleSignInModule.statusCodes;
|
|
321
|
+
} catch (importError) {
|
|
322
|
+
console.error('โ Google Sign-In package not available:', importError);
|
|
323
|
+
throw new Error('Google Sign-In SDK not installed. Please install @react-native-google-signin/google-signin');
|
|
324
|
+
}
|
|
690
325
|
|
|
691
|
-
//
|
|
692
|
-
|
|
326
|
+
// Configure Google Sign-In with better error handling
|
|
327
|
+
try {
|
|
328
|
+
const youtubeConfig = PLATFORM_AUTH_CONFIG.youtube;
|
|
329
|
+
const webClientId = youtubeConfig.clientId || '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
330
|
+
const iosClientId = youtubeConfig.iosClientId || webClientId;
|
|
331
|
+
await GoogleSignin.configure({
|
|
332
|
+
webClientId: webClientId,
|
|
333
|
+
iosClientId: iosClientId,
|
|
334
|
+
scopes: ['https://www.googleapis.com/auth/youtube.readonly'],
|
|
335
|
+
offlineAccess: true,
|
|
336
|
+
hostedDomain: '',
|
|
337
|
+
forceCodeForRefreshToken: true,
|
|
338
|
+
accountName: ''
|
|
339
|
+
});
|
|
340
|
+
console.log('โ
Google Sign-In configured successfully with client ID:', webClientId.substring(0, 20) + '...');
|
|
341
|
+
} catch (configError) {
|
|
342
|
+
console.error('โ Google Sign-In configuration failed:', configError);
|
|
343
|
+
throw new Error(`Google Sign-In configuration failed: ${configError.message || configError}`);
|
|
344
|
+
}
|
|
693
345
|
|
|
694
|
-
//
|
|
346
|
+
// Check if Google Play Services are available (Android only)
|
|
695
347
|
try {
|
|
696
|
-
await
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
console.log('
|
|
348
|
+
await GoogleSignin.hasPlayServices({
|
|
349
|
+
showPlayServicesUpdateDialog: true
|
|
350
|
+
});
|
|
351
|
+
console.log('โ
Google Play Services available');
|
|
352
|
+
} catch (playServicesError) {
|
|
353
|
+
console.error('โ Google Play Services error:', playServicesError);
|
|
354
|
+
throw new Error(`Google Play Services not available: ${playServicesError.message || playServicesError}`);
|
|
700
355
|
}
|
|
701
356
|
|
|
702
|
-
// Sign in with Google
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
357
|
+
// Sign in with Google
|
|
358
|
+
let userInfo;
|
|
359
|
+
try {
|
|
360
|
+
var _userInfo$user;
|
|
361
|
+
userInfo = await GoogleSignin.signIn();
|
|
362
|
+
console.log('โ
Google Sign-In successful:', (_userInfo$user = userInfo.user) === null || _userInfo$user === void 0 ? void 0 : _userInfo$user.email);
|
|
363
|
+
} catch (signInError) {
|
|
364
|
+
console.error('โ Google Sign-In failed:', signInError);
|
|
365
|
+
|
|
366
|
+
// Handle specific error codes
|
|
367
|
+
if (signInError.code === statusCodes.SIGN_IN_CANCELLED) {
|
|
368
|
+
throw new Error('Google Sign-In was cancelled by user');
|
|
369
|
+
} else if (signInError.code === statusCodes.IN_PROGRESS) {
|
|
370
|
+
throw new Error('Google Sign-In already in progress');
|
|
371
|
+
} else if (signInError.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
372
|
+
throw new Error('Google Play Services not available or outdated');
|
|
373
|
+
} else {
|
|
374
|
+
throw new Error(`Google Sign-In failed: ${signInError.message || signInError}`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
707
377
|
|
|
708
378
|
// Get access token for API calls
|
|
709
|
-
const tokens = await
|
|
379
|
+
const tokens = await GoogleSignin.getTokens();
|
|
710
380
|
console.log('๐ Got Google tokens');
|
|
711
|
-
console.log('๐ FULL tokens object:');
|
|
712
|
-
console.log(JSON.stringify(tokens, null, 2));
|
|
713
381
|
|
|
714
|
-
//
|
|
715
|
-
const currentUser = await
|
|
716
|
-
console.log('๐ค Current user info:', currentUser === null || currentUser === void 0 || (_currentUser$
|
|
717
|
-
console.log('๐ FULL currentUser object:');
|
|
718
|
-
console.log(JSON.stringify(currentUser, null, 2));
|
|
382
|
+
// Get current user info with refresh token
|
|
383
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
384
|
+
console.log('๐ค Current user info:', currentUser === null || currentUser === void 0 || (_currentUser$user = currentUser.user) === null || _currentUser$user === void 0 ? void 0 : _currentUser$user.email);
|
|
719
385
|
|
|
720
|
-
//
|
|
386
|
+
// Extract refresh token from server auth code
|
|
721
387
|
let refreshToken = null;
|
|
722
|
-
console.log('๐ REFRESH TOKEN EXTRACTION:');
|
|
723
|
-
console.log('- userInfo.data?.serverAuthCode:', (_userInfo$data16 = userInfo.data) !== null && _userInfo$data16 !== void 0 && _userInfo$data16.serverAuthCode ? `Present: ${userInfo.data.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
724
|
-
console.log('- currentUser?.serverAuthCode:', currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode ? `Present: ${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
725
|
-
console.log('- tokens.idToken:', tokens.idToken ? `Present: ${tokens.idToken.substring(0, 20)}...` : 'Missing');
|
|
726
|
-
console.log('- tokens.accessToken:', tokens.accessToken ? `Present: ${tokens.accessToken.substring(0, 20)}...` : 'Missing');
|
|
727
|
-
|
|
728
|
-
// The serverAuthCode is the refresh token mechanism for React Native Google Sign-In
|
|
729
388
|
if (currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode) {
|
|
389
|
+
console.log('๐ Server auth code available for refresh token');
|
|
730
390
|
refreshToken = currentUser.serverAuthCode;
|
|
731
|
-
console.log('โ
Got serverAuthCode (refresh token mechanism)');
|
|
732
|
-
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
733
|
-
} else if ((_userInfo$data17 = userInfo.data) !== null && _userInfo$data17 !== void 0 && _userInfo$data17.serverAuthCode) {
|
|
734
|
-
refreshToken = userInfo.data.serverAuthCode;
|
|
735
|
-
console.log('โ
Got serverAuthCode from sign-in response');
|
|
736
|
-
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
737
391
|
}
|
|
738
|
-
|
|
739
|
-
// โ
CRITICAL: Verify refresh token availability
|
|
740
392
|
if (!refreshToken) {
|
|
741
|
-
console.
|
|
742
|
-
console.error('๐ก User needs to reconnect with proper consent screen');
|
|
743
|
-
console.error('๐ก Check Google Sign-In configuration: offlineAccess, forceCodeForRefreshToken');
|
|
744
|
-
|
|
745
|
-
// Still continue but warn about the issue
|
|
746
|
-
console.warn('โ ๏ธ Continuing without refresh token - connection may fail later');
|
|
393
|
+
console.warn('โ ๏ธ No refresh token available - token refresh may fail later');
|
|
747
394
|
} else {
|
|
748
395
|
console.log('โ
Refresh token available for YouTube connection');
|
|
749
|
-
console.log('๐ Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
|
|
750
396
|
}
|
|
751
397
|
|
|
752
|
-
// Fetch YouTube channel information
|
|
398
|
+
// Fetch YouTube channel information
|
|
753
399
|
let channelName = 'Unknown Channel';
|
|
754
400
|
let channelId = null;
|
|
755
401
|
try {
|
|
@@ -765,60 +411,28 @@ const initiateNativeAuth = async (platform, username) => {
|
|
|
765
411
|
if (channelData.items && channelData.items.length > 0) {
|
|
766
412
|
channelName = channelData.items[0].snippet.title;
|
|
767
413
|
channelId = channelData.items[0].id;
|
|
768
|
-
console.log('โ
YouTube channel found:', channelName
|
|
769
|
-
} else {
|
|
770
|
-
var _userInfo$data18, _userInfo$data19;
|
|
771
|
-
console.log('โ ๏ธ No YouTube channel found for user');
|
|
772
|
-
channelName = ((_userInfo$data18 = userInfo.data) === null || _userInfo$data18 === void 0 || (_userInfo$data18 = _userInfo$data18.user) === null || _userInfo$data18 === void 0 ? void 0 : _userInfo$data18.name) || ((_userInfo$data19 = userInfo.data) === null || _userInfo$data19 === void 0 || (_userInfo$data19 = _userInfo$data19.user) === null || _userInfo$data19 === void 0 ? void 0 : _userInfo$data19.email) || 'No Channel';
|
|
414
|
+
console.log('โ
YouTube channel found:', channelName);
|
|
773
415
|
}
|
|
774
|
-
} else {
|
|
775
|
-
var _userInfo$data20, _userInfo$data21;
|
|
776
|
-
console.log('โ ๏ธ Failed to fetch YouTube channel info:', channelResponse.status);
|
|
777
|
-
channelName = ((_userInfo$data20 = userInfo.data) === null || _userInfo$data20 === void 0 || (_userInfo$data20 = _userInfo$data20.user) === null || _userInfo$data20 === void 0 ? void 0 : _userInfo$data20.name) || ((_userInfo$data21 = userInfo.data) === null || _userInfo$data21 === void 0 || (_userInfo$data21 = _userInfo$data21.user) === null || _userInfo$data21 === void 0 ? void 0 : _userInfo$data21.email) || 'Unknown Channel';
|
|
778
416
|
}
|
|
779
417
|
} catch (channelError) {
|
|
780
|
-
var _userInfo$
|
|
418
|
+
var _userInfo$user2, _userInfo$user3;
|
|
781
419
|
console.log('โ ๏ธ Error fetching YouTube channel info:', channelError);
|
|
782
|
-
channelName = ((_userInfo$
|
|
420
|
+
channelName = ((_userInfo$user2 = userInfo.user) === null || _userInfo$user2 === void 0 ? void 0 : _userInfo$user2.name) || ((_userInfo$user3 = userInfo.user) === null || _userInfo$user3 === void 0 ? void 0 : _userInfo$user3.email) || 'Unknown Channel';
|
|
783
421
|
}
|
|
784
422
|
|
|
785
|
-
// Get
|
|
423
|
+
// Get authentication info
|
|
786
424
|
let authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
787
425
|
const storedUsername = await _asyncStorage.default.getItem('onairos_username');
|
|
788
|
-
const finalUsername = storedUsername || username || ((_userInfo$
|
|
426
|
+
const finalUsername = storedUsername || username || ((_userInfo$user4 = userInfo.user) === null || _userInfo$user4 === void 0 ? void 0 : _userInfo$user4.email) || 'youtube_user';
|
|
789
427
|
|
|
790
|
-
//
|
|
428
|
+
// Create auth token if needed
|
|
791
429
|
if (!authToken || authToken.trim().length < 20) {
|
|
792
|
-
console.log('๐
|
|
430
|
+
console.log('๐ Creating authentication token for YouTube...');
|
|
793
431
|
try {
|
|
794
|
-
var _userInfo$
|
|
795
|
-
|
|
796
|
-
const fallbackEmail = ((_userInfo$data25 = userInfo.data) === null || _userInfo$data25 === void 0 || (_userInfo$data25 = _userInfo$data25.user) === null || _userInfo$data25 === void 0 ? void 0 : _userInfo$data25.email) || `${finalUsername}@youtube.temp`;
|
|
797
|
-
|
|
798
|
-
// Step 1: Create Enoch user first
|
|
799
|
-
console.log('๐ Step 1: Creating Enoch user for YouTube auth...');
|
|
800
|
-
try {
|
|
801
|
-
var _userInfo$data26;
|
|
802
|
-
const enochRegisterResponse = await fetch('https://api2.onairos.uk/enoch/users/register', {
|
|
803
|
-
method: 'POST',
|
|
804
|
-
headers: {
|
|
805
|
-
'Content-Type': 'application/json'
|
|
806
|
-
},
|
|
807
|
-
body: JSON.stringify({
|
|
808
|
-
email: fallbackEmail,
|
|
809
|
-
name: finalUsername,
|
|
810
|
-
photoUrl: ((_userInfo$data26 = userInfo.data) === null || _userInfo$data26 === void 0 || (_userInfo$data26 = _userInfo$data26.user) === null || _userInfo$data26 === void 0 ? void 0 : _userInfo$data26.photo) || ''
|
|
811
|
-
})
|
|
812
|
-
});
|
|
813
|
-
console.log('๐ก Enoch register response status:', enochRegisterResponse.status);
|
|
814
|
-
const enochResponseData = await enochRegisterResponse.json();
|
|
815
|
-
console.log('๐ Enoch user creation response:', enochResponseData);
|
|
816
|
-
} catch (enochError) {
|
|
817
|
-
console.warn('โ ๏ธ Enoch user creation failed (continuing):', enochError);
|
|
818
|
-
}
|
|
432
|
+
var _userInfo$user5;
|
|
433
|
+
const fallbackEmail = ((_userInfo$user5 = userInfo.user) === null || _userInfo$user5 === void 0 ? void 0 : _userInfo$user5.email) || `${finalUsername}@youtube.temp`;
|
|
819
434
|
|
|
820
|
-
//
|
|
821
|
-
console.log('๐ Step 2: Creating Onairos account for YouTube auth...');
|
|
435
|
+
// Create user accounts and get JWT token
|
|
822
436
|
const onairosSignupResponse = await fetch('https://api2.onairos.uk/register/enoch', {
|
|
823
437
|
method: 'POST',
|
|
824
438
|
headers: {
|
|
@@ -830,248 +444,255 @@ const initiateNativeAuth = async (platform, username) => {
|
|
|
830
444
|
name: finalUsername
|
|
831
445
|
})
|
|
832
446
|
});
|
|
833
|
-
console.log('๐ก Onairos register response status:', onairosSignupResponse.status);
|
|
834
447
|
if (onairosSignupResponse.ok) {
|
|
835
448
|
var _onairosResponseData$;
|
|
836
449
|
const onairosResponseData = await onairosSignupResponse.json();
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
if (onairosResponseData.token) {
|
|
841
|
-
authToken = onairosResponseData.token;
|
|
842
|
-
} else if ((_onairosResponseData$ = onairosResponseData.data) !== null && _onairosResponseData$ !== void 0 && _onairosResponseData$.token) {
|
|
843
|
-
authToken = onairosResponseData.data.token;
|
|
844
|
-
} else if (onairosResponseData.jwt) {
|
|
845
|
-
authToken = onairosResponseData.jwt;
|
|
846
|
-
}
|
|
450
|
+
|
|
451
|
+
// Extract token from response
|
|
452
|
+
authToken = onairosResponseData.token || ((_onairosResponseData$ = onairosResponseData.data) === null || _onairosResponseData$ === void 0 ? void 0 : _onairosResponseData$.token) || onairosResponseData.jwt;
|
|
847
453
|
if (authToken) {
|
|
848
|
-
// Store
|
|
454
|
+
// Store tokens
|
|
849
455
|
await _asyncStorage.default.setItem('onairos_jwt_token', authToken);
|
|
850
456
|
await _asyncStorage.default.setItem('enoch_token', authToken);
|
|
851
457
|
await _asyncStorage.default.setItem('auth_token', authToken);
|
|
852
458
|
await _asyncStorage.default.setItem('onairos_username', onairosResponseData.username || finalUsername);
|
|
853
|
-
console.log('โ
Successfully created and stored
|
|
854
|
-
console.log('๐ Enoch token preview:', `${authToken.substring(0, 20)}...`);
|
|
459
|
+
console.log('โ
Successfully created and stored authentication token');
|
|
855
460
|
}
|
|
856
|
-
} else {
|
|
857
|
-
const errorText = await onairosSignupResponse.text();
|
|
858
|
-
console.warn('โ ๏ธ Could not create Enoch auth token for YouTube:', errorText);
|
|
859
461
|
}
|
|
860
462
|
} catch (tokenError) {
|
|
861
|
-
console.warn('โ ๏ธ Error creating
|
|
862
|
-
// Continue without token - backend will handle gracefully
|
|
463
|
+
console.warn('โ ๏ธ Error creating auth token:', tokenError);
|
|
863
464
|
}
|
|
864
|
-
} else {
|
|
865
|
-
console.log('โ
Found existing authentication token for YouTube auth');
|
|
866
|
-
console.log('๐ Token preview:', `${authToken.substring(0, 20)}...`);
|
|
867
465
|
}
|
|
868
466
|
console.log('๐ Linking YouTube data to user:', finalUsername);
|
|
869
|
-
console.log('๐ Using auth token for linking:', authToken ? `${authToken.substring(0, 20)}...` : 'No token');
|
|
870
467
|
console.log('๐บ YouTube channel name:', channelName);
|
|
871
468
|
|
|
872
|
-
//
|
|
873
|
-
const backendPayload = {
|
|
874
|
-
session: {
|
|
875
|
-
username: finalUsername,
|
|
876
|
-
platform: 'youtube',
|
|
877
|
-
timestamp: new Date().toISOString(),
|
|
878
|
-
channelName: channelName,
|
|
879
|
-
channelId: channelId
|
|
880
|
-
},
|
|
881
|
-
googleUser: (_userInfo$data27 = userInfo.data) === null || _userInfo$data27 === void 0 ? void 0 : _userInfo$data27.user,
|
|
882
|
-
accessToken: tokens.accessToken,
|
|
883
|
-
idToken: tokens.idToken,
|
|
884
|
-
refreshToken: refreshToken,
|
|
885
|
-
// โ
CRITICAL: Include refresh token
|
|
886
|
-
serverAuthCode: refreshToken,
|
|
887
|
-
// โ
Alternative refresh mechanism (same as refreshToken)
|
|
888
|
-
|
|
889
|
-
// โ
CRITICAL: Additional compatibility fields for backend
|
|
890
|
-
refresh_token: refreshToken,
|
|
891
|
-
// Snake case version
|
|
892
|
-
server_auth_code: refreshToken,
|
|
893
|
-
// Snake case version
|
|
894
|
-
authCode: refreshToken,
|
|
895
|
-
// Alternative naming
|
|
896
|
-
|
|
897
|
-
// Include user account linking information
|
|
898
|
-
userAccountInfo: {
|
|
899
|
-
username: finalUsername,
|
|
900
|
-
email: (_userInfo$data28 = userInfo.data) === null || _userInfo$data28 === void 0 || (_userInfo$data28 = _userInfo$data28.user) === null || _userInfo$data28 === void 0 ? void 0 : _userInfo$data28.email,
|
|
901
|
-
authToken: authToken,
|
|
902
|
-
channelName: channelName,
|
|
903
|
-
channelId: channelId,
|
|
904
|
-
// CRITICAL: Include user identifier that matches your database
|
|
905
|
-
userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${(_userInfo$data29 = userInfo.data) === null || _userInfo$data29 === void 0 || (_userInfo$data29 = _userInfo$data29.user) === null || _userInfo$data29 === void 0 ? void 0 : _userInfo$data29.email}`,
|
|
906
|
-
googleId: (_userInfo$data30 = userInfo.data) === null || _userInfo$data30 === void 0 || (_userInfo$data30 = _userInfo$data30.user) === null || _userInfo$data30 === void 0 ? void 0 : _userInfo$data30.id,
|
|
907
|
-
appleUserId: (_authToken = authToken) !== null && _authToken !== void 0 && _authToken.includes('apple') ? authToken.split('.')[1] : null,
|
|
908
|
-
// โ
CRITICAL: Also include refresh token in userAccountInfo
|
|
909
|
-
refreshToken: refreshToken,
|
|
910
|
-
serverAuthCode: refreshToken
|
|
911
|
-
},
|
|
912
|
-
// Token expiry information
|
|
913
|
-
tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
|
|
914
|
-
// 1 hour from now
|
|
915
|
-
// Force refresh token request
|
|
916
|
-
requestRefreshToken: true,
|
|
917
|
-
// โ
CRITICAL: Debug information for backend
|
|
918
|
-
debugInfo: {
|
|
919
|
-
hasRefreshToken: !!refreshToken,
|
|
920
|
-
refreshTokenType: refreshToken ? refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken' : 'none',
|
|
921
|
-
configuredForRefresh: true,
|
|
922
|
-
forcedConsent: true,
|
|
923
|
-
refreshTokenValue: refreshToken // Include actual value for debugging
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
console.log('๐ค BACKEND PAYLOAD SUMMARY:');
|
|
927
|
-
console.log('- hasAccessToken:', !!backendPayload.accessToken);
|
|
928
|
-
console.log('- hasRefreshToken:', !!backendPayload.refreshToken);
|
|
929
|
-
console.log('- hasServerAuthCode:', !!backendPayload.serverAuthCode);
|
|
930
|
-
console.log('- refreshTokenType:', backendPayload.debugInfo.refreshTokenType);
|
|
931
|
-
console.log('- userEmail:', (_userInfo$data31 = userInfo.data) === null || _userInfo$data31 === void 0 || (_userInfo$data31 = _userInfo$data31.user) === null || _userInfo$data31 === void 0 ? void 0 : _userInfo$data31.email);
|
|
932
|
-
console.log('- channelName:', channelName);
|
|
933
|
-
console.log('๐ COMPLETE BACKEND PAYLOAD:');
|
|
934
|
-
console.log(JSON.stringify(backendPayload, null, 2));
|
|
935
|
-
|
|
936
|
-
// Send the tokens to your backend for YouTube data processing with ENHANCED LOGGING
|
|
937
|
-
console.log('๐ค Sending YouTube auth to backend with refresh token:', !!refreshToken);
|
|
469
|
+
// Send tokens to backend for YouTube data processing
|
|
938
470
|
const backendResponse = await fetch('https://api2.onairos.uk/youtube/native-auth', {
|
|
939
471
|
method: 'POST',
|
|
940
472
|
headers: {
|
|
941
473
|
'Content-Type': 'application/json',
|
|
942
474
|
...(authToken && {
|
|
943
|
-
'Authorization': authToken
|
|
944
|
-
})
|
|
475
|
+
'Authorization': `Bearer ${authToken}`
|
|
476
|
+
})
|
|
945
477
|
},
|
|
946
|
-
body: JSON.stringify(
|
|
478
|
+
body: JSON.stringify({
|
|
479
|
+
session: {
|
|
480
|
+
username: finalUsername,
|
|
481
|
+
platform: 'youtube',
|
|
482
|
+
timestamp: new Date().toISOString(),
|
|
483
|
+
channelName: channelName,
|
|
484
|
+
channelId: channelId
|
|
485
|
+
},
|
|
486
|
+
googleUser: userInfo.user,
|
|
487
|
+
accessToken: tokens.accessToken,
|
|
488
|
+
idToken: tokens.idToken,
|
|
489
|
+
refreshToken: refreshToken,
|
|
490
|
+
// CRITICAL: Include refresh token
|
|
491
|
+
serverAuthCode: currentUser === null || currentUser === void 0 ? void 0 : currentUser.serverAuthCode,
|
|
492
|
+
userAccountInfo: {
|
|
493
|
+
username: finalUsername,
|
|
494
|
+
email: (_userInfo$user6 = userInfo.user) === null || _userInfo$user6 === void 0 ? void 0 : _userInfo$user6.email,
|
|
495
|
+
authToken: authToken,
|
|
496
|
+
channelName: channelName,
|
|
497
|
+
channelId: channelId,
|
|
498
|
+
userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${(_userInfo$user7 = userInfo.user) === null || _userInfo$user7 === void 0 ? void 0 : _userInfo$user7.email}`,
|
|
499
|
+
googleId: (_userInfo$user8 = userInfo.user) === null || _userInfo$user8 === void 0 ? void 0 : _userInfo$user8.id
|
|
500
|
+
},
|
|
501
|
+
tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
|
|
502
|
+
// 1 hour from now
|
|
503
|
+
requestRefreshToken: true
|
|
504
|
+
})
|
|
947
505
|
});
|
|
948
|
-
console.log('๐ก Backend response status:', backendResponse.status);
|
|
949
|
-
console.log('๐ก Backend response headers:', backendResponse.headers);
|
|
950
506
|
if (backendResponse.ok) {
|
|
951
|
-
var _responseData$validat2, _responseData$tempora2;
|
|
952
507
|
const responseData = await backendResponse.json();
|
|
953
|
-
console.log('โ
YouTube connection
|
|
954
|
-
console.log('๐ COMPLETE BACKEND RESPONSE:');
|
|
955
|
-
console.log(JSON.stringify(responseData, null, 2));
|
|
956
|
-
|
|
957
|
-
// โ
Enhanced verification with temporary mode detection (exact backend fields)
|
|
958
|
-
const isTemporaryMode = ((_responseData$validat2 = responseData.validation) === null || _responseData$validat2 === void 0 ? void 0 : _responseData$validat2.isTemporaryMode) === true || ((_responseData$tempora2 = responseData.temporaryMode) === null || _responseData$tempora2 === void 0 ? void 0 : _responseData$tempora2.enabled) === true || responseData.isTemporaryMode === true || responseData.message && responseData.message.includes('temporary access token mode');
|
|
959
|
-
if (isTemporaryMode) {
|
|
960
|
-
console.log('๐ [YOUTUBE AUTH] YouTube connected in temporary mode');
|
|
961
|
-
console.log('โ
[YOUTUBE AUTH] Training will work, but connection expires in ~1 hour');
|
|
962
|
-
console.log('โน๏ธ [YOUTUBE AUTH] User can reconnect later for refresh tokens if needed');
|
|
963
|
-
} else if (responseData.hasRefreshToken || responseData.refreshTokenReceived) {
|
|
964
|
-
console.log('โ
[YOUTUBE AUTH] Backend confirmed refresh token received');
|
|
965
|
-
console.log('โ
[YOUTUBE AUTH] Full YouTube connection with persistent access');
|
|
966
|
-
} else {
|
|
967
|
-
console.warn('โ ๏ธ [YOUTUBE AUTH] Backend did not confirm refresh token');
|
|
968
|
-
console.warn('๐ [YOUTUBE AUTH] Response data keys:', Object.keys(responseData));
|
|
969
|
-
console.warn('โ ๏ธ [YOUTUBE AUTH] Connection may fail when tokens expire');
|
|
970
|
-
}
|
|
508
|
+
console.log('โ
YouTube connection processed by backend:', responseData);
|
|
971
509
|
return true;
|
|
972
510
|
} else {
|
|
973
511
|
const errorData = await backendResponse.text();
|
|
974
|
-
console.error('โ
|
|
975
|
-
console.error('๐ BACKEND ERROR RESPONSE:');
|
|
976
|
-
console.error(errorData);
|
|
512
|
+
console.error('โ Backend processing failed:', backendResponse.status, errorData);
|
|
977
513
|
return false;
|
|
978
514
|
}
|
|
979
515
|
} catch (error) {
|
|
980
516
|
console.error('โ Google Sign-In error:', error);
|
|
981
|
-
|
|
517
|
+
const {
|
|
518
|
+
statusCodes: StatusCodes
|
|
519
|
+
} = require('@react-native-google-signin/google-signin');
|
|
520
|
+
if (error.code === StatusCodes.SIGN_IN_CANCELLED) {
|
|
982
521
|
console.log('User cancelled Google Sign-In');
|
|
983
|
-
} else if (error.code ===
|
|
522
|
+
} else if (error.code === StatusCodes.IN_PROGRESS) {
|
|
984
523
|
console.log('Google Sign-In already in progress');
|
|
985
|
-
} else if (error.code ===
|
|
524
|
+
} else if (error.code === StatusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
986
525
|
console.log('Google Play Services not available');
|
|
987
526
|
}
|
|
988
527
|
return false;
|
|
989
528
|
}
|
|
990
529
|
}
|
|
991
|
-
|
|
992
|
-
// Instagram is commented out in the UI, but keeping the code for future use
|
|
993
|
-
if (platform === 'instagram') {
|
|
994
|
-
// Simulate Facebook Login SDK for Instagram
|
|
995
|
-
console.log('Initiating Facebook Login for Instagram');
|
|
996
|
-
return new Promise(resolve => {
|
|
997
|
-
setTimeout(() => {
|
|
998
|
-
console.log('Facebook Login completed successfully');
|
|
999
|
-
resolve(true);
|
|
1000
|
-
}, 1000);
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
530
|
return false;
|
|
1004
531
|
};
|
|
1005
532
|
|
|
1006
|
-
/**
|
|
1007
|
-
*
|
|
533
|
+
/**
|
|
534
|
+
* Handles the OAuth callback
|
|
535
|
+
* @param url The callback URL
|
|
536
|
+
* @returns The authorization code extracted from the URL
|
|
1008
537
|
*/
|
|
1009
538
|
exports.initiateNativeAuth = initiateNativeAuth;
|
|
539
|
+
const handleOAuthCallback = url => {
|
|
540
|
+
try {
|
|
541
|
+
// Parse the URL
|
|
542
|
+
const parsedUrl = new URL(url);
|
|
543
|
+
|
|
544
|
+
// Extract the authorization code
|
|
545
|
+
return parsedUrl.searchParams.get('code');
|
|
546
|
+
} catch (error) {
|
|
547
|
+
console.error('Error handling OAuth callback:', error);
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Checks if a URL is an OAuth callback
|
|
554
|
+
* @param url The URL to check
|
|
555
|
+
* @returns True if the URL is an OAuth callback
|
|
556
|
+
*/
|
|
557
|
+
exports.handleOAuthCallback = handleOAuthCallback;
|
|
1010
558
|
const isOAuthCallback = url => {
|
|
1011
|
-
|
|
559
|
+
// Check if the URL starts with our redirect URI
|
|
560
|
+
return url.startsWith('onairosanime://auth/');
|
|
1012
561
|
};
|
|
1013
562
|
|
|
1014
|
-
/**
|
|
1015
|
-
*
|
|
1016
|
-
* This would typically be done on a server, but we're simulating it here
|
|
563
|
+
/**
|
|
564
|
+
* Test connectivity to the Onairos API server
|
|
1017
565
|
*/
|
|
1018
566
|
exports.isOAuthCallback = isOAuthCallback;
|
|
1019
|
-
const
|
|
1020
|
-
console.log(`Exchanging code for token for platform: ${platform}`);
|
|
567
|
+
const testApiConnectivity = async () => {
|
|
1021
568
|
try {
|
|
1022
|
-
|
|
1023
|
-
const tokenUrl = `https://api2.onairos.uk/${platform}/token`;
|
|
569
|
+
console.log('๐ Testing connectivity to Onairos API...');
|
|
1024
570
|
|
|
1025
|
-
//
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
571
|
+
// Test multiple endpoints for better reliability
|
|
572
|
+
const testEndpoints = ['https://api2.onairos.uk/health', 'https://api2.onairos.uk' // Base URL
|
|
573
|
+
];
|
|
574
|
+
let lastError = null;
|
|
575
|
+
for (const endpoint of testEndpoints) {
|
|
576
|
+
try {
|
|
577
|
+
console.log(`๐ Testing endpoint: ${endpoint}`);
|
|
578
|
+
const controller = new AbortController();
|
|
579
|
+
const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
|
|
580
|
+
|
|
581
|
+
const response = await fetch(endpoint, {
|
|
582
|
+
method: 'GET',
|
|
583
|
+
headers: {
|
|
584
|
+
'Content-Type': 'application/json',
|
|
585
|
+
'User-Agent': 'OnairosReactNative/1.0'
|
|
586
|
+
},
|
|
587
|
+
signal: controller.signal
|
|
588
|
+
});
|
|
589
|
+
clearTimeout(timeoutId);
|
|
590
|
+
console.log(`๐ API connectivity test response for ${endpoint}:`, response.status);
|
|
591
|
+
if (response.ok || response.status === 404) {
|
|
592
|
+
// Accept 404 as it means the server is reachable
|
|
593
|
+
console.log('โ
API server is reachable');
|
|
594
|
+
return {
|
|
595
|
+
success: true
|
|
596
|
+
};
|
|
597
|
+
} else {
|
|
598
|
+
console.log(`โ ๏ธ API server responded with status ${response.status} for ${endpoint}`);
|
|
599
|
+
lastError = `API server error: ${response.status}`;
|
|
600
|
+
// Continue to next endpoint
|
|
601
|
+
}
|
|
602
|
+
} catch (fetchError) {
|
|
603
|
+
console.log(`โ Failed to reach ${endpoint}:`, fetchError);
|
|
604
|
+
if (fetchError.name === 'AbortError') {
|
|
605
|
+
lastError = 'Connection timeout - API server took too long to respond';
|
|
606
|
+
} else if (fetchError.message.includes('Network request failed')) {
|
|
607
|
+
lastError = 'Network error - check your internet connection';
|
|
608
|
+
} else if (fetchError.message.includes('not connected to the internet')) {
|
|
609
|
+
lastError = 'No internet connection';
|
|
610
|
+
} else {
|
|
611
|
+
lastError = `Network error: ${fetchError.message}`;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// Continue to next endpoint
|
|
615
|
+
}
|
|
1039
616
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
617
|
+
console.error('โ All API connectivity tests failed');
|
|
618
|
+
return {
|
|
619
|
+
success: false,
|
|
620
|
+
error: lastError || 'Cannot reach API server'
|
|
621
|
+
};
|
|
1043
622
|
} catch (error) {
|
|
1044
|
-
console.error(
|
|
623
|
+
console.error('โ API connectivity test failed:', error);
|
|
624
|
+
return {
|
|
625
|
+
success: false,
|
|
626
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
};
|
|
1045
630
|
|
|
1046
|
-
|
|
1047
|
-
|
|
631
|
+
/**
|
|
632
|
+
* ๐ REFRESH GOOGLE TOKENS
|
|
633
|
+
*/
|
|
634
|
+
exports.testApiConnectivity = testApiConnectivity;
|
|
635
|
+
const refreshGoogleTokens = async () => {
|
|
636
|
+
try {
|
|
637
|
+
console.log('๐ Attempting to refresh Google tokens...');
|
|
638
|
+
const {
|
|
639
|
+
GoogleSignin
|
|
640
|
+
} = require('@react-native-google-signin/google-signin');
|
|
641
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
642
|
+
if (!currentUser) {
|
|
643
|
+
console.log('โ User not signed in to Google, cannot refresh tokens');
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
const tokens = await GoogleSignin.getTokens();
|
|
647
|
+
console.log('โ
Successfully refreshed Google tokens');
|
|
1048
648
|
return {
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
expires_in: 3600
|
|
649
|
+
accessToken: tokens.accessToken,
|
|
650
|
+
idToken: tokens.idToken
|
|
1052
651
|
};
|
|
652
|
+
} catch (error) {
|
|
653
|
+
console.error('โ Failed to refresh Google tokens:', error);
|
|
654
|
+
|
|
655
|
+
// If refresh fails, try to sign in again
|
|
656
|
+
try {
|
|
657
|
+
console.log('๐ Refresh failed, attempting re-authentication...');
|
|
658
|
+
const {
|
|
659
|
+
GoogleSignin
|
|
660
|
+
} = require('@react-native-google-signin/google-signin');
|
|
661
|
+
const userInfo = await GoogleSignin.signIn();
|
|
662
|
+
const tokens = await GoogleSignin.getTokens();
|
|
663
|
+
console.log('โ
Re-authentication successful');
|
|
664
|
+
return {
|
|
665
|
+
accessToken: tokens.accessToken,
|
|
666
|
+
idToken: tokens.idToken
|
|
667
|
+
};
|
|
668
|
+
} catch (signInError) {
|
|
669
|
+
console.error('โ Re-authentication also failed:', signInError);
|
|
670
|
+
return null;
|
|
671
|
+
}
|
|
1053
672
|
}
|
|
1054
673
|
};
|
|
1055
674
|
|
|
1056
|
-
/**
|
|
1057
|
-
*
|
|
1058
|
-
* This should be called when the backend reports token expiry
|
|
675
|
+
/**
|
|
676
|
+
* ๐ REFRESH YOUTUBE TOKENS
|
|
1059
677
|
*/
|
|
1060
|
-
exports.
|
|
678
|
+
exports.refreshGoogleTokens = refreshGoogleTokens;
|
|
1061
679
|
const refreshYouTubeTokens = async () => {
|
|
1062
680
|
try {
|
|
1063
|
-
var _currentUser$
|
|
681
|
+
var _currentUser$user2;
|
|
1064
682
|
console.log('๐ Refreshing YouTube tokens...');
|
|
1065
683
|
|
|
1066
684
|
// Get fresh tokens from Google SDK
|
|
1067
|
-
const freshTokens = await
|
|
685
|
+
const freshTokens = await refreshGoogleTokens();
|
|
1068
686
|
if (!freshTokens) {
|
|
1069
687
|
console.error('โ Failed to get fresh tokens from Google SDK');
|
|
1070
688
|
return false;
|
|
1071
689
|
}
|
|
1072
690
|
|
|
1073
691
|
// Get current user info
|
|
1074
|
-
const
|
|
692
|
+
const {
|
|
693
|
+
GoogleSignin
|
|
694
|
+
} = require('@react-native-google-signin/google-signin');
|
|
695
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
1075
696
|
if (!currentUser) {
|
|
1076
697
|
console.error('โ No current Google user found');
|
|
1077
698
|
return false;
|
|
@@ -1089,15 +710,14 @@ const refreshYouTubeTokens = async () => {
|
|
|
1089
710
|
method: 'POST',
|
|
1090
711
|
headers: {
|
|
1091
712
|
'Content-Type': 'application/json',
|
|
1092
|
-
'Authorization': authToken
|
|
713
|
+
'Authorization': `Bearer ${authToken}`
|
|
1093
714
|
},
|
|
1094
715
|
body: JSON.stringify({
|
|
1095
716
|
accessToken: freshTokens.accessToken,
|
|
1096
717
|
idToken: freshTokens.idToken,
|
|
1097
718
|
refreshToken: currentUser.serverAuthCode,
|
|
1098
|
-
userEmail: (_currentUser$
|
|
719
|
+
userEmail: (_currentUser$user2 = currentUser.user) === null || _currentUser$user2 === void 0 ? void 0 : _currentUser$user2.email,
|
|
1099
720
|
tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(),
|
|
1100
|
-
// 1 hour from now
|
|
1101
721
|
timestamp: new Date().toISOString()
|
|
1102
722
|
})
|
|
1103
723
|
});
|
|
@@ -1116,186 +736,332 @@ const refreshYouTubeTokens = async () => {
|
|
|
1116
736
|
}
|
|
1117
737
|
};
|
|
1118
738
|
|
|
1119
|
-
/**
|
|
1120
|
-
*
|
|
1121
|
-
* This signals the backend to restart training with the new refresh token
|
|
739
|
+
/**
|
|
740
|
+
* ๐ฏ ENHANCED OAUTH CALLBACK HANDLER
|
|
1122
741
|
*/
|
|
1123
742
|
exports.refreshYouTubeTokens = refreshYouTubeTokens;
|
|
1124
|
-
const
|
|
743
|
+
const handleOAuthCallbackUrl = url => {
|
|
1125
744
|
try {
|
|
1126
|
-
console.log('
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
});
|
|
1141
|
-
if (response.ok) {
|
|
1142
|
-
const responseData = await response.json();
|
|
1143
|
-
console.log('โ
[TRAINING RESTART] Training restart successful:', responseData);
|
|
1144
|
-
} else {
|
|
1145
|
-
const errorData = await response.text();
|
|
1146
|
-
console.error('โ [TRAINING RESTART] Training restart failed:', response.status, errorData);
|
|
1147
|
-
throw new Error(`Training restart failed: ${response.status}`);
|
|
745
|
+
console.log('๐ Processing OAuth callback URL:', url);
|
|
746
|
+
|
|
747
|
+
// Parse the URL
|
|
748
|
+
const parsedUrl = new URL(url);
|
|
749
|
+
|
|
750
|
+
// Extract platform and code
|
|
751
|
+
const platform = parsedUrl.searchParams.get('platform') || parsedUrl.pathname.split('/').find(segment => ['instagram', 'youtube', 'reddit', 'pinterest', 'email'].includes(segment));
|
|
752
|
+
const code = parsedUrl.searchParams.get('code');
|
|
753
|
+
const error = parsedUrl.searchParams.get('error');
|
|
754
|
+
if (error) {
|
|
755
|
+
console.error('โ OAuth error in callback:', error);
|
|
756
|
+
return {
|
|
757
|
+
success: false
|
|
758
|
+
};
|
|
1148
759
|
}
|
|
760
|
+
if (code && platform) {
|
|
761
|
+
console.log(`โ
OAuth callback processed: ${platform} with code: ${code.substring(0, 10)}...`);
|
|
762
|
+
return {
|
|
763
|
+
platform,
|
|
764
|
+
code,
|
|
765
|
+
success: true
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
console.warn('โ ๏ธ OAuth callback missing platform or code');
|
|
769
|
+
return {
|
|
770
|
+
success: false
|
|
771
|
+
};
|
|
1149
772
|
} catch (error) {
|
|
1150
|
-
console.error('โ
|
|
1151
|
-
|
|
773
|
+
console.error('โ Error processing OAuth callback:', error);
|
|
774
|
+
return {
|
|
775
|
+
success: false
|
|
776
|
+
};
|
|
1152
777
|
}
|
|
1153
778
|
};
|
|
1154
779
|
|
|
1155
|
-
/**
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
780
|
+
/**
|
|
781
|
+
* ๐ง UPDATE GOOGLE CLIENT IDS
|
|
782
|
+
* Allows apps to configure their own Google client IDs
|
|
1158
783
|
*/
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
console.log('
|
|
1162
|
-
|
|
1163
|
-
//
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
console.log('๐ New token status:', newDebugInfo);
|
|
1173
|
-
} else {
|
|
1174
|
-
console.error('โ Failed to fix YouTube connection');
|
|
1175
|
-
}
|
|
1176
|
-
} else {
|
|
1177
|
-
console.log('โ
Refresh token already available');
|
|
1178
|
-
}
|
|
1179
|
-
} catch (error) {
|
|
1180
|
-
console.error('โ Error testing YouTube refresh token:', error);
|
|
784
|
+
exports.handleOAuthCallbackUrl = handleOAuthCallbackUrl;
|
|
785
|
+
const updateGoogleClientIds = config => {
|
|
786
|
+
console.log('๐ง Updating Google client IDs configuration');
|
|
787
|
+
if (config.webClientId || config.iosClientId) {
|
|
788
|
+
// Update the YouTube configuration
|
|
789
|
+
PLATFORM_AUTH_CONFIG.youtube = {
|
|
790
|
+
...PLATFORM_AUTH_CONFIG.youtube,
|
|
791
|
+
clientId: config.webClientId || PLATFORM_AUTH_CONFIG.youtube.clientId,
|
|
792
|
+
iosClientId: config.iosClientId || PLATFORM_AUTH_CONFIG.youtube.iosClientId
|
|
793
|
+
};
|
|
794
|
+
console.log('โ
Google client IDs updated successfully');
|
|
795
|
+
console.log(' - Web Client ID:', config.webClientId ? config.webClientId.substring(0, 20) + '...' : 'not provided');
|
|
796
|
+
console.log(' - iOS Client ID:', config.iosClientId ? config.iosClientId.substring(0, 20) + '...' : 'not provided');
|
|
1181
797
|
}
|
|
1182
798
|
};
|
|
1183
799
|
|
|
1184
|
-
/**
|
|
1185
|
-
* Request email verification
|
|
800
|
+
/**
|
|
801
|
+
* Request email verification using developer API key
|
|
802
|
+
* @param email Email address to verify
|
|
803
|
+
* @param testMode Whether to use test mode
|
|
804
|
+
* @returns Promise with verification result
|
|
1186
805
|
*/
|
|
1187
|
-
exports.
|
|
806
|
+
exports.updateGoogleClientIds = updateGoogleClientIds;
|
|
1188
807
|
const requestEmailVerification = async (email, testMode = false) => {
|
|
1189
808
|
try {
|
|
1190
809
|
console.log('๐ง Requesting email verification for:', email);
|
|
1191
|
-
const response = await
|
|
810
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)('/email/verification', {
|
|
1192
811
|
method: 'POST',
|
|
1193
|
-
headers: (0, _api.getApiHeaders)(),
|
|
1194
812
|
body: JSON.stringify({
|
|
1195
813
|
email,
|
|
1196
814
|
action: 'request',
|
|
1197
815
|
testMode
|
|
1198
816
|
})
|
|
1199
817
|
});
|
|
1200
|
-
const
|
|
1201
|
-
if (response.ok) {
|
|
818
|
+
const data = await response.json();
|
|
819
|
+
if (response.ok && data.success) {
|
|
820
|
+
console.log('โ
Email verification requested successfully');
|
|
1202
821
|
return {
|
|
1203
822
|
success: true,
|
|
1204
|
-
message:
|
|
823
|
+
message: data.message || 'Verification code sent to your email'
|
|
1205
824
|
};
|
|
1206
825
|
} else {
|
|
826
|
+
console.error('โ Email verification request failed:', data.error);
|
|
1207
827
|
return {
|
|
1208
828
|
success: false,
|
|
1209
|
-
error:
|
|
829
|
+
error: data.error || 'Failed to send verification code'
|
|
1210
830
|
};
|
|
1211
831
|
}
|
|
1212
832
|
} catch (error) {
|
|
1213
833
|
console.error('โ Error requesting email verification:', error);
|
|
1214
834
|
return {
|
|
1215
835
|
success: false,
|
|
1216
|
-
error:
|
|
836
|
+
error: error instanceof Error ? error.message : 'Network error'
|
|
1217
837
|
};
|
|
1218
838
|
}
|
|
1219
839
|
};
|
|
1220
840
|
|
|
1221
|
-
/**
|
|
1222
|
-
* Verify email code
|
|
841
|
+
/**
|
|
842
|
+
* Verify email code and store JWT token
|
|
843
|
+
* @param email Email address
|
|
844
|
+
* @param code Verification code
|
|
845
|
+
* @param testMode Whether to use test mode
|
|
846
|
+
* @returns Promise with verification result and JWT token
|
|
1223
847
|
*/
|
|
1224
848
|
exports.requestEmailVerification = requestEmailVerification;
|
|
1225
849
|
const verifyEmailCode = async (email, code, testMode = false) => {
|
|
1226
850
|
try {
|
|
1227
851
|
console.log('๐ Verifying email code for:', email);
|
|
1228
|
-
const response = await
|
|
852
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)('/email/verification', {
|
|
1229
853
|
method: 'POST',
|
|
1230
|
-
headers: (0, _api.getApiHeaders)(),
|
|
1231
854
|
body: JSON.stringify({
|
|
1232
855
|
email,
|
|
1233
|
-
code,
|
|
1234
856
|
action: 'verify',
|
|
857
|
+
code,
|
|
1235
858
|
testMode
|
|
1236
859
|
})
|
|
1237
860
|
});
|
|
1238
|
-
const
|
|
1239
|
-
if (response.ok) {
|
|
861
|
+
const data = await response.json();
|
|
862
|
+
if (response.ok && data.success) {
|
|
863
|
+
console.log('โ
Email verification successful');
|
|
864
|
+
|
|
865
|
+
// Store JWT token if received
|
|
866
|
+
if (data.token || data.jwtToken) {
|
|
867
|
+
const jwtToken = data.token || data.jwtToken;
|
|
868
|
+
await (0, _apiKeyService.storeJWT)(jwtToken);
|
|
869
|
+
console.log('๐ซ JWT token stored successfully');
|
|
870
|
+
}
|
|
1240
871
|
return {
|
|
1241
872
|
success: true,
|
|
1242
|
-
message:
|
|
1243
|
-
existingUser:
|
|
1244
|
-
token:
|
|
873
|
+
message: data.message || 'Email verified successfully',
|
|
874
|
+
existingUser: data.existingUser || false,
|
|
875
|
+
token: data.token || data.jwtToken
|
|
1245
876
|
};
|
|
1246
877
|
} else {
|
|
878
|
+
console.error('โ Email verification failed:', data.error);
|
|
1247
879
|
return {
|
|
1248
880
|
success: false,
|
|
1249
|
-
error:
|
|
881
|
+
error: data.error || 'Invalid verification code'
|
|
1250
882
|
};
|
|
1251
883
|
}
|
|
1252
884
|
} catch (error) {
|
|
1253
885
|
console.error('โ Error verifying email code:', error);
|
|
1254
886
|
return {
|
|
1255
887
|
success: false,
|
|
1256
|
-
error:
|
|
888
|
+
error: error instanceof Error ? error.message : 'Network error'
|
|
1257
889
|
};
|
|
1258
890
|
}
|
|
1259
891
|
};
|
|
1260
892
|
|
|
1261
|
-
/**
|
|
1262
|
-
* Check email verification status
|
|
893
|
+
/**
|
|
894
|
+
* Check email verification status
|
|
895
|
+
* @param email Email address
|
|
896
|
+
* @param testMode Whether to use test mode
|
|
897
|
+
* @returns Promise with status result
|
|
1263
898
|
*/
|
|
1264
899
|
exports.verifyEmailCode = verifyEmailCode;
|
|
1265
900
|
const checkEmailVerificationStatus = async (email, testMode = false) => {
|
|
1266
901
|
try {
|
|
1267
|
-
|
|
902
|
+
console.log('๐ Checking email verification status for:', email);
|
|
903
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)('/email/verification/status', {
|
|
1268
904
|
method: 'POST',
|
|
1269
|
-
headers: (0, _api.getApiHeaders)(),
|
|
1270
905
|
body: JSON.stringify({
|
|
1271
906
|
email,
|
|
1272
907
|
testMode
|
|
1273
908
|
})
|
|
1274
909
|
});
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
910
|
+
const data = await response.json();
|
|
911
|
+
if (response.ok && data.success) {
|
|
912
|
+
return {
|
|
913
|
+
success: true,
|
|
914
|
+
isPending: data.isPending || false
|
|
915
|
+
};
|
|
916
|
+
} else {
|
|
917
|
+
return {
|
|
918
|
+
success: false,
|
|
919
|
+
error: data.error || 'Failed to check verification status'
|
|
920
|
+
};
|
|
921
|
+
}
|
|
1281
922
|
} catch (error) {
|
|
1282
923
|
console.error('โ Error checking email verification status:', error);
|
|
1283
924
|
return {
|
|
1284
925
|
success: false,
|
|
1285
|
-
|
|
1286
|
-
error: 'Network error'
|
|
926
|
+
error: error instanceof Error ? error.message : 'Network error'
|
|
1287
927
|
};
|
|
1288
928
|
}
|
|
1289
929
|
};
|
|
1290
930
|
|
|
1291
|
-
/**
|
|
1292
|
-
*
|
|
931
|
+
/**
|
|
932
|
+
* Disconnect a platform (uses developer API key)
|
|
933
|
+
* @param platform Platform to disconnect
|
|
934
|
+
* @param username Username associated with the platform
|
|
935
|
+
* @returns Promise with disconnect result
|
|
1293
936
|
*/
|
|
1294
937
|
exports.checkEmailVerificationStatus = checkEmailVerificationStatus;
|
|
1295
|
-
const
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
938
|
+
const disconnectPlatform = async (platform, username) => {
|
|
939
|
+
try {
|
|
940
|
+
console.log('๐ Disconnecting platform:', platform, 'for user:', username);
|
|
941
|
+
|
|
942
|
+
// Make authenticated API call to disconnect platform
|
|
943
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)('/revoke', {
|
|
944
|
+
method: 'POST',
|
|
945
|
+
body: JSON.stringify({
|
|
946
|
+
platform,
|
|
947
|
+
username
|
|
948
|
+
})
|
|
949
|
+
});
|
|
950
|
+
const data = await response.json();
|
|
951
|
+
if (response.ok && data.success) {
|
|
952
|
+
console.log(`โ
${platform} disconnected successfully`);
|
|
953
|
+
return {
|
|
954
|
+
success: true
|
|
955
|
+
};
|
|
956
|
+
} else {
|
|
957
|
+
console.error(`โ Failed to disconnect ${platform}:`, data.error);
|
|
958
|
+
return {
|
|
959
|
+
success: false,
|
|
960
|
+
error: data.error || 'Failed to disconnect platform'
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
} catch (error) {
|
|
964
|
+
console.error(`โ Error disconnecting ${platform}:`, error);
|
|
965
|
+
return {
|
|
966
|
+
success: false,
|
|
967
|
+
error: error instanceof Error ? error.message : 'Network error'
|
|
968
|
+
};
|
|
969
|
+
}
|
|
1299
970
|
};
|
|
1300
|
-
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Store PIN for user (uses JWT authentication and extracts username from JWT)
|
|
974
|
+
* @param pin User PIN
|
|
975
|
+
* @param username Optional username (if not provided, extracts from JWT)
|
|
976
|
+
* @returns Promise with result
|
|
977
|
+
*/
|
|
978
|
+
exports.disconnectPlatform = disconnectPlatform;
|
|
979
|
+
const storePIN = async (pin, username) => {
|
|
980
|
+
try {
|
|
981
|
+
// Extract username from JWT if not provided
|
|
982
|
+
const userToStore = username || (0, _apiKeyService.extractUsernameFromJWT)();
|
|
983
|
+
if (!userToStore) {
|
|
984
|
+
console.error('โ No username available - either provide username or ensure JWT token is valid');
|
|
985
|
+
return {
|
|
986
|
+
success: false,
|
|
987
|
+
error: 'No username available for PIN storage'
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
console.log('๐ Storing PIN for user:', userToStore);
|
|
991
|
+
|
|
992
|
+
// Make authenticated request to store PIN (using developer API key for now)
|
|
993
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)('/store-pin/web', {
|
|
994
|
+
method: 'POST',
|
|
995
|
+
headers: {
|
|
996
|
+
'Content-Type': 'application/json'
|
|
997
|
+
},
|
|
998
|
+
body: JSON.stringify({
|
|
999
|
+
username: userToStore,
|
|
1000
|
+
pin
|
|
1001
|
+
})
|
|
1002
|
+
});
|
|
1003
|
+
const data = await response.json();
|
|
1004
|
+
if (response.ok && data.success) {
|
|
1005
|
+
console.log('โ
PIN stored successfully for user:', userToStore);
|
|
1006
|
+
return {
|
|
1007
|
+
success: true
|
|
1008
|
+
};
|
|
1009
|
+
} else {
|
|
1010
|
+
console.error('โ Failed to store PIN:', data.error);
|
|
1011
|
+
return {
|
|
1012
|
+
success: false,
|
|
1013
|
+
error: data.error || 'Failed to store PIN'
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
} catch (error) {
|
|
1017
|
+
console.error('โ Error storing PIN:', error);
|
|
1018
|
+
return {
|
|
1019
|
+
success: false,
|
|
1020
|
+
error: error instanceof Error ? error.message : 'Network error'
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* ๐ซ GET STORED JWT TOKEN
|
|
1027
|
+
* Helper function to retrieve stored JWT token from email verification or other sources
|
|
1028
|
+
*/
|
|
1029
|
+
exports.storePIN = storePIN;
|
|
1030
|
+
const getStoredJwtToken = async () => {
|
|
1031
|
+
try {
|
|
1032
|
+
console.log('๐ซ Retrieving stored JWT token...');
|
|
1033
|
+
|
|
1034
|
+
// Try different storage keys in order of preference
|
|
1035
|
+
const tokenSources = ['email_verification_token', 'onairos_jwt_token', 'enoch_token', 'auth_token'];
|
|
1036
|
+
for (const source of tokenSources) {
|
|
1037
|
+
const token = await _asyncStorage.default.getItem(source);
|
|
1038
|
+
if (token && token.length > 20) {
|
|
1039
|
+
console.log(`โ
JWT token found in ${source}:`, token.substring(0, 20) + '...');
|
|
1040
|
+
return token;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
console.warn('โ ๏ธ No JWT token found in storage');
|
|
1044
|
+
return null;
|
|
1045
|
+
} catch (error) {
|
|
1046
|
+
console.error('โ Error retrieving JWT token:', error);
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* ๐ซ CLEAR STORED TOKENS
|
|
1053
|
+
* Helper function to clear all stored tokens (useful for logout)
|
|
1054
|
+
*/
|
|
1055
|
+
exports.getStoredJwtToken = getStoredJwtToken;
|
|
1056
|
+
const clearStoredTokens = async () => {
|
|
1057
|
+
try {
|
|
1058
|
+
console.log('๐งน Clearing all stored tokens...');
|
|
1059
|
+
const tokenKeys = ['email_verification_token', 'onairos_jwt_token', 'enoch_token', 'auth_token', 'email_verification_email', 'email_verification_request_id', 'email_verification_request_email', 'token_timestamp', 'user_pin_stored', 'pin_storage_timestamp'];
|
|
1060
|
+
await Promise.all(tokenKeys.map(key => _asyncStorage.default.removeItem(key)));
|
|
1061
|
+
console.log('โ
All tokens cleared successfully');
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
console.error('โ Error clearing tokens:', error);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
exports.clearStoredTokens = clearStoredTokens;
|
|
1301
1067
|
//# sourceMappingURL=platformAuthService.js.map
|