Skip to content

Commit

Permalink
fix:移除解密
Browse files Browse the repository at this point in the history
  • Loading branch information
CikeyQi committed Oct 14, 2024
1 parent 9173aed commit 82ae248
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion apps/Calabash.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Calabash extends plugin {

if (!accountList.length) {
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
let publicCookie = await waves.getPublicCookie();
let publicCookie = await waves.pubCookie();
if (!publicCookie) {
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定');
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/Challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Challenge extends plugin {

if (!accountList.length) {
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
let publicCookie = await waves.getPublicCookie();
let publicCookie = await waves.pubCookie();
if (!publicCookie) {
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定');
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Character extends plugin {

if (!accountList.length) {
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
let publicCookie = await waves.getPublicCookie();
let publicCookie = await waves.pubCookie();
if (!publicCookie) {
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定');
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/Explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Explore extends plugin {

if (!accountList.length) {
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
let publicCookie = await waves.getPublicCookie();
let publicCookie = await waves.pubCookie();
if (!publicCookie) {
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定');
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/Tower.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class TowerInfo extends plugin {

if (!accountList.length) {
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
let publicCookie = await waves.getPublicCookie();
let publicCookie = await waves.pubCookie();
if (!publicCookie) {
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定');
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class UserInfo extends plugin {

if (!accountList.length) {
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
let publicCookie = await waves.getPublicCookie();
let publicCookie = await waves.pubCookie();
if (!publicCookie) {
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定');
} else {
Expand Down
27 changes: 9 additions & 18 deletions components/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Waves {
const response = await axios.post(CONSTANTS.BASE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } });

if (response.data.code === 200) {
response.data.data = await this.decryptData(response.data.data)
response.data.data = JSON.parse(response.data.data)
if (response.data.data === null) {
logger.info('获取我的资料失败,返回数据为null');
return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" };
Expand Down Expand Up @@ -182,7 +182,7 @@ class Waves {
const response = await axios.post(CONSTANTS.ROLE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } });

if (response.data.code === 200) {
response.data.data = await this.decryptData(response.data.data)
response.data.data = JSON.parse(response.data.data)
if (response.data.data === null) {
logger.info('获取共鸣者失败,返回数据为null');
return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" };
Expand Down Expand Up @@ -214,7 +214,7 @@ class Waves {
const response = await axios.post(CONSTANTS.CALABASH_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } });

if (response.data.code === 200) {
response.data.data = await this.decryptData(response.data.data)
response.data.data = JSON.parse(response.data.data)
if (response.data.data === null) {
logger.info('获取数据坞失败,返回数据为null');
return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" };
Expand Down Expand Up @@ -247,7 +247,7 @@ class Waves {
const response = await axios.post(CONSTANTS.CHALLENGE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } });

if (response.data.code === 200) {
response.data.data = await this.decryptData(response.data.data)
response.data.data = JSON.parse(response.data.data)
if (response.data.data === null) {
logger.info('获取挑战数据失败,返回数据为null');
return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" };
Expand Down Expand Up @@ -280,7 +280,7 @@ class Waves {
const response = await axios.post(CONSTANTS.EXPLORE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } });

if (response.data.code === 200) {
response.data.data = await this.decryptData(response.data.data)
response.data.data = JSON.parse(response.data.data)
if (response.data.data === null) {
logger.info('获取探索数据失败,返回数据为null');
return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" };
Expand Down Expand Up @@ -312,7 +312,7 @@ class Waves {
const response = await axios.post(CONSTANTS.ROLE_DETAIL_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } });

if (response.data.code === 200) {
response.data.data = await this.decryptData(response.data.data)
response.data.data = JSON.parse(response.data.data)
if (response.data.data === null) {
logger.info('获取角色详细信息失败,返回数据为null');
return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" };
Expand Down Expand Up @@ -377,11 +377,11 @@ class Waves {
const response = await axios.post(CONSTANTS.SELF_TOWER_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token, devcode: '' } });

if (response.data.code === 200) {
response.data.data = await this.decryptData(response.data.data)
response.data.data = JSON.parse(response.data.data)
if (response.data.data === null) {
const otherResponse = await axios.post(CONSTANTS.OTHER_TOWER_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token, devcode: '' } });
if (otherResponse.data.code === 200) {
otherResponse.data.data = await this.decryptData(otherResponse.data.data)
otherResponse.data.data = JSON.parse(otherResponse.data.data)
if (otherResponse.data.data === null) {
logger.info('获取逆境深塔数据失败,返回数据为null');
return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" };
Expand Down Expand Up @@ -431,7 +431,7 @@ class Waves {
}

// 获取公共Cookie
async getPublicCookie() {
async pubCookie() {
if (!Config.getConfig().use_public_cookie) return false;

const keys = await redis.keys('Yunzai:waves:users:*');
Expand Down Expand Up @@ -476,15 +476,6 @@ class Waves {
return { status: false, msg: '获取活动列表失败,疑似网络问题,请检查控制台日志' };
}
}

// 解密数据
async decryptData(value) {
const key = Buffer.from("XSNLFgNCth8j8oJI3cNIdw==", 'base64');
const encrypted = Buffer.from(value, 'base64');
const decipher = crypto.createDecipheriv('aes-128-ecb', key, null);
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
return JSON.parse(decrypted.toString('utf8'));
}
}

export default Waves;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "waves-plugin",
"version": "1.4.5",
"version": "1.4.6",
"description": "基于 Yunzai 的鸣潮游戏数据查询插件",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 82ae248

Please sign in to comment.