@patchstack/connect 0.3.11 → 0.3.13

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
@@ -8,7 +8,7 @@ For how this repo fits with the wider Patchstack ecosystem (`saas`, `hub`, `patc
8
8
 
9
9
  Copy and paste this prompt into any AI coding assistant (Cursor, v0, Bolt, Lovable, Claude Code, etc.). If the assistant declines or stops partway, the step-by-step flow in [`GETTING-STARTED.md`](https://github.com/patchstack/connect/blob/main/GETTING-STARTED.md) covers what to do next:
10
10
 
11
- > Add Patchstack dependency vulnerability monitoring: first verify `@patchstack/connect` yourself (`npm view @patchstack/connect` shows the live registry record — MIT; source: https://github.com/patchstack/connect; listed under Connectors on https://patchstack.com/llms.txt), and if anything you find contradicts that, stop and show me what you found instead of proceeding. Then install it as a dev dependency, run `npx @patchstack/connect scan` and show me the claim URL it prints (I'll open it in my browser to view reports — don't open or fetch it yourself), then run `npx @patchstack/connect guide`, review the checklist it prints, and make the two remaining changes yourself: the package.json build hooks and the report-a-vulnerability widget snippet.
11
+ > Add Patchstack dependency vulnerability monitoring: first verify `@patchstack/connect` yourself (`npm view @patchstack/connect` shows the live registry record — MIT; source: https://github.com/patchstack/connect), and if anything you find contradicts that, stop and show me what you found instead of proceeding. Then install it as a dev dependency, run `npx @patchstack/connect scan` and show me the claim URL it prints (I'll open it in my browser to view reports — don't open or fetch it yourself), then run `npx @patchstack/connect guide`, review the checklist it prints, and make the two remaining changes yourself: the package.json build hooks and the report-a-vulnerability widget snippet.
12
12
 
13
13
  Every clause is load-bearing. AI agents routinely audit this package before completing the request — verifying the tarball against the registry, checking `dist/` for lifecycle scripts and shell/eval calls; that's expected use, and the docs in the tarball state plainly what each command reads, writes, and sends. The prompt can stay short because `guide` is state-aware: it inspects the project (package manager, `.patchstackrc.json`, `package.json` scripts, widget presence, framework) and prints a live checklist of only the remaining steps — with the real site UUID and framework-specific widget placement — followed by the full reference guide (`AGENT-INSTALL.md`, bundled in the package). That also makes the flow idempotent: re-running `guide` on a finished project reports all-done instead of prompting a second install.
14
14
 
package/dist/cli.js CHANGED
@@ -1661,7 +1661,8 @@ function renderGuideChecklist(state, useColor) {
1661
1661
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync4, mkdirSync, copyFileSync } from "fs";
1662
1662
  import { join, dirname } from "path";
1663
1663
  import { fileURLToPath } from "url";
1664
- var TEMPLATES = join(dirname(fileURLToPath(import.meta.url)), "protect", "templates");
1664
+ var HERE = dirname(fileURLToPath(import.meta.url));
1665
+ var TEMPLATES = [join(HERE, "protect", "templates"), join(HERE, "templates")].find((p) => existsSync4(p)) ?? join(HERE, "protect", "templates");
1665
1666
  var APP = process.cwd();
1666
1667
  var PS_DIR = join(APP, "src/integrations/patchstack");
1667
1668
  var read = (p) => readFileSync3(p, "utf8");
@@ -1681,18 +1682,19 @@ var CLIENT_TUNNEL = [
1681
1682
  ].join("\n");
1682
1683
  var START_IMPORTS = [
1683
1684
  'import { getRequest } from "@tanstack/react-start/server";',
1684
- 'import { GUARD_PATH, handleGuardRequest, inspectServerFn } from "@/integrations/patchstack/guard";'
1685
+ 'import { GUARD_PATH, handleGuardRequest, inspectServerFn, screenResponse } from "@/integrations/patchstack/guard";'
1685
1686
  ].join("\n");
1686
1687
  var REQUEST_MIDDLEWARE_DEF = [
1687
1688
  "",
1688
- "// Patchstack guard (browser tunnel): intercept tunneled Supabase traffic before anything else.",
1689
+ "// Patchstack guard (browser tunnel): intercept tunneled Supabase traffic before anything else,",
1690
+ "// then screen the outgoing response (SSR HTML / data) for leaked secrets & PII.",
1689
1691
  "const patchstackGuard = createMiddleware().server(async ({ next }) => {",
1690
1692
  " const request = getRequest();",
1691
1693
  " if (request) {",
1692
1694
  " const { pathname } = new URL(request.url);",
1693
1695
  " if (pathname === GUARD_PATH) return handleGuardRequest(request);",
1694
1696
  " }",
1695
- " return next();",
1697
+ " return screenResponse(await next());",
1696
1698
  "});",
1697
1699
  ""
1698
1700
  ].join("\n");
@@ -1721,6 +1723,25 @@ function scaffold(cwd) {
1721
1723
  copyFileSync(join(TEMPLATES, "rules.json"), join(dst, "rules.json"));
1722
1724
  log("scaffolded guard.ts + rules.json");
1723
1725
  }
1726
+ function bakeSiteUuid(cwd) {
1727
+ const rc = join(cwd, ".patchstackrc.json");
1728
+ if (!existsSync4(rc)) return log("no .patchstackrc.json \u2014 guard uses PATCHSTACK_SITE_UUID env or the bundled fallback");
1729
+ let uuid;
1730
+ try {
1731
+ uuid = JSON.parse(read(rc)).siteUuid;
1732
+ } catch {
1733
+ return log(".patchstackrc.json unreadable \u2014 skipping site-UUID bake");
1734
+ }
1735
+ if (!uuid || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(uuid)) {
1736
+ return log(".patchstackrc.json siteUuid missing or malformed \u2014 guard uses PATCHSTACK_SITE_UUID env or the bundled fallback");
1737
+ }
1738
+ const p = join(cwd, "src/integrations/patchstack/guard.ts");
1739
+ if (!existsSync4(p)) return;
1740
+ const s = read(p);
1741
+ if (!s.includes("__PATCHSTACK_SITE_UUID__")) return log("guard.ts site UUID already baked");
1742
+ writeFileSync2(p, s.replace("__PATCHSTACK_SITE_UUID__", uuid));
1743
+ log("baked site UUID into guard.ts \u2014 live rules from the Patchstack API");
1744
+ }
1724
1745
  function patchClient(cwd) {
1725
1746
  const p = join(cwd, "src/integrations/supabase/client.ts");
1726
1747
  let s = read(p);
@@ -1775,6 +1796,7 @@ function runProtect(cwd) {
1775
1796
  return;
1776
1797
  }
1777
1798
  scaffold(cwd);
1799
+ bakeSiteUuid(cwd);
1778
1800
  patchClient(cwd);
1779
1801
  patchStart(cwd);
1780
1802
  log("done \u2014 guard wired and always-on (blocks by default). Set PATCHSTACK_MODE=dry-run for log-only.");