Compare commits

...
Author SHA1 Message Date
whoswhip 892624f6ac fix: properly resolve dynamic urls 2026-11-06 08:36:32 -05:00
whoswhip eed65b754e refactor: improve encryption performance and safety
also fixed some issues i saw related to dynamic urls being resolved improperly
formatted via prettier
2026-11-06 08:25:26 -05:00
whoswhip 22c144e970 chore: bump version 2026-10-18 11:59:59 -04:00
whoswhip 336990f5b8 style: separate comments from the paste container 2026-10-18 11:55:39 -04:00
whoswhip 45878d5af1 omfg, actually fix #lib imports 2026-10-18 11:47:06 -04:00
whoswhip 2c43c0b29c chore(deps): update nuget packages for security 2026-10-18 11:24:29 -04:00
whoswhip 0e3a6d97e3 fix: use node env instead of sveltekit env 2026-10-11 22:15:13 -04:00
whoswhip 878457f49d fix #lib 2026-10-10 21:32:51 -04:00
whoswhip 8d060204c8 fix: use #lib instead of $lib 2026-10-10 21:29:02 -04:00
whoswhip f2559eaad0 fix: update TypeScript configuration to extend from $app/tsconfig and adjust include/exclude paths 2026-10-10 21:04:04 -04:00
whoswhip e485b9782b fix node adapter 2026-10-10 20:33:08 -04:00
whoswhip ed7e82adc2 Merge branch 'SharpbinV3' of github.com:whoswhip/Sharpbin into SharpbinV3 2026-10-10 13:34:52 -04:00
whoswhip f8a74d415d Merge pull request #27 from whoswhip/dependabot/npm_and_yarn/SharpbinV3.Client/npm_and_yarn-b9088de85f
chore(deps): bump the npm_and_yarn group across 1 directory with 6 updates
2026-10-10 13:33:41 -04:00
whoswhip e375b0a020 refactor: simplify configuration to a single env file 2026-09-26 19:40:36 -04:00
60 changed files with 582 additions and 410 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
**/.classpath
**/.dockerignore
**/.env
**/backend.env
**/frontend.env
**/.git
**/.gitignore
**/.project
@@ -27,4 +29,4 @@ README.md
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
!.git/refs/heads/**
+10 -10
View File
@@ -1,13 +1,14 @@
# Replace every replace_with_ value before running. See README.md for secret generation.
# Use a different random secret for each setting, except the shared frontend/backend key.
# Required Misc. Variables
# Copy to .env in the repository root. Replace every replace_with_ value before running.
# Generate a different random value for each secret. See README.md for instructions.
# Site
Domain=example.com
Https=true
AllowedCorsOrigins__0=https://example.com
JwtSettings__Secret=replace_with_a_unique_random_jwt_secret_before_running
ConnectionStrings__DefaultConnection=Data Source=/app/data/sharpbin.db
ORIGIN=https://example.com
# Auth Settings
# Authentication
JwtSettings__Secret=replace_with_a_unique_random_jwt_secret_before_running
# These Turnstile keys are for testing. Use your own site and secret keys in production.
AuthSettings__CF_Turnstile_SecretKey=1x0000000000000000000000000000000AA
AuthSettings__CF_Turnstile_SiteKey=3x00000000000000000000FF
@@ -15,12 +16,11 @@ AuthSettings__Registration_Enabled=true
AuthSettings__Admins_Require_2FA=true
AuthSettings__API_Key_HMAC_Secret=replace_with_a_unique_random_api_key_hmac_secret_before_running
# Paste Settings
# Pastes
PasteSettings__MaxTitleLength=500
PasteSettings__MaxPasteSizeInBytes=1048576
PasteSettings__EnablePasteCompression=true
PasteSettings__RequiresVerification=true
PasteSettings__View_HMAC_Secret=replace_with_a_unique_random_view_hmac_secret_before_running
# Used so that views are only counted from the frontend
# Must be the same on both the frontend and backend environment
PasteSettings__View_Internal_API_Key=replace_with_the_same_random_internal_api_key_in_both_files
# Compose passes this value to both services. No separate frontend key is needed.
PasteSettings__View_Internal_API_Key=replace_with_a_unique_random_internal_api_key_before_running
+3 -1
View File
@@ -325,4 +325,6 @@ Data
!SharpbinV3.Server/Data
.idea
**/.env
**/.env
backend.env
frontend.env
+53
View File
@@ -1,3 +1,56 @@
## [3.1.0](https://github.com/whoswhip/Sharpbin/compare/v3.0.5...v3.1.0) (2026-10-18)
### Bug Fixes
* add docker entrypoint sccript ([045a193](https://github.com/whoswhip/Sharpbin/commit/045a1934d80277b75b34d7566ea283c57a7b1e83))
* add tooltip to comment timestamp for better context ([c98e5e5](https://github.com/whoswhip/Sharpbin/commit/c98e5e53b02002ac0328947cdbabddaa60ebe877))
* allow null display name when saving display name ([20473da](https://github.com/whoswhip/Sharpbin/commit/20473da0bacc891354ef75cd05b4fdb3443ae629))
* always underline users in comments ([e239bf2](https://github.com/whoswhip/Sharpbin/commit/e239bf2ae5a4ca0f93cfc197d9658df459b87d10))
* compact paste smaller; better edited display ([e8cd93e](https://github.com/whoswhip/Sharpbin/commit/e8cd93e7bdfc47e0c105935182c7062fd191cb57))
* disable but show buttons for author or anon users ([77f6623](https://github.com/whoswhip/Sharpbin/commit/77f6623fcf6b9b50e26ce533cee7b83c26836051))
* disable styles on comment reactions ([23f0c92](https://github.com/whoswhip/Sharpbin/commit/23f0c92aed9bd8235ad1cc6b62aa3c9bf8674370))
* disabled:cursor-not-allowed on like buttons ([95a5c18](https://github.com/whoswhip/Sharpbin/commit/95a5c18dc57ad33701bbd6d9f5cfcf6a1cda6f49))
* enforce 2fa only on certain update actions ([a55268a](https://github.com/whoswhip/Sharpbin/commit/a55268afdc171d3d7f074ee008be3434e14c0482))
* enhance user update permissions and authentication checks ([6c810b0](https://github.com/whoswhip/Sharpbin/commit/6c810b07b738ca2cb0cfe87c264e26395254024b))
* handle username conflict during user creation ([f5a7aab](https://github.com/whoswhip/Sharpbin/commit/f5a7aabf42a67969baf6e307b3178e89c75a4716))
* improve paste description ([60796a8](https://github.com/whoswhip/Sharpbin/commit/60796a85fb3f287cc88d42dda7f9bc446d0d5f97))
* include '.' before extension on paste download ([ee6a6d5](https://github.com/whoswhip/Sharpbin/commit/ee6a6d5e6d3f4d5ef2fb2c8f6032e695b228fcf9))
* lower vulnerabilities + harden docker setup ([d16f1f8](https://github.com/whoswhip/Sharpbin/commit/d16f1f872fa34de460f9ee8903b4eefbe780c041))
* make cursor-not-allowed !important ([9916930](https://github.com/whoswhip/Sharpbin/commit/99169305c7b496eef51cfb5493cd3c8548f366e7))
* multiple vulnerabilities ([6a7b865](https://github.com/whoswhip/Sharpbin/commit/6a7b8653dc154366c85de32dccf242a071eebdf0))
* normalize canonical URL to prevent duplicate content issues ([ad693b2](https://github.com/whoswhip/Sharpbin/commit/ad693b28ea701554fceede1f8e30e7990240281c))
* normalize cononical ([d45f253](https://github.com/whoswhip/Sharpbin/commit/d45f253c000e834db584fed89ddb541c09f466c7))
* only show report button if logged in ([40c6ac6](https://github.com/whoswhip/Sharpbin/commit/40c6ac663f95c40a154dc56598bdfe6e59f38703))
* prevent admins and moderators from being reported ([f2c67ae](https://github.com/whoswhip/Sharpbin/commit/f2c67ae3677658efaf84811271f62c5043797460))
* prevent authors from reacting to their pas6te ([3da7f99](https://github.com/whoswhip/Sharpbin/commit/3da7f99feba4aaaa02a6e9f0c7771a548e6530c3))
* remove recipient information from warning log when email settings are incomplete ([b65d3f8](https://github.com/whoswhip/Sharpbin/commit/b65d3f8726f77f2b7260e97ba439bfea4e2ad908))
* remove trailing '.' in filename ([b0e9f51](https://github.com/whoswhip/Sharpbin/commit/b0e9f5104c92a3cb6a8965d23460c86a64595d12))
* show uncompressed size in stats ([61efbf8](https://github.com/whoswhip/Sharpbin/commit/61efbf8b0415fe159b5e777f737ee4e8b25beb02))
* sizeStored -> StoredSize in typescript paste type ([6c65a52](https://github.com/whoswhip/Sharpbin/commit/6c65a52ee06c266eeeb5519e779eb49f73be33b7))
* update robots.txt to specify allowed and disallowed paths for web crawlers ([ea634fd](https://github.com/whoswhip/Sharpbin/commit/ea634fd85135d2996e96f6a48ce2fbccbb75b7e2))
* update TypeScript configuration to extend from $app/tsconfig and adjust include/exclude paths ([f2559ea](https://github.com/whoswhip/Sharpbin/commit/f2559eaad0ac79ac2ee18f3b9388ce62b11b5543))
* use #lib instead of $lib ([8d06020](https://github.com/whoswhip/Sharpbin/commit/8d060204c890018f49147e681f94a6737ac1c4b1)), closes [#lib](https://github.com/whoswhip/Sharpbin/issues/lib)
* use node env instead of sveltekit env ([0e3a6d9](https://github.com/whoswhip/Sharpbin/commit/0e3a6d97e395c605d419c2464c3b7fccbcdd5c6f))
### Features
* add /[@username](https://github.com/username) redirect to /user/username ([70e637b](https://github.com/whoswhip/Sharpbin/commit/70e637b281ae060e40ceb6e312591276d1c68540))
* add bot detection to skip recording views for known bots ([41d4411](https://github.com/whoswhip/Sharpbin/commit/41d441135cdef6c22df34a512507ef7032009db9))
* add sub tab to the settings tab ([e20a620](https://github.com/whoswhip/Sharpbin/commit/e20a6200dd3c1f0dfe26645c625cac448dc50d76))
* allow staff members to see user's unlisted pastes; show dislikes in the paste lists ([6ed2974](https://github.com/whoswhip/Sharpbin/commit/6ed2974e42df9d10da755af6897b4eea4ee6d34a))
* **auth:** enhance token management and synchronization with user data ([2864c81](https://github.com/whoswhip/Sharpbin/commit/2864c81f83ca49032a803f8ca2ccad19a1f8d9fe))
* comments & paste/comment reactions; renames/refactors ([63b77be](https://github.com/whoswhip/Sharpbin/commit/63b77bece9b71d547d15403257da44e8597db97b))
* **comments:** implement delete comment functionality with confirmation modal ([95ca811](https://github.com/whoswhip/Sharpbin/commit/95ca811d4295759b3fc161eff9ba81c7499be254))
* **comments:** implement recursive comment deletion in HardDeleteComment method ([8d3caf5](https://github.com/whoswhip/Sharpbin/commit/8d3caf5375a8065281b917b1c24970580799a059))
* enhance SEO for home, recent, and paste pages ([edffd54](https://github.com/whoswhip/Sharpbin/commit/edffd5490fae8274293982ded81c7971b614fd28))
* improve rate limit partition keys + less strict limits ([6cadc0b](https://github.com/whoswhip/Sharpbin/commit/6cadc0b74d3b5cb340347b1fc8dbaf8f06318e5b))
* **modal:** refactor modal types and integrate security action requirements ([f82d314](https://github.com/whoswhip/Sharpbin/commit/f82d314d80dcd8e70f197c254bb4e7ba2fee67f0))
* password resets ([d4976ac](https://github.com/whoswhip/Sharpbin/commit/d4976ac9aac41cb7ad23070480862bf2cec89095))
## [3.0.5](https://github.com/whoswhip/Sharpbin/compare/v3.0.4...v3.0.5) (2026-03-31)
+19 -7
View File
@@ -26,7 +26,7 @@ The easiest way to run SharpbinV3 is using Docker Compose.
git clone https://github.com/whoswhip/Sharpbin.git
```
3. In the repository root, copy `backend.env.example` to `backend.env` and `frontend.env.example` to `frontend.env`.
3. In the repository root, copy `.env.example` to `.env`.
4. Replace the secret placeholders and configure your domain and Turnstile keys. Set `ORIGIN` to the public frontend URL, including the scheme. For local Docker testing, use `ORIGIN=http://localhost:5173`, `Domain=localhost:5173`, `Https=false`, and `AllowedCorsOrigins__0=http://localhost:5173`.
5. Run the following command in the root directory:
@@ -36,9 +36,11 @@ docker compose up -d --build
### Configuration
Configure the backend in `backend.env` and the frontend in `frontend.env` when using Docker Compose. The backend also loads `appsettings.json`, with environment variables taking precedence.
Configure Sharpbin in the root `.env` file when using Docker Compose. The backend loads this file as environment variables. Compose passes only the backend URL, public origin, and shared view-recording key to the frontend.
Compose explicitly sets `ConnectionStrings__DefaultConnection`, `DATA_PROTECTION_KEY_PATH`, and the frontend's `VITE_API_URL`. These override values from the environment files; change `docker-compose.yml` to override them.
The backend image includes `appsettings.json` with application defaults. Environment variables have priority, so you do not need to edit or mount that file for normal setup. Additional backend settings, including `EmailSettings__Host` and other SMTP settings, can be added to `.env` using their existing names.
Compose defaults the database to `/app/data/sharpbin.db`, Data Protection keys to `/app/data/keys`, and `VITE_API_URL` to `http://backend:8080`. To override them, add `ConnectionStrings__DefaultConnection`, `DATA_PROTECTION_KEY_PATH`, or `VITE_API_URL` to `.env`. Keep database and key paths under `/app/data` to use the existing persistent volume.
The example secrets are placeholders, not secure defaults. Generate a separate secret for JWT signing, API-key hashing, and view hashing, plus one shared internal API key. This command generates a 64-character random hex value; run it once for each secret:
@@ -52,7 +54,17 @@ or use openSSL:
openssl rand -hex 32
```
Set the same shared value in `PasteSettings__View_Internal_API_Key` in `backend.env` and `VIEW_INTERNAL_API_KEY` in `frontend.env`. Keep generated secrets across restarts and updates. Changing the API-key HMAC secret invalidates existing API keys.
Set the shared key once as `PasteSettings__View_Internal_API_Key`. Compose supplies it to the frontend as `VIEW_INTERNAL_API_KEY`. Keep generated secrets across restarts and updates. Changing the API-key HMAC secret invalidates existing API keys.
#### Migrating an Existing Installation
1. Copy the values from `backend.env` into the root `.env` file. If `.env` already exists, merge the settings without replacing existing values blindly.
2. Copy `ORIGIN` from `frontend.env`. If it was unset, use your public frontend URL, including the scheme.
3. Keep `PasteSettings__View_Internal_API_Key` set to the existing shared key. The separate `VIEW_INTERNAL_API_KEY` entry is no longer needed for Compose.
4. Move any custom `appsettings.json` values into `.env` using `__` for nested settings. For array settings, use numbered entries such as `AllowedCorsOrigins__0`. If you need to retain a custom JSON file, add a read-only mount for it in `compose.override.yaml`.
5. Run `docker compose up -d --build`. The old `backend.env` and `frontend.env` files are no longer read by Compose.
Keep the existing database volume, Data Protection keys, and secret values. Do not regenerate secrets during this migration.
> When configuring via `appsettings.json` instead of for example `ConnectionStrings__DefaultConnection` it would be:
@@ -80,14 +92,14 @@ Set the same shared value in `PasteSettings__View_Internal_API_Key` in `backend.
- `PasteSettings__EnablePasteCompression`:**true**: Enables/Disables server-side paste compression.
- `PasteSettings__RequiresVerification`:**true**: Enables/Disables CAPTCHA verification when creating pastes.
- `PasteSettings__View_HMAC_Secret`: A required random secret of 32–128 characters used to hash viewer identifiers.
- `PasteSettings__View_Internal_API_Key`: A shared key of 32–128 characters used to authorize view recording. Match the frontend's `VIEW_INTERNAL_API_KEY`.
- `PasteSettings__View_Internal_API_Key`: A shared key of 32–128 characters used to authorize view recording. Compose passes it to both services.
#### Frontend (SharpbinV3.Client)
- `VITE_API_URL`: The backend URL reachable from the frontend server. Defaults to `http://localhost:5050`; Compose overrides it with `http://backend:8080`. Browser requests use the frontend's `/api` proxy.
- `VITE_API_URL`: The backend URL reachable from the frontend server. Defaults to `http://localhost:5050` when running directly and `http://backend:8080` in Compose. Browser requests use the frontend's `/api` proxy.
- `ORIGIN`: The public frontend URL, including its scheme (e.g., `https://example.com`). Used by the production Node server; see [SvelteKit's Node adapter documentation](https://svelte.dev/docs/kit/adapter-node#ORIGIN-PROTOCOL_HEADER-HOST_HEADER-and-PORT_HEADER).
- `VITE_ALLOWED_HOSTS`: A comma-separated list used only by Vite dev/preview (e.g., `localhost,sharpbin.cc`). Export it in the shell before starting Vite; the config reads `process.env` directly. It does not configure production host restrictions.
- `VIEW_INTERNAL_API_KEY`: The production frontend's shared view-recording key. Falls back to `View_HMAC_Internal_API_Key` if unset. The frontend does not read `PasteSettings__View_Internal_API_Key`.
- `VIEW_INTERNAL_API_KEY`: The production frontend's shared view-recording key. Compose sets it from `PasteSettings__View_Internal_API_Key`; do not duplicate it in the root `.env`. When running the frontend directly, set it yourself or use the existing `View_HMAC_Internal_API_Key` fallback.
When `NODE_ENV=development`, the frontend uses a fixed development-only internal key matching the backend's checked-in development configuration and ignores both environment key names. See the [client README](SharpbinV3.Client/README.md) for development and standalone production setup.
+6 -4
View File
@@ -38,13 +38,15 @@ The frontend will be available at http://localhost:5173.
### Running in Production
Docker Compose loads `frontend.env` and runs the built Node server on port 5173. Set these runtime variables:
Docker Compose reads the root `.env` file and runs the built Node server on port 5173. Configure these values there:
- `VITE_API_URL`: Backend URL. Compose sets `http://backend:8080` directly, overriding `frontend.env`.
- `VITE_API_URL`: Backend URL. Defaults to `http://backend:8080` in Compose.
- `ORIGIN`: Public frontend URL, such as `https://example.com` or `http://localhost:5173` for local Docker testing.
- `VIEW_INTERNAL_API_KEY`: Same generated value as the backend's `PasteSettings__View_Internal_API_Key`. If unset, the frontend reads `View_HMAC_Internal_API_Key`; it does not read the backend setting name.
- `PasteSettings__View_Internal_API_Key`: Shared view-recording key. Compose passes it to the frontend as `VIEW_INTERNAL_API_KEY`, so you only set it once.
For a standalone Node deployment, `.env` is not loaded automatically. Build the frontend, then load your environment file explicitly:
For a standalone Node deployment, set `VITE_API_URL`, `ORIGIN`, and `VIEW_INTERNAL_API_KEY` in the client's own `.env` file. The key must match the backend's `PasteSettings__View_Internal_API_Key`. The frontend still supports `View_HMAC_Internal_API_Key` as a fallback; it does not read the backend setting name directly.
The standalone server does not load `.env` automatically. Build the frontend, then load your environment file explicitly:
```bash
npm run build
+1 -3
View File
@@ -6,7 +6,6 @@ import svelte from 'eslint-plugin-svelte';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
@@ -33,8 +32,7 @@ export default defineConfig(
parserOptions: {
projectService: true,
extraFileExtensions: ['.svelte'],
parser: ts.parser,
svelteConfig
parser: ts.parser
}
}
}
+137 -159
View File
@@ -51,8 +51,8 @@
"svelte-check": "^4.3.4",
"tailwind-scrollbar": "^4.0.2",
"tailwindcss": "^4.1.17",
"typescript": "^5.9.3",
"typescript-eslint": "^8.48.1",
"typescript": "^6.0.3",
"typescript-eslint": "^8.71.2",
"vite": "^8.0.16"
}
},
@@ -282,9 +282,9 @@
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz",
"integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==",
"version": "4.10.1",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz",
"integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -671,9 +671,6 @@
"cpu": [
"arm"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -690,9 +687,6 @@
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -709,9 +703,6 @@
"cpu": [
"ppc64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -728,9 +719,6 @@
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -747,9 +735,6 @@
"cpu": [
"s390x"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -766,9 +751,6 @@
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -785,9 +767,6 @@
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -804,9 +783,6 @@
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -823,9 +799,6 @@
"cpu": [
"arm"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -848,9 +821,6 @@
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -873,9 +843,6 @@
"cpu": [
"ppc64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -898,9 +865,6 @@
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -923,9 +887,6 @@
"cpu": [
"s390x"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -948,9 +909,6 @@
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -973,9 +931,6 @@
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -998,9 +953,6 @@
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -2281,20 +2233,20 @@
"optional": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.50.1.tgz",
"integrity": "sha512-PKhLGDq3JAg0Jk/aK890knnqduuI/Qj+udH7wCf0217IGi4gt+acgCyPVe79qoT+qKUvHMDQkwJeKW9fwl8Cyw==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.2.tgz",
"integrity": "sha512-K72/pvT7qpm8q3k8G5u93NCSN1RcLxX5h7Gw0bQpbMXviBHeY6Nx1WEwmk9wP+eKTSQ8ecxvcgt/ZX/rB938xQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.50.1",
"@typescript-eslint/type-utils": "8.50.1",
"@typescript-eslint/utils": "8.50.1",
"@typescript-eslint/visitor-keys": "8.50.1",
"ignore": "^7.0.0",
"@eslint-community/regexpp": "^4.12.2",
"@typescript-eslint/scope-manager": "8.71.2",
"@typescript-eslint/type-utils": "8.71.2",
"@typescript-eslint/utils": "8.71.2",
"@typescript-eslint/visitor-keys": "8.71.2",
"ignore": "^7.0.5",
"natural-compare": "^1.4.0",
"ts-api-utils": "^2.1.0"
"ts-api-utils": "^2.5.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2304,15 +2256,15 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"@typescript-eslint/parser": "^8.50.1",
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
"@typescript-eslint/parser": "^8.71.2",
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz",
"integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==",
"version": "7.0.12",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz",
"integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2320,17 +2272,17 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.50.1.tgz",
"integrity": "sha512-hM5faZwg7aVNa819m/5r7D0h0c9yC4DUlWAOvHAtISdFTc8xB86VmX5Xqabrama3wIPJ/q9RbGS1worb6JfnMg==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.2.tgz",
"integrity": "sha512-aTtmZjp/x3gsGHkDs04/1I8kNogBJkpQaeGaN0PfiG43NzDEmW2n+OP5im9wfsvyX0yP1UZWBrAGtDBfH9jEVw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/scope-manager": "8.50.1",
"@typescript-eslint/types": "8.50.1",
"@typescript-eslint/typescript-estree": "8.50.1",
"@typescript-eslint/visitor-keys": "8.50.1",
"debug": "^4.3.4"
"@typescript-eslint/scope-manager": "8.71.2",
"@typescript-eslint/types": "8.71.2",
"@typescript-eslint/typescript-estree": "8.71.2",
"@typescript-eslint/visitor-keys": "8.71.2",
"debug": "^4.4.3"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2340,20 +2292,20 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/@typescript-eslint/project-service": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.50.1.tgz",
"integrity": "sha512-E1ur1MCVf+YiP89+o4Les/oBAVzmSbeRB0MQLfSlYtbWU17HPxZ6Bhs5iYmKZRALvEuBoXIZMOIRRc/P++Ortg==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.2.tgz",
"integrity": "sha512-Pd68GsLVh5ZXlcEccFPdhSOvtHZ/2WU0XsA8zmXOS3F158lVlcTLhfQ6qvtL1RzbMie0Kp8xtbVwAg4nejKPHw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/tsconfig-utils": "^8.50.1",
"@typescript-eslint/types": "^8.50.1",
"debug": "^4.3.4"
"@typescript-eslint/tsconfig-utils": "^8.71.2",
"@typescript-eslint/types": "^8.71.2",
"debug": "^4.4.3"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2363,18 +2315,18 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <6.0.0"
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.50.1.tgz",
"integrity": "sha512-mfRx06Myt3T4vuoHaKi8ZWNTPdzKPNBhiblze5N50//TSHOAQQevl/aolqA/BcqqbJ88GUnLqjjcBc8EWdBcVw==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.2.tgz",
"integrity": "sha512-YF4wgg5iUX5Obywoac27B56FhozMNFhdJSbh11H5GBAwmBtfyRhmgTQqW9tRNNmHDvsZ2CX6UGzoz+YfYn2Leg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.50.1",
"@typescript-eslint/visitor-keys": "8.50.1"
"@typescript-eslint/types": "8.71.2",
"@typescript-eslint/visitor-keys": "8.71.2"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2385,9 +2337,9 @@
}
},
"node_modules/@typescript-eslint/tsconfig-utils": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.50.1.tgz",
"integrity": "sha512-ooHmotT/lCWLXi55G4mvaUF60aJa012QzvLK0Y+Mp4WdSt17QhMhWOaBWeGTFVkb2gDgBe19Cxy1elPXylslDw==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.2.tgz",
"integrity": "sha512-jz49TAWokm/7yWD9/o837nYax9DyALxIPOImdImvVzo6canBCZYzin8zJyqNR5k1j9K1DE0bVvr0XYB+99uAdg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2398,21 +2350,21 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <6.0.0"
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.50.1.tgz",
"integrity": "sha512-7J3bf022QZE42tYMO6SL+6lTPKFk/WphhRPe9Tw/el+cEwzLz1Jjz2PX3GtGQVxooLDKeMVmMt7fWpYRdG5Etg==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.2.tgz",
"integrity": "sha512-cC8UaalCViJkb3rH/xLIvidEwoFRtMZMUqDjjJMGEKaTFwYRHYBcoczlEGHuvkHEO8svRDrgZ0yQgOArFmwang==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.50.1",
"@typescript-eslint/typescript-estree": "8.50.1",
"@typescript-eslint/utils": "8.50.1",
"debug": "^4.3.4",
"ts-api-utils": "^2.1.0"
"@typescript-eslint/types": "8.71.2",
"@typescript-eslint/typescript-estree": "8.71.2",
"@typescript-eslint/utils": "8.71.2",
"debug": "^4.4.3",
"ts-api-utils": "^2.5.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2422,14 +2374,14 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/@typescript-eslint/types": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.50.1.tgz",
"integrity": "sha512-v5lFIS2feTkNyMhd7AucE/9j/4V9v5iIbpVRncjk/K0sQ6Sb+Np9fgYS/63n6nwqahHQvbmujeBL7mp07Q9mlA==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.2.tgz",
"integrity": "sha512-y5Ukl3oVp7e/VGxqIoEXoeb/Roj71PAJ4WG/N/RGj+eeDvKRLM15kGr9MijLbN0i03S52zxu31Z98E5gWChJKw==",
"devOptional": true,
"license": "MIT",
"engines": {
@@ -2441,21 +2393,21 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.50.1.tgz",
"integrity": "sha512-woHPdW+0gj53aM+cxchymJCrh0cyS7BTIdcDxWUNsclr9VDkOSbqC13juHzxOmQ22dDkMZEpZB+3X1WpUvzgVQ==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.2.tgz",
"integrity": "sha512-DgNOEsl4pdYzwSL+N/Cl33tX1Hlw3FvId73LnKXfq7jnrF2viOEn7X+P7RBkkSWCVm92gnWd28GIC5vJuLREeA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/project-service": "8.50.1",
"@typescript-eslint/tsconfig-utils": "8.50.1",
"@typescript-eslint/types": "8.50.1",
"@typescript-eslint/visitor-keys": "8.50.1",
"debug": "^4.3.4",
"minimatch": "^9.0.4",
"semver": "^7.6.0",
"@typescript-eslint/project-service": "8.71.2",
"@typescript-eslint/tsconfig-utils": "8.71.2",
"@typescript-eslint/types": "8.71.2",
"@typescript-eslint/visitor-keys": "8.71.2",
"debug": "^4.4.3",
"minimatch": "^10.2.2",
"semver": "^7.7.3",
"tinyglobby": "^0.2.15",
"ts-api-utils": "^2.1.0"
"ts-api-utils": "^2.5.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2465,46 +2417,59 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <6.0.0"
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/balanced-match": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
"dev": true,
"license": "MIT",
"engines": {
"node": "18 || 20 || >=22"
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
"version": "2.1.7",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
"version": "5.0.12",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
"balanced-match": "^4.0.2"
},
"engines": {
"node": "20 || >=22"
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
"version": "9.0.9",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
"integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
"version": "10.2.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
"dev": true,
"license": "ISC",
"license": "BlueOak-1.0.0",
"dependencies": {
"brace-expansion": "^2.0.2"
"brace-expansion": "^5.0.8"
},
"engines": {
"node": ">=16 || 14 >=14.17"
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/@typescript-eslint/utils": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.50.1.tgz",
"integrity": "sha512-lCLp8H1T9T7gPbEuJSnHwnSuO9mDf8mfK/Nion5mZmiEaQD9sWf9W4dfeFqRyqRjF06/kBuTmAqcs9sewM2NbQ==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.2.tgz",
"integrity": "sha512-RyKa1G1M9rKHDhrk+HJtiF1MvLD5Ux2JW3TSkzw+02pRALdpJb+QzG1Y5em+LvCgzGwgg8H7mBRFKljNz7ImPw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.7.0",
"@typescript-eslint/scope-manager": "8.50.1",
"@typescript-eslint/types": "8.50.1",
"@typescript-eslint/typescript-estree": "8.50.1"
"@eslint-community/eslint-utils": "^4.9.1",
"@typescript-eslint/scope-manager": "8.71.2",
"@typescript-eslint/types": "8.71.2",
"@typescript-eslint/typescript-estree": "8.71.2"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2514,19 +2479,19 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.50.1.tgz",
"integrity": "sha512-IrDKrw7pCRUR94zeuCSUWQ+w8JEf5ZX5jl/e6AHGSLi1/zIr0lgutfn/7JpfCey+urpgQEdrZVYzCaVVKiTwhQ==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.2.tgz",
"integrity": "sha512-zozlN0UA32bSG2zkKAgQyRYSbEISVoyU6vvkKYo2aSny74D8Jh4e+POkJ6Lk0dlezZi5x7TtD+88Xb06IB8nhg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.50.1",
"eslint-visitor-keys": "^4.2.1"
"@typescript-eslint/types": "8.71.2",
"eslint-visitor-keys": "^5.0.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2536,6 +2501,19 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz",
"integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": "^20.19.0 || ^22.13.0 || >=24"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/acorn": {
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
@@ -5761,9 +5739,9 @@
}
},
"node_modules/ts-api-utils": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.2.0.tgz",
"integrity": "sha512-L6f5oQRAoLU1RwXz0Ab9mxsE7LtxeVB6AIR1lpkZMsOyg/JXeaxBaXa/FVCBZyNr9S9I4wkHrlZTklX+im+WMw==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz",
"integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==",
"dev": true,
"license": "MIT",
"engines": {
@@ -5806,9 +5784,9 @@
}
},
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
"devOptional": true,
"license": "Apache-2.0",
"bin": {
@@ -5820,16 +5798,16 @@
}
},
"node_modules/typescript-eslint": {
"version": "8.50.1",
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.50.1.tgz",
"integrity": "sha512-ytTHO+SoYSbhAH9CrYnMhiLx8To6PSSvqnvXyPUgPETCvB6eBKmTI9w6XMPS3HsBRGkwTVBX+urA8dYQx6bHfQ==",
"version": "8.71.2",
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.2.tgz",
"integrity": "sha512-Rz4effbMy2g9wnvOJZG6SbVavX313Lap1vNEbk1RUochzickvzP8P4HB+bkNg5e50eVz1hQGjh9K1omI1xB4Bw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/eslint-plugin": "8.50.1",
"@typescript-eslint/parser": "8.50.1",
"@typescript-eslint/typescript-estree": "8.50.1",
"@typescript-eslint/utils": "8.50.1"
"@typescript-eslint/eslint-plugin": "8.71.2",
"@typescript-eslint/parser": "8.71.2",
"@typescript-eslint/typescript-estree": "8.71.2",
"@typescript-eslint/utils": "8.71.2"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -5839,8 +5817,8 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/uglify-js": {
+7 -3
View File
@@ -1,7 +1,7 @@
{
"name": "sharpbinv3.client",
"private": true,
"version": "3.0.5",
"version": "3.1.0",
"type": "module",
"scripts": {
"dev": "vite dev",
@@ -40,10 +40,14 @@
"svelte-check": "^4.3.4",
"tailwind-scrollbar": "^4.0.2",
"tailwindcss": "^4.1.17",
"typescript": "^5.9.3",
"typescript-eslint": "^8.48.1",
"typescript": "^6.0.3",
"typescript-eslint": "^8.71.2",
"vite": "^8.0.16"
},
"imports": {
"#lib": "./src/lib/index.ts",
"#lib/*": "./src/lib/*"
},
"dependencies": {
"@fontsource/inter": "^5.2.8",
"@fontsource/jetbrains-mono": "^5.2.8",
@@ -1,10 +1,10 @@
<script lang="ts">
import QRCode from 'qrcode';
import { getRefreshToken, getToken, setTokens } from '$lib/utils/auth';
import { parseTotpEnabled } from '$lib/utils/totp';
import { getRefreshToken, getToken, setTokens } from '#lib/utils/auth';
import { parseTotpEnabled } from '#lib/utils/totp';
import { tick } from 'svelte';
import { extractError } from '$lib/utils/misc';
import type { ModalItem, ModalMode } from '$lib/types/modal';
import { extractError } from '#lib/utils/misc';
import type { ModalItem, ModalMode } from '#lib/types/modal';
interface Props {
show?: boolean;
@@ -1,6 +1,6 @@
<script lang="ts">
import Modal from '$lib/components/Modal.svelte';
import { cancelModal, confirmModal, modal } from '$lib/stores/modal';
import Modal from '#lib/components/Modal.svelte';
import { cancelModal, confirmModal, modal } from '#lib/stores/modal';
let state = $derived($modal);
</script>
@@ -1,9 +1,9 @@
<script lang="ts">
import { user } from '$lib/stores/user';
import { user } from '#lib/stores/user';
import { resolve } from '$app/paths';
import { page } from '$app/state';
import { clearTokens, hasRole } from '$lib/utils/auth';
import logo from '$lib/assets/favicon.svg';
import { clearTokens, hasRole } from '#lib/utils/auth';
import logo from '#lib/assets/favicon.svg';
import type { PageData } from '../../routes/$types';
import { slide } from 'svelte/transition';
import { Menu, X } from '@lucide/svelte';
@@ -1,5 +1,5 @@
<script lang="ts">
import { tooltip, dateToRelativeString, formatNumber, formatBytes } from '$lib/utils/misc';
import { tooltip, dateToRelativeString, formatNumber, formatBytes } from '#lib/utils/misc';
import { resolve } from '$app/paths';
import {
Eye,
@@ -15,8 +15,8 @@
HatGlasses,
ThumbsUp
} from '@lucide/svelte';
import { syntaxes } from '$lib/consts';
import type { Paste } from '$lib/types/paste';
import { syntaxes } from '#lib/consts';
import type { Paste } from '#lib/types/paste';
interface Props {
paste: Paste;
@@ -34,7 +34,7 @@
{#if compact}
<a
href={resolve(`/${paste.id}`)}
href={resolve(`/[id]`, { id: paste.id })}
class="flex flex-col gap-1 rounded border border-neutral-700 bg-neutral-800 px-4 py-3 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
>
<div class="flex w-full flex-row justify-between">
@@ -119,7 +119,7 @@
</a>
{:else}
<a
href={resolve(`/${paste.id}`)}
href={resolve(`/[id]`, { id: paste.id })}
class="flex flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
>
<span
@@ -1,14 +1,14 @@
<script lang="ts">
import type { CommentReaction, CommentTreeNode } from '$lib/types/comment';
import { dateToRelativeString, tooltip } from '$lib/utils/misc';
import { parseCommentMarkdown } from '$lib/utils/markdown';
import { escapeHtml } from '$lib/utils/html';
import { user } from '$lib/stores/user';
import PasteCommentItem from '$lib/components/PasteCommentItem.svelte';
import type { CommentReaction, CommentTreeNode } from '#lib/types/comment';
import { dateToRelativeString, tooltip } from '#lib/utils/misc';
import { parseCommentMarkdown } from '#lib/utils/markdown';
import { escapeHtml } from '#lib/utils/html';
import { user } from '#lib/stores/user';
import PasteCommentItem from '#lib/components/PasteCommentItem.svelte';
import { ThumbsUp, ThumbsDown, Trash2, Shredder, Reply, Quote } from '@lucide/svelte';
import { resolve } from '$app/paths';
import RichTextEditor from './RichTextEditor.svelte';
import { hasRole, roles } from '$lib/utils/auth';
import { hasRole, roles } from '#lib/utils/auth';
interface Props {
node: CommentTreeNode;
@@ -101,7 +101,7 @@
<span class="text-red-500">BANNED</span>
{/if}
<a
href={resolve(`/user/${node.author?.username}`)}
href={resolve(`/user/[username]`, { username: node.author?.username})}
class="flex items-center gap-2 underline"
>
<span
@@ -1,17 +1,17 @@
<script lang="ts">
import { onMount } from 'svelte';
import { getToken } from '$lib/utils/auth';
import { user } from '$lib/stores/user';
import { getToken } from '#lib/utils/auth';
import { user } from '#lib/stores/user';
import type {
CommentReaction,
CommentReactionResult,
PasteComment,
CommentTreeNode
} from '$lib/types/comment';
import PasteCommentItem from '$lib/components/PasteCommentItem.svelte';
} from '#lib/types/comment';
import PasteCommentItem from '#lib/components/PasteCommentItem.svelte';
import { SvelteMap } from 'svelte/reactivity';
import RichTextEditor from './RichTextEditor.svelte';
import { openModal } from '$lib/stores/modal';
import { openModal } from '#lib/stores/modal';
import { RefreshCw } from '@lucide/svelte';
interface Props {
@@ -237,15 +237,13 @@
}
</script>
<section id="comments-section" class="mt-6 rounded border border-neutral-700 bg-neutral-900 p-4">
<section
id="comments-section"
class="mt-4 w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4"
>
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-2">
<h2 class="text-lg font-semibold text-neutral-100">Comments</h2>
<span
class="rounded border border-neutral-700 bg-neutral-800 px-2 py-0.5 text-xs text-neutral-300"
>
{comments.length}
</span>
<h2 class="text-lg font-semibold text-neutral-100">{comments.length} Comments</h2>
</div>
<button
type="button"
@@ -1,6 +1,6 @@
<script lang="ts">
import { Bold, Italic, CodeXml, Quote, Send, Eye, Pencil } from '@lucide/svelte';
import { parseCommentMarkdown } from '$lib/utils/markdown';
import { parseCommentMarkdown } from '#lib/utils/markdown';
interface Props {
class?: string;
+1 -1
View File
@@ -1 +1 @@
// place files you want to import through the `$lib` alias in this folder.
// place files you want to import through the `#lib` alias in this folder.
+1 -1
View File
@@ -1,4 +1,4 @@
import { env } from '$env/dynamic/private';
import { env } from 'node:process';
export const apiUrl = env.VITE_API_URL ?? 'http://localhost:5050';
export const viewInternalApiKey =
+1 -1
View File
@@ -1,4 +1,4 @@
import { apiUrl } from '$lib/server/api';
import { apiUrl } from '#lib/server/api';
const methodsWithoutBody = new Set(['GET', 'HEAD']);
+1 -1
View File
@@ -1,5 +1,5 @@
import { writable } from 'svelte/store';
import type { ModalOpenOptions, ModalState } from '$lib/types/modal';
import type { ModalOpenOptions, ModalState } from '#lib/types/modal';
const initialState: ModalState = {
show: false,
+1 -1
View File
@@ -1,6 +1,6 @@
import { writable } from 'svelte/store';
import { browser } from '$app/environment';
import type { AuthUser } from '$lib/types/user';
import type { AuthUser } from '#lib/types/user';
let initial: AuthUser | null = null;
@@ -0,0 +1,9 @@
import { argon2id } from 'hash-wasm';
self.onmessage = async (event: MessageEvent<Parameters<typeof argon2id>[0]>) => {
try {
self.postMessage(await argon2id(event.data));
} catch {
self.postMessage(null);
}
};
+2 -2
View File
@@ -1,7 +1,7 @@
import { browser } from '$app/environment';
import type { Cookies } from '@sveltejs/kit';
import { user } from '$lib/stores/user';
import type { JWTUser } from '$lib/types/user';
import { user } from '#lib/stores/user';
import type { JWTUser } from '#lib/types/user';
export const roles = {
User: 1,
+128 -19
View File
@@ -1,5 +1,3 @@
import { argon2id } from 'hash-wasm';
const BASE64_CHUNK_SIZE = 0x8000;
const SALT_LENGTH = 16;
const IV_LENGTH = 12;
@@ -9,8 +7,58 @@ const ARGON2_PARALLELISM = 1;
const ARGON2_HASH_LENGTH = 32;
const AES_KEY_LENGTH = 256;
const ENCRYPTION_AAD = 'enc-v4';
const ENCRYPTED_DATA_OVERHEAD = 60;
const ENCRYPTED_METADATA_OVERHEAD = 150;
const ENCRYPTED_DATA_OVERHEAD = SALT_LENGTH + IV_LENGTH + 16;
const MAX_ENVELOPE_LENGTH = 16 * 1024 * 1024;
const ENCRYPTION_HEADER = {
version: 5,
kdf: 'Argon2id',
memorySize: ARGON2_MEMORY_SIZE,
iterations: ARGON2_ITERATIONS,
parallelism: ARGON2_PARALLELISM,
algorithm: 'AES-GCM',
saltLength: SALT_LENGTH,
ivLength: IV_LENGTH
};
let derivingKey = false;
async function argon2id(
options: Parameters<typeof import('hash-wasm').argon2id>[0]
): Promise<Uint8Array<ArrayBuffer>> {
if (derivingKey) throw new Error('Another encryption operation is already running.');
derivingKey = true;
try {
return await new Promise((resolve, reject) => {
const worker = new Worker(new URL('./argon2.worker.ts', import.meta.url), { type: 'module' });
const finish = () => {
clearTimeout(timeout);
worker.terminate();
};
const timeout = setTimeout(() => {
finish();
reject(new Error('Key derivation timed out.'));
}, 60_000);
worker.onmessage = (event: MessageEvent<Uint8Array | null>) => {
finish();
if (event.data instanceof Uint8Array && event.data.length === ARGON2_HASH_LENGTH) {
resolve(new Uint8Array(event.data));
} else reject(new Error('Key derivation failed. The device may lack memory.'));
};
worker.onerror = (event) => {
event.preventDefault();
finish();
reject(new Error('Unable to run the encryption worker.'));
};
try {
worker.postMessage(options);
} catch (error) {
finish();
reject(error);
}
});
} finally {
derivingKey = false;
}
}
function toBase64(bytes: Uint8Array): string {
let binary = '';
@@ -29,7 +77,21 @@ function fromBase64(data: string): Uint8Array {
return bytes;
}
export function encodePasswordFragment(password: string): string {
return `u1.${toBase64(new TextEncoder().encode(password))}`;
}
export function decodePasswordFragment(fragment: string): string {
return fragment.startsWith('u1.')
? new TextDecoder('utf-8', { fatal: true }).decode(fromBase64(fragment.slice(3)))
: atob(fragment);
}
export async function encryptAES(content: string, password: string): Promise<string> {
if (!password) throw new Error('Password required for encryption.');
if (estimateEncryptedSize(content) > MAX_ENVELOPE_LENGTH) {
throw new Error('Encrypted paste exceeds the supported size limit.');
}
const enc = new TextEncoder();
const salt = window.crypto.getRandomValues(new Uint8Array(SALT_LENGTH));
@@ -56,7 +118,7 @@ export async function encryptAES(content: string, password: string): Promise<str
{
name: 'AES-GCM',
iv,
additionalData: enc.encode(ENCRYPTION_AAD)
additionalData: enc.encode(JSON.stringify(ENCRYPTION_HEADER))
},
key,
enc.encode(content)
@@ -68,14 +130,7 @@ export async function encryptAES(content: string, password: string): Promise<str
combined.set(new Uint8Array(encryptedContent), salt.byteLength + iv.byteLength);
return JSON.stringify({
version: 4,
kdf: 'Argon2id',
memorySize: ARGON2_MEMORY_SIZE,
iterations: ARGON2_ITERATIONS,
parallelism: ARGON2_PARALLELISM,
algorithm: 'AES-GCM',
saltLength: salt.byteLength,
ivLength: iv.byteLength,
...ENCRYPTION_HEADER,
data: toBase64(combined)
});
}
@@ -84,17 +139,58 @@ export function estimateEncryptedSize(content: string): number {
const rawSize = new TextEncoder().encode(content).length;
const combinedSize = rawSize + ENCRYPTED_DATA_OVERHEAD;
const b64Size = Math.ceil(combinedSize / 3) * 4;
return b64Size + ENCRYPTED_METADATA_OVERHEAD;
return b64Size + JSON.stringify({ ...ENCRYPTION_HEADER, data: '' }).length;
}
export async function decryptAES(result: string, password: string): Promise<string | null> {
try {
const enc = new TextEncoder();
if (result.length > MAX_ENVELOPE_LENGTH) {
throw new Error('Encrypted paste exceeds the supported size limit.');
}
const parsed = JSON.parse(result);
if (!parsed || typeof parsed !== 'object' || parsed.algorithm !== 'AES-GCM') {
throw new Error('Unsupported or malformed encrypted paste.');
}
const legacyPBKDF2 =
parsed.version === 1 &&
parsed.kdf === 'PBKDF2' &&
parsed.iterations === 100000 &&
parsed.hash === 'SHA-256' &&
(parsed.saltLength === undefined || parsed.saltLength === SALT_LENGTH) &&
(parsed.ivLength === undefined || parsed.ivLength === IV_LENGTH);
const legacyArgon2 =
parsed.version === 4 && parsed.memorySize === 65536 && parsed.saltLength === 32;
const currentArgon2 =
(parsed.version === 4 || parsed.version === 5) &&
parsed.memorySize === ARGON2_MEMORY_SIZE &&
parsed.saltLength === SALT_LENGTH;
if (
!legacyPBKDF2 &&
!(
parsed.kdf === 'Argon2id' &&
parsed.iterations === ARGON2_ITERATIONS &&
parsed.parallelism === ARGON2_PARALLELISM &&
parsed.ivLength === IV_LENGTH &&
(legacyArgon2 || currentArgon2)
)
)
throw new Error('Unsupported encryption profile.');
if (
typeof parsed.data !== 'string' ||
!parsed.data.length ||
parsed.data.length % 4 !== 0 ||
!/^[A-Za-z0-9+/]*={0,2}$/.test(parsed.data)
) {
throw new Error('Malformed encrypted-paste encoding.');
}
const combined = fromBase64(parsed.data);
const saltLength = parsed.saltLength || SALT_LENGTH;
const ivLength = parsed.ivLength || IV_LENGTH;
const saltLength = parsed.saltLength ?? SALT_LENGTH;
const ivLength = parsed.ivLength ?? IV_LENGTH;
if (combined.length < saltLength + ivLength + 16) {
throw new Error('Encrypted paste is truncated.');
}
const salt = combined.slice(0, saltLength);
const iv = combined.slice(saltLength, saltLength + ivLength);
const data = combined.slice(saltLength + ivLength);
@@ -146,14 +242,27 @@ export async function decryptAES(result: string, password: string): Promise<stri
{
name: 'AES-GCM',
iv,
additionalData: enc.encode(ENCRYPTION_AAD)
additionalData: enc.encode(
parsed.version === 5
? JSON.stringify(ENCRYPTION_HEADER)
: currentArgon2
? ENCRYPTION_AAD
: ''
)
},
key,
data
);
return new TextDecoder().decode(decryptedContent);
} catch {
return null;
} catch (error) {
if (error instanceof DOMException && error.name === 'OperationError') return null;
if (
error instanceof SyntaxError ||
(error instanceof DOMException && error.name === 'InvalidCharacterError')
) {
throw new Error('Malformed encrypted paste.');
}
throw error;
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
import { marked } from 'marked';
import createDOMPurify from 'dompurify';
import type { WindowLike } from 'dompurify';
import { trustedDomains } from '$lib/consts';
import { trustedDomains } from '#lib/consts';
import { escapeHtml } from './html';
export const externalMediaWarningStorageKey = 'sharpbin:ignore-external-media-warning';
+1 -1
View File
@@ -1,4 +1,4 @@
import { syntaxes } from '$lib/consts';
import { syntaxes } from '#lib/consts';
/**
* @param bytes Bytes to format.
+7 -7
View File
@@ -1,13 +1,13 @@
<script lang="ts">
import { onMount } from 'svelte';
import './layout.css';
import favicon from '$lib/assets/favicon.svg';
import Navbar from '$lib/components/Navbar.svelte';
import Footer from '$lib/components/Footer.svelte';
import ModalHost from '$lib/components/ModalHost.svelte';
import { user } from '$lib/stores/user';
import { startTokenRefreshInterval, getToken, refreshTokenIfNeeded } from '$lib/utils/auth';
import { parseTotpEnabled } from '$lib/utils/totp';
import favicon from '#lib/assets/favicon.svg';
import Navbar from '#lib/components/Navbar.svelte';
import Footer from '#lib/components/Footer.svelte';
import ModalHost from '#lib/components/ModalHost.svelte';
import { user } from '#lib/stores/user';
import { startTokenRefreshInterval, getToken, refreshTokenIfNeeded } from '#lib/utils/auth';
import { parseTotpEnabled } from '#lib/utils/totp';
import { page } from '$app/state';
import type { LayoutData } from './$types';
+14 -9
View File
@@ -1,20 +1,20 @@
<script lang="ts">
import type { PageData } from './$types';
import { syntaxes, expiresOptions } from '$lib/consts';
import { user } from '$lib/stores/user';
import { getToken } from '$lib/utils/auth';
import { syntaxes, expiresOptions } from '#lib/consts';
import { user } from '#lib/stores/user';
import { getToken } from '#lib/utils/auth';
import { onMount } from 'svelte';
import { fly, fade } from 'svelte/transition';
import { encryptAES, estimateEncryptedSize } from '$lib/utils/encryption';
import { encryptAES, estimateEncryptedSize, encodePasswordFragment } from '#lib/utils/encryption';
import {
formatBytes,
formatNumber,
isBinaryData,
tooltip,
syntaxFromExtension
} from '$lib/utils/misc';
import { parseMarkdown } from '$lib/utils/markdown';
import Dropdown from '$lib/components/Dropdown.svelte';
} from '#lib/utils/misc';
import { parseMarkdown } from '#lib/utils/markdown';
import Dropdown from '#lib/components/Dropdown.svelte';
import { SvelteURLSearchParams } from 'svelte/reactivity';
import { FileUp, X, Eye, EyeClosed, Dices } from '@lucide/svelte';
@@ -162,7 +162,12 @@
let body = content;
if (selectedVisibility === 2) {
body = await encryptAES(content, password);
try {
body = await encryptAES(content, password);
} catch (cause) {
error = cause instanceof Error ? cause.message : 'Encryption failed.';
return;
}
}
if (
@@ -196,7 +201,7 @@
if (response.ok) {
const result = await response.json();
if (selectedVisibility === 2) {
const passwordBase64 = btoa(password);
const passwordBase64 = encodePasswordFragment(password);
window.location.href = `/${result.id}#${passwordBase64}`;
return;
}
@@ -1,21 +1,21 @@
import { syntaxes } from '$lib/consts';
import { apiUrl } from '$lib/server/api';
import { syntaxes } from '#lib/consts';
import { apiUrl } from '#lib/server/api';
import {
getCachedOgImage,
getCacheControlHeader,
getCacheTtlSeconds,
scheduleOgImageCachePurge,
storeCachedOgImage
} from '$lib/server/og/cache';
import OgPasteEmbed from '$lib/server/og/PasteEmbed.svelte';
import type { PasteEmbedProps } from '$lib/server/og/pasteEmbed';
import type { Paste } from '$lib/types/paste';
} from '#lib/server/og/cache';
import OgPasteEmbed from '#lib/server/og/PasteEmbed.svelte';
import type { PasteEmbedProps } from '#lib/server/og/pasteEmbed';
import type { Paste } from '#lib/types/paste';
import {
dateToRelativeString,
extractDateFromUUIDv7,
formatBytes,
formatNumber
} from '$lib/utils/misc';
} from '#lib/utils/misc';
import { Resvg } from '@resvg/resvg-js';
import { readFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
@@ -1,8 +1,8 @@
import type { PageServerLoad } from './$types';
import type { Paste } from '$lib/types/paste';
import type { PasteComment } from '$lib/types/comment';
import { getServerToken } from '$lib/utils/auth';
import { apiUrl, viewInternalApiKey } from '$lib/server/api';
import type { Paste } from '#lib/types/paste';
import type { PasteComment } from '#lib/types/comment';
import { getServerToken } from '#lib/utils/auth';
import { apiUrl, viewInternalApiKey } from '#lib/server/api';
import { error } from '@sveltejs/kit';
export const load: PageServerLoad = async ({ params, fetch, url, cookies, parent, request }) => {
+41 -25
View File
@@ -36,24 +36,24 @@
dateToRelativeString,
tooltip,
isBinaryData
} from '$lib/utils/misc';
} from '#lib/utils/misc';
import {
getIgnoreExternalMediaWarning,
parseMarkdown,
setIgnoreExternalMediaWarning
} from '$lib/utils/markdown';
import { syntaxes, expiresOptions } from '$lib/consts';
} from '#lib/utils/markdown';
import { syntaxes, expiresOptions } from '#lib/consts';
import { resolve } from '$app/paths';
import { decryptAES, encryptAES } from '$lib/utils/encryption';
import { escapeHtml } from '$lib/utils/html';
import { decryptAES, encryptAES, decodePasswordFragment } from '#lib/utils/encryption';
import { escapeHtml } from '#lib/utils/html';
import { fade } from 'svelte/transition';
import { getToken, hasRole } from '$lib/utils/auth';
import { user } from '$lib/stores/user';
import Dropdown from '$lib/components/Dropdown.svelte';
import PasteComments from '$lib/components/PasteComments.svelte';
import { openModal } from '$lib/stores/modal';
import type { Paste, PasteReaction } from '$lib/types/paste';
import HighlightWorker from '$lib/workers/highlight.worker?worker';
import { getToken, hasRole } from '#lib/utils/auth';
import { user } from '#lib/stores/user';
import Dropdown from '#lib/components/Dropdown.svelte';
import PasteComments from '#lib/components/PasteComments.svelte';
import { openModal } from '#lib/stores/modal';
import type { Paste, PasteReaction } from '#lib/types/paste';
import HighlightWorker from '#lib/workers/highlight.worker?worker';
interface Props {
data: PageData;
}
@@ -359,8 +359,8 @@
});
editMetadata = data.paste ? { ...data.paste } : null;
}
} catch {
editError = 'An error occurred while updating.';
} catch (cause) {
editError = cause instanceof Error ? cause.message : 'An error occurred while updating.';
} finally {
editLoading = false;
editing = false;
@@ -517,8 +517,20 @@
contentRendered = false;
decryptStatus = 'Preparing decryption...';
const urlHash = window.location.hash.slice(1);
let passwordFromUrl: string | null = null;
if (urlHash) {
const passwordFromUrl = atob(urlHash);
history.replaceState(
history.state,
'',
window.location.pathname + window.location.search
);
try {
passwordFromUrl = decodePasswordFragment(urlHash);
} catch {
/* empty */
}
}
if (passwordFromUrl !== null) {
decryptStatus = 'Deriving key...';
decryptedContent = await decryptAES(data.content, passwordFromUrl);
if (decryptedContent === null) {
@@ -528,11 +540,10 @@
decryptStatus = 'Deriving key...';
decryptedContent = await decryptAES(data.content, password);
if (decryptedContent === null) {
decryptError = 'Incorrect password. Please try again.';
decryptStatus = 'Decryption failed.';
decryptError = 'Wrong password or damaged encrypted paste.';
decryptStatus = decryptError;
} else {
await renderPaste();
history.replaceState(null, '', window.location.pathname + window.location.search);
}
} else {
decryptStatus = 'Decryption canceled.';
@@ -548,8 +559,8 @@
decryptStatus = 'Deriving key...';
decryptedContent = await decryptAES(data.content, password);
if (decryptedContent === null) {
decryptError = 'Incorrect password. Please try again.';
decryptStatus = 'Decryption failed.';
decryptError = 'Wrong password or damaged encrypted paste.';
decryptStatus = decryptError;
} else {
await renderPaste();
}
@@ -560,7 +571,12 @@
decryptStatus = 'Rendering content...';
await renderPaste();
}
} catch {
} catch (cause) {
if (data?.paste?.visibility === 2) {
decryptStatus = cause instanceof Error ? cause.message : 'Unable to decrypt this paste.';
contentRendered = false;
return;
}
decryptStatus = 'Rendering content...';
await renderPaste();
}
@@ -655,7 +671,7 @@
{#if data.paste.author}
<User class="inline-block h-4 w-4 text-neutral-400" />
<a
href={resolve(`/user/${data.paste.author.username}`)}
href={resolve(`/user/[username]`, { username: data.paste.author.username })}
class="text-neutral-400 transition-colors duration-300 hover:text-neutral-500"
>{data.paste.author.username}</a
>
@@ -938,7 +954,7 @@
</button>
<a
href={resolve(`/raw/${data.paste.id}`)}
href={resolve(`/raw/[id]`, { id: data.paste.id })}
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
>
<File class="{iconsOnly ? '' : 'mr-1'} h-5 w-5 text-neutral-400" />
@@ -1110,14 +1126,14 @@
{@html pasteContent}
</div>
{/if}
<PasteComments pasteId={data.paste.id} initialComments={data.comments ?? []} />
{:else}
<h1 class="mb-4 text-center text-4xl font-bold">Paste not found</h1>
<h2 class="mt-2 text-center text-xl">The paste you are looking for does not exist.</h2>
{/if}
</div>
<PasteComments pasteId={data.paste.id} initialComments={data.comments ?? []} />
<style>
.hljs {
background-color: var(--color-neutral-800) !important;
@@ -1,4 +1,4 @@
import { proxyBackendRequest } from '$lib/server/proxy';
import { proxyBackendRequest } from '#lib/server/proxy';
import type { RequestHandler } from './$types';
const handle: RequestHandler = ({ params, request, url }) => {
@@ -1,6 +1,6 @@
<script lang="ts">
import { resolve } from '$app/paths';
import { extractError } from '$lib/utils/misc';
import { extractError } from '#lib/utils/misc';
import { onMount } from 'svelte';
import type { PageData } from './$types';
@@ -1,4 +1,4 @@
import { apiUrl } from '$lib/server/api';
import { apiUrl } from '#lib/server/api';
import { json } from '@sveltejs/kit';
export const GET = async () => {
@@ -1,7 +1,7 @@
<script lang="ts">
import { resolve } from '$app/paths';
import { setTokens, startTokenRefreshInterval } from '$lib/utils/auth';
import { extractError } from '$lib/utils/misc';
import { setTokens, startTokenRefreshInterval } from '#lib/utils/auth';
import { extractError } from '#lib/utils/misc';
import { onMount } from 'svelte';
import type { PageData } from './$types';
@@ -1,4 +1,4 @@
import { proxyBackendRequest } from '$lib/server/proxy';
import { proxyBackendRequest } from '#lib/server/proxy';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = ({ request, url }) => {
@@ -1,4 +1,4 @@
import { proxyBackendRequest } from '$lib/server/proxy';
import { proxyBackendRequest } from '#lib/server/proxy';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = ({ params, request, url }) => {
@@ -1,5 +1,5 @@
import type { RequestHandler } from '@sveltejs/kit';
import { apiUrl } from '$lib/server/api';
import { apiUrl } from '#lib/server/api';
export const GET: RequestHandler = async ({ params, request }) => {
const { id } = params;
@@ -1,6 +1,6 @@
import type { PageServerLoad } from './$types';
import type { Paste } from '$lib/types/paste';
import { extractError } from '$lib/utils/misc';
import type { Paste } from '#lib/types/paste';
import { extractError } from '#lib/utils/misc';
import { error } from '@sveltejs/kit';
export const load: PageServerLoad = async ({ fetch, request }) => {
@@ -1,7 +1,7 @@
<script lang="ts">
import type { PageData } from './$types';
import { onMount } from 'svelte';
import Paste from '$lib/components/Paste.svelte';
import Paste from '#lib/components/Paste.svelte';
interface Props {
data: PageData;
@@ -1,7 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { setTokens, startTokenRefreshInterval } from '$lib/utils/auth';
import { extractError } from '$lib/utils/misc';
import { setTokens, startTokenRefreshInterval } from '#lib/utils/auth';
import { extractError } from '#lib/utils/misc';
import { Check, X, Eye, EyeClosed } from '@lucide/svelte';
import { slide, fade } from 'svelte/transition';
import { resolve } from '$app/paths';
@@ -1,8 +1,8 @@
import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';
import { apiUrl } from '$lib/server/api';
import { getServerToken, clearServerTokens, roles, getUserFromToken } from '$lib/utils/auth';
import type { Report } from '$lib/types/report';
import { apiUrl } from '#lib/server/api';
import { getServerToken, clearServerTokens, roles, getUserFromToken } from '#lib/utils/auth';
import type { Report } from '#lib/types/report';
export const load: PageServerLoad = async ({ fetch, cookies, params, url, request }) => {
const token = getServerToken(cookies);
@@ -1,9 +1,9 @@
<script lang="ts">
import type { PageData } from './$types';
import { resolve } from '$app/paths';
import { reportStatusLabels, reportTargetLabels, reportTypeLabels } from '$lib/types/report';
import { tooltip } from '$lib/utils/misc';
import { getToken } from '$lib/utils/auth';
import { reportStatusLabels, reportTargetLabels, reportTypeLabels } from '#lib/types/report';
import { tooltip } from '#lib/utils/misc';
import { getToken } from '#lib/utils/auth';
interface Props {
data: PageData;
@@ -75,7 +75,7 @@
{#if report.reporterUsername}
<a
class="text-neutral-200 hover:text-white hover:underline"
href={resolve(`/user/${report.reporterUsername}`)}
href={resolve(`/user/[username]`, { username: report.reporterUsername})}
use:tooltip={report.reporterUUID}
>
{report.reporterDisplayName || report.reporterUsername}
@@ -89,7 +89,7 @@
Target Paste:
<a
class="text-neutral-200 hover:text-white hover:underline"
href={resolve(`/${report.pasteId}`)}
href={resolve(`/[id]`, { id: report.pasteId})}
>
{report.pasteTitle !== '' ? report.pasteTitle : report.pasteId}
</a>
@@ -101,7 +101,7 @@
{#if report.targetUsername}
<a
class="text-neutral-200 hover:text-white hover:underline"
href={resolve(`/user/${report.targetUsername}`)}
href={resolve(`/user/[username]`, { username: report.targetUsername})}
use:tooltip={report.userUUID}
>
{report.targetDisplayName || report.targetUsername}
@@ -1,15 +1,15 @@
import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';
import { apiUrl } from '$lib/server/api';
import { apiUrl } from '#lib/server/api';
import {
getServerToken,
getUserFromToken,
clearServerTokens,
hasRole,
roles
} from '$lib/utils/auth';
import type { ReportListResponse } from '$lib/types/report';
import { extractError } from '$lib/utils/misc';
} from '#lib/utils/auth';
import type { ReportListResponse } from '#lib/types/report';
import { extractError } from '#lib/utils/misc';
function normalizeTarget(value: string | null): 'all' | 'pastes' | 'users' {
if (value === 'pastes' || value === 'users') return value;
@@ -5,8 +5,8 @@
import type { PageData } from './$types';
import { resolve } from '$app/paths';
import { goto } from '$app/navigation';
import { reportStatusLabels, reportTargetLabels, reportTypeLabels } from '$lib/types/report';
import { tooltip } from '$lib/utils/misc';
import { reportStatusLabels, reportTargetLabels, reportTypeLabels } from '#lib/types/report';
import { tooltip } from '#lib/utils/misc';
import { SvelteURLSearchParams } from 'svelte/reactivity';
interface Props {
@@ -200,11 +200,11 @@
class="flex cursor-pointer flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
role="link"
tabindex="0"
onclick={() => goto(resolve(`/report/${report.reportID}`))}
onclick={() => goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}))}
onkeydown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
goto(resolve(`/report/${report.reportID}`));
goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}));
}
}}
>
@@ -221,7 +221,7 @@
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
{#if report.pasteId}
<a
href={resolve(`/${report.pasteId}`)}
href={resolve(`/[id]`, { id: report.pasteId})}
class="text-neutral-300 hover:text-white"
onclick={stopPropagation(bubble('click'))}
>
@@ -231,7 +231,7 @@
{#if report.userUUID}
{#if report.targetUsername}
<a
href={resolve(`/user/${report.targetUsername}`)}
href={resolve(`/user/[username]`, {username: report.targetUsername})}
class="text-neutral-300 hover:text-white"
use:tooltip={report.userUUID}
onclick={stopPropagation(bubble('click'))}
@@ -244,7 +244,7 @@
{/if}
{#if report.reporterUsername}
<a
href={resolve(`/user/${report.reporterUsername}`)}
href={resolve(`/user/[username]`, { username: report.reporterUsername})}
class="text-neutral-300 hover:text-white"
use:tooltip={report.reporterUUID}
onclick={stopPropagation(bubble('click'))}
@@ -1,5 +1,5 @@
import { apiUrl } from '$lib/server/api';
import { extractError } from '$lib/utils/misc';
import { apiUrl } from '#lib/server/api';
import { extractError } from '#lib/utils/misc';
import { error } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
@@ -1,6 +1,6 @@
<script lang="ts">
import { resolve } from '$app/paths';
import { extractError } from '$lib/utils/misc';
import { extractError } from '#lib/utils/misc';
import { Check, X } from '@lucide/svelte';
import { slide, fade } from 'svelte/transition';
import type { PageData } from './$types';
@@ -1,7 +1,7 @@
import type { PageServerLoad } from './$types';
import { apiUrl } from '$lib/server/api';
import { apiUrl } from '#lib/server/api';
import { error, isHttpError } from '@sveltejs/kit';
import { extractError } from '$lib/utils/misc';
import { extractError } from '#lib/utils/misc';
export const load: PageServerLoad = async ({ fetch }) => {
try {
@@ -1,6 +1,6 @@
<script lang="ts">
import type { PageData } from './$types';
import { formatBytes, formatNumber, tooltip } from '$lib/utils/misc';
import { formatBytes, formatNumber, tooltip } from '#lib/utils/misc';
import { FileText, Users, Database, TrendingUp } from '@lucide/svelte';
interface Props {
@@ -1,11 +1,11 @@
import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';
import { apiUrl } from '$lib/server/api';
import { getServerToken } from '$lib/utils/auth';
import type { User } from '$lib/types/user';
import type { Paste } from '$lib/types/paste';
import type { Pagination } from '$lib/types/pagination';
import type { Report, ReportListResponse } from '$lib/types/report';
import { apiUrl } from '#lib/server/api';
import { getServerToken } from '#lib/utils/auth';
import type { User } from '#lib/types/user';
import type { Paste } from '#lib/types/paste';
import type { Pagination } from '#lib/types/pagination';
import type { Report, ReportListResponse } from '#lib/types/report';
function decodeJwtRoles(token?: string | null): number {
try {
@@ -6,7 +6,7 @@
import { goto, afterNavigate } from '$app/navigation';
import { page } from '$app/state';
import type { PageData } from './$types';
import type { Pagination } from '$lib/types/pagination';
import type { Pagination } from '#lib/types/pagination';
import {
User,
CalendarDays,
@@ -30,13 +30,13 @@
tooltip,
dateToRelativeString,
extractError
} from '$lib/utils/misc';
import { clearTokens, getToken, hasRole, roles } from '$lib/utils/auth';
import { openModal } from '$lib/stores/modal';
import { user } from '$lib/stores/user';
} from '#lib/utils/misc';
import { clearTokens, getToken, hasRole, roles } from '#lib/utils/auth';
import { openModal } from '#lib/stores/modal';
import { user } from '#lib/stores/user';
import { onMount } from 'svelte';
import Paste from '$lib/components/Paste.svelte';
import { reportStatusLabels, reportTargetLabels, reportTypeLabels } from '$lib/types/report';
import Paste from '#lib/components/Paste.svelte';
import { reportStatusLabels, reportTargetLabels, reportTypeLabels } from '#lib/types/report';
import { fade } from 'svelte/transition';
interface Props {
@@ -1676,11 +1676,11 @@
class="flex cursor-pointer flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
role="link"
tabindex="0"
onclick={() => goto(resolve(`/report/${report.reportID}`))}
onclick={() => goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}))}
onkeydown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
goto(resolve(`/report/${report.reportID}`));
goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}));
}
}}
>
@@ -1697,7 +1697,7 @@
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
{#if report.pasteId}
<a
href={resolve(`/${report.pasteId}`)}
href={resolve(`/[id]`, {id:report.pasteId})}
class="text-neutral-300 hover:text-white"
onclick={stopPropagation(bubble('click'))}
>
@@ -1707,7 +1707,7 @@
{#if report.userUUID}
{#if report.targetUsername}
<a
href={resolve(`/user/${report.targetUsername}`)}
href={resolve(`/user/[username]`, { username: report.targetUsername})}
class="text-neutral-300 hover:text-white"
use:tooltip={report.userUUID}
onclick={stopPropagation(bubble('click'))}
@@ -1735,11 +1735,11 @@
class="flex cursor-pointer flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
role="link"
tabindex="0"
onclick={() => goto(resolve(`/report/${report.reportID}`))}
onclick={() => goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}))}
onkeydown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
goto(resolve(`/report/${report.reportID}`));
goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}));
}
}}
>
@@ -1756,7 +1756,7 @@
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
{#if report.reporterUsername}
<a
href={resolve(`/user/${report.reporterUsername}`)}
href={resolve(`/user/[username]`, { username: report.reporterUsername})}
class="text-neutral-300 hover:text-white"
use:tooltip={report.reporterUUID}
onclick={stopPropagation(bubble('click'))}
@@ -1768,7 +1768,7 @@
{/if}
{#if report.pastePID}
<a
href={resolve(`/${report.pasteId ?? report.pastePID}`)}
href={resolve(`/[id]`, { id: report.pasteId ?? ""})}
class="text-neutral-300 hover:text-white"
onclick={stopPropagation(bubble('click'))}
>
@@ -1778,7 +1778,7 @@
{#if report.userUUID}
{#if report.targetUsername}
<a
href={resolve(`/user/${report.targetUsername}`)}
href={resolve(`/user/[username]`, { username: report.targetUsername})}
class="text-neutral-300 hover:text-white"
use:tooltip={report.userUUID}
onclick={stopPropagation(bubble('click'))}
@@ -1,7 +1,7 @@
import type { RequestEvent } from '@sveltejs/kit';
import { error, redirect } from '@sveltejs/kit';
import { apiUrl } from '$lib/server/api';
import { getServerToken } from '$lib/utils/auth';
import { apiUrl } from '#lib/server/api';
import { getServerToken } from '#lib/utils/auth';
export const load = async ({ params, fetch, cookies }: RequestEvent) => {
const token = getServerToken(cookies);
@@ -1,5 +1,5 @@
import { apiUrl } from '$lib/server/api';
import { extractError } from '$lib/utils/misc';
import { apiUrl } from '#lib/server/api';
import { extractError } from '#lib/utils/misc';
import { error } from '@sveltejs/kit';
export const load = async ({ url, request }) => {
-18
View File
@@ -1,18 +0,0 @@
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://svelte.dev/docs/kit/integrations
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter()
}
};
export default config;
+8 -3
View File
@@ -1,5 +1,7 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"extends": "$app/tsconfig",
"include": ["src", "test", "*"],
"exclude": ["src/service-worker"],
"compilerOptions": {
"rewriteRelativeImportExtensions": true,
"allowJs": true,
@@ -10,10 +12,13 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
"moduleResolution": "bundler",
"paths": {
"#lib/*": ["./src/lib/*"]
}
}
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
// except #lib which is handled by https://svelte.dev/docs/kit/configuration#files
//
// To make changes to top-level options such as include and exclude, we recommend extending
// the generated config; see https://svelte.dev/docs/kit/configuration#typescript
+3 -1
View File
@@ -1,5 +1,7 @@
import tailwindcss from '@tailwindcss/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { defineConfig } from 'vite';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
@@ -14,7 +16,7 @@ const allowedHosts = process.env.VITE_ALLOWED_HOSTS
: ['localhost'];
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
plugins: [tailwindcss(), sveltekit({ adapter: adapter(), preprocess: vitePreprocess() })],
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
COMMIT_HASH: JSON.stringify(process.env.GIT_COMMIT_HASH || 'unknown')
+4 -2
View File
@@ -13,10 +13,12 @@ This is the backend API for SharpbinV3, built with ASP.NET Core and Entity Frame
The server configuration is managed in `appsettings.json`. For development, ensure you have set the following in `appsettings.Development.json` or as environment variables:
- `ConnectionStrings__DefaultConnection`: SQLite connection string (e.g., `Data Source=sharpbin.db` locally). Compose sets `Data Source=/app/data/sharpbin.db` directly.
- `ConnectionStrings__DefaultConnection`: SQLite connection string (e.g., `Data Source=sharpbin.db` locally). Compose defaults to `Data Source=/app/data/sharpbin.db`.
- `JwtSettings__Secret`: A random secret of 32–128 characters used for signing JWT tokens.
- `PasteSettings__View_HMAC_Secret`: A required random secret of 32–128 characters used to hash viewer identifiers.
- `PasteSettings__View_Internal_API_Key`: A shared key of 32–128 characters used to authorize view recording. Match the production frontend's `VIEW_INTERNAL_API_KEY`.
- `PasteSettings__View_Internal_API_Key`: A shared key of 32–128 characters used to authorize view recording. Compose passes it to both services. For standalone deployments, match the frontend's `VIEW_INTERNAL_API_KEY`.
For Docker Compose, configure the backend in the root `.env` file. The image includes `appsettings.json` defaults, and environment variables override them. No host configuration mount is required.
The development frontend uses a fixed internal key matching the checked-in `appsettings.Development.json`. Changing only the backend key will break development view recording. Use generated secrets for deployment; see the [root configuration guide](../README.md#configuration).
@@ -34,10 +34,13 @@
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="10.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageReference Include="Otp.NET" Version="1.4.1" />
<PackageReference Include="SQLitePCLRaw.lib.e_sqlite3" Version="3.53.4.1-pre1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.16.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="11.0.0-rc.2.26504.105" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<EmbeddedResource Include="EmailTemplates\*.html" />
</ItemGroup>
</Project>
+8 -8
View File
@@ -6,13 +6,13 @@ services:
image: sharpbin-backend
container_name: sharpbin-backend
env_file:
- "backend.env"
- ".env"
environment:
DATA_PROTECTION_KEY_PATH: /app/data/keys
ConnectionStrings__DefaultConnection: "Data Source=/app/data/sharpbin.db"
DATA_PROTECTION_KEY_PATH: ${DATA_PROTECTION_KEY_PATH:-/app/data/keys}
ConnectionStrings__DefaultConnection: ${ConnectionStrings__DefaultConnection:-Data Source=/app/data/sharpbin.db}
PasteSettings__View_Internal_API_Key: ${PasteSettings__View_Internal_API_Key:?Set PasteSettings__View_Internal_API_Key in .env}
volumes:
- sharpbin-data:/app/data
- ./SharpbinV3.Server/appsettings.json:/app/appsettings.json
networks:
- sharpbin-net
healthcheck:
@@ -28,13 +28,13 @@ services:
context: ./SharpbinV3.Client
dockerfile: Dockerfile
args:
GIT_COMMIT_HASH: ${GIT_COMMIT_HASH}
GIT_COMMIT_HASH: ${GIT_COMMIT_HASH:-unknown}
image: sharpbin-frontend
container_name: sharpbin-frontend
env_file:
- "frontend.env"
environment:
VITE_API_URL: http://backend:8080
VITE_API_URL: ${VITE_API_URL:-http://backend:8080}
ORIGIN: ${ORIGIN:?Set ORIGIN in .env}
VIEW_INTERNAL_API_KEY: ${PasteSettings__View_Internal_API_Key:?Set PasteSettings__View_Internal_API_Key in .env}
ports:
- "5173:5173"
-10
View File
@@ -1,10 +0,0 @@
# Docker Compose sets this URL directly; change docker-compose.yml to override it.
VITE_API_URL=http://backend:8080
# Public frontend URL, including the scheme. Use http://localhost:5173 for local Docker testing.
ORIGIN=https://example.com
# VITE_ALLOWED_HOSTS only affects Vite dev/preview, not the production Node server.
# Used so that views are only counted from the frontend
# Must be the same on both the frontend and backend environment
# Production fallback: View_HMAC_Internal_API_Key (not PasteSettings__View_Internal_API_Key).
# Replace this placeholder with the same generated value as the backend setting.
VIEW_INTERNAL_API_KEY=replace_with_the_same_random_internal_api_key_in_both_files