wuzapi 1.7.0 → 1.7.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 +61 -2
- package/dist/types/webhook.d.ts +20 -2
- package/dist/webhook.js +19 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -977,6 +977,38 @@ switch (messageType) {
|
|
|
977
977
|
const pollMsg = webhookPayload.event.Message.pollCreationMessageV3;
|
|
978
978
|
console.log("Poll:", pollMsg.name, `${pollMsg.options.length} options`);
|
|
979
979
|
break;
|
|
980
|
+
|
|
981
|
+
case MessageType.BUTTONS_RESPONSE:
|
|
982
|
+
const buttonResponse = webhookPayload.event.Message.buttonsResponseMessage;
|
|
983
|
+
console.log("Button clicked:", buttonResponse.selectedButtonId);
|
|
984
|
+
break;
|
|
985
|
+
|
|
986
|
+
case MessageType.LIST_RESPONSE:
|
|
987
|
+
const listResponse = webhookPayload.event.Message.listResponseMessage;
|
|
988
|
+
console.log(
|
|
989
|
+
"List item selected:",
|
|
990
|
+
listResponse.singleSelectReply.selectedRowId
|
|
991
|
+
);
|
|
992
|
+
break;
|
|
993
|
+
|
|
994
|
+
case MessageType.GROUP_INVITE:
|
|
995
|
+
const groupInvite = webhookPayload.event.Message.groupInviteMessage;
|
|
996
|
+
console.log("Group invite:", groupInvite.groupName);
|
|
997
|
+
break;
|
|
998
|
+
|
|
999
|
+
case MessageType.VIEW_ONCE:
|
|
1000
|
+
const viewOnceMsg = webhookPayload.event.Message.viewOnceMessage;
|
|
1001
|
+
console.log("View once message received");
|
|
1002
|
+
break;
|
|
1003
|
+
|
|
1004
|
+
// Handle other new message types
|
|
1005
|
+
case MessageType.BUTTONS:
|
|
1006
|
+
case MessageType.LIST:
|
|
1007
|
+
case MessageType.TEMPLATE:
|
|
1008
|
+
case MessageType.POLL:
|
|
1009
|
+
case MessageType.POLL_UPDATE:
|
|
1010
|
+
console.log(`Interactive message type: ${messageType}`);
|
|
1011
|
+
break;
|
|
980
1012
|
}
|
|
981
1013
|
|
|
982
1014
|
// Handle media intelligently
|
|
@@ -991,20 +1023,47 @@ if (hasS3Media(webhookPayload)) {
|
|
|
991
1023
|
|
|
992
1024
|
```typescript
|
|
993
1025
|
enum MessageType {
|
|
1026
|
+
// Basic messages
|
|
994
1027
|
TEXT = "conversation", // Simple text messages
|
|
995
1028
|
EXTENDED_TEXT = "extendedTextMessage", // Rich text messages
|
|
1029
|
+
|
|
1030
|
+
// Media messages
|
|
996
1031
|
IMAGE = "imageMessage", // Photos, screenshots
|
|
997
1032
|
VIDEO = "videoMessage", // Video files, GIFs
|
|
998
1033
|
AUDIO = "audioMessage", // Audio files, voice messages
|
|
999
1034
|
DOCUMENT = "documentMessage", // PDFs, Word docs, etc.
|
|
1035
|
+
STICKER = "stickerMessage", // Stickers (animated/static)
|
|
1036
|
+
|
|
1037
|
+
// Contact & location
|
|
1000
1038
|
CONTACT = "contactMessage", // Shared contacts
|
|
1001
1039
|
LOCATION = "locationMessage", // Location pins
|
|
1002
|
-
|
|
1040
|
+
|
|
1041
|
+
// Interactive messages
|
|
1042
|
+
BUTTONS = "buttonsMessage", // Interactive buttons
|
|
1043
|
+
LIST = "listMessage", // List menus
|
|
1044
|
+
TEMPLATE = "templateMessage", // Template messages
|
|
1045
|
+
|
|
1046
|
+
// Response messages
|
|
1047
|
+
BUTTONS_RESPONSE = "buttonsResponseMessage", // Button click responses
|
|
1048
|
+
LIST_RESPONSE = "listResponseMessage", // List selection responses
|
|
1049
|
+
|
|
1050
|
+
// Group messages
|
|
1051
|
+
GROUP_INVITE = "groupInviteMessage", // Group invitations
|
|
1052
|
+
|
|
1053
|
+
// Poll messages
|
|
1054
|
+
POLL = "pollCreationMessage", // Polls (standard)
|
|
1055
|
+
POLL_CREATION = "pollCreationMessageV3", // Polls (v3)
|
|
1056
|
+
POLL_UPDATE = "pollUpdateMessage", // Poll vote updates
|
|
1057
|
+
|
|
1058
|
+
// Special messages
|
|
1059
|
+
VIEW_ONCE = "viewOnceMessage", // View once messages
|
|
1003
1060
|
REACTION = "reactionMessage", // Message reactions (emoji)
|
|
1004
|
-
POLL_CREATION = "pollCreationMessageV3", // Polls (groups only)
|
|
1005
1061
|
EDITED = "editedMessage", // Edited messages
|
|
1062
|
+
|
|
1063
|
+
// System messages
|
|
1006
1064
|
PROTOCOL = "protocolMessage", // System messages
|
|
1007
1065
|
DEVICE_SENT = "deviceSentMessage", // Multi-device messages
|
|
1066
|
+
|
|
1008
1067
|
UNKNOWN = "unknown", // Unrecognized types
|
|
1009
1068
|
}
|
|
1010
1069
|
```
|
package/dist/types/webhook.d.ts
CHANGED
|
@@ -301,11 +301,20 @@ export interface WebhookGenericMessage {
|
|
|
301
301
|
audioMessage?: WebhookAudioMessage;
|
|
302
302
|
documentMessage?: WebhookDocumentMessage;
|
|
303
303
|
contactMessage?: WebhookContactMessage;
|
|
304
|
-
pollCreationMessageV3?: WebhookPollCreationMessageV3;
|
|
305
304
|
locationMessage?: WebhookLocationMessage;
|
|
306
305
|
stickerMessage?: WebhookStickerMessage;
|
|
307
306
|
reactionMessage?: WebhookReactionMessage;
|
|
308
307
|
editedMessage?: WebhookEditedMessage;
|
|
308
|
+
buttonsMessage?: unknown;
|
|
309
|
+
listMessage?: unknown;
|
|
310
|
+
templateMessage?: unknown;
|
|
311
|
+
buttonsResponseMessage?: unknown;
|
|
312
|
+
listResponseMessage?: unknown;
|
|
313
|
+
groupInviteMessage?: unknown;
|
|
314
|
+
pollCreationMessage?: unknown;
|
|
315
|
+
pollCreationMessageV3?: WebhookPollCreationMessageV3;
|
|
316
|
+
pollUpdateMessage?: unknown;
|
|
317
|
+
viewOnceMessage?: unknown;
|
|
309
318
|
protocolMessage?: {
|
|
310
319
|
type?: number;
|
|
311
320
|
editedMessage?: WebhookGenericMessage;
|
|
@@ -329,13 +338,22 @@ export declare enum MessageType {
|
|
|
329
338
|
AUDIO = "audioMessage",
|
|
330
339
|
DOCUMENT = "documentMessage",
|
|
331
340
|
CONTACT = "contactMessage",
|
|
332
|
-
POLL_CREATION = "pollCreationMessageV3",
|
|
333
341
|
LOCATION = "locationMessage",
|
|
334
342
|
STICKER = "stickerMessage",
|
|
335
343
|
REACTION = "reactionMessage",
|
|
336
344
|
EDITED = "editedMessage",
|
|
337
345
|
PROTOCOL = "protocolMessage",
|
|
338
346
|
DEVICE_SENT = "deviceSentMessage",
|
|
347
|
+
BUTTONS = "buttonsMessage",
|
|
348
|
+
LIST = "listMessage",
|
|
349
|
+
TEMPLATE = "templateMessage",
|
|
350
|
+
BUTTONS_RESPONSE = "buttonsResponseMessage",
|
|
351
|
+
LIST_RESPONSE = "listResponseMessage",
|
|
352
|
+
GROUP_INVITE = "groupInviteMessage",
|
|
353
|
+
POLL = "pollCreationMessage",
|
|
354
|
+
POLL_CREATION = "pollCreationMessageV3",
|
|
355
|
+
POLL_UPDATE = "pollUpdateMessage",
|
|
356
|
+
VIEW_ONCE = "viewOnceMessage",
|
|
339
357
|
UNKNOWN = "unknown"
|
|
340
358
|
}
|
|
341
359
|
export interface WebhookHistorySyncNotification {
|
package/dist/webhook.js
CHANGED
|
@@ -58,13 +58,22 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
|
58
58
|
MessageType2["AUDIO"] = "audioMessage";
|
|
59
59
|
MessageType2["DOCUMENT"] = "documentMessage";
|
|
60
60
|
MessageType2["CONTACT"] = "contactMessage";
|
|
61
|
-
MessageType2["POLL_CREATION"] = "pollCreationMessageV3";
|
|
62
61
|
MessageType2["LOCATION"] = "locationMessage";
|
|
63
62
|
MessageType2["STICKER"] = "stickerMessage";
|
|
64
63
|
MessageType2["REACTION"] = "reactionMessage";
|
|
65
64
|
MessageType2["EDITED"] = "editedMessage";
|
|
66
65
|
MessageType2["PROTOCOL"] = "protocolMessage";
|
|
67
66
|
MessageType2["DEVICE_SENT"] = "deviceSentMessage";
|
|
67
|
+
MessageType2["BUTTONS"] = "buttonsMessage";
|
|
68
|
+
MessageType2["LIST"] = "listMessage";
|
|
69
|
+
MessageType2["TEMPLATE"] = "templateMessage";
|
|
70
|
+
MessageType2["BUTTONS_RESPONSE"] = "buttonsResponseMessage";
|
|
71
|
+
MessageType2["LIST_RESPONSE"] = "listResponseMessage";
|
|
72
|
+
MessageType2["GROUP_INVITE"] = "groupInviteMessage";
|
|
73
|
+
MessageType2["POLL"] = "pollCreationMessage";
|
|
74
|
+
MessageType2["POLL_CREATION"] = "pollCreationMessageV3";
|
|
75
|
+
MessageType2["POLL_UPDATE"] = "pollUpdateMessage";
|
|
76
|
+
MessageType2["VIEW_ONCE"] = "viewOnceMessage";
|
|
68
77
|
MessageType2["UNKNOWN"] = "unknown";
|
|
69
78
|
return MessageType2;
|
|
70
79
|
})(MessageType || {});
|
|
@@ -95,7 +104,16 @@ function discoverMessageType(message) {
|
|
|
95
104
|
if (message.locationMessage) return "locationMessage";
|
|
96
105
|
if (message.stickerMessage) return "stickerMessage";
|
|
97
106
|
if (message.reactionMessage) return "reactionMessage";
|
|
107
|
+
if (message.buttonsMessage) return "buttonsMessage";
|
|
108
|
+
if (message.listMessage) return "listMessage";
|
|
109
|
+
if (message.templateMessage) return "templateMessage";
|
|
110
|
+
if (message.buttonsResponseMessage) return "buttonsResponseMessage";
|
|
111
|
+
if (message.listResponseMessage) return "listResponseMessage";
|
|
112
|
+
if (message.groupInviteMessage) return "groupInviteMessage";
|
|
113
|
+
if (message.pollCreationMessage) return "pollCreationMessage";
|
|
98
114
|
if (message.pollCreationMessageV3) return "pollCreationMessageV3";
|
|
115
|
+
if (message.pollUpdateMessage) return "pollUpdateMessage";
|
|
116
|
+
if (message.viewOnceMessage) return "viewOnceMessage";
|
|
99
117
|
if (message.editedMessage) return "editedMessage";
|
|
100
118
|
if (message.protocolMessage) return "protocolMessage";
|
|
101
119
|
if (message.deviceSentMessage) return "deviceSentMessage";
|
package/dist/webhook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sources":["../src/types/webhook.ts"],"sourcesContent":["// Import types that are identical from other modules\nimport type { VerifiedName } from \"./user.js\";\n\n// Webhook endpoints types\n\n// Webhook event types (events that can be subscribed to via webhooks)\nexport enum WebhookEventType {\n MESSAGE = \"Message\",\n UNDECRYPTABLE_MESSAGE = \"UndecryptableMessage\",\n RECEIPT = \"Receipt\",\n READ_RECEIPT = \"ReadReceipt\",\n MEDIA_RETRY = \"MediaRetry\",\n GROUP_INFO = \"GroupInfo\",\n JOINED_GROUP = \"JoinedGroup\",\n PICTURE = \"Picture\",\n BLOCKLIST_CHANGE = \"BlocklistChange\",\n BLOCKLIST = \"Blocklist\",\n CONNECTED = \"Connected\",\n DISCONNECTED = \"Disconnected\",\n CONNECT_FAILURE = \"ConnectFailure\",\n KEEP_ALIVE_RESTORED = \"KeepAliveRestored\",\n KEEP_ALIVE_TIMEOUT = \"KeepAliveTimeout\",\n LOGGED_OUT = \"LoggedOut\",\n CLIENT_OUTDATED = \"ClientOutdated\",\n TEMPORARY_BAN = \"TemporaryBan\",\n STREAM_ERROR = \"StreamError\",\n STREAM_REPLACED = \"StreamReplaced\",\n PAIR_SUCCESS = \"PairSuccess\",\n PAIR_ERROR = \"PairError\",\n QR = \"QR\",\n QR_SCANNED_WITHOUT_MULTIDEVICE = \"QRScannedWithoutMultidevice\",\n PRIVACY_SETTINGS = \"PrivacySettings\",\n PUSH_NAME_SETTING = \"PushNameSetting\",\n USER_ABOUT = \"UserAbout\",\n APP_STATE = \"AppState\",\n APP_STATE_SYNC_COMPLETE = \"AppStateSyncComplete\",\n HISTORY_SYNC = \"HistorySync\",\n OFFLINE_SYNC_COMPLETED = \"OfflineSyncCompleted\",\n OFFLINE_SYNC_PREVIEW = \"OfflineSyncPreview\",\n CALL_OFFER = \"CallOffer\",\n CALL_ACCEPT = \"CallAccept\",\n CALL_TERMINATE = \"CallTerminate\",\n CALL_OFFER_NOTICE = \"CallOfferNotice\",\n CALL_RELAY_LATENCY = \"CallRelayLatency\",\n PRESENCE = \"Presence\",\n CHAT_PRESENCE = \"ChatPresence\",\n IDENTITY_CHANGE = \"IdentityChange\",\n CAT_REFRESH_ERROR = \"CATRefreshError\",\n NEWSLETTER_JOIN = \"NewsletterJoin\",\n NEWSLETTER_LEAVE = \"NewsletterLeave\",\n NEWSLETTER_MUTE_CHANGE = \"NewsletterMuteChange\",\n NEWSLETTER_LIVE_UPDATE = \"NewsletterLiveUpdate\",\n FB_MESSAGE = \"FBMessage\",\n ALL = \"All\",\n}\n\n// Helper to get all webhook event values as string array\nexport const WEBHOOK_EVENTS = Object.values(WebhookEventType);\n\n// Type for webhook event names\nexport type WebhookEvent = keyof typeof WebhookEventType;\n\nexport interface SetWebhookRequest {\n webhook: string;\n events: (WebhookEvent | string)[];\n}\n\nexport interface SetWebhookResponse {\n WebhookURL: string;\n Events: string[];\n}\n\nexport interface GetWebhookResponse {\n subscribe: string[];\n webhook: string;\n}\n\nexport interface UpdateWebhookRequest {\n webhook?: string;\n events?: (WebhookEvent | string)[];\n Active?: boolean;\n}\n\nexport interface UpdateWebhookResponse {\n WebhookURL: string;\n Events: string[];\n active: boolean;\n}\n\nexport interface DeleteWebhookResponse {\n Details: string;\n}\n\n// Webhook payload types (what your webhook endpoint receives)\n\nexport interface S3MediaInfo {\n url: string;\n key: string;\n bucket: string;\n size: number;\n mimeType: string;\n fileName: string;\n}\n\n// Base interface that all webhook payloads extend from\nexport interface WebhookPayloadBase<T = unknown> {\n event: T;\n type: string;\n token: string;\n state?: string; // Optional state field (e.g., \"Read\" or \"Delivered\" for ReadReceipt events)\n}\n\n// Standard webhook payload with optional media\nexport interface WebhookPayload<T = unknown> extends WebhookPayloadBase<T> {\n s3?: S3MediaInfo;\n base64?: string;\n mimeType?: string;\n fileName?: string;\n}\n\n// Specific webhook payload types for different media delivery modes\n\n// S3 only delivery\nexport interface S3OnlyWebhookPayload<T = unknown>\n extends WebhookPayloadBase<T> {\n s3: S3MediaInfo;\n}\n\n// Base64 only delivery\nexport interface Base64OnlyWebhookPayload<T = unknown>\n extends WebhookPayloadBase<T> {\n base64: string;\n mimeType: string;\n fileName: string;\n}\n\n// Both S3 and Base64 delivery\nexport interface BothMediaWebhookPayload<T = unknown>\n extends WebhookPayloadBase<T> {\n s3: S3MediaInfo;\n base64: string;\n mimeType: string;\n fileName: string;\n}\n\n// Union type for all possible webhook payloads\nexport type AnyWebhookPayload<T = unknown> =\n | WebhookPayload<T>\n | S3OnlyWebhookPayload<T>\n | Base64OnlyWebhookPayload<T>\n | BothMediaWebhookPayload<T>;\n\n// Shared message and media interfaces for reusability across webhook events\n//\n// Note: Webhook events may have different structures than the corresponding\n// WhatsApp events in events.ts. Webhook events use flat structures with\n// string-based JIDs and ISO timestamp strings, while internal events use\n// structured JID objects and Date objects.\n\n// Common context info structures\nexport interface WebhookMessageContextInfo {\n deviceListMetadata?: WebhookDeviceListMetadata;\n deviceListMetadataVersion?: number;\n messageSecret?: string; // Encryption secret (string format for webhook)\n limitSharingV2?: {\n initiatedByMe: boolean;\n trigger: number;\n };\n}\n\nexport interface WebhookDeviceListMetadata {\n senderKeyHash?: string; // Base64 string format for webhook (vs Uint8Array in message.ts)\n senderTimestamp?: number;\n recipientKeyHash?: string; // Base64 string format for webhook\n recipientTimestamp?: number;\n senderAccountType?: number; // Webhook-specific field\n receiverAccountType?: number; // Webhook-specific field\n}\n\nexport interface WebhookContextInfo {\n disappearingMode?: {\n initiator: number;\n initiatedByMe?: boolean; // Webhook-specific field\n trigger?: number; // Webhook-specific field\n };\n ephemeralSettingTimestamp?: number;\n expiration?: number;\n forwardingScore?: number;\n isForwarded?: boolean;\n pairedMediaType?: number;\n statusSourceType?: number;\n featureEligibilities?: {\n canBeReshared?: boolean;\n };\n}\n\n// Common message types that are reused across different webhook events\nexport interface WebhookExtendedTextMessage {\n text: string;\n contextInfo?: WebhookContextInfo;\n inviteLinkGroupTypeV2?: number; // Webhook-specific field\n previewType?: number; // Webhook-specific field\n}\n\nexport interface WebhookImageMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n JPEGThumbnail?: string; // Base64 encoded JPEG thumbnail\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n height: number;\n imageSourceType: number; // Webhook-specific field\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n midQualityFileSHA256: string; // Mid quality file hash (webhook-specific)\n mimetype: string; // MIME type (e.g., \"image/jpeg\")\n scanLengths: number[]; // Progressive scan lengths (webhook-specific)\n scansSidecar: string; // Progressive scan sidecar data (webhook-specific)\n firstScanLength?: number; // First scan length (webhook-specific)\n firstScanSidecar?: string; // First scan sidecar (webhook-specific)\n width: number;\n}\n\nexport interface WebhookVideoMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n JPEGThumbnail?: string; // Base64 encoded JPEG thumbnail\n accessibilityLabel?: string;\n caption?: string;\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n externalShareFullVideoDurationInSeconds?: number; // Webhook-specific field\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n gifAttribution?: number; // GIF attribution type (0=none, 1=giphy, 2=tenor, etc.) (webhook-specific)\n gifPlayback?: boolean; // Whether this video should be played as a GIF (webhook-specific)\n height: number;\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n mimetype: string; // MIME type (e.g., \"video/mp4\")\n seconds: number; // Video duration in seconds\n streamingSidecar?: string; // Streaming sidecar data for video streaming\n thumbnailDirectPath?: string; // Thumbnail direct path (webhook-specific)\n thumbnailEncSHA256?: string; // Thumbnail encrypted SHA256 (webhook-specific)\n thumbnailSHA256?: string; // Thumbnail SHA256 (webhook-specific)\n videoSourceType?: number; // Webhook-specific field\n width: number;\n}\n\nexport interface WebhookAudioMessage {\n URL?: string; // Uppercase for webhook\n contextInfo?: WebhookContextInfo;\n directPath?: string;\n fileEncSHA256?: string; // String format for webhook\n fileLength?: number;\n fileSHA256?: string; // String format for webhook\n mediaKey?: string; // String format for webhook\n mediaKeyTimestamp?: number;\n mimetype?: string;\n seconds?: number;\n ptt?: boolean; // Push to talk (voice message) - Note: payload uses uppercase \"PTT\"\n streamingSidecar?: string; // Streaming sidecar data for audio streaming (webhook-specific)\n waveform?: string; // Base64 encoded waveform for voice messages (webhook-specific)\n}\n\nexport interface WebhookDocumentMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n contactVcard: boolean; // Whether this is a contact vCard (webhook-specific field)\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileName: string; // Original file name\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n mimetype: string; // MIME type (e.g., \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\", \"application/pdf\")\n pageCount?: number; // Number of pages in the document (webhook-specific field)\n title: string; // Document title (usually filename without extension)\n}\n\nexport interface WebhookContactMessage {\n contextInfo?: WebhookContextInfo;\n displayName: string; // Display name of the contact\n vcard: string; // vCard data in standard vCard format\n}\n\nexport interface WebhookPollCreationMessageV3 {\n contextInfo?: WebhookContextInfo;\n name: string; // Poll question/title\n options: Array<{\n optionHash: string; // Hash for the option\n optionName: string; // Display text for the option\n }>;\n pollContentType: number; // Type of poll content\n selectableOptionsCount: number; // Number of options that can be selected (0 = single choice, >0 = multiple choice)\n}\n\nexport interface WebhookLocationMessage {\n JPEGThumbnail?: string; // Base64 encoded JPEG thumbnail of the location (webhook-specific field)\n contextInfo?: WebhookContextInfo;\n degreesLatitude: number; // Latitude coordinate\n degreesLongitude: number; // Longitude coordinate\n}\n\nexport interface WebhookStickerMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n firstFrameLength?: number; // First frame length for animated stickers (webhook-specific)\n firstFrameSidecar?: string; // First frame sidecar data (webhook-specific)\n height: number; // Sticker height\n isAiSticker?: boolean; // Whether this is an AI-generated sticker (webhook-specific)\n isAnimated?: boolean; // Whether this is an animated sticker (webhook-specific)\n isAvatar?: boolean; // Whether this is an avatar sticker (webhook-specific)\n isLottie?: boolean; // Whether this is a Lottie sticker (webhook-specific)\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n mimetype: string; // MIME type (typically \"image/webp\" for stickers)\n stickerSentTS?: number; // Sticker sent timestamp (webhook-specific field)\n width: number; // Sticker width\n}\n\nexport interface WebhookReactionMessage {\n key: WebhookMessageKey; // Key of the message being reacted to\n senderTimestampMS?: number; // Timestamp when reaction was sent\n text?: string; // The reaction emoji/text\n}\n\nexport interface WebhookEditedMessage {\n message?: unknown; // The edited message content\n timestampMS?: string; // Edit timestamp\n editedMessageID?: string; // ID of original message being edited\n}\n\n// Message key structure\nexport interface WebhookMessageKey {\n ID: string; // Uppercase field name for webhook (vs lowercase 'id' in message.ts)\n fromMe: boolean; // Required in webhook (vs optional in message.ts)\n participant?: string; // JID in string format\n remoteJID: string; // Uppercase JID field name for webhook (vs 'remoteJid' in message.ts)\n}\n\n// User receipt structure\nexport interface UserReceipt {\n userJID?: string;\n receiptTimestamp?: number;\n readTimestamp?: number;\n playedTimestamp?: number;\n}\n\n// Reaction structure\nexport interface WebhookReaction {\n key?: WebhookMessageKey;\n text?: string;\n senderTimestampMS?: number;\n}\n\n// Generic message wrapper for webhook payloads\nexport interface WebhookGenericMessage {\n messageContextInfo?: WebhookMessageContextInfo;\n conversation?: string; // Simple text message\n extendedTextMessage?: WebhookExtendedTextMessage;\n imageMessage?: WebhookImageMessage;\n videoMessage?: WebhookVideoMessage;\n audioMessage?: WebhookAudioMessage;\n documentMessage?: WebhookDocumentMessage;\n contactMessage?: WebhookContactMessage;\n pollCreationMessageV3?: WebhookPollCreationMessageV3;\n locationMessage?: WebhookLocationMessage;\n stickerMessage?: WebhookStickerMessage;\n reactionMessage?: WebhookReactionMessage;\n editedMessage?: WebhookEditedMessage;\n protocolMessage?: {\n type?: number;\n editedMessage?: WebhookGenericMessage; // Nested edited message in protocol messages\n key?: WebhookMessageKey; // Message key for protocol messages\n timestampMS?: number; // Edit timestamp\n historySyncNotification?: WebhookHistorySyncNotification;\n initialSecurityNotificationSettingSync?: {\n securityNotificationEnabled: boolean;\n };\n };\n deviceSentMessage?: {\n destinationJID: string;\n message: WebhookGenericMessage;\n };\n}\n\n// Message types enum for easier handling of different message types\nexport enum MessageType {\n TEXT = \"conversation\",\n EXTENDED_TEXT = \"extendedTextMessage\",\n IMAGE = \"imageMessage\",\n VIDEO = \"videoMessage\",\n AUDIO = \"audioMessage\",\n DOCUMENT = \"documentMessage\",\n CONTACT = \"contactMessage\",\n POLL_CREATION = \"pollCreationMessageV3\",\n LOCATION = \"locationMessage\",\n STICKER = \"stickerMessage\",\n REACTION = \"reactionMessage\",\n EDITED = \"editedMessage\",\n PROTOCOL = \"protocolMessage\",\n DEVICE_SENT = \"deviceSentMessage\",\n UNKNOWN = \"unknown\",\n}\n// History sync notification structure\nexport interface WebhookHistorySyncNotification {\n chunkOrder?: number;\n directPath: string;\n encHandle: string; // Webhook-specific field\n fileEncSHA256: string; // String format for webhook\n fileLength: number;\n fileSHA256: string; // String format for webhook\n mediaKey: string; // String format for webhook\n progress?: number;\n syncType: number;\n}\n\n// Using VerifiedName imported from user.ts (identical interface)\n\n// Specific webhook event data interfaces\n\n// QR webhook event data (based on observed webhook payload)\n// Note: For QR events, the event field is actually just the string \"code\"\n// We represent this as an empty interface since the real data is at payload level\nexport interface QRWebhookEvent {\n // The event field contains just the string \"code\"\n // The actual QR code data is in qrCodeBase64 at the payload level\n}\n\n// Connected webhook event data (based on observed webhook payload)\n// Note: For Connected events, the event field is an empty object {}\nexport interface ConnectedWebhookEvent {\n // The event field contains an empty object {}\n // No additional data is provided for Connected events\n}\n\n// ReadReceipt webhook event data (based on observed webhook payload)\n// Maps to Receipt event type but with webhook-specific structure\nexport interface ReadReceiptWebhookEvent {\n AddressingMode: string;\n BroadcastListOwner: string;\n Chat: string; // JID in string format (e.g., \"554198387899-1431900789@g.us\")\n IsFromMe: boolean;\n IsGroup: boolean;\n MessageIDs: string[];\n MessageSender: string;\n RecipientAlt: string;\n Sender: string; // JID in string format (e.g., \"554198387899@s.whatsapp.net\")\n SenderAlt: string;\n Timestamp: string; // ISO string timestamp\n Type: string; // Receipt type (e.g., \"read\")\n}\n\n// HistorySync webhook event data (based on observed webhook payload)\n// Contains different types of historical data - can be pastParticipants, statusV3Messages, conversations, etc.\nexport interface HistorySyncWebhookEvent {\n Data: {\n // Variant 1: Past participants data (groups and stickers)\n pastParticipants?: Array<{\n groupJID: string; // JID in string format (e.g., \"120363388053770128@g.us\")\n pastParticipants: Array<{\n leaveReason: number; // 0 = left voluntarily, 1 = kicked/removed\n leaveTS: number; // Unix timestamp\n userJID: string; // JID in string format\n }>;\n }>;\n recentStickers?: Array<{\n URL: string; // Full WhatsApp media URL\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash\n height: number;\n isLottie: boolean; // Whether it's an animated Lottie sticker\n lastStickerSentTS: number; // Unix timestamp of last usage\n mediaKey: string; // Media encryption key\n mimetype: string; // MIME type (e.g., \"image/webp\")\n weight: number; // Usage weight/frequency\n width: number;\n }>;\n\n // Variant 2: Status messages data (stories/status updates)\n statusV3Messages?: Array<{\n key: WebhookMessageKey;\n message: WebhookGenericMessage;\n messageTimestamp: number; // Unix timestamp\n participant: string; // JID in string format\n reportingTokenInfo?: {\n reportingTag: string;\n };\n }>;\n\n // Variant 3: Conversation histories data\n conversations?: Array<{\n ID: string; // JID in string format (chat identifier)\n messages: Array<{\n message: {\n key: WebhookMessageKey;\n message: WebhookGenericMessage;\n messageTimestamp: number; // Unix timestamp\n messageC2STimestamp?: number; // Client to server timestamp\n ephemeralStartTimestamp?: number; // Ephemeral message start timestamp\n originalSelfAuthorUserJIDString?: string; // Original author for messages sent by self\n status?: number; // Message status (3=delivered, 4=read, 5=played)\n userReceipt?: UserReceipt[];\n reactions?: WebhookReaction[];\n reportingTokenInfo?: {\n reportingTag: string;\n };\n };\n msgOrderID: number; // Message order ID\n }>;\n }>;\n phoneNumberToLidMappings?: Array<{\n lidJID: string; // LID JID (e.g., \"165434221441206@lid\")\n pnJID: string; // Phone number JID (e.g., \"554199392033@s.whatsapp.net\")\n }>;\n\n // Common fields for all variants\n chunkOrder?: number; // Chunk order for paginated sync\n progress?: number; // Sync progress\n syncType: number; // Sync operation type\n };\n}\n\n// Message webhook event data (based on observed webhook payload)\n// Complex structure similar to MessageEvent in events.ts but with webhook-specific format\nexport interface MessageWebhookEvent {\n Info: {\n AddressingMode: string;\n BroadcastListOwner: string;\n Category: string;\n Chat: string; // JID in string format\n DeviceSentMeta: {\n DestinationJID: string;\n Phash: string;\n } | null;\n Edit: string;\n ID: string;\n IsFromMe: boolean;\n IsGroup: boolean;\n MediaType: string;\n MsgBotInfo: {\n EditSenderTimestampMS: string; // ISO timestamp\n EditTargetID: string;\n EditType: string;\n };\n MsgMetaInfo: {\n DeprecatedLIDSession: unknown | null;\n TargetID: string;\n TargetSender: string;\n ThreadMessageID: string;\n ThreadMessageSenderJID: string;\n };\n Multicast: boolean;\n PushName: string;\n RecipientAlt: string;\n Sender: string; // JID in string format\n SenderAlt: string;\n ServerID: number;\n Timestamp: string; // ISO string timestamp\n Type: string; // Message type (e.g., \"text\")\n VerifiedName: VerifiedName | null;\n };\n IsDocumentWithCaption: boolean;\n IsEdit: boolean;\n IsEphemeral: boolean;\n IsLottieSticker: boolean;\n IsViewOnce: boolean;\n IsViewOnceV2: boolean;\n IsViewOnceV2Extension: boolean;\n Message: WebhookGenericMessage; // Using webhook-specific message structure\n NewsletterMeta: unknown | null;\n RawMessage: WebhookGenericMessage; // Using webhook-specific message structure\n RetryCount: number;\n SourceWebMsg: unknown | null;\n UnavailableRequestID: string;\n}\n\n// Typed webhook payloads for specific events\nexport type QRWebhookPayload = AnyWebhookPayload<QRWebhookEvent> & {\n qrCodeBase64: string; // QR code as base64 data URL\n};\nexport type ConnectedWebhookPayload = AnyWebhookPayload<ConnectedWebhookEvent>;\nexport type ReadReceiptWebhookPayload =\n AnyWebhookPayload<ReadReceiptWebhookEvent>;\nexport type HistorySyncWebhookPayload =\n AnyWebhookPayload<HistorySyncWebhookEvent>;\nexport type MessageWebhookPayload = AnyWebhookPayload<MessageWebhookEvent>;\n\n// Webhook event mapping types for type-safe handling\nexport interface WebhookEventMap {\n QR: QRWebhookEvent;\n Connected: ConnectedWebhookEvent;\n ReadReceipt: ReadReceiptWebhookEvent;\n HistorySync: HistorySyncWebhookEvent;\n Message: MessageWebhookEvent;\n // Add more webhook event mappings here as they are discovered\n}\n\n// Type-safe webhook handler function type\nexport type WebhookEventHandler<T extends keyof WebhookEventMap> = (\n payload: AnyWebhookPayload<WebhookEventMap[T]>\n) => void | Promise<void>;\n\n// Union type for all specific webhook payloads\nexport type SpecificWebhookPayload =\n | QRWebhookPayload\n | ConnectedWebhookPayload\n | ReadReceiptWebhookPayload\n | HistorySyncWebhookPayload\n | MessageWebhookPayload;\n\n// Type guard to check if payload is a specific webhook event type\nexport function isWebhookEventType<T extends keyof WebhookEventMap>(\n payload: WebhookPayloadBase,\n eventType: T\n): payload is AnyWebhookPayload<WebhookEventMap[T]> {\n return payload.type === eventType;\n}\n\n// Helper type guards\nexport function hasS3Media(\n payload: WebhookPayloadBase\n): payload is S3OnlyWebhookPayload | BothMediaWebhookPayload {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return !!(payload as any).s3;\n}\n\nexport function hasBase64Media(\n payload: WebhookPayloadBase\n): payload is Base64OnlyWebhookPayload | BothMediaWebhookPayload {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return !!(payload as any).base64;\n}\n\nexport function hasBothMedia(\n payload: WebhookPayloadBase\n): payload is BothMediaWebhookPayload {\n return hasS3Media(payload) && hasBase64Media(payload);\n}\n\n// Helper type guard to check if payload has token (all webhook payloads should)\nexport function isValidWebhookPayload(\n payload: unknown\n): payload is WebhookPayloadBase {\n return (\n typeof payload === \"object\" &&\n payload !== null &&\n \"event\" in payload &&\n \"type\" in payload &&\n \"token\" in payload\n );\n}\n\n/**\n * Utility function to discover the type of a GenericMessage\n * @param message - The GenericMessage to analyze\n * @returns MessageType enum value indicating the message type\n *\n * @example\n * ```typescript\n * import { discoverMessageType, MessageType } from \"wuzapi\";\n *\n * const messageType = discoverMessageType(webhookPayload.event.Message);\n *\n * switch (messageType) {\n * case MessageType.IMAGE:\n * console.log(\"Received an image message\");\n * break;\n * case MessageType.EXTENDED_TEXT:\n * console.log(\"Received a text message\");\n * break;\n * // ... handle other types\n * }\n * ```\n */\nexport function discoverMessageType(\n message: WebhookGenericMessage\n): MessageType {\n if (!message) return MessageType.UNKNOWN;\n\n // Check for each message type in order of most common to least common\n if (message.conversation) return MessageType.TEXT;\n if (message.extendedTextMessage) return MessageType.EXTENDED_TEXT;\n if (message.imageMessage) return MessageType.IMAGE;\n if (message.videoMessage) return MessageType.VIDEO;\n if (message.audioMessage) return MessageType.AUDIO;\n if (message.documentMessage) return MessageType.DOCUMENT;\n if (message.contactMessage) return MessageType.CONTACT;\n if (message.locationMessage) return MessageType.LOCATION;\n if (message.stickerMessage) return MessageType.STICKER;\n if (message.reactionMessage) return MessageType.REACTION;\n if (message.pollCreationMessageV3) return MessageType.POLL_CREATION;\n if (message.editedMessage) return MessageType.EDITED;\n if (message.protocolMessage) return MessageType.PROTOCOL;\n if (message.deviceSentMessage) return MessageType.DEVICE_SENT;\n\n return MessageType.UNKNOWN;\n}\n"],"names":["WebhookEventType","MessageType"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"webhook.js","sources":["../src/types/webhook.ts"],"sourcesContent":["// Import types that are identical from other modules\nimport type { VerifiedName } from \"./user.js\";\n\n// Webhook endpoints types\n\n// Webhook event types (events that can be subscribed to via webhooks)\nexport enum WebhookEventType {\n MESSAGE = \"Message\",\n UNDECRYPTABLE_MESSAGE = \"UndecryptableMessage\",\n RECEIPT = \"Receipt\",\n READ_RECEIPT = \"ReadReceipt\",\n MEDIA_RETRY = \"MediaRetry\",\n GROUP_INFO = \"GroupInfo\",\n JOINED_GROUP = \"JoinedGroup\",\n PICTURE = \"Picture\",\n BLOCKLIST_CHANGE = \"BlocklistChange\",\n BLOCKLIST = \"Blocklist\",\n CONNECTED = \"Connected\",\n DISCONNECTED = \"Disconnected\",\n CONNECT_FAILURE = \"ConnectFailure\",\n KEEP_ALIVE_RESTORED = \"KeepAliveRestored\",\n KEEP_ALIVE_TIMEOUT = \"KeepAliveTimeout\",\n LOGGED_OUT = \"LoggedOut\",\n CLIENT_OUTDATED = \"ClientOutdated\",\n TEMPORARY_BAN = \"TemporaryBan\",\n STREAM_ERROR = \"StreamError\",\n STREAM_REPLACED = \"StreamReplaced\",\n PAIR_SUCCESS = \"PairSuccess\",\n PAIR_ERROR = \"PairError\",\n QR = \"QR\",\n QR_SCANNED_WITHOUT_MULTIDEVICE = \"QRScannedWithoutMultidevice\",\n PRIVACY_SETTINGS = \"PrivacySettings\",\n PUSH_NAME_SETTING = \"PushNameSetting\",\n USER_ABOUT = \"UserAbout\",\n APP_STATE = \"AppState\",\n APP_STATE_SYNC_COMPLETE = \"AppStateSyncComplete\",\n HISTORY_SYNC = \"HistorySync\",\n OFFLINE_SYNC_COMPLETED = \"OfflineSyncCompleted\",\n OFFLINE_SYNC_PREVIEW = \"OfflineSyncPreview\",\n CALL_OFFER = \"CallOffer\",\n CALL_ACCEPT = \"CallAccept\",\n CALL_TERMINATE = \"CallTerminate\",\n CALL_OFFER_NOTICE = \"CallOfferNotice\",\n CALL_RELAY_LATENCY = \"CallRelayLatency\",\n PRESENCE = \"Presence\",\n CHAT_PRESENCE = \"ChatPresence\",\n IDENTITY_CHANGE = \"IdentityChange\",\n CAT_REFRESH_ERROR = \"CATRefreshError\",\n NEWSLETTER_JOIN = \"NewsletterJoin\",\n NEWSLETTER_LEAVE = \"NewsletterLeave\",\n NEWSLETTER_MUTE_CHANGE = \"NewsletterMuteChange\",\n NEWSLETTER_LIVE_UPDATE = \"NewsletterLiveUpdate\",\n FB_MESSAGE = \"FBMessage\",\n ALL = \"All\",\n}\n\n// Helper to get all webhook event values as string array\nexport const WEBHOOK_EVENTS = Object.values(WebhookEventType);\n\n// Type for webhook event names\nexport type WebhookEvent = keyof typeof WebhookEventType;\n\nexport interface SetWebhookRequest {\n webhook: string;\n events: (WebhookEvent | string)[];\n}\n\nexport interface SetWebhookResponse {\n WebhookURL: string;\n Events: string[];\n}\n\nexport interface GetWebhookResponse {\n subscribe: string[];\n webhook: string;\n}\n\nexport interface UpdateWebhookRequest {\n webhook?: string;\n events?: (WebhookEvent | string)[];\n Active?: boolean;\n}\n\nexport interface UpdateWebhookResponse {\n WebhookURL: string;\n Events: string[];\n active: boolean;\n}\n\nexport interface DeleteWebhookResponse {\n Details: string;\n}\n\n// Webhook payload types (what your webhook endpoint receives)\n\nexport interface S3MediaInfo {\n url: string;\n key: string;\n bucket: string;\n size: number;\n mimeType: string;\n fileName: string;\n}\n\n// Base interface that all webhook payloads extend from\nexport interface WebhookPayloadBase<T = unknown> {\n event: T;\n type: string;\n token: string;\n state?: string; // Optional state field (e.g., \"Read\" or \"Delivered\" for ReadReceipt events)\n}\n\n// Standard webhook payload with optional media\nexport interface WebhookPayload<T = unknown> extends WebhookPayloadBase<T> {\n s3?: S3MediaInfo;\n base64?: string;\n mimeType?: string;\n fileName?: string;\n}\n\n// Specific webhook payload types for different media delivery modes\n\n// S3 only delivery\nexport interface S3OnlyWebhookPayload<T = unknown>\n extends WebhookPayloadBase<T> {\n s3: S3MediaInfo;\n}\n\n// Base64 only delivery\nexport interface Base64OnlyWebhookPayload<T = unknown>\n extends WebhookPayloadBase<T> {\n base64: string;\n mimeType: string;\n fileName: string;\n}\n\n// Both S3 and Base64 delivery\nexport interface BothMediaWebhookPayload<T = unknown>\n extends WebhookPayloadBase<T> {\n s3: S3MediaInfo;\n base64: string;\n mimeType: string;\n fileName: string;\n}\n\n// Union type for all possible webhook payloads\nexport type AnyWebhookPayload<T = unknown> =\n | WebhookPayload<T>\n | S3OnlyWebhookPayload<T>\n | Base64OnlyWebhookPayload<T>\n | BothMediaWebhookPayload<T>;\n\n// Shared message and media interfaces for reusability across webhook events\n//\n// Note: Webhook events may have different structures than the corresponding\n// WhatsApp events in events.ts. Webhook events use flat structures with\n// string-based JIDs and ISO timestamp strings, while internal events use\n// structured JID objects and Date objects.\n\n// Common context info structures\nexport interface WebhookMessageContextInfo {\n deviceListMetadata?: WebhookDeviceListMetadata;\n deviceListMetadataVersion?: number;\n messageSecret?: string; // Encryption secret (string format for webhook)\n limitSharingV2?: {\n initiatedByMe: boolean;\n trigger: number;\n };\n}\n\nexport interface WebhookDeviceListMetadata {\n senderKeyHash?: string; // Base64 string format for webhook (vs Uint8Array in message.ts)\n senderTimestamp?: number;\n recipientKeyHash?: string; // Base64 string format for webhook\n recipientTimestamp?: number;\n senderAccountType?: number; // Webhook-specific field\n receiverAccountType?: number; // Webhook-specific field\n}\n\nexport interface WebhookContextInfo {\n disappearingMode?: {\n initiator: number;\n initiatedByMe?: boolean; // Webhook-specific field\n trigger?: number; // Webhook-specific field\n };\n ephemeralSettingTimestamp?: number;\n expiration?: number;\n forwardingScore?: number;\n isForwarded?: boolean;\n pairedMediaType?: number;\n statusSourceType?: number;\n featureEligibilities?: {\n canBeReshared?: boolean;\n };\n}\n\n// Common message types that are reused across different webhook events\nexport interface WebhookExtendedTextMessage {\n text: string;\n contextInfo?: WebhookContextInfo;\n inviteLinkGroupTypeV2?: number; // Webhook-specific field\n previewType?: number; // Webhook-specific field\n}\n\nexport interface WebhookImageMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n JPEGThumbnail?: string; // Base64 encoded JPEG thumbnail\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n height: number;\n imageSourceType: number; // Webhook-specific field\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n midQualityFileSHA256: string; // Mid quality file hash (webhook-specific)\n mimetype: string; // MIME type (e.g., \"image/jpeg\")\n scanLengths: number[]; // Progressive scan lengths (webhook-specific)\n scansSidecar: string; // Progressive scan sidecar data (webhook-specific)\n firstScanLength?: number; // First scan length (webhook-specific)\n firstScanSidecar?: string; // First scan sidecar (webhook-specific)\n width: number;\n}\n\nexport interface WebhookVideoMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n JPEGThumbnail?: string; // Base64 encoded JPEG thumbnail\n accessibilityLabel?: string;\n caption?: string;\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n externalShareFullVideoDurationInSeconds?: number; // Webhook-specific field\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n gifAttribution?: number; // GIF attribution type (0=none, 1=giphy, 2=tenor, etc.) (webhook-specific)\n gifPlayback?: boolean; // Whether this video should be played as a GIF (webhook-specific)\n height: number;\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n mimetype: string; // MIME type (e.g., \"video/mp4\")\n seconds: number; // Video duration in seconds\n streamingSidecar?: string; // Streaming sidecar data for video streaming\n thumbnailDirectPath?: string; // Thumbnail direct path (webhook-specific)\n thumbnailEncSHA256?: string; // Thumbnail encrypted SHA256 (webhook-specific)\n thumbnailSHA256?: string; // Thumbnail SHA256 (webhook-specific)\n videoSourceType?: number; // Webhook-specific field\n width: number;\n}\n\nexport interface WebhookAudioMessage {\n URL?: string; // Uppercase for webhook\n contextInfo?: WebhookContextInfo;\n directPath?: string;\n fileEncSHA256?: string; // String format for webhook\n fileLength?: number;\n fileSHA256?: string; // String format for webhook\n mediaKey?: string; // String format for webhook\n mediaKeyTimestamp?: number;\n mimetype?: string;\n seconds?: number;\n ptt?: boolean; // Push to talk (voice message) - Note: payload uses uppercase \"PTT\"\n streamingSidecar?: string; // Streaming sidecar data for audio streaming (webhook-specific)\n waveform?: string; // Base64 encoded waveform for voice messages (webhook-specific)\n}\n\nexport interface WebhookDocumentMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n contactVcard: boolean; // Whether this is a contact vCard (webhook-specific field)\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileName: string; // Original file name\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n mimetype: string; // MIME type (e.g., \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\", \"application/pdf\")\n pageCount?: number; // Number of pages in the document (webhook-specific field)\n title: string; // Document title (usually filename without extension)\n}\n\nexport interface WebhookContactMessage {\n contextInfo?: WebhookContextInfo;\n displayName: string; // Display name of the contact\n vcard: string; // vCard data in standard vCard format\n}\n\nexport interface WebhookPollCreationMessageV3 {\n contextInfo?: WebhookContextInfo;\n name: string; // Poll question/title\n options: Array<{\n optionHash: string; // Hash for the option\n optionName: string; // Display text for the option\n }>;\n pollContentType: number; // Type of poll content\n selectableOptionsCount: number; // Number of options that can be selected (0 = single choice, >0 = multiple choice)\n}\n\nexport interface WebhookLocationMessage {\n JPEGThumbnail?: string; // Base64 encoded JPEG thumbnail of the location (webhook-specific field)\n contextInfo?: WebhookContextInfo;\n degreesLatitude: number; // Latitude coordinate\n degreesLongitude: number; // Longitude coordinate\n}\n\nexport interface WebhookStickerMessage {\n URL: string; // Full WhatsApp media URL (uppercase for webhook)\n contextInfo?: WebhookContextInfo;\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash (string format for webhook)\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash (string format for webhook)\n firstFrameLength?: number; // First frame length for animated stickers (webhook-specific)\n firstFrameSidecar?: string; // First frame sidecar data (webhook-specific)\n height: number; // Sticker height\n isAiSticker?: boolean; // Whether this is an AI-generated sticker (webhook-specific)\n isAnimated?: boolean; // Whether this is an animated sticker (webhook-specific)\n isAvatar?: boolean; // Whether this is an avatar sticker (webhook-specific)\n isLottie?: boolean; // Whether this is a Lottie sticker (webhook-specific)\n mediaKey: string; // Media encryption key (string format for webhook)\n mediaKeyTimestamp: number; // Unix timestamp\n mimetype: string; // MIME type (typically \"image/webp\" for stickers)\n stickerSentTS?: number; // Sticker sent timestamp (webhook-specific field)\n width: number; // Sticker width\n}\n\nexport interface WebhookReactionMessage {\n key: WebhookMessageKey; // Key of the message being reacted to\n senderTimestampMS?: number; // Timestamp when reaction was sent\n text?: string; // The reaction emoji/text\n}\n\nexport interface WebhookEditedMessage {\n message?: unknown; // The edited message content\n timestampMS?: string; // Edit timestamp\n editedMessageID?: string; // ID of original message being edited\n}\n\n// Message key structure\nexport interface WebhookMessageKey {\n ID: string; // Uppercase field name for webhook (vs lowercase 'id' in message.ts)\n fromMe: boolean; // Required in webhook (vs optional in message.ts)\n participant?: string; // JID in string format\n remoteJID: string; // Uppercase JID field name for webhook (vs 'remoteJid' in message.ts)\n}\n\n// User receipt structure\nexport interface UserReceipt {\n userJID?: string;\n receiptTimestamp?: number;\n readTimestamp?: number;\n playedTimestamp?: number;\n}\n\n// Reaction structure\nexport interface WebhookReaction {\n key?: WebhookMessageKey;\n text?: string;\n senderTimestampMS?: number;\n}\n\n// Generic message wrapper for webhook payloads\nexport interface WebhookGenericMessage {\n messageContextInfo?: WebhookMessageContextInfo;\n conversation?: string; // Simple text message\n extendedTextMessage?: WebhookExtendedTextMessage;\n imageMessage?: WebhookImageMessage;\n videoMessage?: WebhookVideoMessage;\n audioMessage?: WebhookAudioMessage;\n documentMessage?: WebhookDocumentMessage;\n contactMessage?: WebhookContactMessage;\n locationMessage?: WebhookLocationMessage;\n stickerMessage?: WebhookStickerMessage;\n reactionMessage?: WebhookReactionMessage;\n editedMessage?: WebhookEditedMessage;\n\n // Interactive messages\n // TODO: define proper interfaces\n buttonsMessage?: unknown;\n listMessage?: unknown;\n templateMessage?: unknown;\n\n // Response messages\n buttonsResponseMessage?: unknown;\n listResponseMessage?: unknown;\n\n // Group messages\n groupInviteMessage?: unknown;\n\n // Poll messages\n pollCreationMessage?: unknown;\n pollCreationMessageV3?: WebhookPollCreationMessageV3;\n pollUpdateMessage?: unknown;\n\n // Special messages\n viewOnceMessage?: unknown;\n\n protocolMessage?: {\n type?: number;\n editedMessage?: WebhookGenericMessage; // Nested edited message in protocol messages\n key?: WebhookMessageKey; // Message key for protocol messages\n timestampMS?: number; // Edit timestamp\n historySyncNotification?: WebhookHistorySyncNotification;\n initialSecurityNotificationSettingSync?: {\n securityNotificationEnabled: boolean;\n };\n };\n deviceSentMessage?: {\n destinationJID: string;\n message: WebhookGenericMessage;\n };\n}\n\n// Message types enum for easier handling of different message types\nexport enum MessageType {\n TEXT = \"conversation\",\n EXTENDED_TEXT = \"extendedTextMessage\",\n IMAGE = \"imageMessage\",\n VIDEO = \"videoMessage\",\n AUDIO = \"audioMessage\",\n DOCUMENT = \"documentMessage\",\n CONTACT = \"contactMessage\",\n LOCATION = \"locationMessage\",\n STICKER = \"stickerMessage\",\n REACTION = \"reactionMessage\",\n EDITED = \"editedMessage\",\n PROTOCOL = \"protocolMessage\",\n DEVICE_SENT = \"deviceSentMessage\",\n\n // Interactive messages\n BUTTONS = \"buttonsMessage\",\n LIST = \"listMessage\",\n TEMPLATE = \"templateMessage\",\n\n // Response messages\n BUTTONS_RESPONSE = \"buttonsResponseMessage\",\n LIST_RESPONSE = \"listResponseMessage\",\n\n // Group messages\n GROUP_INVITE = \"groupInviteMessage\",\n\n // Poll messages\n POLL = \"pollCreationMessage\",\n POLL_CREATION = \"pollCreationMessageV3\",\n POLL_UPDATE = \"pollUpdateMessage\",\n\n // Special messages\n VIEW_ONCE = \"viewOnceMessage\",\n\n UNKNOWN = \"unknown\",\n}\n// History sync notification structure\nexport interface WebhookHistorySyncNotification {\n chunkOrder?: number;\n directPath: string;\n encHandle: string; // Webhook-specific field\n fileEncSHA256: string; // String format for webhook\n fileLength: number;\n fileSHA256: string; // String format for webhook\n mediaKey: string; // String format for webhook\n progress?: number;\n syncType: number;\n}\n\n// Using VerifiedName imported from user.ts (identical interface)\n\n// Specific webhook event data interfaces\n\n// QR webhook event data (based on observed webhook payload)\n// Note: For QR events, the event field is actually just the string \"code\"\n// We represent this as an empty interface since the real data is at payload level\nexport interface QRWebhookEvent {\n // The event field contains just the string \"code\"\n // The actual QR code data is in qrCodeBase64 at the payload level\n}\n\n// Connected webhook event data (based on observed webhook payload)\n// Note: For Connected events, the event field is an empty object {}\nexport interface ConnectedWebhookEvent {\n // The event field contains an empty object {}\n // No additional data is provided for Connected events\n}\n\n// ReadReceipt webhook event data (based on observed webhook payload)\n// Maps to Receipt event type but with webhook-specific structure\nexport interface ReadReceiptWebhookEvent {\n AddressingMode: string;\n BroadcastListOwner: string;\n Chat: string; // JID in string format (e.g., \"554198387899-1431900789@g.us\")\n IsFromMe: boolean;\n IsGroup: boolean;\n MessageIDs: string[];\n MessageSender: string;\n RecipientAlt: string;\n Sender: string; // JID in string format (e.g., \"554198387899@s.whatsapp.net\")\n SenderAlt: string;\n Timestamp: string; // ISO string timestamp\n Type: string; // Receipt type (e.g., \"read\")\n}\n\n// HistorySync webhook event data (based on observed webhook payload)\n// Contains different types of historical data - can be pastParticipants, statusV3Messages, conversations, etc.\nexport interface HistorySyncWebhookEvent {\n Data: {\n // Variant 1: Past participants data (groups and stickers)\n pastParticipants?: Array<{\n groupJID: string; // JID in string format (e.g., \"120363388053770128@g.us\")\n pastParticipants: Array<{\n leaveReason: number; // 0 = left voluntarily, 1 = kicked/removed\n leaveTS: number; // Unix timestamp\n userJID: string; // JID in string format\n }>;\n }>;\n recentStickers?: Array<{\n URL: string; // Full WhatsApp media URL\n directPath: string; // Direct path to media\n fileEncSHA256: string; // Encrypted file SHA256 hash\n fileLength: number; // File size in bytes\n fileSHA256: string; // File SHA256 hash\n height: number;\n isLottie: boolean; // Whether it's an animated Lottie sticker\n lastStickerSentTS: number; // Unix timestamp of last usage\n mediaKey: string; // Media encryption key\n mimetype: string; // MIME type (e.g., \"image/webp\")\n weight: number; // Usage weight/frequency\n width: number;\n }>;\n\n // Variant 2: Status messages data (stories/status updates)\n statusV3Messages?: Array<{\n key: WebhookMessageKey;\n message: WebhookGenericMessage;\n messageTimestamp: number; // Unix timestamp\n participant: string; // JID in string format\n reportingTokenInfo?: {\n reportingTag: string;\n };\n }>;\n\n // Variant 3: Conversation histories data\n conversations?: Array<{\n ID: string; // JID in string format (chat identifier)\n messages: Array<{\n message: {\n key: WebhookMessageKey;\n message: WebhookGenericMessage;\n messageTimestamp: number; // Unix timestamp\n messageC2STimestamp?: number; // Client to server timestamp\n ephemeralStartTimestamp?: number; // Ephemeral message start timestamp\n originalSelfAuthorUserJIDString?: string; // Original author for messages sent by self\n status?: number; // Message status (3=delivered, 4=read, 5=played)\n userReceipt?: UserReceipt[];\n reactions?: WebhookReaction[];\n reportingTokenInfo?: {\n reportingTag: string;\n };\n };\n msgOrderID: number; // Message order ID\n }>;\n }>;\n phoneNumberToLidMappings?: Array<{\n lidJID: string; // LID JID (e.g., \"165434221441206@lid\")\n pnJID: string; // Phone number JID (e.g., \"554199392033@s.whatsapp.net\")\n }>;\n\n // Common fields for all variants\n chunkOrder?: number; // Chunk order for paginated sync\n progress?: number; // Sync progress\n syncType: number; // Sync operation type\n };\n}\n\n// Message webhook event data (based on observed webhook payload)\n// Complex structure similar to MessageEvent in events.ts but with webhook-specific format\nexport interface MessageWebhookEvent {\n Info: {\n AddressingMode: string;\n BroadcastListOwner: string;\n Category: string;\n Chat: string; // JID in string format\n DeviceSentMeta: {\n DestinationJID: string;\n Phash: string;\n } | null;\n Edit: string;\n ID: string;\n IsFromMe: boolean;\n IsGroup: boolean;\n MediaType: string;\n MsgBotInfo: {\n EditSenderTimestampMS: string; // ISO timestamp\n EditTargetID: string;\n EditType: string;\n };\n MsgMetaInfo: {\n DeprecatedLIDSession: unknown | null;\n TargetID: string;\n TargetSender: string;\n ThreadMessageID: string;\n ThreadMessageSenderJID: string;\n };\n Multicast: boolean;\n PushName: string;\n RecipientAlt: string;\n Sender: string; // JID in string format\n SenderAlt: string;\n ServerID: number;\n Timestamp: string; // ISO string timestamp\n Type: string; // Message type (e.g., \"text\")\n VerifiedName: VerifiedName | null;\n };\n IsDocumentWithCaption: boolean;\n IsEdit: boolean;\n IsEphemeral: boolean;\n IsLottieSticker: boolean;\n IsViewOnce: boolean;\n IsViewOnceV2: boolean;\n IsViewOnceV2Extension: boolean;\n Message: WebhookGenericMessage; // Using webhook-specific message structure\n NewsletterMeta: unknown | null;\n RawMessage: WebhookGenericMessage; // Using webhook-specific message structure\n RetryCount: number;\n SourceWebMsg: unknown | null;\n UnavailableRequestID: string;\n}\n\n// Typed webhook payloads for specific events\nexport type QRWebhookPayload = AnyWebhookPayload<QRWebhookEvent> & {\n qrCodeBase64: string; // QR code as base64 data URL\n};\nexport type ConnectedWebhookPayload = AnyWebhookPayload<ConnectedWebhookEvent>;\nexport type ReadReceiptWebhookPayload =\n AnyWebhookPayload<ReadReceiptWebhookEvent>;\nexport type HistorySyncWebhookPayload =\n AnyWebhookPayload<HistorySyncWebhookEvent>;\nexport type MessageWebhookPayload = AnyWebhookPayload<MessageWebhookEvent>;\n\n// Webhook event mapping types for type-safe handling\nexport interface WebhookEventMap {\n QR: QRWebhookEvent;\n Connected: ConnectedWebhookEvent;\n ReadReceipt: ReadReceiptWebhookEvent;\n HistorySync: HistorySyncWebhookEvent;\n Message: MessageWebhookEvent;\n // Add more webhook event mappings here as they are discovered\n}\n\n// Type-safe webhook handler function type\nexport type WebhookEventHandler<T extends keyof WebhookEventMap> = (\n payload: AnyWebhookPayload<WebhookEventMap[T]>\n) => void | Promise<void>;\n\n// Union type for all specific webhook payloads\nexport type SpecificWebhookPayload =\n | QRWebhookPayload\n | ConnectedWebhookPayload\n | ReadReceiptWebhookPayload\n | HistorySyncWebhookPayload\n | MessageWebhookPayload;\n\n// Type guard to check if payload is a specific webhook event type\nexport function isWebhookEventType<T extends keyof WebhookEventMap>(\n payload: WebhookPayloadBase,\n eventType: T\n): payload is AnyWebhookPayload<WebhookEventMap[T]> {\n return payload.type === eventType;\n}\n\n// Helper type guards\nexport function hasS3Media(\n payload: WebhookPayloadBase\n): payload is S3OnlyWebhookPayload | BothMediaWebhookPayload {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return !!(payload as any).s3;\n}\n\nexport function hasBase64Media(\n payload: WebhookPayloadBase\n): payload is Base64OnlyWebhookPayload | BothMediaWebhookPayload {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return !!(payload as any).base64;\n}\n\nexport function hasBothMedia(\n payload: WebhookPayloadBase\n): payload is BothMediaWebhookPayload {\n return hasS3Media(payload) && hasBase64Media(payload);\n}\n\n// Helper type guard to check if payload has token (all webhook payloads should)\nexport function isValidWebhookPayload(\n payload: unknown\n): payload is WebhookPayloadBase {\n return (\n typeof payload === \"object\" &&\n payload !== null &&\n \"event\" in payload &&\n \"type\" in payload &&\n \"token\" in payload\n );\n}\n\n/**\n * Utility function to discover the type of a GenericMessage\n * @param message - The GenericMessage to analyze\n * @returns MessageType enum value indicating the message type\n *\n * @example\n * ```typescript\n * import { discoverMessageType, MessageType } from \"wuzapi\";\n *\n * const messageType = discoverMessageType(webhookPayload.event.Message);\n *\n * switch (messageType) {\n * case MessageType.IMAGE:\n * console.log(\"Received an image message\");\n * break;\n * case MessageType.EXTENDED_TEXT:\n * console.log(\"Received a text message\");\n * break;\n * // ... handle other types\n * }\n * ```\n */\nexport function discoverMessageType(\n message: WebhookGenericMessage\n): MessageType {\n if (!message) return MessageType.UNKNOWN;\n\n // Check for each message type in order of most common to least common\n if (message.conversation) return MessageType.TEXT;\n if (message.extendedTextMessage) return MessageType.EXTENDED_TEXT;\n if (message.imageMessage) return MessageType.IMAGE;\n if (message.videoMessage) return MessageType.VIDEO;\n if (message.audioMessage) return MessageType.AUDIO;\n if (message.documentMessage) return MessageType.DOCUMENT;\n if (message.contactMessage) return MessageType.CONTACT;\n if (message.locationMessage) return MessageType.LOCATION;\n if (message.stickerMessage) return MessageType.STICKER;\n if (message.reactionMessage) return MessageType.REACTION;\n\n // Interactive messages\n if (message.buttonsMessage) return MessageType.BUTTONS;\n if (message.listMessage) return MessageType.LIST;\n if (message.templateMessage) return MessageType.TEMPLATE;\n\n // Response messages\n if (message.buttonsResponseMessage) return MessageType.BUTTONS_RESPONSE;\n if (message.listResponseMessage) return MessageType.LIST_RESPONSE;\n\n // Group messages\n if (message.groupInviteMessage) return MessageType.GROUP_INVITE;\n\n // Poll messages\n if (message.pollCreationMessage) return MessageType.POLL;\n if (message.pollCreationMessageV3) return MessageType.POLL_CREATION;\n if (message.pollUpdateMessage) return MessageType.POLL_UPDATE;\n\n // Special messages\n if (message.viewOnceMessage) return MessageType.VIEW_ONCE;\n\n // System messages\n if (message.editedMessage) return MessageType.EDITED;\n if (message.protocolMessage) return MessageType.PROTOCOL;\n if (message.deviceSentMessage) return MessageType.DEVICE_SENT;\n\n return MessageType.UNKNOWN;\n}\n"],"names":["WebhookEventType","MessageType"],"mappings":"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"}
|