socketon 0.30.7 → 1.31.2-rc
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 +175 -87
- package/lib/Defaults/index.js +1 -1
- package/lib/Socket/business.d.ts +1 -1
- package/lib/Socket/chats.d.ts +1 -1
- package/lib/Socket/groups.d.ts +1 -1
- package/lib/Socket/index.d.ts +1 -1
- package/lib/Socket/messages-send.d.ts +1 -1
- package/lib/Socket/messages-send.js +1 -1
- package/lib/Socket/newsletter.d.ts +1 -1
- package/lib/Socket/newsletter.js +98 -26
- package/lib/Socket/registration.d.ts +1 -1
- package/lib/Socket/socket.d.ts +1 -1
- package/lib/Socket/socket.js +42 -22
- package/lib/Socket/usync.d.ts +1 -1
- package/lib/Utils/generics.js +10 -82
- package/lib/Utils/generics.js.bak +433 -0
- package/lib/Utils/messages.js +33 -0
- package/lib/Utils/validate-connection.js +2 -0
- package/lib/Utils/validate-connection.js.bak +237 -0
- package/lib/index.js +4 -5
- package/package.json +27 -23
|
@@ -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
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const chalk = require("chalk");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
console.log(chalk.
|
|
7
|
-
console.log(chalk.
|
|
5
|
+
const packageInfo = require('../package.json');
|
|
6
|
+
console.log(chalk.magentaBright.bold(`\n© Socketon v${packageInfo.version} - 2025 By IbraDecode`));
|
|
7
|
+
console.log(chalk.cyan(`Need Help? WhatsApp: +31617786379`));
|
|
8
8
|
console.log(chalk.gray("------------------------------\n"));
|
|
9
9
|
|
|
10
10
|
|
|
@@ -17,8 +17,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
17
17
|
Object.defineProperty(o, k2, desc);
|
|
18
18
|
}) : (function(o, m, k, k2) {
|
|
19
19
|
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] =
|
|
21
|
-
m[k];
|
|
20
|
+
o[k2] = m[k];
|
|
22
21
|
}));
|
|
23
22
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
24
23
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
package/package.json
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
2
|
+
"name": "socketon",
|
|
3
|
+
"version": "1.31.2-rc",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"tag": "rc"
|
|
6
|
+
},
|
|
7
|
+
"description": "WhatsApp API Library - Socketon By IbraDecode & Socketon Community",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"whatsapp",
|
|
10
|
+
"socketon",
|
|
11
|
+
"baileys",
|
|
12
|
+
"whatsapp-web",
|
|
13
|
+
"whatsapp-chat",
|
|
14
|
+
"whatsapp-group",
|
|
15
|
+
"botwa",
|
|
16
|
+
"whatsapp-bot",
|
|
17
|
+
"whatsapp-api",
|
|
18
|
+
"socketon-whatsapp"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/IbraDecode/socketon",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/lbraDecode/socketon.git"
|
|
20
24
|
},
|
|
21
25
|
"license": "MIT",
|
|
22
|
-
"author": "
|
|
26
|
+
"author": "Ibra Decode",
|
|
23
27
|
"main": "lib/index.js",
|
|
24
28
|
"types": "lib/index.d.ts",
|
|
25
29
|
"files": [
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
"futoin-hkdf": "^1.5.1",
|
|
55
59
|
"libphonenumber-js": "^1.10.20",
|
|
56
60
|
"lodash": "^4.17.21",
|
|
57
|
-
"libsignal": "npm:@
|
|
61
|
+
"libsignal": "npm:@skyzopedia/libsignal-node",
|
|
58
62
|
"music-metadata": "^7.12.3",
|
|
59
63
|
"node-cache": "^5.1.2",
|
|
60
64
|
"node-fetch": "^2.6.1",
|
|
@@ -71,9 +75,9 @@
|
|
|
71
75
|
"@types/sharp": "^0.29.4",
|
|
72
76
|
"@types/ws": "^8.0.0",
|
|
73
77
|
"conventional-changelog-cli": "^2.2.2",
|
|
74
|
-
"eslint": "^
|
|
78
|
+
"eslint": "^9.0.0",
|
|
75
79
|
"jest": "^27.0.6",
|
|
76
|
-
"jimp": "^0.
|
|
80
|
+
"jimp": "^0.22.12",
|
|
77
81
|
"link-preview-js": "^3.0.0",
|
|
78
82
|
"open": "^8.4.2",
|
|
79
83
|
"qrcode-terminal": "^0.12.0",
|
|
@@ -86,7 +90,7 @@
|
|
|
86
90
|
"json": "^11.0.0"
|
|
87
91
|
},
|
|
88
92
|
"peerDependencies": {
|
|
89
|
-
"jimp": "^0.
|
|
93
|
+
"jimp": "^0.22.12",
|
|
90
94
|
"link-preview-js": "^3.0.0",
|
|
91
95
|
"qrcode-terminal": "^0.12.0",
|
|
92
96
|
"sharp": "^0.32.2"
|