@patchstack/connect 0.3.19 → 0.3.21

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/protect.d.ts CHANGED
@@ -23,6 +23,13 @@ export interface Protection {
23
23
  node(options?: { maxBodyBytes?: number; screenResponses?: boolean }): (req: unknown, res: unknown, next: () => void) => void;
24
24
  /** Present when `egress: true` — restores the original global fetch. */
25
25
  uninstallEgress?: () => void;
26
+ /** Present with a live source — re-fetch + hot-swap the rules once (used by the loop + push). */
27
+ refresh?: () => Promise<void>;
28
+ /** Present with a live source — a fetch handler that runs `refresh()` when the request carries
29
+ * the configured refresh secret (a push/zero-day trigger). No secret set → the handler 404s. */
30
+ refreshHandler?: () => (request: Request) => Promise<Response>;
31
+ /** Present when `refreshMs > 0` — stops the live rule-refresh loop. */
32
+ stopRefresh?: () => void;
26
33
  }
27
34
 
28
35
  export interface CreateProtectionOptions {
@@ -37,6 +44,28 @@ export interface CreateProtectionOptions {
37
44
  siteUuid?: string;
38
45
  /** Override the Pulse rules API base URL. */
39
46
  pulseRulesUrl?: string;
47
+ /**
48
+ * Re-fetch and hot-swap the live rules every N ms. For long-lived runtimes that aren't restarted
49
+ * on change (an AI builder's sandbox/preview) so a rule that becomes relevant after boot still
50
+ * applies. Default 0 (off) — a real deploy restarts the process, which re-fetches anyway. Only
51
+ * meaningful with a live source (`siteUuid`/`token`).
52
+ */
53
+ refreshMs?: number;
54
+ /**
55
+ * Shared secret gating the push refresh endpoint (`refreshHandler()`): the platform/SaaS hits the
56
+ * endpoint with this secret to trigger an immediate refresh. Falls back to `PATCHSTACK_REFRESH_SECRET`.
57
+ * Unset → the endpoint 404s (never an open refresh trigger).
58
+ */
59
+ refreshSecret?: string;
60
+ /**
61
+ * During a refresh, also re-post the dependency manifest (the runtime counterpart to `scan`) so a
62
+ * dependency added after boot — e.g. via `npm install <pkg>`, which fires no npm lifecycle hook —
63
+ * is reported and enforced without a restart. Defaults on when a `siteUuid` is set; set false to
64
+ * refresh rules only. Only meaningful with `refreshMs > 0` and a Pulse `siteUuid`.
65
+ */
66
+ reportManifest?: boolean;
67
+ /** Directory the manifest re-scan reads the lockfile from during a refresh. Default process.cwd(). */
68
+ cwd?: string;
40
69
  /** Directory for the last-known-good rule cache (disk — the default cache backend). */
41
70
  cacheDir?: string;
42
71
  /**
@@ -55,6 +84,12 @@ export interface CreateProtectionOptions {
55
84
  egress?: boolean;
56
85
  /** Hosts exempt from egress screening. */
57
86
  allowHosts?: string[];
87
+ /**
88
+ * Screen the Node http/https path against DNS rebinding: resolve outbound hostnames and block +
89
+ * pin to the vetted address when they map to a disallowed (internal/metadata) IP. Default true;
90
+ * only active when `egress` is on and node:dns is available (a no-op on edge runtimes).
91
+ */
92
+ screenDns?: boolean;
58
93
  /** Redaction mask (string or per-category function). Default "[REDACTED]". */
59
94
  maskWith?: string | ((category?: string) => string);
60
95
  onError?: (err: unknown) => void;