@alannxd/baileys 6.2.7 → 6.2.8
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 +440 -203
- package/lib/Defaults/index.js +2 -2
- package/lib/Socket/Client/websocket.js +35 -5
- package/lib/Socket/chats.js +0 -5
- package/lib/Socket/index.js +1 -9
- package/lib/Socket/luxu.js +4 -5
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.js +56 -114
- package/lib/Socket/mex.js +38 -51
- package/lib/Socket/newsletter.js +276 -745
- package/lib/Socket/socket.js +27 -161
- package/lib/Socket/username.js +204 -206
- package/lib/Store/make-in-memory-store.js +1 -47
- package/lib/Types/Mex.js +2 -76
- package/lib/Utils/browser-utils.js +1 -0
- package/lib/Utils/generics.js +2 -2
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/messages-media.js +0 -82
- package/lib/Utils/messages.js +2 -136
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +50 -52
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +52 -55
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +25 -28
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -37
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +23 -25
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/index.js +6 -12
- package/lib/WAUSync/USyncQuery.js +96 -149
- package/lib/WAUSync/USyncUser.js +29 -54
- package/lib/WAUSync/index.js +4 -3
- package/lib/index.js +5 -2
- package/package.json +14 -13
- package/lib/Socket/graphql.js +0 -716
- package/lib/Socket/interop.js +0 -463
- package/lib/Socket/message-builder.js +0 -475
- package/lib/Socket/privacy.js +0 -318
- package/lib/Utils/sticker.js +0 -133
- package/lib/Utils/use-sqlite-auth-state.js +0 -162
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -53
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +0 -43
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +0 -58
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -30
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +0 -32
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +0 -28
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -38
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { assertNodeErrorFree, getBinaryNodeChild } from '../../WABinary/index.js'
|
|
2
|
-
|
|
3
|
-
export class USyncBusinessProtocol {
|
|
4
|
-
constructor(profileVersion = '2') {
|
|
5
|
-
this.name = 'business'
|
|
6
|
-
this.profileVersion = profileVersion
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
getQueryElement() {
|
|
10
|
-
return {
|
|
11
|
-
tag: 'business',
|
|
12
|
-
attrs: {},
|
|
13
|
-
content: [
|
|
14
|
-
{ tag: 'verified_name', attrs: {} },
|
|
15
|
-
{ tag: 'profile', attrs: { v: this.profileVersion } }
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
getUserElement(user) {
|
|
21
|
-
const children = []
|
|
22
|
-
if (user.verifiedNameSerial) {
|
|
23
|
-
children.push({ tag: 'verified_name', attrs: { serial: user.verifiedNameSerial } })
|
|
24
|
-
}
|
|
25
|
-
if (user.businessProfileTag) {
|
|
26
|
-
children.push({ tag: 'profile', attrs: { tag: user.businessProfileTag } })
|
|
27
|
-
}
|
|
28
|
-
return children.length > 0 ? { tag: 'business', attrs: {}, content: children } : null
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
parser(node) {
|
|
32
|
-
if (node.tag !== 'business') return null
|
|
33
|
-
assertNodeErrorFree(node)
|
|
34
|
-
const verifiedNameNode = getBinaryNodeChild(node, 'verified_name')
|
|
35
|
-
const profileNode = getBinaryNodeChild(node, 'profile')
|
|
36
|
-
return {
|
|
37
|
-
verifiedName: verifiedNameNode?.content ?? null,
|
|
38
|
-
verifiedLevel: verifiedNameNode?.attrs?.verified_level ?? null,
|
|
39
|
-
profileTag: profileNode?.attrs?.tag ?? null,
|
|
40
|
-
pnJid: node.attrs?.pn_jid ?? null
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { getBinaryNodeChild } from '../../WABinary/index.js'
|
|
2
|
-
|
|
3
|
-
// Device feature flags that can be queried, ported from WhatsApp Web's
|
|
4
|
-
// WAWebUsyncFeature module.
|
|
5
|
-
export const USYNC_FEATURES = [
|
|
6
|
-
'document',
|
|
7
|
-
'encrypt',
|
|
8
|
-
'encrypt_blist',
|
|
9
|
-
'encrypt_contact',
|
|
10
|
-
'encrypt_group_gen2',
|
|
11
|
-
'encrypt_image',
|
|
12
|
-
'encrypt_location',
|
|
13
|
-
'encrypt_url',
|
|
14
|
-
'encrypt_v2',
|
|
15
|
-
'voip',
|
|
16
|
-
'multi_agent'
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
export class USyncFeatureProtocol {
|
|
20
|
-
/**
|
|
21
|
-
* @param {string[]} [features] feature names to query (defaults to all known)
|
|
22
|
-
*/
|
|
23
|
-
constructor(features) {
|
|
24
|
-
this.name = 'feature'
|
|
25
|
-
this.features = features && features.length ? features : USYNC_FEATURES
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
getQueryElement() {
|
|
29
|
-
return {
|
|
30
|
-
tag: 'feature',
|
|
31
|
-
attrs: {},
|
|
32
|
-
content: this.features.map(feature => ({ tag: feature, attrs: {} }))
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getUserElement() {
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
parser(node) {
|
|
41
|
-
if (node.tag !== 'feature') return null
|
|
42
|
-
const errorNode = getBinaryNodeChild(node, 'error')
|
|
43
|
-
if (errorNode) {
|
|
44
|
-
return {
|
|
45
|
-
errorCode: errorNode.attrs?.code ? +errorNode.attrs.code : undefined,
|
|
46
|
-
errorText: errorNode.attrs?.text
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const features = {}
|
|
50
|
-
const children = Array.isArray(node.content) ? node.content : []
|
|
51
|
-
for (const child of children) {
|
|
52
|
-
if (child?.attrs && child.attrs.value !== undefined) {
|
|
53
|
-
features[child.tag] = child.attrs.value
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return features
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export class USyncLIDProtocol {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.name = 'lid'
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
getQueryElement() {
|
|
7
|
-
return {
|
|
8
|
-
tag: 'lid',
|
|
9
|
-
attrs: {}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
getUserElement(user) {
|
|
14
|
-
if (user.lid) {
|
|
15
|
-
return {
|
|
16
|
-
tag: 'lid',
|
|
17
|
-
attrs: { jid: user.lid }
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
return null
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
parser(node) {
|
|
25
|
-
if (node.tag === 'lid') {
|
|
26
|
-
return node.attrs.val
|
|
27
|
-
}
|
|
28
|
-
return null
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { assertNodeErrorFree } from '../../WABinary/index.js'
|
|
2
|
-
|
|
3
|
-
export class USyncPictureProtocol {
|
|
4
|
-
constructor(type = 'image') {
|
|
5
|
-
this.name = 'picture'
|
|
6
|
-
// "image" for full resolution, "preview" for thumbnail
|
|
7
|
-
this.type = type
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
getQueryElement() {
|
|
11
|
-
return {
|
|
12
|
-
tag: 'picture',
|
|
13
|
-
attrs: { type: this.type }
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getUserElement(user) {
|
|
18
|
-
const attrs = {}
|
|
19
|
-
if (user.pictureId != null) attrs.id = String(user.pictureId)
|
|
20
|
-
return Object.keys(attrs).length > 0 ? { tag: 'picture', attrs } : null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
parser(node) {
|
|
24
|
-
if (node.tag !== 'picture') return null
|
|
25
|
-
assertNodeErrorFree(node)
|
|
26
|
-
const id = node.attrs?.id ?? null
|
|
27
|
-
const directPath = node.attrs?.direct_path ?? null
|
|
28
|
-
const hash = node.attrs?.hash ?? null
|
|
29
|
-
if (!id && !directPath) return null
|
|
30
|
-
return { id, directPath, hash }
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { assertNodeErrorFree } from '../../WABinary/index.js'
|
|
2
|
-
|
|
3
|
-
export class USyncSidelistProtocol {
|
|
4
|
-
constructor(useLidAddressing = true) {
|
|
5
|
-
this.name = 'sidelist'
|
|
6
|
-
// When true, sends addressing_mode="lid" — required for interop/LID-mode contacts
|
|
7
|
-
this.useLidAddressing = useLidAddressing
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
getQueryElement() {
|
|
11
|
-
const attrs = {}
|
|
12
|
-
if (this.useLidAddressing) attrs.addressing_mode = 'lid'
|
|
13
|
-
return { tag: 'sidelist', attrs }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getUserElement(user) {
|
|
17
|
-
if (user.sidelistDelete) {
|
|
18
|
-
return { tag: 'sidelist', attrs: { type: 'delete' } }
|
|
19
|
-
}
|
|
20
|
-
return null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
parser(node) {
|
|
24
|
-
if (node.tag !== 'sidelist' && node.tag !== 'side_list') return null
|
|
25
|
-
assertNodeErrorFree(node)
|
|
26
|
-
return { type: node.attrs?.type ?? null }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { assertNodeErrorFree, getBinaryNodeChild } from '../../WABinary/index.js'
|
|
2
|
-
|
|
3
|
-
export class USyncTextStatusProtocol {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.name = 'text_status'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
getQueryElement() {
|
|
9
|
-
return {
|
|
10
|
-
tag: 'text_status',
|
|
11
|
-
attrs: {}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getUserElement() {
|
|
16
|
-
return null
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
parser(node) {
|
|
20
|
-
if (node.tag !== 'text_status') return null
|
|
21
|
-
assertNodeErrorFree(node)
|
|
22
|
-
const lastUpdateTimeSec = node.attrs?.last_update_time ? +node.attrs.last_update_time : 0
|
|
23
|
-
const ephemeralDurationSec = node.attrs?.ephemeral_duration_sec ? +node.attrs.ephemeral_duration_sec : 0
|
|
24
|
-
const text = node.attrs?.text ?? null
|
|
25
|
-
const emojiNode = getBinaryNodeChild(node, 'emoji')
|
|
26
|
-
const emoji = emojiNode?.attrs?.content ?? null
|
|
27
|
-
// expiry is lastUpdateTime + ephemeralDuration (both in ms); 0 means no expiry
|
|
28
|
-
const expiresAt = ephemeralDurationSec > 0
|
|
29
|
-
? new Date((lastUpdateTimeSec + ephemeralDurationSec) * 1000)
|
|
30
|
-
: null
|
|
31
|
-
return {
|
|
32
|
-
text,
|
|
33
|
-
emoji,
|
|
34
|
-
setAt: new Date(lastUpdateTimeSec * 1000),
|
|
35
|
-
expiresAt
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|