mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
012690f507
|
||
|
|
5017e73bb5
|
||
|
|
809b513e7a
|
||
|
|
3374eadb56
|
||
|
|
7d09870ad2
|
||
|
|
fd1cb3998c
|
||
|
|
3dc8070efe
|
||
|
|
78f4ae181e
|
||
|
|
ee45deb439
|
||
|
|
3b2801a655
|
||
|
|
cac34423d9
|
||
|
|
5052bbdb13
|
||
|
|
0283d987d0
|
||
|
|
ff706d8777
|
||
|
|
53d0f33ff0
|
||
|
|
db363f0211
|
||
|
|
4feae4cadf
|
||
|
|
0d9a713247
|
||
|
|
d2b9acb70f
|
||
|
|
1cd6d16d85
|
||
|
|
1a13694621
|
||
|
|
3904ac327f
|
||
|
|
d64e1b4e82
|
||
|
|
697ec384f8
|
||
|
|
4917180624
|
||
|
|
e90184992a
|
||
|
|
698db0a85e
|
||
|
|
6b32994d16
|
||
|
|
d04e2962b5
|
||
|
|
b56a848d21
|
||
|
|
91ad515205
|
||
|
|
f37e647a1c
|
||
|
|
54ca2ee641
|
||
|
|
22317a2fae
|
||
|
|
c9591a43c7
|
||
|
|
cbbed2d341
|
||
|
|
23e7973e97
|
||
|
|
e141e1c642
|
||
|
|
f95b347191
|
||
|
|
908441de4b
|
||
|
|
755b356d61
|
||
|
|
71363fa1a4
|
||
|
|
abcf79c645
|
||
|
|
4057f2303c
|
||
|
|
fb41995d53
|
||
|
|
4b01d801eb
|
||
|
|
a76213b397
|
||
|
|
e4cf98af09
|
||
|
|
8b3f397837
|
||
|
|
a6ffa982a4
|
||
|
|
005cb5de23
|
||
|
|
05cd024110
|
||
|
|
270360a32f
|
||
|
|
79ca6ffa80
|
||
|
|
15f0be5a2f
|
||
|
|
c52ad8ba9b
|
||
|
|
5375e1caa6
|
||
|
|
81f85defb0
|
||
|
|
2cc2379e10
|
||
|
|
adcaaadd7e
|
||
|
|
1af3c095c4
|
||
|
|
ca210c5ea3
|
||
|
|
854e50fe78
|
||
|
|
500f457f97
|
||
|
|
8aa1543296
|
||
|
|
9d0cc54db4
|
||
|
|
3101f83e3f
|
||
|
|
d2486b9f6e
|
||
|
|
5b6498746b
|
||
|
|
15b9109ee5
|
+257
@@ -0,0 +1,257 @@
|
|||||||
|
## [3.0.4](https://github.com/whoswhip/Sharpbin/compare/v3.0.3...v3.0.4) (2026-02-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **backend:** use GenerateSecureRandomString for api-keys, paste ids, and refresh tokens ([5017e73](https://github.com/whoswhip/Sharpbin/commit/5017e73bb54e626d4dc060fd553c972663eec45f))
|
||||||
|
* **frontend:api-keys:** add flag to track successful API key fetch ([78f4ae1](https://github.com/whoswhip/Sharpbin/commit/78f4ae181eb18a98ed9964d8e651d84319fa8d2c))
|
||||||
|
* **frontend:user:** resolve lint errors ([7d09870](https://github.com/whoswhip/Sharpbin/commit/7d09870ad25472ff17a1acc22d5724e199f2c931))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add dotnet-ef tool configuration to dotnet-tools.json ([db363f0](https://github.com/whoswhip/Sharpbin/commit/db363f0211972a06b622770ca522d3ef0bba12c8))
|
||||||
|
* **backend:authentication:** implement API key authentication scheme and update authorization policies ([3374ead](https://github.com/whoswhip/Sharpbin/commit/3374eadb5654fa349a636c4a41a53df1ddf2edfe))
|
||||||
|
* **backend:utilities:** implement GenerateSecureRandomString function that uses RandomNumberGenerator ([809b513](https://github.com/whoswhip/Sharpbin/commit/809b513e7a3f5a4f7faf64b02d9ed83e81c540b8))
|
||||||
|
* **backend:** implement api keys; rename token -> verificationToken in paste creation api ([53d0f33](https://github.com/whoswhip/Sharpbin/commit/53d0f33ff026d6e5a188d80585e6a3bb633d9fa8))
|
||||||
|
* **frontend:api-keys:** display the count of API keys in the header and adjust empty state condition ([3dc8070](https://github.com/whoswhip/Sharpbin/commit/3dc8070efeb19538c4ff120d2a681c4167c716f3))
|
||||||
|
* **frontend:api-keys:** implement API key management features including creation, deletion, and fetching ([ee45deb](https://github.com/whoswhip/Sharpbin/commit/ee45deb43937cbf3996c3c379461110a484bd086))
|
||||||
|
* **frontend:modal:** decrease modal background opacity and blur ([3b2801a](https://github.com/whoswhip/Sharpbin/commit/3b2801a65509d3a894c701f03028b2cd4599b456))
|
||||||
|
* **frontend:stats:** enhance tooltip for total storage used to show uncompressed size ([cac3442](https://github.com/whoswhip/Sharpbin/commit/cac34423d99d1228f426be903da53bafca5f50e7))
|
||||||
|
* **frontend:user:** improve UX; move user settings to settings tab ([5052bbd](https://github.com/whoswhip/Sharpbin/commit/5052bbdb135dc2df08db94874de5bf2bf738364c))
|
||||||
|
* **frontend:** improve user page UX ([ff706d8](https://github.com/whoswhip/Sharpbin/commit/ff706d877742317cb8f4ccf72ba5f0791a6d2b88))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.0.3](https://github.com/whoswhip/Sharpbin/compare/v3.0.2...v3.0.3) (2026-02-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* correct spelling of 'Verification' in PasteSettings and PasteController ([697ec38](https://github.com/whoswhip/Sharpbin/commit/697ec384f8a0d3d86eb7e523595ddda3cda256b4))
|
||||||
|
* do not generate open api documents on build ([e901849](https://github.com/whoswhip/Sharpbin/commit/e90184992a1dd585bfb3728dc866193ab870fb86))
|
||||||
|
* ensure length > 0 and that arrays have value before validating ([f95b347](https://github.com/whoswhip/Sharpbin/commit/f95b347191854e8057c8086e52165a83e2fa8a7d))
|
||||||
|
* initialize multiselect state in modal component ([908441d](https://github.com/whoswhip/Sharpbin/commit/908441de4b7e857d8cbcc520da86cf1abaab0fa2))
|
||||||
|
* prevent internal server endpoint leakage in openapi ([4917180](https://github.com/whoswhip/Sharpbin/commit/4917180624d1ec2f7af784c50c5cd2810beba1b3))
|
||||||
|
* resolve lint issues ([b56a848](https://github.com/whoswhip/Sharpbin/commit/b56a848d21da5d8bb57c22bdc03bd84449813338))
|
||||||
|
* simplify height adjustment logic for text area and markdown container ([f37e647](https://github.com/whoswhip/Sharpbin/commit/f37e647a1c0264a3b6229c270e75b8176ec93628))
|
||||||
|
* update display name validation to allow spaces and improve error message ([755b356](https://github.com/whoswhip/Sharpbin/commit/755b356d616a339273c7e45207304e901617c367))
|
||||||
|
* update stats tooltip to display correct pluralization for paste counts ([54ca2ee](https://github.com/whoswhip/Sharpbin/commit/54ca2ee6417e0a6cfcc14ccb0be6e79d9dc4cacd))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add statistics link to footer component ([cbbed2d](https://github.com/whoswhip/Sharpbin/commit/cbbed2d341670ba7b034af161ccdb3ddb3101dc0))
|
||||||
|
* add statistics page ([22317a2](https://github.com/whoswhip/Sharpbin/commit/22317a2fae8f8a8ed45f313a46bb2489b8042f92))
|
||||||
|
* allow spaces in display names ([abcf79c](https://github.com/whoswhip/Sharpbin/commit/abcf79c6458b97d1f75b6c31020fdc7ab957d4f2))
|
||||||
|
* **backend:** allow spaces in display name during registration ([71363fa](https://github.com/whoswhip/Sharpbin/commit/71363fa1a467c660297301d4f35513bdfe39ccd5))
|
||||||
|
* cache for 6 hours instead of 24 hours ([d04e296](https://github.com/whoswhip/Sharpbin/commit/d04e2962b51796393f77b66fd37f6efad924b413))
|
||||||
|
* enhance API stats endpoint to include daily paste counts for the past week ([23e7973](https://github.com/whoswhip/Sharpbin/commit/23e7973e972f197954568fb292f1c8f6e5272c50))
|
||||||
|
* implement web worker for syntax highlighting using highlight.js ([1cd6d16](https://github.com/whoswhip/Sharpbin/commit/1cd6d16d8538bf3b990f523703eb9abc19da5f36))
|
||||||
|
* proxy openapi url ([698db0a](https://github.com/whoswhip/Sharpbin/commit/698db0a85e000e8b1ab76d82827b8f404ffd0f67))
|
||||||
|
* true total paste size; always map the openapi route ([6b32994](https://github.com/whoswhip/Sharpbin/commit/6b32994d16b201a5a99037fcb23af30bd35876bc))
|
||||||
|
* update tooltip function to accept parameters for styling ([c9591a4](https://github.com/whoswhip/Sharpbin/commit/c9591a43c78b7c8a09b3e7afa0e8b401b70efae0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.0.2](https://github.com/whoswhip/Sharpbin/compare/v3.0.1...v3.0.2) (2026-01-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add IValidateableObject interface to required DTO's ensuring model validation ([270360a](https://github.com/whoswhip/Sharpbin/commit/270360a32f9b9217a1be1057058a61c57f578e95))
|
||||||
|
* adjust input margin for title field in paste creation ([d2486b9](https://github.com/whoswhip/Sharpbin/commit/d2486b9f6e1b87e2d4e13fcc2550292ad77170c3))
|
||||||
|
* enable AllowMissingPrunePackageData in project configuration ([c52ad8b](https://github.com/whoswhip/Sharpbin/commit/c52ad8ba9b12e62324fc6bac445a3e1c5b275e95))
|
||||||
|
* improve error handling and update user display name modal ([a6ffa98](https://github.com/whoswhip/Sharpbin/commit/a6ffa982a4225ef4512b925af39ed4836be40fbb))
|
||||||
|
* update version to 3.0.1 in package-lock.json ([15f0be5](https://github.com/whoswhip/Sharpbin/commit/15f0be5a2f902429906c1acdfe7923b25c16be12))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add conventional-changelog and conventional-changelog-angular dependencies ([e4cf98a](https://github.com/whoswhip/Sharpbin/commit/e4cf98af096b4909e97898eaa452447a09307d31))
|
||||||
|
* add inputMaxLength property to Modal component for better input control ([005cb5d](https://github.com/whoswhip/Sharpbin/commit/005cb5de23e244a4b07ea1173b7805f7cd2b2561))
|
||||||
|
* add output caching and stats endpoint to track pastes and users ([ca210c5](https://github.com/whoswhip/Sharpbin/commit/ca210c5ea3e97d7a4e93f51794d1da7a6da40ebf))
|
||||||
|
* createdAt paste property ([9d0cc54](https://github.com/whoswhip/Sharpbin/commit/9d0cc54db46a24d16f752b5db66baf1565891d26))
|
||||||
|
* enhance PasteService with caching and cache invalidation methods ([5375e1c](https://github.com/whoswhip/Sharpbin/commit/5375e1caa64ce51bd0cd3613f8df68d6ea2d7aa4))
|
||||||
|
* include createdAt in user responses ([854e50f](https://github.com/whoswhip/Sharpbin/commit/854e50fe78265a58af6004c3db12ca551c4372f9))
|
||||||
|
* include paste createdAt in responses ([8aa1543](https://github.com/whoswhip/Sharpbin/commit/8aa1543296817745f66a724e349897d8496bb193))
|
||||||
|
* user createdAt property ([500f457](https://github.com/whoswhip/Sharpbin/commit/500f457f976bc4742e8e3395f01eef84a0c16558))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.0.1](https://github.com/whoswhip/Sharpbin/compare/v3.0.0...v3.0.1) (2026-01-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* adjust dropdown max height dynamically and improve search input positioning ([2d01e72](https://github.com/whoswhip/Sharpbin/commit/2d01e726a97b99a35017df9f477fa1304213bc9e))
|
||||||
|
* adjust height properties for paste creation info ([01efa39](https://github.com/whoswhip/Sharpbin/commit/01efa399cf7d7aa1d38af1bc29017a8873f97dca))
|
||||||
|
* adjust tooltip formatting for decrypted size display ([a7481b5](https://github.com/whoswhip/Sharpbin/commit/a7481b5852532d42697e723f8f49cfa126ce8212))
|
||||||
|
* allow flexible display on cf turnstile ([3681f58](https://github.com/whoswhip/Sharpbin/commit/3681f586dc0a01fcfd197db3961386d4ac7fe371))
|
||||||
|
* disable pointer events on menu icons ([590f0c3](https://github.com/whoswhip/Sharpbin/commit/590f0c3da9c4bd6f9db43a5866dddfb9a2859326))
|
||||||
|
* enhance password validation and add show/hide functionality ([ec62e3b](https://github.com/whoswhip/Sharpbin/commit/ec62e3be7556f083ef8380dd4eece4f5e5b4f148))
|
||||||
|
* enhance Paste component layout and user information display ([4db9867](https://github.com/whoswhip/Sharpbin/commit/4db986715cfd36d300677b7e527ff8e2de827791))
|
||||||
|
* include author data in recent paste data ([c9aa0d9](https://github.com/whoswhip/Sharpbin/commit/c9aa0d9a16f9135be7be4b100c6c0966f3285e6a))
|
||||||
|
* render all turnstiles as flexible and interaction-only ([75010d3](https://github.com/whoswhip/Sharpbin/commit/75010d303424a45d9435571b45e4d0d29ade23a9))
|
||||||
|
* resize markdown preview as well ([51449ab](https://github.com/whoswhip/Sharpbin/commit/51449abe6e894d289374ec7ffcef21ff3d1e71c9))
|
||||||
|
* resolve lint issue svelte/no-at-html-tags ([71fb5b1](https://github.com/whoswhip/Sharpbin/commit/71fb5b16160aa986ca577c25373dcc382ff96ba3))
|
||||||
|
* update Open Graph description to use syntax name from consts ([a06021f](https://github.com/whoswhip/Sharpbin/commit/a06021f0cd67162446d9393a854ddc4f7f3a74b0))
|
||||||
|
* update resize function call to use `previewMode` ensuring resize when switched to code ([16f5bff](https://github.com/whoswhip/Sharpbin/commit/16f5bff317a6620e3a7e5a0fd99ac6b56599dd8e))
|
||||||
|
* update Turnstile configuration and improve layout for verification ([9c49c21](https://github.com/whoswhip/Sharpbin/commit/9c49c21e62118d277670677e51a685150194a2b6))
|
||||||
|
* update visibility icons in Paste component ([6c8cdcc](https://github.com/whoswhip/Sharpbin/commit/6c8cdccbbfd3becdd5fae4674909c788f00edab7))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add CSV rendering functionality with PapaParse ([bfad18b](https://github.com/whoswhip/Sharpbin/commit/bfad18bb0551ddc2eb03f934ecedd2b7b89ddbf2))
|
||||||
|
* add CSV to syntax lists ([147e43c](https://github.com/whoswhip/Sharpbin/commit/147e43cd8ab32da538e6ff76a68cdb7441e469e2))
|
||||||
|
* add papaparse and its type definitions ([95316f5](https://github.com/whoswhip/Sharpbin/commit/95316f5a846c03a5e2b014717c26bea9005f933d))
|
||||||
|
* add tailwind-scrollbar npm package ([43f9a25](https://github.com/whoswhip/Sharpbin/commit/43f9a25915ac32076636ab86781aa7efb5240b41))
|
||||||
|
* close hamburger menu when clicked outside ([1937307](https://github.com/whoswhip/Sharpbin/commit/1937307ae728f0d77c9ee572adf1ba688648e0aa))
|
||||||
|
* enhance CSV rendering with header support and improved styling ([c940fc5](https://github.com/whoswhip/Sharpbin/commit/c940fc5207a80563a620b37c9aeebce395c659e9))
|
||||||
|
* include decrypted size in paste size tooltip ([7082fc4](https://github.com/whoswhip/Sharpbin/commit/7082fc45346824f14d6f8fe85743f73eca6a35c1))
|
||||||
|
* style dropdown scrollbar ([091c6d8](https://github.com/whoswhip/Sharpbin/commit/091c6d895e638fc13b68207e3ae765664dfc80b6))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [3.0.0](https://github.com/whoswhip/Sharpbin/compare/050f0bc935937b8b80500a59bc6ac5513fd7af93...v3.0.0) (2026-01-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add ASPNETCORE_URLS environment variable for backend service in docker-compose.yml ([c4f606e](https://github.com/whoswhip/Sharpbin/commit/c4f606ecf265678495b616a11c0fab1aa4ca9331))
|
||||||
|
* add cursor pointer to the submit button for better UX ([f5de211](https://github.com/whoswhip/Sharpbin/commit/f5de211611c8142c0825286c0f514b1edc161d51))
|
||||||
|
* add validation for display name length in user creation and update requests ([9bb620a](https://github.com/whoswhip/Sharpbin/commit/9bb620a4a31473385af6ffd32d2b7d7c5affd415))
|
||||||
|
* adjust password hint display logic in registration form ([361cf76](https://github.com/whoswhip/Sharpbin/commit/361cf76f46598c1d797c745e44f2de5d960682bc))
|
||||||
|
* center-align text in login and registration links in navbar ([4dafde7](https://github.com/whoswhip/Sharpbin/commit/4dafde739aaf04d4a7b0e08ee15415518bcf2e7b))
|
||||||
|
* change to non-reactive statements ([55bee20](https://github.com/whoswhip/Sharpbin/commit/55bee20e5de3d4c155f2eaa0f7999110a86aa535))
|
||||||
|
* correct conditional logic for user role checks in component rendering ([7298982](https://github.com/whoswhip/Sharpbin/commit/729898296b4e09fa8cada5feb524f1d3774a2d7c))
|
||||||
|
* correct environment variable key for Turnstile Site Key in docker-compose ([2773813](https://github.com/whoswhip/Sharpbin/commit/2773813c263d59a20ceabd02ebabd763a3832ebc))
|
||||||
|
* correct property name for TOTP enabled flag in parseTotpEnabled function ([9e56c4e](https://github.com/whoswhip/Sharpbin/commit/9e56c4eee1d97227b821d643640d2d1db593aba7))
|
||||||
|
* correct syntax selection logic for file drag and drop handling ([62b5dce](https://github.com/whoswhip/Sharpbin/commit/62b5dcef00e6230ec8674d3de65617216e760e51))
|
||||||
|
* display 2FA status only for the account owner ([4de6a6a](https://github.com/whoswhip/Sharpbin/commit/4de6a6a1186e97a7063d5e55008f9acc5043b912))
|
||||||
|
* dont disabled login button when registrations are disabled ([bbfa9ff](https://github.com/whoswhip/Sharpbin/commit/bbfa9ffc560a87bcc8441fddc6d78496819a9144))
|
||||||
|
* enhance paste size validation logic ([f467a2a](https://github.com/whoswhip/Sharpbin/commit/f467a2a89966e6025d7ac0a60eb89c99956e4d28))
|
||||||
|
* enhance textarea styling and display content metrics ([fabef95](https://github.com/whoswhip/Sharpbin/commit/fabef95159e469abcf6316362f18de25aab0a0c6))
|
||||||
|
* enhance tooltip functionality and update last login display ([d3c2efd](https://github.com/whoswhip/Sharpbin/commit/d3c2efd2108026b5e49f1a199c6f2afdeb0a06a0))
|
||||||
|
* ensure JSDOM is only loaded in server-side environments ([7789ab6](https://github.com/whoswhip/Sharpbin/commit/7789ab6cb2822ca338186573c010047a3c5b0f48))
|
||||||
|
* improve error handling and display for login failures ([ce66fe1](https://github.com/whoswhip/Sharpbin/commit/ce66fe13e8718b8abbf67adca9fa1775c932401f))
|
||||||
|
* improve error handling and response messages in EditPaste method ([284c5e9](https://github.com/whoswhip/Sharpbin/commit/284c5e927e1ef796026ca1b1a078adadc1986721))
|
||||||
|
* improve error handling for registration response ([d514e45](https://github.com/whoswhip/Sharpbin/commit/d514e456bf364b1dbdbd7e67938ca609c2362468))
|
||||||
|
* improve error handling in paste fetching and add error page ([5e4afaf](https://github.com/whoswhip/Sharpbin/commit/5e4afafac0e57a24316761c555892fee5dc8394a))
|
||||||
|
* improve error logging for view count increment failure ([8b84a2d](https://github.com/whoswhip/Sharpbin/commit/8b84a2d8a3dbcfa0909a9ba7ac79531244c268f2))
|
||||||
|
* improve formatBytes function and display byte size in textarea ([2a9a4b9](https://github.com/whoswhip/Sharpbin/commit/2a9a4b9eefaef513df5437a9d548e1941583fc1e))
|
||||||
|
* include url queries in resolve ([7857c32](https://github.com/whoswhip/Sharpbin/commit/7857c327eac1a2371552bedc1571650bffb29c0d))
|
||||||
|
* increase max height ([7650fd7](https://github.com/whoswhip/Sharpbin/commit/7650fd786dbcffb9cba6aba9c073d9ec5e19c737))
|
||||||
|
* inline is expired calculation ([2b60ee8](https://github.com/whoswhip/Sharpbin/commit/2b60ee86369731ebc98deaf007c725a544382b2a))
|
||||||
|
* lint issues resolved ([21b6f95](https://github.com/whoswhip/Sharpbin/commit/21b6f95edc1ff34a3ee66f32083b4f99d9bbf2ac))
|
||||||
|
* load turnstile script in layout and explicitly render ([2c24af5](https://github.com/whoswhip/Sharpbin/commit/2c24af5ac98dd4959e353571d3186fb98b459bf4))
|
||||||
|
* null user/paste fk in reports on delete ([f8a1490](https://github.com/whoswhip/Sharpbin/commit/f8a149058295ebc56fc43cecf03b76792fc62529))
|
||||||
|
* prevent moderators from modifiying higher roles(admin) ([3711885](https://github.com/whoswhip/Sharpbin/commit/3711885a38e18ddf6e478e17c671c4c7774c0d3e))
|
||||||
|
* properly set limiter ([6f99036](https://github.com/whoswhip/Sharpbin/commit/6f990364a59b0a9801a6dbd715c70c2f29e63e9c))
|
||||||
|
* refresh token ([19f439a](https://github.com/whoswhip/Sharpbin/commit/19f439a4052d16a3bddba36dc15822906ca92e11))
|
||||||
|
* remove dependency condition for backend service health check in docker-compose.yml ([095df2f](https://github.com/whoswhip/Sharpbin/commit/095df2f3f3aff1eccf4f023ca1a77bc11d66bbea))
|
||||||
|
* remove quotes from DATA_PROTECTION_KEY_PATH in docker-compose ([f96396b](https://github.com/whoswhip/Sharpbin/commit/f96396b586f5f0b5da66227c08767be348f5cbab))
|
||||||
|
* remove quotes from default connection string in docker-compose ([d5565f9](https://github.com/whoswhip/Sharpbin/commit/d5565f9a68bf38035d994002812c3411427f563e))
|
||||||
|
* remove unused nuget package ([4bd6a18](https://github.com/whoswhip/Sharpbin/commit/4bd6a18e31970f4568f0d405454c30b56e06c895))
|
||||||
|
* reset Turnstile on login and registration error handling ([5a630d2](https://github.com/whoswhip/Sharpbin/commit/5a630d2a715acc851add8f82b19dba111d98c2bd))
|
||||||
|
* reset turnstile on login error handling ([1da88db](https://github.com/whoswhip/Sharpbin/commit/1da88dba4ed500baf6dc57b6eeb02b115c0fd000))
|
||||||
|
* resolve lint issues ([1f4fda1](https://github.com/whoswhip/Sharpbin/commit/1f4fda1a16f92cebae716642482d959ad300c5a7))
|
||||||
|
* ssr request to user; navbar positioning ([bffc4e2](https://github.com/whoswhip/Sharpbin/commit/bffc4e2bf41fe1a3dd93f3042be0e796b6f986d2))
|
||||||
|
* **style:** update Navbar styling for improved layout and consistency ([6c3caaf](https://github.com/whoswhip/Sharpbin/commit/6c3caaf2ecaa6dc9e616d7f5a7f65ee1a15c091c))
|
||||||
|
* **styling:** add table styling for markdown elements ([825d384](https://github.com/whoswhip/Sharpbin/commit/825d384db4c906f373ea92ae3e4b46efd741e862))
|
||||||
|
* **styling:** adjust margin and padding for first child in markdown elements ([8f5499a](https://github.com/whoswhip/Sharpbin/commit/8f5499ae05f69c131447fef6188680d448ed895e))
|
||||||
|
* **styling:** enforce max width on recent pastes titles ([8accfa2](https://github.com/whoswhip/Sharpbin/commit/8accfa2dc525f528337e2cbd79ab6a6a2c2b748f))
|
||||||
|
* token refreshing using wrong object path ([e45785e](https://github.com/whoswhip/Sharpbin/commit/e45785e1b8bb64a0834cf420db4866307146132d))
|
||||||
|
* update API fetch calls to use dynamic apiUrl ([6072f7f](https://github.com/whoswhip/Sharpbin/commit/6072f7f674bc3def903815de35536ed933cff7fd))
|
||||||
|
* update API routes for fetching raw paste content and deleting pastes ([48543c7](https://github.com/whoswhip/Sharpbin/commit/48543c7ff03b1ff4b3efa96de56097fb9ada2f02))
|
||||||
|
* update database connection string configuration in Program.cs and docker-compose.yml ([011b523](https://github.com/whoswhip/Sharpbin/commit/011b523fd321e0834c73790b2553adee37a022f6))
|
||||||
|
* update docker-compose to reflect correct backend directory structure ([113ad49](https://github.com/whoswhip/Sharpbin/commit/113ad499d9806a7a237f6afdb9a6bf02ebc238aa))
|
||||||
|
* update environment variables in docker-compose for backend and frontend services ([5e8d7be](https://github.com/whoswhip/Sharpbin/commit/5e8d7be86423247e63a350d440bc52cf3428d312))
|
||||||
|
* update Navbar and layout server to improve structure and data handling ([a912d04](https://github.com/whoswhip/Sharpbin/commit/a912d0463b1e8517f055f596c2cb033b88db6b9b))
|
||||||
|
* update paste view count display in metadata ([f9b63ed](https://github.com/whoswhip/Sharpbin/commit/f9b63edf776e2715b09de2d408aab4ba85ccd50f))
|
||||||
|
* update profile link to direct to user page instead of dashboard ([ff52498](https://github.com/whoswhip/Sharpbin/commit/ff52498cf99a74936d47d73369c7fdd7b771f0df))
|
||||||
|
* update SQLite connection string retrieval in Program.cs ([6178888](https://github.com/whoswhip/Sharpbin/commit/6178888246871f38ab8373bacbb2a61fba6d4046))
|
||||||
|
* update TOTP API request payload to use 'code' instead of 'totpcode' ([6bcc62a](https://github.com/whoswhip/Sharpbin/commit/6bcc62a7e7b77c1129c16d9a8c979e003b6481e5))
|
||||||
|
* update version number to 3.0.0 and remove beta check from footer ([8252d58](https://github.com/whoswhip/Sharpbin/commit/8252d58f47d503a0c40f95bde9ee277341e801b9))
|
||||||
|
* use $app/state ([b44f0bc](https://github.com/whoswhip/Sharpbin/commit/b44f0bce0ab5f7fcedf9c206362a31947215eef9))
|
||||||
|
* use margin-bottom instead of margin-top for elements ([bd7d115](https://github.com/whoswhip/Sharpbin/commit/bd7d1154eaf57e310a82cb43c09baf15c499a489))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* /raw/{id} endpoint ([ca87b1a](https://github.com/whoswhip/Sharpbin/commit/ca87b1a5f220a6f3b8857cf00602abf867c9a7d9))
|
||||||
|
* account deletion; auto incremental uids; display name renaming UI + account deletion UI; enhanced username validation ([fe54ff1](https://github.com/whoswhip/Sharpbin/commit/fe54ff15ce7122373643eece9981eb05a1d7c7d0))
|
||||||
|
* add application version definition to Vite config ([eca6867](https://github.com/whoswhip/Sharpbin/commit/eca6867fcab5c1ba4d1d327c76f18fd21290abd6))
|
||||||
|
* add delete functionality for pastes with authorization check ([3015f97](https://github.com/whoswhip/Sharpbin/commit/3015f97ff977fbfd9b23a11aad016ac7408be752))
|
||||||
|
* add Dockerfile and docker-compose for backend and frontend services ([31142e0](https://github.com/whoswhip/Sharpbin/commit/31142e0cf96d2ff868fadf1ecac192a07ebc5c2d))
|
||||||
|
* add editedAt field to Paste interface and enhance paste editing functionality ([86b74a1](https://github.com/whoswhip/Sharpbin/commit/86b74a140a546651d301079b71531468d0b1d52d))
|
||||||
|
* add Footer component to layout for improved user navigation ([e093550](https://github.com/whoswhip/Sharpbin/commit/e0935505ea01c286cb802337461b1ebbb4eb6f2d))
|
||||||
|
* add health check endpoint returning status ok ([dfdce51](https://github.com/whoswhip/Sharpbin/commit/dfdce51c6e648b601880a16644d7790b41550129))
|
||||||
|
* add health checks for backend and frontend services in docker-compose.yml ([08c4be4](https://github.com/whoswhip/Sharpbin/commit/08c4be4f7eb8e985114d1f87a8bd69a7bad0a9ee))
|
||||||
|
* add health checks for backend and frontend services in docker-compose.yml ([57dad56](https://github.com/whoswhip/Sharpbin/commit/57dad564a6df35ea488fab40fa9798511036d4ac))
|
||||||
|
* add health checks for database connectivity ([cab1b17](https://github.com/whoswhip/Sharpbin/commit/cab1b170c1218c47c5c4f366425731c3fdb5d67a))
|
||||||
|
* add isBinaryData utility function and integrate it into paste handling; add drag and drop functionality when creating a paste ([bf0eac9](https://github.com/whoswhip/Sharpbin/commit/bf0eac9ed8aa00cf4d82236cf8257f87bc6b8588))
|
||||||
|
* add markdown parsing and rendering support ([406381f](https://github.com/whoswhip/Sharpbin/commit/406381fbfe724249b41477f64ef42116882a671d))
|
||||||
|
* add Pagination interface and integrate it into User type ([a9e1e82](https://github.com/whoswhip/Sharpbin/commit/a9e1e823591c01be4dc960bf5427131480dfa413))
|
||||||
|
* add pagination to user retrieval endpoints; enhance BuildUserResponse to include pagination details ([93df14e](https://github.com/whoswhip/Sharpbin/commit/93df14e59ce876c877d34d28a9f0a0cf3d53eb28))
|
||||||
|
* add PasteCleanUpService as a hosted service ([f578b58](https://github.com/whoswhip/Sharpbin/commit/f578b58780930d253837d4e1c795f46c6b27b9df))
|
||||||
|
* add PasteSettings environment variables for internal API key and HMAC secret ([a6fa65c](https://github.com/whoswhip/Sharpbin/commit/a6fa65c3bd67fbb1133737d738626c345304f503))
|
||||||
|
* add recent pastes page with data fetching and display logic ([8a6ab29](https://github.com/whoswhip/Sharpbin/commit/8a6ab29f52ddd6e05c211569323d0d4d48b4938b))
|
||||||
|
* add registration status check and disable form elements when registration is disabled ([b1d2d3f](https://github.com/whoswhip/Sharpbin/commit/b1d2d3f5bba5e7f0bab38448fc25baa8a4551317))
|
||||||
|
* add variant support for dropdown component styling ([1950dc4](https://github.com/whoswhip/Sharpbin/commit/1950dc47ae8c5ca721851999afb2ce32b7c5c4cb))
|
||||||
|
* admins can change user's roles ([99feb27](https://github.com/whoswhip/Sharpbin/commit/99feb2795a17b43724985cbf1722088fde0ac281))
|
||||||
|
* auth, compression, jwt, paste wip, roles, ratelimiting ([6ec1a7f](https://github.com/whoswhip/Sharpbin/commit/6ec1a7fa7b3254e6ab09aaed8943534b79dac9cd))
|
||||||
|
* auto detect syntax from file extension on drag and drop; syntax from extension function ([9e05600](https://github.com/whoswhip/Sharpbin/commit/9e056009e3858d9a56bd71638cd32db3ce122a60))
|
||||||
|
* bypass user confirmation when loading external assets in markdown for trusted domains ([35d891b](https://github.com/whoswhip/Sharpbin/commit/35d891bed7bd7fb2415a14e74f45eb5b7d4e3453))
|
||||||
|
* create Paste component for displaying paste details ([753d28f](https://github.com/whoswhip/Sharpbin/commit/753d28f720c9f7f6a3b7d787ca19a8149d592ee7))
|
||||||
|
* declare application version constant in app.d.ts ([72206e9](https://github.com/whoswhip/Sharpbin/commit/72206e9ba214b602cafd2836d880ac06debb69de))
|
||||||
|
* enable registration toggle and update Navbar to reflect registration status ([159fcc2](https://github.com/whoswhip/Sharpbin/commit/159fcc2a890480cfad0cc19dd153c84aa1af88d0))
|
||||||
|
* enhance AuthService to support admin role assignment for the first user ([c934c85](https://github.com/whoswhip/Sharpbin/commit/c934c85b130d2c0086146110f3211f612387b8d3))
|
||||||
|
* enhance code highlighting for plaintext in syntax highlighter ([5cb30a9](https://github.com/whoswhip/Sharpbin/commit/5cb30a90a760874d54cc18e0adc63cfe6812d1c7))
|
||||||
|
* enhance decryption process with status updates and improved user feedback ([7b3af77](https://github.com/whoswhip/Sharpbin/commit/7b3af774494c31f8fcd829d20f9bb5f46242320a))
|
||||||
|
* enhance paste creation with dynamic textarea resizing and improved password handling; generate random password button in paste creation; show password in paste creation; ([5410a89](https://github.com/whoswhip/Sharpbin/commit/5410a8973a81dc6a854f1c685e3a3546de985486))
|
||||||
|
* enhance tooltip functionality and improve date formatting ([8ab66f5](https://github.com/whoswhip/Sharpbin/commit/8ab66f5f159c1c34d29c456fef9a4c626548c6aa))
|
||||||
|
* enhance tooltip functionality; prevent empty tooltips for paste titles ([7eb0204](https://github.com/whoswhip/Sharpbin/commit/7eb0204e6751df148b6520c6ccd665289e31341b))
|
||||||
|
* enhance user experience with tooltips; implement return URL handling on login and registration; add user roles; improve paste visibility checks ([5fca207](https://github.com/whoswhip/Sharpbin/commit/5fca207ad61acf0dca4c9fd13ab5a598d89ba890))
|
||||||
|
* implement decryptAes function; moved to encryption.ts ([f61f31d](https://github.com/whoswhip/Sharpbin/commit/f61f31de0e9a3c97a347d38783cddb4c0d7f83fe))
|
||||||
|
* implement mobile support for navbar ([63f55d2](https://github.com/whoswhip/Sharpbin/commit/63f55d2bdac475bd7d981d87475fa4e8cddb6b72))
|
||||||
|
* implement modal component for password input and confirmation actions ([b6e020f](https://github.com/whoswhip/Sharpbin/commit/b6e020fa6987b5ecad5ca78d24ce87e41799c177))
|
||||||
|
* implement pagination for user pastes; enhance fetchPage function and update display logic ([49b9673](https://github.com/whoswhip/Sharpbin/commit/49b9673d48d50a5ca2adea9b4c2055ae2c88f001))
|
||||||
|
* implement paste decryption ([3a54951](https://github.com/whoswhip/Sharpbin/commit/3a549511f93d7001d246c318545e6edb307e2f99))
|
||||||
|
* implement rate limiting policy for site info endpoints in Auth and Paste controllers ([3895bd9](https://github.com/whoswhip/Sharpbin/commit/3895bd968136071cc09bba686107f693f7e47dc3))
|
||||||
|
* implement registration page with Turnstile verification and loading state ([24b25c2](https://github.com/whoswhip/Sharpbin/commit/24b25c2291eea16fab16c250b5856b91f7385b74))
|
||||||
|
* implement server-side user data fetching; enhance user controller for detailed responses; update token handling to use cookies ([4151c62](https://github.com/whoswhip/Sharpbin/commit/4151c62b8cd10cdbf6a757f6e82935e8d5426a5a))
|
||||||
|
* implement Turnstile verification for enhanced security during login and registration ([848b859](https://github.com/whoswhip/Sharpbin/commit/848b8598e5fb407f284027875c1f09c396b4aa6f))
|
||||||
|
* implement user update functionality by UUID and add validation to UpdateUserRequest ([f40d4ab](https://github.com/whoswhip/Sharpbin/commit/f40d4ab68c3aabf95b8775601b1534bda9665b4b))
|
||||||
|
* improve file download naming by using syntax extension conditionally ([fed0663](https://github.com/whoswhip/Sharpbin/commit/fed06630b7383eb185b2afbdfd30d2776416bcc5))
|
||||||
|
* improve paste creation validation; add content size check and remove unnecessary logging ([dd6ce5c](https://github.com/whoswhip/Sharpbin/commit/dd6ce5c39506e9e22aeefa4db34ac8caa48a5cdd))
|
||||||
|
* improve recent page; improve SEO for pages ([3a5738b](https://github.com/whoswhip/Sharpbin/commit/3a5738b53173ddae500098ffcbf1769dada11584))
|
||||||
|
* initial commit ([050f0bc](https://github.com/whoswhip/Sharpbin/commit/050f0bc935937b8b80500a59bc6ac5513fd7af93))
|
||||||
|
* integrate hash-wasm for enhanced AES encryption and decryption ([7e1fb3a](https://github.com/whoswhip/Sharpbin/commit/7e1fb3add4f438a206638ea0c90b0a27fd108c53))
|
||||||
|
* login & registration; enhanced paste view; custom dropdown + search; navbar; global user access via store; auto token refresh; paste creation as user; /api/user/me, returns info on yourself including pastes; ([db1d870](https://github.com/whoswhip/Sharpbin/commit/db1d8704a1d0f183812fbd41ad077274c6626801))
|
||||||
|
* paste cleanup service; sveltekit frontend; paste editing; paste metadata modifying ([adad139](https://github.com/whoswhip/Sharpbin/commit/adad139081fb4d9b2ed644e8fe4cdd89ac2ef38d))
|
||||||
|
* paste compression & verification enforcement settings; enforce 2fa on admins setting; increase paste validation; anonymous uploads ([9f55aa1](https://github.com/whoswhip/Sharpbin/commit/9f55aa1b2273ee0298892dba380c71630c743289))
|
||||||
|
* paste creation, utilities, revert to gzip, grammar fixes etc ([93daa2e](https://github.com/whoswhip/Sharpbin/commit/93daa2e1a2b75cc2e93cbc7149b837e79eb9ece4))
|
||||||
|
* paste creation; paste viewing; more langs supported; jwt settings class; paste settings class; data validation on paste metadata modification ([b9b14a3](https://github.com/whoswhip/Sharpbin/commit/b9b14a3d5a553fd1e7e7294c8ba29cd8cb8218dd))
|
||||||
|
* paste views; configuration validation; hmacsha256 method; enhance paste clean up serivce; paste view clean up service; ([3048af3](https://github.com/whoswhip/Sharpbin/commit/3048af3a6dece0338e278bf6d6b2358c0f4952fc))
|
||||||
|
* preview markdown in paste creation; prevent external option in parseMarkdown ([3f27a3a](https://github.com/whoswhip/Sharpbin/commit/3f27a3a3e726e941ad6e996db53f9366506a7012))
|
||||||
|
* refactor drag and drop file handling to update syntax selection conditionally ([ca9fa81](https://github.com/whoswhip/Sharpbin/commit/ca9fa81771af49b20628c148a1ac61ad6a168bf9))
|
||||||
|
* refactor refresh token handling; update schema and logic for improved security and functionality ([ae91108](https://github.com/whoswhip/Sharpbin/commit/ae91108484ff73a6cdee16e0454acc330a221a33))
|
||||||
|
* reporting apis; better rate limiting ([14bbd9c](https://github.com/whoswhip/Sharpbin/commit/14bbd9c762f641ac738714822d19845d86bb6582))
|
||||||
|
* reports; improved+simplifed modals; extractError funcction; ([67447d5](https://github.com/whoswhip/Sharpbin/commit/67447d51aec59af200524e7f33bcee5678adc2bc))
|
||||||
|
* seo optimizations + opengraph embeds ([3bbd646](https://github.com/whoswhip/Sharpbin/commit/3bbd64631a46d510e720db3a3d5cf7ad4298702d))
|
||||||
|
* totp 2fa; httpcontext extension for jwtuser; asp.net data protection; prevent banned users from certain actions; account deletion requires 2fa if enabled; making users admins requires 2fa if enabled; httpcontext extension to get ip; enhance user store ([20ceb91](https://github.com/whoswhip/Sharpbin/commit/20ceb91db8405172d5beb9df646d3d912cea40a5))
|
||||||
|
* update API routes for paste options and recent pastes ([1f2761f](https://github.com/whoswhip/Sharpbin/commit/1f2761f463e160a0d4d865a4d6a5763fc408712b))
|
||||||
|
* update button styles for active state in paste creation ([6981836](https://github.com/whoswhip/Sharpbin/commit/698183690c1b48b6e6ebf83f62025242d746c607))
|
||||||
|
* update favicon and improve tooltip for paste size display ([1ed2178](https://github.com/whoswhip/Sharpbin/commit/1ed21789e656dfdc7a65119f4c5ec010a1669593))
|
||||||
|
* update minimum height for main sections across multiple pages for consistent layout ([c565c57](https://github.com/whoswhip/Sharpbin/commit/c565c57e20cb0eb7d6e57e17182382e2ee931190))
|
||||||
|
* view raw button; paste header follows when scrolling; scroll to top button appears after scrolling far enough ([28a0ccb](https://github.com/whoswhip/Sharpbin/commit/28a0ccbfab4461fd6fe75d25b3f7cffce063041f))
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* Revert "chore: format via csharpier" ([6bea6c4](https://github.com/whoswhip/Sharpbin/commit/6bea6c49bef1eea4dfd72d962b4e06e20b64594f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -34,7 +34,15 @@ docker-compose up -d
|
|||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
You can configure the application using environment variables. When using Docker Compose, these can be set in the `docker-compose.yml` file.
|
You can configure Sharpbin using environment variables or `appsettings.json`. When using Docker Compose, these can be set in the `docker-compose.yml` file.
|
||||||
|
|
||||||
|
> When configuring via `appsettings.json` instead of for example `ConnectionStrings__DefaultConnection` it would be:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"DefaultConnection": "Data Source=sharpbin.db"
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
#### Backend (SharpbinV3.Server)
|
#### Backend (SharpbinV3.Server)
|
||||||
|
|
||||||
@@ -42,16 +50,16 @@ You can configure the application using environment variables. When using Docker
|
|||||||
- `JwtSettings__Secret`: A secure string used for signing JWT tokens.
|
- `JwtSettings__Secret`: A secure string used for signing JWT tokens.
|
||||||
- `AuthSettings__CF_Turnstile_SecretKey`: Your Cloudflare Turnstile secret key.
|
- `AuthSettings__CF_Turnstile_SecretKey`: Your Cloudflare Turnstile secret key.
|
||||||
- `AuthSettings__CF_Turnstile_SiteKey`: Your Cloudflare Turnstile site key.
|
- `AuthSettings__CF_Turnstile_SiteKey`: Your Cloudflare Turnstile site key.
|
||||||
- `AuthSettings__Registration_Enabled`: Set to `true` by default, enables/disables registration.
|
- `AuthSettings__Registration_Enabled`:**true**: Enables/disables registration.
|
||||||
- `AuthSettings__First_User_Admin`: Gives the first user the admin role, it is recommended to disable this after use.
|
- `AuthSettings__First_User_Admin`: Gives the first user the admin role, it is recommended to disable this after use.
|
||||||
- `AuthSettings__Admins_Require_2FA`: Enforces Admins to have 2FA when trying to do certain actions.
|
- `AuthSettings__Admins_Require_2FA`: Enforces Admins to have 2FA when trying to do certain actions.
|
||||||
|
- `AuthSettings__API_Key_HMAC_Secret`: Recommended to securely hash API keys, but is not required.
|
||||||
- `PasteSettings__MaxTitleLength`: Max title length in characters.
|
- `PasteSettings__MaxTitleLength`: Max title length in characters.
|
||||||
- `PasteSettings__MaxPasteSizeInBytes`: Max Paste Size set in bytes, the default is `1_048_576` (1MB)
|
- `PasteSettings__MaxPasteSizeInBytes`:**1_048_576** (1MB): Max Paste Size set in bytes.
|
||||||
- `PasteSettings__EnablePasteCompression`: Enables/Disables server-side paste compression, `true` by default.
|
- `PasteSettings__EnablePasteCompression`:**true**: Enables/Disables server-side paste compression.
|
||||||
- `PasteSettings__RequiresVerification`: Enables/Disables CAPTCHA verification when creating pastes, `true` by default.
|
- `PasteSettings__RequiresVerification`:**true**: Enables/Disables CAPTCHA verification when creating pastes.
|
||||||
- `PasteSettings__View_HMAC_Secret`: Required to securely hash viewer identifiers
|
- `PasteSettings__View_HMAC_Secret`: Required to securely hash viewer identifiers
|
||||||
- `PasteSettings__View_Internal_API_Key`: Enforces views to be counted/recorded only by the frontend, if set it needs to be the same for both backend and frontend.
|
- `PasteSettings__View_Internal_API_Key`: Enforces views to be counted/recorded only by the frontend, if set it needs to be the same for both backend and frontend.
|
||||||
- `ASPNETCORE_ENVIRONMENT`: Set to `Production` or `Development`.
|
|
||||||
|
|
||||||
#### Frontend (SharpbinV3.Client)
|
#### Frontend (SharpbinV3.Client)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ npm install
|
|||||||
|
|
||||||
### Environment Configuration
|
### Environment Configuration
|
||||||
|
|
||||||
The application requires an environment variable to point to the backend API. Create a `.env` file in this directory or set the variable in your environment:
|
The frontend requires an environment variable to point to the backend API. Create a `.env` file in this directory or set the variable in your environment:
|
||||||
|
|
||||||
- `VITE_API_URL`: The URL of the backend API (e.g., `http://localhost:8080`).
|
- `VITE_API_URL`: The URL of the backend API (e.g., `http://localhost:8080`).
|
||||||
- `VITE_ALLOWED_HOSTS`: A comma separated list of allowed hosts (e.g., `localhost,sharpbin.whoswhip.dev`)
|
- `VITE_ALLOWED_HOSTS`: A comma separated list of allowed hosts (e.g., `localhost,sharpbin.whoswhip.dev`)
|
||||||
@@ -33,21 +33,13 @@ Start the development server with Hot Module Replacement (HMR):
|
|||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
The application will be available at http://localhost:5173.
|
The frontend will be available at http://localhost:5173.
|
||||||
|
|
||||||
## Script Reference
|
## Script Reference
|
||||||
|
|
||||||
- `npm run dev`: Start the Vite development server.
|
- `npm run dev`: Start the Vite development server.
|
||||||
- `npm run build`: Create a production build of the application.
|
- `npm run build`: Create a production build of the frontend.
|
||||||
- `npm run preview`: Locally preview the production build.
|
- `npm run preview`: Locally preview the production build.
|
||||||
- `npm run check`: Run type checking with svelte-check.
|
- `npm run check`: Run type checking with svelte-check.
|
||||||
- `npm run lint`: Run ESLint and Prettier checks.
|
- `npm run lint`: Run ESLint and Prettier checks.
|
||||||
- `npm run format`: Format the codebase with Prettier.
|
- `npm run format`: Format the codebase with Prettier.
|
||||||
|
|
||||||
## Tech Stack
|
|
||||||
|
|
||||||
- Svelte 5 with SvelteKit.
|
|
||||||
- Tailwind CSS for styling.
|
|
||||||
- Lucide Svelte for icons.
|
|
||||||
- Highlight.js for syntax highlighting.
|
|
||||||
- TypeScript for type safety.
|
|
||||||
|
|||||||
Generated
+388
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sharpbinv3.client",
|
"name": "sharpbinv3.client",
|
||||||
"version": "3.0.0",
|
"version": "3.0.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sharpbinv3.client",
|
"name": "sharpbinv3.client",
|
||||||
"version": "3.0.0",
|
"version": "3.0.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lucide/svelte": "^0.562.0",
|
"@lucide/svelte": "^0.562.0",
|
||||||
"@sveltejs/adapter-node": "^5.4.0",
|
"@sveltejs/adapter-node": "^5.4.0",
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
"@types/node": "^22",
|
"@types/node": "^22",
|
||||||
"@types/papaparse": "^5.5.2",
|
"@types/papaparse": "^5.5.2",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
|
"conventional-changelog": "^7.1.1",
|
||||||
|
"conventional-changelog-angular": "^8.1.0",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-svelte": "^3.13.1",
|
"eslint-plugin-svelte": "^3.13.1",
|
||||||
@@ -83,6 +85,33 @@
|
|||||||
"integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==",
|
"integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@conventional-changelog/git-client": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@conventional-changelog/git-client/-/git-client-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-lAw7iA5oTPWOLjiweb7DlGEMDEvzqzLLa6aWOly2FSZ64IwLE8T458rC+o+WvI31Doz6joM7X2DoNog7mX8r4A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@simple-libs/child-process-utils": "^1.0.0",
|
||||||
|
"@simple-libs/stream-utils": "^1.1.0",
|
||||||
|
"semver": "^7.5.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"conventional-commits-filter": "^5.0.0",
|
||||||
|
"conventional-commits-parser": "^6.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"conventional-commits-filter": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"conventional-commits-parser": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@csstools/color-helpers": {
|
"node_modules/@csstools/color-helpers": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz",
|
||||||
@@ -1322,6 +1351,39 @@
|
|||||||
"win32"
|
"win32"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@simple-libs/child-process-utils": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@simple-libs/child-process-utils/-/child-process-utils-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-3nWd8irxvDI6v856wpPCHZ+08iQR0oHTZfzAZmnbsLzf+Sf1odraP6uKOHDZToXq3RPRV/LbqGVlSCogm9cJjg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@simple-libs/stream-utils": "^1.1.0",
|
||||||
|
"@types/node": "^22.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://ko-fi.com/dangreen"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@simple-libs/stream-utils": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@simple-libs/stream-utils/-/stream-utils-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-6rsHTjodIn/t90lv5snQjRPVtOosM7Vp0AKdrObymq45ojlgVwnpAqdc+0OBBrpEiy31zZ6/TKeIVqV1HwvnuQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "^22.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://ko-fi.com/dangreen"
|
||||||
|
}
|
||||||
|
},
|
||||||
"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",
|
||||||
@@ -1827,6 +1889,13 @@
|
|||||||
"undici-types": "~6.21.0"
|
"undici-types": "~6.21.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/normalize-package-data": {
|
||||||
|
"version": "2.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz",
|
||||||
|
"integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/papaparse": {
|
"node_modules/@types/papaparse": {
|
||||||
"version": "5.5.2",
|
"version": "5.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.5.2.tgz",
|
||||||
@@ -2218,6 +2287,13 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/array-ify": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/axobject-query": {
|
"node_modules/axobject-query": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
|
||||||
@@ -2350,6 +2426,17 @@
|
|||||||
"integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==",
|
"integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/compare-func": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"array-ify": "^1.0.0",
|
||||||
|
"dot-prop": "^5.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"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",
|
||||||
@@ -2357,6 +2444,97 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/conventional-changelog": {
|
||||||
|
"version": "7.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-7.1.1.tgz",
|
||||||
|
"integrity": "sha512-rlqa8Lgh8YzT3Akruk05DR79j5gN9NCglHtJZwpi6vxVeaoagz+84UAtKQj/sT+RsfGaZkt3cdFCjcN6yjr5sw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@conventional-changelog/git-client": "^2.5.1",
|
||||||
|
"@types/normalize-package-data": "^2.4.4",
|
||||||
|
"conventional-changelog-preset-loader": "^5.0.0",
|
||||||
|
"conventional-changelog-writer": "^8.2.0",
|
||||||
|
"conventional-commits-parser": "^6.2.0",
|
||||||
|
"fd-package-json": "^2.0.0",
|
||||||
|
"meow": "^13.0.0",
|
||||||
|
"normalize-package-data": "^7.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"conventional-changelog": "dist/cli/index.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/conventional-changelog-angular": {
|
||||||
|
"version": "8.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-8.1.0.tgz",
|
||||||
|
"integrity": "sha512-GGf2Nipn1RUCAktxuVauVr1e3r8QrLP/B0lEUsFktmGqc3ddbQkhoJZHJctVU829U1c6mTSWftrVOCHaL85Q3w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"compare-func": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/conventional-changelog-preset-loader": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-SetDSntXLk8Jh1NOAl1Gu5uLiCNSYenB5tm0YVeZKePRIgDW9lQImromTwLa3c/Gae298tsgOM+/CYT9XAl0NA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/conventional-changelog-writer": {
|
||||||
|
"version": "8.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-8.2.0.tgz",
|
||||||
|
"integrity": "sha512-Y2aW4596l9AEvFJRwFGJGiQjt2sBYTjPD18DdvxX9Vpz0Z7HQ+g1Z+6iYDAm1vR3QOJrDBkRHixHK/+FhkR6Pw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"conventional-commits-filter": "^5.0.0",
|
||||||
|
"handlebars": "^4.7.7",
|
||||||
|
"meow": "^13.0.0",
|
||||||
|
"semver": "^7.5.2"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"conventional-changelog-writer": "dist/cli/index.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/conventional-commits-filter": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-tQMagCOC59EVgNZcC5zl7XqO30Wki9i9J3acbUvkaosCT6JX3EeFwJD7Qqp4MCikRnzS18WXV3BLIQ66ytu6+Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/conventional-commits-parser": {
|
||||||
|
"version": "6.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.2.1.tgz",
|
||||||
|
"integrity": "sha512-20pyHgnO40rvfI0NGF/xiEoFMkXDtkF8FwHvk5BokoFoCuTQRI8vrNCNFWUOfuolKJMm1tPCHc8GgYEtr1XRNA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"meow": "^13.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"conventional-commits-parser": "dist/cli/index.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cookie": {
|
"node_modules/cookie": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
||||||
@@ -2523,6 +2701,19 @@
|
|||||||
"@types/trusted-types": "^2.0.7"
|
"@types/trusted-types": "^2.0.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/dot-prop": {
|
||||||
|
"version": "5.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
|
||||||
|
"integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"is-obj": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/emoji-regex": {
|
"node_modules/emoji-regex": {
|
||||||
"version": "8.0.0",
|
"version": "8.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||||
@@ -2855,6 +3046,16 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/fd-package-json": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fd-package-json/-/fd-package-json-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-jKmm9YtsNXN789RS/0mSzOC1NUq9mkVd65vbSSVsKdjGvYXBuE4oWe2QOEoFeRmJg+lPuZxpmrfFclNhoRMneQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"walk-up-path": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fdir": {
|
"node_modules/fdir": {
|
||||||
"version": "6.5.0",
|
"version": "6.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
||||||
@@ -2988,6 +3189,28 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/handlebars": {
|
||||||
|
"version": "4.7.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
|
||||||
|
"integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"minimist": "^1.2.5",
|
||||||
|
"neo-async": "^2.6.2",
|
||||||
|
"source-map": "^0.6.1",
|
||||||
|
"wordwrap": "^1.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"handlebars": "bin/handlebars"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.7"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"uglify-js": "^3.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/has-flag": {
|
"node_modules/has-flag": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
@@ -3025,6 +3248,26 @@
|
|||||||
"node": ">=12.0.0"
|
"node": ">=12.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/hosted-git-info": {
|
||||||
|
"version": "8.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-8.1.0.tgz",
|
||||||
|
"integrity": "sha512-Rw/B2DNQaPBICNXEm8balFz9a6WpZrkCGpcWFpy7nCj+NyhSdqXipmfvtmWt9xGfp0wZnBxB+iVpLmQMYt47Tw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^10.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.17.0 || >=20.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/hosted-git-info/node_modules/lru-cache": {
|
||||||
|
"version": "10.4.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
|
||||||
|
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
"node_modules/html-encoding-sniffer": {
|
"node_modules/html-encoding-sniffer": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz",
|
||||||
@@ -3153,6 +3396,16 @@
|
|||||||
"integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==",
|
"integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/is-obj": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/is-potential-custom-element-name": {
|
"node_modules/is-potential-custom-element-name": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||||
@@ -3623,6 +3876,19 @@
|
|||||||
"integrity": "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==",
|
"integrity": "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==",
|
||||||
"license": "CC0-1.0"
|
"license": "CC0-1.0"
|
||||||
},
|
},
|
||||||
|
"node_modules/meow": {
|
||||||
|
"version": "13.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz",
|
||||||
|
"integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"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",
|
||||||
@@ -3636,6 +3902,16 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/minimist": {
|
||||||
|
"version": "1.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||||
|
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mri": {
|
"node_modules/mri": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
||||||
@@ -3685,6 +3961,28 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/neo-async": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/normalize-package-data": {
|
||||||
|
"version": "7.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-7.0.1.tgz",
|
||||||
|
"integrity": "sha512-linxNAT6M0ebEYZOx2tO6vBEFsVgnPpv+AVjk0wJHfaUIbq31Jm3T6vvZaarnOeWDh8ShnwXuaAyM7WT3RzErA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"hosted-git-info": "^8.0.0",
|
||||||
|
"semver": "^7.3.5",
|
||||||
|
"validate-npm-package-license": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.17.0 || >=20.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"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",
|
||||||
@@ -4325,6 +4623,16 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||||
@@ -4334,6 +4642,42 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/spdx-correct": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"spdx-expression-parse": "^3.0.0",
|
||||||
|
"spdx-license-ids": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/spdx-exceptions": {
|
||||||
|
"version": "2.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz",
|
||||||
|
"integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "CC-BY-3.0"
|
||||||
|
},
|
||||||
|
"node_modules/spdx-expression-parse": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"spdx-exceptions": "^2.1.0",
|
||||||
|
"spdx-license-ids": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/spdx-license-ids": {
|
||||||
|
"version": "3.0.22",
|
||||||
|
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.22.tgz",
|
||||||
|
"integrity": "sha512-4PRT4nh1EImPbt2jASOKHX7PB7I+e4IWNLvkKFDxNhJlfjbYlleYQh285Z/3mPTHSAK/AvdMmw5BNNuYH8ShgQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "CC0-1.0"
|
||||||
|
},
|
||||||
"node_modules/string-width": {
|
"node_modules/string-width": {
|
||||||
"version": "4.2.3",
|
"version": "4.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||||
@@ -4652,6 +4996,20 @@
|
|||||||
"typescript": ">=4.8.4 <6.0.0"
|
"typescript": ">=4.8.4 <6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uglify-js": {
|
||||||
|
"version": "3.19.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
|
||||||
|
"integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"optional": true,
|
||||||
|
"bin": {
|
||||||
|
"uglifyjs": "bin/uglifyjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "6.21.0",
|
"version": "6.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||||
@@ -4676,6 +5034,17 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/validate-npm-package-license": {
|
||||||
|
"version": "3.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
|
||||||
|
"integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"spdx-correct": "^3.0.0",
|
||||||
|
"spdx-expression-parse": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"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",
|
||||||
@@ -4781,6 +5150,16 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/walk-up-path": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-3hu+tD8YzSLGuFYtPRb48vdhKMi0KQV5sn+uWr8+7dMEq/2G/dtLrdDinkLjqq5TIbIBjYJ4Ax/n3YiaW7QM8A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "8.0.1",
|
"version": "8.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz",
|
||||||
@@ -4844,6 +5223,13 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/wordwrap": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/wrap-ansi": {
|
"node_modules/wrap-ansi": {
|
||||||
"version": "6.2.0",
|
"version": "6.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "sharpbinv3.client",
|
"name": "sharpbinv3.client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.0.1",
|
"version": "3.0.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"lint": "prettier --check . && eslint ."
|
"lint": "prettier --check . && eslint .",
|
||||||
|
"change-log": "conventional-changelog -p angular -i ../CHANGELOG.md -s -r 0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.4.0",
|
"@eslint/compat": "^1.4.0",
|
||||||
@@ -24,6 +25,8 @@
|
|||||||
"@types/node": "^22",
|
"@types/node": "^22",
|
||||||
"@types/papaparse": "^5.5.2",
|
"@types/papaparse": "^5.5.2",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
|
"conventional-changelog": "^7.1.1",
|
||||||
|
"conventional-changelog-angular": "^8.1.0",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-svelte": "^3.13.1",
|
"eslint-plugin-svelte": "^3.13.1",
|
||||||
|
|||||||
@@ -95,7 +95,10 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="scrollbar-thin scrollbar-thumb-neutral-600 scrollbar-track-neutral-700" style="overflow-y: auto; max-height: calc({dropdownMaxHeight} - 3rem);">
|
<div
|
||||||
|
class="scrollbar-thin scrollbar-thumb-neutral-600 scrollbar-track-neutral-700"
|
||||||
|
style="overflow-y: auto; max-height: calc({dropdownMaxHeight} - 3rem);"
|
||||||
|
>
|
||||||
{#each filteredOptions as option (option.value)}
|
{#each filteredOptions as option (option.value)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="mb-5 max-h-10 w-full border-t border-neutral-800 pt-5 text-center text-sm text-neutral-500"
|
class="mb-5 max-h-10 w-full border-t border-neutral-800 pt-5 text-center text-sm text-neutral-500"
|
||||||
>
|
>
|
||||||
@@ -10,5 +14,9 @@
|
|||||||
Source Code
|
Source Code
|
||||||
</a>
|
</a>
|
||||||
<span class="mx-1">•</span>
|
<span class="mx-1">•</span>
|
||||||
|
<a href={resolve('/stats')} class="text-neutral-400 underline hover:text-neutral-200"
|
||||||
|
>Statistics</a
|
||||||
|
>
|
||||||
|
<span class="mx-1">•</span>
|
||||||
v{__APP_VERSION__}
|
v{__APP_VERSION__}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
export let error = '';
|
export let error = '';
|
||||||
export let placeholder = '';
|
export let placeholder = '';
|
||||||
export let inputType = 'text';
|
export let inputType = 'text';
|
||||||
|
export let inputMaxLength: number | null = null;
|
||||||
export let items: { label: string; value: unknown }[] = [];
|
export let items: { label: string; value: unknown }[] = [];
|
||||||
export let initialValue: unknown = null;
|
export let initialValue: unknown = null;
|
||||||
export let totpActive: boolean | null = null;
|
export let totpActive: boolean | null = null;
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
let reportType = '';
|
let reportType = '';
|
||||||
let reportInitialized = false;
|
let reportInitialized = false;
|
||||||
let reportLoading = false;
|
let reportLoading = false;
|
||||||
|
let multiselectInitialized = false;
|
||||||
let turnstileEl: HTMLDivElement | null = null;
|
let turnstileEl: HTMLDivElement | null = null;
|
||||||
let turnstileWidgetId: string | null = null;
|
let turnstileWidgetId: string | null = null;
|
||||||
|
|
||||||
@@ -84,6 +86,11 @@
|
|||||||
initializeReport();
|
initializeReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: if (show && mode === 'multiselect' && !multiselectInitialized) {
|
||||||
|
multiselectInitialized = true;
|
||||||
|
inputValue = Array.isArray(initialValue) ? JSON.parse(JSON.stringify(initialValue)) : [];
|
||||||
|
}
|
||||||
|
|
||||||
function resetModal() {
|
function resetModal() {
|
||||||
inputValue =
|
inputValue =
|
||||||
initialValue !== null
|
initialValue !== null
|
||||||
@@ -101,6 +108,7 @@
|
|||||||
reportType = '';
|
reportType = '';
|
||||||
reportInitialized = false;
|
reportInitialized = false;
|
||||||
reportLoading = false;
|
reportLoading = false;
|
||||||
|
multiselectInitialized = false;
|
||||||
if (turnstileWidgetId && typeof window !== 'undefined' && window.turnstile?.remove) {
|
if (turnstileWidgetId && typeof window !== 'undefined' && window.turnstile?.remove) {
|
||||||
window.turnstile.remove(turnstileWidgetId);
|
window.turnstile.remove(turnstileWidgetId);
|
||||||
}
|
}
|
||||||
@@ -394,10 +402,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if show}
|
{#if show}
|
||||||
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/20 backdrop-blur-xs">
|
||||||
<form
|
<form
|
||||||
on:submit|preventDefault={handleSubmit}
|
on:submit|preventDefault={handleSubmit}
|
||||||
class="w-full max-w-md rounded bg-neutral-900 p-6"
|
class="w-full max-w-md rounded border border-neutral-800 bg-neutral-900 p-6"
|
||||||
>
|
>
|
||||||
<h2 class="mb-4 text-xl font-semibold text-white">
|
<h2 class="mb-4 text-xl font-semibold text-white">
|
||||||
{displayTitle}
|
{displayTitle}
|
||||||
@@ -477,7 +485,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<textarea
|
<textarea
|
||||||
bind:value={inputValue}
|
bind:value={inputValue}
|
||||||
maxlength="1000"
|
maxlength={inputMaxLength ?? undefined}
|
||||||
placeholder={placeholder || 'Describe the issue'}
|
placeholder={placeholder || 'Describe the issue'}
|
||||||
class="h-28 w-full resize-none rounded border border-neutral-700 bg-neutral-800 p-2 text-white outline-none"
|
class="h-28 w-full resize-none rounded border border-neutral-700 bg-neutral-800 p-2 text-white outline-none"
|
||||||
></textarea>
|
></textarea>
|
||||||
@@ -489,6 +497,7 @@
|
|||||||
{:else if shouldShowInput}
|
{:else if shouldShowInput}
|
||||||
<input
|
<input
|
||||||
type={inputType}
|
type={inputType}
|
||||||
|
maxlength={inputMaxLength ?? undefined}
|
||||||
bind:value={inputValue}
|
bind:value={inputValue}
|
||||||
class="mb-3 w-full rounded border border-neutral-700 bg-neutral-800 p-2 text-white outline-none"
|
class="mb-3 w-full rounded border border-neutral-700 bg-neutral-800 p-2 text-white outline-none"
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
error={state.error}
|
error={state.error}
|
||||||
placeholder={state.placeholder}
|
placeholder={state.placeholder}
|
||||||
inputType={state.inputType}
|
inputType={state.inputType}
|
||||||
|
inputMaxLength={state.maxInputLength ?? null}
|
||||||
items={state.items}
|
items={state.items}
|
||||||
initialValue={state.initialValue}
|
initialValue={state.initialValue}
|
||||||
totpActive={state.totpActive}
|
totpActive={state.totpActive}
|
||||||
|
|||||||
@@ -132,6 +132,15 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
{#if paste.editedAt}
|
||||||
|
<div
|
||||||
|
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||||
|
use:tooltip={new Date(paste.editedAt).toLocaleString()}
|
||||||
|
>
|
||||||
|
<History class="h-4 w-4" />
|
||||||
|
<span>Edited {dateToRelativeString(new Date(paste.editedAt), true, false, now)}</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{#if paste.expiresAt > 0}
|
{#if paste.expiresAt > 0}
|
||||||
<div
|
<div
|
||||||
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||||
@@ -151,15 +160,6 @@
|
|||||||
<span>{paste.author?.username ?? 'Anonymous'}</span>
|
<span>{paste.author?.username ?? 'Anonymous'}</span>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if paste.editedAt}
|
|
||||||
<div
|
|
||||||
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
|
||||||
use:tooltip={new Date(paste.editedAt).toLocaleString()}
|
|
||||||
>
|
|
||||||
<History class="h-4 w-4" />
|
|
||||||
<span>Edited {dateToRelativeString(new Date(paste.editedAt), true, false, now)}</span>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center gap-2 text-sm text-neutral-400">
|
<div class="flex items-center gap-2 text-sm text-neutral-400">
|
||||||
|
|||||||
+184
-151
@@ -4,157 +4,190 @@ export type Syntax = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const syntaxes: Record<string, Syntax> = {
|
export const syntaxes: Record<string, Syntax> = {
|
||||||
plaintext: { name: 'Plain Text', extension: '' },
|
plaintext: { name: 'Plain Text', extension: 'txt' },
|
||||||
abap: { name: 'ABAP', extension: '.abap' },
|
'1c': { name: '1c', extension: '' },
|
||||||
'actionscript-3': { name: 'ActionScript 3', extension: '.as' },
|
abnf: { name: 'Augmented Backus-Naur Form', extension: 'abnf' },
|
||||||
ada: { name: 'Ada', extension: '.adb' },
|
accesslog: { name: 'Access Log', extension: 'log' },
|
||||||
apache: { name: 'Apache', extension: '.conf' },
|
actionscript: { name: 'ActionScript', extension: 'as' },
|
||||||
apex: { name: 'Apex', extension: '.cls' },
|
ada: { name: 'Ada', extension: 'ada' },
|
||||||
apl: { name: 'APL', extension: '.apl' },
|
angelscript: { name: 'AngelScript', extension: 'angelscript' },
|
||||||
applescript: { name: 'AppleScript', extension: '.applescript' },
|
apache: { name: 'Apache', extension: 'apache' },
|
||||||
ara: { name: 'ARA', extension: '.ara' },
|
applescript: { name: 'AppleScript', extension: 'applescript' },
|
||||||
asm: { name: 'Assembly', extension: '.asm' },
|
arcade: { name: 'Arcade', extension: 'arcade' },
|
||||||
astro: { name: 'Astro', extension: '.astro' },
|
arduino: { name: 'Arduino', extension: 'ino' },
|
||||||
awk: { name: 'AWK', extension: '.awk' },
|
arm: { name: 'ARM Assembly', extension: 's' },
|
||||||
ballerina: { name: 'Ballerina', extension: '.bal' },
|
asciidoc: { name: 'AsciiDoc', extension: 'adoc' },
|
||||||
bat: { name: 'Batch', extension: '.bat' },
|
aspectj: { name: 'AspectJ', extension: 'aj' },
|
||||||
berry: { name: 'Berry', extension: '.be' },
|
autohotkey: { name: 'AutoHotkey', extension: 'ahk' },
|
||||||
bibtex: { name: 'BibTeX', extension: '.bib' },
|
autoit: { name: 'AutoIt', extension: 'au3' },
|
||||||
bicep: { name: 'Bicep', extension: '.bicep' },
|
avrasm: { name: 'AVR Assembly', extension: 's' },
|
||||||
blade: { name: 'Blade', extension: '.blade.php' },
|
awk: { name: 'AWK', extension: 'awk' },
|
||||||
c: { name: 'C', extension: '.c' },
|
bash: { name: 'Bash', extension: 'sh' },
|
||||||
cadence: { name: 'Cadence', extension: '.cdc' },
|
basic: { name: 'BASIC', extension: 'bas' },
|
||||||
clarity: { name: 'Clarity', extension: '.clar' },
|
bnf: { name: 'Backus-Naur Form', extension: 'bnf' },
|
||||||
clojure: { name: 'Clojure', extension: '.clj' },
|
brainfuck: { name: 'Brainfuck', extension: 'bf' },
|
||||||
cmake: { name: 'CMake', extension: '.cmake' },
|
c: { name: 'C', extension: 'c' },
|
||||||
cobol: { name: 'COBOL', extension: '.cob' },
|
cpp: { name: 'C++', extension: 'cpp' },
|
||||||
codeql: { name: 'CodeQL', extension: '.ql' },
|
hpp: { name: 'C++ Header', extension: 'h' },
|
||||||
coffee: { name: 'CoffeeScript', extension: '.coffee' },
|
csharp: { name: 'C#', extension: 'cs' },
|
||||||
cpp: { name: 'C++', extension: '.cpp' },
|
cal: { name: 'C/AL', extension: '' },
|
||||||
crystal: { name: 'Crystal', extension: '.cr' },
|
cos: { name: 'Cache Object Script', extension: '' },
|
||||||
csharp: { name: 'C#', extension: '.cs' },
|
capnproto: { name: "Cap'n Proto", extension: 'capnp' },
|
||||||
css: { name: 'CSS', extension: '.css' },
|
clojure: { name: 'Clojure', extension: 'clj' },
|
||||||
csv: { name: 'CSV', extension: '.csv' },
|
cmake: { name: 'CMake', extension: 'cmake' },
|
||||||
cue: { name: 'CUE', extension: '.cue' },
|
coffeescript: { name: 'CoffeeScript', extension: 'coffee' },
|
||||||
d: { name: 'D', extension: '.d' },
|
coq: { name: 'Coq', extension: 'v' },
|
||||||
dart: { name: 'Dart', extension: '.dart' },
|
crmsh: { name: 'CRMsH', extension: '' },
|
||||||
diff: { name: 'Diff', extension: '.diff' },
|
crystal: { name: 'Crystal', extension: 'cr' },
|
||||||
docker: { name: 'Docker', extension: 'Dockerfile' },
|
csp: { name: 'CSP', extension: 'csp' },
|
||||||
'dream-maker': { name: 'Dream Maker', extension: '.dm' },
|
css: { name: 'CSS', extension: 'css' },
|
||||||
elixir: { name: 'Elixir', extension: '.ex' },
|
d: { name: 'D', extension: 'd' },
|
||||||
elm: { name: 'Elm', extension: '.elm' },
|
dart: { name: 'Dart', extension: 'dart' },
|
||||||
erb: { name: 'ERB', extension: '.erb' },
|
deplhi: { name: 'Delphi', extension: 'pas' },
|
||||||
erlang: { name: 'Erlang', extension: '.erl' },
|
diff: { name: 'Diff', extension: 'diff' },
|
||||||
fish: { name: 'Fish', extension: '.fish' },
|
django: { name: 'Django', extension: 'django' },
|
||||||
fsharp: { name: 'F#', extension: '.fs' },
|
dns: { name: 'DNS Zone', extension: 'dns' },
|
||||||
gdresource: { name: 'Godot Resource', extension: '.tres' },
|
dockerfile: { name: 'Dockerfile', extension: 'dockerfile' },
|
||||||
gdscript: { name: 'GDScript', extension: '.gd' },
|
dos: { name: 'DOS', extension: 'bat' },
|
||||||
gdshader: { name: 'Godot Shader', extension: '.gdshader' },
|
bat: { name: 'Batchfile', extension: 'bat' },
|
||||||
gherkin: { name: 'Gherkin', extension: '.feature' },
|
dsconfig: { name: 'DSConfig', extension: '' },
|
||||||
'git-commit': { name: 'Git Commit', extension: '' },
|
dts: { name: 'Device Tree', extension: 'dts' },
|
||||||
'git-rebase': { name: 'Git Rebase', extension: '' },
|
dust: { name: 'Dust', extension: 'dust' },
|
||||||
glsl: { name: 'GLSL', extension: '.glsl' },
|
ebnf: { name: 'Extended Backus-Naur Form', extension: 'ebnf' },
|
||||||
gnuplot: { name: 'Gnuplot', extension: '.gp' },
|
elixir: { name: 'Elixir', extension: 'ex' },
|
||||||
go: { name: 'Go', extension: '.go' },
|
elm: { name: 'Elm', extension: 'elm' },
|
||||||
graphql: { name: 'GraphQL', extension: '.graphql' },
|
erlang: { name: 'Erlang', extension: 'erl' },
|
||||||
groovy: { name: 'Groovy', extension: '.groovy' },
|
excel: { name: 'Excel', extension: 'xlsx' },
|
||||||
hack: { name: 'Hack', extension: '.hack' },
|
fsharp: { name: 'F#', extension: 'fs' },
|
||||||
haml: { name: 'Haml', extension: '.haml' },
|
fix: { name: 'FIX', extension: 'fix' },
|
||||||
handlebars: { name: 'Handlebars', extension: '.hbs' },
|
flix: { name: 'Flix', extension: 'flix' },
|
||||||
haskell: { name: 'Haskell', extension: '.hs' },
|
fortran: { name: 'Fortran', extension: 'f90' },
|
||||||
hcl: { name: 'HCL', extension: '.hcl' },
|
gcode: { name: 'G-code', extension: 'gcode' },
|
||||||
hjson: { name: 'HJSON', extension: '.hjson' },
|
gams: { name: 'GAMS', extension: 'gms' },
|
||||||
hlsl: { name: 'HLSL', extension: '.hlsl' },
|
gauss: { name: 'GAUSS', extension: 'gss' },
|
||||||
html: { name: 'HTML', extension: '.html' },
|
gherkin: { name: 'Gherkin', extension: '' },
|
||||||
ini: { name: 'INI', extension: '.ini' },
|
go: { name: 'Go', extension: 'go' },
|
||||||
java: { name: 'Java', extension: '.java' },
|
golo: { name: 'Golo', extension: 'golo' },
|
||||||
javascript: { name: 'JavaScript', extension: '.js' },
|
gradle: { name: 'Gradle', extension: 'gradle' },
|
||||||
jison: { name: 'Jison', extension: '.jison' },
|
graphql: { name: 'GraphQL', extension: 'graphql' },
|
||||||
json: { name: 'JSON', extension: '.json' },
|
groovy: { name: 'Groovy', extension: 'groovy' },
|
||||||
json5: { name: 'JSON5', extension: '.json5' },
|
haml: { name: 'HAML', extension: 'haml' },
|
||||||
jsonc: { name: 'JSONC', extension: '.json' },
|
handlebars: { name: 'Handlebars', extension: 'hbs' },
|
||||||
jsonnet: { name: 'Jsonnet', extension: '.jsonnet' },
|
haskell: { name: 'Haskell', extension: 'hs' },
|
||||||
jssm: { name: 'JSSM', extension: '.jssm' },
|
haxe: { name: 'Haxe', extension: 'hx' },
|
||||||
jsx: { name: 'JSX', extension: '.jsx' },
|
html: { name: 'HTML', extension: 'html' },
|
||||||
julia: { name: 'Julia', extension: '.jl' },
|
xml: { name: 'XML', extension: 'xml' },
|
||||||
kotlin: { name: 'Kotlin', extension: '.kt' },
|
rss: { name: 'RSS', extension: 'rss' },
|
||||||
latex: { name: 'LaTeX', extension: '.tex' },
|
atom: { name: 'Atom', extension: 'atom' },
|
||||||
less: { name: 'Less', extension: '.less' },
|
svg: { name: 'SVG', extension: 'svg' },
|
||||||
liquid: { name: 'Liquid', extension: '.liquid' },
|
http: { name: 'HTTP', extension: 'http' },
|
||||||
lisp: { name: 'Lisp', extension: '.lisp' },
|
https: { name: 'HTTPS', extension: 'http' },
|
||||||
logo: { name: 'Logo', extension: '.logo' },
|
hy: { name: 'Hy', extension: 'hy' },
|
||||||
lua: { name: 'Lua', extension: '.lua' },
|
inform7: { name: 'Inform 7', extension: 'ni' },
|
||||||
makefile: { name: 'Makefile', extension: '.makefile' },
|
ini: { name: 'INI', extension: 'ini' },
|
||||||
markdown: { name: 'Markdown', extension: '.md' },
|
toml: { name: 'TOML', extension: 'toml' },
|
||||||
marko: { name: 'Marko', extension: '.marko' },
|
irpf90: { name: 'IRPF90', extension: 'irpf90' },
|
||||||
matlab: { name: 'MATLAB', extension: '.m' },
|
java: { name: 'Java', extension: 'java' },
|
||||||
mdx: { name: 'MDX', extension: '.mdx' },
|
javascript: { name: 'JavaScript', extension: 'js' },
|
||||||
nginx: { name: 'Nginx', extension: '.conf' },
|
jolie: { name: 'Jolie', extension: 'ol' },
|
||||||
nim: { name: 'Nim', extension: '.nim' },
|
json: { name: 'JSON', extension: 'json' },
|
||||||
nix: { name: 'Nix', extension: '.nix' },
|
json5: { name: 'JSON5', extension: 'json5' },
|
||||||
'objective-c': { name: 'Objective-C', extension: '.m' },
|
julia: { name: 'Julia', extension: 'jl' },
|
||||||
'objective-cpp': { name: 'Objective-C++', extension: '.mm' },
|
'julia-repl': { name: 'Julia REPL', extension: '' },
|
||||||
ocaml: { name: 'OCaml', extension: '.ml' },
|
kotlin: { name: 'Kotlin', extension: 'kt' },
|
||||||
pascal: { name: 'Pascal', extension: '.pas' },
|
lasso: { name: 'Lasso', extension: 'lasso' },
|
||||||
perl: { name: 'Perl', extension: '.pl' },
|
latex: { name: 'LaTeX', extension: 'tex' },
|
||||||
php: { name: 'PHP', extension: '.php' },
|
ldif: { name: 'LDIF', extension: 'ldif' },
|
||||||
plsql: { name: 'PL/SQL', extension: '.sql' },
|
leaf: { name: 'Leaf', extension: 'leaf' },
|
||||||
postcss: { name: 'PostCSS', extension: '.pcss' },
|
less: { name: 'Less', extension: 'less' },
|
||||||
powerquery: { name: 'Power Query', extension: '.pq' },
|
lisp: { name: 'Lisp', extension: 'lisp' },
|
||||||
powershell: { name: 'PowerShell', extension: '.ps1' },
|
livecodeserver: { name: 'LiveCode Server', extension: '' },
|
||||||
prisma: { name: 'Prisma', extension: '.prisma' },
|
livescript: { name: 'LiveScript', extension: 'ls' },
|
||||||
prolog: { name: 'Prolog', extension: '.pl' },
|
lua: { name: 'Lua', extension: 'lua' },
|
||||||
proto: { name: 'Protocol Buffers', extension: '.proto' },
|
makefile: { name: 'Makefile', extension: 'makefile' },
|
||||||
pug: { name: 'Pug', extension: '.pug' },
|
markdown: { name: 'Markdown', extension: 'md' },
|
||||||
puppet: { name: 'Puppet', extension: '.pp' },
|
mathematica: { name: 'Mathematica', extension: 'nb' },
|
||||||
purescript: { name: 'PureScript', extension: '.purs' },
|
matlab: { name: 'MATLAB', extension: 'm' },
|
||||||
python: { name: 'Python', extension: '.py' },
|
maxima: { name: 'Maxima', extension: 'max' },
|
||||||
r: { name: 'R', extension: '.r' },
|
mel: { name: 'Maya Embedded Language', extension: 'mel' },
|
||||||
raku: { name: 'Raku', extension: '.raku' },
|
mercury: { name: 'Mercury', extension: 'm' },
|
||||||
razor: { name: 'Razor', extension: '.cshtml' },
|
mipsasm: { name: 'MIPS Assembly', extension: 's' },
|
||||||
reg: { name: 'Registry', extension: '.reg' },
|
mizar: { name: 'Mizar', extension: 'miz' },
|
||||||
rel: { name: 'Rel', extension: '.rel' },
|
mojolicious: { name: 'Mojolicious', extension: '' },
|
||||||
riscv: { name: 'RISC-V', extension: '.s' },
|
monkey: { name: 'Monkey', extension: 'monkey' },
|
||||||
rst: { name: 'reStructuredText', extension: '.rst' },
|
moonscript: { name: 'MoonScript', extension: 'moon' },
|
||||||
ruby: { name: 'Ruby', extension: '.rb' },
|
n1ql: { name: 'N1QL', extension: '' },
|
||||||
rust: { name: 'Rust', extension: '.rs' },
|
nginx: { name: 'Nginx', extension: 'nginx' },
|
||||||
sas: { name: 'SAS', extension: '.sas' },
|
nim: { name: 'Nim', extension: 'nim' },
|
||||||
sass: { name: 'Sass', extension: '.sass' },
|
nix: { name: 'Nix', extension: 'nix' },
|
||||||
scala: { name: 'Scala', extension: '.scala' },
|
nsis: { name: 'NSIS', extension: 'nsi' },
|
||||||
scheme: { name: 'Scheme', extension: '.scm' },
|
objectivec: { name: 'Objective-C', extension: 'm' },
|
||||||
scss: { name: 'SCSS', extension: '.scss' },
|
ocaml: { name: 'OCaml', extension: 'ml' },
|
||||||
shaderlab: { name: 'ShaderLab', extension: '.shader' },
|
glsl: { name: 'OpenGL Shading Language', extension: 'glsl' },
|
||||||
shell: { name: 'Shell', extension: '.sh' },
|
openscad: { name: 'OpenSCAD', extension: 'scad' },
|
||||||
smalltalk: { name: 'Smalltalk', extension: '.st' },
|
ruleslanguage: { name: 'Oracle Rules Language', extension: '' },
|
||||||
solidity: { name: 'Solidity', extension: '.sol' },
|
oxygene: { name: 'Oxygene', extension: 'oxygene' },
|
||||||
sparql: { name: 'SPARQL', extension: '.rq' },
|
parser3: { name: 'Parser3', extension: '' },
|
||||||
sql: { name: 'SQL', extension: '.sql' },
|
perl: { name: 'Perl', extension: 'pl' },
|
||||||
'ssh-config': { name: 'SSH Config', extension: '' },
|
pf: { name: 'PF', extension: 'pf' },
|
||||||
stata: { name: 'Stata', extension: '.do' },
|
php: { name: 'PHP', extension: 'php' },
|
||||||
stylus: { name: 'Stylus', extension: '.styl' },
|
pony: { name: 'Pony', extension: 'pony' },
|
||||||
svelte: { name: 'Svelte', extension: '.svelte' },
|
postgresql: { name: 'PostgreSQL', extension: 'sql' },
|
||||||
swift: { name: 'Swift', extension: '.swift' },
|
powershell: { name: 'PowerShell', extension: 'ps1' },
|
||||||
'system-verilog': { name: 'SystemVerilog', extension: '.sv' },
|
processing: { name: 'Processing', extension: 'pde' },
|
||||||
tasl: { name: 'TASL', extension: '.tasl' },
|
prolog: { name: 'Prolog', extension: 'pl' },
|
||||||
tcl: { name: 'Tcl', extension: '.tcl' },
|
properties: { name: 'Java Properties', extension: 'properties' },
|
||||||
tex: { name: 'TeX', extension: '.tex' },
|
protobuf: { name: 'Protocol Buffers', extension: 'proto' },
|
||||||
toml: { name: 'TOML', extension: '.toml' },
|
puppet: { name: 'Puppet', extension: 'pp' },
|
||||||
tsx: { name: 'TSX', extension: '.tsx' },
|
python: { name: 'Python', extension: 'py' },
|
||||||
turtle: { name: 'Turtle', extension: '.ttl' },
|
profiler: { name: 'Poython Profiler Results', extension: '' },
|
||||||
twig: { name: 'Twig', extension: '.twig' },
|
'python-repl': { name: 'Python REPL', extension: '' },
|
||||||
typescript: { name: 'TypeScript', extension: '.ts' },
|
q: { name: 'Q', extension: 'q' },
|
||||||
v: { name: 'V', extension: '.v' },
|
qml: { name: 'QML', extension: 'qml' },
|
||||||
vb: { name: 'VB', extension: '.vb' },
|
r: { name: 'R', extension: 'r' },
|
||||||
verilog: { name: 'Verilog', extension: '.v' },
|
reasonml: { name: 'ReasonML', extension: 're' },
|
||||||
vhdl: { name: 'VHDL', extension: '.vhdl' },
|
rib: { name: 'RenderMan Interface Bytestream', extension: 'rib' },
|
||||||
viml: { name: 'VimL', extension: '.vim' },
|
rsl: { name: 'RenderMan Shading Language', extension: 'rsl' },
|
||||||
vue: { name: 'Vue', extension: '.vue' },
|
graph: { name: 'Roboconf', extension: '' },
|
||||||
wasm: { name: 'WebAssembly', extension: '.wasm' },
|
ruby: { name: 'Ruby', extension: 'rb' },
|
||||||
wenyan: { name: 'Wenyan', extension: '.wy' },
|
rust: { name: 'Rust', extension: 'rs' },
|
||||||
xml: { name: 'XML', extension: '.xml' },
|
sas: { name: 'SAS', extension: 'sas' },
|
||||||
xsl: { name: 'XSL', extension: '.xsl' },
|
scala: { name: 'Scala', extension: 'scala' },
|
||||||
yaml: { name: 'YAML', extension: '.yaml' },
|
scheme: { name: 'Scheme', extension: 'scm' },
|
||||||
zenscript: { name: 'ZenScript', extension: '.zs' }
|
scilab: { name: 'Scilab', extension: 'sci' },
|
||||||
|
scss: { name: 'SCSS', extension: 'scss' },
|
||||||
|
shell: { name: 'Shell', extension: 'sh' },
|
||||||
|
smali: { name: 'Smali', extension: 'smali' },
|
||||||
|
smalltalk: { name: 'Smalltalk', extension: 'st' },
|
||||||
|
sml: { name: 'Standard ML', extension: 'sml' },
|
||||||
|
sql: { name: 'SQL', extension: 'sql' },
|
||||||
|
stan: { name: 'Stan', extension: 'stan' },
|
||||||
|
stata: { name: 'Stata', extension: 'do' },
|
||||||
|
step21: { name: 'STEP Part 21', extension: 'stp' },
|
||||||
|
stylus: { name: 'Stylus', extension: 'styl' },
|
||||||
|
subunit: { name: 'SubUnit', extension: 'subunit' },
|
||||||
|
svelte: { name: 'Svelte', extension: 'svelte' }, // svelte seems to work even though the docs say it requires a plugin
|
||||||
|
swift: { name: 'Swift', extension: 'swift' },
|
||||||
|
tcl: { name: 'Tcl', extension: 'tcl' },
|
||||||
|
tap: { name: 'Test Anything Protocol', extension: 'tap' },
|
||||||
|
thrift: { name: 'Thrift', extension: 'thrift' },
|
||||||
|
toit: { name: 'Toit', extension: 'toit' },
|
||||||
|
tp: { name: 'TP', extension: 'tp' },
|
||||||
|
twig: { name: 'Twig', extension: 'twig' },
|
||||||
|
typescript: { name: 'TypeScript', extension: 'ts' },
|
||||||
|
vala: { name: 'Vala', extension: 'vala' },
|
||||||
|
vbnet: { name: 'VB.NET', extension: 'vb' },
|
||||||
|
vba: { name: 'VBA', extension: 'vba' },
|
||||||
|
vbscript: { name: 'VBScript', extension: 'vbs' },
|
||||||
|
verilog: { name: 'Verilog', extension: 'v' },
|
||||||
|
vhdl: { name: 'VHDL', extension: 'vhd' },
|
||||||
|
vim: { name: 'Vim Script', extension: 'vim' },
|
||||||
|
axapta: { name: 'X++', extension: 'xpp' },
|
||||||
|
x86asm: { name: 'x86 Assembly', extension: 's' },
|
||||||
|
xl: { name: 'XL', extension: 'xl' },
|
||||||
|
xquery: { name: 'XQuery', extension: 'xq' },
|
||||||
|
yaml: { name: 'YAML', extension: 'yaml' },
|
||||||
|
zephir: { name: 'Zephir', extension: 'zep' }
|
||||||
};
|
};
|
||||||
|
|
||||||
export const expiresOptions = [
|
export const expiresOptions = [
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ type ModalState = {
|
|||||||
error: string;
|
error: string;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
inputType: string;
|
inputType: string;
|
||||||
|
maxInputLength?: number;
|
||||||
items: ModalItem[];
|
items: ModalItem[];
|
||||||
initialValue: unknown;
|
initialValue: unknown;
|
||||||
totpActive: boolean | null;
|
totpActive: boolean | null;
|
||||||
@@ -42,6 +43,7 @@ const initialState: ModalState = {
|
|||||||
error: '',
|
error: '',
|
||||||
placeholder: '',
|
placeholder: '',
|
||||||
inputType: 'text',
|
inputType: 'text',
|
||||||
|
maxInputLength: undefined,
|
||||||
items: [],
|
items: [],
|
||||||
initialValue: null,
|
initialValue: null,
|
||||||
totpActive: null,
|
totpActive: null,
|
||||||
|
|||||||
@@ -24,15 +24,8 @@ export interface ReportListResponse {
|
|||||||
pagination: Pagination;
|
pagination: Pagination;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const reportTypeLabels = [
|
export const reportTypeLabels = ['CopyrightViolation', 'IllegalContent', 'Fraud', 'Other'] as const;
|
||||||
'Spam',
|
|
||||||
'Abuse',
|
|
||||||
'InappropriateContent',
|
|
||||||
'CopyrightViolation',
|
|
||||||
'Fraud',
|
|
||||||
'Other'
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const reportStatusLabels = ['Open', 'InProgress', 'Resolved', 'Closed'] as const;
|
export const reportStatusLabels = ['Open', 'Closed'] as const;
|
||||||
|
|
||||||
export const reportTargetLabels = ['Paste', 'User'] as const;
|
export const reportTargetLabels = ['Paste', 'User'] as const;
|
||||||
|
|||||||
@@ -113,8 +113,9 @@ export function dateToRelativeString(
|
|||||||
return `${parts.join(', ')} ${suffix}`.trim();
|
return `${parts.join(', ')} ${suffix}`.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tooltip(node: HTMLElement, text: string) {
|
export function tooltip(node: HTMLElement, params: string | [string, boolean?]) {
|
||||||
let currentText = text ?? '';
|
let currentText = typeof params === 'string' ? params : (params[0] ?? '');
|
||||||
|
let darker = typeof params === 'string' ? false : (params[1] ?? false);
|
||||||
let tooltipEl: HTMLDivElement | null = null;
|
let tooltipEl: HTMLDivElement | null = null;
|
||||||
let caretEl: HTMLDivElement | null = null;
|
let caretEl: HTMLDivElement | null = null;
|
||||||
let showTimeout: ReturnType<typeof setTimeout>;
|
let showTimeout: ReturnType<typeof setTimeout>;
|
||||||
@@ -123,8 +124,9 @@ export function tooltip(node: HTMLElement, text: string) {
|
|||||||
function createTooltip() {
|
function createTooltip() {
|
||||||
if (!currentText || currentText.trim() === '') return;
|
if (!currentText || currentText.trim() === '') return;
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
el.className =
|
el.className = `fixed z-50 rounded ${
|
||||||
'fixed z-50 rounded bg-neutral-800 px-2 py-1 text-sm text-white shadow-lg opacity-0 transition-opacity duration-150';
|
darker ? 'bg-neutral-900 border border-neutral-800' : 'bg-neutral-800'
|
||||||
|
} px-2 py-1 text-sm text-white shadow-lg opacity-0 transition-opacity duration-150`;
|
||||||
el.style.maxWidth = '90%';
|
el.style.maxWidth = '90%';
|
||||||
el.style.wordBreak = 'break-word';
|
el.style.wordBreak = 'break-word';
|
||||||
|
|
||||||
@@ -219,10 +221,10 @@ export function tooltip(node: HTMLElement, text: string) {
|
|||||||
caretEl.style.borderLeft = '7px solid transparent';
|
caretEl.style.borderLeft = '7px solid transparent';
|
||||||
caretEl.style.borderRight = '7px solid transparent';
|
caretEl.style.borderRight = '7px solid transparent';
|
||||||
if (caretOnTop) {
|
if (caretOnTop) {
|
||||||
caretEl.style.borderBottom = '7px solid #27272a';
|
caretEl.style.borderBottom = `7px solid ${darker ? '#171717' : '#27272a'}`;
|
||||||
caretEl.style.borderTop = '';
|
caretEl.style.borderTop = '';
|
||||||
} else {
|
} else {
|
||||||
caretEl.style.borderTop = '7px solid #27272a';
|
caretEl.style.borderTop = `7px solid ${darker ? '#171717' : '#27272a'}`;
|
||||||
caretEl.style.borderBottom = '';
|
caretEl.style.borderBottom = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,8 +262,10 @@ export function tooltip(node: HTMLElement, text: string) {
|
|||||||
window.addEventListener('resize', mouseOut, true);
|
window.addEventListener('resize', mouseOut, true);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
update(newText: string) {
|
update(newParams: string | [string, boolean?]) {
|
||||||
currentText = newText ?? '';
|
currentText = typeof newParams === 'string' ? newParams : (newParams[0] ?? '');
|
||||||
|
darker = typeof newParams === 'string' ? false : (newParams[1] ?? false);
|
||||||
|
|
||||||
if (!currentText || currentText.trim() === '') {
|
if (!currentText || currentText.trim() === '') {
|
||||||
if (tooltipEl) {
|
if (tooltipEl) {
|
||||||
tooltipEl.remove();
|
tooltipEl.remove();
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import hljs from 'highlight.js';
|
||||||
|
|
||||||
|
type HighlightRequest = {
|
||||||
|
id: number;
|
||||||
|
code: string;
|
||||||
|
lang: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type HighlightResponse = {
|
||||||
|
id: number;
|
||||||
|
html: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const escapeHtml = (value: string) =>
|
||||||
|
value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
|
||||||
|
self.onmessage = (event: MessageEvent<HighlightRequest>) => {
|
||||||
|
const { id, code, lang } = event.data;
|
||||||
|
let html = '';
|
||||||
|
try {
|
||||||
|
if (lang === 'plaintext') {
|
||||||
|
html = escapeHtml(code);
|
||||||
|
} else if (lang && hljs.getLanguage && hljs.getLanguage(lang)) {
|
||||||
|
html = hljs.highlight(code, { language: lang, ignoreIllegals: true }).value;
|
||||||
|
} else {
|
||||||
|
html = hljs.highlightAuto(code).value;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
if (lang === 'plaintext') {
|
||||||
|
html = escapeHtml(code);
|
||||||
|
} else {
|
||||||
|
html = hljs.highlightAuto(code).value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const response: HighlightResponse = { id, html };
|
||||||
|
self.postMessage(response);
|
||||||
|
};
|
||||||
@@ -58,7 +58,6 @@
|
|||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<Navbar {data} />
|
<Navbar {data} />
|
||||||
<!-- <div class="h-15 w-full"></div> -->
|
|
||||||
<slot />
|
<slot />
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|
||||||
|
|||||||
@@ -65,17 +65,9 @@
|
|||||||
let max: number;
|
let max: number;
|
||||||
let element = markdown ? markdownConatiner : textArea;
|
let element = markdown ? markdownConatiner : textArea;
|
||||||
|
|
||||||
if (!markdown) {
|
element.style.height = 'auto';
|
||||||
textArea.style.height = 'auto';
|
h = element.scrollHeight;
|
||||||
|
max = MAX_HEIGHT();
|
||||||
h = textArea.scrollHeight;
|
|
||||||
max = MAX_HEIGHT();
|
|
||||||
} else {
|
|
||||||
markdownConatiner.style.height = 'auto';
|
|
||||||
|
|
||||||
h = markdownConatiner.scrollHeight;
|
|
||||||
max = MAX_HEIGHT();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (h > max) {
|
if (h > max) {
|
||||||
element.style.height = max + 'px';
|
element.style.height = max + 'px';
|
||||||
@@ -140,9 +132,9 @@
|
|||||||
data.auth?.cf_turnstile_site_key &&
|
data.auth?.cf_turnstile_site_key &&
|
||||||
window.turnstile
|
window.turnstile
|
||||||
) {
|
) {
|
||||||
const token = window.turnstile.getResponse();
|
const verificationToken = window.turnstile.getResponse();
|
||||||
if (token) {
|
if (verificationToken) {
|
||||||
params.append('token', token);
|
params.append('verificationToken', verificationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +232,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Title (optional)"
|
placeholder="Title (optional)"
|
||||||
class="mb-4 w-full rounded border border-neutral-700 bg-neutral-800 p-2"
|
class="mb-2 w-full rounded border border-neutral-700 bg-neutral-800 p-2"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
bind:value={title}
|
bind:value={title}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
import Dropdown from '$lib/components/Dropdown.svelte';
|
import Dropdown from '$lib/components/Dropdown.svelte';
|
||||||
import { openModal } from '$lib/stores/modal';
|
import { openModal } from '$lib/stores/modal';
|
||||||
import type { Paste } from '$lib/types/paste';
|
import type { Paste } from '$lib/types/paste';
|
||||||
|
import HighlightWorker from '$lib/workers/highlight.worker?worker';
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
let reportSiteKey: string | null = null;
|
let reportSiteKey: string | null = null;
|
||||||
@@ -59,6 +60,8 @@
|
|||||||
let contentRendered = false;
|
let contentRendered = false;
|
||||||
let downloadedPaste = false;
|
let downloadedPaste = false;
|
||||||
let copiedPaste = false;
|
let copiedPaste = false;
|
||||||
|
let highlightWorker: Worker | null = null;
|
||||||
|
let highlightRequestId = 0;
|
||||||
|
|
||||||
let scrollY = 0;
|
let scrollY = 0;
|
||||||
|
|
||||||
@@ -90,10 +93,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
highlightWorker = new HighlightWorker();
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
now = new Date();
|
now = new Date();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
return () => {
|
return () => {
|
||||||
|
if (highlightWorker) highlightWorker.terminate();
|
||||||
if (interval) clearInterval(interval);
|
if (interval) clearInterval(interval);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -113,51 +118,71 @@
|
|||||||
return html.replace(code, numbered);
|
return html.replace(code, numbered);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function renderCode(content: string | null = null) {
|
async function renderPaste(content: string | null = null) {
|
||||||
if (!data?.paste) return;
|
if (!data?.paste) return;
|
||||||
let code = content ?? decryptedContent ?? data.content ?? '';
|
|
||||||
|
|
||||||
const encoder = new TextEncoder();
|
let contentToRender = content ?? decryptedContent ?? data.content ?? '';
|
||||||
const buffer = encoder.encode(code).buffer;
|
|
||||||
isBinary = isBinaryData(buffer);
|
isBinary = isBinaryData(new TextEncoder().encode(contentToRender).buffer);
|
||||||
if (isBinary) {
|
if (isBinary) {
|
||||||
contentRendered = true;
|
contentRendered = true;
|
||||||
decryptStatus = '';
|
decryptStatus = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (data.paste.syntax) {
|
||||||
|
case 'markdown':
|
||||||
|
pasteContent = await parseMarkdown(contentToRender);
|
||||||
|
contentRendered = true;
|
||||||
|
decryptStatus = '';
|
||||||
|
break;
|
||||||
|
case 'csv':
|
||||||
|
await renderCsv(contentToRender);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
await renderCode(contentToRender);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function renderCode(content: string | null = null) {
|
||||||
|
if (!data?.paste) return;
|
||||||
|
let code = content ?? decryptedContent ?? data.content ?? '';
|
||||||
|
|
||||||
const lang = (data.paste.syntax ?? '').toLowerCase();
|
const lang = (data.paste.syntax ?? '').toLowerCase();
|
||||||
|
|
||||||
if (lang === 'markdown') {
|
|
||||||
pasteContent = await parseMarkdown(code);
|
|
||||||
contentRendered = true;
|
|
||||||
decryptStatus = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lang === 'csv') {
|
|
||||||
await renderCsv(code);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let highlighted = '';
|
let highlighted = '';
|
||||||
try {
|
const worker = highlightWorker;
|
||||||
if (lang === 'plaintext') {
|
if (worker) {
|
||||||
const escapeHtml = (s: string) =>
|
const requestId = ++highlightRequestId;
|
||||||
s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
highlighted = await new Promise((resolve) => {
|
||||||
highlighted = escapeHtml(code);
|
const handler = (event: MessageEvent<{ id: number; html: string }>) => {
|
||||||
} else if (lang && hljs.getLanguage && hljs.getLanguage(lang)) {
|
if (event.data.id !== requestId) return;
|
||||||
highlighted = hljs.highlight(code, { language: lang, ignoreIllegals: true }).value;
|
worker.removeEventListener('message', handler);
|
||||||
} else {
|
resolve(event.data.html);
|
||||||
highlighted = hljs.highlightAuto(code).value;
|
};
|
||||||
}
|
worker.addEventListener('message', handler);
|
||||||
} catch {
|
worker.postMessage({ id: requestId, code, lang });
|
||||||
if (lang === 'plaintext') {
|
});
|
||||||
const escapeHtml = (s: string) =>
|
} else {
|
||||||
s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
try {
|
||||||
highlighted = escapeHtml(code);
|
if (lang === 'plaintext') {
|
||||||
} else {
|
const escapeHtml = (s: string) =>
|
||||||
highlighted = hljs.highlightAuto(code).value;
|
s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
highlighted = escapeHtml(code);
|
||||||
|
} else if (lang && hljs.getLanguage && hljs.getLanguage(lang)) {
|
||||||
|
highlighted = hljs.highlight(code, { language: lang, ignoreIllegals: true }).value;
|
||||||
|
} else {
|
||||||
|
highlighted = hljs.highlightAuto(code).value;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
if (lang === 'plaintext') {
|
||||||
|
const escapeHtml = (s: string) =>
|
||||||
|
s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
highlighted = escapeHtml(code);
|
||||||
|
} else {
|
||||||
|
highlighted = hljs.highlightAuto(code).value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const wrapped = `<pre><code class="hljs">${highlighted}</code></pre>`;
|
const wrapped = `<pre><code class="hljs">${highlighted}</code></pre>`;
|
||||||
@@ -260,7 +285,7 @@
|
|||||||
}
|
}
|
||||||
data.content = rawContent;
|
data.content = rawContent;
|
||||||
decryptedContent = rawContent;
|
decryptedContent = rawContent;
|
||||||
await renderCode(rawContent);
|
await renderPaste(rawContent);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(metadata?.syntax !== data.paste.syntax ||
|
(metadata?.syntax !== data.paste.syntax ||
|
||||||
@@ -415,14 +440,14 @@
|
|||||||
decryptError = 'Incorrect password. Please try again.';
|
decryptError = 'Incorrect password. Please try again.';
|
||||||
decryptStatus = 'Decryption failed.';
|
decryptStatus = 'Decryption failed.';
|
||||||
} else {
|
} else {
|
||||||
await renderCode();
|
await renderPaste();
|
||||||
history.replaceState(null, '', window.location.pathname + window.location.search);
|
history.replaceState(null, '', window.location.pathname + window.location.search);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
decryptStatus = 'Decryption canceled.';
|
decryptStatus = 'Decryption canceled.';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await renderCode();
|
await renderPaste();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -435,22 +460,22 @@
|
|||||||
decryptError = 'Incorrect password. Please try again.';
|
decryptError = 'Incorrect password. Please try again.';
|
||||||
decryptStatus = 'Decryption failed.';
|
decryptStatus = 'Decryption failed.';
|
||||||
} else {
|
} else {
|
||||||
await renderCode();
|
await renderPaste();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
decryptStatus = 'Decryption canceled.';
|
decryptStatus = 'Decryption canceled.';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
decryptStatus = 'Rendering content...';
|
decryptStatus = 'Rendering content...';
|
||||||
await renderCode();
|
await renderPaste();
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
decryptStatus = 'Rendering content...';
|
decryptStatus = 'Rendering content...';
|
||||||
await renderCode();
|
await renderPaste();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$: if (data?.paste && (data.paste.visibility !== 2 || decryptedContent !== null)) renderCode();
|
$: if (data?.paste && (data.paste.visibility !== 2 || decryptedContent !== null)) renderPaste();
|
||||||
$: reportSiteKey =
|
$: reportSiteKey =
|
||||||
(data as unknown as { authOptions?: { cf_turnstile_site_key?: string | null } }).authOptions
|
(data as unknown as { authOptions?: { cf_turnstile_site_key?: string | null } }).authOptions
|
||||||
?.cf_turnstile_site_key ?? null;
|
?.cf_turnstile_site_key ?? null;
|
||||||
@@ -905,6 +930,7 @@
|
|||||||
on:click={handleMarkdownClick}
|
on:click={handleMarkdownClick}
|
||||||
role="presentation"
|
role="presentation"
|
||||||
>
|
>
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
{@html pasteContent}
|
{@html pasteContent}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
let passwordFocused = false;
|
let passwordFocused = false;
|
||||||
let showPassword = false;
|
let showPassword = false;
|
||||||
1;
|
|
||||||
let passwordChecks = {
|
let passwordChecks = {
|
||||||
minLength: false,
|
minLength: false,
|
||||||
maxLength: false,
|
maxLength: false,
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import type { PageServerLoad } from './$types';
|
||||||
|
import { env } from '$env/dynamic/private';
|
||||||
|
import { error, isHttpError } from '@sveltejs/kit';
|
||||||
|
import { extractError } from '$lib/utils/misc';
|
||||||
|
|
||||||
|
const API_URL = env.VITE_API_URL ?? 'http://localhost:5050';
|
||||||
|
|
||||||
|
export const load: PageServerLoad = async ({ fetch }) => {
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_URL}/api/stats`);
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
const json = await res.json().catch(() => ({}));
|
||||||
|
const message = extractError(json);
|
||||||
|
throw error(res.status, message ?? 'Failed to load statistics');
|
||||||
|
}
|
||||||
|
const stats = await res.json();
|
||||||
|
return { stats };
|
||||||
|
} catch (e) {
|
||||||
|
if (isHttpError(e)) throw e;
|
||||||
|
throw error(500, 'Failed to load statistics');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
import { formatBytes, formatNumber, tooltip } from '$lib/utils/misc';
|
||||||
|
import { FileText, Users, Database, TrendingUp } from '@lucide/svelte';
|
||||||
|
|
||||||
|
export let data: PageData;
|
||||||
|
$: stats = data.stats.stats;
|
||||||
|
|
||||||
|
$: dailyData = stats.pastes.daily || [];
|
||||||
|
$: maxCount = Math.max(...dailyData.map((d: { count: number; date: number }) => d.count), 5);
|
||||||
|
|
||||||
|
function getOrdinal(n: number) {
|
||||||
|
const s = ['th', 'st', 'nd', 'rd'];
|
||||||
|
const v = n % 100;
|
||||||
|
return s[(v - 20) % 10] || s[v] || s[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(timestamp: number) {
|
||||||
|
const date = new Date(timestamp);
|
||||||
|
const day = date.getDate();
|
||||||
|
const options: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric' };
|
||||||
|
const locale = typeof navigator !== 'undefined' ? navigator.language : 'en-US';
|
||||||
|
|
||||||
|
if (!locale.startsWith('en')) {
|
||||||
|
return date.toLocaleDateString(locale, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
const month = date.toLocaleString(locale, { month: 'short' });
|
||||||
|
const suffix = getOrdinal(day);
|
||||||
|
|
||||||
|
const parts = new Intl.DateTimeFormat(locale, { month: 'short', day: 'numeric' }).formatToParts(
|
||||||
|
date
|
||||||
|
);
|
||||||
|
if (parts[0].type === 'day') {
|
||||||
|
return `${day}${suffix} ${month}`;
|
||||||
|
}
|
||||||
|
return `${month} ${day}${suffix}`;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>Statistics - Sharpbin</title>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
|
<main
|
||||||
|
class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
|
||||||
|
>
|
||||||
|
<div class="w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-6">
|
||||||
|
<h1 class="mb-6 text-center text-4xl font-bold">Statistics</h1>
|
||||||
|
<div class="mb-8 grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||||
|
<div class="flex items-center space-x-4 rounded-lg bg-neutral-800 p-4">
|
||||||
|
<div class="rounded-full bg-neutral-500/20 p-3 text-white">
|
||||||
|
<FileText size={24} />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-sm text-neutral-400">Total Pastes</p>
|
||||||
|
<p class="text-2xl font-bold">{formatNumber(stats.pastes.total)}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-4 rounded-lg bg-neutral-800 p-4">
|
||||||
|
<div class="rounded-full bg-neutral-500/20 p-3 text-white">
|
||||||
|
<TrendingUp size={24} />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-sm text-neutral-400">Last 7 Days</p>
|
||||||
|
<p class="text-2xl font-bold">{formatNumber(stats.pastes.past7Days)}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-4 rounded-lg bg-neutral-800 p-4">
|
||||||
|
<div class="rounded-full bg-neutral-500/20 p-3 text-white">
|
||||||
|
<Database size={24} />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-sm text-neutral-400">Total Storage Used</p>
|
||||||
|
<p
|
||||||
|
class="text-2xl font-bold"
|
||||||
|
use:tooltip={[
|
||||||
|
`${stats.pastes.trueTotalSizeInBytes != stats.pastes.totalSizeInBytes ? `Uncompressed Size: ${formatBytes(stats.pastes.trueTotalSizeInBytes)}` : ''}`,
|
||||||
|
true
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{formatBytes(stats.pastes.totalSizeInBytes)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-4 rounded-lg bg-neutral-800 p-4">
|
||||||
|
<div class="rounded-full bg-neutral-500/20 p-3 text-white">
|
||||||
|
<Users size={24} />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-sm text-neutral-400">Total Users</p>
|
||||||
|
<p class="text-2xl font-bold">{formatNumber(stats.users.total)}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rounded-lg bg-neutral-800 p-6">
|
||||||
|
<h2 class="mb-6 text-xl font-semibold">Pastes Growth (Last 7 Days)</h2>
|
||||||
|
<div class="flex h-64 w-full items-end justify-between gap-2 px-2">
|
||||||
|
{#if dailyData.length > 0}
|
||||||
|
{#each dailyData as d (d.date)}
|
||||||
|
<div class="group relative flex h-full flex-1 flex-col justify-end">
|
||||||
|
<div
|
||||||
|
use:tooltip={[`${formatNumber(d.count)} paste${d.count !== 1 ? 's' : ''}`, true]}
|
||||||
|
class="w-full rounded-t-sm bg-neutral-600 transition-all hover:bg-neutral-500"
|
||||||
|
style="height: {d.count === 0 ? '2px' : Math.max((d.count / maxCount) * 95, 2)}%"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="absolute top-full mt-2 w-full text-center text-[10px] text-neutral-400 sm:text-xs"
|
||||||
|
>
|
||||||
|
{formatDate(d.date)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
{:else}
|
||||||
|
<div class="flex h-full w-full items-center justify-center text-neutral-500">
|
||||||
|
No data available for the last 7 days.
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="h-6"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,8 @@ export default defineConfig({
|
|||||||
server: {
|
server: {
|
||||||
host: true,
|
host: true,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': apiUrl
|
'/api': apiUrl,
|
||||||
|
'/openapi': apiUrl
|
||||||
},
|
},
|
||||||
allowedHosts: allowedHosts
|
allowedHosts: allowedHosts
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Migrations/
|
||||||
|
obj/
|
||||||
|
bin/
|
||||||
|
cache/
|
||||||
|
SharpbinV3/
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 150,
|
||||||
|
"useTabs": false,
|
||||||
|
"indentSize": 4,
|
||||||
|
"endOfLine": "auto"
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using SharpbinV3.Server.Extensions;
|
||||||
|
using SharpbinV3.Server.Services;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Authentication
|
||||||
|
{
|
||||||
|
public sealed class ApiKeyAuthenticationHandler(
|
||||||
|
IOptionsMonitor<AuthenticationSchemeOptions> options,
|
||||||
|
ILoggerFactory logger,
|
||||||
|
UrlEncoder encoder,
|
||||||
|
ApiKeyService apiKeyService
|
||||||
|
) : AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder)
|
||||||
|
{
|
||||||
|
private readonly ApiKeyService _apiKeyService = apiKeyService;
|
||||||
|
|
||||||
|
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||||
|
{
|
||||||
|
var apiKeyString = Context.GetApiKey();
|
||||||
|
if (string.IsNullOrEmpty(apiKeyString))
|
||||||
|
return AuthenticateResult.NoResult();
|
||||||
|
|
||||||
|
var apiKey = await _apiKeyService.GetByKeyAsync(apiKeyString);
|
||||||
|
if (apiKey == null || apiKey.User == null)
|
||||||
|
return AuthenticateResult.Fail("Invalid API key.");
|
||||||
|
|
||||||
|
var claims = new List<Claim>
|
||||||
|
{
|
||||||
|
new("uuid", apiKey.User.UUID.ToString()),
|
||||||
|
new("username", apiKey.User.Username ?? ""),
|
||||||
|
new("displayname", apiKey.User.DisplayName ?? ""),
|
||||||
|
new("totp_enabled", (apiKey.User.Totp != null).ToString()),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (apiKey.User.Roles != null)
|
||||||
|
claims.AddRange(apiKey.User.Roles.Select(r => new Claim(ClaimTypes.Role, r.ToString())));
|
||||||
|
|
||||||
|
var identity = new ClaimsIdentity(claims, AuthSchemes.ApiKey);
|
||||||
|
var principal = new ClaimsPrincipal(identity);
|
||||||
|
var ticket = new AuthenticationTicket(principal, AuthSchemes.ApiKey);
|
||||||
|
|
||||||
|
Context.SetApiKeyContext(apiKey);
|
||||||
|
await _apiKeyService.UpdateLastUsedAsync(apiKey.UUID);
|
||||||
|
|
||||||
|
return AuthenticateResult.Success(ticket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace SharpbinV3.Server.Authentication
|
||||||
|
{
|
||||||
|
public static class AuthSchemes
|
||||||
|
{
|
||||||
|
public const string Combined = "Combined";
|
||||||
|
public const string ApiKey = "ApiKey";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using System.Security.Claims;
|
||||||
using System.Security.Claims;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using SharpbinV3.Server.Extensions;
|
||||||
|
|
||||||
namespace SharpbinV3.Server.Authorization
|
namespace SharpbinV3.Server.Authorization
|
||||||
{
|
{
|
||||||
@@ -7,18 +8,27 @@ namespace SharpbinV3.Server.Authorization
|
|||||||
{
|
{
|
||||||
private readonly bool _requireAuth = requireAuth;
|
private readonly bool _requireAuth = requireAuth;
|
||||||
|
|
||||||
protected override Task HandleRequirementAsync(
|
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, NotBannedRequirement requirement)
|
||||||
AuthorizationHandlerContext context,
|
|
||||||
NotBannedRequirement requirement)
|
|
||||||
{
|
{
|
||||||
|
var httpContext = context.Resource as HttpContext;
|
||||||
var isAuthenticated = context.User.Identity?.IsAuthenticated ?? false;
|
var isAuthenticated = context.User.Identity?.IsAuthenticated ?? false;
|
||||||
|
|
||||||
|
if (!isAuthenticated && httpContext != null)
|
||||||
|
{
|
||||||
|
var apiKey = httpContext.GetApiKeyFromContext();
|
||||||
|
if (apiKey != null)
|
||||||
|
{
|
||||||
|
isAuthenticated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_requireAuth && !isAuthenticated)
|
if (_requireAuth && !isAuthenticated)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var isBanned = context.User.Claims.Any(c =>
|
var isBanned = context.User.Claims.Any(c => (c.Type == ClaimTypes.Role || c.Type == "role") && c.Value == "403");
|
||||||
(c.Type == ClaimTypes.Role || c.Type == "role") &&
|
|
||||||
c.Value == "403");
|
if (httpContext?.GetApiKeyFromContext()?.User?.Roles?.Contains(403) == true)
|
||||||
|
isBanned = true;
|
||||||
|
|
||||||
if (!isBanned)
|
if (!isBanned)
|
||||||
context.Succeed(requirement);
|
context.Succeed(requirement);
|
||||||
|
|||||||
@@ -2,7 +2,5 @@
|
|||||||
|
|
||||||
namespace SharpbinV3.Server.Authorization
|
namespace SharpbinV3.Server.Authorization
|
||||||
{
|
{
|
||||||
public class NotBannedRequirement : IAuthorizationRequirement
|
public class NotBannedRequirement : IAuthorizationRequirement { }
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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.DTOs;
|
using SharpbinV3.Server.DTOs;
|
||||||
|
using SharpbinV3.Server.DTOs.ApiKey;
|
||||||
using SharpbinV3.Server.DTOs.Auth;
|
using SharpbinV3.Server.DTOs.Auth;
|
||||||
using SharpbinV3.Server.DTOs.User;
|
using SharpbinV3.Server.DTOs.User;
|
||||||
using SharpbinV3.Server.Extensions;
|
using SharpbinV3.Server.Extensions;
|
||||||
@@ -19,11 +20,19 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class AuthController(UserService userService, AuthService authService, IOptions<AuthSettings> options,
|
public class AuthController(
|
||||||
VerificationService verification, TotpVerificationProvider totp, AppDbContext db) : ControllerBase
|
UserService userService,
|
||||||
|
AuthService authService,
|
||||||
|
ApiKeyService apiKeyService,
|
||||||
|
IOptions<AuthSettings> options,
|
||||||
|
VerificationService verification,
|
||||||
|
TotpVerificationProvider totp,
|
||||||
|
AppDbContext db
|
||||||
|
) : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly AuthService _authService = authService;
|
private readonly AuthService _authService = authService;
|
||||||
private readonly UserService _userService = userService;
|
private readonly UserService _userService = userService;
|
||||||
|
private readonly ApiKeyService _apiKeyService = apiKeyService;
|
||||||
private readonly VerificationService _verification = verification;
|
private readonly VerificationService _verification = verification;
|
||||||
private readonly TotpVerificationProvider _totp = totp;
|
private readonly TotpVerificationProvider _totp = totp;
|
||||||
private readonly AppDbContext _db = db;
|
private readonly AppDbContext _db = db;
|
||||||
@@ -37,11 +46,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
return BadRequest(new { success = false, message = "Registration is disabled." });
|
return BadRequest(new { success = false, message = "Registration is disabled." });
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
if (!await _verification.VerifyAsync(new VerificationContext
|
if (!await _verification.VerifyAsync(new VerificationContext { Token = request.Token, Ip = HttpContext.GetRequestIP() }))
|
||||||
{
|
|
||||||
Token = request.Token,
|
|
||||||
Ip = HttpContext.GetRequestIP()
|
|
||||||
}))
|
|
||||||
return BadRequest(new { success = false, message = "Verification failed." });
|
return BadRequest(new { success = false, message = "Verification failed." });
|
||||||
|
|
||||||
var existingUser = await _userService.GetByUsername(request.Username);
|
var existingUser = await _userService.GetByUsername(request.Username);
|
||||||
@@ -57,21 +62,22 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
return BadRequest(new { success = false, message = "Display name should not exceed 26 characters." });
|
return BadRequest(new { success = false, message = "Display name should not exceed 26 characters." });
|
||||||
|
|
||||||
var user = await _authService.CreateUser(request.Username, request.Password, request.Email, request.DisplayName);
|
var user = await _authService.CreateUser(request.Username, request.Password, request.Email, request.DisplayName);
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
message = "User registered successfully.",
|
|
||||||
user = new UserResponseDto
|
|
||||||
{
|
{
|
||||||
UID = user.UID,
|
message = "User registered successfully.",
|
||||||
UUID = user.UUID,
|
user = new UserResponseDto
|
||||||
Username = user.Username,
|
{
|
||||||
DisplayName = user.DisplayName,
|
UID = user.UID,
|
||||||
Email = user.Email,
|
UUID = user.UUID,
|
||||||
Roles = user.Roles,
|
Username = user.Username,
|
||||||
Visibility = user.Visibility,
|
DisplayName = user.DisplayName,
|
||||||
LastLogin = user.LastLogin
|
Email = user.Email,
|
||||||
|
Roles = user.Roles,
|
||||||
|
Visibility = user.Visibility,
|
||||||
|
LastLogin = user.LastLogin,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,11 +89,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (string.IsNullOrEmpty(request.Username) && string.IsNullOrEmpty(request.Email))
|
if (string.IsNullOrEmpty(request.Username) && string.IsNullOrEmpty(request.Email))
|
||||||
return BadRequest(new { success = false, message = "Username or email is required." });
|
return BadRequest(new { success = false, message = "Username or email is required." });
|
||||||
|
|
||||||
if (!await _verification.VerifyAsync(new VerificationContext
|
if (!await _verification.VerifyAsync(new VerificationContext { Token = request.Token, Ip = HttpContext.GetRequestIP() }))
|
||||||
{
|
|
||||||
Token = request.Token,
|
|
||||||
Ip = HttpContext.GetRequestIP()
|
|
||||||
}))
|
|
||||||
return BadRequest(new { success = false, message = "Verification failed." });
|
return BadRequest(new { success = false, message = "Verification failed." });
|
||||||
|
|
||||||
User? user = null;
|
User? user = null;
|
||||||
@@ -104,24 +106,25 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(request.TotpCode))
|
if (string.IsNullOrWhiteSpace(request.TotpCode))
|
||||||
return BadRequest(new { success = false, message = "TOTP code is required." });
|
return BadRequest(new { success = false, message = "TOTP code is required." });
|
||||||
var totpValid = await _totp.VerifyAsync(new VerificationContext
|
|
||||||
{
|
var totpValid = await _totp.VerifyAsync(new VerificationContext { UserUUID = user.UUID, Code = request.TotpCode });
|
||||||
UserUUID = user.UUID,
|
|
||||||
Code = request.TotpCode
|
|
||||||
});
|
|
||||||
if (!totpValid)
|
if (!totpValid)
|
||||||
return BadRequest(new { success = false, message = "Invalid TOTP code." });
|
return BadRequest(new { success = false, message = "Invalid TOTP code." });
|
||||||
}
|
}
|
||||||
var token = _authService.GenerateJWTToken(user);
|
var token = _authService.GenerateJWTToken(user);
|
||||||
await _authService.UpdateLoginTime(user);
|
await _authService.UpdateLoginTime(user);
|
||||||
var result = await token;
|
var result = await token;
|
||||||
return Ok(new LoginResponseDto
|
return Ok(
|
||||||
{
|
new LoginResponseDto
|
||||||
Success = true,
|
{
|
||||||
Token = result.Token ?? string.Empty,
|
Success = true,
|
||||||
RefreshToken = result.RefreshToken ?? string.Empty
|
Token = result.Token ?? string.Empty,
|
||||||
});
|
RefreshToken = result.RefreshToken ?? string.Empty,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("refresh")]
|
[Route("refresh")]
|
||||||
[EnableRateLimiting("Sliding")]
|
[EnableRateLimiting("Sliding")]
|
||||||
@@ -130,16 +133,17 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var jwtResult = await _authService.RefreshJWTToken(request.Token, request.RefreshToken);
|
var jwtResult = await _authService.RefreshJWTToken(request.Token, request.RefreshToken);
|
||||||
return Ok(new TokenRefreshResponseDto
|
return Ok(
|
||||||
{
|
new TokenRefreshResponseDto
|
||||||
Success = jwtResult?.Success ?? false,
|
|
||||||
Message = jwtResult?.Errors != null && jwtResult.Errors.Count > 0 ? string.Join("; ", jwtResult.Errors) : "Token refreshed successfully.",
|
|
||||||
Token = jwtResult != null ? new TokenData
|
|
||||||
{
|
{
|
||||||
Token = jwtResult.Token,
|
Success = jwtResult?.Success ?? false,
|
||||||
RefreshToken = jwtResult.RefreshToken
|
Message =
|
||||||
} : null
|
jwtResult?.Errors != null && jwtResult.Errors.Count > 0
|
||||||
});
|
? string.Join("; ", jwtResult.Errors)
|
||||||
|
: "Token refreshed successfully.",
|
||||||
|
Token = jwtResult != null ? new TokenData { Token = jwtResult.Token, RefreshToken = jwtResult.RefreshToken } : null,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -153,39 +157,45 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
public IActionResult GetSiteInfo()
|
public IActionResult GetSiteInfo()
|
||||||
{
|
{
|
||||||
var authSettings = options.Value;
|
var authSettings = options.Value;
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
cf_turnstile_site_key = string.IsNullOrEmpty(authSettings.CF_Turnstile_SiteKey) ? null : authSettings.CF_Turnstile_SiteKey,
|
{
|
||||||
registration_enabled = authSettings.Registration_Enabled
|
cf_turnstile_site_key = string.IsNullOrEmpty(authSettings.CF_Turnstile_SiteKey) ? null : authSettings.CF_Turnstile_SiteKey,
|
||||||
});
|
registration_enabled = authSettings.Registration_Enabled,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize]
|
[Authorize(Policy = "JwtOnly")]
|
||||||
[Route("totp/enroll")]
|
[Route("totp/enroll")]
|
||||||
public async Task<IActionResult> StartTotpEnrollment()
|
public async Task<IActionResult> StartTotpEnrollment()
|
||||||
{
|
{
|
||||||
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
||||||
if (user is null) return BadRequest(new { success = false, message = "User not found." });
|
if (user is null)
|
||||||
|
return BadRequest(new { success = false, message = "User not found." });
|
||||||
|
|
||||||
var secret = _totp.GenerateSecret();
|
var secret = _totp.GenerateSecret();
|
||||||
var secretBase32 = _totp.ToBase32(secret);
|
var secretBase32 = _totp.ToBase32(secret);
|
||||||
var account = string.IsNullOrWhiteSpace(user.Email) ? user.Username : user.Email!;
|
var account = string.IsNullOrWhiteSpace(user.Email) ? user.Username : user.Email!;
|
||||||
var uri = _totp.BuildOtpAuthUri("SharpbinV3", account, secretBase32);
|
var uri = _totp.BuildOtpAuthUri("SharpbinV3", account, secretBase32);
|
||||||
return Ok(new { success = true, secret = secretBase32, otpauth = uri });
|
return Ok(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
secret = secretBase32,
|
||||||
|
otpauth = uri,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize(Policy = "JwtOnly")]
|
||||||
[Route("totp/enable")]
|
[Route("totp/enable")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
public async Task<IActionResult> EnableTotp([FromBody] EnableTotpDto request)
|
public async Task<IActionResult> EnableTotp([FromBody] EnableTotpDto request)
|
||||||
{
|
{
|
||||||
var uuidClaim = User.Claims.FirstOrDefault(c => c.Type == "UUID")?.Value;
|
var uuid = Guid.Parse(User.FindFirst("uuid")!.Value);
|
||||||
if (string.IsNullOrEmpty(uuidClaim))
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var uuid = Guid.Parse(uuidClaim);
|
|
||||||
if (string.IsNullOrWhiteSpace(request.Secret) || string.IsNullOrWhiteSpace(request.Code))
|
if (string.IsNullOrWhiteSpace(request.Secret) || string.IsNullOrWhiteSpace(request.Code))
|
||||||
return BadRequest(new { success = false, message = "Secret and code are required." });
|
return BadRequest(new { success = false, message = "Secret and code are required." });
|
||||||
|
|
||||||
@@ -210,27 +220,107 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize(Policy = "JwtOnly")]
|
||||||
[Route("totp/disable")]
|
[Route("totp/disable")]
|
||||||
public async Task<IActionResult> DisableTotp([FromBody] DisableTotpDto dto)
|
public async Task<IActionResult> DisableTotp([FromBody] DisableTotpDto dto)
|
||||||
{
|
{
|
||||||
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
||||||
if (user == null) return BadRequest(new { success = false, message = "User not found." });
|
if (user == null)
|
||||||
|
return BadRequest(new { success = false, message = "User not found." });
|
||||||
if (string.IsNullOrWhiteSpace(dto.Code))
|
if (string.IsNullOrWhiteSpace(dto.Code))
|
||||||
return BadRequest(new { success = false, message = "TOTP code is required." });
|
return BadRequest(new { success = false, message = "TOTP code is required." });
|
||||||
var existing = await _db.UserTotps.FirstOrDefaultAsync(t => t.UserUUID == user.UUID);
|
var existing = await _db.UserTotps.FirstOrDefaultAsync(t => t.UserUUID == user.UUID);
|
||||||
if (existing is null)
|
if (existing is null)
|
||||||
return BadRequest(new { success = false, message = "TOTP is not enabled." });
|
return BadRequest(new { success = false, message = "TOTP is not enabled." });
|
||||||
if (!_totp.VerifyAsync(new VerificationContext
|
if (!_totp.VerifyAsync(new VerificationContext { UserUUID = user.UUID, Code = dto.Code }).Result)
|
||||||
{
|
|
||||||
UserUUID = user.UUID,
|
|
||||||
Code = dto.Code
|
|
||||||
}).Result)
|
|
||||||
return BadRequest(new { success = false, message = "Invalid TOTP code." });
|
return BadRequest(new { success = false, message = "Invalid TOTP code." });
|
||||||
|
|
||||||
_db.UserTotps.Remove(existing);
|
_db.UserTotps.Remove(existing);
|
||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
return Ok(new { success = true, message = "TOTP disabled." });
|
return Ok(new { success = true, message = "TOTP disabled." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Authorize(Policy = "JwtOnly")]
|
||||||
|
[Route("apikey/create")]
|
||||||
|
[EnableRateLimiting("Strict")]
|
||||||
|
public async Task<IActionResult> CreateApiKey([FromBody] CreateApiKeyRequest request)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(request.Name))
|
||||||
|
return BadRequest(new { success = false, message = "API key name is required." });
|
||||||
|
if (request.Name.Length > 26)
|
||||||
|
return BadRequest(new { success = false, message = "API key name must not exceed 26 characters." });
|
||||||
|
|
||||||
|
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
||||||
|
if (user == null)
|
||||||
|
return BadRequest(new { success = false, message = "User not found." });
|
||||||
|
|
||||||
|
var existingKeys = await _apiKeyService.GetUserKeysAsync(user.UUID);
|
||||||
|
if (existingKeys.Count >= 10)
|
||||||
|
return BadRequest(new { success = false, message = "API key limit reached. Please delete existing keys before creating new ones." });
|
||||||
|
|
||||||
|
var (apiKey, key) = await _apiKeyService.CreateAsync(user.UUID, request.Name);
|
||||||
|
|
||||||
|
return Ok(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
message = "API key created. Save it now as you won't be able to see it again.",
|
||||||
|
apiKey = new ApiKeyResponseDto
|
||||||
|
{
|
||||||
|
UUID = apiKey.UUID,
|
||||||
|
Key = key,
|
||||||
|
Name = apiKey.Name,
|
||||||
|
CreatedAt = apiKey.CreatedAt,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize]
|
||||||
|
[Route("apikey/list")]
|
||||||
|
public async Task<IActionResult> ListApiKeys()
|
||||||
|
{
|
||||||
|
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
||||||
|
if (user == null)
|
||||||
|
return BadRequest(new { success = false, message = "User not found." });
|
||||||
|
|
||||||
|
var apiKeys = await _apiKeyService.GetUserKeysAsync(user.UUID);
|
||||||
|
return Ok(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
apiKeys = apiKeys
|
||||||
|
.Select(k => new ApiKeyListItemDto
|
||||||
|
{
|
||||||
|
UUID = k.UUID,
|
||||||
|
Name = k.Name,
|
||||||
|
CreatedAt = k.CreatedAt,
|
||||||
|
LastUsedAt = k.LastUsedAt,
|
||||||
|
})
|
||||||
|
.ToList(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
[Authorize(Policy = "JwtOnly")]
|
||||||
|
[Route("apikey/{uuid}")]
|
||||||
|
public async Task<IActionResult> DeleteApiKey(string uuid)
|
||||||
|
{
|
||||||
|
if (!Guid.TryParse(uuid, out var keyUUID))
|
||||||
|
return BadRequest(new { success = false, message = "Invalid API key UUID." });
|
||||||
|
|
||||||
|
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
||||||
|
if (user == null)
|
||||||
|
return BadRequest(new { success = false, message = "User not found." });
|
||||||
|
|
||||||
|
var deleted = await _apiKeyService.DeleteAsync(user.UUID, keyUUID);
|
||||||
|
if (!deleted)
|
||||||
|
return NotFound(new { success = false, message = "API key not found." });
|
||||||
|
|
||||||
|
return Ok(new { success = true, message = "API key deleted." });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,14 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
{
|
{
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class PasteController(PasteService pasteService, VerificationService verificationService, AuthService authService,
|
public class PasteController(
|
||||||
ReportService reportService, IOptions<PasteSettings> options, IOptions<AuthSettings> authSettings) : ControllerBase
|
PasteService pasteService,
|
||||||
|
VerificationService verificationService,
|
||||||
|
AuthService authService,
|
||||||
|
ReportService reportService,
|
||||||
|
IOptions<PasteSettings> options,
|
||||||
|
IOptions<AuthSettings> authSettings
|
||||||
|
) : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly PasteService _pasteService = pasteService;
|
private readonly PasteService _pasteService = pasteService;
|
||||||
private readonly VerificationService _verificationService = verificationService;
|
private readonly VerificationService _verificationService = verificationService;
|
||||||
@@ -29,41 +35,58 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
[Route("create")]
|
[Route("create")]
|
||||||
[Authorize(Policy = "NotBanned")]
|
[Authorize(Policy = "NotBanned")]
|
||||||
[EnableRateLimiting("Strict")]
|
[EnableRateLimiting("Strict")]
|
||||||
public async Task<IActionResult> CreatePaste(string title = "", string syntax = "plaintext", int visibility = 0, long expiresAt = 0, string? token = null)
|
public async Task<IActionResult> CreatePaste(
|
||||||
|
string title = "",
|
||||||
|
string syntax = "plaintext",
|
||||||
|
int visibility = 0,
|
||||||
|
long expiresAt = 0,
|
||||||
|
string? verificationToken = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!await _pasteService.ValidateExpiresAt(expiresAt))
|
if (!_pasteService.ValidateExpiresAt(expiresAt))
|
||||||
return BadRequest(new { success = false, message = "Invalid expiration time." });
|
return BadRequest(new { success = false, message = "Invalid expiration time." });
|
||||||
if (!await _pasteService.ValidateVisibility(visibility))
|
if (!_pasteService.ValidateVisibility(visibility))
|
||||||
return BadRequest(new { success = false, message = "Invalid visibility level. Must be between 0 and 2." });
|
return BadRequest(new { success = false, message = "Invalid visibility level. Must be between 0 and 2." });
|
||||||
if (!await _pasteService.ValidateSyntax(syntax))
|
if (!_pasteService.ValidateSyntax(syntax))
|
||||||
return BadRequest(new { success = false, message = "Invalid syntax." });
|
return BadRequest(new { success = false, message = "Invalid syntax." });
|
||||||
if (!await _pasteService.ValidateTitle(title))
|
if (!_pasteService.ValidateTitle(title))
|
||||||
return BadRequest(new { success = false, message = $"Invalid title. Must be less than {_pasteSettings.MaxTitleLength} characters." });
|
return BadRequest(new { success = false, 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();
|
||||||
if (content.Length == 0)
|
if (content.Length == 0)
|
||||||
return BadRequest(new { success = false, message = "Paste content cannot be empty." });
|
return BadRequest(new { success = false, message = "Paste content cannot be empty." });
|
||||||
if (System.Text.Encoding.UTF8.GetByteCount(content) > _pasteSettings.MaxPasteSizeInBytes)
|
if (System.Text.Encoding.UTF8.GetByteCount(content) > _pasteSettings.MaxPasteSizeInBytes)
|
||||||
return BadRequest(new { success = false, message = $"Paste size exceeds the maximum allowed size of {_pasteSettings.MaxPasteSizeInBytes} bytes." });
|
return BadRequest(
|
||||||
|
new { success = false, message = $"Paste size exceeds the maximum allowed size of {_pasteSettings.MaxPasteSizeInBytes} bytes." }
|
||||||
|
);
|
||||||
|
|
||||||
if (_pasteSettings.RequiresVerfication && !await _verificationService.VerifyAsync(new VerificationContext
|
if (_pasteSettings.RequiresVerification && !HttpContext.IsApiKeyAuthenticated())
|
||||||
{
|
{
|
||||||
Token = token,
|
var providedApiKey = HttpContext.GetApiKey();
|
||||||
Ip = HttpContext.GetRequestIP()
|
if (providedApiKey != null)
|
||||||
}))
|
return BadRequest(new { success = false, message = "Invalid API key." });
|
||||||
return BadRequest(new { success = false, message = "Verification failed." });
|
|
||||||
|
var verifyResult = await _verificationService.VerifyAsync(
|
||||||
|
new VerificationContext { Token = verificationToken, Ip = HttpContext.GetRequestIP() }
|
||||||
|
);
|
||||||
|
if (!verifyResult)
|
||||||
|
return BadRequest(new { success = false, message = "Verification failed." });
|
||||||
|
}
|
||||||
|
|
||||||
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
var user = await _authService.GetUserFromHttpContext(HttpContext);
|
||||||
Paste paste = await _pasteService.Create(user, content, title, syntax, visibility, expiresAt, _pasteSettings.EnablePasteCompression);
|
Paste paste = await _pasteService.Create(user, content, title, syntax, visibility, expiresAt, _pasteSettings.EnablePasteCompression);
|
||||||
return Ok(new PasteCreatedResponseDto
|
return Ok(
|
||||||
{
|
new PasteCreatedResponseDto
|
||||||
ID = paste.ID,
|
{
|
||||||
UUID = paste.UUID,
|
ID = paste.ID,
|
||||||
IsCompressed = paste.IsCompressed,
|
UUID = paste.UUID,
|
||||||
Size = paste.Size,
|
CreatedAt = paste.CreatedAt,
|
||||||
TrueSize = paste.TrueSize,
|
IsCompressed = paste.IsCompressed,
|
||||||
ExpiresAt = paste.ExpiresAt
|
Size = paste.Size,
|
||||||
});
|
TrueSize = paste.TrueSize,
|
||||||
|
ExpiresAt = paste.ExpiresAt,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@@ -78,41 +101,44 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
int? reportCount = null;
|
int? reportCount = null;
|
||||||
if (jwtUser != null && jwtUser.Roles.Any(r => r == 1 || r == 255))
|
if (jwtUser != null && jwtUser.Roles.Any(r => r == 1 || r == 255))
|
||||||
{
|
{
|
||||||
var query = new ReportQuery
|
var query = new ReportQuery { PastePID = paste.PID };
|
||||||
{
|
|
||||||
PastePID = paste.PID
|
|
||||||
};
|
|
||||||
reportCount = await _reportService.GetReportCount(query);
|
reportCount = await _reportService.GetReportCount(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
success = true,
|
|
||||||
paste = new PasteResponseDto
|
|
||||||
{
|
{
|
||||||
ID = paste.ID,
|
success = true,
|
||||||
UUID = paste.UUID,
|
paste = new PasteResponseDto
|
||||||
Title = paste.Title,
|
|
||||||
Size = paste.Size,
|
|
||||||
TrueSize = paste.TrueSize,
|
|
||||||
IsCompressed = paste.IsCompressed,
|
|
||||||
Views = paste.Views,
|
|
||||||
Syntax = paste.Syntax,
|
|
||||||
Visibility = paste.Visibility,
|
|
||||||
ExpiresAt = paste.ExpiresAt,
|
|
||||||
EditedAt = paste.EditedAt,
|
|
||||||
ReportCount = reportCount,
|
|
||||||
Author = paste.User != null && paste.User.Visibility == 0 ? new UserSimpleDto
|
|
||||||
{
|
{
|
||||||
UID = paste.User.UID,
|
ID = paste.ID,
|
||||||
UUID = paste.User.UUID,
|
UUID = paste.UUID,
|
||||||
Username = paste.User.Username,
|
CreatedAt = paste.CreatedAt,
|
||||||
DisplayName = paste.User.DisplayName,
|
Title = paste.Title,
|
||||||
Visibility = paste.User.Visibility,
|
Size = paste.Size,
|
||||||
Roles = paste.User.Roles
|
TrueSize = paste.TrueSize,
|
||||||
} : null
|
IsCompressed = paste.IsCompressed,
|
||||||
|
Views = paste.Views,
|
||||||
|
Syntax = paste.Syntax,
|
||||||
|
Visibility = paste.Visibility,
|
||||||
|
ExpiresAt = paste.ExpiresAt,
|
||||||
|
EditedAt = paste.EditedAt,
|
||||||
|
ReportCount = reportCount,
|
||||||
|
Author =
|
||||||
|
paste.User != null && paste.User.Visibility == 0
|
||||||
|
? new UserSimpleDto
|
||||||
|
{
|
||||||
|
UID = paste.User.UID,
|
||||||
|
UUID = paste.User.UUID,
|
||||||
|
Username = paste.User.Username,
|
||||||
|
DisplayName = paste.User.DisplayName,
|
||||||
|
Visibility = paste.User.Visibility,
|
||||||
|
Roles = paste.User.Roles,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@@ -120,7 +146,8 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
public async Task<IActionResult> GetRawPasteByID(string id)
|
public async Task<IActionResult> GetRawPasteByID(string id)
|
||||||
{
|
{
|
||||||
var paste = await _pasteService.Get(id);
|
var paste = await _pasteService.Get(id);
|
||||||
if (paste == null) return NotFound();
|
if (paste == null)
|
||||||
|
return NotFound();
|
||||||
if (paste.IsCompressed)
|
if (paste.IsCompressed)
|
||||||
Response.Headers.Append("Content-Encoding", "gzip");
|
Response.Headers.Append("Content-Encoding", "gzip");
|
||||||
|
|
||||||
@@ -129,7 +156,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
|
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Route("{id}")]
|
[Route("{id}")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> EditPaste(string id)
|
public async Task<IActionResult> EditPaste(string id)
|
||||||
{
|
{
|
||||||
string content = await new StreamReader(Request.Body).ReadToEndAsync();
|
string content = await new StreamReader(Request.Body).ReadToEndAsync();
|
||||||
@@ -140,9 +167,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (paste == null)
|
if (paste == null)
|
||||||
return StatusCode(404, new { success = false, message = "Paste not found." });
|
return StatusCode(404, new { success = false, message = "Paste not found." });
|
||||||
|
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
||||||
if (paste.AuthorUUID != user.UUID && !hasPrivilegedRole)
|
if (paste.AuthorUUID != user.UUID && !hasPrivilegedRole)
|
||||||
@@ -151,22 +176,21 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
return StatusCode(403, new { success = false, message = "2FA is required to perform this action." });
|
return StatusCode(403, new { success = false, message = "2FA is required to perform this action." });
|
||||||
|
|
||||||
bool result = await _pasteService.EditText(paste, content);
|
bool result = await _pasteService.EditText(paste, content);
|
||||||
if (!result) return StatusCode(500, new { success = false, message = "An error occurred while editing the paste." });
|
if (!result)
|
||||||
|
return StatusCode(500, new { success = false, message = "An error occurred while editing the paste." });
|
||||||
return Ok(new { message = "Paste edited successfully." });
|
return Ok(new { message = "Paste edited successfully." });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch]
|
[HttpPatch]
|
||||||
[Route("{id}")]
|
[Route("{id}")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> ModifyPasteMetadata(string id, [FromBody] UpdatePasteDto request)
|
public async Task<IActionResult> ModifyPasteMetadata(string id, [FromBody] UpdatePasteDto request)
|
||||||
{
|
{
|
||||||
var paste = await _pasteService.Get(id);
|
var paste = await _pasteService.Get(id);
|
||||||
if (paste == null)
|
if (paste == null)
|
||||||
return NotFound(new { success = false, message = "Paste not found." });
|
return NotFound(new { success = false, message = "Paste not found." });
|
||||||
|
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
||||||
|
|
||||||
@@ -183,47 +207,49 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (request.ExpiresAt.HasValue)
|
if (request.ExpiresAt.HasValue)
|
||||||
paste.ExpiresAt = request.ExpiresAt.Value;
|
paste.ExpiresAt = request.ExpiresAt.Value;
|
||||||
|
|
||||||
if (!await _pasteService.ValidateExpiresAt(paste.ExpiresAt))
|
if (!_pasteService.ValidateExpiresAt(paste.ExpiresAt))
|
||||||
return BadRequest(new { success = false, message = "Invalid expiration time." });
|
return BadRequest(new { success = false, message = "Invalid expiration time." });
|
||||||
if (!await _pasteService.ValidateVisibility(paste.Visibility))
|
if (!_pasteService.ValidateVisibility(paste.Visibility))
|
||||||
return BadRequest(new { success = false, message = "Invalid visibility level. Must be between 0 and 2." });
|
return BadRequest(new { success = false, message = "Invalid visibility level. Must be between 0 and 2." });
|
||||||
if (!await _pasteService.ValidateSyntax(paste.Syntax ?? "plaintext"))
|
if (!_pasteService.ValidateSyntax(paste.Syntax ?? "plaintext"))
|
||||||
return BadRequest(new { success = false, message = "Invalid syntax." });
|
return BadRequest(new { success = false, message = "Invalid syntax." });
|
||||||
if (!await _pasteService.ValidateTitle(paste.Title ?? ""))
|
if (!_pasteService.ValidateTitle(paste.Title ?? ""))
|
||||||
return BadRequest(new { success = false, message = $"Invalid title. Must be less than {_pasteSettings.MaxTitleLength} characters." });
|
return BadRequest(new { success = false, 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
|
||||||
success = true,
|
|
||||||
message = "Paste metadata updated successfully.",
|
|
||||||
paste = new PasteResponseDto
|
|
||||||
{
|
{
|
||||||
ID = newPaste.ID,
|
success = true,
|
||||||
UUID = newPaste.UUID,
|
message = "Paste metadata updated successfully.",
|
||||||
Title = newPaste.Title,
|
paste = new PasteResponseDto
|
||||||
Size = newPaste.Size,
|
{
|
||||||
TrueSize = newPaste.TrueSize,
|
ID = newPaste.ID,
|
||||||
IsCompressed = newPaste.IsCompressed,
|
UUID = newPaste.UUID,
|
||||||
Views = newPaste.Views,
|
CreatedAt = newPaste.CreatedAt,
|
||||||
Syntax = newPaste.Syntax,
|
Title = newPaste.Title,
|
||||||
Visibility = newPaste.Visibility,
|
Size = newPaste.Size,
|
||||||
ExpiresAt = newPaste.ExpiresAt
|
TrueSize = newPaste.TrueSize,
|
||||||
|
IsCompressed = newPaste.IsCompressed,
|
||||||
|
Views = newPaste.Views,
|
||||||
|
Syntax = newPaste.Syntax,
|
||||||
|
Visibility = newPaste.Visibility,
|
||||||
|
ExpiresAt = newPaste.ExpiresAt,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Route("{id}")]
|
[Route("{id}")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> DeletePaste(string id)
|
public async Task<IActionResult> DeletePaste(string id)
|
||||||
{
|
{
|
||||||
var paste = await _pasteService.Get(id);
|
var paste = await _pasteService.Get(id);
|
||||||
if (paste == null) return NotFound(new { success = false, message = "Paste not found." });
|
if (paste == null)
|
||||||
|
return NotFound(new { success = false, message = "Paste not found." });
|
||||||
|
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
||||||
if (paste.AuthorUUID != user.UUID && !hasPrivilegedRole)
|
if (paste.AuthorUUID != user.UUID && !hasPrivilegedRole)
|
||||||
@@ -232,7 +258,8 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
return StatusCode(403, new { success = false, message = "2FA is required to perform this action." });
|
return StatusCode(403, new { success = false, message = "2FA is required to perform this action." });
|
||||||
|
|
||||||
bool result = await _pasteService.Delete(paste);
|
bool result = await _pasteService.Delete(paste);
|
||||||
if (!result) return StatusCode(500, new { success = false, message = "An error occurred while deleting the paste." });
|
if (!result)
|
||||||
|
return StatusCode(500, new { success = false, message = "An error occurred while deleting the paste." });
|
||||||
return Ok(new { success = true, message = "Paste deleted successfully." });
|
return Ok(new { success = true, message = "Paste deleted successfully." });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,8 +274,10 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
|
|
||||||
if (_pasteSettings.View_HMAC_Secret == null)
|
if (_pasteSettings.View_HMAC_Secret == null)
|
||||||
return StatusCode(500, new { success = false, message = "View recording is not configured properly." });
|
return StatusCode(500, new { success = false, message = "View recording is not configured properly." });
|
||||||
if (!string.IsNullOrWhiteSpace(_pasteSettings.View_Internal_API_Key)
|
if (
|
||||||
&& _pasteSettings.View_Internal_API_Key != Request.Headers["X-Internal-API-Key"])
|
!string.IsNullOrWhiteSpace(_pasteSettings.View_Internal_API_Key)
|
||||||
|
&& _pasteSettings.View_Internal_API_Key != Request.Headers["X-Internal-API-Key"]
|
||||||
|
)
|
||||||
return Unauthorized(new { success = false, message = "Invalid API key." });
|
return Unauthorized(new { success = false, message = "Invalid API key." });
|
||||||
|
|
||||||
var result = await _pasteService.RecordView(paste, HttpContext);
|
var result = await _pasteService.RecordView(paste, HttpContext);
|
||||||
@@ -263,55 +292,54 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("{id}/report")]
|
[Route("{id}/report")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
public async Task<IActionResult> ReportPaste(string id, [FromBody] ReportDto request)
|
public async Task<IActionResult> ReportPaste(string id, [FromBody] ReportDto request)
|
||||||
{
|
{
|
||||||
var paste = await _pasteService.Get(id);
|
var paste = await _pasteService.Get(id);
|
||||||
if (paste == null)
|
if (paste == null)
|
||||||
return NotFound(new { success = false, message = "Paste not found." });
|
return NotFound(new { success = false, message = "Paste not found." });
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
Enum.TryParse<ReportType>(request.ReportType, true, out var reportType);
|
Enum.TryParse<ReportType>(request.ReportType, true, out var reportType);
|
||||||
if (!Enum.IsDefined(reportType))
|
if (!Enum.IsDefined(reportType))
|
||||||
return BadRequest(new { success = false, message = "Invalid report type." });
|
return BadRequest(new { success = false, message = "Invalid report type." });
|
||||||
|
|
||||||
if (!await _verificationService.VerifyAsync(new VerificationContext
|
if (
|
||||||
{
|
!await _verificationService.VerifyAsync(
|
||||||
Token = request.VerificationToken,
|
new VerificationContext { Token = request.VerificationToken, Ip = HttpContext.GetRequestIP() }
|
||||||
Ip = HttpContext.GetRequestIP()
|
)
|
||||||
}))
|
)
|
||||||
return BadRequest(new { success = false, message = "Verification failed." });
|
return BadRequest(new { success = false, message = "Verification failed." });
|
||||||
|
|
||||||
|
|
||||||
Report report = await _reportService.CreateReport(user.UUID, ReportTargetType.Paste, paste.PID, reportType, request.Description);
|
Report report = await _reportService.CreateReport(user.UUID, ReportTargetType.Paste, paste.PID, reportType, request.Description);
|
||||||
if (report == null)
|
if (report == null)
|
||||||
return StatusCode(500, new { success = false, message = "An error occurred while reporting the paste." });
|
return StatusCode(500, new { success = false, message = "An error occurred while reporting the paste." });
|
||||||
|
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
success = true,
|
|
||||||
message = "Paste reported successfully.",
|
|
||||||
report = new ReportResponseDto
|
|
||||||
{
|
{
|
||||||
ReportID = report.ReportID,
|
success = true,
|
||||||
Type = report.Type,
|
message = "Paste reported successfully.",
|
||||||
Status = report.Status,
|
report = new ReportResponseDto
|
||||||
Description = report.Description,
|
{
|
||||||
CreatedAt = report.CreatedAt,
|
ReportID = report.ReportID,
|
||||||
UpdatedAt = report.UpdatedAt,
|
Type = report.Type,
|
||||||
ReporterUUID = report.ReporterUUID,
|
Status = report.Status,
|
||||||
TargetType = report.TargetType,
|
Description = report.Description,
|
||||||
UserUUID = report.UserUUID
|
CreatedAt = report.CreatedAt,
|
||||||
|
UpdatedAt = report.UpdatedAt,
|
||||||
|
ReporterUUID = report.ReporterUUID,
|
||||||
|
TargetType = report.TargetType,
|
||||||
|
UserUUID = report.UserUUID,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch]
|
[HttpPatch]
|
||||||
[Route("{id}/report/{reportId}")]
|
[Route("{id}/report/{reportId}")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
public async Task<IActionResult> ModifyPasteReport(string id, int reportId, [FromBody] ReportDto request)
|
public async Task<IActionResult> ModifyPasteReport(string id, int reportId, [FromBody] ReportDto request)
|
||||||
{
|
{
|
||||||
@@ -323,9 +351,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (report == null || report.TargetType != ReportTargetType.Paste || report.PastePID != paste.PID)
|
if (report == null || report.TargetType != ReportTargetType.Paste || report.PastePID != paste.PID)
|
||||||
return NotFound(new { success = false, message = "Report not found." });
|
return NotFound(new { success = false, message = "Report not found." });
|
||||||
|
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
||||||
if (report.ReporterUUID != user.UUID && !hasPrivilegedRole)
|
if (report.ReporterUUID != user.UUID && !hasPrivilegedRole)
|
||||||
@@ -347,7 +373,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Route("{id}/report/{reportId}")]
|
[Route("{id}/report/{reportId}")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
public async Task<IActionResult> DeletePasteReport(string id, int reportId)
|
public async Task<IActionResult> DeletePasteReport(string id, int reportId)
|
||||||
{
|
{
|
||||||
@@ -359,9 +385,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (report == null || report.TargetType != ReportTargetType.Paste || report.PastePID != paste.PID)
|
if (report == null || report.TargetType != ReportTargetType.Paste || report.PastePID != paste.PID)
|
||||||
return NotFound(new { success = false, message = "Report not found." });
|
return NotFound(new { success = false, message = "Report not found." });
|
||||||
|
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
var hasPrivilegedRole = user.Roles.Any(r => r == 1 || r == 255);
|
||||||
if (report.ReporterUUID != user.UUID && !hasPrivilegedRole)
|
if (report.ReporterUUID != user.UUID && !hasPrivilegedRole)
|
||||||
@@ -382,29 +406,35 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
public async Task<IActionResult> GetRecentPastes()
|
public async Task<IActionResult> GetRecentPastes()
|
||||||
{
|
{
|
||||||
var results = await _pasteService.GetList(0, 50, true);
|
var results = await _pasteService.GetList(0, 50, true);
|
||||||
return Ok(results.Select(p => new PasteResponseDto
|
return Ok(
|
||||||
{
|
results.Select(p => new PasteResponseDto
|
||||||
ID = p.ID,
|
|
||||||
UUID = p.UUID,
|
|
||||||
Title = p.Title,
|
|
||||||
Size = p.Size,
|
|
||||||
TrueSize = p.TrueSize,
|
|
||||||
IsCompressed = p.IsCompressed,
|
|
||||||
Views = p.Views,
|
|
||||||
Syntax = p.Syntax,
|
|
||||||
Visibility = p.Visibility,
|
|
||||||
ExpiresAt = p.ExpiresAt,
|
|
||||||
EditedAt = p.EditedAt,
|
|
||||||
Author = p.User != null && p.User.Visibility == 0 ? new UserSimpleDto
|
|
||||||
{
|
{
|
||||||
UID = p.User.UID,
|
ID = p.ID,
|
||||||
UUID = p.User.UUID,
|
UUID = p.UUID,
|
||||||
Username = p.User.Username,
|
CreatedAt = p.CreatedAt,
|
||||||
DisplayName = p.User.DisplayName,
|
Title = p.Title,
|
||||||
Visibility = p.User.Visibility,
|
Size = p.Size,
|
||||||
Roles = p.User.Roles
|
TrueSize = p.TrueSize,
|
||||||
} : null
|
IsCompressed = p.IsCompressed,
|
||||||
}));
|
Views = p.Views,
|
||||||
|
Syntax = p.Syntax,
|
||||||
|
Visibility = p.Visibility,
|
||||||
|
ExpiresAt = p.ExpiresAt,
|
||||||
|
EditedAt = p.EditedAt,
|
||||||
|
Author =
|
||||||
|
p.User != null && p.User.Visibility == 0
|
||||||
|
? new UserSimpleDto
|
||||||
|
{
|
||||||
|
UID = p.User.UID,
|
||||||
|
UUID = p.User.UUID,
|
||||||
|
Username = p.User.Username,
|
||||||
|
DisplayName = p.User.DisplayName,
|
||||||
|
Visibility = p.User.Visibility,
|
||||||
|
Roles = p.User.Roles,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@@ -412,19 +442,21 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
[Route("info")]
|
[Route("info")]
|
||||||
public IActionResult GetCreatePasteOptions()
|
public IActionResult GetCreatePasteOptions()
|
||||||
{
|
{
|
||||||
return Ok(new PasteOptionsDto
|
return Ok(
|
||||||
{
|
new PasteOptionsDto
|
||||||
Syntaxes = _pasteSettings.ValidSyntaxLanguages,
|
{
|
||||||
Visibilities =
|
Syntaxes = [.. _pasteSettings.ValidSyntaxLanguages],
|
||||||
[
|
Visibilities =
|
||||||
new() { Value = 0, DisplayName = "Public" },
|
[
|
||||||
new() { Value = 1, DisplayName = "Unlisted" },
|
new() { Value = 0, DisplayName = "Public" },
|
||||||
new() { Value = 2, DisplayName = "Private" }
|
new() { Value = 1, DisplayName = "Unlisted" },
|
||||||
],
|
new() { Value = 2, DisplayName = "Private" },
|
||||||
MaxTitleLength = _pasteSettings.MaxTitleLength,
|
],
|
||||||
MaxPasteSize = _pasteSettings.MaxPasteSizeInBytes,
|
MaxTitleLength = _pasteSettings.MaxTitleLength,
|
||||||
RequiresVerification = _pasteSettings.RequiresVerfication
|
MaxPasteSize = _pasteSettings.MaxPasteSizeInBytes,
|
||||||
});
|
RequiresVerification = _pasteSettings.RequiresVerification,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,10 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
[Route("{reportId:int}")]
|
[Route("{reportId:int}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[EnableRateLimiting("Sliding")]
|
[EnableRateLimiting("Sliding")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> GetReportById(int reportId)
|
public async Task<IActionResult> GetReportById(int reportId)
|
||||||
{
|
{
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user is null)
|
|
||||||
return Unauthorized(new { success = false, message = "You must be logged in to view reports." });
|
|
||||||
|
|
||||||
var report = await reportService.GetReportByID(reportId);
|
var report = await reportService.GetReportByID(reportId);
|
||||||
if (report is null)
|
if (report is null)
|
||||||
@@ -32,35 +30,35 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
|
|
||||||
var (Username, DisplayName) = await reportService.GetReporterInfo(report.ReporterUUID);
|
var (Username, DisplayName) = await reportService.GetReporterInfo(report.ReporterUUID);
|
||||||
|
|
||||||
return Ok(new ReportResponseDto
|
return Ok(
|
||||||
{
|
new ReportResponseDto
|
||||||
ReportID = report.ReportID,
|
{
|
||||||
Type = report.Type,
|
ReportID = report.ReportID,
|
||||||
Status = report.Status,
|
Type = report.Type,
|
||||||
Description = report.Description,
|
Status = report.Status,
|
||||||
CreatedAt = report.CreatedAt,
|
Description = report.Description,
|
||||||
UpdatedAt = report.UpdatedAt,
|
CreatedAt = report.CreatedAt,
|
||||||
ReporterUUID = report.ReporterUUID,
|
UpdatedAt = report.UpdatedAt,
|
||||||
ReporterUsername = Username,
|
ReporterUUID = report.ReporterUUID,
|
||||||
ReporterDisplayName = DisplayName,
|
ReporterUsername = Username,
|
||||||
TargetType = report.TargetType,
|
ReporterDisplayName = DisplayName,
|
||||||
PasteId = report.Paste?.ID,
|
TargetType = report.TargetType,
|
||||||
PasteTitle = report.Paste?.Title,
|
PasteId = report.Paste?.ID,
|
||||||
UserUUID = report.UserUUID,
|
PasteTitle = report.Paste?.Title,
|
||||||
TargetUsername = report.User?.Username,
|
UserUUID = report.UserUUID,
|
||||||
TargetDisplayName = report.User?.DisplayName
|
TargetUsername = report.User?.Username,
|
||||||
});
|
TargetDisplayName = report.User?.DisplayName,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("{reportId:int}")]
|
[Route("{reportId:int}")]
|
||||||
[HttpPatch]
|
[HttpPatch]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> UpdateReport(int reportId, [FromBody] ReportUpdateDto request)
|
public async Task<IActionResult> UpdateReport(int reportId, [FromBody] ReportUpdateDto request)
|
||||||
{
|
{
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user is null)
|
|
||||||
return Unauthorized(new { success = false, message = "You must be logged in to update reports." });
|
|
||||||
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
||||||
return StatusCode(403, new { success = false, message = "You do not have permission to update reports." });
|
return StatusCode(403, new { success = false, message = "You do not have permission to update reports." });
|
||||||
|
|
||||||
@@ -91,24 +89,26 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
var updated = await reportService.UpdateReport(report);
|
var updated = await reportService.UpdateReport(report);
|
||||||
var (Username, DisplayName) = await reportService.GetReporterInfo(updated.ReporterUUID);
|
var (Username, DisplayName) = await reportService.GetReporterInfo(updated.ReporterUUID);
|
||||||
|
|
||||||
return Ok(new ReportResponseDto
|
return Ok(
|
||||||
{
|
new ReportResponseDto
|
||||||
ReportID = updated.ReportID,
|
{
|
||||||
Type = updated.Type,
|
ReportID = updated.ReportID,
|
||||||
Status = updated.Status,
|
Type = updated.Type,
|
||||||
Description = updated.Description,
|
Status = updated.Status,
|
||||||
CreatedAt = updated.CreatedAt,
|
Description = updated.Description,
|
||||||
UpdatedAt = updated.UpdatedAt,
|
CreatedAt = updated.CreatedAt,
|
||||||
ReporterUUID = updated.ReporterUUID,
|
UpdatedAt = updated.UpdatedAt,
|
||||||
ReporterUsername = Username,
|
ReporterUUID = updated.ReporterUUID,
|
||||||
ReporterDisplayName = DisplayName,
|
ReporterUsername = Username,
|
||||||
TargetType = updated.TargetType,
|
ReporterDisplayName = DisplayName,
|
||||||
PasteId = updated.Paste?.ID,
|
TargetType = updated.TargetType,
|
||||||
PasteTitle = updated.Paste?.Title,
|
PasteId = updated.Paste?.ID,
|
||||||
UserUUID = updated.UserUUID,
|
PasteTitle = updated.Paste?.Title,
|
||||||
TargetUsername = updated.User?.Username,
|
UserUUID = updated.UserUUID,
|
||||||
TargetDisplayName = updated.User?.DisplayName
|
TargetUsername = updated.User?.Username,
|
||||||
});
|
TargetDisplayName = updated.User?.DisplayName,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("options")]
|
[Route("options")]
|
||||||
@@ -123,47 +123,40 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
[Route("pastes")]
|
[Route("pastes")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[EnableRateLimiting("Sliding")]
|
[EnableRateLimiting("Sliding")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> GetReportsForPastes([FromQuery] ReportQuery request)
|
public async Task<IActionResult> GetReportsForPastes([FromQuery] ReportQuery request)
|
||||||
{
|
{
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user is null)
|
|
||||||
return Unauthorized(new { success = false, message = "You must be logged in to view reports." });
|
|
||||||
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
||||||
return StatusCode(403, new { success = false, message = "You do not have permission to view pastes." });
|
return StatusCode(403, new { success = false, message = "You do not have permission to view pastes." });
|
||||||
|
|
||||||
var query = request with
|
var query = request with { Page = Math.Max(request.Page, 1), PageSize = Math.Clamp(request.PageSize, 1, 100), UserUUID = null };
|
||||||
{
|
|
||||||
Page = Math.Max(request.Page, 1),
|
|
||||||
PageSize = Math.Clamp(request.PageSize, 1, 100),
|
|
||||||
UserUUID = null
|
|
||||||
};
|
|
||||||
|
|
||||||
var reports = await reportService.GetPasteReports(query);
|
var reports = await reportService.GetPasteReports(query);
|
||||||
var totalCount = await reportService.GetReportCount(query);
|
var totalCount = await reportService.GetReportCount(query);
|
||||||
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
Reports = reports,
|
|
||||||
Pagination = new
|
|
||||||
{
|
{
|
||||||
query.Page,
|
Reports = reports,
|
||||||
query.PageSize,
|
Pagination = new
|
||||||
TotalCount = totalCount,
|
{
|
||||||
TotalPages = totalPages
|
query.Page,
|
||||||
|
query.PageSize,
|
||||||
|
TotalCount = totalCount,
|
||||||
|
TotalPages = totalPages,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("users")]
|
[Route("users")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[EnableRateLimiting("Sliding")]
|
[EnableRateLimiting("Sliding")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> GetReportsForUsers([FromQuery] ReportQuery request)
|
public async Task<IActionResult> GetReportsForUsers([FromQuery] ReportQuery request)
|
||||||
{
|
{
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user is null)
|
|
||||||
return Unauthorized(new { success = false, message = "You must be logged in to view reports." });
|
|
||||||
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
||||||
return StatusCode(403, new { success = false, message = "You do not have permission to view users." });
|
return StatusCode(403, new { success = false, message = "You do not have permission to view users." });
|
||||||
|
|
||||||
@@ -172,40 +165,41 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
Page = Math.Max(request.Page, 1),
|
Page = Math.Max(request.Page, 1),
|
||||||
PageSize = Math.Clamp(request.PageSize, 1, 100),
|
PageSize = Math.Clamp(request.PageSize, 1, 100),
|
||||||
PastePID = null,
|
PastePID = null,
|
||||||
PasteId = null
|
PasteId = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
var reports = await reportService.GetUserReports(query);
|
var reports = await reportService.GetUserReports(query);
|
||||||
var totalCount = await reportService.GetReportCount(query);
|
var totalCount = await reportService.GetReportCount(query);
|
||||||
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
Reports = reports,
|
|
||||||
Pagination = new
|
|
||||||
{
|
{
|
||||||
query.Page,
|
Reports = reports,
|
||||||
query.PageSize,
|
Pagination = new
|
||||||
TotalCount = totalCount,
|
{
|
||||||
TotalPages = totalPages
|
query.Page,
|
||||||
|
query.PageSize,
|
||||||
|
TotalCount = totalCount,
|
||||||
|
TotalPages = totalPages,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("all")]
|
[Route("all")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[EnableRateLimiting("Sliding")]
|
[EnableRateLimiting("Sliding")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> GetAllReports(
|
public async Task<IActionResult> GetAllReports(
|
||||||
[FromQuery] Guid? reporterUuid,
|
[FromQuery] Guid? reporterUuid,
|
||||||
[FromQuery] ReportTargetType? targetType,
|
[FromQuery] ReportTargetType? targetType,
|
||||||
[FromQuery] ReportType? type,
|
[FromQuery] ReportType? type,
|
||||||
[FromQuery] ReportStatus? status,
|
[FromQuery] ReportStatus? status,
|
||||||
[FromQuery] int page = 1,
|
[FromQuery] int page = 1,
|
||||||
[FromQuery] int pageSize = 20)
|
[FromQuery] int pageSize = 20
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var user = HttpContext.GetJwtUser();
|
var user = HttpContext.GetJwtUser()!;
|
||||||
if (user is null)
|
|
||||||
return Unauthorized(new { success = false, message = "You must be logged in to view reports." });
|
|
||||||
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
if (!user.Roles.Contains(1) && !user.Roles.Contains(255))
|
||||||
return StatusCode(403, new { success = false, message = "You do not have permission to view reports." });
|
return StatusCode(403, new { success = false, message = "You do not have permission to view reports." });
|
||||||
|
|
||||||
@@ -216,23 +210,25 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
Type = type,
|
Type = type,
|
||||||
Status = status,
|
Status = status,
|
||||||
Page = Math.Max(page, 1),
|
Page = Math.Max(page, 1),
|
||||||
PageSize = Math.Clamp(pageSize, 1, 100)
|
PageSize = Math.Clamp(pageSize, 1, 100),
|
||||||
};
|
};
|
||||||
|
|
||||||
var reports = await reportService.GetReports(query);
|
var reports = await reportService.GetReports(query);
|
||||||
var totalCount = await reportService.GetReportCount(query);
|
var totalCount = await reportService.GetReportCount(query);
|
||||||
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
Reports = reports,
|
|
||||||
Pagination = new
|
|
||||||
{
|
{
|
||||||
query.Page,
|
Reports = reports,
|
||||||
query.PageSize,
|
Pagination = new
|
||||||
TotalCount = totalCount,
|
{
|
||||||
TotalPages = totalPages
|
query.Page,
|
||||||
|
query.PageSize,
|
||||||
|
TotalCount = totalCount,
|
||||||
|
TotalPages = totalPages,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,14 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class UserController(UserService userService, AppDbContext db, TotpVerificationProvider totp,
|
public class UserController(
|
||||||
VerificationService verificationService, ReportService reportServer, IOptions<AuthSettings> authSettings) : ControllerBase
|
UserService userService,
|
||||||
|
AppDbContext db,
|
||||||
|
TotpVerificationProvider totp,
|
||||||
|
VerificationService verificationService,
|
||||||
|
ReportService reportServer,
|
||||||
|
IOptions<AuthSettings> authSettings
|
||||||
|
) : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly UserService _userService = userService;
|
private readonly UserService _userService = userService;
|
||||||
private readonly AppDbContext _db = db;
|
private readonly AppDbContext _db = db;
|
||||||
@@ -47,31 +53,30 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IActionResult> GetMe([FromQuery] int page = 1)
|
public async Task<IActionResult> GetMe([FromQuery] int page = 1)
|
||||||
{
|
{
|
||||||
var userUUID = HttpContext.User?.FindFirst("uuid")?.Value;
|
var userUUID = HttpContext.User.FindFirst("uuid")!.Value;
|
||||||
if (userUUID is null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var user = await _userService.GetByUUID(Guid.Parse(userUUID), withPastes: true);
|
var user = await _userService.GetByUUID(Guid.Parse(userUUID), withPastes: true);
|
||||||
return user == null ? NotFound(new { success = false, message = "User not found." }) : await BuildUserResponse(user, page);
|
return user == null ? NotFound(new { success = false, message = "User not found." }) : await BuildUserResponse(user, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch("uuid/{uuid}")]
|
[HttpPatch("uuid/{uuid}")]
|
||||||
[Authorize]
|
[Authorize(Policy = "JwtOnly")]
|
||||||
[EnableRateLimiting("Strict")]
|
[EnableRateLimiting("Strict")]
|
||||||
public async Task<IActionResult> UpdateByUUID(Guid uuid, [FromBody] UpdateUserDto updatedUser)
|
public async Task<IActionResult> UpdateByUUID(Guid uuid, [FromBody] UpdateUserDto updatedUser)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"{ModelState.IsValid}");
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
|
|
||||||
var jwtUser = HttpContext.GetJwtUser();
|
var jwtUser = HttpContext.GetJwtUser()!;
|
||||||
if (jwtUser == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var user = await _userService.GetByUUID(uuid);
|
var user = await _userService.GetByUUID(uuid);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return NotFound(new { success = false, message = "User not found." });
|
return NotFound(new { success = false, message = "User not found." });
|
||||||
|
|
||||||
if ((user.Roles.Contains(255) && !jwtUser.Roles.Contains(255)) || (!jwtUser.Roles.Any(r => r == 1 || r == 255) && user.UUID != jwtUser.UUID))
|
if (
|
||||||
|
(user.Roles.Contains(255) && !jwtUser.Roles.Contains(255))
|
||||||
|
|| (!jwtUser.Roles.Any(r => r == 1 || r == 255) && user.UUID != jwtUser.UUID)
|
||||||
|
)
|
||||||
return StatusCode(403, new { success = false, message = "You do not have permission to modify this user." });
|
return StatusCode(403, new { success = false, message = "You do not have permission to modify this user." });
|
||||||
|
|
||||||
if (jwtUser.Roles.Contains(255) && !jwtUser.TotpEnabled && _authSettings.Admins_Require_2FA)
|
if (jwtUser.Roles.Contains(255) && !jwtUser.TotpEnabled && _authSettings.Admins_Require_2FA)
|
||||||
@@ -87,11 +92,10 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
{
|
{
|
||||||
if (updatedUser.Roles.Contains(255) && jwtUser.TotpEnabled)
|
if (updatedUser.Roles.Contains(255) && jwtUser.TotpEnabled)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(updatedUser.TotpCode) || !await _totp.VerifyAsync(new VerificationContext
|
if (
|
||||||
{
|
string.IsNullOrEmpty(updatedUser.TotpCode)
|
||||||
UserUUID = jwtUser.UUID,
|
|| !await _totp.VerifyAsync(new VerificationContext { UserUUID = jwtUser.UUID, Code = updatedUser.TotpCode })
|
||||||
Code = updatedUser.TotpCode
|
)
|
||||||
}))
|
|
||||||
{
|
{
|
||||||
return Unauthorized(new { message = "Invalid TOTP code." });
|
return Unauthorized(new { message = "Invalid TOTP code." });
|
||||||
}
|
}
|
||||||
@@ -104,13 +108,11 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("uuid/{uuid}")]
|
[HttpDelete("uuid/{uuid}")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
public async Task<IActionResult> DeleteByUUID(Guid uuid, [FromBody] DeleteUserDto dto)
|
public async Task<IActionResult> DeleteByUUID(Guid uuid, [FromBody] DeleteUserDto dto)
|
||||||
{
|
{
|
||||||
var jwtUser = HttpContext.GetJwtUser();
|
var jwtUser = HttpContext.GetJwtUser()!;
|
||||||
if (jwtUser == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var user = await _userService.GetByUUID(uuid);
|
var user = await _userService.GetByUUID(uuid);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@@ -123,22 +125,20 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
|
|
||||||
if (jwtUser.TotpEnabled)
|
if (jwtUser.TotpEnabled)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(dto.TotpCode) || !await _totp.VerifyAsync(new VerificationContext
|
if (
|
||||||
{
|
string.IsNullOrEmpty(dto.TotpCode)
|
||||||
UserUUID = jwtUser.UUID,
|
|| !await _totp.VerifyAsync(new VerificationContext { UserUUID = jwtUser.UUID, Code = dto.TotpCode })
|
||||||
Code = dto.TotpCode
|
)
|
||||||
}))
|
|
||||||
{
|
{
|
||||||
return Unauthorized(new { message = "Invalid TOTP code." });
|
return Unauthorized(new { message = "Invalid TOTP code." });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(dto.Token) || !await _verificationService.VerifyAsync(new VerificationContext
|
if (
|
||||||
{
|
string.IsNullOrEmpty(dto.Token)
|
||||||
Token = dto.Token,
|
|| !await _verificationService.VerifyAsync(new VerificationContext { Token = dto.Token, Ip = HttpContext.GetRequestIP() })
|
||||||
Ip = HttpContext.GetRequestIP()
|
)
|
||||||
}))
|
|
||||||
{
|
{
|
||||||
return Unauthorized(new { message = "Invalid verification token." });
|
return Unauthorized(new { message = "Invalid verification token." });
|
||||||
}
|
}
|
||||||
@@ -152,12 +152,10 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("{uuid}/report")]
|
[Route("{uuid}/report")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> ReportUser(Guid uuid, [FromBody] ReportDto request)
|
public async Task<IActionResult> ReportUser(Guid uuid, [FromBody] ReportDto request)
|
||||||
{
|
{
|
||||||
var reporter = HttpContext.GetJwtUser();
|
var reporter = HttpContext.GetJwtUser()!;
|
||||||
if (reporter == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var reportedUser = await _userService.GetByUUID(uuid);
|
var reportedUser = await _userService.GetByUUID(uuid);
|
||||||
if (reportedUser == null)
|
if (reportedUser == null)
|
||||||
@@ -168,45 +166,45 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (!Enum.IsDefined(reportType))
|
if (!Enum.IsDefined(reportType))
|
||||||
return BadRequest(new { success = false, message = "Invalid report type." });
|
return BadRequest(new { success = false, message = "Invalid report type." });
|
||||||
|
|
||||||
if (!await _verificationService.VerifyAsync(new VerificationContext
|
if (
|
||||||
{
|
!await _verificationService.VerifyAsync(
|
||||||
Token = request.VerificationToken,
|
new VerificationContext { Token = request.VerificationToken, Ip = HttpContext.GetRequestIP() }
|
||||||
Ip = HttpContext.GetRequestIP()
|
)
|
||||||
}))
|
)
|
||||||
return Unauthorized(new { success = false, message = "Invalid verification token." });
|
return Unauthorized(new { success = false, message = "Invalid verification token." });
|
||||||
|
|
||||||
Report report = await _reportService.CreateReport(reporter.UUID, ReportTargetType.User, uuid, reportType, request.Description);
|
Report report = await _reportService.CreateReport(reporter.UUID, ReportTargetType.User, uuid, reportType, request.Description);
|
||||||
if (report == null)
|
if (report == null)
|
||||||
return StatusCode(500, new { success = false, message = "An error occurred while creating the report." });
|
return StatusCode(500, new { success = false, message = "An error occurred while creating the report." });
|
||||||
|
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
success = true,
|
|
||||||
message = "User reported successfully.",
|
|
||||||
report = new ReportResponseDto
|
|
||||||
{
|
{
|
||||||
ReportID = report.ReportID,
|
success = true,
|
||||||
Type = report.Type,
|
message = "User reported successfully.",
|
||||||
Status = report.Status,
|
report = new ReportResponseDto
|
||||||
Description = report.Description,
|
{
|
||||||
CreatedAt = report.CreatedAt,
|
ReportID = report.ReportID,
|
||||||
UpdatedAt = report.UpdatedAt,
|
Type = report.Type,
|
||||||
ReporterUUID = report.ReporterUUID,
|
Status = report.Status,
|
||||||
TargetType = report.TargetType,
|
Description = report.Description,
|
||||||
UserUUID = report.UserUUID
|
CreatedAt = report.CreatedAt,
|
||||||
|
UpdatedAt = report.UpdatedAt,
|
||||||
|
ReporterUUID = report.ReporterUUID,
|
||||||
|
TargetType = report.TargetType,
|
||||||
|
UserUUID = report.UserUUID,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch]
|
[HttpPatch]
|
||||||
[Route("{uuid}/report/{reportId}")]
|
[Route("{uuid}/report/{reportId}")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> UpdateUserReport(Guid uuid, int reportId, [FromBody] ReportDto request)
|
public async Task<IActionResult> UpdateUserReport(Guid uuid, int reportId, [FromBody] ReportDto request)
|
||||||
{
|
{
|
||||||
var jwtUser = HttpContext.GetJwtUser();
|
var jwtUser = HttpContext.GetJwtUser()!;
|
||||||
if (jwtUser == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var user = await _userService.GetByUUID(uuid);
|
var user = await _userService.GetByUUID(uuid);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@@ -230,12 +228,10 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Route("{uuid}/report/{reportId}")]
|
[Route("{uuid}/report/{reportId}")]
|
||||||
[EnableRateLimiting("Sensitive")]
|
[EnableRateLimiting("Sensitive")]
|
||||||
[Authorize(Policy = "AuthAndNotBanned")]
|
[Authorize(Policy = "JwtOnlyAndNotBanned")]
|
||||||
public async Task<IActionResult> DeleteUserReport(Guid uuid, int reportId)
|
public async Task<IActionResult> DeleteUserReport(Guid uuid, int reportId)
|
||||||
{
|
{
|
||||||
var jwtUser = HttpContext.GetJwtUser();
|
var jwtUser = HttpContext.GetJwtUser()!;
|
||||||
if (jwtUser == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var user = await _userService.GetByUUID(uuid);
|
var user = await _userService.GetByUUID(uuid);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@@ -253,13 +249,11 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize]
|
[Authorize(Policy = "JwtOnly")]
|
||||||
[Route("{uuid}/reports")]
|
[Route("{uuid}/reports")]
|
||||||
public async Task<IActionResult> GetUserReports(Guid uuid, [FromQuery] ReportQuery request)
|
public async Task<IActionResult> GetUserReports(Guid uuid, [FromQuery] ReportQuery request)
|
||||||
{
|
{
|
||||||
var jwtUser = HttpContext.GetJwtUser();
|
var jwtUser = HttpContext.GetJwtUser()!;
|
||||||
if (jwtUser == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var user = await _userService.GetByUUID(uuid);
|
var user = await _userService.GetByUUID(uuid);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@@ -268,36 +262,31 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (!jwtUser.Roles.Any(r => r == 1 || r == 255))
|
if (!jwtUser.Roles.Any(r => r == 1 || r == 255))
|
||||||
return StatusCode(403, new { success = false, message = "You do not have permission to view this user's reports." });
|
return StatusCode(403, new { success = false, message = "You do not have permission to view this user's reports." });
|
||||||
|
|
||||||
var query = request with
|
var query = request with { UserUUID = user.UUID, Page = Math.Max(request.Page, 1), PageSize = Math.Clamp(request.PageSize, 1, 100) };
|
||||||
{
|
|
||||||
UserUUID = user.UUID,
|
|
||||||
Page = Math.Max(request.Page, 1),
|
|
||||||
PageSize = Math.Clamp(request.PageSize, 1, 100)
|
|
||||||
};
|
|
||||||
var reports = await _reportService.GetUserReports(query);
|
var reports = await _reportService.GetUserReports(query);
|
||||||
var totalCount = await _reportService.GetReportCount(query);
|
var totalCount = await _reportService.GetReportCount(query);
|
||||||
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
Reports = reports,
|
|
||||||
Pagination = new
|
|
||||||
{
|
{
|
||||||
query.Page,
|
Reports = reports,
|
||||||
query.PageSize,
|
Pagination = new
|
||||||
TotalCount = totalCount,
|
{
|
||||||
TotalPages = totalPages
|
query.Page,
|
||||||
|
query.PageSize,
|
||||||
|
TotalCount = totalCount,
|
||||||
|
TotalPages = totalPages,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize]
|
[Authorize(Policy = "JwtOnly")]
|
||||||
[Route("{uuid}/reports/submitted")]
|
[Route("{uuid}/reports/submitted")]
|
||||||
public async Task<IActionResult> GetUserSubmittedReports(Guid uuid, [FromQuery] ReportQuery request)
|
public async Task<IActionResult> GetUserSubmittedReports(Guid uuid, [FromQuery] ReportQuery request)
|
||||||
{
|
{
|
||||||
var jwtUser = HttpContext.GetJwtUser();
|
var jwtUser = HttpContext.GetJwtUser()!;
|
||||||
if (jwtUser == null)
|
|
||||||
return Unauthorized(new { success = false, message = "Invalid token." });
|
|
||||||
|
|
||||||
var user = await _userService.GetByUUID(uuid);
|
var user = await _userService.GetByUUID(uuid);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@@ -308,28 +297,25 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
if (!isOwner && !hasPrivilegedRole)
|
if (!isOwner && !hasPrivilegedRole)
|
||||||
return StatusCode(403, new { success = false, message = "You do not have permission to view this user's submitted reports." });
|
return StatusCode(403, new { success = false, message = "You do not have permission to view this user's submitted reports." });
|
||||||
|
|
||||||
var query = request with
|
var query = request with { ReporterUUID = user.UUID, Page = Math.Max(request.Page, 1), PageSize = Math.Clamp(request.PageSize, 1, 100) };
|
||||||
{
|
|
||||||
ReporterUUID = user.UUID,
|
|
||||||
Page = Math.Max(request.Page, 1),
|
|
||||||
PageSize = Math.Clamp(request.PageSize, 1, 100)
|
|
||||||
};
|
|
||||||
|
|
||||||
var reports = await _reportService.GetReports(query);
|
var reports = await _reportService.GetReports(query);
|
||||||
var totalCount = await _reportService.GetReportCount(query);
|
var totalCount = await _reportService.GetReportCount(query);
|
||||||
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
var totalPages = (int)Math.Ceiling(totalCount / (double)query.PageSize);
|
||||||
|
|
||||||
return Ok(new
|
return Ok(
|
||||||
{
|
new
|
||||||
Reports = reports,
|
|
||||||
Pagination = new
|
|
||||||
{
|
{
|
||||||
query.Page,
|
Reports = reports,
|
||||||
query.PageSize,
|
Pagination = new
|
||||||
TotalCount = totalCount,
|
{
|
||||||
TotalPages = totalPages
|
query.Page,
|
||||||
|
query.PageSize,
|
||||||
|
TotalCount = totalCount,
|
||||||
|
TotalPages = totalPages,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IActionResult> BuildUserResponse(User user, int page = 1)
|
private async Task<IActionResult> BuildUserResponse(User user, int page = 1)
|
||||||
@@ -360,6 +346,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
{
|
{
|
||||||
ID = p.ID,
|
ID = p.ID,
|
||||||
UUID = p.UUID,
|
UUID = p.UUID,
|
||||||
|
CreatedAt = p.CreatedAt,
|
||||||
Title = p.Title,
|
Title = p.Title,
|
||||||
Syntax = p.Syntax,
|
Syntax = p.Syntax,
|
||||||
Size = p.Size,
|
Size = p.Size,
|
||||||
@@ -367,7 +354,7 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
Views = p.Views,
|
Views = p.Views,
|
||||||
Visibility = p.Visibility,
|
Visibility = p.Visibility,
|
||||||
EditedAt = p.EditedAt,
|
EditedAt = p.EditedAt,
|
||||||
ExpiresAt = p.ExpiresAt
|
ExpiresAt = p.ExpiresAt,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
@@ -376,59 +363,67 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
Page = page,
|
Page = page,
|
||||||
PageSize = pageSize,
|
PageSize = pageSize,
|
||||||
TotalCount = totalCount,
|
TotalCount = totalCount,
|
||||||
TotalPages = totalPages
|
TotalPages = totalPages,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isAuthenticatedUser)
|
if (isAuthenticatedUser)
|
||||||
{
|
{
|
||||||
var reports = await _reportService.GetReports(new ReportQuery
|
var reports = await _reportService.GetReports(
|
||||||
{
|
new ReportQuery
|
||||||
ReporterUUID = user.UUID,
|
{
|
||||||
Page = page,
|
ReporterUUID = user.UUID,
|
||||||
PageSize = pageSize
|
Page = page,
|
||||||
});
|
PageSize = pageSize,
|
||||||
|
}
|
||||||
|
);
|
||||||
var reportsCount = await _reportService.GetReportCountByReporter(user.UUID);
|
var reportsCount = await _reportService.GetReportCountByReporter(user.UUID);
|
||||||
|
|
||||||
return Ok(new
|
return Ok(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
User = new UserResponseDto
|
||||||
|
{
|
||||||
|
UID = user.UID,
|
||||||
|
Username = user.Username,
|
||||||
|
UUID = user.UUID,
|
||||||
|
CreatedAt = user.CreatedAt,
|
||||||
|
DisplayName = user.DisplayName,
|
||||||
|
Email = user.Email,
|
||||||
|
LastLogin = user.LastLogin,
|
||||||
|
Roles = user.Roles,
|
||||||
|
Visibility = user.Visibility,
|
||||||
|
},
|
||||||
|
Pastes = pastes,
|
||||||
|
Reports = reports,
|
||||||
|
Pagination = pagination,
|
||||||
|
ReportsPagination = new
|
||||||
|
{
|
||||||
|
Page = page,
|
||||||
|
PageSize = pageSize,
|
||||||
|
TotalCount = reportsCount,
|
||||||
|
TotalPages = (int)Math.Ceiling(reportsCount / (double)pageSize),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(
|
||||||
|
new
|
||||||
{
|
{
|
||||||
User = new UserResponseDto
|
User = new UserSimpleDto
|
||||||
{
|
{
|
||||||
UID = user.UID,
|
UID = user.UID,
|
||||||
Username = user.Username,
|
Username = user.Username,
|
||||||
UUID = user.UUID,
|
UUID = user.UUID,
|
||||||
|
CreatedAt = user.CreatedAt,
|
||||||
DisplayName = user.DisplayName,
|
DisplayName = user.DisplayName,
|
||||||
Email = user.Email,
|
|
||||||
LastLogin = user.LastLogin,
|
|
||||||
Roles = user.Roles,
|
Roles = user.Roles,
|
||||||
Visibility = user.Visibility
|
Visibility = user.Visibility,
|
||||||
},
|
},
|
||||||
Pastes = pastes,
|
Pastes = pastes,
|
||||||
Reports = reports,
|
|
||||||
Pagination = pagination,
|
Pagination = pagination,
|
||||||
ReportsPagination = new
|
}
|
||||||
{
|
);
|
||||||
Page = page,
|
|
||||||
PageSize = pageSize,
|
|
||||||
TotalCount = reportsCount,
|
|
||||||
TotalPages = (int)Math.Ceiling(reportsCount / (double)pageSize)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(new
|
|
||||||
{
|
|
||||||
User = new UserSimpleDto
|
|
||||||
{
|
|
||||||
UID = user.UID,
|
|
||||||
Username = user.Username,
|
|
||||||
UUID = user.UUID,
|
|
||||||
DisplayName = user.DisplayName,
|
|
||||||
Roles = user.Roles,
|
|
||||||
Visibility = user.Visibility
|
|
||||||
},
|
|
||||||
Pastes = pastes,
|
|
||||||
Pagination = pagination
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace SharpbinV3.Server.DTOs.ApiKey
|
||||||
|
{
|
||||||
|
public sealed class ApiKeyListItemDto
|
||||||
|
{
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public required Guid UUID { get; set; }
|
||||||
|
public required long CreatedAt { get; set; }
|
||||||
|
public long? LastUsedAt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace SharpbinV3.Server.DTOs.ApiKey
|
||||||
|
{
|
||||||
|
public sealed class ApiKeyResponseDto
|
||||||
|
{
|
||||||
|
public required string Key { get; set; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public required Guid UUID { get; set; }
|
||||||
|
public required long CreatedAt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace SharpbinV3.Server.DTOs.ApiKey
|
||||||
|
{
|
||||||
|
public sealed class CreateApiKeyRequest
|
||||||
|
{
|
||||||
|
public required string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ namespace SharpbinV3.Server.DTOs.Auth
|
|||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
public required string Token { get; set; }
|
public required string Token { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public required string RefreshToken { get; set; }
|
public required string RefreshToken { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace SharpbinV3.Server.DTOs.Auth
|
|||||||
{
|
{
|
||||||
[JsonPropertyName("success")]
|
[JsonPropertyName("success")]
|
||||||
public bool Success { get; set; }
|
public bool Success { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("error-codes")]
|
[JsonPropertyName("error-codes")]
|
||||||
public string[]? ErrorCodes { get; set; }
|
public string[]? ErrorCodes { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace SharpbinV3.Server.DTOs.Paste
|
|||||||
{
|
{
|
||||||
public string ID { get; set; } = string.Empty;
|
public string ID { get; set; } = string.Empty;
|
||||||
public Guid UUID { get; set; }
|
public Guid UUID { get; set; }
|
||||||
|
public long CreatedAt { get; set; }
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
public string? Syntax { get; set; }
|
public string? Syntax { get; set; }
|
||||||
public long Size { get; set; }
|
public long Size { get; set; }
|
||||||
@@ -23,6 +24,7 @@ namespace SharpbinV3.Server.DTOs.Paste
|
|||||||
{
|
{
|
||||||
public string ID { get; set; } = string.Empty;
|
public string ID { get; set; } = string.Empty;
|
||||||
public Guid UUID { get; set; }
|
public Guid UUID { get; set; }
|
||||||
|
public long CreatedAt { get; set; }
|
||||||
public bool IsCompressed { get; set; }
|
public bool IsCompressed { get; set; }
|
||||||
public long Size { get; set; }
|
public long Size { get; set; }
|
||||||
public long TrueSize { get; set; }
|
public long TrueSize { get; set; }
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ namespace SharpbinV3.Server.DTOs.Report
|
|||||||
[Required]
|
[Required]
|
||||||
[MinLength(12), MaxLength(1000)]
|
[MinLength(12), MaxLength(1000)]
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string ReportType { get; set; } = string.Empty; // e.g., "Spam", "Abuse", etc.
|
public string ReportType { get; set; } = string.Empty;
|
||||||
public string ReportStatus { get; set; } = "Open";
|
public string ReportStatus { get; set; } = "Open";
|
||||||
public string? VerificationToken { get; set; }
|
public string? VerificationToken { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace SharpbinV3.Server.DTOs.Report
|
|||||||
{
|
{
|
||||||
public string? Status { get; set; }
|
public string? Status { get; set; }
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
|
|
||||||
[MaxLength(1000)]
|
[MaxLength(1000)]
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace SharpbinV3.Server.DTOs.User
|
|||||||
[StringLength(50, MinimumLength = 3)]
|
[StringLength(50, MinimumLength = 3)]
|
||||||
public string? Username { get; set; }
|
public string? Username { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
|
|
||||||
[StringLength(128, MinimumLength = 6)]
|
[StringLength(128, MinimumLength = 6)]
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
public string? Token { get; set; }
|
public string? Token { get; set; }
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace SharpbinV3.Server.DTOs
|
namespace SharpbinV3.Server.DTOs
|
||||||
{
|
{
|
||||||
public partial class RegisterUserDto
|
public partial class RegisterUserDto : IValidatableObject
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(50, MinimumLength = 3)]
|
[StringLength(50, MinimumLength = 3)]
|
||||||
@@ -18,22 +18,32 @@ namespace SharpbinV3.Server.DTOs
|
|||||||
public string? DisplayName { get; set; }
|
public string? DisplayName { get; set; }
|
||||||
public string? Token { get; set; }
|
public string? Token { get; set; }
|
||||||
|
|
||||||
public IEnumerable<ValidationResult> Validate()
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
var results = new List<ValidationResult>();
|
var results = new List<ValidationResult>();
|
||||||
if (!ValidateUsername().IsMatch(Username))
|
if (!ValidateUsername().IsMatch(Username))
|
||||||
results.Add(new ValidationResult("Username can only contain letters, numbers, underscores, and dots.", [nameof(Username)]));
|
results.Add(new ValidationResult("Username can only contain letters, numbers, underscores, and dots.", [nameof(Username)]));
|
||||||
if (!ValidatePassword().IsMatch(Password))
|
if (!ValidatePassword().IsMatch(Password))
|
||||||
results.Add(new ValidationResult("Password should have at least 8 characters, including uppercase, lowercase, and digits.", [nameof(Password)]));
|
results.Add(
|
||||||
|
new ValidationResult(
|
||||||
|
"Password should have at least 8 characters, including uppercase, lowercase, and digits.",
|
||||||
|
[nameof(Password)]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (DisplayName != null)
|
if (DisplayName != null && DisplayName.Length > 0)
|
||||||
{
|
{
|
||||||
if (DisplayName.Length < 3 || DisplayName.Length > 26)
|
if (DisplayName.Length < 3 || DisplayName.Length > 26)
|
||||||
results.Add(new ValidationResult("DisplayName must be between 3 and 26 characters.", [nameof(DisplayName)]));
|
results.Add(new ValidationResult("DisplayName must be between 3 and 26 characters.", [nameof(DisplayName)]));
|
||||||
if (!ValidateUsername().IsMatch(DisplayName))
|
if (!ValidateDisplayname().IsMatch(DisplayName))
|
||||||
results.Add(new ValidationResult("DisplayName can only contain letters, numbers, underscores, and dots.", [nameof(DisplayName)]));
|
results.Add(
|
||||||
|
new ValidationResult(
|
||||||
|
"DisplayName can only contain alphanumeric characters, underscores, periods, and spaces (no leading or trailing spaces).",
|
||||||
|
[nameof(DisplayName)]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (Email != null)
|
if (Email != null && Email.Length > 0)
|
||||||
{
|
{
|
||||||
var emailAttribute = new EmailAddressAttribute();
|
var emailAttribute = new EmailAddressAttribute();
|
||||||
if (!emailAttribute.IsValid(Email))
|
if (!emailAttribute.IsValid(Email))
|
||||||
@@ -44,6 +54,10 @@ namespace SharpbinV3.Server.DTOs
|
|||||||
|
|
||||||
[GeneratedRegex("^[A-Za-z0-9_.]+$")]
|
[GeneratedRegex("^[A-Za-z0-9_.]+$")]
|
||||||
private static partial Regex ValidateUsername();
|
private static partial Regex ValidateUsername();
|
||||||
|
|
||||||
|
[GeneratedRegex("^[A-Za-z0-9_.]+(?: [A-Za-z0-9_.]+)*$")]
|
||||||
|
private static partial Regex ValidateDisplayname();
|
||||||
|
|
||||||
[GeneratedRegex("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,}$")]
|
[GeneratedRegex("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,}$")]
|
||||||
public static partial Regex ValidatePassword();
|
public static partial Regex ValidatePassword();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace SharpbinV3.Server.DTOs
|
namespace SharpbinV3.Server.DTOs
|
||||||
{
|
{
|
||||||
public partial class UpdateUserDto
|
public partial class UpdateUserDto : IValidatableObject
|
||||||
{
|
{
|
||||||
public string? DisplayName { get; set; }
|
public string? DisplayName { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
@@ -11,28 +11,33 @@ namespace SharpbinV3.Server.DTOs
|
|||||||
public int[]? Roles { get; set; }
|
public int[]? Roles { get; set; }
|
||||||
public string? TotpCode { get; set; }
|
public string? TotpCode { get; set; }
|
||||||
|
|
||||||
public IEnumerable<ValidationResult> Validate()
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
var results = new List<ValidationResult>();
|
var results = new List<ValidationResult>();
|
||||||
if (DisplayName != null)
|
if (DisplayName != null && DisplayName.Length > 0)
|
||||||
{
|
{
|
||||||
if (DisplayName.Length < 3 || DisplayName.Length > 26)
|
if (DisplayName.Length < 3 || DisplayName.Length > 26)
|
||||||
results.Add(new ValidationResult("DisplayName must be between 3 and 26 characters.", [nameof(DisplayName)]));
|
results.Add(new ValidationResult("DisplayName must be between 3 and 26 characters.", [nameof(DisplayName)]));
|
||||||
if (!ValidateDisplayname().IsMatch(DisplayName))
|
if (!ValidateDisplayname().IsMatch(DisplayName))
|
||||||
results.Add(new ValidationResult("DisplayName can only contain letters, numbers, underscores, and dots.", [nameof(DisplayName)]));
|
results.Add(
|
||||||
|
new ValidationResult(
|
||||||
|
"DisplayName can only contain alphanumeric characters, underscores, periods, and spaces (no leading or trailing spaces).",
|
||||||
|
[nameof(DisplayName)]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (Email != null)
|
if (Email != null && Email.Length > 0)
|
||||||
{
|
{
|
||||||
var emailAttribute = new EmailAddressAttribute();
|
var emailAttribute = new EmailAddressAttribute();
|
||||||
if (!emailAttribute.IsValid(Email))
|
if (!emailAttribute.IsValid(Email))
|
||||||
results.Add(new ValidationResult("Invalid email format.", [nameof(Email)]));
|
results.Add(new ValidationResult("Invalid email format.", [nameof(Email)]));
|
||||||
}
|
}
|
||||||
if (Visibility != null)
|
if (Visibility != null && Visibility.HasValue)
|
||||||
{
|
{
|
||||||
if (Visibility < 0 || Visibility > 2)
|
if (Visibility < 0 || Visibility > 2)
|
||||||
results.Add(new ValidationResult("Visibility must be between 0 and 2.", [nameof(Visibility)]));
|
results.Add(new ValidationResult("Visibility must be between 0 and 2.", [nameof(Visibility)]));
|
||||||
}
|
}
|
||||||
if (Roles != null)
|
if (Roles != null && Roles.Length > 0)
|
||||||
{
|
{
|
||||||
if (Roles.Length == 0)
|
if (Roles.Length == 0)
|
||||||
results.Add(new ValidationResult("Roles cannot be an empty array.", [nameof(Roles)]));
|
results.Add(new ValidationResult("Roles cannot be an empty array.", [nameof(Roles)]));
|
||||||
@@ -42,12 +47,11 @@ namespace SharpbinV3.Server.DTOs
|
|||||||
if (!validRoles.Contains(role))
|
if (!validRoles.Contains(role))
|
||||||
results.Add(new ValidationResult($"Invalid role: {role}.", [nameof(Roles)]));
|
results.Add(new ValidationResult($"Invalid role: {role}.", [nameof(Roles)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
[GeneratedRegex("^[A-Za-z0-9_.]+$")]
|
[GeneratedRegex("^[A-Za-z0-9_.]+(?: [A-Za-z0-9_.]+)*$")]
|
||||||
private static partial Regex ValidateDisplayname();
|
private static partial Regex ValidateDisplayname();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace SharpbinV3.Server.DTOs.User
|
|||||||
{
|
{
|
||||||
public int? UID { get; set; }
|
public int? UID { get; set; }
|
||||||
public Guid UUID { get; set; }
|
public Guid UUID { get; set; }
|
||||||
|
public long CreatedAt { get; set; }
|
||||||
public string Username { get; set; } = string.Empty;
|
public string Username { get; set; } = string.Empty;
|
||||||
public string? DisplayName { get; set; }
|
public string? DisplayName { get; set; }
|
||||||
public int[] Roles { get; set; } = [];
|
public int[] Roles { get; set; } = [];
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace SharpbinV3.Server.Data
|
|||||||
public DbSet<RefreshToken> RefreshTokens => Set<RefreshToken>();
|
public DbSet<RefreshToken> RefreshTokens => Set<RefreshToken>();
|
||||||
public DbSet<UserTotp> UserTotps => Set<UserTotp>();
|
public DbSet<UserTotp> UserTotps => Set<UserTotp>();
|
||||||
public DbSet<Report> Reports => Set<Report>();
|
public DbSet<Report> Reports => Set<Report>();
|
||||||
|
public DbSet<ApiKey> ApiKeys => Set<ApiKey>();
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
@@ -56,6 +57,12 @@ namespace SharpbinV3.Server.Data
|
|||||||
.WithMany(u => u.Reports)
|
.WithMany(u => u.Reports)
|
||||||
.HasForeignKey(r => r.UserUUID)
|
.HasForeignKey(r => r.UserUUID)
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
modelBuilder.Entity<ApiKey>()
|
||||||
|
.HasOne(a => a.User)
|
||||||
|
.WithMany(u => u.ApiKeys)
|
||||||
|
.HasForeignKey(a => a.UserUUID)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Data.Entities
|
||||||
|
{
|
||||||
|
public sealed class ApiKey
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public Guid UUID { get; set; } = Guid.CreateVersion7();
|
||||||
|
public required Guid UserUUID { get; set; }
|
||||||
|
public User? User { get; set; }
|
||||||
|
public required string KeyHash { get; set; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public long CreatedAt { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
|
public long? LastUsedAt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,11 +9,15 @@ namespace SharpbinV3.Server.Data.Entities
|
|||||||
[Index(nameof(AuthorUUID))]
|
[Index(nameof(AuthorUUID))]
|
||||||
[Index(nameof(ExpiresAt))]
|
[Index(nameof(ExpiresAt))]
|
||||||
[Index(nameof(Visibility))]
|
[Index(nameof(Visibility))]
|
||||||
|
[Index(nameof(Syntax))]
|
||||||
|
[Index(nameof(Views))]
|
||||||
|
[Index(nameof(Size))]
|
||||||
public sealed class Paste
|
public sealed class Paste
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int PID { get; set; }
|
public int PID { get; set; }
|
||||||
public required Guid UUID { get; set; } // uuid v7 includes timestamp, this counts as created at
|
public required Guid UUID { get; set; }
|
||||||
|
public long CreatedAt { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
public required string ID { get; set; }
|
public required string ID { get; set; }
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -36,16 +36,12 @@ namespace SharpbinV3.Server.Data.Entities
|
|||||||
public enum ReportStatus
|
public enum ReportStatus
|
||||||
{
|
{
|
||||||
Open,
|
Open,
|
||||||
InProgress,
|
|
||||||
Resolved,
|
|
||||||
Closed
|
Closed
|
||||||
}
|
}
|
||||||
public enum ReportType
|
public enum ReportType
|
||||||
{
|
{
|
||||||
Spam,
|
|
||||||
Abuse,
|
|
||||||
InappropriateContent,
|
|
||||||
CopyrightViolation,
|
CopyrightViolation,
|
||||||
|
IllegalContent,
|
||||||
Fraud,
|
Fraud,
|
||||||
Other
|
Other
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ namespace SharpbinV3.Server.Data.Entities
|
|||||||
{
|
{
|
||||||
public int? UID { get; set; }
|
public int? UID { get; set; }
|
||||||
[Key]
|
[Key]
|
||||||
public required Guid UUID { get; set; } = Guid.CreateVersion7(); // uuid v7 includes timestamp
|
public required Guid UUID { get; set; } = Guid.CreateVersion7();
|
||||||
|
public long CreatedAt { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
public required string Username { get; set; }
|
public required string Username { get; set; }
|
||||||
public required string PasswordHash { get; set; }
|
public required string PasswordHash { get; set; }
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ namespace SharpbinV3.Server.Data.Entities
|
|||||||
public List<Paste> Pastes { get; set; } = [];
|
public List<Paste> Pastes { get; set; } = [];
|
||||||
public List<RefreshToken> RefreshTokens { get; set; } = [];
|
public List<RefreshToken> RefreshTokens { get; set; } = [];
|
||||||
public List<Report> Reports { get; set; } = [];
|
public List<Report> Reports { get; set; } = [];
|
||||||
|
public List<ApiKey> ApiKeys { get; set; } = [];
|
||||||
public UserTotp? Totp { get; set; }
|
public UserTotp? Totp { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,54 @@
|
|||||||
using SharpbinV3.Server.Services;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
using SharpbinV3.Server.Data.Entities;
|
||||||
|
using SharpbinV3.Server.Services;
|
||||||
|
|
||||||
namespace SharpbinV3.Server.Extensions
|
namespace SharpbinV3.Server.Extensions
|
||||||
{
|
{
|
||||||
public static class HttpContextExtensions
|
public static class HttpContextExtensions
|
||||||
{
|
{
|
||||||
public readonly static string[] ipHeaders =
|
public static readonly string[] ipHeaders =
|
||||||
[
|
[
|
||||||
"X-Forwarded-For",
|
"X-Forwarded-For",
|
||||||
"X-Real-IP",
|
"X-Real-IP",
|
||||||
"CF-Connecting-IP",
|
"CF-Connecting-IP",
|
||||||
"True-Client-IP",
|
"True-Client-IP",
|
||||||
"X-Cluster-Client-IP",
|
"X-Cluster-Client-IP",
|
||||||
"X-ProxyUser-IP"
|
"X-ProxyUser-IP",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
private const string ApiKeyContextKey = "ApiKey";
|
||||||
|
|
||||||
|
public static string? GetApiKey(this HttpContext context)
|
||||||
|
{
|
||||||
|
var apiKeyHeader = context.Request.Headers["X-API-Key"].FirstOrDefault();
|
||||||
|
if (string.IsNullOrEmpty(apiKeyHeader))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (apiKeyHeader.Length != ApiKeyService.KeyLength)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return apiKeyHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ApiKey? GetApiKeyFromContext(this HttpContext context)
|
||||||
|
{
|
||||||
|
if (context.Items.TryGetValue(ApiKeyContextKey, out var apiKey))
|
||||||
|
return apiKey as ApiKey;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetApiKeyContext(this HttpContext context, ApiKey apiKey)
|
||||||
|
{
|
||||||
|
context.Items[ApiKeyContextKey] = apiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsApiKeyAuthenticated(this HttpContext context)
|
||||||
|
{
|
||||||
|
return context.GetApiKeyFromContext() != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static JwtUser? GetJwtUser(this HttpContext context)
|
public static JwtUser? GetJwtUser(this HttpContext context)
|
||||||
{
|
{
|
||||||
if (context.User == null || !context.User.Identity?.IsAuthenticated == true)
|
if (context.User == null || !context.User.Identity?.IsAuthenticated == true)
|
||||||
@@ -30,15 +64,13 @@ namespace SharpbinV3.Server.Extensions
|
|||||||
var displayName = claims.FirstOrDefault(c => c.Type == "displayname")?.Value ?? "";
|
var displayName = claims.FirstOrDefault(c => c.Type == "displayname")?.Value ?? "";
|
||||||
var totpEnabled = claims.FirstOrDefault(c => c.Type == "totp_enabled")?.Value == "True";
|
var totpEnabled = claims.FirstOrDefault(c => c.Type == "totp_enabled")?.Value == "True";
|
||||||
|
|
||||||
var roles = claims
|
var roles = claims.Where(c => c.Type == ClaimTypes.Role).Select(c => int.TryParse(c.Value, out var r) ? r : 0).ToArray();
|
||||||
.Where(c => c.Type == ClaimTypes.Role)
|
|
||||||
.Select(c => int.TryParse(c.Value, out var r) ? r : 0)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
var expClaim = claims.FirstOrDefault(c => c.Type == JwtRegisteredClaimNames.Exp)?.Value;
|
var expClaim = claims.FirstOrDefault(c => c.Type == JwtRegisteredClaimNames.Exp)?.Value;
|
||||||
var expires = expClaim != null && long.TryParse(expClaim, out var expUnix)
|
var expires =
|
||||||
? DateTimeOffset.FromUnixTimeSeconds(expUnix).UtcDateTime
|
expClaim != null && long.TryParse(expClaim, out var expUnix)
|
||||||
: DateTime.UtcNow.AddMinutes(15);
|
? DateTimeOffset.FromUnixTimeSeconds(expUnix).UtcDateTime
|
||||||
|
: DateTime.UtcNow.AddMinutes(15);
|
||||||
|
|
||||||
return new JwtUser
|
return new JwtUser
|
||||||
{
|
{
|
||||||
@@ -47,7 +79,7 @@ namespace SharpbinV3.Server.Extensions
|
|||||||
DisplayName = displayName,
|
DisplayName = displayName,
|
||||||
TotpEnabled = totpEnabled,
|
TotpEnabled = totpEnabled,
|
||||||
Roles = roles.Length > 0 ? roles : [0],
|
Roles = roles.Length > 0 ? roles : [0],
|
||||||
Expires = expires
|
Expires = expires,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using SharpbinV3.Server.Extensions;
|
||||||
|
using SharpbinV3.Server.Services;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Middleware
|
||||||
|
{
|
||||||
|
public sealed class ApiKeyAuthenticationMiddleware(RequestDelegate next)
|
||||||
|
{
|
||||||
|
private readonly RequestDelegate _next = next;
|
||||||
|
|
||||||
|
public async Task InvokeAsync(HttpContext context, ApiKeyService apiKeyService)
|
||||||
|
{
|
||||||
|
var apiKeyString = context.GetApiKey();
|
||||||
|
if (!string.IsNullOrEmpty(apiKeyString))
|
||||||
|
{
|
||||||
|
var apiKey = await apiKeyService.GetByKeyAsync(apiKeyString);
|
||||||
|
if (apiKey != null)
|
||||||
|
{
|
||||||
|
context.SetApiKeyContext(apiKey);
|
||||||
|
await apiKeyService.UpdateLastUsedAsync(apiKey.UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _next(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+356
@@ -0,0 +1,356 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SharpbinV3.Server.Data;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20260128093015_IndexSyntaxViewsSize")]
|
||||||
|
partial class IndexSyntaxViewsSize
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "10.0.1");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("PID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AuthorUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Content")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<long?>("EditedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ExpiresAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsCompressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("Size")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Syntax")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("TrueSize")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Views")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("PID");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorUUID");
|
||||||
|
|
||||||
|
b.HasIndex("ExpiresAt");
|
||||||
|
|
||||||
|
b.HasIndex("ID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("PID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Size");
|
||||||
|
|
||||||
|
b.HasIndex("Syntax");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Views");
|
||||||
|
|
||||||
|
b.HasIndex("Visibility");
|
||||||
|
|
||||||
|
b.ToTable("Pastes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ViewedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ViewerHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID", "ViewerHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("PasteViews");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ExpiresAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ReplacedByToken")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Revoked")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("RowVersion")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<string>("TokenHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("TokenHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ReportID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ReporterUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("TargetType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long?>("UpdatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ReportID");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID");
|
||||||
|
|
||||||
|
b.HasIndex("ReportID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ReporterUUID");
|
||||||
|
|
||||||
|
b.HasIndex("TargetType");
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long?>("LastLogin")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string>("Roles")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("UID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("UUID");
|
||||||
|
|
||||||
|
b.HasIndex("UID");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("EncryptedSecret")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.HasKey("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("UserTotps");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Pastes")
|
||||||
|
.HasForeignKey("AuthorUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("PasteViews")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("RefreshTokens")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithOne("Totp")
|
||||||
|
.HasForeignKey("SharpbinV3.Server.Data.Entities.UserTotp", "UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("PasteViews");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Pastes");
|
||||||
|
|
||||||
|
b.Navigation("RefreshTokens");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
|
||||||
|
b.Navigation("Totp");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class IndexSyntaxViewsSize : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Pastes_Size",
|
||||||
|
table: "Pastes",
|
||||||
|
column: "Size");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Pastes_Syntax",
|
||||||
|
table: "Pastes",
|
||||||
|
column: "Syntax");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Pastes_Views",
|
||||||
|
table: "Pastes",
|
||||||
|
column: "Views");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Pastes_Size",
|
||||||
|
table: "Pastes");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Pastes_Syntax",
|
||||||
|
table: "Pastes");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Pastes_Views",
|
||||||
|
table: "Pastes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SharpbinV3.Server.Data;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20260128093730_PasteCreatedAt")]
|
||||||
|
partial class PasteCreatedAt
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "10.0.1");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("PID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AuthorUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Content")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long?>("EditedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ExpiresAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsCompressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("Size")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Syntax")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("TrueSize")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Views")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("PID");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorUUID");
|
||||||
|
|
||||||
|
b.HasIndex("ExpiresAt");
|
||||||
|
|
||||||
|
b.HasIndex("ID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("PID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Size");
|
||||||
|
|
||||||
|
b.HasIndex("Syntax");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Views");
|
||||||
|
|
||||||
|
b.HasIndex("Visibility");
|
||||||
|
|
||||||
|
b.ToTable("Pastes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ViewedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ViewerHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID", "ViewerHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("PasteViews");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ExpiresAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ReplacedByToken")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Revoked")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("RowVersion")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<string>("TokenHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("TokenHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ReportID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ReporterUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("TargetType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long?>("UpdatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ReportID");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID");
|
||||||
|
|
||||||
|
b.HasIndex("ReportID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ReporterUUID");
|
||||||
|
|
||||||
|
b.HasIndex("TargetType");
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long?>("LastLogin")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string>("Roles")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("UID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("UUID");
|
||||||
|
|
||||||
|
b.HasIndex("UID");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("EncryptedSecret")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.HasKey("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("UserTotps");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Pastes")
|
||||||
|
.HasForeignKey("AuthorUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("PasteViews")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("RefreshTokens")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithOne("Totp")
|
||||||
|
.HasForeignKey("SharpbinV3.Server.Data.Entities.UserTotp", "UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("PasteViews");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Pastes");
|
||||||
|
|
||||||
|
b.Navigation("RefreshTokens");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
|
||||||
|
b.Navigation("Totp");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class PasteCreatedAt : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<long>(
|
||||||
|
name: "CreatedAt",
|
||||||
|
table: "Pastes",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CreatedAt",
|
||||||
|
table: "Pastes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,362 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SharpbinV3.Server.Data;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20260128101620_UserCreatedAt")]
|
||||||
|
partial class UserCreatedAt
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "10.0.1");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("PID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AuthorUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Content")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long?>("EditedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ExpiresAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsCompressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("Size")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Syntax")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("TrueSize")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Views")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("PID");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorUUID");
|
||||||
|
|
||||||
|
b.HasIndex("ExpiresAt");
|
||||||
|
|
||||||
|
b.HasIndex("ID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("PID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Size");
|
||||||
|
|
||||||
|
b.HasIndex("Syntax");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Views");
|
||||||
|
|
||||||
|
b.HasIndex("Visibility");
|
||||||
|
|
||||||
|
b.ToTable("Pastes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ViewedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ViewerHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID", "ViewerHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("PasteViews");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ExpiresAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ReplacedByToken")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Revoked")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("RowVersion")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<string>("TokenHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("TokenHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ReportID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ReporterUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("TargetType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long?>("UpdatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ReportID");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID");
|
||||||
|
|
||||||
|
b.HasIndex("ReportID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ReporterUUID");
|
||||||
|
|
||||||
|
b.HasIndex("TargetType");
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long?>("LastLogin")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string>("Roles")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("UID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("UUID");
|
||||||
|
|
||||||
|
b.HasIndex("UID");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("EncryptedSecret")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.HasKey("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("UserTotps");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Pastes")
|
||||||
|
.HasForeignKey("AuthorUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("PasteViews")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("RefreshTokens")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithOne("Totp")
|
||||||
|
.HasForeignKey("SharpbinV3.Server.Data.Entities.UserTotp", "UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("PasteViews");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Pastes");
|
||||||
|
|
||||||
|
b.Navigation("RefreshTokens");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
|
||||||
|
b.Navigation("Totp");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class UserCreatedAt : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<long>(
|
||||||
|
name: "CreatedAt",
|
||||||
|
table: "Users",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CreatedAt",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,405 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SharpbinV3.Server.Data;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20260210231315_AddApiKeys")]
|
||||||
|
partial class AddApiKeys
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "10.0.1");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.ApiKey", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("KeyHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long?>("LastUsedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("UUID");
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("ApiKeys");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("PID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AuthorUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Content")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long?>("EditedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ExpiresAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsCompressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("Size")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Syntax")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("TrueSize")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Views")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("PID");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorUUID");
|
||||||
|
|
||||||
|
b.HasIndex("ExpiresAt");
|
||||||
|
|
||||||
|
b.HasIndex("ID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("PID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Size");
|
||||||
|
|
||||||
|
b.HasIndex("Syntax");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Views");
|
||||||
|
|
||||||
|
b.HasIndex("Visibility");
|
||||||
|
|
||||||
|
b.ToTable("Pastes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ViewedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ViewerHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID", "ViewerHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("PasteViews");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ExpiresAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ReplacedByToken")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Revoked")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("RowVersion")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<string>("TokenHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("TokenHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ReportID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("PastePID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ReporterUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("TargetType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long?>("UpdatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid?>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ReportID");
|
||||||
|
|
||||||
|
b.HasIndex("PastePID");
|
||||||
|
|
||||||
|
b.HasIndex("ReportID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ReporterUUID");
|
||||||
|
|
||||||
|
b.HasIndex("TargetType");
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long?>("LastLogin")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string>("Roles")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("UID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Visibility")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("UUID");
|
||||||
|
|
||||||
|
b.HasIndex("UID");
|
||||||
|
|
||||||
|
b.HasIndex("UUID")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<byte[]>("EncryptedSecret")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.HasKey("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("UserTotps");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.ApiKey", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("ApiKeys")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Pastes")
|
||||||
|
.HasForeignKey("AuthorUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.PasteView", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("PasteViews")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("RefreshTokens")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Report", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.Paste", "Paste")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("PastePID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("Reports")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.Navigation("Paste");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.UserTotp", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithOne("Totp")
|
||||||
|
.HasForeignKey("SharpbinV3.Server.Data.Entities.UserTotp", "UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("PasteViews");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("ApiKeys");
|
||||||
|
|
||||||
|
b.Navigation("Pastes");
|
||||||
|
|
||||||
|
b.Navigation("RefreshTokens");
|
||||||
|
|
||||||
|
b.Navigation("Reports");
|
||||||
|
|
||||||
|
b.Navigation("Totp");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddApiKeys : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ApiKeys",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UUID = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||||
|
UserUUID = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||||
|
KeyHash = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
|
CreatedAt = table.Column<long>(type: "INTEGER", nullable: false),
|
||||||
|
LastUsedAt = table.Column<long>(type: "INTEGER", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ApiKeys", x => x.UUID);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ApiKeys_Users_UserUUID",
|
||||||
|
column: x => x.UserUUID,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "UUID",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ApiKeys_UserUUID",
|
||||||
|
table: "ApiKeys",
|
||||||
|
column: "UserUUID");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ApiKeys");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,36 @@ namespace SharpbinV3.Server.Migrations
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.1");
|
modelBuilder.HasAnnotation("ProductVersion", "10.0.1");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.ApiKey", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UUID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("KeyHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long?>("LastUsedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserUUID")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("UUID");
|
||||||
|
|
||||||
|
b.HasIndex("UserUUID");
|
||||||
|
|
||||||
|
b.ToTable("ApiKeys");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("PID")
|
b.Property<int>("PID")
|
||||||
@@ -30,6 +60,9 @@ namespace SharpbinV3.Server.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("BLOB");
|
.HasColumnType("BLOB");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<long?>("EditedAt")
|
b.Property<long?>("EditedAt")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
@@ -75,9 +108,15 @@ namespace SharpbinV3.Server.Migrations
|
|||||||
b.HasIndex("PID")
|
b.HasIndex("PID")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Size");
|
||||||
|
|
||||||
|
b.HasIndex("Syntax");
|
||||||
|
|
||||||
b.HasIndex("UUID")
|
b.HasIndex("UUID")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Views");
|
||||||
|
|
||||||
b.HasIndex("Visibility");
|
b.HasIndex("Visibility");
|
||||||
|
|
||||||
b.ToTable("Pastes");
|
b.ToTable("Pastes");
|
||||||
@@ -210,6 +249,9 @@ namespace SharpbinV3.Server.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("CreatedAt")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("DisplayName")
|
b.Property<string>("DisplayName")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
@@ -264,6 +306,17 @@ namespace SharpbinV3.Server.Migrations
|
|||||||
b.ToTable("UserTotps");
|
b.ToTable("UserTotps");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.ApiKey", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
|
.WithMany("ApiKeys")
|
||||||
|
.HasForeignKey("UserUUID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
|
||||||
@@ -333,6 +386,8 @@ namespace SharpbinV3.Server.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
|
||||||
{
|
{
|
||||||
|
b.Navigation("ApiKeys");
|
||||||
|
|
||||||
b.Navigation("Pastes");
|
b.Navigation("Pastes");
|
||||||
|
|
||||||
b.Navigation("RefreshTokens");
|
b.Navigation("RefreshTokens");
|
||||||
|
|||||||
+254
-99
@@ -1,9 +1,15 @@
|
|||||||
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.RateLimiting;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.DataProtection;
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using Microsoft.OpenApi;
|
||||||
|
using SharpbinV3.Server.Authentication;
|
||||||
using SharpbinV3.Server.Authorization;
|
using SharpbinV3.Server.Authorization;
|
||||||
using SharpbinV3.Server.Data;
|
using SharpbinV3.Server.Data;
|
||||||
using SharpbinV3.Server.Extensions;
|
using SharpbinV3.Server.Extensions;
|
||||||
@@ -11,9 +17,6 @@ using SharpbinV3.Server.Services;
|
|||||||
using SharpbinV3.Server.Services.Verification;
|
using SharpbinV3.Server.Services.Verification;
|
||||||
using SharpbinV3.Server.Services.Verification.Providers;
|
using SharpbinV3.Server.Services.Verification.Providers;
|
||||||
using SharpbinV3.Server.Settings;
|
using SharpbinV3.Server.Settings;
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Threading.RateLimiting;
|
|
||||||
|
|
||||||
namespace SharpbinV3.Server
|
namespace SharpbinV3.Server
|
||||||
{
|
{
|
||||||
@@ -25,14 +28,39 @@ namespace SharpbinV3.Server
|
|||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
||||||
builder.Services.AddControllers()
|
builder
|
||||||
|
.Services.AddControllers()
|
||||||
.AddJsonOptions(options =>
|
.AddJsonOptions(options =>
|
||||||
{
|
{
|
||||||
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
|
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
|
||||||
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||||
});
|
});
|
||||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||||
builder.Services.AddOpenApi();
|
builder.Services.AddOpenApi(options =>
|
||||||
|
{
|
||||||
|
options.AddDocumentTransformer(
|
||||||
|
(document, context, cancellationToken) =>
|
||||||
|
{
|
||||||
|
document?.Components ??= new();
|
||||||
|
document?.Servers?.Clear();
|
||||||
|
document?.Components?.SecuritySchemes ??= new Dictionary<string, IOpenApiSecurityScheme>();
|
||||||
|
|
||||||
|
document
|
||||||
|
?.Components
|
||||||
|
?.SecuritySchemes
|
||||||
|
?["ApiKey"] = new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Type = SecuritySchemeType.ApiKey,
|
||||||
|
Name = "X-API-Key",
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Description = "Bypass authentication and captcha by providing a valid API key.",
|
||||||
|
};
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services.AddDbContext<AppDbContext>(opt =>
|
builder.Services.AddDbContext<AppDbContext>(opt =>
|
||||||
{
|
{
|
||||||
opt.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"));
|
opt.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"));
|
||||||
@@ -43,101 +71,164 @@ namespace SharpbinV3.Server
|
|||||||
builder.Services.AddScoped<UserService>();
|
builder.Services.AddScoped<UserService>();
|
||||||
builder.Services.AddScoped<AuthService>();
|
builder.Services.AddScoped<AuthService>();
|
||||||
builder.Services.AddScoped<PasteService>();
|
builder.Services.AddScoped<PasteService>();
|
||||||
|
builder.Services.AddScoped<ApiKeyService>();
|
||||||
builder.Services.AddScoped<VerificationService>();
|
builder.Services.AddScoped<VerificationService>();
|
||||||
builder.Services.AddScoped<TotpVerificationProvider>();
|
builder.Services.AddScoped<TotpVerificationProvider>();
|
||||||
builder.Services.AddHttpClient<IVerificationProvider, TurnstileVerificationProvider>();
|
builder.Services.AddHttpClient<IVerificationProvider, TurnstileVerificationProvider>();
|
||||||
builder.Services.AddScoped<ReportService>();
|
builder.Services.AddScoped<ReportService>();
|
||||||
builder.Services.AddMemoryCache();
|
builder.Services.AddMemoryCache();
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
builder.Services.AddHealthChecks()
|
builder.Services.AddHealthChecks().AddDbContextCheck<AppDbContext>("Database");
|
||||||
.AddDbContextCheck<AppDbContext>("Database");
|
|
||||||
|
|
||||||
builder.Services.AddOptions<PasteSettings>()
|
builder
|
||||||
|
.Services.AddOptions<PasteSettings>()
|
||||||
.Bind(builder.Configuration.GetSection("PasteSettings"))
|
.Bind(builder.Configuration.GetSection("PasteSettings"))
|
||||||
.ValidateDataAnnotations()
|
.ValidateDataAnnotations()
|
||||||
.ValidateOnStart();
|
.ValidateOnStart();
|
||||||
builder.Services.AddOptions<JWTSettings>()
|
builder
|
||||||
|
.Services.AddOptions<JWTSettings>()
|
||||||
.Bind(builder.Configuration.GetSection("JwtSettings"))
|
.Bind(builder.Configuration.GetSection("JwtSettings"))
|
||||||
.ValidateDataAnnotations()
|
.ValidateDataAnnotations()
|
||||||
.ValidateOnStart();
|
.ValidateOnStart();
|
||||||
builder.Services.Configure<AuthSettings>(builder.Configuration.GetSection("AuthSettings"));
|
builder.Services.Configure<AuthSettings>(builder.Configuration.GetSection("AuthSettings"));
|
||||||
|
|
||||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
builder
|
||||||
.AddJwtBearer();
|
.Services.AddAuthentication(options =>
|
||||||
|
|
||||||
builder.Services.AddOptions<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme)
|
|
||||||
.Configure<IOptions<JWTSettings>>((options, jwtSettings) =>
|
|
||||||
{
|
{
|
||||||
var settings = jwtSettings.Value;
|
options.DefaultAuthenticateScheme = AuthSchemes.Combined;
|
||||||
var key = Encoding.UTF8.GetBytes(settings.Secret);
|
options.DefaultScheme = AuthSchemes.Combined;
|
||||||
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
options.SaveToken = true;
|
})
|
||||||
options.TokenValidationParameters = new TokenValidationParameters
|
.AddPolicyScheme(
|
||||||
|
AuthSchemes.Combined,
|
||||||
|
AuthSchemes.Combined,
|
||||||
|
options =>
|
||||||
{
|
{
|
||||||
ValidateIssuerSigningKey = true,
|
options.ForwardDefaultSelector = context =>
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(key),
|
{
|
||||||
|
var apiKeyHeader = context.Request.Headers["X-API-Key"].ToString();
|
||||||
|
if (!string.IsNullOrEmpty(apiKeyHeader))
|
||||||
|
return AuthSchemes.ApiKey;
|
||||||
|
|
||||||
ValidateIssuer = true,
|
var authHeader = context.Request.Headers.Authorization.ToString();
|
||||||
ValidIssuer = settings.Issuer,
|
if (!string.IsNullOrEmpty(authHeader) && authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
||||||
|
return JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
|
||||||
ValidateAudience = true,
|
return JwtBearerDefaults.AuthenticationScheme;
|
||||||
ValidAudience = settings.Audience,
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.AddJwtBearer()
|
||||||
|
.AddScheme<AuthenticationSchemeOptions, ApiKeyAuthenticationHandler>(AuthSchemes.ApiKey, _ => { });
|
||||||
|
|
||||||
RequireExpirationTime = true,
|
builder
|
||||||
ValidateLifetime = true,
|
.Services.AddOptions<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme)
|
||||||
ClockSkew = TimeSpan.Zero,
|
.Configure<IOptions<JWTSettings>>(
|
||||||
|
(options, jwtSettings) =>
|
||||||
|
{
|
||||||
|
var settings = jwtSettings.Value;
|
||||||
|
var key = Encoding.UTF8.GetBytes(settings.Secret);
|
||||||
|
|
||||||
RequireSignedTokens = true,
|
options.SaveToken = true;
|
||||||
ValidAlgorithms = [SecurityAlgorithms.HmacSha256]
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
};
|
{
|
||||||
});
|
ValidateIssuerSigningKey = true,
|
||||||
|
IssuerSigningKey = new SymmetricSecurityKey(key),
|
||||||
|
|
||||||
builder.Services.AddAuthorizationBuilder()
|
ValidateIssuer = true,
|
||||||
.AddPolicy("NotBanned", policy =>
|
ValidIssuer = settings.Issuer,
|
||||||
policy.Requirements.Add(new NotBannedRequirement()));
|
|
||||||
builder.Services.AddAuthorizationBuilder()
|
ValidateAudience = true,
|
||||||
.AddPolicy("AuthAndNotBanned", policy =>
|
ValidAudience = settings.Audience,
|
||||||
policy.Requirements.Add(new NotBannedRequirement()));
|
|
||||||
|
RequireExpirationTime = true,
|
||||||
|
ValidateLifetime = true,
|
||||||
|
ClockSkew = TimeSpan.Zero,
|
||||||
|
|
||||||
|
RequireSignedTokens = true,
|
||||||
|
ValidAlgorithms = [SecurityAlgorithms.HmacSha256],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
builder.Services.AddAuthorizationBuilder().AddPolicy("NotBanned", policy => policy.Requirements.Add(new NotBannedRequirement()));
|
||||||
|
builder.Services.AddAuthorizationBuilder().AddPolicy("AuthAndNotBanned", policy => policy.Requirements.Add(new NotBannedRequirement()));
|
||||||
|
builder
|
||||||
|
.Services.AddAuthorizationBuilder()
|
||||||
|
.AddPolicy(
|
||||||
|
"JwtOnly",
|
||||||
|
policy =>
|
||||||
|
{
|
||||||
|
policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme);
|
||||||
|
policy.RequireAuthenticatedUser();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
builder
|
||||||
|
.Services.AddAuthorizationBuilder()
|
||||||
|
.AddPolicy(
|
||||||
|
"JwtOnlyAndNotBanned",
|
||||||
|
policy =>
|
||||||
|
{
|
||||||
|
policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme);
|
||||||
|
policy.RequireAuthenticatedUser();
|
||||||
|
policy.Requirements.Add(new NotBannedRequirement());
|
||||||
|
}
|
||||||
|
);
|
||||||
builder.Services.AddSingleton<IAuthorizationHandler>(new NotBannedHandler(false));
|
builder.Services.AddSingleton<IAuthorizationHandler>(new NotBannedHandler(false));
|
||||||
builder.Services.AddSingleton<IAuthorizationHandler>(new NotBannedHandler(true));
|
builder.Services.AddSingleton<IAuthorizationHandler>(new NotBannedHandler(true));
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddRateLimiter(options =>
|
builder.Services.AddRateLimiter(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy("Sliding", httpContext =>
|
options.AddPolicy(
|
||||||
RateLimitPartition.GetSlidingWindowLimiter(httpContext.GetRequestIP(), _ => new SlidingWindowRateLimiterOptions
|
"Sliding",
|
||||||
{
|
httpContext =>
|
||||||
Window = TimeSpan.FromSeconds(10),
|
RateLimitPartition.GetSlidingWindowLimiter(
|
||||||
PermitLimit = 10,
|
httpContext.GetRequestIP(),
|
||||||
QueueLimit = 2,
|
_ => new SlidingWindowRateLimiterOptions
|
||||||
SegmentsPerWindow = 5,
|
{
|
||||||
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
Window = TimeSpan.FromSeconds(10),
|
||||||
}
|
PermitLimit = 10,
|
||||||
));
|
QueueLimit = 2,
|
||||||
|
SegmentsPerWindow = 5,
|
||||||
|
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
options.AddPolicy("Strict", httpContext =>
|
options.AddPolicy(
|
||||||
RateLimitPartition.GetTokenBucketLimiter(httpContext.GetRequestIP(), _ => new TokenBucketRateLimiterOptions
|
"Strict",
|
||||||
{
|
httpContext =>
|
||||||
TokenLimit = 5,
|
RateLimitPartition.GetTokenBucketLimiter(
|
||||||
QueueLimit = 0,
|
httpContext.GetRequestIP(),
|
||||||
TokensPerPeriod = 1,
|
_ => new TokenBucketRateLimiterOptions
|
||||||
ReplenishmentPeriod = TimeSpan.FromSeconds(30),
|
{
|
||||||
AutoReplenishment = true,
|
TokenLimit = 5,
|
||||||
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
QueueLimit = 0,
|
||||||
}
|
TokensPerPeriod = 1,
|
||||||
));
|
ReplenishmentPeriod = TimeSpan.FromSeconds(30),
|
||||||
|
AutoReplenishment = true,
|
||||||
|
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
options.AddPolicy("Sensitive", httpContext =>
|
options.AddPolicy(
|
||||||
RateLimitPartition.GetTokenBucketLimiter(httpContext.GetRequestIP(), _ => new TokenBucketRateLimiterOptions
|
"Sensitive",
|
||||||
{
|
httpContext =>
|
||||||
TokenLimit = 3,
|
RateLimitPartition.GetTokenBucketLimiter(
|
||||||
QueueLimit = 0,
|
httpContext.GetRequestIP(),
|
||||||
TokensPerPeriod = 1,
|
_ => new TokenBucketRateLimiterOptions
|
||||||
ReplenishmentPeriod = TimeSpan.FromMinutes(1),
|
{
|
||||||
AutoReplenishment = true,
|
TokenLimit = 3,
|
||||||
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
QueueLimit = 0,
|
||||||
}
|
TokensPerPeriod = 1,
|
||||||
));
|
ReplenishmentPeriod = TimeSpan.FromMinutes(1),
|
||||||
|
AutoReplenishment = true,
|
||||||
|
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
options.AddPolicy("NoLimit", _ => RateLimitPartition.GetNoLimiter(0));
|
options.AddPolicy("NoLimit", _ => RateLimitPartition.GetNoLimiter(0));
|
||||||
|
|
||||||
@@ -145,51 +236,61 @@ namespace SharpbinV3.Server
|
|||||||
{
|
{
|
||||||
var remoteIp = httpContext.GetRequestIP();
|
var remoteIp = httpContext.GetRequestIP();
|
||||||
|
|
||||||
return RateLimitPartition.GetFixedWindowLimiter(remoteIp, _ => new FixedWindowRateLimiterOptions
|
return RateLimitPartition.GetFixedWindowLimiter(
|
||||||
{
|
remoteIp,
|
||||||
PermitLimit = 100,
|
_ => new FixedWindowRateLimiterOptions
|
||||||
Window = TimeSpan.FromMinutes(1),
|
{
|
||||||
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
PermitLimit = 100,
|
||||||
QueueLimit = 0
|
Window = TimeSpan.FromMinutes(1),
|
||||||
});
|
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
|
||||||
|
QueueLimit = 0,
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
|
options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
|
||||||
options.OnRejected = async (context, cancellationToken) =>
|
options.OnRejected = async (context, cancellationToken) =>
|
||||||
{
|
{
|
||||||
await context.HttpContext.Response.WriteAsJsonAsync(new
|
await context.HttpContext.Response.WriteAsJsonAsync(
|
||||||
{
|
new { success = false, Message = "Too many requests. Please try again later." },
|
||||||
success = false,
|
cancellationToken: cancellationToken
|
||||||
Message = "Too many requests. Please try again later."
|
);
|
||||||
}, cancellationToken: cancellationToken);
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
builder.Services.AddCors(o =>
|
builder.Services.AddOutputCache(options =>
|
||||||
{
|
{
|
||||||
o.AddDefaultPolicy(p =>
|
options.AddPolicy(
|
||||||
p.WithOrigins("http://localhost:5173")
|
"1Day",
|
||||||
.AllowAnyHeader()
|
builder =>
|
||||||
.AllowAnyMethod());
|
{
|
||||||
|
builder.Expire(TimeSpan.FromDays(1));
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddDataProtection()
|
builder.Services.AddCors(o =>
|
||||||
|
{
|
||||||
|
o.AddDefaultPolicy(p => p.WithOrigins("http://localhost:5173").AllowAnyHeader().AllowAnyMethod());
|
||||||
|
});
|
||||||
|
|
||||||
|
builder
|
||||||
|
.Services.AddDataProtection()
|
||||||
.PersistKeysToFileSystem(GetDataProtectionKeyDirectory(builder.Environment))
|
.PersistKeysToFileSystem(GetDataProtectionKeyDirectory(builder.Environment))
|
||||||
.SetApplicationName("SharpbinV3");
|
.SetApplicationName("SharpbinV3");
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.UseRateLimiter();
|
app.UseRateLimiter();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
app.MapOpenApi();
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.MapOpenApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
app.UseCors();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.UseOutputCache();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
@@ -198,7 +299,8 @@ namespace SharpbinV3.Server
|
|||||||
db.Database.Migrate();
|
db.Database.Migrate();
|
||||||
|
|
||||||
// this is temporary since the migration doesnt seem to work properly
|
// this is temporary since the migration doesnt seem to work properly
|
||||||
db.Database.ExecuteSql($"""
|
db.Database.ExecuteSql(
|
||||||
|
$"""
|
||||||
CREATE TRIGGER IF NOT EXISTS Users_UID_AutoIncrement
|
CREATE TRIGGER IF NOT EXISTS Users_UID_AutoIncrement
|
||||||
AFTER INSERT ON Users
|
AFTER INSERT ON Users
|
||||||
BEGIN
|
BEGIN
|
||||||
@@ -208,22 +310,75 @@ namespace SharpbinV3.Server
|
|||||||
)
|
)
|
||||||
WHERE rowid = NEW.rowid AND NEW.UID IS NULL;
|
WHERE rowid = NEW.rowid AND NEW.UID IS NULL;
|
||||||
END;
|
END;
|
||||||
""");
|
"""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.MapHealthChecks("/health");
|
app.MapHealthChecks("/health");
|
||||||
|
|
||||||
|
app.MapGet(
|
||||||
|
"/api/stats",
|
||||||
|
async (AppDbContext db) =>
|
||||||
|
{
|
||||||
|
var now = DateTimeOffset.UtcNow;
|
||||||
|
var todayStart = new DateTimeOffset(now.Year, now.Month, now.Day, 0, 0, 0, TimeSpan.Zero);
|
||||||
|
var sevenDaysAgo = todayStart.AddDays(-6).ToUnixTimeMilliseconds();
|
||||||
|
|
||||||
|
var pasteCount = await db.Pastes.CountAsync();
|
||||||
|
var userCount = await db.Users.CountAsync();
|
||||||
|
var totalPasteSize = await db.Pastes.SumAsync(p => p.Size);
|
||||||
|
var trueTotalPasteSize = await db.Pastes.SumAsync(p => p.TrueSize);
|
||||||
|
|
||||||
|
var dailyCounts = await db
|
||||||
|
.Pastes.Where(p => p.CreatedAt >= sevenDaysAgo)
|
||||||
|
.GroupBy(p => p.CreatedAt / 86400000)
|
||||||
|
.Select(g => new { Day = g.Key, Count = g.Count() })
|
||||||
|
.ToDictionaryAsync(x => x.Day, x => x.Count);
|
||||||
|
|
||||||
|
var dailyStats = new List<object>();
|
||||||
|
var pasteCountWeek = 0;
|
||||||
|
|
||||||
|
for (int i = 6; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var dayTs = todayStart.AddDays(-i).ToUnixTimeMilliseconds();
|
||||||
|
dailyCounts.TryGetValue(dayTs / 86400000, out var count);
|
||||||
|
|
||||||
|
dailyStats.Add(new { date = dayTs, count });
|
||||||
|
pasteCountWeek += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Ok(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
stats = new
|
||||||
|
{
|
||||||
|
pastes = new
|
||||||
|
{
|
||||||
|
total = pasteCount,
|
||||||
|
past7Days = pasteCountWeek,
|
||||||
|
totalSizeInBytes = totalPasteSize,
|
||||||
|
trueTotalSizeInBytes = trueTotalPasteSize,
|
||||||
|
daily = dailyStats,
|
||||||
|
},
|
||||||
|
users = new { total = userCount },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.CacheOutput(policy => policy.Expire(TimeSpan.FromHours(6)).Tag("stats"));
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
static DirectoryInfo GetDataProtectionKeyDirectory(IHostEnvironment env)
|
static DirectoryInfo GetDataProtectionKeyDirectory(IHostEnvironment env)
|
||||||
{
|
{
|
||||||
var overridepath = Environment.GetEnvironmentVariable("DATA_PROTECTION_KEY_PATH");
|
var overridepath = Environment.GetEnvironmentVariable("DATA_PROTECTION_KEY_PATH");
|
||||||
if (!string.IsNullOrEmpty(overridepath))
|
if (!string.IsNullOrEmpty(overridepath))
|
||||||
return new DirectoryInfo(overridepath);
|
return new DirectoryInfo(overridepath);
|
||||||
|
|
||||||
var basePath = env.IsDevelopment()
|
var basePath = env.IsDevelopment() ? Environment.CurrentDirectory : Environment.SpecialFolder.ApplicationData.ToString();
|
||||||
? Environment.CurrentDirectory
|
|
||||||
: Environment.SpecialFolder.ApplicationData.ToString();
|
|
||||||
|
|
||||||
var path = Path.Combine(basePath, "SharpbinV3", "DataProtectionKeys");
|
var path = Path.Combine(basePath, "SharpbinV3", "DataProtectionKeys");
|
||||||
|
|
||||||
|
|||||||
@@ -15,15 +15,6 @@ The server configuration is managed in `appsettings.json`. For development, ensu
|
|||||||
|
|
||||||
- `ConnectionStrings__DefaultConnection`: SQLite connection string (e.g., `Data Source=/app/data/sharpbin.db`).
|
- `ConnectionStrings__DefaultConnection`: SQLite connection string (e.g., `Data Source=/app/data/sharpbin.db`).
|
||||||
- `JwtSettings__Secret`: A secure string used for signing JWT tokens.
|
- `JwtSettings__Secret`: A secure string used for signing JWT tokens.
|
||||||
- `AuthSettings__CF_Turnstile_SecretKey`: Your Cloudflare Turnstile secret key.
|
|
||||||
- `AuthSettings__CF_Turnstile_SiteKey`: Your Cloudflare Turnstile site key.
|
|
||||||
- `AuthSettings__Registration_Enabled`: Set to `true` by default, enables/disables registration.
|
|
||||||
- `AuthSettings__First_User_Admin`: Gives the first user the admin role, it is recommended to disable this after use.
|
|
||||||
- `AuthSettings__Admins_Require_2FA`: Enforces Admins to have 2FA when trying to do certain actions.
|
|
||||||
- `PasteSettings__MaxTitleLength`: Max title length in characters.
|
|
||||||
- `PasteSettings__MaxPasteSizeInBytes`: Max Paste Size set in bytes, the default is `1_048_576` (1MB)
|
|
||||||
- `PasteSettings__EnablePasteCompression`: Enables/Disables server-side paste compression, `true` by default.
|
|
||||||
- `PasteSettings__RequiresVerification`: Enables/Disables CAPTCHA verification when creating pastes, `true` by default.
|
|
||||||
- `PasteSettings__View_HMAC_Secret`: Required to securely hash viewer identifiers
|
- `PasteSettings__View_HMAC_Secret`: Required to securely hash viewer identifiers
|
||||||
- `PasteSettings__View_Internal_API_Key`: Enforces views to be counted/recorded only by the frontend, if set it needs to be the same for both backend and frontend.
|
- `PasteSettings__View_Internal_API_Key`: Enforces views to be counted/recorded only by the frontend, if set it needs to be the same for both backend and frontend.
|
||||||
|
|
||||||
@@ -43,13 +34,4 @@ Use the following command to run the server with hot reload:
|
|||||||
dotnet watch run
|
dotnet watch run
|
||||||
```
|
```
|
||||||
|
|
||||||
The API will be accessible at http://localhost:8080 by default (check `Properties/launchSettings.json` or your specific configuration).
|
The API will be accessible at http://localhost:5050 by default (check `Properties/launchSettings.json` or your specific configuration).
|
||||||
|
|
||||||
## Tech Stack
|
|
||||||
|
|
||||||
- ASP.NET Core (Web API)
|
|
||||||
- Entity Framework Core with SQLite
|
|
||||||
- JWT Authentication
|
|
||||||
- BCrypt for password hashing
|
|
||||||
- Health Checks for monitoring
|
|
||||||
- Swagger/OpenAPI for documentation
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using SharpbinV3.Server.Data;
|
||||||
|
using SharpbinV3.Server.Data.Entities;
|
||||||
|
using SharpbinV3.Server.Settings;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Services
|
||||||
|
{
|
||||||
|
public sealed class ApiKeyService(AppDbContext db, IOptions<AuthSettings> authOptions)
|
||||||
|
{
|
||||||
|
private readonly AppDbContext _db = db;
|
||||||
|
private readonly AuthSettings _authSettings = authOptions.Value;
|
||||||
|
|
||||||
|
public const int KeyLength = 64;
|
||||||
|
|
||||||
|
private string ComputeHash(string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_authSettings.API_Key_HMAC_Secret))
|
||||||
|
return Utilities.ComputeSha256(input);
|
||||||
|
else
|
||||||
|
return Utilities.ComputeHmacSha256(input, _authSettings.API_Key_HMAC_Secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ApiKey?> GetByKeyAsync(string key)
|
||||||
|
{
|
||||||
|
var keyHash = ComputeHash(key);
|
||||||
|
return await _db.ApiKeys.Include(a => a.User).FirstOrDefaultAsync(a => a.KeyHash == keyHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(ApiKey apiKey, string key)> CreateAsync(Guid userUUID, string name)
|
||||||
|
{
|
||||||
|
var key = Utilities.GenerateSecureRandomString(KeyLength);
|
||||||
|
var keyHash = ComputeHash(key);
|
||||||
|
|
||||||
|
var apiKey = new ApiKey
|
||||||
|
{
|
||||||
|
UserUUID = userUUID,
|
||||||
|
Name = name,
|
||||||
|
KeyHash = keyHash,
|
||||||
|
};
|
||||||
|
|
||||||
|
_db.ApiKeys.Add(apiKey);
|
||||||
|
await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
return (apiKey, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> DeleteAsync(Guid userUUID, Guid keyUUID)
|
||||||
|
{
|
||||||
|
var apiKey = await _db.ApiKeys.FirstOrDefaultAsync(a => a.UUID == keyUUID && a.UserUUID == userUUID);
|
||||||
|
if (apiKey == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_db.ApiKeys.Remove(apiKey);
|
||||||
|
await _db.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<ApiKey>> GetUserKeysAsync(Guid userUUID)
|
||||||
|
{
|
||||||
|
return await _db.ApiKeys.Where(a => a.UserUUID == userUUID).OrderByDescending(a => a.CreatedAt).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateLastUsedAsync(Guid keyUUID)
|
||||||
|
{
|
||||||
|
var apiKey = await _db.ApiKeys.FirstOrDefaultAsync(a => a.UUID == keyUUID);
|
||||||
|
if (apiKey == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
apiKey.LastUsedAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
|
await _db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Options;
|
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.Auth;
|
using SharpbinV3.Server.DTOs.Auth;
|
||||||
|
using SharpbinV3.Server.Extensions;
|
||||||
using SharpbinV3.Server.Settings;
|
using SharpbinV3.Server.Settings;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Text;
|
|
||||||
using Bcrypt = BCrypt.Net.BCrypt;
|
using Bcrypt = BCrypt.Net.BCrypt;
|
||||||
|
|
||||||
namespace SharpbinV3.Server.Services
|
namespace SharpbinV3.Server.Services
|
||||||
@@ -21,7 +22,13 @@ namespace SharpbinV3.Server.Services
|
|||||||
public int[] Roles { get; set; } = [];
|
public int[] Roles { get; set; } = [];
|
||||||
public DateTime Expires { get; set; }
|
public DateTime Expires { get; set; }
|
||||||
}
|
}
|
||||||
public sealed class AuthService(AppDbContext db, IOptions<JWTSettings> jwtOptions, IOptions<AuthSettings> authOptions, ILogger<AuthService> logger)
|
|
||||||
|
public sealed class AuthService(
|
||||||
|
AppDbContext db,
|
||||||
|
IOptions<JWTSettings> jwtOptions,
|
||||||
|
IOptions<AuthSettings> authOptions,
|
||||||
|
ILogger<AuthService> logger
|
||||||
|
)
|
||||||
{
|
{
|
||||||
private readonly AppDbContext _db = db;
|
private readonly AppDbContext _db = db;
|
||||||
private readonly JWTSettings _jwtSettings = jwtOptions.Value;
|
private readonly JWTSettings _jwtSettings = jwtOptions.Value;
|
||||||
@@ -36,7 +43,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
PasswordHash = Bcrypt.HashPassword(password),
|
PasswordHash = Bcrypt.HashPassword(password),
|
||||||
Email = email,
|
Email = email,
|
||||||
DisplayName = displayName,
|
DisplayName = displayName,
|
||||||
UUID = Guid.CreateVersion7()
|
UUID = Guid.CreateVersion7(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_authSettings.First_User_Admin && !await _db.Users.AnyAsync())
|
if (_authSettings.First_User_Admin && !await _db.Users.AnyAsync())
|
||||||
@@ -46,6 +53,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CreateJWT> GenerateJWTToken(User user)
|
public async Task<CreateJWT> GenerateJWTToken(User user)
|
||||||
{
|
{
|
||||||
var jwtHandler = new JwtSecurityTokenHandler();
|
var jwtHandler = new JwtSecurityTokenHandler();
|
||||||
@@ -58,7 +66,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
new("username", user.Username),
|
new("username", user.Username),
|
||||||
new("displayname", user.DisplayName ?? ""),
|
new("displayname", user.DisplayName ?? ""),
|
||||||
new("totp_enabled", totpEnabled.ToString()),
|
new("totp_enabled", totpEnabled.ToString()),
|
||||||
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
|
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (user.Roles != null)
|
if (user.Roles != null)
|
||||||
@@ -77,17 +85,14 @@ namespace SharpbinV3.Server.Services
|
|||||||
Issuer = _jwtSettings.Issuer,
|
Issuer = _jwtSettings.Issuer,
|
||||||
Audience = _jwtSettings.Audience,
|
Audience = _jwtSettings.Audience,
|
||||||
Expires = DateTime.UtcNow.AddMinutes(15),
|
Expires = DateTime.UtcNow.AddMinutes(15),
|
||||||
SigningCredentials = new SigningCredentials(
|
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature),
|
||||||
new SymmetricSecurityKey(key),
|
|
||||||
SecurityAlgorithms.HmacSha256Signature
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var token = jwtHandler.CreateToken(descriptor);
|
var token = jwtHandler.CreateToken(descriptor);
|
||||||
var jwtToken = jwtHandler.WriteToken(token);
|
var jwtToken = jwtHandler.WriteToken(token);
|
||||||
var jti = claims.First(c => c.Type == JwtRegisteredClaimNames.Jti).Value;
|
var jti = claims.First(c => c.Type == JwtRegisteredClaimNames.Jti).Value;
|
||||||
|
|
||||||
var rawRefreshToken = Utilities.GenerateRandomString(36) + Guid.NewGuid();
|
var rawRefreshToken = Utilities.GenerateSecureRandomString(36) + Guid.NewGuid();
|
||||||
var refreshToken = new RefreshToken
|
var refreshToken = new RefreshToken
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
@@ -97,7 +102,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
CreatedAt = DateTimeOffset.UtcNow,
|
CreatedAt = DateTimeOffset.UtcNow,
|
||||||
ExpiresAt = DateTimeOffset.UtcNow.AddMonths(6),
|
ExpiresAt = DateTimeOffset.UtcNow.AddMonths(6),
|
||||||
Used = false,
|
Used = false,
|
||||||
Revoked = false
|
Revoked = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
await _db.RefreshTokens.AddAsync(refreshToken);
|
await _db.RefreshTokens.AddAsync(refreshToken);
|
||||||
@@ -107,7 +112,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
{
|
{
|
||||||
Token = jwtToken,
|
Token = jwtToken,
|
||||||
Success = true,
|
Success = true,
|
||||||
RefreshToken = rawRefreshToken
|
RefreshToken = rawRefreshToken,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,38 +123,39 @@ namespace SharpbinV3.Server.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var principal = jwtHandler.ValidateToken(token, new TokenValidationParameters
|
var principal = jwtHandler.ValidateToken(
|
||||||
{
|
token,
|
||||||
ValidateIssuerSigningKey = true,
|
new TokenValidationParameters
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(key),
|
{
|
||||||
ValidateIssuer = true,
|
ValidateIssuerSigningKey = true,
|
||||||
ValidIssuer = _jwtSettings.Issuer,
|
IssuerSigningKey = new SymmetricSecurityKey(key),
|
||||||
ValidateAudience = true,
|
ValidateIssuer = true,
|
||||||
ValidAudience = _jwtSettings.Audience,
|
ValidIssuer = _jwtSettings.Issuer,
|
||||||
ClockSkew = TimeSpan.Zero,
|
ValidateAudience = true,
|
||||||
ValidateLifetime = false,
|
ValidAudience = _jwtSettings.Audience,
|
||||||
RequireSignedTokens = true,
|
ClockSkew = TimeSpan.Zero,
|
||||||
ValidAlgorithms = [SecurityAlgorithms.HmacSha256]
|
ValidateLifetime = false,
|
||||||
}, out SecurityToken validatedToken);
|
RequireSignedTokens = true,
|
||||||
|
ValidAlgorithms = [SecurityAlgorithms.HmacSha256],
|
||||||
|
},
|
||||||
|
out SecurityToken validatedToken
|
||||||
|
);
|
||||||
|
|
||||||
var jti = principal.Claims.First(c => c.Type == JwtRegisteredClaimNames.Jti).Value;
|
var jti = principal.Claims.First(c => c.Type == JwtRegisteredClaimNames.Jti).Value;
|
||||||
|
|
||||||
var tokenHash = Utilities.ComputeSha256(refreshToken);
|
var tokenHash = Utilities.ComputeSha256(refreshToken);
|
||||||
|
|
||||||
var storedToken = await _db.RefreshTokens
|
var storedToken = await _db.RefreshTokens.FirstOrDefaultAsync(rt => rt.TokenHash == tokenHash);
|
||||||
.FirstOrDefaultAsync(rt => rt.TokenHash == tokenHash);
|
|
||||||
|
|
||||||
if (storedToken == null
|
if (
|
||||||
|
storedToken == null
|
||||||
|| storedToken.Used
|
|| storedToken.Used
|
||||||
|| storedToken.Revoked
|
|| storedToken.Revoked
|
||||||
|| storedToken.ExpiresAt < DateTimeOffset.UtcNow
|
|| storedToken.ExpiresAt < DateTimeOffset.UtcNow
|
||||||
|| storedToken.JwtId != jti)
|
|| storedToken.JwtId != jti
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return new CreateJWT
|
return new CreateJWT { Success = false, Errors = ["Invalid or expired refresh token."] };
|
||||||
{
|
|
||||||
Success = false,
|
|
||||||
Errors = ["Invalid or expired refresh token."]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
storedToken.Used = true;
|
storedToken.Used = true;
|
||||||
@@ -172,7 +178,6 @@ namespace SharpbinV3.Server.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<User> UpdateUser(User user)
|
public async Task<User> UpdateUser(User user)
|
||||||
{
|
{
|
||||||
var existingUser = await _db.Users.FirstOrDefaultAsync(u => u.UUID == user.UUID) ?? throw new Exception("User not found");
|
var existingUser = await _db.Users.FirstOrDefaultAsync(u => u.UUID == user.UUID) ?? throw new Exception("User not found");
|
||||||
@@ -186,6 +191,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateLoginTime(User user)
|
public async Task UpdateLoginTime(User user)
|
||||||
{
|
{
|
||||||
var existingUser = await _db.Users.FirstOrDefaultAsync(u => u.UUID == user.UUID) ?? throw new Exception("User not found");
|
var existingUser = await _db.Users.FirstOrDefaultAsync(u => u.UUID == user.UUID) ?? throw new Exception("User not found");
|
||||||
@@ -196,6 +202,10 @@ namespace SharpbinV3.Server.Services
|
|||||||
|
|
||||||
public async Task<User?> GetUserFromHttpContext(HttpContext context)
|
public async Task<User?> GetUserFromHttpContext(HttpContext context)
|
||||||
{
|
{
|
||||||
|
var apiKey = context.GetApiKeyFromContext();
|
||||||
|
if (apiKey != null)
|
||||||
|
return await _db.Users.FirstOrDefaultAsync(u => u.UUID == apiKey.UserUUID);
|
||||||
|
|
||||||
var uuidClaim = context.User.Claims.FirstOrDefault(c => c.Type == "uuid")?.Value;
|
var uuidClaim = context.User.Claims.FirstOrDefault(c => c.Type == "uuid")?.Value;
|
||||||
if (uuidClaim == null)
|
if (uuidClaim == null)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
|
||||||
|
|
||||||
namespace SharpbinV3.Server.Services
|
namespace SharpbinV3.Server.Services
|
||||||
{
|
{
|
||||||
public class CompressionService : ICompressionService
|
public class CompressionService : ICompressionService
|
||||||
@@ -21,11 +20,13 @@ namespace SharpbinV3.Server.Services
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Compress(string data)
|
public byte[] Compress(string data)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(data);
|
ArgumentNullException.ThrowIfNull(data);
|
||||||
return Compress(System.Text.Encoding.UTF8.GetBytes(data));
|
return Compress(System.Text.Encoding.UTF8.GetBytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Decompress(byte[] compressedData)
|
public byte[] Decompress(byte[] compressedData)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(compressedData);
|
ArgumentNullException.ThrowIfNull(compressedData);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
public class PasteCleanUpService(IServiceProvider serviceProvider, ILogger<PasteCleanUpService> logger) : BackgroundService
|
public class PasteCleanUpService(IServiceProvider serviceProvider, ILogger<PasteCleanUpService> logger) : BackgroundService
|
||||||
{
|
{
|
||||||
private readonly TimeSpan _period = TimeSpan.FromMinutes(5);
|
private readonly TimeSpan _period = TimeSpan.FromMinutes(5);
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
using var timer = new PeriodicTimer(_period);
|
using var timer = new PeriodicTimer(_period);
|
||||||
|
|||||||
@@ -1,20 +1,32 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using System.Text;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Options;
|
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.Extensions;
|
using SharpbinV3.Server.Extensions;
|
||||||
using SharpbinV3.Server.Settings;
|
using SharpbinV3.Server.Settings;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SharpbinV3.Server.Services
|
namespace SharpbinV3.Server.Services
|
||||||
{
|
{
|
||||||
public sealed class PasteService(AppDbContext db, ICompressionService cs, IOptions<PasteSettings> options)
|
public sealed class PasteService(AppDbContext db, ICompressionService cs, IMemoryCache cache, IOptions<PasteSettings> options)
|
||||||
{
|
{
|
||||||
private readonly AppDbContext _db = db;
|
private readonly AppDbContext _db = db;
|
||||||
private readonly ICompressionService _cs = cs;
|
private readonly ICompressionService _cs = cs;
|
||||||
|
private readonly IMemoryCache _cache = cache;
|
||||||
private readonly PasteSettings _pasteSettings = options.Value;
|
private readonly PasteSettings _pasteSettings = options.Value;
|
||||||
|
private readonly Lock _invalidationLock = new();
|
||||||
|
private readonly HashSet<string> _pasteListCacheKeys = [];
|
||||||
|
|
||||||
public async Task<Paste> Create(User? author, string content, string title, string syntax, int visibility, long expiresAt, bool shouldCompress)
|
public async Task<Paste> Create(
|
||||||
|
User? author,
|
||||||
|
string content,
|
||||||
|
string title,
|
||||||
|
string syntax,
|
||||||
|
int visibility,
|
||||||
|
long expiresAt,
|
||||||
|
bool shouldCompress
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var data = Encoding.UTF8.GetBytes(content);
|
var data = Encoding.UTF8.GetBytes(content);
|
||||||
if (shouldCompress)
|
if (shouldCompress)
|
||||||
@@ -23,7 +35,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
var paste = new Paste
|
var paste = new Paste
|
||||||
{
|
{
|
||||||
UUID = Guid.CreateVersion7(),
|
UUID = Guid.CreateVersion7(),
|
||||||
ID = Utilities.GenerateRandomString(8),
|
ID = Utilities.GenerateSecureRandomString(8),
|
||||||
Title = title,
|
Title = title,
|
||||||
AuthorUUID = author?.UUID,
|
AuthorUUID = author?.UUID,
|
||||||
User = author,
|
User = author,
|
||||||
@@ -42,6 +54,9 @@ namespace SharpbinV3.Server.Services
|
|||||||
_db.Users.Update(author);
|
_db.Users.Update(author);
|
||||||
}
|
}
|
||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
InvalidatePasteListCache();
|
||||||
|
|
||||||
return paste;
|
return paste;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,22 +64,32 @@ namespace SharpbinV3.Server.Services
|
|||||||
{
|
{
|
||||||
_db.Pastes.Remove(paste);
|
_db.Pastes.Remove(paste);
|
||||||
var result = await _db.SaveChangesAsync();
|
var result = await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
InvalidatePasteCache(paste.ID);
|
||||||
|
|
||||||
return result > 0;
|
return result > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Paste> Edit(Paste paste)
|
public async Task<Paste> Edit(Paste paste)
|
||||||
{
|
{
|
||||||
_db.Pastes.Update(paste);
|
_db.Pastes.Update(paste);
|
||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
InvalidatePasteCache(paste.ID);
|
||||||
|
|
||||||
return paste;
|
return paste;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> Exists(string id)
|
public async Task<bool> Exists(string id)
|
||||||
{
|
{
|
||||||
return await _db.Pastes.AnyAsync(p => p.ID == id);
|
return await _db.Pastes.AnyAsync(p => p.ID == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> Exists(Guid uuid)
|
public async Task<bool> Exists(Guid uuid)
|
||||||
{
|
{
|
||||||
return await _db.Pastes.AnyAsync(p => p.UUID == uuid);
|
return await _db.Pastes.AnyAsync(p => p.UUID == uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> EditText(Paste paste, string text)
|
public async Task<bool> EditText(Paste paste, string text)
|
||||||
{
|
{
|
||||||
var data = Encoding.UTF8.GetBytes(text);
|
var data = Encoding.UTF8.GetBytes(text);
|
||||||
@@ -78,13 +103,20 @@ namespace SharpbinV3.Server.Services
|
|||||||
paste.IsCompressed = data.Length < Encoding.UTF8.GetByteCount(text);
|
paste.IsCompressed = data.Length < Encoding.UTF8.GetByteCount(text);
|
||||||
_db.Pastes.Update(paste);
|
_db.Pastes.Update(paste);
|
||||||
var result = await _db.SaveChangesAsync();
|
var result = await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
InvalidatePasteCache(paste.ID);
|
||||||
|
|
||||||
return result > 0;
|
return result > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(Paste? paste, bool alreadyExists)> RecordView(Paste paste, HttpContext context)
|
public async Task<(Paste? paste, bool alreadyExists)> RecordView(Paste paste, HttpContext context)
|
||||||
{
|
{
|
||||||
if (paste == null) return (null, false);
|
if (paste == null)
|
||||||
if (context == null) return (null, false);
|
return (null, false);
|
||||||
if (_pasteSettings.View_HMAC_Secret == null) return (null, false);
|
if (context == null)
|
||||||
|
return (null, false);
|
||||||
|
if (_pasteSettings.View_HMAC_Secret == null)
|
||||||
|
return (null, false);
|
||||||
|
|
||||||
var viewerIp = context.GetRequestIP();
|
var viewerIp = context.GetRequestIP();
|
||||||
var viewerUserAgent = context.Request.Headers.UserAgent.ToString();
|
var viewerUserAgent = context.Request.Headers.UserAgent.ToString();
|
||||||
@@ -99,54 +131,101 @@ namespace SharpbinV3.Server.Services
|
|||||||
if (await _db.PasteViews.AnyAsync(pv => pv.PastePID == paste.PID && pv.ViewerHash == viewerHash))
|
if (await _db.PasteViews.AnyAsync(pv => pv.PastePID == paste.PID && pv.ViewerHash == viewerHash))
|
||||||
return (null, true);
|
return (null, true);
|
||||||
|
|
||||||
_db.PasteViews.Add(new PasteView
|
_db.PasteViews.Add(
|
||||||
{
|
new PasteView
|
||||||
PastePID = paste.PID,
|
{
|
||||||
ViewerHash = viewerHash,
|
PastePID = paste.PID,
|
||||||
ViewedAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
ViewerHash = viewerHash,
|
||||||
});
|
ViewedAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
paste.Views += 1;
|
paste.Views += 1;
|
||||||
_db.Pastes.Update(paste);
|
_db.Pastes.Update(paste);
|
||||||
var result = await _db.SaveChangesAsync();
|
var result = await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
if (result > 0)
|
||||||
|
InvalidatePasteCache(paste.ID);
|
||||||
|
|
||||||
return (result > 0 ? paste : null, result > 0);
|
return (result > 0 ? paste : null, 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);
|
string key = $"v1:paste:{id}";
|
||||||
|
var paste = await _cache.GetOrCreateAsync(
|
||||||
|
key,
|
||||||
|
async entry =>
|
||||||
|
{
|
||||||
|
entry.SetSlidingExpiration(TimeSpan.FromMinutes(10));
|
||||||
|
return await _db.Pastes.Include(p => p.User).FirstOrDefaultAsync(p => p.ID == id);
|
||||||
|
}
|
||||||
|
);
|
||||||
return paste ?? null;
|
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)
|
||||||
{
|
{
|
||||||
var query = _db.Pastes.AsQueryable();
|
string key = $"v1:list:pastes:public={publicOnly}:offset={offset}:count={count}";
|
||||||
if (publicOnly)
|
|
||||||
query = query.Where(p => p.Visibility == 0);
|
|
||||||
|
|
||||||
return await query
|
var pastes = await _cache.GetOrCreateAsync(
|
||||||
.OrderByDescending(p => p.PID)
|
key,
|
||||||
.Skip(offset)
|
async entry =>
|
||||||
.Take(count)
|
{
|
||||||
.Include(p => p.User)
|
entry.SetSlidingExpiration(TimeSpan.FromMinutes(5));
|
||||||
.ToListAsync();
|
|
||||||
|
lock (_invalidationLock)
|
||||||
|
_pasteListCacheKeys.Add(key);
|
||||||
|
|
||||||
|
var query = _db.Pastes.AsQueryable();
|
||||||
|
if (publicOnly)
|
||||||
|
query = query.Where(p => p.Visibility == 0);
|
||||||
|
|
||||||
|
return await query.OrderByDescending(p => p.PID).Skip(offset).Take(count).Include(p => p.User).ToListAsync();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return pastes ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> ValidateSyntax(string syntax)
|
public bool ValidateSyntax(string syntax)
|
||||||
{
|
{
|
||||||
return await Task.FromResult(_pasteSettings.ValidSyntaxLanguages.Contains(syntax));
|
return _pasteSettings.ValidSyntaxLanguages.Contains(syntax);
|
||||||
}
|
}
|
||||||
public async Task<bool> ValidateTitle(string title)
|
|
||||||
|
public bool ValidateTitle(string title)
|
||||||
{
|
{
|
||||||
return await Task.FromResult(title.Length <= _pasteSettings.MaxTitleLength);
|
return title.Length <= _pasteSettings.MaxTitleLength;
|
||||||
}
|
}
|
||||||
public async Task<bool> ValidateVisibility(int visibility)
|
|
||||||
|
public bool ValidateVisibility(int visibility)
|
||||||
{
|
{
|
||||||
return await Task.FromResult(visibility >= 0 && visibility <= 2);
|
return visibility >= 0 && visibility <= 2;
|
||||||
}
|
}
|
||||||
public async Task<bool> ValidateExpiresAt(long expiresAt)
|
|
||||||
|
public bool ValidateExpiresAt(long expiresAt)
|
||||||
{
|
{
|
||||||
if (expiresAt == 0) return true;
|
if (expiresAt == 0)
|
||||||
|
return true;
|
||||||
var currentTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
var currentTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
return await Task.FromResult(expiresAt > currentTime - 1000);
|
return expiresAt > currentTime - 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvalidatePasteCache(string pasteId)
|
||||||
|
{
|
||||||
|
string key = $"v1:paste:{pasteId}";
|
||||||
|
_cache.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvalidatePasteListCache()
|
||||||
|
{
|
||||||
|
lock (_invalidationLock)
|
||||||
|
{
|
||||||
|
foreach (var listKey in _pasteListCacheKeys)
|
||||||
|
_cache.Remove(listKey);
|
||||||
|
|
||||||
|
_pasteListCacheKeys.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,16 @@ using SharpbinV3.Server.Data;
|
|||||||
|
|
||||||
namespace SharpbinV3.Server.Services
|
namespace SharpbinV3.Server.Services
|
||||||
{
|
{
|
||||||
public sealed class PasteViewCleanUpService(
|
public sealed class PasteViewCleanUpService(IServiceProvider serviceProvider, ILogger<PasteViewCleanUpService> logger) : BackgroundService
|
||||||
IServiceProvider serviceProvider,
|
|
||||||
ILogger<PasteViewCleanUpService> logger
|
|
||||||
) : BackgroundService
|
|
||||||
{
|
{
|
||||||
private static readonly TimeSpan Period = TimeSpan.FromHours(1);
|
private static readonly TimeSpan Period = TimeSpan.FromHours(1);
|
||||||
private static readonly long RetentionMs =
|
private static readonly long RetentionMs = (long)TimeSpan.FromDays(7).TotalMilliseconds;
|
||||||
(long)TimeSpan.FromDays(7).TotalMilliseconds;
|
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
using var timer = new PeriodicTimer(Period);
|
using var timer = new PeriodicTimer(Period);
|
||||||
|
|
||||||
while (!stoppingToken.IsCancellationRequested &&
|
while (!stoppingToken.IsCancellationRequested && await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
await timer.WaitForNextTickAsync(stoppingToken))
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -35,16 +30,12 @@ namespace SharpbinV3.Server.Services
|
|||||||
using var scope = serviceProvider.CreateScope();
|
using var scope = serviceProvider.CreateScope();
|
||||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||||
|
|
||||||
var cutoff =
|
var cutoff = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - RetentionMs;
|
||||||
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - RetentionMs;
|
|
||||||
|
|
||||||
var deleted = await db.PasteViews
|
var deleted = await db.PasteViews.Where(v => v.ViewedAt < cutoff).ExecuteDeleteAsync(token);
|
||||||
.Where(v => v.ViewedAt < cutoff)
|
|
||||||
.ExecuteDeleteAsync(token);
|
|
||||||
|
|
||||||
if (deleted > 0)
|
if (deleted > 0)
|
||||||
logger.LogInformation("Deleted {Count} stale paste views", deleted);
|
logger.LogInformation("Deleted {Count} stale paste views", deleted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,9 @@ namespace SharpbinV3.Server.Services
|
|||||||
public class ReportService(AppDbContext db)
|
public class ReportService(AppDbContext db)
|
||||||
{
|
{
|
||||||
private readonly AppDbContext _db = db;
|
private readonly AppDbContext _db = db;
|
||||||
|
|
||||||
private sealed record UserInfo(string Username, string? DisplayName);
|
private sealed record UserInfo(string Username, string? DisplayName);
|
||||||
|
|
||||||
public async Task<Report> CreateReport(Guid reporterUUID, ReportTargetType targetType, Guid userUUID, ReportType type, string description)
|
public async Task<Report> CreateReport(Guid reporterUUID, ReportTargetType targetType, Guid userUUID, ReportType type, string description)
|
||||||
{
|
{
|
||||||
var report = new Report
|
var report = new Report
|
||||||
@@ -17,12 +19,13 @@ namespace SharpbinV3.Server.Services
|
|||||||
TargetType = targetType,
|
TargetType = targetType,
|
||||||
UserUUID = userUUID,
|
UserUUID = userUUID,
|
||||||
Type = type,
|
Type = type,
|
||||||
Description = description
|
Description = description,
|
||||||
};
|
};
|
||||||
await _db.Reports.AddAsync(report);
|
await _db.Reports.AddAsync(report);
|
||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Report> CreateReport(Guid reporterUUID, ReportTargetType targetType, int? pastePID, ReportType type, string description)
|
public async Task<Report> CreateReport(Guid reporterUUID, ReportTargetType targetType, int? pastePID, ReportType type, string description)
|
||||||
{
|
{
|
||||||
var report = new Report
|
var report = new Report
|
||||||
@@ -53,10 +56,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
|
|
||||||
if (query.PasteId != null)
|
if (query.PasteId != null)
|
||||||
{
|
{
|
||||||
q = q.Where(r => _db.Pastes
|
q = q.Where(r => _db.Pastes.Where(p => p.ID == query.PasteId).Select(p => (int?)p.PID).Contains(r.PastePID));
|
||||||
.Where(p => p.ID == query.PasteId)
|
|
||||||
.Select(p => (int?)p.PID)
|
|
||||||
.Contains(r.PastePID));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.TargetType != null)
|
if (query.TargetType != null)
|
||||||
@@ -71,25 +71,16 @@ namespace SharpbinV3.Server.Services
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<ReportResponseDto>> GetPasteReports(ReportQuery query)
|
public async Task<List<ReportResponseDto>> GetPasteReports(ReportQuery query)
|
||||||
{
|
{
|
||||||
query = query with
|
query = query with { TargetType = ReportTargetType.Paste, UserUUID = null };
|
||||||
{
|
|
||||||
TargetType = ReportTargetType.Paste,
|
|
||||||
UserUUID = null
|
|
||||||
};
|
|
||||||
|
|
||||||
return await GetReports(query);
|
return await GetReports(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<ReportResponseDto>> GetUserReports(ReportQuery query)
|
public async Task<List<ReportResponseDto>> GetUserReports(ReportQuery query)
|
||||||
{
|
{
|
||||||
query = query with
|
query = query with { TargetType = ReportTargetType.User, PastePID = null };
|
||||||
{
|
|
||||||
TargetType = ReportTargetType.User,
|
|
||||||
PastePID = null
|
|
||||||
};
|
|
||||||
|
|
||||||
return await GetReports(query);
|
return await GetReports(query);
|
||||||
}
|
}
|
||||||
@@ -109,27 +100,22 @@ namespace SharpbinV3.Server.Services
|
|||||||
CreatedAt = r.CreatedAt,
|
CreatedAt = r.CreatedAt,
|
||||||
UpdatedAt = r.UpdatedAt,
|
UpdatedAt = r.UpdatedAt,
|
||||||
ReporterUUID = r.ReporterUUID,
|
ReporterUUID = r.ReporterUUID,
|
||||||
ReporterUsername = _db.Users
|
ReporterUsername = _db.Users.Where(u => u.UUID == r.ReporterUUID).Select(u => u.Username).FirstOrDefault(),
|
||||||
.Where(u => u.UUID == r.ReporterUUID)
|
ReporterDisplayName = _db.Users.Where(u => u.UUID == r.ReporterUUID).Select(u => u.DisplayName).FirstOrDefault(),
|
||||||
.Select(u => u.Username)
|
|
||||||
.FirstOrDefault(),
|
|
||||||
ReporterDisplayName = _db.Users
|
|
||||||
.Where(u => u.UUID == r.ReporterUUID)
|
|
||||||
.Select(u => u.DisplayName)
|
|
||||||
.FirstOrDefault(),
|
|
||||||
TargetType = r.TargetType,
|
TargetType = r.TargetType,
|
||||||
PasteId = r.Paste != null ? r.Paste.ID : null,
|
PasteId = r.Paste != null ? r.Paste.ID : null,
|
||||||
PasteTitle = r.Paste != null ? r.Paste.Title : null,
|
PasteTitle = r.Paste != null ? r.Paste.Title : null,
|
||||||
UserUUID = r.UserUUID,
|
UserUUID = r.UserUUID,
|
||||||
TargetUsername = r.User != null ? r.User.Username : null,
|
TargetUsername = r.User != null ? r.User.Username : null,
|
||||||
TargetDisplayName = r.User != null ? r.User.DisplayName : null
|
TargetDisplayName = r.User != null ? r.User.DisplayName : null,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(string? Username, string? DisplayName)> GetReporterInfo(Guid reporterUUID)
|
public async Task<(string? Username, string? DisplayName)> GetReporterInfo(Guid reporterUUID)
|
||||||
{
|
{
|
||||||
var info = await _db.Users.AsNoTracking()
|
var info = await _db
|
||||||
|
.Users.AsNoTracking()
|
||||||
.Where(u => u.UUID == reporterUUID)
|
.Where(u => u.UUID == reporterUUID)
|
||||||
.Select(u => new UserInfo(u.Username, u.DisplayName))
|
.Select(u => new UserInfo(u.Username, u.DisplayName))
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
@@ -137,25 +123,19 @@ namespace SharpbinV3.Server.Services
|
|||||||
return info is null ? (null, null) : (info.Username, info.DisplayName);
|
return info is null ? (null, null) : (info.Username, info.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<int> GetReportCount(ReportTargetType targetType)
|
public async Task<int> GetReportCount(ReportTargetType targetType)
|
||||||
{
|
{
|
||||||
return await _db.Reports
|
return await _db.Reports.Where(r => r.TargetType == targetType).CountAsync();
|
||||||
.Where(r => r.TargetType == targetType)
|
|
||||||
.CountAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetReportCountByReporter(Guid reporterUUID)
|
public async Task<int> GetReportCountByReporter(Guid reporterUUID)
|
||||||
{
|
{
|
||||||
return await _db.Reports
|
return await _db.Reports.Where(r => r.ReporterUUID == reporterUUID).CountAsync();
|
||||||
.Where(r => r.ReporterUUID == reporterUUID)
|
|
||||||
.CountAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetReportCount()
|
public async Task<int> GetReportCount()
|
||||||
{
|
{
|
||||||
return await _db.Reports
|
return await _db.Reports.CountAsync();
|
||||||
.CountAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetReportCount(ReportQuery query)
|
public async Task<int> GetReportCount(ReportQuery query)
|
||||||
@@ -165,10 +145,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
|
|
||||||
public async Task<Report?> GetReportByID(int reportID)
|
public async Task<Report?> GetReportByID(int reportID)
|
||||||
{
|
{
|
||||||
return await _db.Reports
|
return await _db.Reports.Include(r => r.User).Include(r => r.Paste).FirstOrDefaultAsync(r => r.ReportID == reportID);
|
||||||
.Include(r => r.User)
|
|
||||||
.Include(r => r.Paste)
|
|
||||||
.FirstOrDefaultAsync(r => r.ReportID == reportID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Report> UpdateReport(Report report)
|
public async Task<Report> UpdateReport(Report report)
|
||||||
@@ -177,6 +154,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> DeleteReport(Report report)
|
public async Task<bool> DeleteReport(Report report)
|
||||||
{
|
{
|
||||||
_db.Reports.Remove(report);
|
_db.Reports.Remove(report);
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
using SharpbinV3.Server.Data;
|
using SharpbinV3.Server.Data;
|
||||||
using SharpbinV3.Server.Data.Entities;
|
using SharpbinV3.Server.Data.Entities;
|
||||||
|
|
||||||
|
|
||||||
namespace SharpbinV3.Server.Services
|
namespace SharpbinV3.Server.Services
|
||||||
{
|
{
|
||||||
public sealed class UserService(AppDbContext db)
|
public sealed class UserService(AppDbContext db)
|
||||||
{
|
{
|
||||||
private readonly AppDbContext _db = db;
|
private readonly AppDbContext _db = db;
|
||||||
|
|
||||||
public Task<User?> GetByUID(int uid, bool withPastes = false)
|
public Task<User?> GetByUID(int uid, bool withPastes = false)
|
||||||
{
|
{
|
||||||
IQueryable<User> query = _db.Users;
|
IQueryable<User> query = _db.Users;
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ using SharpbinV3.Server.Data;
|
|||||||
|
|
||||||
namespace SharpbinV3.Server.Services.Verification.Providers
|
namespace SharpbinV3.Server.Services.Verification.Providers
|
||||||
{
|
{
|
||||||
public sealed class TotpVerificationProvider(AppDbContext db, IDataProtectionProvider dataProtectionProvider, IMemoryCache cache) : IVerificationProvider
|
public sealed class TotpVerificationProvider(AppDbContext db, IDataProtectionProvider dataProtectionProvider, IMemoryCache cache)
|
||||||
|
: IVerificationProvider
|
||||||
{
|
{
|
||||||
private readonly AppDbContext _db = db;
|
private readonly AppDbContext _db = db;
|
||||||
private readonly IDataProtector _protector = dataProtectionProvider.CreateProtector("TotpSecret-v1");
|
private readonly IDataProtector _protector = dataProtectionProvider.CreateProtector("TotpSecret-v1");
|
||||||
@@ -17,11 +18,14 @@ namespace SharpbinV3.Server.Services.Verification.Providers
|
|||||||
|
|
||||||
public async Task<bool> VerifyAsync(VerificationContext ctx)
|
public async Task<bool> VerifyAsync(VerificationContext ctx)
|
||||||
{
|
{
|
||||||
if (ctx.UserUUID is null) return false;
|
if (ctx.UserUUID is null)
|
||||||
if (string.IsNullOrWhiteSpace(ctx.Code)) return false;
|
return false;
|
||||||
|
if (string.IsNullOrWhiteSpace(ctx.Code))
|
||||||
|
return false;
|
||||||
|
|
||||||
var userTotp = await _db.UserTotps.FirstOrDefaultAsync(t => t.UserUUID == ctx.UserUUID.Value);
|
var userTotp = await _db.UserTotps.FirstOrDefaultAsync(t => t.UserUUID == ctx.UserUUID.Value);
|
||||||
if (userTotp is null) return false;
|
if (userTotp is null)
|
||||||
|
return false;
|
||||||
|
|
||||||
var secret = _protector.Unprotect(userTotp.EncryptedSecret);
|
var secret = _protector.Unprotect(userTotp.EncryptedSecret);
|
||||||
if (!VerifyCode(secret, ctx.Code, out var step))
|
if (!VerifyCode(secret, ctx.Code, out var step))
|
||||||
@@ -39,7 +43,14 @@ namespace SharpbinV3.Server.Services.Verification.Providers
|
|||||||
|
|
||||||
public byte[] FromBase32(string base32) => string.IsNullOrWhiteSpace(base32) ? [] : Base32Encoding.ToBytes(base32);
|
public byte[] FromBase32(string base32) => string.IsNullOrWhiteSpace(base32) ? [] : Base32Encoding.ToBytes(base32);
|
||||||
|
|
||||||
public string BuildOtpAuthUri(string issuer, string accountName, string secretBase32, int digits = 6, int period = 30, string algorithm = "SHA1")
|
public string BuildOtpAuthUri(
|
||||||
|
string issuer,
|
||||||
|
string accountName,
|
||||||
|
string secretBase32,
|
||||||
|
int digits = 6,
|
||||||
|
int period = 30,
|
||||||
|
string algorithm = "SHA1"
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var label = Uri.EscapeDataString($"{issuer}:{accountName}");
|
var label = Uri.EscapeDataString($"{issuer}:{accountName}");
|
||||||
var query = $"secret={secretBase32}&issuer={Uri.EscapeDataString(issuer)}&algorithm={algorithm}&digits={digits}&period={period}";
|
var query = $"secret={secretBase32}&issuer={Uri.EscapeDataString(issuer)}&algorithm={algorithm}&digits={digits}&period={period}";
|
||||||
@@ -47,6 +58,7 @@ namespace SharpbinV3.Server.Services.Verification.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Protect(byte[] secret) => _protector.Protect(secret);
|
public byte[] Protect(byte[] secret) => _protector.Protect(secret);
|
||||||
|
|
||||||
public byte[] Unprotect(byte[] protectedSecret) => _protector.Unprotect(protectedSecret);
|
public byte[] Unprotect(byte[] protectedSecret) => _protector.Unprotect(protectedSecret);
|
||||||
|
|
||||||
public bool VerifyWithSecretBase32(string secretBase32, string code, int digits = 6, int period = 30, int window = 1)
|
public bool VerifyWithSecretBase32(string secretBase32, string code, int digits = 6, int period = 30, int window = 1)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Extensions.Options;
|
using System.Text.Json;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using SharpbinV3.Server.DTOs.Auth;
|
using SharpbinV3.Server.DTOs.Auth;
|
||||||
using SharpbinV3.Server.Settings;
|
using SharpbinV3.Server.Settings;
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace SharpbinV3.Server.Services.Verification.Providers
|
namespace SharpbinV3.Server.Services.Verification.Providers
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,8 @@ namespace SharpbinV3.Server.Services.Verification.Providers
|
|||||||
private const string SiteverifyUrl = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
|
private const string SiteverifyUrl = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
|
||||||
|
|
||||||
public int Priority => 1;
|
public int Priority => 1;
|
||||||
public bool IsConfigured => !string.IsNullOrEmpty(_authSettings.CF_Turnstile_SecretKey) && !string.IsNullOrEmpty(_authSettings.CF_Turnstile_SiteKey);
|
public bool IsConfigured =>
|
||||||
|
!string.IsNullOrEmpty(_authSettings.CF_Turnstile_SecretKey) && !string.IsNullOrEmpty(_authSettings.CF_Turnstile_SiteKey);
|
||||||
|
|
||||||
public async Task<bool> VerifyAsync(VerificationContext ctx)
|
public async Task<bool> VerifyAsync(VerificationContext ctx)
|
||||||
{
|
{
|
||||||
@@ -20,11 +21,7 @@ namespace SharpbinV3.Server.Services.Verification.Providers
|
|||||||
if (string.IsNullOrEmpty(ctx.Token))
|
if (string.IsNullOrEmpty(ctx.Token))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var parameters = new Dictionary<string, string>
|
var parameters = new Dictionary<string, string> { { "secret", _authSettings.CF_Turnstile_SecretKey }, { "response", ctx.Token } };
|
||||||
{
|
|
||||||
{ "secret", _authSettings.CF_Turnstile_SecretKey },
|
|
||||||
{ "response", ctx.Token }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(ctx.Ip))
|
if (!string.IsNullOrEmpty(ctx.Ip))
|
||||||
parameters.Add("remoteip", ctx.Ip);
|
parameters.Add("remoteip", ctx.Ip);
|
||||||
|
|||||||
@@ -8,5 +8,4 @@
|
|||||||
public Guid? UserUUID { get; init; }
|
public Guid? UserUUID { get; init; }
|
||||||
public string? Code { get; init; }
|
public string? Code { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ namespace SharpbinV3.Server.Services.Verification
|
|||||||
|
|
||||||
private IVerificationProvider? GetActiveProvider()
|
private IVerificationProvider? GetActiveProvider()
|
||||||
{
|
{
|
||||||
return _providers
|
return _providers.Where(p => p.IsConfigured).OrderByDescending(p => p.Priority).FirstOrDefault();
|
||||||
.Where(p => p.IsConfigured)
|
|
||||||
.OrderByDescending(p => p.Priority)
|
|
||||||
.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> VerifyAsync(VerificationContext context, IVerificationProvider? provider = null)
|
public async Task<bool> VerifyAsync(VerificationContext context, IVerificationProvider? provider = null)
|
||||||
|
|||||||
@@ -7,5 +7,6 @@
|
|||||||
public bool Registration_Enabled { get; set; } = true;
|
public bool Registration_Enabled { get; set; } = true;
|
||||||
public bool First_User_Admin { get; set; } = true;
|
public bool First_User_Admin { get; set; } = true;
|
||||||
public bool Admins_Require_2FA { get; set; } = true;
|
public bool Admins_Require_2FA { get; set; } = true;
|
||||||
|
public string API_Key_HMAC_Secret { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ namespace SharpbinV3.Server.Settings
|
|||||||
{
|
{
|
||||||
[Required, MinLength(32), MaxLength(128)]
|
[Required, MinLength(32), MaxLength(128)]
|
||||||
public string Secret { get; set; } = string.Empty;
|
public string Secret { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required, MaxLength(128)]
|
[Required, MaxLength(128)]
|
||||||
public string Issuer { get; set; } = "SharpbinApi";
|
public string Issuer { get; set; } = "SharpbinApi";
|
||||||
|
|
||||||
[Required, MaxLength(128)]
|
[Required, MaxLength(128)]
|
||||||
public string Audience { get; set; } = "SharpbinClient";
|
public string Audience { get; set; } = "SharpbinClient";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,15 @@ namespace SharpbinV3.Server.Settings
|
|||||||
{
|
{
|
||||||
public class PasteSettings
|
public class PasteSettings
|
||||||
{
|
{
|
||||||
public string[] ValidSyntaxLanguages { get; set; } = [];
|
public HashSet<string> ValidSyntaxLanguages { get; set; } = [];
|
||||||
public int MaxTitleLength { get; set; } = 500;
|
public int MaxTitleLength { get; set; } = 500;
|
||||||
public int MaxPasteSizeInBytes { get; set; } = 1_048_576; // 1 MB
|
public int MaxPasteSizeInBytes { get; set; } = 1_048_576; // 1 MB
|
||||||
public bool EnablePasteCompression { get; set; } = true;
|
public bool EnablePasteCompression { get; set; } = true;
|
||||||
public bool RequiresVerfication { get; set; } = true;
|
public bool RequiresVerification { get; set; } = true;
|
||||||
|
|
||||||
[Required, MinLength(32), MaxLength(128)]
|
[Required, MinLength(32), MaxLength(128)]
|
||||||
public string View_HMAC_Secret { get; set; } = string.Empty;
|
public string View_HMAC_Secret { get; set; } = string.Empty;
|
||||||
|
|
||||||
[MinLength(32), MaxLength(128)]
|
[MinLength(32), MaxLength(128)]
|
||||||
public string View_Internal_API_Key { get; set; } = string.Empty;
|
public string View_Internal_API_Key { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,38 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UserSecretsId>a95b1aac-5cce-4fa9-8056-51f0d045cf2f</UserSecretsId>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
|
||||||
<PropertyGroup>
|
<EnableStaticWebAssets>false</EnableStaticWebAssets>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<EnableDefaultContentItems>false</EnableDefaultContentItems>
|
||||||
<Nullable>enable</Nullable>
|
<AllowMissingPrunePackageData>True</AllowMissingPrunePackageData>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<OpenApiGenerateDocumentsOnBuild>false</OpenApiGenerateDocumentsOnBuild>
|
||||||
<UserSecretsId>a95b1aac-5cce-4fa9-8056-51f0d045cf2f</UserSecretsId>
|
</PropertyGroup>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
|
|
||||||
<EnableStaticWebAssets>false</EnableStaticWebAssets>
|
|
||||||
<EnableDefaultContentItems>false</EnableDefaultContentItems>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.1" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.01" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="10.0.1" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
|
|
||||||
<PackageReference Include="Otp.NET" Version="1.4.1" />
|
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.01" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="10.0.1">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
|
||||||
|
<PackageReference Include="Otp.NET" Version="1.4.1" />
|
||||||
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -10,12 +10,40 @@ namespace SharpbinV3.Server
|
|||||||
var random = new Random();
|
var random = new Random();
|
||||||
return new string([.. Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)])]);
|
return new string([.. Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)])]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GenerateSecureRandomString(int length)
|
||||||
|
{
|
||||||
|
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
Span<byte> buffer = stackalloc byte[128];
|
||||||
|
|
||||||
|
var result = new char[length];
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
while (pos < length)
|
||||||
|
{
|
||||||
|
RandomNumberGenerator.Fill(buffer);
|
||||||
|
|
||||||
|
foreach (byte b in buffer)
|
||||||
|
{
|
||||||
|
if (b >= 248)
|
||||||
|
continue; // 248 is the largest multiple of 62 < 256
|
||||||
|
|
||||||
|
result[pos++] = chars[b % chars.Length];
|
||||||
|
if (pos == length)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new string(result);
|
||||||
|
}
|
||||||
|
|
||||||
public static string ComputeSha256(string input)
|
public static string ComputeSha256(string input)
|
||||||
{
|
{
|
||||||
var inputBytes = System.Text.Encoding.UTF8.GetBytes(input);
|
var inputBytes = System.Text.Encoding.UTF8.GetBytes(input);
|
||||||
var hashBytes = SHA256.HashData(inputBytes);
|
var hashBytes = SHA256.HashData(inputBytes);
|
||||||
return Convert.ToHexString(hashBytes);
|
return Convert.ToHexString(hashBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ComputeHmacSha256(string secret, string input)
|
public static string ComputeHmacSha256(string secret, string input)
|
||||||
{
|
{
|
||||||
var secretBytes = System.Text.Encoding.UTF8.GetBytes(secret);
|
var secretBytes = System.Text.Encoding.UTF8.GetBytes(secret);
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
},
|
},
|
||||||
"AuthSettings": {
|
"AuthSettings": {
|
||||||
"CF_Turnstile_SiteKey": "3x00000000000000000000FF",
|
"CF_Turnstile_SiteKey": "3x00000000000000000000FF",
|
||||||
"CF_Turnstile_SecretKey": "1x0000000000000000000000000000000AA"
|
"CF_Turnstile_SecretKey": "1x0000000000000000000000000000000AA",
|
||||||
|
"Admins_Require_2FA": false
|
||||||
},
|
},
|
||||||
"JwtSettings": {
|
"JwtSettings": {
|
||||||
"Secret": "ad277c181e51d2131017abc53a5805ccb85410ab902d2e1e09266304e4e86d6c38f2b2543b708d678dfdbfb76016dcf568925ddb25dc91638a69e479e31a23c9",
|
"Secret": "ad277c181e51d2131017abc53a5805ccb85410ab902d2e1e09266304e4e86d6c38f2b2543b708d678dfdbfb76016dcf568925ddb25dc91638a69e479e31a23c9",
|
||||||
|
|||||||
@@ -17,156 +17,189 @@
|
|||||||
"PasteSettings": {
|
"PasteSettings": {
|
||||||
"ValidSyntaxLanguages": [
|
"ValidSyntaxLanguages": [
|
||||||
"plaintext",
|
"plaintext",
|
||||||
"abap",
|
"1c",
|
||||||
"actionscript-3",
|
"abnf",
|
||||||
|
"accesslog",
|
||||||
|
"actionscript",
|
||||||
"ada",
|
"ada",
|
||||||
|
"angelscript",
|
||||||
"apache",
|
"apache",
|
||||||
"apex",
|
|
||||||
"apl",
|
|
||||||
"applescript",
|
"applescript",
|
||||||
"ara",
|
"arcade",
|
||||||
"asm",
|
"arduino",
|
||||||
"astro",
|
"arm",
|
||||||
|
"asciidoc",
|
||||||
|
"aspectj",
|
||||||
|
"autohotkey",
|
||||||
|
"autoit",
|
||||||
|
"avrasm",
|
||||||
"awk",
|
"awk",
|
||||||
"ballerina",
|
"bash",
|
||||||
"bat",
|
"basic",
|
||||||
"berry",
|
"bnf",
|
||||||
"bibtex",
|
"brainfuck",
|
||||||
"bicep",
|
|
||||||
"blade",
|
|
||||||
"c",
|
"c",
|
||||||
"cadence",
|
"cpp",
|
||||||
"clarity",
|
"hpp",
|
||||||
|
"csharp",
|
||||||
|
"cal",
|
||||||
|
"cos",
|
||||||
|
"capnproto",
|
||||||
"clojure",
|
"clojure",
|
||||||
"cmake",
|
"cmake",
|
||||||
"cobol",
|
"coffeescript",
|
||||||
"codeql",
|
"coq",
|
||||||
"coffee",
|
"crmsh",
|
||||||
"cpp",
|
|
||||||
"crystal",
|
"crystal",
|
||||||
"csharp",
|
"csp",
|
||||||
"css",
|
"css",
|
||||||
"csv",
|
|
||||||
"cue",
|
|
||||||
"d",
|
"d",
|
||||||
"dart",
|
"dart",
|
||||||
|
"deplhi",
|
||||||
"diff",
|
"diff",
|
||||||
"docker",
|
"django",
|
||||||
"dream-maker",
|
"dns",
|
||||||
|
"dockerfile",
|
||||||
|
"dos",
|
||||||
|
"bat",
|
||||||
|
"dsconfig",
|
||||||
|
"dts",
|
||||||
|
"dust",
|
||||||
|
"ebnf",
|
||||||
"elixir",
|
"elixir",
|
||||||
"elm",
|
"elm",
|
||||||
"erb",
|
|
||||||
"erlang",
|
"erlang",
|
||||||
"fish",
|
"excel",
|
||||||
"fsharp",
|
"fsharp",
|
||||||
"gdresource",
|
"fix",
|
||||||
"gdscript",
|
"flix",
|
||||||
"gdshader",
|
"fortran",
|
||||||
|
"gcode",
|
||||||
|
"gams",
|
||||||
|
"gauss",
|
||||||
"gherkin",
|
"gherkin",
|
||||||
"git-commit",
|
|
||||||
"git-rebase",
|
|
||||||
"glsl",
|
|
||||||
"gnuplot",
|
|
||||||
"go",
|
"go",
|
||||||
|
"golo",
|
||||||
|
"gradle",
|
||||||
"graphql",
|
"graphql",
|
||||||
"groovy",
|
"groovy",
|
||||||
"hack",
|
|
||||||
"haml",
|
"haml",
|
||||||
"handlebars",
|
"handlebars",
|
||||||
"haskell",
|
"haskell",
|
||||||
"hcl",
|
"haxe",
|
||||||
"hjson",
|
|
||||||
"hlsl",
|
|
||||||
"html",
|
"html",
|
||||||
|
"xml",
|
||||||
|
"rss",
|
||||||
|
"atom",
|
||||||
|
"svg",
|
||||||
|
"http",
|
||||||
|
"https",
|
||||||
|
"hy",
|
||||||
|
"inform7",
|
||||||
"ini",
|
"ini",
|
||||||
|
"toml",
|
||||||
|
"irpf90",
|
||||||
"java",
|
"java",
|
||||||
"javascript",
|
"javascript",
|
||||||
"jison",
|
"jolie",
|
||||||
"json",
|
"json",
|
||||||
"json5",
|
"json5",
|
||||||
"jsonc",
|
|
||||||
"jsonnet",
|
|
||||||
"jssm",
|
|
||||||
"jsx",
|
|
||||||
"julia",
|
"julia",
|
||||||
|
"julia-repl",
|
||||||
"kotlin",
|
"kotlin",
|
||||||
|
"lasso",
|
||||||
"latex",
|
"latex",
|
||||||
|
"ldif",
|
||||||
|
"leaf",
|
||||||
"less",
|
"less",
|
||||||
"liquid",
|
|
||||||
"lisp",
|
"lisp",
|
||||||
"logo",
|
"livecodeserver",
|
||||||
|
"livescript",
|
||||||
"lua",
|
"lua",
|
||||||
"makefile",
|
"makefile",
|
||||||
"markdown",
|
"markdown",
|
||||||
"marko",
|
"mathematica",
|
||||||
"matlab",
|
"matlab",
|
||||||
"mdx",
|
"maxima",
|
||||||
|
"mel",
|
||||||
|
"mercury",
|
||||||
|
"mipsasm",
|
||||||
|
"mizar",
|
||||||
|
"mojolicious",
|
||||||
|
"monkey",
|
||||||
|
"moonscript",
|
||||||
|
"n1ql",
|
||||||
"nginx",
|
"nginx",
|
||||||
"nim",
|
"nim",
|
||||||
"nix",
|
"nix",
|
||||||
"objective-c",
|
"nsis",
|
||||||
"objective-cpp",
|
"objectivec",
|
||||||
"ocaml",
|
"ocaml",
|
||||||
"pascal",
|
"glsl",
|
||||||
|
"openscad",
|
||||||
|
"ruleslanguage",
|
||||||
|
"oxygene",
|
||||||
|
"parser3",
|
||||||
"perl",
|
"perl",
|
||||||
|
"pf",
|
||||||
"php",
|
"php",
|
||||||
"plsql",
|
"pony",
|
||||||
"postcss",
|
"postgresql",
|
||||||
"powerquery",
|
|
||||||
"powershell",
|
"powershell",
|
||||||
"prisma",
|
"processing",
|
||||||
"prolog",
|
"prolog",
|
||||||
"proto",
|
"properties",
|
||||||
"pug",
|
"protobuf",
|
||||||
"puppet",
|
"puppet",
|
||||||
"purescript",
|
|
||||||
"python",
|
"python",
|
||||||
|
"profiler",
|
||||||
|
"python-repl",
|
||||||
|
"q",
|
||||||
|
"qml",
|
||||||
"r",
|
"r",
|
||||||
"raku",
|
"reasonml",
|
||||||
"razor",
|
"rib",
|
||||||
"reg",
|
"rsl",
|
||||||
"rel",
|
"graph",
|
||||||
"riscv",
|
|
||||||
"rst",
|
|
||||||
"ruby",
|
"ruby",
|
||||||
"rust",
|
"rust",
|
||||||
"sas",
|
"sas",
|
||||||
"sass",
|
|
||||||
"scala",
|
"scala",
|
||||||
"scheme",
|
"scheme",
|
||||||
|
"scilab",
|
||||||
"scss",
|
"scss",
|
||||||
"shaderlab",
|
|
||||||
"shell",
|
"shell",
|
||||||
|
"smali",
|
||||||
"smalltalk",
|
"smalltalk",
|
||||||
"solidity",
|
"sml",
|
||||||
"sparql",
|
|
||||||
"sql",
|
"sql",
|
||||||
"ssh-config",
|
"stan",
|
||||||
"stata",
|
"stata",
|
||||||
|
"step21",
|
||||||
"stylus",
|
"stylus",
|
||||||
|
"subunit",
|
||||||
"svelte",
|
"svelte",
|
||||||
"swift",
|
"swift",
|
||||||
"system-verilog",
|
|
||||||
"tasl",
|
|
||||||
"tcl",
|
"tcl",
|
||||||
"tex",
|
"tap",
|
||||||
"toml",
|
"thrift",
|
||||||
"tsx",
|
"toit",
|
||||||
"turtle",
|
"tp",
|
||||||
"twig",
|
"twig",
|
||||||
"typescript",
|
"typescript",
|
||||||
"v",
|
"vala",
|
||||||
"vb",
|
"vbnet",
|
||||||
|
"vba",
|
||||||
|
"vbscript",
|
||||||
"verilog",
|
"verilog",
|
||||||
"vhdl",
|
"vhdl",
|
||||||
"viml",
|
"vim",
|
||||||
"vue",
|
"axapta",
|
||||||
"wasm",
|
"x86asm",
|
||||||
"wenyan",
|
"xl",
|
||||||
"xml",
|
"xquery",
|
||||||
"xsl",
|
|
||||||
"yaml",
|
"yaml",
|
||||||
"zenscript"
|
"zephir"
|
||||||
],
|
],
|
||||||
"MaxPasteSizeBytes": 1048576,
|
"MaxPasteSizeBytes": 1048576,
|
||||||
"MaxTitleLength": 500
|
"MaxTitleLength": 500
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"csharpier": {
|
||||||
|
"version": "1.2.6",
|
||||||
|
"commands": [
|
||||||
|
"csharpier"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
|
},
|
||||||
|
"dotnet-ef": {
|
||||||
|
"version": "10.0.3",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-ef"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user