Repository navigation
Burn pastes - #1
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces the legacy paste expiration model with configurable “Burn Rules” (time-based or unlock-count-based), updating both the React UI and the Rust API/server cleanup logic. It also tightens a few security/ops aspects (token comparison, CORS configurability) and improves local build performance via Docker cache mounts.
Changes:
- Introduce burn-rule fields end-to-end (DB schema + migrations, Rust routes, TS API types, create/edit/view UI).
- Replace expiration UI/timers with burn-status labeling and new BurnRulesControl (popover/drawer) UX.
- Operational/security updates: configurable CORS origins, constant-time auth token compare, improved Docker build caching.
Reviewed changes
Copilot reviewed 28 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/ViewPaste.tsx | Uses burn-status label UI; improves blob URL lifecycle; updates raw-view implementation. |
| src/pages/NewPaste.tsx | Replaces “expires in” with burn-rule inputs and validation when creating pastes. |
| src/pages/EditPaste.tsx | Adds burn-rule editing (including “keep existing time burn” behavior). |
| src/lib/utils.ts | Centralizes formatFileSize utility. |
| src/lib/crypto.ts | Removes modulo bias in access code generation (rejection sampling). |
| src/lib/constants.ts | Adds burn-rule constants/validation and burn status label helpers; exports LANG_MAP. |
| src/lib/api.ts | Updates Paste model and create/update payloads to burn-rule fields; changes revoke API payload. |
| src/hooks/use-media-query.ts | Adds media-query hook used to switch popover vs drawer UI. |
| src/components/ui/drawer.tsx | Adds Vaul-based Drawer primitives for mobile burn-rule editor. |
| src/components/SharePasteDialog.tsx | Adds messaging about revoke-share burn behavior when sharing. |
| src/components/PasteCard.tsx | Displays burn-status label in list cards; wires burnAction to share dialog. |
| src/components/Navbar.tsx | Fixes theme preview application to react to activeIndex changes while modal open. |
| src/components/ExpirationTimer.tsx | Removes legacy expiration countdown component. |
| src/components/CodePreview.tsx | Switches to shared LANG_MAP from constants. |
| src/components/BurnRulesControl.tsx | New unified burn-rule control UI (desktop popover + mobile drawer). |
| src-rust/routes/paste.rs | Implements burn rules in CRUD/list/unlock paths; adds visibility filtering and unlock-count enforcement. |
| src-rust/routes/file.rs | Aligns file access control with burn rules and pending-delete grace window. |
| src-rust/main.rs | Adds ALLOWED_ORIGINS-driven CORS configuration; expands cleanup task for burned pastes. |
| src-rust/expiry.rs | Replaces expiry helpers with burn-rule time computations and pending-delete scheduling. |
| src-rust/db.rs | Adds migration path to rebuild pastes for burn rules; new indexes and idempotent handling. |
| src-rust/auth.rs | Uses constant-time comparison for auth cookie token checking. |
| schema.sql | Updates schema for burn-rule columns + indexes (drops expires_at index). |
| package.json | Adds vaul dependency. |
| package-lock.json | Locks vaul dependency. |
| fix_frontend.py | Adds a local refactor script (currently committed into the repo). |
| Dockerfile | Adds build cache mounts; changes backend build artifact copying to support caching. |
| docker-compose.yml | Adds ALLOWED_ORIGINS environment variable wiring and documentation. |
| Cargo.toml | Adds subtle and chrono dependencies. |
| Cargo.lock | Locks new Rust dependencies. |
| .env.example | Documents ALLOWED_ORIGINS configuration for production CORS restriction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+338
to
+342
| const win = window.open('', '_blank'); | ||
| if (win) { | ||
| win.document.title = paste.title || 'Raw Paste'; | ||
| win.document.write(`<pre style="word-wrap: break-word; white-space: pre-wrap;">${paste.content.replace(/</g, '<').replace(/>/g, '>')}</pre>`); | ||
| win.document.close(); |
Comment on lines
+127
to
+129
| burn_trigger: burnTrigger === 'off' ? null : burnTrigger as 'time', | ||
| burn_after_value: burnTrigger === 'time' ? Number(burnValue) : undefined, | ||
| burn_after_unit: burnTrigger === 'time' ? burnUnit : undefined, |
Comment on lines
+308
to
+318
| Err(_) => { | ||
| tracing::error!( | ||
| "ALLOWED_ORIGINS value '{}' is not a valid HTTP origin. \ | ||
| Falling back to open CORS (*).", | ||
| trimmed | ||
| ); | ||
| CorsLayer::new() | ||
| .allow_origin(Any) | ||
| .allow_methods(Any) | ||
| .allow_headers(Any) | ||
| } |
Comment on lines
+1
to
+5
| import re | ||
|
|
||
| # 1. Update constants.ts | ||
| with open('src/lib/constants.ts', 'r') as f: | ||
| constants = f.read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
added burn pastes and updated dockerfile for local builds