@hostwebhook/node 1.6.1 → 1.6.2

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/README.md CHANGED
@@ -113,7 +113,7 @@ const result = await hw.send(
113
113
  { waitForResult: true },
114
114
  );
115
115
 
116
- console.log(result.syncStatus); // 200 = delivered, 422 = validation failed, 502 = failed, 408 = timeout
116
+ console.log(result.syncStatus); // 200 = delivered, 202 = paused, 422 = validation failed, 500 = failed, 408 = timeout
117
117
  console.log(result.steps); // array of pipeline steps with nodeType, status, durationMs
118
118
  console.log(result.response); // response body from target URL
119
119
  ```
@@ -187,7 +187,7 @@ Your endpoint has a **Response Mode** setting (None or Sync) that affects how `s
187
187
  |----------|--------------|------------|----------|
188
188
  | **Forms / UIs** | None | `onResult` | `send()` returns instantly. Pipeline result arrives in background callback. **UI never blocks.** |
189
189
  | **Backend scripts** | None | `waitForResult` | `send()` blocks until pipeline completes via SSE (~120s max). |
190
- | **API proxy / Stripe** | Sync | *(none)* | `send()` blocks until pipeline completes via HTTP (~120s max). Result is inline in the response. |
190
+ | **API proxy / Stripe** | Sync | *(none)* | `send()` blocks until a Schema Validator or an AI Node in the flow answers (20s at most, 55s with an AI Node; `timeoutMs` is 60s by default, enough for both). A 2xx is the result; a 422, 500 or 408 throws `SendError` with the JSON body in `responseBody`. |
191
191
  | **Testing (Postman)** | Sync | *(none)* | Single request, response includes full pipeline result. |
192
192
 
193
193
  > **Warning: Never use Sync mode for user-facing forms or UIs.** Sync mode holds the HTTP connection open on the server, which blocks `send()` and freezes the UI until the pipeline completes. If the pipeline has approval nodes, merge nodes, or long delays, the SDK will timeout. Use **None** mode with `onResult` instead — the user sees "Sent!" immediately and the pipeline result arrives in the background.
