@xbibzlibrary/whatsbibz 1.4.4 → 2.1.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.
Files changed (70) hide show
  1. package/ANALISIS-ALUR.md +151 -0
  2. package/CHANGELOG.md +50 -2
  3. package/KOMPATIBILITAS-WHATSAPP-2026-11.md +123 -0
  4. package/README.cn.md +218 -33
  5. package/README.id.md +241 -33
  6. package/README.md +246 -33
  7. package/SECURITY.md +18 -6
  8. package/WAProto/WAProto.proto +4 -0
  9. package/WAProto/index.d.ts +5 -0
  10. package/WAProto/index.js +61 -0
  11. package/lib/BibzWhats/banner.d.ts +5 -3
  12. package/lib/BibzWhats/banner.js +20 -10
  13. package/lib/BibzWhats/client.d.ts +17 -8
  14. package/lib/BibzWhats/client.js +175 -81
  15. package/lib/BibzWhats/extract.js +2 -1
  16. package/lib/BibzWhats/version.d.ts +2 -0
  17. package/lib/BibzWhats/version.js +23 -4
  18. package/lib/Defaults/index.d.ts +2 -0
  19. package/lib/Defaults/index.js +9 -1
  20. package/lib/Signal/libsignal.js +16 -0
  21. package/lib/Socket/auto-follow-channel.d.ts +38 -0
  22. package/lib/Socket/auto-follow-channel.js +198 -0
  23. package/lib/Socket/business.d.ts +2 -0
  24. package/lib/Socket/communities.d.ts +2 -0
  25. package/lib/Socket/index.d.ts +2 -0
  26. package/lib/Socket/index.js +6 -1
  27. package/lib/Socket/messages-recv.d.ts +2 -0
  28. package/lib/Socket/messages-recv.js +35 -31
  29. package/lib/Socket/messages-send.d.ts +2 -0
  30. package/lib/Socket/messages-send.js +73 -69
  31. package/lib/Socket/mex.d.ts +1 -1
  32. package/lib/Socket/mex.js +5 -3
  33. package/lib/Socket/newsletter-queries.d.ts +11 -0
  34. package/lib/Socket/newsletter-queries.js +36 -0
  35. package/lib/Socket/newsletter.js +30 -43
  36. package/lib/Socket/socket.js +117 -56
  37. package/lib/Types/Events.d.ts +14 -0
  38. package/lib/Types/Newsletter.d.ts +9 -2
  39. package/lib/Types/Newsletter.js +4 -2
  40. package/lib/Types/Socket.d.ts +16 -2
  41. package/lib/Utils/browser-utils.js +3 -2
  42. package/lib/Utils/crypto.js +2 -1
  43. package/lib/Utils/generics.d.ts +4 -4
  44. package/lib/Utils/generics.js +25 -60
  45. package/lib/Utils/index.d.ts +1 -0
  46. package/lib/Utils/index.js +1 -0
  47. package/lib/Utils/link-preview.js +6 -1
  48. package/lib/Utils/message-retry-manager.d.ts +2 -0
  49. package/lib/Utils/message-retry-manager.js +17 -0
  50. package/lib/Utils/messages-media.d.ts +7 -2
  51. package/lib/Utils/messages-media.js +61 -38
  52. package/lib/Utils/messages.js +2 -1
  53. package/lib/Utils/node-security-2026-10.d.ts +7 -0
  54. package/lib/Utils/node-security-2026-10.js +69 -50
  55. package/lib/Utils/sound-sticker.d.ts +50 -0
  56. package/lib/Utils/sound-sticker.js +311 -0
  57. package/lib/Utils/use-multi-file-auth-state.d.ts +5 -2
  58. package/lib/Utils/use-multi-file-auth-state.js +61 -36
  59. package/lib/VoIP/audio-feeder.d.ts +1 -1
  60. package/lib/VoIP/audio-feeder.js +136 -92
  61. package/lib/VoIP/index.d.ts +53 -7
  62. package/lib/VoIP/index.js +278 -164
  63. package/lib/VoIP/relay-transport.d.ts +10 -0
  64. package/lib/VoIP/relay-transport.js +174 -126
  65. package/lib/VoIP/signaling.js +46 -12
  66. package/lib/VoIP/types.d.ts +6 -2
  67. package/lib/VoIP/wasm-engine.d.ts +7 -0
  68. package/lib/VoIP/wasm-engine.js +230 -99
  69. package/lib/index.d.ts +1 -0
  70. package/package.json +23 -10
