From f3650a1135dc9d4262cf29e253cb22f572e48bc4 Mon Sep 17 00:00:00 2001 From: Azarattum Date: Sun, 21 Apr 2024 23:35:18 +0700 Subject: [PATCH] Added token rotation support for VK --- plugins/vk/index.ts | 6 +++--- plugins/vk/plugin.ts | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/vk/index.ts b/plugins/vk/index.ts index fefdd138..88c8db2a 100644 --- a/plugins/vk/index.ts +++ b/plugins/vk/index.ts @@ -20,10 +20,10 @@ import { import { array, optional } from "@amadeus-music/core"; import { safeFetch } from "./captcha"; -init(function* ({ vk: { token } }) { - if (!token) throw "No token found!"; +init(function* ({ vk: { tokens } }) { + if (!tokens.length) throw "No token found!"; this.fetch.baseURL = "https://api.vk.me/method/"; - this.fetch.params = { v: "5.190", access_token: token }; + this.fetch.params = { v: "5.190", access_token: tokens }; this.fetch.headers = { "User-Agent": "Mrs.ia/1520 CFNetwork/1331.0.7 Darwin/21.4.0", }; diff --git a/plugins/vk/plugin.ts b/plugins/vk/plugin.ts index 61c7bb0e..2d53a8ab 100644 --- a/plugins/vk/plugin.ts +++ b/plugins/vk/plugin.ts @@ -1,4 +1,10 @@ -import { string, defaulted, object, register } from "@amadeus-music/core"; +import { + defaulted, + register, + string, + object, + array, +} from "@amadeus-music/core"; import { name, version } from "./package.json"; export const { @@ -17,6 +23,6 @@ export const { name, version, config: { - vk: defaulted(object({ token: defaulted(string(), "") }), {}), + vk: defaulted(object({ tokens: defaulted(array(string()), []) }), {}), }, });