The recipes.blue monorepo recipes.blue
recipes appview atproto

feat: pds auth proxying v1

+27 -7
+13
apps/web/public/.well-known/did.json
···
··· 1 + { 2 + "@context": [ 3 + "https://www.w3.org/ns/did/v1" 4 + ], 5 + "id": "did:web:recipes.blue", 6 + "service": [ 7 + { 8 + "id": "#api", 9 + "type": "RecipesApiService", 10 + "serviceEndpoint": "https://recipes.blue" 11 + } 12 + ] 13 + }
+14 -7
apps/web/src/hooks/use-xrpc.tsx
··· 1 import { SERVER_URL } from "@/lib/utils"; 2 import { CredentialManager, XRPC } from "@atcute/client" 3 - import { OAuthUserAgent } from "@atcute/oauth-browser-client"; 4 5 - export function useXrpc(agent?: OAuthUserAgent) { 6 - let handler; 7 - if (agent) handler = agent; 8 - else handler = new CredentialManager({ service: `https://${SERVER_URL}` }); 9 10 - const rpc = new XRPC({ handler }); 11 12 - return rpc; 13 }
··· 1 import { SERVER_URL } from "@/lib/utils"; 2 + import { useAuth } from "@/state/auth"; 3 import { CredentialManager, XRPC } from "@atcute/client" 4 5 + export function useXrpc() { 6 + const { agent } = useAuth(); 7 8 + if (agent) { 9 + return new XRPC({ 10 + handler: agent, 11 + proxy: { 12 + type: 'atproto_pds', 13 + service: `did:web:${SERVER_URL}#api`, 14 + }, 15 + }); 16 + } 17 18 + const creds = new CredentialManager({ service: `https://${SERVER_URL}` }); 19 + return new XRPC({ handler: creds }); 20 }