@void/edge 1.4.0 → 1.5.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/dist/index.d.mts +0 -16
- package/dist/index.mjs +7 -14
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AssetConfig, AssetConfig as AssetConfig$1, HeaderRule, HeaderRule as HeaderRule$1, RedirectRule, RedirectRule as RedirectRule$1 } from "@void/deploy-core";
|
|
2
|
-
//#region src/access.d.ts
|
|
3
2
|
type ProjectZeroTrustRouting = Readonly<{
|
|
4
3
|
teamDomain: string;
|
|
5
4
|
audiences: ReadonlyArray<Readonly<{
|
|
@@ -7,12 +6,8 @@ type ProjectZeroTrustRouting = Readonly<{
|
|
|
7
6
|
audience: string;
|
|
8
7
|
}>>;
|
|
9
8
|
}>;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/https.d.ts
|
|
12
9
|
/** Upgrade public HTTP requests without involving assets or application code. */
|
|
13
10
|
export declare function redirectToHttps(request: Request): Response | undefined;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/headers.d.ts
|
|
16
11
|
type HeaderRulePolicy = Readonly<{
|
|
17
12
|
/**
|
|
18
13
|
* Protect unrelated tenants that share one registrable domain. Direct
|
|
@@ -58,8 +53,6 @@ export declare function sanitizeClearSiteData(value: string): string | null;
|
|
|
58
53
|
* Returns the original response unchanged when no rules or no matches.
|
|
59
54
|
*/
|
|
60
55
|
export declare function applyHeaderRules(response: Response, pathname: string, rules?: ReadonlyArray<HeaderRule$1>, policy?: HeaderRulePolicy): Response;
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/pattern.d.ts
|
|
63
56
|
type CompiledPattern = Readonly<{
|
|
64
57
|
/**
|
|
65
58
|
* @deprecated Built on first read for older callers; Void does not use it.
|
|
@@ -112,8 +105,6 @@ export declare function matchSegmentPattern(pattern: string, pathname: string):
|
|
|
112
105
|
* because `compilePattern` captures anonymous `*` as `splat`.
|
|
113
106
|
*/
|
|
114
107
|
export declare function substituteParams(destination: string, params: Record<string, string>): string;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/routing-rules.d.ts
|
|
117
108
|
type RoutingRuleResult = {
|
|
118
109
|
type: "redirect";
|
|
119
110
|
destination: string;
|
|
@@ -151,8 +142,6 @@ export declare function applyRoutingRules(pathname: string, rules?: ReadonlyArra
|
|
|
151
142
|
* rather than `/new#faq?utm=x` (which browsers treat as fragment text).
|
|
152
143
|
*/
|
|
153
144
|
export declare function mergeQueryIntoLocation(destination: string, requestSearch: string): string;
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/runtime.d.ts
|
|
156
145
|
type EdgeAssetFetcher = Readonly<{
|
|
157
146
|
fetch(request: Request): Promise<Response>;
|
|
158
147
|
}>;
|
|
@@ -183,8 +172,6 @@ type StaticEdgeHandler = Readonly<{
|
|
|
183
172
|
* miss, and response-header rules apply to the effective pathname.
|
|
184
173
|
*/
|
|
185
174
|
export declare function createStaticEdgeHandler(config: StaticEdgeConfig): StaticEdgeHandler;
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/static.d.ts
|
|
188
175
|
type ResolvedAsset = Readonly<{
|
|
189
176
|
path: string;
|
|
190
177
|
hash: string;
|
|
@@ -247,8 +234,6 @@ export declare function getContentType(path: string): string;
|
|
|
247
234
|
* Any other stored value is authoritative and honored as-is.
|
|
248
235
|
*/
|
|
249
236
|
export declare function resolveAssetContentType(stored: string | null | undefined, path: string): string | undefined;
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/limits.d.ts
|
|
252
237
|
/** Shared between the SDK, edge admission and Pages clients. */
|
|
253
238
|
type UsageLimitData = {
|
|
254
239
|
code: "usage_limit";
|
|
@@ -259,5 +244,4 @@ type UsageLimitData = {
|
|
|
259
244
|
};
|
|
260
245
|
export declare function readUsageLimit(value: unknown): UsageLimitData | null;
|
|
261
246
|
export declare function usageLimitResponse(limit: UsageLimitData): Response;
|
|
262
|
-
//#endregion
|
|
263
247
|
export type { AssetConfig, ClearSiteDataMember, CompiledPattern, EdgeAssetFetcher, HeaderRule, HeaderRulePolicy, ProjectZeroTrustRouting, RedirectRule, ResolvedAsset, RoutingRuleResult, StaticEdgeConfig, StaticEdgeEnv, StaticEdgeHandler, UsageLimitData };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/https.ts
|
|
2
2
|
/** Upgrade public HTTP requests without involving assets or application code. */
|
|
3
3
|
function redirectToHttps(request) {
|
|
4
4
|
const url = new URL(request.url);
|
|
@@ -15,8 +15,7 @@ function isIpv4Loopback(hostname) {
|
|
|
15
15
|
const parts = hostname.split(".");
|
|
16
16
|
return parts.length === 4 && parts[0] === "127" && parts.every((part) => part !== "" && [...part].every((char) => char >= "0" && char <= "9"));
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
//#region src/pattern.ts
|
|
18
|
+
// src/pattern.ts
|
|
20
19
|
/**
|
|
21
20
|
* Path-pattern matchers shared by routing, header, and revalidate rules.
|
|
22
21
|
*
|
|
@@ -384,8 +383,7 @@ function substituteParams(destination, params) {
|
|
|
384
383
|
if (/^[/\\]{2}/.test(result) && !/^[/\\]{2}/.test(destination)) return "/" + result.replace(/^[/\\]+/, "");
|
|
385
384
|
return result;
|
|
386
385
|
}
|
|
387
|
-
|
|
388
|
-
//#region src/headers.ts
|
|
386
|
+
// src/headers.ts
|
|
389
387
|
/**
|
|
390
388
|
* Headers that rules may never set on a shared domain. void.app is not on the
|
|
391
389
|
* Public Suffix List, so a `Set-Cookie` with `Domain=.void.app` reaches every
|
|
@@ -496,8 +494,7 @@ function applyHeaderRules(response, pathname, rules, policy) {
|
|
|
496
494
|
}
|
|
497
495
|
return newResponse;
|
|
498
496
|
}
|
|
499
|
-
|
|
500
|
-
//#region src/routing-rules.ts
|
|
497
|
+
// src/routing-rules.ts
|
|
501
498
|
/**
|
|
502
499
|
* Check routing rules (redirects + rewrites) against a request pathname.
|
|
503
500
|
*
|
|
@@ -563,8 +560,7 @@ function mergeQueryIntoLocation(destination, requestSearch) {
|
|
|
563
560
|
for (const [key, value] of reqParams) if (!destParams.has(key)) destParams.append(key, value);
|
|
564
561
|
return base.slice(0, destQueryIdx) + "?" + destParams.toString() + fragment;
|
|
565
562
|
}
|
|
566
|
-
|
|
567
|
-
//#region src/runtime.ts
|
|
563
|
+
// src/runtime.ts
|
|
568
564
|
/**
|
|
569
565
|
* Create the thin Worker used by direct static, SPA, and SSG deployments.
|
|
570
566
|
* Routing semantics intentionally match the hosted dispatch Worker: redirects
|
|
@@ -621,8 +617,7 @@ function rewriteRequest(request, url, originalUrl) {
|
|
|
621
617
|
rewritten.headers.set("X-Void-Original-URL", originalUrl);
|
|
622
618
|
return rewritten;
|
|
623
619
|
}
|
|
624
|
-
|
|
625
|
-
//#region src/static.ts
|
|
620
|
+
// src/static.ts
|
|
626
621
|
/**
|
|
627
622
|
* Percent-decode a request pathname for a manifest lookup, honoring required
|
|
628
623
|
* URL encodings and encoded square brackets. Returns the raw value unchanged
|
|
@@ -852,8 +847,7 @@ function resolveAssetContentType(stored, path) {
|
|
|
852
847
|
if (!stored || stored === "application/octet-stream") return getContentType(path);
|
|
853
848
|
return stored;
|
|
854
849
|
}
|
|
855
|
-
|
|
856
|
-
//#region src/limits.ts
|
|
850
|
+
// src/limits.ts
|
|
857
851
|
function readUsageLimit(value) {
|
|
858
852
|
if (!value || typeof value !== "object") return null;
|
|
859
853
|
const v = value;
|
|
@@ -885,5 +879,4 @@ function usageLimitResponse(limit) {
|
|
|
885
879
|
headers
|
|
886
880
|
});
|
|
887
881
|
}
|
|
888
|
-
//#endregion
|
|
889
882
|
export { applyHeaderRules, applyRoutingRules, compilePattern, createStaticEdgeHandler, getContentType, matchLiteralPattern, matchPattern, matchPatternCaptures, matchSegmentPattern, mergeQueryIntoLocation, parseClearSiteData, readUsageLimit, redirectToHttps, resolveAssetContentType, resolveStaticPath, safeDecodePathname, sanitizeClearSiteData, substituteParams, usageLimitResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/edge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Routing, headers, and static asset helpers for Void runtimes.",
|
|
5
5
|
"homepage": "https://void.cloud",
|
|
6
6
|
"bugs": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@void/deploy-core": "1.
|
|
29
|
+
"@void/deploy-core": "1.5.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@cloudflare/workers-types": "^5.
|
|
32
|
+
"@cloudflare/workers-types": "^5.20261102.1",
|
|
33
33
|
"typescript": "7.0.2",
|
|
34
|
-
"vite-plus": "1.
|
|
34
|
+
"vite-plus": "1.4.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "vp pack",
|