perimeterx-js-core 0.26.2 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/activities/utils.js +6 -3
- package/lib/cjs/config/ConfigurationBase.js +7 -0
- package/lib/cjs/config/defaults/DefaultConfigurationParams.js +1 -0
- package/lib/cjs/custom_parameters/CustomParametersUtils.js +38 -0
- package/lib/cjs/phase/impl/EnrichContextFromResponsePhase.js +19 -0
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/esm/activities/utils.js +5 -2
- package/lib/esm/config/ConfigurationBase.js +3 -0
- package/lib/esm/config/defaults/DefaultConfigurationParams.js +1 -0
- package/lib/esm/custom_parameters/CustomParametersUtils.js +28 -0
- package/lib/esm/phase/impl/EnrichContextFromResponsePhase.js +5 -0
- package/lib/esm/utils/constants.js +1 -1
- package/lib/types/activities/utils.d.ts +2 -2
- package/lib/types/config/ConfigurationBase.d.ts +2 -1
- package/lib/types/config/IConfiguration.d.ts +5 -1
- package/lib/types/config/params/CoreConfigurationParams.d.ts +2 -1
- package/lib/types/context/interfaces/IContext.d.ts +8 -1
- package/lib/types/custom_parameters/CustomParameters.d.ts +20 -1
- package/lib/types/custom_parameters/CustomParametersFunction.d.ts +2 -1
- package/lib/types/custom_parameters/CustomParametersUtils.d.ts +3 -1
- package/lib/types/custom_parameters/index.d.ts +2 -2
- package/lib/types/phase/impl/EnrichContextFromResponsePhase.d.ts +1 -0
- package/lib/types/utils/constants.d.ts +1 -1
- package/package.json +1 -1
|
@@ -66,7 +66,7 @@ var createAsyncActivityCommonDetails = function (context) {
|
|
|
66
66
|
};
|
|
67
67
|
exports.createAsyncActivityCommonDetails = createAsyncActivityCommonDetails;
|
|
68
68
|
var createCommonActivityDetails = function (config, context) {
|
|
69
|
-
var _a, _b;
|
|
69
|
+
var _a, _b, _c;
|
|
70
70
|
var details = {
|
|
71
71
|
module_version: config.moduleVersion,
|
|
72
72
|
// Note: risk_mode currently reflects only Bot Defender mode
|
|
@@ -79,7 +79,7 @@ var createCommonActivityDetails = function (config, context) {
|
|
|
79
79
|
(0, exports.addProductDataToDetails)(details, context.productData);
|
|
80
80
|
(0, exports.addServerDataToDetails)(details, context.serverData);
|
|
81
81
|
(0, exports.addTlsDataToDetails)(details, context.tlsData);
|
|
82
|
-
(0, exports.addCustomParametersToDetails)(details, (_b = context.customParameters) !== null && _b !== void 0 ? _b : null);
|
|
82
|
+
(0, exports.addCustomParametersToDetails)(details, (_b = context.customParameters) !== null && _b !== void 0 ? _b : null, (_c = context.responseCustomParameters) !== null && _c !== void 0 ? _c : null);
|
|
83
83
|
return details;
|
|
84
84
|
};
|
|
85
85
|
exports.createCommonActivityDetails = createCommonActivityDetails;
|
|
@@ -116,10 +116,13 @@ var addConfigDataToDetails = function (details, config) {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
exports.addConfigDataToDetails = addConfigDataToDetails;
|
|
119
|
-
var addCustomParametersToDetails = function (details, customParameters) {
|
|
119
|
+
var addCustomParametersToDetails = function (details, customParameters, responseCustomParameters) {
|
|
120
120
|
if (customParameters) {
|
|
121
121
|
Object.assign(details, customParameters);
|
|
122
122
|
}
|
|
123
|
+
if (responseCustomParameters) {
|
|
124
|
+
Object.assign(details, responseCustomParameters);
|
|
125
|
+
}
|
|
123
126
|
};
|
|
124
127
|
exports.addCustomParametersToDetails = addCustomParametersToDetails;
|
|
125
128
|
var addProductDataToDetails = function (details, productData) {
|
|
@@ -492,6 +492,13 @@ var ConfigurationBase = /** @class */ (function () {
|
|
|
492
492
|
enumerable: false,
|
|
493
493
|
configurable: true
|
|
494
494
|
});
|
|
495
|
+
Object.defineProperty(ConfigurationBase.prototype, "enrichResponseCustomParameters", {
|
|
496
|
+
get: function () {
|
|
497
|
+
return this.configParams.px_enrich_response_custom_parameters;
|
|
498
|
+
},
|
|
499
|
+
enumerable: false,
|
|
500
|
+
configurable: true
|
|
501
|
+
});
|
|
495
502
|
Object.defineProperty(ConfigurationBase.prototype, "additionalActivityHandler", {
|
|
496
503
|
get: function () {
|
|
497
504
|
return this.configParams.px_additional_activity_handler;
|
|
@@ -116,6 +116,7 @@ var defaultConfigurationParams = function () { return ({
|
|
|
116
116
|
px_sensitive_graphql_operation_names: [],
|
|
117
117
|
px_sensitive_graphql_operation_types: [],
|
|
118
118
|
px_enrich_custom_parameters: null,
|
|
119
|
+
px_enrich_response_custom_parameters: null,
|
|
119
120
|
px_jwt_cookie_name: '',
|
|
120
121
|
px_jwt_cookie_user_id_field_name: '',
|
|
121
122
|
px_jwt_cookie_additional_field_names: [],
|
|
@@ -62,6 +62,31 @@ var CustomParametersUtils;
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
}); };
|
|
65
|
+
CustomParametersUtils.createResponseCustomParameters = function (config, context) { return __awaiter(_this, void 0, void 0, function () {
|
|
66
|
+
var parameters, e_2;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
if (!(config.enrichResponseCustomParameters && typeof config.enrichResponseCustomParameters === 'function')) return [3 /*break*/, 4];
|
|
71
|
+
_a.label = 1;
|
|
72
|
+
case 1:
|
|
73
|
+
_a.trys.push([1, 3, , 4]);
|
|
74
|
+
if (!context.response) {
|
|
75
|
+
context.logger.debug('no response available for response custom parameters');
|
|
76
|
+
return [2 /*return*/, null];
|
|
77
|
+
}
|
|
78
|
+
return [4 /*yield*/, config.enrichResponseCustomParameters(config.getActiveConfig(), context.response.getUnderlyingResponse())];
|
|
79
|
+
case 2:
|
|
80
|
+
parameters = _a.sent();
|
|
81
|
+
return [2 /*return*/, CustomParametersUtils.normalizeResponseCustomParams(parameters)];
|
|
82
|
+
case 3:
|
|
83
|
+
e_2 = _a.sent();
|
|
84
|
+
context.logger.error("unable to enrich response custom params: ".concat(e_2));
|
|
85
|
+
return [3 /*break*/, 4];
|
|
86
|
+
case 4: return [2 /*return*/, null];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); };
|
|
65
90
|
CustomParametersUtils.normalizeCustomParams = function (customParameters) {
|
|
66
91
|
var normalizedParams = {};
|
|
67
92
|
if (customParameters && typeof customParameters === 'object') {
|
|
@@ -79,4 +104,17 @@ var CustomParametersUtils;
|
|
|
79
104
|
}
|
|
80
105
|
return Object.keys(normalizedParams).length === 0 ? null : normalizedParams;
|
|
81
106
|
};
|
|
107
|
+
CustomParametersUtils.normalizeResponseCustomParams = function (customParameters) {
|
|
108
|
+
var normalizedParams = {};
|
|
109
|
+
if (customParameters && typeof customParameters === 'object') {
|
|
110
|
+
var paramKeyRegex_2 = /^custom_param(1[1-9]|20)$/;
|
|
111
|
+
Object.entries(customParameters).forEach(function (_a) {
|
|
112
|
+
var param = _a[0], value = _a[1];
|
|
113
|
+
if (param.match(paramKeyRegex_2) && value !== '') {
|
|
114
|
+
normalizedParams[param] = value;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return Object.keys(normalizedParams).length === 0 ? null : normalizedParams;
|
|
119
|
+
};
|
|
82
120
|
})(CustomParametersUtils || (exports.CustomParametersUtils = CustomParametersUtils = {}));
|
|
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.EnrichContextFromResponsePhase = void 0;
|
|
40
40
|
var utils_1 = require("../../utils/index.js");
|
|
41
|
+
var custom_parameters_1 = require("../../custom_parameters/index.js");
|
|
41
42
|
/**
|
|
42
43
|
* `EnrichContextFromResponsePhase` enriches the context with response data. Each product's `enrichContextFromResponse`
|
|
43
44
|
* method is called since every product may use the response data differently.
|
|
@@ -55,6 +56,9 @@ var EnrichContextFromResponsePhase = /** @class */ (function () {
|
|
|
55
56
|
context.logger.debug('enrich context from response phase');
|
|
56
57
|
return [4 /*yield*/, this.addProductDataToContext(context)];
|
|
57
58
|
case 1:
|
|
59
|
+
_a.sent();
|
|
60
|
+
return [4 /*yield*/, this.addResponseCustomParametersToContext(context)];
|
|
61
|
+
case 2:
|
|
58
62
|
_a.sent();
|
|
59
63
|
return [2 /*return*/, { done: false }];
|
|
60
64
|
}
|
|
@@ -91,6 +95,21 @@ var EnrichContextFromResponsePhase = /** @class */ (function () {
|
|
|
91
95
|
});
|
|
92
96
|
});
|
|
93
97
|
};
|
|
98
|
+
EnrichContextFromResponsePhase.prototype.addResponseCustomParametersToContext = function (context) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
var _a;
|
|
101
|
+
return __generator(this, function (_b) {
|
|
102
|
+
switch (_b.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
_a = context;
|
|
105
|
+
return [4 /*yield*/, custom_parameters_1.CustomParametersUtils.createResponseCustomParameters(this.config, context)];
|
|
106
|
+
case 1:
|
|
107
|
+
_a.responseCustomParameters = _b.sent();
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
94
113
|
return EnrichContextFromResponsePhase;
|
|
95
114
|
}());
|
|
96
115
|
exports.EnrichContextFromResponsePhase = EnrichContextFromResponsePhase;
|
|
@@ -14,4 +14,4 @@ exports.PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
|
|
|
14
14
|
exports.EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
15
15
|
exports.URL_REGEX = /^(https?:)\/\/(([^@\s:\/]+):?([^@\s\/]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)(\/?[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
16
16
|
exports.REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
|
|
17
|
-
exports.CORE_MODULE_VERSION = 'JS Core 0.
|
|
17
|
+
exports.CORE_MODULE_VERSION = 'JS Core 0.27.0';
|
|
@@ -70,7 +70,7 @@ export const createCommonActivityDetails = (config, context) => {
|
|
|
70
70
|
addProductDataToDetails(details, context.productData);
|
|
71
71
|
addServerDataToDetails(details, context.serverData);
|
|
72
72
|
addTlsDataToDetails(details, context.tlsData);
|
|
73
|
-
addCustomParametersToDetails(details, context.customParameters ?? null);
|
|
73
|
+
addCustomParametersToDetails(details, context.customParameters ?? null, context.responseCustomParameters ?? null);
|
|
74
74
|
return details;
|
|
75
75
|
};
|
|
76
76
|
export const addRootContextDataToDetails = (details, context) => {
|
|
@@ -104,10 +104,13 @@ export const addConfigDataToDetails = (details, config) => {
|
|
|
104
104
|
details.remote_config_version = config.remoteConfigVersion;
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
export const addCustomParametersToDetails = (details, customParameters) => {
|
|
107
|
+
export const addCustomParametersToDetails = (details, customParameters, responseCustomParameters) => {
|
|
108
108
|
if (customParameters) {
|
|
109
109
|
Object.assign(details, customParameters);
|
|
110
110
|
}
|
|
111
|
+
if (responseCustomParameters) {
|
|
112
|
+
Object.assign(details, responseCustomParameters);
|
|
113
|
+
}
|
|
111
114
|
};
|
|
112
115
|
export const addProductDataToDetails = (details, productData) => {
|
|
113
116
|
if (productData.ad) {
|
|
@@ -273,6 +273,9 @@ export class ConfigurationBase {
|
|
|
273
273
|
get enrichCustomParameters() {
|
|
274
274
|
return this.configParams.px_enrich_custom_parameters;
|
|
275
275
|
}
|
|
276
|
+
get enrichResponseCustomParameters() {
|
|
277
|
+
return this.configParams.px_enrich_response_custom_parameters;
|
|
278
|
+
}
|
|
276
279
|
get additionalActivityHandler() {
|
|
277
280
|
return this.configParams.px_additional_activity_handler;
|
|
278
281
|
}
|
|
@@ -113,6 +113,7 @@ export const defaultConfigurationParams = () => ({
|
|
|
113
113
|
px_sensitive_graphql_operation_names: [],
|
|
114
114
|
px_sensitive_graphql_operation_types: [],
|
|
115
115
|
px_enrich_custom_parameters: null,
|
|
116
|
+
px_enrich_response_custom_parameters: null,
|
|
116
117
|
px_jwt_cookie_name: '',
|
|
117
118
|
px_jwt_cookie_user_id_field_name: '',
|
|
118
119
|
px_jwt_cookie_additional_field_names: [],
|
|
@@ -13,6 +13,22 @@ export var CustomParametersUtils;
|
|
|
13
13
|
}
|
|
14
14
|
return null;
|
|
15
15
|
};
|
|
16
|
+
CustomParametersUtils.createResponseCustomParameters = async (config, context) => {
|
|
17
|
+
if (config.enrichResponseCustomParameters && typeof config.enrichResponseCustomParameters === 'function') {
|
|
18
|
+
try {
|
|
19
|
+
if (!context.response) {
|
|
20
|
+
context.logger.debug('no response available for response custom parameters');
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const parameters = await config.enrichResponseCustomParameters(config.getActiveConfig(), context.response.getUnderlyingResponse());
|
|
24
|
+
return CustomParametersUtils.normalizeResponseCustomParams(parameters);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
context.logger.error(`unable to enrich response custom params: ${e}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
16
32
|
CustomParametersUtils.normalizeCustomParams = (customParameters) => {
|
|
17
33
|
const normalizedParams = {};
|
|
18
34
|
if (customParameters && typeof customParameters === 'object') {
|
|
@@ -29,4 +45,16 @@ export var CustomParametersUtils;
|
|
|
29
45
|
}
|
|
30
46
|
return Object.keys(normalizedParams).length === 0 ? null : normalizedParams;
|
|
31
47
|
};
|
|
48
|
+
CustomParametersUtils.normalizeResponseCustomParams = (customParameters) => {
|
|
49
|
+
const normalizedParams = {};
|
|
50
|
+
if (customParameters && typeof customParameters === 'object') {
|
|
51
|
+
const paramKeyRegex = /^custom_param(1[1-9]|20)$/;
|
|
52
|
+
Object.entries(customParameters).forEach(([param, value]) => {
|
|
53
|
+
if (param.match(paramKeyRegex) && value !== '') {
|
|
54
|
+
normalizedParams[param] = value;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return Object.keys(normalizedParams).length === 0 ? null : normalizedParams;
|
|
59
|
+
};
|
|
32
60
|
})(CustomParametersUtils || (CustomParametersUtils = {}));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNullOrUndefined } from '../../utils/index.js';
|
|
2
|
+
import { CustomParametersUtils } from '../../custom_parameters/index.js';
|
|
2
3
|
/**
|
|
3
4
|
* `EnrichContextFromResponsePhase` enriches the context with response data. Each product's `enrichContextFromResponse`
|
|
4
5
|
* method is called since every product may use the response data differently.
|
|
@@ -13,6 +14,7 @@ export class EnrichContextFromResponsePhase {
|
|
|
13
14
|
async execute(context) {
|
|
14
15
|
context.logger.debug('enrich context from response phase');
|
|
15
16
|
await this.addProductDataToContext(context);
|
|
17
|
+
await this.addResponseCustomParametersToContext(context);
|
|
16
18
|
return { done: false };
|
|
17
19
|
}
|
|
18
20
|
async addProductDataToContext(context) {
|
|
@@ -23,4 +25,7 @@ export class EnrichContextFromResponsePhase {
|
|
|
23
25
|
}
|
|
24
26
|
}));
|
|
25
27
|
}
|
|
28
|
+
async addResponseCustomParametersToContext(context) {
|
|
29
|
+
context.responseCustomParameters = await CustomParametersUtils.createResponseCustomParameters(this.config, context);
|
|
30
|
+
}
|
|
26
31
|
}
|
|
@@ -11,4 +11,4 @@ export const PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
|
|
|
11
11
|
export const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
12
12
|
export const URL_REGEX = /^(https?:)\/\/(([^@\s:\/]+):?([^@\s\/]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)(\/?[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
13
13
|
export const REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
|
|
14
|
-
export const CORE_MODULE_VERSION = 'JS Core 0.
|
|
14
|
+
export const CORE_MODULE_VERSION = 'JS Core 0.27.0';
|
|
@@ -4,7 +4,7 @@ import { IConfiguration } from '../config';
|
|
|
4
4
|
import { ProductData } from '../products';
|
|
5
5
|
import { ActivityType } from './ActivityType';
|
|
6
6
|
import { AdditionalS2SActivityDetails, AsyncActivity, AsyncActivityCommonDetails, AsyncActivityDetails, BlockActivityDetails, CommonActivityDetails, HeaderEntry, PageRequestedActivityDetails } from './model';
|
|
7
|
-
import { CustomParameters } from '../custom_parameters';
|
|
7
|
+
import { CustomParameters, ResponseCustomParameters } from '../custom_parameters';
|
|
8
8
|
/**
|
|
9
9
|
* Creates an async activity object based on the provided parameters.
|
|
10
10
|
* @param activityType - The activity type to create.
|
|
@@ -26,7 +26,7 @@ export declare const createCommonActivityDetails: <Req, Res, Added, Removed>(con
|
|
|
26
26
|
export declare const addRootContextDataToDetails: <Req, Res>(details: CommonActivityDetails, context: ReadonlyContext<Req, Res>) => void;
|
|
27
27
|
export declare function redactCookieSecret(secret: string): string;
|
|
28
28
|
export declare const addConfigDataToDetails: <Req, Res, Added, Removed>(details: CommonActivityDetails, config: IConfiguration<Req, Res, Added, Removed>) => void;
|
|
29
|
-
export declare const addCustomParametersToDetails: (details: CommonActivityDetails, customParameters: CustomParameters | null) => void;
|
|
29
|
+
export declare const addCustomParametersToDetails: (details: CommonActivityDetails, customParameters: CustomParameters | null, responseCustomParameters: ResponseCustomParameters | null) => void;
|
|
30
30
|
export declare const addProductDataToDetails: (details: CommonActivityDetails, productData: DeepReadonly<ProductData>) => void;
|
|
31
31
|
export declare const addTlsDataToDetails: (details: CommonActivityDetails, tlsData: DeepReadonly<TlsData>) => void;
|
|
32
32
|
export declare const addServerDataToDetails: (details: CommonActivityDetails, serverData: DeepReadonly<ServerData>) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConfiguration } from './IConfiguration';
|
|
2
2
|
import { RemoteConfigurationParams, StaticConfigurationParams, AllConfigurationParams, RequiredAllConfigurationParams, ActiveConfigurationParams, CoreConfigurationParams } from './params';
|
|
3
|
-
import { CustomParametersFunction } from '../custom_parameters';
|
|
3
|
+
import { CustomParametersFunction, ResponseCustomParametersFunction } from '../custom_parameters';
|
|
4
4
|
import { AdditionalActivityHandler } from '../additional_activity_handler';
|
|
5
5
|
import { ILogger, LoggerSeverity } from '../logger';
|
|
6
6
|
import { CustomBlockResponseHeadersHandler, CustomPreflightHandler } from '../cors';
|
|
@@ -104,6 +104,7 @@ export declare abstract class ConfigurationBase<Req, Res, Added, Removed extends
|
|
|
104
104
|
get sensitiveGraphqlOperationNames(): Array<string | RegExp>;
|
|
105
105
|
get sensitiveGraphqlOperationTypes(): string[];
|
|
106
106
|
get enrichCustomParameters(): CustomParametersFunction<Req, Res, Added, Removed> | null;
|
|
107
|
+
get enrichResponseCustomParameters(): ResponseCustomParametersFunction<Req, Res, Added, Removed> | null;
|
|
107
108
|
get additionalActivityHandler(): AdditionalActivityHandler<Req, Res, Added, Removed> | null;
|
|
108
109
|
get altBackendCaptchaUrl(): string;
|
|
109
110
|
get corsSupportEnabled(): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModuleMode } from '../utils';
|
|
2
2
|
import { ILogger, LoggerSeverity } from '../logger';
|
|
3
|
-
import { CustomParametersFunction } from '../custom_parameters';
|
|
3
|
+
import { CustomParametersFunction, ResponseCustomParametersFunction } from '../custom_parameters';
|
|
4
4
|
import { AdditionalActivityHandler } from '../additional_activity_handler';
|
|
5
5
|
import { ActiveConfigurationParams, RemoteConfigurationParams, StaticConfigurationParams } from './params';
|
|
6
6
|
import { CustomBlockResponseHeadersHandler, CustomPreflightHandler } from '../cors';
|
|
@@ -243,6 +243,10 @@ export interface IConfiguration<Req, Res, Added, Removed> {
|
|
|
243
243
|
* A function returning CustomParameters that will be added to the enforcer activities.
|
|
244
244
|
*/
|
|
245
245
|
readonly enrichCustomParameters: CustomParametersFunction<Req, Res, Added, Removed> | null;
|
|
246
|
+
/**
|
|
247
|
+
* A function returning ResponseCustomParameters that will be added to the enforcer activities.
|
|
248
|
+
*/
|
|
249
|
+
readonly enrichResponseCustomParameters: ResponseCustomParametersFunction<Req, Res, Added, Removed> | null;
|
|
246
250
|
/**
|
|
247
251
|
* A function that will be called after the asynchronous activities are sent to the backend.
|
|
248
252
|
*/
|
|
@@ -3,7 +3,7 @@ import { ModuleMode } from '../../utils';
|
|
|
3
3
|
import { CredentialEndpointConfiguration, CredentialIntelligenceVersion, CustomLoginSuccessfulCallback, LoginSuccessfulReportingMethod } from '../../products';
|
|
4
4
|
import { GraphQLOperationType, ExtractGraphQLKeywordsFunction } from '../../graphql';
|
|
5
5
|
import { AdditionalActivityHandler } from '../../additional_activity_handler';
|
|
6
|
-
import { CustomParametersFunction } from '../../custom_parameters';
|
|
6
|
+
import { CustomParametersFunction, ResponseCustomParametersFunction } from '../../custom_parameters';
|
|
7
7
|
import { CustomBlockResponseHeadersHandler, CustomPreflightHandler } from '../../cors';
|
|
8
8
|
import { CustomRequestFunction } from '../CustomRequestFunction';
|
|
9
9
|
import { TokenVersion } from '../../risk_token';
|
|
@@ -121,6 +121,7 @@ export type CommonConfigurationParams<Req, Res, Added, Removed> = TokenV3Configu
|
|
|
121
121
|
px_secured_pxhd_enabled?: boolean;
|
|
122
122
|
px_additional_activity_handler?: AdditionalActivityHandler<Req, Res, Added, Removed> | null;
|
|
123
123
|
px_enrich_custom_parameters?: CustomParametersFunction<Req, Res, Added, Removed> | null;
|
|
124
|
+
px_enrich_response_custom_parameters?: ResponseCustomParametersFunction<Req, Res, Added, Removed> | null;
|
|
124
125
|
px_login_successful_custom_callback?: CustomLoginSuccessfulCallback<Res> | null;
|
|
125
126
|
px_cors_custom_preflight_handler?: CustomPreflightHandler<Req> | null;
|
|
126
127
|
px_cors_create_custom_block_response_headers?: CustomBlockResponseHeadersHandler<Req> | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VidSource } from '../../utils';
|
|
2
2
|
import { BlockAction } from '../../blocker';
|
|
3
|
-
import { CustomParameters } from '../../custom_parameters';
|
|
3
|
+
import { CustomParameters, ResponseCustomParameters } from '../../custom_parameters';
|
|
4
4
|
import { PXDE } from '../../pxde';
|
|
5
5
|
import { TokenOrigin } from '../../risk_token';
|
|
6
6
|
import { RequestData } from './RequestData';
|
|
@@ -109,6 +109,13 @@ export interface IContext<Req, Res> {
|
|
|
109
109
|
* custom parameters will be added to the activities sent to the collector.
|
|
110
110
|
*/
|
|
111
111
|
customParameters?: CustomParameters | null;
|
|
112
|
+
/**
|
|
113
|
+
* An object with 10 additional custom parameters (11-20) that the customer can set and define
|
|
114
|
+
* based on the response from the origin. These custom parameters will be added to all async
|
|
115
|
+
* activities sent to the collector, including page_requested, (simulated) block,
|
|
116
|
+
* and additional_s2s activities.
|
|
117
|
+
*/
|
|
118
|
+
responseCustomParameters?: ResponseCustomParameters | null;
|
|
112
119
|
/**
|
|
113
120
|
* An array of objects with information about the different GraphQL operations
|
|
114
121
|
* parsed from the request.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { IS_HYPESALE_PARAM_NAME } from '../products';
|
|
2
2
|
/**
|
|
3
|
-
* Custom parameters defined by the user
|
|
3
|
+
* Custom parameters (1-10) defined by the user that will be added to all activities sent to HUMAN backend,
|
|
4
|
+
* including page_requested, block (and simulated block), and additional_s2s activities.
|
|
5
|
+
* These parameters are extracted from the incoming request.
|
|
4
6
|
*/
|
|
5
7
|
export type CustomParameters = {
|
|
6
8
|
custom_param1?: any;
|
|
@@ -15,3 +17,20 @@ export type CustomParameters = {
|
|
|
15
17
|
custom_param10?: any;
|
|
16
18
|
[IS_HYPESALE_PARAM_NAME]?: boolean;
|
|
17
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Response-based custom parameters (11-20) defined by the user that will be added to all async activities sent to HUMAN backend,
|
|
22
|
+
* including page_requested, simulated block, and additional_s2s activities.
|
|
23
|
+
* These parameters are extracted from the origin response after it has been received.
|
|
24
|
+
*/
|
|
25
|
+
export type ResponseCustomParameters = {
|
|
26
|
+
custom_param11?: any;
|
|
27
|
+
custom_param12?: any;
|
|
28
|
+
custom_param13?: any;
|
|
29
|
+
custom_param14?: any;
|
|
30
|
+
custom_param15?: any;
|
|
31
|
+
custom_param16?: any;
|
|
32
|
+
custom_param17?: any;
|
|
33
|
+
custom_param18?: any;
|
|
34
|
+
custom_param19?: any;
|
|
35
|
+
custom_param20?: any;
|
|
36
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { CustomParameters } from './CustomParameters';
|
|
1
|
+
import { CustomParameters, ResponseCustomParameters } from './CustomParameters';
|
|
2
2
|
import { ActiveConfigurationParams } from '../config';
|
|
3
3
|
export type CustomParametersFunction<Req, Res, Added, Removed> = (config: ActiveConfigurationParams<Req, Res, Added, Removed>, request: Req) => CustomParameters | Promise<CustomParameters>;
|
|
4
|
+
export type ResponseCustomParametersFunction<Req, Res, Added, Removed> = (config: ActiveConfigurationParams<Req, Res, Added, Removed>, response: Res) => ResponseCustomParameters | Promise<ResponseCustomParameters>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { IConfiguration } from '../config';
|
|
2
2
|
import { ReadonlyContext } from '../context';
|
|
3
|
-
import { CustomParameters } from './CustomParameters';
|
|
3
|
+
import { CustomParameters, ResponseCustomParameters } from './CustomParameters';
|
|
4
4
|
export declare namespace CustomParametersUtils {
|
|
5
5
|
const createCustomParameters: <Req, Res, Added, Removed>(config: IConfiguration<Req, Res, Added, Removed>, context: ReadonlyContext<Req, Res>) => Promise<CustomParameters | null>;
|
|
6
|
+
const createResponseCustomParameters: <Req, Res, Added, Removed>(config: IConfiguration<Req, Res, Added, Removed>, context: ReadonlyContext<Req, Res>) => Promise<ResponseCustomParameters | null>;
|
|
6
7
|
const normalizeCustomParams: (customParameters: Record<string, any>) => CustomParameters | null;
|
|
8
|
+
const normalizeResponseCustomParams: (customParameters: Record<string, any>) => ResponseCustomParameters | null;
|
|
7
9
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CustomParameters } from './CustomParameters';
|
|
1
|
+
export { CustomParameters, ResponseCustomParameters } from './CustomParameters';
|
|
2
|
+
export { CustomParametersFunction, ResponseCustomParametersFunction } from './CustomParametersFunction';
|
|
2
3
|
export { CustomParametersUtils } from './CustomParametersUtils';
|
|
3
|
-
export { CustomParametersFunction } from './CustomParametersFunction';
|
|
@@ -13,4 +13,5 @@ export declare class EnrichContextFromResponsePhase<Req, Res, Added, Removed> im
|
|
|
13
13
|
constructor(config: IConfiguration<Req, Res, Added, Removed>, products: Products<Req, Res>);
|
|
14
14
|
execute(context: IContext<Req, Res>): Promise<PhaseResult>;
|
|
15
15
|
protected addProductDataToContext(context: IContext<Req, Res>): Promise<void>;
|
|
16
|
+
protected addResponseCustomParametersToContext(context: IContext<Req, Res>): Promise<void>;
|
|
16
17
|
}
|
|
@@ -11,4 +11,4 @@ export declare const PUSH_DATA_FEATURE_HEADER_NAME = "x-px-feature";
|
|
|
11
11
|
export declare const EMAIL_ADDRESS_REGEX: RegExp;
|
|
12
12
|
export declare const URL_REGEX: RegExp;
|
|
13
13
|
export declare const REGEX_STRUCTURE: RegExp;
|
|
14
|
-
export declare const CORE_MODULE_VERSION = "JS Core 0.
|
|
14
|
+
export declare const CORE_MODULE_VERSION = "JS Core 0.27.0";
|