@subiz/widget-v4 4.1.32 → 4.1.35

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 (76) hide show
  1. package/compiled_src/chatbox/ChatButton.js +1 -1
  2. package/compiled_src/plugin.js +1 -0
  3. package/compiled_src/store/api.js +2 -2
  4. package/compiled_src/store/store.js +26 -1
  5. package/compiled_src/util/common.js +4 -2
  6. package/malicious-app.js +3 -3
  7. package/package.json +6 -6
  8. package/src/chatbox/ChatButton.js +2 -1
  9. package/src/store/api.js +3 -2
  10. package/src/store/store.js +31 -2
  11. package/src/util/common.js +2 -1
  12. package/dist/132.js +0 -6661
  13. package/dist/178.js +0 -406
  14. package/dist/213.js +0 -2780
  15. package/dist/335.js +0 -372
  16. package/dist/362.js +0 -107
  17. package/dist/441.js +0 -2983
  18. package/dist/605.js +0 -305
  19. package/dist/678.js +0 -107
  20. package/dist/782.js +0 -107
  21. package/dist/assets/img/Facebook.64607ec.png +0 -0
  22. package/dist/assets/img/Zalo.6845707.png +0 -0
  23. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  24. package/dist/assets/img/caret.998eb8f.svg +0 -1
  25. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  26. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  27. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  28. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  29. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  30. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  31. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  32. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  33. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  34. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  35. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  36. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  37. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  38. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  39. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  40. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  41. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  42. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  43. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  44. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  45. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  46. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  47. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  48. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  49. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  50. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  51. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  52. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  53. package/dist/assets/img/empty.29bed2d.svg +0 -23
  54. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  55. package/dist/assets/img/external-link.90577cc.svg +0 -1
  56. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  57. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  58. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  59. package/dist/assets/img/image_default.be0698b.png +0 -0
  60. package/dist/assets/img/info.ebce7ea.svg +0 -1
  61. package/dist/assets/img/loader.37000a7.svg +0 -1
  62. package/dist/assets/img/loading_static.a27f0ac.svg +0 -10
  63. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  64. package/dist/assets/img/package.8d37d0f.svg +0 -5
  65. package/dist/assets/img/package_fade.763c001.svg +0 -1
  66. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  67. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  68. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  69. package/dist/assets/img/search.f9705ff.svg +0 -1
  70. package/dist/assets/img/send.6db52a9.svg +0 -3
  71. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  72. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  73. package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
  74. package/dist/assets/img/x.26fdfa3.svg +0 -5
  75. package/dist/screenshoot.html +0 -7
  76. package/dist/screenshoot.js +0 -6338
@@ -379,5 +379,5 @@ function randomAgent(agentM) {
379
379
  return agents[Math.floor(Math.random() * _index.default.size(agents))] || {};
380
380
  }
381
381
  const Ms30Mins = 30 * 60 * 1000;
382
- const DEF_BG_URL = 'https://file-subiz.com/bubble_11.svg';
382
+ const DEF_BG_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5';
383
383
  const DEF_BG = 'linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)';
@@ -32,6 +32,7 @@ function Plugin(plugin, store, $container, lib) {
32
32
  if (plugin.type === 'popup' && store.isConverted(plugin.id)) return;
33
33
  let lastrun = store.matchLastPluginRun(plugin.id);
34
34
  if (plugin.type === 'chatbox' || plugin.type === 'notification') lastrun = undefined;
35
+ if (!plugin.enabled) return;
35
36
  let match = _index.default.checkRunConditions(plugin.initiative_frequency, plugin.conditions, lastrun, store);
36
37
  if (!match) return;
37
38
  state = 'running';
@@ -10,7 +10,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
10
10
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
11
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
12
  const ajax = require('@subiz/ajax/src/ajax.js');
13
- ajax.env.XMLHttpRequest = window.XMLHttpRequest;
13
+ ajax.env.XMLHttpRequest = _index.default.XMLHttpRequest;
14
14
  function jsonifyTextPlain(param, done) {
15
15
  let req = param.request;
16
16
  if (req.content_type === 'text/plain' && req.body !== undefined) req.body = _index.default.stringify(req.body);
@@ -41,7 +41,7 @@ class _default {
41
41
  _defineProperty(this, "markAsSeen", (cid, messageId) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/messages/${messageId}/seen`));
42
42
  _defineProperty(this, "getConversation", cid => this.apireq.get(`/accounts/${this.accid}/conversations/${cid}`));
43
43
  _defineProperty(this, "getLocaleContent", locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`));
44
- _defineProperty(this, "sendEvent", data => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/events`, data));
44
+ _defineProperty(this, "sendEvent", data => this.apireq.addQuery('shorten', true).post(`/accounts/${this.accid}/users/${this.uid}/events`, data));
45
45
  _defineProperty(this, "sendTyping", cid => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`));
46
46
  _defineProperty(this, "sendLostFocus", (device, productid, source_id, sku) => this.sendEvent({
47
47
  by: {
@@ -367,7 +367,7 @@ class Store {
367
367
  account_id: accid,
368
368
  user_ref: userRef,
369
369
  user_mask: mask
370
- });
370
+ }, xhrsend);
371
371
  this.realtime.onEvent(this.onWs.bind(this));
372
372
  this.realtime.onInterrupted(() => this.reconnectWs(accid, user.id));
373
373
  this.seenLoop();
@@ -1080,4 +1080,29 @@ let cleanMyLocalStorage = () => {
1080
1080
  }
1081
1081
  }
1082
1082
  });
