diff --git a/ebs/package.json b/ebs/package.json index a5392a6..4de7eca 100644 --- a/ebs/package.json +++ b/ebs/package.json @@ -14,6 +14,7 @@ "dotenv": "^16.4.5", "express": "^4.19.2", "express-ws": "^5.0.2", + "fflate": "^0.8.2", "jsonpack": "^1.1.5", "jsonwebtoken": "^9.0.2", "mysql2": "^3.10.0", diff --git a/ebs/src/modules/config.ts b/ebs/src/modules/config.ts index 6911012..adbf71e 100644 --- a/ebs/src/modules/config.ts +++ b/ebs/src/modules/config.ts @@ -1,7 +1,7 @@ import { Config } from "common/types"; import { app } from "../index"; import { sendPubSubMessage } from "../util/pubsub"; -import { pack } from "jsonpack"; +import { strToU8, compressSync, strFromU8 } from "fflate"; import { getBannedUsers } from "../util/db"; let config: Config | undefined; @@ -40,7 +40,7 @@ export async function getConfig(): Promise { export async function broadcastConfigRefresh(config: Config) { return sendPubSubMessage({ type: "config_refreshed", - data: pack(config), + data: strFromU8(compressSync(strToU8(JSON.stringify(config)))), }); } diff --git a/frontend/package.json b/frontend/package.json index aec5838..f9ec040 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -25,5 +25,8 @@ "webpack-dev-server": "^5.0.4", "webpack-merge": "^5.10.0", "zip-webpack-plugin": "^4.0.1" + }, + "dependencies": { + "fflate": "^0.8.2" } } diff --git a/frontend/www/src/modules/pubsub.ts b/frontend/www/src/modules/pubsub.ts index 0db39c0..dc9a79e 100644 --- a/frontend/www/src/modules/pubsub.ts +++ b/frontend/www/src/modules/pubsub.ts @@ -1,7 +1,7 @@ import { Config, PubSubMessage } from "common/types"; -import { unpack } from "jsonpack"; import { postProcessConfig, setConfig } from "../util/config"; import { renderRedeemButtons } from "./redeems"; +import { strToU8, decompressSync, strFromU8 } from "fflate"; Twitch.ext.listen("global", async (_t, _c, message) => { const pubSubMessage = JSON.parse(message) as PubSubMessage; @@ -10,7 +10,7 @@ Twitch.ext.listen("global", async (_t, _c, message) => { switch (pubSubMessage.type) { case "config_refreshed": - const config = unpack(pubSubMessage.data); + const config = JSON.parse(strFromU8(decompressSync(strToU8(pubSubMessage.data)))) as Config; // console.log(config); await setConfig(postProcessConfig(config)); await renderRedeemButtons();