From bc67bdb5b1237756b6429505f5503d6dfee940e9 Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 12 Apr 2024 09:20:07 -0700 Subject: [PATCH] rm some useless code --- src/lib/oauth.ts | 12 +----------- src/screens/Login/hooks/useLogin.ts | 18 ++++++------------ 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/lib/oauth.ts b/src/lib/oauth.ts index d1152a6e6f..391ca85059 100644 --- a/src/lib/oauth.ts +++ b/src/lib/oauth.ts @@ -1,7 +1,7 @@ import {isWeb} from 'platform/detection' export const OAUTH_CLIENT_ID = 'http://localhost/' -export const OAUTH_REDIRECT_URI = 'http://127.0.0.1:5173/' +export const OAUTH_REDIRECT_URI = 'http://127.0.0.1:2583/' export const OAUTH_SCOPE = 'openid profile email phone offline_access' export const OAUTH_GRANT_TYPES = [ 'authorization_code', @@ -10,13 +10,3 @@ export const OAUTH_GRANT_TYPES = [ export const OAUTH_RESPONSE_TYPES = ['code', 'code id_token'] as const export const DPOP_BOUND_ACCESS_TOKENS = true export const OAUTH_APPLICATION_TYPE = isWeb ? 'web' : 'native' // TODO what should we put here for native - -export const buildOAuthUrl = (serviceUrl: string, state: string) => { - const url = new URL(serviceUrl) - url.searchParams.set('client_id', OAUTH_CLIENT_ID) - url.searchParams.set('redirect_uri', OAUTH_REDIRECT_URI) - url.searchParams.set('response_type', OAUTH_RESPONSE_TYPES.join(' ')) - url.searchParams.set('scope', OAUTH_SCOPE) - url.searchParams.set('state', state) - return url.toString() -} diff --git a/src/screens/Login/hooks/useLogin.ts b/src/screens/Login/hooks/useLogin.ts index c596d994f8..89cc9528f8 100644 --- a/src/screens/Login/hooks/useLogin.ts +++ b/src/screens/Login/hooks/useLogin.ts @@ -2,7 +2,6 @@ import React from 'react' import * as Browser from 'expo-web-browser' import { - buildOAuthUrl, DPOP_BOUND_ACCESS_TOKENS, OAUTH_APPLICATION_TYPE, OAUTH_CLIENT_ID, @@ -14,7 +13,7 @@ import { import {RNOAuthClientFactory} from '../../../../modules/expo-bluesky-oauth-client' // Service URL here is just a placeholder, this isn't how it will actually work -export function useLogin(serviceUrl: string | undefined) { +export function useLogin() { const openAuthSession = React.useCallback(async () => { const oauthFactory = new RNOAuthClientFactory({ clientMetadata: { @@ -29,24 +28,19 @@ export function useLogin(serviceUrl: string | undefined) { fetch: global.fetch, }) - const res = await oauthFactory.signIn('http://localhost:2583/') - console.log(res) + const url = await oauthFactory.signIn('http://localhost:2583/') - return - - if (!serviceUrl) return - - const url = buildOAuthUrl(serviceUrl, '123') // TODO replace '123' with the appropriate state + console.log(url.href) const authSession = await Browser.openAuthSessionAsync( - url, // This isn't actually how this will work - OAUTH_REDIRECT_URI, // Replace this as well with the appropriate link + url.href, + OAUTH_REDIRECT_URI, ) if (authSession.type !== 'success') { return } - }, [serviceUrl]) + }, []) return { openAuthSession,