@patchstack/connect 0.5.11 → 0.5.12
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/AGENT-INSTALL.md +31 -4
- package/README.md +2 -2
- package/dist/cli.js +136 -173
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/protect.cjs +3 -2
- package/dist/protect.cjs.map +1 -1
- package/dist/protect.js +1 -1
- package/dist/{refresh-manifest-PPV22Q2E.js → refresh-manifest-47HJRCDX.js} +3 -2
- package/dist/refresh-manifest-47HJRCDX.js.map +1 -0
- package/package.json +1 -1
- package/dist/refresh-manifest-PPV22Q2E.js.map +0 -1
package/AGENT-INSTALL.md
CHANGED
|
@@ -22,6 +22,16 @@ For a standalone site made of HTML, CSS, and browser JavaScript, with no package
|
|
|
22
22
|
|
|
23
23
|
Report this as **disclosure widget installed**, with any remaining preview or publishing step. This path does not inventory local JavaScript files or scripts loaded from a CDN, scan npm dependencies, or install runtime exploit protection. External APIs used by the page require their own server-side integration.
|
|
24
24
|
|
|
25
|
+
### JS/Node applications — the usual path
|
|
26
|
+
|
|
27
|
+
1. Check what is already done with `npx @patchstack/connect guide` (read-only). If the project is already provisioned, reuse it — see "Before you start — never install twice".
|
|
28
|
+
2. Install `@patchstack/connect` as a runtime dependency with the project's package manager.
|
|
29
|
+
3. Run `npx @patchstack/connect setup`. In a hosted builder, scope `PATCHSTACK_ENVIRONMENT=sandbox` to that command — see "Automated setup".
|
|
30
|
+
4. Finish any step the checklist at the end of `setup` still lists. "Automated setup" names each one.
|
|
31
|
+
5. Tell the person the dashboard link, which parts are active and which are not, to refresh their preview, and to deploy when they are ready.
|
|
32
|
+
|
|
33
|
+
If your tool will not run the command, see "When your tool will not run this CLI". The sections below describe what each command reads, writes, and sends.
|
|
34
|
+
|
|
25
35
|
## Command reference
|
|
26
36
|
|
|
27
37
|
Every command at a glance — what it does, whether it reads your source, what it writes, and what leaves your machine. Full behavior, flags, and edge cases follow in the sections below.
|
|
@@ -108,9 +118,26 @@ This is a request, not a mechanism: nothing in the install depends on it. Do it
|
|
|
108
118
|
|
|
109
119
|
**If the request you were given includes a claim token**, pass it exactly as given: `npx @patchstack/connect setup --claim-token <token>`. The site is then created in the person's own Patchstack account and `setup` prints their dashboard link for it — there is no sign-in step to relay. The token comes only from the person's Patchstack dashboard; never invent one, never write it to a file, never print it back. If `setup` reports that the token had expired or was not recognised, the site is not connected: hand over the dashboard link it prints instead, and tell the person they can copy a fresh prompt from the dashboard.
|
|
110
120
|
|
|
111
|
-
In a hosted builder
|
|
121
|
+
**In a hosted builder:**
|
|
122
|
+
|
|
123
|
+
- Run setup with `PATCHSTACK_ENVIRONMENT=sandbox` scoped to the workspace process/command.
|
|
124
|
+
- Ensure the CLI's on-disk edits are adopted into the platform's persisted project state.
|
|
125
|
+
- Restart any already-running preview/server process so it loads the guard.
|
|
126
|
+
- Do not persist `"environment": "sandbox"` in `.patchstackrc.json`: deployed builds use the same committed files and report `production` only when the build platform's own variables say so.
|
|
127
|
+
|
|
128
|
+
**How each environment is labelled:**
|
|
129
|
+
|
|
130
|
+
- A build platform's tier (Vercel, Netlify, Render, Railway, GitLab CI) or a branch named `main`, `master`, `production`, `prod`, `release` or `live` (Cloudflare Pages and Workers Builds, AWS Amplify, GitHub Actions, GitLab CI without a tier) reports `production`; a preview, pull request or other branch there reports `sandbox`, as does the Replit workspace, while a Replit Deployment reports `production`.
|
|
131
|
+
- A build in a project the builder generated and builds for itself (Lovable, Replit) reports `production` without an override, because the edit preview is a dev server and a build is the publish step — which is exactly why the sandbox label belongs in the workspace process and not in a file.
|
|
132
|
+
- A scan on a developer's machine, in a CI runner this does not know (`CI=true` alone), or on a platform with no such signal reports `local` on its own, and the dashboard shows that app as configured, not deployed.
|
|
133
|
+
|
|
134
|
+
**What runtime protection can report:** a positively identified static build reports runtime protection as not applicable. A bundler-only project, including plain Vite, can remain runtime unknown and receive a generic scaffold with incomplete wiring. Report that limitation; do not add an artificial server merely to make the check pass, and never describe a widget or an unwired scaffold as runtime protection.
|
|
135
|
+
|
|
136
|
+
**A step the checklist still lists is yours to finish, not a result to report.** `setup` applies what it can apply safely and prints the exact edit for anything it would have had to overwrite user code to do. They are: moving `@patchstack/connect` out of `devDependencies`, the widget tag in a root layout `setup` could not edit, the production marker on a server-rendered root, and wiring a generic guard into the server entry. The last three are steps 3 and 4 of "Manual setup" below; after the guard one, `npx @patchstack/connect protect --check` must exit 0.
|
|
137
|
+
|
|
138
|
+
**A tick is "nothing owed here", not "this part is on".** The checklist marks steps this project still owes, so a part it cannot carry — or one that is switched off — is green with nothing outstanding. `No build script to integrate`, `Disclosure widget disabled by config` and `Runtime protection: not applicable` all read that way. So report what the project ended up with by name — dependency scans, the disclosure widget, the build hooks, runtime protection — and say which of them are not active and why, rather than reporting an empty checklist as a finished install. Of those, the widget is the one that can be off by setting rather than by the shape of the project: if `.patchstackrc.json` carries `"widget": false` and the person did not ask for that, tell them it is off and ask whether they want it on.
|
|
112
139
|
|
|
113
|
-
**Finish by telling the user to refresh their preview.** The widget
|
|
140
|
+
**Finish by telling the user to refresh their preview.** The widget loads with the page, so a preview that was already open still shows the HTML from before setup — the widget is missing there until it reloads. Tell them what to expect after the refresh: a site that is not yet connected to an account shows the "Connect this website" panel, and the "Report a vulnerability" button takes its place once the site is claimed. A freshly set up site is unclaimed unless setup ran with a claim token. Nothing in the CLI can reach the user's browser, so relaying this is your job. Phrase it as a check rather than a required step: a builder that hot reloads, or a preview server you restarted, may have refreshed it already.
|
|
114
141
|
|
|
115
142
|
**Then tell them to deploy.** Setup changes source files, and the deployed site keeps serving its previous build until the next deploy — so visitors get no widget, and on a server-rendered root no production marker, until the user deploys (or hits Publish) again. Say it as a reminder; do not deploy anything yourself.
|
|
116
143
|
|
|
@@ -182,7 +209,7 @@ Handle it in this order:
|
|
|
182
209
|
npx @patchstack/connect scan
|
|
183
210
|
```
|
|
184
211
|
|
|
185
|
-
It prints a dashboard link but never opens it. Open that link in a browser to view reports. It also prints what it did about the widget — if it added the tag, reload the preview and confirm the "Report a vulnerability" button
|
|
212
|
+
It prints a dashboard link but never opens it. Open that link in a browser to view reports. It also prints what it did about the widget — if it added the tag, reload the preview and confirm the widget appears: the "Connect this website" panel while the site is unclaimed, the "Report a vulnerability" button once it is claimed.
|
|
186
213
|
|
|
187
214
|
2. **Wire builds** in `package.json`:
|
|
188
215
|
|
|
@@ -564,7 +591,7 @@ Two more endpoints the package can call, for completeness:
|
|
|
564
591
|
- `npx @patchstack/connect status` re-prints the site UUID and dashboard URL, and checks whether the site still exists on Patchstack (`Site status: active / removed / could not be verified`).
|
|
565
592
|
- `npx @patchstack/connect protect --check` verifies from the source that the runtime guard is connected to the request path. It does not run the app.
|
|
566
593
|
- `npx @patchstack/connect protect --check --runtime` additionally **starts the app** on a loopback port and sends it one request, to establish that a request reaches the guard seam. Opt-in, and the only command that runs the application; exit `0`/`1`/`2` as described in step 4.
|
|
567
|
-
- Load the site in a browser — the "Report a vulnerability" button
|
|
594
|
+
- Load the site in a browser — the widget should appear: the "Connect this website" panel while the site is unclaimed, the "Report a vulnerability" button once it is claimed. Refresh a page that was already open before the tag was added: the widget only loads with the page.
|
|
568
595
|
- On the deployed site, the button appears only after a deploy that includes these source changes.
|
|
569
596
|
|
|
570
597
|
## Answering "is Patchstack installed?" / "is Patchstack removed?"
|
package/README.md
CHANGED
|
@@ -95,13 +95,13 @@ That's it. `setup`:
|
|
|
95
95
|
2. POSTs the package list to Patchstack with **no** UUID.
|
|
96
96
|
3. Patchstack provisions a fresh site and returns its UUID.
|
|
97
97
|
4. The connector writes the UUID to `.patchstackrc.json` so the next `scan` targets the same site.
|
|
98
|
-
5. The connector installs the disclosure widget's `<script>` tag into your root HTML shell (see *The disclosure widget* below) so the
|
|
98
|
+
5. The connector installs the disclosure widget's `<script>` tag into your root HTML shell (see *The disclosure widget* below) so the widget shows up on the next preview reload — as the "Connect this website" panel until the site is claimed, then as the "Report a vulnerability" button. On a server-rendered root it also adds the production marker, which is what tells the widget to switch from build mode to visitor report intake on the published site.
|
|
99
99
|
6. Installs the runtime guard after provisioning, bakes the site UUID into it, and verifies the framework seam. Known server stacks are auto-wired; unmatched or conflicting layouts get a generic scaffold and exact manual checks.
|
|
100
100
|
7. Adds `postinstall: patchstack-connect scan`, preserving any existing command, so dependencies added during a sandbox session and build-less production installs are reported immediately.
|
|
101
101
|
8. Wires `scan` before builds and `mark-build` after builds, preserving existing commands and using direct build chaining for Bun.
|
|
102
102
|
9. Prints a dashboard link — open it in a browser to attach the new site to your Patchstack account. You can re-display it any time with `npx @patchstack/connect status`.
|
|
103
103
|
|
|
104
|
-
Then **refresh your preview**. The widget
|
|
104
|
+
Then **refresh your preview**. The widget loads with the page, so a preview that was already open still shows the HTML from before setup. Builders that hot reload will have refreshed it for you; if the widget is missing, refresh it once. Until the site is claimed it shows the "Connect this website" panel; the "Report a vulnerability" button takes its place once it is. `setup` prints the same reminder, and the CLI has no way to reload a browser itself.
|
|
105
105
|
|
|
106
106
|
Then **deploy**. These are source changes, so your live site keeps serving its previous build — visitors get the widget, and a server-rendered root gets the production marker, only after the next deploy.
|
|
107
107
|
|