wuzapi 1.6.1 → 1.6.2
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 +278 -29
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/modules/webhook.d.ts +11 -3
- package/dist/modules/webhook.js +13 -0
- package/dist/modules/webhook.js.map +1 -1
- package/dist/types/index.js +7 -12
- package/dist/types/index.js.map +1 -1
- package/dist/types/webhook.d.ts +63 -12
- package/dist/webhook.js +69 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -239,18 +239,37 @@ await client.webhook.setWebhook("https://your-server.com/webhook", ["Message"]);
|
|
|
239
239
|
|
|
240
240
|
// In your webhook handler:
|
|
241
241
|
app.post("/webhook", async (req, res) => {
|
|
242
|
-
const
|
|
242
|
+
const webhookPayload = req.body;
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
// Validate payload structure
|
|
245
|
+
if (webhookPayload.token !== "your-expected-token") {
|
|
246
|
+
return res.status(401).json({ error: "Invalid token" });
|
|
247
|
+
}
|
|
247
248
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
// Handle by event type
|
|
250
|
+
switch (webhookPayload.type) {
|
|
251
|
+
case "Message":
|
|
252
|
+
const { event } = webhookPayload;
|
|
253
|
+
if (event.Message?.conversation) {
|
|
254
|
+
const message = event.Message.conversation;
|
|
255
|
+
const from = event.Info.RemoteJid.replace("@s.whatsapp.net", "");
|
|
256
|
+
|
|
257
|
+
if (message.toLowerCase().includes("hello")) {
|
|
258
|
+
await client.chat.sendText({
|
|
259
|
+
Phone: from,
|
|
260
|
+
Body: "Hello! 👋 How can I help you?",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
|
|
266
|
+
case "Connected":
|
|
267
|
+
console.log("✅ WhatsApp connected");
|
|
268
|
+
break;
|
|
269
|
+
|
|
270
|
+
case "QR":
|
|
271
|
+
console.log("📱 QR Code:", webhookPayload.event.Codes);
|
|
272
|
+
break;
|
|
254
273
|
}
|
|
255
274
|
|
|
256
275
|
res.json({ success: true });
|
|
@@ -653,7 +672,9 @@ await client.admin.deleteUserComplete("user-id-string", {
|
|
|
653
672
|
// Set webhook URL with specific events
|
|
654
673
|
await client.webhook.setWebhook("https://my-server.com/webhook", [
|
|
655
674
|
"Message",
|
|
656
|
-
"
|
|
675
|
+
"Receipt",
|
|
676
|
+
"Connected",
|
|
677
|
+
"Disconnected",
|
|
657
678
|
]);
|
|
658
679
|
|
|
659
680
|
// Get current webhook configuration
|
|
@@ -664,12 +685,186 @@ console.log("Subscribed events:", webhookConfig.subscribe);
|
|
|
664
685
|
// Update webhook URL, events, and status
|
|
665
686
|
await client.webhook.updateWebhook(
|
|
666
687
|
"https://my-new-server.com/webhook",
|
|
667
|
-
["Message", "
|
|
688
|
+
["Message", "Receipt", "Presence"],
|
|
668
689
|
true
|
|
669
690
|
);
|
|
670
691
|
|
|
671
692
|
// Delete webhook configuration
|
|
672
693
|
await client.webhook.deleteWebhook();
|
|
694
|
+
|
|
695
|
+
// Get all available events
|
|
696
|
+
const availableEvents = client.webhook.constructor.getAvailableEvents();
|
|
697
|
+
console.log("Available events:", availableEvents);
|
|
698
|
+
|
|
699
|
+
// Use the enum for type safety (TypeScript)
|
|
700
|
+
import { WebhookEventType } from "wuzapi";
|
|
701
|
+
await client.webhook.setWebhook("https://my-server.com/webhook", [
|
|
702
|
+
WebhookEventType.MESSAGE,
|
|
703
|
+
WebhookEventType.RECEIPT,
|
|
704
|
+
WebhookEventType.CONNECTED,
|
|
705
|
+
]);
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### 📋 Complete Webhook Events List
|
|
709
|
+
|
|
710
|
+
WuzAPI supports **45 different webhook events**. Here's the complete list:
|
|
711
|
+
|
|
712
|
+
#### 🔧 **Connection & Session Events**
|
|
713
|
+
|
|
714
|
+
```typescript
|
|
715
|
+
WebhookEventType.CONNECTED; // "Connected"
|
|
716
|
+
WebhookEventType.DISCONNECTED; // "Disconnected"
|
|
717
|
+
WebhookEventType.CONNECT_FAILURE; // "ConnectFailure"
|
|
718
|
+
WebhookEventType.LOGGED_OUT; // "LoggedOut"
|
|
719
|
+
WebhookEventType.KEEP_ALIVE_RESTORED; // "KeepAliveRestored"
|
|
720
|
+
WebhookEventType.KEEP_ALIVE_TIMEOUT; // "KeepAliveTimeout"
|
|
721
|
+
WebhookEventType.CLIENT_OUTDATED; // "ClientOutdated"
|
|
722
|
+
WebhookEventType.TEMPORARY_BAN; // "TemporaryBan"
|
|
723
|
+
WebhookEventType.STREAM_ERROR; // "StreamError"
|
|
724
|
+
WebhookEventType.STREAM_REPLACED; // "StreamReplaced"
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
#### 🔐 **Authentication Events**
|
|
728
|
+
|
|
729
|
+
```typescript
|
|
730
|
+
WebhookEventType.QR; // "QR"
|
|
731
|
+
WebhookEventType.QR_SCANNED_WITHOUT_MULTIDEVICE; // "QRScannedWithoutMultidevice"
|
|
732
|
+
WebhookEventType.PAIR_SUCCESS; // "PairSuccess"
|
|
733
|
+
WebhookEventType.PAIR_ERROR; // "PairError"
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
#### 💬 **Message Events**
|
|
737
|
+
|
|
738
|
+
```typescript
|
|
739
|
+
WebhookEventType.MESSAGE; // "Message"
|
|
740
|
+
WebhookEventType.UNDECRYPTABLE_MESSAGE; // "UndecryptableMessage"
|
|
741
|
+
WebhookEventType.RECEIPT; // "Receipt"
|
|
742
|
+
WebhookEventType.MEDIA_RETRY; // "MediaRetry"
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
#### 👥 **Group Events**
|
|
746
|
+
|
|
747
|
+
```typescript
|
|
748
|
+
WebhookEventType.GROUP_INFO; // "GroupInfo"
|
|
749
|
+
WebhookEventType.JOINED_GROUP; // "JoinedGroup"
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
#### 👤 **User & Contact Events**
|
|
753
|
+
|
|
754
|
+
```typescript
|
|
755
|
+
WebhookEventType.PICTURE; // "Picture"
|
|
756
|
+
WebhookEventType.USER_ABOUT; // "UserAbout"
|
|
757
|
+
WebhookEventType.PUSH_NAME_SETTING; // "PushNameSetting"
|
|
758
|
+
WebhookEventType.PRIVACY_SETTINGS; // "PrivacySettings"
|
|
759
|
+
WebhookEventType.PRESENCE; // "Presence"
|
|
760
|
+
WebhookEventType.CHAT_PRESENCE; // "ChatPresence"
|
|
761
|
+
WebhookEventType.IDENTITY_CHANGE; // "IdentityChange"
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
#### 🚫 **Blocklist Events**
|
|
765
|
+
|
|
766
|
+
```typescript
|
|
767
|
+
WebhookEventType.BLOCKLIST; // "Blocklist"
|
|
768
|
+
WebhookEventType.BLOCKLIST_CHANGE; // "BlocklistChange"
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
#### 📱 **App State & Sync Events**
|
|
772
|
+
|
|
773
|
+
```typescript
|
|
774
|
+
WebhookEventType.APP_STATE; // "AppState"
|
|
775
|
+
WebhookEventType.APP_STATE_SYNC_COMPLETE; // "AppStateSyncComplete"
|
|
776
|
+
WebhookEventType.HISTORY_SYNC; // "HistorySync"
|
|
777
|
+
WebhookEventType.OFFLINE_SYNC_COMPLETED; // "OfflineSyncCompleted"
|
|
778
|
+
WebhookEventType.OFFLINE_SYNC_PREVIEW; // "OfflineSyncPreview"
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
#### 📞 **Call Events**
|
|
782
|
+
|
|
783
|
+
```typescript
|
|
784
|
+
WebhookEventType.CALL_OFFER; // "CallOffer"
|
|
785
|
+
WebhookEventType.CALL_ACCEPT; // "CallAccept"
|
|
786
|
+
WebhookEventType.CALL_TERMINATE; // "CallTerminate"
|
|
787
|
+
WebhookEventType.CALL_OFFER_NOTICE; // "CallOfferNotice"
|
|
788
|
+
WebhookEventType.CALL_RELAY_LATENCY; // "CallRelayLatency"
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
#### 📰 **Newsletter Events**
|
|
792
|
+
|
|
793
|
+
```typescript
|
|
794
|
+
WebhookEventType.NEWSLETTER_JOIN; // "NewsletterJoin"
|
|
795
|
+
WebhookEventType.NEWSLETTER_LEAVE; // "NewsletterLeave"
|
|
796
|
+
WebhookEventType.NEWSLETTER_MUTE_CHANGE; // "NewsletterMuteChange"
|
|
797
|
+
WebhookEventType.NEWSLETTER_LIVE_UPDATE; // "NewsletterLiveUpdate"
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
#### 🔧 **System Events**
|
|
801
|
+
|
|
802
|
+
```typescript
|
|
803
|
+
WebhookEventType.CAT_REFRESH_ERROR; // "CATRefreshError"
|
|
804
|
+
WebhookEventType.FB_MESSAGE; // "FBMessage"
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
### 📦 **Webhook Payload Structure**
|
|
808
|
+
|
|
809
|
+
All webhook payloads follow this structure:
|
|
810
|
+
|
|
811
|
+
```typescript
|
|
812
|
+
{
|
|
813
|
+
"event": { /* Event-specific data */ },
|
|
814
|
+
"type": "Message", // Event type from the list above
|
|
815
|
+
"token": "YOUR_TOKEN", // Your authentication token
|
|
816
|
+
|
|
817
|
+
// Optional media fields (when media is involved)
|
|
818
|
+
"s3": {
|
|
819
|
+
"url": "https://bucket.s3.amazonaws.com/media/file.jpg",
|
|
820
|
+
"key": "media/file.jpg",
|
|
821
|
+
"bucket": "your-bucket",
|
|
822
|
+
"size": 1024000,
|
|
823
|
+
"mimeType": "image/jpeg",
|
|
824
|
+
"fileName": "file.jpg"
|
|
825
|
+
},
|
|
826
|
+
"base64": "data:image/jpeg;base64,/9j/4AAQ...",
|
|
827
|
+
"mimeType": "image/jpeg",
|
|
828
|
+
"fileName": "image.jpg"
|
|
829
|
+
}
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
### 🎯 **Event Subscription Examples**
|
|
833
|
+
|
|
834
|
+
```typescript
|
|
835
|
+
// Subscribe to all message-related events
|
|
836
|
+
await client.webhook.setWebhook("https://your-server.com/webhook", [
|
|
837
|
+
"Message",
|
|
838
|
+
"UndecryptableMessage",
|
|
839
|
+
"Receipt",
|
|
840
|
+
"MediaRetry",
|
|
841
|
+
]);
|
|
842
|
+
|
|
843
|
+
// Subscribe to connection events only
|
|
844
|
+
await client.webhook.setWebhook("https://your-server.com/webhook", [
|
|
845
|
+
"Connected",
|
|
846
|
+
"Disconnected",
|
|
847
|
+
"LoggedOut",
|
|
848
|
+
"QR",
|
|
849
|
+
]);
|
|
850
|
+
|
|
851
|
+
// Subscribe to group events
|
|
852
|
+
await client.webhook.setWebhook("https://your-server.com/webhook", [
|
|
853
|
+
"GroupInfo",
|
|
854
|
+
"JoinedGroup",
|
|
855
|
+
]);
|
|
856
|
+
|
|
857
|
+
// Subscribe to all events
|
|
858
|
+
await client.webhook.setWebhook("https://your-server.com/webhook", ["All"]);
|
|
859
|
+
|
|
860
|
+
// TypeScript: Use enum for type safety
|
|
861
|
+
import { WebhookEventType } from "wuzapi";
|
|
862
|
+
await client.webhook.setWebhook("https://your-server.com/webhook", [
|
|
863
|
+
WebhookEventType.MESSAGE,
|
|
864
|
+
WebhookEventType.RECEIPT,
|
|
865
|
+
WebhookEventType.CONNECTED,
|
|
866
|
+
WebhookEventType.QR,
|
|
867
|
+
]);
|
|
673
868
|
```
|
|
674
869
|
|
|
675
870
|
</details>
|
|
@@ -715,29 +910,83 @@ app.post("/webhook", async (req, res) => {
|
|
|
715
910
|
try {
|
|
716
911
|
const webhookPayload = req.body;
|
|
717
912
|
|
|
718
|
-
//
|
|
719
|
-
if (
|
|
720
|
-
|
|
913
|
+
// Validate payload structure with token and type
|
|
914
|
+
if (
|
|
915
|
+
!webhookPayload.token ||
|
|
916
|
+
!webhookPayload.type ||
|
|
917
|
+
!webhookPayload.event
|
|
918
|
+
) {
|
|
919
|
+
return res
|
|
920
|
+
.status(400)
|
|
921
|
+
.json({ error: "Invalid webhook payload structure" });
|
|
721
922
|
}
|
|
722
923
|
|
|
723
|
-
|
|
924
|
+
// Verify token (optional security check)
|
|
925
|
+
if (webhookPayload.token !== "your-expected-token") {
|
|
926
|
+
return res.status(401).json({ error: "Invalid webhook token" });
|
|
927
|
+
}
|
|
724
928
|
|
|
725
|
-
|
|
726
|
-
if (event.Message && event.Info) {
|
|
727
|
-
const messageContent = getMessageContent(event.Message);
|
|
728
|
-
const from = event.Info.RemoteJid.replace("@s.whatsapp.net", "");
|
|
929
|
+
console.log(`Received webhook event: ${webhookPayload.type}`);
|
|
729
930
|
|
|
730
|
-
|
|
731
|
-
|
|
931
|
+
// Handle S3 media if present
|
|
932
|
+
if (hasS3Media(webhookPayload)) {
|
|
933
|
+
console.log("S3 Media:", webhookPayload.s3.url);
|
|
934
|
+
}
|
|
732
935
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
936
|
+
const event = webhookPayload.event;
|
|
937
|
+
|
|
938
|
+
// Handle different event types
|
|
939
|
+
switch (webhookPayload.type) {
|
|
940
|
+
case "Message":
|
|
941
|
+
if (event.Message && event.Info) {
|
|
942
|
+
const messageContent = getMessageContent(event.Message);
|
|
943
|
+
const from = event.Info.RemoteJid.replace("@s.whatsapp.net", "");
|
|
944
|
+
|
|
945
|
+
if (messageContent?.type === "text") {
|
|
946
|
+
console.log(`Message from ${from}: ${messageContent.content}`);
|
|
947
|
+
|
|
948
|
+
// Auto-reply
|
|
949
|
+
if (messageContent.content.toLowerCase().includes("hello")) {
|
|
950
|
+
await client.chat.sendText({
|
|
951
|
+
Phone: from,
|
|
952
|
+
Body: "Hello! 👋 How can I help you?",
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
}
|
|
739
956
|
}
|
|
740
|
-
|
|
957
|
+
break;
|
|
958
|
+
|
|
959
|
+
case "Receipt":
|
|
960
|
+
console.log("Message receipt:", event.Type, event.MessageIDs);
|
|
961
|
+
break;
|
|
962
|
+
|
|
963
|
+
case "Connected":
|
|
964
|
+
console.log("✅ WhatsApp connected successfully");
|
|
965
|
+
break;
|
|
966
|
+
|
|
967
|
+
case "Disconnected":
|
|
968
|
+
console.log("❌ WhatsApp disconnected");
|
|
969
|
+
break;
|
|
970
|
+
|
|
971
|
+
case "QR":
|
|
972
|
+
console.log("📱 QR Code received:", event.Codes);
|
|
973
|
+
break;
|
|
974
|
+
|
|
975
|
+
case "GroupInfo":
|
|
976
|
+
console.log("👥 Group info updated:", event.GroupName);
|
|
977
|
+
break;
|
|
978
|
+
|
|
979
|
+
case "Presence":
|
|
980
|
+
console.log(
|
|
981
|
+
"👤 User presence:",
|
|
982
|
+
event.From,
|
|
983
|
+
event.Unavailable ? "offline" : "online"
|
|
984
|
+
);
|
|
985
|
+
break;
|
|
986
|
+
|
|
987
|
+
// Handle all other webhook events
|
|
988
|
+
default:
|
|
989
|
+
console.log(`Unhandled event type: ${webhookPayload.type}`, event);
|
|
741
990
|
}
|
|
742
991
|
|
|
743
992
|
res.json({ success: true });
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const wuzapiClient = require("./wuzapi-client.js");
|
|
4
4
|
const client = require("./client.js");
|
|
5
|
+
const webhook = require("./webhook.js");
|
|
5
6
|
const types_index = require("./types/index.js");
|
|
6
7
|
const modules_admin = require("./modules/admin.js");
|
|
7
8
|
const modules_session = require("./modules/session.js");
|
|
@@ -13,6 +14,12 @@ const modules_newsletter = require("./modules/newsletter.js");
|
|
|
13
14
|
exports.WuzapiClient = wuzapiClient.WuzapiClient;
|
|
14
15
|
exports.default = wuzapiClient.WuzapiClient;
|
|
15
16
|
exports.WuzapiError = client.WuzapiError;
|
|
17
|
+
exports.WEBHOOK_EVENTS = webhook.WEBHOOK_EVENTS;
|
|
18
|
+
exports.WebhookEventType = webhook.WebhookEventType;
|
|
19
|
+
exports.hasBase64Media = webhook.hasBase64Media;
|
|
20
|
+
exports.hasBothMedia = webhook.hasBothMedia;
|
|
21
|
+
exports.hasS3Media = webhook.hasS3Media;
|
|
22
|
+
exports.isValidWebhookPayload = webhook.isValidWebhookPayload;
|
|
16
23
|
exports.BotPluginSearchProvider = types_index.BotPluginSearchProvider;
|
|
17
24
|
exports.BotPluginType = types_index.BotPluginType;
|
|
18
25
|
exports.ButtonType = types_index.ButtonType;
|
|
@@ -42,9 +49,6 @@ exports.UnavailableType = types_index.UnavailableType;
|
|
|
42
49
|
exports.VideoAttribution = types_index.VideoAttribution;
|
|
43
50
|
exports.VideoSourceType = types_index.VideoSourceType;
|
|
44
51
|
exports.getMessageContent = types_index.getMessageContent;
|
|
45
|
-
exports.hasBase64Media = types_index.hasBase64Media;
|
|
46
|
-
exports.hasBothMedia = types_index.hasBothMedia;
|
|
47
|
-
exports.hasS3Media = types_index.hasS3Media;
|
|
48
52
|
exports.AdminModule = modules_admin.AdminModule;
|
|
49
53
|
exports.SessionModule = modules_session.SessionModule;
|
|
50
54
|
exports.UserModule = modules_user.UserModule;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BaseClient } from '../client.js';
|
|
2
2
|
import { RequestOptions } from '../types/common.js';
|
|
3
|
-
import { SetWebhookResponse, GetWebhookResponse, UpdateWebhookResponse, DeleteWebhookResponse } from '../types/webhook.js';
|
|
3
|
+
import { SetWebhookResponse, GetWebhookResponse, UpdateWebhookResponse, DeleteWebhookResponse, WebhookEventType, WebhookEvent } from '../types/webhook.js';
|
|
4
4
|
export declare class WebhookModule extends BaseClient {
|
|
5
5
|
/**
|
|
6
6
|
* Set webhook URL and events to subscribe to
|
|
7
7
|
*/
|
|
8
|
-
setWebhook(webhookURL: string, events?: string[], options?: RequestOptions): Promise<SetWebhookResponse>;
|
|
8
|
+
setWebhook(webhookURL: string, events?: (WebhookEvent | string)[], options?: RequestOptions): Promise<SetWebhookResponse>;
|
|
9
9
|
/**
|
|
10
10
|
* Get current webhook configuration
|
|
11
11
|
*/
|
|
@@ -13,9 +13,17 @@ export declare class WebhookModule extends BaseClient {
|
|
|
13
13
|
/**
|
|
14
14
|
* Update webhook URL, events, and activation status
|
|
15
15
|
*/
|
|
16
|
-
updateWebhook(webhookURL?: string, events?: string[], active?: boolean, options?: RequestOptions): Promise<UpdateWebhookResponse>;
|
|
16
|
+
updateWebhook(webhookURL?: string, events?: (WebhookEvent | string)[], active?: boolean, options?: RequestOptions): Promise<UpdateWebhookResponse>;
|
|
17
17
|
/**
|
|
18
18
|
* Delete webhook configuration
|
|
19
19
|
*/
|
|
20
20
|
deleteWebhook(options?: RequestOptions): Promise<DeleteWebhookResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Get all available webhook event types
|
|
23
|
+
*/
|
|
24
|
+
static getAvailableEvents(): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Get webhook event types enum for type-safe access
|
|
27
|
+
*/
|
|
28
|
+
static get EventTypes(): typeof WebhookEventType;
|
|
21
29
|
}
|
package/dist/modules/webhook.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const client = require("../client.js");
|
|
4
|
+
const webhook = require("../webhook.js");
|
|
4
5
|
class WebhookModule extends client.BaseClient {
|
|
5
6
|
/**
|
|
6
7
|
* Set webhook URL and events to subscribe to
|
|
@@ -32,6 +33,18 @@ class WebhookModule extends client.BaseClient {
|
|
|
32
33
|
async deleteWebhook(options) {
|
|
33
34
|
return this.delete("/webhook", options);
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Get all available webhook event types
|
|
38
|
+
*/
|
|
39
|
+
static getAvailableEvents() {
|
|
40
|
+
return webhook.WEBHOOK_EVENTS;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get webhook event types enum for type-safe access
|
|
44
|
+
*/
|
|
45
|
+
static get EventTypes() {
|
|
46
|
+
return webhook.WebhookEventType;
|
|
47
|
+
}
|
|
35
48
|
}
|
|
36
49
|
exports.WebhookModule = WebhookModule;
|
|
37
50
|
//# sourceMappingURL=webhook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sources":["../../src/modules/webhook.ts"],"sourcesContent":["import { BaseClient } from \"../client.js\";\nimport { RequestOptions } from \"../types/common.js\";\nimport {\n SetWebhookRequest,\n SetWebhookResponse,\n GetWebhookResponse,\n UpdateWebhookRequest,\n UpdateWebhookResponse,\n DeleteWebhookResponse,\n} from \"../types/webhook.js\";\n\nexport class WebhookModule extends BaseClient {\n /**\n * Set webhook URL and events to subscribe to\n */\n async setWebhook(\n webhookURL: string,\n events: string[] = [\"All\"],\n options?: RequestOptions\n ): Promise<SetWebhookResponse> {\n const request: SetWebhookRequest = { webhook: webhookURL, events };\n return this.post<SetWebhookResponse>(\"/webhook\", request, options);\n }\n\n /**\n * Get current webhook configuration\n */\n async getWebhook(options?: RequestOptions): Promise<GetWebhookResponse> {\n return this.get<GetWebhookResponse>(\"/webhook\", options);\n }\n\n /**\n * Update webhook URL, events, and activation status\n */\n async updateWebhook(\n webhookURL?: string,\n events?: string[],\n active?: boolean,\n options?: RequestOptions\n ): Promise<UpdateWebhookResponse> {\n const request: UpdateWebhookRequest = {\n webhook: webhookURL,\n events,\n Active: active,\n };\n return this.put<UpdateWebhookResponse>(\"/webhook\", request, options);\n }\n\n /**\n * Delete webhook configuration\n */\n async deleteWebhook(\n options?: RequestOptions\n ): Promise<DeleteWebhookResponse> {\n return this.delete<DeleteWebhookResponse>(\"/webhook\", options);\n }\n}\n"],"names":["BaseClient"],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.js","sources":["../../src/modules/webhook.ts"],"sourcesContent":["import { BaseClient } from \"../client.js\";\nimport { RequestOptions } from \"../types/common.js\";\nimport {\n SetWebhookRequest,\n SetWebhookResponse,\n GetWebhookResponse,\n UpdateWebhookRequest,\n UpdateWebhookResponse,\n DeleteWebhookResponse,\n WebhookEventType,\n WebhookEvent,\n WEBHOOK_EVENTS,\n} from \"../types/webhook.js\";\n\nexport class WebhookModule extends BaseClient {\n /**\n * Set webhook URL and events to subscribe to\n */\n async setWebhook(\n webhookURL: string,\n events: (WebhookEvent | string)[] = [\"All\"],\n options?: RequestOptions\n ): Promise<SetWebhookResponse> {\n const request: SetWebhookRequest = { webhook: webhookURL, events };\n return this.post<SetWebhookResponse>(\"/webhook\", request, options);\n }\n\n /**\n * Get current webhook configuration\n */\n async getWebhook(options?: RequestOptions): Promise<GetWebhookResponse> {\n return this.get<GetWebhookResponse>(\"/webhook\", options);\n }\n\n /**\n * Update webhook URL, events, and activation status\n */\n async updateWebhook(\n webhookURL?: string,\n events?: (WebhookEvent | string)[],\n active?: boolean,\n options?: RequestOptions\n ): Promise<UpdateWebhookResponse> {\n const request: UpdateWebhookRequest = {\n webhook: webhookURL,\n events,\n Active: active,\n };\n return this.put<UpdateWebhookResponse>(\"/webhook\", request, options);\n }\n\n /**\n * Delete webhook configuration\n */\n async deleteWebhook(\n options?: RequestOptions\n ): Promise<DeleteWebhookResponse> {\n return this.delete<DeleteWebhookResponse>(\"/webhook\", options);\n }\n\n /**\n * Get all available webhook event types\n */\n static getAvailableEvents(): string[] {\n return WEBHOOK_EVENTS;\n }\n\n /**\n * Get webhook event types enum for type-safe access\n */\n static get EventTypes(): typeof WebhookEventType {\n return WebhookEventType;\n }\n}\n"],"names":["BaseClient","WEBHOOK_EVENTS","WebhookEventType"],"mappings":";;;;AAcO,MAAM,sBAAsBA,OAAAA,WAAW;AAAA;AAAA;AAAA;AAAA,EAI5C,MAAM,WACJ,YACA,SAAoC,CAAC,KAAK,GAC1C,SAC6B;AAC7B,UAAM,UAA6B,EAAE,SAAS,YAAY,OAAA;AAC1D,WAAO,KAAK,KAAyB,YAAY,SAAS,OAAO;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,SAAuD;AACtE,WAAO,KAAK,IAAwB,YAAY,OAAO;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cACJ,YACA,QACA,QACA,SACgC;AAChC,UAAM,UAAgC;AAAA,MACpC,SAAS;AAAA,MACT;AAAA,MACA,QAAQ;AAAA,IAAA;AAEV,WAAO,KAAK,IAA2B,YAAY,SAAS,OAAO;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cACJ,SACgC;AAChC,WAAO,KAAK,OAA8B,YAAY,OAAO;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,qBAA+B;AACpC,WAAOC,QAAAA;AAAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW,aAAsC;AAC/C,WAAOC,QAAAA;AAAAA,EACT;AACF;;"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
return !!payload.s3;
|
|
5
|
-
}
|
|
6
|
-
function hasBase64Media(payload) {
|
|
7
|
-
return !!payload.base64;
|
|
8
|
-
}
|
|
9
|
-
function hasBothMedia(payload) {
|
|
10
|
-
return hasS3Media(payload) && hasBase64Media(payload);
|
|
11
|
-
}
|
|
3
|
+
const webhook = require("../webhook.js");
|
|
12
4
|
var DisappearingModeInitiator = /* @__PURE__ */ ((DisappearingModeInitiator2) => {
|
|
13
5
|
DisappearingModeInitiator2[DisappearingModeInitiator2["CHANGED_IN_CHAT"] = 0] = "CHANGED_IN_CHAT";
|
|
14
6
|
DisappearingModeInitiator2[DisappearingModeInitiator2["INITIATED_BY_ME"] = 1] = "INITIATED_BY_ME";
|
|
@@ -361,6 +353,12 @@ var TempBanReason = /* @__PURE__ */ ((TempBanReason2) => {
|
|
|
361
353
|
TempBanReason2[TempBanReason2["BROADCAST_LIST"] = 106] = "BROADCAST_LIST";
|
|
362
354
|
return TempBanReason2;
|
|
363
355
|
})(TempBanReason || {});
|
|
356
|
+
exports.WEBHOOK_EVENTS = webhook.WEBHOOK_EVENTS;
|
|
357
|
+
exports.WebhookEventType = webhook.WebhookEventType;
|
|
358
|
+
exports.hasBase64Media = webhook.hasBase64Media;
|
|
359
|
+
exports.hasBothMedia = webhook.hasBothMedia;
|
|
360
|
+
exports.hasS3Media = webhook.hasS3Media;
|
|
361
|
+
exports.isValidWebhookPayload = webhook.isValidWebhookPayload;
|
|
364
362
|
exports.BotPluginSearchProvider = BotPluginSearchProvider;
|
|
365
363
|
exports.BotPluginType = BotPluginType;
|
|
366
364
|
exports.ButtonType = ButtonType;
|
|
@@ -390,7 +388,4 @@ exports.UnavailableType = UnavailableType;
|
|
|
390
388
|
exports.VideoAttribution = VideoAttribution;
|
|
391
389
|
exports.VideoSourceType = VideoSourceType;
|
|
392
390
|
exports.getMessageContent = getMessageContent;
|
|
393
|
-
exports.hasBase64Media = hasBase64Media;
|
|
394
|
-
exports.hasBothMedia = hasBothMedia;
|
|
395
|
-
exports.hasS3Media = hasS3Media;
|
|
396
391
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/types/webhook.ts","../../src/types/message.ts","../../src/types/events.ts"],"sourcesContent":["// Webhook endpoints types\n\nexport interface SetWebhookRequest {\n webhook: string;\n events: 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?: 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\nexport interface WebhookPayload<T = unknown> {\n event: 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 event: T;\n s3: S3MediaInfo;\n}\n\n// Base64 only delivery\nexport interface Base64OnlyWebhookPayload<T = unknown> {\n event: T;\n base64: string;\n mimeType: string;\n fileName: string;\n}\n\n// Both S3 and Base64 delivery\nexport interface BothMediaWebhookPayload<T = unknown> {\n event: 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// Helper type guards\nexport function hasS3Media(\n payload: WebhookPayload\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: WebhookPayload\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: WebhookPayload\n): payload is BothMediaWebhookPayload {\n return hasS3Media(payload) && hasBase64Media(payload);\n}\n","// WhatsApp Message types based on whatsmeow protobuf definitions\n// Reference: https://pkg.go.dev/go.mau.fi/whatsmeow@v0.0.0-20250829123043-72d2ed58e998/proto/waE2E#Message\n\n// Base message context and metadata types\nexport interface ContextInfo {\n stanzaId?: string;\n participant?: string;\n quotedMessage?: Message;\n remoteJid?: string;\n mentionedJid?: string[];\n conversionSource?: string;\n conversionData?: string;\n conversionDelaySeconds?: number;\n forwardingScore?: number;\n isForwarded?: boolean;\n quotedAd?: AdReplyInfo;\n placeholderKey?: MessageKey;\n expiration?: number;\n ephemeralSettingTimestamp?: number;\n ephemeralSharedSecret?: string;\n externalAdReply?: ExternalAdReplyInfo;\n entryPointConversionSource?: string;\n entryPointConversionApp?: string;\n entryPointConversionDelaySeconds?: number;\n disappearingMode?: DisappearingMode;\n actionLink?: ActionLink;\n groupSubject?: string;\n parentGroupJid?: string;\n trustBannerType?: string;\n trustBannerAction?: number;\n isSampled?: boolean;\n utm?: UTMInfo;\n}\n\nexport interface MessageKey {\n remoteJid?: string;\n fromMe?: boolean;\n id?: string;\n participant?: string;\n}\n\nexport interface DisappearingMode {\n initiator?: DisappearingModeInitiator;\n trigger?: DisappearingModeTrigger;\n initiatorDeviceJid?: string;\n}\n\nexport enum DisappearingModeInitiator {\n CHANGED_IN_CHAT = 0,\n INITIATED_BY_ME = 1,\n INITIATED_BY_OTHER = 2,\n}\n\nexport enum DisappearingModeTrigger {\n UNKNOWN = 0,\n CHAT_SETTING = 1,\n ACCOUNT_SETTING = 2,\n BULK_CHANGE = 3,\n}\n\nexport interface AdReplyInfo {\n advertiserName?: string;\n mediaType?: MediaType;\n jpegThumbnail?: Uint8Array;\n caption?: string;\n}\n\nexport interface ExternalAdReplyInfo {\n title?: string;\n body?: string;\n mediaType?: MediaType;\n thumbnailUrl?: string;\n mediaUrl?: string;\n thumbnail?: Uint8Array;\n sourceType?: string;\n sourceId?: string;\n sourceUrl?: string;\n containsAutoReply?: boolean;\n renderLargerThumbnail?: boolean;\n showAdAttribution?: boolean;\n ctwaClid?: string;\n ref?: string;\n}\n\nexport interface ActionLink {\n url?: string;\n buttonTitle?: string;\n}\n\nexport interface UTMInfo {\n utmSource?: string;\n utmCampaign?: string;\n}\n\nexport enum MediaType {\n UNKNOWN = 0,\n IMAGE = 1,\n VIDEO = 2,\n AUDIO = 3,\n DOCUMENT = 4,\n STICKER = 5,\n}\n\n// Interactive elements\nexport interface InteractiveAnnotation {\n polygonVertices?: Point[];\n location?: Location;\n}\n\nexport interface Point {\n xDeprecated?: number;\n yDeprecated?: number;\n x?: number;\n y?: number;\n}\n\n// Location types\nexport interface LocationMessage {\n degreesLatitude?: number;\n degreesLongitude?: number;\n name?: string;\n address?: string;\n url?: string;\n isLiveLocation?: boolean;\n accuracyInMeters?: number;\n speedInMps?: number;\n degreesClockwiseFromMagneticNorth?: number;\n comment?: string;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n}\n\nexport interface LiveLocationMessage {\n degreesLatitude?: number;\n degreesLongitude?: number;\n accuracyInMeters?: number;\n speedInMps?: number;\n degreesClockwiseFromMagneticNorth?: number;\n caption?: string;\n sequenceNumber?: number;\n timeOffset?: number;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n}\n\nexport interface Location {\n degreesLatitude?: number;\n degreesLongitude?: number;\n name?: string;\n}\n\n// Media message types\nexport interface ImageMessage {\n url?: string;\n mimetype?: string;\n caption?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n height?: number;\n width?: number;\n mediaKey?: Uint8Array;\n fileEncSha256?: Uint8Array;\n interactiveAnnotations?: InteractiveAnnotation[];\n directPath?: string;\n mediaKeyTimestamp?: number;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n firstScanSidecar?: Uint8Array;\n firstScanLength?: number;\n experimentGroupId?: number;\n scansSidecar?: Uint8Array;\n scanLengths?: number[];\n midQualityFileSha256?: Uint8Array;\n midQualityFileEncSha256?: Uint8Array;\n viewOnce?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n staticUrl?: string;\n annotations?: InteractiveAnnotation[];\n originalFileName?: string;\n}\n\nexport interface VideoMessage {\n url?: string;\n mimetype?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n seconds?: number;\n mediaKey?: Uint8Array;\n caption?: string;\n gifPlayback?: boolean;\n height?: number;\n width?: number;\n fileEncSha256?: Uint8Array;\n interactiveAnnotations?: InteractiveAnnotation[];\n directPath?: string;\n mediaKeyTimestamp?: number;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n streamingSidecar?: Uint8Array;\n gifAttribution?: VideoAttribution;\n viewOnce?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n staticUrl?: string;\n annotations?: InteractiveAnnotation[];\n accessibilityLabel?: string;\n processedVideos?: ProcessedVideo[];\n externalShareFullVideoDurationInSeconds?: number;\n motionPhotoPresentationOffsetMS?: number;\n metadataUrl?: string;\n videoSourceType?: VideoSourceType;\n}\n\nexport enum VideoAttribution {\n NONE = 0,\n GIPHY = 1,\n TENOR = 2,\n KLIPY = 3,\n}\n\nexport enum VideoSourceType {\n USER_VIDEO = 0,\n AI_GENERATED = 1,\n}\n\nexport interface ProcessedVideo {\n url?: string;\n fileLength?: number;\n fileSha256?: Uint8Array;\n fileEncSha256?: Uint8Array;\n}\n\nexport interface AudioMessage {\n url?: string;\n mimetype?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n seconds?: number;\n ptt?: boolean;\n mediaKey?: Uint8Array;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n mediaKeyTimestamp?: number;\n contextInfo?: ContextInfo;\n streamingSidecar?: Uint8Array;\n waveform?: Uint8Array;\n backgroundArgb?: number;\n viewOnce?: boolean;\n}\n\nexport interface DocumentMessage {\n url?: string;\n mimetype?: string;\n title?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n pageCount?: number;\n mediaKey?: Uint8Array;\n fileName?: string;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n mediaKeyTimestamp?: number;\n contactVcard?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n thumbnailHeight?: number;\n thumbnailWidth?: number;\n caption?: string;\n}\n\nexport interface StickerMessage {\n url?: string;\n fileSha256?: Uint8Array;\n fileEncSha256?: Uint8Array;\n mediaKey?: Uint8Array;\n mimetype?: string;\n height?: number;\n width?: number;\n directPath?: string;\n fileLength?: number;\n mediaKeyTimestamp?: number;\n firstFrameLength?: number;\n firstFrameSidecar?: Uint8Array;\n isAnimated?: boolean;\n pngThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n stickerSentTs?: number;\n isAvatar?: boolean;\n isAiSticker?: boolean;\n isLottie?: boolean;\n}\n\n// Contact message types\nexport interface ContactMessage {\n displayName?: string;\n vcard?: string;\n contextInfo?: ContextInfo;\n}\n\nexport interface ContactsArrayMessage {\n displayName?: string;\n contacts?: ContactMessage[];\n contextInfo?: ContextInfo;\n}\n\n// Text and extended text messages\nexport interface ExtendedTextMessage {\n text?: string;\n matchedText?: string;\n canonicalUrl?: string;\n description?: string;\n title?: string;\n textArgb?: number;\n backgroundArgb?: number;\n font?: ExtendedTextMessageFontType;\n previewType?: ExtendedTextMessagePreviewType;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n doNotPlayInline?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n mediaKey?: Uint8Array;\n mediaKeyTimestamp?: number;\n thumbnailHeight?: number;\n thumbnailWidth?: number;\n inviteLinkGroupType?: ExtendedTextMessageInviteLinkGroupType;\n inviteLinkParentGroupSubject?: string;\n inviteLinkParentGroupThumbnailJpeg?: Uint8Array;\n inviteLinkGroupTypeV2?: InviteLinkGroupType;\n viewOnce?: boolean;\n}\n\nexport enum ExtendedTextMessageFontType {\n SANS_SERIF = 0,\n SERIF = 1,\n NORICAN_REGULAR = 2,\n BRYNDAN_WRITE = 3,\n BEBASNEUE_REGULAR = 4,\n OSWALD_HEAVY = 5,\n}\n\nexport enum ExtendedTextMessagePreviewType {\n NONE = 0,\n VIDEO = 1,\n PLACEHOLDER = 4,\n IMAGE = 5,\n}\n\nexport enum ExtendedTextMessageInviteLinkGroupType {\n DEFAULT = 0,\n PARENT = 1,\n SUB = 2,\n DEFAULT_SUB = 3,\n}\n\nexport enum InviteLinkGroupType {\n DEFAULT = 0,\n PARENT = 1,\n SUB = 2,\n DEFAULT_SUB = 3,\n}\n\n// Interactive messages\nexport interface ButtonsMessage {\n contentText?: string;\n footerText?: string;\n contextInfo?: ContextInfo;\n buttons?: Button[];\n headerType?: ButtonsMessageHeaderType;\n text?: string;\n documentMessage?: DocumentMessage;\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n locationMessage?: LocationMessage;\n}\n\nexport interface Button {\n buttonId?: string;\n buttonText?: ButtonText;\n type?: ButtonType;\n nativeFlowInfo?: NativeFlowInfo;\n}\n\nexport interface ButtonText {\n displayText?: string;\n}\n\nexport enum ButtonType {\n UNKNOWN = 0,\n RESPONSE = 1,\n NATIVE_FLOW = 2,\n}\n\nexport interface NativeFlowInfo {\n name?: string;\n paramsJson?: string;\n}\n\nexport enum ButtonsMessageHeaderType {\n UNKNOWN = 0,\n EMPTY = 1,\n TEXT = 2,\n DOCUMENT = 3,\n IMAGE = 4,\n VIDEO = 5,\n LOCATION = 6,\n}\n\nexport interface ListMessage {\n title?: string;\n description?: string;\n buttonText?: string;\n listType?: ListMessageListType;\n sections?: Section[];\n productListInfo?: ProductListInfo;\n footerText?: string;\n contextInfo?: ContextInfo;\n}\n\nexport interface Section {\n title?: string;\n rows?: Row[];\n}\n\nexport interface Row {\n title?: string;\n description?: string;\n rowId?: string;\n}\n\nexport interface ProductListInfo {\n productSections?: ProductSection[];\n headerImage?: ImageMessage;\n businessOwnerJid?: string;\n}\n\nexport interface ProductSection {\n title?: string;\n products?: ProductListItem[];\n}\n\nexport interface ProductListItem {\n productId?: string;\n}\n\nexport enum ListMessageListType {\n UNKNOWN = 0,\n SINGLE_SELECT = 1,\n PRODUCT_LIST = 2,\n}\n\n// Template and interactive response messages\nexport interface TemplateMessage {\n contextInfo?: ContextInfo;\n hydratedTemplate?: HydratedFourRowTemplate;\n templateId?: string;\n documentMessage?: DocumentMessage;\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n locationMessage?: LocationMessage;\n}\n\nexport interface HydratedFourRowTemplate {\n documentMessage?: DocumentMessage;\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n locationMessage?: LocationMessage;\n title?: string;\n hydratedContentText?: string;\n hydratedFooterText?: string;\n hydratedButtons?: HydratedTemplateButton[];\n templateId?: string;\n mask?: string;\n}\n\nexport interface HydratedTemplateButton {\n index?: number;\n quickReplyButton?: HydratedQuickReplyButton;\n urlButton?: HydratedURLButton;\n callButton?: HydratedCallButton;\n}\n\nexport interface HydratedQuickReplyButton {\n displayText?: string;\n id?: string;\n}\n\nexport interface HydratedURLButton {\n displayText?: string;\n url?: string;\n}\n\nexport interface HydratedCallButton {\n displayText?: string;\n phoneNumber?: string;\n}\n\n// Response messages\nexport interface ButtonsResponseMessage {\n selectedButtonId?: string;\n contextInfo?: ContextInfo;\n type?: ButtonsResponseMessageType;\n selectedDisplayText?: string;\n}\n\nexport enum ButtonsResponseMessageType {\n UNKNOWN = 0,\n DISPLAY_TEXT = 1,\n}\n\nexport interface ListResponseMessage {\n title?: string;\n listType?: ListResponseMessageListType;\n singleSelectReply?: SingleSelectReply;\n contextInfo?: ContextInfo;\n description?: string;\n}\n\nexport interface SingleSelectReply {\n selectedRowId?: string;\n}\n\nexport enum ListResponseMessageListType {\n UNKNOWN = 0,\n SINGLE_SELECT = 1,\n}\n\n// Payment and order messages\nexport interface SendPaymentMessage {\n noteMessage?: Message;\n requestMessageKey?: MessageKey;\n background?: PaymentBackground;\n}\n\nexport interface PaymentBackground {\n id?: string;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n mediaKey?: Uint8Array;\n type?: PaymentBackgroundType;\n mediaKeyTimestamp?: number;\n}\n\nexport enum PaymentBackgroundType {\n UNKNOWN = 0,\n DEFAULT = 1,\n}\n\nexport interface RequestPaymentMessage {\n noteMessage?: Message;\n currencyCodeIso4217?: string;\n amount1000?: number;\n requestFrom?: string;\n expiryTimestamp?: number;\n background?: PaymentBackground;\n}\n\nexport interface DeclinePaymentRequestMessage {\n key?: MessageKey;\n}\n\nexport interface CancelPaymentRequestMessage {\n key?: MessageKey;\n}\n\n// Group invite message\nexport interface GroupInviteMessage {\n groupJid?: string;\n inviteCode?: string;\n inviteExpiration?: number;\n groupName?: string;\n jpegThumbnail?: Uint8Array;\n caption?: string;\n contextInfo?: ContextInfo;\n}\n\n// Poll message\nexport interface PollCreationMessage {\n name?: string;\n options?: PollOption[];\n selectableOptionsCount?: number;\n contextInfo?: ContextInfo;\n}\n\nexport interface PollOption {\n optionName?: string;\n}\n\nexport interface PollUpdateMessage {\n pollCreationMessageKey?: MessageKey;\n vote?: PollEncValue;\n metadata?: PollUpdateMetadata;\n senderTimestampMs?: number;\n}\n\nexport interface PollEncValue {\n encPayload?: Uint8Array;\n encIv?: Uint8Array;\n}\n\nexport interface PollUpdateMetadata {\n // Metadata about the poll update\n}\n\n// Chat and conversation messages\nexport interface Chat {\n displayName?: string;\n id?: string;\n}\n\nexport interface Call {\n callKey?: Uint8Array;\n conversionSource?: string;\n conversionData?: Uint8Array;\n conversionDelaySeconds?: number;\n}\n\n// Main Message union type\nexport interface Message {\n // Text messages\n conversation?: string;\n extendedTextMessage?: ExtendedTextMessage;\n\n // Media messages\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n audioMessage?: AudioMessage;\n documentMessage?: DocumentMessage;\n stickerMessage?: StickerMessage;\n\n // Location messages\n locationMessage?: LocationMessage;\n liveLocationMessage?: LiveLocationMessage;\n\n // Contact messages\n contactMessage?: ContactMessage;\n contactsArrayMessage?: ContactsArrayMessage;\n\n // Interactive messages\n buttonsMessage?: ButtonsMessage;\n listMessage?: ListMessage;\n templateMessage?: TemplateMessage;\n\n // Response messages\n buttonsResponseMessage?: ButtonsResponseMessage;\n listResponseMessage?: ListResponseMessage;\n\n // Payment messages\n sendPaymentMessage?: SendPaymentMessage;\n requestPaymentMessage?: RequestPaymentMessage;\n declinePaymentRequestMessage?: DeclinePaymentRequestMessage;\n cancelPaymentRequestMessage?: CancelPaymentRequestMessage;\n\n // Group messages\n groupInviteMessage?: GroupInviteMessage;\n\n // Poll messages\n pollCreationMessage?: PollCreationMessage;\n pollUpdateMessage?: PollUpdateMessage;\n\n // System messages\n protocolMessage?: ProtocolMessage;\n ephemeralMessage?: EphemeralMessage;\n viewOnceMessage?: ViewOnceMessage;\n reactionMessage?: ReactionMessage;\n stickerSyncRmrMessage?: StickerSyncRmrMessage;\n\n // Call messages\n call?: Call;\n chat?: Chat;\n\n // MessageContextInfo\n messageContextInfo?: MessageContextInfo;\n}\n\n// System and protocol messages\nexport interface ProtocolMessage {\n key?: MessageKey;\n type?: ProtocolMessageType;\n ephemeralExpiration?: number;\n ephemeralSettingTimestamp?: number;\n historySyncNotification?: HistorySyncNotification;\n appStateSyncKeyShare?: AppStateSyncKeyShare;\n appStateSyncKeyRequest?: AppStateSyncKeyRequest;\n initialSecurityNotificationSettingSync?: InitialSecurityNotificationSettingSync;\n appStateFatalExceptionNotification?: AppStateFatalExceptionNotification;\n disappearingMode?: DisappearingMode;\n editedMessage?: Message;\n timestampMs?: number;\n peerDataOperationRequestMessage?: PeerDataOperationRequestMessage;\n peerDataOperationRequestResponseMessage?: PeerDataOperationRequestResponseMessage;\n}\n\nexport enum ProtocolMessageType {\n REVOKE = 0,\n EPHEMERAL_SETTING = 3,\n EPHEMERAL_SYNC_RESPONSE = 4,\n HISTORY_SYNC_NOTIFICATION = 5,\n APP_STATE_SYNC_KEY_SHARE = 6,\n APP_STATE_SYNC_KEY_REQUEST = 7,\n MSG_FANOUT_BACKFILL_REQUEST = 8,\n INITIAL_SECURITY_NOTIFICATION_SETTING_SYNC = 9,\n APP_STATE_FATAL_EXCEPTION_NOTIFICATION = 10,\n SHARE_PHONE_NUMBER = 11,\n MESSAGE_EDIT = 14,\n PEER_DATA_OPERATION_REQUEST_MESSAGE = 16,\n PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE = 17,\n}\n\nexport interface EphemeralMessage {\n message?: Message;\n}\n\nexport interface ViewOnceMessage {\n message?: Message;\n}\n\nexport interface ReactionMessage {\n key?: MessageKey;\n text?: string;\n groupingKey?: string;\n senderTimestampMs?: number;\n unread?: boolean;\n}\n\nexport interface StickerSyncRmrMessage {\n filehash?: string[];\n rmrSource?: string;\n requestTimestamp?: number;\n}\n\nexport interface MessageContextInfo {\n deviceListMetadata?: DeviceListMetadata;\n deviceListMetadataVersion?: number;\n messageSecret?: Uint8Array;\n paddingBytes?: Uint8Array;\n messageAddOnDurationInSecs?: number;\n botMessageInvoker?: BotMessageInvoker;\n botResponseCorrelationId?: string;\n botPluginType?: BotPluginType;\n botPluginReferenceIndex?: number;\n botPluginSearchProvider?: BotPluginSearchProvider;\n botPluginSearchUrl?: string;\n botPluginMaybeParentPluginType?: BotPluginType;\n botReelPluginThumbnailCdnUrl?: string;\n expiredBotResponseCorrelationId?: string;\n}\n\nexport interface DeviceListMetadata {\n senderKeyHash?: Uint8Array;\n senderTimestamp?: number;\n senderKeyIndexes?: number[];\n recipientKeyHash?: Uint8Array;\n recipientTimestamp?: number;\n recipientKeyIndexes?: number[];\n}\n\nexport interface BotMessageInvoker {\n // Bot message invoker details\n}\n\nexport enum BotPluginType {\n REELS = 0,\n SEARCH = 1,\n}\n\nexport enum BotPluginSearchProvider {\n BING = 0,\n GOOGLE = 1,\n}\n\n// Additional system notification types\nexport interface HistorySyncNotification {\n fileSha256?: Uint8Array;\n fileLength?: number;\n mediaKey?: Uint8Array;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n syncType?: HistorySyncNotificationHistorySyncType;\n chunkOrder?: number;\n originalMessageId?: string;\n progress?: number;\n oldestMsgInChunkTimestampSec?: number;\n initialHistBootstrapInlinePayload?: Uint8Array;\n peerDataRequestSessionId?: string;\n}\n\nexport enum HistorySyncNotificationHistorySyncType {\n INITIAL_BOOTSTRAP = 0,\n INITIAL_STATUS_V3 = 1,\n FULL = 2,\n RECENT = 3,\n PUSH_NAME = 4,\n NON_BLOCKING_DATA = 5,\n ON_DEMAND = 6,\n}\n\nexport interface AppStateSyncKeyShare {\n keys?: AppStateSyncKey[];\n}\n\nexport interface AppStateSyncKey {\n keyId?: AppStateSyncKeyId;\n keyData?: AppStateSyncKeyData;\n}\n\nexport interface AppStateSyncKeyId {\n keyId?: Uint8Array;\n}\n\nexport interface AppStateSyncKeyData {\n keyData?: Uint8Array;\n fingerprint?: AppStateSyncKeyFingerprint;\n timestamp?: number;\n}\n\nexport interface AppStateSyncKeyFingerprint {\n rawId?: number;\n currentIndex?: number;\n deviceIndexes?: number[];\n}\n\nexport interface AppStateSyncKeyRequest {\n keyIds?: AppStateSyncKeyId[];\n}\n\nexport interface InitialSecurityNotificationSettingSync {\n securityNotificationEnabled?: boolean;\n}\n\nexport interface AppStateFatalExceptionNotification {\n collectionNames?: string[];\n timestamp?: number;\n}\n\nexport interface PeerDataOperationRequestMessage {\n peerDataOperationRequestType?: PeerDataOperationRequestType;\n requestId?: string;\n}\n\nexport interface PeerDataOperationRequestResponseMessage {\n peerDataOperationResult?: PeerDataOperationRequestResponseMessagePeerDataOperationResult;\n stanzaId?: string;\n}\n\nexport enum PeerDataOperationRequestType {\n UPLOAD_STICKER = 0,\n SEND_RECENT_STICKER_BOOTSTRAP = 1,\n GENERATE_LINK_PREVIEW = 2,\n}\n\nexport enum PeerDataOperationRequestResponseMessagePeerDataOperationResult {\n SUCCESS = 0,\n NOT_AUTHORIZED = 1,\n NOT_FOUND = 2,\n THROTTLED = 3,\n UNKNOWN_ERROR = 4,\n}\n\n// Helper type to get the active message type\nexport type MessageContent =\n | { type: \"text\"; content: string }\n | { type: \"extendedText\"; content: ExtendedTextMessage }\n | { type: \"image\"; content: ImageMessage }\n | { type: \"video\"; content: VideoMessage }\n | { type: \"audio\"; content: AudioMessage }\n | { type: \"document\"; content: DocumentMessage }\n | { type: \"sticker\"; content: StickerMessage }\n | { type: \"location\"; content: LocationMessage }\n | { type: \"liveLocation\"; content: LiveLocationMessage }\n | { type: \"contact\"; content: ContactMessage }\n | { type: \"contactsArray\"; content: ContactsArrayMessage }\n | { type: \"buttons\"; content: ButtonsMessage }\n | { type: \"list\"; content: ListMessage }\n | { type: \"template\"; content: TemplateMessage }\n | { type: \"buttonsResponse\"; content: ButtonsResponseMessage }\n | { type: \"listResponse\"; content: ListResponseMessage }\n | { type: \"groupInvite\"; content: GroupInviteMessage }\n | { type: \"poll\"; content: PollCreationMessage }\n | { type: \"pollUpdate\"; content: PollUpdateMessage }\n | { type: \"reaction\"; content: ReactionMessage }\n | { type: \"protocol\"; content: ProtocolMessage }\n | { type: \"ephemeral\"; content: EphemeralMessage }\n | { type: \"viewOnce\"; content: ViewOnceMessage };\n\n// Utility function to extract message content and type\nexport function getMessageContent(message: Message): MessageContent | null {\n if (message.conversation) {\n return { type: \"text\", content: message.conversation };\n }\n if (message.extendedTextMessage) {\n return { type: \"extendedText\", content: message.extendedTextMessage };\n }\n if (message.imageMessage) {\n return { type: \"image\", content: message.imageMessage };\n }\n if (message.videoMessage) {\n return { type: \"video\", content: message.videoMessage };\n }\n if (message.audioMessage) {\n return { type: \"audio\", content: message.audioMessage };\n }\n if (message.documentMessage) {\n return { type: \"document\", content: message.documentMessage };\n }\n if (message.stickerMessage) {\n return { type: \"sticker\", content: message.stickerMessage };\n }\n if (message.locationMessage) {\n return { type: \"location\", content: message.locationMessage };\n }\n if (message.liveLocationMessage) {\n return { type: \"liveLocation\", content: message.liveLocationMessage };\n }\n if (message.contactMessage) {\n return { type: \"contact\", content: message.contactMessage };\n }\n if (message.contactsArrayMessage) {\n return { type: \"contactsArray\", content: message.contactsArrayMessage };\n }\n if (message.buttonsMessage) {\n return { type: \"buttons\", content: message.buttonsMessage };\n }\n if (message.listMessage) {\n return { type: \"list\", content: message.listMessage };\n }\n if (message.templateMessage) {\n return { type: \"template\", content: message.templateMessage };\n }\n if (message.buttonsResponseMessage) {\n return { type: \"buttonsResponse\", content: message.buttonsResponseMessage };\n }\n if (message.listResponseMessage) {\n return { type: \"listResponse\", content: message.listResponseMessage };\n }\n if (message.groupInviteMessage) {\n return { type: \"groupInvite\", content: message.groupInviteMessage };\n }\n if (message.pollCreationMessage) {\n return { type: \"poll\", content: message.pollCreationMessage };\n }\n if (message.pollUpdateMessage) {\n return { type: \"pollUpdate\", content: message.pollUpdateMessage };\n }\n if (message.reactionMessage) {\n return { type: \"reaction\", content: message.reactionMessage };\n }\n if (message.protocolMessage) {\n return { type: \"protocol\", content: message.protocolMessage };\n }\n if (message.ephemeralMessage) {\n return { type: \"ephemeral\", content: message.ephemeralMessage };\n }\n if (message.viewOnceMessage) {\n return { type: \"viewOnce\", content: message.viewOnceMessage };\n }\n\n return null;\n}\n","// WhatsApp events types based on whatsmeow package\n// Reference: https://pkg.go.dev/go.mau.fi/whatsmeow@v0.0.0-20250829123043-72d2ed58e998/types/events\n\nimport { Message } from \"./message.js\";\n\n// Event types enum for all possible WhatsApp events\nexport enum EventType {\n // Core message and communication events\n MESSAGE = \"Message\",\n RECEIPT = \"Receipt\",\n PRESENCE = \"Presence\",\n CHAT_PRESENCE = \"ChatPresence\",\n\n // Connection and session events\n CONNECTED = \"Connected\",\n DISCONNECTED = \"Disconnected\",\n LOGGED_OUT = \"LoggedOut\",\n QR = \"QR\",\n QR_SCANNED_WITHOUT_MULTIDEVICE = \"QRScannedWithoutMultidevice\",\n PAIR_SUCCESS = \"PairSuccess\",\n PAIR_ERROR = \"PairError\",\n MANUAL_LOGIN_RECONNECT = \"ManualLoginReconnect\",\n KEEP_ALIVE_RESTORED = \"KeepAliveRestored\",\n KEEP_ALIVE_TIMEOUT = \"KeepAliveTimeout\",\n\n // Group events\n GROUP_INFO = \"GroupInfo\",\n JOINED_GROUP = \"JoinedGroup\",\n\n // Contact and user events\n CONTACT = \"Contact\",\n PUSH_NAME = \"PushName\",\n PUSH_NAME_SETTING = \"PushNameSetting\",\n PICTURE = \"Picture\",\n USER_ABOUT = \"UserAbout\",\n USER_STATUS_MUTE = \"UserStatusMute\",\n PRIVACY_SETTINGS = \"PrivacySettings\",\n\n // App state and sync events\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 IDENTITY_CHANGE = \"IdentityChange\",\n\n // Chat management events\n ARCHIVE = \"Archive\",\n UNARCHIVE_CHATS_SETTING = \"UnarchiveChatsSetting\",\n CLEAR_CHAT = \"ClearChat\",\n DELETE_CHAT = \"DeleteChat\",\n DELETE_FOR_ME = \"DeleteForMe\",\n MARK_CHAT_AS_READ = \"MarkChatAsRead\",\n MUTE = \"Mute\",\n PIN = \"Pin\",\n STAR = \"Star\",\n\n // Label events\n LABEL_ASSOCIATION_CHAT = \"LabelAssociationChat\",\n LABEL_ASSOCIATION_MESSAGE = \"LabelAssociationMessage\",\n LABEL_EDIT = \"LabelEdit\",\n\n // Media events\n MEDIA_RETRY = \"MediaRetry\",\n MEDIA_RETRY_ERROR = \"MediaRetryError\",\n\n // Newsletter events\n NEWSLETTER_JOIN = \"NewsletterJoin\",\n NEWSLETTER_LEAVE = \"NewsletterLeave\",\n NEWSLETTER_LIVE_UPDATE = \"NewsletterLiveUpdate\",\n NEWSLETTER_MESSAGE_META = \"NewsletterMessageMeta\",\n NEWSLETTER_MUTE_CHANGE = \"NewsletterMuteChange\",\n\n // Error and system events\n UNDECRYPTABLE_MESSAGE = \"UndecryptableMessage\",\n STREAM_ERROR = \"StreamError\",\n STREAM_REPLACED = \"StreamReplaced\",\n CONNECT_FAILURE = \"ConnectFailure\",\n CLIENT_OUTDATED = \"ClientOutdated\",\n TEMPORARY_BAN = \"TemporaryBan\",\n CAT_REFRESH_ERROR = \"CATRefreshError\",\n PERMANENT_DISCONNECT = \"PermanentDisconnect\",\n\n // Blocklist events\n BLOCKLIST = \"Blocklist\",\n BLOCKLIST_ACTION = \"BlocklistAction\",\n BLOCKLIST_CHANGE = \"BlocklistChange\",\n\n // Business events\n BUSINESS_NAME = \"BusinessName\",\n\n // Call events\n CALL_ACCEPT = \"CallAccept\",\n CALL_OFFER = \"CallOffer\",\n CALL_OFFER_NOTICE = \"CallOfferNotice\",\n CALL_PRE_ACCEPT = \"CallPreAccept\",\n CALL_REJECT = \"CallReject\",\n CALL_RELAY_LATENCY = \"CallRelayLatency\",\n CALL_TERMINATE = \"CallTerminate\",\n CALL_TRANSPORT = \"CallTransport\",\n UNKNOWN_CALL_EVENT = \"UnknownCallEvent\",\n\n // FB/Meta specific events\n FB_MESSAGE = \"FBMessage\",\n}\n\n// Additional specific types from whatsmeow\nexport interface WaBinaryNode {\n Tag: string;\n Attrs: Record<string, string>;\n Content: unknown;\n}\n\nexport interface SyncAction {\n timestamp: Date;\n action: unknown;\n}\n\nexport interface StarAction extends SyncAction {\n starred: boolean;\n}\n\nexport interface ArchiveAction extends SyncAction {\n archived: boolean;\n}\n\nexport interface ClearChatAction extends SyncAction {\n messageRange?: {\n lastMessageTimestamp?: Date;\n lastSystemMessageTimestamp?: Date;\n };\n}\n\nexport interface DeleteChatAction extends SyncAction {}\n\nexport interface DeleteMessageForMeAction extends SyncAction {}\n\nexport interface MarkChatAsReadAction extends SyncAction {\n read: boolean;\n messageRange?: {\n lastMessageTimestamp?: Date;\n lastSystemMessageTimestamp?: Date;\n };\n}\n\nexport interface MuteAction extends SyncAction {\n muted: boolean;\n muteEndTimestamp?: Date;\n}\n\nexport interface PinAction extends SyncAction {\n pinned: boolean;\n}\n\nexport interface PushNameSettingAction extends SyncAction {\n name: string;\n}\n\nexport interface UnarchiveChatsSettingAction extends SyncAction {\n unarchiveChats: boolean;\n}\n\nexport interface LabelAssociationAction extends SyncAction {\n labeled: boolean;\n}\n\nexport interface LabelEditAction extends SyncAction {\n name: string;\n color: number;\n predefinedId?: string;\n deleted: boolean;\n}\n\nexport interface BusinessNameAction extends SyncAction {\n businessName: string;\n verified: number;\n}\n\nexport interface UserStatusMuteAction extends SyncAction {\n muted: boolean;\n}\n\nexport interface Armadillo {\n payload?: unknown;\n}\n\nexport interface ConsumerApplication {\n metadata?: unknown;\n}\n\nexport interface BasicCallMeta {\n from: JID;\n timestamp: Date;\n callId: string;\n callCreator: JID;\n}\n\nexport interface CallRemoteMeta {\n remoteJid: JID;\n fromMe: boolean;\n}\n\nexport interface EventGroupParticipant {\n JID: JID;\n IsAdmin: boolean;\n IsSuperAdmin: boolean;\n}\n\nexport interface HistorySyncData {\n conversations?: unknown[];\n messages?: unknown[];\n}\n\n// Common types used in events\nexport interface JID {\n User: string;\n Agent: number;\n Device: number;\n Integrator: number;\n Server: string;\n AD: boolean;\n}\n\nexport interface MessageInfo {\n ID: string;\n Type: string;\n PushName: string;\n Timestamp: Date;\n Source: MessageSource;\n DeviceSentMeta?: DeviceSentMeta;\n ServerID?: number;\n Status?: MessageStatus;\n}\n\nexport interface MessageSource {\n Chat: JID;\n Sender: JID;\n IsFromMe: boolean;\n IsGroup: boolean;\n BroadcastListOwner?: JID;\n}\n\nexport interface DeviceSentMeta {\n DestinationJID: string;\n Phash: string;\n}\n\nexport enum MessageStatus {\n ERROR = \"ERROR\",\n PENDING = \"PENDING\",\n SERVER_ACK = \"SERVER_ACK\",\n DELIVERY_ACK = \"DELIVERY_ACK\",\n READ = \"READ\",\n PLAYED = \"PLAYED\",\n}\n\nexport enum ReceiptType {\n UNKNOWN = \"\",\n DELIVERY = \"delivery\",\n READ = \"read\",\n READ_SELF = \"read-self\",\n PLAYED = \"played\",\n SENDER = \"sender\",\n INACTIVE = \"inactive\",\n PEER_MSG = \"peer_msg\",\n}\n\nexport enum DecryptFailMode {\n UNAVAILABLE = \"unavailable\",\n DECRYPT_FAIL = \"decrypt_fail\",\n}\n\nexport enum UnavailableType {\n UNKNOWN = \"\",\n VIEW_ONCE = \"view_once\",\n}\n\nexport enum ConnectFailureReason {\n SOCKET_OPEN_TIMEOUT = 4001,\n SOCKET_PING_TIMEOUT = 4002,\n SOCKET_PONG_TIMEOUT = 4003,\n UNKNOWN_LOGOUT = 4004,\n BAD_MAC = 4005,\n INIT_TIMEOUT = 4006,\n MULTI_DEVICE_MISMATCH = 4007,\n MULTI_DEVICE_DISABLED = 4008,\n TEMP_BANNED = 4009,\n CLIENT_OUTDATED = 4010,\n STREAM_ERROR = 4011,\n DEVICE_GONE = 4012,\n IDENTITY_MISSING = 4013,\n RATE_LIMIT_HIT = 4014,\n MAIN_DEVICE_GONE = 4015,\n}\n\nexport enum TempBanReason {\n SENT_TO_TOO_MANY_PEOPLE = 101,\n BLOCKED_BY_USERS = 102,\n CREATED_TOO_MANY_GROUPS = 103,\n SENT_TOO_MANY_SAME_MESSAGE = 104,\n BROADCAST_LIST = 106,\n}\n\n// Event types\nexport interface AppState {\n name: string;\n version: number;\n hash: string[];\n}\n\nexport interface AppStateSyncComplete {\n name: string;\n}\n\nexport interface Archive {\n JID: JID;\n Timestamp: Date;\n Action: ArchiveAction;\n FromFullSync: boolean;\n}\n\nexport interface Blocklist {\n JID: JID;\n action: string;\n dhash: string;\n}\n\nexport interface BlocklistAction {\n action: string;\n}\n\nexport interface BlocklistChange {\n JID: JID;\n action: BlocklistChangeAction;\n}\n\nexport interface BlocklistChangeAction {\n action: string;\n}\n\nexport interface BusinessName {\n BusinessJID: JID;\n PushName: string;\n VerifiedName: string;\n VerifiedLevel: string;\n Action: BusinessNameAction;\n FromFullSync: boolean;\n}\n\nexport interface CATRefreshError {\n code: string;\n text: string;\n}\n\nexport interface CallAccept {\n BasicCallMeta: BasicCallMeta;\n}\n\nexport interface CallOffer {\n BasicCallMeta: BasicCallMeta;\n CallRemoteMeta: CallRemoteMeta;\n Data: string;\n}\n\nexport interface CallOfferNotice {\n BasicCallMeta: BasicCallMeta;\n Media: string;\n Type: string;\n Data: string;\n}\n\nexport interface CallPreAccept {\n BasicCallMeta: BasicCallMeta;\n CallRemoteMeta: CallRemoteMeta;\n}\n\nexport interface CallReject {\n BasicCallMeta: BasicCallMeta;\n}\n\nexport interface CallRelayLatency {\n BasicCallMeta: BasicCallMeta;\n Latency: number;\n}\n\nexport interface CallTerminate {\n BasicCallMeta: BasicCallMeta;\n Reason: string;\n}\n\nexport interface CallTransport {\n BasicCallMeta: BasicCallMeta;\n}\n\nexport interface ChatPresence {\n MessageSource: MessageSource;\n State: string;\n Media: string;\n}\n\nexport interface ClearChat {\n ChatJID: JID;\n Timestamp: Date;\n Action: ClearChatAction;\n FromFullSync: boolean;\n}\n\nexport interface ClientOutdated {\n // Event indicating the client version is outdated\n}\n\nexport interface ConnectFailure {\n Reason: ConnectFailureReason;\n Raw: WaBinaryNode;\n}\n\nexport interface Connected {\n // Event indicating successful connection\n}\n\nexport interface EventContact {\n JID: JID;\n Found: boolean;\n FirstName: string;\n FullName: string;\n PushName: string;\n BusinessName: string;\n}\n\nexport interface DeleteChat {\n ChatJID: JID;\n Timestamp: Date;\n Action: DeleteChatAction;\n FromFullSync: boolean;\n}\n\nexport interface DeleteForMe {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n Timestamp: Date;\n Action: DeleteMessageForMeAction;\n FromFullSync: boolean;\n}\n\nexport interface Disconnected {\n // Event indicating disconnection\n}\n\nexport interface FBMessage {\n Info: MessageInfo;\n IsEphemeral: boolean;\n IsViewOnce: boolean;\n IsDocumentWithCaption: boolean;\n IsEdit: boolean;\n Message: Armadillo;\n}\n\nexport interface EventGroupInfo {\n JID: JID;\n GroupName: string;\n GroupTopic: string;\n GroupLocked: boolean;\n GroupAnnounce: boolean;\n GroupEphemeral: boolean;\n GroupParent?: JID;\n GroupLinkedParent?: JID;\n GroupIsDefaultSub: boolean;\n GroupCreated: Date;\n ParticipantVersionID: string;\n Participants: EventGroupParticipant[];\n PendingParticipants: EventGroupParticipant[];\n JoinedAt: Date;\n CreateKey: string;\n Sender: JID;\n Timestamp: Date;\n}\n\nexport interface HistorySync {\n Data: HistorySyncData;\n}\n\nexport interface IdentityChange {\n JID: JID;\n Timestamp: Date;\n Implicit: boolean;\n}\n\nexport interface JoinedGroup {\n Reason: string;\n Type: string;\n CreateKey: string;\n Participants: EventGroupParticipant[];\n}\n\nexport interface KeepAliveRestored {\n // Event indicating keep-alive connection restored\n}\n\nexport interface KeepAliveTimeout {\n // Event indicating keep-alive timeout\n}\n\nexport interface LabelAssociationChat {\n ChatJID: JID;\n LabelID: string;\n Labeled: boolean;\n Timestamp: Date;\n Action: LabelAssociationAction;\n FromFullSync: boolean;\n}\n\nexport interface LabelAssociationMessage {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n LabelID: string;\n Labeled: boolean;\n Timestamp: Date;\n Action: LabelAssociationAction;\n FromFullSync: boolean;\n}\n\nexport interface LabelEdit {\n ID: string;\n Name: string;\n Color: number;\n Deleted: boolean;\n Timestamp: Date;\n Action: LabelEditAction;\n FromFullSync: boolean;\n}\n\nexport interface LoggedOut {\n OnConnect: boolean;\n Reason: string;\n}\n\nexport interface ManualLoginReconnect {\n // Event indicating manual login reconnection required\n}\n\nexport interface MarkChatAsRead {\n ChatJID: JID;\n Timestamp: Date;\n Action: MarkChatAsReadAction;\n FromFullSync: boolean;\n}\n\nexport interface MediaRetry {\n MessageID: string;\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n Timestamp: Date;\n}\n\nexport interface MediaRetryError {\n MessageID: string;\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n Timestamp: Date;\n Error: string;\n}\n\nexport interface MessageEvent {\n Info: MessageInfo;\n Message: Message;\n IsEphemeral: boolean;\n IsViewOnce: boolean;\n IsDocumentWithCaption: boolean;\n IsEdit: boolean;\n RawMessage: WaBinaryNode;\n}\n\nexport interface Mute {\n ChatJID: JID;\n Timestamp: Date;\n Action: MuteAction;\n FromFullSync: boolean;\n}\n\nexport interface NewsletterJoin {\n ID: JID;\n NewsletterMeta: {\n name: string;\n description?: string;\n invite?: string;\n creationTime?: Date;\n };\n}\n\nexport interface NewsletterLeave {\n ID: JID;\n}\n\nexport interface NewsletterLiveUpdate {\n ID: JID;\n Time: Date;\n Messages: unknown[];\n}\n\nexport interface NewsletterMessageMeta {\n ID: JID;\n MessageServerID: number;\n MessageID: string;\n ReactionCounts: Record<string, number>;\n Views: number;\n}\n\nexport interface NewsletterMuteChange {\n ID: JID;\n Mute: string;\n}\n\nexport interface OfflineSyncCompleted {\n Count: number;\n}\n\nexport interface OfflineSyncPreview {\n Messages: unknown[];\n IsLatest: boolean;\n}\n\nexport interface PairError {\n ID: string;\n Error: string;\n}\n\nexport interface PairSuccess {\n ID: string;\n BusinessName: string;\n Platform: string;\n}\n\nexport interface PermanentDisconnect {\n // Event indicating permanent disconnection\n}\n\nexport interface Picture {\n JID: JID;\n Author: JID;\n Timestamp: Date;\n Remove: boolean;\n NewPicture?: {\n id: string;\n type: string;\n directPath: string;\n };\n OldPicture?: {\n id: string;\n type: string;\n directPath: string;\n };\n}\n\nexport interface Pin {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n Timestamp: Date;\n Action: PinAction;\n FromFullSync: boolean;\n}\n\nexport interface Presence {\n From: JID;\n Unavailable: boolean;\n LastSeen: Date;\n}\n\nexport interface PrivacySettings {\n GroupAddChanged: boolean;\n LastSeenChanged: boolean;\n StatusChanged: boolean;\n ProfileChanged: boolean;\n ReadReceiptsChanged: boolean;\n OnlineChanged: boolean;\n CallAddChanged: boolean;\n}\n\nexport interface PushName {\n JID: JID;\n Message: MessageInfo;\n OldPushName: string;\n NewPushName: string;\n}\n\nexport interface PushNameSetting {\n Timestamp: Date;\n Action: PushNameSettingAction;\n FromFullSync: boolean;\n}\n\nexport interface QR {\n Codes: string[];\n}\n\nexport interface QRScannedWithoutMultidevice {\n // Event indicating QR was scanned but multidevice not enabled\n}\n\nexport interface Receipt {\n MessageSource: MessageSource;\n MessageIDs: string[];\n Timestamp: Date;\n Type: ReceiptType;\n MessageSender: JID;\n}\n\nexport interface Star {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n Timestamp: Date;\n Action: StarAction;\n FromFullSync: boolean;\n}\n\nexport interface StreamError {\n Code: string;\n Raw: WaBinaryNode;\n}\n\nexport interface StreamReplaced {\n // Event indicating stream was replaced by another connection\n}\n\nexport interface TemporaryBan {\n Code: TempBanReason;\n Expire: number; // Duration in seconds\n}\n\nexport interface UnarchiveChatsSetting {\n Timestamp: Date;\n Action: UnarchiveChatsSettingAction;\n FromFullSync: boolean;\n}\n\nexport interface UndecryptableMessage {\n Info: MessageInfo;\n IsUnavailable: boolean;\n UnavailableType: UnavailableType;\n DecryptFailMode: DecryptFailMode;\n}\n\nexport interface UnknownCallEvent {\n Node: WaBinaryNode;\n}\n\nexport interface UserAbout {\n JID: JID;\n Status: string;\n Timestamp: Date;\n}\n\nexport interface UserStatusMute {\n JID: JID;\n Timestamp: Date;\n Action: UserStatusMuteAction;\n FromFullSync: boolean;\n}\n\n// Union type for all possible events\nexport type WhatsAppEvent =\n | AppState\n | AppStateSyncComplete\n | Archive\n | Blocklist\n | BlocklistAction\n | BlocklistChange\n | BusinessName\n | CATRefreshError\n | CallAccept\n | CallOffer\n | CallOfferNotice\n | CallPreAccept\n | CallReject\n | CallRelayLatency\n | CallTerminate\n | CallTransport\n | ChatPresence\n | ClearChat\n | ClientOutdated\n | ConnectFailure\n | Connected\n | EventContact\n | DeleteChat\n | DeleteForMe\n | Disconnected\n | FBMessage\n | EventGroupInfo\n | HistorySync\n | IdentityChange\n | JoinedGroup\n | KeepAliveRestored\n | KeepAliveTimeout\n | LabelAssociationChat\n | LabelAssociationMessage\n | LabelEdit\n | LoggedOut\n | ManualLoginReconnect\n | MarkChatAsRead\n | MediaRetry\n | MediaRetryError\n | MessageEvent\n | Mute\n | NewsletterJoin\n | NewsletterLeave\n | NewsletterLiveUpdate\n | NewsletterMessageMeta\n | NewsletterMuteChange\n | OfflineSyncCompleted\n | OfflineSyncPreview\n | PairError\n | PairSuccess\n | PermanentDisconnect\n | Picture\n | Pin\n | Presence\n | PrivacySettings\n | PushName\n | PushNameSetting\n | QR\n | QRScannedWithoutMultidevice\n | Receipt\n | Star\n | StreamError\n | StreamReplaced\n | TemporaryBan\n | UnarchiveChatsSetting\n | UndecryptableMessage\n | UnknownCallEvent\n | UserAbout\n | UserStatusMute;\n\n// Event handler type\nexport type EventHandler<T extends WhatsAppEvent = WhatsAppEvent> = (\n event: T\n) => void | Promise<void>;\n\n// Event emitter interface\nexport interface EventEmitter {\n on<T extends WhatsAppEvent>(\n eventType: string,\n handler: EventHandler<T>\n ): void;\n off<T extends WhatsAppEvent>(\n eventType: string,\n handler: EventHandler<T>\n ): void;\n emit<T extends WhatsAppEvent>(eventType: string, event: T): void;\n}\n"],"names":["DisappearingModeInitiator","DisappearingModeTrigger","MediaType","VideoAttribution","VideoSourceType","ExtendedTextMessageFontType","ExtendedTextMessagePreviewType","ExtendedTextMessageInviteLinkGroupType","InviteLinkGroupType","ButtonType","ButtonsMessageHeaderType","ListMessageListType","ButtonsResponseMessageType","ListResponseMessageListType","PaymentBackgroundType","ProtocolMessageType","BotPluginType","BotPluginSearchProvider","HistorySyncNotificationHistorySyncType","PeerDataOperationRequestType","PeerDataOperationRequestResponseMessagePeerDataOperationResult","EventType","MessageStatus","ReceiptType","DecryptFailMode","UnavailableType","ConnectFailureReason","TempBanReason"],"mappings":";;AAqFO,SAAS,WACd,SAC2D;AAE3D,SAAO,CAAC,CAAE,QAAgB;AAC5B;AAEO,SAAS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types/message.ts","../../src/types/events.ts"],"sourcesContent":["// WhatsApp Message types based on whatsmeow protobuf definitions\n// Reference: https://pkg.go.dev/go.mau.fi/whatsmeow@v0.0.0-20250829123043-72d2ed58e998/proto/waE2E#Message\n\n// Base message context and metadata types\nexport interface ContextInfo {\n stanzaId?: string;\n participant?: string;\n quotedMessage?: Message;\n remoteJid?: string;\n mentionedJid?: string[];\n conversionSource?: string;\n conversionData?: string;\n conversionDelaySeconds?: number;\n forwardingScore?: number;\n isForwarded?: boolean;\n quotedAd?: AdReplyInfo;\n placeholderKey?: MessageKey;\n expiration?: number;\n ephemeralSettingTimestamp?: number;\n ephemeralSharedSecret?: string;\n externalAdReply?: ExternalAdReplyInfo;\n entryPointConversionSource?: string;\n entryPointConversionApp?: string;\n entryPointConversionDelaySeconds?: number;\n disappearingMode?: DisappearingMode;\n actionLink?: ActionLink;\n groupSubject?: string;\n parentGroupJid?: string;\n trustBannerType?: string;\n trustBannerAction?: number;\n isSampled?: boolean;\n utm?: UTMInfo;\n}\n\nexport interface MessageKey {\n remoteJid?: string;\n fromMe?: boolean;\n id?: string;\n participant?: string;\n}\n\nexport interface DisappearingMode {\n initiator?: DisappearingModeInitiator;\n trigger?: DisappearingModeTrigger;\n initiatorDeviceJid?: string;\n}\n\nexport enum DisappearingModeInitiator {\n CHANGED_IN_CHAT = 0,\n INITIATED_BY_ME = 1,\n INITIATED_BY_OTHER = 2,\n}\n\nexport enum DisappearingModeTrigger {\n UNKNOWN = 0,\n CHAT_SETTING = 1,\n ACCOUNT_SETTING = 2,\n BULK_CHANGE = 3,\n}\n\nexport interface AdReplyInfo {\n advertiserName?: string;\n mediaType?: MediaType;\n jpegThumbnail?: Uint8Array;\n caption?: string;\n}\n\nexport interface ExternalAdReplyInfo {\n title?: string;\n body?: string;\n mediaType?: MediaType;\n thumbnailUrl?: string;\n mediaUrl?: string;\n thumbnail?: Uint8Array;\n sourceType?: string;\n sourceId?: string;\n sourceUrl?: string;\n containsAutoReply?: boolean;\n renderLargerThumbnail?: boolean;\n showAdAttribution?: boolean;\n ctwaClid?: string;\n ref?: string;\n}\n\nexport interface ActionLink {\n url?: string;\n buttonTitle?: string;\n}\n\nexport interface UTMInfo {\n utmSource?: string;\n utmCampaign?: string;\n}\n\nexport enum MediaType {\n UNKNOWN = 0,\n IMAGE = 1,\n VIDEO = 2,\n AUDIO = 3,\n DOCUMENT = 4,\n STICKER = 5,\n}\n\n// Interactive elements\nexport interface InteractiveAnnotation {\n polygonVertices?: Point[];\n location?: Location;\n}\n\nexport interface Point {\n xDeprecated?: number;\n yDeprecated?: number;\n x?: number;\n y?: number;\n}\n\n// Location types\nexport interface LocationMessage {\n degreesLatitude?: number;\n degreesLongitude?: number;\n name?: string;\n address?: string;\n url?: string;\n isLiveLocation?: boolean;\n accuracyInMeters?: number;\n speedInMps?: number;\n degreesClockwiseFromMagneticNorth?: number;\n comment?: string;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n}\n\nexport interface LiveLocationMessage {\n degreesLatitude?: number;\n degreesLongitude?: number;\n accuracyInMeters?: number;\n speedInMps?: number;\n degreesClockwiseFromMagneticNorth?: number;\n caption?: string;\n sequenceNumber?: number;\n timeOffset?: number;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n}\n\nexport interface Location {\n degreesLatitude?: number;\n degreesLongitude?: number;\n name?: string;\n}\n\n// Media message types\nexport interface ImageMessage {\n url?: string;\n mimetype?: string;\n caption?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n height?: number;\n width?: number;\n mediaKey?: Uint8Array;\n fileEncSha256?: Uint8Array;\n interactiveAnnotations?: InteractiveAnnotation[];\n directPath?: string;\n mediaKeyTimestamp?: number;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n firstScanSidecar?: Uint8Array;\n firstScanLength?: number;\n experimentGroupId?: number;\n scansSidecar?: Uint8Array;\n scanLengths?: number[];\n midQualityFileSha256?: Uint8Array;\n midQualityFileEncSha256?: Uint8Array;\n viewOnce?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n staticUrl?: string;\n annotations?: InteractiveAnnotation[];\n originalFileName?: string;\n}\n\nexport interface VideoMessage {\n url?: string;\n mimetype?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n seconds?: number;\n mediaKey?: Uint8Array;\n caption?: string;\n gifPlayback?: boolean;\n height?: number;\n width?: number;\n fileEncSha256?: Uint8Array;\n interactiveAnnotations?: InteractiveAnnotation[];\n directPath?: string;\n mediaKeyTimestamp?: number;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n streamingSidecar?: Uint8Array;\n gifAttribution?: VideoAttribution;\n viewOnce?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n staticUrl?: string;\n annotations?: InteractiveAnnotation[];\n accessibilityLabel?: string;\n processedVideos?: ProcessedVideo[];\n externalShareFullVideoDurationInSeconds?: number;\n motionPhotoPresentationOffsetMS?: number;\n metadataUrl?: string;\n videoSourceType?: VideoSourceType;\n}\n\nexport enum VideoAttribution {\n NONE = 0,\n GIPHY = 1,\n TENOR = 2,\n KLIPY = 3,\n}\n\nexport enum VideoSourceType {\n USER_VIDEO = 0,\n AI_GENERATED = 1,\n}\n\nexport interface ProcessedVideo {\n url?: string;\n fileLength?: number;\n fileSha256?: Uint8Array;\n fileEncSha256?: Uint8Array;\n}\n\nexport interface AudioMessage {\n url?: string;\n mimetype?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n seconds?: number;\n ptt?: boolean;\n mediaKey?: Uint8Array;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n mediaKeyTimestamp?: number;\n contextInfo?: ContextInfo;\n streamingSidecar?: Uint8Array;\n waveform?: Uint8Array;\n backgroundArgb?: number;\n viewOnce?: boolean;\n}\n\nexport interface DocumentMessage {\n url?: string;\n mimetype?: string;\n title?: string;\n fileSha256?: Uint8Array;\n fileLength?: number;\n pageCount?: number;\n mediaKey?: Uint8Array;\n fileName?: string;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n mediaKeyTimestamp?: number;\n contactVcard?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n thumbnailHeight?: number;\n thumbnailWidth?: number;\n caption?: string;\n}\n\nexport interface StickerMessage {\n url?: string;\n fileSha256?: Uint8Array;\n fileEncSha256?: Uint8Array;\n mediaKey?: Uint8Array;\n mimetype?: string;\n height?: number;\n width?: number;\n directPath?: string;\n fileLength?: number;\n mediaKeyTimestamp?: number;\n firstFrameLength?: number;\n firstFrameSidecar?: Uint8Array;\n isAnimated?: boolean;\n pngThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n stickerSentTs?: number;\n isAvatar?: boolean;\n isAiSticker?: boolean;\n isLottie?: boolean;\n}\n\n// Contact message types\nexport interface ContactMessage {\n displayName?: string;\n vcard?: string;\n contextInfo?: ContextInfo;\n}\n\nexport interface ContactsArrayMessage {\n displayName?: string;\n contacts?: ContactMessage[];\n contextInfo?: ContextInfo;\n}\n\n// Text and extended text messages\nexport interface ExtendedTextMessage {\n text?: string;\n matchedText?: string;\n canonicalUrl?: string;\n description?: string;\n title?: string;\n textArgb?: number;\n backgroundArgb?: number;\n font?: ExtendedTextMessageFontType;\n previewType?: ExtendedTextMessagePreviewType;\n jpegThumbnail?: Uint8Array;\n contextInfo?: ContextInfo;\n doNotPlayInline?: boolean;\n thumbnailDirectPath?: string;\n thumbnailSha256?: Uint8Array;\n thumbnailEncSha256?: Uint8Array;\n mediaKey?: Uint8Array;\n mediaKeyTimestamp?: number;\n thumbnailHeight?: number;\n thumbnailWidth?: number;\n inviteLinkGroupType?: ExtendedTextMessageInviteLinkGroupType;\n inviteLinkParentGroupSubject?: string;\n inviteLinkParentGroupThumbnailJpeg?: Uint8Array;\n inviteLinkGroupTypeV2?: InviteLinkGroupType;\n viewOnce?: boolean;\n}\n\nexport enum ExtendedTextMessageFontType {\n SANS_SERIF = 0,\n SERIF = 1,\n NORICAN_REGULAR = 2,\n BRYNDAN_WRITE = 3,\n BEBASNEUE_REGULAR = 4,\n OSWALD_HEAVY = 5,\n}\n\nexport enum ExtendedTextMessagePreviewType {\n NONE = 0,\n VIDEO = 1,\n PLACEHOLDER = 4,\n IMAGE = 5,\n}\n\nexport enum ExtendedTextMessageInviteLinkGroupType {\n DEFAULT = 0,\n PARENT = 1,\n SUB = 2,\n DEFAULT_SUB = 3,\n}\n\nexport enum InviteLinkGroupType {\n DEFAULT = 0,\n PARENT = 1,\n SUB = 2,\n DEFAULT_SUB = 3,\n}\n\n// Interactive messages\nexport interface ButtonsMessage {\n contentText?: string;\n footerText?: string;\n contextInfo?: ContextInfo;\n buttons?: Button[];\n headerType?: ButtonsMessageHeaderType;\n text?: string;\n documentMessage?: DocumentMessage;\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n locationMessage?: LocationMessage;\n}\n\nexport interface Button {\n buttonId?: string;\n buttonText?: ButtonText;\n type?: ButtonType;\n nativeFlowInfo?: NativeFlowInfo;\n}\n\nexport interface ButtonText {\n displayText?: string;\n}\n\nexport enum ButtonType {\n UNKNOWN = 0,\n RESPONSE = 1,\n NATIVE_FLOW = 2,\n}\n\nexport interface NativeFlowInfo {\n name?: string;\n paramsJson?: string;\n}\n\nexport enum ButtonsMessageHeaderType {\n UNKNOWN = 0,\n EMPTY = 1,\n TEXT = 2,\n DOCUMENT = 3,\n IMAGE = 4,\n VIDEO = 5,\n LOCATION = 6,\n}\n\nexport interface ListMessage {\n title?: string;\n description?: string;\n buttonText?: string;\n listType?: ListMessageListType;\n sections?: Section[];\n productListInfo?: ProductListInfo;\n footerText?: string;\n contextInfo?: ContextInfo;\n}\n\nexport interface Section {\n title?: string;\n rows?: Row[];\n}\n\nexport interface Row {\n title?: string;\n description?: string;\n rowId?: string;\n}\n\nexport interface ProductListInfo {\n productSections?: ProductSection[];\n headerImage?: ImageMessage;\n businessOwnerJid?: string;\n}\n\nexport interface ProductSection {\n title?: string;\n products?: ProductListItem[];\n}\n\nexport interface ProductListItem {\n productId?: string;\n}\n\nexport enum ListMessageListType {\n UNKNOWN = 0,\n SINGLE_SELECT = 1,\n PRODUCT_LIST = 2,\n}\n\n// Template and interactive response messages\nexport interface TemplateMessage {\n contextInfo?: ContextInfo;\n hydratedTemplate?: HydratedFourRowTemplate;\n templateId?: string;\n documentMessage?: DocumentMessage;\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n locationMessage?: LocationMessage;\n}\n\nexport interface HydratedFourRowTemplate {\n documentMessage?: DocumentMessage;\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n locationMessage?: LocationMessage;\n title?: string;\n hydratedContentText?: string;\n hydratedFooterText?: string;\n hydratedButtons?: HydratedTemplateButton[];\n templateId?: string;\n mask?: string;\n}\n\nexport interface HydratedTemplateButton {\n index?: number;\n quickReplyButton?: HydratedQuickReplyButton;\n urlButton?: HydratedURLButton;\n callButton?: HydratedCallButton;\n}\n\nexport interface HydratedQuickReplyButton {\n displayText?: string;\n id?: string;\n}\n\nexport interface HydratedURLButton {\n displayText?: string;\n url?: string;\n}\n\nexport interface HydratedCallButton {\n displayText?: string;\n phoneNumber?: string;\n}\n\n// Response messages\nexport interface ButtonsResponseMessage {\n selectedButtonId?: string;\n contextInfo?: ContextInfo;\n type?: ButtonsResponseMessageType;\n selectedDisplayText?: string;\n}\n\nexport enum ButtonsResponseMessageType {\n UNKNOWN = 0,\n DISPLAY_TEXT = 1,\n}\n\nexport interface ListResponseMessage {\n title?: string;\n listType?: ListResponseMessageListType;\n singleSelectReply?: SingleSelectReply;\n contextInfo?: ContextInfo;\n description?: string;\n}\n\nexport interface SingleSelectReply {\n selectedRowId?: string;\n}\n\nexport enum ListResponseMessageListType {\n UNKNOWN = 0,\n SINGLE_SELECT = 1,\n}\n\n// Payment and order messages\nexport interface SendPaymentMessage {\n noteMessage?: Message;\n requestMessageKey?: MessageKey;\n background?: PaymentBackground;\n}\n\nexport interface PaymentBackground {\n id?: string;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n mediaKey?: Uint8Array;\n type?: PaymentBackgroundType;\n mediaKeyTimestamp?: number;\n}\n\nexport enum PaymentBackgroundType {\n UNKNOWN = 0,\n DEFAULT = 1,\n}\n\nexport interface RequestPaymentMessage {\n noteMessage?: Message;\n currencyCodeIso4217?: string;\n amount1000?: number;\n requestFrom?: string;\n expiryTimestamp?: number;\n background?: PaymentBackground;\n}\n\nexport interface DeclinePaymentRequestMessage {\n key?: MessageKey;\n}\n\nexport interface CancelPaymentRequestMessage {\n key?: MessageKey;\n}\n\n// Group invite message\nexport interface GroupInviteMessage {\n groupJid?: string;\n inviteCode?: string;\n inviteExpiration?: number;\n groupName?: string;\n jpegThumbnail?: Uint8Array;\n caption?: string;\n contextInfo?: ContextInfo;\n}\n\n// Poll message\nexport interface PollCreationMessage {\n name?: string;\n options?: PollOption[];\n selectableOptionsCount?: number;\n contextInfo?: ContextInfo;\n}\n\nexport interface PollOption {\n optionName?: string;\n}\n\nexport interface PollUpdateMessage {\n pollCreationMessageKey?: MessageKey;\n vote?: PollEncValue;\n metadata?: PollUpdateMetadata;\n senderTimestampMs?: number;\n}\n\nexport interface PollEncValue {\n encPayload?: Uint8Array;\n encIv?: Uint8Array;\n}\n\nexport interface PollUpdateMetadata {\n // Metadata about the poll update\n}\n\n// Chat and conversation messages\nexport interface Chat {\n displayName?: string;\n id?: string;\n}\n\nexport interface Call {\n callKey?: Uint8Array;\n conversionSource?: string;\n conversionData?: Uint8Array;\n conversionDelaySeconds?: number;\n}\n\n// Main Message union type\nexport interface Message {\n // Text messages\n conversation?: string;\n extendedTextMessage?: ExtendedTextMessage;\n\n // Media messages\n imageMessage?: ImageMessage;\n videoMessage?: VideoMessage;\n audioMessage?: AudioMessage;\n documentMessage?: DocumentMessage;\n stickerMessage?: StickerMessage;\n\n // Location messages\n locationMessage?: LocationMessage;\n liveLocationMessage?: LiveLocationMessage;\n\n // Contact messages\n contactMessage?: ContactMessage;\n contactsArrayMessage?: ContactsArrayMessage;\n\n // Interactive messages\n buttonsMessage?: ButtonsMessage;\n listMessage?: ListMessage;\n templateMessage?: TemplateMessage;\n\n // Response messages\n buttonsResponseMessage?: ButtonsResponseMessage;\n listResponseMessage?: ListResponseMessage;\n\n // Payment messages\n sendPaymentMessage?: SendPaymentMessage;\n requestPaymentMessage?: RequestPaymentMessage;\n declinePaymentRequestMessage?: DeclinePaymentRequestMessage;\n cancelPaymentRequestMessage?: CancelPaymentRequestMessage;\n\n // Group messages\n groupInviteMessage?: GroupInviteMessage;\n\n // Poll messages\n pollCreationMessage?: PollCreationMessage;\n pollUpdateMessage?: PollUpdateMessage;\n\n // System messages\n protocolMessage?: ProtocolMessage;\n ephemeralMessage?: EphemeralMessage;\n viewOnceMessage?: ViewOnceMessage;\n reactionMessage?: ReactionMessage;\n stickerSyncRmrMessage?: StickerSyncRmrMessage;\n\n // Call messages\n call?: Call;\n chat?: Chat;\n\n // MessageContextInfo\n messageContextInfo?: MessageContextInfo;\n}\n\n// System and protocol messages\nexport interface ProtocolMessage {\n key?: MessageKey;\n type?: ProtocolMessageType;\n ephemeralExpiration?: number;\n ephemeralSettingTimestamp?: number;\n historySyncNotification?: HistorySyncNotification;\n appStateSyncKeyShare?: AppStateSyncKeyShare;\n appStateSyncKeyRequest?: AppStateSyncKeyRequest;\n initialSecurityNotificationSettingSync?: InitialSecurityNotificationSettingSync;\n appStateFatalExceptionNotification?: AppStateFatalExceptionNotification;\n disappearingMode?: DisappearingMode;\n editedMessage?: Message;\n timestampMs?: number;\n peerDataOperationRequestMessage?: PeerDataOperationRequestMessage;\n peerDataOperationRequestResponseMessage?: PeerDataOperationRequestResponseMessage;\n}\n\nexport enum ProtocolMessageType {\n REVOKE = 0,\n EPHEMERAL_SETTING = 3,\n EPHEMERAL_SYNC_RESPONSE = 4,\n HISTORY_SYNC_NOTIFICATION = 5,\n APP_STATE_SYNC_KEY_SHARE = 6,\n APP_STATE_SYNC_KEY_REQUEST = 7,\n MSG_FANOUT_BACKFILL_REQUEST = 8,\n INITIAL_SECURITY_NOTIFICATION_SETTING_SYNC = 9,\n APP_STATE_FATAL_EXCEPTION_NOTIFICATION = 10,\n SHARE_PHONE_NUMBER = 11,\n MESSAGE_EDIT = 14,\n PEER_DATA_OPERATION_REQUEST_MESSAGE = 16,\n PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE = 17,\n}\n\nexport interface EphemeralMessage {\n message?: Message;\n}\n\nexport interface ViewOnceMessage {\n message?: Message;\n}\n\nexport interface ReactionMessage {\n key?: MessageKey;\n text?: string;\n groupingKey?: string;\n senderTimestampMs?: number;\n unread?: boolean;\n}\n\nexport interface StickerSyncRmrMessage {\n filehash?: string[];\n rmrSource?: string;\n requestTimestamp?: number;\n}\n\nexport interface MessageContextInfo {\n deviceListMetadata?: DeviceListMetadata;\n deviceListMetadataVersion?: number;\n messageSecret?: Uint8Array;\n paddingBytes?: Uint8Array;\n messageAddOnDurationInSecs?: number;\n botMessageInvoker?: BotMessageInvoker;\n botResponseCorrelationId?: string;\n botPluginType?: BotPluginType;\n botPluginReferenceIndex?: number;\n botPluginSearchProvider?: BotPluginSearchProvider;\n botPluginSearchUrl?: string;\n botPluginMaybeParentPluginType?: BotPluginType;\n botReelPluginThumbnailCdnUrl?: string;\n expiredBotResponseCorrelationId?: string;\n}\n\nexport interface DeviceListMetadata {\n senderKeyHash?: Uint8Array;\n senderTimestamp?: number;\n senderKeyIndexes?: number[];\n recipientKeyHash?: Uint8Array;\n recipientTimestamp?: number;\n recipientKeyIndexes?: number[];\n}\n\nexport interface BotMessageInvoker {\n // Bot message invoker details\n}\n\nexport enum BotPluginType {\n REELS = 0,\n SEARCH = 1,\n}\n\nexport enum BotPluginSearchProvider {\n BING = 0,\n GOOGLE = 1,\n}\n\n// Additional system notification types\nexport interface HistorySyncNotification {\n fileSha256?: Uint8Array;\n fileLength?: number;\n mediaKey?: Uint8Array;\n fileEncSha256?: Uint8Array;\n directPath?: string;\n syncType?: HistorySyncNotificationHistorySyncType;\n chunkOrder?: number;\n originalMessageId?: string;\n progress?: number;\n oldestMsgInChunkTimestampSec?: number;\n initialHistBootstrapInlinePayload?: Uint8Array;\n peerDataRequestSessionId?: string;\n}\n\nexport enum HistorySyncNotificationHistorySyncType {\n INITIAL_BOOTSTRAP = 0,\n INITIAL_STATUS_V3 = 1,\n FULL = 2,\n RECENT = 3,\n PUSH_NAME = 4,\n NON_BLOCKING_DATA = 5,\n ON_DEMAND = 6,\n}\n\nexport interface AppStateSyncKeyShare {\n keys?: AppStateSyncKey[];\n}\n\nexport interface AppStateSyncKey {\n keyId?: AppStateSyncKeyId;\n keyData?: AppStateSyncKeyData;\n}\n\nexport interface AppStateSyncKeyId {\n keyId?: Uint8Array;\n}\n\nexport interface AppStateSyncKeyData {\n keyData?: Uint8Array;\n fingerprint?: AppStateSyncKeyFingerprint;\n timestamp?: number;\n}\n\nexport interface AppStateSyncKeyFingerprint {\n rawId?: number;\n currentIndex?: number;\n deviceIndexes?: number[];\n}\n\nexport interface AppStateSyncKeyRequest {\n keyIds?: AppStateSyncKeyId[];\n}\n\nexport interface InitialSecurityNotificationSettingSync {\n securityNotificationEnabled?: boolean;\n}\n\nexport interface AppStateFatalExceptionNotification {\n collectionNames?: string[];\n timestamp?: number;\n}\n\nexport interface PeerDataOperationRequestMessage {\n peerDataOperationRequestType?: PeerDataOperationRequestType;\n requestId?: string;\n}\n\nexport interface PeerDataOperationRequestResponseMessage {\n peerDataOperationResult?: PeerDataOperationRequestResponseMessagePeerDataOperationResult;\n stanzaId?: string;\n}\n\nexport enum PeerDataOperationRequestType {\n UPLOAD_STICKER = 0,\n SEND_RECENT_STICKER_BOOTSTRAP = 1,\n GENERATE_LINK_PREVIEW = 2,\n}\n\nexport enum PeerDataOperationRequestResponseMessagePeerDataOperationResult {\n SUCCESS = 0,\n NOT_AUTHORIZED = 1,\n NOT_FOUND = 2,\n THROTTLED = 3,\n UNKNOWN_ERROR = 4,\n}\n\n// Helper type to get the active message type\nexport type MessageContent =\n | { type: \"text\"; content: string }\n | { type: \"extendedText\"; content: ExtendedTextMessage }\n | { type: \"image\"; content: ImageMessage }\n | { type: \"video\"; content: VideoMessage }\n | { type: \"audio\"; content: AudioMessage }\n | { type: \"document\"; content: DocumentMessage }\n | { type: \"sticker\"; content: StickerMessage }\n | { type: \"location\"; content: LocationMessage }\n | { type: \"liveLocation\"; content: LiveLocationMessage }\n | { type: \"contact\"; content: ContactMessage }\n | { type: \"contactsArray\"; content: ContactsArrayMessage }\n | { type: \"buttons\"; content: ButtonsMessage }\n | { type: \"list\"; content: ListMessage }\n | { type: \"template\"; content: TemplateMessage }\n | { type: \"buttonsResponse\"; content: ButtonsResponseMessage }\n | { type: \"listResponse\"; content: ListResponseMessage }\n | { type: \"groupInvite\"; content: GroupInviteMessage }\n | { type: \"poll\"; content: PollCreationMessage }\n | { type: \"pollUpdate\"; content: PollUpdateMessage }\n | { type: \"reaction\"; content: ReactionMessage }\n | { type: \"protocol\"; content: ProtocolMessage }\n | { type: \"ephemeral\"; content: EphemeralMessage }\n | { type: \"viewOnce\"; content: ViewOnceMessage };\n\n// Utility function to extract message content and type\nexport function getMessageContent(message: Message): MessageContent | null {\n if (message.conversation) {\n return { type: \"text\", content: message.conversation };\n }\n if (message.extendedTextMessage) {\n return { type: \"extendedText\", content: message.extendedTextMessage };\n }\n if (message.imageMessage) {\n return { type: \"image\", content: message.imageMessage };\n }\n if (message.videoMessage) {\n return { type: \"video\", content: message.videoMessage };\n }\n if (message.audioMessage) {\n return { type: \"audio\", content: message.audioMessage };\n }\n if (message.documentMessage) {\n return { type: \"document\", content: message.documentMessage };\n }\n if (message.stickerMessage) {\n return { type: \"sticker\", content: message.stickerMessage };\n }\n if (message.locationMessage) {\n return { type: \"location\", content: message.locationMessage };\n }\n if (message.liveLocationMessage) {\n return { type: \"liveLocation\", content: message.liveLocationMessage };\n }\n if (message.contactMessage) {\n return { type: \"contact\", content: message.contactMessage };\n }\n if (message.contactsArrayMessage) {\n return { type: \"contactsArray\", content: message.contactsArrayMessage };\n }\n if (message.buttonsMessage) {\n return { type: \"buttons\", content: message.buttonsMessage };\n }\n if (message.listMessage) {\n return { type: \"list\", content: message.listMessage };\n }\n if (message.templateMessage) {\n return { type: \"template\", content: message.templateMessage };\n }\n if (message.buttonsResponseMessage) {\n return { type: \"buttonsResponse\", content: message.buttonsResponseMessage };\n }\n if (message.listResponseMessage) {\n return { type: \"listResponse\", content: message.listResponseMessage };\n }\n if (message.groupInviteMessage) {\n return { type: \"groupInvite\", content: message.groupInviteMessage };\n }\n if (message.pollCreationMessage) {\n return { type: \"poll\", content: message.pollCreationMessage };\n }\n if (message.pollUpdateMessage) {\n return { type: \"pollUpdate\", content: message.pollUpdateMessage };\n }\n if (message.reactionMessage) {\n return { type: \"reaction\", content: message.reactionMessage };\n }\n if (message.protocolMessage) {\n return { type: \"protocol\", content: message.protocolMessage };\n }\n if (message.ephemeralMessage) {\n return { type: \"ephemeral\", content: message.ephemeralMessage };\n }\n if (message.viewOnceMessage) {\n return { type: \"viewOnce\", content: message.viewOnceMessage };\n }\n\n return null;\n}\n","// WhatsApp events types based on whatsmeow package\n// Reference: https://pkg.go.dev/go.mau.fi/whatsmeow@v0.0.0-20250829123043-72d2ed58e998/types/events\n\nimport { Message } from \"./message.js\";\n\n// Event types enum for all possible WhatsApp events\nexport enum EventType {\n // Core message and communication events\n MESSAGE = \"Message\",\n RECEIPT = \"Receipt\",\n PRESENCE = \"Presence\",\n CHAT_PRESENCE = \"ChatPresence\",\n\n // Connection and session events\n CONNECTED = \"Connected\",\n DISCONNECTED = \"Disconnected\",\n LOGGED_OUT = \"LoggedOut\",\n QR = \"QR\",\n QR_SCANNED_WITHOUT_MULTIDEVICE = \"QRScannedWithoutMultidevice\",\n PAIR_SUCCESS = \"PairSuccess\",\n PAIR_ERROR = \"PairError\",\n MANUAL_LOGIN_RECONNECT = \"ManualLoginReconnect\",\n KEEP_ALIVE_RESTORED = \"KeepAliveRestored\",\n KEEP_ALIVE_TIMEOUT = \"KeepAliveTimeout\",\n\n // Group events\n GROUP_INFO = \"GroupInfo\",\n JOINED_GROUP = \"JoinedGroup\",\n\n // Contact and user events\n CONTACT = \"Contact\",\n PUSH_NAME = \"PushName\",\n PUSH_NAME_SETTING = \"PushNameSetting\",\n PICTURE = \"Picture\",\n USER_ABOUT = \"UserAbout\",\n USER_STATUS_MUTE = \"UserStatusMute\",\n PRIVACY_SETTINGS = \"PrivacySettings\",\n\n // App state and sync events\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 IDENTITY_CHANGE = \"IdentityChange\",\n\n // Chat management events\n ARCHIVE = \"Archive\",\n UNARCHIVE_CHATS_SETTING = \"UnarchiveChatsSetting\",\n CLEAR_CHAT = \"ClearChat\",\n DELETE_CHAT = \"DeleteChat\",\n DELETE_FOR_ME = \"DeleteForMe\",\n MARK_CHAT_AS_READ = \"MarkChatAsRead\",\n MUTE = \"Mute\",\n PIN = \"Pin\",\n STAR = \"Star\",\n\n // Label events\n LABEL_ASSOCIATION_CHAT = \"LabelAssociationChat\",\n LABEL_ASSOCIATION_MESSAGE = \"LabelAssociationMessage\",\n LABEL_EDIT = \"LabelEdit\",\n\n // Media events\n MEDIA_RETRY = \"MediaRetry\",\n MEDIA_RETRY_ERROR = \"MediaRetryError\",\n\n // Newsletter events\n NEWSLETTER_JOIN = \"NewsletterJoin\",\n NEWSLETTER_LEAVE = \"NewsletterLeave\",\n NEWSLETTER_LIVE_UPDATE = \"NewsletterLiveUpdate\",\n NEWSLETTER_MESSAGE_META = \"NewsletterMessageMeta\",\n NEWSLETTER_MUTE_CHANGE = \"NewsletterMuteChange\",\n\n // Error and system events\n UNDECRYPTABLE_MESSAGE = \"UndecryptableMessage\",\n STREAM_ERROR = \"StreamError\",\n STREAM_REPLACED = \"StreamReplaced\",\n CONNECT_FAILURE = \"ConnectFailure\",\n CLIENT_OUTDATED = \"ClientOutdated\",\n TEMPORARY_BAN = \"TemporaryBan\",\n CAT_REFRESH_ERROR = \"CATRefreshError\",\n PERMANENT_DISCONNECT = \"PermanentDisconnect\",\n\n // Blocklist events\n BLOCKLIST = \"Blocklist\",\n BLOCKLIST_ACTION = \"BlocklistAction\",\n BLOCKLIST_CHANGE = \"BlocklistChange\",\n\n // Business events\n BUSINESS_NAME = \"BusinessName\",\n\n // Call events\n CALL_ACCEPT = \"CallAccept\",\n CALL_OFFER = \"CallOffer\",\n CALL_OFFER_NOTICE = \"CallOfferNotice\",\n CALL_PRE_ACCEPT = \"CallPreAccept\",\n CALL_REJECT = \"CallReject\",\n CALL_RELAY_LATENCY = \"CallRelayLatency\",\n CALL_TERMINATE = \"CallTerminate\",\n CALL_TRANSPORT = \"CallTransport\",\n UNKNOWN_CALL_EVENT = \"UnknownCallEvent\",\n\n // FB/Meta specific events\n FB_MESSAGE = \"FBMessage\",\n}\n\n// Additional specific types from whatsmeow\nexport interface WaBinaryNode {\n Tag: string;\n Attrs: Record<string, string>;\n Content: unknown;\n}\n\nexport interface SyncAction {\n timestamp: Date;\n action: unknown;\n}\n\nexport interface StarAction extends SyncAction {\n starred: boolean;\n}\n\nexport interface ArchiveAction extends SyncAction {\n archived: boolean;\n}\n\nexport interface ClearChatAction extends SyncAction {\n messageRange?: {\n lastMessageTimestamp?: Date;\n lastSystemMessageTimestamp?: Date;\n };\n}\n\nexport interface DeleteChatAction extends SyncAction {}\n\nexport interface DeleteMessageForMeAction extends SyncAction {}\n\nexport interface MarkChatAsReadAction extends SyncAction {\n read: boolean;\n messageRange?: {\n lastMessageTimestamp?: Date;\n lastSystemMessageTimestamp?: Date;\n };\n}\n\nexport interface MuteAction extends SyncAction {\n muted: boolean;\n muteEndTimestamp?: Date;\n}\n\nexport interface PinAction extends SyncAction {\n pinned: boolean;\n}\n\nexport interface PushNameSettingAction extends SyncAction {\n name: string;\n}\n\nexport interface UnarchiveChatsSettingAction extends SyncAction {\n unarchiveChats: boolean;\n}\n\nexport interface LabelAssociationAction extends SyncAction {\n labeled: boolean;\n}\n\nexport interface LabelEditAction extends SyncAction {\n name: string;\n color: number;\n predefinedId?: string;\n deleted: boolean;\n}\n\nexport interface BusinessNameAction extends SyncAction {\n businessName: string;\n verified: number;\n}\n\nexport interface UserStatusMuteAction extends SyncAction {\n muted: boolean;\n}\n\nexport interface Armadillo {\n payload?: unknown;\n}\n\nexport interface ConsumerApplication {\n metadata?: unknown;\n}\n\nexport interface BasicCallMeta {\n from: JID;\n timestamp: Date;\n callId: string;\n callCreator: JID;\n}\n\nexport interface CallRemoteMeta {\n remoteJid: JID;\n fromMe: boolean;\n}\n\nexport interface EventGroupParticipant {\n JID: JID;\n IsAdmin: boolean;\n IsSuperAdmin: boolean;\n}\n\nexport interface HistorySyncData {\n conversations?: unknown[];\n messages?: unknown[];\n}\n\n// Common types used in events\nexport interface JID {\n User: string;\n Agent: number;\n Device: number;\n Integrator: number;\n Server: string;\n AD: boolean;\n}\n\nexport interface MessageInfo {\n ID: string;\n Type: string;\n PushName: string;\n Timestamp: Date;\n Source: MessageSource;\n DeviceSentMeta?: DeviceSentMeta;\n ServerID?: number;\n Status?: MessageStatus;\n}\n\nexport interface MessageSource {\n Chat: JID;\n Sender: JID;\n IsFromMe: boolean;\n IsGroup: boolean;\n BroadcastListOwner?: JID;\n}\n\nexport interface DeviceSentMeta {\n DestinationJID: string;\n Phash: string;\n}\n\nexport enum MessageStatus {\n ERROR = \"ERROR\",\n PENDING = \"PENDING\",\n SERVER_ACK = \"SERVER_ACK\",\n DELIVERY_ACK = \"DELIVERY_ACK\",\n READ = \"READ\",\n PLAYED = \"PLAYED\",\n}\n\nexport enum ReceiptType {\n UNKNOWN = \"\",\n DELIVERY = \"delivery\",\n READ = \"read\",\n READ_SELF = \"read-self\",\n PLAYED = \"played\",\n SENDER = \"sender\",\n INACTIVE = \"inactive\",\n PEER_MSG = \"peer_msg\",\n}\n\nexport enum DecryptFailMode {\n UNAVAILABLE = \"unavailable\",\n DECRYPT_FAIL = \"decrypt_fail\",\n}\n\nexport enum UnavailableType {\n UNKNOWN = \"\",\n VIEW_ONCE = \"view_once\",\n}\n\nexport enum ConnectFailureReason {\n SOCKET_OPEN_TIMEOUT = 4001,\n SOCKET_PING_TIMEOUT = 4002,\n SOCKET_PONG_TIMEOUT = 4003,\n UNKNOWN_LOGOUT = 4004,\n BAD_MAC = 4005,\n INIT_TIMEOUT = 4006,\n MULTI_DEVICE_MISMATCH = 4007,\n MULTI_DEVICE_DISABLED = 4008,\n TEMP_BANNED = 4009,\n CLIENT_OUTDATED = 4010,\n STREAM_ERROR = 4011,\n DEVICE_GONE = 4012,\n IDENTITY_MISSING = 4013,\n RATE_LIMIT_HIT = 4014,\n MAIN_DEVICE_GONE = 4015,\n}\n\nexport enum TempBanReason {\n SENT_TO_TOO_MANY_PEOPLE = 101,\n BLOCKED_BY_USERS = 102,\n CREATED_TOO_MANY_GROUPS = 103,\n SENT_TOO_MANY_SAME_MESSAGE = 104,\n BROADCAST_LIST = 106,\n}\n\n// Event types\nexport interface AppState {\n name: string;\n version: number;\n hash: string[];\n}\n\nexport interface AppStateSyncComplete {\n name: string;\n}\n\nexport interface Archive {\n JID: JID;\n Timestamp: Date;\n Action: ArchiveAction;\n FromFullSync: boolean;\n}\n\nexport interface Blocklist {\n JID: JID;\n action: string;\n dhash: string;\n}\n\nexport interface BlocklistAction {\n action: string;\n}\n\nexport interface BlocklistChange {\n JID: JID;\n action: BlocklistChangeAction;\n}\n\nexport interface BlocklistChangeAction {\n action: string;\n}\n\nexport interface BusinessName {\n BusinessJID: JID;\n PushName: string;\n VerifiedName: string;\n VerifiedLevel: string;\n Action: BusinessNameAction;\n FromFullSync: boolean;\n}\n\nexport interface CATRefreshError {\n code: string;\n text: string;\n}\n\nexport interface CallAccept {\n BasicCallMeta: BasicCallMeta;\n}\n\nexport interface CallOffer {\n BasicCallMeta: BasicCallMeta;\n CallRemoteMeta: CallRemoteMeta;\n Data: string;\n}\n\nexport interface CallOfferNotice {\n BasicCallMeta: BasicCallMeta;\n Media: string;\n Type: string;\n Data: string;\n}\n\nexport interface CallPreAccept {\n BasicCallMeta: BasicCallMeta;\n CallRemoteMeta: CallRemoteMeta;\n}\n\nexport interface CallReject {\n BasicCallMeta: BasicCallMeta;\n}\n\nexport interface CallRelayLatency {\n BasicCallMeta: BasicCallMeta;\n Latency: number;\n}\n\nexport interface CallTerminate {\n BasicCallMeta: BasicCallMeta;\n Reason: string;\n}\n\nexport interface CallTransport {\n BasicCallMeta: BasicCallMeta;\n}\n\nexport interface ChatPresence {\n MessageSource: MessageSource;\n State: string;\n Media: string;\n}\n\nexport interface ClearChat {\n ChatJID: JID;\n Timestamp: Date;\n Action: ClearChatAction;\n FromFullSync: boolean;\n}\n\nexport interface ClientOutdated {\n // Event indicating the client version is outdated\n}\n\nexport interface ConnectFailure {\n Reason: ConnectFailureReason;\n Raw: WaBinaryNode;\n}\n\nexport interface Connected {\n // Event indicating successful connection\n}\n\nexport interface EventContact {\n JID: JID;\n Found: boolean;\n FirstName: string;\n FullName: string;\n PushName: string;\n BusinessName: string;\n}\n\nexport interface DeleteChat {\n ChatJID: JID;\n Timestamp: Date;\n Action: DeleteChatAction;\n FromFullSync: boolean;\n}\n\nexport interface DeleteForMe {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n Timestamp: Date;\n Action: DeleteMessageForMeAction;\n FromFullSync: boolean;\n}\n\nexport interface Disconnected {\n // Event indicating disconnection\n}\n\nexport interface FBMessage {\n Info: MessageInfo;\n IsEphemeral: boolean;\n IsViewOnce: boolean;\n IsDocumentWithCaption: boolean;\n IsEdit: boolean;\n Message: Armadillo;\n}\n\nexport interface EventGroupInfo {\n JID: JID;\n GroupName: string;\n GroupTopic: string;\n GroupLocked: boolean;\n GroupAnnounce: boolean;\n GroupEphemeral: boolean;\n GroupParent?: JID;\n GroupLinkedParent?: JID;\n GroupIsDefaultSub: boolean;\n GroupCreated: Date;\n ParticipantVersionID: string;\n Participants: EventGroupParticipant[];\n PendingParticipants: EventGroupParticipant[];\n JoinedAt: Date;\n CreateKey: string;\n Sender: JID;\n Timestamp: Date;\n}\n\nexport interface HistorySync {\n Data: HistorySyncData;\n}\n\nexport interface IdentityChange {\n JID: JID;\n Timestamp: Date;\n Implicit: boolean;\n}\n\nexport interface JoinedGroup {\n Reason: string;\n Type: string;\n CreateKey: string;\n Participants: EventGroupParticipant[];\n}\n\nexport interface KeepAliveRestored {\n // Event indicating keep-alive connection restored\n}\n\nexport interface KeepAliveTimeout {\n // Event indicating keep-alive timeout\n}\n\nexport interface LabelAssociationChat {\n ChatJID: JID;\n LabelID: string;\n Labeled: boolean;\n Timestamp: Date;\n Action: LabelAssociationAction;\n FromFullSync: boolean;\n}\n\nexport interface LabelAssociationMessage {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n LabelID: string;\n Labeled: boolean;\n Timestamp: Date;\n Action: LabelAssociationAction;\n FromFullSync: boolean;\n}\n\nexport interface LabelEdit {\n ID: string;\n Name: string;\n Color: number;\n Deleted: boolean;\n Timestamp: Date;\n Action: LabelEditAction;\n FromFullSync: boolean;\n}\n\nexport interface LoggedOut {\n OnConnect: boolean;\n Reason: string;\n}\n\nexport interface ManualLoginReconnect {\n // Event indicating manual login reconnection required\n}\n\nexport interface MarkChatAsRead {\n ChatJID: JID;\n Timestamp: Date;\n Action: MarkChatAsReadAction;\n FromFullSync: boolean;\n}\n\nexport interface MediaRetry {\n MessageID: string;\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n Timestamp: Date;\n}\n\nexport interface MediaRetryError {\n MessageID: string;\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n Timestamp: Date;\n Error: string;\n}\n\nexport interface MessageEvent {\n Info: MessageInfo;\n Message: Message;\n IsEphemeral: boolean;\n IsViewOnce: boolean;\n IsDocumentWithCaption: boolean;\n IsEdit: boolean;\n RawMessage: WaBinaryNode;\n}\n\nexport interface Mute {\n ChatJID: JID;\n Timestamp: Date;\n Action: MuteAction;\n FromFullSync: boolean;\n}\n\nexport interface NewsletterJoin {\n ID: JID;\n NewsletterMeta: {\n name: string;\n description?: string;\n invite?: string;\n creationTime?: Date;\n };\n}\n\nexport interface NewsletterLeave {\n ID: JID;\n}\n\nexport interface NewsletterLiveUpdate {\n ID: JID;\n Time: Date;\n Messages: unknown[];\n}\n\nexport interface NewsletterMessageMeta {\n ID: JID;\n MessageServerID: number;\n MessageID: string;\n ReactionCounts: Record<string, number>;\n Views: number;\n}\n\nexport interface NewsletterMuteChange {\n ID: JID;\n Mute: string;\n}\n\nexport interface OfflineSyncCompleted {\n Count: number;\n}\n\nexport interface OfflineSyncPreview {\n Messages: unknown[];\n IsLatest: boolean;\n}\n\nexport interface PairError {\n ID: string;\n Error: string;\n}\n\nexport interface PairSuccess {\n ID: string;\n BusinessName: string;\n Platform: string;\n}\n\nexport interface PermanentDisconnect {\n // Event indicating permanent disconnection\n}\n\nexport interface Picture {\n JID: JID;\n Author: JID;\n Timestamp: Date;\n Remove: boolean;\n NewPicture?: {\n id: string;\n type: string;\n directPath: string;\n };\n OldPicture?: {\n id: string;\n type: string;\n directPath: string;\n };\n}\n\nexport interface Pin {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n Timestamp: Date;\n Action: PinAction;\n FromFullSync: boolean;\n}\n\nexport interface Presence {\n From: JID;\n Unavailable: boolean;\n LastSeen: Date;\n}\n\nexport interface PrivacySettings {\n GroupAddChanged: boolean;\n LastSeenChanged: boolean;\n StatusChanged: boolean;\n ProfileChanged: boolean;\n ReadReceiptsChanged: boolean;\n OnlineChanged: boolean;\n CallAddChanged: boolean;\n}\n\nexport interface PushName {\n JID: JID;\n Message: MessageInfo;\n OldPushName: string;\n NewPushName: string;\n}\n\nexport interface PushNameSetting {\n Timestamp: Date;\n Action: PushNameSettingAction;\n FromFullSync: boolean;\n}\n\nexport interface QR {\n Codes: string[];\n}\n\nexport interface QRScannedWithoutMultidevice {\n // Event indicating QR was scanned but multidevice not enabled\n}\n\nexport interface Receipt {\n MessageSource: MessageSource;\n MessageIDs: string[];\n Timestamp: Date;\n Type: ReceiptType;\n MessageSender: JID;\n}\n\nexport interface Star {\n ChatJID: JID;\n SenderJID: JID;\n IsFromMe: boolean;\n MessageID: string;\n Timestamp: Date;\n Action: StarAction;\n FromFullSync: boolean;\n}\n\nexport interface StreamError {\n Code: string;\n Raw: WaBinaryNode;\n}\n\nexport interface StreamReplaced {\n // Event indicating stream was replaced by another connection\n}\n\nexport interface TemporaryBan {\n Code: TempBanReason;\n Expire: number; // Duration in seconds\n}\n\nexport interface UnarchiveChatsSetting {\n Timestamp: Date;\n Action: UnarchiveChatsSettingAction;\n FromFullSync: boolean;\n}\n\nexport interface UndecryptableMessage {\n Info: MessageInfo;\n IsUnavailable: boolean;\n UnavailableType: UnavailableType;\n DecryptFailMode: DecryptFailMode;\n}\n\nexport interface UnknownCallEvent {\n Node: WaBinaryNode;\n}\n\nexport interface UserAbout {\n JID: JID;\n Status: string;\n Timestamp: Date;\n}\n\nexport interface UserStatusMute {\n JID: JID;\n Timestamp: Date;\n Action: UserStatusMuteAction;\n FromFullSync: boolean;\n}\n\n// Union type for all possible events\nexport type WhatsAppEvent =\n | AppState\n | AppStateSyncComplete\n | Archive\n | Blocklist\n | BlocklistAction\n | BlocklistChange\n | BusinessName\n | CATRefreshError\n | CallAccept\n | CallOffer\n | CallOfferNotice\n | CallPreAccept\n | CallReject\n | CallRelayLatency\n | CallTerminate\n | CallTransport\n | ChatPresence\n | ClearChat\n | ClientOutdated\n | ConnectFailure\n | Connected\n | EventContact\n | DeleteChat\n | DeleteForMe\n | Disconnected\n | FBMessage\n | EventGroupInfo\n | HistorySync\n | IdentityChange\n | JoinedGroup\n | KeepAliveRestored\n | KeepAliveTimeout\n | LabelAssociationChat\n | LabelAssociationMessage\n | LabelEdit\n | LoggedOut\n | ManualLoginReconnect\n | MarkChatAsRead\n | MediaRetry\n | MediaRetryError\n | MessageEvent\n | Mute\n | NewsletterJoin\n | NewsletterLeave\n | NewsletterLiveUpdate\n | NewsletterMessageMeta\n | NewsletterMuteChange\n | OfflineSyncCompleted\n | OfflineSyncPreview\n | PairError\n | PairSuccess\n | PermanentDisconnect\n | Picture\n | Pin\n | Presence\n | PrivacySettings\n | PushName\n | PushNameSetting\n | QR\n | QRScannedWithoutMultidevice\n | Receipt\n | Star\n | StreamError\n | StreamReplaced\n | TemporaryBan\n | UnarchiveChatsSetting\n | UndecryptableMessage\n | UnknownCallEvent\n | UserAbout\n | UserStatusMute;\n\n// Event handler type\nexport type EventHandler<T extends WhatsAppEvent = WhatsAppEvent> = (\n event: T\n) => void | Promise<void>;\n\n// Event emitter interface\nexport interface EventEmitter {\n on<T extends WhatsAppEvent>(\n eventType: string,\n handler: EventHandler<T>\n ): void;\n off<T extends WhatsAppEvent>(\n eventType: string,\n handler: EventHandler<T>\n ): void;\n emit<T extends WhatsAppEvent>(eventType: string, event: T): void;\n}\n"],"names":["DisappearingModeInitiator","DisappearingModeTrigger","MediaType","VideoAttribution","VideoSourceType","ExtendedTextMessageFontType","ExtendedTextMessagePreviewType","ExtendedTextMessageInviteLinkGroupType","InviteLinkGroupType","ButtonType","ButtonsMessageHeaderType","ListMessageListType","ButtonsResponseMessageType","ListResponseMessageListType","PaymentBackgroundType","ProtocolMessageType","BotPluginType","BotPluginSearchProvider","HistorySyncNotificationHistorySyncType","PeerDataOperationRequestType","PeerDataOperationRequestResponseMessagePeerDataOperationResult","EventType","MessageStatus","ReceiptType","DecryptFailMode","UnavailableType","ConnectFailureReason","TempBanReason"],"mappings":";;;AA+CO,IAAK,8CA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T = "Receipt",
|
|
5
|
+
MEDIA_RETRY = "MediaRetry",
|
|
6
|
+
GROUP_INFO = "GroupInfo",
|
|
7
|
+
JOINED_GROUP = "JoinedGroup",
|
|
8
|
+
PICTURE = "Picture",
|
|
9
|
+
BLOCKLIST_CHANGE = "BlocklistChange",
|
|
10
|
+
BLOCKLIST = "Blocklist",
|
|
11
|
+
CONNECTED = "Connected",
|
|
12
|
+
DISCONNECTED = "Disconnected",
|
|
13
|
+
CONNECT_FAILURE = "ConnectFailure",
|
|
14
|
+
KEEP_ALIVE_RESTORED = "KeepAliveRestored",
|
|
15
|
+
KEEP_ALIVE_TIMEOUT = "KeepAliveTimeout",
|
|
16
|
+
LOGGED_OUT = "LoggedOut",
|
|
17
|
+
CLIENT_OUTDATED = "ClientOutdated",
|
|
18
|
+
TEMPORARY_BAN = "TemporaryBan",
|
|
19
|
+
STREAM_ERROR = "StreamError",
|
|
20
|
+
STREAM_REPLACED = "StreamReplaced",
|
|
21
|
+
PAIR_SUCCESS = "PairSuccess",
|
|
22
|
+
PAIR_ERROR = "PairError",
|
|
23
|
+
QR = "QR",
|
|
24
|
+
QR_SCANNED_WITHOUT_MULTIDEVICE = "QRScannedWithoutMultidevice",
|
|
25
|
+
PRIVACY_SETTINGS = "PrivacySettings",
|
|
26
|
+
PUSH_NAME_SETTING = "PushNameSetting",
|
|
27
|
+
USER_ABOUT = "UserAbout",
|
|
28
|
+
APP_STATE = "AppState",
|
|
29
|
+
APP_STATE_SYNC_COMPLETE = "AppStateSyncComplete",
|
|
30
|
+
HISTORY_SYNC = "HistorySync",
|
|
31
|
+
OFFLINE_SYNC_COMPLETED = "OfflineSyncCompleted",
|
|
32
|
+
OFFLINE_SYNC_PREVIEW = "OfflineSyncPreview",
|
|
33
|
+
CALL_OFFER = "CallOffer",
|
|
34
|
+
CALL_ACCEPT = "CallAccept",
|
|
35
|
+
CALL_TERMINATE = "CallTerminate",
|
|
36
|
+
CALL_OFFER_NOTICE = "CallOfferNotice",
|
|
37
|
+
CALL_RELAY_LATENCY = "CallRelayLatency",
|
|
38
|
+
PRESENCE = "Presence",
|
|
39
|
+
CHAT_PRESENCE = "ChatPresence",
|
|
40
|
+
IDENTITY_CHANGE = "IdentityChange",
|
|
41
|
+
CAT_REFRESH_ERROR = "CATRefreshError",
|
|
42
|
+
NEWSLETTER_JOIN = "NewsletterJoin",
|
|
43
|
+
NEWSLETTER_LEAVE = "NewsletterLeave",
|
|
44
|
+
NEWSLETTER_MUTE_CHANGE = "NewsletterMuteChange",
|
|
45
|
+
NEWSLETTER_LIVE_UPDATE = "NewsletterLiveUpdate",
|
|
46
|
+
FB_MESSAGE = "FBMessage"
|
|
47
|
+
}
|
|
48
|
+
export declare const WEBHOOK_EVENTS: WebhookEventType[];
|
|
49
|
+
export type WebhookEvent = keyof typeof WebhookEventType | "All";
|
|
1
50
|
export interface SetWebhookRequest {
|
|
2
51
|
webhook: string;
|
|
3
|
-
events: string[];
|
|
52
|
+
events: (WebhookEvent | string)[];
|
|
4
53
|
}
|
|
5
54
|
export interface SetWebhookResponse {
|
|
6
55
|
WebhookURL: string;
|
|
@@ -12,7 +61,7 @@ export interface GetWebhookResponse {
|
|
|
12
61
|
}
|
|
13
62
|
export interface UpdateWebhookRequest {
|
|
14
63
|
webhook?: string;
|
|
15
|
-
events?: string[];
|
|
64
|
+
events?: (WebhookEvent | string)[];
|
|
16
65
|
Active?: boolean;
|
|
17
66
|
}
|
|
18
67
|
export interface UpdateWebhookResponse {
|
|
@@ -31,31 +80,33 @@ export interface S3MediaInfo {
|
|
|
31
80
|
mimeType: string;
|
|
32
81
|
fileName: string;
|
|
33
82
|
}
|
|
34
|
-
export interface
|
|
83
|
+
export interface WebhookPayloadBase<T = unknown> {
|
|
35
84
|
event: T;
|
|
85
|
+
type: string;
|
|
86
|
+
token: string;
|
|
87
|
+
}
|
|
88
|
+
export interface WebhookPayload<T = unknown> extends WebhookPayloadBase<T> {
|
|
36
89
|
s3?: S3MediaInfo;
|
|
37
90
|
base64?: string;
|
|
38
91
|
mimeType?: string;
|
|
39
92
|
fileName?: string;
|
|
40
93
|
}
|
|
41
|
-
export interface S3OnlyWebhookPayload<T = unknown> {
|
|
42
|
-
event: T;
|
|
94
|
+
export interface S3OnlyWebhookPayload<T = unknown> extends WebhookPayloadBase<T> {
|
|
43
95
|
s3: S3MediaInfo;
|
|
44
96
|
}
|
|
45
|
-
export interface Base64OnlyWebhookPayload<T = unknown> {
|
|
46
|
-
event: T;
|
|
97
|
+
export interface Base64OnlyWebhookPayload<T = unknown> extends WebhookPayloadBase<T> {
|
|
47
98
|
base64: string;
|
|
48
99
|
mimeType: string;
|
|
49
100
|
fileName: string;
|
|
50
101
|
}
|
|
51
|
-
export interface BothMediaWebhookPayload<T = unknown> {
|
|
52
|
-
event: T;
|
|
102
|
+
export interface BothMediaWebhookPayload<T = unknown> extends WebhookPayloadBase<T> {
|
|
53
103
|
s3: S3MediaInfo;
|
|
54
104
|
base64: string;
|
|
55
105
|
mimeType: string;
|
|
56
106
|
fileName: string;
|
|
57
107
|
}
|
|
58
108
|
export type AnyWebhookPayload<T = unknown> = WebhookPayload<T> | S3OnlyWebhookPayload<T> | Base64OnlyWebhookPayload<T> | BothMediaWebhookPayload<T>;
|
|
59
|
-
export declare function hasS3Media(payload:
|
|
60
|
-
export declare function hasBase64Media(payload:
|
|
61
|
-
export declare function hasBothMedia(payload:
|
|
109
|
+
export declare function hasS3Media(payload: WebhookPayloadBase): payload is S3OnlyWebhookPayload | BothMediaWebhookPayload;
|
|
110
|
+
export declare function hasBase64Media(payload: WebhookPayloadBase): payload is Base64OnlyWebhookPayload | BothMediaWebhookPayload;
|
|
111
|
+
export declare function hasBothMedia(payload: WebhookPayloadBase): payload is BothMediaWebhookPayload;
|
|
112
|
+
export declare function isValidWebhookPayload(payload: unknown): payload is WebhookPayloadBase;
|
package/dist/webhook.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
|
|
3
|
+
WebhookEventType2["MESSAGE"] = "Message";
|
|
4
|
+
WebhookEventType2["UNDECRYPTABLE_MESSAGE"] = "UndecryptableMessage";
|
|
5
|
+
WebhookEventType2["RECEIPT"] = "Receipt";
|
|
6
|
+
WebhookEventType2["MEDIA_RETRY"] = "MediaRetry";
|
|
7
|
+
WebhookEventType2["GROUP_INFO"] = "GroupInfo";
|
|
8
|
+
WebhookEventType2["JOINED_GROUP"] = "JoinedGroup";
|
|
9
|
+
WebhookEventType2["PICTURE"] = "Picture";
|
|
10
|
+
WebhookEventType2["BLOCKLIST_CHANGE"] = "BlocklistChange";
|
|
11
|
+
WebhookEventType2["BLOCKLIST"] = "Blocklist";
|
|
12
|
+
WebhookEventType2["CONNECTED"] = "Connected";
|
|
13
|
+
WebhookEventType2["DISCONNECTED"] = "Disconnected";
|
|
14
|
+
WebhookEventType2["CONNECT_FAILURE"] = "ConnectFailure";
|
|
15
|
+
WebhookEventType2["KEEP_ALIVE_RESTORED"] = "KeepAliveRestored";
|
|
16
|
+
WebhookEventType2["KEEP_ALIVE_TIMEOUT"] = "KeepAliveTimeout";
|
|
17
|
+
WebhookEventType2["LOGGED_OUT"] = "LoggedOut";
|
|
18
|
+
WebhookEventType2["CLIENT_OUTDATED"] = "ClientOutdated";
|
|
19
|
+
WebhookEventType2["TEMPORARY_BAN"] = "TemporaryBan";
|
|
20
|
+
WebhookEventType2["STREAM_ERROR"] = "StreamError";
|
|
21
|
+
WebhookEventType2["STREAM_REPLACED"] = "StreamReplaced";
|
|
22
|
+
WebhookEventType2["PAIR_SUCCESS"] = "PairSuccess";
|
|
23
|
+
WebhookEventType2["PAIR_ERROR"] = "PairError";
|
|
24
|
+
WebhookEventType2["QR"] = "QR";
|
|
25
|
+
WebhookEventType2["QR_SCANNED_WITHOUT_MULTIDEVICE"] = "QRScannedWithoutMultidevice";
|
|
26
|
+
WebhookEventType2["PRIVACY_SETTINGS"] = "PrivacySettings";
|
|
27
|
+
WebhookEventType2["PUSH_NAME_SETTING"] = "PushNameSetting";
|
|
28
|
+
WebhookEventType2["USER_ABOUT"] = "UserAbout";
|
|
29
|
+
WebhookEventType2["APP_STATE"] = "AppState";
|
|
30
|
+
WebhookEventType2["APP_STATE_SYNC_COMPLETE"] = "AppStateSyncComplete";
|
|
31
|
+
WebhookEventType2["HISTORY_SYNC"] = "HistorySync";
|
|
32
|
+
WebhookEventType2["OFFLINE_SYNC_COMPLETED"] = "OfflineSyncCompleted";
|
|
33
|
+
WebhookEventType2["OFFLINE_SYNC_PREVIEW"] = "OfflineSyncPreview";
|
|
34
|
+
WebhookEventType2["CALL_OFFER"] = "CallOffer";
|
|
35
|
+
WebhookEventType2["CALL_ACCEPT"] = "CallAccept";
|
|
36
|
+
WebhookEventType2["CALL_TERMINATE"] = "CallTerminate";
|
|
37
|
+
WebhookEventType2["CALL_OFFER_NOTICE"] = "CallOfferNotice";
|
|
38
|
+
WebhookEventType2["CALL_RELAY_LATENCY"] = "CallRelayLatency";
|
|
39
|
+
WebhookEventType2["PRESENCE"] = "Presence";
|
|
40
|
+
WebhookEventType2["CHAT_PRESENCE"] = "ChatPresence";
|
|
41
|
+
WebhookEventType2["IDENTITY_CHANGE"] = "IdentityChange";
|
|
42
|
+
WebhookEventType2["CAT_REFRESH_ERROR"] = "CATRefreshError";
|
|
43
|
+
WebhookEventType2["NEWSLETTER_JOIN"] = "NewsletterJoin";
|
|
44
|
+
WebhookEventType2["NEWSLETTER_LEAVE"] = "NewsletterLeave";
|
|
45
|
+
WebhookEventType2["NEWSLETTER_MUTE_CHANGE"] = "NewsletterMuteChange";
|
|
46
|
+
WebhookEventType2["NEWSLETTER_LIVE_UPDATE"] = "NewsletterLiveUpdate";
|
|
47
|
+
WebhookEventType2["FB_MESSAGE"] = "FBMessage";
|
|
48
|
+
return WebhookEventType2;
|
|
49
|
+
})(WebhookEventType || {});
|
|
50
|
+
const WEBHOOK_EVENTS = Object.values(WebhookEventType);
|
|
51
|
+
function hasS3Media(payload) {
|
|
52
|
+
return !!payload.s3;
|
|
53
|
+
}
|
|
54
|
+
function hasBase64Media(payload) {
|
|
55
|
+
return !!payload.base64;
|
|
56
|
+
}
|
|
57
|
+
function hasBothMedia(payload) {
|
|
58
|
+
return hasS3Media(payload) && hasBase64Media(payload);
|
|
59
|
+
}
|
|
60
|
+
function isValidWebhookPayload(payload) {
|
|
61
|
+
return typeof payload === "object" && payload !== null && "event" in payload && "type" in payload && "token" in payload;
|
|
62
|
+
}
|
|
63
|
+
exports.WEBHOOK_EVENTS = WEBHOOK_EVENTS;
|
|
64
|
+
exports.WebhookEventType = WebhookEventType;
|
|
65
|
+
exports.hasBase64Media = hasBase64Media;
|
|
66
|
+
exports.hasBothMedia = hasBothMedia;
|
|
67
|
+
exports.hasS3Media = hasS3Media;
|
|
68
|
+
exports.isValidWebhookPayload = isValidWebhookPayload;
|
|
69
|
+
//# sourceMappingURL=webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.js","sources":["../src/types/webhook.ts"],"sourcesContent":["// 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 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}\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 | \"All\";\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}\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// 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"],"names":["WebhookEventType"],"mappings":";AAGO,IAAK,qCAAAA,sBAAL;AACLA,oBAAA,SAAA,IAAU;AACVA,oBAAA,uBAAA,IAAwB;AACxBA,oBAAA,SAAA,IAAU;AACVA,oBAAA,aAAA,IAAc;AACdA,oBAAA,YAAA,IAAa;AACbA,oBAAA,cAAA,IAAe;AACfA,oBAAA,SAAA,IAAU;AACVA,oBAAA,kBAAA,IAAmB;AACnBA,oBAAA,WAAA,IAAY;AACZA,oBAAA,WAAA,IAAY;AACZA,oBAAA,cAAA,IAAe;AACfA,oBAAA,iBAAA,IAAkB;AAClBA,oBAAA,qBAAA,IAAsB;AACtBA,oBAAA,oBAAA,IAAqB;AACrBA,oBAAA,YAAA,IAAa;AACbA,oBAAA,iBAAA,IAAkB;AAClBA,oBAAA,eAAA,IAAgB;AAChBA,oBAAA,cAAA,IAAe;AACfA,oBAAA,iBAAA,IAAkB;AAClBA,oBAAA,cAAA,IAAe;AACfA,oBAAA,YAAA,IAAa;AACbA,oBAAA,IAAA,IAAK;AACLA,oBAAA,gCAAA,IAAiC;AACjCA,oBAAA,kBAAA,IAAmB;AACnBA,oBAAA,mBAAA,IAAoB;AACpBA,oBAAA,YAAA,IAAa;AACbA,oBAAA,WAAA,IAAY;AACZA,oBAAA,yBAAA,IAA0B;AAC1BA,oBAAA,cAAA,IAAe;AACfA,oBAAA,wBAAA,IAAyB;AACzBA,oBAAA,sBAAA,IAAuB;AACvBA,oBAAA,YAAA,IAAa;AACbA,oBAAA,aAAA,IAAc;AACdA,oBAAA,gBAAA,IAAiB;AACjBA,oBAAA,mBAAA,IAAoB;AACpBA,oBAAA,oBAAA,IAAqB;AACrBA,oBAAA,UAAA,IAAW;AACXA,oBAAA,eAAA,IAAgB;AAChBA,oBAAA,iBAAA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