From 4a4b20cf09fed345eb5bcc3267282567ea0d82fa Mon Sep 17 00:00:00 2001 From: split Date: Thu, 21 Nov 2024 21:15:51 -0800 Subject: [PATCH] refactor: :fire: remove discord (i dont want to bother with it) --- README.md | 5 --- src/translators/discord.ts | 79 -------------------------------------- 2 files changed, 84 deletions(-) delete mode 100644 src/translators/discord.ts diff --git a/README.md b/README.md index fbd1767..76c0c04 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,6 @@ All settings for endpoints are configured in query parameters. - `identifier`: Bluesky handle - `password`: Bluesky password - create an app password in settings -### `/discord` - -- `token`: Discord token -- `cookie`: Cookie header, b64-encoded - ### `/misskey` - `instance`: Link to your Misskey instance. Include protocol. diff --git a/src/translators/discord.ts b/src/translators/discord.ts deleted file mode 100644 index 8d84e46..0000000 --- a/src/translators/discord.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { z } from "zod" -import { translator } from "../lib/types.js" -import downloadAvatarForPayload from "../lib/downloadAvatarForPayload.js" -export default translator({ - query: z.object({ - token: z.string().describe("Discord token"), - cookie: z.string().describe(`Cookie header, b64-encoded`), - }), - async execute(payload, { token, cookie }) { - let avatar = await downloadAvatarForPayload(payload, [ - "png", - "jpeg", - undefined, - ]) - - if (!avatar) throw new Error("discord: failed to get avatar") - - const browser_version = "113.0.5666.197", - browser_version_short = browser_version.split(".")[1], - client_build_number = "347115", // todo: figure out how to get this? - ua = `Mozilla/5.0 (Windows NT 10.0; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${browser_version} Safari/537.36` - - // copied from a firefox private browsing window - // realistically this will probably need updates in the future - // but for now this is good enough - let f = await fetch("https://discord.com/api/v9/users/@me", { - headers: { - "User-Agent": ua, - Accept: "*/*", - "Accept-Language": "en-US,en;q=0.5", - "Content-Type": "application/json", - Authorization: token, - "X-Super-Properties": Buffer.from( - JSON.stringify({ - os: "Windows", - browser: "Chrome", - device: "", - system_locale: "en-US", - browser_user_agent: ua, - browser_version, - os_version: "10", - referrer: "", - referring_domain: "", - referrer_current: "", - referring_domain_current: "", - release_channel: "stable", - client_build_number, - client_event_source: null, - }) - ).toString("base64"), - cookie: Buffer.from(cookie, "base64url").toString(), - "X-Discord-Locale": "en-US", - "X-Discord-Timezone": "America/Los_Angeles", - "X-Debug-Options": "bugReporterEnabled", - "Sec-GPC": "1", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-origin", - "sec-ch-ua-platform": '"Windows"', - "sec-ch-ua": `"Google Chrome";v="${browser_version_short}", "Chromium";v="${browser_version_short}", "Not=A?Brand";v="24"`, - "sec-ch-ua-mobile": "?0", - Priority: "u=0", - Referer: "https://discord.com/channels/@me/", - Origin: "https://discord.com", - }, - body: JSON.stringify({ - avatar: `data:${avatar.type};base64,${Buffer.from( - await avatar.arrayBuffer() - ).toString("base64")}`, - }), - method: "PATCH", - }) - - if (!f.ok) - throw new Error( - `discord: avatar set failed with ${f.status}: ${await f.text()}` - ) - }, -})