@amerged/ohmyhost-mcp 0.1.31 → 0.1.32

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.
@@ -1,21 +1,163 @@
1
1
  export const PINNED_BUN_VERSION = "1.2.22";
2
2
 
3
3
  /**
4
- * The installed Next.js release must satisfy the same window as source admission.
4
+ * @typedef {"next" | "vite" | "@tanstack/react-start"} FrameworkVersionPackage
5
+ * @typedef {Readonly<{
6
+ * floors: readonly string[];
7
+ * denied: readonly (readonly [string, string | null])[];
8
+ * }>} FrameworkVersionPolicyEntry
9
+ * @typedef {Readonly<Record<FrameworkVersionPackage, FrameworkVersionPolicyEntry>>} FrameworkVersionPolicy
10
+ */
11
+
12
+ /**
13
+ * Security floors per framework package. A stable release is admitted when it is at or above the
14
+ * highest floor whose major is not above its own major, and outside every denied range. There is no
15
+ * upper bound: later patches, minors and majors reach the real build, which reports adapter failures.
16
+ * Denied ranges are half-open [introduced, fixed); a null fix denies every later release.
17
+ *
18
+ * next: GHSA-4jqv-mc3x-m676 and GHSA-mcj8-r9mp-w47p (fixed in 15.5.27 and 16.3.8); GHSA-cjq9-62q9-8jv4,
19
+ * GHSA-f87g-xv8r-7p7x, GHSA-3w37-wq28-93x7, GHSA-h694-7cp9-m8p3 and GHSA-39w2-rjm5-chcv (16.3.8).
20
+ * @tanstack/react-start: GHSA-qx66-fv34-fjm8 (fixed in 1.168.60).
21
+ * vite: GHSA-64vr-g452-qvp3 (fixed in 5.4.6), the only advisory affecting `vite build` output.
22
+ * @type {FrameworkVersionPolicy}
23
+ */
24
+ export const FRAMEWORK_VERSION_POLICY = Object.freeze({
25
+ next: Object.freeze({ floors: Object.freeze(["15.5.27", "16.3.8"]), denied: Object.freeze([]) }),
26
+ vite: Object.freeze({ floors: Object.freeze(["5.4.6"]), denied: Object.freeze([]) }),
27
+ "@tanstack/react-start": Object.freeze({
28
+ floors: Object.freeze(["1.168.60"]),
29
+ denied: Object.freeze([]),
30
+ }),
31
+ });
32
+
33
+ const STABLE_VERSION = /^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/u;
34
+
35
+ /**
5
36
  * @param {unknown} version
6
- * @returns {boolean}
37
+ * @returns {readonly [number, number, number] | null}
7
38
  */
