@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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ # 1.12.0 (2022-01-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fixed downloadMedia (fix [#463](https://github.com/wppconnect-team/wppconnect/issues/463)) ([ea9ba75](https://github.com/wppconnect-team/wppconnect/commit/ea9ba75ec3e24103a7ccf55b0df43ffc8d46271b))
7
+
8
+
9
+
10
+ ## 1.11.1 (2021-12-09)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Fixed getNumberProfile function (fix [#717](https://github.com/wppconnect-team/wppconnect/issues/717)) ([89a0720](https://github.com/wppconnect-team/wppconnect/commit/89a072066991213d301739b0788d19f05a9b0912))
16
+
17
+
18
+
19
+ # 1.11.0 (2021-12-09)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * Fixed initialization of onPresenceChanged (fix [#704](https://github.com/wppconnect-team/wppconnect/issues/704)) ([0470ea8](https://github.com/wppconnect-team/wppconnect/commit/0470ea8a0fd15727f91e18c913b96f3c1e1f79a9))
25
+
26
+
27
+
28
+ ## 1.10.3 (2021-11-18)
29
+
30
+
31
+
1
32
  ## 1.10.2 (2021-11-15)
2
33
 
3
34
 
@@ -76,7 +76,7 @@ var magix = function (fileData, mediaKeyBase64, mediaType, expectedSize) {
76
76
  var encodedHex = fileData.toString('hex');
77
77
  var encodedBytes = hexToBytes(encodedHex);
78
78
  var mediaKeyBytes = base64ToBytes(mediaKeyBase64);
79
- var info = "WhatsApp " + exports.mediaTypes[mediaType.toUpperCase()] + " Keys";
79
+ var info = "WhatsApp ".concat(exports.mediaTypes[mediaType.toUpperCase()], " Keys");
80
80
  var hash = 'sha256';
81
81
  var salt = new Uint8Array(32);
82
82
  var expandedSize = 112;
@@ -65,7 +65,7 @@ function downloadFileToBase64(_path, _mines) {
65
65
  switch (_a.label) {
66
66
  case 0:
67
67
  if (!Array.isArray(_mines)) {
68
- console.error("set mines string array, not \"" + typeof _mines + "\" ");
68
+ console.error("set mines string array, not \"".concat(typeof _mines, "\" "));
69
69
  return [2 /*return*/, false];
70
70
  }
71
71
  reHttp = /^https?:/;
@@ -89,12 +89,12 @@ function downloadFileToBase64(_path, _mines) {
89
89
  return m.exec(mimeType_1);
90
90
  });
91
91
  if (!isValidMime) {
92
- console.error("Content-Type \"" + mimeType_1 + "\" of " + _path + " is not allowed");
92
+ console.error("Content-Type \"".concat(mimeType_1, "\" of ").concat(_path, " is not allowed"));
93
93
  return [2 /*return*/, false];
94
94
  }
95
95
  }
96
96
  content = Buffer.from(response.data, 'binary').toString('base64');
97
- return [2 /*return*/, "data:" + mimeType_1 + ";base64," + content];
97
+ return [2 /*return*/, "data:".concat(mimeType_1, ";base64,").concat(content)];
98
98
  case 3:
99
99
  error_1 = _a.sent();
100
100
  return [3 /*break*/, 4];
@@ -94,7 +94,7 @@ function evaluateAndReturn(page, pageFunction) {
94
94
  throw new Error('Passed function is not well-serializable!');
95
95
  }
96
96
  }
97
- func = new Function("\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };\n var _this; // for arrow function\n\n return new Promise(async (resolve) => {\n try {\n return resolve(await (" + functionText + ").apply(this, arguments));\n } catch (error) {\n return resolve({\n __error: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error))),\n });\n }\n });");
97
+ func = new Function("\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };\n\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };\n var _this; // for arrow function\n\n return new Promise(async (resolve) => {\n try {\n return resolve(await (".concat(functionText, ").apply(this, arguments));\n } catch (error) {\n return resolve({\n __error: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error))),\n });\n }\n });"));
98
98
  return [4 /*yield*/, page.evaluate.apply(page, __spreadArray([func], args, false))];
99
99
  case 1:
100
100
  result = (_a.sent());
@@ -101,7 +101,7 @@ function fileToBase64(path, mime) {
101
101
  if (!mime) {
102
102
  mime = 'application/octet-stream';
103
103
  }
104
- data = "data:" + mime + ";base64," + base64;
104
+ data = "data:".concat(mime, ";base64,").concat(base64);
105
105
  return [2 /*return*/, data];
106
106
  case 3: return [2 /*return*/, false];
107
107
  }
@@ -4,5 +4,4 @@ export { downloadFileToBase64 } from './download-file';
4
4
  export { stickerSelect, resizeImg } from './select-sticker';
5
5
  export { scrapeImg } from './scrape-img-qr';
6
6
  export { scrapeLogin } from './scrape-login';
7
- export { scrapeDesconnected } from './scrape-desconnect';
8
7
  export { evaluateAndReturn } from './evaluate-and-return';
@@ -16,7 +16,7 @@
16
16
  * along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.evaluateAndReturn = exports.scrapeDesconnected = exports.scrapeLogin = exports.scrapeImg = exports.resizeImg = exports.stickerSelect = exports.downloadFileToBase64 = exports.base64MimeType = exports.fileToBase64 = void 0;
19
+ exports.evaluateAndReturn = exports.scrapeLogin = exports.scrapeImg = exports.resizeImg = exports.stickerSelect = exports.downloadFileToBase64 = exports.base64MimeType = exports.fileToBase64 = void 0;
20
20
  var file_to_base64_1 = require("./file-to-base64");
21
21
  Object.defineProperty(exports, "fileToBase64", { enumerable: true, get: function () { return file_to_base64_1.fileToBase64; } });
22
22
  var base64_mimetype_1 = require("./base64-mimetype");
@@ -30,7 +30,5 @@ var scrape_img_qr_1 = require("./scrape-img-qr");
30
30
  Object.defineProperty(exports, "scrapeImg", { enumerable: true, get: function () { return scrape_img_qr_1.scrapeImg; } });
31
31
  var scrape_login_1 = require("./scrape-login");
32
32
  Object.defineProperty(exports, "scrapeLogin", { enumerable: true, get: function () { return scrape_login_1.scrapeLogin; } });
33
- var scrape_desconnect_1 = require("./scrape-desconnect");
34
- Object.defineProperty(exports, "scrapeDesconnected", { enumerable: true, get: function () { return scrape_desconnect_1.scrapeDesconnected; } });
35
33
  var evaluate_and_return_1 = require("./evaluate-and-return");
36
34
  Object.defineProperty(exports, "evaluateAndReturn", { enumerable: true, get: function () { return evaluate_and_return_1.evaluateAndReturn; } });
@@ -87,7 +87,7 @@ function stickerSelect(_B, _t) {
87
87
  case 6:
88
88
  metadata = _c.sent();
89
89
  if (metadata.width > 512 || metadata.pageHeight > 512) {
90
- console.error("Invalid image size (max 512x512):" + metadata.width + "x" + metadata.pageHeight);
90
+ console.error("Invalid image size (max 512x512):".concat(metadata.width, "x").concat(metadata.pageHeight));
91
91
  return [2 /*return*/, false];
92
92
  }
93
93
  _b = {};
@@ -122,7 +122,12 @@ var ControlsLayer = /** @class */ (function (_super) {
122
122
  ControlsLayer.prototype.markUnseenMessage = function (contactId) {
123
123
  return __awaiter(this, void 0, void 0, function () {
124
124
  return __generator(this, function (_a) {
125
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WAPI.markUnseenMessage(contactId); }, contactId)];
125
+ switch (_a.label) {
126
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WPP.chat.markIsUnread(contactId); }, contactId)];
127
+ case 1:
128
+ _a.sent();
129
+ return [2 /*return*/, true];
130
+ }
126
131
  });
127
132
  });
128
133
  };
@@ -171,7 +171,7 @@ var HostLayer = /** @class */ (function () {
171
171
  _this.log('verbose', 'wapi.js injected');
172
172
  _this.getWAVersion()
173
173
  .then(function (version) {
174
- _this.log('info', "WhatsApp WEB version: " + version);
174
+ _this.log('info', "WhatsApp WEB version: ".concat(version));
175
175
  })
176
176
  .catch(function () { return null; });
177
177
  })
