@commet/node 7.2.0 → 7.4.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
@@ -435,7 +435,11 @@ var PromoCodesResource = class {
435
435
  const { id } = params;
436
436
  return this.httpClient.get(`/promo-codes/${id}`, void 0, options);
437
437
  }
438
- /** Create a new promo code. Optionally restrict to specific plans. */
438
+ /**
439
+ * Create a new promo code. Optionally restrict to specific plans.
440
+ *
441
+ * **100% discounts are not supported.** Percentage codes must be strictly less than 100% (`discountValue` < 10000 basis points). For full waivers, use an introductory offer on the plan instead. At checkout, any code — percentage or fixed amount — that would reduce the total below the currency's minimum charge ($0.50 USD equivalent) is silently dropped.
442
+ */
439
443
  async create(params, options) {
440
444
  return this.httpClient.post("/promo-codes", params, options);
441
445
  }
@@ -536,7 +540,7 @@ var SubscriptionsResource = class {
536
540
  const { id } = params;
537
541
  return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);
538
542
  }
539
- /** Retries the outstanding renewal charge for a past_due subscription. On a successful charge the subscription recovers to active and a payment.recovered webhook is delivered; a declined charge returns an error and the subscription stays past_due. */
543
+ /** Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. */
540
544
  async reactivate(params, options) {
541
545
  const { id } = params;
542
546
  return this.httpClient.post(`/subscriptions/${id}/reactivate`, {}, options);
@@ -728,8 +732,8 @@ import crypto2 from "crypto";
728
732
  var Webhooks = class {
729
733
  constructor(httpClient) {
730
734
  this.httpClient = httpClient;
735
+ this.eventHandlers = /* @__PURE__ */ new Map();
731
736
  }
732
- /** HMAC-SHA256 verification. Payload must be the raw request body string, not parsed JSON. */
733
737
  verify(params) {
734
738
  const { payload, signature, secret } = params;
735
739
  if (!signature || !secret || !payload) {
@@ -749,7 +753,6 @@ var Webhooks = class {
749
753
  const { payload, secret } = params;
750
754
  return crypto2.createHmac("sha256", secret).update(payload).digest("hex");
751
755
  }
752
- /** Verifies signature and parses JSON in one step. Returns null if invalid. */
753
756
  verifyAndParse(params) {
754
757
  const { rawBody, signature, secret } = params;
755
758
  if (!this.verify({ payload: rawBody, signature, secret })) {
@@ -761,6 +764,20 @@ var Webhooks = class {
761
764
  return null;
762
765
  }
763
766
  }
767
+ on(event, handler) {
768
+ this.eventHandlers.set(
769
+ event,
770
+ handler
771
+ );
772
+ return this;
773
+ }
774
+ async process(params) {
775
+ const payload = this.verifyAndParse(params);
776
+ if (!payload) return null;
777
+ const handler = this.eventHandlers.get(payload.event);
778
+ if (handler) await handler(payload.data, payload);
779
+ return payload;
780
+ }
764
781
  async list(params, options) {
765
782
  return this.httpClient.get("/webhooks", params, options);
766
783
  }
@@ -816,8 +833,8 @@ var CommetValidationError = class extends CommetError {
816
833
  };
817
834
 
818
835
  // src/version.ts
819
- var API_VERSION = "2026-06-10";
820
- var SDK_VERSION = "7.2.0";
836
+ var API_VERSION = "2026-06-23";
837
+ var SDK_VERSION = "7.4.0";
821
838
 
822
839
  // src/utils/telemetry.ts
823
840
  var registeredIntegrations = /* @__PURE__ */ new Set();