node-iframe
Advanced tools
Comparing version 1.4.2 to 1.4.4
@@ -64,3 +64,4 @@ "use strict"; | ||
exports.appSourceConfig = appSourceConfig; | ||
function manipulateSource(_, src, url, $html) { | ||
function manipulateSource(_a, src, url, $html) { | ||
var key = _a.key, attribute = _a.attribute; | ||
if (src) { | ||
@@ -86,3 +87,3 @@ var trailing_1 = src && src[0] === "/"; | ||
source = _a.sent(); | ||
$html("script[src=\"" + src + "\"]").html(source); | ||
$html(key + "[" + attribute + "=\"" + src + "\"]").html(source); | ||
return [2]; | ||
@@ -108,2 +109,14 @@ } | ||
} | ||
var getInlineAttribute = function (key) { | ||
var attribute; | ||
switch (key) { | ||
case "link": | ||
attribute = "href"; | ||
break; | ||
default: | ||
attribute = "src"; | ||
break; | ||
} | ||
return attribute; | ||
}; | ||
function renderHtml(_a, server) { | ||
@@ -113,3 +126,3 @@ var url = _a.url, baseHref = _a.baseHref, config = _a.config; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var cachedHtml, e_1, _b, inline, cors, inlineScripts, inlineLinks, corsScripts, response, html, $html_1, e_2; | ||
var cachedHtml, e_1, _b, inline, cors, response, html, $html_1, e_2; | ||
return __generator(this, function (_c) { | ||
@@ -141,4 +154,2 @@ switch (_c.label) { | ||
}, inline = _b.inline, cors = _b.cors; | ||
inlineScripts = inline.script, inlineLinks = inline.link; | ||
corsScripts = cors.script; | ||
_c.label = 5; | ||
@@ -160,15 +171,15 @@ case 5: | ||
} | ||
if (inlineScripts) { | ||
$html_1("script").attr("src", function (i, src) { | ||
return manipulateSource(i, src, url, $html_1); | ||
}); | ||
} | ||
if (inlineLinks) { | ||
$html_1("link").attr("href", function (i, src) { | ||
return manipulateSource(i, src, url, $html_1); | ||
}); | ||
} | ||
if (corsScripts) { | ||
$html_1("script").attr("crossorigin", corsScripts); | ||
} | ||
Object.keys(inline).forEach(function (key) { | ||
if (inline[key]) { | ||
var attribute_1 = getInlineAttribute(key); | ||
$html_1(key).attr(attribute_1, function (_, src) { | ||
return manipulateSource({ key: key, attribute: attribute_1 }, src, url, $html_1); | ||
}); | ||
} | ||
}); | ||
Object.keys(cors).forEach(function (key) { | ||
if (cors[key]) { | ||
$html_1(key).attr("crossorigin", cors[key]); | ||
} | ||
}); | ||
if (!config_1.cacheConfig.disabled && (cache_1.appCache === null || cache_1.appCache === void 0 ? void 0 : cache_1.appCache.set)) { | ||
@@ -190,18 +201,2 @@ cache_1.appCache.set(url, $html_1.html()); | ||
} | ||
function createIframe(req, res, next) { | ||
var _this = this; | ||
res.createIframe = function (model) { return __awaiter(_this, void 0, void 0, function () { | ||
var $html; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, renderHtml(model, true)]; | ||
case 1: | ||
$html = _a.sent(); | ||
res.status(($html === null || $html === void 0 ? void 0 : $html.status) || 200).send($html.html()); | ||
return [2]; | ||
} | ||
}); | ||
}); }; | ||
next(); | ||
} | ||
function fetchFrame(model) { | ||
@@ -228,3 +223,19 @@ return __awaiter(this, void 0, void 0, function () { | ||
exports.configureResourceControl = configureResourceControl; | ||
function createIframe(req, res, next) { | ||
var _this = this; | ||
res.createIframe = function (model) { return __awaiter(_this, void 0, void 0, function () { | ||
var $html; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, renderHtml(model, true)]; | ||
case 1: | ||
$html = _a.sent(); | ||
res.status(($html === null || $html === void 0 ? void 0 : $html.status) || 200).send($html.html()); | ||
return [2]; | ||
} | ||
}); | ||
}); }; | ||
next(); | ||
} | ||
exports["default"] = createIframe; | ||
//# sourceMappingURL=iframe.js.map |
{ | ||
"name": "node-iframe", | ||
"version": "1.4.2", | ||
"version": "1.4.4", | ||
"description": "create a iframe on your server to bypass CORS issues. ( reverse engineer security issues )", | ||
@@ -5,0 +5,0 @@ "main": "dist/iframe.js", |
@@ -13,3 +13,3 @@ # node-iframe | ||
On your server if using with express | ||
as express middleware | ||
@@ -46,3 +46,3 @@ ```typescript | ||
Configure how to handle resources for all request can be controlled top level or scoped. | ||
Configure how to handle resources for all request | ||
@@ -49,0 +49,0 @@ ```typescript |
import { configureTemplates } from "@app/templates"; | ||
import { configureCacheControl } from "@app/cache"; | ||
declare type CorsResourceType = "anonymous" | "use-credentials" | boolean; | ||
interface InlineElementsConfig { | ||
@@ -7,3 +8,2 @@ script?: boolean; | ||
} | ||
declare type CorsResourceType = "anonymous" | "use-credentials" | boolean; | ||
interface CorsElementsConfig { | ||
@@ -33,6 +33,6 @@ audio?: CorsResourceType; | ||
}; | ||
declare function createIframe(req: any, res: any, next: any): void; | ||
declare function fetchFrame(model: any): Promise<any>; | ||
declare function configureResourceControl(appConfig: RenderHtmlConfig): void; | ||
declare function createIframe(req: any, res: any, next: any): void; | ||
export { appSourceConfig, configureResourceControl, configureTemplates, configureCacheControl, fetchFrame, }; | ||
export default createIframe; |
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
41803
637