diff --git a/src/app/jams/oauth/code/route.ts b/src/app/jams/oauth/code/route.ts index 66f056d..3ffcf8e 100644 --- a/src/app/jams/oauth/code/route.ts +++ b/src/app/jams/oauth/code/route.ts @@ -39,19 +39,39 @@ export async function GET(request: NextRequest) { // Test for user existence let tUserExists = await mauth.verifyUser(tUserToken.token_type + " " + tUserToken.access_token); - console.log(tUserExists,); + console.log(tUserExists); if (tUserExists == null) return new Response('', { status: 400 }); + // Check if user is "dangerous" + + const t1ListRequest = await fetch("https://seirdy.one/pb/tier1.csv"); + + const t1List = await t1ListRequest.text(); + + if (t1List == null) return new Response('', { + status: 500 + }); + + // Split lists + + const JSONt1List = t1List.split("\n").slice(2).map(x => x.split(",")[0]); + + // Impersonation check + + if (!tUserExists.url.includes(instance) && !tUserExists.url.includes(tUserExists.acct)) return new Response(`URL is invalid`, { + status: 401 + }); + let currentUser = { id: nanoid(21), instance, username: tUserExists.acct, admin: false, url: tUserExists.url, - banned: false, + banned: JSONt1List.includes(instance), // If user's domain is on tier1, start user banned joined: Date.now() } as UserTable; diff --git a/src/app/jams/oauth/login/route.ts b/src/app/jams/oauth/login/route.ts index 404abee..b601b5c 100644 --- a/src/app/jams/oauth/login/route.ts +++ b/src/app/jams/oauth/login/route.ts @@ -11,6 +11,37 @@ export async function GET(request: NextRequest) { }); const mauth = new MastoAuth(instance); + // Check if instance is fediblocked + + const fnListRequest = await fetch("https://seirdy.one/pb/FediNuke.txt"); + + const fnList = await fnListRequest.text(); + + if (fnList == null) return new Response('', { + status: 500 + }); + + const ssListRequest = await fetch("https://seirdy.one/pb/spammy-subdomains.txt"); + + const ssList = await ssListRequest.text(); + + if (ssList == null) return new Response('', { + status: 500 + }); + + // Split lists + + const JSONFnList = fnList.split("\n"); + const JSONSsList = ssList.split("\n"); + + if (JSONSsList.includes(instance)) return new Response('https://seirdy.one/pb/spammy-subdomains.txt', { + status: 403 + }); + + if (JSONFnList.includes(instance)) return new Response('https://seirdy.one/pb/FediNuke.txt', { + status: 403 + }); + // Check if instance app exists let existingInstanceApp = await db .selectFrom('apps') @@ -41,7 +72,7 @@ export async function GET(request: NextRequest) { .returningAll() .executeTakeFirstOrThrow(); } catch (err) { - return new Response('', { + return new Response('', { status: 500 }); }