Skip to content

Commit

Permalink
Added token rotation support for yandex
Browse files Browse the repository at this point in the history
  • Loading branch information
Azarattum committed Apr 21, 2024
1 parent 467bc08 commit b697505
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions plugins/yandex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ import { auth, header, transform } from "./meta";
import { array } from "@amadeus-music/core";
import { createHash } from "node:crypto";

init(function* ({ yandex: { token } }) {
if (!token) throw "No token found!";
init(function* ({ yandex: { tokens } }) {
if (!tokens.length) throw "No token found!";
this.connect.baseURL = "wss://uniproxy.alice.yandex.net/uni.ws";
this.fetch.baseURL = "https://api.music.yandex.net/";
this.fetch.params = { page: "0" };
this.fetch.tls = "TLSv1.2";
this.fetch.headers = {
"X-Yandex-Music-Client": "YandexMusicAndroid/24023621",
Authorization: tokens.map((x) => `OAuth ${x}`),
"User-Agent": "Yandex-Music-API",
Authorization: `OAuth ${token}`,
};
});

Expand Down
10 changes: 8 additions & 2 deletions plugins/yandex/plugin.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -21,6 +27,6 @@ export const {
name,
version,
config: {
yandex: defaulted(object({ token: defaulted(string(), "") }), {}),
yandex: defaulted(object({ tokens: defaulted(array(string()), []) }), {}),
},
});

0 comments on commit b697505

Please sign in to comment.