@commet/node 7.2.0 → 7.3.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/index.mjs CHANGED
@@ -728,8 +728,8 @@ import crypto2 from "crypto";
728
728
  var Webhooks = class {
729
729
  constructor(httpClient) {
730
730
  this.httpClient = httpClient;
731
+ this.eventHandlers = /* @__PURE__ */ new Map();
731
732
  }
732
- /** HMAC-SHA256 verification. Payload must be the raw request body string, not parsed JSON. */
733
733
  verify(params) {
734
734
  const { payload, signature, secret } = params;
735
735
  if (!signature || !secret || !payload) {
@@ -749,7 +749,6 @@ var Webhooks = class {
749
749
  const { payload, secret } = params;
750
750
  return crypto2.createHmac("sha256", secret).update(payload).digest("hex");
751
751
  }
752
- /** Verifies signature and parses JSON in one step. Returns null if invalid. */
753
752
  verifyAndParse(params) {
754
753
  const { rawBody, signature, secret } = params;
755
754
  if (!this.verify({ payload: rawBody, signature, secret })) {
@@ -761,6 +760,20 @@ var Webhooks = class {
761
760
  return null;
762
761
  }
763
762
  }
763
+ on(event, handler) {
764
+ this.eventHandlers.set(
765
+ event,
766
+ handler
767
+ );
768
+ return this;
769
+ }
770
+ async process(params) {
771
+ const payload = this.verifyAndParse(params);
772
+ if (!payload) return null;
773
+ const handler = this.eventHandlers.get(payload.event);
774
+ if (handler) await handler(payload.data, payload);
775
+ return payload;
776
+ }
764
777
  async list(params, options) {
765
778
  return this.httpClient.get("/webhooks", params, options);
766
779
  }
@@ -817,7 +830,7 @@ var CommetValidationError = class extends CommetError {
817
830
 
818
831
  // src/version.ts
819
832
  var API_VERSION = "2026-06-10";
820
- var SDK_VERSION = "7.2.0";
833
+ var SDK_VERSION = "7.3.0";
821
834
 
822
835
  // src/utils/telemetry.ts
823
836
  var registeredIntegrations = /* @__PURE__ */ new Set();