@samva/webhooks 0.15.0 → 0.17.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.
- package/dist/effect.js +4 -4
- package/dist/{json-schemas.gen-eya_ZDps.js → json-schemas.gen-DC_ZmYw2.js} +872 -5
- package/dist/promise.js +2 -2
- package/dist/protocol-GkuvvobW.js +679 -0
- package/dist/protocol.js +1 -1
- package/dist/schemas.gen.d.ts +486 -0
- package/dist/schemas.gen.js +407 -2
- package/dist/types.gen.d.ts +351 -1
- package/package.json +1 -1
- package/dist/protocol-CLrYczjc.js +0 -570
|
@@ -0,0 +1,679 @@
|
|
|
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") || validate730(value["media"])) && (!Object.hasOwn(value, "reaction") || validate753(value["reaction"])) && (!Object.hasOwn(value, "location") || validate761(value["location"])) && (!Object.hasOwn(value, "contacts") || validate767(value["contacts"])) && (!Object.hasOwn(value, "reply") || validate803(value["reply"])) && (!Object.hasOwn(value, "context") || validate808(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);
|
|
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) => validate731(value) || validate6(value);
|
|
97
|
+
const validate731 = (value) => validate732(value) || validate737(value) || validate742(value);
|
|
98
|
+
const validate732 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "url") && (!Object.hasOwn(value, "type") || validate733(value["type"])) && (!Object.hasOwn(value, "url") || validate2(value["url"])) && (!Object.hasOwn(value, "caption") || validate2(value["caption"])) && (!Object.hasOwn(value, "filename") || validate2(value["filename"]));
|
|
99
|
+
const validate733 = (value) => typeof value === "string" && (value === "image" || value === "video" || value === "audio" || value === "document" || value === "sticker");
|
|
100
|
+
const validate737 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "mediaId") && (!Object.hasOwn(value, "type") || validate733(value["type"])) && (!Object.hasOwn(value, "mediaId") || validate658(value["mediaId"])) && (!Object.hasOwn(value, "caption") || validate2(value["caption"])) && (!Object.hasOwn(value, "filename") || validate2(value["filename"]));
|
|
101
|
+
const validate742 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "providerMediaId") && (!Object.hasOwn(value, "type") || validate733(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"]));
|
|
102
|
+
const validate753 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "providerMessageId") && Object.hasOwn(value, "emoji") && (!Object.hasOwn(value, "messageId") || validate754(value["messageId"])) && (!Object.hasOwn(value, "providerMessageId") || validate2(value["providerMessageId"])) && (!Object.hasOwn(value, "emoji") || validate8(value["emoji"]));
|
|
103
|
+
const validate754 = (value) => validate755(value) || validate6(value);
|
|
104
|
+
const validate755 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^msg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
105
|
+
const validate761 = (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"]));
|
|
106
|
+
const validate767 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate768);
|
|
107
|
+
const validate768 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "name") || validate769(value["name"])) && (!Object.hasOwn(value, "phones") || validate776(value["phones"])) && (!Object.hasOwn(value, "emails") || validate781(value["emails"])) && (!Object.hasOwn(value, "urls") || validate785(value["urls"])) && (!Object.hasOwn(value, "org") || validate789(value["org"])) && (!Object.hasOwn(value, "addresses") || validate793(value["addresses"])) && (!Object.hasOwn(value, "birthday") || validate2(value["birthday"]));
|
|
108
|
+
const validate769 = (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"]));
|
|
109
|
+
const validate776 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate777);
|
|
110
|
+
const validate777 = (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"]));
|
|
111
|
+
const validate781 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate782);
|
|
112
|
+
const validate782 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "email") || validate2(value["email"])) && (!Object.hasOwn(value, "type") || validate2(value["type"]));
|
|
113
|
+
const validate785 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate786);
|
|
114
|
+
const validate786 = (value) => isObject(value) && isObject(value) && (!Object.hasOwn(value, "url") || validate2(value["url"])) && (!Object.hasOwn(value, "type") || validate2(value["type"]));
|
|
115
|
+
const validate789 = (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"]));
|
|
116
|
+
const validate793 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate794);
|
|
117
|
+
const validate794 = (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"]));
|
|
118
|
+
const validate803 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "id") && Object.hasOwn(value, "title") && (!Object.hasOwn(value, "type") || validate804(value["type"])) && (!Object.hasOwn(value, "id") || validate2(value["id"])) && (!Object.hasOwn(value, "title") || validate2(value["title"])) && (!Object.hasOwn(value, "description") || validate2(value["description"]));
|
|
119
|
+
const validate804 = (value) => typeof value === "string" && (value === "button" || value === "list" || value === "template_button");
|
|
120
|
+
const validate808 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "providerMessageId") && (!Object.hasOwn(value, "messageId") || validate754(value["messageId"])) && (!Object.hasOwn(value, "providerMessageId") || validate2(value["providerMessageId"]));
|
|
121
|
+
const validate816 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate817(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate819(value["data"]));
|
|
122
|
+
const validate817 = (value) => typeof value === "string" && value === "message.opened";
|
|
123
|
+
const validate819 = (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") || validate755(value["messageId"])) && (!Object.hasOwn(value, "organizationId") || validate821(value["organizationId"])) && (!Object.hasOwn(value, "channel") || validate822(value["channel"])) && (!Object.hasOwn(value, "deliveryId") || validate823(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") || validate834(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") || validate858(value["campaignId"])) && (!Object.hasOwn(value, "campaignRunId") || validate861(value["campaignRunId"]));
|
|
124
|
+
const validate821 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^org_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
125
|
+
const validate822 = (value) => typeof value === "string" && value === "email";
|
|
126
|
+
const validate823 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mdel_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
127
|
+
const validate834 = (value) => validate835(value) || validate6(value);
|
|
128
|
+
const validate835 = (value) => typeof value === "string" && (value === "google-image-proxy" || value === "apple-mail-privacy" || value === "scanner-user-agent" || value === "scanner-asn" || value === "too-fast");
|
|
129
|
+
const validate858 = (value) => validate859(value) || validate6(value);
|
|
130
|
+
const validate859 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^camp_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
131
|
+
const validate861 = (value) => validate862(value) || validate6(value);
|
|
132
|
+
const validate862 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^crun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
133
|
+
const validate864 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate865(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate867(value["data"]));
|
|
134
|
+
const validate865 = (value) => typeof value === "string" && value === "message.clicked";
|
|
135
|
+
const validate867 = (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") || validate755(value["messageId"])) && (!Object.hasOwn(value, "organizationId") || validate821(value["organizationId"])) && (!Object.hasOwn(value, "channel") || validate822(value["channel"])) && (!Object.hasOwn(value, "deliveryId") || validate823(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") || validate881(value["linkTags"])) && (!Object.hasOwn(value, "firstClick") || validate33(value["firstClick"])) && (!Object.hasOwn(value, "machine") || validate33(value["machine"])) && (!Object.hasOwn(value, "machineReason") || validate834(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") || validate858(value["campaignId"])) && (!Object.hasOwn(value, "campaignRunId") || validate861(value["campaignRunId"]));
|
|
136
|
+
const validate881 = (value) => isObject(value) && isObject(value) && Object.entries(value).every(([key, item]) => validate45(item));
|
|
137
|
+
const validate916 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate917(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate919(value["data"]));
|
|
138
|
+
const validate917 = (value) => typeof value === "string" && value === "contact.created";
|
|
139
|
+
const validate919 = (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") || validate920(value["contactId"])) && (!Object.hasOwn(value, "status") || validate921(value["status"])) && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "displayName") || validate923(value["displayName"])) && (!Object.hasOwn(value, "identities") || validate928(value["identities"])) && (!Object.hasOwn(value, "tags") || validate45(value["tags"])) && (!Object.hasOwn(value, "externalId") || validate923(value["externalId"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
|
|
140
|
+
const validate920 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^contact_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
141
|
+
const validate921 = (value) => typeof value === "string" && (value === "active" || value === "paused" || value === "blocked" || value === "archived");
|
|
142
|
+
const validate923 = (value) => validate8(value) || validate6(value);
|
|
143
|
+
const validate928 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate929);
|
|
144
|
+
const validate929 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "channel") && Object.hasOwn(value, "identifier") && Object.hasOwn(value, "verified") && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "identifier") || validate2(value["identifier"])) && (!Object.hasOwn(value, "verified") || validate33(value["verified"]));
|
|
145
|
+
const validate942 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate943(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate919(value["data"]));
|
|
146
|
+
const validate943 = (value) => typeof value === "string" && value === "contact.updated";
|
|
147
|
+
const validate968 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate969(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate919(value["data"]));
|
|
148
|
+
const validate969 = (value) => typeof value === "string" && value === "contact.deleted";
|
|
149
|
+
const validate994 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate995(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate997(value["data"]));
|
|
150
|
+
const validate995 = (value) => typeof value === "string" && value === "contact.subscribed";
|
|
151
|
+
const validate997 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "organizationId") && Object.hasOwn(value, "contactId") && Object.hasOwn(value, "email") && Object.hasOwn(value, "groupId") && Object.hasOwn(value, "groupName") && Object.hasOwn(value, "source") && Object.hasOwn(value, "occurredAt") && (!Object.hasOwn(value, "organizationId") || validate821(value["organizationId"])) && (!Object.hasOwn(value, "contactId") || validate8(value["contactId"])) && (!Object.hasOwn(value, "email") || validate2(value["email"])) && (!Object.hasOwn(value, "groupId") || validate2(value["groupId"])) && (!Object.hasOwn(value, "groupName") || validate2(value["groupName"])) && (!Object.hasOwn(value, "contactGroupId") || validate1005(value["contactGroupId"])) && (!Object.hasOwn(value, "unsubscribeGroupId") || validate1008(value["unsubscribeGroupId"])) && (!Object.hasOwn(value, "consentIp") || validate8(value["consentIp"])) && (!Object.hasOwn(value, "consentSource") || validate8(value["consentSource"])) && (!Object.hasOwn(value, "source") || validate1017(value["source"])) && (!Object.hasOwn(value, "messageId") || validate754(value["messageId"])) && (!Object.hasOwn(value, "campaignId") || validate858(value["campaignId"])) && (!Object.hasOwn(value, "campaignRunId") || validate861(value["campaignRunId"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"]));
|
|
152
|
+
const validate1005 = (value) => validate1006(value) || validate6(value);
|
|
153
|
+
const validate1006 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^cgrp_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
154
|
+
const validate1008 = (value) => validate1009(value) || validate6(value);
|
|
155
|
+
const validate1009 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^unsub_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
156
|
+
const validate1017 = (value) => typeof value === "string" && (value === "link" || value === "api" || value === "manual" || value === "complaint");
|
|
157
|
+
const validate1028 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1029(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate997(value["data"]));
|
|
158
|
+
const validate1029 = (value) => typeof value === "string" && value === "contact.unsubscribed";
|
|
159
|
+
const validate1062 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1063(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate997(value["data"]));
|
|
160
|
+
const validate1063 = (value) => typeof value === "string" && value === "contact.resubscribed";
|
|
161
|
+
const validate1096 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1097(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1099(value["data"]));
|
|
162
|
+
const validate1097 = (value) => typeof value === "string" && value === "conversation.created";
|
|
163
|
+
const validate1099 = (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") || validate1100(value["conversationId"])) && (!Object.hasOwn(value, "organizationId") || validate821(value["organizationId"])) && (!Object.hasOwn(value, "title") || validate923(value["title"])) && (!Object.hasOwn(value, "channels") || validate1107(value["channels"])) && (!Object.hasOwn(value, "primaryChannel") || validate7(value["primaryChannel"])) && (!Object.hasOwn(value, "status") || validate1110(value["status"])) && (!Object.hasOwn(value, "primaryContactId") || validate1111(value["primaryContactId"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
|
|
164
|
+
const validate1100 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^conv_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
165
|
+
const validate1107 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate7);
|
|
166
|
+
const validate1110 = (value) => typeof value === "string" && (value === "active" || value === "waiting" || value === "resolved" || value === "escalated" || value === "archived");
|
|
167
|
+
const validate1111 = (value) => validate1112(value) || validate6(value);
|
|
168
|
+
const validate1112 = (value) => validate920(value) || validate6(value);
|
|
169
|
+
const validate1118 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1119(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1099(value["data"]));
|
|
170
|
+
const validate1119 = (value) => typeof value === "string" && value === "conversation.updated";
|
|
171
|
+
const validate1140 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1141(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1099(value["data"]));
|
|
172
|
+
const validate1141 = (value) => typeof value === "string" && value === "conversation.archived";
|
|
173
|
+
const validate1162 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1163(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1165(value["data"]));
|
|
174
|
+
const validate1163 = (value) => typeof value === "string" && value === "webhook.created";
|
|
175
|
+
const validate1165 = (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") || validate1166(value["webhookId"])) && (!Object.hasOwn(value, "organizationId") || validate821(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") || validate1176(value["status"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
|
|
176
|
+
const validate1166 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^wep_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
177
|
+
const validate1176 = (value) => typeof value === "string" && (value === "active" || value === "disabled");
|
|
178
|
+
const validate1179 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1180(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1165(value["data"]));
|
|
179
|
+
const validate1180 = (value) => typeof value === "string" && value === "webhook.updated";
|
|
180
|
+
const validate1196 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1197(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1165(value["data"]));
|
|
181
|
+
const validate1197 = (value) => typeof value === "string" && value === "webhook.deleted";
|
|
182
|
+
const validate1213 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1214(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate12(value["data"]));
|
|
183
|
+
const validate1214 = (value) => typeof value === "string" && value === "webhook.test";
|
|
184
|
+
const validate1217 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1218(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1220(value["data"]));
|
|
185
|
+
const validate1218 = (value) => typeof value === "string" && value === "domain.updated";
|
|
186
|
+
const validate1220 = (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") || validate1221(value["domainId"])) && (!Object.hasOwn(value, "organizationId") || validate821(value["organizationId"])) && (!Object.hasOwn(value, "domain") || validate2(value["domain"])) && (!Object.hasOwn(value, "previousPhase") || validate1224(value["previousPhase"])) && (!Object.hasOwn(value, "phase") || validate1224(value["phase"])) && (!Object.hasOwn(value, "dns") || validate1226(value["dns"])) && (!Object.hasOwn(value, "provider") || validate1233(value["provider"])) && (!Object.hasOwn(value, "operationId") || validate1243(value["operationId"])) && (!Object.hasOwn(value, "checkedAt") || validate8(value["checkedAt"])) && (!Object.hasOwn(value, "nextCheckAt") || validate8(value["nextCheckAt"])) && (!Object.hasOwn(value, "failure") || validate1252(value["failure"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
|
|
187
|
+
const validate1221 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^dom_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
188
|
+
const validate1224 = (value) => typeof value === "string" && (value === "dns-setup" || value === "provisioning" || value === "verifying" || value === "ready" || value === "degraded" || value === "failed");
|
|
189
|
+
const validate1226 = (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") || validate1228(value["total"])) && (!Object.hasOwn(value, "satisfied") || validate1228(value["satisfied"])) && (!Object.hasOwn(value, "missing") || validate1228(value["missing"])) && (!Object.hasOwn(value, "mismatch") || validate1228(value["mismatch"])) && (!Object.hasOwn(value, "unknown") || validate1228(value["unknown"]));
|
|
190
|
+
const validate1228 = (value) => typeof value === "number" && Number.isInteger(value);
|
|
191
|
+
const validate1233 = (value) => validate1234(value) || validate6(value);
|
|
192
|
+
const validate1234 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "identity") && (!Object.hasOwn(value, "identity") || validate1235(value["identity"])) && (!Object.hasOwn(value, "dkim") || validate1236(value["dkim"])) && (!Object.hasOwn(value, "mailFrom") || validate1236(value["mailFrom"]));
|
|
193
|
+
const validate1235 = (value) => typeof value === "string" && (value === "pending" || value === "verified" || value === "failed" || value === "unknown");
|
|
194
|
+
const validate1236 = (value) => validate1235(value) || validate6(value);
|
|
195
|
+
const validate1243 = (value) => validate1244(value) || validate6(value);
|
|
196
|
+
const validate1244 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^op_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
197
|
+
const validate1252 = (value) => validate1253(value) || validate6(value);
|
|
198
|
+
const validate1253 = (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"]));
|
|
199
|
+
const validate1259 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1260(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1262(value["data"]));
|
|
200
|
+
const validate1260 = (value) => typeof value === "string" && value === "domain.warming.updated";
|
|
201
|
+
const validate1262 = (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") || validate1267(value["reason"])) && (!Object.hasOwn(value, "status") || validate1268(value["status"])) && (!Object.hasOwn(value, "holdReason") || validate8(value["holdReason"])) && (!Object.hasOwn(value, "batch") || validate1272(value["batch"])) && (!Object.hasOwn(value, "updatedAt") || validate2(value["updatedAt"]));
|
|
202
|
+
const validate1267 = (value) => typeof value === "string" && (value === "plan-created" || value === "policy-updated" || value === "window-opened" || value === "window-cancelled" || value === "paused" || value === "resumed" || value === "held" || value === "completed");
|
|
203
|
+
const validate1268 = (value) => typeof value === "string" && (value === "active" || value === "paused" || value === "completed");
|
|
204
|
+
const validate1272 = (value) => validate1273(value) || validate6(value);
|
|
205
|
+
const validate1273 = (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"]));
|
|
206
|
+
const validate1283 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1284(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1286(value["data"]));
|
|
207
|
+
const validate1284 = (value) => typeof value === "string" && value === "template.registration.updated";
|
|
208
|
+
const validate1286 = (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") || validate1287(value["id"])) && (!Object.hasOwn(value, "templateId") || validate1288(value["templateId"])) && (!Object.hasOwn(value, "publicationId") || validate1289(value["publicationId"])) && (!Object.hasOwn(value, "target") || validate1290(value["target"])) && (!Object.hasOwn(value, "name") || validate2(value["name"])) && (!Object.hasOwn(value, "language") || validate2(value["language"])) && (!Object.hasOwn(value, "status") || validate1300(value["status"])) && (!Object.hasOwn(value, "category") || validate1301(value["category"])) && (!Object.hasOwn(value, "providerCategory") || validate1302(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") || validate821(value["organizationId"])) && (!Object.hasOwn(value, "previousStatus") || validate1300(value["previousStatus"]));
|
|
209
|
+
const validate1287 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^treg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
210
|
+
const validate1288 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^tmpl_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
211
|
+
const validate1289 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^tpub_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
212
|
+
const validate1290 = (value) => validate1291(value) || validate1294(value);
|
|
213
|
+
const validate1291 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "provider") && Object.hasOwn(value, "wabaId") && (!Object.hasOwn(value, "provider") || validate1292(value["provider"])) && (!Object.hasOwn(value, "wabaId") || validate2(value["wabaId"]));
|
|
214
|
+
const validate1292 = (value) => typeof value === "string" && value === "whatsapp";
|
|
215
|
+
const validate1294 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "provider") && Object.hasOwn(value, "entityId") && Object.hasOwn(value, "headerId") && (!Object.hasOwn(value, "provider") || validate1295(value["provider"])) && (!Object.hasOwn(value, "entityId") || validate2(value["entityId"])) && (!Object.hasOwn(value, "headerId") || validate2(value["headerId"]));
|
|
216
|
+
const validate1295 = (value) => typeof value === "string" && value === "dlt";
|
|
217
|
+
const validate1300 = (value) => typeof value === "string" && (value === "draft" || value === "submitted" || value === "approved" || value === "rejected" || value === "paused" || value === "disabled");
|
|
218
|
+
const validate1301 = (value) => typeof value === "string" && (value === "marketing" || value === "utility" || value === "authentication" || value === "transactional" || value === "service_implicit" || value === "service_explicit" || value === "promotional");
|
|
219
|
+
const validate1302 = (value) => validate1301(value) || validate6(value);
|
|
220
|
+
const validate1319 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1320(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1322(value["data"]));
|
|
221
|
+
const validate1320 = (value) => typeof value === "string" && value === "mailbox.message.received";
|
|
222
|
+
const validate1322 = (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") || validate1324(value["namespaceId"])) && (!Object.hasOwn(value, "message") || validate1327(value["message"])) && (!Object.hasOwn(value, "thread") || validate1356(value["thread"]));
|
|
223
|
+
const validate1324 = (value) => validate1325(value) || validate6(value);
|
|
224
|
+
const validate1325 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^ns_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
225
|
+
const validate1327 = (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") || validate755(value["id"])) && (!Object.hasOwn(value, "channel") || validate1329(value["channel"])) && (!Object.hasOwn(value, "threadId") || validate1330(value["threadId"])) && (!Object.hasOwn(value, "from") || validate1331(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") || validate1349(value["attachments"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"]));
|
|
226
|
+
const validate1329 = (value) => typeof value === "string" && (value === "email" || value === "whatsapp" || value === "sms");
|
|
227
|
+
const validate1330 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^thread_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
228
|
+
const validate1331 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "address") && (!Object.hasOwn(value, "address") || validate2(value["address"])) && (!Object.hasOwn(value, "name") || validate8(value["name"]));
|
|
229
|
+
const validate1349 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate1350);
|
|
230
|
+
const validate1350 = (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") || validate1351(value["id"])) && (!Object.hasOwn(value, "filename") || validate2(value["filename"])) && (!Object.hasOwn(value, "contentType") || validate2(value["contentType"])) && (!Object.hasOwn(value, "size") || validate15(value["size"]));
|
|
231
|
+
const validate1351 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^att_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
232
|
+
const validate1356 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "subject") && Object.hasOwn(value, "preview") && (!Object.hasOwn(value, "id") || validate1330(value["id"])) && (!Object.hasOwn(value, "endpointId") || validate1358(value["endpointId"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "preview") || validate8(value["preview"]));
|
|
233
|
+
const validate1358 = (value) => validate1359(value) || validate6(value);
|
|
234
|
+
const validate1359 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mbxep_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
235
|
+
const validate1367 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1368(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1370(value["data"]));
|
|
236
|
+
const validate1368 = (value) => typeof value === "string" && value === "mailbox.message.sent";
|
|
237
|
+
const validate1370 = (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") || validate1324(value["namespaceId"])) && (!Object.hasOwn(value, "actionId") || validate1375(value["actionId"])) && (!Object.hasOwn(value, "state") || validate1376(value["state"])) && (!Object.hasOwn(value, "acceptedAt") || validate2(value["acceptedAt"])) && (!Object.hasOwn(value, "actor") || validate1378(value["actor"])) && (!Object.hasOwn(value, "message") || validate1327(value["message"]));
|
|
238
|
+
const validate1375 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
239
|
+
const validate1376 = (value) => typeof value === "string" && value === "completed";
|
|
240
|
+
const validate1378 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "kind") && Object.hasOwn(value, "id") && Object.hasOwn(value, "source") && (!Object.hasOwn(value, "kind") || validate1379(value["kind"])) && (!Object.hasOwn(value, "id") || validate2(value["id"])) && (!Object.hasOwn(value, "displayName") || validate8(value["displayName"])) && (!Object.hasOwn(value, "source") || validate1384(value["source"]));
|
|
241
|
+
const validate1379 = (value) => typeof value === "string" && (value === "user" || value === "apiKey" || value === "extension" || value === "externalAgent" || value === "samvaAgent" || value === "system");
|
|
242
|
+
const validate1384 = (value) => typeof value === "string" && (value === "humanUi" || value === "externalApi" || value === "externalAgent" || value === "extension" || value === "system");
|
|
243
|
+
const validate1414 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1415(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1417(value["data"]));
|
|
244
|
+
const validate1415 = (value) => typeof value === "string" && value === "mailbox.action.pending_approval";
|
|
245
|
+
const validate1417 = (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") || validate1324(value["namespaceId"])) && (!Object.hasOwn(value, "action") || validate1422(value["action"])) && (!Object.hasOwn(value, "draft") || validate1452(value["draft"]));
|
|
246
|
+
const validate1422 = (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") || validate1375(value["id"])) && (!Object.hasOwn(value, "type") || validate1424(value["type"])) && (!Object.hasOwn(value, "state") || validate1425(value["state"])) && (!Object.hasOwn(value, "decision") || validate1426(value["decision"])) && (!Object.hasOwn(value, "threadId") || validate1438(value["threadId"])) && (!Object.hasOwn(value, "reason") || validate8(value["reason"])) && (!Object.hasOwn(value, "proposedBy") || validate1378(value["proposedBy"])) && (!Object.hasOwn(value, "createdAt") || validate2(value["createdAt"]));
|
|
247
|
+
const validate1424 = (value) => typeof value === "string" && (value === "sendMessage" || value === "reply" || value === "updateDraft" || value === "createNote" || value === "assignThread" || value === "changeThreadState" || value === "call" || value === "extensionRequest");
|
|
248
|
+
const validate1425 = (value) => typeof value === "string" && value === "approvalRequired";
|
|
249
|
+
const validate1426 = (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") || validate1427(value["outcome"])) && (!Object.hasOwn(value, "reason") || validate8(value["reason"])) && (!Object.hasOwn(value, "policyId") || validate1431(value["policyId"])) && (!Object.hasOwn(value, "source") || validate1434(value["source"])) && (!Object.hasOwn(value, "decidedAt") || validate2(value["decidedAt"]));
|
|
250
|
+
const validate1427 = (value) => typeof value === "string" && (value === "allow" || value === "requireApproval" || value === "deny");
|
|
251
|
+
const validate1431 = (value) => validate1432(value) || validate6(value);
|
|
252
|
+
const validate1432 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^mbxpol_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
253
|
+
const validate1434 = (value) => validate1435(value) || validate6(value);
|
|
254
|
+
const validate1435 = (value) => typeof value === "string" && (value === "grant" || value === "installation" || value === "policy");
|
|
255
|
+
const validate1438 = (value) => validate1330(value) || validate6(value);
|
|
256
|
+
const validate1452 = (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"]));
|
|
257
|
+
const validate1460 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1461(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1463(value["data"]));
|
|
258
|
+
const validate1461 = (value) => typeof value === "string" && value === "mailbox.message.quarantined";
|
|
259
|
+
const validate1463 = (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") || validate1324(value["namespaceId"])) && (!Object.hasOwn(value, "disposition") || validate1468(value["disposition"])) && (!Object.hasOwn(value, "reason") || validate1469(value["reason"])) && (!Object.hasOwn(value, "source") || validate1470(value["source"])) && (!Object.hasOwn(value, "message") || validate1471(value["message"]));
|
|
260
|
+
const validate1468 = (value) => typeof value === "string" && (value === "quarantined" || value === "isolated");
|
|
261
|
+
const validate1469 = (value) => typeof value === "string" && (value === "spam" || value === "dmarc" || value === "virus" || value === "virus_unscanned" || value === "phishing" || value === "fraud" || value === "prompt_injection");
|
|
262
|
+
const validate1470 = (value) => typeof value === "string" && (value === "receipt" || value === "classifier");
|
|
263
|
+
const validate1471 = (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") || validate755(value["id"])) && (!Object.hasOwn(value, "from") || validate1331(value["from"])) && (!Object.hasOwn(value, "subject") || validate8(value["subject"])) && (!Object.hasOwn(value, "receivedAt") || validate2(value["receivedAt"]));
|
|
264
|
+
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"]));
|
|
265
|
+
const validate1483 = (value) => typeof value === "string" && value === "mailbox.message.released";
|
|
266
|
+
const validate1485 = (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") || validate1324(value["namespaceId"])) && (!Object.hasOwn(value, "releasedBy") || validate1378(value["releasedBy"])) && (!Object.hasOwn(value, "reason") || validate1469(value["reason"])) && (!Object.hasOwn(value, "message") || validate1327(value["message"])) && (!Object.hasOwn(value, "thread") || validate1356(value["thread"]));
|
|
267
|
+
const validate1538 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1539(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1541(value["data"]));
|
|
268
|
+
const validate1539 = (value) => typeof value === "string" && value === "mailbox.message.discarded";
|
|
269
|
+
const validate1541 = (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") || validate1324(value["namespaceId"])) && (!Object.hasOwn(value, "discardedBy") || validate1378(value["discardedBy"])) && (!Object.hasOwn(value, "disposition") || validate1468(value["disposition"])) && (!Object.hasOwn(value, "reason") || validate1469(value["reason"])) && (!Object.hasOwn(value, "message") || validate1471(value["message"]));
|
|
270
|
+
const validate1566 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1567(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1569(value["data"]));
|
|
271
|
+
const validate1567 = (value) => typeof value === "string" && value === "journey.webhook";
|
|
272
|
+
const validate1569 = (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") || validate821(value["organizationId"])) && (!Object.hasOwn(value, "journeyId") || validate1571(value["journeyId"])) && (!Object.hasOwn(value, "journeyVersion") || validate1228(value["journeyVersion"])) && (!Object.hasOwn(value, "runId") || validate1573(value["runId"])) && (!Object.hasOwn(value, "nodeId") || validate2(value["nodeId"])) && (!Object.hasOwn(value, "contact") || validate1575(value["contact"])) && (!Object.hasOwn(value, "data") || validate12(value["data"]));
|
|
273
|
+
const validate1571 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^jrny_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
274
|
+
const validate1573 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^jrun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
275
|
+
const validate1575 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "id") && Object.hasOwn(value, "externalId") && Object.hasOwn(value, "email") && (!Object.hasOwn(value, "id") || validate920(value["id"])) && (!Object.hasOwn(value, "externalId") || validate8(value["externalId"])) && (!Object.hasOwn(value, "email") || validate8(value["email"]));
|
|
276
|
+
/** Narrow an event to a structurally valid payload known to this package. */
|
|
277
|
+
const isKnownEvent = (value) => {
|
|
278
|
+
switch (value.type) {
|
|
279
|
+
case "message.sent": return validate0(value);
|
|
280
|
+
case "message.delivered": return validate86(value);
|
|
281
|
+
case "message.read": return validate172(value);
|
|
282
|
+
case "message.failed": return validate258(value);
|
|
283
|
+
case "message.bounced": return validate344(value);
|
|
284
|
+
case "message.complained": return validate426(value);
|
|
285
|
+
case "message.received": return validate508(value);
|
|
286
|
+
case "message.opened": return validate816(value);
|
|
287
|
+
case "message.clicked": return validate864(value);
|
|
288
|
+
case "contact.created": return validate916(value);
|
|
289
|
+
case "contact.updated": return validate942(value);
|
|
290
|
+
case "contact.deleted": return validate968(value);
|
|
291
|
+
case "contact.subscribed": return validate994(value);
|
|
292
|
+
case "contact.unsubscribed": return validate1028(value);
|
|
293
|
+
case "contact.resubscribed": return validate1062(value);
|
|
294
|
+
case "conversation.created": return validate1096(value);
|
|
295
|
+
case "conversation.updated": return validate1118(value);
|
|
296
|
+
case "conversation.archived": return validate1140(value);
|
|
297
|
+
case "webhook.created": return validate1162(value);
|
|
298
|
+
case "webhook.updated": return validate1179(value);
|
|
299
|
+
case "webhook.deleted": return validate1196(value);
|
|
300
|
+
case "webhook.test": return validate1213(value);
|
|
301
|
+
case "domain.updated": return validate1217(value);
|
|
302
|
+
case "domain.warming.updated": return validate1259(value);
|
|
303
|
+
case "template.registration.updated": return validate1283(value);
|
|
304
|
+
case "mailbox.message.received": return validate1319(value);
|
|
305
|
+
case "mailbox.message.sent": return validate1367(value);
|
|
306
|
+
case "mailbox.action.pending_approval": return validate1414(value);
|
|
307
|
+
case "mailbox.message.quarantined": return validate1460(value);
|
|
308
|
+
case "mailbox.message.released": return validate1482(value);
|
|
309
|
+
case "mailbox.message.discarded": return validate1538(value);
|
|
310
|
+
case "journey.webhook": return validate1566(value);
|
|
311
|
+
default: return false;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
const validateEvent = (value) => {
|
|
315
|
+
if (!isObject(value) || typeof value.type !== "string" || typeof value.timestamp !== "string" || !Object.hasOwn(value, "data")) return false;
|
|
316
|
+
switch (value.type) {
|
|
317
|
+
case "message.sent": return validate0(value);
|
|
318
|
+
case "message.delivered": return validate86(value);
|
|
319
|
+
case "message.read": return validate172(value);
|
|
320
|
+
case "message.failed": return validate258(value);
|
|
321
|
+
case "message.bounced": return validate344(value);
|
|
322
|
+
case "message.complained": return validate426(value);
|
|
323
|
+
case "message.received": return validate508(value);
|
|
324
|
+
case "message.opened": return validate816(value);
|
|
325
|
+
case "message.clicked": return validate864(value);
|
|
326
|
+
case "contact.created": return validate916(value);
|
|
327
|
+
case "contact.updated": return validate942(value);
|
|
328
|
+
case "contact.deleted": return validate968(value);
|
|
329
|
+
case "contact.subscribed": return validate994(value);
|
|
330
|
+
case "contact.unsubscribed": return validate1028(value);
|
|
331
|
+
case "contact.resubscribed": return validate1062(value);
|
|
332
|
+
case "conversation.created": return validate1096(value);
|
|
333
|
+
case "conversation.updated": return validate1118(value);
|
|
334
|
+
case "conversation.archived": return validate1140(value);
|
|
335
|
+
case "webhook.created": return validate1162(value);
|
|
336
|
+
case "webhook.updated": return validate1179(value);
|
|
337
|
+
case "webhook.deleted": return validate1196(value);
|
|
338
|
+
case "webhook.test": return validate1213(value);
|
|
339
|
+
case "domain.updated": return validate1217(value);
|
|
340
|
+
case "domain.warming.updated": return validate1259(value);
|
|
341
|
+
case "template.registration.updated": return validate1283(value);
|
|
342
|
+
case "mailbox.message.received": return validate1319(value);
|
|
343
|
+
case "mailbox.message.sent": return validate1367(value);
|
|
344
|
+
case "mailbox.action.pending_approval": return validate1414(value);
|
|
345
|
+
case "mailbox.message.quarantined": return validate1460(value);
|
|
346
|
+
case "mailbox.message.released": return validate1482(value);
|
|
347
|
+
case "mailbox.message.discarded": return validate1538(value);
|
|
348
|
+
case "journey.webhook": return validate1566(value);
|
|
349
|
+
default: return true;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/errors.ts
|
|
354
|
+
/**
|
|
355
|
+
* Base class for every failure this package reports while verifying a webhook delivery.
|
|
356
|
+
*
|
|
357
|
+
* Each subclass carries a literal `_tag` (also used as `name`), so you can branch on the failure
|
|
358
|
+
* with a `switch` or Effect's `catchTag`. `detail` is a human-readable reason for your logs; do not
|
|
359
|
+
* echo it to the sender, and do not match on its wording.
|
|
360
|
+
*/
|
|
361
|
+
var WebhookVerificationError = class extends Error {
|
|
362
|
+
/** Discriminant naming the concrete failure; equal to the subclass name. */
|
|
363
|
+
_tag;
|
|
364
|
+
/** Human-readable reason for logs. The wording is not a stable contract. */
|
|
365
|
+
detail;
|
|
366
|
+
constructor(tag, options) {
|
|
367
|
+
super(options.detail);
|
|
368
|
+
this.name = tag;
|
|
369
|
+
this._tag = tag;
|
|
370
|
+
this.detail = options.detail;
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* The signing secret is unusable: it lacks the `whsec_` prefix, the remainder is not Base64, or
|
|
375
|
+
* the decoded key length is outside the accepted range (`detail` names the range). This is a
|
|
376
|
+
* configuration error on the receiving side, not a bad delivery; copy the endpoint's signing
|
|
377
|
+
* secret from Samva again.
|
|
378
|
+
*/
|
|
379
|
+
var InvalidWebhookSecretError = class extends WebhookVerificationError {
|
|
380
|
+
constructor(options) {
|
|
381
|
+
super("InvalidWebhookSecretError", options);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* One of the `webhook-id`, `webhook-timestamp`, or `webhook-signature` headers is missing or
|
|
386
|
+
* empty; `header` names it. The request is not a Samva delivery, or something between Samva and
|
|
387
|
+
* your handler stripped the headers.
|
|
388
|
+
*/
|
|
389
|
+
var InvalidWebhookHeadersError = class extends WebhookVerificationError {
|
|
390
|
+
/** The first signing header, in id, timestamp, signature order, that is missing or empty. */
|
|
391
|
+
header;
|
|
392
|
+
constructor(options) {
|
|
393
|
+
super("InvalidWebhookHeadersError", options);
|
|
394
|
+
this.header = options.header;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* The `webhook-timestamp` header is not an integer count of Unix seconds, it lies further from the
|
|
399
|
+
* current time than the replay tolerance, or the tolerance you passed is negative or not finite.
|
|
400
|
+
* A delivery outside the tolerance is rejected even when its signature is valid; that bounds how
|
|
401
|
+
* long a captured request can be replayed. Repeated failures on genuine deliveries usually mean
|
|
402
|
+
* the receiving server's clock is wrong.
|
|
403
|
+
*/
|
|
404
|
+
var WebhookTimestampError = class extends WebhookVerificationError {
|
|
405
|
+
constructor(options) {
|
|
406
|
+
super("WebhookTimestampError", options);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* No signature in the `webhook-signature` header matches the delivery, or no verification key was
|
|
411
|
+
* supplied. Treat the request as forged and reject it. When genuine deliveries fail, the usual
|
|
412
|
+
* causes are the wrong endpoint secret or a body that was parsed and re-serialized before
|
|
413
|
+
* verification instead of passed through as the exact bytes received.
|
|
414
|
+
*/
|
|
415
|
+
var WebhookSignatureError = class extends WebhookVerificationError {
|
|
416
|
+
constructor(options) {
|
|
417
|
+
super("WebhookSignatureError", options);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* The signature is valid, but the body is not UTF-8 JSON holding exactly the `type`,
|
|
422
|
+
* `timestamp`, and `data` fields of a Samva event envelope.
|
|
423
|
+
*/
|
|
424
|
+
var MalformedWebhookPayloadError = class extends WebhookVerificationError {
|
|
425
|
+
constructor(options) {
|
|
426
|
+
super("MalformedWebhookPayloadError", options);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* The runtime's Web Crypto implementation could not import a key or compute a signature, none of
|
|
431
|
+
* the supplied public keys could be imported, or the Effect entrypoint could not read the request
|
|
432
|
+
* body. Points at the runtime or its configuration rather than at the delivery.
|
|
433
|
+
*/
|
|
434
|
+
var WebhookCryptoError = class extends WebhookVerificationError {
|
|
435
|
+
constructor(options) {
|
|
436
|
+
super("WebhookCryptoError", options);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/protocol.ts
|
|
441
|
+
/**
|
|
442
|
+
* Header carrying the delivery's unique message ID. Retries of the same delivery reuse it, so it
|
|
443
|
+
* is the key for deduplicating deliveries you have already handled.
|
|
444
|
+
*/
|
|
445
|
+
const WEBHOOK_ID_HEADER = "webhook-id";
|
|
446
|
+
/** Header carrying the time Samva signed the delivery, as integer Unix seconds. */
|
|
447
|
+
const WEBHOOK_TIMESTAMP_HEADER = "webhook-timestamp";
|
|
448
|
+
/**
|
|
449
|
+
* Header carrying one or more space-separated `<version>,<base64 signature>` entries. More than one
|
|
450
|
+
* entry appears while a signing secret is being rotated; a delivery verifies when any entry of the
|
|
451
|
+
* expected version matches.
|
|
452
|
+
*/
|
|
453
|
+
const WEBHOOK_SIGNATURE_HEADER = "webhook-signature";
|
|
454
|
+
/**
|
|
455
|
+
* Replay tolerance, in seconds, used when a caller passes no `toleranceSeconds`. A delivery whose
|
|
456
|
+
* `webhook-timestamp` differs from the current time by more than this, in either direction, is
|
|
457
|
+
* rejected with {@link WebhookTimestampError}.
|
|
458
|
+
*/
|
|
459
|
+
const DEFAULT_TOLERANCE_SECONDS = 300;
|
|
460
|
+
const SECRET_PREFIX = "whsec_";
|
|
461
|
+
const ASYMMETRIC_ALGORITHM = {
|
|
462
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
463
|
+
hash: "SHA-256"
|
|
464
|
+
};
|
|
465
|
+
const MINIMUM_SECRET_BYTES = 24;
|
|
466
|
+
const MAXIMUM_SECRET_BYTES = 64;
|
|
467
|
+
const GENERATED_SECRET_BYTES = 32;
|
|
468
|
+
const encoder = new TextEncoder();
|
|
469
|
+
const toBytes = (body) => typeof body === "string" ? encoder.encode(body) : body;
|
|
470
|
+
const toCryptoBytes = (bytes) => new Uint8Array(bytes);
|
|
471
|
+
const bytesToBase64 = (bytes) => {
|
|
472
|
+
let binary = "";
|
|
473
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
474
|
+
return btoa(binary);
|
|
475
|
+
};
|
|
476
|
+
const base64ToBytes = (encoded) => {
|
|
477
|
+
const binary = atob(encoded);
|
|
478
|
+
return Uint8Array.from(binary, (character) => character.charCodeAt(0));
|
|
479
|
+
};
|
|
480
|
+
const decodeSecret = (secret) => {
|
|
481
|
+
if (!secret.startsWith(SECRET_PREFIX)) throw new InvalidWebhookSecretError({ detail: "Webhook secret must start with whsec_" });
|
|
482
|
+
const decoded = (() => {
|
|
483
|
+
try {
|
|
484
|
+
return base64ToBytes(secret.slice(6));
|
|
485
|
+
} catch {
|
|
486
|
+
throw new InvalidWebhookSecretError({ detail: "Webhook secret is not valid Base64" });
|
|
487
|
+
}
|
|
488
|
+
})();
|
|
489
|
+
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` });
|
|
490
|
+
return decoded;
|
|
491
|
+
};
|
|
492
|
+
const importHmacKey = async (secret) => {
|
|
493
|
+
const secretBytes = decodeSecret(secret);
|
|
494
|
+
try {
|
|
495
|
+
return await crypto.subtle.importKey("raw", toCryptoBytes(secretBytes), {
|
|
496
|
+
name: "HMAC",
|
|
497
|
+
hash: "SHA-256"
|
|
498
|
+
}, false, ["sign"]);
|
|
499
|
+
} catch (cause) {
|
|
500
|
+
throw new WebhookCryptoError({ detail: `Unable to import webhook signing key: ${cause instanceof Error ? cause.message : String(cause)}` });
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
const importVerificationKey = async (publicKey) => {
|
|
504
|
+
try {
|
|
505
|
+
return await crypto.subtle.importKey("spki", toCryptoBytes(base64ToBytes(publicKey.trim())), ASYMMETRIC_ALGORITHM, false, ["verify"]);
|
|
506
|
+
} catch {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
const signedBytes = (id, timestamp, body) => {
|
|
511
|
+
const prefix = encoder.encode(`${id}.${timestamp}.`);
|
|
512
|
+
const material = new Uint8Array(prefix.byteLength + body.byteLength);
|
|
513
|
+
material.set(prefix);
|
|
514
|
+
material.set(body, prefix.byteLength);
|
|
515
|
+
return material;
|
|
516
|
+
};
|
|
517
|
+
const hmac = async (secret, id, timestamp, body) => {
|
|
518
|
+
const key = await importHmacKey(secret);
|
|
519
|
+
try {
|
|
520
|
+
return new Uint8Array(await crypto.subtle.sign("HMAC", key, toCryptoBytes(signedBytes(id, timestamp, body))));
|
|
521
|
+
} catch (cause) {
|
|
522
|
+
throw new WebhookCryptoError({ detail: `Unable to sign webhook: ${cause instanceof Error ? cause.message : String(cause)}` });
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
const asymmetricMatch = async (key, candidate, content) => {
|
|
526
|
+
try {
|
|
527
|
+
return await crypto.subtle.verify(ASYMMETRIC_ALGORITHM, key, toCryptoBytes(candidate), content);
|
|
528
|
+
} catch {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
const timingSafeEqual = (left, right) => {
|
|
533
|
+
if (left.byteLength !== right.byteLength) return false;
|
|
534
|
+
let difference = 0;
|
|
535
|
+
for (let index = 0; index < left.byteLength; index += 1) difference |= (left[index] ?? 0) ^ (right[index] ?? 0);
|
|
536
|
+
return difference === 0;
|
|
537
|
+
};
|
|
538
|
+
const signatureCandidates = (header, expected) => header.split(" ").map((candidate) => candidate.split(",", 2)).flatMap(([version, encoded]) => {
|
|
539
|
+
if (version !== expected || encoded === void 0) return [];
|
|
540
|
+
try {
|
|
541
|
+
return [base64ToBytes(encoded)];
|
|
542
|
+
} catch {
|
|
543
|
+
return [];
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
const parseEvent = (body) => {
|
|
547
|
+
try {
|
|
548
|
+
const parsed = JSON.parse(new TextDecoder("utf-8", {
|
|
549
|
+
fatal: true,
|
|
550
|
+
ignoreBOM: false
|
|
551
|
+
}).decode(body));
|
|
552
|
+
if (!validateEvent(parsed)) throw new MalformedWebhookPayloadError({ detail: "Webhook event does not match its payload schema" });
|
|
553
|
+
return parsed;
|
|
554
|
+
} catch {
|
|
555
|
+
throw new MalformedWebhookPayloadError({ detail: "Webhook body must be valid UTF-8 JSON matching a Samva event payload schema" });
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* Creates a random `whsec_`-prefixed signing secret from the runtime's secure random source.
|
|
560
|
+
* Samva issues each endpoint's secret for you; use this to sign test deliveries with
|
|
561
|
+
* {@link signWebhook}.
|
|
562
|
+
*/
|
|
563
|
+
const generateWebhookSecret = () => {
|
|
564
|
+
const bytes = crypto.getRandomValues(new Uint8Array(GENERATED_SECRET_BYTES));
|
|
565
|
+
return `${SECRET_PREFIX}${bytesToBase64(bytes)}`;
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Builds the bytes every signature version covers: `<id>.<timestamp>.<body>`. Use it to verify a
|
|
569
|
+
* signature with your own crypto code; {@link verifyWebhookAt} and
|
|
570
|
+
* {@link verifyWebhookAtWithPublicKeys} build it for you.
|
|
571
|
+
*/
|
|
572
|
+
const webhookSignedContent = (input) => signedBytes(input.id, input.timestamp, toBytes(input.body));
|
|
573
|
+
/** Formats raw signature bytes as one `<version>,<base64>` entry of the `webhook-signature` header. */
|
|
574
|
+
const encodeWebhookSignature = (version, signature) => `${version},${bytesToBase64(signature)}`;
|
|
575
|
+
/**
|
|
576
|
+
* Computes the `v1` HMAC-SHA256 signature Samva sends, formatted as one `webhook-signature`
|
|
577
|
+
* entry. Use it to produce signed test deliveries for your handler.
|
|
578
|
+
*
|
|
579
|
+
* `timestamp` is Unix seconds; a number is stringified, and the verifier requires an integer.
|
|
580
|
+
* Rejects with {@link InvalidWebhookSecretError} for an unusable secret and
|
|
581
|
+
* {@link WebhookCryptoError} when Web Crypto fails.
|
|
582
|
+
*/
|
|
583
|
+
const signWebhook = async (input) => {
|
|
584
|
+
const timestamp = String(input.timestamp);
|
|
585
|
+
const signature = await hmac(input.secret, input.id, timestamp, toBytes(input.body));
|
|
586
|
+
return encodeWebhookSignature("v1", signature);
|
|
587
|
+
};
|
|
588
|
+
const requireHeader = (header, value) => {
|
|
589
|
+
if (value === null || value === void 0) throw new InvalidWebhookHeadersError({
|
|
590
|
+
header,
|
|
591
|
+
detail: `${header} header is missing`
|
|
592
|
+
});
|
|
593
|
+
if (value.length === 0) throw new InvalidWebhookHeadersError({
|
|
594
|
+
header,
|
|
595
|
+
detail: `${header} header is empty`
|
|
596
|
+
});
|
|
597
|
+
return value;
|
|
598
|
+
};
|
|
599
|
+
const requireHeaders = (values) => ({
|
|
600
|
+
id: requireHeader(WEBHOOK_ID_HEADER, values.id),
|
|
601
|
+
timestamp: requireHeader(WEBHOOK_TIMESTAMP_HEADER, values.timestamp),
|
|
602
|
+
signature: requireHeader(WEBHOOK_SIGNATURE_HEADER, values.signature)
|
|
603
|
+
});
|
|
604
|
+
const freshHeaders = (input) => {
|
|
605
|
+
const { id, timestamp, signature } = requireHeaders(input.headers);
|
|
606
|
+
const timestampSeconds = Number(timestamp);
|
|
607
|
+
if (!Number.isInteger(timestampSeconds)) throw new WebhookTimestampError({ detail: "webhook-timestamp must be Unix seconds" });
|
|
608
|
+
const toleranceSeconds = input.toleranceSeconds ?? 300;
|
|
609
|
+
if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) throw new WebhookTimestampError({ detail: "Webhook tolerance must be non-negative" });
|
|
610
|
+
if (Math.abs(input.nowMilliseconds / 1e3 - timestampSeconds) > toleranceSeconds) throw new WebhookTimestampError({ detail: "Webhook timestamp is outside the replay tolerance" });
|
|
611
|
+
return {
|
|
612
|
+
id,
|
|
613
|
+
timestamp,
|
|
614
|
+
signature
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
/**
|
|
618
|
+
* Verifies a `v1` (HMAC-SHA256) delivery against an explicit current time. The `verify` and
|
|
619
|
+
* `verifyRequest` entry points call this with the current clock; call it directly when your
|
|
620
|
+
* framework owns the clock or a test needs a fixed time.
|
|
621
|
+
*
|
|
622
|
+
* Checks, in order: all three headers are present and non-empty; the timestamp is integer Unix seconds within
|
|
623
|
+
* `toleranceSeconds` of `nowMilliseconds`; some `v1` entry in the signature header matches, using
|
|
624
|
+
* a constant-time comparison; the body has a valid envelope and known event payloads match their schema. Unknown event types pass
|
|
625
|
+
* through with untyped data. The replay window rejects stale
|
|
626
|
+
* deliveries but does not detect a repeat inside it; deduplicate on the returned `id`.
|
|
627
|
+
*
|
|
628
|
+
* Rejects with {@link InvalidWebhookHeadersError}, {@link WebhookTimestampError},
|
|
629
|
+
* {@link InvalidWebhookSecretError}, {@link WebhookSignatureError},
|
|
630
|
+
* {@link MalformedWebhookPayloadError}, or {@link WebhookCryptoError}.
|
|
631
|
+
*/
|
|
632
|
+
const verifyWebhookAt = async (input) => {
|
|
633
|
+
const { id, timestamp, signature } = freshHeaders(input);
|
|
634
|
+
const body = toBytes(input.body);
|
|
635
|
+
const expected = await hmac(input.secret, id, timestamp, body);
|
|
636
|
+
if (!signatureCandidates(signature, "v1").some((candidate) => timingSafeEqual(expected, candidate))) throw new WebhookSignatureError({ detail: "Webhook signature verification failed" });
|
|
637
|
+
return {
|
|
638
|
+
id,
|
|
639
|
+
event: parseEvent(body)
|
|
640
|
+
};
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* Verifies a `v2` (RSASSA-PKCS1-v1_5, SHA-256) delivery against one or more public keys, each a
|
|
644
|
+
* Base64-encoded SPKI DER key. Pass several keys during a key rotation; the delivery verifies when
|
|
645
|
+
* any `v2` signature entry matches any key.
|
|
646
|
+
*
|
|
647
|
+
* Header, timestamp, and envelope checks match {@link verifyWebhookAt}. Keys that fail to import
|
|
648
|
+
* are skipped. Rejects with {@link WebhookSignatureError} when `publicKeys` is empty or nothing
|
|
649
|
+
* matches, and {@link WebhookCryptoError} when none of the keys imports.
|
|
650
|
+
*/
|
|
651
|
+
const verifyWebhookAtWithPublicKeys = async (input) => {
|
|
652
|
+
const { id, timestamp, signature } = freshHeaders(input);
|
|
653
|
+
if (input.publicKeys.length === 0) throw new WebhookSignatureError({ detail: "No webhook verification key is available" });
|
|
654
|
+
const keys = (await Promise.all(input.publicKeys.map(importVerificationKey))).filter((key) => key !== void 0);
|
|
655
|
+
if (keys.length === 0) throw new WebhookCryptoError({ detail: "Unable to import any webhook verification key: keys must be Base64 SPKI DER" });
|
|
656
|
+
const body = toBytes(input.body);
|
|
657
|
+
const content = toCryptoBytes(signedBytes(id, timestamp, body));
|
|
658
|
+
const candidates = signatureCandidates(signature, "v2");
|
|
659
|
+
if (!(await Promise.all(keys.flatMap((key) => candidates.map((candidate) => asymmetricMatch(key, candidate, content))))).includes(true)) throw new WebhookSignatureError({ detail: "Webhook signature verification failed" });
|
|
660
|
+
return {
|
|
661
|
+
id,
|
|
662
|
+
event: parseEvent(body)
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* Reads the three signing headers from a Fetch API `Headers` object, for code that needs a header
|
|
667
|
+
* value, such as the timestamp, before or beside verification. Throws
|
|
668
|
+
* {@link InvalidWebhookHeadersError}, naming the header, when one is missing or empty; call it
|
|
669
|
+
* inside the same error handling as the verification that follows.
|
|
670
|
+
*/
|
|
671
|
+
const readWebhookHeaders = (headers) => requireHeaders({
|
|
672
|
+
id: headers.get(WEBHOOK_ID_HEADER),
|
|
673
|
+
timestamp: headers.get(WEBHOOK_TIMESTAMP_HEADER),
|
|
674
|
+
signature: headers.get(WEBHOOK_SIGNATURE_HEADER)
|
|
675
|
+
});
|
|
676
|
+
//#endregion
|
|
677
|
+
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 };
|
|
678
|
+
|
|
679
|
+
//# sourceMappingURL=protocol-GkuvvobW.js.map
|