@samva/webhooks 0.35.0 → 0.37.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 CHANGED
@@ -1,6 +1,6 @@
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
- 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";
1
+ import { a as generateWebhookSecret, c as verifyWebhookAt, d as MalformedWebhookPayloadError, f as WebhookCryptoError, g as isKnownEvent, h as WebhookVerificationError, i as WEBHOOK_TIMESTAMP_HEADER, l as InvalidWebhookHeadersError, m as WebhookTimestampError, n as WEBHOOK_ID_HEADER, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-IJ8lllqW.js";
2
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-C5nX_b5f.js";
3
+ import { ContactConsentChangedEventSchema, ContactCreatedEventSchema, ContactDeletedEventSchema, ContactResubscribedEventSchema, ContactSubscribedEventSchema, ContactUnsubscribedEventSchema, ContactUpdatedEventSchema, ConversationArchivedEventSchema, ConversationCreatedEventSchema, ConversationUpdatedEventSchema, DomainUpdatedEventSchema, DomainWarmingUpdatedEventSchema, EmailSendingPausedEventSchema, EmailSendingResumedEventSchema, 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
6
6
  /**
@@ -74,6 +74,6 @@ const verifyRequest = Effect.fn("Webhooks.verifyRequest")(function* (request, se
74
74
  nowMilliseconds
75
75
  });
76
76
  });
77
- export { ContactConsentChangedEventSchema, ContactCreatedEventSchema, ContactDeletedEventSchema, ContactResubscribedEventSchema, ContactSubscribedEventSchema, ContactUnsubscribedEventSchema, ContactUpdatedEventSchema, ConversationArchivedEventSchema, ConversationCreatedEventSchema, ConversationUpdatedEventSchema, DEFAULT_TOLERANCE_SECONDS, DomainUpdatedEventSchema, DomainWarmingUpdatedEventSchema, FlowRegistrationUpdatedEventSchema, InvalidWebhookHeadersError, InvalidWebhookSecretError, JourneyWebhookEventSchema, MailboxActionPendingApprovalEventSchema, MailboxActionResolvedEventSchema, MailboxMessageDeliveredEventSchema, MailboxMessageDiscardedEventSchema, MailboxMessageFailedEventSchema, MailboxMessageQuarantinedEventSchema, MailboxMessageReadEventSchema, MailboxMessageReceivedEventSchema, MailboxMessageReleasedEventSchema, MailboxMessageSentEventSchema, MalformedWebhookPayloadError, MessageBouncedEventSchema, MessageClickedEventSchema, MessageComplainedEventSchema, MessageDeliveredEventSchema, MessageFailedEventSchema, MessageOpenedEventSchema, MessageReadEventSchema, MessageReceivedEventSchema, MessageSentEventSchema, SamvaWebhookEventSchema, TemplateRegistrationUpdatedEventSchema, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WebhookCreatedEventSchema, WebhookCryptoError, WebhookDeletedEventSchema, WebhookEventJsonSchemas, WebhookSignatureError, WebhookTestEventSchema, WebhookTimestampError, WebhookUpdatedEventSchema, WebhookVerificationError, WhatsappNumberConnectedEventSchema, generateWebhookSecret, isKnownEvent, signWebhook, verify, verifyRequest };
77
+ export { ContactConsentChangedEventSchema, ContactCreatedEventSchema, ContactDeletedEventSchema, ContactResubscribedEventSchema, ContactSubscribedEventSchema, ContactUnsubscribedEventSchema, ContactUpdatedEventSchema, ConversationArchivedEventSchema, ConversationCreatedEventSchema, ConversationUpdatedEventSchema, DEFAULT_TOLERANCE_SECONDS, DomainUpdatedEventSchema, DomainWarmingUpdatedEventSchema, EmailSendingPausedEventSchema, EmailSendingResumedEventSchema, FlowRegistrationUpdatedEventSchema, InvalidWebhookHeadersError, InvalidWebhookSecretError, JourneyWebhookEventSchema, MailboxActionPendingApprovalEventSchema, MailboxActionResolvedEventSchema, MailboxMessageDeliveredEventSchema, MailboxMessageDiscardedEventSchema, MailboxMessageFailedEventSchema, MailboxMessageQuarantinedEventSchema, MailboxMessageReadEventSchema, MailboxMessageReceivedEventSchema, MailboxMessageReleasedEventSchema, MailboxMessageSentEventSchema, MalformedWebhookPayloadError, MessageBouncedEventSchema, MessageClickedEventSchema, MessageComplainedEventSchema, MessageDeliveredEventSchema, MessageFailedEventSchema, MessageOpenedEventSchema, MessageReadEventSchema, MessageReceivedEventSchema, MessageSentEventSchema, SamvaWebhookEventSchema, TemplateRegistrationUpdatedEventSchema, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WebhookCreatedEventSchema, WebhookCryptoError, WebhookDeletedEventSchema, WebhookEventJsonSchemas, WebhookSignatureError, WebhookTestEventSchema, WebhookTimestampError, WebhookUpdatedEventSchema, WebhookVerificationError, WhatsappNumberConnectedEventSchema, generateWebhookSecret, isKnownEvent, signWebhook, verify, verifyRequest };
78
78
 
79
79
  //# sourceMappingURL=effect.js.map
package/dist/errors.d.ts CHANGED
@@ -49,8 +49,8 @@ export declare class WebhookTimestampError extends WebhookVerificationError<"Web
49
49
  constructor(options: WebhookVerificationFailureOptions);
50
50
  }
51
51
  /**
52
- * No signature in the `webhook-signature` header matches the delivery, or no verification key was
53
- * supplied. Treat the request as forged and reject it. When genuine deliveries fail, the usual
52
+ * No signature in the `webhook-signature` header matches the delivery. Treat the request as forged
53
+ * and reject it. When genuine deliveries fail, the usual
54
54
  * causes are the wrong endpoint secret or a body that was parsed and re-serialized before
55
55
  * verification instead of passed through as the exact bytes received.
56
56
  */
@@ -65,9 +65,9 @@ export declare class MalformedWebhookPayloadError extends WebhookVerificationErr
65
65
  constructor(options: WebhookVerificationFailureOptions);
66
66
  }
67
67
  /**
68
- * The runtime's Web Crypto implementation could not import a key or compute a signature, none of
69
- * the supplied public keys could be imported, or the Effect entrypoint could not read the request
70
- * body. Points at the runtime or its configuration rather than at the delivery.
68
+ * The runtime's Web Crypto implementation could not import a key or compute a signature, or the
69
+ * Effect entrypoint could not read the request body. Points at the runtime or its configuration
70
+ * rather than at the delivery.
71
71
  */
72
72
  export declare class WebhookCryptoError extends WebhookVerificationError<"WebhookCryptoError"> {
73
73
  constructor(options: WebhookVerificationFailureOptions);
@@ -2756,6 +2756,88 @@ const WebhookEventJsonSchemas = {
2756
2756
  ],
2757
2757
  additionalProperties: true
2758
2758
  },
2759
+ "email.sending.paused": {
2760
+ type: "object",
2761
+ properties: {
2762
+ type: {
2763
+ type: "string",
2764
+ enum: ["email.sending.paused"]
2765
+ },
2766
+ timestamp: { type: "string" },
2767
+ data: {
2768
+ type: "object",
2769
+ properties: {
2770
+ organizationId: {
2771
+ type: "string",
2772
+ pattern: "^org_[0-9a-hjkmnp-tv-z]{16,24}$"
2773
+ },
2774
+ namespaceId: { anyOf: [{
2775
+ type: "string",
2776
+ pattern: "^ns_[0-9a-hjkmnp-tv-z]{16,24}$"
2777
+ }, { type: "null" }] },
2778
+ channel: {
2779
+ type: "string",
2780
+ enum: ["email"]
2781
+ },
2782
+ occurredAt: { type: "string" }
2783
+ },
2784
+ required: [
2785
+ "organizationId",
2786
+ "namespaceId",
2787
+ "channel",
2788
+ "occurredAt"
2789
+ ],
2790
+ additionalProperties: true
2791
+ }
2792
+ },
2793
+ required: [
2794
+ "type",
2795
+ "timestamp",
2796
+ "data"
2797
+ ],
2798
+ additionalProperties: true
2799
+ },
2800
+ "email.sending.resumed": {
2801
+ type: "object",
2802
+ properties: {
2803
+ type: {
2804
+ type: "string",
2805
+ enum: ["email.sending.resumed"]
2806
+ },
2807
+ timestamp: { type: "string" },
2808
+ data: {
2809
+ type: "object",
2810
+ properties: {
2811
+ organizationId: {
2812
+ type: "string",
2813
+ pattern: "^org_[0-9a-hjkmnp-tv-z]{16,24}$"
2814
+ },
2815
+ namespaceId: { anyOf: [{
2816
+ type: "string",
2817
+ pattern: "^ns_[0-9a-hjkmnp-tv-z]{16,24}$"
2818
+ }, { type: "null" }] },
2819
+ channel: {
2820
+ type: "string",
2821
+ enum: ["email"]
2822
+ },
2823
+ occurredAt: { type: "string" }
2824
+ },
2825
+ required: [
2826
+ "organizationId",
2827
+ "namespaceId",
2828
+ "channel",
2829
+ "occurredAt"
2830
+ ],
2831
+ additionalProperties: true
2832
+ }
2833
+ },
2834
+ required: [
2835
+ "type",
2836
+ "timestamp",
2837
+ "data"
2838
+ ],
2839
+ additionalProperties: true
2840
+ },
2759
2841
  "template.registration.updated": {
2760
2842
  type: "object",
2761
2843
  properties: {
@@ -3467,9 +3549,15 @@ const WebhookEventJsonSchemas = {
3467
3549
  "changeThreadState",
3468
3550
  "call",
3469
3551
  "extensionRequest",
3470
- "toolCall"
3552
+ "toolCall",
3553
+ "handoff"
3471
3554
  ]
3472
3555
  },
3556
+ reviewRound: {
3557
+ type: "integer",
3558
+ maximum: 9007199254740991,
3559
+ exclusiveMinimum: 0
3560
+ },
3473
3561
  state: {
3474
3562
  type: "string",
3475
3563
  enum: ["approvalRequired"],
@@ -3478,38 +3566,168 @@ const WebhookEventJsonSchemas = {
3478
3566
  decision: {
3479
3567
  type: "object",
3480
3568
  properties: {
3569
+ id: {
3570
+ type: "string",
3571
+ pattern: "^pdec_[0-9a-hjkmnp-tv-z]{16,24}$"
3572
+ },
3573
+ reviewRound: {
3574
+ type: "integer",
3575
+ maximum: 9007199254740991,
3576
+ exclusiveMinimum: 0
3577
+ },
3578
+ requirement: {
3579
+ type: "string",
3580
+ enum: [
3581
+ "run",
3582
+ "model",
3583
+ "person",
3584
+ "never"
3585
+ ]
3586
+ },
3587
+ decider: {
3588
+ type: "string",
3589
+ enum: [
3590
+ "rule",
3591
+ "model",
3592
+ "person",
3593
+ "agent"
3594
+ ]
3595
+ },
3481
3596
  outcome: {
3482
3597
  type: "string",
3483
3598
  enum: [
3484
3599
  "allow",
3485
- "requireApproval",
3486
- "deny"
3600
+ "hold",
3601
+ "refuse"
3487
3602
  ]
3488
3603
  },
3489
- reason: { anyOf: [{ type: "string" }, { type: "null" }] },
3490
- policyId: { anyOf: [{
3604
+ reason: {
3491
3605
  type: "string",
3492
- pattern: "^mbxpol_[0-9a-hjkmnp-tv-z]{16,24}$"
3606
+ minLength: 1
3607
+ },
3608
+ scopes: {
3609
+ type: "array",
3610
+ items: {
3611
+ type: "object",
3612
+ properties: {
3613
+ kind: {
3614
+ type: "string",
3615
+ enum: [
3616
+ "organization",
3617
+ "mailbox",
3618
+ "agent",
3619
+ "apiKey"
3620
+ ]
3621
+ },
3622
+ id: {
3623
+ type: "string",
3624
+ minLength: 1
3625
+ }
3626
+ },
3627
+ required: ["kind", "id"],
3628
+ additionalProperties: true
3629
+ }
3630
+ },
3631
+ rule: { anyOf: [{
3632
+ type: "object",
3633
+ properties: {
3634
+ scope: {
3635
+ type: "object",
3636
+ properties: {
3637
+ kind: {
3638
+ type: "string",
3639
+ enum: [
3640
+ "organization",
3641
+ "mailbox",
3642
+ "agent",
3643
+ "apiKey"
3644
+ ]
3645
+ },
3646
+ id: {
3647
+ type: "string",
3648
+ minLength: 1
3649
+ }
3650
+ },
3651
+ required: ["kind", "id"],
3652
+ additionalProperties: true
3653
+ },
3654
+ index: {
3655
+ type: "integer",
3656
+ minimum: 0,
3657
+ maximum: 9007199254740991
3658
+ }
3659
+ },
3660
+ required: ["scope", "index"],
3661
+ additionalProperties: true
3493
3662
  }, { type: "null" }] },
3494
- source: { anyOf: [{
3663
+ guard: { anyOf: [{
3495
3664
  type: "string",
3496
- enum: [
3497
- "grant",
3498
- "installation",
3499
- "policy"
3500
- ]
3665
+ minLength: 1
3666
+ }, { type: "null" }] },
3667
+ guardReason: { anyOf: [{
3668
+ type: "string",
3669
+ minLength: 1
3501
3670
  }, { type: "null" }] },
3502
- decidedAt: { type: "string" }
3671
+ resolution: { anyOf: [{
3672
+ type: "object",
3673
+ properties: {
3674
+ by: {
3675
+ type: "string",
3676
+ pattern: "^user_[0-9a-hjkmnp-tv-z]{16,24}$"
3677
+ },
3678
+ at: { type: "string" },
3679
+ as: {
3680
+ type: "string",
3681
+ enum: [
3682
+ "approved",
3683
+ "edited",
3684
+ "denied",
3685
+ "alwaysAllowed"
3686
+ ]
3687
+ },
3688
+ diff: { anyOf: [{
3689
+ type: "object",
3690
+ properties: {
3691
+ text: { anyOf: [{
3692
+ type: "object",
3693
+ properties: {
3694
+ before: { anyOf: [{ type: "string" }, { type: "null" }] },
3695
+ after: { anyOf: [{ type: "string" }, { type: "null" }] }
3696
+ },
3697
+ required: ["before", "after"],
3698
+ additionalProperties: true
3699
+ }, { type: "null" }] },
3700
+ html: { anyOf: [{
3701
+ type: "object",
3702
+ properties: {
3703
+ before: { anyOf: [{ type: "string" }, { type: "null" }] },
3704
+ after: { anyOf: [{ type: "string" }, { type: "null" }] }
3705
+ },
3706
+ required: ["before", "after"],
3707
+ additionalProperties: true
3708
+ }, { type: "null" }] }
3709
+ },
3710
+ additionalProperties: true
3711
+ }, { type: "null" }] }
3712
+ },
3713
+ required: [
3714
+ "by",
3715
+ "at",
3716
+ "as"
3717
+ ],
3718
+ additionalProperties: true
3719
+ }, { type: "null" }] }
3503
3720
  },
3504
3721
  required: [
3722
+ "id",
3723
+ "reviewRound",
3724
+ "requirement",
3725
+ "decider",
3505
3726
  "outcome",
3506
3727
  "reason",
3507
- "policyId",
3508
- "source",
3509
- "decidedAt"
3728
+ "scopes"
3510
3729
  ],
3511
- additionalProperties: true,
3512
- description: "Deliveries recorded before this field existed omit it."
3730
+ additionalProperties: true
3513
3731
  },
3514
3732
  threadId: { anyOf: [{
3515
3733
  type: "string",
@@ -3556,6 +3774,8 @@ const WebhookEventJsonSchemas = {
3556
3774
  required: [
3557
3775
  "id",
3558
3776
  "type",
3777
+ "reviewRound",
3778
+ "decision",
3559
3779
  "threadId",
3560
3780
  "reason",
3561
3781
  "proposedBy",
@@ -3664,9 +3884,15 @@ const WebhookEventJsonSchemas = {
3664
3884
  "changeThreadState",
3665
3885
  "call",
3666
3886
  "extensionRequest",
3667
- "toolCall"
3887
+ "toolCall",
3888
+ "handoff"
3668
3889
  ]
3669
3890
  },
3891
+ reviewRound: {
3892
+ type: "integer",
3893
+ maximum: 9007199254740991,
3894
+ exclusiveMinimum: 0
3895
+ },
3670
3896
  threadId: { anyOf: [{
3671
3897
  type: "string",
3672
3898
  pattern: "^thread_[0-9a-hjkmnp-tv-z]{16,24}$"
@@ -3711,6 +3937,7 @@ const WebhookEventJsonSchemas = {
3711
3937
  required: [
3712
3938
  "id",
3713
3939
  "type",
3940
+ "reviewRound",
3714
3941
  "threadId",
3715
3942
  "proposedBy",
3716
3943
  "createdAt"
@@ -4495,4 +4722,4 @@ const WebhookEventJsonSchemas = {
4495
4722
  };
4496
4723
  export { WebhookEventJsonSchemas as t };
4497
4724
 
4498
- //# sourceMappingURL=json-schemas.gen-BHKhYQV4.js.map
4725
+ //# sourceMappingURL=json-schemas.gen-C5nX_b5f.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-D6py4UMl.js";
2
- import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-BHKhYQV4.js";
1
+ import { a as generateWebhookSecret, c as verifyWebhookAt, d as MalformedWebhookPayloadError, f as WebhookCryptoError, g as isKnownEvent, h as WebhookVerificationError, i as WEBHOOK_TIMESTAMP_HEADER, l as InvalidWebhookHeadersError, m as WebhookTimestampError, n as WEBHOOK_ID_HEADER, o as readWebhookHeaders, p as WebhookSignatureError, r as WEBHOOK_SIGNATURE_HEADER, s as signWebhook, t as DEFAULT_TOLERANCE_SECONDS, u as InvalidWebhookSecretError } from "./protocol-IJ8lllqW.js";
2
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-C5nX_b5f.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