Compare commits

...

4 Commits

Author SHA1 Message Date
Dave Hrycyszyn 922941f2db Artificially locking the client to a specific gateway with the correct HTTPS setup 2022-09-23 17:06:58 +01:00
Dave Hrycyszyn f334acab99 Upgraded all tungstenite components so that wss connections work 2022-09-23 17:06:37 +01:00
Dave Hrycyszyn 001c98e544 Adding in a happy favicon 2022-09-23 17:03:57 +01:00
Dave Hrycyszyn d3eb238d5a Release of 1.0.0 - there was a duff 1.0.1 version published in my account 2022-09-15 16:09:31 +01:00
14 changed files with 142 additions and 46 deletions
Generated
+98 -23
View File
@@ -1128,7 +1128,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8"
dependencies = [
"sct",
"sct 0.6.1",
]
[[package]]
@@ -1954,8 +1954,8 @@ dependencies = [
"secp256k1",
"thiserror",
"tokio",
"tokio-tungstenite",
"tungstenite",
"tokio-tungstenite 0.17.2",
"tungstenite 0.17.3",
"url",
"validator-client",
"wasm-bindgen",
@@ -1980,7 +1980,7 @@ dependencies = [
"serde",
"serde_json",
"thiserror",
"tungstenite",
"tungstenite 0.17.3",
]
[[package]]
@@ -2380,7 +2380,7 @@ dependencies = [
"tokio",
"tokio-rustls",
"tower-service",
"webpki",
"webpki 0.21.4",
]
[[package]]
@@ -2393,12 +2393,12 @@ dependencies = [
"futures-util",
"hyper",
"log",
"rustls",
"rustls 0.19.1",
"rustls-native-certs",
"tokio",
"tokio-rustls",
"webpki",
"webpki-roots",
"webpki 0.21.4",
"webpki-roots 0.21.1",
]
[[package]]
@@ -3073,7 +3073,7 @@ dependencies = [
"serde_json",
"sled",
"tokio",
"tokio-tungstenite",
"tokio-tungstenite 0.17.2",
"topology",
"url",
"validator-client",
@@ -3120,7 +3120,7 @@ dependencies = [
"thiserror",
"tokio",
"tokio-stream",
"tokio-tungstenite",
"tokio-tungstenite 0.17.2",
"tokio-util 0.7.3",
"url",
"validator-api-requests",
@@ -3194,7 +3194,7 @@ dependencies = [
"statistics-common",
"thiserror",
"tokio",
"tokio-tungstenite",
"tokio-tungstenite 0.14.0",
"websocket-requests",
]
@@ -3211,7 +3211,7 @@ dependencies = [
"statistics-common",
"thiserror",
"tokio",
"tokio-tungstenite",
"tokio-tungstenite 0.14.0",
]
[[package]]
@@ -4714,8 +4714,20 @@ dependencies = [
"base64",
"log",
"ring",
"sct",
"webpki",
"sct 0.6.1",
"webpki 0.21.4",
]
[[package]]
name = "rustls"
version = "0.20.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033"
dependencies = [
"log",
"ring",
"sct 0.7.0",
"webpki 0.22.0",
]
[[package]]
@@ -4725,7 +4737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092"
dependencies = [
"openssl-probe",
"rustls",
"rustls 0.19.1",
"schannel",
"security-framework",
]
@@ -4817,6 +4829,16 @@ dependencies = [
"untrusted",
]
[[package]]
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "sec1"
version = "0.2.1"
@@ -5308,7 +5330,7 @@ dependencies = [
"once_cell",
"paste",
"percent-encoding",
"rustls",
"rustls 0.19.1",
"sha2 0.9.9",
"smallvec 1.8.0",
"sqlformat",
@@ -5317,8 +5339,8 @@ dependencies = [
"thiserror",
"tokio-stream",
"url",
"webpki",
"webpki-roots",
"webpki 0.21.4",
"webpki-roots 0.21.1",
]
[[package]]
@@ -5777,9 +5799,9 @@ version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
dependencies = [
"rustls",
"rustls 0.19.1",
"tokio",
"webpki",
"webpki 0.21.4",
]
[[package]]
@@ -5816,7 +5838,19 @@ dependencies = [
"log",
"pin-project",
"tokio",
"tungstenite",
"tungstenite 0.13.0",
]
[[package]]
name = "tokio-tungstenite"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181"
dependencies = [
"futures-util",
"log",
"tokio",
"tungstenite 0.17.3",
]
[[package]]
@@ -6084,6 +6118,28 @@ dependencies = [
"utf-8",
]
[[package]]
name = "tungstenite"
version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0"
dependencies = [
"base64",
"byteorder",
"bytes",
"http",
"httparse",
"log",
"rand 0.8.5",
"rustls 0.20.6",
"sha-1 0.10.0",
"thiserror",
"url",
"utf-8",
"webpki 0.22.0",
"webpki-roots 0.22.4",
]
[[package]]
name = "typenum"
version = "1.15.0"
@@ -6461,7 +6517,7 @@ version = "0.1.0"
dependencies = [
"futures",
"js-sys",
"tungstenite",
"tungstenite 0.17.3",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -6533,13 +6589,32 @@ dependencies = [
"untrusted",
]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940"
dependencies = [
"webpki",
"webpki 0.21.4",
]
[[package]]
name = "webpki-roots"
version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1c760f0d366a6c24a02ed7816e23e691f5d92291f94d15e836006fd11b04daf"
dependencies = [
"webpki 0.22.0",
]
[[package]]
+1 -1
View File
@@ -28,7 +28,7 @@ rand = { version = "0.7.3", features = ["wasm-bindgen"] } # rng-related traits +
serde = { version = "1.0.104", features = ["derive"] } # for config serialization/deserialization
sled = "0.34" # for storage of replySURB decryption keys
tokio = { version = "1.19.1", features = ["rt-multi-thread", "net", "signal"] } # async runtime
tokio-tungstenite = "0.14" # websocket
tokio-tungstenite = "0.17.2" # websocket
## internal
client-core = { path = "../client-core" }
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
name = "nym-client-wasm"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jedrzej Stuczynski <andrew@nymtech.net>"]
version = "1.0.1"
version = "1.0.0"
edition = "2021"
keywords = ["nym", "sphinx", "wasm", "webassembly", "privacy", "client"]
license = "Apache-2.0"
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

+16 -2
View File
@@ -211,7 +211,7 @@ impl NymClient {
self
}
pub(crate) fn choose_gateway(&self) -> &gateway::Node {
pub(crate) fn choose_gateway(&self) -> gateway::Node {
let topology = self
.topology
.as_ref()
@@ -219,7 +219,21 @@ impl NymClient {
// choose the first one available
assert!(!topology.gateways().is_empty());
topology.gateways().first().unwrap()
topology.gateways().first().unwrap();
console_log!("picking nym gateway");
gateway::Node {
owner: "n1kymvkx6vsq7pvn6hfurkpg06h3j4gxj4em7tlg".to_string(),
stake: 100000000,
location: "PRIVACY HQ".to_string(),
host: "gateway1.nymtech.net".parse().unwrap(),
mix_host: "213.219.38.119:1789".parse().unwrap(),
clients_port: 443,
identity_key: identity::PublicKey::from_base58_string("E3mvZTHQCdBvhfr178Swx9g4QG3kkRUun7YnToLMcMbM").unwrap(),
sphinx_key: encryption::PublicKey::from_base58_string("CYcrjoJ8GT7Dp54zViUyyRUfegeRCyPifWQZHRgMZrfX").unwrap(),
version: "1.0.0-rc.2".to_string()
}
}
// Right now it's impossible to have async exported functions to take `&mut self` rather than mut self
+3 -3
View File
@@ -30,8 +30,8 @@ network-defaults = { path = "../../network-defaults" }
validator-client = { path = "../validator-client", optional = true }
[dependencies.tungstenite]
version = "0.13"
default-features = false
version = "0.17.3"
features = ["rustls-tls-webpki-roots"]
# non-wasm-only dependencies
[target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio]
@@ -39,7 +39,7 @@ version = "1.19.1"
features = ["macros", "rt", "net", "sync", "time"]
[target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio-tungstenite]
version = "0.14"
version = "0.17.2"
[target."cfg(not(target_arch = \"wasm32\"))".dependencies.credential-storage]
path = "../../credential-storage"
@@ -30,7 +30,7 @@ use rand::rngs::OsRng;
use std::convert::TryFrom;
use std::sync::Arc;
use std::time::Duration;
use tungstenite::protocol::Message;
use tungstenite::Message;
#[cfg(not(target_arch = "wasm32"))]
use tokio_tungstenite::connect_async;
@@ -449,7 +449,7 @@ impl GatewayClient {
.derive_destination_address();
let encrypted_address = EncryptedAddressBytes::new(&self_address, shared_key, &iv);
let msg =
let msg: tungstenite::Message =
ClientControlRequest::new_authenticate(self_address, encrypted_address, iv).into();
match self.send_websocket_message(msg).await? {
@@ -733,6 +733,8 @@ impl GatewayClient {
}
pub async fn authenticate_and_start(&mut self) -> Result<Arc<SharedKeys>, GatewayClientError> {
println!("About to establish connection to {}", self.gateway_address);
if !self.connection.is_established() {
self.establish_connection().await?;
}
+1 -1
View File
@@ -89,7 +89,7 @@ impl Node {
}
pub fn clients_address(&self) -> String {
format!("ws://{}:{}", self.host, self.clients_port)
format!("wss://{}:{}", self.host, self.clients_port)
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ wasm-bindgen-futures = "0.4"
# we don't want entire tokio-tungstenite, tungstenite itself is just fine - we just want message and error enums
[dependencies.tungstenite]
version = "0.13"
version = "0.17.3"
default-features = false
[dependencies.web-sys]
+5
View File
@@ -85,6 +85,11 @@ pub struct JSWebsocket {
impl JSWebsocket {
pub fn new(url: &str) -> Result<Self, JsValue> {
console_log!(
"Attempting to establish wasm websocket connection to {}",
url
);
let ws = WebSocket::new(url)?;
// we don't want to ever have to deal with blobs
ws.set_binary_type(web_sys::BinaryType::Arraybuffer);
+1 -1
View File
@@ -33,7 +33,7 @@ subtle-encoding = { version = "0.5", features = ["bech32-preview"]}
thiserror = "1"
tokio = { version = "1.19.1", features = [ "rt-multi-thread", "net", "signal", "fs" ] }
tokio-stream = { version = "0.1.9", features = [ "fs" ] }
tokio-tungstenite = "0.14"
tokio-tungstenite = "0.17"
tokio-util = { version = "0.7.3", features = [ "codec" ] }
url = { version = "2.2", features = [ "serde" ] }
web3 = "0.17.0"
+1 -1
View File
@@ -29,6 +29,6 @@ credentials = { path = "../../common/credentials" }
coconut = ["coconut-interface", "credentials/coconut"]
[dependencies.tungstenite]
version = "0.13.0"
version = "0.17.3"
default-features = false
@@ -9,7 +9,8 @@ pub use self::shared_key::{SharedKeySize, SharedKeys};
use crypto::asymmetric::identity;
use futures::{Sink, Stream};
use rand::{CryptoRng, RngCore};
use tungstenite::{Error as WsError, Message as WsMessage};
use tungstenite::error::Error as WsError;
use tungstenite::protocol::Message as WsMessage;
pub(crate) type WsItem = Result<WsMessage, WsError>;
+8 -9
View File
@@ -18,7 +18,6 @@ use std::{
convert::{TryFrom, TryInto},
fmt::{self, Error, Formatter},
};
use tungstenite::protocol::Message;
#[cfg(feature = "coconut")]
use coconut_interface::Credential;
@@ -192,12 +191,12 @@ impl ClientControlRequest {
}
}
impl From<ClientControlRequest> for Message {
impl From<ClientControlRequest> for tungstenite::Message {
fn from(req: ClientControlRequest) -> Self {
// it should be safe to call `unwrap` here as the message is generated by the server
// so if it fails (and consequently panics) it's a bug that should be resolved
let str_req = serde_json::to_string(&req).unwrap();
Message::Text(str_req)
tungstenite::Message::Text(str_req)
}
}
@@ -258,12 +257,12 @@ impl ServerResponse {
}
}
impl From<ServerResponse> for Message {
impl From<ServerResponse> for tungstenite::Message {
fn from(res: ServerResponse) -> Self {
// it should be safe to call `unwrap` here as the message is generated by the server
// so if it fails (and consequently panics) it's a bug that should be resolved
let str_res = serde_json::to_string(&res).unwrap();
Message::Text(str_res)
tungstenite::Message::Text(str_res)
}
}
@@ -314,8 +313,8 @@ impl BinaryRequest {
BinaryRequest::ForwardSphinx(mix_packet)
}
pub fn into_ws_message(self, shared_key: &SharedKeys) -> Message {
Message::Binary(self.into_encrypted_tagged_bytes(shared_key))
pub fn into_ws_message(self, shared_key: &SharedKeys) -> tungstenite::Message {
tungstenite::Message::Binary(self.into_encrypted_tagged_bytes(shared_key))
}
}
@@ -367,8 +366,8 @@ impl BinaryResponse {
BinaryResponse::PushedMixMessage(msg)
}
pub fn into_ws_message(self, shared_key: &SharedKeys) -> Message {
Message::Binary(self.into_encrypted_tagged_bytes(shared_key))
pub fn into_ws_message(self, shared_key: &SharedKeys) -> tungstenite::Message {
tungstenite::Message::Binary(self.into_encrypted_tagged_bytes(shared_key))
}
}