@@ -205,7 +205,7 @@ var HostLayer = /** @class */ (function () {
205
205
  var _this = this;
206
206
  if (this.options.autoClose > 0 && !this.autoCloseInterval) {
207
207
  var seconds = Math.round(this.options.autoClose / 1000);
208
- this.log('info', "Auto close configured to " + seconds + "s");
208
+ this.log('info', "Auto close configured to ".concat(seconds, "s"));
209
209
  var remain_1 = seconds;
210
210
  this.autoCloseInterval = setInterval(function () {
211
211
  if (_this.page.isClosed()) {
@@ -214,7 +214,7 @@ var HostLayer = /** @class */ (function () {
214
214
  }
215
215
  remain_1 -= 1;
216
216
  if (remain_1 % 10 === 0 || remain_1 <= 5) {
217
- _this.log('http', "Auto close remain: " + remain_1 + "s");
217
+ _this.log('http', "Auto close remain: ".concat(remain_1, "s"));
218
218
  }
219
219
  if (remain_1 <= 0) {
220
220
  _this.tryAutoClose();
@@ -270,10 +270,10 @@ var HostLayer = /** @class */ (function () {
270
270
  _a.label = 5;
271
271
  case 5:
272
272
  if (this.options.logQR) {
273
- this.log('info', "Waiting for QRCode Scan (Attempt " + attempt + ")...:\n" + qr, { code: urlCode });
273
+ this.log('info', "Waiting for QRCode Scan (Attempt ".concat(attempt, ")...:\n").concat(qr), { code: urlCode });
274
274
  }
275
275
  else {
276
- this.log('verbose', "Waiting for QRCode Scan: Attempt " + attempt);
276
+ this.log('verbose', "Waiting for QRCode Scan: Attempt ".concat(attempt));
277
277
  }
278
278
  if (catchQR) {
279
279
  catchQR(result.base64Image, qr, attempt, result.urlCode);
@@ -509,8 +509,7 @@ var HostLayer = /** @class */ (function () {
509
509
  return __generator(this, function (_a) {
510
510
  switch (_a.label) {
511
511
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
512
- //@ts-ignore
513
- return Store.State.default.state;
512
+ return WPP.whatsapp.State.state;
514
513
  })];
515
514
  case 1: return [2 /*return*/, _a.sent()];
516
515
  }
@@ -89,7 +89,7 @@ var ListenerLayer = /** @class */ (function (_super) {
89
89
  _this.page = page;
90
90
  _this.listenerEmitter = new events_1.EventEmitter();
91
91
  _this.listenerEmitter.on(exposed_enum_1.ExposedFn.onInterfaceChange, function (state) {
92
- _this.log('http', "Current state: " + state.mode + " (" + state.displayInfo + ")");
92
+ _this.log('http', "Current state: ".concat(state.mode, " (").concat(state.displayInfo, ")"));
93
93
  });
94
94
  return _this;
95
95
  }
@@ -117,7 +117,7 @@ var ListenerLayer = /** @class */ (function (_super) {
117
117
  case 1:
118
118
  has = _b.sent();
119
119
  if (!!has) return [3 /*break*/, 3];
120
- this_1.log('debug', "Exposing " + func + " function");
120
+ this_1.log('debug', "Exposing ".concat(func, " function"));
121
121
  return [4 /*yield*/, this_1.page
122
122
  .exposeFunction(func, function () {
123
123
  var _a;
@@ -199,7 +199,6 @@ var ListenerLayer = /** @class */ (function (_super) {
199
199
  window['onLiveLocation'].exposed = true;
200
200
  }
201
201
  if (!window['onRevokedMessage'].exposed) {
202
- // @ts-ignore
203
202
  WPP.chat.on('msg_revoke', function (data) {
204
203
  var eventData = {
205
204
  author: data.author,
@@ -30,7 +30,7 @@ export declare class RetrieverLayer extends SenderLayer {
30
30
  * @category Blocklist
31
31
  * @returns array of [0,1,2,3....]
32
32
  */
33
- getBlockList(): Promise<import("../model").Contact[]>;
33
+ getBlockList(): Promise<string[]>;
34
34
  /**
35
35
  * Retrieves all chats
36
36
  * @category Chat
@@ -115,6 +115,9 @@ export declare class RetrieverLayer extends SenderLayer {
115
115
  getStatus(contactId: string): Promise<import("../model").ContactStatus>;
116
116
  /**
117
117
  * Checks if a number is a valid whatsapp number
118
+ *
119
+ * Deprecated in favor of checkNumberStatus
120
+ * @deprecated Deprecated in favor of checkNumberStatus
118
121
  * @category Contact
119
122
  * @param contactId, you need to include the @c.us at the end.
120
123
  * @returns contact detial as promise
@@ -162,7 +162,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
162
162
  return __awaiter(this, void 0, void 0, function () {
163
163
  return __generator(this, function (_a) {
164
164
  switch (_a.label) {
165
- case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () { return WAPI.getBlockList(); })];
165
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
166
+ return WPP.blocklist.all().map(function (b) { return b.toString(); });
167
+ })];
166
168
  case 1: return [2 /*return*/, _a.sent()];
167
169
  }
168
170
  });
@@ -361,6 +363,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
361
363
  };
362
364
  /**
363
365
  * Checks if a number is a valid whatsapp number
366
+ *
367
+ * Deprecated in favor of checkNumberStatus
368
+ * @deprecated Deprecated in favor of checkNumberStatus
364
369
  * @category Contact
365
370
  * @param contactId, you need to include the @c.us at the end.
366
371
  * @returns contact detial as promise
@@ -1,4 +1,4 @@
1
- import { ListMessageOptions } from '@wppconnect/wa-js/dist/chat';
1
+ import type { ListMessageOptions, TextMessageOptions } from '@wppconnect/wa-js/dist/chat';
2
2
  import { Page } from 'puppeteer';
3
3
  import { CreateConfig } from '../../config/create-config';
4
4
  import { Message, SendFileResult, SendLinkResult, SendStickerResult } from '../model';
@@ -20,8 +20,30 @@ export declare class SenderLayer extends ListenerLayer {
20
20
  * @category Chat
21
21
  * @param to chat id: xxxxx@us.c
22
22
  * @param content text message
23
+ *
24
+ * @example
25
+ * ```javascript
26
+ * // Simple message
27
+ * client.sendText('<number>@c.us', 'A simple message');
28
+ *
29
+ * // With buttons
30
+ * client.sendText('<number>@c.us', 'A simple message with buttons', {
31
+ * buttons: [
32
+ * {
33
+ * id: 'your custom id 1',
34
+ * text: 'Some text'
35
+ * },
36
+ * {
37
+ * id: 'another id 2',
38
+ * text: 'Another text'
39
+ * }
40
+ * ],
41
+ * title: 'Title text' // Optional
42
+ * footer: 'Footer text' // Optional
43
+ * });
44
+ * ```
23
45
  */
24
- sendText(to: string, content: string): Promise<Message>;
46
+ sendText(to: string, content: string, options?: TextMessageOptions): Promise<Message>;
25
47
  /**
26
48
  *
27
49
  * @category Chat
@@ -181,7 +203,7 @@ export declare class SenderLayer extends ListenerLayer {
181
203
  * @param to Chat id
182
204
  * @param contactsId Example: 0000@c.us | [000@c.us, 1111@c.us]
183
205
  */
184
- sendContactVcard(to: string, contactsId: string | string[], name?: string): Promise<object>;
206
+ sendContactVcard(to: string, contactsId: string, name?: string): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
185
207
  /**
186
208
  * Send a list of contact cards
187
209
  * @category Chat
@@ -191,7 +213,7 @@ export declare class SenderLayer extends ListenerLayer {
191
213
  sendContactVcardList(to: string, contacts: (string | {
192
214
  id: string;
193
215
  name: string;
194
- })[]): Promise<object>;
216
+ })[]): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
195
217
  /**
196
218
  * Forwards array of messages (could be ids or message objects)
197
219
  * @category Chat
@@ -230,19 +252,34 @@ export declare class SenderLayer extends ListenerLayer {
230
252
  * @category Chat
231
253
  * @param chatId chat id: xxxxx@us.c
232
254
  */
233
- sendSeen(chatId: string): Promise<void>;
255
+ sendSeen(chatId: string): Promise<{
256
+ wid: import("@wppconnect/wa-js/dist/whatsapp").Wid;
257
+ unreadCount: number;
258
+ }>;
234
259
  /**
235
260
  * Starts typing ('Typing...' state)
236
261
  * @category Chat
237
262
  * @param chatId
238
263
  */
239
- startTyping(to: string): Promise<void>;
264
+ startTyping(to: string, duration?: number): Promise<void>;
240
265
  /**
241
266
  * Stops typing ('Typing...' state)
242
267
  * @category Chat
243
268
  * @param chatId
244
269
  */
245
270
  stopTyping(to: string): Promise<void>;
271
+ /**
272
+ * Starts recording ('Recording...' state)
273
+ * @category Chat
274
+ * @param chatId
275
+ */
276
+ startRecording(to: string, duration?: number): Promise<void>;
277
+ /**
278
+ * Stops recording ('Recording...' state)
279
+ * @category Chat
280
+ * @param chatId
281
+ */
282
+ stopRecoring(to: string): Promise<void>;
246
283
  /**
247
284
  * Update your online presence
248
285
  * @category Chat
@@ -253,7 +290,7 @@ export declare class SenderLayer extends ListenerLayer {
253
290
  * Sends text with tags
254
291
  * @category Chat
255
292
  */
256
- sendMentioned(to: string, message: string, mentioned: string[]): Promise<void>;
293
+ sendMentioned(to: string, message: string, mentioned: string[]): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
257
294
  /**
258
295
  * Sends a list message
259
296
  *
@@ -287,9 +324,11 @@ export declare class SenderLayer extends ListenerLayer {
287
324
  sendListMessage(to: string, options: ListMessageOptions): Promise<void>;
288
325
  /**
289
326
  * Sets the chat state
327
+ * Deprecated in favor of Use startTyping or startRecording functions
290
328
  * @category Chat
291
329
  * @param chatState
292
330
  * @param chatId
331
+ * @deprecated Deprecated in favor of Use startTyping or startRecording functions
293
332
  */
294
333
  setChatState(chatId: string, chatState: ChatState): Promise<void>;
295
334
  }
@@ -30,6 +30,17 @@ var __extends = (this && this.__extends) || (function () {
30
30
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31
31
  };
32
32
  })();
33
+ var __assign = (this && this.__assign) || function () {
34
+ __assign = Object.assign || function(t) {
35
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
36
+ s = arguments[i];
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
38
+ t[p] = s[p];
39
+ }
40
+ return t;
41
+ };
42
+ return __assign.apply(this, arguments);
43
+ };
33
44
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
34
45
  if (k2 === undefined) k2 = k;
35
46
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -130,19 +141,56 @@ var SenderLayer = /** @class */ (function (_super) {
130
141
  * @category Chat
131
142
  * @param to chat id: xxxxx@us.c
132
143
  * @param content text message
144
+ *
145
+ * @example
146
+ * ```javascript
147
+ * // Simple message
148
+ * client.sendText('<number>@c.us', 'A simple message');
149
+ *
150
+ * // With buttons
151
+ * client.sendText('<number>@c.us', 'A simple message with buttons', {
152
+ * buttons: [
153
+ * {
154
+ * id: 'your custom id 1',
155
+ * text: 'Some text'
156
+ * },
157
+ * {
158
+ * id: 'another id 2',
159
+ * text: 'Another text'
160
+ * }
161
+ * ],
162
+ * title: 'Title text' // Optional
163
+ * footer: 'Footer text' // Optional
164
+ * });
165
+ * ```
133
166
  */
134
- SenderLayer.prototype.sendText = function (to, content) {
167
+ SenderLayer.prototype.sendText = function (to, content, options) {
135
168
  return __awaiter(this, void 0, void 0, function () {
136
- var messageId, result;
169
+ var sendResult, result;
170
+ var _this = this;
137
171
  return __generator(this, function (_a) {
138
172
  switch (_a.label) {
139
173
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
140
- var to = _a.to, content = _a.content;
141
- return WAPI.sendMessage(to, content);
142
- }, { to: to, content: content })];
174
+ var to = _a.to, content = _a.content, options = _a.options;
175
+ return WPP.chat.sendTextMessage(to, content, __assign(__assign({}, options), { waitForAck: true }));
176
+ }, { to: to, content: content, options: options })];
143
177
  case 1:
144
- messageId = _a.sent();
145
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (messageId) { return WAPI.getMessageById(messageId); }, messageId)];
178
+ sendResult = _a.sent();
179
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
180
+ var messageId = _a.messageId;
181
+ return __awaiter(_this, void 0, void 0, function () {
182
+ var _b, _c, _d, _e;
183
+ return __generator(this, function (_f) {
184
+ switch (_f.label) {
185
+ case 0:
186
+ _c = (_b = JSON).parse;
187
+ _e = (_d = JSON).stringify;
188
+ return [4 /*yield*/, WAPI.getMessageById(messageId)];
189
+ case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
190
+ }
191
+ });
192
+ });
193
+ }, { messageId: sendResult.id })];
146
194
  case 2:
147
195
  result = (_a.sent());
148
196
  if (result['erro'] == true) {
@@ -308,17 +356,34 @@ var SenderLayer = /** @class */ (function (_super) {
308
356
  */
309
357
  SenderLayer.prototype.sendMessageWithThumb = function (thumb, url, title, description, chatId) {
310
358
  return __awaiter(this, void 0, void 0, function () {
359
+ var base64;
311
360
  return __generator(this, function (_a) {
312
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
313
- var thumb = _a.thumb, url = _a.url, title = _a.title, description = _a.description, chatId = _a.chatId;
314
- WAPI.sendMessageWithThumb(thumb, url, title, description, chatId);
315
- }, {
316
- thumb: thumb,
317
- url: url,
318
- title: title,
319
- description: description,
320
- chatId: chatId,
321
- })];
361
+ switch (_a.label) {
362
+ case 0: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(thumb, [
363
+ 'image/gif',
364
+ 'image/png',
365
+ 'image/jpg',
366
+ 'image/jpeg',
367
+ 'image/webp',
368
+ ])];
369
+ case 1:
370
+ base64 = _a.sent();
371
+ if (!!base64) return [3 /*break*/, 3];
372
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(thumb)];
373
+ case 2:
374
+ base64 = _a.sent();
375
+ _a.label = 3;
376
+ case 3: return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
377
+ var thumb = _a.thumb, url = _a.url, title = _a.title, description = _a.description, chatId = _a.chatId;
378
+ WAPI.sendMessageWithThumb(thumb, url, title, description, chatId);
379
+ }, {
380
+ base64: base64,
381
+ url: url,
382
+ title: title,
383
+ description: description,
384
+ chatId: chatId,
385
+ })];
386
+ }
322
387
  });
323
388
  });
324
389
  };
@@ -693,13 +758,13 @@ var SenderLayer = /** @class */ (function (_super) {
693
758
  switch (_a.label) {
694
759
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
695
760
  var to = _a.to, contactsId = _a.contactsId, name = _a.name;
696
- return WAPI.sendContactVcard(to, contactsId, name);
761
+ return WPP.chat.sendVCardContactMessage(to, {
762
+ id: contactsId,
763
+ name: name,
764
+ });
697
765
  }, { to: to, contactsId: contactsId, name: name })];
698
766
  case 1:
699
767
  result = _a.sent();
700
- if (result['erro'] == true) {
701
- throw result;
702
- }
703
768
  return [2 /*return*/, result];
704
769
  }
705
770
  });
@@ -718,13 +783,10 @@ var SenderLayer = /** @class */ (function (_super) {
718
783
  switch (_a.label) {
719
784
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
720
785
  var to = _a.to, contacts = _a.contacts;
721
- return WAPI.sendContactVcardList(to, contacts);
786
+ return WPP.chat.sendVCardContactMessage(to, contacts);
722
787
  }, { to: to, contacts: contacts })];
723
788
  case 1:
724
789
  result = _a.sent();
725
- if (result['erro'] == true) {
726
- throw result;
727
- }
728
790
  return [2 /*return*/, result];
729
791
  }
730
792
  });
@@ -899,7 +961,7 @@ var SenderLayer = /** @class */ (function (_super) {
899
961
  SenderLayer.prototype.sendSeen = function (chatId) {
900
962
  return __awaiter(this, void 0, void 0, function () {
901
963
  return __generator(this, function (_a) {
902
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) { return WAPI.sendSeen(chatId); }, chatId)];
964
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) { return WPP.chat.markIsRead(chatId); }, chatId)];
903
965
  });
904
966
  });
