Working out some of the appview structure

+296 -52
+3
.gitignore
··· 5 5 .direnv 6 6 .env 7 7 .devenv 8 + 9 + .db/ 10 + **/.db/
+215 -24
Cargo.lock
··· 278 278 checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" 279 279 dependencies = [ 280 280 "async-trait", 281 - "axum-core", 281 + "axum-core 0.4.5", 282 282 "bytes", 283 283 "futures-util", 284 284 "http", ··· 287 287 "hyper", 288 288 "hyper-util", 289 289 "itoa", 290 - "matchit", 290 + "matchit 0.7.3", 291 + "memchr", 292 + "mime", 293 + "percent-encoding", 294 + "pin-project-lite", 295 + "rustversion", 296 + "serde", 297 + "serde_json", 298 + "serde_path_to_error", 299 + "serde_urlencoded", 300 + "sync_wrapper", 301 + "tokio", 302 + "tower", 303 + "tower-layer", 304 + "tower-service", 305 + "tracing", 306 + ] 307 + 308 + [[package]] 309 + name = "axum" 310 + version = "0.8.4" 311 + source = "registry+https://github.com/rust-lang/crates.io-index" 312 + checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" 313 + dependencies = [ 314 + "axum-core 0.5.2", 315 + "bytes", 316 + "form_urlencoded", 317 + "futures-util", 318 + "http", 319 + "http-body", 320 + "http-body-util", 321 + "hyper", 322 + "hyper-util", 323 + "itoa", 324 + "matchit 0.8.4", 291 325 "memchr", 292 326 "mime", 293 327 "percent-encoding", ··· 314 348 "async-trait", 315 349 "bytes", 316 350 "futures-util", 351 + "http", 352 + "http-body", 353 + "http-body-util", 354 + "mime", 355 + "pin-project-lite", 356 + "rustversion", 357 + "sync_wrapper", 358 + "tower-layer", 359 + "tower-service", 360 + "tracing", 361 + ] 362 + 363 + [[package]] 364 + name = "axum-core" 365 + version = "0.5.2" 366 + source = "registry+https://github.com/rust-lang/crates.io-index" 367 + checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" 368 + dependencies = [ 369 + "bytes", 370 + "futures-core", 317 371 "http", 318 372 "http-body", 319 373 "http-body-util", ··· 575 629 checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" 576 630 577 631 [[package]] 632 + name = "cookie" 633 + version = "0.18.1" 634 + source = "registry+https://github.com/rust-lang/crates.io-index" 635 + checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" 636 + dependencies = [ 637 + "percent-encoding", 638 + "time", 639 + "version_check", 640 + ] 641 + 642 + [[package]] 578 643 name = "cordyceps" 579 644 version = "0.3.3" 580 645 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 796 861 checksum = "ab03c107fafeb3ee9f5925686dbb7a73bc76e3932abb0d2b365cb64b169cf04c" 797 862 798 863 [[package]] 864 + name = "diesel" 865 + version = "2.2.10" 866 + source = "registry+https://github.com/rust-lang/crates.io-index" 867 + checksum = "ff3e1edb1f37b4953dd5176916347289ed43d7119cc2e6c7c3f7849ff44ea506" 868 + dependencies = [ 869 + "diesel_derives", 870 + "libsqlite3-sys", 871 + "time", 872 + ] 873 + 874 + [[package]] 875 + name = "diesel_derives" 876 + version = "2.2.5" 877 + source = "registry+https://github.com/rust-lang/crates.io-index" 878 + checksum = "68d4216021b3ea446fd2047f5c8f8fe6e98af34508a254a01e4d6bc1e844f84d" 879 + dependencies = [ 880 + "diesel_table_macro_syntax", 881 + "dsl_auto_type", 882 + "proc-macro2", 883 + "quote", 884 + "syn", 885 + ] 886 + 887 + [[package]] 888 + name = "diesel_table_macro_syntax" 889 + version = "0.2.0" 890 + source = "registry+https://github.com/rust-lang/crates.io-index" 891 + checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" 892 + dependencies = [ 893 + "syn", 894 + ] 895 + 896 + [[package]] 799 897 name = "digest" 800 898 version = "0.10.7" 801 899 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 819 917 ] 820 918 821 919 [[package]] 920 + name = "dotenvy" 921 + version = "0.15.7" 922 + source = "registry+https://github.com/rust-lang/crates.io-index" 923 + checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" 924 + 925 + [[package]] 926 + name = "dsl_auto_type" 927 + version = "0.1.3" 928 + source = "registry+https://github.com/rust-lang/crates.io-index" 929 + checksum = "139ae9aca7527f85f26dd76483eb38533fd84bd571065da1739656ef71c5ff5b" 930 + dependencies = [ 931 + "darling", 932 + "either", 933 + "heck 0.5.0", 934 + "proc-macro2", 935 + "quote", 936 + "syn", 937 + ] 938 + 939 + [[package]] 822 940 name = "ecdsa" 823 941 version = "0.16.9" 824 942 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1196 1314 1197 1315 [[package]] 1198 1316 name = "hashlink" 1199 - version = "0.10.0" 1317 + version = "0.9.1" 1200 1318 source = "registry+https://github.com/rust-lang/crates.io-index" 1201 - checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" 1319 + checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" 1202 1320 dependencies = [ 1203 - "hashbrown 0.15.3", 1321 + "hashbrown 0.14.5", 1204 1322 ] 1205 1323 1206 1324 [[package]] ··· 1310 1428 ] 1311 1429 1312 1430 [[package]] 1431 + name = "http-range-header" 1432 + version = "0.4.2" 1433 + source = "registry+https://github.com/rust-lang/crates.io-index" 1434 + checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" 1435 + 1436 + [[package]] 1313 1437 name = "httparse" 1314 1438 version = "1.10.1" 1315 1439 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1688 1812 1689 1813 [[package]] 1690 1814 name = "libsqlite3-sys" 1691 - version = "0.33.0" 1815 + version = "0.30.1" 1692 1816 source = "registry+https://github.com/rust-lang/crates.io-index" 1693 - checksum = "947e6816f7825b2b45027c2c32e7085da9934defa535de4a6a46b10a4d5257fa" 1817 + checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" 1694 1818 dependencies = [ 1695 1819 "cc", 1696 1820 "pkg-config", ··· 1796 1920 checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" 1797 1921 1798 1922 [[package]] 1923 + name = "matchit" 1924 + version = "0.8.4" 1925 + source = "registry+https://github.com/rust-lang/crates.io-index" 1926 + checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" 1927 + 1928 + [[package]] 1799 1929 name = "memchr" 1800 1930 version = "2.7.4" 1801 1931 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1803 1933 1804 1934 [[package]] 1805 1935 name = "merde" 1806 - version = "10.0.7" 1936 + version = "10.0.6" 1807 1937 source = "registry+https://github.com/rust-lang/crates.io-index" 1808 - checksum = "edd8dc7668eb89ede52dc09d4b21a8c2f7c9cd47168ea1f82550f705615d9b99" 1938 + checksum = "5ec14139b169a3bb101da2dd8c0c2e47ddaf63000075662635c64c985bb5ae7b" 1809 1939 dependencies = [ 1810 1940 "merde_core", 1811 1941 "merde_json", ··· 1815 1945 1816 1946 [[package]] 1817 1947 name = "merde_core" 1818 - version = "10.0.6" 1948 + version = "10.0.5" 1819 1949 source = "registry+https://github.com/rust-lang/crates.io-index" 1820 - checksum = "e937026f22a5a3567bc402f1edf871ecab0e0222cd6f829ea58abae0185e759c" 1950 + checksum = "714d8f25279d095f8d23392476e2e82427e8689348e34f90ddc0712497e157de" 1821 1951 dependencies = [ 1822 1952 "camino", 1823 1953 "compact_bytes", ··· 1829 1959 1830 1960 [[package]] 1831 1961 name = "merde_json" 1832 - version = "10.0.6" 1962 + version = "10.0.5" 1833 1963 source = "registry+https://github.com/rust-lang/crates.io-index" 1834 - checksum = "a729dbfff53e394d26496e43edd4725032cd70f917e9f050fa5639f6a4af3abd" 1964 + checksum = "d354c179fe95a0568c8ffb95c276f73556ecb95edca76f742505320e7545cea9" 1835 1965 dependencies = [ 1836 1966 "itoa", 1837 1967 "lexical-parse-float", ··· 1841 1971 1842 1972 [[package]] 1843 1973 name = "merde_msgpack" 1844 - version = "10.0.6" 1974 + version = "10.0.5" 1845 1975 source = "registry+https://github.com/rust-lang/crates.io-index" 1846 - checksum = "ffe4620c27f9a69f4d105f011855584217648923920273e082507a3b464a8159" 1976 + checksum = "f2b710370fee77ca3cb8e6666a2586f26f3a653d7b2e338ede77a13c99108c5e" 1847 1977 dependencies = [ 1848 1978 "merde_core", 1849 1979 "rmp", ··· 1851 1981 1852 1982 [[package]] 1853 1983 name = "merde_yaml" 1854 - version = "10.0.6" 1984 + version = "10.0.5" 1855 1985 source = "registry+https://github.com/rust-lang/crates.io-index" 1856 - checksum = "7c36f61da594ecad0ed986ceeb5061eba47a36fcf839576ce525c7e4ff08f3fa" 1986 + checksum = "cb581c31249876b3b385a2cc50fafc666adc9c316874819b7aac7266b3c26c17" 1857 1987 dependencies = [ 1858 1988 "merde_core", 1859 1989 "yaml-rust2", ··· 1894 2024 version = "0.3.17" 1895 2025 source = "registry+https://github.com/rust-lang/crates.io-index" 1896 2026 checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" 2027 + 2028 + [[package]] 2029 + name = "mime_guess" 2030 + version = "2.0.5" 2031 + source = "registry+https://github.com/rust-lang/crates.io-index" 2032 + checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" 2033 + dependencies = [ 2034 + "mime", 2035 + "unicase", 2036 + ] 1897 2037 1898 2038 [[package]] 1899 2039 name = "minijinja" ··· 2092 2232 2093 2233 [[package]] 2094 2234 name = "ordered-float" 2095 - version = "5.0.0" 2235 + version = "4.6.0" 2096 2236 source = "registry+https://github.com/rust-lang/crates.io-index" 2097 - checksum = "e2c1f9f56e534ac6a9b8a4600bdf0f530fb393b5f393e7b4d03489c3cf0c3f01" 2237 + checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" 2098 2238 dependencies = [ 2099 2239 "num-traits", 2100 2240 ] ··· 2429 2569 2430 2570 [[package]] 2431 2571 name = "rusqlite" 2432 - version = "0.35.0" 2572 + version = "0.32.1" 2433 2573 source = "registry+https://github.com/rust-lang/crates.io-index" 2434 - checksum = "a22715a5d6deef63c637207afbe68d0c72c3f8d0022d7cf9714c442d6157606b" 2574 + checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" 2435 2575 dependencies = [ 2436 2576 "bitflags", 2437 2577 "fallible-iterator", 2438 2578 "fallible-streaming-iterator", 2439 - "hashlink 0.10.0", 2579 + "hashlink 0.9.1", 2440 2580 "libsqlite3-sys", 2441 2581 "smallvec", 2442 2582 ] ··· 3124 3264 ] 3125 3265 3126 3266 [[package]] 3267 + name = "tower-cookies" 3268 + version = "0.11.0" 3269 + source = "registry+https://github.com/rust-lang/crates.io-index" 3270 + checksum = "151b5a3e3c45df17466454bb74e9ecedecc955269bdedbf4d150dfa393b55a36" 3271 + dependencies = [ 3272 + "axum-core 0.5.2", 3273 + "cookie", 3274 + "futures-util", 3275 + "http", 3276 + "parking_lot", 3277 + "pin-project-lite", 3278 + "tower-layer", 3279 + "tower-service", 3280 + ] 3281 + 3282 + [[package]] 3283 + name = "tower-http" 3284 + version = "0.6.4" 3285 + source = "registry+https://github.com/rust-lang/crates.io-index" 3286 + checksum = "0fdb0c213ca27a9f57ab69ddb290fd80d970922355b83ae380b395d3986b8a2e" 3287 + dependencies = [ 3288 + "bitflags", 3289 + "bytes", 3290 + "futures-util", 3291 + "http", 3292 + "http-body", 3293 + "http-body-util", 3294 + "http-range-header", 3295 + "httpdate", 3296 + "mime", 3297 + "mime_guess", 3298 + "percent-encoding", 3299 + "pin-project-lite", 3300 + "tokio", 3301 + "tokio-util", 3302 + "tower-layer", 3303 + "tower-service", 3304 + "tracing", 3305 + ] 3306 + 3307 + [[package]] 3127 3308 name = "tower-layer" 3128 3309 version = "0.3.3" 3129 3310 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3411 3592 name = "weaver-appview" 3412 3593 version = "0.1.0" 3413 3594 dependencies = [ 3414 - "axum", 3595 + "atrium-api", 3596 + "atrium-common", 3597 + "atrium-identity", 3598 + "atrium-oauth", 3599 + "atrium-xrpc", 3600 + "axum 0.8.4", 3415 3601 "clap", 3602 + "diesel", 3603 + "dotenvy", 3416 3604 "tokio", 3605 + "tower", 3606 + "tower-cookies", 3607 + "tower-http", 3417 3608 "weaver-common", 3418 3609 "weaver-workspace-hack", 3419 3610 ] ··· 3486 3677 name = "weaver-server" 3487 3678 version = "0.1.0" 3488 3679 dependencies = [ 3489 - "axum", 3680 + "axum 0.7.9", 3490 3681 "clap", 3491 3682 "tokio", 3492 3683 "weaver-common",
+17 -2
crates/weaver-appview/Cargo.toml
··· 8 8 [dependencies] 9 9 weaver-common = { path = "../weaver-common" } 10 10 weaver-workspace-hack = { version = "0.1", path = "../weaver-workspace-hack" } 11 + clap = { version = "4.5", features = ["derive", "env", "cargo", "unicode"] } 11 12 12 - axum = "0.7.5" 13 + axum = "0.8" 14 + tower = "0.5" 15 + tower-http = { version = "0.6", features = ["fs"] } 16 + tower-cookies = "0.11" 17 + 18 + 13 19 tokio = { version = "1.44", features = ["full"] } 20 + atrium-oauth = "0.1.1" 21 + atrium-xrpc = "0.12.3" 22 + atrium-api = "0.25.3" 23 + atrium-common = "0.1.1" 24 + atrium-identity = "0.1.3" 14 25 15 26 16 - clap = { version = "4.5", features = ["derive", "env", "cargo", "unicode"] } 27 + diesel = { version = "2.2.0", features = ["sqlite", "returning_clauses_for_sqlite_3_35"] } 28 + # build libsqlite3 as part of the build process 29 + # uncomment this line if you run into setup issues 30 + # libsqlite3-sys = { version = "0.30", features = ["bundled"] } 31 + dotenvy = "0.15"
+9
crates/weaver-appview/diesel.toml
··· 1 + # For documentation on how to configure this file, 2 + # see https://diesel.rs/guides/configuring-diesel-cli 3 + 4 + [print_schema] 5 + file = "src/schema.rs" 6 + custom_type_derives = ["diesel::query_builder::QueryId", "Clone"] 7 + 8 + [migrations_directory] 9 + dir = "/home/orual/Projects/weaver.sh/crates/weaver-appview/migrations"
crates/weaver-appview/migrations/.keep

