From 5a37f61816160996109055c9a14838a1a692b054 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 17 Mar 2026 18:49:12 +0200 Subject: [PATCH 01/10] make async `prepareRequestOptions` --- lib/request.js | 3 +- lib/utils.js | 256 +++++++++++++++++++++++++------------------------ 2 files changed, 135 insertions(+), 124 deletions(-) diff --git a/lib/request.js b/lib/request.js index 15b4f40c8..d7448b2d4 100644 --- a/lib/request.js +++ b/lib/request.js @@ -162,7 +162,8 @@ export default function(options, iframely_options, callback) { url: options.uri }); - fetchData(utils.prepareRequestOptions(options, iframely_options)) + utils.prepareRequestOptions(options, iframely_options) + .then(request_options => fetchData(request_options)) .then(result => { finish(null, result); }) diff --git a/lib/utils.js b/lib/utils.js index 418d98624..0e4a78f86 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -82,99 +82,104 @@ export function getMaxCacheTTL(url, options, default_min_ttl) { }; export function prepareRequestOptions(request_options, options) { + return new Promise((resolve, reject) => { + try { + if (request_options.url && !request_options.uri) { + request_options.uri = request_options.url; + } + var uri = request_options.uri; + delete request_options.url; - if (request_options.url && !request_options.uri) { - request_options.uri = request_options.url; - } - var uri = request_options.uri; - delete request_options.url; + var disable_language = false; - var disable_language = false; + function setPrerender(prerender_option) { + if (options?.allowPrerender && CONFIG.PRERENDER_URL) { + request_options.uri = CONFIG.PRERENDER_URL + encodeURIComponent(uri); + + // Use string `proxy.prerender` as additional prerender param. + if (typeof prerender_option === 'string') { + request_options.uri += (request_options.uri.indexOf('?') > -1 ? '&' : '?' ) + `prerender=${prerender_option}`; + } + } + } - function setPrerender(prerender_option) { - if (options?.allowPrerender && CONFIG.PRERENDER_URL) { - request_options.uri = CONFIG.PRERENDER_URL + encodeURIComponent(uri); - - // Use string `proxy.prerender` as additional prerender param. - if (typeof prerender_option === 'string') { - request_options.uri += (request_options.uri.indexOf('?') > -1 ? '&' : '?' ) + `prerender=${prerender_option}`; + var enable_domain_prerender = options?.getDomainOptions && options.getDomainOptions('meta.prerender'); + if (enable_domain_prerender) { + setPrerender(enable_domain_prerender); } - } - } - var enable_domain_prerender = options?.getDomainOptions && options.getDomainOptions('meta.prerender'); - if (enable_domain_prerender) { - setPrerender(enable_domain_prerender); - } + if (CONFIG.PROXY || (options && options.proxy)) { - if (CONFIG.PROXY || (options && options.proxy)) { + var proxy = (options && options.proxy) || getCustomProxyForUri(uri, options); + if (proxy) { + if (!enable_domain_prerender && proxy.prerender && options?.allowPrerender) { + setPrerender(proxy.prerender); - var proxy = (options && options.proxy) || getCustomProxyForUri(uri, options); - if (proxy) { - if (!enable_domain_prerender && proxy.prerender && options?.allowPrerender) { - setPrerender(proxy.prerender); - - } else if (proxy.proxy && CONFIG.PROXY_URL) { - request_options.uri = /{url}/.test(CONFIG.PROXY_URL) - ? CONFIG.PROXY_URL.replace(/{url}/, encodeURIComponent(uri)) - : CONFIG.PROXY_URL + encodeURIComponent(uri); - } else if (proxy.proxy_url && /{url}/.test(proxy.proxy_url)) { - request_options.uri = proxy.proxy_url.replace(/{url}/, encodeURIComponent(uri)); - } - if (proxy.user_agent) { - request_options.headers = request_options.headers || {}; - request_options.headers['User-Agent'] = proxy.user_agent; - } - if (proxy.headers) { - request_options.headers = request_options.headers || {}; - Object.assign(request_options.headers, proxy.headers) - } - if (proxy.request_options) { - Object.assign(request_options, proxy.request_options); - } - if (proxy.disable_http2) { - request_options.disable_http2 = true; - } - if (proxy.disable_language) { - disable_language = true; - } - if (options && proxy.maxredirects && (!options.redirectsHistory || options.redirectsHistory.length === 0)) { - options.maxRedirects = proxy.maxredirects; - } - if (proxy && proxy.timeout > 0) { - request_options.timeout = proxy.timeout > 100 ? proxy.timeout : proxy.timeout * 1000; + } else if (proxy.proxy && CONFIG.PROXY_URL) { + request_options.uri = /{url}/.test(CONFIG.PROXY_URL) + ? CONFIG.PROXY_URL.replace(/{url}/, encodeURIComponent(uri)) + : CONFIG.PROXY_URL + encodeURIComponent(uri); + } else if (proxy.proxy_url && /{url}/.test(proxy.proxy_url)) { + request_options.uri = proxy.proxy_url.replace(/{url}/, encodeURIComponent(uri)); + } + if (proxy.user_agent) { + request_options.headers = request_options.headers || {}; + request_options.headers['User-Agent'] = proxy.user_agent; + } + if (proxy.headers) { + request_options.headers = request_options.headers || {}; + Object.assign(request_options.headers, proxy.headers) + } + if (proxy.request_options) { + Object.assign(request_options, proxy.request_options); + } + if (proxy.disable_http2) { + request_options.disable_http2 = true; + } + if (proxy.disable_language) { + disable_language = true; + } + if (options && proxy.maxredirects && (!options.redirectsHistory || options.redirectsHistory.length === 0)) { + options.maxRedirects = proxy.maxredirects; + } + if (proxy && proxy.timeout > 0) { + request_options.timeout = proxy.timeout > 100 ? proxy.timeout : proxy.timeout * 1000; + } + } } - } - } - if (options && options.getProviderOptions - && (options.getProviderOptions('app.name') || options.getProviderOptions('app.ua_extension')) - && request_options.headers - && request_options.headers['User-Agent'] === CONFIG.USER_AGENT) { - - var ext = options.getProviderOptions('app.ua_extension', options.getProviderOptions('app.name')); - if ( /^[a-zA-Z0-9\.\s_-]+$/.test(ext) && ext.length > 1) { - ext = ext[0].toUpperCase() + ext.slice(1) - request_options.headers['User-Agent'] += ' ' + ext; - } - } - - var lang = options?.getProviderOptions && options.getProviderOptions('locale') || ''; - if (!disable_language) { - request_options.headers = request_options.headers || {}; - request_options.headers['Accept-Language'] = - lang /* !== '' */ - ? lang.replace('_', '-') - + (/\-/.test(lang) ? `,${lang.replace(/\-.*$/, '')};q=0.9` : '') - + ',en;q=0.7,*;q=0.5' - : 'en,*'; - } + if (options && options.getProviderOptions + && (options.getProviderOptions('app.name') || options.getProviderOptions('app.ua_extension')) + && request_options.headers + && request_options.headers['User-Agent'] === CONFIG.USER_AGENT) { + + var ext = options.getProviderOptions('app.ua_extension', options.getProviderOptions('app.name')); + if ( /^[a-zA-Z0-9\.\s_-]+$/.test(ext) && ext.length > 1) { + ext = ext[0].toUpperCase() + ext.slice(1) + request_options.headers['User-Agent'] += ' ' + ext; + } + } - prepareEncodedUri(request_options, 'uri'); + var lang = options?.getProviderOptions && options.getProviderOptions('locale') || ''; + if (!disable_language) { + request_options.headers = request_options.headers || {}; + request_options.headers['Accept-Language'] = + lang /* !== '' */ + ? lang.replace('_', '-') + + (/\-/.test(lang) ? `,${lang.replace(/\-.*$/, '')};q=0.9` : '') + + ',en;q=0.7,*;q=0.5' + : 'en,*'; + } - setCookieFromJar(uri, request_options.headers, options?.jar) + prepareEncodedUri(request_options, 'uri'); - return request_options; + setCookieFromJar(uri, request_options.headers, options?.jar) + + resolve(request_options); + } catch(ex) { + reject(ex); + } + }); }; /** @@ -207,21 +212,24 @@ export function prepareRequestOptions(request_options, options) { follow = 0; } - var request_options = prepareRequestOptions({ - // Reviewed. - uri: url, - method: 'GET', - headers: { - 'User-Agent': options.user_agent || CONFIG.USER_AGENT, - 'Accept': '*/*' - }, - timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, - redirect: redirect, - follow: follow - }, options); - try { - fetchStreamKeepAlive(request_options) + var request_options; + prepareRequestOptions({ + // Reviewed. + uri: url, + method: 'GET', + headers: { + 'User-Agent': options.user_agent || CONFIG.USER_AGENT, + 'Accept': '*/*' + }, + timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, + redirect: redirect, + follow: follow + }, options) + .then(_request_options => { + request_options = _request_options; + return fetchStreamKeepAlive(request_options) + }) .then(stream => { // Custom inner redirect logic with cookies. @@ -281,23 +289,26 @@ var getHead = function(url, options, callbacks) { follow = 0; } - var request_options = prepareRequestOptions({ - // jar: jar, - - // Reviewed. - uri: url, - method: 'HEAD', - headers: { - 'User-Agent': CONFIG.USER_AGENT - }, - timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, - redirect: redirect, - follow: follow - // No abort controller for head. - }, options); - try { - fetchStreamAuthorized(request_options) + var request_options; + prepareRequestOptions({ + // jar: jar, + + // Reviewed. + uri: url, + method: 'HEAD', + headers: { + 'User-Agent': CONFIG.USER_AGENT + }, + timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, + redirect: redirect, + follow: follow + // No abort controller for head. + }, options) + .then(_request_options => { + request_options = _request_options; + return fetchStreamAuthorized(request_options); + }) .then(response => { callbacks.onResponse && callbacks.onResponse(response, request_options); }) @@ -1237,19 +1248,18 @@ export function generateLinksHtml(data, options) { var getUriStatusPrivate = function(uri, options, cb) { - var request_options = prepareRequestOptions({ - // Reviewed. - uri: uri, - method: 'GET', - headers: { - 'User-Agent': CONFIG.USER_AGENT - }, - timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, - follow: CONFIG.MAX_REDIRECTS - }); - try { - fetchStream(request_options) + prepareRequestOptions({ + // Reviewed. + uri: uri, + method: 'GET', + headers: { + 'User-Agent': CONFIG.USER_AGENT + }, + timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, + follow: CONFIG.MAX_REDIRECTS + }) + .then(request_options => fetchStream(request_options)) .then(res => { // TODO: may cause AbortError before cb. res.abortController.abort(); From d3d7880a9886605b46c5f20b4497f5eea0f29130 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 17 Mar 2026 19:10:03 +0200 Subject: [PATCH 02/10] get custom request headers with `options.getSigHeaders` --- lib/utils.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 0e4a78f86..32826a37d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -88,9 +88,11 @@ export function prepareRequestOptions(request_options, options) { request_options.uri = request_options.url; } var uri = request_options.uri; + var original_uri = uri; delete request_options.url; var disable_language = false; + var request_sig = false; function setPrerender(prerender_option) { if (options?.allowPrerender && CONFIG.PRERENDER_URL) { @@ -145,6 +147,9 @@ export function prepareRequestOptions(request_options, options) { if (proxy && proxy.timeout > 0) { request_options.timeout = proxy.timeout > 100 ? proxy.timeout : proxy.timeout * 1000; } + if (proxy.sig && options.getSigHeaders) { + request_sig = true; + } } } @@ -174,8 +179,22 @@ export function prepareRequestOptions(request_options, options) { prepareEncodedUri(request_options, 'uri'); setCookieFromJar(uri, request_options.headers, options?.jar) + + if (request_sig) { + options.getSigHeaders(original_uri, function(error, headers) { + if (error) { + // Skip error. + resolve(request_options); + } else { + request_options.headers = request_options.headers || {}; + Object.assign(request_options.headers, headers) + resolve(request_options); + } + }); + } else { + resolve(request_options); + } - resolve(request_options); } catch(ex) { reject(ex); } From 20c32e0570b0df8eada8b5f368f7502931849cef Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 17 Mar 2026 19:15:57 +0200 Subject: [PATCH 03/10] request custom headers when `options.sig` --- lib/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 32826a37d..d859cdd09 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -147,7 +147,7 @@ export function prepareRequestOptions(request_options, options) { if (proxy && proxy.timeout > 0) { request_options.timeout = proxy.timeout > 100 ? proxy.timeout : proxy.timeout * 1000; } - if (proxy.sig && options.getSigHeaders) { + if (proxy.sig) { request_sig = true; } } @@ -180,7 +180,7 @@ export function prepareRequestOptions(request_options, options) { setCookieFromJar(uri, request_options.headers, options?.jar) - if (request_sig) { + if ((options.sig || request_sig) && options.getSigHeaders) { options.getSigHeaders(original_uri, function(error, headers) { if (error) { // Skip error. From 8c808beab5ccfb43041d5f8bfba782a514114e0c Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 17 Mar 2026 19:21:12 +0200 Subject: [PATCH 04/10] catch error in `getSigHeaders` --- lib/utils.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index d859cdd09..3137dc9d8 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -181,16 +181,21 @@ export function prepareRequestOptions(request_options, options) { setCookieFromJar(uri, request_options.headers, options?.jar) if ((options.sig || request_sig) && options.getSigHeaders) { - options.getSigHeaders(original_uri, function(error, headers) { - if (error) { - // Skip error. - resolve(request_options); - } else { - request_options.headers = request_options.headers || {}; - Object.assign(request_options.headers, headers) - resolve(request_options); - } - }); + try { + options.getSigHeaders(original_uri, function(error, headers) { + if (error) { + // Skip error. + resolve(request_options); + } else { + request_options.headers = request_options.headers || {}; + Object.assign(request_options.headers, headers); + resolve(request_options); + } + }); + } catch(ex) { + console.error('options.getSigHeaders exception', ex); + resolve(request_options); + } } else { resolve(request_options); } From ef295269b0c07bcd981fe718be39b1476ba7eb64 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 18 Mar 2026 21:26:16 +0200 Subject: [PATCH 05/10] log getSigHeaders error --- lib/utils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/utils.js b/lib/utils.js index 3137dc9d8..5ca62405c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -185,6 +185,7 @@ export function prepareRequestOptions(request_options, options) { options.getSigHeaders(original_uri, function(error, headers) { if (error) { // Skip error. + console.error('getSigHeaders error', error); resolve(request_options); } else { request_options.headers = request_options.headers || {}; From efc0b6486fb1d85d8128696ca6283ab89b2c55a1 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 25 Mar 2026 16:39:42 +0200 Subject: [PATCH 06/10] update user agent workaround --- lib/request.js | 5 ----- lib/utils.js | 20 ++++++++------------ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/request.js b/lib/request.js index d7448b2d4..97634efa4 100644 --- a/lib/request.js +++ b/lib/request.js @@ -152,11 +152,6 @@ export default function(options, iframely_options, callback) { }); } - if (!options.headers || !options.headers['User-Agent']) { - options.headers = options.headers || {}; - options.headers['User-Agent'] = CONFIG.USER_AGENT; - } - iframely_options.registerFetch({ source: 'api', url: options.uri diff --git a/lib/utils.js b/lib/utils.js index 5ca62405c..e300a1ef6 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -110,6 +110,9 @@ export function prepareRequestOptions(request_options, options) { setPrerender(enable_domain_prerender); } + request_options.headers = request_options.headers || {}; + request_options.headers['User-Agent'] = options.user_agent || CONFIG.USER_AGENT; + if (CONFIG.PROXY || (options && options.proxy)) { var proxy = (options && options.proxy) || getCustomProxyForUri(uri, options); @@ -125,7 +128,6 @@ export function prepareRequestOptions(request_options, options) { request_options.uri = proxy.proxy_url.replace(/{url}/, encodeURIComponent(uri)); } if (proxy.user_agent) { - request_options.headers = request_options.headers || {}; request_options.headers['User-Agent'] = proxy.user_agent; } if (proxy.headers) { @@ -153,17 +155,18 @@ export function prepareRequestOptions(request_options, options) { } } - if (options && options.getProviderOptions + // Add user agent extension to default agent if avaliable. + if (options?.getProviderOptions && (options.getProviderOptions('app.name') || options.getProviderOptions('app.ua_extension')) && request_options.headers && request_options.headers['User-Agent'] === CONFIG.USER_AGENT) { var ext = options.getProviderOptions('app.ua_extension', options.getProviderOptions('app.name')); - if ( /^[a-zA-Z0-9\.\s_-]+$/.test(ext) && ext.length > 1) { + if (/^[a-zA-Z0-9\.\s_-]+$/.test(ext) && ext.length > 1) { ext = ext[0].toUpperCase() + ext.slice(1) request_options.headers['User-Agent'] += ' ' + ext; - } - } + } + } var lang = options?.getProviderOptions && options.getProviderOptions('locale') || ''; if (!disable_language) { @@ -244,7 +247,6 @@ export function prepareRequestOptions(request_options, options) { uri: url, method: 'GET', headers: { - 'User-Agent': options.user_agent || CONFIG.USER_AGENT, 'Accept': '*/*' }, timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, @@ -322,9 +324,6 @@ var getHead = function(url, options, callbacks) { // Reviewed. uri: url, method: 'HEAD', - headers: { - 'User-Agent': CONFIG.USER_AGENT - }, timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, redirect: redirect, follow: follow @@ -1278,9 +1277,6 @@ var getUriStatusPrivate = function(uri, options, cb) { // Reviewed. uri: uri, method: 'GET', - headers: { - 'User-Agent': CONFIG.USER_AGENT - }, timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, follow: CONFIG.MAX_REDIRECTS }) From f5189bf99c6752a5f747346dc00a362dab13f2c2 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 25 Mar 2026 21:22:09 +0200 Subject: [PATCH 07/10] tests: allow use getSigHeaders --- lib/utils.js | 1 + modules/tests-ui/tester.js | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index e300a1ef6..740829897 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -193,6 +193,7 @@ export function prepareRequestOptions(request_options, options) { } else { request_options.headers = request_options.headers || {}; Object.assign(request_options.headers, headers); + console.log('--- debug used headers', request_options.headers); resolve(request_options); } }); diff --git a/modules/tests-ui/tester.js b/modules/tests-ui/tester.js index fd85e264f..72b888493 100644 --- a/modules/tests-ui/tester.js +++ b/modules/tests-ui/tester.js @@ -16,6 +16,8 @@ import { run as iframely } from '../../lib/core.js'; import * as whitelist from '../../lib/whitelist.js'; import * as pluginLoader from '../../lib/loader/pluginLoader.js'; import { difference } from '../../utils.js'; +import { fetchData } from '../../lib/fetch.js'; + var plugins = pluginLoader._plugins; var testOnePlugin = false; @@ -60,6 +62,26 @@ function cerror() { } } +function getSigHeaders(url, cb) { + const sigUrl = new URL(CONFIG.SIG_API); + sigUrl.searchParams.append('url', url); + fetchData({ + uri: sigUrl, + json: true + }) + .then(result => { + console.log('-- got sig headers ', result) + cb(null, result); + }) + .catch(cb);; +} + +function getSigHeadersFunction() { + if (CONFIG.SIG_API) { + return getSigHeaders; + } +} + function updateObsoletePluginTests(providersIds, cb) { PluginTest.updateMany({ _id: { @@ -540,7 +562,8 @@ function processPluginTests(pluginTest, plugin, count, cb) { refresh: true, readability: true, disableHttp2: disableHttp2, - getWhitelistRecord: whitelist.findWhitelistRecordFor + getWhitelistRecord: whitelist.findWhitelistRecordFor, + getSigHeaders: getSigHeadersFunction() }, callback); }, CONFIG.tests.pause_between_tests || 0); } From e6dfc31c879b9c50a2c1b850efdc6e649c661c16 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 25 Mar 2026 21:37:18 +0200 Subject: [PATCH 08/10] use getSigHeaders --- modules/tests-ui/tester.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/tests-ui/tester.js b/modules/tests-ui/tester.js index 72b888493..89f479008 100644 --- a/modules/tests-ui/tester.js +++ b/modules/tests-ui/tester.js @@ -70,8 +70,8 @@ function getSigHeaders(url, cb) { json: true }) .then(result => { - console.log('-- got sig headers ', result) - cb(null, result); + console.log('-- got sig headers ', result.data) + cb(null, result.data); }) .catch(cb);; } @@ -563,7 +563,8 @@ function processPluginTests(pluginTest, plugin, count, cb) { readability: true, disableHttp2: disableHttp2, getWhitelistRecord: whitelist.findWhitelistRecordFor, - getSigHeaders: getSigHeadersFunction() + getSigHeaders: getSigHeadersFunction(), + sig: !!CONFIG.SIG_API }, callback); }, CONFIG.tests.pause_between_tests || 0); } From 7710f78f093c6ec44db66a2d12effd769afa4501 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 25 Mar 2026 22:05:12 +0200 Subject: [PATCH 09/10] debugger: use `getSigHeaders` --- modules/api/utils.js | 24 +++++++++++++++++++++++- modules/api/views.js | 4 +++- modules/tests-ui/tester.js | 22 +--------------------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/modules/api/utils.js b/modules/api/utils.js index e80324508..8415e90d2 100644 --- a/modules/api/utils.js +++ b/modules/api/utils.js @@ -1,3 +1,5 @@ +import { fetchData } from "../../lib/fetch"; + var _RE = /^_.+/; export function getProviderOptionsQuery(query) { @@ -54,4 +56,24 @@ export function getProviderOptionsFromQuery(query) { } return providerOptions; -} \ No newline at end of file +} + +function getSigHeaders(url, cb) { + const sigUrl = new URL(CONFIG.SIG_API); + sigUrl.searchParams.append('url', url); + fetchData({ + uri: sigUrl, + json: true + }) + .then(result => { + console.log('-- got sig headers ', result.data) + cb(null, result.data); + }) + .catch(cb);; +} + +export function getSigHeadersFunction() { + if (CONFIG.SIG_API) { + return getSigHeaders; + } +} diff --git a/modules/api/views.js b/modules/api/views.js index b04c51632..421ab7d85 100644 --- a/modules/api/views.js +++ b/modules/api/views.js @@ -144,7 +144,9 @@ export default function(app) { maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'), promoUri: req.query.promoUri, refresh: getBooleanParam(req, 'refresh'), - providerOptions: getProviderOptionsFromQuery(req.query) + providerOptions: getProviderOptionsFromQuery(req.query), + getSigHeaders: apiUtils.getSigHeadersFunction(), + sig: !!CONFIG.SIG_API }, cb); } diff --git a/modules/tests-ui/tester.js b/modules/tests-ui/tester.js index 89f479008..fae56f129 100644 --- a/modules/tests-ui/tester.js +++ b/modules/tests-ui/tester.js @@ -16,7 +16,7 @@ import { run as iframely } from '../../lib/core.js'; import * as whitelist from '../../lib/whitelist.js'; import * as pluginLoader from '../../lib/loader/pluginLoader.js'; import { difference } from '../../utils.js'; -import { fetchData } from '../../lib/fetch.js'; +import { getSigHeadersFunction } from '../api/utils.js'; var plugins = pluginLoader._plugins; @@ -62,26 +62,6 @@ function cerror() { } } -function getSigHeaders(url, cb) { - const sigUrl = new URL(CONFIG.SIG_API); - sigUrl.searchParams.append('url', url); - fetchData({ - uri: sigUrl, - json: true - }) - .then(result => { - console.log('-- got sig headers ', result.data) - cb(null, result.data); - }) - .catch(cb);; -} - -function getSigHeadersFunction() { - if (CONFIG.SIG_API) { - return getSigHeaders; - } -} - function updateObsoletePluginTests(providersIds, cb) { PluginTest.updateMany({ _id: { From fa530a2302c4ce5abff392acbe3ecea19ead9008 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 25 Mar 2026 22:08:19 +0200 Subject: [PATCH 10/10] bugfix import --- modules/api/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/api/utils.js b/modules/api/utils.js index 8415e90d2..db4d7ce55 100644 --- a/modules/api/utils.js +++ b/modules/api/utils.js @@ -1,4 +1,4 @@ -import { fetchData } from "../../lib/fetch"; +import { fetchData } from "../../lib/fetch.js"; var _RE = /^_.+/;