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