@nexustechpro/baileys 2.0.5 → 2.0.6
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/WAProto/index.js +22 -18
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +7 -6
- package/lib/Signal/libsignal.js +65 -50
- package/lib/Socket/chats.js +64 -57
- package/lib/Socket/index.js +2 -3
- package/lib/Socket/messages-recv.js +227 -41
- package/lib/Socket/messages-send.js +79 -117
- package/lib/Socket/nexus-handler.js +325 -90
- package/lib/Socket/registration.js +50 -33
- package/lib/Socket/socket.js +232 -69
- package/lib/Types/Newsletter.js +37 -29
- package/lib/Types/State.js +43 -0
- package/lib/Utils/auth-utils.js +2 -2
- package/lib/Utils/chat-utils.js +48 -16
- package/lib/Utils/companion-reg-client-utils.js +34 -0
- package/lib/Utils/decode-wa-message.js +40 -8
- package/lib/Utils/generics.js +5 -7
- package/lib/Utils/index.js +4 -0
- package/lib/Utils/link-preview.js +10 -0
- package/lib/Utils/messages-media.js +426 -382
- package/lib/Utils/messages.js +602 -487
- package/lib/Utils/process-message.js +53 -35
- package/lib/Utils/reporting-utils.js +155 -0
- package/lib/Utils/signal.js +134 -104
- package/lib/Utils/sync-action-utils.js +33 -0
- package/lib/Utils/tc-token-utils.js +162 -0
- package/lib/WABinary/constants.js +6 -0
- package/lib/WABinary/index.js +1 -0
- package/lib/index.js +2 -3
- package/package.json +6 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import { MOBILE_TOKEN, MOBILE_REGISTRATION_ENDPOINT, MOBILE_USERAGENT, REGISTRATION_PUBLIC_KEY } from '../Defaults/index.js'
|
|
4
|
-
import { md5, Curve, aesEncryptGCM } from '../Utils/
|
|
3
|
+
import { MOBILE_TOKEN, MOBILE_REGISTRATION_ENDPOINT, MOBILE_USERAGENT, REGISTRATION_PUBLIC_KEY, GRAPHQL_ENDPOINT, GRAPHQL_ACCESS_TOKEN, GRAPHQL_BAN_STATUS_DOC_ID } from '../Defaults/index.js'
|
|
4
|
+
import { md5, Curve, aesEncryptGCM } from '../Utils/index.js';
|
|
5
5
|
import { jidEncode } from '../WABinary/index.js';
|
|
6
6
|
import { makeCommunitiesSocket } from './communities.js';
|
|
7
7
|
|
|
@@ -69,6 +69,22 @@ const makeRegistrationSocket = (config) => {
|
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
async function getBanDetails(appealToken) {
|
|
73
|
+
const res = await axios.post(GRAPHQL_ENDPOINT, {
|
|
74
|
+
variables: JSON.stringify({ app_id: 'dev.app.id', request_token: appealToken }),
|
|
75
|
+
access_token: GRAPHQL_ACCESS_TOKEN,
|
|
76
|
+
doc_id: GRAPHQL_BAN_STATUS_DOC_ID,
|
|
77
|
+
lang: 'en_GB',
|
|
78
|
+
'Content-Type': 'application/json'
|
|
79
|
+
}, {
|
|
80
|
+
headers: {
|
|
81
|
+
'User-Agent': MOBILE_USERAGENT,
|
|
82
|
+
'Content-Type': 'application/json'
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
return res.data?.data?.whatsapp_support_ban_appeal_status || null
|
|
86
|
+
}
|
|
87
|
+
|
|
72
88
|
function registrationParams(params) {
|
|
73
89
|
const e_regid = Buffer.alloc(4);
|
|
74
90
|
e_regid.writeInt32BE(params.registrationId);
|
|
@@ -76,33 +92,33 @@ function registrationParams(params) {
|
|
|
76
92
|
const e_skey_id = Buffer.alloc(3);
|
|
77
93
|
e_skey_id.writeInt16BE(params.signedPreKey.keyId);
|
|
78
94
|
|
|
95
|
+
// ✅ Clean BEFORE token generation
|
|
79
96
|
params.phoneNumberCountryCode = params.phoneNumberCountryCode.replace('+', '').trim();
|
|
80
97
|
params.phoneNumberNationalNumber = params.phoneNumberNationalNumber.replace(/[/\-\s)(]/g, '').trim();
|
|
81
98
|
|
|
82
99
|
return {
|
|
83
|
-
cc:
|
|
84
|
-
in:
|
|
85
|
-
Rc:
|
|
86
|
-
lg:
|
|
87
|
-
lc:
|
|
88
|
-
mistyped:
|
|
89
|
-
authkey:
|
|
90
|
-
e_regid:
|
|
91
|
-
e_keytype:
|
|
92
|
-
e_ident:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
token: md5(Buffer.concat([MOBILE_TOKEN, Buffer.from(params.phoneNumberNationalNumber)])).toString('hex'),
|
|
100
|
+
cc: params.phoneNumberCountryCode,
|
|
101
|
+
in: params.phoneNumberNationalNumber,
|
|
102
|
+
Rc: '0',
|
|
103
|
+
lg: 'en',
|
|
104
|
+
lc: 'GB',
|
|
105
|
+
mistyped: '6',
|
|
106
|
+
authkey: Buffer.from(params.noiseKey.public).toString('base64url'),
|
|
107
|
+
e_regid: e_regid.toString('base64url'),
|
|
108
|
+
e_keytype: 'BQ',
|
|
109
|
+
e_ident: Buffer.from(params.signedIdentityKey.public).toString('base64url'),
|
|
110
|
+
e_skey_id: e_skey_id.toString('base64url'),
|
|
111
|
+
e_skey_val: Buffer.from(params.signedPreKey.keyPair.public).toString('base64url'),
|
|
112
|
+
e_skey_sig: Buffer.from(params.signedPreKey.signature).toString('base64url'),
|
|
113
|
+
fdid: params.phoneId,
|
|
114
|
+
network_ratio_type: '1',
|
|
115
|
+
expid: params.deviceId,
|
|
116
|
+
simnum: '1',
|
|
117
|
+
hasinrc: '1',
|
|
118
|
+
pid: Math.floor(Math.random() * 1000).toString(),
|
|
119
|
+
id: convertBufferToUrlHex(params.identityId),
|
|
120
|
+
backup_token: convertBufferToUrlHex(params.backupToken),
|
|
121
|
+
token: Buffer.from(md5(Buffer.concat([MOBILE_TOKEN, Buffer.from(params.phoneNumberNationalNumber)]))).toString('hex'),
|
|
106
122
|
fraud_checkpoint_code: params.captcha,
|
|
107
123
|
};
|
|
108
124
|
}
|
|
@@ -114,13 +130,13 @@ function mobileRegisterCode(params, fetchOptions) {
|
|
|
114
130
|
return mobileRegisterFetch('/code', {
|
|
115
131
|
params: {
|
|
116
132
|
...registrationParams(params),
|
|
117
|
-
mcc:
|
|
118
|
-
mnc:
|
|
133
|
+
mcc: `${params.phoneNumberMobileCountryCode}`.padStart(3, '0'),
|
|
134
|
+
mnc: `${params.phoneNumberMobileNetworkCode || '001'}`.padStart(3, '0'),
|
|
119
135
|
sim_mcc: '000',
|
|
120
136
|
sim_mnc: '000',
|
|
121
|
-
method:
|
|
122
|
-
reason:
|
|
123
|
-
hasav:
|
|
137
|
+
method: params?.method || 'sms',
|
|
138
|
+
reason: '',
|
|
139
|
+
hasav: '1',
|
|
124
140
|
},
|
|
125
141
|
...fetchOptions,
|
|
126
142
|
});
|
|
@@ -148,8 +164,8 @@ async function mobileRegister(params, fetchOptions) {
|
|
|
148
164
|
*/
|
|
149
165
|
function mobileRegisterEncrypt(data) {
|
|
150
166
|
const keypair = Curve.generateKeyPair();
|
|
151
|
-
const key
|
|
152
|
-
const buffer
|
|
167
|
+
const key = Curve.sharedKey(keypair.private, REGISTRATION_PUBLIC_KEY);
|
|
168
|
+
const buffer = aesEncryptGCM(Buffer.from(data), new Uint8Array(key), Buffer.alloc(12), Buffer.alloc(0));
|
|
153
169
|
|
|
154
170
|
return Buffer.concat([Buffer.from(keypair.public), buffer]).toString('base64url');
|
|
155
171
|
}
|
|
@@ -194,4 +210,5 @@ export {
|
|
|
194
210
|
mobileRegister,
|
|
195
211
|
mobileRegisterEncrypt,
|
|
196
212
|
mobileRegisterFetch,
|
|
197
|
-
|
|
213
|
+
getBanDetails
|
|
214
|
+
}
|