diff --git a/Cargo.lock b/Cargo.lock index 9b540043..a10ae32f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,7 +78,7 @@ name = "alias" version = "0.1.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -1012,7 +1012,7 @@ dependencies = [ "alloy-sol-types", "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "rand 0.8.5", "serde", @@ -1383,7 +1383,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "url", @@ -1592,7 +1592,7 @@ name = "cat" version = "0.1.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -1656,7 +1656,7 @@ dependencies = [ "alloy-sol-types", "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "rand 0.8.5", "serde", @@ -1675,7 +1675,7 @@ version = "0.2.1" dependencies = [ "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "pleco", "serde", "serde_json", @@ -1863,6 +1863,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +[[package]] +name = "contacts" +version = "0.1.0" +dependencies = [ + "kinode_process_lib 0.9.4 (git+https://github.com/kinode-dao/process_lib?rev=088a549)", + "process_macros", + "serde", + "serde_json", + "wit-bindgen", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -2433,7 +2444,7 @@ name = "download" version = "0.1.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "serde", "serde_json", @@ -2445,7 +2456,7 @@ name = "downloads" version = "0.5.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "rand 0.8.5", "serde", @@ -2482,7 +2493,7 @@ dependencies = [ name = "echo" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "wit-bindgen", ] @@ -2721,7 +2732,7 @@ version = "0.2.0" dependencies = [ "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "rand 0.8.5", "serde", @@ -2875,7 +2886,7 @@ dependencies = [ name = "get_block" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -2940,7 +2951,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" name = "globe" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "url", @@ -3067,7 +3078,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" name = "help" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "wit-bindgen", ] @@ -3096,7 +3107,7 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" name = "hi" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -3129,7 +3140,7 @@ version = "0.1.1" dependencies = [ "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -3444,7 +3455,7 @@ name = "install" version = "0.1.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "serde", "serde_json", @@ -3621,7 +3632,7 @@ name = "kfetch" version = "0.1.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde", "serde", "serde_json", @@ -3633,7 +3644,7 @@ name = "kill" version = "0.1.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -3706,9 +3717,8 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +version = "0.9.2" +source = "git+https://github.com/kinode-dao/process_lib.git?rev=9ac9e51#9ac9e513c0228f2dcfe8999ed4ca2c38246ee3db" dependencies = [ "alloy 0.1.4", "alloy-primitives", @@ -3729,8 +3739,31 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.2" -source = "git+https://github.com/kinode-dao/process_lib.git?rev=9ac9e51#9ac9e513c0228f2dcfe8999ed4ca2c38246ee3db" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" +dependencies = [ + "alloy 0.1.4", + "alloy-primitives", + "alloy-sol-macro", + "alloy-sol-types", + "anyhow", + "bincode", + "http 1.1.0", + "mime_guess", + "rand 0.8.5", + "rmp-serde", + "serde", + "serde_json", + "thiserror", + "url", + "wit-bindgen", +] + +[[package]] +name = "kinode_process_lib" +version = "0.9.4" +source = "git+https://github.com/kinode-dao/process_lib?rev=088a549#088a5497257eada697e0869d6a8d7e9ef5e620f6" dependencies = [ "alloy 0.1.4", "alloy-primitives", @@ -3794,7 +3827,7 @@ dependencies = [ "alloy-sol-types", "anyhow", "hex", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde", "serde", "serde_json", @@ -4023,7 +4056,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex", "serde", "serde_json", @@ -4193,7 +4226,7 @@ dependencies = [ name = "net_diagnostics" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde", "serde", "wit-bindgen", @@ -4519,7 +4552,7 @@ dependencies = [ name = "peer" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde", "serde", "wit-bindgen", @@ -4529,7 +4562,7 @@ dependencies = [ name = "peers" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde", "serde", "wit-bindgen", @@ -5570,7 +5603,7 @@ dependencies = [ "anyhow", "base64 0.22.1", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde", "serde", "serde_json", @@ -5788,7 +5821,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" name = "state" version = "0.1.0" dependencies = [ - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -5965,7 +5998,7 @@ version = "0.1.1" dependencies = [ "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.8.5", "regex", "serde", @@ -5979,7 +6012,7 @@ version = "0.1.1" dependencies = [ "anyhow", "bincode", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "serde", "serde_json", @@ -6236,7 +6269,7 @@ version = "0.2.0" dependencies = [ "anyhow", "clap", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "wit-bindgen", @@ -6567,7 +6600,7 @@ name = "uninstall" version = "0.1.0" dependencies = [ "anyhow", - "kinode_process_lib 0.9.1", + "kinode_process_lib 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_macros", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index f6660743..ec72600a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ members = [ "kinode/packages/app_store/app_store", "kinode/packages/app_store/ft_worker", "kinode/packages/app_store/download", "kinode/packages/app_store/install", "kinode/packages/app_store/uninstall", "kinode/packages/app_store/downloads", "kinode/packages/app_store/chain", "kinode/packages/chess/chess", + "kinode/packages/contacts/contacts", "kinode/packages/homepage/homepage", "kinode/packages/kino_updates/blog", "kinode/packages/kino_updates/globe", "kinode/packages/kns_indexer/kns_indexer", "kinode/packages/kns_indexer/get_block", "kinode/packages/kns_indexer/state", diff --git a/README.md b/README.md index c86f767b..d4b1fc2b 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ The distro userspace packages are: - `app_store:sys` - `chess:sys` +- `contacts:sys` - `homepage:sys` - `kino_updates:sys` - `kns_indexer:sys` diff --git a/kinode/packages/app_store/Cargo.lock b/kinode/packages/app_store/Cargo.lock index 1d1104c2..3d930d14 100644 --- a/kinode/packages/app_store/Cargo.lock +++ b/kinode/packages/app_store/Cargo.lock @@ -1617,9 +1617,9 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/app_store/app_store/Cargo.toml b/kinode/packages/app_store/app_store/Cargo.toml index 68618698..717aa4aa 100644 --- a/kinode/packages/app_store/app_store/Cargo.toml +++ b/kinode/packages/app_store/app_store/Cargo.toml @@ -11,7 +11,7 @@ alloy-primitives = "0.7.6" alloy-sol-types = "0.7.6" anyhow = "1.0" bincode = "1.3.3" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" process_macros = { git = "https://github.com/kinode-dao/process_macros", rev = "626e501" } rand = "0.8" serde = { version = "1.0", features = ["derive"] } diff --git a/kinode/packages/app_store/app_store/src/http_api.rs b/kinode/packages/app_store/app_store/src/http_api.rs index 3788d737..804d7175 100644 --- a/kinode/packages/app_store/app_store/src/http_api.rs +++ b/kinode/packages/app_store/app_store/src/http_api.rs @@ -9,7 +9,6 @@ use crate::{ }, state::{MirrorCheck, PackageState, State}, }; - use kinode_process_lib::{ http::{self, server, Method, StatusCode}, println, Address, LazyLoadBlob, PackageId, Request, SendError, SendErrorKind, @@ -22,7 +21,7 @@ const ICON: &str = include_str!("icon"); /// Bind static and dynamic HTTP paths for the app store, /// bind to our WS updates path, and add icon and widget to homepage. pub fn init_frontend(our: &Address, http_server: &mut server::HttpServer) { - let config = server::HttpBindingConfig::default(); + let config = server::HttpBindingConfig::default().secure_subdomain(true); for path in [ "/apps", // all on-chain apps @@ -44,12 +43,19 @@ pub fn init_frontend(our: &Address, http_server: &mut server::HttpServer) { .bind_http_path(path, config.clone()) .expect("failed to bind http path"); } + + // bind /apps path at base domain, in addition to secure subdomain, + // so that widget can access it + http_server + .bind_http_path("/apps-public", config.clone().secure_subdomain(false)) + .expect("failed to bind http path"); + http_server .serve_ui(&our, "ui", vec!["/"], config.clone()) .expect("failed to serve static UI"); http_server - .bind_ws_path("/", server::WsBindingConfig::default()) + .secure_bind_ws_path("/") .expect("failed to bind ws path"); // add ourselves to the homepage @@ -136,7 +142,7 @@ fn make_widget() -> String { + + + + + + + +

contacts

+
+
+
+
+ + +
+
+ +
+ +
+ + +
+ + + \ No newline at end of file diff --git a/kinode/packages/contacts/pkg/ui/script.js b/kinode/packages/contacts/pkg/ui/script.js new file mode 100644 index 00000000..153ff50a --- /dev/null +++ b/kinode/packages/contacts/pkg/ui/script.js @@ -0,0 +1,132 @@ +const APP_PATH = '/contacts:contacts:sys/ask'; + +function api_call(body) { + fetch(APP_PATH, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(body), + }); +} + +function populate(data) { + console.log(data); + populate_contacts(data); +} + +function populate_contacts(contacts) { + const ul = document.getElementById('contacts'); + ul.innerHTML = ''; + // sort contacts alphabetically by node + Object.entries(contacts).sort((a, b) => a[0].localeCompare(b[0])).forEach(([node, contact]) => { + const li = document.createElement('li'); + const div = document.createElement('div'); + div.classList.add('contact'); + div.innerHTML = `

${node}

+ +
+ +
+
+ + + +
+ `; + li.appendChild(div); + ul.appendChild(li); + }); + + ul.querySelectorAll('.delete-contact').forEach(form => { + form.addEventListener('submit', function (e) { + e.preventDefault(); + const node = this.getAttribute('id'); + api_call({ + "RemoveContact": node + }); + }); + }); + + ul.querySelectorAll('.add-field').forEach(form => { + form.addEventListener('submit', function (e) { + e.preventDefault(); + const node = this.getAttribute('id'); + const data = new FormData(e.target); + let value = data.get('value'); + // if value is not valid JSON, wrap it in quotes + try { + JSON.parse(value); + } catch (e) { + // If parsing fails, assume it's a string and wrap it in quotes + value = `"${value}"`; + } + api_call({ + "AddField": [node, data.get('field'), value] + }); + }); + }); +} + +document.getElementById('back-button').addEventListener('click', () => { + // set page to `/` while also removing the subdomain + const url = new URL(window.location.href); + if (url.hostname.split('.')[0] === 'contacts-sys') { + url.hostname = url.hostname.split('.').slice(1).join('.'); + } + url.pathname = '/'; + window.location.href = url.toString(); +}); + +document.getElementById('add-contact').addEventListener('submit', (e) => { + e.preventDefault(); + const data = new FormData(e.target); + const node = data.get('node'); + const body = { + "AddContact": node + }; + fetch(APP_PATH, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(body), + }).then(response => { + e.target.reset(); + if (response.status === 200) { + return null; + } else { + return response.json(); + } + }).then(data => { + if (data === null) { + return; + } else { + alert(JSON.stringify(data)); + } + }).catch(error => { + console.error('Error:', error); + }); +}) + +function removeField(node, field) { + api_call({ + "RemoveField": [node, field] + }); +} + +// Setup WebSocket connection +const wsProtocol = location.protocol === 'https:' ? 'wss://' : 'ws://'; +const ws = new WebSocket(wsProtocol + location.host + "/contacts:contacts:sys/"); +ws.onmessage = event => { + const data = JSON.parse(event.data); + populate(data); +}; + diff --git a/kinode/packages/homepage/Cargo.lock b/kinode/packages/homepage/Cargo.lock index 10eaa344..03715fc6 100644 --- a/kinode/packages/homepage/Cargo.lock +++ b/kinode/packages/homepage/Cargo.lock @@ -1464,9 +1464,9 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/homepage/homepage/Cargo.toml b/kinode/packages/homepage/homepage/Cargo.toml index 65a6cd84..29945d47 100644 --- a/kinode/packages/homepage/homepage/Cargo.toml +++ b/kinode/packages/homepage/homepage/Cargo.toml @@ -9,7 +9,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" bincode = "1.3.3" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/kino_updates/Cargo.lock b/kinode/packages/kino_updates/Cargo.lock index 2b1368c7..d7ef3a68 100644 --- a/kinode/packages/kino_updates/Cargo.lock +++ b/kinode/packages/kino_updates/Cargo.lock @@ -1476,9 +1476,9 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/kino_updates/blog/Cargo.toml b/kinode/packages/kino_updates/blog/Cargo.toml index 44c22568..c71a8418 100644 --- a/kinode/packages/kino_updates/blog/Cargo.toml +++ b/kinode/packages/kino_updates/blog/Cargo.toml @@ -9,7 +9,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" bincode = "1.3.3" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" url = "2.5.0" diff --git a/kinode/packages/kino_updates/globe/Cargo.toml b/kinode/packages/kino_updates/globe/Cargo.toml index b3fbd6da..ce9e9c94 100644 --- a/kinode/packages/kino_updates/globe/Cargo.toml +++ b/kinode/packages/kino_updates/globe/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" url = "2.5.0" diff --git a/kinode/packages/kns_indexer/Cargo.lock b/kinode/packages/kns_indexer/Cargo.lock index e247a634..ac88fe79 100644 --- a/kinode/packages/kns_indexer/Cargo.lock +++ b/kinode/packages/kns_indexer/Cargo.lock @@ -1462,9 +1462,9 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/kns_indexer/get_block/Cargo.toml b/kinode/packages/kns_indexer/get_block/Cargo.toml index 14f3fbd5..351d48f6 100644 --- a/kinode/packages/kns_indexer/get_block/Cargo.toml +++ b/kinode/packages/kns_indexer/get_block/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/kns_indexer/kns_indexer/Cargo.toml b/kinode/packages/kns_indexer/kns_indexer/Cargo.toml index ee5e5a27..4a6b3cbe 100644 --- a/kinode/packages/kns_indexer/kns_indexer/Cargo.toml +++ b/kinode/packages/kns_indexer/kns_indexer/Cargo.toml @@ -11,7 +11,7 @@ anyhow = "1.0" alloy-primitives = "0.7.0" alloy-sol-types = "0.7.0" hex = "0.4.3" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" rmp-serde = "1.1.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/packages/kns_indexer/state/Cargo.toml b/kinode/packages/kns_indexer/state/Cargo.toml index 81a0c301..3299252d 100644 --- a/kinode/packages/kns_indexer/state/Cargo.toml +++ b/kinode/packages/kns_indexer/state/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/settings/Cargo.lock b/kinode/packages/settings/Cargo.lock index 8c57f800..5bbb9200 100644 --- a/kinode/packages/settings/Cargo.lock +++ b/kinode/packages/settings/Cargo.lock @@ -1452,9 +1452,9 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/settings/settings/Cargo.toml b/kinode/packages/settings/settings/Cargo.toml index b3bfdb8d..e942a927 100644 --- a/kinode/packages/settings/settings/Cargo.toml +++ b/kinode/packages/settings/settings/Cargo.toml @@ -10,7 +10,7 @@ simulation-mode = [] anyhow = "1.0" base64 = "0.22.0" bincode = "1.3.3" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" rmp-serde = "1.2.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/packages/terminal/Cargo.lock b/kinode/packages/terminal/Cargo.lock index 2e4bcbe6..d1037071 100644 --- a/kinode/packages/terminal/Cargo.lock +++ b/kinode/packages/terminal/Cargo.lock @@ -1620,9 +1620,9 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/terminal/alias/Cargo.toml b/kinode/packages/terminal/alias/Cargo.toml index e1858722..ea1a618b 100644 --- a/kinode/packages/terminal/alias/Cargo.toml +++ b/kinode/packages/terminal/alias/Cargo.toml @@ -8,7 +8,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/terminal/cat/Cargo.toml b/kinode/packages/terminal/cat/Cargo.toml index 217c41d4..2b26f7b1 100644 --- a/kinode/packages/terminal/cat/Cargo.toml +++ b/kinode/packages/terminal/cat/Cargo.toml @@ -8,7 +8,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/terminal/echo/Cargo.toml b/kinode/packages/terminal/echo/Cargo.toml index d558bc42..4aab7640 100644 --- a/kinode/packages/terminal/echo/Cargo.toml +++ b/kinode/packages/terminal/echo/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" wit-bindgen = "0.24.0" [lib] diff --git a/kinode/packages/terminal/help/Cargo.toml b/kinode/packages/terminal/help/Cargo.toml index 4bb23c00..04deffb1 100644 --- a/kinode/packages/terminal/help/Cargo.toml +++ b/kinode/packages/terminal/help/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" wit-bindgen = "0.24.0" [lib] diff --git a/kinode/packages/terminal/hi/Cargo.toml b/kinode/packages/terminal/hi/Cargo.toml index 9a888b2b..b3980ef5 100644 --- a/kinode/packages/terminal/hi/Cargo.toml +++ b/kinode/packages/terminal/hi/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/terminal/kfetch/Cargo.toml b/kinode/packages/terminal/kfetch/Cargo.toml index de4900d8..80776601 100644 --- a/kinode/packages/terminal/kfetch/Cargo.toml +++ b/kinode/packages/terminal/kfetch/Cargo.toml @@ -8,7 +8,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" rmp-serde = "1.1.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/packages/terminal/kill/Cargo.toml b/kinode/packages/terminal/kill/Cargo.toml index 5ea1df88..c6f24ee9 100644 --- a/kinode/packages/terminal/kill/Cargo.toml +++ b/kinode/packages/terminal/kill/Cargo.toml @@ -8,7 +8,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/terminal/m/Cargo.toml b/kinode/packages/terminal/m/Cargo.toml index c57ea76a..c7da8d44 100644 --- a/kinode/packages/terminal/m/Cargo.toml +++ b/kinode/packages/terminal/m/Cargo.toml @@ -9,7 +9,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" clap = "4.4" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" regex = "1.10.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/packages/terminal/net_diagnostics/Cargo.toml b/kinode/packages/terminal/net_diagnostics/Cargo.toml index 302f5976..1d0c2a39 100644 --- a/kinode/packages/terminal/net_diagnostics/Cargo.toml +++ b/kinode/packages/terminal/net_diagnostics/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" rmp-serde = "1.1.2" serde = { version = "1.0", features = ["derive"] } wit-bindgen = "0.24.0" diff --git a/kinode/packages/terminal/peer/Cargo.toml b/kinode/packages/terminal/peer/Cargo.toml index a4e3da0b..1727c377 100644 --- a/kinode/packages/terminal/peer/Cargo.toml +++ b/kinode/packages/terminal/peer/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" rmp-serde = "1.1.2" serde = { version = "1.0", features = ["derive"] } wit-bindgen = "0.24.0" diff --git a/kinode/packages/terminal/peers/Cargo.toml b/kinode/packages/terminal/peers/Cargo.toml index 68167a7a..c6e0e095 100644 --- a/kinode/packages/terminal/peers/Cargo.toml +++ b/kinode/packages/terminal/peers/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" simulation-mode = [] [dependencies] -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" rmp-serde = "1.1.2" serde = { version = "1.0", features = ["derive"] } wit-bindgen = "0.24.0" diff --git a/kinode/packages/terminal/pkg/manifest.json b/kinode/packages/terminal/pkg/manifest.json index 918314c4..b87e4aaa 100644 --- a/kinode/packages/terminal/pkg/manifest.json +++ b/kinode/packages/terminal/pkg/manifest.json @@ -5,6 +5,8 @@ "on_exit": "Restart", "request_networking": true, "request_capabilities": [ + "app_store:app_store:sys", + "contacts:contacts:sys", "chess:chess:sys", "eth:distro:sys", { diff --git a/kinode/packages/terminal/terminal/Cargo.toml b/kinode/packages/terminal/terminal/Cargo.toml index 44be523c..87699f35 100644 --- a/kinode/packages/terminal/terminal/Cargo.toml +++ b/kinode/packages/terminal/terminal/Cargo.toml @@ -9,7 +9,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" bincode = "1.3.3" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" rand = "0.8" regex = "1.10.3" serde = { version = "1.0", features = ["derive"] } diff --git a/kinode/packages/terminal/top/Cargo.toml b/kinode/packages/terminal/top/Cargo.toml index 737d1c17..818c9b08 100644 --- a/kinode/packages/terminal/top/Cargo.toml +++ b/kinode/packages/terminal/top/Cargo.toml @@ -9,7 +9,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" clap = "4.4" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.24.0" diff --git a/kinode/packages/tester/Cargo.lock b/kinode/packages/tester/Cargo.lock index f015a76e..7bb8a6f6 100644 --- a/kinode/packages/tester/Cargo.lock +++ b/kinode/packages/tester/Cargo.lock @@ -1452,9 +1452,9 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c5b69ac1fc0cb457c7714ceb8c0a5bdbee4ee00b837f9f16ea711e902bdfe8" +checksum = "c257733fdc158b8223e43d92baeac02fe3d6a06b62953dbaea36e989f861b138" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/tester/tester/Cargo.toml b/kinode/packages/tester/tester/Cargo.toml index ef50587a..8937be61 100644 --- a/kinode/packages/tester/tester/Cargo.toml +++ b/kinode/packages/tester/tester/Cargo.toml @@ -9,7 +9,7 @@ simulation-mode = [] [dependencies] anyhow = "1.0" bincode = "1.3.3" -kinode_process_lib = "0.9.1" +kinode_process_lib = "0.9.4" process_macros = { git = "https://github.com/kinode-dao/process_macros", rev = "626e501" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/src/http/login.html b/kinode/src/http/login.html index 6d197345..afcff2ef 100644 --- a/kinode/src/http/login.html +++ b/kinode/src/http/login.html @@ -231,7 +231,18 @@ } }); }); + + // Check for redirect parameter on page load + document.addEventListener("DOMContentLoaded", () => { + const urlParams = new URLSearchParams(window.location.search); + const redirectPath = urlParams.get('redirect'); + if (redirectPath) { + // Ensure the redirect path starts with a slash + const path = redirectPath.startsWith('/') ? redirectPath : '/' + redirectPath; + window.location.href = path; + } + }); - + \ No newline at end of file diff --git a/kinode/src/kernel/mod.rs b/kinode/src/kernel/mod.rs index bc9ee827..79a28ff3 100644 --- a/kinode/src/kernel/mod.rs +++ b/kinode/src/kernel/mod.rs @@ -798,7 +798,7 @@ pub async fn kernel( // networking capabilities. let Some(persisted) = process_map.get(&kernel_message.target.process) else { t::Printout::new( - 0, + 2, format!( "event loop: got {} from network for {}, but process does not exist{}", match kernel_message.message { diff --git a/kinode/src/register-ui/src/App.tsx b/kinode/src/register-ui/src/App.tsx index 7f923270..09ddfcdc 100644 --- a/kinode/src/register-ui/src/App.tsx +++ b/kinode/src/register-ui/src/App.tsx @@ -21,7 +21,6 @@ function App() { const [reset, setReset] = useState(false); const [direct, setDirect] = useState(false); const [knsName, setKnsName] = useState(''); - const [appSizeOnLoad, setAppSizeOnLoad] = useState(0); const [networkingKey, setNetworkingKey] = useState(''); const [ipAddress, setIpAddress] = useState(0); const [ws_port, setWsPort] = useState(0); @@ -36,10 +35,6 @@ function App() { const openConnect = () => setConnectOpen(true) const closeConnect = () => setConnectOpen(false) - useEffect(() => setAppSizeOnLoad( - (window.performance.getEntriesByType('navigation') as any)[0].transferSize - ), []); - useEffect(() => { (async () => { try { @@ -84,7 +79,7 @@ function App() { // todo, most of these can be removed... const props = { direct, setDirect, - key, appSizeOnLoad, + key, keyFileName, setKeyFileName, reset, setReset, pw, setPw, diff --git a/kinode/src/register-ui/src/lib/types.ts b/kinode/src/register-ui/src/lib/types.ts index 9588d83d..1f84ffc9 100644 --- a/kinode/src/register-ui/src/lib/types.ts +++ b/kinode/src/register-ui/src/lib/types.ts @@ -21,7 +21,6 @@ export interface PageProps { setReset: React.Dispatch>, pw: string, setPw: React.Dispatch>, - appSizeOnLoad: number, nodeChainId: string, } diff --git a/kinode/src/register-ui/src/pages/ImportKeyfile.tsx b/kinode/src/register-ui/src/pages/ImportKeyfile.tsx index 07d53ab8..735cccbb 100644 --- a/kinode/src/register-ui/src/pages/ImportKeyfile.tsx +++ b/kinode/src/register-ui/src/pages/ImportKeyfile.tsx @@ -7,13 +7,13 @@ import { import { PageProps } from "../lib/types"; import Loader from "../components/Loader"; import { sha256, toBytes } from "viem"; +import { redirectToHomepage } from "../utils/redirect-to-homepage"; interface ImportKeyfileProps extends PageProps { } function ImportKeyfile({ pw, setPw, - appSizeOnLoad, }: ImportKeyfileProps) { const [localKey, setLocalKey] = useState(null); @@ -70,24 +70,15 @@ function ImportKeyfile({ if (result.status > 399) { throw new Error("Incorrect password"); } + redirectToHomepage(); - const interval = setInterval(async () => { - const res = await fetch("/", { credentials: 'include' }); - if ( - res.status < 300 && - Number(res.headers.get("content-length")) !== appSizeOnLoad - ) { - clearInterval(interval); - window.location.replace("/"); - } - }, 2000); } } catch { window.alert("An error occurred, please try again."); setLoading(false); } }, - [localKey, pw, keyErrs, appSizeOnLoad] + [localKey, pw, keyErrs] ); return ( diff --git a/kinode/src/register-ui/src/pages/Login.tsx b/kinode/src/register-ui/src/pages/Login.tsx index f8a22c8d..5d7f24df 100644 --- a/kinode/src/register-ui/src/pages/Login.tsx +++ b/kinode/src/register-ui/src/pages/Login.tsx @@ -4,13 +4,13 @@ import Loader from "../components/Loader"; import { useNavigate } from "react-router-dom"; import { sha256, toBytes } from "viem"; import { Tooltip } from "../components/Tooltip"; +import { redirectToHomepage } from "../utils/redirect-to-homepage"; interface LoginProps extends PageProps { } function Login({ pw, setPw, - appSizeOnLoad, routers, setRouters, knsName, @@ -57,23 +57,14 @@ function Login({ if (result.status > 399) { throw new Error(await result.text()); } + redirectToHomepage(); - const interval = setInterval(async () => { - const res = await fetch("/", { credentials: 'include' }); - if ( - res.status < 300 && - Number(res.headers.get("content-length")) !== appSizeOnLoad - ) { - clearInterval(interval); - window.location.replace("/"); - } - }, 2000); } catch (err: any) { setKeyErrs([String(err)]); setLoading(""); } }, - [pw, appSizeOnLoad] + [pw] ); const isDirect = Boolean(routers?.length === 0); diff --git a/kinode/src/register-ui/src/pages/SetPassword.tsx b/kinode/src/register-ui/src/pages/SetPassword.tsx index 879d26e9..d86ae419 100644 --- a/kinode/src/register-ui/src/pages/SetPassword.tsx +++ b/kinode/src/register-ui/src/pages/SetPassword.tsx @@ -5,6 +5,7 @@ import { Tooltip } from "../components/Tooltip"; import { sha256, toBytes } from "viem"; import { useSignTypedData, useAccount, useChainId } from 'wagmi' import { KIMAP } from "../abis"; +import { redirectToHomepage } from "../utils/redirect-to-homepage"; type SetPasswordProps = { direct: boolean; @@ -12,7 +13,6 @@ type SetPasswordProps = { reset: boolean; knsName: string; setPw: React.Dispatch>; - appSizeOnLoad: number; nodeChainId: string; closeConnect: () => void; }; @@ -23,7 +23,6 @@ function SetPassword({ pw, reset, setPw, - appSizeOnLoad, }: SetPasswordProps) { const [pw2, setPw2] = useState(""); const [error, setError] = useState(""); @@ -103,25 +102,15 @@ function SetPassword({ const base64String = await result.json(); downloadKeyfile(knsName, base64String); + redirectToHomepage(); - const interval = setInterval(async () => { - const res = await fetch("/", { credentials: 'include' }); - - if ( - res.status < 300 && - Number(res.headers.get("content-length")) !== appSizeOnLoad - ) { - clearInterval(interval); - window.location.replace("/"); - } - }, 2000); } catch { alert("There was an error setting your password, please try again."); setLoading(false); } }, 500); }, - [appSizeOnLoad, direct, pw, pw2, reset, knsName] + [direct, pw, pw2, reset, knsName] ); return ( diff --git a/kinode/src/register-ui/src/utils/redirect-to-homepage.ts b/kinode/src/register-ui/src/utils/redirect-to-homepage.ts new file mode 100644 index 00000000..274a1e85 --- /dev/null +++ b/kinode/src/register-ui/src/utils/redirect-to-homepage.ts @@ -0,0 +1,9 @@ +export const redirectToHomepage = () => { + const interval = setInterval(async () => { + const res = await fetch("/version", { credentials: 'include' }); + if (res.status == 200) { + clearInterval(interval); + window.location.replace("/"); + } + }, 500); +}; \ No newline at end of file