can send chat now

This commit is contained in:
Michael Zhang 2023-12-25 15:06:35 -05:00
parent 605c3d423a
commit d0d8d7acaa
10 changed files with 857 additions and 34 deletions

593
Cargo.lock generated
View file

@ -185,13 +185,94 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "axum"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "202651474fe73c62d9e0a56c6133f7a0ff1dc1c8cf7a5b03381af2a26553ac9d"
dependencies = [
"async-trait",
"axum-core",
"axum-macros",
"base64 0.21.5",
"bytes",
"futures-util",
"http 1.0.0",
"http-body 1.0.0",
"http-body-util",
"hyper 1.1.0",
"hyper-util",
"itoa 1.0.10",
"matchit",
"memchr",
"mime",
"multer",
"percent-encoding",
"pin-project-lite",
"rustversion",
"serde",
"serde_json",
"serde_path_to_error",
"serde_urlencoded",
"sha1",
"sync_wrapper",
"tokio",
"tokio-tungstenite 0.20.1",
"tower",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum-core"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77cb22c689c44d4c07b0ab44ebc25d69d8ae601a2f28fb8d672d344178fa17aa"
dependencies = [
"async-trait",
"bytes",
"futures-util",
"http 1.0.0",
"http-body 1.0.0",
"http-body-util",
"mime",
"pin-project-lite",
"rustversion",
"sync_wrapper",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum-macros"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a2edad600410b905404c594e2523549f1bcd4bded1e252c8f74524ccce0b867"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"syn 2.0.43",
]
[[package]]
name = "backend"
version = "0.1.0"
dependencies = [
"anyhow",
"axum",
"common",
"dashmap",
"ed25519-compact",
"futures",
"k256",
"lazy_static",
"prisma-client-rust",
"prisma-client-rust-cli",
"rand 0.8.5",
"ring",
"serde",
"serde_json",
"tokio",
]
[[package]]
@ -215,6 +296,12 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270"
[[package]]
name = "base16ct"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
name = "base36"
version = "0.0.1"
@ -243,6 +330,12 @@ version = "0.21.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
[[package]]
name = "base64ct"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]]
name = "bigdecimal"
version = "0.3.1"
@ -695,6 +788,7 @@ dependencies = [
"anyhow",
"capnp",
"capnpc",
"serde",
]
[[package]]
@ -712,6 +806,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "510ca239cf13b7f8d16a2b48f263de7b4f8c566f0af58d901031473c76afb1e3"
[[package]]
name = "const-oid"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
[[package]]
name = "convert_case"
version = "0.4.0"
@ -856,6 +956,18 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "crypto-bigint"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
dependencies = [
"generic-array",
"rand_core 0.6.4",
"subtle",
"zeroize",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
@ -893,6 +1005,12 @@ dependencies = [
"syn 2.0.43",
]
[[package]]
name = "ct-codecs"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df"
[[package]]
name = "ctor"
version = "0.2.6"
@ -1006,6 +1124,19 @@ dependencies = [
"syn 2.0.43",
]
[[package]]
name = "dashmap"
version = "5.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
dependencies = [
"cfg-if",
"hashbrown 0.14.3",
"lock_api",
"once_cell",
"parking_lot_core 0.9.9",
]
[[package]]
name = "data-encoding"
version = "2.5.0"
@ -1023,6 +1154,16 @@ dependencies = [
"regex",
]
[[package]]
name = "der"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c"
dependencies = [
"const-oid",
"zeroize",
]
[[package]]
name = "deranged"
version = "0.3.10"
@ -1083,6 +1224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer 0.10.4",
"const-oid",
"crypto-common",
"subtle",
]
@ -1194,12 +1336,55 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
[[package]]
name = "ecdsa"
version = "0.16.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"
dependencies = [
"der",
"digest 0.10.7",
"elliptic-curve",
"rfc6979",
"signature",
"spki",
]
[[package]]
name = "ed25519-compact"
version = "2.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a667e6426df16c2ac478efa4a439d0e674cba769c5556e8cf221739251640c8c"
dependencies = [
"ct-codecs",
"getrandom 0.2.11",
]
[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "elliptic-curve"
version = "0.13.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
dependencies = [
"base16ct",
"crypto-bigint",
"digest 0.10.7",
"ff",
"generic-array",
"group",
"pkcs8",
"rand_core 0.6.4",
"sec1",
"subtle",
"zeroize",
]
[[package]]
name = "embed-resource"
version = "2.4.0"
@ -1401,6 +1586,16 @@ dependencies = [
"simd-adler32",
]
[[package]]
name = "ff"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449"
dependencies = [
"rand_core 0.6.4",
"subtle",
]
[[package]]
name = "field-offset"
version = "0.3.6"
@ -1481,10 +1676,15 @@ name = "frontend"
version = "0.0.0"
dependencies = [
"common",
"futures",
"reqwest",
"serde",
"serde_json",
"tauri",
"tauri-build",
"tokio",
"tokio-tungstenite 0.21.0",
"url",
]
[[package]]
@ -1766,6 +1966,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
"zeroize",
]
[[package]]
@ -1786,8 +1987,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"wasm-bindgen",
]
[[package]]
@ -1911,6 +2114,17 @@ dependencies = [
"thiserror",
]
[[package]]
name = "group"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
dependencies = [
"ff",
"rand_core 0.6.4",
"subtle",
]
[[package]]
name = "gtk"
version = "0.15.5"
@ -1977,7 +2191,26 @@ dependencies = [
"futures-core",
"futures-sink",
"futures-util",
"http",
"http 0.2.11",
"indexmap 2.1.0",
"slab",
"tokio",
"tokio-util 0.7.10",
"tracing",
]
[[package]]
name = "h2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http 1.0.0",
"indexmap 2.1.0",
"slab",
"tokio",
@ -2090,6 +2323,17 @@ dependencies = [
"itoa 1.0.10",
]
[[package]]
name = "http"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea"
dependencies = [
"bytes",
"fnv",
"itoa 1.0.10",
]
[[package]]
name = "http-body"
version = "0.4.6"
@ -2097,7 +2341,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
"http",
"http 0.2.11",
"pin-project-lite",
]
[[package]]
name = "http-body"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
dependencies = [
"bytes",
"http 1.0.0",
]
[[package]]
name = "http-body-util"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840"
dependencies = [
"bytes",
"futures-util",
"http 1.0.0",
"http-body 1.0.0",
"pin-project-lite",
]
@ -2129,9 +2396,9 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
"h2",
"http",
"http-body",
"h2 0.3.22",
"http 0.2.11",
"http-body 0.4.6",
"httparse",
"httpdate",
"itoa 1.0.10",
@ -2143,6 +2410,25 @@ dependencies = [
"want",
]
[[package]]
name = "hyper"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"h2 0.4.0",
"http 1.0.0",
"http-body 1.0.0",
"httparse",
"httpdate",
"itoa 1.0.10",
"pin-project-lite",
"tokio",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
@ -2150,12 +2436,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
"hyper",
"hyper 0.14.28",
"native-tls",
"tokio",
"tokio-native-tls 0.3.1",
]
[[package]]
name = "hyper-util"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http 1.0.0",
"http-body 1.0.0",
"hyper 1.1.0",
"pin-project-lite",
"socket2 0.5.5",
"tokio",
"tracing",
]
[[package]]
name = "iana-time-zone"
version = "0.1.58"
@ -2444,6 +2748,20 @@ dependencies = [
"serde_json",
]
[[package]]
name = "k256"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b"
dependencies = [
"cfg-if",
"ecdsa",
"elliptic-curve",
"once_cell",
"sha2 0.10.8",
"signature",
]
[[package]]
name = "keccak"
version = "0.1.4"
@ -2742,6 +3060,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5"
[[package]]
name = "matchit"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "md-5"
version = "0.10.6"
@ -2799,7 +3123,7 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953cbbb6f9ba4b9304f4df79b98cdc9d14071ed93065a9fca11c00c5d9181b66"
dependencies = [
"hyper",
"hyper 0.14.28",
"indexmap 1.9.3",
"ipnet",
"metrics 0.19.0",
@ -2976,7 +3300,7 @@ dependencies = [
"percent-encoding",
"rand 0.8.5",
"rustc_version_runtime",
"rustls",
"rustls 0.21.10",
"rustls-pemfile",
"serde",
"serde_bytes",
@ -2989,13 +3313,13 @@ dependencies = [
"take_mut",
"thiserror",
"tokio",
"tokio-rustls",
"tokio-rustls 0.24.1",
"tokio-util 0.7.10",
"trust-dns-proto",
"trust-dns-resolver",
"typed-builder",
"uuid",
"webpki-roots",
"webpki-roots 0.25.3",
]
[[package]]
@ -3093,6 +3417,24 @@ dependencies = [
"serde",
]
[[package]]
name = "multer"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2"
dependencies = [
"bytes",
"encoding_rs",
"futures-util",
"http 0.2.11",
"httparse",
"log",
"memchr",
"mime",
"spin",
"version_check",
]
[[package]]
name = "mysql_async"
version = "0.30.0"
@ -3871,6 +4213,16 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkcs8"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
dependencies = [
"der",
"spki",
]
[[package]]
name = "pkg-config"
version = "0.3.28"
@ -4016,7 +4368,7 @@ source = "git+https://github.com/Brendonovich/prisma-client-rust?tag=0.6.10#9486
dependencies = [
"directories",
"flate2",
"http",
"http 0.2.11",
"prisma-client-rust-sdk",
"proc-macro2",
"quote",
@ -4592,10 +4944,10 @@ dependencies = [
"encoding_rs",
"futures-core",
"futures-util",
"h2",
"http",
"http-body",
"hyper",
"h2 0.3.22",
"http 0.2.11",
"http-body 0.4.6",
"hyper 0.14.28",
"hyper-tls",
"ipnet",
"js-sys",
@ -4629,6 +4981,16 @@ dependencies = [
"quick-error",
]
[[package]]
name = "rfc6979"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"
dependencies = [
"hmac",
"subtle",
]
[[package]]
name = "ring"
version = "0.17.7"
@ -4765,10 +5127,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
dependencies = [
"log",
"ring",
"rustls-webpki",
"rustls-webpki 0.101.7",
"sct",
]
[[package]]
name = "rustls"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe6b63262c9fcac8659abfaa96cac103d28166d3ff3eaf8f412e19f3ae9e5a48"
dependencies = [
"log",
"ring",
"rustls-pki-types",
"rustls-webpki 0.102.0",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pemfile"
version = "1.0.4"
@ -4778,6 +5154,12 @@ dependencies = [
"base64 0.21.5",
]
[[package]]
name = "rustls-pki-types"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e9d979b3ce68192e42760c7810125eb6cf2ea10efae545a156063e61f314e2a"
[[package]]
name = "rustls-webpki"
version = "0.101.7"
@ -4788,6 +5170,17 @@ dependencies = [
"untrusted",
]
[[package]]
name = "rustls-webpki"
version = "0.102.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de2635c8bc2b88d367767c5de8ea1d8db9af3f6219eba28442242d9ab81d1b89"
dependencies = [
"ring",
"rustls-pki-types",
"untrusted",
]
[[package]]
name = "rustversion"
version = "1.0.14"
@ -4891,6 +5284,20 @@ version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
[[package]]
name = "sec1"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
dependencies = [
"base16ct",
"der",
"generic-array",
"pkcs8",
"subtle",
"zeroize",
]
[[package]]
name = "security-framework"
version = "2.9.2"
@ -5214,6 +5621,16 @@ dependencies = [
"libc",
]
[[package]]
name = "signature"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
dependencies = [
"digest 0.10.7",
"rand_core 0.6.4",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
@ -5307,6 +5724,16 @@ version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "spki"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
dependencies = [
"base64ct",
"der",
]
[[package]]
name = "sql-ddl"
version = "0.1.0"
@ -5540,6 +5967,12 @@ dependencies = [
"syn 2.0.43",
]
[[package]]
name = "sync_wrapper"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "synstructure"
version = "0.12.6"
@ -5703,7 +6136,7 @@ dependencies = [
"glob",
"gtk",
"heck 0.4.1",
"http",
"http 0.2.11",
"ignore",
"objc",
"once_cell",
@ -5799,7 +6232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf2d0652aa2891ff3e9caa2401405257ea29ab8372cce01f186a5825f1bd0e76"
dependencies = [
"gtk",
"http",
"http 0.2.11",
"http-range",
"rand 0.8.5",
"raw-window-handle",
@ -6087,10 +6520,49 @@ version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
dependencies = [
"rustls",
"rustls 0.21.10",
"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.1",
"rustls-pki-types",
"tokio",
]
[[package]]
name = "tokio-tungstenite"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c"
dependencies = [
"futures-util",
"log",
"tokio",
"tungstenite 0.20.1",
]
[[package]]
name = "tokio-tungstenite"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38"
dependencies = [
"futures-util",
"log",
"rustls 0.22.1",
"rustls-pki-types",
"tokio",
"tokio-rustls 0.25.0",
"tungstenite 0.21.0",
"webpki-roots 0.26.0",
]
[[package]]
name = "tokio-util"
version = "0.6.10"
@ -6200,6 +6672,28 @@ dependencies = [
"winnow",
]
[[package]]
name = "tower"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
"futures-core",
"futures-util",
"pin-project",
"pin-project-lite",
"tokio",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tower-layer"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
[[package]]
name = "tower-service"
version = "0.3.2"
@ -6373,6 +6867,46 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "tungstenite"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9"
dependencies = [
"byteorder",
"bytes",
"data-encoding",
"http 0.2.11",
"httparse",
"log",
"rand 0.8.5",
"sha1",
"thiserror",
"url",
"utf-8",
]
[[package]]
name = "tungstenite"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1"
dependencies = [
"byteorder",
"bytes",
"data-encoding",
"http 1.0.0",
"httparse",
"log",
"rand 0.8.5",
"rustls 0.22.1",
"rustls-pki-types",
"sha1",
"thiserror",
"url",
"utf-8",
]
[[package]]
name = "twox-hash"
version = "1.6.3"
@ -6380,7 +6914,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if",
"rand 0.7.3",
"rand 0.8.5",
"static_assertions",
]
@ -6735,6 +7269,15 @@ version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
[[package]]
name = "webpki-roots"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de2cfda980f21be5a7ed2eadb3e6fe074d56022bea2cdeb1a62eb220fc04188"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "webview2-com"
version = "0.19.1"
@ -7161,7 +7704,7 @@ dependencies = [
"glib",
"gtk",
"html5ever",
"http",
"http 0.2.11",
"kuchikiki",
"libc",
"log",
@ -7242,3 +7785,9 @@ dependencies = [
"quote",
"syn 2.0.43",
]
[[package]]
name = "zeroize"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"

View file

@ -7,6 +7,7 @@
- [ ] retrieve history
- [ ] notifications
- [ ] multiple clients
- [ ] send files (s3 backend interop)
distant future shit

View file

@ -4,6 +4,18 @@ version = "0.1.0"
edition = "2021"
[dependencies]
common = { path = "../common" }
anyhow = { version = "1.0.76", features = ["backtrace"] }
axum = { version = "0.7.2", features = ["http2", "multipart", "macros", "ws"] }
dashmap = "5.5.3"
ed25519-compact = "2.0.6"
futures = "0.3.30"
k256 = "0.13.2"
lazy_static = "1.4.0"
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.10" }
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.10" }
rand = "0.8.5"
ring = "0.17.7"
serde = "1.0.193"
serde_json = "1.0.108"
tokio = { version = "1.35.1", features = ["full"] }

View file

@ -15,9 +15,20 @@ model User {
pubKey String @id
displayName String
accountCreatedAt DateTime @default(now())
messages Message[]
}
model Auth {
token String @id @default(uuid())
name String
pubKey String
active Boolean
createdAt DateTime @default(now())
expiresAt DateTime?
}
model Room {
id String @id
}
@ -30,5 +41,7 @@ model Message {
authorPubKey String
author User @relation(fields: [authorPubKey], references: [pubKey])
createdAt DateTime @default(now())
@@index([type])
}

View file

@ -1,3 +1,100 @@
fn main() {
println!("Hello, world!");
#[macro_use]
extern crate serde;
mod prisma;
use std::{future::Future, sync::Arc};
use anyhow::Result;
use axum::{
extract::{
ws::{Message as WsMessage, WebSocket},
Query, State, WebSocketUpgrade,
},
response::{sse::Event, Response},
routing::{get, post},
Json, Router,
};
use common::Message;
use dashmap::DashMap;
use futures::FutureExt;
use prisma::PrismaClient;
use serde_json::{json, Value};
use tokio::sync::broadcast::{self, Sender};
lazy_static::lazy_static! {
static ref AUTH_CHALLENGES: DashMap<String, String> = DashMap::new();
}
#[derive(Clone)]
struct AppState {
room_tx: Sender<Message>,
client: Arc<PrismaClient>,
}
#[tokio::main]
async fn main() -> Result<()> {
let client = PrismaClient::_builder().build().await?;
let (room_tx, room_rx) = broadcast::channel::<Message>(10_000);
let state = AppState {
client: Arc::new(client),
room_tx,
};
let app = Router::new()
.route("/v1/message", post(send_message))
.route("/v1/events", get(event_stream_init))
.with_state(state);
let listener = tokio::net::TcpListener::bind("0.0.0.0:1551").await?;
axum::serve(listener, app).await?;
Ok(())
}
#[derive(Debug, Deserialize)]
struct SendMessageRequest {
#[serde(flatten)]
message: Message,
}
async fn send_message(
State(state): State<AppState>,
Json(request): Json<SendMessageRequest>,
) -> Json<Value> {
state.room_tx.send(request.message).unwrap();
println!("Got message from client, forwarding to room...");
Json(json!({}))
}
#[derive(Debug, Deserialize)]
struct EventStreamRequest {
name: String,
}
async fn event_stream_init(
ws: WebSocketUpgrade,
Query(request): Query<EventStreamRequest>,
State(state): State<AppState>,
) -> Response {
println!("Username: {}", request.name);
ws.on_upgrade(|socket| event_stream(socket, request, state))
}
async fn event_stream(
mut socket: WebSocket,
request: EventStreamRequest,
state: AppState,
) {
let room_tx = state.room_tx.clone();
let mut room_rx = room_tx.subscribe();
loop {
let result = room_rx.recv().await.unwrap();
println!("Received message: {result:?}");
let payload = serde_json::to_string(&result).unwrap();
socket.send(WsMessage::Text(payload)).await.unwrap();
}
}

View file

@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
anyhow = { version = "1.0.76", features = ["backtrace"] }
capnp = "0.18.10"
serde = { version = "1.0.193", features = ["derive"] }
[build-dependencies]
anyhow = { version = "1.0.76", features = ["backtrace"] }

View file

@ -1,3 +1,12 @@
#[macro_use]
extern crate serde;
pub mod clientserver_capnp {
include!(concat!(env!("OUT_DIR"), "/proto/clientserver_capnp.rs"));
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
pub author: String,
pub body: String,
}

View file

@ -15,9 +15,14 @@ tauri-build = { version = "1.5", features = [] }
[dependencies]
tauri = { version = "1.5", features = ["shell-open"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_json = "1.0.108"
common = { path = "../../common" }
tokio-tungstenite = { version = "0.21.0", features = ["rustls-tls-webpki-roots"] }
tokio = { version = "1.35.1", features = ["full"] }
reqwest = { version = "0.11.23", features = ["json"] }
futures = "0.3.30"
url = "2.5.0"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem

View file

@ -1,6 +1,31 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use common::Message;
use futures::{stream::SplitSink, SinkExt, StreamExt};
use tauri::{State, Window};
use tokio::{net::TcpStream, sync::RwLock};
use tokio_tungstenite::{
tungstenite::Message as WsMessage, MaybeTlsStream, WebSocketStream,
};
use url::Url;
struct AppState {
connection: RwLock<Connection>,
}
enum Connection {
Unconnected,
Connected(ConnState),
}
struct ConnState {
server_address: String,
username: String,
socket_write:
SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, WsMessage>,
}
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
@ -8,16 +33,86 @@ fn greet(name: &str) -> String {
}
#[tauri::command]
fn connect(server_address: &str, username: &str) -> String {
format!(
"connecting to {} with username {}",
server_address, username
)
async fn connect(
server_address: String,
username: String,
state: State<'_, AppState>,
window: Window,
) -> Result<String, String> {
let mut url = Url::parse(&server_address).unwrap();
url.set_scheme("ws");
url.set_path("/v1/events");
url.set_query(Some(&format!("name={username}")));
// &format!("/v1/events?name={username}"));
println!("connecting to {url}");
let (socket, response) = tokio_tungstenite::connect_async(url).await.unwrap();
let (socket_write, mut socket_read) = socket.split();
// Spawn reader
tokio::spawn(async move {
loop {
let message = match socket_read.next().await {
Some(v) => v.unwrap(),
None => break,
};
let message: Message = match message {
WsMessage::Text(message) => serde_json::from_str(&message).unwrap(),
_ => continue,
};
window.emit("new_message", message).unwrap();
}
});
{
let mut state_ref = state.connection.write().await;
*state_ref = Connection::Connected(ConnState {
server_address,
username,
socket_write,
});
}
Ok(format!("connected"))
}
fn main() {
#[tauri::command]
async fn send_message(
state: State<'_, AppState>,
content: String,
) -> Result<String, String> {
let state_ref = state.connection.read().await;
match *state_ref {
Connection::Unconnected => return Err(format!("L")),
Connection::Connected(ref state) => {
let message = Message {
author: state.username.clone(),
body: content,
};
// let payload = serde_json::to_string(&message).unwrap();
let client = reqwest::Client::new();
let url = format!("{}/v1/message", state.server_address);
let res = client.post(url).json(&message).send().await.unwrap();
// state.socket.send(WsMessage::Text(payload)).await.unwrap();
}
}
Ok(format!("done"))
}
#[tokio::main]
async fn main() {
let state = AppState {
connection: RwLock::new(Connection::Unconnected),
};
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet, connect])
.manage(state)
.invoke_handler(tauri::generate_handler![greet, connect, send_message])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View file

@ -1,6 +1,8 @@
import { createEffect, createSignal } from "solid-js";
import { invoke } from "@tauri-apps/api/tauri";
import "./App.css";
import { listen } from "@tauri-apps/api/event";
import { createStore } from "solid-js/store";
const initialRandomNumber = Math.floor(Math.random() * 9000) + 1000;
@ -12,6 +14,8 @@ function App() {
const [connectionStatus, setConnectionStatus] = createSignal({
status: "unconnected",
});
const [messageContent, setMessageContent] = createSignal("");
const [messages, setMessages] = createStore([]);
// const [greetMsg, setGreetMsg] = createSignal("");
// const [name, setName] = createSignal("");
@ -27,7 +31,15 @@ function App() {
serverAddress: serverAddress(),
username: username(),
});
console.log("result", result);
console.log("connection result", result);
setConnectionStatus({ status: "connected" });
};
const sendMessage = async (evt) => {
evt.preventDefault();
await invoke("send_message", { content: messageContent() });
console.log("SHIET");
};
const action = () => {
@ -42,6 +54,17 @@ function App() {
};
const disabled = () => connectionStatus().status === "connecting";
createEffect(async () => {
const unlisten = await listen("new_message", (event) => {
console.log("new message", event);
setMessages([...messages, event.payload]);
});
return () => {
unlisten();
};
});
return (
<div class="container">
<div>
@ -60,6 +83,24 @@ function App() {
</div>
<div>{connectionStatus().status}</div>
<div>
<ul>
{messages.map((message) => (
<li>{JSON.stringify(message)}</li>
))}
</ul>
</div>
<div>
<form onSubmit={sendMessage}>
<input
placeholder="Send a message..."
value={messageContent()}
onChange={(evt) => setMessageContent(evt.target.value)}
/>
</form>
</div>
</div>
);
}