mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-10 10:57:08 +02:00
Safer Basic Auth
This commit is contained in:
@@ -33,7 +33,8 @@ module.exports = class GitHubCommand extends Command {
|
||||
async run(msg, { author, repository }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://${GITHUB_USERNAME}:${GITHUB_PASSWORD}@api.github.com/repos/${author}/${repository}`);
|
||||
.get(`https://api.github.com/repos/${author}/${repository}`)
|
||||
.set({ Authorization: `Basic ${Buffer.from(`${GITHUB_USERNAME}:${GITHUB_PASSWORD}`).toString('base64')}` });
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFFFFFF)
|
||||
.setAuthor('GitHub', 'https://i.imgur.com/e4HunUm.png', 'https://github.com/')
|
||||
|
||||
@@ -29,8 +29,9 @@ module.exports = class MyAnimeListAnimeCommand extends Command {
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get(`https://${MAL_USERNAME}:${MAL_PASSWORD}@myanimelist.net/api/anime/search.xml`)
|
||||
.query({ q: query });
|
||||
.get('https://myanimelist.net/api/anime/search.xml')
|
||||
.query({ q: query })
|
||||
.set({ Authorization: `Basic ${Buffer.from(`${MAL_USERNAME}:${MAL_PASSWORD}`).toString('base64')}` });
|
||||
const body = await xml(text);
|
||||
const data = body.anime.entry[0];
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
@@ -29,8 +29,9 @@ module.exports = class MyAnimeListMangaCommand extends Command {
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get(`https://${MAL_USERNAME}:${MAL_PASSWORD}@myanimelist.net/api/manga/search.xml`)
|
||||
.query({ q: query });
|
||||
.get('https://myanimelist.net/api/manga/search.xml')
|
||||
.query({ q: query })
|
||||
.set({ Authorization: `Basic ${Buffer.from(`${MAL_USERNAME}:${MAL_PASSWORD}`).toString('base64')}` });
|
||||
const body = await xml(text);
|
||||
const data = body.manga.entry[0];
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
@@ -61,11 +61,10 @@ module.exports = class TwitterCommand extends Command {
|
||||
}
|
||||
|
||||
async fetchToken() {
|
||||
const auth = Buffer.from(`${TWITTER_KEY}:${TWITTER_SECRET}`).toString('base64');
|
||||
const { body } = await snekfetch
|
||||
.post('https://api.twitter.com/oauth2/token')
|
||||
.set({
|
||||
Authorization: `Basic ${auth}`,
|
||||
Authorization: `Basic ${Buffer.from(`${TWITTER_KEY}:${TWITTER_SECRET}`).toString('base64')}`,
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
})
|
||||
.send('grant_type=client_credentials');
|
||||
|
||||
Reference in New Issue
Block a user