@appwarden/middleware 3.11.1 → 3.11.2

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
@@ -4,7 +4,7 @@
4
4
  [![GitHub](https://img.shields.io/badge/GitHub-appwarden%2Fmiddleware-181717?logo=github&logoColor=white)](https://github.com/appwarden/middleware)
5
5
  [![npm version](https://img.shields.io/npm/v/@appwarden/middleware.svg)](https://www.npmjs.com/package/@appwarden/middleware)
6
6
  [![npm provenance](https://img.shields.io/badge/npm-provenance-green)](https://docs.npmjs.com/generating-provenance-statements)
7
- ![Test Coverage](https://img.shields.io/badge/coverage-93.04%25-brightgreen)
7
+ ![Test Coverage](https://img.shields.io/badge/coverage-93.05%25-brightgreen)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
9
 
10
10
  ## Core Features
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-2WPLLVUI.js";
4
4
  import {
5
5
  printMessage
6
- } from "./chunk-QUVGY2YI.js";
6
+ } from "./chunk-ASH6UZ27.js";
7
7
 
8
8
  // src/utils/build-lock-page-url.ts
9
9
  function normalizeLockPageSlug(lockPageSlug) {
@@ -113,6 +113,11 @@ var BooleanSchema = BoolOrStringSchema.transform((val) => {
113
113
  throw new Error("Invalid value");
114
114
  });
115
115
  var AppwardenApiTokenSchema = z.string().refine((val) => !!val, { message: "appwardenApiToken is required" });
116
+ var AppwardenApiHostnameSchema = z.string().url({
117
+ message: "Invalid `appwardenApiHostname`. Please provide an absolute URL (e.g. https://api.appwarden.io)."
118
+ }).refine((value) => value.startsWith("https://"), {
119
+ message: "`appwardenApiHostname` must use the https:// scheme (e.g. https://api.appwarden.io)."
120
+ });
116
121
  var LockValue = z.object({
117
122
  isLocked: z.number(),
118
123
  isLockedTest: z.number(),
@@ -306,6 +311,7 @@ export {
306
311
  getErrors,
307
312
  BooleanSchema,
308
313
  AppwardenApiTokenSchema,
314
+ AppwardenApiHostnameSchema,
309
315
  LockValue,
310
316
  store,
311
317
  CSP_KEYWORDS,
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-2WPLLVUI.js";
5
5
  import {
6
6
  makeCSPHeader
7
- } from "./chunk-QUVGY2YI.js";
7
+ } from "./chunk-ASH6UZ27.js";
8
8
 
9
9
  // src/middlewares/use-content-security-policy.ts
10
10
  var AppendAttribute = (attribute, nonce) => ({
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MemoryCache,
3
3
  debug
4
- } from "./chunk-KE2UVIYR.js";
4
+ } from "./chunk-6JYUNSUJ.js";
5
5
  import {
6
6
  APPWARDEN_CACHE_KEY,
7
7
  APPWARDEN_TEST_ROUTE
@@ -11,7 +11,7 @@ import {
11
11
  getLockValue,
12
12
  store,
13
13
  syncEdgeValue
14
- } from "./chunk-QUVGY2YI.js";
14
+ } from "./chunk-ASH6UZ27.js";
15
15
 
16
16
  // src/core/check-lock-status.ts
17
17
  var createContext = async (config) => {
@@ -12,7 +12,7 @@ declare const AstroCloudflareConfigSchema: z.ZodObject<{
12
12
  /** The Appwarden API token for authentication */
13
13
  appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
14
14
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
15
- appwardenApiHostname: z.ZodOptional<z.ZodString>;
15
+ appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
16
16
  /** Enable debug logging */
17
17
  debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
18
18
  /** Optional Content Security Policy configuration */
@@ -3,29 +3,30 @@ import {
3
3
  } from "../chunk-XFG6SUSV.js";
4
4
  import {
5
5
  useContentSecurityPolicy
6
- } from "../chunk-K7ZIT3FM.js";
6
+ } from "../chunk-RQLMO5FA.js";
7
7
  import {
8
8
  getNowMs
9
9
  } from "../chunk-X7WZVYQS.js";
10
10
  import {
11
11
  checkLockStatus
12
- } from "../chunk-ZOYE6D3A.js";
12
+ } from "../chunk-VQIRZMED.js";
13
13
  import {
14
14
  TEMPORARY_REDIRECT_STATUS,
15
15
  buildLockPageUrl,
16
16
  createRedirect,
17
17
  debug,
18
18
  isOnLockPage
19
- } from "../chunk-KE2UVIYR.js";
19
+ } from "../chunk-6JYUNSUJ.js";
20
20
  import {
21
21
  UseCSPInputSchema,
22
22
  isHTMLRequest
23
23
  } from "../chunk-2WPLLVUI.js";
24
24
  import {
25
+ AppwardenApiHostnameSchema,
25
26
  AppwardenApiTokenSchema,
26
27
  BooleanSchema,
27
28
  printMessage
28
- } from "../chunk-QUVGY2YI.js";
29
+ } from "../chunk-ASH6UZ27.js";
29
30
 
30
31
  // src/adapters/astro-cloudflare.ts
31
32
  import { waitUntil } from "cloudflare:workers";
@@ -38,7 +39,7 @@ var AstroCloudflareConfigSchema = z.object({
38
39
  /** The Appwarden API token for authentication */
39
40
  appwardenApiToken: AppwardenApiTokenSchema,
40
41
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
41
- appwardenApiHostname: z.string().optional(),
42
+ appwardenApiHostname: AppwardenApiHostnameSchema.optional(),
42
43
  /** Enable debug logging */
43
44
  debug: BooleanSchema.default(false),
44
45
  /** Optional Content Security Policy configuration */
@@ -11,7 +11,7 @@ declare const NextJsCloudflareConfigSchema: z.ZodObject<{
11
11
  /** The Appwarden API token for authentication */
12
12
  appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
13
13
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
14
- appwardenApiHostname: z.ZodOptional<z.ZodString>;
14
+ appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
15
15
  /** Enable debug logging */
16
16
  debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
17
17
  /** Optional Content Security Policy configuration (headers only, no HTML rewriting; '{{nonce}}' is not supported) */
@@ -3,22 +3,23 @@ import {
3
3
  } from "../chunk-X7WZVYQS.js";
4
4
  import {
5
5
  checkLockStatus
6
- } from "../chunk-ZOYE6D3A.js";
6
+ } from "../chunk-VQIRZMED.js";
7
7
  import {
8
8
  TEMPORARY_REDIRECT_STATUS,
9
9
  buildLockPageUrl,
10
10
  debug,
11
11
  isOnLockPage
12
- } from "../chunk-KE2UVIYR.js";
12
+ } from "../chunk-6JYUNSUJ.js";
13
13
  import {
14
14
  UseCSPInputSchema,
15
15
  isHTMLRequest
16
16
  } from "../chunk-2WPLLVUI.js";
17
17
  import {
18
+ AppwardenApiHostnameSchema,
18
19
  AppwardenApiTokenSchema,
19
20
  BooleanSchema,
20
21
  printMessage
21
- } from "../chunk-QUVGY2YI.js";
22
+ } from "../chunk-ASH6UZ27.js";
22
23
 
23
24
  // src/adapters/nextjs-cloudflare.ts
24
25
  import {
@@ -44,7 +45,7 @@ var NextJsCloudflareConfigSchema = z.object({
44
45
  /** The Appwarden API token for authentication */
45
46
  appwardenApiToken: AppwardenApiTokenSchema,
46
47
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
47
- appwardenApiHostname: z.string().optional(),
48
+ appwardenApiHostname: AppwardenApiHostnameSchema.optional(),
48
49
  /** Enable debug logging */
49
50
  debug: BooleanSchema.default(false),
50
51
  /** Optional Content Security Policy configuration (headers only, no HTML rewriting; '{{nonce}}' is not supported) */
@@ -101,7 +102,7 @@ function createAppwardenMiddleware(configFn) {
101
102
  debugFn(
102
103
  `Applying CSP headers in ${config.contentSecurityPolicy.mode} mode`
103
104
  );
104
- const { makeCSPHeader } = await import("../cloudflare-JVRRPVRP.js");
105
+ const { makeCSPHeader } = await import("../cloudflare-TJXWELMX.js");
105
106
  const [headerName, headerValue] = makeCSPHeader(
106
107
  "",
107
108
  config.contentSecurityPolicy.directives,
@@ -10,7 +10,7 @@ declare const ReactRouterCloudflareConfigSchema: z.ZodObject<{
10
10
  /** The Appwarden API token for authentication */
11
11
  appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
12
12
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
13
- appwardenApiHostname: z.ZodOptional<z.ZodString>;
13
+ appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
14
14
  /** Enable debug logging */
15
15
  debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
16
16
  /** Optional Content Security Policy configuration */
@@ -3,28 +3,29 @@ import {
3
3
  } from "../chunk-XFG6SUSV.js";
4
4
  import {
5
5
  useContentSecurityPolicy
6
- } from "../chunk-K7ZIT3FM.js";
6
+ } from "../chunk-RQLMO5FA.js";
7
7
  import {
8
8
  getNowMs
9
9
  } from "../chunk-X7WZVYQS.js";
10
10
  import {
11
11
  checkLockStatus
12
- } from "../chunk-ZOYE6D3A.js";
12
+ } from "../chunk-VQIRZMED.js";
13
13
  import {
14
14
  buildLockPageUrl,
15
15
  createRedirect,
16
16
  debug,
17
17
  isOnLockPage
18
- } from "../chunk-KE2UVIYR.js";
18
+ } from "../chunk-6JYUNSUJ.js";
19
19
  import {
20
20
  UseCSPInputSchema,
21
21
  isHTMLRequest
22
22
  } from "../chunk-2WPLLVUI.js";
23
23
  import {
24
+ AppwardenApiHostnameSchema,
24
25
  AppwardenApiTokenSchema,
25
26
  BooleanSchema,
26
27
  printMessage
27
- } from "../chunk-QUVGY2YI.js";
28
+ } from "../chunk-ASH6UZ27.js";
28
29
 
29
30
  // src/adapters/react-router-cloudflare.ts
30
31
  import { waitUntil } from "cloudflare:workers";
@@ -37,7 +38,7 @@ var ReactRouterCloudflareConfigSchema = z.object({
37
38
  /** The Appwarden API token for authentication */
38
39
  appwardenApiToken: AppwardenApiTokenSchema,
39
40
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
40
- appwardenApiHostname: z.string().optional(),
41
+ appwardenApiHostname: AppwardenApiHostnameSchema.optional(),
41
42
  /** Enable debug logging */
42
43
  debug: BooleanSchema.default(false),
43
44
  /** Optional Content Security Policy configuration */
@@ -10,7 +10,7 @@ declare const TanStackStartCloudflareConfigSchema: z.ZodObject<{
10
10
  /** The Appwarden API token for authentication */
11
11
  appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
12
12
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
13
- appwardenApiHostname: z.ZodOptional<z.ZodString>;
13
+ appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
14
14
  /** Enable debug logging */
15
15
  debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
16
16
  /** Optional Content Security Policy configuration */
@@ -3,28 +3,29 @@ import {
3
3
  } from "../chunk-XFG6SUSV.js";
4
4
  import {
5
5
  useContentSecurityPolicy
6
- } from "../chunk-K7ZIT3FM.js";
6
+ } from "../chunk-RQLMO5FA.js";
7
7
  import {
8
8
  getNowMs
9
9
  } from "../chunk-X7WZVYQS.js";
10
10
  import {
11
11
  checkLockStatus
12
- } from "../chunk-ZOYE6D3A.js";
12
+ } from "../chunk-VQIRZMED.js";
13
13
  import {
14
14
  buildLockPageUrl,
15
15
  createRedirect,
16
16
  debug,
17
17
  isOnLockPage
18
- } from "../chunk-KE2UVIYR.js";
18
+ } from "../chunk-6JYUNSUJ.js";
19
19
  import {
20
20
  UseCSPInputSchema,
21
21
  isHTMLRequest
22
22
  } from "../chunk-2WPLLVUI.js";
23
23
  import {
24
+ AppwardenApiHostnameSchema,
24
25
  AppwardenApiTokenSchema,
25
26
  BooleanSchema,
26
27
  printMessage
27
- } from "../chunk-QUVGY2YI.js";
28
+ } from "../chunk-ASH6UZ27.js";
28
29
 
29
30
  // src/adapters/tanstack-start-cloudflare.ts
30
31
  import { waitUntil } from "cloudflare:workers";
@@ -37,7 +38,7 @@ var TanStackStartCloudflareConfigSchema = z.object({
37
38
  /** The Appwarden API token for authentication */
38
39
  appwardenApiToken: AppwardenApiTokenSchema,
39
40
  /** Optional custom API hostname (defaults to https://api.appwarden.io) */
40
- appwardenApiHostname: z.string().optional(),
41
+ appwardenApiHostname: AppwardenApiHostnameSchema.optional(),
41
42
  /** Enable debug logging */
42
43
  debug: BooleanSchema.default(false),
43
44
  /** Optional Content Security Policy configuration */
@@ -11,7 +11,7 @@ import {
11
11
  makeCSPHeader,
12
12
  store,
13
13
  syncEdgeValue
14
- } from "./chunk-QUVGY2YI.js";
14
+ } from "./chunk-ASH6UZ27.js";
15
15
  export {
16
16
  CSP_KEYWORDS,
17
17
  autoQuoteCSPDirectiveArray,
package/cloudflare.d.ts CHANGED
@@ -331,7 +331,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
331
331
  } | undefined;
332
332
  }>>>;
333
333
  appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
334
- appwardenApiHostname: z.ZodOptional<z.ZodString>;
334
+ appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
335
335
  }, "strip", z.ZodTypeAny, {
336
336
  debug: boolean;
337
337
  appwardenApiToken: string;
package/cloudflare.js CHANGED
@@ -1,25 +1,26 @@
1
1
  import {
2
2
  useContentSecurityPolicy
3
- } from "./chunk-K7ZIT3FM.js";
3
+ } from "./chunk-RQLMO5FA.js";
4
4
  import {
5
5
  checkLockStatus
6
- } from "./chunk-ZOYE6D3A.js";
6
+ } from "./chunk-VQIRZMED.js";
7
7
  import {
8
8
  buildLockPageUrl,
9
9
  createRedirect,
10
10
  debug,
11
11
  isOnLockPage
12
- } from "./chunk-KE2UVIYR.js";
12
+ } from "./chunk-6JYUNSUJ.js";
13
13
  import {
14
14
  UseCSPInputSchema,
15
15
  isHTMLRequest
16
16
  } from "./chunk-2WPLLVUI.js";
17
17
  import {
18
+ AppwardenApiHostnameSchema,
18
19
  AppwardenApiTokenSchema,
19
20
  BooleanSchema,
20
21
  insertErrorLogs,
21
22
  printMessage
22
- } from "./chunk-QUVGY2YI.js";
23
+ } from "./chunk-ASH6UZ27.js";
23
24
 
24
25
  // src/runners/appwarden-on-cloudflare.ts
25
26
  import { ZodError } from "zod";
@@ -42,7 +43,7 @@ var UseAppwardenInputSchema = z.object({
42
43
  lockPageSlug: z.string().optional(),
43
44
  multidomainConfig: AppwardenMultidomainConfigSchema.optional(),
44
45
  appwardenApiToken: AppwardenApiTokenSchema,
45
- appwardenApiHostname: z.string().optional()
46
+ appwardenApiHostname: AppwardenApiHostnameSchema.optional()
46
47
  });
47
48
  var lockPageSlugRefinement = (schema) => schema.refine(
48
49
  (data) => data.lockPageSlug || data.multidomainConfig,
package/index.js CHANGED
@@ -5,14 +5,14 @@ import {
5
5
  } from "./chunk-QEFORWCW.js";
6
6
  import {
7
7
  useContentSecurityPolicy
8
- } from "./chunk-K7ZIT3FM.js";
8
+ } from "./chunk-RQLMO5FA.js";
9
9
  import {
10
10
  APPWARDEN_CACHE_KEY,
11
11
  CSPDirectivesSchema,
12
12
  CSPModeSchema,
13
13
  LOCKDOWN_TEST_EXPIRY_MS
14
14
  } from "./chunk-2WPLLVUI.js";
15
- import "./chunk-QUVGY2YI.js";
15
+ import "./chunk-ASH6UZ27.js";
16
16
  export {
17
17
  APPWARDEN_CACHE_KEY,
18
18
  CSPDirectivesSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appwarden/middleware",
3
- "version": "3.11.1",
3
+ "version": "3.11.2",
4
4
  "description": "Instantly disable all user interaction with your app deployed on Cloudflare or Vercel",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/vercel.d.ts CHANGED
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
4
4
  cacheUrl: z.ZodString;
5
5
  appwardenApiToken: z.ZodString;
6
- appwardenApiHostname: z.ZodOptional<z.ZodString>;
6
+ appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
7
7
  vercelApiToken: z.ZodOptional<z.ZodString>;
8
8
  debug: z.ZodOptional<z.ZodBoolean>;
9
9
  lockPageSlug: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
package/vercel.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  buildLockPageUrl,
9
9
  debug,
10
10
  isOnLockPage
11
- } from "./chunk-KE2UVIYR.js";
11
+ } from "./chunk-6JYUNSUJ.js";
12
12
  import {
13
13
  APPWARDEN_CACHE_KEY,
14
14
  CSPDirectivesSchema,
@@ -18,11 +18,12 @@ import {
18
18
  isHTMLRequest
19
19
  } from "./chunk-2WPLLVUI.js";
20
20
  import {
21
+ AppwardenApiHostnameSchema,
21
22
  LockValue,
22
23
  getErrors,
23
24
  makeCSPHeader,
24
25
  printMessage
25
- } from "./chunk-QUVGY2YI.js";
26
+ } from "./chunk-ASH6UZ27.js";
26
27
 
27
28
  // src/runners/appwarden-on-vercel.ts
28
29
  import { waitUntil } from "@vercel/functions";
@@ -183,7 +184,7 @@ var VercelCSPSchema = z.object({
183
184
  var BaseNextJsConfigSchema = z.object({
184
185
  cacheUrl: z.string(),
185
186
  appwardenApiToken: z.string(),
186
- appwardenApiHostname: z.string().optional(),
187
+ appwardenApiHostname: AppwardenApiHostnameSchema.optional(),
187
188
  vercelApiToken: z.string().optional(),
188
189
  debug: z.boolean().optional(),
189
190
  lockPageSlug: z.string().default("").transform((val) => val.replace(/^\/?/, "/")),