dibosockets 1.0.2 → 1.0.4

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.
Files changed (40) hide show
  1. package/WAProto/WAProto.proto +5619 -5619
  2. package/lib/Api/Internet/growagarden.js +28 -28
  3. package/lib/Api/creator.json +13 -13
  4. package/lib/Api/downloader/tiktokdownload.js +132 -132
  5. package/lib/Api/index.js +38 -38
  6. package/lib/Api/nsfw/loli.js +79 -79
  7. package/lib/Api/stalker/githubstalk.js +46 -46
  8. package/lib/Api/stalker/stalkroblox.js +94 -94
  9. package/lib/Api/stalker/tiktokstalk.js +68 -68
  10. package/lib/Api/tools/ssweb.js +38 -38
  11. package/lib/Defaults/baileys-version.json +3 -3
  12. package/lib/Defaults/index.js +122 -122
  13. package/lib/Defaults/phonenumber_mcc.json +223 -223
  14. package/lib/Socket/RHandler.js +448 -448
  15. package/lib/Socket/business.js +266 -266
  16. package/lib/Socket/chats.js +1137 -1137
  17. package/lib/Socket/communities.js +441 -441
  18. package/lib/Socket/index.js +43 -43
  19. package/lib/Socket/messages-recv.js +1065 -1065
  20. package/lib/Socket/messages-send.js +881 -881
  21. package/lib/Socket/newsletter.js +286 -286
  22. package/lib/Socket/socket.js +666 -666
  23. package/lib/Store/make-in-memory-store.js +439 -439
  24. package/lib/Types/Newsletter.js +18 -18
  25. package/lib/Utils/async-iterable.js +41 -41
  26. package/lib/Utils/baileys-event-stream.js +63 -63
  27. package/lib/Utils/browser-utils.js +34 -34
  28. package/lib/Utils/event-buffer.js +518 -518
  29. package/lib/Utils/generics.js +431 -431
  30. package/lib/Utils/index.js +36 -36
  31. package/lib/Utils/message-retry-manager.js +127 -127
  32. package/lib/Utils/messages-media.js +926 -926
  33. package/lib/Utils/messages.js +1105 -1105
  34. package/lib/Utils/process-message.js +404 -404
  35. package/lib/Utils/resolveJid.js +52 -52
  36. package/lib/Utils/use-multi-file-auth-state.js +122 -122
  37. package/lib/Utils/validate-connection.js +228 -228
  38. package/lib/WABinary/jid-utils.js +85 -85
  39. package/lib/index.js +87 -74
  40. package/package.json +2 -2
