perimeterx-js-core 0.36.0 → 0.37.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.
Files changed (52) hide show
  1. package/lib/cjs/activities/utils.js +20 -0
  2. package/lib/cjs/config/ConfigurationBase.js +14 -0
  3. package/lib/cjs/config/defaults/DefaultConfigurationParams.js +2 -0
  4. package/lib/cjs/context/DefaultContext.js +4 -0
  5. package/lib/cjs/context/SerializedContext.js +1 -0
  6. package/lib/cjs/enforcer/utils.js +2 -0
  7. package/lib/cjs/products/agentic_trust/AgenticTrust.js +163 -0
  8. package/lib/cjs/products/agentic_trust/IAgenticTrust.js +2 -0
  9. package/lib/cjs/products/agentic_trust/index.js +19 -0
  10. package/lib/cjs/products/agentic_trust/model/AgenticTrustData.js +2 -0
  11. package/lib/cjs/products/agentic_trust/model/index.js +17 -0
  12. package/lib/cjs/products/index.js +1 -0
  13. package/lib/cjs/products/utils/ProductName.js +1 -0
  14. package/lib/cjs/products/utils/ProductPriorityOrder.js +1 -0
  15. package/lib/cjs/risk_api/model/GetRiskRequestHeaders.js +18 -0
  16. package/lib/cjs/utils/constants.js +1 -1
  17. package/lib/esm/activities/utils.js +20 -0
  18. package/lib/esm/config/ConfigurationBase.js +6 -0
  19. package/lib/esm/config/defaults/DefaultConfigurationParams.js +2 -0
  20. package/lib/esm/context/DefaultContext.js +5 -0
  21. package/lib/esm/context/SerializedContext.js +2 -0
  22. package/lib/esm/enforcer/utils.js +3 -1
  23. package/lib/esm/products/agentic_trust/AgenticTrust.js +84 -0
  24. package/lib/esm/products/agentic_trust/IAgenticTrust.js +1 -0
  25. package/lib/esm/products/agentic_trust/index.js +3 -0
  26. package/lib/esm/products/agentic_trust/model/AgenticTrustData.js +1 -0
  27. package/lib/esm/products/agentic_trust/model/index.js +1 -0
  28. package/lib/esm/products/index.js +1 -0
  29. package/lib/esm/products/utils/ProductName.js +1 -0
  30. package/lib/esm/products/utils/ProductPriorityOrder.js +1 -0
  31. package/lib/esm/risk_api/model/GetRiskRequestHeaders.js +18 -0
  32. package/lib/esm/utils/constants.js +1 -1
  33. package/lib/types/activities/model/CommonActivityDetails.d.ts +6 -0
  34. package/lib/types/config/ConfigurationBase.d.ts +2 -0
  35. package/lib/types/config/IConfiguration.d.ts +8 -0
  36. package/lib/types/config/params/CoreConfigurationParams.d.ts +2 -0
  37. package/lib/types/context/ContextJson.d.ts +1 -0
  38. package/lib/types/context/DefaultContext.d.ts +1 -0
  39. package/lib/types/context/SerializedContext.d.ts +1 -0
  40. package/lib/types/context/interfaces/IContext.d.ts +4 -0
  41. package/lib/types/products/agentic_trust/AgenticTrust.d.ts +15 -0
  42. package/lib/types/products/agentic_trust/IAgenticTrust.d.ts +4 -0
  43. package/lib/types/products/agentic_trust/index.d.ts +3 -0
  44. package/lib/types/products/agentic_trust/model/AgenticTrustData.d.ts +7 -0
  45. package/lib/types/products/agentic_trust/model/index.d.ts +1 -0
  46. package/lib/types/products/index.d.ts +1 -0
  47. package/lib/types/products/interfaces/ProductDataType.d.ts +2 -1
  48. package/lib/types/products/interfaces/ProductType.d.ts +2 -1
  49. package/lib/types/products/utils/ProductName.d.ts +2 -1
  50. package/lib/types/risk_api/utils.d.ts +6 -0
  51. package/lib/types/utils/constants.d.ts +1 -1
  52. package/package.json +1 -1
@@ -93,6 +93,9 @@ var addRootContextDataToDetails = function (details, context) {
93
93
  if (context.vidSource) {
94
94
  details.enforcer_vid_source = context.vidSource;
95
95
  }
96
+ if (context.origCookieVid) {
97
+ details.orig_cookie_vid = context.origCookieVid;
98
+ }
96
99
  if (context.graphqlData) {
97
100
  details.graphql_operations = context.graphqlData;
98
101
  }
@@ -161,6 +164,23 @@ var addProductDataToDetails = function (details, productData) {
161
164
  details.is_sensitive_route = productData.bd.isSensitiveRequest;
162
165
  }
163
166
  }
167
+ if (productData.at) {
168
+ if (productData.at.mcpMethod) {
169
+ details.mcp_method = productData.at.mcpMethod;
170
+ }
171
+ if (productData.at.mcpToolName) {
172
+ details.mcp_tool_name = productData.at.mcpToolName;
173
+ }
174
+ if (productData.at.mcpToolArgumentKeys) {
175
+ details.mcp_tool_argument_keys = productData.at.mcpToolArgumentKeys;
176
+ }
177
+ if (productData.at.mcpSessionId) {
178
+ details.mcp_session_id = productData.at.mcpSessionId;
179
+ }
180
+ if (productData.at.mcpHttpMethod) {
181
+ details.mcp_http_method = productData.at.mcpHttpMethod;
182
+ }
183
+ }
164
184
  };
