Skip to content

Conversation

@Ryanmtate
Copy link
Contributor

This pull request introduces updates to enable WASM compatibility. The most important changes include updating dependencies (notably jsonschema, serde, tokio, and reqwest), refactoring for WASM support (including conditional compilation and trait adjustments), and improving the handling and validation of JSON schemas.

Dependency Updates and WASM Compatibility:

  • Updated dependencies in Cargo.toml to use a WASM-compatible fork of jsonschema, newer versions of serde, tokio (with appropriate features), and separated reqwest dependencies for WASM and non-WASM targets. [1] [2]
  • Refactored trait and struct definitions throughout the codebase to use conditional compilation and async_trait attributes for WASM compatibility, including in Client, RequestSigner, and SessionStore traits. [1] [2] [3] [4] [5] [6]

JSON Schema Handling Improvements:

  • Switched from using jsonschema::JSONSchema to jsonschema::Resource given interface changes, and updated related methods to use the new validator construction pattern. [1] [2] [3] [4]

Session and Verifier Refactoring:

  • Made Verifier struct fields public and adjusted SessionStore trait and builder patterns to support both WASM and non-WASM targets, improving flexibility and testability. [1] [2] [3]
  • Modularized the in-memory session store for non-WASM targets and added serialization support for Session. [1] [2] [3] [4]

HTTP Client Abstraction:

  • Refactored HTTP client code to provide a WASM-compatible interface, moving client implementation behind conditional compilation and improving error handling. [1] [2] [3] [4]

Cryptographic Enhancements and Testing:

  • Added a helper method to P256Signer for constructing from PKCS#8 PEM, and included a corresponding test to verify its functionality. [1] [2]

Test Suite Adjustments:

  • Updated test files to exclude execution on WASM targets, ensuring tests only run where supported. [1] [2]

@Ryanmtate Ryanmtate requested review from cobward and sbihel September 29, 2025 16:20
Ok(Self { key, jwk })
}

pub fn from_pkcs8_pem(s: &str) -> Result<Self> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think this should be added to the crate. It means we make the pkcs8 feature of p256 mandatory, when a dependent might just want to use DER

# There may be a better way to handle this that doesn't require the `json-syntax` crate directly.
json-syntax = { version = "0.12.5", features = ["serde_json"] }
jsonschema = "0.18.0"
jsonschema = { git = "https://github.com/spruceid/jsonschema.git", branch = "feat/wasm-support" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning on raising a PR with the changes?

Copy link
Contributor Author

@Ryanmtate Ryanmtate Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yes, but receiving a Pull request creation failed. Validation failed: must be a collaborator error when opening a PR against the origin repository. We can merge this branch into our forked main branch, but likely will need to reach out to the repo owner and allow him to accept changes upstream.

Cargo.toml Outdated
serde_urlencoded = "0.7.1"
ssi = { version = "0.12", features = ["secp256r1"] }
tokio = "1.32.0"
tokio = { version = "1.43.0", features = ["sync"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this feature needed?

pub struct CompiledJsonSchema {
raw: serde_json::Value,
compiled: Arc<jsonschema::JSONSchema>,
compiled: Arc<jsonschema::Resource>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this Arc still needed if the methods now don't return self.compiled directly?


#[derive(Debug, Clone)]
pub struct ReqwestClient(reqwest::Client);
#[cfg(not(target_arch = "wasm32"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that the "client" code isn't fully available on WASM? Why not use reqwest's default WASM client (https://docs.rs/reqwest/latest/reqwest/#wasm) and simply disable rusttls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some tls and cookie related features that get disabled with the reqwest client when the target is automatically set. I split those those methods into conditional compilations, and we are able to have a working client for a wasm target rather than target gating the entire client code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants