Skip to content

[WIP] enable using PASETO in browser, with the help of Web Assembly/WASM

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT
Notifications You must be signed in to change notification settings

achmadk/pasetors-wasm

PASETO rust WASM (pasetors-wasm)

Enable the use of PASETO in the JavaScript browser with the help of WebAssembly (WASM).

Built with 🦀🕸 by Achmad Kurnianto

⛰️ Background

PASETO is everything you love about JOSE (JWT, JWE, JWS) without any of the many design deficits that plague the JOSE standards. According to the paseto.io website, there is no PASETO library supported for JavaScript browsers yet. Library paseto from Filip Skokan only supports nodejs, and paseto.js from Samuel Judson from now uses deprecated versions 1 and 2 implementations of PASETO.

Luckily, there are PASETO libraries implemented with the rust programming language, which can be compiled into WebAssembly. One of them is pasetors from Johannes, which has WASM support but is not fully tested.

The creator of pasetors also lacks experience using JavaScript programming language and publishing it to the npm registry. I hope this crate will help him and improve WASM support of pasetors.

🚴 Usages

Installation

This crate will produce 2 separate npm libraries each called @achmadk/pasetors-wasm (support JavaScript browser) and @achmadk/pasetors-wasm-node (support nodejs).

yarn add @achmadk/pasetors-wasm # for browser, or
yarn add @achmadk/pasetors-wasm-node # for nodejs

Methods (WIP)

  • v4.localToken.encrypt
  • v4.localToken.decrypt
  • v4.publicToken.sign
  • v4.publicToken.verify

🖊️ Contributing

🛠️ Build with wasm-pack build

wasm-pack build --release -t web -s achmadk --out-dir pkg/pasetors-wasm --out-name pasetors-wasm # for browser
wasm-pack build --release -t nodejs -s achmadk --out-dir pkg/pasetors-wasm-node --out-name pasetors-wasm-node # for nodejs

🔬 Test in either Browsers or nodejs

wasm-pack test --headless
wasm-pack test --chrome --firefox
wasm-pack test --node

For more information about contributing, please read this file

🔋 Batteries Included

  • wasm-bindgen for communicating between WebAssembly and JavaScript.
  • console_error_panic_hook for logging panic messages to the developer console.
  • wee_alloc, an allocator optimized for small code size.
  • pasetors for implementing PASETO with rust programming language.

About

[WIP] enable using PASETO in browser, with the help of Web Assembly/WASM

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages