@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
|
@@ -1,79 +1,395 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import 'zod';
|
|
1
|
+
import { z } from 'zod';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Zod schema for React Router Cloudflare adapter configuration.
|
|
5
|
+
* Validates the config object returned by the configFn.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
env: CloudflareEnv;
|
|
10
|
-
ctx: ExecutionContext;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Symbol used to store Cloudflare context in RouterContextProvider.
|
|
14
|
-
* This is used when middleware is enabled with the v8_middleware future flag.
|
|
15
|
-
*/
|
|
16
|
-
declare const cloudflareContextSymbol: unique symbol;
|
|
17
|
-
/**
|
|
18
|
-
* Configuration for the Appwarden middleware.
|
|
19
|
-
*/
|
|
20
|
-
interface ReactRouterAppwardenConfig {
|
|
7
|
+
declare const ReactRouterCloudflareConfigSchema: z.ZodObject<{
|
|
21
8
|
/** The slug/path of the lock page to redirect to when the site is locked */
|
|
22
|
-
lockPageSlug:
|
|
9
|
+
lockPageSlug: z.ZodString;
|
|
23
10
|
/** The Appwarden API token for authentication */
|
|
24
|
-
appwardenApiToken: string
|
|
11
|
+
appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
|
|
25
12
|
/** Optional custom API hostname (defaults to https://api.appwarden.io) */
|
|
26
|
-
appwardenApiHostname
|
|
13
|
+
appwardenApiHostname: z.ZodOptional<z.ZodString>;
|
|
27
14
|
/** Enable debug logging */
|
|
28
|
-
debug
|
|
15
|
+
debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
|
|
29
16
|
/** Optional Content Security Policy configuration */
|
|
30
|
-
contentSecurityPolicy
|
|
31
|
-
|
|
17
|
+
contentSecurityPolicy: z.ZodOptional<z.ZodLazy<z.ZodObject<{
|
|
18
|
+
mode: z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>;
|
|
19
|
+
directives: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
20
|
+
"default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
21
|
+
"script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
22
|
+
"style-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
23
|
+
"img-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
24
|
+
"connect-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
25
|
+
"font-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
26
|
+
"object-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
27
|
+
"media-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
28
|
+
"frame-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
29
|
+
sandbox: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
30
|
+
"report-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
31
|
+
"child-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
32
|
+
"form-action": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
33
|
+
"frame-ancestors": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
34
|
+
"plugin-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
35
|
+
"base-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
36
|
+
"report-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
37
|
+
"worker-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
38
|
+
"manifest-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
39
|
+
"prefetch-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
40
|
+
"navigate-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
41
|
+
"require-sri-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
42
|
+
"block-all-mixed-content": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
43
|
+
"upgrade-insecure-requests": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
44
|
+
"trusted-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
45
|
+
"require-trusted-types-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
48
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
49
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
50
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
51
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
52
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
53
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
54
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
55
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
56
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
57
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
58
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
59
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
60
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
61
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
62
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
63
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
64
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
65
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
66
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
67
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
68
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
69
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
70
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
71
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
72
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
75
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
76
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
77
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
78
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
79
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
80
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
81
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
82
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
83
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
84
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
85
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
86
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
87
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
88
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
89
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
90
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
91
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
92
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
93
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
94
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
95
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
96
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
97
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
98
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
99
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
100
|
+
}>]>, string | {
|
|
101
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
102
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
103
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
104
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
105
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
106
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
107
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
108
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
109
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
110
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
111
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
112
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
113
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
114
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
115
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
116
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
117
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
118
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
119
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
120
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
121
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
122
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
123
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
124
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
125
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
126
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
127
|
+
}, string | {
|
|
128
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
129
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
130
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
131
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
132
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
133
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
134
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
135
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
136
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
137
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
138
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
139
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
140
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
141
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
142
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
143
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
144
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
145
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
146
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
147
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
148
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
149
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
150
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
151
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
152
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
153
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
154
|
+
}>, {
|
|
155
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
156
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
157
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
158
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
159
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
160
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
161
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
162
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
163
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
164
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
165
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
166
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
167
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
168
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
169
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
170
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
171
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
172
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
173
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
174
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
175
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
176
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
177
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
178
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
179
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
180
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
181
|
+
} | undefined, string | {
|
|
182
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
183
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
184
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
185
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
186
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
187
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
188
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
189
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
190
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
191
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
192
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
193
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
194
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
195
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
196
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
197
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
198
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
199
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
200
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
201
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
202
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
203
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
204
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
205
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
206
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
207
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
208
|
+
}>;
|
|
209
|
+
}, "strip", z.ZodTypeAny, {
|
|
210
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
211
|
+
directives?: {
|
|
212
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
213
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
214
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
215
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
216
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
217
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
218
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
219
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
220
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
221
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
222
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
223
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
224
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
225
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
226
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
227
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
228
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
229
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
230
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
231
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
232
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
233
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
234
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
235
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
236
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
237
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
238
|
+
} | undefined;
|
|
239
|
+
}, {
|
|
240
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
241
|
+
directives: string | {
|
|
242
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
243
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
244
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
245
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
246
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
247
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
248
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
249
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
250
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
251
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
252
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
253
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
254
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
255
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
256
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
257
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
258
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
259
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
260
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
261
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
262
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
263
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
264
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
265
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
266
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
267
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
268
|
+
};
|
|
269
|
+
}>>>;
|
|
270
|
+
}, "strip", z.ZodTypeAny, {
|
|
271
|
+
debug: boolean;
|
|
272
|
+
lockPageSlug: string;
|
|
273
|
+
appwardenApiToken: string;
|
|
274
|
+
contentSecurityPolicy?: {
|
|
275
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
276
|
+
directives?: {
|
|
277
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
278
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
279
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
280
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
281
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
282
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
283
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
284
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
285
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
286
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
287
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
288
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
289
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
290
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
291
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
292
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
293
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
294
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
295
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
296
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
297
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
298
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
299
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
300
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
301
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
302
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
303
|
+
} | undefined;
|
|
304
|
+
} | undefined;
|
|
305
|
+
appwardenApiHostname?: string | undefined;
|
|
306
|
+
}, {
|
|
307
|
+
lockPageSlug: string;
|
|
308
|
+
appwardenApiToken: string;
|
|
309
|
+
debug?: string | boolean | undefined;
|
|
310
|
+
contentSecurityPolicy?: {
|
|
311
|
+
mode: "disabled" | "report-only" | "enforced";
|
|
312
|
+
directives: string | {
|
|
313
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
314
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
315
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
316
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
317
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
318
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
319
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
320
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
321
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
322
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
323
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
324
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
325
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
326
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
327
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
328
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
329
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
330
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
331
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
332
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
333
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
334
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
335
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
336
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
337
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
338
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
339
|
+
};
|
|
340
|
+
} | undefined;
|
|
341
|
+
appwardenApiHostname?: string | undefined;
|
|
342
|
+
}>;
|
|
343
|
+
type ReactRouterCloudflareConfig = z.infer<typeof ReactRouterCloudflareConfigSchema>;
|
|
32
344
|
/**
|
|
33
|
-
*
|
|
34
|
-
* This
|
|
345
|
+
* Input type for React Router Cloudflare adapter configuration.
|
|
346
|
+
* This is the pre-transformation type that accepts string | boolean for debug
|
|
347
|
+
* and string | object for CSP directives, allowing users to pass environment
|
|
348
|
+
* variables directly without manual transformation.
|
|
35
349
|
*/
|
|
36
|
-
type
|
|
350
|
+
type ReactRouterAppwardenConfigInput = z.input<typeof ReactRouterCloudflareConfigSchema>;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Configuration function that returns the config.
|
|
354
|
+
* This allows dynamic configuration based on environment variables from cloudflare:workers.
|
|
355
|
+
* The config can use the relaxed input types (string | boolean for debug,
|
|
356
|
+
* string | object for CSP directives) which will be transformed by Zod.
|
|
357
|
+
*
|
|
358
|
+
* @param runtime - Optional runtime context (for backward compatibility)
|
|
359
|
+
*/
|
|
360
|
+
type ReactRouterConfigFn = (runtime?: unknown) => ReactRouterAppwardenConfigInput;
|
|
37
361
|
/**
|
|
38
362
|
* React Router middleware function signature.
|
|
39
363
|
* This matches the unstable_middleware export type in React Router v7.
|
|
40
|
-
*
|
|
41
|
-
* Supports both old and new context APIs:
|
|
42
|
-
* - Old API: context is a plain object with `cloudflare` property
|
|
43
|
-
* - New API (v8_middleware): context is a RouterContextProvider instance
|
|
44
364
|
*/
|
|
45
365
|
interface ReactRouterMiddlewareArgs {
|
|
46
366
|
request: Request;
|
|
47
367
|
params: Record<string, string | undefined>;
|
|
48
|
-
context: any;
|
|
49
368
|
}
|
|
50
|
-
type ReactRouterMiddlewareFunction = (args: ReactRouterMiddlewareArgs, next: () => Promise<
|
|
369
|
+
type ReactRouterMiddlewareFunction = (args: ReactRouterMiddlewareArgs, next: () => Promise<void | Response>) => Promise<void | Response>;
|
|
51
370
|
/**
|
|
52
371
|
* Creates an Appwarden middleware function for React Router.
|
|
53
372
|
*
|
|
54
373
|
* This middleware checks if the site is locked and redirects to the lock page if so.
|
|
55
374
|
* It should be exported from your root route (root.tsx) to protect all routes.
|
|
56
375
|
*
|
|
57
|
-
* Supports both old and new React Router context APIs:
|
|
58
|
-
* - Old API: Pass context as plain object with `cloudflare` property
|
|
59
|
-
* - New API (v8_middleware): Use RouterContextProvider with cloudflareContextSymbol
|
|
60
|
-
*
|
|
61
376
|
* @example
|
|
62
377
|
* ```typescript
|
|
63
378
|
* // app/root.tsx
|
|
379
|
+
* import { env } from "cloudflare:workers"
|
|
64
380
|
* import { createAppwardenMiddleware } from "@appwarden/middleware/react-router"
|
|
65
381
|
*
|
|
66
382
|
* export const unstable_middleware = [
|
|
67
|
-
* createAppwardenMiddleware((
|
|
383
|
+
* createAppwardenMiddleware(() => ({
|
|
68
384
|
* lockPageSlug: env.APPWARDEN_LOCK_PAGE_SLUG,
|
|
69
385
|
* appwardenApiToken: env.APPWARDEN_API_TOKEN,
|
|
70
386
|
* })),
|
|
71
387
|
* ]
|
|
72
388
|
* ```
|
|
73
389
|
*
|
|
74
|
-
* @param configFn - A function that
|
|
390
|
+
* @param configFn - A function that returns the config using env from cloudflare:workers
|
|
75
391
|
* @returns A React Router middleware function
|
|
76
392
|
*/
|
|
77
393
|
declare function createAppwardenMiddleware(configFn: ReactRouterConfigFn): ReactRouterMiddlewareFunction;
|
|
78
394
|
|
|
79
|
-
export { type
|
|
395
|
+
export { type ReactRouterAppwardenConfigInput, type ReactRouterCloudflareConfig, type ReactRouterConfigFn, type ReactRouterMiddlewareArgs, type ReactRouterMiddlewareFunction, createAppwardenMiddleware };
|
|
@@ -3,31 +3,31 @@ 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
|
buildLockPageUrl,
|
|
18
15
|
createRedirect,
|
|
19
16
|
debug,
|
|
20
17
|
isOnLockPage
|
|
21
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-Z7FIMIZS.js";
|
|
22
19
|
import {
|
|
23
20
|
UseCSPInputSchema,
|
|
24
21
|
isHTMLRequest
|
|
25
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-UIIYORBW.js";
|
|
26
23
|
import {
|
|
27
24
|
AppwardenApiTokenSchema,
|
|
28
25
|
BooleanSchema,
|
|
29
26
|
printMessage
|
|
30
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-QGXPAVOA.js";
|
|
28
|
+
|
|
29
|
+
// src/adapters/react-router-cloudflare.ts
|
|
30
|
+
import { waitUntil } from "cloudflare:workers";
|
|
31
31
|
|
|
32
32
|
// src/schemas/react-router-cloudflare.ts
|
|
33
33
|
import { z } from "zod";
|
|
@@ -45,40 +45,23 @@ var ReactRouterCloudflareConfigSchema = z.object({
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
// src/adapters/react-router-cloudflare.ts
|
|
48
|
-
var cloudflareContextSymbol = /* @__PURE__ */ Symbol.for(
|
|
49
|
-
"@appwarden/middleware:cloudflare"
|
|
50
|
-
);
|
|
51
|
-
function getCloudflareContext(context) {
|
|
52
|
-
if (context?.cloudflare) {
|
|
53
|
-
return context.cloudflare;
|
|
54
|
-
}
|
|
55
|
-
if (context?.get && typeof context.get === "function") {
|
|
56
|
-
try {
|
|
57
|
-
const cloudflare = context.get(cloudflareContextSymbol);
|
|
58
|
-
if (cloudflare) {
|
|
59
|
-
return cloudflare;
|
|
60
|
-
}
|
|
61
|
-
} catch {
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
48
|
function createAppwardenMiddleware(configFn) {
|
|
67
49
|
return async (args, next) => {
|
|
68
50
|
const startTime = getNowMs();
|
|
69
|
-
const { request
|
|
51
|
+
const { request } = args;
|
|
70
52
|
try {
|
|
71
|
-
const
|
|
72
|
-
|
|
53
|
+
const configInput = configFn();
|
|
54
|
+
const validationResult = ReactRouterCloudflareConfigSchema.safeParse(configInput);
|
|
55
|
+
if (!validationResult.success) {
|
|
73
56
|
console.error(
|
|
74
57
|
printMessage(
|
|
75
|
-
|
|
58
|
+
`Config validation failed: ${validationResult.error.message}`
|
|
76
59
|
)
|
|
77
60
|
);
|
|
78
61
|
return next();
|
|
79
62
|
}
|
|
80
|
-
const config =
|
|
81
|
-
const debugFn = debug(config.debug
|
|
63
|
+
const config = validationResult.data;
|
|
64
|
+
const debugFn = debug(config.debug);
|
|
82
65
|
const requestUrl = new URL(request.url);
|
|
83
66
|
const isHTML = isHTMLRequest(request);
|
|
84
67
|
debugFn(
|
|
@@ -88,10 +71,6 @@ function createAppwardenMiddleware(configFn) {
|
|
|
88
71
|
if (!isHTML) {
|
|
89
72
|
return next();
|
|
90
73
|
}
|
|
91
|
-
const hasError = validateConfig(config, ReactRouterCloudflareConfigSchema);
|
|
92
|
-
if (hasError) {
|
|
93
|
-
return next();
|
|
94
|
-
}
|
|
95
74
|
if (isOnLockPage(config.lockPageSlug, request.url)) {
|
|
96
75
|
debugFn("Already on lock page - skipping");
|
|
97
76
|
return next();
|
|
@@ -102,7 +81,7 @@ function createAppwardenMiddleware(configFn) {
|
|
|
102
81
|
appwardenApiHostname: config.appwardenApiHostname,
|
|
103
82
|
debug: config.debug,
|
|
104
83
|
lockPageSlug: config.lockPageSlug,
|
|
105
|
-
waitUntil
|
|
84
|
+
waitUntil
|
|
106
85
|
});
|
|
107
86
|
if (result.isLocked) {
|
|
108
87
|
const lockPageUrl = buildLockPageUrl(config.lockPageSlug, request.url);
|
|
@@ -116,7 +95,7 @@ function createAppwardenMiddleware(configFn) {
|
|
|
116
95
|
request,
|
|
117
96
|
response,
|
|
118
97
|
hostname: requestUrl.hostname,
|
|
119
|
-
waitUntil
|
|
98
|
+
waitUntil,
|
|
120
99
|
debug: debugFn
|
|
121
100
|
};
|
|
122
101
|
await useContentSecurityPolicy(config.contentSecurityPolicy)(
|
|
@@ -146,6 +125,5 @@ function createAppwardenMiddleware(configFn) {
|
|
|
146
125
|
};
|
|
147
126
|
}
|
|
148
127
|
export {
|
|
149
|
-
cloudflareContextSymbol,
|
|
150
128
|
createAppwardenMiddleware
|
|
151
129
|
};
|