@webdecoy/node 0.21.3 → 0.22.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/dist/vercel.d.mts CHANGED
@@ -1,11 +1,11 @@
1
- import { a as ClearanceGateOptions, C as ClearanceContext, b as GateOutcome } from './index-GXXXr_mb.mjs';
1
+ import { a as ClearanceGateOptions, C as ClearanceContext, D as DetectAndGateOptions, d as GateOutcome } from './detect-and-gate-DwcmcUjY.mjs';
2
+ import './sdk-CLrhCMK0.mjs';
2
3
 
3
4
  /**
4
- * WebDecoy clearance for Vercel Routing Middleware, any framework.
5
+ * WebDecoy for Vercel Routing Middleware, any framework.
5
6
  *
6
7
  * Astro, SvelteKit, Nuxt, Remix or a static site on Vercel: put this in
7
- * `middleware.ts` at the project root and set WEBDECOY_SITE_KEY,
8
- * WEBDECOY_SCANNER_ID and WEBDECOY_SENSOR_KEY in the project's environment.
8
+ * `middleware.ts` at the project root.
9
9
  *
10
10
  * ```ts
11
11
  * // middleware.ts
@@ -17,10 +17,21 @@ import { a as ClearanceGateOptions, C as ClearanceContext, b as GateOutcome } fr
17
17
  * };
18
18
  * ```
19
19
  *
20
- * Next.js sites use `withClearance()` from @webdecoy/nextjs instead.
20
+ * It reads the project's environment:
21
21
  *
22
- * Starts in whatever mode the site has in WebDecoy, monitor by default, and
23
- * enforces only once it is switched there and paths are protected.
22
+ * - `WEBDECOY_API_KEY` turns on detection: the request is classified and bots
23
+ * are reported to WebDecoy, including the reserved test trigger
24
+ * (`curl -A "WebDecoy-Test/1.0" https://your-site/`).
25
+ * - `WEBDECOY_SITE_KEY`, `WEBDECOY_SCANNER_ID` and `WEBDECOY_SENSOR_KEY` turn on
26
+ * the clearance gate for the paths the site protects in WebDecoy.
27
+ *
28
+ * Either half works without the other, and with neither every request passes.
29
+ * Detection starts in monitor mode and the gate in whatever mode the site has
30
+ * in WebDecoy (monitor by default), so installing this changes no response
31
+ * until you choose to enforce. Every failure lets the request through.
32
+ *
33
+ * Next.js sites use `@webdecoy/nextjs/vercel`, the same middleware in Next's
34
+ * types.
24
35
  */
25
36
 
26
37
  /**
@@ -34,9 +45,31 @@ import { a as ClearanceGateOptions, C as ClearanceContext, b as GateOutcome } fr
34
45
  * nothing continues the request untouched.
35
46
  */
36
47
  declare function toMiddlewareResponse(outcome: GateOutcome): Response | undefined;
37
- /** Routing Middleware bound to one site. Options default to the environment. */
48
+ /**
49
+ * The clearance gate alone, as Routing Middleware. Options default to the
50
+ * environment. Reports no detections; {@link createVercelMiddleware} does both.
51
+ */
38
52
  declare function clearanceMiddleware(options?: ClearanceGateOptions): (request: Request, context?: ClearanceContext) => Promise<Response | undefined>;
53
+ /**
54
+ * Detection and the clearance gate as Routing Middleware, for customizing
55
+ * what the default export does. Options default to the environment.
56
+ *
57
+ * ```ts
58
+ * // middleware.ts
59
+ * import { createVercelMiddleware } from '@webdecoy/node/vercel';
60
+ * import { tripwire } from '@webdecoy/node';
61
+ *
62
+ * export default createVercelMiddleware({
63
+ * rules: [tripwire({ paths: ['/admin-backup.zip'] })],
64
+ * });
65
+ *
66
+ * export const config = { matcher: ['/((?!_astro/|favicon.ico).*)'] };
67
+ * ```
68
+ *
69
+ * Without an API key it is exactly {@link clearanceMiddleware}.
70
+ */
71
+ declare function createVercelMiddleware(options?: DetectAndGateOptions): (request: Request, context?: ClearanceContext) => Promise<Response | undefined>;
39
72
  /** The middleware configured from WEBDECOY_* environment variables. */
40
73
  declare const middleware: (request: Request, context?: ClearanceContext) => Promise<Response | undefined>;
41
74
 
