diff --git a/backend/.gitignore b/backend/.gitignore index ea8c4bf..8b0c561 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1 +1,2 @@ /target +*.env \ No newline at end of file diff --git a/backend/:database.db/000036.sst b/backend/:database.db/000036.sst deleted file mode 100644 index b89b49f..0000000 Binary files a/backend/:database.db/000036.sst and /dev/null differ diff --git a/backend/:database.db/000039.log b/backend/:database.db/000039.log deleted file mode 100644 index 9101dc5..0000000 Binary files a/backend/:database.db/000039.log and /dev/null differ diff --git a/backend/:database.db/CURRENT b/backend/:database.db/CURRENT deleted file mode 100644 index e2c0c4b..0000000 --- a/backend/:database.db/CURRENT +++ /dev/null @@ -1 +0,0 @@ -MANIFEST-000040 diff --git a/backend/:database.db/MANIFEST-000040 b/backend/:database.db/MANIFEST-000040 deleted file mode 100644 index eced684..0000000 Binary files a/backend/:database.db/MANIFEST-000040 and /dev/null differ diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 9a33600..720a50f 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -191,6 +191,9 @@ name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +dependencies = [ + "serde", +] [[package]] name = "ascii-canvas" @@ -445,6 +448,12 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.6.0" @@ -555,6 +564,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "bytecount" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" + [[package]] name = "bytemuck" version = "1.20.0" @@ -576,6 +591,37 @@ dependencies = [ "serde", ] +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", +] + [[package]] name = "castaway" version = "0.2.3" @@ -668,15 +714,20 @@ name = "chatapp-backend" version = "0.1.0" dependencies = [ "chrono", + "dotenv", "futures", "rand", "rocket", + "rocket_cors", "rocket_ws", "serde", "serde_json", + "serenity", "sha2", "surrealdb", "tokio", + "toml", + "tracing-subscriber", ] [[package]] @@ -731,6 +782,17 @@ dependencies = [ "inout", ] +[[package]] +name = "command_attr" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fcc89439e1bb4e19050a9586a767781a3060000d2f3296fd2a40597ad9421c5" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -763,6 +825,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -778,6 +850,24 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -875,6 +965,7 @@ dependencies = [ "lock_api", "once_cell", "parking_lot_core", + "serde", ] [[package]] @@ -925,7 +1016,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b035a542cf7abf01f2e3c4d5a7acbaebfefe120ae4efc7bde3df98186e4b8af7" dependencies = [ - "bitflags", + "bitflags 2.6.0", "proc-macro2", "proc-macro2-diagnostics", "quote", @@ -990,6 +1081,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + [[package]] name = "earcutr" version = "0.4.3" @@ -1046,6 +1143,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + [[package]] name = "event-listener" version = "5.3.1" @@ -1093,6 +1199,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "float_next_after" version = "1.0.0" @@ -1253,6 +1369,15 @@ dependencies = [ "thread_local", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generator" version = "0.7.5" @@ -1603,6 +1728,20 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.31", + "rustls 0.21.12", + "tokio", + "tokio-rustls 0.24.1", +] + [[package]] name = "hyper-rustls" version = "0.27.3" @@ -1618,7 +1757,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.0", "tower-service", - "webpki-roots", + "webpki-roots 0.26.7", ] [[package]] @@ -1957,6 +2096,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "levenshtein" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" + [[package]] name = "lexicmp" version = "0.1.0" @@ -1984,7 +2129,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags", + "bitflags 2.6.0", "libc", ] @@ -2143,6 +2288,21 @@ dependencies = [ "unicase", ] +[[package]] +name = "mini-moka" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c325dfab65f261f386debee8b0969da215b3fa0037e74c8a1234db7ba986d803" +dependencies = [ + "crossbeam-channel", + "crossbeam-utils", + "dashmap", + "skeptic", + "smallvec", + "tagptr", + "triomphe", +] + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -2680,6 +2840,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "pulldown-cmark" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" +dependencies = [ + "bitflags 2.6.0", + "memchr", + "unicase", +] + [[package]] name = "quick_cache" version = "0.5.2" @@ -2838,7 +3009,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags", + "bitflags 2.6.0", ] [[package]] @@ -2925,6 +3096,50 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", + "hyper-rustls 0.24.2", + "ipnet", + "js-sys", + "log", + "mime", + "mime_guess", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls 0.21.12", + "rustls-pemfile 1.0.4", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-rustls 0.24.1", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots 0.25.4", + "winreg", +] + [[package]] name = "reqwest" version = "0.12.9" @@ -2939,7 +3154,7 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "hyper 1.5.1", - "hyper-rustls", + "hyper-rustls 0.27.3", "hyper-util", "ipnet", "js-sys", @@ -2956,7 +3171,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.2", "tokio", "tokio-rustls 0.26.0", "tokio-util", @@ -2966,7 +3181,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots", + "webpki-roots 0.26.7", "windows-registry", ] @@ -3133,6 +3348,23 @@ dependencies = [ "version_check", ] +[[package]] +name = "rocket_cors" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfac3a1df83f8d4fc96aa41dba3b86c786417b7fc0f52ec76295df2ba781aa69" +dependencies = [ + "http 0.2.12", + "log", + "regex", + "rocket", + "serde", + "serde_derive", + "unicase", + "unicase_serde", + "url", +] + [[package]] name = "rocket_http" version = "0.5.1" @@ -3246,7 +3478,7 @@ version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ - "bitflags", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -3265,6 +3497,20 @@ dependencies = [ "sct", ] +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.8", + "subtle", + "zeroize", +] + [[package]] name = "rustls" version = "0.23.19" @@ -3398,6 +3644,16 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "serde", + "zeroize", +] + [[package]] name = "semver" version = "1.0.23" @@ -3431,6 +3687,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_cow" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7bbbec7196bfde255ab54b65e34087c0849629280028238e67ee25d6a4b7da" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.215" @@ -3506,6 +3771,43 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "serenity" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d72ec4323681bf9a3cabe40fd080abc2435859b502a1b5aa9bf693f125bfa76" +dependencies = [ + "arrayvec", + "async-trait", + "base64 0.22.1", + "bitflags 2.6.0", + "bytes", + "chrono", + "command_attr", + "dashmap", + "flate2", + "futures", + "fxhash", + "levenshtein", + "mime_guess", + "parking_lot", + "percent-encoding", + "reqwest 0.11.27", + "secrecy", + "serde", + "serde_cow", + "serde_json", + "static_assertions", + "time", + "tokio", + "tokio-tungstenite 0.21.0", + "tracing", + "typemap_rev", + "typesize", + "url", + "uwl", +] + [[package]] name = "sha1" version = "0.10.6" @@ -3576,6 +3878,21 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "skeptic" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8" +dependencies = [ + "bytecount", + "cargo_metadata", + "error-chain", + "glob", + "pulldown-cmark", + "tempfile", + "walkdir", +] + [[package]] name = "slab" version = "0.4.9" @@ -3693,6 +4010,12 @@ dependencies = [ "loom", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "static_assertions_next" version = "1.1.2" @@ -3788,7 +4111,7 @@ dependencies = [ "path-clean", "pharos", "reblessive", - "reqwest", + "reqwest 0.12.9", "revision", "ring", "rust_decimal", @@ -3929,6 +4252,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "sync_wrapper" version = "1.0.2" @@ -3949,6 +4278,33 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "tap" version = "1.0.1" @@ -4144,6 +4500,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -4174,8 +4541,12 @@ checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", + "rustls 0.22.4", + "rustls-pki-types", "tokio", + "tokio-rustls 0.25.0", "tungstenite 0.21.0", + "webpki-roots 0.26.7", ] [[package]] @@ -4191,7 +4562,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.0", "tungstenite 0.23.0", - "webpki-roots", + "webpki-roots 0.26.7", ] [[package]] @@ -4254,6 +4625,7 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4320,6 +4692,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "triomphe" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" + [[package]] name = "try-lock" version = "0.2.5" @@ -4339,6 +4717,8 @@ dependencies = [ "httparse", "log", "rand", + "rustls 0.22.4", + "rustls-pki-types", "sha1", "thiserror 1.0.69", "url", @@ -4366,12 +4746,47 @@ dependencies = [ "utf-8", ] +[[package]] +name = "typemap_rev" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b08b0c1257381af16a5c3605254d529d3e7e109f3c62befc5d168968192998" + [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typesize" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "549e54551d85ba6718a95333d9bc4367f69793d7aba638de30f8d25a1f554a1d" +dependencies = [ + "chrono", + "dashmap", + "hashbrown 0.14.5", + "mini-moka", + "parking_lot", + "secrecy", + "serde_json", + "time", + "typesize-derive", + "url", +] + +[[package]] +name = "typesize-derive" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9fc0ad9e03a2b0c2e2a0eafaecccef2121829e1ab6ce9c9d790e6c6766bd1c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "ubyte" version = "0.10.4" @@ -4415,6 +4830,16 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" +[[package]] +name = "unicase_serde" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef53697679d874d69f3160af80bc28de12730a985d57bdf2b47456ccb8b11f1" +dependencies = [ + "serde", + "unicase", +] + [[package]] name = "unicode-ident" version = "1.0.14" @@ -4483,6 +4908,7 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -4520,6 +4946,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "uwl" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0" + [[package]] name = "valuable" version = "0.1.0" @@ -4677,6 +5109,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + [[package]] name = "webpki-roots" version = "0.26.7" @@ -4765,6 +5203,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -4913,6 +5360,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "write16" version = "1.0.0" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 87f43f6..206355d 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -14,3 +14,8 @@ surrealdb = "2.1.2" chrono = "0.4.38" rand = "0.8.5" sha2 = "0.10.8" +rocket_cors = "0.6.0-alpha2" +serenity = "0.12.4" +dotenv = "0.15.0" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +toml = "0.8.19" diff --git a/backend/Deploy.toml b/backend/Deploy.toml new file mode 100644 index 0000000..50d07d1 --- /dev/null +++ b/backend/Deploy.toml @@ -0,0 +1,11 @@ +[chatsync] +socket_path = "/tmp/minecraft_chat/chat.sock" + +[discord] +channel_id = 1315044374127841374 + +[server.dev] +url = "http://localhost:8080" + +[server.prod] +url = "https://zxq5.dev" \ No newline at end of file diff --git a/backend/Rocket.toml b/backend/Rocket.toml new file mode 100644 index 0000000..b59e8c7 --- /dev/null +++ b/backend/Rocket.toml @@ -0,0 +1,8 @@ +[default] +address = "0.0.0.0" +port = 8000 + + +[release] +address = "0.0.0.0" +port = 8000 \ No newline at end of file diff --git a/backend/database.db/000127.sst b/backend/database.db/000127.sst new file mode 100644 index 0000000..86054e8 Binary files /dev/null and b/backend/database.db/000127.sst differ diff --git a/backend/database.db/000135.sst b/backend/database.db/000135.sst new file mode 100644 index 0000000..7d86e7d Binary files /dev/null and b/backend/database.db/000135.sst differ diff --git a/backend/database.db/000143.sst b/backend/database.db/000143.sst new file mode 100644 index 0000000..c0410db Binary files /dev/null and b/backend/database.db/000143.sst differ diff --git a/backend/database.db/000151.sst b/backend/database.db/000151.sst new file mode 100644 index 0000000..2c6e1b6 Binary files /dev/null and b/backend/database.db/000151.sst differ diff --git a/backend/:database.db/LOCK b/backend/database.db/000158.log similarity index 100% rename from backend/:database.db/LOCK rename to backend/database.db/000158.log diff --git a/backend/database.db/000159.sst b/backend/database.db/000159.sst new file mode 100644 index 0000000..fe44aac Binary files /dev/null and b/backend/database.db/000159.sst differ diff --git a/backend/database.db/CURRENT b/backend/database.db/CURRENT new file mode 100644 index 0000000..53dc731 --- /dev/null +++ b/backend/database.db/CURRENT @@ -0,0 +1 @@ +MANIFEST-000155 diff --git a/backend/:database.db/IDENTITY b/backend/database.db/IDENTITY similarity index 100% rename from backend/:database.db/IDENTITY rename to backend/database.db/IDENTITY diff --git a/backend/:database.db/LOG b/backend/database.db/LOCK similarity index 100% rename from backend/:database.db/LOG rename to backend/database.db/LOCK diff --git a/backend/:database.db/LOG.old.1733097790180551 b/backend/database.db/LOG similarity index 100% rename from backend/:database.db/LOG.old.1733097790180551 rename to backend/database.db/LOG diff --git a/backend/:database.db/LOG.old.1733153202364941 b/backend/database.db/LOG.old.1733097790180551 similarity index 100% rename from backend/:database.db/LOG.old.1733153202364941 rename to backend/database.db/LOG.old.1733097790180551 diff --git a/backend/:database.db/LOG.old.1733153214576839 b/backend/database.db/LOG.old.1733153202364941 similarity index 100% rename from backend/:database.db/LOG.old.1733153214576839 rename to backend/database.db/LOG.old.1733153202364941 diff --git a/backend/:database.db/LOG.old.1733153244020989 b/backend/database.db/LOG.old.1733153214576839 similarity index 100% rename from backend/:database.db/LOG.old.1733153244020989 rename to backend/database.db/LOG.old.1733153214576839 diff --git a/backend/database.db/LOG.old.1733153244020989 b/backend/database.db/LOG.old.1733153244020989 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733179876786230 b/backend/database.db/LOG.old.1733179876786230 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733239508404847 b/backend/database.db/LOG.old.1733239508404847 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733240000196799 b/backend/database.db/LOG.old.1733240000196799 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733247584505572 b/backend/database.db/LOG.old.1733247584505572 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733247646351434 b/backend/database.db/LOG.old.1733247646351434 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733310950417930 b/backend/database.db/LOG.old.1733310950417930 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733439380076021 b/backend/database.db/LOG.old.1733439380076021 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733533335591798 b/backend/database.db/LOG.old.1733533335591798 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733534082968251 b/backend/database.db/LOG.old.1733534082968251 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733611342201019 b/backend/database.db/LOG.old.1733611342201019 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733611346540264 b/backend/database.db/LOG.old.1733611346540264 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733670041224770 b/backend/database.db/LOG.old.1733670041224770 new file mode 100644 index 0000000..08f8786 --- /dev/null +++ b/backend/database.db/LOG.old.1733670041224770 @@ -0,0 +1 @@ +2024/12/07-22:42:26.540786 140431350968320 [WARN] [db/db_impl/db_impl_open.cc:2254] DB::Open() failed: IO error: While lock file: database.db/LOCK: Resource temporarily unavailable diff --git a/backend/database.db/LOG.old.1733685004656213 b/backend/database.db/LOG.old.1733685004656213 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733697931872539 b/backend/database.db/LOG.old.1733697931872539 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/LOG.old.1733709984460666 b/backend/database.db/LOG.old.1733709984460666 new file mode 100644 index 0000000..e69de29 diff --git a/backend/database.db/MANIFEST-000155 b/backend/database.db/MANIFEST-000155 new file mode 100644 index 0000000..2114c23 Binary files /dev/null and b/backend/database.db/MANIFEST-000155 differ diff --git a/backend/:database.db/OPTIONS-000033 b/backend/database.db/OPTIONS-000149 similarity index 100% rename from backend/:database.db/OPTIONS-000033 rename to backend/database.db/OPTIONS-000149 diff --git a/backend/:database.db/OPTIONS-000042 b/backend/database.db/OPTIONS-000157 similarity index 100% rename from backend/:database.db/OPTIONS-000042 rename to backend/database.db/OPTIONS-000157 diff --git a/backend/sql/functions/auth.surql b/backend/sql/functions/auth.surql index 4ccfa7e..faebcc7 100644 --- a/backend/sql/functions/auth.surql +++ b/backend/sql/functions/auth.surql @@ -1,3 +1,17 @@ +DEFINE FUNCTION auth::credentials::validate($username: string, $password: string) { + LET $user = (SELECT id, passhash FROM User WHERE username = $username)[0]; + IF $user + { + RETURN { + authenticated: crypto::argon2::compare($user.passhash, $password), + id: $user.id + }; + } + ELSE + { NONE } + ; +} + DEFINE FUNCTION auth::sessiontoken::new($user: uuid) { LET $token = rand::string(64); @@ -10,3 +24,76 @@ DEFINE FUNCTION auth::sessiontoken::new($user: uuid) { }; } +DEFINE FUNCTION auth::sessiontoken::validate($token: string) { + LET $exists = (SELECT * FROM SessionToken WHERE token = $token)[0]; + + IF $exists = NONE { + RETURN NONE; + } + + IF time::now() > $exists.expires { + DELETE SessionToken:exists.id; + RETURN NONE; + }; + + RETURN $exists.user; +} + +DEFINE FUNCTION auth::accesstoken::new($user: uuid, $max_uses: option) { + + IF $max_uses = NONE { + LET $max_uses = 1; + }; + + LET $token = rand::string(64); + + CREATE AccessToken CONTENT { + id: rand::uuid::v4(), + max_uses: 1, + token: $token, + created: time::now(), + expires: time::now() + 7d, + creator: Entity:user + uses: 0, + }; + + RETURN $token; +} + + +DEFINE FUNCTION auth::user::signup( + $email: string, + $username: string, + $password: string, + $displayname: option, + $accesstoken: option, +){ + LET $entity_id = rand::uuid::v4(); + + IF $displayname = NONE { + LET $displayname = $username; + }; + + CREATE Entity CONTENT { + id: $entity_id, + deleted: false, + displayname: $displayname, + joined: time::now(), + username: $username, + }; + + LET $human_id = rand::uuid::v4(); + + CREATE Human CONTENT { + id: $human_id, + email: $email, + passhash: crypto::argon2::generate($password), + entity: Entity:entity_id + }; + + IF !$accesstoken = NONE { + RELATE Human:human_id -> UserJoinedBy -> AccessToken:(SELECT id FROM AccessToken WHERE token = $accesstoken)[0] + } + + RETURN $human_id +} diff --git a/backend/sql/functions/message.surql b/backend/sql/functions/message.surql new file mode 100644 index 0000000..7040a34 --- /dev/null +++ b/backend/sql/functions/message.surql @@ -0,0 +1,32 @@ +DEFINE FUNCTION message::send($from: uuid, $channel: uuid, $content: string, $reply_to: option) { + + LET $content_id = rand::uuid::v4(); + CREATE MessageStringContent CONTENT { + id: $content_id, + content: $content + }; + + LET $message_id = rand::uuid::v4(); + CREATE Message CONTENT { + id: $message_id, + channel: Channel:channel, + edited: false, + sent: time::now(), + reply_to: $reply_to, + }; + + RELATE Message:message_id -> HasContent -> MessageStringContent:content_id; + RELATE Entity:from -> SentMessage -> Message:message_id; +} + +DEFINE FUNCTION message::edit($user: uuid, $message: uuid, $content: string) { + LET $id = (SELECT id + FROM Entity:user + ->SentMessage + ->(Message WHERE id = $message) + ->HasContent + ->MessageStringContent)[0]; + + UPDATE MessageStringContent SET content = $content WHERE id = $id.id; + UPDATE Message:message SET edited = true; +} \ No newline at end of file diff --git a/backend/sql/functions/user.surql b/backend/sql/functions/user.surql new file mode 100644 index 0000000..5b38338 --- /dev/null +++ b/backend/sql/functions/user.surql @@ -0,0 +1,51 @@ +DEFINE FUNCTION user::human::new( + $email: string, + $username: string, + $password: string, + $displayname: option, + $accesstoken: option, +){ + LET $entity_id = rand::uuid::v4(); + + IF $displayname = NONE { + LET $displayname = $username; + }; + + CREATE Entity CONTENT { + id: $entity_id, + deleted: false, + displayname: $displayname, + joined: time::now(), + username: $username, + }; + + LET $human_id = rand::uuid::v4(); + + CREATE Human CONTENT { + id: $human_id, + email: $email, + passhash: crypto::argon2::generate($password), + entity: Entity:entity_id + }; + + IF !$accesstoken = NONE { + RELATE Human:human_id -> UserJoinedBy -> AccessToken:(SELECT id FROM AccessToken WHERE token = $accesstoken)[0] + } + + RETURN $human_id +} + +DEFINE FUNCTION objects::human::get($id: uuid) { + + LET $human = (SELECT * FROM Human WHERE id = $id)[0]; + LET $entity = (SELECT * FROM Entity WHERE id = $human.entity)[0]; + + RETURN { + id: $human.id, + email: $human.email, + passhash: $human.passhash, + username: $entity.username, + displayname: $entity.displayname, + joined: $entity.joined + } +} \ No newline at end of file diff --git a/backend/sql/schema/new-connection-2024-12-02.surql b/backend/sql/schema/new-connection-2024-12-02.surql new file mode 100644 index 0000000..9a4bd4a --- /dev/null +++ b/backend/sql/schema/new-connection-2024-12-02.surql @@ -0,0 +1,482 @@ +-- ------------------------------ +-- OPTION +-- ------------------------------ + +OPTION IMPORT; + +-- ------------------------------ +-- FUNCTIONS +-- ------------------------------ + +DEFINE FUNCTION fn::auth::credentials::validate($username: string, $password: string) -> option { + LET $user = (SELECT id, passhash FROM User WHERE username = $username)[0]; + IF $user { + RETURN { + authenticated: crypto::argon2::compare($user.passhash, $password), + id: $user.id + }; + } ELSE { + RETURN NONE + }; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::auth::sessiontoken::new($user: uuid) { + LET $token = rand::string(64); + CREATE SessionToken CONTENT { + created: time::now(), + expires: time::now() + 1w, + id: rand::uuid::v4(), + token: $token, + user: Entity:user + }; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::auth::sessiontoken::validate($token: string) { + LET $exists = (SELECT * FROM SessionToken WHERE token = $token)[0]; + IF $exists = NONE { RETURN NONE; }; + IF time::now() > $exists.expires { + DELETE SessionToken:exists.id; + RETURN NONE; + }; + RETURN $exists.user; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::channel::new() {} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::friend::accept($from: uuid, $to: uuid) { + IF (SELECT * FROM HasFriendRequest WHERE in = Entity:from AND out = Entity:to)[0] = NONE { RETURN NONE; } ELSE { DELETE HasFriendRequest WHERE in = Entity:from AND out = Entity:to; }; + LET $fsid: uuid = rand::uuid::v4(); + CREATE Friendship SET id = $fsid, channel_id = fn::channel::new(), since = time::now(); + + RELATE Entity:from -> HasFriendship -> Friendship:fsid CONTENT { + nickname = Entity:from.displayname + }; + + RELATE Entity:to -> HasFriendship -> Friendship:fsid CONTENT { + nickname = Entity:to.displayname + }; + +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::friend::reject($from: uuid, $to: uuid) { + DELETE Entity:from->FriendRequest WHERE out = Entity:to; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::friend::remove($from: uuid, $to: uuid) { + DELETE Entity:from->HasFriendship->Friendship WHERE <-HasFriendship.out = Entity:to; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::friend::request($from: uuid, $to: uuid) { + RELATE Entity:from -> HasFriendRequest -> Entity:to CONTENT { + created = time::now() + }; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::icon::default() -> string { + RETURN '/static/public/server_default.png'; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::message::edit($user: uuid, $message: uuid, $content: string) { + LET $id = (SELECT id FROM Entity:user->SentMessage->(Message WHERE id = $message)->HasContent->MessageStringContent)[0]; + UPDATE MessageStringContent SET content = $content WHERE id = $id.id; + UPDATE Message:message SET edited = true; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::server::join($entity: uuid, $server: uuid) { + LET $user = (SELECT displayname FROM Entity WHERE id = $entity); + RELATE Entity:entity -> HasServer -> Server:server CONTENT { + joined: time::now(), nickname: $user.displayname + }; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::server::leave($server: uuid, $entity: uuid) { + DELETE HasServer WHERE out = Server:server AND in = Entity:entity; + DELETE HasRole WHERE in = Entity:entity AND ->Role.server = Server:server; +} PERMISSIONS FULL; + + +DEFINE FUNCTION fn::server::new($name: string, $creator: uuid) { + LET $id = rand::uuid::v4(); + CREATE Server CONTENT { + created: time::now(), + icon_uri: fn::icon::default(), + id: $id, + name: $name, + owner: $creator + }; + fn::server::join($id, $creator); +} PERMISSIONS FULL; + +DEFINE FUNCTION fn::sessiontoken::new() -> string { + LET $token = rand::string(64); + CREATE SessionToken CONTENT { + created: time::now(), + expires: time::now() + 1w, + id: rand::uuid::v4(), + token: $token, + user: Entity:user + }; +} PERMISSIONS FULL; + +-- ------------------------------ +-- TABLE: AccessToken +-- ------------------------------ + +DEFINE TABLE AccessToken TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD created ON AccessToken TYPE datetime PERMISSIONS FULL; +DEFINE FIELD creator ON AccessToken TYPE record PERMISSIONS FULL; +DEFINE FIELD expires ON AccessToken TYPE datetime PERMISSIONS FULL; +DEFINE FIELD id ON AccessToken TYPE uuid PERMISSIONS FULL; +DEFINE FIELD max_uses ON AccessToken TYPE option PERMISSIONS FULL; +DEFINE FIELD token ON AccessToken TYPE string PERMISSIONS FULL; +DEFINE FIELD uses ON AccessToken TYPE int PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Channel +-- ------------------------------ + +DEFINE TABLE Channel TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD id ON Channel TYPE uuid PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: DataPool +-- ------------------------------ + +DEFINE TABLE DataPool TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD `value` ON DataPool TYPE string PERMISSIONS FULL; +DEFINE FIELD id ON DataPool TYPE uuid PERMISSIONS FULL; +DEFINE FIELD key ON DataPool TYPE string PERMISSIONS FULL; +DEFINE FIELD owner ON DataPool TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Entity +-- ------------------------------ + +DEFINE TABLE Entity TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD deleted ON Entity TYPE bool VALUE false PERMISSIONS FULL; +DEFINE FIELD displayname ON Entity TYPE string PERMISSIONS FULL; +DEFINE FIELD id ON Entity TYPE uuid PERMISSIONS FULL; +DEFINE FIELD joined ON Entity TYPE datetime PERMISSIONS FULL; +DEFINE FIELD username ON Entity TYPE string PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Faction +-- ------------------------------ + +DEFINE TABLE Faction TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD id ON Faction TYPE uuid PERMISSIONS FULL; +DEFINE FIELD name ON Faction TYPE string PERMISSIONS FULL; +DEFINE FIELD owner ON Faction TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Friendship +-- ------------------------------ + +DEFINE TABLE Friendship TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD dm_channel ON Friendship TYPE record PERMISSIONS FULL; +DEFINE FIELD id ON Friendship TYPE uuid PERMISSIONS FULL; +DEFINE FIELD since ON Friendship TYPE datetime PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: GroupChat +-- ------------------------------ + +DEFINE TABLE GroupChat TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD channel ON GroupChat TYPE record PERMISSIONS FULL; +DEFINE FIELD icon_uri ON GroupChat TYPE string PERMISSIONS FULL; +DEFINE FIELD name ON GroupChat TYPE string PERMISSIONS FULL; +DEFINE FIELD owner ON GroupChat TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasChannel +-- ------------------------------ + +DEFINE TABLE HasChannel TYPE RELATION IN Server OUT Channel SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasChannel TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasChannel TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasContent +-- ------------------------------ + +DEFINE TABLE HasContent TYPE RELATION IN Message OUT MessageStringContent SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasContent TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasContent TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasDomain +-- ------------------------------ + +DEFINE TABLE HasDomain TYPE RELATION IN DataPool OUT Server | GroupChat | Friendship SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasDomain TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasDomain TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasFriendRequest +-- ------------------------------ + +DEFINE TABLE HasFriendRequest TYPE RELATION IN Entity OUT Entity SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD created ON HasFriendRequest TYPE datetime PERMISSIONS FULL; +DEFINE FIELD in ON HasFriendRequest TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasFriendRequest TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasFriendship +-- ------------------------------ + +DEFINE TABLE HasFriendship TYPE RELATION IN Entity OUT Friendship SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasFriendship TYPE record PERMISSIONS FULL; +DEFINE FIELD nickname ON HasFriendship TYPE string PERMISSIONS FULL; +DEFINE FIELD out ON HasFriendship TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasGroupChat +-- ------------------------------ + +DEFINE TABLE HasGroupChat TYPE RELATION IN Entity OUT GroupChat SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasGroupChat TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasGroupChat TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasPermission +-- ------------------------------ + +DEFINE TABLE HasPermission TYPE RELATION IN HasServer | ServerRole OUT Permission SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasPermission TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasPermission TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasRole +-- ------------------------------ + +DEFINE TABLE HasRole TYPE RELATION IN Entity OUT ServerRole SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasRole TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasRole TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasServer +-- ------------------------------ + +DEFINE TABLE HasServer TYPE RELATION IN Entity OUT Server SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasServer TYPE record PERMISSIONS FULL; +DEFINE FIELD joined ON HasServer TYPE datetime PERMISSIONS FULL; +DEFINE FIELD nickname ON HasServer TYPE string PERMISSIONS FULL; +DEFINE FIELD out ON HasServer TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: HasTitle +-- ------------------------------ + +DEFINE TABLE HasTitle TYPE RELATION IN Entity OUT Title SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON HasTitle TYPE record PERMISSIONS FULL; +DEFINE FIELD out ON HasTitle TYPE record PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Human +-- ------------------------------ + +DEFINE TABLE Human TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD email ON Human TYPE string PERMISSIONS FULL; +DEFINE FIELD entity ON Human TYPE record<Entity> PERMISSIONS FULL; +DEFINE FIELD id ON Human TYPE uuid PERMISSIONS FULL; +DEFINE FIELD passhash ON Human TYPE string PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Message +-- ------------------------------ + +DEFINE TABLE Message TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD channel ON Message TYPE record<Channel> PERMISSIONS FULL; +DEFINE FIELD edited ON Message TYPE bool PERMISSIONS FULL; +DEFINE FIELD id ON Message TYPE uuid PERMISSIONS FULL; +DEFINE FIELD reply_to ON Message TYPE option<record<Message>> PERMISSIONS FULL; +DEFINE FIELD sent ON Message TYPE datetime PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: MessageStringContent +-- ------------------------------ + +DEFINE TABLE MessageStringContent TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD content ON MessageStringContent TYPE string PERMISSIONS FULL; +DEFINE FIELD id ON MessageStringContent TYPE uuid PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Permission +-- ------------------------------ + +DEFINE TABLE Permission TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD id ON Permission TYPE uuid PERMISSIONS FULL; +DEFINE FIELD name ON Permission TYPE string PERMISSIONS FULL; +DEFINE FIELD server ON Permission TYPE record<Server> PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Plugin +-- ------------------------------ + +DEFINE TABLE Plugin TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD created ON Plugin TYPE datetime PERMISSIONS FULL; +DEFINE FIELD id ON Plugin TYPE uuid PERMISSIONS FULL; +DEFINE FIELD name ON Plugin TYPE string PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: PluginEntity +-- ------------------------------ + +DEFINE TABLE PluginEntity TYPE RELATION IN Plugin OUT Entity SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON PluginEntity TYPE record<Plugin> PERMISSIONS FULL; +DEFINE FIELD out ON PluginEntity TYPE record<Entity> PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: SentMessage +-- ------------------------------ + +DEFINE TABLE SentMessage TYPE RELATION IN Entity OUT Message SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON SentMessage TYPE record<Entity> PERMISSIONS FULL; +DEFINE FIELD out ON SentMessage TYPE record<Message> PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Server +-- ------------------------------ + +DEFINE TABLE Server TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD created ON Server TYPE datetime PERMISSIONS FULL; +DEFINE FIELD icon_uri ON Server TYPE string PERMISSIONS FULL; +DEFINE FIELD id ON Server TYPE uuid PERMISSIONS FULL; +DEFINE FIELD name ON Server TYPE string PERMISSIONS FULL; +DEFINE FIELD owner ON Server TYPE record<Entity> PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: ServerRole +-- ------------------------------ + +DEFINE TABLE ServerRole TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD colour ON ServerRole TYPE string PERMISSIONS FULL; +DEFINE FIELD name ON ServerRole TYPE string PERMISSIONS FULL; +DEFINE FIELD server ON ServerRole TYPE record<Server> PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: SessionToken +-- ------------------------------ + +DEFINE TABLE SessionToken TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD created ON SessionToken TYPE datetime PERMISSIONS FULL; +DEFINE FIELD expires ON SessionToken TYPE datetime PERMISSIONS FULL; +DEFINE FIELD id ON SessionToken TYPE uuid PERMISSIONS FULL; +DEFINE FIELD token ON SessionToken TYPE string PERMISSIONS FULL; +DEFINE FIELD user ON SessionToken TYPE record<Human> PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: Title +-- ------------------------------ + +DEFINE TABLE Title TYPE NORMAL SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD colour ON Title TYPE string PERMISSIONS FULL; +DEFINE FIELD faction ON Title TYPE record<Faction> PERMISSIONS FULL; +DEFINE FIELD name ON Title TYPE string PERMISSIONS FULL; + + + +-- ------------------------------ +-- TABLE: UserJoinedBy +-- ------------------------------ + +DEFINE TABLE UserJoinedBy TYPE RELATION IN Human OUT AccessToken SCHEMAFULL PERMISSIONS NONE; + +DEFINE FIELD in ON UserJoinedBy TYPE record<Human> PERMISSIONS FULL; +DEFINE FIELD out ON UserJoinedBy TYPE record<AccessToken> PERMISSIONS FULL; + + + diff --git a/backend/src/auth.rs b/backend/src/auth.rs index fc444b7..b0dbf2c 100644 --- a/backend/src/auth.rs +++ b/backend/src/auth.rs @@ -1,14 +1,12 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use rand::{thread_rng, Rng}; -use rocket::{http::{CookieJar, Status}, options, post, request::{FromRequest, Outcome}, serde::json::Json, Request}; +use rocket::{http::{Cookie, CookieJar, Status}, options, post, request::{FromRequest, Outcome}, serde::json::Json, Request}; use serde::Deserialize; use sha2::{Digest, Sha256}; use surrealdb::RecordId; -use crate::{database::DB, user::{ - User, AuthResponse -}}; +use crate::{database::DB, user::User}; #[derive(Deserialize)] pub struct UserLoginForm { @@ -22,45 +20,105 @@ pub fn login_options() -> Status { } -#[post("/login", data = "<user>")] -pub async fn login(user: Json<UserLoginForm>, jar: &CookieJar<'_>) -> Status { - - println!("Logging in: {}", user.username); - - if let Ok(response) = User::authenticate(user.username.clone(), user.password.clone()).await { - if response.matches { - - let token = SessionToken::new(response.user_id).await; - jar.add_private(("auth", token.token)); - println!("success!"); - - return Status::Ok - } else { - println!("does not match"); +#[post("/login", data = "<form>")] +pub async fn login(form: Json<UserLoginForm>, jar: &CookieJar<'_>) -> Status { + match User::login(form.username.clone(), form.password.clone()).await { + Ok(token) => { + println!("logged in"); + jar.add_private(Cookie::new("auth-token", token)); + Status::Ok + } + Err(e) => { + println!("login failed: {}", e); + Status::Unauthorized } - } else { - println!("response err"); } - - println!("failed!"); - return Status::Unauthorized } +#[derive(Deserialize)] +pub struct UserSignupForm { + username: String, + password: String, + token: String, +} + + #[options("/signup")] pub fn signup_options() -> Status { Status::Ok } #[post("/signup", data = "<user>")] -pub async fn signup(user: Json<UserLoginForm>, jar: &CookieJar<'_>) -> Status { - - println!("signing up: {}", user.username); - - User::create(user.username.clone(), user.password.clone()).await; - - login(user, jar).await +pub async fn signup(user: Json<UserSignupForm>, jar: &CookieJar<'_>) -> Status { + match User::signup( + user.username.clone(), + user.username.clone(), + user.password.clone(), + user.username.clone() + ).await { + Ok(token) => { + println!("signed up"); + jar.add_private(Cookie::new("auth-token", token)); + Status::Ok + } + Err(e) => { + println!("signup failed: {}", e); + Status::Conflict + } + } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pub type SessionTokenGuard = User; #[derive(Debug, Clone)] @@ -76,7 +134,7 @@ impl<'r> FromRequest<'r> for SessionTokenGuard { type Error = (); async fn from_request(req: &'r Request<'_>) -> Outcome<Self, Self::Error> { - if let Some(cookie) = req.cookies().get_private("auth") { + if let Some(cookie) = req.cookies().get_private("auth-token") { let token = cookie.value().to_string(); return match DB .query(" diff --git a/backend/src/chatsync/listener.rs b/backend/src/chatsync/listener.rs new file mode 100644 index 0000000..130007e --- /dev/null +++ b/backend/src/chatsync/listener.rs @@ -0,0 +1,133 @@ +use std::{fs, os::unix::fs::PermissionsExt, path::Path}; +use rocket::{get, serde::json::Json}; +use rocket::tokio::{ + self, + net::{UnixListener, UnixStream}, + io::{AsyncReadExt, AsyncWriteExt}, + sync::Mutex, +}; +use std::sync::Arc; +use serde::{Deserialize, Serialize}; +use crate::messenger::MessengerServer; + +const SOCKET_PATH: &str = "/tmp/minecraft_chat/chat.sock"; +const SOCKET_DIR: &str = "/tmp/minecraft_chat"; + +#[derive(Deserialize)] +struct MinecraftMessage { + player: String, + content: String, +} + +#[derive(Serialize)] +struct Response { + status: String, +} + +#[derive(Serialize)] +pub struct Status { + status: String, + timestamp: i64, +} + +// This function ensures the socket directory exists with correct permissions +pub fn init_socket() { + // Create socket directory if it doesn't exist + let socket_dir = "/tmp/minecraft_chat"; + if !std::path::Path::new(socket_dir).exists() { + fs::create_dir(socket_dir).expect("Failed to create socket directory"); + // Set directory permissions to 755 (rwxr-xr-x) + fs::set_permissions(socket_dir, fs::Permissions::from_mode(0o755)) + .expect("Failed to set directory permissions"); + } +} + +pub fn get_socket_path() -> String { + "/tmp/minecraft_chat/chat.sock".to_string() +} + +pub async fn start_unix_socket(messenger: Arc<Mutex<MessengerServer>>) { + // Ensure the socket directory exists with correct permissions + if !Path::new(SOCKET_DIR).exists() { + fs::create_dir(SOCKET_DIR).expect("Failed to create socket directory"); + fs::set_permissions(SOCKET_DIR, fs::Permissions::from_mode(0o755)) + .expect("Failed to set directory permissions"); + } + + // Remove existing socket file if it exists + if Path::new(SOCKET_PATH).exists() { + fs::remove_file(SOCKET_PATH).expect("Failed to remove existing socket"); + } + + // Create and bind to the Unix socket + let listener = UnixListener::bind(SOCKET_PATH).expect("Failed to bind to Unix socket"); + + // Set socket file permissions to 777 for testing (adjust as needed) + fs::set_permissions(SOCKET_PATH, fs::Permissions::from_mode(0o777)) + .expect("Failed to set socket permissions"); + + println!("Unix socket listening at {}", SOCKET_PATH); + + while let Ok((stream, _)) = listener.accept().await { + let messenger = messenger.clone(); + tokio::spawn(async move { + handle_connection(stream, messenger).await; + }); + } +} + +async fn handle_connection(mut stream: UnixStream, messenger: Arc<Mutex<MessengerServer>>) { + let mut buffer = [0; 1024]; + + match stream.read(&mut buffer).await { + Ok(n) => { + if let Ok(message_str) = String::from_utf8(buffer[..n].to_vec()) { + if let Ok(message) = serde_json::from_str::<MinecraftMessage>(&message_str) { + // Forward the message to the chat system + let response = handle_minecraft_message(message, messenger).await; + + // Send response + if let Ok(response_json) = serde_json::to_string(&response) { + let _ = stream.write_all(response_json.as_bytes()).await; + } + } + } + } + Err(e) => eprintln!("Error reading from Unix socket: {}", e), + } +} + +async fn handle_minecraft_message(msg: MinecraftMessage, messenger: Arc<Mutex<MessengerServer>>) -> Response { + // Create a real-time message + use crate::messenger::RealTimeMessage; + use std::time::{SystemTime, UNIX_EPOCH}; + + let message = RealTimeMessage { + message_id: 0, + user_id: "minecraft".to_string(), + display_name: msg.player, + created_at: SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_millis() as i64, + content: msg.content, + }; + + // Send the message to channel 1 (or adjust as needed) + messenger.lock().await.send(1, message).await; + + Response { + status: "ok".to_string(), + } +} + +#[get("/minecraft/chat")] +pub fn chat() -> Json<Status> { + Json(Status { + status: "ok".to_string(), + timestamp: std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_secs() as i64, + }) +} diff --git a/backend/src/chatsync/mod.rs b/backend/src/chatsync/mod.rs new file mode 100644 index 0000000..3aedfef --- /dev/null +++ b/backend/src/chatsync/mod.rs @@ -0,0 +1,31 @@ +pub mod listener; + +use listener::init_socket; +use rocket::fairing::Fairing; +use std::sync::Arc; +use rocket::tokio::sync::Mutex; +use crate::messenger::MessengerServer; + +pub struct ChatSyncFairing { + pub messenger: Arc<Mutex<MessengerServer>>, +} + +#[rocket::async_trait] +impl Fairing for ChatSyncFairing { + fn info(&self) -> rocket::fairing::Info { + rocket::fairing::Info { + name: "Chat Sync", + kind: rocket::fairing::Kind::Liftoff, + } + } + + async fn on_liftoff(&self, _rocket: &rocket::Rocket<rocket::Orbit>) { + let messenger = self.messenger.clone(); + + init_socket(); + + tokio::spawn(async move { + listener::start_unix_socket(messenger).await; + }); + } +} diff --git a/backend/src/config.rs b/backend/src/config.rs new file mode 100644 index 0000000..f3ca2d2 --- /dev/null +++ b/backend/src/config.rs @@ -0,0 +1,77 @@ +use std::sync::LazyLock; +use serde::{Deserialize, Serialize}; +use toml::Table; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Config { + socket_path: String, + channel_id: u64, + pub dev_url: String, + pub prod_url: String +} + +impl Config { + pub fn load() -> Config { + + let content = match std::fs::read_to_string("Deploy.toml") { + Ok(content) => content, + Err(e) => { + eprintln!("Failed to read Deploy.toml: {}", e); + return Config::default(); + }, + }; + + let table: Table = match content.parse::<Table>() { + Ok(table) => table, + Err(e) => { + eprintln!("Failed to parse Deploy.toml: {}", e); + return Config::default(); + }, + }; + + let mut config = Config::default(); + + if let Some(socket_path) = table.get("chatsync") { + if let Some(socket_path) = socket_path.as_table() { + if let Some(path) = socket_path.get("socket_path") { + config.socket_path = path.to_string(); + } + } + } + + // get urls + + if let Some(server) = table.get("server") { + if let Some(server) = server.as_table() { + if let Some(url) = server.get("dev") { + if let Some(url) = url.as_table() { + if let Some(url) = url.get("url") { + config.dev_url = url.to_string(); + println!("OK!") + } + } + } + if let Some(url) = server.get("prod") { + if let Some(url) = url.as_table() { + if let Some(url) = url.get("url") { + config.prod_url = url.to_string(); + } + } + } + } + } + + config + } +} + +impl Default for Config { + fn default() -> Self { + Config { + socket_path: "/tmp/minecraft_chat/chat.sock".to_string(), + channel_id: 1315044374127841374, + dev_url: "http://localhost:8080".to_string(), + prod_url: "https://zxq5.dev".to_string() + } + } +} \ No newline at end of file diff --git a/backend/src/error.rs b/backend/src/error.rs new file mode 100644 index 0000000..13497f4 --- /dev/null +++ b/backend/src/error.rs @@ -0,0 +1,20 @@ +#[derive(Debug)] +pub enum BackendError { + DbError(String), +} + +impl std::fmt::Display for BackendError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + BackendError::DbError(message) => write!(f, "{}", message), + } + } +} + +impl std::error::Error for BackendError {} + +impl From<surrealdb::Error> for BackendError { + fn from(err: surrealdb::Error) -> Self { + BackendError::DbError(err.to_string()) + } +} \ No newline at end of file diff --git a/backend/src/features/memelicense.rs b/backend/src/features/memelicense.rs new file mode 100644 index 0000000..bfc72f3 --- /dev/null +++ b/backend/src/features/memelicense.rs @@ -0,0 +1,5 @@ + +#[get("/license/<username>")] +pub async fn get_meme_license(username: String) -> String { + format!("Meme license for {}", username) +} \ No newline at end of file diff --git a/backend/src/features/mod.rs b/backend/src/features/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/backend/src/main.rs b/backend/src/main.rs index 5dd2fdd..26faa9e 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,43 +1,68 @@ use auth::{login, login_options, signup, signup_options}; -use rocket::{fs::FileServer, launch, routes}; -use std::sync::Arc; +use config::Config; +use rocket::http::Method; use rocket::tokio::sync::Mutex; +use rocket::{fs::FileServer, launch, routes}; +use rocket_cors::{AllowedHeaders, AllowedOrigins, CorsOptions}; +use std::sync::Arc; -mod messenger; mod auth; -mod user; mod database; +mod error; +mod features; +mod messenger; +mod servers; +mod user; +mod chatsync; +mod config; -use messenger::{MessengerServer, connect}; +pub(crate) use error::BackendError; +use messenger::{connect, MessengerServer}; +use chatsync::ChatSyncFairing; #[launch] async fn rocket() -> _ { let messenger = Arc::new(Mutex::new(MessengerServer::new())); + let chat_sync = ChatSyncFairing { + messenger: messenger.clone(), + }; + + let config = Config::load(); + + let cors = CorsOptions::default() + .allowed_origins(AllowedOrigins::some_exact(&[ + &config.dev_url, + &config.prod_url, + ])) + .allowed_methods( + vec![Method::Get, Method::Post, Method::Options] + .into_iter() + .map(From::from) + .collect(), + ) + .allowed_headers(AllowedHeaders::some(&[ + "Authorization", + "Accept", + "Content-Type", + ])) + .allow_credentials(true); database::init().await.unwrap(); rocket::build() - .manage(messenger) - .mount("/", routes![ - connect, - login, - signup, - login_options, - signup_options, - ]) .mount("/static", FileServer::from("static")) - .attach(rocket::fairing::AdHoc::on_response("CORS", |_, res| Box::pin(async move { - res.set_header(rocket::http::Header::new( - "Access-Control-Allow-Origin", - "*" - )); - res.set_header(rocket::http::Header::new( - "Access-Control-Allow-Methods", - "GET, POST, OPTIONS" - )); - res.set_header(rocket::http::Header::new( - "Access-Control-Allow-Headers", - "*" - )); - }))) + .mount( + "/api", + routes![ + connect, + login, + login_options, + signup, + signup_options, + ], + ) + .manage(messenger) + .manage(config) + .attach(cors.to_cors().unwrap()) + .attach(chat_sync) } diff --git a/backend/src/messenger.rs b/backend/src/messenger.rs index 32691ea..18e20f2 100644 --- a/backend/src/messenger.rs +++ b/backend/src/messenger.rs @@ -1,5 +1,6 @@ use std::{collections::HashMap, sync::Arc, time::{SystemTime, UNIX_EPOCH}}; +use chrono::Utc; use rocket::{ futures::{ channel::mpsc, @@ -16,46 +17,49 @@ use rocket::{ use serde::Serialize; use rocket_ws::{Channel, WebSocket, stream::DuplexStream}; -use surrealdb::{RecordId, Uuid}; - +use surrealdb::{RecordId, Uuid, Datetime}; use crate::{auth::SessionTokenGuard, user::User}; +#[get("/messenger/connect/<channel_id>/<user_id>")] +pub async fn connect<'r> ( + // user: SessionTokenGuard, + user_id: String, + ws: WebSocket, + messenger: &'r rocket::State<Arc<Mutex<MessengerServer>>>, + channel_id: i32, + mut shutdown: Shutdown, +) -> Result<Channel<'r>, Status> { + let messenger = Arc::clone(messenger.inner()); + Ok(ws.channel(move | channel| { + Box::pin(async move { -#[get("/messenger/connect/<channel_id>")] - pub async fn connect<'r> ( - user: SessionTokenGuard, - ws: WebSocket, - messenger: &'r rocket::State<Arc<Mutex<MessengerServer>>>, - channel_id: i32, - mut shutdown: Shutdown, - ) -> Result<Channel<'r>, Status> { - - let messenger = Arc::clone(messenger.inner()); - - Ok(ws.channel(move | channel| { - Box::pin(async move { - - let (sender, receiver) = mpsc::channel::<RealTimeMessage>(100); - let (ws_sender, ws_receiver) = channel.split(); - - println!("REGISTERING: {}", user.id); - messenger.lock().await.register(user.id.clone(), channel_id, sender); - - tokio::select! { - _ = inbound_message(ws_receiver, messenger.clone(), channel_id, &user) => {}, - _ = outbound_message(ws_sender, receiver) => {}, - _ = &mut shutdown => {}, - } - - // Once the client disconnects, or the server is shutdown they are deregistered from the channel. - println!("DEREGISTERING: {}", user.id); - messenger.lock().await.deregister(user.id); - Ok(()) - }) - })) - } + let user = User { + id: RecordId::from_table_key("User", Uuid::new_v4().to_string()), + email: "".to_string(), + username: user_id, + passhash: "test".to_string(), + displayname: "test".to_string(), + joined: Datetime::from(Utc::now()), + }; + + let (sender, receiver) = mpsc::channel::<RealTimeMessage>(100); + let (ws_sender, ws_receiver) = channel.split(); + + messenger.lock().await.register(user.id.clone(), channel_id, sender); + + tokio::select! { + _ = inbound_message(ws_receiver, messenger.clone(), channel_id, &user) => {}, + _ = outbound_message(ws_sender, receiver) => {}, + _ = &mut shutdown => {}, + } + + messenger.lock().await.deregister(user.id); + Ok(()) + }) + })) +} @@ -72,7 +76,7 @@ pub async fn inbound_message( let message = RealTimeMessage { message_id: 0, - user_id: user.id.key().to_string(), + user_id: user.id.key().to_string().trim_start_matches('⟨').trim_end_matches('⟩').to_string(), display_name: user.username.clone(), created_at: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as i64, content: text, diff --git a/backend/src/servers.rs b/backend/src/servers.rs new file mode 100644 index 0000000..53f8c40 --- /dev/null +++ b/backend/src/servers.rs @@ -0,0 +1,21 @@ +use rocket::{get, serde::json::Json}; +use serde::Serialize; + +#[get("/servers")] +pub fn servers() -> Json<Vec<Server>> { + Json(vec![ + Server { id: "0".to_string(), name: "Test Server".to_string() }, + Server { id: "1".to_string(), name: "Test Server2".to_string() }, + Server { id: "2".to_string(), name: "Test Server3".to_string() }, + Server { id: "3".to_string(), name: "Test Server4".to_string() }, + Server { id: "4".to_string(), name: "Test Server5".to_string() }, + Server { id: "5".to_string(), name: "Test Server6".to_string() }, + Server { id: "6".to_string(), name: "Test Server7".to_string() }, + ]) +} + +#[derive(Serialize)] +struct Server { + id: String, + name: String, +} \ No newline at end of file diff --git a/backend/src/user.rs b/backend/src/user.rs index 35f9076..0601cf6 100644 --- a/backend/src/user.rs +++ b/backend/src/user.rs @@ -1,78 +1,131 @@ use serde::{Deserialize, Serialize}; -use surrealdb::RecordId; -use crate::database::DB; +use surrealdb::{Datetime, RecordId}; -use chrono::Utc; +use crate::{database::DB, BackendError}; #[derive(Debug, Deserialize, Serialize)] pub struct User { pub id: RecordId, pub username: String, + pub email: String, pub passhash: String, pub displayname: String, - pub joined: i64, + pub joined: Datetime, } -#[derive(Debug, Deserialize)] -pub struct AuthResponse { - pub matches: bool, - pub user_id: RecordId, +#[derive(Debug, Deserialize, Serialize)] +struct Entity { + id: RecordId, + deleted: bool, + displayname: String, + joined: Datetime, + username: String +} + +#[derive(Debug, Deserialize, Serialize)] +struct Human { + id: RecordId, + email: String, + passhash: String } impl User { - pub async fn authenticate(username: String, password: String) -> Result<AuthResponse, ()> { + pub async fn signup( + username: String, + email: String, + password: String, + displayname: String + ) -> Result<String, BackendError> { - match DB - .query(" - LET $user = (SELECT id, passhash FROM User WHERE username = $username)[0]; - RETURN { - matches: crypto::argon2::compare($user.passhash, $password), - user_id: $user.id - }" - ) - .bind(("username", username)) - .bind(("password", password)) - .await - .map_err(|_| ())? - .take::<Option<AuthResponse>>(0) - { - Ok(Some(response)) => Ok(response), - Ok(None) => { - println!("User not found"); - Err(()) - } - Err(e) => { - println!("Error authenticating user: {}", e); - Err(()) - } - _ => Err(()), - } + // let entity = DB + // .create("Entity") + // .content(Entity { + // id: RecordId::from(("Entity", Id::rand())), + // deleted: false, + // displayname: displayname, + // joined: Datetime::now(), + // username: username, + // }) + // .await; + + + + return Ok(String::new()); + + // match DB + // .query(" + // LET $entity_id = CREATE Entity CONTENT { + // deleted: false, + // displayname: $displayname, + // joined: time::now(), + // username: $username, + // } RETURN AFTER.id; + + // LET $human_id = CREATE Human CONTENT { + // email: $email, + // passhash: crypto::argon2::generate($password), + // } RETURN AFTER.id; + + // LET $node1 = type::thing('Entity', $entity_id); + // LET $node2 = type::thing('Human', $human_id); + // RELATE $node2 -> HasEntity -> $node1; + + // LET $session_token = CREATE SessionToken CONTENT { + // id: rand::uuid::v4(), + // created: time::now(), + // expires: time::now() + 7d, + // token: rand::string(64), + // user: type::thing('Human', $human_id), + // } RETURN AFTER.token; + + // RETURN $session_token; + // ") + // .bind(("username", username)) + // .bind(("email", email)) + // .bind(("password", password)) + // .bind(("displayname", displayname)) + // .await + // .unwrap() + // .take::<Option<String>>(0) + // .map_err(|e| BackendError::from(e)) + // { + // Ok(Some(user)) => Ok(user), + // Ok(None) => panic!("NO TOKEN RETURNED"), + // _ => Err(BackendError::DbError("Failed to create user".to_string())), + // } } - pub async fn create(username: String, password: String) -> Result<String, ()> { + pub async fn login(username: String, password: String) -> Result<String, BackendError> { + match DB .query(" - CREATE User:uuid() SET - username = $username, - displayname = $displayname, - passhash = crypto::argon2::generate($passhash), - joined = $joined; - SELECT * FROM User WHERE username = $username + LET $human = (SELECT id, passhash FROM Human WHERE email = $email)[0]; + + IF !crypto::argon2::compare($human.passhash, $password) { + RETURN NONE; + }; + + LET $session_token = rand::string(64); + + CREATE SessionToken CONTENT { + id: rand::uuid::v4(), + created: time::now(), + expires: time::now() + 7d, + token: $session_token, + user: type::thing('Human', $human.id), + }; + + RETURN $session_token; ") - .bind(("username", username.clone())) - .bind(("passhash", password)) - .bind(("displayname", username)) - .bind(("joined", Utc::now().timestamp())) + .bind(("email", username)) + .bind(("password", password)) .await .unwrap() - .take::<Option<User>>(0) + .take::<Option<String>>(0) + .map_err(|e| BackendError::from(e)) { - Ok(Some(user)) => { - let k = user.id.key().to_string(); - println!("Created User: {}", k); - Ok(k) - }, - _ => Err(()) + Ok(Some(user)) => Ok(user), + _ => Err(BackendError::DbError("Failed to create user".to_string())), } } } \ No newline at end of file diff --git a/backend/static/public/default_pfp.png b/backend/static/public/default_pfp.png new file mode 100644 index 0000000..ca7fa2a Binary files /dev/null and b/backend/static/public/default_pfp.png differ diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index 538562f..65899c4 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -20,7 +20,11 @@ web-sys = { version = "0.3", features = [ "CloseEvent", "Window", "Location", - "History" + "History", + "HtmlCanvasElement", + "HtmlImageElement", + "CanvasRenderingContext2d", + "ImageData" ]} futures = "0.3" -chrono = "0.4" \ No newline at end of file +chrono = "0.4" diff --git a/frontend/Trunk.toml b/frontend/Trunk.toml new file mode 100644 index 0000000..aa138e5 --- /dev/null +++ b/frontend/Trunk.toml @@ -0,0 +1,2 @@ +[serve] +port = 8080 diff --git a/frontend/dist/chatapp-frontend-2d9721327d80d1a4.js b/frontend/dist/chatapp-frontend-2879b3175985551e.js similarity index 95% rename from frontend/dist/chatapp-frontend-2d9721327d80d1a4.js rename to frontend/dist/chatapp-frontend-2879b3175985551e.js index c67263d..f3e8d4d 100644 --- a/frontend/dist/chatapp-frontend-2d9721327d80d1a4.js +++ b/frontend/dist/chatapp-frontend-2879b3175985551e.js @@ -119,6 +119,28 @@ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') wasm.__wbindgen_export_7.get(state.dtor)(state.a, state.b) }); +function makeClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + try { + return f(state.a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_7.get(state.dtor)(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} + function makeMutClosure(arg0, arg1, dtor, f) { const state = { a: arg0, b: arg1, cnt: 1, dtor }; const real = (...args) => { @@ -144,28 +166,6 @@ function makeMutClosure(arg0, arg1, dtor, f) { return real; } -function makeClosure(arg0, arg1, dtor, f) { - const state = { a: arg0, b: arg1, cnt: 1, dtor }; - const real = (...args) => { - // First up with a closure we increment the internal reference - // count. This ensures that the Rust closure environment won't - // be deallocated while we're invoking it. - state.cnt++; - try { - return f(state.a, state.b, ...args); - } finally { - if (--state.cnt === 0) { - wasm.__wbindgen_export_7.get(state.dtor)(state.a, state.b); - state.a = 0; - CLOSURE_DTORS.unregister(state); - } - } - }; - real.original = state; - CLOSURE_DTORS.register(real, state, state); - return real; -} - function debugString(val) { // primitive types const type = typeof val; @@ -231,23 +231,19 @@ function debugString(val) { return className; } function __wbg_adapter_42(arg0, arg1, arg2) { - wasm.closure130_externref_shim(arg0, arg1, arg2); + wasm.closure400_externref_shim(arg0, arg1, arg2); } -function __wbg_adapter_45(arg0, arg1, arg2) { - wasm.closure540_externref_shim(arg0, arg1, arg2); +function __wbg_adapter_47(arg0, arg1, arg2) { + wasm.closure612_externref_shim(arg0, arg1, arg2); } -function __wbg_adapter_48(arg0, arg1, arg2) { - wasm.closure616_externref_shim(arg0, arg1, arg2); +function __wbg_adapter_50(arg0, arg1, arg2) { + wasm.closure700_externref_shim(arg0, arg1, arg2); } -function __wbg_adapter_51(arg0, arg1, arg2) { - wasm.closure638_externref_shim(arg0, arg1, arg2); -} - -function __wbg_adapter_54(arg0, arg1, arg2) { - wasm.closure647_externref_shim(arg0, arg1, arg2); +function __wbg_adapter_53(arg0, arg1, arg2) { + wasm.closure717_externref_shim(arg0, arg1, arg2); } async function __wbg_load(module, imports) { @@ -386,13 +382,6 @@ function __wbg_get_imports() { const ret = Array.from(arg0); return ret; }; - imports.wbg.__wbg_getItem_561976eef304cebe = function() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg1.getItem(getStringFromWasm0(arg2, arg3)); - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); - }, arguments) }; imports.wbg.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) { arg0.getRandomValues(arg1); }, arguments) }; @@ -571,14 +560,15 @@ function __wbg_get_imports() { const ret = arg0.__yew_listener_id; return isLikeNone(ret) ? 0x100000001 : (ret) >>> 0; }; - imports.wbg.__wbg_localStorage_05bfbeeb8946b5bf = function() { return handleError(function (arg0) { - const ret = arg0.localStorage; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, arguments) }; imports.wbg.__wbg_location_54d35e8c85dcfb9c = function(arg0) { const ret = arg0.location; return ret; }; + imports.wbg.__wbg_log_c3d56bb0009edd6a = function(arg0, arg1) { + var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice(); + wasm.__wbindgen_free(arg0, arg1 * 4, 4); + console.log(...v0); + }; imports.wbg.__wbg_message_142844ca2fe283e3 = function(arg0) { const ret = arg0.message; return ret; @@ -924,24 +914,24 @@ function __wbg_get_imports() { const ret = false; return ret; }; - imports.wbg.__wbindgen_closure_wrapper280 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 131, __wbg_adapter_42); + imports.wbg.__wbindgen_closure_wrapper1214 = function(arg0, arg1, arg2) { + const ret = makeClosure(arg0, arg1, 613, __wbg_adapter_47); return ret; }; - imports.wbg.__wbindgen_closure_wrapper5502 = function(arg0, arg1, arg2) { - const ret = makeClosure(arg0, arg1, 541, __wbg_adapter_45); + imports.wbg.__wbindgen_closure_wrapper1482 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 701, __wbg_adapter_50); return ret; }; - imports.wbg.__wbindgen_closure_wrapper7256 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 617, __wbg_adapter_48); + imports.wbg.__wbindgen_closure_wrapper1516 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 718, __wbg_adapter_53); return ret; }; - imports.wbg.__wbindgen_closure_wrapper7485 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 639, __wbg_adapter_51); + imports.wbg.__wbindgen_closure_wrapper681 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 401, __wbg_adapter_42); return ret; }; - imports.wbg.__wbindgen_closure_wrapper7756 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 648, __wbg_adapter_54); + imports.wbg.__wbindgen_closure_wrapper683 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 401, __wbg_adapter_42); return ret; }; imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { diff --git a/frontend/dist/chatapp-frontend-2879b3175985551e_bg.wasm b/frontend/dist/chatapp-frontend-2879b3175985551e_bg.wasm new file mode 100644 index 0000000..7bfbb3b Binary files /dev/null and b/frontend/dist/chatapp-frontend-2879b3175985551e_bg.wasm differ diff --git a/frontend/dist/chatapp-frontend-2d9721327d80d1a4_bg.wasm b/frontend/dist/chatapp-frontend-2d9721327d80d1a4_bg.wasm deleted file mode 100644 index 906aec6..0000000 Binary files a/frontend/dist/chatapp-frontend-2d9721327d80d1a4_bg.wasm and /dev/null differ diff --git a/frontend/dist/styles-a0f557a2c187e84.css b/frontend/dist/components-c4a55600848b6fb1.css similarity index 58% rename from frontend/dist/styles-a0f557a2c187e84.css rename to frontend/dist/components-c4a55600848b6fb1.css index 88e83a1..fe4cffc 100644 --- a/frontend/dist/styles-a0f557a2c187e84.css +++ b/frontend/dist/components-c4a55600848b6fb1.css @@ -1,30 +1,4 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -:root { - --blur-amount: 10px; - --border-radius: 15px; - --glow-color: rgba(255, 255, 255, 0.3); - --message-bubble-color: rgba(255, 255, 255, 0.1); - --border-color: rgba(255, 255, 255, 0.1); - --shadow-color: rgba(0, 0, 0, 0.2); -} - -html, body { - margin: 0; - padding: 0; - height: 100vh; - width: 100%; - overflow: hidden; - background: linear-gradient(135deg, #1a2a6c, #2a4858, #141E30); - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; - color: white; -} - -.app-container { +.base-container { height: 100vh; width: 100vw; display: flex; @@ -32,17 +6,18 @@ html, body { overflow: hidden; } -.chat-container { +.app-container { flex: 1; margin: 0 2rem; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; - width: 100%; + width: calc(100% - 4rem); max-width: 1400px; margin-left: auto; margin-right: auto; + height: calc(100vh - 80px); /* Account for navbar height */ overflow: hidden; } @@ -60,6 +35,37 @@ html, body { flex-direction: column; gap: 1rem; width: 100%; + min-height: 0; /* This is crucial for flex child scrolling */ +} + +.meme-license-container { + flex: 1; + overflow-y: auto; + padding: 0; + background: rgba(255, 255, 255, 0.05); + backdrop-filter: blur(var(--blur-amount)); + -webkit-backdrop-filter: blur(var(--blur-amount)); + border-radius: 40px; + border: 1px solid var(--border-color); + box-shadow: 0 4px 24px var(--shadow-color); + display: flex; + flex-direction: row; + gap: 1rem; + width: 100%; + min-height: 0; /* This is crucial for flex child scrolling */ +} + +.ui-server-list { + height: 100%; + overflow-y: auto; + margin: 16px; + padding: 1rem; + background: rgba(255, 255, 255, 0.05); + backdrop-filter: blur(var(--blur-amount)); + -webkit-backdrop-filter: blur(var(--blur-amount)); + border-radius: var(--border-radius); + border: 1px solid var(--border-color); + box-shadow: 0 4px 24px var(--shadow-color); } .message { @@ -103,17 +109,17 @@ html, body { .username { font-weight: 600; font-size: 0.9rem; - color: #fff; + color: var(--text-color, #fff); text-shadow: 0 2px 4px var(--shadow-color); } .timestamp { - color: rgba(255, 255, 255, 0.6); + color: var(--text-secondary, rgba(255, 255, 255, 0.6)); font-size: 0.8rem; } .message-content { - color: rgba(255, 255, 255, 0.9); + color: var(--text-color, rgba(255, 255, 255, 0.9)); font-size: 0.95rem; } @@ -132,41 +138,68 @@ html, body { .message-input { flex: 1; - background: rgba(255, 255, 255, 0.1); - border: 1px solid var(--border-color); - border-radius: var(--border-radius); - padding: 0.8rem 1rem; - color: white; + background: var(--background-element, rgba(255, 255, 255, 0.1)); + border: none; + padding: 0.4rem 1.5rem; + color: var(--text-color, white); font-size: 1rem; resize: vertical; - min-height: 1.5rem; - max-height: 150px; transition: all 0.3s ease; - box-shadow: 0 2px 8px var(--shadow-color); } .message-input:hover, .message-input:focus { - border-color: var(--glow-color); - box-shadow: 0 0 15px var(--glow-color); - outline: none; + background-color: rgba(255, 255, 255, 0.3); } -.send-button { - background: rgba(255, 255, 255, 0.1); +.ui-button { + background: var(--background-element, rgba(255, 255, 255, 0.1)); + padding: 0.4rem 1.5rem; + color: var(--text-color, white); + font-size: 1rem; + cursor: pointer; + border: none; + transition: all 0.3s ease; +} + +.ui-group { + display: flex; + flex-direction: row; + + background: var(--background-element, rgba(255, 255, 255, 0.1)); + border: 1px solid var(--border-color); + border-radius: var(--border-radius); + width: 100%; + color: var(--text-color, white); + font-size: 1rem; + transition: all 0.3s ease; + box-shadow: 0 2px 8px var(--shadow-color); + + overflow: hidden; +} + +.ui-layout-horizontal { + display: flex; + flex-direction: row; + gap: 1rem; + margin: 0; + padding: 0; + width: 100%; +} + +.ui-element-standalone { + background: var(--background-element, rgba(255, 255, 255, 0.1)); border: 1px solid var(--border-color); border-radius: var(--border-radius); padding: 0.8rem 1.5rem; - color: white; + color: var(--text-color, white); font-size: 1rem; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 2px 8px var(--shadow-color); } -.send-button:hover { - border-color: var(--glow-color); - box-shadow: 0 0 15px var(--glow-color); - background: rgba(255, 255, 255, 0.2); +.ui-button:hover { + background-color: rgba(255, 255, 255, 0.3); } .navbar { @@ -174,122 +207,113 @@ html, body { justify-content: space-between; align-items: center; padding: 1rem 2rem; - background: rgba(255, 255, 255, 0.1); + background: var(--background-element, rgba(255, 255, 255, 0.1)); backdrop-filter: blur(var(--blur-amount)); -webkit-backdrop-filter: blur(var(--blur-amount)); - border: none; border-bottom: 1px solid var(--border-color); - box-shadow: 0 4px 24px var(--shadow-color); - margin: 0; + box-shadow: 0 2px 8px var(--shadow-color); + position: relative; + z-index: 1000; } .nav-brand { font-size: 1.5rem; font-weight: bold; - color: white; text-shadow: 0 2px 4px var(--shadow-color); + white-space: nowrap; } -/* Login styles */ -.login-container { - position: absolute; - left: 50%; - top: 50%; - transform: translate(-50%, -50%); - width: 90%; - max-width: 400px; -} -.login-form { - display: flex; - flex-direction: column; - gap: 1rem; - padding: 2rem; - background: rgba(255, 255, 255, 0.1); +.selector { + position: relative; + display: inline-block; + + background: rgba(255, 255, 255, 0.01); + width: max-content; + + /* background: var(--background-element, rgba(255, 255, 255, 0.1)); */ backdrop-filter: blur(var(--blur-amount)); -webkit-backdrop-filter: blur(var(--blur-amount)); - border-radius: var(--border-radius); - border: 1px solid var(--border-color); - box-shadow: 0 4px 24px var(--shadow-color); -} - -.login-title { - font-size: 1.5rem; - font-weight: bold; - text-align: center; - color: white; - text-shadow: 0 2px 4px var(--shadow-color); - margin-bottom: 1rem; -} - -.login-input { - background: rgba(255, 255, 255, 0.1); + border: 1px solid var(--border-color); border-radius: var(--border-radius); - padding: 0.8rem 1rem; - color: white; - font-size: 1rem; - transition: all 0.3s ease; box-shadow: 0 2px 8px var(--shadow-color); -} -.login-input:hover, .login-input:focus { - border-color: var(--glow-color); - box-shadow: 0 0 15px var(--glow-color); - outline: none; -} - -.login-input::placeholder { - color: rgba(255, 255, 255, 0.6); -} - -.login-button { - background: rgba(255, 255, 255, 0.1); - border: 1px solid var(--border-color); - border-radius: var(--border-radius); - padding: 0.8rem 1.5rem; - color: white; + color: var(--text-color, white); font-size: 1rem; cursor: pointer; transition: all 0.3s ease; - box-shadow: 0 2px 8px var(--shadow-color); - text-align: center; - text-decoration: none; + z-index: 1001; } -.login-button:hover { - border-color: var(--glow-color); - box-shadow: 0 0 15px var(--glow-color); - background: rgba(255, 255, 255, 0.2); -} +.selector-items { + display: none; + position: absolute; + top: calc(100% + 1px); + left: -1px; + right: -1px; -.login-text { - color: rgba(255, 255, 255, 0.9); - text-align: center; - margin: 0.5rem 0; -} - -.login-link { - color: white; - text-decoration: none; - transition: all 0.3s ease; -} - -.login-link:hover { - text-shadow: 0 0 10px var(--glow-color); -} - -.login-error { - background: rgba(255, 0, 0, 0.1); - border: 1px solid rgba(255, 0, 0, 0.3); + border: 1px solid var(--border-color); border-radius: var(--border-radius); - padding: 0.8rem 1.5rem; - color: white; - font-size: 1rem; - text-align: center; + box-shadow: 0 4px 12px var(--shadow-color); + z-index: 1002; + backdrop-filter: blur(var(--blur-amount)); -webkit-backdrop-filter: blur(var(--blur-amount)); - box-shadow: 0 2px 8px var(--shadow-color); + overflow: hidden; +} + +.selector:hover .selector-items { + display: block; +} + +.selector-button { + background: none; + width: 100%; + padding: 0.4rem 1.5rem; + border: none; + color: var(--text-color, white); + font-size: 0.9rem; + cursor: pointer; + transition: all 0.2s ease; + text-align: center; + white-space: nowrap; +} + +.selector-label { + background: none; + width: 100%; + padding: 0.4rem 1.5rem; + border: none; + color: var(--text-color, white); + font-size: 0.9rem; + cursor: pointer; + transition: all 0.2s ease; + text-align: center; + white-space: nowrap; + position: relative; + padding-right: 2rem; + border-radius: var(--border-radius); +} + +.selector-label::after { + content: "▼"; + position: absolute; + right: 0.8rem; + top: 50%; + transform: translateY(-50%); + font-size: 0.8rem; + opacity: 0.7; +} + +.selector-button:hover { + color: var(--glow-color); + background-color: rgba(255, 255, 255, 0.1); +} + +.selector-button.active { + color: var(--glow-color); + font-weight: 500; } /* Custom scrollbar */ diff --git a/frontend/dist/form-3a77ed11d71d542d.css b/frontend/dist/form-3a77ed11d71d542d.css new file mode 100644 index 0000000..59f1be6 --- /dev/null +++ b/frontend/dist/form-3a77ed11d71d542d.css @@ -0,0 +1,104 @@ + +/* Form styles */ +.form-container { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + width: 90%; + max-width: 400px; +} + +.form-form { + display: flex; + flex-direction: column; + gap: 1rem; + padding: 2rem; + background: rgba(255, 255, 255, 0.1); + backdrop-filter: blur(var(--blur-amount)); + -webkit-backdrop-filter: blur(var(--blur-amount)); + border-radius: var(--border-radius); + border: 1px solid var(--border-color); + box-shadow: 0 4px 24px var(--shadow-color); +} + +.form-title { + font-size: 1.5rem; + font-weight: bold; + text-align: center; + color: var(--text-color); + text-shadow: 0 2px 4px var(--shadow-color); + margin-bottom: 1rem; +} + +.form-input { + background: rgba(255, 255, 255, 0.1); + border: 1px solid var(--border-color); + border-radius: var(--border-radius); + padding: 0.8rem 1rem; + color: var(--text-color); + + font-size: 1rem; + transition: all 0.3s ease; + box-shadow: 0 2px 8px var(--shadow-color); +} + +.form-input:hover, .form-input:focus { + border-color: var(--glow-color); + box-shadow: 0 0 15px var(--glow-color); + outline: none; +} + +.form-input::placeholder { + color: var(--text-color); + text-align: center; +} + +.form-button { + background: rgba(255, 255, 255, 0.1); + border: 1px solid var(--border-color); + border-radius: var(--border-radius); + padding: 0.8rem 1.5rem; + color: var(--text-color); + font-size: 1rem; + cursor: pointer; + transition: all 0.3s ease; + box-shadow: 0 2px 8px var(--shadow-color); + text-align: center; + text-decoration: none; +} + +.form-button:hover { + border-color: var(--glow-color); + box-shadow: 0 0 15px var(--glow-color); + background: rgba(255, 255, 255, 0.2); +} + +.form-text { + color: var(--text-color); + text-align: center; + margin: 0.5rem 0; +} + +.form-link { + color: var(--text-color); + text-decoration: none; + transition: all 0.3s ease; +} + +.form-link:hover { + text-shadow: 0 0 10px var(--glow-color); +} + +.form-error { + background: rgba(255, 0, 0, 0.1); + border: 1px solid rgba(255, 0, 0, 0.3); + border-radius: var(--border-radius); + padding: 0.8rem 1.5rem; + color: var(--text-color); + font-size: 1rem; + text-align: center; + backdrop-filter: blur(var(--blur-amount)); + -webkit-backdrop-filter: blur(var(--blur-amount)); + box-shadow: 0 2px 8px var(--shadow-color); +} \ No newline at end of file diff --git a/frontend/dist/global-7cfadbee4d5b1bff.css b/frontend/dist/global-7cfadbee4d5b1bff.css new file mode 100644 index 0000000..c55ebaa --- /dev/null +++ b/frontend/dist/global-7cfadbee4d5b1bff.css @@ -0,0 +1,45 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + + --blur-amount: 10px; + --border-radius: 15px; + --shadow-color: rgba(0, 0, 0, 0.4); +} + +*[theme="default"] { + --background: linear-gradient(135deg, #1a2a6c, #2a4858, #141E30); + --glow-color: rgba(255, 255, 255, 0.3); + --message-bubble-color: rgba(255, 255, 255, 0.1); + --border-color: rgba(255, 255, 255, 0.1); + --text-color: #ffffff; + +} + +*[theme="light"] { + --background: #ffffff; + --glow-color: rgba(100, 149, 237, 0.3); + --message-bubble-color: rgba(100, 149, 237, 0.1); + --border-color: rgba(100, 149, 237, 0.2); + --text-color: #000000; +} + +*[theme="dark"] { + --background: linear-gradient(135deg, #121212, #1a1a1a, #232323); + --glow-color: rgba(147, 112, 219, 0.4); + --message-bubble-color: rgba(147, 112, 219, 0.15); + --border-color: rgba(255, 255, 255, 0.1); + --text-color: #ffffff; +} + +html, body { + margin: 0; + padding: 0; + height: 100vh; + width: 100%; + overflow: hidden; + background: var(--background); + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + color: var(--text-color, white); +} diff --git a/frontend/dist/index.html b/frontend/dist/index.html index 6e4225e..51d545a 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -5,14 +5,16 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Chat App - - + + + +
-