Skip to main content

bitrouter_core/auth/
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 access;
10pub mod chain;
11pub mod claims;
12pub mod keys;
13pub mod token;
14
15/// Errors arising from JWT operations.
16#[derive(Debug, thiserror::Error)]
17pub enum JwtError {
18    #[error("invalid keypair bytes")]
19    InvalidKeypair,
20    #[error("invalid public key")]
21    InvalidPublicKey,
22    #[error("invalid secp256k1 key")]
23    InvalidSecp256k1Key,
24    #[error("malformed token: {0}")]
25    MalformedToken(String),
26    #[error("signing failed: {0}")]
27    Signing(String),
28    #[error("verification failed: {0}")]
29    Verification(String),
30    #[error("token expired")]
31    Expired,
32    #[error("unsupported algorithm: {0}")]
33    UnsupportedAlgorithm(String),
34    #[error("invalid CAIP-10 identifier: {0}")]
35    InvalidCaip10(String),
36    #[error("invalid chain identifier: {0}")]
37    InvalidChain(String),
38    #[error("recovered address does not match iss")]
39    AddressMismatch,
40    #[error("secp256k1 error: {0}")]
41    Secp256k1(String),
42}