@samva/webhooks 0.33.0 → 0.35.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/README.md +1 -1
- package/dist/effect.js +2 -2
- package/dist/{json-schemas.gen-eaxxbAJh.js → json-schemas.gen-BHKhYQV4.js} +13 -13
- package/dist/promise.js +2 -2
- package/dist/{protocol-Di63Knu8.js → protocol-D6py4UMl.js} +5 -6
- package/dist/protocol.js +1 -1
- package/dist/schemas.gen.d.ts +12 -12
- package/dist/schemas.gen.js +12 -12
- package/dist/types.gen.d.ts +6 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@samva/webhooks`
|
|
2
2
|
|
|
3
|
-
Samva is the email API for your app: transactional and campaign sending, inbound
|
|
3
|
+
Samva is the email and WhatsApp API for your app: transactional and campaign sending, inbound replies threaded into conversations, programmable mailboxes, and signed webhooks. Small businesses use the same platform to answer their customers in Samva Mail.
|
|
4
4
|
|
|
5
5
|
Verify signed Samva webhook deliveries in Node.js, Bun, Cloudflare Workers, and other Web
|
|
6
6
|
Crypto-compatible runtimes.
|
package/dist/effect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as WebhookTimestampError, c as signWebhook, f as InvalidWebhookHeadersError, g as WebhookSignatureError, h as WebhookCryptoError, i as WEBHOOK_TIMESTAMP_HEADER, l as verifyWebhookAt, m as MalformedWebhookPayloadError, n as WEBHOOK_ID_HEADER, o as generateWebhookSecret, p as InvalidWebhookSecretError, r as WEBHOOK_SIGNATURE_HEADER, t as DEFAULT_TOLERANCE_SECONDS, v as WebhookVerificationError, y as isKnownEvent } from "./protocol-
|
|
2
|
-
import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-
|
|
1
|
+
import { _ as WebhookTimestampError, c as signWebhook, f as InvalidWebhookHeadersError, g as WebhookSignatureError, h as WebhookCryptoError, i as WEBHOOK_TIMESTAMP_HEADER, l as verifyWebhookAt, m as MalformedWebhookPayloadError, n as WEBHOOK_ID_HEADER, o as generateWebhookSecret, p as InvalidWebhookSecretError, r as WEBHOOK_SIGNATURE_HEADER, t as DEFAULT_TOLERANCE_SECONDS, v as WebhookVerificationError, y as isKnownEvent } from "./protocol-D6py4UMl.js";
|
|
2
|
+
import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-BHKhYQV4.js";
|
|
3
3
|
import { ContactConsentChangedEventSchema, ContactCreatedEventSchema, ContactDeletedEventSchema, ContactResubscribedEventSchema, ContactSubscribedEventSchema, ContactUnsubscribedEventSchema, ContactUpdatedEventSchema, ConversationArchivedEventSchema, ConversationCreatedEventSchema, ConversationUpdatedEventSchema, DomainUpdatedEventSchema, DomainWarmingUpdatedEventSchema, FlowRegistrationUpdatedEventSchema, JourneyWebhookEventSchema, MailboxActionPendingApprovalEventSchema, MailboxActionResolvedEventSchema, MailboxMessageDeliveredEventSchema, MailboxMessageDiscardedEventSchema, MailboxMessageFailedEventSchema, MailboxMessageQuarantinedEventSchema, MailboxMessageReadEventSchema, MailboxMessageReceivedEventSchema, MailboxMessageReleasedEventSchema, MailboxMessageSentEventSchema, MessageBouncedEventSchema, MessageClickedEventSchema, MessageComplainedEventSchema, MessageDeliveredEventSchema, MessageFailedEventSchema, MessageOpenedEventSchema, MessageReadEventSchema, MessageReceivedEventSchema, MessageSentEventSchema, SamvaWebhookEventSchema, TemplateRegistrationUpdatedEventSchema, WebhookCreatedEventSchema, WebhookDeletedEventSchema, WebhookTestEventSchema, WebhookUpdatedEventSchema, WhatsappNumberConnectedEventSchema } from "./schemas.gen.js";
|
|
4
4
|
import { Clock, Effect } from "effect";
|
|
5
5
|
// src/effect.ts
|
|
@@ -3146,9 +3146,9 @@ const WebhookEventJsonSchemas = {
|
|
|
3146
3146
|
channel: {
|
|
3147
3147
|
type: "string",
|
|
3148
3148
|
enum: [
|
|
3149
|
-
"
|
|
3149
|
+
"sms",
|
|
3150
3150
|
"whatsapp",
|
|
3151
|
-
"
|
|
3151
|
+
"email"
|
|
3152
3152
|
],
|
|
3153
3153
|
description: "Deliveries recorded before this field existed omit it; they are email."
|
|
3154
3154
|
},
|
|
@@ -3344,9 +3344,9 @@ const WebhookEventJsonSchemas = {
|
|
|
3344
3344
|
channel: {
|
|
3345
3345
|
type: "string",
|
|
3346
3346
|
enum: [
|
|
3347
|
-
"
|
|
3347
|
+
"sms",
|
|
3348
3348
|
"whatsapp",
|
|
3349
|
-
"
|
|
3349
|
+
"email"
|
|
3350
3350
|
],
|
|
3351
3351
|
description: "Deliveries recorded before this field existed omit it; they are email."
|
|
3352
3352
|
},
|
|
@@ -3972,9 +3972,9 @@ const WebhookEventJsonSchemas = {
|
|
|
3972
3972
|
channel: {
|
|
3973
3973
|
type: "string",
|
|
3974
3974
|
enum: [
|
|
3975
|
-
"
|
|
3975
|
+
"sms",
|
|
3976
3976
|
"whatsapp",
|
|
3977
|
-
"
|
|
3977
|
+
"email"
|
|
3978
3978
|
],
|
|
3979
3979
|
description: "Deliveries recorded before this field existed omit it; they are email."
|
|
3980
3980
|
},
|
|
@@ -4234,9 +4234,9 @@ const WebhookEventJsonSchemas = {
|
|
|
4234
4234
|
channel: {
|
|
4235
4235
|
type: "string",
|
|
4236
4236
|
enum: [
|
|
4237
|
-
"
|
|
4237
|
+
"sms",
|
|
4238
4238
|
"whatsapp",
|
|
4239
|
-
"
|
|
4239
|
+
"email"
|
|
4240
4240
|
],
|
|
4241
4241
|
description: "The channel an endpoint, thread, or message belongs to."
|
|
4242
4242
|
},
|
|
@@ -4306,9 +4306,9 @@ const WebhookEventJsonSchemas = {
|
|
|
4306
4306
|
channel: {
|
|
4307
4307
|
type: "string",
|
|
4308
4308
|
enum: [
|
|
4309
|
-
"
|
|
4309
|
+
"sms",
|
|
4310
4310
|
"whatsapp",
|
|
4311
|
-
"
|
|
4311
|
+
"email"
|
|
4312
4312
|
],
|
|
4313
4313
|
description: "The channel an endpoint, thread, or message belongs to."
|
|
4314
4314
|
},
|
|
@@ -4378,9 +4378,9 @@ const WebhookEventJsonSchemas = {
|
|
|
4378
4378
|
channel: {
|
|
4379
4379
|
type: "string",
|
|
4380
4380
|
enum: [
|
|
4381
|
-
"
|
|
4381
|
+
"sms",
|
|
4382
4382
|
"whatsapp",
|
|
4383
|
-
"
|
|
4383
|
+
"email"
|
|
4384
4384
|
],
|
|
4385
4385
|
description: "The channel an endpoint, thread, or message belongs to."
|
|
4386
4386
|
},
|
|
@@ -4495,4 +4495,4 @@ const WebhookEventJsonSchemas = {
|
|
|
4495
4495
|
};
|
|
4496
4496
|
export { WebhookEventJsonSchemas as t };
|
|
4497
4497
|
|
|
4498
|
-
//# sourceMappingURL=json-schemas.gen-
|
|
4498
|
+
//# sourceMappingURL=json-schemas.gen-BHKhYQV4.js.map
|
package/dist/promise.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as WebhookTimestampError, c as signWebhook, f as InvalidWebhookHeadersError, g as WebhookSignatureError, h as WebhookCryptoError, i as WEBHOOK_TIMESTAMP_HEADER, l as verifyWebhookAt, m as MalformedWebhookPayloadError, n as WEBHOOK_ID_HEADER, o as generateWebhookSecret, p as InvalidWebhookSecretError, r as WEBHOOK_SIGNATURE_HEADER, s as readWebhookHeaders, t as DEFAULT_TOLERANCE_SECONDS, v as WebhookVerificationError, y as isKnownEvent } from "./protocol-
|
|
2
|
-
import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-
|
|
1
|
+
import { _ as WebhookTimestampError, c as signWebhook, f as InvalidWebhookHeadersError, g as WebhookSignatureError, h as WebhookCryptoError, i as WEBHOOK_TIMESTAMP_HEADER, l as verifyWebhookAt, m as MalformedWebhookPayloadError, n as WEBHOOK_ID_HEADER, o as generateWebhookSecret, p as InvalidWebhookSecretError, r as WEBHOOK_SIGNATURE_HEADER, s as readWebhookHeaders, t as DEFAULT_TOLERANCE_SECONDS, v as WebhookVerificationError, y as isKnownEvent } from "./protocol-D6py4UMl.js";
|
|
2
|
+
import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-BHKhYQV4.js";
|
|
3
3
|
// src/promise.ts
|
|
4
4
|
/**
|
|
5
5
|
* Verifies a Samva webhook delivery from its body and header values, then returns its ID and
|
|
@@ -256,8 +256,7 @@ const validate1426 = (value) => isObject(value) && isObject(value);
|
|
|
256
256
|
const validate1428 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1429(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1431(value["data"]));
|
|
257
257
|
const validate1429 = (value) => typeof value === "string" && value === "mailbox.message.received";
|
|
258
258
|
const validate1431 = (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") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "message") || validate1436(value["message"])) && (!Object.hasOwn(value, "thread") || validate1470(value["thread"]));
|
|
259
|
-
const validate1436 = (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") || validate779(value["id"])) && (!Object.hasOwn(value, "campaign") || validate592(value["campaign"])) && (!Object.hasOwn(value, "channel") ||
|
|
260
|
-
const validate1443 = (value) => typeof value === "string" && (value === "email" || value === "whatsapp" || value === "sms");
|
|
259
|
+
const validate1436 = (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") || validate779(value["id"])) && (!Object.hasOwn(value, "campaign") || validate592(value["campaign"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "threadId") || validate1444(value["threadId"])) && (!Object.hasOwn(value, "from") || validate1445(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") || validate1463(value["attachments"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"]));
|
|
261
260
|
const validate1444 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^thread_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
|
|
262
261
|
const validate1445 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "address") && (!Object.hasOwn(value, "address") || validate2(value["address"])) && (!Object.hasOwn(value, "name") || validate8(value["name"]));
|
|
263
262
|
const validate1463 = (value) => Array.isArray(value) && Array.isArray(value) && value.every(validate1464);
|
|
@@ -314,15 +313,15 @@ const validate1706 = (value) => typeof value === "string" && value === "mailbox.
|
|
|
314
313
|
const validate1708 = (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") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "discardedBy") || validate1492(value["discardedBy"])) && (!Object.hasOwn(value, "disposition") || validate1630(value["disposition"])) && (!Object.hasOwn(value, "reason") || validate1631(value["reason"])) && (!Object.hasOwn(value, "message") || validate1633(value["message"]));
|
|
315
314
|
const validate1733 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1734(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1736(value["data"]));
|
|
316
315
|
const validate1734 = (value) => typeof value === "string" && value === "mailbox.message.delivered";
|
|
317
|
-
const validate1736 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "actionId") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "status") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "threadId") || validate1444(value["threadId"])) && (!Object.hasOwn(value, "actionId") || validate1489(value["actionId"])) && (!Object.hasOwn(value, "messageId") || validate779(value["messageId"])) && (!Object.hasOwn(value, "channel") ||
|
|
316
|
+
const validate1736 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "actionId") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "status") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "threadId") || validate1444(value["threadId"])) && (!Object.hasOwn(value, "actionId") || validate1489(value["actionId"])) && (!Object.hasOwn(value, "messageId") || validate779(value["messageId"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "recipient") || validate2(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"])) && (!Object.hasOwn(value, "status") || validate1747(value["status"]));
|
|
318
317
|
const validate1747 = (value) => typeof value === "string" && value === "delivered";
|
|
319
318
|
const validate1748 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1749(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1751(value["data"]));
|
|
320
319
|
const validate1749 = (value) => typeof value === "string" && value === "mailbox.message.read";
|
|
321
|
-
const validate1751 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "actionId") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "status") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "threadId") || validate1444(value["threadId"])) && (!Object.hasOwn(value, "actionId") || validate1489(value["actionId"])) && (!Object.hasOwn(value, "messageId") || validate779(value["messageId"])) && (!Object.hasOwn(value, "channel") ||
|
|
320
|
+
const validate1751 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "actionId") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "status") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "threadId") || validate1444(value["threadId"])) && (!Object.hasOwn(value, "actionId") || validate1489(value["actionId"])) && (!Object.hasOwn(value, "messageId") || validate779(value["messageId"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "recipient") || validate2(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"])) && (!Object.hasOwn(value, "status") || validate1762(value["status"]));
|
|
322
321
|
const validate1762 = (value) => typeof value === "string" && value === "read";
|
|
323
322
|
const validate1763 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1764(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1766(value["data"]));
|
|
324
323
|
const validate1764 = (value) => typeof value === "string" && value === "mailbox.message.failed";
|
|
325
|
-
const validate1766 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "actionId") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "status") && Object.hasOwn(value, "error") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "threadId") || validate1444(value["threadId"])) && (!Object.hasOwn(value, "actionId") || validate1489(value["actionId"])) && (!Object.hasOwn(value, "messageId") || validate779(value["messageId"])) && (!Object.hasOwn(value, "channel") ||
|
|
324
|
+
const validate1766 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "mailboxId") && Object.hasOwn(value, "namespaceId") && Object.hasOwn(value, "threadId") && Object.hasOwn(value, "actionId") && Object.hasOwn(value, "messageId") && Object.hasOwn(value, "channel") && Object.hasOwn(value, "recipient") && Object.hasOwn(value, "occurredAt") && Object.hasOwn(value, "status") && Object.hasOwn(value, "error") && (!Object.hasOwn(value, "mailboxId") || validate5(value["mailboxId"])) && (!Object.hasOwn(value, "namespaceId") || validate1413(value["namespaceId"])) && (!Object.hasOwn(value, "threadId") || validate1444(value["threadId"])) && (!Object.hasOwn(value, "actionId") || validate1489(value["actionId"])) && (!Object.hasOwn(value, "messageId") || validate779(value["messageId"])) && (!Object.hasOwn(value, "channel") || validate7(value["channel"])) && (!Object.hasOwn(value, "recipient") || validate2(value["recipient"])) && (!Object.hasOwn(value, "occurredAt") || validate2(value["occurredAt"])) && (!Object.hasOwn(value, "status") || validate1777(value["status"])) && (!Object.hasOwn(value, "error") || validate1778(value["error"]));
|
|
326
325
|
const validate1777 = (value) => typeof value === "string" && value === "failed";
|
|
327
326
|
const validate1778 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "code") && Object.hasOwn(value, "message") && (!Object.hasOwn(value, "code") || validate8(value["code"])) && (!Object.hasOwn(value, "message") || validate8(value["message"]));
|
|
328
327
|
const validate1785 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "type") && Object.hasOwn(value, "timestamp") && Object.hasOwn(value, "data") && (!Object.hasOwn(value, "type") || validate1786(value["type"])) && (!Object.hasOwn(value, "timestamp") || validate2(value["timestamp"])) && (!Object.hasOwn(value, "data") || validate1788(value["data"]));
|
|
@@ -745,4 +744,4 @@ const readWebhookHeaders = (headers) => requireHeaders({
|
|
|
745
744
|
});
|
|
746
745
|
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 };
|
|
747
746
|
|
|
748
|
-
//# sourceMappingURL=protocol-
|
|
747
|
+
//# sourceMappingURL=protocol-D6py4UMl.js.map
|
package/dist/protocol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as DEFAULT_TOLERANCE_SECONDS, f as InvalidWebhookHeadersError, p as InvalidWebhookSecretError, m as MalformedWebhookPayloadError, n as WEBHOOK_ID_HEADER, r as WEBHOOK_SIGNATURE_HEADER, i as WEBHOOK_TIMESTAMP_HEADER, h as WebhookCryptoError, g as WebhookSignatureError, _ as WebhookTimestampError, v as WebhookVerificationError, a as encodeWebhookSignature, o as generateWebhookSecret, y as isKnownEvent, s as readWebhookHeaders, c as signWebhook, l as verifyWebhookAt, u as verifyWebhookAtWithPublicKeys, d as webhookSignedContent } from "./protocol-
|
|
1
|
+
export { t as DEFAULT_TOLERANCE_SECONDS, f as InvalidWebhookHeadersError, p as InvalidWebhookSecretError, m as MalformedWebhookPayloadError, n as WEBHOOK_ID_HEADER, r as WEBHOOK_SIGNATURE_HEADER, i as WEBHOOK_TIMESTAMP_HEADER, h as WebhookCryptoError, g as WebhookSignatureError, _ as WebhookTimestampError, v as WebhookVerificationError, a as encodeWebhookSignature, o as generateWebhookSecret, y as isKnownEvent, s as readWebhookHeaders, c as signWebhook, l as verifyWebhookAt, u as verifyWebhookAtWithPublicKeys, d as webhookSignedContent } from "./protocol-D6py4UMl.js";
|
package/dist/schemas.gen.d.ts
CHANGED
|
@@ -905,7 +905,7 @@ export declare const MailboxMessageReceivedEventSchema: Schema.StructWithRest<Sc
|
|
|
905
905
|
readonly campaignId: Schema.String;
|
|
906
906
|
readonly runId: Schema.String;
|
|
907
907
|
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>, Schema.Null]>>;
|
|
908
|
-
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["
|
|
908
|
+
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["sms", "whatsapp", "email"]>>;
|
|
909
909
|
readonly threadId: Schema.String;
|
|
910
910
|
readonly from: Schema.StructWithRest<Schema.Struct<{
|
|
911
911
|
readonly address: Schema.String;
|
|
@@ -953,7 +953,7 @@ export declare const MailboxMessageSentEventSchema: Schema.StructWithRest<Schema
|
|
|
953
953
|
readonly campaignId: Schema.String;
|
|
954
954
|
readonly runId: Schema.String;
|
|
955
955
|
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>, Schema.Null]>>;
|
|
956
|
-
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["
|
|
956
|
+
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["sms", "whatsapp", "email"]>>;
|
|
957
957
|
readonly threadId: Schema.String;
|
|
958
958
|
readonly from: Schema.StructWithRest<Schema.Struct<{
|
|
959
959
|
readonly address: Schema.String;
|
|
@@ -1083,7 +1083,7 @@ export declare const MailboxMessageReleasedEventSchema: Schema.StructWithRest<Sc
|
|
|
1083
1083
|
readonly campaignId: Schema.String;
|
|
1084
1084
|
readonly runId: Schema.String;
|
|
1085
1085
|
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>, Schema.Null]>>;
|
|
1086
|
-
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["
|
|
1086
|
+
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["sms", "whatsapp", "email"]>>;
|
|
1087
1087
|
readonly threadId: Schema.String;
|
|
1088
1088
|
readonly from: Schema.StructWithRest<Schema.Struct<{
|
|
1089
1089
|
readonly address: Schema.String;
|
|
@@ -1144,7 +1144,7 @@ export declare const MailboxMessageDeliveredEventSchema: Schema.StructWithRest<S
|
|
|
1144
1144
|
readonly threadId: Schema.String;
|
|
1145
1145
|
readonly actionId: Schema.String;
|
|
1146
1146
|
readonly messageId: Schema.String;
|
|
1147
|
-
readonly channel: Schema.Literals<readonly ["
|
|
1147
|
+
readonly channel: Schema.Literals<readonly ["sms", "whatsapp", "email"]>;
|
|
1148
1148
|
readonly recipient: Schema.String;
|
|
1149
1149
|
readonly occurredAt: Schema.String;
|
|
1150
1150
|
readonly status: Schema.Literal<"delivered">;
|
|
@@ -1159,7 +1159,7 @@ export declare const MailboxMessageReadEventSchema: Schema.StructWithRest<Schema
|
|
|
1159
1159
|
readonly threadId: Schema.String;
|
|
1160
1160
|
readonly actionId: Schema.String;
|
|
1161
1161
|
readonly messageId: Schema.String;
|
|
1162
|
-
readonly channel: Schema.Literals<readonly ["
|
|
1162
|
+
readonly channel: Schema.Literals<readonly ["sms", "whatsapp", "email"]>;
|
|
1163
1163
|
readonly recipient: Schema.String;
|
|
1164
1164
|
readonly occurredAt: Schema.String;
|
|
1165
1165
|
readonly status: Schema.Literal<"read">;
|
|
@@ -1174,7 +1174,7 @@ export declare const MailboxMessageFailedEventSchema: Schema.StructWithRest<Sche
|
|
|
1174
1174
|
readonly threadId: Schema.String;
|
|
1175
1175
|
readonly actionId: Schema.String;
|
|
1176
1176
|
readonly messageId: Schema.String;
|
|
1177
|
-
readonly channel: Schema.Literals<readonly ["
|
|
1177
|
+
readonly channel: Schema.Literals<readonly ["sms", "whatsapp", "email"]>;
|
|
1178
1178
|
readonly recipient: Schema.String;
|
|
1179
1179
|
readonly occurredAt: Schema.String;
|
|
1180
1180
|
readonly status: Schema.Literal<"failed">;
|
|
@@ -2079,7 +2079,7 @@ export declare const SamvaWebhookEventSchema: Schema.Union<readonly [Schema.Stru
|
|
|
2079
2079
|
readonly campaignId: Schema.String;
|
|
2080
2080
|
readonly runId: Schema.String;
|
|
2081
2081
|
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>, Schema.Null]>>;
|
|
2082
|
-
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["
|
|
2082
|
+
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["sms", "whatsapp", "email"]>>;
|
|
2083
2083
|
readonly threadId: Schema.String;
|
|
2084
2084
|
readonly from: Schema.StructWithRest<Schema.Struct<{
|
|
2085
2085
|
readonly address: Schema.String;
|
|
@@ -2126,7 +2126,7 @@ export declare const SamvaWebhookEventSchema: Schema.Union<readonly [Schema.Stru
|
|
|
2126
2126
|
readonly campaignId: Schema.String;
|
|
2127
2127
|
readonly runId: Schema.String;
|
|
2128
2128
|
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>, Schema.Null]>>;
|
|
2129
|
-
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["
|
|
2129
|
+
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["sms", "whatsapp", "email"]>>;
|
|
2130
2130
|
readonly threadId: Schema.String;
|
|
2131
2131
|
readonly from: Schema.StructWithRest<Schema.Struct<{
|
|
2132
2132
|
readonly address: Schema.String;
|
|
@@ -2252,7 +2252,7 @@ export declare const SamvaWebhookEventSchema: Schema.Union<readonly [Schema.Stru
|
|
|
2252
2252
|
readonly campaignId: Schema.String;
|
|
2253
2253
|
readonly runId: Schema.String;
|
|
2254
2254
|
}>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>, Schema.Null]>>;
|
|
2255
|
-
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["
|
|
2255
|
+
readonly channel: Schema.optionalKey<Schema.Literals<readonly ["sms", "whatsapp", "email"]>>;
|
|
2256
2256
|
readonly threadId: Schema.String;
|
|
2257
2257
|
readonly from: Schema.StructWithRest<Schema.Struct<{
|
|
2258
2258
|
readonly address: Schema.String;
|
|
@@ -2311,7 +2311,7 @@ export declare const SamvaWebhookEventSchema: Schema.Union<readonly [Schema.Stru
|
|
|
2311
2311
|
readonly threadId: Schema.String;
|
|
2312
2312
|
readonly actionId: Schema.String;
|
|
2313
2313
|
readonly messageId: Schema.String;
|
|
2314
|
-
readonly channel: Schema.Literals<readonly ["
|
|
2314
|
+
readonly channel: Schema.Literals<readonly ["sms", "whatsapp", "email"]>;
|
|
2315
2315
|
readonly recipient: Schema.String;
|
|
2316
2316
|
readonly occurredAt: Schema.String;
|
|
2317
2317
|
readonly status: Schema.Literal<"delivered">;
|
|
@@ -2325,7 +2325,7 @@ export declare const SamvaWebhookEventSchema: Schema.Union<readonly [Schema.Stru
|
|
|
2325
2325
|
readonly threadId: Schema.String;
|
|
2326
2326
|
readonly actionId: Schema.String;
|
|
2327
2327
|
readonly messageId: Schema.String;
|
|
2328
|
-
readonly channel: Schema.Literals<readonly ["
|
|
2328
|
+
readonly channel: Schema.Literals<readonly ["sms", "whatsapp", "email"]>;
|
|
2329
2329
|
readonly recipient: Schema.String;
|
|
2330
2330
|
readonly occurredAt: Schema.String;
|
|
2331
2331
|
readonly status: Schema.Literal<"read">;
|
|
@@ -2339,7 +2339,7 @@ export declare const SamvaWebhookEventSchema: Schema.Union<readonly [Schema.Stru
|
|
|
2339
2339
|
readonly threadId: Schema.String;
|
|
2340
2340
|
readonly actionId: Schema.String;
|
|
2341
2341
|
readonly messageId: Schema.String;
|
|
2342
|
-
readonly channel: Schema.Literals<readonly ["
|
|
2342
|
+
readonly channel: Schema.Literals<readonly ["sms", "whatsapp", "email"]>;
|
|
2343
2343
|
readonly recipient: Schema.String;
|
|
2344
2344
|
readonly occurredAt: Schema.String;
|
|
2345
2345
|
readonly status: Schema.Literal<"failed">;
|
package/dist/schemas.gen.js
CHANGED
|
@@ -1237,9 +1237,9 @@ const MailboxMessageReceivedEventSchema = Schema.StructWithRest(Schema.Struct({
|
|
|
1237
1237
|
runId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^crun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^crun_[0-9a-hjkmnp-tv-z]{16,24}$" }))
|
|
1238
1238
|
}), [Schema.Record(Schema.String, Schema.Json.annotate({ expected: "JSON value" }))]), Schema.Null])),
|
|
1239
1239
|
channel: Schema.optionalKey(Schema.Literals([
|
|
1240
|
-
"
|
|
1240
|
+
"sms",
|
|
1241
1241
|
"whatsapp",
|
|
1242
|
-
"
|
|
1242
|
+
"email"
|
|
1243
1243
|
]).annotate({ description: "Deliveries recorded before this field existed omit it; they are email." })),
|
|
1244
1244
|
threadId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^thread_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^thread_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1245
1245
|
from: Schema.StructWithRest(Schema.Struct({
|
|
@@ -1303,9 +1303,9 @@ const MailboxMessageSentEventSchema = Schema.StructWithRest(Schema.Struct({
|
|
|
1303
1303
|
runId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^crun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^crun_[0-9a-hjkmnp-tv-z]{16,24}$" }))
|
|
1304
1304
|
}), [Schema.Record(Schema.String, Schema.Json.annotate({ expected: "JSON value" }))]), Schema.Null])),
|
|
1305
1305
|
channel: Schema.optionalKey(Schema.Literals([
|
|
1306
|
-
"
|
|
1306
|
+
"sms",
|
|
1307
1307
|
"whatsapp",
|
|
1308
|
-
"
|
|
1308
|
+
"email"
|
|
1309
1309
|
]).annotate({ description: "Deliveries recorded before this field existed omit it; they are email." })),
|
|
1310
1310
|
threadId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^thread_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^thread_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1311
1311
|
from: Schema.StructWithRest(Schema.Struct({
|
|
@@ -1541,9 +1541,9 @@ const MailboxMessageReleasedEventSchema = Schema.StructWithRest(Schema.Struct({
|
|
|
1541
1541
|
runId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^crun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^crun_[0-9a-hjkmnp-tv-z]{16,24}$" }))
|
|
1542
1542
|
}), [Schema.Record(Schema.String, Schema.Json.annotate({ expected: "JSON value" }))]), Schema.Null])),
|
|
1543
1543
|
channel: Schema.optionalKey(Schema.Literals([
|
|
1544
|
-
"
|
|
1544
|
+
"sms",
|
|
1545
1545
|
"whatsapp",
|
|
1546
|
-
"
|
|
1546
|
+
"email"
|
|
1547
1547
|
]).annotate({ description: "Deliveries recorded before this field existed omit it; they are email." })),
|
|
1548
1548
|
threadId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^thread_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^thread_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1549
1549
|
from: Schema.StructWithRest(Schema.Struct({
|
|
@@ -1628,9 +1628,9 @@ const MailboxMessageDeliveredEventSchema = Schema.StructWithRest(Schema.Struct({
|
|
|
1628
1628
|
actionId: Schema.String.annotate({ description: "The mailbox send action that sent the message." }).check(Schema.isPattern(/* @__PURE__ */ new RegExp("^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1629
1629
|
messageId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^msg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^msg_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1630
1630
|
channel: Schema.Literals([
|
|
1631
|
-
"
|
|
1631
|
+
"sms",
|
|
1632
1632
|
"whatsapp",
|
|
1633
|
-
"
|
|
1633
|
+
"email"
|
|
1634
1634
|
]).annotate({ description: "The channel an endpoint, thread, or message belongs to." }),
|
|
1635
1635
|
recipient: Schema.String.annotate({ description: "The address or number the status is about." }),
|
|
1636
1636
|
occurredAt: Schema.String,
|
|
@@ -1647,9 +1647,9 @@ const MailboxMessageReadEventSchema = Schema.StructWithRest(Schema.Struct({
|
|
|
1647
1647
|
actionId: Schema.String.annotate({ description: "The mailbox send action that sent the message." }).check(Schema.isPattern(/* @__PURE__ */ new RegExp("^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1648
1648
|
messageId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^msg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^msg_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1649
1649
|
channel: Schema.Literals([
|
|
1650
|
-
"
|
|
1650
|
+
"sms",
|
|
1651
1651
|
"whatsapp",
|
|
1652
|
-
"
|
|
1652
|
+
"email"
|
|
1653
1653
|
]).annotate({ description: "The channel an endpoint, thread, or message belongs to." }),
|
|
1654
1654
|
recipient: Schema.String.annotate({ description: "The address or number the status is about." }),
|
|
1655
1655
|
occurredAt: Schema.String,
|
|
@@ -1666,9 +1666,9 @@ const MailboxMessageFailedEventSchema = Schema.StructWithRest(Schema.Struct({
|
|
|
1666
1666
|
actionId: Schema.String.annotate({ description: "The mailbox send action that sent the message." }).check(Schema.isPattern(/* @__PURE__ */ new RegExp("^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1667
1667
|
messageId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^msg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^msg_[0-9a-hjkmnp-tv-z]{16,24}$" })),
|
|
1668
1668
|
channel: Schema.Literals([
|
|
1669
|
-
"
|
|
1669
|
+
"sms",
|
|
1670
1670
|
"whatsapp",
|
|
1671
|
-
"
|
|
1671
|
+
"email"
|
|
1672
1672
|
]).annotate({ description: "The channel an endpoint, thread, or message belongs to." }),
|
|
1673
1673
|
recipient: Schema.String.annotate({ description: "The address or number the status is about." }),
|
|
1674
1674
|
occurredAt: Schema.String,
|
package/dist/types.gen.d.ts
CHANGED
|
@@ -1199,7 +1199,7 @@ export type MailboxMessageReceivedEvent = {
|
|
|
1199
1199
|
} & {
|
|
1200
1200
|
readonly [x: string]: JsonValue;
|
|
1201
1201
|
}) | null;
|
|
1202
|
-
readonly channel?: "
|
|
1202
|
+
readonly channel?: "sms" | "whatsapp" | "email";
|
|
1203
1203
|
readonly threadId: string;
|
|
1204
1204
|
readonly from: {
|
|
1205
1205
|
readonly address: string;
|
|
@@ -1264,7 +1264,7 @@ export type MailboxMessageSentEvent = {
|
|
|
1264
1264
|
} & {
|
|
1265
1265
|
readonly [x: string]: JsonValue;
|
|
1266
1266
|
}) | null;
|
|
1267
|
-
readonly channel?: "
|
|
1267
|
+
readonly channel?: "sms" | "whatsapp" | "email";
|
|
1268
1268
|
readonly threadId: string;
|
|
1269
1269
|
readonly from: {
|
|
1270
1270
|
readonly address: string;
|
|
@@ -1448,7 +1448,7 @@ export type MailboxMessageReleasedEvent = {
|
|
|
1448
1448
|
} & {
|
|
1449
1449
|
readonly [x: string]: JsonValue;
|
|
1450
1450
|
}) | null;
|
|
1451
|
-
readonly channel?: "
|
|
1451
|
+
readonly channel?: "sms" | "whatsapp" | "email";
|
|
1452
1452
|
readonly threadId: string;
|
|
1453
1453
|
readonly from: {
|
|
1454
1454
|
readonly address: string;
|
|
@@ -1533,7 +1533,7 @@ export type MailboxMessageDeliveredEvent = {
|
|
|
1533
1533
|
readonly threadId: string;
|
|
1534
1534
|
readonly actionId: string;
|
|
1535
1535
|
readonly messageId: string;
|
|
1536
|
-
readonly channel: "
|
|
1536
|
+
readonly channel: "sms" | "whatsapp" | "email";
|
|
1537
1537
|
readonly recipient: string;
|
|
1538
1538
|
readonly occurredAt: string;
|
|
1539
1539
|
readonly status: "delivered";
|
|
@@ -1553,7 +1553,7 @@ export type MailboxMessageReadEvent = {
|
|
|
1553
1553
|
readonly threadId: string;
|
|
1554
1554
|
readonly actionId: string;
|
|
1555
1555
|
readonly messageId: string;
|
|
1556
|
-
readonly channel: "
|
|
1556
|
+
readonly channel: "sms" | "whatsapp" | "email";
|
|
1557
1557
|
readonly recipient: string;
|
|
1558
1558
|
readonly occurredAt: string;
|
|
1559
1559
|
readonly status: "read";
|
|
@@ -1573,7 +1573,7 @@ export type MailboxMessageFailedEvent = {
|
|
|
1573
1573
|
readonly threadId: string;
|
|
1574
1574
|
readonly actionId: string;
|
|
1575
1575
|
readonly messageId: string;
|
|
1576
|
-
readonly channel: "
|
|
1576
|
+
readonly channel: "sms" | "whatsapp" | "email";
|
|
1577
1577
|
readonly recipient: string;
|
|
1578
1578
|
readonly occurredAt: string;
|
|
1579
1579
|
readonly status: "failed";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samva/webhooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Runtime-neutral verification for Samva webhook deliveries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"samva",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@effect/tsgo": "0.63.0",
|
|
69
|
-
"@effect/vitest": "4.
|
|
69
|
+
"@effect/vitest": "^4.1.2",
|
|
70
70
|
"@samva/openapi": "0.0.0",
|
|
71
71
|
"ajv": "^8.20.0",
|
|
72
72
|
"ajv-formats": "^3.0.1",
|
|
73
|
-
"effect": "4.
|
|
73
|
+
"effect": "^4.1.2",
|
|
74
74
|
"tsdown": "0.23.1",
|
|
75
75
|
"typescript": "^7.0.2",
|
|
76
76
|
"vitest": "5.0.3"
|