Scratch space for learning atproto app development
1import { JoseKey } from '@atproto/jwk-jose' 2import { NodeOAuthClient } from '@atproto/oauth-client-node' 3import type { Database } from '#/db' 4import { env } from '#/env' 5import { SessionStore, StateStore } from './storage' 6 7export const createClient = async (db: Database) => { 8 const publicUrl = env.PUBLIC_URL 9 const url = publicUrl || `http://127.0.0.1:${env.PORT}` 10 return new NodeOAuthClient({ 11 clientMetadata: { 12 client_name: 'AT Protocol Express App', 13 client_id: publicUrl 14 ? `${url}/client-metadata.json` 15 : `http://localhost?redirect_uri=${encodeURIComponent(`${url}/oauth/callback`)}`, 16 client_uri: url, 17 redirect_uris: [`${url}/oauth/callback`], 18 scope: 'profile offline_access', 19 grant_types: ['authorization_code', 'refresh_token'], 20 response_types: ['code'], 21 application_type: 'web', 22 token_endpoint_auth_method: 'none', 23 dpop_bound_access_tokens: true, 24 }, 25 stateStore: new StateStore(db), 26 sessionStore: new SessionStore(db), 27 }) 28}