verse_session_id/
lib.rs

1//! # verse-session-id
2//!
3//! [<img alt="crates.io" src="https://img.shields.io/crates/v/verse-session-id.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/verse-session-id)
4//! [<img alt="docs.rs" src="https://img.shields.io/docsrs/verse-session-id?style=for-the-badge&logo=docs.rs" height="20">](https://docs.rs/verse-session-id)
5//! [<img alt="MIT" src="https://img.shields.io/github/license/VerseEngine/verse-session-id?style=for-the-badge" height="20">](https://github.com/VerseEngine/verse-session-id/blob/main/LICENSE)
6//! [<img alt="MIT" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge" height="20">](https://github.com/VerseEngine/verse-three/pulls)
7//!
8//! ID with signature/verification functions.  
9//! Used as session ID in [@VerseEngine/verse-core](https://github.com/VerseEngine/verse-session-id).
10//!
11//! ## Usage
12//! ### Signature Verification
13//! ```rust
14//! use verse_session_id::*;
15//!
16//! ...
17//! pub fn verify_string(session_id: &str, signature: &str, data: &str) -> bool {
18//!   let Ok(sid) = session_id.parse::<SessionId>() else {
19//!      return false;
20//!   };
21//!   let Ok(ss) = signature.parse::<SignatureSet>() else {
22//!      return false;
23//!   };
24//!
25//!   sid.verify(vec![data.as_bytes()], &ss).is_ok()
26//! }
27//! ```
28//!
29//!
30//! ### Generate ID
31//! ```rust
32//! let id_pair = new_session_id_pair()?;
33//! let session_id = id_pair.get_id();
34//! // to string
35//! let s = format!("{}", session_id);
36//! ```
37//!
38//!
39//! ### Create a signature
40//! ```rust
41//! pub fn sign_string(&self, data: &str) -> Result<String> {
42//!     let id_pair = ...;
43//!     Ok(id_pair
44//!         .sign(vec![data.as_bytes()])?
45//!         .to_string())
46//! }
47//! ```
48mod session_id;
49pub use session_id::*;
50
51mod session_id_pair;
52pub use session_id_pair::*;
53
54mod errors;