Skip to content

scalajs-io/jwt-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JwtSimple API for Scala.js

jwt-simple - JWT(JSON Web Token) encode and decode module.

Description

JWT(JSON Web Token) encode and decode module.

Build Dependencies

Build/publish the SDK locally

 $ sbt clean publish-local

Running the tests

Before running the tests the first time, you must ensure the npm packages are installed:

$ npm install

Then you can run the tests:

$ sbt test

Examples

import io.scalajs.JSON
import io.scalajs.npm.jwtsimple._
import scala.scalajs.js

val payload = js.Dictionary("foo" -> "bar")
val secret = "scalajs"

// encode
val token = JwtSimple.encode(payload, secret)
println(s"token: $token") //=> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIifQ.GmVaWnUkI1glyMfggMz6u4T-8I5KPfk8Kmc4PxKJz50

// decode
val decoded = JwtSimple.decode(token, secret)
println(s"payload: ${JSON.stringify(decoded)}") //=> { foo: "bar" }

Artifacts and Resolvers

To add the JwtSimple binding to your project, add the following to your build.sbt:

libraryDependencies += "io.scalajs.npm" %%% "jwt-simple" % "0.5.0"

Optionally, you may add the Sonatype Repository resolver:

resolvers += Resolver.sonatypeRepo("releases") 

Releases

No releases published

Packages

No packages published

Languages