1083
+ };
1084
+ function dofetch(method, url, body, cb) {
1085
+ let headers = {};
1086
+ if (body) headers['content-type'] = 'text/plain';
1087
+ fetch(url, {
1088
+ method: method,
1089
+ headers: headers,
1090
+ body: body
1091
+ }).then(res => res.text().then(text => cb && cb(text, res.status))).catch(err => cb && cb(err, -1));
1092
+ }
1093
+ var xhrsend = function (method, url, body, cb) {
1094
+ if (typeof _index.default.XMLHttpRequest === 'undefined') return dofetch(method, url, body, cb);
1095
+ var request = new _index.default.XMLHttpRequest();
1096
+ request.onreadystatechange = function (e) {
1097
+ if (request.readyState !== 4) return;
1098
+ cb && cb(request.responseText, request.status);
1099
+ cb = undefined;
1100
+ };
1101
+ request.onerror = function () {
1102
+ cb && cb(request.responseText, -1);
1103
+ cb = undefined;
1104
+ };
1105
+ request.open(method, url);
1106
+ if (body) request.setRequestHeader('content-type', 'text/plain');
1107
+ request.send(body);
1083
1108
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Date = exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = exports.DEFVAL = void 0;
6
+ exports.XMLHttpRequest = exports.Date = exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = exports.DEFVAL = void 0;
7
7
  exports.agentsOfConvo = agentsOfConvo;
8
8
  exports.checkRunConditions = checkRunConditions;
9
9
  exports.clearTimeout = exports.clearInterval = void 0;
@@ -90,6 +90,8 @@ var clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow);
90
90
  exports.clearInterval = clearInterval;
91
91
  var clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow);
92
92
  exports.clearTimeout = clearTimeout;
