@appwarden/middleware 1.4.1 → 1.4.3

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @appwarden/middleware
2
2
 
3
- ![Test Coverage](https://img.shields.io/badge/coverage-90.01%25-brightgreen)
3
+ ![Test Coverage](https://img.shields.io/badge/coverage-92.74%25-brightgreen)
4
4
  [![npm version](https://img.shields.io/npm/v/@appwarden/middleware.svg)](https://www.npmjs.com/package/@appwarden/middleware)
5
5
  [![npm provenance](https://img.shields.io/badge/npm-provenance-green)](https://docs.npmjs.com/generating-provenance-statements)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@@ -14,7 +14,7 @@ var debug = (...msg) => {
14
14
  };
15
15
 
16
16
  // src/utils/print-message.ts
17
- var addSlashes = (str) => str.replace(/[\\"'`]/g, "\\$&").replace(/\u0000/g, "\\0");
17
+ var addSlashes = (str) => str.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\u0000/g, "\\0").replace(/<\/script>/gi, "<\\/script>");
18
18
  var printMessage = (message) => `[@appwarden/middleware] ${addSlashes(message)}`;
19
19
 
20
20
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  debug,
3
3
  printMessage
4
- } from "./chunk-JWUAFJ2E.js";
4
+ } from "./chunk-FDIKUQ3E.js";
5
5
 
6
6
  // src/schemas/use-content-security-policy.ts
7
7
  import { z as z2 } from "zod";
@@ -125,7 +125,7 @@ var useContentSecurityPolicy = (input) => {
125
125
  if (response.headers.has("Content-Type") && !response.headers.get("Content-Type")?.includes("text/html")) {
126
126
  return;
127
127
  }
128
- const cspNonce = btoa(crypto.getRandomValues(new Uint32Array(2)).toString());
128
+ const cspNonce = crypto.randomUUID();
129
129
  const [cspHeaderName, cspHeaderValue] = makeCSPHeader(
130
130
  cspNonce,
131
131
  config.directives,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LOCKDOWN_TEST_EXPIRY_MS
3
- } from "./chunk-JWUAFJ2E.js";
3
+ } from "./chunk-FDIKUQ3E.js";
4
4
 
5
5
  // src/utils/errors.ts
6
6
  var errorsMap = {
package/cloudflare.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  useContentSecurityPolicy
3
- } from "./chunk-NZNMFDZ7.js";
3
+ } from "./chunk-GTGPYCQY.js";
4
4
  import {
5
5
  BooleanSchema,
6
6
  LockValue,
7
7
  MemoryCache,
8
8
  getErrors
9
- } from "./chunk-47MLTBFC.js";
9
+ } from "./chunk-L6RSRHOF.js";
10
10
  import {
11
11
  APPWARDEN_CACHE_KEY,
12
12
  APPWARDEN_TEST_ROUTE,
13
13
  APPWARDEN_USER_AGENT,
14
14
  debug,
15
15
  printMessage
16
- } from "./chunk-JWUAFJ2E.js";
16
+ } from "./chunk-FDIKUQ3E.js";
17
17
 
18
18
  // src/runners/appwarden-on-cloudflare.ts
19
19
  import { ZodError } from "zod";
@@ -201,7 +201,7 @@ var APIError = class extends Error {
201
201
  var syncEdgeValue = async (context) => {
202
202
  debug(`syncing with api`);
203
203
  try {
204
- const response = await fetch(new URL("/v1/status/check", "https://bot-gateway.appwarden.io"), {
204
+ const response = await fetch(new URL("/v1/status/check", "https://api.appwarden.io"), {
205
205
  method: "POST",
206
206
  headers: { "content-type": "application/json" },
207
207
  body: JSON.stringify({
package/index.js CHANGED
@@ -7,12 +7,12 @@ import {
7
7
  CSPDirectivesSchema,
8
8
  CSPModeSchema,
9
9
  useContentSecurityPolicy
10
- } from "./chunk-NZNMFDZ7.js";
10
+ } from "./chunk-GTGPYCQY.js";
11
11
  import {
12
12
  APPWARDEN_CACHE_KEY,
13
13
  APPWARDEN_USER_AGENT,
14
14
  LOCKDOWN_TEST_EXPIRY_MS
15
- } from "./chunk-JWUAFJ2E.js";
15
+ } from "./chunk-FDIKUQ3E.js";
16
16
  export {
17
17
  APPWARDEN_CACHE_KEY,
18
18
  APPWARDEN_USER_AGENT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appwarden/middleware",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Instantly shut off access your app deployed on Cloudflare or Vercel",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,8 +37,9 @@
37
37
  "default": "./cloudflare.js"
38
38
  }
39
39
  },
40
+ "packageManager": "pnpm@10.4.1",
40
41
  "engines": {
41
- "node": ">=20"
42
+ "node": ">=24"
42
43
  },
43
44
  "dependencies": {
44
45
  "@cloudflare/next-on-pages": "1.13.12",
@@ -54,16 +55,20 @@
54
55
  "optional": true
55
56
  }
56
57
  },
58
+ "lint-staged": {
59
+ "*.{ts,tsx,js,jsx,json,md,yml,yaml}": [
60
+ "prettier --write"
61
+ ]
62
+ },
57
63
  "pnpm": {
58
64
  "overrides": {
59
65
  "cookie@<0.7.0": ">=0.7.0",
60
66
  "esbuild@<=0.24.2": ">=0.25.0",
61
- "tar@<=7.5.2": ">=7.5.3",
62
- "tar@<=7.5.3": ">=7.5.4",
63
- "undici@<5.29.0": ">=5.29.0",
67
+ "path-to-regexp@>=4.0.0 <6.3.0": ">=6.3.0",
68
+ "tar@<7.5.7": ">=7.5.7",
64
69
  "undici@<6.23.0": ">=6.23.0",
65
- "undici@>=4.5.0 <5.28.5": ">=5.28.5",
66
- "path-to-regexp@>=4.0.0 <6.3.0": ">=6.3.0"
70
+ "body-parser@>=2.2.0 <2.2.1": ">=2.2.1",
71
+ "jws@=4.0.0": ">=4.0.1"
67
72
  }
68
73
  }
69
74
  }
package/vercel.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  LockValue,
8
8
  MemoryCache,
9
9
  getErrors
10
- } from "./chunk-47MLTBFC.js";
10
+ } from "./chunk-L6RSRHOF.js";
11
11
  import {
12
12
  APPWARDEN_CACHE_KEY,
13
13
  APPWARDEN_TEST_ROUTE,
@@ -16,7 +16,7 @@ import {
16
16
  errors,
17
17
  globalErrors,
18
18
  printMessage
19
- } from "./chunk-JWUAFJ2E.js";
19
+ } from "./chunk-FDIKUQ3E.js";
20
20
 
21
21
  // src/runners/appwarden-on-vercel.ts
22
22
  import { NextResponse } from "next/server";
@@ -161,7 +161,7 @@ var APIError = class extends Error {
161
161
  var syncEdgeValue = async (context) => {
162
162
  debug(`syncing with api`);
163
163
  try {
164
- const response = await fetch(new URL("/v1/status/check", "https://bot-gateway.appwarden.io"), {
164
+ const response = await fetch(new URL("/v1/status/check", "https://api.appwarden.io"), {
165
165
  method: "POST",
166
166
  headers: { "content-type": "application/json" },
167
167
  body: JSON.stringify({
@@ -229,7 +229,7 @@ var AppwardenConfigSchema = BaseNextJsConfigSchema.refine(
229
229
  path: ["cacheUrl"]
230
230
  }
231
231
  ).superRefine((data, ctx) => {
232
- if (!isValidCacheUrl.edgeConfig(data.cacheUrl) && isValidCacheUrl.upstash(data.cacheUrl)) {
232
+ if (isCacheUrl.edgeConfig(data.cacheUrl) && !isValidCacheUrl.edgeConfig(data.cacheUrl)) {
233
233
  ctx.addIssue({
234
234
  code: "custom",
235
235
  message: printMessage(
@@ -239,7 +239,7 @@ var AppwardenConfigSchema = BaseNextJsConfigSchema.refine(
239
239
  });
240
240
  return false;
241
241
  }
242
- if (!isValidCacheUrl.upstash(data.cacheUrl) && isValidCacheUrl.edgeConfig(data.cacheUrl)) {
242
+ if (isCacheUrl.upstash(data.cacheUrl) && !isValidCacheUrl.upstash(data.cacheUrl)) {
243
243
  ctx.addIssue({
244
244
  code: "custom",
245
245
  message: printMessage(