diff --git a/src/lib/oauth-client.ts b/src/lib/oauth-client.ts index bef8009..e29c42b 100644 --- a/src/lib/oauth-client.ts +++ b/src/lib/oauth-client.ts @@ -110,7 +110,7 @@ export const createClientMetadata = (config: { domain: `http://${string}` | `htt // Loopback client for local development // For loopback, scopes and redirect_uri must be in client_id query string const redirectUri = 'http://127.0.0.1:8000/api/auth/callback'; - const scope = 'atproto transition:generic'; + const scope = 'atproto repo:place.wisp.fs repo:place.wisp.domain repo:place.wisp.subfs blob:*/* blob?maxSize=100000000 rpc:app.bsky.actor.getProfile?aud=*'; const params = new URLSearchParams(); params.append('redirect_uri', redirectUri); params.append('scope', scope); @@ -145,7 +145,7 @@ export const createClientMetadata = (config: { domain: `http://${string}` | `htt application_type: 'web', token_endpoint_auth_method: 'private_key_jwt', token_endpoint_auth_signing_alg: "ES256", - scope: "atproto transition:generic", + scope: "atproto repo:place.wisp.fs repo:place.wisp.domain repo:place.wisp.subfs blob:accept=*/*&maxSize=100000000 rpc:app.bsky.actor.getProfile?aud=*", dpop_bound_access_tokens: true, jwks_uri: `${config.domain}/jwks.json`, subject_type: 'public', diff --git a/src/routes/user.ts b/src/routes/user.ts index 4ba63e6..f525209 100644 --- a/src/routes/user.ts +++ b/src/routes/user.ts @@ -41,13 +41,18 @@ export const userRoutes = (client: NodeOAuthClient, cookieSecret: string) => .get('/info', async ({ auth }) => { try { // Get user's handle from AT Protocol - const agent = new Agent((url, init) => auth.session.fetchHandler(url, init)) + const agent = new Agent(auth.session) let handle = 'unknown' try { + console.log('[User] Attempting to fetch profile for DID:', auth.did) const profile = await agent.getProfile({ actor: auth.did }) + console.log('[User] Profile fetched successfully:', profile.data.handle) handle = profile.data.handle } catch (err) { + console.error('[User] Failed to fetch profile - Full error:', err) + console.error('[User] Error message:', err instanceof Error ? err.message : String(err)) + console.error('[User] Error stack:', err instanceof Error ? err.stack : 'No stack') logger.error('[User] Failed to fetch profile', err) }