whalibmob 5.40.34 → 5.40.37

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/index.d.ts CHANGED
@@ -184,6 +184,127 @@ export interface ConnectWebOptions {
184
184
  fetchVersion?: boolean;
185
185
  /** Emit the QR as a `wa.me/settings/linked_devices#…` link instead of the bare fields. */
186
186
  qrWrapUrl?: boolean;
187
+ /**
188
+ * Called once the phone has authorised this device and before the link is
189
+ * confirmed. Return `false` to turn the link down; `null` removes a callback
190
+ * set earlier.
191
+ */
192
+ prePair?: ((info: PrePairInfo) => boolean | void | Promise<boolean | void>) | null;
193
+ /**
194
+ * Passkey linking: send the confirmation without waiting for the caller when
195
+ * the phone needs no code comparison (`skipHandoffUx`). Default `true`.
196
+ */
197
+ passkeyAutoConfirm?: boolean;
198
+ /**
199
+ * Announce at login that chats are stored by LID. Default `true`; set `false`
200
+ * if your own storage is still keyed by phone number.
201
+ */
202
+ lidDbMigrated?: boolean;
203
+ }
204
+
205
+ /** A message another message acts on. */
206
+ export interface MessageTarget {
207
+ id: string;
208
+ fromMe?: boolean;
209
+ /** In a group, who sent it when it is not ours. */
210
+ participant?: Jid;
211
+ }
212
+
213
+ export interface PollVoteTarget {
214
+ id: string;
215
+ /** Who sent the poll; not needed when `fromMe`. */
216
+ sender?: Jid;
217
+ fromMe?: boolean;
218
+ /** The poll's 32-byte message secret. */
219
+ encKey: Buffer;
220
+ }
221
+
222
+ export interface RawMessageOptions {
223
+ id?: string;
224
+ /** What the stanza says the message is. Default `text`. */
225
+ type?: 'text' | 'media' | 'poll' | 'reaction';
226
+ /** For `media`: image, video, audio, ptt, document, sticker, gif, vcard… */
227
+ mediaType?: string;
228
+ pollType?: 'creation' | 'vote';
229
+ /** `'1'` edit, `'2'` pin, `'7'` revoke, `'8'` admin revoke. */
230
+ edit?: string;
231
+ /** Tell recipients to show nothing if it cannot be decrypted. */
232
+ hide?: boolean;
233
+ }
234
+
235
+ export interface SecretMessageOptions {
236
+ /** The target message's 32-byte secret (`decoded.messageSecret` on it). */
237
+ messageSecret: Buffer;
238
+ targetSender?: Jid;
239
+ sender?: Jid;
240
+ }
241
+
242
+ export interface SecretMessageResult {
243
+ type: 'encReaction' | 'encComment' | 'encEventResponse' | 'secretEncrypted';
244
+ /** The label the key was derived under, e.g. `Enc Reaction`. */
245
+ secretType: string;
246
+ targetKey: { remoteJid: string | null; fromMe: boolean; id: string | null; participant: string | null };
247
+ /** The protobuf that was inside. */
248
+ plaintext: Buffer;
249
+ /** Read as a Message where that is what it is: an edit, a comment. */
250
+ decoded: any | null;
251
+ /** A reaction's emoji; empty when it was removed. */
252
+ text?: string;
253
+ response?: 'going' | 'not_going' | 'maybe' | 'unknown';
254
+ senderTimestampMs?: number;
255
+ timestampMs?: number;
256
+ extraGuestCount?: number;
257
+ messageRaw?: Buffer;
258
+ }
259
+
260
+ /** One post of a channel. */
261
+ export interface NewsletterMessage {
262
+ serverId: number | null;
263
+ id: string | null;
264
+ type: string | null;
265
+ ts: number;
266
+ viewsCount: number;
267
+ forwardsCount: number;
268
+ reactionCounts: Record<string, number> | null;
269
+ /** The encoded Message. */
270
+ raw: Buffer | null;
271
+ decoded: any | null;
272
+ }
273
+
274
+ /** Who a pair-success would link this device to. */
275
+ export interface PrePairInfo {
276
+ jid: Jid;
277
+ lid: Jid | null;
278
+ /** What the primary runs, e.g. `android`. */
279
+ platform: string | null;
280
+ businessName: string | null;
281
+ }
282
+
283
+ /** WebAuthn request options in their JSON form; binary members are base64url. */
284
+ export interface PasskeyRequestOptions {
285
+ challenge: string;
286
+ timeout?: number;
287
+ rpId?: string;
288
+ allowCredentials?: Array<{ id: string; type: string; transports?: string[] }>;
289
+ userVerification?: string;
290
+ extensions?: Record<string, unknown>;
291
+ [key: string]: unknown;
292
+ }
293
+
294
+ /** Bytes, or the same as base64url or base64 text. */
295
+ export type PasskeyBytes = string | Buffer | Uint8Array | ArrayBuffer;
296
+
297
+ /** A WebAuthn assertion — what `credential.toJSON()` returns in a browser. */
298
+ export interface PasskeyAssertion {
299
+ id?: string;
300
+ rawId: PasskeyBytes;
301
+ type?: string;
302
+ response: {
303
+ clientDataJSON: PasskeyBytes;
304
+ authenticatorData: PasskeyBytes;
305
+ signature: PasskeyBytes;
306
+ userHandle?: PasskeyBytes | null;
307
+ };
187
308
  }
