#jwt #token #google #sign #android

jsonwebtoken-google-wasm

parse and validate google jwt token compliant with webassembly runtimes with jsonwebtoken

8 releases

0.0.8 Sep 21, 2023
0.0.7 Sep 21, 2023

#493 in WebAssembly

Download history 1/week @ 2024-02-23 1/week @ 2024-03-01 57/week @ 2024-03-29

57 downloads per month

MIT/Apache

19KB
378 lines

Parse and validate Google JWT tokens within Rust WebAssembly

Developed for CloudFlare Workers. Experimental & non-reviewed. Use at own risk.

#[derive(Debug, Serialize, Deserialize)]
pub struct Token {
    pub email: String,
    pub aud: String,
    pub iss: String,
    pub exp: u64,
}

async fn main() {
    let parser = Parser::new("your-google-client-id");
    let claims = parser.parse::<Token>("your-token", Instant::now()).await.unwrap();
    // Instant::now() is not supported on Cloudflare workers and needs to be replaced.
}

Credits

Based upon avkviring/jsonwebtoken-google which can't target WASM due to a rand crate dependency.

Dependencies

~11–25MB
~414K SLoC