@amerged/ohmyhost-cli 0.1.59 → 0.1.62

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.
@@ -0,0 +1,90 @@
1
+ const ulid = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/u;
2
+ function record(raw: unknown, keys: readonly string[]): Record<string, unknown> {
3
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
4
+ throw new TypeError("Invalid connection response");
5
+ const value = raw as Record<string, unknown>;
6
+ if (Object.keys(value).length !== keys.length || keys.some((key) => !Object.hasOwn(value, key)))
7
+ throw new TypeError("Invalid connection response");
8
+ return value;
9
+ }
10
+ function date(raw: unknown): void {
11
+ if (typeof raw !== "string" || !Number.isFinite(Date.parse(raw)))
12
+ throw new TypeError("Invalid connection response");
13
+ }
14
+ function items(raw: unknown): void {
15
+ if (!Array.isArray(raw) || raw.length > 10000) throw new TypeError("Invalid connection response");
16
+ for (const row of raw) {
17
+ const v = record(row, ["id", "name"]);
18
+ if (
19
+ !Number.isSafeInteger(v["id"]) ||
20
+ Number(v["id"]) < 1 ||
21
+ typeof v["name"] !== "string" ||
22
+ !v["name"] ||
23
+ v["name"].length > 1024
24
+ )
25
+ throw new TypeError("Invalid connection response");
26
+ }
27
+ }
28
+ export function parseConnectionResponse(
29
+ kind:
30
+ | "connection-begin"
31
+ | "connection-list"
32
+ | "connection-status"
33
+ | "connection-discover"
34
+ | "connection-disconnect",
35
+ raw: unknown,
36
+ expectedOrigin?: string,
37
+ ): unknown {
38
+ if (kind === "connection-begin") {
39
+ const v = record(raw, ["request_id", "url", "expires_at"]);
40
+ date(v["expires_at"]);
41
+ if (
42
+ typeof v["request_id"] !== "string" ||
43
+ !/^[a-f0-9]{64}$/u.test(v["request_id"]) ||
44
+ typeof v["url"] !== "string"
45
+ )
46
+ throw new TypeError("Invalid connection response");
47
+ const url = new URL(v["url"]);
48
+ if (
49
+ !["https://app.ohmyho.st", "https://dev.app.ohmyho.st"].includes(url.origin) ||
50
+ (expectedOrigin !== undefined && url.origin !== expectedOrigin) ||
51
+ url.pathname !== "/connections/authorize" ||
52
+ url.hash ||
53
+ url.searchParams.size !== 1 ||
54
+ !/^[A-Za-z0-9_-]{43}$/u.test(url.searchParams.get("request") ?? "")
55
+ )
56
+ throw new TypeError("Invalid connection response");
57
+ } else if (kind === "connection-status") {
58
+ const v = record(raw, ["state", "expires_at"]);
59
+ date(v["expires_at"]);
60
+ if (!["pending", "consumed", "expired"].includes(String(v["state"])))
61
+ throw new TypeError("Invalid connection response");
62
+ } else if (kind === "connection-disconnect") {
63
+ const v = record(raw, ["state"]);
64
+ if (!["disconnected", "revocation_pending"].includes(String(v["state"])))
65
+ throw new TypeError("Invalid connection response");
66
+ } else if (kind === "connection-discover") {
67
+ const v = record(raw, ["organizations", "teams", "connections"]);
68
+ items(v["organizations"]);
69
+ items(v["teams"]);
70
+ items(v["connections"]);
71
+ } else {
72
+ const v = record(raw, ["connections"]);
73
+ if (!Array.isArray(v["connections"]) || v["connections"].length > 10000)
74
+ throw new TypeError("Invalid connection response");
75
+ for (const row of v["connections"]) {
76
+ const grant = record(row, ["id", "provider", "state", "created_at"]);
77
+ date(grant["created_at"]);
78
+ if (
79
+ typeof grant["id"] !== "string" ||
80
+ !ulid.test(grant["id"]) ||
81
+ grant["provider"] !== "make" ||
82
+ !["active", "refreshing", "reconnect_required", "disconnecting", "disconnected"].includes(
83
+ String(grant["state"]),
84
+ )
85
+ )
86
+ throw new TypeError("Invalid connection response");
87
+ }
88
+ }
89
+ return raw;
90
+ }
@@ -124,7 +124,7 @@ export const FRAMEWORK_ADMISSION_CONFORMANCE_CORPUS: Readonly<{
124
124
  Readonly<{ diagnostic: FrameworkConversionDiagnostic }>)[];
