@hbmodsofc/baileys 2.3.0 → 2.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/lib/Defaults/index.js +1 -1
- package/lib/Socket/chats.js +320 -265
- package/lib/Socket/hbmods.d.ts +18 -17
- package/lib/Socket/hbmods.js +480 -1
- package/lib/Socket/messages-send.js +909 -1
- package/lib/Socket/newsletter.js +372 -1
- package/lib/Socket/socket.js +680 -1
- package/lib/Utils/generics.js +9 -4
- package/lib/Utils/generics.js.bak +433 -0
- package/lib/Utils/messages.js +2 -2
- package/lib/Utils/validate-connection.js +2 -0
- package/lib/Utils/validate-connection.js.bak +237 -0
- package/lib/index.js +84 -1
- package/package.json +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const WAProto_1 = require("../../WAProto");
|
|
7
|
+
const Defaults_1 = require("../Defaults");
|
|
8
|
+
const WABinary_1 = require("../WABinary");
|
|
9
|
+
const crypto_2 = require("./crypto");
|
|
10
|
+
const generics_1 = require("./generics");
|
|
11
|
+
const signal_1 = require("./signal");
|
|
12
|
+
|
|
13
|
+
const getUserAgent = (config) => {
|
|
14
|
+
return {
|
|
15
|
+
appVersion: {
|
|
16
|
+
primary: config.version[0],
|
|
17
|
+
secondary: config.version[1],
|
|
18
|
+
tertiary: config.version[2],
|
|
19
|
+
},
|
|
20
|
+
platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
21
|
+
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
22
|
+
osVersion: '0.1',
|
|
23
|
+
device: 'Desktop',
|
|
24
|
+
osBuildNumber: '0.1',
|
|
25
|
+
localeLanguageIso6391: 'en',
|
|
26
|
+
mnc: '000',
|
|
27
|
+
mcc: '000',
|
|
28
|
+
localeCountryIso31661Alpha2: config.countryCode || 'US'
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.Browsers = {
|
|
33
|
+
iOS: (browser) => ["ios", browser, "18.2"],
|
|
34
|
+
ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
|
|
35
|
+
macOS: (browser) => ['Mac OS', browser, '14.4.1'],
|
|
36
|
+
baileys: (browser) => ['Baileys', browser, '6.5.0'],
|
|
37
|
+
windows: (browser) => ['Windows', browser, '10.0.22631']
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const PLATFORM_MAP = {
|
|
41
|
+
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
42
|
+
'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getWebInfo = (config) => {
|
|
46
|
+
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
47
|
+
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]] && config.browser[1] === 'Desktop') {
|
|
48
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
49
|
+
}
|
|
50
|
+
return { webSubPlatform };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getClientPayload = (config) => {
|
|
54
|
+
const payload = {
|
|
55
|
+
connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
56
|
+
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
57
|
+
userAgent: getUserAgent(config),
|
|
58
|
+
};
|
|
59
|
+
payload.webInfo = getWebInfo(config);
|
|
60
|
+
return payload;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const generateLoginNode = (userJid, config) => {
|
|
64
|
+
const { user, device } = (0, WABinary_1.jidDecode)(userJid);
|
|
65
|
+
const payload = {
|
|
66
|
+
...getClientPayload(config),
|
|
67
|
+
passive: true,
|
|
68
|
+
pull: true,
|
|
69
|
+
username: +user,
|
|
70
|
+
device: device,
|
|
71
|
+
lidDbMigrated: false
|
|
72
|
+
};
|
|
73
|
+
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
74
|
+
};
|
|
75
|
+
exports.generateLoginNode = generateLoginNode;
|
|
76
|
+
|
|
77
|
+
const getPlatformType = (platform) => {
|
|
78
|
+
const platformType = platform.toUpperCase();
|
|
79
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
83
|
+
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
84
|
+
.update(config.version.join('.'))
|
|
85
|
+
.digest();
|
|
86
|
+
|
|
87
|
+
const companion = {
|
|
88
|
+
os: config.browser[0],
|
|
89
|
+
platformType: getPlatformType(config.browser[1]),
|
|
90
|
+
requireFullSync: config.syncFullHistory,
|
|
91
|
+
historySyncConfig: {
|
|
92
|
+
storageQuotaMb: 10240,
|
|
93
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
94
|
+
recentSyncDaysLimit: undefined,
|
|
95
|
+
supportCallLogHistory: false,
|
|
96
|
+
supportBotUserAgentChatHistory: true,
|
|
97
|
+
supportCagReactionsAndPolls: true,
|
|
98
|
+
supportBizHostedMsg: true,
|
|
99
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
100
|
+
supportHostedGroupMsg: true,
|
|
101
|
+
supportFbidBotChatHistory: true,
|
|
102
|
+
supportAddOnHistorySyncMigration: undefined,
|
|
103
|
+
supportMessageAssociation: true,
|
|
104
|
+
supportGroupHistory: false,
|
|
105
|
+
onDemandReady: undefined,
|
|
106
|
+
supportGuestChat: undefined
|
|
107
|
+
},
|
|
108
|
+
version: {
|
|
109
|
+
primary: 10,
|
|
110
|
+
secondary: 15,
|
|
111
|
+
tertiary: 7
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
|
|
116
|
+
|
|
117
|
+
const registerPayload = {
|
|
118
|
+
...getClientPayload(config),
|
|
119
|
+
passive: false,
|
|
120
|
+
pull: false,
|
|
121
|
+
devicePairingData: {
|
|
122
|
+
buildHash: appVersionBuf,
|
|
123
|
+
deviceProps: companionProto,
|
|
124
|
+
eRegid: (0, generics_1.encodeBigEndian)(registrationId),
|
|
125
|
+
eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
|
|
126
|
+
eIdent: signedIdentityKey.public,
|
|
127
|
+
eSkeyId: (0, generics_1.encodeBigEndian)(signedPreKey.keyId, 3),
|
|
128
|
+
eSkeyVal: signedPreKey.keyPair.public,
|
|
129
|
+
eSkeySig: signedPreKey.signature,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
|
|
133
|
+
};
|
|
134
|
+
exports.generateRegistrationNode = generateRegistrationNode;
|
|
135
|
+
|
|
136
|
+
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
137
|
+
const msgId = stanza.attrs.id;
|
|
138
|
+
const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
|
|
139
|
+
const deviceIdentityNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
|
|
140
|
+
const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
|
|
141
|
+
const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
|
|
142
|
+
const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
|
|
143
|
+
|
|
144
|
+
if (!deviceIdentityNode || !deviceNode) {
|
|
145
|
+
throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const bizName = businessNode?.attrs.name;
|
|
149
|
+
const jid = deviceNode.attrs.jid;
|
|
150
|
+
const lid = deviceNode.attrs.lid;
|
|
151
|
+
|
|
152
|
+
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
153
|
+
|
|
154
|
+
let hmacPrefix = Buffer.from([]);
|
|
155
|
+
if (accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED) {
|
|
156
|
+
hmacPrefix = Buffer.from([0x06, 0x05]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
160
|
+
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
161
|
+
throw new boom_1.Boom('Invalid account signature');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
|
|
165
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
166
|
+
|
|
167
|
+
const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(deviceDetails);
|
|
168
|
+
|
|
169
|
+
const accountSignaturePrefix = deviceIdentity.deviceType === WAProto_1.proto.ADVEncryptionType.HOSTED
|
|
170
|
+
? Buffer.from([0x06, 0x05])
|
|
171
|
+
: Buffer.from([0x06, 0x00]);
|
|
172
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
|
|
173
|
+
|
|
174
|
+
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
175
|
+
throw new boom_1.Boom('Failed to verify account signature');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const deviceMsg = Buffer.concat([
|
|
179
|
+
Buffer.from([0x06, 0x01]),
|
|
180
|
+
deviceDetails,
|
|
181
|
+
signedIdentityKey.public,
|
|
182
|
+
accountSignatureKey
|
|
183
|
+
]);
|
|
184
|
+
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
185
|
+
|
|
186
|
+
const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
|
|
187
|
+
const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
|
|
188
|
+
|
|
189
|
+
const reply = {
|
|
190
|
+
tag: 'iq',
|
|
191
|
+
attrs: {
|
|
192
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
193
|
+
type: 'result',
|
|
194
|
+
id: msgId,
|
|
195
|
+
},
|
|
196
|
+
content: [
|
|
197
|
+
{
|
|
198
|
+
tag: 'pair-device-sign',
|
|
199
|
+
attrs: {},
|
|
200
|
+
content: [
|
|
201
|
+
{
|
|
202
|
+
tag: 'device-identity',
|
|
203
|
+
attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
|
|
204
|
+
content: accountEnc
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const authUpdate = {
|
|
212
|
+
account,
|
|
213
|
+
me: { id: jid, name: bizName, lid },
|
|
214
|
+
signalIdentities: [
|
|
215
|
+
...(signalIdentities || []),
|
|
216
|
+
identity
|
|
217
|
+
],
|
|
218
|
+
platform: platformNode?.attrs.name
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
creds: authUpdate,
|
|
223
|
+
reply
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
227
|
+
|
|
228
|
+
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
229
|
+
account = { ...account };
|
|
230
|
+
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
231
|
+
account.accountSignatureKey = null;
|
|
232
|
+
}
|
|
233
|
+
return WAProto_1.proto.ADVSignedDeviceIdentity
|
|
234
|
+
.encode(account)
|
|
235
|
+
.finish();
|
|
236
|
+
};
|
|
237
|
+
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|
package/lib/index.js
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
console.log();
|
|
5
|
+
console.log(chalk.hex('#00ffea')('┌──────────────────────────────────────────┐'));
|
|
6
|
+
console.log(
|
|
7
|
+
chalk.hex('#00ffea')('│') +
|
|
8
|
+
chalk.hex('#39ff14').bold(' H B W A B O T S Y S T E M ') +
|
|
9
|
+
chalk.hex('#00ffea')('│')
|
|
10
|
+
);
|
|
11
|
+
console.log(chalk.hex('#00ffea')('└──────────────────────────────────────────┘'));
|
|
12
|
+
console.log();
|
|
13
|
+
|
|
14
|
+
console.log(
|
|
15
|
+
chalk.hex('#39ff14')('> ') +
|
|
16
|
+
chalk.hex('#00ffea')('Library Author : ') +
|
|
17
|
+
chalk.hex('#39ff14').bold('HBMods-OFC')
|
|
18
|
+
);
|
|
19
|
+
console.log(
|
|
20
|
+
chalk.hex('#39ff14')('> ') +
|
|
21
|
+
chalk.hex('#00ffea')('Instagram : ') +
|
|
22
|
+
chalk.hex('#ff00ff').bold('Herbert_Suantak2')
|
|
23
|
+
);
|
|
24
|
+
console.log(
|
|
25
|
+
chalk.hex('#39ff14')('> ') +
|
|
26
|
+
chalk.hex('#00ffea')('YouTube : ') +
|
|
27
|
+
chalk.hex('#ff3131').bold('HBMods-OFC')
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
console.log();
|
|
31
|
+
console.log(
|
|
32
|
+
chalk.hex('#39ff14').bold('>> ') +
|
|
33
|
+
chalk.hex('#00ffea').bold('Thank you for using this library. You are part of the system.')
|
|
34
|
+
);
|
|
35
|
+
console.log(
|
|
36
|
+
chalk.hex('#39ff14').bold('>> ') +
|
|
37
|
+
chalk.hex('#00ffea').bold('Initializing modules... Complete.\n\n')
|
|
38
|
+
);
|
|
39
|
+
console.log();
|
|
40
|
+
|
|
41
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
42
|
+
if (k2 === undefined) k2 = k;
|
|
43
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
44
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
45
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
46
|
+
}
|
|
47
|
+
Object.defineProperty(o, k2, desc);
|
|
48
|
+
}) : (function(o, m, k, k2) {
|
|
49
|
+
if (k2 === undefined) k2 = k;
|
|
50
|
+
o[k2] = m[k];
|
|
51
|
+
}));
|
|
52
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
53
|
+
for (var p in m)
|
|
54
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
55
|
+
__createBinding(exports, m, p);
|
|
56
|
+
};
|
|
57
|
+
var __importDefault = (this && this.__importDefault) || function(mod) {
|
|
58
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.proto = exports.makeWASocket = void 0;
|
|
63
|
+
|
|
64
|
+
const WAProto_1 = require("../WAProto");
|
|
65
|
+
Object.defineProperty(exports, "proto", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function() {
|
|
68
|
+
return WAProto_1.proto;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const Socket_1 = __importDefault(require("./Socket"));
|
|
73
|
+
exports.makeWASocket = Socket_1.default;
|
|
74
|
+
|
|
75
|
+
__exportStar(require("../WAProto"), exports);
|
|
76
|
+
__exportStar(require("./Utils"), exports);
|
|
77
|
+
__exportStar(require("./Types"), exports);
|
|
78
|
+
__exportStar(require("./Store"), exports);
|
|
79
|
+
__exportStar(require("./Defaults"), exports);
|
|
80
|
+
__exportStar(require("./WABinary"), exports);
|
|
81
|
+
__exportStar(require("./WAM"), exports);
|
|
82
|
+
__exportStar(require("./WAUSync"), exports);
|
|
83
|
+
|
|
84
|
+
exports.default = Socket_1.default;
|