返回提交历史
Modified
src/controllers/api/inventoryController.ts
+19
-3
Modified
src/types/inventoryTypes/inventoryTypes.ts
+62
-48
XFEstudio/SpaceNinjaServer
chore: don't send cheat keys to client in inventory json (#3185)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3185 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
d20dfb8f
代码差异
2 个文件
+81
-51
@@ -7,7 +7,12 @@ import allDialogue from "../../../static/fixed_responses/allDialogue.json" with
7
7
import allPopups from "../../../static/fixed_responses/allPopups.json" with { type: "json" };
8
8
import type { ILoadoutConfigClientLegacy, ILoadoutDatabase, ILoadOutPresets } from "../../types/saveLoadoutTypes.ts";
9
9
import type { IInventoryClient, IShipInventory, IUpgradeClient } from "../../types/inventoryTypes/inventoryTypes.ts";
10
import { equipmentKeys, loadoutKeysLegacy } from "../../types/inventoryTypes/inventoryTypes.ts";
10
import {
11
accountCheatBooleans,
12
accountCheatNumbers,
13
equipmentKeys,
14
loadoutKeysLegacy
15
} from "../../types/inventoryTypes/inventoryTypes.ts";
11
16
import type { IPolarity } from "../../types/inventoryTypes/commonInventoryTypes.ts";
12
17
import { ArtifactPolarity } from "../../types/inventoryTypes/commonInventoryTypes.ts";
13
18
import type { ICountedItem } from "warframe-public-export-plus";
@@ -286,7 +291,8 @@ export const inventoryController: RequestHandler = async (request, response) =>
286
291
await getInventoryResponse(
287
292
inventory,
288
293
"xpBasedLevelCapDisabled" in request.query,
289
"ignoreBuildLabel" in request.query ? undefined : account.BuildLabel
294
"ignoreBuildLabel" in request.query ? undefined : account.BuildLabel,
295
"ignoreBuildLabel" in request.query
290
296
)
291
297
);
292
298
};
@@ -294,7 +300,8 @@ export const inventoryController: RequestHandler = async (request, response) =>
294
300
export const getInventoryResponse = async (
295
301
inventory: TInventoryDatabaseDocument,
296
302
xpBasedLevelCapDisabled: boolean,
297
buildLabel: string | undefined
303
buildLabel: string | undefined,
304
forWebui: boolean = false
298
305
): Promise<IInventoryClient> => {
299
306
const [inventoryWithLoadOutPresets, ships, latestMessage] = await Promise.all([
300
307
inventory.populate<{ LoadOutPresets: ILoadoutDatabase }>("LoadOutPresets"),
@@ -304,6 +311,15 @@ export const getInventoryResponse = async (
304
311
const inventoryResponse = inventoryWithLoadOutPresets.toJSON<IInventoryClient>();
305
312
inventoryResponse.Ships = ships.map(x => x.toJSON<IShipInventory>());
306
313
314
if (!forWebui) {
315
for (const key of accountCheatBooleans) {
316
delete inventoryResponse[key as keyof typeof inventoryResponse];
317
}
318
for (const key of accountCheatNumbers) {
319
delete inventoryResponse[key as keyof typeof inventoryResponse];
320
}
321
}
322
307
323
// In case mission inventory update added an inbox message, we need to send the Mailbox part so the client knows to refresh it.
308
324
if (latestMessage) {
309
325
inventoryResponse.Mailbox = {
@@ -28,54 +28,68 @@ export type InventoryDatabaseEquipment = {
28
28
};
29
29
30
30
// Fields specific to SNS
31
export interface IAccountCheats {
32
skipAllDialogue?: boolean;
33
skipAllPopups?: boolean;
34
dontSubtractPurchaseCreditCost?: boolean;
35
dontSubtractPurchasePlatinumCost?: boolean;
36
dontSubtractPurchaseItemCost?: boolean;
37
dontSubtractPurchaseStandingCost?: boolean;
38
dontSubtractVoidTraces?: boolean;
39
dontSubtractConsumables?: boolean;
40
finishInvasionsInOneMission?: boolean;
41
infiniteCredits?: boolean;
42
infinitePlatinum?: boolean;
43
infiniteEndo?: boolean;
44
infiniteRegalAya?: boolean;
45
infiniteHelminthMaterials?: boolean;
46
universalPolarityEverywhere?: boolean;
47
unlockDoubleCapacityPotatoesEverywhere?: boolean;
48
unlockExilusEverywhere?: boolean;
49
unlockArcanesEverywhere?: boolean;
50
alertsRepeatable?: boolean;
51
syndicateMissionsRepeatable?: boolean;
52
instantFinishRivenChallenge?: boolean;
53
noDailyStandingLimits?: boolean;
54
noDailyFocusLimit?: boolean;
55
noArgonCrystalDecay?: boolean;
56
noMasteryRankUpCooldown?: boolean;
57
noVendorPurchaseLimits?: boolean;
58
noDeathMarks?: boolean;
59
noKimCooldowns?: boolean;
60
noBlessingCooldown?: boolean;
61
claimingBlueprintRefundsIngredients?: boolean;
62
instantResourceExtractorDrones?: boolean;
63
noResourceExtractorDronesDamage?: boolean;
64
missionsCanGiveAllRelics?: boolean;
65
exceptionalRelicsAlwaysGiveBronzeReward?: boolean;
66
flawlessRelicsAlwaysGiveSilverReward?: boolean;
67
radiantRelicsAlwaysGiveGoldReward?: boolean;
68
disableDailyTribute?: boolean;
69
nemesisHenchmenKillsMultiplierGrineer?: number;
70
nemesisHenchmenKillsMultiplierCorpus?: number;
71
nemesisAntivirusGainMultiplier?: number;
72
nemesisHintProgressMultiplierGrineer?: number;
73
nemesisHintProgressMultiplierCorpus?: number;
74
nemesisExtraWeapon?: number;
75
spoofMasteryRank?: number;
76
relicRewardItemCountMultiplier?: number;
77
nightwaveStandingMultiplier?: number;
78
}
31
export const accountCheatBooleans = [
32
"skipAllDialogue",
33
"skipAllPopups",
34
"dontSubtractPurchaseCreditCost",
35
"dontSubtractPurchasePlatinumCost",
36
"dontSubtractPurchaseItemCost",
37
"dontSubtractPurchaseStandingCost",
38
"dontSubtractVoidTraces",
39
"dontSubtractConsumables",
40
"finishInvasionsInOneMission",
41
"infiniteCredits",
42
"infinitePlatinum",
43
"infiniteEndo",
44
"infiniteRegalAya",
45
"infiniteHelminthMaterials",
46
"universalPolarityEverywhere",
47
"unlockDoubleCapacityPotatoesEverywhere",
48
"unlockExilusEverywhere",
49
"unlockArcanesEverywhere",
50
"alertsRepeatable",
51
"syndicateMissionsRepeatable",
52
"instantFinishRivenChallenge",
53
"noDailyStandingLimits",
54
"noDailyFocusLimit",
55
"noArgonCrystalDecay",
56
"noMasteryRankUpCooldown",
57
"noVendorPurchaseLimits",
58
"noDeathMarks",
59
"noKimCooldowns",
60
"noBlessingCooldown",
61
"claimingBlueprintRefundsIngredients",
62
"instantResourceExtractorDrones",
63
"noResourceExtractorDronesDamage",
64
"missionsCanGiveAllRelics",
65
"exceptionalRelicsAlwaysGiveBronzeReward",
66
"flawlessRelicsAlwaysGiveSilverReward",
67
"radiantRelicsAlwaysGiveGoldReward",
68
"disableDailyTribute"
69
] as const;
70
export const accountCheatNumbers = [
71
"nemesisHenchmenKillsMultiplierGrineer",
72
"nemesisHenchmenKillsMultiplierCorpus",
73
"nemesisAntivirusGainMultiplier",
74
"nemesisHintProgressMultiplierGrineer",
75
"nemesisHintProgressMultiplierCorpus",
76
"nemesisExtraWeapon",
77
"spoofMasteryRank",
78
"relicRewardItemCountMultiplier",
79
"nightwaveStandingMultiplier"
80
] as const;
81
82
type TAccountCheatBooleanKey = (typeof accountCheatBooleans)[number];
83
type TAccountCheatNumberKey = (typeof accountCheatNumbers)[number];
84
85
type IAccountCheatBooleans = {
86
[_ in TAccountCheatBooleanKey]: boolean | undefined;
87
};
88
type IAccountCheatNumbers = {
89
[_ in TAccountCheatNumberKey]: number | undefined;
90
};
91
92
export interface IAccountCheats extends IAccountCheatBooleans, IAccountCheatNumbers {}
79
93
80
94
export interface IInventoryDatabase
81
95
extends