nodedb 0.0.0-beta.1

Local-first, real-time, edge-to-cloud hybrid database for multi-modal workloads
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Shared utilities for the security subsystem.

/// Decode a base64url-encoded string (no padding required).
///
/// Handles the URL-safe alphabet (`-` and `_`) and adds padding as needed.
/// Used across JWT validation, JWKS key parsing, and token introspection.
pub fn base64_url_decode(input: &str) -> Option<Vec<u8>> {
    let padded = match input.len() % 4 {
        2 => format!("{input}=="),
        3 => format!("{input}="),
        _ => input.to_string(),
    };
    let standard = padded.replace('-', "+").replace('_', "/");
    use base64::Engine;
    base64::engine::general_purpose::STANDARD
        .decode(&standard)
        .ok()
}