8
- export function isAdmittedNextVersion(version) {
9
- if (typeof version !== "string") return false;
10
- const match = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/u.exec(version);
11
- if (match === null) return false;
12
- const major = Number(match[1]);
13
- const minor = Number(match[2]);
14
- const patch = Number(match[3]);
15
- if (![major, minor, patch].every(Number.isSafeInteger)) return false;
16
- return (
17
- (major === 15 && minor === 5 && patch >= 26) || (major === 16 && minor === 3 && patch === 8)
18
- );
39
+ export function parseStableVersion(version) {
40
+ if (typeof version !== "string") return null;
41
+ const match = STABLE_VERSION.exec(version);
42
+ return match === null
43
+ ? null
44
+ : Object.freeze([Number(match[1]), Number(match[2]), Number(match[3])]);
45
+ }
46
+
47
+ /**
48
+ * @param {readonly [number, number, number]} left
49
+ * @param {readonly [number, number, number]} right
50
+ * @returns {number}
51
+ */
52
+ export function compareStableVersions(left, right) {
53
+ return left[0] - right[0] || left[1] - right[1] || left[2] - right[2];
54
+ }
55
+
56
+ /**
57
+ * @param {unknown} packageName
58
+ * @param {FrameworkVersionPolicy} policy
59
+ * @returns {FrameworkVersionPolicyEntry | null}
60
+ */
61
+ function packagePolicy(packageName, policy) {
62
+ return typeof packageName === "string" && Object.hasOwn(policy, packageName)
63
+ ? policy[/** @type {FrameworkVersionPackage} */ (packageName)]
64
+ : null;
65
+ }
66
+
67
+ /**
68
+ * The floor that applies to a release line: the highest floor whose major is not above its major.
69
+ * @param {FrameworkVersionPolicyEntry} entry
70
+ * @param {readonly [number, number, number]} version
71
+ * @returns {readonly [number, number, number] | null}
72
+ */
73
+ function applicableFloor(entry, version) {
74
+ let floor = null;
75
+ for (const candidate of entry.floors) {
76
+ const parsed = parseStableVersion(candidate);
77
+ if (parsed !== null && parsed[0] <= version[0]) floor = parsed;
78
+ }
79
+ return floor;
80
+ }
81
+
82
+ /**
83
+ * @param {unknown} packageName
84
+ * @param {unknown} version
85
+ * @param {FrameworkVersionPolicy} [policy]
86
+ * @returns {"admitted" | "invalid_version" | "below_security_minimum" | "known_vulnerable"}
87
+ */
88
+ export function frameworkVersionVerdict(packageName, version, policy = FRAMEWORK_VERSION_POLICY) {
89
+ const entry = packagePolicy(packageName, policy);
90
+ const parsed = parseStableVersion(version);
91
+ if (entry === null || parsed === null) return "invalid_version";
92
+ const floor = applicableFloor(entry, parsed);
93
+ if (floor === null || compareStableVersions(parsed, floor) < 0) return "below_security_minimum";
94
+ for (const [introduced, fixed] of entry.denied) {
95
+ const from = parseStableVersion(introduced);
96
+ const to = fixed === null ? null : parseStableVersion(fixed);
97
+ if (
98
+ from !== null &&
99
+ compareStableVersions(parsed, from) >= 0 &&
100
+ (to === null || compareStableVersions(parsed, to) < 0)
101
+ )
102
+ return "known_vulnerable";
103
+ }
104
+ return "admitted";
105
+ }
106
+
107
+ /**
108
+ * The lowest release a customer can move to from the line of `version`: its floor (or the lowest
109
+ * floor for an unknown or older line), raised past a denied range that contains it. A range or a
110
+ * prerelease is placed on the line of its numeric core.
111
+ * @param {unknown} packageName
112
+ * @param {unknown} version
113
+ * @param {FrameworkVersionPolicy} [policy]
114
+ * @returns {string}
115
+ */
116
+ export function frameworkVersionMinimum(packageName, version, policy = FRAMEWORK_VERSION_POLICY) {
117
+ const entry = packagePolicy(packageName, policy);
118
+ if (entry === null) throw new TypeError("Framework version package is not governed");
119
+ const lowest = parseStableVersion(entry.floors[0]);
120
+ if (lowest === null) throw new TypeError("Framework version policy is invalid");
121
+ const core =
122
+ typeof version === "string"
123
+ ? /^[~^]?((?:0|[1-9][0-9]{0,5})\.(?:0|[1-9][0-9]{0,5})\.(?:0|[1-9][0-9]{0,5}))(?:[-+].*)?$/u.exec(
124
+ version,
125
+ )
126
+ : null;
127
+ const parsed = parseStableVersion(core?.[1]);
128
+ let minimum = (parsed === null ? null : applicableFloor(entry, parsed)) ?? lowest;
129
+ // Overlapping advisories chain, and a floor can sit inside a denied range: raise the candidate
130
+ // past every fixed range that contains it until none does.
131
+ let candidate = parsed !== null && compareStableVersions(parsed, minimum) >= 0 ? parsed : minimum;
132
+ for (let raised = true; raised; ) {
133
+ raised = false;
134
+ for (const [introduced, fixed] of entry.denied) {
135
+ const from = parseStableVersion(introduced);
136
+ const to = fixed === null ? null : parseStableVersion(fixed);
137
+ if (
138
+ from !== null &&
139
+ to !== null &&
140
+ compareStableVersions(candidate, from) >= 0 &&
141
+ compareStableVersions(candidate, to) < 0
142
+ ) {
143
+ candidate = to;
144
+ minimum = to;
145
+ raised = true;
146
+ }
147
+ }
148
+ }
149
+ return minimum.join(".");
150
+ }
151
+
152
+ /**
153
+ * Next.js 16 and later build with Webpack explicitly; Next.js 15 builds with Webpack by default.
154
+ * @param {unknown} version
155
+ * @returns {readonly string[]}
156
+ */
157
+ export function nextBuildArguments(version) {
158
+ const parsed = parseStableVersion(version);
159
+ if (parsed === null) throw new TypeError("Next.js version is invalid");
160
+ return parsed[0] >= 16 ? Object.freeze(["--webpack"]) : Object.freeze([]);
19
161
  }
20
162
 
21
163
  const TYPESCRIPT_BUILD_STAGE = /^tsc(?:[ \t]+(?:--noEmit|-b|--build))?$/u;
@@ -1 +1,15 @@
1
- export { isAdmittedFrameworkBuildScript, PINNED_BUN_VERSION } from "./framework-build-script.mjs";
1
+ export {
2
+ compareStableVersions,
3
+ FRAMEWORK_VERSION_POLICY,
4
+ frameworkVersionMinimum,
5
+ frameworkVersionVerdict,
6
+ isAdmittedFrameworkBuildScript,
7
+ nextBuildArguments,
8
+ parseStableVersion,
9
+ PINNED_BUN_VERSION,
10
+ } from "./framework-build-script.mjs";
11
+ export type {
12
+ FrameworkVersionPackage,
13
+ FrameworkVersionPolicy,
14
+ FrameworkVersionPolicyEntry,
15
+ } from "./framework-build-script.mjs";