This is a binary file and will not be displayed.

+2
crates/weaver-appview/src/main.rs
··· 1 + mod oauth; 2 + 1 3 #[tokio::main] 2 4 async fn main() {}
crates/weaver-appview/src/oauth.rs

This is a binary file and will not be displayed.

+2 -3
crates/weaver-cli/src/main.rs
··· 6 6 use std::{ 7 7 error, 8 8 io::{BufRead, Write, stdin, stdout}, 9 - sync::Arc, 10 9 }; 11 10 12 11 #[tokio::main] 13 12 async fn main() -> Result<(), Box<dyn error::Error>> { 14 - let client = weaver_common::oauth::default_oauth_client("http://127.0.0.1/callback")?; 13 + let client = weaver_common::oauth::default_oauth_client("https://appview.weaver.sh")?; 15 14 println!( 16 15 "Authorization url: {}", 17 16 client 18 17 .authorize( 19 - std::env::var("PDS_URL").unwrap_or(String::from("https://atproto.systems")), 18 + std::env::var("HANDLE").unwrap_or(String::from("https://atproto.systems")), 20 19 AuthorizeOptions { 21 20 scopes: vec![ 22 21 Scope::Known(KnownScope::Atproto),
+5 -1
crates/weaver-common/Cargo.toml
··· 5 5 license.workspace = true 6 6 publish = false 7 7 8 + [features] 9 + default = ["dev"] 10 + dev = [] 11 + 8 12 [dependencies] 9 13 n0-future = { workspace = true } 10 14 weaver-workspace-hack = { version = "0.1", path = "../weaver-workspace-hack" } 11 15 markdown-weaver = { workspace = true } 12 - libsqlite3-sys = { version = "0.33.0", features = ["bundled"] } 16 + libsqlite3-sys = { version = "0.30.1", features = ["bundled"] } 13 17 14 18 http = "1.3.1" 15 19
+41 -10
crates/weaver-common/src/oauth.rs
··· 4 4 did::{CommonDidResolver, CommonDidResolverConfig, DEFAULT_PLC_DIRECTORY_URL}, 5 5 handle::{AtprotoHandleResolver, AtprotoHandleResolverConfig}, 6 6 }; 7 + #[cfg(not(feature = "dev"))] 8 + use atrium_oauth::AtprotoClientMetadata; 9 + #[cfg(feature = "dev")] 10 + use atrium_oauth::AtprotoLocalhostClientMetadata; 7 11 use atrium_oauth::{ 8 - AtprotoLocalhostClientMetadata, DefaultHttpClient, KnownScope, OAuthClient, OAuthClientConfig, 9 - OAuthResolverConfig, Scope, 12 + DefaultHttpClient, KnownScope, OAuthClient, OAuthClientConfig, OAuthResolverConfig, Scope, 10 13 store::{ 11 14 session::{MemorySessionStore, Session}, 12 15 state::{InternalStateData, MemoryStateStore}, ··· 30 33 atrium_oauth::Error, 31 34 > { 32 35 let http_client = Arc::new(atrium_oauth::DefaultHttpClient::default()); 36 + let keys = if cfg!(feature = "dev") { None } else { todo!() }; 33 37 let config = OAuthClientConfig { 34 - client_metadata: AtprotoLocalhostClientMetadata { 35 - redirect_uris: Some(vec![url.as_ref().to_string()]), 36 - scopes: Some(vec![ 37 - Scope::Known(KnownScope::Atproto), 38 - Scope::Known(KnownScope::TransitionGeneric), 39 - ]), 40 - }, 41 - keys: None, 38 + client_metadata: default_client_metadata(url.as_ref()), 39 + keys, 42 40 resolver: OAuthResolverConfig { 43 41 did_resolver: CommonDidResolver::new(CommonDidResolverConfig { 44 42 plc_directory_url: DEFAULT_PLC_DIRECTORY_URL.to_string(), ··· 57 55 let client = OAuthClient::new(config)?; 58 56 Ok(client) 59 57 } 58 + 59 + #[cfg(feature = "dev")] 60 + pub fn default_client_metadata(_host: &str) -> AtprotoLocalhostClientMetadata { 61 + AtprotoLocalhostClientMetadata { 62 + redirect_uris: make_redirect_uris("http://127.0.0.1:4000"), 63 + scopes: make_scopes(), 64 + } 65 + } 66 + 67 + #[cfg(not(feature = "dev"))] 68 + pub fn default_client_metadata(host: &str) -> AtprotoClientMetadata { 69 + AtprotoClientMetadata { 70 + client_id: host.to_string(), 71 + redirect_uris: make_redirect_uris(host), 72 + scopes: make_scopes(), 73 + token_endpoint_auth_method: AuthMethod::PrivateKeyJwt, 74 + grant_types: vec![GrantType::AuthorizationCode, GrantType::RefreshToken], 75 + token_endpoint_auth_signing_alg: Some(String::from("ES256")), 76 + } 77 + } 78 + 79 + #[inline] 80 + fn make_redirect_uris(url: &str) -> Option<Vec<String>> { 81 + Some(vec![format!("{}/oauth/callback", url)]) 82 + } 83 + 84 + #[inline] 85 + fn make_scopes() -> Option<Vec<Scope>> { 86 + Some(vec![ 87 + Scope::Known(KnownScope::Atproto), 88 + Scope::Known(KnownScope::TransitionGeneric), 89 + ]) 90 + }
-12
docs/oauth/client-metadata.json
··· 1 - { 2 - "client_id": "https://appview.weaver.sh/oauth/client-metadata.json", 3 - "application_type": "native", 4 - "client_name": "Weaver Appview", 5 - "client_uri": "https://appview.weaver.sh", 6 - "dpop_bound_access_tokens": true, 7 - "grant_types": ["authorization_code", "refresh_token"], 8 - "redirect_uris": ["http://127.0.0.1:8080/oauth/callback"], 9 - "response_types": ["code"], 10 - "scope": "atproto transition:generic", 11 - "token_endpoint_auth_method": "none" 12 - }
+2
flake.nix
··· 272 272 NIX_LD = lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; 273 273 274 274 LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:$NIX_LD_LIBRARY_PATH"; 275 + DATABASE_URL = "./.db/weaver.db"; 275 276 276 277 # Additional dev-shell environment variables can be set directly 277 278 # MY_CUSTOM_DEVELOPMENT_VAR = "something else"; ··· 281 282 cargo-hakari 282 283 nixd 283 284 alejandra 285 + diesel-cli 284 286 ]; 285 287 }; 286 288 });