tangled
alpha
login
or
join now
modamo.xyz
/
bambu
1
fork
atom
this repo has no description
1
fork
atom
overview
issues
pulls
pipelines
Add missing auth files
modamo-gh
1 month ago
0985ef8c
3ae5294e
+62
-4
4 changed files
expand all
collapse all
unified
split
app
.well-known
jwks.json
route.ts
library
page.tsx
oauth-client-metadata.json
route.ts
scripts
generateKey.ts
+14
app/.well-known/jwks.json/route.ts
···
1
1
+
import { JoseKey } from "@atproto/oauth-client-node";
2
2
+
import { NextResponse } from "next/server";
3
3
+
4
4
+
const PRIVATE_KEY = process.env.PRIVATE_KEY;
5
5
+
6
6
+
export async function GET() {
7
7
+
if (!PRIVATE_KEY) {
8
8
+
return NextResponse.json({ keys: [] });
9
9
+
}
10
10
+
11
11
+
const key = await JoseKey.fromJWK(JSON.parse(PRIVATE_KEY));
12
12
+
13
13
+
return NextResponse.json({ keys: [key.publicJwk] });
14
14
+
}
+30
-4
app/library/page.tsx
···
1
1
-
const Library = () => {
2
2
-
return <div></div>
3
3
-
}
1
1
+
import { getSession } from "@/lib/auth/session";
2
2
+
import { Agent } from "@atproto/api";
3
3
+
import { redirect } from "next/navigation";
4
4
+
5
5
+
const Library = async () => {
6
6
+
const session = await getSession();
7
7
+
8
8
+
if (!session) {
9
9
+
redirect("/");
10
10
+
}
4
11
5
5
-
export default Library;
12
12
+
const agent = new Agent(session);
13
13
+
14
14
+
let error, profile;
15
15
+
16
16
+
try {
17
17
+
const response = await agent.getProfile({ actor: session.did });
18
18
+
19
19
+
profile = response.data;
20
20
+
21
21
+
console.log(profile);
22
22
+
} catch (error) {
23
23
+
console.error("Error fetching profile:", error);
24
24
+
25
25
+
error =
26
26
+
error instanceof Error ? error.message : "Failed to fetch profile";
27
27
+
}
28
28
+
return <div></div>;
29
29
+
};
30
30
+
31
31
+
export default Library;
+8
app/oauth-client-metadata.json/route.ts
···
1
1
+
import { getOAuthClient } from "@/lib/auth/client";
2
2
+
import { NextResponse } from "next/server";
3
3
+
4
4
+
export async function GET(){
5
5
+
const client = await getOAuthClient();
6
6
+
7
7
+
return NextResponse.json(client.clientMetadata)
8
8
+
}
+10
scripts/generateKey.ts
···
1
1
+
import { JoseKey } from "@atproto/oauth-client-node";
2
2
+
3
3
+
const main = async () => {
4
4
+
const kid = Date.now().toString();
5
5
+
const key = await JoseKey.generate(["ES256"], kid);
6
6
+
7
7
+
console.log(JSON.stringify(key.privateJwk));
8
8
+
};
9
9
+
10
10
+
main();