@jkt48connect-corp/baileys 7.3.4 → 7.3.6
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/JKT48Connect +36 -0
- package/lib/Socket/socket.js +34 -3
- package/lib/Utils/JKT48Connect +36 -0
- package/package.json +1 -1
package/lib/JKT48Connect
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
**IMPORTANT NOTICE - COPYRIGHT AND USAGE TERMS**
|
2
|
+
|
3
|
+
Please read this carefully before using, modifying, or redistributing this package.
|
4
|
+
|
5
|
+
This package (@jkt48connect-corp/baileys-lite) is the intellectual property of JKT48Connect Team. Unauthorized copying, renaming, or redistribution without proper attribution is strictly prohibited.
|
6
|
+
|
7
|
+
**USAGE REQUIREMENTS:**
|
8
|
+
|
9
|
+
If you intend to use, modify, fork, or redistribute this package, you MUST:
|
10
|
+
|
11
|
+
1. Retain all original copyright notices
|
12
|
+
2. Include proper attribution to @jkt48connect-corp and JKT48Connect Team
|
13
|
+
3. Clearly state that the original work was created by JKT48Connect Team
|
14
|
+
4. Do not remove or modify existing license headers
|
15
|
+
|
16
|
+
**REQUIRED COPYRIGHT NOTICE:**
|
17
|
+
|
18
|
+
When using this package, include the following notice in your project:
|
19
|
+
|
20
|
+
```
|
21
|
+
Original Package: @jkt48connect-corp/baileys-lite
|
22
|
+
Created by: JKT48Connect Team
|
23
|
+
Copyright (c) JKT48Connect-Corp
|
24
|
+
```
|
25
|
+
|
26
|
+
**COLLABORATION WELCOME:**
|
27
|
+
|
28
|
+
We encourage collaboration and contributions to improve this package. However, all contributions must be made through proper channels and with full attribution to original creators.
|
29
|
+
|
30
|
+
For licensing inquiries, collaboration requests, or permission to use this package in commercial projects, please contact the JKT48Connect Team directly.
|
31
|
+
|
32
|
+
**VIOLATION CONSEQUENCES:**
|
33
|
+
|
34
|
+
Failure to comply with these terms may result in legal action and immediate cessation of usage rights.
|
35
|
+
|
36
|
+
By using this package, you acknowledge that you have read, understood, and agree to comply with these terms.
|
package/lib/Socket/socket.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
"use strict";
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
4
|
exports.makeSocket = void 0;
|
@@ -19,7 +20,7 @@ const Client_1 = require("./Client");
|
|
19
20
|
*/
|
20
21
|
const makeSocket = (config) => {
|
21
22
|
var _a, _b;
|
22
|
-
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
|
23
|
+
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, isAutoReconnect, } = config;
|
23
24
|
let url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
|
24
25
|
config.mobile = config.mobile || url.protocol === 'tcp:';
|
25
26
|
if (config.mobile && url.protocol !== 'tcp:') {
|
@@ -460,7 +461,37 @@ const makeSocket = (config) => {
|
|
460
461
|
}
|
461
462
|
});
|
462
463
|
ws.on('error', mapWebSocketError(end));
|
463
|
-
|
464
|
+
|
465
|
+
// Add auto-reconnect functionality
|
466
|
+
let reconnectAttempts = 0;
|
467
|
+
const maxReconnects = 10;
|
468
|
+
|
469
|
+
ws.on('close', () => {
|
470
|
+
const error = new boom_1.Boom('Connection Terminated', {
|
471
|
+
statusCode: Types_1.DisconnectReason.connectionClosed
|
472
|
+
});
|
473
|
+
|
474
|
+
end(error);
|
475
|
+
|
476
|
+
const shouldReconnect =
|
477
|
+
config.isAutoReconnect &&
|
478
|
+
error.output.statusCode !== Types_1.DisconnectReason.loggedOut &&
|
479
|
+
reconnectAttempts < maxReconnects;
|
480
|
+
|
481
|
+
if (shouldReconnect) {
|
482
|
+
const delay = Math.min(10000, 2000 * Math.pow(2, reconnectAttempts++)); // backoff 2s, 4s, 8s...
|
483
|
+
logger.warn(`Auto reconnect #${reconnectAttempts} in ${delay / 1000}s...`);
|
484
|
+
|
485
|
+
setTimeout(() => {
|
486
|
+
makeSocket({ ...config });
|
487
|
+
}, delay);
|
488
|
+
} else if (!config.isAutoReconnect) {
|
489
|
+
logger.info('Auto reconnect disabled.');
|
490
|
+
} else {
|
491
|
+
logger.info('Auto reconnect stopped: max attempts reached or logged out.');
|
492
|
+
}
|
493
|
+
});
|
494
|
+
|
464
495
|
// the server terminated the connection
|
465
496
|
ws.on('CB:xmlstreamend', () => end(new boom_1.Boom('Connection Terminated by Server', { statusCode: Types_1.DisconnectReason.connectionClosed })));
|
466
497
|
// QR gen
|
@@ -626,4 +657,4 @@ function mapWebSocketError(handler) {
|
|
626
657
|
return (error) => {
|
627
658
|
handler(new boom_1.Boom(`WebSocket Error (${error === null || error === void 0 ? void 0 : error.message})`, { statusCode: (0, Utils_1.getCodeFromWSError)(error), data: error }));
|
628
659
|
};
|
629
|
-
}
|
660
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
**IMPORTANT NOTICE - COPYRIGHT AND USAGE TERMS**
|
2
|
+
|
3
|
+
Please read this carefully before using, modifying, or redistributing this package.
|
4
|
+
|
5
|
+
This package (@jkt48connect-corp/baileys-lite) is the intellectual property of JKT48Connect Team. Unauthorized copying, renaming, or redistribution without proper attribution is strictly prohibited.
|
6
|
+
|
7
|
+
**USAGE REQUIREMENTS:**
|
8
|
+
|
9
|
+
If you intend to use, modify, fork, or redistribute this package, you MUST:
|
10
|
+
|
11
|
+
1. Retain all original copyright notices
|
12
|
+
2. Include proper attribution to @jkt48connect-corp and JKT48Connect Team
|
13
|
+
3. Clearly state that the original work was created by JKT48Connect Team
|
14
|
+
4. Do not remove or modify existing license headers
|
15
|
+
|
16
|
+
**REQUIRED COPYRIGHT NOTICE:**
|
17
|
+
|
18
|
+
When using this package, include the following notice in your project:
|
19
|
+
|
20
|
+
```
|
21
|
+
Original Package: @jkt48connect-corp/baileys-lite
|
22
|
+
Created by: JKT48Connect Team
|
23
|
+
Copyright (c) JKT48Connect-Corp
|
24
|
+
```
|
25
|
+
|
26
|
+
**COLLABORATION WELCOME:**
|
27
|
+
|
28
|
+
We encourage collaboration and contributions to improve this package. However, all contributions must be made through proper channels and with full attribution to original creators.
|
29
|
+
|
30
|
+
For licensing inquiries, collaboration requests, or permission to use this package in commercial projects, please contact the JKT48Connect Team directly.
|
31
|
+
|
32
|
+
**VIOLATION CONSEQUENCES:**
|
33
|
+
|
34
|
+
Failure to comply with these terms may result in legal action and immediate cessation of usage rights.
|
35
|
+
|
36
|
+
By using this package, you acknowledge that you have read, understood, and agree to comply with these terms.
|