Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 34 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axios-auth-refresh",
"version": "3.3.6",
"version": "4.0.0",
"description": "Axios plugin which makes it very easy to automatically refresh the authorization tokens of your clients",
"keywords": [
"axios",
Expand Down Expand Up @@ -28,11 +28,11 @@
"prepare": "husky install"
},
"peerDependencies": {
"axios": ">= 0.18 < 0.19.0 || >= 0.19.1"
"axios": ">= 1.6.0"
},
"devDependencies": {
"@types/jest": "^28.1.6",
"axios": "^1.2.2",
"axios": "^1.6.0",
"babel-loader": "^9.1.0",
"clean-webpack-plugin": "^4.0.0",
"declaration-bundler-webpack-plugin": "^1.0.3",
Expand All @@ -45,7 +45,8 @@
"ts-loader": "^9.3.1",
"typescript": "^4.9.4",
"webpack": "^5.73.0",
"webpack-cli": "^5.0.1"
"webpack-cli": "^5.0.1",
"@types/node": "~20.8.10"
},
"files": [
"dist",
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosAuthRefreshCache, AxiosAuthRefreshRequestConfig } from '../model';
import axios, { AxiosRequestConfig, AxiosStatic } from 'axios';
import axios, { InternalAxiosRequestConfig, AxiosStatic } from 'axios';
import createAuthRefreshInterceptor, { AxiosAuthRefreshOptions } from '../index';
import {
unsetCache,
Expand Down Expand Up @@ -329,7 +329,7 @@ describe('Requests interceptor', () => {

it('calls the onRetry callback before retrying the request', async () => {
const instance = axios.create();
const onRetry = jest.fn((requestConfig: AxiosRequestConfig) => requestConfig);
const onRetry = jest.fn((requestConfig: InternalAxiosRequestConfig) => requestConfig);
createRequestQueueInterceptor(instance, cache, { onRetry });
createRefreshCall(
{},
Expand All @@ -347,7 +347,7 @@ describe('Requests interceptor', () => {
describe('Response interceptor', () => {
it('uses the request interceptor to call the onRetry callback before retrying the request', async () => {
const instance = axios.create();
const onRetry = jest.fn((requestConfig: AxiosRequestConfig) => {
const onRetry = jest.fn((requestConfig: InternalAxiosRequestConfig) => {
// modify the url to one that will respond with status code 200
return {
...requestConfig,
Expand All @@ -363,7 +363,7 @@ describe('Response interceptor', () => {

it('uses the request interceptor to call the onRetry callback before retrying all the requests', async () => {
const instance = axios.create();
const onRetry = jest.fn((requestConfig: AxiosRequestConfig) => {
const onRetry = jest.fn((requestConfig: InternalAxiosRequestConfig) => {
// modify the url to one that will respond with status code 200
return {
...requestConfig,
Expand Down
8 changes: 5 additions & 3 deletions src/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
import { AxiosError, AxiosInstance, InternalAxiosRequestConfig } from 'axios';

export interface AxiosAuthRefreshOptions {
statusCodes?: Array<number>;
Expand All @@ -11,7 +11,9 @@ export interface AxiosAuthRefreshOptions {
retryInstance?: AxiosInstance;
interceptNetworkError?: boolean;
pauseInstanceWhileRefreshing?: boolean;
onRetry?: (requestConfig: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>;
onRetry?: (
requestConfig: InternalAxiosRequestConfig
) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;

/**
* @deprecated
Expand All @@ -27,6 +29,6 @@ export interface AxiosAuthRefreshCache {
requestQueueInterceptorId: number | undefined;
}

export interface AxiosAuthRefreshRequestConfig extends AxiosRequestConfig {
export interface AxiosAuthRefreshRequestConfig extends InternalAxiosRequestConfig {
skipAuthRefresh?: boolean;
}
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosInstance, AxiosPromise, AxiosRequestConfig } from 'axios';
import axios, { AxiosInstance, AxiosPromise, InternalAxiosRequestConfig } from 'axios';
import { AxiosAuthRefreshOptions, AxiosAuthRefreshCache } from './model';

export interface CustomAxiosRequestConfig extends AxiosRequestConfig {
export interface CustomAxiosRequestConfig extends InternalAxiosRequestConfig {
skipAuthRefresh?: boolean;
}

Expand Down