tangled
alpha
login
or
join now
grain.social
/
grain
38
fork
atom
grain.social is a photo sharing platform built on atproto.
38
fork
atom
overview
issues
2
pulls
pipelines
move token callback to bff
chadtmiller.com
8 months ago
d60f0aa5
9e50c1dd
+8
-20
4 changed files
expand all
collapse all
unified
split
deno.json
deno.lock
src
api
mod.ts
main.tsx
+1
-1
deno.json
···
3
3
"$lexicon/": "./__generated__/",
4
4
"@atproto/api": "npm:@atproto/api@^0.15.16",
5
5
"@atproto/syntax": "npm:@atproto/syntax@^0.4.0",
6
6
-
"@bigmoves/bff": "jsr:@bigmoves/bff@0.3.0-beta.42",
6
6
+
"@bigmoves/bff": "jsr:@bigmoves/bff@0.3.0-beta.43",
7
7
"@std/http": "jsr:@std/http@^1.0.17",
8
8
"@std/path": "jsr:@std/path@^1.0.9",
9
9
"@tailwindcss/cli": "npm:@tailwindcss/cli@^4.1.4",
+4
-4
deno.lock
···
2
2
"version": "5",
3
3
"specifiers": {
4
4
"jsr:@bigmoves/atproto-oauth-client@0.2": "0.2.0",
5
5
-
"jsr:@bigmoves/bff@0.3.0-beta.42": "0.3.0-beta.42",
5
5
+
"jsr:@bigmoves/bff@0.3.0-beta.43": "0.3.0-beta.43",
6
6
"jsr:@deno/gfm@0.10": "0.10.0",
7
7
"jsr:@denosaurs/emoji@0.3": "0.3.1",
8
8
"jsr:@luca/esbuild-deno-loader@~0.11.1": "0.11.1",
···
97
97
"npm:jose"
98
98
]
99
99
},
100
100
-
"@bigmoves/bff@0.3.0-beta.42": {
101
101
-
"integrity": "4866ae7f9e1a61e0abe8255f40e6ccba6d370a0ea4710cf061ebfcb5248ac688",
100
100
+
"@bigmoves/bff@0.3.0-beta.43": {
101
101
+
"integrity": "ec8a2b4deaf454072697407cd2a0f0247a453693b1aa0027fb00c848f6524c76",
102
102
"dependencies": [
103
103
"jsr:@bigmoves/atproto-oauth-client",
104
104
"jsr:@std/assert@^1.0.13",
···
2100
2100
},
2101
2101
"workspace": {
2102
2102
"dependencies": [
2103
2103
-
"jsr:@bigmoves/bff@0.3.0-beta.42",
2103
2103
+
"jsr:@bigmoves/bff@0.3.0-beta.43",
2104
2104
"jsr:@std/http@^1.0.17",
2105
2105
"jsr:@std/path@^1.0.9",
2106
2106
"npm:@atproto/api@~0.15.16",
+1
-15
src/api/mod.ts
···
26
26
OutputSchema as GetNotificationsOutputSchema,
27
27
} from "$lexicon/types/social/grain/notification/getNotifications.ts";
28
28
import { AtUri } from "@atproto/syntax";
29
29
-
import { BffMiddleware, OAUTH_ROUTES, route } from "@bigmoves/bff";
29
29
+
import { BffMiddleware, route } from "@bigmoves/bff";
30
30
import {
31
31
getActorGalleries,
32
32
getActorProfileDetailed,
···
39
39
import { getGalleryComments } from "../modules/comments.tsx";
40
40
41
41
export const middlewares: BffMiddleware[] = [
42
42
-
async (req, ctx) => {
43
43
-
const url = new URL(req.url);
44
44
-
const { pathname } = url;
45
45
-
46
46
-
if (pathname === OAUTH_ROUTES.tokenCallback) {
47
47
-
const token = url.searchParams.get("token") ?? undefined;
48
48
-
if (!token) {
49
49
-
throw new BadRequestError("Missing token parameter");
50
50
-
}
51
51
-
return ctx.redirect(`grainflutter://auth/callback?token=${token}`);
52
52
-
}
53
53
-
54
54
-
return ctx.next();
55
55
-
},
56
42
route("/oauth/session", (_req, _params, ctx) => {
57
43
if (!ctx.currentUser) {
58
44
return ctx.json("Unauthorized", 401);
+2
src/main.tsx
···
52
52
"social.grain.photo.exif": ["photo"],
53
53
"social.grain.comment": ["subject"],
54
54
},
55
55
+
// Used to exchange jwt token with mobile app
56
56
+
tokenCallbackUrl: "grainflutter://auth/callback",
55
57
lexicons,
56
58
rootElement: Root,
57
59
onError,