@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/README.md +62 -61
- 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 +355 -39
- package/cloudflare/react-router.js +17 -39
- 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/cloudflare/astro.d.ts
CHANGED
|
@@ -1,7 +1,355 @@
|
|
|
1
1
|
import { Runtime } from '@astrojs/cloudflare';
|
|
2
2
|
import { MiddlewareHandler } from 'astro';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Zod schema for Astro Cloudflare adapter configuration.
|
|
7
|
+
* Validates the config object returned by the configFn.
|
|
8
|
+
*/
|
|
9
|
+
declare const AstroCloudflareConfigSchema: z.ZodObject<{
|
|
10
|
+
/** The slug/path of the lock page to redirect to when the site is locked */
|
|
11
|
+
lockPageSlug: z.ZodString;
|
|
12
|
+
/** The Appwarden API token for authentication */
|
|
13
|
+
appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
|
|
14
|
+
/** Optional custom API hostname (defaults to https://api.appwarden.io) */
|
|
15
|
+
appwardenApiHostname: z.ZodOptional<z.ZodString>;
|
|
16
|
+
/** Enable debug logging */
|
|
17
|
+
debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
|
|
18
|
+
/** Optional Content Security Policy configuration */
|
|
19
|
+
contentSecurityPolicy: z.ZodOptional<z.ZodLazy<z.ZodObject<{
|
|
20
|
+
mode: z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>;
|
|
21
|
+
directives: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
22
|
+
"default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
23
|
+
"script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
24
|
+
"style-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
25
|
+
"img-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
26
|
+
"connect-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
27
|
+
"font-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
28
|
+
"object-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
29
|
+
"media-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
30
|
+
"frame-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
31
|
+
sandbox: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
32
|
+
"report-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
33
|
+
"child-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
34
|
+
"form-action": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
35
|
+
"frame-ancestors": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
36
|
+
"plugin-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
37
|
+
"base-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
38
|
+
"report-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
39
|
+
"worker-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
40
|
+
"manifest-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
41
|
+
"prefetch-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
42
|
+
"navigate-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
43
|
+
"require-sri-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
44
|
+
"block-all-mixed-content": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
45
|
+
"upgrade-insecure-requests": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
46
|
+
"trusted-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
47
|
+
"require-trusted-types-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
50
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
51
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
52
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
53
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
54
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
55
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
56
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
57
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
58
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
59
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
60
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
61
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
62
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
63
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
64
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
65
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
66
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
67
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
68
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
69
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
70
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
71
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
72
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
73
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
74
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
77
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
78
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
79
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
80
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
81
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
82
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
83
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
84
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
85
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
86
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
87
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
88
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
89
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
90
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
91
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
92
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
93
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
94
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
95
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
96
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
97
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
98
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
99
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
100
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
101
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
102
|
+
}>]>, string | {
|
|
103
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
104
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
105
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
106
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
107
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
108
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
109
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
110
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
111
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
112
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
113
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
114
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
115
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
116
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
117
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
118
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
119
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
120
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
121
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
122
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
123
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
124
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
125
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
126
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
127
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
128
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
129
|
+
}, string | {
|
|
130
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
131
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
132
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
133
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
134
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
135
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
136
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
137
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
138
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
139
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
140
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
141
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
142
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
143
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
144
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
145
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
146
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
147
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
148
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
149
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
150
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
151
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
152
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
153
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
154
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
155
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
156
|
+
}>, {
|
|
157
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
158
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
159
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
160
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
161
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
162
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
163
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
164
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
165
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
166
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
167
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
168
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
169
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
170
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
171
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
172
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
173
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
174
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
175
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
176
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
177
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
178
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
179
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
180
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
181
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
182
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
183
|
+
} | undefined, string | {
|
|
184
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
185
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
186
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
187
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
188
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
189
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
190
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
191
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
192
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
193
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
194
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
195
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
196
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
197
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
198
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
199
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
200
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
201
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
202
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
203
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
204
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
205
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
206
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
207
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
208
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
209
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
210
|
+
}>;
|
|
211
|
+
}, "strip", z.ZodTypeAny, {
|
|
212
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
213
|
+
directives?: {
|
|
214
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
215
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
216
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
217
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
218
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
219
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
220
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
221
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
222
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
223
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
224
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
225
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
226
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
227
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
228
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
229
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
230
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
231
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
232
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
233
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
234
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
235
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
236
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
237
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
238
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
239
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
240
|
+
} | undefined;
|
|
241
|
+
}, {
|
|
242
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
243
|
+
directives: string | {
|
|
244
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
245
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
246
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
247
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
248
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
249
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
250
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
251
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
252
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
253
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
254
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
255
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
256
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
257
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
258
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
259
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
260
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
261
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
262
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
263
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
264
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
265
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
266
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
267
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
268
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
269
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
270
|
+
};
|
|
271
|
+
}>>>;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
debug: boolean;
|
|
274
|
+
lockPageSlug: string;
|
|
275
|
+
appwardenApiToken: string;
|
|
276
|
+
contentSecurityPolicy?: {
|
|
277
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
278
|
+
directives?: {
|
|
279
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
280
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
281
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
282
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
283
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
284
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
285
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
286
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
287
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
288
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
289
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
290
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
291
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
292
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
293
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
294
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
295
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
296
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
297
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
298
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
299
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
300
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
301
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
302
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
303
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
304
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
305
|
+
} | undefined;
|
|
306
|
+
} | undefined;
|
|
307
|
+
appwardenApiHostname?: string | undefined;
|
|
308
|
+
}, {
|
|
309
|
+
lockPageSlug: string;
|
|
310
|
+
appwardenApiToken: string;
|
|
311
|
+
debug?: string | boolean | undefined;
|
|
312
|
+
contentSecurityPolicy?: {
|
|
313
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
314
|
+
directives: string | {
|
|
315
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
316
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
317
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
318
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
319
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
320
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
321
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
322
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
323
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
324
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
325
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
326
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
327
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
328
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
329
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
330
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
331
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
332
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
333
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
334
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
335
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
336
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
337
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
338
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
339
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
340
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
341
|
+
};
|
|
342
|
+
} | undefined;
|
|
343
|
+
appwardenApiHostname?: string | undefined;
|
|
344
|
+
}>;
|
|
345
|
+
type AstroCloudflareConfig = z.infer<typeof AstroCloudflareConfigSchema>;
|
|
346
|
+
/**
|
|
347
|
+
* Input type for Astro Cloudflare adapter configuration.
|
|
348
|
+
* This is the pre-transformation type that accepts string | boolean for debug
|
|
349
|
+
* and string | object for CSP directives, allowing users to pass environment
|
|
350
|
+
* variables directly without manual transformation.
|
|
351
|
+
*/
|
|
352
|
+
type AstroCloudflareConfigInput = z.input<typeof AstroCloudflareConfigSchema>;
|
|
5
353
|
|
|
6
354
|
/**
|
|
7
355
|
* Cloudflare runtime context provided by Astro on Cloudflare Workers.
|
|
@@ -12,24 +360,19 @@ import 'zod';
|
|
|
12
360
|
type AstroCloudflareRuntime = Runtime<CloudflareEnv>["runtime"];
|
|
13
361
|
/**
|
|
14
362
|
* Configuration for the Appwarden middleware.
|
|
363
|
+
*
|
|
364
|
+
* This is an alias of the validated output type from
|
|
365
|
+
* AstroCloudflareConfigSchema, so it always stays in sync with the
|
|
366
|
+
* actual runtime config contract.
|
|
15
367
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
lockPageSlug: string;
|
|
19
|
-
/** The Appwarden API token for authentication */
|
|
20
|
-
appwardenApiToken: string;
|
|
21
|
-
/** Optional custom API hostname (defaults to https://api.appwarden.io) */
|
|
22
|
-
appwardenApiHostname?: string;
|
|
23
|
-
/** Enable debug logging */
|
|
24
|
-
debug?: boolean;
|
|
25
|
-
/** Optional Content Security Policy configuration */
|
|
26
|
-
contentSecurityPolicy?: UseCSPInput;
|
|
27
|
-
}
|
|
368
|
+
type AstroAppwardenConfig = AstroCloudflareConfig;
|
|
369
|
+
|
|
28
370
|
/**
|
|
29
371
|
* Configuration function that receives the Cloudflare runtime and returns the config.
|
|
30
372
|
* This allows dynamic configuration based on environment variables.
|
|
373
|
+
* Accepts pre-transformation input types (e.g., string | boolean for debug, string | object for CSP directives).
|
|
31
374
|
*/
|
|
32
|
-
type AstroConfigFn = (runtime: AstroCloudflareRuntime) =>
|
|
375
|
+
type AstroConfigFn = (runtime: AstroCloudflareRuntime) => AstroCloudflareConfigInput;
|
|
33
376
|
/**
|
|
34
377
|
* Creates an Appwarden middleware function for Astro.
|
|
35
378
|
*
|
|
@@ -55,4 +398,4 @@ type AstroConfigFn = (runtime: AstroCloudflareRuntime) => AstroAppwardenConfig;
|
|
|
55
398
|
*/
|
|
56
399
|
declare function createAppwardenMiddleware(configFn: AstroConfigFn): MiddlewareHandler;
|
|
57
400
|
|
|
58
|
-
export { createAppwardenMiddleware };
|
|
401
|
+
export { type AstroAppwardenConfig, type AstroCloudflareConfig, type AstroCloudflareConfigInput, type AstroCloudflareRuntime, type AstroConfigFn, createAppwardenMiddleware };
|
package/cloudflare/astro.js
CHANGED
|
@@ -3,32 +3,32 @@ import {
|
|
|
3
3
|
} from "../chunk-XFG6SUSV.js";
|
|
4
4
|
import {
|
|
5
5
|
useContentSecurityPolicy
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-VSCXTBP6.js";
|
|
7
7
|
import {
|
|
8
8
|
getNowMs
|
|
9
9
|
} from "../chunk-X7WZVYQS.js";
|
|
10
|
-
import {
|
|
11
|
-
validateConfig
|
|
12
|
-
} from "../chunk-MNGMTDH3.js";
|
|
13
10
|
import {
|
|
14
11
|
checkLockStatus
|
|
15
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-MYIKUPTR.js";
|
|
16
13
|
import {
|
|
17
14
|
TEMPORARY_REDIRECT_STATUS,
|
|
18
15
|
buildLockPageUrl,
|
|
19
16
|
createRedirect,
|
|
20
17
|
debug,
|
|
21
18
|
isOnLockPage
|
|
22
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-Z7FIMIZS.js";
|
|
23
20
|
import {
|
|
24
21
|
UseCSPInputSchema,
|
|
25
22
|
isHTMLRequest
|
|
26
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-UIIYORBW.js";
|
|
27
24
|
import {
|
|
28
25
|
AppwardenApiTokenSchema,
|
|
29
26
|
BooleanSchema,
|
|
30
27
|
printMessage
|
|
31
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-QGXPAVOA.js";
|
|
29
|
+
|
|
30
|
+
// src/adapters/astro-cloudflare.ts
|
|
31
|
+
import { waitUntil } from "cloudflare:workers";
|
|
32
32
|
|
|
33
33
|
// src/schemas/astro-cloudflare.ts
|
|
34
34
|
import { z } from "zod";
|
|
@@ -61,8 +61,18 @@ function createAppwardenMiddleware(configFn) {
|
|
|
61
61
|
);
|
|
62
62
|
return next();
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
const
|
|
64
|
+
const rawConfig = configFn(runtime);
|
|
65
|
+
const validationResult = AstroCloudflareConfigSchema.safeParse(rawConfig);
|
|
66
|
+
if (!validationResult.success) {
|
|
67
|
+
console.error(
|
|
68
|
+
printMessage(
|
|
69
|
+
`Config validation failed: ${validationResult.error.message}`
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
return next();
|
|
73
|
+
}
|
|
74
|
+
const config = validationResult.data;
|
|
75
|
+
const debugFn = debug(config.debug);
|
|
66
76
|
const requestUrl = new URL(request.url);
|
|
67
77
|
const isHTML = isHTMLRequest(request);
|
|
68
78
|
debugFn(
|
|
@@ -72,10 +82,6 @@ function createAppwardenMiddleware(configFn) {
|
|
|
72
82
|
if (!isHTML) {
|
|
73
83
|
return next();
|
|
74
84
|
}
|
|
75
|
-
const hasError = validateConfig(config, AstroCloudflareConfigSchema);
|
|
76
|
-
if (hasError) {
|
|
77
|
-
return next();
|
|
78
|
-
}
|
|
79
85
|
if (isOnLockPage(config.lockPageSlug, request.url)) {
|
|
80
86
|
debugFn("Already on lock page - skipping");
|
|
81
87
|
return next();
|
|
@@ -86,7 +92,7 @@ function createAppwardenMiddleware(configFn) {
|
|
|
86
92
|
appwardenApiHostname: config.appwardenApiHostname,
|
|
87
93
|
debug: config.debug,
|
|
88
94
|
lockPageSlug: config.lockPageSlug,
|
|
89
|
-
waitUntil
|
|
95
|
+
waitUntil
|
|
90
96
|
});
|
|
91
97
|
if (result.isLocked) {
|
|
92
98
|
const lockPageUrl = buildLockPageUrl(config.lockPageSlug, request.url);
|
|
@@ -106,7 +112,7 @@ function createAppwardenMiddleware(configFn) {
|
|
|
106
112
|
request,
|
|
107
113
|
response,
|
|
108
114
|
hostname: requestUrl.hostname,
|
|
109
|
-
waitUntil
|
|
115
|
+
waitUntil,
|
|
110
116
|
debug: debugFn
|
|
111
117
|
};
|
|
112
118
|
await useContentSecurityPolicy(config.contentSecurityPolicy)(
|