165
185
  exports.addProductDataToDetails = addProductDataToDetails;
166
186
  var addTlsDataToDetails = function (details, tlsData) {
@@ -790,6 +790,20 @@ var ConfigurationBase = /** @class */ (function () {
790
790
  enumerable: false,
791
791
  configurable: true
792
792
  });
793
+ Object.defineProperty(ConfigurationBase.prototype, "agenticTrustEnabled", {
794
+ get: function () {
795
+ return this.configParams.px_agentic_trust_enabled;
796
+ },
797
+ enumerable: false,
798
+ configurable: true
799
+ });
800
+ Object.defineProperty(ConfigurationBase.prototype, "agenticTrustMcpEndpointPath", {
801
+ get: function () {
802
+ return this.configParams.px_agentic_trust_mcp_endpoint_path;
803
+ },
804
+ enumerable: false,
805
+ configurable: true
806
+ });
793
807
  Object.defineProperty(ConfigurationBase.prototype, "enableBlockedUrlOnCaptchaBlockPage", {
794
808
  get: function () {
795
809
  return true;
@@ -141,5 +141,7 @@ var defaultConfigurationParams = function () { return ({
141
141
  px_custom_is_enforced_request: null,
142
142
  px_custom_is_filtered_request: null,
143
143
  px_extract_graphql_keywords: null,
144
+ px_agentic_trust_enabled: false,
145
+ px_agentic_trust_mcp_endpoint_path: '/mcp',
144
146
  }); };
145
147
  exports.defaultConfigurationParams = defaultConfigurationParams;
@@ -152,6 +152,9 @@ var DefaultContext = /** @class */ (function () {
152
152
  this.vid = vidValue;
153
153
  this.vidSource = utils_1.VidSource.VID_COOKIE;
154
154
  }
155
+ else if (vidValue) {
156
+ this.origCookieVid = vidValue;
157
+ }
155
158
  var pxhdCookie = this.requestData.cookies[utils_1.PXHD_COOKIE_NAME];
156
159
  if (pxhdCookie) {
157
160
  this.pxhd = {
@@ -184,6 +187,7 @@ var DefaultContext = /** @class */ (function () {
184
187
  customParameters: this.customParameters,
185
188
  graphqlData: this.graphqlData,
186
189
  vid: this.vid,
190
+ origCookieVid: this.origCookieVid,
187
191
  vidSource: this.vidSource,
188
192
  uuid: this.uuid,
189
193
  enforcerStartTime: this.enforcerStartTime,
@@ -39,6 +39,7 @@ var SerializedContext = /** @class */ (function () {
39
39
  this.tokenOrigin = contextJson.tokenOrigin;
40
40
  this.uuid = contextJson.uuid;
41
41
  this.vid = contextJson.vid;
42
+ this.origCookieVid = contextJson.origCookieVid;
42
43
  this.vidSource = contextJson.vidSource;
43
44
  this.pxhd = contextJson.pxhd;
44
45
  this.pxde = contextJson.pxde;
@@ -68,12 +68,14 @@ var createEnforcerProducts = function (config, products, base64Utils, hashUtils,
68
68
  var accountDefender = (products === null || products === void 0 ? void 0 : products.ad) || new products_1.AccountDefender(config, { base64Utils: base64Utils });
69
69
  var credentialIntelligence = (products === null || products === void 0 ? void 0 : products.ci) || new products_1.CredentialIntelligence(config, { hashUtils: hashUtils, urlUtils: urlUtils });
70
70
  var hypeSaleChallenge = (products === null || products === void 0 ? void 0 : products.hsc) || new products_1.HypeSaleChallenge(config, { base64Utils: base64Utils });
71
+ var agenticTrust = (products === null || products === void 0 ? void 0 : products.at) || new products_1.AgenticTrust(config);
71
72
  return _a = {},
72
73
  _a[products_1.ProductName.BOT_DEFENDER] = botDefender,
73
74
  _a[products_1.ProductName.ACCOUNT_DEFENDER] = accountDefender,
74
75
  _a[products_1.ProductName.CODE_DEFENDER] = products === null || products === void 0 ? void 0 : products.cd,
75
76
  _a[products_1.ProductName.CREDENTIAL_INTELLIGENCE] = credentialIntelligence,
76
77
  _a[products_1.ProductName.HYPE_SALE_CHALLENGE] = hypeSaleChallenge,
78
+ _a[products_1.ProductName.AGENTIC_TRUST] = agenticTrust,
77
79
  _a;
78
80
  };
79
81
  exports.createEnforcerProducts = createEnforcerProducts;
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AgenticTrust = void 0;
40
+ var http_1 = require("../../http/index.js");
41
+ var MCP_SESSION_ID_HEADER = 'mcp-session-id';
42
+ var AgenticTrust = /** @class */ (function () {
43
+ function AgenticTrust(config) {
44
+ this.config = config;
45
+ }
46
+ AgenticTrust.prototype.enrichContextFromRequest = function (context) {
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ var data, sessionId;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0:
52
+ if (!this.config.agenticTrustEnabled) {
53
+ return [2 /*return*/, null];
54
+ }
55
+ if (!this.isMatchingEndpoint(context)) {
56
+ return [2 /*return*/, null];
57
+ }
58
+ data = {
59
+ mcpHttpMethod: context.requestData.method,
60
+ };
61
+ sessionId = context.requestData.request.headers.get(MCP_SESSION_ID_HEADER);
62
+ if (sessionId) {
63
+ data.mcpSessionId = sessionId;
64
+ }
65
+ if (!(context.requestData.method === http_1.HttpMethod.POST)) return [3 /*break*/, 2];
66
+ return [4 /*yield*/, this.extractFromBody(context, data)];
67
+ case 1:
68
+ _a.sent();
69
+ _a.label = 2;
70
+ case 2: return [2 /*return*/, data];
71
+ }
72
+ });
73
+ });
74
+ };
75
+ AgenticTrust.prototype.enrichContextFromRiskApi = function (_context) {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ return __generator(this, function (_a) {
78
+ return [2 /*return*/, null];
79
+ });
80
+ });
81
+ };
82
+ AgenticTrust.prototype.modifyIncomingRequest = function (_context) {
83
+ return __awaiter(this, void 0, void 0, function () {
84
+ return __generator(this, function (_a) {
85
+ return [2 /*return*/];
86
+ });
87
+ });
88
+ };
89
+ AgenticTrust.prototype.enrichContextFromResponse = function (context) {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ var responseHeaders, sessionId;
92
+ var _a;
93
+ return __generator(this, function (_b) {
94
+ if (!context.productData.at) {
95
+ return [2 /*return*/, null];
96
+ }
97
+ if (context.productData.at.mcpSessionId) {
98
+ return [2 /*return*/, null];
99
+ }
100
+ responseHeaders = (_a = context.response) === null || _a === void 0 ? void 0 : _a.headers;
101
+ if (!responseHeaders) {
102
+ return [2 /*return*/, null];
103
+ }
104
+ sessionId = responseHeaders.get(MCP_SESSION_ID_HEADER);
105
+ if (sessionId) {
106
+ return [2 /*return*/, { mcpSessionId: sessionId }];
107
+ }
108
+ return [2 /*return*/, null];
109
+ });
110
+ });
111
+ };
112
+ AgenticTrust.prototype.modifyOutgoingResponse = function (_context) {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ return __generator(this, function (_a) {
115
+ return [2 /*return*/];
116
+ });
117
+ });
118
+ };
119
+ AgenticTrust.prototype.isMatchingEndpoint = function (context) {
120
+ var pathname = context.requestData.url.pathname.replace(/\/+$/, '');
121
+ var configuredPath = this.config.agenticTrustMcpEndpointPath.replace(/\/+$/, '');
122
+ return pathname === configuredPath;
123
+ };
124
+ AgenticTrust.prototype.extractFromBody = function (context, data) {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ var body, jsonRpcMessage, _a;
127
+ return __generator(this, function (_b) {
128
+ switch (_b.label) {
129
+ case 0:
130
+ _b.trys.push([0, 2, , 3]);
131
+ return [4 /*yield*/, context.requestData.request.json()];
132
+ case 1:
133
+ body = _b.sent();
134
+ if (!body) {
135
+ return [2 /*return*/];
136
+ }
137
+ jsonRpcMessage = Array.isArray(body) ? body[0] : body;
138
+ if (!jsonRpcMessage) {
139
+ return [2 /*return*/];
140
+ }
141
+ if (typeof jsonRpcMessage.method === 'string') {
142
+ data.mcpMethod = jsonRpcMessage.method;
143
+ }
144
+ if (jsonRpcMessage.params) {
145
+ if (typeof jsonRpcMessage.params.name === 'string') {
146
+ data.mcpToolName = jsonRpcMessage.params.name;
147
+ }
148
+ if (jsonRpcMessage.params.arguments && typeof jsonRpcMessage.params.arguments === 'object') {
149
+ data.mcpToolArgumentKeys = Object.keys(jsonRpcMessage.params.arguments).join(',');
150
+ }
151
+ }
152
+ return [3 /*break*/, 3];
153
+ case 2:
154
+ _a = _b.sent();
155
+ return [3 /*break*/, 3];
156
+ case 3: return [2 /*return*/];
157
+ }
158
+ });
159
+ });
160
+ };
161
+ return AgenticTrust;
162
+ }());
163
+ exports.AgenticTrust = AgenticTrust;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AgenticTrust.js"), exports);
18
+ __exportStar(require("./IAgenticTrust.js"), exports);
19
+ __exportStar(require("./model/index.js"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AgenticTrustData.js"), exports);
@@ -20,3 +20,4 @@ __exportStar(require("./bot_defender/index.js"), exports);
20
20
  __exportStar(require("./credential_intelligence/index.js"), exports);
21
21
  __exportStar(require("./account_defender/index.js"), exports);
22
22
  __exportStar(require("./hype_sale_challenge/index.js"), exports);
23
+ __exportStar(require("./agentic_trust/index.js"), exports);
@@ -8,4 +8,5 @@ var ProductName;
8
8
  ProductName["CODE_DEFENDER"] = "cd";
9
9
  ProductName["CREDENTIAL_INTELLIGENCE"] = "ci";
10
10
  ProductName["HYPE_SALE_CHALLENGE"] = "hsc";
11
+ ProductName["AGENTIC_TRUST"] = "at";
11
12
  })(ProductName || (exports.ProductName = ProductName = {}));
