@appwarden/middleware 3.13.3 → 3.14.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 +1 -1
- package/{chunk-OIEAURS7.js → chunk-FE7E5Q5F.js} +8 -0
- package/{chunk-X2TEREDD.js → chunk-GMWSGC6T.js} +8 -4
- package/{chunk-UBWPR24M.js → chunk-HKPJZTYK.js} +1 -1
- package/{chunk-PSOS33UD.js → chunk-NC2TN3D5.js} +2 -4
- package/{chunk-2ZF7A6Z3.js → chunk-VVE7MFVZ.js} +1 -1
- package/{chunk-HZRLFCGV.js → chunk-YPF5MTU3.js} +2 -2
- package/cloudflare/astro.d.ts +11 -5
- package/cloudflare/astro.js +19 -9
- package/cloudflare/nextjs.js +3 -3
- package/cloudflare/react-router.js +5 -5
- package/cloudflare/tanstack-start.js +5 -5
- package/cloudflare.d.ts +5 -5
- package/cloudflare.js +5 -5
- package/index.d.ts +8 -6
- package/index.js +6 -2
- package/package.json +1 -1
- package/vercel.d.ts +10 -10
- package/vercel.js +8 -4
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
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/version.ts
|
|
2
|
+
var MIDDLEWARE_VERSION = "3.13.4";
|
|
3
|
+
|
|
1
4
|
// src/constants.ts
|
|
2
5
|
var LOCKDOWN_TEST_EXPIRY_MS = 5 * 60 * 1e3;
|
|
3
6
|
var errors = { badCacheConnection: "BAD_CACHE_CONNECTION" };
|
|
@@ -14,6 +17,8 @@ var HEARTBEAT_CONFIG_ERRORS_MAX_SERIALIZED_BYTES = 12 * 1024;
|
|
|
14
17
|
var HEARTBEAT_RESPONSE_BODY_MAX_SERIALIZED_BYTES = 32 * 1024;
|
|
15
18
|
var HEARTBEAT_CONFIG_ERROR_MAX_PATH_SEGMENT_LENGTH = 100;
|
|
16
19
|
var APPWARDEN_CACHE_KEY = "appwarden-lock";
|
|
20
|
+
var APPWARDEN_MIDDLEWARE_USER_AGENT_PREFIX = "Appwarden/";
|
|
21
|
+
var APPWARDEN_MIDDLEWARE_USER_AGENT = `${APPWARDEN_MIDDLEWARE_USER_AGENT_PREFIX}${MIDDLEWARE_VERSION}`;
|
|
17
22
|
var HEARTBEAT_SERVICE_VALUES = [
|
|
18
23
|
"cloudflare",
|
|
19
24
|
"cloudflare-astro",
|
|
@@ -192,6 +197,7 @@ var UseCSPInputSchema = z4.object({
|
|
|
192
197
|
});
|
|
193
198
|
|
|
194
199
|
export {
|
|
200
|
+
MIDDLEWARE_VERSION,
|
|
195
201
|
LOCKDOWN_TEST_EXPIRY_MS,
|
|
196
202
|
errors,
|
|
197
203
|
globalErrors,
|
|
@@ -207,6 +213,8 @@ export {
|
|
|
207
213
|
HEARTBEAT_RESPONSE_BODY_MAX_SERIALIZED_BYTES,
|
|
208
214
|
HEARTBEAT_CONFIG_ERROR_MAX_PATH_SEGMENT_LENGTH,
|
|
209
215
|
APPWARDEN_CACHE_KEY,
|
|
216
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT_PREFIX,
|
|
217
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT,
|
|
210
218
|
HEARTBEAT_SERVICE_VALUES,
|
|
211
219
|
HEARTBEAT_SERVICES,
|
|
212
220
|
BooleanSchema,
|
|
@@ -2,12 +2,13 @@ import {
|
|
|
2
2
|
MemoryCache,
|
|
3
3
|
debug,
|
|
4
4
|
printMessage
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NC2TN3D5.js";
|
|
6
6
|
import {
|
|
7
7
|
APPWARDEN_CACHE_KEY,
|
|
8
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT,
|
|
8
9
|
APPWARDEN_TEST_ROUTE,
|
|
9
10
|
LockValue
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FE7E5Q5F.js";
|
|
11
12
|
|
|
12
13
|
// src/utils/cloudflare/cloudflare-cache.ts
|
|
13
14
|
var store = {
|
|
@@ -127,7 +128,10 @@ var syncEdgeValue = async (context) => {
|
|
|
127
128
|
try {
|
|
128
129
|
const response = await fetch(new URL("/v1/appwarden/status", apiHostname), {
|
|
129
130
|
method: "POST",
|
|
130
|
-
headers: {
|
|
131
|
+
headers: {
|
|
132
|
+
"content-type": "application/json",
|
|
133
|
+
"user-agent": APPWARDEN_MIDDLEWARE_USER_AGENT
|
|
134
|
+
},
|
|
131
135
|
body: JSON.stringify({
|
|
132
136
|
service: "cloudflare",
|
|
133
137
|
provider: context.provider,
|
|
@@ -138,7 +142,7 @@ var syncEdgeValue = async (context) => {
|
|
|
138
142
|
if (response.status === 403) {
|
|
139
143
|
console.log(
|
|
140
144
|
printMessage(
|
|
141
|
-
"Verifying domain ownership...this will only take a few minutes."
|
|
145
|
+
"Verifying domain ownership... this will only take a few minutes."
|
|
142
146
|
)
|
|
143
147
|
);
|
|
144
148
|
}
|
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
HEARTBEAT_CONTRACT_VERSION,
|
|
10
10
|
HEARTBEAT_RESPONSE_BODY_MAX_SERIALIZED_BYTES,
|
|
11
11
|
LOCKDOWN_TEST_EXPIRY_MS,
|
|
12
|
+
MIDDLEWARE_VERSION,
|
|
12
13
|
validateHeartbeatResponseBody
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FE7E5Q5F.js";
|
|
14
15
|
|
|
15
16
|
// src/utils/build-lock-page-url.ts
|
|
16
17
|
function normalizeLockPageSlug(lockPageSlug) {
|
|
@@ -121,9 +122,6 @@ var MemoryCache = class {
|
|
|
121
122
|
};
|
|
122
123
|
};
|
|
123
124
|
|
|
124
|
-
// src/version.ts
|
|
125
|
-
var MIDDLEWARE_VERSION = "3.13.2";
|
|
126
|
-
|
|
127
125
|
// src/utils/heartbeat.ts
|
|
128
126
|
var DEFAULT_HEARTBEAT_CONFIG_ERROR_CODE = "custom";
|
|
129
127
|
var DEFAULT_HEARTBEAT_CONFIG_ERROR_MESSAGE = "Appwarden configuration validation failed";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isHTMLResponse,
|
|
3
3
|
makeCSPHeader
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NC2TN3D5.js";
|
|
5
5
|
import {
|
|
6
6
|
UseCSPInputSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FE7E5Q5F.js";
|
|
8
8
|
|
|
9
9
|
// src/middlewares/use-content-security-policy.ts
|
|
10
10
|
var AppendAttribute = (attribute, nonce) => ({
|
package/cloudflare/astro.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Runtime } from '@astrojs/cloudflare';
|
|
2
1
|
import { MiddlewareHandler } from 'astro';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
|
|
@@ -352,12 +351,19 @@ type AstroCloudflareConfig = z.infer<typeof AstroCloudflareConfigSchema>;
|
|
|
352
351
|
type AstroCloudflareConfigInput = z.input<typeof AstroCloudflareConfigSchema>;
|
|
353
352
|
|
|
354
353
|
/**
|
|
355
|
-
* Cloudflare runtime context
|
|
356
|
-
* This is extracted from the locals object when using @astrojs/cloudflare adapter.
|
|
354
|
+
* Normalized Cloudflare runtime context exposed to Appwarden config functions.
|
|
357
355
|
*
|
|
358
|
-
*
|
|
356
|
+
* Astro v6 no longer exposes the old `locals.runtime` shape, so we compose the
|
|
357
|
+
* runtime from current Cloudflare primitives instead:
|
|
358
|
+
* - bindings from `cloudflare:workers`
|
|
359
|
+
* - cache storage from the global `caches`
|
|
360
|
+
* - execution context from `context.locals.cfContext`
|
|
359
361
|
*/
|
|
360
|
-
|
|
362
|
+
interface AstroCloudflareRuntime {
|
|
363
|
+
env: CloudflareEnv;
|
|
364
|
+
caches: CacheStorage;
|
|
365
|
+
ctx: ExecutionContext;
|
|
366
|
+
}
|
|
361
367
|
/**
|
|
362
368
|
* Configuration for the Appwarden middleware.
|
|
363
369
|
*
|
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-VVE7MFVZ.js";
|
|
5
|
+
import "../chunk-YPF5MTU3.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-GMWSGC6T.js";
|
|
13
13
|
import {
|
|
14
14
|
TEMPORARY_REDIRECT_STATUS,
|
|
15
15
|
buildLockPageUrl,
|
|
@@ -22,17 +22,17 @@ import {
|
|
|
22
22
|
isOnLockPage,
|
|
23
23
|
printMessage,
|
|
24
24
|
sanitizeConfigErrors
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-NC2TN3D5.js";
|
|
26
26
|
import {
|
|
27
27
|
AppwardenApiHostnameSchema,
|
|
28
28
|
AppwardenApiTokenSchema,
|
|
29
29
|
BooleanSchema,
|
|
30
30
|
HEARTBEAT_SERVICES,
|
|
31
31
|
UseCSPInputSchema
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-FE7E5Q5F.js";
|
|
33
33
|
|
|
34
34
|
// src/adapters/astro-cloudflare.ts
|
|
35
|
-
import { waitUntil } from "cloudflare:workers";
|
|
35
|
+
import { env as cloudflareEnv, waitUntil } from "cloudflare:workers";
|
|
36
36
|
|
|
37
37
|
// src/schemas/astro-cloudflare.ts
|
|
38
38
|
import { z } from "zod";
|
|
@@ -87,6 +87,16 @@ var createAstroHeartbeatResponse = (request, runtime, configFn) => {
|
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
+
var getAstroCloudflareRuntime = (locals) => {
|
|
91
|
+
if (!locals.cfContext) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
env: cloudflareEnv,
|
|
96
|
+
caches,
|
|
97
|
+
ctx: locals.cfContext
|
|
98
|
+
};
|
|
99
|
+
};
|
|
90
100
|
function createAppwardenMiddleware(configFn) {
|
|
91
101
|
return async (context, next) => {
|
|
92
102
|
const startTime = getNowMs();
|
|
@@ -117,15 +127,15 @@ function createAppwardenMiddleware(configFn) {
|
|
|
117
127
|
}
|
|
118
128
|
};
|
|
119
129
|
const locals = context.locals;
|
|
130
|
+
const runtime = getAstroCloudflareRuntime(locals);
|
|
120
131
|
if (isHeartbeatRequest(request, requestUrl)) {
|
|
121
|
-
return createAstroHeartbeatResponse(request,
|
|
132
|
+
return createAstroHeartbeatResponse(request, runtime, configFn);
|
|
122
133
|
}
|
|
123
134
|
try {
|
|
124
|
-
const runtime = locals.runtime;
|
|
125
135
|
if (!runtime) {
|
|
126
136
|
console.error(
|
|
127
137
|
printMessage(
|
|
128
|
-
"Cloudflare
|
|
138
|
+
"Cloudflare context not found. Ensure @astrojs/cloudflare adapter is configured."
|
|
129
139
|
)
|
|
130
140
|
);
|
|
131
141
|
return next();
|
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-GMWSGC6T.js";
|
|
11
11
|
import {
|
|
12
12
|
TEMPORARY_REDIRECT_STATUS,
|
|
13
13
|
buildLockPageUrl,
|
|
@@ -20,14 +20,14 @@ import {
|
|
|
20
20
|
makeCSPHeader,
|
|
21
21
|
printMessage,
|
|
22
22
|
sanitizeConfigErrors
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-NC2TN3D5.js";
|
|
24
24
|
import {
|
|
25
25
|
AppwardenApiHostnameSchema,
|
|
26
26
|
AppwardenApiTokenSchema,
|
|
27
27
|
BooleanSchema,
|
|
28
28
|
HEARTBEAT_SERVICES,
|
|
29
29
|
UseCSPInputSchema
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-FE7E5Q5F.js";
|
|
31
31
|
|
|
32
32
|
// src/adapters/nextjs-cloudflare.ts
|
|
33
33
|
import { getCloudflareContext } from "@opennextjs/cloudflare";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyContentSecurityPolicyToResponse,
|
|
3
3
|
isResponseLike
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-VVE7MFVZ.js";
|
|
5
|
+
import "../chunk-YPF5MTU3.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-GMWSGC6T.js";
|
|
13
13
|
import {
|
|
14
14
|
buildLockPageUrl,
|
|
15
15
|
createHeartbeatConfigError,
|
|
@@ -21,14 +21,14 @@ import {
|
|
|
21
21
|
isOnLockPage,
|
|
22
22
|
printMessage,
|
|
23
23
|
sanitizeConfigErrors
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-NC2TN3D5.js";
|
|
25
25
|
import {
|
|
26
26
|
AppwardenApiHostnameSchema,
|
|
27
27
|
AppwardenApiTokenSchema,
|
|
28
28
|
BooleanSchema,
|
|
29
29
|
HEARTBEAT_SERVICES,
|
|
30
30
|
UseCSPInputSchema
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-FE7E5Q5F.js";
|
|
32
32
|
|
|
33
33
|
// src/adapters/react-router-cloudflare.ts
|
|
34
34
|
import { waitUntil } from "cloudflare:workers";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyContentSecurityPolicyToResponse,
|
|
3
3
|
isResponseLike
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-VVE7MFVZ.js";
|
|
5
|
+
import "../chunk-YPF5MTU3.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-GMWSGC6T.js";
|
|
13
13
|
import {
|
|
14
14
|
buildLockPageUrl,
|
|
15
15
|
createHeartbeatConfigError,
|
|
@@ -21,14 +21,14 @@ import {
|
|
|
21
21
|
isOnLockPage,
|
|
22
22
|
printMessage,
|
|
23
23
|
sanitizeConfigErrors
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-NC2TN3D5.js";
|
|
25
25
|
import {
|
|
26
26
|
AppwardenApiHostnameSchema,
|
|
27
27
|
AppwardenApiTokenSchema,
|
|
28
28
|
BooleanSchema,
|
|
29
29
|
HEARTBEAT_SERVICES,
|
|
30
30
|
UseCSPInputSchema
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-FE7E5Q5F.js";
|
|
32
32
|
|
|
33
33
|
// src/adapters/tanstack-start-cloudflare.ts
|
|
34
34
|
import { waitUntil } from "cloudflare:workers";
|
package/cloudflare.d.ts
CHANGED
|
@@ -515,7 +515,6 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestCo
|
|
|
515
515
|
debug: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
|
|
516
516
|
}, "strip", z.ZodTypeAny, {
|
|
517
517
|
lockPageSlug: string;
|
|
518
|
-
debug?: boolean | undefined;
|
|
519
518
|
contentSecurityPolicy?: {
|
|
520
519
|
mode: "disabled" | "report-only" | "enforced";
|
|
521
520
|
directives?: {
|
|
@@ -547,9 +546,9 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestCo
|
|
|
547
546
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
548
547
|
} | undefined;
|
|
549
548
|
} | undefined;
|
|
549
|
+
debug?: boolean | undefined;
|
|
550
550
|
}, {
|
|
551
551
|
lockPageSlug: string;
|
|
552
|
-
debug?: string | boolean | undefined;
|
|
553
552
|
contentSecurityPolicy?: {
|
|
554
553
|
mode: "disabled" | "report-only" | "enforced";
|
|
555
554
|
directives: string | {
|
|
@@ -581,6 +580,7 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestCo
|
|
|
581
580
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
582
581
|
};
|
|
583
582
|
} | undefined;
|
|
583
|
+
debug?: string | boolean | undefined;
|
|
584
584
|
}>>>;
|
|
585
585
|
appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
|
|
586
586
|
appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
@@ -621,7 +621,6 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestCo
|
|
|
621
621
|
} | undefined;
|
|
622
622
|
multidomainConfig?: Record<string, {
|
|
623
623
|
lockPageSlug: string;
|
|
624
|
-
debug?: boolean | undefined;
|
|
625
624
|
contentSecurityPolicy?: {
|
|
626
625
|
mode: "disabled" | "report-only" | "enforced";
|
|
627
626
|
directives?: {
|
|
@@ -653,11 +652,11 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestCo
|
|
|
653
652
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
654
653
|
} | undefined;
|
|
655
654
|
} | undefined;
|
|
655
|
+
debug?: boolean | undefined;
|
|
656
656
|
}> | undefined;
|
|
657
657
|
appwardenApiHostname?: string | undefined;
|
|
658
658
|
}, {
|
|
659
659
|
appwardenApiToken: string;
|
|
660
|
-
debug?: string | boolean | undefined;
|
|
661
660
|
lockPageSlug?: string | undefined;
|
|
662
661
|
contentSecurityPolicy?: {
|
|
663
662
|
mode: "disabled" | "report-only" | "enforced";
|
|
@@ -690,9 +689,9 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestCo
|
|
|
690
689
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
691
690
|
};
|
|
692
691
|
} | undefined;
|
|
692
|
+
debug?: string | boolean | undefined;
|
|
693
693
|
multidomainConfig?: Record<string, {
|
|
694
694
|
lockPageSlug: string;
|
|
695
|
-
debug?: string | boolean | undefined;
|
|
696
695
|
contentSecurityPolicy?: {
|
|
697
696
|
mode: "disabled" | "report-only" | "enforced";
|
|
698
697
|
directives: string | {
|
|
@@ -724,6 +723,7 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<RequestCo
|
|
|
724
723
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
725
724
|
};
|
|
726
725
|
} | undefined;
|
|
726
|
+
debug?: string | boolean | undefined;
|
|
727
727
|
}> | undefined;
|
|
728
728
|
appwardenApiHostname?: string | undefined;
|
|
729
729
|
}>, any, any>>>;
|
package/cloudflare.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UseAppwardenInputSchema,
|
|
3
3
|
lockPageSlugRefinement
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HKPJZTYK.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-YPF5MTU3.js";
|
|
11
11
|
import {
|
|
12
12
|
checkLockStatus
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GMWSGC6T.js";
|
|
14
14
|
import {
|
|
15
15
|
buildLockPageUrl,
|
|
16
16
|
createHeartbeatConfigError,
|
|
@@ -22,10 +22,10 @@ import {
|
|
|
22
22
|
isOnLockPage,
|
|
23
23
|
printMessage,
|
|
24
24
|
sanitizeConfigErrors
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-NC2TN3D5.js";
|
|
26
26
|
import {
|
|
27
27
|
HEARTBEAT_SERVICES
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FE7E5Q5F.js";
|
|
29
29
|
|
|
30
30
|
// src/runners/appwarden-on-cloudflare.ts
|
|
31
31
|
import { ZodError } from "zod";
|
package/index.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ declare const HEARTBEAT_RESPONSE_BODY_MAX_SERIALIZED_BYTES: number;
|
|
|
33
33
|
*/
|
|
34
34
|
declare const HEARTBEAT_CONFIG_ERROR_MAX_PATH_SEGMENT_LENGTH = 100;
|
|
35
35
|
declare const APPWARDEN_CACHE_KEY: "appwarden-lock";
|
|
36
|
+
declare const APPWARDEN_MIDDLEWARE_USER_AGENT_PREFIX = "Appwarden/";
|
|
37
|
+
declare const APPWARDEN_MIDDLEWARE_USER_AGENT: string;
|
|
36
38
|
declare const HEARTBEAT_SERVICE_VALUES: readonly ["cloudflare", "cloudflare-astro", "cloudflare-react-router", "cloudflare-tanstack-start", "cloudflare-nextjs", "vercel"];
|
|
37
39
|
/**
|
|
38
40
|
* Service identifiers for different middleware adapters.
|
|
@@ -708,7 +710,6 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
708
710
|
debug: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>, boolean, string | boolean | undefined>>;
|
|
709
711
|
}, "strip", z.ZodTypeAny, {
|
|
710
712
|
lockPageSlug: string;
|
|
711
|
-
debug?: boolean | undefined;
|
|
712
713
|
contentSecurityPolicy?: {
|
|
713
714
|
mode: "disabled" | "report-only" | "enforced";
|
|
714
715
|
directives?: {
|
|
@@ -740,9 +741,9 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
740
741
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
741
742
|
} | undefined;
|
|
742
743
|
} | undefined;
|
|
744
|
+
debug?: boolean | undefined;
|
|
743
745
|
}, {
|
|
744
746
|
lockPageSlug: string;
|
|
745
|
-
debug?: string | boolean | undefined;
|
|
746
747
|
contentSecurityPolicy?: {
|
|
747
748
|
mode: "disabled" | "report-only" | "enforced";
|
|
748
749
|
directives: string | {
|
|
@@ -774,6 +775,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
774
775
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
775
776
|
};
|
|
776
777
|
} | undefined;
|
|
778
|
+
debug?: string | boolean | undefined;
|
|
777
779
|
}>>>;
|
|
778
780
|
appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
|
|
779
781
|
appwardenApiHostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
@@ -814,7 +816,6 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
814
816
|
} | undefined;
|
|
815
817
|
multidomainConfig?: Record<string, {
|
|
816
818
|
lockPageSlug: string;
|
|
817
|
-
debug?: boolean | undefined;
|
|
818
819
|
contentSecurityPolicy?: {
|
|
819
820
|
mode: "disabled" | "report-only" | "enforced";
|
|
820
821
|
directives?: {
|
|
@@ -846,11 +847,11 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
846
847
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
847
848
|
} | undefined;
|
|
848
849
|
} | undefined;
|
|
850
|
+
debug?: boolean | undefined;
|
|
849
851
|
}> | undefined;
|
|
850
852
|
appwardenApiHostname?: string | undefined;
|
|
851
853
|
}, {
|
|
852
854
|
appwardenApiToken: string;
|
|
853
|
-
debug?: string | boolean | undefined;
|
|
854
855
|
lockPageSlug?: string | undefined;
|
|
855
856
|
contentSecurityPolicy?: {
|
|
856
857
|
mode: "disabled" | "report-only" | "enforced";
|
|
@@ -883,9 +884,9 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
883
884
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
884
885
|
};
|
|
885
886
|
} | undefined;
|
|
887
|
+
debug?: string | boolean | undefined;
|
|
886
888
|
multidomainConfig?: Record<string, {
|
|
887
889
|
lockPageSlug: string;
|
|
888
|
-
debug?: string | boolean | undefined;
|
|
889
890
|
contentSecurityPolicy?: {
|
|
890
891
|
mode: "disabled" | "report-only" | "enforced";
|
|
891
892
|
directives: string | {
|
|
@@ -917,6 +918,7 @@ declare const UseAppwardenInputSchema: z.ZodObject<{
|
|
|
917
918
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
918
919
|
};
|
|
919
920
|
} | undefined;
|
|
921
|
+
debug?: string | boolean | undefined;
|
|
920
922
|
}> | undefined;
|
|
921
923
|
appwardenApiHostname?: string | undefined;
|
|
922
924
|
}>;
|
|
@@ -936,4 +938,4 @@ declare const LockValue: z.ZodObject<{
|
|
|
936
938
|
}>;
|
|
937
939
|
type LockValueType = z.infer<typeof LockValue>;
|
|
938
940
|
|
|
939
|
-
export { APPWARDEN_CACHE_KEY, APPWARDEN_HEARTBEAT_ROUTE, HEARTBEAT_CONFIG_ERRORS_MAX_SERIALIZED_BYTES, HEARTBEAT_CONFIG_ERROR_MAX_CODE_LENGTH, HEARTBEAT_CONFIG_ERROR_MAX_COUNT, HEARTBEAT_CONFIG_ERROR_MAX_MESSAGE_LENGTH, HEARTBEAT_CONFIG_ERROR_MAX_PATH_DEPTH, HEARTBEAT_CONFIG_ERROR_MAX_PATH_SEGMENT_LENGTH, HEARTBEAT_CONTRACT_VERSION, HEARTBEAT_RESPONSE_BODY_MAX_SERIALIZED_BYTES, HEARTBEAT_SERVICES, HEARTBEAT_SERVICE_VALUES, HEARTBEAT_VERSION_MAX_LENGTH, type HeartbeatConfigError, HeartbeatConfigErrorSchema, type HeartbeatResponseBody, HeartbeatResponseBodySchema, type HeartbeatService, LOCKDOWN_TEST_EXPIRY_MS, type LockValueType, UseAppwardenInputSchema, getEdgeConfigId, isCacheUrl, isValidCacheUrl, validateHeartbeatResponseBody };
|
|
941
|
+
export { APPWARDEN_CACHE_KEY, APPWARDEN_HEARTBEAT_ROUTE, APPWARDEN_MIDDLEWARE_USER_AGENT, APPWARDEN_MIDDLEWARE_USER_AGENT_PREFIX, HEARTBEAT_CONFIG_ERRORS_MAX_SERIALIZED_BYTES, HEARTBEAT_CONFIG_ERROR_MAX_CODE_LENGTH, HEARTBEAT_CONFIG_ERROR_MAX_COUNT, HEARTBEAT_CONFIG_ERROR_MAX_MESSAGE_LENGTH, HEARTBEAT_CONFIG_ERROR_MAX_PATH_DEPTH, HEARTBEAT_CONFIG_ERROR_MAX_PATH_SEGMENT_LENGTH, HEARTBEAT_CONTRACT_VERSION, HEARTBEAT_RESPONSE_BODY_MAX_SERIALIZED_BYTES, HEARTBEAT_SERVICES, HEARTBEAT_SERVICE_VALUES, HEARTBEAT_VERSION_MAX_LENGTH, type HeartbeatConfigError, HeartbeatConfigErrorSchema, type HeartbeatResponseBody, HeartbeatResponseBodySchema, type HeartbeatService, LOCKDOWN_TEST_EXPIRY_MS, type LockValueType, UseAppwardenInputSchema, getEdgeConfigId, isCacheUrl, isValidCacheUrl, validateHeartbeatResponseBody };
|
package/index.js
CHANGED
|
@@ -5,10 +5,12 @@ import {
|
|
|
5
5
|
} from "./chunk-QEFORWCW.js";
|
|
6
6
|
import {
|
|
7
7
|
UseAppwardenInputSchema
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HKPJZTYK.js";
|
|
9
9
|
import {
|
|
10
10
|
APPWARDEN_CACHE_KEY,
|
|
11
11
|
APPWARDEN_HEARTBEAT_ROUTE,
|
|
12
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT,
|
|
13
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT_PREFIX,
|
|
12
14
|
CSPDirectivesSchema,
|
|
13
15
|
CSPModeSchema,
|
|
14
16
|
HEARTBEAT_CONFIG_ERRORS_MAX_SERIALIZED_BYTES,
|
|
@@ -26,10 +28,12 @@ import {
|
|
|
26
28
|
HeartbeatResponseBodySchema,
|
|
27
29
|
LOCKDOWN_TEST_EXPIRY_MS,
|
|
28
30
|
validateHeartbeatResponseBody
|
|
29
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-FE7E5Q5F.js";
|
|
30
32
|
export {
|
|
31
33
|
APPWARDEN_CACHE_KEY,
|
|
32
34
|
APPWARDEN_HEARTBEAT_ROUTE,
|
|
35
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT,
|
|
36
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT_PREFIX,
|
|
33
37
|
CSPDirectivesSchema,
|
|
34
38
|
CSPModeSchema,
|
|
35
39
|
HEARTBEAT_CONFIG_ERRORS_MAX_SERIALIZED_BYTES,
|
package/package.json
CHANGED
package/vercel.d.ts
CHANGED
|
@@ -318,7 +318,6 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
318
318
|
lockPageSlug: string;
|
|
319
319
|
appwardenApiToken: string;
|
|
320
320
|
cacheUrl: string;
|
|
321
|
-
debug?: boolean | undefined;
|
|
322
321
|
contentSecurityPolicy?: {
|
|
323
322
|
mode: "disabled" | "report-only" | "enforced";
|
|
324
323
|
directives?: {
|
|
@@ -350,12 +349,12 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
350
349
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
351
350
|
} | undefined;
|
|
352
351
|
} | undefined;
|
|
352
|
+
debug?: boolean | undefined;
|
|
353
353
|
appwardenApiHostname?: string | undefined;
|
|
354
354
|
vercelApiToken?: string | undefined;
|
|
355
355
|
}, {
|
|
356
356
|
appwardenApiToken: string;
|
|
357
357
|
cacheUrl: string;
|
|
358
|
-
debug?: boolean | undefined;
|
|
359
358
|
lockPageSlug?: string | undefined;
|
|
360
359
|
contentSecurityPolicy?: {
|
|
361
360
|
mode: "disabled" | "report-only" | "enforced";
|
|
@@ -388,13 +387,13 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
388
387
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
389
388
|
};
|
|
390
389
|
} | undefined;
|
|
390
|
+
debug?: boolean | undefined;
|
|
391
391
|
appwardenApiHostname?: string | undefined;
|
|
392
392
|
vercelApiToken?: string | undefined;
|
|
393
393
|
}>, {
|
|
394
394
|
lockPageSlug: string;
|
|
395
395
|
appwardenApiToken: string;
|
|
396
396
|
cacheUrl: string;
|
|
397
|
-
debug?: boolean | undefined;
|
|
398
397
|
contentSecurityPolicy?: {
|
|
399
398
|
mode: "disabled" | "report-only" | "enforced";
|
|
400
399
|
directives?: {
|
|
@@ -426,12 +425,12 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
426
425
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
427
426
|
} | undefined;
|
|
428
427
|
} | undefined;
|
|
428
|
+
debug?: boolean | undefined;
|
|
429
429
|
appwardenApiHostname?: string | undefined;
|
|
430
430
|
vercelApiToken?: string | undefined;
|
|
431
431
|
}, {
|
|
432
432
|
appwardenApiToken: string;
|
|
433
433
|
cacheUrl: string;
|
|
434
|
-
debug?: boolean | undefined;
|
|
435
434
|
lockPageSlug?: string | undefined;
|
|
436
435
|
contentSecurityPolicy?: {
|
|
437
436
|
mode: "disabled" | "report-only" | "enforced";
|
|
@@ -464,13 +463,13 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
464
463
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
465
464
|
};
|
|
466
465
|
} | undefined;
|
|
466
|
+
debug?: boolean | undefined;
|
|
467
467
|
appwardenApiHostname?: string | undefined;
|
|
468
468
|
vercelApiToken?: string | undefined;
|
|
469
469
|
}>, {
|
|
470
470
|
lockPageSlug: string;
|
|
471
471
|
appwardenApiToken: string;
|
|
472
472
|
cacheUrl: string;
|
|
473
|
-
debug?: boolean | undefined;
|
|
474
473
|
contentSecurityPolicy?: {
|
|
475
474
|
mode: "disabled" | "report-only" | "enforced";
|
|
476
475
|
directives?: {
|
|
@@ -502,12 +501,12 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
502
501
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
503
502
|
} | undefined;
|
|
504
503
|
} | undefined;
|
|
504
|
+
debug?: boolean | undefined;
|
|
505
505
|
appwardenApiHostname?: string | undefined;
|
|
506
506
|
vercelApiToken?: string | undefined;
|
|
507
507
|
}, {
|
|
508
508
|
appwardenApiToken: string;
|
|
509
509
|
cacheUrl: string;
|
|
510
|
-
debug?: boolean | undefined;
|
|
511
510
|
lockPageSlug?: string | undefined;
|
|
512
511
|
contentSecurityPolicy?: {
|
|
513
512
|
mode: "disabled" | "report-only" | "enforced";
|
|
@@ -540,13 +539,13 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
540
539
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
541
540
|
};
|
|
542
541
|
} | undefined;
|
|
542
|
+
debug?: boolean | undefined;
|
|
543
543
|
appwardenApiHostname?: string | undefined;
|
|
544
544
|
vercelApiToken?: string | undefined;
|
|
545
545
|
}>, {
|
|
546
546
|
lockPageSlug: string;
|
|
547
547
|
appwardenApiToken: string;
|
|
548
548
|
cacheUrl: string;
|
|
549
|
-
debug?: boolean | undefined;
|
|
550
549
|
contentSecurityPolicy?: {
|
|
551
550
|
mode: "disabled" | "report-only" | "enforced";
|
|
552
551
|
directives?: {
|
|
@@ -578,12 +577,12 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
578
577
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
579
578
|
} | undefined;
|
|
580
579
|
} | undefined;
|
|
580
|
+
debug?: boolean | undefined;
|
|
581
581
|
appwardenApiHostname?: string | undefined;
|
|
582
582
|
vercelApiToken?: string | undefined;
|
|
583
583
|
}, {
|
|
584
584
|
appwardenApiToken: string;
|
|
585
585
|
cacheUrl: string;
|
|
586
|
-
debug?: boolean | undefined;
|
|
587
586
|
lockPageSlug?: string | undefined;
|
|
588
587
|
contentSecurityPolicy?: {
|
|
589
588
|
mode: "disabled" | "report-only" | "enforced";
|
|
@@ -616,13 +615,13 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
616
615
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
617
616
|
};
|
|
618
617
|
} | undefined;
|
|
618
|
+
debug?: boolean | undefined;
|
|
619
619
|
appwardenApiHostname?: string | undefined;
|
|
620
620
|
vercelApiToken?: string | undefined;
|
|
621
621
|
}>, {
|
|
622
622
|
lockPageSlug: string;
|
|
623
623
|
appwardenApiToken: string;
|
|
624
624
|
cacheUrl: string;
|
|
625
|
-
debug?: boolean | undefined;
|
|
626
625
|
contentSecurityPolicy?: {
|
|
627
626
|
mode: "disabled" | "report-only" | "enforced";
|
|
628
627
|
directives?: {
|
|
@@ -654,12 +653,12 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
654
653
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
655
654
|
} | undefined;
|
|
656
655
|
} | undefined;
|
|
656
|
+
debug?: boolean | undefined;
|
|
657
657
|
appwardenApiHostname?: string | undefined;
|
|
658
658
|
vercelApiToken?: string | undefined;
|
|
659
659
|
}, {
|
|
660
660
|
appwardenApiToken: string;
|
|
661
661
|
cacheUrl: string;
|
|
662
|
-
debug?: boolean | undefined;
|
|
663
662
|
lockPageSlug?: string | undefined;
|
|
664
663
|
contentSecurityPolicy?: {
|
|
665
664
|
mode: "disabled" | "report-only" | "enforced";
|
|
@@ -692,6 +691,7 @@ declare const AppwardenConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.Zo
|
|
|
692
691
|
"require-trusted-types-for"?: string | boolean | string[] | undefined;
|
|
693
692
|
};
|
|
694
693
|
} | undefined;
|
|
694
|
+
debug?: boolean | undefined;
|
|
695
695
|
appwardenApiHostname?: string | undefined;
|
|
696
696
|
vercelApiToken?: string | undefined;
|
|
697
697
|
}>;
|
package/vercel.js
CHANGED
|
@@ -20,9 +20,10 @@ import {
|
|
|
20
20
|
makeCSPHeader,
|
|
21
21
|
printMessage,
|
|
22
22
|
sanitizeConfigErrors
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-NC2TN3D5.js";
|
|
24
24
|
import {
|
|
25
25
|
APPWARDEN_CACHE_KEY,
|
|
26
|
+
APPWARDEN_MIDDLEWARE_USER_AGENT,
|
|
26
27
|
AppwardenApiHostnameSchema,
|
|
27
28
|
CSPDirectivesSchema,
|
|
28
29
|
CSPModeSchema,
|
|
@@ -30,7 +31,7 @@ import {
|
|
|
30
31
|
LockValue,
|
|
31
32
|
errors,
|
|
32
33
|
globalErrors
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-FE7E5Q5F.js";
|
|
34
35
|
|
|
35
36
|
// src/runners/appwarden-on-vercel.ts
|
|
36
37
|
import { waitUntil } from "@vercel/functions";
|
|
@@ -116,7 +117,10 @@ var syncEdgeValue = async (context) => {
|
|
|
116
117
|
const apiHostname = context.appwardenApiHostname ?? "https://api.appwarden.io";
|
|
117
118
|
const response = await fetch(new URL("/v1/appwarden/status", apiHostname), {
|
|
118
119
|
method: "POST",
|
|
119
|
-
headers: {
|
|
120
|
+
headers: {
|
|
121
|
+
"content-type": "application/json",
|
|
122
|
+
"user-agent": APPWARDEN_MIDDLEWARE_USER_AGENT
|
|
123
|
+
},
|
|
120
124
|
body: JSON.stringify({
|
|
121
125
|
service: "vercel",
|
|
122
126
|
cacheUrl: context.cacheUrl,
|
|
@@ -128,7 +132,7 @@ var syncEdgeValue = async (context) => {
|
|
|
128
132
|
if (response.status === 403) {
|
|
129
133
|
console.log(
|
|
130
134
|
printMessage(
|
|
131
|
-
"Verifying domain ownership...this will only take a few minutes."
|
|
135
|
+
"Verifying domain ownership... this will only take a few minutes."
|
|
132
136
|
)
|
|
133
137
|
);
|
|
134
138
|
}
|