BUGFIX: Memory Leak in NetscriptPorts (#399)

Co-authored-by: Snarling <84951833+Snarling@users.noreply.github.com>
This commit is contained in:
T.J. Eckman
2023-02-27 19:54:04 -05:00
committed by GitHub
parent 9d504b0dfb
commit 33f0150d25
15 changed files with 169 additions and 190 deletions
+9 -24
View File
@@ -23,17 +23,10 @@ export type INetscriptExtra = {
export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
return {
heart: {
// Easter egg function
break: () => () => {
return Player.karma;
},
},
openDevMenu: () => () => {
devMenu.emit();
},
exploit: () => () => {
Player.giveExploit(Exploit.UndocumentedFunctionCall);
break: () => () => Player.karma,
},
openDevMenu: () => () => devMenu.emit(),
exploit: () => () => Player.giveExploit(Exploit.UndocumentedFunctionCall),
bypass: (ctx) => (doc) => {
// reset both fields first
type temporary = { completely_unused_field: unknown };
@@ -64,20 +57,12 @@ export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
Player.giveExploit(Exploit.RealityAlteration);
}
},
rainbow: (ctx) => (guess) => {
function tryGuess(): boolean {
// eslint-disable-next-line no-sync
const verified = bcrypt.compareSync(
helpers.string(ctx, "guess", guess),
"$2a$10$aertxDEkgor8baVtQDZsLuMwwGYmkRM/ohcA6FjmmzIHQeTCsrCcO",
);
if (verified) {
Player.giveExploit(Exploit.INeedARainbow);
return true;
}
return false;
}
return tryGuess();
rainbow: (ctx) => (_guess) => {
const guess = helpers.string(ctx, "guess", _guess);
const verified = bcrypt.compareSync(guess, "$2a$10$aertxDEkgor8baVtQDZsLuMwwGYmkRM/ohcA6FjmmzIHQeTCsrCcO");
if (!verified) return false;
Player.giveExploit(Exploit.INeedARainbow);
return true;
},
iKnowWhatImDoing: (ctx) => () => {
helpers.log(ctx, () => "Unlocking unsupported feature: window.tprintRaw");