@vanzxy/baileys 1.4.7 → 1.4.9

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.
@@ -1602,7 +1602,22 @@ class AIRich extends BaseBuilder {
1602
1602
  return new Proxy(this, {
1603
1603
  get(target, prop, receiver) {
1604
1604
  const orig = Reflect.get(target, prop, receiver);
1605
- if (typeof orig !== 'function' || !/^(add|set)/.test(String(prop))) return orig;
1605
+ if (typeof orig !== 'function') return orig;
1606
+
1607
+ // Vanz@Fix 23-08-26 (part 2) --- the add*/set* filter below only wrapped methods whose
1608
+ // name starts with "add"/"set". Everything else (send(), build(), ...) fell through to
1609
+ // `return orig` unwrapped, so calling e.g. `richInstance.send(...)` still invoked the
1610
+ // real method with `this` = the Proxy (`receiver`), hitting the exact same
1611
+ // "Cannot read private member #client..." brand-check error the add*/set* fix was for —
1612
+ // just one level up, in send()/build() themselves. Every function property now gets
1613
+ // bound to `target` (the real instance) at minimum; add*/set* additionally get the
1614
+ // insertAt/id bookkeeping below.
1615
+ if (!/^(add|set)/.test(String(prop))) {
1616
+ return (...args) => {
1617
+ const result = orig.apply(target, args);
1618
+ return result === target ? receiver : result;
1619
+ };
1620
+ }
1606
1621
 
1607
1622
  return (...args) => {
1608
1623
  const opts = args.find((a) => a && typeof a === 'object' && !Array.isArray(a) && !Buffer.isBuffer(a) && ('id' in a || 'insertAt' in a));
@@ -1612,7 +1627,18 @@ class AIRich extends BaseBuilder {
1612
1627
  const subBefore = target._submessages.length;
1613
1628
  const secBefore = target._sections.length;
1614
1629
 
1615
- const result = orig.apply(receiver, args);
1630
+ // Vanz@Fix 23-08-26 --- was orig.apply(receiver, args): calling the real method bound to
1631
+ // the Proxy itself (`receiver`) makes any `this.#client` access inside throw
1632
+ // "Cannot read private member #client from an object whose class did not declare it",
1633
+ // because a Proxy is never the branded instance a private field was declared on —
1634
+ // this hit every add*() that touches #client via Toolkit.resolveMedia(this.#client, ...)
1635
+ // (addProduct/addPost/addReels/addSource, and would eventually hit addImage/addVideo
1636
+ // too once JIT/engine specifics changed). Binding to `target` (the real instance) instead
1637
+ // fixes it for good; `target._submessages`/`target._sections` below are unaffected since
1638
+ // they're plain properties, and `result === target ? receiver : result` still converts a
1639
+ // `this`-return back to the Proxy so chaining (`.addX().addY()`) keeps working.
1640
+ const result = orig.apply(target, args);
1641
+
1616
1642
 
1617
1643
  const subItems = target._submessages.splice(subBefore);
1618
1644
  const secItems = target._sections.splice(secBefore);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanzxy/baileys",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "description": "Enhanced Baileys fork by Vanzxy — based on @itsliaaa/baileys + @whiskeysockets/baileys with fixes for audio group status and clean media without newsletter button.",
5
5
  "type": "module",
6
6
  "main": "./cjs/lib/index.js",
@@ -1,208 +0,0 @@
1
- /**
2
- * Type declarations for lib/Utils/MessageBuilder.js
3
- * Hand-written (this file had no .d.ts before — not shipped by upstream
4
- * either). Public chaining API only; internal/private members omitted.
5
- */
6
-
7
- export const MESSAGE_BUILDER_VERSION: string; // '4.7'
8
-
9
- export abstract class BaseBuilder {
10
- setTitle(title: string): this;
11
- setSubtitle(subtitle: string): this;
12
- setBody(body: string): this;
13
- setFooter(footer: string): this;
14
- setContextInfo(obj: Record<string, any>): this;
15
- addPayload(obj: Record<string, any>): this;
16
- }
17
-
18
- export interface LimitedTimeOfferParams {
19
- text?: string;
20
- url?: string;
21
- copy_code?: string;
22
- expiration_time?: number;
23
- }
24
-
25
- export interface BottomSheetParams {
26
- in_thread_buttons_limit?: number;
27
- divider_indices?: number[];
28
- list_title?: string;
29
- button_title?: string;
30
- }
31
-
32
- export interface TapTargetConfigurationParams {
33
- title?: string;
34
- description?: string;
35
- canonical_url?: string;
36
- domain?: string;
37
- buttonIndex?: number;
38
- }
39
-
40
- export class Button extends BaseBuilder {
41
- constructor(client: any);
42
- setVideo(path: string | Buffer, options?: Record<string, any>): this;
43
- setImage(path: string | Buffer, options?: Record<string, any>): this;
44
- setDocument(path: string | Buffer, options?: Record<string, any>): this;
45
- setMedia(obj: Record<string, any>): this;
46
- clearButtons(): this;
47
- setParams(obj: Record<string, any>): this;
48
- addButton(name: string, params: string | Record<string, any>): this;
49
- makeRow(header?: string, title?: string, description?: string, id?: string): this;
50
- makeSection(title?: string, highlight_label?: string): this;
51
- addSelection(title: string, options?: Record<string, any>): this;
52
- addReply(display_text: string, id: string, options?: Record<string, any>): this;
53
- /** cta_call. Note (v4.7): keys on `phone_number`, not `id` — fixed from a prior version that silently mis-keyed this field. */
54
- addCall(display_text: string, phone_number: string, options?: Record<string, any>): this;
55
- addReminder(display_text: string, id: string, options?: Record<string, any>): this;
56
- addCancelReminder(display_text: string, id: string, options?: Record<string, any>): this;
57
- addAddress(display_text: string, id: string, options?: Record<string, any>): this;
58
- addLocation(options?: Record<string, any>): this;
59
- addUrl(display_text: string, url: string, webview_interaction?: boolean, options?: Record<string, any>): this;
60
- addCopy(display_text: string, copy_code: string, options?: Record<string, any>): this;
61
- /** open_webview — opens a titled in-app webview. */
62
- addOpenWebview(title: string, url: string, options?: Record<string, any>): this;
63
- /** cta_catalog — opens the sender's WhatsApp Business catalog. Business-account gated. */
64
- addCatalog(display_text?: string, options?: Record<string, any>): this;
65
- /** automated_greeting_message_view_catalog. Business-account gated. */
66
- addViewCatalog(options?: Record<string, any>): this;
67
- /** call_permission_request. */
68
- addCallPermission(display_text?: string, options?: Record<string, any>): this;
69
- /** payment_info — structured payment-settings payload (e.g. PIX). Payment-enabled accounts only. */
70
- addPaymentInfo(payload?: Record<string, any>): this;
71
- /** review_and_pay — order/payment summary flow. Server-validated by WhatsApp. */
72
- addReviewAndPay(payload?: Record<string, any>): this;
73
- /** wa_payment_transaction_details. */
74
- addTransactionDetails(payload?: Record<string, any>): this;
75
- /** mpm — multi-product message. Business-catalog accounts only. */
76
- addMultiProduct(payload?: Record<string, any>): this;
77
- setLimitedTimeOffer(params?: LimitedTimeOfferParams): this;
78
- setBottomSheet(params?: BottomSheetParams): this;
79
- setTapTargetConfiguration(params?: TapTargetConfigurationParams): this;
80
- toCard(): Promise<Record<string, any>>;
81
- build(jid: string, options?: Record<string, any>): Promise<Record<string, any>>;
82
- send(jid: string, options?: Record<string, any>): Promise<any>;
83
-
84
- /** Native-flow names WA renders with a dedicated node instead of the generic v=9 "mixed" node. */
85
- static SPECIAL_FLOW: Record<string, { v: string; name: string }>;
86
-
87
- // Presets attached at runtime via attachPresets() from MessageKit.js.
88
- static confirm?: (client: any, text: string, options?: Record<string, any>) => Button;
89
- static yesNo?: (client: any, text: string, options?: Record<string, any>) => Button;
90
- static menu?: (client: any, options?: Record<string, any>) => Button;
91
- }
92
-
93
- export class ButtonV2 extends BaseBuilder {
94
- constructor(client: any);
95
- addButton(displayText: string, buttonId?: string): this;
96
- addRawButton(obj: Record<string, any>): this;
97
- setThumbnail(path: string | Buffer): this;
98
- setMedia(obj: Record<string, any>): this;
99
- /** @param options.viewOnce Default true — some clients require this for legacy buttonsMessage to render; pass false for a normal (non-disappearing) message. */
100
- build(jid: string, options?: Record<string, any> & { viewOnce?: boolean }): Promise<Record<string, any>>;
101
- send(jid: string, options?: Record<string, any> & { viewOnce?: boolean }): Promise<any>;
102
- }
103
-
104
- export class Carousel extends BaseBuilder {
105
- constructor(client: any);
106
- /** WhatsApp caps carousels at this many cards (10); addCard() throws past it. */
107
- static MAX_CARDS: number;
108
- addCard(card: Record<string, any> | Record<string, any>[]): this;
109
- build(jid: string, options?: Record<string, any>): Record<string, any>;
110
- send(jid: string, options?: Record<string, any>): Promise<any>;
111
- }
112
-
113
- export class Poll extends BaseBuilder {
114
- constructor(client: any);
115
- setName(name: string): this;
116
- addOption(name: string): this;
117
- addOptions(names: string[]): this;
118
- setSelectable(count: number): this;
119
- setMultiSelect(canSelectMultiple?: boolean): this;
120
- setHideVoter(hide?: boolean): this;
121
- setCanAddOption(allow?: boolean): this;
122
- setAnnouncementGroup(isAnnouncement?: boolean): this;
123
- setEndDate(date: Date | string | number): this;
124
- /** Defers hash/version handling to the socket's own sendMessage({poll}) logic — see .js docblock. */
125
- setQuiz(correctOptionName: string): this;
126
- build(): { poll: Record<string, any> };
127
- send(jid: string, options?: Record<string, any>): Promise<any>;
128
- }
129
-
130
- export interface AddTextOptions {
131
- hyperlink?: boolean;
132
- citation?: boolean;
133
- latex?: boolean;
134
- }
135
-
136
- export interface AddInlineImageOptions {
137
- text?: string;
138
- alignment?: string;
139
- tapLinkUrl?: string;
140
- resolveUrl?: boolean;
141
- }
142
-
143
- export class AIRich extends BaseBuilder {
144
- constructor(client: any);
145
- addSubmessage(submessage: Record<string, any>): this;
146
- addSection(section: Record<string, any>): this;
147
- addText(text: string, options?: AddTextOptions): this;
148
- addCode(language: string, code: string): this;
149
- addTable(table: string[][], options?: AddTextOptions): this;
150
- addSource(sources?: Record<string, any>[]): this;
151
- addReels(reelsItems?: Record<string, any>[]): this;
152
- addImage(imageUrl: string, options?: { resolveUrl?: boolean }): this;
153
- addInlineImage(imageUrl: string, options?: AddInlineImageOptions): this;
154
- addVideo(videoUrl: string, options?: { autoFill?: boolean }): this;
155
- addProduct(data?: Record<string, any>): this;
156
- addPost(data?: Record<string, any>): this;
157
- addTip(text: string): this;
158
- /** FOATextPrimitive — large heading text, distinct from addText()'s paragraph text. */
159
- addHeading(text: string): this;
160
- /** GenAIImagePrimitive — "ready" static image (preview + full-res), distinct from addImage()'s generation-style card. */
161
- addImageCard(previewUrl: string | Buffer, fullUrl?: string | Buffer, options?: { resolveUrl?: boolean }): this;
162
- /** GenAI3PExtWidgetPrimitive — experimental, reverse-engineered; see JSDoc in the .js file for caveats. */
163
- addWidget(data: Record<string, any> | Record<string, any>[], options?: { layout?: 'Single' | 'HScroll' | 'ActionRow' | string }): this;
164
- /** GenAIFooterActionPrimitive — footer action link chips (e.g. "Join our Group"). */
165
- addFooterAction(actions: { text: string; url: string; type?: string } | { text: string; url: string; type?: string }[]): this;
166
- /** GenAIDividerPrimitive — plain horizontal line, no content. */
167
- addDivider(): this;
168
- /** GenAISpacerPrimitive — blank vertical spacing. */
169
- addSpacer(spacing?: number): this;
170
- /** GenAILatexUXPrimitive — has a real AI_RICH_RESPONSE_LATEX submessage (unlike most primitives here). */
171
- addLatex(expression: string): this;
172
- /** GenAITaskPrimitive — task/checklist card. */
173
- addTask(data: { task_id?: string; title: string; subtitle?: string; status?: string; textFallback?: boolean }): this;
174
- /** GenAIBotProgressStatusPrimitive — one-shot "searching/working" status chip. */
175
- addProgressStatus(title: string, options?: { icon?: string; is_in_progress?: boolean; target_secondary_screen_id?: string; target_secondary_screen_tab_id?: string }): this;
176
- /** GenAIBotThinkingStatusPrimitive — one-shot "thinking" status chip. */
177
- addThinkingStatus(title: string, options?: { icon?: string; is_in_progress?: boolean; target_secondary_screen_id?: string; target_secondary_screen_tab_id?: string; textFallback?: boolean }): this;
178
- /** GenAIMetaSubsQuotaUpsellPrimitive — subscription-quota-limit upsell card. */
179
- addQuotaUpsell(data: { title: string; body?: string; body_line1?: string; body_line2?: string; buttons?: { label: string; action?: string; deeplink?: string }[] }): this;
180
- /** FOABloksPrimitive — raw Bloks payload; most experimental primitive, fields passed through as-is. */
181
- addBloks(data: { type: string; data?: string; uuid?: string; initial_response?: any; versioning_id?: string; textFallback?: boolean }): this;
182
- addSuggest(suggestion: Record<string, any>, options?: { scroll?: boolean; layout?: string }): this;
183
- /** GenAIImaginePrimitive with status GENERATING — pending-generation placeholder, distinct from addImage()/addVideo()'s READY status. */
184
- addGenerating(options?: { imagine_type?: 'IMAGE' | 'ANIMATE'; estimated_completion_time?: number; textFallback?: boolean }): this;
185
- build(): Record<string, any>;
186
- send(jid: string, options?: Record<string, any>): Promise<any>;
187
-
188
- static tokenizer(code: string, lang?: string): Record<string, any>;
189
- static toTableMetadata(arr: string[][], options?: AddTextOptions): Record<string, any>;
190
- static newLayout(name: string, data: Record<string, any> | Record<string, any>[], extra?: Record<string, any>): Record<string, any>;
191
- /** Send a support-ticket marker message (messageContextInfo.supportPayload). */
192
- static sendSupportPayload(client: any, jid: string, text: string, options?: { ticketId?: string; isAiMessage?: boolean; shouldShowSystemMessage?: boolean; version?: number }): Promise<any>;
193
- /** Send an image + video as one paired-media unit (messageAssociation). */
194
- static sendPairedMedia(client: any, jid: string, media: { image: string | Buffer; video: string | Buffer }): Promise<any>;
195
- }
196
-
197
- // Same class as AIRich — exported under alternate names (see Vanz@Alias in
198
- // MessageBuilder.js). All four are structurally identical to AIRich.
199
- export { AIRich as AIVanzxy, AIRich as LeafRich, AIRich as VanzxyAI, AIRich as VanzxyRich };
200
-
201
- export class Toolkit {
202
- static extractIE(text: string, options?: AddTextOptions): Record<string, any>;
203
- static getMp4Duration(buffer: Buffer, options?: { silent?: boolean }): Promise<number>;
204
- static getMp4Preview(
205
- videoBuffer: Buffer,
206
- options?: { time?: number; result?: 'buffer' | string; resize?: boolean; width?: number; height?: number; silent?: boolean }
207
- ): Promise<Buffer | Record<string, any>>;
208
- }