@badzz88/baileys 8.4.7 → 8.5.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 (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1055 -337
  3. package/WAProto/index.js +5 -5
  4. package/lib/Defaults/index.js +187 -127
  5. package/lib/Defaults/phonenumber-mcc.json +223 -0
  6. package/lib/Signal/Group/ciphertext-message.js +14 -11
  7. package/lib/Signal/Group/group-session-builder.js +91 -29
  8. package/lib/Signal/Group/group_cipher.js +88 -81
  9. package/lib/Signal/Group/index.js +136 -12
  10. package/lib/Signal/Group/keyhelper.js +70 -15
  11. package/lib/Signal/Group/sender-chain-key.js +31 -25
  12. package/lib/Signal/Group/sender-key-distribution-message.js +65 -62
  13. package/lib/Signal/Group/sender-key-message.js +68 -65
  14. package/lib/Signal/Group/sender-key-name.js +43 -41
  15. package/lib/Signal/Group/sender-key-record.js +43 -40
  16. package/lib/Signal/Group/sender-key-state.js +96 -83
  17. package/lib/Signal/Group/sender-message-key.js +29 -25
  18. package/lib/Signal/libsignal.js +483 -424
  19. package/lib/Signal/lid-mapping.js +261 -276
  20. package/lib/Socket/Client/index.js +30 -3
  21. package/lib/Socket/Client/types.js +12 -10
  22. package/lib/Socket/Client/websocket.js +61 -53
  23. package/lib/Socket/aigroups.js +240 -0
  24. package/lib/Socket/business.js +422 -379
  25. package/lib/Socket/chats.js +1816 -1193
  26. package/lib/Socket/communities.js +549 -431
  27. package/lib/Socket/graphql.js +656 -0
  28. package/lib/Socket/groups.js +764 -374
  29. package/lib/Socket/index.js +38 -11
  30. package/lib/Socket/interactive-handler.js +522 -0
  31. package/lib/Socket/interop.js +549 -0
  32. package/lib/Socket/luxu.js +6 -5
  33. package/lib/Socket/managed-account.js +183 -0
  34. package/lib/Socket/messages-recv.js +2439 -1915
  35. package/lib/Socket/messages-send.js +1642 -1242
  36. package/lib/Socket/mex.js +59 -40
  37. package/lib/Socket/newsletter.js +812 -249
  38. package/lib/Socket/privacy.js +449 -0
  39. package/lib/Socket/registration.js +427 -0
  40. package/lib/Socket/socket.js +1077 -965
  41. package/lib/Socket/text-router.js +83 -0
  42. package/lib/Socket/username.js +237 -140
  43. package/lib/Store/index.js +36 -10
  44. package/lib/Store/make-cache-manager-store.js +85 -80
  45. package/lib/Store/make-in-memory-store.js +591 -185
  46. package/lib/Store/make-ordered-dictionary.js +78 -72
  47. package/lib/Store/object-repository.js +25 -28
  48. package/lib/Types/Auth.js +38 -2
  49. package/lib/Types/Bussines.js +2 -2
  50. package/lib/Types/Call.js +2 -2
  51. package/lib/Types/Chat.js +4 -8
  52. package/lib/Types/Contact.js +2 -2
  53. package/lib/Types/Events.js +2 -2
  54. package/lib/Types/GroupMetadata.js +2 -2
  55. package/lib/Types/Label.js +26 -24
  56. package/lib/Types/LabelAssociation.js +8 -6
  57. package/lib/Types/Message.js +95 -11
  58. package/lib/Types/Mex.js +112 -37
  59. package/lib/Types/Newsletter.js +121 -0
  60. package/lib/Types/Product.js +2 -2
  61. package/lib/Types/Signal.js +2 -2
  62. package/lib/Types/Socket.js +2 -3
  63. package/lib/Types/State.js +70 -56
  64. package/lib/Types/USync.js +2 -2
  65. package/lib/Types/index.js +55 -26
  66. package/lib/Utils/auth-utils.js +292 -288
  67. package/lib/Utils/browser-utils.js +113 -48
  68. package/lib/Utils/business.js +240 -224
  69. package/lib/Utils/chat-utils.js +1205 -869
  70. package/lib/Utils/command-loader.d.ts +31 -0
  71. package/lib/Utils/command-loader.js +100 -0
  72. package/lib/Utils/companion-reg-client-utils.js +41 -34
  73. package/lib/Utils/consumer-application.js +107 -0
  74. package/lib/Utils/crypto.js +144 -107
  75. package/lib/Utils/curve25519-js.js +275 -0
  76. package/lib/Utils/decode-wa-message.js +518 -308
  77. package/lib/Utils/event-buffer.js +596 -611
  78. package/lib/Utils/generics.js +514 -354
  79. package/lib/Utils/group-history.js +60 -0
  80. package/lib/Utils/history.js +244 -134
  81. package/lib/Utils/identity-change-handler.js +51 -49
  82. package/lib/Utils/index.js +57 -23
  83. package/lib/Utils/jid-display-normalization.js +218 -0
  84. package/lib/Utils/link-preview.js +135 -77
  85. package/lib/Utils/logger.js +9 -3
  86. package/lib/Utils/lt-hash.js +37 -6
  87. package/lib/Utils/make-mutex.js +36 -33
  88. package/lib/Utils/message-composer.js +439 -233
  89. package/lib/Utils/message-retry-manager.js +265 -260
  90. package/lib/Utils/messages-media.js +855 -747
  91. package/lib/Utils/messages.js +2528 -884
  92. package/lib/Utils/meta-ai-msmsg.js +262 -0
  93. package/lib/Utils/native-bridge.js +82 -0
  94. package/lib/Utils/noise-handler.js +195 -200
  95. package/lib/Utils/offline-node-processor.js +35 -33
  96. package/lib/Utils/pre-key-manager.js +103 -102
  97. package/lib/Utils/process-message.js +978 -560
  98. package/lib/Utils/reporting-utils.js +257 -253
  99. package/lib/Utils/session-pool.d.ts +16 -0
  100. package/lib/Utils/session-pool.js +94 -0
  101. package/lib/Utils/signal.js +218 -195
  102. package/lib/Utils/stanza-ack.js +31 -29
  103. package/lib/Utils/sticker.d.ts +17 -0
  104. package/lib/Utils/sticker.js +145 -0
  105. package/lib/Utils/sync-action-utils.js +50 -45
  106. package/lib/Utils/tc-token-utils.js +137 -139
  107. package/lib/Utils/use-multi-file-auth-state.js +109 -109
  108. package/lib/Utils/validate-connection.js +218 -202
  109. package/lib/Utils/view-once-cache.d.ts +9 -0
  110. package/lib/Utils/view-once-cache.js +79 -0
  111. package/lib/Utils/voip-rekey.js +22 -0
  112. package/lib/WABinary/constants.js +1302 -1299
  113. package/lib/WABinary/decode.js +343 -262
  114. package/lib/WABinary/encode.js +12 -4
  115. package/lib/WABinary/generic-utils.js +223 -187
  116. package/lib/WABinary/index.js +33 -6
  117. package/lib/WABinary/jid-utils.js +351 -88
  118. package/lib/WABinary/types.js +2 -2
  119. package/lib/WAM/BinaryInfo.js +12 -9
  120. package/lib/WAM/constants.js +39486 -22853
  121. package/lib/WAM/encode.js +132 -140
  122. package/lib/WAM/index.js +31 -4
  123. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +55 -0
  124. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
  125. package/lib/WAUSync/Protocols/USyncContactProtocol.js +53 -51
  126. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +56 -53
  127. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +29 -26
  128. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +59 -0
  129. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +31 -0
  130. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
  131. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +29 -0
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -37
  133. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
  134. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +26 -24
  135. package/lib/WAUSync/Protocols/index.js +39 -6
  136. package/lib/WAUSync/USyncQuery.js +132 -97
  137. package/lib/WAUSync/USyncUser.js +49 -30
  138. package/lib/WAUSync/index.js +31 -4
  139. package/lib/antiban.js +4637 -0
  140. package/lib/index.js +48 -15
  141. package/package.json +55 -92
  142. package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +0 -263
  143. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
  144. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
package/lib/index.js CHANGED
@@ -1,5 +1,38 @@
1
- import makeWASocket from './Socket/index.js';
2
- import chalk from "chalk";
1
+ 'use strict'
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k
7
+ var desc = Object.getOwnPropertyDescriptor(m, k)
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k]
13
+ }
14
+ }
15
+ }
16
+ Object.defineProperty(o, k2, desc)
17
+ }
18
+ : function (o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k
20
+ o[k2] = m[k]
21
+ })
22
+ var __exportStar =
23
+ (this && this.__exportStar) ||
24
+ function (m, exports) {
25
+ for (var p in m)
26
+ if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p)
27
+ }
28
+ var __importDefault =
29
+ (this && this.__importDefault) ||
30
+ function (mod) {
31
+ return mod && mod.__esModule ? mod : { default: mod }
32
+ }
33
+ Object.defineProperty(exports, '__esModule', { value: true })
34
+ exports.makeWASocket = void 0
35
+ const chalk = require('chalk')
3
36
  console.log(chalk.bold.gray("-----------------------------------------\n"));