@@ -214,7 +214,7 @@ Your endpoint has a **Response Mode** setting (None or Sync) that affects how `s
214
214
  | `signingSecret` | `string` | — | Signs outgoing requests with HMAC-SHA256 |
215
215
  | `signature` | `StaticSignature` | — | Static secret signature (alternative to HMAC) |
216
216
  | `defaultHeaders` | `Record<string, string>` | — | Headers added to every request |
217
- | `timeoutMs` | `number` | `10000` | Request timeout in ms |
217
+ | `timeoutMs` | `number` | `60000` | Request timeout in ms (long enough for a Sync webhook) |
218
218
 
219
219
  ### SendOptions
220
220
 
package/dist/index.d.mts CHANGED
@@ -220,7 +220,7 @@ interface HostWebhookConfig {
220
220
  signature?: StaticSignature;
221
221
  /** Custom headers to include in every request. */
222
222
  defaultHeaders?: Record<string, string>;
223
- /** Request timeout in milliseconds. Default: 10000 (10s). */
223
+ /** Request timeout in milliseconds. Default: 60000 (60s), long enough for a Sync webhook with an AI Node (55s at most). */
224
224
  timeoutMs?: number;
225
225
  }
226
226
  /** A single pipeline execution step received via SSE stream. */
@@ -295,7 +295,13 @@ interface SendResult {
295
295
  eventId: string;
296
296
  /** Short-lived token for SSE stream auth (returned by ingress, used internally by waitForResult). */
297
297
  streamToken?: string;
298
- /** Sync/stream: pipeline result status (200=delivered, 422=validation failed, 502=delivery failed, 408=timeout) */
298
+ /**
299
+ * Stream (`waitForResult`, `onResult`, `stream()`): pipeline result status —
300
+ * 200=delivered, 202=paused (approval, merge or a long delay), 422=validation
301
+ * failed, 500=delivery failed, 408=timeout. A webhook in Sync response mode
302
+ * answers with the real HTTP status instead: a non-2xx (422, 500, 408) throws
303
+ * `SendError` with the JSON body in `responseBody`.
304
+ */
299
305
  syncStatus?: number;
300
306
  /** Sync/stream: delivery status ('delivered') */
301
307
  deliveryStatus?: string;
package/dist/index.d.ts CHANGED
@@ -220,7 +220,7 @@ interface HostWebhookConfig {
220
220
  signature?: StaticSignature;
221
221
  /** Custom headers to include in every request. */
222
222
  defaultHeaders?: Record<string, string>;
223
- /** Request timeout in milliseconds. Default: 10000 (10s). */
223
+ /** Request timeout in milliseconds. Default: 60000 (60s), long enough for a Sync webhook with an AI Node (55s at most). */
224
224
  timeoutMs?: number;
225
225
  }
226
226
  /** A single pipeline execution step received via SSE stream. */
@@ -295,7 +295,13 @@ interface SendResult {
295
295
  eventId: string;
296
296
  /** Short-lived token for SSE stream auth (returned by ingress, used internally by waitForResult). */
297
297
  streamToken?: string;
298
- /** Sync/stream: pipeline result status (200=delivered, 422=validation failed, 502=delivery failed, 408=timeout) */
298
+ /**
299
+ * Stream (`waitForResult`, `onResult`, `stream()`): pipeline result status —
300
+ * 200=delivered, 202=paused (approval, merge or a long delay), 422=validation
301
+ * failed, 500=delivery failed, 408=timeout. A webhook in Sync response mode
302
+ * answers with the real HTTP status instead: a non-2xx (422, 500, 408) throws
303
+ * `SendError` with the JSON body in `responseBody`.
304
+ */
299
305
  syncStatus?: number;
300
306
  /** Sync/stream: delivery status ('delivered') */
301
307
  deliveryStatus?: string;
package/dist/index.js CHANGED
@@ -213,7 +213,7 @@ var SendError = class extends Error {
213
213
 
214
214
  // src/client.ts
215
215
  var DEFAULT_BASE_URL = "https://api.hostwebhook.com";
216
- var DEFAULT_TIMEOUT = 1e4;
216
+ var DEFAULT_TIMEOUT = 6e4;
217
217
  var _apiKey, _token, _baseUrl, _signingSecret, _signature, _defaultHeaders, _timeoutMs, _HostWebhook_instances, doSend_fn, waitForStream_fn;
218
218
  var HostWebhook = class {
219
219
  constructor(config) {
@@ -410,7 +410,7 @@ doSend_fn = async function(token, payload, options) {
410
410
  }
411
411
  const headers = {
412
412
  "Content-Type": options?.contentType ?? "application/json",
413
- "User-Agent": `HostWebhook-SDK/${"1.6.1"}`,
413
+ "User-Agent": `HostWebhook-SDK/${"1.6.2"}`,
414
414
  "X-HostWebhook-Sent-At": (/* @__PURE__ */ new Date()).toISOString(),
415
415
  ...tz ? { "X-HostWebhook-Timezone": tz } : {},
416
416
  ...__privateGet(this, _defaultHeaders),
@@ -457,6 +457,10 @@ doSend_fn = async function(token, payload, options) {
457
457
  } catch {
458
458
  ingressResult = { eventId: text };
459
459
  }
460
+ if (!ingressResult.eventId) {
461
+ const deCabecera = res.headers.get("x-hostwebhook-event-id");
462
+ if (deCabecera) ingressResult = { ...ingressResult, eventId: deCabecera };
463
+ }
460
464
  } catch (err) {
461
465
  if (err instanceof SendError) throw err;
462
466
  if (err instanceof DOMException && err.name === "AbortError") {
package/dist/index.mjs CHANGED
@@ -179,7 +179,7 @@ var SendError = class extends Error {
179
179
 
180
180
  // src/client.ts
181
181
  var DEFAULT_BASE_URL = "https://api.hostwebhook.com";
182
- var DEFAULT_TIMEOUT = 1e4;
182
+ var DEFAULT_TIMEOUT = 6e4;
183
183
  var _apiKey, _token, _baseUrl, _signingSecret, _signature, _defaultHeaders, _timeoutMs, _HostWebhook_instances, doSend_fn, waitForStream_fn;
184
184
  var HostWebhook = class {
185
185
  constructor(config) {
@@ -376,7 +376,7 @@ doSend_fn = async function(token, payload, options) {
376
376
  }
377
377
  const headers = {
378
378
  "Content-Type": options?.contentType ?? "application/json",
379
- "User-Agent": `HostWebhook-SDK/${"1.6.1"}`,
379
+ "User-Agent": `HostWebhook-SDK/${"1.6.2"}`,
380
380
  "X-HostWebhook-Sent-At": (/* @__PURE__ */ new Date()).toISOString(),
381
381
  ...tz ? { "X-HostWebhook-Timezone": tz } : {},
382
382
  ...__privateGet(this, _defaultHeaders),
@@ -423,6 +423,10 @@ doSend_fn = async function(token, payload, options) {
423
423
  } catch {
424
424
  ingressResult = { eventId: text };
425
425
  }
426
+ if (!ingressResult.eventId) {
427
+ const deCabecera = res.headers.get("x-hostwebhook-event-id");
428
+ if (deCabecera) ingressResult = { ...ingressResult, eventId: deCabecera };
429
+ }
426
430
  } catch (err) {
427
431
  if (err instanceof SendError) throw err;
428
432
  if (err instanceof DOMException && err.name === "AbortError") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostwebhook/node",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Official HostWebhook SDK — verify signatures, parse headers, and send webhooks",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",