@appwarden/middleware 1.0.16

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.
@@ -0,0 +1,245 @@
1
+ import { z } from 'zod';
2
+ import './cloudflare-hVS30fDq.js';
3
+
4
+ interface MiddlewareContext {
5
+ hostname: string;
6
+ request: Request;
7
+ response: Response;
8
+ waitUntil: ExecutionContext["waitUntil"];
9
+ }
10
+ type Middleware = (context: MiddlewareContext, next: () => MiddlewareNextSchemaType) => MiddlewareNextSchemaType;
11
+ declare const MiddlewareNextSchema: z.ZodUnion<[z.ZodVoid, z.ZodNull, z.ZodPromise<z.ZodUnion<[z.ZodVoid, z.ZodNull]>>]>;
12
+ type MiddlewareNextSchemaType = z.infer<typeof MiddlewareNextSchema>;
13
+
14
+ declare const CSPDirectivesSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
15
+ "default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
16
+ "script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
17
+ "style-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
18
+ "img-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
19
+ "connect-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
20
+ "font-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
21
+ "object-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
22
+ "media-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
23
+ "frame-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
24
+ sandbox: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
25
+ "report-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
26
+ "child-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
27
+ "form-action": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
28
+ "frame-ancestors": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
29
+ "plugin-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
30
+ "base-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
31
+ "report-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
32
+ "worker-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
33
+ "manifest-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
34
+ "prefetch-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
35
+ "navigate-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
36
+ "require-sri-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
37
+ "block-all-mixed-content": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
38
+ "upgrade-insecure-requests": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
39
+ "trusted-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
40
+ "require-trusted-types-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ "default-src"?: string | boolean | string[] | undefined;
43
+ "script-src"?: string | boolean | string[] | undefined;
44
+ "style-src"?: string | boolean | string[] | undefined;
45
+ "img-src"?: string | boolean | string[] | undefined;
46
+ "connect-src"?: string | boolean | string[] | undefined;
47
+ "font-src"?: string | boolean | string[] | undefined;
48
+ "object-src"?: string | boolean | string[] | undefined;
49
+ "media-src"?: string | boolean | string[] | undefined;
50
+ "frame-src"?: string | boolean | string[] | undefined;
51
+ sandbox?: string | boolean | string[] | undefined;
52
+ "report-uri"?: string | boolean | string[] | undefined;
53
+ "child-src"?: string | boolean | string[] | undefined;
54
+ "form-action"?: string | boolean | string[] | undefined;
55
+ "frame-ancestors"?: string | boolean | string[] | undefined;
56
+ "plugin-types"?: string | boolean | string[] | undefined;
57
+ "base-uri"?: string | boolean | string[] | undefined;
58
+ "report-to"?: string | boolean | string[] | undefined;
59
+ "worker-src"?: string | boolean | string[] | undefined;
60
+ "manifest-src"?: string | boolean | string[] | undefined;
61
+ "prefetch-src"?: string | boolean | string[] | undefined;
62
+ "navigate-to"?: string | boolean | string[] | undefined;
63
+ "require-sri-for"?: string | boolean | string[] | undefined;
64
+ "block-all-mixed-content"?: string | boolean | string[] | undefined;
65
+ "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
66
+ "trusted-types"?: string | boolean | string[] | undefined;
67
+ "require-trusted-types-for"?: string | boolean | string[] | undefined;
68
+ }, {
69
+ "default-src"?: string | boolean | string[] | undefined;
70
+ "script-src"?: string | boolean | string[] | undefined;
71
+ "style-src"?: string | boolean | string[] | undefined;
72
+ "img-src"?: string | boolean | string[] | undefined;
73
+ "connect-src"?: string | boolean | string[] | undefined;
74
+ "font-src"?: string | boolean | string[] | undefined;
75
+ "object-src"?: string | boolean | string[] | undefined;
76
+ "media-src"?: string | boolean | string[] | undefined;
77
+ "frame-src"?: string | boolean | string[] | undefined;
78
+ sandbox?: string | boolean | string[] | undefined;
79
+ "report-uri"?: string | boolean | string[] | undefined;
80
+ "child-src"?: string | boolean | string[] | undefined;
81
+ "form-action"?: string | boolean | string[] | undefined;
82
+ "frame-ancestors"?: string | boolean | string[] | undefined;
83
+ "plugin-types"?: string | boolean | string[] | undefined;
84
+ "base-uri"?: string | boolean | string[] | undefined;
85
+ "report-to"?: string | boolean | string[] | undefined;
86
+ "worker-src"?: string | boolean | string[] | undefined;
87
+ "manifest-src"?: string | boolean | string[] | undefined;
88
+ "prefetch-src"?: string | boolean | string[] | undefined;
89
+ "navigate-to"?: string | boolean | string[] | undefined;
90
+ "require-sri-for"?: string | boolean | string[] | undefined;
91
+ "block-all-mixed-content"?: string | boolean | string[] | undefined;
92
+ "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
93
+ "trusted-types"?: string | boolean | string[] | undefined;
94
+ "require-trusted-types-for"?: string | boolean | string[] | undefined;
95
+ }>]>;
96
+ declare const CSPEnforcedSchema: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
97
+ declare const InputConfigSchema: z.ZodObject<{
98
+ directives: z.ZodUnion<[z.ZodString, z.ZodObject<{
99
+ "default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
100
+ "script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
101
+ "style-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
102
+ "img-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
103
+ "connect-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
104
+ "font-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
105
+ "object-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
106
+ "media-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
107
+ "frame-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
108
+ sandbox: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
109
+ "report-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
110
+ "child-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
111
+ "form-action": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
112
+ "frame-ancestors": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
113
+ "plugin-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
114
+ "base-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
115
+ "report-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
116
+ "worker-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
117
+ "manifest-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
118
+ "prefetch-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
119
+ "navigate-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
120
+ "require-sri-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
121
+ "block-all-mixed-content": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
122
+ "upgrade-insecure-requests": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
123
+ "trusted-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
124
+ "require-trusted-types-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
125
+ }, "strip", z.ZodTypeAny, {
126
+ "default-src"?: string | boolean | string[] | undefined;
127
+ "script-src"?: string | boolean | string[] | undefined;
128
+ "style-src"?: string | boolean | string[] | undefined;
129
+ "img-src"?: string | boolean | string[] | undefined;
130
+ "connect-src"?: string | boolean | string[] | undefined;
131
+ "font-src"?: string | boolean | string[] | undefined;
132
+ "object-src"?: string | boolean | string[] | undefined;
133
+ "media-src"?: string | boolean | string[] | undefined;
134
+ "frame-src"?: string | boolean | string[] | undefined;
135
+ sandbox?: string | boolean | string[] | undefined;
136
+ "report-uri"?: string | boolean | string[] | undefined;
137
+ "child-src"?: string | boolean | string[] | undefined;
138
+ "form-action"?: string | boolean | string[] | undefined;
139
+ "frame-ancestors"?: string | boolean | string[] | undefined;
140
+ "plugin-types"?: string | boolean | string[] | undefined;
141
+ "base-uri"?: string | boolean | string[] | undefined;
142
+ "report-to"?: string | boolean | string[] | undefined;
143
+ "worker-src"?: string | boolean | string[] | undefined;
144
+ "manifest-src"?: string | boolean | string[] | undefined;
145
+ "prefetch-src"?: string | boolean | string[] | undefined;
146
+ "navigate-to"?: string | boolean | string[] | undefined;
147
+ "require-sri-for"?: string | boolean | string[] | undefined;
148
+ "block-all-mixed-content"?: string | boolean | string[] | undefined;
149
+ "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
150
+ "trusted-types"?: string | boolean | string[] | undefined;
151
+ "require-trusted-types-for"?: string | boolean | string[] | undefined;
152
+ }, {
153
+ "default-src"?: string | boolean | string[] | undefined;
154
+ "script-src"?: string | boolean | string[] | undefined;
155
+ "style-src"?: string | boolean | string[] | undefined;
156
+ "img-src"?: string | boolean | string[] | undefined;
157
+ "connect-src"?: string | boolean | string[] | undefined;
158
+ "font-src"?: string | boolean | string[] | undefined;
159
+ "object-src"?: string | boolean | string[] | undefined;
160
+ "media-src"?: string | boolean | string[] | undefined;
161
+ "frame-src"?: string | boolean | string[] | undefined;
162
+ sandbox?: string | boolean | string[] | undefined;
163
+ "report-uri"?: string | boolean | string[] | undefined;
164
+ "child-src"?: string | boolean | string[] | undefined;
165
+ "form-action"?: string | boolean | string[] | undefined;
166
+ "frame-ancestors"?: string | boolean | string[] | undefined;
167
+ "plugin-types"?: string | boolean | string[] | undefined;
168
+ "base-uri"?: string | boolean | string[] | undefined;
169
+ "report-to"?: string | boolean | string[] | undefined;
170
+ "worker-src"?: string | boolean | string[] | undefined;
171
+ "manifest-src"?: string | boolean | string[] | undefined;
172
+ "prefetch-src"?: string | boolean | string[] | undefined;
173
+ "navigate-to"?: string | boolean | string[] | undefined;
174
+ "require-sri-for"?: string | boolean | string[] | undefined;
175
+ "block-all-mixed-content"?: string | boolean | string[] | undefined;
176
+ "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
177
+ "trusted-types"?: string | boolean | string[] | undefined;
178
+ "require-trusted-types-for"?: string | boolean | string[] | undefined;
179
+ }>]>;
180
+ enforce: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
181
+ }, "strip", z.ZodTypeAny, {
182
+ directives: string | {
183
+ "default-src"?: string | boolean | string[] | undefined;
184
+ "script-src"?: string | boolean | string[] | undefined;
185
+ "style-src"?: string | boolean | string[] | undefined;
186
+ "img-src"?: string | boolean | string[] | undefined;
187
+ "connect-src"?: string | boolean | string[] | undefined;
188
+ "font-src"?: string | boolean | string[] | undefined;
189
+ "object-src"?: string | boolean | string[] | undefined;
190
+ "media-src"?: string | boolean | string[] | undefined;
191
+ "frame-src"?: string | boolean | string[] | undefined;
192
+ sandbox?: string | boolean | string[] | undefined;
193
+ "report-uri"?: string | boolean | string[] | undefined;
194
+ "child-src"?: string | boolean | string[] | undefined;
195
+ "form-action"?: string | boolean | string[] | undefined;
196
+ "frame-ancestors"?: string | boolean | string[] | undefined;
197
+ "plugin-types"?: string | boolean | string[] | undefined;
198
+ "base-uri"?: string | boolean | string[] | undefined;
199
+ "report-to"?: string | boolean | string[] | undefined;
200
+ "worker-src"?: string | boolean | string[] | undefined;
201
+ "manifest-src"?: string | boolean | string[] | undefined;
202
+ "prefetch-src"?: string | boolean | string[] | undefined;
203
+ "navigate-to"?: string | boolean | string[] | undefined;
204
+ "require-sri-for"?: string | boolean | string[] | undefined;
205
+ "block-all-mixed-content"?: string | boolean | string[] | undefined;
206
+ "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
207
+ "trusted-types"?: string | boolean | string[] | undefined;
208
+ "require-trusted-types-for"?: string | boolean | string[] | undefined;
209
+ };
210
+ enforce?: string | boolean | undefined;
211
+ }, {
212
+ directives: string | {
213
+ "default-src"?: string | boolean | string[] | undefined;
214
+ "script-src"?: string | boolean | string[] | undefined;
215
+ "style-src"?: string | boolean | string[] | undefined;
216
+ "img-src"?: string | boolean | string[] | undefined;
217
+ "connect-src"?: string | boolean | string[] | undefined;
218
+ "font-src"?: string | boolean | string[] | undefined;
219
+ "object-src"?: string | boolean | string[] | undefined;
220
+ "media-src"?: string | boolean | string[] | undefined;
221
+ "frame-src"?: string | boolean | string[] | undefined;
222
+ sandbox?: string | boolean | string[] | undefined;
223
+ "report-uri"?: string | boolean | string[] | undefined;
224
+ "child-src"?: string | boolean | string[] | undefined;
225
+ "form-action"?: string | boolean | string[] | undefined;
226
+ "frame-ancestors"?: string | boolean | string[] | undefined;
227
+ "plugin-types"?: string | boolean | string[] | undefined;
228
+ "base-uri"?: string | boolean | string[] | undefined;
229
+ "report-to"?: string | boolean | string[] | undefined;
230
+ "worker-src"?: string | boolean | string[] | undefined;
231
+ "manifest-src"?: string | boolean | string[] | undefined;
232
+ "prefetch-src"?: string | boolean | string[] | undefined;
233
+ "navigate-to"?: string | boolean | string[] | undefined;
234
+ "require-sri-for"?: string | boolean | string[] | undefined;
235
+ "block-all-mixed-content"?: string | boolean | string[] | undefined;
236
+ "upgrade-insecure-requests"?: string | boolean | string[] | undefined;
237
+ "trusted-types"?: string | boolean | string[] | undefined;
238
+ "require-trusted-types-for"?: string | boolean | string[] | undefined;
239
+ };
240
+ enforce?: string | boolean | undefined;
241
+ }>;
242
+ type InputConfigType = z.infer<typeof InputConfigSchema>;
243
+ declare const useContentSecurityPolicy: (input: InputConfigType) => Middleware;
244
+
245
+ export { CSPDirectivesSchema as C, type Middleware as M, CSPEnforcedSchema as a, useContentSecurityPolicy as u };
package/vercel.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import * as next_dist_server_web_types from 'next/dist/server/web/types';
2
+ import * as next_server from 'next/server';
3
+ import { z } from 'zod';
4
+
5
+ declare const BaseNextJsConfigSchema: z.ZodObject<{
6
+ provider: z.ZodEnum<["upstash", "edge-config"]>;
7
+ lockPageSlug: z.ZodString;
8
+ connectionString: z.ZodString;
9
+ edgeConfigId: z.ZodOptional<z.ZodString>;
10
+ vercelApiToken: z.ZodOptional<z.ZodString>;
11
+ appwardenApiToken: z.ZodString;
12
+ }, "strip", z.ZodTypeAny, {
13
+ provider: "upstash" | "edge-config";
14
+ lockPageSlug: string;
15
+ connectionString: string;
16
+ appwardenApiToken: string;
17
+ edgeConfigId?: string | undefined;
18
+ vercelApiToken?: string | undefined;
19
+ }, {
20
+ provider: "upstash" | "edge-config";
21
+ lockPageSlug: string;
22
+ connectionString: string;
23
+ appwardenApiToken: string;
24
+ edgeConfigId?: string | undefined;
25
+ vercelApiToken?: string | undefined;
26
+ }>;
27
+ type BaseNextJsConfigFnType = z.infer<typeof BaseNextJsConfigSchema>;
28
+
29
+ declare const withAppwarden: (input: BaseNextJsConfigFnType) => (req: next_server.NextRequest, event: next_server.NextFetchEvent) => Promise<next_dist_server_web_types.NextMiddlewareResult>;
30
+
31
+ export { BaseNextJsConfigSchema, withAppwarden };
package/vercel.js ADDED
@@ -0,0 +1,13 @@
1
+ import {
2
+ appwardenOnVercel
3
+ } from "./chunk-JXIVUR6E.js";
4
+ import {
5
+ BaseNextJsConfigSchema
6
+ } from "./chunk-C7APN7T6.js";
7
+
8
+ // src/bundles/vercel.ts
9
+ var withAppwarden = appwardenOnVercel;
10
+ export {
11
+ BaseNextJsConfigSchema,
12
+ withAppwarden
13
+ };