@appwarden/middleware 3.7.0 → 3.9.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appwarden/middleware",
3
- "version": "3.7.0",
4
- "description": "Instantly shut off access your app deployed on Cloudflare or Vercel",
3
+ "version": "3.9.0",
4
+ "description": "Instantly disable all user interaction with your app deployed on Cloudflare or Vercel",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Appwarden <support@appwarden.io>",
@@ -58,7 +58,7 @@
58
58
  "node": ">=24"
59
59
  },
60
60
  "dependencies": {
61
- "@upstash/redis": "^1.36.2",
61
+ "@upstash/redis": "^1.36.3",
62
62
  "@vercel/edge-config": "^1.4.3",
63
63
  "zod": "^3.25.76"
64
64
  },
@@ -117,7 +117,10 @@
117
117
  "h3@<=1.15.4": ">=1.15.5",
118
118
  "js-yaml@<3.14.2": ">=3.14.2",
119
119
  "fast-xml-parser@<5.3.8": ">=5.3.8",
120
- "serialize-javascript@<=7.0.2": ">=7.0.3"
120
+ "serialize-javascript@<=7.0.2": ">=7.0.3",
121
+ "svgo@=4.0.0": ">=4.0.1",
122
+ "@opennextjs/cloudflare@<1.17.1": ">=1.17.1",
123
+ "tar@<=7.5.9": ">=7.5.10"
121
124
  }
122
125
  }
123
126
  }
@@ -97,6 +97,17 @@ declare global {
97
97
  }
98
98
  }
99
99
 
100
+ interface MiddlewareContext {
101
+ hostname: string;
102
+ request: Request;
103
+ response: Response;
104
+ waitUntil: ExecutionContext["waitUntil"];
105
+ debug: (...msg: any[]) => void;
106
+ }
107
+ type Middleware = (context: MiddlewareContext, next: () => MiddlewareNextSchemaType) => MiddlewareNextSchemaType;
108
+ declare const MiddlewareNextSchema: z.ZodUnion<[z.ZodVoid, z.ZodNull, z.ZodPromise<z.ZodUnion<[z.ZodVoid, z.ZodNull]>>]>;
109
+ type MiddlewareNextSchemaType = z.infer<typeof MiddlewareNextSchema>;
110
+
100
111
  declare const CSPDirectivesSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
101
112
  "default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
102
113
  "script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
@@ -179,10 +190,10 @@ declare const CSPDirectivesSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
179
190
  "trusted-types"?: string | boolean | string[] | undefined;
180
191
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
181
192
  }>]>;
