Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wavesenterprise/api-token-refresher

Package Overview
Dependencies
Maintainers
9
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wavesenterprise/api-token-refresher

Wavesenterprise JWT refresh library for both Node.js and browser.

  • 3.0.0-RC1
  • npm
  • Socket score

Version published
Weekly downloads
12
Maintainers
9
Weekly downloads
 
Created
Source

Wavesenterprise JWT refresh library for both Node.js and browser.

Installation

npm install @wavesenterprise/api-token-refresher --save

Example of usage

config

export type TokenPair = {
  access_token: string,
  refresh_token: string,
}

export type TokenRefresherConfig = {
  authorization: TokenPair,
  refreshCallback(refreshToken: string): Promise<TokenPair>,
  axiosRequestConfig?: AxiosRequestConfig,
  onChangeAccessToken?(token: string): void,
  onRefreshFailed?(err: any): void,
  refreshBeforeExpire?: number,
  maxAttemptsToRefreshToken?: number,
}

Usage

Full example can be found in examples/ folder

import { ApiTokenRefresher } from '@wavesenterprise/api-token-refresher'
import axios from 'axios'

const refreshCallback = async (token: string) => {
  return Promise.reject('just test')
  try {
    const { data } = await axios.post(`${AUTH_SERVICE_ADDRESS}/v1/auth/refresh`, { token })
    console.log('token refreshed')
    return data
  } catch (e) {
    console.log('refresh failed relogin')
    return getTokens()
  }
}

const apiTokenRefresher = new ApiTokenRefresher({
    authorization: tokens,
    refreshCallback,
 })
const { axios, fetch } = apiTokenRefresher.init()

FAQs

Package last updated on 11 Nov 2020

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc