@samva/webhooks 0.22.1 → 0.23.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,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-8ERuoP0F.js";
2
- import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-CPzGmYvg.js";
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-BshlNyvg.js";
2
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-CaL1pRff.js";
3
3
  import { ContactConsentChangedEventSchema, ContactCreatedEventSchema, ContactDeletedEventSchema, ContactResubscribedEventSchema, ContactSubscribedEventSchema, ContactUnsubscribedEventSchema, ContactUpdatedEventSchema, ConversationArchivedEventSchema, ConversationCreatedEventSchema, ConversationUpdatedEventSchema, DomainUpdatedEventSchema, DomainWarmingUpdatedEventSchema, FlowRegistrationUpdatedEventSchema, JourneyWebhookEventSchema, MailboxActionPendingApprovalEventSchema, MailboxActionResolvedEventSchema, MailboxMessageDiscardedEventSchema, MailboxMessageQuarantinedEventSchema, 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
  //#region src/effect.ts
@@ -2498,11 +2498,31 @@ const WebhookEventJsonSchemas = {
2498
2498
  type: "object",
2499
2499
  properties: {
2500
2500
  observed: { type: "boolean" },
2501
- total: { type: "integer" },
2502
- satisfied: { type: "integer" },
2503
- missing: { type: "integer" },
2504
- mismatch: { type: "integer" },
2505
- unknown: { type: "integer" }
2501
+ total: {
2502
+ type: "integer",
2503
+ minimum: -9007199254740991,
2504
+ maximum: 9007199254740991
2505
+ },
2506
+ satisfied: {
2507
+ type: "integer",
2508
+ minimum: -9007199254740991,
2509
+ maximum: 9007199254740991
2510
+ },
2511
+ missing: {
2512
+ type: "integer",
2513
+ minimum: -9007199254740991,
2514
+ maximum: 9007199254740991
2515
+ },
2516
+ mismatch: {
2517
+ type: "integer",
2518
+ minimum: -9007199254740991,
2519
+ maximum: 9007199254740991
2520
+ },
2521
+ unknown: {
2522
+ type: "integer",
2523
+ minimum: -9007199254740991,
2524
+ maximum: 9007199254740991
2525
+ }
2506
2526
  },
2507
2527
  required: [
2508
2528
  "observed",
@@ -2838,7 +2858,11 @@ const WebhookEventJsonSchemas = {
2838
2858
  type: "string",
2839
2859
  pattern: "^wafver_[0-9a-hjkmnp-tv-z]{16,24}$"
2840
2860
  },
2841
- versionNumber: { type: "integer" },
2861
+ versionNumber: {
2862
+ type: "integer",
2863
+ minimum: -9007199254740991,
2864
+ maximum: 9007199254740991
2865
+ },
2842
2866
  wabaId: { type: "string" },
2843
2867
  providerFlowId: { anyOf: [{ type: "string" }, { type: "null" }] },
2844
2868
  name: { type: "string" },
@@ -2860,8 +2884,16 @@ const WebhookEventJsonSchemas = {
2860
2884
  error: { type: "string" },
2861
2885
  message: { type: "string" },
2862
2886
  path: { type: "string" },
2863
- line: { type: "integer" },
2864
- column: { type: "integer" }
2887
+ line: {
2888
+ type: "integer",
2889
+ minimum: -9007199254740991,
2890
+ maximum: 9007199254740991
2891
+ },
2892
+ column: {
2893
+ type: "integer",
2894
+ minimum: -9007199254740991,
2895
+ maximum: 9007199254740991
2896
+ }
2865
2897
  },
2866
2898
  required: ["error", "message"],
2867
2899
  additionalProperties: true
@@ -4046,7 +4078,11 @@ const WebhookEventJsonSchemas = {
4046
4078
  type: "string",
4047
4079
  pattern: "^jrny_[0-9a-hjkmnp-tv-z]{16,24}$"
4048
4080
  },
4049
- journeyVersion: { type: "integer" },
4081
+ journeyVersion: {
4082
+ type: "integer",
4083
+ minimum: -9007199254740991,
4084
+ maximum: 9007199254740991
4085
+ },
4050
4086
  runId: {
4051
4087
  type: "string",
4052
4088
  pattern: "^jrun_[0-9a-hjkmnp-tv-z]{16,24}$"
@@ -4094,4 +4130,4 @@ const WebhookEventJsonSchemas = {
4094
4130
  //#endregion
4095
4131
  export { WebhookEventJsonSchemas as t };
4096
4132
 
4097
- //# sourceMappingURL=json-schemas.gen-CPzGmYvg.js.map
4133
+ //# sourceMappingURL=json-schemas.gen-CaL1pRff.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-8ERuoP0F.js";
2
- import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-CPzGmYvg.js";
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-BshlNyvg.js";
2
+ import { t as WebhookEventJsonSchemas } from "./json-schemas.gen-CaL1pRff.js";
3
3
  //#region src/promise.ts
4
4
  /**
5
5
  * Verifies a Samva webhook delivery from its body and header values, then returns its ID and
@@ -205,7 +205,7 @@ const validate1262 = (value) => isObject(value) && isObject(value) && Object.has
205
205
  const validate1263 = (value) => typeof value === "string" && typeof value === "string" && (/* @__PURE__ */ new RegExp("^dom_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).test(value);
206
206
  const validate1266 = (value) => typeof value === "string" && (value === "dns-setup" || value === "provisioning" || value === "verifying" || value === "ready" || value === "degraded" || value === "failed");
207
207
  const validate1268 = (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") || validate1270(value["total"])) && (!Object.hasOwn(value, "satisfied") || validate1270(value["satisfied"])) && (!Object.hasOwn(value, "missing") || validate1270(value["missing"])) && (!Object.hasOwn(value, "mismatch") || validate1270(value["mismatch"])) && (!Object.hasOwn(value, "unknown") || validate1270(value["unknown"]));
208
- const validate1270 = (value) => typeof value === "number" && Number.isInteger(value);
208
+ const validate1270 = (value) => typeof value === "number" && Number.isInteger(value) && typeof value === "number" && value >= -9007199254740991 && typeof value === "number" && value <= 9007199254740991;
209
209
  const validate1275 = (value) => validate1276(value) || validate6(value);
210
210
  const validate1276 = (value) => isObject(value) && isObject(value) && Object.hasOwn(value, "identity") && (!Object.hasOwn(value, "identity") || validate1277(value["identity"])) && (!Object.hasOwn(value, "dkim") || validate1278(value["dkim"])) && (!Object.hasOwn(value, "mailFrom") || validate1278(value["mailFrom"]));
211
211
  const validate1277 = (value) => typeof value === "string" && (value === "pending" || value === "verified" || value === "failed" || value === "unknown");
@@ -727,4 +727,4 @@ const readWebhookHeaders = (headers) => requireHeaders({
727
727
  //#endregion
728
728
  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 };
729
729
 
730
- //# sourceMappingURL=protocol-8ERuoP0F.js.map
730
+ //# sourceMappingURL=protocol-BshlNyvg.js.map
package/dist/protocol.js CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as WebhookTimestampError, a as encodeWebhookSignature, c as signWebhook, d as webhookSignedContent, 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, u as verifyWebhookAtWithPublicKeys, v as WebhookVerificationError, y as isKnownEvent } from "./protocol-8ERuoP0F.js";
1
+ import { _ as WebhookTimestampError, a as encodeWebhookSignature, c as signWebhook, d as webhookSignedContent, 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, u as verifyWebhookAtWithPublicKeys, v as WebhookVerificationError, y as isKnownEvent } from "./protocol-BshlNyvg.js";
2
2
  export { DEFAULT_TOLERANCE_SECONDS, InvalidWebhookHeadersError, InvalidWebhookSecretError, MalformedWebhookPayloadError, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WebhookCryptoError, WebhookSignatureError, WebhookTimestampError, WebhookVerificationError, encodeWebhookSignature, generateWebhookSecret, isKnownEvent, readWebhookHeaders, signWebhook, verifyWebhookAt, verifyWebhookAtWithPublicKeys, webhookSignedContent };
@@ -966,11 +966,11 @@ const DomainUpdatedEventSchema = Schema.StructWithRest(Schema.Struct({
966
966
  ]),
967
967
  dns: Schema.StructWithRest(Schema.Struct({
968
968
  observed: Schema.Boolean,
969
- total: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })),
970
- satisfied: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })),
971
- missing: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })),
972
- mismatch: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })),
973
- unknown: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" }))
969
+ total: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" })),
970
+ satisfied: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" })),
971
+ missing: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" })),
972
+ mismatch: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" })),
973
+ unknown: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" }))
974
974
  }), [Schema.Record(Schema.String, Schema.Json.annotate({ expected: "JSON value" }))]),
