Cleanups and licensing fix

This commit is contained in:
Christien Rioux 2025-09-03 10:27:23 -04:00
parent 6a79e13024
commit 34c82ec128
41 changed files with 14725 additions and 12558 deletions

View file

@ -37,6 +37,7 @@
- Added SequenceOrdering enum to represent ordering mode for protocols rather than a bool
- `RecordKey`s are now validated on both server side and client side of DHT RPC operations, closes [#299](https://gitlab.com/veilid/veilid/-/issues/299)
- Revert punishment for FailedToVerifySenderPeerInfo, with a better peer info filter, fixes [#470](https://gitlab.com/veilid/veilid/-/issues/470)
- Update keyring-manager to eliminate licensing issue
- veilid-python:
- Correction of type hints

362
Cargo.lock generated
View file

@ -212,9 +212,9 @@ checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
[[package]]
name = "arboard"
version = "3.6.0"
version = "3.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55f533f8e0af236ffe5eb979b99381df3258853f00ba2e44b6e1955292c75227"
checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf"
dependencies = [
"clipboard-win",
"log",
@ -223,6 +223,7 @@ dependencies = [
"objc2-foundation",
"parking_lot 0.12.4",
"percent-encoding",
"windows-sys 0.60.2",
"x11rb",
]
@ -291,9 +292,9 @@ dependencies = [
[[package]]
name = "async-executor"
version = "1.13.2"
version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb812ffb58524bdd10860d7d974e2f01cc0950c2438a74ee5ec2e2280c6c4ffa"
checksum = "497c00e0fd83a72a79a39fcbd8e3e2f055d6f6c7e025f3b3d91f4f8e76527fb8"
dependencies = [
"async-task",
"concurrent-queue",
@ -746,9 +747,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.9.2"
version = "2.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29"
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
[[package]]
name = "bitmaps"
@ -883,28 +884,29 @@ dependencies = [
[[package]]
name = "capnp"
version = "0.21.4"
version = "0.21.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "def25bdbbc2758b363d79129c7f277520e3347e8b647c404d4823591f837c4ad"
checksum = "f62fcad97587224e2a1bd12ec1c7c0e95b93cefd285763a174cf1b34048c6437"
dependencies = [
"embedded-io 0.6.1",
]
[[package]]
name = "capnpc"
version = "0.21.2"
version = "0.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d93a18ec8176d4a87f1852b6a560b4196729365c01ba3cad03b73a376a23c56e"
checksum = "6da96dcb0a0e0c526daf42bac55e1550f18ad973df9ef9ba75204f332c80ad16"
dependencies = [
"capnp",
]
[[package]]
name = "cc"
version = "1.2.33"
version = "1.2.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f"
checksum = "590f9024a68a8c40351881787f1934dc11afd69090f5edb6831464694d836ea3"
dependencies = [
"find-msvc-tools",
"shlex",
]
@ -1028,9 +1030,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.5.45"
version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318"
checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931"
dependencies = [
"clap_builder",
"clap_derive",
@ -1038,9 +1040,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.5.44"
version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8"
checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6"
dependencies = [
"anstream",
"anstyle",
@ -1051,9 +1053,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.5.45"
version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6"
checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
dependencies = [
"heck",
"proc-macro2",
@ -1091,7 +1093,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
dependencies = [
"thiserror 2.0.15",
"thiserror 2.0.16",
]
[[package]]
@ -1161,13 +1163,13 @@ dependencies = [
[[package]]
name = "config"
version = "0.15.14"
version = "0.15.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4092bf3922a966e2bd74640b80f36c73eaa7251a4fd0fbcda1f8a4de401352"
checksum = "0faa974509d38b33ff89282db9c3295707ccf031727c0de9772038ec526852ba"
dependencies = [
"pathdiff",
"serde",
"winnow 0.7.12",
"winnow 0.7.13",
"yaml-rust2 0.10.3",
]
@ -1263,6 +1265,16 @@ dependencies = [
"libc",
]
[[package]]
name = "core-foundation"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
@ -1314,7 +1326,7 @@ version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"crossterm_winapi",
"libc",
"mio 0.8.11",
@ -1330,7 +1342,7 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"crossterm_winapi",
"derive_more",
"document-features",
@ -1527,12 +1539,12 @@ dependencies = [
[[package]]
name = "darling"
version = "0.21.2"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08440b3dd222c3d0433e63e097463969485f112baff337dfdaca043a0d760570"
checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0"
dependencies = [
"darling_core 0.21.2",
"darling_macro 0.21.2",
"darling_core 0.21.3",
"darling_macro 0.21.3",
]
[[package]]
@ -1565,9 +1577,9 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.21.2"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d25b7912bc28a04ab1b7715a68ea03aaa15662b43a1a4b2c480531fd19f8bf7e"
checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4"
dependencies = [
"fnv",
"ident_case",
@ -1600,11 +1612,11 @@ dependencies = [
[[package]]
name = "darling_macro"
version = "0.21.2"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce154b9bea7fb0c8e8326e62d00354000c36e79770ff21b8c84e3aa267d9d531"
checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81"
dependencies = [
"darling_core 0.21.2",
"darling_core 0.21.3",
"quote",
"syn 2.0.106",
]
@ -1640,9 +1652,9 @@ dependencies = [
[[package]]
name = "deranged"
version = "0.4.0"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc"
dependencies = [
"powerfmt",
"serde",
@ -1727,7 +1739,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"objc2",
]
@ -1871,9 +1883,9 @@ dependencies = [
[[package]]
name = "enumset"
version = "1.1.9"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f50acec76c668b4621fe3694e5ddee53c8fae2a03410026f50947d195eb44dc1"
checksum = "25b07a8dfbbbfc0064c0a6bdf9edcf966de6b1c33ce344bdeca3b41615452634"
dependencies = [
"enumset_derive",
"serde",
@ -1881,11 +1893,11 @@ dependencies = [
[[package]]
name = "enumset_derive"
version = "0.13.1"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "588eaef9dbc5d72c5fa4edf162527e67dab5d14ba61519ef7c8e233d5bdc092c"
checksum = "f43e744e4ea338060faee68ed933e46e722fb7f3617e722a5772d7e856d8b3ce"
dependencies = [
"darling 0.21.2",
"darling 0.21.3",
"proc-macro2",
"quote",
"syn 2.0.106",
@ -2020,16 +2032,22 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
[[package]]
name = "filetime"
version = "0.2.25"
version = "0.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586"
checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed"
dependencies = [
"cfg-if 1.0.3",
"libc",
"libredox",
"windows-sys 0.59.0",
"windows-sys 0.60.2",
]
[[package]]
name = "find-msvc-tools"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e178e4fba8a2726903f6ba98a6d221e76f9c12c650d5dc0e6afdc50677b49650"
[[package]]
name = "flate2"
version = "1.1.2"
@ -2099,9 +2117,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
dependencies = [
"percent-encoding",
]
@ -2273,12 +2291,12 @@ dependencies = [
[[package]]
name = "gethostname"
version = "0.4.3"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818"
checksum = "fc257fdb4038301ce4b9cd1b3b51704509692bb3ff716a410cbd07925d9dae55"
dependencies = [
"libc",
"windows-targets 0.48.5",
"rustix 1.0.8",
"windows-targets 0.52.6",
]
[[package]]
@ -2303,7 +2321,7 @@ dependencies = [
"cfg-if 1.0.3",
"libc",
"r-efi",
"wasi 0.14.2+wasi-0.2.4",
"wasi 0.14.3+wasi-0.2.4",
]
[[package]]
@ -2398,7 +2416,7 @@ dependencies = [
"futures-sink",
"futures-util",
"http 0.2.12",
"indexmap 2.10.0",
"indexmap 2.11.0",
"slab",
"tokio",
"tokio-util",
@ -2865,9 +2883,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "1.0.3"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
dependencies = [
"idna_adapter",
"smallvec",
@ -2942,9 +2960,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.10.0"
version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
checksum = "f2481980430f9f78649238835720ddccc57e52df14ffce1c6f37391d61b563e9"
dependencies = [
"equivalent",
"hashbrown 0.15.5",
@ -2982,11 +3000,11 @@ dependencies = [
[[package]]
name = "io-uring"
version = "0.7.9"
version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"cfg-if 1.0.3",
"libc",
]
@ -3091,14 +3109,12 @@ checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
[[package]]
name = "keyring-manager"
version = "0.5.1"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aed4aad1a5c0ae5cfd990fd8cb7e1e31d1742e04c964a62b6928962838c766d"
checksum = "7118537d59e34bd487248fb745ec6c21625d216a4722712c8fc581f6ec6bd68e"
dependencies = [
"byteorder",
"cfg-if 1.0.3",
"core-foundation",
"core-foundation-sys",
"directories",
"fs4",
"jni",
@ -3107,11 +3123,11 @@ dependencies = [
"ndk",
"ndk-glue",
"secret-service",
"security-framework",
"security-framework-sys",
"security-framework 2.11.1",
"security-framework 3.3.0",
"serde",
"serde_cbor",
"snailquote",
"unicode_categories",
"winapi",
]
@ -3216,7 +3232,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"libc",
"redox_syscall 0.5.17",
]
@ -3331,11 +3347,11 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
[[package]]
name = "matchers"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
dependencies = [
"regex-automata 0.1.10",
"regex-automata",
]
[[package]]
@ -3447,7 +3463,7 @@ dependencies = [
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework 2.11.1",
"security-framework-sys",
"tempfile",
]
@ -3578,7 +3594,7 @@ dependencies = [
"log",
"netlink-packet-core",
"netlink-sys",
"thiserror 2.0.15",
"thiserror 2.0.16",
]
[[package]]
@ -3625,7 +3641,7 @@ version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"cfg-if 1.0.3",
"libc",
]
@ -3636,7 +3652,7 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"cfg-if 1.0.3",
"cfg_aliases",
"libc",
@ -3648,7 +3664,7 @@ version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"cfg-if 1.0.3",
"cfg_aliases",
"libc",
@ -3684,12 +3700,11 @@ dependencies = [
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
version = "0.50.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
dependencies = [
"overload",
"winapi",
"windows-sys 0.52.0",
]
[[package]]
@ -3816,7 +3831,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"objc2",
"objc2-core-graphics",
"objc2-foundation",
@ -3828,7 +3843,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"dispatch2",
"objc2",
]
@ -3839,7 +3854,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"dispatch2",
"objc2",
"objc2-core-foundation",
@ -3858,7 +3873,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"objc2",
"objc2-core-foundation",
]
@ -3869,7 +3884,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"objc2",
"objc2-core-foundation",
]
@ -3907,7 +3922,7 @@ version = "0.10.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"cfg-if 1.0.3",
"foreign-types",
"libc",
@ -4148,12 +4163,6 @@ dependencies = [
"log",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owning_ref"
version = "0.4.1"
@ -4268,9 +4277,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "percent-encoding"
version = "2.3.1"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "pharos"
@ -4432,9 +4441,9 @@ dependencies = [
[[package]]
name = "potential_utf"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585"
checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a"
dependencies = [
"zerovec",
]
@ -4652,7 +4661,7 @@ version = "0.5.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
]
[[package]]
@ -4688,47 +4697,32 @@ dependencies = [
[[package]]
name = "regex"
version = "1.11.1"
version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata 0.4.9",
"regex-syntax 0.8.5",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.8.5",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
[[package]]
name = "reqwest"
@ -4836,7 +4830,7 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "549b9d036d571d42e6e85d1c1425e2ac83491075078ca9a15be021c56b1641f2"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
@ -4885,7 +4879,7 @@ version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"errno",
"libc",
"linux-raw-sys 0.4.15",
@ -4898,7 +4892,7 @@ version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"errno",
"libc",
"linux-raw-sys 0.9.4",
@ -4953,7 +4947,7 @@ dependencies = [
"futures-util",
"pin-project 1.1.10",
"thingbuf",
"thiserror 2.0.15",
"thiserror 2.0.16",
"unicode-segmentation",
]
@ -5091,8 +5085,21 @@ version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
dependencies = [
"bitflags 2.9.2",
"core-foundation",
"bitflags 2.9.4",
"core-foundation 0.9.4",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80fb1d92c5028aa318b4b8bd7302a5bfcf48be96a37fc6fc790f806b0004ee0c"
dependencies = [
"bitflags 2.9.4",
"core-foundation 0.10.1",
"core-foundation-sys",
"libc",
"security-framework-sys",
@ -5262,7 +5269,7 @@ dependencies = [
"chrono",
"hex",
"indexmap 1.9.3",
"indexmap 2.10.0",
"indexmap 2.11.0",
"schemars 0.9.0",
"schemars 1.0.4",
"serde",
@ -5290,7 +5297,7 @@ version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap 2.10.0",
"indexmap 2.11.0",
"itoa",
"ryu",
"serde",
@ -5303,7 +5310,7 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4db627b98b36d4203a7b458cf3573730f2bb591b28871d916dfa9efabfd41f"
dependencies = [
"indexmap 2.10.0",
"indexmap 2.11.0",
"itoa",
"ryu",
"serde",
@ -5491,16 +5498,6 @@ version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "snailquote"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec62a949bda7f15800481a711909f946e1204f2460f89210eaf7f57730f88f86"
dependencies = [
"thiserror 1.0.69",
"unicode_categories",
]
[[package]]
name = "socket2"
version = "0.4.10"
@ -5658,7 +5655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-foundation 0.9.4",
"system-configuration-sys",
]
@ -5734,11 +5731,11 @@ dependencies = [
[[package]]
name = "thiserror"
version = "2.0.15"
version = "2.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850"
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
dependencies = [
"thiserror-impl 2.0.15",
"thiserror-impl 2.0.16",
]
[[package]]
@ -5754,9 +5751,9 @@ dependencies = [
[[package]]
name = "thiserror-impl"
version = "2.0.15"
version = "2.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0"
checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960"
dependencies = [
"proc-macro2",
"quote",
@ -5784,12 +5781,11 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.41"
version = "0.3.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031"
dependencies = [
"deranged",
"itoa",
"libc",
"num-conv",
"num_threads",
@ -5801,15 +5797,15 @@ dependencies = [
[[package]]
name = "time-core"
version = "0.1.4"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
[[package]]
name = "time-macros"
version = "0.2.22"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3"
dependencies = [
"num-conv",
"time-core",
@ -5953,7 +5949,7 @@ version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap 2.10.0",
"indexmap 2.11.0",
"toml_datetime",
"winnow 0.5.40",
]
@ -5964,12 +5960,12 @@ version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
"indexmap 2.10.0",
"indexmap 2.11.0",
"serde",
"serde_spanned",
"toml_datetime",
"toml_write",
"winnow 0.7.12",
"winnow 0.7.13",
]
[[package]]
@ -6232,14 +6228,14 @@ dependencies = [
[[package]]
name = "tracing-subscriber"
version = "0.3.19"
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"regex-automata",
"sharded-slab",
"smallvec",
"thread_local",
@ -6406,13 +6402,14 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "url"
version = "2.5.4"
version = "2.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b"
dependencies = [
"form_urlencoded",
"idna",
"percent-encoding",
"serde",
]
[[package]]
@ -6511,8 +6508,8 @@ dependencies = [
"async-tungstenite 0.23.0",
"cfg-if 1.0.3",
"chrono",
"clap 4.5.45",
"config 0.15.14",
"clap 4.5.47",
"config 0.15.15",
"console",
"crossbeam-channel",
"cursive",
@ -6664,7 +6661,7 @@ name = "veilid-core-examples-private-route"
version = "0.1.0"
dependencies = [
"async-stdin",
"clap 4.5.45",
"clap 4.5.47",
"ctrlc",
"data-encoding",
"tokio",
@ -6753,7 +6750,7 @@ dependencies = [
"backtrace",
"cfg-if 1.0.3",
"chrono",
"clap 4.5.45",
"clap 4.5.47",
"color-eyre",
"config 0.14.1",
"console-subscriber",
@ -6813,7 +6810,7 @@ dependencies = [
"backtrace",
"cfg-if 1.0.3",
"chrono",
"clap 4.5.45",
"clap 4.5.47",
"console_error_panic_hook",
"ctrlc",
"eyre",
@ -6954,11 +6951,11 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasi"
version = "0.14.2+wasi-0.2.4"
version = "0.14.3+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95"
dependencies = [
"wit-bindgen-rt",
"wit-bindgen",
]
[[package]]
@ -7308,7 +7305,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "193cae8e647981c35bc947fdd57ba7928b1fa0d4a79305f6dd2dc55221ac35ac"
dependencies = [
"bitflags 2.9.2",
"bitflags 2.9.4",
"widestring",
"windows-sys 0.59.0",
]
@ -7621,9 +7618,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.7.12"
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95"
checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
dependencies = [
"memchr",
]
@ -7639,13 +7636,10 @@ dependencies = [
]
[[package]]
name = "wit-bindgen-rt"
version = "0.39.0"
name = "wit-bindgen"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
"bitflags 2.9.2",
]
checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814"
[[package]]
name = "writeable"
@ -7661,7 +7655,7 @@ checksum = "ed39ff9f8b2eda91bf6390f9f49eee93d655489e15708e3bb638c1c4f07cecb4"
dependencies = [
"async-tungstenite 0.28.2",
"async_io_stream",
"bitflags 2.9.2",
"bitflags 2.9.4",
"futures-core",
"futures-io",
"futures-sink",
@ -7685,7 +7679,7 @@ dependencies = [
"pharos",
"rustc_version",
"send_wrapper 0.6.0",
"thiserror 2.0.15",
"thiserror 2.0.16",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@ -7693,20 +7687,20 @@ dependencies = [
[[package]]
name = "x11rb"
version = "0.13.1"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12"
checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414"
dependencies = [
"gethostname",
"rustix 0.38.44",
"rustix 1.0.8",
"x11rb-protocol",
]
[[package]]
name = "x11rb-protocol"
version = "0.13.1"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d"
checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd"
[[package]]
name = "x25519-dalek"

View file

@ -24,6 +24,7 @@ cursive = { git = "https://gitlab.com/veilid/cursive.git" }
cursive_core = { git = "https://gitlab.com/veilid/cursive.git" }
# For local development
# keyring-manager = { path = "../keyring-manager" }
# keyvaluedb = { path = "../keyvaluedb/keyvaluedb" }
# keyvaluedb-memorydb = { path = "../keyvaluedb/keyvaluedb-memorydb" }
# keyvaluedb-sqlite = { path = "../keyvaluedb/keyvaluedb-sqlite" }

View file

@ -199,7 +199,7 @@ futures-util = { version = "0.3.31", default-features = false, features = [
] }
# Data structures
keyring-manager = "0.5.1"
keyring-manager = "0.6.0"
keyvaluedb-sqlite = "0.1.3"
# Network

View file

@ -141,6 +141,14 @@ pub trait CryptoSystem {
}
Ok(())
}
fn check_keypair(&self, keypair: &KeyPair) -> VeilidAPIResult<()> {
if keypair.kind() != self.kind() {
apibail_generic!("incorrect keypair kind");
}
self.check_public_key(&keypair.key())?;
self.check_secret_key(&keypair.secret())?;
Ok(())
}
fn validate_keypair(&self, key: &PublicKey, secret: &SecretKey) -> VeilidAPIResult<bool>;
fn validate_hash(&self, data: &[u8], hash: &HashDigest) -> VeilidAPIResult<bool>;

View file

@ -240,6 +240,45 @@ impl Crypto {
self.get_async(best_crypto_kind()).unwrap()
}
// Convenience validators
pub fn check_shared_secret(&self, secret: &SharedSecret) -> VeilidAPIResult<()> {
let Some(vcrypto) = self.get(secret.kind()) else {
apibail_generic!("unsupported crypto kind");
};
vcrypto.check_shared_secret(secret)
}
pub fn check_hash_digest(&self, hash: &HashDigest) -> VeilidAPIResult<()> {
let Some(vcrypto) = self.get(hash.kind()) else {
apibail_generic!("unsupported crypto kind");
};
vcrypto.check_hash_digest(hash)
}
pub fn check_public_key(&self, key: &PublicKey) -> VeilidAPIResult<()> {
let Some(vcrypto) = self.get(key.kind()) else {
apibail_generic!("unsupported crypto kind");
};
vcrypto.check_public_key(key)
}
pub fn check_secret_key(&self, key: &SecretKey) -> VeilidAPIResult<()> {
let Some(vcrypto) = self.get(key.kind()) else {
apibail_generic!("unsupported crypto kind");
};
vcrypto.check_secret_key(key)
}
pub fn check_signature(&self, signature: &Signature) -> VeilidAPIResult<()> {
let Some(vcrypto) = self.get(signature.kind()) else {
apibail_generic!("unsupported crypto kind");
};
vcrypto.check_signature(signature)
}
pub fn check_keypair(&self, key_pair: &KeyPair) -> VeilidAPIResult<()> {
let Some(vcrypto) = self.get(key_pair.kind()) else {
apibail_generic!("unsupported crypto kind");
};
vcrypto.check_keypair(key_pair)
}
/// BareSignature set verification
/// Returns Some() the set of signature cryptokinds that validate and are supported
/// Returns None if any cryptokinds are supported and do not validate

View file

@ -373,6 +373,28 @@ impl RoutingTable {
false
}
// Convenience validators
pub fn check_route_id(&self, route_id: &RouteId) -> VeilidAPIResult<()> {
let crypto = self.crypto();
let Some(vcrypto) = crypto.get(route_id.kind()) else {
apibail_generic!("unsupported crypto kind");
};
if route_id.ref_value().len() != vcrypto.hash_digest_length() {
apibail_generic!("invalid route id length");
}
Ok(())
}
pub fn check_node_id(&self, node_id: &NodeId) -> VeilidAPIResult<()> {
let crypto = self.crypto();
let Some(_) = crypto.get(node_id.kind()) else {
apibail_generic!("unsupported crypto kind");
};
if node_id.ref_value().len() != HASH_COORDINATE_LENGTH {
apibail_generic!("invalid node id length");
}
Ok(())
}
/// Produce node id from public key
pub fn generate_node_id(&self, public_key: &PublicKey) -> VeilidAPIResult<NodeId> {
if public_key.ref_value().len() == HASH_COORDINATE_LENGTH {

View file

@ -559,6 +559,33 @@ impl StorageManager {
)
}
/// Validate a record key
pub(crate) fn check_record_key(&self, record_key: &RecordKey) -> VeilidAPIResult<()> {
let crypto = self.crypto();
let Some(vcrypto) = crypto.get(record_key.kind()) else {
apibail_generic!("unsupported record key kind");
};
if record_key.value().key().len() != HASH_COORDINATE_LENGTH {
apibail_generic!(format!(
"invalid record key length: {} != {}",
record_key.value().key().len(),
HASH_COORDINATE_LENGTH
));
}
if let Some(encryption_key) = record_key.value().encryption_key() {
if encryption_key.len() != vcrypto.shared_secret_length() {
apibail_generic!(format!(
"invalid encryption key length: {} != {}",
encryption_key.len(),
vcrypto.shared_secret_length()
));
}
}
Ok(())
}
/// Create a local record from scratch with a new owner key, open it, and return the opened descriptor
pub async fn create_record(
&self,
@ -660,8 +687,7 @@ impl StorageManager {
// If we got nothing back, the key wasn't found
if result.inspect_result.opt_descriptor().is_none() {
// No result
let opaque_record_key = record_key.opaque();
apibail_key_not_found!(opaque_record_key);
apibail_key_not_found!(record_key.opaque());
};
// Check again to see if we have a local record already or not
@ -1195,10 +1221,10 @@ impl StorageManager {
// Obtain the inner state lock
let mut inner = self.inner.lock().await;
let opaque_record_key = record_key.opaque();
// Get the safety selection and the writer we opened this record
let (safety_selection, opt_watcher) = {
let opaque_record_key = record_key.opaque();
let Some(opened_record) = inner.opened_records.get(&opaque_record_key) else {
// Record must be opened already to change watch
apibail_generic!("record not open");
@ -1218,7 +1244,6 @@ impl StorageManager {
// Get the schema so we can truncate the watch to the number of subkeys
let schema = if let Some(lrs) = inner.local_record_store.as_ref() {
let opaque_record_key = record_key.opaque();
let Some(schema) = lrs.peek_record(&opaque_record_key, |r| r.schema()) else {
apibail_generic!("no local record found");
};
@ -1804,7 +1829,6 @@ impl StorageManager {
}
// Write open record
let opaque_record_key = record_key.opaque();
inner
.opened_records
.entry(opaque_record_key)

View file

@ -227,6 +227,9 @@ impl VeilidAPI {
#[instrument(target = "veilid_api", level = "debug", skip(self), fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub fn generate_member_id(&self, writer_key: &PublicKey) -> VeilidAPIResult<MemberId> {
veilid_log!(self debug "VeilidAPI::generate_member_id(writer_key: {:?}", writer_key);
self.crypto()?.check_public_key(writer_key)?;
let storage_manager = self.core_context()?.storage_manager();
storage_manager.generate_member_id(writer_key)
}
@ -340,7 +343,10 @@ impl VeilidAPI {
pub fn release_private_route(&self, route_id: RouteId) -> VeilidAPIResult<()> {
veilid_log!(self debug
"VeilidAPI::release_private_route(route_id: {:?})", route_id);
let routing_table = self.core_context()?.routing_table();
routing_table.check_route_id(&route_id)?;
let rss = routing_table.route_spec_store();
if !rss.release_route(route_id.clone()) {
apibail_invalid_argument!("release_private_route", "key", route_id);

View file

@ -108,7 +108,7 @@ impl RoutingContext {
veilid_log!(self debug
"RoutingContext::with_safety(self: {:?}, safety_selection: {:?})", self, safety_selection);
if let SafetySelection::Unsafe(_) = safety_selection {
if let SafetySelection::Unsafe(_) = &safety_selection {
#[cfg(not(feature = "footgun"))]
{
return Err(VeilidAPIError::generic(
@ -117,6 +117,15 @@ impl RoutingContext {
}
}
if let SafetySelection::Safe(safe) = &safety_selection {
if let Some(preferred_route) = &safe.preferred_route {
self.api
.core_context()?
.routing_table()
.check_route_id(preferred_route)?;
}
}
Ok(Self {
api: self.api.clone(),
unlocked_inner: Arc::new(RoutingContextUnlockedInner { safety_selection }),
@ -179,6 +188,24 @@ impl RoutingContext {
.map_err(VeilidAPIError::invalid_target)
}
fn check_target(&self, target: &Target) -> VeilidAPIResult<()> {
match target {
Target::NodeId(node_id) => {
self.api
.core_context()?
.routing_table()
.check_node_id(node_id)?;
}
Target::RouteId(route_id) => {
self.api
.core_context()?
.routing_table()
.check_route_id(route_id)?;
}
}
Ok(())
}
#[instrument(target = "veilid_api", level = "debug", skip(message), fields(__VEILID_LOG_KEY = self.log_key(), message_len = message.len()), ret, err)]
async fn internal_app_call(
&self,
@ -189,6 +216,8 @@ impl RoutingContext {
"RoutingContext::app_call(self: {:?}, target: {:?}, message_len: {:?})", self, target, message.len());
veilid_log!(self trace "message: {:?}", message);
self.check_target(&target)?;
let rpc_processor = self.api.core_context()?.rpc_processor();
// Get destination
@ -252,6 +281,8 @@ impl RoutingContext {
"RoutingContext::app_message(self: {:?}, target: {:?}, message_len: {})", self, target, message.len());
veilid_log!(self trace "message: {:?}", message);
self.check_target(&target)?;
let rpc_processor = self.api.core_context()?.rpc_processor();
// Get destination
@ -317,6 +348,11 @@ impl RoutingContext {
"RoutingContext::get_dht_record_key(self: {:?} schema: {:?}, owner_key: {:?}, encryption_key: {:?}", self, schema, owner_key, encryption_key);
schema.validate()?;
self.api.crypto()?.check_public_key(&owner_key)?;
if let Some(encryption_key) = encryption_key.as_ref() {
self.api.crypto()?.check_shared_secret(encryption_key)?;
}
let storage_manager = self.api.core_context()?.storage_manager();
storage_manager.get_record_key(schema, &owner_key, encryption_key)
}
@ -339,9 +375,11 @@ impl RoutingContext {
) -> VeilidAPIResult<DHTRecordDescriptor> {
veilid_log!(self debug
"RoutingContext::create_dht_record(self: {:?}, schema: {:?}, owner: {:?}, kind: {:?})", self, schema, owner, kind);
schema.validate()?;
Crypto::validate_crypto_kind(kind)?;
schema.validate()?;
if let Some(owner) = &owner {
self.api.crypto()?.check_keypair(owner)?;
}
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.create_record(
@ -367,18 +405,24 @@ impl RoutingContext {
#[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub async fn open_dht_record(
&self,
key: RecordKey,
record_key: RecordKey,
default_writer: Option<KeyPair>,
) -> VeilidAPIResult<DHTRecordDescriptor> {
veilid_log!(self debug
"RoutingContext::open_dht_record(self: {:?}, key: {:?}, default_writer: {:?})", self, key, default_writer);
"RoutingContext::open_dht_record(self: {:?}, key: {:?}, default_writer: {:?})", self, record_key, default_writer);
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
if let Some(default_writer) = &default_writer {
self.api.crypto()?.check_keypair(default_writer)?;
}
let storage_manager = self.api.core_context()?.storage_manager();
storage_manager
.open_record(
key,
record_key,
default_writer,
self.unlocked_inner.safety_selection.clone(),
)
@ -389,14 +433,17 @@ impl RoutingContext {
///
/// Closing a record allows you to re-open it with a different routing context.
#[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub async fn close_dht_record(&self, key: RecordKey) -> VeilidAPIResult<()> {
pub async fn close_dht_record(&self, record_key: RecordKey) -> VeilidAPIResult<()> {
veilid_log!(self debug
"RoutingContext::close_dht_record(self: {:?}, key: {:?})", self, key);
"RoutingContext::close_dht_record(self: {:?}, key: {:?})", self, record_key);
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.close_record(key)).await
Box::pin(storage_manager.close_record(record_key)).await
}
/// Deletes a DHT record at a specific key.
@ -405,14 +452,17 @@ impl RoutingContext {
/// Deleting a record does not delete it from the network, but will remove the storage of the record
/// locally, and will prevent its value from being refreshed on the network by this node.
#[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub async fn delete_dht_record(&self, key: RecordKey) -> VeilidAPIResult<()> {
pub async fn delete_dht_record(&self, record_key: RecordKey) -> VeilidAPIResult<()> {
veilid_log!(self debug
"RoutingContext::delete_dht_record(self: {:?}, key: {:?})", self, key);
"RoutingContext::delete_dht_record(self: {:?}, key: {:?})", self, record_key);
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.delete_record(key)).await
Box::pin(storage_manager.delete_record(record_key)).await
}
/// Gets the latest value of a subkey.
@ -424,17 +474,20 @@ impl RoutingContext {
#[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub async fn get_dht_value(
&self,
key: RecordKey,
record_key: RecordKey,
subkey: ValueSubkey,
force_refresh: bool,
) -> VeilidAPIResult<Option<ValueData>> {
veilid_log!(self debug
"RoutingContext::get_dht_value(self: {:?}, key: {:?}, subkey: {:?}, force_refresh: {:?})", self, key, subkey, force_refresh);
"RoutingContext::get_dht_value(self: {:?}, key: {:?}, subkey: {:?}, force_refresh: {:?})", self, record_key, subkey, force_refresh);
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.get_value(key, subkey, force_refresh)).await
Box::pin(storage_manager.get_value(record_key, subkey, force_refresh)).await
}
/// Pushes a changed subkey value to the network.
@ -447,18 +500,21 @@ impl RoutingContext {
#[instrument(target = "veilid_api", level = "debug", skip(data), fields(__VEILID_LOG_KEY = self.log_key(), data = print_data(&data, Some(64))), ret, err)]
pub async fn set_dht_value(
&self,
key: RecordKey,
record_key: RecordKey,
subkey: ValueSubkey,
data: Vec<u8>,
options: Option<SetDHTValueOptions>,
) -> VeilidAPIResult<Option<ValueData>> {
veilid_log!(self debug
"RoutingContext::set_dht_value(self: {:?}, key: {:?}, subkey: {:?}, data: len={}, options: {:?})", self, key, subkey, data.len(), options);
"RoutingContext::set_dht_value(self: {:?}, key: {:?}, subkey: {:?}, data: len={}, options: {:?})", self, record_key, subkey, data.len(), options);
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.set_value(key, subkey, data, options)).await
Box::pin(storage_manager.set_value(record_key, subkey, data, options)).await
}
/// Add or update a watch to a DHT value that informs the user via an VeilidUpdate::ValueChange callback when the record has subkeys change.
@ -489,21 +545,24 @@ impl RoutingContext {
#[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub async fn watch_dht_values(
&self,
key: RecordKey,
record_key: RecordKey,
subkeys: Option<ValueSubkeyRangeSet>,
expiration: Option<Timestamp>,
count: Option<u32>,
) -> VeilidAPIResult<bool> {
veilid_log!(self debug
"RoutingContext::watch_dht_values(self: {:?}, key: {:?}, subkeys: {:?}, expiration: {:?}, count: {:?})", self, key, subkeys, expiration, count);
"RoutingContext::watch_dht_values(self: {:?}, key: {:?}, subkeys: {:?}, expiration: {:?}, count: {:?})", self, record_key, subkeys, expiration, count);
let subkeys = subkeys.unwrap_or_default();
let expiration = expiration.unwrap_or_default();
let count = count.unwrap_or(u32::MAX);
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.watch_values(key, subkeys, expiration, count)).await
Box::pin(storage_manager.watch_values(record_key, subkeys, expiration, count)).await
}
/// Cancels a watch early.
@ -521,17 +580,20 @@ impl RoutingContext {
#[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub async fn cancel_dht_watch(
&self,
key: RecordKey,
record_key: RecordKey,
subkeys: Option<ValueSubkeyRangeSet>,
) -> VeilidAPIResult<bool> {
veilid_log!(self debug
"RoutingContext::cancel_dht_watch(self: {:?}, key: {:?}, subkeys: {:?}", self, key, subkeys);
"RoutingContext::cancel_dht_watch(self: {:?}, key: {:?}, subkeys: {:?}", self, record_key, subkeys);
let subkeys = subkeys.unwrap_or_default();
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.cancel_watch_values(key, subkeys)).await
Box::pin(storage_manager.cancel_watch_values(record_key, subkeys)).await
}
/// Inspects a DHT record for subkey state.
@ -577,18 +639,21 @@ impl RoutingContext {
#[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)]
pub async fn inspect_dht_record(
&self,
key: RecordKey,
record_key: RecordKey,
subkeys: Option<ValueSubkeyRangeSet>,
scope: DHTReportScope,
) -> VeilidAPIResult<DHTRecordReport> {
veilid_log!(self debug
"RoutingContext::inspect_dht_record(self: {:?}, key: {:?}, subkeys: {:?}, scope: {:?})", self, key, subkeys, scope);
"RoutingContext::inspect_dht_record(self: {:?}, key: {:?}, subkeys: {:?}, scope: {:?})", self, record_key, subkeys, scope);
let subkeys = subkeys.unwrap_or_default();
Crypto::validate_crypto_kind(key.kind())?;
self.api
.core_context()?
.storage_manager()
.check_record_key(&record_key)?;
let storage_manager = self.api.core_context()?.storage_manager();
Box::pin(storage_manager.inspect_record(key, subkeys, scope)).await
Box::pin(storage_manager.inspect_record(record_key, subkeys, scope)).await
}
///////////////////////////////////

View file

@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.8.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.25" apply false
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
}
include ":app"

View file

@ -52,13 +52,13 @@ void main() {
group('Routing Contexts', () {
test('routing contexts', testRoutingContexts);
test('app message loopback',
() async => testAppMessageLoopback(fixture.updateStream));
() => testAppMessageLoopback(fixture.updateStream));
test('app call loopback',
() async => testAppCallLoopback(fixture.updateStream));
() => testAppCallLoopback(fixture.updateStream));
test('app message loopback big packets',
() async => testAppMessageLoopbackBigPackets(fixture.updateStream));
() => testAppMessageLoopbackBigPackets(fixture.updateStream));
test('app call loopback big packets',
() async => testAppCallLoopbackBigPackets(fixture.updateStream));
() => testAppCallLoopbackBigPackets(fixture.updateStream));
});
group('Veilid DHT', () {

View file

@ -25,7 +25,7 @@ Future<void> testHashAndVerifyPassword() async {
for (final kind in Veilid.instance.validCryptoKinds()) {
final cs = await Veilid.instance.getCryptoSystem(kind);
final nonce = await cs.randomNonce();
final salt = nonce.decode();
final salt = nonce.toBytes();
// Password match
final phash = await cs.hashPassword(utf8.encode('abc123'), salt);

View file

@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
# platform :ios, '13.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View file

@ -30,12 +30,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/veilid/ios"
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
system_info_plus: 555ce7047fbbf29154726db942ae785c29211740
veilid: 3ce560a4f2b568a77a9fd5e23090f2fa97581019
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011
PODFILE CHECKSUM: 0dbd5a87e0ace00c9610d2037ac22083a01f861d
COCOAPODS: 1.16.2

View file

@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
@ -43,6 +44,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"

View file

@ -3,10 +3,24 @@ import 'package:flutter/services.dart';
/// TextField History Controller
class HistoryTextEditingController {
////////////////////////////////////////////////////////////////////////////
late void Function(void Function()) setState;
final TextEditingController _controller;
late final FocusNode _historyFocusNode;
final List<String> _history = [];
var _historyPosition = 0;
var _historyCurrentEdit = '';
HistoryTextEditingController(
{required this.setState, TextEditingController? controller})
: _controller = controller ?? TextEditingController() {
_historyFocusNode = FocusNode(onKeyEvent: (_node, event) {
_historyFocusNode = FocusNode(onKeyEvent: (node, event) {
if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.arrowUp) {
if (_historyPosition > 0) {
@ -55,15 +69,6 @@ class HistoryTextEditingController {
}
FocusNode get focusNode => _historyFocusNode;
TextEditingController get controller => _controller;
////////////////////////////////////////////////////////////////////////////
late void Function(void Function()) setState;
final TextEditingController _controller;
late final FocusNode _historyFocusNode;
final List<String> _history = [];
int _historyPosition = 0;
String _historyCurrentEdit = '';
}

View file

@ -1,4 +1,3 @@
// ignore_for_file: prefer_single_quotes
import 'dart:io' show Platform;
import 'package:ansicolor/ansicolor.dart';
@ -7,7 +6,7 @@ import 'package:loggy/loggy.dart';
import 'package:veilid/veilid.dart';
// Loggy tools
const LogLevel traceLevel = LogLevel('Trace', 1);
const traceLevel = LogLevel('Trace', 1);
VeilidConfigLogLevel convertToVeilidConfigLogLevel(LogLevel? level) {
if (level == null) {
@ -66,7 +65,7 @@ String wrapWithLogColor(LogLevel? level, String text) {
void setRootLogLevel(LogLevel? level) {
Loggy('').level = getLogOptions(level);
Veilid.instance.changeLogLevel("all", convertToVeilidConfigLogLevel(level));
Veilid.instance.changeLogLevel('all', convertToVeilidConfigLogLevel(level));
}
extension PrettyPrintLogRecord on LogRecord {
@ -78,10 +77,10 @@ extension PrettyPrintLogRecord on LogRecord {
}
class CallbackPrinter extends LoggyPrinter {
CallbackPrinter() : super();
void Function(LogRecord)? callback;
CallbackPrinter() : super();
@override
void onLog(LogRecord record) {
final out = record.pretty().replaceAll('\uFFFD', '');
@ -95,13 +94,14 @@ class CallbackPrinter extends LoggyPrinter {
callback?.call(record);
}
// Keep this as a function
// ignore: use_setters_to_change_properties
void setCallback(void Function(LogRecord)? cb) {
callback = cb;
}
}
CallbackPrinter globalTerminalPrinter = CallbackPrinter();
var globalTerminalPrinter = CallbackPrinter();
extension TraceLoggy on Loggy {
void trace(dynamic message, [Object? error, StackTrace? stackTrace]) =>

View file

@ -25,8 +25,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/veilid/macos
SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
macos_window_utils: 3bca8603c2a1cf2257351dfe6bbccc9accf739fd
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
macos_window_utils: 23f54331a0fd51eea9e0ed347253bf48fd379d1d
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
veilid: 319e2e78836d7b3d08203596d0b4a0e244b68d29

View file

@ -1,6 +1,30 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: da0d9209ca76bde579f2da330aeb9df62b6319c834fa7baae052021b0462401f
url: "https://pub.dev"
source: hosted
version: "85.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: f4ad0fea5f102201015c9aae9d93bc02f75dd9491529a8c21f88d17a8523d44c
url: "https://pub.dev"
source: hosted
version: "7.6.0"
analyzer_plugin:
dependency: transitive
description:
name: analyzer_plugin
sha256: a5ab7590c27b779f3d4de67f31c4109dbe13dd7339f86461a6f2a8ab2594d8ce
url: "https://pub.dev"
source: hosted
version: "0.13.4"
ansicolor:
dependency: "direct main"
description:
@ -9,14 +33,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
args:
dependency: transitive
description:
name: args
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
url: "https://pub.dev"
source: hosted
version: "2.7.0"
async:
dependency: transitive
description:
name: async
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
url: "https://pub.dev"
source: hosted
version: "2.12.0"
version: "2.13.0"
async_tools:
dependency: transitive
description:
@ -57,6 +89,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f"
url: "https://pub.dev"
source: hosted
version: "2.0.4"
ci:
dependency: transitive
description:
name: ci
sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13"
url: "https://pub.dev"
source: hosted
version: "0.1.0"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
url: "https://pub.dev"
source: hosted
version: "0.4.2"
clock:
dependency: transitive
description:
@ -81,6 +137,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.2"
crypto:
dependency: transitive
description:
name: crypto
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
url: "https://pub.dev"
source: hosted
version: "3.0.6"
cupertino_icons:
dependency: "direct main"
description:
@ -89,6 +153,46 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.8"
custom_lint:
dependency: transitive
description:
name: custom_lint
sha256: "78085fbe842de7c5bef92de811ca81536968dbcbbcdac5c316711add2d15e796"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
custom_lint_builder:
dependency: transitive
description:
name: custom_lint_builder
sha256: cc5532d5733d4eccfccaaec6070a1926e9f21e613d93ad0927fad020b95c9e52
url: "https://pub.dev"
source: hosted
version: "0.8.0"
custom_lint_core:
dependency: transitive
description:
name: custom_lint_core
sha256: cc4684d22ca05bf0a4a51127e19a8aea576b42079ed2bc9e956f11aaebe35dd1
url: "https://pub.dev"
source: hosted
version: "0.8.0"
custom_lint_visitor:
dependency: transitive
description:
name: custom_lint_visitor
sha256: "4a86a0d8415a91fbb8298d6ef03e9034dc8e323a599ddc4120a0e36c433983a2"
url: "https://pub.dev"
source: hosted
version: "1.0.0+7.7.0"
dart_style:
dependency: transitive
description:
name: dart_style
sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
equatable:
dependency: transitive
description:
@ -101,10 +205,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.2"
version: "1.3.3"
ffi:
dependency: transitive
description:
@ -161,15 +265,23 @@ packages:
dependency: transitive
description:
name: freezed_annotation
sha256: c87ff004c8aa6af2d531668b46a4ea379f7191dc6dfa066acd53d506da6e044b
sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.1.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
glob:
dependency: transitive
description:
name: glob
sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de
url: "https://pub.dev"
source: hosted
version: "2.1.3"
globbing:
dependency: transitive
description:
@ -178,6 +290,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
hotreloader:
dependency: transitive
description:
name: hotreloader
sha256: bc167a1163807b03bada490bfe2df25b0d744df359227880220a5cbd04e5734b
url: "https://pub.dev"
source: hosted
version: "4.3.0"
integration_test:
dependency: "direct dev"
description: flutter
@ -195,34 +315,42 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0"
url: "https://pub.dev"
source: hosted
version: "10.0.8"
version: "11.0.1"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.9"
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
lint_hard:
dependency: "direct dev"
description:
name: lint_hard
sha256: ffe7058cb49e021d244d67e650a63380445b56643c2849c6929e938246b99058
sha256: "805771ca5131c1e798ec7e94eb557dc61d6dc1220246855196776f4ac7299446"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
version: "6.2.1"
logging:
dependency: transitive
description:
name: logging
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
url: "https://pub.dev"
source: hosted
version: "1.3.0"
loggy:
dependency: "direct main"
description:
@ -235,10 +363,10 @@ packages:
dependency: transitive
description:
name: macos_window_utils
sha256: "3534f2af024f2f24112ca28789a44e6750083f8c0065414546c6593ee48a5009"
sha256: d4df3501fd32ac0d2d7590cb6a8e4758337d061c8fa0db816fdd636be63a8438
url: "https://pub.dev"
source: hosted
version: "1.6.1"
version: "1.9.0"
matcher:
dependency: transitive
description:
@ -263,6 +391,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.16.0"
package_config:
dependency: transitive
description:
name: package_config
sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc
url: "https://pub.dev"
source: hosted
version: "2.2.0"
path:
dependency: "direct main"
description:
@ -283,18 +419,18 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: "0ca7359dad67fd7063cb2892ab0c0737b2daafd807cf1acecd62374c8fae6c12"
sha256: "993381400e94d18469750e5b9dcb8206f15bc09f9da86b9e44a9b0092a0066db"
url: "https://pub.dev"
source: hosted
version: "2.2.16"
version: "2.2.18"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
sha256: "16eef174aacb07e09c351502740fa6254c165757638eba1e9116b0a781201bbd"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
version: "2.4.2"
path_provider_linux:
dependency: transitive
description:
@ -339,10 +475,26 @@ packages:
dependency: transitive
description:
name: process
sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d"
sha256: c6248e4526673988586e8c00bb22a49210c258dc91df5227d5da9748ecf79744
url: "https://pub.dev"
source: hosted
version: "5.0.3"
version: "5.0.5"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082"
url: "https://pub.dev"
source: hosted
version: "1.5.0"
quiver:
dependency: transitive
description:
@ -351,6 +503,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.2.2"
rxdart:
dependency: transitive
description:
name: rxdart
sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962"
url: "https://pub.dev"
source: hosted
version: "0.28.0"
sky_engine:
dependency: transitive
description: flutter
@ -364,6 +524,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.1"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
dependency: transitive
description:
@ -380,6 +548,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
stream_transform:
dependency: transitive
description:
name: stream_transform
sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871
url: "https://pub.dev"
source: hosted
version: "2.1.1"
string_scanner:
dependency: transitive
description:
@ -424,10 +600,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev"
source: hosted
version: "0.7.4"
version: "0.7.6"
typed_data:
dependency: transitive
description:
@ -436,14 +612,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
uuid:
dependency: transitive
description:
name: uuid
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
url: "https://pub.dev"
source: hosted
version: "4.5.1"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
veilid:
dependency: "direct main"
description:
@ -462,18 +646,26 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
url: "https://pub.dev"
source: hosted
version: "14.3.1"
version: "15.0.2"
watcher:
dependency: transitive
description:
name: watcher
sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c"
url: "https://pub.dev"
source: hosted
version: "1.1.3"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade"
url: "https://pub.dev"
source: hosted
version: "3.0.4"
version: "3.1.0"
xdg_directories:
dependency: transitive
description:
@ -490,6 +682,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
yaml:
dependency: transitive
description:
name: yaml
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
url: "https://pub.dev"
source: hosted
version: "3.1.3"
zmodem:
dependency: transitive
description:
@ -499,5 +699,5 @@ packages:
source: hosted
version: "0.0.6"
sdks:
dart: ">=3.7.0 <4.0.0"
flutter: ">=3.27.0"
dart: ">=3.8.0 <4.0.0"
flutter: ">=3.29.0"

View file

@ -44,7 +44,7 @@ dev_dependencies:
sdk: flutter
integration_test:
sdk: flutter
lint_hard: ^6.0.0
lint_hard: ^6.2.1
veilid_test:
path: ../packages/veilid_test

View file

@ -70,9 +70,10 @@ sealed class DHTSchema with _$DHTSchema {
const factory DHTSchema.dflt({required int oCnt}) = DHTSchemaDFLT;
@FreezedUnionValue('SMPL')
const factory DHTSchema.smpl(
{required int oCnt,
required List<DHTSchemaMember> members}) = DHTSchemaSMPL;
const factory DHTSchema.smpl({
required int oCnt,
required List<DHTSchemaMember> members,
}) = DHTSchemaSMPL;
factory DHTSchema.fromJson(dynamic json) =>
_$DHTSchemaFromJson(json as Map<String, dynamic>);
@ -84,12 +85,21 @@ const defaultDHTSchema = DHTSchema.dflt(oCnt: 1);
sealed class DHTSchemaMember with _$DHTSchemaMember {
@Assert('mCnt > 0 && mCnt <= 65535', 'value out of range')
const factory DHTSchemaMember({
required MemberId mKey,
required BareMemberId mKey,
required int mCnt,
}) = _DHTSchemaMember;
factory DHTSchemaMember.fromJson(dynamic json) =>
_$DHTSchemaMemberFromJson(json as Map<String, dynamic>);
static Future<DHTSchemaMember> fromPublicKey(
Veilid veilid,
PublicKey publicKey,
int mCnt,
) async => DHTSchemaMember(
mKey: (await veilid.generateMemberId(publicKey)).value,
mCnt: mCnt,
);
}
//////////////////////////////////////
@ -135,7 +145,10 @@ extension DHTRecordDescriptorExt on DHTRecordDescriptor {
@freezed
sealed class ValueData with _$ValueData {
@Assert('seq >= 0', 'seq out of range')
static const maxLen = 32768;
@Assert('seq >= 0 && seq <= 4294967295', 'seq out of range')
@Assert('data.length <= ValueData.maxLen', 'data too large')
const factory ValueData({
required int seq,
@Uint8ListJsonConverter.jsIsArray() required Uint8List data,
@ -180,7 +193,8 @@ abstract class SafetySelection {
final json = jsond as Map<String, dynamic>;
if (json.containsKey('Unsafe')) {
return SafetySelectionUnsafe(
sequencing: Sequencing.fromJson(json['Unsafe']));
sequencing: Sequencing.fromJson(json['Unsafe']),
);
} else if (json.containsKey('Safe')) {
return SafetySelectionSafe(safetySpec: SafetySpec.fromJson(json['Safe']));
} else {
@ -192,13 +206,14 @@ abstract class SafetySelection {
@immutable
class SafetySelectionUnsafe extends Equatable implements SafetySelection {
//
const SafetySelectionUnsafe({
required this.sequencing,
});
final Sequencing sequencing;
//
const SafetySelectionUnsafe({required this.sequencing});
@override
List<Object> get props => [sequencing];
@override
bool? get stringify => null;
@ -208,13 +223,14 @@ class SafetySelectionUnsafe extends Equatable implements SafetySelection {
@immutable
class SafetySelectionSafe extends Equatable implements SafetySelection {
//
const SafetySelectionSafe({
required this.safetySpec,
});
final SafetySpec safetySpec;
//
const SafetySelectionSafe({required this.safetySpec});
@override
List<Object> get props => [safetySpec];
@override
bool? get stringify => null;
@ -256,13 +272,14 @@ abstract class Target {
@immutable
class TargetNodeId extends Equatable implements Target {
//
const TargetNodeId({
required this.nodeId,
});
final NodeId nodeId;
//
const TargetNodeId({required this.nodeId});
@override
List<Object> get props => [nodeId];
@override
bool? get stringify => null;
@ -272,13 +289,14 @@ class TargetNodeId extends Equatable implements Target {
@immutable
class TargetRouteId extends Equatable implements Target {
//
const TargetRouteId({
required this.routeId,
});
final RouteId routeId;
//
const TargetRouteId({required this.routeId});
@override
List<Object> get props => [routeId];
@override
bool? get stringify => null;
@ -290,10 +308,10 @@ class TargetRouteId extends Equatable implements Target {
/// RouteBlob
@freezed
sealed class RouteBlob with _$RouteBlob {
const factory RouteBlob(
{required RouteId routeId,
@Uint8ListJsonConverter.jsIsArray() required Uint8List blob}) =
_RouteBlob;
const factory RouteBlob({
required RouteId routeId,
@Uint8ListJsonConverter.jsIsArray() required Uint8List blob,
}) = _RouteBlob;
factory RouteBlob.fromJson(dynamic json) =>
_$RouteBlobFromJson(json as Map<String, dynamic>);
}
@ -328,19 +346,17 @@ enum DHTReportScope {
@freezed
sealed class SetDHTValueOptions with _$SetDHTValueOptions {
const factory SetDHTValueOptions({
KeyPair? writer,
bool? allowOffline,
}) = _SetDHTValueOptions;
const factory SetDHTValueOptions({KeyPair? writer, bool? allowOffline}) =
_SetDHTValueOptions;
factory SetDHTValueOptions.fromJson(dynamic json) =>
_$SetDHTValueOptionsFromJson(json as Map<String, dynamic>);
@override
Map<String, dynamic> toJson() => {
'writer': writer,
'allow_offline': allowOffline,
};
'writer': writer,
'allow_offline': allowOffline,
};
}
//////////////////////////////////////
@ -351,10 +367,14 @@ abstract class VeilidRoutingContext {
// Modifiers
VeilidRoutingContext withDefaultSafety({bool closeSelf = false});
VeilidRoutingContext withSafety(SafetySelection safetySelection,
{bool closeSelf = false});
VeilidRoutingContext withSequencing(Sequencing sequencing,
{bool closeSelf = false});
VeilidRoutingContext withSafety(
SafetySelection safetySelection, {
bool closeSelf = false,
});
VeilidRoutingContext withSequencing(
Sequencing sequencing, {
bool closeSelf = false,
});
Future<SafetySelection> safety();
// App call/message
@ -362,21 +382,40 @@ abstract class VeilidRoutingContext {
Future<void> appMessage(Target target, Uint8List message);
// DHT Operations
Future<DHTRecordDescriptor> createDHTRecord(CryptoKind kind, DHTSchema schema,
{KeyPair? owner});
Future<DHTRecordDescriptor> createDHTRecord(
CryptoKind kind,
DHTSchema schema, {
KeyPair? owner,
});
Future<DHTRecordDescriptor> openDHTRecord(RecordKey key, {KeyPair? writer});
Future<void> closeDHTRecord(RecordKey key);
Future<void> deleteDHTRecord(RecordKey key);
Future<RecordKey> getDHTRecordKey(
DHTSchema schema, PublicKey owner, SharedSecret? encryptionKey);
Future<ValueData?> getDHTValue(RecordKey key, int subkey,
{bool forceRefresh = false});
Future<ValueData?> setDHTValue(RecordKey key, int subkey, Uint8List data,
{SetDHTValueOptions? options});
Future<bool> watchDHTValues(RecordKey key,
{List<ValueSubkeyRange>? subkeys, Timestamp? expiration, int? count});
DHTSchema schema,
PublicKey owner,
SharedSecret? encryptionKey,
);
Future<ValueData?> getDHTValue(
RecordKey key,
int subkey, {
bool forceRefresh = false,
});
Future<ValueData?> setDHTValue(
RecordKey key,
int subkey,
Uint8List data, {
SetDHTValueOptions? options,
});
Future<bool> watchDHTValues(
RecordKey key, {
List<ValueSubkeyRange>? subkeys,
Timestamp? expiration,
int? count,
});
Future<bool> cancelDHTWatch(RecordKey key, {List<ValueSubkeyRange>? subkeys});
Future<DHTRecordReport> inspectDHTRecord(RecordKey key,
{List<ValueSubkeyRange>? subkeys,
DHTReportScope scope = DHTReportScope.local});
Future<DHTRecordReport> inspectDHTRecord(
RecordKey key, {
List<ValueSubkeyRange>? subkeys,
DHTReportScope scope = DHTReportScope.local,
});
}

File diff suppressed because it is too large Load diff

View file

@ -13,10 +13,7 @@ DHTSchemaDFLT _$DHTSchemaDFLTFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$DHTSchemaDFLTToJson(DHTSchemaDFLT instance) =>
<String, dynamic>{
'o_cnt': instance.oCnt,
'kind': instance.$type,
};
<String, dynamic>{'o_cnt': instance.oCnt, 'kind': instance.$type};
DHTSchemaSMPL _$DHTSchemaSMPLFromJson(Map<String, dynamic> json) =>
DHTSchemaSMPL(
@ -36,15 +33,12 @@ Map<String, dynamic> _$DHTSchemaSMPLToJson(DHTSchemaSMPL instance) =>
_DHTSchemaMember _$DHTSchemaMemberFromJson(Map<String, dynamic> json) =>
_DHTSchemaMember(
mKey: Typed<BareMemberId>.fromJson(json['m_key']),
mKey: BareMemberId.fromJson(json['m_key']),
mCnt: (json['m_cnt'] as num).toInt(),
);
Map<String, dynamic> _$DHTSchemaMemberToJson(_DHTSchemaMember instance) =>
<String, dynamic>{
'm_key': instance.mKey.toJson(),
'm_cnt': instance.mCnt,
};
<String, dynamic>{'m_key': instance.mKey.toJson(), 'm_cnt': instance.mCnt};
_DHTRecordDescriptor _$DHTRecordDescriptorFromJson(Map<String, dynamic> json) =>
_DHTRecordDescriptor(
@ -57,19 +51,19 @@ _DHTRecordDescriptor _$DHTRecordDescriptorFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$DHTRecordDescriptorToJson(
_DHTRecordDescriptor instance) =>
<String, dynamic>{
'key': instance.key.toJson(),
'owner': instance.owner.toJson(),
'schema': instance.schema.toJson(),
'owner_secret': instance.ownerSecret?.toJson(),
};
_DHTRecordDescriptor instance,
) => <String, dynamic>{
'key': instance.key.toJson(),
'owner': instance.owner.toJson(),
'schema': instance.schema.toJson(),
'owner_secret': instance.ownerSecret?.toJson(),
};
_ValueData _$ValueDataFromJson(Map<String, dynamic> json) => _ValueData(
seq: (json['seq'] as num).toInt(),
data: const Uint8ListJsonConverter.jsIsArray().fromJson(json['data']),
writer: Typed<BarePublicKey>.fromJson(json['writer']),
);
seq: (json['seq'] as num).toInt(),
data: const Uint8ListJsonConverter.jsIsArray().fromJson(json['data']),
writer: Typed<BarePublicKey>.fromJson(json['writer']),
);
Map<String, dynamic> _$ValueDataToJson(_ValueData instance) =>
<String, dynamic>{
@ -79,13 +73,13 @@ Map<String, dynamic> _$ValueDataToJson(_ValueData instance) =>
};
_SafetySpec _$SafetySpecFromJson(Map<String, dynamic> json) => _SafetySpec(
hopCount: (json['hop_count'] as num).toInt(),
stability: Stability.fromJson(json['stability']),
sequencing: Sequencing.fromJson(json['sequencing']),
preferredRoute: json['preferred_route'] == null
? null
: Typed<BareRouteId>.fromJson(json['preferred_route']),
);
hopCount: (json['hop_count'] as num).toInt(),
stability: Stability.fromJson(json['stability']),
sequencing: Sequencing.fromJson(json['sequencing']),
preferredRoute: json['preferred_route'] == null
? null
: Typed<BareRouteId>.fromJson(json['preferred_route']),
);
Map<String, dynamic> _$SafetySpecToJson(_SafetySpec instance) =>
<String, dynamic>{
@ -96,9 +90,9 @@ Map<String, dynamic> _$SafetySpecToJson(_SafetySpec instance) =>
};
_RouteBlob _$RouteBlobFromJson(Map<String, dynamic> json) => _RouteBlob(
routeId: Typed<BareRouteId>.fromJson(json['route_id']),
blob: const Uint8ListJsonConverter.jsIsArray().fromJson(json['blob']),
);
routeId: Typed<BareRouteId>.fromJson(json['route_id']),
blob: const Uint8ListJsonConverter.jsIsArray().fromJson(json['blob']),
);
Map<String, dynamic> _$RouteBlobToJson(_RouteBlob instance) =>
<String, dynamic>{
@ -122,14 +116,14 @@ _DHTRecordReport _$DHTRecordReportFromJson(Map<String, dynamic> json) =>
.toList(),
);
Map<String, dynamic> _$DHTRecordReportToJson(_DHTRecordReport instance) =>
<String, dynamic>{
'subkeys': instance.subkeys.map((e) => e.toJson()).toList(),
'offline_subkeys':
instance.offlineSubkeys.map((e) => e.toJson()).toList(),
'local_seqs': instance.localSeqs,
'network_seqs': instance.networkSeqs,
};
Map<String, dynamic> _$DHTRecordReportToJson(
_DHTRecordReport instance,
) => <String, dynamic>{
'subkeys': instance.subkeys.map((e) => e.toJson()).toList(),
'offline_subkeys': instance.offlineSubkeys.map((e) => e.toJson()).toList(),
'local_seqs': instance.localSeqs,
'network_seqs': instance.networkSeqs,
};
_SetDHTValueOptions _$SetDHTValueOptionsFromJson(Map<String, dynamic> json) =>
_SetDHTValueOptions(

View file

@ -5,6 +5,10 @@ import 'package:freezed_annotation/freezed_annotation.dart';
@immutable
class ValueSubkeyRange extends Equatable {
final int low;
final int high;
const ValueSubkeyRange({
required this.low,
required this.high,
@ -12,14 +16,18 @@ class ValueSubkeyRange extends Equatable {
factory ValueSubkeyRange.single(int val) =>
ValueSubkeyRange(low: val, high: val);
factory ValueSubkeyRange.make(int low, int high) =>
ValueSubkeyRange(low: low, high: high);
factory ValueSubkeyRange.fromIntPair((int, int) pair) =>
ValueSubkeyRange(low: pair.$1, high: pair.$2);
factory ValueSubkeyRange.fromIntList(List<int> intlist) {
assert(intlist.length == 2, 'range must be a two item list');
return ValueSubkeyRange(low: intlist[0], high: intlist[1]);
}
factory ValueSubkeyRange.fromJson(dynamic json) =>
ValueSubkeyRange.fromIntList((json as List<dynamic>).cast<int>());
@ -27,9 +35,6 @@ class ValueSubkeyRange extends Equatable {
@override
List<Object> get props => [low, high];
final int low;
final int high;
}
extension ValueSubkeyRangeExt on ValueSubkeyRange {

View file

@ -43,10 +43,14 @@ List<T>? Function(dynamic) optJsonListConstructor<T>(
@immutable
class VeilidVersion extends Equatable {
const VeilidVersion(this.major, this.minor, this.patch);
final int major;
final int minor;
final int patch;
const VeilidVersion(this.major, this.minor, this.patch);
@override
List<Object> get props => [major, minor, patch];
}
@ -55,15 +59,21 @@ class VeilidVersion extends Equatable {
/// Timestamp
@immutable
class Timestamp extends Equatable implements Comparable<Timestamp> {
final BigInt value;
const Timestamp({required this.value});
factory Timestamp.zero() => Timestamp(value: BigInt.zero);
factory Timestamp.fromInt64(Int64 i64) => Timestamp(
value: (BigInt.from((i64 >> 32).toUnsigned(32).toInt()) << 32) |
BigInt.from(i64.toUnsigned(32).toInt()));
factory Timestamp.fromString(String s) => Timestamp(value: BigInt.parse(s));
factory Timestamp.fromJson(dynamic json) =>
Timestamp.fromString(json as String);
final BigInt value;
@override
List<Object> get props => [value];
@ -71,13 +81,18 @@ class Timestamp extends Equatable implements Comparable<Timestamp> {
int compareTo(Timestamp other) => value.compareTo(other.value);
bool operator <(Timestamp other) => compareTo(other) < 0;
bool operator <=(Timestamp other) => compareTo(other) <= 0;
bool operator >(Timestamp other) => compareTo(other) > 0;
bool operator >=(Timestamp other) => compareTo(other) >= 0;
@override
String toString() => value.toString();
String toJson() => toString();
Int64 toInt64() => Int64.fromInts(
(value >> 32).toUnsigned(32).toInt(), value.toUnsigned(32).toInt());
@ -91,20 +106,27 @@ class Timestamp extends Equatable implements Comparable<Timestamp> {
@immutable
class TimestampDuration extends Equatable
implements Comparable<TimestampDuration> {
final BigInt value;
const TimestampDuration({required this.value});
factory TimestampDuration.fromInt64(Int64 i64) => TimestampDuration(
value: (BigInt.from((i64 >> 32).toUnsigned(32).toInt()) << 32) |
BigInt.from(i64.toUnsigned(32).toInt()));
factory TimestampDuration.fromMillis(int millis) =>
TimestampDuration(value: BigInt.from(millis) * BigInt.from(1000));
factory TimestampDuration.fromDuration(Duration d) => TimestampDuration(
value: BigInt.from(d.inSeconds) * BigInt.from(1000000) +
BigInt.from(d.inMicroseconds % 1000000));
factory TimestampDuration.fromString(String s) =>
TimestampDuration(value: BigInt.parse(s));
factory TimestampDuration.fromJson(dynamic json) =>
TimestampDuration.fromString(json as String);
final BigInt value;
@override
List<Object> get props => [value];
@ -112,8 +134,11 @@ class TimestampDuration extends Equatable
int compareTo(TimestampDuration other) => value.compareTo(other.value);
bool operator <(TimestampDuration other) => compareTo(other) < 0;
bool operator <=(TimestampDuration other) => compareTo(other) <= 0;
bool operator >(TimestampDuration other) => compareTo(other) > 0;
bool operator >=(TimestampDuration other) => compareTo(other) >= 0;
@override
@ -153,11 +178,14 @@ class TimestampDuration extends Equatable
}
String toJson() => value.toString();
Int64 toInt64() => Int64.fromInts(
(value >> 32).toUnsigned(32).toInt(), value.toUnsigned(32).toInt());
double toMillis() => value / BigInt.from(1000);
double toSecs() => value / BigInt.from(1000000);
BigInt toMicros() => value;
}

View file

@ -108,9 +108,11 @@ class VeilidAPIExceptionTimeout implements VeilidAPIException {
@immutable
class VeilidAPIExceptionTryAgain implements VeilidAPIException {
final String message;
//
const VeilidAPIExceptionTryAgain(this.message);
final String message;
@override
String toString() => 'VeilidAPIException: TryAgain (message: $message)';
@ -129,9 +131,10 @@ class VeilidAPIExceptionShutdown implements VeilidAPIException {
@immutable
class VeilidAPIExceptionInvalidTarget implements VeilidAPIException {
final String message;
//
const VeilidAPIExceptionInvalidTarget(this.message);
final String message;
@override
String toString() => 'VeilidAPIException: InvalidTarget (message: $message)';
@ -142,9 +145,11 @@ class VeilidAPIExceptionInvalidTarget implements VeilidAPIException {
@immutable
class VeilidAPIExceptionNoConnection implements VeilidAPIException {
final String message;
//
const VeilidAPIExceptionNoConnection(this.message);
final String message;
@override
String toString() => 'VeilidAPIException: NoConnection (message: $message)';
@ -154,9 +159,11 @@ class VeilidAPIExceptionNoConnection implements VeilidAPIException {
@immutable
class VeilidAPIExceptionKeyNotFound implements VeilidAPIException {
final String key;
//
const VeilidAPIExceptionKeyNotFound(this.key);
final String key;
@override
String toString() => 'VeilidAPIException: KeyNotFound (key: $key)';
@ -166,9 +173,10 @@ class VeilidAPIExceptionKeyNotFound implements VeilidAPIException {
@immutable
class VeilidAPIExceptionInternal implements VeilidAPIException {
final String message;
//
const VeilidAPIExceptionInternal(this.message);
final String message;
@override
String toString() => 'VeilidAPIException: Internal ($message)';
@ -179,9 +187,10 @@ class VeilidAPIExceptionInternal implements VeilidAPIException {
@immutable
class VeilidAPIExceptionUnimplemented implements VeilidAPIException {
final String message;
//
const VeilidAPIExceptionUnimplemented(this.message);
final String message;
@override
String toString() => 'VeilidAPIException: Unimplemented ($message)';
@ -192,10 +201,12 @@ class VeilidAPIExceptionUnimplemented implements VeilidAPIException {
@immutable
class VeilidAPIExceptionParseError implements VeilidAPIException {
final String message;
final String value;
//
const VeilidAPIExceptionParseError(this.message, this.value);
final String message;
final String value;
@override
String toString() =>
@ -207,12 +218,15 @@ class VeilidAPIExceptionParseError implements VeilidAPIException {
@immutable
class VeilidAPIExceptionInvalidArgument implements VeilidAPIException {
final String context;
final String argument;
final String value;
//
const VeilidAPIExceptionInvalidArgument(
this.context, this.argument, this.value);
final String context;
final String argument;
final String value;
@override
String toString() => 'VeilidAPIException: InvalidArgument'
@ -224,10 +238,12 @@ class VeilidAPIExceptionInvalidArgument implements VeilidAPIException {
@immutable
class VeilidAPIExceptionMissingArgument implements VeilidAPIException {
final String context;
final String argument;
//
const VeilidAPIExceptionMissingArgument(this.context, this.argument);
final String context;
final String argument;
@override
String toString() =>
@ -239,9 +255,10 @@ class VeilidAPIExceptionMissingArgument implements VeilidAPIException {
@immutable
class VeilidAPIExceptionGeneric implements VeilidAPIException {
final String message;
//
const VeilidAPIExceptionGeneric(this.message);
final String message;
@override
String toString() => 'VeilidAPIException: Generic (message: $message)';

File diff suppressed because it is too large Load diff

View file

@ -7,164 +7,161 @@ part of 'veilid_config.dart';
// **************************************************************************
_VeilidFFIConfigLoggingTerminal _$VeilidFFIConfigLoggingTerminalFromJson(
Map<String, dynamic> json) =>
_VeilidFFIConfigLoggingTerminal(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
ignoreLogTargets: (json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> json,
) => _VeilidFFIConfigLoggingTerminal(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
ignoreLogTargets:
(json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> _$VeilidFFIConfigLoggingTerminalToJson(
_VeilidFFIConfigLoggingTerminal instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidFFIConfigLoggingTerminal instance,
) => <String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidFFIConfigLoggingOtlp _$VeilidFFIConfigLoggingOtlpFromJson(
Map<String, dynamic> json) =>
_VeilidFFIConfigLoggingOtlp(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
grpcEndpoint: json['grpc_endpoint'] as String,
serviceName: json['service_name'] as String,
ignoreLogTargets: (json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> json,
) => _VeilidFFIConfigLoggingOtlp(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
grpcEndpoint: json['grpc_endpoint'] as String,
serviceName: json['service_name'] as String,
ignoreLogTargets:
(json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> _$VeilidFFIConfigLoggingOtlpToJson(
_VeilidFFIConfigLoggingOtlp instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'grpc_endpoint': instance.grpcEndpoint,
'service_name': instance.serviceName,
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidFFIConfigLoggingOtlp instance,
) => <String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'grpc_endpoint': instance.grpcEndpoint,
'service_name': instance.serviceName,
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidFFIConfigLoggingApi _$VeilidFFIConfigLoggingApiFromJson(
Map<String, dynamic> json) =>
_VeilidFFIConfigLoggingApi(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
ignoreLogTargets: (json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> json,
) => _VeilidFFIConfigLoggingApi(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
ignoreLogTargets:
(json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> _$VeilidFFIConfigLoggingApiToJson(
_VeilidFFIConfigLoggingApi instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidFFIConfigLoggingApi instance,
) => <String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidFFIConfigLoggingFlame _$VeilidFFIConfigLoggingFlameFromJson(
Map<String, dynamic> json) =>
_VeilidFFIConfigLoggingFlame(
enabled: json['enabled'] as bool,
path: json['path'] as String,
);
Map<String, dynamic> json,
) => _VeilidFFIConfigLoggingFlame(
enabled: json['enabled'] as bool,
path: json['path'] as String,
);
Map<String, dynamic> _$VeilidFFIConfigLoggingFlameToJson(
_VeilidFFIConfigLoggingFlame instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'path': instance.path,
};
_VeilidFFIConfigLoggingFlame instance,
) => <String, dynamic>{'enabled': instance.enabled, 'path': instance.path};
_VeilidFFIConfigLogging _$VeilidFFIConfigLoggingFromJson(
Map<String, dynamic> json) =>
_VeilidFFIConfigLogging(
terminal: VeilidFFIConfigLoggingTerminal.fromJson(json['terminal']),
otlp: VeilidFFIConfigLoggingOtlp.fromJson(json['otlp']),
api: VeilidFFIConfigLoggingApi.fromJson(json['api']),
flame: VeilidFFIConfigLoggingFlame.fromJson(json['flame']),
);
Map<String, dynamic> json,
) => _VeilidFFIConfigLogging(
terminal: VeilidFFIConfigLoggingTerminal.fromJson(json['terminal']),
otlp: VeilidFFIConfigLoggingOtlp.fromJson(json['otlp']),
api: VeilidFFIConfigLoggingApi.fromJson(json['api']),
flame: VeilidFFIConfigLoggingFlame.fromJson(json['flame']),
);
Map<String, dynamic> _$VeilidFFIConfigLoggingToJson(
_VeilidFFIConfigLogging instance) =>
<String, dynamic>{
'terminal': instance.terminal.toJson(),
'otlp': instance.otlp.toJson(),
'api': instance.api.toJson(),
'flame': instance.flame.toJson(),
};
_VeilidFFIConfigLogging instance,
) => <String, dynamic>{
'terminal': instance.terminal.toJson(),
'otlp': instance.otlp.toJson(),
'api': instance.api.toJson(),
'flame': instance.flame.toJson(),
};
_VeilidFFIConfig _$VeilidFFIConfigFromJson(Map<String, dynamic> json) =>
_VeilidFFIConfig(
logging: VeilidFFIConfigLogging.fromJson(json['logging']),
);
_VeilidFFIConfig(logging: VeilidFFIConfigLogging.fromJson(json['logging']));
Map<String, dynamic> _$VeilidFFIConfigToJson(_VeilidFFIConfig instance) =>
<String, dynamic>{
'logging': instance.logging.toJson(),
};
<String, dynamic>{'logging': instance.logging.toJson()};
_VeilidWASMConfigLoggingPerformance
_$VeilidWASMConfigLoggingPerformanceFromJson(Map<String, dynamic> json) =>
_VeilidWASMConfigLoggingPerformance(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
logsInTimings: json['logs_in_timings'] as bool,
logsInConsole: json['logs_in_console'] as bool,
ignoreLogTargets: (json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> _$VeilidWASMConfigLoggingPerformanceToJson(
_VeilidWASMConfigLoggingPerformance instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'logs_in_timings': instance.logsInTimings,
'logs_in_console': instance.logsInConsole,
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidWASMConfigLoggingApi _$VeilidWASMConfigLoggingApiFromJson(
Map<String, dynamic> json) =>
_VeilidWASMConfigLoggingApi(
_$VeilidWASMConfigLoggingPerformanceFromJson(Map<String, dynamic> json) =>
_VeilidWASMConfigLoggingPerformance(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
ignoreLogTargets: (json['ignore_log_targets'] as List<dynamic>?)
logsInTimings: json['logs_in_timings'] as bool,
logsInConsole: json['logs_in_console'] as bool,
ignoreLogTargets:
(json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> _$VeilidWASMConfigLoggingPerformanceToJson(
_VeilidWASMConfigLoggingPerformance instance,
) => <String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'logs_in_timings': instance.logsInTimings,
'logs_in_console': instance.logsInConsole,
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidWASMConfigLoggingApi _$VeilidWASMConfigLoggingApiFromJson(
Map<String, dynamic> json,
) => _VeilidWASMConfigLoggingApi(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
ignoreLogTargets:
(json['ignore_log_targets'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> _$VeilidWASMConfigLoggingApiToJson(
_VeilidWASMConfigLoggingApi instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidWASMConfigLoggingApi instance,
) => <String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'ignore_log_targets': instance.ignoreLogTargets,
};
_VeilidWASMConfigLogging _$VeilidWASMConfigLoggingFromJson(
Map<String, dynamic> json) =>
_VeilidWASMConfigLogging(
performance:
VeilidWASMConfigLoggingPerformance.fromJson(json['performance']),
api: VeilidWASMConfigLoggingApi.fromJson(json['api']),
);
Map<String, dynamic> json,
) => _VeilidWASMConfigLogging(
performance: VeilidWASMConfigLoggingPerformance.fromJson(json['performance']),
api: VeilidWASMConfigLoggingApi.fromJson(json['api']),
);
Map<String, dynamic> _$VeilidWASMConfigLoggingToJson(
_VeilidWASMConfigLogging instance) =>
<String, dynamic>{
'performance': instance.performance.toJson(),
'api': instance.api.toJson(),
};
_VeilidWASMConfigLogging instance,
) => <String, dynamic>{
'performance': instance.performance.toJson(),
'api': instance.api.toJson(),
};
_VeilidWASMConfig _$VeilidWASMConfigFromJson(Map<String, dynamic> json) =>
_VeilidWASMConfig(
@ -172,9 +169,7 @@ _VeilidWASMConfig _$VeilidWASMConfigFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$VeilidWASMConfigToJson(_VeilidWASMConfig instance) =>
<String, dynamic>{
'logging': instance.logging.toJson(),
};
<String, dynamic>{'logging': instance.logging.toJson()};
_VeilidConfigHTTPS _$VeilidConfigHTTPSFromJson(Map<String, dynamic> json) =>
_VeilidConfigHTTPS(
@ -209,18 +204,18 @@ Map<String, dynamic> _$VeilidConfigHTTPToJson(_VeilidConfigHTTP instance) =>
};
_VeilidConfigApplication _$VeilidConfigApplicationFromJson(
Map<String, dynamic> json) =>
_VeilidConfigApplication(
https: VeilidConfigHTTPS.fromJson(json['https']),
http: VeilidConfigHTTP.fromJson(json['http']),
);
Map<String, dynamic> json,
) => _VeilidConfigApplication(
https: VeilidConfigHTTPS.fromJson(json['https']),
http: VeilidConfigHTTP.fromJson(json['http']),
);
Map<String, dynamic> _$VeilidConfigApplicationToJson(
_VeilidConfigApplication instance) =>
<String, dynamic>{
'https': instance.https.toJson(),
'http': instance.http.toJson(),
};
_VeilidConfigApplication instance,
) => <String, dynamic>{
'https': instance.https.toJson(),
'http': instance.http.toJson(),
};
_VeilidConfigUDP _$VeilidConfigUDPFromJson(Map<String, dynamic> json) =>
_VeilidConfigUDP(
@ -297,22 +292,22 @@ Map<String, dynamic> _$VeilidConfigWSSToJson(_VeilidConfigWSS instance) =>
};
_VeilidConfigProtocol _$VeilidConfigProtocolFromJson(
Map<String, dynamic> json) =>
_VeilidConfigProtocol(
udp: VeilidConfigUDP.fromJson(json['udp']),
tcp: VeilidConfigTCP.fromJson(json['tcp']),
ws: VeilidConfigWS.fromJson(json['ws']),
wss: VeilidConfigWSS.fromJson(json['wss']),
);
Map<String, dynamic> json,
) => _VeilidConfigProtocol(
udp: VeilidConfigUDP.fromJson(json['udp']),
tcp: VeilidConfigTCP.fromJson(json['tcp']),
ws: VeilidConfigWS.fromJson(json['ws']),
wss: VeilidConfigWSS.fromJson(json['wss']),
);
Map<String, dynamic> _$VeilidConfigProtocolToJson(
_VeilidConfigProtocol instance) =>
<String, dynamic>{
'udp': instance.udp.toJson(),
'tcp': instance.tcp.toJson(),
'ws': instance.ws.toJson(),
'wss': instance.wss.toJson(),
};
_VeilidConfigProtocol instance,
) => <String, dynamic>{
'udp': instance.udp.toJson(),
'tcp': instance.tcp.toJson(),
'ws': instance.ws.toJson(),
'wss': instance.wss.toJson(),
};
_VeilidConfigPrivacy _$VeilidConfigPrivacyFromJson(Map<String, dynamic> json) =>
_VeilidConfigPrivacy(
@ -320,17 +315,15 @@ _VeilidConfigPrivacy _$VeilidConfigPrivacyFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$VeilidConfigPrivacyToJson(
_VeilidConfigPrivacy instance) =>
<String, dynamic>{
'require_inbound_relay': instance.requireInboundRelay,
};
_VeilidConfigPrivacy instance,
) => <String, dynamic>{'require_inbound_relay': instance.requireInboundRelay};
_VeilidConfigTLS _$VeilidConfigTLSFromJson(Map<String, dynamic> json) =>
_VeilidConfigTLS(
certificatePath: json['certificate_path'] as String,
privateKeyPath: json['private_key_path'] as String,
connectionInitialTimeoutMs:
(json['connection_initial_timeout_ms'] as num).toInt(),
connectionInitialTimeoutMs: (json['connection_initial_timeout_ms'] as num)
.toInt(),
);
Map<String, dynamic> _$VeilidConfigTLSToJson(_VeilidConfigTLS instance) =>
@ -363,40 +356,39 @@ _VeilidConfigDHT _$VeilidConfigDHTFromJson(Map<String, dynamic> json) =>
remoteMaxRecords: (json['remote_max_records'] as num).toInt(),
remoteMaxSubkeyCacheMemoryMb:
(json['remote_max_subkey_cache_memory_mb'] as num).toInt(),
remoteMaxStorageSpaceMb:
(json['remote_max_storage_space_mb'] as num).toInt(),
remoteMaxStorageSpaceMb: (json['remote_max_storage_space_mb'] as num)
.toInt(),
publicWatchLimit: (json['public_watch_limit'] as num).toInt(),
memberWatchLimit: (json['member_watch_limit'] as num).toInt(),
maxWatchExpirationMs: (json['max_watch_expiration_ms'] as num).toInt(),
);
Map<String, dynamic> _$VeilidConfigDHTToJson(_VeilidConfigDHT instance) =>
<String, dynamic>{
'resolve_node_timeout_ms': instance.resolveNodeTimeoutMs,
'resolve_node_count': instance.resolveNodeCount,
'resolve_node_fanout': instance.resolveNodeFanout,
'max_find_node_count': instance.maxFindNodeCount,
'get_value_timeout_ms': instance.getValueTimeoutMs,
'get_value_count': instance.getValueCount,
'get_value_fanout': instance.getValueFanout,
'set_value_timeout_ms': instance.setValueTimeoutMs,
'set_value_count': instance.setValueCount,
'set_value_fanout': instance.setValueFanout,
'min_peer_count': instance.minPeerCount,
'min_peer_refresh_time_ms': instance.minPeerRefreshTimeMs,
'validate_dial_info_receipt_time_ms':
instance.validateDialInfoReceiptTimeMs,
'local_subkey_cache_size': instance.localSubkeyCacheSize,
'local_max_subkey_cache_memory_mb': instance.localMaxSubkeyCacheMemoryMb,
'remote_subkey_cache_size': instance.remoteSubkeyCacheSize,
'remote_max_records': instance.remoteMaxRecords,
'remote_max_subkey_cache_memory_mb':
instance.remoteMaxSubkeyCacheMemoryMb,
'remote_max_storage_space_mb': instance.remoteMaxStorageSpaceMb,
'public_watch_limit': instance.publicWatchLimit,
'member_watch_limit': instance.memberWatchLimit,
'max_watch_expiration_ms': instance.maxWatchExpirationMs,
};
Map<String, dynamic> _$VeilidConfigDHTToJson(
_VeilidConfigDHT instance,
) => <String, dynamic>{
'resolve_node_timeout_ms': instance.resolveNodeTimeoutMs,
'resolve_node_count': instance.resolveNodeCount,
'resolve_node_fanout': instance.resolveNodeFanout,
'max_find_node_count': instance.maxFindNodeCount,
'get_value_timeout_ms': instance.getValueTimeoutMs,
'get_value_count': instance.getValueCount,
'get_value_fanout': instance.getValueFanout,
'set_value_timeout_ms': instance.setValueTimeoutMs,
'set_value_count': instance.setValueCount,
'set_value_fanout': instance.setValueFanout,
'min_peer_count': instance.minPeerCount,
'min_peer_refresh_time_ms': instance.minPeerRefreshTimeMs,
'validate_dial_info_receipt_time_ms': instance.validateDialInfoReceiptTimeMs,
'local_subkey_cache_size': instance.localSubkeyCacheSize,
'local_max_subkey_cache_memory_mb': instance.localMaxSubkeyCacheMemoryMb,
'remote_subkey_cache_size': instance.remoteSubkeyCacheSize,
'remote_max_records': instance.remoteMaxRecords,
'remote_max_subkey_cache_memory_mb': instance.remoteMaxSubkeyCacheMemoryMb,
'remote_max_storage_space_mb': instance.remoteMaxStorageSpaceMb,
'public_watch_limit': instance.publicWatchLimit,
'member_watch_limit': instance.memberWatchLimit,
'max_watch_expiration_ms': instance.maxWatchExpirationMs,
};
_VeilidConfigRPC _$VeilidConfigRPCFromJson(Map<String, dynamic> json) =>
_VeilidConfigRPC(
@ -421,44 +413,45 @@ Map<String, dynamic> _$VeilidConfigRPCToJson(_VeilidConfigRPC instance) =>
};
_VeilidConfigRoutingTable _$VeilidConfigRoutingTableFromJson(
Map<String, dynamic> json) =>
_VeilidConfigRoutingTable(
publicKeys: (json['public_keys'] as List<dynamic>)
.map(Typed<BarePublicKey>.fromJson)
.toList(),
secretKeys: (json['secret_keys'] as List<dynamic>)
.map(Typed<BareSecretKey>.fromJson)
.toList(),
bootstrap:
(json['bootstrap'] as List<dynamic>).map((e) => e as String).toList(),
bootstrapKeys: (json['bootstrap_keys'] as List<dynamic>)
.map(Typed<BarePublicKey>.fromJson)
.toList(),
limitOverAttached: (json['limit_over_attached'] as num).toInt(),
limitFullyAttached: (json['limit_fully_attached'] as num).toInt(),
limitAttachedStrong: (json['limit_attached_strong'] as num).toInt(),
limitAttachedGood: (json['limit_attached_good'] as num).toInt(),
limitAttachedWeak: (json['limit_attached_weak'] as num).toInt(),
);
Map<String, dynamic> json,
) => _VeilidConfigRoutingTable(
publicKeys: (json['public_keys'] as List<dynamic>)
.map(Typed<BarePublicKey>.fromJson)
.toList(),
secretKeys: (json['secret_keys'] as List<dynamic>)
.map(Typed<BareSecretKey>.fromJson)
.toList(),
bootstrap: (json['bootstrap'] as List<dynamic>)
.map((e) => e as String)
.toList(),
bootstrapKeys: (json['bootstrap_keys'] as List<dynamic>)
.map(Typed<BarePublicKey>.fromJson)
.toList(),
limitOverAttached: (json['limit_over_attached'] as num).toInt(),
limitFullyAttached: (json['limit_fully_attached'] as num).toInt(),
limitAttachedStrong: (json['limit_attached_strong'] as num).toInt(),
limitAttachedGood: (json['limit_attached_good'] as num).toInt(),
limitAttachedWeak: (json['limit_attached_weak'] as num).toInt(),
);
Map<String, dynamic> _$VeilidConfigRoutingTableToJson(
_VeilidConfigRoutingTable instance) =>
<String, dynamic>{
'public_keys': instance.publicKeys.map((e) => e.toJson()).toList(),
'secret_keys': instance.secretKeys.map((e) => e.toJson()).toList(),
'bootstrap': instance.bootstrap,
'bootstrap_keys': instance.bootstrapKeys.map((e) => e.toJson()).toList(),
'limit_over_attached': instance.limitOverAttached,
'limit_fully_attached': instance.limitFullyAttached,
'limit_attached_strong': instance.limitAttachedStrong,
'limit_attached_good': instance.limitAttachedGood,
'limit_attached_weak': instance.limitAttachedWeak,
};
_VeilidConfigRoutingTable instance,
) => <String, dynamic>{
'public_keys': instance.publicKeys.map((e) => e.toJson()).toList(),
'secret_keys': instance.secretKeys.map((e) => e.toJson()).toList(),
'bootstrap': instance.bootstrap,
'bootstrap_keys': instance.bootstrapKeys.map((e) => e.toJson()).toList(),
'limit_over_attached': instance.limitOverAttached,
'limit_fully_attached': instance.limitFullyAttached,
'limit_attached_strong': instance.limitAttachedStrong,
'limit_attached_good': instance.limitAttachedGood,
'limit_attached_weak': instance.limitAttachedWeak,
};
_VeilidConfigNetwork _$VeilidConfigNetworkFromJson(Map<String, dynamic> json) =>
_VeilidConfigNetwork(
connectionInitialTimeoutMs:
(json['connection_initial_timeout_ms'] as num).toInt(),
connectionInitialTimeoutMs: (json['connection_initial_timeout_ms'] as num)
.toInt(),
connectionInactivityTimeoutMs:
(json['connection_inactivity_timeout_ms'] as num).toInt(),
maxConnectionsPerIp4: (json['max_connections_per_ip4'] as num).toInt(),
@ -468,12 +461,12 @@ _VeilidConfigNetwork _$VeilidConfigNetworkFromJson(Map<String, dynamic> json) =>
(json['max_connections_per_ip6_prefix_size'] as num).toInt(),
maxConnectionFrequencyPerMin:
(json['max_connection_frequency_per_min'] as num).toInt(),
clientAllowlistTimeoutMs:
(json['client_allowlist_timeout_ms'] as num).toInt(),
clientAllowlistTimeoutMs: (json['client_allowlist_timeout_ms'] as num)
.toInt(),
reverseConnectionReceiptTimeMs:
(json['reverse_connection_receipt_time_ms'] as num).toInt(),
holePunchReceiptTimeMs:
(json['hole_punch_receipt_time_ms'] as num).toInt(),
holePunchReceiptTimeMs: (json['hole_punch_receipt_time_ms'] as num)
.toInt(),
routingTable: VeilidConfigRoutingTable.fromJson(json['routing_table']),
rpc: VeilidConfigRPC.fromJson(json['rpc']),
dht: VeilidConfigDHT.fromJson(json['dht']),
@ -488,106 +481,100 @@ _VeilidConfigNetwork _$VeilidConfigNetworkFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$VeilidConfigNetworkToJson(
_VeilidConfigNetwork instance) =>
<String, dynamic>{
'connection_initial_timeout_ms': instance.connectionInitialTimeoutMs,
'connection_inactivity_timeout_ms':
instance.connectionInactivityTimeoutMs,
'max_connections_per_ip4': instance.maxConnectionsPerIp4,
'max_connections_per_ip6_prefix': instance.maxConnectionsPerIp6Prefix,
'max_connections_per_ip6_prefix_size':
instance.maxConnectionsPerIp6PrefixSize,
'max_connection_frequency_per_min': instance.maxConnectionFrequencyPerMin,
'client_allowlist_timeout_ms': instance.clientAllowlistTimeoutMs,
'reverse_connection_receipt_time_ms':
instance.reverseConnectionReceiptTimeMs,
'hole_punch_receipt_time_ms': instance.holePunchReceiptTimeMs,
'routing_table': instance.routingTable.toJson(),
'rpc': instance.rpc.toJson(),
'dht': instance.dht.toJson(),
'upnp': instance.upnp,
'detect_address_changes': instance.detectAddressChanges,
'restricted_nat_retries': instance.restrictedNatRetries,
'tls': instance.tls.toJson(),
'application': instance.application.toJson(),
'protocol': instance.protocol.toJson(),
'privacy': instance.privacy.toJson(),
'network_key_password': instance.networkKeyPassword,
};
_VeilidConfigNetwork instance,
) => <String, dynamic>{
'connection_initial_timeout_ms': instance.connectionInitialTimeoutMs,
'connection_inactivity_timeout_ms': instance.connectionInactivityTimeoutMs,
'max_connections_per_ip4': instance.maxConnectionsPerIp4,
'max_connections_per_ip6_prefix': instance.maxConnectionsPerIp6Prefix,
'max_connections_per_ip6_prefix_size':
instance.maxConnectionsPerIp6PrefixSize,
'max_connection_frequency_per_min': instance.maxConnectionFrequencyPerMin,
'client_allowlist_timeout_ms': instance.clientAllowlistTimeoutMs,
'reverse_connection_receipt_time_ms': instance.reverseConnectionReceiptTimeMs,
'hole_punch_receipt_time_ms': instance.holePunchReceiptTimeMs,
'routing_table': instance.routingTable.toJson(),
'rpc': instance.rpc.toJson(),
'dht': instance.dht.toJson(),
'upnp': instance.upnp,
'detect_address_changes': instance.detectAddressChanges,
'restricted_nat_retries': instance.restrictedNatRetries,
'tls': instance.tls.toJson(),
'application': instance.application.toJson(),
'protocol': instance.protocol.toJson(),
'privacy': instance.privacy.toJson(),
'network_key_password': instance.networkKeyPassword,
};
_VeilidConfigTableStore _$VeilidConfigTableStoreFromJson(
Map<String, dynamic> json) =>
_VeilidConfigTableStore(
directory: json['directory'] as String,
delete: json['delete'] as bool,
);
Map<String, dynamic> json,
) => _VeilidConfigTableStore(
directory: json['directory'] as String,
delete: json['delete'] as bool,
);
Map<String, dynamic> _$VeilidConfigTableStoreToJson(
_VeilidConfigTableStore instance) =>
<String, dynamic>{
'directory': instance.directory,
'delete': instance.delete,
};
_VeilidConfigTableStore instance,
) => <String, dynamic>{
'directory': instance.directory,
'delete': instance.delete,
};
_VeilidConfigBlockStore _$VeilidConfigBlockStoreFromJson(
Map<String, dynamic> json) =>
_VeilidConfigBlockStore(
directory: json['directory'] as String,
delete: json['delete'] as bool,
);
Map<String, dynamic> json,
) => _VeilidConfigBlockStore(
directory: json['directory'] as String,
delete: json['delete'] as bool,
);
Map<String, dynamic> _$VeilidConfigBlockStoreToJson(
_VeilidConfigBlockStore instance) =>
<String, dynamic>{
'directory': instance.directory,
'delete': instance.delete,
};
_VeilidConfigBlockStore instance,
) => <String, dynamic>{
'directory': instance.directory,
'delete': instance.delete,
};
_VeilidConfigProtectedStore _$VeilidConfigProtectedStoreFromJson(
Map<String, dynamic> json) =>
_VeilidConfigProtectedStore(
allowInsecureFallback: json['allow_insecure_fallback'] as bool,
alwaysUseInsecureStorage: json['always_use_insecure_storage'] as bool,
directory: json['directory'] as String,
delete: json['delete'] as bool,
deviceEncryptionKeyPassword:
json['device_encryption_key_password'] as String,
newDeviceEncryptionKeyPassword:
json['new_device_encryption_key_password'] as String?,
);
Map<String, dynamic> json,
) => _VeilidConfigProtectedStore(
allowInsecureFallback: json['allow_insecure_fallback'] as bool,
alwaysUseInsecureStorage: json['always_use_insecure_storage'] as bool,
directory: json['directory'] as String,
delete: json['delete'] as bool,
deviceEncryptionKeyPassword: json['device_encryption_key_password'] as String,
newDeviceEncryptionKeyPassword:
json['new_device_encryption_key_password'] as String?,
);
Map<String, dynamic> _$VeilidConfigProtectedStoreToJson(
_VeilidConfigProtectedStore instance) =>
<String, dynamic>{
'allow_insecure_fallback': instance.allowInsecureFallback,
'always_use_insecure_storage': instance.alwaysUseInsecureStorage,
'directory': instance.directory,
'delete': instance.delete,
'device_encryption_key_password': instance.deviceEncryptionKeyPassword,
'new_device_encryption_key_password':
instance.newDeviceEncryptionKeyPassword,
};
_VeilidConfigProtectedStore instance,
) => <String, dynamic>{
'allow_insecure_fallback': instance.allowInsecureFallback,
'always_use_insecure_storage': instance.alwaysUseInsecureStorage,
'directory': instance.directory,
'delete': instance.delete,
'device_encryption_key_password': instance.deviceEncryptionKeyPassword,
'new_device_encryption_key_password': instance.newDeviceEncryptionKeyPassword,
};
_VeilidConfigCapabilities _$VeilidConfigCapabilitiesFromJson(
Map<String, dynamic> json) =>
_VeilidConfigCapabilities(
disable:
(json['disable'] as List<dynamic>).map((e) => e as String).toList(),
);
Map<String, dynamic> json,
) => _VeilidConfigCapabilities(
disable: (json['disable'] as List<dynamic>).map((e) => e as String).toList(),
);
Map<String, dynamic> _$VeilidConfigCapabilitiesToJson(
_VeilidConfigCapabilities instance) =>
<String, dynamic>{
'disable': instance.disable,
};
_VeilidConfigCapabilities instance,
) => <String, dynamic>{'disable': instance.disable};
_VeilidConfig _$VeilidConfigFromJson(Map<String, dynamic> json) =>
_VeilidConfig(
programName: json['program_name'] as String,
namespace: json['namespace'] as String,
capabilities: VeilidConfigCapabilities.fromJson(json['capabilities']),
protectedStore:
VeilidConfigProtectedStore.fromJson(json['protected_store']),
protectedStore: VeilidConfigProtectedStore.fromJson(
json['protected_store'],
),
tableStore: VeilidConfigTableStore.fromJson(json['table_store']),
blockStore: VeilidConfigBlockStore.fromJson(json['block_store']),
network: VeilidConfigNetwork.fromJson(json['network']),

View file

@ -14,6 +14,8 @@ import 'veilid.dart';
typedef CryptoKind = int;
const CryptoKind cryptoKindVLD0 =
$V << 24 | $L << 16 | $D << 8 | $0 << 0; // "VLD0"
// const CryptoKind cryptoKindVLD1 =
// $V << 24 | $L << 16 | $D << 8 | $1 << 0; // "VLD1"
const CryptoKind cryptoKindNONE =
$N << 24 | $O << 16 | $N << 8 | $E << 0; // "NONE"
@ -35,16 +37,29 @@ CryptoKind cryptoKindFromString(String s) {
if (s.codeUnits.length != 4) {
throw const FormatException('malformed string');
}
final kind =
ByteData.sublistView(Uint8List.fromList(s.codeUnits)).getUint32(0);
final kind = ByteData.sublistView(
Uint8List.fromList(s.codeUnits),
).getUint32(0);
return kind;
}
//////////////////////////////////////
/// Types
abstract interface class TypedCryptoKey<V> {
CryptoKind get kind;
V get value;
}
@immutable
class Typed<V extends EncodedString> extends Equatable {
class Typed<V extends EncodedString> extends Equatable
implements TypedCryptoKey<V> {
@override
final CryptoKind kind;
@override
final V value;
const Typed({required this.kind, required this.value});
factory Typed.fromString(String s) {
@ -56,24 +71,25 @@ class Typed<V extends EncodedString> extends Equatable {
final value = EncodedString.fromString<V>(parts.sublist(1).join(':'));
return Typed(kind: kind, value: value);
}
factory Typed.fromBytes(Uint8List b) {
final kind = cryptoKindFromBytes(b);
final value = EncodedString.fromBytes<V>(b.sublist(4));
return Typed(kind: kind, value: value);
}
factory Typed.fromJson(dynamic json) => Typed.fromString(json as String);
final CryptoKind kind;
final V value;
@override
List<Object> get props => [kind, value];
@override
String toString() => '${cryptoKindToString(kind)}:$value';
Uint8List decode() {
Uint8List toBytes() {
final b = BytesBuilder()
..add(cryptoKindToBytes(kind))
..add(value.decode());
..add(value.toBytes());
return b.toBytes();
}
@ -82,6 +98,10 @@ class Typed<V extends EncodedString> extends Equatable {
@immutable
class BareKeyPair extends Equatable {
final BarePublicKey key;
final BareSecretKey secret;
const BareKeyPair({required this.key, required this.secret});
factory BareKeyPair.fromString(String s) {
@ -93,10 +113,10 @@ class BareKeyPair extends Equatable {
final secret = BareSecretKey.fromString(parts[1]);
return BareKeyPair(key: key, secret: secret);
}
factory BareKeyPair.fromJson(dynamic json) =>
BareKeyPair.fromString(json as String);
final BarePublicKey key;
final BareSecretKey secret;
@override
List<Object> get props => [key, secret];
@ -107,9 +127,13 @@ class BareKeyPair extends Equatable {
}
@immutable
class KeyPair extends Equatable {
class KeyPair extends Equatable implements TypedCryptoKey<BareKeyPair> {
final PublicKey key;
final SecretKey secret;
KeyPair({required this.key, required this.secret})
: assert(key.kind == secret.kind, 'keypair parts must have same kind');
: assert(key.kind == secret.kind, 'keypair parts must have same kind');
factory KeyPair.fromString(String s) {
final parts = s.split(':');
@ -117,22 +141,39 @@ class KeyPair extends Equatable {
throw VeilidAPIExceptionInvalidArgument('malformed string', 's', s);
}
final kind = cryptoKindFromString(parts[0]);
final key =
PublicKey(kind: kind, value: BarePublicKey.fromString(parts[1]));
final secret =
SecretKey(kind: kind, value: BareSecretKey.fromString(parts[2]));
final key = PublicKey(
kind: kind,
value: BarePublicKey.fromString(parts[1]),
);
final secret = SecretKey(
kind: kind,
value: BareSecretKey.fromString(parts[2]),
);
return KeyPair(key: key, secret: secret);
}
factory KeyPair.fromJson(dynamic json) => KeyPair.fromString(json as String);
factory KeyPair.fromBareKeyPair(CryptoKind kind, BareKeyPair keyPair) =>
KeyPair(
key: PublicKey(kind: kind, value: keyPair.key),
secret: SecretKey(kind: kind, value: keyPair.secret));
key: PublicKey(kind: kind, value: keyPair.key),
secret: SecretKey(kind: kind, value: keyPair.secret),
);
factory KeyPair.fromPublicAndBareSecret(
PublicKey key, BareSecretKey secret) =>
KeyPair(key: key, secret: SecretKey(kind: key.kind, value: secret));
final PublicKey key;
final SecretKey secret;
PublicKey key,
BareSecretKey secret,
) => KeyPair(
key: key,
secret: SecretKey(kind: key.kind, value: secret),
);
@override
CryptoKind get kind => key.kind;
@override
BareKeyPair get value => BareKeyPair(key: key.value, secret: secret.value);
@override
List<Object> get props => [key, secret];
@ -141,12 +182,17 @@ class KeyPair extends Equatable {
'${cryptoKindToString(key.kind)}:${key.value}:${secret.value}';
String toJson() => toString();
BareKeyPair toBareKeyPair() =>
BareKeyPair(key: key.value, secret: secret.value);
}
@immutable
class BareRecordKey extends Equatable {
final BareOpaqueRecordKey key;
final BareSharedSecret? encryptionKey;
const BareRecordKey({required this.key, required this.encryptionKey});
factory BareRecordKey.fromString(String s) {
@ -162,10 +208,10 @@ class BareRecordKey extends Equatable {
final key = BareOpaqueRecordKey.fromString(parts[0]);
return BareRecordKey(key: key, encryptionKey: null);
}
factory BareRecordKey.fromJson(dynamic json) =>
BareRecordKey.fromString(json as String);
final BareOpaqueRecordKey key;
final BareSharedSecret? encryptionKey;
@override
List<Object?> get props => [key, encryptionKey];
@ -176,10 +222,16 @@ class BareRecordKey extends Equatable {
}
@immutable
class RecordKey extends Equatable {
RecordKey({required this.key, required this.encryptionKey})
: assert(encryptionKey == null || key.kind == encryptionKey.kind,
'recordkey parts must have same kind');
class RecordKey extends Equatable implements TypedCryptoKey<BareRecordKey> {
final OpaqueRecordKey opaque;
final SharedSecret? encryptionKey;
RecordKey({required this.opaque, required this.encryptionKey})
: assert(
encryptionKey == null || opaque.kind == encryptionKey.kind,
'recordkey parts must have same kind',
);
factory RecordKey.fromString(String s) {
final parts = s.split(':');
@ -190,41 +242,75 @@ class RecordKey extends Equatable {
}
final kind = cryptoKindFromString(parts[0]);
final key = OpaqueRecordKey(
kind: kind, value: BareOpaqueRecordKey.fromString(parts[1]));
kind: kind,
value: BareOpaqueRecordKey.fromString(parts[1]),
);
if (parts.length == 3) {
final encryptionKey = SharedSecret(
kind: kind, value: BareSharedSecret.fromString(parts[2]));
return RecordKey(key: key, encryptionKey: encryptionKey);
kind: kind,
value: BareSharedSecret.fromString(parts[2]),
);
return RecordKey(opaque: key, encryptionKey: encryptionKey);
}
return RecordKey(key: key, encryptionKey: null);
return RecordKey(opaque: key, encryptionKey: null);
}
factory RecordKey.fromJson(dynamic json) =>
RecordKey.fromString(json as String);
factory RecordKey.fromBareRecordKey(
CryptoKind kind, BareRecordKey bareRecordKey) =>
RecordKey(
key: OpaqueRecordKey(kind: kind, value: bareRecordKey.key),
encryptionKey: bareRecordKey.encryptionKey == null
? null
: SharedSecret(kind: kind, value: bareRecordKey.encryptionKey!));
factory RecordKey.fromOpaqueRecordKey(
OpaqueRecordKey key, BareSharedSecret? encryptionKey) =>
RecordKey(
key: key,
encryptionKey: encryptionKey == null
? null
: SharedSecret(kind: key.kind, value: encryptionKey));
final OpaqueRecordKey key;
final SharedSecret? encryptionKey;
CryptoKind kind,
BareRecordKey bareRecordKey,
) => RecordKey(
opaque: OpaqueRecordKey(kind: kind, value: bareRecordKey.key),
encryptionKey: bareRecordKey.encryptionKey == null
? null
: SharedSecret(kind: kind, value: bareRecordKey.encryptionKey!),
);
factory RecordKey.fromBytes(Uint8List bytes) {
final keyLength = ByteData.sublistView(bytes).getUint8(0);
final keyBytes = bytes.sublist(1, 1 + keyLength);
final key = OpaqueRecordKey.fromBytes(keyBytes);
SharedSecret? encryptionKey;
if (bytes.length > 1 + keyLength) {
final ekBytes = bytes.sublist(1 + keyLength, bytes.length);
encryptionKey = SharedSecret(
kind: key.kind,
value: BareSharedSecret.fromBytes(ekBytes),
);
}
return RecordKey(opaque: key, encryptionKey: encryptionKey);
}
@override
List<Object?> get props => [key, encryptionKey];
List<Object?> get props => [opaque, encryptionKey];
@override
CryptoKind get kind => opaque.kind;
@override
BareRecordKey get value =>
BareRecordKey(key: opaque.value, encryptionKey: encryptionKey?.value);
@override
String toString() => encryptionKey != null
? '${cryptoKindToString(key.kind)}:${key.value}:${encryptionKey!.value}'
: '${cryptoKindToString(key.kind)}:${key.value}';
? '${cryptoKindToString(opaque.kind)}:${opaque.value}:${encryptionKey!.value}'
: '${cryptoKindToString(opaque.kind)}:${opaque.value}';
String toJson() => toString();
Uint8List toBytes() {
final keyBytes = opaque.toBytes();
final b = BytesBuilder()
..addByte(keyBytes.lengthInBytes)
..add(keyBytes);
final ek = encryptionKey;
if (ek != null) {
b.add(ek.value.toBytes());
}
return b.toBytes();
}
}
typedef PublicKey = Typed<BarePublicKey>;
@ -257,7 +343,10 @@ abstract class VeilidCryptoSystem {
Future<SharedSecret> randomSharedSecret();
Future<SharedSecret> computeDH(PublicKey key, SecretKey secret);
Future<SharedSecret> generateSharedSecret(
PublicKey key, SecretKey secret, Uint8List domain);
PublicKey key,
SecretKey secret,
Uint8List domain,
);
Future<KeyPair> generateKeyPair();
Future<HashDigest> generateHash(Uint8List data);
//Future<HashDigest> generateHashReader(Stream<List<int>> reader);
@ -297,26 +386,41 @@ abstract class VeilidCryptoSystem {
// AEAD Encrypt/Decrypt
Future<Uint8List> decryptAead(Uint8List body, Nonce nonce,
SharedSecret sharedSecret, Uint8List? associatedData);
Future<Uint8List> encryptAead(Uint8List body, Nonce nonce,
SharedSecret sharedSecret, Uint8List? associatedData);
Future<Uint8List> decryptAead(
Uint8List body,
Nonce nonce,
SharedSecret sharedSecret,
Uint8List? associatedData,
);
Future<Uint8List> encryptAead(
Uint8List body,
Nonce nonce,
SharedSecret sharedSecret,
Uint8List? associatedData,
);
Future<Uint8List> cryptNoAuth(
Uint8List body, Nonce nonce, SharedSecret sharedSecret);
Uint8List body,
Nonce nonce,
SharedSecret sharedSecret,
);
Future<Uint8List> encryptAeadWithNonce(
Uint8List body, SharedSecret secret) async {
Uint8List body,
SharedSecret secret,
) async {
// generate nonce
final nonce = await randomNonce();
// crypt and append nonce
final b = BytesBuilder()
..add(await encryptAead(body, nonce, secret, null))
..add(nonce.decode());
..add(nonce.toBytes());
return b.toBytes();
}
Future<Uint8List> decryptAeadWithNonce(
Uint8List body, SharedSecret secret) async {
Uint8List body,
SharedSecret secret,
) async {
final nlen = await nonceLength();
if (body.length < nlen) {
throw const FormatException('not enough data to decrypt');
@ -328,17 +432,22 @@ abstract class VeilidCryptoSystem {
}
Future<Uint8List> encryptAeadWithPassword(
Uint8List body, String password) async {
Uint8List body,
String password,
) async {
final ekbytes = Uint8List.fromList(utf8.encode(password));
final nonce = await randomNonce();
final saltBytes = nonce.decode();
final saltBytes = nonce.toBytes();
final sharedSecret = await deriveSharedSecret(ekbytes, saltBytes);
return Uint8List.fromList(
(await encryptAead(body, nonce, sharedSecret, null)) + saltBytes);
(await encryptAead(body, nonce, sharedSecret, null)) + saltBytes,
);
}
Future<Uint8List> decryptAeadWithPassword(
Uint8List body, String password) async {
Uint8List body,
String password,
) async {
final nlen = await nonceLength();
if (body.length < nlen) {
throw const FormatException('not enough data to decrypt');
@ -354,18 +463,22 @@ abstract class VeilidCryptoSystem {
// NoAuth Encrypt/Decrypt
Future<Uint8List> encryptNoAuthWithNonce(
Uint8List body, SharedSecret secret) async {
Uint8List body,
SharedSecret secret,
) async {
// generate nonce
final nonce = await randomNonce();
// crypt and append nonce
final b = BytesBuilder()
..add(await cryptNoAuth(body, nonce, secret))
..add(nonce.decode());
..add(nonce.toBytes());
return b.toBytes();
}
Future<Uint8List> decryptNoAuthWithNonce(
Uint8List body, SharedSecret secret) async {
Uint8List body,
SharedSecret secret,
) async {
final nlen = await nonceLength();
if (body.length < nlen) {
throw const FormatException('not enough data to decrypt');
@ -377,17 +490,22 @@ abstract class VeilidCryptoSystem {
}
Future<Uint8List> encryptNoAuthWithPassword(
Uint8List body, String password) async {
Uint8List body,
String password,
) async {
final ekbytes = Uint8List.fromList(utf8.encode(password));
final nonce = await randomNonce();
final saltBytes = nonce.decode();
final saltBytes = nonce.toBytes();
final sharedSecret = await deriveSharedSecret(ekbytes, saltBytes);
return Uint8List.fromList(
(await cryptNoAuth(body, nonce, sharedSecret)) + saltBytes);
(await cryptNoAuth(body, nonce, sharedSecret)) + saltBytes,
);
}
Future<Uint8List> decryptNoAuthWithPassword(
Uint8List body, String password) async {
Uint8List body,
String password,
) async {
final nlen = await nonceLength();
if (body.length < nlen) {
throw const FormatException('not enough data to decrypt');

View file

@ -25,15 +25,17 @@ Uint8List base64UrlNoPadDecodeDynamic(dynamic source) =>
base64UrlNoPadDecode(source as String);
class Uint8ListJsonConverter implements JsonConverter<Uint8List, dynamic> {
const Uint8ListJsonConverter() : _jsIsArray = false;
const Uint8ListJsonConverter.jsIsArray() : _jsIsArray = true;
final bool _jsIsArray;
const Uint8ListJsonConverter() : _jsIsArray = false;
const Uint8ListJsonConverter.jsIsArray() : _jsIsArray = true;
@override
Uint8List fromJson(dynamic json) => kIsWeb && _jsIsArray
? convertUint8ListFromJson(json)
: base64UrlNoPadDecode(json as String);
@override
dynamic toJson(Uint8List data) => kIsWeb && _jsIsArray
? convertUint8ListToJson(data)
@ -42,6 +44,10 @@ class Uint8ListJsonConverter implements JsonConverter<Uint8List, dynamic> {
@immutable
sealed class EncodedString extends Equatable {
////////////////////////////////////////////////////////////////////////////
final String contents;
EncodedString._fromBytes(Uint8List bytes)
: contents = base64UrlNoPadEncode(bytes);
@ -49,13 +55,15 @@ sealed class EncodedString extends Equatable {
// Ensure things can be decoded, will throw an exception if it fails
base64UrlNoPadDecode(contents);
}
EncodedString._fromJson(dynamic json) : contents = json as String {
// Ensure things can be decoded, will throw an exception if it fails
base64UrlNoPadDecode(contents);
}
String toJson() => toString();
Uint8List decode() => base64UrlNoPadDecode(contents);
Uint8List toBytes() => base64UrlNoPadDecode(contents);
@override
String toString() => contents;
@ -74,10 +82,10 @@ sealed class EncodedString extends Equatable {
return BareSecretKey.fromBytes(bytes) as T;
case const (BareHashDigest):
return BareHashDigest.fromBytes(bytes) as T;
case const (BareOpaqueRecordKey):
return BareOpaqueRecordKey.fromBytes(bytes) as T;
case const (BareSharedSecret):
return BareSharedSecret.fromBytes(bytes) as T;
case const (BareHashDistance):
return BareHashDistance.fromBytes(bytes) as T;
case const (BareRouteId):
return BareRouteId.fromBytes(bytes) as T;
case const (BareNodeId):
@ -101,10 +109,10 @@ sealed class EncodedString extends Equatable {
return BareSecretKey.fromString(s) as T;
case const (BareHashDigest):
return BareHashDigest.fromString(s) as T;
case const (BareOpaqueRecordKey):
return BareOpaqueRecordKey.fromString(s) as T;
case const (BareSharedSecret):
return BareSharedSecret.fromString(s) as T;
case const (BareHashDistance):
return BareHashDistance.fromString(s) as T;
case const (BareRouteId):
return BareRouteId.fromString(s) as T;
case const (BareNodeId):
@ -128,10 +136,10 @@ sealed class EncodedString extends Equatable {
return BareSecretKey.fromJson(json) as T;
case const (BareHashDigest):
return BareHashDigest.fromJson(json) as T;
case const (BareOpaqueRecordKey):
return BareOpaqueRecordKey.fromJson(json) as T;
case const (BareSharedSecret):
return BareSharedSecret.fromJson(json) as T;
case const (BareHashDistance):
return BareHashDistance.fromJson(json) as T;
case const (BareRouteId):
return BareRouteId.fromJson(json) as T;
case const (BareNodeId):
@ -143,9 +151,6 @@ sealed class EncodedString extends Equatable {
}
}
////////////////////////////////////////////////////////////////////////////
final String contents;
@override
List<Object> get props => [contents];
}
@ -180,24 +185,18 @@ class BareHashDigest extends EncodedString {
BareHashDigest.fromJson(super.json) : super._fromJson();
}
class BareSharedSecret extends EncodedString {
BareSharedSecret.fromBytes(super.bytes) : super._fromBytes();
BareSharedSecret.fromString(super.s) : super._fromString();
BareSharedSecret.fromJson(super.json) : super._fromJson();
}
class BareHashDistance extends EncodedString {
BareHashDistance.fromBytes(super.bytes) : super._fromBytes();
BareHashDistance.fromString(super.s) : super._fromString();
BareHashDistance.fromJson(super.json) : super._fromJson();
}
class BareOpaqueRecordKey extends EncodedString {
BareOpaqueRecordKey.fromBytes(super.bytes) : super._fromBytes();
BareOpaqueRecordKey.fromString(super.s) : super._fromString();
BareOpaqueRecordKey.fromJson(super.json) : super._fromJson();
}
class BareSharedSecret extends EncodedString {
BareSharedSecret.fromBytes(super.bytes) : super._fromBytes();
BareSharedSecret.fromString(super.s) : super._fromString();
BareSharedSecret.fromJson(super.json) : super._fromJson();
}
class BareRouteId extends EncodedString {
BareRouteId.fromBytes(super.bytes) : super._fromBytes();
BareRouteId.fromString(super.s) : super._fromString();

View file

@ -547,10 +547,11 @@ Stream<T> processStreamJson<T>(
}
class _Ctx {
_Ctx(int this.id, this.ffi);
int? id;
final VeilidFFI ffi;
_Ctx(int this.id, this.ffi);
void ensureValid() {
if (id == null) {
throw VeilidAPIExceptionNotInitialized();
@ -567,11 +568,12 @@ class _Ctx {
// FFI implementation of VeilidRoutingContext
class VeilidRoutingContextFFI extends VeilidRoutingContext {
final _Ctx _ctx;
static final Finalizer<_Ctx> _finalizer = Finalizer((ctx) => ctx.close());
VeilidRoutingContextFFI._(this._ctx) {
_finalizer.attach(this, _ctx, detach: this);
}
final _Ctx _ctx;
static final Finalizer<_Ctx> _finalizer = Finalizer((ctx) => ctx.close());
@override
void close() {
@ -818,10 +820,12 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
}
class _TDBT {
_TDBT(int this.id, this.tdbffi, this.ffi);
int? id;
final VeilidTableDBFFI tdbffi;
final VeilidFFI ffi;
_TDBT(int this.id, this.tdbffi, this.ffi);
void ensureValid() {
if (id == null) {
throw VeilidAPIExceptionNotInitialized();
@ -838,11 +842,12 @@ class _TDBT {
// FFI implementation of VeilidTableDBTransaction
class VeilidTableDBTransactionFFI extends VeilidTableDBTransaction {
final _TDBT _tdbt;
static final Finalizer<_TDBT> _finalizer = Finalizer((tdbt) => tdbt.close());
VeilidTableDBTransactionFFI._(this._tdbt) {
_finalizer.attach(this, _tdbt, detach: this);
}
final _TDBT _tdbt;
static final Finalizer<_TDBT> _finalizer = Finalizer((tdbt) => tdbt.close());
@override
bool isDone() => _tdbt.id == null;
@ -909,9 +914,11 @@ class VeilidTableDBTransactionFFI extends VeilidTableDBTransaction {
}
class _TDB {
_TDB(int this.id, this.ffi);
int? id;
final VeilidFFI ffi;
_TDB(int this.id, this.ffi);
void ensureValid() {
if (id == null) {
throw VeilidAPIExceptionNotInitialized();
@ -928,11 +935,12 @@ class _TDB {
// FFI implementation of VeilidTableDB
class VeilidTableDBFFI extends VeilidTableDB {
final _TDB _tdb;
static final Finalizer<_TDB> _finalizer = Finalizer((tdb) => tdb.close());
VeilidTableDBFFI._(this._tdb) {
_finalizer.attach(this, _tdb, detach: this);
}
final _TDB _tdb;
static final Finalizer<_TDB> _finalizer = Finalizer((tdb) => tdb.close());
@override
void close() {
@ -1029,10 +1037,11 @@ class VeilidTableDBFFI extends VeilidTableDB {
// FFI implementation of VeilidCryptoSystem
class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
VeilidCryptoSystemFFI._(this._ffi, this._kind);
final CryptoKind _kind;
final VeilidFFI _ffi;
VeilidCryptoSystemFFI._(this._ffi, this._kind);
@override
CryptoKind kind() => _kind;
@ -1376,6 +1385,113 @@ class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
// FFI implementation of high level Veilid API
class VeilidFFI extends Veilid {
// veilid_core shared library
final DynamicLibrary _dylib;
// Shared library functions
final _FreeStringDart _freeString;
final _InitializeVeilidCoreDart _initializeVeilidCore;
final _ChangeLogLevelDart _changeLogLevel;
final _ChangeLogIgnoreDart _changeLogIgnore;
final _StartupVeilidCoreDart _startupVeilidCore;
final _GetVeilidStateDart _getVeilidState;
final _IsShutdownDart _isShutdown;
final _AttachDart _attach;
final _DetachDart _detach;
final _ShutdownVeilidCoreDart _shutdownVeilidCore;
final _RoutingContextDart _routingContext;
final _ReleaseRoutingContextDart _releaseRoutingContext;
final _RoutingContextWithDefaultSafetyDart _routingContextWithDefaultSafety;
final _RoutingContextWithSafetyDart _routingContextWithSafety;
final _RoutingContextWithSequencingDart _routingContextWithSequencing;
final _RoutingContextSafetyDart _routingContextSafety;
final _RoutingContextAppCallDart _routingContextAppCall;
final _RoutingContextAppMessageDart _routingContextAppMessage;
final _RoutingContextGetDHTRecordKeyDart _routingContextGetDHTRecordKey;
final _RoutingContextCreateDHTRecordDart _routingContextCreateDHTRecord;
final _RoutingContextOpenDHTRecordDart _routingContextOpenDHTRecord;
final _RoutingContextCloseDHTRecordDart _routingContextCloseDHTRecord;
final _RoutingContextDeleteDHTRecordDart _routingContextDeleteDHTRecord;
final _RoutingContextGetDHTValueDart _routingContextGetDHTValue;
final _RoutingContextSetDHTValueDart _routingContextSetDHTValue;
final _RoutingContextWatchDHTValuesDart _routingContextWatchDHTValues;
final _RoutingContextCancelDHTWatchDart _routingContextCancelDHTWatch;
final _RoutingContextInspectDHTRecordDart _routingContextInspectDHTRecord;
final _GenerateMemberIdDart _generateMemberId;
final _NewPrivateRouteDart _newPrivateRoute;
final _NewCustomPrivateRouteDart _newCustomPrivateRoute;
final _ImportRemotePrivateRouteDart _importRemotePrivateRoute;
final _ReleasePrivateRouteDart _releasePrivateRoute;
final _AppCallReplyDart _appCallReply;
final _OpenTableDbDart _openTableDb;
final _ReleaseTableDbDart _releaseTableDb;
final _DeleteTableDbDart _deleteTableDb;
final _TableDbGetColumnCountDart _tableDbGetColumnCount;
final _TableDbGetKeysDart _tableDbGetKeys;
final _TableDbStoreDart _tableDbStore;
final _TableDbLoadDart _tableDbLoad;
final _TableDbDeleteDart _tableDbDelete;
final _TableDbTransactDart _tableDbTransact;
final _ReleaseTableDbTransactionDart _releaseTableDbTransaction;
final _TableDbTransactionCommitDart _tableDbTransactionCommit;
final _TableDbTransactionRollbackDart _tableDbTransactionRollback;
final _TableDbTransactionStoreDart _tableDbTransactionStore;
final _TableDbTransactionDeleteDart _tableDbTransactionDelete;
final _ValidCryptoKindsDart _validCryptoKinds;
final _VerifySignaturesDart _verifySignatures;
final _GenerateSignaturesDart _generateSignatures;
final _GenerateKeyPairDart _generateKeyPair;
final _CryptoCachedDHDart _cryptoCachedDH;
final _CryptoComputeDHDart _cryptoComputeDH;
final _CryptoGenerateSharedSecretDart _cryptoGenerateSharedSecret;
final _CryptoRandomBytesDart _cryptoRandomBytes;
final _CryptoHashPasswordDart _cryptoHashPassword;
final _CryptoVerifyPasswordDart _cryptoVerifyPassword;
final _CryptoDeriveSharedSecretDart _cryptoDeriveSharedSecret;
final _CryptoSharedSecretLengthDart _cryptoSharedSecretLength;
final _CryptoNonceLengthDart _cryptoNonceLength;
final _CryptoHashDigestLengthDart _cryptoHashDigestLength;
final _CryptoPublicKeyLengthDart _cryptoPublicKeyLength;
final _CryptoSecretKeyLengthDart _cryptoSecretKeyLength;
final _CryptoSignatureLengthDart _cryptoSignatureLength;
final _CryptoDefaultSaltLengthDart _cryptoDefaultSaltLength;
final _CryptoAeadOverheadDart _cryptoAeadOverhead;
final _CryptoCheckSharedSecretDart _cryptoCheckSharedSecret;
final _CryptoCheckNonceDart _cryptoCheckNonce;
final _CryptoCheckHashDigestDart _cryptoCheckHashDigest;
final _CryptoCheckPublicKeyDart _cryptoCheckPublicKey;
final _CryptoCheckSecretKeyDart _cryptoCheckSecretKey;
final _CryptoCheckSignatureDart _cryptoCheckSignature;
final _CryptoRandomNonceDart _cryptoRandomNonce;
final _CryptoRandomSharedSecretDart _cryptoRandomSharedSecret;
final _CryptoGenerateKeyPairDart _cryptoGenerateKeyPair;
final _CryptoGenerateHashDart _cryptoGenerateHash;
final _CryptoValidateKeyPairDart _cryptoValidateKeyPair;
final _CryptoValidateHashDart _cryptoValidateHash;
final _CryptoSignDart _cryptoSign;
final _CryptoVerifyDart _cryptoVerify;
final _CryptoDecryptAeadDart _cryptoDecryptAead;
final _CryptoEncryptAeadDart _cryptoEncryptAead;
final _CryptoCryptNoAuthDart _cryptoCryptNoAuth;
final _NowDart _now;
final _DebugDart _debug;
final _VeilidVersionStringDart _veilidVersionString;
final _VeilidVersionDart _veilidVersion;
final _DefaultVeilidConfigDart _defaultVeilidConfig;
final _VeilidFeaturesDart _veilidFeatures;
VeilidFFI(DynamicLibrary dylib)
: _dylib = dylib,
_freeString =
@ -1666,113 +1782,6 @@ class VeilidFFI extends Veilid {
const String.fromEnvironment('VEILID_CRASH_PATH').toNativeUtf8(),
);
}
// veilid_core shared library
final DynamicLibrary _dylib;
// Shared library functions
final _FreeStringDart _freeString;
final _InitializeVeilidCoreDart _initializeVeilidCore;
final _ChangeLogLevelDart _changeLogLevel;
final _ChangeLogIgnoreDart _changeLogIgnore;
final _StartupVeilidCoreDart _startupVeilidCore;
final _GetVeilidStateDart _getVeilidState;
final _IsShutdownDart _isShutdown;
final _AttachDart _attach;
final _DetachDart _detach;
final _ShutdownVeilidCoreDart _shutdownVeilidCore;
final _RoutingContextDart _routingContext;
final _ReleaseRoutingContextDart _releaseRoutingContext;
final _RoutingContextWithDefaultSafetyDart _routingContextWithDefaultSafety;
final _RoutingContextWithSafetyDart _routingContextWithSafety;
final _RoutingContextWithSequencingDart _routingContextWithSequencing;
final _RoutingContextSafetyDart _routingContextSafety;
final _RoutingContextAppCallDart _routingContextAppCall;
final _RoutingContextAppMessageDart _routingContextAppMessage;
final _RoutingContextGetDHTRecordKeyDart _routingContextGetDHTRecordKey;
final _RoutingContextCreateDHTRecordDart _routingContextCreateDHTRecord;
final _RoutingContextOpenDHTRecordDart _routingContextOpenDHTRecord;
final _RoutingContextCloseDHTRecordDart _routingContextCloseDHTRecord;
final _RoutingContextDeleteDHTRecordDart _routingContextDeleteDHTRecord;
final _RoutingContextGetDHTValueDart _routingContextGetDHTValue;
final _RoutingContextSetDHTValueDart _routingContextSetDHTValue;
final _RoutingContextWatchDHTValuesDart _routingContextWatchDHTValues;
final _RoutingContextCancelDHTWatchDart _routingContextCancelDHTWatch;
final _RoutingContextInspectDHTRecordDart _routingContextInspectDHTRecord;
final _GenerateMemberIdDart _generateMemberId;
final _NewPrivateRouteDart _newPrivateRoute;
final _NewCustomPrivateRouteDart _newCustomPrivateRoute;
final _ImportRemotePrivateRouteDart _importRemotePrivateRoute;
final _ReleasePrivateRouteDart _releasePrivateRoute;
final _AppCallReplyDart _appCallReply;
final _OpenTableDbDart _openTableDb;
final _ReleaseTableDbDart _releaseTableDb;
final _DeleteTableDbDart _deleteTableDb;
final _TableDbGetColumnCountDart _tableDbGetColumnCount;
final _TableDbGetKeysDart _tableDbGetKeys;
final _TableDbStoreDart _tableDbStore;
final _TableDbLoadDart _tableDbLoad;
final _TableDbDeleteDart _tableDbDelete;
final _TableDbTransactDart _tableDbTransact;
final _ReleaseTableDbTransactionDart _releaseTableDbTransaction;
final _TableDbTransactionCommitDart _tableDbTransactionCommit;
final _TableDbTransactionRollbackDart _tableDbTransactionRollback;
final _TableDbTransactionStoreDart _tableDbTransactionStore;
final _TableDbTransactionDeleteDart _tableDbTransactionDelete;
final _ValidCryptoKindsDart _validCryptoKinds;
final _VerifySignaturesDart _verifySignatures;
final _GenerateSignaturesDart _generateSignatures;
final _GenerateKeyPairDart _generateKeyPair;
final _CryptoCachedDHDart _cryptoCachedDH;
final _CryptoComputeDHDart _cryptoComputeDH;
final _CryptoGenerateSharedSecretDart _cryptoGenerateSharedSecret;
final _CryptoRandomBytesDart _cryptoRandomBytes;
final _CryptoHashPasswordDart _cryptoHashPassword;
final _CryptoVerifyPasswordDart _cryptoVerifyPassword;
final _CryptoDeriveSharedSecretDart _cryptoDeriveSharedSecret;
final _CryptoSharedSecretLengthDart _cryptoSharedSecretLength;
final _CryptoNonceLengthDart _cryptoNonceLength;
final _CryptoHashDigestLengthDart _cryptoHashDigestLength;
final _CryptoPublicKeyLengthDart _cryptoPublicKeyLength;
final _CryptoSecretKeyLengthDart _cryptoSecretKeyLength;
final _CryptoSignatureLengthDart _cryptoSignatureLength;
final _CryptoDefaultSaltLengthDart _cryptoDefaultSaltLength;
final _CryptoAeadOverheadDart _cryptoAeadOverhead;
final _CryptoCheckSharedSecretDart _cryptoCheckSharedSecret;
final _CryptoCheckNonceDart _cryptoCheckNonce;
final _CryptoCheckHashDigestDart _cryptoCheckHashDigest;
final _CryptoCheckPublicKeyDart _cryptoCheckPublicKey;
final _CryptoCheckSecretKeyDart _cryptoCheckSecretKey;
final _CryptoCheckSignatureDart _cryptoCheckSignature;
final _CryptoRandomNonceDart _cryptoRandomNonce;
final _CryptoRandomSharedSecretDart _cryptoRandomSharedSecret;
final _CryptoGenerateKeyPairDart _cryptoGenerateKeyPair;
final _CryptoGenerateHashDart _cryptoGenerateHash;
final _CryptoValidateKeyPairDart _cryptoValidateKeyPair;
final _CryptoValidateHashDart _cryptoValidateHash;
final _CryptoSignDart _cryptoSign;
final _CryptoVerifyDart _cryptoVerify;
final _CryptoDecryptAeadDart _cryptoDecryptAead;
final _CryptoEncryptAeadDart _cryptoEncryptAead;
final _CryptoCryptNoAuthDart _cryptoCryptNoAuth;
final _NowDart _now;
final _DebugDart _debug;
final _VeilidVersionStringDart _veilidVersionString;
final _VeilidVersionDart _veilidVersion;
final _DefaultVeilidConfigDart _defaultVeilidConfig;
final _VeilidFeaturesDart _veilidFeatures;
@override
void initializeVeilidCore(Map<String, dynamic> platformConfigJson) {
final nativePlatformConfig = jsonEncode(platformConfigJson).toNativeUtf8();

View file

@ -41,9 +41,12 @@ Future<T> _wrapApiPromise<T>(Object p) => js_util
});
class _Ctx {
_Ctx(int id, this.js) : _id = id;
int? _id;
final VeilidJS js;
_Ctx(int id, this.js) : _id = id;
int requireId() {
if (_id == null) {
throw VeilidAPIExceptionNotInitialized();
@ -61,11 +64,13 @@ class _Ctx {
// JS implementation of VeilidRoutingContext
class VeilidRoutingContextJS extends VeilidRoutingContext {
final _Ctx _ctx;
static final Finalizer<_Ctx> _finalizer = Finalizer((ctx) => ctx.close());
VeilidRoutingContextJS._(this._ctx) {
_finalizer.attach(this, _ctx, detach: this);
}
final _Ctx _ctx;
static final Finalizer<_Ctx> _finalizer = Finalizer((ctx) => ctx.close());
@override
void close() {
@ -270,13 +275,14 @@ class VeilidRoutingContextJS extends VeilidRoutingContext {
// JS implementation of VeilidCryptoSystem
class VeilidCryptoSystemJS extends VeilidCryptoSystem {
VeilidCryptoSystemJS._(this._js, this._kind);
final CryptoKind _kind;
// Keep the reference
// ignore: unused_field
final VeilidJS _js;
VeilidCryptoSystemJS._(this._js, this._kind);
@override
CryptoKind kind() => _kind;
@ -293,6 +299,7 @@ class VeilidCryptoSystemJS extends VeilidCryptoSystem {
wasm,
'crypto_compute_dh',
[_kind, jsonEncode(key), jsonEncode(secret)]))));
@override
Future<SharedSecret> generateSharedSecret(
PublicKey key, SecretKey secret, Uint8List domain) async =>
@ -481,10 +488,14 @@ class VeilidCryptoSystemJS extends VeilidCryptoSystem {
}
class _TDBT {
_TDBT(this.id, this.tdbjs, this.js);
int? id;
final VeilidTableDBJS tdbjs;
final VeilidJS js;
_TDBT(this.id, this.tdbjs, this.js);
void ensureValid() {
if (id == null) {
throw VeilidAPIExceptionNotInitialized();
@ -501,11 +512,13 @@ class _TDBT {
// JS implementation of VeilidTableDBTransaction
class VeilidTableDBTransactionJS extends VeilidTableDBTransaction {
final _TDBT _tdbt;
static final Finalizer<_TDBT> _finalizer = Finalizer((tdbt) => tdbt.close());
VeilidTableDBTransactionJS._(this._tdbt) {
_finalizer.attach(this, _tdbt, detach: this);
}
final _TDBT _tdbt;
static final Finalizer<_TDBT> _finalizer = Finalizer((tdbt) => tdbt.close());
@override
bool isDone() => _tdbt.id == null;
@ -551,11 +564,12 @@ class VeilidTableDBTransactionJS extends VeilidTableDBTransaction {
}
class _TDB {
_TDB(int id, this.js) : _id = id;
int? _id;
final VeilidJS js;
_TDB(int id, this.js) : _id = id;
int requireId() {
if (_id == null) {
throw VeilidAPIExceptionNotInitialized();
@ -573,11 +587,13 @@ class _TDB {
// JS implementation of VeilidTableDB
class VeilidTableDBJS extends VeilidTableDB {
final _TDB _tdb;
static final Finalizer<_TDB> _finalizer = Finalizer((tdb) => tdb.close());
VeilidTableDBJS._(this._tdb) {
_finalizer.attach(this, _tdb, detach: this);
}
final _TDB _tdb;
static final Finalizer<_TDB> _finalizer = Finalizer((tdb) => tdb.close());
@override
void close() {

File diff suppressed because it is too large Load diff

View file

@ -51,20 +51,20 @@ _TransferStatsDownUp _$TransferStatsDownUpFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$TransferStatsDownUpToJson(
_TransferStatsDownUp instance) =>
<String, dynamic>{
'down': instance.down.toJson(),
'up': instance.up.toJson(),
};
_TransferStatsDownUp instance,
) => <String, dynamic>{
'down': instance.down.toJson(),
'up': instance.up.toJson(),
};
_StateStats _$StateStatsFromJson(Map<String, dynamic> json) => _StateStats(
span: TimestampDuration.fromJson(json['span']),
reliable: TimestampDuration.fromJson(json['reliable']),
unreliable: TimestampDuration.fromJson(json['unreliable']),
dead: TimestampDuration.fromJson(json['dead']),
punished: TimestampDuration.fromJson(json['punished']),
reason: StateReasonStats.fromJson(json['reason']),
);
span: TimestampDuration.fromJson(json['span']),
reliable: TimestampDuration.fromJson(json['reliable']),
unreliable: TimestampDuration.fromJson(json['unreliable']),
dead: TimestampDuration.fromJson(json['dead']),
punished: TimestampDuration.fromJson(json['punished']),
reason: StateReasonStats.fromJson(json['reason']),
);
Map<String, dynamic> _$StateStatsToJson(_StateStats instance) =>
<String, dynamic>{
@ -79,15 +79,18 @@ Map<String, dynamic> _$StateStatsToJson(_StateStats instance) =>
_StateReasonStats _$StateReasonStatsFromJson(Map<String, dynamic> json) =>
_StateReasonStats(
canNotSend: TimestampDuration.fromJson(json['can_not_send']),
tooManyLostAnswers:
TimestampDuration.fromJson(json['too_many_lost_answers']),
tooManyLostAnswers: TimestampDuration.fromJson(
json['too_many_lost_answers'],
),
noPingResponse: TimestampDuration.fromJson(json['no_ping_response']),
failedToSend: TimestampDuration.fromJson(json['failed_to_send']),
lostAnswers: TimestampDuration.fromJson(json['lost_answers']),
notSeenConsecutively:
TimestampDuration.fromJson(json['not_seen_consecutively']),
inUnreliablePingSpan:
TimestampDuration.fromJson(json['in_unreliable_ping_span']),
notSeenConsecutively: TimestampDuration.fromJson(
json['not_seen_consecutively'],
),
inUnreliablePingSpan: TimestampDuration.fromJson(
json['in_unreliable_ping_span'],
),
);
Map<String, dynamic> _$StateReasonStatsToJson(_StateReasonStats instance) =>
@ -102,86 +105,84 @@ Map<String, dynamic> _$StateReasonStatsToJson(_StateReasonStats instance) =>
};
_AnswerStats _$AnswerStatsFromJson(Map<String, dynamic> json) => _AnswerStats(
span: TimestampDuration.fromJson(json['span']),
questions: (json['questions'] as num).toInt(),
answers: (json['answers'] as num).toInt(),
lostAnswers: (json['lost_answers'] as num).toInt(),
consecutiveAnswersMaximum:
(json['consecutive_answers_maximum'] as num).toInt(),
consecutiveAnswersAverage:
(json['consecutive_answers_average'] as num).toInt(),
consecutiveAnswersMinimum:
(json['consecutive_answers_minimum'] as num).toInt(),
consecutiveLostAnswersMaximum:
(json['consecutive_lost_answers_maximum'] as num).toInt(),
consecutiveLostAnswersAverage:
(json['consecutive_lost_answers_average'] as num).toInt(),
consecutiveLostAnswersMinimum:
(json['consecutive_lost_answers_minimum'] as num).toInt(),
);
span: TimestampDuration.fromJson(json['span']),
questions: (json['questions'] as num).toInt(),
answers: (json['answers'] as num).toInt(),
lostAnswers: (json['lost_answers'] as num).toInt(),
consecutiveAnswersMaximum: (json['consecutive_answers_maximum'] as num)
.toInt(),
consecutiveAnswersAverage: (json['consecutive_answers_average'] as num)
.toInt(),
consecutiveAnswersMinimum: (json['consecutive_answers_minimum'] as num)
.toInt(),
consecutiveLostAnswersMaximum:
(json['consecutive_lost_answers_maximum'] as num).toInt(),
consecutiveLostAnswersAverage:
(json['consecutive_lost_answers_average'] as num).toInt(),
consecutiveLostAnswersMinimum:
(json['consecutive_lost_answers_minimum'] as num).toInt(),
);
Map<String, dynamic> _$AnswerStatsToJson(_AnswerStats instance) =>
<String, dynamic>{
'span': instance.span.toJson(),
'questions': instance.questions,
'answers': instance.answers,
'lost_answers': instance.lostAnswers,
'consecutive_answers_maximum': instance.consecutiveAnswersMaximum,
'consecutive_answers_average': instance.consecutiveAnswersAverage,
'consecutive_answers_minimum': instance.consecutiveAnswersMinimum,
'consecutive_lost_answers_maximum':
instance.consecutiveLostAnswersMaximum,
'consecutive_lost_answers_average':
instance.consecutiveLostAnswersAverage,
'consecutive_lost_answers_minimum':
instance.consecutiveLostAnswersMinimum,
};
Map<String, dynamic> _$AnswerStatsToJson(
_AnswerStats instance,
) => <String, dynamic>{
'span': instance.span.toJson(),
'questions': instance.questions,
'answers': instance.answers,
'lost_answers': instance.lostAnswers,
'consecutive_answers_maximum': instance.consecutiveAnswersMaximum,
'consecutive_answers_average': instance.consecutiveAnswersAverage,
'consecutive_answers_minimum': instance.consecutiveAnswersMinimum,
'consecutive_lost_answers_maximum': instance.consecutiveLostAnswersMaximum,
'consecutive_lost_answers_average': instance.consecutiveLostAnswersAverage,
'consecutive_lost_answers_minimum': instance.consecutiveLostAnswersMinimum,
};
_RPCStats _$RPCStatsFromJson(Map<String, dynamic> json) => _RPCStats(
messagesSent: (json['messages_sent'] as num).toInt(),
messagesRcvd: (json['messages_rcvd'] as num).toInt(),
questionsInFlight: (json['questions_in_flight'] as num).toInt(),
lastQuestionTs: json['last_question_ts'] == null
? null
: Timestamp.fromJson(json['last_question_ts']),
lastSeenTs: json['last_seen_ts'] == null
? null
: Timestamp.fromJson(json['last_seen_ts']),
firstConsecutiveSeenTs: json['first_consecutive_seen_ts'] == null
? null
: Timestamp.fromJson(json['first_consecutive_seen_ts']),
recentLostAnswersUnordered:
(json['recent_lost_answers_unordered'] as num).toInt(),
recentLostAnswersOrdered:
(json['recent_lost_answers_ordered'] as num).toInt(),
failedToSend: (json['failed_to_send'] as num).toInt(),
answerUnordered: AnswerStats.fromJson(json['answer_unordered']),
answerOrdered: AnswerStats.fromJson(json['answer_ordered']),
);
messagesSent: (json['messages_sent'] as num).toInt(),
messagesRcvd: (json['messages_rcvd'] as num).toInt(),
questionsInFlight: (json['questions_in_flight'] as num).toInt(),
lastQuestionTs: json['last_question_ts'] == null
? null
: Timestamp.fromJson(json['last_question_ts']),
lastSeenTs: json['last_seen_ts'] == null
? null
: Timestamp.fromJson(json['last_seen_ts']),
firstConsecutiveSeenTs: json['first_consecutive_seen_ts'] == null
? null
: Timestamp.fromJson(json['first_consecutive_seen_ts']),
recentLostAnswersUnordered: (json['recent_lost_answers_unordered'] as num)
.toInt(),
recentLostAnswersOrdered: (json['recent_lost_answers_ordered'] as num)
.toInt(),
failedToSend: (json['failed_to_send'] as num).toInt(),
answerUnordered: AnswerStats.fromJson(json['answer_unordered']),
answerOrdered: AnswerStats.fromJson(json['answer_ordered']),
);
Map<String, dynamic> _$RPCStatsToJson(_RPCStats instance) => <String, dynamic>{
'messages_sent': instance.messagesSent,
'messages_rcvd': instance.messagesRcvd,
'questions_in_flight': instance.questionsInFlight,
'last_question_ts': instance.lastQuestionTs?.toJson(),
'last_seen_ts': instance.lastSeenTs?.toJson(),
'first_consecutive_seen_ts': instance.firstConsecutiveSeenTs?.toJson(),
'recent_lost_answers_unordered': instance.recentLostAnswersUnordered,
'recent_lost_answers_ordered': instance.recentLostAnswersOrdered,
'failed_to_send': instance.failedToSend,
'answer_unordered': instance.answerUnordered.toJson(),
'answer_ordered': instance.answerOrdered.toJson(),
};
'messages_sent': instance.messagesSent,
'messages_rcvd': instance.messagesRcvd,
'questions_in_flight': instance.questionsInFlight,
'last_question_ts': instance.lastQuestionTs?.toJson(),
'last_seen_ts': instance.lastSeenTs?.toJson(),
'first_consecutive_seen_ts': instance.firstConsecutiveSeenTs?.toJson(),
'recent_lost_answers_unordered': instance.recentLostAnswersUnordered,
'recent_lost_answers_ordered': instance.recentLostAnswersOrdered,
'failed_to_send': instance.failedToSend,
'answer_unordered': instance.answerUnordered.toJson(),
'answer_ordered': instance.answerOrdered.toJson(),
};
_PeerStats _$PeerStatsFromJson(Map<String, dynamic> json) => _PeerStats(
timeAdded: Timestamp.fromJson(json['time_added']),
rpcStats: RPCStats.fromJson(json['rpc_stats']),
transfer: TransferStatsDownUp.fromJson(json['transfer']),
state: StateStats.fromJson(json['state']),
latency: json['latency'] == null
? null
: LatencyStats.fromJson(json['latency']),
);
timeAdded: Timestamp.fromJson(json['time_added']),
rpcStats: RPCStats.fromJson(json['rpc_stats']),
transfer: TransferStatsDownUp.fromJson(json['transfer']),
state: StateStats.fromJson(json['state']),
latency: json['latency'] == null
? null
: LatencyStats.fromJson(json['latency']),
);
Map<String, dynamic> _$PeerStatsToJson(_PeerStats instance) =>
<String, dynamic>{
@ -209,23 +210,24 @@ Map<String, dynamic> _$PeerTableDataToJson(_PeerTableData instance) =>
};
VeilidLog _$VeilidLogFromJson(Map<String, dynamic> json) => VeilidLog(
logLevel: VeilidLogLevel.fromJson(json['log_level']),
message: json['message'] as String,
backtrace: json['backtrace'] as String?,
$type: json['kind'] as String?,
);
logLevel: VeilidLogLevel.fromJson(json['log_level']),
message: json['message'] as String,
backtrace: json['backtrace'] as String?,
$type: json['kind'] as String?,
);
Map<String, dynamic> _$VeilidLogToJson(VeilidLog instance) => <String, dynamic>{
'log_level': instance.logLevel.toJson(),
'message': instance.message,
'backtrace': instance.backtrace,
'kind': instance.$type,
};
'log_level': instance.logLevel.toJson(),
'message': instance.message,
'backtrace': instance.backtrace,
'kind': instance.$type,
};
VeilidAppMessage _$VeilidAppMessageFromJson(Map<String, dynamic> json) =>
VeilidAppMessage(
message:
const Uint8ListJsonConverter.jsIsArray().fromJson(json['message']),
message: const Uint8ListJsonConverter.jsIsArray().fromJson(
json['message'],
),
sender: json['sender'] == null
? null
: Typed<BarePublicKey>.fromJson(json['sender']),
@ -233,19 +235,20 @@ VeilidAppMessage _$VeilidAppMessageFromJson(Map<String, dynamic> json) =>
$type: json['kind'] as String?,
);
Map<String, dynamic> _$VeilidAppMessageToJson(VeilidAppMessage instance) =>
<String, dynamic>{
'message':
const Uint8ListJsonConverter.jsIsArray().toJson(instance.message),
'sender': instance.sender?.toJson(),
'route_id': instance.routeId,
'kind': instance.$type,
};
Map<String, dynamic> _$VeilidAppMessageToJson(
VeilidAppMessage instance,
) => <String, dynamic>{
'message': const Uint8ListJsonConverter.jsIsArray().toJson(instance.message),
'sender': instance.sender?.toJson(),
'route_id': instance.routeId,
'kind': instance.$type,
};
VeilidAppCall _$VeilidAppCallFromJson(Map<String, dynamic> json) =>
VeilidAppCall(
message:
const Uint8ListJsonConverter.jsIsArray().fromJson(json['message']),
message: const Uint8ListJsonConverter.jsIsArray().fromJson(
json['message'],
),
callId: json['call_id'] as String,
sender: json['sender'] == null
? null
@ -254,59 +257,60 @@ VeilidAppCall _$VeilidAppCallFromJson(Map<String, dynamic> json) =>
$type: json['kind'] as String?,
);
Map<String, dynamic> _$VeilidAppCallToJson(VeilidAppCall instance) =>
<String, dynamic>{
'message':
const Uint8ListJsonConverter.jsIsArray().toJson(instance.message),
'call_id': instance.callId,
'sender': instance.sender?.toJson(),
'route_id': instance.routeId,
'kind': instance.$type,
};
Map<String, dynamic> _$VeilidAppCallToJson(
VeilidAppCall instance,
) => <String, dynamic>{
'message': const Uint8ListJsonConverter.jsIsArray().toJson(instance.message),
'call_id': instance.callId,
'sender': instance.sender?.toJson(),
'route_id': instance.routeId,
'kind': instance.$type,
};
VeilidUpdateAttachment _$VeilidUpdateAttachmentFromJson(
Map<String, dynamic> json) =>
VeilidUpdateAttachment(
state: AttachmentState.fromJson(json['state']),
publicInternetReady: json['public_internet_ready'] as bool,
localNetworkReady: json['local_network_ready'] as bool,
uptime: TimestampDuration.fromJson(json['uptime']),
attachedUptime: json['attached_uptime'] == null
? null
: TimestampDuration.fromJson(json['attached_uptime']),
$type: json['kind'] as String?,
);
Map<String, dynamic> json,
) => VeilidUpdateAttachment(
state: AttachmentState.fromJson(json['state']),
publicInternetReady: json['public_internet_ready'] as bool,
localNetworkReady: json['local_network_ready'] as bool,
uptime: TimestampDuration.fromJson(json['uptime']),
attachedUptime: json['attached_uptime'] == null
? null
: TimestampDuration.fromJson(json['attached_uptime']),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$VeilidUpdateAttachmentToJson(
VeilidUpdateAttachment instance) =>
<String, dynamic>{
'state': instance.state.toJson(),
'public_internet_ready': instance.publicInternetReady,
'local_network_ready': instance.localNetworkReady,
'uptime': instance.uptime.toJson(),
'attached_uptime': instance.attachedUptime?.toJson(),
'kind': instance.$type,
};
VeilidUpdateAttachment instance,
) => <String, dynamic>{
'state': instance.state.toJson(),
'public_internet_ready': instance.publicInternetReady,
'local_network_ready': instance.localNetworkReady,
'uptime': instance.uptime.toJson(),
'attached_uptime': instance.attachedUptime?.toJson(),
'kind': instance.$type,
};
VeilidUpdateNetwork _$VeilidUpdateNetworkFromJson(Map<String, dynamic> json) =>
VeilidUpdateNetwork(
started: json['started'] as bool,
bpsDown: BigInt.parse(json['bps_down'] as String),
bpsUp: BigInt.parse(json['bps_up'] as String),
peers:
(json['peers'] as List<dynamic>).map(PeerTableData.fromJson).toList(),
peers: (json['peers'] as List<dynamic>)
.map(PeerTableData.fromJson)
.toList(),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$VeilidUpdateNetworkToJson(
VeilidUpdateNetwork instance) =>
<String, dynamic>{
'started': instance.started,
'bps_down': instance.bpsDown.toString(),
'bps_up': instance.bpsUp.toString(),
'peers': instance.peers.map((e) => e.toJson()).toList(),
'kind': instance.$type,
};
VeilidUpdateNetwork instance,
) => <String, dynamic>{
'started': instance.started,
'bps_down': instance.bpsDown.toString(),
'bps_up': instance.bpsUp.toString(),
'peers': instance.peers.map((e) => e.toJson()).toList(),
'kind': instance.$type,
};
VeilidUpdateConfig _$VeilidUpdateConfigFromJson(Map<String, dynamic> json) =>
VeilidUpdateConfig(
@ -321,76 +325,77 @@ Map<String, dynamic> _$VeilidUpdateConfigToJson(VeilidUpdateConfig instance) =>
};
VeilidUpdateRouteChange _$VeilidUpdateRouteChangeFromJson(
Map<String, dynamic> json) =>
VeilidUpdateRouteChange(
deadRoutes: (json['dead_routes'] as List<dynamic>)
.map((e) => e as String)
.toList(),
deadRemoteRoutes: (json['dead_remote_routes'] as List<dynamic>)
.map((e) => e as String)
.toList(),
$type: json['kind'] as String?,
);
Map<String, dynamic> json,
) => VeilidUpdateRouteChange(
deadRoutes: (json['dead_routes'] as List<dynamic>)
.map((e) => e as String)
.toList(),
deadRemoteRoutes: (json['dead_remote_routes'] as List<dynamic>)
.map((e) => e as String)
.toList(),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$VeilidUpdateRouteChangeToJson(
VeilidUpdateRouteChange instance) =>
<String, dynamic>{
'dead_routes': instance.deadRoutes,
'dead_remote_routes': instance.deadRemoteRoutes,
'kind': instance.$type,
};
VeilidUpdateRouteChange instance,
) => <String, dynamic>{
'dead_routes': instance.deadRoutes,
'dead_remote_routes': instance.deadRemoteRoutes,
'kind': instance.$type,
};
VeilidUpdateValueChange _$VeilidUpdateValueChangeFromJson(
Map<String, dynamic> json) =>
VeilidUpdateValueChange(
key: RecordKey.fromJson(json['key']),
subkeys: (json['subkeys'] as List<dynamic>)
.map(ValueSubkeyRange.fromJson)
.toList(),
count: (json['count'] as num).toInt(),
value: json['value'] == null ? null : ValueData.fromJson(json['value']),
$type: json['kind'] as String?,
);
Map<String, dynamic> json,
) => VeilidUpdateValueChange(
key: RecordKey.fromJson(json['key']),
subkeys: (json['subkeys'] as List<dynamic>)
.map(ValueSubkeyRange.fromJson)
.toList(),
count: (json['count'] as num).toInt(),
value: json['value'] == null ? null : ValueData.fromJson(json['value']),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$VeilidUpdateValueChangeToJson(
VeilidUpdateValueChange instance) =>
<String, dynamic>{
'key': instance.key.toJson(),
'subkeys': instance.subkeys.map((e) => e.toJson()).toList(),
'count': instance.count,
'value': instance.value?.toJson(),
'kind': instance.$type,
};
VeilidUpdateValueChange instance,
) => <String, dynamic>{
'key': instance.key.toJson(),
'subkeys': instance.subkeys.map((e) => e.toJson()).toList(),
'count': instance.count,
'value': instance.value?.toJson(),
'kind': instance.$type,
};
_VeilidStateAttachment _$VeilidStateAttachmentFromJson(
Map<String, dynamic> json) =>
_VeilidStateAttachment(
state: AttachmentState.fromJson(json['state']),
publicInternetReady: json['public_internet_ready'] as bool,
localNetworkReady: json['local_network_ready'] as bool,
uptime: TimestampDuration.fromJson(json['uptime']),
attachedUptime: json['attached_uptime'] == null
? null
: TimestampDuration.fromJson(json['attached_uptime']),
);
Map<String, dynamic> json,
) => _VeilidStateAttachment(
state: AttachmentState.fromJson(json['state']),
publicInternetReady: json['public_internet_ready'] as bool,
localNetworkReady: json['local_network_ready'] as bool,
uptime: TimestampDuration.fromJson(json['uptime']),
attachedUptime: json['attached_uptime'] == null
? null
: TimestampDuration.fromJson(json['attached_uptime']),
);
Map<String, dynamic> _$VeilidStateAttachmentToJson(
_VeilidStateAttachment instance) =>
<String, dynamic>{
'state': instance.state.toJson(),
'public_internet_ready': instance.publicInternetReady,
'local_network_ready': instance.localNetworkReady,
'uptime': instance.uptime.toJson(),
'attached_uptime': instance.attachedUptime?.toJson(),
};
_VeilidStateAttachment instance,
) => <String, dynamic>{
'state': instance.state.toJson(),
'public_internet_ready': instance.publicInternetReady,
'local_network_ready': instance.localNetworkReady,
'uptime': instance.uptime.toJson(),
'attached_uptime': instance.attachedUptime?.toJson(),
};
_VeilidStateNetwork _$VeilidStateNetworkFromJson(Map<String, dynamic> json) =>
_VeilidStateNetwork(
started: json['started'] as bool,
bpsDown: BigInt.parse(json['bps_down'] as String),
bpsUp: BigInt.parse(json['bps_up'] as String),
peers:
(json['peers'] as List<dynamic>).map(PeerTableData.fromJson).toList(),
peers: (json['peers'] as List<dynamic>)
.map(PeerTableData.fromJson)
.toList(),
);
Map<String, dynamic> _$VeilidStateNetworkToJson(_VeilidStateNetwork instance) =>
@ -402,20 +407,16 @@ Map<String, dynamic> _$VeilidStateNetworkToJson(_VeilidStateNetwork instance) =>
};
_VeilidStateConfig _$VeilidStateConfigFromJson(Map<String, dynamic> json) =>
_VeilidStateConfig(
config: VeilidConfig.fromJson(json['config']),
);
_VeilidStateConfig(config: VeilidConfig.fromJson(json['config']));
Map<String, dynamic> _$VeilidStateConfigToJson(_VeilidStateConfig instance) =>
<String, dynamic>{
'config': instance.config.toJson(),
};
<String, dynamic>{'config': instance.config.toJson()};
_VeilidState _$VeilidStateFromJson(Map<String, dynamic> json) => _VeilidState(
attachment: VeilidStateAttachment.fromJson(json['attachment']),
network: VeilidStateNetwork.fromJson(json['network']),
config: VeilidStateConfig.fromJson(json['config']),
);
attachment: VeilidStateAttachment.fromJson(json['attachment']),
network: VeilidStateNetwork.fromJson(json['network']),
config: VeilidStateConfig.fromJson(json['config']),
);
Map<String, dynamic> _$VeilidStateToJson(_VeilidState instance) =>
<String, dynamic>{

View file

@ -12,7 +12,7 @@ abstract class VeilidTableDBTransaction {
Future<void> delete(int col, Uint8List key);
Future<void> storeJson(int col, Uint8List key, Object? object,
{Object? Function(Object? nonEncodable)? toEncodable}) async =>
{Object? Function(Object? nonEncodable)? toEncodable}) =>
store(col, key,
utf8.encoder.convert(jsonEncode(object, toEncodable: toEncodable)));

View file

@ -1,9 +1,7 @@
import 'package:veilid/veilid.dart';
class ProcessorConnectionState {
ProcessorConnectionState();
VeilidStateAttachment attachment = VeilidStateAttachment(
var attachment = VeilidStateAttachment(
localNetworkReady: false,
publicInternetReady: false,
state: AttachmentState.detached,
@ -11,9 +9,12 @@ class ProcessorConnectionState {
value: BigInt.zero,
),
attachedUptime: null);
VeilidStateNetwork network = VeilidStateNetwork(
var network = VeilidStateNetwork(
bpsDown: BigInt.zero, bpsUp: BigInt.zero, started: false, peers: []);
ProcessorConnectionState();
bool get isAttached => !(attachment.state == AttachmentState.detached ||
attachment.state == AttachmentState.detaching ||
attachment.state == AttachmentState.attaching);

View file

@ -9,14 +9,16 @@ abstract class TickerFixtureTickable {
}
class TickerFixture {
TickerFixture({required this.updateProcessorFixture});
static final _fixtureMutex = Mutex();
UpdateProcessorFixture updateProcessorFixture;
Timer? _tickTimer;
final List<TickerFixtureTickable> _tickables = [];
TickerFixture({required this.updateProcessorFixture});
Future<void> setUp() async {
await _fixtureMutex.acquire();
_tickTimer = Timer.periodic(const Duration(seconds: 1), (timer) {

View file

@ -7,13 +7,13 @@ import 'processor_connection_state.dart';
import 'veilid_fixture.dart';
class UpdateProcessorFixture {
UpdateProcessorFixture({required this.veilidFixture});
static final _fixtureMutex = Mutex();
VeilidFixture veilidFixture;
ProcessorConnectionState processorConnectionState =
ProcessorConnectionState();
final processorConnectionState = ProcessorConnectionState();
UpdateProcessorFixture({required this.veilidFixture});
Future<void> setUp() async {
await _fixtureMutex.acquire();

View file

@ -17,15 +17,18 @@ abstract class VeilidFixture {
}
class DefaultVeilidFixture implements VeilidFixture {
DefaultVeilidFixture({required this.programName});
StreamSubscription<VeilidUpdate>? _veilidUpdateSubscription;
Stream<VeilidUpdate>? _veilidUpdateStream;
late final StreamController<VeilidUpdate> _updateStreamController;
static final _fixtureMutex = Mutex();
final String programName;
DefaultVeilidFixture({required this.programName});
@override
Future<void> setUp() async {
await _fixtureMutex.acquire();

View file

@ -7,7 +7,7 @@ homepage: https://veilid.com
publish_to: "none" # Remove this line if you wish to publish to pub.dev
environment:
sdk: '>=3.0.0 <4.0.0'
sdk: '>=3.8.0 <4.0.0'
flutter: '>=3.19.1'
dependencies:
@ -20,7 +20,7 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
freezed_annotation: ^3.0.0
freezed_annotation: ^3.1.0
json_annotation: ^4.9.0
path: ^1.9.0
path_provider: ^2.1.3
@ -31,9 +31,9 @@ dev_dependencies:
build_runner: ^2.4.10
flutter_test:
sdk: flutter
freezed: ^3.0.4
freezed: ^3.2.0
json_serializable: ^6.8.0
lint_hard: ^6.0.0
lint_hard: ^6.2.1
test: ^1.25.15
# The following section is specific to Flutter.