From d0be23324bcf706f5a359236d2945944abbb40f8 Mon Sep 17 00:00:00 2001 From: nazeh Date: Sun, 22 Sep 2024 11:42:33 +0300 Subject: [PATCH] fix(pkarr): add rand in wasm target --- pkarr/Cargo.toml | 2 +- pkarr/README.md | 7 +++++++ pkarr/src/keys.rs | 2 -- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkarr/Cargo.toml b/pkarr/Cargo.toml index 7c07414..fb62494 100644 --- a/pkarr/Cargo.toml +++ b/pkarr/Cargo.toml @@ -19,6 +19,7 @@ tracing = "0.1.40" dyn-clone = "1.0.17" lru = { version = "0.12.3", default-features = false } serde = { version = "1.0.209", features = ["derive"], optional = true } +rand = { version = "0.8.5", optional = true } document-features = "0.2.8" @@ -27,7 +28,6 @@ document-features = "0.2.8" mainline = { version = "2.0.1", optional = true } flume = { version = "0.11.0", features = ["select", "eventual-fairness", "async"], default-features = false , optional = true } tokio = { version = "1.40.0", optional = true } -rand = { version = "0.8.5", optional = true } reqwest = { version = "0.12.7", features = ["rustls-tls"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/pkarr/README.md b/pkarr/README.md index 37ae8b3..e02292f 100644 --- a/pkarr/README.md +++ b/pkarr/README.md @@ -9,3 +9,10 @@ Publish and resolve DNS packets over Mainline DHT. ## Get started Check the [Examples](https://github.com/Nuhvi/pkarr/tree/main/pkarr/examples). + +## WebAssembly support + +This version of Pkarr assumes that you are running Wasm in a JavaScript environment, +and using the Relays clients, so you can't use it in Wasi for example, nor can you +use some Wasi bindings to use the DHT directly. If you really need Wasi support, please +open an issue on `https://git.pkarr.org`. diff --git a/pkarr/src/keys.rs b/pkarr/src/keys.rs index d86cd46..c1966a8 100644 --- a/pkarr/src/keys.rs +++ b/pkarr/src/keys.rs @@ -2,7 +2,6 @@ use crate::{Error, Result}; use ed25519_dalek::{SecretKey, Signature, Signer, SigningKey, Verifier, VerifyingKey}; -#[cfg(not(target_arch = "wasm32"))] #[cfg(feature = "rand")] use rand::rngs::OsRng; use std::{ @@ -18,7 +17,6 @@ use serde::{Deserialize, Serialize}; pub struct Keypair(SigningKey); impl Keypair { - #[cfg(not(target_arch = "wasm32"))] #[cfg(feature = "rand")] pub fn random() -> Keypair { let mut csprng = OsRng;