node-iframe
Advanced tools
Comparing version 1.4.1 to 1.4.2
"use strict"; | ||
exports.__esModule = true; | ||
exports.configureCacheControl = exports.appCache = void 0; | ||
var config_1 = require("@app/config"); | ||
var config_1 = require("../config"); | ||
var appCache; | ||
exports.appCache = appCache; | ||
function _extractValidNodeCacheOptions(options) { | ||
return Object.keys(options).reduce(function (object, key) { | ||
if (key !== "disabled") { | ||
object[key] = options[key]; | ||
} | ||
return object; | ||
}, {}); | ||
} | ||
function createCache() { | ||
if (!config_1.cacheConfig.disabled) { | ||
var NodeCache = require("node-cache"); | ||
appCache: NodeCache; | ||
exports.appCache = appCache = new NodeCache(_extractValidNodeCacheOptions((appCache === null || appCache === void 0 ? void 0 : appCache.options) || config_1.cacheConfig)); | ||
var Cache = require("node-cache"); | ||
exports.appCache = appCache = new Cache((appCache === null || appCache === void 0 ? void 0 : appCache.options) || config_1.cacheConfig); | ||
} | ||
@@ -24,10 +15,14 @@ } | ||
if ("disabled" in options) { | ||
if (options.disabled) { | ||
exports.appCache = appCache = undefined; | ||
} | ||
var enableCache = config_1.cacheConfig.disabled && !options.disabled; | ||
config_1.cacheConfig.disabled = !!options.disabled; | ||
options.disabled ? (exports.appCache = appCache = undefined) : createCache(); | ||
enableCache && createCache(); | ||
} | ||
if (!config_1.cacheConfig.disabled) { | ||
if (typeof appCache === "undefined") { | ||
if (!appCache) { | ||
exports.appCache = appCache = {}; | ||
} | ||
appCache.options = Object.assign({}, appCache === null || appCache === void 0 ? void 0 : appCache.options, _extractValidNodeCacheOptions(options)); | ||
appCache.options = Object.assign({}, appCache === null || appCache === void 0 ? void 0 : appCache.options, options); | ||
} | ||
@@ -34,0 +29,0 @@ } |
@@ -57,6 +57,6 @@ "use strict"; | ||
var cheerio_1 = require("cheerio"); | ||
var templates_1 = require("@app/templates"); | ||
var templates_1 = require("./templates"); | ||
exports.configureTemplates = templates_1.configureTemplates; | ||
var config_1 = require("@app/config"); | ||
var cache_1 = require("@app/cache"); | ||
var config_1 = require("./config"); | ||
var cache_1 = require("./cache"); | ||
exports.configureCacheControl = cache_1.configureCacheControl; | ||
@@ -169,4 +169,4 @@ var appSourceConfig = config_1.defaultConfig; | ||
} | ||
if (!config_1.cacheConfig.disabled) { | ||
cache_1.appCache === null || cache_1.appCache === void 0 ? void 0 : cache_1.appCache.set(url, $html_1.html()); | ||
if (!config_1.cacheConfig.disabled && (cache_1.appCache === null || cache_1.appCache === void 0 ? void 0 : cache_1.appCache.set)) { | ||
cache_1.appCache.set(url, $html_1.html()); | ||
} | ||
@@ -173,0 +173,0 @@ if (server) { |
@@ -40,3 +40,3 @@ "use strict"; | ||
exports.fetchWithTimestamps = void 0; | ||
var iframe_1 = require("@app/iframe"); | ||
var iframe_1 = require("../iframe"); | ||
var fetchWithTimestamps = function (_a) { | ||
@@ -43,0 +43,0 @@ var url = _a.url, operation = _a.operation, log = _a.log; |
{ | ||
"name": "node-iframe", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "create a iframe on your server to bypass CORS issues. ( reverse engineer security issues )", | ||
@@ -8,3 +8,3 @@ "main": "dist/iframe.js", | ||
"test": "jest", | ||
"prepare": "tsc" | ||
"prepare": "tsc --project tsconfig.json && tscpaths -p tsconfig.json -s ./src -o ./dist" | ||
}, | ||
@@ -30,4 +30,5 @@ "keywords": [ | ||
"ts-jest": "^26.4.1", | ||
"tscpaths": "0.0.9", | ||
"typescript": "^3.7.5" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # node-iframe | ||
`npm install node-iframe` or `yarn add node-iframe` | ||
`npm install node-iframe` | ||
@@ -25,3 +25,3 @@ ## How to use | ||
baseHref: req.query.baseHref, // optional: determine how to control link redirects, | ||
config: JSON.parse(req.query.config), // optional: determine element cors or inlining per route | ||
config: JSON.parse(req.query.config), // optional: determine element cors or inlining #shape src/iframe.ts#L34 | ||
}) | ||
@@ -51,8 +51,8 @@ ); | ||
const { | ||
configureCacheControl, | ||
configureResourceControl, | ||
configureCacheControl, | ||
configureTemplates, | ||
} = require("node-iframe"); | ||
// optional: configure if element should be inlined, cors, etc, this combines with the `config` param | ||
// optional: configure if elements should be inlined, cors, etc, this combines with the `config` param | ||
configureResourceControl({ | ||
@@ -59,0 +59,0 @@ inline: { script: true, link: false }, |
@@ -1,3 +0,3 @@ | ||
import { Options as CacheOptions } from "node-cache"; | ||
interface AppCache extends CacheOptions { | ||
import type { Options } from "node-cache"; | ||
interface AppCache extends Options { | ||
disabled?: boolean; | ||
@@ -4,0 +4,0 @@ } |
Sorry, the diff of this file is not supported yet
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
41377
6
626