perimeterx-js-core 1.2.0 → 1.2.2
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/risk_api/client/GetRiskApiClientV2.js +3 -1
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/cjs/utils/utils.js +4 -1
- package/lib/esm/risk_api/client/GetRiskApiClientV2.js +4 -2
- package/lib/esm/utils/constants.js +1 -1
- package/lib/esm/utils/utils.js +2 -0
- package/lib/types/utils/constants.d.ts +1 -1
- package/lib/types/utils/utils.d.ts +1 -0
- package/package.json +2 -2
|
@@ -66,7 +66,9 @@ var GetRiskApiClientV2 = /** @class */ (function (_super) {
|
|
|
66
66
|
}));
|
|
67
67
|
};
|
|
68
68
|
GetRiskApiClientV2.prototype.shouldFilterHeader = function (headerName, headerValue) {
|
|
69
|
-
return (0, utils_2.isAscii)(headerName) &&
|
|
69
|
+
return ((0, utils_2.isAscii)(headerName) &&
|
|
70
|
+
!(0, utils_2.hasControlChars)(headerName) &&
|
|
71
|
+
headerValue.every(function (value) { return (0, utils_2.isAscii)(value) && !(0, utils_2.hasControlChars)(value); }));
|
|
70
72
|
};
|
|
71
73
|
GetRiskApiClientV2.prototype.addHeadersFromObject = function (headers, object, headerNamesMap) {
|
|
72
74
|
Object.entries(headerNamesMap).forEach(function (_a) {
|
|
@@ -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 1.2.
|
|
18
|
+
exports.CORE_MODULE_VERSION = 'JS Core 1.2.2';
|
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.isAscii = exports.isNullOrUndefined = exports.isValidTokenVersion = exports.telemetryConfigReplacer = exports.convertRegexStringToRegex = exports.algoToCryptoString = exports.algoToSubtleCryptoString = exports.sleep = exports.getPropertyFromObject = exports.rejectOnTimeout = exports.isStringMatch = exports.isStringInPatterns = exports.removeSensitiveHeaders = exports.redactSensitiveFields = exports.stripMatrixParams = exports.getExtension = exports.getAuthorizationHeader = exports.getCollectorDomain = exports.getScoreApiDomain = exports.isEmailAddress = exports.isValidUuid = exports.isValidEnumValue = void 0;
|
|
39
|
+
exports.hasControlChars = exports.isAscii = exports.isNullOrUndefined = exports.isValidTokenVersion = exports.telemetryConfigReplacer = exports.convertRegexStringToRegex = exports.algoToCryptoString = exports.algoToSubtleCryptoString = exports.sleep = exports.getPropertyFromObject = exports.rejectOnTimeout = exports.isStringMatch = exports.isStringInPatterns = exports.removeSensitiveHeaders = exports.redactSensitiveFields = exports.stripMatrixParams = exports.getExtension = exports.getAuthorizationHeader = exports.getCollectorDomain = exports.getScoreApiDomain = exports.isEmailAddress = exports.isValidUuid = exports.isValidEnumValue = void 0;
|
|
40
40
|
var http_1 = require("../http/index.js");
|
|
41
41
|
var error_1 = require("./error/index.js");
|
|
42
42
|
var constants_1 = require("./constants.js");
|
|
@@ -266,3 +266,6 @@ var isNullOrUndefined = function (value) {
|
|
|
266
266
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
267
267
|
var isAscii = function (str) { return str.split('').every(function (char) { return char <= '\x7F'; }); };
|
|
268
268
|
exports.isAscii = isAscii;
|
|
269
|
+
var CONTROL_CHARS_REGEX = /[\u0000-\u001F\u007F]/;
|
|
270
|
+
var hasControlChars = function (str) { return CONTROL_CHARS_REGEX.test(str); };
|
|
271
|
+
exports.hasControlChars = hasControlChars;
|
|
@@ -3,7 +3,7 @@ import { AUTHORIZATION_HEADER_NAME, CONTENT_LENGTH_HEADER_NAME, CONTENT_TYPE_HEA
|
|
|
3
3
|
import { GetRiskResponseV2 } from '../risk_response/index.js';
|
|
4
4
|
import { RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES, RISK_ACTIVITY_FIELDS_TO_HEADER_NAMES, RISK_ACTIVITY_REQUEST_FIELDS_TO_HEADER_NAMES, } from '../model/index.js';
|
|
5
5
|
import { createRiskApiActivity } from '../utils.js';
|
|
6
|
-
import { isAscii } from '../../utils/index.js';
|
|
6
|
+
import { hasControlChars, isAscii } from '../../utils/index.js';
|
|
7
7
|
export class GetRiskApiClientV2 extends RiskApiClientBase {
|
|
8
8
|
constructor(config, httpClient) {
|
|
9
9
|
super(config, httpClient);
|
|
@@ -42,7 +42,9 @@ export class GetRiskApiClientV2 extends RiskApiClientBase {
|
|
|
42
42
|
return Object.fromEntries(Object.entries(headers).filter(([name, value]) => this.shouldFilterHeader(name, value)));
|
|
43
43
|
}
|
|
44
44
|
shouldFilterHeader(headerName, headerValue) {
|
|
45
|
-
return isAscii(headerName) &&
|
|
45
|
+
return (isAscii(headerName) &&
|
|
46
|
+
!hasControlChars(headerName) &&
|
|
47
|
+
headerValue.every((value) => isAscii(value) && !hasControlChars(value)));
|
|
46
48
|
}
|
|
47
49
|
addHeadersFromObject(headers, object, headerNamesMap) {
|
|
48
50
|
Object.entries(headerNamesMap).forEach(([key, headerConversionObject]) => {
|
|
@@ -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 1.2.
|
|
15
|
+
export const CORE_MODULE_VERSION = 'JS Core 1.2.2';
|
package/lib/esm/utils/utils.js
CHANGED
|
@@ -188,3 +188,5 @@ export const telemetryConfigReplacer = (_key, value) => {
|
|
|
188
188
|
export const isValidTokenVersion = (tokenVersion) => Object.values(TokenVersion).includes(tokenVersion);
|
|
189
189
|
export const isNullOrUndefined = (value) => value === null || value === undefined;
|
|
190
190
|
export const isAscii = (str) => str.split('').every((char) => char <= '\x7F');
|
|
191
|
+
const CONTROL_CHARS_REGEX = /[\u0000-\u001F\u007F]/;
|
|
192
|
+
export const hasControlChars = (str) => CONTROL_CHARS_REGEX.test(str);
|
|
@@ -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 1.2.
|
|
15
|
+
export declare const CORE_MODULE_VERSION = "JS Core 1.2.2";
|
|
@@ -24,3 +24,4 @@ export declare const telemetryConfigReplacer: (_key: string, value: any) => stri
|
|
|
24
24
|
export declare const isValidTokenVersion: (tokenVersion: any) => tokenVersion is TokenVersion;
|
|
25
25
|
export declare const isNullOrUndefined: <T>(value: T | null | undefined) => value is null | undefined;
|
|
26
26
|
export declare const isAscii: (str: string) => boolean;
|
|
27
|
+
export declare const hasControlChars: (str: string) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "perimeterx-js-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"typesVersions": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"ip-range-check": "^0.2.0",
|
|
48
48
|
"js-base64": "^3.7.2",
|
|
49
49
|
"ts-essentials": "^10.0.0",
|
|
50
|
-
"undici": "^6.
|
|
50
|
+
"undici": "^6.29.1",
|
|
51
51
|
"uuid": "^11.1.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|