Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@atayahmet/react-axios-token-provider
Advanced tools
React Axios Token Provider package is a make easy what repetitive processes.
React Axios Token Provider package is a make easy what repetitive processes. For example handle access token or refresh token management process easly.
It can be preferred to reduce repetitive practices for authentication operations in projects.
Use the package manager yarn or npm to install react-axios-token-provider
$ npm i @atayahmet/react-axios-token-provider --save
$ yarn add @atayahmet/react-axios-token-provider
import AxiosTokenProvider from '@atayahmet/react-axios-token-provider';
import axios from 'axios';
function App() {
return (
<AxiosTokenProvider instance={axios}>
<div>
<h1>Hello World!</h1>
</div>
</AxiosTokenProvider>
);
}
name | type | default | description |
---|---|---|---|
instance | AxiosInstance | AxiosInstance | An axios instance. |
init | Function | - | Initializer helper function. |
refreshToken | Boolean | false | Activation of refresh token. |
csrfToken | Boolean | false | Activation of csrf token. |
initialAccessToken | String | - | Initial access token. |
initialRefreshToken | String | - | Initial refresh token. |
initialCsrfToken | String | - | Initial csrf token. |
tokenPathVariants | IPathVariants | Default Path Variants | The paths of all type tokens in response object. |
statusCallbacks | Object | - | Specific events of status codes. |
You need to define your axios instance you want to manage. If no instance is defined, no action will be taken. A log is written to the console at the warning level.
Example:
import axios from 'axios';
<AxiosTokenProvider instance={axios}>
<App />
</AxiosTokenProvider>;
The init prop is a inilizer function for provide extra config to developers.
Example:
function initializer(instance) {
instance.baseURL = 'https://reqres.in/api';
}
<AxiosTokenProvider init={initializer} instance={axios}>
<App />
</AxiosTokenProvider>
You can define all token (access, refresh or csrf) paths to this prop.
Example:
<AxiosTokenProvider
tokenPathVariants={{
accessToken: ['headers.X-Access-Token', 'data.tokens.access_token'],
refreshToken: ['headers.X-Refresh-Token', 'data.tokens.refresh_token'],
}}
></AxiosTokenProvider>
{
accessToken: ['headers.x-access-token', 'data.access_token'],
csrfToken: ['headers.x-csrf-token', 'headers.x-xsrf-token'],
refreshToken: ['headers.x-refresh-token', 'data.refresh_token'],
}
You can define specific callbacks to response status codes.
Example:
function unauthorized(response) {
location.href = '/login';
}
function forbidden(response) {
// do something
}
<AxiosTokenProvider
statusCallbacks={{
401: unauthorized,
403: forbidden,
}}
></AxiosTokenProvider>
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
FAQs
React Axios Token Provider package is a make easy what repetitive processes.
We found that @atayahmet/react-axios-token-provider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.