@samva/webhooks 0.20.0 → 0.21.0

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.
@@ -1,714 +0,0 @@
1
- //#region src/decoder.gen.ts
2
- const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
- const validate0 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate3(value["data"]));
4
- const validate1 = (value) => typeof value === "string" && value === "message.sent";
5
- const validate2 = (value) => typeof value === "string";
6
- const validate3 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "channel") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "organizationId") && (!Object.hasOwn(value, "mailboxId") || validate4(value["mailboxId"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "status") || validate8(value["status"])) && (!Object.hasOwn(value, "metadata") || validate11(value["metadata"])) && (!Object.hasOwn(value, "cost") || validate14(value["cost"])) && (!Object.hasOwn(value, "recipient") || validate8(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate8(value["occurredAt"])) && (!Object.hasOwn(value, "failureReason") || validate8(value["failureReason"])) && (!Object.hasOwn(value, "errorCode") || validate8(value["errorCode"])) && (!Object.hasOwn(value, "conversationId") || validate8(value["conversationId"])) && (!Object.hasOwn(value, "isBillable") || validate32(value["isBillable"])) && (!Object.hasOwn(value, "messageType") || validate8(value["messageType"])) && (!Object.hasOwn(value, "templateCategory") || validate38(value["templateCategory"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "toEmails") || validate44(value["toEmails"])) && (!Object.hasOwn(value, "providerMessageId") || validate8(value["providerMessageId"])) && (!Object.hasOwn(value, "waId") || validate8(value["waId"])) && (!Object.hasOwn(value, "hasAttachments") || validate32(value["hasAttachments"])) && (!Object.hasOwn(value, "isAutoReply") || validate32(value["isAutoReply"])) && (!Object.hasOwn(value, "segments") || validate14(value["segments"])) && (!Object.hasOwn(value, "to") || validate8(value["to"])) && (!Object.hasOwn(value, "from") || validate8(value["from"])) && (!Object.hasOwn(value, "body") || validate8(value["body"])) && (!Object.hasOwn(value, "direction") || validate72(value["direction"])) && (!Object.hasOwn(value, "errorMessage") || validate8(value["errorMessage"])) && (!Object.hasOwn(value, "parts") || validate14(value["parts"])) && (!Object.hasOwn(value, "carrier") || validate8(value["carrier"])) && (!Object.hasOwn(value, "messageId") || validate2(value["messageId"])) && (!Object.hasOwn(value, "organizationId") || validate2(value["organizationId"]));
7
- const validate4 = (value) => validate5(value) || validate6(value);
8
- const validate5 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mbx_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
9
- const validate6 = (value) => value === null;
10
- const validate7 = (value) => typeof value === "string" && (value === "sms" || value === "whatsapp" || value === "email");
11
- const validate8 = (value) => validate2(value) || validate6(value);
12
- const validate11 = (value) => validate12(value) || validate6(value);
13
- const validate12 = (value) => isObject(value);
14
- const validate14 = (value) => validate15(value) || validate6(value);
15
- const validate15 = (value) => typeof value === "number" && Number.isFinite(value);
16
- const validate32 = (value) => validate33(value) || validate6(value);
17
- const validate33 = (value) => typeof value === "boolean";
18
- const validate38 = (value) => validate39(value) || validate6(value);
19
- const validate39 = (value) => typeof value === "string" && (value === "marketing" || value === "utility" || value === "authentication");
20
- const validate44 = (value) => validate45(value) || validate6(value);
21
- const validate45 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate2);
22
- const validate72 = (value) => validate73(value) || validate6(value);
23
- const validate73 = (value) => typeof value === "string" && (value === "inbound" || value === "outbound");
24
- const validate86 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate87(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate3(value["data"]));
25
- const validate87 = (value) => typeof value === "string" && value === "message.delivered";
26
- const validate172 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate173(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate3(value["data"]));
27
- const validate173 = (value) => typeof value === "string" && value === "message.read";
28
- const validate258 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate259(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate3(value["data"]));
29
- const validate259 = (value) => typeof value === "string" && value === "message.failed";
30
- const validate344 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate345(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate347(value["data"]));
31
- const validate345 = (value) => typeof value === "string" && value === "message.bounced";
32
- const validate347 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "channel") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "organizationId") && (!Object.hasOwn(value, "mailboxId") || validate4(value["mailboxId"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "status") || validate8(value["status"])) && (!Object.hasOwn(value, "metadata") || validate11(value["metadata"])) && (!Object.hasOwn(value, "cost") || validate14(value["cost"])) && (!Object.hasOwn(value, "recipient") || validate2(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"])) && (!Object.hasOwn(value, "failureReason") || validate8(value["failureReason"])) && (!Object.hasOwn(value, "errorCode") || validate8(value["errorCode"])) && (!Object.hasOwn(value, "conversationId") || validate8(value["conversationId"])) && (!Object.hasOwn(value, "isBillable") || validate32(value["isBillable"])) && (!Object.hasOwn(value, "messageType") || validate8(value["messageType"])) && (!Object.hasOwn(value, "templateCategory") || validate38(value["templateCategory"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "toEmails") || validate44(value["toEmails"])) && (!Object.hasOwn(value, "providerMessageId") || validate8(value["providerMessageId"])) && (!Object.hasOwn(value, "waId") || validate8(value["waId"])) && (!Object.hasOwn(value, "hasAttachments") || validate32(value["hasAttachments"])) && (!Object.hasOwn(value, "isAutoReply") || validate32(value["isAutoReply"])) && (!Object.hasOwn(value, "segments") || validate14(value["segments"])) && (!Object.hasOwn(value, "to") || validate8(value["to"])) && (!Object.hasOwn(value, "from") || validate8(value["from"])) && (!Object.hasOwn(value, "body") || validate8(value["body"])) && (!Object.hasOwn(value, "direction") || validate72(value["direction"])) && (!Object.hasOwn(value, "errorMessage") || validate8(value["errorMessage"])) && (!Object.hasOwn(value, "parts") || validate14(value["parts"])) && (!Object.hasOwn(value, "carrier") || validate8(value["carrier"])) && (!Object.hasOwn(value, "messageId") || validate2(value["messageId"])) && (!Object.hasOwn(value, "organizationId") || validate2(value["organizationId"]));
33
- const validate426 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate427(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate347(value["data"]));
34
- const validate427 = (value) => typeof value === "string" && value === "message.complained";
35
- const validate508 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate509(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate511(value["data"]));
36
- const validate509 = (value) => typeof value === "string" && value === "message.received";
37
- const validate511 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "channel") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "organizationId") && (!Object.hasOwn(value, "mailboxId") || validate4(value["mailboxId"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "status") || validate8(value["status"])) && (!Object.hasOwn(value, "metadata") || validate11(value["metadata"])) && (!Object.hasOwn(value, "cost") || validate14(value["cost"])) && (!Object.hasOwn(value, "recipient") || validate8(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate8(value["occurredAt"])) && (!Object.hasOwn(value, "failureReason") || validate8(value["failureReason"])) && (!Object.hasOwn(value, "errorCode") || validate8(value["errorCode"])) && (!Object.hasOwn(value, "conversationId") || validate8(value["conversationId"])) && (!Object.hasOwn(value, "isBillable") || validate32(value["isBillable"])) && (!Object.hasOwn(value, "messageType") || validate8(value["messageType"])) && (!Object.hasOwn(value, "templateCategory") || validate38(value["templateCategory"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "toEmails") || validate44(value["toEmails"])) && (!Object.hasOwn(value, "providerMessageId") || validate8(value["providerMessageId"])) && (!Object.hasOwn(value, "waId") || validate8(value["waId"])) && (!Object.hasOwn(value, "hasAttachments") || validate32(value["hasAttachments"])) && (!Object.hasOwn(value, "isAutoReply") || validate32(value["isAutoReply"])) && (!Object.hasOwn(value, "segments") || validate14(value["segments"])) && (!Object.hasOwn(value, "to") || validate8(value["to"])) && (!Object.hasOwn(value, "from") || validate8(value["from"])) && (!Object.hasOwn(value, "body") || validate8(value["body"])) && (!Object.hasOwn(value, "direction") || validate72(value["direction"])) && (!Object.hasOwn(value, "errorMessage") || validate8(value["errorMessage"])) && (!Object.hasOwn(value, "parts") || validate14(value["parts"])) && (!Object.hasOwn(value, "carrier") || validate8(value["carrier"])) && (!Object.hasOwn(value, "whatsapp") || validate592(value["whatsapp"])) && (!Object.hasOwn(value, "messageId") || validate2(value["messageId"])) && (!Object.hasOwn(value, "organizationId") || validate2(value["organizationId"]));
38
- const validate592 = (value) => validate593(value) || validate6(value);
39
- const validate593 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "text") || validate8(value["text"])) && (!Object.hasOwn(value, "template") || validate597(value["template"])) && (!Object.hasOwn(value, "interactive") || validate645(value["interactive"])) && (!Object.hasOwn(value, "media") || validate744(value["media"])) && (!Object.hasOwn(value, "reaction") || validate767(value["reaction"])) && (!Object.hasOwn(value, "location") || validate775(value["location"])) && (!Object.hasOwn(value, "contacts") || validate781(value["contacts"])) && (!Object.hasOwn(value, "reply") || validate817(value["reply"])) && (!Object.hasOwn(value, "flowResponse") || validate822(value["flowResponse"])) && (!Object.hasOwn(value, "context") || validate828(value["context"]));
40
- const validate597 = (value) => validate598(value) || validate6(value);
41
- const validate598 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "name") && Object.hasOwn(value, "language") && Object.hasOwn(value, "components") && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "language") || validate2(value["language"])) && (!Object.hasOwn(value, "components") || validate601(value["components"]));
42
- const validate601 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate602);
43
- const validate602 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "parameters") && (!Object.hasOwn(value, "type") || validate603(value["type"])) && (!Object.hasOwn(value, "sub_type") || validate604(value["sub_type"])) && (!Object.hasOwn(value, "index") || validate8(value["index"])) && (!Object.hasOwn(value, "parameters") || validate610(value["parameters"]));
44
- const validate603 = (value) => typeof value === "string" && (value === "header" || value === "body" || value === "footer" || value === "button");
45
- const validate604 = (value) => validate605(value) || validate6(value);
46
- const validate605 = (value) => typeof value === "string" && (value === "url" || value === "quick_reply" || value === "copy_code");
47
- const validate610 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate611);
48
- const validate611 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && (!Object.hasOwn(value, "type") || validate612(value["type"])) && (!Object.hasOwn(value, "text") || validate8(value["text"])) && (!Object.hasOwn(value, "currency") || validate616(value["currency"])) && (!Object.hasOwn(value, "date_time") || validate622(value["date_time"])) && (!Object.hasOwn(value, "image") || validate626(value["image"])) && (!Object.hasOwn(value, "document") || validate630(value["document"])) && (!Object.hasOwn(value, "video") || validate626(value["video"])) && (!Object.hasOwn(value, "coupon_code") || validate8(value["coupon_code"]));
49
- const validate612 = (value) => typeof value === "string" && (value === "text" || value === "currency" || value === "date_time" || value === "image" || value === "document" || value === "video" || value === "coupon_code");
50
- const validate616 = (value) => validate617(value) || validate6(value);
51
- const validate617 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "fallback_value") && Object.hasOwn(value, "code") && Object.hasOwn(value, "amount_1000") && (!Object.hasOwn(value, "fallback_value") || validate2(value["fallback_value"])) && (!Object.hasOwn(value, "code") || validate2(value["code"])) && (!Object.hasOwn(value, "amount_1000") || validate15(value["amount_1000"]));
52
- const validate622 = (value) => validate623(value) || validate6(value);
53
- const validate623 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "fallback_value") && (!Object.hasOwn(value, "fallback_value") || validate2(value["fallback_value"]));
54
- const validate626 = (value) => validate627(value) || validate6(value);
55
- const validate627 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "link") && (!Object.hasOwn(value, "link") || validate2(value["link"]));
56
- const validate630 = (value) => validate631(value) || validate6(value);
57
- const validate631 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "link") && (!Object.hasOwn(value, "link") || validate2(value["link"])) && (!Object.hasOwn(value, "filename") || validate8(value["filename"]));
58
- const validate645 = (value) => validate646(value) || validate681(value) || validate697(value) || validate730(value);
59
- const validate646 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "body") && Object.hasOwn(value, "buttons") && (!Object.hasOwn(value, "type") || validate647(value["type"])) && (!Object.hasOwn(value, "header") || validate648(value["header"])) && (!Object.hasOwn(value, "body") || validate675(value["body"])) && (!Object.hasOwn(value, "footer") || validate651(value["footer"])) && (!Object.hasOwn(value, "buttons") || validate677(value["buttons"]));
60
- const validate647 = (value) => typeof value === "string" && value === "buttons";
61
- const validate648 = (value) => validate649(value) || validate652(value) || validate659(value) || validate666(value);
62
- const validate649 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "text") && (!Object.hasOwn(value, "type") || validate650(value["type"])) && (!Object.hasOwn(value, "text") || validate651(value["text"]));
63
- const validate650 = (value) => typeof value === "string" && value === "text";
64
- const validate651 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 60;
65
- const validate652 = (value) => validate653(value) || validate656(value);
66
- const validate653 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "url") && (!Object.hasOwn(value, "type") || validate654(value["type"])) && (!Object.hasOwn(value, "url") || validate2(value["url"]));
67
- const validate654 = (value) => typeof value === "string" && value === "image";
68
- const validate656 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "mediaId") && (!Object.hasOwn(value, "type") || validate654(value["type"])) && (!Object.hasOwn(value, "mediaId") || validate658(value["mediaId"]));
69
- const validate658 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^media_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
70
- const validate659 = (value) => validate660(value) || validate663(value);
71
- const validate660 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "url") && (!Object.hasOwn(value, "type") || validate661(value["type"])) && (!Object.hasOwn(value, "url") || validate2(value["url"]));
72
- const validate661 = (value) => typeof value === "string" && value === "video";
73
- const validate663 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "mediaId") && (!Object.hasOwn(value, "type") || validate661(value["type"])) && (!Object.hasOwn(value, "mediaId") || validate658(value["mediaId"]));
74
- const validate666 = (value) => validate667(value) || validate671(value);
75
- const validate667 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "url") && (!Object.hasOwn(value, "type") || validate668(value["type"])) && (!Object.hasOwn(value, "filename") || validate669(value["filename"])) && (!Object.hasOwn(value, "url") || validate2(value["url"]));
76
- const validate668 = (value) => typeof value === "string" && value === "document";
77
- const validate669 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 255;
78
- const validate671 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "mediaId") && (!Object.hasOwn(value, "type") || validate668(value["type"])) && (!Object.hasOwn(value, "filename") || validate669(value["filename"])) && (!Object.hasOwn(value, "mediaId") || validate658(value["mediaId"]));
79
- const validate675 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 1024;
80
- const validate677 = (value) => Array.isArray(value) && Array.isArray(value) && value.length >= 1 && Array.isArray(value) && value.length <= 3 && Array.isArray(value) && value.every(validate678);
81
- const validate678 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "title") && (!Object.hasOwn(value, "id") || validate679(value["id"])) && (!Object.hasOwn(value, "title") || validate680(value["title"]));
82
- const validate679 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 256;
83
- const validate680 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 20;
84
- const validate681 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "body") && Object.hasOwn(value, "button") && Object.hasOwn(value, "sections") && (!Object.hasOwn(value, "type") || validate682(value["type"])) && (!Object.hasOwn(value, "header") || validate649(value["header"])) && (!Object.hasOwn(value, "body") || validate686(value["body"])) && (!Object.hasOwn(value, "footer") || validate651(value["footer"])) && (!Object.hasOwn(value, "button") || validate680(value["button"])) && (!Object.hasOwn(value, "sections") || validate689(value["sections"]));
85
- const validate682 = (value) => typeof value === "string" && value === "list";
86
- const validate686 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 4096;
87
- const validate689 = (value) => Array.isArray(value) && Array.isArray(value) && value.length >= 1 && Array.isArray(value) && value.length <= 10 && Array.isArray(value) && value.every(validate690);
88
- const validate690 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "rows") && (!Object.hasOwn(value, "title") || validate691(value["title"])) && (!Object.hasOwn(value, "rows") || validate692(value["rows"]));
89
- const validate691 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 24;
90
- const validate692 = (value) => Array.isArray(value) && Array.isArray(value) && value.length >= 1 && Array.isArray(value) && value.every(validate693);
91
- const validate693 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "title") && (!Object.hasOwn(value, "id") || validate694(value["id"])) && (!Object.hasOwn(value, "title") || validate691(value["title"])) && (!Object.hasOwn(value, "description") || validate696(value["description"]));
92
- const validate694 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 200;
93
- const validate696 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 72;
94
- const validate697 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "body") && Object.hasOwn(value, "displayText") && Object.hasOwn(value, "url") && (!Object.hasOwn(value, "type") || validate698(value["type"])) && (!Object.hasOwn(value, "header") || validate648(value["header"])) && (!Object.hasOwn(value, "body") || validate675(value["body"])) && (!Object.hasOwn(value, "footer") || validate651(value["footer"])) && (!Object.hasOwn(value, "displayText") || validate680(value["displayText"])) && (!Object.hasOwn(value, "url") || validate2(value["url"]));
95
- const validate698 = (value) => typeof value === "string" && value === "cta_url";
96
- const validate730 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "body") && Object.hasOwn(value, "flowId") && Object.hasOwn(value, "cta") && Object.hasOwn(value, "flowVersionId") && Object.hasOwn(value, "providerFlowId") && (!Object.hasOwn(value, "type") || validate731(value["type"])) && (!Object.hasOwn(value, "header") || validate649(value["header"])) && (!Object.hasOwn(value, "body") || validate675(value["body"])) && (!Object.hasOwn(value, "footer") || validate651(value["footer"])) && (!Object.hasOwn(value, "flowId") || validate737(value["flowId"])) && (!Object.hasOwn(value, "cta") || validate738(value["cta"])) && (!Object.hasOwn(value, "token") || validate675(value["token"])) && (!Object.hasOwn(value, "screen") || validate740(value["screen"])) && (!Object.hasOwn(value, "data") || validate12(value["data"])) && (!Object.hasOwn(value, "flowVersionId") || validate742(value["flowVersionId"])) && (!Object.hasOwn(value, "providerFlowId") || validate2(value["providerFlowId"]));
97
- const validate731 = (value) => typeof value === "string" && value === "flow";
98
- const validate737 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^waflow_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
99
- const validate738 = (value) => typeof value === "string" && typeof value === "string" && Array.from(value).length >= 1 && typeof value === "string" && Array.from(value).length <= 30;
100
- const validate740 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^[A-Za-z_]{1,100}$", "u")).test(value);
101
- const validate742 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^wafver_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
102
- const validate744 = (value) => validate745(value) || validate6(value);
103
- const validate745 = (value) => validate746(value) || validate751(value) || validate756(value);
104
- const validate746 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "url") && (!Object.hasOwn(value, "type") || validate747(value["type"])) && (!Object.hasOwn(value, "url") || validate2(value["url"])) && (!Object.hasOwn(value, "caption") || validate2(value["caption"])) && (!Object.hasOwn(value, "filename") || validate2(value["filename"]));
105
- const validate747 = (value) => typeof value === "string" && (value === "image" || value === "video" || value === "audio" || value === "document" || value === "sticker");
106
- const validate751 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "mediaId") && (!Object.hasOwn(value, "type") || validate747(value["type"])) && (!Object.hasOwn(value, "mediaId") || validate658(value["mediaId"])) && (!Object.hasOwn(value, "caption") || validate2(value["caption"])) && (!Object.hasOwn(value, "filename") || validate2(value["filename"]));
107
- const validate756 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "providerMediaId") && (!Object.hasOwn(value, "type") || validate747(value["type"])) && (!Object.hasOwn(value, "providerMediaId") || validate2(value["providerMediaId"])) && (!Object.hasOwn(value, "mimeType") || validate8(value["mimeType"])) && (!Object.hasOwn(value, "caption") || validate8(value["caption"])) && (!Object.hasOwn(value, "filename") || validate2(value["filename"]));
108
- const validate767 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "providerMessageId") && Object.hasOwn(value, "emoji") && (!Object.hasOwn(value, "messageId") || validate768(value["messageId"])) && (!Object.hasOwn(value, "providerMessageId") || validate2(value["providerMessageId"])) && (!Object.hasOwn(value, "emoji") || validate8(value["emoji"]));
109
- const validate768 = (value) => validate769(value) || validate6(value);
110
- const validate769 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^msg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
111
- const validate775 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "latitude") && Object.hasOwn(value, "longitude") && (!Object.hasOwn(value, "latitude") || validate15(value["latitude"])) && (!Object.hasOwn(value, "longitude") || validate15(value["longitude"])) && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "address") || validate2(value["address"])) && (!Object.hasOwn(value, "url") || validate2(value["url"]));
112
- const validate781 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate782);
113
- const validate782 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "name") || validate783(value["name"])) && (!Object.hasOwn(value, "phones") || validate790(value["phones"])) && (!Object.hasOwn(value, "emails") || validate795(value["emails"])) && (!Object.hasOwn(value, "urls") || validate799(value["urls"])) && (!Object.hasOwn(value, "org") || validate803(value["org"])) && (!Object.hasOwn(value, "addresses") || validate807(value["addresses"])) && (!Object.hasOwn(value, "birthday") || validate2(value["birthday"]));
114
- const validate783 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "formattedName") || validate2(value["formattedName"])) && (!Object.hasOwn(value, "firstName") || validate2(value["firstName"])) && (!Object.hasOwn(value, "lastName") || validate2(value["lastName"])) && (!Object.hasOwn(value, "middleName") || validate2(value["middleName"])) && (!Object.hasOwn(value, "prefix") || validate2(value["prefix"])) && (!Object.hasOwn(value, "suffix") || validate2(value["suffix"]));
115
- const validate790 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate791);
116
- const validate791 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "phone") || validate2(value["phone"])) && (!Object.hasOwn(value, "type") || validate2(value["type"])) && (!Object.hasOwn(value, "waId") || validate2(value["waId"]));
117
- const validate795 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate796);
118
- const validate796 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "email") || validate2(value["email"])) && (!Object.hasOwn(value, "type") || validate2(value["type"]));
119
- const validate799 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate800);
120
- const validate800 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "url") || validate2(value["url"])) && (!Object.hasOwn(value, "type") || validate2(value["type"]));
121
- const validate803 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "company") || validate2(value["company"])) && (!Object.hasOwn(value, "department") || validate2(value["department"])) && (!Object.hasOwn(value, "title") || validate2(value["title"]));
122
- const validate807 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate808);
123
- const validate808 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "street") || validate2(value["street"])) && (!Object.hasOwn(value, "city") || validate2(value["city"])) && (!Object.hasOwn(value, "state") || validate2(value["state"])) && (!Object.hasOwn(value, "zip") || validate2(value["zip"])) && (!Object.hasOwn(value, "country") || validate2(value["country"])) && (!Object.hasOwn(value, "countryCode") || validate2(value["countryCode"])) && (!Object.hasOwn(value, "type") || validate2(value["type"]));
124
- const validate817 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "id") && Object.hasOwn(value, "title") && (!Object.hasOwn(value, "type") || validate818(value["type"])) && (!Object.hasOwn(value, "id") || validate2(value["id"])) && (!Object.hasOwn(value, "title") || validate2(value["title"])) && (!Object.hasOwn(value, "description") || validate2(value["description"]));
125
- const validate818 = (value) => typeof value === "string" && (value === "button" || value === "list" || value === "template_button");
126
- const validate822 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "flowToken") && Object.hasOwn(value, "response") && (!Object.hasOwn(value, "flowToken") || validate8(value["flowToken"])) && (!Object.hasOwn(value, "response") || validate12(value["response"])) && (!Object.hasOwn(value, "body") || validate2(value["body"]));
127
- const validate828 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "providerMessageId") && (!Object.hasOwn(value, "messageId") || validate768(value["messageId"])) && (!Object.hasOwn(value, "providerMessageId") || validate2(value["providerMessageId"]));
128
- const validate836 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate837(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate839(value["data"]));
129
- const validate837 = (value) => typeof value === "string" && value === "message.opened";
130
- const validate839 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "deliveryId") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "firstOpen") && Object.hasOwn(value, "machine") && Object.hasOwn(value, "machineReason") && (!Object.hasOwn(value, "messageId") || validate769(value["messageId"])) && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "channel") || validate842(value["channel"])) && (!Object.hasOwn(value, "deliveryId") || validate843(value["deliveryId"])) && (!Object.hasOwn(value, "recipient") || validate2(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"])) && (!Object.hasOwn(value, "userAgent") || validate8(value["userAgent"])) && (!Object.hasOwn(value, "ipAddress") || validate8(value["ipAddress"])) && (!Object.hasOwn(value, "firstOpen") || validate33(value["firstOpen"])) && (!Object.hasOwn(value, "machine") || validate33(value["machine"])) && (!Object.hasOwn(value, "machineReason") || validate854(value["machineReason"])) && (!Object.hasOwn(value, "country") || validate8(value["country"])) && (!Object.hasOwn(value, "city") || validate8(value["city"])) && (!Object.hasOwn(value, "asn") || validate14(value["asn"])) && (!Object.hasOwn(value, "code") || validate8(value["code"])) && (!Object.hasOwn(value, "linkIndex") || validate14(value["linkIndex"])) && (!Object.hasOwn(value, "destinationUrl") || validate8(value["destinationUrl"])) && (!Object.hasOwn(value, "metadata") || validate11(value["metadata"])) && (!Object.hasOwn(value, "campaignId") || validate878(value["campaignId"])) && (!Object.hasOwn(value, "campaignRunId") || validate881(value["campaignRunId"]));
131
- const validate841 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^org_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
132
- const validate842 = (value) => typeof value === "string" && value === "email";
133
- const validate843 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mdel_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
134
- const validate854 = (value) => validate855(value) || validate6(value);
135
- const validate855 = (value) => typeof value === "string" && (value === "google-image-proxy" || value === "apple-mail-privacy" || value === "scanner-user-agent" || value === "scanner-asn" || value === "too-fast");
136
- const validate878 = (value) => validate879(value) || validate6(value);
137
- const validate879 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^camp_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
138
- const validate881 = (value) => validate882(value) || validate6(value);
139
- const validate882 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^crun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
140
- const validate884 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate885(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate887(value["data"]));
141
- const validate885 = (value) => typeof value === "string" && value === "message.clicked";
142
- const validate887 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "deliveryId") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "url") && Object.hasOwn(value, "linkTags") && Object.hasOwn(value, "firstClick") && Object.hasOwn(value, "machine") && Object.hasOwn(value, "machineReason") && (!Object.hasOwn(value, "messageId") || validate769(value["messageId"])) && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "channel") || validate842(value["channel"])) && (!Object.hasOwn(value, "deliveryId") || validate843(value["deliveryId"])) && (!Object.hasOwn(value, "recipient") || validate2(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"])) && (!Object.hasOwn(value, "userAgent") || validate8(value["userAgent"])) && (!Object.hasOwn(value, "ipAddress") || validate8(value["ipAddress"])) && (!Object.hasOwn(value, "url") || validate2(value["url"])) && (!Object.hasOwn(value, "linkTags") || validate901(value["linkTags"])) && (!Object.hasOwn(value, "firstClick") || validate33(value["firstClick"])) && (!Object.hasOwn(value, "machine") || validate33(value["machine"])) && (!Object.hasOwn(value, "machineReason") || validate854(value["machineReason"])) && (!Object.hasOwn(value, "country") || validate8(value["country"])) && (!Object.hasOwn(value, "city") || validate8(value["city"])) && (!Object.hasOwn(value, "asn") || validate14(value["asn"])) && (!Object.hasOwn(value, "code") || validate8(value["code"])) && (!Object.hasOwn(value, "linkIndex") || validate14(value["linkIndex"])) && (!Object.hasOwn(value, "destinationUrl") || validate8(value["destinationUrl"])) && (!Object.hasOwn(value, "metadata") || validate11(value["metadata"])) && (!Object.hasOwn(value, "campaignId") || validate878(value["campaignId"])) && (!Object.hasOwn(value, "campaignRunId") || validate881(value["campaignRunId"]));
143
- const validate901 = (value) => isObject(value) && isObject(value) && Object.entries(value).every(([key, item]) => validate45(item));
144
- const validate936 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate937(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate939(value["data"]));
145
- const validate937 = (value) => typeof value === "string" && value === "contact.created";
146
- const validate939 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "contactId") && Object.hasOwn(value, "status") && Object.hasOwn(value, "name") && Object.hasOwn(value, "identities") && Object.hasOwn(value, "tags") && Object.hasOwn(value, "createdAt") && Object.hasOwn(value, "updatedAt") && (!Object.hasOwn(value, "contactId") || validate940(value["contactId"])) && (!Object.hasOwn(value, "status") || validate941(value["status"])) && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "displayName") || validate943(value["displayName"])) && (!Object.hasOwn(value, "identities") || validate948(value["identities"])) && (!Object.hasOwn(value, "tags") || validate45(value["tags"])) && (!Object.hasOwn(value, "externalId") || validate943(value["externalId"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
147
- const validate940 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^contact_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
148
- const validate941 = (value) => typeof value === "string" && (value === "active" || value === "paused" || value === "blocked" || value === "archived");
149
- const validate943 = (value) => validate8(value) || validate6(value);
150
- const validate948 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate949);
151
- const validate949 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "identifier") && Object.hasOwn(value, "verified") && (!Object.hasOwn(value, "type") || validate950(value["type"])) && (!Object.hasOwn(value, "identifier") || validate2(value["identifier"])) && (!Object.hasOwn(value, "verified") || validate33(value["verified"]));
152
- const validate950 = (value) => typeof value === "string" && (value === "email" || value === "phone");
153
- const validate962 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate963(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate939(value["data"]));
154
- const validate963 = (value) => typeof value === "string" && value === "contact.updated";
155
- const validate988 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate989(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate939(value["data"]));
156
- const validate989 = (value) => typeof value === "string" && value === "contact.deleted";
157
- const validate1014 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1015(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1017(value["data"]));
158
- const validate1015 = (value) => typeof value === "string" && value === "contact.subscribed";
159
- const validate1017 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "contactId") && Object.hasOwn(value, "groupId") && Object.hasOwn(value, "groupName") && Object.hasOwn(value, "source") && Object.hasOwn(value, "occurredAt") && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "contactId") || validate940(value["contactId"])) && (!Object.hasOwn(value, "email") || validate8(value["email"])) && (!Object.hasOwn(value, "groupId") || validate2(value["groupId"])) && (!Object.hasOwn(value, "groupName") || validate2(value["groupName"])) && (!Object.hasOwn(value, "contactGroupId") || validate1025(value["contactGroupId"])) && (!Object.hasOwn(value, "unsubscribeGroupId") || validate1028(value["unsubscribeGroupId"])) && (!Object.hasOwn(value, "consentIp") || validate8(value["consentIp"])) && (!Object.hasOwn(value, "consentSource") || validate8(value["consentSource"])) && (!Object.hasOwn(value, "source") || validate1037(value["source"])) && (!Object.hasOwn(value, "messageId") || validate768(value["messageId"])) && (!Object.hasOwn(value, "campaignId") || validate878(value["campaignId"])) && (!Object.hasOwn(value, "campaignRunId") || validate881(value["campaignRunId"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"]));
160
- const validate1025 = (value) => validate1026(value) || validate6(value);
161
- const validate1026 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^cgrp_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
162
- const validate1028 = (value) => validate1029(value) || validate6(value);
163
- const validate1029 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^unsub_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
164
- const validate1037 = (value) => typeof value === "string" && (value === "link" || value === "api" || value === "manual" || value === "complaint");
165
- const validate1048 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1049(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1017(value["data"]));
166
- const validate1049 = (value) => typeof value === "string" && value === "contact.unsubscribed";
167
- const validate1082 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1083(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1017(value["data"]));
168
- const validate1083 = (value) => typeof value === "string" && value === "contact.resubscribed";
169
- const validate1116 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1117(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1119(value["data"]));
170
- const validate1117 = (value) => typeof value === "string" && value === "contact.consent_changed";
171
- const validate1119 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "contactId") && Object.hasOwn(value, "identity") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "status") && Object.hasOwn(value, "previousStatus") && Object.hasOwn(value, "source") && Object.hasOwn(value, "capturedAt") && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "contactId") || validate940(value["contactId"])) && (!Object.hasOwn(value, "identity") || validate1122(value["identity"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "status") || validate1127(value["status"])) && (!Object.hasOwn(value, "previousStatus") || validate1128(value["previousStatus"])) && (!Object.hasOwn(value, "source") || validate2(value["source"])) && (!Object.hasOwn(value, "capturedAt") || validate2(value["capturedAt"]));
172
- const validate1122 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "type") && Object.hasOwn(value, "identifier") && (!Object.hasOwn(value, "id") || validate1123(value["id"])) && (!Object.hasOwn(value, "type") || validate950(value["type"])) && (!Object.hasOwn(value, "identifier") || validate2(value["identifier"]));
173
- const validate1123 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^cident_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
174
- const validate1127 = (value) => typeof value === "string" && (value === "opted_in" || value === "opted_out");
175
- const validate1128 = (value) => validate1127(value) || validate6(value);
176
- const validate1133 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1134(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1136(value["data"]));
177
- const validate1134 = (value) => typeof value === "string" && value === "conversation.created";
178
- const validate1136 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "conversationId") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "channels") && Object.hasOwn(value, "primaryChannel") && Object.hasOwn(value, "status") && Object.hasOwn(value, "createdAt") && Object.hasOwn(value, "updatedAt") && (!Object.hasOwn(value, "conversationId") || validate1137(value["conversationId"])) && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "title") || validate943(value["title"])) && (!Object.hasOwn(value, "channels") || validate1144(value["channels"])) && (!Object.hasOwn(value, "primaryChannel") || validate7(value["primaryChannel"])) && (!Object.hasOwn(value, "status") || validate1147(value["status"])) && (!Object.hasOwn(value, "primaryContactId") || validate1148(value["primaryContactId"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
179
- const validate1137 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^conv_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
180
- const validate1144 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate7);
181
- const validate1147 = (value) => typeof value === "string" && (value === "active" || value === "waiting" || value === "resolved" || value === "escalated" || value === "archived");
182
- const validate1148 = (value) => validate1149(value) || validate6(value);
183
- const validate1149 = (value) => validate940(value) || validate6(value);
184
- const validate1155 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1156(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1136(value["data"]));
185
- const validate1156 = (value) => typeof value === "string" && value === "conversation.updated";
186
- const validate1177 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1178(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1136(value["data"]));
187
- const validate1178 = (value) => typeof value === "string" && value === "conversation.archived";
188
- const validate1199 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1200(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1202(value["data"]));
189
- const validate1200 = (value) => typeof value === "string" && value === "webhook.created";
190
- const validate1202 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "webhookId") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "name") && Object.hasOwn(value, "url") && Object.hasOwn(value, "eventTypes") && Object.hasOwn(value, "channels") && Object.hasOwn(value, "status") && Object.hasOwn(value, "createdAt") && Object.hasOwn(value, "updatedAt") && (!Object.hasOwn(value, "webhookId") || validate1203(value["webhookId"])) && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "url") || validate2(value["url"])) && (!Object.hasOwn(value, "eventTypes") || validate45(value["eventTypes"])) && (!Object.hasOwn(value, "channels") || validate44(value["channels"])) && (!Object.hasOwn(value, "status") || validate1213(value["status"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
191
- const validate1203 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^wep_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
192
- const validate1213 = (value) => typeof value === "string" && (value === "active" || value === "disabled");
193
- const validate1216 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1217(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1202(value["data"]));
194
- const validate1217 = (value) => typeof value === "string" && value === "webhook.updated";
195
- const validate1233 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1234(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1202(value["data"]));
196
- const validate1234 = (value) => typeof value === "string" && value === "webhook.deleted";
197
- const validate1250 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1251(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate12(value["data"]));
198
- const validate1251 = (value) => typeof value === "string" && value === "webhook.test";
199
- const validate1254 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1255(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1257(value["data"]));
200
- const validate1255 = (value) => typeof value === "string" && value === "domain.updated";
201
- const validate1257 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "domainId") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "domain") && Object.hasOwn(value, "previousPhase") && Object.hasOwn(value, "phase") && Object.hasOwn(value, "dns") && Object.hasOwn(value, "provider") && Object.hasOwn(value, "operationId") && Object.hasOwn(value, "checkedAt") && Object.hasOwn(value, "nextCheckAt") && Object.hasOwn(value, "failure") && Object.hasOwn(value, "updatedAt") && (!Object.hasOwn(value, "domainId") || validate1258(value["domainId"])) && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "domain") || validate2(value["domain"])) && (!Object.hasOwn(value, "previousPhase") || validate1261(value["previousPhase"])) && (!Object.hasOwn(value, "phase") || validate1261(value["phase"])) && (!Object.hasOwn(value, "dns") || validate1263(value["dns"])) && (!Object.hasOwn(value, "provider") || validate1270(value["provider"])) && (!Object.hasOwn(value, "operationId") || validate1280(value["operationId"])) && (!Object.hasOwn(value, "checkedAt") || validate8(value["checkedAt"])) && (!Object.hasOwn(value, "nextCheckAt") || validate8(value["nextCheckAt"])) && (!Object.hasOwn(value, "failure") || validate1289(value["failure"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
202
- const validate1258 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^dom_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
203
- const validate1261 = (value) => typeof value === "string" && (value === "dns-setup" || value === "provisioning" || value === "verifying" || value === "ready" || value === "degraded" || value === "failed");
204
- const validate1263 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "observed") && Object.hasOwn(value, "total") && Object.hasOwn(value, "satisfied") && Object.hasOwn(value, "missing") && Object.hasOwn(value, "mismatch") && Object.hasOwn(value, "unknown") && (!Object.hasOwn(value, "observed") || validate33(value["observed"])) && (!Object.hasOwn(value, "total") || validate1265(value["total"])) && (!Object.hasOwn(value, "satisfied") || validate1265(value["satisfied"])) && (!Object.hasOwn(value, "missing") || validate1265(value["missing"])) && (!Object.hasOwn(value, "mismatch") || validate1265(value["mismatch"])) && (!Object.hasOwn(value, "unknown") || validate1265(value["unknown"]));
205
- const validate1265 = (value) => typeof value === "number" && Number.isInteger(value);
206
- const validate1270 = (value) => validate1271(value) || validate6(value);
207
- const validate1271 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "identity") && (!Object.hasOwn(value, "identity") || validate1272(value["identity"])) && (!Object.hasOwn(value, "dkim") || validate1273(value["dkim"])) && (!Object.hasOwn(value, "mailFrom") || validate1273(value["mailFrom"]));
208
- const validate1272 = (value) => typeof value === "string" && (value === "pending" || value === "verified" || value === "failed" || value === "unknown");
209
- const validate1273 = (value) => validate1272(value) || validate6(value);
210
- const validate1280 = (value) => validate1281(value) || validate6(value);
211
- const validate1281 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^op_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
212
- const validate1289 = (value) => validate1290(value) || validate6(value);
213
- const validate1290 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "code") && Object.hasOwn(value, "message") && Object.hasOwn(value, "failedAt") && (!Object.hasOwn(value, "code") || validate2(value["code"])) && (!Object.hasOwn(value, "message") || validate2(value["message"])) && (!Object.hasOwn(value, "failedAt") || validate2(value["failedAt"]));
214
- const validate1296 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1297(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1299(value["data"]));
215
- const validate1297 = (value) => typeof value === "string" && value === "domain.warming.updated";
216
- const validate1299 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "domainId") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "domain") && Object.hasOwn(value, "planId") && Object.hasOwn(value, "reason") && Object.hasOwn(value, "status") && Object.hasOwn(value, "holdReason") && Object.hasOwn(value, "batch") && Object.hasOwn(value, "updatedAt") && (!Object.hasOwn(value, "domainId") || validate2(value["domainId"])) && (!Object.hasOwn(value, "organizationId") || validate2(value["organizationId"])) && (!Object.hasOwn(value, "domain") || validate2(value["domain"])) && (!Object.hasOwn(value, "planId") || validate2(value["planId"])) && (!Object.hasOwn(value, "reason") || validate1304(value["reason"])) && (!Object.hasOwn(value, "status") || validate1305(value["status"])) && (!Object.hasOwn(value, "holdReason") || validate8(value["holdReason"])) && (!Object.hasOwn(value, "batch") || validate1309(value["batch"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
217
- const validate1304 = (value) => typeof value === "string" && (value === "plan-created" || value === "policy-updated" || value === "window-opened" || value === "window-cancelled" || value === "paused" || value === "resumed" || value === "held" || value === "completed");
218
- const validate1305 = (value) => typeof value === "string" && (value === "active" || value === "paused" || value === "completed");
219
- const validate1309 = (value) => validate1310(value) || validate6(value);
220
- const validate1310 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "sequence") && Object.hasOwn(value, "startsAt") && Object.hasOwn(value, "endsAt") && Object.hasOwn(value, "allowanceRecipients") && Object.hasOwn(value, "dailyGrowthPercent") && Object.hasOwn(value, "targetDailyRecipients") && (!Object.hasOwn(value, "id") || validate2(value["id"])) && (!Object.hasOwn(value, "sequence") || validate15(value["sequence"])) && (!Object.hasOwn(value, "startsAt") || validate2(value["startsAt"])) && (!Object.hasOwn(value, "endsAt") || validate2(value["endsAt"])) && (!Object.hasOwn(value, "allowanceRecipients") || validate15(value["allowanceRecipients"])) && (!Object.hasOwn(value, "dailyGrowthPercent") || validate15(value["dailyGrowthPercent"])) && (!Object.hasOwn(value, "targetDailyRecipients") || validate15(value["targetDailyRecipients"]));
221
- const validate1320 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1321(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1323(value["data"]));
222
- const validate1321 = (value) => typeof value === "string" && value === "template.registration.updated";
223
- const validate1323 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "templateId") && Object.hasOwn(value, "publicationId") && Object.hasOwn(value, "target") && Object.hasOwn(value, "name") && Object.hasOwn(value, "language") && Object.hasOwn(value, "status") && Object.hasOwn(value, "category") && Object.hasOwn(value, "providerCategory") && Object.hasOwn(value, "providerTemplateId") && Object.hasOwn(value, "reason") && Object.hasOwn(value, "submittedAt") && Object.hasOwn(value, "statusChangedAt") && Object.hasOwn(value, "createdAt") && Object.hasOwn(value, "updatedAt") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "previousStatus") && (!Object.hasOwn(value, "id") || validate1324(value["id"])) && (!Object.hasOwn(value, "templateId") || validate1325(value["templateId"])) && (!Object.hasOwn(value, "publicationId") || validate1326(value["publicationId"])) && (!Object.hasOwn(value, "target") || validate1327(value["target"])) && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "language") || validate2(value["language"])) && (!Object.hasOwn(value, "status") || validate1337(value["status"])) && (!Object.hasOwn(value, "category") || validate1338(value["category"])) && (!Object.hasOwn(value, "providerCategory") || validate1339(value["providerCategory"])) && (!Object.hasOwn(value, "providerTemplateId") || validate8(value["providerTemplateId"])) && (!Object.hasOwn(value, "reason") || validate8(value["reason"])) && (!Object.hasOwn(value, "submittedAt") || validate8(value["submittedAt"])) && (!Object.hasOwn(value, "statusChangedAt") || validate2(value["statusChangedAt"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"])) && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "previousStatus") || validate1337(value["previousStatus"]));
224
- const validate1324 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^treg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
225
- const validate1325 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^tmpl_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
226
- const validate1326 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^tpub_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
227
- const validate1327 = (value) => validate1328(value) || validate1331(value);
228
- const validate1328 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "provider") && Object.hasOwn(value, "wabaId") && (!Object.hasOwn(value, "provider") || validate1329(value["provider"])) && (!Object.hasOwn(value, "wabaId") || validate2(value["wabaId"]));
229
- const validate1329 = (value) => typeof value === "string" && value === "whatsapp";
230
- const validate1331 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "provider") && Object.hasOwn(value, "entityId") && Object.hasOwn(value, "headerId") && (!Object.hasOwn(value, "provider") || validate1332(value["provider"])) && (!Object.hasOwn(value, "entityId") || validate2(value["entityId"])) && (!Object.hasOwn(value, "headerId") || validate2(value["headerId"]));
231
- const validate1332 = (value) => typeof value === "string" && value === "dlt";
232
- const validate1337 = (value) => typeof value === "string" && (value === "draft" || value === "submitted" || value === "approved" || value === "rejected" || value === "paused" || value === "disabled");
233
- const validate1338 = (value) => typeof value === "string" && (value === "marketing" || value === "utility" || value === "authentication" || value === "transactional" || value === "service_implicit" || value === "service_explicit" || value === "promotional");
234
- const validate1339 = (value) => validate1338(value) || validate6(value);
235
- const validate1356 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1357(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1359(value["data"]));
236
- const validate1357 = (value) => typeof value === "string" && value === "flow.registration.updated";
237
- const validate1359 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "flowId") && Object.hasOwn(value, "versionId") && Object.hasOwn(value, "versionNumber") && Object.hasOwn(value, "wabaId") && Object.hasOwn(value, "providerFlowId") && Object.hasOwn(value, "name") && Object.hasOwn(value, "status") && Object.hasOwn(value, "validationErrors") && Object.hasOwn(value, "publishedAt") && Object.hasOwn(value, "statusChangedAt") && Object.hasOwn(value, "createdAt") && Object.hasOwn(value, "updatedAt") && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "previousStatus") && (!Object.hasOwn(value, "id") || validate1360(value["id"])) && (!Object.hasOwn(value, "flowId") || validate737(value["flowId"])) && (!Object.hasOwn(value, "versionId") || validate742(value["versionId"])) && (!Object.hasOwn(value, "versionNumber") || validate1265(value["versionNumber"])) && (!Object.hasOwn(value, "wabaId") || validate2(value["wabaId"])) && (!Object.hasOwn(value, "providerFlowId") || validate8(value["providerFlowId"])) && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "status") || validate1369(value["status"])) && (!Object.hasOwn(value, "validationErrors") || validate1370(value["validationErrors"])) && (!Object.hasOwn(value, "publishedAt") || validate8(value["publishedAt"])) && (!Object.hasOwn(value, "statusChangedAt") || validate2(value["statusChangedAt"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"])) && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "previousStatus") || validate1384(value["previousStatus"]));
238
- const validate1360 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^wafreg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
239
- const validate1369 = (value) => typeof value === "string" && (value === "draft" || value === "published" || value === "throttled" || value === "blocked" || value === "deprecated");
240
- const validate1370 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate1371);
241
- const validate1371 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "error") && Object.hasOwn(value, "message") && (!Object.hasOwn(value, "error") || validate2(value["error"])) && (!Object.hasOwn(value, "message") || validate2(value["message"])) && (!Object.hasOwn(value, "path") || validate2(value["path"])) && (!Object.hasOwn(value, "line") || validate1265(value["line"])) && (!Object.hasOwn(value, "column") || validate1265(value["column"]));
242
- const validate1384 = (value) => validate1369(value) || validate6(value);
243
- const validate1387 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1388(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1390(value["data"]));
244
- const validate1388 = (value) => typeof value === "string" && value === "mailbox.message.received";
245
- const validate1390 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "message") && Object.hasOwn(value, "thread") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1392(value["namespaceId"])) && (!Object.hasOwn(value, "message") || validate1395(value["message"])) && (!Object.hasOwn(value, "thread") || validate1424(value["thread"]));
246
- const validate1392 = (value) => validate1393(value) || validate6(value);
247
- const validate1393 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^ns_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
248
- const validate1395 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "from") && Object.hasOwn(value, "to") && Object.hasOwn(value, "cc") && Object.hasOwn(value, "subject") && Object.hasOwn(value, "text") && Object.hasOwn(value, "replyText") && Object.hasOwn(value, "attachments") && Object.hasOwn(value, "occurredAt") && (!Object.hasOwn(value, "id") || validate769(value["id"])) && (!Object.hasOwn(value, "channel") || validate1397(value["channel"])) && (!Object.hasOwn(value, "threadId") || validate1398(value["threadId"])) && (!Object.hasOwn(value, "from") || validate1399(value["from"])) && (!Object.hasOwn(value, "to") || validate45(value["to"])) && (!Object.hasOwn(value, "cc") || validate45(value["cc"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "text") || validate8(value["text"])) && (!Object.hasOwn(value, "replyText") || validate8(value["replyText"])) && (!Object.hasOwn(value, "attachments") || validate1417(value["attachments"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"]));
249
- const validate1397 = (value) => typeof value === "string" && (value === "email" || value === "whatsapp" || value === "sms");
250
- const validate1398 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^thread_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
251
- const validate1399 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "address") && (!Object.hasOwn(value, "address") || validate2(value["address"])) && (!Object.hasOwn(value, "name") || validate8(value["name"]));
252
- const validate1417 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate1418);
253
- const validate1418 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "filename") && Object.hasOwn(value, "contentType") && Object.hasOwn(value, "size") && (!Object.hasOwn(value, "id") || validate1419(value["id"])) && (!Object.hasOwn(value, "filename") || validate2(value["filename"])) && (!Object.hasOwn(value, "contentType") || validate2(value["contentType"])) && (!Object.hasOwn(value, "size") || validate15(value["size"]));
254
- const validate1419 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^att_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
255
- const validate1424 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "subject") && Object.hasOwn(value, "preview") && (!Object.hasOwn(value, "id") || validate1398(value["id"])) && (!Object.hasOwn(value, "endpointId") || validate1426(value["endpointId"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "preview") || validate8(value["preview"]));
256
- const validate1426 = (value) => validate1427(value) || validate6(value);
257
- const validate1427 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mbxep_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
258
- const validate1435 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1436(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1438(value["data"]));
259
- const validate1436 = (value) => typeof value === "string" && value === "mailbox.message.sent";
260
- const validate1438 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "actionId") && Object.hasOwn(value, "actor") && Object.hasOwn(value, "message") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1392(value["namespaceId"])) && (!Object.hasOwn(value, "actionId") || validate1443(value["actionId"])) && (!Object.hasOwn(value, "state") || validate1444(value["state"])) && (!Object.hasOwn(value, "acceptedAt") || validate2(value["acceptedAt"])) && (!Object.hasOwn(value, "actor") || validate1446(value["actor"])) && (!Object.hasOwn(value, "message") || validate1395(value["message"]));
261
- const validate1443 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
262
- const validate1444 = (value) => typeof value === "string" && value === "completed";
263
- const validate1446 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "kind") && Object.hasOwn(value, "id") && Object.hasOwn(value, "source") && (!Object.hasOwn(value, "kind") || validate1447(value["kind"])) && (!Object.hasOwn(value, "id") || validate2(value["id"])) && (!Object.hasOwn(value, "displayName") || validate8(value["displayName"])) && (!Object.hasOwn(value, "source") || validate1452(value["source"]));
264
- const validate1447 = (value) => typeof value === "string" && (value === "user" || value === "apiKey" || value === "extension" || value === "externalAgent" || value === "samvaAgent" || value === "system");
265
- const validate1452 = (value) => typeof value === "string" && (value === "humanUi" || value === "externalApi" || value === "externalAgent" || value === "extension" || value === "system");
266
- const validate1482 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1483(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1485(value["data"]));
267
- const validate1483 = (value) => typeof value === "string" && value === "mailbox.action.pending_approval";
268
- const validate1485 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "action") && Object.hasOwn(value, "draft") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1392(value["namespaceId"])) && (!Object.hasOwn(value, "action") || validate1490(value["action"])) && (!Object.hasOwn(value, "draft") || validate1520(value["draft"]));
269
- const validate1490 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "type") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "reason") && Object.hasOwn(value, "proposedBy") && Object.hasOwn(value, "createdAt") && (!Object.hasOwn(value, "id") || validate1443(value["id"])) && (!Object.hasOwn(value, "type") || validate1492(value["type"])) && (!Object.hasOwn(value, "state") || validate1493(value["state"])) && (!Object.hasOwn(value, "decision") || validate1494(value["decision"])) && (!Object.hasOwn(value, "threadId") || validate1506(value["threadId"])) && (!Object.hasOwn(value, "reason") || validate8(value["reason"])) && (!Object.hasOwn(value, "proposedBy") || validate1446(value["proposedBy"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"]));
270
- const validate1492 = (value) => typeof value === "string" && (value === "sendMessage" || value === "reply" || value === "updateDraft" || value === "createNote" || value === "assignThread" || value === "changeThreadState" || value === "call" || value === "extensionRequest");
271
- const validate1493 = (value) => typeof value === "string" && value === "approvalRequired";
272
- const validate1494 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "outcome") && Object.hasOwn(value, "reason") && Object.hasOwn(value, "policyId") && Object.hasOwn(value, "source") && Object.hasOwn(value, "decidedAt") && (!Object.hasOwn(value, "outcome") || validate1495(value["outcome"])) && (!Object.hasOwn(value, "reason") || validate8(value["reason"])) && (!Object.hasOwn(value, "policyId") || validate1499(value["policyId"])) && (!Object.hasOwn(value, "source") || validate1502(value["source"])) && (!Object.hasOwn(value, "decidedAt") || validate2(value["decidedAt"]));
273
- const validate1495 = (value) => typeof value === "string" && (value === "allow" || value === "requireApproval" || value === "deny");
274
- const validate1499 = (value) => validate1500(value) || validate6(value);
275
- const validate1500 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mbxpol_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
276
- const validate1502 = (value) => validate1503(value) || validate6(value);
277
- const validate1503 = (value) => typeof value === "string" && (value === "grant" || value === "installation" || value === "policy");
278
- const validate1506 = (value) => validate1398(value) || validate6(value);
279
- const validate1520 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "to") && Object.hasOwn(value, "cc") && Object.hasOwn(value, "subject") && (!Object.hasOwn(value, "to") || validate45(value["to"])) && (!Object.hasOwn(value, "cc") || validate45(value["cc"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"]));
280
- const validate1528 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1529(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1531(value["data"]));
281
- const validate1529 = (value) => typeof value === "string" && value === "mailbox.action.resolved";
282
- const validate1531 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "action") && Object.hasOwn(value, "resolution") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1392(value["namespaceId"])) && (!Object.hasOwn(value, "action") || validate1536(value["action"])) && (!Object.hasOwn(value, "resolution") || validate1550(value["resolution"]));
283
- const validate1536 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "type") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "proposedBy") && Object.hasOwn(value, "createdAt") && (!Object.hasOwn(value, "id") || validate1443(value["id"])) && (!Object.hasOwn(value, "type") || validate1492(value["type"])) && (!Object.hasOwn(value, "threadId") || validate1506(value["threadId"])) && (!Object.hasOwn(value, "proposedBy") || validate1446(value["proposedBy"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"]));
284
- const validate1550 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "outcome") && Object.hasOwn(value, "actor") && Object.hasOwn(value, "resolvedAt") && Object.hasOwn(value, "reason") && (!Object.hasOwn(value, "outcome") || validate1551(value["outcome"])) && (!Object.hasOwn(value, "actor") || validate1446(value["actor"])) && (!Object.hasOwn(value, "resolvedAt") || validate2(value["resolvedAt"])) && (!Object.hasOwn(value, "reason") || validate8(value["reason"]));
285
- const validate1551 = (value) => typeof value === "string" && (value === "approved" || value === "denied" || value === "cancelled");
286
- const validate1563 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1564(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1566(value["data"]));
287
- const validate1564 = (value) => typeof value === "string" && value === "mailbox.message.quarantined";
288
- const validate1566 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "disposition") && Object.hasOwn(value, "reason") && Object.hasOwn(value, "source") && Object.hasOwn(value, "message") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1392(value["namespaceId"])) && (!Object.hasOwn(value, "disposition") || validate1571(value["disposition"])) && (!Object.hasOwn(value, "reason") || validate1572(value["reason"])) && (!Object.hasOwn(value, "source") || validate1573(value["source"])) && (!Object.hasOwn(value, "message") || validate1574(value["message"]));
289
- const validate1571 = (value) => typeof value === "string" && (value === "quarantined" || value === "isolated");
290
- const validate1572 = (value) => typeof value === "string" && (value === "spam" || value === "dmarc" || value === "virus" || value === "virus_unscanned" || value === "phishing" || value === "fraud" || value === "prompt_injection");
291
- const validate1573 = (value) => typeof value === "string" && (value === "receipt" || value === "classifier");
292
- const validate1574 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "from") && Object.hasOwn(value, "subject") && Object.hasOwn(value, "receivedAt") && (!Object.hasOwn(value, "id") || validate769(value["id"])) && (!Object.hasOwn(value, "from") || validate1399(value["from"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "receivedAt") || validate2(value["receivedAt"]));
293
- const validate1585 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1586(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1588(value["data"]));
294
- const validate1586 = (value) => typeof value === "string" && value === "mailbox.message.released";
295
- const validate1588 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "releasedBy") && Object.hasOwn(value, "reason") && Object.hasOwn(value, "message") && Object.hasOwn(value, "thread") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1392(value["namespaceId"])) && (!Object.hasOwn(value, "releasedBy") || validate1446(value["releasedBy"])) && (!Object.hasOwn(value, "reason") || validate1572(value["reason"])) && (!Object.hasOwn(value, "message") || validate1395(value["message"])) && (!Object.hasOwn(value, "thread") || validate1424(value["thread"]));
296
- const validate1641 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1642(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1644(value["data"]));
297
- const validate1642 = (value) => typeof value === "string" && value === "mailbox.message.discarded";
298
- const validate1644 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "discardedBy") && Object.hasOwn(value, "disposition") && Object.hasOwn(value, "reason") && Object.hasOwn(value, "message") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1392(value["namespaceId"])) && (!Object.hasOwn(value, "discardedBy") || validate1446(value["discardedBy"])) && (!Object.hasOwn(value, "disposition") || validate1571(value["disposition"])) && (!Object.hasOwn(value, "reason") || validate1572(value["reason"])) && (!Object.hasOwn(value, "message") || validate1574(value["message"]));
299
- const validate1669 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1670(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1672(value["data"]));
300
- const validate1670 = (value) => typeof value === "string" && value === "journey.webhook";
301
- const validate1672 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "journeyId") && Object.hasOwn(value, "journeyVersion") && Object.hasOwn(value, "runId") && Object.hasOwn(value, "nodeId") && Object.hasOwn(value, "contact") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "organizationId") || validate841(value["organizationId"])) && (!Object.hasOwn(value, "journeyId") || validate1674(value["journeyId"])) && (!Object.hasOwn(value, "journeyVersion") || validate1265(value["journeyVersion"])) && (!Object.hasOwn(value, "runId") || validate1676(value["runId"])) && (!Object.hasOwn(value, "nodeId") || validate2(value["nodeId"])) && (!Object.hasOwn(value, "contact") || validate1678(value["contact"])) && (!Object.hasOwn(value, "data") || validate12(value["data"]));
302
- const validate1674 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^jrny_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
303
- const validate1676 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^jrun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
304
- const validate1678 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "externalId") && Object.hasOwn(value, "email") && (!Object.hasOwn(value, "id") || validate940(value["id"])) && (!Object.hasOwn(value, "externalId") || validate8(value["externalId"])) && (!Object.hasOwn(value, "email") || validate8(value["email"]));
305
- /** Narrow an event to a structurally valid payload known to this package. */
306
- const isKnownEvent = (value) => {
307
- switch (value.type) {
308
- case "message.sent": return validate0(value);
309
- case "message.delivered": return validate86(value);
310
- case "message.read": return validate172(value);
311
- case "message.failed": return validate258(value);
312
- case "message.bounced": return validate344(value);
313
- case "message.complained": return validate426(value);
314
- case "message.received": return validate508(value);
315
- case "message.opened": return validate836(value);
316
- case "message.clicked": return validate884(value);
317
- case "contact.created": return validate936(value);
318
- case "contact.updated": return validate962(value);
319
- case "contact.deleted": return validate988(value);
320
- case "contact.subscribed": return validate1014(value);
321
- case "contact.unsubscribed": return validate1048(value);
322
- case "contact.resubscribed": return validate1082(value);
323
- case "contact.consent_changed": return validate1116(value);
324
- case "conversation.created": return validate1133(value);
325
- case "conversation.updated": return validate1155(value);
326
- case "conversation.archived": return validate1177(value);
327
- case "webhook.created": return validate1199(value);
328
- case "webhook.updated": return validate1216(value);
329
- case "webhook.deleted": return validate1233(value);
330
- case "webhook.test": return validate1250(value);
331
- case "domain.updated": return validate1254(value);
332
- case "domain.warming.updated": return validate1296(value);
333
- case "template.registration.updated": return validate1320(value);
334
- case "flow.registration.updated": return validate1356(value);
335
- case "mailbox.message.received": return validate1387(value);
336
- case "mailbox.message.sent": return validate1435(value);
337
- case "mailbox.action.pending_approval": return validate1482(value);
338
- case "mailbox.action.resolved": return validate1528(value);
339
- case "mailbox.message.quarantined": return validate1563(value);
340
- case "mailbox.message.released": return validate1585(value);
341
- case "mailbox.message.discarded": return validate1641(value);
342
- case "journey.webhook": return validate1669(value);
343
- default: return false;
344
- }
345
- };
346
- const validateEvent = (value) => {
347
- if (!isObject(value) || typeof value.type !== "string" || typeof value.timestamp !== "string" || !Object.hasOwn(value, "data")) return false;
348
- switch (value.type) {
349
- case "message.sent": return validate0(value);
350
- case "message.delivered": return validate86(value);
351
- case "message.read": return validate172(value);
352
- case "message.failed": return validate258(value);
353
- case "message.bounced": return validate344(value);
354
- case "message.complained": return validate426(value);
355
- case "message.received": return validate508(value);
356
- case "message.opened": return validate836(value);
357
- case "message.clicked": return validate884(value);
358
- case "contact.created": return validate936(value);
359
- case "contact.updated": return validate962(value);
360
- case "contact.deleted": return validate988(value);
361
- case "contact.subscribed": return validate1014(value);
362
- case "contact.unsubscribed": return validate1048(value);
363
- case "contact.resubscribed": return validate1082(value);
364
- case "contact.consent_changed": return validate1116(value);
365
- case "conversation.created": return validate1133(value);
366
- case "conversation.updated": return validate1155(value);
367
- case "conversation.archived": return validate1177(value);
368
- case "webhook.created": return validate1199(value);
369
- case "webhook.updated": return validate1216(value);
370
- case "webhook.deleted": return validate1233(value);
371
- case "webhook.test": return validate1250(value);
372
- case "domain.updated": return validate1254(value);
373
- case "domain.warming.updated": return validate1296(value);
374
- case "template.registration.updated": return validate1320(value);
375
- case "flow.registration.updated": return validate1356(value);
376
- case "mailbox.message.received": return validate1387(value);
377
- case "mailbox.message.sent": return validate1435(value);
378
- case "mailbox.action.pending_approval": return validate1482(value);
379
- case "mailbox.action.resolved": return validate1528(value);
380
- case "mailbox.message.quarantined": return validate1563(value);
381
- case "mailbox.message.released": return validate1585(value);
382
- case "mailbox.message.discarded": return validate1641(value);
383
- case "journey.webhook": return validate1669(value);
384
- default: return true;
385
- }
386
- };
387
- //#endregion
388
- //#region src/errors.ts
389
- /**
390
- * Base class for every failure this package reports while verifying a webhook delivery.
391
- *
392
- * Each subclass carries a literal `_tag` (also used as `name`), so you can branch on the failure
393
- * with a `switch` or Effect's `catchTag`. `detail` is a human-readable reason for your logs; do not
394
- * echo it to the sender, and do not match on its wording.
395
- */
396
- var WebhookVerificationError = class extends Error {
397
- /** Discriminant naming the concrete failure; equal to the subclass name. */
398
- _tag;
399
- /** Human-readable reason for logs. The wording is not a stable contract. */
400
- detail;
401
- constructor(tag, options) {
402
- super(options.detail);
403
- this.name = tag;
404
- this._tag = tag;
405
- this.detail = options.detail;
406
- }
407
- };
408
- /**
409
- * The signing secret is unusable: it lacks the `whsec_` prefix, the remainder is not Base64, or
410
- * the decoded key length is outside the accepted range (`detail` names the range). This is a
411
- * configuration error on the receiving side, not a bad delivery; copy the endpoint's signing
412
- * secret from Samva again.
413
- */
414
- var InvalidWebhookSecretError = class extends WebhookVerificationError {
415
- constructor(options) {
416
- super("InvalidWebhookSecretError", options);
417
- }
418
- };
419
- /**
420
- * One of the `webhook-id`, `webhook-timestamp`, or `webhook-signature` headers is missing or
421
- * empty; `header` names it. The request is not a Samva delivery, or something between Samva and
422
- * your handler stripped the headers.
423
- */
424
- var InvalidWebhookHeadersError = class extends WebhookVerificationError {
425
- /** The first signing header, in id, timestamp, signature order, that is missing or empty. */
426
- header;
427
- constructor(options) {
428
- super("InvalidWebhookHeadersError", options);
429
- this.header = options.header;
430
- }
431
- };
432
- /**
433
- * The `webhook-timestamp` header is not an integer count of Unix seconds, it lies further from the
434
- * current time than the replay tolerance, or the tolerance you passed is negative or not finite.
435
- * A delivery outside the tolerance is rejected even when its signature is valid; that bounds how
436
- * long a captured request can be replayed. Repeated failures on genuine deliveries usually mean
437
- * the receiving server's clock is wrong.
438
- */
439
- var WebhookTimestampError = class extends WebhookVerificationError {
440
- constructor(options) {
441
- super("WebhookTimestampError", options);
442
- }
443
- };
444
- /**
445
- * No signature in the `webhook-signature` header matches the delivery, or no verification key was
446
- * supplied. Treat the request as forged and reject it. When genuine deliveries fail, the usual
447
- * causes are the wrong endpoint secret or a body that was parsed and re-serialized before
448
- * verification instead of passed through as the exact bytes received.
449
- */
450
- var WebhookSignatureError = class extends WebhookVerificationError {
451
- constructor(options) {
452
- super("WebhookSignatureError", options);
453
- }
454
- };
455
- /**
456
- * The signature is valid, but the body is not UTF-8 JSON holding exactly the `type`,
457
- * `timestamp`, and `data` fields of a Samva event envelope.
458
- */
459
- var MalformedWebhookPayloadError = class extends WebhookVerificationError {
460
- constructor(options) {
461
- super("MalformedWebhookPayloadError", options);
462
- }
463
- };
464
- /**
465
- * The runtime's Web Crypto implementation could not import a key or compute a signature, none of
466
- * the supplied public keys could be imported, or the Effect entrypoint could not read the request
467
- * body. Points at the runtime or its configuration rather than at the delivery.
468
- */
469
- var WebhookCryptoError = class extends WebhookVerificationError {
470
- constructor(options) {
471
- super("WebhookCryptoError", options);
472
- }
473
- };
474
- //#endregion
475
- //#region src/protocol.ts
476
- /**
477
- * Header carrying the delivery's unique message ID. Retries of the same delivery reuse it, so it
478
- * is the key for deduplicating deliveries you have already handled.
479
- */
480
- const WEBHOOK_ID_HEADER = "webhook-id";
481
- /** Header carrying the time Samva signed the delivery, as integer Unix seconds. */
482
- const WEBHOOK_TIMESTAMP_HEADER = "webhook-timestamp";
483
- /**
484
- * Header carrying one or more space-separated `<version>,<base64 signature>` entries. More than one
485
- * entry appears while a signing secret is being rotated; a delivery verifies when any entry of the
486
- * expected version matches.
487
- */
488
- const WEBHOOK_SIGNATURE_HEADER = "webhook-signature";
489
- /**
490
- * Replay tolerance, in seconds, used when a caller passes no `toleranceSeconds`. A delivery whose
491
- * `webhook-timestamp` differs from the current time by more than this, in either direction, is
492
- * rejected with {@link WebhookTimestampError}.
493
- */
494
- const DEFAULT_TOLERANCE_SECONDS = 300;
495
- const SECRET_PREFIX = "whsec_";
496
- const ASYMMETRIC_ALGORITHM = {
497
- name: "RSASSA-PKCS1-v1_5",
498
- hash: "SHA-256"
499
- };
500
- const MINIMUM_SECRET_BYTES = 24;
501
- const MAXIMUM_SECRET_BYTES = 64;
502
- const GENERATED_SECRET_BYTES = 32;
503
- const encoder = new TextEncoder();
504
- const toBytes = (body) => typeof body === "string" ? encoder.encode(body) : body;
505
- const toCryptoBytes = (bytes) => new Uint8Array(bytes);
506
- const bytesToBase64 = (bytes) => {
507
- let binary = "";
508
- for (const byte of bytes) binary += String.fromCharCode(byte);
509
- return btoa(binary);
510
- };
511
- const base64ToBytes = (encoded) => {
512
- const binary = atob(encoded);
513
- return Uint8Array.from(binary, (character) => character.charCodeAt(0));
514
- };
515
- const decodeSecret = (secret) => {
516
- if (!secret.startsWith(SECRET_PREFIX)) throw new InvalidWebhookSecretError({ detail: "Webhook secret must start with whsec_" });
517
- const decoded = (() => {
518
- try {
519
- return base64ToBytes(secret.slice(6));
520
- } catch {
521
- throw new InvalidWebhookSecretError({ detail: "Webhook secret is not valid Base64" });
522
- }
523
- })();
524
- if (decoded.byteLength < MINIMUM_SECRET_BYTES || decoded.byteLength > MAXIMUM_SECRET_BYTES) throw new InvalidWebhookSecretError({ detail: `Webhook secret must decode to ${MINIMUM_SECRET_BYTES}-${MAXIMUM_SECRET_BYTES} bytes` });
525
- return decoded;
526
- };
527
- const importHmacKey = async (secret) => {
528
- const secretBytes = decodeSecret(secret);
529
- try {
530
- return await crypto.subtle.importKey("raw", toCryptoBytes(secretBytes), {
531
- name: "HMAC",
532
- hash: "SHA-256"
533
- }, false, ["sign"]);
534
- } catch (cause) {
535
- throw new WebhookCryptoError({ detail: `Unable to import webhook signing key: ${cause instanceof Error ? cause.message : String(cause)}` });
536
- }
537
- };
538
- const importVerificationKey = async (publicKey) => {
539
- try {
540
- return await crypto.subtle.importKey("spki", toCryptoBytes(base64ToBytes(publicKey.trim())), ASYMMETRIC_ALGORITHM, false, ["verify"]);
541
- } catch {
542
- return;
543
- }
544
- };
545
- const signedBytes = (id, timestamp, body) => {
546
- const prefix = encoder.encode(`${id}.${timestamp}.`);
547
- const material = new Uint8Array(prefix.byteLength + body.byteLength);
548
- material.set(prefix);
549
- material.set(body, prefix.byteLength);
550
- return material;
551
- };
552
- const hmac = async (secret, id, timestamp, body) => {
553
- const key = await importHmacKey(secret);
554
- try {
555
- return new Uint8Array(await crypto.subtle.sign("HMAC", key, toCryptoBytes(signedBytes(id, timestamp, body))));
556
- } catch (cause) {
557
- throw new WebhookCryptoError({ detail: `Unable to sign webhook: ${cause instanceof Error ? cause.message : String(cause)}` });
558
- }
559
- };
560
- const asymmetricMatch = async (key, candidate, content) => {
561
- try {
562
- return await crypto.subtle.verify(ASYMMETRIC_ALGORITHM, key, toCryptoBytes(candidate), content);
563
- } catch {
564
- return false;
565
- }
566
- };
567
- const timingSafeEqual = (left, right) => {
568
- if (left.byteLength !== right.byteLength) return false;
569
- let difference = 0;
570
- for (let index = 0; index < left.byteLength; index += 1) difference |= (left[index] ?? 0) ^ (right[index] ?? 0);
571
- return difference === 0;
572
- };
573
- const signatureCandidates = (header, expected) => header.split(" ").map((candidate) => candidate.split(",", 2)).flatMap(([version, encoded]) => {
574
- if (version !== expected || encoded === void 0) return [];
575
- try {
576
- return [base64ToBytes(encoded)];
577
- } catch {
578
- return [];
579
- }
580
- });
581
- const parseEvent = (body) => {
582
- try {
583
- const parsed = JSON.parse(new TextDecoder("utf-8", {
584
- fatal: true,
585
- ignoreBOM: false
586
- }).decode(body));
587
- if (!validateEvent(parsed)) throw new MalformedWebhookPayloadError({ detail: "Webhook event does not match its payload schema" });
588
- return parsed;
589
- } catch {
590
- throw new MalformedWebhookPayloadError({ detail: "Webhook body must be valid UTF-8 JSON matching a Samva event payload schema" });
591
- }
592
- };
593
- /**
594
- * Creates a random `whsec_`-prefixed signing secret from the runtime's secure random source.
595
- * Samva issues each endpoint's secret for you; use this to sign test deliveries with
596
- * {@link signWebhook}.
597
- */
598
- const generateWebhookSecret = () => {
599
- const bytes = crypto.getRandomValues(new Uint8Array(GENERATED_SECRET_BYTES));
600
- return `${SECRET_PREFIX}${bytesToBase64(bytes)}`;
601
- };
602
- /**
603
- * Builds the bytes every signature version covers: `<id>.<timestamp>.<body>`. Use it to verify a
604
- * signature with your own crypto code; {@link verifyWebhookAt} and
605
- * {@link verifyWebhookAtWithPublicKeys} build it for you.
606
- */
607
- const webhookSignedContent = (input) => signedBytes(input.id, input.timestamp, toBytes(input.body));
608
- /** Formats raw signature bytes as one `<version>,<base64>` entry of the `webhook-signature` header. */
609
- const encodeWebhookSignature = (version, signature) => `${version},${bytesToBase64(signature)}`;
610
- /**
611
- * Computes the `v1` HMAC-SHA256 signature Samva sends, formatted as one `webhook-signature`
612
- * entry. Use it to produce signed test deliveries for your handler.
613
- *
614
- * `timestamp` is Unix seconds; a number is stringified, and the verifier requires an integer.
615
- * Rejects with {@link InvalidWebhookSecretError} for an unusable secret and
616
- * {@link WebhookCryptoError} when Web Crypto fails.
617
- */
618
- const signWebhook = async (input) => {
619
- const timestamp = String(input.timestamp);
620
- const signature = await hmac(input.secret, input.id, timestamp, toBytes(input.body));
621
- return encodeWebhookSignature("v1", signature);
622
- };
623
- const requireHeader = (header, value) => {
624
- if (value === null || value === void 0) throw new InvalidWebhookHeadersError({
625
- header,
626
- detail: `${header} header is missing`
627
- });
628
- if (value.length === 0) throw new InvalidWebhookHeadersError({
629
- header,
630
- detail: `${header} header is empty`
631
- });
632
- return value;
633
- };
634
- const requireHeaders = (values) => ({
635
- id: requireHeader(WEBHOOK_ID_HEADER, values.id),
636
- timestamp: requireHeader(WEBHOOK_TIMESTAMP_HEADER, values.timestamp),
637
- signature: requireHeader(WEBHOOK_SIGNATURE_HEADER, values.signature)
638
- });
639
- const freshHeaders = (input) => {
640
- const { id, timestamp, signature } = requireHeaders(input.headers);
641
- const timestampSeconds = Number(timestamp);
642
- if (!Number.isInteger(timestampSeconds)) throw new WebhookTimestampError({ detail: "webhook-timestamp must be Unix seconds" });
643
- const toleranceSeconds = input.toleranceSeconds ?? 300;
644
- if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) throw new WebhookTimestampError({ detail: "Webhook tolerance must be non-negative" });
645
- if (Math.abs(input.nowMilliseconds / 1e3 - timestampSeconds) > toleranceSeconds) throw new WebhookTimestampError({ detail: "Webhook timestamp is outside the replay tolerance" });
646
- return {
647
- id,
648
- timestamp,
649
- signature
650
- };
651
- };
652
- /**
653
- * Verifies a `v1` (HMAC-SHA256) delivery against an explicit current time. The `verify` and
654
- * `verifyRequest` entry points call this with the current clock; call it directly when your
655
- * framework owns the clock or a test needs a fixed time.
656
- *
657
- * Checks, in order: all three headers are present and non-empty; the timestamp is integer Unix seconds within
658
- * `toleranceSeconds` of `nowMilliseconds`; some `v1` entry in the signature header matches, using
659
- * a constant-time comparison; the body has a valid envelope and known event payloads match their schema. Unknown event types pass
660
- * through with untyped data. The replay window rejects stale
661
- * deliveries but does not detect a repeat inside it; deduplicate on the returned `id`.
662
- *
663
- * Rejects with {@link InvalidWebhookHeadersError}, {@link WebhookTimestampError},
664
- * {@link InvalidWebhookSecretError}, {@link WebhookSignatureError},
665
- * {@link MalformedWebhookPayloadError}, or {@link WebhookCryptoError}.
666
- */
667
- const verifyWebhookAt = async (input) => {
668
- const { id, timestamp, signature } = freshHeaders(input);
669
- const body = toBytes(input.body);
670
- const expected = await hmac(input.secret, id, timestamp, body);
671
- if (!signatureCandidates(signature, "v1").some((candidate) => timingSafeEqual(expected, candidate))) throw new WebhookSignatureError({ detail: "Webhook signature verification failed" });
672
- return {
673
- id,
674
- event: parseEvent(body)
675
- };
676
- };
677
- /**
678
- * Verifies a `v2` (RSASSA-PKCS1-v1_5, SHA-256) delivery against one or more public keys, each a
679
- * Base64-encoded SPKI DER key. Pass several keys during a key rotation; the delivery verifies when
680
- * any `v2` signature entry matches any key.
681
- *
682
- * Header, timestamp, and envelope checks match {@link verifyWebhookAt}. Keys that fail to import
683
- * are skipped. Rejects with {@link WebhookSignatureError} when `publicKeys` is empty or nothing
684
- * matches, and {@link WebhookCryptoError} when none of the keys imports.
685
- */
686
- const verifyWebhookAtWithPublicKeys = async (input) => {
687
- const { id, timestamp, signature } = freshHeaders(input);
688
- if (input.publicKeys.length === 0) throw new WebhookSignatureError({ detail: "No webhook verification key is available" });
689
- const keys = (await Promise.all(input.publicKeys.map(importVerificationKey))).filter((key) => key !== void 0);
690
- if (keys.length === 0) throw new WebhookCryptoError({ detail: "Unable to import any webhook verification key: keys must be Base64 SPKI DER" });
691
- const body = toBytes(input.body);
692
- const content = toCryptoBytes(signedBytes(id, timestamp, body));
693
- const candidates = signatureCandidates(signature, "v2");
694
- if (!(await Promise.all(keys.flatMap((key) => candidates.map((candidate) => asymmetricMatch(key, candidate, content))))).includes(true)) throw new WebhookSignatureError({ detail: "Webhook signature verification failed" });
695
- return {
696
- id,
697
- event: parseEvent(body)
698
- };
699
- };
700
- /**
701
- * Reads the three signing headers from a Fetch API `Headers` object, for code that needs a header
702
- * value, such as the timestamp, before or beside verification. Throws
703
- * {@link InvalidWebhookHeadersError}, naming the header, when one is missing or empty; call it
704
- * inside the same error handling as the verification that follows.
705
- */
706
- const readWebhookHeaders = (headers) => requireHeaders({
707
- id: headers.get(WEBHOOK_ID_HEADER),
708
- timestamp: headers.get(WEBHOOK_TIMESTAMP_HEADER),
709
- signature: headers.get(WEBHOOK_SIGNATURE_HEADER)
710
- });
711
- //#endregion
712
- export { WebhookTimestampError as _, encodeWebhookSignature as a, signWebhook as c, webhookSignedContent as d, InvalidWebhookHeadersError as f, WebhookSignatureError as g, WebhookCryptoError as h, WEBHOOK_TIMESTAMP_HEADER as i, verifyWebhookAt as l, MalformedWebhookPayloadError as m, WEBHOOK_ID_HEADER as n, generateWebhookSecret as o, InvalidWebhookSecretError as p, WEBHOOK_SIGNATURE_HEADER as r, readWebhookHeaders as s, DEFAULT_TOLERANCE_SECONDS as t, verifyWebhookAtWithPublicKeys as u, WebhookVerificationError as v, isKnownEvent as y };
713
-
714
- //# sourceMappingURL=protocol-BSGksDha.js.map