confium-wasm 0.3.0

Browser/Node.js verifier package for Confium — composite signatures, transparency proofs, certificate validation. WASM-bindgen surface; verifier-only by design.
Documentation
//! Browser/Node.js **verifier** package for Confium, plus an
//! opt-in **signer** surface for WASI hosts (Cloudflare Workers,
//! Fastly Compute@Edge, Vercel Edge Functions, Deno, Bun).
//!
//! wasm-bindgen surface. The default build targets
//! `wasm32-unknown-unknown` and is verifier-only by design — browsers
//! verify; servers sign.
//!
//! Build with the `sign` Cargo feature (and target `wasm32-wasip1`)
//! to expose the threshold-ECDSA signing surface from
//! `confium-tc-cmp20` / `confium-tc-gg18` / `confium-tc-frost-p256`.
//! This is the recommended shape for edge-deployed signers: the same
//! Rust code that powers the Ruby / Python / Node bindings also runs
//! in any WASI host, with no FFI overhead.
//!
//! Each subsystem is gated by a Cargo feature so consumers can
//! tree-shake aggressively. Verifier features are on by default;
//! `sign` is off by default.

#![forbid(unsafe_code)]
#![warn(missing_docs)]

use wasm_bindgen::prelude::*;

#[cfg(feature = "verify-composite")]
mod composite;

#[cfg(feature = "verify-composite")]
pub use composite::{CompositeSignature, CompositeVerificationResult};

#[cfg(feature = "verify-transparency")]
mod transparency;

#[cfg(feature = "verify-transparency")]
pub use transparency::{
    InclusionProof, MerkleTree, compute_artifact_hash, compute_leaf_hash, tree_head_from_json,
    verify_inclusion_with_head,
};

#[cfg(feature = "verify-attributes")]
mod attributes;

#[cfg(feature = "verify-attributes")]
pub use attributes::Predicate;

#[cfg(feature = "verify-pki")]
mod pki;

#[cfg(feature = "verify-pki")]
pub use pki::{Certificate, SignedData};

#[cfg(feature = "sign")]
mod signer;

#[cfg(feature = "sign")]
pub use signer::{Cmp20Signer, Gg18Signer};

/// Package version (mirrors the Cargo version).
#[wasm_bindgen]
pub fn version() -> String {
    env!("CARGO_PKG_VERSION").to_string()
}

/// Confium-core crate version this WASM blob was built against.
#[wasm_bindgen]
pub fn core_version() -> String {
    "0.2.0".to_string()
}

/// Canonicalize XML per RFC 3076 (Canonical XML 1.0).
#[wasm_bindgen]
pub fn canonicalize_xml(xml: &str) -> Result<String, JsValue> {
    confium_pki::xmldsig::canonicalize(xml)
        .map_err(|e| JsValue::from_str(&e.to_string()))
}

/// Canonicalize XML per Exclusive C14N (RFC 3741).
#[wasm_bindgen]
pub fn canonicalize_exclusive_xml(xml: &str) -> Result<String, JsValue> {
    confium_pki::xmldsig::canonicalize_exclusive(xml)
        .map_err(|e| JsValue::from_str(&e.to_string()))
}