zaileys 4.8.7 → 4.8.8
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/dist/builder/builder.d.ts +7 -0
- package/dist/builder/state.d.ts +1 -0
- package/dist/client/client.d.ts +21 -0
- package/dist/domain/chat.d.ts +5 -0
- package/dist/domain/privacy.d.ts +3 -1
- package/dist/domain/socket-like.d.ts +3 -1
- package/dist/domain/types.d.ts +4 -2
- package/dist/events/call-metadata.d.ts +7 -0
- package/dist/events/context.d.ts +52 -0
- package/dist/events/decoders/messages.d.ts +2 -0
- package/dist/events/decoders/mutations.d.ts +2 -0
- package/dist/events/index.d.ts +1 -1
- package/dist/events/types.d.ts +24 -0
- package/dist/index.cjs +16 -16
- package/dist/index.mjs +16 -16
- package/package.json +1 -1
|
@@ -19,6 +19,8 @@ export interface BuilderSocketLike {
|
|
|
19
19
|
export type TextOptions = {
|
|
20
20
|
rich?: boolean;
|
|
21
21
|
} & AIRichOptions;
|
|
22
|
+
/** The pseudo-recipient WhatsApp uses for personal statuses (stories). */
|
|
23
|
+
export declare const STATUS_BROADCAST_JID = "status@broadcast";
|
|
22
24
|
export declare class MessageBuilder<State extends BuilderState> {
|
|
23
25
|
protected readonly __state?: State;
|
|
24
26
|
protected readonly socket: BuilderSocketLike;
|
|
@@ -55,6 +57,11 @@ export declare class MessageBuilder<State extends BuilderState> {
|
|
|
55
57
|
reply(quoted: WAMessage | WAMessageKey): MessageBuilder<State>;
|
|
56
58
|
mentions(jids: string[]): MessageBuilder<State>;
|
|
57
59
|
mentionAll(): MessageBuilder<State>;
|
|
60
|
+
/**
|
|
61
|
+
* Sets who sees a status posted to `status@broadcast`. WhatsApp delivers a status only to the jids
|
|
62
|
+
* listed here — an empty list is accepted by the server but reaches nobody, so this is required.
|
|
63
|
+
*/
|
|
64
|
+
audience(jids: string[]): MessageBuilder<State>;
|
|
58
65
|
disappearing(seconds: number): MessageBuilder<State>;
|
|
59
66
|
then<T = WAMessageKey>(this: MessageBuilder<'content-set'>, onResolved: (key: WAMessageKey) => T, onRejected?: (err: unknown) => T | PromiseLike<T>): Promise<T>;
|
|
60
67
|
private uploadHeaderMedia;
|
package/dist/builder/state.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type BuilderInternalState = {
|
|
|
8
8
|
quoted?: WAMessage | WAMessageKey;
|
|
9
9
|
mentions?: string[];
|
|
10
10
|
mentionAll?: boolean;
|
|
11
|
+
statusJidList?: string[];
|
|
11
12
|
disappearingSeconds?: number;
|
|
12
13
|
resolveRecipient?: (raw: string) => Promise<string>;
|
|
13
14
|
recordSent?: (message: WAMessage) => void;
|
package/dist/client/client.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ import { TypedEventEmitter } from './event-emitter.js';
|
|
|
10
10
|
import type { BaileysSocket, ClientEventMap, ClientOptions, ConnectionState, ProviderKind } from './types.js';
|
|
11
11
|
import { CloudModule } from '../cloud/module.js';
|
|
12
12
|
import { type WebhookHandler } from '../cloud/webhook.js';
|
|
13
|
+
/**
|
|
14
|
+
* Reads the `<result>` payload of a `w:mex` reply. A jid with no username comes back as an
|
|
15
|
+
* `XWA2ResponseStatus` instead of an `XWA2Username`, so entries without one are skipped.
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseMexUsers: (result: unknown) => Array<{
|
|
18
|
+
jid: string;
|
|
19
|
+
username: string;
|
|
20
|
+
}>;
|
|
13
21
|
export declare class Client extends TypedEventEmitter<ClientEventMap> {
|
|
14
22
|
readonly sessionId: string;
|
|
15
23
|
auth: AuthStoreBundle;
|
|
@@ -156,10 +164,23 @@ export declare class Client extends TypedEventEmitter<ClientEventMap> {
|
|
|
156
164
|
private handleOpen;
|
|
157
165
|
private resolveMessageForResend;
|
|
158
166
|
private lidMapping;
|
|
167
|
+
/** One round trip for many jids, so resolving a whole participant list is not N lookups. */
|
|
168
|
+
private lidMapBulk;
|
|
159
169
|
/** Resolve a `@lid` JID to its phone-number JID (uses WhatsApp's LID mapping; may hit the network). */
|
|
160
170
|
lidToPn(lid: string): Promise<string | null>;
|
|
161
171
|
/** Resolve a phone-number JID to its `@lid` JID (uses WhatsApp's LID mapping; may hit the network). */
|
|
162
172
|
pnToLid(pn: string): Promise<string | null>;
|
|
173
|
+
/** Bulk {@link lidToPn}. Returns a `lid -> pn` map; jids WhatsApp could not resolve are simply absent. */
|
|
174
|
+
lidToPns(lids: string[]): Promise<Map<string, string>>;
|
|
175
|
+
/** Bulk {@link pnToLid}. Returns a `pn -> lid` map; jids WhatsApp could not resolve are simply absent. */
|
|
176
|
+
pnToLids(pns: string[]): Promise<Map<string, string>>;
|
|
177
|
+
/**
|
|
178
|
+
* Looks up WhatsApp usernames (`@handle`) for many jids in one round trip. Returns a `jid -> username`
|
|
179
|
+
* map; jids whose owner has not set a username are simply absent. Works best with `@lid` jids.
|
|
180
|
+
*/
|
|
181
|
+
usernames(jids: string[]): Promise<Map<string, string>>;
|
|
182
|
+
/** Single-jid {@link usernames}. `null` when the account has no username or the lookup fails. */
|
|
183
|
+
getUsername(jid: string): Promise<string | null>;
|
|
163
184
|
/**
|
|
164
185
|
* Download media bytes for a message stored in the message store (by key).
|
|
165
186
|
* Tries both `fromMe` variants. `null` when the message is unknown or carries no media.
|
package/dist/domain/chat.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export declare class ChatModule {
|
|
|
22
22
|
markUnread(jid: string): Promise<void>;
|
|
23
23
|
star(key: WAMessageKey, starred?: boolean): Promise<void>;
|
|
24
24
|
unstar(key: WAMessageKey): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Asks WhatsApp to resend older messages from before `oldest`. Returns the request id; the messages
|
|
27
|
+
* themselves arrive later on the `history-sync` event, not from this call.
|
|
28
|
+
*/
|
|
29
|
+
fetchHistory(count: number, oldest: WAMessageKey, oldestTimestamp: number): Promise<string>;
|
|
25
30
|
delete(jid: string): Promise<void>;
|
|
26
31
|
clear(jid: string): Promise<void>;
|
|
27
32
|
}
|
package/dist/domain/privacy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DomainSocketLike } from './socket-like.js';
|
|
2
|
-
import type { PrivacyConfig, PrivacySettings, WAReadReceiptsValue } from './types.js';
|
|
2
|
+
import type { PrivacyConfig, PrivacySettings, WAPrivacyCallValue, WAReadReceiptsValue } from './types.js';
|
|
3
3
|
export declare class PrivacyModule {
|
|
4
4
|
private readonly getSocket;
|
|
5
5
|
constructor(getSocket: () => DomainSocketLike | undefined);
|
|
@@ -12,4 +12,6 @@ export declare class PrivacyModule {
|
|
|
12
12
|
unblock(jid: string): Promise<void>;
|
|
13
13
|
blocklist(): Promise<string[]>;
|
|
14
14
|
disappearingMode(seconds: number): Promise<void>;
|
|
15
|
+
/** Restricts who may call you. `known` blocks calls from anyone outside your contacts. */
|
|
16
|
+
call(value: WAPrivacyCallValue): Promise<void>;
|
|
15
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModification, GroupMetadata, NewsletterMetadata, ParticipantAction, WAMediaUpload, WAPrivacyGroupAddValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from 'baileys';
|
|
1
|
+
import type { ChatModification, GroupMetadata, NewsletterMetadata, ParticipantAction, WAMediaUpload, WAMessageKey, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from 'baileys';
|
|
2
2
|
import type { LinkedGroup } from './types.js';
|
|
3
3
|
export interface DomainSocketLike {
|
|
4
4
|
groupCreate(subject: string, participants: string[]): Promise<GroupMetadata>;
|
|
@@ -60,6 +60,7 @@ export interface DomainSocketLike {
|
|
|
60
60
|
updateStatusPrivacy(value: WAPrivacyValue): Promise<void>;
|
|
61
61
|
updateReadReceiptsPrivacy(value: WAReadReceiptsValue): Promise<void>;
|
|
62
62
|
updateGroupsAddPrivacy(value: WAPrivacyGroupAddValue): Promise<void>;
|
|
63
|
+
updateCallPrivacy(value: WAPrivacyCallValue): Promise<void>;
|
|
63
64
|
updateDefaultDisappearingMode(duration: number): Promise<void>;
|
|
64
65
|
fetchPrivacySettings(force?: boolean): Promise<{
|
|
65
66
|
[_: string]: string;
|
|
@@ -73,6 +74,7 @@ export interface DomainSocketLike {
|
|
|
73
74
|
profilePictureUrl(jid: string, type?: 'image' | 'preview', timeoutMs?: number): Promise<string | undefined>;
|
|
74
75
|
fetchStatus(jid: string): Promise<unknown>;
|
|
75
76
|
chatModify(mod: ChatModification, jid: string): Promise<void>;
|
|
77
|
+
fetchMessageHistory(count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number): Promise<string>;
|
|
76
78
|
newsletterCreate(name: string, description?: string): Promise<NewsletterMetadata>;
|
|
77
79
|
newsletterFollow(jid: string): Promise<unknown>;
|
|
78
80
|
newsletterUnfollow(jid: string): Promise<unknown>;
|
package/dist/domain/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { GroupMetadata, GroupParticipant, ParticipantAction, WAPrivacyValue, WAPrivacyOnlineValue, WAReadReceiptsValue, WAPrivacyGroupAddValue, NewsletterMetadata, WAMediaUpload, } from 'baileys';
|
|
2
|
-
import type { WAPrivacyValue, WAPrivacyOnlineValue, WAReadReceiptsValue, WAPrivacyGroupAddValue } from 'baileys';
|
|
1
|
+
export type { GroupMetadata, GroupParticipant, ParticipantAction, WAPrivacyValue, WAPrivacyOnlineValue, WAReadReceiptsValue, WAPrivacyGroupAddValue, WAPrivacyCallValue, NewsletterMetadata, WAMediaUpload, } from 'baileys';
|
|
2
|
+
import type { WAPrivacyValue, WAPrivacyOnlineValue, WAReadReceiptsValue, WAPrivacyGroupAddValue, WAPrivacyCallValue } from 'baileys';
|
|
3
3
|
export interface ParticipantUpdateResult {
|
|
4
4
|
jid: string;
|
|
5
5
|
status: string;
|
|
@@ -11,6 +11,8 @@ export interface PrivacyConfig {
|
|
|
11
11
|
status?: WAPrivacyValue;
|
|
12
12
|
readReceipts?: WAReadReceiptsValue;
|
|
13
13
|
groupAdd?: WAPrivacyGroupAddValue;
|
|
14
|
+
/** Who may call you. `known` limits calls to your contacts. */
|
|
15
|
+
call?: WAPrivacyCallValue;
|
|
14
16
|
}
|
|
15
17
|
export type PrivacySettings = {
|
|
16
18
|
[key: string]: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CallerInfo } from './types.js';
|
|
2
|
+
/** Reads the caller details WhatsApp puts on a raw `<call>` stanza. Returns false when the node is not an offer. */
|
|
3
|
+
export declare const rememberCallerInfo: (raw: unknown) => boolean;
|
|
4
|
+
/** Pops the caller details captured for a call id, if the raw stanza carried any. */
|
|
5
|
+
export declare const takeCallerInfo: (callId: string) => CallerInfo | undefined;
|
|
6
|
+
/** Test seam: drops everything captured so far. */
|
|
7
|
+
export declare const resetCallerInfo: () => void;
|
package/dist/events/context.d.ts
CHANGED
|
@@ -19,6 +19,16 @@ export interface MediaAttachment {
|
|
|
19
19
|
fileName: string | null;
|
|
20
20
|
fileSize: number | null;
|
|
21
21
|
ptt: boolean;
|
|
22
|
+
/** Playback length in seconds, for audio and video. */
|
|
23
|
+
duration: number | null;
|
|
24
|
+
width: number | null;
|
|
25
|
+
height: number | null;
|
|
26
|
+
/** Page count, for documents. */
|
|
27
|
+
pages: number | null;
|
|
28
|
+
/** `true` for an animated sticker or a GIF-playback video. */
|
|
29
|
+
isAnimated: boolean;
|
|
30
|
+
/** Inline JPEG preview, when WhatsApp sent one. Lets you show a thumbnail without downloading. */
|
|
31
|
+
thumbnail: Buffer | null;
|
|
22
32
|
buffer(): Promise<Buffer>;
|
|
23
33
|
stream(): Promise<Readable>;
|
|
24
34
|
}
|
|
@@ -147,6 +157,25 @@ export interface TemplateMedia {
|
|
|
147
157
|
buttons: MessageButton[];
|
|
148
158
|
}
|
|
149
159
|
export type ContextMedia = MediaAttachment | PollMedia | ContactMedia | LocationMedia | EventMedia | AlbumMedia | GroupInviteMedia | ProductMedia | OrderMedia | PaymentMedia | LinkPreviewMedia | ButtonsMedia | ListMedia | InteractiveMedia | TemplateMedia;
|
|
160
|
+
/** Attribution for a chat that started from a Meta ad (Click-to-WhatsApp). */
|
|
161
|
+
export interface AdAttribution {
|
|
162
|
+
/** The click id to join against Meta Ads reporting. */
|
|
163
|
+
clickId?: string;
|
|
164
|
+
sourceId?: string;
|
|
165
|
+
sourceUrl?: string;
|
|
166
|
+
/** Which Meta surface the ad ran on, e.g. `facebook`, `instagram`. */
|
|
167
|
+
sourceApp?: string;
|
|
168
|
+
sourceType?: string;
|
|
169
|
+
title?: string;
|
|
170
|
+
body?: string;
|
|
171
|
+
thumbnailUrl?: string;
|
|
172
|
+
/** Campaign reference you set on the ad. */
|
|
173
|
+
ref?: string;
|
|
174
|
+
}
|
|
175
|
+
export interface BusinessInfo {
|
|
176
|
+
/** WhatsApp-verified business name. Unlike `senderName` this cannot be set by the sender. */
|
|
177
|
+
verifiedName: string;
|
|
178
|
+
}
|
|
150
179
|
export interface MessageContext {
|
|
151
180
|
uniqueId: string;
|
|
152
181
|
staticId: string;
|
|
@@ -158,6 +187,8 @@ export interface MessageContext {
|
|
|
158
187
|
senderId: string;
|
|
159
188
|
senderLid: string | null;
|
|
160
189
|
senderName: string | null;
|
|
190
|
+
/** WhatsApp username (the `@handle`), without the `@`. Only sent for accounts that set one. */
|
|
191
|
+
senderUsername: string | null;
|
|
161
192
|
senderDevice: SenderDevice;
|
|
162
193
|
timestamp: number;
|
|
163
194
|
text: string;
|
|
@@ -170,6 +201,20 @@ export interface MessageContext {
|
|
|
170
201
|
isViewOnce: boolean;
|
|
171
202
|
isEphemeral: boolean;
|
|
172
203
|
isForwarded: boolean;
|
|
204
|
+
/** `true` for a backlog message replayed after a reconnect. Skip these to avoid answering twice. */
|
|
205
|
+
isOffline: boolean;
|
|
206
|
+
/** How many hops this message has been forwarded. `>= 5` is WhatsApp's "forwarded many times". */
|
|
207
|
+
forwardCount: number;
|
|
208
|
+
/** The chat's disappearing timer in seconds, or `null` when messages are kept. */
|
|
209
|
+
ephemeralDuration: number | null;
|
|
210
|
+
/** Whether WhatsApp addressed this message by phone number or by LID. */
|
|
211
|
+
addressingMode: 'pn' | 'lid';
|
|
212
|
+
/** JIDs of groups tagged in the message (community `@group` mentions). */
|
|
213
|
+
mentionedGroups: string[];
|
|
214
|
+
/** Present only on the first message of a chat opened from a Meta ad. */
|
|
215
|
+
ad?: AdAttribution;
|
|
216
|
+
/** Present only when the sender is a verified WhatsApp Business account. */
|
|
217
|
+
business?: BusinessInfo;
|
|
173
218
|
isQuestion: boolean;
|
|
174
219
|
isPrefix: boolean;
|
|
175
220
|
isTagMe: boolean;
|
|
@@ -217,6 +262,13 @@ export interface BuildContextInput {
|
|
|
217
262
|
isForwarded: boolean;
|
|
218
263
|
isBroadcast: boolean;
|
|
219
264
|
isNewsletter: boolean;
|
|
265
|
+
isOffline?: boolean;
|
|
266
|
+
forwardCount?: number;
|
|
267
|
+
ephemeralDuration?: number | null;
|
|
268
|
+
addressingMode?: 'pn' | 'lid';
|
|
269
|
+
mentionedGroups?: string[];
|
|
270
|
+
ad?: AdAttribution;
|
|
271
|
+
business?: BusinessInfo;
|
|
220
272
|
prefixes: string[];
|
|
221
273
|
citationConfig?: CitationConfig;
|
|
222
274
|
lidMap?: Map<string, string>;
|
|
@@ -7,6 +7,8 @@ export interface DecodeContext {
|
|
|
7
7
|
selfLid?: string;
|
|
8
8
|
selfName?: string;
|
|
9
9
|
lidMap?: Map<string, string>;
|
|
10
|
+
/** WhatsApp replays a reconnect's backlog as `append`; live traffic arrives as `notify`. */
|
|
11
|
+
isOffline?: boolean;
|
|
10
12
|
logger?: DownloadLogger;
|
|
11
13
|
channelId?: string;
|
|
12
14
|
receiverId?: string;
|
|
@@ -4,6 +4,8 @@ import { type LongLike } from './_shared.js';
|
|
|
4
4
|
export interface MutationContext {
|
|
5
5
|
selfJid: string;
|
|
6
6
|
pushName?: string;
|
|
7
|
+
/** Looks up the original poll so a vote's option hashes can be turned back into their text. */
|
|
8
|
+
resolvePoll?: (id: string, remoteJid: string) => Promise<proto.IWebMessageInfo | null>;
|
|
7
9
|
}
|
|
8
10
|
export interface ReactionItem {
|
|
9
11
|
key: WAMessageKey;
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './guards.js';
|
|
2
|
-
export type { ButtonClickPayload, CallBase, CallPayload, DeletePayload, EditPayload, GroupJoinPayload, GroupLeavePayload, GroupParticipantInfo, GroupUpdatePayload, HistorySyncPayload, InboundEventMap, InboundEventName, LimitedPayload, ListSelectPayload, MediaDescriptor, MediaDownloadResult, MediaKind, MemberTagPayload, NewsletterPayload, PollVotePayload, PresencePayload, QuotedRef, ReactionPayload, SenderInfo, } from './types.js';
|
|
2
|
+
export type { ButtonClickPayload, CallBase, CallerInfo, CallPayload, DeletePayload, EditPayload, GroupJoinPayload, GroupLeavePayload, GroupParticipantInfo, GroupUpdatePayload, HistorySyncPayload, InboundEventMap, InboundEventName, LimitedPayload, ListSelectPayload, MediaDescriptor, MediaDownloadResult, MediaKind, MemberTagPayload, NewsletterPayload, PollVotePayload, PresencePayload, QuotedRef, ReactionPayload, SenderInfo, } from './types.js';
|
|
3
3
|
export type { BuildContextInput, ChatType, CitationConfig, CitationPredicates, ContextMedia, MentionAllContext, MentionContext, MessageContext, SenderDevice, } from './context.js';
|
|
4
4
|
export { buildMessageContext } from './context.js';
|
package/dist/events/types.d.ts
CHANGED
|
@@ -54,7 +54,10 @@ export interface DeletePayload {
|
|
|
54
54
|
}
|
|
55
55
|
export interface PollVotePayload {
|
|
56
56
|
pollKey: WAMessageKey;
|
|
57
|
+
/** Raw SHA-256 hashes WhatsApp sends. Use {@link PollVotePayload.options} for readable text. */
|
|
57
58
|
selectedOptions: string[];
|
|
59
|
+
/** The option text the voter picked. Needs the original poll in the store; empty when unavailable. */
|
|
60
|
+
options(): Promise<string[]>;
|
|
58
61
|
voter: SenderInfo;
|
|
59
62
|
timestamp: number;
|
|
60
63
|
}
|
|
@@ -109,6 +112,25 @@ export type CallPayload = (CallBase & {
|
|
|
109
112
|
}) | (CallBase & {
|
|
110
113
|
kind: 'ended';
|
|
111
114
|
});
|
|
115
|
+
export interface CallerInfo {
|
|
116
|
+
/** Caller platform as WhatsApp reports it, e.g. `iphone`, `android`, `smba`. More reliable than a jid device index. */
|
|
117
|
+
platform?: string;
|
|
118
|
+
/** Caller's WhatsApp app version, e.g. `2.26.30.78`. */
|
|
119
|
+
appVersion?: string;
|
|
120
|
+
/** Caller's pushname carried on the call stanza. */
|
|
121
|
+
name?: string;
|
|
122
|
+
/** ISO 3166 country the caller is dialling from, e.g. `ID`. */
|
|
123
|
+
countryCode?: string;
|
|
124
|
+
/** Caller's phone-number jid — present even when the call itself is addressed by LID. */
|
|
125
|
+
phoneJid?: string;
|
|
126
|
+
/** Raw network medium code the caller's device reported. */
|
|
127
|
+
networkMedium?: number;
|
|
128
|
+
/** Screen size the caller's device advertised. Video calls only. */
|
|
129
|
+
screen?: {
|
|
130
|
+
width: number;
|
|
131
|
+
height: number;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
112
134
|
export interface CallBase {
|
|
113
135
|
callId: string;
|
|
114
136
|
from: string;
|
|
@@ -116,6 +138,8 @@ export interface CallBase {
|
|
|
116
138
|
isVideo: boolean;
|
|
117
139
|
timestamp: number;
|
|
118
140
|
status?: string;
|
|
141
|
+
/** Extra caller details from the raw call stanza. Absent when WhatsApp did not send them. */
|
|
142
|
+
caller?: CallerInfo;
|
|
119
143
|
}
|
|
120
144
|
export interface HistorySyncPayload {
|
|
121
145
|
syncType: string;
|