#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

#564 in WebAssembly

29 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–23MB
~370K SLoC