Skip to main content

bitrouter_core/jwt/
mod.rs

1//! BitRouter JWT protocol types.
2//!
3//! Defines the open JWT claims standard shared between the bitrouter CLI,
4//! self-hosted servers, and the BitRouter cloud service. JWTs are signed
5//! with web3 wallet keys — Ed25519 for Solana (`SOL_EDDSA`) or EIP-191
6//! secp256k1 for EVM chains (`EIP191K`). Users hold the private seed,
7//! servers verify signatures and resolve accounts by CAIP-10 identity.
8
9pub mod chain;
10pub mod claims;
11pub mod keys;
12pub mod token;
13
14/// Errors arising from JWT operations.
15#[derive(Debug, thiserror::Error)]
16pub enum JwtError {
17    #[error("invalid keypair bytes")]
18    InvalidKeypair,
19    #[error("invalid public key")]
20    InvalidPublicKey,
21    #[error("invalid secp256k1 key")]
22    InvalidSecp256k1Key,
23    #[error("malformed token: {0}")]
24    MalformedToken(String),
25    #[error("signing failed: {0}")]
26    Signing(String),
27    #[error("verification failed: {0}")]
28    Verification(String),
29    #[error("token expired")]
30    Expired,
31    #[error("unsupported algorithm: {0}")]
32    UnsupportedAlgorithm(String),
33    #[error("invalid CAIP-10 identifier: {0}")]
34    InvalidCaip10(String),
35    #[error("invalid chain identifier: {0}")]
36    InvalidChain(String),
37    #[error("recovered address does not match iss")]
38    AddressMismatch,
39    #[error("secp256k1 error: {0}")]
40    Secp256k1(String),
41}