@commentkit/comment-kit 2.0.0 → 2.0.1
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/CHANGELOG.md +24 -0
- package/README.md +109 -13
- package/SECURITY.md +2 -2
- package/dist/node/cli/doctor.js +84 -20
- package/dist/node/cli/init.js +349 -35
- package/dist/node/cli/main.js +35 -17
- package/dist/node/cli/mcp.js +187 -6
- package/dist/node/shared/dashboard-places.js +33 -0
- package/dist/npm/chunks/{AgentSend-DxRJIYiz.js → AgentSend-DOy3jhyF.js} +16 -16
- package/dist/npm/chunks/{Checklist-CnlfeSbc.js → Checklist-CW_SwMpS.js} +70 -70
- package/dist/npm/chunks/{Composer-B1bBVszY.js → Composer-Bveq5QrK.js} +276 -274
- package/dist/npm/chunks/{Guest-vvNPz8h-.js → Guest-7hcN765o.js} +58 -55
- package/dist/npm/chunks/{MarkupEditor-VCOXh9d2.js → MarkupEditor-6bJGpWGO.js} +46 -39
- package/dist/npm/chunks/Panel-ChPUB68C.js +1211 -0
- package/dist/npm/chunks/{Settings-BGoZS2iV.js → Settings-CB5eEKnf.js} +77 -77
- package/dist/npm/chunks/{Shortcuts-B2OMvczr.js → Shortcuts-eAyjJ89P.js} +4 -4
- package/dist/npm/chunks/{StyleEditor-CJ_d8Huf.js → StyleEditor-CZTdAA5c.js} +10 -10
- package/dist/npm/chunks/{StylePanel-yQzHHlY7.js → StylePanel-B4pHQUL9.js} +61 -61
- package/dist/npm/chunks/{TaskFields-fmy6_HtK.js → TaskFields-C8BX0Sgg.js} +55 -55
- package/dist/npm/chunks/ThreadCard-B1EsX3PR.js +1160 -0
- package/dist/npm/chunks/Viewer-DY6zb90M.js +114 -0
- package/dist/npm/chunks/{agent-C1OQzBAm.js → agent-MTQHr9ei.js} +1 -1
- package/dist/npm/chunks/{ar-CAJ3XT8e.js → ar-L5cQ-NPe.js} +2 -0
- package/dist/npm/chunks/{card-bits-CAnzrqx3.js → card-bits-CTdrkYn8.js} +16 -16
- package/dist/npm/chunks/{client-kNAo2TTG.js → client-7eVxvg5j.js} +7 -7
- package/dist/npm/chunks/{confetti-CkBdSu19.js → confetti-BIs5s14P.js} +1 -1
- package/dist/npm/chunks/{context-B8UAzve0.js → context-Cf6khm7A.js} +1 -1
- package/dist/npm/chunks/{de-Dl18G48t.js → de-D0C-v6tP.js} +2 -0
- package/dist/npm/chunks/{dialog-GO04oC3D.js → dialog-DvdIkCW0.js} +1 -1
- package/dist/npm/chunks/{dpop-U48QIQd7.js → dpop-0A76OPa9.js} +1 -1
- package/dist/npm/chunks/{es-Dxk79lS9.js → es-Bw4Dj9tN.js} +2 -0
- package/dist/npm/chunks/{extension-CKFpPWmi.js → extension-DFVOvciD.js} +1 -1
- package/dist/npm/chunks/{extension-E81hWyiT.js → extension-SmoH5AA4.js} +2 -2
- package/dist/npm/chunks/{files-DyD5BZgp.js → files-4lV9YQIX.js} +2 -2
- package/dist/npm/chunks/{fr-8BebGKYD.js → fr-TkuQaIAa.js} +2 -0
- package/dist/npm/chunks/{hi-BIN6Yy_p.js → hi-DXSH2U8d.js} +2 -0
- package/dist/npm/chunks/{i18n-DOBt8e9U.js → i18n-aVSu9TcJ.js} +56 -47
- package/dist/npm/chunks/{identify-CN-3xzqL.js → identify-BGYh2dVo.js} +4 -4
- package/dist/npm/chunks/{it-Cr6EwpPQ.js → it-CiWA_bch.js} +2 -0
- package/dist/npm/chunks/{ja-Iy3s5aur.js → ja-C-QmR3yz.js} +2 -0
- package/dist/npm/chunks/{late-words-B2bmZceJ.js → late-words-80_VWt8S.js} +3 -1
- package/dist/npm/chunks/{live-CelVeZfP.js → live-BExWHzQ7.js} +1 -1
- package/dist/npm/chunks/{nl-B84WHqqe.js → nl-CEmZRqjX.js} +2 -0
- package/dist/npm/chunks/{page-key-DepmJzC1.js → page-key-HSY3Lze5.js} +1 -1
- package/dist/npm/chunks/{pick-yTyqtxN0.js → pick-B3sR7jtS.js} +1 -1
- package/dist/npm/chunks/{pkce-ChKGSW_4.js → pkce-CfZhiNBi.js} +1 -1
- package/dist/npm/chunks/{pt-BR-DOkdlfoe.js → pt-BR-b-a8sxO8.js} +2 -0
- package/dist/npm/chunks/{report-CrIqQZDI.js → report-DaVuoRYS.js} +1 -1
- package/dist/npm/chunks/show-BoN8AC-F.js +97 -0
- package/dist/npm/chunks/{signin-Dd1rb2BP.js → signin-BOWr_WCo.js} +3 -3
- package/dist/npm/chunks/{source-pXVve2Cx.js → source-mk3rGBBQ.js} +1 -1
- package/dist/npm/chunks/{src-BTMy4Gyc.js → src-C8rZFyL_.js} +77 -70
- package/dist/npm/chunks/start-CV4j78_q.js +1894 -0
- package/dist/npm/chunks/{states-sfTbjZz8.js → states-b9Bv3Ci7.js} +1 -1
- package/dist/npm/chunks/{upload-MgPYqPyE.js → upload-B2mkgMeJ.js} +1 -1
- package/dist/npm/chunks/uploads-8AxyRq7g.js +1147 -0
- package/dist/npm/chunks/{wrap-Bl0gbnFa.js → wrap-DW6EFbVQ.js} +1 -1
- package/dist/npm/chunks/{zh-CN-Z5fQCb7G.js → zh-CN-JTscW8u8.js} +2 -0
- package/dist/npm/element.js +1 -1
- package/dist/npm/headless.js +2 -2
- package/dist/npm/index.js +2 -2
- package/dist/npm/react.js +1 -1
- package/dist/npm/svelte.js +1 -1
- package/dist/npm/types/core/types.d.ts +2 -2
- package/dist/npm/vue.js +1 -1
- package/package.json +3 -1
- package/dist/npm/chunks/Panel-F37vIL1K.js +0 -1206
- package/dist/npm/chunks/ThreadCard-D51slKST.js +0 -1113
- package/dist/npm/chunks/Viewer-BOBadqmC.js +0 -111
- package/dist/npm/chunks/show-BgVC8gWY.js +0 -97
- package/dist/npm/chunks/start-DtVlpt7p.js +0 -1878
- package/dist/npm/chunks/uploads-D49mywwz.js +0 -1146
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @commentkit/comment-kit
|
|
2
2
|
|
|
3
|
+
## [2.0.1] - 2026-11-20
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- The `commentkit` command works on Laravel apps. `init` sets up Laravel with Inertia (React, Vue or Svelte), Blade or Livewire: it adds `init()` to `resources/js/app.*` (or the entry `vite.config` lists), with the key written in as the default so the server needs no new environment variable. It names layouts whose `@vite` loads only stylesheets, and for plain Blade pages it prints the script tag and the layouts it belongs in instead of editing them. The README has a Laravel section.
|
|
8
|
+
- `init` prints the exact lines to add the build plugin to vite-plus configs that use `lazyPlugins`, with the Node version the plugin needs.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- The widget now looks like the CommentKit dashboard. Cards, menus and the inbox have slightly smaller corners and softer shadows, and the colours are a little cooler. Fields, the comment box, chips and reactions have a clearer edge, so you can see where to type or press. Focus shows as one grey ring on every control, fields included, instead of the accent colour. The default accent is Ember red with white text on buttons; pins keep the orange. Statuses match the dashboard: open is stone grey and "In review" is violet, and delete actions use their own red. If your site sets its own accent colour, it is kept on buttons and pins (a few mid-tone colours are darkened just enough for white text on them to stay readable). Nothing to change to upgrade.
|
|
13
|
+
- A single click on the page beside an open comment no longer looks like nothing happened: the card gives a small shake (none if you prefer reduced motion) and says how to close it. A double-click or double-tap outside closes it, like ×. The page still receives every click as before, and an unsent reply stays saved as a draft.
|
|
14
|
+
- `doctor` says in one neutral line when the terminal is signed in to a different website than the folder's key, with how to switch, instead of warning. Without an address, it suggests running it with the site's address.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- The ⋯ menu on an open comment shows that it is open, and closes when you click or tap beside it, press Esc (focus goes back to ⋯) or choose an item.
|
|
19
|
+
- Esc in any of the widget's menus and drop-downs (the ⋯ menus, priority, assignee, labels, reactions, the inbox filters) closes only that menu, not the comment card or the inbox around it.
|
|
20
|
+
- If one of the parts the widget loads on demand fails to download (a deploy in progress, a network blip), it is tried again a moment later instead of leaving the widget missing until the page is reloaded. A later Cmd/Ctrl+Shift+K or opening another comment tries again too.
|
|
21
|
+
- `doctor` finds the widget in Laravel entries, in the entries `vite.config` lists under `input`, in a file an entry imports, and as the script tag in a Blade layout, and reads the key written there.
|
|
22
|
+
- The package manager is chosen by lockfile first: a `package-lock.json` next to a stray `pnpm-workspace.yaml` now means npm.
|
|
23
|
+
- `mcp install` changes only the entry it adds: the file keeps its indentation, line endings and trailing newline. Backups no longer land in a git repository where git would pick them up, and a git-ignored `.mcp.json` is reported as such.
|
|
24
|
+
- Messages from `doctor`, the CLI and the SDK's console warnings point to the dashboard pages that exist (for example the website's Settings → Install, under Addresses) instead of the retired Setup and Connect pages.
|
|
25
|
+
- The README's Vue, Nuxt and build plugin examples work as pasted.
|
|
26
|
+
|
|
3
27
|
## [2.0.0] - 2026-11-17
|
|
4
28
|
|
|
5
29
|
### Added
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package, `@commentkit/comment-kit`, holds the browser SDK, the build plugin
|
|
|
8
8
|
|
|
9
9
|
## Install in 60 seconds
|
|
10
10
|
|
|
11
|
-
Find your project key in CommentKit
|
|
11
|
+
Find your project key (the website key, `pk_live_…`) in CommentKit in the website's **Settings → Install**, and add every address the site runs on there, under **Addresses** (live, staging, previews). A wildcard such as `https://*.preview.example.com` covers one level of subdomains (`pr-1.preview.example.com`, not `a.b.preview.example.com`); shared hosts such as `vercel.app` take the exact address instead (or `https://*--yoursite.netlify.app` for one Netlify site's previews). `localhost` always works for your team.
|
|
12
12
|
|
|
13
13
|
### Any website: the script tag
|
|
14
14
|
|
|
@@ -27,7 +27,7 @@ npm install @commentkit/comment-kit
|
|
|
27
27
|
npx @commentkit/comment-kit init
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
`init` finds your framework (Next.js, Vite, SvelteKit, React Router, Remix, Astro, Nuxt or a plain website) and shows each change before it makes it: the key in your env file, the build plugin in your config, `.commentkit/` in `.gitignore` and the widget in your layout or entry file. Without signing in, pass the key: `npx @commentkit/comment-kit init --key pk_live_your_key`. The full package name works before and after the package is installed.
|
|
30
|
+
`init` finds your framework (Next.js, Vite, SvelteKit, React Router, Remix, Astro, Nuxt, Laravel or a plain website) and shows each change before it makes it: the key in your env file, the build plugin in your config, `.commentkit/` in `.gitignore` and the widget in your layout or entry file. Without signing in, pass the key: `npx @commentkit/comment-kit init --key pk_live_your_key`. The full package name works before and after the package is installed.
|
|
31
31
|
|
|
32
32
|
Or call `init()` yourself, once, in browser code:
|
|
33
33
|
|
|
@@ -56,15 +56,22 @@ Options are read when it mounts. A change to `project`, `branch`, `commit`, `end
|
|
|
56
56
|
|
|
57
57
|
### Vue and Nuxt
|
|
58
58
|
|
|
59
|
+
Vue: install the plugin where your app is created, before `mount()`. Keep your other imports, such as your CSS:
|
|
60
|
+
|
|
59
61
|
```ts
|
|
62
|
+
// src/main.ts
|
|
63
|
+
import { createApp } from "vue";
|
|
60
64
|
import { CommentKitPlugin } from "@commentkit/comment-kit/vue";
|
|
65
|
+
import App from "./App.vue";
|
|
61
66
|
|
|
67
|
+
const app = createApp(App);
|
|
62
68
|
app.use(CommentKitPlugin, { project: "pk_live_your_key" });
|
|
69
|
+
app.mount("#app");
|
|
63
70
|
```
|
|
64
71
|
|
|
65
72
|
Or place `<CommentKit project="pk_live_your_key" />` from `@commentkit/comment-kit/vue` once in your root component. Its props are the options. A change to `project`, `branch`, `commit`, `endpoint`, `privacy` or `toggleShortcut` restarts the widget; a new `identity` token signs that person in without a restart.
|
|
66
73
|
|
|
67
|
-
Nuxt: create `plugins/commentkit.client.ts
|
|
74
|
+
Nuxt: create `app/plugins/commentkit.client.ts` (on Nuxt 3, `plugins/commentkit.client.ts`):
|
|
68
75
|
|
|
69
76
|
```ts
|
|
70
77
|
import { init } from "@commentkit/comment-kit";
|
|
@@ -91,6 +98,81 @@ and add `runtimeConfig: { public: { commentkitKey: "" } }` to `nuxt.config.ts` (
|
|
|
91
98
|
|
|
92
99
|
A change to `project`, `branch`, `commit`, `endpoint`, `privacy` or `toggleShortcut` restarts the widget.
|
|
93
100
|
|
|
101
|
+
### Laravel
|
|
102
|
+
|
|
103
|
+
`npx @commentkit/comment-kit init` sets up a Laravel app (one with `artisan` and `laravel/framework` in `composer.json`) and shows each change first. By hand:
|
|
104
|
+
|
|
105
|
+
**Inertia (React, Vue or Svelte), and Blade or Livewire pages that load a Vite entry.** Call `init()` once in the JavaScript entry your pages load, usually `resources/js/app.js` (or `app.ts`, `app.jsx`, `app.tsx`; the entries are listed under `input` in `vite.config.js`). Keep what the file has, such as `createInertiaApp(…)`: put the import with your other imports and the call at the end.
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
// resources/js/app.js
|
|
109
|
+
import { init } from '@commentkit/comment-kit';
|
|
110
|
+
|
|
111
|
+
init({ project: import.meta.env.VITE_COMMENTKIT_KEY || 'pk_live_your_key' });
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
That one call covers every page that loads the entry, whichever Inertia flavour you use; the React, Vue and Svelte helpers are not needed. It does nothing during server-side rendering.
|
|
115
|
+
|
|
116
|
+
**Where the key goes.** In the entry, as the default value, as above. Publishable keys are public by design, so it is safe to commit, and a server that builds on deploy needs no new environment variable. `VITE_COMMENTKIT_KEY` in `.env` overrides it when you build (for example `pk_test_…` on staging). A key only in `.env.local` would not reach a server: that file is git-ignored and Laravel itself never reads it.
|
|
117
|
+
|
|
118
|
+
**Layouts.** A page shows the widget only when its layout loads the entry. A layout whose `@vite` lists only stylesheets needs the entry added:
|
|
119
|
+
|
|
120
|
+
```blade
|
|
121
|
+
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Pages with no JavaScript entry.** Paste the script tag before `</body>` in the layout; there is nothing to install or build:
|
|
125
|
+
|
|
126
|
+
```html
|
|
127
|
+
<script src="https://commentkit.dev/cdn/v1/loader.js" data-project="pk_live_your_key" defer></script>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`init` prints this line and the layouts that look like the place for it. It does not edit Blade files.
|
|
131
|
+
|
|
132
|
+
**Filament.** Filament admin panels do not load your app's entry, so the widget does not show in them. To add it there, render the script tag through Filament's `PanelsRenderHook::BODY_END` render hook.
|
|
133
|
+
|
|
134
|
+
**Content Security Policy.** If the app sends a policy (often from a middleware), allow CommentKit's hosts as described in [What CommentKit does to your page](#what-commentkit-does-to-your-page), then run `npx @commentkit/comment-kit doctor https://your-site.com` to check it.
|
|
135
|
+
|
|
136
|
+
**Build plugin (optional).** Put `commentkit()` first in `plugins`, before `laravel(…)`:
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
// vite.config.js
|
|
140
|
+
import { defineConfig } from 'vite';
|
|
141
|
+
import laravel from 'laravel-vite-plugin';
|
|
142
|
+
import commentkit from '@commentkit/comment-kit/vite';
|
|
143
|
+
|
|
144
|
+
export default defineConfig({
|
|
145
|
+
plugins: [
|
|
146
|
+
commentkit(),
|
|
147
|
+
laravel({
|
|
148
|
+
input: ['resources/css/app.css', 'resources/js/app.js'],
|
|
149
|
+
refresh: true,
|
|
150
|
+
}),
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
With vite-plus, where the list is built in `lazyPlugins(() => [...])`, it goes first in the list the callback returns (`init` prints these lines rather than editing inside the callback):
|
|
156
|
+
|
|
157
|
+
```js
|
|
158
|
+
// vite.config.js
|
|
159
|
+
import { defineConfig, lazyPlugins } from 'vite-plus';
|
|
160
|
+
import laravel from 'laravel-vite-plugin';
|
|
161
|
+
import commentkit from '@commentkit/comment-kit/vite';
|
|
162
|
+
|
|
163
|
+
export default defineConfig({
|
|
164
|
+
plugins: lazyPlugins(() => [
|
|
165
|
+
commentkit(),
|
|
166
|
+
laravel({
|
|
167
|
+
input: ['resources/css/app.css', 'resources/js/app.js'],
|
|
168
|
+
refresh: true,
|
|
169
|
+
}),
|
|
170
|
+
]),
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The plugin's source locations need Node 22.18+ or 24.11+. A server that builds on deploy with an older Node prints one warning and builds as usual, without them.
|
|
175
|
+
|
|
94
176
|
### Custom element (Angular, Solid, Astro, Qwik, anything else)
|
|
95
177
|
|
|
96
178
|
Import it once in your bundle, then place the tag anywhere:
|
|
@@ -107,7 +189,12 @@ A change to any attribute restarts the widget with the new settings. You can als
|
|
|
107
189
|
|
|
108
190
|
### Headless
|
|
109
191
|
|
|
110
|
-
`@commentkit/comment-kit/headless` exports `CommentKitClient`, `createAnchor`, `resolveAnchor`, `stableSelector`, `pageKey`, `configurePrivacy`, `ApiClient` and `AuthManager` for your own interface. It adds nothing to the page.
|
|
192
|
+
`@commentkit/comment-kit/headless` exports `CommentKitClient`, `createAnchor`, `resolveAnchor`, `stableSelector`, `pageKey`, `configurePrivacy`, `ApiClient` and `AuthManager` for your own interface. It adds nothing to the page. It also exports:
|
|
193
|
+
|
|
194
|
+
- `currentPageUrl()`: this page's address as CommentKit stores it (without CommentKit's own parameters);
|
|
195
|
+
- `SDK_VERSION`: the version string of the SDK you installed;
|
|
196
|
+
- `EDIT_CONFLICT`: the error code (`"edit_conflict"`) a `CommentKitError` carries when someone else changed a message or thread first;
|
|
197
|
+
- `CommentKitError`, and every public type.
|
|
111
198
|
|
|
112
199
|
## Options
|
|
113
200
|
|
|
@@ -139,6 +226,8 @@ Settings that apply without a deploy live in the dashboard: pausing feedback, th
|
|
|
139
226
|
`init()` returns a handle. Every method is safe to call at any time: none throws, and the promises never reject.
|
|
140
227
|
|
|
141
228
|
```ts
|
|
229
|
+
import { init } from "@commentkit/comment-kit";
|
|
230
|
+
|
|
142
231
|
const kit = init({ project: "pk_live_your_key" });
|
|
143
232
|
|
|
144
233
|
kit.show(); // show the widget (same as Cmd/Ctrl+Shift+K)
|
|
@@ -151,6 +240,7 @@ await kit.signOut(); // sign the reviewer out of CommentKit on this brows
|
|
|
151
240
|
kit.session(); // { person, role, project, environment, capabilities } | null
|
|
152
241
|
const off = kit.on("thread:created", ({ thread }) => console.log(thread.reference));
|
|
153
242
|
kit.destroy(); // release this handle; the last one removes the widget
|
|
243
|
+
kit.client; // the CommentKitClient underneath (see Headless), e.g. kit.client.pageKey()
|
|
154
244
|
```
|
|
155
245
|
|
|
156
246
|
`init()` can be called more than once: each call returns its own handle onto the same widget, which stays until the last handle is destroyed. A second copy of the SDK on the same page (npm and the script tag together) stays off and says so in the console.
|
|
@@ -242,10 +332,10 @@ The exact hosts for your project are listed at `https://commentkit.dev/docs/csp`
|
|
|
242
332
|
|
|
243
333
|
**Removing it.** `kit.destroy()` (the last handle), or `window.CommentKit.destroy()` for the script tag, removes the element, the listeners, the wrappers and the global. Signing out, from your code with `signOut()`, from the widget's Settings or in another tab, ends the session and removes that person's drafts on this device.
|
|
244
334
|
|
|
245
|
-
**No automatic updates.** `/cdn/v1/loader.js` always loads the latest
|
|
335
|
+
**No automatic updates.** `/cdn/v1/loader.js` always loads the latest stable release (`v1` names the channel, not the SDK version). To pin one version, use its folder and its Subresource Integrity hash from `https://commentkit.dev/cdn/integrity.json` (keyed by version, then file):
|
|
246
336
|
|
|
247
337
|
```html
|
|
248
|
-
<script src="https://commentkit.dev/cdn/
|
|
338
|
+
<script src="https://commentkit.dev/cdn/2.0.0/loader.js" integrity="sha384-…" crossorigin="anonymous" data-project="pk_live_your_key" defer></script>
|
|
249
339
|
```
|
|
250
340
|
|
|
251
341
|
A pinned loader never switches version and loads the rest of the widget from the same folder, which never changes after it is published. The browser checks the hash of `loader.js` itself; the files the loader then imports (`commentkit.js` and its chunks) are not covered by that hash, because browsers do not apply a preloaded integrity hash to a later dynamic import (see [SECURITY.md](SECURITY.md#trust-model)). If you need every byte checked, install from npm and bundle it. A pinned version gets no fixes: move to a newer one on purpose. With npm, pin an exact version (`npm install --save-exact`) and commit your lockfile.
|
|
@@ -265,7 +355,7 @@ A pinned loader never switches version and loads the rest of the widget from the
|
|
|
265
355
|
|
|
266
356
|
**Masked by default.** Screenshots leave out password, hidden, email and phone inputs; any field whose `autocomplete` says it is a password, one-time code, payment, contact (email, phone, address, postal code) or identity (name, username, birthday, organisation) field; every iframe; the widget itself; and anything matching `data-commentkit-redact`, your `redact` selectors or the dashboard's privacy selectors. The text a comment keeps to find its spot never comes from those elements and never contains what anyone typed into a form field.
|
|
267
357
|
|
|
268
|
-
**`privacy: "strict"`** also leaves every form field's value (`input`, `textarea`, `select`) and every editable region (`contenteditable`) out of screenshots. The website's
|
|
358
|
+
**`privacy: "strict"`** also leaves every form field's value (`input`, `textarea`, `select`) and every editable region (`contenteditable`) out of screenshots. The website's **Settings → Feedback button** in CommentKit can turn this on for everyone ("Hide everything people type in screenshots"): the widget then uses strict mode whatever `init()` says. The stricter of the two always wins; `privacy: "standard"` never turns the dashboard's setting off.
|
|
269
359
|
|
|
270
360
|
**Mark private parts of your page** with the attribute, or list selectors:
|
|
271
361
|
|
|
@@ -274,6 +364,8 @@ A pinned loader never switches version and loads the rest of the widget from the
|
|
|
274
364
|
```
|
|
275
365
|
|
|
276
366
|
```ts
|
|
367
|
+
import { init } from "@commentkit/comment-kit";
|
|
368
|
+
|
|
277
369
|
init({ project: "pk_live_your_key", redact: [".customer-email", "#account-number"] });
|
|
278
370
|
```
|
|
279
371
|
|
|
@@ -291,7 +383,7 @@ See [SECURITY.md](SECURITY.md) for the trust model and how to report a vulnerabi
|
|
|
291
383
|
|
|
292
384
|
If your website has its own login, the people signed in to it can comment without a second sign-in. Your **server** makes a short-lived token for the signed-in user, and the page passes it to the widget.
|
|
293
385
|
|
|
294
|
-
1. In CommentKit open
|
|
386
|
+
1. In CommentKit open the website's **Settings → For developers**, under **Sign in from your website**, and create the identity secret. Keep it on your server only.
|
|
295
387
|
2. On your server, make a token for the signed-in user. It is an HS256 JWT with `sub` (your user id), `email`, optional `name`, `aud` (your project key), `iat` and `exp` (at most 10 minutes after `iat`). An optional `jti` makes it work once.
|
|
296
388
|
|
|
297
389
|
Node (no dependencies):
|
|
@@ -322,6 +414,8 @@ If your website has its own login, the people signed in to it can comment withou
|
|
|
322
414
|
3. Give the token to the widget. A function is best: the widget calls it again whenever the CommentKit session ends.
|
|
323
415
|
|
|
324
416
|
```ts
|
|
417
|
+
import { init } from "@commentkit/comment-kit";
|
|
418
|
+
|
|
325
419
|
init({ project: "pk_live_your_key", identity: () => fetch("/commentkit-token").then((r) => r.text()) });
|
|
326
420
|
```
|
|
327
421
|
|
|
@@ -350,8 +444,10 @@ Reviewers can approve a page when they are happy with it. In the inbox, above "T
|
|
|
350
444
|
|
|
351
445
|
Optional. The plugins tag elements with their source location in development, so a comment says which file and line to open, and they record the branch and commit of each build, so the widget shows this branch's feedback first.
|
|
352
446
|
|
|
447
|
+
Add them to the config you already have: keep your settings and plugins, add the `commentkit` import and put `commentkit()` first in `plugins`. Next.js: wrap your existing config in `withCommentKit()`. SvelteKit and Nuxt are in [plugins/README.md](plugins/README.md#sveltekit).
|
|
448
|
+
|
|
353
449
|
```ts
|
|
354
|
-
// vite.config.ts
|
|
450
|
+
// vite.config.ts
|
|
355
451
|
import { defineConfig } from "vite";
|
|
356
452
|
import react from "@vitejs/plugin-react";
|
|
357
453
|
import commentkit from "@commentkit/comment-kit/vite";
|
|
@@ -397,7 +493,7 @@ Every command takes `--help`. Full reference: [cli/README.md](cli/README.md).
|
|
|
397
493
|
|
|
398
494
|
## AI agents (MCP)
|
|
399
495
|
|
|
400
|
-
Connect your coding agent to `https://commentkit.dev/mcp` and sign in when it asks; in the browser you choose the
|
|
496
|
+
Connect your coding agent to `https://commentkit.dev/mcp` and sign in when it asks; in the browser you choose the website and what the agent may do. Nothing to install:
|
|
401
497
|
|
|
402
498
|
```sh
|
|
403
499
|
npx @commentkit/comment-kit mcp install cursor # or vscode, claude, codex
|
|
@@ -423,8 +519,8 @@ A site with everything in place:
|
|
|
423
519
|
```text
|
|
424
520
|
CommentKit doctor (https://commentkit.dev)
|
|
425
521
|
|
|
426
|
-
✓ @commentkit/comment-kit
|
|
427
|
-
✓ The widget is added in
|
|
522
|
+
✓ @commentkit/comment-kit 2.0.0 is installed (Vite).
|
|
523
|
+
✓ The widget is added in src/main.ts.
|
|
428
524
|
✓ Project key pk_live_abcd… found in .env.local (VITE_COMMENTKIT_KEY).
|
|
429
525
|
✓ The build plugin is set up in vite.config.ts.
|
|
430
526
|
✓ The CLI is signed in to “Acme site”.
|
|
@@ -441,7 +537,7 @@ Everything CommentKit needs is in place.
|
|
|
441
537
|
A site that is not on the project's list and whose CSP blocks CommentKit:
|
|
442
538
|
|
|
443
539
|
```text
|
|
444
|
-
✗ https://shop.acme.com is not on the project's list of allowed websites, so the widget will not load there.
|
|
540
|
+
✗ https://shop.acme.com is not on the project's list of allowed websites, so the widget will not load there. A workspace owner or admin adds it in CommentKit, in the website's Settings → Install, under Addresses.
|
|
445
541
|
✓ The page has the CommentKit script tag (key pk_live_abcd…).
|
|
446
542
|
✗ The page's CSP blocks the CommentKit script: script-src does not allow https://commentkit.dev. Add https://commentkit.dev to script-src in the Content-Security-Policy header.
|
|
447
543
|
✗ The page's CSP blocks the widget's requests: default-src does not allow https://commentkit.dev. Add https://commentkit.dev to default-src in the Content-Security-Policy header.
|
package/SECURITY.md
CHANGED
|
@@ -48,7 +48,7 @@ What limits the damage:
|
|
|
48
48
|
- **Sign-in secrets travel only in URL fragments.** A sign-in link from a CommentKit email carries its secret after `#`, which browsers never send to servers, and so does the code email's "Send my comment" link (`#ck_code=`). The loader and `init()` take them off the address bar before anything else runs. The "Send my comment" link publishes only after the guest presses a button in the widget, so a mail scanner that opens links cannot use it; it works once, for 10 minutes, on the website the comment was left on, and the session it starts is bound to the key of the browser that pressed it.
|
|
49
49
|
- **Credentials never touch your page.** Sign-in happens in a CommentKit window (or a same-tab redirect) with PKCE.
|
|
50
50
|
- **Website sign-in is guest-only.** A token from your own login (`identity`) always makes a client-level reviewer, never a team member, and only works on the project's listed websites. Make every token single-use (a `jti`): the widget never re-sends a token that may already have reached the server. An email address that belongs to a reviewer who joined with an emailed code is refused (`identity_conflict`) unless you turn on "Trust email addresses from my website's login" (website settings → For developers). Call `signOut()` from your own logout so the next person on that browser starts signed out.
|
|
51
|
-
- **The project key identifies, it does not authorise.** `pk_…` keys are public. The API accepts browser calls only from the website addresses listed
|
|
51
|
+
- **The project key identifies, it does not authorise.** `pk_…` keys are public. The API accepts browser calls only from the website addresses listed in the website's Settings → Install, under Addresses, and checks every action against the signed-in person's role. A `*.` wildcard there covers one level of subdomains only (`*.example.com` lets in `shop.example.com`, never `a.b.example.com`), and is refused on shared hosts where anyone can have a site (`vercel.app`, `github.io` and the like).
|
|
52
52
|
- **Agent tokens are for servers only.** They are scoped to one project, read-only unless a person grants more, refused when sent from a browser, and stop working when the person who made them loses access.
|
|
53
53
|
- **Feedback is untrusted.** The widget renders it as text, never as HTML. Agent prompts, `npx @commentkit/comment-kit pull` and the MCP server wrap it in `<untrusted-user-content>` fences.
|
|
54
54
|
- **Screenshots leave out private data** before the image is made (see [README → Privacy](README.md#privacy)). Uploaded images are re-encoded on the server, which removes EXIF and GPS data.
|
|
@@ -57,7 +57,7 @@ What limits the damage:
|
|
|
57
57
|
|
|
58
58
|
1. **Load only the scripts you trust** on pages where the widget runs, and keep CommentKit off payment, password-reset, medical and financial pages unless you have reviewed them. Page addresses, titles, selected text, comments and attachments can still contain personal data.
|
|
59
59
|
2. **Pin and review releases** if you need to: an exact npm version and your lockfile, or a pinned `/cdn/<version>/loader.js` with its `integrity` hash (see [README → What CommentKit does to your page](README.md#what-commentkit-does-to-your-page)). The `integrity` hash covers `loader.js` only: the widget files it imports from the same version folder are not checked by the browser. A `<link rel="modulepreload" integrity>` does not close that gap: in our tests WebKit ignores it, and Chromium and Firefox fetch the file again, unchecked, for an `import()` that starts after the preload finished (Firefox also skips it for imported chunks). To have every byte checked, install from npm and serve the widget from your own bundle.
|
|
60
|
-
3. **List only the websites you need**
|
|
60
|
+
3. **List only the websites you need** in the website's Settings → Install, under Addresses, and remove old preview patterns. Prefer exact addresses; a wildcard reaches one subdomain level.
|
|
61
61
|
4. **Use a Content Security Policy.** CommentKit needs no `unsafe-eval` or `unsafe-inline`. The directives are in the README; `npx @commentkit/comment-kit doctor <url>` checks a page's policy. Under Trusted Types, allow the `commentkit-capture` policy name.
|
|
62
62
|
5. **Mark private regions** with `data-commentkit-redact` or `redact`, and use `privacy: "strict"` on pages full of forms, or turn on "Hide everything people type in screenshots" in the website's settings in CommentKit to enforce it everywhere (the widget uses the stricter of the two). Add your own privacy notice there too: guests then see a link to it next to CommentKit's.
|
|
63
63
|
6. **Attachments.** Your CommentKit workspace may limit attachments to images; the widget then offers and accepts only those.
|
package/dist/node/cli/doctor.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Node built-ins only. Every network call goes through an injectable fetch, so the tests run offline.
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { DASHBOARD } from "../shared/dashboard-places.js";
|
|
5
6
|
import { CliError, endpointFrom, Project } from "./api.js";
|
|
6
7
|
import { safeUrl } from "./format.js";
|
|
7
|
-
import { PLUGIN_IMPORT, plan } from "./init.js";
|
|
8
|
+
import { describePlace, PLUGIN_IMPORT, plan, templatesWithTag } from "./init.js";
|
|
8
9
|
import { PUBLISHABLE_KEY } from "./main.js";
|
|
9
10
|
const TIMEOUT_MS = 10_000;
|
|
10
11
|
const MAX_PAGE_BYTES = 2 * 1024 * 1024;
|
|
@@ -339,15 +340,20 @@ function projectSetup(cwd, flagKey, env) {
|
|
|
339
340
|
const checks = [];
|
|
340
341
|
const pkg = readJson(join(cwd, "package.json"));
|
|
341
342
|
const htmlFiles = ["index.html", "public/index.html"].filter((f) => existsSync(join(cwd, f)));
|
|
342
|
-
const appFound = Boolean(pkg) || htmlFiles.length > 0;
|
|
343
343
|
// The same framework and entry-file detection init uses; plan() only reads files.
|
|
344
344
|
const p = plan(cwd, PLAN_KEY);
|
|
345
|
+
// A Laravel app with plain Blade pages may have no package.json.
|
|
346
|
+
const appFound = Boolean(pkg) || htmlFiles.length > 0 || p.framework === "laravel";
|
|
345
347
|
const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
|
|
346
348
|
const installed = readJson(join(cwd, "node_modules", SDK, "package.json"));
|
|
347
349
|
const installedVersion = typeof installed?.version === "string" ? clean(installed.version, 40) : null;
|
|
348
350
|
const html = htmlFiles.map((f) => ({ file: f, text: readFileSync(join(cwd, f), "utf8") }));
|
|
349
351
|
const htmlLoader = html.map((h) => ({ file: h.file, sdk: findSdk(h.text, "http://localhost/") })).find((h) => h.sdk.loader);
|
|
352
|
+
// Laravel: the script tag can be in a Blade layout or a public/*.html page.
|
|
353
|
+
const templateTags = p.framework === "laravel" ? templatesWithTag(cwd) : [];
|
|
350
354
|
const bundled = Boolean(deps[SDK]);
|
|
355
|
+
// Where the widget is: the entry or a file it imports (Vite, Laravel), else what init's plan found.
|
|
356
|
+
const widget = p.widget;
|
|
351
357
|
const add = p.install[0]?.join(" ") ?? `npm install ${SDK}`;
|
|
352
358
|
if (!appFound) {
|
|
353
359
|
checks.push({ id: "setup.app", status: "info", message: "No package.json or index.html in this folder, so the project checks were skipped.", fix: `Run ${CLI} doctor in your app's folder to include them.` });
|
|
@@ -360,18 +366,23 @@ function projectSetup(cwd, flagKey, env) {
|
|
|
360
366
|
else if (htmlLoader) {
|
|
361
367
|
checks.push({ id: "setup.package", status: "pass", message: `The CommentKit script tag is in ${htmlLoader.file}.` });
|
|
362
368
|
}
|
|
369
|
+
else if (templateTags.length) {
|
|
370
|
+
checks.push({ id: "setup.package", status: "pass", message: `The CommentKit script tag is in ${templateTags.map((t) => t.file).slice(0, 3).join(", ")}${templateTags.length > 3 ? ` and ${templateTags.length - 3} more` : ""}.` });
|
|
371
|
+
}
|
|
363
372
|
else if (p.entry === "done") {
|
|
364
373
|
checks.push({ id: "setup.package", status: "pass", message: `The CommentKit script tag is in your ${p.label} app.` });
|
|
365
374
|
}
|
|
366
375
|
else {
|
|
367
|
-
checks.push({ id: "setup.package", status: "fail", message: `CommentKit is not installed in this ${p.label} app: no ${SDK} in package.json and no script tag.`, fix: p.framework === "html" ? `Run ${CLI} init, or add the script tag before </body> (https://commentkit.dev/docs).` : `Run ${CLI} init (or ${add}).` });
|
|
376
|
+
checks.push({ id: "setup.package", status: "fail", message: `CommentKit is not installed in this ${p.label} app: no ${SDK} in package.json and no script tag.`, fix: p.framework === "html" || !p.install.length ? `Run ${CLI} init, or add the script tag before </body> (https://commentkit.dev/docs).` : `Run ${CLI} init (or ${add}).` });
|
|
368
377
|
}
|
|
369
378
|
if (appFound && bundled) {
|
|
370
|
-
if (
|
|
379
|
+
if (widget)
|
|
380
|
+
checks.push({ id: "setup.widget", status: "pass", message: `The widget is added in ${describePlace(widget)}.` });
|
|
381
|
+
else if (p.entry === "done")
|
|
371
382
|
checks.push({ id: "setup.widget", status: "pass", message: "The widget is added in your layout or entry file." });
|
|
372
383
|
else {
|
|
373
384
|
const where = p.entry ? p.entry.file : "your layout or entry file";
|
|
374
|
-
checks.push({ id: "setup.widget", status: "warn", message: `Could not find the widget in ${where}.`, fix: `If you call init() or render <CommentKit> somewhere else, ignore this; otherwise run ${CLI} init.` });
|
|
385
|
+
checks.push({ id: "setup.widget", status: "warn", message: `Could not find the widget in ${where}${p.entry && p.framework === "laravel" ? " or a file it imports" : ""}.`, fix: `If you call init() or render <CommentKit> somewhere else, ignore this; otherwise run ${CLI} init.` });
|
|
375
386
|
}
|
|
376
387
|
}
|
|
377
388
|
// The key: --key, then the env files init writes, then the environment, then the script tag.
|
|
@@ -411,9 +422,15 @@ function projectSetup(cwd, flagKey, env) {
|
|
|
411
422
|
key = htmlLoader.sdk.loader.key;
|
|
412
423
|
keySource = htmlLoader.file;
|
|
413
424
|
}
|
|
425
|
+
// Written into the code as the default (init({ project: import.meta.env.VITE_COMMENTKIT_KEY || "pk_…" })), or on a template's tag.
|
|
426
|
+
const written = [widget, ...templateTags].find((place) => place?.key);
|
|
427
|
+
if (!key && written) {
|
|
428
|
+
key = written.key;
|
|
429
|
+
keySource = written.file;
|
|
430
|
+
}
|
|
414
431
|
}
|
|
415
432
|
if (key && !PUBLISHABLE_KEY.test(key)) {
|
|
416
|
-
checks.push({ id: "setup.key", status: "fail", message: `The project key in ${keySource} is not a publishable key (it should look like pk_live_… or pk_test_…).`, fix:
|
|
433
|
+
checks.push({ id: "setup.key", status: "fail", message: `The project key in ${keySource} is not a publishable key (it should look like pk_live_… or pk_test_…).`, fix: `Copy the key again from ${DASHBOARD.install} in CommentKit.` });
|
|
417
434
|
}
|
|
418
435
|
else if (key) {
|
|
419
436
|
checks.push({ id: "setup.key", status: "pass", message: `Project key ${maskKey(key)} found in ${keySource}.` });
|
|
@@ -421,18 +438,50 @@ function projectSetup(cwd, flagKey, env) {
|
|
|
421
438
|
checks.push({ id: "setup.key-name", status: "warn", message: `${p.label} apps do not read ${keyVar}, so the widget gets no key.`, fix: `Rename it to ${p.envVar} in ${keySource.split(" ")[0]}.` });
|
|
422
439
|
}
|
|
423
440
|
}
|
|
441
|
+
else if (appFound && p.framework === "laravel") {
|
|
442
|
+
checks.push({ id: "setup.key", status: "fail", message: "No project key found in .env, your JavaScript entry or a Blade script tag.", fix: `Run ${CLI} init, or write the key into your entry: init({ project: import.meta.env.VITE_COMMENTKIT_KEY || "pk_…" }) (the key is in ${DASHBOARD.install} in CommentKit). If the key comes from somewhere else, run ${CLI} doctor --key pk_… instead.` });
|
|
443
|
+
}
|
|
424
444
|
else if (appFound) {
|
|
425
|
-
checks.push({ id: "setup.key", status: "fail", message: `No project key found${p.envFile ? ` in ${p.envFile}` : ""}${htmlFiles.length ? ` or ${htmlFiles[0]}` : ""}.`, fix: p.envVar ? `Run ${CLI} init, or add ${p.envVar}=pk_… to ${p.envFile} (the key is
|
|
445
|
+
checks.push({ id: "setup.key", status: "fail", message: `No project key found${p.envFile ? ` in ${p.envFile}` : ""}${htmlFiles.length ? ` or ${htmlFiles[0]}` : ""}.`, fix: p.envVar ? `Run ${CLI} init, or add ${p.envVar}=pk_… to ${p.envFile} (the key is in ${DASHBOARD.install} in CommentKit). If the key is written straight into your code, run ${CLI} doctor --key pk_… instead.` : `Run ${CLI} init, or put data-project="pk_…" on the script tag (the key is in ${DASHBOARD.install} in CommentKit).` });
|
|
426
446
|
}
|
|
427
|
-
|
|
447
|
+
// A Laravel app without a JavaScript entry uses the script tag: there is no build to add the plugin to.
|
|
448
|
+
if (appFound && p.framework !== "html" && !(p.framework === "laravel" && !p.configFile)) {
|
|
428
449
|
const config = p.configFile ? readFileSync(join(cwd, p.configFile), "utf8") : "";
|
|
429
450
|
if (PLUGIN_IMPORT.test(config))
|
|
430
451
|
checks.push({ id: "setup.plugin", status: "pass", message: `The build plugin is set up in ${p.configFile}.` });
|
|
431
452
|
else
|
|
432
|
-
checks.push({ id: "setup.plugin", status: "info", message: "The build plugin is not set up. It is optional: it adds source file and line to feedback, so you and your coding agent land on the right code.", fix: `Run ${CLI} init to add it.` });
|
|
453
|
+
checks.push({ id: "setup.plugin", status: "info", message: "The build plugin is not set up. It is optional: it adds source file and line to feedback, so you and your coding agent land on the right code.", fix: p.configFile && !p.configEdit ? `Run ${CLI} init: it prints the lines to add to ${p.configFile}, which it cannot edit safely.` : `Run ${CLI} init to add it.` });
|
|
433
454
|
}
|
|
434
455
|
return { checks, key, keySource, installedVersion, bundled, appFound };
|
|
435
456
|
}
|
|
457
|
+
/** Code hosts and registries: a package.json homepage there is not the website. */
|
|
458
|
+
const NOT_A_SITE = /(^|\.)(github\.com|gitlab\.com|bitbucket\.org|npmjs\.com|npmjs\.org)$/i;
|
|
459
|
+
/**
|
|
460
|
+
* The website's address as the project records it: APP_URL in .env.example (Laravel), then "homepage" in
|
|
461
|
+
* package.json. Only a real http(s) address counts: localhost, *.test and code-host links are left out.
|
|
462
|
+
*/
|
|
463
|
+
export function siteAddress(cwd) {
|
|
464
|
+
const candidates = [];
|
|
465
|
+
if (existsSync(join(cwd, ".env.example")))
|
|
466
|
+
candidates.push({ raw: envValue(readFileSync(join(cwd, ".env.example"), "utf8"), "APP_URL"), source: ".env.example (APP_URL)" });
|
|
467
|
+
const homepage = readJson(join(cwd, "package.json"))?.homepage;
|
|
468
|
+
candidates.push({ raw: typeof homepage === "string" ? homepage : null, source: "package.json (homepage)" });
|
|
469
|
+
for (const { raw, source } of candidates) {
|
|
470
|
+
if (!raw || /[\s"'`$<>]/.test(raw))
|
|
471
|
+
continue;
|
|
472
|
+
let url;
|
|
473
|
+
try {
|
|
474
|
+
url = new URL(raw);
|
|
475
|
+
}
|
|
476
|
+
catch {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if ((url.protocol !== "http:" && url.protocol !== "https:") || url.username || url.password || isDevHost(url.hostname) || NOT_A_SITE.test(url.hostname))
|
|
480
|
+
continue;
|
|
481
|
+
return { url: url.origin, source };
|
|
482
|
+
}
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
436
485
|
async function getJson(fetchFn, url, headers, timeoutMs) {
|
|
437
486
|
try {
|
|
438
487
|
const response = await fetchFn(url, { redirect: "error", credentials: "omit", signal: AbortSignal.timeout(timeoutMs), headers: { accept: "application/json", ...headers } });
|
|
@@ -475,13 +524,13 @@ function keyCheck(answer, key, host, sdk) {
|
|
|
475
524
|
if (config.enabled === false && config.disabled_reason === "version_blocked")
|
|
476
525
|
return { config, check: { id: "api.key", status: "fail", message: `This SDK version${sdk ? ` (${clean(sdk, 40)})` : ""} has been switched off by CommentKit; update the package. Until then the widget stays hidden everywhere.`, fix: `npm install ${SDK}@latest, then deploy (sites with the /cdn/v1/ script tag get the fix by themselves).` } };
|
|
477
526
|
if (config.enabled === false)
|
|
478
|
-
return { config, check: { id: "api.key", status: "fail", message: `Feedback is paused for “${name}” (the kill switch is on), so the widget stays hidden everywhere.`, fix:
|
|
527
|
+
return { config, check: { id: "api.key", status: "fail", message: `Feedback is paused for “${name}” (the kill switch is on), so the widget stays hidden everywhere.`, fix: `Turn feedback back on in CommentKit, in ${DASHBOARD.feedbackState}; it applies within a minute.` } };
|
|
479
528
|
if (config.read_only === true)
|
|
480
|
-
return { config, check: { id: "api.key", status: "warn", message: `“${name}” is read-only: the widget shows existing feedback, but nobody can add new feedback (comments are turned off or the plan ended).`, fix:
|
|
529
|
+
return { config, check: { id: "api.key", status: "warn", message: `“${name}” is read-only: the widget shows existing feedback, but nobody can add new feedback (comments are turned off or the plan ended).`, fix: `Check the workspace's plan in CommentKit, and ${DASHBOARD.feedbackState}.` } };
|
|
481
530
|
return { config, check: { id: "api.key", status: "pass", message: `CommentKit knows the key ${maskKey(key)} (project “${name}”) and feedback is on.` } };
|
|
482
531
|
}
|
|
483
532
|
if (status === 404)
|
|
484
|
-
return { config: null, check: { id: "api.key", status: "fail", message: `CommentKit does not know the key ${maskKey(key)}.`, fix:
|
|
533
|
+
return { config: null, check: { id: "api.key", status: "fail", message: `CommentKit does not know the key ${maskKey(key)}.`, fix: `Copy the key again from ${DASHBOARD.install} in CommentKit (pk_live_… for your live site, pk_test_… for staging).` } };
|
|
485
534
|
if (status === 429)
|
|
486
535
|
return { config: null, check: { id: "api.key", status: "warn", message: "CommentKit is getting too many requests from this network right now, so the key was not checked.", fix: `Run ${CLI} doctor again in a minute.` } };
|
|
487
536
|
return { config: null, check: { id: "api.key", status: "fail", message: `CommentKit answered HTTP ${status} when checking the key${json.detail ? `: ${clean(json.detail)}` : ""}.`, fix: `Run ${CLI} doctor again in a few minutes; if it keeps failing, contact CommentKit support.` } };
|
|
@@ -550,8 +599,9 @@ export async function doctor(options, deps = {}) {
|
|
|
550
599
|
const pageKey = sdk?.loader?.key ?? sdk?.key ?? null;
|
|
551
600
|
const key = setup.key && PUBLISHABLE_KEY.test(setup.key) ? setup.key : pageKey && PUBLISHABLE_KEY.test(pageKey) ? pageKey : null;
|
|
552
601
|
if (!setup.appFound && !key)
|
|
553
|
-
checks.push({ id: "setup.key", status: "fail", message: "No project key to check: none in this folder" + (site ? " or on the page." : "."), fix:
|
|
602
|
+
checks.push({ id: "setup.key", status: "fail", message: "No project key to check: none in this folder" + (site ? " or on the page." : "."), fix: `Run doctor in your app's folder, or pass --key pk_… (the key is in ${DASHBOARD.install} in CommentKit).` });
|
|
554
603
|
// 2. Sign-in (optional for doctor).
|
|
604
|
+
let otherWebsite = null;
|
|
555
605
|
try {
|
|
556
606
|
const project = await (deps.project ?? signedIn)();
|
|
557
607
|
if (!project) {
|
|
@@ -559,9 +609,8 @@ export async function doctor(options, deps = {}) {
|
|
|
559
609
|
}
|
|
560
610
|
else {
|
|
561
611
|
checks.push({ id: "signin", status: "pass", message: `The CLI is signed in to “${clean(project.name, 80)}”.` });
|
|
562
|
-
if (key && project.keys.length && !project.keys.includes(key))
|
|
563
|
-
|
|
564
|
-
}
|
|
612
|
+
if (key && project.keys.length && !project.keys.includes(key))
|
|
613
|
+
otherWebsite = clean(project.name, 80);
|
|
565
614
|
}
|
|
566
615
|
}
|
|
567
616
|
catch (error) {
|
|
@@ -580,6 +629,14 @@ export async function doctor(options, deps = {}) {
|
|
|
580
629
|
else if (setup.appFound) {
|
|
581
630
|
checks.push({ id: "api.key", status: "info", message: "Skipped the check with CommentKit: there is no valid project key." });
|
|
582
631
|
}
|
|
632
|
+
// The folder's key belongs to another website than the one the CLI is signed in to. When CommentKit
|
|
633
|
+
// confirmed the key, that is a normal setup (one terminal, several websites): one neutral line.
|
|
634
|
+
if (otherWebsite && key) {
|
|
635
|
+
const known = config ? clean(config.project?.name, 80) : "";
|
|
636
|
+
checks.push(config
|
|
637
|
+
? { id: "signin.key", status: "info", message: `The terminal is signed in to “${otherWebsite}”, a different website from this folder's key${known ? ` (“${known}”)` : ""}. To switch, run ${CLI} login and choose ${known ? `“${known}”` : "this website"}.` }
|
|
638
|
+
: { id: "signin.key", status: "warn", message: `The key ${maskKey(key)} is not one of “${otherWebsite}”'s keys.`, fix: `If this app belongs to another website, ignore this; otherwise copy the key from ${DASHBOARD.install} in CommentKit.` });
|
|
639
|
+
}
|
|
583
640
|
// 4. The website.
|
|
584
641
|
if (site) {
|
|
585
642
|
const shown = clean(safeUrl(site.href), 200);
|
|
@@ -595,14 +652,14 @@ export async function doctor(options, deps = {}) {
|
|
|
595
652
|
if ("error" in answer)
|
|
596
653
|
checks.push(unreachable("site.origin", host, answer.error));
|
|
597
654
|
else if (answer.status === 403 && answer.json.code === "origin_not_allowed")
|
|
598
|
-
checks.push({ id: "site.origin", status: "fail", message: `${origin} is not on the project's list of allowed websites, so the widget will not load there.`, fix:
|
|
655
|
+
checks.push({ id: "site.origin", status: "fail", message: `${origin} is not on the project's list of allowed websites, so the widget will not load there.`, fix: `A workspace owner or admin adds it in CommentKit, in ${DASHBOARD.addresses}.` });
|
|
599
656
|
else if (answer.status === 200) {
|
|
600
657
|
const environment = clean(answer.json.environment, 30);
|
|
601
658
|
checks.push({ id: "site.origin", status: "pass", message: `${origin} is on the project's allowed websites${environment ? ` (${environment})` : ""}.` });
|
|
602
659
|
config ??= answer.json;
|
|
603
660
|
}
|
|
604
661
|
else if (answer.status === 404)
|
|
605
|
-
checks.push({ id: "site.origin", status: "fail", message: `CommentKit does not know the key ${maskKey(originKey)} used on the page.`, fix:
|
|
662
|
+
checks.push({ id: "site.origin", status: "fail", message: `CommentKit does not know the key ${maskKey(originKey)} used on the page.`, fix: `Copy the key again from ${DASHBOARD.install} in CommentKit.` });
|
|
606
663
|
else
|
|
607
664
|
checks.push({ id: "site.origin", status: "warn", message: `Could not check whether ${origin} is allowed (HTTP ${answer.status}).`, fix: `Run ${CLI} doctor again in a minute.` });
|
|
608
665
|
}
|
|
@@ -623,9 +680,9 @@ export async function doctor(options, deps = {}) {
|
|
|
623
680
|
if (sdk.loader) {
|
|
624
681
|
const loaderKey = sdk.loader.key;
|
|
625
682
|
if (!loaderKey)
|
|
626
|
-
checks.push({ id: "site.sdk", status: "fail", message: "The page has the CommentKit script tag, but without a project key.", fix:
|
|
683
|
+
checks.push({ id: "site.sdk", status: "fail", message: "The page has the CommentKit script tag, but without a project key.", fix: `Add data-project="pk_…" to the script tag (the key is in ${DASHBOARD.install} in CommentKit).` });
|
|
627
684
|
else if (!PUBLISHABLE_KEY.test(loaderKey))
|
|
628
|
-
checks.push({ id: "site.sdk", status: "fail", message: "The CommentKit script tag on the page has a key that is not a publishable key.", fix:
|
|
685
|
+
checks.push({ id: "site.sdk", status: "fail", message: "The CommentKit script tag on the page has a key that is not a publishable key.", fix: `Copy the key again from ${DASHBOARD.install} in CommentKit into data-project.` });
|
|
629
686
|
else {
|
|
630
687
|
checks.push({ id: "site.sdk", status: "pass", message: `The page has the CommentKit script tag (key ${maskKey(loaderKey)}).` });
|
|
631
688
|
if (setup.key && PUBLISHABLE_KEY.test(setup.key) && setup.key !== loaderKey)
|
|
@@ -703,6 +760,13 @@ export async function doctor(options, deps = {}) {
|
|
|
703
760
|
checks.push({ id: "site.visibility", status: "info", message: `On ${site.host} the Comment button is hidden from ordinary visitors. It appears after opening a share link, for signed-in reviewers, or after pressing Cmd+Shift+K (Ctrl+Shift+K on Windows).` });
|
|
704
761
|
}
|
|
705
762
|
}
|
|
763
|
+
// Without an address only this folder and the key were checked. Say how to check the site too.
|
|
764
|
+
if (!site && (setup.appFound || key)) {
|
|
765
|
+
const found = siteAddress(options.cwd);
|
|
766
|
+
checks.push(found
|
|
767
|
+
? { id: "site.suggest", status: "info", message: `To also check that ${found.url} is on the project's allowed websites and that its Content Security Policy lets CommentKit load, run ${CLI} doctor ${found.url} (address from ${found.source}).` }
|
|
768
|
+
: { id: "site.suggest", status: "info", message: `To also check that your site is on the project's allowed websites and that its Content Security Policy lets CommentKit load, run ${CLI} doctor with its address, for example ${CLI} doctor https://staging.example.com.` });
|
|
769
|
+
}
|
|
706
770
|
// 5. Version: GET /sdk/latest is the newest stable SDK (public, no key needed). A canary rolling out is not
|
|
707
771
|
// offered: only what every site gets once it is stable.
|
|
708
772
|
if (reachable && setup.installedVersion) {
|