@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.
Files changed (45) hide show
  1. package/README.md +440 -203
  2. package/lib/Defaults/index.js +2 -2
  3. package/lib/Socket/Client/websocket.js +35 -5
  4. package/lib/Socket/chats.js +0 -5
  5. package/lib/Socket/index.js +1 -9
  6. package/lib/Socket/luxu.js +4 -5
  7. package/lib/Socket/messages-recv.js +1 -1
  8. package/lib/Socket/messages-send.js +56 -114
  9. package/lib/Socket/mex.js +38 -51
  10. package/lib/Socket/newsletter.js +276 -745
  11. package/lib/Socket/socket.js +27 -161
  12. package/lib/Socket/username.js +204 -206
  13. package/lib/Store/make-in-memory-store.js +1 -47
  14. package/lib/Types/Mex.js +2 -76
  15. package/lib/Utils/browser-utils.js +1 -0
  16. package/lib/Utils/generics.js +2 -2
  17. package/lib/Utils/index.js +0 -1
  18. package/lib/Utils/messages-media.js +0 -82
  19. package/lib/Utils/messages.js +2 -136
  20. package/lib/WAUSync/Protocols/USyncContactProtocol.js +50 -52
  21. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +52 -55
  22. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +25 -28
  23. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -37
  24. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +23 -25
  25. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  26. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  27. package/lib/WAUSync/Protocols/index.js +6 -12
  28. package/lib/WAUSync/USyncQuery.js +96 -149
  29. package/lib/WAUSync/USyncUser.js +29 -54
  30. package/lib/WAUSync/index.js +4 -3
  31. package/lib/index.js +5 -2
  32. package/package.json +14 -13
  33. package/lib/Socket/graphql.js +0 -716
  34. package/lib/Socket/interop.js +0 -463
  35. package/lib/Socket/message-builder.js +0 -475
  36. package/lib/Socket/privacy.js +0 -318
  37. package/lib/Utils/sticker.js +0 -133
  38. package/lib/Utils/use-sqlite-auth-state.js +0 -162
  39. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -53
  40. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +0 -43
  41. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +0 -58
  42. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -30
  43. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +0 -32
  44. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +0 -28
  45. 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
- }