···15151616run dev with `npm run dev` (port 3768) and build with `npm run build` (the output is the `dist` folder)
17171818+1919+2020+you probably dont need to change these
2121+```ts
2222+const PROD_HANDLE_RESOLVER_PDS = "https://pds-nd.whey.party"
2323+const DEV_HANDLE_RESOLVER_PDS = "https://bsky.social"
2424+```
2525+if you do want to change these, i recommend changing both of these to your own PDS url. i separate the prod and dev urls so that you can change it as needed. here i separated it because if the prod resolver and prod url shares the same domain itll error and prevent logins
2626+1827## useQuery
1928Red Dwarf has been upgraded from its original bespoke caching system to Tanstack Query (react query). this migration was done to achieve a more robust and maintainable approach to data fetching and caching and state synchronization. ive seen serious performance gains from this switch!
2029
+61-30
oauthdev.mts
···11-import fs from 'fs';
22-import path from 'path';
11+import fs from "fs";
22+import path from "path";
33//import { generateClientMetadata } from './src/helpers/oauthClient'
44export const generateClientMetadata = (appOrigin: string) => {
55- const callbackPath = '/callback';
55+ const callbackPath = "/callback";
6677 return {
88- "client_id": `${appOrigin}/client-metadata.json`,
99- "client_name": "ForumTest",
1010- "client_uri": appOrigin,
1111- "logo_uri": `${appOrigin}/logo192.png`,
1212- "tos_uri": `${appOrigin}/terms-of-service`,
1313- "policy_uri": `${appOrigin}/privacy-policy`,
1414- "redirect_uris": [`${appOrigin}${callbackPath}`] as [string, ...string[]],
1515- "scope": "atproto transition:generic",
1616- "grant_types": ["authorization_code", "refresh_token"] as ["authorization_code", "refresh_token"],
1717- "response_types": ["code"] as ["code"],
1818- "token_endpoint_auth_method": "none" as "none",
1919- "application_type": "web" as "web",
2020- "dpop_bound_access_tokens": true
2121- };
2222-}
88+ client_id: `${appOrigin}/client-metadata.json`,
99+ client_name: "ForumTest",
1010+ client_uri: appOrigin,
1111+ logo_uri: `${appOrigin}/logo192.png`,
1212+ tos_uri: `${appOrigin}/terms-of-service`,
1313+ policy_uri: `${appOrigin}/privacy-policy`,
1414+ redirect_uris: [`${appOrigin}${callbackPath}`] as [string, ...string[]],
1515+ scope: "atproto transition:generic",
1616+ grant_types: ["authorization_code", "refresh_token"] as [
1717+ "authorization_code",
1818+ "refresh_token",
1919+ ],
2020+ response_types: ["code"] as ["code"],
2121+ token_endpoint_auth_method: "none" as "none",
2222+ application_type: "web" as "web",
2323+ dpop_bound_access_tokens: true,
2424+ };
2525+};
23262424-2525-export function generateMetadataPlugin({prod, dev}:{prod: string, dev: string}) {
2727+export function generateMetadataPlugin({
2828+ prod,
2929+ dev,
3030+ prodResolver = "https://bsky.social",
3131+ devResolver = prodResolver,
3232+}: {
3333+ prod: string;
3434+ dev: string;
3535+ prodResolver?: string;
3636+ devResolver?: string;
3737+}) {
2638 return {
2727- name: 'vite-plugin-generate-metadata',
3939+ name: "vite-plugin-generate-metadata",
2840 config(_config: any, { mode }: any) {
2929- let appOrigin;
3030- if (mode === 'production') {
3131- appOrigin = prod
3232- if (!appOrigin || !appOrigin.startsWith('https://')) {
3333- throw new Error('VITE_APP_ORIGIN environment variable must be set to a valid HTTPS URL for production build.');
4141+ let appOrigin, resolver;
4242+ if (mode === "production") {
4343+ appOrigin = prod;
4444+ resolver = prodResolver;
4545+ if (!appOrigin || !appOrigin.startsWith("https://")) {
4646+ throw new Error(
4747+ "VITE_APP_ORIGIN environment variable must be set to a valid HTTPS URL for production build."
4848+ );
3449 }
3550 } else {
3651 appOrigin = dev;
5252+ resolver = devResolver;
3753 }
3838-3939-5454+4055 const metadata = generateClientMetadata(appOrigin);
4141- const outputPath = path.resolve(process.cwd(), 'public', 'client-metadata.json');
5656+ const outputPath = path.resolve(
5757+ process.cwd(),
5858+ "public",
5959+ "client-metadata.json"
6060+ );
42614362 fs.writeFileSync(outputPath, JSON.stringify(metadata, null, 2));
44636464+ const resolvers = {
6565+ resolver: resolver,
6666+ };
6767+ const resolverOutPath = path.resolve(
6868+ process.cwd(),
6969+ "public",
7070+ "resolvers.json"
7171+ );
7272+7373+ fs.writeFileSync(resolverOutPath, JSON.stringify(resolvers, null, 2));
7474+7575+4576 // /*mass comment*/ console.log(`✅ Generated client-metadata.json for ${appOrigin}`);
4677 },
4778 };
4848-}7979+}
+2-2
src/utils/oauthClient.ts
···11import { BrowserOAuthClient, type ClientMetadata } from '@atproto/oauth-client-browser';
2233-// i tried making this https://pds-nd.whey.party but cors is annoying as fuck
44-const handleResolverPDS = 'https://bsky.social';
33+import resolvers from '../../public/resolvers.json' with { type: 'json' };
44+const handleResolverPDS = resolvers.resolver || 'https://bsky.social';
5566// eslint-disable-next-line @typescript-eslint/ban-ts-comment
77// @ts-ignore this should be fine ? the vite plugin should generate this before errors