perimeterx-js-core
Advanced tools
Comparing version
@@ -86,8 +86,9 @@ "use strict"; | ||
ConfigurationBase.prototype.createInternalLogger = function (params) { | ||
return new logger_1.DefaultLogger(params.px_logger_severity, false); | ||
var _a; | ||
return new logger_1.DefaultLogger(params.px_logger_severity, false, (_a = this.logger) === null || _a === void 0 ? void 0 : _a.getLogs()); | ||
}; | ||
ConfigurationBase.prototype.addRemoteConfig = function (remoteConfigParams) { | ||
this.remoteConfigParams = remoteConfigParams; | ||
var mergedParams = __assign(__assign({}, this.staticConfigParams), remote_config_1.RemoteConfigUtils.prepareRemoteConfigParams(remoteConfigParams, this.logger)); | ||
this.configParams = this.createActiveConfiguration(mergedParams, this.defaultConfigParams); | ||
ConfigurationBase.prototype.setRemoteConfigData = function (remoteConfigData) { | ||
this.remoteConfigData = remoteConfigData; | ||
var params = __assign(__assign({}, this.staticConfigParams), remote_config_1.RemoteConfigUtils.prepareRemoteConfigParams(remoteConfigData, this.logger)); | ||
this.configParams = this.createActiveConfiguration(params, this.defaultConfigParams); | ||
}; | ||
@@ -106,3 +107,5 @@ ConfigurationBase.prototype.getActiveConfig = function () { | ||
ConfigurationBase.prototype.getRemoteConfig = function () { | ||
return Object.assign({}, this.remoteConfigParams); | ||
return this.remoteConfigData | ||
? remote_config_1.RemoteConfigUtils.prepareRemoteConfigParams(this.remoteConfigData, this.logger) | ||
: {}; | ||
}; | ||
@@ -109,0 +112,0 @@ Object.defineProperty(ConfigurationBase.prototype, "moduleVersion", { |
@@ -19,3 +19,2 @@ "use strict"; | ||
__exportStar(require("./ConfigurationBase.js"), exports); | ||
__exportStar(require("./ConfigurationBuilderBase.js"), exports); | ||
__exportStar(require("./CustomRequestFunction.js"), exports); | ||
@@ -22,0 +21,0 @@ __exportStar(require("./remote_config/index.js"), exports); |
@@ -21,4 +21,4 @@ "use strict"; | ||
__exportStar(require("./storage_client/index.js"), exports); | ||
__exportStar(require("./DefaultRemoteConfigUpdater.js"), exports); | ||
__exportStar(require("./IRemoteConfigUpdater.js"), exports); | ||
__exportStar(require("./manager/index.js"), exports); | ||
__exportStar(require("./update_parser/index.js"), exports); | ||
__exportStar(require("./RemoteConfigUtils.js"), exports); |
@@ -18,2 +18,2 @@ "use strict"; | ||
__exportStar(require("./RemoteConfigData.js"), exports); | ||
__exportStar(require("./RemoteConfigUpdateRequestData.js"), exports); | ||
__exportStar(require("./RemoteConfigNotifyRequestPayload.js"), exports); |
@@ -23,4 +23,14 @@ "use strict"; | ||
}; | ||
RemoteConfigUtils.prepareRemoteConfigParams = function (remoteConfigParams, logger) { | ||
var remoteConfig = Object.assign({}, remoteConfigParams); | ||
RemoteConfigUtils.prepareRemoteConfigParams = function (_a, logger) { | ||
var version = _a.version, configValue = _a.configValue; | ||
var remoteConfig = { | ||
px_remote_config_version: version, | ||
px_remote_config_enabled: configValue.px_remote_config_enabled, | ||
}; | ||
if (!configValue.px_remote_config_enabled) { | ||
// returning only the version and the fact that remote config is disabled | ||
// so we can report the version on async activities without merging the rest of the remote configs | ||
return remoteConfig; | ||
} | ||
Object.assign(remoteConfig, configValue); | ||
// Remote config receives strings and regexes in separate fields (px_sensitive_routes, px_sensitive_routes_regex) | ||
@@ -27,0 +37,0 @@ // Before initializing a new active configuration, we merge the two into the more generic field (px_sensitive_routes) |
@@ -15,3 +15,2 @@ "use strict"; | ||
exports.DefaultContext = void 0; | ||
var config_1 = require("../config/index.js"); | ||
var blocker_1 = require("../blocker/index.js"); | ||
@@ -27,2 +26,3 @@ var pxhd_1 = require("../pxhd/index.js"); | ||
function DefaultContext(config, request, options) { | ||
this._shouldSendLogs = false; | ||
this.enforcerStartTime = Date.now(); | ||
@@ -45,4 +45,6 @@ this.config = config; | ||
this.reasons = {}; | ||
this.isRemoteConfigUpdateRequest = config_1.RemoteConfigUtils.isRemoteConfigUpdateRequest(request); | ||
this.shouldSendLogs = this.isRemoteConfigUpdateRequest || this.isHeaderBasedLoggerRequest(config, request); | ||
this.remoteConfigUpdateData = { | ||
shouldUpdate: false, | ||
}; | ||
this.shouldSendLogs = this.isHeaderBasedLoggerRequest(config, request); | ||
this.logger = this.createContextLogger(config, this.shouldSendLogs); | ||
@@ -56,2 +58,18 @@ this.requestData = this.createRequestData(config, request, options.cookieParser); | ||
} | ||
Object.defineProperty(DefaultContext.prototype, "shouldSendLogs", { | ||
get: function () { | ||
return this._shouldSendLogs; | ||
}, | ||
set: function (shouldSendLogs) { | ||
if (this._shouldSendLogs === shouldSendLogs) { | ||
return; | ||
} | ||
this._shouldSendLogs = shouldSendLogs; | ||
if (this.logger) { | ||
this.logger.shouldSaveLogs = shouldSendLogs; | ||
} | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(DefaultContext.prototype, "isMobile", { | ||
@@ -152,3 +170,3 @@ get: function () { | ||
isMobile: this.isMobile, | ||
isRemoteConfigUpdateRequest: this.isRemoteConfigUpdateRequest, | ||
remoteConfigUpdateData: this.remoteConfigUpdateData, | ||
productData: this.productData, | ||
@@ -155,0 +173,0 @@ requestData: __assign(__assign({}, this.requestData), { request: undefined, url: this.requestData.url.href }), |
@@ -23,3 +23,4 @@ "use strict"; | ||
__exportStar(require("./ServerData.js"), exports); | ||
__exportStar(require("./RemoteConfigUpdateData.js"), exports); | ||
__exportStar(require("./IContext.js"), exports); | ||
__exportStar(require("./ReadonlyContext.js"), exports); |
@@ -25,3 +25,3 @@ "use strict"; | ||
this.requestId = contextJson.requestId; | ||
this.isRemoteConfigUpdateRequest = contextJson.isRemoteConfigUpdateRequest; | ||
this.remoteConfigUpdateData = contextJson.remoteConfigUpdateData; | ||
this.logger = this.createLogger(config, contextJson.shouldSendLogs, (_a = contextJson.logger) === null || _a === void 0 ? void 0 : _a.logs); | ||
@@ -28,0 +28,0 @@ this.productData = contextJson.productData; |
@@ -62,2 +62,3 @@ "use strict"; | ||
this.activityClient = initializationBlock.activityClient; | ||
this.remoteConfigManager = initializationBlock.remoteConfigManager; | ||
this.filterFlow = this.createFilterFlow(config, initializationBlock); | ||
@@ -95,6 +96,11 @@ this.enforceFlow = this.createEnforceFlow(config, initializationBlock); | ||
var context, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 3, , 4]); | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, ((_a = this.remoteConfigManager) === null || _a === void 0 ? void 0 : _a.loadRemoteConfig())]; | ||
case 1: | ||
_b.sent(); | ||
_b.label = 2; | ||
case 2: | ||
_b.trys.push([2, 5, , 6]); | ||
if (!this.config.moduleEnabled) { | ||
@@ -104,11 +110,11 @@ return [2 /*return*/, null]; | ||
return [4 /*yield*/, this.constructContext.apply(this, args)]; | ||
case 1: | ||
context = _a.sent(); | ||
case 3: | ||
context = _b.sent(); | ||
return [4 /*yield*/, this.doEnforce.apply(this, __spreadArray([context], args, false))]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
case 4: return [2 /*return*/, _b.sent()]; | ||
case 5: | ||
e_1 = _b.sent(); | ||
(context || this.config).logger.error("caught error in enforce - ".concat(e_1)); | ||
return [2 /*return*/, null]; | ||
case 4: return [2 /*return*/]; | ||
case 6: return [2 /*return*/]; | ||
} | ||
@@ -115,0 +121,0 @@ }); |
@@ -14,3 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createEnforcerProducts = exports.createEnforcerInitializationBlock = void 0; | ||
exports.createRemoteConfigClients = exports.createEnforcerProducts = exports.createEnforcerInitializationBlock = void 0; | ||
var risk_token_1 = require("../risk_token/index.js"); | ||
@@ -29,3 +29,3 @@ var config_1 = require("../config/index.js"); | ||
var createEnforcerInitializationBlock = function (config, options) { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
var tokenVersion = config.tokenVersion; | ||
@@ -37,3 +37,3 @@ if (!(0, utils_1.isValidTokenVersion)(tokenVersion)) { | ||
} | ||
var cipherUtils = tokenVersion === risk_token_1.TokenVersion.V2 ? null : (_a = options.cipherUtils) !== null && _a !== void 0 ? _a : null; | ||
var cipherUtils = tokenVersion === risk_token_1.TokenVersion.V2 ? null : ((_a = options.cipherUtils) !== null && _a !== void 0 ? _a : null); | ||
if (tokenVersion === risk_token_1.TokenVersion.V3 && !cipherUtils) { | ||
@@ -60,38 +60,6 @@ throw new utils_1.EnforcerError('error initializing enforcer: token v3 requires cipherUtils'); | ||
var logServiceClient = options.logServiceClient || (config.loggerAuthToken ? new logger_1.HttpLogServiceClient(config, httpClient) : null); | ||
var remoteConfigStorageClient = (_b = options.remoteConfigStorageClient) !== null && _b !== void 0 ? _b : null; | ||
var remoteConfigServiceClient = options.remoteConfigServiceClient || | ||
(config.remoteConfigAuthToken ? new config_1.HttpRemoteConfigServiceClient(config, httpClient) : null); | ||
var remoteConfigUpdater = options.remoteConfigUpdater || | ||
(remoteConfigStorageClient && remoteConfigServiceClient | ||
? new config_1.DefaultRemoteConfigUpdater(config, { | ||
serviceClient: remoteConfigServiceClient, | ||
storageClient: remoteConfigStorageClient, | ||
base64Utils: base64Utils, | ||
hmacUtils: hmacUtils, | ||
}) | ||
: null); | ||
var snippetInjector = (_c = options.snippetInjector) !== null && _c !== void 0 ? _c : null; | ||
var snippetInjector = (_b = options.snippetInjector) !== null && _b !== void 0 ? _b : null; | ||
var snippetRetriever = options.snippetRetriever || (snippetInjector ? new snippet_injection_1.DefaultSnippetRetriever(config) : null); | ||
var allOptions = { | ||
httpClient: httpClient, | ||
base64Utils: base64Utils, | ||
hmacUtils: hmacUtils, | ||
hashUtils: hashUtils, | ||
urlUtils: urlUtils, | ||
ipRangeChecker: ipRangeChecker, | ||
cipherUtils: cipherUtils, | ||
cors: cors, | ||
telemetry: telemetry, | ||
dataEnrichment: dataEnrichment, | ||
graphQLParser: graphQLParser, | ||
tokenParser: tokenParser, | ||
riskApiClient: riskApiClient, | ||
activityClient: activityClient, | ||
logServiceClient: logServiceClient, | ||
remoteConfigStorageClient: remoteConfigStorageClient, | ||
remoteConfigServiceClient: remoteConfigServiceClient, | ||
remoteConfigUpdater: remoteConfigUpdater, | ||
snippetInjector: snippetInjector, | ||
snippetRetriever: snippetRetriever, | ||
}; | ||
var remoteConfigClients = (0, exports.createRemoteConfigClients)(config, options); | ||
var allOptions = __assign({ httpClient: httpClient, base64Utils: base64Utils, hmacUtils: hmacUtils, hashUtils: hashUtils, urlUtils: urlUtils, ipRangeChecker: ipRangeChecker, cipherUtils: cipherUtils, cors: cors, telemetry: telemetry, dataEnrichment: dataEnrichment, graphQLParser: graphQLParser, tokenParser: tokenParser, riskApiClient: riskApiClient, activityClient: activityClient, logServiceClient: logServiceClient, snippetInjector: snippetInjector, snippetRetriever: snippetRetriever }, remoteConfigClients); | ||
var products = (0, exports.createEnforcerProducts)(config, options.products, base64Utils, hashUtils, urlUtils, ipRangeChecker); | ||
@@ -118,1 +86,29 @@ return __assign({ products: products }, allOptions); | ||
exports.createEnforcerProducts = createEnforcerProducts; | ||
var createRemoteConfigClients = function (config, options) { | ||
var _a, _b, _c, _d; | ||
var remoteConfigStorageClient = (_a = options.remoteConfigStorageClient) !== null && _a !== void 0 ? _a : null; | ||
var remoteConfigServiceClient = null; | ||
var remoteConfigManager = null; | ||
var remoteConfigUpdateParser = null; | ||
if (remoteConfigStorageClient) { | ||
remoteConfigServiceClient = | ||
(_b = options.remoteConfigServiceClient) !== null && _b !== void 0 ? _b : new config_1.HttpRemoteConfigServiceClient(config, options.httpClient); | ||
remoteConfigManager = | ||
(_c = options.remoteConfigManager) !== null && _c !== void 0 ? _c : new config_1.DefaultRemoteConfigManager(config, { | ||
serviceClient: remoteConfigServiceClient, | ||
storageClient: remoteConfigStorageClient, | ||
}); | ||
remoteConfigUpdateParser = | ||
(_d = options.remoteConfigUpdateParser) !== null && _d !== void 0 ? _d : new config_1.DefaultNotifyRemoteConfigUpdateParser(config, { | ||
base64Utils: options.base64Utils, | ||
hmacUtils: options.hmacUtils, | ||
}); | ||
} | ||
return { | ||
remoteConfigServiceClient: remoteConfigServiceClient, | ||
remoteConfigManager: remoteConfigManager, | ||
remoteConfigUpdateParser: remoteConfigUpdateParser, | ||
remoteConfigStorageClient: remoteConfigStorageClient, | ||
}; | ||
}; | ||
exports.createRemoteConfigClients = createRemoteConfigClients; |
@@ -20,12 +20,14 @@ "use strict"; | ||
var impl_1 = require("../impl/index.js"); | ||
var impl_2 = require("../impl/index.js"); | ||
var EndEnforcerFlow = /** @class */ (function (_super) { | ||
__extends(EndEnforcerFlow, _super); | ||
function EndEnforcerFlow(config, _a) { | ||
var logServiceClient = _a.logServiceClient, telemetry = _a.telemetry; | ||
var phases = [new impl_2.SendTelemetryActivityPhase(telemetry)]; | ||
var logServiceClient = _a.logServiceClient, telemetry = _a.telemetry, remoteConfigManager = _a.remoteConfigManager; | ||
var phases = [new impl_1.SendTelemetryActivityPhase(telemetry)]; | ||
if (remoteConfigManager) { | ||
phases.push(new impl_1.UpdateRemoteConfigPhase(config, remoteConfigManager)); | ||
} | ||
if (logServiceClient) { | ||
phases.push(new impl_1.SendLogsPhase(config, logServiceClient)); | ||
} | ||
phases.push(new impl_2.ClearLogsPhase()); | ||
phases.push(new impl_1.ClearLogsPhase()); | ||
return _super.call(this, phases) || this; | ||
@@ -32,0 +34,0 @@ } |
@@ -25,3 +25,3 @@ "use strict"; | ||
function FilterFlow(config, _a) { | ||
var httpClient = _a.httpClient, products = _a.products, cors = _a.cors, telemetry = _a.telemetry, remoteConfigUpdater = _a.remoteConfigUpdater; | ||
var httpClient = _a.httpClient, products = _a.products, cors = _a.cors, telemetry = _a.telemetry, remoteConfigUpdateParser = _a.remoteConfigUpdateParser; | ||
var phases = []; | ||
@@ -38,5 +38,4 @@ var firstPartyProducts = FilterFlow.getFirstPartyProducts(products); | ||
phases.push(new impl_1.IdentifyTelemetryRequestPhase(telemetry)); | ||
if (remoteConfigUpdater) { | ||
var updateRemoteConfigPhase = new impl_1.UpdateRemoteConfigPhase(config, remoteConfigUpdater); | ||
phases.push(updateRemoteConfigPhase); | ||
if (remoteConfigUpdateParser) { | ||
phases.push(new impl_1.IdentifyRemoteConfigNotifyRequestPhase(remoteConfigUpdateParser)); | ||
} | ||
@@ -43,0 +42,0 @@ return _super.call(this, phases) || this; |
@@ -33,5 +33,6 @@ "use strict"; | ||
__exportStar(require("./SendLogsPhase.js"), exports); | ||
__exportStar(require("./ClearLogsPhase.js"), exports); | ||
__exportStar(require("./IdentifyRemoteConfigNotifyRequestPhase.js"), exports); | ||
__exportStar(require("./UpdateRemoteConfigPhase.js"), exports); | ||
__exportStar(require("./ClearLogsPhase.js"), exports); | ||
__exportStar(require("./IdentifyTelemetryRequestPhase.js"), exports); | ||
__exportStar(require("./SendTelemetryActivityPhase.js"), exports); |
@@ -41,17 +41,17 @@ "use strict"; | ||
var UpdateRemoteConfigPhase = /** @class */ (function () { | ||
function UpdateRemoteConfigPhase(config, remoteConfigUpdater) { | ||
function UpdateRemoteConfigPhase(config, remoteConfigManager) { | ||
this.config = config; | ||
this.remoteConfigUpdater = remoteConfigUpdater; | ||
this.remoteConfigManager = remoteConfigManager; | ||
} | ||
UpdateRemoteConfigPhase.prototype.execute = function (context) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var isSuccessful; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!this.remoteConfigUpdater.isUpdateRemoteConfigRequest(context)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.remoteConfigUpdater.updateRemoteConfig(context)]; | ||
if (!this.remoteConfigManager.shouldUpdateRemoteConfig(context)) return [3 /*break*/, 2]; | ||
context.shouldSendLogs = true; | ||
return [4 /*yield*/, this.remoteConfigManager.updateRemoteConfig(context)]; | ||
case 1: | ||
isSuccessful = _a.sent(); | ||
return [2 /*return*/, { done: true, response: this.getUpdateConfigResponse(isSuccessful) }]; | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, { done: false }]; | ||
@@ -62,11 +62,4 @@ } | ||
}; | ||
UpdateRemoteConfigPhase.prototype.getUpdateConfigResponse = function (isSuccessful) { | ||
return { | ||
status: isSuccessful ? 200 : 400, | ||
body: isSuccessful ? 'OK' : 'Bad Request', | ||
headers: {}, | ||
}; | ||
}; | ||
return UpdateRemoteConfigPhase; | ||
}()); | ||
exports.UpdateRemoteConfigPhase = UpdateRemoteConfigPhase; |
@@ -17,2 +17,2 @@ "use strict"; | ||
exports.REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/; | ||
exports.CORE_MODULE_VERSION = 'JS Core 0.24.4'; | ||
exports.CORE_MODULE_VERSION = 'JS Core 0.25.0'; |
@@ -9,3 +9,3 @@ import { defaultConfigurationParams } from './defaults/index.js'; | ||
staticConfigParams; | ||
remoteConfigParams; | ||
remoteConfigData; | ||
defaultConfigParams; | ||
@@ -79,11 +79,11 @@ removedParams; | ||
createInternalLogger(params) { | ||
return new DefaultLogger(params.px_logger_severity, false); | ||
return new DefaultLogger(params.px_logger_severity, false, this.logger?.getLogs()); | ||
} | ||
addRemoteConfig(remoteConfigParams) { | ||
this.remoteConfigParams = remoteConfigParams; | ||
const mergedParams = { | ||
setRemoteConfigData(remoteConfigData) { | ||
this.remoteConfigData = remoteConfigData; | ||
const params = { | ||
...this.staticConfigParams, | ||
...RemoteConfigUtils.prepareRemoteConfigParams(remoteConfigParams, this.logger), | ||
...RemoteConfigUtils.prepareRemoteConfigParams(remoteConfigData, this.logger), | ||
}; | ||
this.configParams = this.createActiveConfiguration(mergedParams, this.defaultConfigParams); | ||
this.configParams = this.createActiveConfiguration(params, this.defaultConfigParams); | ||
} | ||
@@ -102,3 +102,5 @@ getActiveConfig() { | ||
getRemoteConfig() { | ||
return Object.assign({}, this.remoteConfigParams); | ||
return this.remoteConfigData | ||
? RemoteConfigUtils.prepareRemoteConfigParams(this.remoteConfigData, this.logger) | ||
: {}; | ||
} | ||
@@ -105,0 +107,0 @@ get moduleVersion() { |
export * from './IConfiguration.js'; | ||
export * from './ConfigurationBase.js'; | ||
export * from './ConfigurationBuilderBase.js'; | ||
export * from './CustomRequestFunction.js'; | ||
@@ -5,0 +4,0 @@ export * from './remote_config/index.js'; |
@@ -5,4 +5,4 @@ export * from './constants.js'; | ||
export * from './storage_client/index.js'; | ||
export * from './DefaultRemoteConfigUpdater.js'; | ||
export * from './IRemoteConfigUpdater.js'; | ||
export * from './manager/index.js'; | ||
export * from './update_parser/index.js'; | ||
export * from './RemoteConfigUtils.js'; |
export * from './RemoteConfigData.js'; | ||
export * from './RemoteConfigUpdateRequestData.js'; | ||
export * from './RemoteConfigNotifyRequestPayload.js'; |
@@ -9,4 +9,13 @@ import { HttpMethod } from '../../http/index.js'; | ||
!!request.headers.get(PUSH_DATA_HMAC_HEADER_NAME); | ||
RemoteConfigUtils.prepareRemoteConfigParams = (remoteConfigParams, logger) => { | ||
const remoteConfig = Object.assign({}, remoteConfigParams); | ||
RemoteConfigUtils.prepareRemoteConfigParams = ({ version, configValue }, logger) => { | ||
const remoteConfig = { | ||
px_remote_config_version: version, | ||
px_remote_config_enabled: configValue.px_remote_config_enabled, | ||
}; | ||
if (!configValue.px_remote_config_enabled) { | ||
// returning only the version and the fact that remote config is disabled | ||
// so we can report the version on async activities without merging the rest of the remote configs | ||
return remoteConfig; | ||
} | ||
Object.assign(remoteConfig, configValue); | ||
// Remote config receives strings and regexes in separate fields (px_sensitive_routes, px_sensitive_routes_regex) | ||
@@ -13,0 +22,0 @@ // Before initializing a new active configuration, we merge the two into the more generic field (px_sensitive_routes) |
@@ -1,2 +0,1 @@ | ||
import { RemoteConfigUtils } from '../config/index.js'; | ||
import { BlockAction } from '../blocker/index.js'; | ||
@@ -13,4 +12,3 @@ import { PXHDSource } from '../pxhd/index.js'; | ||
tokenOrigin; | ||
isRemoteConfigUpdateRequest; | ||
shouldSendLogs; | ||
remoteConfigUpdateData; | ||
requestData; | ||
@@ -39,2 +37,3 @@ tokenData; | ||
shouldSendTelemetry; | ||
_shouldSendLogs = false; | ||
config; | ||
@@ -60,4 +59,6 @@ urlUtils; | ||
this.reasons = {}; | ||
this.isRemoteConfigUpdateRequest = RemoteConfigUtils.isRemoteConfigUpdateRequest(request); | ||
this.shouldSendLogs = this.isRemoteConfigUpdateRequest || this.isHeaderBasedLoggerRequest(config, request); | ||
this.remoteConfigUpdateData = { | ||
shouldUpdate: false, | ||
}; | ||
this.shouldSendLogs = this.isHeaderBasedLoggerRequest(config, request); | ||
this.logger = this.createContextLogger(config, this.shouldSendLogs); | ||
@@ -71,2 +72,14 @@ this.requestData = this.createRequestData(config, request, options.cookieParser); | ||
} | ||
get shouldSendLogs() { | ||
return this._shouldSendLogs; | ||
} | ||
set shouldSendLogs(shouldSendLogs) { | ||
if (this._shouldSendLogs === shouldSendLogs) { | ||
return; | ||
} | ||
this._shouldSendLogs = shouldSendLogs; | ||
if (this.logger) { | ||
this.logger.shouldSaveLogs = shouldSendLogs; | ||
} | ||
} | ||
get isMobile() { | ||
@@ -159,3 +172,3 @@ return this.tokenOrigin === TokenOrigin.HEADER; | ||
isMobile: this.isMobile, | ||
isRemoteConfigUpdateRequest: this.isRemoteConfigUpdateRequest, | ||
remoteConfigUpdateData: this.remoteConfigUpdateData, | ||
productData: this.productData, | ||
@@ -162,0 +175,0 @@ requestData: { |
@@ -7,3 +7,4 @@ export * from './RequestData.js'; | ||
export * from './ServerData.js'; | ||
export * from './RemoteConfigUpdateData.js'; | ||
export * from './IContext.js'; | ||
export * from './ReadonlyContext.js'; |
@@ -6,3 +6,3 @@ import { DefaultLogger } from '../logger/index.js'; | ||
isMobile; | ||
isRemoteConfigUpdateRequest; | ||
remoteConfigUpdateData; | ||
logger; | ||
@@ -37,3 +37,3 @@ productData; | ||
this.requestId = contextJson.requestId; | ||
this.isRemoteConfigUpdateRequest = contextJson.isRemoteConfigUpdateRequest; | ||
this.remoteConfigUpdateData = contextJson.remoteConfigUpdateData; | ||
this.logger = this.createLogger(config, contextJson.shouldSendLogs, contextJson.logger?.logs); | ||
@@ -40,0 +40,0 @@ this.productData = contextJson.productData; |
@@ -10,2 +10,3 @@ import { EndEnforcerFlow, EnforceFlow, FilterFlow, PostEnforceFlow } from '../phase/index.js'; | ||
activityClient; | ||
remoteConfigManager; | ||
/** | ||
@@ -21,2 +22,3 @@ * The EnforcerBase constructor. | ||
this.activityClient = initializationBlock.activityClient; | ||
this.remoteConfigManager = initializationBlock.remoteConfigManager; | ||
this.filterFlow = this.createFilterFlow(config, initializationBlock); | ||
@@ -48,2 +50,3 @@ this.enforceFlow = this.createEnforceFlow(config, initializationBlock); | ||
async enforce(...args) { | ||
await this.remoteConfigManager?.loadRemoteConfig(); | ||
let context; | ||
@@ -50,0 +53,0 @@ try { |
import { DefaultTokenV2Parser, DefaultTokenV3Parser, TokenVersion } from '../risk_token/index.js'; | ||
import { DefaultRemoteConfigUpdater, HttpRemoteConfigServiceClient } from '../config/index.js'; | ||
import { DefaultNotifyRemoteConfigUpdateParser, DefaultRemoteConfigManager, HttpRemoteConfigServiceClient, } from '../config/index.js'; | ||
import { DefaultCors } from '../cors/index.js'; | ||
@@ -20,3 +20,3 @@ import { DefaultTelemetry } from '../telemetry/index.js'; | ||
} | ||
const cipherUtils = tokenVersion === TokenVersion.V2 ? null : options.cipherUtils ?? null; | ||
const cipherUtils = tokenVersion === TokenVersion.V2 ? null : (options.cipherUtils ?? null); | ||
if (tokenVersion === TokenVersion.V3 && !cipherUtils) { | ||
@@ -43,16 +43,5 @@ throw new EnforcerError('error initializing enforcer: token v3 requires cipherUtils'); | ||
const logServiceClient = options.logServiceClient || (config.loggerAuthToken ? new HttpLogServiceClient(config, httpClient) : null); | ||
const remoteConfigStorageClient = options.remoteConfigStorageClient ?? null; | ||
const remoteConfigServiceClient = options.remoteConfigServiceClient || | ||
(config.remoteConfigAuthToken ? new HttpRemoteConfigServiceClient(config, httpClient) : null); | ||
const remoteConfigUpdater = options.remoteConfigUpdater || | ||
(remoteConfigStorageClient && remoteConfigServiceClient | ||
? new DefaultRemoteConfigUpdater(config, { | ||
serviceClient: remoteConfigServiceClient, | ||
storageClient: remoteConfigStorageClient, | ||
base64Utils, | ||
hmacUtils, | ||
}) | ||
: null); | ||
const snippetInjector = options.snippetInjector ?? null; | ||
const snippetRetriever = options.snippetRetriever || (snippetInjector ? new DefaultSnippetRetriever(config) : null); | ||
const remoteConfigClients = createRemoteConfigClients(config, options); | ||
const allOptions = { | ||
@@ -74,7 +63,5 @@ httpClient, | ||
logServiceClient, | ||
remoteConfigStorageClient, | ||
remoteConfigServiceClient, | ||
remoteConfigUpdater, | ||
snippetInjector, | ||
snippetRetriever, | ||
...remoteConfigClients, | ||
}; | ||
@@ -99,1 +86,29 @@ const products = createEnforcerProducts(config, options.products, base64Utils, hashUtils, urlUtils, ipRangeChecker); | ||
}; | ||
export const createRemoteConfigClients = (config, options) => { | ||
const remoteConfigStorageClient = options.remoteConfigStorageClient ?? null; | ||
let remoteConfigServiceClient = null; | ||
let remoteConfigManager = null; | ||
let remoteConfigUpdateParser = null; | ||
if (remoteConfigStorageClient) { | ||
remoteConfigServiceClient = | ||
options.remoteConfigServiceClient ?? new HttpRemoteConfigServiceClient(config, options.httpClient); | ||
remoteConfigManager = | ||
options.remoteConfigManager ?? | ||
new DefaultRemoteConfigManager(config, { | ||
serviceClient: remoteConfigServiceClient, | ||
storageClient: remoteConfigStorageClient, | ||
}); | ||
remoteConfigUpdateParser = | ||
options.remoteConfigUpdateParser ?? | ||
new DefaultNotifyRemoteConfigUpdateParser(config, { | ||
base64Utils: options.base64Utils, | ||
hmacUtils: options.hmacUtils, | ||
}); | ||
} | ||
return { | ||
remoteConfigServiceClient, | ||
remoteConfigManager, | ||
remoteConfigUpdateParser, | ||
remoteConfigStorageClient, | ||
}; | ||
}; |
import { LoggerSeverity } from './LoggerSeverity.js'; | ||
export class LoggerBase { | ||
shouldSaveLogs; | ||
loggerSeverity; | ||
shouldSaveLogs; | ||
logs; | ||
@@ -6,0 +6,0 @@ constructor(loggerSeverity = LoggerSeverity.ERROR, shouldSaveLogs, logs = []) { |
@@ -1,6 +0,8 @@ | ||
import { CompositePhase, SendLogsPhase } from '../impl/index.js'; | ||
import { ClearLogsPhase, SendTelemetryActivityPhase } from '../impl/index.js'; | ||
import { ClearLogsPhase, CompositePhase, SendLogsPhase, SendTelemetryActivityPhase, UpdateRemoteConfigPhase, } from '../impl/index.js'; | ||
export class EndEnforcerFlow extends CompositePhase { | ||
constructor(config, { logServiceClient, telemetry, }) { | ||
constructor(config, { logServiceClient, telemetry, remoteConfigManager, }) { | ||
const phases = [new SendTelemetryActivityPhase(telemetry)]; | ||
if (remoteConfigManager) { | ||
phases.push(new UpdateRemoteConfigPhase(config, remoteConfigManager)); | ||
} | ||
if (logServiceClient) { | ||
@@ -7,0 +9,0 @@ phases.push(new SendLogsPhase(config, logServiceClient)); |
import { ProductName } from '../../products/index.js'; | ||
import { isNullOrUndefined } from '../../utils/index.js'; | ||
import { CompositePhase, FilterPhase, FirstPartyPhase, PreflightPhase, UpdateRemoteConfigPhase, IdentifyTelemetryRequestPhase, } from '../impl/index.js'; | ||
import { CompositePhase, FilterPhase, FirstPartyPhase, PreflightPhase, IdentifyTelemetryRequestPhase, IdentifyRemoteConfigNotifyRequestPhase, } from '../impl/index.js'; | ||
export class FilterFlow extends CompositePhase { | ||
constructor(config, { httpClient, products, cors, telemetry, remoteConfigUpdater, }) { | ||
constructor(config, { httpClient, products, cors, telemetry, remoteConfigUpdateParser, }) { | ||
const phases = []; | ||
@@ -17,5 +17,4 @@ const firstPartyProducts = FilterFlow.getFirstPartyProducts(products); | ||
phases.push(new IdentifyTelemetryRequestPhase(telemetry)); | ||
if (remoteConfigUpdater) { | ||
const updateRemoteConfigPhase = new UpdateRemoteConfigPhase(config, remoteConfigUpdater); | ||
phases.push(updateRemoteConfigPhase); | ||
if (remoteConfigUpdateParser) { | ||
phases.push(new IdentifyRemoteConfigNotifyRequestPhase(remoteConfigUpdateParser)); | ||
} | ||
@@ -22,0 +21,0 @@ super(phases); |
@@ -17,5 +17,6 @@ export * from './FirstPartyPhase.js'; | ||
export * from './SendLogsPhase.js'; | ||
export * from './ClearLogsPhase.js'; | ||
export * from './IdentifyRemoteConfigNotifyRequestPhase.js'; | ||
export * from './UpdateRemoteConfigPhase.js'; | ||
export * from './ClearLogsPhase.js'; | ||
export * from './IdentifyTelemetryRequestPhase.js'; | ||
export * from './SendTelemetryActivityPhase.js'; |
export class UpdateRemoteConfigPhase { | ||
config; | ||
remoteConfigUpdater; | ||
constructor(config, remoteConfigUpdater) { | ||
remoteConfigManager; | ||
constructor(config, remoteConfigManager) { | ||
this.config = config; | ||
this.remoteConfigUpdater = remoteConfigUpdater; | ||
this.remoteConfigManager = remoteConfigManager; | ||
} | ||
async execute(context) { | ||
if (this.remoteConfigUpdater.isUpdateRemoteConfigRequest(context)) { | ||
const isSuccessful = await this.remoteConfigUpdater.updateRemoteConfig(context); | ||
return { done: true, response: this.getUpdateConfigResponse(isSuccessful) }; | ||
if (this.remoteConfigManager.shouldUpdateRemoteConfig(context)) { | ||
context.shouldSendLogs = true; | ||
await this.remoteConfigManager.updateRemoteConfig(context); | ||
} | ||
return { done: false }; | ||
} | ||
getUpdateConfigResponse(isSuccessful) { | ||
return { | ||
status: isSuccessful ? 200 : 400, | ||
body: isSuccessful ? 'OK' : 'Bad Request', | ||
headers: {}, | ||
}; | ||
} | ||
} |
@@ -14,2 +14,2 @@ export const PXVID_COOKIE_NAME = '_pxvid'; | ||
export const REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/; | ||
export const CORE_MODULE_VERSION = 'JS Core 0.24.4'; | ||
export const CORE_MODULE_VERSION = 'JS Core 0.25.0'; |
@@ -11,2 +11,3 @@ import { IConfiguration } from './IConfiguration'; | ||
import { ExtractGraphQLKeywordsFunction } from '../graphql'; | ||
import { RemoteConfigData } from './remote_config'; | ||
import { TokenVersion } from '../risk_token'; | ||
@@ -17,3 +18,3 @@ import { CustomSnippetFunction } from '../snippet_injection'; | ||
protected readonly staticConfigParams: StaticConfigurationParams<Req, Res, Added, Removed>; | ||
protected remoteConfigParams?: RemoteConfigurationParams<Req, Res, Added, Removed>; | ||
protected remoteConfigData?: RemoteConfigData<Req, Res, Added, Removed>; | ||
protected readonly defaultConfigParams: RequiredAllConfigurationParams<Req, Res, Added, Removed>; | ||
@@ -30,3 +31,3 @@ protected readonly removedParams: Record<Removed, undefined>; | ||
protected createInternalLogger(params: RequiredAllConfigurationParams<Req, Res, Added, Removed>): ILogger; | ||
addRemoteConfig(remoteConfigParams: RemoteConfigurationParams<Req, Res, Added, Removed>): void; | ||
setRemoteConfigData(remoteConfigData: RemoteConfigData<Req, Res, Added, Removed>): void; | ||
getActiveConfig(): ActiveConfigurationParams<Req, Res, Added, Removed>; | ||
@@ -33,0 +34,0 @@ getStaticConfig(): StaticConfigurationParams<Req, Res, Added, Removed>; |
@@ -12,2 +12,3 @@ import { ModuleMode } from '../utils'; | ||
import { CustomSnippetFunction } from '../snippet_injection'; | ||
import { RemoteConfigData } from './remote_config'; | ||
export interface IConfiguration<Req, Res, Added, Removed> { | ||
@@ -404,5 +405,5 @@ /** | ||
/** | ||
* Adds a remote configuration to the current configuration. | ||
* Sets the remote configuration data. | ||
*/ | ||
addRemoteConfig(remoteConfigurationParams: RemoteConfigurationParams<Req, Res, Added, Removed>): void; | ||
setRemoteConfigData(remoteConfigData: RemoteConfigData<Req, Res, Added, Removed>): void; | ||
} |
export * from './IConfiguration'; | ||
export * from './ConfigurationBase'; | ||
export * from './ConfigurationBuilderBase'; | ||
export * from './CustomRequestFunction'; | ||
@@ -5,0 +4,0 @@ export * from './remote_config'; |
@@ -17,6 +17,6 @@ import { LoggerSeverity } from '../../logger'; | ||
px_remote_config_auth_token?: string; | ||
px_remote_config_id?: string; | ||
}; | ||
export type RemoteConfigurationParamsOnly = { | ||
px_remote_config_enabled?: boolean; | ||
px_remote_config_id?: string; | ||
px_remote_config_version?: number; | ||
@@ -23,0 +23,0 @@ px_sensitive_routes_regex?: string[]; |
@@ -5,4 +5,4 @@ export * from './constants'; | ||
export * from './storage_client'; | ||
export * from './DefaultRemoteConfigUpdater'; | ||
export * from './IRemoteConfigUpdater'; | ||
export * from './manager'; | ||
export * from './update_parser'; | ||
export * from './RemoteConfigUtils'; |
export * from './RemoteConfigData'; | ||
export * from './RemoteConfigUpdateRequestData'; | ||
export * from './RemoteConfigNotifyRequestPayload'; |
import { ILogger } from '../../logger'; | ||
import { IIncomingRequest } from '../../http'; | ||
import { RemoteConfigurationParams } from '../params'; | ||
import { RemoteConfigData } from './model'; | ||
export declare namespace RemoteConfigUtils { | ||
const isRemoteConfigUpdateRequest: <Req>(request: IIncomingRequest<Req>) => boolean; | ||
const prepareRemoteConfigParams: <Req, Res, Added, Removed>(remoteConfigParams: RemoteConfigurationParams<Req, Res, Added, Removed>, logger: ILogger) => RemoteConfigurationParams<Req, Res, Added, Removed>; | ||
const prepareRemoteConfigParams: <Req, Res, Added, Removed>({ version, configValue }: RemoteConfigData<Req, Res, Added, Removed>, logger: ILogger) => RemoteConfigurationParams<Req, Res, Added, Removed>; | ||
const mergeStringRegexConfigurationValues: (stringFields: Array<string | RegExp> | undefined, regexFields: string[] | undefined, logger: ILogger) => Array<string | RegExp>; | ||
} |
import { IHttpClient, IIncomingResponse, IOutgoingRequest } from '../../../http'; | ||
import { IConfiguration } from '../../IConfiguration'; | ||
import { RemoteConfigData, RemoteConfigUpdateRequestData } from '../model'; | ||
import { RemoteConfigData, RemoteConfigNotifyRequestPayload } from '../model'; | ||
import { IRemoteConfigServiceClient } from './IRemoteConfigServiceClient'; | ||
@@ -9,5 +9,5 @@ export declare class HttpRemoteConfigServiceClient<Req, Res, Added, Removed> implements IRemoteConfigServiceClient<Req, Res, Added, Removed> { | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, httpClient: IHttpClient); | ||
fetch(_updateRequestData: RemoteConfigUpdateRequestData): Promise<RemoteConfigData<Req, Res, Added, Removed>>; | ||
fetch(_updateRequestData: RemoteConfigNotifyRequestPayload): Promise<RemoteConfigData<Req, Res, Added, Removed>>; | ||
protected createFetchRemoteConfigRequest(): IOutgoingRequest; | ||
protected extractConfigFromResponse(response: IIncomingResponse): Promise<RemoteConfigData<Req, Res, Added, Removed>>; | ||
} |
import { AsyncOrSync } from 'ts-essentials'; | ||
import { RemoteConfigData, RemoteConfigUpdateRequestData } from '../model'; | ||
import { RemoteConfigData, RemoteConfigNotifyRequestPayload } from '../model'; | ||
export interface IRemoteConfigServiceClient<Req, Res, Added, Removed> { | ||
fetch(updateRequestData: RemoteConfigUpdateRequestData): AsyncOrSync<RemoteConfigData<Req, Res, Added, Removed>>; | ||
fetch(updateRequestData: RemoteConfigNotifyRequestPayload): AsyncOrSync<RemoteConfigData<Req, Res, Added, Removed>>; | ||
} |
import { AsyncOrSync } from 'ts-essentials'; | ||
import { RemoteConfigData } from '../model'; | ||
export interface IRemoteConfigStorageClient<Req, Res, Added, Removed> { | ||
load(): AsyncOrSync<RemoteConfigData<Req, Res, Added, Removed>>; | ||
load(): AsyncOrSync<RemoteConfigData<Req, Res, Added, Removed> | null>; | ||
save(remoteConfigData: RemoteConfigData<Req, Res, Added, Removed>): AsyncOrSync<void>; | ||
} |
@@ -10,3 +10,3 @@ import { TokenOrigin } from '../risk_token'; | ||
import { GraphQLData } from '../graphql'; | ||
import { RequestData, RiskApiData, ServerData, TlsData, TokenData } from './interfaces'; | ||
import { RemoteConfigUpdateData, RequestData, RiskApiData, ServerData, TlsData, TokenData } from './interfaces'; | ||
import { LogRecord } from '../logger'; | ||
@@ -40,3 +40,3 @@ type RequestDataJson<Req> = Omit<RequestData<Req>, 'url' | 'request'> & { | ||
readonly shouldSendLogs: boolean; | ||
readonly isRemoteConfigUpdateRequest: boolean; | ||
readonly remoteConfigUpdateData: RemoteConfigUpdateData; | ||
readonly enforcerStartTime?: number; | ||
@@ -43,0 +43,0 @@ logger?: { |
@@ -12,3 +12,3 @@ import { IConfiguration } from '../config'; | ||
import { ILogger } from '../logger'; | ||
import { IContext, RequestData, RiskApiData, ServerData, TlsData, TokenData } from './interfaces'; | ||
import { IContext, RemoteConfigUpdateData, RequestData, RiskApiData, ServerData, TlsData, TokenData } from './interfaces'; | ||
import { ContextJson } from './ContextJson'; | ||
@@ -24,4 +24,3 @@ import { GraphQLData } from '../graphql'; | ||
readonly tokenOrigin: TokenOrigin; | ||
readonly isRemoteConfigUpdateRequest: boolean; | ||
readonly shouldSendLogs: boolean; | ||
readonly remoteConfigUpdateData: RemoteConfigUpdateData; | ||
readonly requestData: RequestData<Req>; | ||
@@ -50,5 +49,8 @@ readonly tokenData: TokenData<Req, Res>; | ||
shouldSendTelemetry: boolean; | ||
protected _shouldSendLogs: boolean; | ||
protected readonly config: IConfiguration<Req, Res, Added, Removed>; | ||
protected readonly urlUtils: IUrlUtils; | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, request: IIncomingRequest<Req>, options: DefaultContextOptions); | ||
get shouldSendLogs(): boolean; | ||
set shouldSendLogs(shouldSendLogs: boolean); | ||
get isMobile(): boolean; | ||
@@ -55,0 +57,0 @@ protected createContextLogger(config: IConfiguration<Req, Res, Added, Removed>, shouldSaveLogs: boolean): ILogger; |
@@ -17,2 +17,3 @@ import { VidSource } from '../../utils'; | ||
import { ILogger } from '../../logger'; | ||
import { RemoteConfigUpdateData } from './RemoteConfigUpdateData'; | ||
export interface IContext<Req, Res> { | ||
@@ -124,7 +125,7 @@ /** | ||
*/ | ||
readonly shouldSendLogs: boolean; | ||
shouldSendLogs: boolean; | ||
/** | ||
* Whether the incoming request was sent to trigger a remote configuration update. | ||
* Data concerning any required updates to the remote configuration. | ||
*/ | ||
readonly isRemoteConfigUpdateRequest: boolean; | ||
readonly remoteConfigUpdateData: RemoteConfigUpdateData; | ||
/** | ||
@@ -131,0 +132,0 @@ * The time the Enforcer process started |
@@ -7,3 +7,4 @@ export * from './RequestData'; | ||
export * from './ServerData'; | ||
export * from './RemoteConfigUpdateData'; | ||
export * from './IContext'; | ||
export * from './ReadonlyContext'; |
@@ -13,7 +13,7 @@ import { IConfiguration } from '../config'; | ||
import { GraphQLData } from '../graphql'; | ||
import { IContext, RequestData, RiskApiData, ServerData, TlsData, TokenData } from './interfaces'; | ||
import { IContext, RemoteConfigUpdateData, RequestData, RiskApiData, ServerData, TlsData, TokenData } from './interfaces'; | ||
import { ContextJson } from './ContextJson'; | ||
export declare class SerializedContext<Req, Res, Added, Removed> implements IContext<Req, Res> { | ||
readonly isMobile: boolean; | ||
readonly isRemoteConfigUpdateRequest: boolean; | ||
readonly remoteConfigUpdateData: RemoteConfigUpdateData; | ||
readonly logger: ILogger; | ||
@@ -20,0 +20,0 @@ readonly productData: ProductData; |
import { AsyncOrSync } from 'ts-essentials'; | ||
import { IConfiguration } from '../config'; | ||
import { IConfiguration, IRemoteConfigManager } from '../config'; | ||
import { IContext } from '../context'; | ||
@@ -16,2 +16,3 @@ import { IMinimalResponse, IOutgoingResponse } from '../http'; | ||
protected readonly activityClient: IActivityClient<Req, Res>; | ||
protected readonly remoteConfigManager: IRemoteConfigManager<Req, Res> | null; | ||
/** | ||
@@ -18,0 +19,0 @@ * Constructs the concrete request context given the provided EnforceArgs. |
@@ -12,3 +12,3 @@ import { IDataEnrichment } from '../pxde'; | ||
import { ILogServiceClient } from '../logger'; | ||
import { IRemoteConfigStorageClient, IRemoteConfigServiceClient, IRemoteConfigUpdater } from '../config'; | ||
import { IRemoteConfigStorageClient, IRemoteConfigServiceClient, IRemoteConfigManager, IRemoteConfigUpdateParser } from '../config'; | ||
import { ISnippetInjector, ISnippetRetriever } from '../snippet_injection'; | ||
@@ -32,3 +32,4 @@ export type EnforcerOptions<Req, Res, Added, Removed> = { | ||
logServiceClient?: ILogServiceClient<Req, Res> | null; | ||
remoteConfigUpdater?: IRemoteConfigUpdater<Req, Res> | null; | ||
remoteConfigManager?: IRemoteConfigManager<Req, Res> | null; | ||
remoteConfigUpdateParser?: IRemoteConfigUpdateParser<Req, Res> | null; | ||
remoteConfigStorageClient?: IRemoteConfigStorageClient<Req, Res, Added, Removed> | null; | ||
@@ -35,0 +36,0 @@ remoteConfigServiceClient?: IRemoteConfigServiceClient<Req, Res, Added, Removed> | null; |
@@ -1,2 +0,2 @@ | ||
import { IConfiguration } from '../config'; | ||
import { IConfiguration, IRemoteConfigManager, IRemoteConfigServiceClient, IRemoteConfigStorageClient, IRemoteConfigUpdateParser } from '../config'; | ||
import { EnforcerOptions } from './EnforcerOptions'; | ||
@@ -7,1 +7,7 @@ import { Products } from '../products'; | ||
export declare const createEnforcerProducts: <Req, Res, Added, Removed>(config: IConfiguration<Req, Res, Added, Removed>, products: Products<Req, Res> | undefined, base64Utils: IBase64Utils, hashUtils: IHashUtils, urlUtils: IUrlUtils, ipRangeChecker: IIpRangeChecker) => Products<Req, Res>; | ||
export declare const createRemoteConfigClients: <Req, Res, Added, Removed>(config: IConfiguration<Req, Res, Added, Removed>, options: EnforcerOptions<Req, Res, Added, Removed>) => { | ||
remoteConfigServiceClient: IRemoteConfigServiceClient<Req, Res, Added, Removed> | null; | ||
remoteConfigManager: IRemoteConfigManager<Req, Res> | null; | ||
remoteConfigUpdateParser: IRemoteConfigUpdateParser<Req, Res> | null; | ||
remoteConfigStorageClient: IRemoteConfigStorageClient<Req, Res, Added, Removed> | null; | ||
}; |
@@ -36,2 +36,6 @@ import { LoggerSeverity } from './LoggerSeverity'; | ||
clearLogs(): void; | ||
/** | ||
* Whether the logger should save the logs it writes | ||
*/ | ||
shouldSaveLogs: boolean; | ||
} |
@@ -5,4 +5,4 @@ import { ILogger } from './ILogger'; | ||
export declare abstract class LoggerBase implements ILogger { | ||
shouldSaveLogs: boolean; | ||
protected loggerSeverity: `${LoggerSeverity}`; | ||
protected readonly shouldSaveLogs: boolean; | ||
protected logs: LogRecord[]; | ||
@@ -9,0 +9,0 @@ protected constructor(loggerSeverity: `${LoggerSeverity}` | undefined, shouldSaveLogs: boolean, logs?: LogRecord[]); |
import { IConfiguration } from '../../config'; | ||
import { CompositePhase } from '../impl'; | ||
import { EnforcerOptions } from '../../enforcer'; | ||
type RequiredEndEnforcerFlowOptions = 'logServiceClient' | 'telemetry'; | ||
type RequiredEndEnforcerFlowOptions = 'logServiceClient' | 'telemetry' | 'remoteConfigManager'; | ||
export declare class EndEnforcerFlow<Req, Res, Added, Removed> extends CompositePhase<Req, Res> { | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, { logServiceClient, telemetry, }: Pick<Required<EnforcerOptions<Req, Res, Added, Removed>>, RequiredEndEnforcerFlowOptions>); | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, { logServiceClient, telemetry, remoteConfigManager, }: Pick<Required<EnforcerOptions<Req, Res, Added, Removed>>, RequiredEndEnforcerFlowOptions>); | ||
} | ||
export {}; |
@@ -8,5 +8,5 @@ import { IConfiguration } from '../../config'; | ||
export declare class FilterFlow<Req, Res, Added, Removed> extends CompositePhase<Req, Res> { | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, { httpClient, products, cors, telemetry, remoteConfigUpdater, }: Required<EnforcerOptions<Req, Res, Added, Removed>>); | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, { httpClient, products, cors, telemetry, remoteConfigUpdateParser, }: Required<EnforcerOptions<Req, Res, Added, Removed>>); | ||
protected static getFirstPartyProducts<Req, Res>(products: Products<Req, Res>): IFirstParty<Req, Res>[]; | ||
protected static getFilterProducts<Req, Res>(products: Products<Req, Res>): IFilter<Req, Res>[]; | ||
} |
@@ -17,5 +17,6 @@ export * from './FirstPartyPhase'; | ||
export * from './SendLogsPhase'; | ||
export * from './ClearLogsPhase'; | ||
export * from './IdentifyRemoteConfigNotifyRequestPhase'; | ||
export * from './UpdateRemoteConfigPhase'; | ||
export * from './ClearLogsPhase'; | ||
export * from './IdentifyTelemetryRequestPhase'; | ||
export * from './SendTelemetryActivityPhase'; |
@@ -1,3 +0,2 @@ | ||
import { IConfiguration, IRemoteConfigUpdater } from '../../config'; | ||
import { IMinimalResponse } from '../../http'; | ||
import { IConfiguration, IRemoteConfigManager } from '../../config'; | ||
import { IContext } from '../../context'; | ||
@@ -8,6 +7,5 @@ import { IPhase } from '../IPhase'; | ||
protected readonly config: IConfiguration<Req, Res, Added, Removed>; | ||
protected readonly remoteConfigUpdater: IRemoteConfigUpdater<Req, Res>; | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, remoteConfigUpdater: IRemoteConfigUpdater<Req, Res>); | ||
protected readonly remoteConfigManager: IRemoteConfigManager<Req, Res>; | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, remoteConfigManager: IRemoteConfigManager<Req, Res>); | ||
execute(context: IContext<Req, Res>): Promise<PhaseResult>; | ||
protected getUpdateConfigResponse(isSuccessful: boolean): IMinimalResponse; | ||
} |
@@ -14,2 +14,2 @@ export declare const PXVID_COOKIE_NAME = "_pxvid"; | ||
export declare const REGEX_STRUCTURE: RegExp; | ||
export declare const CORE_MODULE_VERSION = "JS Core 0.24.4"; | ||
export declare const CORE_MODULE_VERSION = "JS Core 0.25.0"; |
{ | ||
"name": "perimeterx-js-core", | ||
"version": "0.24.4", | ||
"version": "0.25.0", | ||
"description": "", | ||
@@ -38,4 +38,4 @@ "type": "module", | ||
"clean": "rm -rf lib", | ||
"lint": "./node_modules/eslint/bin/eslint.js . --ext .ts", | ||
"lint:fix": "./node_modules/eslint/bin/eslint.js . --ext .ts --fix", | ||
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts", | ||
"lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts --fix", | ||
"test": "mocha", | ||
@@ -61,20 +61,20 @@ "coverage": "nyc npm run test", | ||
"@types/uuid": "^10.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.40.0", | ||
"@typescript-eslint/parser": "^5.40.0", | ||
"@typescript-eslint/eslint-plugin": "^8.26.0", | ||
"@typescript-eslint/parser": "^8.26.0", | ||
"chai": "^4.3.6", | ||
"chai-as-promised": "^8.0.0", | ||
"core-js": "^3.19.1", | ||
"eslint": "^8.25.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.1.0", | ||
"eslint": "^9.21.0", | ||
"eslint-config-prettier": "^10.0.2", | ||
"eslint-plugin-prettier": "^5.2.3", | ||
"husky": "^9.1.7", | ||
"lint-staged": "^15.4.3", | ||
"mocha": "^10.0.0", | ||
"nyc": "^17.0.0", | ||
"prettier": "^2.7.1", | ||
"prettier": "^3.5.3", | ||
"sinon": "^18.0.0", | ||
"ts-loader": "^9.4.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.6", | ||
"tsc-alias": "^1.8.11" | ||
"tsc-alias": "^1.8.11", | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -81,0 +81,0 @@ "lint-staged": { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1275365
0.99%1239
1.23%26332
0.87%