various fixes
Some checks failed
Galvanic Corrosion Cross-Compile / build (push) Failing after 39s

* Reverted shutdown mechanism
* Socket authentication fix for Cloudflare users
    - Cloudflare formats headers
* Steam auth verbose
* Upload artifacts to CDN and send Discord webhook link in #dev
This commit is contained in:
2025-05-12 20:57:52 -04:00
parent 83440a9245
commit 9ce5431d9d
12 changed files with 98 additions and 144 deletions

View File

@@ -26,10 +26,35 @@ jobs:
id: get_hash id: get_hash
run: echo "HASH=$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV run: echo "HASH=$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV
- name: Upload builds - name: Rename Linux build
uses: actions/upload-artifact@v3 run: mv build/GalvanicCorrosion build/GalvanicCorrosion-$HASH
- name: Rename Windows build
run: mv build/GalvanicCorrosion.exe build/GalvanicCorrosion-$HASH.exe
- name: Upload Linux build to CDN
env:
API_KEY: ${{ secrets.API_KEY }}
SERVER_URL: https://cdn.proxnet.dev/upload
run: |
curl -X POST "$SERVER_URL" \
-H "x-api-key: $API_KEY" \
-F "file=@build/GalvanicCorrosion" \
- name: Upload Windows build to CDN
env:
API_KEY: ${{ secrets.API_KEY }}
SERVER_URL: https://cdn.proxnet.dev/upload
run: |
curl -X POST "$SERVER_URL" \
-H "x-api-key: $API_KEY" \
-F "file=@build/GalvanicCorrosion.exe" \
- name: Discord Webhook - Storage Links
uses: tsickert/discord-webhook@v7.0.0
with: with:
name: GalvanicCorrosion-${{ env.HASH }} webhook-url: ${{ secrets.WEBHOOK_URL }}
path: | username: Galvanic Corrosion Gitea Actions
build/* embed-title: Storage Links | ${{ env.HASH }}
retention-days: 30 embed-description: |
"Artifacts ($HASH)\n\n[Linux](https://cdn.proxnet.dev/cdn/GalvanicCorrosion-$HASH) - [Windows](https://cdn.proxnet.dev/cdn/GalvanicCorrosion-$HASH.exe)"

View File

@@ -12,13 +12,9 @@
"imports": { "imports": {
"@gz/jwt": "jsr:@gz/jwt@^0.1.0", "@gz/jwt": "jsr:@gz/jwt@^0.1.0",
"@proxnet/undead-logging": "jsr:@proxnet/undead-logging@^1.2.0", "@proxnet/undead-logging": "jsr:@proxnet/undead-logging@^1.2.0",
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/http@^1.0.13",
"@types/cookie-parser": "npm:@types/cookie-parser@^1.4.8", "@types/cookie-parser": "npm:@types/cookie-parser@^1.4.8",
"@types/express": "npm:@types/express@^5.0.0", "@types/express": "npm:@types/express@^5.0.0",
"@types/node": "npm:@types/node@^22.13.14",
"@types/validator": "npm:@types/validator@^13.12.2", "@types/validator": "npm:@types/validator@^13.12.2",
"@types/ws": "npm:@types/ws@^8.18.0",
"cookie-parser": "npm:cookie-parser@^1.4.7", "cookie-parser": "npm:cookie-parser@^1.4.7",
"discord.js": "npm:discord.js@^14.16.3", "discord.js": "npm:discord.js@^14.16.3",
"express": "npm:express@^4.21.2", "express": "npm:express@^4.21.2",

111
deno.lock generated
View File

@@ -1,21 +1,10 @@
{ {
"version": "4", "version": "5",
"specifiers": { "specifiers": {
"jsr:@gz/jwt@0.1": "0.1.0", "jsr:@gz/jwt@0.1": "0.1.0",
"jsr:@proxnet/undead-logging@^1.2.0": "1.2.0", "jsr:@proxnet/undead-logging@^1.2.0": "1.2.0",
"jsr:@std/assert@1": "1.0.7",
"jsr:@std/bytes@^1.0.2": "1.0.4", "jsr:@std/bytes@^1.0.2": "1.0.4",
"jsr:@std/cli@^1.0.12": "1.0.15",
"jsr:@std/crypto@^1.0.3": "1.0.3", "jsr:@std/crypto@^1.0.3": "1.0.3",
"jsr:@std/encoding@^1.0.7": "1.0.8",
"jsr:@std/fmt@^1.0.5": "1.0.6",
"jsr:@std/html@^1.0.3": "1.0.3",
"jsr:@std/http@^1.0.13": "1.0.13",
"jsr:@std/internal@^1.0.5": "1.0.5",
"jsr:@std/media-types@^1.1.0": "1.1.0",
"jsr:@std/net@^1.0.4": "1.0.4",
"jsr:@std/path@^1.0.8": "1.0.8",
"jsr:@std/streams@^1.0.9": "1.0.9",
"jsr:@std/uuid@*": "1.0.4", "jsr:@std/uuid@*": "1.0.4",
"npm:@imagemagick/magick-wasm@0.0.31": "0.0.31", "npm:@imagemagick/magick-wasm@0.0.31": "0.0.31",
"npm:@types/cookie-parser@*": "1.4.8_@types+express@5.0.0", "npm:@types/cookie-parser@*": "1.4.8_@types+express@5.0.0",
@@ -23,9 +12,7 @@
"npm:@types/express@*": "5.0.0", "npm:@types/express@*": "5.0.0",
"npm:@types/express@5": "5.0.0", "npm:@types/express@5": "5.0.0",
"npm:@types/node@*": "22.5.4", "npm:@types/node@*": "22.5.4",
"npm:@types/node@^22.13.14": "22.13.14",
"npm:@types/validator@^13.12.2": "13.12.2", "npm:@types/validator@^13.12.2": "13.12.2",
"npm:@types/ws@^8.18.0": "8.18.0",
"npm:chalk@^5.3.0": "5.3.0", "npm:chalk@^5.3.0": "5.3.0",
"npm:cookie-parser@^1.4.7": "1.4.7", "npm:cookie-parser@^1.4.7": "1.4.7",
"npm:discord.js@^14.16.3": "14.16.3", "npm:discord.js@^14.16.3": "14.16.3",
@@ -44,58 +31,12 @@
"npm:chalk" "npm:chalk"
] ]
}, },
"@std/assert@1.0.7": {
"integrity": "64ce9fac879e0b9f3042a89b3c3f8ccfc9c984391af19e2087513a79d73e28c3",
"dependencies": [
"jsr:@std/internal"
]
},
"@std/bytes@1.0.4": { "@std/bytes@1.0.4": {
"integrity": "11a0debe522707c95c7b7ef89b478c13fb1583a7cfb9a85674cd2cc2e3a28abc" "integrity": "11a0debe522707c95c7b7ef89b478c13fb1583a7cfb9a85674cd2cc2e3a28abc"
}, },
"@std/cli@1.0.15": {
"integrity": "e79ba3272ec710ca44d8342a7688e6288b0b88802703f3264184b52893d5e93f"
},
"@std/crypto@1.0.3": { "@std/crypto@1.0.3": {
"integrity": "a2a32f51ddef632d299e3879cd027c630dcd4d1d9a5285d6e6788072f4e51e7f" "integrity": "a2a32f51ddef632d299e3879cd027c630dcd4d1d9a5285d6e6788072f4e51e7f"
}, },
"@std/encoding@1.0.8": {
"integrity": "a6c8f3f933ab1bed66244f435d1dc0fd23a888e07195532122ddc3d5f8f0e6b4"
},
"@std/fmt@1.0.6": {
"integrity": "a2c56a69a2369876ddb3ad6a500bb6501b5bad47bb3ea16bfb0c18974d2661fc"
},
"@std/html@1.0.3": {
"integrity": "7a0ac35e050431fb49d44e61c8b8aac1ebd55937e0dc9ec6409aa4bab39a7988"
},
"@std/http@1.0.13": {
"integrity": "d29618b982f7ae44380111f7e5b43da59b15db64101198bb5f77100d44eb1e1e",
"dependencies": [
"jsr:@std/cli",
"jsr:@std/encoding",
"jsr:@std/fmt",
"jsr:@std/html",
"jsr:@std/media-types",
"jsr:@std/net",
"jsr:@std/path",
"jsr:@std/streams"
]
},
"@std/internal@1.0.5": {
"integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
},
"@std/media-types@1.1.0": {
"integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4"
},
"@std/net@1.0.4": {
"integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852"
},
"@std/path@1.0.8": {
"integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
},
"@std/streams@1.0.9": {
"integrity": "a9d26b1988cdd7aa7b1f4b51e1c36c1557f3f252880fa6cc5b9f37078b1a5035"
},
"@std/uuid@1.0.4": { "@std/uuid@1.0.4": {
"integrity": "f4233149cc8b4753cc3763fd83a7c4101699491f55c7be78dc7b30281946d7a0", "integrity": "f4233149cc8b4753cc3763fd83a7c4101699491f55c7be78dc7b30281946d7a0",
"dependencies": [ "dependencies": [
@@ -153,7 +94,7 @@
"@discordjs/rest", "@discordjs/rest",
"@discordjs/util", "@discordjs/util",
"@sapphire/async-queue", "@sapphire/async-queue",
"@types/ws@8.5.13", "@types/ws",
"@vladfrangu/async_event_emitter", "@vladfrangu/async_event_emitter",
"discord-api-types@0.37.83", "discord-api-types@0.37.83",
"tslib", "tslib",
@@ -183,13 +124,13 @@
"integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==",
"dependencies": [ "dependencies": [
"@types/connect", "@types/connect",
"@types/node@22.5.4" "@types/node"
] ]
}, },
"@types/connect@3.4.38": { "@types/connect@3.4.38": {
"integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
"dependencies": [ "dependencies": [
"@types/node@22.5.4" "@types/node"
] ]
}, },
"@types/cookie-parser@1.4.8_@types+express@5.0.0": { "@types/cookie-parser@1.4.8_@types+express@5.0.0": {
@@ -201,7 +142,7 @@
"@types/express-serve-static-core@5.0.1": { "@types/express-serve-static-core@5.0.1": {
"integrity": "sha512-CRICJIl0N5cXDONAdlTv5ShATZ4HEwk6kDDIW2/w9qOWKg+NU/5F8wYRWCrONad0/UKkloNSmmyN/wX4rtpbVA==", "integrity": "sha512-CRICJIl0N5cXDONAdlTv5ShATZ4HEwk6kDDIW2/w9qOWKg+NU/5F8wYRWCrONad0/UKkloNSmmyN/wX4rtpbVA==",
"dependencies": [ "dependencies": [
"@types/node@22.5.4", "@types/node",
"@types/qs", "@types/qs",
"@types/range-parser", "@types/range-parser",
"@types/send" "@types/send"
@@ -222,22 +163,10 @@
"@types/mime@1.3.5": { "@types/mime@1.3.5": {
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==" "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w=="
}, },
"@types/node@22.12.0": {
"integrity": "sha512-Fll2FZ1riMjNmlmJOdAyY5pUbkftXslB5DgEzlIuNaiWhXd00FhWxVC/r4yV/4wBb9JfImTu+jiSvXTkJ7F/gA==",
"dependencies": [
"undici-types@6.20.0"
]
},
"@types/node@22.13.14": {
"integrity": "sha512-Zs/Ollc1SJ8nKUAgc7ivOEdIBM8JAKgrqqUYi2J997JuKO7/tpQC+WCetQ1sypiKCQWHdvdg9wBNpUPEWZae7w==",
"dependencies": [
"undici-types@6.20.0"
]
},
"@types/node@22.5.4": { "@types/node@22.5.4": {
"integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==",
"dependencies": [ "dependencies": [
"undici-types@6.19.8" "undici-types"
] ]
}, },
"@types/qs@6.9.17": { "@types/qs@6.9.17": {
@@ -250,30 +179,24 @@
"integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==",
"dependencies": [ "dependencies": [
"@types/mime", "@types/mime",
"@types/node@22.5.4" "@types/node"
] ]
}, },
"@types/serve-static@1.15.7": { "@types/serve-static@1.15.7": {
"integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==",
"dependencies": [ "dependencies": [
"@types/http-errors", "@types/http-errors",
"@types/node@22.5.4", "@types/node",
"@types/send" "@types/send"
] ]
}, },
"@types/validator@13.12.2": { "@types/validator@13.12.2": {
"integrity": "sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==" "integrity": "sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA=="
}, },
"@types/ws@8.18.0": {
"integrity": "sha512-8svvI3hMyvN0kKCJMvTJP/x6Y/EoQbepff882wL+Sn5QsXb3etnamgrJq4isrBxSJj5L2AuXcI0+bgkoAXGUJw==",
"dependencies": [
"@types/node@22.12.0"
]
},
"@types/ws@8.5.13": { "@types/ws@8.5.13": {
"integrity": "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==", "integrity": "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==",
"dependencies": [ "dependencies": [
"@types/node@22.5.4" "@types/node"
] ]
}, },
"@vladfrangu/async_event_emitter@2.4.6": { "@vladfrangu/async_event_emitter@2.4.6": {
@@ -603,7 +526,8 @@
] ]
}, },
"mime@1.6.0": { "mime@1.6.0": {
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"bin": true
}, },
"ms@2.0.0": { "ms@2.0.0": {
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
@@ -760,9 +684,6 @@
"undici-types@6.19.8": { "undici-types@6.19.8": {
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
}, },
"undici-types@6.20.0": {
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="
},
"undici@6.19.8": { "undici@6.19.8": {
"integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==" "integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g=="
}, },
@@ -779,7 +700,11 @@
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="
}, },
"ws@8.18.0": { "ws@8.18.0": {
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==" "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
"optionalPeers": [
"bufferutil@^4.0.1",
"utf-8-validate@>=5.0.2"
]
}, },
"zod@3.24.2": { "zod@3.24.2": {
"integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==" "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ=="
@@ -930,13 +855,9 @@
"dependencies": [ "dependencies": [
"jsr:@gz/jwt@0.1", "jsr:@gz/jwt@0.1",
"jsr:@proxnet/undead-logging@^1.2.0", "jsr:@proxnet/undead-logging@^1.2.0",
"jsr:@std/assert@1",
"jsr:@std/http@^1.0.13",
"npm:@types/cookie-parser@^1.4.8", "npm:@types/cookie-parser@^1.4.8",
"npm:@types/express@5", "npm:@types/express@5",
"npm:@types/node@^22.13.14",
"npm:@types/validator@^13.12.2", "npm:@types/validator@^13.12.2",
"npm:@types/ws@^8.18.0",
"npm:cookie-parser@^1.4.7", "npm:cookie-parser@^1.4.7",
"npm:discord.js@^14.16.3", "npm:discord.js@^14.16.3",
"npm:express@^4.21.2", "npm:express@^4.21.2",

View File

@@ -37,7 +37,7 @@ try {
const data = Deno.readTextFileSync(`${RootPath}/res/words.json`); const data = Deno.readTextFileSync(`${RootPath}/res/words.json`);
charades = JSON.parse(data); charades = JSON.parse(data);
} catch (err) { } catch (err) {
log.e(`Could not read charades words config from disk!`); log.e(`Could not read charades words config from disk: ${(err as Error).message}`);
} }
export function getWords() { export function getWords() {

View File

@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <https://www.gnu.org/licenses/>. */
enum AvatarItemType { enum _AvatarItemType {
None = -1, None = -1,
Hat, Hat,
BackHead, BackHead,

View File

@@ -49,11 +49,18 @@ export async function AuthenticateUserTicket(ticket: string, userid: string) {
params.append('appid', "471710"); params.append('appid', "471710");
params.append('ticket', ticket); params.append('ticket', ticket);
try {
const res = await fetch(`https://api.steampowered.com/ISteamUserAuth/AuthenticateUserTicket/v1?${params}`); const res = await fetch(`https://api.steampowered.com/ISteamUserAuth/AuthenticateUserTicket/v1?${params}`);
const resjson = (await res.json()) as SteamRes; const resjson = (await res.json()) as SteamRes;
if (resjson.response.error) { if (resjson.response.error) {
log.w(`Steam Authentication failed: (${resjson.response.error.errorcode}) ${resjson.response.error.errordesc}`); log.w(`Steam Authentication failed: (${resjson.response.error.errorcode}) ${resjson.response.error.errordesc}`);
// add more error codes later if needed
const conditions = [
resjson.response.error.errorcode == 100
].includes(true);
if (conditions) log.w('This error indicates a client problem.');
return false; return false;
} }
@@ -63,6 +70,10 @@ export async function AuthenticateUserTicket(ticket: string, userid: string) {
log.w("Steam Authentication failed: Steam response did not contain params or error! This should never be logged!"); log.w("Steam Authentication failed: Steam response did not contain params or error! This should never be logged!");
return false; return false;
} }
} catch (err) {
log.w(`Steam Authentication failed: ${(err as Error).message}`);
return false;
}
} }
export * as Steam from "./steam.ts"; export * as Steam from "./steam.ts";