905
967
  };
@@ -908,14 +970,15 @@ var SenderLayer = /** @class */ (function (_super) {
908
970
  * @category Chat
909
971
  * @param chatId
910
972
  */
911
- SenderLayer.prototype.startTyping = function (to) {
973
+ SenderLayer.prototype.startTyping = function (to, duration) {
912
974
  return __awaiter(this, void 0, void 0, function () {
913
975
  return __generator(this, function (_a) {
914
976
  return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
915
- var to = _a.to;
916
- return WAPI.startTyping(to);
977
+ var to = _a.to, duration = _a.duration;
978
+ return WPP.chat.markIsComposing(to, duration);
917
979
  }, {
918
980
  to: to,
981
+ duration: duration,
919
982
  })];
920
983
  });
921
984
  });
@@ -930,7 +993,42 @@ var SenderLayer = /** @class */ (function (_super) {
930
993
  return __generator(this, function (_a) {
931
994
  return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
932
995
  var to = _a.to;
933
- return WAPI.stopTyping(to);
996
+ return WPP.chat.markIsPaused(to);
997
+ }, {
998
+ to: to,
999
+ })];
1000
+ });
1001
+ });
1002
+ };
1003
+ /**
1004
+ * Starts recording ('Recording...' state)
1005
+ * @category Chat
1006
+ * @param chatId
1007
+ */
1008
+ SenderLayer.prototype.startRecording = function (to, duration) {
1009
+ return __awaiter(this, void 0, void 0, function () {
1010
+ return __generator(this, function (_a) {
1011
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1012
+ var to = _a.to, duration = _a.duration;
1013
+ return WPP.chat.markIsRecording(to, duration);
1014
+ }, {
1015
+ to: to,
1016
+ duration: duration,
1017
+ })];
1018
+ });
1019
+ });
1020
+ };
1021
+ /**
1022
+ * Stops recording ('Recording...' state)
1023
+ * @category Chat
1024
+ * @param chatId
1025
+ */
1026
+ SenderLayer.prototype.stopRecoring = function (to) {
1027
+ return __awaiter(this, void 0, void 0, function () {
1028
+ return __generator(this, function (_a) {
1029
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1030
+ var to = _a.to;
1031
+ return WPP.chat.markIsPaused(to);
934
1032
  }, {
935
1033
  to: to,
936
1034
  })];
@@ -965,7 +1063,10 @@ var SenderLayer = /** @class */ (function (_super) {
965
1063
  switch (_a.label) {
966
1064
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
967
1065
  var to = _a.to, message = _a.message, mentioned = _a.mentioned;
968
- WAPI.sendMessageMentioned(to, message, mentioned);
1066
+ return WPP.chat.sendTextMessage(to, message, {
1067
+ detectMentioned: true,
1068
+ mentionedList: mentioned,
1069
+ });
969
1070
  }, { to: to, message: message, mentioned: mentioned })];
970
1071
  case 1: return [2 /*return*/, _a.sent()];
971
1072
  }
@@ -1017,9 +1118,11 @@ var SenderLayer = /** @class */ (function (_super) {
1017
1118
  };
1018
1119
  /**
1019
1120
  * Sets the chat state
1121
+ * Deprecated in favor of Use startTyping or startRecording functions
1020
1122
  * @category Chat
1021
1123
  * @param chatState
1022
1124
  * @param chatId
1125
+ * @deprecated Deprecated in favor of Use startTyping or startRecording functions
1023
1126
  */
1024
1127
  SenderLayer.prototype.setChatState = function (chatId, chatState) {
1025
1128
  return __awaiter(this, void 0, void 0, function () {
@@ -34,7 +34,7 @@ export declare class Whatsapp extends BusinessLayer {
34
34
  * Logout whastapp
35
35
  * @returns boolean
36
36
  */
37
- logout(): Promise<any>;
37
+ logout(): Promise<boolean>;
38
38
  /**
39
39
  * Closes page and browser
40
40
  * @internal