@patchstack/connect 0.3.29 → 0.3.30

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.
Files changed (40) hide show
  1. package/AGENT-INSTALL.md +37 -21
  2. package/README.md +24 -10
  3. package/dist/{chunk-MJOTFUDE.js → chunk-LLKP5EJS.js} +1 -1
  4. package/dist/chunk-LLKP5EJS.js.map +1 -0
  5. package/dist/cli.js +1062 -189
  6. package/dist/cli.js.map +1 -1
  7. package/dist/index.cjs +419 -104
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +28 -9
  10. package/dist/index.d.ts +28 -9
  11. package/dist/index.js +412 -97
  12. package/dist/index.js.map +1 -1
  13. package/dist/protect/templates/astro-middleware.ts +33 -13
  14. package/dist/protect/templates/demo-rules.json +2 -3
  15. package/dist/protect/templates/express-guard.cjs +26 -15
  16. package/dist/protect/templates/express-guard.js +26 -15
  17. package/dist/protect/templates/express-guard.ts +33 -16
  18. package/dist/protect/templates/fastify-plugin.cjs +33 -11
  19. package/dist/protect/templates/fastify-plugin.js +33 -11
  20. package/dist/protect/templates/fastify-plugin.ts +40 -12
  21. package/dist/protect/templates/generic-guard.cjs +28 -12
  22. package/dist/protect/templates/generic-guard.js +28 -13
  23. package/dist/protect/templates/generic-guard.ts +41 -20
  24. package/dist/protect/templates/guard.ts +47 -27
  25. package/dist/protect/templates/next-middleware.ts +29 -12
  26. package/dist/protect/templates/nuxt-middleware.ts +29 -12
  27. package/dist/protect/templates/rules.json +2 -2
  28. package/dist/protect/templates/sveltekit-hooks.ts +33 -13
  29. package/dist/protect.cjs +1039 -235
  30. package/dist/protect.cjs.map +1 -1
  31. package/dist/protect.d.ts +39 -11
  32. package/dist/protect.edge.js +663 -132
  33. package/dist/protect.edge.js.map +4 -4
  34. package/dist/protect.js +665 -134
  35. package/dist/protect.js.map +1 -1
  36. package/dist/{refresh-manifest-VRBE6RH6.js → refresh-manifest-ZSP76JWQ.js} +351 -94
  37. package/dist/refresh-manifest-ZSP76JWQ.js.map +1 -0
  38. package/package.json +5 -2
  39. package/dist/chunk-MJOTFUDE.js.map +0 -1
  40. package/dist/refresh-manifest-VRBE6RH6.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -74,7 +74,7 @@ declare class PatchstackError extends Error {
74
74
  }
75
75
 
76
76
  type LockfileFilename = 'package-lock.json' | 'bun.lock' | 'bun.lockb' | 'yarn.lock' | 'pnpm-lock.yaml';