188
309
 
189
310
  export interface DisconnectOptions {
@@ -965,6 +1086,38 @@ export interface WhalibmobEvents {
965
1086
  qr_timeout: () => void;
966
1087
  pair_device: (p: { refs: string[] }) => void;
967
1088
  paired: (p: { jid: Jid; lid: Jid; deviceIndex: number; platform: string }) => void;
1089
+ /** Companion mode: a pair-success was turned down, here or by `prePair`. `error` fires too. */
1090
+ pair_error: (p: { jid: Jid | null; lid: Jid | null; platform: string | null; err: Error }) => void;
1091
+
1092
+ /** A keepalive ping went unanswered. The connection is not closed for you. */
1093
+ keepalive_timeout: (k: { errorCount: number; lastSuccess: number | null }) => void;
1094
+ /** The first keepalive answered after one or more were missed. */
1095
+ keepalive_restored: (k: { missed: number }) => void;
1096
+ /** What the server is about to replay from while this client was away. */
1097
+ offline_sync_preview: (o: { total: number; appDataChanges: number; messages: number; notifications: number; receipts: number }) => void;
1098
+ /** The replay is done; what arrives from here on is live. */
1099
+ offline_sync_completed: (o: { count: number }) => void;
1100
+ /** The account is temporarily banned; the session survives. */
1101
+ temporary_ban: (b: { code: string | null; expireSecs: number | null; expiresAt: number | null }) => void;
1102
+ /** The QR was scanned by a phone with multi-device turned off. */
1103
+ qr_scanned_without_multidevice: (e: Record<string, never>) => void;
1104
+ picture_update: (p: { jid: Jid; author: Jid | null; removed: boolean; pictureId: string | null; ts: number }) => void;
1105
+ about_update: (a: { jid: Jid; about: string; ts: number }) => void;
1106
+ newsletter_live_update: (u: { jid: Jid; ts: number; messages: NewsletterMessage[] }) => void;
1107
+ label_edit: (l: { labelId: string; name: string; color: number; deleted: boolean; remote?: boolean; synced?: boolean }) => void;
1108
+ label_association: (l: { labelId: string; jid: Jid; msgId: string | null; labeled: boolean; remote?: boolean; synced?: boolean }) => void;
1109
+ message_deleted_for_me: (m: { jid: Jid; msgId: string; fromMe: boolean; deleteMedia: boolean; remote?: boolean; synced?: boolean }) => void;
1110
+ status_muted: (s: { jid: Jid; muted: boolean; remote?: boolean }) => void;
1111
+ unarchive_chats_setting: (s: { unarchiveChats: boolean; remote?: boolean }) => void;
1112
+ /** Companion mode: the account can be linked with a passkey. Answer with `sendPasskeyResponse`. */
1113
+ passkey_request: (p: { publicKey: PasskeyRequestOptions }) => void;
1114
+ /**
1115
+ * Companion mode: the code to compare with the phone. Unless `autoConfirmed`,
1116
+ * call `sendPasskeyConfirmation` once the owner says it matches.
1117
+ */
1118
+ passkey_confirmation: (p: { code: string; skipHandoffUx: boolean; autoConfirmed: boolean }) => void;
1119
+ /** Companion mode: a passkey step failed. `continuation` is false for the request itself. */
1120
+ passkey_error: (p: { err: Error & { code?: string }; continuation: boolean }) => void;
968
1121
  restart_required: (r: { reason?: string }) => void;
969
1122
  web_ready_for_pairing: () => void;
970
1123
 
@@ -1209,8 +1362,16 @@ export declare class WhalibmobClient extends EventEmitter {
1209
1362
  connectWeb(phoneNumber: string, opts?: ConnectWebOptions): Promise<this>;
1210
1363
  /** Alias of `connectWeb`. */
1211
1364
  initWeb(phoneNumber: string, opts?: ConnectWebOptions): Promise<this>;
1212
- /** Ask for an 8-character pairing code. Throws if the session is already linked. */
1365
+ /**
1366
+ * Ask for an 8-character pairing code. Resolves once the server has accepted
1367
+ * the request; throws if it refuses (`err.code` is `PAIRING_CODE_*`) or if the
1368
+ * session is already linked.
1369
+ */
1213
1370
  requestPairingCode(phoneNumber?: string, customCode?: string): Promise<string>;
1371
+ /** Companion mode: answer a `passkey_request` with the authenticator's assertion. */
1372
+ sendPasskeyResponse(response: PasskeyAssertion): Promise<void>;
1373
+ /** Companion mode: finish a passkey link once the code has been confirmed. */
1374
+ sendPasskeyConfirmation(): Promise<void>;
1214
1375
  /** Mobile primary only: cached, bounded pending alerts, no authorization. */
1215
1376
  getPrimaryLinkInvitations(): PrimaryLinkInvitation[];
1216
1377
  /** Approve a separate companion on the current primary socket; never requests SMS. */
@@ -1347,6 +1508,18 @@ export declare class WhalibmobClient extends EventEmitter {
1347
1508
  * without them only the SHA-256 of each choice is available.
1348
1509
  */
1349
1510
  decryptPollVote(vote: DecodedMessage | IncomingMessage, opts: PollVoteOptions): PollVoteResult;
1511
+ /** Vote on a poll. `selected` are option texts; an empty list clears the vote. */
1512
+ sendPollVote(chatJid: Jid, poll: PollVoteTarget, selected: string[], opts?: SendOptions & { sender?: Jid }): Promise<SendResult>;
1513
+ /** Send an encoded `Message` this library has no method for. */
1514
+ sendRawMessage(to: Jid, message: Buffer, opts?: RawMessageOptions): Promise<SendResult>;
1515
+ /** Pin a message for everyone in a chat. */
1516
+ pinMessage(chatJid: Jid, target: MessageTarget, opts?: { pin?: boolean; durationSecs?: number; id?: string }): Promise<SendResult>;
1517
+ unpinMessage(chatJid: Jid, target: MessageTarget, opts?: { id?: string }): Promise<SendResult>;
1518
+ /** Open an add-on sealed under another message's secret. Throws when it will not open. */
1519
+ decryptSecretMessage(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
1520
+ decryptReaction(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
1521
+ decryptComment(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
1522
+ decryptEventResponse(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
1350
1523
  /** Ask the sender's phone to re-upload a file the CDN no longer has. */
1351
1524
  requestMediaRetry(info: { id: string; chatJid: Jid; fromMe: boolean; participant?: Jid }, mediaKey: Buffer): Promise<void>;
1352
1525
  decryptMediaRetry(notification: MediaRetryNotification, mediaKey: Buffer): MediaRetryResult;
@@ -1368,6 +1541,16 @@ export declare class WhalibmobClient extends EventEmitter {
1368
1541
  queryPictureInfo(jid: Jid, opts?: object): Promise<any>;
1369
1542
  downloadProfilePicture(jid: Jid, opts?: object): Promise<Buffer | null>;
1370
1543
  queryBusinessProfile(jid: Jid): Promise<BusinessProfile | null>;
1544
+ resolveBusinessMessageLink(linkOrCode: string): Promise<{ jid: Jid | null; pushName: string | null; message: string | null;
1545
+ isSigned: boolean; verifiedName: string | null; verifiedLevel: string | null }>;
1546
+ /** Our own contact link; `revoke` replaces it. */
1547
+ getContactQrLink(revoke?: boolean): Promise<{ code: string; link: string }>;
1548
+ resolveContactQrLink(linkOrCode: string): Promise<{ jid: Jid | null; pushName: string | null; type: string | null }>;
1549
+ getBotList(): Promise<Array<{ jid: Jid; personaId: string | null }>>;
1550
+ fetchStickerPack(packId: string): Promise<any>;
1551
+ registerWebPush(subscription: { endpoint: string; auth: Buffer | string; p256dh: Buffer | string }): Promise<void>;
1552
+ getPushConfig(): Promise<Record<string, string>>;
1553
+ sendHistorySyncServerErrorReceipt(msgId: string, mediaKey: Buffer): Promise<void>;
1371
1554
 
1372
1555
  // ─── Profile ─────────────────────────────────────────────────────────────
1373
1556
  /** Publishes and saves rename intent. True confirms an App State write only;
@@ -1455,6 +1638,12 @@ export declare class WhalibmobClient extends EventEmitter {
1455
1638
  archiveChat(jid: Jid): Promise<boolean>;
1456
1639
  unarchiveChat(jid: Jid): Promise<boolean>;
1457
1640
  starMessage(msgId: string, chatJid: Jid, fromMe: boolean): Promise<boolean>;
1641
+ /** Create, rename or recolour a label, or delete it with `{ deleted: true }`. Needs app-state sync. */
1642
+ editLabel(labelId: string | number, opts?: { name?: string; color?: number; deleted?: boolean }): Promise<void>;
1643
+ labelChat(jid: Jid, labelId: string | number, labeled?: boolean): Promise<void>;
1644
+ labelMessage(jid: Jid, labelId: string | number, msgId: string, labeled?: boolean): Promise<void>;
1645
+ /** Delete one message on this account's devices only. Needs app-state sync. */
1646
+ deleteMessageForMe(jid: Jid, msgId: string, fromMe: boolean, opts?: { timestamp?: number; deleteMedia?: boolean }): Promise<void>;
1458
1647
  unstarMessage(msgId: string, chatJid: Jid, fromMe: boolean): Promise<boolean>;
1459
1648
  changeEphemeralTimer(jid: Jid, seconds: number): Promise<any>;
1460
1649
  changeNewChatsEphemeralTimer(seconds: number): Promise<any>;
@@ -1543,6 +1732,9 @@ export declare class WhalibmobClient extends EventEmitter {
1543
1732
  createCommunity(subject: string, description?: string, opts?: object): Promise<GroupMetadata>;
1544
1733
  deactivateCommunity(communityJid: Jid): Promise<any>;
1545
1734
  linkGroupsToCommunity(communityJid: Jid, groupJids: Jid[]): Promise<any>;
1735
+ getSubGroups(communityJid: Jid): Promise<Array<{ jid: Jid; subject: string | null; subjectTime: number; size: number | null; isDefaultSubGroup: boolean }>>;
1736
+ /** Everyone in any group of a community. Community admins only. */
1737
+ getLinkedGroupsParticipants(communityJid: Jid): Promise<Array<{ jid: Jid; phoneNumber: Jid | null; lid: Jid | null }>>;
1546
1738
  unlinkGroupFromCommunity(communityJid: Jid, groupJid: Jid): Promise<any>;
1547
1739
 
1548
1740
  // ─── Newsletters ─────────────────────────────────────────────────────────
@@ -1552,6 +1744,20 @@ export declare class WhalibmobClient extends EventEmitter {
1552
1744
  queryNewsletterMetadata(newsletterJid: Jid): Promise<any>;
1553
1745
  changeNewsletterDescription(newsletterJid: Jid, description: string): Promise<any>;
1554
1746
  sendNewsletterText(newsletterJid: Jid, text: string): Promise<any>;
1747
+ /** Post an encoded `Message` to a channel you administer. */
1748
+ sendNewsletterMessage(newsletterJid: Jid, message: Buffer,
1749
+ opts?: { id?: string; type?: string; mediaType?: string; mediaId?: string; edit?: string }): Promise<{ id: string; to: Jid }>;
1750
+ getNewsletterMessages(newsletterJid: Jid, opts?: { count?: number; before?: number }): Promise<NewsletterMessage[]>;
1751
+ getNewsletterMessageUpdates(newsletterJid: Jid, opts?: { count?: number; since?: number; after?: number }): Promise<NewsletterMessage[]>;
1752
+ /** Ask for count changes to be pushed as `newsletter_live_update`, for `durationSecs`. */
1753
+ subscribeNewsletterLiveUpdates(newsletterJid: Jid): Promise<{ durationSecs: number }>;
1754
+ markNewsletterViewed(newsletterJid: Jid, serverIds: number | number[]): Promise<void>;
1755
+ /** React to a channel post; an empty reaction takes ours back. */
1756
+ sendNewsletterReaction(newsletterJid: Jid, serverId: number, reaction: string, opts?: { id?: string }): Promise<{ id: string; to: Jid }>;
1757
+ muteNewsletter(newsletterJid: Jid, mute?: boolean): Promise<{ jid: Jid; muted: boolean }>;
1758
+ unmuteNewsletter(newsletterJid: Jid): Promise<{ jid: Jid; muted: boolean }>;
1759
+ getSubscribedNewsletters(): Promise<any[]>;
1760
+ getNewsletterInfoWithInvite(linkOrCode: string): Promise<any>;
1555
1761
 
1556
1762
  // ─── Stores on disk ──────────────────────────────────────────────────────
1557
1763
  getHistoryStore(): any;
@@ -2150,6 +2356,7 @@ export declare const Messages: {
2150
2356
  RETRY_KEY_INFO: string;
2151
2357
  };
2152
2358
  ReportingToken: LibModule;
2359
+ MessageSecret: LibModule;
2153
2360
  TcTokenStore: LibModule;
2154
2361
  };
2155
2362
 
@@ -2264,6 +2471,7 @@ export declare const Hkdf: LibModule & {
2264
2471
  export declare const PairingCode: LibModule;
2265
2472
  export declare const CompanionPairing: LibModule;
2266
2473
  export declare const QrPairing: LibModule;
2474
+ export declare const PasskeyPairing: LibModule;
2267
2475
  export declare const WebVersion: LibModule;
2268
2476
  export declare const WebProto: LibModule;
2269
2477
 
package/index.js CHANGED
@@ -145,6 +145,7 @@ const Plist = require('./lib/plist');
145
145
  const PairingCode = require('./lib/PairingCode');
146
146
  const CompanionPairing = require('./lib/CompanionPairing');
147
147
  const QrPairing = require('./lib/QrPairing');
148
+ const PasskeyPairing = require('./lib/PasskeyPairing');
148
149
  const WebVersion = require('./lib/WebVersion');
149
150
  const WebProto = require('./lib/webproto');
150
151
 
@@ -169,6 +170,7 @@ const GroupParticipant = require('./lib/GroupParticipant');
169
170
  const Messages = {
170
171
  MessageSender: require('./lib/messages/MessageSender'),
171
172
  MediaRetry: require('./lib/messages/MediaRetry'),
173
+ MessageSecret: require('./lib/messages/MessageSecret'),
172
174
  ReportingToken: require('./lib/messages/ReportingToken'),
173
175
  TcTokenStore: require('./lib/messages/TcTokenStore')
174
176
  };
@@ -418,6 +420,7 @@ module.exports = {
418
420
  PairingCode,
419
421
  CompanionPairing,
420
422
  QrPairing,
423
+ PasskeyPairing,
421
424
  WebVersion,
422
425
  WebProto,
423
426