summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2025-07-02 15:54:23 +0200
committerEmma [it/its]@Rory& <root@rory.gay>2025-07-02 15:54:23 +0200
commitfca7953a514f278f1ac4547602a2f328e8b5831d (patch)
tree2c59eb5c3ffc03e7fbd8db60eefd428aba6f676c /src
parentFix the fix (diff)
downloadserver-ts-fca7953a514f278f1ac4547602a2f328e8b5831d.tar.xz
Update some dependencies, fix nix
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/gifs/search.ts3
-rw-r--r--src/api/routes/gifs/trending-gifs.ts3
-rw-r--r--src/api/routes/gifs/trending.ts5
-rw-r--r--src/util/util/AutoUpdate.ts5
-rw-r--r--src/util/util/RabbitMQ.ts4
-rw-r--r--src/util/util/WebAuthn.ts9
6 files changed, 18 insertions, 11 deletions
diff --git a/src/api/routes/gifs/search.ts b/src/api/routes/gifs/search.ts

index 3869bbe6b..04e2013ad 100644 --- a/src/api/routes/gifs/search.ts +++ b/src/api/routes/gifs/search.ts
@@ -26,6 +26,7 @@ import { import { Request, Response, Router } from "express"; import fetch from "node-fetch-commonjs"; import { ProxyAgent } from "proxy-agent"; +import http from "http"; const router = Router(); @@ -67,7 +68,7 @@ router.get( const response = await fetch( `https://g.tenor.com/v1/search?q=${q}&media_format=${media_format}&locale=${locale}&key=${apiKey}`, { - agent, + agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, diff --git a/src/api/routes/gifs/trending-gifs.ts b/src/api/routes/gifs/trending-gifs.ts
index f19874e6d..34428a546 100644 --- a/src/api/routes/gifs/trending-gifs.ts +++ b/src/api/routes/gifs/trending-gifs.ts
@@ -26,6 +26,7 @@ import { import { Request, Response, Router } from "express"; import fetch from "node-fetch-commonjs"; import { ProxyAgent } from "proxy-agent"; +import http from "http"; const router = Router(); @@ -62,7 +63,7 @@ router.get( const response = await fetch( `https://g.tenor.com/v1/trending?media_format=${media_format}&locale=${locale}&key=${apiKey}`, { - agent, + agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, diff --git a/src/api/routes/gifs/trending.ts b/src/api/routes/gifs/trending.ts
index 2c43a501f..c95d8fbbd 100644 --- a/src/api/routes/gifs/trending.ts +++ b/src/api/routes/gifs/trending.ts
@@ -26,6 +26,7 @@ import { import { Request, Response, Router } from "express"; import fetch from "node-fetch-commonjs"; import { ProxyAgent } from "proxy-agent"; +import http from "http"; const router = Router(); @@ -58,7 +59,7 @@ router.get( fetch( `https://g.tenor.com/v1/categories?locale=${locale}&key=${apiKey}`, { - agent, + agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, @@ -66,7 +67,7 @@ router.get( fetch( `https://g.tenor.com/v1/trending?locale=${locale}&key=${apiKey}`, { - agent, + agent: agent as http.Agent, method: "get", headers: { "Content-Type": "application/json" }, }, diff --git a/src/util/util/AutoUpdate.ts b/src/util/util/AutoUpdate.ts
index 9a3c0a2ab..ce03012b0 100644 --- a/src/util/util/AutoUpdate.ts +++ b/src/util/util/AutoUpdate.ts
@@ -22,6 +22,7 @@ import { ProxyAgent } from "proxy-agent"; import readline from "readline"; import fs from "fs/promises"; import path from "path"; +import http from "http"; const rl = readline.createInterface({ input: process.stdin, @@ -75,7 +76,7 @@ async function download(url: string, dir: string) { // TODO: use file stream instead of buffer (to prevent crash because of high memory usage for big files) // TODO check file hash const agent = new ProxyAgent(); - const response = await fetch(url, { agent }); + const response = await fetch(url, { agent: agent as http.Agent }); const buffer = await response.buffer(); const tempDir = await fs.mkdtemp("spacebar"); await fs.writeFile(path.join(tempDir, "Spacebar.zip"), buffer); @@ -98,7 +99,7 @@ async function getCurrentVersion(dir: string) { async function getLatestVersion(url: string) { try { const agent = new ProxyAgent(); - const response = await fetch(url, { agent }); + const response = await fetch(url, { agent: agent as http.Agent }); const content = (await response.json()) as { version: string }; return content.version; } catch (error) { diff --git a/src/util/util/RabbitMQ.ts b/src/util/util/RabbitMQ.ts
index 7d9f12ce2..1a61aee93 100644 --- a/src/util/util/RabbitMQ.ts +++ b/src/util/util/RabbitMQ.ts
@@ -16,11 +16,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import amqp, { Connection, Channel } from "amqplib"; +import amqp, { Channel, ChannelModel } from "amqplib"; import { Config } from "./Config"; export const RabbitMQ: { - connection: Connection | null; + connection: ChannelModel | null; channel: Channel | null; init: () => Promise<void>; } = { diff --git a/src/util/util/WebAuthn.ts b/src/util/util/WebAuthn.ts
index b0027b13c..735e7965b 100644 --- a/src/util/util/WebAuthn.ts +++ b/src/util/util/WebAuthn.ts
@@ -20,10 +20,13 @@ import { Fido2Lib } from "fido2-lib"; import jwt from "jsonwebtoken"; import { Config } from "./Config"; -const JWTOptions: jwt.SignOptions = { +const jwtSignOptions: jwt.SignOptions = { algorithm: "HS256", expiresIn: "5m", }; +const jwtVerifyOptions: jwt.VerifyOptions = { + algorithms: ["HS256"] +}; export const WebAuthn: { fido2: Fido2Lib | null; @@ -44,7 +47,7 @@ export async function generateWebAuthnTicket( jwt.sign( { challenge }, Config.get().security.jwtSecret, - JWTOptions, + jwtSignOptions, (err, token) => { if (err || !token) return rej(err || "no token"); return res(token); @@ -58,7 +61,7 @@ export async function verifyWebAuthnToken(token: string) { jwt.verify( token, Config.get().security.jwtSecret, - JWTOptions, + jwtVerifyOptions, async (err, decoded) => { if (err) return rej(err); return res(decoded);