From 7bdbf803ea2ff5d65dec224c4f0d82b49766d11a Mon Sep 17 00:00:00 2001 From: ~latter-bolden Date: Wed, 13 Mar 2024 15:39:31 -0400 Subject: [PATCH] mobile: rip out useDevTools development auth in favor of new setup --- apps/tlon-mobile/app.config.ts | 2 - .../ios/Landscape.xcodeproj/project.pbxproj | 22 +++++++--- apps/tlon-mobile/ios/Podfile.lock | 2 +- apps/tlon-mobile/src/App.tsx | 3 -- .../src/components/SingletonWebview.tsx | 5 ++- apps/tlon-mobile/src/constants.ts | 3 -- apps/tlon-mobile/src/lib/useDevTools.ts | 44 ------------------- 7 files changed, 21 insertions(+), 60 deletions(-) delete mode 100644 apps/tlon-mobile/src/lib/useDevTools.ts diff --git a/apps/tlon-mobile/app.config.ts b/apps/tlon-mobile/app.config.ts index efe1f1d77a..b37cfba299 100644 --- a/apps/tlon-mobile/app.config.ts +++ b/apps/tlon-mobile/app.config.ts @@ -29,8 +29,6 @@ export default ({ config }: ConfigContext): ExpoConfig => ({ defaultShipLoginAccessCode: process.env.DEFAULT_SHIP_LOGIN_ACCESS_CODE, recaptchaSiteKeyAndroid: process.env.RECAPTCHA_SITE_KEY_ANDROID, recaptchaSiteKeyIOS: process.env.RECAPTCHA_SITE_KEY_IOS, - devLocal: Boolean(process.env.DEV_LOCAL), - devLocalCode: process.env.DEV_LOCAL_CODE, }, ios: { runtimeVersion: '4.0.0', diff --git a/apps/tlon-mobile/ios/Landscape.xcodeproj/project.pbxproj b/apps/tlon-mobile/ios/Landscape.xcodeproj/project.pbxproj index 827cc5dae9..a3eaa6fc2d 100644 --- a/apps/tlon-mobile/ios/Landscape.xcodeproj/project.pbxproj +++ b/apps/tlon-mobile/ios/Landscape.xcodeproj/project.pbxproj @@ -482,7 +482,7 @@ mainGroup = 83CBB9F61A601CBA00E9B192; packageReferences = ( 70A62C5F2A5A6B1A00EBED16 /* XCRemoteSwiftPackageReference "SimpleKeychain" */, - 70D386462A6098F800AFB46E /* XCRemoteSwiftPackageReference "Alamofire.git" */, + 70D386462A6098F800AFB46E /* XCRemoteSwiftPackageReference "Alamofire" */, 70D3866D2A60A3B300AFB46E /* XCRemoteSwiftPackageReference "UrsusSigil" */, ); productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; @@ -1221,6 +1221,12 @@ " ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", " ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", " ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", ); IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1330,6 +1336,12 @@ " ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", " ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", " ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", + " ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", ); IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1398,7 +1410,7 @@ minimumVersion = 1.0.0; }; }; - 70D386462A6098F800AFB46E /* XCRemoteSwiftPackageReference "Alamofire.git" */ = { + 70D386462A6098F800AFB46E /* XCRemoteSwiftPackageReference "Alamofire" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Alamofire/Alamofire.git"; requirement = { @@ -1422,7 +1434,7 @@ minimumVersion = 1.0.0; }; }; - 70DBBFE32B7C60B50021EA96 /* XCRemoteSwiftPackageReference "Alamofire.git" */ = { + 70DBBFE32B7C60B50021EA96 /* XCRemoteSwiftPackageReference "Alamofire" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Alamofire/Alamofire.git"; requirement = { @@ -1448,7 +1460,7 @@ }; 70D386472A6098F800AFB46E /* Alamofire */ = { isa = XCSwiftPackageProductDependency; - package = 70D386462A6098F800AFB46E /* XCRemoteSwiftPackageReference "Alamofire.git" */; + package = 70D386462A6098F800AFB46E /* XCRemoteSwiftPackageReference "Alamofire" */; productName = Alamofire; }; 70D3866E2A60A3B300AFB46E /* UrsusSigil */ = { @@ -1463,7 +1475,7 @@ }; 70DBBFE22B7C60B50021EA96 /* Alamofire */ = { isa = XCSwiftPackageProductDependency; - package = 70DBBFE32B7C60B50021EA96 /* XCRemoteSwiftPackageReference "Alamofire.git" */; + package = 70DBBFE32B7C60B50021EA96 /* XCRemoteSwiftPackageReference "Alamofire" */; productName = Alamofire; }; 70DBBFE42B7C60B50021EA96 /* UrsusSigil */ = { diff --git a/apps/tlon-mobile/ios/Podfile.lock b/apps/tlon-mobile/ios/Podfile.lock index 345c0c5abb..01efc90c86 100644 --- a/apps/tlon-mobile/ios/Podfile.lock +++ b/apps/tlon-mobile/ios/Podfile.lock @@ -1682,7 +1682,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 sqlite3: f163dbbb7aa3339ad8fc622782c2d9d7b72f7e9c UMAppLoader: 5df85360d65cabaef544be5424ac64672e648482 - Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 + Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: 82da24eb176d4abdeaf445b3581717ec492dd7e8 diff --git a/apps/tlon-mobile/src/App.tsx b/apps/tlon-mobile/src/App.tsx index 49507f8823..6fb18e7047 100644 --- a/apps/tlon-mobile/src/App.tsx +++ b/apps/tlon-mobile/src/App.tsx @@ -16,7 +16,6 @@ import { SafeAreaProvider } from 'react-native-safe-area-context'; import { useTailwind } from 'tailwind-rn'; import { LoadingSpinner } from './components/LoadingSpinner'; -import { DEV_LOCAL, DEV_LOCAL_CODE } from './constants'; import { ShipProvider, useShip } from './contexts/ship'; import * as db from './db'; import { useDeepLink } from './hooks/useDeepLink'; @@ -24,7 +23,6 @@ import { useIsDarkMode } from './hooks/useIsDarkMode'; import { useScreenOptions } from './hooks/useScreenOptions'; import { inviteShipWithLure } from './lib/hostingApi'; import { syncContacts } from './lib/sync'; -import { useDevTools } from './lib/useDevTools'; import { TabStack } from './navigation/TabStack'; import { CheckVerifyScreen } from './screens/CheckVerifyScreen'; import { EULAScreen } from './screens/EULAScreen'; @@ -51,7 +49,6 @@ type Props = { const OnboardingStack = createNativeStackNavigator(); const App = ({ wer: initialWer }: Props) => { - useDevTools({ enabled: DEV_LOCAL, localCode: DEV_LOCAL_CODE }); const isDarkMode = useIsDarkMode(); const tailwind = useTailwind(); const { isLoading, isAuthenticated, ship } = useShip(); diff --git a/apps/tlon-mobile/src/components/SingletonWebview.tsx b/apps/tlon-mobile/src/components/SingletonWebview.tsx index a4949ea038..4a4f8ce0d7 100644 --- a/apps/tlon-mobile/src/components/SingletonWebview.tsx +++ b/apps/tlon-mobile/src/components/SingletonWebview.tsx @@ -14,7 +14,7 @@ import { URL } from 'react-native-url-polyfill'; import { WebView } from 'react-native-webview'; import { useTailwind } from 'tailwind-rn'; -import { DEV_LOCAL } from '../constants'; +import { DEFAULT_SHIP_LOGIN_URL, DEFAULT_TLON_LOGIN_EMAIL } from '../constants'; import { useShip } from '../contexts/ship'; import { useWebViewContext } from '../contexts/webview/webview'; import { useWebView } from '../hooks/useWebView'; @@ -212,7 +212,8 @@ export const SingletonWebview = () => { window.colorscheme="${nativeOptions.colorScheme}"; window.safeAreaInsets=${JSON.stringify(nativeOptions.safeAreaInsets)}; ${ - DEV_LOCAL + // in development, explicitly set Urbit runtime configured window vars + DEFAULT_SHIP_LOGIN_URL || DEFAULT_TLON_LOGIN_EMAIL ? ` window.our="${ship}"; window.ship="${ship?.slice(1)}"; ` : '' } diff --git a/apps/tlon-mobile/src/constants.ts b/apps/tlon-mobile/src/constants.ts index 4ec0f146b7..a5a9801f0f 100644 --- a/apps/tlon-mobile/src/constants.ts +++ b/apps/tlon-mobile/src/constants.ts @@ -32,6 +32,3 @@ export const DEFAULT_TLON_LOGIN_PASSWORD = extra.defaultTlonLoginPassword ?? ''; export const DEFAULT_SHIP_LOGIN_URL = extra.defaultShipLoginUrl ?? ''; export const DEFAULT_SHIP_LOGIN_ACCESS_CODE = extra.defaultShipLoginAccessCode ?? ''; - -export const DEV_LOCAL = extra.devLocal ? Boolean(extra.devLocal) : false; -export const DEV_LOCAL_CODE = extra.devLocalCode ?? ''; diff --git a/apps/tlon-mobile/src/lib/useDevTools.ts b/apps/tlon-mobile/src/lib/useDevTools.ts deleted file mode 100644 index d6130e353a..0000000000 --- a/apps/tlon-mobile/src/lib/useDevTools.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { useEffect } from 'react'; - -import { useShip } from '../contexts/ship'; -import { getShipFromCookie } from '../utils/ship'; -import { getLandscapeAuthCookie } from './landscapeApi'; - -const DEV_SHIP_URL = 'http://localhost:3000'; - -export function useDevTools(config: { enabled: boolean; localCode: string }) { - const { setShip, clearShip } = useShip(); - - // For use with local development. If the env vars DEV_LOCAL and DEV_LOCAL_CODE are set, - // will attempt to automatically authenticate you to the tlon-web dev server - useEffect(() => { - async function setupDevAuth() { - let cookie = null; - try { - cookie = await getLandscapeAuthCookie(DEV_SHIP_URL, config.localCode); - } catch (e) { - console.error('Error getting development auth cookie:', e); - } - - if (cookie) { - const ship = getShipFromCookie(cookie); - setShip({ - ship, - shipUrl: DEV_SHIP_URL, - }); - console.log(`Development auth configured for ${ship}`); - } else { - console.warn('Failed to set up development auth'); - clearShip(); - } - } - - if (config.enabled) { - if (!config.localCode) { - console.warn('No code found, skipping development auth'); - return; - } - setupDevAuth(); - } - }, []); -}