@areumtecnologia/wasockets 2.2.3 → 2.3.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 (31) hide show
  1. package/README.md +98 -25
  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 +213 -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 +99 -0
  26. package/lib/Client/Normalizers/JidNormalizer.js +96 -0
  27. package/lib/Client/Normalizers/MessageNormalizer.js +422 -0
  28. package/lib/Client/WaClient.js +438 -0
  29. package/lib/Client/index.d.ts +547 -0
  30. package/lib/Client/index.js +76 -0
  31. package/package.json +29 -23
@@ -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
@@ -0,0 +1,198 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class MessageManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ /**
16
+ * Envia mensagem de texto com suporte a menções
17
+ * @param {string} jid
18
+ * @param {string} text
19
+ * @param {Object} [options={}]
20
+ */
21
+ async sendText(jid, text, options = {}) {
22
+ const payload = {
23
+ text: text || '',
24
+ ...(options.mentions ? { mentions: options.mentions.map(JidNormalizer.toJid) } : {})
25
+ }
26
+ return this.client.sendMessage(jid, payload, options)
27
+ }
28
+
29
+ /**
30
+ * Envia arquivo de mídia (imagem, vídeo, áudio, documento ou figurinha)
31
+ * @param {string} jid
32
+ * @param {'image'|'video'|'audio'|'document'|'sticker'} type
33
+ * @param {string|Buffer|Object} content - Caminho, URL ou Buffer
34
+ * @param {Object} [options={}]
35
+ */
36
+ async sendMedia(jid, type, content, options = {}) {
37
+ const mediaPayload = typeof content === 'string' ? { url: content } : content
38
+ const payload = {
39
+ [type]: mediaPayload,
40
+ ...(options.caption ? { caption: options.caption } : {}),
41
+ ...(options.fileName ? { fileName: options.fileName } : {}),
42
+ ...(options.mimetype ? { mimetype: options.mimetype } : {}),
43
+ ...(options.viewOnce ? { viewOnce: true } : {})
44
+ }
45
+ return this.client.sendMessage(jid, payload, options)
46
+ }
47
+
48
+ /**
49
+ * Envia um álbum de fotos ou vídeos agrupados nativamente
50
+ * @param {string} jid
51
+ * @param {Array<Object>} items
52
+ * @param {Object} [options={}]
53
+ */
54
+ async sendAlbum(jid, items = [], options = {}) {
55
+ const targetJid = JidNormalizer.toJid(jid)
56
+ if (this.client.sock?.sendAlbumMessage) {
57
+ return this.client.sock.sendAlbumMessage(targetJid, items, options)
58
+ }
59
+ return this.client.sendMessage(targetJid, { album: items }, options)
60
+ }
61
+
62
+ /**
63
+ * Envia áudio simulando gravação de voz (PTT / Voice Note)
64
+ * @param {string} jid
65
+ * @param {string|Buffer|Object} audioSource
66
+ * @param {Object} [options={}]
67
+ */
68
+ async sendVoice(jid, audioSource, options = {}) {
69
+ const payload = {
70
+ audio: typeof audioSource === 'string' ? { url: audioSource } : audioSource,
71
+ mimetype: 'audio/mp4',
72
+ ptt: true,
73
+ ...(options.waveform ? { waveform: options.waveform } : {})
74
+ }
75
+ return this.client.sendMessage(jid, payload, options)
76
+ }
77
+
78
+ /**
79
+ * Envia um contato com cartão vCard
80
+ * @param {string} jid
81
+ * @param {string} name
82
+ * @param {string} phoneNumber
83
+ * @param {Object} [options={}]
84
+ */
85
+ async sendContact(jid, name, phoneNumber, options = {}) {
86
+ const cleanPhone = JidNormalizer.toPhoneNumber(phoneNumber)
87
+ const vcard = 'BEGIN:VCARD\n'
88
+ + 'VERSION:3.0\n'
89
+ + `FN:${name}\n`
90
+ + `ORG:${options.org || name};\n`
91
+ + `TEL;type=CELL;type=VOICE;waid=${cleanPhone}:+${cleanPhone}\n`
92
+ + 'END:VCARD'
93
+
94
+ const payload = {
95
+ contacts: {
96
+ displayName: name,
97
+ contacts: [{ vcard }]
98
+ }
99
+ }
100
+ return this.client.sendMessage(jid, payload, options)
101
+ }
102
+
103
+ /**
104
+ * Envia localização fixa ou ao vivo
105
+ * @param {string} jid
106
+ * @param {{ latitude: number, longitude: number, name?: string, address?: string, live?: boolean }} coords
107
+ * @param {Object} [options={}]
108
+ */
109
+ async sendLocation(jid, coords, options = {}) {
110
+ const payload = {
111
+ location: {
112
+ degreesLatitude: coords.latitude,
113
+ degreesLongitude: coords.longitude,
114
+ ...(coords.name ? { name: coords.name } : {}),
115
+ ...(coords.address ? { address: coords.address } : {})
116
+ },
117
+ ...(coords.live ? { live: true } : {})
118
+ }
119
+ return this.client.sendMessage(jid, payload, options)
120
+ }
121
+
122
+ /**
123
+ * Encaminha uma mensagem existente para outro destinatário
124
+ * @param {string} targetJid
125
+ * @param {Object} message - Objeto raw da mensagem
126
+ * @param {Object} [options={}]
127
+ */
128
+ async forward(targetJid, message, options = {}) {
129
+ return this.client.sendMessage(targetJid, { forward: message }, options)
130
+ }
131
+
132
+ /**
133
+ * Apaga uma mensagem para todos no chat
134
+ * @param {string} jid
135
+ * @param {Object} messageKey - { remoteJid, id, fromMe }
136
+ */
137
+ async delete(jid, messageKey) {
138
+ return this.client.sendMessage(jid, { delete: messageKey })
139
+ }
140
+
141
+ /**
142
+ * Edita uma mensagem de texto já enviada pelo próprio bot
143
+ * @param {string} jid
144
+ * @param {Object} messageKey
145
+ * @param {string} newText
146
+ */
147
+ async edit(jid, messageKey, newText) {
148
+ return this.client.sendMessage(jid, {
149
+ edit: messageKey,
150
+ text: newText
151
+ })
152
+ }
153
+
154
+ /**
155
+ * Fixa uma mensagem no topo da conversa
156
+ * @param {string} jid
157
+ * @param {Object} messageKey
158
+ * @param {number} [durationSeconds=86400]
159
+ */
160
+ async pin(jid, messageKey, durationSeconds = 86400) {
161
+ if (!this.client.sock?.pinInChatMessage) {
162
+ throw new Error('Método pinInChatMessage indisponível no socket.')
163
+ }
164
+ const targetJid = JidNormalizer.toJid(jid)
165
+ return this.client.sock.pinInChatMessage(targetJid, messageKey, 1, durationSeconds)
166
+ }
167
+
168
+ /**
169
+ * Desafixa mensagem do topo da conversa
170
+ * @param {string} jid
171
+ * @param {Object} messageKey
172
+ */
173
+ async unpin(jid, messageKey) {
174
+ if (!this.client.sock?.pinInChatMessage) {
175
+ throw new Error('Método pinInChatMessage indisponível no socket.')
176
+ }
177
+ const targetJid = JidNormalizer.toJid(jid)
178
+ return this.client.sock.pinInChatMessage(targetJid, messageKey, 2)
179
+ }
180
+
181
+ /**
182
+ * Reage com emoji a uma mensagem
183
+ * @param {string} jid
184
+ * @param {Object} messageKey
185
+ * @param {string} emoji
186
+ */
187
+ async react(jid, messageKey, emoji) {
188
+ return this.client.sendMessage(jid, {
189
+ react: {
190
+ text: emoji || '',
191
+ key: messageKey
192
+ }
193
+ })
194
+ }
195
+ }
196
+
197
+ exports.MessageManager = MessageManager
198
+ exports.default = MessageManager
@@ -0,0 +1,68 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class PresenceManager {
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
+ * Inicia estado 'digitando' com retorno de objeto cancelador
24
+ * @param {string} jid
25
+ * @returns {{ stop: () => Promise<void> }}
26
+ */
27
+ startTyping(jid) {
28
+ return this.client.startTyping(jid)
29
+ }
30
+
31
+ /**
32
+ * Inicia simulação de gravação de áudio com cancelador
33
+ * @param {string} jid
34
+ * @returns {{ stop: () => Promise<void> }}
35
+ */
36
+ startRecording(jid) {
37
+ return this.client.startRecording(jid)
38
+ }
39
+
40
+ /**
41
+ * Define a presença da conta como online/disponível
42
+ */
43
+ async setOnline() {
44
+ const sock = this._getSock()
45
+ return sock.sendPresenceUpdate('available')
46
+ }
47
+
48
+ /**
49
+ * Define a presença da conta como offline/indisponível
50
+ */
51
+ async setOffline() {
52
+ const sock = this._getSock()
53
+ return sock.sendPresenceUpdate('unavailable')
54
+ }
55
+
56
+ /**
57
+ * Assina atualizações de presença em tempo real de um contato
58
+ * @param {string} jid
59
+ */
60
+ async subscribe(jid) {
61
+ const sock = this._getSock()
62
+ const targetJid = JidNormalizer.toJid(jid)
63
+ return sock.presenceSubscribe(targetJid)
64
+ }
65
+ }
66
+
67
+ exports.PresenceManager = PresenceManager
68
+ exports.default = PresenceManager
@@ -0,0 +1,98 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class PrivacyManager {
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
+ * Bloqueia um contato
24
+ * @param {string} jid
25
+ */
26
+ async block(jid) {
27
+ const sock = this._getSock()
28
+ const targetJid = JidNormalizer.toJid(jid)
29
+ return sock.updateBlockStatus(targetJid, 'block')
30
+ }
31
+
32
+ /**
33
+ * Desbloqueia um contato
34
+ * @param {string} jid
35
+ */
36
+ async unblock(jid) {
37
+ const sock = this._getSock()
38
+ const targetJid = JidNormalizer.toJid(jid)
39
+ return sock.updateBlockStatus(targetJid, 'unblock')
40
+ }
41
+
42
+ /**
43
+ * Retorna a lista de todos os JIDs bloqueados
44
+ * @returns {Promise<string[]>}
45
+ */
46
+ async getBlocklist() {
47
+ const sock = this._getSock()
48
+ return sock.fetchBlocklist()
49
+ }
50
+
51
+ /**
52
+ * Configura privacidade de Visto por Último
53
+ * @param {'all'|'contacts'|'contact_blacklist'|'none'} privacy
54
+ */
55
+ async setLastSeen(privacy) {
56
+ const sock = this._getSock()
57
+ return sock.updateLastSeenPrivacy(privacy)
58
+ }
59
+
60
+ /**
61
+ * Configura privacidade de Online
62
+ * @param {'all'|'match_last_seen'} privacy
63
+ */
64
+ async setOnline(privacy) {
65
+ const sock = this._getSock()
66
+ return sock.updateOnlinePrivacy(privacy)
67
+ }
68
+
69
+ /**
70
+ * Configura privacidade da Foto de Perfil
71
+ * @param {'all'|'contacts'|'contact_blacklist'|'none'} privacy
72
+ */
73
+ async setProfilePicture(privacy) {
74
+ const sock = this._getSock()
75
+ return sock.updateProfilePicturePrivacy(privacy)
76
+ }
77
+
78
+ /**
79
+ * Configura privacidade do Recado/Status
80
+ * @param {'all'|'contacts'|'contact_blacklist'|'none'} privacy
81
+ */
82
+ async setAbout(privacy) {
83
+ const sock = this._getSock()
84
+ return sock.updateStatusPrivacy(privacy)
85
+ }
86
+
87
+ /**
88
+ * Ativa ou desativa confirmações de leitura (ticks azuis)
89
+ * @param {boolean} enabled
90
+ */
91
+ async setReadReceipts(enabled) {
92
+ const sock = this._getSock()
93
+ return sock.updateReadReceiptsPrivacy(enabled ? 'all' : 'none')
94
+ }
95
+ }
96
+
97
+ exports.PrivacyManager = PrivacyManager
98
+ exports.default = PrivacyManager