@sanzoffc/baileys 3.0.1 → 3.0.2
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/LICENSE +1 -1
- package/WAProto/WAProto.proto +769 -233
- package/WAProto/index.js +65801 -141371
- package/lib/Defaults/index.js +117 -114
- package/lib/Defaults/index.js.bak +123 -0
- package/lib/KeyDB/BinarySearch.js +20 -0
- package/lib/KeyDB/KeyedDB.js +167 -0
- package/lib/KeyDB/index.js +4 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -14
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +75 -87
- package/lib/Signal/Group/index.js +13 -57
- package/lib/Signal/Group/keyhelper.js +17 -52
- package/lib/Signal/Group/sender-chain-key.js +27 -33
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -63
- package/lib/Signal/Group/sender-key-message.js +65 -66
- package/lib/Signal/Group/sender-key-name.js +45 -44
- package/lib/Signal/Group/sender-key-record.js +39 -49
- package/lib/Signal/Group/sender-key-state.js +80 -93
- package/lib/Signal/Group/sender-message-key.js +27 -28
- package/lib/Signal/libsignal.js +313 -163
- package/lib/Signal/lid-mapping.js +155 -0
- package/lib/Socket/Client/index.js +4 -18
- package/lib/Socket/Client/types.js +12 -12
- package/lib/Socket/Client/websocket.js +51 -71
- package/lib/Socket/Client/websocket.js.bak +53 -0
- package/lib/Socket/business.js +359 -242
- package/lib/Socket/chats.js +858 -945
- package/lib/Socket/communities.js +413 -0
- package/lib/Socket/groups.js +304 -324
- package/lib/Socket/index.js +15 -9
- package/lib/Socket/messages-recv.js +1105 -1046
- package/lib/Socket/messages-send.js +615 -389
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.js +224 -227
- package/lib/Socket/socket.js +795 -621
- package/lib/Store/index.js +6 -8
- package/lib/Store/make-cache-manager-store.js +75 -0
- package/lib/Store/make-in-memory-store.js +286 -435
- package/lib/Store/make-ordered-dictionary.js +77 -79
- package/lib/Store/object-repository.js +24 -26
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.js +9 -4
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +12 -7
- package/lib/Types/Newsletter.js +32 -17
- package/lib/Types/Newsletter.js.bak +33 -0
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.js +4 -2
- package/lib/Types/State.js +11 -2
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.js +27 -41
- package/lib/Utils/auth-utils.js +211 -191
- package/lib/Utils/baileys-event-stream.js +44 -0
- package/lib/Utils/browser-utils.js +21 -31
- package/lib/Utils/business.js +213 -214
- package/lib/Utils/chat-utils.js +711 -689
- package/lib/Utils/crypto.js +112 -175
- package/lib/Utils/decode-wa-message.js +254 -194
- package/lib/Utils/event-buffer.js +510 -500
- package/lib/Utils/generics.js +318 -430
- package/lib/Utils/history.js +83 -90
- package/lib/Utils/index.js +21 -35
- package/lib/Utils/link-preview.js +71 -116
- package/lib/Utils/logger.js +5 -7
- package/lib/Utils/lt-hash.js +40 -46
- package/lib/Utils/make-mutex.js +34 -41
- package/lib/Utils/message-retry-manager.js +33 -48
- package/lib/Utils/messages-media.js +573 -825
- package/lib/Utils/messages.js +349 -489
- package/lib/Utils/noise-handler.js +138 -144
- package/lib/Utils/pre-key-manager.js +85 -0
- package/lib/Utils/process-message.js +321 -384
- package/lib/Utils/signal.js +147 -139
- package/lib/Utils/use-multi-file-auth-state.js +95 -109
- package/lib/Utils/validate-connection.js +183 -212
- package/lib/WABinary/constants.js +1298 -1298
- package/lib/WABinary/decode.js +231 -256
- package/lib/WABinary/encode.js +207 -239
- package/lib/WABinary/generic-utils.js +119 -40
- package/lib/WABinary/index.js +7 -21
- package/lib/WABinary/jid-utils.js +87 -79
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.js +10 -12
- package/lib/WAM/constants.js +22851 -15348
- package/lib/WAM/encode.js +135 -136
- package/lib/WAM/index.js +5 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -30
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +49 -53
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -28
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -39
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +26 -20
- package/lib/WAUSync/Protocols/index.js +6 -20
- package/lib/WAUSync/USyncQuery.js +86 -85
- package/lib/WAUSync/USyncUser.js +23 -25
- package/lib/WAUSync/index.js +5 -19
- package/lib/index.js +18 -49
- package/package.json +65 -78
- package/README.MD +0 -1295
- package/WAProto/GenerateStatics.sh +0 -4
- package/WAProto/p.html +0 -1
- package/engine-requirements.js +0 -10
- package/lib/Defaults/wileys-version.json +0 -3
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/usync.js +0 -70
- package/lib/Utils/wileys-event-stream.js +0 -63
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto;
|
|
2
|
-
yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js;
|
|
3
|
-
|
|
4
|
-
#protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=node,useOptionals=true,forceLong=long --ts_proto_out=. ./src/Binary/WAMessage.proto;
|
package/WAProto/p.html
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
wileys
|
package/engine-requirements.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const major = parseInt(process.versions.node.split('.')[0], 10);
|
|
2
|
-
|
|
3
|
-
if (major < 20) {
|
|
4
|
-
console.error(
|
|
5
|
-
`\n❌ This package requires Node.js 20+ to run reliably.\n` +
|
|
6
|
-
` You are using Node.js ${process.versions.node}.\n` +
|
|
7
|
-
` Please upgrade to Node.js 20+ to proceed.\n`
|
|
8
|
-
);
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = queueJob;
|
|
4
|
-
const _queueAsyncBuckets = new Map();
|
|
5
|
-
const _gcLimit = 10000;
|
|
6
|
-
async function _asyncQueueExecutor(queue, cleanup) {
|
|
7
|
-
let offt = 0;
|
|
8
|
-
// eslint-disable-next-line no-constant-condition
|
|
9
|
-
while (true) {
|
|
10
|
-
const limit = Math.min(queue.length, _gcLimit);
|
|
11
|
-
for (let i = offt; i < limit; i++) {
|
|
12
|
-
const job = queue[i];
|
|
13
|
-
try {
|
|
14
|
-
job.resolve(await job.awaitable());
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
job.reject(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (limit < queue.length) {
|
|
21
|
-
if (limit >= _gcLimit) {
|
|
22
|
-
queue.splice(0, limit);
|
|
23
|
-
offt = 0;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
offt = limit;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
cleanup();
|
|
34
|
-
}
|
|
35
|
-
function queueJob(bucket, awaitable) {
|
|
36
|
-
// Skip name assignment since it's readonly in strict mode
|
|
37
|
-
if (typeof bucket !== 'string') {
|
|
38
|
-
console.warn('Unhandled bucket type (for naming):', typeof bucket, bucket);
|
|
39
|
-
}
|
|
40
|
-
let inactive = false;
|
|
41
|
-
if (!_queueAsyncBuckets.has(bucket)) {
|
|
42
|
-
_queueAsyncBuckets.set(bucket, []);
|
|
43
|
-
inactive = true;
|
|
44
|
-
}
|
|
45
|
-
const queue = _queueAsyncBuckets.get(bucket);
|
|
46
|
-
const job = new Promise((resolve, reject) => {
|
|
47
|
-
queue.push({
|
|
48
|
-
awaitable,
|
|
49
|
-
resolve: resolve,
|
|
50
|
-
reject
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
if (inactive) {
|
|
54
|
-
_asyncQueueExecutor(queue, () => _queueAsyncBuckets.delete(bucket));
|
|
55
|
-
}
|
|
56
|
-
return job;
|
|
57
|
-
}
|
package/lib/Socket/usync.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeUSyncSocket = void 0;
|
|
4
|
-
const boom_1 = require("@hapi/boom");
|
|
5
|
-
const WABinary_1 = require("../WABinary");
|
|
6
|
-
const socket_1 = require("./socket");
|
|
7
|
-
const makeUSyncSocket = (config) => {
|
|
8
|
-
const sock = (0, socket_1.makeSocket)(config);
|
|
9
|
-
const { generateMessageTag, query, } = sock;
|
|
10
|
-
const executeUSyncQuery = async (usyncQuery) => {
|
|
11
|
-
if (usyncQuery.protocols.length === 0) {
|
|
12
|
-
throw new boom_1.Boom('USyncQuery must have at least one protocol');
|
|
13
|
-
}
|
|
14
|
-
// todo: validate users, throw WARNING on no valid users
|
|
15
|
-
// variable below has only validated users
|
|
16
|
-
const validUsers = usyncQuery.users;
|
|
17
|
-
const userNodes = validUsers.map((user) => {
|
|
18
|
-
return {
|
|
19
|
-
tag: 'user',
|
|
20
|
-
attrs: {
|
|
21
|
-
jid: !user.phone ? user.id : undefined,
|
|
22
|
-
},
|
|
23
|
-
content: usyncQuery.protocols
|
|
24
|
-
.map((a) => a.getUserElement(user))
|
|
25
|
-
.filter(a => a !== null)
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
const listNode = {
|
|
29
|
-
tag: 'list',
|
|
30
|
-
attrs: {},
|
|
31
|
-
content: userNodes
|
|
32
|
-
};
|
|
33
|
-
const queryNode = {
|
|
34
|
-
tag: 'query',
|
|
35
|
-
attrs: {},
|
|
36
|
-
content: usyncQuery.protocols.map((a) => a.getQueryElement())
|
|
37
|
-
};
|
|
38
|
-
const iq = {
|
|
39
|
-
tag: 'iq',
|
|
40
|
-
attrs: {
|
|
41
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
42
|
-
type: 'get',
|
|
43
|
-
xmlns: 'usync',
|
|
44
|
-
},
|
|
45
|
-
content: [
|
|
46
|
-
{
|
|
47
|
-
tag: 'usync',
|
|
48
|
-
attrs: {
|
|
49
|
-
context: usyncQuery.context,
|
|
50
|
-
mode: usyncQuery.mode,
|
|
51
|
-
sid: generateMessageTag(),
|
|
52
|
-
last: 'true',
|
|
53
|
-
index: '0',
|
|
54
|
-
},
|
|
55
|
-
content: [
|
|
56
|
-
queryNode,
|
|
57
|
-
listNode
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
};
|
|
62
|
-
const result = await query(iq);
|
|
63
|
-
return usyncQuery.parseUSyncQueryResult(result);
|
|
64
|
-
};
|
|
65
|
-
return {
|
|
66
|
-
...sock,
|
|
67
|
-
executeUSyncQuery,
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
exports.makeUSyncSocket = makeUSyncSocket;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readAndEmitEventStream = exports.captureEventStream = void 0;
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const promises_1 = require("fs/promises");
|
|
10
|
-
const readline_1 = require("readline");
|
|
11
|
-
const generics_1 = require("./generics");
|
|
12
|
-
const make_mutex_1 = require("./make-mutex");
|
|
13
|
-
/**
|
|
14
|
-
* Captures events from a wileys event emitter & stores them in a file
|
|
15
|
-
* @param ev The event emitter to read events from
|
|
16
|
-
* @param filename File to save to
|
|
17
|
-
*/
|
|
18
|
-
const captureEventStream = (ev, filename) => {
|
|
19
|
-
const oldEmit = ev.emit;
|
|
20
|
-
// write mutex so data is appended in order
|
|
21
|
-
const writeMutex = (0, make_mutex_1.makeMutex)();
|
|
22
|
-
// monkey patch eventemitter to capture all events
|
|
23
|
-
ev.emit = function (...args) {
|
|
24
|
-
const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n';
|
|
25
|
-
const result = oldEmit.apply(ev, args);
|
|
26
|
-
writeMutex.mutex(async () => {
|
|
27
|
-
await (0, promises_1.writeFile)(filename, content, { flag: 'a' });
|
|
28
|
-
});
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.captureEventStream = captureEventStream;
|
|
33
|
-
/**
|
|
34
|
-
* Read event file and emit events from there
|
|
35
|
-
* @param filename filename containing event data
|
|
36
|
-
* @param delayIntervalMs delay between each event emit
|
|
37
|
-
*/
|
|
38
|
-
const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
39
|
-
const ev = new events_1.default();
|
|
40
|
-
const fireEvents = async () => {
|
|
41
|
-
// from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
|
|
42
|
-
const fileStream = (0, fs_1.createReadStream)(filename);
|
|
43
|
-
const rl = (0, readline_1.createInterface)({
|
|
44
|
-
input: fileStream,
|
|
45
|
-
crlfDelay: Infinity
|
|
46
|
-
});
|
|
47
|
-
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
48
|
-
// ('\r\n') in input.txt as a single line break.
|
|
49
|
-
for await (const line of rl) {
|
|
50
|
-
if (line) {
|
|
51
|
-
const { event, data } = JSON.parse(line);
|
|
52
|
-
ev.emit(event, data);
|
|
53
|
-
delayIntervalMs && await (0, generics_1.delay)(delayIntervalMs);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
fileStream.close();
|
|
57
|
-
};
|
|
58
|
-
return {
|
|
59
|
-
ev,
|
|
60
|
-
task: fireEvents()
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
exports.readAndEmitEventStream = readAndEmitEventStream;
|