Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 72 lines 2.4 kB view raw
1import {BrowserOAuthClient} from '@atproto/oauth-client-browser' 2 3const OAUTH_BASE_URL: string = 4 process.env.EXPO_PUBLIC_OAUTH_BASE_URL || 'https://witchsky.app' 5 6const OAUTH_CLIENT_NAME: string = 7 process.env.EXPO_PUBLIC_OAUTH_CLIENT_NAME || 'Witchsky' 8 9const OAUTH_SCOPE = 10 'atproto transition:generic transition:email transition:chat.bsky identity:handle account:email?action=manage account:status?action=manage' 11 12function isLoopback() { 13 if (typeof window === 'undefined') return false 14 const host = window.location.hostname 15 return ( 16 host === 'localhost' || 17 host === '127.0.0.1' || 18 host === '[::1]' || 19 host === '::1' 20 ) 21} 22 23const BSKY_OAUTH_CLIENT = createWebOAuthClient() 24 25function createWebOAuthClient() { 26 if (isLoopback()) { 27 // Loopback client: encode scope and redirect_uri in the client_id URL. 28 // The authorization server uses hardcoded metadata for http://localhost 29 // client_ids. Without explicit scope, only "atproto" is granted, which 30 // lacks the transition:* scopes needed for appview/chat APIs. 31 const port = window.location.port ? `:${window.location.port}` : '' 32 const redirectUri = `http://127.0.0.1${port}/` 33 const clientId = 34 `http://localhost` + 35 `?redirect_uri=${encodeURIComponent(redirectUri)}` + 36 `&scope=${encodeURIComponent(OAUTH_SCOPE)}` 37 38 return new BrowserOAuthClient({ 39 clientMetadata: { 40 client_id: clientId, 41 redirect_uris: [redirectUri], 42 scope: OAUTH_SCOPE, 43 token_endpoint_auth_method: 'none', 44 response_types: ['code'], 45 grant_types: ['authorization_code', 'refresh_token'], 46 application_type: 'web', 47 dpop_bound_access_tokens: true, 48 }, 49 handleResolver: 'https://bsky.social', 50 }) 51 } 52 53 return new BrowserOAuthClient({ 54 clientMetadata: { 55 client_id: `${OAUTH_BASE_URL}/oauth-client-metadata.json`, 56 client_name: OAUTH_CLIENT_NAME, 57 client_uri: OAUTH_BASE_URL, 58 redirect_uris: [`${OAUTH_BASE_URL}/auth/web/callback`], 59 scope: OAUTH_SCOPE, 60 token_endpoint_auth_method: 'none', 61 response_types: ['code'], 62 grant_types: ['authorization_code', 'refresh_token'], 63 application_type: 'web', 64 dpop_bound_access_tokens: true, 65 }, 66 handleResolver: 'https://bsky.social', 67 }) 68} 69 70export function getWebOAuthClient() { 71 return BSKY_OAUTH_CLIENT 72}