@open-wa/wa-automate 4.23.3 → 4.23.7

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.
@@ -210,6 +210,12 @@ export declare class Client {
210
210
  * Listens to new orders. Only works on business accounts
211
211
  */
212
212
  onOrder(fn: (order: Order) => void): Promise<Listener | boolean>;
213
+ /**
214
+ *[REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
215
+ *
216
+ * Listens to new orders. Only works on business accounts
217
+ */
218
+ onNewProduct(fn: (product: Product) => void): Promise<Listener | boolean>;
213
219
  /**
214
220
  * [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
215
221
  *
@@ -266,7 +266,10 @@ class Client {
266
266
  const ident = typeof ((_f = this._createConfig) === null || _f === void 0 ? void 0 : _f.autoEmoji) === "string" ? (_g = this._createConfig) === null || _g === void 0 ? void 0 : _g.autoEmoji : ":";
267
267
  this.onMessage((message) => __awaiter(this, void 0, void 0, function* () {
268
268
  if (message.body && message.body.startsWith(ident) && message.body.endsWith(ident)) {
269
- return yield this.sendEmoji(message.from, message.body.replace(new RegExp(ident, 'g'), ""), message.id);
269
+ const emojiId = message.body.replace(new RegExp(ident, 'g'), "");
270
+ if (!emojiId)
271
+ return;
272
+ return yield this.sendEmoji(message.from, emojiId, message.id);
270
273
  }
271
274
  }));
272
275
  }
@@ -715,6 +718,16 @@ class Client {
715
718
  return this.registerListener(events_2.SimpleListener.Order, fn);
716
719
  });
717
720
  }
721
+ /**
722
+ *[REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
723
+ *
724
+ * Listens to new orders. Only works on business accounts
725
+ */
726
+ onNewProduct(fn) {
727
+ return __awaiter(this, void 0, void 0, function* () {
728
+ return this.registerListener(events_2.SimpleListener.NewProduct, fn);
729
+ });
730
+ }
718
731
  /**
719
732
  * [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
720
733
  *
@@ -81,5 +81,10 @@ export declare enum SimpleListener {
81
81
  * Requires licence
82
82
  * Represents [[onContactAdded]]
83
83
  */
84
- Order = "onOrder"
84
+ Order = "onOrder",
85
+ /**
86
+ * Requires licence
87
+ * Represents [[onNewProduct]]
88
+ */
89
+ NewProduct = "onNewProduct"
85
90
  }
@@ -89,4 +89,9 @@ var SimpleListener;
89
89
  * Represents [[onContactAdded]]
90
90
  */
91
91
  SimpleListener["Order"] = "onOrder";
92
+ /**
93
+ * Requires licence
94
+ * Represents [[onNewProduct]]
95
+ */
96
+ SimpleListener["NewProduct"] = "onNewProduct";
92
97
  })(SimpleListener = exports.SimpleListener || (exports.SimpleListener = {}));
package/dist/cli/setup.js CHANGED
@@ -353,7 +353,7 @@ const cli = () => {
353
353
  booleanDefault: undefined
354
354
  });
355
355
  const cliConfig = Object.assign(Object.assign(Object.assign({ sessionId: "session" }, _cli.flags), (exports.configFile(_cli.flags.config) || {})), exports.envArgs());
356
- const PORT = cliConfig.port || process.env.PORT || 8080;
356
+ const PORT = Number(cliConfig.port || process.env.PORT || 8080);
357
357
  const spinner = new events_1.Spin(cliConfig.sessionId, 'STARTUP', cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.disableSpins);
358
358
  const createConfig = Object.assign({}, cliConfig);
