Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@wavesenterprise/api-token-refresher
Advanced tools
Wavesenterprise JWT refresh library for both Node.js and browser.
Wavesenterprise JWT refresh library for both Node.js and browser.
npm install @wavesenterprise/api-token-refresher --save
type TokenPair = {
access_token: string,
refresh_token: string,
}
export type TokenRefresherConfig = {
authorization: TokenPair, // inital auth pair
refreshCallback(refreshToken: string): Promise<TokenPair>, // called to get new TokenPair
axiosRequestConfig?: AxiosRequestConfig, // optional, custom AxiosRequestConfig
onChangeAccessToken?(token: string): void, // optional, called after success token refresh
onRefreshFailed?(err: any): void, // optional, default console.log(err), called in case refresh error
refreshBeforeExpire?: number, // optional, default 30000, refresh will start if expiration - refreshBeforeExpire < Date.now()
minTimeBeforeExpireToSendReq?: number, // optional, default 1000, if expiration - minTimeBeforeExpireToSendReq < Date.now() token will be updted synchronously before req
maxAttemptsToRefreshToken?: number, // optional, default 5
sleepAfterError?: number, // optional default 1000
}
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()
import { init } from 'vostok-auth-refresh/axios';
const axios = init({
authorization: {
access_token: "",
refresh_token: ""
},
async refreshCallback(token: string): Promise<ITokenPair> {
return api.getRefreshToken(token)
},
onChangeAccessToken(token: string): void {
// do smth with new access token
},
});
changed to
import { ApiTokenRefresher } from '@wavesenterprise/api-token-refresher'
const apiTokenRefresher = new ApiTokenRefresher({
authorization: {
access_token: "",
refresh_token: ""
},
async refreshCallback(token: string): Promise<ITokenPair> {
return api.getRefreshToken(token)
},
onChangeAccessToken(token: string): void {
// do smth with new access token
},
)
const { axios } = apiTokenRefresher.init();
FAQs
Unknown package
We found that @wavesenterprise/api-token-refresher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.