feat: discord cookie

This commit is contained in:
May 2024-11-21 21:02:59 -08:00
parent 40600f8439
commit 7da7cc8b3a
Signed by: split
GPG key ID: C325C61F0BF517C0
2 changed files with 16 additions and 5 deletions

View file

@ -14,6 +14,7 @@ All settings for endpoints are configured in query parameters.
### `/discord` ### `/discord`
- `token`: Discord token - `token`: Discord token
- `cookie`: Cookie header, b64-encoded
### `/misskey` ### `/misskey`

View file

@ -2,8 +2,11 @@ import { z } from "zod"
import { translator } from "../lib/types.js" import { translator } from "../lib/types.js"
import downloadAvatarForPayload from "../lib/downloadAvatarForPayload.js" import downloadAvatarForPayload from "../lib/downloadAvatarForPayload.js"
export default translator({ export default translator({
query: z.object({ token: z.string().describe("Discord token") }), query: z.object({
async execute(payload, { token }) { token: z.string().describe("Discord token"),
cookie: z.string().describe(`Cookie header, b64-encoded`),
}),
async execute(payload, { token, cookie }) {
let avatar = await downloadAvatarForPayload(payload, [ let avatar = await downloadAvatarForPayload(payload, [
"png", "png",
"jpeg", "jpeg",
@ -30,15 +33,22 @@ export default translator({
"X-Super-Properties": Buffer.from( "X-Super-Properties": Buffer.from(
JSON.stringify({ JSON.stringify({
os: "Windows", os: "Windows",
browser: "Discord Client", browser: "Chrome",
os_arch: "x64", device: "",
system_locale: "en-US", system_locale: "en-US",
os_version: "10.0.22621", browser_user_agent: ua,
browser_version,
os_version: "10",
referrer: "",
referring_domain: "",
referrer_current: "",
referring_domain_current: "",
release_channel: "stable", release_channel: "stable",
client_build_number, client_build_number,
client_event_source: null, client_event_source: null,
}) })
).toString("base64"), ).toString("base64"),
cookie: Buffer.from(cookie, "base64").toString(),
"X-Discord-Locale": "en-US", "X-Discord-Locale": "en-US",
"X-Discord-Timezone": "America/Los_Angeles", "X-Discord-Timezone": "America/Los_Angeles",
"X-Debug-Options": "bugReporterEnabled", "X-Debug-Options": "bugReporterEnabled",