import { dev } from '$app/environment';
import { scope } from '@atcute/oauth-node-client';
import { xrpcMethods } from './generated-methods';

// Writable collections on the USER's PDS. This app writes nothing to the user's
// PDS — every record lives in contrail spaces, authored by the user DID via
// space.putRecord or by the community DID via community.space.putRecord.
// Keep the list empty; repo scope is omitted below.
export const collections = [] as const;

export type AllowedCollection = (typeof collections)[number];

// OAuth scope.
//
// We ask for:
//   - `atproto` — baseline identity scope.
//   - `rpc` for every XRPC method contrail emits in this namespace. The list
//     is auto-generated by `pnpm generate` (source: contrail's permissionSet),
//     so adding/removing collections or toggling modules automatically updates
//     the consent prompt.
//   - `aud: '*'` — we don't couple the scope to a specific service DID so one
//     OAuth client metadata works in dev and prod. The PDS still only mints
//     JWTs for the exact `aud` the app asks for at getServiceAuth time.
export const scopes = [
	'atproto',
	scope.rpc({
		aud: '*',
		lxm: [...xrpcMethods] as `${string}.${string}.${string}`[]
	})
];

// set to false to disable signup
export const ALLOW_SIGNUP = true;

// which PDS to use for signup (change to your preferred PDS)
const devPDS = 'https://pds.rip/';
const prodPDS = 'https://selfhosted.social/';
export const signUpPDS = dev ? devPDS : prodPDS;

// where to redirect after oauth login/signup
export const REDIRECT_PATH = '/oauth/callback';

// redirect the user back to the page they were on before login
export const REDIRECT_TO_LAST_PAGE_ON_LOGIN = true;

export const DOH_RESOLVER = 'https://mozilla.cloudflare-dns.com/dns-query';
