@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.d.mts +1063 -13
- package/dist/index.d.ts +1063 -13
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -481,7 +481,11 @@ var PromoCodesResource = class {
|
|
|
481
481
|
const { id } = params;
|
|
482
482
|
return this.httpClient.get(`/promo-codes/${id}`, void 0, options);
|
|
483
483
|
}
|
|
484
|
-
/**
|
|
484
|
+
/**
|
|
485
|
+
* Create a new promo code. Optionally restrict to specific plans.
|
|
486
|
+
*
|
|
487
|
+
* **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.
|
|
488
|
+
*/
|
|
485
489
|
async create(params, options) {
|
|
486
490
|
return this.httpClient.post("/promo-codes", params, options);
|
|
487
491
|
}
|
|
@@ -582,7 +586,7 @@ var SubscriptionsResource = class {
|
|
|
582
586
|
const { id } = params;
|
|
583
587
|
return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);
|
|
584
588
|
}
|
|
585
|
-
/**
|
|
589
|
+
/** 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. */
|
|
586
590
|
async reactivate(params, options) {
|
|
587
591
|
const { id } = params;
|
|
588
592
|
return this.httpClient.post(`/subscriptions/${id}/reactivate`, {}, options);
|
|
@@ -774,8 +778,8 @@ var import_node_crypto = __toESM(require("crypto"));
|
|
|
774
778
|
var Webhooks = class {
|
|
775
779
|
constructor(httpClient) {
|
|
776
780
|
this.httpClient = httpClient;
|
|
781
|
+
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
777
782
|
}
|
|
778
|
-
/** HMAC-SHA256 verification. Payload must be the raw request body string, not parsed JSON. */
|
|
779
783
|
verify(params) {
|
|
780
784
|
const { payload, signature, secret } = params;
|
|
781
785
|
if (!signature || !secret || !payload) {
|
|
@@ -795,7 +799,6 @@ var Webhooks = class {
|
|
|
795
799
|
const { payload, secret } = params;
|
|
796
800
|
return import_node_crypto.default.createHmac("sha256", secret).update(payload).digest("hex");
|
|
797
801
|
}
|
|
798
|
-
/** Verifies signature and parses JSON in one step. Returns null if invalid. */
|
|
799
802
|
verifyAndParse(params) {
|
|
800
803
|
const { rawBody, signature, secret } = params;
|
|
801
804
|
if (!this.verify({ payload: rawBody, signature, secret })) {
|
|
@@ -807,6 +810,20 @@ var Webhooks = class {
|
|
|
807
810
|
return null;
|
|
808
811
|
}
|
|
809
812
|
}
|
|
813
|
+
on(event, handler) {
|
|
814
|
+
this.eventHandlers.set(
|
|
815
|
+
event,
|
|
816
|
+
handler
|
|
817
|
+
);
|
|
818
|
+
return this;
|
|
819
|
+
}
|
|
820
|
+
async process(params) {
|
|
821
|
+
const payload = this.verifyAndParse(params);
|
|
822
|
+
if (!payload) return null;
|
|
823
|
+
const handler = this.eventHandlers.get(payload.event);
|
|
824
|
+
if (handler) await handler(payload.data, payload);
|
|
825
|
+
return payload;
|
|
826
|
+
}
|
|
810
827
|
async list(params, options) {
|
|
811
828
|
return this.httpClient.get("/webhooks", params, options);
|
|
812
829
|
}
|
|
@@ -862,8 +879,8 @@ var CommetValidationError = class extends CommetError {
|
|
|
862
879
|
};
|
|
863
880
|
|
|
864
881
|
// src/version.ts
|
|
865
|
-
var API_VERSION = "2026-06-
|
|
866
|
-
var SDK_VERSION = "7.
|
|
882
|
+
var API_VERSION = "2026-06-23";
|
|
883
|
+
var SDK_VERSION = "7.4.0";
|
|
867
884
|
|
|
868
885
|
// src/utils/telemetry.ts
|
|
869
886
|
var registeredIntegrations = /* @__PURE__ */ new Set();
|