@neelegirly/baileys 2.2.17 → 2.2.19
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.
- package/README.md +109 -27
- package/lib/Socket/business.d.ts +6 -1
- package/lib/Socket/chats.d.ts +6 -1
- package/lib/Socket/chats.js +121 -28
- package/lib/Socket/communities.d.ts +5 -0
- package/lib/Socket/groups.d.ts +6 -1
- package/lib/Socket/groups.js +15 -1
- package/lib/Socket/index.d.ts +6 -1
- package/lib/Socket/messages-recv.d.ts +5 -0
- package/lib/Socket/messages-recv.js +26 -8
- package/lib/Socket/messages-send.d.ts +6 -1
- package/lib/Socket/newsletter.d.ts +6 -1
- package/lib/Socket/registration.d.ts +5 -0
- package/lib/Socket/socket.js +55 -29
- package/lib/Types/Call.d.ts +3 -2
- package/lib/Types/Contact.d.ts +3 -1
- package/lib/Types/Events.d.ts +14 -1
- package/lib/Types/GroupMetadata.d.ts +9 -1
- package/lib/Types/Message.d.ts +21 -3
- package/lib/Types/Signal.d.ts +17 -1
- package/lib/Utils/branding.js +47 -3
- package/lib/Utils/chat-utils.d.ts +21 -1
- package/lib/Utils/chat-utils.js +27 -8
- package/lib/Utils/decode-wa-message.js +5 -1
- package/lib/Utils/event-buffer.js +3 -1
- package/lib/Utils/generics.js +9 -0
- package/lib/Utils/history.js +10 -11
- package/lib/Utils/messages-media.js +2 -2
- package/lib/Utils/messages.js +19 -2
- package/lib/Utils/process-message.js +5 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +27 -4
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +31 -0
- package/lib/WAUSync/Protocols/index.d.ts +2 -1
- package/lib/WAUSync/Protocols/index.js +2 -1
- package/lib/WAUSync/USyncQuery.d.ts +2 -1
- package/lib/WAUSync/USyncQuery.js +5 -1
- package/lib/WAUSync/USyncUser.d.ts +4 -0
- package/lib/WAUSync/USyncUser.js +9 -1
- package/package.json +1 -1
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -60,7 +60,7 @@ const makeLtHashGenerator = ({ indexValueMap, hash }) => {
|
|
|
60
60
|
const prevOp = indexValueMap[indexMacBase64]
|
|
61
61
|
if (operation === WAProto_1.proto.SyncdMutation.SyncdOperation.REMOVE) {
|
|
62
62
|
if (!prevOp) {
|
|
63
|
-
|
|
63
|
+
return
|
|
64
64
|
}
|
|
65
65
|
// remove from index value mac, since this mutation is erased
|
|
66
66
|
delete indexValueMap[indexMacBase64]
|
|
@@ -107,10 +107,23 @@ const generatePatchMac = (snapshotMac, valueMacs, version, type, key) => {
|
|
|
107
107
|
|
|
108
108
|
const newLTHashState = () => ({ version: 0, hash: Buffer.alloc(128), indexValueMap: {} })
|
|
109
109
|
|
|
110
|
+
const ensureLTHashStateVersion = (state) => {
|
|
111
|
+
if (typeof state.version !== 'number' || Number.isNaN(state.version)) {
|
|
112
|
+
state.version = 0
|
|
113
|
+
}
|
|
114
|
+
return state
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const MAX_SYNC_ATTEMPTS = 2
|
|
118
|
+
|
|
119
|
+
const isMissingKeyError = (error) => error?.data?.isMissingKey === true
|
|
120
|
+
|
|
121
|
+
const isAppStateSyncIrrecoverable = (error, attempts) => attempts >= MAX_SYNC_ATTEMPTS || error?.name === 'TypeError'
|
|
122
|
+
|
|
110
123
|
const encodeSyncdPatch = async ({ type, index, syncAction, apiVersion, operation }, myAppStateKeyId, state, getAppStateSyncKey) => {
|
|
111
124
|
const key = !!myAppStateKeyId ? await getAppStateSyncKey(myAppStateKeyId) : undefined
|
|
112
125
|
if (!key) {
|
|
113
|
-
throw new boom_1.Boom(`myAppStateKey ("${myAppStateKeyId}") not present`, {
|
|
126
|
+
throw new boom_1.Boom(`myAppStateKey ("${myAppStateKeyId}") not present`, { data: { isMissingKey: true } })
|
|
114
127
|
}
|
|
115
128
|
const encKeyId = Buffer.from(myAppStateKeyId, 'base64')
|
|
116
129
|
state = { ...state, indexValueMap: { ...state.indexValueMap } }
|
|
@@ -197,7 +210,7 @@ const decodeSyncdMutations = async (msgMutations, initialState, getAppStateSyncK
|
|
|
197
210
|
const base64Key = Buffer.from(keyId).toString('base64')
|
|
198
211
|
const keyEnc = await getAppStateSyncKey(base64Key)
|
|
199
212
|
if (!keyEnc) {
|
|
200
|
-
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`, {
|
|
213
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`, { data: { isMissingKey: true, msgMutations } })
|
|
201
214
|
}
|
|
202
215
|
return mutationKeys(keyEnc.keyData)
|
|
203
216
|
}
|
|
@@ -208,7 +221,7 @@ const decodeSyncdPatch = async (msg, name, initialState, getAppStateSyncKey, onM
|
|
|
208
221
|
const base64Key = Buffer.from(msg.keyId.id).toString('base64')
|
|
209
222
|
const mainKeyObj = await getAppStateSyncKey(base64Key)
|
|
210
223
|
if (!mainKeyObj) {
|
|
211
|
-
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode patch`, {
|
|
224
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode patch`, { data: { isMissingKey: true, msg } })
|
|
212
225
|
}
|
|
213
226
|
const mainKey = await mutationKeys(mainKeyObj.keyData)
|
|
214
227
|
const mutationmacs = msg.mutations.map(mutation => mutation.record.value.blob.slice(-32))
|
|
@@ -291,7 +304,7 @@ const decodeSyncdSnapshot = async (name, snapshot, getAppStateSyncKey, minimumVe
|
|
|
291
304
|
const base64Key = Buffer.from(snapshot.keyId.id).toString('base64')
|
|
292
305
|
const keyEnc = await getAppStateSyncKey(base64Key)
|
|
293
306
|
if (!keyEnc) {
|
|
294
|
-
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation
|
|
307
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`, { data: { isMissingKey: true } })
|
|
295
308
|
}
|
|
296
309
|
const result = await mutationKeys(keyEnc.keyData)
|
|
297
310
|
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey)
|
|
@@ -335,7 +348,7 @@ const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options,
|
|
|
335
348
|
const base64Key = Buffer.from(keyId.id).toString('base64')
|
|
336
349
|
const keyEnc = await getAppStateSyncKey(base64Key)
|
|
337
350
|
if (!keyEnc) {
|
|
338
|
-
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation
|
|
351
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`, { data: { isMissingKey: true } })
|
|
339
352
|
}
|
|
340
353
|
const result = await mutationKeys(keyEnc.keyData)
|
|
341
354
|
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey)
|
|
@@ -690,7 +703,8 @@ const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) => {
|
|
|
690
703
|
else if (action?.contactAction) {
|
|
691
704
|
ev.emit('contacts.upsert', [{
|
|
692
705
|
id,
|
|
693
|
-
name: action.contactAction.fullName,
|
|
706
|
+
name: action.contactAction.fullName || action.contactAction.firstName || action.contactAction.username || undefined,
|
|
707
|
+
username: action.contactAction.username || undefined,
|
|
694
708
|
lid: action.contactAction.lidJid || undefined,
|
|
695
709
|
jid: WABinary_1.isJidUser(id) ? id : undefined
|
|
696
710
|
}])
|
|
@@ -784,7 +798,12 @@ const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) => {
|
|
|
784
798
|
|
|
785
799
|
module.exports = {
|
|
786
800
|
mutationKeys,
|
|
801
|
+
makeLtHashGenerator,
|
|
787
802
|
newLTHashState,
|
|
803
|
+
ensureLTHashStateVersion,
|
|
804
|
+
MAX_SYNC_ATTEMPTS,
|
|
805
|
+
isMissingKeyError,
|
|
806
|
+
isAppStateSyncIrrecoverable,
|
|
788
807
|
encodeSyncdPatch,
|
|
789
808
|
decodeSyncdMutations,
|
|
790
809
|
decodeSyncdPatch,
|
|
@@ -795,4 +814,4 @@ module.exports = {
|
|
|
795
814
|
decodePatches,
|
|
796
815
|
chatModificationToAppPatch,
|
|
797
816
|
processSyncAction
|
|
798
|
-
}
|
|
817
|
+
}
|
|
@@ -112,9 +112,13 @@ const fromMe = WABinary_1.isJidNewsletter(stanza.attrs.from)
|
|
|
112
112
|
const pushname = stanza?.attrs?.notify
|
|
113
113
|
const key = {
|
|
114
114
|
remoteJid: chatId,
|
|
115
|
+
remoteJidUsername: !WABinary_1.isJidGroup(chatId)
|
|
116
|
+
? stanza.attrs.peer_recipient_username || stanza.attrs.recipient_username
|
|
117
|
+
: undefined,
|
|
115
118
|
fromMe,
|
|
116
119
|
id: msgId,
|
|
117
120
|
...(participant !== undefined && { participant: fromMe ? meId : participant }),
|
|
121
|
+
...(stanza.attrs.participant !== undefined && { participantUsername: stanza.attrs.participant_username }),
|
|
118
122
|
...(stanza.attrs.participant_pn !== undefined && { participant_pn: fromMe ? meId : stanza.attrs.participant_pn }),
|
|
119
123
|
...(stanza.attrs.participant_lid !== undefined && { participant_lid: fromMe ? meLid : stanza.attrs.participant_lid }),
|
|
120
124
|
}
|
|
@@ -285,4 +289,4 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
285
289
|
module.exports = {
|
|
286
290
|
decodeMessageNode,
|
|
287
291
|
decryptMessageNode
|
|
288
|
-
}
|
|
292
|
+
}
|
|
@@ -188,6 +188,7 @@ function append(data, historyCache, event, eventData, logger) {
|
|
|
188
188
|
data.historySets.empty = false
|
|
189
189
|
data.historySets.syncType = eventData.syncType
|
|
190
190
|
data.historySets.progress = eventData.progress
|
|
191
|
+
data.historySets.chunkOrder = eventData.chunkOrder
|
|
191
192
|
data.historySets.peerDataRequestSessionId = eventData.peerDataRequestSessionId
|
|
192
193
|
data.historySets.isLatest = eventData.isLatest || data.historySets.isLatest
|
|
193
194
|
break
|
|
@@ -483,6 +484,7 @@ function consolidateEvents(data) {
|
|
|
483
484
|
syncType: data.historySets.syncType,
|
|
484
485
|
progress: data.historySets.progress,
|
|
485
486
|
isLatest: data.historySets.isLatest,
|
|
487
|
+
chunkOrder: data.historySets.chunkOrder,
|
|
486
488
|
peerDataRequestSessionId: data.historySets.peerDataRequestSessionId
|
|
487
489
|
}
|
|
488
490
|
}
|
|
@@ -562,4 +564,4 @@ const stringifyMessageKey = (key) => `${key.remoteJid},${key.id},${key.fromMe ?
|
|
|
562
564
|
|
|
563
565
|
module.exports = {
|
|
564
566
|
makeEventBuffer
|
|
565
|
-
}
|
|
567
|
+
}
|
package/lib/Utils/generics.js
CHANGED
|
@@ -507,6 +507,15 @@ const getCallStatusFromNode = ({ tag, attrs }) => {
|
|
|
507
507
|
status = 'terminate'
|
|
508
508
|
}
|
|
509
509
|
break
|
|
510
|
+
case 'preaccept':
|
|
511
|
+
status = 'preaccept'
|
|
512
|
+
break
|
|
513
|
+
case 'transport':
|
|
514
|
+
status = 'transport'
|
|
515
|
+
break
|
|
516
|
+
case 'relaylatency':
|
|
517
|
+
status = 'relaylatency'
|
|
518
|
+
break
|
|
510
519
|
case 'reject':
|
|
511
520
|
status = 'reject'
|
|
512
521
|
break
|
package/lib/Utils/history.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const promises_1 = require("stream/promises")
|
|
6
6
|
const zlib_1 = require("zlib")
|
|
7
7
|
const WAProto_1 = require("../../WAProto")
|
|
8
8
|
const Types_1 = require("../Types")
|
|
@@ -10,17 +10,14 @@ const WABinary_1 = require("../WABinary")
|
|
|
10
10
|
const generics_1 = require("./generics")
|
|
11
11
|
const messages_1 = require("./messages")
|
|
12
12
|
const messages_media_1 = require("./messages-media")
|
|
13
|
-
const inflatePromise = util_1.promisify(zlib_1.inflate)
|
|
14
13
|
|
|
15
14
|
const downloadHistory = async (msg, options) => {
|
|
16
15
|
const stream = await messages_media_1.downloadContentFromMessage(msg, 'md-msg-hist', { options })
|
|
16
|
+
const inflater = zlib_1.createInflate()
|
|
17
17
|
const bufferArray = []
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let buffer = Buffer.concat(bufferArray)
|
|
22
|
-
// decompress buffer
|
|
23
|
-
buffer = await inflatePromise(buffer)
|
|
18
|
+
inflater.on('data', chunk => bufferArray.push(chunk))
|
|
19
|
+
await promises_1.pipeline(stream, inflater)
|
|
20
|
+
const buffer = Buffer.concat(bufferArray)
|
|
24
21
|
const syncData = WAProto_1.proto.HistorySync.decode(buffer)
|
|
25
22
|
return syncData
|
|
26
23
|
}
|
|
@@ -37,7 +34,8 @@ const processHistoryMessage = (item) => {
|
|
|
37
34
|
for (const chat of item.conversations) {
|
|
38
35
|
contacts.push({
|
|
39
36
|
id: chat.id,
|
|
40
|
-
name: chat.name || undefined,
|
|
37
|
+
name: chat.displayName || chat.name || chat.username || undefined,
|
|
38
|
+
username: chat.username || undefined,
|
|
41
39
|
lid: chat.lidJid || undefined,
|
|
42
40
|
jid: (0, WABinary_1.isJidUser)(chat.id) ? chat.id : undefined
|
|
43
41
|
});
|
|
@@ -68,7 +66,7 @@ const processHistoryMessage = (item) => {
|
|
|
68
66
|
if (WABinary_1.isJidUser(chat.id) && chat.readOnly && chat.archived) {
|
|
69
67
|
delete chat.readOnly
|
|
70
68
|
}
|
|
71
|
-
chats.push(
|
|
69
|
+
chats.push(chat)
|
|
72
70
|
}
|
|
73
71
|
break
|
|
74
72
|
case WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME:
|
|
@@ -76,6 +74,7 @@ const processHistoryMessage = (item) => {
|
|
|
76
74
|
contacts.push({
|
|
77
75
|
id: c.id,
|
|
78
76
|
name: c.name || undefined,
|
|
77
|
+
username: c.username || undefined,
|
|
79
78
|
lid: c.lidJid || undefined,
|
|
80
79
|
jid: WABinary_1.isJidUser(c.id) ? c.id : undefined
|
|
81
80
|
})
|
|
@@ -107,4 +106,4 @@ module.exports = {
|
|
|
107
106
|
processHistoryMessage,
|
|
108
107
|
downloadAndProcessHistorySyncNotification,
|
|
109
108
|
getHistoryMsg
|
|
110
|
-
}
|
|
109
|
+
}
|
|
@@ -572,7 +572,7 @@ const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, { startB
|
|
|
572
572
|
}
|
|
573
573
|
const output = new stream_1.Transform({
|
|
574
574
|
transform(chunk, _, callback) {
|
|
575
|
-
let data = Buffer.concat([remainingBytes, chunk])
|
|
575
|
+
let data = remainingBytes.length ? Buffer.concat([remainingBytes, chunk]) : chunk
|
|
576
576
|
const decryptLength = toSmallestChunkSize(data.length)
|
|
577
577
|
remainingBytes = data.slice(decryptLength)
|
|
578
578
|
data = data.slice(0, decryptLength)
|
|
@@ -803,4 +803,4 @@ module.exports = {
|
|
|
803
803
|
decryptMediaRetryData,
|
|
804
804
|
getStatusCodeForMediaRetry,
|
|
805
805
|
MEDIA_RETRY_STATUS_MAP
|
|
806
|
-
}
|
|
806
|
+
}
|
package/lib/Utils/messages.js
CHANGED
|
@@ -643,6 +643,13 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
+
else if ('album' in message) {
|
|
647
|
+
m.albumMessage = {
|
|
648
|
+
expectedImageCount: message.album.expectedImageCount,
|
|
649
|
+
expectedVideoCount: message.album.expectedVideoCount
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
646
653
|
else if ('payment' in message) {
|
|
647
654
|
const requestPaymentMessage = {
|
|
648
655
|
amount: {
|
|
@@ -753,6 +760,16 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
753
760
|
m = mess
|
|
754
761
|
}
|
|
755
762
|
|
|
763
|
+
if ('albumParentKey' in message && !!message.albumParentKey) {
|
|
764
|
+
m.messageContextInfo = {
|
|
765
|
+
...m.messageContextInfo,
|
|
766
|
+
messageAssociation: {
|
|
767
|
+
associationType: WAProto_1.proto.MessageAssociation.AssociationType.MEDIA_ALBUM,
|
|
768
|
+
parentMessageKey: message.albumParentKey
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
756
773
|
if ('sections' in message && !!message.sections) {
|
|
757
774
|
const listMessage = {
|
|
758
775
|
title: message.title,
|
|
@@ -851,7 +868,7 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
851
868
|
hydratedTemplate.hydratedContentText = message.caption
|
|
852
869
|
}
|
|
853
870
|
|
|
854
|
-
Object.assign(
|
|
871
|
+
Object.assign(hydratedTemplate, m)
|
|
855
872
|
}
|
|
856
873
|
|
|
857
874
|
if ('footer' in message && !!message.footer) {
|
|
@@ -1576,4 +1593,4 @@ module.exports = {
|
|
|
1576
1593
|
downloadMediaMessage,
|
|
1577
1594
|
assertMediaContent,
|
|
1578
1595
|
patchMessageForMdIfRequired
|
|
1579
|
-
}
|
|
1596
|
+
}
|
|
@@ -161,6 +161,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
161
161
|
isLatest: histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND
|
|
162
162
|
? isLatest
|
|
163
163
|
: undefined,
|
|
164
|
+
chunkOrder: histNotification.chunkOrder,
|
|
164
165
|
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
165
166
|
})
|
|
166
167
|
}
|
|
@@ -283,15 +284,15 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
283
284
|
let participants
|
|
284
285
|
|
|
285
286
|
const jid2 = message.key.participant;
|
|
286
|
-
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: jid2, participants, action}))
|
|
287
|
+
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: jid2, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername, participants, action}))
|
|
287
288
|
const emitGroupUpdate = (update) => {
|
|
288
|
-
ev.emit('groups.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined }])
|
|
289
|
+
ev.emit('groups.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername }])
|
|
289
290
|
}
|
|
290
291
|
const emitCommunityUpdate = (update) => {
|
|
291
|
-
ev.emit('communities.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined }])
|
|
292
|
+
ev.emit('communities.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername }])
|
|
292
293
|
}
|
|
293
294
|
const emitGroupRequestJoin = (participant, action, method) => {
|
|
294
|
-
ev.emit('group.join-request', { id: jid, author: message.participant, participant, action, method: method })
|
|
295
|
+
ev.emit('group.join-request', { id: jid, author: message.participant, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername, participant, action, method: method })
|
|
295
296
|
}
|
|
296
297
|
const participantsIncludesMe = () => participants.find(jid => WABinary_1.areJidsSameUser(meId, jid))
|
|
297
298
|
switch (message.messageStubType) {
|
|
@@ -15,11 +15,34 @@ class USyncContactProtocol {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
getUserElement(user) {
|
|
18
|
-
|
|
18
|
+
if (user.phone) {
|
|
19
|
+
return {
|
|
20
|
+
tag: 'contact',
|
|
21
|
+
attrs: {},
|
|
22
|
+
content: user.phone,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (user.username) {
|
|
26
|
+
return {
|
|
27
|
+
tag: 'contact',
|
|
28
|
+
attrs: {
|
|
29
|
+
username: user.username,
|
|
30
|
+
...(user.usernameKey ? { pin: user.usernameKey } : {}),
|
|
31
|
+
...(user.lid ? { lid: user.lid } : {})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (user.type) {
|
|
36
|
+
return {
|
|
37
|
+
tag: 'contact',
|
|
38
|
+
attrs: {
|
|
39
|
+
type: user.type
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
19
43
|
return {
|
|
20
44
|
tag: 'contact',
|
|
21
|
-
attrs: {}
|
|
22
|
-
content: user.phone,
|
|
45
|
+
attrs: {}
|
|
23
46
|
}
|
|
24
47
|
}
|
|
25
48
|
parser(node) {
|
|
@@ -33,4 +56,4 @@ class USyncContactProtocol {
|
|
|
33
56
|
|
|
34
57
|
module.exports = {
|
|
35
58
|
USyncContactProtocol
|
|
36
|
-
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
+
import { BinaryNode } from '../../WABinary'
|
|
3
|
+
|
|
4
|
+
export declare class USyncUsernameProtocol implements USyncQueryProtocol {
|
|
5
|
+
name: string
|
|
6
|
+
getQueryElement(): BinaryNode
|
|
7
|
+
getUserElement(): null
|
|
8
|
+
parser(node: BinaryNode): string | null
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const WABinary_1 = require("../../WABinary")
|
|
6
|
+
|
|
7
|
+
class USyncUsernameProtocol {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = 'username'
|
|
10
|
+
}
|
|
11
|
+
getQueryElement() {
|
|
12
|
+
return {
|
|
13
|
+
tag: 'username',
|
|
14
|
+
attrs: {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
getUserElement() {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
parser(node) {
|
|
21
|
+
if (node.tag === 'username') {
|
|
22
|
+
WABinary_1.assertNodeErrorFree(node)
|
|
23
|
+
return typeof node.content === 'string' ? node.content : null
|
|
24
|
+
}
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
USyncUsernameProtocol
|
|
31
|
+
}
|
|
@@ -3,4 +3,5 @@ export * from './USyncContactProtocol'
|
|
|
3
3
|
export * from './USyncDeviceProtocol'
|
|
4
4
|
export * from './USyncLIDProtocol'
|
|
5
5
|
export * from './USyncStatusProtocol'
|
|
6
|
-
export * from './USyncDisappearingModeProtocol'
|
|
6
|
+
export * from './USyncDisappearingModeProtocol'
|
|
7
|
+
export * from './USyncUsernameProtocol'
|
|
@@ -23,4 +23,5 @@ __exportStar(require("./USyncContactProtocol"), exports)
|
|
|
23
23
|
__exportStar(require("./USyncDeviceProtocol"), exports)
|
|
24
24
|
__exportStar(require("./USyncLIDProtocol"), exports)
|
|
25
25
|
__exportStar(require("./USyncStatusProtocol"), exports)
|
|
26
|
-
__exportStar(require("./USyncDisappearingModeProtocol"), exports)
|
|
26
|
+
__exportStar(require("./USyncDisappearingModeProtocol"), exports)
|
|
27
|
+
__exportStar(require("./USyncUsernameProtocol"), exports)
|
|
@@ -75,8 +75,12 @@ class USyncQuery {
|
|
|
75
75
|
this.protocols.push(new Protocols_1.USyncDisappearingModeProtocol())
|
|
76
76
|
return this
|
|
77
77
|
}
|
|
78
|
+
withUsernameProtocol() {
|
|
79
|
+
this.protocols.push(new Protocols_1.USyncUsernameProtocol())
|
|
80
|
+
return this
|
|
81
|
+
}
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
module.exports = {
|
|
81
85
|
USyncQuery
|
|
82
|
-
}
|
|
86
|
+
}
|
|
@@ -2,11 +2,15 @@ export declare class USyncUser {
|
|
|
2
2
|
id: string
|
|
3
3
|
lid: string
|
|
4
4
|
phone: string
|
|
5
|
+
username: string
|
|
6
|
+
usernameKey: string
|
|
5
7
|
type: string
|
|
6
8
|
personaId: string
|
|
7
9
|
withId(id: string): this
|
|
8
10
|
withLid(lid: string): this
|
|
9
11
|
withPhone(phone: string): this
|
|
12
|
+
withUsername(username: string): this
|
|
13
|
+
withUsernameKey(usernameKey: string): this
|
|
10
14
|
withType(type: string): this
|
|
11
15
|
withPersonaId(personaId: string): this
|
|
12
16
|
}
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -15,6 +15,14 @@ class USyncUser {
|
|
|
15
15
|
this.phone = phone
|
|
16
16
|
return this
|
|
17
17
|
}
|
|
18
|
+
withUsername(username) {
|
|
19
|
+
this.username = username
|
|
20
|
+
return this
|
|
21
|
+
}
|
|
22
|
+
withUsernameKey(usernameKey) {
|
|
23
|
+
this.usernameKey = usernameKey
|
|
24
|
+
return this
|
|
25
|
+
}
|
|
18
26
|
withType(type) {
|
|
19
27
|
this.type = type
|
|
20
28
|
return this
|
|
@@ -27,4 +35,4 @@ class USyncUser {
|
|
|
27
35
|
|
|
28
36
|
module.exports = {
|
|
29
37
|
USyncUser
|
|
30
|
-
}
|
|
38
|
+
}
|