182
- declare const CSPModeSchema: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>>>;
183
- declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
184
- mode: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>>>;
185
- directives: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
193
+ declare const CSPModeSchema: z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>;
194
+ declare const UseCSPInputSchema: z.ZodObject<{
195
+ mode: z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>;
196
+ directives: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
186
197
  "default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
187
198
  "script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
188
199
  "style-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
@@ -263,7 +274,7 @@ declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
263
274
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
264
275
  "trusted-types"?: string | boolean | string[] | undefined;
265
276
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
266
- }>]>>, string | {
277
+ }>]>, string | {
267
278
  "default-src"?: string | boolean | string[] | undefined;
268
279
  "script-src"?: string | boolean | string[] | undefined;
269
280
  "style-src"?: string | boolean | string[] | undefined;
@@ -290,7 +301,7 @@ declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
290
301
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
291
302
  "trusted-types"?: string | boolean | string[] | undefined;
292
303
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
293
- } | undefined, string | {
304
+ }, string | {
294
305
  "default-src"?: string | boolean | string[] | undefined;
295
306
  "script-src"?: string | boolean | string[] | undefined;
296
307
  "style-src"?: string | boolean | string[] | undefined;
@@ -317,7 +328,7 @@ declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
317
328
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
318
329
  "trusted-types"?: string | boolean | string[] | undefined;
319
330
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
320
- } | undefined>, {
331
+ }>, {
321
332
  "default-src"?: string | boolean | string[] | undefined;
322
333
  "script-src"?: string | boolean | string[] | undefined;
323
334
  "style-src"?: string | boolean | string[] | undefined;
@@ -371,7 +382,7 @@ declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
371
382
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
372
383
  "trusted-types"?: string | boolean | string[] | undefined;
373
384
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
374
- } | undefined>;
385
+ }>;
375
386
  }, "strip", z.ZodTypeAny, {
376
387
  mode: "disabled" | "report-only" | "enforced";
377
388
  directives?: {
@@ -403,38 +414,8 @@ declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
403
414
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
404
415
  } | undefined;
405
416
  }, {
406
- mode?: "disabled" | "report-only" | "enforced" | undefined;
407
- directives?: string | {
408
- "default-src"?: string | boolean | string[] | undefined;
409
- "script-src"?: string | boolean | string[] | undefined;
410
- "style-src"?: string | boolean | string[] | undefined;
411
- "img-src"?: string | boolean | string[] | undefined;
412
- "connect-src"?: string | boolean | string[] | undefined;
413
- "font-src"?: string | boolean | string[] | undefined;
414
- "object-src"?: string | boolean | string[] | undefined;
415
- "media-src"?: string | boolean | string[] | undefined;
416
- "frame-src"?: string | boolean | string[] | undefined;
417
- sandbox?: string | boolean | string[] | undefined;
418
- "report-uri"?: string | boolean | string[] | undefined;
419
- "child-src"?: string | boolean | string[] | undefined;
420
- "form-action"?: string | boolean | string[] | undefined;
421
- "frame-ancestors"?: string | boolean | string[] | undefined;
422
- "plugin-types"?: string | boolean | string[] | undefined;
423
- "base-uri"?: string | boolean | string[] | undefined;
424
- "report-to"?: string | boolean | string[] | undefined;
425
- "worker-src"?: string | boolean | string[] | undefined;
426
- "manifest-src"?: string | boolean | string[] | undefined;
427
- "prefetch-src"?: string | boolean | string[] | undefined;
428
- "navigate-to"?: string | boolean | string[] | undefined;
429
- "require-sri-for"?: string | boolean | string[] | undefined;
430
- "block-all-mixed-content"?: string | boolean | string[] | undefined;
431
- "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
432
- "trusted-types"?: string | boolean | string[] | undefined;
433
- "require-trusted-types-for"?: string | boolean | string[] | undefined;
434
- } | undefined;
435
- }>, {
436
417
  mode: "disabled" | "report-only" | "enforced";
437
- directives?: {
418
+ directives: string | {
438
419
  "default-src"?: string | boolean | string[] | undefined;
439
420
  "script-src"?: string | boolean | string[] | undefined;
440
421
  "style-src"?: string | boolean | string[] | undefined;
@@ -461,38 +442,10 @@ declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
461
442
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
462
443
  "trusted-types"?: string | boolean | string[] | undefined;
463
444
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
464
- } | undefined;
465
- }, {
466
- mode?: "disabled" | "report-only" | "enforced" | undefined;
467
- directives?: string | {
468
- "default-src"?: string | boolean | string[] | undefined;
469
- "script-src"?: string | boolean | string[] | undefined;
470
- "style-src"?: string | boolean | string[] | undefined;
471
- "img-src"?: string | boolean | string[] | undefined;
472
- "connect-src"?: string | boolean | string[] | undefined;
473
- "font-src"?: string | boolean | string[] | undefined;
474
- "object-src"?: string | boolean | string[] | undefined;
475
- "media-src"?: string | boolean | string[] | undefined;
476
- "frame-src"?: string | boolean | string[] | undefined;
477
- sandbox?: string | boolean | string[] | undefined;
478
- "report-uri"?: string | boolean | string[] | undefined;
479
- "child-src"?: string | boolean | string[] | undefined;
480
- "form-action"?: string | boolean | string[] | undefined;
481
- "frame-ancestors"?: string | boolean | string[] | undefined;
482
- "plugin-types"?: string | boolean | string[] | undefined;
483
- "base-uri"?: string | boolean | string[] | undefined;
484
- "report-to"?: string | boolean | string[] | undefined;
485
- "worker-src"?: string | boolean | string[] | undefined;
486
- "manifest-src"?: string | boolean | string[] | undefined;
487
- "prefetch-src"?: string | boolean | string[] | undefined;
488
- "navigate-to"?: string | boolean | string[] | undefined;
489
- "require-sri-for"?: string | boolean | string[] | undefined;
490
- "block-all-mixed-content"?: string | boolean | string[] | undefined;
491
- "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
492
- "trusted-types"?: string | boolean | string[] | undefined;
493
- "require-trusted-types-for"?: string | boolean | string[] | undefined;
494
- } | undefined;
445
+ };
495
446
  }>;
