@areumtecnologia/wasockets 2.0.0 → 2.3.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 (75) hide show
  1. package/README.md +1987 -1649
  2. package/lib/Client/Builders/Buttons.js +127 -0
  3. package/lib/Client/Builders/EventBuilder.js +122 -0
  4. package/lib/Client/Builders/InteractiveMessage.js +150 -0
  5. package/lib/Client/Builders/Lists.js +78 -0
  6. package/lib/Client/Builders/PollBuilder.js +84 -0
  7. package/lib/Client/Builders/index.js +21 -0
  8. package/lib/Client/Constants.js +54 -0
  9. package/lib/Client/Context/CallContext.js +96 -0
  10. package/lib/Client/Context/MediaObject.js +155 -0
  11. package/lib/Client/Context/MessageContext.js +146 -0
  12. package/lib/Client/Modules/BusinessManager.js +155 -0
  13. package/lib/Client/Modules/ChannelManager.js +144 -0
  14. package/lib/Client/Modules/ChatManager.js +113 -0
  15. package/lib/Client/Modules/CommunityManager.js +136 -0
  16. package/lib/Client/Modules/GroupManager.js +194 -0
  17. package/lib/Client/Modules/LabelManager.js +123 -0
  18. package/lib/Client/Modules/MessageManager.js +198 -0
  19. package/lib/Client/Modules/PresenceManager.js +68 -0
  20. package/lib/Client/Modules/PrivacyManager.js +98 -0
  21. package/lib/Client/Modules/ProfileManager.js +92 -0
  22. package/lib/Client/Modules/UserManager.js +92 -0
  23. package/lib/Client/Modules/VoipManager.js +117 -0
  24. package/lib/Client/Modules/index.js +29 -0
  25. package/lib/Client/Normalizers/EventNormalizer.js +82 -0
  26. package/lib/Client/Normalizers/JidNormalizer.js +93 -0
  27. package/lib/Client/Normalizers/MessageNormalizer.js +134 -0
  28. package/lib/Client/WaClient.js +438 -0
  29. package/lib/Client/index.d.ts +464 -0
  30. package/lib/Client/index.js +76 -0
  31. package/lib/Defaults/baileys-version.json +1 -1
  32. package/lib/Defaults/connection.js +14 -1
  33. package/lib/Socket/index.js +51 -48
  34. package/lib/Socket/messages-recv.js +74 -13
  35. package/lib/Socket/messages-send.js +50 -25
  36. package/lib/Socket/socket.js +13 -0
  37. package/lib/Socket/voip.js +123 -0
  38. package/lib/Store/make-cache-manager-store.js +14 -5
  39. package/lib/Types/index.d.ts +4 -0
  40. package/lib/Utils/auth-utils.js +16 -1
  41. package/lib/Utils/browser-utils.js +6 -2
  42. package/lib/Utils/generics.js +47 -8
  43. package/lib/Utils/index.d.ts +1 -0
  44. package/lib/Utils/messages-media.js +44 -21
  45. package/lib/Utils/pre-key-manager.js +16 -1
  46. package/lib/Utils/validate-connection.js +10 -11
  47. package/lib/VoIP/VoIPCrypto.js +150 -0
  48. package/lib/VoIP/VoIPManager.js +469 -0
  49. package/lib/VoIP/VoIPMediaEngine.js +224 -0
  50. package/lib/VoIP/VoIPProtocol.js +354 -0
  51. package/lib/VoIP/VoIPRelayTransport.js +173 -0
  52. package/lib/VoIP/VoIPSession.js +314 -0
  53. package/lib/VoIP/assets/wasm/loader.js +5 -0
  54. package/lib/VoIP/assets/wasm/whatsapp.wasm +0 -0
  55. package/lib/VoIP/assets/wasm/worker-modules.js +305 -0
  56. package/lib/VoIP/engine/audio-feeder.d.mts +15 -0
  57. package/lib/VoIP/engine/audio-feeder.mjs +243 -0
  58. package/lib/VoIP/engine/index.d.mts +91 -0
  59. package/lib/VoIP/engine/index.mjs +1683 -0
  60. package/lib/VoIP/engine/relay-transport.d.mts +43 -0
  61. package/lib/VoIP/engine/relay-transport.mjs +607 -0
  62. package/lib/VoIP/engine/signaling.d.mts +44 -0
  63. package/lib/VoIP/engine/signaling.mjs +893 -0
  64. package/lib/VoIP/engine/types.d.mts +183 -0
  65. package/lib/VoIP/engine/types.mjs +17 -0
  66. package/lib/VoIP/engine/wasm-engine.d.mts +103 -0
  67. package/lib/VoIP/engine/wasm-engine.mjs +1397 -0
  68. package/lib/VoIP/engine/worker-bootstrap.mjs +1049 -0
  69. package/lib/VoIP/index.js +51 -0
  70. package/lib/VoIP/utils/audio.d.ts +28 -0
  71. package/lib/VoIP/utils/audio.js +148 -0
  72. package/lib/WABinary/generic-utils.js +22 -6
  73. package/lib/index.d.ts +382 -274
  74. package/lib/index.js +5 -0
  75. package/package.json +51 -49