125
125
  }> = Object.freeze({
126
126
  admitted: Object.freeze([
127
- corpusCase("Next.js 16.4.1 with npm on the edge runtime", nextSource()),
127
+ corpusCase("Next.js 16.4.5 with npm on the edge runtime", nextSource()),
128
128
  corpusCase("Next.js 17.0.0, a later stable major", nextSource({ declared: "17.0.0" })),
129
129
  corpusCase(
130
130
  "Vite ^8.2.0 resolved to 8.3.4 by pnpm-lock.yaml",
@@ -144,26 +144,26 @@ export const FRAMEWORK_ADMISSION_CONFORMANCE_CORPUS: Readonly<{
144
144
  Object.freeze({
145
145
  ...corpusCase(
146
146
  "Next.js ^16.3.0 with bun.lock, which ohmyho.st does not resolve",
147
- nextSource({ declared: "^16.3.0", resolved: "16.4.1", manager: "bun" }),
147
+ nextSource({ declared: "^16.3.0", resolved: "16.4.5", manager: "bun" }),
148
148
  ),
149
149
  packages: Object.freeze(["next"] as const),
150
150
  }),
151
151
  ]),
152
152
  refused: Object.freeze([
153
153
  refusedCase(
154
- "Next.js 16.4.0 below the 16.x security minimum",
155
- nextSource({ declared: "16.4.0" }),
156
- versionFinding("package-lock.json", "next", "16.4.0", "16.4.1"),
154
+ "Next.js 16.4.4 below the 16.x security minimum",
155
+ nextSource({ declared: "16.4.4" }),
156
+ versionFinding("package-lock.json", "next", "16.4.4", "16.4.5"),
157
157
  ),
158
158
  refusedCase(
159
159
  "Next.js 15.5.28 declared with yarn, because no 15.x release is admitted",
160
160
  nextSource({ declared: "15.5.28", manager: "yarn" }),
161
- versionFinding("package.json", "next", "15.5.28", "16.4.1"),
161
+ versionFinding("package.json", "next", "15.5.28", "16.4.5"),
162
162
  ),
163
163
  refusedCase(
164
164
  "Next.js ^16.3.0 resolved to 16.4.0 by package-lock.json",
165
165
  nextSource({ declared: "^16.3.0", resolved: "16.4.0" }),
166
- versionFinding("package-lock.json", "next", "16.4.0", "16.4.1"),
166
+ versionFinding("package-lock.json", "next", "16.4.0", "16.4.5"),
167
167
  ),
168
168
  refusedCase(
169
169
  "TanStack Start 1.168.59 resolved by pnpm-lock.yaml below its security minimum",
@@ -351,7 +351,7 @@ function nextSource(
351
351
  ): Readonly<Record<string, string>> {
352
352
  const manager = options.manager ?? "npm";
353
353
  const [packageManager, lockfile] = CORPUS_MANAGERS[manager];
354
- const next = options.declared ?? "16.4.1";
354
+ const next = options.declared ?? "16.4.5";
355
355
  const react = { react: "19.1.2", "react-dom": "19.1.2" };
356
356
  const runtime = options.field === "devDependencies" ? react : { next, ...react };
357
357
  return Object.freeze({
@@ -377,8 +377,8 @@ function nextSource(
377
377
  }
378
378
 
379
379
  /**
380
- * The next.config.ts and Tailwind CSS files and packages `create-next-app@16.4.1 --yes` writes, in
381
- * an App Router source with the packageManager, lockfile and ohmyhost.yaml ohmyho.st requires;
380
+ * The next.config.ts and Tailwind CSS files modeled on `create-next-app@16.4.1 --yes`, with patched
381
+ * Next.js packages in an App Router source and the packageManager, lockfile and ohmyhost.yaml ohmyho.st requires;
382
382
  * `tailwind: false` is its --no-tailwind output. On Turbopack, its default bundler, it adds only the
383
383
  * Turbopack rule for Tailwind CSS; `postcss` adds the postcss.config.mjs and @tailwindcss/postcss it
384
384
  * writes for any other bundler.
@@ -387,7 +387,7 @@ function createNextAppSource(
387
387
  options: Readonly<{ tailwind: boolean; postcss?: boolean }>,
388
388
  ): Readonly<Record<string, string>> {
389
389
  const [packageManager, lockfile] = CORPUS_MANAGERS.npm;
390
- const runtime = { next: "16.4.1", react: "19.3.0", "react-dom": "19.3.0" };
390
+ const runtime = { next: "16.4.5", react: "19.3.0", "react-dom": "19.3.0" };
391
391
  const postcss = options.postcss === true;
392
392
  return Object.freeze({
393
393
  "ohmyhost.yaml": corpusConfiguration("npm", ".open-next/assets", "edge"),
@@ -15,13 +15,14 @@ export const PINNED_BUN_VERSION = "1.2.22";
15
15
  * upper bound: later patches, minors and majors reach the real build, which reports adapter failures.
16
16
  * Denied ranges are half-open [introduced, fixed); a null fix denies every later release.
17
17
  *
18
- * next: GHSA-2464-fhr4-w9xw (critical, remote code execution through the Image Optimization API with
18
+ * next: GHSA-mfr8-8qww-v76h (information disclosure across root params, fixed in 16.4.5).
19
+ * Earlier floors: GHSA-2464-fhr4-w9xw (critical, remote code execution through the Image Optimization API with
19
20
  * SVG and sharp before 0.35.5) and GHSA-p3m5-59mp-jv5r (high, denial of service through Server
20
21
  * Actions), both fixed in 15.5.28 and 16.4.1; GHSA-673q-mjm6-r5xr (critical, remote code execution
21
22
  * through `use cache` functions that return typed arrays, Next.js 16 only, fixed in 16.4.1).
22
23
  * There is no 15.x floor: the pinned OpenNext has refused Next.js 15 since 21 October 2026, so every 15.x
23
- * release is refused with the minimum 16.4.1 instead of sending a customer to 15.5.28 and a failing build.
24
- * Earlier floors: GHSA-4jqv-mc3x-m676 and GHSA-mcj8-r9mp-w47p (fixed in 15.5.27 and 16.3.8);
24
+ * release is refused with the minimum 16.4.5 instead of sending a customer to 15.5.28 and a failing build.
25
+ * GHSA-4jqv-mc3x-m676 and GHSA-mcj8-r9mp-w47p (fixed in 15.5.27 and 16.3.8);
25
26
  * GHSA-cjq9-62q9-8jv4, GHSA-f87g-xv8r-7p7x, GHSA-3w37-wq28-93x7, GHSA-h694-7cp9-m8p3 and
26
27
  * GHSA-39w2-rjm5-chcv (16.3.8).
27
28
  * @tanstack/react-start: GHSA-qx66-fv34-fjm8 (fixed in 1.168.60).
@@ -34,7 +35,7 @@ export const FRAMEWORK_VERSION_POLICY = Object.freeze({
34
35
  floors: Object.freeze(["14.4.0"]),
35
36
  denied: Object.freeze([]),
36
37
  }),
37
- next: Object.freeze({ floors: Object.freeze(["16.4.1"]), denied: Object.freeze([]) }),
38
+ next: Object.freeze({ floors: Object.freeze(["16.4.5"]), denied: Object.freeze([]) }),
38
39
  vite: Object.freeze({ floors: Object.freeze(["5.4.6"]), denied: Object.freeze([]) }),
39
40
  "@tanstack/react-start": Object.freeze({
40
41
  floors: Object.freeze(["1.168.60"]),
@@ -16,6 +16,8 @@ export * from "./browser-capabilities.js";
16
16
  export * from "./problem-policy.js";
17
17
  export * from "./secret-names.js";
18
18
  export * from "./project-data-changes.js";
19
+ export * from "./preview-view.js";
20
+ export type * from "./previews.js";
19
21
 
20
22
  export type OhmyhostRuntimeMode = "static" | "edge" | "functions" | "auto";
21
23
 
@@ -234,6 +236,8 @@ function forbiddenEgressHostname(hostname: string): boolean {
234
236
  /(?:^|\.)ohmyho-(?:mail|storage)-gateway-[a-z0-9][a-z0-9-]*\.[a-z0-9][a-z0-9-]*\.workers\.dev\.?$/u.test(
235
237
  normalized,
236
238
  ) ||
239
+ normalized.replace(/\.+$/u, "") === "connect.ohmyho.st" ||
240
+ normalized.replace(/\.+$/u, "").endsWith(".connect.ohmyho.st") ||
237
241
  normalized === "localhost" ||
238
242
  normalized.endsWith(".localhost") ||
239
243
  normalized.endsWith(".local") ||
@@ -0,0 +1,49 @@
1
+ /** Public preview response, validated before a CLI or agent presents its private URL. */
2
+ export interface PreviewView {
3
+ readonly id: string;
4
+ readonly project_id: string;
5
+ readonly environment: "dev" | "prod";
6
+ readonly status: "cold" | "starting" | "ready" | "sleeping";
7
+ readonly url: string;
8
+ readonly source: Readonly<{ sequence: number; commit_sha: string }> | null;
9
+ }
10
+
11
+ export function parsePreviewView(
12
+ value: unknown,
13
+ scope?: { projectId: string; environment: "dev" | "prod" },
14
+ ): PreviewView {
15
+ if (!value || typeof value !== "object" || Array.isArray(value))
16
+ throw new TypeError("Invalid preview response");
17
+ const row = value as Record<string, unknown>;
18
+ const ulid = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/u;
19
+ if (
20
+ Object.keys(row).sort().join(",") !== "environment,id,project_id,source,status,url" ||
21
+ typeof row["id"] !== "string" ||
22
+ !ulid.test(row["id"]) ||
23
+ typeof row["project_id"] !== "string" ||
24
+ !ulid.test(row["project_id"]) ||
25
+ (row["environment"] !== "dev" && row["environment"] !== "prod") ||
26
+ !["cold", "starting", "ready", "sleeping"].includes(String(row["status"])) ||
27
+ typeof row["url"] !== "string" ||
28
+ !/^https:\/\/[a-z2-7]{51}[aq]\.preview(?:\.dev)?\.omh\.st$/u.test(row["url"]) ||
29
+ (scope !== undefined &&
30
+ (row["project_id"] !== scope.projectId || row["environment"] !== scope.environment))
31
+ )
32
+ throw new TypeError("Invalid preview response");
33
+ if (row["source"] !== null) {
34
+ const source = row["source"];
35
+ if (!source || typeof source !== "object" || Array.isArray(source))
36
+ throw new TypeError("Invalid preview response");
37
+ const item = source as Record<string, unknown>;
38
+ if (
39
+ Object.keys(item).sort().join(",") !== "commit_sha,sequence" ||
40
+ typeof item["sequence"] !== "number" ||
41
+ !Number.isSafeInteger(item["sequence"]) ||
42
+ item["sequence"] <= 0 ||
43
+ typeof item["commit_sha"] !== "string" ||
44
+ !/^(?!0{40}$)[0-9a-f]{40}$/u.test(item["commit_sha"])
45
+ )
46
+ throw new TypeError("Invalid preview response");
47
+ }
48
+ return value as PreviewView;
49
+ }