@badzz88/baileys 8.4.9 → 8.5.1
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 +1 -1
- package/WAProto/WAProto.proto +6 -347
- package/WAProto/fix-imports.js +85 -86
- package/WAProto/index.d.ts +25 -4913
- package/WAProto/index.js +93 -14069
- package/{src → lib}/Defaults/index.js +2 -13
- package/{src → lib}/Signal/Group/group_cipher.js +5 -5
- package/{src → lib}/Signal/Group/keyhelper.js +4 -4
- package/{src → lib}/Signal/Group/sender-chain-key.js +2 -2
- package/{src → lib}/Signal/Group/sender-key-distribution-message.js +1 -1
- package/{src → lib}/Signal/Group/sender-key-message.js +3 -3
- package/{src → lib}/Signal/Group/sender-key-record.js +1 -1
- package/{src → lib}/Signal/Group/sender-message-key.js +2 -2
- package/{src → lib}/Signal/libsignal.js +26 -6
- package/{src → lib}/Socket/chats.js +58 -616
- package/{src → lib}/Socket/communities.js +28 -59
- package/{src → lib}/Socket/graphql.js +103 -362
- package/{src → lib}/Socket/groups.js +29 -77
- package/{src → lib}/Socket/index.js +5 -3
- package/{src → lib}/Socket/interactive-handler.js +60 -117
- package/{src → lib}/Socket/interop.js +19 -36
- package/lib/Socket/luxu.js +387 -0
- package/{src → lib}/Socket/managed-account.js +27 -58
- package/{src → lib}/Socket/messages-recv.js +144 -715
- package/{src → lib}/Socket/messages-send.js +102 -412
- package/lib/Socket/mex.js +60 -0
- package/{src → lib}/Socket/newsletter.js +23 -266
- package/{src → lib}/Socket/privacy.js +38 -41
- package/{src → lib}/Socket/registration.js +106 -113
- package/{src → lib}/Socket/socket.js +101 -88
- package/{src → lib}/Socket/text-router.js +17 -1
- package/lib/Socket/username.js +243 -0
- package/lib/Store/keyed-db.js +108 -0
- package/{src → lib}/Store/make-in-memory-store.js +104 -6
- package/lib/Types/Mex.js +112 -0
- package/{src → lib}/Types/Newsletter.js +41 -72
- package/{src → lib}/Types/index.js +1 -0
- package/{src → lib}/Utils/chat-utils.js +9 -73
- 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 +42 -0
- package/lib/Utils/crypto.js +155 -0
- package/lib/Utils/curve25519-js.js +275 -0
- package/{src → lib}/Utils/decode-wa-message.js +36 -284
- package/{src → lib}/Utils/event-buffer.js +27 -6
- package/{src → lib}/Utils/generics.js +37 -114
- package/{src → lib}/Utils/index.js +5 -1
- package/lib/Utils/lt-hash.js +39 -0
- package/{src → lib}/Utils/message-retry-manager.js +39 -0
- package/{src → lib}/Utils/messages-media.js +58 -105
- package/{src → lib}/Utils/messages.js +529 -115
- package/lib/Utils/meta-ai-msmsg.js +262 -0
- package/lib/Utils/native-bridge.js +82 -0
- package/{src → lib}/Utils/noise-handler.js +15 -13
- package/{src → lib}/Utils/process-message.js +55 -54
- package/{src → lib}/Utils/reporting-utils.js +2 -2
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/{src → lib}/Utils/signal.js +51 -19
- package/{src → lib}/Utils/stanza-ack.js +2 -36
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/{src → lib}/Utils/tc-token-utils.js +1 -1
- package/{src → lib}/Utils/validate-connection.js +11 -40
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/{src → lib}/WABinary/decode.js +4 -38
- package/lib/WABinary/encode.js +228 -0
- package/{src → lib}/WABinary/generic-utils.js +93 -1
- package/{src → lib}/WABinary/jid-utils.js +3 -16
- package/{src → lib}/WAM/encode.js +1 -1
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/{src → lib}/WAUSync/Protocols/USyncContactProtocol.js +1 -7
- package/{src → lib}/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
- package/{src → lib}/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
- package/{src → lib}/WAUSync/Protocols/USyncFeatureProtocol.js +2 -17
- package/{src → lib}/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
- package/{src → lib}/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
- package/{src → lib}/WAUSync/Protocols/index.js +0 -1
- package/{src → lib}/WAUSync/USyncQuery.js +6 -77
- package/{src → lib}/WAUSync/USyncUser.js +8 -16
- package/{src → lib}/WAUSync/index.js +0 -1
- package/{src → lib}/antiban.js +266 -355
- package/{src → lib}/index.js +2 -2
- package/package.json +19 -16
- package/WAProto/fix-import.js +0 -38
- package/src/Socket/mex.js +0 -47
- package/src/Socket/username.js +0 -234
- package/src/Utils/crypto.js +0 -125
- package/src/Utils/lt-hash.js +0 -10
- package/src/Utils/message-inspect.js +0 -400
- package/src/Utils/meta-ai-msmsg.js +0 -133
- package/src/WABinary/encode.js +0 -58
- package/src/WAUSync/Protocols/USyncBusinessProtocol.js +0 -100
- package/src/WAUSync/USyncBackoff.js +0 -31
- /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
- /package/{src → lib}/Signal/Group/ciphertext-message.js +0 -0
- /package/{src → lib}/Signal/Group/group-session-builder.js +0 -0
- /package/{src → lib}/Signal/Group/index.js +0 -0
- /package/{src → lib}/Signal/Group/sender-key-name.js +0 -0
- /package/{src → lib}/Signal/Group/sender-key-state.js +0 -0
- /package/{src → lib}/Signal/lid-mapping.js +0 -0
- /package/{src → lib}/Socket/Client/index.js +0 -0
- /package/{src → lib}/Socket/Client/types.js +0 -0
- /package/{src → lib}/Socket/Client/websocket.js +0 -0
- /package/{src → lib}/Socket/aigroups.js +0 -0
- /package/{src → lib}/Socket/business.js +0 -0
- /package/{src → lib}/Store/index.js +0 -0
- /package/{src → lib}/Store/make-cache-manager-store.js +0 -0
- /package/{src → lib}/Store/make-ordered-dictionary.js +0 -0
- /package/{src → lib}/Store/object-repository.js +0 -0
- /package/{src → lib}/Types/Auth.js +0 -0
- /package/{src → lib}/Types/Bussines.js +0 -0
- /package/{src → lib}/Types/Call.js +0 -0
- /package/{src → lib}/Types/Chat.js +0 -0
- /package/{src → lib}/Types/Contact.js +0 -0
- /package/{src → lib}/Types/Events.js +0 -0
- /package/{src → lib}/Types/GroupMetadata.js +0 -0
- /package/{src → lib}/Types/Label.js +0 -0
- /package/{src → lib}/Types/LabelAssociation.js +0 -0
- /package/{src → lib}/Types/Message.js +0 -0
- /package/{src → lib}/Types/Product.js +0 -0
- /package/{src → lib}/Types/Signal.js +0 -0
- /package/{src → lib}/Types/Socket.js +0 -0
- /package/{src → lib}/Types/State.js +0 -0
- /package/{src → lib}/Types/USync.js +0 -0
- /package/{src → lib}/Utils/auth-utils.js +0 -0
- /package/{src → lib}/Utils/browser-utils.js +0 -0
- /package/{src → lib}/Utils/business.js +0 -0
- /package/{src → lib}/Utils/consumer-application.js +0 -0
- /package/{src → lib}/Utils/group-history.js +0 -0
- /package/{src → lib}/Utils/history.js +0 -0
- /package/{src → lib}/Utils/identity-change-handler.js +0 -0
- /package/{src → lib}/Utils/jid-display-normalization.js +0 -0
- /package/{src → lib}/Utils/link-preview.js +0 -0
- /package/{src → lib}/Utils/logger.js +0 -0
- /package/{src → lib}/Utils/make-mutex.js +0 -0
- /package/{src → lib}/Utils/message-composer.js +0 -0
- /package/{src → lib}/Utils/offline-node-processor.js +0 -0
- /package/{src → lib}/Utils/pre-key-manager.js +0 -0
- /package/{src → lib}/Utils/sync-action-utils.js +0 -0
- /package/{src → lib}/Utils/use-multi-file-auth-state.js +0 -0
- /package/{src → lib}/Utils/voip-rekey.js +0 -0
- /package/{src → lib}/WABinary/constants.js +0 -0
- /package/{src → lib}/WABinary/index.js +0 -0
- /package/{src → lib}/WABinary/types.js +0 -0
- /package/{src → lib}/WAM/BinaryInfo.js +0 -0
- /package/{src → lib}/WAM/constants.js +0 -0
- /package/{src → lib}/WAM/index.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncLIDProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncPictureProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncSidelistProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -0
package/{src → lib}/index.js
RENAMED
|
@@ -57,9 +57,9 @@ console.log(chalk.bold.cyan(`
|
|
|
57
57
|
¤═―— ⎧ 𝐁𝐀𝐃𝐙𝐙 𝐁𝐀𝐈𝐋𝐄𝐘𝐒 ⎭ ⊱―—═¤
|
|
58
58
|
Information:
|
|
59
59
|
Developer: @badzzne2
|
|
60
|
-
Version:
|
|
60
|
+
Version: 12.0
|
|
61
61
|
Status: Baileys Berhasil Terinstall
|
|
62
|
-
Update date:
|
|
62
|
+
Update date: 09/08/26
|
|
63
63
|
`));
|
|
64
64
|
console.log(chalk.bold.gray("--------------------------------------------\n"));
|
|
65
65
|
console.log(chalk.bold.cyan("Follow Our Telegram Channel To See Update Information: t.me/FoxsSql\n"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@badzz88/baileys",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.1",
|
|
4
4
|
"description": "Baileys Whatsapp Api Modification By Badzz88",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -13,26 +13,24 @@
|
|
|
13
13
|
"automation",
|
|
14
14
|
"md"
|
|
15
15
|
],
|
|
16
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://www.npmjs.com/package/@badzz88/baileys",
|
|
17
17
|
"repository": {
|
|
18
|
-
"url": "
|
|
18
|
+
"url": "https://github.com/package/Badzz88/baileys.giy"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"author": "Badzz88",
|
|
22
|
-
"main": "
|
|
22
|
+
"main": "lib/index.js",
|
|
23
23
|
"files": [
|
|
24
|
-
"
|
|
24
|
+
"lib/**/*",
|
|
25
25
|
"WAProto/**/*",
|
|
26
|
-
"engine-requirements.js"
|
|
27
|
-
"documentation/**/*"
|
|
26
|
+
"engine-requirements.js"
|
|
28
27
|
],
|
|
29
28
|
"scripts": {
|
|
30
29
|
"ncu": "npm-check-updates",
|
|
31
|
-
"format": "prettier --write \"
|
|
30
|
+
"format": "prettier --write \"lib/**/*.{js,json,md}\"",
|
|
32
31
|
"lint": "tsc && eslint src --ext .js",
|
|
33
32
|
"lint:fix": "npm run format && npm run lint -- --fix",
|
|
34
|
-
"test": "jest --runInBand"
|
|
35
|
-
"preinstall": "node ./engine-requirements.js"
|
|
33
|
+
"test": "jest --runInBand"
|
|
36
34
|
},
|
|
37
35
|
"dependencies": {
|
|
38
36
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
@@ -45,11 +43,10 @@
|
|
|
45
43
|
"music-metadata": "^11.12.3",
|
|
46
44
|
"p-queue": "^9.3.0",
|
|
47
45
|
"pino": "^10.3.1",
|
|
48
|
-
"chalk": "^4.1.2",
|
|
49
46
|
"protobufjs": "^7.6.1",
|
|
50
|
-
"
|
|
51
|
-
"whatsapp-rust-bridge
|
|
52
|
-
"
|
|
47
|
+
"ws": "^8.21.0",
|
|
48
|
+
"whatsapp-rust-bridge": "0.5.4",
|
|
49
|
+
"jimp": "^1.6.0"
|
|
53
50
|
},
|
|
54
51
|
"devDependencies": {
|
|
55
52
|
"@eslint/eslintrc": "^3.3.1",
|
|
@@ -77,8 +74,8 @@
|
|
|
77
74
|
},
|
|
78
75
|
"peerDependencies": {
|
|
79
76
|
"audio-decode": "^2.1.3",
|
|
80
|
-
"jimp": "^1.6.0",
|
|
81
77
|
"link-preview-js": "^3.2.0",
|
|
78
|
+
"@img/sharp-wasm32": "^0.35.1",
|
|
82
79
|
"sharp": "^0.32.5"
|
|
83
80
|
},
|
|
84
81
|
"peerDependenciesMeta": {
|
|
@@ -91,12 +88,18 @@
|
|
|
91
88
|
"link-preview-js": {
|
|
92
89
|
"optional": true
|
|
93
90
|
},
|
|
91
|
+
"@img/sharp-wasm32": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
94
|
"sharp": {
|
|
95
95
|
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"whatsapp-rust-bridge": {
|
|
98
|
+
"optional": true
|
|
96
99
|
}
|
|
97
100
|
},
|
|
98
101
|
"packageManager": "yarn@4.9.2",
|
|
99
102
|
"engines": {
|
|
100
103
|
"node": ">=20.0.0"
|
|
101
104
|
}
|
|
102
|
-
}
|
|
105
|
+
}
|
package/WAProto/fix-import.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const { readFileSync, writeFileSync } = require('fs');
|
|
2
|
-
const { exit } = require('process');
|
|
3
|
-
|
|
4
|
-
const FILE = './index.js';
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
let content = readFileSync(FILE, 'utf8');
|
|
8
|
-
|
|
9
|
-
content = content
|
|
10
|
-
.replace(
|
|
11
|
-
/import \* as (\$protobuf) from/g,
|
|
12
|
-
'import $1 from'
|
|
13
|
-
)
|
|
14
|
-
.replace(
|
|
15
|
-
/(['"])protobufjs\/minimal(['"])/g,
|
|
16
|
-
'$1protobufjs/minimal.js$2'
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
writeFileSync(FILE, content, 'utf8');
|
|
20
|
-
|
|
21
|
-
console.log(`
|
|
22
|
-
╔════════════════════════╗
|
|
23
|
-
║ ✅ IMPORTS PATCHED ║
|
|
24
|
-
╠════════════════════════╣
|
|
25
|
-
║ File : ${FILE.padEnd(26)}║
|
|
26
|
-
║ Status : Success ║
|
|
27
|
-
╚════════════════════════╝
|
|
28
|
-
`);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.error(`
|
|
31
|
-
╔════════════════════════╗
|
|
32
|
-
║ ❌ PATCH FAILED
|
|
33
|
-
╠════════════════════════╣
|
|
34
|
-
║ ${err.message}
|
|
35
|
-
╚════════════════════════╝
|
|
36
|
-
`);
|
|
37
|
-
exit(1);
|
|
38
|
-
}
|
package/src/Socket/mex.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.executeWMexQuery = void 0
|
|
4
|
-
const boom_1 = require('@hapi/boom')
|
|
5
|
-
const WABinary_1 = require('../WABinary')
|
|
6
|
-
const wMexQuery = (variables, queryId, query, generateMessageTag) => {
|
|
7
|
-
return query({
|
|
8
|
-
tag: 'iq',
|
|
9
|
-
attrs: {
|
|
10
|
-
id: generateMessageTag(),
|
|
11
|
-
type: 'get',
|
|
12
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
13
|
-
xmlns: 'w:mex'
|
|
14
|
-
},
|
|
15
|
-
content: [
|
|
16
|
-
{
|
|
17
|
-
tag: 'query',
|
|
18
|
-
attrs: { query_id: queryId },
|
|
19
|
-
content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
|
|
25
|
-
const result = await wMexQuery(variables, queryId, query, generateMessageTag)
|
|
26
|
-
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
|
|
27
|
-
if (child?.content) {
|
|
28
|
-
const data = JSON.parse(child.content.toString())
|
|
29
|
-
if (data.errors && data.errors.length > 0) {
|
|
30
|
-
const errorMessages = data.errors.map(err => err.message || 'Unknown error').join(', ')
|
|
31
|
-
const firstError = data.errors[0]
|
|
32
|
-
const errorCode = firstError.extensions?.error_code || 400
|
|
33
|
-
// Log full error payload to aid debugging stale/invalid query_id issues
|
|
34
|
-
console.error('[mex error] query_id=%s code=%s errors=%s', queryId, errorCode, JSON.stringify(data.errors))
|
|
35
|
-
throw new boom_1.Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
|
|
36
|
-
}
|
|
37
|
-
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
38
|
-
if (typeof response !== 'undefined') {
|
|
39
|
-
return response
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const action = (dataPath || '').startsWith('xwa2_')
|
|
43
|
-
? dataPath.substring(5).replace(/_/g, ' ')
|
|
44
|
-
: dataPath?.replace(/_/g, ' ')
|
|
45
|
-
throw new boom_1.Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
|
|
46
|
-
}
|
|
47
|
-
exports.executeWMexQuery = executeWMexQuery
|
package/src/Socket/username.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.makeUsernameSocket = void 0
|
|
4
|
-
|
|
5
|
-
const { executeWMexQuery } = require('./mex')
|
|
6
|
-
const { USyncQuery, USyncUser } = require('../WAUSync')
|
|
7
|
-
const { makeNewsletterSocket } = require('./newsletter')
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* w:mex query IDs for username operations.
|
|
11
|
-
*
|
|
12
|
-
* Source: whatsapp-android-mex_client_persist_ids.json (WA 2.26.26.4 APK assets)
|
|
13
|
-
* Cross-checked: live Frida capture on real device (wa-logger-2.26.26.4.js, 2026-06-30)
|
|
14
|
-
*/
|
|
15
|
-
const USERNAME_QUERY_IDS = {
|
|
16
|
-
CHECK: '26124072630599518', // UsernameCheck
|
|
17
|
-
CHECK_MULTI: '27134626522840286', // UsernameCheckMulti
|
|
18
|
-
SET: '27108705368767936', // UsernameSet
|
|
19
|
-
GET: '32618050064506055', // UsernameGet
|
|
20
|
-
GET_RECOMMENDATIONS: '26077456248616957', // UsernameGetRecommendationsQuery
|
|
21
|
-
PIN_SET: '25529696019976770' // UsernamePinSet
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Source enum values from EnumC141106Vn (UsernameCheck result)
|
|
26
|
-
* and EnumC141056Vi (rejection reasons) confirmed via C164057Wg.java
|
|
27
|
-
*/
|
|
28
|
-
const USERNAME_CHECK_RESULT = {
|
|
29
|
-
SUCCESS: 'SUCCESS',
|
|
30
|
-
INVALID: 'INVALID'
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const USERNAME_SOURCE = {
|
|
34
|
-
FB: 'FB',
|
|
35
|
-
IG: 'IG',
|
|
36
|
-
USER_INPUT: 'USER_INPUT',
|
|
37
|
-
SUGGESTION: 'SUGGESTION'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const makeUsernameSocket = config => {
|
|
41
|
-
const sock = makeNewsletterSocket(config)
|
|
42
|
-
const { query, generateMessageTag, executeUSyncQuery } = sock
|
|
43
|
-
|
|
44
|
-
const mexQuery = (variables, queryId, dataPath) =>
|
|
45
|
-
executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Check whether a username is available.
|
|
49
|
-
*
|
|
50
|
-
* @param {string} username - The @username to check (without @)
|
|
51
|
-
* @param {boolean} includeSuggestions - Request alternative suggestions when taken
|
|
52
|
-
* @returns {object}
|
|
53
|
-
* On success: { available: true, username }
|
|
54
|
-
* On taken: { available: false, username, suggestions: string[], rejectionReasons: string[], suggestionsEligible: boolean }
|
|
55
|
-
* On rate-limit: throws Boom with statusCode 429
|
|
56
|
-
*
|
|
57
|
-
* Confirmed fields from C164057Wg.java:
|
|
58
|
-
* data.xwa2_username_check.result → 'SUCCESS' | 'INVALID'
|
|
59
|
-
* data.xwa2_username_check.suggestions
|
|
60
|
-
* data.xwa2_username_check.rejection_reasons
|
|
61
|
-
* data.xwa2_username_check.suggestions_eligible
|
|
62
|
-
*/
|
|
63
|
-
const checkUsername = async (username, includeSuggestions = true, sessionId) => {
|
|
64
|
-
// session_id ties this check to the subsequent set step — caller can pass one in
|
|
65
|
-
// so both use the same UUID (confirmed from live WA 2.26.26.4 capture).
|
|
66
|
-
const session_id = sessionId || require('crypto').randomUUID()
|
|
67
|
-
const data = await mexQuery(
|
|
68
|
-
{
|
|
69
|
-
username,
|
|
70
|
-
include_suggestions: includeSuggestions,
|
|
71
|
-
session_id,
|
|
72
|
-
source: USERNAME_SOURCE.USER_INPUT
|
|
73
|
-
},
|
|
74
|
-
USERNAME_QUERY_IDS.CHECK,
|
|
75
|
-
'xwa2_username_check'
|
|
76
|
-
)
|
|
77
|
-
if (data?.result === USERNAME_CHECK_RESULT.SUCCESS) {
|
|
78
|
-
return { available: true, username, session_id }
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
available: false,
|
|
82
|
-
username,
|
|
83
|
-
session_id,
|
|
84
|
-
suggestions: data?.suggestions ?? [],
|
|
85
|
-
rejectionReasons: data?.rejection_reasons ?? [],
|
|
86
|
-
suggestionsEligible: data?.suggestions_eligible ?? true
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Set your own username.
|
|
92
|
-
*
|
|
93
|
-
* @param {string} username - The username to set (without @)
|
|
94
|
-
* @param {object} options
|
|
95
|
-
* @param {string} [options.source] - 'USER_INPUT' | 'FB' | 'IG' | 'SUGGESTION'
|
|
96
|
-
* @param {string} [options.sessionId] - Optional session tracking ID
|
|
97
|
-
* @param {string} [options.pin] - Optional PIN for protected usernames
|
|
98
|
-
*
|
|
99
|
-
* Confirmed variables from C1568872p.java A00():
|
|
100
|
-
* username, reserved (bool), session_id, source, pin
|
|
101
|
-
*/
|
|
102
|
-
const setUsername = async (username, options = {}) => {
|
|
103
|
-
const { source = USERNAME_SOURCE.USER_INPUT, sessionId, pin } = options
|
|
104
|
-
// session_id links the check and set steps — generate one if caller doesn't supply it.
|
|
105
|
-
// reserved:true confirmed from live WA 2.26.26.4 capture (was wrongly false before).
|
|
106
|
-
const session_id = sessionId || require('crypto').randomUUID()
|
|
107
|
-
const variables = {
|
|
108
|
-
username,
|
|
109
|
-
reserved: true,
|
|
110
|
-
source,
|
|
111
|
-
session_id,
|
|
112
|
-
...(pin ? { pin } : {})
|
|
113
|
-
}
|
|
114
|
-
return mexQuery(variables, USERNAME_QUERY_IDS.SET, 'xwa2_username_set')
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Delete (unset) your own username.
|
|
119
|
-
*
|
|
120
|
-
* Confirmed from C1568872p.java:
|
|
121
|
-
* str4 = str == null ? "delete" : "set"
|
|
122
|
-
* → sending username=null triggers the delete path on the server.
|
|
123
|
-
*/
|
|
124
|
-
const deleteUsername = async () => {
|
|
125
|
-
return mexQuery({ username: null }, USERNAME_QUERY_IDS.SET, 'xwa2_username_delete')
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Get your own current username.
|
|
130
|
-
*
|
|
131
|
-
* Confirmed from C1568872p.java A02():
|
|
132
|
-
* AbstractC41851rT.A0L(AbstractC130045pa.A0T(), C1363664w.class, "UsernameGet", false)
|
|
133
|
-
*/
|
|
134
|
-
const getMyUsername = async () => {
|
|
135
|
-
const data = await mexQuery({}, USERNAME_QUERY_IDS.GET, 'xwa2_username_get')
|
|
136
|
-
return data?.username ?? null
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Set or delete the PIN that protects your username.
|
|
141
|
-
*
|
|
142
|
-
* @param {string|null} pin - New PIN, or null to delete the PIN
|
|
143
|
-
*
|
|
144
|
-
* Confirmed from MexUsernamePinProtocolApi.java:
|
|
145
|
-
* operation "UsernamePinSet", variable "pin"
|
|
146
|
-
* pin=null triggers the "delete" path on the server.
|
|
147
|
-
*/
|
|
148
|
-
const setUsernamePin = async pin => {
|
|
149
|
-
// pin=null → delete PIN (server interprets empty/null variables as delete)
|
|
150
|
-
const variables = pin != null ? { pin } : {}
|
|
151
|
-
return mexQuery(variables, USERNAME_QUERY_IDS.PIN_SET, 'xwa2_username_pin_set')
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Look up a contact by their @username via USync.
|
|
156
|
-
*
|
|
157
|
-
* Confirmed via USyncContactProtocol.getUserElement():
|
|
158
|
-
* { tag: 'contact', attrs: { username, pin? } }
|
|
159
|
-
*
|
|
160
|
-
* @param {string} username - The username to look up (without @)
|
|
161
|
-
* @param {string} [pin] - Optional PIN if the username is PIN-protected
|
|
162
|
-
* @returns {{ jid, lid?, contact: boolean }|null}
|
|
163
|
-
*/
|
|
164
|
-
const findUserByUsername = async (username, pin) => {
|
|
165
|
-
const usyncQuery = new USyncQuery().withContactProtocol()
|
|
166
|
-
const user = new USyncUser().withUsername(username)
|
|
167
|
-
if (pin) user.withUsernameKey(pin)
|
|
168
|
-
usyncQuery.withUser(user)
|
|
169
|
-
const result = await executeUSyncQuery(usyncQuery)
|
|
170
|
-
if (!result?.list?.length) return null
|
|
171
|
-
const entry = result.list[0]
|
|
172
|
-
return {
|
|
173
|
-
jid: entry.id,
|
|
174
|
-
contact: entry.contact ?? false
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Fetch the username of one or more contacts by their JID.
|
|
180
|
-
* Uses USync with the username protocol.
|
|
181
|
-
*
|
|
182
|
-
* @param {...string} jids - One or more JIDs
|
|
183
|
-
* @returns {Array<{ id, username: string|null }>}
|
|
184
|
-
*/
|
|
185
|
-
const fetchContactUsernames = async (...jids) => {
|
|
186
|
-
const usyncQuery = new USyncQuery().withUsernameProtocol()
|
|
187
|
-
for (const jid of jids) {
|
|
188
|
-
usyncQuery.withUser(new USyncUser().withId(jid))
|
|
189
|
-
}
|
|
190
|
-
const result = await executeUSyncQuery(usyncQuery)
|
|
191
|
-
return result?.list ?? []
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Check multiple usernames for availability at once.
|
|
196
|
-
* @param {string[]} usernames - Array of usernames (without @)
|
|
197
|
-
*/
|
|
198
|
-
const checkUsernameMulti = async usernames => {
|
|
199
|
-
const data = await mexQuery(
|
|
200
|
-
{ usernames },
|
|
201
|
-
USERNAME_QUERY_IDS.CHECK_MULTI,
|
|
202
|
-
'xwa2_username_check_multi'
|
|
203
|
-
)
|
|
204
|
-
return data
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Fetch username recommendations for the current user.
|
|
209
|
-
* @param {string} [source] - Source hint: 'FB' | 'IG' | 'USER_INPUT'
|
|
210
|
-
*/
|
|
211
|
-
const getUsernameRecommendations = async (source = null) => {
|
|
212
|
-
const variables = {}
|
|
213
|
-
if (source) variables.source = source
|
|
214
|
-
return mexQuery(variables, USERNAME_QUERY_IDS.GET_RECOMMENDATIONS, 'xwa2_username_get_recommendations')
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
...sock,
|
|
219
|
-
checkUsername,
|
|
220
|
-
checkUsernameMulti,
|
|
221
|
-
setUsername,
|
|
222
|
-
deleteUsername,
|
|
223
|
-
getMyUsername,
|
|
224
|
-
getUsernameRecommendations,
|
|
225
|
-
setUsernamePin,
|
|
226
|
-
findUserByUsername,
|
|
227
|
-
fetchContactUsernames,
|
|
228
|
-
USERNAME_QUERY_IDS,
|
|
229
|
-
USERNAME_CHECK_RESULT,
|
|
230
|
-
USERNAME_SOURCE
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
exports.makeUsernameSocket = makeUsernameSocket
|
package/src/Utils/crypto.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.signedKeyPair =
|
|
4
|
-
exports.Curve =
|
|
5
|
-
exports.generateSignalPubKey =
|
|
6
|
-
exports.getEnabledFeatures =
|
|
7
|
-
exports.hkdf =
|
|
8
|
-
exports.md5 =
|
|
9
|
-
void 0
|
|
10
|
-
exports.aesEncryptGCM = aesEncryptGCM
|
|
11
|
-
exports.aesDecryptGCM = aesDecryptGCM
|
|
12
|
-
exports.aesEncryptCTR = aesEncryptCTR
|
|
13
|
-
exports.aesDecryptCTR = aesDecryptCTR
|
|
14
|
-
exports.aesDecrypt = aesDecrypt
|
|
15
|
-
exports.aesDecryptWithIV = aesDecryptWithIV
|
|
16
|
-
exports.aesEncrypt = aesEncrypt
|
|
17
|
-
exports.aesEncrypWithIV = aesEncrypWithIV
|
|
18
|
-
exports.hmacSign = hmacSign
|
|
19
|
-
exports.sha256 = sha256
|
|
20
|
-
exports.derivePairingCodeKey = derivePairingCodeKey
|
|
21
|
-
const { subtle } = globalThis.crypto
|
|
22
|
-
const Defaults_1 = require('../Defaults')
|
|
23
|
-
const rb = require('whatsapp-rust-bridge-baron')
|
|
24
|
-
|
|
25
|
-
// ── Re-exports from Rust ─────────────────────────────────────────────────────
|
|
26
|
-
Object.defineProperty(exports, 'md5', { enumerable: true, get: () => rb.md5 })
|
|
27
|
-
Object.defineProperty(exports, 'hkdf', { enumerable: true, get: () => rb.hkdf })
|
|
28
|
-
Object.defineProperty(exports, 'getEnabledFeatures', { enumerable: true, get: () => rb.getEnabledFeatures })
|
|
29
|
-
|
|
30
|
-
// ── Signal pub key helper ─────────────────────────────────────────────────────
|
|
31
|
-
const generateSignalPubKey = pubKey =>
|
|
32
|
-
pubKey.length === 33 ? pubKey : Buffer.concat([Defaults_1.KEY_BUNDLE_TYPE, pubKey])
|
|
33
|
-
exports.generateSignalPubKey = generateSignalPubKey
|
|
34
|
-
|
|
35
|
-
// ── Curve — fully delegated to Rust bridge ────────────────────────────────────
|
|
36
|
-
exports.Curve = {
|
|
37
|
-
generateKeyPair: () => {
|
|
38
|
-
const pair = rb.generateKeyPair()
|
|
39
|
-
return {
|
|
40
|
-
private: Buffer.from(pair.privKey),
|
|
41
|
-
public: Buffer.from(pair.pubKey).subarray(1) // strip 0x05 prefix
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
sharedKey: (privateKey, publicKey) => Buffer.from(rb.calculateAgreement(generateSignalPubKey(publicKey), privateKey)),
|
|
45
|
-
sign: (privateKey, buf) => rb.calculateSignature(privateKey, buf),
|
|
46
|
-
verify: (pubKey, message, signature) => {
|
|
47
|
-
try {
|
|
48
|
-
return rb.verifySignature(generateSignalPubKey(pubKey), message, signature)
|
|
49
|
-
} catch {
|
|
50
|
-
return false
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const signedKeyPair = (identityKeyPair, keyId) => {
|
|
56
|
-
const preKey = exports.Curve.generateKeyPair()
|
|
57
|
-
const pubKey = generateSignalPubKey(preKey.public)
|
|
58
|
-
const signature = exports.Curve.sign(identityKeyPair.private, pubKey)
|
|
59
|
-
return { keyPair: preKey, signature, keyId }
|
|
60
|
-
}
|
|
61
|
-
exports.signedKeyPair = signedKeyPair
|
|
62
|
-
|
|
63
|
-
// ── AES-256-GCM ───────────────────────────────────────────────────────────────
|
|
64
|
-
function aesEncryptGCM(plaintext, key, iv, additionalData) {
|
|
65
|
-
return Buffer.from(rb.aesEncryptGCM(plaintext, key, iv, additionalData))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function aesDecryptGCM(ciphertext, key, iv, additionalData) {
|
|
69
|
-
return Buffer.from(rb.aesDecryptGCM(ciphertext, key, iv, additionalData))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ── AES-256-CTR ───────────────────────────────────────────────────────────────
|
|
73
|
-
function aesEncryptCTR(plaintext, key, iv) {
|
|
74
|
-
return Buffer.from(rb.aesEncryptCTR(plaintext, key, iv))
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function aesDecryptCTR(ciphertext, key, iv) {
|
|
78
|
-
return Buffer.from(rb.aesDecryptCTR(ciphertext, key, iv))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ── AES-256-CBC ───────────────────────────────────────────────────────────────
|
|
82
|
-
function aesDecrypt(buffer, key) {
|
|
83
|
-
return Buffer.from(rb.aesDecrypt(buffer, key))
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function aesDecryptWithIV(buffer, key, IV) {
|
|
87
|
-
return Buffer.from(rb.aesDecryptWithIV(buffer, key, IV))
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function aesEncrypt(buffer, key) {
|
|
91
|
-
return Buffer.from(rb.aesEncrypt(buffer, key))
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function aesEncrypWithIV(buffer, key, IV) {
|
|
95
|
-
return Buffer.from(rb.aesEncrypWithIV(buffer, key, IV))
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// ── HMAC-SHA256 ───────────────────────────────────────────────────────────────
|
|
99
|
-
function hmacSign(buffer, key, variant = 'sha256') {
|
|
100
|
-
if (variant !== 'sha256') {
|
|
101
|
-
// fallback for non-SHA256 variants (rare edge case)
|
|
102
|
-
const { createHmac } = require('crypto')
|
|
103
|
-
return createHmac(variant, key).update(buffer).digest()
|
|
104
|
-
}
|
|
105
|
-
return Buffer.from(rb.hmacSign(buffer, key))
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ── SHA-256 ───────────────────────────────────────────────────────────────────
|
|
109
|
-
function sha256(buffer) {
|
|
110
|
-
return Buffer.from(rb.sha256(buffer))
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ── PBKDF2 pairing code key ───────────────────────────────────────────────────
|
|
114
|
-
async function derivePairingCodeKey(pairingCode, salt) {
|
|
115
|
-
const encoder = new TextEncoder()
|
|
116
|
-
const pairingCodeBuffer = encoder.encode(pairingCode)
|
|
117
|
-
const saltBuffer = new Uint8Array(salt instanceof Uint8Array ? salt : new Uint8Array(salt))
|
|
118
|
-
const keyMaterial = await subtle.importKey('raw', pairingCodeBuffer, { name: 'PBKDF2' }, false, ['deriveBits'])
|
|
119
|
-
const derivedBits = await subtle.deriveBits(
|
|
120
|
-
{ name: 'PBKDF2', salt: saltBuffer, iterations: 2 << 16, hash: 'SHA-256' },
|
|
121
|
-
keyMaterial,
|
|
122
|
-
256
|
|
123
|
-
)
|
|
124
|
-
return Buffer.from(derivedBits)
|
|
125
|
-
}
|
package/src/Utils/lt-hash.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.LT_HASH_ANTI_TAMPERING = void 0
|
|
4
|
-
const whatsapp_rust_bridge_1 = require('whatsapp-rust-bridge-baron')
|
|
5
|
-
/**
|
|
6
|
-
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
7
|
-
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
8
|
-
* if the same series of mutations was made sequentially.
|
|
9
|
-
*/
|
|
10
|
-
exports.LT_HASH_ANTI_TAMPERING = new whatsapp_rust_bridge_1.LTHashAntiTampering()
|