@constructor-io/constructorio-client-javascript 2.61.0 → 2.62.1

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.
@@ -31,7 +31,7 @@ export interface IBrowseParameters {
31
31
  hiddenFacets?: string[];
32
32
  variationsMap?: VariationsMap;
33
33
  qsParam?: Record<string, any>;
34
- filterMatchTypes: Record<string, 'all'| 'any' | 'none'>
34
+ filterMatchTypes?: Record<string, 'all'| 'any' | 'none'>
35
35
  }
36
36
 
37
37
  declare class Browse {
@@ -30,7 +30,7 @@ export interface SearchParameters {
30
30
  hiddenFacets?: string[];
31
31
  variationsMap?: VariationsMap;
32
32
  qsParam?: Record<string, any>;
33
- filterMatchTypes: Record<string, 'all'| 'any' | 'none'>
33
+ filterMatchTypes?: Record<string, 'all'| 'any' | 'none'>
34
34
  }
35
35
  declare class Search {
36
36
  constructor(options: ConstructorClientOptions);
@@ -13,11 +13,12 @@ var HumanityCheck = /*#__PURE__*/function () {
13
13
  function HumanityCheck() {
14
14
  var _this = this;
15
15
  (0, _classCallCheck2["default"])(this, HumanityCheck);
16
- this.isHumanBoolean = this.getIsHumanFromSessionStorage();
16
+ // Check if a human event has been performed in the past
17
+ this.hasPerformedHumanEvent = !!store.session.get(storageKey) || false;
17
18
 
18
- // Humanity proved, remove handlers to prove humanity
19
+ // Humanity proved, remove handlers
19
20
  var remove = function remove() {
20
- _this.isHumanBoolean = true;
21
+ _this.hasPerformedHumanEvent = true;
21
22
  store.session.set(storageKey, true);
22
23
  humanEvents.forEach(function (eventType) {
23
24
  helpers.removeEventListener(eventType, remove, true);
@@ -25,37 +26,37 @@ var HumanityCheck = /*#__PURE__*/function () {
25
26
  };
26
27
 
27
28
  // Add handlers to prove humanity
28
- if (!this.isHumanBoolean) {
29
+ if (!this.hasPerformedHumanEvent) {
29
30
  humanEvents.forEach(function (eventType) {
30
31
  helpers.addEventListener(eventType, remove, true);
31
32
  });
32
33
  }
33
34
  }
34
- (0, _createClass2["default"])(HumanityCheck, [{
35
- key: "getIsHumanFromSessionStorage",
36
- value: function getIsHumanFromSessionStorage() {
37
- return !!store.session.get(storageKey) || false;
38
- }
39
-
40
- // Return boolean indicating if is human
41
- }, {
42
- key: "isHuman",
43
- value: function isHuman() {
44
- return this.isHumanBoolean || !!store.session.get(storageKey);
45
- }
46
35
 
47
- // Return boolean indicating if useragent matches botlist
48
- }, {
36
+ // Return boolean indicating if user is a bot
37
+ // ...if it has a bot-like useragent
38
+ // ...or uses webdriver
39
+ // ...or has not performed a human event
40
+ (0, _createClass2["default"])(HumanityCheck, [{
49
41
  key: "isBot",
50
42
  value: function isBot() {
51
- if (this.getIsHumanFromSessionStorage()) {
52
- return false;
53
- }
54
43
  var _helpers$getNavigator = helpers.getNavigator(),
55
44
  userAgent = _helpers$getNavigator.userAgent,
56
45
  webdriver = _helpers$getNavigator.webdriver;
57
46
  var botRegex = new RegExp("(".concat(botList.join('|'), ")"));
58
- return Boolean(userAgent.match(botRegex)) || Boolean(webdriver);
47
+
48
+ // Always check the user agent and webdriver fields first to determine if the user is a bot
49
+ if (Boolean(userAgent.match(botRegex)) || Boolean(webdriver)) {
50
+ return true;
51
+ }
52
+
53
+ // If the user hasn't performed a human event, it indicates it is a bot
54
+ if (!this.hasPerformedHumanEvent) {
55
+ return true;
56
+ }
57
+
58
+ // Otherwise, it is a human
59
+ return false;
59
60
  }
60
61
  }]);
61
62
  return HumanityCheck;
@@ -62,7 +62,7 @@ var RequestQueue = /*#__PURE__*/function () {
62
62
  var queue = RequestQueue.get();
63
63
  if (
64
64
  // Consider user "human" if no DOM context is available
65
- (!helpers.canUseDOM() || this.humanity.isHuman()) && !this.requestPending && !this.pageUnloading && queue.length) {
65
+ (!helpers.canUseDOM() || !this.humanity.isBot()) && !this.requestPending && !this.pageUnloading && queue.length) {
66
66
  var request;
67
67
  var nextInQueue = queue.shift();
68
68
  var _nextInQueue = nextInQueue,
package/lib/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _default = '2.61.0';
7
+ var _default = '2.62.1';
8
8
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.61.0",
3
+ "version": "2.62.1",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",