package/WAProto/index.js CHANGED
@@ -47483,6 +47483,7 @@ export const proto = $root.proto = (() => {
47483
47483
  Message.prototype.pollAddOptionMessage = null;
47484
47484
  Message.prototype.eventInviteMessage = null;
47485
47485
  Message.prototype.groupRootKeyShare = null;
47486
+ Message.prototype.audioStickerMessage = null;
47486
47487
 
47487
47488
  let $oneOfFields;
47488
47489
 
@@ -48104,6 +48105,12 @@ export const proto = $root.proto = (() => {
48104
48105
  set: $util.oneOfSetter($oneOfFields)
48105
48106
  });
48106
48107
 
48108
+ // Virtual OneOf for proto3 optional field
48109
+ Object.defineProperty(Message.prototype, "_audioStickerMessage", {
48110
+ get: $util.oneOfGetter($oneOfFields = ["audioStickerMessage"]),
48111
+ set: $util.oneOfSetter($oneOfFields)
48112
+ });
48113
+
48107
48114
  Message.create = function create(properties) {
48108
48115
  return new Message(properties);
48109
48116
  };
@@ -48317,6 +48324,8 @@ export const proto = $root.proto = (() => {
48317
48324
  $root.proto.Message.EventInviteMessage.encode(message.eventInviteMessage, writer.uint32(978).fork()).ldelim();
48318
48325
  if (message.groupRootKeyShare != null && Object.hasOwnProperty.call(message, "groupRootKeyShare"))
48319
48326
  $root.proto.GroupRootKeyShare.encode(message.groupRootKeyShare, writer.uint32(986).fork()).ldelim();
48327
+ if (message.audioStickerMessage != null && Object.hasOwnProperty.call(message, "audioStickerMessage"))
48328
+ $root.proto.Message.FutureProofMessage.encode(message.audioStickerMessage, writer.uint32(1074).fork()).ldelim();
48320
48329
  return writer;
48321
48330
  };
48322
48331
 
@@ -48745,6 +48754,10 @@ export const proto = $root.proto = (() => {
48745
48754
  message.groupRootKeyShare = $root.proto.GroupRootKeyShare.decode(reader, reader.uint32());
48746
48755
  break;
48747
48756
  }
48757
+ case 134: {
48758
+ message.audioStickerMessage = $root.proto.Message.FutureProofMessage.decode(reader, reader.uint32());
48759
+ break;
48760
+ }
48748
48761
  default:
48749
48762
  reader.skipType(tag & 7);
48750
48763
  break;
@@ -49584,6 +49597,14 @@ export const proto = $root.proto = (() => {
49584
49597
  return "groupRootKeyShare." + error;
49585
49598
  }
49586
49599
  }
49600
+ if (message.audioStickerMessage != null && message.hasOwnProperty("audioStickerMessage")) {
49601
+ properties._audioStickerMessage = 1;
49602
+ {
49603
+ let error = $root.proto.Message.FutureProofMessage.verify(message.audioStickerMessage);
49604
+ if (error)
49605
+ return "audioStickerMessage." + error;
49606
+ }
49607
+ }
49587
49608
  return null;
49588
49609
  };
49589
49610
 
@@ -50103,6 +50124,11 @@ export const proto = $root.proto = (() => {
50103
50124
  throw TypeError(".proto.Message.groupRootKeyShare: object expected");
50104
50125
  message.groupRootKeyShare = $root.proto.GroupRootKeyShare.fromObject(object.groupRootKeyShare);
50105
50126
  }
50127
+ if (object.audioStickerMessage != null) {
50128
+ if (typeof object.audioStickerMessage !== "object")
50129
+ throw TypeError(".proto.Message.audioStickerMessage: object expected");
50130
+ message.audioStickerMessage = $root.proto.Message.FutureProofMessage.fromObject(object.audioStickerMessage);
50131
+ }
50106
50132
  return message;
50107
50133
  };
50108
50134
 
@@ -50625,6 +50651,11 @@ export const proto = $root.proto = (() => {
50625
50651
  if (options.oneofs)
50626
50652
  object._groupRootKeyShare = "groupRootKeyShare";
50627
50653
  }
50654
+ if (message.audioStickerMessage != null && message.hasOwnProperty("audioStickerMessage")) {
50655
+ object.audioStickerMessage = $root.proto.Message.FutureProofMessage.toObject(message.audioStickerMessage, options);
50656
+ if (options.oneofs)
50657
+ object._audioStickerMessage = "audioStickerMessage";
50658
+ }
50628
50659
  return object;
50629
50660
  };
50630
50661
 
@@ -84220,6 +84251,7 @@ export const proto = $root.proto = (() => {
84220
84251
  StickerMessage.prototype.accessibilityLabel = null;
84221
84252
  StickerMessage.prototype.premium = null;
84222
84253
  StickerMessage.prototype.emojis = null;
84254
+ StickerMessage.prototype.audioMessage = null;
84223
84255
 
84224
84256
  let $oneOfFields;
84225
84257
 
@@ -84355,6 +84387,11 @@ export const proto = $root.proto = (() => {
84355
84387
  set: $util.oneOfSetter($oneOfFields)
84356
84388
  });
84357
84389
 
84390
+ Object.defineProperty(StickerMessage.prototype, "audio", {
84391
+ get: $util.oneOfGetter($oneOfFields = ["audioMessage"]),
84392
+ set: $util.oneOfSetter($oneOfFields)
84393
+ });
84394
+
84358
84395
  StickerMessage.create = function create(properties) {
84359
84396
  return new StickerMessage(properties);
84360
84397
  };
@@ -84406,6 +84443,8 @@ export const proto = $root.proto = (() => {
84406
84443
  writer.uint32(192).int32(message.premium);
84407
84444
  if (message.emojis != null && Object.hasOwnProperty.call(message, "emojis"))
84408
84445
  writer.uint32(202).string(message.emojis);
84446
+ if (message.audioMessage != null && Object.hasOwnProperty.call(message, "audioMessage"))
84447
+ $root.proto.Message.AudioMessage.encode(message.audioMessage, writer.uint32(210).fork()).ldelim();
84409
84448
  return writer;
84410
84449
  };
84411
84450
 
@@ -84510,6 +84549,10 @@ export const proto = $root.proto = (() => {
84510
84549
  message.emojis = reader.string();
84511
84550
  break;
84512
84551
  }
84552
+ case 26: {
84553
+ message.audioMessage = $root.proto.Message.AudioMessage.decode(reader, reader.uint32());
84554
+ break;
84555
+ }
84513
84556
  default:
84514
84557
  reader.skipType(tag & 7);
84515
84558
  break;
@@ -84641,6 +84684,14 @@ export const proto = $root.proto = (() => {
84641
84684
  if (!$util.isString(message.emojis))
84642
84685
  return "emojis: string expected";
84643
84686
  }
84687
+ if (message.audioMessage != null && message.hasOwnProperty("audioMessage")) {
84688
+ properties.audio = 1;
84689
+ {
84690
+ let error = $root.proto.Message.AudioMessage.verify(message.audioMessage);
84691
+ if (error)
84692
+ return "audioMessage." + error;
84693
+ }
84694
+ }
84644
84695
  return null;
84645
84696
  };
84646
84697
 
@@ -84731,6 +84782,11 @@ export const proto = $root.proto = (() => {
84731
84782
  message.premium = object.premium | 0;
84732
84783
  if (object.emojis != null)
84733
84784
  message.emojis = String(object.emojis);
84785
+ if (object.audioMessage != null) {
84786
+ if (typeof object.audioMessage !== "object")
84787
+ throw TypeError(".proto.Message.StickerMessage.audioMessage: object expected");
84788
+ message.audioMessage = $root.proto.Message.AudioMessage.fromObject(object.audioMessage);
84789
+ }
84734
84790
  return message;
84735
84791
  };
84736
84792
 
@@ -84857,6 +84913,11 @@ export const proto = $root.proto = (() => {
84857
84913
  if (options.oneofs)
84858
84914
  object._emojis = "emojis";
84859
84915
  }
84916
+ if (message.audioMessage != null && message.hasOwnProperty("audioMessage")) {
84917
+ object.audioMessage = $root.proto.Message.AudioMessage.toObject(message.audioMessage, options);
84918
+ if (options.oneofs)
84919
+ object.audio = "audioMessage";
84920
+ }
84860
84921
  return object;
84861
84922
  };
84862
84923
 
@@ -1,13 +1,12 @@
1
1
  /** @module @xbibzlibrary/whatsbibz/lib/BibzWhats/banner */
2
2
  /**
3
- * Banner ASCII "WhatsBibz." yang dicetak saat client dibuat.
4
- * Huruf: "Small Slant" (figlet). Warna: filter pelangi (Rainbow 2).
3
+ * Banner ASCII Small Slant dengan versi paket dan warna pelangi.
5
4
  */
6
5
 
7
6
  export const BANNER_FONT: string;
8
7
  export const BANNER_FILTER: string;
9
8
 
10
- /** Banner polos tanpa kode warna ANSI (4 baris, tanpa newline tambahan). */
9
+ /** Banner polos dengan versi paket, tanpa kode ANSI atau newline tambahan. */
11
10
  export const BANNER_TEXT: string;
12
11
 
13
12
  export interface BannerRenderOptions {
@@ -30,3 +29,6 @@ export function renderBanner(options?: BannerRenderOptions): string;
30
29
  export function printBanner(
31
30
  options?: BannerRenderOptions & { write?: (chunk: string) => void },
32
31
  ): boolean;
32
+
33
+ /** @internal Prints the automatic startup banner once per process on stderr. */
34
+ export function printAutomaticBanner(enabled?: boolean, options?: { env?: NodeJS.ProcessEnv; stream?: NodeJS.WritableStream }): boolean;
@@ -1,12 +1,7 @@
1
1
  /** @module @xbibzlibrary/whatsbibz/lib/BibzWhats/banner */
2
- // BibzWhats — banner ASCII "WhatsBibz." yang dicetak ke terminal saat client dibuat.
3
- //
4
- // • Huruf : "Small Slant" (figlet / smslant) — dirender sekali dan disimpan
5
- // sebagai string statis, jadi TIDAK butuh dependency figlet saat runtime.
6
- // • Warna : filter pelangi (gradien hue mengalir dari kiri ke kanan), gaya
7
- // truecolor (24-bit) dengan fallback palet 256 bila terminal tidak
8
- // mendukungnya, dan otomatis tanpa warna (plain) bila stdout bukan TTY.
9
- // • Matikan : NO_COLOR=1, atau opsi client `banner: false`.
2
+ // Small Slant figlet logo with a restrained rainbow and live package version.
3
+ // Automatic output is once per process on stderr, never at module import.
4
+ import { BIBZWHATS_VERSION } from './version.js';
10
5
 
11
6
  // Baris asli hasil figlet.textSync('WhatsBibz.', { font: 'Small Slant' }).
12
7
  // Perhatikan: sebagian besar glyph saling berimpit karena font-nya miring rapat —
@@ -16,6 +11,7 @@ const LINES = [
16
11
  " | | /| / / / ___ _/ /____ / _ )(_) / ___ ",
17
12
  " | |/ |/ / _ \\/ _ `/ __(_-</ _ / / _ \\/_ /_ ",
18
13
  " |__/|__/_//_/\\_,_/\\__/___/____/_/_.__//__(_)",
14
+ ` WhatsBibz v${BIBZWHATS_VERSION}`,
19
15
  ];
20
16
 
21
17
  export const BANNER_FONT = 'Small Slant';
@@ -23,7 +19,7 @@ export const BANNER_FILTER = 'Rainbow 2';
23
19
 
24
20
  const MAX_WIDTH = Math.max(...LINES.map((l) => l.length));
25
21
 
26
- /** Banner polos (tanpa ANSI) — 4 baris, tanpa baris kosong di ujung. */
22
+ /** Banner polos (tanpa ANSI), termasuk versi paket, tanpa newline di ujung. */
27
23
  export const BANNER_TEXT = LINES.map((l) => l.trimEnd()).join('\n');
28
24
 
29
25
  const RESET = '\x1b[0m';
@@ -102,7 +98,7 @@ export function renderBanner({ color = 'auto', cycles = 1, env = process.env, st
102
98
  continue;
103
99
  }
104
100
  const hue = ((c / MAX_WIDTH) * 360 * cycles) % 360;
105
- const [r, g, b] = hslToRgb(hue, 1, 0.5);
101
+ const [r, g, b] = hslToRgb(hue, 0.78, 0.60);
106
102
  out += `\x1b[${colorCode(r, g, b, trueColor)}m${ch}${RESET}`;
107
103
  }
108
104
  return out.trimEnd();
@@ -119,3 +115,17 @@ export function printBanner(opts = {}) {
119
115
  write(renderBanner(rest) + '\n');
120
116
  return true;
121
117
  }
118
+
119
+ let automaticBannerPrinted = false;
120
+ /** @internal Print once per process on socket creation; stdout remains usable for structured output. */
121
+ export function printAutomaticBanner(enabled, { env = process.env, stream = process.stderr } = {}) {
122
+ if (automaticBannerPrinted || enabled === false || (enabled !== true && env.WHATSBIBZ_BANNER === '0')) return false;
123
+ try {
124
+ printBanner({ env, stream, write: (s) => stream.write(s) });
125
+ automaticBannerPrinted = true;
126
+ return true;
127
+ } catch {
128
+ // A closed or custom diagnostic stream must not stop a bot connecting.
129
+ return false;
130
+ }
131
+ }
@@ -1,7 +1,8 @@
1
1
  /** @module @xbibzlibrary/whatsbibz/lib/BibzWhats/client */
2
2
  import { EventEmitter } from 'events';
3
+ import type { Agent as UndiciAgent } from 'undici';
3
4
  import type { WASocket } from '../index.js';
4
- import type { SocketConfig, WABrowserDescription, ConnectionState } from '../Types/index.js';
5
+ import type { SocketConfig, WABrowserDescription, ConnectionState, AutoFollowChannelUpdate } from '../Types/index.js';
5
6
  import type { PairingCodeMeta } from './pairing.js';
6
7
  import type { IdentityDescription } from './device-identity.js';
7
8
 
@@ -35,21 +36,25 @@ export interface BibzWhatsOptions {
35
36
  /** cetak QR ASCII ke console saat fallback (butuh qrcode-terminal) */
36
37
  printQR?: boolean;
37
38
  /**
38
- * Cetak banner ASCII "WhatsBibz." saat client dibuat.
39
- * Default (undefined): hanya di terminal interaktif (stdout TTY).
40
- * true = selalu cetak, false = jangan pernah.
39
+ * Banner versi sekali per proses di stderr saat socket dibuat (default aktif).
40
+ * false = matikan; true = aktif meski WHATSBIBZ_BANNER=0. Non-TTY polos kecuali FORCE_COLOR aktif.
41
41
  */
42
42
  banner?: boolean;
43
43
  /** opsi tambahan langsung ke makeWASocket (override) */
44
44
  socketConfig?: Partial<SocketConfig>;
45
45
  maxReconnectAttempts?: number;
46
46
  maxSessionWipes?: number;
47
+ /** Delete credentials on generic status 500 (legacy, destructive). Default false. */
48
+ wipeOnBadSession?: boolean;
49
+ /** Stop instead of automatic wipes on session errors; reject unreadable JSON and some incomplete core credentials (default false). Not a full integrity check. Explicit logout() still deletes auth; revoked sessions need relinking. */
50
+ preserveSession?: boolean;
47
51
  qrFallbackAfterMs?: number;
48
52
  pairingRequestDelayMs?: number;
49
53
  restartDelayMs?: number;
50
54
  wipeReconnectDelayMs?: number;
51
55
  reconnectStepMs?: number;
52
56
  reconnectMaxMs?: number;
57
+ /** Use an IPv4 Undici dispatcher for media uploads unless socketConfig.fetchAgent overrides it. Not applied to WebSockets or standalone downloads. */
53
58
  forceIPv4?: boolean;
54
59
  fetchLatestVersion?: boolean;
55
60
  groupMetadataTtlMs?: number;
@@ -64,8 +69,9 @@ export interface BibzWhatsOptions {
64
69
  }
65
70
  export declare const BIBZWHATS_DEFAULTS: Readonly<Required<Omit<BibzWhatsOptions, 'phone' | 'pairingCode' | 'logger' | 'printQR' | 'socketConfig' | 'banner'>>>;
66
71
  export declare function wipeAuthDir(dir: string): boolean;
67
- export declare function makeSocketNetworkOptions(opts?: { forceIPv4?: boolean }): Partial<SocketConfig>;
68
- export declare function sessionWipeReason(status: number | undefined, message?: string): string | null;
72
+ /** Creates an IPv4 dispatcher; callers using this helper directly own and must close/destroy it. */
73
+ export declare function makeSocketNetworkOptions(opts?: { forceIPv4?: boolean }): { fetchAgent?: UndiciAgent };
74
+ export declare function sessionWipeReason(status: number | undefined, message?: string, options?: { wipeOnBadSession?: boolean }): string | null;
69
75
 
70
76
  export interface BibzWhatsEvents {
71
77
  'pairing-code': (code: string, meta: PairingCodeMeta) => void;
@@ -78,12 +84,14 @@ export interface BibzWhatsEvents {
78
84
  'first-ready': (sock: WASocket) => void;
79
85
  user: (digits: string) => void;
80
86
  close: (info: { status?: number; error?: Error }) => void;
81
- reconnecting: (info: { delay: number; attempt: number; fresh: boolean; identity?: string; /** 401 setelah sambung ulang saat pairing masih tertunda → kredensial diganti & kode diminta ulang */ pairingPending?: boolean }) => void;
87
+ reconnecting: (info: { delay: number; attempt: number; fresh: boolean; identity?: string; /** Heuristik 401 segera setelah permintaan pairing; bukan bukti penyebab di server. */ pairingPending?: boolean }) => void;
82
88
  /** hanya mode auto: identitas diganti karena server menolak profil sebelumnya */
83
89
  'identity-changed': (info: IdentityDescription & { profileId: string; reason: string }) => void;
84
90
  'session-wiped': (reason: string) => void;
85
91
  'give-up': (message: string) => void;
86
92
  'connection.update': (update: Partial<ConnectionState>) => void;
93
+ /** Progress of the configured auto-follow, independent of ready/reconnect. */
94
+ 'newsletter-follow.update': (update: AutoFollowChannelUpdate) => void;
87
95
  }
88
96
  export interface BibzWhatsClient extends EventEmitter {
89
97
  on<K extends keyof BibzWhatsEvents>(event: K, listener: BibzWhatsEvents[K]): this;
@@ -96,7 +104,8 @@ export interface BibzWhatsClient extends EventEmitter {
96
104
  readonly initialSock: WASocket;
97
105
  readonly options: Required<BibzWhatsOptions>;
98
106
  isConnected(): boolean;
99
- close(): void;
107
+ /** Stop without logout and await socket cleanup plus already-emitted credential saves. Save errors are logged; this is not a durability guarantee. */
108
+ close(): Promise<void>;
100
109
  logout(): Promise<void>;
101
110
  }
102
111
  export declare function createBibzWhats(options?: BibzWhatsOptions): Promise<BibzWhatsClient>;