@klnap/next-proxy-chain 3.0.0 → 3.0.2
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -7
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6152c52: Add top-level `main` and `types` entries so TypeScript projects that use `moduleResolution: "node"` resolve the package types. Next.js 15 generates that setting by default, and it ignored the `exports` map, so `import { chain } from "@klnap/next-proxy-chain"` failed type checking. Runtime exports and the `exports` map are unchanged.
|
|
8
|
+
|
|
9
|
+
## 3.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8a67a83: Fix host scope matching when several host regular expressions are declared together. Each alternative is now compiled independently, so backreferences in one alternative no longer bind to another alternative's capture group.
|
|
14
|
+
|
|
3
15
|
## 3.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -353,7 +353,7 @@ Formatted and structured traces omit header values, cookie values, raw query val
|
|
|
353
353
|
|
|
354
354
|
The package declares `next >=15.0.0` as a peer dependency and Node.js `>=20.0.0`. It provides ESM and CommonJS entrypoints with TypeScript declarations.
|
|
355
355
|
|
|
356
|
-
Packed consumer builds and live requests were verified with Next.js 15.5.29 and 16.
|
|
356
|
+
Packed consumer builds and live requests were verified with Next.js 15.5.29 and 16.4.6 on Node.js 26.13.1. This does not verify every version in the peer range. Next.js 15 Edge deployments have not been independently verified.
|
|
357
357
|
|
|
358
358
|
## Documentation
|
|
359
359
|
|
package/dist/index.cjs
CHANGED
|
@@ -476,11 +476,10 @@ function hostGlobToRegex(value) {
|
|
|
476
476
|
}
|
|
477
477
|
function host(matcher) {
|
|
478
478
|
const list = Array.isArray(matcher) ? matcher : [matcher];
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return
|
|
479
|
+
return list.map((m) => {
|
|
480
|
+
const source = m instanceof RegExp ? m.source : hostGlobToRegex(m);
|
|
481
|
+
return new RegExp(`^(?:${source})$`, "i");
|
|
482
482
|
});
|
|
483
|
-
return toStatelessRegExp(new RegExp(`^(?:${parts.join("|")})$`, "i"));
|
|
484
483
|
}
|
|
485
484
|
function isScopeObject(value) {
|
|
486
485
|
return "host" in value || "path" in value;
|
|
@@ -567,7 +566,7 @@ function compileScopes(input) {
|
|
|
567
566
|
}
|
|
568
567
|
function scopeMatches(pathname, hostname, scope) {
|
|
569
568
|
if (scope.host) {
|
|
570
|
-
if (!hostname || !scope.host.test(hostname)) return false;
|
|
569
|
+
if (!hostname || !scope.host.some((alternative) => alternative.test(hostname))) return false;
|
|
571
570
|
}
|
|
572
571
|
if (scope.path) {
|
|
573
572
|
if (!scope.path.some((alternative) => alternative.test(pathname))) return false;
|
|
@@ -589,7 +588,7 @@ function toRule(entry) {
|
|
|
589
588
|
);
|
|
590
589
|
}
|
|
591
590
|
return {
|
|
592
|
-
host: s.host
|
|
591
|
+
host: s.host?.map(toStatelessRegExp),
|
|
593
592
|
path: s.path?.map(toStatelessRegExp)
|
|
594
593
|
};
|
|
595
594
|
});
|
|
@@ -635,7 +634,8 @@ function canonicalPathname(pathname) {
|
|
|
635
634
|
}
|
|
636
635
|
function scopeKey(scope) {
|
|
637
636
|
const path2 = scope.path?.map((alternative) => `${alternative.source}::${alternative.flags}`).join("&");
|
|
638
|
-
|
|
637
|
+
const hostKey = scope.host?.map((alternative) => `${alternative.source}::${alternative.flags}`).join("&");
|
|
638
|
+
return `${hostKey ?? "*"}|${path2 ?? "*"}`;
|
|
639
639
|
}
|
|
640
640
|
function assertIncludeExcludeNoOverlap(include, exclude, label) {
|
|
641
641
|
if (!include?.length || !exclude?.length) return;
|
package/dist/index.d.cts
CHANGED
|
@@ -121,7 +121,8 @@ type RouteScopeInput = PathMatcher | {
|
|
|
121
121
|
type RouteScopeList = RouteScopeInput | RouteScopeInput[];
|
|
122
122
|
/** Compiled route scope evaluated during request execution. */
|
|
123
123
|
type CompiledScope = {
|
|
124
|
-
|
|
124
|
+
/** Independent alternatives with OR semantics; each is anchored and case-insensitive. */
|
|
125
|
+
host?: RegExp[];
|
|
125
126
|
/** Independent alternatives with OR semantics; each keeps its own flags. */
|
|
126
127
|
path?: RegExp[];
|
|
127
128
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -121,7 +121,8 @@ type RouteScopeInput = PathMatcher | {
|
|
|
121
121
|
type RouteScopeList = RouteScopeInput | RouteScopeInput[];
|
|
122
122
|
/** Compiled route scope evaluated during request execution. */
|
|
123
123
|
type CompiledScope = {
|
|
124
|
-
|
|
124
|
+
/** Independent alternatives with OR semantics; each is anchored and case-insensitive. */
|
|
125
|
+
host?: RegExp[];
|
|
125
126
|
/** Independent alternatives with OR semantics; each keeps its own flags. */
|
|
126
127
|
path?: RegExp[];
|
|
127
128
|
};
|
package/dist/index.js
CHANGED
|
@@ -449,11 +449,10 @@ function hostGlobToRegex(value) {
|
|
|
449
449
|
}
|
|
450
450
|
function host(matcher) {
|
|
451
451
|
const list = Array.isArray(matcher) ? matcher : [matcher];
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return
|
|
452
|
+
return list.map((m) => {
|
|
453
|
+
const source = m instanceof RegExp ? m.source : hostGlobToRegex(m);
|
|
454
|
+
return new RegExp(`^(?:${source})$`, "i");
|
|
455
455
|
});
|
|
456
|
-
return toStatelessRegExp(new RegExp(`^(?:${parts.join("|")})$`, "i"));
|
|
457
456
|
}
|
|
458
457
|
function isScopeObject(value) {
|
|
459
458
|
return "host" in value || "path" in value;
|
|
@@ -540,7 +539,7 @@ function compileScopes(input) {
|
|
|
540
539
|
}
|
|
541
540
|
function scopeMatches(pathname, hostname, scope) {
|
|
542
541
|
if (scope.host) {
|
|
543
|
-
if (!hostname || !scope.host.test(hostname)) return false;
|
|
542
|
+
if (!hostname || !scope.host.some((alternative) => alternative.test(hostname))) return false;
|
|
544
543
|
}
|
|
545
544
|
if (scope.path) {
|
|
546
545
|
if (!scope.path.some((alternative) => alternative.test(pathname))) return false;
|
|
@@ -562,7 +561,7 @@ function toRule(entry) {
|
|
|
562
561
|
);
|
|
563
562
|
}
|
|
564
563
|
return {
|
|
565
|
-
host: s.host
|
|
564
|
+
host: s.host?.map(toStatelessRegExp),
|
|
566
565
|
path: s.path?.map(toStatelessRegExp)
|
|
567
566
|
};
|
|
568
567
|
});
|
|
@@ -608,7 +607,8 @@ function canonicalPathname(pathname) {
|
|
|
608
607
|
}
|
|
609
608
|
function scopeKey(scope) {
|
|
610
609
|
const path2 = scope.path?.map((alternative) => `${alternative.source}::${alternative.flags}`).join("&");
|
|
611
|
-
|
|
610
|
+
const hostKey = scope.host?.map((alternative) => `${alternative.source}::${alternative.flags}`).join("&");
|
|
611
|
+
return `${hostKey ?? "*"}|${path2 ?? "*"}`;
|
|
612
612
|
}
|
|
613
613
|
function assertIncludeExcludeNoOverlap(include, exclude, label) {
|
|
614
614
|
if (!include?.length || !exclude?.length) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klnap/next-proxy-chain",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Composable proxy and middleware for Next.js.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
"docs/guides.md",
|
|
43
43
|
"docs/security.md"
|
|
44
44
|
],
|
|
45
|
+
"main": "./dist/index.cjs",
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
45
47
|
"exports": {
|
|
46
48
|
".": {
|
|
47
49
|
"import": {
|
|
@@ -80,7 +82,7 @@
|
|
|
80
82
|
"@changesets/cli": "3.0.3",
|
|
81
83
|
"@types/bun": "1.4.5",
|
|
82
84
|
"@types/node": "^20",
|
|
83
|
-
"next": "16.
|
|
85
|
+
"next": "16.4.6",
|
|
84
86
|
"npm": "12.2.3",
|
|
85
87
|
"publint": "0.3.25",
|
|
86
88
|
"tsup": "8.5.1",
|