496
447
  type UseCSPInput = z.infer<typeof UseCSPInputSchema>;
497
448
 
498
- export { type Bindings as B, CSPDirectivesSchema as C, type UseCSPInput as U, CSPModeSchema as a };
449
+ declare const useContentSecurityPolicy: (input: UseCSPInput) => Middleware;
450
+
451
+ export { type Bindings as B, CSPDirectivesSchema as C, type Middleware as M, CSPModeSchema as a, useContentSecurityPolicy as u };
package/vercel.d.ts CHANGED
@@ -6,9 +6,9 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
6
6
  vercelApiToken: z.ZodOptional<z.ZodString>;
7
7
  debug: z.ZodOptional<z.ZodBoolean>;
8
8
  lockPageSlug: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
9
- contentSecurityPolicy: z.ZodOptional<z.ZodEffects<z.ZodObject<{
10
- mode: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>>>;
11
- directives: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodLazy<z.ZodUnion<[z.ZodString, z.ZodObject<{
9
+ contentSecurityPolicy: z.ZodOptional<z.ZodObject<{
10
+ mode: z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>;
11
+ directives: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodLazy<z.ZodUnion<[z.ZodString, z.ZodObject<{
12
12
  "default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
13
13
  "script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
14
14
  "style-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
@@ -89,7 +89,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
89
89
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
90
90
  "trusted-types"?: string | boolean | string[] | undefined;
91
91
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
92
- }>]>>>, string | {
92
+ }>]>>, string | {
93
93
  "default-src"?: string | boolean | string[] | undefined;
94
94
  "script-src"?: string | boolean | string[] | undefined;
95
95
  "style-src"?: string | boolean | string[] | undefined;
@@ -116,7 +116,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
116
116
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
117
117
  "trusted-types"?: string | boolean | string[] | undefined;
118
118
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
119
- } | undefined, string | {
119
+ }, string | {
120
120
  "default-src"?: string | boolean | string[] | undefined;
121
121
  "script-src"?: string | boolean | string[] | undefined;
122
122
  "style-src"?: string | boolean | string[] | undefined;
@@ -143,7 +143,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
143
143
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
144
144
  "trusted-types"?: string | boolean | string[] | undefined;
145
145
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
146
- } | undefined>, string | {
146
+ }>, string | {
147
147
  "default-src"?: string | boolean | string[] | undefined;
148
148
  "script-src"?: string | boolean | string[] | undefined;
149
149
  "style-src"?: string | boolean | string[] | undefined;
@@ -170,7 +170,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
170
170
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
171
171
  "trusted-types"?: string | boolean | string[] | undefined;
172
172
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
173
- } | undefined, string | {
173
+ }, string | {
174
174
  "default-src"?: string | boolean | string[] | undefined;
175
175
  "script-src"?: string | boolean | string[] | undefined;
176
176
  "style-src"?: string | boolean | string[] | undefined;
@@ -197,7 +197,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
197
197
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
198
198
  "trusted-types"?: string | boolean | string[] | undefined;
199
199
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
200
- } | undefined>, {
200
+ }>, {
201
201
  "default-src"?: string | boolean | string[] | undefined;
202
202
  "script-src"?: string | boolean | string[] | undefined;
203
203
  "style-src"?: string | boolean | string[] | undefined;
@@ -251,7 +251,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
251
251
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
252
252
  "trusted-types"?: string | boolean | string[] | undefined;
253
253
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
254
- } | undefined>;
254
+ }>;
255
255
  }, "strip", z.ZodTypeAny, {
256
256
  mode: "disabled" | "report-only" | "enforced";
257
257
  directives?: {
@@ -283,38 +283,8 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
283
283
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
284
284
  } | undefined;
285
285
  }, {
286
- mode?: "disabled" | "report-only" | "enforced" | undefined;
287
- directives?: string | {
288
- "default-src"?: string | boolean | string[] | undefined;
289
- "script-src"?: string | boolean | string[] | undefined;
290
- "style-src"?: string | boolean | string[] | undefined;
291
- "img-src"?: string | boolean | string[] | undefined;
292
- "connect-src"?: string | boolean | string[] | undefined;
293
- "font-src"?: string | boolean | string[] | undefined;
294
- "object-src"?: string | boolean | string[] | undefined;
295
- "media-src"?: string | boolean | string[] | undefined;
296
- "frame-src"?: string | boolean | string[] | undefined;
297
- sandbox?: string | boolean | string[] | undefined;
298
- "report-uri"?: string | boolean | string[] | undefined;
299
- "child-src"?: string | boolean | string[] | undefined;
300
- "form-action"?: string | boolean | string[] | undefined;
301
- "frame-ancestors"?: string | boolean | string[] | undefined;
302
- "plugin-types"?: string | boolean | string[] | undefined;
303
- "base-uri"?: string | boolean | string[] | undefined;
304
- "report-to"?: string | boolean | string[] | undefined;
305
- "worker-src"?: string | boolean | string[] | undefined;
306
- "manifest-src"?: string | boolean | string[] | undefined;
307
- "prefetch-src"?: string | boolean | string[] | undefined;
308
- "navigate-to"?: string | boolean | string[] | undefined;
309
- "require-sri-for"?: string | boolean | string[] | undefined;
310
- "block-all-mixed-content"?: string | boolean | string[] | undefined;
311
- "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
312
- "trusted-types"?: string | boolean | string[] | undefined;
313
- "require-trusted-types-for"?: string | boolean | string[] | undefined;
314
- } | undefined;
315
- }>, {
316
286
  mode: "disabled" | "report-only" | "enforced";
317
- directives?: {
287
+ directives: string | {
318
288
  "default-src"?: string | boolean | string[] | undefined;
319
289
  "script-src"?: string | boolean | string[] | undefined;
320
290
  "style-src"?: string | boolean | string[] | undefined;
@@ -341,37 +311,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
341
311
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
342
312
  "trusted-types"?: string | boolean | string[] | undefined;
343
313
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
344
- } | undefined;
345
- }, {
346
- mode?: "disabled" | "report-only" | "enforced" | undefined;
347
- directives?: string | {
348
- "default-src"?: string | boolean | string[] | undefined;
349
- "script-src"?: string | boolean | string[] | undefined;
350
- "style-src"?: string | boolean | string[] | undefined;
351
- "img-src"?: string | boolean | string[] | undefined;
352
- "connect-src"?: string | boolean | string[] | undefined;
353
- "font-src"?: string | boolean | string[] | undefined;
354
- "object-src"?: string | boolean | string[] | undefined;
355
- "media-src"?: string | boolean | string[] | undefined;
356
- "frame-src"?: string | boolean | string[] | undefined;
357
- sandbox?: string | boolean | string[] | undefined;
358
- "report-uri"?: string | boolean | string[] | undefined;
359
- "child-src"?: string | boolean | string[] | undefined;
360
- "form-action"?: string | boolean | string[] | undefined;
361
- "frame-ancestors"?: string | boolean | string[] | undefined;
362
- "plugin-types"?: string | boolean | string[] | undefined;
363
- "base-uri"?: string | boolean | string[] | undefined;
364
- "report-to"?: string | boolean | string[] | undefined;
365
- "worker-src"?: string | boolean | string[] | undefined;
366
- "manifest-src"?: string | boolean | string[] | undefined;
367
- "prefetch-src"?: string | boolean | string[] | undefined;
368
- "navigate-to"?: string | boolean | string[] | undefined;
369
- "require-sri-for"?: string | boolean | string[] | undefined;
370
- "block-all-mixed-content"?: string | boolean | string[] | undefined;
371
- "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
372
- "trusted-types"?: string | boolean | string[] | undefined;
373
- "require-trusted-types-for"?: string | boolean | string[] | undefined;
374
- } | undefined;
314
+ };
375
315
  }>>;
376
316
  }, "strip", z.ZodTypeAny, {
377
317
  lockPageSlug: string;
@@ -416,8 +356,8 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
416
356
  debug?: boolean | undefined;
417
357
  lockPageSlug?: string | undefined;
418
358
  contentSecurityPolicy?: {
419
- mode?: "disabled" | "report-only" | "enforced" | undefined;
420
- directives?: string | {
359
+ mode: "disabled" | "report-only" | "enforced";
360
+ directives: string | {
421
361
  "default-src"?: string | boolean | string[] | undefined;
422
362
  "script-src"?: string | boolean | string[] | undefined;
423
363
  "style-src"?: string | boolean | string[] | undefined;
@@ -444,7 +384,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
444
384
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
445
385
  "trusted-types"?: string | boolean | string[] | undefined;
446
386
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
447
- } | undefined;
387
+ };
448
388
  } | undefined;
449
389
  vercelApiToken?: string | undefined;
450
390
  }>, {
@@ -490,8 +430,8 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
490
430
  debug?: boolean | undefined;
491
431
  lockPageSlug?: string | undefined;
492
432
  contentSecurityPolicy?: {
493
- mode?: "disabled" | "report-only" | "enforced" | undefined;
494
- directives?: string | {
433
+ mode: "disabled" | "report-only" | "enforced";
434
+ directives: string | {
495
435
  "default-src"?: string | boolean | string[] | undefined;
496
436
  "script-src"?: string | boolean | string[] | undefined;
497
437
  "style-src"?: string | boolean | string[] | undefined;
@@ -518,7 +458,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
518
458
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
519
459
  "trusted-types"?: string | boolean | string[] | undefined;
520
460
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
521
- } | undefined;
461
+ };
522
462
  } | undefined;
523
463
  vercelApiToken?: string | undefined;
524
464
  }>, {
@@ -564,8 +504,8 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
564
504
  debug?: boolean | undefined;
565
505
  lockPageSlug?: string | undefined;
566
506
  contentSecurityPolicy?: {
567
- mode?: "disabled" | "report-only" | "enforced" | undefined;
568
- directives?: string | {
507
+ mode: "disabled" | "report-only" | "enforced";
508
+ directives: string | {
569
509
  "default-src"?: string | boolean | string[] | undefined;
570
510
  "script-src"?: string | boolean | string[] | undefined;
571
511
  "style-src"?: string | boolean | string[] | undefined;
@@ -592,7 +532,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
592
532
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
593
533
  "trusted-types"?: string | boolean | string[] | undefined;
594
534
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
595
- } | undefined;
535
+ };
596
536
  } | undefined;
597
537
  vercelApiToken?: string | undefined;
598
538
  }>, {
@@ -638,8 +578,8 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
638
578
  debug?: boolean | undefined;
639
579
  lockPageSlug?: string | undefined;
640
580
  contentSecurityPolicy?: {
641
- mode?: "disabled" | "report-only" | "enforced" | undefined;
642
- directives?: string | {
581
+ mode: "disabled" | "report-only" | "enforced";
582
+ directives: string | {
643
583
  "default-src"?: string | boolean | string[] | undefined;
644
584
  "script-src"?: string | boolean | string[] | undefined;
645
585
  "style-src"?: string | boolean | string[] | undefined;
@@ -666,7 +606,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
666
606
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
667
607
  "trusted-types"?: string | boolean | string[] | undefined;
668
608
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
669
- } | undefined;
609
+ };
670
610
  } | undefined;
671
611
  vercelApiToken?: string | undefined;
672
612
  }>, {
@@ -712,8 +652,8 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
712
652
  debug?: boolean | undefined;
713
653
  lockPageSlug?: string | undefined;
714
654
  contentSecurityPolicy?: {
715
- mode?: "disabled" | "report-only" | "enforced" | undefined;
716
- directives?: string | {
655
+ mode: "disabled" | "report-only" | "enforced";
656
+ directives: string | {
717
657
  "default-src"?: string | boolean | string[] | undefined;
718
658
  "script-src"?: string | boolean | string[] | undefined;
719
659
  "style-src"?: string | boolean | string[] | undefined;
@@ -740,7 +680,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
740
680
  "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
741
681
  "trusted-types"?: string | boolean | string[] | undefined;
742
682
  "require-trusted-types-for"?: string | boolean | string[] | undefined;
743
- } | undefined;
683
+ };
744
684
  } | undefined;
745
685
  vercelApiToken?: string | undefined;
746
686
  }>;
