MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / base64_url_decode

Function base64_url_decode

nodedb/src/control/security/util.rs:9–20  ·  view source on GitHub ↗

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.

(input: &str)

Source from the content-addressed store, hash-verified

7/// Handles the URL-safe alphabet (`-` and `_`) and adds padding as needed.
8/// Used across JWT validation, JWKS key parsing, and token introspection.
9pub fn base64_url_decode(input: &str) -> Option<Vec<u8>> {
10 let padded = match input.len() % 4 {
11 2 => format!("{input}=="),
12 3 => format!("{input}="),
13 _ => input.to_string(),
14 };
15 let standard = padded.replace('-', "+").replace('_', "/");
16 use base64::Engine;
17 base64::engine::general_purpose::STANDARD
18 .decode(&standard)
19 .ok()
20}

Callers 12

validateMethod · 0.85
base64url_decode_worksFunction · 0.85
verify_bearer_tokenFunction · 0.85
parse_rsa_jwkFunction · 0.85
parse_ec_jwkFunction · 0.85
decode_claimsMethod · 0.85
decode_unverifiedMethod · 0.85
decode_jwt_headerFunction · 0.85
extract_jwt_exp_msFunction · 0.85
extract_exp_from_tokenFunction · 0.85

Calls 5

to_stringMethod · 0.80
replaceMethod · 0.80
lenMethod · 0.45
okMethod · 0.45
decodeMethod · 0.45

Tested by 1

base64url_decode_worksFunction · 0.68