feat: paste creation; paste viewing; more langs supported; jwt settings class; paste settings class; data validation on paste metadata modification

This commit is contained in:
2025-12-28 08:34:53 -05:00
parent adad139081
commit b9b14a3d5a
21 changed files with 1203 additions and 77 deletions
+1 -1
View File
@@ -2,5 +2,5 @@
"files.associations": { "files.associations": {
"*.css": "tailwindcss" "*.css": "tailwindcss"
}, },
"tailwindCSS.experimental.configFile": "src/routes/layout.css", "tailwindCSS.experimental.configFile": "src/routes/layout.css"
} }
+567 -16
View File
@@ -22,6 +22,7 @@
"prettier": "^3.7.4", "prettier": "^3.7.4",
"prettier-plugin-svelte": "^3.4.0", "prettier-plugin-svelte": "^3.4.0",
"prettier-plugin-tailwindcss": "^0.7.2", "prettier-plugin-tailwindcss": "^0.7.2",
"shiki": "^3.20.0",
"svelte": "^5.45.6", "svelte": "^5.45.6",
"svelte-check": "^4.3.4", "svelte-check": "^4.3.4",
"tailwindcss": "^4.1.17", "tailwindcss": "^4.1.17",
@@ -1067,6 +1068,80 @@
"win32" "win32"
] ]
}, },
"node_modules/@shikijs/core": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-3.20.0.tgz",
"integrity": "sha512-f2ED7HYV4JEk827mtMDwe/yQ25pRiXZmtHjWF8uzZKuKiEsJR7Ce1nuQ+HhV9FzDcbIo4ObBCD9GPTzNuy9S1g==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shikijs/types": "3.20.0",
"@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4",
"hast-util-to-html": "^9.0.5"
}
},
"node_modules/@shikijs/engine-javascript": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-3.20.0.tgz",
"integrity": "sha512-OFx8fHAZuk7I42Z9YAdZ95To6jDePQ9Rnfbw9uSRTSbBhYBp1kEOKv/3jOimcj3VRUKusDYM6DswLauwfhboLg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shikijs/types": "3.20.0",
"@shikijs/vscode-textmate": "^10.0.2",
"oniguruma-to-es": "^4.3.4"
}
},
"node_modules/@shikijs/engine-oniguruma": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.20.0.tgz",
"integrity": "sha512-Yx3gy7xLzM0ZOjqoxciHjA7dAt5tyzJE3L4uQoM83agahy+PlW244XJSrmJRSBvGYELDhYXPacD4R/cauV5bzQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shikijs/types": "3.20.0",
"@shikijs/vscode-textmate": "^10.0.2"
}
},
"node_modules/@shikijs/langs": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-3.20.0.tgz",
"integrity": "sha512-le+bssCxcSHrygCWuOrYJHvjus6zhQ2K7q/0mgjiffRbkhM4o1EWu2m+29l0yEsHDbWaWPNnDUTRVVBvBBeKaA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shikijs/types": "3.20.0"
}
},
"node_modules/@shikijs/themes": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-3.20.0.tgz",
"integrity": "sha512-U1NSU7Sl26Q7ErRvJUouArxfM2euWqq1xaSrbqMu2iqa+tSp0D1Yah8216sDYbdDHw4C8b75UpE65eWorm2erQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shikijs/types": "3.20.0"
}
},
"node_modules/@shikijs/types": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-3.20.0.tgz",
"integrity": "sha512-lhYAATn10nkZcBQ0BlzSbJA3wcmL5MXUUF8d2Zzon6saZDlToKaiRX60n2+ZaHJCmXEcZRWNzn+k9vplr8Jhsw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4"
}
},
"node_modules/@shikijs/vscode-textmate": {
"version": "10.0.2",
"resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz",
"integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==",
"dev": true,
"license": "MIT"
},
"node_modules/@standard-schema/spec": { "node_modules/@standard-schema/spec": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
@@ -1458,6 +1533,16 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/hast": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz",
"integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "*"
}
},
"node_modules/@types/json-schema": { "node_modules/@types/json-schema": {
"version": "7.0.15", "version": "7.0.15",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
@@ -1465,6 +1550,16 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/mdast": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
"integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "*"
}
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.19.3", "version": "22.19.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.3.tgz",
@@ -1475,6 +1570,13 @@
"undici-types": "~6.21.0" "undici-types": "~6.21.0"
} }
}, },
"node_modules/@types/unist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
"dev": true,
"license": "MIT"
},
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.50.1", "version": "8.50.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.50.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.50.1.tgz",
@@ -1731,6 +1833,13 @@
"url": "https://opencollective.com/typescript-eslint" "url": "https://opencollective.com/typescript-eslint"
} }
}, },
"node_modules/@ungap/structured-clone": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz",
"integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==",
"dev": true,
"license": "ISC"
},
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.15.0", "version": "8.15.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
@@ -1842,6 +1951,17 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/ccount": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
"integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/chalk": { "node_modules/chalk": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@@ -1859,6 +1979,28 @@
"url": "https://github.com/chalk/chalk?sponsor=1" "url": "https://github.com/chalk/chalk?sponsor=1"
} }
}, },
"node_modules/character-entities-html4": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz",
"integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/character-entities-legacy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz",
"integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/chokidar": { "node_modules/chokidar": {
"version": "4.0.3", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
@@ -1905,6 +2047,17 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/comma-separated-tokens": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
"integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/concat-map": { "node_modules/concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -1985,6 +2138,16 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/detect-libc": { "node_modules/detect-libc": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
@@ -2002,6 +2165,20 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/devlop": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz",
"integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==",
"dev": true,
"license": "MIT",
"dependencies": {
"dequal": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/enhanced-resolve": { "node_modules/enhanced-resolve": {
"version": "5.18.4", "version": "5.18.4",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.4.tgz", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.4.tgz",
@@ -2440,6 +2617,55 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/hast-util-to-html": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz",
"integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/unist": "^3.0.0",
"ccount": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-whitespace": "^3.0.0",
"html-void-elements": "^3.0.0",
"mdast-util-to-hast": "^13.0.0",
"property-information": "^7.0.0",
"space-separated-tokens": "^2.0.0",
"stringify-entities": "^4.0.0",
"zwitch": "^2.0.4"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-whitespace": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz",
"integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/html-void-elements": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz",
"integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/ignore": { "node_modules/ignore": {
"version": "5.3.2", "version": "5.3.2",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
@@ -2913,6 +3139,122 @@
"@jridgewell/sourcemap-codec": "^1.5.5" "@jridgewell/sourcemap-codec": "^1.5.5"
} }
}, },
"node_modules/mdast-util-to-hast": {
"version": "13.2.1",
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz",
"integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/mdast": "^4.0.0",
"@ungap/structured-clone": "^1.0.0",
"devlop": "^1.0.0",
"micromark-util-sanitize-uri": "^2.0.0",
"trim-lines": "^3.0.0",
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-util-character": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz",
"integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==",
"dev": true,
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT",
"dependencies": {
"micromark-util-symbol": "^2.0.0",
"micromark-util-types": "^2.0.0"
}
},
"node_modules/micromark-util-encode": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz",
"integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==",
"dev": true,
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT"
},
"node_modules/micromark-util-sanitize-uri": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz",
"integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==",
"dev": true,
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT",
"dependencies": {
"micromark-util-character": "^2.0.0",
"micromark-util-encode": "^2.0.0",
"micromark-util-symbol": "^2.0.0"
}
},
"node_modules/micromark-util-symbol": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz",
"integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==",
"dev": true,
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT"
},
"node_modules/micromark-util-types": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz",
"integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==",
"dev": true,
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT"
},
"node_modules/minimatch": { "node_modules/minimatch": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
@@ -2979,6 +3321,25 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/oniguruma-parser": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.1.tgz",
"integrity": "sha512-8Unqkvk1RYc6yq2WBYRj4hdnsAxVze8i7iPfQr8e4uSP3tRv0rpZcbGUDvxfQQcdwHt/e9PrMvGCsa8OqG9X3w==",
"dev": true,
"license": "MIT"
},
"node_modules/oniguruma-to-es": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.4.tgz",
"integrity": "sha512-3VhUGN3w2eYxnTzHn+ikMI+fp/96KoRSVK9/kMTcFqj1NRDh2IhQCKvYxDnWePKRXY/AqH+Fuiyb7VHSzBjHfA==",
"dev": true,
"license": "MIT",
"dependencies": {
"oniguruma-parser": "^0.12.1",
"regex": "^6.0.1",
"regex-recursion": "^6.0.2"
}
},
"node_modules/optionator": { "node_modules/optionator": {
"version": "0.9.4", "version": "0.9.4",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -3335,6 +3696,17 @@
} }
} }
}, },
"node_modules/property-information": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz",
"integrity": "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/punycode": { "node_modules/punycode": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
@@ -3359,6 +3731,33 @@
"url": "https://paulmillr.com/funding/" "url": "https://paulmillr.com/funding/"
} }
}, },
"node_modules/regex": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz",
"integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==",
"dev": true,
"license": "MIT",
"dependencies": {
"regex-utilities": "^2.3.0"
}
},
"node_modules/regex-recursion": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz",
"integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==",
"dev": true,
"license": "MIT",
"dependencies": {
"regex-utilities": "^2.3.0"
}
},
"node_modules/regex-utilities": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz",
"integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==",
"dev": true,
"license": "MIT"
},
"node_modules/resolve-from": { "node_modules/resolve-from": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
@@ -3467,6 +3866,23 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/shiki": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-3.20.0.tgz",
"integrity": "sha512-kgCOlsnyWb+p0WU+01RjkCH+eBVsjL1jOwUYWv0YDWkM2/A46+LDKVs5yZCUXjJG6bj4ndFoAg5iLIIue6dulg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shikijs/core": "3.20.0",
"@shikijs/engine-javascript": "3.20.0",
"@shikijs/engine-oniguruma": "3.20.0",
"@shikijs/langs": "3.20.0",
"@shikijs/themes": "3.20.0",
"@shikijs/types": "3.20.0",
"@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4"
}
},
"node_modules/sirv": { "node_modules/sirv": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz", "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz",
@@ -3492,6 +3908,32 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/space-separated-tokens": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
"integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/stringify-entities": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz",
"integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==",
"dev": true,
"license": "MIT",
"dependencies": {
"character-entities-html4": "^2.0.0",
"character-entities-legacy": "^3.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/strip-json-comments": { "node_modules/strip-json-comments": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
@@ -3647,6 +4089,17 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
"integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/ts-api-utils": { "node_modules/ts-api-utils": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.2.0.tgz", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.2.0.tgz",
@@ -3718,6 +4171,79 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/unist-util-is": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz",
"integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-position": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz",
"integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
"integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit-parents": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz",
"integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/uri-js": { "node_modules/uri-js": {
"version": "4.4.1", "version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
@@ -3735,6 +4261,36 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/vfile": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz",
"integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"vfile-message": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-message": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz",
"integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-stringify-position": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vite": { "node_modules/vite": {
"version": "7.3.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz",
@@ -3856,22 +4412,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/yaml": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz",
"integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==",
"extraneous": true,
"license": "ISC",
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14.6"
},
"funding": {
"url": "https://github.com/sponsors/eemeli"
}
},
"node_modules/yocto-queue": { "node_modules/yocto-queue": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
@@ -3891,6 +4431,17 @@
"integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==", "integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
},
"node_modules/zwitch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
"integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
} }
} }
} }
+1
View File
@@ -28,6 +28,7 @@
"prettier": "^3.7.4", "prettier": "^3.7.4",
"prettier-plugin-svelte": "^3.4.0", "prettier-plugin-svelte": "^3.4.0",
"prettier-plugin-tailwindcss": "^0.7.2", "prettier-plugin-tailwindcss": "^0.7.2",
"shiki": "^3.20.0",
"svelte": "^5.45.6", "svelte": "^5.45.6",
"svelte-check": "^4.3.4", "svelte-check": "^4.3.4",
"tailwindcss": "^4.1.17", "tailwindcss": "^4.1.17",
+8
View File
@@ -3,6 +3,14 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap"
rel="stylesheet"
/>
%sveltekit.head% %sveltekit.head%
</head> </head>
<body data-sveltekit-preload-data="hover"> <body data-sveltekit-preload-data="hover">
+74
View File
@@ -0,0 +1,74 @@
export const displayNames: Record<string, string> = {
plaintext: 'Plain Text',
abap: 'ABAP',
'actionscript-3': 'ActionScript 3',
apl: 'APL',
applescript: 'AppleScript',
ara: 'ARA',
awk: 'AWK',
bibtex: 'BibTeX',
cmake: 'CMake',
cobol: 'COBOL',
codeql: 'CodeQL',
coffee: 'CoffeeScript',
cpp: 'C++',
csharp: 'C#',
css: 'CSS',
cue: 'CUE',
'dream-maker': 'Dream Maker',
erb: 'ERB',
fsharp: 'F#',
gdresource: 'Godot Resource',
gdscript: 'GDScript',
gdshader: 'Godot Shader',
'git-commit': 'Git Commit',
'git-rebase': 'Git Rebase',
glsl: 'GLSL',
graphql: 'GraphQL',
hcl: 'HCL',
hjson: 'HJSON',
hlsl: 'HLSL',
html: 'HTML',
ini: 'INI',
javascript: 'JavaScript',
json: 'JSON',
json5: 'JSON5',
jsonc: 'JSONC',
jssm: 'JSSM',
jsx: 'JSX',
latex: 'LaTeX',
matlab: 'MATLAB',
mdx: 'MDX',
'objective-c': 'Objective-C',
'objective-cpp': 'Objective-C++',
ocaml: 'OCaml',
php: 'PHP',
plsql: 'PL/SQL',
postcss: 'PostCSS',
powerquery: 'Power Query',
purescript: 'PureScript',
riscv: 'RISC-V',
rst: 'reStructuredText',
sas: 'SAS',
scss: 'SCSS',
shaderlab: 'ShaderLab',
sparql: 'SPARQL',
sql: 'SQL',
'ssh-config': 'SSH Config',
'system-verilog': 'SystemVerilog',
tasl: 'TASL',
tex: 'TeX',
toml: 'TOML',
tsx: 'TSX',
typescript: 'TypeScript',
vb: 'VB',
vhdl: 'VHDL',
viml: 'VimL',
wasm: 'WebAssembly',
xml: 'XML',
xsl: 'XSL',
yaml: 'YAML',
zenscript: 'ZenScript'
};
// only include langs that need special display names
// e.g. cpp -> C++ or toml -> TOML, langs like java are automatically capitalized
+23
View File
@@ -0,0 +1,23 @@
import { createHighlighter } from 'shiki';
import type { Highlighter } from 'shiki';
let highlighterPromise: Promise<Highlighter> | null = null;
async function loadHighlighter() {
const res = await fetch('http://localhost:5050/api/paste/create/options');
if (!res.ok) throw new Error('Failed to fetch paste options');
const data = await res.json();
return createHighlighter({
themes: ['github-dark', 'github-light'],
langs: data.syntaxes
});
}
export function getShiki() {
if (!highlighterPromise) {
highlighterPromise = loadHighlighter();
}
return highlighterPromise;
}
@@ -0,0 +1,7 @@
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ fetch }) => {
const res = await fetch('/api/paste/create/options');
const options = await res.json();
return { options };
};
+142 -2
View File
@@ -1,2 +1,142 @@
<h1>Welcome to SvelteKit</h1> <script lang="ts">
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p> import type { PageData } from './$types';
import { displayNames } from '$lib/consts';
export let data: PageData;
let title = '';
let content = '';
let selectedSyntax = data.options.syntaxes[0];
let selectedVisibility = data.options.visibilities[0].value;
let password = '';
async function handleSubmit(event: Event) {
event.preventDefault();
const params = new URLSearchParams({
title: title.trim(),
syntax: selectedSyntax,
visibility: selectedVisibility.toString()
});
let body = content;
if (selectedVisibility === 2) {
body = await encryptAES(content, password);
}
const url = `/api/paste/create?${params.toString()}`;
const options: RequestInit = {
method: 'POST',
headers: { 'Content-Type': 'text/plain' },
body
};
const response = await fetch(url, options);
if (response.ok) {
const result = await response.json();
window.location.href = `/${result.id}`;
} else {
alert('Failed to create paste. Please try again.');
}
}
async function encryptAES(content: string, password: string): Promise<string> {
const enc = new TextEncoder();
const keyMaterial = await window.crypto.subtle.importKey(
'raw',
enc.encode(password),
{ name: 'PBKDF2' },
false,
['deriveBits', 'deriveKey']
);
const salt = window.crypto.getRandomValues(new Uint8Array(16));
const key = await window.crypto.subtle.deriveKey(
{
name: 'PBKDF2',
salt: salt,
iterations: 100000,
hash: 'SHA-256'
},
keyMaterial,
{ name: 'AES-GCM', length: 256 },
false,
['encrypt']
);
const iv = window.crypto.getRandomValues(new Uint8Array(12));
const encryptedContent = await window.crypto.subtle.encrypt(
{
name: 'AES-GCM',
iv: iv
},
key,
enc.encode(content)
);
const combined = new Uint8Array(salt.byteLength + iv.byteLength + encryptedContent.byteLength);
combined.set(salt, 0);
combined.set(iv, salt.byteLength);
combined.set(new Uint8Array(encryptedContent), salt.byteLength + iv.byteLength);
const result = {
version: 1,
kdf: 'PBKDF2',
iterations: 100000,
hash: 'SHA-256',
algorithm: 'AES-GCM',
data: btoa(String.fromCharCode(...combined))
};
return JSON.stringify(result);
}
</script>
<main
class="flex min-h-screen w-full flex-col items-center justify-center bg-neutral-950 text-white"
>
<div class="rounded border-2 border-neutral-800 bg-neutral-900 p-6 w-full max-w-5xl">
<h1 class="mb-6 text-center text-4xl font-bold">Create a Paste</h1>
<form class="mt-4" on:submit|preventDefault={handleSubmit}>
<input
type="text"
placeholder="Title (optional)"
class="mb-4 w-full rounded border border-neutral-700 bg-neutral-800 p-2"
spellcheck="false"
autocomplete="off"
bind:value={title}
/>
<textarea
placeholder="Your paste content here..."
class="mb-4 h-64 max-h-[50vh] min-h-10 w-full resize-y rounded border border-neutral-700 bg-neutral-800 p-2"
spellcheck="false"
autocomplete="off"
bind:value={content}
></textarea>
<select
class="mb-4 w-full rounded border border-neutral-700 bg-neutral-800 p-2"
bind:value={selectedSyntax}
>
{#each data.options.syntaxes as lang (lang)}
<option value={lang}
>{displayNames[lang] ?? lang.charAt(0).toUpperCase() + lang.slice(1)}</option
>
{/each}
</select>
<select
class="mb-4 w-full rounded border border-neutral-700 bg-neutral-800 p-2"
bind:value={selectedVisibility}
>
{#each data.options.visibilities as visibility (visibility.value)}
<option value={visibility.value}>{visibility.displayName}</option>
{/each}
</select>
{#if selectedVisibility === 2}
<input
type="password"
placeholder="Password for private paste"
class="mb-4 w-full rounded border border-neutral-700 bg-neutral-800 p-2"
spellcheck="false"
autocomplete="off"
bind:value={password}
/>
{/if}
<button
type="submit"
class="w-full rounded bg-neutral-700 px-4 py-2 font-semibold text-white transition-colors duration-200 hover:bg-neutral-800 active:bg-neutral-900"
>Create Paste</button
>
</form>
</div>
</main>
@@ -0,0 +1,30 @@
import type { PageServerLoad } from './$types';
import { getShiki } from '$lib/shiki';
export const load: PageServerLoad = async ({ params, fetch }) => {
const { id } = params;
const paste = await fetch(`/api/paste/${id}`);
if (paste.status === 404) {
return {
status: 404,
error: { message: 'Paste not found' }
};
}
const pasteData = await paste.json();
const pasteContent = await fetch(`/api/paste/raw/${id}`);
const pasteOptions = await fetch('/api/paste/create/options');
const options = await pasteOptions.json();
const content = await pasteContent.text();
let highlighted = '';
if (pasteData && content) {
const shiki = await getShiki();
highlighted = shiki.codeToHtml(content, {
lang: pasteData.syntax || 'plaintext',
theme: 'github-dark'
});
}
return { paste: pasteData, content, options, highlighted };
};
@@ -0,0 +1,83 @@
<script lang="ts">
import type { PageData } from './$types';
export let data: PageData;
function addLineNumbers(html: string): string {
const match = html.match(/<pre.*?>[\s\S]*?<code.*?>([\s\S]*?)<\/code><\/pre>/);
if (!match) return html;
const code = match[1];
const lines = code.split(/\n/);
const digits = String(lines.length).length;
const numbered = lines
.map(
(line, i) =>
`<div class="code-row"><span class="line-number" style="width:${digits}ch">${i + 1}</span><span class="code-line">${line}</span></div>`
)
.join('');
return html.replace(code, numbered);
}
</script>
<main
class="flex min-h-screen w-full flex-col items-center justify-center bg-neutral-950 text-white"
>
{#if data.paste}
<div class="max-h-[80vh] rounded border-2 border-neutral-800 bg-neutral-900 p-4 w-full max-w-5xl">
<h1 class="mb-4 text-center text-4xl font-bold">{data.paste.title || 'Untitled Paste'}</h1>
<div
class="codeblock-with-lines max-w-full overflow-x-auto overflow-y-auto"
style="max-width:100vw; min-width:0;"
>
{@html addLineNumbers(data.highlighted ?? '')}
</div>
</div>
{:else}
<h1 class="text-2xl font-bold">Paste not found</h1>
<h2 class="mt-2 text-lg">The paste you are looking for does not exist.</h2>
{/if}
<style>
.codeblock-with-lines {
max-width: 100vw;
min-width: 0;
overflow-x: auto;
overflow-y: auto;
}
.codeblock-with-lines pre {
display: block;
position: relative;
padding: 1em;
margin: 0;
background: none;
border-radius: 0.25em;
background-color: var(--color-neutral-800) !important;
overflow-x: auto;
min-width: max-content;
max-height: 60vh;
}
.code-row {
display: flex;
align-items: flex-start;
min-width: max-content;
padding: 0.1em 0;
}
.line-number {
flex-shrink: 0;
text-align: right;
color: #888;
user-select: none;
margin-right: 1em;
font-variant-numeric: tabular-nums;
padding-right: 0.5em;
padding-left: 0.25em;
background: none;
}
.code-line {
display: block;
white-space: pre;
word-break: normal;
overflow-wrap: normal;
padding-left: 0.25em;
min-width: 0;
}
</style>
</main>
+28
View File
@@ -1 +1,29 @@
@import 'tailwindcss'; @import 'tailwindcss';
* {
box-sizing: border-box;
}
body,
h1,
h2,
h3,
p {
font-family: 'IBM Plex Sans', sans-serif;
}
pre,
code,
textarea,
option,
select {
font-family: 'Fira Code', monospace;
}
input[type='text'],
input[type='email'],
input[type='password'],
textarea,
select {
outline: none;
}
+34 -4
View File
@@ -1,17 +1,20 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using SharpbinV3.Server.Data.Entities; using SharpbinV3.Server.Data.Entities;
using SharpbinV3.Server.DTOs; using SharpbinV3.Server.DTOs;
using SharpbinV3.Server.Services; using SharpbinV3.Server.Services;
using SharpbinV3.Server.Settings;
namespace SharpbinV3.Server.Controllers namespace SharpbinV3.Server.Controllers
{ {
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class PasteController(IPasteService pasteService, IUserService userService) : ControllerBase public class PasteController(IPasteService pasteService, IUserService userService, IOptions<PasteSettings> options) : ControllerBase
{ {
private readonly IPasteService _pasteService = pasteService; private readonly IPasteService _pasteService = pasteService;
private readonly IUserService _userService = userService; private readonly IUserService _userService = userService;
private readonly PasteSettings _pasteSettings = options.Value;
[HttpPost] [HttpPost]
[Route("create")] [Route("create")]
@@ -24,7 +27,7 @@ namespace SharpbinV3.Server.Controllers
if (!await _pasteService.ValidateSyntax(syntax)) if (!await _pasteService.ValidateSyntax(syntax))
return BadRequest(new { message = "Invalid syntax." }); return BadRequest(new { message = "Invalid syntax." });
if (!await _pasteService.ValidateTitle(title)) if (!await _pasteService.ValidateTitle(title))
return BadRequest(new { message = "Invalid title. Must be less than 500 characters." }); return BadRequest(new { message = $"Invalid title. Must be less than {_pasteSettings.MaxTitleLength} characters." });
string content = await new StreamReader(Request.Body).ReadToEndAsync(); string content = await new StreamReader(Request.Body).ReadToEndAsync();
var httpUser = HttpContext.User; var httpUser = HttpContext.User;
@@ -40,7 +43,6 @@ namespace SharpbinV3.Server.Controllers
paste.TrueSize, paste.TrueSize,
paste.ExpiresAt paste.ExpiresAt
}); });
} }
[HttpGet] [HttpGet]
[Route("{id}")] [Route("{id}")]
@@ -48,7 +50,6 @@ namespace SharpbinV3.Server.Controllers
{ {
var paste = await _pasteService.Get(id); var paste = await _pasteService.Get(id);
if (paste == null) return NotFound(); if (paste == null) return NotFound();
Console.WriteLine(paste.User);
return Ok(new return Ok(new
{ {
paste.ID, paste.ID,
@@ -124,6 +125,16 @@ namespace SharpbinV3.Server.Controllers
paste.Visibility = request.Visibility.Value; paste.Visibility = request.Visibility.Value;
if (request.ExpiresAt.HasValue) if (request.ExpiresAt.HasValue)
paste.ExpiresAt = request.ExpiresAt.Value; paste.ExpiresAt = request.ExpiresAt.Value;
if (!await _pasteService.ValidateExpiresAt(paste.ExpiresAt))
return BadRequest(new { message = "Invalid expiration time." });
if (!await _pasteService.ValidateVisibility(paste.Visibility))
return BadRequest(new { message = "Invalid visibility level. Must be between 0 and 2." });
if (!await _pasteService.ValidateSyntax(paste.Syntax ?? "plaintext"))
return BadRequest(new { message = "Invalid syntax." });
if (!await _pasteService.ValidateTitle(paste.Title ?? ""))
return BadRequest(new { message = $"Invalid title. Must be less than {_pasteSettings.MaxTitleLength} characters." });
var newPaste = await _pasteService.Edit(paste); var newPaste = await _pasteService.Edit(paste);
return Ok(new return Ok(new
{ {
@@ -143,5 +154,24 @@ namespace SharpbinV3.Server.Controllers
} }
}); });
} }
[HttpGet]
[Route("create/options")]
public IActionResult GetCreatePasteOptions()
{
var options = new
{
syntaxes = _pasteSettings.ValidSyntaxLanguages,
visibilities = new[]
{
new { value = 0, displayName = "Public" },
new { value = 1, displayName = "Unlisted" },
new { value = 2, displayName = "Private" }
},
maxTitleLength = _pasteSettings.MaxTitleLength,
maxPasteSize = _pasteSettings.MaxPasteSizeInBytes
};
return Ok(options);
}
} }
} }
@@ -1,10 +1,7 @@
using System.ComponentModel.DataAnnotations; namespace SharpbinV3.Server.DTOs
namespace SharpbinV3.Server.DTOs
{ {
public class PasteMetadataUpdateRequest public class PasteMetadataUpdateRequest
{ {
[StringLength(500)]
public string? Title { get; set; } public string? Title { get; set; }
public string? Syntax { get; set; } public string? Syntax { get; set; }
public int? Visibility { get; set; } public int? Visibility { get; set; }
+1 -2
View File
@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
+3
View File
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using SharpbinV3.Server.Data; using SharpbinV3.Server.Data;
using SharpbinV3.Server.Services; using SharpbinV3.Server.Services;
using SharpbinV3.Server.Settings;
using System.Text; using System.Text;
using System.Threading.RateLimiting; using System.Threading.RateLimiting;
@@ -72,6 +73,8 @@ namespace SharpbinV3.Server
.AllowAnyHeader() .AllowAnyHeader()
.AllowAnyMethod()); .AllowAnyMethod());
}); });
builder.Services.Configure<PasteSettings>(builder.Configuration.GetSection("PasteSettings"));
builder.Services.Configure<JWTSettings>(builder.Configuration.GetSection("JWTSettings"));
var app = builder.Build(); var app = builder.Build();
app.UseRateLimiter(); app.UseRateLimiter();
+11 -9
View File
@@ -1,8 +1,10 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using SharpbinV3.Server.Data; using SharpbinV3.Server.Data;
using SharpbinV3.Server.Data.Entities; using SharpbinV3.Server.Data.Entities;
using SharpbinV3.Server.DTOs; using SharpbinV3.Server.DTOs;
using SharpbinV3.Server.Settings;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims; using System.Security.Claims;
using System.Text; using System.Text;
@@ -10,10 +12,10 @@ using Bcrypt = BCrypt.Net.BCrypt;
namespace SharpbinV3.Server.Services namespace SharpbinV3.Server.Services
{ {
public sealed class AuthService(AppDbContext db, IConfiguration configuration) : IAuthService public sealed class AuthService(AppDbContext db, IOptions<JWTSettings> options) : IAuthService
{ {
private readonly AppDbContext _db = db; private readonly AppDbContext _db = db;
private readonly IConfiguration _configuration = configuration; private readonly JWTSettings _jwtSettings = options.Value;
public async Task<User> CreateUser(string username, string password, string? email, string? displayName) public async Task<User> CreateUser(string username, string password, string? email, string? displayName)
{ {
@@ -33,7 +35,7 @@ namespace SharpbinV3.Server.Services
public async Task<JWTResult> GenerateJWTToken(User user) public async Task<JWTResult> GenerateJWTToken(User user)
{ {
var jwtHandler = new JwtSecurityTokenHandler(); var jwtHandler = new JwtSecurityTokenHandler();
var key = Encoding.ASCII.GetBytes(_configuration["JwtConfig:Secret"]!); var key = Encoding.ASCII.GetBytes(_jwtSettings.SecretKey);
var descriptor = new SecurityTokenDescriptor var descriptor = new SecurityTokenDescriptor
{ {
@@ -43,8 +45,8 @@ namespace SharpbinV3.Server.Services
new Claim("Roles", user.Roles != null ? string.Join(",", user.Roles) : "0"), new Claim("Roles", user.Roles != null ? string.Join(",", user.Roles) : "0"),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
]), ]),
Issuer = _configuration["JwtConfig:Issuer"], Issuer = _jwtSettings.Issuer,
Audience = _configuration["JwtConfig:Audience"], Audience = _jwtSettings.Audience,
Expires = DateTime.UtcNow.AddMinutes(15), Expires = DateTime.UtcNow.AddMinutes(15),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
}; };
@@ -91,7 +93,7 @@ namespace SharpbinV3.Server.Services
public async Task<bool> ValidateJWTToken(string token) public async Task<bool> ValidateJWTToken(string token)
{ {
var jwtHandler = new JwtSecurityTokenHandler(); var jwtHandler = new JwtSecurityTokenHandler();
var key = Encoding.ASCII.GetBytes(_configuration["JwtConfig:Secret"]!); var key = Encoding.ASCII.GetBytes(_jwtSettings.SecretKey);
try try
{ {
jwtHandler.ValidateToken(token, new TokenValidationParameters jwtHandler.ValidateToken(token, new TokenValidationParameters
@@ -113,7 +115,7 @@ namespace SharpbinV3.Server.Services
public async Task<JWTResult> RefreshJWTToken(string token, string refreshToken) public async Task<JWTResult> RefreshJWTToken(string token, string refreshToken)
{ {
var jwtHandler = new JwtSecurityTokenHandler(); var jwtHandler = new JwtSecurityTokenHandler();
var key = Encoding.ASCII.GetBytes(_configuration["JwtConfig:Secret"]!); var key = Encoding.ASCII.GetBytes(_jwtSettings.SecretKey);
try try
{ {
var principal = jwtHandler.ValidateToken(token, new TokenValidationParameters var principal = jwtHandler.ValidateToken(token, new TokenValidationParameters
@@ -121,9 +123,9 @@ namespace SharpbinV3.Server.Services
ValidateIssuerSigningKey = true, ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(key), IssuerSigningKey = new SymmetricSecurityKey(key),
ValidateIssuer = true, ValidateIssuer = true,
ValidIssuer = _configuration["JwtConfig:Issuer"], ValidIssuer = _jwtSettings.Issuer,
ValidateAudience = true, ValidateAudience = true,
ValidAudience = _configuration["JwtConfig:Audience"], ValidAudience = _jwtSettings.Audience,
ClockSkew = TimeSpan.Zero, ClockSkew = TimeSpan.Zero,
ValidateLifetime = false ValidateLifetime = false
}, out SecurityToken validatedToken); }, out SecurityToken validatedToken);
+8 -32
View File
@@ -1,41 +1,17 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using SharpbinV3.Server.Data; using SharpbinV3.Server.Data;
using SharpbinV3.Server.Data.Entities; using SharpbinV3.Server.Data.Entities;
using SharpbinV3.Server.Settings;
using System.Text; using System.Text;
namespace SharpbinV3.Server.Services namespace SharpbinV3.Server.Services
{ {
public sealed class PasteService(AppDbContext db, ICompressionService cs) : IPasteService public sealed class PasteService(AppDbContext db, ICompressionService cs, IOptions<PasteSettings> options) : IPasteService
{ {
private readonly AppDbContext _db = db; private readonly AppDbContext _db = db;
private readonly ICompressionService _cs = cs; private readonly ICompressionService _cs = cs;
private readonly static string[] ValidSyntaxLanguages = private readonly PasteSettings _pasteSettings = options.Value;
[
"plaintext",
"autoHotkey",
"autoIt",
"bash",
"c",
"cpp",
"csharp",
"css",
"dart",
"html",
"java",
"javascript",
"json",
"lua",
"markdown",
"php",
"python",
"ruby",
"rust",
"sql",
"swift",
"typescript",
"toml",
"xml"
];
public async Task<Paste> Create(User? author, string content, string title, string syntax, int visibility, long expiresAt) public async Task<Paste> Create(User? author, string content, string title, string syntax, int visibility, long expiresAt)
{ {
@@ -92,10 +68,10 @@ namespace SharpbinV3.Server.Services
var result = await _db.SaveChangesAsync(); var result = await _db.SaveChangesAsync();
return result > 0; return result > 0;
} }
public async Task<Paste> Get(string id) public async Task<Paste?> Get(string id)
{ {
var paste = await _db.Pastes.Include(p => p.User).FirstOrDefaultAsync(p => p.ID == id); var paste = await _db.Pastes.Include(p => p.User).FirstOrDefaultAsync(p => p.ID == id);
return paste ?? throw new KeyNotFoundException("Paste not found"); return paste ?? null;
} }
public async Task<List<Paste>> GetList(int offset, int count, bool publicOnly = false) public async Task<List<Paste>> GetList(int offset, int count, bool publicOnly = false)
{ {
@@ -112,11 +88,11 @@ namespace SharpbinV3.Server.Services
public async Task<bool> ValidateSyntax(string syntax) public async Task<bool> ValidateSyntax(string syntax)
{ {
return await Task.FromResult(ValidSyntaxLanguages.Contains(syntax)); return await Task.FromResult(_pasteSettings.ValidSyntaxLanguages.Contains(syntax));
} }
public async Task<bool> ValidateTitle(string title) public async Task<bool> ValidateTitle(string title)
{ {
return await Task.FromResult(title.Length <= 500); return await Task.FromResult(title.Length <= _pasteSettings.MaxTitleLength);
} }
public async Task<bool> ValidateVisibility(int visibility) public async Task<bool> ValidateVisibility(int visibility)
{ {
+9
View File
@@ -0,0 +1,9 @@
namespace SharpbinV3.Server.Settings
{
public class JWTSettings
{
public string SecretKey { get; set; } = Utilities.GenerateRandomString(64);
public string Issuer { get; set; } = "SharpbinV3";
public string Audience { get; set; } = "SharpbinV3.Client";
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace SharpbinV3.Server.Settings
{
public class PasteSettings
{
public string[] ValidSyntaxLanguages { get; set; } = [];
public int MaxTitleLength { get; set; } = 500;
public int MaxPasteSizeInBytes { get; set; } = 1_048_576; // 1 MB
}
}
+157 -1
View File
@@ -9,9 +9,165 @@
"DefaultConnection": "Data Source=sharpbin.db" "DefaultConnection": "Data Source=sharpbin.db"
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"JwtConfig": { "JwtSettings": {
"Secret": "", "Secret": "",
"Issuer": "SharpbinApi", "Issuer": "SharpbinApi",
"Audience": "SharpbinClient" "Audience": "SharpbinClient"
},
"PasteSettings": {
"ValidSyntaxLanguages": [
"plaintext",
"abap",
"actionscript-3",
"ada",
"apache",
"apex",
"apl",
"applescript",
"ara",
"asm",
"astro",
"awk",
"ballerina",
"bat",
"berry",
"bibtex",
"bicep",
"blade",
"c",
"cadence",
"clarity",
"clojure",
"cmake",
"cobol",
"codeql",
"coffee",
"cpp",
"crystal",
"csharp",
"css",
"cue",
"d",
"dart",
"diff",
"docker",
"dream-maker",
"elixir",
"elm",
"erb",
"erlang",
"fish",
"fsharp",
"gdresource",
"gdscript",
"gdshader",
"gherkin",
"git-commit",
"git-rebase",
"glsl",
"gnuplot",
"go",
"graphql",
"groovy",
"hack",
"haml",
"handlebars",
"haskell",
"hcl",
"hjson",
"hlsl",
"html",
"ini",
"java",
"javascript",
"jison",
"json",
"json5",
"jsonc",
"jsonnet",
"jssm",
"jsx",
"julia",
"kotlin",
"latex",
"less",
"liquid",
"lisp",
"logo",
"lua",
"makefile",
"markdown",
"marko",
"matlab",
"mdx",
"nginx",
"nim",
"nix",
"objective-c",
"objective-cpp",
"ocaml",
"pascal",
"perl",
"php",
"plsql",
"postcss",
"powerquery",
"powershell",
"prisma",
"prolog",
"proto",
"pug",
"puppet",
"purescript",
"python",
"r",
"raku",
"razor",
"reg",
"rel",
"riscv",
"rst",
"ruby",
"rust",
"sas",
"sass",
"scala",
"scheme",
"scss",
"shaderlab",
"shell",
"smalltalk",
"solidity",
"sparql",
"sql",
"ssh-config",
"stata",
"stylus",
"svelte",
"swift",
"system-verilog",
"tasl",
"tcl",
"tex",
"toml",
"tsx",
"turtle",
"twig",
"typescript",
"v",
"vb",
"verilog",
"vhdl",
"viml",
"vue",
"wasm",
"wenyan",
"xml",
"xsl",
"yaml",
"zenscript"
],
"MaxPasteSizeBytes": 1048576,
"MaxTitleLength": 500
} }
} }