Skip to content

Commit

Permalink
Fix WASM compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothee-haudebourg committed Mar 25, 2024
1 parent 026a4f9 commit 7040d7d
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 28 deletions.
4 changes: 4 additions & 0 deletions crates/caips/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ documentation = "https://docs.rs/ssi-caips/"
default = ["eip", "ripemd-160", "ssi-jwk/secp256k1"]
eip = ["ssi-jwk/eip"]
ripemd-160 = ["ssi-jwk/ripemd-160"]

## Enable aleo accounts.
##
## Not compatible with WASM targets.
aleo = ["ssi-jwk/aleo", "bech32"]
tezos = ["ssi-jwk/tezos"]

Expand Down
2 changes: 1 addition & 1 deletion crates/claims/crates/jwt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ serde_with = "2.3.2"
chrono = { version = "0.4", features = ["serde"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
chrono = { version = "0.4", features = ["serde", "wasmbind"] }
chrono = { version = "0.4", features = ["serde", "wasmbind"] }
4 changes: 4 additions & 0 deletions crates/claims/crates/vc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ ssi-verification-methods.workspace = true
ssi-dids-core.workspace = true
ssi-data-integrity.workspace = true

[target.'cfg(target_os = "android")'.dependencies.reqwest]
version = "0.11"
features = ["json", "native-tls-vendored"]

[dev-dependencies]
ssi-verification-methods.workspace = true
ssi-jwk.workspace = true
Expand Down
8 changes: 6 additions & 2 deletions crates/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ documentation = "https://docs.rs/ssi-crypto/"

[features]
default = ["secp256k1", "ripemd-160"]
secp256k1 = ["k256", "keccak"]
bbs = ["dep:bbs", "pairing-plus", "rand_old", "sha2_old", "hkdf", "serde"]
secp256k1 = ["k256", "getrandom", "keccak"]
bbs = ["dep:bbs", "pairing-plus", "rand_old", "getrandom", "sha2_old", "hkdf", "serde"]
ripemd-160 = ["ripemd160", "secp256k1"]
keccak = ["keccak-hash"]
ring = ["dep:ring"]
Expand All @@ -24,6 +24,7 @@ k256 = { workspace = true, optional = true, features = ["ecdsa"] }
p256 = { workspace = true, optional = true, features = ["ecdsa"] }
hkdf = { version = "0.8", optional = true }
rand_old = { package = "rand", version = "0.7", optional = true }
getrandom = { version = "0.2", optional = true } # Required for wasm targets.
sha2_old = { package = "sha2", version = "0.8", optional = true }
keccak-hash = { version = "0.7", optional = true }
ed25519-dalek = { workspace = true, optional = true }
Expand All @@ -41,6 +42,9 @@ multibase.workspace = true
pin-project.workspace = true
hex.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"], optional = true }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
8 changes: 3 additions & 5 deletions crates/dids/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ ssi-jwk.workspace = true
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"], optional = true }
percent-encoding = { version = "2.1", optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
chrono = { version = "0.4", features = ["serde"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
chrono = { version = "0.4", features = ["serde", "wasmbind"] }
[target.'cfg(target_os = "android")'.dependencies.reqwest]
version = "0.11"
features = ["json", "native-tls-vendored"]

[dev-dependencies]
async-std = { version = "1.9", features = ["attributes"] }
Expand Down
15 changes: 9 additions & 6 deletions crates/dids/methods/ion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ documentation = "https://docs.rs/did-ion/"
[dependencies]
ssi-verification-methods.workspace = true
ssi-dids-core = { workspace = true, features = ["http"] }
ssi-jwk.workspace = true
ssi-jwk = { workspace = true, features = ["secp256k1"] }
ssi-jws.workspace = true
ssi-jwt.workspace = true
serde.workspace = true
Expand All @@ -28,10 +28,13 @@ sha2 = "0.10"
json-patch = "0.2.6"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }

[dev-dependencies]
lazy_static = "1.4"
ssi-jws = { workspace = true, features = ["secp256k1"] }

[target.'cfg(target_os = "android")'.dependencies.reqwest]
version = "0.11"
features = ["json", "native-tls-vendored"]
features = ["json", "native-tls-vendored"]

# [target.'cfg(target_arch = "wasm32", target_arch = "wasm64")'.dependencies]


[dev-dependencies]
lazy_static = "1.4"
ssi-jws = { workspace = true, features = ["secp256k1"] }
5 changes: 4 additions & 1 deletion crates/dids/methods/pkh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ ssi-dids-core.workspace = true
ssi-jwk.workspace = true
iref.workspace = true
static-iref.workspace = true
chrono = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
async-trait.workspace = true
bs58 = { workspace = true, features = ["check"] }
bech32 = "0.8"
chrono = { workspace = true, features = ["serde"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
chrono = { workspace = true, features = ["serde", "wasmbind"] }

[dev-dependencies]
ssi-core.workspace = true
Expand Down
7 changes: 6 additions & 1 deletion crates/dids/methods/tz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ssi-dids-core.workspace = true
ssi-jwk = { workspace = true, default-features = false, features = ["tezos"] }
ssi-jws = { workspace = true, default-features = false }
ssi-core.workspace = true
chrono = { version = "0.4" }
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -29,6 +28,12 @@ iref.workspace = true
static-iref.workspace = true
thiserror.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
chrono = { workspace = true, features = ["serde"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
chrono = { workspace = true, features = ["serde", "wasmbind"] }

[target.'cfg(target_os = "android")'.dependencies.reqwest]
version = "0.11"
features = ["json", "native-tls-vendored"]
Expand Down
2 changes: 1 addition & 1 deletion crates/json-ld/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::collections::HashMap;
use std::sync::Arc;

use async_std::sync::RwLock;
use futures::future::{BoxFuture, FutureExt};
use iref::{Iri, IriBuf};
use json_ld::future::{BoxFuture, FutureExt};
pub use json_ld::{syntax, Options, RemoteDocumentReference};
use json_ld::{syntax::TryFromJson, Loader, RemoteContext, RemoteContextReference, RemoteDocument};
use json_syntax::Parse;
Expand Down
10 changes: 5 additions & 5 deletions crates/jwk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ documentation = "https://docs.rs/ssi-jwk/"
default = ["secp256k1", "secp256r1", "ed25519", "rsa", "eip", "ripemd-160"]

## Enable secp256k1 keys.
secp256k1 = ["k256", "rand", "ssi-crypto/secp256k1"]
secp256k1 = ["k256", "rand", "getrandom", "ssi-crypto/secp256k1"]

## Enable secp256r1 (p256) keys.
secp256r1 = ["p256", "rand"]
secp256r1 = ["p256", "rand", "getrandom"]

## Enable secp384r1 (p384) keys.
secp384r1 = ["p384", "rand"]
secp384r1 = ["p384", "rand", "getrandom"]

## Enable ed25519 (EdDSA) keys.
ed25519 = ["ed25519-dalek", "rand", "getrandom"]
Expand All @@ -27,6 +27,8 @@ ed25519 = ["ed25519-dalek", "rand", "getrandom"]
rsa = ["dep:rsa"]

## Enable aleo ecosystem keys.
##
## Not compatible with WASM targets.
aleo = ["rand", "blake2", "snarkvm-dpc", "snarkvm-algorithms", "snarkvm-curves", "snarkvm-utilities", "snarkvm-parameters", "bs58"]

## enable ripemd-160 hashing for keys, e.g. for bitcoin.
Expand Down Expand Up @@ -80,8 +82,6 @@ snarkvm-parameters = { version = "0.7.9", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"], optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
getrandom = { version = "0.2", optional = true }

[dev-dependencies]
hex.workspace = true
Expand Down
6 changes: 2 additions & 4 deletions crates/ucan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ ssi-core.workspace = true
ssi-verification-methods.workspace = true
ssi-caips.workspace = true
libipld = { version = "0.14", default-features = false, features = ["dag-cbor", "dag-json", "derive", "serde-codec"]}

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
chrono = { version = "0.4", features = ["serde"] }
chrono = { workspace = true, features = ["serde"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
chrono = { version = "0.4", features = ["serde", "wasmbind"] }
chrono = { workspace = true, features = ["serde", "wasmbind"] }

[dev-dependencies]
async-std = { version = "1.9", features = ["attributes"] }
Expand Down
5 changes: 4 additions & 1 deletion crates/verification-methods/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/spruceid/ssi/"
documentation = "https://docs.rs/ssi-verification-methods/"

[features]
default = ["ed25519", "rsa", "secp256k1", "secp256r1", "secp384r1", "tezos", "eip712", "aleo", "solana"]
default = ["ed25519", "rsa", "secp256k1", "secp256r1", "secp384r1", "tezos", "eip712", "solana"]

## enable RSA keys
rsa = []
Expand All @@ -30,6 +30,9 @@ tezos = ["ssi-tzkey", "ssi-caips/tezos"]

eip712 = ["ssi-eip712", "sha3"]

## Enable aleo keys.
##
## Not compatible with WASM targets.
aleo = ["ssi-caips/aleo"]

solana = []
Expand Down
2 changes: 1 addition & 1 deletion crates/verification-methods/core/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl fmt::Display for ProofPurpose {
}
}

pub struct UnknownProofPurpose(IriBuf);
pub struct UnknownProofPurpose(pub IriBuf);

impl TryFrom<IriBuf> for ProofPurpose {
type Error = UnknownProofPurpose;
Expand Down

0 comments on commit 7040d7d

Please sign in to comment.