42
- export { ClearanceContext, ClearanceGateOptions, clearanceMiddleware, middleware as default, toMiddlewareResponse };
75
+ export { ClearanceContext, ClearanceGateOptions, DetectAndGateOptions, clearanceMiddleware, createVercelMiddleware, middleware as default, toMiddlewareResponse };
package/dist/vercel.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { a as ClearanceGateOptions, C as ClearanceContext, b as GateOutcome } from './index-GXXXr_mb.js';
1
+ import { a as ClearanceGateOptions, C as ClearanceContext, D as DetectAndGateOptions, d as GateOutcome } from './detect-and-gate-yg8SW2bD.js';
2
+ import './sdk-CLrhCMK0.js';
2
3
 
3
4
  /**
4
- * WebDecoy clearance for Vercel Routing Middleware, any framework.
5
+ * WebDecoy for Vercel Routing Middleware, any framework.
5
6
  *
6
7
  * Astro, SvelteKit, Nuxt, Remix or a static site on Vercel: put this in
7
- * `middleware.ts` at the project root and set WEBDECOY_SITE_KEY,
8
- * WEBDECOY_SCANNER_ID and WEBDECOY_SENSOR_KEY in the project's environment.
8
+ * `middleware.ts` at the project root.
9
9
  *
10
10
  * ```ts
11
11
  * // middleware.ts
@@ -17,10 +17,21 @@ import { a as ClearanceGateOptions, C as ClearanceContext, b as GateOutcome } fr
17
17
  * };
18
18
  * ```
19
19
  *
20
- * Next.js sites use `withClearance()` from @webdecoy/nextjs instead.
20
+ * It reads the project's environment:
21
21
  *
22
- * Starts in whatever mode the site has in WebDecoy, monitor by default, and
23
- * enforces only once it is switched there and paths are protected.
22
+ * - `WEBDECOY_API_KEY` turns on detection: the request is classified and bots
23
+ * are reported to WebDecoy, including the reserved test trigger
24
+ * (`curl -A "WebDecoy-Test/1.0" https://your-site/`).
25
+ * - `WEBDECOY_SITE_KEY`, `WEBDECOY_SCANNER_ID` and `WEBDECOY_SENSOR_KEY` turn on
26
+ * the clearance gate for the paths the site protects in WebDecoy.
27
+ *
28
+ * Either half works without the other, and with neither every request passes.
29
+ * Detection starts in monitor mode and the gate in whatever mode the site has
30
+ * in WebDecoy (monitor by default), so installing this changes no response
31
+ * until you choose to enforce. Every failure lets the request through.
32
+ *
33
+ * Next.js sites use `@webdecoy/nextjs/vercel`, the same middleware in Next's
34
+ * types.
24
35
  */
25
36
 
26
37
  /**
@@ -34,9 +45,31 @@ import { a as ClearanceGateOptions, C as ClearanceContext, b as GateOutcome } fr
34
45
  * nothing continues the request untouched.
35
46
  */
36
47
  declare function toMiddlewareResponse(outcome: GateOutcome): Response | undefined;
37
- /** Routing Middleware bound to one site. Options default to the environment. */
48
+ /**
49
+ * The clearance gate alone, as Routing Middleware. Options default to the
50
+ * environment. Reports no detections; {@link createVercelMiddleware} does both.
51
+ */
38
52
  declare function clearanceMiddleware(options?: ClearanceGateOptions): (request: Request, context?: ClearanceContext) => Promise<Response | undefined>;
53
+ /**
54
+ * Detection and the clearance gate as Routing Middleware, for customizing
55
+ * what the default export does. Options default to the environment.
56
+ *
57
+ * ```ts
58
+ * // middleware.ts
59
+ * import { createVercelMiddleware } from '@webdecoy/node/vercel';
60
+ * import { tripwire } from '@webdecoy/node';
61
+ *
62
+ * export default createVercelMiddleware({
63
+ * rules: [tripwire({ paths: ['/admin-backup.zip'] })],
64
+ * });
65
+ *
66
+ * export const config = { matcher: ['/((?!_astro/|favicon.ico).*)'] };
67
+ * ```
68
+ *
69
+ * Without an API key it is exactly {@link clearanceMiddleware}.
70
+ */
71
+ declare function createVercelMiddleware(options?: DetectAndGateOptions): (request: Request, context?: ClearanceContext) => Promise<Response | undefined>;
39
72
  /** The middleware configured from WEBDECOY_* environment variables. */
40
73
  declare const middleware: (request: Request, context?: ClearanceContext) => Promise<Response | undefined>;
41
74
 
42
- export { ClearanceContext, ClearanceGateOptions, clearanceMiddleware, middleware as default, toMiddlewareResponse };
75
+ export { ClearanceContext, ClearanceGateOptions, DetectAndGateOptions, clearanceMiddleware, createVercelMiddleware, middleware as default, toMiddlewareResponse };