From f240a2b4077846f5eef03a8acb2b2274068d1094 Mon Sep 17 00:00:00 2001 From: Morgan Williams <2504532+mrgnw@users.noreply.github.com> Date: Mon, 28 Jul 2025 12:41:59 +0200 Subject: [PATCH 1/2] DEFAULT_CLIENT_ENCRYPTION --- frontend/pages/PasteBin.tsx | 2 +- frontend/vite-env.d.ts | 1 + frontend/vite.config.js | 1 + wrangler.toml | 3 +++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/pages/PasteBin.tsx b/frontend/pages/PasteBin.tsx index 3ed98ca3..406df49f 100644 --- a/frontend/pages/PasteBin.tsx +++ b/frontend/pages/PasteBin.tsx @@ -38,7 +38,7 @@ export function PasteBin() { name: "", password: "", uploadKind: "short", - doEncrypt: false, + doEncrypt: DEFAULT_CLIENT_ENCRYPTION, }) const [pasteResponse, setPasteResponse] = useState(undefined) diff --git a/frontend/vite-env.d.ts b/frontend/vite-env.d.ts index 4a393b0f..4ec9e33a 100644 --- a/frontend/vite-env.d.ts +++ b/frontend/vite-env.d.ts @@ -4,3 +4,4 @@ declare const REPO: string declare const MAX_EXPIRATION: string declare const DEFAULT_EXPIRATION: string declare const INDEX_PAGE_TITLE: string +declare const DEFAULT_CLIENT_ENCRYPTION: boolean diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 8f2c1873..ab488c0f 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -42,6 +42,7 @@ export default defineConfig(({ mode }) => { MAX_EXPIRATION: JSON.stringify(getVar("MAX_EXPIRATION")), DEFAULT_EXPIRATION: JSON.stringify(getVar("DEFAULT_EXPIRATION")), INDEX_PAGE_TITLE: JSON.stringify(indexTitle), + DEFAULT_CLIENT_ENCRYPTION: getVar("DEFAULT_CLIENT_ENCRYPTION"), }, server: { port: 5173, diff --git a/wrangler.toml b/wrangler.toml index 07552902..3d465ac6 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -75,3 +75,6 @@ R2_MAX_ALLOWED = "100M" # The following mimetypes will be converted to text/plain DISALLOWED_MIME_FOR_PASTE = ["text/html", "audio/x-mpegurl"] + +# Default client-side encryption setting (true/false) +DEFAULT_CLIENT_ENCRYPTION = true From 0db93e71e4272f69723b93ae0b9a21f6cf6425d2 Mon Sep 17 00:00:00 2001 From: Morgan Williams <2504532+mrgnw@users.noreply.github.com> Date: Mon, 28 Jul 2025 12:44:30 +0200 Subject: [PATCH 2/2] default DEFAULT_CLIENT_ENCRYPTION false --- frontend/vite.config.js | 6 ++++-- worker-configuration.d.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index ab488c0f..aac24a2f 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -13,9 +13,11 @@ export default defineConfig(({ mode }) => { const wranglerConfigText = readFileSync(wranglerConfigPath, "utf8") const wranglerConfigParsed = toml.parse(wranglerConfigText) - function getVar(name) { + function getVar(name, defaultValue = undefined) { if (wranglerConfigParsed.vars !== undefined && wranglerConfigParsed.vars[name] !== undefined) { return wranglerConfigParsed.vars[name] + } else if (defaultValue !== undefined) { + return defaultValue } else { throw new Error(`Cannot find vars.${name} in ${wranglerConfigPath}`) } @@ -42,7 +44,7 @@ export default defineConfig(({ mode }) => { MAX_EXPIRATION: JSON.stringify(getVar("MAX_EXPIRATION")), DEFAULT_EXPIRATION: JSON.stringify(getVar("DEFAULT_EXPIRATION")), INDEX_PAGE_TITLE: JSON.stringify(indexTitle), - DEFAULT_CLIENT_ENCRYPTION: getVar("DEFAULT_CLIENT_ENCRYPTION"), + DEFAULT_CLIENT_ENCRYPTION: getVar("DEFAULT_CLIENT_ENCRYPTION", false), }, server: { port: 5173, diff --git a/worker-configuration.d.ts b/worker-configuration.d.ts index 13c5229d..408a557e 100644 --- a/worker-configuration.d.ts +++ b/worker-configuration.d.ts @@ -17,6 +17,7 @@ declare namespace Cloudflare { R2_THRESHOLD: string; R2_MAX_ALLOWED: string; DISALLOWED_MIME_FOR_PASTE: string[]; + DEFAULT_CLIENT_ENCRYPTION: boolean; R2: R2Bucket; ASSETS: Fetcher; }