tangled
alpha
login
or
join now
roost.moe
/
recipes.blue
2
fork
atom
The recipes.blue monorepo
recipes.blue
recipes
appview
atproto
2
fork
atom
overview
issues
1
pulls
pipelines
feat: pds auth proxying v1
Hayden Young
1 year ago
88a149a1
c119b277
+27
-7
2 changed files
expand all
collapse all
unified
split
apps
web
public
.well-known
did.json
src
hooks
use-xrpc.tsx
+13
apps/web/public/.well-known/did.json
···
0
0
0
0
0
0
0
0
0
0
0
0
0
···
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";
0
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 });
0
0
0
0
0
0
0
0
11
12
-
return rpc;
0
13
}
···
1
import { SERVER_URL } from "@/lib/utils";
2
+
import { useAuth } from "@/state/auth";
3
import { CredentialManager, XRPC } from "@atcute/client"
0
4
5
+
export function useXrpc() {
6
+
const { agent } = useAuth();
0
0
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
}