your personal website on atproto - mirror
blento.app
1import { resolve } from '$app/paths';
2import { blobs, collections, rpcCalls, SITE } from './settings';
3
4function constructScope() {
5 const repos = collections.map((collection) => 'repo:' + collection).join(' ');
6
7 let rpcs = '';
8 for (const [key, value] of Object.entries(rpcCalls)) {
9 if (Array.isArray(value)) {
10 rpcs += value.map((lxm) => 'rpc?lxm=' + lxm + '&aud=' + key).join(' ');
11 } else {
12 rpcs += 'rpc?lxm=' + value + '&aud=' + key;
13 }
14 }
15 let blobScope: string | undefined = undefined;
16 if (Array.isArray(blobs)) {
17 blobScope = 'blob?' + blobs.map((b) => 'accept=' + b).join('&');
18 } else if (blobs) {
19 blobScope = 'blob:' + blobs;
20 }
21
22 const scope = ['atproto', repos, rpcs, blobScope].filter((v) => v?.trim()).join(' ');
23 return scope;
24}
25
26export const metadata = {
27 client_id: SITE + resolve('/oauth-client-metadata.json'),
28 redirect_uris: [SITE + resolve('/oauth/callback')],
29 scope: constructScope(),
30 grant_types: ['authorization_code', 'refresh_token'],
31 response_types: ['code'],
32 token_endpoint_auth_method: 'none',
33 application_type: 'web',
34 dpop_bound_access_tokens: true
35};