ZZZ-Plugin/lib/mysapi/tool.js
2024-08-01 09:00:48 +08:00

116 lines
5.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { generateSeed } from '../../utils/data.js';
import crypto from 'crypto';
/**
* derived from miao-yunzai
*/
export default class ZZZApiTool {
/**
*
* @param {uid} uid
* @param {server} server
*/
constructor(uid, server) {
this.uid = uid;
this.isZZZ = true;
this.server = server;
this.game = 'zzz';
this.uuid = crypto.randomUUID();
if (['prod_gf_cn'].includes(this.server)) {
this.gameBiz = 'nap_cn';
this.host = 'https://api-takumi.mihoyo.com/';
this.hostRecord = 'https://api-takumi-record.mihoyo.com/';
this.hostPublicData = 'https://public-data-api.mihoyo.com/';
} else {
this.gameBiz = 'nap_global';
this.host = 'https://sg-public-api.hoyolab.com/';
this.hostRecord = 'https://sg-act-nap-api.hoyolab.com/';
this.hostPublicData = 'https://sg-public-data-api.hoyoverse.com/';
}
this.zzzUrlMap = {
zzzUser: {
url: `${this.host}binding/api/getUserGameRolesByCookie`,
query: `game_biz=${this.gameBiz}&region=${this.server}&game_uid=${this.uid}`,
},
zzzNote: {
url: `${this.hostRecord}event/game_record_zzz/api/zzz/note`,
query: `role_id=${this.uid}&server=${this.server}`,
},
zzzIndex: {
url: `${this.hostRecord}event/game_record_zzz/api/zzz/index`,
query: `lang=zh-cn&role_id=${this.uid}&server=${this.server}`,
},
zzzAvatarList: {
url: `${this.hostRecord}event/game_record_zzz/api/zzz/avatar/basic`,
query: `lang=zh-cn&role_id=${this.uid}&server=${this.server}`,
},
zzzAvatarInfo: {
url: `${this.hostRecord}event/game_record_zzz/api/zzz/avatar/info`,
query: `lang=zh-cn&role_id=${this.uid}&server=${this.server}&need_wiki=false`,
},
zzzBuddyList: {
url: `${this.hostRecord}event/game_record_zzz/api/zzz/buddy/info`,
query: `lang=zh-cn&role_id=${this.uid}&server=${this.server}`,
},
zzzChallenge: {
url: `${this.hostRecord}event/game_record_zzz/api/zzz/challenge`,
query: `lang=zh-cn&role_id=${this.uid}&server=${this.server}&schedule_type=1`,
},
zzzChallengePeriod: {
url: `${this.hostRecord}event/game_record_zzz/api/zzz/challenge`,
query: `lang=zh-cn&role_id=${this.uid}&server=${this.server}&schedule_type=2`,
},
zzzAuthKey: {
url: `${this.host}binding/api/genAuthKey`,
body: {
auth_appid: 'webview_gacha',
game_biz: this.gameBiz,
game_uid: this.uid * 1,
region: this.server,
},
dsSalt: 'web',
},
};
}
getUrlMap = (data = {}) => {
let urlMap = {
zzz: {
...(['prod_gf_cn'].includes(this.server)
? {
getFp: {
url: `${this.hostPublicData}device-fp/api/getFp`,
body: {
seed_id: `${generateSeed(13)}`,
device_id: data.deviceId,
platform: '1',
seed_time: new Date().getTime() + '',
ext_fields: `{"romRemain":"16357","romCapacity":"121947","osVersion":"15.7.1","ramCapacity":"3662","ramRemain":"62","appUpdateTimeDiff":"1722253089969","isJailBreak":"0","cpuCores":"6","magnetometer":"-205.693817x20.642471x-103.278427","vendor":"中国电信","networkType":"WIFI","gyroscope":"0.371554x0.804200x-0.526751","appMemory":"82","packageName":"com.miHoYo.mhybbs","model":"iPhone13,2","hasVpn":"1","appInstallTimeDiff":"1722253055560","screenBrightness":"0.063","cpuType":"CPU_TYPE_ARM64","chargeStatus":"1","packageVersion":"2.20.1","IDFV":"${data.deviceId.toUpperCase()}","deviceName":"navel","buildTime":"1719312801323","accelerometer":"0.044586x-0.842255x-0.624100","screenSize":"390×844","proxyStatus":"1","isPushEnabled":"0","isSimInserted":"1","batteryStatus":"46"}`,
bbs_device_id: data.deviceId,
app_name: 'bbs_cn',
device_fp: '38d7fc717dc22',
},
noDs: true,
},
}
: {
getFp: {
url: `${this.hostPublicData}device-fp/api/getFp`,
body: {
seed_id: `${this.uuid}`,
device_id: '35315696b7071100',
hoyolab_device_id: `${this.uuid}`,
platform: '2',
seed_time: new Date().getTime() + '',
ext_fields: `{"proxyStatus":1,"isRoot":1,"romCapacity":"512","deviceName":"Xperia 1","productName":"J9110","romRemain":"483","hostname":"BuildHost","screenSize":"1096x2434","isTablet":0,"model":"J9110","brand":"Sony","hardware":"qcom","deviceType":"J9110","devId":"REL","serialNumber":"unknown","sdCapacity":107433,"buildTime":"1633631032000","buildUser":"BuildUser","simState":1,"ramRemain":"98076","appUpdateTimeDiff":1716545162858,"deviceInfo":"Sony\/J9110\/J9110:11\/55.2.A.4.332\/055002A004033203408384484:user\/release-keys","buildType":"user","sdkVersion":"30","ui_mode":"UI_MODE_TYPE_NORMAL","isMockLocation":0,"cpuType":"arm64-v8a","isAirMode":0,"ringMode":2,"app_set_id":"${this.uuid}","chargeStatus":1,"manufacturer":"Sony","emulatorStatus":0,"appMemory":"512","adid":"${this.uuid}","osVersion":"11","vendor":"unknown","accelerometer":"-0.9233304x7.574181x6.472585","sdRemain":97931,"buildTags":"release-keys","packageName":"com.mihoyo.hoyolab","networkType":"WiFi","debugStatus":1,"ramCapacity":"107433","magnetometer":"-9.075001x-27.300001x-3.3000002","display":"55.2.A.4.332","appInstallTimeDiff":1716489549794,"packageVersion":"","gyroscope":"0.027029991x-0.04459185x0.032222193","batteryStatus":45,"hasKeyboard":0,"board":"msmnile"}`,
app_name: 'bbs_oversea',
device_fp: '38d7f2352506c',
},
noDs: true,
},
}),
...this.zzzUrlMap,
},
};
return urlMap[this.game];
};
}