
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@axmit/axios-patch-jwt
Advanced tools
This package will pass your user's creds inside Heders.Authorization for every request via axios.
It helps with JWT-way authorization systems.
You need to run configureAxiosJWTInterseptors(config); at your project's root file.
Something like index.tsx where you call ReactDOM.render();
{
storage: (Your storage instance),
axios: (Your axios instance),
refreshTokenEndpoint: (link to your refresh-token API point),
convertToCamelCase: (optional flag that provide info which case used your API)
Example with universal storage:
import { IAsyncStorage, WebStorageDecorator } from 'universal-storage';
import axios from 'axios';
const storage: IAsyncStorage = new WebStorageDecorator(localStorage);
configureAxiosJWTInterseptors({ storage, axios, refreshTokenEndpoint: '/api/auth' });
Now you can use saveCreds and clearCreads methods after login/logout in your app
Example:
const login = (data: ILoginPostData): Promise<any> =>
axios
.post(API_ROUTE, data)
.then(async response => {
await saveCreds(response.data.data);
return response;
})
.catch(error => Promise.reject(error.response));
const logout = (): Promise<any> =>
axios
.delete(API_ROUTE)
.then(async response => {
await clearCreds();
return response;
})
.catch(error => Promise.reject(error.response));
There are also a getCreds method for specific situations
Example:
const creds = await getCreds();
Where creds object looks like:
{
access: {token: ''},
refresh: {token: ''}
}
FAQs
Wrapper for axios library using JWT
The npm package @axmit/axios-patch-jwt receives a total of 643 weekly downloads. As such, @axmit/axios-patch-jwt popularity was classified as not popular.
We found that @axmit/axios-patch-jwt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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 Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.