marvin-auth-kit
Advanced tools
Comparing version 5.2.2 to 5.2.3
@@ -50,7 +50,9 @@ import axios from "axios"; | ||
} | ||
async function refresh() { | ||
async function refresh(error) { | ||
const { refreshToken } = tokens.get(); | ||
if (!refreshToken) { | ||
console.error("RefreshWithoutRefreshTokenError"); | ||
return; | ||
if (error) | ||
throw error; | ||
throw new Error("Unauthorized"); | ||
} | ||
@@ -111,3 +113,3 @@ try { | ||
_retryCounter++; | ||
await refresh(); | ||
await refresh(error); | ||
const { token } = tokens.get(); | ||
@@ -130,3 +132,5 @@ const retryRequest = { | ||
_retryCounter = 0; | ||
throw error.response.data; | ||
if (error && error.response) | ||
throw error.response; | ||
throw error; | ||
} | ||
@@ -165,2 +169,3 @@ } | ||
//ignore error, this only serves as a boolean switch! | ||
return false; | ||
} | ||
@@ -167,0 +172,0 @@ } |
@@ -69,3 +69,3 @@ import axios from "axios"; | ||
// remove ready only && toSerialize props | ||
const { auth_keypair_public, version, metadata_configuration, ...requestBody } = config; | ||
const { auth_keypair_public, metadata_configuration, version, ...requestBody } = config; | ||
try { | ||
@@ -83,3 +83,3 @@ const url = `${fullUrl(_config)}/config`; | ||
}); | ||
return { ..._cachedServerconfig, metadata_configuration }; | ||
return _cachedServerconfig; | ||
} | ||
@@ -86,0 +86,0 @@ else { |
{ | ||
"name": "marvin-auth-kit", | ||
"version": "5.2.2", | ||
"version": "5.2.3", | ||
"description": "Javscript authentication kit", | ||
@@ -48,3 +48,3 @@ "main": "dist/index.js", | ||
"mailslurp-client": "^8.7.8", | ||
"react": "^16.13.1", | ||
"react": "^17.0.2", | ||
"ts-jest": "^26.3.0", | ||
@@ -51,0 +51,0 @@ "typescript": "^4.5.4" |
@@ -1,2 +0,7 @@ | ||
import axios, { AxiosRequestConfig, AxiosResponse, AxiosStatic } from "axios"; | ||
import axios, { | ||
AxiosError, | ||
AxiosRequestConfig, | ||
AxiosResponse, | ||
AxiosStatic, | ||
} from "axios"; | ||
@@ -61,3 +66,3 @@ import { AuthAPI, Config, Tokens } from "./types"; | ||
async function refresh(): Promise<Tokens> { | ||
async function refresh(error?: AxiosError): Promise<Tokens> { | ||
const { refreshToken } = tokens.get(); | ||
@@ -67,3 +72,4 @@ | ||
console.error("RefreshWithoutRefreshTokenError"); | ||
return; | ||
if (error) throw error; | ||
throw new Error("Unauthorized"); | ||
} | ||
@@ -124,3 +130,3 @@ | ||
async function responseErrorHandler(error: any): Promise<any> { | ||
async function responseErrorHandler(error: AxiosError): Promise<any> { | ||
if ( | ||
@@ -135,3 +141,3 @@ error && | ||
_retryCounter++; | ||
await refresh(); | ||
await refresh(error); | ||
const { token } = tokens.get(); | ||
@@ -153,3 +159,4 @@ const retryRequest = { | ||
_retryCounter = 0; | ||
throw error.response.data; | ||
if (error && error.response) throw error.response; | ||
throw error; | ||
} | ||
@@ -190,2 +197,3 @@ } | ||
//ignore error, this only serves as a boolean switch! | ||
return false; | ||
} | ||
@@ -192,0 +200,0 @@ } |
@@ -74,3 +74,8 @@ import axios from "axios"; | ||
// remove ready only && toSerialize props | ||
const { auth_keypair_public, version, metadata_configuration, ...requestBody } = config; | ||
const { | ||
auth_keypair_public, | ||
metadata_configuration, | ||
version, | ||
...requestBody | ||
} = config; | ||
try { | ||
@@ -88,4 +93,3 @@ const url = `${fullUrl(_config)}/config`; | ||
}); | ||
return {..._cachedServerconfig, metadata_configuration}; | ||
return _cachedServerconfig; | ||
} else { | ||
@@ -92,0 +96,0 @@ throw response.data; |
150965
4135