@appwarden/middleware 3.8.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/README.md +60 -57
- package/{chunk-G5FWKV2Q.js → chunk-MYIKUPTR.js} +3 -3
- package/{chunk-GK6JL5NZ.js → chunk-QGXPAVOA.js} +3 -5
- package/{chunk-HCGLR3Z3.js → chunk-UIIYORBW.js} +3 -9
- package/{chunk-52NBQDQT.js → chunk-VSCXTBP6.js} +2 -2
- package/{chunk-EPJ4ZVO6.js → chunk-Z7FIMIZS.js} +2 -2
- package/cloudflare/astro.d.ts +359 -16
- package/cloudflare/astro.js +22 -16
- package/cloudflare/nextjs.d.ts +419 -16
- package/cloudflare/nextjs.js +19 -15
- package/cloudflare/react-router.d.ts +23 -92
- package/cloudflare/react-router.js +12 -17
- package/cloudflare/tanstack-start.d.ts +45 -94
- package/cloudflare/tanstack-start.js +37 -21
- package/{cloudflare-K5EFFMNI.js → cloudflare-PE3JKP3X.js} +1 -1
- package/cloudflare.d.ts +17 -77
- package/cloudflare.js +6 -40
- package/index.d.ts +1 -5
- package/index.js +3 -3
- package/package.json +7 -4
- package/{use-content-security-policy-DUYpyUPy.d.ts → use-content-security-policy-jlU0Hjj8.d.ts} +24 -71
- package/vercel.d.ts +26 -86
- package/vercel.js +25 -15
- package/chunk-MNGMTDH3.js +0 -25
- package/use-content-security-policy-Dvc-oObb.d.ts +0 -17
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.
|
|
10
|
-
mode: z.
|
|
11
|
-
directives: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.
|
|
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
|
-
}>]
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
|
420
|
-
directives
|
|
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
|
-
}
|
|
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
|
|
494
|
-
directives
|
|
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
|
-
}
|
|
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
|
|
568
|
-
directives
|
|
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
|
-
}
|
|
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
|
|
642
|
-
directives
|
|
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
|
-
}
|
|
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
|
|
716
|
-
directives
|
|
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
|
-
}
|
|
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-
|
|
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-
|
|
19
|
+
} from "./chunk-UIIYORBW.js";
|
|
23
20
|
import {
|
|
24
21
|
LockValue,
|
|
22
|
+
getErrors,
|
|
25
23
|
makeCSPHeader,
|
|
26
24
|
printMessage
|
|
27
|
-
} from "./chunk-
|
|
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
|
|
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).
|
|
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
|
-
})
|
|
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 };
|