From 6b6b7014f57ce6f5be7af805577b429ad5527521 Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Tue, 29 Aug 2023 12:53:46 -0600 Subject: [PATCH] feat: add clients for ceramic and kubo (#5) --- Cargo.lock | 588 +++++++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 18 ++ tests/api.rs | 132 +++++++++++- 3 files changed, 688 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18def16d..c48cf5a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,7 +25,7 @@ checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom 0.2.10", "once_cell", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -36,7 +36,7 @@ checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "once_cell", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -144,11 +144,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock", - "autocfg", + "autocfg 1.1.0", "cfg-if", "concurrent-queue", "futures-lite", - "log", + "log 0.4.20", "parking", "polling", "rustix 0.37.23", @@ -184,7 +184,7 @@ dependencies = [ "futures-lite", "gloo-timers", "kv-log-macro", - "log", + "log 0.4.20", "memchr", "once_cell", "pin-project-lite", @@ -216,6 +216,15 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +[[package]] +name = "autocfg" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -249,6 +258,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +[[package]] +name = "base64" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" +dependencies = [ + "byteorder", + "safemem", +] + [[package]] name = "base64" version = "0.12.3" @@ -409,7 +428,7 @@ dependencies = [ "atomic-waker", "fastrand 1.9.0", "futures-lite", - "log", + "log 0.4.20", ] [[package]] @@ -421,6 +440,16 @@ dependencies = [ "sha2 0.9.9", ] +[[package]] +name = "buf_redux" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" +dependencies = [ + "memchr", + "safemem", +] + [[package]] name = "bumpalo" version = "3.13.0" @@ -439,6 +468,16 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + [[package]] name = "bytes" version = "1.4.0" @@ -492,10 +531,35 @@ dependencies = [ "libc", ] +[[package]] +name = "ceramic-api-server" +version = "0.1.0" +source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" +dependencies = [ + "async-trait", + "chrono", + "futures", + "hyper", + "hyper-openssl", + "hyper-tls", + "lazy_static", + "log 0.4.20", + "mime 0.3.17", + "native-tls", + "openssl", + "percent-encoding 2.3.0", + "regex", + "serde", + "serde_ignored", + "serde_json", + "swagger", + "url", +] + [[package]] name = "ceramic-core" version = "0.1.0" -source = "git+https://github.com/3box/rust-ceramic?branch=main#ff306f4178e8c703f4b64322556a1b8d68c347d9" +source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" dependencies = [ "anyhow", "async-trait", @@ -521,7 +585,7 @@ dependencies = [ [[package]] name = "ceramic-event" version = "0.1.0" -source = "git+https://github.com/3box/rust-ceramic?branch=main#ff306f4178e8c703f4b64322556a1b8d68c347d9" +source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" dependencies = [ "anyhow", "ceramic-core", @@ -549,6 +613,33 @@ dependencies = [ "url", ] +[[package]] +name = "ceramic-kubo-rpc-server" +version = "0.1.0" +source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" +dependencies = [ + "async-trait", + "chrono", + "futures", + "hyper", + "hyper-openssl", + "hyper-tls", + "lazy_static", + "log 0.4.20", + "mime 0.2.6", + "mime 0.3.17", + "multipart", + "native-tls", + "openssl", + "percent-encoding 2.3.0", + "regex", + "serde", + "serde_ignored", + "serde_json", + "swagger", + "url", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -608,6 +699,15 @@ dependencies = [ "cc", ] +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "combination" version = "0.1.5" @@ -1218,9 +1318,15 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ - "percent-encoding", + "percent-encoding 2.3.0", ] +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "funty" version = "1.1.0" @@ -1347,7 +1453,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -1421,7 +1527,7 @@ version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" dependencies = [ - "bytes", + "bytes 1.4.0", "fnv", "futures-core", "futures-sink", @@ -1491,7 +1597,7 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ - "bytes", + "bytes 1.4.0", "fnv", "itoa", ] @@ -1502,7 +1608,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ - "bytes", + "bytes 1.4.0", "http", "pin-project-lite", ] @@ -1525,7 +1631,7 @@ version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ - "bytes", + "bytes 1.4.0", "futures-channel", "futures-core", "futures-util", @@ -1543,6 +1649,41 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-old-types" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6896be51ecf3966c0fa14ff2da3233dbb9aef57ccea1be1afe55f105f4d4c9c4" +dependencies = [ + "base64 0.9.3", + "bytes 0.4.12", + "httparse", + "language-tags", + "log 0.4.20", + "mime 0.3.17", + "percent-encoding 1.0.1", + "time 0.1.45", + "unicase 2.7.0", +] + +[[package]] +name = "hyper-openssl" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ee5d7a8f718585d1c3c61dfde28ef5b0bb14734b4db13f5ada856cdc6c612b" +dependencies = [ + "http", + "hyper", + "linked_hash_set", + "once_cell", + "openssl", + "openssl-sys", + "parking_lot", + "tokio", + "tokio-openssl", + "tower-layer", +] + [[package]] name = "hyper-rustls" version = "0.24.1" @@ -1563,7 +1704,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes", + "bytes 1.4.0", "hyper", "native-tls", "tokio", @@ -1615,7 +1756,7 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "autocfg", + "autocfg 1.1.0", "hashbrown 0.12.3", "serde", ] @@ -1671,6 +1812,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + [[package]] name = "ipnet" version = "2.8.0" @@ -1788,8 +1938,8 @@ dependencies = [ "langtag", "locspan", "locspan-derive", - "log", - "mime", + "log 0.4.20", + "mime 0.3.17", "mown", "once_cell", "permutohedron", @@ -1924,7 +2074,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" dependencies = [ - "log", + "log 0.4.20", ] [[package]] @@ -1933,6 +2083,12 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed60c85f254d6ae8450cec15eedd921efbc4d1bdf6fcf6202b9a58b403f6f805" +[[package]] +name = "language-tags" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" + [[package]] name = "lazy_static" version = "1.4.0" @@ -2035,7 +2191,7 @@ dependencies = [ "libipld-core", "libipld-json", "libipld-macro", - "log", + "log 0.4.20", "multihash 0.16.3", "parking_lot", "thiserror", @@ -2115,7 +2271,7 @@ checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" dependencies = [ "bs58", "ed25519-dalek", - "log", + "log 0.4.20", "multiaddr", "multihash 0.17.0", "quick-protobuf", @@ -2125,6 +2281,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linked_hash_set" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -2143,7 +2314,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ - "autocfg", + "autocfg 1.1.0", "scopeguard", ] @@ -2169,6 +2340,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "log" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" +dependencies = [ + "log 0.4.20", +] + [[package]] name = "log" version = "0.4.20" @@ -2193,12 +2373,33 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "mime" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" +dependencies = [ + "log 0.3.9", +] + [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "1.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216929a5ee4dd316b1702eedf5e74548c123d370f47841ceaac38ca154690ca3" +dependencies = [ + "mime 0.2.6", + "phf", + "phf_codegen", + "unicase 1.4.2", +] + [[package]] name = "minicbor" version = "0.19.1" @@ -2254,10 +2455,10 @@ dependencies = [ "arrayref", "byteorder", "data-encoding", - "log", + "log 0.4.20", "multibase 0.9.1", "multihash 0.17.0", - "percent-encoding", + "percent-encoding 2.3.0", "serde", "static_assertions", "unsigned-varint", @@ -2338,6 +2539,24 @@ dependencies = [ "synstructure", ] +[[package]] +name = "multipart" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136eed74cadb9edd2651ffba732b19a450316b680e4f48d6c79e905799e19d01" +dependencies = [ + "buf_redux", + "httparse", + "log 0.4.20", + "mime 0.2.6", + "mime_guess", + "quick-error", + "rand 0.6.5", + "safemem", + "tempfile", + "twoway", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -2346,7 +2565,7 @@ checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ "lazy_static", "libc", - "log", + "log 0.4.20", "openssl", "openssl-probe", "openssl-sys", @@ -2372,7 +2591,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -2411,7 +2630,7 @@ version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-traits", ] @@ -2421,7 +2640,7 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -2432,7 +2651,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ - "autocfg", + "autocfg 1.1.0", "libm", ] @@ -2581,6 +2800,12 @@ dependencies = [ "base64ct", ] +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + [[package]] name = "percent-encoding" version = "2.3.0" @@ -2593,6 +2818,45 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b687ff7b5da449d39e418ad391e5e08da53ec334903ddbb921db208908fc372c" +[[package]] +name = "phf" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +dependencies = [ + "phf_shared", + "rand 0.6.5", +] + +[[package]] +name = "phf_shared" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +dependencies = [ + "siphasher", + "unicase 1.4.2", +] + [[package]] name = "pin-project-lite" version = "0.2.12" @@ -2649,12 +2913,12 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ - "autocfg", + "autocfg 1.1.0", "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", - "log", + "log 0.4.20", "pin-project-lite", "windows-sys", ] @@ -2704,7 +2968,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -2715,7 +2979,7 @@ checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2", "quote", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -2727,6 +2991,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quick-protobuf" version = "0.8.1" @@ -2751,6 +3021,25 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.8", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi", +] + [[package]] name = "rand" version = "0.7.3" @@ -2761,7 +3050,7 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc", + "rand_hc 0.2.0", ] [[package]] @@ -2775,6 +3064,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.3.1", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -2795,6 +3094,21 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + [[package]] name = "rand_core" version = "0.5.1" @@ -2813,6 +3127,15 @@ dependencies = [ "getrandom 0.2.10", ] +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -2822,6 +3145,59 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "rdf-types" version = "0.12.19" @@ -2835,6 +3211,15 @@ dependencies = [ "locspan-derive", ] +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "redox_syscall" version = "0.3.5" @@ -2895,7 +3280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ "base64 0.21.2", - "bytes", + "bytes 1.4.0", "encoding_rs", "futures-core", "futures-util", @@ -2907,11 +3292,11 @@ dependencies = [ "hyper-tls", "ipnet", "js-sys", - "log", - "mime", + "log 0.4.20", + "mime 0.3.17", "native-tls", "once_cell", - "percent-encoding", + "percent-encoding 2.3.0", "pin-project-lite", "rustls", "rustls-pemfile", @@ -2991,8 +3376,12 @@ dependencies = [ name = "rust-ceramic-migration-tests" version = "0.1.0" dependencies = [ + "ceramic-api-server", "ceramic-http-client", + "ceramic-kubo-rpc-server", "dotenvy", + "hyper", + "swagger", "tokio", "tracing", "tracing-test", @@ -3038,7 +3427,7 @@ version = "0.21.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" dependencies = [ - "log", + "log 0.4.20", "ring", "rustls-webpki", "sct", @@ -3081,6 +3470,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "700de91d5fd6091442d00fdd9ee790af6d4f0f480562b0f5a1e8f59e90aafe73" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "schannel" version = "0.1.22" @@ -3216,6 +3611,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "serde_ignored" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80c31d5c53fd39f208e770f5a20a0bb214dee2a8d0d8adba18e19ad95a482ca5" +dependencies = [ + "serde", +] + [[package]] name = "serde_ipld_dagcbor" version = "0.3.0" @@ -3390,6 +3794,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "siphasher" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" + [[package]] name = "siwe" version = "0.5.2" @@ -3426,9 +3836,15 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ - "autocfg", + "autocfg 1.1.0", ] +[[package]] +name = "slog" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" + [[package]] name = "smallstr" version = "0.3.0" @@ -3929,6 +4345,27 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "swagger" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fbc05d7c4952357d7a0e69884942c84df3d0990c56768cc019869e9af6a4019" +dependencies = [ + "base64 0.13.1", + "futures", + "hyper", + "hyper-old-types", + "hyper-openssl", + "hyper-tls", + "mime 0.3.17", + "native-tls", + "openssl", + "serde", + "serde_json", + "slog", + "uuid", +] + [[package]] name = "syn" version = "1.0.109" @@ -4082,7 +4519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ "backtrace", - "bytes", + "bytes 1.4.0", "libc", "mio", "num_cpus", @@ -4113,6 +4550,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-openssl" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08f9ffb7809f1b20c1b398d92acf4cc719874b3b2b2d9ea2f09b4a80350878a" +dependencies = [ + "futures-util", + "openssl", + "openssl-sys", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -4129,7 +4578,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ - "bytes", + "bytes 1.4.0", "futures-core", "futures-sink", "pin-project-lite", @@ -4154,6 +4603,12 @@ dependencies = [ "winnow", ] +[[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" @@ -4200,7 +4655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" dependencies = [ "lazy_static", - "log", + "log 0.4.20", "tracing-core", ] @@ -4260,6 +4715,15 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "twoway" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1" +dependencies = [ + "memchr", +] + [[package]] name = "typenum" version = "1.16.0" @@ -4278,6 +4742,24 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicase" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" +dependencies = [ + "version_check 0.1.5", +] + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check 0.9.4", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -4325,7 +4807,7 @@ checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", - "percent-encoding", + "percent-encoding 2.3.0", ] [[package]] @@ -4334,6 +4816,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca61eb27fa339aa08826a29f03e87b99b4d8f0fc2255306fd266bb1b6a9de498" +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.10", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" @@ -4352,6 +4844,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" + [[package]] name = "version_check" version = "0.9.4" @@ -4408,7 +4906,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", - "log", + "log 0.4.20", "once_cell", "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index c9519b74..90253542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,26 @@ edition = "2021" [dependencies] ceramic-http-client = { git = "https://github.com/3box/ceramic-http-client-rs.git", branch = "main" } +ceramic-api-server = { git = "https://github.com/3box/rust-ceramic", branch = "main", default-features = false, features = [ + "client", + # TODO: We do not need the server but the generated feature flags are broken + # percent-encoding dep is not included with client feature alone. + "server", +] } +ceramic-kubo-rpc-server = { git = "https://github.com/3box/rust-ceramic", branch = "main", default-features = false, features = [ + "client", + # TODO: We do not need the server but the generated feature flags are broken + # percent-encoding dep is not included with client feature alone. + "server", +] } dotenvy = "0.15.7" tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] } tracing = "0.1" tracing-test = "0.2" url = { version = "2.2.2" } +swagger = "6.3.0" +hyper = { version = "0.14.27", features = ["client"] } + +#[patch."https://github.com/3box/rust-ceramic"] +#ceramic-api-server = { path = "../rust-ceramic/api-server" } +#ceramic-kubo-rpc-server = { path = "../rust-ceramic/kubo-rpc-server" } diff --git a/tests/api.rs b/tests/api.rs index bb0bb534..24c5d0e3 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -2,6 +2,12 @@ use std::env; use std::path::Path; use std::sync::Once; +use ceramic_api_server::ApiNoContext as CeramicApi; +use ceramic_kubo_rpc_server::ApiNoContext as KuboRpcApi; + +use swagger::{ + AuthData, ContextBuilder, ContextWrapper, DropContextService, EmptyContext, Push, XSpanIdString, +}; use tokio::sync::OnceCell; use tracing_test::traced_test; use url::Url; @@ -15,6 +21,39 @@ const ENV_PATH: &str = "ENV_PATH"; static INIT_ENV: Once = Once::new(); static COMPOSEDB_CLIENTS: OnceCell> = OnceCell::const_new(); +static CERAMIC_CLIENTS: OnceCell> = OnceCell::const_new(); +static KUBO_RPC_CLIENTS: OnceCell> = OnceCell::const_new(); + +type ClientContext = swagger::make_context_ty!( + ContextBuilder, + EmptyContext, + Option, + XSpanIdString +); +type CeramicClient = Box< + ContextWrapper< + ceramic_api_server::Client< + DropContextService< + hyper::client::Client, + ClientContext, + >, + ClientContext, + >, + ClientContext, + >, +>; +type KuboRpcClient = Box< + ContextWrapper< + ceramic_kubo_rpc_server::Client< + DropContextService< + hyper::client::Client, + ClientContext, + >, + ClientContext, + >, + ClientContext, + >, +>; fn init_env() { INIT_ENV.call_once(|| { @@ -44,6 +83,67 @@ async fn get_composedb_clients() -> &'static Vec { .await } +async fn get_ceramic_clients() -> &'static Vec { + CERAMIC_CLIENTS + .get_or_init(|| async { + init_env(); + // Parse Ceramic URLs and create clients + let urls = env::var(CERAMIC_URLS).unwrap_or_default(); + let urls = urls.split(','); + let mut clients = Vec::new(); + + for url in urls { + if url.is_empty() { + continue; + } + let context: ClientContext = swagger::make_context!( + ContextBuilder, + EmptyContext, + None as Option, + XSpanIdString::default() + ); + let client = ceramic_api_server::Client::try_new_http(url) + .expect("Failed to create HTTP client"); + clients.push(Box::new( + ceramic_api_server::ContextWrapperExt::with_context(client, context), + )) + } + + clients + }) + .await +} +async fn get_kubo_rpc_clients() -> &'static Vec { + KUBO_RPC_CLIENTS + .get_or_init(|| async { + init_env(); + // Parse Ceramic URLs and create clients + let urls = env::var(CERAMIC_URLS).unwrap_or_default(); + let urls = urls.split(','); + let mut clients = Vec::new(); + + for url in urls { + if url.is_empty() { + continue; + } + let context: ClientContext = swagger::make_context!( + ContextBuilder, + EmptyContext, + None as Option, + XSpanIdString::default() + ); + let client = ceramic_kubo_rpc_server::Client::try_new_http(url) + .expect("Failed to create HTTP client"); + clients.push(Box::new( + ceramic_kubo_rpc_server::ContextWrapperExt::with_context(client, context), + )) + } + + clients + }) + .await +} + #[tokio::test] #[traced_test] async fn hello_composedb() { @@ -60,10 +160,32 @@ async fn hello_composedb() { #[tokio::test] #[traced_test] async fn hello_ceramic() { - init_env(); - if let Ok(urls) = env::var(CERAMIC_URLS) { - urls.split(',').for_each(|url| { - println!("Hello Ceramic!\n{:?}", url); - }); + let ceramic_clients = get_ceramic_clients().await; + assert!(!ceramic_clients.is_empty()); + for c in ceramic_clients { + // TODO(nathanielc): change this to a version call once https://github.com/3box/rust-ceramic/pull/83 + // merges + let _ = c + .subscribe_sort_key_sort_value_get( + "model".to_string(), + "sort_value".to_string(), + None, + None, + None, + None, + ) + .await + .unwrap(); + } +} + +#[tokio::test] +#[traced_test] +async fn hello_kubo_rpc() { + let kubo_rpc_clients = get_kubo_rpc_clients().await; + assert!(!kubo_rpc_clients.is_empty()); + for c in kubo_rpc_clients { + let id = c.id_post(None).await.unwrap(); + println!("{id:?}"); } }