93
+ var XMLHttpRequest = f.contentWindow.XMLHttpRequest;
94
+ exports.XMLHttpRequest = XMLHttpRequest;
93
95
  function convoOfEv(ev) {
94
96
  if (!ev) return '';
95
97
  switch (ev.type) {
@@ -551,7 +553,7 @@ function setCss(id, $css, css) {
551
553
  $css.appendChild(document.createTextNode(css));
552
554
  }
553
555
  }
554
- const DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = 'https://file-subiz.com/bubble_11.svg';
556
+ const DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5';
555
557
  exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL;
556
558
  const DEFVAL = {
557
559
  primary_color: '#0265FF',
package/malicious-app.js CHANGED
@@ -8,6 +8,6 @@ tag.src = 'https://public-gcs.subiz-cdn.com/widget-v4/public/' + hash + '.app.js
8
8
  document.body.appendChild(tag)
9
9
 
10
10
  // record which domain still use old code
11
- var xhttp = new XMLHttpRequest()
12
- xhttp.open('GET', 'https://api.sbz.vn/4.0/old', true)
13
- xhttp.send()
11
+ // var xhttp = new XMLHttpRequest()
12
+ // xhttp.open('GET', 'https://api.sbz.vn/4.0/old', true)
13
+ // xhttp.send()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.32",
3
+ "version": "4.1.35",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -23,17 +23,17 @@
23
23
  "preact": "^10.15.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@babel/cli": "^7.22.5",
27
- "@babel/core": "^7.22.5",
26
+ "@babel/cli": "^7.22.6",
27
+ "@babel/core": "^7.22.6",
28
28
  "@babel/plugin-proposal-class-properties": "^7.18.6",
29
29
  "@babel/plugin-transform-react-jsx": "^7.22.5",
30
- "@babel/preset-env": "^7.22.5",
30
+ "@babel/preset-env": "^7.22.6",
31
31
  "babel-loader": "^9.1.2",
32
32
  "babel-plugin-syntax-jsx": "^6.18.0",
33
33
  "html-webpack-plugin": "^5.5.3",
34
34
  "prettier": "^2.8.8",
35
- "puppeteer": "^20.7.2",
36
- "webpack": "^5.87.0",
35
+ "puppeteer": "^20.7.3",
36
+ "webpack": "^5.88.1",
37
37
  "webpack-bundle-analyzer": "^4.9.0",
38
38
  "webpack-cli": "^5.1.4",
39
39
  "webpack-dev-server": "^4.15.1"
@@ -418,5 +418,6 @@ function randomAgent(agentM) {
418
418
 
419
419
  const Ms30Mins = 30 * 60 * 1000
420
420
 
421
- const DEF_BG_URL = 'https://file-subiz.com/bubble_11.svg'
421
+ // v=5 trick to clear cache
422
+ const DEF_BG_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5'
422
423
  const DEF_BG = 'linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)'
package/src/store/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import sb from '../util/index.js'
2
2
  const ajax = require('@subiz/ajax/src/ajax.js')
3
- ajax.env.XMLHttpRequest = window.XMLHttpRequest
3
+ ajax.env.XMLHttpRequest = sb.XMLHttpRequest
4
4
 
5
5
  function jsonifyTextPlain(param, done) {
6
6
  let req = param.request
@@ -216,7 +216,8 @@ export default class {
216
216
 
217
217
  getConversation = (cid) => this.apireq.get(`/accounts/${this.accid}/conversations/${cid}`)
218
218
  getLocaleContent = (locale) => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`)
219
- sendEvent = (data) => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/events`, data)
219
+ sendEvent = (data) =>
220
+ this.apireq.addQuery('shorten', true).post(`/accounts/${this.accid}/users/${this.uid}/events`, data)
220
221
  sendTyping = (cid) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`)
221
222
 
222
223
  sendLostFocus = (device, productid, source_id, sku) =>
@@ -420,7 +420,8 @@ export default class Store {
420
420
 
421
421
  if (this.realtime) this.realtime.stop()
422
422
  if (this.fake) this.realtime = new RealtimeFake()
423
- else this.realtime = new Realtime(this.RealtimeURL, {account_id: accid, user_ref: userRef, user_mask: mask})
423
+ else
424
+ this.realtime = new Realtime(this.RealtimeURL, {account_id: accid, user_ref: userRef, user_mask: mask}, xhrsend)
424
425
 
425
426
  this.realtime.onEvent(this.onWs.bind(this))
426
427
  this.realtime.onInterrupted(() => this.reconnectWs(accid, user.id))
@@ -654,7 +655,7 @@ export default class Store {
654
655
 
655
656
  // send the content view, the first presence and record domain
656
657
  async track() {
657
- let out = await this.api.sendContentView(
658
+ let out = await this.api.sendContentView(
658
659
  this.device,
659
660
  location.href,
660
661
  document.title,
@@ -1302,3 +1303,31 @@ let cleanMyLocalStorage = () => {
1302
1303
  }
1303
1304
  })
1304
1305
  }
1306
+
1307
+ function dofetch(method, url, body, cb) {
1308
+ let headers = {}
1309
+ if (body) headers['content-type'] = 'text/plain'
1310
+ fetch(url, {method: method, headers: headers, body: body})
1311
+ .then((res) => res.text().then((text) => cb && cb(text, res.status)))
1312
+ .catch((err) => cb && cb(err, -1))
1313
+ }
1314
+
1315
+ // xhrsend sends an HTTP request
1316
+ var xhrsend = function (method, url, body, cb) {
1317
+ if (typeof sb.XMLHttpRequest === 'undefined') return dofetch(method, url, body, cb)
1318
+ var request = new sb.XMLHttpRequest()
1319
+ request.onreadystatechange = function (e) {
1320
+ if (request.readyState !== 4) return
1321
+ cb && cb(request.responseText, request.status)
1322
+ cb = undefined // dont call cb anymore
1323
+ }
1324
+
1325
+ request.onerror = function () {
1326
+ cb && cb(request.responseText, -1) // network error
1327
+ cb = undefined // dont call cb anymore
1328
+ }
1329
+
1330
+ request.open(method, url)
1331
+ if (body) request.setRequestHeader('content-type', 'text/plain')
1332
+ request.send(body)
1333
+ }
@@ -18,6 +18,7 @@ export var setTimeout = f.contentWindow.setTimeout.bind(f.contentWindow)
18
18
  export var setInterval = f.contentWindow.setInterval.bind(f.contentWindow)
19
19
  export var clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow)
20
20
  export var clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow)
21
+ export var XMLHttpRequest = f.contentWindow.XMLHttpRequest
21
22
 
22
23
  // convoOfEv extracts the ID of the conversation
23
24
  // that event is sent to
@@ -580,7 +581,7 @@ export function setCss(id, $css, css) {
580
581
  }
581
582
  }
582
583
 
583
- export const DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = 'https://file-subiz.com/bubble_11.svg'
584
+ export const DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5' // v=5 trick to clear cache
584
585
 
585
586
  export const DEFVAL = {
586
587
  primary_color: '#0265FF',