@@ -8,4 +8,5 @@ exports.PRODUCT_PRIORITY_ORDER = [
8
8
  ProductName_1.ProductName.ACCOUNT_DEFENDER,
9
9
  ProductName_1.ProductName.CREDENTIAL_INTELLIGENCE,
10
10
  ProductName_1.ProductName.CODE_DEFENDER,
11
+ ProductName_1.ProductName.AGENTIC_TRUST,
11
12
  ];
@@ -97,6 +97,9 @@ exports.RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES = {
97
97
  enforcer_vid_source: {
98
98
  header: 'x-px-add-enforcer-vid-source',
99
99
  },
100
+ orig_cookie_vid: {
101
+ header: 'x-px-add-orig-cookie-vid',
102
+ },
100
103
  server_info_datacenter: {
101
104
  header: 'x-px-add-server-info-datacenter',
102
105
  },
@@ -186,4 +189,19 @@ exports.RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES = {
186
189
  header: 'x-px-add-is-sensitive-route',
187
190
  convertToString: function (value) { return "".concat(value); },
188
191
  },
192
+ mcp_method: {
193
+ header: 'x-px-add-mcp-method',
194
+ },
195
+ mcp_tool_name: {
196
+ header: 'x-px-add-mcp-tool-name',
197
+ },
198
+ mcp_tool_argument_keys: {
199
+ header: 'x-px-add-mcp-tool-argument-keys',
200
+ },
201
+ mcp_session_id: {
202
+ header: 'x-px-add-mcp-session-id',
203
+ },
204
+ mcp_http_method: {
205
+ header: 'x-px-add-mcp-http-method',
206
+ },
189
207
  };
