Skip to content

Commit

Permalink
Add eslint support! 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
wearrrrr committed Mar 18, 2024
1 parent a5d590b commit f3e347c
Show file tree
Hide file tree
Showing 17 changed files with 1,390 additions and 107 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
public/
31 changes: 31 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
env: {
node: true,
es2022: true,
browser: true,
},
extends: ["eslint:recommended", "plugin:astro/recommended"],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
"no-unused-vars": "error",
},
overrides: [
{
files: ["*.astro"],
parser: "astro-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser",
extraFileExtensions: [".astro"],
},
},
{
// Define the configuration for `<script>` tag.
// Script in `<script>` is assigned a virtual file name with the `.js` extension.
files: ["**/*.astro/*.js", "*.astro/*.js"],
parser: "@typescript-eslint/parser",
},
],
};
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"search.exclude": {
"/public/games/**": true
}
}
"search.exclude": {
"/public/games/**": true
}
}
7 changes: 3 additions & 4 deletions Checkfailed.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
<body>
<h1>Welcome to nginx!</h1>
<p>
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required. If you are expecting another
page, please check your network or
If you see this page, the nginx web server is successfully installed and working. Further
configuration is required. If you are expecting another page, please check your network or
<a href="/" id="rcheck"><b>Refresh this page</b></a>
</p>

Expand All @@ -37,4 +36,4 @@ <h1>Welcome to nginx!</h1>
}
</script>
</body>
</html>
</html>
86 changes: 43 additions & 43 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { existsSync } from "fs";
import dotenv from "dotenv";
import cookieParser from "cookie-parser";
import wisp from "wisp-server-node";
import fs from "node:fs";
dotenv.config();

const LICENSE_SERVER_URL = "https://license.mercurywork.shop/validate?license=";
Expand Down Expand Up @@ -52,9 +53,7 @@ async function MasqFail(req, res) {
return;
}
const unsafeSuffix = req.headers.host + ".html";
let safeSuffix = path
.normalize(unsafeSuffix)
.replace(/^(\.\.(\/|\\|$))+/, "");
let safeSuffix = path.normalize(unsafeSuffix).replace(/^(\.\.(\/|\\|$))+/, "");
let safeJoin = path.join(process.cwd() + "/Masqrd", safeSuffix);
try {
await fs.promises.access(safeJoin); // man do I wish this was an if-then instead of a "exception on fail"
Expand All @@ -72,51 +71,53 @@ async function MasqFail(req, res) {
// Woooooo masqr yayyyy (said no one)
// uncomment for masqr
app.use(async (req, res, next) => {
if (req.headers.host && whiteListedDomains.includes(req.headers.host)) {
next();
return;
}
const authheader = req.headers.authorization;
if (req.cookies["authcheck"]) {
next();
return;
}


if (req.cookies['refreshcheck'] != "true") {
res.cookie("refreshcheck", "true", {maxAge: 10000}) // 10s refresh check
MasqFail(req, res)
return;
}

if (!authheader) {
res.setHeader('WWW-Authenticate', 'Basic'); // Yeah so we need to do this to get the auth params, kinda annoying and just showing a login prompt gives it away so its behind a 10s refresh check
res.status(401);
MasqFail(req, res)
return;
}

const auth = Buffer.from(authheader.split(' ')[1], 'base64').toString().split(':');
const pass = auth[1];

const licenseCheck = ((await (await fetch(LICENSE_SERVER_URL + pass + "&host=" + req.headers.host)).json()))["status"]
console.log(LICENSE_SERVER_URL + pass + "&host=" + req.headers.host +" returned " +licenseCheck)
if (licenseCheck == "License valid") {
res.cookie("authcheck", "true", {expires: new Date((Date.now()) + (365*24*60*60 * 1000))}) // authorize session, for like a year, by then the link will be expired lol
res.send(`<script> window.location.href = window.location.href </script>`) // fun hack to make the browser refresh and remove the auth params from the URL
return;
}

MasqFail(req, res)
return;
})
if (req.headers.host && whiteListedDomains.includes(req.headers.host)) {
next();
return;
}
const authheader = req.headers.authorization;
if (req.cookies["authcheck"]) {
next();
return;
}

if (req.cookies["refreshcheck"] != "true") {
res.cookie("refreshcheck", "true", { maxAge: 10000 }); // 10s refresh check
MasqFail(req, res);
return;
}

if (!authheader) {
res.setHeader("WWW-Authenticate", "Basic"); // Yeah so we need to do this to get the auth params, kinda annoying and just showing a login prompt gives it away so its behind a 10s refresh check
res.status(401);
MasqFail(req, res);
return;
}

const auth = Buffer.from(authheader.split(" ")[1], "base64").toString().split(":");
const pass = auth[1];

const licenseCheck = (
await (await fetch(LICENSE_SERVER_URL + pass + "&host=" + req.headers.host)).json()
)["status"];
console.log(
LICENSE_SERVER_URL + pass + "&host=" + req.headers.host + " returned " + licenseCheck
);
if (licenseCheck == "License valid") {
res.cookie("authcheck", "true", { expires: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000) }); // authorize session, for like a year, by then the link will be expired lol
res.send(`<script> window.location.href = window.location.href </script>`); // fun hack to make the browser refresh and remove the auth params from the URL
return;
}

MasqFail(req, res);
return;
});

app.use(express.static(path.join(process.cwd(), "static")));
app.use(express.static(path.join(process.cwd(), "build")));
app.use("/uv/", express.static(uvPath));
app.use("/epoxy/", express.static(epoxyPath));
app.use("/libcurl/", express.static(libcurlPath))
app.use("/libcurl/", express.static(libcurlPath));

app.use(express.json());
app.use(
Expand All @@ -129,7 +130,6 @@ app.use(function (req, res, next) {
console.log("Game request");
res.header("Cross-Origin-Opener-Policy", "same-origin");
res.header("Cross-Origin-Embedder-Policy", "require-corp");

}
next();
});
Expand Down
Loading

0 comments on commit f3e347c

Please sign in to comment.