@patchstack/connect 0.5.21 → 0.5.22
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 +41 -9
- package/package.json +1 -1
package/AGENT-INSTALL.md
CHANGED
|
@@ -16,11 +16,11 @@ For a standalone site made of HTML, CSS, and browser JavaScript, with no package
|
|
|
16
16
|
- **Create a Node project in the folder and let Connect set it up.** No trip to the dashboard first: `setup` creates the site and prints the link that connects it to their account. It adds `package.json`, a lockfile and `node_modules` to their folder. Packages they add later are checked for known security problems. A page with no packages of its own has little to check at first, and there is still no runtime protection without a server. Follow "Creating a Node project for a plain HTML site" below.
|
|
17
17
|
- **Stop here.** Nothing is changed.
|
|
18
18
|
|
|
19
|
-
Do not pick for them, and do not create the Node project unless they choose it.
|
|
20
|
-
2. Add one widget tag before `</body>` in the page or shared layout. Preserve an existing correct tag.
|
|
19
|
+
Do not pick for them, and do not create the Node project unless they choose it. **A request to install or set up `@patchstack/connect` is that choice**: follow "Creating a Node project for a plain HTML site" without asking.
|
|
20
|
+
2. Add one widget tag before `</body>` in the page or shared layout. Preserve an existing correct tag. Do not add `data-build-mode`: setting it to `"false"` hides the owner's connect and log-in panels everywhere, including on the person's own machine.
|
|
21
21
|
|
|
22
22
|
```html
|
|
23
|
-
<script src="https://cdn.patchstack.com/patchstack-widget.js" data-site-uuid="YOUR_SITE_UUID"
|
|
23
|
+
<script src="https://cdn.patchstack.com/patchstack-widget.js" data-site-uuid="YOUR_SITE_UUID" defer></script>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
Replace `YOUR_SITE_UUID` with the real public site UUID before saving. Keep credentials out of the page. The [public widget reference](https://cdn.patchstack.com/llm.html) documents this embed and its options.
|
|
@@ -32,20 +32,25 @@ Report this as **Patchstack Connector installed**, with any remaining preview or
|
|
|
32
32
|
|
|
33
33
|
Only when the person chose this option in step 1 above. Work in the folder that holds the site's pages.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
The pages get a build step, even though nothing is compiled. The build is what runs `scan` before and `mark-build` after, and `mark-build` is what tells a visitor's browser that a page is the live site. Without it the live site is never recognised as deployed. The build copies the pages to `dist/` and the stamp goes on the copy, so the pages the person edits stay as they are and their own machine keeps showing the owner panels.
|
|
36
|
+
|
|
37
|
+
1. Move the pages (every `.html` file, plus the CSS, scripts and images they use) into `public/` if they are not there already. Then create the project with its build script **before** running `setup`, so `setup` wires the hooks around it:
|
|
36
38
|
|
|
37
39
|
```
|
|
38
40
|
npm init -y
|
|
41
|
+
npm pkg set scripts.build="node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});fs.cpSync('public','dist',{recursive:true})\""
|
|
39
42
|
npm install --save @patchstack/connect
|
|
40
43
|
npx @patchstack/connect setup
|
|
41
44
|
```
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
2.
|
|
45
|
-
3.
|
|
46
|
+
`setup` creates the site, writes its `siteUuid` to `.patchstackrc.json`, adds the Patchstack widget to `public/index.html`, adds `"postinstall": "patchstack-connect scan"`, and wires `"prebuild": "patchstack-connect scan"` and `"postbuild": "patchstack-connect mark-build"` around the build. In a hosted builder, scope `PATCHSTACK_ENVIRONMENT=sandbox` to the `setup` command, as in "Automated setup".
|
|
47
|
+
2. Add `dist` to `.gitignore` next to the entries `setup` wrote.
|
|
48
|
+
3. Put the widget on the other pages. `setup` adds the tag only to `index.html`, `public/index.html` or `src/app.html`. For any other page it lists the widget under `Missing` and prints the tag to add. Add one tag before `</body>` on each page, or in the shared layout, exactly as printed — no `data-build-mode`.
|
|
49
|
+
4. When the person names where the site is published, add that host's build settings so it publishes `dist/` and runs the build. See "Deploying" below; for Netlify that is a `netlify.toml` with `command = "npm run build"` and `publish = "dist"`.
|
|
50
|
+
5. Two `✘` lines are expected and need no fix:
|
|
46
51
|
- `Runtime protection: no server file found`. A plain HTML site has no server to guard. Do not add one. `setup` leaves a generic guard in `patchstack/`, which nothing loads until a server does.
|
|
47
52
|
- `Deploy project to protect live app`. Publishing the pages is the person's step.
|
|
48
|
-
|
|
53
|
+
6. End as in "The message you end on", with the dashboard link from the `Next:` line. Say that the widget, and a check of the packages the site installs, are active, and that runtime protection is not. To preview it on their own machine, serve `public/` (for example `python3 -m http.server -d public`). Do not publish anything yourself.
|
|
49
54
|
|
|
50
55
|
### JS/Node applications — the usual path
|
|
51
56
|
|
|
@@ -129,10 +134,37 @@ When setup is finished, the person reads one short message, not a transcript of
|
|
|
129
134
|
1. **One sentence on the result.** "Patchstack is now watching your site." If something did not finish, say what, in one line.
|
|
130
135
|
2. **The four steps**, copied from the end of the `setup` output with their `✔` and `✘`.
|
|
131
136
|
3. **The next step**, from the `Next:` line, in plain words, with its link or command.
|
|
132
|
-
4. **Refresh and deploy.** Refresh the preview to see the Patchstack Connector, and deploy when ready.
|
|
137
|
+
4. **Refresh and deploy.** Refresh the preview to see the Patchstack Connector, and deploy when ready. Say how, in one line: "When you want it live, ask me to deploy it — I'll run the build so Patchstack can recognise the live site."
|
|
138
|
+
|
|
139
|
+
**When the person later asks you to deploy, re-read "Deploying" below before running anything.** A deploy that skips the build, or uploads the project folder, publishes the API key and leaves the live site unrecognised.
|
|
133
140
|
|
|
134
141
|
Leave out the files you changed, the commands you ran, settings, and anything that worked as expected. If the person asks for the detail, give it then. `--verbose` prints it.
|
|
135
142
|
|
|
143
|
+
## Deploying
|
|
144
|
+
|
|
145
|
+
Only when the person asks you to publish the site. Two things decide whether Patchstack recognises the deploy: the build has to run, and it has to know it is the production build.
|
|
146
|
+
|
|
147
|
+
- **Deploy through the build, and publish only its output.** Never pass `--no-build`, and never upload the project folder itself: it holds `node_modules` and `.patchstackrc.local.json`, which contains the site's API key. Publish `dist/` for a plain HTML site, or whatever the framework builds.
|
|
148
|
+
- **A deploy that builds on this machine** (`netlify deploy --prod --build`, a static folder uploaded by hand) has nothing that says "production" to Patchstack. Prefix that command, and only the production one, with `PATCHSTACK_ENVIRONMENT=production`:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
PATCHSTACK_ENVIRONMENT=production npx netlify deploy --prod --build
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The key is in `.patchstackrc.local.json` on this machine, so nothing else is needed. A preview deploy runs without the prefix.
|
|
155
|
+
- **A deploy that builds on the host** (`vercel --prod`, or any git-connected Netlify or Vercel site) labels production by itself, but the host never receives `.patchstackrc.local.json`. Before the first production deploy, put the key in the host's production settings, read straight from the file so it is never printed:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
node -p "require('./.patchstackrc.local.json').apiKey" | npx vercel env add PATCHSTACK_API_KEY production --sensitive
|
|
159
|
+
npx netlify env:set PATCHSTACK_API_KEY "$(node -p "require('./.patchstackrc.local.json').apiKey")" --context production --secret
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
An app with a server needs this for runtime protection: the guard fetches its rules with the key. Without it the deploy is still recognised as long as the packages have not changed since the last scan, but nothing is protected. Never put the key in a committed file, in a public variable (`NEXT_PUBLIC_*`, `VITE_*`), or in your reply.
|
|
163
|
+
- **Check the live site after deploying**, and tell the person what you found:
|
|
164
|
+
- `curl -s <live url> | grep -ac __PATCHSTACK_PROD__` prints `1` or more. `0` means the build did not know it was production, and the widget will treat the live site as a preview.
|
|
165
|
+
- `curl -s -o /dev/null -w "%{http_code}" <live url>/.patchstackrc.local.json` is not `200`. A `200` means the API key was published: delete the deploy and tell the person.
|
|
166
|
+
- The owner reaches their dashboard on the live site by adding `#patchstack` to the address, for example `https://example.com/#patchstack`. Visitors never see the owner panels there.
|
|
167
|
+
|
|
136
168
|
## Automated setup
|
|
137
169
|
|
|
138
170
|
1. **Install** (skip if already present), matching the project's package manager:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patchstack/connect",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.22",
|
|
4
4
|
"description": "Runtime application security for JavaScript and Node.js: dependency inventory, attack-surface mapping, and an in-process guard that virtually patches known vulnerabilities and hardens responses.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"patchstack",
|