package/vercel.js CHANGED
@@ -2,16 +2,13 @@ import {
2
2
  isCacheUrl,
3
3
  isValidCacheUrl
4
4
  } from "./chunk-QEFORWCW.js";
5
- import {
6
- validateConfig
7
- } from "./chunk-MNGMTDH3.js";
8
5
  import {
9
6
  MemoryCache,
10
7
  TEMPORARY_REDIRECT_STATUS,
11
8
  buildLockPageUrl,
12
9
  debug,
13
10
  isOnLockPage
14
- } from "./chunk-EPJ4ZVO6.js";
11
+ } from "./chunk-Z7FIMIZS.js";
15
12
  import {
16
13
  APPWARDEN_CACHE_KEY,
17
14
  CSPDirectivesSchema,
@@ -19,12 +16,13 @@ import {
19
16
  errors,
20
17
  globalErrors,
21
18
  isHTMLRequest
22
- } from "./chunk-HCGLR3Z3.js";
19
+ } from "./chunk-UIIYORBW.js";
23
20
  import {
24
21
  LockValue,
22
+ getErrors,
25
23
  makeCSPHeader,
26
24
  printMessage
27
- } from "./chunk-GK6JL5NZ.js";
25
+ } from "./chunk-QGXPAVOA.js";
28
26
 