@@ -0,0 +1,113 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class ChatManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Fixa a conversa no topo
24
+ * @param {string} jid
25
+ */
26
+ async pin(jid) {
27
+ const sock = this._getSock()
28
+ const targetJid = JidNormalizer.toJid(jid)
29
+ return sock.chatModify({ pin: true }, targetJid)
30
+ }
31
+
32
+ /**
33
+ * Desafixa a conversa do topo
34
+ * @param {string} jid
35
+ */
36
+ async unpin(jid) {
37
+ const sock = this._getSock()
38
+ const targetJid = JidNormalizer.toJid(jid)
39
+ return sock.chatModify({ pin: false }, targetJid)
40
+ }
41
+
42
+ /**
43
+ * Silencia notificações do chat
44
+ * @param {string} jid
45
+ * @param {number} [durationMs=86400000] - Duração em ms (padrão: 24h, null para permanente)
46
+ */
47
+ async mute(jid, durationMs = 86400000) {
48
+ const sock = this._getSock()
49
+ const targetJid = JidNormalizer.toJid(jid)
50
+ return sock.chatModify({ mute: durationMs }, targetJid)
51
+ }
52
+
53
+ /**
54
+ * Reativa o som do chat
55
+ * @param {string} jid
56
+ */
57
+ async unmute(jid) {
58
+ const sock = this._getSock()
59
+ const targetJid = JidNormalizer.toJid(jid)
60
+ return sock.chatModify({ mute: null }, targetJid)
61
+ }
62
+
63
+ /**
64
+ * Arquiva uma conversa
65
+ * @param {string} jid
66
+ */
67
+ async archive(jid) {
68
+ const sock = this._getSock()
69
+ const targetJid = JidNormalizer.toJid(jid)
70
+ return sock.chatModify({ archive: true }, targetJid)
71
+ }
72
+
73
+ /**
74
+ * Desarquiva uma conversa
75
+ * @param {string} jid
76
+ */
77
+ async unarchive(jid) {
78
+ const sock = this._getSock()
79
+ const targetJid = JidNormalizer.toJid(jid)
80
+ return sock.chatModify({ archive: false }, targetJid)
81
+ }
82
+
83
+ /**
84
+ * Marca ou desmarca o chat como favorito
85
+ * @param {string} jid
86
+ * @param {boolean} [isFavorite=true]
87
+ */
88
+ async setFavorite(jid, isFavorite = true) {
89
+ const sock = this._getSock()
90
+ const targetJid = JidNormalizer.toJid(jid)
91
+ if (!sock.updateFavorite) {
92
+ throw new Error('updateFavorite indisponível no socket.')
93
+ }
94
+ return sock.updateFavorite(targetJid, isFavorite)
95
+ }
96
+
97
+ /**
98
+ * Salva uma anotação interna no contato (recurso exclusivo WaSockets)
99
+ * @param {string} jid
100
+ * @param {string} note
101
+ */
102
+ async setChatNote(jid, note) {
103
+ const sock = this._getSock()
104
+ const targetJid = JidNormalizer.toJid(jid)
105
+ if (!sock.updateChatNote) {
106
+ throw new Error('updateChatNote indisponível no socket.')
107
+ }
108
+ return sock.updateChatNote(targetJid, note)
109
+ }
110
+ }
111
+
112
+ exports.ChatManager = ChatManager
113
+ exports.default = ChatManager
@@ -0,0 +1,136 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class CommunityManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Cria uma nova comunidade (grupo pai de avisos)
24
+ * @param {string} subject - Nome da comunidade
25
+ * @param {string} [description=''] - Descrição da comunidade
26
+ */
27
+ async create(subject, description = '') {
28
+ const sock = this._getSock()
29
+ if (!sock.communityCreate) {
30
+ throw new Error('communityCreate indisponível no socket.')
31
+ }
32
+ return sock.communityCreate(subject, description)
33
+ }
34
+
35
+ /**
36
+ * Obtém metadados da comunidade
37
+ * @param {string} communityJid
38
+ */
39
+ async getMetadata(communityJid) {
40
+ const sock = this._getSock()
41
+ const targetJid = JidNormalizer.toJid(communityJid)
42
+ if (!sock.communityMetadata) {
43
+ throw new Error('communityMetadata indisponível no socket.')
44
+ }
45
+ return sock.communityMetadata(targetJid)
46
+ }
47
+
48
+ /**
49
+ * Cria um novo subgrupo já vinculado à comunidade
50
+ * @param {string} communityJid
51
+ * @param {string} subject - Nome do subgrupo
52
+ * @param {string[]} [participants=[]]
53
+ */
54
+ async createSubgroup(communityJid, subject, participants = []) {
55
+ const sock = this._getSock()
56
+ const targetJid = JidNormalizer.toJid(communityJid)
57
+ const jids = participants.map(JidNormalizer.toJid)
58
+ if (!sock.communityCreateGroup) {
59
+ throw new Error('communityCreateGroup indisponível no socket.')
60
+ }
61
+ return sock.communityCreateGroup(subject, jids, targetJid)
62
+ }
63
+
64
+ /**
65
+ * Vincula um grupo existente à comunidade
66
+ * @param {string} communityJid
67
+ * @param {string} groupJid
68
+ */
69
+ async linkSubgroup(communityJid, groupJid) {
70
+ const sock = this._getSock()
71
+ const parentJid = JidNormalizer.toJid(communityJid)
72
+ const childJid = JidNormalizer.toJid(groupJid)
73
+ if (!sock.communityLinkGroup) {
74
+ throw new Error('communityLinkGroup indisponível no socket.')
75
+ }
76
+ return sock.communityLinkGroup(childJid, parentJid)
77
+ }
78
+
79
+ /**
80
+ * Desvincula um subgrupo da comunidade
81
+ * @param {string} communityJid
82
+ * @param {string} groupJid
83
+ */
84
+ async unlinkSubgroup(communityJid, groupJid) {
85
+ const sock = this._getSock()
86
+ const parentJid = JidNormalizer.toJid(communityJid)
87
+ const childJid = JidNormalizer.toJid(groupJid)
88
+ if (!sock.communityUnlinkGroup) {
89
+ throw new Error('communityUnlinkGroup indisponível no socket.')
90
+ }
91
+ return sock.communityUnlinkGroup(childJid, parentJid)
92
+ }
93
+
94
+ /**
95
+ * Retorna a lista de subgrupos vinculados à comunidade
96
+ * @param {string} communityJid
97
+ */
98
+ async getSubgroups(communityJid) {
99
+ const sock = this._getSock()
100
+ const targetJid = JidNormalizer.toJid(communityJid)
101
+ if (!sock.communityFetchLinkedGroups) {
102
+ throw new Error('communityFetchLinkedGroups indisponível no socket.')
103
+ }
104
+ return sock.communityFetchLinkedGroups(targetJid)
105
+ }
106
+
107
+ /**
108
+ * Sai da comunidade
109
+ * @param {string} communityJid
110
+ */
111
+ async leave(communityJid) {
112
+ const sock = this._getSock()
113
+ const targetJid = JidNormalizer.toJid(communityJid)
114
+ if (!sock.communityLeave) {
115
+ throw new Error('communityLeave indisponível no socket.')
116
+ }
117
+ return sock.communityLeave(targetJid)
118
+ }
119
+
120
+ /**
121
+ * Altera o nome da comunidade
122
+ * @param {string} communityJid
123
+ * @param {string} subject
124
+ */
125
+ async setName(communityJid, subject) {
126
+ const sock = this._getSock()
127
+ const targetJid = JidNormalizer.toJid(communityJid)
128
+ if (!sock.communityUpdateSubject) {
129
+ throw new Error('communityUpdateSubject indisponível no socket.')
130
+ }
131
+ return sock.communityUpdateSubject(targetJid, subject)
132
+ }
133
+ }
134
+
135
+ exports.CommunityManager = CommunityManager
136
+ exports.default = CommunityManager
@@ -0,0 +1,194 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class GroupManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Cria um novo grupo
24
+ * @param {string} subject - Nome do grupo
25
+ * @param {string[]} participants - Lista de telefones ou JIDs
26
+ */
27
+ async create(subject, participants = []) {
28
+ const sock = this._getSock()
29
+ const jids = participants.map(JidNormalizer.toJid)
30
+ return sock.groupCreate(subject, jids)
31
+ }
32
+
33
+ /**
34
+ * Retorna os metadados do grupo (usa cache em memória quando disponível)
35
+ * @param {string} groupJid
36
+ */
37
+ async getMetadata(groupJid) {
38
+ const sock = this._getSock()
39
+ const targetJid = JidNormalizer.toJid(groupJid)
40
+ return sock.groupMetadata(targetJid)
41
+ }
42
+
43
+ /**
44
+ * Adiciona participantes ao grupo
45
+ * @param {string} groupJid
46
+ * @param {string[]} participants
47
+ */
48
+ async addMembers(groupJid, participants = []) {
49
+ const sock = this._getSock()
50
+ const targetJid = JidNormalizer.toJid(groupJid)
51
+ const jids = participants.map(JidNormalizer.toJid)
52
+ return sock.groupParticipantsUpdate(targetJid, jids, 'add')
53
+ }
54
+
55
+ /**
56
+ * Remove participantes do grupo
57
+ * @param {string} groupJid
58
+ * @param {string[]} participants
59
+ */
60
+ async removeMembers(groupJid, participants = []) {
61
+ const sock = this._getSock()
62
+ const targetJid = JidNormalizer.toJid(groupJid)
63
+ const jids = participants.map(JidNormalizer.toJid)
64
+ return sock.groupParticipantsUpdate(targetJid, jids, 'remove')
65
+ }
66
+
67
+ /**
68
+ * Promove membros a administradores do grupo
69
+ * @param {string} groupJid
70
+ * @param {string[]} participants
71
+ */
72
+ async promote(groupJid, participants = []) {
73
+ const sock = this._getSock()
74
+ const targetJid = JidNormalizer.toJid(groupJid)
75
+ const jids = participants.map(JidNormalizer.toJid)
76
+ return sock.groupParticipantsUpdate(targetJid, jids, 'promote')
77
+ }
78
+
79
+ /**
80
+ * Rebaixa administradores a membros normais
81
+ * @param {string} groupJid
82
+ * @param {string[]} participants
83
+ */
84
+ async demote(groupJid, participants = []) {
85
+ const sock = this._getSock()
86
+ const targetJid = JidNormalizer.toJid(groupJid)
87
+ const jids = participants.map(JidNormalizer.toJid)
88
+ return sock.groupParticipantsUpdate(targetJid, jids, 'demote')
89
+ }
90
+
91
+ /**
92
+ * Obtém o código de convite do grupo
93
+ * @param {string} groupJid
94
+ * @returns {Promise<string>} Código de convite
95
+ */
96
+ async getInviteCode(groupJid) {
97
+ const sock = this._getSock()
98
+ const targetJid = JidNormalizer.toJid(groupJid)
99
+ return sock.groupInviteCode(targetJid)
100
+ }
101
+
102
+ /**
103
+ * Revoga o código de convite atual e gera um novo
104
+ * @param {string} groupJid
105
+ * @returns {Promise<string>} Novo código
106
+ */
107
+ async revokeInviteCode(groupJid) {
108
+ const sock = this._getSock()
109
+ const targetJid = JidNormalizer.toJid(groupJid)
110
+ return sock.groupRevokeInvite(targetJid)
111
+ }
112
+
113
+ /**
114
+ * Entra em um grupo através de um código de convite
115
+ * @param {string} inviteCode
116
+ * @returns {Promise<string>} JID do grupo
117
+ */
118
+ async joinWithCode(inviteCode) {
119
+ const sock = this._getSock()
120
+ const cleanCode = inviteCode.replace('https://chat.whatsapp.com/', '').trim()
121
+ return sock.groupAcceptInvite(cleanCode)
122
+ }
123
+
124
+ /**
125
+ * Altera o assunto/nome do grupo
126
+ * @param {string} groupJid
127
+ * @param {string} subject
128
+ */
129
+ async setSubject(groupJid, subject) {
130
+ const sock = this._getSock()
131
+ const targetJid = JidNormalizer.toJid(groupJid)
132
+ return sock.groupUpdateSubject(targetJid, subject)
133
+ }
134
+
135
+ /**
136
+ * Altera a descrição do grupo
137
+ * @param {string} groupJid
138
+ * @param {string} description
139
+ */
140
+ async setDescription(groupJid, description) {
141
+ const sock = this._getSock()
142
+ const targetJid = JidNormalizer.toJid(groupJid)
143
+ return sock.groupUpdateDescription(targetJid, description)
144
+ }
145
+
146
+ /**
147
+ * Define se apenas administradores podem enviar mensagens
148
+ * @param {string} groupJid
149
+ * @param {boolean} announceOnly
150
+ */
151
+ async setAnnounceOnly(groupJid, announceOnly = true) {
152
+ const sock = this._getSock()
153
+ const targetJid = JidNormalizer.toJid(groupJid)
154
+ return sock.groupSettingUpdate(targetJid, announceOnly ? 'announcement' : 'not_announcement')
155
+ }
156
+
157
+ /**
158
+ * Define se apenas administradores podem alterar as configurações do grupo
159
+ * @param {string} groupJid
160
+ * @param {boolean} locked
161
+ */
162
+ async setLocked(groupJid, locked = true) {
163
+ const sock = this._getSock()
164
+ const targetJid = JidNormalizer.toJid(groupJid)
165
+ return sock.groupSettingUpdate(targetJid, locked ? 'locked' : 'unlocked')
166
+ }
167
+
168
+ /**
169
+ * Menciona todos os membros do grupo em uma mensagem
170
+ * @param {string} groupJid
171
+ * @param {string|Object} textOrContent
172
+ * @param {Object} [options={}]
173
+ */
174
+ async mentionAll(groupJid, textOrContent, options = {}) {
175
+ const sock = this._getSock()
176
+ const targetJid = JidNormalizer.toJid(groupJid)
177
+ const content = typeof textOrContent === 'string' ? { text: textOrContent } : textOrContent
178
+
179
+ if (sock.groupSendMentionAll) {
180
+ return sock.groupSendMentionAll(targetJid, content, options)
181
+ }
182
+
183
+ // Fallback: busca participantes e anexa em mentions
184
+ const meta = await this.getMetadata(targetJid)
185
+ const participants = (meta.participants || []).map(p => p.id)
186
+ return this.client.sendMessage(targetJid, {
187
+ ...content,
188
+ mentions: participants
189
+ }, options)
190
+ }
191
+ }
192
+
193
+ exports.GroupManager = GroupManager
194
+ exports.default = GroupManager
@@ -0,0 +1,123 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class LabelManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Cria uma nova etiqueta no WhatsApp Business
24
+ * @param {string} name - Nome da etiqueta
25
+ * @param {number} color - Índice numérico da cor (0 a 19)
26
+ * @param {number} [predefinedId=0]
27
+ */
28
+ async create(name, color = 0, predefinedId = 0) {
29
+ const sock = this._getSock()
30
+ if (!sock.createLabel) {
31
+ throw new Error('createLabel indisponível no socket.')
32
+ }
33
+ return sock.createLabel(name, color, predefinedId)
34
+ }
35
+
36
+ /**
37
+ * Atualiza dados de uma etiqueta existente
38
+ * @param {string} id
39
+ * @param {string} name
40
+ * @param {number} color
41
+ * @param {number} [predefinedId=0]
42
+ */
43
+ async update(id, name, color = 0, predefinedId = 0) {
44
+ const sock = this._getSock()
45
+ if (!sock.updateLabel) {
46
+ throw new Error('updateLabel indisponível no socket.')
47
+ }
48
+ return sock.updateLabel(id, name, color, predefinedId)
49
+ }
50
+
51
+ /**
52
+ * Remove uma etiqueta
53
+ * @param {string} id
54
+ */
55
+ async delete(id) {
56
+ const sock = this._getSock()
57
+ if (!sock.deleteLabel) {
58
+ throw new Error('deleteLabel indisponível no socket.')
59
+ }
60
+ return sock.deleteLabel(id)
61
+ }
62
+
63
+ /**
64
+ * Associa uma etiqueta a uma conversa
65
+ * @param {string} jid
66
+ * @param {string} labelId
67
+ */
68
+ async addChat(jid, labelId) {
69
+ const sock = this._getSock()
70
+ const targetJid = JidNormalizer.toJid(jid)
71
+ if (!sock.addChatLabel) {
72
+ throw new Error('addChatLabel indisponível no socket.')
73
+ }
74
+ return sock.addChatLabel(targetJid, labelId)
75
+ }
76
+
77
+ /**
78
+ * Remove uma etiqueta de uma conversa
79
+ * @param {string} jid
80
+ * @param {string} labelId
81
+ */
82
+ async removeChat(jid, labelId) {
83
+ const sock = this._getSock()
84
+ const targetJid = JidNormalizer.toJid(jid)
85
+ if (!sock.removeChatLabel) {
86
+ throw new Error('removeChatLabel indisponível no socket.')
87
+ }
88
+ return sock.removeChatLabel(targetJid, labelId)
89
+ }
90
+
91
+ /**
92
+ * Associa uma etiqueta a uma mensagem específica
93
+ * @param {string} jid
94
+ * @param {string} messageId
95
+ * @param {string} labelId
96
+ */
97
+ async addMessage(jid, messageId, labelId) {
98
+ const sock = this._getSock()
99
+ const targetJid = JidNormalizer.toJid(jid)
100
+ if (!sock.addMessageLabel) {
101
+ throw new Error('addMessageLabel indisponível no socket.')
102
+ }
103
+ return sock.addMessageLabel(targetJid, messageId, labelId)
104
+ }
105
+
106
+ /**
107
+ * Remove uma etiqueta de uma mensagem
108
+ * @param {string} jid
109
+ * @param {string} messageId
110
+ * @param {string} labelId
111
+ */
112
+ async removeMessage(jid, messageId, labelId) {
113
+ const sock = this._getSock()
114
+ const targetJid = JidNormalizer.toJid(jid)
115
+ if (!sock.removeMessageLabel) {
116
+ throw new Error('removeMessageLabel indisponível no socket.')
117
+ }
118
+ return sock.removeMessageLabel(targetJid, messageId, labelId)
119
+ }
120
+ }
121
+
122
+ exports.LabelManager = LabelManager
123
+ exports.default = LabelManager