@pney/whatsapp-web 1.34.6 → 1.34.7-1

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.
Files changed (59) hide show
  1. package/.env.example +0 -1
  2. package/.gitattributes +4 -0
  3. package/.husky/commit-msg +4 -0
  4. package/.husky/pre-commit +1 -0
  5. package/.lintstagedrc.json +6 -0
  6. package/.prettierignore +8 -0
  7. package/.prettierrc.json +10 -0
  8. package/README.md +83 -80
  9. package/commitlint.config.js +29 -0
  10. package/eslint.config.mjs +67 -0
  11. package/example.js +151 -71
  12. package/index.d.ts +982 -734
  13. package/index.js +4 -4
  14. package/package.json +3 -3
  15. package/shell.js +4 -4
  16. package/src/Client.js +1860 -920
  17. package/src/authStrategies/BaseAuthStrategy.js +4 -2
  18. package/src/authStrategies/LocalAuth.js +25 -12
  19. package/src/authStrategies/NoAuth.js +3 -4
  20. package/src/authStrategies/RemoteAuth.js +92 -43
  21. package/src/factories/ChatFactory.js +1 -1
  22. package/src/factories/ContactFactory.js +2 -2
  23. package/src/structures/Base.js +5 -3
  24. package/src/structures/Broadcast.js +1 -2
  25. package/src/structures/BusinessContact.js +1 -2
  26. package/src/structures/Buttons.js +14 -10
  27. package/src/structures/Call.js +10 -6
  28. package/src/structures/Channel.js +171 -91
  29. package/src/structures/Chat.js +57 -41
  30. package/src/structures/ClientInfo.js +1 -1
  31. package/src/structures/Contact.js +37 -16
  32. package/src/structures/GroupChat.js +425 -228
  33. package/src/structures/GroupNotification.js +21 -12
  34. package/src/structures/Label.js +6 -6
  35. package/src/structures/List.js +22 -14
  36. package/src/structures/Location.js +5 -4
  37. package/src/structures/Message.js +412 -168
  38. package/src/structures/MessageMedia.js +31 -18
  39. package/src/structures/Order.js +4 -4
  40. package/src/structures/Payment.js +6 -3
  41. package/src/structures/Poll.js +2 -2
  42. package/src/structures/PollVote.js +9 -6
  43. package/src/structures/PrivateChat.js +2 -4
  44. package/src/structures/PrivateContact.js +2 -4
  45. package/src/structures/Product.js +1 -1
  46. package/src/structures/ProductMetadata.js +1 -2
  47. package/src/structures/Reaction.js +2 -4
  48. package/src/structures/ScheduledEvent.js +22 -10
  49. package/src/util/Constants.js +8 -6
  50. package/src/util/Injected/AuthStore/AuthStore.js +7 -3
  51. package/src/util/Injected/Utils.js +753 -345
  52. package/src/util/InterfaceController.js +72 -25
  53. package/src/util/Puppeteer.js +1 -1
  54. package/src/util/Util.js +28 -15
  55. package/src/webCache/LocalWebCache.js +7 -5
  56. package/src/webCache/RemoteWebCache.js +10 -4
  57. package/src/webCache/WebCache.js +8 -5
  58. package/src/webCache/WebCacheFactory.js +9 -9
  59. package/CODE_OF_CONDUCT.md +0 -133
