Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/pages/PasteBin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function PasteBin() {
name: "",
password: "",
uploadKind: "short",
doEncrypt: false,
doEncrypt: DEFAULT_CLIENT_ENCRYPTION,
})

const [pasteResponse, setPasteResponse] = useState<PasteResponse | undefined>(undefined)
Expand Down
1 change: 1 addition & 0 deletions frontend/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand All @@ -42,6 +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", false),
},
server: {
port: 5173,
Expand Down
1 change: 1 addition & 0 deletions worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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