This commit is contained in:
Hailey
2024-08-03 13:58:44 -07:00
parent 2901f0fc50
commit ff5bc69b5a
6 changed files with 44 additions and 12 deletions
+1
View File
@@ -223,6 +223,7 @@ func serve(cctx *cli.Context) error {
e.GET("/intent/compose", server.WebGeneric)
e.GET("/messages", server.WebGeneric)
e.GET("/messages/:conversation", server.WebGeneric)
e.GET("/auth/callback", server.WebGeneric)
// profile endpoints; only first populates info
e.GET("/profile/:handleOrDID", server.WebProfile)
@@ -1,11 +1,11 @@
{
"client_id": "https://bsky.app/.well-known/client-metadata.json",
"client_id": "https://.ngrok-free.app/.well-known/client-metadata.json",
"client_name": "Bluesky",
"client_uri": "https://bsky.app",
"client_uri": "https://.ngrok-free.app",
"logo_uri": "https://bsky.app/logo.png",
"tos_uri": "https://bsky.social/about/support/tos",
"policy_uri": "https://bsky.social/about/support/privacy-policy",
"redirect_uris": ["https://bsky.app/auth/callback"],
"redirect_uris": ["https://.ngrok-free.app/auth/callback"],
"scope": "profile email offline_access",
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
+6
View File
@@ -41,6 +41,7 @@ import {PreferencesThreads} from 'view/screens/PreferencesThreads'
import {SavedFeeds} from 'view/screens/SavedFeeds'
import {SharedPreferencesTesterScreen} from '#/screens/E2E/SharedPreferencesTesterScreen'
import HashtagScreen from '#/screens/Hashtag'
import {CallbackScreen} from '#/screens/Login/CallbackScreen'
import {ModerationScreen} from '#/screens/Moderation'
import {ProfileKnownFollowersScreen} from '#/screens/Profile/KnownFollowers'
import {ProfileLabelerLikedByScreen} from '#/screens/Profile/ProfileLabelerLikedBy'
@@ -364,6 +365,11 @@ function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) {
getComponent={() => Wizard}
options={{title: title(msg`Edit your starter pack`), requireAuth: true}}
/>
<Stack.Screen
name="AuthCallback"
getComponent={() => CallbackScreen}
options={{title: title(msg`Callback`)}}
/>
</>
)
}
+1
View File
@@ -50,6 +50,7 @@ export type CommonNavigatorParams = {
StarterPackShort: {code: string}
StarterPackWizard: undefined
StarterPackEdit: {rkey?: string}
AuthCallback: undefined
}
export type BottomTabNavigatorParams = CommonNavigatorParams & {
+26 -2
View File
@@ -1,7 +1,31 @@
import React from 'react'
import {AppBskyActorDefs} from '@atproto/api'
import {ListMaybePlaceholder} from '#/components/Lists'
import {CenteredView} from 'view/com/util/Views'
import {client} from '#/screens/Login/LoginForm'
import {Text} from '#/components/Typography'
export function CallbackScreen() {
return <ListMaybePlaceholder isLoading={true} />
const [profile, setProfile] = React.useState<AppBskyActorDefs.ProfileView>()
React.useEffect(() => {
;(async () => {
const res = await client.init()
const profileRes = await res!.agent.request(
'/xrpc/com.atproto.repo.getRecord?' +
new URLSearchParams({
repo: res!.agent.sub,
collection: 'app.bsky.actor.profile',
rkey: 'self',
}).toString(),
)
const json = await profileRes?.json()
setProfile(json.value)
})()
}, [])
return (
<CenteredView>
<Text>{profile ? profile.displayName : 'Loading'}</Text>
</CenteredView>
)
}
+7 -7
View File
@@ -27,7 +27,7 @@ import {logger} from '#/logger'
import {useSessionApi} from '#/state/session'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useRequestNotificationsPermission} from 'lib/notifications/notifications'
import {useGate} from 'lib/statsig/statsig'
// import {useGate} from 'lib/statsig/statsig'
import {useSetHasCheckedForStarterPack} from 'state/preferences/used-starter-packs'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
@@ -43,13 +43,13 @@ import {FormContainer} from './FormContainer'
type ServiceDescription = ComAtprotoServerDescribeServer.OutputSchema
const client = new BrowserOAuthClient({
export const client = new BrowserOAuthClient({
plcDirectoryUrl: 'https://plc.directory',
handleResolver: 'https://bsky.social',
clientMetadata: {
client_id: 'http://localhost:19006/',
redirect_uris: ['http://localhost:19006/auth/callback'],
response_types: ['code'],
client_id: 'https://.ngrok-free.app/.well-known/client-metadata.json',
client_name: 'Bluesky',
redirect_uris: ['https://.ngrok-free.app/auth/callback'],
token_endpoint_auth_method: 'none',
},
})
@@ -186,8 +186,8 @@ export const LoginForm = ({
const {setShowLoggedOut} = useLoggedOutViewControls()
const setHasCheckedForStarterPack = useSetHasCheckedForStarterPack()
const gate = useGate()
const oauthEnabled = __DEV__ || gate('use_oauth')
// const gate = useGate()
const oauthEnabled = true
const oauth = useOAuth(client)
const [handle, setHandle] = React.useState('')