359
359
  if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.session) {
@@ -117,7 +117,7 @@ function initPage(sessionId, config, customUserAgent, spinner) {
117
117
  }
118
118
  spinner === null || spinner === void 0 ? void 0 : spinner.info('Loading session data');
119
119
  let sessionjson = getSessionDataFromFile(sessionId, config, spinner);
120
- if (!sessionjson && config.sessionDataBucketAuth) {
120
+ if (!sessionjson && sessionjson !== "" && config.sessionDataBucketAuth) {
121
121
  try {
122
122
  spinner === null || spinner === void 0 ? void 0 : spinner.info('Unable to find session data file locally, attempting to find session data in cloud storage..');
123
123
  sessionjson = JSON.parse(Buffer.from(yield pico_s3_1.getTextFile(Object.assign(Object.assign({ directory: '_sessionData' }, JSON.parse(Buffer.from(config.sessionDataBucketAuth, 'base64').toString('ascii'))), { filename: `${config.sessionId || 'session'}.data.json` })), 'base64').toString('ascii'));
@@ -85,7 +85,7 @@ let axios;
85
85
  */
86
86
  //@ts-ignore
87
87
  function create(config = {}) {
88
- var _a, _b;
88
+ var _a, _b, _c;
89
89
  return __awaiter(this, void 0, void 0, function* () {
90
90
  const START_TIME = Date.now();
91
91
  let waPage = undefined;
@@ -377,7 +377,9 @@ function create(config = {}) {
377
377
  if ((config === null || config === void 0 ? void 0 : config.licenseKey) || me._serialized !== earlyWid) {
378
378
  yield getAndInjectLicense(waPage, config, me, debugInfo, spinner, me._serialized !== earlyWid ? false : yield licensePromise);
379
379
  }
380
+ spinner.info("Finalizing web session...");
380
381
  yield init_patch_1.injectInitPatch(waPage);
382
+ spinner.info("Finalizing client...");
381
383
  yield client.loaded();
382
384
  if (config.ensureHeadfulIntegrity && !attemptingReauth) {
383
385
  spinner.info("QR scanned for the first time. Refreshing...");
@@ -398,6 +400,10 @@ function create(config = {}) {
398
400
  catch (error) {
399
401
  spinner.emit(error.message);
400
402
  yield kill(waPage);
403
+ if (error.name === "ProtocolError" && ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes("Target closed"))) {
404
+ spinner.fail(error.message);
405
+ process.exit();
406
+ }
401
407
  if (error.name === "TimeoutError" && (config === null || config === void 0 ? void 0 : config.multiDevice)) {
402
408
  spinner.fail(`Please delete the ${config === null || config === void 0 ? void 0 : config.userDataDir} folder and any related data.json files and try again. It is highly suggested to set useChrome: true also.`);
403
409
  }
package/dist/lib/wapi.js CHANGED
@@ -52,7 +52,7 @@ if (!window.Store||!window.Store.Msg) {
52
52
  { id: "Participants", conditions: (module) => (module.addParticipants && module.removeParticipants && module.promoteParticipants && module.demoteParticipants) ? module : null },
53
53
  { id: "WidFactory", conditions: (module) => (module.isWidlike && module.createWid && module.createWidFromWidLike) ? module : null },
54
54
  { id: "Base", conditions: (module) => (module.setSubProtocol && module.binSend && module.actionNode) ? module : null },
55
- { id: "Versions", conditions: (module) => (module.loadProtoVersions && module.default["15"] && module.default["16"] && module.default["17"]) ? module : null },
55
+ { id: "Versions", conditions: (module) => (module.loadProtoVersions && module.default && module.default["15"] && module.default["16"] && module.default["17"]) ? module : null },
56
56
  { id: "Sticker", conditions: (module) => (module.default && module.default.Sticker) ? module.default.Sticker : null },
57
57
  { id: "MediaUpload", conditions: (module) => (module.default && module.default.mediaUpload) ? module.default : null },
58
58
  { id: "UploadUtils", conditions: (module) => (module.default && module.default.encryptAndUpload) ? module.default : null }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.23.3",
3
+ "version": "4.23.7",
4
4
  "licenseCheckUrl": "https://openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",
@@ -81,7 +81,7 @@
81
81
  "ava": "^3.13.0",
82
82
  "changelog-parser": "^2.8.0",
83
83
  "command-line-args": "^5.1.1",
84
- "eslint": "^7.20.0",
84
+ "eslint": "^8.1.0",
85
85
  "husky": "^7.0.0",
86
86
  "line-reader": "^0.4.0",
87
87
  "marked": "^3.0.0",