diff --git a/lib/pxconfig.js b/lib/pxconfig.js index 575bb589..0bc6e97b 100644 --- a/lib/pxconfig.js +++ b/lib/pxconfig.js @@ -33,7 +33,7 @@ class PxConfig { ['CSS_REF', 'cssRef'], ['CUSTOM_LOGO', 'customLogo'], ['SENSITIVE_ROUTES', 'sensitiveRoutes'], ['WHITELIST_ROUTES', 'whitelistRoutes'], ['DYNAMIC_CONFIGURATIONS', 'dynamicConfigurations'], ['MODULE_MODE', 'moduleMode'], ['FIRST_PARTY_ENABLED', 'firstPartyEnabled'], ['ADDITIONAL_ACTIVITY_HANDLER', 'additionalActivityHandler'], ['ENRICH_CUSTOM_PARAMETERS', 'enrichCustomParameters'], ['TESTING_MODE', 'testingMode'], ['WHITELIST_EXT', 'whitelistExt'], ['BYPASS_MONITOR_HEADER', 'bypassMonitorHeader'], ['ADVANCED_BLOCKING_RESPONSE', 'advancedBlockingResponse'], - ['TELEMETRY_COMMAND_HEADER', 'telemetryCommandHeader']]; + ['TELEMETRY_COMMAND_HEADER', 'telemetryCommandHeader'], ['CUSTOM_TEMPLATE_ROOT', 'customTemplateRoot'], ['CUSTOM_TEMPLATE_DATA', 'customTemplateData']]; configKeyMapping.forEach(([targetKey, sourceKey]) => { this.PX_DEFAULT[targetKey] = PxConfig.configurationsOverriding(this.PX_DEFAULT, params, targetKey, sourceKey); @@ -208,7 +208,9 @@ function pxDefaultConfig(PX_INTERNAL) { WHITELIST_EXT: [], BYPASS_MONITOR_HEADER: '', CONFIG_PATH: '', - ADVANCED_BLOCKING_RESPONSE: true + ADVANCED_BLOCKING_RESPONSE: true, + CUSTOM_TEMPLATE_ROOT: '', + CUSTOM_TEMPLATE_DATA: {} }; } diff --git a/lib/pxenforcer.js b/lib/pxenforcer.js index 69586694..2ea69366 100644 --- a/lib/pxenforcer.js +++ b/lib/pxenforcer.js @@ -329,14 +329,15 @@ class PxEnforcer { hostUrl: hostUrl, jsClientSrc: jsClientSrc, firstPartyEnabled: this._config.FIRST_PARTY_ENABLED, - blockScript: captchaSrc + blockScript: captchaSrc, + customData: this._config.CUSTOM_TEMPLATE_DATA && JSON.stringify(this._config.CUSTOM_TEMPLATE_DATA) }; } compileMustache(template, props, cb) { let htmlTemplate = ''; - mu.root = `${__dirname}/templates`; + mu.root = this._config.CUSTOM_TEMPLATE_ROOT || `${__dirname}/templates`; const compile = mu.compileAndRender(`${template}.mustache`, props); // Building html from template into string variable