keithbaileys 1.0.6 → 1.0.8

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.
@@ -13,11 +13,34 @@ class USyncContactProtocol {
13
13
  };
14
14
  }
15
15
  getUserElement(user) {
16
- //TODO: Implement type / username fields (not yet supported)
16
+ if (user.phone) {
17
+ return {
18
+ tag: 'contact',
19
+ attrs: {},
20
+ content: user.phone
21
+ };
22
+ }
23
+ if (user.username) {
24
+ return {
25
+ tag: 'contact',
26
+ attrs: {
27
+ username: user.username,
28
+ ...(user.usernameKey ? { pin: user.usernameKey } : {}),
29
+ ...(user.lid ? { lid: user.lid } : {})
30
+ }
31
+ };
32
+ }
33
+ if (user.type) {
34
+ return {
35
+ tag: 'contact',
36
+ attrs: {
37
+ type: user.type
38
+ }
39
+ };
40
+ }
17
41
  return {
18
42
  tag: 'contact',
19
- attrs: {},
20
- content: user.phone
43
+ attrs: {}
21
44
  };
22
45
  }
23
46
  parser(node) {
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USyncUsernameProtocol = void 0;
4
+ const WABinary_1 = require("../../WABinary");
5
+ class USyncUsernameProtocol {
6
+ constructor() {
7
+ this.name = 'username';
8
+ }
9
+ getQueryElement() {
10
+ return {
11
+ tag: 'username',
12
+ attrs: {}
13
+ };
14
+ }
15
+ getUserElement() {
16
+ return null;
17
+ }
18
+ parser(node) {
19
+ if (node.tag === 'username') {
20
+ (0, WABinary_1.assertNodeErrorFree)(node);
21
+ return typeof node.content === 'string' ? node.content : null;
22
+ }
23
+ return null;
24
+ }
25
+ }
26
+ exports.USyncUsernameProtocol = USyncUsernameProtocol;
@@ -18,3 +18,4 @@ __exportStar(require("./USyncDeviceProtocol"), exports);
18
18
  __exportStar(require("./USyncContactProtocol"), exports);
19
19
  __exportStar(require("./USyncStatusProtocol"), exports);
20
20
  __exportStar(require("./USyncDisappearingModeProtocol"), exports);
21
+ __exportStar(require("./USyncUsernameProtocol"), exports);
@@ -89,5 +89,9 @@ class USyncQuery {
89
89
  this.protocols.push(new UsyncLIDProtocol_1.USyncLIDProtocol());
90
90
  return this;
91
91
  }
92
+ withUsernameProtocol() {
93
+ this.protocols.push(new Protocols_1.USyncUsernameProtocol());
94
+ return this;
95
+ }
92
96
  }
93
97
  exports.USyncQuery = USyncQuery;
@@ -14,6 +14,14 @@ class USyncUser {
14
14
  this.phone = phone;
15
15
  return this;
16
16
  }
17
+ withUsername(username) {
18
+ this.username = username;
19
+ return this;
20
+ }
21
+ withUsernameKey(usernameKey) {
22
+ this.usernameKey = usernameKey;
23
+ return this;
24
+ }
17
25
  withType(type) {
18
26
  this.type = type;
19
27
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keithbaileys",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "A lightweight, full-featured WhatsApp Web API library for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",