@@ -10,7 +10,7 @@ class GroupNotification extends Base {
10
10
  constructor(client, data) {
11
11
  super(client);
12
12
 
13
- if(data) this._patch(data);
13
+ if (data) this._patch(data);
14
14
  }
15
15
 
16
16
  _patch(data) {
@@ -26,12 +26,12 @@ class GroupNotification extends Base {
26
26
  */
27
27
  this.body = data.body || '';
28
28
 
29
- /**
29
+ /**
30
30
  * GroupNotification type
31
31
  * @type {GroupNotificationTypes}
32
32
  */
33
33
  this.type = data.subtype;
34
-
34
+
35
35
  /**
36
36
  * Unix timestamp for when the groupNotification was created
37
37
  * @type {number}
@@ -40,17 +40,23 @@ class GroupNotification extends Base {
40
40
 
41
41
  /**
42
42
  * ID for the Chat that this groupNotification was sent for.
43
- *
43
+ *
44
44
  * @type {string}
45
45
  */
46
- this.chatId = typeof (data.id.remote) === 'object' ? data.id.remote._serialized : data.id.remote;
46
+ this.chatId =
47
+ typeof data.id.remote === 'object'
48
+ ? data.id.remote._serialized
49
+ : data.id.remote;
47
50
 
48
51
  /**
49
52
  * ContactId for the user that produced the GroupNotification.
50
53
  * @type {string}
51
54
  */
52
- this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
53
-
55
+ this.author =
56
+ typeof data.author === 'object'
57
+ ? data.author._serialized
58
+ : data.author;
59
+
54
60
  /**
55
61
  * Contact IDs for the users that were affected by this GroupNotification.
56
62
  * @type {Array<string>}
@@ -85,20 +91,23 @@ class GroupNotification extends Base {
85
91
  * @returns {Promise<Array<Contact>>}
86
92
  */
87
93
  async getRecipients() {
88
- return await Promise.all(this.recipientIds.map(async m => await this.client.getContactById(m)));
94
+ return await Promise.all(
95
+ this.recipientIds.map(
96
+ async (m) => await this.client.getContactById(m),
97
+ ),
98
+ );
89
99
  }
90
100
 
91
101
  /**
92
102
  * Sends a message to the same chat this GroupNotification was produced in.
93
- *
94
- * @param {string|MessageMedia|Location} content
103
+ *
104
+ * @param {string|MessageMedia|Location} content
95
105
  * @param {object} options
96
106
  * @returns {Promise<Message>}
97
107
  */
98
- async reply(content, options={}) {
108
+ async reply(content, options = {}) {
99
109
  return this.client.sendMessage(this.chatId, content, options);
100
110
  }
101
-
102
111
  }
103
112
 
104
113
  module.exports = GroupNotification;
@@ -12,13 +12,13 @@ class Label extends Base {
12
12
  * @param {Base} client
13
13
  * @param {object} labelData
14
14
  */
15
- constructor(client, labelData){
15
+ constructor(client, labelData) {
16
16
  super(client);
17
17
 
18
- if(labelData) this._patch(labelData);
18
+ if (labelData) this._patch(labelData);
19
19
  }
20
20
 
21
- _patch(labelData){
21
+ _patch(labelData) {
22
22
  /**
23
23
  * Label ID
24
24
  * @type {string}
@@ -37,14 +37,14 @@ class Label extends Base {
37
37
  */
38
38
  this.hexColor = labelData.hexColor;
39
39
  }
40
+
40
41
  /**
41
42
  * Get all chats that have been assigned this Label
42
43
  * @returns {Promise<Array<Chat>>}
43
44
  */
44
- async getChats(){
45
+ async getChats() {
45
46
  return this.client.getChatsByLabelId(this.id);
46
47
  }
47
-
48
48
  }
49
49
 
50
- module.exports = Label;
50
+ module.exports = Label;
@@ -25,13 +25,12 @@ class List {
25
25
  * @type {string}
26
26
  */
27
27
  this.buttonText = buttonText;
28
-
28
+
29
29
  /**
30
30
  * title of message
31
31
  * @type {string}
32
32
  */
33
33
  this.title = title;
34
-
35
34
 
36
35
  /**
37
36
  * footer of message
@@ -44,9 +43,8 @@ class List {
44
43
  * @type {Array<any>}
45
44
  */
46
45
  this.sections = this._format(sections);
47
-
48
46
  }
49
-
47
+
50
48
  /**
51
49
  * Creates section array from simple array
52
50
  * @param {Array<any>} sections
@@ -55,25 +53,35 @@ class List {
55
53
  * Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
56
54
  * Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
57
55
  */
58
- _format(sections){
59
- if(!sections.length){throw '[LT02] List without sections';}
60
- if(sections.length > 1 && sections.filter(s => typeof s.title == 'undefined').length > 1){throw '[LT05] You can\'t have more than one empty title.';}
61
- return sections.map( (section) =>{
62
- if(!section.rows.length){throw '[LT03] Section without rows';}
56
+ _format(sections) {
57
+ if (!sections.length) {
58
+ throw '[LT02] List without sections';
59
+ }
60
+ if (
61
+ sections.length > 1 &&
62
+ sections.filter((s) => typeof s.title == 'undefined').length > 1
63
+ ) {
64
+ throw "[LT05] You can't have more than one empty title.";
65
+ }
66
+ return sections.map((section) => {
67
+ if (!section.rows.length) {
68
+ throw '[LT03] Section without rows';
69
+ }
63
70
  return {
64
71
  title: section.title ? section.title : undefined,
65
- rows: section.rows.map( (row) => {
66
- if(!row.title){throw '[LT04] Row without title';}
72
+ rows: section.rows.map((row) => {
73
+ if (!row.title) {
74
+ throw '[LT04] Row without title';
75
+ }
67
76
  return {
68
77
  rowId: row.id ? row.id : Util.generateHash(6),
69
78
  title: row.title,
70
- description: row.description ? row.description : ''
79
+ description: row.description ? row.description : '',
71
80
  };
72
- })
81
+ }),
73
82
  };
74
83
  });
75
84
  }
76
-
77
85
  }
78
86
 
79
87
  module.exports = List;
@@ -53,10 +53,11 @@ class Location {
53
53
  * Location full description
54
54
  * @type {string|undefined}
55
55
  */
56
- this.description = this.name && this.address
57
- ? `${this.name}\n${this.address}`
58
- : this.name || this.address || '';
56
+ this.description =
57
+ this.name && this.address
58
+ ? `${this.name}\n${this.address}`
59
+ : this.name || this.address || '';
59
60
  }
60
61
  }
61
62
 
62
- module.exports = Location;
63
+ module.exports = Location;