ATProto forum built with ESAV
at main 38 lines 1.7 kB view raw
1import { BrowserOAuthClient, type ClientMetadata } from '@atproto/oauth-client-browser'; 2 3// const domain = location.origin ? location.origin : ((import.meta?.env?.DEV) ? 'https://local3768forumtest.whey.party' : 'https://forumtest.whey.party') 4const handleResolverPDS = 'https://pds-nd.whey.party' 5 6// export const generateClientMetadata = (appOrigin: string) => { 7// const callbackPath = '/callback'; 8 9// return { 10// "client_id": `${appOrigin}/client-metadata.json`, 11// "client_name": "ForumTest", 12// "client_uri": appOrigin, 13// "logo_uri": `${appOrigin}/logo192.png`, 14// "tos_uri": `${appOrigin}/terms-of-service`, 15// "policy_uri": `${appOrigin}/privacy-policy`, 16// "redirect_uris": [`${appOrigin}${callbackPath}`] as [string, ...string[]], 17// "scope": "atproto transition:generic", 18// "grant_types": ["authorization_code", "refresh_token"] as ["authorization_code", "refresh_token"], 19// "response_types": ["code"] as ["code"], 20// "token_endpoint_auth_method": "none" as "none", 21// "application_type": "web" as "web", 22// "dpop_bound_access_tokens": true 23// }; 24// } 25 26// IF ERROR: you need to build it first, either npm run dev or npm run build 27import clientMetadata from '../../public/client-metadata.json' assert { type: 'json' }; 28 29// async function loadClientMetadata(): Promise<ClientMetadata> { 30// const res = await fetch('/client-metadata.json'); 31// if (!res.ok) throw new Error('Failed to load client metadata'); 32// return res.json(); 33// } 34 35export const oauthClient = new BrowserOAuthClient({ 36 clientMetadata: clientMetadata as ClientMetadata, 37 handleResolver: handleResolverPDS, 38});