this repo has no description
1import { NodeOAuthClient } from '@atproto/oauth-client-node';
2import { getKeyset } from './keys.js';
3
4const stateStore = new Map();
5const sessionStore = new Map();
6
7export const buildOAuthClient = async ({ publicUrl }) => {
8 const keyset = await getKeyset();
9 const clientId = `${publicUrl}/client-metadata.json`;
10 return new NodeOAuthClient({
11 clientMetadata: {
12 client_id: clientId,
13 client_name: 'portable.agency',
14 client_uri: publicUrl,
15 redirect_uris: [`${publicUrl}/oauth/callback`],
16 grant_types: ['authorization_code', 'refresh_token'],
17 scope: 'atproto repo:agency.portable.membership',
18 response_types: ['code'],
19 application_type: 'web',
20 token_endpoint_auth_method: 'private_key_jwt',
21 token_endpoint_auth_signing_alg: 'ES256',
22 dpop_bound_access_tokens: true,
23 jwks_uri: `${publicUrl}/jwks.json`,
24 },
25 keyset,
26 stateStore: {
27 async set(key, state) { stateStore.set(key, state); },
28 async get(key) { return stateStore.get(key); },
29 async del(key) { stateStore.delete(key); },
30 },
31 sessionStore: {
32 async set(sub, session) { sessionStore.set(sub, session); },
33 async get(sub) { return sessionStore.get(sub); },
34 async del(sub) { sessionStore.delete(sub); },
35 },
36 });
37};