Skip to content

release_v0.2.1

Latest

Choose a tag to compare

@robjsliwa robjsliwa released this 25 Oct 12:28
d59d507

Release v0.2.1

Fix Crash When Executing as WebAssembly by Adding Support for Time Retrieval in Browser Environment

Description:
This pull request addresses an issue where the jwt-rustcrypto library would crash when executed as WebAssembly (WASM) in the browser. The crash was caused by the library's reliance on system time, which is not accessible in the same way within a browser environment. To resolve this, modifications were made to allow the library to retrieve the current timestamp using browser-compatible methods when compiled for WebAssembly.

Changes:

  • Cargo.toml:
    • Bumped the version from 0.2.0 to 0.2.1.
    • Added wasm-bindgen as a dependency to enable interfacing with JavaScript functions for browser compatibility.
  • Cargo.lock:
    • Updated to reflect changes in dependencies.
  • src/validation.rs:
    • Implemented conditional compilation to differentiate between standard system time access (std::time::SystemTime) and WebAssembly-compatible time retrieval using wasm-bindgen.
    • Added new functions to retrieve the current timestamp using JavaScript's Date.now() method when running in a WASM environment.
    • Included a conditional import of wasm-bindgen::prelude::* for WebAssembly-specific functionalities.
    • Improved error handling and ensured consistent behavior across environments.