invoance/lib.rs
1//! Official Rust SDK for the [Invoance](https://invoance.com) compliance API —
2//! cryptographic proof, document anchoring, and AI attestation.
3//!
4//! The SDK is async (built on `tokio` + `reqwest`). Construct a client, then
5//! reach each product surface through a resource accessor:
6//!
7//! ```no_run
8//! # async fn run() -> Result<(), invoance::Error> {
9//! use invoance::InvoanceClient;
10//! use invoance::models::IngestEventParams;
11//! use serde_json::json;
12//!
13//! let client = InvoanceClient::new()?; // reads INVOANCE_API_KEY from env
14//!
15//! let event = client
16//! .events()
17//! .ingest(IngestEventParams {
18//! event_type: "policy.approval".into(),
19//! payload: json!({ "policy_id": "pol_001", "decision": "approved" })
20//! .as_object()
21//! .unwrap()
22//! .clone(),
23//! ..Default::default()
24//! })
25//! .await?;
26//! println!("{}", event.event_id);
27//! # Ok(()) }
28//! ```
29//!
30//! ## Error handling
31//!
32//! Every fallible call returns `Result<T, `[`Error`]`>`. Classify with the
33//! boolean predicates (`is_authentication()`, `is_quota_exceeded()`, …) or by
34//! matching the [`Error`] variants.
35//!
36//! ## Offline crypto helpers
37//!
38//! - [`audit_verify::verify_audit_event`] — verify an audit event's Ed25519
39//! signature without trusting the server.
40//! - [`audit_canonical`] — the `invoance.audit/1` canonicalizer.
41//! - [`resources::content_idempotency_key`] — derive a content-stable
42//! idempotency key from a request body.
43
44#![forbid(unsafe_code)]
45
46pub mod audit_canonical;
47pub mod audit_verify;
48mod client;
49mod config;
50mod error;
51mod http;
52pub mod models;
53pub mod resources;
54mod validate;
55mod version;
56
57pub use audit_canonical::{canonical_audit_bytes, normalize_ts, payload_hash_hex, AUDIT_SCHEMA_ID};
58pub use audit_verify::{verify_audit_event, AuditVerifyResult, KeySource};
59pub use client::{ClientBuilder, InvoanceClient, ValidationResult};
60pub use config::ClientConfig;
61pub use error::{ApiErrorKind, Error, RequestContext};
62pub use resources::content_idempotency_key;
63pub use version::SDK_VERSION;