whatsapp-web-jf.js 1.31.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.
Files changed (55) hide show
  1. package/.env.example +3 -0
  2. package/CODE_OF_CONDUCT.md +133 -0
  3. package/LICENSE +201 -0
  4. package/README.md +185 -0
  5. package/example.js +680 -0
  6. package/index.d.ts +2069 -0
  7. package/index.js +34 -0
  8. package/package.json +55 -0
  9. package/shell.js +36 -0
  10. package/src/Client.js +2188 -0
  11. package/src/authStrategies/BaseAuthStrategy.js +27 -0
  12. package/src/authStrategies/LocalAuth.js +58 -0
  13. package/src/authStrategies/NoAuth.js +12 -0
  14. package/src/authStrategies/RemoteAuth.js +210 -0
  15. package/src/factories/ChatFactory.js +21 -0
  16. package/src/factories/ContactFactory.js +16 -0
  17. package/src/structures/Base.js +22 -0
  18. package/src/structures/Broadcast.js +69 -0
  19. package/src/structures/BusinessContact.js +21 -0
  20. package/src/structures/Buttons.js +82 -0
  21. package/src/structures/Call.js +76 -0
  22. package/src/structures/Channel.js +382 -0
  23. package/src/structures/Chat.js +291 -0
  24. package/src/structures/ClientInfo.js +71 -0
  25. package/src/structures/Contact.js +208 -0
  26. package/src/structures/GroupChat.js +473 -0
  27. package/src/structures/GroupNotification.js +104 -0
  28. package/src/structures/Label.js +50 -0
  29. package/src/structures/List.js +79 -0
  30. package/src/structures/Location.js +62 -0
  31. package/src/structures/Message.js +704 -0
  32. package/src/structures/MessageMedia.js +111 -0
  33. package/src/structures/Order.js +52 -0
  34. package/src/structures/Payment.js +79 -0
  35. package/src/structures/Poll.js +44 -0
  36. package/src/structures/PollVote.js +61 -0
  37. package/src/structures/PrivateChat.js +13 -0
  38. package/src/structures/PrivateContact.js +13 -0
  39. package/src/structures/Product.js +68 -0
  40. package/src/structures/ProductMetadata.js +25 -0
  41. package/src/structures/Reaction.js +69 -0
  42. package/src/structures/index.js +26 -0
  43. package/src/util/Constants.js +176 -0
  44. package/src/util/Injected/AuthStore/AuthStore.js +17 -0
  45. package/src/util/Injected/AuthStore/LegacyAuthStore.js +22 -0
  46. package/src/util/Injected/LegacyStore.js +146 -0
  47. package/src/util/Injected/Store.js +215 -0
  48. package/src/util/Injected/Utils.js +1139 -0
  49. package/src/util/InterfaceController.js +126 -0
  50. package/src/util/Puppeteer.js +23 -0
  51. package/src/util/Util.js +186 -0
  52. package/src/webCache/LocalWebCache.js +40 -0
  53. package/src/webCache/RemoteWebCache.js +40 -0
  54. package/src/webCache/WebCache.js +14 -0
  55. package/src/webCache/WebCacheFactory.js +20 -0
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ const Util = require('../util/Util');
4
+
5
+ /**
6
+ * Message type List
7
+ */
8
+ class List {
9
+ /**
10
+ * @param {string} body
11
+ * @param {string} buttonText
12
+ * @param {Array<any>} sections
13
+ * @param {string?} title
14
+ * @param {string?} footer
15
+ */
16
+ constructor(body, buttonText, sections, title, footer) {
17
+ /**
18
+ * Message body
19
+ * @type {string}
20
+ */
21
+ this.description = body;
22
+
23
+ /**
24
+ * List button text
25
+ * @type {string}
26
+ */
27
+ this.buttonText = buttonText;
28
+
29
+ /**
30
+ * title of message
31
+ * @type {string}
32
+ */
33
+ this.title = title;
34
+
35
+
36
+ /**
37
+ * footer of message
38
+ * @type {string}
39
+ */
40
+ this.footer = footer;
41
+
42
+ /**
43
+ * sections of message
44
+ * @type {Array<any>}
45
+ */
46
+ this.sections = this._format(sections);
47
+
48
+ }
49
+
50
+ /**
51
+ * Creates section array from simple array
52
+ * @param {Array<any>} sections
53
+ * @returns {Array<any>}
54
+ * @example
55
+ * Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
56
+ * Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
57
+ */
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';}
63
+ return {
64
+ title: section.title ? section.title : undefined,
65
+ rows: section.rows.map( (row) => {
66
+ if(!row.title){throw '[LT04] Row without title';}
67
+ return {
68
+ rowId: row.id ? row.id : Util.generateHash(6),
69
+ title: row.title,
70
+ description: row.description ? row.description : ''
71
+ };
72
+ })
73
+ };
74
+ });
75
+ }
76
+
77
+ }
78
+
79
+ module.exports = List;
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Location send options
5
+ * @typedef {Object} LocationSendOptions
6
+ * @property {string} [name] Location name
7
+ * @property {string} [address] Location address
8
+ * @property {string} [url] URL address to be shown within a location message
9
+ * @property {string} [description] Location full description
10
+ */
11
+
12
+ /**
13
+ * Location information
14
+ */
15
+ class Location {
16
+ /**
17
+ * @param {number} latitude
18
+ * @param {number} longitude
19
+ * @param {LocationSendOptions} [options] Location send options
20
+ */
21
+ constructor(latitude, longitude, options = {}) {
22
+ /**
23
+ * Location latitude
24
+ * @type {number}
25
+ */
26
+ this.latitude = latitude;
27
+
28
+ /**
29
+ * Location longitude
30
+ * @type {number}
31
+ */
32
+ this.longitude = longitude;
33
+
34
+ /**
35
+ * Name for the location
36
+ * @type {string|undefined}
37
+ */
38
+ this.name = options.name;
39
+
40
+ /**
41
+ * Location address
42
+ * @type {string|undefined}
43
+ */
44
+ this.address = options.address;
45
+
46
+ /**
47
+ * URL address to be shown within a location message
48
+ * @type {string|undefined}
49
+ */
50
+ this.url = options.url;
51
+
52
+ /**
53
+ * Location full description
54
+ * @type {string|undefined}
55
+ */
56
+ this.description = this.name && this.address
57
+ ? `${this.name}\n${this.address}`
58
+ : this.name || this.address || '';
59
+ }
60
+ }
61
+
62
+ module.exports = Location;