rm some useless code

This commit is contained in:
Hailey
2024-04-12 09:20:07 -07:00
parent 951f5f25d6
commit bc67bdb5b1
2 changed files with 7 additions and 23 deletions
+1 -11
View File
@@ -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()
}
+6 -12
View File
@@ -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,