@@ -15,4 +15,4 @@ exports.PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
15
15
  exports.EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
16
16
  exports.URL_REGEX = /^(https?:)\/\/(([^@\s:\/]+):?([^@\s\/]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)(\/?[^?#]*)(\?[^#]*|)(#.*|)$/;
17
17
  exports.REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
18
- exports.CORE_MODULE_VERSION = 'JS Core 0.36.0';
18
+ exports.CORE_MODULE_VERSION = 'JS Core 0.37.0';
@@ -83,6 +83,9 @@ export const addRootContextDataToDetails = (details, context) => {
83
83
  if (context.vidSource) {
84
84
  details.enforcer_vid_source = context.vidSource;
85
85
  }
86
+ if (context.origCookieVid) {
87
+ details.orig_cookie_vid = context.origCookieVid;
88
+ }
86
89
  if (context.graphqlData) {
87
90
  details.graphql_operations = context.graphqlData;
88
91
  }
@@ -148,6 +151,23 @@ export const addProductDataToDetails = (details, productData) => {
148
151
  details.is_sensitive_route = productData.bd.isSensitiveRequest;
149
152
  }
150
153
  }
154
+ if (productData.at) {
155
+ if (productData.at.mcpMethod) {
156
+ details.mcp_method = productData.at.mcpMethod;
157
+ }
158
+ if (productData.at.mcpToolName) {
159
+ details.mcp_tool_name = productData.at.mcpToolName;
160
+ }
161
+ if (productData.at.mcpToolArgumentKeys) {
162
+ details.mcp_tool_argument_keys = productData.at.mcpToolArgumentKeys;
163
+ }
164
+ if (productData.at.mcpSessionId) {
165
+ details.mcp_session_id = productData.at.mcpSessionId;
166
+ }
167
+ if (productData.at.mcpHttpMethod) {
168
+ details.mcp_http_method = productData.at.mcpHttpMethod;
169
+ }
170
+ }
151
171
  };
152
172
  export const addTlsDataToDetails = (details, tlsData) => {
153
173
  if (tlsData.tlsCipher) {
@@ -412,6 +412,12 @@ export class ConfigurationBase {
412
412
  get proxyUrl() {
413
413
  return this.configParams.px_proxy_url;
414
414
  }
415
+ get agenticTrustEnabled() {
416
+ return this.configParams.px_agentic_trust_enabled;
417
+ }
418
+ get agenticTrustMcpEndpointPath() {
419
+ return this.configParams.px_agentic_trust_mcp_endpoint_path;
420
+ }
415
421
  get enableBlockedUrlOnCaptchaBlockPage() {
416
422
  return true;
417
423
  }
@@ -138,4 +138,6 @@ export const defaultConfigurationParams = () => ({
138
138
  px_custom_is_enforced_request: null,
139
139
  px_custom_is_filtered_request: null,
140
140
  px_extract_graphql_keywords: null,
141
+ px_agentic_trust_enabled: false,
142
+ px_agentic_trust_mcp_endpoint_path: '/mcp',
141
143
  });
@@ -22,6 +22,7 @@ export class DefaultContext {
22
22
  productData;
23
23
  uuid;
24
24
  vid;
25
+ origCookieVid;
25
26
  vidSource;
26
27
  action;
27
28
  reasons;
@@ -154,6 +155,9 @@ export class DefaultContext {
154
155
  this.vid = vidValue;
155
156
  this.vidSource = VidSource.VID_COOKIE;
156
157
  }
158
+ else if (vidValue) {
159
+ this.origCookieVid = vidValue;
160
+ }
157
161
  const pxhdCookie = this.requestData.cookies[PXHD_COOKIE_NAME];
158
162
  if (pxhdCookie) {
159
163
  this.pxhd = {
@@ -190,6 +194,7 @@ export class DefaultContext {
190
194
  customParameters: this.customParameters,
191
195
  graphqlData: this.graphqlData,
192
196
  vid: this.vid,
197
+ origCookieVid: this.origCookieVid,
193
198
  vidSource: this.vidSource,
194
199
  uuid: this.uuid,
195
200
  enforcerStartTime: this.enforcerStartTime,
@@ -29,6 +29,7 @@ export class SerializedContext {
29
29
  customParameters;
30
30
  graphqlData;
31
31
  vid;
32
+ origCookieVid;
32
33
  vidSource;
33
34
  tokenOrigin;
34
35
  uuid;
@@ -50,6 +51,7 @@ export class SerializedContext {
50
51
  this.tokenOrigin = contextJson.tokenOrigin;
51
52
  this.uuid = contextJson.uuid;
52
53
  this.vid = contextJson.vid;
54
+ this.origCookieVid = contextJson.origCookieVid;
53
55
  this.vidSource = contextJson.vidSource;
54
56
  this.pxhd = contextJson.pxhd;
55
57
  this.pxde = contextJson.pxde;
@@ -7,7 +7,7 @@ import { DefaultGraphQLParser } from '../graphql/index.js';
7
7
  import { PostRiskApiClientV2, PostRiskApiClientV3 } from '../risk_api/index.js';
8
8
  import { HttpActivityClient, HttpBatchedActivityClient } from '../activities/index.js';
9
9
  import { HttpLogServiceClient } from '../logger/index.js';
10
- import { AccountDefender, BotDefender, CredentialIntelligence, HypeSaleChallenge, ProductName, } from '../products/index.js';
10
+ import { AccountDefender, BotDefender, CredentialIntelligence, HypeSaleChallenge, AgenticTrust, ProductName, } from '../products/index.js';
11
11
  import { EnforcerError, isValidTokenVersion } from '../utils/index.js';
12
12
  import { DefaultSnippetRetriever } from '../snippet_injection/index.js';
13
13
  export const createEnforcerInitializationBlock = (config, options) => {
@@ -70,12 +70,14 @@ export const createEnforcerProducts = (config, products, base64Utils, hashUtils,
70
70
  const accountDefender = products?.ad || new AccountDefender(config, { base64Utils });
71
71
  const credentialIntelligence = products?.ci || new CredentialIntelligence(config, { hashUtils, urlUtils });
72
72
  const hypeSaleChallenge = products?.hsc || new HypeSaleChallenge(config, { base64Utils });
73
+ const agenticTrust = products?.at || new AgenticTrust(config);
73
74
  return {
74
75
  [ProductName.BOT_DEFENDER]: botDefender,
75
76
  [ProductName.ACCOUNT_DEFENDER]: accountDefender,
76
77
  [ProductName.CODE_DEFENDER]: products?.cd,
77
78
  [ProductName.CREDENTIAL_INTELLIGENCE]: credentialIntelligence,
78
79
  [ProductName.HYPE_SALE_CHALLENGE]: hypeSaleChallenge,
80
+ [ProductName.AGENTIC_TRUST]: agenticTrust,
79
81
  };
80
82
  };
81
83
  export const createRemoteConfigClients = (config, options) => {
@@ -0,0 +1,84 @@
1
+ import { HttpMethod } from '../../http/index.js';
2
+ const MCP_SESSION_ID_HEADER = 'mcp-session-id';
3
+ export class AgenticTrust {
4
+ config;
5
+ constructor(config) {
6
+ this.config = config;
7
+ }
8
+ async enrichContextFromRequest(context) {
9
+ if (!this.config.agenticTrustEnabled) {
10
+ return null;
11
+ }
12
+ if (!this.isMatchingEndpoint(context)) {
13
+ return null;
14
+ }
15
+ const data = {
16
+ mcpHttpMethod: context.requestData.method,
17
+ };
18
+ const sessionId = context.requestData.request.headers.get(MCP_SESSION_ID_HEADER);
19
+ if (sessionId) {
20
+ data.mcpSessionId = sessionId;
21
+ }
22
+ if (context.requestData.method === HttpMethod.POST) {
23
+ await this.extractFromBody(context, data);
24
+ }
25
+ return data;
26
+ }
27
+ async enrichContextFromRiskApi(_context) {
28
+ return null;
29
+ }
30
+ async modifyIncomingRequest(_context) {
31
+ // no-op
32
+ }
33
+ async enrichContextFromResponse(context) {
34
+ if (!context.productData.at) {
35
+ return null;
36
+ }
37
+ if (context.productData.at.mcpSessionId) {
38
+ return null;
39
+ }
40
+ const responseHeaders = context.response?.headers;
41
+ if (!responseHeaders) {
42
+ return null;
43
+ }
44
+ const sessionId = responseHeaders.get(MCP_SESSION_ID_HEADER);
45
+ if (sessionId) {
46
+ return { mcpSessionId: sessionId };
47
+ }
48
+ return null;
49
+ }
50
+ async modifyOutgoingResponse(_context) {
51
+ // no-op
52
+ }
53
+ isMatchingEndpoint(context) {
54
+ const pathname = context.requestData.url.pathname.replace(/\/+$/, '');
55
+ const configuredPath = this.config.agenticTrustMcpEndpointPath.replace(/\/+$/, '');
56
+ return pathname === configuredPath;
57
+ }
58
+ async extractFromBody(context, data) {
59
+ try {
60
+ const body = await context.requestData.request.json();
61
+ if (!body) {
62
+ return;
63
+ }
64
+ const jsonRpcMessage = Array.isArray(body) ? body[0] : body;
65
+ if (!jsonRpcMessage) {
66
+ return;
67
+ }
68
+ if (typeof jsonRpcMessage.method === 'string') {
69
+ data.mcpMethod = jsonRpcMessage.method;
70
+ }
71
+ if (jsonRpcMessage.params) {
72
+ if (typeof jsonRpcMessage.params.name === 'string') {
73
+ data.mcpToolName = jsonRpcMessage.params.name;
74
+ }
75
+ if (jsonRpcMessage.params.arguments && typeof jsonRpcMessage.params.arguments === 'object') {
76
+ data.mcpToolArgumentKeys = Object.keys(jsonRpcMessage.params.arguments).join(',');
77
+ }
78
+ }
79
+ }
80
+ catch {
81
+ // failed to parse request body
82
+ }
83
+ }
84
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './AgenticTrust.js';
2
+ export * from './IAgenticTrust.js';
3
+ export * from './model/index.js';
@@ -0,0 +1 @@
1
+ export * from './AgenticTrustData.js';
@@ -4,3 +4,4 @@ export * from './bot_defender/index.js';
4
4
  export * from './credential_intelligence/index.js';
5
5
  export * from './account_defender/index.js';
6
6
  export * from './hype_sale_challenge/index.js';
7
+ export * from './agentic_trust/index.js';
@@ -5,4 +5,5 @@ export var ProductName;
5
5
  ProductName["CODE_DEFENDER"] = "cd";
6
6
  ProductName["CREDENTIAL_INTELLIGENCE"] = "ci";
7
7
  ProductName["HYPE_SALE_CHALLENGE"] = "hsc";
8
+ ProductName["AGENTIC_TRUST"] = "at";
8
9
  })(ProductName || (ProductName = {}));
@@ -5,4 +5,5 @@ export const PRODUCT_PRIORITY_ORDER = [
5
5
  ProductName.ACCOUNT_DEFENDER,
6
6
  ProductName.CREDENTIAL_INTELLIGENCE,
7
7
  ProductName.CODE_DEFENDER,
8
+ ProductName.AGENTIC_TRUST,
8
9
  ];
@@ -94,6 +94,9 @@ export const RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES = {
94
94
  enforcer_vid_source: {
95
95
  header: 'x-px-add-enforcer-vid-source',
96
96
  },
97
+ orig_cookie_vid: {
98
+ header: 'x-px-add-orig-cookie-vid',
99
+ },
97
100
  server_info_datacenter: {
98
101
  header: 'x-px-add-server-info-datacenter',
99
102
  },
@@ -183,4 +186,19 @@ export const RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES = {
183
186
  header: 'x-px-add-is-sensitive-route',
184
187
  convertToString: (value) => `${value}`,
185
188
  },
189
+ mcp_method: {
190
+ header: 'x-px-add-mcp-method',
191
+ },
192
+ mcp_tool_name: {
193
+ header: 'x-px-add-mcp-tool-name',
194
+ },
195
+ mcp_tool_argument_keys: {
196
+ header: 'x-px-add-mcp-tool-argument-keys',
197
+ },
198
+ mcp_session_id: {
199
+ header: 'x-px-add-mcp-session-id',
200
+ },
201
+ mcp_http_method: {
202
+ header: 'x-px-add-mcp-http-method',
203
+ },
186
204
  };
@@ -12,4 +12,4 @@ export const PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
12
12
  export const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
13
13
  export const URL_REGEX = /^(https?:)\/\/(([^@\s:\/]+):?([^@\s\/]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)(\/?[^?#]*)(\?[^#]*|)(#.*|)$/;
14
14
  export const REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
15
- export const CORE_MODULE_VERSION = 'JS Core 0.36.0';
15
+ export const CORE_MODULE_VERSION = 'JS Core 0.37.0';
@@ -24,6 +24,7 @@ export type CommonActivityDetails = {
24
24
  tls_preferred_ciphers?: string;
25
25
  tls_ja3_fingerprint?: string;
26
26
  enforcer_vid_source?: VidSource;
27
+ orig_cookie_vid?: string;
27
28
  original_uuid?: string;
28
29
  original_token_error?: string;
29
30
  original_token?: string;
@@ -47,4 +48,9 @@ export type CommonActivityDetails = {
47
48
  raw_url?: string;
48
49
  used_cookie_secret?: string;
49
50
  is_sensitive_route?: boolean;
51
+ mcp_method?: string;
52
+ mcp_tool_name?: string;
53
+ mcp_tool_argument_keys?: string;
54
+ mcp_session_id?: string;
55
+ mcp_http_method?: string;
50
56
  } & CustomParameters;
@@ -150,6 +150,8 @@ export declare abstract class ConfigurationBase<Req, Res, Supported extends stri
150
150
  get createCustomSnippet(): CustomSnippetFunction<Req, Res, Supported, Added> | null;
151
151
  get dataEnrichmentHeaderName(): string;
152
152
  get proxyUrl(): string;
153
+ get agenticTrustEnabled(): boolean;
154
+ get agenticTrustMcpEndpointPath(): string;
153
155
  get enableBlockedUrlOnCaptchaBlockPage(): boolean;
154
156
  get awaitAsyncHttpRequests(): boolean;
155
157
  get isPostEnforceEnabled(): boolean;
@@ -348,6 +348,14 @@ export interface IConfiguration<Req, Res, Supported extends string, Added> {
348
348
  * The default login successful custom callback to use if none is defined for an endpoint.
349
349
  */
350
350
  readonly ciDefaultLoginSuccessfulCustomCallback: CustomLoginSuccessfulCallback<Res> | null;
351
+ /**
352
+ * Whether to enable Agentic Trust.
353
+ */
354
+ readonly agenticTrustEnabled: boolean;
355
+ /**
356
+ * The endpoint path used for MCP requests.
357
+ */
358
+ readonly agenticTrustMcpEndpointPath: string;
351
359
  /**
352
360
  * The authentication token for the logging service.
353
361
  */
@@ -122,6 +122,8 @@ export type CommonConfigurationParams<Req, Res, Supported extends string, Added>
122
122
  px_secured_pxhd_enabled?: boolean;
123
123
  px_data_enrichment_header_name?: string;
124
124
  px_proxy_url?: string;
125
+ px_agentic_trust_enabled?: boolean;
126
+ px_agentic_trust_mcp_endpoint_path?: string;
125
127
  px_additional_activity_handler?: AdditionalActivityHandler<Req, Res, Supported, Added> | null;
126
128
  px_enrich_custom_parameters?: CustomParametersFunction<Req, Res, Supported, Added> | null;
127
129
  px_enrich_response_custom_parameters?: ResponseCustomParametersFunction<Req, Res, Supported, Added> | null;
@@ -29,6 +29,7 @@ export type ContextJson<Req = unknown, Res = unknown> = {
29
29
  readonly productData: ProductData;
30
30
  uuid?: string;
31
31
  vid?: string;
32
+ origCookieVid?: string;
32
33
  vidSource?: VidSource;
33
34
  tokenOrigin: TokenOrigin;
34
35
  score?: number;
@@ -34,6 +34,7 @@ export declare class DefaultContext<Req, Res, Supported extends string, Added> i
34
34
  readonly productData: ProductData;
35
35
  uuid?: string;
36
36
  vid?: string;
37
+ origCookieVid?: string;
37
38
  vidSource?: VidSource;
38
39
  action: Action;
39
40
  reasons: Partial<Record<ProductName, string>>;
@@ -41,6 +41,7 @@ export declare class SerializedContext<Req, Res, Supported extends string, Added
41
41
  customParameters?: CustomParameters;
42
42
  graphqlData?: GraphQLData[];
43
43
  vid?: string;
44
+ origCookieVid?: string;
44
45
  vidSource?: VidSource;
45
46
  tokenOrigin: TokenOrigin;
46
47
  uuid?: string;
@@ -61,6 +61,10 @@ export interface IContext<Req, Res> {
61
61
  * The visitor ID, unique to the end-user.
62
62
  */
63
63
  vid?: string;
64
+ /**
65
+ * The raw `_pxvid` cookie value when it fails UUID validation.
66
+ */
67
+ origCookieVid?: string;
64
68
  /**
65
69
  * The secret used to decrypt the risk cookie.
66
70
  */
@@ -0,0 +1,15 @@
1
+ import { IConfiguration } from '../../config';
2
+ import { ReadonlyContext } from '../../context';
3
+ import { IAgenticTrust } from './IAgenticTrust';
4
+ import { AgenticTrustData } from './model';
5
+ export declare class AgenticTrust<Req, Res, Supported extends string, Added> implements IAgenticTrust<Req, Res> {
6
+ protected readonly config: IConfiguration<Req, Res, Supported, Added>;
7
+ constructor(config: IConfiguration<Req, Res, Supported, Added>);
8
+ enrichContextFromRequest(context: ReadonlyContext<Req, Res>): Promise<AgenticTrustData | null>;
9
+ enrichContextFromRiskApi(_context: ReadonlyContext<Req, Res>): Promise<Partial<AgenticTrustData> | null>;
10
+ modifyIncomingRequest(_context: ReadonlyContext<Req, Res>): Promise<void>;
11
+ enrichContextFromResponse(context: ReadonlyContext<Req, Res>): Promise<Partial<AgenticTrustData> | null>;
12
+ modifyOutgoingResponse(_context: ReadonlyContext<Req, Res>): Promise<void>;
13
+ protected isMatchingEndpoint(context: ReadonlyContext<Req, Res>): boolean;
14
+ protected extractFromBody(context: ReadonlyContext<Req, Res>, data: AgenticTrustData): Promise<void>;
15
+ }
@@ -0,0 +1,4 @@
1
+ import { IProduct } from '../interfaces';
2
+ import { ProductName } from '../utils';
3
+ export interface IAgenticTrust<Req, Res> extends IProduct<ProductName.AGENTIC_TRUST, Req, Res> {
4
+ }
@@ -0,0 +1,3 @@
1
+ export * from './AgenticTrust';
2
+ export * from './IAgenticTrust';
3
+ export * from './model';
@@ -0,0 +1,7 @@
1
+ export type AgenticTrustData = {
2
+ mcpMethod?: string;
3
+ mcpToolName?: string;
4
+ mcpToolArgumentKeys?: string;
5
+ mcpSessionId?: string;
6
+ mcpHttpMethod?: string;
7
+ };
@@ -0,0 +1 @@
1
+ export * from './AgenticTrustData';
@@ -4,3 +4,4 @@ export * from './bot_defender';
4
4
  export * from './credential_intelligence';
5
5
  export * from './account_defender';
6
6
  export * from './hype_sale_challenge';
7
+ export * from './agentic_trust';
@@ -3,4 +3,5 @@ import { BotDefenderData } from '../bot_defender';
3
3
  import { CredentialIntelligenceData } from '../credential_intelligence';
4
4
  import { AccountDefenderData } from '../account_defender';
5
5
  import { HypeSaleChallengeData } from '../hype_sale_challenge';
6
- export type ProductDataType<Name extends ProductName> = Name extends ProductName.BOT_DEFENDER ? BotDefenderData : Name extends ProductName.CREDENTIAL_INTELLIGENCE ? CredentialIntelligenceData : Name extends ProductName.ACCOUNT_DEFENDER ? AccountDefenderData : Name extends ProductName.HYPE_SALE_CHALLENGE ? HypeSaleChallengeData : never;
6
+ import { AgenticTrustData } from '../agentic_trust';
7
+ export type ProductDataType<Name extends ProductName> = Name extends ProductName.BOT_DEFENDER ? BotDefenderData : Name extends ProductName.CREDENTIAL_INTELLIGENCE ? CredentialIntelligenceData : Name extends ProductName.ACCOUNT_DEFENDER ? AccountDefenderData : Name extends ProductName.HYPE_SALE_CHALLENGE ? HypeSaleChallengeData : Name extends ProductName.AGENTIC_TRUST ? AgenticTrustData : never;
@@ -3,4 +3,5 @@ import { IBotDefender } from '../bot_defender';
3
3
  import { ICredentialIntelligence } from '../credential_intelligence';
4
4
  import { IAccountDefender } from '../account_defender';
5
5
  import { IHypeSaleChallenge } from '../hype_sale_challenge';
6
- export type ProductType<Name extends ProductName, Req, Res> = Name extends ProductName.BOT_DEFENDER ? IBotDefender<Req, Res> : Name extends ProductName.CREDENTIAL_INTELLIGENCE ? ICredentialIntelligence<Req, Res> : Name extends ProductName.ACCOUNT_DEFENDER ? IAccountDefender<Req, Res> : Name extends ProductName.HYPE_SALE_CHALLENGE ? IHypeSaleChallenge<Req, Res> : never;
6
+ import { IAgenticTrust } from '../agentic_trust';
7
+ export type ProductType<Name extends ProductName, Req, Res> = Name extends ProductName.BOT_DEFENDER ? IBotDefender<Req, Res> : Name extends ProductName.CREDENTIAL_INTELLIGENCE ? ICredentialIntelligence<Req, Res> : Name extends ProductName.ACCOUNT_DEFENDER ? IAccountDefender<Req, Res> : Name extends ProductName.HYPE_SALE_CHALLENGE ? IHypeSaleChallenge<Req, Res> : Name extends ProductName.AGENTIC_TRUST ? IAgenticTrust<Req, Res> : never;
@@ -3,5 +3,6 @@ export declare enum ProductName {
3
3
  ACCOUNT_DEFENDER = "ad",
4
4
  CODE_DEFENDER = "cd",
5
5
  CREDENTIAL_INTELLIGENCE = "ci",
6
- HYPE_SALE_CHALLENGE = "hsc"
6
+ HYPE_SALE_CHALLENGE = "hsc",
7
+ AGENTIC_TRUST = "at"
7
8
  }
@@ -31,6 +31,7 @@ export declare const createRiskApiActivity: <Req, Res, Supported extends string,
31
31
  tls_preferred_ciphers?: string;
32
32
  tls_ja3_fingerprint?: string;
33
33
  enforcer_vid_source?: import("../utils").VidSource;
34
+ orig_cookie_vid?: string;
34
35
  original_uuid?: string;
35
36
  original_token_error?: string;
36
37
  original_token?: string;
@@ -54,6 +55,11 @@ export declare const createRiskApiActivity: <Req, Res, Supported extends string,
54
55
  raw_url?: string;
55
56
  used_cookie_secret?: string;
56
57
  is_sensitive_route?: boolean;
58
+ mcp_method?: string;
59
+ mcp_tool_name?: string;
60
+ mcp_tool_argument_keys?: string;
61
+ mcp_session_id?: string;
62
+ mcp_http_method?: string;
57
63
  custom_param1?: any;
58
64
  custom_param2?: any;
59
65
  custom_param3?: any;
@@ -12,4 +12,4 @@ export declare const PUSH_DATA_FEATURE_HEADER_NAME = "x-px-feature";
12
12
  export declare const EMAIL_ADDRESS_REGEX: RegExp;
13
13
  export declare const URL_REGEX: RegExp;
14
14
  export declare const REGEX_STRUCTURE: RegExp;
15
- export declare const CORE_MODULE_VERSION = "JS Core 0.36.0";
15
+ export declare const CORE_MODULE_VERSION = "JS Core 0.37.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perimeterx-js-core",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "typesVersions": {