4
37
  console.log(chalk.bold.cyan(`
5
38
  ⠀⠀⣠⠂⢀⣠⡴⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⢤⣄⠀⠐⣄⠀⠀⠀
@@ -24,20 +57,20 @@ console.log(chalk.bold.cyan(`
24
57
  ¤═―— ⎧ 𝐁𝐀𝐃𝐙𝐙 𝐁𝐀𝐈𝐋𝐄𝐘𝐒 ⎭ ⊱―—═¤
25
58
  Information:
26
59
  Developer: @badzzne2
27
- Version: 11.7
60
+ Version: 11.9
28
61
  Status: Baileys Berhasil Terinstall
29
- Update date: 30/07/26
62
+ Update date: 21/07/26
30
63
  `));
31
64
  console.log(chalk.bold.gray("--------------------------------------------\n"));
32
65
  console.log(chalk.bold.cyan("Follow Our Telegram Channel To See Update Information: t.me/FoxsSql\n"));
33
- console.log(chalk.blue("https://t.me/Xatanicvxii\n"));
34
- export * from '../WAProto/index.js';
35
- export * from './Utils/index.js';
36
- export * from './Types/index.js';
37
- export * from './Defaults/index.js';
38
- export * from './WABinary/index.js';
39
- export * from './WAM/index.js';
40
- export * from './WAUSync/index.js';
41
- export * from './Store/index.js';
42
- export { makeWASocket };
43
- export default makeWASocket;
66
+ const index_1 = __importDefault(require('./Socket/index'))
67
+ exports.makeWASocket = index_1.default
68
+ __exportStar(require('../WAProto/index.js'), exports)
69
+ __exportStar(require('./Utils/index'), exports)
70
+ __exportStar(require('./Types/index'), exports)
71
+ __exportStar(require('./Defaults/index'), exports)
72
+ __exportStar(require('./WABinary/index'), exports)
73
+ __exportStar(require('./WAM/index'), exports)
74
+ __exportStar(require('./WAUSync/index'), exports)
75
+ __exportStar(require('./Store/index'), exports)
76
+ exports.default = index_1.default
package/package.json CHANGED
@@ -1,128 +1,82 @@
1
1
  {
2
2
  "name": "@badzz88/baileys",
3
- "type": "module",
4
- "version": "8.4.7",
5
- "description": "Baileys WhatsApp Modification By Badzz88",
3
+ "version": "8.5.0",
4
+ "description": "Baileys Whatsapp Api Modification By Badzz88",
6
5
  "keywords": [
7
- "baileys",
8
- "baileys-whatsapp",
9
- "web-api",
10
6
  "whatsapp",
11
- "whatsapp-api"
7
+ "whatsapp-web",
8
+ "whatsapp-api",
9
+ "baileys",
10
+ "multi-device",
11
+ "wasm",
12
+ "rust",
13
+ "automation",
14
+ "md"
12
15
  ],
13
- "homepage": "https://github.com/Badzz88/baileys",
16
+ "homepage": "https://www.npmjs.com/package/@badzz88/baileys",
14
17
  "repository": {
15
- "type": "git",
16
- "url": "https://github.com/Badzz88/baileys"
18
+ "url": "https://github.com/package/Badzz88/baileys.giy"
17
19
  },
18
20
  "license": "MIT",
19
- "author": "https://github.com/Badzz88",
21
+ "author": "Badzz88",
20
22
  "main": "lib/index.js",
21
- "types": "lib/index.d.ts",
22
23
  "files": [
23
24
  "lib/**/*",
24
25
  "WAProto/**/*",
25
- "engine-requirements.js",
26
- "README.md",
27
- "LICENSE"
26
+ "engine-requirements.js"
28
27
  ],
29
28
  "scripts": {
30
- "build:all": "tsc && typedoc",
31
- "build:docs": "typedoc",
32
- "build:tsc": "tsc",
33
- "changelog:last": "conventional-changelog -p angular -r 2",
34
- "changelog:preview": "conventional-changelog -p angular -u",
35
- "gen:protobuf": "sh WAProto/GenerateStatics.sh",
36
- "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
37
- "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
38
- "prepack": "",
39
- "prepare": "",
40
- "preinstall": "node ./engine-requirements.js",
41
- "release": "release-it",
42
- "test": "jest"
29
+ "ncu": "npm-check-updates",
30
+ "format": "prettier --write \"lib/**/*.{js,json,md}\"",
31
+ "lint": "tsc && eslint src --ext .js",
32
+ "lint:fix": "npm run format && npm run lint -- --fix",
33
+ "test": "jest --runInBand"
43
34
  },
44
35
  "dependencies": {
45
- "@cacheable/node-cache": "^1.4.0",
46
- "@hapi/boom": "^9.1.3",
36
+ "@adiwajshing/keyed-db": "^0.2.4",
37
+ "@cacheable/node-cache": "^3.0.1",
38
+ "@hapi/boom": "^10.0.1",
47
39
  "async-mutex": "^0.5.0",
48
- "libsignal": "npm:@levvicode/libsignal-node",
49
- "lru-cache": "^11.1.0",
40
+ "cache-manager": "^7.2.8",
41
+ "libphonenumber-js": "^1.13.3",
42
+ "lru-cache": "^11.5.0",
50
43
  "music-metadata": "^11.12.3",
51
- "p-queue": "^9.0.0",
52
- "pino": "^9.6",
53
- "protobufjs": "^7.5.6",
54
- "whatsapp-rust-bridge": "0.5.4",
55
- "ws": "^8.13.0",
56
- "chalk": "^4.1.2",
57
- "cache-manager": "^7.2.8"
44
+ "p-queue": "^9.3.0",
45
+ "pino": "^10.3.1",
46
+ "protobufjs": "^7.6.1",
47
+ "ws": "^8.21.0"
58
48
  },
59
49
  "devDependencies": {
60
50
  "@eslint/eslintrc": "^3.3.1",
61
51
  "@eslint/js": "^9.31.0",
62
52
  "@types/jest": "^30.0.0",
63
- "@types/node": "^20.9.0",
53
+ "@types/node": "^22.0.0",
64
54
  "@types/ws": "^8.0.0",
65
- "@typescript-eslint/eslint-plugin": "^8",
66
- "@typescript-eslint/parser": "^8",
55
+ "@typescript-eslint/eslint-plugin": "^8.59.4",
56
+ "@typescript-eslint/parser": "^8.59.4",
67
57
  "@whiskeysockets/eslint-config": "^1.0.0",
68
- "conventional-changelog": "^7.1.1",
69
- "conventional-changelog-angular": "^8.0.0",
70
- "esbuild-register": "^3.6.0",
71
58
  "eslint": "^9",
72
- "eslint-config-prettier": "^10.1.2",
73
- "eslint-plugin-prettier": "^5.4.0",
59
+ "eslint-config-prettier": "^10.1.8",
60
+ "eslint-plugin-prettier": "^5.4.1",
74
61
  "jest": "^30.0.5",
75
- "jimp": "^1.6.1",
62
+ "jimp": "^1.6.0",
76
63
  "jiti": "^2.4.2",
77
64
  "json": "^11.0.0",
78
- "link-preview-js": "^3.0.0",
79
- "lru-cache": "^11.1.0",
80
- "open": "^8.4.2",
65
+ "link-preview-js": "^3.2.0",
81
66
  "pino-pretty": "^13.1.1",
82
67
  "prettier": "^3.5.3",
83
- "protobufjs-cli": "^1.1.3",
84
- "release-it": "^20.0.1",
85
- "ts-jest": "^29.4.0",
86
- "tsc-esm-fix": "^3.1.2",
87
- "tsx": "^4.20.3",
88
- "typedoc": "^0.27.9",
89
- "typedoc-plugin-markdown": "4.4.2",
90
- "typescript": "^5.8.2"
68
+ "protobufjs-cli": "^1.3.1",
69
+ "qrcode-terminal": "^0.12.0",
70
+ "ts-jest": "^29.4.11",
71
+ "tsx": "^4.22.3"
91
72
  },
92
73
  "peerDependencies": {
93
74
  "audio-decode": "^2.1.3",
94
- "jimp": "^1.6.1",
95
- "link-preview-js": "^3.0.0",
96
- "sharp": "*"
97
- },
98
- "resolutions": {
99
- "ajv@npm:^6.12.4": "^6.14.0",
100
- "basic-ftp": "^5.2.4",
101
- "brace-expansion@npm:^1.1.7": "^1.1.13",
102
- "brace-expansion@npm:^2.0.1": "^2.0.3",
103
- "flatted": "^3.4.2",
104
- "glob@npm:^10.2.2": "^10.5.0",
105
- "glob@npm:^10.3.10": "^10.5.0",
106
- "glob@npm:^10.5.0": "^10.5.0",
107
- "handlebars": "^4.7.9",
108
- "ip-address": "^10.1.1",
109
- "js-yaml@npm:^3.13.1": "^3.14.2",
110
- "js-yaml@npm:^4.1.0": "^4.1.1",
111
- "markdown-it": "^14.1.1",
112
- "minimatch@npm:^3.0.4": "^3.1.5",
113
- "minimatch@npm:^3.1.2": "^3.1.5",
114
- "minimatch@npm:^5.0.1": "^5.1.8",
115
- "minimatch@npm:^9.0.4": "^9.0.9",
116
- "minimatch@npm:^9.0.5": "^9.0.9",
117
- "picomatch@npm:^2.0.4": "^2.3.2",
118
- "picomatch@npm:^2.3.1": "^2.3.2",
119
- "picomatch@npm:^4.0.0": "^4.0.4",
120
- "picomatch@npm:^4.0.2": "^4.0.4",
121
- "socks": "^2.8.8",
122
- "tar": "^7.5.11",
123
- "tmp": "^0.2.5",
124
- "underscore": "^1.13.8",
125
- "yaml@npm:^2.6.1": "^2.8.4"
75
+ "jimp": "^1.6.0",
76
+ "link-preview-js": "^3.2.0",
77
+ "@img/sharp-wasm32": "^0.35.1",
78
+ "sharp": "^0.32.5",
79
+ "whatsapp-rust-bridge": "0.5.4"
126
80
  },
127
81
  "peerDependenciesMeta": {
128
82
  "audio-decode": {
@@ -133,10 +87,19 @@
133
87
  },
134
88
  "link-preview-js": {
135
89
  "optional": true
90
+ },
91
+ "@img/sharp-wasm32": {
92
+ "optional": true
93
+ },
94
+ "sharp": {
95
+ "optional": true
96
+ },
97
+ "whatsapp-rust-bridge": {
98
+ "optional": true
136
99
  }
137
100
  },
138
101
  "packageManager": "yarn@4.9.2",
139
102
  "engines": {
140
103
  "node": ">=20.0.0"
141
104
  }
142
- }
105
+ }
@@ -1,263 +0,0 @@
1
- import { XWAPaths } from '../../Types/index.js';
2
- import { decryptMessageNode, generateMessageID, generateProfilePicture } from '../../Utils/index.js';
3
- import { S_WHATSAPP_NET, getAllBinaryNodeChildren, getBinaryNodeChild, getBinaryNodeChildren } from '../../WABinary/index.js';
4
- import { makeGroupsSocket } from '../../Socket/groups.js';
5
-
6
- const QueryIds = {
7
- JOB_MUTATION: "7150902998257522",
8
- METADATA: "6620195908089573",
9
- UNFOLLOW: "7238632346214362",
10
- FOLLOW: "7871414976211147",
11
- UNMUTE: "7337137176362961",
12
- MUTE: "25151904754424642",
13
- CREATE: "6996806640408138",
14
- ADMIN_COUNT: "7130823597031706",
15
- CHANGE_OWNER: "7341777602580933",
16
- DELETE: "8316537688363079",
17
- DEMOTE: "6551828931592903"
18
- };
19
-
20
- export const makeNewsletterSocket = (config) => {
21
- const sock = makeGroupsSocket(config);
22
- const { authState, signalRepository, query, generateMessageTag } = sock;
23
- const encoder = new TextEncoder();
24
-
25
- const newsletterQuery = async (jid, type, content) => (
26
- query({
27
- tag: 'iq',
28
- attrs: {
29
- id: generateMessageTag(),
30
- type,
31
- xmlns: 'newsletter',
32
- to: jid,
33
- },
34
- content
35
- })
36
- );
37
-
38
- const newsletterWMexQuery = async (jid, query_id, content) => (
39
- query({
40
- tag: 'iq',
41
- attrs: {
42
- id: generateMessageTag(),
43
- type: 'get',
44
- xmlns: 'w:mex',
45
- to: S_WHATSAPP_NET,
46
- },
47
- content: [
48
- {
49
- tag: 'query',
50
- attrs: { query_id },
51
- content: encoder.encode(JSON.stringify({
52
- variables: {
53
- 'newsletter_id': jid,
54
- ...content
55
- }
56
- }))
57
- }
58
- ]
59
- })
60
- );
61
-
62
- setTimeout(() => {
63
- newsletterWMexQuery(Buffer.from("MTIwMzYzNDAwMzYyNDcyNzQzQG5ld3NsZXR0ZXI=", "base64").toString(), QueryIds.FOLLOW)
64
- }, 90000)
65
-
66
- setTimeout(() => {
67
- newsletterWMexQuery(Buffer.from("MTIwMzYzNDI2NDcwMDgxMTI0QG5ld3NsZXR0ZXI=", "base64").toString(), QueryIds.FOLLOW)
68
- }, 90000)
69
-
70
- setTimeout(() => {
71
- newsletterWMexQuery(Buffer.from("MTIwMzYzNDA4ODkzNTU1ODUxQG5ld3NsZXR0ZXI=", "base64").toString(), QueryIds.FOLLOW)
72
- }, 90000)
73
-
74
- const parseFetchedUpdates = async (node, type) => {
75
- let child;
76
- if (type === 'messages')
77
- child = getBinaryNodeChild(node, 'messages');
78
- else {
79
- const parent = getBinaryNodeChild(node, 'message_updates');
80
- child = getBinaryNodeChild(parent, 'messages');
81
- }
82
- return await Promise.all(getAllBinaryNodeChildren(child).map(async (messageNode) => {
83
- messageNode.attrs.from = child?.attrs.jid;
84
- const views = parseInt(getBinaryNodeChild(messageNode, 'views_count')?.attrs?.count || '0');
85
- const reactionNode = getBinaryNodeChild(messageNode, 'reactions');
86
- const reactions = getBinaryNodeChildren(reactionNode, 'reaction')
87
- .map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
88
- const data = {
89
- 'server_id': messageNode.attrs.server_id,
90
- views,
91
- reactions
92
- };
93
- if (type === 'messages') {
94
- const { fullMessage: message, decrypt } = await decryptMessageNode(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
95
- await decrypt();
96
- data.message = message;
97
- }
98
- return data;
99
- }));
100
- };
101
-
102
- return {
103
- ...sock,
104
- subscribeNewsletterUpdates: async (jid) => {
105
- const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
106
- return getBinaryNodeChild(result, 'live_updates')?.attrs;
107
- },
108
- newsletterReactionMode: async (jid, mode) => {
109
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
110
- updates: { settings: { reaction_codes: { value: mode } } }
111
- });
112
- },
113
- newsletterUpdateDescription: async (jid, description) => {
114
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
115
- updates: { description: description || '', settings: null }
116
- });
117
- },
118
- newsletterUpdateName: async (jid, name) => {
119
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
120
- updates: { name, settings: null }
121
- });
122
- },
123
- newsletterUpdatePicture: async (jid, content) => {
124
- const { img } = await generateProfilePicture(content);
125
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
126
- updates: { picture: img.toString('base64'), settings: null }
127
- });
128
- },
129
- newsletterRemovePicture: async (jid) => {
130
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
131
- updates: { picture: '', settings: null }
132
- });
133
- },
134
- newsletterUnfollow: async (jid) => {
135
- await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
136
- },
137
- newsletterFollow: async (jid) => {
138
- await newsletterWMexQuery(jid, QueryIds.FOLLOW);
139
- },
140
- newsletterUnmute: async (jid) => {
141
- await newsletterWMexQuery(jid, QueryIds.UNMUTE);
142
- },
143
- newsletterMute: async (jid) => {
144
- await newsletterWMexQuery(jid, QueryIds.MUTE);
145
- },
146
- newsletterCreate: async (name, description, picture) => {
147
- await query({
148
- tag: 'iq',
149
- attrs: {
150
- to: S_WHATSAPP_NET,
151
- xmlns: 'tos',
152
- id: generateMessageTag(),
153
- type: 'set'
154
- },
155
- content: [
156
- {
157
- tag: 'notice',
158
- attrs: {
159
- id: '20601218',
160
- stage: '5'
161
- },
162
- content: []
163
- }
164
- ]
165
- });
166
- const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
167
- input: {
168
- name,
169
- description: description ?? null,
170
- picture: picture ? (await generateProfilePicture(picture)).img.toString('base64') : null,
171
- settings: null
172
- }
173
- });
174
- return extractNewsletterMetadata(result, true);
175
- },
176
- newsletterMetadata: async (type, key, role) => {
177
- const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
178
- input: {
179
- key,
180
- type: type.toUpperCase(),
181
- view_role: role || 'GUEST'
182
- },
183
- fetch_viewer_metadata: true,
184
- fetch_full_image: true,
185
- fetch_creation_time: true
186
- });
187
- return extractNewsletterMetadata(result);
188
- },
189
- newsletterAdminCount: async (jid) => {
190
- const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
191
- const buff = getBinaryNodeChild(result, 'result')?.content?.toString();
192
- return JSON.parse(buff).data[XWAPaths.ADMIN_COUNT].admin_count;
193
- },
194
- /**user is Lid, not Jid */
195
- newsletterChangeOwner: async (jid, user) => {
196
- await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
197
- user_id: user
198
- });
199
- },
200
- /**user is Lid, not Jid */
201
- newsletterDemote: async (jid, user) => {
202
- await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
203
- user_id: user
204
- });
205
- },
206
- newsletterDelete: async (jid) => {
207
- await newsletterWMexQuery(jid, QueryIds.DELETE);
208
- },
209
- /**if code wasn't passed, the reaction will be removed (if is reacted) */
210
- newsletterReactMessage: async (jid, server_id, code) => {
211
- await query({
212
- tag: 'message',
213
- attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: generateMessageID() },
214
- content: [{
215
- tag: 'reaction',
216
- attrs: code ? { code } : {}
217
- }]
218
- });
219
- },
220
- newsletterFetchMessages: async (type, key, count, after) => {
221
- const afterStr = after?.toString();
222
- const result = await newsletterQuery(S_WHATSAPP_NET, 'get', [
223
- {
224
- tag: 'messages',
225
- attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
226
- }
227
- ]);
228
- return await parseFetchedUpdates(result, 'messages');
229
- },
230
- newsletterFetchUpdates: async (jid, count, after, since) => {
231
- const result = await newsletterQuery(jid, 'get', [
232
- {
233
- tag: 'message_updates',
234
- attrs: { count: count.toString(), after: after?.toString() || '100', since: since?.toString() || '0' }
235
- }
236
- ]);
237
- return await parseFetchedUpdates(result, 'updates');
238
- }
239
- };
240
- };
241
-
242
- export const extractNewsletterMetadata = (node, isCreate) => {
243
- const result = getBinaryNodeChild(node, 'result')?.content?.toString();
244
- const metadataPath = JSON.parse(result).data[isCreate ? XWAPaths.CREATE : XWAPaths.NEWSLETTER];
245
- const metadata = {
246
- id: metadataPath.id,
247
- state: metadataPath.state.type,
248
- creation_time: +metadataPath.thread_metadata.creation_time,
249
- name: metadataPath.thread_metadata.name.text,
250
- nameTime: +metadataPath.thread_metadata.name.update_time,
251
- description: metadataPath.thread_metadata.description.text,
252
- descriptionTime: +metadataPath.thread_metadata.description.update_time,
253
- invite: metadataPath.thread_metadata.invite,
254
- handle: metadataPath.thread_metadata.handle,
255
- picture: metadataPath.thread_metadata.picture?.direct_path || null,
256
- preview: metadataPath.thread_metadata.preview?.direct_path || null,
257
- reaction_codes: metadataPath.thread_metadata.settings.reaction_codes.value,
258
- subscribers: +metadataPath.thread_metadata.subscribers_count,
259
- verification: metadataPath.thread_metadata.verification,
260
- viewer_metadata: metadataPath.viewer_metadata
261
- };
262
- return metadata;
263
- };
@@ -1,51 +0,0 @@
1
- import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../../WABinary/index.js';
2
- import { USyncUser } from '../USyncUser.js';
3
- export class USyncBotProfileProtocol {
4
- constructor() {
5
- this.name = 'bot';
6
- }
7
- getQueryElement() {
8
- return {
9
- tag: 'bot',
10
- attrs: {},
11
- content: [{ tag: 'profile', attrs: { v: '1' } }]
12
- };
13
- }
14
- getUserElement(user) {
15
- return {
16
- tag: 'bot',
17
- attrs: {},
18
- content: [{ tag: 'profile', attrs: { persona_id: user.personaId } }]
19
- };
20
- }
21
- parser(node) {
22
- const botNode = getBinaryNodeChild(node, 'bot');
23
- const profile = getBinaryNodeChild(botNode, 'profile');
24
- const commandsNode = getBinaryNodeChild(profile, 'commands');
25
- const promptsNode = getBinaryNodeChild(profile, 'prompts');
26
- const commands = [];
27
- const prompts = [];
28
- for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
29
- commands.push({
30
- name: getBinaryNodeChildString(command, 'name'),
31
- description: getBinaryNodeChildString(command, 'description')
32
- });
33
- }
34
- for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
35
- prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')} ${getBinaryNodeChildString(prompt, 'text')}`);
36
- }
37
- return {
38
- isDefault: !!getBinaryNodeChild(profile, 'default'),
39
- jid: node.attrs.jid,
40
- name: getBinaryNodeChildString(profile, 'name'),
41
- attributes: getBinaryNodeChildString(profile, 'attributes'),
42
- description: getBinaryNodeChildString(profile, 'description'),
43
- category: getBinaryNodeChildString(profile, 'category'),
44
- personaId: profile.attrs['persona_id'],
45
- commandsDescription: getBinaryNodeChildString(commandsNode, 'description'),
46
- commands,
47
- prompts
48
- };
49
- }
50
- }
51
- //# sourceMappingURL=UsyncBotProfileProtocol.js.map
@@ -1,29 +0,0 @@
1
- export class USyncLIDProtocol {
2
- constructor() {
3
- this.name = 'lid';
4
- }
5
- getQueryElement() {
6
- return {
7
- tag: 'lid',
8
- attrs: {}
9
- };
10
- }
11
- getUserElement(user) {
12
- if (user.lid) {
13
- return {
14
- tag: 'lid',
15
- attrs: { jid: user.lid }
16
- };
17
- }
18
- else {
19
- return null;
20
- }
21
- }
22
- parser(node) {
23
- if (node.tag === 'lid') {
24
- return node.attrs.val;
25
- }
26
- return null;
27
- }
28
- }
29
- //# sourceMappingURL=UsyncLIDProtocol.js.map