@open-wa/wa-automate 4.33.8 → 4.34.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -101,6 +101,7 @@ export declare class Client {
101
101
  */
102
102
  getConfig(): ConfigObject;
103
103
  private pup;
104
+ private responseWrap;
104
105
  /**
105
106
  * //////////////////////// LISTENERS
106
107
  */
@@ -487,36 +487,39 @@ class Client {
487
487
  if (_t && logging) {
488
488
  logging_1.log.info(`OUT ${invocation_id}: ${Date.now() - _t}ms`, { res });
489
489
  }
490
- if (this._createConfig.onError && typeof res == "string" && (res.startsWith("Error") || res.startsWith("ERROR"))) {
491
- const e = this._createConfig.onError;
492
- /**
493
- * Log error
494
- */
495
- if (e == model_1.OnError.LOG_AND_FALSE ||
496
- e == model_1.OnError.LOG_AND_STRING ||
497
- res.includes("get.openwa.dev"))
498
- console.error(res);
499
- /**
500
- * Return res
501
- */
502
- if (e == model_1.OnError.AS_STRING ||
503
- e == model_1.OnError.NOTHING ||
504
- e == model_1.OnError.LOG_AND_STRING)
505
- return res;
506
- /**
507
- * Return false
508
- */
509
- if (e == model_1.OnError.LOG_AND_FALSE ||
510
- e == model_1.OnError.RETURN_FALSE)
511
- return false;
512
- if (e == model_1.OnError.RETURN_ERROR)
513
- return new Error(res);
514
- if (e == model_1.OnError.THROW)
515
- throw new Error(res);
516
- }
517
- return res;
490
+ return this.responseWrap(res);
518
491
  });
519
492
  }
493
+ responseWrap(res) {
494
+ if (this._createConfig.onError && typeof res == "string" && (res.startsWith("Error") || res.startsWith("ERROR"))) {
495
+ const e = this._createConfig.onError;
496
+ /**
497
+ * Log error
498
+ */
499
+ if (e == model_1.OnError.LOG_AND_FALSE ||
500
+ e == model_1.OnError.LOG_AND_STRING ||
501
+ res.includes("get.openwa.dev"))
502
+ console.error(res);
503
+ /**
504
+ * Return res
505
+ */
506
+ if (e == model_1.OnError.AS_STRING ||
507
+ e == model_1.OnError.NOTHING ||
508
+ e == model_1.OnError.LOG_AND_STRING)
509
+ return res;
510
+ /**
511
+ * Return false
512
+ */
513
+ if (e == model_1.OnError.LOG_AND_FALSE ||
514
+ e == model_1.OnError.RETURN_FALSE)
515
+ return false;
516
+ if (e == model_1.OnError.RETURN_ERROR)
517
+ return new Error(res);
518
+ if (e == model_1.OnError.THROW)
519
+ throw new Error(res);
520
+ }
521
+ return res;
522
+ }
520
523
  /**
521
524
  * //////////////////////// LISTENERS
522
525
  */
@@ -1223,10 +1226,9 @@ class Client {
1223
1226
  if (err.includes(res)) {
1224
1227
  let msg = res;
1225
1228
  if (res == err[1])
1226
- msg = `\n${res}. Unlock this feature and support open-wa by getting a license: ${yield this.link()}\n`;
1227
- console.error(msg);
1228
- if (this._createConfig.onError == model_1.OnError.THROW)
1229
- throw new errors_1.CustomError(errors_1.ERROR_NAME.SENDTEXT_FAILURE, msg);
1229
+ msg = `ERROR: ${res}. Unlock this feature and support open-wa by getting a license: ${yield this.link()}`;
1230
+ console.error(`\n${msg}\n`);
1231
+ return this.responseWrap(msg);
1230
1232
  }
1231
1233
  return (err.includes(res) ? false : res);
1232
1234
  });
@@ -378,8 +378,6 @@ function create(config = {}) {
378
378
  config.skipBrokenMethodsCheck = true;
379
379
  // config.skipPatches = true;
380
380
  }
381
- debugInfo.NUM = yield waPage.evaluate(`(window.localStorage['last-wid'] || '').replace('@c.us','').replace(/"/g,"").slice(-4)`);
382
- debugInfo.NUM_HASH = (0, crypto_1.createHash)('md5').update(yield waPage.evaluate(`(window.localStorage['last-wid'] || '').replace('@c.us','').replace(/"/g,"")`), 'utf8').digest('hex');
383
381
  if (config === null || config === void 0 ? void 0 : config.hostNotificationLang) {
384
382
  yield waPage.evaluate(`window.hostlang="${config.hostNotificationLang}"`);
385
383
  }
@@ -388,6 +386,9 @@ function create(config = {}) {
388
386
  yield (0, patch_manager_1.getAndInjectLivePatch)(waPage, spinner, yield patchPromise, config, debugInfo);
389
387
  debugInfo.OW_KEY = yield waPage.evaluate(`window.o()`);
390
388
  }
389
+ const NUM = ((yield waPage.evaluate(`(window.moi() || "").replace('@c.us','').replace(/"/g,"")`)) || "");
390
+ debugInfo.NUM = NUM.slice(-4);
391
+ debugInfo.NUM_HASH = (0, crypto_1.createHash)('md5').update(NUM, 'utf8').digest('hex');
391
392
  if ((config === null || config === void 0 ? void 0 : config.skipBrokenMethodsCheck) !== true)
392
393
  yield (0, launch_checks_1.integrityCheck)(waPage, notifier, spinner, debugInfo);
393
394
  const LAUNCH_TIME_MS = Date.now() - START_TIME;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.33.8",
3
+ "version": "4.34.0",
4
4
  "licenseCheckUrl": "https://funcs.openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://funcs.openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",