Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

supertokens-website

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertokens-website - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3

4

CHANGELOG.md

@@ -9,2 +9,6 @@ # Changelog

## [4.1.3] - 2020-04-02
### Changed
- In axios interception, when handling error, we no longer create a new axios instance
## [4.1.2] - 2020-03-20

@@ -11,0 +15,0 @@ ### Changed

2

lib/build/axios.d.ts
import { AxiosPromise, AxiosRequestConfig, AxiosResponse } from "axios";
export declare function interceptorFunctionRequestFulfilled(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
export declare function responseInterceptor(response: AxiosResponse): Promise<AxiosResponse<any>>;
export declare function responseInterceptor(axiosInstance: any): (response: AxiosResponse<any>) => Promise<AxiosResponse<any>>;
/**

@@ -5,0 +5,0 @@ * @class AuthHttpRequest

@@ -222,53 +222,57 @@ "use strict";

exports.interceptorFunctionRequestFulfilled = interceptorFunctionRequestFulfilled;
function responseInterceptor(response) {
return __awaiter(this, void 0, void 0, function() {
var url, idRefreshToken, config, antiCsrfToken;
return __generator(this, function(_a) {
try {
if (!AuthHttpRequest.initCalled) {
throw new Error("init function not called");
}
url = getUrlFromConfig(response.config);
if (typeof url === "string" && _1.getDomainFromUrl(url) !== AuthHttpRequest.apiDomain) {
// this check means that if you are using axios via inteceptor, then we only do the refresh steps if you are calling your APIs.
return [2 /*return*/, response];
}
processState_1.ProcessState.getInstance().addState(
processState_1.PROCESS_STATE.CALLING_INTERCEPTION_RESPONSE
);
idRefreshToken = response.headers["id-refresh-token"];
if (idRefreshToken !== undefined) {
handleSessionExp_1.setIDToCookie(idRefreshToken, AuthHttpRequest.websiteRootDomain);
}
if (response.status === AuthHttpRequest.sessionExpiredStatusCode) {
config = response.config;
return [
2 /*return*/,
AuthHttpRequest.doRequest(
function(config) {
// we create an instance since we don't want to intercept this.
var instance = axios_1.default.create();
return instance(config);
},
config,
url,
response,
true
)
];
} else {
antiCsrfToken = response.headers["anti-csrf"];
if (antiCsrfToken !== undefined) {
_1.AntiCsrfToken.setItem(handleSessionExp_1.getIDFromCookie(), antiCsrfToken);
function responseInterceptor(axiosInstance) {
var _this = this;
return function(response) {
return __awaiter(_this, void 0, void 0, function() {
var url, idRefreshToken, config, antiCsrfToken;
return __generator(this, function(_a) {
try {
if (!AuthHttpRequest.initCalled) {
throw new Error("init function not called");
}
return [2 /*return*/, response];
url = getUrlFromConfig(response.config);
if (typeof url === "string" && _1.getDomainFromUrl(url) !== AuthHttpRequest.apiDomain) {
// this check means that if you are using axios via inteceptor, then we only do the refresh steps if you are calling your APIs.
return [2 /*return*/, response];
}
processState_1.ProcessState.getInstance().addState(
processState_1.PROCESS_STATE.CALLING_INTERCEPTION_RESPONSE
);
idRefreshToken = response.headers["id-refresh-token"];
if (idRefreshToken !== undefined) {
handleSessionExp_1.setIDToCookie(idRefreshToken, AuthHttpRequest.websiteRootDomain);
}
if (response.status === AuthHttpRequest.sessionExpiredStatusCode) {
config = response.config;
return [
2 /*return*/,
AuthHttpRequest.doRequest(
function(config) {
// we create an instance since we don't want to intercept this.
// const instance = axios.create();
// return instance(config);
return axiosInstance(config);
},
config,
url,
response,
true
)
];
} else {
antiCsrfToken = response.headers["anti-csrf"];
if (antiCsrfToken !== undefined) {
_1.AntiCsrfToken.setItem(handleSessionExp_1.getIDFromCookie(), antiCsrfToken);
}
return [2 /*return*/, response];
}
} finally {
if (handleSessionExp_1.getIDFromCookie() === undefined) {
_1.AntiCsrfToken.removeToken();
}
}
} finally {
if (handleSessionExp_1.getIDFromCookie() === undefined) {
_1.AntiCsrfToken.removeToken();
}
}
return [2 /*return*/];
return [2 /*return*/];
});
});
});
};
}

@@ -634,3 +638,3 @@ exports.responseInterceptor = responseInterceptor;

// Add a response interceptor
axiosInstance.interceptors.response.use(responseInterceptor, function(error) {
axiosInstance.interceptors.response.use(responseInterceptor(axiosInstance), function(error) {
return __awaiter(this, void 0, void 0, function() {

@@ -653,4 +657,5 @@ var config;

// we create an instance since we don't want to intercept this.
var instance = axios_1.default.create();
return instance(config);
// const instance = axios.create();
// return instance(config);
return axiosInstance(config);
},

@@ -657,0 +662,0 @@ config,

@@ -1,1 +0,1 @@

export declare const package_version = "4.1.2";
export declare const package_version = "4.1.3";

@@ -17,2 +17,2 @@ "use strict";

*/
exports.package_version = "4.1.2";
exports.package_version = "4.1.3";
{
"name": "supertokens-website",
"version": "4.1.2",
"version": "4.1.3",
"description": "frontend sdk for website to be used for auth solution.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc