mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
fix:fp统一使用ltuid
This commit is contained in:
parent
9429a60ec0
commit
69d9d95568
2 changed files with 37 additions and 82 deletions
118
lib/plugin.js
118
lib/plugin.js
|
|
@ -86,43 +86,46 @@ export class ZZZPlugin extends plugin {
|
|||
throw new Error('ltuid为空');
|
||||
}
|
||||
// 获取设备指纹
|
||||
let deviceFp;
|
||||
let bindInfo = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:BIND`);
|
||||
if (bindInfo) {
|
||||
deviceFp = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
||||
let data = {
|
||||
deviceFp,
|
||||
};
|
||||
try {
|
||||
bindInfo = JSON.parse(bindInfo);
|
||||
let deviceFp = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
||||
let data = {};
|
||||
if (!deviceFp) {
|
||||
let bindInfo = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:BIND`);
|
||||
if (bindInfo) {
|
||||
deviceFp = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
||||
data = {
|
||||
productName: bindInfo?.deviceProduct,
|
||||
deviceType: bindInfo?.deviceName,
|
||||
modelName: bindInfo?.deviceModel,
|
||||
oaid: bindInfo?.oaid,
|
||||
osVersion: bindInfo?.androidVersion,
|
||||
deviceInfo: bindInfo?.deviceFingerprint,
|
||||
board: bindInfo?.deviceBoard,
|
||||
deviceFp,
|
||||
};
|
||||
} catch (error) {
|
||||
bindInfo = null;
|
||||
}
|
||||
if (!deviceFp) {
|
||||
const sdk = api.getUrl('getFp', data);
|
||||
const res = await request(sdk.url, {
|
||||
headers: sdk.headers,
|
||||
method: 'POST',
|
||||
body: sdk.body,
|
||||
});
|
||||
const fpRes = await res.json();
|
||||
logger.debug(`[米游社][设备指纹]${JSON.stringify(fpRes)}`);
|
||||
deviceFp = fpRes?.data?.device_fp;
|
||||
if (!deviceFp) {
|
||||
return { api: null, uid: null, deviceFp: null };
|
||||
try {
|
||||
bindInfo = JSON.parse(bindInfo);
|
||||
data = {
|
||||
productName: bindInfo?.deviceProduct,
|
||||
deviceType: bindInfo?.deviceName,
|
||||
modelName: bindInfo?.deviceModel,
|
||||
oaid: bindInfo?.oaid,
|
||||
osVersion: bindInfo?.androidVersion,
|
||||
deviceInfo: bindInfo?.deviceFingerprint,
|
||||
board: bindInfo?.deviceBoard,
|
||||
};
|
||||
} catch (error) {
|
||||
bindInfo = null;
|
||||
}
|
||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:FP`, deviceFp, {
|
||||
EX: 86400 * 7,
|
||||
});
|
||||
}
|
||||
const sdk = api.getUrl('getFp', data);
|
||||
const res = await request(sdk.url, {
|
||||
headers: sdk.headers,
|
||||
method: 'POST',
|
||||
body: sdk.body,
|
||||
});
|
||||
const fpRes = await res.json();
|
||||
logger.debug(`[米游社][设备指纹]${JSON.stringify(fpRes)}`);
|
||||
deviceFp = fpRes?.data?.device_fp;
|
||||
if (!deviceFp) {
|
||||
return { api: null, uid: null, deviceFp: null };
|
||||
}
|
||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:FP`, deviceFp, {
|
||||
EX: 86400 * 7,
|
||||
});
|
||||
if (!/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
||||
data['deviceFp'] = deviceFp;
|
||||
const deviceLogin = api.getUrl('deviceLogin', data);
|
||||
const saveDevice = api.getUrl('saveDevice', data);
|
||||
|
|
@ -147,53 +150,6 @@ export class ZZZPlugin extends plugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
deviceFp = await redis.get(`ZZZ:DEVICE_FP:${uid}:FP`);
|
||||
let data = {
|
||||
deviceFp,
|
||||
};
|
||||
if (!deviceFp) {
|
||||
const sdk = api.getUrl('getFp');
|
||||
const res = await request(sdk.url, {
|
||||
headers: sdk.headers,
|
||||
method: 'POST',
|
||||
body: sdk.body,
|
||||
});
|
||||
const fpRes = await res.json();
|
||||
logger.debug(`[米游社][设备指纹]${JSON.stringify(fpRes)}`);
|
||||
deviceFp = fpRes?.data?.device_fp;
|
||||
if (!deviceFp) {
|
||||
return { api: null, uid: null, deviceFp: null };
|
||||
}
|
||||
await redis.set(`ZZZ:DEVICE_FP:${uid}:FP`, deviceFp, {
|
||||
EX: 86400 * 7,
|
||||
});
|
||||
if (!/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
||||
data['deviceFp'] = deviceFp;
|
||||
const deviceLogin = api.getUrl('deviceLogin', data);
|
||||
const saveDevice = api.getUrl('saveDevice', data);
|
||||
if (!!deviceLogin && !!saveDevice) {
|
||||
logger.debug(`[米游社][设备登录]保存设备信息`);
|
||||
try {
|
||||
logger.debug(`[米游社][设备登录]${JSON.stringify(deviceLogin)}`);
|
||||
const login = await request(deviceLogin.url, {
|
||||
headers: deviceLogin.headers,
|
||||
method: 'POST',
|
||||
body: deviceLogin.body,
|
||||
});
|
||||
const save = await request(saveDevice.url, {
|
||||
headers: saveDevice.headers,
|
||||
method: 'POST',
|
||||
body: saveDevice.body,
|
||||
});
|
||||
const result = await Promise.all([login.json(), save.json()]);
|
||||
logger.debug(`[米游社][设备登录]${JSON.stringify(result)}`);
|
||||
} catch (error) {
|
||||
logger.error(`[米游社][设备登录]${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 返回数据(API、UID、设备指纹)
|
||||
return { api, uid, deviceFp };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue