@assinafy/cli 2.7.0 → 2.7.1

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/api.js CHANGED
@@ -2294,7 +2294,7 @@ var DEFAULT_EVENTS = [
2294
2294
  "signer_rejected_document",
2295
2295
  "document_processing_failed"
2296
2296
  ];
2297
- function validateWebhookFields(payload) {
2297
+ function validateWebhookFields(payload, requireHttps = false) {
2298
2298
  if (payload.url !== void 0) {
2299
2299
  let webhookUrl;
2300
2300
  try {
@@ -2305,6 +2305,9 @@ function validateWebhookFields(payload) {
2305
2305
  if (webhookUrl.protocol !== "http:" && webhookUrl.protocol !== "https:") {
2306
2306
  throw new ValidationError("Webhook URL must be a valid HTTP(S) URL");
2307
2307
  }
2308
+ if (requireHttps && webhookUrl.protocol !== "https:") {
2309
+ throw new ValidationError("Webhook URL must use HTTPS");
2310
+ }
2308
2311
  }
2309
2312
  if (payload.email !== void 0) requireEmail(payload.email);
2310
2313
  if (payload.events !== void 0 && (!Array.isArray(payload.events) || payload.events.some((event) => typeof event !== "string" || !event))) {
@@ -2327,7 +2330,7 @@ var WebhookResource = class extends BaseResource {
2327
2330
  */
2328
2331
  async register(payload, accountId) {
2329
2332
  if (!payload.url) throw new ValidationError("Webhook URL is required");
2330
- validateWebhookFields({ ...payload, email: payload.email ?? "" });
2333
+ validateWebhookFields({ ...payload, email: payload.email ?? "" }, true);
2331
2334
  const id = this.accountId(accountId);
2332
2335
  const body = {
2333
2336
  url: payload.url,
@@ -2378,7 +2381,7 @@ var WebhookResource = class extends BaseResource {
2378
2381
  */
2379
2382
  async createEndpoint(payload, accountId) {
2380
2383
  if (!payload.url) throw new ValidationError("Webhook URL is required");
2381
- validateWebhookFields({ ...payload, email: payload.email ?? "" });
2384
+ validateWebhookFields({ ...payload, email: payload.email ?? "" }, true);
2382
2385
  const id = this.accountId(accountId);
2383
2386
  const body = { ...payload, events: payload.events ?? DEFAULT_EVENTS };
2384
2387
  this.logger.info("Creating webhook endpoint", { eventCount: body.events.length });
@@ -2408,7 +2411,7 @@ var WebhookResource = class extends BaseResource {
2408
2411
  if (!payload || typeof payload !== "object" || Object.keys(payload).length === 0) {
2409
2412
  throw new ValidationError("At least one webhook endpoint field is required");
2410
2413
  }
2411
- validateWebhookFields(payload);
2414
+ validateWebhookFields(payload, true);
2412
2415
  return this.call(
2413
2416
  "Failed to update webhook endpoint",
2414
2417
  () => this.http.put(`/accounts/${id}/webhooks/endpoints/${eid}`, payload)