@webdecoy/nextjs 0.18.0 → 0.18.2
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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -116,6 +116,9 @@ interface WithBotProtectionOptions extends WebDecoyMiddlewareOptions {
|
|
|
116
116
|
* export default withBotProtection(handler, {
|
|
117
117
|
* apiKey: process.env.WEBDECOY_API_KEY!,
|
|
118
118
|
* blockThreshold: 70,
|
|
119
|
+
* // Monitor is the default: the handler always runs and
|
|
120
|
+
* // req.webdecoyDecision.allowed says what enforce would have done.
|
|
121
|
+
* mode: 'enforce',
|
|
119
122
|
* });
|
|
120
123
|
* ```
|
|
121
124
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,9 @@ interface WithBotProtectionOptions extends WebDecoyMiddlewareOptions {
|
|
|
116
116
|
* export default withBotProtection(handler, {
|
|
117
117
|
* apiKey: process.env.WEBDECOY_API_KEY!,
|
|
118
118
|
* blockThreshold: 70,
|
|
119
|
+
* // Monitor is the default: the handler always runs and
|
|
120
|
+
* // req.webdecoyDecision.allowed says what enforce would have done.
|
|
121
|
+
* mode: 'enforce',
|
|
119
122
|
* });
|
|
120
123
|
* ```
|
|
121
124
|
*/
|
package/dist/index.js
CHANGED
|
@@ -124,6 +124,7 @@ function withWebDecoy(config) {
|
|
|
124
124
|
function withBotProtection(handler, config) {
|
|
125
125
|
const sdk = new import_node.WebDecoy(config);
|
|
126
126
|
const threshold = config.blockThreshold ?? 80;
|
|
127
|
+
const mode = config.mode ?? "monitor";
|
|
127
128
|
return (async (...args) => {
|
|
128
129
|
const [req, res] = args;
|
|
129
130
|
try {
|
|
@@ -145,7 +146,7 @@ function withBotProtection(handler, config) {
|
|
|
145
146
|
skipLocalAnalysis: config.skipLocalAnalysis,
|
|
146
147
|
metadata: config.metadata
|
|
147
148
|
});
|
|
148
|
-
if (!result.allowed) {
|
|
149
|
+
if (!result.allowed && mode === "enforce") {
|
|
149
150
|
const block = (0, import_node.ruleBlockResponse)(result);
|
|
150
151
|
if (block) {
|
|
151
152
|
for (const [name, value] of Object.entries(block.headers)) {
|
package/dist/index.mjs
CHANGED
|
@@ -100,6 +100,7 @@ function withWebDecoy(config) {
|
|
|
100
100
|
function withBotProtection(handler, config) {
|
|
101
101
|
const sdk = new WebDecoy(config);
|
|
102
102
|
const threshold = config.blockThreshold ?? 80;
|
|
103
|
+
const mode = config.mode ?? "monitor";
|
|
103
104
|
return (async (...args) => {
|
|
104
105
|
const [req, res] = args;
|
|
105
106
|
try {
|
|
@@ -121,7 +122,7 @@ function withBotProtection(handler, config) {
|
|
|
121
122
|
skipLocalAnalysis: config.skipLocalAnalysis,
|
|
122
123
|
metadata: config.metadata
|
|
123
124
|
});
|
|
124
|
-
if (!result.allowed) {
|
|
125
|
+
if (!result.allowed && mode === "enforce") {
|
|
125
126
|
const block = ruleBlockResponse(result);
|
|
126
127
|
if (block) {
|
|
127
128
|
for (const [name, value] of Object.entries(block.headers)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webdecoy/nextjs",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Web Decoy middleware for Next.js",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"url": "https://github.com/WebDecoy/node/issues"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@webdecoy/node": "^0.18.
|
|
45
|
+
"@webdecoy/node": "^0.18.2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"next": ">=13.0.0"
|