@appwarden/middleware 1.1.3 → 1.1.4
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/{chunk-3STKCAEA.js → chunk-6DI6L6AE.js} +17 -18
- package/{chunk-5UMKWIJW.js → chunk-GC5FS43G.js} +7 -3
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/package.json +2 -2
- package/{use-content-security-policy-DBWKjDEH.d.ts → use-content-security-policy-UyG9yvVs.d.ts} +2 -2
- package/vercel.js +1 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
printMessage,
|
|
11
11
|
removedHeaders,
|
|
12
12
|
renderLockPage
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GC5FS43G.js";
|
|
14
14
|
|
|
15
15
|
// src/utils/cloudflare/cloudflare-cache.ts
|
|
16
16
|
var store = {
|
|
@@ -40,7 +40,7 @@ var getCacheValue = async (context, cacheKey) => {
|
|
|
40
40
|
var updateCacheValue = async (context, cacheKey, value, cacheExpirationSeconds) => {
|
|
41
41
|
debug(
|
|
42
42
|
"updating cache...",
|
|
43
|
-
cacheKey.
|
|
43
|
+
cacheKey.href,
|
|
44
44
|
value,
|
|
45
45
|
cacheExpirationSeconds ? `expires in ${cacheExpirationSeconds}s` : ""
|
|
46
46
|
);
|
|
@@ -128,7 +128,7 @@ var getLockValue = async (context) => {
|
|
|
128
128
|
var insertErrorLogs = async (context, error) => {
|
|
129
129
|
const errors = getErrors(error);
|
|
130
130
|
for (const err of errors) {
|
|
131
|
-
console.
|
|
131
|
+
console.log(printMessage(err));
|
|
132
132
|
}
|
|
133
133
|
return new HTMLRewriter().on("body", {
|
|
134
134
|
element: (elem) => {
|
|
@@ -197,21 +197,20 @@ var syncEdgeValue = async (context) => {
|
|
|
197
197
|
if (result.error) {
|
|
198
198
|
throw new APIError(result.error.message);
|
|
199
199
|
}
|
|
200
|
-
if (result.content) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
200
|
+
if (!result.content) {
|
|
201
|
+
throw new APIError("no content from api");
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const parsedValue = LockValue.omit({ lastCheck: true }).parse(
|
|
205
|
+
result.content
|
|
206
|
+
);
|
|
207
|
+
debug(`syncing with api...DONE ${JSON.stringify(parsedValue, null, 2)}`);
|
|
208
|
+
await context.edgeCache.updateValue({
|
|
209
|
+
...parsedValue,
|
|
210
|
+
lastCheck: Date.now()
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
throw new APIError(`Failed to parse check endpoint result - ${error}`);
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
216
|
} catch (e) {
|
|
@@ -89,7 +89,7 @@ var errorsMap = {
|
|
|
89
89
|
["DirectivesRequired" /* DirectivesRequired */]: '`CSP_DIRECTIVES` must be provided when `CSP_MODE` is "report-only" or "enforced"',
|
|
90
90
|
["DirectivesBadParse" /* DirectivesBadParse */]: "Failed to parse `CSP_DIRECTIVES`. Is it a valid JSON string?"
|
|
91
91
|
},
|
|
92
|
-
appwardenApiToken: "Please provide a valid `appwardenApiToken`. Learn more at https://appwarden.com/docs/api-
|
|
92
|
+
appwardenApiToken: "Please provide a valid `appwardenApiToken`. Learn more at https://appwarden.com/docs/guides/api-token-management."
|
|
93
93
|
};
|
|
94
94
|
var getErrors = (error) => {
|
|
95
95
|
const matches = [];
|
|
@@ -308,7 +308,7 @@ var AppwardenConfigSchema = BaseNextJsConfigSchema.refine(
|
|
|
308
308
|
}
|
|
309
309
|
).refine((data) => !!data.appwardenApiToken, {
|
|
310
310
|
message: printMessage(
|
|
311
|
-
"Please provide a valid `appwardenApiToken`. Learn more at https://appwarden.com/docs/api-
|
|
311
|
+
"Please provide a valid `appwardenApiToken`. Learn more at https://appwarden.com/docs/guides/api-token-management."
|
|
312
312
|
),
|
|
313
313
|
path: ["appwardenApiToken"]
|
|
314
314
|
});
|
|
@@ -473,7 +473,11 @@ var CSPDirectivesSchema = z8.union([
|
|
|
473
473
|
z8.string(),
|
|
474
474
|
ContentSecurityPolicySchema
|
|
475
475
|
]);
|
|
476
|
-
var CSPModeSchema = z8.
|
|
476
|
+
var CSPModeSchema = z8.union([
|
|
477
|
+
z8.literal("disabled"),
|
|
478
|
+
z8.literal("report-only"),
|
|
479
|
+
z8.literal("enforced")
|
|
480
|
+
]).optional().default("disabled");
|
|
477
481
|
var UseCSPInputSchema = z8.object({
|
|
478
482
|
mode: CSPModeSchema,
|
|
479
483
|
directives: CSPDirectivesSchema.optional().refine(
|
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-UyG9yvVs.js';
|
|
2
|
+
export { u as useContentSecurityPolicy } from './use-content-security-policy-UyG9yvVs.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<{
|
package/cloudflare.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
insertErrorLogs,
|
|
3
3
|
useAppwarden,
|
|
4
4
|
useContentSecurityPolicy
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6DI6L6AE.js";
|
|
6
6
|
import {
|
|
7
7
|
ConfigFnInputSchema,
|
|
8
8
|
usePipeline
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GC5FS43G.js";
|
|
10
10
|
|
|
11
11
|
// src/runners/appwarden-on-cloudflare.ts
|
|
12
12
|
import { ZodError } from "zod";
|
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-UyG9yvVs.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const LOCKDOWN_TEST_EXPIRY_MS: number;
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useContentSecurityPolicy
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6DI6L6AE.js";
|
|
4
4
|
import {
|
|
5
5
|
APPWARDEN_CACHE_KEY,
|
|
6
6
|
APPWARDEN_USER_AGENT,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
getEdgeConfigId,
|
|
11
11
|
isCacheUrl,
|
|
12
12
|
isValidCacheUrl
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GC5FS43G.js";
|
|
14
14
|
export {
|
|
15
15
|
APPWARDEN_CACHE_KEY,
|
|
16
16
|
APPWARDEN_USER_AGENT,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appwarden/middleware",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Instantly shut off access your app deployed on Cloudflare or Vercel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"monitoring"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@cloudflare/next-on-pages": "1.13.
|
|
19
|
+
"@cloudflare/next-on-pages": "1.13.5",
|
|
20
20
|
"@upstash/redis": "^1.30.0",
|
|
21
21
|
"@vercel/edge-config": "^1.1.0",
|
|
22
22
|
"zod": "^3"
|
package/{use-content-security-policy-DBWKjDEH.d.ts → use-content-security-policy-UyG9yvVs.d.ts}
RENAMED
|
@@ -188,9 +188,9 @@ declare const CSPDirectivesSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
|
188
188
|
"trusted-types"?: string | boolean | string[] | undefined;
|
|
189
189
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
190
190
|
}>]>;
|
|
191
|
-
declare const CSPModeSchema: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.
|
|
191
|
+
declare const CSPModeSchema: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>>>;
|
|
192
192
|
declare const UseCSPInputSchema: z.ZodEffects<z.ZodObject<{
|
|
193
|
-
mode: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.
|
|
193
|
+
mode: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"disabled">, z.ZodLiteral<"report-only">, z.ZodLiteral<"enforced">]>>>;
|
|
194
194
|
directives: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
195
195
|
"default-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|
|
196
196
|
"script-src": z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString, z.ZodBoolean]>>;
|