@appwarden/middleware 3.9.1 → 3.10.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
@@ -143,7 +143,7 @@ import { sequence } from "astro:middleware"
143
143
  import { createAppwardenMiddleware } from "@appwarden/middleware/cloudflare/astro"
144
144
 
145
145
  const appwarden = createAppwardenMiddleware((cloudflare) => ({
146
- lockPageSlug: cloudflare.env.APPWARDEN_LOCK_PAGE_SLUG,
146
+ lockPageSlug: cloudflare.env.LOCK_PAGE_SLUG,
147
147
  appwardenApiToken: cloudflare.env.APPWARDEN_API_TOKEN,
148
148
  debug: cloudflare.env.DEBUG,
149
149
  contentSecurityPolicy: {
@@ -230,7 +230,7 @@ export const config = {
230
230
  }
231
231
 
232
232
  export default createAppwardenMiddleware((cloudflare) => ({
233
- lockPageSlug: cloudflare.env.APPWARDEN_LOCK_PAGE_SLUG,
233
+ lockPageSlug: cloudflare.env.LOCK_PAGE_SLUG,
234
234
  appwardenApiToken: cloudflare.env.APPWARDEN_API_TOKEN,
235
235
  debug: cloudflare.env.DEBUG,
236
236
  // Headers-only CSP (no HTML rewriting, no nonce support; do not use `{{nonce}}` here)
@@ -386,7 +386,7 @@ type AstroConfigFn = (runtime: AstroCloudflareRuntime) => AstroCloudflareConfigI
386
386
  * import { createAppwardenMiddleware } from "@appwarden/middleware/astro"
387
387
  *
388
388
  * const appwarden = createAppwardenMiddleware(({ env }) => ({
389
- * lockPageSlug: env.APPWARDEN_LOCK_PAGE_SLUG,
389
+ * lockPageSlug: env.LOCK_PAGE_SLUG,
390
390
  * appwardenApiToken: env.APPWARDEN_API_TOKEN,
391
391
  * }))
392
392
  *
@@ -454,7 +454,7 @@ type NextJsMiddlewareFunction = (request: NextRequest, event?: NextFetchEvent) =
454
454
  * }
455
455
  *
456
456
  * export default createAppwardenMiddleware(({ env }) => ({
457
- * lockPageSlug: env.APPWARDEN_LOCK_PAGE_SLUG,
457
+ * lockPageSlug: env.LOCK_PAGE_SLUG,
458
458
  * appwardenApiToken: env.APPWARDEN_API_TOKEN,
459
459
  * }))
460
460
  * ```
@@ -381,7 +381,7 @@ type ReactRouterMiddlewareFunction = (args: ReactRouterMiddlewareArgs, next: ()
381
381
  *
382
382
  * export const unstable_middleware = [
383
383
  * createAppwardenMiddleware(() => ({
384
- * lockPageSlug: env.APPWARDEN_LOCK_PAGE_SLUG,
384
+ * lockPageSlug: env.LOCK_PAGE_SLUG,
385
385
  * appwardenApiToken: env.APPWARDEN_API_TOKEN,
386
386
  * })),
387
387
  * ]
package/cloudflare.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as Bindings } from './use-content-security-policy-jlU0Hjj8.js';
2
- export { u as useContentSecurityPolicy } from './use-content-security-policy-jlU0Hjj8.js';
1
+ import { B as Bindings } from './use-content-security-policy-UMl4Biie.js';
2
+ export { u as useContentSecurityPolicy } from './use-content-security-policy-UMl4Biie.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-jlU0Hjj8.js';
1
+ export { B as Bindings, C as CSPDirectivesSchema, a as CSPModeSchema, M as Middleware, u as useContentSecurityPolicy } from './use-content-security-policy-UMl4Biie.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.9.1",
3
+ "version": "3.10.0",
4
4
  "description": "Instantly disable all user interaction with your app deployed on Cloudflare or Vercel",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -84,16 +84,41 @@ declare const ContentSecurityPolicySchema: z.ZodObject<{
84
84
  }>;
85
85
  type ContentSecurityPolicyType = z.infer<typeof ContentSecurityPolicySchema>;
86
86
 
87
+ /**
88
+ * Fallback bindings type for when Wrangler types are not available.
89
+ * This provides a minimal type definition for development.
90
+ *
91
+ * When users run `wrangler types`, it generates:
92
+ * - `declare namespace Cloudflare { interface Env { ... } }`
93
+ * - `interface Env extends Cloudflare.Env {}`
94
+ *
95
+ * Our CloudflareEnv should pick up the user's generated Env type first.
96
+ */
87
97
  type Bindings = {
88
- DEBUG: string | boolean;
89
- LOCK_PAGE_SLUG: string;
90
- CSP_MODE: "disabled" | "report-only" | "enforced";
91
- CSP_DIRECTIVES: string | ContentSecurityPolicyType;
92
- APPWARDEN_API_TOKEN: string;
98
+ DEBUG?: string | boolean;
99
+ LOCK_PAGE_SLUG?: string;
100
+ CSP_MODE?: "disabled" | "report-only" | "enforced";
101
+ CSP_DIRECTIVES?: string | ContentSecurityPolicyType;
102
+ APPWARDEN_API_TOKEN?: string;
93
103
  APPWARDEN_API_HOSTNAME?: string;
94
104
  };
95
105
  declare global {
96
- interface CloudflareEnv extends Bindings {
106
+ /**
107
+ * CloudflareEnv is the global type used by all adapters.
108
+ *
109
+ * TypeScript's declaration merging means:
110
+ * 1. If user has Wrangler-generated `interface Env`, CloudflareEnv will extend it
111
+ * 2. If not, CloudflareEnv will extend our fallback Bindings type
112
+ *
113
+ * This ensures Wrangler types take precedence when available.
114
+ */
115
+ interface CloudflareEnv extends Env {
116
+ }
117
+ /**
118
+ * Fallback Env interface when Wrangler types are not generated.
119
+ * If the user runs `wrangler types`, their generated Env will merge with this.
120
+ */
121
+ interface Env extends Bindings {
97
122
  }
98
123
  }
99
124