perimeterx-js-core
Advanced tools
Comparing version
@@ -51,2 +51,3 @@ "use strict"; | ||
} | ||
this.shouldSendTelemetry = false; | ||
} | ||
@@ -169,2 +170,3 @@ Object.defineProperty(DefaultContext.prototype, "isMobile", { | ||
pxdeVerified: this.pxdeVerified, | ||
shouldSendTelemetry: this.shouldSendTelemetry, | ||
logger: this.shouldSendLogs | ||
@@ -171,0 +173,0 @@ ? { |
@@ -46,2 +46,3 @@ "use strict"; | ||
this.blockAction = contextJson.blockAction; | ||
this.shouldSendTelemetry = contextJson.shouldSendTelemetry; | ||
} | ||
@@ -48,0 +49,0 @@ SerializedContext.prototype.createRequestData = function (_a, request, urlUtils) { |
@@ -20,12 +20,12 @@ "use strict"; | ||
var impl_1 = require("../impl"); | ||
var ClearLogsPhase_1 = require("../impl/ClearLogsPhase"); | ||
var impl_2 = require("../impl"); | ||
var EndEnforcerFlow = /** @class */ (function (_super) { | ||
__extends(EndEnforcerFlow, _super); | ||
function EndEnforcerFlow(config, _a) { | ||
var logServiceClient = _a.logServiceClient; | ||
var phases = []; | ||
var logServiceClient = _a.logServiceClient, telemetry = _a.telemetry; | ||
var phases = [new impl_2.SendTelemetryActivityPhase(telemetry)]; | ||
if (logServiceClient) { | ||
phases.push(new impl_1.SendLogsPhase(config, logServiceClient)); | ||
} | ||
phases.push(new ClearLogsPhase_1.ClearLogsPhase()); | ||
phases.push(new impl_2.ClearLogsPhase()); | ||
return _super.call(this, phases) || this; | ||
@@ -32,0 +32,0 @@ } |
@@ -36,3 +36,3 @@ "use strict"; | ||
phases.push(new impl_1.PreflightPhase(config, cors)); | ||
phases.push(new impl_1.TelemetryPhase(telemetry)); | ||
phases.push(new impl_1.IdentifyTelemetryRequestPhase(telemetry)); | ||
if (remoteConfigUpdater) { | ||
@@ -39,0 +39,0 @@ var updateRemoteConfigPhase = new impl_1.UpdateRemoteConfigPhase(config, remoteConfigUpdater); |
@@ -20,3 +20,2 @@ "use strict"; | ||
__exportStar(require("./PreflightPhase"), exports); | ||
__exportStar(require("./TelemetryPhase"), exports); | ||
__exportStar(require("./EnrichContextFromRequestPhase"), exports); | ||
@@ -37,1 +36,3 @@ __exportStar(require("./ParseTokenPhase"), exports); | ||
__exportStar(require("./ClearLogsPhase"), exports); | ||
__exportStar(require("./IdentifyTelemetryRequestPhase"), exports); | ||
__exportStar(require("./SendTelemetryActivityPhase"), exports); |
@@ -132,2 +132,3 @@ "use strict"; | ||
dataEnrichment: 'pxde', | ||
telemetryRequested: 'shouldSendTelemetry', | ||
}); | ||
@@ -134,0 +135,0 @@ if (riskResponse.dataEnrichment) { |
@@ -81,3 +81,3 @@ "use strict"; | ||
if (!((response === null || response === void 0 ? void 0 : response.status) !== 200)) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.handleS2SError(riskApiData, response)]; | ||
return [4 /*yield*/, this.handleS2SError(riskApiData, context, response)]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
@@ -90,3 +90,3 @@ case 4: | ||
if (!!(_a.sent())) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, this.handleS2SError(riskApiData, response)]; | ||
return [4 /*yield*/, this.handleS2SError(riskApiData, context, response)]; | ||
case 6: return [2 /*return*/, _a.sent()]; | ||
@@ -102,3 +102,3 @@ case 7: | ||
context.logger.error("caught error in risk api: ".concat(err_1, " - ").concat(JSON.stringify(context.requestData.url))); | ||
return [4 /*yield*/, this.handleS2SError(riskApiData, response, err_1)]; | ||
return [4 /*yield*/, this.handleS2SError(riskApiData, context, response, err_1)]; | ||
case 9: return [2 /*return*/, _a.sent()]; | ||
@@ -182,3 +182,3 @@ case 10: return [2 /*return*/]; | ||
}; | ||
PostRiskApiClientBase.prototype.handleS2SError = function (riskApiData, response, error) { | ||
PostRiskApiClientBase.prototype.handleS2SError = function (riskApiData, context, response, error) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -229,2 +229,3 @@ var _a, _b, _c, errorMessage, existingMessage; | ||
} | ||
context.logger.debug("S2S error message: ".concat(riskApiData.errorMessage)); | ||
return [2 /*return*/, riskApiData]; | ||
@@ -231,0 +232,0 @@ } |
@@ -129,2 +129,10 @@ "use strict"; | ||
}); | ||
Object.defineProperty(RiskResponseBase.prototype, "telemetryRequested", { | ||
get: function () { | ||
var _a; | ||
return (_a = this.riskResponse) === null || _a === void 0 ? void 0 : _a.telemetry_requested; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RiskResponseBase.prototype, "drc", { | ||
@@ -149,2 +157,3 @@ get: function () { | ||
additionalRiskInfo: this.additionalRiskInfo, | ||
telemetryRequested: this.telemetryRequested, | ||
uuid: this.uuid, | ||
@@ -151,0 +160,0 @@ }; |
@@ -8,2 +8,3 @@ "use strict"; | ||
this.additionalRiskInfo = riskResponseJson.additionalRiskInfo; | ||
this.telemetryRequested = riskResponseJson.telemetryRequested; | ||
this.dataEnrichment = riskResponseJson.dataEnrichment; | ||
@@ -10,0 +11,0 @@ this.drc = riskResponseJson.drc; |
@@ -17,2 +17,2 @@ "use strict"; | ||
exports.REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/; | ||
exports.CORE_MODULE_VERSION = 'JS Core 0.24.0'; | ||
exports.CORE_MODULE_VERSION = 'JS Core 0.24.1'; |
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./IRequestIdGenerator"), exports); | ||
__exportStar(require("./SimpleRequestIdGenerator"), exports); |
@@ -37,2 +37,3 @@ import { RemoteConfigUtils } from '../config'; | ||
usedCookieSecret; | ||
shouldSendTelemetry; | ||
config; | ||
@@ -66,2 +67,3 @@ urlUtils; | ||
} | ||
this.shouldSendTelemetry = false; | ||
} | ||
@@ -180,2 +182,3 @@ get isMobile() { | ||
pxdeVerified: this.pxdeVerified, | ||
shouldSendTelemetry: this.shouldSendTelemetry, | ||
logger: this.shouldSendLogs | ||
@@ -182,0 +185,0 @@ ? { |
@@ -30,2 +30,3 @@ import { DefaultLogger } from '../logger'; | ||
uuid; | ||
shouldSendTelemetry; | ||
constructor(config, contextJson, request, urlUtils) { | ||
@@ -57,2 +58,3 @@ this.action = contextJson.action; | ||
this.blockAction = contextJson.blockAction; | ||
this.shouldSendTelemetry = contextJson.shouldSendTelemetry; | ||
} | ||
@@ -59,0 +61,0 @@ createRequestData({ requestData }, request, urlUtils) { |
import { CompositePhase, SendLogsPhase } from '../impl'; | ||
import { ClearLogsPhase } from '../impl/ClearLogsPhase'; | ||
import { ClearLogsPhase, SendTelemetryActivityPhase } from '../impl'; | ||
export class EndEnforcerFlow extends CompositePhase { | ||
constructor(config, { logServiceClient }) { | ||
const phases = []; | ||
constructor(config, { logServiceClient, telemetry, }) { | ||
const phases = [new SendTelemetryActivityPhase(telemetry)]; | ||
if (logServiceClient) { | ||
@@ -7,0 +7,0 @@ phases.push(new SendLogsPhase(config, logServiceClient)); |
import { ProductName } from '../../products'; | ||
import { isNullOrUndefined } from '../../utils'; | ||
import { CompositePhase, FilterPhase, FirstPartyPhase, PreflightPhase, TelemetryPhase, UpdateRemoteConfigPhase, } from '../impl'; | ||
import { CompositePhase, FilterPhase, FirstPartyPhase, PreflightPhase, UpdateRemoteConfigPhase, IdentifyTelemetryRequestPhase, } from '../impl'; | ||
export class FilterFlow extends CompositePhase { | ||
@@ -16,3 +16,3 @@ constructor(config, { httpClient, products, cors, telemetry, remoteConfigUpdater, }) { | ||
phases.push(new PreflightPhase(config, cors)); | ||
phases.push(new TelemetryPhase(telemetry)); | ||
phases.push(new IdentifyTelemetryRequestPhase(telemetry)); | ||
if (remoteConfigUpdater) { | ||
@@ -19,0 +19,0 @@ const updateRemoteConfigPhase = new UpdateRemoteConfigPhase(config, remoteConfigUpdater); |
export * from './FirstPartyPhase'; | ||
export * from './FilterPhase'; | ||
export * from './PreflightPhase'; | ||
export * from './TelemetryPhase'; | ||
export * from './EnrichContextFromRequestPhase'; | ||
@@ -20,1 +19,3 @@ export * from './ParseTokenPhase'; | ||
export * from './ClearLogsPhase'; | ||
export * from './IdentifyTelemetryRequestPhase'; | ||
export * from './SendTelemetryActivityPhase'; |
@@ -44,2 +44,3 @@ import { Action, getReasonForHighestPriorityProduct } from '../../action'; | ||
dataEnrichment: 'pxde', | ||
telemetryRequested: 'shouldSendTelemetry', | ||
}); | ||
@@ -46,0 +47,0 @@ if (riskResponse.dataEnrichment) { |
@@ -26,3 +26,3 @@ import { AUTHORIZATION_HEADER_NAME, CONTENT_TYPE_HEADER_NAME, ContentType, HttpMethod, OutgoingRequestImpl, } from '../../http'; | ||
if (response?.status !== 200) { | ||
return await this.handleS2SError(riskApiData, response); | ||
return await this.handleS2SError(riskApiData, context, response); | ||
} | ||
@@ -32,3 +32,3 @@ riskResponse = this.createRiskResponse(response); | ||
if (!(await riskResponse.validate())) { | ||
return await this.handleS2SError(riskApiData, response); | ||
return await this.handleS2SError(riskApiData, context, response); | ||
} | ||
@@ -43,3 +43,3 @@ context.logger.debug(`received risk response, score: ${riskResponse.score}, rtt: ${riskApiData.riskRtt}`); | ||
context.logger.error(`caught error in risk api: ${err} - ${JSON.stringify(context.requestData.url)}`); | ||
return await this.handleS2SError(riskApiData, response, err); | ||
return await this.handleS2SError(riskApiData, context, response, err); | ||
} | ||
@@ -111,3 +111,3 @@ } | ||
} | ||
async handleS2SError(riskApiData, response, error) { | ||
async handleS2SError(riskApiData, context, response, error) { | ||
riskApiData.riskApiCallResult = RiskApiCallResult.ERROR; | ||
@@ -138,2 +138,3 @@ riskApiData.errorReason = S2SErrorReason.UNKNOWN_ERROR; | ||
} | ||
context.logger.debug(`S2S error message: ${riskApiData.errorMessage}`); | ||
return riskApiData; | ||
@@ -140,0 +141,0 @@ } |
@@ -41,2 +41,5 @@ import { RiskStatus } from '../model'; | ||
} | ||
get telemetryRequested() { | ||
return this.riskResponse?.telemetry_requested; | ||
} | ||
get drc() { | ||
@@ -56,2 +59,3 @@ return this.riskResponse?.drc; | ||
additionalRiskInfo: this.additionalRiskInfo, | ||
telemetryRequested: this.telemetryRequested, | ||
uuid: this.uuid, | ||
@@ -58,0 +62,0 @@ }; |
export class SerializedRiskResponse { | ||
action; | ||
additionalRiskInfo; | ||
telemetryRequested; | ||
dataEnrichment; | ||
@@ -15,2 +16,3 @@ drc; | ||
this.additionalRiskInfo = riskResponseJson.additionalRiskInfo; | ||
this.telemetryRequested = riskResponseJson.telemetryRequested; | ||
this.dataEnrichment = riskResponseJson.dataEnrichment; | ||
@@ -17,0 +19,0 @@ this.drc = riskResponseJson.drc; |
@@ -14,2 +14,2 @@ export const PXVID_COOKIE_NAME = '_pxvid'; | ||
export const REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/; | ||
export const CORE_MODULE_VERSION = 'JS Core 0.24.0'; | ||
export const CORE_MODULE_VERSION = 'JS Core 0.24.1'; |
export * from './IRequestIdGenerator'; | ||
export * from './SimpleRequestIdGenerator'; |
@@ -7,3 +7,3 @@ import { IRemoteConfigStorageClient } from './remote_config'; | ||
protected readonly base64Utils: IBase64Utils; | ||
protected abstract createRemoteConfigStorageClient(staticConfig: ConfigurationType): Promise<IRemoteConfigStorageClient<Req, Res, Added, Removed>>; | ||
protected abstract createRemoteConfigStorageClient(staticConfig: ConfigurationType): Promise<IRemoteConfigStorageClient<Req, Res, Added, Removed> | null>; | ||
protected abstract createConfiguration(params: ParamsType | StaticConfigurationParams<Req, Res, Added, Removed>): ConfigurationType; | ||
@@ -10,0 +10,0 @@ protected constructor(base64Utils: IBase64Utils); |
@@ -44,3 +44,4 @@ import { TokenOrigin } from '../risk_token'; | ||
}; | ||
shouldSendTelemetry: boolean; | ||
}; | ||
export {}; |
@@ -47,2 +47,3 @@ import { IConfiguration } from '../config'; | ||
usedCookieSecret?: string; | ||
shouldSendTelemetry: boolean; | ||
protected readonly config: IConfiguration<Req, Res, Added, Removed>; | ||
@@ -49,0 +50,0 @@ protected readonly urlUtils: IUrlUtils; |
@@ -132,2 +132,6 @@ import { VidSource } from '../../utils'; | ||
readonly enforcerStartTime?: number; | ||
/** | ||
* Whether to send telemetry activity for the current request. | ||
*/ | ||
shouldSendTelemetry: boolean; | ||
} |
@@ -41,2 +41,3 @@ import { IConfiguration } from '../config'; | ||
uuid?: string; | ||
shouldSendTelemetry: boolean; | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, contextJson: ContextJson<Req, Res>, request: IIncomingRequest<Req>, urlUtils: IUrlUtils); | ||
@@ -43,0 +44,0 @@ protected createRequestData({ requestData }: ContextJson<Req, Res>, request: IIncomingRequest<Req>, urlUtils: IUrlUtils): RequestData<Req>; |
import { IConfiguration } from '../../config'; | ||
import { CompositePhase } from '../impl'; | ||
import { EnforcerOptions } from '../../enforcer'; | ||
type RequiredEndEnforcerFlowOptions = 'logServiceClient' | 'telemetry'; | ||
export declare class EndEnforcerFlow<Req, Res, Added, Removed> extends CompositePhase<Req, Res> { | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, { logServiceClient }: Pick<Required<EnforcerOptions<Req, Res, Added, Removed>>, 'logServiceClient'>); | ||
constructor(config: IConfiguration<Req, Res, Added, Removed>, { logServiceClient, telemetry, }: Pick<Required<EnforcerOptions<Req, Res, Added, Removed>>, RequiredEndEnforcerFlowOptions>); | ||
} | ||
export {}; |
export * from './FirstPartyPhase'; | ||
export * from './FilterPhase'; | ||
export * from './PreflightPhase'; | ||
export * from './TelemetryPhase'; | ||
export * from './EnrichContextFromRequestPhase'; | ||
@@ -20,1 +19,3 @@ export * from './ParseTokenPhase'; | ||
export * from './ClearLogsPhase'; | ||
export * from './IdentifyTelemetryRequestPhase'; | ||
export * from './SendTelemetryActivityPhase'; |
@@ -38,4 +38,4 @@ import { ReadonlyContext, RiskApiData } from '../../context'; | ||
protected handleS2STimeout(riskApiData: RiskApiData): RiskApiData; | ||
protected handleS2SError(riskApiData: RiskApiData, response?: IIncomingResponse, error?: unknown): Promise<RiskApiData>; | ||
protected handleS2SError(riskApiData: RiskApiData, context: ReadonlyContext<Req, Res>, response?: IIncomingResponse, error?: unknown): Promise<RiskApiData>; | ||
} | ||
export declare const isEnforcerTimeoutError: (err: unknown) => boolean; |
@@ -14,2 +14,3 @@ import { BlockAction } from '../../blocker'; | ||
additional_risk_info?: string; | ||
telemetry_requested?: boolean; | ||
}; |
@@ -16,3 +16,4 @@ import { AsyncOrSync } from 'ts-essentials'; | ||
readonly additionalRiskInfo?: string; | ||
readonly telemetryRequested?: boolean; | ||
validate(): AsyncOrSync<boolean>; | ||
} |
@@ -24,4 +24,5 @@ import { PXDE } from '../../pxde'; | ||
get additionalRiskInfo(): string | undefined; | ||
get telemetryRequested(): boolean | undefined; | ||
get drc(): number | undefined; | ||
toJSON(): RiskResponseJson; | ||
} |
@@ -15,2 +15,3 @@ import { RiskStatus } from '../../model'; | ||
readonly additionalRiskInfo?: string; | ||
readonly telemetryRequested?: boolean; | ||
}; |
@@ -9,2 +9,3 @@ import { IRiskResponse } from '../IRiskResponse'; | ||
readonly additionalRiskInfo: string | undefined; | ||
readonly telemetryRequested: boolean | undefined; | ||
readonly dataEnrichment: PXDE | undefined; | ||
@@ -11,0 +12,0 @@ readonly drc: number | undefined; |
@@ -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.0"; | ||
export declare const CORE_MODULE_VERSION = "JS Core 0.24.1"; |
export * from './IRequestIdGenerator'; | ||
export * from './SimpleRequestIdGenerator'; |
{ | ||
"name": "perimeterx-js-core", | ||
"version": "0.24.0", | ||
"version": "0.24.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
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
1255323
0.63%1224
0.49%26106
0.61%