@patchstack/connect 0.5.27 → 0.5.32

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 +75 -25
  2. package/README.md +28 -14
  3. package/dist/{chunk-YG5C7HYB.js → chunk-52IV7LN7.js} +1 -1
  4. package/dist/{chunk-YG5C7HYB.js.map → chunk-52IV7LN7.js.map} +1 -1
  5. package/dist/cli.js +2749 -372
  6. package/dist/cli.js.map +1 -1
  7. package/dist/index.cjs +10 -6
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +5 -0
  10. package/dist/index.d.ts +5 -0
  11. package/dist/index.js +10 -6
  12. package/dist/index.js.map +1 -1
  13. package/dist/protect/templates/astro-middleware.ts +5 -4
  14. package/dist/protect/templates/express-guard.cjs +5 -8
  15. package/dist/protect/templates/express-guard.js +5 -8
  16. package/dist/protect/templates/express-guard.ts +5 -8
  17. package/dist/protect/templates/fastify-plugin.cjs +52 -6
  18. package/dist/protect/templates/fastify-plugin.js +52 -6
  19. package/dist/protect/templates/fastify-plugin.ts +53 -7
  20. package/dist/protect/templates/fetch-guard.ts +52 -0
  21. package/dist/protect/templates/generic-guard.cjs +6 -5
  22. package/dist/protect/templates/generic-guard.js +6 -5
  23. package/dist/protect/templates/generic-guard.ts +5 -8
  24. package/dist/protect/templates/guard.ts +4 -7
  25. package/dist/protect/templates/next-guard.ts +5 -4
  26. package/dist/protect/templates/next-middleware.ts +5 -4
  27. package/dist/protect/templates/nuxt-middleware.ts +5 -4
  28. package/dist/protect/templates/sveltekit-hooks.ts +5 -4
  29. package/dist/protect.cjs +10 -6
  30. package/dist/protect.cjs.map +1 -1
  31. package/dist/protect.d.cts +1 -1
  32. package/dist/protect.d.ts +1 -1
  33. package/dist/protect.edge.js +2 -2
  34. package/dist/protect.edge.js.map +1 -1
  35. package/dist/protect.js +4 -4
  36. package/dist/protect.js.map +1 -1
  37. package/dist/{refresh-manifest-THITZHBD.js → refresh-manifest-EBORKM75.js} +10 -6
  38. package/dist/refresh-manifest-EBORKM75.js.map +1 -0
  39. package/package.json +5 -2
  40. package/dist/refresh-manifest-THITZHBD.js.map +0 -1
@@ -19,7 +19,7 @@ export interface Protection {
19
19
  * Any further arguments are the host's handler arguments, passed on to `peerAddress`. */
20
20
  fetchGuard(): (request: Request, ...hostArgs: unknown[]) => Promise<Response | null>;
21
21
  /** Screens the request, then the response (secret-leak redaction / withhold). */
22
- fetch(handler: (request: Request, ...rest: unknown[]) => unknown): (request: Request, ...rest: unknown[]) => Promise<unknown>;
22
+ fetch<This, Args extends unknown[]>(handler: (this: This, request: Request, ...rest: Args) => Response | Promise<Response>): (this: This, request: Request, ...rest: Args) => Promise<Response>;
23
23
  /**
24
24
  * Screen a fetch Response through the response-phase rules (redact/withhold/encode).
25
25
  *
package/dist/protect.d.ts CHANGED
@@ -19,7 +19,7 @@ export interface Protection {
19
19
  * Any further arguments are the host's handler arguments, passed on to `peerAddress`. */
20
20
  fetchGuard(): (request: Request, ...hostArgs: unknown[]) => Promise<Response | null>;
21
21
  /** Screens the request, then the response (secret-leak redaction / withhold). */
22
- fetch(handler: (request: Request, ...rest: unknown[]) => unknown): (request: Request, ...rest: unknown[]) => Promise<unknown>;
22
+ fetch<This, Args extends unknown[]>(handler: (this: This, request: Request, ...rest: Args) => Response | Promise<Response>): (this: This, request: Request, ...rest: Args) => Promise<Response>;
23
23
  /**
24
24
  * Screen a fetch Response through the response-phase rules (redact/withhold/encode).
25
25
  *
@@ -7261,10 +7261,10 @@ async function createProtection(options = {}) {
7261
7261
  },
7262
7262
  // Wrap a fetch handler: screens the request, then the response (redact/block).
7263
7263
  fetch(handler) {
7264
- return async (request, ...rest) => {
7264
+ return async function(request, ...rest) {
7265
7265
  const { blocked, client } = await screenFetchRequest(request, rest);
7266
7266
  if (blocked) return blocked;
7267
- const response = await handler(request, ...rest);
7267
+ const response = await handler.call(this, request, ...rest);
7268
7268
  return screenResp(response, reqContextFromFetch(request, client));
7269
7269
  };
7270
7270
  },