View File

@@ -130,20 +130,32 @@ try {
valid: false valid: false
} }
type AuthResult = FailedAuth | SuccessfulAuth; type AuthResult = FailedAuth | SuccessfulAuth;
// Please rewrite this for the love of God
const authenticate = async (req: Request) => { const authenticate = async (req: Request) => {
const authHeader = req.headers.get('authorization'); const authHeader = req.headers.get('authorization');
if (!authHeader) return { valid: false } as AuthResult; if (!authHeader) return { valid: false } as AuthResult;
//log.d(authHeader); let token: string | undefined;
const token = authHeader.split(", ")[1]; // Why is the header formatted like this? if (authHeader.substring(0, 6) === 'Bearer') {
if (!token) return { valid: false } as AuthResult; const splitToken = authHeader.split(' ');
const splitToken = token.split(' ')[1]; if (splitToken[1]) token = splitToken[1];
if (!splitToken) return { valid: false } as AuthResult; }
if (authHeader.includes(', ')) {
const splitToken = authHeader.split(', ');
if (splitToken[1]) token = splitToken[1];
}
const decodedToken = await decode<ProfileTokenFormat>(splitToken, config.auth.secret, {algorithm: 'HS512'}); try {
if (!token) throw new Error("No token provided");
const decodedToken = await decode<ProfileTokenFormat>(token, config.auth.secret, {algorithm: 'HS512'});
const schemaResult = ProfileTokenSchema.safeParse(decodedToken); const schemaResult = ProfileTokenSchema.safeParse(decodedToken);
if (!schemaResult.success) return { valid: false } as AuthResult; if (!schemaResult.success) return { valid: false } as AuthResult;
else return { token: decodedToken, valid: true } as AuthResult; else return { token: decodedToken, valid: true } as AuthResult;
} catch (err) {
log.w(`Authentication failed`);
log.w((err as Error).message);
return { valid: false } as AuthResult;
}
} }
const port = config.web.api.port; const port = config.web.api.port;
@@ -187,7 +199,7 @@ try {
return response; return response;
} else { } else {
log.e(`401 ${info.remoteAddr} ${req.method} ${req.url}`); log.e(`401 ${info.remoteAddr.hostname}:${info.remoteAddr.port} ${req.method} ${req.url}`);
return new Response(null, { status: 401 }); return new Response(null, { status: 401 });
} }
@@ -200,20 +212,19 @@ try {
Deno.addSignalListener("SIGINT", () => { Deno.addSignalListener("SIGINT", () => {
if (shuttingDown) return; if (shuttingDown) return;
shuttingDown = true; shuttingDown = true;
for (const handoff of SocketHandoff.all()) handoff.complete();
for (const sock of UnifiedProfile.getAllSockets()) sock.sendNotification(PushNotificationId.ModerationQuitGame);
});
Deno.addSignalListener("SIGINT", () => {
if (shuttingDown) return;
log.i(`Shutting down`); log.i(`Shutting down`);
abort.abort(); // websockets abort.abort(); // websockets
http.close(); http.close();
http.closeAllConnections(); http.closeAllConnections();
}); });
Deno.addSignalListener("SIGINT", () => {
for (const socket of UnifiedProfile.getAllSockets()) socket.sendNotification(PushNotificationId.ModerationQuitGame); // untested
});
if (!(await UnifiedProfile.existsByName("Coach"))) UnifiedProfile.create({ username: "Coach", id: 1 }); // create Coach id 1 if they do not exist if (!(await UnifiedProfile.existsByName("Coach"))) UnifiedProfile.create({ username: "Coach", id: 1 }); // create Coach id 1 if they do not exist
if (!(await UnifiedProfile.existsByName("Server"))) UnifiedProfile.create({ username: "Server", id: 2 }); // create Server id 2 if they do not exist if (!(await UnifiedProfile.existsByName("Server"))) UnifiedProfile.create({ username: "Server", id: 2 }); // create Server id 2 if they do not exist
// use these later in development
if (!(await GameConfigs.getGameConfig('splitTestSoftOverrides'))) GameConfigs.setGameConfig('splitTestSoftOverrides', ''); if (!(await GameConfigs.getGameConfig('splitTestSoftOverrides'))) GameConfigs.setGameConfig('splitTestSoftOverrides', '');
if (!(await GameConfigs.getGameConfig('splitTestHardOverrides'))) GameConfigs.setGameConfig('splitTestHardOverrides', ''); if (!(await GameConfigs.getGameConfig('splitTestHardOverrides'))) GameConfigs.setGameConfig('splitTestHardOverrides', '');

View File

@@ -20,12 +20,9 @@ import express from "express";
import UnifiedProfile, { Profile } from "../../data/profiles.ts"; import UnifiedProfile, { Profile } from "../../data/profiles.ts";
import { z } from "zod"; import { z } from "zod";
import { AuthType } from "../../data/users.ts"; import { AuthType } from "../../data/users.ts";
import Logging from "@proxnet/undead-logging";
export const route = APIUtils.createRouter("/account"); export const route = APIUtils.createRouter("/account");
const log = new Logging("AccountRoute");
const CreateAccountRequestBodySchema = z.object({ const CreateAccountRequestBodySchema = z.object({
platform: z.string(), platform: z.string(),
platformId: z.string(), platformId: z.string(),

View File

@@ -58,7 +58,6 @@ route.router.post('/v1/cleargroup',
APIUtils.Authentication, APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game), APIUtils.AuthenticationType(AuthType.Game),
express.json(), express.json(),
APIUtils.logBody,
APIUtils.validateRequestBody(ClearGroupRequestSchema), APIUtils.validateRequestBody(ClearGroupRequestSchema),
(rq: express.Request<NoBody, NoBody, ClearGroupRequestBody>, rs: express.Response) => { (rq: express.Request<NoBody, NoBody, ClearGroupRequestBody>, rs: express.Response) => {

View File

@@ -33,7 +33,6 @@ route.router.get('/v2',
async (_rq, rs) => { async (_rq, rs) => {
const settings = await rs.locals.profile.Settings.getSettings(); const settings = await rs.locals.profile.Settings.getSettings();
log.d(`settings res: ${JSON.stringify(settings)}`);
rs.json(settings); rs.json(settings);
} }

View File

@@ -108,7 +108,6 @@ route.router.post("/token",
APIUtils.Authentication, APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Web), APIUtils.AuthenticationType(AuthType.Web),
express.urlencoded({ extended: true }), express.urlencoded({ extended: true }),
APIUtils.logBody,
APIUtils.validateRequestBody<AuthBodyBase>(TokenRequestBodySchema), APIUtils.validateRequestBody<AuthBodyBase>(TokenRequestBodySchema),
async ( async (

View File

@@ -21,13 +21,10 @@ import express from "express";
import Matchmaking from "../../data/live/base.ts"; import Matchmaking from "../../data/live/base.ts";
import Presence, { PresenceExport } from "../../data/live/presence.ts"; import Presence, { PresenceExport } from "../../data/live/presence.ts";
import { AuthType } from "../../data/users.ts"; import { AuthType } from "../../data/users.ts";
import Logging from "@proxnet/undead-logging";
import UnifiedProfile from "../../data/profiles.ts"; import UnifiedProfile from "../../data/profiles.ts";
import { PlayerStatusVisibility, VRMovementMode } from "../../data/live/types.ts"; import { PlayerStatusVisibility, VRMovementMode } from "../../data/live/types.ts";
import { SettingKey } from "../../data/content/settings.ts"; import { SettingKey } from "../../data/content/settings.ts";
const log = new Logging("MatchPlayerRoute");
export const route = APIUtils.createRouter('/player'); export const route = APIUtils.createRouter('/player');
interface BaseLoginLock { interface BaseLoginLock {
@@ -57,7 +54,6 @@ route.router.get('/',
} }
rs.json(presExport); rs.json(presExport);
log.d(JSON.stringify(presExport));
} }
) )