mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Compare commits
3
Commits
v3.1.0
...
SharpbinV3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
892624f6ac
|
||
|
|
eed65b754e
|
||
|
|
22c144e970
|
@@ -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)
|
## [3.0.5](https://github.com/whoswhip/Sharpbin/compare/v3.0.4...v3.0.5) (2026-03-31)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "sharpbinv3.client",
|
"name": "sharpbinv3.client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.0.5",
|
"version": "3.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
{#if compact}
|
{#if compact}
|
||||||
<a
|
<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"
|
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">
|
<div class="flex w-full flex-row justify-between">
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
</a>
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
<a
|
<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"
|
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
|
<span
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
<span class="text-red-500">BANNED</span>
|
<span class="text-red-500">BANNED</span>
|
||||||
{/if}
|
{/if}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/user/${node.author?.username}`)}
|
href={resolve(`/user/[username]`, { username: node.author?.username})}
|
||||||
class="flex items-center gap-2 underline"
|
class="flex items-center gap-2 underline"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -237,7 +237,10 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section id="comments-section" class="w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4 mt-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="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<h2 class="text-lg font-semibold text-neutral-100">{comments.length} Comments</h2>
|
<h2 class="text-lg font-semibold text-neutral-100">{comments.length} Comments</h2>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
import { argon2id } from 'hash-wasm';
|
|
||||||
|
|
||||||
const BASE64_CHUNK_SIZE = 0x8000;
|
const BASE64_CHUNK_SIZE = 0x8000;
|
||||||
const SALT_LENGTH = 16;
|
const SALT_LENGTH = 16;
|
||||||
const IV_LENGTH = 12;
|
const IV_LENGTH = 12;
|
||||||
@@ -9,8 +7,58 @@ const ARGON2_PARALLELISM = 1;
|
|||||||
const ARGON2_HASH_LENGTH = 32;
|
const ARGON2_HASH_LENGTH = 32;
|
||||||
const AES_KEY_LENGTH = 256;
|
const AES_KEY_LENGTH = 256;
|
||||||
const ENCRYPTION_AAD = 'enc-v4';
|
const ENCRYPTION_AAD = 'enc-v4';
|
||||||
const ENCRYPTED_DATA_OVERHEAD = 60;
|
const ENCRYPTED_DATA_OVERHEAD = SALT_LENGTH + IV_LENGTH + 16;
|
||||||
const ENCRYPTED_METADATA_OVERHEAD = 150;
|
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 {
|
function toBase64(bytes: Uint8Array): string {
|
||||||
let binary = '';
|
let binary = '';
|
||||||
@@ -29,7 +77,21 @@ function fromBase64(data: string): Uint8Array {
|
|||||||
return bytes;
|
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> {
|
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 enc = new TextEncoder();
|
||||||
const salt = window.crypto.getRandomValues(new Uint8Array(SALT_LENGTH));
|
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',
|
name: 'AES-GCM',
|
||||||
iv,
|
iv,
|
||||||
additionalData: enc.encode(ENCRYPTION_AAD)
|
additionalData: enc.encode(JSON.stringify(ENCRYPTION_HEADER))
|
||||||
},
|
},
|
||||||
key,
|
key,
|
||||||
enc.encode(content)
|
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);
|
combined.set(new Uint8Array(encryptedContent), salt.byteLength + iv.byteLength);
|
||||||
|
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
version: 4,
|
...ENCRYPTION_HEADER,
|
||||||
kdf: 'Argon2id',
|
|
||||||
memorySize: ARGON2_MEMORY_SIZE,
|
|
||||||
iterations: ARGON2_ITERATIONS,
|
|
||||||
parallelism: ARGON2_PARALLELISM,
|
|
||||||
algorithm: 'AES-GCM',
|
|
||||||
saltLength: salt.byteLength,
|
|
||||||
ivLength: iv.byteLength,
|
|
||||||
data: toBase64(combined)
|
data: toBase64(combined)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -84,17 +139,58 @@ export function estimateEncryptedSize(content: string): number {
|
|||||||
const rawSize = new TextEncoder().encode(content).length;
|
const rawSize = new TextEncoder().encode(content).length;
|
||||||
const combinedSize = rawSize + ENCRYPTED_DATA_OVERHEAD;
|
const combinedSize = rawSize + ENCRYPTED_DATA_OVERHEAD;
|
||||||
const b64Size = Math.ceil(combinedSize / 3) * 4;
|
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> {
|
export async function decryptAES(result: string, password: string): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
const enc = new TextEncoder();
|
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);
|
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 combined = fromBase64(parsed.data);
|
||||||
|
|
||||||
const saltLength = parsed.saltLength || SALT_LENGTH;
|
const saltLength = parsed.saltLength ?? SALT_LENGTH;
|
||||||
const ivLength = parsed.ivLength || IV_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 salt = combined.slice(0, saltLength);
|
||||||
const iv = combined.slice(saltLength, saltLength + ivLength);
|
const iv = combined.slice(saltLength, saltLength + ivLength);
|
||||||
const data = combined.slice(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',
|
name: 'AES-GCM',
|
||||||
iv,
|
iv,
|
||||||
additionalData: enc.encode(ENCRYPTION_AAD)
|
additionalData: enc.encode(
|
||||||
|
parsed.version === 5
|
||||||
|
? JSON.stringify(ENCRYPTION_HEADER)
|
||||||
|
: currentArgon2
|
||||||
|
? ENCRYPTION_AAD
|
||||||
|
: ''
|
||||||
|
)
|
||||||
},
|
},
|
||||||
key,
|
key,
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
|
|
||||||
return new TextDecoder().decode(decryptedContent);
|
return new TextDecoder().decode(decryptedContent);
|
||||||
} catch {
|
} catch (error) {
|
||||||
return null;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { getToken } from '#lib/utils/auth';
|
import { getToken } from '#lib/utils/auth';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { fly, fade } from 'svelte/transition';
|
import { fly, fade } from 'svelte/transition';
|
||||||
import { encryptAES, estimateEncryptedSize } from '#lib/utils/encryption';
|
import { encryptAES, estimateEncryptedSize, encodePasswordFragment } from '#lib/utils/encryption';
|
||||||
import {
|
import {
|
||||||
formatBytes,
|
formatBytes,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
@@ -162,7 +162,12 @@
|
|||||||
|
|
||||||
let body = content;
|
let body = content;
|
||||||
if (selectedVisibility === 2) {
|
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 (
|
if (
|
||||||
@@ -196,7 +201,7 @@
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
if (selectedVisibility === 2) {
|
if (selectedVisibility === 2) {
|
||||||
const passwordBase64 = btoa(password);
|
const passwordBase64 = encodePasswordFragment(password);
|
||||||
window.location.href = `/${result.id}#${passwordBase64}`;
|
window.location.href = `/${result.id}#${passwordBase64}`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
} from '#lib/utils/markdown';
|
} from '#lib/utils/markdown';
|
||||||
import { syntaxes, expiresOptions } from '#lib/consts';
|
import { syntaxes, expiresOptions } from '#lib/consts';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import { decryptAES, encryptAES } from '#lib/utils/encryption';
|
import { decryptAES, encryptAES, decodePasswordFragment } from '#lib/utils/encryption';
|
||||||
import { escapeHtml } from '#lib/utils/html';
|
import { escapeHtml } from '#lib/utils/html';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { getToken, hasRole } from '#lib/utils/auth';
|
import { getToken, hasRole } from '#lib/utils/auth';
|
||||||
@@ -359,8 +359,8 @@
|
|||||||
});
|
});
|
||||||
editMetadata = data.paste ? { ...data.paste } : null;
|
editMetadata = data.paste ? { ...data.paste } : null;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (cause) {
|
||||||
editError = 'An error occurred while updating.';
|
editError = cause instanceof Error ? cause.message : 'An error occurred while updating.';
|
||||||
} finally {
|
} finally {
|
||||||
editLoading = false;
|
editLoading = false;
|
||||||
editing = false;
|
editing = false;
|
||||||
@@ -517,8 +517,20 @@
|
|||||||
contentRendered = false;
|
contentRendered = false;
|
||||||
decryptStatus = 'Preparing decryption...';
|
decryptStatus = 'Preparing decryption...';
|
||||||
const urlHash = window.location.hash.slice(1);
|
const urlHash = window.location.hash.slice(1);
|
||||||
|
let passwordFromUrl: string | null = null;
|
||||||
if (urlHash) {
|
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...';
|
decryptStatus = 'Deriving key...';
|
||||||
decryptedContent = await decryptAES(data.content, passwordFromUrl);
|
decryptedContent = await decryptAES(data.content, passwordFromUrl);
|
||||||
if (decryptedContent === null) {
|
if (decryptedContent === null) {
|
||||||
@@ -528,11 +540,10 @@
|
|||||||
decryptStatus = 'Deriving key...';
|
decryptStatus = 'Deriving key...';
|
||||||
decryptedContent = await decryptAES(data.content, password);
|
decryptedContent = await decryptAES(data.content, password);
|
||||||
if (decryptedContent === null) {
|
if (decryptedContent === null) {
|
||||||
decryptError = 'Incorrect password. Please try again.';
|
decryptError = 'Wrong password or damaged encrypted paste.';
|
||||||
decryptStatus = 'Decryption failed.';
|
decryptStatus = decryptError;
|
||||||
} else {
|
} else {
|
||||||
await renderPaste();
|
await renderPaste();
|
||||||
history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
decryptStatus = 'Decryption canceled.';
|
decryptStatus = 'Decryption canceled.';
|
||||||
@@ -548,8 +559,8 @@
|
|||||||
decryptStatus = 'Deriving key...';
|
decryptStatus = 'Deriving key...';
|
||||||
decryptedContent = await decryptAES(data.content, password);
|
decryptedContent = await decryptAES(data.content, password);
|
||||||
if (decryptedContent === null) {
|
if (decryptedContent === null) {
|
||||||
decryptError = 'Incorrect password. Please try again.';
|
decryptError = 'Wrong password or damaged encrypted paste.';
|
||||||
decryptStatus = 'Decryption failed.';
|
decryptStatus = decryptError;
|
||||||
} else {
|
} else {
|
||||||
await renderPaste();
|
await renderPaste();
|
||||||
}
|
}
|
||||||
@@ -560,7 +571,12 @@
|
|||||||
decryptStatus = 'Rendering content...';
|
decryptStatus = 'Rendering content...';
|
||||||
await renderPaste();
|
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...';
|
decryptStatus = 'Rendering content...';
|
||||||
await renderPaste();
|
await renderPaste();
|
||||||
}
|
}
|
||||||
@@ -655,7 +671,7 @@
|
|||||||
{#if data.paste.author}
|
{#if data.paste.author}
|
||||||
<User class="inline-block h-4 w-4 text-neutral-400" />
|
<User class="inline-block h-4 w-4 text-neutral-400" />
|
||||||
<a
|
<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"
|
class="text-neutral-400 transition-colors duration-300 hover:text-neutral-500"
|
||||||
>{data.paste.author.username}</a
|
>{data.paste.author.username}</a
|
||||||
>
|
>
|
||||||
@@ -938,7 +954,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a
|
<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"
|
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" />
|
<File class="{iconsOnly ? '' : 'mr-1'} h-5 w-5 text-neutral-400" />
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
{#if report.reporterUsername}
|
{#if report.reporterUsername}
|
||||||
<a
|
<a
|
||||||
class="text-neutral-200 hover:text-white hover:underline"
|
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}
|
use:tooltip={report.reporterUUID}
|
||||||
>
|
>
|
||||||
{report.reporterDisplayName || report.reporterUsername}
|
{report.reporterDisplayName || report.reporterUsername}
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
Target Paste:
|
Target Paste:
|
||||||
<a
|
<a
|
||||||
class="text-neutral-200 hover:text-white hover:underline"
|
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}
|
{report.pasteTitle !== '' ? report.pasteTitle : report.pasteId}
|
||||||
</a>
|
</a>
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
{#if report.targetUsername}
|
{#if report.targetUsername}
|
||||||
<a
|
<a
|
||||||
class="text-neutral-200 hover:text-white hover:underline"
|
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}
|
use:tooltip={report.userUUID}
|
||||||
>
|
>
|
||||||
{report.targetDisplayName || report.targetUsername}
|
{report.targetDisplayName || report.targetUsername}
|
||||||
|
|||||||
@@ -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"
|
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"
|
role="link"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
onclick={() => goto(resolve(`/report/${report.reportID}`))}
|
onclick={() => goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}))}
|
||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key === 'Enter' || e.key === ' ') {
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
e.preventDefault();
|
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>
|
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
|
||||||
{#if report.pasteId}
|
{#if report.pasteId}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/${report.pasteId}`)}
|
href={resolve(`/[id]`, { id: report.pasteId})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
onclick={stopPropagation(bubble('click'))}
|
onclick={stopPropagation(bubble('click'))}
|
||||||
>
|
>
|
||||||
@@ -231,7 +231,7 @@
|
|||||||
{#if report.userUUID}
|
{#if report.userUUID}
|
||||||
{#if report.targetUsername}
|
{#if report.targetUsername}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/user/${report.targetUsername}`)}
|
href={resolve(`/user/[username]`, {username: report.targetUsername})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
use:tooltip={report.userUUID}
|
use:tooltip={report.userUUID}
|
||||||
onclick={stopPropagation(bubble('click'))}
|
onclick={stopPropagation(bubble('click'))}
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if report.reporterUsername}
|
{#if report.reporterUsername}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/user/${report.reporterUsername}`)}
|
href={resolve(`/user/[username]`, { username: report.reporterUsername})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
use:tooltip={report.reporterUUID}
|
use:tooltip={report.reporterUUID}
|
||||||
onclick={stopPropagation(bubble('click'))}
|
onclick={stopPropagation(bubble('click'))}
|
||||||
|
|||||||
@@ -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"
|
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"
|
role="link"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
onclick={() => goto(resolve(`/report/${report.reportID}`))}
|
onclick={() => goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}))}
|
||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key === 'Enter' || e.key === ' ') {
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
e.preventDefault();
|
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>
|
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
|
||||||
{#if report.pasteId}
|
{#if report.pasteId}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/${report.pasteId}`)}
|
href={resolve(`/[id]`, {id:report.pasteId})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
onclick={stopPropagation(bubble('click'))}
|
onclick={stopPropagation(bubble('click'))}
|
||||||
>
|
>
|
||||||
@@ -1707,7 +1707,7 @@
|
|||||||
{#if report.userUUID}
|
{#if report.userUUID}
|
||||||
{#if report.targetUsername}
|
{#if report.targetUsername}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/user/${report.targetUsername}`)}
|
href={resolve(`/user/[username]`, { username: report.targetUsername})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
use:tooltip={report.userUUID}
|
use:tooltip={report.userUUID}
|
||||||
onclick={stopPropagation(bubble('click'))}
|
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"
|
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"
|
role="link"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
onclick={() => goto(resolve(`/report/${report.reportID}`))}
|
onclick={() => goto(resolve(`/report/[reportId]`, { reportId: String(report.reportID)}))}
|
||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key === 'Enter' || e.key === ' ') {
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
e.preventDefault();
|
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>
|
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
|
||||||
{#if report.reporterUsername}
|
{#if report.reporterUsername}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/user/${report.reporterUsername}`)}
|
href={resolve(`/user/[username]`, { username: report.reporterUsername})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
use:tooltip={report.reporterUUID}
|
use:tooltip={report.reporterUUID}
|
||||||
onclick={stopPropagation(bubble('click'))}
|
onclick={stopPropagation(bubble('click'))}
|
||||||
@@ -1768,7 +1768,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if report.pastePID}
|
{#if report.pastePID}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/${report.pasteId ?? report.pastePID}`)}
|
href={resolve(`/[id]`, { id: report.pasteId ?? ""})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
onclick={stopPropagation(bubble('click'))}
|
onclick={stopPropagation(bubble('click'))}
|
||||||
>
|
>
|
||||||
@@ -1778,7 +1778,7 @@
|
|||||||
{#if report.userUUID}
|
{#if report.userUUID}
|
||||||
{#if report.targetUsername}
|
{#if report.targetUsername}
|
||||||
<a
|
<a
|
||||||
href={resolve(`/user/${report.targetUsername}`)}
|
href={resolve(`/user/[username]`, { username: report.targetUsername})}
|
||||||
class="text-neutral-300 hover:text-white"
|
class="text-neutral-300 hover:text-white"
|
||||||
use:tooltip={report.userUUID}
|
use:tooltip={report.userUUID}
|
||||||
onclick={stopPropagation(bubble('click'))}
|
onclick={stopPropagation(bubble('click'))}
|
||||||
|
|||||||
Reference in New Issue
Block a user