@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.
- package/LICENSE +21 -0
- package/README.md +1055 -337
- package/WAProto/index.js +5 -5
- package/lib/Defaults/index.js +187 -127
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.js +14 -11
- package/lib/Signal/Group/group-session-builder.js +91 -29
- package/lib/Signal/Group/group_cipher.js +88 -81
- package/lib/Signal/Group/index.js +136 -12
- package/lib/Signal/Group/keyhelper.js +70 -15
- package/lib/Signal/Group/sender-chain-key.js +31 -25
- package/lib/Signal/Group/sender-key-distribution-message.js +65 -62
- package/lib/Signal/Group/sender-key-message.js +68 -65
- package/lib/Signal/Group/sender-key-name.js +43 -41
- package/lib/Signal/Group/sender-key-record.js +43 -40
- package/lib/Signal/Group/sender-key-state.js +96 -83
- package/lib/Signal/Group/sender-message-key.js +29 -25
- package/lib/Signal/libsignal.js +483 -424
- package/lib/Signal/lid-mapping.js +261 -276
- package/lib/Socket/Client/index.js +30 -3
- package/lib/Socket/Client/types.js +12 -10
- package/lib/Socket/Client/websocket.js +61 -53
- package/lib/Socket/aigroups.js +240 -0
- package/lib/Socket/business.js +422 -379
- package/lib/Socket/chats.js +1816 -1193
- package/lib/Socket/communities.js +549 -431
- package/lib/Socket/graphql.js +656 -0
- package/lib/Socket/groups.js +764 -374
- package/lib/Socket/index.js +38 -11
- package/lib/Socket/interactive-handler.js +522 -0
- package/lib/Socket/interop.js +549 -0
- package/lib/Socket/luxu.js +6 -5
- package/lib/Socket/managed-account.js +183 -0
- package/lib/Socket/messages-recv.js +2439 -1915
- package/lib/Socket/messages-send.js +1642 -1242
- package/lib/Socket/mex.js +59 -40
- package/lib/Socket/newsletter.js +812 -249
- package/lib/Socket/privacy.js +449 -0
- package/lib/Socket/registration.js +427 -0
- package/lib/Socket/socket.js +1077 -965
- package/lib/Socket/text-router.js +83 -0
- package/lib/Socket/username.js +237 -140
- package/lib/Store/index.js +36 -10
- package/lib/Store/make-cache-manager-store.js +85 -80
- package/lib/Store/make-in-memory-store.js +591 -185
- package/lib/Store/make-ordered-dictionary.js +78 -72
- package/lib/Store/object-repository.js +25 -28
- package/lib/Types/Auth.js +38 -2
- package/lib/Types/Bussines.js +2 -2
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.js +4 -8
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.js +26 -24
- package/lib/Types/LabelAssociation.js +8 -6
- package/lib/Types/Message.js +95 -11
- package/lib/Types/Mex.js +112 -37
- package/lib/Types/Newsletter.js +121 -0
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.js +70 -56
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.js +55 -26
- package/lib/Utils/auth-utils.js +292 -288
- package/lib/Utils/browser-utils.js +113 -48
- package/lib/Utils/business.js +240 -224
- package/lib/Utils/chat-utils.js +1205 -869
- package/lib/Utils/command-loader.d.ts +31 -0
- package/lib/Utils/command-loader.js +100 -0
- package/lib/Utils/companion-reg-client-utils.js +41 -34
- package/lib/Utils/consumer-application.js +107 -0
- package/lib/Utils/crypto.js +144 -107
- package/lib/Utils/curve25519-js.js +275 -0
- package/lib/Utils/decode-wa-message.js +518 -308
- package/lib/Utils/event-buffer.js +596 -611
- package/lib/Utils/generics.js +514 -354
- package/lib/Utils/group-history.js +60 -0
- package/lib/Utils/history.js +244 -134
- package/lib/Utils/identity-change-handler.js +51 -49
- package/lib/Utils/index.js +57 -23
- package/lib/Utils/jid-display-normalization.js +218 -0
- package/lib/Utils/link-preview.js +135 -77
- package/lib/Utils/logger.js +9 -3
- package/lib/Utils/lt-hash.js +37 -6
- package/lib/Utils/make-mutex.js +36 -33
- package/lib/Utils/message-composer.js +439 -233
- package/lib/Utils/message-retry-manager.js +265 -260
- package/lib/Utils/messages-media.js +855 -747
- package/lib/Utils/messages.js +2528 -884
- package/lib/Utils/meta-ai-msmsg.js +262 -0
- package/lib/Utils/native-bridge.js +82 -0
- package/lib/Utils/noise-handler.js +195 -200
- package/lib/Utils/offline-node-processor.js +35 -33
- package/lib/Utils/pre-key-manager.js +103 -102
- package/lib/Utils/process-message.js +978 -560
- package/lib/Utils/reporting-utils.js +257 -253
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/lib/Utils/signal.js +218 -195
- package/lib/Utils/stanza-ack.js +31 -29
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/lib/Utils/sync-action-utils.js +50 -45
- package/lib/Utils/tc-token-utils.js +137 -139
- package/lib/Utils/use-multi-file-auth-state.js +109 -109
- package/lib/Utils/validate-connection.js +218 -202
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/lib/Utils/voip-rekey.js +22 -0
- package/lib/WABinary/constants.js +1302 -1299
- package/lib/WABinary/decode.js +343 -262
- package/lib/WABinary/encode.js +12 -4
- package/lib/WABinary/generic-utils.js +223 -187
- package/lib/WABinary/index.js +33 -6
- package/lib/WABinary/jid-utils.js +351 -88
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +12 -9
- package/lib/WAM/constants.js +39486 -22853
- package/lib/WAM/encode.js +132 -140
- package/lib/WAM/index.js +31 -4
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +55 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +53 -51
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +56 -53
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +29 -26
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +59 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +31 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +29 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -37
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +26 -24
- package/lib/WAUSync/Protocols/index.js +39 -6
- package/lib/WAUSync/USyncQuery.js +132 -97
- package/lib/WAUSync/USyncUser.js +49 -30
- package/lib/WAUSync/index.js +31 -4
- package/lib/antiban.js +4637 -0
- package/lib/index.js +48 -15
- package/package.json +55 -92
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +0 -263
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
package/lib/index.js
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.
|
|
60
|
+
Version: 11.9
|
|
28
61
|
Status: Baileys Berhasil Terinstall
|
|
29
|
-
Update date:
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
"
|
|
4
|
-
"
|
|
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-
|
|
7
|
+
"whatsapp-web",
|
|
8
|
+
"whatsapp-api",
|
|
9
|
+
"baileys",
|
|
10
|
+
"multi-device",
|
|
11
|
+
"wasm",
|
|
12
|
+
"rust",
|
|
13
|
+
"automation",
|
|
14
|
+
"md"
|
|
12
15
|
],
|
|
13
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://www.npmjs.com/package/@badzz88/baileys",
|
|
14
17
|
"repository": {
|
|
15
|
-
"
|
|
16
|
-
"url": "https://github.com/Badzz88/baileys"
|
|
18
|
+
"url": "https://github.com/package/Badzz88/baileys.giy"
|
|
17
19
|
},
|
|
18
20
|
"license": "MIT",
|
|
19
|
-
"author": "
|
|
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
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
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
|
-
"@
|
|
46
|
-
"@
|
|
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
|
-
"
|
|
49
|
-
"
|
|
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.
|
|
52
|
-
"pino": "^
|
|
53
|
-
"protobufjs": "^7.
|
|
54
|
-
"
|
|
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": "^
|
|
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.
|
|
73
|
-
"eslint-plugin-prettier": "^5.4.
|
|
59
|
+
"eslint-config-prettier": "^10.1.8",
|
|
60
|
+
"eslint-plugin-prettier": "^5.4.1",
|
|
74
61
|
"jest": "^30.0.5",
|
|
75
|
-
"jimp": "^1.6.
|
|
62
|
+
"jimp": "^1.6.0",
|
|
76
63
|
"jiti": "^2.4.2",
|
|
77
64
|
"json": "^11.0.0",
|
|
78
|
-
"link-preview-js": "^3.
|
|
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
|
|
84
|
-
"
|
|
85
|
-
"ts-jest": "^29.4.
|
|
86
|
-
"
|
|
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.
|
|
95
|
-
"link-preview-js": "^3.
|
|
96
|
-
"sharp": "
|
|
97
|
-
|
|
98
|
-
|
|
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
|