77
- type DetectionStrategy = 'npm-lockfile' | 'node-modules-walk' | 'pnpm-lockfile' | 'yarn-lockfile';
77
+ type DetectionStrategy = 'npm-lockfile' | 'bun-lockfile' | 'node-modules-walk' | 'pnpm-lockfile' | 'yarn-lockfile';
78
78
  interface DetectedLockfile {
79
79
  ecosystem: 'npm';
80
80
  filePath: string;
@@ -145,21 +145,40 @@ interface ResolveConfigOptions {
145
145
  }
146
146
  declare function resolveConfig(options: ResolveConfigOptions): Promise<Config>;
147
147
  declare function writeConfigFile(cwd: string, config: ConfigFile): Promise<string>;
148
+ /**
149
+ * What happened to the credential file, so a caller can say only what is true.
150
+ *
151
+ * `ignored` is the OUTCOME of the ignore entry, verified by reading the file back — not the fact that a
152
+ * write was attempted. Telling somebody their credential is ignored when it is not is worse than telling
153
+ * them nothing: they stop looking, and a credential committed once is in the history whether or not the
154
+ * file is removed afterwards.
155
+ */
156
+ interface SecretFileResult {
157
+ /** Absolute path of the credential file. */
158
+ path: string;
159
+ /** True only when `.gitignore` was read back and really covers it. */
160
+ ignored: boolean;
161
+ /** Why not, when it is not — for the caller to print instead of a false assurance. */
162
+ reason?: string;
163
+ }
148
164
  /**
149
165
  * Merge a new siteUuid into the existing `.patchstackrc.json` (or create it).
150
166
  * Preserves any `endpoint` / `timeoutMs` / `apiKey` the user already wrote.
151
167
  */
152
168
  declare function persistSiteUuid(cwd: string, siteUuid: string): Promise<string>;
153
169
  /**
154
- * Persist the WP-format api_key issued at provision. Authenticates both the
155
- * Pulse endpoints and connector log reporting. Never embed it in the public
156
- * disclosure widget.
170
+ * Persist the WP-format api_key issued at provision. Authenticates both the Pulse endpoints and connector
171
+ * log reporting. Never embed it in the public disclosure widget.
172
+ *
173
+ * Written to the credential file, which setup adds to the project's ignore list — the public config is
174
+ * meant to be committed, so a credential in it is a credential in the repository.
157
175
  *
158
- * Drops any `pulseAuth` written by an earlier version. That field resolves
159
- * ahead of `apiKey`, so leaving a copy behind after the credential changes
160
- * would leave Pulse authenticating with the value the server just replaced.
176
+ * Any copy in the committed config is REMOVED at the same time. Leaving it would mean the value that just
177
+ * got moved is still in the file everyone commits, which is the state this split exists to end. `pulseAuth`
178
+ * goes with it: that field resolves ahead of `apiKey`, so a stale copy would keep authenticating with a
179
+ * credential the server has replaced.
161
180
  */
162
- declare function persistApiKey(cwd: string, apiKey: string): Promise<string>;
181
+ declare function persistApiKey(cwd: string, apiKey: string): Promise<SecretFileResult>;
163
182
  /**
164
183
  * Persist a Pulse-specific credential.
165
184
  *
@@ -167,7 +186,7 @@ declare function persistApiKey(cwd: string, apiKey: string): Promise<string>;
167
186
  * credentials; they share one today, so `persistApiKey` covers both. Retained
168
187
  * for callers that separate them.
169
188
  */
170
- declare function persistPulseAuth(cwd: string, pulseAuth: string): Promise<string>;
189
+ declare function persistPulseAuth(cwd: string, pulseAuth: string): Promise<SecretFileResult>;
171
190
 
172
191
  /**
173
192
  * A best-effort description of the stack a build was produced with, derived
package/dist/index.d.ts CHANGED
@@ -74,7 +74,7 @@ declare class PatchstackError extends Error {
74
74
  }
75
75
 
76
76
  type LockfileFilename = 'package-lock.json' | 'bun.lock' | 'bun.lockb' | 'yarn.lock' | 'pnpm-lock.yaml';
77
- type DetectionStrategy = 'npm-lockfile' | 'node-modules-walk' | 'pnpm-lockfile' | 'yarn-lockfile';
77
+ type DetectionStrategy = 'npm-lockfile' | 'bun-lockfile' | 'node-modules-walk' | 'pnpm-lockfile' | 'yarn-lockfile';
78
78
  interface DetectedLockfile {
79
79
  ecosystem: 'npm';
80
80
  filePath: string;
@@ -145,21 +145,40 @@ interface ResolveConfigOptions {
145
145
  }
146
146
  declare function resolveConfig(options: ResolveConfigOptions): Promise<Config>;
147
147
  declare function writeConfigFile(cwd: string, config: ConfigFile): Promise<string>;
148
+ /**
149
+ * What happened to the credential file, so a caller can say only what is true.
150
+ *
151
+ * `ignored` is the OUTCOME of the ignore entry, verified by reading the file back — not the fact that a
152
+ * write was attempted. Telling somebody their credential is ignored when it is not is worse than telling
153
+ * them nothing: they stop looking, and a credential committed once is in the history whether or not the
154
+ * file is removed afterwards.
155
+ */
156
+ interface SecretFileResult {
157
+ /** Absolute path of the credential file. */
158
+ path: string;
159
+ /** True only when `.gitignore` was read back and really covers it. */
160
+ ignored: boolean;
161
+ /** Why not, when it is not — for the caller to print instead of a false assurance. */
162
+ reason?: string;
163
+ }
148
164
  /**
149
165
  * Merge a new siteUuid into the existing `.patchstackrc.json` (or create it).
150
166
  * Preserves any `endpoint` / `timeoutMs` / `apiKey` the user already wrote.
151
167
  */
152
168
  declare function persistSiteUuid(cwd: string, siteUuid: string): Promise<string>;
153
169
  /**
154
- * Persist the WP-format api_key issued at provision. Authenticates both the
155
- * Pulse endpoints and connector log reporting. Never embed it in the public
156
- * disclosure widget.
170
+ * Persist the WP-format api_key issued at provision. Authenticates both the Pulse endpoints and connector
171
+ * log reporting. Never embed it in the public disclosure widget.
172
+ *
173
+ * Written to the credential file, which setup adds to the project's ignore list — the public config is
174
+ * meant to be committed, so a credential in it is a credential in the repository.
157
175
  *
158
- * Drops any `pulseAuth` written by an earlier version. That field resolves
159
- * ahead of `apiKey`, so leaving a copy behind after the credential changes
160
- * would leave Pulse authenticating with the value the server just replaced.
176
+ * Any copy in the committed config is REMOVED at the same time. Leaving it would mean the value that just
177
+ * got moved is still in the file everyone commits, which is the state this split exists to end. `pulseAuth`
178
+ * goes with it: that field resolves ahead of `apiKey`, so a stale copy would keep authenticating with a
179
+ * credential the server has replaced.
161
180
  */
162
- declare function persistApiKey(cwd: string, apiKey: string): Promise<string>;
181
+ declare function persistApiKey(cwd: string, apiKey: string): Promise<SecretFileResult>;
163
182
  /**
164
183
  * Persist a Pulse-specific credential.
165
184
  *
@@ -167,7 +186,7 @@ declare function persistApiKey(cwd: string, apiKey: string): Promise<string>;
167
186
  * credentials; they share one today, so `persistApiKey` covers both. Retained
168
187
  * for callers that separate them.
169
188
  */
170
- declare function persistPulseAuth(cwd: string, pulseAuth: string): Promise<string>;
189
+ declare function persistPulseAuth(cwd: string, pulseAuth: string): Promise<SecretFileResult>;
171
190
 
172
191
  /**
173
192
  * A best-effort description of the stack a build was produced with, derived