@@ -1,229 +1,229 @@
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
- const PLATFORM_MAP = {
33
- 'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
34
- 'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
35
- };
36
-
37
- const getWebInfo = (config) => {
38
- let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
39
- if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]] && config.browser[1] === 'Desktop') {
40
- webSubPlatform = PLATFORM_MAP[config.browser[0]];
41
- }
42
- return { webSubPlatform };
43
- };
44
-
45
- const getClientPayload = (config) => {
46
- const payload = {
47
- connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
48
- connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
49
- userAgent: getUserAgent(config),
50
- };
51
- payload.webInfo = getWebInfo(config);
52
- return payload;
53
- };
54
-
55
- const generateLoginNode = (userJid, config) => {
56
- const { user, device } = (0, WABinary_1.jidDecode)(userJid);
57
- const payload = {
58
- ...getClientPayload(config),
59
- passive: true,
60
- pull: true,
61
- username: +user,
62
- device: device,
63
- lidDbMigrated: false
64
- };
65
- return WAProto_1.proto.ClientPayload.fromObject(payload);
66
- };
67
- exports.generateLoginNode = generateLoginNode;
68
-
69
- const getPlatformType = (platform) => {
70
- const platformType = platform.toUpperCase();
71
- return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
72
- };
73
-
74
- const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
75
- const appVersionBuf = (0, crypto_1.createHash)('md5')
76
- .update(config.version.join('.'))
77
- .digest();
78
-
79
- const companion = {
80
- os: config.browser[0],
81
- platformType: getPlatformType(config.browser[1]),
82
- requireFullSync: config.syncFullHistory,
83
- historySyncConfig: {
84
- storageQuotaMb: 10240,
85
- inlineInitialPayloadInE2EeMsg: true,
86
- recentSyncDaysLimit: undefined,
87
- supportCallLogHistory: false,
88
- supportBotUserAgentChatHistory: true,
89
- supportCagReactionsAndPolls: true,
90
- supportBizHostedMsg: true,
91
- supportRecentSyncChunkMessageCountTuning: true,
92
- supportHostedGroupMsg: true,
93
- supportFbidBotChatHistory: true,
94
- supportAddOnHistorySyncMigration: undefined,
95
- supportMessageAssociation: true,
96
- supportGroupHistory: false,
97
- onDemandReady: undefined,
98
- supportGuestChat: undefined
99
- },
100
- version: {
101
- primary: 10,
102
- secondary: 15,
103
- tertiary: 7
104
- }
105
- };
106
-
107
- const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
108
-
109
- const registerPayload = {
110
- ...getClientPayload(config),
111
- passive: false,
112
- pull: false,
113
- devicePairingData: {
114
- buildHash: appVersionBuf,
115
- deviceProps: companionProto,
116
- eRegid: (0, generics_1.encodeBigEndian)(registrationId),
117
- eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
118
- eIdent: signedIdentityKey.public,
119
- eSkeyId: (0, generics_1.encodeBigEndian)(signedPreKey.keyId, 3),
120
- eSkeyVal: signedPreKey.keyPair.public,
121
- eSkeySig: signedPreKey.signature,
122
- },
123
- };
124
- return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
125
- };
126
- exports.generateRegistrationNode = generateRegistrationNode;
127
-
128
- const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
129
- const msgId = stanza.attrs.id;
130
- const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
131
- const deviceIdentityNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
132
- const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
133
- const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
134
- const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
135
-
136
- if (!deviceIdentityNode || !deviceNode) {
137
- throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
138
- }
139
-
140
- const bizName = businessNode?.attrs.name;
141
- const jid = deviceNode.attrs.jid;
142
- const lid = deviceNode.attrs.lid;
143
-
144
- const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
145
-
146
- let hmacPrefix = Buffer.from([]);
147
- if (accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED) {
148
- hmacPrefix = Buffer.from([0x06, 0x05]);
149
- }
150
-
151
- const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
152
- if (Buffer.compare(hmac, advSign) !== 0) {
153
- throw new boom_1.Boom('Invalid account signature');
154
- }
155
-
156
- const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
157
- const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
158
-
159
- const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(deviceDetails);
160
-
161
- const accountSignaturePrefix = deviceIdentity.deviceType === WAProto_1.proto.ADVEncryptionType.HOSTED
162
- ? Buffer.from([0x06, 0x05])
163
- : Buffer.from([0x06, 0x00]);
164
- const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
165
-
166
- if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
167
- throw new boom_1.Boom('Failed to verify account signature');
168
- }
169
-
170
- const deviceMsg = Buffer.concat([
171
- Buffer.from([0x06, 0x01]),
172
- deviceDetails,
173
- signedIdentityKey.public,
174
- accountSignatureKey
175
- ]);
176
- account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
177
-
178
- const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
179
- const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
180
-
181
- const reply = {
182
- tag: 'iq',
183
- attrs: {
184
- to: WABinary_1.S_WHATSAPP_NET,
185
- type: 'result',
186
- id: msgId,
187
- },
188
- content: [
189
- {
190
- tag: 'pair-device-sign',
191
- attrs: {},
192
- content: [
193
- {
194
- tag: 'device-identity',
195
- attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
196
- content: accountEnc
197
- }
198
- ]
199
- }
200
- ]
201
- };
202
-
203
- const authUpdate = {
204
- account,
205
- me: { id: jid, name: bizName, lid },
206
- signalIdentities: [
207
- ...(signalIdentities || []),
208
- identity
209
- ],
210
- platform: platformNode?.attrs.name
211
- };
212
-
213
- return {
214
- creds: authUpdate,
215
- reply
216
- };
217
- };
218
- exports.configureSuccessfulPairing = configureSuccessfulPairing;
219
-
220
- const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
221
- account = { ...account };
222
- if (!includeSignatureKey || !account.accountSignatureKey?.length) {
223
- account.accountSignatureKey = null;
224
- }
225
- return WAProto_1.proto.ADVSignedDeviceIdentity
226
- .encode(account)
227
- .finish();
228
- };
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
+ const PLATFORM_MAP = {
33
+ 'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
34
+ 'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
35
+ };
36
+
37
+ const getWebInfo = (config) => {
38
+ let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
39
+ if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]] && config.browser[1] === 'Desktop') {
40
+ webSubPlatform = PLATFORM_MAP[config.browser[0]];
41
+ }
42
+ return { webSubPlatform };
43
+ };
44
+
45
+ const getClientPayload = (config) => {
46
+ const payload = {
47
+ connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
48
+ connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
49
+ userAgent: getUserAgent(config),
50
+ };
51
+ payload.webInfo = getWebInfo(config);
52
+ return payload;
53
+ };
54
+
55
+ const generateLoginNode = (userJid, config) => {
56
+ const { user, device } = (0, WABinary_1.jidDecode)(userJid);
57
+ const payload = {
58
+ ...getClientPayload(config),
59
+ passive: true,
60
+ pull: true,
61
+ username: +user,
62
+ device: device,
63
+ lidDbMigrated: false
64
+ };
65
+ return WAProto_1.proto.ClientPayload.fromObject(payload);
66
+ };
67
+ exports.generateLoginNode = generateLoginNode;
68
+
69
+ const getPlatformType = (platform) => {
70
+ const platformType = platform.toUpperCase();
71
+ return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
72
+ };
73
+
74
+ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
75
+ const appVersionBuf = (0, crypto_1.createHash)('md5')
76
+ .update(config.version.join('.'))
77
+ .digest();
78
+
79
+ const companion = {
80
+ os: config.browser[0],
81
+ platformType: getPlatformType(config.browser[1]),
82
+ requireFullSync: config.syncFullHistory,
83
+ historySyncConfig: {
84
+ storageQuotaMb: 10240,
85
+ inlineInitialPayloadInE2EeMsg: true,
86
+ recentSyncDaysLimit: undefined,
87
+ supportCallLogHistory: false,
88
+ supportBotUserAgentChatHistory: true,
89
+ supportCagReactionsAndPolls: true,
90
+ supportBizHostedMsg: true,
91
+ supportRecentSyncChunkMessageCountTuning: true,
92
+ supportHostedGroupMsg: true,
93
+ supportFbidBotChatHistory: true,
94
+ supportAddOnHistorySyncMigration: undefined,
95
+ supportMessageAssociation: true,
96
+ supportGroupHistory: false,
97
+ onDemandReady: undefined,
98
+ supportGuestChat: undefined
99
+ },
100
+ version: {
101
+ primary: 10,
102
+ secondary: 15,
103
+ tertiary: 7
104
+ }
105
+ };
106
+
107
+ const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
108
+
109
+ const registerPayload = {
110
+ ...getClientPayload(config),
111
+ passive: false,
112
+ pull: false,
113
+ devicePairingData: {
114
+ buildHash: appVersionBuf,
115
+ deviceProps: companionProto,
116
+ eRegid: (0, generics_1.encodeBigEndian)(registrationId),
117
+ eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
118
+ eIdent: signedIdentityKey.public,
119
+ eSkeyId: (0, generics_1.encodeBigEndian)(signedPreKey.keyId, 3),
120
+ eSkeyVal: signedPreKey.keyPair.public,
121
+ eSkeySig: signedPreKey.signature,
122
+ },
123
+ };
124
+ return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
125
+ };
126
+ exports.generateRegistrationNode = generateRegistrationNode;
127
+
128
+ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
129
+ const msgId = stanza.attrs.id;
130
+ const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
131
+ const deviceIdentityNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
132
+ const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
133
+ const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
134
+ const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
135
+
136
+ if (!deviceIdentityNode || !deviceNode) {
137
+ throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
138
+ }
139
+
140
+ const bizName = businessNode?.attrs.name;
141
+ const jid = deviceNode.attrs.jid;
142
+ const lid = deviceNode.attrs.lid;
143
+
144
+ const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
145
+
146
+ let hmacPrefix = Buffer.from([]);
147
+ if (accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED) {
148
+ hmacPrefix = Buffer.from([0x06, 0x05]);
149
+ }
150
+
151
+ const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
152
+ if (Buffer.compare(hmac, advSign) !== 0) {
153
+ throw new boom_1.Boom('Invalid account signature');
154
+ }
155
+
156
+ const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
157
+ const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
158
+
159
+ const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(deviceDetails);
160
+
161
+ const accountSignaturePrefix = deviceIdentity.deviceType === WAProto_1.proto.ADVEncryptionType.HOSTED
162
+ ? Buffer.from([0x06, 0x05])
163
+ : Buffer.from([0x06, 0x00]);
164
+ const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
165
+
166
+ if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
167
+ throw new boom_1.Boom('Failed to verify account signature');
168
+ }
169
+
170
+ const deviceMsg = Buffer.concat([
171
+ Buffer.from([0x06, 0x01]),
172
+ deviceDetails,
173
+ signedIdentityKey.public,
174
+ accountSignatureKey
175
+ ]);
176
+ account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
177
+
178
+ const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
179
+ const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
180
+
181
+ const reply = {
182
+ tag: 'iq',
183
+ attrs: {
184
+ to: WABinary_1.S_WHATSAPP_NET,
185
+ type: 'result',
186
+ id: msgId,
187
+ },
188
+ content: [
189
+ {
190
+ tag: 'pair-device-sign',
191
+ attrs: {},
192
+ content: [
193
+ {
194
+ tag: 'device-identity',
195
+ attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
196
+ content: accountEnc
197
+ }
198
+ ]
199
+ }
200
+ ]
201
+ };
202
+
203
+ const authUpdate = {
204
+ account,
205
+ me: { id: jid, name: bizName, lid },
206
+ signalIdentities: [
207
+ ...(signalIdentities || []),
208
+ identity
209
+ ],
210
+ platform: platformNode?.attrs.name
211
+ };
212
+
213
+ return {
214
+ creds: authUpdate,
215
+ reply
216
+ };
217
+ };
218
+ exports.configureSuccessfulPairing = configureSuccessfulPairing;
219
+
220
+ const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
221
+ account = { ...account };
222
+ if (!includeSignatureKey || !account.accountSignatureKey?.length) {
223
+ account.accountSignatureKey = null;
224
+ }
225
+ return WAProto_1.proto.ADVSignedDeviceIdentity
226
+ .encode(account)
227
+ .finish();
228
+ };
229
229
  exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;