Comparing version 3.0.0 to 3.0.1
@@ -51,3 +51,5 @@ "use strict"; | ||
var applyStorage_1 = require("./applyStorage"); | ||
// a little time before expiration to try refresh (seconds) | ||
var ms_1 = __importDefault(require("ms")); | ||
// Token Leeway | ||
// A little time before expiration to try refresh (seconds) | ||
var expireFudge = 10; | ||
@@ -207,4 +209,5 @@ var isRefreshing = false; | ||
var authTokenInterceptor = function (_a) { | ||
var _b = _a.header, header = _b === void 0 ? 'Authorization' : _b, _c = _a.headerPrefix, headerPrefix = _c === void 0 ? 'Bearer ' : _c, requestRefresh = _a.requestRefresh, _d = _a.tokenExpireFudge, tokenExpireFudge = _d === void 0 ? 10 : _d, _e = _a.getStorage, getStorage = _e === void 0 ? getBrowserLocalStorage_1.getBrowserLocalStorage : _e; | ||
expireFudge = tokenExpireFudge; | ||
var _b = _a.header, header = _b === void 0 ? 'Authorization' : _b, _c = _a.headerPrefix, headerPrefix = _c === void 0 ? 'Bearer ' : _c, requestRefresh = _a.requestRefresh, _d = _a.tokenExpireFudge, tokenExpireFudge = _d === void 0 ? '10s' : _d, _e = _a.getStorage, getStorage = _e === void 0 ? getBrowserLocalStorage_1.getBrowserLocalStorage : _e; | ||
expireFudge = | ||
(0, ms_1.default)(typeof tokenExpireFudge === 'string' ? tokenExpireFudge : "".concat(tokenExpireFudge, "s")) / 1000; | ||
(0, applyStorage_1.applyStorage)(getStorage()); | ||
@@ -211,0 +214,0 @@ return function (requestConfig) { return __awaiter(void 0, void 0, void 0, function () { |
import { TokenRefreshRequest } from './TokenRefreshRequest'; | ||
import { StorageType } from './StorageType'; | ||
import { StringValue } from 'ms'; | ||
export interface IAuthTokenInterceptorConfig { | ||
@@ -7,5 +8,9 @@ header?: string; | ||
requestRefresh: TokenRefreshRequest; | ||
tokenExpireFudge?: number; | ||
/** | ||
* | ||
* Token leeway in seconds (or via [`ms`](https://github.com/vercel/ms)) | ||
*/ | ||
tokenExpireFudge?: number | StringValue; | ||
getStorage?: () => StorageType; | ||
} | ||
//# sourceMappingURL=IAuthTokenInterceptorConfig.d.ts.map |
{ | ||
"name": "axios-jwt", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Axios interceptor to store, use, and refresh tokens for authentication.", | ||
@@ -25,3 +25,3 @@ "main": "dist/index.js", | ||
"jest-environment-jsdom": "29.2.2", | ||
"jsonwebtoken": "8.5.1", | ||
"jsonwebtoken": "9.0.0", | ||
"prettier": "2.7.1", | ||
@@ -41,3 +41,4 @@ "ts-jest": "29.0.3", | ||
"dependencies": { | ||
"jwt-decode": "3.1.2" | ||
"jwt-decode": "3.1.2", | ||
"ms": "^3.0.0-canary.1" | ||
}, | ||
@@ -44,0 +45,0 @@ "scripts": { |
@@ -13,4 +13,6 @@ import type { AxiosRequestConfig } from 'axios' | ||
import { applyStorage } from './applyStorage' | ||
import ms from 'ms' | ||
// a little time before expiration to try refresh (seconds) | ||
// Token Leeway | ||
// A little time before expiration to try refresh (seconds) | ||
let expireFudge = 10 | ||
@@ -174,6 +176,7 @@ | ||
requestRefresh, | ||
tokenExpireFudge = 10, | ||
tokenExpireFudge = '10s', | ||
getStorage = getBrowserLocalStorage, | ||
}: IAuthTokenInterceptorConfig) => { | ||
expireFudge = tokenExpireFudge | ||
expireFudge = | ||
ms(typeof tokenExpireFudge === 'string' ? tokenExpireFudge : `${tokenExpireFudge}s`) / 1000 | ||
applyStorage(getStorage()) | ||
@@ -180,0 +183,0 @@ |
import { TokenRefreshRequest } from './TokenRefreshRequest' | ||
import { StorageType } from './StorageType' | ||
import { StringValue } from 'ms' | ||
@@ -8,4 +9,8 @@ export interface IAuthTokenInterceptorConfig { | ||
requestRefresh: TokenRefreshRequest | ||
tokenExpireFudge?: number | ||
/** | ||
* | ||
* Token leeway in seconds (or via [`ms`](https://github.com/vercel/ms)) | ||
*/ | ||
tokenExpireFudge?: number | StringValue | ||
getStorage?: () => StorageType | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98144
1759
4
+ Addedms@^3.0.0-canary.1
+ Addedms@3.0.0-canary.1(transitive)