@appwarden/middleware 3.10.2 → 3.11.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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![GitHub](https://img.shields.io/badge/GitHub-appwarden%2Fmiddleware-181717?logo=github&logoColor=white)](https://github.com/appwarden/middleware)
5
5
  [![npm version](https://img.shields.io/npm/v/@appwarden/middleware.svg)](https://www.npmjs.com/package/@appwarden/middleware)
6
6
  [![npm provenance](https://img.shields.io/badge/npm-provenance-green)](https://docs.npmjs.com/generating-provenance-statements)
7
- ![Test Coverage](https://img.shields.io/badge/coverage-92.9%25-brightgreen)
7
+ ![Test Coverage](https://img.shields.io/badge/coverage-93.03%25-brightgreen)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
9
 
10
10
  ## Core Features
package/cloudflare.d.ts CHANGED
@@ -260,8 +260,10 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
260
260
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
261
261
  };
262
262
  }>>>;
263
+ debug: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
263
264
  }, "strip", z.ZodTypeAny, {
264
265
  lockPageSlug: string;
266
+ debug?: boolean | undefined;
265
267
  contentSecurityPolicy?: {
266
268
  mode: "disabled" | "report-only" | "enforced";
267
269
  directives?: {
@@ -295,6 +297,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
295
297
  } | undefined;
296
298
  }, {
297
299
  lockPageSlug: string;
300
+ debug?: string | boolean | undefined;
298
301
  contentSecurityPolicy?: {
299
302
  mode: "disabled" | "report-only" | "enforced";
300
303
  directives: string | {
@@ -335,6 +338,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
335
338
  lockPageSlug?: string | undefined;
336
339
  multidomainConfig?: Record<string, {
337
340
  lockPageSlug: string;
341
+ debug?: boolean | undefined;
338
342
  contentSecurityPolicy?: {
339
343
  mode: "disabled" | "report-only" | "enforced";
340
344
  directives?: {
@@ -374,6 +378,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
374
378
  lockPageSlug?: string | undefined;
375
379
  multidomainConfig?: Record<string, {
376
380
  lockPageSlug: string;
381
+ debug?: string | boolean | undefined;
377
382
  contentSecurityPolicy?: {
378
383
  mode: "disabled" | "report-only" | "enforced";
379
384
  directives: string | {
package/cloudflare.js CHANGED
@@ -33,7 +33,8 @@ var AppwardenMultidomainConfigSchema = z.record(
33
33
  z.string(),
34
34
  z.object({
35
35
  lockPageSlug: z.string(),
36
- contentSecurityPolicy: z.lazy(() => UseCSPInputSchema).optional()
36
+ contentSecurityPolicy: z.lazy(() => UseCSPInputSchema).optional(),
37
+ debug: BooleanSchema.optional()
37
38
  })
38
39
  );
39
40
  var UseAppwardenInputSchema = z.object({
@@ -146,16 +147,20 @@ var appwardenOnCloudflare = (inputFn) => async (request, env, ctx) => {
146
147
  return insertErrorLogs(tempContext, parsedInput.error);
147
148
  }
148
149
  const input = parsedInput.data({ env, ctx, cf: {} });
150
+ const domainDebug = input.multidomainConfig?.[requestUrl.hostname]?.debug ?? input.debug ?? false;
149
151
  const context = {
150
152
  request,
151
153
  hostname: requestUrl.hostname,
152
154
  response: new Response("Unhandled response"),
153
155
  // https://developers.cloudflare.com/workers/observability/errors/#illegal-invocation-errors
154
156
  waitUntil: (fn) => ctx.waitUntil(fn),
155
- debug: debug(input.debug ?? false)
157
+ debug: debug(domainDebug)
156
158
  };
157
159
  try {
158
- const pipeline = [useAppwarden(input), useFetchOrigin()];
160
+ const pipeline = [
161
+ useAppwarden({ ...input, debug: domainDebug }),
162
+ useFetchOrigin()
163
+ ];
159
164
  const cspConfig = input.multidomainConfig?.[requestUrl.hostname]?.contentSecurityPolicy;
160
165
  if (cspConfig) {
161
166
  pipeline.push(useContentSecurityPolicy(cspConfig));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appwarden/middleware",
3
- "version": "3.10.2",
3
+ "version": "3.11.0",
4
4
  "description": "Instantly disable all user interaction with your app deployed on Cloudflare or Vercel",
5
5
  "type": "module",
6
6
  "license": "MIT",