Skip to content

Latest commit

 

History

History
76 lines (53 loc) · 3.21 KB

README.md

File metadata and controls

76 lines (53 loc) · 3.21 KB

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.