975
975
  provider: Schema.Union([Schema.StructWithRest(Schema.Struct({
976
976
  identity: Schema.Literals([
@@ -1106,7 +1106,7 @@ const FlowRegistrationUpdatedEventSchema = Schema.StructWithRest(Schema.Struct({
1106
1106
  id: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^wafreg_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^wafreg_[0-9a-hjkmnp-tv-z]{16,24}$" })),
1107
1107
  flowId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^waflow_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^waflow_[0-9a-hjkmnp-tv-z]{16,24}$" })),
1108
1108
  versionId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^wafver_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^wafver_[0-9a-hjkmnp-tv-z]{16,24}$" })),
1109
- versionNumber: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })),
1109
+ versionNumber: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" })),
1110
1110
  wabaId: Schema.String,
1111
1111
  providerFlowId: Schema.Union([Schema.String, Schema.Null]),
1112
1112
  name: Schema.String,
@@ -1121,8 +1121,8 @@ const FlowRegistrationUpdatedEventSchema = Schema.StructWithRest(Schema.Struct({
1121
1121
  error: Schema.String,
1122
1122
  message: Schema.String,
1123
1123
  path: Schema.optionalKey(Schema.String),
1124
- line: Schema.optionalKey(Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" }))),
1125
- column: Schema.optionalKey(Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })))
1124
+ line: Schema.optionalKey(Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" }))),
1125
+ column: Schema.optionalKey(Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" })))
1126
1126
  }), [Schema.Record(Schema.String, Schema.Json.annotate({ expected: "JSON value" }))])),
1127
1127
  endpointAlerts: Schema.Array(Schema.StructWithRest(Schema.Struct({
1128
1128
  kind: Schema.String,
@@ -1544,7 +1544,7 @@ const JourneyWebhookEventSchema = Schema.StructWithRest(Schema.Struct({
1544
1544
  data: Schema.StructWithRest(Schema.Struct({
1545
1545
  organizationId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^org_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^org_[0-9a-hjkmnp-tv-z]{16,24}$" })),
1546
1546
  journeyId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^jrny_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^jrny_[0-9a-hjkmnp-tv-z]{16,24}$" })),
1547
- journeyVersion: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })),
1547
+ journeyVersion: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" })),
1548
1548
  runId: Schema.String.check(Schema.isPattern(/* @__PURE__ */ new RegExp("^jrun_[0-9a-hjkmnp-tv-z]{16,24}$", "u")).annotate({ expected: "a string matching the RegExp ^jrun_[0-9a-hjkmnp-tv-z]{16,24}$" })),
1549
1549
  nodeId: Schema.String,
1550
1550
  contact: Schema.StructWithRest(Schema.Struct({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samva/webhooks",
3
- "version": "0.22.1",
3
+ "version": "0.23.0",
4
4
  "description": "Runtime-neutral verification for Samva webhook deliveries",
5
5
  "keywords": [
6
6
  "samva",