Socket
Book a DemoInstallSign in
Socket

jwt-runner

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwt-runner

Package for generate and auto-update tokens on client browsers

0.0.4
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

Jwt Runner

This package is designed for full-stack developers, who also not know with deal with jwt on frontend

Using:

On Server:

import { JwtServer } from 'jwt-runner'

const server = new JwtServer({ secret: "my-secret" })

const accessToken = await server.encode({ userId: 1 })

...


const payload = await server.verifyAndDecode(accessToken)

On Client:

import { JwtClient } from 'jwt-runner/browser'

const jwtClient = new JwtClient({
  onUpdate: async (refreshToken) => {
    // Make request to server for update access and refresh tokens
    return { accessToken, refreshToken }
  }
})

// If the tokens have been stored before, jwtClient.start() will pull them from localStorage
await jwtClient.start()

jwtClient.setTokens({ accessToken, refreshToken })

// The client will then automatically update the tokens as needed

FAQs

Package last updated on 01 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.