@appwarden/middleware 3.14.1 → 3.15.1
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 +1 -1
- package/{chunk-2FSRHIPY.js → chunk-2ZKE4AI4.js} +50 -2
- package/{chunk-JJOX4UAG.js → chunk-IAOONP5L.js} +5 -4
- package/{chunk-PCWFMNHW.js → chunk-L4UHIU77.js} +17 -4
- package/{chunk-7BZFEX4Z.js → chunk-LRDZKQI3.js} +1 -1
- package/{chunk-LDKC5DRW.js → chunk-TXFZUVJP.js} +21 -2
- package/{chunk-DM57ZOTI.js → chunk-YJSTNZGA.js} +8 -3
- package/cloudflare/astro.d.ts +13 -6
- package/cloudflare/astro.js +18 -8
- package/cloudflare/nextjs.d.ts +5 -4
- package/cloudflare/nextjs.js +16 -6
- package/cloudflare/react-router.d.ts +5 -4
- package/cloudflare/react-router.js +18 -8
- package/cloudflare/tanstack-start.d.ts +6 -4
- package/cloudflare/tanstack-start.js +18 -8
- package/cloudflare.d.ts +733 -4
- package/cloudflare.js +26 -8
- package/index.d.ts +3 -3
- package/index.js +2 -2
- package/package.json +19 -13
- package/scripts/appwarden-link.cjs +851 -0
- package/vercel.d.ts +4 -3
- package/vercel.js +34 -6
package/cloudflare.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UseAppwardenInputSchema,
|
|
3
3
|
lockPageSlugRefinement
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IAOONP5L.js";
|
|
5
5
|
import {
|
|
6
6
|
getErrors
|
|
7
7
|
} from "./chunk-NV7K5PRA.js";
|
|
8
8
|
import {
|
|
9
9
|
useContentSecurityPolicy
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YJSTNZGA.js";
|
|
11
11
|
import {
|
|
12
12
|
checkLockStatus
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-L4UHIU77.js";
|
|
14
14
|
import {
|
|
15
15
|
buildLockPageUrl,
|
|
16
16
|
createHeartbeatConfigError,
|
|
@@ -20,12 +20,13 @@ import {
|
|
|
20
20
|
isHTMLRequest,
|
|
21
21
|
isHeartbeatRequest,
|
|
22
22
|
isOnLockPage,
|
|
23
|
+
parseMergedConfig,
|
|
23
24
|
printMessage,
|
|
24
25
|
sanitizeConfigErrors
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2ZKE4AI4.js";
|
|
26
27
|
import {
|
|
27
28
|
HEARTBEAT_SERVICES
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-TXFZUVJP.js";
|
|
29
30
|
|
|
30
31
|
// src/runners/appwarden-on-cloudflare.ts
|
|
31
32
|
import { ZodError } from "zod";
|
|
@@ -57,17 +58,23 @@ var usePipeline = (...initMiddlewares) => {
|
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
// src/utils/cloudflare/insert-errors-logs.ts
|
|
61
|
+
function htmlEscape(str) {
|
|
62
|
+
return str.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026");
|
|
63
|
+
}
|
|
60
64
|
var insertErrorLogs = async (context, error) => {
|
|
61
65
|
const errors = getErrors(error);
|
|
62
66
|
for (const err of errors) {
|
|
63
67
|
console.log(printMessage(err));
|
|
64
68
|
}
|
|
69
|
+
const safeErrors = JSON.stringify(
|
|
70
|
+
errors.map((err) => printMessage(err))
|
|
71
|
+
);
|
|
72
|
+
const escapedErrors = htmlEscape(safeErrors);
|
|
65
73
|
return new HTMLRewriter().on("body", {
|
|
66
74
|
element: (elem) => {
|
|
75
|
+
elem.setAttribute("data-appwarden-logs", escapedErrors);
|
|
67
76
|
elem.append(
|
|
68
|
-
`<script>
|
|
69
|
-
${errors.map((err) => `console.error(\`${printMessage(err)}\`)`).join("\n")}
|
|
70
|
-
</script>`,
|
|
77
|
+
`<script>const logs=JSON.parse(document.body.getAttribute("data-appwarden-logs"));for(const log of logs){console.error(log)}</script>`,
|
|
71
78
|
{ html: true }
|
|
72
79
|
);
|
|
73
80
|
}
|
|
@@ -128,6 +135,16 @@ var useFetchOrigin = () => async (context, next) => {
|
|
|
128
135
|
};
|
|
129
136
|
|
|
130
137
|
// src/runners/appwarden-on-cloudflare.ts
|
|
138
|
+
var RefinedUseAppwardenInputSchema = lockPageSlugRefinement(
|
|
139
|
+
UseAppwardenInputSchema
|
|
140
|
+
);
|
|
141
|
+
function getAppwardenConfiguration(generatedConfig, config) {
|
|
142
|
+
return parseMergedConfig(
|
|
143
|
+
generatedConfig,
|
|
144
|
+
config,
|
|
145
|
+
RefinedUseAppwardenInputSchema.parse
|
|
146
|
+
);
|
|
147
|
+
}
|
|
131
148
|
var appwardenOnCloudflare = (inputFn) => async (request, env, ctx) => {
|
|
132
149
|
ctx.passThroughOnException();
|
|
133
150
|
const requestUrl = new URL(request.url);
|
|
@@ -223,5 +240,6 @@ var appwardenOnCloudflare = (inputFn) => async (request, env, ctx) => {
|
|
|
223
240
|
var createAppwardenMiddleware = appwardenOnCloudflare;
|
|
224
241
|
export {
|
|
225
242
|
createAppwardenMiddleware,
|
|
243
|
+
getAppwardenConfiguration,
|
|
226
244
|
useContentSecurityPolicy
|
|
227
245
|
};
|
package/index.d.ts
CHANGED
|
@@ -198,7 +198,7 @@ declare const isValidCacheUrl: {
|
|
|
198
198
|
|
|
199
199
|
declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
200
200
|
debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
|
|
201
|
-
lockPageSlug: z.ZodOptional<z.ZodString
|
|
201
|
+
lockPageSlug: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
202
202
|
contentSecurityPolicy: z.ZodOptional<z.ZodLazy<z.ZodObject<{
|
|
203
203
|
mode: z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>;
|
|
204
204
|
directives: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
@@ -453,7 +453,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
453
453
|
};
|
|
454
454
|
}>>>;
|
|
455
455
|
multidomainConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
456
|
-
lockPageSlug: z.ZodString
|
|
456
|
+
lockPageSlug: z.ZodEffects<z.ZodString, string, string>;
|
|
457
457
|
contentSecurityPolicy: z.ZodOptional<z.ZodLazy<z.ZodObject<{
|
|
458
458
|
mode: z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>;
|
|
459
459
|
directives: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
@@ -778,7 +778,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
778
778
|
} | undefined;
|
|
779
779
|
}>>>;
|
|
780
780
|
appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
|
|
781
|
-
appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
781
|
+
appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
782
782
|
}, "strip", z.ZodTypeAny, {
|
|
783
783
|
debug: boolean;
|
|
784
784
|
appwardenApiToken: string;
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-QEFORWCW.js";
|
|
6
6
|
import {
|
|
7
7
|
UseAppwardenInputSchema
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IAOONP5L.js";
|
|
9
9
|
import {
|
|
10
10
|
APPWARDEN_CACHE_KEY,
|
|
11
11
|
APPWARDEN_HEARTBEAT_ROUTE,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
HeartbeatResponseBodySchema,
|
|
29
29
|
LOCKDOWN_TEST_EXPIRY_MS,
|
|
30
30
|
validateHeartbeatResponseBody
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-TXFZUVJP.js";
|
|
32
32
|
export {
|
|
33
33
|
APPWARDEN_CACHE_KEY,
|
|
34
34
|
APPWARDEN_HEARTBEAT_ROUTE,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appwarden/middleware",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.1",
|
|
4
4
|
"description": "Instantly disable all user interaction with your app deployed on Cloudflare or Vercel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"main": "./index.js",
|
|
25
25
|
"types": "./index.d.ts",
|
|
26
|
+
"bin": {
|
|
27
|
+
"appwarden-link": "./scripts/appwarden-link.cjs"
|
|
28
|
+
},
|
|
26
29
|
"exports": {
|
|
27
30
|
".": {
|
|
28
31
|
"types": "./index.d.ts",
|
|
@@ -58,8 +61,9 @@
|
|
|
58
61
|
"node": ">=22.14.0"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
61
|
-
"@upstash/redis": "^1.
|
|
64
|
+
"@upstash/redis": "^1.38.0",
|
|
62
65
|
"@vercel/edge-config": "^1.4.3",
|
|
66
|
+
"acorn": "^8.16.0",
|
|
63
67
|
"zod": "^3.25.76"
|
|
64
68
|
},
|
|
65
69
|
"peerDependencies": {
|
|
@@ -100,16 +104,20 @@
|
|
|
100
104
|
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1",
|
|
101
105
|
"@opennextjs/cloudflare@<1.17.1": ">=1.17.1",
|
|
102
106
|
"@smithy/config-resolver@<4.4.0": ">=4.4.0",
|
|
107
|
+
"@tanstack/start-server-core@<1.167.30": ">=1.169.4",
|
|
108
|
+
"@tanstack/start-server-core@1.163.2>h3-v2": "npm:h3@2.0.1-rc.22",
|
|
103
109
|
"ajv@>=7.0.0-alpha.0 <8.18.0": ">=8.18.0",
|
|
104
110
|
"body-parser@>=2.2.0 <2.2.1": ">=2.2.1",
|
|
111
|
+
"brace-expansion@<5.0.6": ">=5.0.6",
|
|
105
112
|
"cookie@<0.7.0": ">=0.7.0",
|
|
106
|
-
"devalue@<5.
|
|
113
|
+
"devalue@<5.8.1": ">=5.8.1",
|
|
107
114
|
"dompurify@<=3.3.1": ">=3.3.2",
|
|
108
115
|
"esbuild@<=0.24.2": ">=0.25.0",
|
|
109
|
-
"fast-
|
|
116
|
+
"fast-uri@<=3.1.1": ">=3.1.2",
|
|
117
|
+
"fast-xml-parser@<5.7.0": ">=5.7.3",
|
|
110
118
|
"flatted@<3.4.2": ">=3.4.2",
|
|
111
119
|
"h3@<1.15.6": ">=1.15.6",
|
|
112
|
-
"h3@>=2.0.0
|
|
120
|
+
"h3@>=2.0.0-beta.0 <2.0.1-rc.18": ">=2.0.1-rc.22",
|
|
113
121
|
"handlebars@4.7.8": "4.7.9",
|
|
114
122
|
"js-yaml@<3.14.2": ">=3.14.2",
|
|
115
123
|
"jws@=4.0.0": ">=4.0.1",
|
|
@@ -117,28 +125,26 @@
|
|
|
117
125
|
"lodash-es@>=4.0.0 <=4.17.23": ">=4.18.1",
|
|
118
126
|
"mermaid@<10.9.5": ">=10.9.5",
|
|
119
127
|
"minimatch@<10.2.1": ">=10.2.3",
|
|
120
|
-
"next
|
|
128
|
+
"next@<16.2.6": ">=16.2.6",
|
|
129
|
+
"nitropack@<2.13.4": ">=2.13.4",
|
|
121
130
|
"npm@<=11.8.0": ">=11.9.0",
|
|
122
131
|
"path-to-regexp@>=4.0.0 <6.3.0": ">=6.3.0",
|
|
123
132
|
"picomatch@<4.0.4": ">=4.0.4",
|
|
124
|
-
"qs
|
|
133
|
+
"qs@<=6.15.1": ">=6.15.2",
|
|
125
134
|
"rollup@>=4.0.0 <4.59.0": ">=4.59.0",
|
|
126
135
|
"serialize-javascript@<=7.0.2": ">=7.0.3",
|
|
127
136
|
"svgo@=4.0.0": ">=4.0.1",
|
|
128
137
|
"tar@<=7.5.10": ">=7.5.11",
|
|
129
138
|
"undici@<7.24.0": ">=7.24.0",
|
|
130
139
|
"wrangler@>=4.0.0 <4.59.1": ">=4.59.1",
|
|
131
|
-
"@tanstack/start-server-core@1.163.2>h3-v2": "npm:h3@2.0.1-rc.16",
|
|
132
|
-
"h3@>=2.0.0-beta.0 <=2.0.1-rc.16": ">=2.0.1-rc.17",
|
|
133
|
-
"h3@>=2.0.0-beta.4 <2.0.1-rc.18": ">=2.0.1-rc.18",
|
|
134
|
-
"h3@>=2.0.1-alpha.0 <=2.0.1-rc.16": ">=2.0.1-rc.17",
|
|
135
140
|
"defu@<=6.1.4": ">=6.1.5",
|
|
136
141
|
"vite@<=6.4.1": ">=6.4.2",
|
|
137
142
|
"vite@>=7.0.0 <=7.3.1": ">=7.3.2",
|
|
138
143
|
"vite@>=7.1.0 <=7.3.1": ">=7.3.2",
|
|
139
144
|
"vite@>=6.0.0 <=6.4.1": ">=6.4.2",
|
|
140
|
-
"
|
|
141
|
-
"
|
|
145
|
+
"follow-redirects@<=1.15.11": ">=1.16.0",
|
|
146
|
+
"postcss@<8.5.10": ">=8.5.15",
|
|
147
|
+
"ws@<8.20.1": ">=8.20.1"
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
150
|
}
|