lordceaser-baileys 3.3.8 → 3.4.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/WAProto/index.js +1 -2
- package/index.js +4 -16
- package/lib/Socket/Client/index.js +0 -1
- package/lib/Socket/Client/types.js +1 -2
- package/lib/Socket/Client/websocket.js +1 -2
- package/lib/Socket/business.js +70 -42
- package/lib/Socket/chats.js +731 -21
- package/lib/Socket/communities.js +1 -1
- package/lib/Socket/groups.js +207 -5
- package/lib/Socket/index.js +28 -3
- package/lib/Socket/messages-recv.js +381 -9
- package/lib/Socket/messages-send.js +2189 -157
- package/lib/Socket/mex.js +1 -2
- package/lib/Socket/newsletter.js +98 -19
- package/lib/Socket/socket.js +64 -17
- package/lib/Utils/crypto.js +6 -5
- package/lib/Utils/lt-hash.js +3 -8
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +1 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +1 -2
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -3
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -2
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -2
- package/lib/WAUSync/Protocols/index.js +7 -1
- package/lib/WAUSync/USyncQuery.js +126 -23
- package/lib/WAUSync/USyncUser.js +24 -1
- package/lib/WAUSync/index.js +1 -2
- package/package.json +2 -6
- package/lib/Socket/Socket/Client/index.js +0 -2
- package/lib/Socket/Socket/Client/types.js +0 -10
- package/lib/Socket/Socket/Client/websocket.js +0 -53
- package/lib/Socket/Socket/business.js +0 -407
- package/lib/Socket/Socket/chats.js +0 -1908
- package/lib/Socket/Socket/communities.js +0 -431
- package/lib/Socket/Socket/groups.js +0 -549
- package/lib/Socket/Socket/index.js +0 -37
- package/lib/Socket/Socket/messages-recv.js +0 -2144
- package/lib/Socket/Socket/messages-send.js +0 -3177
- package/lib/Socket/Socket/mex.js +0 -41
- package/lib/Socket/Socket/newsletter.js +0 -260
- package/lib/Socket/Socket/socket.js +0 -1017
- package/lib/Utils/_crypto_orig.js +0 -118
- package/lib/WAUSync/WAUSync/Protocols/USyncContactProtocol.js +0 -56
- package/lib/WAUSync/WAUSync/Protocols/USyncDeviceProtocol.js +0 -53
- package/lib/WAUSync/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -26
- package/lib/WAUSync/WAUSync/Protocols/USyncStatusProtocol.js +0 -37
- package/lib/WAUSync/WAUSync/Protocols/USyncUsernameProtocol.js +0 -24
- package/lib/WAUSync/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -50
- package/lib/WAUSync/WAUSync/Protocols/UsyncLIDProtocol.js +0 -28
- package/lib/WAUSync/WAUSync/Protocols/index.js +0 -12
- package/lib/WAUSync/WAUSync/USyncQuery.js +0 -201
- package/lib/WAUSync/WAUSync/USyncUser.js +0 -54
- package/lib/WAUSync/WAUSync/index.js +0 -3
- /package/lib/Socket/{Socket/aigroups.js → aigroups.js} +0 -0
- /package/lib/Socket/{Socket/ban-checker.js → ban-checker.js} +0 -0
- /package/lib/Socket/{Socket/chats.js[old] → chats.js[old]} +0 -0
- /package/lib/Socket/{Socket/graphql.js → graphql.js} +0 -0
- /package/lib/Socket/{Socket/groups.js[old] → groups.js[old]} +0 -0
- /package/lib/Socket/{Socket/interactive-handler.js → interactive-handler.js} +0 -0
- /package/lib/Socket/{Socket/interop.js → interop.js} +0 -0
- /package/lib/Socket/{Socket/managed-account.js → managed-account.js} +0 -0
- /package/lib/Socket/{Socket/privacy.js → privacy.js} +0 -0
- /package/lib/Socket/{Socket/registration.js → registration.js} +0 -0
- /package/lib/Socket/{Socket/username.js → username.js} +0 -0
- /package/lib/WAUSync/{WAUSync/Protocols → Protocols}/USyncBusinessProtocol.js +0 -0
- /package/lib/WAUSync/{WAUSync/Protocols → Protocols}/USyncFeatureProtocol.js +0 -0
- /package/lib/WAUSync/{WAUSync/Protocols → Protocols}/USyncPictureProtocol.js +0 -0
- /package/lib/WAUSync/{WAUSync/Protocols → Protocols}/USyncSidelistProtocol.js +0 -0
- /package/lib/WAUSync/{WAUSync/Protocols → Protocols}/USyncTextStatusProtocol.js +0 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getBinaryNodeChild } from '../WABinary/index.js';
|
|
2
2
|
import { USyncBotProfileProtocol } from './Protocols/UsyncBotProfileProtocol.js';
|
|
3
3
|
import { USyncLIDProtocol } from './Protocols/UsyncLIDProtocol.js';
|
|
4
|
+
import { USyncBusinessProtocol } from './Protocols/USyncBusinessProtocol.js';
|
|
5
|
+
import { USyncFeatureProtocol } from './Protocols/USyncFeatureProtocol.js';
|
|
6
|
+
import { USyncPictureProtocol } from './Protocols/USyncPictureProtocol.js';
|
|
7
|
+
import { USyncTextStatusProtocol } from './Protocols/USyncTextStatusProtocol.js';
|
|
8
|
+
import { USyncSidelistProtocol } from './Protocols/USyncSidelistProtocol.js';
|
|
4
9
|
import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol, USyncUsernameProtocol } from './Protocols/index.js';
|
|
5
10
|
import { USyncUser } from './USyncUser.js';
|
|
6
11
|
export class USyncQuery {
|
|
@@ -23,47 +28,126 @@ export class USyncQuery {
|
|
|
23
28
|
return this;
|
|
24
29
|
}
|
|
25
30
|
parseUSyncQueryResult(result) {
|
|
26
|
-
if (result
|
|
31
|
+
if (!result || result.attrs.type !== 'result') {
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
34
|
const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
|
|
30
35
|
return [protocol.name, protocol.parser];
|
|
31
36
|
}));
|
|
32
37
|
const queryResult = {
|
|
33
|
-
|
|
38
|
+
errors: {},
|
|
39
|
+
refresh: {},
|
|
34
40
|
list: [],
|
|
35
41
|
sideList: []
|
|
36
42
|
};
|
|
37
43
|
const usyncNode = getBinaryNodeChild(result, 'usync');
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
// Each protocol's result child can carry either an <error code text backoff/>
|
|
45
|
+
// (caller should back off future queries for that protocol) or a refresh="n"
|
|
46
|
+
// attr (caller may cache the response for n seconds). Ported from WAWebUsync's
|
|
47
|
+
// usyncParser.
|
|
48
|
+
const resultNode = usyncNode ? getBinaryNodeChild(usyncNode, 'result') : undefined;
|
|
49
|
+
if (resultNode) {
|
|
50
|
+
for (const protocol of this.protocols) {
|
|
51
|
+
const protocolNode = getBinaryNodeChild(resultNode, protocol.name);
|
|
52
|
+
if (!protocolNode) continue;
|
|
53
|
+
const errorNode = getBinaryNodeChild(protocolNode, 'error');
|
|
54
|
+
if (errorNode) {
|
|
55
|
+
queryResult.errors[protocol.name] = {
|
|
56
|
+
errorCode: errorNode.attrs.code ? +errorNode.attrs.code : undefined,
|
|
57
|
+
errorText: errorNode.attrs.text,
|
|
58
|
+
errorBackoff: errorNode.attrs.backoff ? +errorNode.attrs.backoff : undefined
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else if (protocolNode.attrs.refresh !== undefined) {
|
|
62
|
+
queryResult.refresh[protocol.name] = +protocolNode.attrs.refresh;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const parseUserNodes = nodes => {
|
|
67
|
+
return nodes.reduce((acc, node) => {
|
|
44
68
|
const id = node?.attrs.jid;
|
|
45
69
|
if (id) {
|
|
70
|
+
// G. Blocked-by tracking: a user-level error attribute signals the contact
|
|
71
|
+
// has blocked us (WA uses 401/403/405 on the <user> node in this case).
|
|
72
|
+
const userErrorCode = node?.attrs?.error ? parseInt(node.attrs.error, 10) : 0;
|
|
73
|
+
const isBlockedByAttr = userErrorCode === 401 || userErrorCode === 403 || userErrorCode === 405;
|
|
74
|
+
|
|
46
75
|
const data = Array.isArray(node?.content)
|
|
47
|
-
? Object.fromEntries(
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
? Object.fromEntries(
|
|
77
|
+
node.content
|
|
78
|
+
.map(content => {
|
|
79
|
+
const protocol = content.tag;
|
|
80
|
+
|
|
81
|
+
// B. Privacy Token: extract per-contact privacy_token and
|
|
82
|
+
// privacy_mode_ts from <privacy> child elements in usync responses.
|
|
83
|
+
if (protocol === 'privacy') {
|
|
84
|
+
const tokenNode = getBinaryNodeChild(content, 'token');
|
|
85
|
+
const modeTsNode = getBinaryNodeChild(content, 'mode_ts');
|
|
86
|
+
// Also accept inline attrs format
|
|
87
|
+
const tokenVal = tokenNode?.content || content.attrs?.token;
|
|
88
|
+
const modeTsVal =
|
|
89
|
+
modeTsNode?.content?.toString?.() || modeTsNode?.attrs?.value || content.attrs?.mode_ts || null;
|
|
90
|
+
if (tokenVal) {
|
|
91
|
+
return [
|
|
92
|
+
'privacy',
|
|
93
|
+
{
|
|
94
|
+
token: Buffer.isBuffer(tokenVal) || tokenVal instanceof Uint8Array
|
|
95
|
+
? Buffer.from(tokenVal)
|
|
96
|
+
: tokenVal,
|
|
97
|
+
modeTs: modeTsVal
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
return ['privacy', null];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const parser = protocolMap[protocol];
|
|
105
|
+
if (parser) {
|
|
106
|
+
try {
|
|
107
|
+
return [protocol, parser(content)];
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
// G. Blocked-by: sub-node parser errors with blocked codes
|
|
111
|
+
// should surface as isBlockedByContact rather than crashing.
|
|
112
|
+
const errCode = err?.data ?? err?.output?.payload?.data;
|
|
113
|
+
if (errCode === 401 || errCode === 403 || errCode === 405) {
|
|
114
|
+
return ['isBlockedByContact', true];
|
|
115
|
+
}
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return [protocol, null];
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
.filter(([, b]) => b !== null)
|
|
124
|
+
)
|
|
59
125
|
: {};
|
|
126
|
+
|
|
127
|
+
// Merge user-attr blocked flag with any parser-detected blocked flag.
|
|
128
|
+
if (isBlockedByAttr) {
|
|
129
|
+
data.isBlockedByContact = true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Remap snake_case protocol keys to camelCase contact fields.
|
|
133
|
+
if ('disappearing_mode' in data) {
|
|
134
|
+
data.disappearingMode = data.disappearing_mode;
|
|
135
|
+
delete data.disappearing_mode;
|
|
136
|
+
}
|
|
137
|
+
|
|
60
138
|
acc.push({ ...data, id });
|
|
61
139
|
}
|
|
62
140
|
return acc;
|
|
63
141
|
}, []);
|
|
142
|
+
};
|
|
143
|
+
const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined;
|
|
144
|
+
if (listNode?.content && Array.isArray(listNode.content)) {
|
|
145
|
+
queryResult.list = parseUserNodes(listNode.content);
|
|
146
|
+
}
|
|
147
|
+
const sideListNode = usyncNode ? getBinaryNodeChild(usyncNode, 'side_list') : undefined;
|
|
148
|
+
if (sideListNode?.content && Array.isArray(sideListNode.content)) {
|
|
149
|
+
queryResult.sideList = parseUserNodes(sideListNode.content);
|
|
64
150
|
}
|
|
65
|
-
//TODO: implement side list
|
|
66
|
-
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
|
67
151
|
return queryResult;
|
|
68
152
|
}
|
|
69
153
|
withDeviceProtocol() {
|
|
@@ -94,5 +178,24 @@ export class USyncQuery {
|
|
|
94
178
|
this.protocols.push(new USyncUsernameProtocol());
|
|
95
179
|
return this;
|
|
96
180
|
}
|
|
181
|
+
withBusinessProtocol(profileVersion) {
|
|
182
|
+
this.protocols.push(new USyncBusinessProtocol(profileVersion));
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
withPictureProtocol(type) {
|
|
186
|
+
this.protocols.push(new USyncPictureProtocol(type));
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
withTextStatusProtocol() {
|
|
190
|
+
this.protocols.push(new USyncTextStatusProtocol());
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
withSidelistProtocol(useLidAddressing) {
|
|
194
|
+
this.protocols.push(new USyncSidelistProtocol(useLidAddressing));
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
withFeatureProtocol(features) {
|
|
198
|
+
this.protocols.push(new USyncFeatureProtocol(features));
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
97
201
|
}
|
|
98
|
-
//# sourceMappingURL=USyncQuery.js.map
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -27,5 +27,28 @@ export class USyncUser {
|
|
|
27
27
|
this.personaId = personaId;
|
|
28
28
|
return this;
|
|
29
29
|
}
|
|
30
|
+
withTcToken(tcToken) {
|
|
31
|
+
this.tcToken = tcToken;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
withPnJid(pnJid) {
|
|
35
|
+
this.pnJid = pnJid;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
withDeviceHash(deviceHash) {
|
|
39
|
+
this.deviceHash = deviceHash;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
withTs(ts) {
|
|
43
|
+
this.ts = ts;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
withExpectedTs(expectedTs) {
|
|
47
|
+
this.expectedTs = expectedTs;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/** Ported from WAWebUsyncUser's validate() — a usync user needs at least one addressable field. */
|
|
51
|
+
validate() {
|
|
52
|
+
return !!(this.id || this.phone || this.username || this.pnJid);
|
|
53
|
+
}
|
|
30
54
|
}
|
|
31
|
-
//# sourceMappingURL=USyncUser.js.map
|
package/lib/WAUSync/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lordceaser-baileys",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "CEASER v3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
|
+
"description": "CEASER v3.4.0 FINAL - PACKED not cloned - FORCED JS BRIDGE INSIDE BELLY - FIXED md5 + LTHashAntiTampering + proto + hkdf + async-mutex + @cacheable - 150 files - WILL LINK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"scripts": { "postinstall": "node -e \"try{require('./index.js')}catch(e){}\"" },
|
|
@@ -22,10 +22,6 @@
|
|
|
22
22
|
"whatsapp-rust-bridge": "^0.1.5",
|
|
23
23
|
"ws": "^8.14.2",
|
|
24
24
|
"axios": "^1.6.0",
|
|
25
|
-
"jimp": "^0.22.10",
|
|
26
|
-
"file-type": "^16.5.4",
|
|
27
|
-
"node-cache": "^5.1.2",
|
|
28
|
-
"keyv": "^4.5.4",
|
|
29
25
|
"futoin-hkdf": "^1.5.1"
|
|
30
26
|
},
|
|
31
27
|
"files": ["lib/","lib/package.json","WAProto/","WABinary/","WASignalGroup/","WAMessage/","WAM/","src/","index.js"]
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import WebSocket from 'ws';
|
|
2
|
-
import { DEFAULT_ORIGIN } from '../../Defaults/index.js';
|
|
3
|
-
import { AbstractSocketClient } from './types.js';
|
|
4
|
-
export class WebSocketClient extends AbstractSocketClient {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.socket = null;
|
|
8
|
-
}
|
|
9
|
-
get isOpen() {
|
|
10
|
-
return this.socket?.readyState === WebSocket.OPEN;
|
|
11
|
-
}
|
|
12
|
-
get isClosed() {
|
|
13
|
-
return this.socket === null || this.socket?.readyState === WebSocket.CLOSED;
|
|
14
|
-
}
|
|
15
|
-
get isClosing() {
|
|
16
|
-
return this.socket === null || this.socket?.readyState === WebSocket.CLOSING;
|
|
17
|
-
}
|
|
18
|
-
get isConnecting() {
|
|
19
|
-
return this.socket?.readyState === WebSocket.CONNECTING;
|
|
20
|
-
}
|
|
21
|
-
connect() {
|
|
22
|
-
if (this.socket) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
this.socket = new WebSocket(this.url, {
|
|
26
|
-
origin: DEFAULT_ORIGIN,
|
|
27
|
-
headers: this.config.options?.headers,
|
|
28
|
-
handshakeTimeout: this.config.connectTimeoutMs,
|
|
29
|
-
timeout: this.config.connectTimeoutMs,
|
|
30
|
-
agent: this.config.agent
|
|
31
|
-
});
|
|
32
|
-
this.socket.setMaxListeners(0);
|
|
33
|
-
const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
|
|
34
|
-
for (const event of events) {
|
|
35
|
-
this.socket?.on(event, (...args) => this.emit(event, ...args));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async close() {
|
|
39
|
-
if (!this.socket) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const closePromise = new Promise(resolve => {
|
|
43
|
-
this.socket?.once('close', resolve);
|
|
44
|
-
});
|
|
45
|
-
this.socket.close();
|
|
46
|
-
await closePromise;
|
|
47
|
-
this.socket = null;
|
|
48
|
-
}
|
|
49
|
-
send(str, cb) {
|
|
50
|
-
this.socket?.send(str, cb);
|
|
51
|
-
return Boolean(this.socket);
|
|
52
|
-
}
|
|
53
|
-
}
|