@wppconnect-team/wppconnect 1.10.2 → 1.12.0

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.
@@ -198,24 +198,22 @@ var Whatsapp = /** @class */ (function (_super) {
198
198
  */
199
199
  Whatsapp.prototype.downloadMedia = function (messageId) {
200
200
  return __awaiter(this, void 0, void 0, function () {
201
- var result;
201
+ var _this = this;
202
202
  return __generator(this, function (_a) {
203
203
  switch (_a.label) {
204
204
  case 0:
205
205
  if (typeof messageId !== 'string') {
206
206
  messageId = messageId.id;
207
207
  }
208
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (messageId) {
209
- return WAPI.downloadMedia(messageId).catch(function (e) { return ({
210
- __error: e,
211
- }); });
212
- }, messageId)];
213
- case 1:
214
- result = _a.sent();
215
- if (typeof result == 'object' && '__error' in result) {
216
- throw result.__error;
217
- }
218
- return [2 /*return*/, result];
208
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (messageId) { return __awaiter(_this, void 0, void 0, function () { var _a, _b; return __generator(this, function (_c) {
209
+ switch (_c.label) {
210
+ case 0:
211
+ _b = (_a = WPP.util).blobToBase64;
212
+ return [4 /*yield*/, WPP.chat.downloadMedia(messageId)];
213
+ case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
214
+ }
215
+ }); }); }, messageId)];
216
+ case 1: return [2 /*return*/, _a.sent()];
219
217
  }
220
218
  });
221
219
  });
@@ -109,6 +109,6 @@ export interface CreateConfig {
109
109
  * Define the connected device name in WhatsApp app
110
110
  * @default 'WPPConnect'
111
111
  */
112
- deviceName?: string;
112
+ deviceName?: string | false;
113
113
  }
114
114
  export declare const defaultOptions: CreateConfig;
@@ -20,5 +20,5 @@ exports.defaultOptions = {
20
20
  logger: logger_1.defaultLogger,
21
21
  tokenStore: 'file',
22
22
  whatsappVersion: '2.2144.x',
23
- deviceName: 'WPPConnect',
23
+ deviceName: false,
24
24
  };
@@ -233,8 +233,9 @@ function injectApi(page) {
233
233
  _a.sent();
234
234
  return [4 /*yield*/, page
235
235
  .waitForFunction(function () {
236
- // @ts-ignore
237
236
  return typeof window.WPP !== 'undefined' && window.WPP.isReady;
237
+ }, {
238
+ timeout: 60000,
238
239
  })
239
240
  .catch(function () { return false; })];
240
241
  case 3:
@@ -253,7 +254,6 @@ function injectApi(page) {
253
254
  _a.sent();
254
255
  return [4 /*yield*/, page
255
256
  .waitForFunction(function () {
256
- // @ts-ignore
257
257
  return (typeof window.WAPI !== 'undefined' &&
258
258
  typeof window.Store !== 'undefined');
259
259
  })
@@ -124,7 +124,7 @@ function create(sessionOrOption, catchQR, statusFind, options, browserSessionTok
124
124
  logger.info('Initializing browser...', { session: session, type: 'browser' });
125
125
  return [4 /*yield*/, (0, browser_1.initBrowser)(session, mergedOptions, logger).catch(function (e) {
126
126
  if (mergedOptions.browserWS && mergedOptions.browserWS != '') {
127
- logger.error("Error when try to connect " + mergedOptions.browserWS, {
127
+ logger.error("Error when try to connect ".concat(mergedOptions.browserWS), {
128
128
  session: session,
129
129
  type: 'browser',
130
130
  });
@@ -126,9 +126,9 @@ function checkWPPConnectVersion() {
126
126
  */
127
127
  function logUpdateAvailable(current, latest) {
128
128
  // prettier-ignore
129
- var newVersionLog = "There is a new version of " + chalk_1.default.bold("Wppconnect") + " " + chalk_1.default.gray(current) + " \u279C " + chalk_1.default.bold.green(latest) + "\n" +
129
+ var newVersionLog = "There is a new version of ".concat(chalk_1.default.bold("Wppconnect"), " ").concat(chalk_1.default.gray(current), " \u279C ").concat(chalk_1.default.bold.green(latest), "\n") +
130
130
  "Update your package by running:\n\n" +
131
- (chalk_1.default.bold('\>') + " " + chalk_1.default.blueBright('npm update @wppconnect-team/wppconnect'));
131
+ "".concat(chalk_1.default.bold('\>'), " ").concat(chalk_1.default.blueBright('npm update @wppconnect-team/wppconnect'));
132
132
  logger_1.defaultLogger.info((0, boxen_1.default)(newVersionLog, { padding: 1 }));
133
- logger_1.defaultLogger.info("For more info visit: " + chalk_1.default.underline('https://github.com/wppconnect-team/wppconnect/blob/master/Update.md') + "\n");
133
+ logger_1.defaultLogger.info("For more info visit: ".concat(chalk_1.default.underline('https://github.com/wppconnect-team/wppconnect/blob/master/Update.md'), "\n"));
134
134
  }