@appwarden/middleware 1.5.0 → 1.6.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 +17 -48
- package/chunk-5DEXVBY6.js +232 -0
- package/chunk-6PUA5YXP.js +27 -0
- package/{chunk-FDIKUQ3E.js → chunk-7UTT3M2S.js} +11 -3
- package/{chunk-L6RSRHOF.js → chunk-B5IE7V77.js} +36 -34
- package/{chunk-TP5CHUTK.js → chunk-MOTPEQEU.js} +3 -2
- package/chunk-N6AUTMZO.js +22 -0
- package/cloudflare/astro.d.ts +72 -0
- package/cloudflare/astro.js +90 -0
- package/cloudflare/nextjs.d.ts +60 -0
- package/cloudflare/nextjs.js +77 -0
- package/cloudflare/react-router.d.ts +63 -0
- package/cloudflare/react-router.js +83 -0
- package/cloudflare/tanstack-start.d.ts +71 -0
- package/cloudflare/tanstack-start.js +86 -0
- package/cloudflare.d.ts +17 -31
- package/cloudflare.js +30 -217
- package/index.d.ts +2 -4
- package/index.js +2 -4
- package/package.json +31 -4
- package/{use-content-security-policy-Cgy0nz3J.d.ts → use-content-security-policy-Bh2qDCKv.d.ts} +98 -2
- package/vercel.d.ts +45 -7
- package/vercel.js +62 -151
- package/cloudflare-2PkEr25r.d.ts +0 -99
package/cloudflare.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useContentSecurityPolicy
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MOTPEQEU.js";
|
|
4
4
|
import {
|
|
5
|
+
checkLockStatus,
|
|
6
|
+
getLockValue,
|
|
7
|
+
store
|
|
8
|
+
} from "./chunk-5DEXVBY6.js";
|
|
9
|
+
import {
|
|
10
|
+
AppwardenApiTokenSchema,
|
|
5
11
|
BooleanSchema,
|
|
6
|
-
LockValue,
|
|
7
|
-
MemoryCache,
|
|
8
12
|
getErrors
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-B5IE7V77.js";
|
|
10
14
|
import {
|
|
11
15
|
APPWARDEN_CACHE_KEY,
|
|
12
|
-
|
|
13
|
-
APPWARDEN_USER_AGENT,
|
|
14
|
-
debug,
|
|
16
|
+
isHTMLResponse,
|
|
15
17
|
printMessage
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-7UTT3M2S.js";
|
|
17
19
|
|
|
18
20
|
// src/runners/appwarden-on-cloudflare.ts
|
|
19
21
|
import { ZodError } from "zod";
|
|
@@ -33,12 +35,13 @@ var UseAppwardenInputSchema = z.object({
|
|
|
33
35
|
debug: BooleanSchema.default(false),
|
|
34
36
|
lockPageSlug: z.string().optional(),
|
|
35
37
|
multidomainConfig: AppwardenMultidomainConfigSchema.optional(),
|
|
36
|
-
appwardenApiToken:
|
|
38
|
+
appwardenApiToken: AppwardenApiTokenSchema,
|
|
39
|
+
appwardenApiHostname: z.string().optional()
|
|
37
40
|
});
|
|
38
41
|
var lockPageSlugRefinement = (schema) => schema.refine(
|
|
39
42
|
(data) => data.lockPageSlug || data.multidomainConfig,
|
|
40
43
|
{
|
|
41
|
-
message: "
|
|
44
|
+
message: "lockPageSlug must be provided"
|
|
42
45
|
}
|
|
43
46
|
);
|
|
44
47
|
|
|
@@ -46,7 +49,10 @@ var lockPageSlugRefinement = (schema) => schema.refine(
|
|
|
46
49
|
var ConfigFnInputSchema = z2.function().args(z2.custom()).returns(
|
|
47
50
|
lockPageSlugRefinement(
|
|
48
51
|
UseAppwardenInputSchema.extend({
|
|
49
|
-
middleware: z2.object({
|
|
52
|
+
middleware: z2.object({
|
|
53
|
+
before: z2.custom().array().default([]),
|
|
54
|
+
after: z2.custom().array().default([])
|
|
55
|
+
}).default({})
|
|
50
56
|
})
|
|
51
57
|
)
|
|
52
58
|
);
|
|
@@ -81,113 +87,6 @@ var renderLockPage = (context) => fetch(new URL(context.lockPageSlug, context.re
|
|
|
81
87
|
}
|
|
82
88
|
});
|
|
83
89
|
|
|
84
|
-
// src/utils/cloudflare/cloudflare-cache.ts
|
|
85
|
-
var store = {
|
|
86
|
-
json: (context, cacheKey, options) => {
|
|
87
|
-
const cacheKeyUrl = new URL(cacheKey, context.serviceOrigin);
|
|
88
|
-
return {
|
|
89
|
-
getValue: () => getCacheValue(context, cacheKeyUrl),
|
|
90
|
-
updateValue: (json) => updateCacheValue(context, cacheKeyUrl, json, options?.ttl),
|
|
91
|
-
deleteValue: () => clearCache(context, cacheKeyUrl)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var getCacheValue = async (context, cacheKey) => {
|
|
96
|
-
const match = await context.cache.match(cacheKey);
|
|
97
|
-
if (!match) {
|
|
98
|
-
debug(`[${cacheKey.pathname}] Cache MISS!`);
|
|
99
|
-
return void 0;
|
|
100
|
-
}
|
|
101
|
-
debug(`[${cacheKey.pathname}] Cache MATCH!`);
|
|
102
|
-
return match;
|
|
103
|
-
};
|
|
104
|
-
var updateCacheValue = async (context, cacheKey, value, ttl) => {
|
|
105
|
-
debug(
|
|
106
|
-
"updating cache...",
|
|
107
|
-
cacheKey.href,
|
|
108
|
-
value,
|
|
109
|
-
ttl ? `expires in ${ttl}s` : ""
|
|
110
|
-
);
|
|
111
|
-
await context.cache.put(
|
|
112
|
-
cacheKey,
|
|
113
|
-
new Response(JSON.stringify(value), {
|
|
114
|
-
headers: {
|
|
115
|
-
"content-type": "application/json",
|
|
116
|
-
...ttl && {
|
|
117
|
-
"cache-control": `max-age=${ttl}`
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
var clearCache = (context, cacheKey) => context.cache.delete(cacheKey);
|
|
124
|
-
|
|
125
|
-
// src/utils/cloudflare/delete-edge-value.ts
|
|
126
|
-
var deleteEdgeValue = async (context) => {
|
|
127
|
-
try {
|
|
128
|
-
switch (context.provider) {
|
|
129
|
-
case "cloudflare-cache": {
|
|
130
|
-
const success = await context.edgeCache.deleteValue();
|
|
131
|
-
if (!success) {
|
|
132
|
-
throw new Error();
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
default:
|
|
137
|
-
throw new Error(`Unsupported provider: ${context.provider}`);
|
|
138
|
-
}
|
|
139
|
-
} catch (e) {
|
|
140
|
-
const message = "Failed to delete edge value";
|
|
141
|
-
console.error(
|
|
142
|
-
printMessage(e instanceof Error ? `${message} - ${e.message}` : message)
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// src/utils/cloudflare/get-lock-value.ts
|
|
148
|
-
var getLockValue = async (context) => {
|
|
149
|
-
try {
|
|
150
|
-
let shouldDeleteEdgeValue = false;
|
|
151
|
-
let cacheResponse, lockValue = {
|
|
152
|
-
isLocked: 0,
|
|
153
|
-
isLockedTest: 0,
|
|
154
|
-
lastCheck: Date.now(),
|
|
155
|
-
code: ""
|
|
156
|
-
};
|
|
157
|
-
switch (context.provider) {
|
|
158
|
-
case "cloudflare-cache": {
|
|
159
|
-
cacheResponse = await context.edgeCache.getValue();
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
default:
|
|
163
|
-
throw new Error(`Unsupported provider: ${context.provider}`);
|
|
164
|
-
}
|
|
165
|
-
if (!cacheResponse) {
|
|
166
|
-
return { lockValue: void 0 };
|
|
167
|
-
}
|
|
168
|
-
try {
|
|
169
|
-
const clonedResponse = cacheResponse?.clone();
|
|
170
|
-
lockValue = LockValue.parse(
|
|
171
|
-
clonedResponse ? await clonedResponse.json() : void 0
|
|
172
|
-
);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.error(
|
|
175
|
-
printMessage(
|
|
176
|
-
`Failed to parse ${context.keyName} from edge cache - ${error}`
|
|
177
|
-
)
|
|
178
|
-
);
|
|
179
|
-
shouldDeleteEdgeValue = true;
|
|
180
|
-
}
|
|
181
|
-
return { lockValue, shouldDeleteEdgeValue };
|
|
182
|
-
} catch (e) {
|
|
183
|
-
const message = "Failed to retrieve edge value";
|
|
184
|
-
console.error(
|
|
185
|
-
printMessage(e instanceof Error ? `${message} - ${e.message}` : message)
|
|
186
|
-
);
|
|
187
|
-
return { lockValue: void 0 };
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
90
|
// src/utils/cloudflare/insert-errors-logs.ts
|
|
192
91
|
var insertErrorLogs = async (context, error) => {
|
|
193
92
|
const errors = getErrors(error);
|
|
@@ -206,88 +105,6 @@ var insertErrorLogs = async (context, error) => {
|
|
|
206
105
|
}).transform(await fetch(context.request));
|
|
207
106
|
};
|
|
208
107
|
|
|
209
|
-
// src/utils/cloudflare/sync-edge-value.ts
|
|
210
|
-
var APIError = class extends Error {
|
|
211
|
-
constructor(message) {
|
|
212
|
-
super(message);
|
|
213
|
-
this.name = "APIError";
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
var syncEdgeValue = async (context) => {
|
|
217
|
-
debug(`syncing with api`);
|
|
218
|
-
try {
|
|
219
|
-
const response = await fetch(new URL("/v1/status/check", "https://api.appwarden.io"), {
|
|
220
|
-
method: "POST",
|
|
221
|
-
headers: { "content-type": "application/json" },
|
|
222
|
-
body: JSON.stringify({
|
|
223
|
-
service: "cloudflare",
|
|
224
|
-
provider: context.provider,
|
|
225
|
-
fqdn: context.requestUrl.hostname,
|
|
226
|
-
appwardenApiToken: context.appwardenApiToken
|
|
227
|
-
})
|
|
228
|
-
});
|
|
229
|
-
if (response.status !== 200) {
|
|
230
|
-
throw new Error(`${response.status} ${response.statusText}`);
|
|
231
|
-
}
|
|
232
|
-
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
233
|
-
const result = await response.json();
|
|
234
|
-
if (result.error) {
|
|
235
|
-
throw new APIError(result.error.message);
|
|
236
|
-
}
|
|
237
|
-
if (!result.content) {
|
|
238
|
-
throw new APIError("no content from api");
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
const parsedValue = LockValue.omit({ lastCheck: true }).parse(
|
|
242
|
-
result.content
|
|
243
|
-
);
|
|
244
|
-
debug(`syncing with api...DONE ${JSON.stringify(parsedValue, null, 2)}`);
|
|
245
|
-
await context.edgeCache.updateValue({
|
|
246
|
-
...parsedValue,
|
|
247
|
-
lastCheck: Date.now()
|
|
248
|
-
});
|
|
249
|
-
} catch (error) {
|
|
250
|
-
throw new APIError(`Failed to parse check endpoint result - ${error}`);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
} catch (e) {
|
|
254
|
-
const message = "Failed to fetch from check endpoint";
|
|
255
|
-
console.error(
|
|
256
|
-
printMessage(
|
|
257
|
-
e instanceof APIError ? e.message : e instanceof Error ? `${message} - ${e.message}` : message
|
|
258
|
-
)
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
// src/handlers/maybe-quarantine.ts
|
|
264
|
-
var resolveLockValue = async (context, options) => {
|
|
265
|
-
const { lockValue, shouldDeleteEdgeValue } = await getLockValue(context);
|
|
266
|
-
if (shouldDeleteEdgeValue) {
|
|
267
|
-
await deleteEdgeValue(context);
|
|
268
|
-
}
|
|
269
|
-
if (lockValue?.isLocked || context.requestUrl.pathname === APPWARDEN_TEST_ROUTE && !MemoryCache.isTestExpired(lockValue)) {
|
|
270
|
-
await options.onLocked();
|
|
271
|
-
}
|
|
272
|
-
return lockValue;
|
|
273
|
-
};
|
|
274
|
-
var maybeQuarantine = async (context, options) => {
|
|
275
|
-
const cachedLockValue = await resolveLockValue(context, {
|
|
276
|
-
onLocked: options.onLocked
|
|
277
|
-
});
|
|
278
|
-
const shouldRecheck = MemoryCache.isExpired(cachedLockValue);
|
|
279
|
-
if (shouldRecheck) {
|
|
280
|
-
if (!cachedLockValue || cachedLockValue.isLocked) {
|
|
281
|
-
await syncEdgeValue(context);
|
|
282
|
-
await resolveLockValue(context, {
|
|
283
|
-
onLocked: options.onLocked
|
|
284
|
-
});
|
|
285
|
-
} else {
|
|
286
|
-
context.waitUntil(syncEdgeValue(context));
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
|
|
291
108
|
// src/handlers/reset-cache.ts
|
|
292
109
|
var isResetCacheRequest = (request) => request.method === "POST" && new URL(request.url).pathname === "/__appwarden/reset-cache" && request.headers.get("content-type") === "application/json";
|
|
293
110
|
var handleResetCache = async (keyName, provider, edgeCache, request) => {
|
|
@@ -324,29 +141,25 @@ var useAppwarden = (input) => async (context, next) => {
|
|
|
324
141
|
await handleResetCache(keyName, provider, edgeCache, request);
|
|
325
142
|
return;
|
|
326
143
|
}
|
|
327
|
-
|
|
328
|
-
const isMonitoringRequest = request.headers.get("User-Agent") === APPWARDEN_USER_AGENT;
|
|
329
|
-
if (isHTMLRequest && !isMonitoringRequest) {
|
|
144
|
+
if (isHTMLResponse(response)) {
|
|
330
145
|
const lockPageSlug = input.multidomainConfig?.[requestUrl.hostname]?.lockPageSlug ?? input.lockPageSlug;
|
|
331
146
|
if (!lockPageSlug) {
|
|
332
147
|
return;
|
|
333
148
|
}
|
|
334
|
-
const
|
|
335
|
-
keyName,
|
|
149
|
+
const result = await checkLockStatus({
|
|
336
150
|
request,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
provider,
|
|
151
|
+
appwardenApiToken: input.appwardenApiToken,
|
|
152
|
+
appwardenApiHostname: input.appwardenApiHostname,
|
|
340
153
|
debug: input.debug,
|
|
341
154
|
lockPageSlug,
|
|
342
|
-
appwardenApiToken: input.appwardenApiToken,
|
|
343
155
|
waitUntil: (fn) => context.waitUntil(fn)
|
|
344
|
-
};
|
|
345
|
-
await maybeQuarantine(innerContext, {
|
|
346
|
-
onLocked: async () => {
|
|
347
|
-
context.response = await renderLockPage(innerContext);
|
|
348
|
-
}
|
|
349
156
|
});
|
|
157
|
+
if (result.isLocked) {
|
|
158
|
+
context.response = await renderLockPage({
|
|
159
|
+
lockPageSlug,
|
|
160
|
+
requestUrl
|
|
161
|
+
});
|
|
162
|
+
}
|
|
350
163
|
}
|
|
351
164
|
} catch (e) {
|
|
352
165
|
const message = "Appwarden encountered an unknown error. Please contact Appwarden support at https://appwarden.io/join-community.";
|
|
@@ -401,8 +214,8 @@ var appwardenOnCloudflare = (inputFn) => async (request, env, ctx) => {
|
|
|
401
214
|
};
|
|
402
215
|
|
|
403
216
|
// src/bundles/cloudflare.ts
|
|
404
|
-
var
|
|
217
|
+
var createAppwardenMiddleware = appwardenOnCloudflare;
|
|
405
218
|
export {
|
|
406
|
-
|
|
407
|
-
|
|
219
|
+
createAppwardenMiddleware,
|
|
220
|
+
useContentSecurityPolicy
|
|
408
221
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
export { B as Bindings } from './
|
|
2
|
-
export { C as CSPDirectivesSchema, a as CSPModeSchema, M as Middleware, u as useContentSecurityPolicy } from './use-content-security-policy-Cgy0nz3J.js';
|
|
1
|
+
export { B as Bindings, C as CSPDirectivesSchema, a as CSPModeSchema, M as Middleware, u as useContentSecurityPolicy } from './use-content-security-policy-Bh2qDCKv.js';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
|
|
5
4
|
declare const LOCKDOWN_TEST_EXPIRY_MS: number;
|
|
6
|
-
declare const APPWARDEN_USER_AGENT: "Appwarden-Monitor";
|
|
7
5
|
declare const APPWARDEN_CACHE_KEY: "appwarden-lock";
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -65,4 +63,4 @@ declare const LockValue: z.ZodObject<{
|
|
|
65
63
|
}>;
|
|
66
64
|
type LockValueType = z.infer<typeof LockValue>;
|
|
67
65
|
|
|
68
|
-
export { APPWARDEN_CACHE_KEY,
|
|
66
|
+
export { APPWARDEN_CACHE_KEY, LOCKDOWN_TEST_EXPIRY_MS, type LockValueType, getEdgeConfigId, isCacheUrl, isValidCacheUrl };
|
package/index.js
CHANGED
|
@@ -7,15 +7,13 @@ import {
|
|
|
7
7
|
CSPDirectivesSchema,
|
|
8
8
|
CSPModeSchema,
|
|
9
9
|
useContentSecurityPolicy
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MOTPEQEU.js";
|
|
11
11
|
import {
|
|
12
12
|
APPWARDEN_CACHE_KEY,
|
|
13
|
-
APPWARDEN_USER_AGENT,
|
|
14
13
|
LOCKDOWN_TEST_EXPIRY_MS
|
|
15
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-7UTT3M2S.js";
|
|
16
15
|
export {
|
|
17
16
|
APPWARDEN_CACHE_KEY,
|
|
18
|
-
APPWARDEN_USER_AGENT,
|
|
19
17
|
CSPDirectivesSchema,
|
|
20
18
|
CSPModeSchema,
|
|
21
19
|
LOCKDOWN_TEST_EXPIRY_MS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appwarden/middleware",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Instantly shut off access your app deployed on Cloudflare or Vercel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,6 +35,22 @@
|
|
|
35
35
|
"./cloudflare": {
|
|
36
36
|
"types": "./cloudflare.d.ts",
|
|
37
37
|
"default": "./cloudflare.js"
|
|
38
|
+
},
|
|
39
|
+
"./cloudflare/astro": {
|
|
40
|
+
"types": "./cloudflare/astro.d.ts",
|
|
41
|
+
"default": "./cloudflare/astro.js"
|
|
42
|
+
},
|
|
43
|
+
"./cloudflare/react-router": {
|
|
44
|
+
"types": "./cloudflare/react-router.d.ts",
|
|
45
|
+
"default": "./cloudflare/react-router.js"
|
|
46
|
+
},
|
|
47
|
+
"./cloudflare/tanstack-start": {
|
|
48
|
+
"types": "./cloudflare/tanstack-start.d.ts",
|
|
49
|
+
"default": "./cloudflare/tanstack-start.js"
|
|
50
|
+
},
|
|
51
|
+
"./cloudflare/nextjs": {
|
|
52
|
+
"types": "./cloudflare/nextjs.d.ts",
|
|
53
|
+
"default": "./cloudflare/nextjs.js"
|
|
38
54
|
}
|
|
39
55
|
},
|
|
40
56
|
"packageManager": "pnpm@10.4.1",
|
|
@@ -42,17 +58,25 @@
|
|
|
42
58
|
"node": ">=24"
|
|
43
59
|
},
|
|
44
60
|
"dependencies": {
|
|
45
|
-
"@cloudflare/next-on-pages": "1.13.
|
|
46
|
-
"@upstash/redis": "^1.36.
|
|
61
|
+
"@cloudflare/next-on-pages": "^1.13.16",
|
|
62
|
+
"@upstash/redis": "^1.36.2",
|
|
47
63
|
"@vercel/edge-config": "^1.4.3",
|
|
48
64
|
"zod": "^3.25.76"
|
|
49
65
|
},
|
|
50
66
|
"peerDependencies": {
|
|
67
|
+
"@opennextjs/cloudflare": ">=1.0.0",
|
|
68
|
+
"@vercel/functions": ">=1.0.0",
|
|
51
69
|
"next": ">=14"
|
|
52
70
|
},
|
|
53
71
|
"peerDependenciesMeta": {
|
|
54
72
|
"next": {
|
|
55
73
|
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"@opennextjs/cloudflare": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"@vercel/functions": {
|
|
79
|
+
"optional": true
|
|
56
80
|
}
|
|
57
81
|
},
|
|
58
82
|
"lint-staged": {
|
|
@@ -68,7 +92,10 @@
|
|
|
68
92
|
"tar@<7.5.7": ">=7.5.7",
|
|
69
93
|
"undici@<6.23.0": ">=6.23.0",
|
|
70
94
|
"body-parser@>=2.2.0 <2.2.1": ">=2.2.1",
|
|
71
|
-
"jws@=4.0.0": ">=4.0.1"
|
|
95
|
+
"jws@=4.0.0": ">=4.0.1",
|
|
96
|
+
"@smithy/config-resolver@<4.4.0": ">=4.4.0",
|
|
97
|
+
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1",
|
|
98
|
+
"npm@<=11.8.0": ">=11.9.0"
|
|
72
99
|
}
|
|
73
100
|
}
|
|
74
101
|
}
|
package/{use-content-security-policy-Cgy0nz3J.d.ts → use-content-security-policy-Bh2qDCKv.d.ts}
RENAMED
|
@@ -1,6 +1,102 @@
|
|
|
1
|
-
import './cloudflare-2PkEr25r.js';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
|
|
3
|
+
declare const ContentSecurityPolicySchema: z.ZodObject<{
|
|
4
|
+
"default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
5
|
+
"script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
6
|
+
"style-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
7
|
+
"img-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
8
|
+
"connect-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
9
|
+
"font-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
10
|
+
"object-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
11
|
+
"media-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
12
|
+
"frame-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
13
|
+
sandbox: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
14
|
+
"report-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
15
|
+
"child-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
16
|
+
"form-action": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
17
|
+
"frame-ancestors": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
18
|
+
"plugin-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
19
|
+
"base-uri": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
20
|
+
"report-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
21
|
+
"worker-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
22
|
+
"manifest-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
23
|
+
"prefetch-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
24
|
+
"navigate-to": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
25
|
+
"require-sri-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
26
|
+
"block-all-mixed-content": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
27
|
+
"upgrade-insecure-requests": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
28
|
+
"trusted-types": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
29
|
+
"require-trusted-types-for": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
32
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
33
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
34
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
35
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
36
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
37
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
38
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
39
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
40
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
41
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
42
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
43
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
44
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
45
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
46
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
47
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
48
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
49
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
50
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
51
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
52
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
53
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
54
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
55
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
56
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
"default-src"?: string | boolean | string[] | undefined;
|
|
59
|
+
"script-src"?: string | boolean | string[] | undefined;
|
|
60
|
+
"style-src"?: string | boolean | string[] | undefined;
|
|
61
|
+
"img-src"?: string | boolean | string[] | undefined;
|
|
62
|
+
"connect-src"?: string | boolean | string[] | undefined;
|
|
63
|
+
"font-src"?: string | boolean | string[] | undefined;
|
|
64
|
+
"object-src"?: string | boolean | string[] | undefined;
|
|
65
|
+
"media-src"?: string | boolean | string[] | undefined;
|
|
66
|
+
"frame-src"?: string | boolean | string[] | undefined;
|
|
67
|
+
sandbox?: string | boolean | string[] | undefined;
|
|
68
|
+
"report-uri"?: string | boolean | string[] | undefined;
|
|
69
|
+
"child-src"?: string | boolean | string[] | undefined;
|
|
70
|
+
"form-action"?: string | boolean | string[] | undefined;
|
|
71
|
+
"frame-ancestors"?: string | boolean | string[] | undefined;
|
|
72
|
+
"plugin-types"?: string | boolean | string[] | undefined;
|
|
73
|
+
"base-uri"?: string | boolean | string[] | undefined;
|
|
74
|
+
"report-to"?: string | boolean | string[] | undefined;
|
|
75
|
+
"worker-src"?: string | boolean | string[] | undefined;
|
|
76
|
+
"manifest-src"?: string | boolean | string[] | undefined;
|
|
77
|
+
"prefetch-src"?: string | boolean | string[] | undefined;
|
|
78
|
+
"navigate-to"?: string | boolean | string[] | undefined;
|
|
79
|
+
"require-sri-for"?: string | boolean | string[] | undefined;
|
|
80
|
+
"block-all-mixed-content"?: string | boolean | string[] | undefined;
|
|
81
|
+
"upgrade-insecure-requests"?: string | boolean | string[] | undefined;
|
|
82
|
+
"trusted-types"?: string | boolean | string[] | undefined;
|
|
83
|
+
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
type ContentSecurityPolicyType = z.infer<typeof ContentSecurityPolicySchema>;
|
|
86
|
+
|
|
87
|
+
declare global {
|
|
88
|
+
interface CloudflareEnv extends Bindings {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
type Bindings = {
|
|
92
|
+
DEBUG: string | boolean;
|
|
93
|
+
LOCK_PAGE_SLUG: string;
|
|
94
|
+
CSP_MODE: "disabled" | "report-only" | "enforced";
|
|
95
|
+
CSP_DIRECTIVES: string | ContentSecurityPolicyType;
|
|
96
|
+
APPWARDEN_API_TOKEN: string;
|
|
97
|
+
APPWARDEN_API_HOSTNAME?: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
4
100
|
interface MiddlewareContext {
|
|
5
101
|
hostname: string;
|
|
6
102
|
request: Request;
|
|
@@ -416,4 +512,4 @@ type UseCSPInput = z.infer<typeof UseCSPInputSchema>;
|
|
|
416
512
|
|
|
417
513
|
declare const useContentSecurityPolicy: (input: UseCSPInput) => Middleware;
|
|
418
514
|
|
|
419
|
-
export { CSPDirectivesSchema as C, type Middleware as M, CSPModeSchema as a, useContentSecurityPolicy as u };
|
|
515
|
+
export { type Bindings as B, CSPDirectivesSchema as C, type Middleware as M, CSPModeSchema as a, useContentSecurityPolicy as u };
|
package/vercel.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import * as next_dist_server_web_types from 'next/dist/server/web/types';
|
|
2
|
-
import * as next_server from 'next/server';
|
|
3
|
-
import './cloudflare-2PkEr25r.js';
|
|
4
1
|
import { z } from 'zod';
|
|
5
2
|
|
|
6
|
-
declare const
|
|
3
|
+
declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
7
4
|
cacheUrl: z.ZodString;
|
|
8
5
|
appwardenApiToken: z.ZodString;
|
|
9
6
|
vercelApiToken: z.ZodOptional<z.ZodString>;
|
|
@@ -18,9 +15,50 @@ declare const BaseNextJsConfigSchema: z.ZodObject<{
|
|
|
18
15
|
cacheUrl: string;
|
|
19
16
|
lockPageSlug?: string | undefined;
|
|
20
17
|
vercelApiToken?: string | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
lockPageSlug: string;
|
|
20
|
+
appwardenApiToken: string;
|
|
21
|
+
cacheUrl: string;
|
|
22
|
+
vercelApiToken?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
appwardenApiToken: string;
|
|
25
|
+
cacheUrl: string;
|
|
26
|
+
lockPageSlug?: string | undefined;
|
|
27
|
+
vercelApiToken?: string | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
lockPageSlug: string;
|
|
30
|
+
appwardenApiToken: string;
|
|
31
|
+
cacheUrl: string;
|
|
32
|
+
vercelApiToken?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
appwardenApiToken: string;
|
|
35
|
+
cacheUrl: string;
|
|
36
|
+
lockPageSlug?: string | undefined;
|
|
37
|
+
vercelApiToken?: string | undefined;
|
|
38
|
+
}>, {
|
|
39
|
+
lockPageSlug: string;
|
|
40
|
+
appwardenApiToken: string;
|
|
41
|
+
cacheUrl: string;
|
|
42
|
+
vercelApiToken?: string | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
appwardenApiToken: string;
|
|
45
|
+
cacheUrl: string;
|
|
46
|
+
lockPageSlug?: string | undefined;
|
|
47
|
+
vercelApiToken?: string | undefined;
|
|
48
|
+
}>, {
|
|
49
|
+
lockPageSlug: string;
|
|
50
|
+
appwardenApiToken: string;
|
|
51
|
+
cacheUrl: string;
|
|
52
|
+
vercelApiToken?: string | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
appwardenApiToken: string;
|
|
55
|
+
cacheUrl: string;
|
|
56
|
+
lockPageSlug?: string | undefined;
|
|
57
|
+
vercelApiToken?: string | undefined;
|
|
21
58
|
}>;
|
|
22
|
-
type
|
|
59
|
+
type VercelAppwardenConfig = z.input<typeof AppwardenConfigSchema>;
|
|
23
60
|
|
|
24
|
-
|
|
61
|
+
type VercelMiddlewareFunction = (request: Request) => Promise<Response>;
|
|
62
|
+
declare function createAppwardenMiddleware(config: VercelAppwardenConfig): VercelMiddlewareFunction;
|
|
25
63
|
|
|
26
|
-
export {
|
|
64
|
+
export { AppwardenConfigSchema, type VercelAppwardenConfig, type VercelMiddlewareFunction, createAppwardenMiddleware };
|