diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05436cd24..4c1872b64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -335,7 +335,7 @@ jobs: CC: /opt/wasi-sdk/bin/clang WASI_SDK_PATH: /opt/wasi-sdk RUST_MIN_STACK: 16777216 - run: cargo +nightly test --target wasm32-wasip2 -p c2pa -p c2pa-crypto --all-features + run: cargo +nightly test --target wasm32-wasip2 -p c2pa -p c2pa-crypto -p cawg-identity --all-features test-direct-minimal-versions: name: Unit tests with minimum versions of direct dependencies diff --git a/Cargo.lock b/Cargo.lock index 79ed98cb2..bd878f91a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -910,6 +910,7 @@ dependencies = [ "tokio", "wasm-bindgen", "wasm-bindgen-test", + "wstd", "zeroize", ] diff --git a/Makefile b/Makefile index 56ec410b1..bd0eaeab0 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ test-wasi: ifeq ($(PLATFORM),mac) $(eval CC := /opt/homebrew/opt/llvm/bin/clang) endif - CC=$(CC) CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime -S cli -S http --dir ." cargo +nightly test --target wasm32-wasip2 -p c2pa -p c2pa-crypto --all-features + CC=$(CC) CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime -S cli -S http --dir ." cargo +nightly test --target wasm32-wasip2 -p c2pa -p c2pa-crypto -p cawg-identity --all-features rm -r sdk/Users # Full local validation, build and test all features including wasm diff --git a/cawg_identity/Cargo.toml b/cawg_identity/Cargo.toml index c2f31ee94..c19486941 100644 --- a/cawg_identity/Cargo.toml +++ b/cawg_identity/Cargo.toml @@ -25,7 +25,7 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] -v1_api = ["c2pa/v1_api"] +v1_api = ["c2pa/v1_api", "c2pa/file_io"] [dependencies] async-trait = "0.1.78" @@ -44,7 +44,6 @@ non-empty-string = { version = "=0.2.4", features = ["serde"] } nonempty-collections = { version = "0.2.9", features = ["serde"] } rand = "0.8.5" regex = "1.11" -reqwest = { version = "0.12.8", default-features = false, features = ["rustls-tls"] } serde = { version = "1.0.197", features = ["derive"] } serde_bytes = "0.11.14" serde_json = "1.0.117" @@ -52,7 +51,13 @@ static-iref = "3.0" thiserror = "1.0.61" zeroize = { version = "1.8", features = ["zeroize_derive"] } -[target.'cfg(target_arch = "wasm32")'.dependencies] +[target.'cfg(target_os = "wasi")'.dependencies] +wstd = "0.5" + +[target.'cfg(not(target_os = "wasi"))'.dependencies] +reqwest = { version = "0.12.8", default-features = false, features = ["rustls-tls"] } + +[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies] wasm-bindgen = "0.2.95" [dev-dependencies] @@ -62,5 +67,5 @@ serde = { version = "1.0.197", features = ["derive"] } httpmock = "0.7.0" tokio = { version = "1.42", features = ["macros", "rt"] } -[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies] wasm-bindgen-test = "0.3.31" diff --git a/cawg_identity/README.md b/cawg_identity/README.md index 52303b990..be5e462a8 100644 --- a/cawg_identity/README.md +++ b/cawg_identity/README.md @@ -27,6 +27,8 @@ The toolkit has been tested on the following operating systems: * Ubuntu Linux on x86 and ARM v8 (aarch64) +* WebAssembly System Interface (WASI) + ## License The `cawg-identity` crate is distributed under the terms of both the MIT license and the Apache License (Version 2.0). diff --git a/cawg_identity/src/claim_aggregation/w3c_vc/did_web.rs b/cawg_identity/src/claim_aggregation/w3c_vc/did_web.rs index 4dbe6ac71..b16c6d78e 100644 --- a/cawg_identity/src/claim_aggregation/w3c_vc/did_web.rs +++ b/cawg_identity/src/claim_aggregation/w3c_vc/did_web.rs @@ -30,10 +30,10 @@ thread_local! { pub(crate) static PROXY: RefCell> = const { RefCell::new(None) }; } -// #[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_os = "wasi"))] use reqwest::Error as HttpError; -// #[cfg(target_arch = "wasm32")] -// use String as HttpError; +#[cfg(target_os = "wasi")] +use String as HttpError; #[derive(Debug, thiserror::Error)] pub enum DidWebError { @@ -81,7 +81,7 @@ pub(crate) async fn resolve(did: &Did<'_>) -> Result { } async fn get_did_doc(url: &str) -> Result, DidWebError> { - // #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_os = "wasi"))] { use reqwest::header; @@ -116,45 +116,36 @@ async fn get_did_doc(url: &str) -> Result, DidWebError> { Ok(document.to_vec()) } - // #[cfg(target_arch = "wasm32")] - // { - // use wasm_bindgen::prelude::*; - // use wasm_bindgen_futures::JsFuture; - // use web_sys::{Request, RequestInit, RequestMode, Response}; - - // let opts = RequestInit::new(); - // opts.set_method("GET"); - // opts.set_mode(RequestMode::Cors); - - // let request = Request::new_with_str_and_init(&url, &opts) - // .map_err(|_| - // DidWebError::Client("Request::new_with_str_and_init".to_string()))?; - - // request - // .headers() - // .set("accept", "application/did+json") - // .map_err(|_| DidWebError::Client("Set headers".to_string()))?; - - // let window = web_sys::window().unwrap(); - // let resp_value = JsFuture::from(window.fetch_with_request(&request)) - // .await - // .map_err(|_| - // DidWebError::Client("window.fetch_with_request".to_string()))?; - - // assert!(resp_value.is_instance_of::()); - // let resp: Response = resp_value.dyn_into().unwrap(); - - // JsFuture::from( - // resp.blob() - // .map_err(|_| - // DidWebError::Client("window.resp.bytes()".to_string()))?, ) - // .await - // .map(|blob| { - // let array = js_sys::Uint8Array::new(&blob); - // array.to_vec() - // }) - // .map_err(|e| DidWebError::Server("resp.blob()".to_string())) - // } + #[cfg(target_os = "wasi")] + { + use wstd::{http, io, io::AsyncRead}; + + let request = http::Request::get(url) + .header("User-Agent", http::HeaderValue::from_static(USER_AGENT)) + .header( + "Accept", + http::HeaderValue::from_static("application/did+json"), + ) + .body(io::empty()) + .map_err(|e| DidWebError::Request(url.to_owned(), e.to_string()))?; + let resp = http::Client::new() + .send(request) + .await + .map_err(|e| DidWebError::Request(url.to_owned(), e.to_string()))?; + + let (parts, mut body) = resp.into_parts(); + match parts.status { + http::StatusCode::OK => (), + http::StatusCode::NOT_FOUND => return Err(DidWebError::NotFound(url.to_string())), + _ => return Err(DidWebError::Server(parts.status.to_string())), + }; + + let mut document = Vec::new(); + body.read_to_end(&mut document) + .await + .map_err(|e| DidWebError::Response(e.to_string()))?; + Ok(document) + } } pub(crate) fn to_url(did: &str) -> Result { diff --git a/cawg_identity/src/tests/builder/error.rs b/cawg_identity/src/tests/builder/error.rs index 237d380a4..fc20cd0e9 100644 --- a/cawg_identity/src/tests/builder/error.rs +++ b/cawg_identity/src/tests/builder/error.rs @@ -11,13 +11,16 @@ // specific language governing permissions and limitations under // each license. -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::builder::IdentityBuilderError; #[test] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] fn impl_from_ciborium_err() { let ciborium_err: ciborium::ser::Error = ciborium::ser::Error::Value("foo".to_string()); let builder_err: IdentityBuilderError = ciborium_err.into(); diff --git a/cawg_identity/src/tests/builder/simple_case.rs b/cawg_identity/src/tests/builder/simple_case.rs index d6d5dfb00..98c2df92c 100644 --- a/cawg_identity/src/tests/builder/simple_case.rs +++ b/cawg_identity/src/tests/builder/simple_case.rs @@ -15,7 +15,7 @@ use std::io::{Cursor, Seek}; use c2pa::{Builder, Reader, SigningAlg}; use serde_json::json; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::{ @@ -31,7 +31,11 @@ const TEST_IMAGE: &[u8] = include_bytes!("../../../../sdk/tests/fixtures/CA.jpg" const TEST_THUMBNAIL: &[u8] = include_bytes!("../../../../sdk/tests/fixtures/thumbnail.jpg"); #[cfg_attr(not(target_arch = "wasm32"), tokio::test)] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] +#[cfg_attr(target_os = "wasi", wstd::test)] async fn simple_case() { // NOTE: This needs to be async for now because the verification side is // async-only. @@ -84,7 +88,11 @@ async fn simple_case() { } #[cfg_attr(not(target_arch = "wasm32"), tokio::test)] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] +#[cfg_attr(target_os = "wasi", wstd::test)] async fn simple_case_async() { let format = "image/jpeg"; let mut source = Cursor::new(TEST_IMAGE); diff --git a/cawg_identity/src/tests/claim_aggregation/interop.rs b/cawg_identity/src/tests/claim_aggregation/interop.rs index 50b6df71c..171b0d526 100644 --- a/cawg_identity/src/tests/claim_aggregation/interop.rs +++ b/cawg_identity/src/tests/claim_aggregation/interop.rs @@ -17,7 +17,7 @@ use c2pa::{HashedUri, Reader}; use chrono::{DateTime, FixedOffset}; use iref::UriBuf; use non_empty_string::NonEmptyString; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::{ @@ -26,7 +26,11 @@ use crate::{ }; #[cfg_attr(not(target_arch = "wasm32"), tokio::test)] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] +#[cfg_attr(target_os = "wasi", wstd::test)] async fn adobe_connected_identities() { let format = "image/jpeg"; let test_image = include_bytes!("../fixtures/claim_aggregation/adobe_connected_identities.jpg"); @@ -102,7 +106,11 @@ async fn adobe_connected_identities() { } #[cfg_attr(not(target_arch = "wasm32"), tokio::test)] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] +#[cfg_attr(target_os = "wasi", wstd::test)] async fn ims_multiple_manifests() { let format = "image/jpeg"; let test_image = include_bytes!("../fixtures/claim_aggregation/ims_multiple_manifests.jpg"); diff --git a/cawg_identity/src/tests/claim_aggregation/w3c_vc/did.rs b/cawg_identity/src/tests/claim_aggregation/w3c_vc/did.rs index 54f49385f..41c09b424 100644 --- a/cawg_identity/src/tests/claim_aggregation/w3c_vc/did.rs +++ b/cawg_identity/src/tests/claim_aggregation/w3c_vc/did.rs @@ -19,13 +19,16 @@ // each license. mod new { - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::claim_aggregation::w3c_vc::did::Did; #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn valid_dids() { let did = Did::new("did:method:foo").unwrap(); assert_eq!(did.method_name(), "method"); @@ -45,7 +48,10 @@ mod new { } #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn err_invalid_did() { Did::new("http:a:b").unwrap_err(); Did::new("did::b").unwrap_err(); @@ -54,13 +60,16 @@ mod new { } mod split_fragment { - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::claim_aggregation::w3c_vc::did::Did; #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn has_fragment() { let did = Did::new("did:method:foo#bar").unwrap(); assert_eq!(did.method_name(), "method"); @@ -72,7 +81,10 @@ mod split_fragment { } #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn no_fragment() { let did = Did::new("did:method:foo").unwrap(); let did2 = Did::new("did:method:foo").unwrap(); diff --git a/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_buf.rs b/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_buf.rs index 95509e2ce..b662335ec 100644 --- a/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_buf.rs +++ b/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_buf.rs @@ -19,13 +19,16 @@ // each license. mod new { - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::claim_aggregation::w3c_vc::did::DidBuf; #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn valid_dids() { let did = DidBuf::new("did:method:foo".to_string()).unwrap(); let did = did.as_did(); @@ -49,7 +52,10 @@ mod new { } #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn err_invalid_did() { DidBuf::new("http:a:b".to_string()).unwrap_err(); DidBuf::new("did::b".to_string()).unwrap_err(); @@ -58,7 +64,7 @@ mod new { } mod impl_serde { - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::claim_aggregation::w3c_vc::did::DidBuf; @@ -72,7 +78,10 @@ mod impl_serde { const SAMPLE_WITH_BAD_DID: &str = r#"{"did": "did::b"}"#; #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn from_json() { let s: Sample = serde_json::from_str(SAMPLE_WITH_DID).unwrap(); let did = s.did; @@ -82,14 +91,20 @@ mod impl_serde { } #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] #[should_panic] fn from_json_err_invalid_did() { let _: Sample = serde_json::from_str(SAMPLE_WITH_BAD_DID).unwrap(); } #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test + )] fn to_json() { let s = Sample { did: DidBuf::new("did:method:foo".to_string()).unwrap(), diff --git a/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_web.rs b/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_web.rs index b7e050031..b19ec7d0f 100644 --- a/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_web.rs +++ b/cawg_identity/src/tests/claim_aggregation/w3c_vc/did_web.rs @@ -18,13 +18,16 @@ // specific language governing permissions and limitations under // each license. -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::claim_aggregation::w3c_vc::{did::Did, did_web}; #[test] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] fn to_url() { // https://w3c-ccg.github.io/did-method-web/#example-3-creating-the-did assert_eq!( @@ -59,8 +62,9 @@ mod resolve { }; #[tokio::test] - // #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] - // Can't test this on WASM until we find an httpmock replacement. + // #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), + // wasm_bindgen_test)] Can't test this on WASM until we find an httpmock + // replacement. async fn from_did_key() { const DID_JSON: &str = r#"{ "@context": "https://www.w3.org/ns/did/v1", @@ -102,7 +106,7 @@ mod resolve { /* #[tokio::test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test)] async fn credential_prove_verify_did_web() { let didweb = VerificationMethodDIDResolver::new(DIDWeb); let params = VerificationParameters::from_resolver(&didweb); diff --git a/cawg_identity/src/tests/claim_aggregation/w3c_vc/jwk.rs b/cawg_identity/src/tests/claim_aggregation/w3c_vc/jwk.rs index 079d2a473..c55ccadaa 100644 --- a/cawg_identity/src/tests/claim_aggregation/w3c_vc/jwk.rs +++ b/cawg_identity/src/tests/claim_aggregation/w3c_vc/jwk.rs @@ -18,7 +18,7 @@ // specific language governing permissions and limitations under // each license. -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::claim_aggregation::w3c_vc::jwk::*; @@ -27,13 +27,19 @@ const ED25519_JSON: &str = r#"{"kty":"OKP","crv":"Ed25519","x":"G80iskrv_nE69qbG "#; #[test] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] fn ed25519_from_str() { let _jwk: Jwk = serde_json::from_str(ED25519_JSON).unwrap(); } #[test] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] fn generate_ed25519() { let _key = Jwk::generate_ed25519().unwrap(); } diff --git a/cawg_identity/src/tests/identity_assertion/signer_payload.rs b/cawg_identity/src/tests/identity_assertion/signer_payload.rs index 57297dec3..cde050a77 100644 --- a/cawg_identity/src/tests/identity_assertion/signer_payload.rs +++ b/cawg_identity/src/tests/identity_assertion/signer_payload.rs @@ -13,13 +13,16 @@ use c2pa::HashedUri; use hex_literal::hex; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::SignerPayload; #[test] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] fn impl_clone() { // Silly test to ensure code coverage on #[derive] line. diff --git a/cawg_identity/src/tests/internal/debug_byte_slice.rs b/cawg_identity/src/tests/internal/debug_byte_slice.rs index 2b1624fc1..6008c9ab5 100644 --- a/cawg_identity/src/tests/internal/debug_byte_slice.rs +++ b/cawg_identity/src/tests/internal/debug_byte_slice.rs @@ -12,13 +12,16 @@ // each license. use hex_literal::hex; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::internal::debug_byte_slice::*; #[test] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] fn debug_byte_slice() { let h = hex!("01020354595f"); let s = DebugByteSlice(&h); diff --git a/cawg_identity/src/tests/mod.rs b/cawg_identity/src/tests/mod.rs index 0c9033b09..b9523b238 100644 --- a/cawg_identity/src/tests/mod.rs +++ b/cawg_identity/src/tests/mod.rs @@ -25,5 +25,5 @@ mod identity_assertion; mod internal; mod x509; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); diff --git a/cawg_identity/src/tests/x509.rs b/cawg_identity/src/tests/x509.rs index 2623c8a3d..4ea4076e1 100644 --- a/cawg_identity/src/tests/x509.rs +++ b/cawg_identity/src/tests/x509.rs @@ -16,7 +16,7 @@ use std::io::{Cursor, Seek}; use c2pa::{Builder, Reader, SigningAlg}; use c2pa_crypto::raw_signature; use serde_json::json; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::{ @@ -30,7 +30,11 @@ const TEST_IMAGE: &[u8] = include_bytes!("../../../sdk/tests/fixtures/CA.jpg"); const TEST_THUMBNAIL: &[u8] = include_bytes!("../../../sdk/tests/fixtures/thumbnail.jpg"); #[cfg_attr(not(target_arch = "wasm32"), tokio::test)] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +#[cfg_attr( + all(target_arch = "wasm32", not(target_os = "wasi")), + wasm_bindgen_test +)] +#[cfg_attr(target_os = "wasi", wstd::test)] async fn simple_case() { let format = "image/jpeg"; let mut source = Cursor::new(TEST_IMAGE); diff --git a/sdk/src/store.rs b/sdk/src/store.rs index 9b56dabdc..4bab71879 100644 --- a/sdk/src/store.rs +++ b/sdk/src/store.rs @@ -3289,6 +3289,7 @@ impl Store { } // fetch remote manifest if possible + // TODO: Switch to reqwest once it supports WASI https://github.com/seanmonstar/reqwest/issues/2294 #[cfg(all(feature = "fetch_remote_manifests", target_os = "wasi"))] fn fetch_remote_manifest(url: &str) -> Result> { use url::Url;