@appwarden/middleware 1.1.2 → 1.1.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.
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  APPWARDEN_CACHE_KEY,
3
3
  APPWARDEN_TEST_ROUTE,
4
+ APPWARDEN_USER_AGENT,
4
5
  LockValue,
5
6
  MemoryCache,
6
7
  UseCSPInputSchema,
@@ -9,7 +10,7 @@ import {
9
10
  printMessage,
10
11
  removedHeaders,
11
12
  renderLockPage
12
- } from "./chunk-RKUPO5Z3.js";
13
+ } from "./chunk-5UMKWIJW.js";
13
14
 
14
15
  // src/utils/cloudflare/cloudflare-cache.ts
15
16
  var store = {
@@ -329,7 +330,8 @@ var useAppwarden = (input) => async (context, next) => {
329
330
  return;
330
331
  }
331
332
  const isHTMLRequest = response.headers.get("Content-Type")?.includes("text/html");
332
- if (isHTMLRequest) {
333
+ const isMonitoringRequest = request.headers.get("User-Agent") === APPWARDEN_USER_AGENT;
334
+ if (isHTMLRequest && !isMonitoringRequest) {
333
335
  const innerContext = {
334
336
  keyName,
335
337
  request,
@@ -4,6 +4,7 @@ var removedHeaders = ["X-Powered-By", "Server"];
4
4
  var errors = { badCacheConnection: "BAD_CACHE_CONNECTION" };
5
5
  var globalErrors = [errors.badCacheConnection];
6
6
  var APPWARDEN_TEST_ROUTE = "/_appwarden/test";
7
+ var APPWARDEN_USER_AGENT = "Appwarden-Monitor";
7
8
  var APPWARDEN_CACHE_KEY = "appwarden-lock";
8
9
 
9
10
  // src/utils/is-cache-url.ts
@@ -503,6 +504,7 @@ export {
503
504
  removedHeaders,
504
505
  globalErrors,
505
506
  APPWARDEN_TEST_ROUTE,
507
+ APPWARDEN_USER_AGENT,
506
508
  APPWARDEN_CACHE_KEY,
507
509
  debug,
508
510
  getErrors,
package/cloudflare.js CHANGED
@@ -2,11 +2,11 @@ import {
2
2
  insertErrorLogs,
3
3
  useAppwarden,
4
4
  useContentSecurityPolicy
5
- } from "./chunk-SDYUAIDZ.js";
5
+ } from "./chunk-3STKCAEA.js";
6
6
  import {
7
7
  ConfigFnInputSchema,
8
8
  usePipeline
9
- } from "./chunk-RKUPO5Z3.js";
9
+ } from "./chunk-5UMKWIJW.js";
10
10
 
11
11
  // src/runners/appwarden-on-cloudflare.ts
12
12
  import { ZodError } from "zod";
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { B as Bindings, C as CSPDirectivesSchema, a as CSPModeSchema, M as Middl
2
2
  import { z } from 'zod';
3
3
 
4
4
  declare const LOCKDOWN_TEST_EXPIRY_MS: number;
5
+ declare const APPWARDEN_USER_AGENT: "Appwarden-Monitor";
5
6
  declare const APPWARDEN_CACHE_KEY: "appwarden-lock";
6
7
 
7
8
  declare const getEdgeConfigId: (value?: string) => string | undefined;
@@ -32,4 +33,4 @@ declare const LockValue: z.ZodObject<{
32
33
  }>;
33
34
  type LockValueType = z.infer<typeof LockValue>;
34
35
 
35
- export { APPWARDEN_CACHE_KEY, LOCKDOWN_TEST_EXPIRY_MS, type LockValueType, getEdgeConfigId, isCacheUrl, isValidCacheUrl };
36
+ export { APPWARDEN_CACHE_KEY, APPWARDEN_USER_AGENT, LOCKDOWN_TEST_EXPIRY_MS, type LockValueType, getEdgeConfigId, isCacheUrl, isValidCacheUrl };
package/index.js CHANGED
@@ -1,17 +1,19 @@
1
1
  import {
2
2
  useContentSecurityPolicy
3
- } from "./chunk-SDYUAIDZ.js";
3
+ } from "./chunk-3STKCAEA.js";
4
4
  import {
5
5
  APPWARDEN_CACHE_KEY,
6
+ APPWARDEN_USER_AGENT,
6
7
  CSPDirectivesSchema,
7
8
  CSPModeSchema,
8
9
  LOCKDOWN_TEST_EXPIRY_MS,
9
10
  getEdgeConfigId,
10
11
  isCacheUrl,
11
12
  isValidCacheUrl
12
- } from "./chunk-RKUPO5Z3.js";
13
+ } from "./chunk-5UMKWIJW.js";
13
14
  export {
14
15
  APPWARDEN_CACHE_KEY,
16
+ APPWARDEN_USER_AGENT,
15
17
  CSPDirectivesSchema,
16
18
  CSPModeSchema,
17
19
  LOCKDOWN_TEST_EXPIRY_MS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appwarden/middleware",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Instantly shut off access your app deployed on Cloudflare or Vercel",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/vercel.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  APPWARDEN_CACHE_KEY,
3
+ APPWARDEN_USER_AGENT,
3
4
  AppwardenConfigSchema,
4
5
  BaseNextJsConfigSchema,
5
6
  MemoryCache,
@@ -10,7 +11,7 @@ import {
10
11
  isCacheUrl,
11
12
  printMessage,
12
13
  syncEdgeValue
13
- } from "./chunk-RKUPO5Z3.js";
14
+ } from "./chunk-5UMKWIJW.js";
14
15
 
15
16
  // src/runners/appwarden-on-vercel.ts
16
17
  import { NextResponse } from "next/server";
@@ -36,14 +37,13 @@ var appwardenOnVercel = (input) => async (req, event) => {
36
37
  }
37
38
  try {
38
39
  const requestUrl = new URL(req.url);
39
- const acceptHeader = req.headers.get("accept");
40
- const isHTMLRequest = acceptHeader?.includes("text/html");
40
+ const isHTMLRequest = req.headers.get("accept")?.includes("text/html");
41
+ const isMonitoringRequest = req.headers.get("User-Agent") === APPWARDEN_USER_AGENT;
41
42
  debug({
42
- acceptHeader,
43
43
  isHTMLRequest,
44
44
  url: requestUrl.pathname
45
45
  });
46
- if (isHTMLRequest) {
46
+ if (isHTMLRequest && !isMonitoringRequest) {
47
47
  let appwardenResponse = void 0;
48
48
  const context = {
49
49
  req,