From eaedbdbcb99f0db2958db77546ace9017b836099 Mon Sep 17 00:00:00 2001 From: Lawin0129 Date: Sat, 29 Jan 2022 19:47:51 +0000 Subject: [PATCH] Add config display name + change some files around --- .../catalog_config.json | 20 ++-- Config/config.ini | 3 + config.json | 3 - index.js | 96 ++++++++++++------- memory.json | 7 ++ package-lock.json | 5 + package.json | 1 + season.json | 6 -- 8 files changed, 88 insertions(+), 53 deletions(-) rename catalog_config.json => Config/catalog_config.json (94%) create mode 100644 Config/config.ini delete mode 100644 config.json create mode 100644 memory.json delete mode 100644 season.json diff --git a/catalog_config.json b/Config/catalog_config.json similarity index 94% rename from catalog_config.json rename to Config/catalog_config.json index 6d54b3a..f815bb0 100644 --- a/catalog_config.json +++ b/Config/catalog_config.json @@ -1,11 +1,11 @@ -{ - "//": "BR Item shop config", - "daily1": "", - "daily2": "", - "daily3": "", - "daily4": "", - "daily5": "", - "daily6": "", - "featured1": "", - "featured2": "" +{ + "//": "BR Item shop config", + "daily1": "", + "daily2": "", + "daily3": "", + "daily4": "", + "daily5": "", + "daily6": "", + "featured1": "", + "featured2": "" } \ No newline at end of file diff --git a/Config/config.ini b/Config/config.ini new file mode 100644 index 0000000..4cdfda6 --- /dev/null +++ b/Config/config.ini @@ -0,0 +1,3 @@ +[Config] +bUseConfigDisplayName=false # If this is set to false, it will use the email to display name method. +displayName=LawinServer # Your fortnite display name. \ No newline at end of file diff --git a/config.json b/config.json deleted file mode 100644 index be253a1..0000000 --- a/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "currentbuildUniqueId": "" -} \ No newline at end of file diff --git a/index.js b/index.js index 8bd312e..a2e5b28 100644 --- a/index.js +++ b/index.js @@ -3,12 +3,15 @@ const express = Express(); const fs = require("fs"); const crypto = require("crypto"); const path = require("path"); -const config = require("./config.json"); +const iniparser = require("ini"); +const config = iniparser.parse(fs.readFileSync(path.join(__dirname, "Config", "config.ini")).toString()); +const memory = require("./memory.json"); const friendslist = require("./responses/friendslist.json"); const friendslist2 = require("./responses/friendslist2.json"); const keychain = require("./responses/keychain.json"); const privacy = require("./responses/privacy.json"); const catalog = getItemShop(); +var Memory_CurrentAccountID = makeid().replace(/-/ig, ""); express.use(function(req, res, next) { // Getting the raw body of a request for client saving if (req.originalUrl.includes('/fortnite/api/cloudstorage/user/')) { @@ -43,7 +46,7 @@ express.get("/clearitemsforshop", async (req, res) => { res.set("Content-Type", "text/plain"); const athena = require("./profiles/athena.json"); - const CatalogConfig = require("./catalog_config.json"); + const CatalogConfig = require("./Config/catalog_config.json"); for (var value in CatalogConfig) { for (var key in athena.items) { @@ -316,11 +319,17 @@ express.get("/lightswitch/api/service/bulk/status", async (req, res) => { }) express.get("/account/api/public/account", async (req, res) => { + var displayName = config.Config.displayName; + + if (config.Config.bUseConfigDisplayName == false) { + displayName = req.query.accountId; + } + res.json( [ { "id": req.query.accountId, - "displayName": req.query.accountId, + "displayName": displayName, "externalAuths": {} }, { @@ -544,11 +553,17 @@ express.get("/account/api/public/account", async (req, res) => { }) express.get("/account/api/public/account/:accountId", async (req, res) => { + var displayName = config.Config.displayName; + + if (config.Config.bUseConfigDisplayName == false) { + displayName = req.params.accountId; + } + res.json({ "id": req.params.accountId, - "displayName": req.params.accountId, + "displayName": displayName, "name": "Lawin", - "email": req.params.accountId + "@lawin.com", + "email": displayName + "@lawin.com", "failedLoginAttempts": 0, "lastLogin": new Date().toISOString(), "numberOfDisplayNameChanges": 0, @@ -602,9 +617,9 @@ express.get("/account/api/epicdomains/ssodomains", async (req, res) => { }) express.get("/fortnite/api/game/v2/matchmakingservice/ticket/player/*", async (req, res) => { - config.currentbuildUniqueId = req.query.bucketId.split(":")[0]; + memory.currentbuildUniqueId = req.query.bucketId.split(":")[0]; - fs.writeFileSync("./config.json", JSON.stringify(config, null, 2)); + fs.writeFileSync("./memory.json", JSON.stringify(memory, null, 2)); res.json({ "serviceUrl": "ws://127.0.0.1:80", @@ -661,7 +676,7 @@ express.get("/fortnite/api/matchmaking/session/:session_id", async (req, res) => "usesPresence": false, "allowJoinViaPresence": true, "allowJoinViaPresenceFriendsOnly": false, - "buildUniqueId": config.currentbuildUniqueId, // buildUniqueId is different for every build, this uses the netver of the version you're currently using + "buildUniqueId": memory.currentbuildUniqueId, // buildUniqueId is different for every build, this uses the netver of the version you're currently using "lastUpdated": new Date().toISOString(), "started": false }) @@ -744,7 +759,7 @@ express.get("/fortnite/api/cloudstorage/system", async (req, res) => { .json() } const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); if (seasondata.season == 10) { return res.status(404).json(); @@ -799,7 +814,7 @@ express.get("/fortnite/api/cloudstorage/user/*/:file", async (req, res) => { } const seasonchecker = require("./seasonchecker.js") - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); var currentBuildID = seasondata.CL; @@ -817,7 +832,7 @@ express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => { res.set("Content-Type", "application/json") const seasonchecker = require("./seasonchecker.js") - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); var currentBuildID = seasondata.CL; @@ -848,7 +863,7 @@ express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => { express.put("/fortnite/api/cloudstorage/user/*/*", async (req, res) => { const seasonchecker = require("./seasonchecker.js") - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); var currentBuildID = seasondata.CL; @@ -875,7 +890,7 @@ express.get("/friends/api/v1/*/summary", async (req, res) => { express.get("/fortnite/api/calendar/v1/timeline", async (req, res) => { const seasonchecker = require("./seasonchecker.js") - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); var activeEvents = [ @@ -1168,6 +1183,12 @@ express.get("/fortnite/api/storefront/v2/keychain", async (req, res) => { }) express.get("/account/api/oauth/verify", async (req, res) => { + var displayName = config.Config.displayName; + + if (config.Config.bUseConfigDisplayName == false) { + displayName = Memory_CurrentAccountID + } + res.json({ "token": "lawinstokenlol", "session_id": "3c3662bcb661d6de679c636744c66b62", @@ -1175,13 +1196,13 @@ express.get("/account/api/oauth/verify", async (req, res) => { "client_id": "lawinsclientidlol", "internal_client": true, "client_service": "fortnite", - "account_id": "LawinServer", + "account_id": Memory_CurrentAccountID, "expires_in": 28800, "expires_at": "9999-12-02T01:12:01.100Z", "auth_method": "exchange_code", - "display_name": "LawinServer", + "display_name": displayName, "app": "fortnite", - "in_app_id": "LawinServer", + "in_app_id": Memory_CurrentAccountID, "device_id": "lawinsdeviceidlol" }) }) @@ -1192,6 +1213,13 @@ express.post("/datarouter/api/v1/public/data", async (req, res) => { }) express.post("/account/api/oauth/token", async (req, res) => { + var displayName = config.Config.displayName; + + if (config.Config.bUseConfigDisplayName == false) { + Memory_CurrentAccountID = req.body.username || "LawinServer" + displayName = req.body.username || "LawinServer" + } + res.json({ "access_token": "lawinstokenlol", "expires_in": 28800, @@ -1200,13 +1228,13 @@ express.post("/account/api/oauth/token", async (req, res) => { "refresh_token": "lawinstokenlol", "refresh_expires": 86400, "refresh_expires_at": "9999-12-02T01:12:01.100Z", - "account_id": req.body.username || "LawinServer", + "account_id": Memory_CurrentAccountID, "client_id": "lawinsclientidlol", "internal_client": true, "client_service": "fortnite", - "displayName": req.body.username || "LawinServer", + "displayName": displayName, "app": "fortnite", - "in_app_id": req.body.username || "LawinServer", + "in_app_id": Memory_CurrentAccountID, "device_id": "lawinsdeviceidlol" }) }) @@ -1409,7 +1437,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/UnlockRewardNode", async (r const profile = require(`./profiles/${req.query.profileId || "athena"}.json`); const common_core = require("./profiles/common_core.json"); const WinterFestIDS = require("./responses/winterfestrewards.json"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); const seasonchecker = require("./seasonchecker.js"); seasonchecker(req, seasondata); @@ -2927,7 +2955,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/PromoteItem", async (req, r // Craft item STW (Guns, melees and traps only) express.post("/fortnite/api/game/v2/profile/*/client/CraftWorldItem", async (req, res) => { - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); const seasonchecker = require("./seasonchecker.js"); seasonchecker(req, seasondata); @@ -3981,7 +4009,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/ClearHeroLoadout", async (r // Recycle items STW express.post("/fortnite/api/game/v2/profile/*/client/RecycleItemBatch", async (req, res) => { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); @@ -5247,7 +5275,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/PurchaseCatalogEntry", asyn if (value.offerId == req.body.offerId) { catalog.storefronts[a].catalogEntries[b].itemGrants.forEach(function(value, c) { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); if (4 > seasondata.season || seasondata.season == 4 && PurchasedLlama == false) { @@ -5566,7 +5594,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/SetItemFavoriteStatusBatch" if (profile.profileId == "athena") { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -5629,7 +5657,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/SetItemFavoriteStatus", asy if (profile.profileId == "athena") { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -5690,7 +5718,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/MarkItemSeen", async (req, if (profile.profileId == "athena") { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -5751,7 +5779,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/MarkItemSeen", async (req, express.post("/fortnite/api/game/v2/profile/*/client/EquipBattleRoyaleCustomization", async (req, res) => { const profile = require("./profiles/athena.json"); const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -5918,7 +5946,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/EquipBattleRoyaleCustomizat express.post("/fortnite/api/game/v2/profile/*/client/SetBattleRoyaleBanner", async (req, res) => { const profile = require("./profiles/athena.json"); const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -5984,7 +6012,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/SetCosmeticLockerBanner", a if (profile.profileId == "athena") { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -6053,7 +6081,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/SetCosmeticLockerSlot", asy if (profile.profileId == "athena") { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -6273,7 +6301,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/*", async (req, res) => { if (profile.profileId == "athena") { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); profile.stats.attributes.season_num = seasondata.season; if (seasondata.season == 2) { @@ -6331,7 +6359,7 @@ express.all("*", async (req, res) => { function getItemShop() { const catalog = JSON.parse(JSON.stringify(require("./responses/catalog.json"))); - const CatalogConfig = require("./catalog_config.json"); + const CatalogConfig = require("./Config/catalog_config.json"); try { for (var value in CatalogConfig) { @@ -6375,7 +6403,7 @@ function getItemShop() { function getTheater(req) { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); var theater = JSON.stringify(require("./responses/worldstw.json")); @@ -6393,7 +6421,7 @@ function getTheater(req) { function getContentPages(req) { const seasonchecker = require("./seasonchecker.js"); - const seasondata = require("./season.json"); + const seasondata = require("./memory.json"); seasonchecker(req, seasondata); const contentpages = JSON.parse(JSON.stringify(require("./responses/contentpages.json"))); diff --git a/memory.json b/memory.json new file mode 100644 index 0000000..f6812b6 --- /dev/null +++ b/memory.json @@ -0,0 +1,7 @@ +{ + "season": 0, + "build": 0.0, + "CL": "", + "lobby": "LobbySeason0", + "currentbuildUniqueId": "" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6ab581d..2a40460 100644 --- a/package-lock.json +++ b/package-lock.json @@ -197,6 +197,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "ini": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ini/-/ini-2.0.0.tgz", + "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==" + }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", diff --git a/package.json b/package.json index 77b72dd..d2a6113 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "crypto": "^1.0.1", "express": "^4.17.2", "fs": "^0.0.1-security", + "ini": "^2.0.0", "path": "^0.12.7" }, "devDependencies": {}, diff --git a/season.json b/season.json deleted file mode 100644 index 3086564..0000000 --- a/season.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "season": 0, - "build": 0.0, - "CL": "", - "lobby": "LobbySeason0" -} \ No newline at end of file