@webdecoy/fastify 0.6.0 → 0.7.0
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/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -0
- package/dist/index.mjs +6 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,18 @@ export { CaptchaEndpointsOptions, ProtectResult, RequestMetadata, SDKDetectionRe
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
interface WebDecoyPluginOptions extends ProtectOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Whether a blocking verdict actually blocks. Defaults to `'monitor'`.
|
|
12
|
+
*
|
|
13
|
+
* MONITOR IS THE DEFAULT ON PURPOSE, and this changed in 0.7.0. Before,
|
|
14
|
+
* installing this with an API key began returning 403 to any request whose
|
|
15
|
+
* server-side score cleared `threatScoreThreshold` (default 80), and there was
|
|
16
|
+
* no supported way to watch first. Found by installing it on a live site that
|
|
17
|
+
* takes payments, where the homepage returned Forbidden on the first request.
|
|
18
|
+
*
|
|
19
|
+
* Watch what it would have done, then set `mode: 'enforce'`.
|
|
20
|
+
*/
|
|
21
|
+
mode?: 'monitor' | 'enforce';
|
|
10
22
|
/**
|
|
11
23
|
* Custom function to extract IP address from request
|
|
12
24
|
* By default, uses request.ip or x-forwarded-for header
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,18 @@ export { CaptchaEndpointsOptions, ProtectResult, RequestMetadata, SDKDetectionRe
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
interface WebDecoyPluginOptions extends ProtectOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Whether a blocking verdict actually blocks. Defaults to `'monitor'`.
|
|
12
|
+
*
|
|
13
|
+
* MONITOR IS THE DEFAULT ON PURPOSE, and this changed in 0.7.0. Before,
|
|
14
|
+
* installing this with an API key began returning 403 to any request whose
|
|
15
|
+
* server-side score cleared `threatScoreThreshold` (default 80), and there was
|
|
16
|
+
* no supported way to watch first. Found by installing it on a live site that
|
|
17
|
+
* takes payments, where the homepage returned Forbidden on the first request.
|
|
18
|
+
*
|
|
19
|
+
* Watch what it would have done, then set `mode: 'enforce'`.
|
|
20
|
+
*/
|
|
21
|
+
mode?: 'monitor' | 'enforce';
|
|
10
22
|
/**
|
|
11
23
|
* Custom function to extract IP address from request
|
|
12
24
|
* By default, uses request.ip or x-forwarded-for header
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,7 @@ async function webdecoyPluginImpl(fastify, options) {
|
|
|
67
67
|
const sdk = new import_node.WebDecoy(options);
|
|
68
68
|
const getIP = options.getIP || defaultGetIP;
|
|
69
69
|
const onBlocked = options.onBlocked || defaultOnBlocked;
|
|
70
|
+
const mode = options.mode ?? "monitor";
|
|
70
71
|
const onError = options.onError || defaultOnError;
|
|
71
72
|
const skipPaths = options.skipPaths;
|
|
72
73
|
fastify.decorateRequest("webdecoy", null);
|
|
@@ -97,6 +98,11 @@ async function webdecoyPluginImpl(fastify, options) {
|
|
|
97
98
|
skipLocalAnalysis: options.skipLocalAnalysis,
|
|
98
99
|
metadata: options.metadata
|
|
99
100
|
});
|
|
101
|
+
if (mode === "monitor") {
|
|
102
|
+
req.webdecoy = result.detection;
|
|
103
|
+
req.webdecoyEdge = result.edge;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
100
106
|
if (!result.allowed && result.ruleResult) {
|
|
101
107
|
const rr = result.ruleResult;
|
|
102
108
|
if (rr.action === "THROTTLE") {
|
package/dist/index.mjs
CHANGED
|
@@ -29,6 +29,7 @@ async function webdecoyPluginImpl(fastify, options) {
|
|
|
29
29
|
const sdk = new WebDecoy(options);
|
|
30
30
|
const getIP = options.getIP || defaultGetIP;
|
|
31
31
|
const onBlocked = options.onBlocked || defaultOnBlocked;
|
|
32
|
+
const mode = options.mode ?? "monitor";
|
|
32
33
|
const onError = options.onError || defaultOnError;
|
|
33
34
|
const skipPaths = options.skipPaths;
|
|
34
35
|
fastify.decorateRequest("webdecoy", null);
|
|
@@ -59,6 +60,11 @@ async function webdecoyPluginImpl(fastify, options) {
|
|
|
59
60
|
skipLocalAnalysis: options.skipLocalAnalysis,
|
|
60
61
|
metadata: options.metadata
|
|
61
62
|
});
|
|
63
|
+
if (mode === "monitor") {
|
|
64
|
+
req.webdecoy = result.detection;
|
|
65
|
+
req.webdecoyEdge = result.edge;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
62
68
|
if (!result.allowed && result.ruleResult) {
|
|
63
69
|
const rr = result.ruleResult;
|
|
64
70
|
if (rr.action === "THROTTLE") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webdecoy/fastify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Web Decoy plugin for Fastify",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"url": "https://github.com/WebDecoy/node/issues"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@webdecoy/node": "^0.
|
|
43
|
+
"@webdecoy/node": "^0.7.0",
|
|
44
44
|
"fastify-plugin": "^4.5.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|