Skip to content

Commit

Permalink
chore: temporary disable twitter auth (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-orion authored Jun 23, 2023
1 parent e3c7a6a commit 59f5546
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 87 deletions.
14 changes: 0 additions & 14 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,6 @@ PODS:
- RCTTypeSafety
- React-Core
- ReactCommon/turbomodule/core
- react-native-twitter-signin (1.2.0):
- React
- TwitterKit5
- react-native-view-shot (3.6.0):
- React-Core
- React-perflogger (0.70.8)
Expand Down Expand Up @@ -732,9 +729,6 @@ PODS:
- SentryPrivate (8.7.3)
- SocketRocket (0.6.0)
- TOCropViewController (2.6.1)
- TwitterCore (3.2.0)
- TwitterKit5 (5.2.0):
- TwitterCore (>= 3.1.0)
- vision-camera-code-scanner (0.2.0):
- GoogleMLKit/BarcodeScanning
- React-Core
Expand Down Expand Up @@ -811,7 +805,6 @@ DEPENDENCIES:
- react-native-pager-view (from `../node_modules/react-native-pager-view`)
- react-native-restart (from `../node_modules/react-native-restart`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- "react-native-twitter-signin (from `../node_modules/@react-native-twitter-signin/twitter-signin`)"
- react-native-view-shot (from `../node_modules/react-native-view-shot`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
Expand Down Expand Up @@ -910,8 +903,6 @@ SPEC REPOS:
- SentryPrivate
- SocketRocket
- TOCropViewController
- TwitterCore
- TwitterKit5
- YogaKit

EXTERNAL SOURCES:
Expand Down Expand Up @@ -983,8 +974,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-restart"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-twitter-signin:
:path: "../node_modules/@react-native-twitter-signin/twitter-signin"
react-native-view-shot:
:path: "../node_modules/react-native-view-shot"
React-perflogger:
Expand Down Expand Up @@ -1155,7 +1144,6 @@ SPEC CHECKSUMS:
react-native-pager-view: 3c66c4e2f3ab423643d07b2c7041f8ac48395f72
react-native-restart: 7595693413fe3ca15893702f2c8306c62a708162
react-native-safe-area-context: 99b24a0c5acd0d5dcac2b1a7f18c49ea317be99a
react-native-twitter-signin: 423e8d20eb26fddc14852d3f1435a8b39358f49d
react-native-view-shot: 705f999ac2a24e4e6c909c0ca65c732ed33ca2ff
React-perflogger: e9249a18e055cae96fdf685bf6145cbea62506c8
React-RCTActionSheet: a6d2a544a4605a111ce80fa9319cc870ca3ea778
Expand Down Expand Up @@ -1200,8 +1188,6 @@ SPEC CHECKSUMS:
SentryPrivate: 2eaabf598a46d4b9b8822aef766df2a84caf2e6f
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
TwitterCore: 8cbc9ad34d91c63a0035ea05bfbfc0d7ca72a28c
TwitterKit5: 64095dfefcf39be2355711ef27112d55e340d90e
vision-camera-code-scanner: dda884a7f3ec8243a2a6d6489b91860648371bca
VisionCamera: e9a95af10e00aaebe99d648ff4519fd336e16ffe
Yoga: d6133108734e69e8c0becc6ba587294b94829687
Expand Down
5 changes: 0 additions & 5 deletions ios/ice/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import <Firebase.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#import <FBSDKCoreKit/FBSDKCoreKit-swift.h>
#import <TwitterKit/TWTRKit.h>
#import <React/RCTLinkingManager.h>

#import <RNBootSplash/RNBootSplash.h>
Expand Down Expand Up @@ -148,10 +147,6 @@ - (BOOL)application:(UIApplication *)application
return YES;
}

if ([[Twitter sharedInstance] application:application openURL:url options:options]) {
return YES;
}

if ([RCTLinkingManager application:application openURL:url options:options]) {
return YES;
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@react-native-firebase/messaging": "^16.4.6",
"@react-native-google-signin/google-signin": "^8.2.1",
"@react-native-masked-view/masked-view": "^0.2.8",
"@react-native-twitter-signin/twitter-signin": "^1.2.0",
"@react-navigation/bottom-tabs": "^6.4.1",
"@react-navigation/native": "^6.0.14",
"@react-navigation/native-stack": "^6.9.2",
Expand Down
7 changes: 0 additions & 7 deletions src/services/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ export const signInWithApple = async () => {

export const signInWithTwitter = async () => {
const result = await startTwitterSignIn();
if (!result.cancelled) {
const twitterCredential = auth.TwitterAuthProvider.credential(
result.data.token,
result.data.secret,
);
await auth().signInWithCredential(twitterCredential);
}
return result;
};

Expand Down
57 changes: 2 additions & 55 deletions src/services/auth/signin/twitter.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,5 @@
// SPDX-License-Identifier: ice License 1.0

import {ENV} from '@constants/env';
import RNTwitterSignIn from '@react-native-twitter-signin/twitter-signin';
import {SocialSignInMethod} from '@services/auth/signin/types';
import {checkProp} from '@utils/guards';
import {removeInvalidUsernameCharacters} from '@utils/username';

RNTwitterSignIn.init(
ENV.TWITTER_CONSUMER_KEY ?? '',
ENV.TWITTER_CONSUMER_SECRET ?? '',
);

export const startTwitterSignIn: SocialSignInMethod<{
token: string;
secret: string;
}> = async () => {
try {
// TODO:: create a patch for @react-native-twitter-signin/twitter-signin
// the patch should add a request to @"https://api.twitter.com/1.1/users/lookup.json" to get the user.name
// on iOS [client sendTwitterRequest] might be used
const {authToken, authTokenSecret, userName, email} =
await RNTwitterSignIn.logIn();
if (!authToken || !authTokenSecret) {
throw new Error(
'Twitter Sign-In failed - no authToken or authTokenSecret returned',
);
}
return {
cancelled: false,
data: {
token: authToken,
secret: authTokenSecret,
},
userInfo: {
userHandle: removeInvalidUsernameCharacters(
userName ?? email?.split('@')[0] ?? '',
),
firstName: null,
lastName: null,
},
};
} catch (error) {
if (
// Android
(checkProp(error, 'code') && error.code === 'USER_CANCELLED') ||
// iOS
(checkProp(error, 'userInfo') &&
checkProp(error.userInfo, 'NSLocalizedDescription') &&
error.userInfo.NSLocalizedDescription === 'User cancelled login flow.')
) {
return {
cancelled: true,
};
}
throw error;
}
export const startTwitterSignIn = () => {
throw new Error('Temporary disabled');
};
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1624,11 +1624,6 @@
resolved "https://registry.yarnpkg.com/@react-native-masked-view/masked-view/-/masked-view-0.2.8.tgz#34405a4361882dae7c81b1b771fe9f5fbd545a97"
integrity sha512-+1holBPDF1yi/y0uc1WB6lA5tSNHhM7PpTMapT3ypvSnKQ9+C6sy/zfjxNxRA/llBQ1Ci6f94EaK56UCKs5lTA==

"@react-native-twitter-signin/twitter-signin@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@react-native-twitter-signin/twitter-signin/-/twitter-signin-1.2.0.tgz#37f050a544f97fb2cc28d039dc0d568ea1a806e8"
integrity sha512-varhgZUxCyN6mhdjhoRixUmtVSVpI1jkHQSHgOVt9v+YIdHYx85Dtd/gfYIo1MRVMbh+hz3veiT5xTzil7Dbzg==

"@react-native/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e"
Expand Down

0 comments on commit 59f5546

Please sign in to comment.