@appwarden/middleware 3.13.2 → 3.13.3
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-QABXSPGV.js → chunk-2ZF7A6Z3.js} +1 -1
- package/{chunk-7FPMUPAS.js → chunk-HZRLFCGV.js} +1 -1
- package/{chunk-EG6TX7RH.js → chunk-PSOS33UD.js} +1 -1
- package/{chunk-OGQHDOKS.js → chunk-X2TEREDD.js} +25 -14
- package/cloudflare/astro.js +4 -4
- package/cloudflare/nextjs.js +2 -2
- package/cloudflare/react-router.js +4 -4
- package/cloudflare/tanstack-start.js +4 -4
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +3 -3
- package/index.d.ts +10 -10
- package/package.json +17 -22
- package/vercel.js +8 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://github.com/appwarden/middleware)
|
|
5
5
|
[](https://www.npmjs.com/package/@appwarden/middleware)
|
|
6
6
|
[](https://docs.npmjs.com/generating-provenance-statements)
|
|
7
|
-

|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
10
|
## Core Features
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
MemoryCache,
|
|
3
3
|
debug,
|
|
4
4
|
printMessage
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PSOS33UD.js";
|
|
6
6
|
import {
|
|
7
7
|
APPWARDEN_CACHE_KEY,
|
|
8
8
|
APPWARDEN_TEST_ROUTE,
|
|
@@ -21,7 +21,8 @@ var store = {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
var getCacheValue = async (context, cacheKey) => {
|
|
24
|
-
const
|
|
24
|
+
const request = new Request(cacheKey.href);
|
|
25
|
+
const match = await context.cache.match(request);
|
|
25
26
|
return match ?? void 0;
|
|
26
27
|
};
|
|
27
28
|
var updateCacheValue = async (context, cacheKey, value, ttl) => {
|
|
@@ -31,19 +32,21 @@ var updateCacheValue = async (context, cacheKey, value, ttl) => {
|
|
|
31
32
|
value,
|
|
32
33
|
ttl ? `expires in ${ttl}s` : ""
|
|
33
34
|
);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
...ttl && {
|
|
40
|
-
"cache-control": `max-age=${ttl}`
|
|
41
|
-
}
|
|
35
|
+
const response = new Response(JSON.stringify(value), {
|
|
36
|
+
headers: {
|
|
37
|
+
"content-type": "application/json",
|
|
38
|
+
...ttl && {
|
|
39
|
+
"cache-control": `max-age=${ttl}`
|
|
42
40
|
}
|
|
43
|
-
}
|
|
44
|
-
);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const request = new Request(cacheKey.href, { method: "GET" });
|
|
44
|
+
await context.cache.put(request, response);
|
|
45
|
+
};
|
|
46
|
+
var clearCache = (context, cacheKey) => {
|
|
47
|
+
const request = new Request(cacheKey.href);
|
|
48
|
+
return context.cache.delete(request);
|
|
45
49
|
};
|
|
46
|
-
var clearCache = (context, cacheKey) => context.cache.delete(cacheKey);
|
|
47
50
|
|
|
48
51
|
// src/utils/cloudflare/delete-edge-value.ts
|
|
49
52
|
var deleteEdgeValue = async (context) => {
|
|
@@ -132,6 +135,13 @@ var syncEdgeValue = async (context) => {
|
|
|
132
135
|
appwardenApiToken: context.appwardenApiToken
|
|
133
136
|
})
|
|
134
137
|
});
|
|
138
|
+
if (response.status === 403) {
|
|
139
|
+
console.log(
|
|
140
|
+
printMessage(
|
|
141
|
+
"Verifying domain ownership...this will only take a few minutes."
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
135
145
|
if (response.status !== 200) {
|
|
136
146
|
throw new Error(`${response.status} ${response.statusText}`);
|
|
137
147
|
}
|
|
@@ -176,7 +186,8 @@ var createContext = async (config) => {
|
|
|
176
186
|
{
|
|
177
187
|
serviceOrigin: requestUrl.origin,
|
|
178
188
|
cache: await caches.open("appwarden:lock"),
|
|
179
|
-
debug: debugFn
|
|
189
|
+
debug: debugFn,
|
|
190
|
+
waitUntil: config.waitUntil
|
|
180
191
|
},
|
|
181
192
|
keyName
|
|
182
193
|
);
|
package/cloudflare/astro.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyContentSecurityPolicyToResponse,
|
|
3
3
|
isResponseLike
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-2ZF7A6Z3.js";
|
|
5
|
+
import "../chunk-HZRLFCGV.js";
|
|
6
6
|
import {
|
|
7
7
|
getNowMs,
|
|
8
8
|
logElapsed
|
|
9
9
|
} from "../chunk-G6BMPIYD.js";
|
|
10
10
|
import {
|
|
11
11
|
checkLockStatus
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-X2TEREDD.js";
|
|
13
13
|
import {
|
|
14
14
|
TEMPORARY_REDIRECT_STATUS,
|
|
15
15
|
buildLockPageUrl,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
isOnLockPage,
|
|
23
23
|
printMessage,
|
|
24
24
|
sanitizeConfigErrors
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-PSOS33UD.js";
|
|
26
26
|
import {
|
|
27
27
|
AppwardenApiHostnameSchema,
|
|
28
28
|
AppwardenApiTokenSchema,
|
package/cloudflare/nextjs.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../chunk-G6BMPIYD.js";
|
|
8
8
|
import {
|
|
9
9
|
checkLockStatus
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-X2TEREDD.js";
|
|
11
11
|
import {
|
|
12
12
|
TEMPORARY_REDIRECT_STATUS,
|
|
13
13
|
buildLockPageUrl,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
makeCSPHeader,
|
|
21
21
|
printMessage,
|
|
22
22
|
sanitizeConfigErrors
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-PSOS33UD.js";
|
|
24
24
|
import {
|
|
25
25
|
AppwardenApiHostnameSchema,
|
|
26
26
|
AppwardenApiTokenSchema,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyContentSecurityPolicyToResponse,
|
|
3
3
|
isResponseLike
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-2ZF7A6Z3.js";
|
|
5
|
+
import "../chunk-HZRLFCGV.js";
|
|
6
6
|
import {
|
|
7
7
|
getNowMs,
|
|
8
8
|
logElapsed
|
|
9
9
|
} from "../chunk-G6BMPIYD.js";
|
|
10
10
|
import {
|
|
11
11
|
checkLockStatus
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-X2TEREDD.js";
|
|
13
13
|
import {
|
|
14
14
|
buildLockPageUrl,
|
|
15
15
|
createHeartbeatConfigError,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
isOnLockPage,
|
|
22
22
|
printMessage,
|
|
23
23
|
sanitizeConfigErrors
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-PSOS33UD.js";
|
|
25
25
|
import {
|
|
26
26
|
AppwardenApiHostnameSchema,
|
|
27
27
|
AppwardenApiTokenSchema,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyContentSecurityPolicyToResponse,
|
|
3
3
|
isResponseLike
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-2ZF7A6Z3.js";
|
|
5
|
+
import "../chunk-HZRLFCGV.js";
|
|
6
6
|
import {
|
|
7
7
|
getNowMs,
|
|
8
8
|
logElapsed
|
|
9
9
|
} from "../chunk-G6BMPIYD.js";
|
|
10
10
|
import {
|
|
11
11
|
checkLockStatus
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-X2TEREDD.js";
|
|
13
13
|
import {
|
|
14
14
|
buildLockPageUrl,
|
|
15
15
|
createHeartbeatConfigError,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
isOnLockPage,
|
|
22
22
|
printMessage,
|
|
23
23
|
sanitizeConfigErrors
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-PSOS33UD.js";
|
|
25
25
|
import {
|
|
26
26
|
AppwardenApiHostnameSchema,
|
|
27
27
|
AppwardenApiTokenSchema,
|
package/cloudflare.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RequestContext, U as UseCSPInput, M as Middleware, B as Bindings } from './use-content-security-policy-Dwdcwp33.js';
|
|
2
1
|
import { z } from 'zod';
|
|
2
|
+
import { R as RequestContext, U as UseCSPInput, M as Middleware, B as Bindings } from './use-content-security-policy-Dwdcwp33.js';
|
|
3
3
|
|
|
4
4
|
declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestContext, z.ZodTypeDef, RequestContext>], z.ZodUnknown>, z.ZodLazy<z.ZodEffects<z.ZodObject<{
|
|
5
5
|
debug: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
|
package/cloudflare.js
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
} from "./chunk-NV7K5PRA.js";
|
|
8
8
|
import {
|
|
9
9
|
useContentSecurityPolicy
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HZRLFCGV.js";
|
|
11
11
|
import {
|
|
12
12
|
checkLockStatus
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-X2TEREDD.js";
|
|
14
14
|
import {
|
|
15
15
|
buildLockPageUrl,
|
|
16
16
|
createHeartbeatConfigError,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
isOnLockPage,
|
|
23
23
|
printMessage,
|
|
24
24
|
sanitizeConfigErrors
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-PSOS33UD.js";
|
|
26
26
|
import {
|
|
27
27
|
HEARTBEAT_SERVICES
|
|
28
28
|
} from "./chunk-OIEAURS7.js";
|
package/index.d.ts
CHANGED
|
@@ -61,13 +61,13 @@ declare const HeartbeatConfigErrorSchema: z.ZodObject<{
|
|
|
61
61
|
code: z.ZodString;
|
|
62
62
|
message: z.ZodString;
|
|
63
63
|
}, "strict", z.ZodTypeAny, {
|
|
64
|
-
message: string;
|
|
65
64
|
code: string;
|
|
66
65
|
path: (string | number)[];
|
|
67
|
-
}, {
|
|
68
66
|
message: string;
|
|
67
|
+
}, {
|
|
69
68
|
code: string;
|
|
70
69
|
path: (string | number)[];
|
|
70
|
+
message: string;
|
|
71
71
|
}>;
|
|
72
72
|
type HeartbeatConfigError = z.infer<typeof HeartbeatConfigErrorSchema>;
|
|
73
73
|
/**
|
|
@@ -85,21 +85,21 @@ declare const HeartbeatResponseBodySchema: z.ZodEffects<z.ZodObject<{
|
|
|
85
85
|
code: z.ZodString;
|
|
86
86
|
message: z.ZodString;
|
|
87
87
|
}, "strict", z.ZodTypeAny, {
|
|
88
|
-
message: string;
|
|
89
88
|
code: string;
|
|
90
89
|
path: (string | number)[];
|
|
91
|
-
}, {
|
|
92
90
|
message: string;
|
|
91
|
+
}, {
|
|
93
92
|
code: string;
|
|
94
93
|
path: (string | number)[];
|
|
95
|
-
}>, "many">, {
|
|
96
94
|
message: string;
|
|
95
|
+
}>, "many">, {
|
|
97
96
|
code: string;
|
|
98
97
|
path: (string | number)[];
|
|
99
|
-
}[], {
|
|
100
98
|
message: string;
|
|
99
|
+
}[], {
|
|
101
100
|
code: string;
|
|
102
101
|
path: (string | number)[];
|
|
102
|
+
message: string;
|
|
103
103
|
}[]>;
|
|
104
104
|
}, "strict", z.ZodTypeAny, {
|
|
105
105
|
status: "ok";
|
|
@@ -109,9 +109,9 @@ declare const HeartbeatResponseBodySchema: z.ZodEffects<z.ZodObject<{
|
|
|
109
109
|
service: "cloudflare" | "cloudflare-astro" | "cloudflare-react-router" | "cloudflare-tanstack-start" | "cloudflare-nextjs" | "vercel";
|
|
110
110
|
version: string;
|
|
111
111
|
configErrors: {
|
|
112
|
-
message: string;
|
|
113
112
|
code: string;
|
|
114
113
|
path: (string | number)[];
|
|
114
|
+
message: string;
|
|
115
115
|
}[];
|
|
116
116
|
}, {
|
|
117
117
|
status: "ok";
|
|
@@ -121,9 +121,9 @@ declare const HeartbeatResponseBodySchema: z.ZodEffects<z.ZodObject<{
|
|
|
121
121
|
service: "cloudflare" | "cloudflare-astro" | "cloudflare-react-router" | "cloudflare-tanstack-start" | "cloudflare-nextjs" | "vercel";
|
|
122
122
|
version: string;
|
|
123
123
|
configErrors: {
|
|
124
|
-
message: string;
|
|
125
124
|
code: string;
|
|
126
125
|
path: (string | number)[];
|
|
126
|
+
message: string;
|
|
127
127
|
}[];
|
|
128
128
|
}>, {
|
|
129
129
|
status: "ok";
|
|
@@ -133,9 +133,9 @@ declare const HeartbeatResponseBodySchema: z.ZodEffects<z.ZodObject<{
|
|
|
133
133
|
service: "cloudflare" | "cloudflare-astro" | "cloudflare-react-router" | "cloudflare-tanstack-start" | "cloudflare-nextjs" | "vercel";
|
|
134
134
|
version: string;
|
|
135
135
|
configErrors: {
|
|
136
|
-
message: string;
|
|
137
136
|
code: string;
|
|
138
137
|
path: (string | number)[];
|
|
138
|
+
message: string;
|
|
139
139
|
}[];
|
|
140
140
|
}, {
|
|
141
141
|
status: "ok";
|
|
@@ -145,9 +145,9 @@ declare const HeartbeatResponseBodySchema: z.ZodEffects<z.ZodObject<{
|
|
|
145
145
|
service: "cloudflare" | "cloudflare-astro" | "cloudflare-react-router" | "cloudflare-tanstack-start" | "cloudflare-nextjs" | "vercel";
|
|
146
146
|
version: string;
|
|
147
147
|
configErrors: {
|
|
148
|
-
message: string;
|
|
149
148
|
code: string;
|
|
150
149
|
path: (string | number)[];
|
|
150
|
+
message: string;
|
|
151
151
|
}[];
|
|
152
152
|
}>;
|
|
153
153
|
type HeartbeatResponseBody = z.infer<typeof HeartbeatResponseBodySchema>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appwarden/middleware",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.3",
|
|
4
4
|
"description": "Instantly disable all user interaction with your app deployed on Cloudflare or Vercel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -97,36 +97,31 @@
|
|
|
97
97
|
},
|
|
98
98
|
"pnpm": {
|
|
99
99
|
"overrides": {
|
|
100
|
+
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1",
|
|
101
|
+
"@opennextjs/cloudflare@<1.17.1": ">=1.17.1",
|
|
102
|
+
"@smithy/config-resolver@<4.4.0": ">=4.4.0",
|
|
103
|
+
"ajv@>=7.0.0-alpha.0 <8.18.0": ">=8.18.0",
|
|
104
|
+
"body-parser@>=2.2.0 <2.2.1": ">=2.2.1",
|
|
100
105
|
"cookie@<0.7.0": ">=0.7.0",
|
|
106
|
+
"devalue@<5.6.4": ">=5.6.4",
|
|
101
107
|
"esbuild@<=0.24.2": ">=0.25.0",
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
108
|
+
"fast-xml-parser@>=4.0.0-beta.3 <=5.5.5": ">=5.5.6",
|
|
109
|
+
"h3@<1.15.6": ">=1.15.6",
|
|
110
|
+
"h3@>=2.0.0 <=2.0.1-rc.14": ">=2.0.1-rc.15",
|
|
111
|
+
"js-yaml@<3.14.2": ">=3.14.2",
|
|
105
112
|
"jws@=4.0.0": ">=4.0.1",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
113
|
+
"minimatch@<10.2.1": ">=10.2.3",
|
|
114
|
+
"next@>=10.0.0 <16.1.7": ">=16.1.7",
|
|
108
115
|
"npm@<=11.8.0": ">=11.9.0",
|
|
109
|
-
"
|
|
116
|
+
"path-to-regexp@>=4.0.0 <6.3.0": ">=6.3.0",
|
|
117
|
+
"picomatch@<4.0.4": ">=4.0.4",
|
|
110
118
|
"qs@>=6.7.0 <=6.14.1": ">=6.14.2",
|
|
111
|
-
"devalue@<=5.6.2": ">=5.6.3",
|
|
112
|
-
"minimatch@<10.2.1": ">=10.2.3",
|
|
113
|
-
"ajv@>=7.0.0-alpha.0 <8.18.0": ">=8.18.0",
|
|
114
119
|
"rollup@>=4.0.0 <4.59.0": ">=4.59.0",
|
|
115
|
-
"h3@<=1.15.4": ">=1.15.5",
|
|
116
|
-
"js-yaml@<3.14.2": ">=3.14.2",
|
|
117
|
-
"fast-xml-parser@<5.3.8": ">=5.3.8",
|
|
118
120
|
"serialize-javascript@<=7.0.2": ">=7.0.3",
|
|
119
121
|
"svgo@=4.0.0": ">=4.0.1",
|
|
120
|
-
"@opennextjs/cloudflare@<1.17.1": ">=1.17.1",
|
|
121
122
|
"tar@<=7.5.10": ">=7.5.11",
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"next@>=10.0.0 <16.1.7": ">=16.1.7",
|
|
125
|
-
"fast-xml-parser@>=4.0.0-beta.3 <=5.5.5": ">=5.5.6",
|
|
126
|
-
"h3@<1.15.6": ">=1.15.6",
|
|
127
|
-
"h3@>=2.0.0-0 <2.0.1-rc.15": ">=2.0.1-rc.15",
|
|
128
|
-
"next@>=16.0.0-beta.0 <16.1.7": ">=16.1.7",
|
|
129
|
-
"h3@>=2.0.0 <=2.0.1-rc.14": ">=2.0.1-rc.15",
|
|
123
|
+
"undici@<7.24.0": ">=7.24.0",
|
|
124
|
+
"wrangler@>=4.0.0 <4.59.1": ">=4.59.1",
|
|
130
125
|
"@tanstack/start-server-core@1.163.2>h3-v2": "npm:h3@2.0.1-rc.16"
|
|
131
126
|
}
|
|
132
127
|
}
|
package/vercel.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
makeCSPHeader,
|
|
21
21
|
printMessage,
|
|
22
22
|
sanitizeConfigErrors
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PSOS33UD.js";
|
|
24
24
|
import {
|
|
25
25
|
APPWARDEN_CACHE_KEY,
|
|
26
26
|
AppwardenApiHostnameSchema,
|
|
@@ -125,6 +125,13 @@ var syncEdgeValue = async (context) => {
|
|
|
125
125
|
appwardenApiToken: context.appwardenApiToken
|
|
126
126
|
})
|
|
127
127
|
});
|
|
128
|
+
if (response.status === 403) {
|
|
129
|
+
console.log(
|
|
130
|
+
printMessage(
|
|
131
|
+
"Verifying domain ownership...this will only take a few minutes."
|
|
132
|
+
)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
128
135
|
if (response.status !== 200) {
|
|
129
136
|
throw new Error(`${response.status} ${response.statusText}`);
|
|
130
137
|
}
|