supertokens-website
Advanced tools
Comparing version 16.0.5 to 16.0.6
@@ -10,2 +10,7 @@ # Changelog | ||
## [16.0.6] - 2023-04-18 | ||
### Fixes | ||
- Refactored XMLHttpRequest interceptor to fix a possible issue timing issue: https://github.com/supertokens/supertokens-website/issues/208 | ||
## [16.0.5] - 2023-04-13 | ||
@@ -12,0 +17,0 @@ |
@@ -1,2 +0,2 @@ | ||
export declare const package_version = "16.0.5"; | ||
export declare const package_version = "16.0.6"; | ||
export declare const supported_fdi: string[]; |
@@ -18,3 +18,3 @@ "use strict"; | ||
*/ | ||
exports.package_version = "16.0.5"; | ||
exports.package_version = "16.0.6"; | ||
exports.supported_fdi = ["1.16"]; |
@@ -156,6 +156,5 @@ "use strict"; | ||
function addInterceptorsToXMLHttpRequest() { | ||
var firstEventLoopDone = false; | ||
setTimeout(function () { | ||
return (firstEventLoopDone = true); | ||
}, 0); | ||
var firstEventLoopDone = new Promise(function (res) { | ||
return setTimeout(res, 0); | ||
}); | ||
var oldXMLHttpRequest = XMLHttpRequest; | ||
@@ -167,11 +166,8 @@ (0, logger_1.logDebugMessage)("addInterceptorsToXMLHttpRequest called"); | ||
var actual = new oldXMLHttpRequest(); | ||
var delayActualCalls = !firstEventLoopDone; | ||
var delayedQueue = firstEventLoopDone; | ||
function delayIfNecessary(cb) { | ||
if (delayActualCalls) { | ||
setTimeout(function () { | ||
cb(); | ||
}, 0); | ||
} else { | ||
cb(); | ||
} | ||
delayedQueue = delayedQueue.finally(function () { | ||
var _a; | ||
return (_a = cb()) === null || _a === void 0 ? void 0 : _a.catch(console.error); | ||
}); | ||
} | ||
@@ -375,5 +371,2 @@ var self = this; | ||
var args = arguments; | ||
listOfFunctionCallsInProxy.push(function (xhr) { | ||
xhr.open.apply(xhr, args); | ||
}); | ||
// method = m; | ||
@@ -410,6 +403,9 @@ url = u; | ||
} | ||
// here we use the apply syntax cause there are other optional args that | ||
// can be passed by the user. | ||
delayIfNecessary(function () { | ||
return actual.open.apply(actual, args); | ||
listOfFunctionCallsInProxy.push(function (xhr) { | ||
xhr.open.apply(xhr, args); | ||
}); | ||
// here we use the apply syntax cause there are other optional args that | ||
// can be passed by the user. | ||
actual.open.apply(actual, args); | ||
}); | ||
@@ -423,2 +419,3 @@ }; | ||
var _this = this; | ||
(0, logger_1.logDebugMessage)("XHRInterceptor.setRequestHeader: Called with ".concat(name)); | ||
if (doNotDoInterception) { | ||
@@ -435,3 +432,3 @@ delayIfNecessary(function () { | ||
} | ||
void (function () { | ||
delayIfNecessary(function () { | ||
return __awaiter(_this, void 0, void 0, function () { | ||
@@ -443,2 +440,4 @@ var accessToken; | ||
if (!(name.toLowerCase() === "authorization")) return [3 /*break*/, 2]; | ||
(0, | ||
logger_1.logDebugMessage)("XHRInterceptor.setRequestHeader: checking if user provided auth header matches local token"); | ||
return [4 /*yield*/, (0, fetch_1.getTokenForHeaderAuth)("access")]; | ||
@@ -463,5 +462,3 @@ case 1: | ||
requestHeaders.push({ name: name, value: value }); | ||
delayIfNecessary(function () { | ||
return actual.setRequestHeader(name, value); | ||
}); | ||
actual.setRequestHeader(name, value); | ||
return [2 /*return*/]; | ||
@@ -471,5 +468,2 @@ } | ||
}); | ||
})().catch(function (err) { | ||
// This should basically never happen: it'd mean that getCookie threw an error | ||
console.error("An error occured during setRequestHeader: ", err); | ||
}); | ||
@@ -476,0 +470,0 @@ }; |
{ | ||
"name": "supertokens-website", | ||
"version": "16.0.5", | ||
"version": "16.0.6", | ||
"description": "frontend sdk for website to be used for auth solution.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
374568
7407