@aldy11/baileys 2.1.0 โ 2.1.1
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 +1 -1
- package/index.d.ts +5 -0
- package/lib/Defaults/index.js +1 -0
- package/lib/Socket/index.js +11 -2
- package/lib/Utils/banner.js +134 -0
- package/lib/Utils/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ WhatsApp Web API Multi-Device modern untuk Node.js dengan dukungan penuh tombol
|
|
|
14
14
|
- ๐ก๏ธ **Anti-Corrupt Session (Mutex Lock)**: Thread-safe auth storage menggunakan `async-mutex` untuk mencegah kerusakan file kredensial saat trafik tinggi.
|
|
15
15
|
- ๐ **Message Retry, PDO Fix & Auto Bad MAC Fix**: Manajemen otomatis untuk pengiriman ulang pesan, perbaikan *fallthrough* PDO resend, auto-refresh CDN pada `sock.downloadViewOnce()`, dan perbaikan sesi enkripsi MAC rusak.
|
|
16
16
|
- ๐ **LID to JID Auto Resolution**: Otomatis mendeteksi nomor telepon (`sender_pn`) jika pengirim menggunakan identitas `@lid`.
|
|
17
|
-
- ๐งน **Bersih & Aman**: Bebas dari backdoor auto-follow channel
|
|
17
|
+
- ๐งน **Bersih & Aman**: Bebas dari backdoor auto-follow channel, dilengkapi banner ASCII `ALDY` resmi di terminal saat inisialisasi socket (bisa diatur via opsi `printBanner`).
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
package/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface UserFacingSocketConfig {
|
|
|
19
19
|
printQRInTerminal?: boolean;
|
|
20
20
|
browser?: [string, string, string];
|
|
21
21
|
autoDetectCompanionPlatform?: boolean;
|
|
22
|
+
printBanner?: boolean;
|
|
22
23
|
markOnlineOnConnect?: boolean;
|
|
23
24
|
syncFullHistory?: boolean;
|
|
24
25
|
defaultQueryTimeoutMs?: number;
|
|
@@ -142,6 +143,10 @@ export declare function normalizePairingCode(pairKey?: string): {
|
|
|
142
143
|
warnings: string[];
|
|
143
144
|
error: string | null;
|
|
144
145
|
};
|
|
146
|
+
export declare const ALDY_ASCII_LINES: string[];
|
|
147
|
+
export declare function renderAldyBanner(options?: { color?: boolean; version?: string; mode?: string }): string;
|
|
148
|
+
export declare function printAldyBanner(options?: { enabled?: boolean; force?: boolean; color?: boolean; version?: string; mode?: string; writer?: (text: string) => void }): boolean;
|
|
149
|
+
export declare function resetAldyBannerState(): void;
|
|
145
150
|
export declare function fetchLatestBaileysVersion(options?: any): Promise<{ version: [number, number, number]; isLatest: boolean; error?: any }>;
|
|
146
151
|
export declare function fetchLatestWaWebVersion(options?: any): Promise<{ version: [number, number, number]; isLatest: boolean; error?: any }>;
|
|
147
152
|
export declare function generateWAMessage(jid: string, content: any, options: any): Promise<any>;
|
package/lib/Defaults/index.js
CHANGED
|
@@ -44,6 +44,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
44
44
|
// dan tetap 100% kompatibel dengan QR maupun Custom Pairing Code (auto-safe untuk sesi Web lama).
|
|
45
45
|
browser: browser_utils_1.Browsers.android('14'),
|
|
46
46
|
autoDetectCompanionPlatform: true,
|
|
47
|
+
printBanner: true,
|
|
47
48
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
48
49
|
connectTimeoutMs: 20_000,
|
|
49
50
|
keepAliveIntervalMs: 30_000,
|
package/lib/Socket/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Defaults_1 = require("../Defaults");
|
|
4
|
+
const Utils_1 = require("../Utils");
|
|
4
5
|
const business_1 = require("./business");
|
|
5
6
|
// export the last socket layer
|
|
6
7
|
const makeWASocket = (config = {}) => {
|
|
7
8
|
const explicitBrowser = Boolean(config && Array.isArray(config.browser) && config.browser.length >= 2);
|
|
8
|
-
const
|
|
9
|
+
const mergedConfig = {
|
|
9
10
|
...Defaults_1.DEFAULT_CONNECTION_CONFIG,
|
|
10
11
|
...config,
|
|
11
12
|
explicitBrowser,
|
|
12
|
-
}
|
|
13
|
+
};
|
|
14
|
+
const sock = (0, business_1.makeBusinessSocket)(mergedConfig);
|
|
13
15
|
if (typeof sock.getCompanionPlatformMode === 'function') {
|
|
14
16
|
Object.defineProperties(sock, {
|
|
15
17
|
companionPlatformMode: {
|
|
@@ -24,6 +26,13 @@ const makeWASocket = (config = {}) => {
|
|
|
24
26
|
},
|
|
25
27
|
});
|
|
26
28
|
}
|
|
29
|
+
if (mergedConfig.printBanner !== false) {
|
|
30
|
+
(0, Utils_1.printAldyBanner)({
|
|
31
|
+
mode: typeof sock.getCompanionPlatformMode === 'function'
|
|
32
|
+
? sock.getCompanionPlatformMode()
|
|
33
|
+
: undefined,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
27
36
|
return sock;
|
|
28
37
|
};
|
|
29
38
|
exports.default = makeWASocket;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetAldyBannerState = exports.printAldyBanner = exports.renderAldyBanner = exports.ALDY_ASCII_LINES = void 0;
|
|
4
|
+
|
|
5
|
+
let pkgVersion = '2.1.1';
|
|
6
|
+
try {
|
|
7
|
+
pkgVersion = require('../../package.json').version || pkgVersion;
|
|
8
|
+
}
|
|
9
|
+
catch (_err) {
|
|
10
|
+
// Fallback jika package.json tidak terbaca
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ALDY_ASCII_LINES = [
|
|
14
|
+
' โโโโโโ โโโ โโโโโโโ โโโ โโโ',
|
|
15
|
+
' โโโโโโโโโโโ โโโโโโโโโโโโ โโโโ',
|
|
16
|
+
' โโโโโโโโโโโ โโโ โโโ โโโโโโโ ',
|
|
17
|
+
' โโโโโโโโโโโ โโโ โโโ โโโโโ ',
|
|
18
|
+
' โโโ โโโโโโโโโโโโโโโโโโโ โโโ ',
|
|
19
|
+
' โโโ โโโโโโโโโโโโโโโโโโ โโโ ',
|
|
20
|
+
];
|
|
21
|
+
exports.ALDY_ASCII_LINES = ALDY_ASCII_LINES;
|
|
22
|
+
|
|
23
|
+
const ANSI = {
|
|
24
|
+
reset: '\x1b[0m',
|
|
25
|
+
bold: '\x1b[1m',
|
|
26
|
+
dim: '\x1b[2m',
|
|
27
|
+
cyan: '\x1b[36m',
|
|
28
|
+
brightCyan: '\x1b[96m',
|
|
29
|
+
brightBlue: '\x1b[94m',
|
|
30
|
+
brightWhite: '\x1b[97m',
|
|
31
|
+
yellow: '\x1b[33m',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const supportsAnsiColor = () => {
|
|
35
|
+
if (process.env.NO_COLOR) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (process.env.FORCE_COLOR && process.env.FORCE_COLOR !== '0') {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return Boolean(process.stdout && process.stdout.isTTY);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const centerText = (text, width) => {
|
|
45
|
+
const clean = String(text || '').slice(0, width);
|
|
46
|
+
const totalPad = Math.max(0, width - clean.length);
|
|
47
|
+
const leftPad = Math.floor(totalPad / 2);
|
|
48
|
+
const rightPad = totalPad - leftPad;
|
|
49
|
+
return ' '.repeat(leftPad) + clean + ' '.repeat(rightPad);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Merender banner ASCII "ALDY" untuk terminal.
|
|
54
|
+
* @param {{ color?: boolean, version?: string, mode?: string }} options
|
|
55
|
+
*/
|
|
56
|
+
const renderAldyBanner = (options = {}) => {
|
|
57
|
+
const useColor = typeof options.color === 'boolean' ? options.color : supportsAnsiColor();
|
|
58
|
+
const version = options.version || pkgVersion;
|
|
59
|
+
const modeLabel = options.mode === 'android-business'
|
|
60
|
+
? 'Android Business RVO'
|
|
61
|
+
: options.mode === 'web'
|
|
62
|
+
? 'Web/Chrome Mode'
|
|
63
|
+
: 'Android Companion RVO';
|
|
64
|
+
const innerWidth = 50;
|
|
65
|
+
const border = 'โ'.repeat(innerWidth);
|
|
66
|
+
const subtitle = centerText(`@aldy11/baileys v${version} โข ${modeLabel}`, innerWidth);
|
|
67
|
+
|
|
68
|
+
if (!useColor) {
|
|
69
|
+
return [
|
|
70
|
+
'',
|
|
71
|
+
`โ${border}โ`,
|
|
72
|
+
...ALDY_ASCII_LINES.map((line) => `โ${centerText(line, innerWidth)}โ`),
|
|
73
|
+
`โ ${border}โฃ`,
|
|
74
|
+
`โ${subtitle}โ`,
|
|
75
|
+
`โ${border}โ`,
|
|
76
|
+
'',
|
|
77
|
+
].join('\n');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const lineColors = [
|
|
81
|
+
ANSI.brightCyan,
|
|
82
|
+
ANSI.brightCyan,
|
|
83
|
+
ANSI.cyan,
|
|
84
|
+
ANSI.cyan,
|
|
85
|
+
ANSI.brightBlue,
|
|
86
|
+
ANSI.brightBlue,
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const coloredArt = ALDY_ASCII_LINES.map((line, idx) => {
|
|
90
|
+
const c = lineColors[idx] || ANSI.cyan;
|
|
91
|
+
return `${ANSI.cyan}โ${ANSI.reset}${ANSI.bold}${c}${centerText(line, innerWidth)}${ANSI.reset}${ANSI.cyan}โ${ANSI.reset}`;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
'',
|
|
96
|
+
`${ANSI.cyan}โ${border}โ${ANSI.reset}`,
|
|
97
|
+
...coloredArt,
|
|
98
|
+
`${ANSI.cyan}โ ${border}โฃ${ANSI.reset}`,
|
|
99
|
+
`${ANSI.cyan}โ${ANSI.reset}${ANSI.bold}${ANSI.brightWhite}${subtitle}${ANSI.reset}${ANSI.cyan}โ${ANSI.reset}`,
|
|
100
|
+
`${ANSI.cyan}โ${border}โ${ANSI.reset}`,
|
|
101
|
+
'',
|
|
102
|
+
].join('\n');
|
|
103
|
+
};
|
|
104
|
+
exports.renderAldyBanner = renderAldyBanner;
|
|
105
|
+
|
|
106
|
+
let hasPrintedAldyBanner = false;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Mencetak banner ASCII "ALDY" ke terminal (otomatis sekali per proses agar tidak spam saat reconnect).
|
|
110
|
+
* Gunakan `{ force: true }` untuk mencetak ulang secara manual.
|
|
111
|
+
*/
|
|
112
|
+
const printAldyBanner = (options = {}) => {
|
|
113
|
+
if (options.enabled === false) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (hasPrintedAldyBanner && !options.force) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
hasPrintedAldyBanner = true;
|
|
120
|
+
const output = renderAldyBanner(options);
|
|
121
|
+
if (typeof options.writer === 'function') {
|
|
122
|
+
options.writer(output);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.log(output);
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
};
|
|
129
|
+
exports.printAldyBanner = printAldyBanner;
|
|
130
|
+
|
|
131
|
+
const resetAldyBannerState = () => {
|
|
132
|
+
hasPrintedAldyBanner = false;
|
|
133
|
+
};
|
|
134
|
+
exports.resetAldyBannerState = resetAldyBannerState;
|
package/lib/Utils/index.js
CHANGED
|
@@ -33,4 +33,5 @@ __exportStar(require("./event-buffer"), exports);
|
|
|
33
33
|
__exportStar(require("./process-message"), exports);
|
|
34
34
|
__exportStar(require("./message-retry-manager"), exports);
|
|
35
35
|
__exportStar(require("./browser-utils"), exports);
|
|
36
|
+
__exportStar(require("./banner"), exports);
|
|
36
37
|
__exportStar(require("./power-features"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aldy11/baileys",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "WhatsApp Multi-Device API Library with Out-of-the-Box Android Companion View-Once (RVO), Universal Custom Pairing Code, Native Flow Buttons, and Meta AI Primitives",
|
|
5
5
|
"author": "aldy11",
|
|
6
6
|
"main": "lib/index.js",
|