node-iframe
Advanced tools
Comparing version 1.5.2 to 1.5.3
@@ -115,9 +115,9 @@ "use strict"; | ||
function renderHtml(_a, server) { | ||
var e_2, _b; | ||
var e_2, _b, e_3, _c, e_4, _d; | ||
var url = _a.url, baseHref = _a.baseHref, config = _a.config; | ||
if (server === void 0) { server = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var cachedHtml, e_3, _c, inline, cors, response, html, $html_1, inlineMutations_2, _d, _e, key, attribute_1, e_2_1, _i, inlineMutations_1, com, key, attribute, src, element, e_4; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
var cachedHtml, e_5, _e, inline, cors, response, html, $html, inlineMutations_2, _f, _g, key, attribute_1, e_2_1, inlineMutations_1, inlineMutations_1_1, com, key, attribute, src, element, e_3_1, _h, _j, key, e_4_1, e_6; | ||
return __generator(this, function (_k) { | ||
switch (_k.label) { | ||
case 0: | ||
@@ -127,8 +127,8 @@ if (!is_url_1["default"](url)) { | ||
} | ||
_f.label = 1; | ||
_k.label = 1; | ||
case 1: | ||
_f.trys.push([1, 3, , 4]); | ||
_k.trys.push([1, 3, , 4]); | ||
return [4, cache_1.appCache.get(url)]; | ||
case 2: | ||
cachedHtml = _f.sent(); | ||
cachedHtml = _k.sent(); | ||
if (cachedHtml) { | ||
@@ -139,13 +139,13 @@ return [2, cheerio_1.load(cachedHtml)]; | ||
case 3: | ||
e_3 = _f.sent(); | ||
console.error(e_3); | ||
e_5 = _k.sent(); | ||
console.error(e_5); | ||
return [3, 4]; | ||
case 4: | ||
_c = { | ||
_e = { | ||
inline: __assign(__assign({}, appSourceConfig.inline), config === null || config === void 0 ? void 0 : config.inline), | ||
cors: __assign(__assign({}, appSourceConfig.cors), config === null || config === void 0 ? void 0 : config.cors) | ||
}, inline = _c.inline, cors = _c.cors; | ||
_f.label = 5; | ||
}, inline = _e.inline, cors = _e.cors; | ||
_k.label = 5; | ||
case 5: | ||
_f.trys.push([5, 25, , 26]); | ||
_k.trys.push([5, 45, , 46]); | ||
return [4, isomorphic_unfetch_1["default"](url, { | ||
@@ -155,23 +155,23 @@ headers: config_1.headers | ||
case 6: | ||
response = _f.sent(); | ||
response = _k.sent(); | ||
return [4, response.text()]; | ||
case 7: | ||
html = _f.sent(); | ||
$html_1 = cheerio_1.load(html); | ||
html = _k.sent(); | ||
$html = cheerio_1.load(html); | ||
if (!!baseHref) { | ||
$html_1("head").prepend("<base target=\"_self\" href=\"" + url + "\">"); | ||
$html("head").prepend("<base target=\"_self\" href=\"" + url + "\">"); | ||
} | ||
inlineMutations_2 = []; | ||
_f.label = 8; | ||
_k.label = 8; | ||
case 8: | ||
_f.trys.push([8, 14, 15, 20]); | ||
_d = __asyncValues(Object.keys(inline)); | ||
_f.label = 9; | ||
case 9: return [4, _d.next()]; | ||
_k.trys.push([8, 14, 15, 20]); | ||
_f = __asyncValues(Object.keys(inline)); | ||
_k.label = 9; | ||
case 9: return [4, _f.next()]; | ||
case 10: | ||
if (!(_e = _f.sent(), !_e.done)) return [3, 13]; | ||
key = _e.value; | ||
if (!(_g = _k.sent(), !_g.done)) return [3, 13]; | ||
key = _g.value; | ||
if (!inline[key]) return [3, 12]; | ||
attribute_1 = "src"; | ||
return [4, $html_1(key).attr(attribute_1, function (_, src) { | ||
return [4, $html(key).attr(attribute_1, function (_, src) { | ||
if (src) { | ||
@@ -183,17 +183,17 @@ inlineMutations_2.push({ key: key, attribute: attribute_1, src: src }); | ||
case 11: | ||
_f.sent(); | ||
_f.label = 12; | ||
_k.sent(); | ||
_k.label = 12; | ||
case 12: return [3, 9]; | ||
case 13: return [3, 20]; | ||
case 14: | ||
e_2_1 = _f.sent(); | ||
e_2_1 = _k.sent(); | ||
e_2 = { error: e_2_1 }; | ||
return [3, 20]; | ||
case 15: | ||
_f.trys.push([15, , 18, 19]); | ||
if (!(_e && !_e.done && (_b = _d["return"]))) return [3, 17]; | ||
return [4, _b.call(_d)]; | ||
_k.trys.push([15, , 18, 19]); | ||
if (!(_g && !_g.done && (_b = _f["return"]))) return [3, 17]; | ||
return [4, _b.call(_f)]; | ||
case 16: | ||
_f.sent(); | ||
_f.label = 17; | ||
_k.sent(); | ||
_k.label = 17; | ||
case 17: return [3, 19]; | ||
@@ -205,35 +205,77 @@ case 18: | ||
case 20: | ||
_i = 0, inlineMutations_1 = inlineMutations_2; | ||
_f.label = 21; | ||
case 21: | ||
if (!(_i < inlineMutations_1.length)) return [3, 24]; | ||
com = inlineMutations_1[_i]; | ||
_k.trys.push([20, 27, 28, 33]); | ||
inlineMutations_1 = __asyncValues(inlineMutations_2); | ||
_k.label = 21; | ||
case 21: return [4, inlineMutations_1.next()]; | ||
case 22: | ||
if (!(inlineMutations_1_1 = _k.sent(), !inlineMutations_1_1.done)) return [3, 26]; | ||
com = inlineMutations_1_1.value; | ||
key = com.key, attribute = com.attribute, src = com.src; | ||
element = key + "[" + attribute + "=\"" + src + "\"]"; | ||
return [4, mutateSource({ key: element, src: src }, url, $html_1)]; | ||
case 22: | ||
_f.sent(); | ||
if (attribute === "src") { | ||
$html_1(element).removeAttr(attribute); | ||
} | ||
_f.label = 23; | ||
return [4, mutateSource({ key: element, src: src }, url, $html)]; | ||
case 23: | ||
_i++; | ||
return [3, 21]; | ||
_k.sent(); | ||
return [4, $html(element).removeAttr(attribute)]; | ||
case 24: | ||
Object.keys(cors).forEach(function (key) { | ||
if (cors[key]) { | ||
$html_1(key).attr("crossorigin", cors[key]); | ||
} | ||
}); | ||
cache_1.appCache.set(url, $html_1.html()); | ||
_k.sent(); | ||
_k.label = 25; | ||
case 25: return [3, 21]; | ||
case 26: return [3, 33]; | ||
case 27: | ||
e_3_1 = _k.sent(); | ||
e_3 = { error: e_3_1 }; | ||
return [3, 33]; | ||
case 28: | ||
_k.trys.push([28, , 31, 32]); | ||
if (!(inlineMutations_1_1 && !inlineMutations_1_1.done && (_c = inlineMutations_1["return"]))) return [3, 30]; | ||
return [4, _c.call(inlineMutations_1)]; | ||
case 29: | ||
_k.sent(); | ||
_k.label = 30; | ||
case 30: return [3, 32]; | ||
case 31: | ||
if (e_3) throw e_3.error; | ||
return [7]; | ||
case 32: return [7]; | ||
case 33: | ||
_k.trys.push([33, 38, 39, 44]); | ||
_h = __asyncValues(Object.keys(cors)); | ||
_k.label = 34; | ||
case 34: return [4, _h.next()]; | ||
case 35: | ||
if (!(_j = _k.sent(), !_j.done)) return [3, 37]; | ||
key = _j.value; | ||
if (cors[key]) { | ||
$html(key).attr("crossorigin", cors[key]); | ||
} | ||
_k.label = 36; | ||
case 36: return [3, 34]; | ||
case 37: return [3, 44]; | ||
case 38: | ||
e_4_1 = _k.sent(); | ||
e_4 = { error: e_4_1 }; | ||
return [3, 44]; | ||
case 39: | ||
_k.trys.push([39, , 42, 43]); | ||
if (!(_j && !_j.done && (_d = _h["return"]))) return [3, 41]; | ||
return [4, _d.call(_h)]; | ||
case 40: | ||
_k.sent(); | ||
_k.label = 41; | ||
case 41: return [3, 43]; | ||
case 42: | ||
if (e_4) throw e_4.error; | ||
return [7]; | ||
case 43: return [7]; | ||
case 44: | ||
cache_1.appCache.set(url, $html.html()); | ||
if (server) { | ||
$html_1.status = 200; | ||
$html.status = 200; | ||
} | ||
return [2, $html_1]; | ||
case 25: | ||
e_4 = _f.sent(); | ||
console.error(e_4); | ||
return [3, 26]; | ||
case 26: return [2, renderErrorHtml({ url: url, server: server, noPage: true })]; | ||
return [2, $html]; | ||
case 45: | ||
e_6 = _k.sent(); | ||
console.error(e_6); | ||
return [3, 46]; | ||
case 46: return [2, renderErrorHtml({ url: url, server: server, noPage: true })]; | ||
} | ||
@@ -240,0 +282,0 @@ }); |
{ | ||
"name": "node-iframe", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "create a iframe on your server to bypass CORS issues. ( reverse engineer security issues )", | ||
@@ -5,0 +5,0 @@ "main": "dist/iframe.js", |
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
46167
727