perimeterx-js-core 0.26.1 → 0.26.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.
@@ -69,11 +69,14 @@ var GetRiskApiClientV2 = /** @class */ (function (_super) {
69
69
  return (0, utils_2.isAscii)(headerName) && headerValue.every(function (value) { return (0, utils_2.isAscii)(value); });
70
70
  };
71
71
  GetRiskApiClientV2.prototype.addHeadersFromObject = function (headers, object, headerNamesMap) {
72
- Object.entries(object).forEach(function (_a) {
73
- var key = _a[0], value = _a[1];
74
- var headerConversionObject = headerNamesMap[key];
75
- if (headerConversionObject && value != null) {
76
- var header = headerConversionObject.header, convertToString = headerConversionObject.convertToString;
72
+ Object.entries(headerNamesMap).forEach(function (_a) {
73
+ var key = _a[0], headerConversionObject = _a[1];
74
+ if (!headerConversionObject) {
75
+ return;
76
+ }
77
+ var header = headerConversionObject.header, convertToString = headerConversionObject.convertToString;
78
+ var value = object[key];
79
+ if (value != null) {
77
80
  var strValue = convertToString
78
81
  ? convertToString(value)
79
82
  : typeof value === 'string'
@@ -81,6 +84,10 @@ var GetRiskApiClientV2 = /** @class */ (function (_super) {
81
84
  : "".concat(value);
82
85
  headers[header] = [strValue];
83
86
  }
87
+ else {
88
+ // delete so that user cannot spoof
89
+ delete headers[header];
90
+ }
84
91
  });
85
92
  };
86
93
  GetRiskApiClientV2.prototype.createRiskResponse = function (response) {
@@ -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.26.1';
17
+ exports.CORE_MODULE_VERSION = 'JS Core 0.26.2';
@@ -45,10 +45,13 @@ export class GetRiskApiClientV2 extends RiskApiClientBase {
45
45
  return isAscii(headerName) && headerValue.every((value) => isAscii(value));
46
46
  }
47
47
  addHeadersFromObject(headers, object, headerNamesMap) {
48
- Object.entries(object).forEach(([key, value]) => {
49
- const headerConversionObject = headerNamesMap[key];
50
- if (headerConversionObject && value != null) {
51
- const { header, convertToString } = headerConversionObject;
48
+ Object.entries(headerNamesMap).forEach(([key, headerConversionObject]) => {
49
+ if (!headerConversionObject) {
50
+ return;
51
+ }
52
+ const { header, convertToString } = headerConversionObject;
53
+ const value = object[key];
54
+ if (value != null) {
52
55
  const strValue = convertToString
53
56
  ? convertToString(value)
54
57
  : typeof value === 'string'
@@ -56,6 +59,10 @@ export class GetRiskApiClientV2 extends RiskApiClientBase {
56
59
  : `${value}`;
57
60
  headers[header] = [strValue];
58
61
  }
62
+ else {
63
+ // delete so that user cannot spoof
64
+ delete headers[header];
65
+ }
59
66
  });
60
67
  }
61
68
  createRiskResponse(response) {
@@ -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.26.1';
14
+ export const CORE_MODULE_VERSION = 'JS Core 0.26.2';
@@ -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.26.1";
14
+ export declare const CORE_MODULE_VERSION = "JS Core 0.26.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perimeterx-js-core",
3
- "version": "0.26.1",
3
+ "version": "0.26.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "typesVersions": {
@@ -35,8 +35,8 @@
35
35
  "build:esm": "tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
36
36
  "build:dec": "tsc -p tsconfig.dec.json && tsc-alias -p tsconfig.dec.json",
37
37
  "clean": "rm -rf lib",
38
- "lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts",
39
- "lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts --fix",
38
+ "lint": "eslint . --ext .ts",
39
+ "lint:fix": "eslint . --ext .ts --fix",
40
40
  "test": "mocha",
41
41
  "coverage": "nyc npm run test",
42
42
  "pre-commit": "./node_modules/.bin/lint-staged",
@@ -48,18 +48,18 @@
48
48
  "js-base64": "^3.7.2",
49
49
  "phin": "^3.7.0",
50
50
  "ts-essentials": "^10.0.0",
51
- "uuid": "^10.0.0"
51
+ "uuid": "^11.1.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@types/chai": "^4.3.3",
55
- "@types/chai-as-promised": "^7.1.5",
54
+ "@types/chai": "^5.2.1",
55
+ "@types/chai-as-promised": "^8.0.2",
56
56
  "@types/crypto-js": "^4.1.1",
57
57
  "@types/mocha": "^10.0.0",
58
58
  "@types/sinon": "^17.0.1",
59
59
  "@types/uuid": "^10.0.0",
60
60
  "@typescript-eslint/eslint-plugin": "^8.26.0",
61
61
  "@typescript-eslint/parser": "^8.26.0",
62
- "chai": "^4.3.6",
62
+ "chai": "^5.2.0",
63
63
  "chai-as-promised": "^8.0.0",
64
64
  "core-js": "^3.19.1",
65
65
  "eslint": "^9.21.0",