mirror of
https://github.com/ibratabian17/OpenParty.git
synced 2026-01-15 14:22:54 -03:00
Improve Account Ticket gen
This commit is contained in:
@@ -72,6 +72,22 @@ function addUser(profileId, userProfile) {
|
||||
const dataFilePath = path.join(getSavefilePath(), `/account/profiles/user.json`);
|
||||
saveUserData(dataFilePath, decryptedData);
|
||||
}
|
||||
// Add a new user
|
||||
function addUserId(profileId, userId) {
|
||||
if (decryptedData[profileId]) {
|
||||
decryptedData[profileId].userId = userId;
|
||||
const dataFilePath = path.join(getSavefilePath(), `/account/profiles/user.json`);
|
||||
saveUserData(dataFilePath, decryptedData);
|
||||
} else {
|
||||
console.log(`[ACC] User ${profileId} not found`)
|
||||
}
|
||||
}
|
||||
|
||||
function updateUserTicket(profileId, Ticket) {
|
||||
decryptedData[profileId.ticket] = Ticket;
|
||||
const dataFilePath = path.join(getSavefilePath(), `/account/profiles/user.json`);
|
||||
saveUserData(dataFilePath, decryptedData);
|
||||
}
|
||||
|
||||
// Helper function to read the leaderboard
|
||||
function readLeaderboard(isDotw = false) {
|
||||
@@ -150,8 +166,14 @@ if (!decryptedData) {
|
||||
loadUserData(dataFilePath);
|
||||
}
|
||||
|
||||
// Initialize routes
|
||||
exports.initroute = (app) => {
|
||||
module.exports = {
|
||||
loadUserData,
|
||||
addUser,
|
||||
addUserId,
|
||||
updateUserTicket,
|
||||
cachedLeaderboard,
|
||||
cachedDotw,
|
||||
initroute: (app) => {
|
||||
|
||||
// Endpoint to get profiles based on profileIds
|
||||
app.get("/profile/v2/profiles", async (req, res) => {
|
||||
@@ -170,6 +192,10 @@ exports.initroute = (app) => {
|
||||
// If the profile is found in the local data
|
||||
if (userProfile && userProfile.name) {
|
||||
console.log(`[ACC] Account Found For: `, profileId);
|
||||
if (!findUserFromTicket(ticket)) {
|
||||
decryptedData[profileId].ticket = ticket;
|
||||
console.log('[ACC] Updated Ticket For ', userProfile.name)
|
||||
}
|
||||
return { ...userProfile, ip: req.clientIp, ticket: '', profileId };
|
||||
} else {
|
||||
// If the profile is not found locally, fetch from external source
|
||||
@@ -216,6 +242,7 @@ exports.initroute = (app) => {
|
||||
|
||||
|
||||
app.post("/profile/v2/profiles", (req, res) => {
|
||||
try {
|
||||
const ticket = req.header("Authorization");
|
||||
const content = req.body;
|
||||
content.ticket = ticket;
|
||||
@@ -244,6 +271,7 @@ exports.initroute = (app) => {
|
||||
|
||||
// Save updated user profile data
|
||||
decryptedData[matchedProfileId] = userProfile;
|
||||
console.error("[ACC] Updated User ", matchedProfileId);
|
||||
saveUserData(dataFilePath, decryptedData);
|
||||
|
||||
// Regenerate Leaderboard List
|
||||
@@ -255,6 +283,9 @@ exports.initroute = (app) => {
|
||||
console.error("[ACC] Can't Find UUID: ", matchedProfileId);
|
||||
res.status(404).send("Profile not found.");
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -382,3 +413,4 @@ exports.initroute = (app) => {
|
||||
res.send(["00000000-0000-0000-0000-000000000000"]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -8,8 +8,9 @@ const core = {
|
||||
generateCoopCarousel: require('../carousel/carousel').generateCoopCarousel,
|
||||
updateMostPlayed: require('../carousel/carousel').updateMostPlayed,
|
||||
signer: require('../lib/signUrl'),
|
||||
ipResolver: require('../lib/ipResolver')
|
||||
ipResolver: require('../lib/ipResolver'),
|
||||
};
|
||||
const { addUserId, updateUserTicket } = require('./account');
|
||||
const settings = require('../../settings.json');
|
||||
const cachedTicket = {};
|
||||
const ipCache = {}; // Cache untuk menyimpan ticket berdasarkan IP
|
||||
@@ -41,7 +42,7 @@ const getCountryFromIp = (ip) => 'US';
|
||||
const generateFalseTicket = () => {
|
||||
const start = "ew0KIC";
|
||||
const end = "KfQ==";
|
||||
const middleLength = 40;
|
||||
const middleLength = 60;
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let middle = '';
|
||||
|
||||
@@ -79,6 +80,8 @@ exports.initroute = (app, express, server) => {
|
||||
|
||||
const response = await axios.post(`${prodwsurl}/v3/profiles/sessions`, req.body, { headers });
|
||||
res.send(response.data);
|
||||
addUserId(response.data.profileId, response.data.userId)
|
||||
updateUserTicket(response.data.profileId, `Ubi_v1 ${response.data.ticket}`)
|
||||
console.log("[ACC] Using Official Ticket");
|
||||
} catch (error) {
|
||||
console.log("[ACC] Error fetching from Ubisoft services", error.message);
|
||||
@@ -114,7 +117,7 @@ exports.initroute = (app, express, server) => {
|
||||
serverTime: now.toISOString(),
|
||||
sessionId,
|
||||
sessionKey: "TqCz5+J0w9e8qpLp/PLr9BCfAc30hKlEJbN0Xr+mbZa=",
|
||||
rememberMeTicket: null
|
||||
rememberMeTicket: null,
|
||||
};
|
||||
|
||||
// Cache the session based on the IP
|
||||
|
||||
Reference in New Issue
Block a user