@appwarden/middleware 1.6.0 → 3.0.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @appwarden/middleware
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
[](https://www.npmjs.com/package/@appwarden/middleware)
|
|
5
5
|
[](https://docs.npmjs.com/generating-provenance-statements)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
package/cloudflare/astro.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { Runtime } from '@astrojs/cloudflare';
|
|
2
|
+
import { APIContext, MiddlewareHandler } from 'astro';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Cloudflare runtime context provided by Astro on Cloudflare Workers.
|
|
3
|
-
* This is
|
|
6
|
+
* This is extracted from the locals object when using @astrojs/cloudflare adapter.
|
|
7
|
+
*
|
|
8
|
+
* Note: Uses generic CloudflareEnv which should be defined in the user's project.
|
|
4
9
|
*/
|
|
5
|
-
|
|
6
|
-
env: CloudflareEnv;
|
|
7
|
-
ctx: ExecutionContext;
|
|
8
|
-
}
|
|
10
|
+
type AstroCloudflareRuntime = Runtime<CloudflareEnv>["runtime"];
|
|
9
11
|
/**
|
|
10
12
|
* Configuration for the Appwarden middleware.
|
|
11
13
|
*/
|
|
@@ -26,24 +28,18 @@ interface AstroAppwardenConfig {
|
|
|
26
28
|
type AstroConfigFn = (runtime: AstroCloudflareRuntime) => AstroAppwardenConfig;
|
|
27
29
|
/**
|
|
28
30
|
* Astro middleware context type.
|
|
29
|
-
*
|
|
31
|
+
* Re-exported from Astro's official APIContext type for type compatibility.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Use `APIContext` from 'astro' directly. This alias is kept for backward compatibility.
|
|
30
34
|
*/
|
|
31
|
-
|
|
32
|
-
/** The incoming request */
|
|
33
|
-
request: Request;
|
|
34
|
-
/** Object for storing request-specific data */
|
|
35
|
-
locals: {
|
|
36
|
-
runtime?: AstroCloudflareRuntime;
|
|
37
|
-
[key: string]: unknown;
|
|
38
|
-
};
|
|
39
|
-
/** Helper to create redirect responses */
|
|
40
|
-
redirect: (path: string, status?: number) => Response;
|
|
41
|
-
}
|
|
35
|
+
type AstroMiddlewareContext = APIContext;
|
|
42
36
|
/**
|
|
43
37
|
* Astro middleware function signature.
|
|
44
|
-
* This
|
|
38
|
+
* This is an alias for Astro's official MiddlewareHandler type for type compatibility.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Use `MiddlewareHandler` from 'astro' directly. This alias is kept for backward compatibility.
|
|
45
41
|
*/
|
|
46
|
-
type AstroMiddlewareFunction =
|
|
42
|
+
type AstroMiddlewareFunction = MiddlewareHandler;
|
|
47
43
|
/**
|
|
48
44
|
* Creates an Appwarden middleware function for Astro.
|
|
49
45
|
*
|
|
@@ -67,6 +63,6 @@ type AstroMiddlewareFunction = (context: AstroMiddlewareContext, next: () => Pro
|
|
|
67
63
|
* @param configFn - A function that receives the Cloudflare runtime and returns the config
|
|
68
64
|
* @returns An Astro middleware function
|
|
69
65
|
*/
|
|
70
|
-
declare function createAppwardenMiddleware(configFn: AstroConfigFn):
|
|
66
|
+
declare function createAppwardenMiddleware(configFn: AstroConfigFn): MiddlewareHandler;
|
|
71
67
|
|
|
72
68
|
export { type AstroAppwardenConfig, type AstroCloudflareRuntime, type AstroConfigFn, type AstroMiddlewareContext, type AstroMiddlewareFunction, createAppwardenMiddleware };
|
package/cloudflare/astro.js
CHANGED
|
@@ -34,7 +34,8 @@ var AstroCloudflareConfigSchema = z.object({
|
|
|
34
34
|
// src/adapters/astro-cloudflare.ts
|
|
35
35
|
function createAppwardenMiddleware(configFn) {
|
|
36
36
|
return async (context, next) => {
|
|
37
|
-
const { request
|
|
37
|
+
const { request } = context;
|
|
38
|
+
const locals = context.locals;
|
|
38
39
|
try {
|
|
39
40
|
const runtime = locals.runtime;
|
|
40
41
|
if (!runtime) {
|
package/cloudflare.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Middleware, B as Bindings } from './use-content-security-policy-
|
|
2
|
-
export { u as useContentSecurityPolicy } from './use-content-security-policy-
|
|
1
|
+
import { M as Middleware, B as Bindings } from './use-content-security-policy-DjRTjIpm.js';
|
|
2
|
+
export { u as useContentSecurityPolicy } from './use-content-security-policy-DjRTjIpm.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
declare const UseAppwardenInputSchema: z.ZodObject<{
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as Bindings, C as CSPDirectivesSchema, a as CSPModeSchema, M as Middleware, u as useContentSecurityPolicy } from './use-content-security-policy-
|
|
1
|
+
export { B as Bindings, C as CSPDirectivesSchema, a as CSPModeSchema, M as Middleware, u as useContentSecurityPolicy } from './use-content-security-policy-DjRTjIpm.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const LOCKDOWN_TEST_EXPIRY_MS: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appwarden/middleware",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Instantly shut off access your app deployed on Cloudflare or Vercel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,17 +58,24 @@
|
|
|
58
58
|
"node": ">=24"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cloudflare/next-on-pages": "^1.13.16",
|
|
62
61
|
"@upstash/redis": "^1.36.2",
|
|
63
62
|
"@vercel/edge-config": "^1.4.3",
|
|
64
63
|
"zod": "^3.25.76"
|
|
65
64
|
},
|
|
66
65
|
"peerDependencies": {
|
|
66
|
+
"@astrojs/cloudflare": ">=11.0.0",
|
|
67
67
|
"@opennextjs/cloudflare": ">=1.0.0",
|
|
68
68
|
"@vercel/functions": ">=1.0.0",
|
|
69
|
+
"astro": ">=4.0.0",
|
|
69
70
|
"next": ">=14"
|
|
70
71
|
},
|
|
71
72
|
"peerDependenciesMeta": {
|
|
73
|
+
"astro": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@astrojs/cloudflare": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
72
79
|
"next": {
|
|
73
80
|
"optional": true
|
|
74
81
|
},
|
|
@@ -95,7 +102,8 @@
|
|
|
95
102
|
"jws@=4.0.0": ">=4.0.1",
|
|
96
103
|
"@smithy/config-resolver@<4.4.0": ">=4.4.0",
|
|
97
104
|
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1",
|
|
98
|
-
"npm@<=11.8.0": ">=11.9.0"
|
|
105
|
+
"npm@<=11.8.0": ">=11.9.0",
|
|
106
|
+
"wrangler@>=4.0.0 <4.59.1": ">=4.59.1"
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
109
|
}
|
package/{use-content-security-policy-Bh2qDCKv.d.ts → use-content-security-policy-DjRTjIpm.d.ts}
RENAMED
|
@@ -84,10 +84,6 @@ declare const ContentSecurityPolicySchema: z.ZodObject<{
|
|
|
84
84
|
}>;
|
|
85
85
|
type ContentSecurityPolicyType = z.infer<typeof ContentSecurityPolicySchema>;
|
|
86
86
|
|
|
87
|
-
declare global {
|
|
88
|
-
interface CloudflareEnv extends Bindings {
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
87
|
type Bindings = {
|
|
92
88
|
DEBUG: string | boolean;
|
|
93
89
|
LOCK_PAGE_SLUG: string;
|
|
@@ -96,6 +92,10 @@ type Bindings = {
|
|
|
96
92
|
APPWARDEN_API_TOKEN: string;
|
|
97
93
|
APPWARDEN_API_HOSTNAME?: string;
|
|
98
94
|
};
|
|
95
|
+
declare global {
|
|
96
|
+
interface CloudflareEnv extends Bindings {
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
99
|
|
|
100
100
|
interface MiddlewareContext {
|
|
101
101
|
hostname: string;
|