29
27
  // src/runners/appwarden-on-vercel.ts
30
28
  import { waitUntil } from "@vercel/functions";
@@ -40,8 +38,7 @@ var getLockValue = async (context) => {
40
38
  let serializedValue, lockValue = {
41
39
  isLocked: 0,
42
40
  isLockedTest: 0,
43
- lastCheck: 0,
44
- code: ""
41
+ lastCheck: 0
45
42
  };
46
43
  switch (context.provider) {
47
44
  case "edge-config": {
@@ -108,7 +105,7 @@ var APIError = class extends Error {
108
105
  var syncEdgeValue = async (context) => {
109
106
  context.debug("syncing with api");
110
107
  try {
111
- const response = await fetch(new URL("/v1/status/check", "https://api.appwarden.io"), {
108
+ const response = await fetch(new URL("/v1/appwarden/status", "https://api.appwarden.io"), {
112
109
  method: "POST",
113
110
  headers: { "content-type": "application/json" },
114
111
  body: JSON.stringify({
@@ -138,10 +135,27 @@ var syncEdgeValue = async (context) => {
138
135
  }
139
136
  };
140
137
 
138
+ // src/utils/validate-config.ts
139
+ function validateConfig(config, schema) {
140
+ const result = schema.safeParse(config);
141
+ const hasErrors = !result.success;
142
+ if (hasErrors) {
143
+ const mappedErrors = getErrors(result.error);
144
+ if (mappedErrors.length > 0) {
145
+ for (const error of mappedErrors) {
146
+ console.error(printMessage(error));
147
+ }
148
+ } else {
149
+ console.error(printMessage(result.error.message));
150
+ }
151
+ }
152
+ return hasErrors;
153
+ }
154
+
141
155
  // src/schemas/vercel.ts
142
156
  var VercelCSPSchema = z.object({
143
157
  mode: CSPModeSchema,
144
- directives: z.lazy(() => CSPDirectivesSchema).optional().refine(
158
+ directives: z.lazy(() => CSPDirectivesSchema).refine(
145
159
  (val) => {
146
160
  try {
147
161
  if (typeof val === "string") {
@@ -155,7 +169,6 @@ var VercelCSPSchema = z.object({
155
169
  { message: "DirectivesBadParse" /* DirectivesBadParse */ }
156
170
  ).refine(
157
171
  (val) => {
158
- if (!val) return true;
159
172
  const serialized = typeof val === "string" ? val : JSON.stringify(val);
160
173
  return !serialized.includes("{{nonce}}");
161
174
  },
@@ -165,10 +178,7 @@ var VercelCSPSchema = z.object({
165
178
  ).transform(
166
179
  (val) => typeof val === "string" ? JSON.parse(val) : val
167
180
  )
168
- }).refine(
169
- (values) => ["report-only", "enforced"].includes(values.mode) ? !!values.directives : true,
170
- { path: ["directives"], message: "DirectivesRequired" /* DirectivesRequired */ }
171
- );
181
+ });
172
182
  var BaseNextJsConfigSchema = z.object({
173
183
  cacheUrl: z.string(),
174
184
  appwardenApiToken: z.string(),
package/chunk-MNGMTDH3.js DELETED
@@ -1,25 +0,0 @@
1
- import {
2
- getErrors,
3
- printMessage
4
- } from "./chunk-GK6JL5NZ.js";
5
-
6
- // src/utils/validate-config.ts
7
- function validateConfig(config, schema) {
8
- const result = schema.safeParse(config);
9
- const hasErrors = !result.success;
10
- if (hasErrors) {
11
- const mappedErrors = getErrors(result.error);
12
- if (mappedErrors.length > 0) {
13
- for (const error of mappedErrors) {
14
- console.error(printMessage(error));
15
- }
16
- } else {
17
- console.error(printMessage(result.error.message));
18
- }
19
- }
20
- return hasErrors;
21
- }
22
-
23
- export {
24
- validateConfig
25
- };
@@ -1,17 +0,0 @@
1
- import { U as UseCSPInput } from './use-content-security-policy-DUYpyUPy.js';
2
- import { z } from 'zod';
3
-
4
- interface MiddlewareContext {
5
- hostname: string;
6
- request: Request;
7
- response: Response;
8
- waitUntil: ExecutionContext["waitUntil"];
9
- debug: (...msg: any[]) => void;
10
- }
11
- type Middleware = (context: MiddlewareContext, next: () => MiddlewareNextSchemaType) => MiddlewareNextSchemaType;
12
- declare const MiddlewareNextSchema: z.ZodUnion<[z.ZodVoid, z.ZodNull, z.ZodPromise<z.ZodUnion<[z.ZodVoid, z.ZodNull]>>]>;
13
- type MiddlewareNextSchemaType = z.infer<typeof MiddlewareNextSchema>;
14
-
15
- declare const useContentSecurityPolicy: (input: UseCSPInput) => Middleware;
16
-
17
- export { type Middleware as M, useContentSecurityPolicy as u };