qiscus-sdk-core 2.16.1 → 2.16.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.
@@ -60,6 +60,15 @@ var __asyncGenerator = (__this, __arguments, generator) => {
60
60
  };
61
61
  var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
62
62
 
63
+ let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
64
+ let nanoid = (size = 21) => {
65
+ let id = "";
66
+ let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
67
+ while (size--) {
68
+ id += urlAlphabet[bytes[size] & 63];
69
+ }
70
+ return id;
71
+ };
63
72
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
64
73
  function getDefaultExportFromCjs$1(x) {
65
74
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -23147,7 +23156,7 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
23147
23156
  }
23148
23157
  };
23149
23158
  }
23150
- const version = "2.16.1";
23159
+ const version = "2.16.2";
23151
23160
  const Package = {
23152
23161
  version
23153
23162
  };
@@ -23494,8 +23503,16 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
23494
23503
  );
23495
23504
  this.extras = setterHelper(null, cfg.extras, configExtras);
23496
23505
  this.enableSync = setterHelper(null, cfg.enable_sync, this.enableSync);
23497
- this.enableSyncEvent = setterHelper(null, cfg.enable_sync_event, this.enableSyncEvent);
23498
- this._autoRefreshToken = setterHelper(null, cfg.auto_refresh_token, false);
23506
+ this.enableSyncEvent = setterHelper(
23507
+ null,
23508
+ cfg.enable_sync_event,
23509
+ this.enableSyncEvent
23510
+ );
23511
+ this._autoRefreshToken = setterHelper(
23512
+ null,
23513
+ cfg.auto_refresh_token,
23514
+ false
23515
+ );
23499
23516
  }).catch((err) => {
23500
23517
  this.logger("got error when trying to get app config", err);
23501
23518
  this.isConfigLoaded = true;
@@ -23576,7 +23593,7 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
23576
23593
  });
23577
23594
  this.syncAdapter = SyncAdapter(() => this.HTTPAdapter, {
23578
23595
  syncInterval: () => this.syncInterval,
23579
- getShouldSync: () => this._forceEnableSync && (this.isLogin && !this.realtimeAdapter.connected),
23596
+ getShouldSync: () => this._forceEnableSync && this.isLogin && !this.realtimeAdapter.connected,
23580
23597
  syncOnConnect: () => this.syncOnConnect,
23581
23598
  lastCommentId: () => this.last_received_comment_id,
23582
23599
  statusLogin: () => this.isLogin,
@@ -23792,7 +23809,12 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
23792
23809
  this.userData.token = token;
23793
23810
  this.userData.refresh_token = refreshToken;
23794
23811
  this.userData.token_expires_at = expiredAt == null ? void 0 : expiredAt.toJSON();
23795
- this.events.emit("token-refreshed", { token, refreshToken, expiredAt, oldToken });
23812
+ this.events.emit("token-refreshed", {
23813
+ token,
23814
+ refreshToken,
23815
+ expiredAt,
23816
+ oldToken
23817
+ });
23796
23818
  this.realtimeAdapter.unsusbcribeUserChannelByToken(oldToken);
23797
23819
  this.realtimeAdapter.subscribeUserChannelByToken(token);
23798
23820
  this._delayedSync();
@@ -24419,10 +24441,7 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
24419
24441
  );
24420
24442
  try {
24421
24443
  let res = yield sendComment();
24422
- res = yield this._hookAdapter.trigger(
24423
- Hooks.MESSAGE_BEFORE_RECEIVED,
24424
- res
24425
- );
24444
+ res = yield this._hookAdapter.trigger(Hooks.MESSAGE_BEFORE_RECEIVED, res);
24426
24445
  Object.assign(messageData, res);
24427
24446
  if (!self2.selected) return Promise.resolve(messageData);
24428
24447
  messageData.markAsSent();
@@ -24432,14 +24451,28 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
24432
24451
  (_b = (_a = this.options).commentSentCallback) == null ? void 0 : _b.call(_a, { comment: messageData });
24433
24452
  self2.events.emit("comment-sent", messageData);
24434
24453
  self2.sortComments();
24435
- const commentIndex = self2._pendingComments.findIndex((c) => c.unique_id === messageData.unique_id);
24454
+ const commentIndex = self2._pendingComments.findIndex(
24455
+ (c) => c.unique_id === messageData.unique_id
24456
+ );
24436
24457
  if (commentIndex > -1) {
24437
24458
  self2._pendingComments.splice(commentIndex, 1);
24438
24459
  }
24439
24460
  return messageData;
24440
24461
  } catch (error) {
24441
24462
  messageData.markAsFailed();
24442
- const whitelistedErrorStatus = [void 0, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524];
24463
+ const whitelistedErrorStatus = [
24464
+ void 0,
24465
+ 408,
24466
+ 413,
24467
+ 429,
24468
+ 500,
24469
+ 502,
24470
+ 503,
24471
+ 504,
24472
+ 521,
24473
+ 522,
24474
+ 524
24475
+ ];
24443
24476
  const message = (_d = (_c = error.message) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
24444
24477
  const isOffline = message.includes("offline");
24445
24478
  if (whitelistedErrorStatus.includes(error.status) || isOffline) {
@@ -24460,7 +24493,9 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
24460
24493
  `Exceeding maximum retry count for comment ${comment.unique_id}, not retrying anymore`
24461
24494
  );
24462
24495
  (_c = (_b = this.options).commentRetryExceedCallback) == null ? void 0 : _c.call(_b, comment);
24463
- const index = this._pendingComments.findIndex((c) => c.unique_id === comment.unique_id);
24496
+ const index = this._pendingComments.findIndex(
24497
+ (c) => c.unique_id === comment.unique_id
24498
+ );
24464
24499
  if (index > -1) {
24465
24500
  this._pendingComments.splice(index, 1);
24466
24501
  }
@@ -24494,7 +24529,9 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
24494
24529
  this.sortComments();
24495
24530
  (_d = (_c2 = this.options).commentSentCallback) == null ? void 0 : _d.call(_c2, { comment });
24496
24531
  this.events.emit("comment-sent", comment);
24497
- const commentIndex = this._pendingComments.findIndex((c) => c.unique_id === comment.unique_id);
24532
+ const commentIndex = this._pendingComments.findIndex(
24533
+ (c) => c.unique_id === comment.unique_id
24534
+ );
24498
24535
  if (commentIndex > -1) {
24499
24536
  this._pendingComments.splice(commentIndex, 1);
24500
24537
  }
@@ -24562,9 +24599,8 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
24562
24599
  );
24563
24600
  }
24564
24601
  prepareCommentToBeSubmitted(comment) {
24565
- var commentToBeSubmitted, uniqueId;
24566
- commentToBeSubmitted = new Comment(comment);
24567
- uniqueId = "bq" + Date.now();
24602
+ let commentToBeSubmitted = new Comment(comment);
24603
+ let uniqueId = `javascript-${nanoid()}`;
24568
24604
  if (comment.unique_id) uniqueId = comment.unique_id;
24569
24605
  commentToBeSubmitted.attachUniqueId(uniqueId);
24570
24606
  commentToBeSubmitted.markAsPending();
@@ -25068,7 +25104,7 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
25068
25104
  });
25069
25105
  }
25070
25106
  _generateUniqueId() {
25071
- return `javascript-${Date.now()}`;
25107
+ return `javascript-${nanoid()}`;
25072
25108
  }
25073
25109
  generateMessage({ roomId, text, extras }) {
25074
25110
  const id = Date.now();